From 33ea41a100e8eea891c1d9d95fe34e346c3e71d1 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Fri, 29 Nov 2024 21:00:10 +0100 Subject: [PATCH] run pre-commit --- .../templates/wizards/qgis/qgis_test/file.cpp | 27 +- src/app/3d/qgs3danimationexportdialog.cpp | 25 +- src/app/3d/qgs3danimationexportdialog.h | 4 +- src/app/3d/qgs3danimationwidget.cpp | 23 +- src/app/3d/qgs3dapputils.cpp | 18 +- src/app/3d/qgs3dapputils.h | 2 - src/app/3d/qgs3ddebugwidget.cpp | 71 +- src/app/3d/qgs3dicongenerator.cpp | 3 +- src/app/3d/qgs3dicongenerator.h | 1 - src/app/3d/qgs3dmapcanvaswidget.cpp | 105 +- src/app/3d/qgs3dmapcanvaswidget.h | 4 +- src/app/3d/qgs3dmapconfigwidget.cpp | 58 +- src/app/3d/qgs3dmaptoolidentify.cpp | 11 +- src/app/3d/qgs3dmaptoolmeasureline.cpp | 13 +- src/app/3d/qgs3dmeasuredialog.cpp | 32 +- src/app/3d/qgs3dmeasuredialog.h | 4 +- src/app/3d/qgs3dmodelsourcelineedit.h | 3 +- src/app/3d/qgs3dnavigationwidget.cpp | 66 +- src/app/3d/qgs3doptions.cpp | 9 +- src/app/3d/qgs3doptions.h | 4 - src/app/3d/qgs3dviewsmanagerdialog.h | 1 + src/app/3d/qgsgoochmaterialwidget.cpp | 12 +- src/app/3d/qgsgoochmaterialwidget.h | 1 - src/app/3d/qgslightswidget.cpp | 18 +- src/app/3d/qgslightswidget.h | 4 +- src/app/3d/qgsline3dsymbolwidget.cpp | 28 +- src/app/3d/qgsline3dsymbolwidget.h | 1 - src/app/3d/qgsmap3dexportwidget.cpp | 23 +- src/app/3d/qgsmap3dexportwidget.h | 2 + src/app/3d/qgsmaterialwidget.cpp | 19 +- src/app/3d/qgsmaterialwidget.h | 3 +- src/app/3d/qgsmesh3dsymbolwidget.cpp | 45 +- src/app/3d/qgsmesh3dsymbolwidget.h | 5 +- src/app/3d/qgsmeshlayer3drendererwidget.cpp | 8 +- src/app/3d/qgsmetalroughmaterialwidget.cpp | 11 +- src/app/3d/qgsnullmaterialwidget.h | 1 - src/app/3d/qgsphongmaterialwidget.cpp | 13 +- src/app/3d/qgsphongtexturedmaterialwidget.cpp | 7 +- src/app/3d/qgspoint3dsymbolwidget.cpp | 16 +- src/app/3d/qgspointcloud3dsymbolwidget.cpp | 49 +- src/app/3d/qgspointcloud3dsymbolwidget.h | 4 +- .../3d/qgspointcloudlayer3drendererwidget.cpp | 4 +- src/app/3d/qgspolygon3dsymbolwidget.cpp | 10 +- src/app/3d/qgsrulebased3drendererwidget.cpp | 18 +- src/app/3d/qgsrulebased3drendererwidget.h | 12 +- src/app/3d/qgsshadowrenderingsettingswidget.h | 1 - src/app/3d/qgssimplelinematerialwidget.cpp | 6 +- src/app/3d/qgssimplelinematerialwidget.h | 1 - .../3d/qgsskyboxrenderingsettingswidget.cpp | 17 +- src/app/3d/qgssymbol3dwidget.cpp | 17 +- src/app/3d/qgssymbol3dwidget.h | 4 +- src/app/3d/qgsvectorlayer3drendererwidget.cpp | 9 +- src/app/3d/qgsvectorlayer3drendererwidget.h | 5 +- .../qgsannotationitempropertieswidget.cpp | 9 +- .../qgsannotationitempropertieswidget.h | 11 +- .../qgsannotationlayerproperties.cpp | 3 +- .../qgsannotationlayerproperties.h | 3 +- .../browser/qgsinbuiltdataitemproviders.cpp | 476 +-- src/app/browser/qgsinbuiltdataitemproviders.h | 75 +- src/app/canvas/qgsappcanvasfiltering.cpp | 26 +- src/app/canvas/qgsappcanvasfiltering.h | 8 +- src/app/canvas/qgscanvasrefreshblocker.cpp | 1 - src/app/canvas/qgscanvasrefreshblocker.h | 2 - .../decorations/qgsdecorationcopyright.cpp | 1 - src/app/decorations/qgsdecorationcopyright.h | 1 - .../qgsdecorationcopyrightdialog.cpp | 10 +- src/app/decorations/qgsdecorationgrid.cpp | 73 +- src/app/decorations/qgsdecorationgrid.h | 43 +- .../decorations/qgsdecorationgriddialog.cpp | 25 +- src/app/decorations/qgsdecorationgriddialog.h | 1 - src/app/decorations/qgsdecorationimage.cpp | 6 +- src/app/decorations/qgsdecorationimage.h | 8 +- .../decorations/qgsdecorationimagedialog.cpp | 32 +- src/app/decorations/qgsdecorationitem.cpp | 4 +- src/app/decorations/qgsdecorationitem.h | 2 - .../decorations/qgsdecorationlayoutextent.cpp | 15 +- .../decorations/qgsdecorationlayoutextent.h | 3 +- .../qgsdecorationlayoutextentdialog.cpp | 2 +- .../qgsdecorationlayoutextentdialog.h | 1 - .../decorations/qgsdecorationnortharrow.cpp | 18 +- src/app/decorations/qgsdecorationnortharrow.h | 4 +- .../qgsdecorationnortharrowdialog.cpp | 41 +- src/app/decorations/qgsdecorationoverlay.cpp | 2 +- src/app/decorations/qgsdecorationscalebar.cpp | 25 +- src/app/decorations/qgsdecorationscalebar.h | 5 +- .../qgsdecorationscalebardialog.cpp | 15 +- src/app/decorations/qgsdecorationtitle.cpp | 1 - src/app/decorations/qgsdecorationtitle.h | 1 - .../decorations/qgsdecorationtitledialog.cpp | 15 +- .../qgsdocumentationpanelwidget.cpp | 6 +- .../qgsdocumentationpanelwidget.h | 4 - .../networklogger/qgsnetworklogger.cpp | 37 +- .../devtools/networklogger/qgsnetworklogger.h | 13 +- .../networklogger/qgsnetworkloggernode.cpp | 83 +- .../networklogger/qgsnetworkloggernode.h | 29 +- .../qgsnetworkloggerpanelwidget.cpp | 22 +- .../qgsnetworkloggerpanelwidget.h | 6 +- .../qgsnetworkloggerwidgetfactory.h | 4 +- .../profiler/qgsprofilerpanelwidget.cpp | 11 +- .../profiler/qgsprofilerpanelwidget.h | 8 - .../profiler/qgsprofilerwidgetfactory.h | 5 +- src/app/devtools/qgsappdevtoolutils.h | 4 +- src/app/devtools/qgsdevtoolsmodelnode.cpp | 22 +- src/app/devtools/qgsdevtoolsmodelnode.h | 25 +- .../querylogger/qgsappquerylogger.cpp | 27 +- .../devtools/querylogger/qgsappquerylogger.h | 13 +- .../qgsdatabasequeryloggernode.cpp | 24 +- .../querylogger/qgsdatabasequeryloggernode.h | 13 +- .../querylogger/qgsqueryloggerpanelwidget.cpp | 22 +- .../querylogger/qgsqueryloggerpanelwidget.h | 7 +- .../querylogger/qgsqueryloggerwidgetfactory.h | 4 +- src/app/dwg/qgsdwgimportdialog.cpp | 25 +- src/app/dwg/qgsdwgimportdialog.h | 1 - src/app/dwg/qgsdwgimporter.cpp | 592 +-- .../qgselevationprofileexportsettingswidget.h | 2 - .../qgselevationprofileimageexportdialog.cpp | 1 - .../qgselevationprofileimageexportdialog.h | 2 - .../qgselevationprofilepdfexportdialog.cpp | 6 +- .../qgselevationprofilepdfexportdialog.h | 2 - .../qgselevationprofiletoolidentify.cpp | 11 +- .../qgselevationprofiletoolidentify.h | 7 +- .../qgselevationprofiletoolmeasure.cpp | 13 +- .../qgselevationprofiletoolmeasure.h | 4 - .../elevation/qgselevationprofilewidget.cpp | 151 +- src/app/elevation/qgselevationprofilewidget.h | 21 +- src/app/elevation/qgsmaptoolprofilecurve.cpp | 3 +- src/app/elevation/qgsmaptoolprofilecurve.h | 4 +- .../qgsmaptoolprofilecurvefromfeature.cpp | 3 +- src/app/georeferencer/qgsgcpcanvasitem.cpp | 5 +- src/app/georeferencer/qgsgcpcanvasitem.h | 5 +- src/app/georeferencer/qgsgcplist.cpp | 15 +- src/app/georeferencer/qgsgcplist.h | 23 +- src/app/georeferencer/qgsgcplistmodel.cpp | 25 +- src/app/georeferencer/qgsgcplistmodel.h | 2 +- src/app/georeferencer/qgsgcplistwidget.cpp | 31 +- src/app/georeferencer/qgsgcplistwidget.h | 8 +- .../georeferencer/qgsgeorefconfigdialog.cpp | 2 - src/app/georeferencer/qgsgeorefdatapoint.cpp | 4 +- src/app/georeferencer/qgsgeorefdatapoint.h | 5 +- src/app/georeferencer/qgsgeorefdelegates.cpp | 12 +- src/app/georeferencer/qgsgeorefdelegates.h | 18 +- src/app/georeferencer/qgsgeorefmainwindow.cpp | 193 +- src/app/georeferencer/qgsgeorefmainwindow.h | 15 +- src/app/georeferencer/qgsgeoreftransform.cpp | 13 +- src/app/georeferencer/qgsgeoreftransform.h | 5 +- src/app/georeferencer/qgsimagewarper.cpp | 94 +- src/app/georeferencer/qgsimagewarper.h | 59 +- src/app/georeferencer/qgsmapcoordsdialog.cpp | 3 +- src/app/georeferencer/qgsmapcoordsdialog.h | 2 - .../georeferencer/qgsrasterchangecoords.cpp | 8 +- src/app/georeferencer/qgsresidualplotitem.cpp | 7 +- src/app/georeferencer/qgsresidualplotitem.h | 5 +- .../qgstransformsettingsdialog.cpp | 33 +- .../qgstransformsettingsdialog.h | 1 - .../qgsvalidateddoublespinbox.cpp | 2 +- src/app/gps/qgsappgpsconnection.cpp | 13 +- src/app/gps/qgsappgpsconnection.h | 6 +- src/app/gps/qgsappgpsdigitizing.cpp | 47 +- src/app/gps/qgsappgpsdigitizing.h | 6 +- src/app/gps/qgsappgpslogging.cpp | 95 +- src/app/gps/qgsappgpslogging.h | 17 +- src/app/gps/qgsappgpssettingsmenu.cpp | 47 +- src/app/gps/qgsappgpssettingsmenu.h | 7 +- src/app/gps/qgsgpsbearingitem.cpp | 3 +- src/app/gps/qgsgpsbearingitem.h | 2 - src/app/gps/qgsgpscanvasbridge.cpp | 46 +- src/app/gps/qgsgpscanvasbridge.h | 4 +- src/app/gps/qgsgpsinformationwidget.cpp | 79 +- src/app/gps/qgsgpsinformationwidget.h | 8 +- src/app/gps/qgsgpsmarker.cpp | 6 +- src/app/gps/qgsgpsmarker.h | 5 +- src/app/gps/qgsgpstoolbar.cpp | 72 +- src/app/gps/qgsgpstoolbar.h | 6 +- src/app/labeling/qgslabelpropertydialog.cpp | 27 +- src/app/labeling/qgslabelpropertydialog.h | 15 +- .../qgsmaptoolchangelabelproperties.cpp | 11 +- .../qgsmaptoolchangelabelproperties.h | 4 +- src/app/labeling/qgsmaptoollabel.cpp | 191 +- src/app/labeling/qgsmaptoollabel.h | 18 +- src/app/labeling/qgsmaptoolmovelabel.cpp | 54 +- src/app/labeling/qgsmaptoolmovelabel.h | 4 +- src/app/labeling/qgsmaptoolpinlabels.cpp | 16 +- src/app/labeling/qgsmaptoolpinlabels.h | 12 +- src/app/labeling/qgsmaptoolrotatelabel.cpp | 21 +- src/app/labeling/qgsmaptoolrotatelabel.h | 3 +- src/app/labeling/qgsmaptoolshowhidelabels.cpp | 18 +- src/app/labeling/qgsmaptoolshowhidelabels.h | 7 +- src/app/layers/qgsapplayerhandling.cpp | 256 +- src/app/layers/qgsapplayerhandling.h | 47 +- src/app/layout/qgslayout3dmapwidget.cpp | 18 +- src/app/layout/qgslayout3dmapwidget.h | 2 +- src/app/layout/qgslayoutappmenuprovider.cpp | 38 +- src/app/layout/qgslayoutappmenuprovider.h | 3 - src/app/layout/qgslayoutdesignerdialog.cpp | 833 ++-- src/app/layout/qgslayoutdesignerdialog.h | 36 +- src/app/layout/qgslayoutimagedrophandler.cpp | 7 +- src/app/layout/qgslayoutimagedrophandler.h | 3 +- src/app/layout/qgslayoutmanagerdialog.cpp | 29 +- src/app/layout/qgslayoutmanagerdialog.h | 3 +- .../qgsreportfieldgroupsectionwidget.cpp | 8 +- .../layout/qgsreportfieldgroupsectionwidget.h | 4 +- .../layout/qgsreportlayoutsectionwidget.cpp | 2 +- src/app/layout/qgsreportlayoutsectionwidget.h | 4 +- src/app/layout/qgsreportorganizerwidget.cpp | 27 +- src/app/layout/qgsreportorganizerwidget.h | 7 +- src/app/layout/qgsreportsectionmodel.cpp | 7 +- src/app/layout/qgsreportsectionmodel.h | 6 +- src/app/layout/qgsreportsectionwidget.cpp | 5 +- src/app/layout/qgsreportsectionwidget.h | 4 +- src/app/locator/qgsactionlocatorfilter.cpp | 5 +- src/app/locator/qgsactionlocatorfilter.h | 10 +- .../qgsactivelayerfeatureslocatorfilter.cpp | 44 +- .../qgsactivelayerfeatureslocatorfilter.h | 2 +- .../qgsalllayersfeatureslocatorfilter.cpp | 13 +- .../qgsalllayersfeatureslocatorfilter.h | 16 +- src/app/locator/qgsbookmarklocatorfilter.h | 1 - .../qgsexpressioncalculatorlocatorfilter.cpp | 1 - .../qgsexpressioncalculatorlocatorfilter.h | 2 - src/app/locator/qgsgotolocatorfilter.cpp | 31 +- src/app/locator/qgsgotolocatorfilter.h | 5 - .../locator/qgslayermetadatalocatorfilter.cpp | 6 +- .../locator/qgslayermetadatalocatorfilter.h | 1 - src/app/locator/qgslayertreelocatorfilter.cpp | 2 +- src/app/locator/qgslayertreelocatorfilter.h | 5 - src/app/locator/qgslayoutlocatorfilter.cpp | 4 +- src/app/locator/qgslayoutlocatorfilter.h | 5 - src/app/locator/qgslocatoroptionswidget.cpp | 21 +- src/app/locator/qgslocatoroptionswidget.h | 15 +- src/app/locator/qgsnominatimlocatorfilter.cpp | 4 +- src/app/locator/qgsnominatimlocatorfilter.h | 2 - src/app/locator/qgssettingslocatorfilter.cpp | 5 +- src/app/locator/qgssettingslocatorfilter.h | 4 +- src/app/main.cpp | 239 +- src/app/mainwin.cpp | 13 +- src/app/maptools/qgsappmaptools.cpp | 6 +- src/app/maptools/qgsappmaptools.h | 11 +- .../qgsavoidintersectionsoperation.cpp | 8 +- .../maptools/qgsavoidintersectionsoperation.h | 17 +- .../qgsmaptoolsdigitizingtechniquemanager.cpp | 38 +- .../qgsmaptoolsdigitizingtechniquemanager.h | 7 +- .../maptools/qgsmaptoolshapecircle2points.cpp | 1 - .../qgsmaptoolshapecircle2tangentspoint.cpp | 33 +- .../qgsmaptoolshapecircle2tangentspoint.h | 5 +- .../maptools/qgsmaptoolshapecircle3points.h | 5 +- .../qgsmaptoolshapecircle3tangents.cpp | 3 +- .../maptools/qgsmaptoolshapecircle3tangents.h | 5 +- .../maptools/qgsmaptoolshapecircleabstract.h | 10 +- .../qgsmaptoolshapecirclecenterpoint.cpp | 1 - .../qgsmaptoolshapecirclecenterpoint.h | 5 +- .../qgsmaptoolshapecircularstringabstract.cpp | 4 +- .../qgsmaptoolshapecircularstringabstract.h | 3 +- .../qgsmaptoolshapecircularstringradius.cpp | 5 +- .../qgsmaptoolshapecircularstringradius.h | 2 +- .../qgsmaptoolshapeellipseabstract.cpp | 1 - .../maptools/qgsmaptoolshapeellipseabstract.h | 4 +- .../qgsmaptoolshapeellipsecenter2points.cpp | 1 - .../qgsmaptoolshapeellipsecenter2points.h | 2 +- .../qgsmaptoolshapeellipsecenterpoint.h | 5 +- .../maptools/qgsmaptoolshapeellipseextent.h | 2 +- src/app/maptools/qgsmaptoolshapeellipsefoci.h | 2 +- .../qgsmaptoolshaperectangle3points.cpp | 5 +- .../qgsmaptoolshaperectangle3points.h | 4 +- .../qgsmaptoolshaperectangleabstract.cpp | 7 +- .../qgsmaptoolshaperectangleabstract.h | 2 +- .../qgsmaptoolshaperectanglecenter.cpp | 2 - .../maptools/qgsmaptoolshaperectanglecenter.h | 2 +- .../maptools/qgsmaptoolshaperectangleextent.h | 2 +- .../qgsmaptoolshaperegularpolygon2points.cpp | 2 +- .../qgsmaptoolshaperegularpolygon2points.h | 3 +- .../qgsmaptoolshaperegularpolygonabstract.cpp | 5 +- .../qgsmaptoolshaperegularpolygonabstract.h | 2 +- ...gsmaptoolshaperegularpolygoncentercorner.h | 2 +- ...smaptoolshaperegularpolygoncenterpoint.cpp | 1 - ...qgsmaptoolshaperegularpolygoncenterpoint.h | 2 +- src/app/mesh/qgsmaptooleditmeshframe.cpp | 309 +- src/app/mesh/qgsmaptooleditmeshframe.h | 39 +- src/app/mesh/qgsmeshcalculatordialog.cpp | 33 +- src/app/mesh/qgsmeshcalculatordialog.h | 5 +- .../mesh/qgsmeshelevationpropertieswidget.cpp | 72 +- .../mesh/qgsmeshelevationpropertieswidget.h | 15 +- .../mesh/qgsmeshselectbyexpressiondialog.cpp | 23 +- .../mesh/qgsmeshselectbyexpressiondialog.h | 1 - .../qgsmeshtransformcoordinatesdockwidget.cpp | 17 +- .../qgsmeshtransformcoordinatesdockwidget.h | 4 +- src/app/mesh/qgsnewmeshlayerdialog.cpp | 19 +- src/app/options/qgsadvancedoptions.cpp | 5 +- src/app/options/qgsadvancedoptions.h | 4 - src/app/options/qgscodeeditoroptions.cpp | 125 +- src/app/options/qgscodeeditoroptions.h | 8 +- .../options/qgscustomprojectionoptions.cpp | 38 +- src/app/options/qgscustomprojectionoptions.h | 29 +- src/app/options/qgselevationoptions.cpp | 1 - src/app/options/qgselevationoptions.h | 3 - src/app/options/qgsfontoptions.cpp | 29 +- src/app/options/qgsfontoptions.h | 3 - src/app/options/qgsgpsdeviceoptions.cpp | 80 +- src/app/options/qgsgpsdeviceoptions.h | 5 +- src/app/options/qgsgpsoptions.cpp | 36 +- src/app/options/qgsgpsoptions.h | 4 - src/app/options/qgsideoptions.cpp | 5 +- src/app/options/qgsideoptions.h | 4 - src/app/options/qgsoptions.cpp | 391 +- src/app/options/qgsoptions.h | 17 +- src/app/options/qgsoptionsutils.cpp | 3 +- src/app/options/qgsoptionsutils.h | 6 +- src/app/options/qgsrasterrenderingoptions.cpp | 44 +- src/app/options/qgsrasterrenderingoptions.h | 5 +- src/app/options/qgsrenderingoptions.cpp | 2 +- src/app/options/qgsrenderingoptions.h | 4 - src/app/options/qgsuserprofileoptions.cpp | 4 +- src/app/options/qgsuserprofileoptions.h | 3 - .../options/qgsuserprofileselectiondialog.cpp | 2 +- .../options/qgsuserprofileselectiondialog.h | 3 - src/app/options/qgsvectorrenderingoptions.cpp | 6 +- src/app/options/qgsvectorrenderingoptions.h | 3 - .../qgsapppluginmanagerinterface.h | 2 - .../pluginmanager/qgspluginitemdelegate.cpp | 7 +- src/app/pluginmanager/qgspluginmanager.cpp | 293 +- src/app/pluginmanager/qgspluginmanager.h | 3 +- .../pluginmanager/qgspluginmanager_texts.cpp | 6 - .../qgspluginsortfilterproxymodel.cpp | 26 +- .../qgspluginsortfilterproxymodel.h | 1 - ...qgspointcloudelevationpropertieswidget.cpp | 66 +- .../qgspointcloudelevationpropertieswidget.h | 4 - .../qgspointcloudlayerproperties.cpp | 17 +- .../pointcloud/qgspointcloudlayerproperties.h | 13 +- .../qgspointcloudlayerstylewidget.cpp | 2 +- .../qgspointcloudlayerstylewidget.h | 1 - .../qgsprojectelevationsettingswidget.cpp | 50 +- .../qgsprojectelevationsettingswidget.h | 3 - src/app/qgisapp.cpp | 2027 ++++----- src/app/qgisapp.h | 77 +- src/app/qgisappinterface.cpp | 49 +- src/app/qgisappinterface.h | 13 +- src/app/qgisappstylesheet.cpp | 12 +- src/app/qgisappstylesheet.h | 4 +- src/app/qgsabout.cpp | 8 +- src/app/qgsanimationexportdialog.cpp | 30 +- src/app/qgsanimationexportdialog.h | 13 +- src/app/qgsannotationwidget.cpp | 14 +- src/app/qgsannotationwidget.h | 5 +- src/app/qgsappauthrequesthandler.cpp | 10 +- src/app/qgsappauthrequesthandler.h | 3 - src/app/qgsappbrowserproviders.cpp | 166 +- src/app/qgsappbrowserproviders.h | 43 +- src/app/qgsappcoordinateoperationhandlers.cpp | 86 +- src/app/qgsappcoordinateoperationhandlers.h | 58 +- src/app/qgsapplayertreeviewmenuprovider.cpp | 370 +- src/app/qgsapplayertreeviewmenuprovider.h | 27 +- src/app/qgsappscreenshots.cpp | 25 +- src/app/qgsappsslerrorhandler.cpp | 12 +- src/app/qgsappsslerrorhandler.h | 3 - src/app/qgsappwindowmanager.h | 10 +- src/app/qgsattributetabledialog.cpp | 65 +- src/app/qgsattributetabledialog.h | 17 +- src/app/qgsbookmarkeditordialog.cpp | 1 - src/app/qgsbookmarkeditordialog.h | 5 +- src/app/qgsbookmarks.cpp | 29 +- src/app/qgsbookmarks.h | 11 +- src/app/qgsclipboard.cpp | 22 +- src/app/qgsclipboard.h | 7 +- src/app/qgscrashhandler.cpp | 19 +- src/app/qgscrashhandler.h | 9 +- src/app/qgscustomization.cpp | 41 +- src/app/qgscustomization.h | 10 +- src/app/qgsdatumtransformtablewidget.cpp | 12 +- src/app/qgsdatumtransformtablewidget.h | 4 +- src/app/qgsdelattrdialog.h | 2 +- src/app/qgsdevtoolspanelwidget.cpp | 17 +- src/app/qgsdevtoolspanelwidget.h | 4 +- src/app/qgsdiscoverrelationsdialog.cpp | 9 +- src/app/qgsdiscoverrelationsdialog.h | 1 - src/app/qgsdisplayangle.h | 2 +- src/app/qgsdxfexportdialog.cpp | 97 +- src/app/qgsdxfexportdialog.h | 9 +- ...elevationshadingrenderersettingswidget.cpp | 36 +- src/app/qgsfeatureaction.cpp | 19 +- src/app/qgsfeatureaction.h | 7 +- src/app/qgsfirstrundialog.cpp | 5 +- src/app/qgsfixattributedialog.cpp | 9 +- src/app/qgsfixattributedialog.h | 2 - src/app/qgsformannotationdialog.cpp | 4 +- src/app/qgsformannotationdialog.h | 2 +- src/app/qgsgeometryvalidationdock.cpp | 19 +- src/app/qgsgeometryvalidationdock.h | 1 - src/app/qgsgeometryvalidationmodel.cpp | 13 +- src/app/qgsgeometryvalidationmodel.h | 21 +- src/app/qgsgeometryvalidationservice.cpp | 59 +- src/app/qgsgeometryvalidationservice.h | 35 +- src/app/qgsguivectorlayertools.cpp | 28 +- src/app/qgsguivectorlayertools.h | 2 - src/app/qgshandlebadlayers.cpp | 111 +- src/app/qgshandlebadlayers.h | 14 +- src/app/qgshtmlannotationdialog.cpp | 4 +- src/app/qgshtmlannotationdialog.h | 2 +- src/app/qgsidentifyresultsdialog.cpp | 185 +- src/app/qgsidentifyresultsdialog.h | 65 +- src/app/qgslayernotesmanager.cpp | 3 +- src/app/qgslayernotesmanager.h | 2 - src/app/qgslayerstylingwidget.cpp | 53 +- src/app/qgslayerstylingwidget.h | 5 +- src/app/qgslayertreegrouppropertieswidget.cpp | 3 +- src/app/qgslayertreegrouppropertieswidget.h | 9 +- src/app/qgslayertreeviewbadlayerindicator.cpp | 2 +- src/app/qgslayertreeviewbadlayerindicator.h | 14 +- src/app/qgslayertreeviewembeddedindicator.cpp | 4 +- src/app/qgslayertreeviewembeddedindicator.h | 2 +- src/app/qgslayertreeviewfilterindicator.cpp | 8 +- src/app/qgslayertreeviewfilterindicator.h | 2 +- src/app/qgslayertreeviewindicatorprovider.cpp | 19 +- src/app/qgslayertreeviewindicatorprovider.h | 5 +- .../qgslayertreeviewlowaccuracyindicator.cpp | 3 - .../qgslayertreeviewlowaccuracyindicator.h | 3 +- src/app/qgslayertreeviewmemoryindicator.cpp | 1 - src/app/qgslayertreeviewnocrsindicator.cpp | 2 +- src/app/qgslayertreeviewnocrsindicator.h | 1 - .../qgslayertreeviewnonremovableindicator.cpp | 3 +- .../qgslayertreeviewnonremovableindicator.h | 3 - src/app/qgslayertreeviewnotesindicator.cpp | 1 - src/app/qgslayertreeviewnotesindicator.h | 3 +- src/app/qgslayertreeviewofflineindicator.cpp | 2 - src/app/qgslayertreeviewtemporalindicator.cpp | 5 +- src/app/qgslayertreeviewtemporalindicator.h | 1 - src/app/qgsmapcanvasdockwidget.cpp | 76 +- src/app/qgsmapcanvasdockwidget.h | 4 +- src/app/qgsmapsavedialog.cpp | 56 +- src/app/qgsmapsavedialog.h | 13 +- src/app/qgsmapthemes.cpp | 14 +- src/app/qgsmapthemes.h | 1 - src/app/qgsmaptooladdfeature.cpp | 10 +- src/app/qgsmaptooladdfeature.h | 3 +- src/app/qgsmaptooladdpart.cpp | 3 +- src/app/qgsmaptooladdpart.h | 1 - src/app/qgsmaptooladdring.h | 2 +- src/app/qgsmaptoolannotation.cpp | 43 +- src/app/qgsmaptoolannotation.h | 3 +- src/app/qgsmaptooldeletepart.cpp | 8 +- src/app/qgsmaptooldeletepart.h | 2 +- src/app/qgsmaptooldeletering.cpp | 10 +- src/app/qgsmaptoolfeatureaction.cpp | 5 +- src/app/qgsmaptoolfillring.cpp | 5 +- src/app/qgsmaptoolfillring.h | 2 +- src/app/qgsmaptoolformannotation.cpp | 5 +- src/app/qgsmaptoolformannotation.h | 2 +- src/app/qgsmaptoolhtmlannotation.cpp | 5 +- src/app/qgsmaptoolhtmlannotation.h | 2 +- src/app/qgsmaptoolidentifyaction.cpp | 5 +- src/app/qgsmaptoolmeasureangle.cpp | 3 +- src/app/qgsmaptoolmeasureangle.h | 3 +- src/app/qgsmaptoolmeasurebearing.cpp | 4 +- src/app/qgsmaptoolmeasurebearing.h | 3 +- src/app/qgsmaptoolmovefeature.cpp | 25 +- src/app/qgsmaptoolmovefeature.h | 8 +- src/app/qgsmaptooloffsetcurve.cpp | 58 +- src/app/qgsmaptooloffsetcurve.h | 5 +- src/app/qgsmaptooloffsetpointsymbol.cpp | 7 +- src/app/qgsmaptooloffsetpointsymbol.h | 8 +- src/app/qgsmaptoolpointsymbol.cpp | 7 +- src/app/qgsmaptoolpointsymbol.h | 3 +- src/app/qgsmaptoolreshape.cpp | 6 +- src/app/qgsmaptoolreshape.h | 2 +- src/app/qgsmaptoolreverseline.cpp | 9 +- src/app/qgsmaptoolreverseline.h | 4 +- src/app/qgsmaptoolrotatefeature.cpp | 19 +- src/app/qgsmaptoolrotatefeature.h | 6 +- src/app/qgsmaptoolrotatepointsymbols.cpp | 9 +- src/app/qgsmaptoolrotatepointsymbols.h | 7 +- src/app/qgsmaptoolscalefeature.cpp | 16 +- src/app/qgsmaptoolscalefeature.h | 8 +- src/app/qgsmaptoolselect.cpp | 17 +- src/app/qgsmaptoolselect.h | 1 - src/app/qgsmaptoolselectionhandler.cpp | 18 +- src/app/qgsmaptoolselectionhandler.h | 7 +- src/app/qgsmaptoolselectutils.cpp | 71 +- src/app/qgsmaptoolselectutils.h | 37 +- src/app/qgsmaptoolsimplify.cpp | 35 +- src/app/qgsmaptoolsimplify.h | 13 +- src/app/qgsmaptoolsplitfeatures.cpp | 25 +- src/app/qgsmaptoolsplitfeatures.h | 2 +- src/app/qgsmaptoolsplitparts.cpp | 15 +- src/app/qgsmaptoolsplitparts.h | 2 +- src/app/qgsmaptooltrimextendfeature.cpp | 3 - src/app/qgsmaptooltrimextendfeature.h | 6 +- src/app/qgsmeasuredialog.cpp | 100 +- src/app/qgsmeasuredialog.h | 8 +- src/app/qgsmeasuretool.cpp | 30 +- src/app/qgsmeasuretool.h | 2 - src/app/qgsmergeattributesdialog.cpp | 50 +- src/app/qgsmergeattributesdialog.h | 8 +- src/app/qgsnewspatialitelayerdialog.cpp | 53 +- src/app/qgsnewspatialitelayerdialog.h | 2 +- src/app/qgspluginmetadata.cpp | 5 +- src/app/qgspluginmetadata.h | 2 +- src/app/qgspluginregistry.cpp | 84 +- src/app/qgspointmarkeritem.cpp | 13 +- src/app/qgspointmarkeritem.h | 20 +- src/app/qgspointrotationitem.cpp | 11 +- src/app/qgspointrotationitem.h | 6 +- src/app/qgsprojectlayergroupdialog.cpp | 15 +- src/app/qgsprojectlayergroupdialog.h | 4 +- src/app/qgsprojectlistitemdelegate.cpp | 42 +- src/app/qgsprojectlistitemdelegate.h | 3 - src/app/qgsprojectproperties.cpp | 295 +- src/app/qgsprojectproperties.h | 20 +- src/app/qgspuzzlewidget.cpp | 7 +- src/app/qgspuzzlewidget.h | 4 +- src/app/qgsrasterattributetableapputils.h | 14 +- src/app/qgsrastercalcdialog.cpp | 11 +- src/app/qgsrastercalcdialog.h | 3 +- src/app/qgsrecentprojectsitemsmodel.cpp | 7 +- src/app/qgsrecentprojectsitemsmodel.h | 16 +- src/app/qgsrecentprojectsmenueventfilter.cpp | 4 +- src/app/qgsrecentprojectsmenueventfilter.h | 1 - src/app/qgsrelationadddlg.cpp | 19 +- src/app/qgsrelationadddlg.h | 3 +- src/app/qgsrelationaddpolymorphicdialog.cpp | 27 +- src/app/qgsrelationaddpolymorphicdialog.h | 3 +- src/app/qgsrelationmanagerdialog.cpp | 28 +- src/app/qgsrelationmanagerdialog.h | 9 +- src/app/qgsselectbyformdialog.cpp | 16 +- src/app/qgsselectbyformdialog.h | 7 +- src/app/qgssettingsregistryapp.cpp | 3 +- src/app/qgssettingstreewidgetold.cpp | 39 +- src/app/qgssettingstreewidgetold.h | 13 +- src/app/qgssnappinglayertreemodel.cpp | 14 +- src/app/qgssnappinglayertreemodel.h | 9 +- src/app/qgssnappingwidget.cpp | 25 +- src/app/qgssnappingwidget.h | 5 +- src/app/qgsstatisticalsummarydockwidget.cpp | 100 +- src/app/qgsstatisticalsummarydockwidget.h | 18 +- src/app/qgsstatusbarcoordinateswidget.cpp | 38 +- src/app/qgsstatusbarcoordinateswidget.h | 1 - src/app/qgsstatusbarmagnifierwidget.cpp | 2 +- src/app/qgsstatusbarmagnifierwidget.h | 1 - src/app/qgsstatusbarscalewidget.cpp | 1 - src/app/qgssvgannotationdialog.cpp | 5 +- src/app/qgssvgannotationdialog.h | 2 +- src/app/qgstemplateprojectsmodel.cpp | 11 +- src/app/qgstemporalcontrollerdockwidget.cpp | 13 +- src/app/qgstemporalcontrollerdockwidget.h | 5 - src/app/qgstextannotationdialog.cpp | 7 +- src/app/qgstextannotationdialog.h | 5 +- src/app/qgsundowidget.cpp | 3 +- src/app/qgsundowidget.h | 4 +- src/app/qgsvariantdelegate.cpp | 47 +- src/app/qgsvariantdelegate.h | 9 +- .../qgsvectorlayerdigitizingproperties.cpp | 7 +- src/app/qgsversioninfo.cpp | 1 - src/app/qgsversionmigration.cpp | 26 +- src/app/qgsversionmigration.h | 4 +- src/app/qgswelcomepage.cpp | 58 +- .../qgsrasterelevationpropertieswidget.cpp | 96 +- .../qgsrasterelevationpropertieswidget.h | 21 +- .../sensor/qgsprojectsensorsettingswidget.cpp | 8 +- .../sensor/qgsprojectsensorsettingswidget.h | 3 - src/app/sensor/qgssensortablewidget.cpp | 44 +- ...qgstiledsceneelevationpropertieswidget.cpp | 13 +- .../qgstiledsceneelevationpropertieswidget.h | 5 +- .../qgstiledscenelayerproperties.cpp | 4 +- .../tiledscene/qgstiledscenelayerproperties.h | 1 - .../qgstiledscenelayerstylewidget.cpp | 2 +- .../qgstiledscenelayerstylewidget.h | 1 - src/app/ui_defaults.h | 3791 ++++++++++++++++- .../qgsvectorelevationpropertieswidget.cpp | 131 +- .../qgsvectorelevationpropertieswidget.h | 4 - src/app/vertextool/qgslockedfeature.cpp | 6 +- src/app/vertextool/qgslockedfeature.h | 8 +- src/app/vertextool/qgsvertexeditor.cpp | 15 +- src/app/vertextool/qgsvertexeditor.h | 12 +- src/app/vertextool/qgsvertextool.cpp | 201 +- src/app/vertextool/qgsvertextool.h | 120 +- .../apiheader/core/qgsauthapiheadermethod.cpp | 13 +- .../apiheader/core/qgsauthapiheadermethod.h | 9 +- .../apiheader/gui/qgsauthapiheaderedit.cpp | 2 +- src/auth/awss3/core/qgsauthawss3method.cpp | 37 +- src/auth/awss3/core/qgsauthawss3method.h | 9 +- src/auth/basic/core/qgsauthbasicmethod.cpp | 44 +- src/auth/basic/core/qgsauthbasicmethod.h | 16 +- .../esritoken/core/qgsauthesritokenmethod.cpp | 10 +- .../esritoken/core/qgsauthesritokenmethod.h | 9 +- .../identcert/core/qgsauthidentcertmethod.cpp | 29 +- .../identcert/core/qgsauthidentcertmethod.h | 13 +- .../identcert/gui/qgsauthidentcertedit.cpp | 6 +- .../core/qgsauthmaptilerhmacsha256method.cpp | 13 +- .../core/qgsauthmaptilerhmacsha256method.h | 9 +- src/auth/oauth2/core/qgsauthoauth2config.cpp | 89 +- src/auth/oauth2/core/qgsauthoauth2config.h | 25 +- src/auth/oauth2/core/qgsauthoauth2method.cpp | 49 +- src/auth/oauth2/core/qgsauthoauth2method.h | 16 +- src/auth/oauth2/core/qgso2.cpp | 43 +- src/auth/oauth2/core/qgso2.h | 13 +- src/auth/oauth2/gui/qgsauthoauth2edit.cpp | 101 +- src/auth/oauth2/gui/qgsauthoauth2edit.h | 2 - .../pkipaths/core/qgsauthpkipathsmethod.cpp | 40 +- .../pkipaths/core/qgsauthpkipathsmethod.h | 13 +- src/auth/pkipaths/gui/qgsauthpkipathsedit.cpp | 18 +- .../pkipkcs12/core/qgsauthpkcs12method.cpp | 54 +- src/auth/pkipkcs12/core/qgsauthpkcs12method.h | 13 +- src/auth/pkipkcs12/gui/qgsauthpkcs12edit.cpp | 15 +- src/auth/pkipkcs12/gui/qgsauthpkcs12edit.h | 2 +- src/crashhandler/qgscrashdialog.cpp | 29 +- src/crashhandler/qgscrashdialog.h | 1 - src/crashhandler/qgscrashreport.cpp | 4 +- src/crashhandler/qgscrashreport.h | 14 +- src/crashhandler/qgsstacktrace.cpp | 253 +- src/crashhandler/qgsstacktrace.h | 17 +- src/customwidgets/qgiscustomwidgets.cpp | 2 +- .../qgsauthconfigselectplugin.cpp | 2 +- .../qgscheckablecomboboxplugin.cpp | 2 +- .../qgscollapsiblegroupboxplugin.cpp | 2 +- src/customwidgets/qgscolorbuttonplugin.cpp | 2 +- src/customwidgets/qgsdatetimeeditplugin.cpp | 2 +- src/customwidgets/qgsdockwidgetplugin.cpp | 2 +- src/customwidgets/qgsdoublespinboxplugin.cpp | 2 +- .../qgsexpressionbuilderwidgetplugin.cpp | 2 +- src/customwidgets/qgsextentgroupboxplugin.cpp | 2 +- .../qgsexternalresourcewidgetplugin.cpp | 2 +- .../qgsfeaturelistcomboboxplugin.cpp | 2 +- .../qgsfeaturepickerwidgetplugin.cpp | 2 +- src/customwidgets/qgsfieldcomboboxplugin.cpp | 2 +- .../qgsfieldexpressionwidgetplugin.cpp | 2 +- src/customwidgets/qgsfilewidgetplugin.cpp | 2 +- src/customwidgets/qgsfilewidgetplugin.h | 1 - src/customwidgets/qgsfilterlineeditplugin.cpp | 2 +- src/customwidgets/qgsfontbuttonplugin.cpp | 2 +- .../qgsmaplayercomboboxplugin.cpp | 2 +- src/customwidgets/qgsopacitywidgetplugin.cpp | 2 +- .../qgspasswordlineeditplugin.cpp | 2 +- .../qgsprojectionselectionwidgetplugin.cpp | 2 +- .../qgspropertyoverridebuttonplugin.cpp | 2 +- .../qgsrasterbandcomboboxplugin.cpp | 2 +- .../qgsrelationeditorwidgetplugin.cpp | 2 +- .../qgsrelationreferencewidgetplugin.cpp | 2 +- .../qgsscalerangewidgetplugin.cpp | 2 +- src/customwidgets/qgsscalewidgetplugin.cpp | 2 +- .../qgsscrollareawidgetplugin.cpp | 2 +- src/customwidgets/qgsspinboxplugin.cpp | 2 +- src/customwidgets/qgssymbolbuttonplugin.cpp | 2 +- src/native/linux/qgslinuxnative.cpp | 80 +- src/native/linux/qgslinuxnative.h | 6 +- src/native/mac/cocoainitializer.mm | 13 +- src/native/mac/qgsmacnative.h | 1 - src/native/mac/qgsmacnative.mm | 120 +- src/native/qgsnative.cpp | 12 +- src/native/qgsnative.h | 59 +- src/native/win/qgswinnative.cpp | 64 +- src/native/win/qgswinnative.h | 19 +- .../qgsgeometrycheckerdialog.cpp | 7 +- .../qgsgeometrycheckerfixsummarydialog.cpp | 6 +- .../qgsgeometrycheckerfixsummarydialog.h | 16 +- .../qgsgeometrycheckerresulttab.cpp | 11 +- .../qgsgeometrycheckersetuptab.cpp | 4 +- .../qgsgeometrycheckfactory.cpp | 12 +- .../qgsgeometrycheckfactory.h | 17 +- .../qgsgeometrycheckfixdialog.cpp | 4 +- src/plugins/grass/qgsgrassaddfeature.h | 1 - src/plugins/grass/qgsgrasseditrenderer.cpp | 14 +- src/plugins/grass/qgsgrasseditrenderer.h | 1 - src/plugins/grass/qgsgrassmapcalc.cpp | 251 +- src/plugins/grass/qgsgrassmapcalc.h | 55 +- src/plugins/grass/qgsgrassmodule.cpp | 58 +- src/plugins/grass/qgsgrassmodule.h | 9 +- src/plugins/grass/qgsgrassmoduleinput.cpp | 39 +- src/plugins/grass/qgsgrassmoduleinput.h | 23 +- src/plugins/grass/qgsgrassmoduleoptions.cpp | 69 +- src/plugins/grass/qgsgrassmoduleoptions.h | 34 +- src/plugins/grass/qgsgrassmoduleparam.cpp | 73 +- src/plugins/grass/qgsgrassmoduleparam.h | 105 +- src/plugins/grass/qgsgrassnewmapset.cpp | 75 +- src/plugins/grass/qgsgrassnewmapset.h | 6 +- src/plugins/grass/qgsgrassplugin.cpp | 54 +- src/plugins/grass/qgsgrassplugin.h | 5 +- src/plugins/grass/qgsgrassregion.cpp | 8 +- src/plugins/grass/qgsgrassregion.h | 6 +- src/plugins/grass/qgsgrassselect.cpp | 17 +- src/plugins/grass/qgsgrassselect.h | 20 +- src/plugins/grass/qgsgrasstools.cpp | 27 +- src/plugins/grass/qgsgrasstools.h | 10 +- src/plugins/grass/qgsgrassutils.cpp | 13 +- src/plugins/grass/qgsgrassutils.h | 11 +- .../offline_editing_plugin.cpp | 2 +- .../offline_editing_plugin_gui.cpp | 13 +- .../offline_editing_progress_dialog.h | 1 - src/plugins/qgisplugin.h | 16 +- src/plugins/topology/checkDock.cpp | 12 +- src/plugins/topology/checkDock.h | 2 - src/plugins/topology/dockModel.cpp | 9 +- src/plugins/topology/dockModel.h | 4 - src/plugins/topology/rulesDialog.cpp | 41 +- src/plugins/topology/rulesDialog.h | 3 - src/plugins/topology/topol.h | 4 +- src/plugins/topology/topolError.cpp | 47 +- src/plugins/topology/topolError.h | 1 - src/plugins/topology/topolTest.cpp | 137 +- src/plugins/topology/topolTest.h | 20 +- src/process/main.cpp | 18 +- src/process/qgsprocess.cpp | 77 +- src/process/qgsprocess.h | 15 +- .../arcgisrest/qgsafsfeatureiterator.h | 7 +- src/providers/arcgisrest/qgsafsprovider.cpp | 30 +- src/providers/arcgisrest/qgsafsprovider.h | 5 +- src/providers/arcgisrest/qgsafsshareddata.cpp | 51 +- src/providers/arcgisrest/qgsafsshareddata.h | 6 +- src/providers/arcgisrest/qgsamsprovider.cpp | 94 +- src/providers/arcgisrest/qgsamsprovider.h | 45 +- .../qgsarcgisrestdataitemguiprovider.cpp | 55 +- .../qgsarcgisrestdataitemguiprovider.h | 4 +- .../arcgisrest/qgsarcgisrestdataitems.cpp | 132 +- .../arcgisrest/qgsarcgisrestdataitems.h | 21 +- .../arcgisrest/qgsarcgisrestprovidergui.cpp | 4 +- .../arcgisrest/qgsarcgisrestprovidergui.h | 2 +- .../arcgisrest/qgsarcgisrestsourceselect.cpp | 30 +- .../arcgisrest/qgsarcgisrestsourceselect.h | 5 - .../arcgisrest/qgsarcgisrestsourcewidget.cpp | 1 - .../arcgisrest/qgsarcgisrestsourcewidget.h | 1 - .../arcgisrest/qgsnewarcgisrestconnection.cpp | 17 +- .../arcgisrest/qgsnewarcgisrestconnection.h | 7 +- .../qgsdelimitedtextfeatureiterator.cpp | 33 +- .../qgsdelimitedtextfeatureiterator.h | 16 +- .../delimitedtext/qgsdelimitedtextfile.cpp | 140 +- .../delimitedtext/qgsdelimitedtextfile.h | 5 +- .../qgsdelimitedtextprovider.cpp | 167 +- .../delimitedtext/qgsdelimitedtextprovider.h | 17 +- .../qgsdelimitedtextprovidergui.cpp | 1 - .../qgsdelimitedtextprovidergui.h | 2 +- .../qgsdelimitedtextsourceselect.cpp | 183 +- .../qgsdelimitedtextsourceselect.h | 13 +- src/providers/gpx/gpsdata.cpp | 48 +- src/providers/gpx/gpsdata.h | 18 +- src/providers/gpx/qgsgpxfeatureiterator.cpp | 16 +- src/providers/gpx/qgsgpxfeatureiterator.h | 8 +- src/providers/gpx/qgsgpxprovider.cpp | 77 +- src/providers/gpx/qgsgpxprovider.h | 31 +- src/providers/gpx/qgsgpxprovidergui.cpp | 3 +- src/providers/gpx/qgsgpxsourceselect.cpp | 37 +- src/providers/gpx/qgsgpxsourceselect.h | 1 - src/providers/grass/qgis.d.rast.c | 24 +- src/providers/grass/qgis.g.info.c | 15 +- src/providers/grass/qgis.r.in.cpp | 22 +- src/providers/grass/qgis.v.in.cpp | 7 +- src/providers/grass/qgsgrass.cpp | 179 +- src/providers/grass/qgsgrass.h | 163 +- .../grass/qgsgrassfeatureiterator.cpp | 52 +- src/providers/grass/qgsgrassfeatureiterator.h | 5 +- src/providers/grass/qgsgrassgislib.cpp | 63 +- src/providers/grass/qgsgrassgislib.h | 4 +- src/providers/grass/qgsgrassimport.cpp | 38 +- src/providers/grass/qgsgrassimport.h | 5 +- src/providers/grass/qgsgrassoptions.cpp | 15 +- src/providers/grass/qgsgrassoptions.h | 1 - src/providers/grass/qgsgrassprovider.cpp | 63 +- src/providers/grass/qgsgrassprovider.h | 45 +- .../grass/qgsgrassprovidermodule.cpp | 51 +- src/providers/grass/qgsgrassprovidermodule.h | 22 +- .../grass/qgsgrassrasterprovider.cpp | 63 +- src/providers/grass/qgsgrassrasterprovider.h | 28 +- .../grass/qgsgrassrasterprovidermodule.cpp | 8 +- src/providers/grass/qgsgrassundocommand.cpp | 1 - src/providers/grass/qgsgrassundocommand.h | 1 + src/providers/grass/qgsgrassvector.cpp | 9 +- src/providers/grass/qgsgrassvector.h | 5 +- src/providers/grass/qgsgrassvectormap.cpp | 22 +- src/providers/grass/qgsgrassvectormap.h | 12 +- .../grass/qgsgrassvectormaplayer.cpp | 38 +- src/providers/grass/qgsgrassvectormaplayer.h | 10 +- src/providers/grass/qgsgrasswin.cpp | 12 +- src/providers/grass/qgsgrasswin.h | 1 - .../hana/qgshanacolumntypethread.cpp | 9 +- src/providers/hana/qgshanacolumntypethread.h | 2 +- src/providers/hana/qgshanaconnection.cpp | 164 +- src/providers/hana/qgshanaconnection.h | 38 +- src/providers/hana/qgshanaconnectionpool.cpp | 8 +- src/providers/hana/qgshanaconnectionpool.h | 3 +- .../hana/qgshanaconnectionstringbuilder.cpp | 3 +- src/providers/hana/qgshanacrsutils.cpp | 12 +- .../hana/qgshanadataitemguiprovider.cpp | 54 +- .../hana/qgshanadataitemguiprovider.h | 4 +- src/providers/hana/qgshanadataitems.cpp | 57 +- src/providers/hana/qgshanadataitems.h | 6 +- src/providers/hana/qgshanadriver.cpp | 6 +- src/providers/hana/qgshanadriver.h | 2 +- src/providers/hana/qgshanaexception.h | 4 +- .../hana/qgshanaexpressioncompiler.cpp | 27 +- src/providers/hana/qgshanafeatureiterator.cpp | 37 +- src/providers/hana/qgshanafeatureiterator.h | 7 +- src/providers/hana/qgshananewconnection.cpp | 54 +- src/providers/hana/qgshananewconnection.h | 3 +- src/providers/hana/qgshanaprimarykeys.cpp | 19 +- src/providers/hana/qgshanaprimarykeys.h | 15 +- src/providers/hana/qgshanaprovider.cpp | 317 +- src/providers/hana/qgshanaprovider.h | 13 +- .../hana/qgshanaproviderconnection.cpp | 3054 +++++++------ .../hana/qgshanaproviderconnection.h | 19 +- src/providers/hana/qgshanaprovidergui.cpp | 6 +- src/providers/hana/qgshanaresultset.cpp | 15 +- src/providers/hana/qgshanasettings.cpp | 4 +- src/providers/hana/qgshanasettings.h | 18 +- src/providers/hana/qgshanasourceselect.cpp | 78 +- src/providers/hana/qgshanasourceselect.h | 13 +- src/providers/hana/qgshanatablemodel.cpp | 17 +- src/providers/hana/qgshanatablemodel.h | 51 +- src/providers/hana/qgshanautils.cpp | 10 +- src/providers/mdal/qgsmdalprovider.cpp | 123 +- src/providers/mdal/qgsmdalprovider.h | 38 +- src/providers/mdal/qgsmdalprovidergui.cpp | 3 +- src/providers/mdal/qgsmdalsourceselect.cpp | 13 +- src/providers/mdal/qgsmdalsourceselect.h | 1 - src/providers/mssql/qgsmssqlconnection.cpp | 13 +- src/providers/mssql/qgsmssqlconnection.h | 4 - src/providers/mssql/qgsmssqldatabase.cpp | 10 +- src/providers/mssql/qgsmssqldatabase.h | 4 +- .../mssql/qgsmssqldataitemguiprovider.cpp | 48 +- .../mssql/qgsmssqldataitemguiprovider.h | 4 +- src/providers/mssql/qgsmssqldataitems.cpp | 30 +- src/providers/mssql/qgsmssqldataitems.h | 3 - .../mssql/qgsmssqlexpressioncompiler.cpp | 23 +- .../mssql/qgsmssqlexpressioncompiler.h | 1 - .../mssql/qgsmssqlfeatureiterator.cpp | 7 +- src/providers/mssql/qgsmssqlfeatureiterator.h | 11 +- .../mssql/qgsmssqlgeomcolumntypethread.cpp | 14 +- .../mssql/qgsmssqlgeometryparser.cpp | 98 +- src/providers/mssql/qgsmssqlgeometryparser.h | 26 +- src/providers/mssql/qgsmssqlnewconnection.cpp | 35 +- src/providers/mssql/qgsmssqlnewconnection.h | 4 +- src/providers/mssql/qgsmssqlprovider.cpp | 439 +- src/providers/mssql/qgsmssqlprovider.h | 31 +- .../mssql/qgsmssqlproviderconnection.cpp | 131 +- .../mssql/qgsmssqlproviderconnection.h | 21 +- src/providers/mssql/qgsmssqlprovidergui.cpp | 3 +- src/providers/mssql/qgsmssqlsourceselect.cpp | 41 +- src/providers/mssql/qgsmssqlsourceselect.h | 6 +- src/providers/mssql/qgsmssqlsqlquerybuilder.h | 3 +- src/providers/mssql/qgsmssqltablemodel.cpp | 69 +- src/providers/mssql/qgsmssqltablemodel.h | 20 +- src/providers/mssql/qgsmssqltransaction.cpp | 2 +- .../oracle/ocispatial/qsql_ocispatial.cpp | 1123 ++--- .../oracle/ocispatial/qsql_ocispatial.h | 11 +- src/providers/oracle/ocispatial/wkbptr.h | 18 +- .../oracle/qgsoraclecolumntypetask.cpp | 13 +- .../oracle/qgsoraclecolumntypetask.h | 6 +- src/providers/oracle/qgsoracleconn.cpp | 148 +- src/providers/oracle/qgsoracleconn.h | 130 +- src/providers/oracle/qgsoracleconnpool.cpp | 4 +- src/providers/oracle/qgsoracleconnpool.h | 4 +- src/providers/oracle/qgsoracledataitems.cpp | 67 +- src/providers/oracle/qgsoracledataitems.h | 4 +- .../oracle/qgsoracleexpressioncompiler.cpp | 15 +- .../oracle/qgsoracleexpressioncompiler.h | 1 - .../oracle/qgsoraclefeatureiterator.cpp | 25 +- .../oracle/qgsoraclefeatureiterator.h | 6 +- .../oracle/qgsoraclenewconnection.cpp | 39 +- .../oracle/qgsoracleprojectstorage.cpp | 23 +- .../oracle/qgsoracleprojectstorage.h | 9 +- .../oracle/qgsoracleprojectstoragedialog.cpp | 12 +- .../oracle/qgsoracleprojectstoragedialog.h | 3 +- src/providers/oracle/qgsoracleprovider.cpp | 667 ++- src/providers/oracle/qgsoracleprovider.h | 89 +- .../oracle/qgsoracleproviderconnection.cpp | 155 +- .../oracle/qgsoracleproviderconnection.h | 15 +- .../oracle/qgsoraclesourceselect.cpp | 34 +- src/providers/oracle/qgsoraclesourceselect.h | 10 +- src/providers/oracle/qgsoracletablecache.cpp | 2 - src/providers/oracle/qgsoracletablecache.h | 5 +- src/providers/oracle/qgsoracletablemodel.cpp | 21 +- src/providers/oracle/qgsoracletablemodel.h | 1 - src/providers/oracle/qgsoracletransaction.cpp | 3 +- src/providers/oracle/qgsoracletransaction.h | 1 - src/providers/pdal/qgspdalindexingtask.cpp | 5 +- src/providers/pdal/qgspdalindexingtask.h | 2 +- src/providers/pdal/qgspdalprovider.cpp | 27 +- src/providers/pdal/qgspdalprovider.h | 19 +- src/providers/pdal/qgspdalprovidergui.cpp | 2 +- src/providers/pdal/qgspdalprovidergui.h | 2 +- .../postgres/qgscolumntypethread.cpp | 12 +- src/providers/postgres/qgspgnewconnection.cpp | 48 +- src/providers/postgres/qgspgnewconnection.h | 2 +- src/providers/postgres/qgspgsourceselect.cpp | 59 +- src/providers/postgres/qgspgsourceselect.h | 2 +- src/providers/postgres/qgspgtablemodel.cpp | 37 +- src/providers/postgres/qgspgtablemodel.h | 5 +- src/providers/postgres/qgspostgresconn.cpp | 600 ++- src/providers/postgres/qgspostgresconn.h | 176 +- .../postgres/qgspostgresconnpool.cpp | 4 +- src/providers/postgres/qgspostgresconnpool.h | 4 +- .../qgspostgresdataitemguiprovider.cpp | 81 +- .../postgres/qgspostgresdataitemguiprovider.h | 6 +- .../postgres/qgspostgresdataitems.cpp | 68 +- src/providers/postgres/qgspostgresdataitems.h | 3 - .../qgspostgresexpressioncompiler.cpp | 3 +- .../postgres/qgspostgresexpressioncompiler.h | 2 - .../postgres/qgspostgresfeatureiterator.cpp | 112 +- .../postgres/qgspostgresfeatureiterator.h | 9 +- .../qgspostgreslayermetadataprovider.cpp | 7 +- .../qgspostgreslayermetadataprovider.h | 1 - .../postgres/qgspostgreslistener.cpp | 4 +- src/providers/postgres/qgspostgreslistener.h | 4 +- .../postgres/qgspostgresprojectstorage.cpp | 19 +- .../postgres/qgspostgresprojectstorage.h | 9 +- .../qgspostgresprojectstoragedialog.cpp | 12 +- .../qgspostgresprojectstoragedialog.h | 3 +- .../postgres/qgspostgresprovider.cpp | 925 ++-- src/providers/postgres/qgspostgresprovider.h | 117 +- .../qgspostgresproviderconnection.cpp | 2082 +++++---- .../postgres/qgspostgresproviderconnection.h | 26 +- .../postgres/qgspostgresprovidergui.cpp | 12 +- .../postgres/qgspostgresprovidergui.h | 6 +- .../qgspostgresprovidermetadatautils.cpp | 95 +- .../qgspostgresprovidermetadatautils.h | 1 - .../postgres/qgspostgrestransaction.cpp | 4 +- .../postgres/qgspostgrestransaction.h | 1 - .../raster/qgspostgresrasterprovider.cpp | 571 +-- .../raster/qgspostgresrasterprovider.h | 34 +- .../raster/qgspostgresrastershareddata.cpp | 215 +- .../raster/qgspostgresrastershareddata.h | 89 +- ...gspostgresrastertemporalsettingswidget.cpp | 25 +- .../qgspostgresrastertemporalsettingswidget.h | 3 - .../raster/qgspostgresrasterutils.cpp | 86 +- .../postgres/raster/qgspostgresrasterutils.h | 6 +- .../spatialite/qgsspatialiteconnection.cpp | 24 +- .../spatialite/qgsspatialiteconnection.h | 18 +- .../spatialite/qgsspatialiteconnpool.cpp | 4 +- .../spatialite/qgsspatialiteconnpool.h | 7 +- .../qgsspatialitedataitemguiprovider.cpp | 42 +- .../qgsspatialitedataitemguiprovider.h | 4 +- .../spatialite/qgsspatialitedataitems.cpp | 5 +- .../spatialite/qgsspatialitedataitems.h | 3 +- .../qgsspatialiteexpressioncompiler.cpp | 5 +- .../qgsspatialiteexpressioncompiler.h | 3 - .../qgsspatialitefeatureiterator.cpp | 29 +- .../spatialite/qgsspatialitefeatureiterator.h | 8 +- .../spatialite/qgsspatialiteprovider.cpp | 1087 +++-- .../spatialite/qgsspatialiteprovider.h | 84 +- .../qgsspatialiteproviderconnection.cpp | 966 ++--- .../qgsspatialiteproviderconnection.h | 9 +- .../spatialite/qgsspatialiteprovidergui.cpp | 2 - .../spatialite/qgsspatialiteprovidergui.h | 3 +- .../spatialite/qgsspatialitesourceselect.cpp | 70 +- .../spatialite/qgsspatialitesourceselect.h | 10 +- .../spatialite/qgsspatialitetablemodel.cpp | 13 +- .../spatialite/qgsspatialitetablemodel.h | 4 +- .../spatialite/qgsspatialitetransaction.cpp | 5 +- .../spatialite/qgsspatialitetransaction.h | 1 - .../virtual/qgsembeddedlayerselectdialog.cpp | 2 +- .../virtual/qgsembeddedlayerselectdialog.h | 2 - src/providers/virtual/qgsslottofunction.h | 11 +- src/providers/virtual/qgsvirtuallayerblob.cpp | 14 +- src/providers/virtual/qgsvirtuallayerblob.h | 24 +- .../qgsvirtuallayerfeatureiterator.cpp | 16 +- .../virtual/qgsvirtuallayerfeatureiterator.h | 13 +- .../virtual/qgsvirtuallayerprovider.cpp | 43 +- .../virtual/qgsvirtuallayerprovider.h | 45 +- .../virtual/qgsvirtuallayerprovidergui.cpp | 1 - .../virtual/qgsvirtuallayerprovidergui.h | 2 +- .../virtual/qgsvirtuallayerqueryparser.cpp | 8 +- .../virtual/qgsvirtuallayerqueryparser.h | 14 +- .../virtual/qgsvirtuallayersourceselect.cpp | 43 +- .../virtual/qgsvirtuallayersourceselect.h | 4 +- .../virtual/qgsvirtuallayersqlitehelper.cpp | 8 +- .../virtual/qgsvirtuallayersqlitehelper.h | 7 +- .../virtual/qgsvirtuallayersqlitemodule.cpp | 144 +- .../virtual/qgsvirtuallayersqlitemodule.h | 36 +- .../qgsvirtualrasterprovider.cpp | 44 +- .../virtualraster/qgsvirtualrasterprovider.h | 25 +- src/providers/wcs/qgswcscapabilities.cpp | 76 +- src/providers/wcs/qgswcscapabilities.h | 91 +- .../wcs/qgswcsdataitemguiprovider.cpp | 19 +- src/providers/wcs/qgswcsdataitemguiprovider.h | 5 +- src/providers/wcs/qgswcsdataitems.cpp | 2 +- src/providers/wcs/qgswcsdataitems.h | 4 +- src/providers/wcs/qgswcsprovider.cpp | 255 +- src/providers/wcs/qgswcsprovider.h | 80 +- src/providers/wcs/qgswcsprovidergui.cpp | 5 +- src/providers/wcs/qgswcsprovidergui.h | 7 +- src/providers/wcs/qgswcssourceselect.cpp | 65 +- src/providers/wcs/qgswcssourceselect.h | 2 - .../wfs/oapif/qgsoapifapirequest.cpp | 36 +- src/providers/wfs/oapif/qgsoapifapirequest.h | 9 +- .../wfs/oapif/qgsoapifcollection.cpp | 48 +- src/providers/wfs/oapif/qgsoapifcollection.h | 34 +- .../wfs/oapif/qgsoapifconformancerequest.cpp | 4 +- .../qgsoapifcql2textexpressioncompiler.cpp | 17 +- .../qgsoapifcql2textexpressioncompiler.h | 8 +- .../oapif/qgsoapifcreatefeaturerequest.cpp | 4 +- .../oapif/qgsoapifdeletefeaturerequest.cpp | 4 +- .../wfs/oapif/qgsoapifitemsrequest.cpp | 21 +- .../wfs/oapif/qgsoapiflandingpagerequest.cpp | 29 +- .../wfs/oapif/qgsoapiflandingpagerequest.h | 1 - .../wfs/oapif/qgsoapifoptionsrequest.cpp | 4 +- .../wfs/oapif/qgsoapifpatchfeaturerequest.cpp | 8 +- src/providers/wfs/oapif/qgsoapifprovider.cpp | 139 +- src/providers/wfs/oapif/qgsoapifprovider.h | 22 +- .../wfs/oapif/qgsoapifputfeaturerequest.cpp | 4 +- .../wfs/oapif/qgsoapifqueryablesrequest.cpp | 19 +- .../wfs/oapif/qgsoapifqueryablesrequest.h | 12 +- .../wfs/oapif/qgsoapifsingleitemrequest.cpp | 15 +- src/providers/wfs/oapif/qgsoapifutils.cpp | 8 +- src/providers/wfs/oapif/qgsoapifutils.h | 10 +- src/providers/wfs/qgsauthorizationsettings.h | 58 +- .../qgsbackgroundcachedfeatureiterator.cpp | 71 +- .../wfs/qgsbackgroundcachedfeatureiterator.h | 155 +- .../wfs/qgsbackgroundcachedshareddata.cpp | 122 +- .../wfs/qgsbackgroundcachedshareddata.h | 4 +- src/providers/wfs/qgsbasenetworkrequest.cpp | 22 +- src/providers/wfs/qgsbasenetworkrequest.h | 16 +- .../wfs/qgscachedirectorymanager.cpp | 17 +- src/providers/wfs/qgscachedirectorymanager.h | 3 +- src/providers/wfs/qgswfscapabilities.cpp | 80 +- src/providers/wfs/qgswfscapabilities.h | 134 +- src/providers/wfs/qgswfsconnection.cpp | 5 +- src/providers/wfs/qgswfsconnection.h | 1 - src/providers/wfs/qgswfsconstants.cpp | 1 - src/providers/wfs/qgswfsconstants.h | 66 +- .../wfs/qgswfsdataitemguiprovider.cpp | 19 +- src/providers/wfs/qgswfsdataitemguiprovider.h | 5 +- src/providers/wfs/qgswfsdataitems.cpp | 14 +- src/providers/wfs/qgswfsdatasourceuri.cpp | 54 +- src/providers/wfs/qgswfsdatasourceuri.h | 10 +- .../wfs/qgswfsdescribefeaturetype.cpp | 3 +- src/providers/wfs/qgswfsdescribefeaturetype.h | 4 +- src/providers/wfs/qgswfsfeatureiterator.cpp | 84 +- src/providers/wfs/qgswfsfeatureiterator.h | 11 +- src/providers/wfs/qgswfsgetfeature.cpp | 5 +- src/providers/wfs/qgswfsgetfeature.h | 7 +- src/providers/wfs/qgswfsguiutils.h | 1 - src/providers/wfs/qgswfsnewconnection.cpp | 9 +- src/providers/wfs/qgswfsprovider.cpp | 398 +- src/providers/wfs/qgswfsprovider.h | 44 +- src/providers/wfs/qgswfsprovidergui.cpp | 11 +- src/providers/wfs/qgswfsprovidergui.h | 2 +- src/providers/wfs/qgswfsprovidermetadata.cpp | 110 +- src/providers/wfs/qgswfsprovidermetadata.h | 6 +- src/providers/wfs/qgswfsrequest.cpp | 2 +- src/providers/wfs/qgswfsshareddata.cpp | 91 +- src/providers/wfs/qgswfsshareddata.h | 25 +- src/providers/wfs/qgswfssourceselect.cpp | 36 +- src/providers/wfs/qgswfssourceselect.h | 11 +- .../wfs/qgswfssubsetstringeditor.cpp | 27 +- src/providers/wfs/qgswfssubsetstringeditor.h | 13 +- src/providers/wfs/qgswfsutils.cpp | 1 - src/providers/wfs/qgswfsutils.h | 4 +- src/providers/wms/qgstilescalewidget.cpp | 8 +- src/providers/wms/qgswmscapabilities.cpp | 320 +- src/providers/wms/qgswmscapabilities.h | 757 ++-- src/providers/wms/qgswmsconnection.h | 2 - .../wms/qgswmsdataitemguiproviders.cpp | 38 +- .../wms/qgswmsdataitemguiproviders.h | 10 +- src/providers/wms/qgswmsdataitems.cpp | 61 +- src/providers/wms/qgswmsdataitems.h | 30 +- src/providers/wms/qgswmsprovider.cpp | 1202 ++---- src/providers/wms/qgswmsprovider.h | 170 +- src/providers/wms/qgswmsprovidergui.cpp | 7 +- src/providers/wms/qgswmsprovidergui.h | 6 +- src/providers/wms/qgswmssourceselect.cpp | 83 +- src/providers/wms/qgswmssourceselect.h | 7 +- src/providers/wms/qgswmstsettingswidget.cpp | 89 +- src/providers/wms/qgswmstsettingswidget.h | 3 - src/providers/wms/qgswmtsdimensions.cpp | 4 +- src/providers/wms/qgswmtsdimensions.h | 1 - src/providers/wms/qgsxyzconnection.cpp | 13 +- src/providers/wms/qgsxyzconnection.h | 36 +- src/providers/wms/qgsxyzconnectiondialog.cpp | 5 +- src/providers/wms/qgsxyzsourceselect.cpp | 8 +- src/providers/wms/qgsxyzsourcewidget.cpp | 26 +- src/providers/wms/qgsxyzsourcewidget.h | 1 - src/python/qgspythonutils.h | 3 +- src/python/qgspythonutilsimpl.cpp | 53 +- src/python/qgspythonutilsimpl.h | 3 - src/quickgui/plugin/qgsquickplugin.cpp | 45 +- src/quickgui/plugin/qgsquickplugin.h | 1 - .../qgsquickelevationprofilecanvas.cpp | 24 +- src/quickgui/qgsquickelevationprofilecanvas.h | 1 - src/quickgui/qgsquickmapcanvasmap.cpp | 15 +- src/quickgui/qgsquickmapcanvasmap.h | 1 - src/quickgui/qgsquickmapsettings.cpp | 3 +- src/quickgui/qgsquickmaptoscreen.h | 1 - src/quickgui/qgsquickmaptransform.cpp | 3 +- src/quickgui/qgsquickutils.h | 1 - src/test/qgstest.h | 157 +- tests/bench/main.cpp | 79 +- tests/bench/qgsbench.cpp | 45 +- tests/bench/qgsbench.h | 3 +- tests/qt_modeltest/dynamictreemodel.cpp | 76 +- tests/qt_modeltest/dynamictreemodel.h | 15 +- tests/qt_modeltest/modeltest.cpp | 59 +- tests/qt_modeltest/modeltest.h | 8 +- tests/qt_modeltest/tst_modeltest.cpp | 12 +- tests/src/3d/sandbox/qgis_3d_sandbox.cpp | 44 +- tests/src/3d/testqgs3dcameracontroller.cpp | 183 +- tests/src/3d/testqgs3dmaterial.cpp | 8 +- tests/src/3d/testqgs3drendering.cpp | 136 +- tests/src/3d/testqgs3dsymbolregistry.cpp | 12 +- tests/src/3d/testqgs3dutils.cpp | 140 +- tests/src/3d/testqgsaabb.cpp | 7 +- tests/src/3d/testqgsgltf3dutils.cpp | 17 +- tests/src/3d/testqgslayout3dmap.cpp | 18 +- tests/src/3d/testqgsmaterialregistry.cpp | 23 +- tests/src/3d/testqgsmesh3drendering.cpp | 9 +- tests/src/3d/testqgspointcloud3drendering.cpp | 28 +- tests/src/3d/testqgstessellator.cpp | 158 +- tests/src/3d/testqgstilingscheme.cpp | 26 +- tests/src/analysis/testqgsalignraster.cpp | 10 +- tests/src/analysis/testqgsgcptransformer.cpp | 356 +- tests/src/analysis/testqgsgeometrysnapper.cpp | 47 +- tests/src/analysis/testqgsinterpolator.cpp | 29 +- tests/src/analysis/testqgsmeshcalculator.cpp | 86 +- tests/src/analysis/testqgsmeshcontours.cpp | 74 +- tests/src/analysis/testqgsnetworkanalysis.cpp | 188 +- tests/src/analysis/testqgsninecellfilters.cpp | 15 +- tests/src/analysis/testqgsprocessing.cpp | 1978 ++++----- .../src/analysis/testqgsprocessingalgspt1.cpp | 2512 ++++++----- .../src/analysis/testqgsprocessingalgspt2.cpp | 371 +- .../testqgsprocessingmodelalgorithm.cpp | 558 ++- .../analysis/testqgsprocessingpdalalgs.cpp | 627 +-- .../src/analysis/testqgsrastercalculator.cpp | 286 +- tests/src/analysis/testqgsreclassifyutils.cpp | 128 +- tests/src/analysis/testqgstriangulation.cpp | 95 +- tests/src/analysis/testqgszonalstatistics.cpp | 19 +- .../testqgsmaptooladdfeatureline.cpp | 53 +- .../testqgsmaptooladdfeaturelinem.cpp | 10 +- .../testqgsmaptooladdfeaturelinez.cpp | 18 +- .../testqgsmaptooladdfeaturelinezm.cpp | 9 +- .../testqgsmaptooladdfeaturepoint.cpp | 14 +- .../testqgsmaptooladdfeaturepointm.cpp | 8 +- .../testqgsmaptooladdfeaturepointz.cpp | 17 +- .../testqgsmaptooladdfeaturepointzm.cpp | 8 +- tests/src/app/testqgisapp.cpp | 15 +- tests/src/app/testqgisappclipboard.cpp | 53 +- tests/src/app/testqgisappdockwidgets.cpp | 20 +- tests/src/app/testqgisapppython.cpp | 8 +- tests/src/app/testqgsadvanceddigitizing.cpp | 241 +- tests/src/app/testqgsappbrowserproviders.cpp | 20 +- .../app/testqgsapplayoutvaliditychecks.cpp | 17 +- tests/src/app/testqgsapplocatorfilters.cpp | 30 +- tests/src/app/testqgsattributetable.cpp | 170 +- tests/src/app/testqgsdecorationscalebar.cpp | 8 +- tests/src/app/testqgsdwgimportdialog.cpp | 28 +- tests/src/app/testqgsfieldcalculator.cpp | 25 +- tests/src/app/testqgsgeoreferencer.cpp | 236 +- tests/src/app/testqgsgpsintegration.cpp | 86 +- tests/src/app/testqgsidentify.cpp | 244 +- tests/src/app/testqgslabelpropertydialog.cpp | 7 +- .../src/app/testqgslayerpropertiesdialogs.cpp | 44 +- tests/src/app/testqgsmapcanvasdockwidget.cpp | 8 +- tests/src/app/testqgsmaptooladdpart.cpp | 154 +- tests/src/app/testqgsmaptooladdring.cpp | 112 +- tests/src/app/testqgsmaptoolcircle.cpp | 133 +- .../src/app/testqgsmaptoolcircularstring.cpp | 12 +- tests/src/app/testqgsmaptooldeletepart.cpp | 48 +- tests/src/app/testqgsmaptooldeletering.cpp | 52 +- .../src/app/testqgsmaptooleditannotation.cpp | 41 +- tests/src/app/testqgsmaptooleditmesh.cpp | 40 +- tests/src/app/testqgsmaptoolellipse.cpp | 176 +- tests/src/app/testqgsmaptoollabel.cpp | 152 +- tests/src/app/testqgsmaptoolmovefeature.cpp | 8 +- tests/src/app/testqgsmaptooloffsetcurve.cpp | 6 +- tests/src/app/testqgsmaptoolrectangle.cpp | 2 +- .../src/app/testqgsmaptoolregularpolygon.cpp | 14 +- tests/src/app/testqgsmaptoolreshape.cpp | 15 +- tests/src/app/testqgsmaptoolreverseline.cpp | 60 +- tests/src/app/testqgsmaptoolrotatefeature.cpp | 8 +- tests/src/app/testqgsmaptoolscalefeature.cpp | 6 +- tests/src/app/testqgsmaptoolselect.cpp | 30 +- tests/src/app/testqgsmaptoolsplitfeatures.cpp | 11 +- tests/src/app/testqgsmaptoolsplitparts.cpp | 38 +- .../app/testqgsmaptooltrimextendfeature.cpp | 246 +- tests/src/app/testqgsmaptoolutils.h | 1 - tests/src/app/testqgsmeasurebearingtool.cpp | 12 +- tests/src/app/testqgsmeasuretool.cpp | 60 +- .../src/app/testqgsmergeattributesdialog.cpp | 26 +- tests/src/app/testqgsmeshcalculatordialog.cpp | 13 +- tests/src/app/testqgsprojectexpressions.cpp | 10 +- tests/src/app/testqgsprojectproperties.cpp | 67 +- .../app/testqgsvectorlayersaveasdialog.cpp | 12 +- tests/src/app/testqgsvertexeditor.cpp | 8 +- tests/src/app/testqgsvertextool.cpp | 54 +- tests/src/auth/testqgsauthoauth2method.cpp | 43 +- tests/src/core/geometry/testgeometryutils.h | 1 - tests/src/core/geometry/testqgscircle.cpp | 103 +- .../core/geometry/testqgscircularstring.cpp | 531 +-- .../core/geometry/testqgscompoundcurve.cpp | 698 +-- .../src/core/geometry/testqgscurvepolygon.cpp | 650 ++- tests/src/core/geometry/testqgsellipse.cpp | 71 +- tests/src/core/geometry/testqgsgeometry.cpp | 351 +- .../geometry/testqgsgeometrycollection.cpp | 487 +-- .../core/geometry/testqgsgeometryutils.cpp | 110 +- .../geometry/testqgsgeometryutilsbase.cpp | 2 +- tests/src/core/geometry/testqgslinestring.cpp | 617 +-- tests/src/core/geometry/testqgsmulticurve.cpp | 333 +- .../core/geometry/testqgsmultilinestring.cpp | 281 +- tests/src/core/geometry/testqgsmultipoint.cpp | 124 +- .../src/core/geometry/testqgsmultipolygon.cpp | 345 +- .../src/core/geometry/testqgsmultisurface.cpp | 303 +- tests/src/core/geometry/testqgspoint.cpp | 144 +- tests/src/core/geometry/testqgspointxy.cpp | 20 +- tests/src/core/geometry/testqgspolygon.cpp | 845 +--- .../geometry/testqgspolyhedralsurface.cpp | 589 +-- .../core/geometry/testqgsquadrilateral.cpp | 332 +- tests/src/core/geometry/testqgsrectangle.cpp | 25 +- .../core/geometry/testqgsregularpolygon.cpp | 71 +- tests/src/core/geometry/testqgstriangle.cpp | 166 +- .../geometry/testqgstriangulatedsurface.cpp | 190 +- tests/src/core/geometry/testtransformer.h | 3 - tests/src/core/test_template.cpp | 10 +- tests/src/core/testcontrastenhancements.cpp | 14 +- tests/src/core/testmaprendererjob.cpp | 5 +- tests/src/core/testqgis.cpp | 52 +- tests/src/core/testqgs25drenderer.cpp | 12 +- .../core/testqgsannotationitemregistry.cpp | 35 +- tests/src/core/testqgsapplication.cpp | 11 +- tests/src/core/testqgsarcgisrestutils.cpp | 648 ++- .../core/testqgsattributeeditorelement.cpp | 43 +- tests/src/core/testqgsauthcertutils.cpp | 2 +- tests/src/core/testqgsauthconfig.cpp | 10 +- tests/src/core/testqgsauthcrypto.cpp | 54 +- tests/src/core/testqgsauthmanager.cpp | 32 +- tests/src/core/testqgsblendmodes.cpp | 28 +- tests/src/core/testqgsbrowsermodel.cpp | 21 +- tests/src/core/testqgsbrowserproxymodel.cpp | 39 +- tests/src/core/testqgscadutils.cpp | 17 +- tests/src/core/testqgscallout.cpp | 255 +- tests/src/core/testqgscalloutregistry.cpp | 13 +- tests/src/core/testqgscentroidfillsymbol.cpp | 23 +- tests/src/core/testqgsclipper.cpp | 45 +- tests/src/core/testqgscolorscheme.cpp | 30 +- tests/src/core/testqgscolorschemeregistry.cpp | 45 +- .../src/core/testqgscompositionconverter.cpp | 114 +- tests/src/core/testqgsconnectionpool.cpp | 11 +- .../core/testqgscoordinatereferencesystem.cpp | 152 +- ...stqgscoordinatereferencesystemregistry.cpp | 30 +- tests/src/core/testqgscoordinatetransform.cpp | 283 +- tests/src/core/testqgscoordinateutils.cpp | 4 +- tests/src/core/testqgscopyfiletask.cpp | 2 +- tests/src/core/testqgscredentials.cpp | 30 +- tests/src/core/testqgscurve.cpp | 92 +- .../src/core/testqgsdatadefinedsizelegend.cpp | 19 +- tests/src/core/testqgsdataitem.cpp | 48 +- tests/src/core/testqgsdatasourceuri.cpp | 483 ++- tests/src/core/testqgsdiagram.cpp | 17 +- tests/src/core/testqgsdistancearea.cpp | 20 +- tests/src/core/testqgsdxfexport.cpp | 973 +++-- tests/src/core/testqgselevationmap.cpp | 6 +- tests/src/core/testqgsellipsemarker.cpp | 17 +- tests/src/core/testqgsexpression.cpp | 313 +- tests/src/core/testqgsexpressioncontext.cpp | 64 +- tests/src/core/testqgsfeature.cpp | 30 +- tests/src/core/testqgsfeaturerequest.cpp | 23 +- tests/src/core/testqgsfield.cpp | 74 +- tests/src/core/testqgsfields.cpp | 75 +- tests/src/core/testqgsfilledmarker.cpp | 33 +- tests/src/core/testqgsfontmarker.cpp | 13 +- tests/src/core/testqgsfontutils.cpp | 31 +- tests/src/core/testqgsgdalcloudconnection.cpp | 17 +- tests/src/core/testqgsgdalprovider.cpp | 156 +- tests/src/core/testqgsgdalutils.cpp | 28 +- tests/src/core/testqgsgenericspatialindex.cpp | 70 +- tests/src/core/testqgsgeometryimport.cpp | 26 +- tests/src/core/testqgsgeopdfexport.cpp | 76 +- tests/src/core/testqgsgltfutils.cpp | 10 +- tests/src/core/testqgsgml.cpp | 1290 +++--- tests/src/core/testqgsgradients.cpp | 13 +- .../core/testqgsgraduatedsymbolrenderer.cpp | 26 +- tests/src/core/testqgshistogram.cpp | 4 +- tests/src/core/testqgshttpheaders.cpp | 95 +- tests/src/core/testqgsimagecache.cpp | 72 +- tests/src/core/testqgsimageoperation.cpp | 11 +- .../core/testqgsinternalgeometryengine.cpp | 25 +- .../core/testqgsinvertedpolygonrenderer.cpp | 24 +- tests/src/core/testqgsjsonutils.cpp | 98 +- tests/src/core/testqgslabelingengine.cpp | 613 ++- tests/src/core/testqgslayerdefinition.cpp | 12 +- tests/src/core/testqgslayeredsymbollevel.cpp | 11 +- tests/src/core/testqgslayertree.cpp | 56 +- tests/src/core/testqgslayout.cpp | 187 +- tests/src/core/testqgslayoutatlas.cpp | 26 +- tests/src/core/testqgslayoutcontext.cpp | 18 +- tests/src/core/testqgslayoutexporter.cpp | 83 +- tests/src/core/testqgslayoutgeopdfexport.cpp | 91 +- tests/src/core/testqgslayouthtml.cpp | 35 +- tests/src/core/testqgslayoutitem.cpp | 159 +- tests/src/core/testqgslayoutitemgroup.cpp | 136 +- tests/src/core/testqgslayoutlabel.cpp | 16 +- tests/src/core/testqgslayoutmanualtable.cpp | 106 +- tests/src/core/testqgslayoutmap.cpp | 125 +- tests/src/core/testqgslayoutmapgrid.cpp | 63 +- tests/src/core/testqgslayoutmapoverview.cpp | 25 +- tests/src/core/testqgslayoutmodel.cpp | 104 +- tests/src/core/testqgslayoutmultiframe.cpp | 43 +- tests/src/core/testqgslayoutobject.cpp | 28 +- tests/src/core/testqgslayoutpage.cpp | 42 +- tests/src/core/testqgslayoutpicture.cpp | 20 +- tests/src/core/testqgslayoutpolyline.cpp | 8 +- tests/src/core/testqgslayoutscalebar.cpp | 174 +- tests/src/core/testqgslayoutshapes.cpp | 35 +- tests/src/core/testqgslayouttable.cpp | 125 +- tests/src/core/testqgslayoutunits.cpp | 90 +- tests/src/core/testqgslayoututils.cpp | 55 +- tests/src/core/testqgslegendrenderer.cpp | 87 +- tests/src/core/testqgslinefillsymbol.cpp | 42 +- tests/src/core/testqgsmapdevicepixelratio.cpp | 7 +- tests/src/core/testqgsmaplayer.cpp | 63 +- .../src/core/testqgsmaplayerstylemanager.cpp | 8 +- tests/src/core/testqgsmaprenderercache.cpp | 10 +- tests/src/core/testqgsmaprendererjob.cpp | 182 +- tests/src/core/testqgsmaprotation.cpp | 13 +- tests/src/core/testqgsmapsettings.cpp | 97 +- tests/src/core/testqgsmapsettingsutils.cpp | 12 +- tests/src/core/testqgsmapthemecollection.cpp | 17 +- tests/src/core/testqgsmaptopixel.cpp | 11 +- .../testqgsmaptopixelgeometrysimplifier.cpp | 21 +- tests/src/core/testqgsmarkerlinesymbol.cpp | 310 +- tests/src/core/testqgsmatrix4x4.cpp | 33 +- tests/src/core/testqgsmesh3daveraging.cpp | 91 +- tests/src/core/testqgsmesheditor.cpp | 1090 +++-- tests/src/core/testqgsmeshlayer.cpp | 156 +- .../src/core/testqgsmeshlayerinterpolator.cpp | 43 +- tests/src/core/testqgsmeshlayerrenderer.cpp | 23 +- tests/src/core/testqgsmimedatautils.cpp | 17 +- .../src/core/testqgsnetworkaccessmanager.cpp | 218 +- .../src/core/testqgsnetworkcontentfetcher.cpp | 16 +- tests/src/core/testqgsnewsfeedparser.cpp | 170 +- tests/src/core/testqgsnmeaconnection.cpp | 50 +- tests/src/core/testqgsofflineediting.cpp | 14 +- tests/src/core/testqgsogcutils.cpp | 1296 +++--- tests/src/core/testqgsogrprovider.cpp | 24 +- tests/src/core/testqgsogrutils.cpp | 520 +-- tests/src/core/testqgsopenclutils.cpp | 50 +- tests/src/core/testqgsoverlayexpression.cpp | 48 +- tests/src/core/testqgspagesizeregistry.cpp | 37 +- tests/src/core/testqgspainteffect.cpp | 78 +- tests/src/core/testqgspainteffectregistry.cpp | 32 +- tests/src/core/testqgspallabeling.cpp | 34 +- tests/src/core/testqgspointcloudattribute.cpp | 40 +- .../src/core/testqgspointcloudexpression.cpp | 279 +- .../core/testqgspointcloudlayerexporter.cpp | 30 +- .../testqgspointcloudrendererregistry.cpp | 8 +- tests/src/core/testqgspointlocator.cpp | 63 +- .../core/testqgspointpatternfillsymbol.cpp | 52 +- tests/src/core/testqgspostgresstringutils.cpp | 1 - tests/src/core/testqgsproject.cpp | 57 +- tests/src/core/testqgsprojectstorage.cpp | 8 +- tests/src/core/testqgsprojutils.cpp | 99 +- tests/src/core/testqgsproperty.cpp | 436 +- tests/src/core/testqgsprovidermetadata.cpp | 37 +- tests/src/core/testqgsrange.cpp | 43 +- tests/src/core/testqgsrasterblock.cpp | 42 +- .../src/core/testqgsrastercontourrenderer.cpp | 11 +- ...rasterdataprovidertemporalcapabilities.cpp | 18 +- tests/src/core/testqgsrasterfilewriter.cpp | 41 +- tests/src/core/testqgsrasterfill.cpp | 78 +- tests/src/core/testqgsrasteriterator.cpp | 66 +- tests/src/core/testqgsrasterlayer.cpp | 205 +- .../testqgsrasterlayertemporalproperties.cpp | 62 +- tests/src/core/testqgsrastermarker.cpp | 18 +- tests/src/core/testqgsrastersublayer.cpp | 20 +- tests/src/core/testqgsrelation.cpp | 9 +- ...testqgsrelationreferencefieldformatter.cpp | 23 +- tests/src/core/testqgsrenderers.cpp | 48 +- tests/src/core/testqgsrulebasedrenderer.cpp | 289 +- tests/src/core/testqgsruntimeprofiler.cpp | 14 +- tests/src/core/testqgsscaleutils.cpp | 10 +- .../core/testqgssensorthingsconnection.cpp | 11 +- tests/src/core/testqgssettings.cpp | 4 +- tests/src/core/testqgssettingsentry.cpp | 4 +- tests/src/core/testqgssettingsregistry.cpp | 1 - tests/src/core/testqgsshapeburst.cpp | 17 +- tests/src/core/testqgssimplemarker.cpp | 108 +- tests/src/core/testqgssimplifymethod.cpp | 15 +- tests/src/core/testqgssnappingutils.cpp | 21 +- tests/src/core/testqgsspatialindex.cpp | 105 +- tests/src/core/testqgsspatialindexkdbush.cpp | 19 +- .../core/testqgssqliteexpressioncompiler.cpp | 10 +- tests/src/core/testqgssqliteutils.cpp | 11 +- tests/src/core/testqgsstac.cpp | 12 +- tests/src/core/testqgsstackeddiagram.cpp | 73 +- tests/src/core/testqgsstatisticalsummary.cpp | 69 +- .../core/testqgsstoredexpressionmanager.cpp | 10 +- tests/src/core/testqgsstringutils.cpp | 45 +- tests/src/core/testqgsstyle.cpp | 408 +- tests/src/core/testqgssvgcache.cpp | 115 +- tests/src/core/testqgssvgmarker.cpp | 22 +- tests/src/core/testqgssymbol.cpp | 64 +- tests/src/core/testqgstaskmanager.cpp | 186 +- .../core/testqgstemporalnavigationobject.cpp | 185 +- tests/src/core/testqgstemporalproperty.cpp | 9 +- tests/src/core/testqgstemporalrangeobject.cpp | 9 +- tests/src/core/testqgstiledownloadmanager.cpp | 17 +- .../src/core/testqgstiledsceneconnection.cpp | 15 +- .../testqgstiledscenerendererregistry.cpp | 8 +- tests/src/core/testqgstiles.cpp | 8 +- tests/src/core/testqgstracer.cpp | 53 +- tests/src/core/testqgstranslateproject.cpp | 12 +- tests/src/core/testqgstriangularmesh.cpp | 20 +- .../testqgsvaluerelationfieldformatter.cpp | 17 +- tests/src/core/testqgsvector.cpp | 4 +- tests/src/core/testqgsvectordataprovider.cpp | 9 +- tests/src/core/testqgsvectorfilewriter.cpp | 166 +- tests/src/core/testqgsvectorlayer.cpp | 50 +- tests/src/core/testqgsvectorlayercache.cpp | 74 +- .../src/core/testqgsvectorlayerjoinbuffer.cpp | 84 +- tests/src/core/testqgsvectorlayerutils.cpp | 10 +- .../src/core/testqgsvectortileconnection.cpp | 9 +- tests/src/core/testqgsvectortilelayer.cpp | 93 +- tests/src/core/testqgsvectortileutils.cpp | 11 +- tests/src/core/testqgsvectortilewriter.cpp | 30 +- tests/src/core/testqgsweakrelation.cpp | 113 +- tests/src/core/testqgsziputils.cpp | 16 +- tests/src/core/testqobjectparentuniqueptr.cpp | 7 - tests/src/core/testziplayer.cpp | 36 +- .../vector/testqgsvectorlayereditbuffer.cpp | 11 +- .../vector/testqgsvectorlayerundocommand.cpp | 24 +- .../testqgsgeometrychecks.cpp | 238 +- .../testqgsvectorlayerfeaturepool.cpp | 2 +- tests/src/gui/testprocessinggui.cpp | 2776 ++++++------ tests/src/gui/testprojectionissues.cpp | 20 +- .../testqgsadvanceddigitizingdockwidget.cpp | 13 +- ...testqgsadvanceddigitizingtoolsregistry.cpp | 12 +- .../gui/testqgsannotationitemguiregistry.cpp | 35 +- tests/src/gui/testqgsattributeform.cpp | 58 +- .../gui/testqgscategorizedrendererwidget.cpp | 197 +- tests/src/gui/testqgscompoundcolorwidget.cpp | 30 +- tests/src/gui/testqgsdatetimeedit.cpp | 17 +- tests/src/gui/testqgsdatumtransformdialog.cpp | 11 +- tests/src/gui/testqgsdockwidget.cpp | 13 +- tests/src/gui/testqgsdoublespinbox.cpp | 10 +- tests/src/gui/testqgsdoublevalidator.cpp | 55 +- tests/src/gui/testqgsdualview.cpp | 56 +- tests/src/gui/testqgseditorwidgetregistry.cpp | 5 +- .../testqgsexternalresourcewidgetwrapper.cpp | 60 +- .../gui/testqgsexternalstoragefilewidget.cpp | 58 +- tests/src/gui/testqgsfeaturelistcombobox.cpp | 18 +- .../src/gui/testqgsfieldexpressionwidget.cpp | 26 +- tests/src/gui/testqgsfiledownloader.cpp | 43 +- tests/src/gui/testqgsfilewidget.cpp | 66 +- tests/src/gui/testqgsfocuswatcher.cpp | 9 +- tests/src/gui/testqgsgui.cpp | 27 +- tests/src/gui/testqgshtmlwidgetwrapper.cpp | 8 +- tests/src/gui/testqgskeyvaluewidget.cpp | 4 +- tests/src/gui/testqgslayoutgui.cpp | 15 +- tests/src/gui/testqgslayoutview.cpp | 59 +- tests/src/gui/testqgslistwidget.cpp | 48 +- tests/src/gui/testqgsmapcanvas.cpp | 81 +- tests/src/gui/testqgsmaptoolcapture.cpp | 8 +- tests/src/gui/testqgsmaptooledit.cpp | 13 +- tests/src/gui/testqgsmaptoolzoom.cpp | 20 +- tests/src/gui/testqgsmaskingwidget.cpp | 14 +- .../gui/testqgsmeshlayerpropertiesdialog.cpp | 18 +- tests/src/gui/testqgsmessagebar.cpp | 30 +- .../src/gui/testqgsnewdatabasetablewidget.cpp | 48 +- tests/src/gui/testqgsogrprovidergui.cpp | 12 +- tests/src/gui/testqgsprocessingmodel.cpp | 166 +- tests/src/gui/testqgsquerybuilder.cpp | 10 +- tests/src/gui/testqgsqueryresultwidget.cpp | 44 +- tests/src/gui/testqgsquickprint.cpp | 18 +- tests/src/gui/testqgsrangewidgetwrapper.cpp | 127 +- tests/src/gui/testqgsrasterhistogram.cpp | 28 +- .../gui/testqgsrasterlayersaveasdialog.cpp | 22 +- .../src/gui/testqgsrasterlayersavesdialog.cpp | 27 +- tests/src/gui/testqgsrelationeditorwidget.cpp | 44 +- .../gui/testqgsrelationreferencewidget.cpp | 12 +- tests/src/gui/testqgsrubberband.cpp | 94 +- tests/src/gui/testqgsscalecombobox.cpp | 12 +- tests/src/gui/testqgsscalerangewidget.cpp | 10 +- ...qgssinglebandpseudocolorrendererwidget.cpp | 7 +- tests/src/gui/testqgsspinbox.cpp | 10 +- tests/src/gui/testqgssqlcomposerdialog.cpp | 7 +- tests/src/gui/testqgssvgselectorwidget.cpp | 12 +- tests/src/gui/testqgstableeditor.cpp | 81 +- tests/src/gui/testqgstexteditwrapper.cpp | 30 +- tests/src/gui/testqgsvaluemapconfigdlg.cpp | 6 +- .../src/gui/testqgsvaluemapwidgetwrapper.cpp | 10 +- .../gui/testqgsvaluerelationwidgetwrapper.cpp | 113 +- tests/src/native/testqgsmacnative.cpp | 2 +- .../providers/grass/testqgsgrassprovider.cpp | 90 +- tests/src/providers/testqgscopcprovider.cpp | 637 ++- tests/src/providers/testqgseptprovider.cpp | 409 +- tests/src/providers/testqgsmdalprovider.cpp | 42 +- tests/src/providers/testqgsmssqlprovider.cpp | 24 +- tests/src/providers/testqgspdalprovider.cpp | 51 +- tests/src/providers/testqgspostgresconn.cpp | 33 +- .../testqgspostgresexpressioncompiler.cpp | 8 +- .../src/providers/testqgspostgresprovider.cpp | 86 +- .../providers/testqgsvirtuallayerprovider.cpp | 12 +- .../testqgsvirtualpointcloudprovider.cpp | 38 +- .../testqgsvirtualrasterprovider.cpp | 106 +- tests/src/providers/testqgswcsprovider.cpp | 26 +- .../src/providers/testqgswcspublicservers.cpp | 98 +- tests/src/providers/testqgswcspublicservers.h | 35 +- .../src/providers/testqgswmscapabilities.cpp | 77 +- .../src/providers/testqgswmsccapabilities.cpp | 2 +- tests/src/providers/testqgswmsprovider.cpp | 36 +- tests/src/quickgui/app/main.cpp | 2 +- .../src/quickgui/testqgsquickmapsettings.cpp | 4 +- .../testqgsserverquerystringparameter.cpp | 6 +- .../wms/test_qgsserver_wms_parameters.cpp | 13 +- 1494 files changed, 40846 insertions(+), 50777 deletions(-) diff --git a/editors/QtCreator/templates/wizards/qgis/qgis_test/file.cpp b/editors/QtCreator/templates/wizards/qgis/qgis_test/file.cpp index cbacf9e7dcfd..2e3b97745511 100644 --- a/editors/QtCreator/templates/wizards/qgis/qgis_test/file.cpp +++ b/editors/QtCreator/templates/wizards/qgis/qgis_test/file.cpp @@ -23,39 +23,38 @@ #include #include -class %{CN}: public QObject +class % { CN } : public QObject { - Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. // Add your test methods here }; -void %{CN}::initTestCase() +void % { CN } +::initTestCase() { - } -void %{CN}::cleanupTestCase() +void % { CN } +::cleanupTestCase() { - } -void %{CN}::init() +void % { CN } +::init() { - } -void %{CN}::cleanup() +void % { CN } +::cleanup() { - } -QGSTEST_MAIN( %{CN} ) +QGSTEST_MAIN( % { CN } ) #include "%{JS: Cpp.classToFileName('%{Class}', '.moc')}" diff --git a/src/app/3d/qgs3danimationexportdialog.cpp b/src/app/3d/qgs3danimationexportdialog.cpp index 66e959a9152d..cd238b47534b 100644 --- a/src/app/3d/qgs3danimationexportdialog.cpp +++ b/src/app/3d/qgs3danimationexportdialog.cpp @@ -25,7 +25,8 @@ #include #include -Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog(): QDialog( nullptr ) +Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog() + : QDialog( nullptr ) { setupUi( this ); mFpsSpinBox->setClearValue( 30 ); @@ -33,16 +34,13 @@ Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog(): QDialog( nullptr ) mHeightSpinBox->setClearValue( 600 ); const QgsSettings settings; - const QString templateText = settings.value( QStringLiteral( "Export3DAnimation/fileNameTemplate" ), - QStringLiteral( "%1####.jpg" ).arg( QgsProject::instance()->baseName() ) - , QgsSettings::App ).toString(); + const QString templateText = settings.value( QStringLiteral( "Export3DAnimation/fileNameTemplate" ), QStringLiteral( "%1####.jpg" ).arg( QgsProject::instance()->baseName() ), QgsSettings::App ).toString(); mTemplateLineEdit->setText( templateText ); const thread_local QRegularExpression rx( QStringLiteral( "^\\w+#+\\.{1}\\w+$" ) ); //e.g. anyprefix#####.png QValidator *validator = new QRegularExpressionValidator( rx, this ); mTemplateLineEdit->setValidator( validator ); - connect( mTemplateLineEdit, &QLineEdit::textChanged, this, [ = ] - { + connect( mTemplateLineEdit, &QLineEdit::textChanged, this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "Export3DAnimation/fileNameTemplate" ), mTemplateLineEdit->text() ); } ); @@ -53,35 +51,30 @@ Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog(): QDialog( nullptr ) mOutputDirFileWidget->setDefaultRoot( settings.value( QStringLiteral( "Export3DAnimation/lastDir" ), QString(), QgsSettings::App ).toString() ); mOutputDirFileWidget->setFilePath( settings.value( QStringLiteral( "Export3DAnimation/lastDir" ), QString(), QgsSettings::App ).toString() ); - connect( mOutputDirFileWidget, &QgsFileWidget::fileChanged, this, [ = ] - { + connect( mOutputDirFileWidget, &QgsFileWidget::fileChanged, this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "Export3DAnimation/lastDir" ), mOutputDirFileWidget->filePath(), QgsSettings::App ); } ); mFpsSpinBox->setValue( settings.value( QStringLiteral( "Export3DAnimation/fps" ), 30 ).toInt() ); - connect( mFpsSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QgsSpinBox::valueChanged ), this, [ = ] - { + connect( mFpsSpinBox, static_cast( &QgsSpinBox::valueChanged ), this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "Export3DAnimation/fps" ), mFpsSpinBox->value() ); } ); mWidthSpinBox->setValue( settings.value( QStringLiteral( "Export3DAnimation/width" ), 800 ).toInt() ); - connect( mWidthSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QgsSpinBox::valueChanged ), this, [ = ] - { + connect( mWidthSpinBox, static_cast( &QgsSpinBox::valueChanged ), this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "Export3DAnimation/width" ), mWidthSpinBox->value() ); } ); mHeightSpinBox->setValue( settings.value( QStringLiteral( "Export3DAnimation/height" ), 600 ).toInt() ); - connect( mHeightSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QgsSpinBox::valueChanged ), this, [ = ] - { + connect( mHeightSpinBox, static_cast( &QgsSpinBox::valueChanged ), this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "Export3DAnimation/height" ), mHeightSpinBox->value() ); } ); - connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html#create-animation" ) ); } ); diff --git a/src/app/3d/qgs3danimationexportdialog.h b/src/app/3d/qgs3danimationexportdialog.h index ba85f12e533e..4e5f8759c567 100644 --- a/src/app/3d/qgs3danimationexportdialog.h +++ b/src/app/3d/qgs3danimationexportdialog.h @@ -36,10 +36,10 @@ class Qgs3DAnimationExportDialog : public QDialog, private Ui::AnimationExport3D ~Qgs3DAnimationExportDialog() override; //! Returns output directory for frames - QString outputDirectory( ) const; + QString outputDirectory() const; //! Returns filename template for frames - QString fileNameExpression( ) const; + QString fileNameExpression() const; //! Returns frames per second int fps() const; diff --git a/src/app/3d/qgs3danimationwidget.cpp b/src/app/3d/qgs3danimationwidget.cpp index 451f138c4d89..76fc396c5edf 100644 --- a/src/app/3d/qgs3danimationwidget.cpp +++ b/src/app/3d/qgs3danimationwidget.cpp @@ -191,15 +191,13 @@ void Qgs3DAnimationWidget::onExportAnimation() if ( dialog.exec() == QDialog::Accepted ) { QgsFeedback progressFeedback; - std::unique_ptr< QgsScopedProxyProgressTask > progressTask = std::make_unique< QgsScopedProxyProgressTask >( tr( "Exporting animation" ) ); + std::unique_ptr progressTask = std::make_unique( tr( "Exporting animation" ) ); QProgressDialog progressDialog( tr( "Exporting frames..." ), tr( "Abort" ), 0, 100, this ); progressDialog.setWindowModality( Qt::WindowModal ); QString error; - connect( &progressFeedback, &QgsFeedback::progressChanged, this, - [&progressDialog, &progressTask]( double progress ) - { + connect( &progressFeedback, &QgsFeedback::progressChanged, this, [&progressDialog, &progressTask]( double progress ) { progressDialog.setValue( static_cast( progress ) ); progressTask->setProgress( progress ); QCoreApplication::processEvents(); @@ -208,14 +206,15 @@ void Qgs3DAnimationWidget::onExportAnimation() connect( &progressDialog, &QProgressDialog::canceled, &progressFeedback, &QgsFeedback::cancel ); const bool success = Qgs3DUtils::exportAnimation( - animation(), - *mMap, - dialog.fps(), - dialog.outputDirectory(), - dialog.fileNameExpression(), - dialog.frameSize(), - error, - &progressFeedback ); + animation(), + *mMap, + dialog.fps(), + dialog.outputDirectory(), + dialog.fileNameExpression(), + dialog.frameSize(), + error, + &progressFeedback + ); progressTask.reset(); diff --git a/src/app/3d/qgs3dapputils.cpp b/src/app/3d/qgs3dapputils.cpp index de85b4edf1d8..e45a927dd9a3 100644 --- a/src/app/3d/qgs3dapputils.cpp +++ b/src/app/3d/qgs3dapputils.cpp @@ -31,16 +31,16 @@ void Qgs3DAppUtils::initialize() { - qgis::down_cast< Qgs3DSymbolMetadata * >( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "point" ) ) )->setWidgetFunction( QgsPoint3DSymbolWidget::create ); - qgis::down_cast< Qgs3DSymbolMetadata * >( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "line" ) ) )->setWidgetFunction( QgsLine3DSymbolWidget::create ); - qgis::down_cast< Qgs3DSymbolMetadata * >( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "polygon" ) ) )->setWidgetFunction( QgsPolygon3DSymbolWidget::create ); + qgis::down_cast( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "point" ) ) )->setWidgetFunction( QgsPoint3DSymbolWidget::create ); + qgis::down_cast( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "line" ) ) )->setWidgetFunction( QgsLine3DSymbolWidget::create ); + qgis::down_cast( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "polygon" ) ) )->setWidgetFunction( QgsPolygon3DSymbolWidget::create ); - qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "null" ) ) )->setWidgetFunction( QgsNullMaterialWidget::create ); - qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phong" ) ) )->setWidgetFunction( QgsPhongMaterialWidget::create ); - qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phongtextured" ) ) )->setWidgetFunction( QgsPhongTexturedMaterialWidget::create ); - qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "gooch" ) ) )->setWidgetFunction( QgsGoochMaterialWidget::create ); - qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "simpleline" ) ) )->setWidgetFunction( QgsSimpleLineMaterialWidget::create ); - qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "metalrough" ) ) )->setWidgetFunction( QgsMetalRoughMaterialWidget::create ); + qgis::down_cast( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "null" ) ) )->setWidgetFunction( QgsNullMaterialWidget::create ); + qgis::down_cast( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phong" ) ) )->setWidgetFunction( QgsPhongMaterialWidget::create ); + qgis::down_cast( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phongtextured" ) ) )->setWidgetFunction( QgsPhongTexturedMaterialWidget::create ); + qgis::down_cast( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "gooch" ) ) )->setWidgetFunction( QgsGoochMaterialWidget::create ); + qgis::down_cast( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "simpleline" ) ) )->setWidgetFunction( QgsSimpleLineMaterialWidget::create ); + qgis::down_cast( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "metalrough" ) ) )->setWidgetFunction( QgsMetalRoughMaterialWidget::create ); QgsStyleModel::setIconGenerator( new Qgs3DIconGenerator( QgsApplication::defaultStyleModel() ) ); } diff --git a/src/app/3d/qgs3dapputils.h b/src/app/3d/qgs3dapputils.h index b2c4f39febea..86d03205867b 100644 --- a/src/app/3d/qgs3dapputils.h +++ b/src/app/3d/qgs3dapputils.h @@ -21,12 +21,10 @@ class Qgs3DAppUtils { public: - /** * Initializes 3D components belonging to the app library. */ static void initialize(); - }; #endif // QGS3DAPPUTILS_H diff --git a/src/app/3d/qgs3ddebugwidget.cpp b/src/app/3d/qgs3ddebugwidget.cpp index 7940b6612ea1..cf22fc84b943 100644 --- a/src/app/3d/qgs3ddebugwidget.cpp +++ b/src/app/3d/qgs3ddebugwidget.cpp @@ -73,29 +73,26 @@ void Qgs3DDebugWidget::setMapSettings( Qgs3DMapSettings *mapSettings ) whileBlocking( chkShowLightSourceOrigins )->setChecked( mMap->showLightSourceOrigins() ); whileBlocking( chkStopUpdates )->setChecked( mMap->stopUpdates() ); whileBlocking( chkDebugOverlay )->setChecked( mMap->isDebugOverlayEnabled() ); - connect( chkShowTileInfo, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowTerrainTilesInfo( enabled ); } ); - connect( chkShowBoundingBoxes, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowTerrainBoundingBoxes( enabled ); } ); - connect( chkShowCameraViewCenter, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowCameraViewCenter( enabled ); } ); - connect( chkShowCameraRotationCenter, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowCameraRotationCenter( enabled ); } ); - connect( chkShowLightSourceOrigins, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowLightSourceOrigins( enabled ); } ); - connect( chkStopUpdates, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setStopUpdates( enabled ); } ); - connect( chkDebugOverlay, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setIsDebugOverlayEnabled( enabled ); } ); + connect( chkShowTileInfo, &QCheckBox::toggled, this, [=]( const bool enabled ) { mMap->setShowTerrainTilesInfo( enabled ); } ); + connect( chkShowBoundingBoxes, &QCheckBox::toggled, this, [=]( const bool enabled ) { mMap->setShowTerrainBoundingBoxes( enabled ); } ); + connect( chkShowCameraViewCenter, &QCheckBox::toggled, this, [=]( const bool enabled ) { mMap->setShowCameraViewCenter( enabled ); } ); + connect( chkShowCameraRotationCenter, &QCheckBox::toggled, this, [=]( const bool enabled ) { mMap->setShowCameraRotationCenter( enabled ); } ); + connect( chkShowLightSourceOrigins, &QCheckBox::toggled, this, [=]( const bool enabled ) { mMap->setShowLightSourceOrigins( enabled ); } ); + connect( chkStopUpdates, &QCheckBox::toggled, this, [=]( const bool enabled ) { mMap->setStopUpdates( enabled ); } ); + connect( chkDebugOverlay, &QCheckBox::toggled, this, [=]( const bool enabled ) { mMap->setIsDebugOverlayEnabled( enabled ); } ); // set up the shadow map block whileBlocking( mDebugShadowMapGroupBox )->setChecked( mMap->debugShadowMapEnabled() ); whileBlocking( mDebugShadowMapCornerComboBox )->setCurrentIndex( mMap->debugShadowMapCorner() ); whileBlocking( mDebugShadowMapSizeSpinBox )->setValue( mMap->debugShadowMapSize() ); // Do not display the shadow debug map if the shadow effect is not enabled. - connect( mDebugShadowMapGroupBox, &QGroupBox::toggled, this, [ = ]( const bool enabled ) - { + connect( mDebugShadowMapGroupBox, &QGroupBox::toggled, this, [=]( const bool enabled ) { mMap->setDebugShadowMapSettings( enabled && mMap->shadowSettings().renderShadows(), static_cast( mDebugShadowMapCornerComboBox->currentIndex() ), mDebugShadowMapSizeSpinBox->value() ); } ); - connect( mDebugShadowMapCornerComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( const int index ) - { + connect( mDebugShadowMapCornerComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=]( const int index ) { mMap->setDebugShadowMapSettings( mDebugShadowMapGroupBox->isChecked() && mMap->shadowSettings().renderShadows(), static_cast( index ), mDebugShadowMapSizeSpinBox->value() ); } ); - connect( mDebugShadowMapSizeSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { + connect( mDebugShadowMapSizeSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { mMap->setDebugShadowMapSettings( mDebugShadowMapGroupBox->isChecked() && mMap->shadowSettings().renderShadows(), static_cast( mDebugShadowMapCornerComboBox->currentIndex() ), value ); } ); @@ -103,75 +100,67 @@ void Qgs3DDebugWidget::setMapSettings( Qgs3DMapSettings *mapSettings ) whileBlocking( mDebugDepthMapGroupBox )->setChecked( mMap->debugDepthMapEnabled() ); whileBlocking( mDebugDepthMapCornerComboBox )->setCurrentIndex( mMap->debugDepthMapCorner() ); whileBlocking( mDebugDepthMapSizeSpinBox )->setValue( mMap->debugDepthMapSize() ); - connect( mDebugDepthMapGroupBox, &QGroupBox::toggled, this, [ = ]( const bool enabled ) - { + connect( mDebugDepthMapGroupBox, &QGroupBox::toggled, this, [=]( const bool enabled ) { mMap->setDebugDepthMapSettings( enabled, static_cast( mDebugDepthMapCornerComboBox->currentIndex() ), mDebugDepthMapSizeSpinBox->value() ); } ); - connect( mDebugDepthMapCornerComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( const int index ) - { + connect( mDebugDepthMapCornerComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=]( const int index ) { mMap->setDebugDepthMapSettings( mDebugDepthMapGroupBox->isChecked(), static_cast( index ), mDebugDepthMapSizeSpinBox->value() ); } ); - connect( mDebugDepthMapSizeSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { + connect( mDebugDepthMapSizeSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { mMap->setDebugDepthMapSettings( mDebugDepthMapGroupBox->isChecked(), static_cast( mDebugDepthMapCornerComboBox->currentIndex() ), value ); } ); // connect the camera info spin boxes with changing functions - connect( mNearPlane, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { + connect( mNearPlane, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { m3DMapCanvas->cameraController()->camera()->setNearPlane( static_cast( value ) ); } ); - connect( mFarPlane, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { + connect( mFarPlane, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { m3DMapCanvas->cameraController()->camera()->setFarPlane( static_cast( value ) ); } ); - connect( mCameraX, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { - QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position(); + connect( mCameraX, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { + QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position(); newPosition.setX( static_cast( value ) ); m3DMapCanvas->cameraController()->camera()->setPosition( newPosition ); } ); - connect( mCameraY, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { - QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position(); + connect( mCameraY, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { + QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position(); newPosition.setY( static_cast( value ) ); m3DMapCanvas->cameraController()->camera()->setPosition( newPosition ); } ); - connect( mCameraZ, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { - QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position(); + connect( mCameraZ, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { + QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position(); newPosition.setZ( static_cast( value ) ); m3DMapCanvas->cameraController()->camera()->setPosition( newPosition ); } ); - connect( mLookingX, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { + connect( mLookingX, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { QgsVector3D newLookingAt = m3DMapCanvas->cameraController()->lookingAtPoint(); newLookingAt.setX( value ); m3DMapCanvas->cameraController()->setLookingAtPoint( newLookingAt, m3DMapCanvas->cameraController()->distance(), m3DMapCanvas->cameraController()->pitch(), - m3DMapCanvas->cameraController()->yaw() ); + m3DMapCanvas->cameraController()->yaw() + ); } ); - connect( mLookingY, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { + connect( mLookingY, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { QgsVector3D newLookingAt = m3DMapCanvas->cameraController()->lookingAtPoint(); newLookingAt.setY( value ); m3DMapCanvas->cameraController()->setLookingAtPoint( newLookingAt, m3DMapCanvas->cameraController()->distance(), m3DMapCanvas->cameraController()->pitch(), - m3DMapCanvas->cameraController()->yaw() ); + m3DMapCanvas->cameraController()->yaw() + ); } ); - connect( mLookingZ, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value ) - { + connect( mLookingZ, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) { QgsVector3D newLookingAt = m3DMapCanvas->cameraController()->lookingAtPoint(); newLookingAt.setZ( value ); m3DMapCanvas->cameraController()->setLookingAtPoint( newLookingAt, m3DMapCanvas->cameraController()->distance(), m3DMapCanvas->cameraController()->pitch(), - m3DMapCanvas->cameraController()->yaw() ); + m3DMapCanvas->cameraController()->yaw() + ); } ); } diff --git a/src/app/3d/qgs3dicongenerator.cpp b/src/app/3d/qgs3dicongenerator.cpp index 5a8ac688a2a2..a4e047eda7a2 100644 --- a/src/app/3d/qgs3dicongenerator.cpp +++ b/src/app/3d/qgs3dicongenerator.cpp @@ -21,13 +21,12 @@ Qgs3DIconGenerator::Qgs3DIconGenerator( QObject *parent ) : QgsAbstractStyleEntityIconGenerator( parent ) { - } void Qgs3DIconGenerator::generateIcon( QgsStyle *, QgsStyle::StyleEntity type, const QString &name ) { QIcon icon; - const QList< QSize > sizes = iconSizes(); + const QList sizes = iconSizes(); if ( sizes.isEmpty() ) icon.addFile( QgsApplication::defaultThemePath() + QDir::separator() + QStringLiteral( "3d.svg" ), QSize( 24, 24 ) ); for ( const QSize &s : sizes ) diff --git a/src/app/3d/qgs3dicongenerator.h b/src/app/3d/qgs3dicongenerator.h index 911ce9cc9bcc..4b7c0963f80e 100644 --- a/src/app/3d/qgs3dicongenerator.h +++ b/src/app/3d/qgs3dicongenerator.h @@ -25,7 +25,6 @@ class Qgs3DIconGenerator : public QgsAbstractStyleEntityIconGenerator Q_OBJECT public: - Qgs3DIconGenerator( QObject *parent ); void generateIcon( QgsStyle *style, QgsStyle::StyleEntity type, const QString &name ) override; diff --git a/src/app/3d/qgs3dmapcanvaswidget.cpp b/src/app/3d/qgs3dmapcanvaswidget.cpp index 730171d5278e..eca9ae3bed0c 100644 --- a/src/app/3d/qgs3dmapcanvaswidget.cpp +++ b/src/app/3d/qgs3dmapcanvaswidget.cpp @@ -68,16 +68,15 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) QToolBar *toolBar = new QToolBar( this ); toolBar->setIconSize( QgisApp::instance()->iconSize( isDocked ) ); - QAction *actionCameraControl = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionPan.svg" ) ), - tr( "Camera Control" ), this, &Qgs3DMapCanvasWidget::cameraControl ); + QAction *actionCameraControl = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionPan.svg" ) ), tr( "Camera Control" ), this, &Qgs3DMapCanvasWidget::cameraControl ); actionCameraControl->setCheckable( true ); - toolBar->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionZoomFullExtent.svg" ) ), - tr( "Zoom Full" ), this, &Qgs3DMapCanvasWidget::resetView ); + toolBar->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionZoomFullExtent.svg" ) ), tr( "Zoom Full" ), this, &Qgs3DMapCanvasWidget::resetView ); QAction *toggleOnScreenNavigation = toolBar->addAction( - QgsApplication::getThemeIcon( QStringLiteral( "mAction3DNavigation.svg" ) ), - tr( "Toggle On-Screen Navigation" ) ); + QgsApplication::getThemeIcon( QStringLiteral( "mAction3DNavigation.svg" ) ), + tr( "Toggle On-Screen Navigation" ) + ); toggleOnScreenNavigation->setCheckable( true ); toggleOnScreenNavigation->setChecked( @@ -87,12 +86,10 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) toolBar->addSeparator(); - QAction *actionIdentify = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionIdentify.svg" ) ), - tr( "Identify" ), this, &Qgs3DMapCanvasWidget::identify ); + QAction *actionIdentify = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionIdentify.svg" ) ), tr( "Identify" ), this, &Qgs3DMapCanvasWidget::identify ); actionIdentify->setCheckable( true ); - QAction *actionMeasurementTool = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionMeasure.svg" ) ), - tr( "Measurement Line" ), this, &Qgs3DMapCanvasWidget::measureLine ); + QAction *actionMeasurementTool = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionMeasure.svg" ) ), tr( "Measurement Line" ), this, &Qgs3DMapCanvasWidget::measureLine ); actionMeasurementTool->setCheckable( true ); // Create action group to make the action exclusive @@ -103,8 +100,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) actionGroup->setExclusive( true ); actionCameraControl->setChecked( true ); - mActionAnim = toolBar->addAction( QIcon( QgsApplication::iconPath( "mTaskRunning.svg" ) ), - tr( "Animations" ), this, &Qgs3DMapCanvasWidget::toggleAnimations ); + mActionAnim = toolBar->addAction( QIcon( QgsApplication::iconPath( "mTaskRunning.svg" ) ), tr( "Animations" ), this, &Qgs3DMapCanvasWidget::toggleAnimations ); mActionAnim->setCheckable( true ); // Export Menu @@ -116,11 +112,9 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) QToolButton *exportButton = qobject_cast( toolBar->widgetForAction( mActionExport ) ); exportButton->setPopupMode( QToolButton::ToolButtonPopupMode::InstantPopup ); - mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionSaveMapAsImage.svg" ) ), - tr( "Save as Image…" ), this, &Qgs3DMapCanvasWidget::saveAsImage ); + mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionSaveMapAsImage.svg" ) ), tr( "Save as Image…" ), this, &Qgs3DMapCanvasWidget::saveAsImage ); - mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "3d.svg" ) ), - tr( "Export 3D Scene" ), this, &Qgs3DMapCanvasWidget::exportScene ); + mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "3d.svg" ) ), tr( "Export 3D Scene" ), this, &Qgs3DMapCanvasWidget::exportScene ); toolBar->addSeparator(); @@ -150,8 +144,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mActionSync2DNavTo3D = new QAction( tr( "2D Map View Follows 3D Camera" ), this ); mActionSync2DNavTo3D->setCheckable( true ); - connect( mActionSync2DNavTo3D, &QAction::triggered, this, [ = ]( bool enabled ) - { + connect( mActionSync2DNavTo3D, &QAction::triggered, this, [=]( bool enabled ) { Qgis::ViewSyncModeFlags syncMode = mCanvas->mapSettings()->viewSyncMode(); syncMode.setFlag( Qgis::ViewSyncModeFlag::Sync2DTo3D, enabled ); mCanvas->mapSettings()->setViewSyncMode( syncMode ); @@ -160,8 +153,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mActionSync3DNavTo2D = new QAction( tr( "3D Camera Follows 2D Map View" ), this ); mActionSync3DNavTo2D->setCheckable( true ); - connect( mActionSync3DNavTo2D, &QAction::triggered, this, [ = ]( bool enabled ) - { + connect( mActionSync3DNavTo2D, &QAction::triggered, this, [=]( bool enabled ) { Qgis::ViewSyncModeFlags syncMode = mCanvas->mapSettings()->viewSyncMode(); syncMode.setFlag( Qgis::ViewSyncModeFlag::Sync3DTo2D, enabled ); mCanvas->mapSettings()->setViewSyncMode( syncMode ); @@ -170,17 +162,14 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mShowFrustumPolyogon = new QAction( tr( "Show Visible Camera Area in 2D Map View" ), this ); mShowFrustumPolyogon->setCheckable( true ); - connect( mShowFrustumPolyogon, &QAction::triggered, this, [ = ]( bool enabled ) - { + connect( mShowFrustumPolyogon, &QAction::triggered, this, [=]( bool enabled ) { mCanvas->mapSettings()->setViewFrustumVisualizationEnabled( enabled ); } ); mCameraMenu->addAction( mShowFrustumPolyogon ); - mActionSetSceneExtent = mCameraMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "extents.svg" ) ), - tr( "Set 3D Scene Extent on 2D Map View" ), this, &Qgs3DMapCanvasWidget::setSceneExtentOn2DCanvas ); + mActionSetSceneExtent = mCameraMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "extents.svg" ) ), tr( "Set 3D Scene Extent on 2D Map View" ), this, &Qgs3DMapCanvasWidget::setSceneExtentOn2DCanvas ); mActionSetSceneExtent->setCheckable( true ); - auto createShortcuts = [ = ]( const QString & objectName, void ( Qgs3DMapCanvasWidget::* slot )() ) - { + auto createShortcuts = [=]( const QString &objectName, void ( Qgs3DMapCanvasWidget::*slot )() ) { if ( QShortcut *sc = QgsGui::shortcutsManager()->shortcutByName( objectName ) ) connect( sc, &QShortcut::activated, this, slot ); }; @@ -197,8 +186,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mActionEnableShadows = new QAction( tr( "Show Shadows" ), this ); mActionEnableShadows->setCheckable( true ); - connect( mActionEnableShadows, &QAction::toggled, this, [ = ]( bool enabled ) - { + connect( mActionEnableShadows, &QAction::toggled, this, [=]( bool enabled ) { QgsShadowSettings settings = mCanvas->mapSettings()->shadowSettings(); settings.setRenderShadows( enabled ); mCanvas->mapSettings()->setShadowSettings( settings ); @@ -207,16 +195,14 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mActionEnableEyeDome = new QAction( tr( "Show Eye Dome Lighting" ), this ); mActionEnableEyeDome->setCheckable( true ); - connect( mActionEnableEyeDome, &QAction::triggered, this, [ = ]( bool enabled ) - { + connect( mActionEnableEyeDome, &QAction::triggered, this, [=]( bool enabled ) { mCanvas->mapSettings()->setEyeDomeLightingEnabled( enabled ); } ); mEffectsMenu->addAction( mActionEnableEyeDome ); mActionEnableAmbientOcclusion = new QAction( tr( "Show Ambient Occlusion" ), this ); mActionEnableAmbientOcclusion->setCheckable( true ); - connect( mActionEnableAmbientOcclusion, &QAction::triggered, this, [ = ]( bool enabled ) - { + connect( mActionEnableAmbientOcclusion, &QAction::triggered, this, [=]( bool enabled ) { QgsAmbientOcclusionSettings ambientOcclusionSettings = mCanvas->mapSettings()->ambientOcclusionSettings(); ambientOcclusionSettings.setEnabled( enabled ); mCanvas->mapSettings()->setAmbientOcclusionSettings( ambientOcclusionSettings ); @@ -224,16 +210,14 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mEffectsMenu->addAction( mActionEnableAmbientOcclusion ); // Options Menu - QAction *configureAction = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionOptions.svg" ) ), - tr( "Configure…" ), this ); + QAction *configureAction = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionOptions.svg" ) ), tr( "Configure…" ), this ); connect( configureAction, &QAction::triggered, this, &Qgs3DMapCanvasWidget::configure ); toolBar->addAction( configureAction ); mCanvas = new Qgs3DMapCanvas; mCanvas->setMinimumSize( QSize( 200, 200 ) ); - connect( mCanvas, &Qgs3DMapCanvas::savedAsImage, this, [ = ]( const QString & fileName ) - { + connect( mCanvas, &Qgs3DMapCanvas::savedAsImage, this, [=]( const QString &fileName ) { QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as Image" ), tr( "Successfully saved the 3D map to %2" ).arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) ); } ); @@ -271,8 +255,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mLabelNavSpeedHideTimeout = new QTimer( this ); mLabelNavSpeedHideTimeout->setInterval( 1000 ); - connect( mLabelNavSpeedHideTimeout, &QTimer::timeout, this, [ = ] - { + connect( mLabelNavSpeedHideTimeout, &QTimer::timeout, this, [=] { mLabelNavigationSpeed->hide(); mLabelNavSpeedHideTimeout->stop(); } ); @@ -321,12 +304,10 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) } QAction *dockAction = mDockableWidgetHelper->createDockUndockAction( tr( "Dock 3D Map View" ), this ); toolBar->addAction( dockAction ); - connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [ = ]() - { + connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [=]() { QgisApp::instance()->close3DMapView( canvasName() ); } ); - connect( dockAction, &QAction::toggled, this, [ = ]( const bool isSmallSize ) - { + connect( dockAction, &QAction::toggled, this, [=]( const bool isSmallSize ) { toolBar->setIconSize( QgisApp::instance()->iconSize( isSmallSize ) ); } ); } @@ -338,7 +319,7 @@ Qgs3DMapCanvasWidget::~Qgs3DMapCanvasWidget() void Qgs3DMapCanvasWidget::saveAsImage() { - const QPair< QString, QString> fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( this, tr( "Choose a file name to save the 3D map canvas to an image" ) ); + const QPair fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( this, tr( "Choose a file name to save the 3D map canvas to an image" ) ); if ( !fileNameAndFilter.first.isEmpty() ) { mCanvas->saveAsImage( fileNameAndFilter.first, fileNameAndFilter.second ); @@ -447,9 +428,7 @@ void Qgs3DMapCanvasWidget::setMapSettings( Qgs3DMapSettings *map ) mAnimationWidget->setMap( map ); // Disable button for switching the map theme if the terrain generator is a mesh, or if there is no terrain - mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled() - || !mCanvas->mapSettings()->terrainGenerator() - || mCanvas->mapSettings()->terrainGenerator()->type() == QgsTerrainGenerator::Mesh ); + mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled() || !mCanvas->mapSettings()->terrainGenerator() || mCanvas->mapSettings()->terrainGenerator()->type() == QgsTerrainGenerator::Mesh ); mLabelFpsCounter->setVisible( map->isFpsCounterEnabled() ); connect( map, &Qgs3DMapSettings::viewFrustumVisualizationEnabledChanged, this, &Qgs3DMapCanvasWidget::onViewFrustumVisualizationEnabledChanged ); @@ -462,7 +441,7 @@ void Qgs3DMapCanvasWidget::setMainCanvas( QgsMapCanvas *canvas ) { mMainCanvas = canvas; - mMapToolExtent = std::make_unique< QgsMapToolExtent >( canvas ); + mMapToolExtent = std::make_unique( canvas ); mMapToolExtent->setAction( mActionSetSceneExtent ); connect( mMapToolExtent.get(), &QgsMapToolExtent::extentChanged, this, &Qgs3DMapCanvasWidget::setSceneExtent ); @@ -507,8 +486,7 @@ void Qgs3DMapCanvasWidget::configure() Qgs3DMapConfigWidget *w = new Qgs3DMapConfigWidget( map, mMainCanvas, mCanvas, mConfigureDialog ); QDialogButtonBox *buttons = new QDialogButtonBox( QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, mConfigureDialog ); - auto applyConfig = [ = ]() - { + auto applyConfig = [=]() { const QgsVector3D oldOrigin = map->origin(); const QgsCoordinateReferenceSystem oldCrs = map->crs(); const QgsCameraPose oldCameraPose = mCanvas->cameraController()->cameraPose(); @@ -518,9 +496,10 @@ void Qgs3DMapCanvasWidget::configure() w->apply(); const QgsVector3D p = Qgs3DUtils::transformWorldCoordinates( - oldLookingAt, - oldOrigin, oldCrs, - map->origin(), map->crs(), QgsProject::instance()->transformContext() ); + oldLookingAt, + oldOrigin, oldCrs, + map->origin(), map->crs(), QgsProject::instance()->transformContext() + ); if ( p != oldLookingAt ) { @@ -531,14 +510,11 @@ void Qgs3DMapCanvasWidget::configure() } // Disable map theme button if the terrain generator is a mesh, or if there is no terrain - mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled() - || !mCanvas->mapSettings()->terrainGenerator() - || map->terrainGenerator()->type() == QgsTerrainGenerator::Mesh ); + mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled() || !mCanvas->mapSettings()->terrainGenerator() || map->terrainGenerator()->type() == QgsTerrainGenerator::Mesh ); }; connect( buttons, &QDialogButtonBox::rejected, mConfigureDialog, &QDialog::reject ); - connect( buttons, &QDialogButtonBox::clicked, mConfigureDialog, [ = ]( QAbstractButton * button ) - { + connect( buttons, &QDialogButtonBox::clicked, mConfigureDialog, [=]( QAbstractButton *button ) { if ( button == buttons->button( QDialogButtonBox::Apply ) || button == buttons->button( QDialogButtonBox::Ok ) ) applyConfig(); if ( button == buttons->button( QDialogButtonBox::Ok ) ) @@ -546,8 +522,7 @@ void Qgs3DMapCanvasWidget::configure() } ); connect( buttons, &QDialogButtonBox::helpRequested, w, []() { QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html#scene-configuration" ) ); } ); - connect( w, &Qgs3DMapConfigWidget::isValidChanged, this, [ = ]( bool valid ) - { + connect( w, &Qgs3DMapConfigWidget::isValidChanged, this, [=]( bool valid ) { buttons->button( QDialogButtonBox::Apply )->setEnabled( valid ); buttons->button( QDialogButtonBox::Ok )->setEnabled( valid ); } ); @@ -568,7 +543,6 @@ void Qgs3DMapCanvasWidget::configure() void Qgs3DMapCanvasWidget::exportScene() { - QDialog dlg; dlg.setWindowTitle( tr( "Export 3D Scene" ) ); dlg.setObjectName( QStringLiteral( "3DSceneExportDialog" ) ); @@ -581,7 +555,7 @@ void Qgs3DMapCanvasWidget::exportScene() connect( buttons, &QDialogButtonBox::accepted, &dlg, &QDialog::accept ); connect( buttons, &QDialogButtonBox::rejected, &dlg, &QDialog::reject ); - connect( buttons, &QDialogButtonBox::helpRequested, &dlg, [ = ] { QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html" ) ); } ); + connect( buttons, &QDialogButtonBox::helpRequested, &dlg, [=] { QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html" ) ); } ); QVBoxLayout *layout = new QVBoxLayout( &dlg ); layout->addWidget( &w, 1 ); @@ -634,8 +608,7 @@ void Qgs3DMapCanvasWidget::mapThemeMenuAboutToShow() { actionFollowMain->setChecked( true ); } - connect( actionFollowMain, &QAction::triggered, this, [ = ] - { + connect( actionFollowMain, &QAction::triggered, this, [=] { mCanvas->mapSettings()->setTerrainMapTheme( QString() ); } ); mMapThemeMenuPresetActions.append( actionFollowMain ); @@ -649,8 +622,7 @@ void Qgs3DMapCanvasWidget::mapThemeMenuAboutToShow() { a->setChecked( true ); } - connect( a, &QAction::triggered, this, [a, this] - { + connect( a, &QAction::triggered, this, [a, this] { mCanvas->mapSettings()->setTerrainMapTheme( a->text() ); } ); mMapThemeMenuPresetActions.append( a ); @@ -739,7 +711,8 @@ void Qgs3DMapCanvasWidget::onGpuMemoryLimitReached() double memLimit = settings.value( QStringLiteral( "map3d/gpuMemoryLimit" ), 500.0, QgsSettings::App ).toDouble(); mMessageBar->pushMessage( tr( "A map layer has used all graphics memory allowed (%1 MB). " "You may want to lower the amount of detail in the scene, or increase the limit in the options." ) - .arg( memLimit ), Qgis::MessageLevel::Warning ); + .arg( memLimit ), + Qgis::MessageLevel::Warning ); mGpuMemoryLimitReachedReported = true; } diff --git a/src/app/3d/qgs3dmapcanvaswidget.h b/src/app/3d/qgs3dmapcanvaswidget.h index 768529389e7e..0a941879998d 100644 --- a/src/app/3d/qgs3dmapcanvaswidget.h +++ b/src/app/3d/qgs3dmapcanvaswidget.h @@ -132,8 +132,8 @@ class APP_EXPORT Qgs3DMapCanvasWidget : public QWidget QAction *mActionEffects = nullptr; QAction *mActionSetSceneExtent = nullptr; QgsDockableWidgetHelper *mDockableWidgetHelper = nullptr; - QObjectUniquePtr< QgsRubberBand > mViewFrustumHighlight; - QObjectUniquePtr< QgsRubberBand > mViewExtentHighlight; + QObjectUniquePtr mViewFrustumHighlight; + QObjectUniquePtr mViewExtentHighlight; QPointer mConfigureDialog; QgsMessageBar *mMessageBar = nullptr; bool mGpuMemoryLimitReachedReported = false; diff --git a/src/app/3d/qgs3dmapconfigwidget.cpp b/src/app/3d/qgs3dmapconfigwidget.cpp index ccc77356a1af..4adf25bbe645 100644 --- a/src/app/3d/qgs3dmapconfigwidget.cpp +++ b/src/app/3d/qgs3dmapconfigwidget.cpp @@ -50,7 +50,7 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas const QgsSettings settings; const int iconSize = QgsGuiUtils::scaleIconSize( 20 ); - m3DOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) ) ; + m3DOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) ); mCameraNavigationModeCombo->addItem( tr( "Terrain Based" ), QVariant::fromValue( Qgis::NavigationMode::TerrainBased ) ); mCameraNavigationModeCombo->addItem( tr( "Walk Mode (First Person)" ), QVariant::fromValue( Qgis::NavigationMode::Walk ) ); @@ -58,7 +58,7 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas // get rid of annoying outer focus rect on Mac m3DOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect, false ); m3DOptionsListWidget->setCurrentRow( settings.value( QStringLiteral( "Windows/3DMapConfig/Tab" ), 0 ).toInt() ); - connect( m3DOptionsListWidget, &QListWidget::currentRowChanged, this, [ = ]( int index ) { m3DOptionsStackedWidget->setCurrentIndex( index ); } ); + connect( m3DOptionsListWidget, &QListWidget::currentRowChanged, this, [=]( int index ) { m3DOptionsStackedWidget->setCurrentIndex( index ); } ); m3DOptionsStackedWidget->setCurrentIndex( m3DOptionsListWidget->currentRow() ); if ( !settings.contains( QStringLiteral( "Windows/3DMapConfig/OptionsSplitState" ) ) ) @@ -75,8 +75,7 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas cboCameraProjectionType->addItem( tr( "Perspective Projection" ), Qt3DRender::QCameraLens::PerspectiveProjection ); cboCameraProjectionType->addItem( tr( "Orthogonal Projection" ), Qt3DRender::QCameraLens::OrthographicProjection ); - connect( cboCameraProjectionType, static_cast( &QComboBox::currentIndexChanged ), this, [ = ]() - { + connect( cboCameraProjectionType, static_cast( &QComboBox::currentIndexChanged ), this, [=]() { spinCameraFieldOfView->setEnabled( cboCameraProjectionType->currentIndex() == cboCameraProjectionType->findData( Qt3DRender::QCameraLens::PerspectiveProjection ) ); } ); @@ -194,16 +193,16 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas // ================== // Page: 3D axis - mCbo3dAxisType->addItem( tr( "Coordinate Reference System" ), static_cast< int >( Qgs3DAxisSettings::Mode::Crs ) ); - mCbo3dAxisType->addItem( tr( "Cube" ), static_cast< int >( Qgs3DAxisSettings::Mode::Cube ) ); + mCbo3dAxisType->addItem( tr( "Coordinate Reference System" ), static_cast( Qgs3DAxisSettings::Mode::Crs ) ); + mCbo3dAxisType->addItem( tr( "Cube" ), static_cast( Qgs3DAxisSettings::Mode::Cube ) ); - mCbo3dAxisHorizPos->addItem( tr( "Left" ), static_cast< int >( Qt::AnchorPoint::AnchorLeft ) ); - mCbo3dAxisHorizPos->addItem( tr( "Center" ), static_cast< int >( Qt::AnchorPoint::AnchorHorizontalCenter ) ); - mCbo3dAxisHorizPos->addItem( tr( "Right" ), static_cast< int >( Qt::AnchorPoint::AnchorRight ) ); + mCbo3dAxisHorizPos->addItem( tr( "Left" ), static_cast( Qt::AnchorPoint::AnchorLeft ) ); + mCbo3dAxisHorizPos->addItem( tr( "Center" ), static_cast( Qt::AnchorPoint::AnchorHorizontalCenter ) ); + mCbo3dAxisHorizPos->addItem( tr( "Right" ), static_cast( Qt::AnchorPoint::AnchorRight ) ); - mCbo3dAxisVertPos->addItem( tr( "Top" ), static_cast< int >( Qt::AnchorPoint::AnchorTop ) ); - mCbo3dAxisVertPos->addItem( tr( "Middle" ), static_cast< int >( Qt::AnchorPoint::AnchorVerticalCenter ) ); - mCbo3dAxisVertPos->addItem( tr( "Bottom" ), static_cast< int >( Qt::AnchorPoint::AnchorBottom ) ); + mCbo3dAxisVertPos->addItem( tr( "Top" ), static_cast( Qt::AnchorPoint::AnchorTop ) ); + mCbo3dAxisVertPos->addItem( tr( "Middle" ), static_cast( Qt::AnchorPoint::AnchorVerticalCenter ) ); + mCbo3dAxisVertPos->addItem( tr( "Bottom" ), static_cast( Qt::AnchorPoint::AnchorBottom ) ); init3DAxisPage(); @@ -276,9 +275,7 @@ void Qgs3DMapConfigWidget::apply() { // if we already have a DEM terrain generator, check whether there was actually any change QgsDemTerrainGenerator *oldDemTerrainGen = static_cast( mMap->terrainGenerator() ); - if ( oldDemTerrainGen->layer() == demLayer && - oldDemTerrainGen->resolution() == spinTerrainResolution->value() && - oldDemTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() ) + if ( oldDemTerrainGen->layer() == demLayer && oldDemTerrainGen->resolution() == spinTerrainResolution->value() && oldDemTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() ) tGenNeedsUpdate = false; } @@ -299,8 +296,7 @@ void Qgs3DMapConfigWidget::apply() if ( mMap->terrainGenerator()->type() == QgsTerrainGenerator::Online ) { QgsOnlineTerrainGenerator *oldOnlineTerrainGen = static_cast( mMap->terrainGenerator() ); - if ( oldOnlineTerrainGen->resolution() == spinTerrainResolution->value() && - oldOnlineTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() ) + if ( oldOnlineTerrainGen->resolution() == spinTerrainResolution->value() && oldOnlineTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() ) tGenNeedsUpdate = false; } @@ -320,7 +316,7 @@ void Qgs3DMapConfigWidget::apply() QgsMeshTerrainGenerator *newTerrainGenerator = new QgsMeshTerrainGenerator; newTerrainGenerator->setCrs( mMap->crs(), QgsProject::instance()->transformContext() ); newTerrainGenerator->setLayer( meshLayer ); - std::unique_ptr< QgsMesh3DSymbol > symbol = mMeshSymbolWidget->symbol(); + std::unique_ptr symbol = mMeshSymbolWidget->symbol(); symbol->setVerticalScale( spinTerrainScale->value() ); newTerrainGenerator->setSymbol( symbol.release() ); mMap->setTerrainGenerator( newTerrainGenerator ); @@ -337,8 +333,8 @@ void Qgs3DMapConfigWidget::apply() } mMap->setFieldOfView( spinCameraFieldOfView->value() ); - mMap->setProjectionType( cboCameraProjectionType->currentData().value< Qt3DRender::QCameraLens::ProjectionType >() ); - mMap->setCameraNavigationMode( mCameraNavigationModeCombo->currentData().value< Qgis::NavigationMode>() ); + mMap->setProjectionType( cboCameraProjectionType->currentData().value() ); + mMap->setCameraNavigationMode( mCameraNavigationModeCombo->currentData().value() ); mMap->setCameraMovementSpeed( mCameraMovementSpeed->value() ); mMap->setTerrainVerticalScale( spinTerrainScale->value() ); mMap->setMapTileResolution( spinMapResolution->value() ); @@ -350,8 +346,8 @@ void Qgs3DMapConfigWidget::apply() mMap->setShowDebugPanel( chkShowDebugPanel->isChecked() ); mMap->setTerrainShadingEnabled( groupTerrainShading->isChecked() ); - const std::unique_ptr< QgsAbstractMaterialSettings > terrainMaterial( widgetTerrainMaterial->settings() ); - if ( QgsPhongMaterialSettings *phongMaterial = dynamic_cast< QgsPhongMaterialSettings * >( terrainMaterial.get() ) ) + const std::unique_ptr terrainMaterial( widgetTerrainMaterial->settings() ); + if ( QgsPhongMaterialSettings *phongMaterial = dynamic_cast( terrainMaterial.get() ) ) mMap->setTerrainShadingMaterial( *phongMaterial ); mMap->setLightSources( widgetLights->lightSources() ); @@ -448,7 +444,7 @@ void Qgs3DMapConfigWidget::validate() switch ( static_cast( cboTerrainType->currentData().toInt() ) ) { case QgsTerrainGenerator::Dem: - if ( ! cboTerrainLayer->currentLayer() ) + if ( !cboTerrainLayer->currentLayer() ) { valid = false; mMessageBar->pushMessage( tr( "An elevation layer must be selected for a DEM terrain" ), Qgis::MessageLevel::Critical ); @@ -456,7 +452,7 @@ void Qgs3DMapConfigWidget::validate() break; case QgsTerrainGenerator::Mesh: - if ( ! cboTerrainLayer->currentLayer() ) + if ( !cboTerrainLayer->currentLayer() ) { valid = false; mMessageBar->pushMessage( tr( "An elevation layer must be selected for a mesh terrain" ), Qgis::MessageLevel::Critical ); @@ -464,7 +460,7 @@ void Qgs3DMapConfigWidget::validate() break; case QgsTerrainGenerator::QuantizedMesh: - if ( ! cboTerrainLayer->currentLayer() ) + if ( !cboTerrainLayer->currentLayer() ) { valid = false; mMessageBar->pushMessage( tr( "An elevation layer must be selected for a quantized mesh terrain" ), Qgis::MessageLevel::Critical ); @@ -498,11 +494,11 @@ void Qgs3DMapConfigWidget::init3DAxisPage() else { mGroupBox3dAxis->setChecked( true ); - mCbo3dAxisType->setCurrentIndex( mCbo3dAxisType->findData( static_cast< int >( s.mode() ) ) ); + mCbo3dAxisType->setCurrentIndex( mCbo3dAxisType->findData( static_cast( s.mode() ) ) ); } - mCbo3dAxisHorizPos->setCurrentIndex( mCbo3dAxisHorizPos->findData( static_cast< int >( s.horizontalPosition() ) ) ); - mCbo3dAxisVertPos->setCurrentIndex( mCbo3dAxisVertPos->findData( static_cast< int >( s.verticalPosition() ) ) ); + mCbo3dAxisHorizPos->setCurrentIndex( mCbo3dAxisHorizPos->findData( static_cast( s.horizontalPosition() ) ) ); + mCbo3dAxisVertPos->setCurrentIndex( mCbo3dAxisVertPos->findData( static_cast( s.verticalPosition() ) ) ); } void Qgs3DMapConfigWidget::on3DAxisChanged() @@ -511,7 +507,7 @@ void Qgs3DMapConfigWidget::on3DAxisChanged() Qgs3DAxisSettings::Mode m; if ( mGroupBox3dAxis->isChecked() ) - m = static_cast< Qgs3DAxisSettings::Mode >( mCbo3dAxisType->currentData().toInt() ); + m = static_cast( mCbo3dAxisType->currentData().toInt() ); else m = Qgs3DAxisSettings::Mode::Off; @@ -521,8 +517,8 @@ void Qgs3DMapConfigWidget::on3DAxisChanged() } else { - const Qt::AnchorPoint hPos = static_cast< Qt::AnchorPoint >( mCbo3dAxisHorizPos->currentData().toInt() ); - const Qt::AnchorPoint vPos = static_cast< Qt::AnchorPoint >( mCbo3dAxisVertPos->currentData().toInt() ); + const Qt::AnchorPoint hPos = static_cast( mCbo3dAxisHorizPos->currentData().toInt() ); + const Qt::AnchorPoint vPos = static_cast( mCbo3dAxisVertPos->currentData().toInt() ); if ( s.horizontalPosition() != hPos || s.verticalPosition() != vPos ) { diff --git a/src/app/3d/qgs3dmaptoolidentify.cpp b/src/app/3d/qgs3dmaptoolidentify.cpp index 649c55b4da24..bf3e05f74709 100644 --- a/src/app/3d/qgs3dmaptoolidentify.cpp +++ b/src/app/3d/qgs3dmaptoolidentify.cpp @@ -50,8 +50,7 @@ void Qgs3DMapToolIdentify::mousePressEvent( QMouseEvent *event ) void Qgs3DMapToolIdentify::mouseMoveEvent( QMouseEvent *event ) { - if ( !mMouseHasMoved && - ( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() ) + if ( !mMouseHasMoved && ( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() ) { mMouseHasMoved = true; } @@ -78,7 +77,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event ) for ( auto it = allHits.constKeyValueBegin(); it != allHits.constKeyValueEnd(); ++it ) { // We can directly show vector layer results - if ( QgsVectorLayer *vlayer = qobject_cast( it->first ) ) + if ( QgsVectorLayer *vlayer = qobject_cast( it->first ) ) { const QgsRayCastingUtils::RayHit hit = it->second.first(); const QgsVector3D mapCoords = Qgs3DUtils::worldToMapCoordinates( hit.pos, mCanvas->mapSettings()->origin() ); @@ -98,7 +97,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event ) showTerrainResults = false; } // We need to restructure point cloud layer results to display them later. We may have multiple hits for each layer. - else if ( QgsPointCloudLayer *pclayer = qobject_cast( it->first ) ) + else if ( QgsPointCloudLayer *pclayer = qobject_cast( it->first ) ) { QVector pointCloudResults; for ( const QgsRayCastingUtils::RayHit &hit : it->second ) @@ -114,7 +113,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event ) const QgsRayCastingUtils::RayHit hit = it->second.first(); const QgsVector3D mapCoords = Qgs3DUtils::worldToMapCoordinates( hit.pos, mCanvas->mapSettings()->origin() ); - QMap< QString, QString > derivedAttributes; + QMap derivedAttributes; QString x; QString y; QgsCoordinateUtils::formatCoordinatePartsForProject( @@ -133,7 +132,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event ) { derivedAttributes[key] = hit.attributes[key].toString(); } - QString nodeId = derivedAttributes[ QStringLiteral( "node_id" ) ]; + QString nodeId = derivedAttributes[QStringLiteral( "node_id" )]; // only derived attributes are supported for now, so attributes is empty QgsMapToolIdentify::IdentifyResult res( it->first, nodeId, {}, derivedAttributes ); tiledSceneIdentifyResults.append( res ); diff --git a/src/app/3d/qgs3dmaptoolmeasureline.cpp b/src/app/3d/qgs3dmaptoolmeasureline.cpp index a17f40bf44d3..331113750382 100644 --- a/src/app/3d/qgs3dmaptoolmeasureline.cpp +++ b/src/app/3d/qgs3dmaptoolmeasureline.cpp @@ -32,7 +32,7 @@ Qgs3DMapToolMeasureLine::Qgs3DMapToolMeasureLine( Qgs3DMapCanvas *canvas ) : Qgs3DMapTool( canvas ) { // Dialog - mDialog = std::make_unique< Qgs3DMeasureDialog >( this ); + mDialog = std::make_unique( this ); mDialog->setWindowFlags( mDialog->windowFlags() | Qt::Tool ); mDialog->restorePosition(); } @@ -97,10 +97,7 @@ void Qgs3DMapToolMeasureLine::handleClick( const QPoint &screenPos ) if ( minDist < 0 || resDist < minDist ) { minDist = resDist; - worldIntersection = QgsVector3D( result.pos.x(), - result.pos.y(), - result.pos.z() - ); + worldIntersection = QgsVector3D( result.pos.x(), result.pos.y(), result.pos.z() ); } } const QgsVector3D mapCoords = Qgs3DUtils::worldToMapCoordinates( worldIntersection, mCanvas->mapSettings()->origin() ); @@ -189,8 +186,7 @@ void Qgs3DMapToolMeasureLine::mousePressEvent( QMouseEvent *event ) void Qgs3DMapToolMeasureLine::mouseMoveEvent( QMouseEvent *event ) { - if ( !mMouseHasMoved && - ( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() ) + if ( !mMouseHasMoved && ( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() ) { mMouseHasMoved = true; } @@ -228,8 +224,7 @@ void Qgs3DMapToolMeasureLine::mouseReleaseEvent( QMouseEvent *event ) void Qgs3DMapToolMeasureLine::keyPressEvent( QKeyEvent *event ) { - if ( event->key() == Qt::Key_Backspace || - event->key() == Qt::Key_Delete ) + if ( event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ) { undo(); } diff --git a/src/app/3d/qgs3dmeasuredialog.cpp b/src/app/3d/qgs3dmeasuredialog.cpp index d45f46489b11..c02f8c46dc02 100644 --- a/src/app/3d/qgs3dmeasuredialog.cpp +++ b/src/app/3d/qgs3dmeasuredialog.cpp @@ -122,17 +122,17 @@ double Qgs3DMeasureDialog::lastHorizontalDistance() void Qgs3DMeasureDialog::repopulateComboBoxUnits() { - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Meters ), static_cast< int >( Qgis::DistanceUnit::Meters ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Kilometers ), static_cast< int >( Qgis::DistanceUnit::Kilometers ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Feet ), static_cast< int >( Qgis::DistanceUnit::Feet ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Yards ), static_cast< int >( Qgis::DistanceUnit::Yards ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Miles ), static_cast< int >( Qgis::DistanceUnit::Miles ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::NauticalMiles ), static_cast< int >( Qgis::DistanceUnit::NauticalMiles ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Centimeters ), static_cast< int >( Qgis::DistanceUnit::Centimeters ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Millimeters ), static_cast< int >( Qgis::DistanceUnit::Millimeters ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Inches ), static_cast< int >( Qgis::DistanceUnit::Inches ) ); - mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Degrees ), static_cast< int >( Qgis::DistanceUnit::Degrees ) ); - mUnitsCombo->addItem( tr( "map units" ), static_cast< int >( Qgis::DistanceUnit::Unknown ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Meters ), static_cast( Qgis::DistanceUnit::Meters ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Kilometers ), static_cast( Qgis::DistanceUnit::Kilometers ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Feet ), static_cast( Qgis::DistanceUnit::Feet ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Yards ), static_cast( Qgis::DistanceUnit::Yards ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Miles ), static_cast( Qgis::DistanceUnit::Miles ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::NauticalMiles ), static_cast( Qgis::DistanceUnit::NauticalMiles ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Centimeters ), static_cast( Qgis::DistanceUnit::Centimeters ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Millimeters ), static_cast( Qgis::DistanceUnit::Millimeters ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Inches ), static_cast( Qgis::DistanceUnit::Inches ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Degrees ), static_cast( Qgis::DistanceUnit::Degrees ) ); + mUnitsCombo->addItem( tr( "map units" ), static_cast( Qgis::DistanceUnit::Unknown ) ); } void Qgs3DMeasureDialog::removeLastPoint() @@ -176,15 +176,15 @@ void Qgs3DMeasureDialog::updateSettings() mDecimalPlaces = settings.value( QStringLiteral( "qgis/measure/decimalplaces" ), "3" ).toInt(); mMapDistanceUnit = mTool->canvas()->mapSettings()->crs().mapUnits(); mDisplayedDistanceUnit = QgsUnitTypes::decodeDistanceUnit( - settings.value( QStringLiteral( "qgis/measure/displayunits" ), - QgsUnitTypes::encodeUnit( Qgis::DistanceUnit::Unknown ) ).toString() ); + settings.value( QStringLiteral( "qgis/measure/displayunits" ), QgsUnitTypes::encodeUnit( Qgis::DistanceUnit::Unknown ) ).toString() + ); setupTableHeader(); - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( mDisplayedDistanceUnit ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( mDisplayedDistanceUnit ) ) ); } void Qgs3DMeasureDialog::unitsChanged( int index ) { - mDisplayedDistanceUnit = static_cast< Qgis::DistanceUnit >( mUnitsCombo->itemData( index ).toInt() ); + mDisplayedDistanceUnit = static_cast( mUnitsCombo->itemData( index ).toInt() ); updateTable(); updateTotal(); } @@ -265,7 +265,7 @@ void Qgs3DMeasureDialog::updateTable() QVector::const_iterator it; bool isFirstPoint = true; // first point QgsPoint p1, p2; - const QVector< QgsPoint > tmpPoints = mTool->points(); + const QVector tmpPoints = mTool->points(); for ( it = tmpPoints.constBegin(); it != tmpPoints.constEnd(); ++it ) { p2 = *it; diff --git a/src/app/3d/qgs3dmeasuredialog.h b/src/app/3d/qgs3dmeasuredialog.h index 72ce92726a01..d3daff03b399 100644 --- a/src/app/3d/qgs3dmeasuredialog.h +++ b/src/app/3d/qgs3dmeasuredialog.h @@ -86,10 +86,10 @@ class Qgs3DMeasureDialog : public QDialog, private Ui::QgsMeasureBase int mDecimalPlaces = 3; //! Distance unit of the map - Qgis::DistanceUnit mMapDistanceUnit = Qgis::DistanceUnit::Unknown; + Qgis::DistanceUnit mMapDistanceUnit = Qgis::DistanceUnit::Unknown; //! Distance unit of the displayed value - Qgis::DistanceUnit mDisplayedDistanceUnit = Qgis::DistanceUnit::Unknown; + Qgis::DistanceUnit mDisplayedDistanceUnit = Qgis::DistanceUnit::Unknown; //! Convert from mMapDistanceUnit to mDisplayedDistanceUnit double convertLength( double length, Qgis::DistanceUnit toUnit ) const; diff --git a/src/app/3d/qgs3dmodelsourcelineedit.h b/src/app/3d/qgs3dmodelsourcelineedit.h index 41649176a3d7..3ad1a1072aef 100644 --- a/src/app/3d/qgs3dmodelsourcelineedit.h +++ b/src/app/3d/qgs3dmodelsourcelineedit.h @@ -32,7 +32,6 @@ class Qgs3DModelSourceLineEdit : public QgsAbstractFileContentSourceLineEdit { Q_OBJECT public: - /** * Constructor for Qgs3DModelSourceLineEdit, with the specified \a parent widget. */ @@ -42,7 +41,7 @@ class Qgs3DModelSourceLineEdit : public QgsAbstractFileContentSourceLineEdit private: #ifndef SIP_RUN -///@cond PRIVATE + ///@cond PRIVATE QString fileFilter() const override; QString selectFileTitle() const override; QString fileFromUrlTitle() const override; diff --git a/src/app/3d/qgs3dnavigationwidget.cpp b/src/app/3d/qgs3dnavigationwidget.cpp index 4d72d3a2a490..ce4ac647705c 100644 --- a/src/app/3d/qgs3dnavigationwidget.cpp +++ b/src/app/3d/qgs3dnavigationwidget.cpp @@ -32,7 +32,8 @@ Q_NOWARN_DEPRECATED_POP #include -Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *parent ) : QWidget( parent ) +Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *parent ) + : QWidget( parent ) { setupUi( this ); @@ -42,10 +43,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mZoomInButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->zoom( 5 ); - } + [=] { + m3DMapCanvas->cameraController()->zoom( 5 ); + } ); // Zoom out button @@ -53,10 +53,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mZoomOutButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->zoom( -5 ); - } + [=] { + m3DMapCanvas->cameraController()->zoom( -5 ); + } ); // Tilt up button @@ -64,10 +63,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mTiltUpButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( 1 ); - } + [=] { + m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( 1 ); + } ); // Tilt down button @@ -75,10 +73,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mTiltDownButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( -1 ); - } + [=] { + m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( -1 ); + } ); // Compas @@ -89,10 +86,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mCompass, &QwtDial::valueChanged, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->setCameraHeadingAngle( float( mCompass->value() ) ); - } + [=] { + m3DMapCanvas->cameraController()->setCameraHeadingAngle( float( mCompass->value() ) ); + } ); // Move up button @@ -100,10 +96,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mMoveUpButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->moveView( 0, 1 ); - } + [=] { + m3DMapCanvas->cameraController()->moveView( 0, 1 ); + } ); // Move right button @@ -111,10 +106,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mMoveRightButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->moveView( 1, 0 ); - } + [=] { + m3DMapCanvas->cameraController()->moveView( 1, 0 ); + } ); // Move down button @@ -122,10 +116,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mMoveDownButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->moveView( 0, -1 ); - } + [=] { + m3DMapCanvas->cameraController()->moveView( 0, -1 ); + } ); // Move left button @@ -133,9 +126,8 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p mMoveLeftButton, &QToolButton::clicked, m3DMapCanvas, - [ = ] - { - m3DMapCanvas->cameraController()->moveView( -1, 0 ); - } + [=] { + m3DMapCanvas->cameraController()->moveView( -1, 0 ); + } ); } diff --git a/src/app/3d/qgs3doptions.cpp b/src/app/3d/qgs3doptions.cpp index 11d9817e05d5..89b1befaa3ff 100644 --- a/src/app/3d/qgs3doptions.cpp +++ b/src/app/3d/qgs3doptions.cpp @@ -52,7 +52,7 @@ Qgs3DOptionsWidget::Qgs3DOptionsWidget( QWidget *parent ) mInvertVerticalAxisCombo->setCurrentIndex( mInvertVerticalAxisCombo->findData( QVariant::fromValue( axisInversion ) ) ); const Qt3DRender::QCameraLens::ProjectionType defaultProjection = settings.enumValue( QStringLiteral( "map3d/defaultProjection" ), Qt3DRender::QCameraLens::PerspectiveProjection, QgsSettings::App ); - cboCameraProjectionType->setCurrentIndex( cboCameraProjectionType->findData( static_cast< int >( defaultProjection ) ) ); + cboCameraProjectionType->setCurrentIndex( cboCameraProjectionType->findData( static_cast( defaultProjection ) ) ); mCameraMovementSpeed->setValue( settings.value( QStringLiteral( "map3d/defaultMovementSpeed" ), 5, QgsSettings::App ).toDouble() ); spinCameraFieldOfView->setValue( settings.value( QStringLiteral( "map3d/defaultFieldOfView" ), 45, QgsSettings::App ).toInt() ); @@ -70,9 +70,9 @@ QString Qgs3DOptionsWidget::helpKey() const void Qgs3DOptionsWidget::apply() { QgsSettings settings; - settings.setEnumValue( QStringLiteral( "map3d/defaultNavigation" ), mCameraNavigationModeCombo->currentData().value< Qgis::NavigationMode >(), QgsSettings::App ); - settings.setEnumValue( QStringLiteral( "map3d/axisInversion" ), mInvertVerticalAxisCombo->currentData().value< Qgis::VerticalAxisInversion >(), QgsSettings::App ); - settings.setValue( QStringLiteral( "map3d/defaultProjection" ), static_cast< Qt3DRender::QCameraLens::ProjectionType >( cboCameraProjectionType->currentData().toInt() ), QgsSettings::App ); + settings.setEnumValue( QStringLiteral( "map3d/defaultNavigation" ), mCameraNavigationModeCombo->currentData().value(), QgsSettings::App ); + settings.setEnumValue( QStringLiteral( "map3d/axisInversion" ), mInvertVerticalAxisCombo->currentData().value(), QgsSettings::App ); + settings.setValue( QStringLiteral( "map3d/defaultProjection" ), static_cast( cboCameraProjectionType->currentData().toInt() ), QgsSettings::App ); settings.setValue( QStringLiteral( "map3d/defaultMovementSpeed" ), mCameraMovementSpeed->value(), QgsSettings::App ); settings.setValue( QStringLiteral( "map3d/defaultFieldOfView" ), spinCameraFieldOfView->value(), QgsSettings::App ); @@ -86,7 +86,6 @@ void Qgs3DOptionsWidget::apply() Qgs3DOptionsFactory::Qgs3DOptionsFactory() : QgsOptionsWidgetFactory( tr( "3D" ), QIcon(), QStringLiteral( "3d" ) ) { - } QIcon Qgs3DOptionsFactory::icon() const diff --git a/src/app/3d/qgs3doptions.h b/src/app/3d/qgs3doptions.h index e23ff691367a..3f786576bab6 100644 --- a/src/app/3d/qgs3doptions.h +++ b/src/app/3d/qgs3doptions.h @@ -31,14 +31,12 @@ class Qgs3DOptionsWidget : public QgsOptionsPageWidget, private Ui::Qgs3DOptions Q_OBJECT public: - /** * Constructor for Qgs3DOptionsWidget with the specified \a parent widget. */ Qgs3DOptionsWidget( QWidget *parent ); QString helpKey() const override; void apply() override; - }; @@ -47,13 +45,11 @@ class Qgs3DOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - Qgs3DOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QString pagePositionHint() const override; - }; diff --git a/src/app/3d/qgs3dviewsmanagerdialog.h b/src/app/3d/qgs3dviewsmanagerdialog.h index 74afaa4ae02a..5aac3c9f3c26 100644 --- a/src/app/3d/qgs3dviewsmanagerdialog.h +++ b/src/app/3d/qgs3dviewsmanagerdialog.h @@ -43,6 +43,7 @@ class Qgs3DViewsManagerDialog : public QDialog, private Ui::Qgs3DViewsManagerDia void currentChanged( const QModelIndex ¤t, const QModelIndex &previous ); void on3DViewsListChanged(); + private: QStringListModel *mListModel = nullptr; diff --git a/src/app/3d/qgsgoochmaterialwidget.cpp b/src/app/3d/qgsgoochmaterialwidget.cpp index 15cb3c97c737..3e62f8b27778 100644 --- a/src/app/3d/qgsgoochmaterialwidget.cpp +++ b/src/app/3d/qgsgoochmaterialwidget.cpp @@ -54,7 +54,7 @@ QgsMaterialSettingsWidget *QgsGoochMaterialWidget::create() void QgsGoochMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) { - const QgsGoochMaterialSettings *goochMaterial = dynamic_cast< const QgsGoochMaterialSettings * >( settings ); + const QgsGoochMaterialSettings *goochMaterial = dynamic_cast( settings ); if ( !goochMaterial ) return; btnDiffuse->setColor( goochMaterial->diffuse() ); @@ -67,10 +67,10 @@ void QgsGoochMaterialWidget::setSettings( const QgsAbstractMaterialSettings *set mPropertyCollection = settings->dataDefinedProperties(); - mDiffuseDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); - mWarmDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Warm ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); - mCoolDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Cool ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); - mSpecularDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mDiffuseDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mWarmDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Warm ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mCoolDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Cool ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mSpecularDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); } void QgsGoochMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique technique ) @@ -101,7 +101,7 @@ void QgsGoochMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique QgsAbstractMaterialSettings *QgsGoochMaterialWidget::settings() { - std::unique_ptr< QgsGoochMaterialSettings > m = std::make_unique< QgsGoochMaterialSettings >(); + std::unique_ptr m = std::make_unique(); m->setDiffuse( btnDiffuse->color() ); m->setWarm( btnWarm->color() ); m->setCool( btnCool->color() ); diff --git a/src/app/3d/qgsgoochmaterialwidget.h b/src/app/3d/qgsgoochmaterialwidget.h index 42d2c22b4aea..f3460e1b3ff8 100644 --- a/src/app/3d/qgsgoochmaterialwidget.h +++ b/src/app/3d/qgsgoochmaterialwidget.h @@ -34,7 +34,6 @@ class QgsGoochMaterialWidget : public QgsMaterialSettingsWidget, private Ui::Goo void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) override; void setTechnique( QgsMaterialSettingsRenderingTechnique technique ) override; QgsAbstractMaterialSettings *settings() override; - }; #endif // QGSGOOCHMATERIALWIDGET_H diff --git a/src/app/3d/qgslightswidget.cpp b/src/app/3d/qgslightswidget.cpp index c551f44b2199..05a315c64de2 100644 --- a/src/app/3d/qgslightswidget.cpp +++ b/src/app/3d/qgslightswidget.cpp @@ -72,7 +72,7 @@ QgsLightsWidget::QgsLightsWidget( QWidget *parent ) connect( spinDirectionalIntensity, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsLightsWidget::updateCurrentDirectionalLightParameters ); connect( btnDirectionalColor, &QgsColorButton::colorChanged, this, &QgsLightsWidget::updateCurrentDirectionalLightParameters ); - connect( dialAzimuth, &QSlider::valueChanged, this, [this]( int value ) {spinBoxAzimuth->setValue( ( value + 180 ) % 360 );} ); + connect( dialAzimuth, &QSlider::valueChanged, this, [this]( int value ) { spinBoxAzimuth->setValue( ( value + 180 ) % 360 ); } ); connect( sliderAltitude, &QSlider::valueChanged, spinBoxAltitude, &QgsDoubleSpinBox::setValue ); connect( spinBoxAzimuth, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsLightsWidget::onDirectionChange ); connect( spinBoxAltitude, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsLightsWidget::onDirectionChange ); @@ -83,17 +83,17 @@ QgsLightsWidget::QgsLightsWidget( QWidget *parent ) void QgsLightsWidget::setLights( const QList sources ) { - QList< QgsPointLightSettings > pointLights; - QList< QgsDirectionalLightSettings > directionalLights; + QList pointLights; + QList directionalLights; for ( const QgsLightSource *source : sources ) { switch ( source->type() ) { case Qgis::LightSourceType::Point: - pointLights.append( *qgis::down_cast< const QgsPointLightSettings *>( source ) ); + pointLights.append( *qgis::down_cast( source ) ); break; case Qgis::LightSourceType::Directional: - directionalLights.append( *qgis::down_cast< const QgsDirectionalLightSettings *>( source ) ); + directionalLights.append( *qgis::down_cast( source ) ); break; } } @@ -138,7 +138,7 @@ void QgsLightsWidget::selectedLightChanged( const QItemSelection &selected, cons return; } - const QgsLightsModel::LightType lightType = static_cast< QgsLightsModel::LightType >( mLightsModel->data( selected.indexes().at( 0 ), QgsLightsModel::LightTypeRole ).toInt() ); + const QgsLightsModel::LightType lightType = static_cast( mLightsModel->data( selected.indexes().at( 0 ), QgsLightsModel::LightTypeRole ).toInt() ); const int listIndex = mLightsModel->data( selected.indexes().at( 0 ), QgsLightsModel::LightListIndex ).toInt(); switch ( lightType ) @@ -302,14 +302,12 @@ void QgsLightsWidget::onDirectionChange() } - // // QgsLightsModel // QgsLightsModel::QgsLightsModel( QObject *parent ) : QAbstractListModel( parent ) { - } int QgsLightsModel::rowCount( const QModelIndex &parent ) const @@ -425,12 +423,12 @@ QList QgsLightsModel::directionalLights() const void QgsLightsModel::setPointLightSettings( int index, const QgsPointLightSettings &light ) { - mPointLights[ index ] = light; + mPointLights[index] = light; } void QgsLightsModel::setDirectionalLightSettings( int index, const QgsDirectionalLightSettings &light ) { - mDirectionalLights[ index ] = light; + mDirectionalLights[index] = light; } QModelIndex QgsLightsModel::addPointLight( const QgsPointLightSettings &light ) diff --git a/src/app/3d/qgslightswidget.h b/src/app/3d/qgslightswidget.h index c615ca2e8bb7..0d36224170d7 100644 --- a/src/app/3d/qgslightswidget.h +++ b/src/app/3d/qgslightswidget.h @@ -27,7 +27,6 @@ class QgsLightsModel : public QAbstractListModel { Q_OBJECT public: - enum LightType { Point, @@ -59,7 +58,6 @@ class QgsLightsModel : public QAbstractListModel QModelIndex addDirectionalLight( const QgsDirectionalLightSettings &light ); private: - QList mPointLights; QList mDirectionalLights; }; @@ -96,8 +94,8 @@ class QgsLightsWidget : public QWidget, private Ui::QgsLightsWidget void onAddDirectionalLight(); void setAzimuthAltitude(); void onDirectionChange(); - private: + private: void showSettingsForPointLight( const QgsPointLightSettings &settings ); void showSettingsForDirectionalLight( const QgsDirectionalLightSettings &settings ); diff --git a/src/app/3d/qgsline3dsymbolwidget.cpp b/src/app/3d/qgsline3dsymbolwidget.cpp index b709c6dcd71d..0accc707ac1c 100644 --- a/src/app/3d/qgsline3dsymbolwidget.cpp +++ b/src/app/3d/qgsline3dsymbolwidget.cpp @@ -28,9 +28,9 @@ QgsLine3DSymbolWidget::QgsLine3DSymbolWidget( QWidget *parent ) spinWidth->setClearValue( 0.0, tr( "Hairline" ) ); spinExtrusion->setClearValue( 0.0 ); - cboAltClamping->addItem( tr( "Absolute" ), static_cast< int >( Qgis::AltitudeClamping::Absolute ) ); - cboAltClamping->addItem( tr( "Relative" ), static_cast< int >( Qgis::AltitudeClamping::Relative ) ); - cboAltClamping->addItem( tr( "Terrain" ), static_cast< int >( Qgis::AltitudeClamping::Terrain ) ); + cboAltClamping->addItem( tr( "Absolute" ), static_cast( Qgis::AltitudeClamping::Absolute ) ); + cboAltClamping->addItem( tr( "Relative" ), static_cast( Qgis::AltitudeClamping::Relative ) ); + cboAltClamping->addItem( tr( "Terrain" ), static_cast( Qgis::AltitudeClamping::Terrain ) ); QgsLine3DSymbol defaultLine; setSymbol( &defaultLine, nullptr ); @@ -56,25 +56,24 @@ Qgs3DSymbolWidget *QgsLine3DSymbolWidget::create( QgsVectorLayer * ) void QgsLine3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer ) { - const QgsLine3DSymbol *lineSymbol = dynamic_cast< const QgsLine3DSymbol *>( symbol ); + const QgsLine3DSymbol *lineSymbol = dynamic_cast( symbol ); if ( !lineSymbol ) return; spinWidth->setValue( lineSymbol->width() ); spinOffset->setValue( lineSymbol->offset() ); spinExtrusion->setValue( lineSymbol->extrusionHeight() ); - cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast< int >( lineSymbol->altitudeClamping() ) ) ); + cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast( lineSymbol->altitudeClamping() ) ) ); cboAltBinding->setCurrentIndex( static_cast( lineSymbol->altitudeBinding() ) ); chkSimpleLines->setChecked( lineSymbol->renderAsSimpleLines() ); widgetMaterial->setSettings( lineSymbol->materialSettings(), layer ); - widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines - : QgsMaterialSettingsRenderingTechnique::Triangles ); + widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines : QgsMaterialSettingsRenderingTechnique::Triangles ); updateGuiState(); } QgsAbstract3DSymbol *QgsLine3DSymbolWidget::symbol() { - std::unique_ptr< QgsLine3DSymbol > sym = std::make_unique< QgsLine3DSymbol >(); + std::unique_ptr sym = std::make_unique(); sym->setWidth( spinWidth->value() ); sym->setOffset( static_cast( spinOffset->value() ) ); sym->setExtrusionHeight( spinExtrusion->value() ); @@ -94,12 +93,11 @@ void QgsLine3DSymbolWidget::updateGuiState() { const bool simple = chkSimpleLines->isChecked(); spinExtrusion->setEnabled( !simple ); - widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines - : QgsMaterialSettingsRenderingTechnique::Triangles ); + widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines : QgsMaterialSettingsRenderingTechnique::Triangles ); // Altitude binding is not taken into account if altitude clamping is absolute. // See: Qgs3DUtils::clampAltitudes() - const bool absoluteClamping = cboAltClamping->currentData().toInt() == static_cast< int >( Qgis::AltitudeClamping::Absolute ); + const bool absoluteClamping = cboAltClamping->currentData().toInt() == static_cast( Qgis::AltitudeClamping::Absolute ); cboAltBinding->setEnabled( !absoluteClamping ); } @@ -108,23 +106,23 @@ void QgsLine3DSymbolWidget::simple3DLinesToggled( bool active ) if ( active ) { //remove "terrain" option for altitude clamping - int terrainIndex = cboAltClamping->findData( static_cast< int >( Qgis::AltitudeClamping::Terrain ) ); + int terrainIndex = cboAltClamping->findData( static_cast( Qgis::AltitudeClamping::Terrain ) ); if ( terrainIndex >= 0 ) { cboAltClamping->removeItem( terrainIndex ); } if ( cboAltClamping->currentIndex() == -1 ) { - cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast< int >( Qgis::AltitudeClamping::Relative ) ) ); + cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast( Qgis::AltitudeClamping::Relative ) ) ); } } else { // make sure "terrain" option is available - int terrainIndex = cboAltClamping->findData( static_cast< int >( Qgis::AltitudeClamping::Terrain ) ); + int terrainIndex = cboAltClamping->findData( static_cast( Qgis::AltitudeClamping::Terrain ) ); if ( terrainIndex == -1 ) { - cboAltClamping->addItem( tr( "Terrain" ), static_cast< int >( Qgis::AltitudeClamping::Terrain ) ); + cboAltClamping->addItem( tr( "Terrain" ), static_cast( Qgis::AltitudeClamping::Terrain ) ); } } } diff --git a/src/app/3d/qgsline3dsymbolwidget.h b/src/app/3d/qgsline3dsymbolwidget.h index 08b5cf12294c..e9e1561cde16 100644 --- a/src/app/3d/qgsline3dsymbolwidget.h +++ b/src/app/3d/qgsline3dsymbolwidget.h @@ -40,7 +40,6 @@ class QgsLine3DSymbolWidget : public Qgs3DSymbolWidget, private Ui::Line3DSymbol private slots: void updateGuiState(); void simple3DLinesToggled( bool active ); - }; #endif // QGSLINE3DSYMBOLWIDGET_H diff --git a/src/app/3d/qgsmap3dexportwidget.cpp b/src/app/3d/qgsmap3dexportwidget.cpp index faaa3a6297c6..1a22983f3c0f 100644 --- a/src/app/3d/qgsmap3dexportwidget.cpp +++ b/src/app/3d/qgsmap3dexportwidget.cpp @@ -26,11 +26,8 @@ #include "qgssettings.h" #include "qgs3dmapexportsettings.h" -QgsMap3DExportWidget::QgsMap3DExportWidget( Qgs3DMapScene *scene, Qgs3DMapExportSettings *exportSettings, QWidget *parent ) : - QWidget( parent ), - ui( new Ui::Map3DExportWidget ), - mScene( scene ), - mExportSettings( exportSettings ) +QgsMap3DExportWidget::QgsMap3DExportWidget( Qgs3DMapScene *scene, Qgs3DMapExportSettings *exportSettings, QWidget *parent ) + : QWidget( parent ), ui( new Ui::Map3DExportWidget ), mScene( scene ), mExportSettings( exportSettings ) { ui->setupUi( this ); ui->terrainResolutionSpinBox->setClearValue( 128 ); @@ -41,14 +38,14 @@ QgsMap3DExportWidget::QgsMap3DExportWidget( Qgs3DMapScene *scene, Qgs3DMapExport loadSettings(); - connect( ui->sceneNameLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & ) { settingsChanged(); } ); - connect( ui->selectFolderWidget, &QgsFileWidget::fileChanged, this, [ = ]( const QString & ) { settingsChanged(); } ); - connect( ui->smoothEdgesCheckBox, &QCheckBox::stateChanged, this, [ = ]( int ) { settingsChanged(); } ); - connect( ui->terrainResolutionSpinBox, qOverload( &QSpinBox::valueChanged ), this, [ = ]( int ) { settingsChanged(); } ); - connect( ui->exportNormalsCheckBox, &QCheckBox::stateChanged, this, [ = ]( int ) { settingsChanged(); } ); - connect( ui->exportTexturesCheckBox, &QCheckBox::stateChanged, this, [ = ]( int ) { settingsChanged(); } ); - connect( ui->terrainTextureResolutionSpinBox, qOverload( &QSpinBox::valueChanged ), this, [ = ]( int ) { settingsChanged(); } ); - connect( ui->scaleSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [ = ]( int ) { settingsChanged(); } ); + connect( ui->sceneNameLineEdit, &QLineEdit::textChanged, this, [=]( const QString & ) { settingsChanged(); } ); + connect( ui->selectFolderWidget, &QgsFileWidget::fileChanged, this, [=]( const QString & ) { settingsChanged(); } ); + connect( ui->smoothEdgesCheckBox, &QCheckBox::stateChanged, this, [=]( int ) { settingsChanged(); } ); + connect( ui->terrainResolutionSpinBox, qOverload( &QSpinBox::valueChanged ), this, [=]( int ) { settingsChanged(); } ); + connect( ui->exportNormalsCheckBox, &QCheckBox::stateChanged, this, [=]( int ) { settingsChanged(); } ); + connect( ui->exportTexturesCheckBox, &QCheckBox::stateChanged, this, [=]( int ) { settingsChanged(); } ); + connect( ui->terrainTextureResolutionSpinBox, qOverload( &QSpinBox::valueChanged ), this, [=]( int ) { settingsChanged(); } ); + connect( ui->scaleSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( int ) { settingsChanged(); } ); // sets the export settings to whatever is on the scene settingsChanged(); diff --git a/src/app/3d/qgsmap3dexportwidget.h b/src/app/3d/qgsmap3dexportwidget.h index 303ff9f1794d..68c4707b9810 100644 --- a/src/app/3d/qgsmap3dexportwidget.h +++ b/src/app/3d/qgsmap3dexportwidget.h @@ -38,8 +38,10 @@ class QgsMap3DExportWidget : public QWidget void exportScene(); private slots: void settingsChanged(); + private: Ui::Map3DExportWidget *ui; + private: Qgs3DMapScene *mScene = nullptr; Qgs3DMapExportSettings *mExportSettings = nullptr; diff --git a/src/app/3d/qgsmaterialwidget.cpp b/src/app/3d/qgsmaterialwidget.cpp index 210a184cb6a5..76c2c9163eda 100644 --- a/src/app/3d/qgsmaterialwidget.cpp +++ b/src/app/3d/qgsmaterialwidget.cpp @@ -24,7 +24,7 @@ QgsMaterialWidget::QgsMaterialWidget( QWidget *parent ) : QWidget( parent ) - , mCurrentSettings( std::make_unique< QgsPhongMaterialSettings >() ) + , mCurrentSettings( std::make_unique() ) , mTechnique( QgsMaterialSettingsRenderingTechnique::Triangles ) { setupUi( this ); @@ -32,8 +32,7 @@ QgsMaterialWidget::QgsMaterialWidget( QWidget *parent ) const QStringList materialTypes = Qgs3D::materialRegistry()->materialSettingsTypes(); for ( const QString &type : materialTypes ) { - mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(), - Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type ); + mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(), Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type ); } connect( mMaterialTypeComboBox, static_cast( &QComboBox::currentIndexChanged ), this, &QgsMaterialWidget::materialTypeChanged ); @@ -52,8 +51,7 @@ void QgsMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique tech if ( !Qgs3D::materialRegistry()->materialSettingsMetadata( type )->supportsTechnique( technique ) ) continue; - mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(), - Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type ); + mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(), Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type ); } const int prevIndex = mMaterialTypeComboBox->findData( prevType ); @@ -69,7 +67,7 @@ void QgsMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique tech else mMaterialTypeComboBox->setCurrentIndex( prevIndex ); - if ( QgsMaterialSettingsWidget *w = qobject_cast< QgsMaterialSettingsWidget * >( mStackedWidget->currentWidget() ) ) + if ( QgsMaterialSettingsWidget *w = qobject_cast( mStackedWidget->currentWidget() ) ) w->setTechnique( technique ); mMaterialTypeComboBox->blockSignals( false ); @@ -97,7 +95,7 @@ void QgsMaterialWidget::setType( const QString &type ) void QgsMaterialWidget::materialTypeChanged() { - std::unique_ptr< QgsAbstractMaterialSettings > currentSettings( settings() ); + std::unique_ptr currentSettings( settings() ); const QString existingType = currentSettings ? currentSettings->type() : QString(); const QString newType = mMaterialTypeComboBox->currentData().toString(); if ( existingType == newType ) @@ -107,7 +105,7 @@ void QgsMaterialWidget::materialTypeChanged() { // change material to a new (with different type) // base new layer on existing materials's properties - std::unique_ptr< QgsAbstractMaterialSettings > newMaterial( am->create() ); + std::unique_ptr newMaterial( am->create() ); if ( newMaterial ) { if ( currentSettings ) @@ -127,7 +125,7 @@ void QgsMaterialWidget::materialTypeChanged() void QgsMaterialWidget::materialWidgetChanged() { - if ( QgsMaterialSettingsWidget *w = qobject_cast< QgsMaterialSettingsWidget * >( mStackedWidget->currentWidget() ) ) + if ( QgsMaterialSettingsWidget *w = qobject_cast( mStackedWidget->currentWidget() ) ) { mCurrentSettings.reset( w->settings() ); } @@ -139,7 +137,7 @@ void QgsMaterialWidget::updateMaterialWidget() if ( mStackedWidget->currentWidget() != mPageDummy ) { // stop updating from the original widget - if ( QgsMaterialSettingsWidget *w = qobject_cast< QgsMaterialSettingsWidget * >( mStackedWidget->currentWidget() ) ) + if ( QgsMaterialSettingsWidget *w = qobject_cast( mStackedWidget->currentWidget() ) ) disconnect( w, &QgsMaterialSettingsWidget::changed, this, &QgsMaterialWidget::materialWidgetChanged ); mStackedWidget->removeWidget( mStackedWidget->currentWidget() ); } @@ -161,4 +159,3 @@ void QgsMaterialWidget::updateMaterialWidget() // When anything is not right mStackedWidget->setCurrentWidget( mPageDummy ); } - diff --git a/src/app/3d/qgsmaterialwidget.h b/src/app/3d/qgsmaterialwidget.h index 02b13352c47f..179ccbeec9e9 100644 --- a/src/app/3d/qgsmaterialwidget.h +++ b/src/app/3d/qgsmaterialwidget.h @@ -55,9 +55,8 @@ class QgsMaterialWidget : public QWidget, private Ui::MaterialWidgetBase void updateMaterialWidget(); QgsVectorLayer *mLayer = nullptr; - std::unique_ptr< QgsAbstractMaterialSettings > mCurrentSettings; + std::unique_ptr mCurrentSettings; QgsMaterialSettingsRenderingTechnique mTechnique; - }; #endif // QGSMATERIALWIDGET_H diff --git a/src/app/3d/qgsmesh3dsymbolwidget.cpp b/src/app/3d/qgsmesh3dsymbolwidget.cpp index 5949171501c9..3f28a7288277 100644 --- a/src/app/3d/qgsmesh3dsymbolwidget.cpp +++ b/src/app/3d/qgsmesh3dsymbolwidget.cpp @@ -30,7 +30,7 @@ QgsMesh3DSymbolWidget::QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget * mSpinBoxVerticaleScale->setClearValue( 1.0 ); mArrowsSpacingSpinBox->setClearValue( 25.0 ); - mComboBoxTextureType->addItem( tr( "Single Color" ), static_cast< int >( QgsMesh3DSymbol::RenderingStyle::SingleColor ) ); + mComboBoxTextureType->addItem( tr( "Single Color" ), static_cast( QgsMesh3DSymbol::RenderingStyle::SingleColor ) ); mComboBoxTextureType->setCurrentIndex( 0 ); mCullingMode->addItem( tr( "No Culling" ), Qgs3DTypes::NoCulling ); @@ -50,8 +50,7 @@ QgsMesh3DSymbolWidget::QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget * connect( mChkSmoothTriangles, &QCheckBox::clicked, this, &QgsMesh3DSymbolWidget::changed ); connect( mGroupBoxWireframe, &QGroupBox::toggled, this, &QgsMesh3DSymbolWidget::changed ); connect( mColorButtonWireframe, &QgsColorButton::colorChanged, this, &QgsMesh3DSymbolWidget::changed ); - connect( mSpinBoxWireframeLineWidth, static_cast( &QDoubleSpinBox::valueChanged ), - this, &QgsMesh3DSymbolWidget::changed ); + connect( mSpinBoxWireframeLineWidth, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsMesh3DSymbolWidget::changed ); connect( mLodSlider, &QSlider::valueChanged, this, &QgsMesh3DSymbolWidget::changed ); connect( mColorRampShaderMinMaxReloadButton, &QPushButton::clicked, this, &QgsMesh3DSymbolWidget::reloadColorRampShaderMinMax ); @@ -60,29 +59,24 @@ QgsMesh3DSymbolWidget::QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget * connect( mColorRampShaderMinEdit, &QLineEdit::editingFinished, this, &QgsMesh3DSymbolWidget::onColorRampShaderMinMaxChanged ); connect( mColorRampShaderMaxEdit, &QLineEdit::editingFinished, this, &QgsMesh3DSymbolWidget::onColorRampShaderMinMaxChanged ); - connect( mComboBoxTextureType, static_cast( &QComboBox::currentIndexChanged ), - this, &QgsMesh3DSymbolWidget::onColoringTypeChanged ); - connect( mComboBoxTextureType, static_cast( &QComboBox::currentIndexChanged ), - this, &QgsMesh3DSymbolWidget::changed ); + connect( mComboBoxTextureType, static_cast( &QComboBox::currentIndexChanged ), this, &QgsMesh3DSymbolWidget::onColoringTypeChanged ); + connect( mComboBoxTextureType, static_cast( &QComboBox::currentIndexChanged ), this, &QgsMesh3DSymbolWidget::changed ); connect( mMeshSingleColorButton, &QgsColorButton::colorChanged, this, &QgsMesh3DSymbolWidget::changed ); - connect( mSpinBoxVerticaleScale, static_cast( &QDoubleSpinBox::valueChanged ), - this, &QgsMesh3DSymbolWidget::changed ); + connect( mSpinBoxVerticaleScale, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsMesh3DSymbolWidget::changed ); - connect( mComboBoxDatasetVertical, static_cast( &QComboBox::currentIndexChanged ), - this, &QgsMesh3DSymbolWidget::changed ); + connect( mComboBoxDatasetVertical, static_cast( &QComboBox::currentIndexChanged ), this, &QgsMesh3DSymbolWidget::changed ); connect( mCheckBoxVerticalMagnitudeRelative, &QCheckBox::clicked, this, &QgsMesh3DSymbolWidget::changed ); connect( mGroupBoxArrowsSettings, &QGroupBox::toggled, this, &QgsMesh3DSymbolWidget::changed ); - connect( mArrowsSpacingSpinBox, static_cast( &QDoubleSpinBox::editingFinished ), - this, &QgsMesh3DSymbolWidget::changed ); + connect( mArrowsSpacingSpinBox, static_cast( &QDoubleSpinBox::editingFinished ), this, &QgsMesh3DSymbolWidget::changed ); connect( mArrowsFixedSizeCheckBox, &QCheckBox::clicked, this, &QgsMesh3DSymbolWidget::changed ); - connect( mGroupBoxTextureSettings, &QgsCollapsibleGroupBox::collapsedStateChanged, this, &QgsMesh3DSymbolWidget::onTextureSettingsCollapseStateChanged ); + connect( mGroupBoxTextureSettings, &QgsCollapsibleGroupBox::collapsedStateChanged, this, &QgsMesh3DSymbolWidget::onTextureSettingsCollapseStateChanged ); } void QgsMesh3DSymbolWidget::setSymbol( const QgsMesh3DSymbol *symbol ) @@ -100,11 +94,10 @@ void QgsMesh3DSymbolWidget::setSymbol( const QgsMesh3DSymbol *symbol ) mSpinBoxVerticaleScale->setValue( symbol->verticalScale() ); - mComboBoxTextureType->setCurrentIndex( mComboBoxTextureType->findData( static_cast< int >( symbol->renderingStyle() ) ) ); + mComboBoxTextureType->setCurrentIndex( mComboBoxTextureType->findData( static_cast( symbol->renderingStyle() ) ) ); mMeshSingleColorButton->setColor( symbol->singleMeshColor() ); mColorRampShaderWidget->setFromShader( symbol->colorRampShader() ); - mColorRampShaderWidget->setMinimumMaximumAndClassify( symbol->colorRampShader().minimumValue(), - symbol->colorRampShader().maximumValue() ); + mColorRampShaderWidget->setMinimumMaximumAndClassify( symbol->colorRampShader().minimumValue(), symbol->colorRampShader().maximumValue() ); setColorRampMinMax( symbol->colorRampShader().minimumValue(), symbol->colorRampShader().maximumValue() ); mComboBoxDatasetVertical->setCurrentIndex( symbol->verticalDatasetGroupIndex() ); @@ -117,7 +110,7 @@ void QgsMesh3DSymbolWidget::setSymbol( const QgsMesh3DSymbol *symbol ) void QgsMesh3DSymbolWidget::configureForTerrain() { - mComboBoxTextureType->addItem( tr( "Color Ramp Shader" ), static_cast< int >( QgsMesh3DSymbol::RenderingStyle::ColorRamp ) ); + mComboBoxTextureType->addItem( tr( "Color Ramp Shader" ), static_cast( QgsMesh3DSymbol::RenderingStyle::ColorRamp ) ); enableVerticalSetting( false ); enableArrowSettings( false ); @@ -126,7 +119,7 @@ void QgsMesh3DSymbolWidget::configureForTerrain() void QgsMesh3DSymbolWidget::configureForDataset() { - mComboBoxTextureType->addItem( tr( "2D Contour Color Ramp Shader" ), static_cast< int >( QgsMesh3DSymbol::RenderingStyle::ColorRamp2DRendering ) ); + mComboBoxTextureType->addItem( tr( "2D Contour Color Ramp Shader" ), static_cast( QgsMesh3DSymbol::RenderingStyle::ColorRamp2DRendering ) ); mGroupBoxColorRampShader->hide(); enableVerticalSetting( true ); enableArrowSettings( true ); @@ -158,9 +151,9 @@ void QgsMesh3DSymbolWidget::setLayer( QgsMeshLayer *meshLayer, bool updateSymbol { mDatasetGroupListModel->syncToLayer( meshLayer ); QgsMeshLayer3DRenderer *renderer = static_cast( meshLayer->renderer3D() ); - if ( renderer && renderer->type() == QLatin1String( "mesh" ) ) + if ( renderer && renderer->type() == QLatin1String( "mesh" ) ) { - if ( renderer->symbol() && renderer->symbol()->type() == QLatin1String( "mesh" ) ) + if ( renderer->symbol() && renderer->symbol()->type() == QLatin1String( "mesh" ) ) { setSymbol( static_cast( renderer->symbol() ) ); return; @@ -168,14 +161,14 @@ void QgsMesh3DSymbolWidget::setLayer( QgsMeshLayer *meshLayer, bool updateSymbol } } - const std::unique_ptr< QgsMesh3DSymbol > defaultSymbol = std::make_unique< QgsMesh3DSymbol >(); + const std::unique_ptr defaultSymbol = std::make_unique(); // set symbol does not take ownership! setSymbol( defaultSymbol.get() ); reloadColorRampShaderMinMax(); //As the symbol is new, the Color ramp shader needs to be initialized with min max value } -QgsMeshLayer *QgsMesh3DSymbolWidget::meshLayer() const {return mLayer;} +QgsMeshLayer *QgsMesh3DSymbolWidget::meshLayer() const { return mLayer; } double QgsMesh3DSymbolWidget::lineEditValue( const QLineEdit *lineEdit ) const { @@ -189,7 +182,7 @@ double QgsMesh3DSymbolWidget::lineEditValue( const QLineEdit *lineEdit ) const std::unique_ptr QgsMesh3DSymbolWidget::symbol() const { - std::unique_ptr< QgsMesh3DSymbol > sym( mSymbol->clone() ); + std::unique_ptr sym( mSymbol->clone() ); sym->setCullingMode( static_cast( mCullingMode->currentData().toInt() ) ); sym->setSmoothedTriangles( mChkSmoothTriangles->isChecked() ); @@ -252,8 +245,8 @@ void QgsMesh3DSymbolWidget::onColorRampShaderMinMaxChanged() void QgsMesh3DSymbolWidget::onColoringTypeChanged() { - mGroupBoxColorRampShader->setVisible( static_cast< QgsMesh3DSymbol::RenderingStyle >( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::ColorRamp ); - mMeshSingleColorWidget->setVisible( static_cast< QgsMesh3DSymbol::RenderingStyle >( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::SingleColor ); + mGroupBoxColorRampShader->setVisible( static_cast( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::ColorRamp ); + mMeshSingleColorWidget->setVisible( static_cast( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::SingleColor ); } void QgsMesh3DSymbolWidget::onTextureSettingsCollapseStateChanged( bool collapsed ) diff --git a/src/app/3d/qgsmesh3dsymbolwidget.h b/src/app/3d/qgsmesh3dsymbolwidget.h index 72233ae9ed5b..6ee2e8c4204c 100644 --- a/src/app/3d/qgsmesh3dsymbolwidget.h +++ b/src/app/3d/qgsmesh3dsymbolwidget.h @@ -32,7 +32,7 @@ class QgsMesh3DSymbolWidget : public QWidget, private Ui::QgsMesh3dPropsWidget public: explicit QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget *parent = nullptr ); - std::unique_ptr< QgsMesh3DSymbol > symbol() const; + std::unique_ptr symbol() const; void setLayer( QgsMeshLayer *meshLayer, bool updateSymbol = true ); QgsMeshLayer *meshLayer() const; @@ -60,8 +60,7 @@ class QgsMesh3DSymbolWidget : public QWidget, private Ui::QgsMesh3dPropsWidget void setColorRampMinMax( double min, double max ); QgsMeshLayer *mLayer = nullptr; QgsMeshDatasetGroupListModel *mDatasetGroupListModel = nullptr; - std::unique_ptr< QgsMesh3DSymbol > mSymbol; - + std::unique_ptr mSymbol; }; #endif // QGSMESH3DSYMBOLWIDGET_H diff --git a/src/app/3d/qgsmeshlayer3drendererwidget.cpp b/src/app/3d/qgsmeshlayer3drendererwidget.cpp index ebe47f68554f..33d93bb378b5 100644 --- a/src/app/3d/qgsmeshlayer3drendererwidget.cpp +++ b/src/app/3d/qgsmeshlayer3drendererwidget.cpp @@ -66,7 +66,7 @@ void QgsMeshLayer3DRendererWidget::setRenderer( const QgsMeshLayer3DRenderer *re QgsMeshLayer3DRenderer *QgsMeshLayer3DRendererWidget::renderer() { - std::unique_ptr< QgsMesh3DSymbol > sym = mWidgetMesh->symbol(); + std::unique_ptr sym = mWidgetMesh->symbol(); sym->setEnabled( mChkEnabled->isChecked() ); mRenderer.reset( new QgsMeshLayer3DRenderer( sym.release() ) ); mRenderer->setLayer( qobject_cast( mLayer ) ); @@ -87,7 +87,7 @@ void QgsMeshLayer3DRendererWidget::onEnabledClicked() void QgsMeshLayer3DRendererWidget::syncToLayer( QgsMapLayer *layer ) { - mLayer = layer ; + mLayer = layer; QgsMeshLayer *meshLayer = qobject_cast( layer ); mWidgetMesh->setLayer( meshLayer ); QgsAbstract3DRenderer *r = layer->renderer3D(); @@ -104,8 +104,8 @@ void QgsMeshLayer3DRendererWidget::syncToLayer( QgsMapLayer *layer ) } } -QgsMeshLayer3DRendererWidgetFactory::QgsMeshLayer3DRendererWidgetFactory( QObject *parent ): - QObject( parent ) +QgsMeshLayer3DRendererWidgetFactory::QgsMeshLayer3DRendererWidgetFactory( QObject *parent ) + : QObject( parent ) { setIcon( QIcon( ":/images/themes/default/3d.svg" ) ); setTitle( tr( "3D View" ) ); diff --git a/src/app/3d/qgsmetalroughmaterialwidget.cpp b/src/app/3d/qgsmetalroughmaterialwidget.cpp index 1aae323e71a2..2c3ffc08e20c 100644 --- a/src/app/3d/qgsmetalroughmaterialwidget.cpp +++ b/src/app/3d/qgsmetalroughmaterialwidget.cpp @@ -30,13 +30,11 @@ QgsMetalRoughMaterialWidget::QgsMetalRoughMaterialWidget( QWidget *parent, bool setSettings( &defaultMaterial, nullptr ); connect( mButtonBaseColor, &QgsColorButton::colorChanged, this, &QgsMetalRoughMaterialWidget::changed ); - connect( mSpinMetalness, static_cast( &QDoubleSpinBox::valueChanged ), this, [ = ] - { + connect( mSpinMetalness, static_cast( &QDoubleSpinBox::valueChanged ), this, [=] { updateWidgetState(); emit changed(); } ); - connect( mSpinRoughness, static_cast( &QDoubleSpinBox::valueChanged ), this, [ = ] - { + connect( mSpinRoughness, static_cast( &QDoubleSpinBox::valueChanged ), this, [=] { updateWidgetState(); emit changed(); } ); @@ -49,12 +47,11 @@ QgsMaterialSettingsWidget *QgsMetalRoughMaterialWidget::create() void QgsMetalRoughMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique ) { - } void QgsMetalRoughMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer * ) { - const QgsMetalRoughMaterialSettings *material = dynamic_cast< const QgsMetalRoughMaterialSettings * >( settings ); + const QgsMetalRoughMaterialSettings *material = dynamic_cast( settings ); if ( !material ) return; mButtonBaseColor->setColor( material->baseColor() ); @@ -68,7 +65,7 @@ void QgsMetalRoughMaterialWidget::setSettings( const QgsAbstractMaterialSettings QgsAbstractMaterialSettings *QgsMetalRoughMaterialWidget::settings() { - std::unique_ptr< QgsMetalRoughMaterialSettings > m = std::make_unique< QgsMetalRoughMaterialSettings >(); + std::unique_ptr m = std::make_unique(); m->setBaseColor( mButtonBaseColor->color() ); m->setMetalness( static_cast( mSpinMetalness->value() ) ); m->setRoughness( static_cast( mSpinRoughness->value() ) ); diff --git a/src/app/3d/qgsnullmaterialwidget.h b/src/app/3d/qgsnullmaterialwidget.h index 66bd9973e2c8..fdc109b26fb5 100644 --- a/src/app/3d/qgsnullmaterialwidget.h +++ b/src/app/3d/qgsnullmaterialwidget.h @@ -33,7 +33,6 @@ class QgsNullMaterialWidget : public QgsMaterialSettingsWidget, private Ui::Null static QgsMaterialSettingsWidget *create(); void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) override; QgsAbstractMaterialSettings *settings() override; - }; #endif // QGSNULLMATERIALWIDGET_H diff --git a/src/app/3d/qgsphongmaterialwidget.cpp b/src/app/3d/qgsphongmaterialwidget.cpp index 0eb19db97828..25522edd5156 100644 --- a/src/app/3d/qgsphongmaterialwidget.cpp +++ b/src/app/3d/qgsphongmaterialwidget.cpp @@ -34,8 +34,7 @@ QgsPhongMaterialWidget::QgsPhongMaterialWidget( QWidget *parent, bool hasOpacity connect( btnDiffuse, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed ); connect( btnAmbient, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed ); connect( btnSpecular, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed ); - connect( spinShininess, static_cast( &QDoubleSpinBox::valueChanged ), this, [ = ] - { + connect( spinShininess, static_cast( &QDoubleSpinBox::valueChanged ), this, [=] { updateWidgetState(); emit changed(); } ); @@ -110,7 +109,7 @@ void QgsPhongMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique void QgsPhongMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) { - const QgsPhongMaterialSettings *phongMaterial = dynamic_cast< const QgsPhongMaterialSettings * >( settings ); + const QgsPhongMaterialSettings *phongMaterial = dynamic_cast( settings ); if ( !phongMaterial ) return; btnDiffuse->setColor( phongMaterial->diffuse() ); @@ -127,16 +126,16 @@ void QgsPhongMaterialWidget::setSettings( const QgsAbstractMaterialSettings *set mPropertyCollection = settings->dataDefinedProperties(); - mDiffuseDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); - mAmbientDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); - mSpecularDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mDiffuseDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mAmbientDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mSpecularDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); updateWidgetState(); } QgsAbstractMaterialSettings *QgsPhongMaterialWidget::settings() { - std::unique_ptr< QgsPhongMaterialSettings > m = std::make_unique< QgsPhongMaterialSettings >(); + std::unique_ptr m = std::make_unique(); m->setDiffuse( btnDiffuse->color() ); m->setAmbient( btnAmbient->color() ); m->setSpecular( btnSpecular->color() ); diff --git a/src/app/3d/qgsphongtexturedmaterialwidget.cpp b/src/app/3d/qgsphongtexturedmaterialwidget.cpp index c01482cf5fb3..a555210a7c2d 100644 --- a/src/app/3d/qgsphongtexturedmaterialwidget.cpp +++ b/src/app/3d/qgsphongtexturedmaterialwidget.cpp @@ -33,8 +33,7 @@ QgsPhongTexturedMaterialWidget::QgsPhongTexturedMaterialWidget( QWidget *parent connect( btnAmbient, &QgsColorButton::colorChanged, this, &QgsPhongTexturedMaterialWidget::changed ); connect( btnSpecular, &QgsColorButton::colorChanged, this, &QgsPhongTexturedMaterialWidget::changed ); - connect( spinShininess, static_cast( &QDoubleSpinBox::valueChanged ), this, [ = ] - { + connect( spinShininess, static_cast( &QDoubleSpinBox::valueChanged ), this, [=] { updateWidgetState(); emit changed(); } ); @@ -51,7 +50,7 @@ QgsMaterialSettingsWidget *QgsPhongTexturedMaterialWidget::create() void QgsPhongTexturedMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer * ) { - const QgsPhongTexturedMaterialSettings *phongMaterial = dynamic_cast< const QgsPhongTexturedMaterialSettings * >( settings ); + const QgsPhongTexturedMaterialSettings *phongMaterial = dynamic_cast( settings ); if ( !phongMaterial ) return; btnAmbient->setColor( phongMaterial->ambient() ); @@ -69,7 +68,7 @@ void QgsPhongTexturedMaterialWidget::setSettings( const QgsAbstractMaterialSetti QgsAbstractMaterialSettings *QgsPhongTexturedMaterialWidget::settings() { - std::unique_ptr< QgsPhongTexturedMaterialSettings > m = std::make_unique< QgsPhongTexturedMaterialSettings >(); + std::unique_ptr m = std::make_unique(); m->setAmbient( btnAmbient->color() ); m->setSpecular( btnSpecular->color() ); m->setShininess( spinShininess->value() ); diff --git a/src/app/3d/qgspoint3dsymbolwidget.cpp b/src/app/3d/qgspoint3dsymbolwidget.cpp index 0d50efde81d0..d2616c68e3dd 100644 --- a/src/app/3d/qgspoint3dsymbolwidget.cpp +++ b/src/app/3d/qgspoint3dsymbolwidget.cpp @@ -74,11 +74,11 @@ QgsPoint3DSymbolWidget::QgsPoint3DSymbolWidget( QWidget *parent ) connect( spinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsPoint3DSymbolWidget::changed ); connect( lineEditModel, &QgsAbstractFileContentSourceLineEdit::sourceChanged, this, &QgsPoint3DSymbolWidget::changed ); connect( widgetMaterial, &QgsMaterialWidget::changed, this, &QgsPoint3DSymbolWidget::changed ); - connect( btnChangeSymbol, static_cast( &QgsSymbolButton::changed ), this, &QgsPoint3DSymbolWidget::changed ); + connect( btnChangeSymbol, static_cast( &QgsSymbolButton::changed ), this, &QgsPoint3DSymbolWidget::changed ); // Sync between billboard height and TZ - connect( spinBillboardHeight, static_cast( &QDoubleSpinBox::valueChanged ), spinTZ, &QDoubleSpinBox::setValue ); - connect( spinTZ, static_cast( &QDoubleSpinBox::valueChanged ), spinBillboardHeight, &QDoubleSpinBox::setValue ); + connect( spinBillboardHeight, static_cast( &QDoubleSpinBox::valueChanged ), spinTZ, &QDoubleSpinBox::setValue ); + connect( spinTZ, static_cast( &QDoubleSpinBox::valueChanged ), spinBillboardHeight, &QDoubleSpinBox::setValue ); } Qgs3DSymbolWidget *QgsPoint3DSymbolWidget::create( QgsVectorLayer * ) @@ -88,7 +88,7 @@ Qgs3DSymbolWidget *QgsPoint3DSymbolWidget::create( QgsVectorLayer * ) void QgsPoint3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer ) { - const QgsPoint3DSymbol *pointSymbol = dynamic_cast< const QgsPoint3DSymbol *>( symbol ); + const QgsPoint3DSymbol *pointSymbol = dynamic_cast( symbol ); if ( !pointSymbol ) return; @@ -171,9 +171,9 @@ void QgsPoint3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVe QgsAbstract3DSymbol *QgsPoint3DSymbolWidget::symbol() { QVariantMap vm; - std::unique_ptr< QgsPoint3DSymbol > sym = std::make_unique< QgsPoint3DSymbol >(); + std::unique_ptr sym = std::make_unique(); sym->setBillboardSymbol( static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) ); - switch ( cboShape->currentData().value< Qgis::Point3DShape >() ) + switch ( cboShape->currentData().value() ) { case Qgis::Point3DShape::Sphere: vm[QStringLiteral( "radius" )] = spinRadius->value(); @@ -217,7 +217,7 @@ QgsAbstract3DSymbol *QgsPoint3DSymbolWidget::symbol() tr.rotate( rot ); sym->setAltitudeClamping( static_cast( cboAltClamping->currentIndex() ) ); - sym->setShape( cboShape->itemData( cboShape->currentIndex() ).value< Qgis::Point3DShape >() ); + sym->setShape( cboShape->itemData( cboShape->currentIndex() ).value() ); sym->setShapeProperties( vm ); sym->setMaterialSettings( widgetMaterial->settings() ); sym->setTransform( tr ); @@ -245,7 +245,7 @@ void QgsPoint3DSymbolWidget::onShapeChanged() transformationWidget->show(); QList activeWidgets; QgsMaterialSettingsRenderingTechnique technique = QgsMaterialSettingsRenderingTechnique::InstancedPoints; - switch ( cboShape->currentData().value< Qgis::Point3DShape >() ) + switch ( cboShape->currentData().value() ) { case Qgis::Point3DShape::Sphere: activeWidgets << labelRadius << spinRadius; diff --git a/src/app/3d/qgspointcloud3dsymbolwidget.cpp b/src/app/3d/qgspointcloud3dsymbolwidget.cpp index 9e98be292e39..d401b5431186 100644 --- a/src/app/3d/qgspointcloud3dsymbolwidget.cpp +++ b/src/app/3d/qgspointcloud3dsymbolwidget.cpp @@ -93,7 +93,7 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la mRenderingStyleComboBox->setCurrentIndex( 0 ); mStackedWidget->setCurrentIndex( 0 ); - whileBlocking( mPointBudgetSpinBox )->setMinimum( std::min( mLayer->pointCount() / 2, ( qint64 )100000 ) ); + whileBlocking( mPointBudgetSpinBox )->setMinimum( std::min( mLayer->pointCount() / 2, ( qint64 ) 100000 ) ); whileBlocking( mPointBudgetSpinBox )->setMaximum( mLayer->pointCount() + 1 ); whileBlocking( mPointBudgetSpinBox )->setValue( 1000000 ); @@ -101,7 +101,7 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la setSymbol( symbol ); connect( mPointSizeSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::emitChangedSignal ); - connect( mRenderingStyleComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsPointCloud3DSymbolWidget::onRenderingStyleChanged ); + connect( mRenderingStyleComboBox, qOverload( &QComboBox::currentIndexChanged ), this, &QgsPointCloud3DSymbolWidget::onRenderingStyleChanged ); connect( mScalarRecalculateMinMaxButton, &QPushButton::clicked, this, &QgsPointCloud3DSymbolWidget::setMinMaxFromLayer ); connect( mColorRampShaderWidget, &QgsColorRampShaderWidget::widgetChanged, this, &QgsPointCloud3DSymbolWidget::emitChangedSignal ); connect( mSingleColorBtn, &QgsColorButton::colorChanged, this, &QgsPointCloud3DSymbolWidget::emitChangedSignal ); @@ -114,16 +114,14 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la connect( mPointBudgetSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [&]() { emitChangedSignal(); } ); connect( mTriangulateGroupBox, &QGroupBox::toggled, this, [&]() { emitChangedSignal(); } ); - connect( mTriangulateGroupBox, &QGroupBox::toggled, this, [&]() {mPointSizeSpinBox->setEnabled( !mTriangulateGroupBox->isChecked() ); } ); + connect( mTriangulateGroupBox, &QGroupBox::toggled, this, [&]() { mPointSizeSpinBox->setEnabled( !mTriangulateGroupBox->isChecked() ); } ); connect( mHorizontalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { emitChangedSignal(); } ); - connect( mHorizontalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() - { mHorizontalTriangleThresholdSpinBox->setEnabled( mHorizontalTriangleCheckBox->isChecked() ); } ); + connect( mHorizontalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { mHorizontalTriangleThresholdSpinBox->setEnabled( mHorizontalTriangleCheckBox->isChecked() ); } ); connect( mHorizontalTriangleThresholdSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [&]() { emitChangedSignal(); } ); connect( mVerticalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { emitChangedSignal(); } ); - connect( mVerticalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() - { mVerticalTriangleThresholdSpinBox->setEnabled( mVerticalTriangleCheckBox->isChecked() ); } ); + connect( mVerticalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { mVerticalTriangleThresholdSpinBox->setEnabled( mVerticalTriangleCheckBox->isChecked() ); } ); connect( mVerticalTriangleThresholdSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, [&]() { emitChangedSignal(); } ); mPointSizeSpinBox->setEnabled( !mTriangulateGroupBox->isChecked() ); @@ -310,8 +308,7 @@ void QgsPointCloud3DSymbolWidget::setCustomMinMaxValues( QgsRgbPointCloud3DSymbo return; } - if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() == - QgsContrastEnhancement::NoEnhancement ) + if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() == QgsContrastEnhancement::NoEnhancement ) { symbol->setRedContrastEnhancement( nullptr ); symbol->setGreenContrastEnhancement( nullptr ); @@ -355,18 +352,21 @@ void QgsPointCloud3DSymbolWidget::setCustomMinMaxValues( QgsRgbPointCloud3DSymbo if ( redEnhancement ) { - redEnhancement->setContrastEnhancementAlgorithm( static_cast< QgsContrastEnhancement::ContrastEnhancementAlgorithm >( - ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) ); + redEnhancement->setContrastEnhancementAlgorithm( static_cast( + ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) + ) ); } if ( greenEnhancement ) { - greenEnhancement->setContrastEnhancementAlgorithm( static_cast< QgsContrastEnhancement::ContrastEnhancementAlgorithm >( - ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) ); + greenEnhancement->setContrastEnhancementAlgorithm( static_cast( + ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) + ) ); } if ( blueEnhancement ) { - blueEnhancement->setContrastEnhancementAlgorithm( static_cast< QgsContrastEnhancement::ContrastEnhancementAlgorithm >( - ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) ); + blueEnhancement->setContrastEnhancementAlgorithm( static_cast( + ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) + ) ); } symbol->setRedContrastEnhancement( redEnhancement ); symbol->setGreenContrastEnhancement( greenEnhancement ); @@ -380,7 +380,8 @@ void QgsPointCloud3DSymbolWidget::minMaxModified() if ( ( QgsContrastEnhancement::ContrastEnhancementAlgorithm )( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) == QgsContrastEnhancement::NoEnhancement ) { mContrastEnhancementAlgorithmComboBox->setCurrentIndex( - mContrastEnhancementAlgorithmComboBox->findData( ( int ) QgsContrastEnhancement::StretchToMinimumMaximum ) ); + mContrastEnhancementAlgorithmComboBox->findData( ( int ) QgsContrastEnhancement::StretchToMinimumMaximum ) + ); } emitChangedSignal(); } @@ -406,7 +407,8 @@ void QgsPointCloud3DSymbolWidget::setMinMaxValue( const QgsContrastEnhancement * // QgsMultiBandColorRenderer is using individual contrast enhancements for each // band, but this widget GUI has one for all mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData( - static_cast< int >( ce->contrastEnhancementAlgorithm() ) ) ); + static_cast( ce->contrastEnhancementAlgorithm() ) + ) ); } void QgsPointCloud3DSymbolWidget::reloadColorRampShaderMinMax() @@ -436,7 +438,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged() } else if ( newSymbolType == QLatin1String( "color-ramp" ) && mLayer->renderer()->type() == QLatin1String( "ramp" ) ) { - const QgsPointCloudAttributeByRampRenderer *renderer2d = dynamic_cast< const QgsPointCloudAttributeByRampRenderer * >( mLayer->renderer() ); + const QgsPointCloudAttributeByRampRenderer *renderer2d = dynamic_cast( mLayer->renderer() ); mBlockChangedSignals++; mRenderingParameterComboBox->setAttribute( renderer2d->attribute() ); mColorRampShaderMinEdit->setValue( renderer2d->minimum() ); @@ -447,7 +449,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged() } else if ( newSymbolType == QLatin1String( "rgb" ) ) { - const QgsPointCloudRgbRenderer *renderer2d = dynamic_cast< const QgsPointCloudRgbRenderer * >( mLayer->renderer() ); + const QgsPointCloudRgbRenderer *renderer2d = dynamic_cast( mLayer->renderer() ); mBlockChangedSignals++; if ( renderer2d ) { @@ -463,8 +465,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged() } else { - if ( mRedAttributeComboBox->findText( QStringLiteral( "Red" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral( "Green" ) ) > -1 && - mRedAttributeComboBox->findText( QStringLiteral( "Blue" ) ) > -1 ) + if ( mRedAttributeComboBox->findText( QStringLiteral( "Red" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral( "Green" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral( "Blue" ) ) > -1 ) { mRedAttributeComboBox->setAttribute( QStringLiteral( "Red" ) ); mGreenAttributeComboBox->setAttribute( QStringLiteral( "Green" ) ); @@ -481,7 +482,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged() blueAttributeChanged(); } - ( void )( renderer2d ); + ( void ) ( renderer2d ); mBlockChangedSignals--; } else if ( newSymbolType == QLatin1String( "classification" ) ) @@ -511,8 +512,8 @@ void QgsPointCloud3DSymbolWidget::rampAttributeChanged() if ( mRenderingParameterComboBox->currentAttribute() == QLatin1String( "Z" ) ) { - const double zScale = static_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() )->zScale(); - const double zOffset = static_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() )->zOffset(); + const double zScale = static_cast( mLayer->elevationProperties() )->zScale(); + const double zOffset = static_cast( mLayer->elevationProperties() )->zOffset(); mProviderMin = mProviderMin * zScale + zOffset; mProviderMax = mProviderMax * zScale + zOffset; } diff --git a/src/app/3d/qgspointcloud3dsymbolwidget.h b/src/app/3d/qgspointcloud3dsymbolwidget.h index 99cc32a0afea..387ac2f8cd40 100644 --- a/src/app/3d/qgspointcloud3dsymbolwidget.h +++ b/src/app/3d/qgspointcloud3dsymbolwidget.h @@ -81,8 +81,8 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS bool mBlockMinMaxChanged = false; bool mBlockSetMinMaxFromLayer = false; - double mProviderMin = std::numeric_limits< double >::quiet_NaN(); - double mProviderMax = std::numeric_limits< double >::quiet_NaN(); + double mProviderMin = std::numeric_limits::quiet_NaN(); + double mProviderMax = std::numeric_limits::quiet_NaN(); void createValidators(); void setCustomMinMaxValues( QgsRgbPointCloud3DSymbol *r ) const; diff --git a/src/app/3d/qgspointcloudlayer3drendererwidget.cpp b/src/app/3d/qgspointcloudlayer3drendererwidget.cpp index 1f99aed553d9..4e1908f61d0c 100644 --- a/src/app/3d/qgspointcloudlayer3drendererwidget.cpp +++ b/src/app/3d/qgspointcloudlayer3drendererwidget.cpp @@ -105,8 +105,8 @@ void QgsPointCloudLayer3DRendererWidget::setDockMode( bool dockMode ) mWidgetPointCloudSymbol->setDockMode( dockMode ); } -QgsPointCloudLayer3DRendererWidgetFactory::QgsPointCloudLayer3DRendererWidgetFactory( QObject *parent ): - QObject( parent ) +QgsPointCloudLayer3DRendererWidgetFactory::QgsPointCloudLayer3DRendererWidgetFactory( QObject *parent ) + : QObject( parent ) { setIcon( QIcon( ":/images/themes/default/3d.svg" ) ); setTitle( tr( "3D View" ) ); diff --git a/src/app/3d/qgspolygon3dsymbolwidget.cpp b/src/app/3d/qgspolygon3dsymbolwidget.cpp index e966b7ff8762..95cff4f26081 100644 --- a/src/app/3d/qgspolygon3dsymbolwidget.cpp +++ b/src/app/3d/qgspolygon3dsymbolwidget.cpp @@ -65,7 +65,7 @@ Qgs3DSymbolWidget *QgsPolygon3DSymbolWidget::create( QgsVectorLayer * ) void QgsPolygon3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer ) { - const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast< const QgsPolygon3DSymbol * >( symbol ); + const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast( symbol ); if ( !polygonSymbol ) return; @@ -81,8 +81,8 @@ void QgsPolygon3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, Qgs widgetMaterial->setSettings( polygonSymbol->materialSettings(), layer ); - btnHeightDD->init( static_cast< int >( QgsAbstract3DSymbol::Property::Height ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true ); - btnExtrusionDD->init( static_cast< int >( QgsAbstract3DSymbol::Property::ExtrusionHeight ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true ); + btnHeightDD->init( static_cast( QgsAbstract3DSymbol::Property::Height ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true ); + btnExtrusionDD->init( static_cast( QgsAbstract3DSymbol::Property::ExtrusionHeight ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true ); groupEdges->setChecked( polygonSymbol->edgesEnabled() ); spinEdgeWidth->setValue( polygonSymbol->edgeWidth() ); @@ -91,7 +91,7 @@ void QgsPolygon3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, Qgs QgsAbstract3DSymbol *QgsPolygon3DSymbolWidget::symbol() { - std::unique_ptr< QgsPolygon3DSymbol > sym = std::make_unique< QgsPolygon3DSymbol >(); + std::unique_ptr sym = std::make_unique(); sym->setOffset( static_cast( spinOffset->value() ) ); sym->setExtrusionHeight( spinExtrusion->value() ); sym->setAltitudeClamping( static_cast( cboAltClamping->currentIndex() ) ); @@ -123,6 +123,6 @@ void QgsPolygon3DSymbolWidget::updateGuiState() { // Altitude binding is not taken into account if altitude clamping is absolute. // See: Qgs3DUtils::clampAltitudes() - const bool absoluteClamping = cboAltClamping->currentIndex() == static_cast< int >( Qgis::AltitudeClamping::Absolute ); + const bool absoluteClamping = cboAltClamping->currentIndex() == static_cast( Qgis::AltitudeClamping::Absolute ); cboAltBinding->setEnabled( !absoluteClamping ); } diff --git a/src/app/3d/qgsrulebased3drendererwidget.cpp b/src/app/3d/qgsrulebased3drendererwidget.cpp index 191c13ae8fbd..011d64996651 100644 --- a/src/app/3d/qgsrulebased3drendererwidget.cpp +++ b/src/app/3d/qgsrulebased3drendererwidget.cpp @@ -58,7 +58,6 @@ QgsRuleBased3DRendererWidget::QgsRuleBased3DRendererWidget( QWidget *parent ) connect( mCopyAction, &QAction::triggered, this, &QgsRuleBased3DRendererWidget::copy ); connect( mPasteAction, &QAction::triggered, this, &QgsRuleBased3DRendererWidget::paste ); connect( mDeleteAction, &QAction::triggered, this, &QgsRuleBased3DRendererWidget::removeRule ); - } QgsRuleBased3DRendererWidget::~QgsRuleBased3DRendererWidget() @@ -108,7 +107,7 @@ void QgsRuleBased3DRendererWidget::setDockMode( bool dockMode ) void QgsRuleBased3DRendererWidget::addRule() { - std::unique_ptr< QgsAbstract3DSymbol > newSymbol( QgsApplication::symbol3DRegistry()->defaultSymbolForGeometryType( mLayer->geometryType() ) ); + std::unique_ptr newSymbol( QgsApplication::symbol3DRegistry()->defaultSymbolForGeometryType( mLayer->geometryType() ) ); newSymbol->setDefaultPropertiesFromLayer( mLayer ); QgsRuleBased3DRenderer::Rule *newrule = new QgsRuleBased3DRenderer::Rule( newSymbol.release() ); @@ -230,9 +229,7 @@ Qt::ItemFlags QgsRuleBased3DRendererModel::flags( const QModelIndex &index ) con const Qt::ItemFlag checkable = ( index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags ); - return Qt::ItemIsEnabled | Qt::ItemIsSelectable | - Qt::ItemIsEditable | checkable | - Qt::ItemIsDragEnabled | drop; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | checkable | Qt::ItemIsDragEnabled | drop; } QVariant QgsRuleBased3DRendererModel::data( const QModelIndex &index, int role ) const @@ -543,8 +540,7 @@ void QgsRuleBased3DRendererModel::insertRule( const QModelIndex &parent, int bef void QgsRuleBased3DRendererModel::updateRule( const QModelIndex &parent, int row ) { - emit dataChanged( index( row, 0, parent ), - index( row, columnCount( parent ), parent ) ); + emit dataChanged( index( row, 0, parent ), index( row, columnCount( parent ), parent ) ); } @@ -588,8 +584,8 @@ Qgs3DRendererRulePropsWidget::Qgs3DRendererRulePropsWidget( QgsRuleBased3DRender connect( editDescription, &QLineEdit::textChanged, this, &Qgs3DRendererRulePropsWidget::widgetChanged ); connect( groupSymbol, &QGroupBox::toggled, this, &Qgs3DRendererRulePropsWidget::widgetChanged ); connect( mSymbolWidget, &QgsSymbol3DWidget::widgetChanged, this, &Qgs3DRendererRulePropsWidget::widgetChanged ); - connect( mFilterRadio, &QRadioButton::toggled, this, [ = ]( bool toggled ) { filterFrame->setEnabled( toggled ) ; } ); - connect( mElseRadio, &QRadioButton::toggled, this, [ = ]( bool toggled ) { if ( toggled ) editFilter->setText( QStringLiteral( "ELSE" ) );} ); + connect( mFilterRadio, &QRadioButton::toggled, this, [=]( bool toggled ) { filterFrame->setEnabled( toggled ); } ); + connect( mElseRadio, &QRadioButton::toggled, this, [=]( bool toggled ) { if ( toggled ) editFilter->setText( QStringLiteral( "ELSE" ) ); } ); } Qgs3DRendererRulePropsWidget::~Qgs3DRendererRulePropsWidget() = default; @@ -602,7 +598,7 @@ void Qgs3DRendererRulePropsWidget::testFilter() QgsExpression filter( editFilter->text() ); if ( filter.hasParserError() ) { - QMessageBox::critical( this, tr( "Test Filter" ), tr( "Filter expression parsing error:\n" ) + filter.parserErrorString() ); + QMessageBox::critical( this, tr( "Test Filter" ), tr( "Filter expression parsing error:\n" ) + filter.parserErrorString() ); return; } @@ -652,7 +648,7 @@ void Qgs3DRendererRulePropsWidget::apply() const QString filter = mElseRadio->isChecked() ? QStringLiteral( "ELSE" ) : editFilter->text(); mRule->setFilterExpression( filter ); mRule->setDescription( editDescription->text() ); - std::unique_ptr< QgsAbstract3DSymbol > newSymbol; + std::unique_ptr newSymbol; if ( groupSymbol->isChecked() ) newSymbol = mSymbolWidget->symbol(); mRule->setSymbol( newSymbol.release() ); diff --git a/src/app/3d/qgsrulebased3drendererwidget.h b/src/app/3d/qgsrulebased3drendererwidget.h index fd6a8e6f4478..b91b848dfea6 100644 --- a/src/app/3d/qgsrulebased3drendererwidget.h +++ b/src/app/3d/qgsrulebased3drendererwidget.h @@ -41,8 +41,7 @@ class QgsRuleBased3DRendererModel : public QAbstractItemModel Qt::ItemFlags flags( const QModelIndex &index ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; - QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const override; + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex & = QModelIndex() ) const override; //! provide model index for parent's child item @@ -72,14 +71,13 @@ class QgsRuleBased3DRendererModel : public QAbstractItemModel void removeRule( const QModelIndex &index ); void willAddRules( const QModelIndex &parent, int count ); // call beginInsertRows - void finishedAddingRules(); // call endInsertRows + void finishedAddingRules(); // call endInsertRows protected: QgsRuleBased3DRenderer::Rule *mRootRule = nullptr; }; - class QgsRuleBased3DRendererWidget : public QgsPanelWidget, private Ui::QgsRuleBased3DRendererWidget { Q_OBJECT @@ -122,8 +120,6 @@ class QgsRuleBased3DRendererWidget : public QgsPanelWidget, private Ui::QgsRuleB }; - - ////// class QgsSymbol3DWidget; @@ -141,8 +137,7 @@ class Qgs3DRendererRulePropsWidget : public QgsPanelWidget, private Ui::Qgs3DRen Editing }; - Qgs3DRendererRulePropsWidget( QgsRuleBased3DRenderer::Rule *rule, QgsVectorLayer *layer, - QWidget *parent = nullptr ); + Qgs3DRendererRulePropsWidget( QgsRuleBased3DRenderer::Rule *rule, QgsVectorLayer *layer, QWidget *parent = nullptr ); ~Qgs3DRendererRulePropsWidget() override; QgsRuleBased3DRenderer::Rule *rule() { return mRule; } @@ -162,7 +157,6 @@ class Qgs3DRendererRulePropsWidget : public QgsPanelWidget, private Ui::Qgs3DRen QgsSymbol3DWidget *mSymbolWidget = nullptr; std::unique_ptr mSymbol; // a clone of original symbol - }; #endif // QGSRULEBASED3DRENDERERWIDGET_H diff --git a/src/app/3d/qgsshadowrenderingsettingswidget.h b/src/app/3d/qgsshadowrenderingsettingswidget.h index 8f9d21c5a7e3..b393b9394182 100644 --- a/src/app/3d/qgsshadowrenderingsettingswidget.h +++ b/src/app/3d/qgsshadowrenderingsettingswidget.h @@ -34,7 +34,6 @@ class QgsShadowRenderingSettingsWidget : public QWidget, private Ui::ShadowRende QgsShadowSettings toShadowSettings(); public slots: void onDirectionalLightsCountChanged( int newCount ); - }; #endif // SHADOWRENDERINGSETTINGSWIDGET_H diff --git a/src/app/3d/qgssimplelinematerialwidget.cpp b/src/app/3d/qgssimplelinematerialwidget.cpp index 507546890cd1..7ffefe85736c 100644 --- a/src/app/3d/qgssimplelinematerialwidget.cpp +++ b/src/app/3d/qgssimplelinematerialwidget.cpp @@ -38,19 +38,19 @@ QgsMaterialSettingsWidget *QgsSimpleLineMaterialWidget::create() void QgsSimpleLineMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) { - const QgsSimpleLineMaterialSettings *lineMaterial = dynamic_cast< const QgsSimpleLineMaterialSettings * >( settings ); + const QgsSimpleLineMaterialSettings *lineMaterial = dynamic_cast( settings ); if ( !lineMaterial ) return; btnAmbient->setColor( lineMaterial->ambient() ); mPropertyCollection = settings->dataDefinedProperties(); - mAmbientDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); + mAmbientDataDefinedButton->init( static_cast( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true ); } QgsAbstractMaterialSettings *QgsSimpleLineMaterialWidget::settings() { - std::unique_ptr< QgsSimpleLineMaterialSettings > m = std::make_unique< QgsSimpleLineMaterialSettings >(); + std::unique_ptr m = std::make_unique(); m->setAmbient( btnAmbient->color() ); mPropertyCollection.setProperty( QgsAbstractMaterialSettings::Property::Ambient, mAmbientDataDefinedButton->toProperty() ); diff --git a/src/app/3d/qgssimplelinematerialwidget.h b/src/app/3d/qgssimplelinematerialwidget.h index 24d2b59118e4..a50ab908efe0 100644 --- a/src/app/3d/qgssimplelinematerialwidget.h +++ b/src/app/3d/qgssimplelinematerialwidget.h @@ -30,7 +30,6 @@ class QgsSimpleLineMaterialWidget : public QgsMaterialSettingsWidget, private Ui void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) override; QgsAbstractMaterialSettings *settings() override; - }; #endif // QGSSIMPLELINEMATERIALWIDGET_H diff --git a/src/app/3d/qgsskyboxrenderingsettingswidget.cpp b/src/app/3d/qgsskyboxrenderingsettingswidget.cpp index 5cc35edf01f4..b50a316474e3 100644 --- a/src/app/3d/qgsskyboxrenderingsettingswidget.cpp +++ b/src/app/3d/qgsskyboxrenderingsettingswidget.cpp @@ -48,18 +48,18 @@ void QgsSkyboxRenderingSettingsWidget::setSkyboxSettings( const QgsSkyboxSetting panoramicTextureImageSource->setSource( skyboxSettings.panoramicTexturePath() ); QMap cubeMapFaces = skyboxSettings.cubeMapFacesPaths(); - posXImageSource->setSource( cubeMapFaces[ QStringLiteral( "posX" ) ] ); - posYImageSource->setSource( cubeMapFaces[ QStringLiteral( "posY" ) ] ); - posZImageSource->setSource( cubeMapFaces[ QStringLiteral( "posZ" ) ] ); - negXImageSource->setSource( cubeMapFaces[ QStringLiteral( "negX" ) ] ); - negYImageSource->setSource( cubeMapFaces[ QStringLiteral( "negY" ) ] ); - negZImageSource->setSource( cubeMapFaces[ QStringLiteral( "negZ" ) ] ); + posXImageSource->setSource( cubeMapFaces[QStringLiteral( "posX" )] ); + posYImageSource->setSource( cubeMapFaces[QStringLiteral( "posY" )] ); + posZImageSource->setSource( cubeMapFaces[QStringLiteral( "posZ" )] ); + negXImageSource->setSource( cubeMapFaces[QStringLiteral( "negX" )] ); + negYImageSource->setSource( cubeMapFaces[QStringLiteral( "negY" )] ); + negZImageSource->setSource( cubeMapFaces[QStringLiteral( "negZ" )] ); } QgsSkyboxSettings QgsSkyboxRenderingSettingsWidget::toSkyboxSettings() { QgsSkyboxSettings settings; - settings.setSkyboxType( static_cast< QgsSkyboxEntity::SkyboxType >( skyboxTypeComboBox->currentIndex() ) ); + settings.setSkyboxType( static_cast( skyboxTypeComboBox->currentIndex() ) ); settings.setPanoramicTexturePath( panoramicTextureImageSource->source() ); settings.setCubeMapFace( QStringLiteral( "posX" ), posXImageSource->source() ); settings.setCubeMapFace( QStringLiteral( "posY" ), posYImageSource->source() ); @@ -72,7 +72,7 @@ QgsSkyboxSettings QgsSkyboxRenderingSettingsWidget::toSkyboxSettings() void QgsSkyboxRenderingSettingsWidget::showSkyboxSettings( int ) { - const QgsSkyboxEntity::SkyboxType type = static_cast< QgsSkyboxEntity::SkyboxType >( skyboxTypeComboBox->currentIndex() ); + const QgsSkyboxEntity::SkyboxType type = static_cast( skyboxTypeComboBox->currentIndex() ); const bool isPanoramic = type == QgsSkyboxEntity::PanoramicSkybox; const bool isDistinctFaces = type == QgsSkyboxEntity::DistinctTexturesSkybox; @@ -91,5 +91,4 @@ void QgsSkyboxRenderingSettingsWidget::showSkyboxSettings( int ) posYImageSource->setVisible( isDistinctFaces ); posZImageSourceLabel->setVisible( isDistinctFaces ); posZImageSource->setVisible( isDistinctFaces ); - } diff --git a/src/app/3d/qgssymbol3dwidget.cpp b/src/app/3d/qgssymbol3dwidget.cpp index ec8fe30882c2..45882146f9a0 100644 --- a/src/app/3d/qgssymbol3dwidget.cpp +++ b/src/app/3d/qgssymbol3dwidget.cpp @@ -55,9 +55,9 @@ QgsSymbol3DWidget::QgsSymbol3DWidget( QgsVectorLayer *layer, QWidget *parent ) std::unique_ptr QgsSymbol3DWidget::symbol() { - if ( Qgs3DSymbolWidget *w = qobject_cast< Qgs3DSymbolWidget * >( widgetStack->currentWidget() ) ) + if ( Qgs3DSymbolWidget *w = qobject_cast( widgetStack->currentWidget() ) ) { - return std::unique_ptr< QgsAbstract3DSymbol >( w->symbol() ); + return std::unique_ptr( w->symbol() ); } return nullptr; } @@ -67,7 +67,7 @@ void QgsSymbol3DWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorL mLayer = vlayer; mStyleWidget->setLayerType( mLayer->geometryType() ); - if ( Qgs3DSymbolWidget *w = qobject_cast< Qgs3DSymbolWidget * >( widgetStack->currentWidget() ) ) + if ( Qgs3DSymbolWidget *w = qobject_cast( widgetStack->currentWidget() ) ) { if ( w->symbolType() == symbol->type() ) { @@ -92,7 +92,7 @@ void QgsSymbol3DWidget::setSymbolFromStyle( const QString &name, QgsStyle::Style style = QgsStyle::defaultStyle(); // get new instance of symbol from style - const std::unique_ptr< QgsAbstract3DSymbol > s( style->symbol3D( name ) ); + const std::unique_ptr s( style->symbol3D( name ) ); if ( !s ) return; @@ -111,15 +111,12 @@ void QgsSymbol3DWidget::saveSymbol() QgsStyle *destinationStyle = saveDlg.destinationStyle(); - std::unique_ptr< QgsAbstract3DSymbol > newSymbol( symbol() ); + std::unique_ptr newSymbol( symbol() ); // check if there is no symbol with same name if ( destinationStyle->symbol3DNames().contains( saveDlg.name() ) ) { - const int res = QMessageBox::warning( this, tr( "Save 3D Symbol" ), - tr( "A 3D symbol with the name '%1' already exists. Overwrite?" ) - .arg( saveDlg.name() ), - QMessageBox::Yes | QMessageBox::No ); + const int res = QMessageBox::warning( this, tr( "Save 3D Symbol" ), tr( "A 3D symbol with the name '%1' already exists. Overwrite?" ).arg( saveDlg.name() ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) { return; @@ -142,7 +139,7 @@ void QgsSymbol3DWidget::updateSymbolWidget( const QgsAbstract3DSymbol *newSymbol if ( widgetStack->currentWidget() != widgetUnsupported ) { // stop updating from the original widget - if ( Qgs3DSymbolWidget *w = qobject_cast< Qgs3DSymbolWidget * >( widgetStack->currentWidget() ) ) + if ( Qgs3DSymbolWidget *w = qobject_cast( widgetStack->currentWidget() ) ) disconnect( w, &Qgs3DSymbolWidget::changed, this, &QgsSymbol3DWidget::widgetChanged ); widgetStack->removeWidget( widgetStack->currentWidget() ); } diff --git a/src/app/3d/qgssymbol3dwidget.h b/src/app/3d/qgssymbol3dwidget.h index 023e2c86864f..c825db792f69 100644 --- a/src/app/3d/qgssymbol3dwidget.h +++ b/src/app/3d/qgssymbol3dwidget.h @@ -42,7 +42,7 @@ class QgsSymbol3DWidget : public QWidget QgsSymbol3DWidget( QgsVectorLayer *layer, QWidget *parent = nullptr ); //! Returns a new symbol instance or NULLPTR - std::unique_ptr< QgsAbstract3DSymbol > symbol(); + std::unique_ptr symbol(); //! Sets symbol (does not take ownership) void setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *vlayer ); @@ -56,7 +56,6 @@ class QgsSymbol3DWidget : public QWidget void saveSymbol(); private: - void updateSymbolWidget( const QgsAbstract3DSymbol *newSymbol ); QStackedWidget *widgetStack = nullptr; @@ -65,7 +64,6 @@ class QgsSymbol3DWidget : public QWidget QgsStyleItemsListWidget *mStyleWidget = nullptr; QgsVectorLayer *mLayer = nullptr; - }; diff --git a/src/app/3d/qgsvectorlayer3drendererwidget.cpp b/src/app/3d/qgsvectorlayer3drendererwidget.cpp index 6ddcf87a68a8..20b7459b735a 100644 --- a/src/app/3d/qgsvectorlayer3drendererwidget.cpp +++ b/src/app/3d/qgsvectorlayer3drendererwidget.cpp @@ -33,7 +33,6 @@ #include - QgsSingleSymbol3DRendererWidget::QgsSingleSymbol3DRendererWidget( QgsVectorLayer *layer, QWidget *parent ) : QWidget( parent ) , mLayer( layer ) @@ -74,7 +73,7 @@ void QgsSingleSymbol3DRendererWidget::setLayer( QgsVectorLayer *layer ) std::unique_ptr QgsSingleSymbol3DRendererWidget::symbol() { - return widgetSymbol->symbol(); // cloned or null + return widgetSymbol->symbol(); // cloned or null } // ------- @@ -101,14 +100,14 @@ QgsVectorLayer3DRendererWidget::QgsVectorLayer3DRendererWidget( QgsMapLayer *lay layout->addWidget( widgetBaseProperties ); widgetNoRenderer = new QLabel; - widgetSingleSymbolRenderer = new QgsSingleSymbol3DRendererWidget( qobject_cast< QgsVectorLayer *>( layer ), this ); + widgetSingleSymbolRenderer = new QgsSingleSymbol3DRendererWidget( qobject_cast( layer ), this ); widgetRuleBasedRenderer = new QgsRuleBased3DRendererWidget( this ); widgetRendererStack->addWidget( widgetNoRenderer ); widgetRendererStack->addWidget( widgetSingleSymbolRenderer ); widgetRendererStack->addWidget( widgetRuleBasedRenderer ); - connect( cboRendererType, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsVectorLayer3DRendererWidget::onRendererTypeChanged ); + connect( cboRendererType, qOverload( &QComboBox::currentIndexChanged ), this, &QgsVectorLayer3DRendererWidget::onRendererTypeChanged ); connect( widgetSingleSymbolRenderer, &QgsSingleSymbol3DRendererWidget::widgetChanged, this, &QgsVectorLayer3DRendererWidget::widgetChanged ); connect( widgetRuleBasedRenderer, &QgsRuleBased3DRendererWidget::widgetChanged, this, &QgsVectorLayer3DRendererWidget::widgetChanged ); connect( widgetRuleBasedRenderer, &QgsRuleBased3DRendererWidget::showPanel, this, &QgsPanelWidget::openPanel ); @@ -171,7 +170,7 @@ void QgsVectorLayer3DRendererWidget::apply() break; case 1: { - std::unique_ptr< QgsAbstract3DSymbol > symbol = widgetSingleSymbolRenderer->symbol(); + std::unique_ptr symbol = widgetSingleSymbolRenderer->symbol(); QgsVectorLayer3DRenderer *r = new QgsVectorLayer3DRenderer( symbol ? symbol.release() : nullptr ); r->setLayer( qobject_cast( mLayer ) ); widgetBaseProperties->apply( r ); diff --git a/src/app/3d/qgsvectorlayer3drendererwidget.h b/src/app/3d/qgsvectorlayer3drendererwidget.h index 59d231b4c45f..cae345cde665 100644 --- a/src/app/3d/qgsvectorlayer3drendererwidget.h +++ b/src/app/3d/qgsvectorlayer3drendererwidget.h @@ -45,7 +45,7 @@ class QgsSingleSymbol3DRendererWidget : public QWidget void setLayer( QgsVectorLayer *layer ); //! Returns the cloned symbol or NULLPTR. - std::unique_ptr< QgsAbstract3DSymbol > symbol(); + std::unique_ptr symbol(); signals: void widgetChanged(); @@ -53,11 +53,9 @@ class QgsSingleSymbol3DRendererWidget : public QWidget private: QgsSymbol3DWidget *widgetSymbol = nullptr; QgsVectorLayer *mLayer = nullptr; - }; - //! Widget for configuration of 3D renderer of a vector layer class QgsVectorLayer3DRendererWidget : public QgsMapLayerConfigWidget { @@ -101,5 +99,4 @@ class QgsVectorLayer3DRendererWidgetFactory : public QObject, public QgsMapLayer }; - #endif // QGSVECTORLAYER3DRENDERERWIDGET_H diff --git a/src/app/annotations/qgsannotationitempropertieswidget.cpp b/src/app/annotations/qgsannotationitempropertieswidget.cpp index bddf2caba58e..37770225a04a 100644 --- a/src/app/annotations/qgsannotationitempropertieswidget.cpp +++ b/src/app/annotations/qgsannotationitempropertieswidget.cpp @@ -51,7 +51,7 @@ QgsAnnotationItemPropertiesWidget::QgsAnnotationItemPropertiesWidget( QgsAnnotat mStack->setCurrentWidget( mPageNoItem ); connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged ); - connect( mBlendModeComboBox, qOverload< int >( &QgsBlendModeComboBox::currentIndexChanged ), this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged ); + connect( mBlendModeComboBox, qOverload( &QgsBlendModeComboBox::currentIndexChanged ), this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged ); connect( mEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged ); setDockMode( true ); @@ -66,7 +66,7 @@ void QgsAnnotationItemPropertiesWidget::syncToLayer( QgsMapLayer *layer ) if ( layer == mLayer ) return; - mLayer = qobject_cast< QgsAnnotationLayer * >( layer ); + mLayer = qobject_cast( layer ); if ( !mLayer ) return; @@ -138,7 +138,7 @@ void QgsAnnotationItemPropertiesWidget::onChanged() if ( QgsAnnotationItem *existingItem = mLayer->item( mMapLayerConfigWidgetContext.annotationId() ) ) { - std::unique_ptr< QgsAnnotationItem > newItem( existingItem->clone() ); + std::unique_ptr newItem( existingItem->clone() ); mItemWidget->updateItem( newItem.get() ); mLayer->replaceItem( mMapLayerConfigWidgetContext.annotationId(), newItem.release() ); @@ -228,7 +228,7 @@ QgsAnnotationItemPropertiesWidgetFactory::QgsAnnotationItemPropertiesWidgetFacto QgsMapLayerConfigWidget *QgsAnnotationItemPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const { - return new QgsAnnotationItemPropertiesWidget( qobject_cast< QgsAnnotationLayer * >( layer ), canvas, parent ); + return new QgsAnnotationItemPropertiesWidget( qobject_cast( layer ), canvas, parent ); } bool QgsAnnotationItemPropertiesWidgetFactory::supportLayerPropertiesDialog() const @@ -245,4 +245,3 @@ bool QgsAnnotationItemPropertiesWidgetFactory::supportsLayer( QgsMapLayer *layer { return layer->type() == Qgis::LayerType::Annotation; } - diff --git a/src/app/annotations/qgsannotationitempropertieswidget.h b/src/app/annotations/qgsannotationitempropertieswidget.h index 9ca1c8f1a584..508ac4b31cfc 100644 --- a/src/app/annotations/qgsannotationitempropertieswidget.h +++ b/src/app/annotations/qgsannotationitempropertieswidget.h @@ -29,7 +29,6 @@ class QgsAnnotationItemPropertiesWidget : public QgsMapLayerConfigWidget, public { Q_OBJECT public: - QgsAnnotationItemPropertiesWidget( QgsAnnotationLayer *layer, QgsMapCanvas *canvas, QWidget *parent ); ~QgsAnnotationItemPropertiesWidget() override; @@ -45,17 +44,16 @@ class QgsAnnotationItemPropertiesWidget : public QgsMapLayerConfigWidget, public void onChanged(); void onLayerPropertyChanged(); - private: + private: void setItemId( const QString &itemId ); - QPointer< QgsAnnotationLayer > mLayer; - QPointer< QgsAnnotationItemBaseWidget > mItemWidget; + QPointer mLayer; + QPointer mItemWidget; QWidget *mPageNoItem = nullptr; bool mBlockLayerUpdates = false; - std::unique_ptr< QgsPaintEffect > mPaintEffect; - + std::unique_ptr mPaintEffect; }; @@ -72,5 +70,4 @@ class QgsAnnotationItemPropertiesWidgetFactory : public QObject, public QgsMapLa }; - #endif // QGSANNOTATIONITEMPROPERTIESWIDGET_H diff --git a/src/app/annotations/qgsannotationlayerproperties.cpp b/src/app/annotations/qgsannotationlayerproperties.cpp index ceb07bd0ff2c..9a0cb1e6c8e5 100644 --- a/src/app/annotations/qgsannotationlayerproperties.cpp +++ b/src/app/annotations/qgsannotationlayerproperties.cpp @@ -59,8 +59,7 @@ QgsAnnotationLayerProperties::QgsAnnotationLayerProperties( QgsAnnotationLayer * QgsSettings settings; if ( !settings.contains( QStringLiteral( "/Windows/AnnotationLayerProperties/tab" ) ) ) { - settings.setValue( QStringLiteral( "Windows/AnnotationLayerProperties/tab" ), - mOptStackedWidget->indexOf( mOptsPage_Information ) ); + settings.setValue( QStringLiteral( "Windows/AnnotationLayerProperties/tab" ), mOptStackedWidget->indexOf( mOptsPage_Information ) ); } mBtnStyle = new QPushButton( tr( "Style" ) ); diff --git a/src/app/annotations/qgsannotationlayerproperties.h b/src/app/annotations/qgsannotationlayerproperties.h index fd3999d3a0e1..782b82c189e4 100644 --- a/src/app/annotations/qgsannotationlayerproperties.h +++ b/src/app/annotations/qgsannotationlayerproperties.h @@ -54,10 +54,9 @@ class APP_EXPORT QgsAnnotationLayerProperties : public QgsLayerPropertiesDialog, QPushButton *mBtnStyle = nullptr; - std::unique_ptr< QgsPaintEffect > mPaintEffect; + std::unique_ptr mPaintEffect; QgsCoordinateReferenceSystem mBackupCrs; - }; #endif // QGSANNOTATIONLAYERPROPERTIES_H diff --git a/src/app/browser/qgsinbuiltdataitemproviders.cpp b/src/app/browser/qgsinbuiltdataitemproviders.cpp index 58522124eb34..aec3c9e79716 100644 --- a/src/app/browser/qgsinbuiltdataitemproviders.cpp +++ b/src/app/browser/qgsinbuiltdataitemproviders.cpp @@ -86,12 +86,12 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe if ( item->type() != Qgis::BrowserItemType::Directory ) return; - QgsDirectoryItem *directoryItem = qobject_cast< QgsDirectoryItem * >( item ); + QgsDirectoryItem *directoryItem = qobject_cast( item ); QgsSettings settings; QAction *actionRefresh = new QAction( tr( "Refresh" ), menu ); - connect( actionRefresh, &QAction::triggered, this, [ = ] { directoryItem->refresh(); } ); + connect( actionRefresh, &QAction::triggered, this, [=] { directoryItem->refresh(); } ); menu->addAction( actionRefresh ); menu->addSeparator(); @@ -99,8 +99,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe QMenu *newMenu = new QMenu( tr( "New" ), menu ); QAction *createFolder = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionNewFolder.svg" ) ), tr( "Directory…" ), menu ); - connect( createFolder, &QAction::triggered, this, [ = ] - { + connect( createFolder, &QAction::triggered, this, [=] { bool ok = false; const QString name = QInputDialog::getText( QgisApp::instance(), tr( "Create Directory" ), tr( "Directory name" ), QLineEdit::Normal, QString(), &ok ); @@ -125,8 +124,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe QAction *createGpkg = new QAction( tr( "GeoPackage…" ), newMenu ); createGpkg->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionNewGeoPackageLayer.svg" ) ) ); - connect( createGpkg, &QAction::triggered, this, [ = ] - { + connect( createGpkg, &QAction::triggered, this, [=] { QDir dir( directoryItem->dirPath() ); QString newName = tr( "New GeoPackage.gpkg" ); int i = 1; @@ -140,15 +138,14 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe if ( QgsProviderMetadata *ogrMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) ) ) { QString error; - if ( ! ogrMetadata->createDatabase( fileName, error ) ) + if ( !ogrMetadata->createDatabase( fileName, error ) ) { context.messageBar()->pushCritical( tr( "New GeoPackage" ), tr( "GeoPackage creation failed: %1" ).arg( error ) ); } else { QObject *contextObject = new QObject(); - connect( directoryItem, &QgsDataItem::stateChanged, contextObject, [contextObject, fileName, context]( QgsDataItem * item, Qgis::BrowserItemState ) - { + connect( directoryItem, &QgsDataItem::stateChanged, contextObject, [contextObject, fileName, context]( QgsDataItem *item, Qgis::BrowserItemState ) { if ( item->state() == Qgis::BrowserItemState::Populated ) { // find the new item and select it @@ -176,16 +173,14 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe QAction *createShp = new QAction( tr( "ShapeFile…" ), newMenu ); createShp->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionNewVectorLayer.svg" ) ) ); - connect( createShp, &QAction::triggered, this, [ = ] - { + connect( createShp, &QAction::triggered, this, [=] { QString enc; QDir dir( directoryItem->dirPath() ); QString error; const QString newFile = QgsNewVectorLayerDialog::execAndCreateLayer( error, QgisApp::instance(), dir.filePath( QStringLiteral( "new_layer.shp" ) ), &enc, QgsProject::instance()->defaultCrsForNewLayers() ); if ( !newFile.isEmpty() ) { - context.messageBar()->pushSuccess( tr( "New ShapeFile" ), tr( "Created %2" ).arg( - QUrl::fromLocalFile( newFile ).toString(), QDir::toNativeSeparators( newFile ) ) ); + context.messageBar()->pushSuccess( tr( "New ShapeFile" ), tr( "Created %2" ).arg( QUrl::fromLocalFile( newFile ).toString(), QDir::toNativeSeparators( newFile ) ) ); item->refresh(); } else if ( !error.isEmpty() ) @@ -195,11 +190,10 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe } ); newMenu->addAction( createShp ); -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,6,0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 6, 0 ) QAction *createFgdb = new QAction( tr( "ESRI FileGeodatabase…" ), newMenu ); createFgdb->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionNewFileGeodatabase.svg" ) ) ); - connect( createFgdb, &QAction::triggered, this, [ = ] - { + connect( createFgdb, &QAction::triggered, this, [=] { QDir dir( directoryItem->dirPath() ); QString newName = tr( "New File Geodatabase.gdb" ); int i = 1; @@ -213,15 +207,14 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe if ( QgsProviderMetadata *ogrMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) ) ) { QString error; - if ( ! ogrMetadata->createDatabase( fileName, error ) ) + if ( !ogrMetadata->createDatabase( fileName, error ) ) { context.messageBar()->pushCritical( tr( "New ESRI File Geodatabase" ), tr( "Database creation failed: %1" ).arg( error ) ); } else { QObject *contextObject = new QObject(); - connect( directoryItem, &QgsDataItem::stateChanged, contextObject, [contextObject, fileName, context]( QgsDataItem * item, Qgis::BrowserItemState ) - { + connect( directoryItem, &QgsDataItem::stateChanged, contextObject, [contextObject, fileName, context]( QgsDataItem *item, Qgis::BrowserItemState ) { if ( item->state() == Qgis::BrowserItemState::Populated ) { // find the new item and select it @@ -259,25 +252,22 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe QAction *addAsFavorite = new QAction( tr( "Add as a Favorite" ), menu ); addAsFavorite->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFavorites.svg" ) ) ); menu->addAction( addAsFavorite ); - connect( addAsFavorite, &QAction::triggered, this, [ = ] - { + connect( addAsFavorite, &QAction::triggered, this, [=] { addFavorite( directoryItem ); } ); } else if ( inFavDirs ) { - if ( QgsFavoriteItem *favoriteItem = qobject_cast< QgsFavoriteItem * >( item ) ) + if ( QgsFavoriteItem *favoriteItem = qobject_cast( item ) ) { QAction *actionRename = new QAction( tr( "Rename Favorite…" ), menu ); - connect( actionRename, &QAction::triggered, this, [ = ] - { + connect( actionRename, &QAction::triggered, this, [=] { renameFavorite( favoriteItem ); } ); menu->addAction( actionRename ); QAction *removeFavoriteAction = new QAction( tr( "Remove Favorite" ), menu ); - connect( removeFavoriteAction, &QAction::triggered, this, [ = ] - { + connect( removeFavoriteAction, &QAction::triggered, this, [=] { removeFavorite( favoriteItem ); } ); menu->addAction( removeFavoriteAction ); @@ -285,8 +275,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe } } QAction *hideAction = new QAction( tr( "Hide from Browser" ), menu ); - connect( hideAction, &QAction::triggered, this, [ = ] - { + connect( hideAction, &QAction::triggered, this, [=] { hideDirectory( directoryItem ); } ); menu->addAction( hideAction ); @@ -298,8 +287,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe for ( const QString &path : hiddenPathList ) { QAction *action = new QAction( QDir::toNativeSeparators( path ), hiddenMenu ); - connect( action, &QAction::triggered, this, [ = ] - { + connect( action, &QAction::triggered, this, [=] { QgsSettings s; QStringList pathsList = s.value( QStringLiteral( "/browser/hiddenPaths" ) ).toStringList(); pathsList.removeAll( path ); @@ -331,8 +319,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe hiddenMenu->addSeparator(); QAction *moreAction = new QAction( tr( "Show More…" ), hiddenMenu ); - connect( moreAction, &QAction::triggered, this, [ = ] - { + connect( moreAction, &QAction::triggered, this, [=] { QgisApp::instance()->showOptionsDialog( QgisApp::instance(), QStringLiteral( "mOptionsPageDataSources" ) ); } ); hiddenMenu->addAction( moreAction ); @@ -348,16 +335,14 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe const QPixmap icon = QgsColorButton::createMenuIcon( directoryItem->iconColor(), true ); actionSetIconColor->setIcon( icon ); } - connect( actionSetIconColor, &QAction::triggered, this, [ = ] - { + connect( actionSetIconColor, &QAction::triggered, this, [=] { changeDirectoryColor( directoryItem ); } ); menu->addAction( actionSetIconColor ); if ( directoryItem->iconColor().isValid() ) { QAction *actionClearIconColor = new QAction( tr( "Clear Custom Color" ), menu ); - connect( actionClearIconColor, &QAction::triggered, this, [ = ] - { + connect( actionClearIconColor, &QAction::triggered, this, [=] { clearDirectoryColor( directoryItem ); } ); menu->addAction( actionClearIconColor ); @@ -366,8 +351,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe QMenu *scanningMenu = new QMenu( tr( "Scanning" ), menu ); QAction *monitorAction = new QAction( tr( "Monitor for Changes" ), scanningMenu ); - connect( monitorAction, &QAction::triggered, this, [ = ] - { + connect( monitorAction, &QAction::triggered, this, [=] { toggleMonitor( directoryItem ); } ); monitorAction->setCheckable( true ); @@ -375,13 +359,11 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe scanningMenu->addAction( monitorAction ); QAction *fastScanAction = new QAction( tr( "Fast Scan this Directory" ), scanningMenu ); - connect( fastScanAction, &QAction::triggered, this, [ = ] - { + connect( fastScanAction, &QAction::triggered, this, [=] { toggleFastScan( directoryItem ); } ); fastScanAction->setCheckable( true ); - fastScanAction->setChecked( settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ), - QStringList() ).toStringList().contains( item->path() ) ); + fastScanAction->setChecked( settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ), QStringList() ).toStringList().contains( item->path() ) ); scanningMenu->addAction( fastScanAction ); menu->addMenu( scanningMenu ); @@ -389,8 +371,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe menu->addSeparator(); QAction *openFolder = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mIconFolder.svg" ) ), tr( "Open Directory…" ), menu ); - connect( openFolder, &QAction::triggered, this, [ = ] - { + connect( openFolder, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl::fromLocalFile( directoryItem->dirPath() ) ); } ); menu->addAction( openFolder ); @@ -398,8 +379,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe if ( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeOpenTerminalAtPath ) { QAction *openTerminal = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionTerminal.svg" ) ), tr( "Open in Terminal…" ), menu ); - connect( openTerminal, &QAction::triggered, this, [ = ] - { + connect( openTerminal, &QAction::triggered, this, [=] { QgsGui::nativePlatformInterface()->openTerminalAtPath( directoryItem->dirPath() ); } ); menu->addAction( openTerminal ); @@ -407,19 +387,17 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe } QAction *propertiesAction = new QAction( tr( "Properties…" ), menu ); - connect( propertiesAction, &QAction::triggered, this, [ = ] - { + connect( propertiesAction, &QAction::triggered, this, [=] { showProperties( directoryItem, context ); } ); menu->addAction( propertiesAction ); if ( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeFilePropertiesDialog ) { - if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem * >( item ) ) + if ( QgsDirectoryItem *dirItem = qobject_cast( item ) ) { QAction *action = menu->addAction( tr( "Directory Properties…" ) ); - connect( action, &QAction::triggered, dirItem, [ dirItem ] - { + connect( action, &QAction::triggered, dirItem, [dirItem] { QgsGui::nativePlatformInterface()->showFileProperties( dirItem->dirPath() ); } ); } @@ -472,7 +450,7 @@ void QgsAppDirectoryItemGuiProvider::clearDirectoryColor( QgsDirectoryItem *item void QgsAppDirectoryItemGuiProvider::hideDirectory( QgsDirectoryItem *item ) { - if ( ! item ) + if ( !item ) return; QgisApp::instance()->browserModel()->hidePath( item ); @@ -481,8 +459,7 @@ void QgsAppDirectoryItemGuiProvider::hideDirectory( QgsDirectoryItem *item ) void QgsAppDirectoryItemGuiProvider::toggleFastScan( QgsDirectoryItem *item ) { QgsSettings settings; - QStringList fastScanDirs = settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ), - QStringList() ).toStringList(); + QStringList fastScanDirs = settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ), QStringList() ).toStringList(); int idx = fastScanDirs.indexOf( item->path() ); if ( idx != -1 ) { @@ -505,7 +482,7 @@ void QgsAppDirectoryItemGuiProvider::toggleMonitor( QgsDirectoryItem *item ) void QgsAppDirectoryItemGuiProvider::showProperties( QgsDirectoryItem *item, QgsDataItemGuiContext context ) { - if ( ! item ) + if ( !item ) return; QgsBrowserPropertiesDialog *dialog = new QgsBrowserPropertiesDialog( QStringLiteral( "browser" ), QgisApp::instance() ); @@ -527,16 +504,14 @@ QString QgsAppFileItemGuiProvider::name() void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) { - QAction *openDataSourceManagerAction = nullptr; - if ( const auto layerItem = qobject_cast< QgsLayerItem * >( item ) ) + if ( const auto layerItem = qobject_cast( item ) ) { const QList sourceSelectProviders { QgsGui::sourceSelectProviderRegistry()->providersByKey( layerItem->providerKey() ) }; - if ( ! sourceSelectProviders.isEmpty() && sourceSelectProviders.first()->capabilities().testFlag( QgsSourceSelectProvider::Capability::ConfigureFromUri ) ) + if ( !sourceSelectProviders.isEmpty() && sourceSelectProviders.first()->capabilities().testFlag( QgsSourceSelectProvider::Capability::ConfigureFromUri ) ) { openDataSourceManagerAction = new QAction( tr( "Open with Data Source Manager…" ), menu ); - connect( openDataSourceManagerAction, &QAction::triggered, this, [ = ] - { + connect( openDataSourceManagerAction, &QAction::triggered, this, [=] { QString pageName { layerItem->providerKey() }; // GPKG special handling if ( qobject_cast( layerItem ) ) @@ -547,7 +522,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m } ); } } - else if ( const auto collectionItem = qobject_cast< QgsFileDataCollectionItem * >( item ) ) + else if ( const auto collectionItem = qobject_cast( item ) ) { QSet providerKeys; const QList sublayers { collectionItem->sublayers() }; @@ -558,17 +533,16 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m if ( providerKeys.count() == 1 ) { - const QgsProviderSublayerDetails &sublayer {sublayers.first() }; + const QgsProviderSublayerDetails &sublayer { sublayers.first() }; openDataSourceManagerAction = new QAction( tr( "Open with Data Source Manager…" ), menu ); - connect( openDataSourceManagerAction, &QAction::triggered, this, [ = ] - { + connect( openDataSourceManagerAction, &QAction::triggered, this, [=] { QString pageName { sublayer.providerKey() }; // GPKG special handling - if ( sublayer.driverName() == QStringLiteral( "GeoPackage" ) ) + if ( sublayer.driverName() == QStringLiteral( "GeoPackage" ) ) { pageName = QStringLiteral( "GeoPackage" ); } - else if ( sublayer.driverName() == QStringLiteral( "SQLite" ) ) + else if ( sublayer.driverName() == QStringLiteral( "SQLite" ) ) { pageName = QStringLiteral( "Spatialite" ); } @@ -585,26 +559,24 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m if ( item->capabilities2() & Qgis::BrowserItemCapability::ItemRepresentsFile ) { - // Check for certain file items const QString filename = item->path(); const QFileInfo fi( filename ); if ( !filename.isEmpty() ) { - const static QList< std::pair< QString, QString > > sStandardFileTypes = - { - { QStringLiteral( "pdf" ), QObject::tr( "Document" )}, - { QStringLiteral( "xls" ), QObject::tr( "Spreadsheet" )}, - { QStringLiteral( "xlsx" ), QObject::tr( "Spreadsheet" )}, - { QStringLiteral( "ods" ), QObject::tr( "Spreadsheet" )}, - { QStringLiteral( "csv" ), QObject::tr( "CSV File" )}, - { QStringLiteral( "txt" ), QObject::tr( "Text File" )}, - { QStringLiteral( "png" ), QObject::tr( "PNG Image" )}, - { QStringLiteral( "jpg" ), QObject::tr( "JPEG Image" )}, - { QStringLiteral( "jpeg" ), QObject::tr( "JPEG Image" )}, - { QStringLiteral( "tif" ), QObject::tr( "TIFF Image" )}, - { QStringLiteral( "tiff" ), QObject::tr( "TIFF Image" )}, - { QStringLiteral( "svg" ), QObject::tr( "SVG File" )} + const static QList> sStandardFileTypes = { + { QStringLiteral( "pdf" ), QObject::tr( "Document" ) }, + { QStringLiteral( "xls" ), QObject::tr( "Spreadsheet" ) }, + { QStringLiteral( "xlsx" ), QObject::tr( "Spreadsheet" ) }, + { QStringLiteral( "ods" ), QObject::tr( "Spreadsheet" ) }, + { QStringLiteral( "csv" ), QObject::tr( "CSV File" ) }, + { QStringLiteral( "txt" ), QObject::tr( "Text File" ) }, + { QStringLiteral( "png" ), QObject::tr( "PNG Image" ) }, + { QStringLiteral( "jpg" ), QObject::tr( "JPEG Image" ) }, + { QStringLiteral( "jpeg" ), QObject::tr( "JPEG Image" ) }, + { QStringLiteral( "tif" ), QObject::tr( "TIFF Image" ) }, + { QStringLiteral( "tiff" ), QObject::tr( "TIFF Image" ) }, + { QStringLiteral( "svg" ), QObject::tr( "SVG File" ) } }; for ( const auto &it : sStandardFileTypes ) { @@ -613,8 +585,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m if ( fi.suffix().compare( ext, Qt::CaseInsensitive ) == 0 ) { QAction *viewAction = new QAction( tr( "Open %1 Externally…" ).arg( name ), menu ); - connect( viewAction, &QAction::triggered, this, [ = ] - { + connect( viewAction, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl::fromLocalFile( filename ) ); } ); @@ -636,7 +607,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m } } - if ( qobject_cast< QgsDataCollectionItem * >( item ) ) + if ( qobject_cast( item ) ) { QAction *actionRefresh = new QAction( QObject::tr( "Refresh" ), menu ); connect( actionRefresh, &QAction::triggered, item, [item] { item->refresh(); } ); @@ -659,7 +630,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m QMenu *manageFileMenu = new QMenu( tr( "Manage" ), menu ); QStringList selectedFiles; - QList< QPointer< QgsDataItem > > selectedParents; + QList> selectedParents; for ( QgsDataItem *selectedItem : selectedItems ) { if ( selectedItem->capabilities2() & Qgis::BrowserItemCapability::ItemRepresentsFile ) @@ -673,8 +644,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m { const QString renameText = tr( "Rename “%1”…" ).arg( fi.fileName() ); QAction *renameAction = new QAction( renameText, menu ); - connect( renameAction, &QAction::triggered, this, [ = ] - { + connect( renameAction, &QAction::triggered, this, [=] { const QString oldPath = selectedFiles.value( 0 ); const QStringList existingNames = QFileInfo( oldPath ).dir().entryList(); @@ -696,10 +666,9 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m } const QString deleteText = selectedFiles.count() == 1 ? tr( "Delete “%1”…" ).arg( fi.fileName() ) - : tr( "Delete Selected Files…" ); + : tr( "Delete Selected Files…" ); QAction *deleteAction = new QAction( deleteText, menu ); - connect( deleteAction, &QAction::triggered, this, [ = ] - { + connect( deleteAction, &QAction::triggered, this, [=] { // Check if the files correspond to paths in the project QList layersList; for ( const QString &path : std::as_const( selectedFiles ) ) @@ -708,15 +677,14 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m } // now expand out the list of files to include all sidecar files (e.g. .aux.xml files) - QSet< QString > allFilesWithSidecars; + QSet allFilesWithSidecars; for ( const QString &file : std::as_const( selectedFiles ) ) { allFilesWithSidecars.insert( file ); allFilesWithSidecars.unite( QgsFileUtils::sidecarFilesForPath( file ) ); } QStringList sortedAllFilesWithSidecars( qgis::setToList( allFilesWithSidecars ) ); - std::sort( sortedAllFilesWithSidecars.begin(), sortedAllFilesWithSidecars.end(), []( const QString & a, const QString & b ) - { + std::sort( sortedAllFilesWithSidecars.begin(), sortedAllFilesWithSidecars.end(), []( const QString &a, const QString &b ) { return a.compare( b, Qt::CaseInsensitive ) < 0; } ); @@ -724,10 +692,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m if ( layersList.empty() ) { // generic warning - QMessageBox message( QMessageBox::Warning, sortedAllFilesWithSidecars.size() > 1 ? tr( "Delete Files" ) : tr( "Delete %1" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), - sortedAllFilesWithSidecars.size() > 1 ? tr( "Permanently delete %n file(s)?", nullptr, sortedAllFilesWithSidecars.size() ) - : tr( "Permanently delete “%1”?" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), - QMessageBox::Yes | QMessageBox::No ); + QMessageBox message( QMessageBox::Warning, sortedAllFilesWithSidecars.size() > 1 ? tr( "Delete Files" ) : tr( "Delete %1" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), sortedAllFilesWithSidecars.size() > 1 ? tr( "Permanently delete %n file(s)?", nullptr, sortedAllFilesWithSidecars.size() ) : tr( "Permanently delete “%1”?" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), QMessageBox::Yes | QMessageBox::No ); message.setDefaultButton( QMessageBox::No ); if ( sortedAllFilesWithSidecars.size() > 1 ) @@ -747,10 +712,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m } else { - QMessageBox message( QMessageBox::Warning, sortedAllFilesWithSidecars.size() > 1 ? tr( "Delete Files" ) : tr( "Delete %1" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), - sortedAllFilesWithSidecars.size() > 1 ? tr( "One or more selected files exist in the current project. Are you sure you want to delete these files?" ) - : tr( "The file %1 exists in the current project. Are you sure you want to delete it?" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), - QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel ); + QMessageBox message( QMessageBox::Warning, sortedAllFilesWithSidecars.size() > 1 ? tr( "Delete Files" ) : tr( "Delete %1" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), sortedAllFilesWithSidecars.size() > 1 ? tr( "One or more selected files exist in the current project. Are you sure you want to delete these files?" ) : tr( "The file %1 exists in the current project. Are you sure you want to delete it?" ).arg( QFileInfo( selectedFiles.at( 0 ) ).fileName() ), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel ); message.setDefaultButton( QMessageBox::Cancel ); message.setButtonText( QMessageBox::Yes, tr( "Delete and Remove Layers" ) ); message.setButtonText( QMessageBox::No, tr( "Delete and Retain Layers" ) ); @@ -802,7 +764,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m } } - for ( const QPointer< QgsDataItem > &parent : selectedParents ) + for ( const QPointer &parent : selectedParents ) { if ( parent ) parent->refresh(); @@ -846,14 +808,12 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m menu->addSeparator(); QAction *showInFilesAction = menu->addAction( tr( "Show in Files" ) ); - connect( showInFilesAction, &QAction::triggered, this, [ = ] - { + connect( showInFilesAction, &QAction::triggered, this, [=] { QgsGui::nativePlatformInterface()->openFileExplorerAndSelectFile( item->path() ); } ); QAction *filePropertiesAction = menu->addAction( tr( "File Properties…" ) ); - connect( filePropertiesAction, &QAction::triggered, this, [ = ] - { + connect( filePropertiesAction, &QAction::triggered, this, [=] { QgsGui::nativePlatformInterface()->showFileProperties( item->path() ); } ); } @@ -864,7 +824,7 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m int QgsAppFileItemGuiProvider::precedenceWhenPopulatingMenus() const { // we want this provider to be called last -- file items should naturally always appear at the bottom of the menu. - return std::numeric_limits< int >::max(); + return std::numeric_limits::max(); } bool QgsAppFileItemGuiProvider::rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context ) @@ -893,7 +853,7 @@ bool QgsAppFileItemGuiProvider::rename( QgsDataItem *item, const QString &name, return rename( oldPath, newName, context, { item->parent() } ); } -bool QgsAppFileItemGuiProvider::rename( const QString &oldPath, const QString &newName, QgsDataItemGuiContext context, const QList > &parentItems ) +bool QgsAppFileItemGuiProvider::rename( const QString &oldPath, const QString &newName, QgsDataItemGuiContext context, const QList> &parentItems ) { // Check if the file corresponds to paths in the project const QList layersList = QgsProjectUtils::layersMatchingPath( QgsProject::instance(), oldPath ); @@ -903,9 +863,7 @@ bool QgsAppFileItemGuiProvider::rename( const QString &oldPath, const QString &n bool updateLayers = false; if ( !layersList.empty() ) { - QMessageBox message( QMessageBox::Warning, tr( "Rename %1" ).arg( QFileInfo( oldPath ).fileName() ), - tr( "The file %1 exists in the current project. Are you sure you want to rename it?" ).arg( QFileInfo( oldPath ).fileName() ), - QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel ); + QMessageBox message( QMessageBox::Warning, tr( "Rename %1" ).arg( QFileInfo( oldPath ).fileName() ), tr( "The file %1 exists in the current project. Are you sure you want to rename it?" ).arg( QFileInfo( oldPath ).fileName() ), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel ); message.setDefaultButton( QMessageBox::Cancel ); message.setButtonText( QMessageBox::Yes, tr( "Rename and Update Layer Paths" ) ); message.setButtonText( QMessageBox::No, tr( "Rename but Leave Layer Paths" ) ); @@ -930,7 +888,7 @@ bool QgsAppFileItemGuiProvider::rename( const QString &oldPath, const QString &n QString error; const bool result = QgsFileUtils::renameDataset( oldPath, newPath, error ); - for ( const QPointer< QgsDataItem > &parentItem : parentItems ) + for ( const QPointer &parentItem : parentItems ) { if ( parentItem ) parentItem->refresh(); @@ -972,15 +930,14 @@ QString QgsProjectHomeItemGuiProvider::name() void QgsProjectHomeItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &, QgsDataItemGuiContext ) { - if ( !qobject_cast< QgsProjectHomeItem * >( item ) ) + if ( !qobject_cast( item ) ) return; if ( !menu->actions().empty() ) menu->insertSeparator( menu->actions().at( 0 ) ); QAction *setHome = new QAction( tr( "Set Project Home…" ), menu ); - connect( setHome, &QAction::triggered, this, [ = ] - { + connect( setHome, &QAction::triggered, this, [=] { QString oldHome = QgsProject::instance()->homePath(); QString newPath = QFileDialog::getExistingDirectory( QgisApp::instance(), tr( "Select Project Home Directory" ), oldHome ); if ( !newPath.isEmpty() ) @@ -1011,8 +968,7 @@ void QgsFavoritesItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu return; QAction *addAction = new QAction( tr( "Add a Directory…" ), menu ); - connect( addAction, &QAction::triggered, this, [ = ] - { + connect( addAction, &QAction::triggered, this, [=] { QString directory = QFileDialog::getExistingDirectory( QgisApp::instance(), tr( "Add Directory to Favorites" ) ); if ( !directory.isEmpty() ) { @@ -1037,8 +993,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men return; QgsLayerItem *layerItem = qobject_cast( item ); - if ( layerItem && ( layerItem->mapLayerType() == Qgis::LayerType::Vector || - layerItem->mapLayerType() == Qgis::LayerType::Raster ) ) + if ( layerItem && ( layerItem->mapLayerType() == Qgis::LayerType::Vector || layerItem->mapLayerType() == Qgis::LayerType::Raster ) ) { QMenu *exportMenu = new QMenu( tr( "Export Layer" ), menu ); @@ -1060,8 +1015,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men QAction *toFileAction = new QAction( tr( "To File…" ), exportMenu ); exportMenu->addAction( toFileAction ); - connect( toFileAction, &QAction::triggered, layerItem, [ layerItem ] - { + connect( toFileAction, &QAction::triggered, layerItem, [layerItem] { switch ( layerItem->mapLayerType() ) { case Qgis::LayerType::Vector: @@ -1107,10 +1061,9 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men } const QString deleteText = selectedDeletableItemPaths.count() == 1 ? tr( "Delete Layer “%1”…" ).arg( layerItem->name() ) - : tr( "Delete Selected Layers…" ); + : tr( "Delete Selected Layers…" ); QAction *deleteAction = new QAction( deleteText, menu ); - connect( deleteAction, &QAction::triggered, this, [ = ] - { + connect( deleteAction, &QAction::triggered, this, [=] { deleteLayers( selectedDeletableItemPaths, context ); } ); @@ -1138,10 +1091,9 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men menu->addSeparator(); const QString addText = selectedItems.count() == 1 ? tr( "Add Layer to Project" ) - : tr( "Add Selected Layers to Project" ); + : tr( "Add Selected Layers to Project" ); QAction *addAction = new QAction( addText, menu ); - connect( addAction, &QAction::triggered, this, [ = ] - { + connect( addAction, &QAction::triggered, this, [=] { addLayersFromItems( selectedItems ); } ); menu->addAction( addAction ); @@ -1163,8 +1115,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men } QAction *propertiesAction = new QAction( tr( "Layer Properties…" ), menu ); - connect( propertiesAction, &QAction::triggered, this, [ = ] - { + connect( propertiesAction, &QAction::triggered, this, [=] { showPropertiesForItem( layerItem, context ); } ); menu->addAction( propertiesAction ); @@ -1173,7 +1124,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men int QgsLayerItemGuiProvider::precedenceWhenPopulatingMenus() const { // we want this provider to be called second last (last place is reserved for QgsAppFileItemGuiProvider) - return std::numeric_limits< int >::max() - 1; + return std::numeric_limits::max() - 1; } bool QgsLayerItemGuiProvider::handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext ) @@ -1264,7 +1215,7 @@ void QgsLayerItemGuiProvider::deleteLayers( const QStringList &itemPaths, QgsDat void QgsLayerItemGuiProvider::showPropertiesForItem( QgsLayerItem *item, QgsDataItemGuiContext context ) { - if ( ! item ) + if ( !item ) return; QgsBrowserPropertiesDialog *dialog = new QgsBrowserPropertiesDialog( QStringLiteral( "browser" ), QgisApp::instance() ); @@ -1291,15 +1242,13 @@ void QgsProjectItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m { QAction *openAction = new QAction( tr( "Open Project" ), menu ); const QString projectPath = projectItem->path(); - connect( openAction, &QAction::triggered, this, [projectPath] - { + connect( openAction, &QAction::triggered, this, [projectPath] { QgisApp::instance()->openProject( projectPath ); } ); menu->addAction( openAction ); QAction *extractAction = new QAction( tr( "Extract Symbols…" ), menu ); - connect( extractAction, &QAction::triggered, this, [projectPath, context] - { + connect( extractAction, &QAction::triggered, this, [projectPath, context] { QgsStyle style; style.createMemoryDatabase(); @@ -1366,11 +1315,10 @@ void QgsFieldsItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *me if ( conn && conn->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::AddField ) ) { QAction *addColumnAction = new QAction( tr( "Add New Field…" ), menu ); - QPointeritemPtr { item }; - const QSet< QString > illegalFieldNames = conn->illegalFieldNames(); + QPointer itemPtr { item }; + const QSet illegalFieldNames = conn->illegalFieldNames(); - connect( addColumnAction, &QAction::triggered, fieldsItem, [ md, fieldsItem, context, itemPtr, menu, illegalFieldNames ] - { + connect( addColumnAction, &QAction::triggered, fieldsItem, [md, fieldsItem, context, itemPtr, menu, illegalFieldNames] { std::unique_ptr layer { fieldsItem->layer() }; if ( layer ) { @@ -1429,7 +1377,7 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men if ( QgsFieldItem *fieldItem = qobject_cast( item ) ) { // Retrieve the connection from the parent - QPointer< QgsFieldsItem > fieldsItem { qobject_cast( fieldItem->parent() ) }; + QPointer fieldsItem { qobject_cast( fieldItem->parent() ) }; if ( fieldsItem ) { const QString connectionUri = fieldsItem->connectionUri(); @@ -1468,11 +1416,8 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men setDomainAction->setChecked( true ); } - connect( setDomainAction, &QAction::triggered, this, [connectionUri, providerKey, schema, tableName, fieldName, domain, context, fieldsItem] - { - if ( QMessageBox::question( nullptr, tr( "Set Field Domain" ), - tr( "Set field domain for %1 to %2?" ).arg( fieldName, domain ), - QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + connect( setDomainAction, &QAction::triggered, this, [connectionUri, providerKey, schema, tableName, fieldName, domain, context, fieldsItem] { + if ( QMessageBox::question( nullptr, tr( "Set Field Domain" ), tr( "Set field domain for %1 to %2?" ).arg( fieldName, domain ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { QgsProviderMetadata *md { QgsProviderRegistry::instance()->providerMetadata( providerKey ) }; std::unique_ptr conn2 { static_cast( md->createConnection( connectionUri, {} ) ) }; @@ -1496,11 +1441,8 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men QAction *clearDomainAction = new QAction( tr( "Unset Field Domain (%1)…" ).arg( domainName ), menu ); menu->addAction( clearDomainAction ); - connect( clearDomainAction, &QAction::triggered, this, [connectionUri, providerKey, schema, tableName, fieldName, domainName, context, fieldsItem] - { - if ( QMessageBox::question( nullptr, tr( "Unset Field Domain" ), - tr( "Unset %1 field domain from %2?" ).arg( domainName, fieldName ), - QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + connect( clearDomainAction, &QAction::triggered, this, [connectionUri, providerKey, schema, tableName, fieldName, domainName, context, fieldsItem] { + if ( QMessageBox::question( nullptr, tr( "Unset Field Domain" ), tr( "Unset %1 field domain from %2?" ).arg( domainName, fieldName ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { QgsProviderMetadata *md { QgsProviderRegistry::instance()->providerMetadata( providerKey ) }; std::unique_ptr conn2 { static_cast( md->createConnection( connectionUri, {} ) ) }; @@ -1523,8 +1465,7 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men QAction *renameFieldAction = new QAction( tr( "Rename Field…" ), menu ); const QString itemName { item->name() }; - connect( renameFieldAction, &QAction::triggered, fieldsItem, [ md, fieldsItem, itemName, context ] - { + connect( renameFieldAction, &QAction::triggered, fieldsItem, [md, fieldsItem, itemName, context] { // Confirmation dialog QgsNewNameDialog dlg( tr( "field “%1”" ).arg( itemName ), itemName ); dlg.setWindowTitle( tr( "Rename Field" ) ); @@ -1551,8 +1492,7 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men QAction *setAliasAction = new QAction( tr( "Set Alias…" ), menu ); const QString itemName { item->name() }; - connect( setAliasAction, &QAction::triggered, fieldsItem, [ md, fieldsItem, itemName, alias, context ] - { + connect( setAliasAction, &QAction::triggered, fieldsItem, [md, fieldsItem, itemName, alias, context] { bool ok = false; const QString newAlias = QInputDialog::getText( QgisApp::instance(), tr( "Set Alias For %1" ).arg( itemName ), tr( "Alias" ), QLineEdit::Normal, alias, &ok ); @@ -1579,8 +1519,7 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men QAction *setCommentAction = new QAction( tr( "Set Comment…" ), menu ); const QString itemName { item->name() }; - connect( setCommentAction, &QAction::triggered, fieldsItem, [ md, fieldsItem, itemName, comment, context ] - { + connect( setCommentAction, &QAction::triggered, fieldsItem, [md, fieldsItem, itemName, comment, context] { bool ok = false; const QString newComment = QInputDialog::getText( QgisApp::instance(), tr( "Set Comment For %1" ).arg( itemName ), tr( "Comment" ), QLineEdit::Normal, comment, &ok ); @@ -1608,10 +1547,9 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men const bool supportsCascade { conn->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::DeleteFieldCascade ) }; const QString itemName { item->name() }; - connect( deleteFieldAction, &QAction::triggered, fieldsItem, [ md, fieldsItem, itemName, context, supportsCascade ] - { + connect( deleteFieldAction, &QAction::triggered, fieldsItem, [md, fieldsItem, itemName, context, supportsCascade] { // Confirmation dialog - QString message { tr( "Delete '%1' permanently?" ).arg( itemName ) }; + QString message { tr( "Delete '%1' permanently?" ).arg( itemName ) }; if ( fieldsItem->tableProperty() && fieldsItem->tableProperty()->primaryKeyColumns().contains( itemName ) ) { message.append( tr( "\nThis field is part of a primary key, its removal may make the table unusable by QGIS!" ) ); @@ -1620,12 +1558,12 @@ void QgsFieldItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men { message.append( tr( "\nThis field is a geometry column, its removal may make the table unusable by QGIS!" ) ); } - QMessageBox msgbox{QMessageBox::Icon::Question, tr( "Delete Field" ), message, QMessageBox::Ok | QMessageBox::Cancel }; + QMessageBox msgbox { QMessageBox::Icon::Question, tr( "Delete Field" ), message, QMessageBox::Ok | QMessageBox::Cancel }; QCheckBox *cb = new QCheckBox( tr( "Delete all related objects (CASCADE)?" ) ); msgbox.setCheckBox( cb ); msgbox.setDefaultButton( QMessageBox::Cancel ); - if ( ! supportsCascade ) + if ( !supportsCascade ) { cb->hide(); } @@ -1663,7 +1601,7 @@ bool QgsFieldItemGuiProvider::rename( QgsDataItem *item, const QString &name, Qg { if ( QgsFieldItem *fieldItem = qobject_cast( item ) ) { - QPointer< QgsFieldsItem > fieldsItem { qobject_cast( fieldItem->parent() ) }; + QPointer fieldsItem { qobject_cast( fieldItem->parent() ) }; if ( fieldsItem ) { const QString connectionUri = fieldsItem->connectionUri(); @@ -1710,7 +1648,7 @@ QWidget *QgsFieldItemGuiProvider::createParamWidget( QgsDataItem *item, QgsDataI QgsDatabaseItemGuiProvider::QgsDatabaseItemGuiProvider() { - if ( QgsDatabaseQueryHistoryProvider *historyProvider = qobject_cast< QgsDatabaseQueryHistoryProvider * >( QgsGui::historyProviderRegistry()->providerById( QStringLiteral( "dbquery" ) ) ) ) + if ( QgsDatabaseQueryHistoryProvider *historyProvider = qobject_cast( QgsGui::historyProviderRegistry()->providerById( QStringLiteral( "dbquery" ) ) ) ) { connect( historyProvider, &QgsDatabaseQueryHistoryProvider::openSqlDialog, this, &QgsDatabaseItemGuiProvider::openSqlDialogGeneric ); } @@ -1726,7 +1664,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * Q_UNUSED( selectedItems ) // Add create new table for collection items but not not if it is a root item - if ( ! qobject_cast( item ) ) + if ( !qobject_cast( item ) ) { std::unique_ptr conn( item->databaseConnection() ); @@ -1734,11 +1672,10 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * { QAction *newTableAction = new QAction( QObject::tr( "New Table…" ), menu ); - QObject::connect( newTableAction, &QAction::triggered, item, [ item, context] - { + QObject::connect( newTableAction, &QAction::triggered, item, [item, context] { std::unique_ptr conn2( item->databaseConnection() ); // This should never happen but let's play safe - if ( ! conn2 ) + if ( !conn2 ) { QgsMessageLog::logMessage( tr( "Connection to the database (%1) was lost." ).arg( item->name() ) ); return; @@ -1747,7 +1684,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * QgsNewVectorTableDialog dlg { conn2.get(), nullptr }; dlg.setCrs( QgsProject::instance()->defaultCrsForNewLayers() ); - const bool isSchema { static_cast< bool >( qobject_cast( item ) ) }; + const bool isSchema { static_cast( qobject_cast( item ) ) }; if ( isSchema ) { @@ -1761,19 +1698,16 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * const QString schemaName { dlg.schemaName() }; const QString geometryColumn { dlg.geometryColumnName() }; const Qgis::WkbType geometryType { dlg.geometryType() }; - const bool createSpatialIndex = dlg.createSpatialIndex() && - geometryType != Qgis::WkbType::NoGeometry && - geometryType != Qgis::WkbType::Unknown; - const QgsCoordinateReferenceSystem crs { dlg.crs( ) }; + const bool createSpatialIndex = dlg.createSpatialIndex() && geometryType != Qgis::WkbType::NoGeometry && geometryType != Qgis::WkbType::Unknown; + const QgsCoordinateReferenceSystem crs { dlg.crs() }; // This flag tells to the provider that field types do not need conversion // also prevents GDAL to create a spatial index by default for GPKG, we are // going to create it afterwards in a unified manner for all providers. - QMap options { { QStringLiteral( "skipConvertFields" ), true }, - { QStringLiteral( "layerOptions" ), QStringLiteral( "SPATIAL_INDEX=NO" ) } }; + QMap options { { QStringLiteral( "skipConvertFields" ), true }, { QStringLiteral( "layerOptions" ), QStringLiteral( "SPATIAL_INDEX=NO" ) } }; - if ( ! geometryColumn.isEmpty() ) + if ( !geometryColumn.isEmpty() ) { - options[ QStringLiteral( "geometryColumn" ) ] = geometryColumn; + options[QStringLiteral( "geometryColumn" )] = geometryColumn; } try @@ -1795,7 +1729,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * // So, we check if the item is a schema or not, if it's not it means we initiated the new table from // the parent connection item, hence we search for the schema item and refresh it instead of refreshing // the connection item (the parent) with no effects. - if ( ! isSchema && conn2->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::Schemas ) ) + if ( !isSchema && conn2->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::Schemas ) ) { const auto constChildren { item->children() }; for ( const auto &c : constChildren ) @@ -1808,7 +1742,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * } else { - item->refresh( ); + item->refresh(); } notify( QObject::tr( "New Table Created" ), QObject::tr( "Table '%1' was created successfully." ).arg( tableName ), context, Qgis::MessageLevel::Success ); } @@ -1816,7 +1750,6 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * { notify( QObject::tr( "New Table Creation Error" ), QObject::tr( "Error creating new table '%1': %2" ).arg( tableName, ex.what() ), context, Qgis::MessageLevel::Critical ); } - } } ); menu->addAction( newTableAction ); @@ -1835,7 +1768,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * QString tableName; if ( qobject_cast( item ) ) { - if ( QgsProviderSublayerItem *sublayerItem = qobject_cast< QgsProviderSublayerItem * >( item ) ) + if ( QgsProviderSublayerItem *sublayerItem = qobject_cast( item ) ) { tableName = sublayerItem->sublayerDetails().name(); } @@ -1847,8 +1780,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * itemParentName = item->parent()->name(); } - QObject::connect( sqlAction, &QAction::triggered, item, [ connectionUri, providerKey, itemName, tableName, itemParentName, context, this ] - { + QObject::connect( sqlAction, &QAction::triggered, item, [connectionUri, providerKey, itemName, tableName, itemParentName, context, this] { QgsProviderMetadata *md { QgsProviderRegistry::instance()->providerMetadata( providerKey ) }; if ( !md ) return; @@ -1856,7 +1788,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * std::unique_ptr conn2( qgis::down_cast( md->createConnection( connectionUri, QVariantMap() ) ) ); // This should never happen but let's play safe - if ( ! conn2 ) + if ( !conn2 ) { QgsMessageLog::logMessage( tr( "Connection to the database (%1) was lost." ).arg( itemName ) ); return; @@ -1868,10 +1800,11 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * if ( !itemParentName.isEmpty() ) { - std::unique_ptr< QgsProviderSqlQueryBuilder > queryBuilder( conn2->queryBuilder() ); + std::unique_ptr queryBuilder( conn2->queryBuilder() ); sql = queryBuilder->createLimitQueryForTable( - conn2->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::Schemas ) ? itemParentName : QString(), - tableName, 10 ); + conn2->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::Schemas ) ? itemParentName : QString(), + tableName, 10 + ); } openSqlDialog( connectionUri, providerKey, sql, context, itemName ); @@ -1888,8 +1821,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu * const QString connectionUri = conn->uri(); const QString providerKey = conn->providerKey(); - connect( compactAction, &QAction::triggered, compactAction, [context, connectionUri, providerKey] - { + connect( compactAction, &QAction::triggered, compactAction, [context, connectionUri, providerKey] { QgsProviderMetadata *md { QgsProviderRegistry::instance()->providerMetadata( providerKey ) }; if ( !md ) return; @@ -1932,11 +1864,11 @@ bool QgsDatabaseItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiCo // BROWSER IS BEING POPULATED // We are limited to VERY VERY cheap calculations only!! // DO NOT UNDER *****ANY***** CIRCUMSTANCES OPEN DATASETS HERE!!!! - QgsFileDataCollectionItem *fileDataCollectionItem = qobject_cast< QgsFileDataCollectionItem * >( item ); + QgsFileDataCollectionItem *fileDataCollectionItem = qobject_cast( item ); if ( !fileDataCollectionItem ) return false; - if ( qobject_cast< QgsGeoPackageCollectionItem * >( item ) ) + if ( qobject_cast( item ) ) return false; // GPKG is handled elsewhere (QgsGeoPackageItemGuiProvider) if ( fileDataCollectionItem->canAddVectorLayers() ) @@ -1953,10 +1885,10 @@ bool QgsDatabaseItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiCo bool QgsDatabaseItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiContext context, const QMimeData *data, Qt::DropAction ) { - if ( !qobject_cast< QgsFileDataCollectionItem * >( item ) ) + if ( !qobject_cast( item ) ) return false; - if ( qobject_cast< QgsGeoPackageCollectionItem * >( item ) ) + if ( qobject_cast( item ) ) return false; // GPKG is handled elsewhere (QgsGeoPackageItemGuiProvider) if ( !QgsMimeDataUtils::isUriList( data ) ) @@ -1968,7 +1900,7 @@ bool QgsDatabaseItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiCo bool hasError = false; // Main task - std::unique_ptr< QgsTaskWithSerialSubTasks > mainTask( new QgsTaskWithSerialSubTasks( tr( "Layer import" ) ) ); + std::unique_ptr mainTask( new QgsTaskWithSerialSubTasks( tr( "Layer import" ) ) ); bool hasSubTasks = false; const QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data ); @@ -2010,7 +1942,7 @@ bool QgsDatabaseItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiCo // check if the destination layer already exists bool exists = false; - const QVector< QgsDataItem * > c( item->children() ); + const QVector c( item->children() ); for ( const QgsDataItem *child : c ) { if ( child->name() == dropUri.name ) @@ -2019,10 +1951,9 @@ bool QgsDatabaseItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiCo } } - if ( ! exists || QMessageBox::question( nullptr, tr( "Overwrite Layer" ), - tr( "Destination layer %1 already exists. Do you want to overwrite it?" ).arg( dropUri.name ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + if ( !exists || QMessageBox::question( nullptr, tr( "Overwrite Layer" ), tr( "Destination layer %1 already exists. Do you want to overwrite it?" ).arg( dropUri.name ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { - QgsVectorLayer *vectorSrcLayer = qobject_cast < QgsVectorLayer * >( srcLayer ); + QgsVectorLayer *vectorSrcLayer = qobject_cast( srcLayer ); QVariantMap options; // options.insert( QStringLiteral( "driverName" ), QStringLiteral( "GPKG" ) ); options.insert( QStringLiteral( "update" ), true ); @@ -2032,15 +1963,13 @@ bool QgsDatabaseItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiCo mainTask->addSubTask( exportTask ); hasSubTasks = true; // when export is successful: - connect( exportTask, &QgsVectorLayerExporterTask::exportComplete, item, [ = ]() - { + connect( exportTask, &QgsVectorLayerExporterTask::exportComplete, item, [=]() { notify( tr( "Import to database" ), tr( "Import was successful." ), context, Qgis::MessageLevel::Success ); item->refresh(); } ); // when an error occurs: - connect( exportTask, &QgsVectorLayerExporterTask::errorOccurred, item, [ = ]( Qgis::VectorExportResult error, const QString & errorMessage ) - { + connect( exportTask, &QgsVectorLayerExporterTask::errorOccurred, item, [=]( Qgis::VectorExportResult error, const QString &errorMessage ) { if ( error != Qgis::VectorExportResult::UserCanceled ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); @@ -2098,8 +2027,7 @@ void QgsDatabaseItemGuiProvider::openSqlDialog( const QString &connectionUri, co widget->setQuery( query ); dialog->setCentralWidget( widget ); - connect( widget, &QgsQueryResultWidget::createSqlVectorLayer, widget, [ provider, connectionUri, context ]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions & options ) - { + connect( widget, &QgsQueryResultWidget::createSqlVectorLayer, widget, [provider, connectionUri, context]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options ) { QgsProviderMetadata *md { QgsProviderRegistry::instance()->providerMetadata( provider ) }; if ( !md ) return; @@ -2117,7 +2045,6 @@ void QgsDatabaseItemGuiProvider::openSqlDialog( const QString &connectionUri, co { notify( QObject::tr( "New SQL Layer Creation Error" ), QObject::tr( "Error creating new SQL layer: %1" ).arg( ex.what() ), context, Qgis::MessageLevel::Critical ); } - } ); dialog->show(); } @@ -2142,24 +2069,24 @@ QString QgsFieldDomainItemGuiProvider::name() void QgsFieldDomainItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &, QgsDataItemGuiContext context ) { - if ( qobject_cast< QgsFieldDomainsItem * >( item ) - || qobject_cast< QgsGeoPackageCollectionItem * >( item ) - || qobject_cast< QgsFileDataCollectionItem * >( item ) ) + if ( qobject_cast( item ) + || qobject_cast( item ) + || qobject_cast( item ) ) { QString providerKey; QString connectionUri; - if ( QgsFieldDomainsItem *fieldDomainsItem = qobject_cast< QgsFieldDomainsItem * >( item ) ) + if ( QgsFieldDomainsItem *fieldDomainsItem = qobject_cast( item ) ) { providerKey = fieldDomainsItem->providerKey(); connectionUri = fieldDomainsItem->connectionUri(); } - else if ( QgsGeoPackageCollectionItem *gpkgItem = qobject_cast< QgsGeoPackageCollectionItem * >( item ) ) + else if ( QgsGeoPackageCollectionItem *gpkgItem = qobject_cast( item ) ) { providerKey = QStringLiteral( "ogr" ); connectionUri = gpkgItem->path().remove( QStringLiteral( "gpkg:/" ) ); } - else if ( QgsFileDataCollectionItem *fileItem = qobject_cast< QgsFileDataCollectionItem * >( item ) ) + else if ( QgsFileDataCollectionItem *fileItem = qobject_cast( item ) ) { providerKey = QStringLiteral( "ogr" ); connectionUri = fileItem->path(); @@ -2175,15 +2102,14 @@ void QgsFieldDomainItemGuiProvider::populateContextMenu( QgsDataItem *item, QMen QMenu *createFieldDomainMenu = new QMenu( tr( "New Field Domain" ), menu ); menu->addMenu( createFieldDomainMenu ); - QPointer< QgsDataItem > itemWeakPointer( item ); + QPointer itemWeakPointer( item ); - auto createDomain = [context, itemWeakPointer, md, connectionUri]( Qgis::FieldDomainType type ) - { + auto createDomain = [context, itemWeakPointer, md, connectionUri]( Qgis::FieldDomainType type ) { QgsFieldDomainDialog dialog( type, QgisApp::instance() ); dialog.setWindowTitle( tr( "New Field Domain" ) ); if ( dialog.exec() ) { - std::unique_ptr< QgsFieldDomain > newDomain( dialog.createFieldDomain() ); + std::unique_ptr newDomain( dialog.createFieldDomain() ); std::unique_ptr conn { static_cast( md->createConnection( connectionUri, {} ) ) }; try { @@ -2201,14 +2127,13 @@ void QgsFieldDomainItemGuiProvider::populateContextMenu( QgsDataItem *item, QMen } }; - const QList< Qgis::FieldDomainType > supportedDomainTypes = conn->supportedFieldDomainTypes(); + const QList supportedDomainTypes = conn->supportedFieldDomainTypes(); if ( supportedDomainTypes.contains( Qgis::FieldDomainType::Range ) ) { QAction *rangeDomainAction = new QAction( QObject::tr( "New Range Domain…" ) ); createFieldDomainMenu->addAction( rangeDomainAction ); - connect( rangeDomainAction, &QAction::triggered, this, [ = ] - { + connect( rangeDomainAction, &QAction::triggered, this, [=] { createDomain( Qgis::FieldDomainType::Range ); } ); } @@ -2217,8 +2142,7 @@ void QgsFieldDomainItemGuiProvider::populateContextMenu( QgsDataItem *item, QMen { QAction *codedDomainAction = new QAction( QObject::tr( "New Coded Values Domain…" ) ); createFieldDomainMenu->addAction( codedDomainAction ); - connect( codedDomainAction, &QAction::triggered, this, [ = ] - { + connect( codedDomainAction, &QAction::triggered, this, [=] { createDomain( Qgis::FieldDomainType::Coded ); } ); } @@ -2227,8 +2151,7 @@ void QgsFieldDomainItemGuiProvider::populateContextMenu( QgsDataItem *item, QMen { QAction *globDomainAction = new QAction( QObject::tr( "New Glob Domain…" ) ); createFieldDomainMenu->addAction( globDomainAction ); - connect( globDomainAction, &QAction::triggered, this, [ = ] - { + connect( globDomainAction, &QAction::triggered, this, [=] { createDomain( Qgis::FieldDomainType::Glob ); } ); } @@ -2239,12 +2162,12 @@ void QgsFieldDomainItemGuiProvider::populateContextMenu( QgsDataItem *item, QMen QWidget *QgsFieldDomainItemGuiProvider::createParamWidget( QgsDataItem *item, QgsDataItemGuiContext ) { - if ( QgsFieldDomainItem *fieldDomainItem = qobject_cast< QgsFieldDomainItem * >( item ) ) + if ( QgsFieldDomainItem *fieldDomainItem = qobject_cast( item ) ) { const QgsFieldDomain *domain = fieldDomainItem->fieldDomain(); return new QgsFieldDomainDetailsWidget( nullptr, domain ); } - else if ( QgsFieldDomainsItem *fieldDomainsItem = qobject_cast< QgsFieldDomainsItem * >( item ) ) + else if ( QgsFieldDomainsItem *fieldDomainsItem = qobject_cast( item ) ) { return new QgsFieldDomainsDetailsWidget( nullptr, fieldDomainsItem->providerKey(), fieldDomainsItem->connectionUri() ); } @@ -2298,13 +2221,13 @@ QString QgsFieldDomainDetailsWidget::htmlMetadata( QgsFieldDomain *domain, const metadata += tr( "Use default field value" ); break; case Qgis::FieldDomainSplitPolicy::Duplicate: - metadata += tr( "Duplicate field value" ); + metadata += tr( "Duplicate field value" ); break; case Qgis::FieldDomainSplitPolicy::GeometryRatio: - metadata += tr( "Use geometry ratio" ); + metadata += tr( "Use geometry ratio" ); break; case Qgis::FieldDomainSplitPolicy::UnsetField: - metadata += tr( "Unset field" ); + metadata += tr( "Unset field" ); break; } metadata += QLatin1String( "\n" ); @@ -2313,13 +2236,13 @@ QString QgsFieldDomainDetailsWidget::htmlMetadata( QgsFieldDomain *domain, const switch ( domain->mergePolicy() ) { case Qgis::FieldDomainMergePolicy::DefaultValue: - metadata += tr( "Use default field value" ); + metadata += tr( "Use default field value" ); break; case Qgis::FieldDomainMergePolicy::Sum: - metadata += tr( "Sum field values" ); + metadata += tr( "Sum field values" ); break; case Qgis::FieldDomainMergePolicy::GeometryWeighted: - metadata += tr( "Use geometry weighted value" ); + metadata += tr( "Use geometry weighted value" ); break; } @@ -2332,8 +2255,8 @@ QString QgsFieldDomainDetailsWidget::htmlMetadata( QgsFieldDomain *domain, const metadata += QStringLiteral( "

" ) + tr( "Coded values" ) + QStringLiteral( "

\n
\n" ); metadata += QLatin1String( "\n" ); - const QgsCodedFieldDomain *codedDomain = qgis::down_cast< QgsCodedFieldDomain *>( domain ); - const QList< QgsCodedValue > values = codedDomain->values(); + const QgsCodedFieldDomain *codedDomain = qgis::down_cast( domain ); + const QList values = codedDomain->values(); for ( const QgsCodedValue &value : values ) { metadata += QStringLiteral( "\n" ); @@ -2344,19 +2267,17 @@ QString QgsFieldDomainDetailsWidget::htmlMetadata( QgsFieldDomain *domain, const case Qgis::FieldDomainType::Range: { - const QgsRangeFieldDomain *rangeDomain = qgis::down_cast< QgsRangeFieldDomain *>( domain ); + const QgsRangeFieldDomain *rangeDomain = qgis::down_cast( domain ); metadata += QStringLiteral( "

" ) + tr( "Range" ) + QStringLiteral( "

\n
\n" ); metadata += QLatin1String( "
" ) + value.code().toString() + QStringLiteral( "" ) + value.value() + QStringLiteral( "
\n" ); metadata += QStringLiteral( "\n" ); metadata += QStringLiteral( "\n" ); metadata += QLatin1String( "
" ) + tr( "Minimum" ) + QStringLiteral( "" ) - + QStringLiteral( "%1 %2" ).arg( rangeDomain->minimum().toString(), - rangeDomain->minimumIsInclusive() ? tr( "(inclusive)" ) : tr( "(exclusive)" ) ) + + QStringLiteral( "%1 %2" ).arg( rangeDomain->minimum().toString(), rangeDomain->minimumIsInclusive() ? tr( "(inclusive)" ) : tr( "(exclusive)" ) ) + QStringLiteral( "
" ) + tr( "Maximum" ) + QStringLiteral( "" ) - + QStringLiteral( "%1 %2" ).arg( rangeDomain->maximum().toString(), - rangeDomain->maximumIsInclusive() ? tr( "(inclusive)" ) : tr( "(exclusive)" ) ) + + QStringLiteral( "%1 %2" ).arg( rangeDomain->maximum().toString(), rangeDomain->maximumIsInclusive() ? tr( "(inclusive)" ) : tr( "(exclusive)" ) ) + QStringLiteral( "
\n

\n" ); @@ -2365,7 +2286,7 @@ QString QgsFieldDomainDetailsWidget::htmlMetadata( QgsFieldDomain *domain, const case Qgis::FieldDomainType::Glob: { - const QgsGlobFieldDomain *globDomain = qgis::down_cast< QgsGlobFieldDomain *>( domain ); + const QgsGlobFieldDomain *globDomain = qgis::down_cast( domain ); metadata += QStringLiteral( "

" ) + tr( "Glob" ) + QStringLiteral( "

\n
\n" ); metadata += QLatin1String( "\n" ); @@ -2375,7 +2296,6 @@ QString QgsFieldDomainDetailsWidget::htmlMetadata( QgsFieldDomain *domain, const metadata += QLatin1String( "
\n

\n" ); break; } - } return metadata; } @@ -2420,7 +2340,7 @@ QgsFieldDomainsDetailsWidget::QgsFieldDomainsDetailsWidget( QWidget *parent, con { try { - std::unique_ptr< QgsFieldDomain > domain( conn->fieldDomain( name ) ); + std::unique_ptr domain( conn->fieldDomain( name ) ); if ( domain ) { metadata += QStringLiteral( "" ) + domain->name() + QStringLiteral( "" ) + domain->typeName() @@ -2452,9 +2372,6 @@ QgsFieldDomainsDetailsWidget::QgsFieldDomainsDetailsWidget( QWidget *parent, con } - - - // // QgsRelationshipItemGuiProvider // @@ -2466,9 +2383,9 @@ QString QgsRelationshipItemGuiProvider::name() void QgsRelationshipItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &, QgsDataItemGuiContext context ) { - if ( QgsRelationshipItem *relationshipItem = qobject_cast< QgsRelationshipItem * >( item ) ) + if ( QgsRelationshipItem *relationshipItem = qobject_cast( item ) ) { - if ( QgsRelationshipsItem *relationshipsItem = qobject_cast< QgsRelationshipsItem * >( relationshipItem->parent() ) ) + if ( QgsRelationshipsItem *relationshipsItem = qobject_cast( relationshipItem->parent() ) ) { const QString providerKey = relationshipsItem->providerKey(); const QString connectionUri = relationshipsItem->connectionUri(); @@ -2482,10 +2399,9 @@ void QgsRelationshipItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe { QAction *editRelationshipAction = new QAction( tr( "Edit Relationship…" ), menu ); - QPointer< QgsDataItem > itemWeakPointer( item ); + QPointer itemWeakPointer( item ); - connect( editRelationshipAction, &QAction::triggered, this, [ = ] - { + connect( editRelationshipAction, &QAction::triggered, this, [=] { std::unique_ptr conn { static_cast( md->createConnection( connectionUri, {} ) ) }; QgsDbRelationDialog dialog( conn.release(), QgisApp::instance() ); @@ -2517,13 +2433,10 @@ void QgsRelationshipItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe { QAction *deleteRelationshipAction = new QAction( tr( "Delete Relationship…" ), menu ); - QPointer< QgsDataItem > itemWeakPointer( item ); + QPointer itemWeakPointer( item ); - connect( deleteRelationshipAction, &QAction::triggered, this, [relation, md, connectionUri, itemWeakPointer, context] - { - if ( QMessageBox::question( nullptr, tr( "Delete Relationship" ), - tr( "Are you sure you want to delete the %1 relationship?" ).arg( relation.name() ), - QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + connect( deleteRelationshipAction, &QAction::triggered, this, [relation, md, connectionUri, itemWeakPointer, context] { + if ( QMessageBox::question( nullptr, tr( "Delete Relationship" ), tr( "Are you sure you want to delete the %1 relationship?" ).arg( relation.name() ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { std::unique_ptr conn { static_cast( md->createConnection( connectionUri, {} ) ) }; try @@ -2547,23 +2460,23 @@ void QgsRelationshipItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe } } } - else if ( qobject_cast< QgsRelationshipsItem * >( item ) - || qobject_cast< QgsGeoPackageCollectionItem * >( item ) - || qobject_cast< QgsFileDataCollectionItem * >( item ) ) + else if ( qobject_cast( item ) + || qobject_cast( item ) + || qobject_cast( item ) ) { QString providerKey; QString connectionUri; - if ( QgsRelationshipsItem *relationshipsItem = qobject_cast< QgsRelationshipsItem * >( item ) ) + if ( QgsRelationshipsItem *relationshipsItem = qobject_cast( item ) ) { providerKey = relationshipsItem->providerKey(); connectionUri = relationshipsItem->connectionUri(); } - else if ( QgsGeoPackageCollectionItem *gpkgItem = qobject_cast< QgsGeoPackageCollectionItem * >( item ) ) + else if ( QgsGeoPackageCollectionItem *gpkgItem = qobject_cast( item ) ) { providerKey = QStringLiteral( "ogr" ); connectionUri = gpkgItem->path().remove( QStringLiteral( "gpkg:/" ) ); } - else if ( QgsFileDataCollectionItem *fileItem = qobject_cast< QgsFileDataCollectionItem * >( item ) ) + else if ( QgsFileDataCollectionItem *fileItem = qobject_cast( item ) ) { providerKey = QStringLiteral( "ogr" ); connectionUri = fileItem->path(); @@ -2579,10 +2492,9 @@ void QgsRelationshipItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe { QAction *createRelationshipAction = new QAction( tr( "New Relationship…" ), menu ); - QPointer< QgsDataItem > itemWeakPointer( item ); + QPointer itemWeakPointer( item ); - connect( createRelationshipAction, &QAction::triggered, this, [ = ] - { + connect( createRelationshipAction, &QAction::triggered, this, [=] { std::unique_ptr conn { static_cast( md->createConnection( connectionUri, {} ) ) }; if ( conn->tables().isEmpty() ) @@ -2621,11 +2533,11 @@ void QgsRelationshipItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe QWidget *QgsRelationshipItemGuiProvider::createParamWidget( QgsDataItem *item, QgsDataItemGuiContext ) { - if ( QgsRelationshipItem *relationshipItem = qobject_cast< QgsRelationshipItem * >( item ) ) + if ( QgsRelationshipItem *relationshipItem = qobject_cast( item ) ) { return new QgsRelationshipDetailsWidget( nullptr, relationshipItem->relation() ); } - else if ( QgsRelationshipsItem *relationsItem = qobject_cast< QgsRelationshipsItem * >( item ) ) + else if ( QgsRelationshipsItem *relationsItem = qobject_cast( item ) ) { return new QgsRelationshipsDetailsWidget( nullptr, relationsItem->providerKey(), relationsItem->connectionUri(), relationsItem->schema(), relationsItem->tableName() ); } @@ -2666,18 +2578,13 @@ QString QgsRelationshipDetailsWidget::htmlMetadata( const QgsWeakRelation &relat if ( relation.cardinality() != Qgis::RelationshipCardinality::ManyToMany ) { metadata += QStringLiteral( "" ) + tr( "Tables" ) + QStringLiteral( "" ) - + QStringLiteral( "%1 → %2" ).arg( relation.referencedLayerName(), - relation.referencingLayerName() ) + QStringLiteral( "\n" ); + + QStringLiteral( "%1 → %2" ).arg( relation.referencedLayerName(), relation.referencingLayerName() ) + QStringLiteral( "\n" ); metadata += QStringLiteral( "" ) + tr( "Fields" ) + QStringLiteral( "" ); QStringList fieldMetadata; for ( int i = 0; i < std::min( relation.referencedLayerFields().size(), relation.referencingLayerFields().size() ); ++i ) { - fieldMetadata << QStringLiteral( "%1.%2 → %3.%4" ).arg( - relation.referencedLayerName(), - relation.referencedLayerFields().at( i ), - relation.referencingLayerName(), - relation.referencingLayerFields().at( i ) ); + fieldMetadata << QStringLiteral( "%1.%2 → %3.%4" ).arg( relation.referencedLayerName(), relation.referencedLayerFields().at( i ), relation.referencingLayerName(), relation.referencingLayerFields().at( i ) ); } metadata += fieldMetadata.join( QLatin1String( "
" ) ); metadata += QLatin1String( "\n" ); @@ -2685,28 +2592,17 @@ QString QgsRelationshipDetailsWidget::htmlMetadata( const QgsWeakRelation &relat else { metadata += QStringLiteral( "" ) + tr( "Tables" ) + QStringLiteral( "" ) - + QStringLiteral( "%1 → %2 → %3" ).arg( relation.referencedLayerName(), - relation.mappingTableName(), - relation.referencingLayerName() ) + QStringLiteral( "\n" ); + + QStringLiteral( "%1 → %2 → %3" ).arg( relation.referencedLayerName(), relation.mappingTableName(), relation.referencingLayerName() ) + QStringLiteral( "\n" ); metadata += QStringLiteral( "" ) + tr( "Fields" ) + QStringLiteral( "" ); QStringList fieldMetadata; for ( int i = 0; i < std::min( relation.referencedLayerFields().size(), relation.mappingReferencedLayerFields().size() ); ++i ) { - fieldMetadata << QStringLiteral( "%1.%2 → %3.%4" ).arg( - relation.referencedLayerName(), - relation.referencedLayerFields().at( i ), - relation.mappingTableName(), - relation.mappingReferencedLayerFields().at( i ) ); + fieldMetadata << QStringLiteral( "%1.%2 → %3.%4" ).arg( relation.referencedLayerName(), relation.referencedLayerFields().at( i ), relation.mappingTableName(), relation.mappingReferencedLayerFields().at( i ) ); } for ( int i = 0; i < std::min( relation.referencingLayerFields().size(), relation.mappingReferencingLayerFields().size() ); ++i ) { - fieldMetadata << QStringLiteral( "%1.%2 → %3.%4" ).arg( - relation.mappingTableName(), - relation.mappingReferencingLayerFields().at( i ), - relation.referencingLayerName(), - relation.referencingLayerFields().at( i ) - ); + fieldMetadata << QStringLiteral( "%1.%2 → %3.%4" ).arg( relation.mappingTableName(), relation.mappingReferencingLayerFields().at( i ), relation.referencingLayerName(), relation.referencingLayerFields().at( i ) ); } metadata += fieldMetadata.join( QLatin1String( "
" ) ); metadata += QLatin1String( "\n" ); @@ -2751,7 +2647,7 @@ QgsRelationshipsDetailsWidget::QgsRelationshipsDetailsWidget( QWidget *parent, c if ( conn && ( conn->capabilities() & QgsAbstractDatabaseProviderConnection::Capability::RetrieveRelationships ) ) { QString relationError; - QList< QgsWeakRelation > relationships; + QList relationships; try { relationships = conn->relationships( schema, tableName ); @@ -2774,8 +2670,7 @@ QgsRelationshipsDetailsWidget::QgsRelationshipsDetailsWidget( QWidget *parent, c metadata += QStringLiteral( "" ).arg( rowClass ) + relation.name() + QStringLiteral( "" ) + relation.referencedLayerName() + QStringLiteral( " → " ) + relation.referencingLayerName() - + QStringLiteral( "" ) + QObject::tr( "%1 (%2)" ).arg( QgsRelation::cardinalityToDisplayString( relation.cardinality() ), - QgsRelation::strengthToDisplayString( relation.strength() ) ) + + QStringLiteral( "" ) + QObject::tr( "%1 (%2)" ).arg( QgsRelation::cardinalityToDisplayString( relation.cardinality() ), QgsRelation::strengthToDisplayString( relation.strength() ) ) + QStringLiteral( "\n" ); i++; } @@ -2803,8 +2698,7 @@ QgsRelationshipsDetailsWidget::QgsRelationshipsDetailsWidget( QWidget *parent, c // QgsFieldsDetailsWidget // -QgsFieldsDetailsWidget::QgsFieldsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, - const QString &tableName ) +QgsFieldsDetailsWidget::QgsFieldsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, const QString &tableName ) : QWidget( parent ) { setupUi( this ); @@ -2886,7 +2780,7 @@ QgsFieldDetailsWidget::QgsFieldDetailsWidget( QWidget *parent, const QString &pr try { // try to retrieve full domain details if possible - std::unique_ptr< QgsFieldDomain > domain( conn->fieldDomain( field.constraints().domainName() ) ); + std::unique_ptr domain( conn->fieldDomain( field.constraints().domainName() ) ); if ( domain ) { metadata += QgsFieldDomainDetailsWidget::htmlMetadata( domain.get(), tr( "Domain" ) ); diff --git a/src/app/browser/qgsinbuiltdataitemproviders.h b/src/app/browser/qgsinbuiltdataitemproviders.h index 76c8263f8595..c2fe553fc145 100644 --- a/src/app/browser/qgsinbuiltdataitemproviders.h +++ b/src/app/browser/qgsinbuiltdataitemproviders.h @@ -36,16 +36,13 @@ class QgsAppDirectoryItemGuiProvider : public QObject, public QgsDataItemGuiProv Q_OBJECT public: - QgsAppDirectoryItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; private: - void addFavorite( QgsDirectoryItem *item ); void removeFavorite( QgsFavoriteItem *favorite ); void renameFavorite( QgsFavoriteItem *favorite ); @@ -62,19 +59,16 @@ class QgsAppFileItemGuiProvider : public QObject, public QgsDataItemGuiProvider Q_OBJECT public: - QgsAppFileItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; int precedenceWhenPopulatingMenus() const override; bool rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context ) override; private: - - bool rename( const QString &oldPath, const QString &newName, QgsDataItemGuiContext context, const QList< QPointer< QgsDataItem > > &parentItems ); + bool rename( const QString &oldPath, const QString &newName, QgsDataItemGuiContext context, const QList> &parentItems ); }; @@ -83,14 +77,11 @@ class QgsProjectHomeItemGuiProvider : public QObject, public QgsDataItemGuiProvi Q_OBJECT public: - QgsProjectHomeItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; - + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; }; @@ -99,14 +90,11 @@ class QgsFavoritesItemGuiProvider : public QObject, public QgsDataItemGuiProvide Q_OBJECT public: - QgsFavoritesItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; - + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; }; @@ -115,22 +103,18 @@ class QgsLayerItemGuiProvider : public QObject, public QgsDataItemGuiProvider Q_OBJECT public: - QgsLayerItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; int precedenceWhenPopulatingMenus() const override; bool handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context ) override; private: - void addLayersFromItems( const QList &items ); void showPropertiesForItem( QgsLayerItem *item, QgsDataItemGuiContext context ); void deleteLayers( const QStringList &itemPath, QgsDataItemGuiContext context ); - }; @@ -139,13 +123,11 @@ class QgsFieldsItemGuiProvider : public QObject, public QgsDataItemGuiProvider Q_OBJECT public: - QgsFieldsItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override; }; @@ -155,13 +137,11 @@ class QgsFieldItemGuiProvider : public QObject, public QgsDataItemGuiProvider Q_OBJECT public: - QgsFieldItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context ) override; QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override; @@ -176,7 +156,6 @@ class QgsFieldsDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadata Q_OBJECT public: - QgsFieldsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, const QString &tableName ); }; @@ -185,26 +164,22 @@ class QgsFieldDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataW Q_OBJECT public: - QgsFieldDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, const QString &tableName, const QgsField &field ); }; - class QgsFieldDomainDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataWidgetBase { Q_OBJECT public: - QgsFieldDomainDetailsWidget( QWidget *parent, const QgsFieldDomain *domain ); ~QgsFieldDomainDetailsWidget() override; static QString htmlMetadata( QgsFieldDomain *domain, const QString &title ); private: - - std::unique_ptr< QgsFieldDomain > mDomain; + std::unique_ptr mDomain; }; class QgsFieldDomainsDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataWidgetBase @@ -212,7 +187,6 @@ class QgsFieldDomainsDetailsWidget : public QWidget, private Ui_QgsBrowserItemMe Q_OBJECT public: - QgsFieldDomainsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri ); }; @@ -222,31 +196,25 @@ class QgsFieldDomainItemGuiProvider : public QObject, public QgsDataItemGuiProvi Q_OBJECT public: - QgsFieldDomainItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override; }; - - class QgsRelationshipDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataWidgetBase { Q_OBJECT public: - QgsRelationshipDetailsWidget( QWidget *parent, const QgsWeakRelation &relation ); ~QgsRelationshipDetailsWidget() override; static QString htmlMetadata( const QgsWeakRelation &relation, const QString &title ); private: - QgsWeakRelation mRelation; }; @@ -255,7 +223,6 @@ class QgsRelationshipsDetailsWidget : public QWidget, private Ui_QgsBrowserItemM Q_OBJECT public: - QgsRelationshipsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, const QString &tableName ); }; @@ -265,33 +232,26 @@ class QgsRelationshipItemGuiProvider : public QObject, public QgsDataItemGuiProv Q_OBJECT public: - QgsRelationshipItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override; }; - class QgsDatabaseItemGuiProvider : public QObject, public QgsDataItemGuiProvider { Q_OBJECT public: - QgsDatabaseItemGuiProvider(); QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool acceptDrop( QgsDataItem *item, QgsDataItemGuiContext context ) override; - bool handleDrop( QgsDataItem *item, QgsDataItemGuiContext context, - const QMimeData *data, - Qt::DropAction action ) override; + bool handleDrop( QgsDataItem *item, QgsDataItemGuiContext context, const QMimeData *data, Qt::DropAction action ) override; void openSqlDialog( const QString &connectionUri, const QString &provider, const QString &query, QgsDataItemGuiContext context, const QString &identifierName = QString() ); @@ -299,27 +259,20 @@ class QgsDatabaseItemGuiProvider : public QObject, public QgsDataItemGuiProvider public slots: void openSqlDialogGeneric( const QString &connectionUri, const QString &provider, const QString &query ); - }; - class QgsProjectItemGuiProvider : public QObject, public QgsDataItemGuiProvider { Q_OBJECT public: - QgsProjectItemGuiProvider() = default; QString name() override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context ) override; - }; #endif // QGSINBUILTDATAITEMPROVIDERS_H - - diff --git a/src/app/canvas/qgsappcanvasfiltering.cpp b/src/app/canvas/qgsappcanvasfiltering.cpp index f78b7f1591bc..c638f16acb28 100644 --- a/src/app/canvas/qgsappcanvasfiltering.cpp +++ b/src/app/canvas/qgsappcanvasfiltering.cpp @@ -27,14 +27,12 @@ QgsAppCanvasFiltering::QgsAppCanvasFiltering( QObject *parent ) : QObject( parent ) { - } void QgsAppCanvasFiltering::setupElevationControllerAction( QAction *action, QgsMapCanvas *canvas ) { action->setCheckable( true ); - connect( action, &QAction::toggled, canvas, [canvas, action, this]( bool checked ) - { + connect( action, &QAction::toggled, canvas, [canvas, action, this]( bool checked ) { if ( checked ) { createElevationController( action, canvas ); @@ -56,30 +54,26 @@ void QgsAppCanvasFiltering::createElevationController( QAction *senderAction, Qg QAction *setProjectLimitsAction = new QAction( tr( "Set Elevation Range…" ), controller ); controller->menu()->addAction( setProjectLimitsAction ); - connect( setProjectLimitsAction, &QAction::triggered, QgisApp::instance(), [] - { + connect( setProjectLimitsAction, &QAction::triggered, QgisApp::instance(), [] { QgisApp::instance()->showProjectProperties( tr( "Elevation" ) ); } ); QAction *disableAction = new QAction( tr( "Disable Elevation Filter" ), controller ); controller->menu()->addAction( disableAction ); - connect( disableAction, &QAction::triggered, senderAction, [senderAction] - { + connect( disableAction, &QAction::triggered, senderAction, [senderAction] { senderAction->setChecked( false ); } ); mCanvasElevationControllerMap.insert( canvas, controller ); - connect( canvas, &QObject::destroyed, this, [canvas, this] - { + connect( canvas, &QObject::destroyed, this, [canvas, this] { mCanvasElevationControllerMap.remove( canvas ); } ); - connect( controller, &QObject::destroyed, this, [canvas, this] - { + connect( controller, &QObject::destroyed, this, [canvas, this] { mCanvasElevationControllerMap.remove( canvas ); } ); // bridge is parented to controller QgsCanvasElevationControllerBridge *bridge = new QgsCanvasElevationControllerBridge( controller, canvas ); - ( void )bridge; + ( void ) bridge; } QgsCanvasElevationControllerBridge::QgsCanvasElevationControllerBridge( QgsElevationControllerWidget *controller, QgsMapCanvas *canvas ) @@ -100,13 +94,11 @@ QgsCanvasElevationControllerBridge::QgsCanvasElevationControllerBridge( QgsEleva { // for main canvas, attach settings to project settings mController->setFixedRangeSize( QgsProject::instance()->elevationProperties()->elevationFilterRangeSize() ); - connect( mController, &QgsElevationControllerWidget::fixedRangeSizeChanged, this, []( double size ) - { + connect( mController, &QgsElevationControllerWidget::fixedRangeSizeChanged, this, []( double size ) { QgsProject::instance()->elevationProperties()->setElevationFilterRangeSize( size ); } ); mController->setInverted( QgsProject::instance()->elevationProperties()->invertElevationFilter() ); - connect( mController, &QgsElevationControllerWidget::invertedChanged, this, []( bool inverted ) - { + connect( mController, &QgsElevationControllerWidget::invertedChanged, this, []( bool inverted ) { QgsProject::instance()->elevationProperties()->setInvertElevationFilter( inverted ); } ); } @@ -131,7 +123,7 @@ void QgsCanvasElevationControllerBridge::canvasLayersChanged() } // and connect to new - const QList< QgsMapLayer * > layers = mCanvas->layers( true ); + const QList layers = mCanvas->layers( true ); for ( QgsMapLayer *layer : layers ) { connect( layer->elevationProperties(), &QgsMapLayerElevationProperties::changed, this, &QgsCanvasElevationControllerBridge::updateSignificantElevations ); diff --git a/src/app/canvas/qgsappcanvasfiltering.h b/src/app/canvas/qgsappcanvasfiltering.h index a1e779e5915d..df7d04b0166e 100644 --- a/src/app/canvas/qgsappcanvasfiltering.h +++ b/src/app/canvas/qgsappcanvasfiltering.h @@ -31,7 +31,6 @@ class QgsCanvasElevationControllerBridge : public QObject Q_OBJECT public: - QgsCanvasElevationControllerBridge( QgsElevationControllerWidget *controller, QgsMapCanvas *canvas ); private slots: @@ -44,7 +43,7 @@ class QgsCanvasElevationControllerBridge : public QObject private: QTimer *mUpdateCanvasTimer = nullptr; QgsElevationControllerWidget *mController = nullptr; - QPointer< QgsMapCanvas> mCanvas; + QPointer mCanvas; QgsWeakMapLayerPointerList mCanvasLayers; }; @@ -53,17 +52,14 @@ class QgsAppCanvasFiltering : public QObject Q_OBJECT public: - QgsAppCanvasFiltering( QObject *parent ); void setupElevationControllerAction( QAction *action, QgsMapCanvas *canvas ); private: - void createElevationController( QAction *senderAction, QgsMapCanvas *canvas ); - QHash< QgsMapCanvas *, QgsElevationControllerWidget * > mCanvasElevationControllerMap; - + QHash mCanvasElevationControllerMap; }; #endif // QGSAPPCANVASFILTERING_H diff --git a/src/app/canvas/qgscanvasrefreshblocker.cpp b/src/app/canvas/qgscanvasrefreshblocker.cpp index 258ad3c93d38..78ea3bc293a3 100644 --- a/src/app/canvas/qgscanvasrefreshblocker.cpp +++ b/src/app/canvas/qgscanvasrefreshblocker.cpp @@ -44,4 +44,3 @@ QgsCanvasRefreshBlocker::~QgsCanvasRefreshBlocker() if ( !mReleased ) release(); } - diff --git a/src/app/canvas/qgscanvasrefreshblocker.h b/src/app/canvas/qgscanvasrefreshblocker.h index 7262b6073b65..b7a1f0fed6b8 100644 --- a/src/app/canvas/qgscanvasrefreshblocker.h +++ b/src/app/canvas/qgscanvasrefreshblocker.h @@ -20,7 +20,6 @@ class QgsCanvasRefreshBlocker { public: - QgsCanvasRefreshBlocker(); QgsCanvasRefreshBlocker( const QgsCanvasRefreshBlocker &other ) = delete; QgsCanvasRefreshBlocker &operator=( const QgsCanvasRefreshBlocker &other ) = delete; @@ -30,7 +29,6 @@ class QgsCanvasRefreshBlocker ~QgsCanvasRefreshBlocker(); private: - bool mReleased = false; }; diff --git a/src/app/decorations/qgsdecorationcopyright.cpp b/src/app/decorations/qgsdecorationcopyright.cpp index 99e61805d5c5..78de74c8ff28 100644 --- a/src/app/decorations/qgsdecorationcopyright.cpp +++ b/src/app/decorations/qgsdecorationcopyright.cpp @@ -199,4 +199,3 @@ void QgsDecorationCopyright::render( const QgsMapSettings &mapSettings, QgsRende //Paint label to canvas QgsTextRenderer::drawText( QPointF( xOffset, yOffset ), 0.0, horizontalAlignment, displayStringList, context, mTextFormat ); } - diff --git a/src/app/decorations/qgsdecorationcopyright.h b/src/app/decorations/qgsdecorationcopyright.h index 5e4b0fdbf03d..675a777af370 100644 --- a/src/app/decorations/qgsdecorationcopyright.h +++ b/src/app/decorations/qgsdecorationcopyright.h @@ -35,7 +35,6 @@ class APP_EXPORT QgsDecorationCopyright : public QgsDecorationItem { Q_OBJECT public: - //! Constructor QgsDecorationCopyright( QObject *parent = nullptr ); diff --git a/src/app/decorations/qgsdecorationcopyrightdialog.cpp b/src/app/decorations/qgsdecorationcopyrightdialog.cpp index 7bdfde71904b..68d6e804b770 100644 --- a/src/app/decorations/qgsdecorationcopyrightdialog.cpp +++ b/src/app/decorations/qgsdecorationcopyrightdialog.cpp @@ -67,8 +67,7 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft ); cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter ); cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight ); - connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int ) - { + connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { spnHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 ); } ); cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) ); @@ -76,10 +75,7 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig spnHorizontal->setClearValue( 0 ); spnHorizontal->setValue( mDeco.mMarginHorizontal ); spnVertical->setValue( mDeco.mMarginVertical ); - wgtUnitSelection->setUnits( { Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::Percentage, - Qgis::RenderUnit::Pixels - } ); + wgtUnitSelection->setUnits( { Qgis::RenderUnit::Millimeters, Qgis::RenderUnit::Percentage, Qgis::RenderUnit::Pixels } ); wgtUnitSelection->setUnit( mDeco.mMarginUnit ); // font settings @@ -119,7 +115,7 @@ void QgsDecorationCopyrightDialog::apply() { mDeco.setTextFormat( mButtonFontStyle->textFormat() ); mDeco.mLabelText = txtCopyrightText->toPlainText(); - mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) ); + mDeco.setPlacement( static_cast( cboPlacement->currentData().toInt() ) ); mDeco.mMarginUnit = wgtUnitSelection->unit(); mDeco.mMarginHorizontal = spnHorizontal->value(); mDeco.mMarginVertical = spnVertical->value(); diff --git a/src/app/decorations/qgsdecorationgrid.cpp b/src/app/decorations/qgsdecorationgrid.cpp index 6f5892553ab4..8d646a24669b 100644 --- a/src/app/decorations/qgsdecorationgrid.cpp +++ b/src/app/decorations/qgsdecorationgrid.cpp @@ -66,8 +66,7 @@ QgsDecorationGrid::QgsDecorationGrid( QObject *parent ) projectRead(); - connect( QgisApp::instance()->mapCanvas(), &QgsMapCanvas::destinationCrsChanged, - this, &QgsDecorationGrid::checkMapUnitsChanged ); + connect( QgisApp::instance()->mapCanvas(), &QgsMapCanvas::destinationCrsChanged, this, &QgsDecorationGrid::checkMapUnitsChanged ); } QgsDecorationGrid::~QgsDecorationGrid() = default; @@ -87,17 +86,14 @@ void QgsDecorationGrid::projectRead() QgsDecorationItem::projectRead(); mEnabled = QgsProject::instance()->readBoolEntry( mConfigurationName, QStringLiteral( "/Enabled" ), false ); - mMapUnits = static_cast< Qgis::DistanceUnit >( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/MapUnits" ), - static_cast< int >( Qgis::DistanceUnit::Unknown ) ) ); - mGridStyle = static_cast< GridStyle >( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Style" ), - QgsDecorationGrid::Line ) ); + mMapUnits = static_cast( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/MapUnits" ), static_cast( Qgis::DistanceUnit::Unknown ) ) ); + mGridStyle = static_cast( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Style" ), QgsDecorationGrid::Line ) ); mGridIntervalX = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/IntervalX" ), 10 ); mGridIntervalY = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/IntervalY" ), 10 ); mGridOffsetX = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/OffsetX" ), 0 ); mGridOffsetY = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/OffsetY" ), 0 ); mShowGridAnnotation = QgsProject::instance()->readBoolEntry( mConfigurationName, QStringLiteral( "/ShowAnnotation" ), false ); - mGridAnnotationDirection = static_cast< GridAnnotationDirection >( QgsProject::instance()->readNumEntry( mConfigurationName, - QStringLiteral( "/AnnotationDirection" ), 0 ) ); + mGridAnnotationDirection = static_cast( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/AnnotationDirection" ), 0 ) ); QDomDocument doc; QDomElement elem; @@ -128,8 +124,8 @@ void QgsDecorationGrid::projectRead() elem = doc.documentElement(); mLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol( elem, rwContext ) ); } - if ( ! mLineSymbol ) - mLineSymbol = std::make_unique< QgsLineSymbol >(); + if ( !mLineSymbol ) + mLineSymbol = std::make_unique(); if ( mMarkerSymbol ) setMarkerSymbol( nullptr ); @@ -140,12 +136,12 @@ void QgsDecorationGrid::projectRead() elem = doc.documentElement(); mMarkerSymbol.reset( QgsSymbolLayerUtils::loadSymbol( elem, rwContext ) ); } - if ( ! mMarkerSymbol ) + if ( !mMarkerSymbol ) { // set default symbol : cross with width=3 QgsSymbolLayerList symbolList; symbolList << new QgsSimpleMarkerSymbolLayer( Qgis::MarkerShape::Cross, 3, 0 ); - mMarkerSymbol = std::make_unique< QgsMarkerSymbol >( symbolList ); + mMarkerSymbol = std::make_unique( symbolList ); } } @@ -153,14 +149,14 @@ void QgsDecorationGrid::saveToProject() { QgsDecorationItem::saveToProject(); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Enabled" ), mEnabled ); - QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MapUnits" ), static_cast< int >( mMapUnits ) ); - QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Style" ), static_cast< int >( mGridStyle ) ); + QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MapUnits" ), static_cast( mMapUnits ) ); + QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Style" ), static_cast( mGridStyle ) ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/IntervalX" ), mGridIntervalX ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/IntervalY" ), mGridIntervalY ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/OffsetX" ), mGridOffsetX ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/OffsetY" ), mGridOffsetY ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/ShowAnnotation" ), mShowGridAnnotation ); - QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationDirection" ), static_cast< int >( mGridAnnotationDirection ) ); + QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationDirection" ), static_cast( mGridAnnotationDirection ) ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationFont" ), mGridAnnotationFont.toString() ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationFrameDistance" ), mAnnotationFrameDistance ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationPrecision" ), mGridAnnotationPrecision ); @@ -190,7 +186,6 @@ void QgsDecorationGrid::saveToProject() doc.appendChild( elem ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MarkerSymbol" ), doc.toString() ); } - } @@ -206,22 +201,22 @@ void QgsDecorationGrid::run() void QgsDecorationGrid::render( const QgsMapSettings &mapSettings, QgsRenderContext &context ) { - if ( ! mEnabled ) + if ( !mEnabled ) return; - QList< QPair< qreal, QLineF > > verticalLines; + QList> verticalLines; yGridLines( mapSettings, verticalLines ); - QList< QPair< qreal, QLineF > > horizontalLines; + QList> horizontalLines; xGridLines( mapSettings, horizontalLines ); - QList< QPair< qreal, QLineF > >::const_iterator vIt = verticalLines.constBegin(); - QList< QPair< qreal, QLineF > >::const_iterator hIt = horizontalLines.constBegin(); + QList>::const_iterator vIt = verticalLines.constBegin(); + QList>::const_iterator hIt = horizontalLines.constBegin(); switch ( mGridStyle ) { case Line: { - if ( ! mLineSymbol ) + if ( !mLineSymbol ) return; mLineSymbol->startRender( context ); @@ -250,7 +245,7 @@ void QgsDecorationGrid::render( const QgsMapSettings &mapSettings, QgsRenderCont case Marker: { - if ( ! mMarkerSymbol ) + if ( !mMarkerSymbol ) return; mMarkerSymbol->startRender( context ); @@ -279,10 +274,10 @@ void QgsDecorationGrid::render( const QgsMapSettings &mapSettings, QgsRenderCont } } -void QgsDecorationGrid::drawCoordinateAnnotations( QgsRenderContext &context, const QList< QPair< qreal, QLineF > > &hLines, const QList< QPair< qreal, QLineF > > &vLines ) +void QgsDecorationGrid::drawCoordinateAnnotations( QgsRenderContext &context, const QList> &hLines, const QList> &vLines ) { QString currentAnnotationString; - QList< QPair< qreal, QLineF > >::const_iterator it = hLines.constBegin(); + QList>::const_iterator it = hLines.constBegin(); for ( ; it != hLines.constEnd(); ++it ) { currentAnnotationString = QString::number( it->first, 'f', mGridAnnotationPrecision ); @@ -401,7 +396,8 @@ static bool clipByRect( QLineF &line, const QPolygonF &rect ) } } } - if ( intersectionList.size() < 2 ) return false; // no intersection + if ( intersectionList.size() < 2 ) + return false; // no intersection line = QLineF( intersectionList.at( 0 ), intersectionList.at( 1 ) ); return true; @@ -418,7 +414,7 @@ static QPolygonF canvasExtent( const QgsMapSettings &mapSettings ) return poly; } -int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const +int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList> &lines ) const { // prepare horizontal lines lines.clear(); @@ -445,7 +441,7 @@ int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPa Q_ASSERT( std::fabs( len - lineWest.length() ) < 1e-6 ); // no shear const double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0; - double dist = static_cast< int >( ( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY; + double dist = static_cast( ( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY; dist = dist - mapBoundingRect.top(); while ( dist < len ) { @@ -462,7 +458,7 @@ int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPa return 0; } -int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const +int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList> &lines ) const { // prepare vertical lines @@ -490,7 +486,7 @@ int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPa const QRectF mapBoundingRect = mapPolygon.boundingRect(); const double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0; - double dist = static_cast< int >( ( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX; + double dist = static_cast( ( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX; dist = dist - mapBoundingRect.left(); while ( dist < len ) { @@ -538,7 +534,7 @@ void QgsDecorationGrid::checkMapUnitsChanged() { mEnabled = false; mMapUnits = Qgis::DistanceUnit::Unknown; // make sure isDirty() returns true - if ( ! QgisApp::instance()->mapCanvas()->isFrozen() ) + if ( !QgisApp::instance()->mapCanvas()->isFrozen() ) { update(); } @@ -549,9 +545,7 @@ bool QgsDecorationGrid::isDirty() { // checks if stored map units is undefined or different from canvas map units // or if interval is 0 - return mMapUnits == Qgis::DistanceUnit::Unknown || - mMapUnits != QgisApp::instance()->mapCanvas()->mapSettings().mapUnits() || - qgsDoubleNear( mGridIntervalX, 0.0 ) || qgsDoubleNear( mGridIntervalY, 0.0 ); + return mMapUnits == Qgis::DistanceUnit::Unknown || mMapUnits != QgisApp::instance()->mapCanvas()->mapSettings().mapUnits() || qgsDoubleNear( mGridIntervalX, 0.0 ) || qgsDoubleNear( mGridIntervalY, 0.0 ); } void QgsDecorationGrid::setDirty( bool dirty ) @@ -599,7 +593,7 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) const { // get current layer and make sure it is a raster layer and CRSs match QgsMapLayer *layer = QgisApp::instance()->mapCanvas()->currentLayer(); - if ( ! layer ) + if ( !layer ) { QMessageBox::warning( nullptr, tr( "Get Interval from Layer" ), tr( "No active layer" ) ); return false; @@ -616,8 +610,7 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) const return false; } const QgsCoordinateReferenceSystem layerCRS = layer->crs(); - const QgsCoordinateReferenceSystem mapCRS = - QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs(); + const QgsCoordinateReferenceSystem mapCRS = QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs(); // is this the best way to compare CRS? should we also make sure map has OTF enabled? // TODO calculate transformed values if necessary if ( layerCRS != mapCRS ) @@ -640,10 +633,8 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) const ratio = extent.yMinimum() / values[1]; values[3] = ( ratio - std::floor( ratio ) ) * values[1]; - QgsDebugMsgLevel( QStringLiteral( "xmax: %1 xmin: %2 width: %3 xInterval: %4 xOffset: %5" ).arg( - extent.xMaximum() ).arg( extent.xMinimum() ).arg( rlayer->width() ).arg( values[0] ).arg( values[2] ), 2 ); - QgsDebugMsgLevel( QStringLiteral( "ymax: %1 ymin: %2 height: %3 yInterval: %4 yOffset: %5" ).arg( - extent.yMaximum() ).arg( extent.yMinimum() ).arg( rlayer->height() ).arg( values[1] ).arg( values[3] ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "xmax: %1 xmin: %2 width: %3 xInterval: %4 xOffset: %5" ).arg( extent.xMaximum() ).arg( extent.xMinimum() ).arg( rlayer->width() ).arg( values[0] ).arg( values[2] ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "ymax: %1 ymin: %2 height: %3 yInterval: %4 yOffset: %5" ).arg( extent.yMaximum() ).arg( extent.yMinimum() ).arg( rlayer->height() ).arg( values[1] ).arg( values[3] ), 2 ); return true; } diff --git a/src/app/decorations/qgsdecorationgrid.h b/src/app/decorations/qgsdecorationgrid.h index ee40410a5bca..7d58dd0ed3ab 100644 --- a/src/app/decorations/qgsdecorationgrid.h +++ b/src/app/decorations/qgsdecorationgrid.h @@ -30,20 +30,18 @@ class QgsMarkerSymbol; #include #include "qgis_app.h" -class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem +class APP_EXPORT QgsDecorationGrid : public QgsDecorationItem { - Q_OBJECT public: - QgsDecorationGrid( QObject *parent = nullptr ); - ~ QgsDecorationGrid() override; + ~QgsDecorationGrid() override; enum GridStyle { Line = 0, // lines - Marker //markers + Marker //markers }; enum GridAnnotationDirection @@ -69,15 +67,15 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; } //! Sets coordinate grid style. - void setGridStyle( GridStyle style ) {mGridStyle = style;} + void setGridStyle( GridStyle style ) { mGridStyle = style; } GridStyle gridStyle() const { return mGridStyle; } //! Sets coordinate interval in x-direction for composergrid. - void setGridIntervalX( double interval ) { mGridIntervalX = interval;} + void setGridIntervalX( double interval ) { mGridIntervalX = interval; } double gridIntervalX() const { return mGridIntervalX; } //! Sets coordinate interval in y-direction for composergrid. - void setGridIntervalY( double interval ) { mGridIntervalY = interval;} + void setGridIntervalY( double interval ) { mGridIntervalY = interval; } double gridIntervalY() const { return mGridIntervalY; } //! Sets x-coordinate offset for composer grid @@ -94,27 +92,27 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem //! Sets with of grid pen void setGridPenWidth( double w ) { mGridPen.setWidthF( w ); } //! Sets the color of the grid pen - void setGridPenColor( const QColor &c ) { mGridPen.setColor( c ); } + void setGridPenColor( const QColor &c ) { mGridPen.setColor( c ); } //! Sets font for grid annotations void setGridAnnotationFont( const QFont &f ) { mGridAnnotationFont = f; } QFont gridAnnotationFont() const { return mGridAnnotationFont; } //! Sets coordinate precision for grid annotations - void setGridAnnotationPrecision( int p ) {mGridAnnotationPrecision = p;} - int gridAnnotationPrecision() const {return mGridAnnotationPrecision;} + void setGridAnnotationPrecision( int p ) { mGridAnnotationPrecision = p; } + int gridAnnotationPrecision() const { return mGridAnnotationPrecision; } //! Sets flag if grid annotation should be shown - void setShowGridAnnotation( bool show ) {mShowGridAnnotation = show;} - bool showGridAnnotation() const {return mShowGridAnnotation;} + void setShowGridAnnotation( bool show ) { mShowGridAnnotation = show; } + bool showGridAnnotation() const { return mShowGridAnnotation; } //! Sets distance between map frame and annotations - void setAnnotationFrameDistance( double d ) {mAnnotationFrameDistance = d;} - double annotationFrameDistance() const {return mAnnotationFrameDistance;} + void setAnnotationFrameDistance( double d ) { mAnnotationFrameDistance = d; } + double annotationFrameDistance() const { return mAnnotationFrameDistance; } //! Sets grid annotation direction. Can be horizontal, vertical, direction of axis and horizontal and vertical - void setGridAnnotationDirection( GridAnnotationDirection d ) {mGridAnnotationDirection = d;} - GridAnnotationDirection gridAnnotationDirection() const {return mGridAnnotationDirection;} + void setGridAnnotationDirection( GridAnnotationDirection d ) { mGridAnnotationDirection = d; } + GridAnnotationDirection gridAnnotationDirection() const { return mGridAnnotationDirection; } //! Sets symbol that is used to draw grid lines. Takes ownership void setLineSymbol( QgsLineSymbol *symbol ); @@ -154,7 +152,6 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem void checkMapUnitsChanged(); private: - //! Enum for different frame borders enum Border { @@ -187,8 +184,8 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem //! Annotation can be horizontal / vertical or different for axes GridAnnotationDirection mGridAnnotationDirection; - std::unique_ptr< QgsLineSymbol > mLineSymbol; - std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol; + std::unique_ptr mLineSymbol; + std::unique_ptr mMarkerSymbol; Qgis::DistanceUnit mMapUnits; @@ -198,20 +195,20 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem * \param hLines horizontal coordinate lines in item coordinates * \param vLines vertical coordinate lines in item coordinates */ - void drawCoordinateAnnotations( QgsRenderContext &context, const QList< QPair< qreal, QLineF > > &hLines, const QList< QPair< qreal, QLineF > > &vLines ); + void drawCoordinateAnnotations( QgsRenderContext &context, const QList> &hLines, const QList> &vLines ); void drawCoordinateAnnotation( QgsRenderContext &context, QPointF pos, const QString &annotationString ); /** * Returns the grid lines with associated coordinate value * \returns 0 in case of success */ - int xGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const; + int xGridLines( const QgsMapSettings &mapSettings, QList> &lines ) const; /** * Returns the grid lines for the y-coordinates. Not vertical in case of rotation * \returns 0 in case of success */ - int yGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const; + int yGridLines( const QgsMapSettings &mapSettings, QList> &lines ) const; //! Returns the item border of a point (in item coordinates) Border borderForLineCoord( QPointF point, const QPainter *p ) const; diff --git a/src/app/decorations/qgsdecorationgriddialog.cpp b/src/app/decorations/qgsdecorationgriddialog.cpp index 73c5ab8d618e..f88d5b28774f 100644 --- a/src/app/decorations/qgsdecorationgriddialog.cpp +++ b/src/app/decorations/qgsdecorationgriddialog.cpp @@ -38,7 +38,7 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationGridDialog::buttonBox_accepted ); connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationGridDialog::buttonBox_rejected ); - connect( mGridTypeComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [ = ]( int ) { updateSymbolButtons(); } ); + connect( mGridTypeComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=]( int ) { updateSymbolButtons(); } ); connect( mPbtnUpdateFromExtents, &QPushButton::clicked, this, &QgsDecorationGridDialog::mPbtnUpdateFromExtents_clicked ); connect( mPbtnUpdateFromLayer, &QPushButton::clicked, this, &QgsDecorationGridDialog::mPbtnUpdateFromLayer_clicked ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationGridDialog::showHelp ); @@ -47,7 +47,7 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg mLineSymbolButton->setSymbolType( Qgis::SymbolType::Line ); grpEnable->setChecked( mDeco.enabled() ); - connect( grpEnable, &QGroupBox::toggled, this, [ = ] { updateSymbolButtons(); } ); + connect( grpEnable, &QGroupBox::toggled, this, [=] { updateSymbolButtons(); } ); // mXMinLineEdit->setValidator( new QDoubleValidator( mXMinLineEdit ) ); @@ -57,14 +57,10 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg // mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::InsideMapFrame, tr( "Inside frame" ) ); // mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::OutsideMapFrame, tr( "Outside frame" ) ); - mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Horizontal, - tr( "Horizontal" ) ); - mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Vertical, - tr( "Vertical" ) ); - mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::HorizontalAndVertical, - tr( "Horizontal and Vertical" ) ); - mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::BoundaryDirection, - tr( "Boundary direction" ) ); + mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Horizontal, tr( "Horizontal" ) ); + mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Vertical, tr( "Vertical" ) ); + mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::HorizontalAndVertical, tr( "Horizontal and Vertical" ) ); + mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::BoundaryDirection, tr( "Boundary direction" ) ); updateGuiElements(); @@ -83,7 +79,6 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg void QgsDecorationGridDialog::updateGuiElements() { - grpEnable->setChecked( mDeco.enabled() ); mIntervalXEdit->setValue( mDeco.gridIntervalX() ); @@ -93,7 +88,7 @@ void QgsDecorationGridDialog::updateGuiElements() mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findData( mDeco.gridStyle() ) ); mDrawAnnotationCheckBox->setChecked( mDeco.showGridAnnotation() ); - mAnnotationDirectionComboBox->setCurrentIndex( static_cast< int >( mDeco.gridAnnotationDirection() ) ); + mAnnotationDirectionComboBox->setCurrentIndex( static_cast( mDeco.gridAnnotationDirection() ) ); mCoordinatePrecisionSpinBox->setValue( mDeco.gridAnnotationPrecision() ); mDistanceToMapFrameSpinBox->setValue( mDeco.annotationFrameDistance() ); @@ -122,7 +117,7 @@ void QgsDecorationGridDialog::updateDecoFromGui() mDeco.setGridIntervalY( mIntervalYEdit->value() ); mDeco.setGridOffsetX( mOffsetXEdit->value() ); mDeco.setGridOffsetY( mOffsetYEdit->value() ); - mDeco.setGridStyle( static_cast< QgsDecorationGrid::GridStyle >( mGridTypeComboBox->currentData().toInt() ) ); + mDeco.setGridStyle( static_cast( mGridTypeComboBox->currentData().toInt() ) ); mDeco.setTextFormat( mAnnotationFontButton->textFormat() ); mDeco.setAnnotationFrameDistance( mDistanceToMapFrameSpinBox->value() ); @@ -145,8 +140,8 @@ void QgsDecorationGridDialog::updateDecoFromGui() mDeco.setGridAnnotationDirection( QgsDecorationGrid::BoundaryDirection ); } mDeco.setGridAnnotationPrecision( mCoordinatePrecisionSpinBox->value() ); - mDeco.setLineSymbol( mLineSymbolButton->clonedSymbol< QgsLineSymbol >() ); - mDeco.setMarkerSymbol( mMarkerSymbolButton->clonedSymbol< QgsMarkerSymbol >() ); + mDeco.setLineSymbol( mLineSymbolButton->clonedSymbol() ); + mDeco.setMarkerSymbol( mMarkerSymbolButton->clonedSymbol() ); } void QgsDecorationGridDialog::showHelp() diff --git a/src/app/decorations/qgsdecorationgriddialog.h b/src/app/decorations/qgsdecorationgriddialog.h index cefe6806bc10..5f64b1154d51 100644 --- a/src/app/decorations/qgsdecorationgriddialog.h +++ b/src/app/decorations/qgsdecorationgriddialog.h @@ -49,7 +49,6 @@ class APP_EXPORT QgsDecorationGridDialog : public QDialog, private Ui::QgsDecora void updateGuiElements(); void updateDecoFromGui(); void updateInterval( bool force = false ); - }; #endif diff --git a/src/app/decorations/qgsdecorationimage.cpp b/src/app/decorations/qgsdecorationimage.cpp index 9213178aef67..b7321bf7cf0d 100644 --- a/src/app/decorations/qgsdecorationimage.cpp +++ b/src/app/decorations/qgsdecorationimage.cpp @@ -250,15 +250,13 @@ void QgsDecorationImage::render( const QgsMapSettings &mapSettings, QgsRenderCon context.painter()->translate( deviceWidth - xOffset - size.width(), yOffset ); break; case BottomRight: - context.painter()->translate( deviceWidth - xOffset - size.width(), - deviceHeight - yOffset - size.height() ); + context.painter()->translate( deviceWidth - xOffset - size.width(), deviceHeight - yOffset - size.height() ); break; case TopCenter: context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, yOffset ); break; case BottomCenter: - context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, - deviceHeight - yOffset - size.height() ); + context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, deviceHeight - yOffset - size.height() ); break; default: QgsDebugError( QStringLiteral( "Unsupported placement index of %1" ).arg( static_cast( mPlacement ) ) ); diff --git a/src/app/decorations/qgsdecorationimage.h b/src/app/decorations/qgsdecorationimage.h index 9ad001986b3a..b8f99bef64ce 100644 --- a/src/app/decorations/qgsdecorationimage.h +++ b/src/app/decorations/qgsdecorationimage.h @@ -26,19 +26,18 @@ class QAction; class QToolBar; class QPainter; -class APP_EXPORT QgsDecorationImage: public QgsDecorationItem +class APP_EXPORT QgsDecorationImage : public QgsDecorationItem { Q_OBJECT public: - /** * Format of source image */ enum Format { - FormatSVG, //!< SVG image - FormatRaster, //!< Raster image + FormatSVG, //!< SVG image + FormatRaster, //!< Raster image FormatUnknown, //!< Invalid or unknown image type }; @@ -65,7 +64,6 @@ class APP_EXPORT QgsDecorationImage: public QgsDecorationItem QString imagePath(); private: - //! The image fill color used with parameter-enabled SVG files QColor mColor; //! The image outline color used with parameter-enabled SVG files diff --git a/src/app/decorations/qgsdecorationimagedialog.cpp b/src/app/decorations/qgsdecorationimagedialog.cpp index 374fd56e911b..1b47042ee5f0 100644 --- a/src/app/decorations/qgsdecorationimagedialog.cpp +++ b/src/app/decorations/qgsdecorationimagedialog.cpp @@ -51,8 +51,7 @@ QgsDecorationImageDialog::QgsDecorationImageDialog( QgsDecorationImage &deco, QW cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft ); cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter ); cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight ); - connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int ) - { + connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { spinHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 ); } ); cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) ); @@ -61,16 +60,16 @@ QgsDecorationImageDialog::QgsDecorationImageDialog( QgsDecorationImage &deco, QW spinHorizontal->setValue( mDeco.mMarginHorizontal ); spinVertical->setValue( mDeco.mMarginVertical ); wgtUnitSelection->setUnits( - { - Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::Percentage, - Qgis::RenderUnit::Pixels - } ); + { Qgis::RenderUnit::Millimeters, + Qgis::RenderUnit::Percentage, + Qgis::RenderUnit::Pixels + } + ); wgtUnitSelection->setUnit( mDeco.mMarginUnit ); // enabled grpEnable->setChecked( mDeco.enabled() ); - connect( grpEnable, &QGroupBox::toggled, this, [ = ] { updateEnabledColorButtons(); } ); + connect( grpEnable, &QGroupBox::toggled, this, [=] { updateEnabledColorButtons(); } ); wgtImagePath->setFilePath( mDeco.imagePath() ); connect( wgtImagePath, &QgsFileWidget::fileChanged, this, &QgsDecorationImageDialog::updateImagePath ); @@ -84,8 +83,8 @@ QgsDecorationImageDialog::QgsDecorationImageDialog( QgsDecorationImage &deco, QW pbnChangeOutlineColor->setColor( mDeco.mOutlineColor ); pbnChangeOutlineColor->setContext( QStringLiteral( "gui" ) ); pbnChangeOutlineColor->setColorDialogTitle( tr( "Select SVG Image Outline Color" ) ); - connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawImage(); } ); - connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawImage(); } ); + connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawImage(); } ); + connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawImage(); } ); drawImage(); } @@ -111,7 +110,7 @@ void QgsDecorationImageDialog::apply() mDeco.mColor = pbnChangeColor->color(); mDeco.mOutlineColor = pbnChangeOutlineColor->color(); mDeco.mSize = spinSize->value(); - mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) ); + mDeco.setPlacement( static_cast( cboPlacement->currentData().toInt() ) ); mDeco.mMarginUnit = wgtUnitSelection->unit(); mDeco.setEnabled( grpEnable->isChecked() ); mDeco.mMarginHorizontal = spinHorizontal->value(); @@ -121,18 +120,13 @@ void QgsDecorationImageDialog::apply() void QgsDecorationImageDialog::updateEnabledColorButtons() { - if ( mDeco.mImageFormat == QgsDecorationImage::FormatSVG ) { QColor defaultFill, defaultStroke; double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity; bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity; bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam; - QgsApplication::svgCache()->containsParams( mDeco.imagePath(), hasFillParam, hasDefaultFillColor, defaultFill, - hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, - hasStrokeParam, hasDefaultStrokeColor, defaultStroke, - hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, - hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity ); + QgsApplication::svgCache()->containsParams( mDeco.imagePath(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasStrokeParam, hasDefaultStrokeColor, defaultStroke, hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity ); pbnChangeColor->setEnabled( grpEnable->isChecked() && hasFillParam ); pbnChangeColor->setAllowOpacity( hasFillOpacityParam ); @@ -234,7 +228,7 @@ void QgsDecorationImageDialog::drawImage() if ( !missing ) { - QPixmap px( maxLength, maxLength ); + QPixmap px( maxLength, maxLength ); px.fill( Qt::transparent ); QPainter painter; @@ -258,7 +252,7 @@ void QgsDecorationImageDialog::drawImage() } else { - QPixmap px( 200, 200 ); + QPixmap px( 200, 200 ); px.fill( Qt::transparent ); QPainter painter; painter.begin( &px ); diff --git a/src/app/decorations/qgsdecorationitem.cpp b/src/app/decorations/qgsdecorationitem.cpp index 73b66f6c6670..b8cd40881345 100644 --- a/src/app/decorations/qgsdecorationitem.cpp +++ b/src/app/decorations/qgsdecorationitem.cpp @@ -59,13 +59,13 @@ void QgsDecorationItem::update() void QgsDecorationItem::projectRead() { mEnabled = QgsProject::instance()->readBoolEntry( mConfigurationName, QStringLiteral( "/Enabled" ), false ); - mPlacement = static_cast< Placement >( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast< int >( mPlacement ) ) ); + mPlacement = static_cast( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast( mPlacement ) ) ); mMarginUnit = QgsUnitTypes::decodeRenderUnit( QgsProject::instance()->readEntry( mConfigurationName, QStringLiteral( "/MarginUnit" ), QgsUnitTypes::encodeUnit( mMarginUnit ) ) ); } void QgsDecorationItem::saveToProject() { QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Enabled" ), mEnabled ); - QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast< int >( mPlacement ) ); + QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast( mPlacement ) ); QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MarginUnit" ), QgsUnitTypes::encodeUnit( mMarginUnit ) ); } diff --git a/src/app/decorations/qgsdecorationitem.h b/src/app/decorations/qgsdecorationitem.h index 7a7a20338bb5..0df60d60e1a7 100644 --- a/src/app/decorations/qgsdecorationitem.h +++ b/src/app/decorations/qgsdecorationitem.h @@ -33,7 +33,6 @@ class APP_EXPORT QgsDecorationItem : public QObject, public QgsMapDecoration Q_OBJECT public: - //! Item placements enum Placement { @@ -79,7 +78,6 @@ class APP_EXPORT QgsDecorationItem : public QObject, public QgsMapDecoration void update(); protected: - //! True if decoration item has to be displayed bool mEnabled = false; diff --git a/src/app/decorations/qgsdecorationlayoutextent.cpp b/src/app/decorations/qgsdecorationlayoutextent.cpp index e45af176a218..838b50754a15 100644 --- a/src/app/decorations/qgsdecorationlayoutextent.cpp +++ b/src/app/decorations/qgsdecorationlayoutextent.cpp @@ -64,7 +64,7 @@ void QgsDecorationLayoutExtent::projectRead() elem = doc.documentElement(); mSymbol.reset( QgsSymbolLayerUtils::loadSymbol( elem, rwContext ) ); } - if ( ! mSymbol ) + if ( !mSymbol ) { mSymbol.reset( new QgsFillSymbol() ); QgsSimpleLineSymbolLayer *layer = new QgsSimpleLineSymbolLayer( QColor( 0, 0, 0, 100 ), 0, Qt::DashLine ); @@ -128,12 +128,12 @@ void QgsDecorationLayoutExtent::render( const QgsMapSettings &mapSettings, QgsRe QTransform transform = m2p.transform(); // only loop through open layout designers - const QSet< QgsLayoutDesignerDialog * > designers = QgisApp::instance()->layoutDesigners(); + const QSet designers = QgisApp::instance()->layoutDesigners(); for ( QgsLayoutDesignerDialog *designer : designers ) { QgsLayout *layout = designer->currentLayout(); - QList< QgsLayoutItemMap * > maps; + QList maps; layout->layoutItems( maps ); for ( const QgsLayoutItemMap *map : std::as_const( maps ) ) { @@ -141,12 +141,10 @@ void QgsDecorationLayoutExtent::render( const QgsMapSettings &mapSettings, QgsRe QPointF labelPoint = extent.at( 1 ); QgsGeometry g = QgsGeometry::fromQPolygonF( extent ); - if ( map->crs() != - mapSettings.destinationCrs() ) + if ( map->crs() != mapSettings.destinationCrs() ) { // reproject extent - QgsCoordinateTransform ct( map->crs(), - mapSettings.destinationCrs(), QgsProject::instance() ); + QgsCoordinateTransform ct( map->crs(), mapSettings.destinationCrs(), QgsProject::instance() ); g = g.densifyByCount( 20 ); try { @@ -165,8 +163,7 @@ void QgsDecorationLayoutExtent::render( const QgsMapSettings &mapSettings, QgsRe if ( mLabelExtents ) { - QgsTextRenderer::drawText( labelPoint, ( map->mapRotation() - mapSettings.rotation() ) * M_PI / 180.0, Qgis::TextHorizontalAlignment::Right, QStringList() << tr( "%1: %2" ).arg( designer->masterLayout()->name(), map->displayName() ), - context, mTextFormat ); + QgsTextRenderer::drawText( labelPoint, ( map->mapRotation() - mapSettings.rotation() ) * M_PI / 180.0, Qgis::TextHorizontalAlignment::Right, QStringList() << tr( "%1: %2" ).arg( designer->masterLayout()->name(), map->displayName() ), context, mTextFormat ); } } } diff --git a/src/app/decorations/qgsdecorationlayoutextent.h b/src/app/decorations/qgsdecorationlayoutextent.h index f6fdd45aa22b..a3ecd65b7ffe 100644 --- a/src/app/decorations/qgsdecorationlayoutextent.h +++ b/src/app/decorations/qgsdecorationlayoutextent.h @@ -34,7 +34,6 @@ class APP_EXPORT QgsDecorationLayoutExtent : public QgsDecorationItem { Q_OBJECT public: - /** * Constructor for QgsDecorationLayoutExtent. */ @@ -91,7 +90,7 @@ class APP_EXPORT QgsDecorationLayoutExtent : public QgsDecorationItem void render( const QgsMapSettings &mapSettings, QgsRenderContext &context ) override; private: - std::unique_ptr< QgsFillSymbol > mSymbol; + std::unique_ptr mSymbol; QgsTextFormat mTextFormat; bool mLabelExtents = true; diff --git a/src/app/decorations/qgsdecorationlayoutextentdialog.cpp b/src/app/decorations/qgsdecorationlayoutextentdialog.cpp index 676f0abc38ae..7c9caf31fd6c 100644 --- a/src/app/decorations/qgsdecorationlayoutextentdialog.cpp +++ b/src/app/decorations/qgsdecorationlayoutextentdialog.cpp @@ -64,7 +64,7 @@ void QgsDecorationLayoutExtentDialog::updateGuiElements() void QgsDecorationLayoutExtentDialog::updateDecoFromGui() { mDeco.setEnabled( grpEnable->isChecked() ); - mDeco.setSymbol( mSymbolButton->clonedSymbol< QgsFillSymbol >() ); + mDeco.setSymbol( mSymbolButton->clonedSymbol() ); mDeco.setTextFormat( mButtonFontStyle->textFormat() ); mDeco.setLabelExtents( mCheckBoxLabelExtents->isChecked() ); } diff --git a/src/app/decorations/qgsdecorationlayoutextentdialog.h b/src/app/decorations/qgsdecorationlayoutextentdialog.h index ff5145dec7ff..9c0e51452ee9 100644 --- a/src/app/decorations/qgsdecorationlayoutextentdialog.h +++ b/src/app/decorations/qgsdecorationlayoutextentdialog.h @@ -47,7 +47,6 @@ class APP_EXPORT QgsDecorationLayoutExtentDialog : public QDialog, private Ui::Q void updateGuiElements(); void updateDecoFromGui(); - }; #endif // QGSDECORATIONLAYOUTEXTENTDIALOG_H diff --git a/src/app/decorations/qgsdecorationnortharrow.cpp b/src/app/decorations/qgsdecorationnortharrow.cpp index 4c9eaf08ce46..b34c148e388b 100644 --- a/src/app/decorations/qgsdecorationnortharrow.cpp +++ b/src/app/decorations/qgsdecorationnortharrow.cpp @@ -153,7 +153,7 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend { try { - mRotationInt = QgsBearingUtils:: bearingTrueNorth( mapSettings.destinationCrs(), mapSettings.transformContext(), context.extent().center() ); + mRotationInt = QgsBearingUtils::bearingTrueNorth( mapSettings.destinationCrs(), mapSettings.transformContext(), context.extent().center() ); } catch ( QgsException & ) { @@ -163,14 +163,8 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend } const double radiansDouble = mRotationInt * M_PI / 180.0; - const int xShift = static_cast( ( - ( centerXDouble * std::cos( radiansDouble ) ) + - ( centerYDouble * std::sin( radiansDouble ) ) - ) - centerXDouble ); - const int yShift = static_cast( ( - ( -centerXDouble * std::sin( radiansDouble ) ) + - ( centerYDouble * std::cos( radiansDouble ) ) - ) - centerYDouble ); + const int xShift = static_cast( ( ( centerXDouble * std::cos( radiansDouble ) ) + ( centerYDouble * std::sin( radiansDouble ) ) ) - centerXDouble ); + const int yShift = static_cast( ( ( -centerXDouble * std::sin( radiansDouble ) ) + ( centerYDouble * std::cos( radiansDouble ) ) ) - centerYDouble ); // need width/height of paint device QPaintDevice *device = context.painter()->device(); const float deviceHeight = static_cast( device->height() ) / context.devicePixelRatio(); @@ -219,15 +213,13 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend context.painter()->translate( deviceWidth - xOffset - maxLength + ( maxLength - size.width() ) / 2, yOffset ); break; case BottomRight: - context.painter()->translate( deviceWidth - xOffset - maxLength + ( maxLength - size.width() ) / 2, - deviceHeight - yOffset - maxLength + ( maxLength - size.height() ) / 2 ); + context.painter()->translate( deviceWidth - xOffset - maxLength + ( maxLength - size.width() ) / 2, deviceHeight - yOffset - maxLength + ( maxLength - size.height() ) / 2 ); break; case TopCenter: context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, yOffset ); break; case BottomCenter: - context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, - deviceHeight - yOffset - size.height() ); + context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, deviceHeight - yOffset - size.height() ); break; default: QgsDebugError( QStringLiteral( "Unsupported placement index of %1" ).arg( static_cast( mPlacement ) ) ); diff --git a/src/app/decorations/qgsdecorationnortharrow.h b/src/app/decorations/qgsdecorationnortharrow.h index 319b97036b4b..20dcc8930df7 100644 --- a/src/app/decorations/qgsdecorationnortharrow.h +++ b/src/app/decorations/qgsdecorationnortharrow.h @@ -29,12 +29,11 @@ class QAction; class QToolBar; class QPainter; -class APP_EXPORT QgsDecorationNorthArrow: public QgsDecorationItem +class APP_EXPORT QgsDecorationNorthArrow : public QgsDecorationItem { Q_OBJECT public: - /** * Constructor for QgsDecorationNorthArrow, with the specified \a parent object. */ @@ -55,7 +54,6 @@ class APP_EXPORT QgsDecorationNorthArrow: public QgsDecorationItem QString svgPath(); private: - // static const double DEG2RAD; static const double TOL; diff --git a/src/app/decorations/qgsdecorationnortharrowdialog.cpp b/src/app/decorations/qgsdecorationnortharrowdialog.cpp index a65d158ea0d5..7d1ff999adf0 100644 --- a/src/app/decorations/qgsdecorationnortharrowdialog.cpp +++ b/src/app/decorations/qgsdecorationnortharrowdialog.cpp @@ -52,12 +52,11 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth spinAngle->setEnabled( !mDeco.mAutomatic ); sliderRotation->setEnabled( !mDeco.mAutomatic ); - connect( cboxAutomatic, &QAbstractButton::toggled, this, [ = ]( bool checked ) - { + connect( cboxAutomatic, &QAbstractButton::toggled, this, [=]( bool checked ) { spinAngle->setEnabled( !checked ); sliderRotation->setEnabled( !checked ); } ); - connect( spinAngle, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsDecorationNorthArrowDialog::spinAngle_valueChanged ); + connect( spinAngle, static_cast( &QSpinBox::valueChanged ), this, &QgsDecorationNorthArrowDialog::spinAngle_valueChanged ); connect( sliderRotation, &QSlider::valueChanged, this, &QgsDecorationNorthArrowDialog::sliderRotation_valueChanged ); // placement @@ -67,8 +66,7 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft ); cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter ); cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight ); - connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int ) - { + connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { spinHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 ); } ); cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) ); @@ -77,11 +75,11 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth spinHorizontal->setValue( mDeco.mMarginHorizontal ); spinVertical->setValue( mDeco.mMarginVertical ); wgtUnitSelection->setUnits( - { - Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::Percentage, - Qgis::RenderUnit::Pixels - } ); + { Qgis::RenderUnit::Millimeters, + Qgis::RenderUnit::Percentage, + Qgis::RenderUnit::Pixels + } + ); wgtUnitSelection->setUnit( mDeco.mMarginUnit ); // enabled @@ -89,8 +87,7 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth mSvgPathLineEdit->setText( mDeco.mSvgPath ); connect( mSvgPathLineEdit, &QLineEdit::textChanged, this, &QgsDecorationNorthArrowDialog::updateSvgPath ); - connect( mSvgSelectorBtn, &QPushButton::clicked, this, [ = ] - { + connect( mSvgSelectorBtn, &QPushButton::clicked, this, [=] { QgsSvgSelectorDialog svgDlg( this ); svgDlg.setWindowTitle( tr( "Select SVG file" ) ); svgDlg.svgSelector()->setSvgPath( mSvgPathLineEdit->text().trimmed() ); @@ -112,8 +109,8 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth pbnChangeOutlineColor->setColor( mDeco.mOutlineColor ); pbnChangeOutlineColor->setContext( QStringLiteral( "gui" ) ); pbnChangeOutlineColor->setColorDialogTitle( tr( "Select North Arrow Outline Color" ) ); - connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawNorthArrow(); } ); - connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawNorthArrow(); } ); + connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawNorthArrow(); } ); + connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawNorthArrow(); } ); drawNorthArrow(); } @@ -153,7 +150,7 @@ void QgsDecorationNorthArrowDialog::apply() mDeco.mOutlineColor = pbnChangeOutlineColor->color(); mDeco.mSize = spinSize->value(); mDeco.mRotationInt = sliderRotation->value(); - mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) ); + mDeco.setPlacement( static_cast( cboPlacement->currentData().toInt() ) ); mDeco.mMarginUnit = wgtUnitSelection->unit(); mDeco.setEnabled( grpEnable->isChecked() ); mDeco.mAutomatic = cboxAutomatic->isChecked(); @@ -202,7 +199,7 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow() size.setHeight( maxLength * viewBox.height() / viewBox.width() ); } - QPixmap myPainterPixmap( maxLength, maxLength ); + QPixmap myPainterPixmap( maxLength, maxLength ); myPainterPixmap.fill( Qt::transparent ); QPainter myQPainter; @@ -221,14 +218,8 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow() //work out how to shift the image so that it appears in the center of the canvas //(x cos a + y sin a - x, -x sin a + y cos a - y) const double myRadiansDouble = ( M_PI / 180 ) * rotation; - const int xShift = static_cast( ( - ( centerXDouble * std::cos( myRadiansDouble ) ) + - ( centerYDouble * std::sin( myRadiansDouble ) ) - ) - centerXDouble ); - const int yShift = static_cast( ( - ( -centerXDouble * std::sin( myRadiansDouble ) ) + - ( centerYDouble * std::cos( myRadiansDouble ) ) - ) - centerYDouble ); + const int xShift = static_cast( ( ( centerXDouble * std::cos( myRadiansDouble ) ) + ( centerYDouble * std::sin( myRadiansDouble ) ) ) - centerXDouble ); + const int yShift = static_cast( ( ( -centerXDouble * std::sin( myRadiansDouble ) ) + ( centerYDouble * std::cos( myRadiansDouble ) ) ) - centerYDouble ); //draw the pixmap in the proper position myQPainter.translate( xShift, yShift ); @@ -242,7 +233,7 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow() } else { - QPixmap myPainterPixmap( 200, 200 ); + QPixmap myPainterPixmap( 200, 200 ); myPainterPixmap.fill( Qt::transparent ); QPainter myQPainter; myQPainter.begin( &myPainterPixmap ); diff --git a/src/app/decorations/qgsdecorationoverlay.cpp b/src/app/decorations/qgsdecorationoverlay.cpp index 494e04b03022..6a7191eff9e8 100644 --- a/src/app/decorations/qgsdecorationoverlay.cpp +++ b/src/app/decorations/qgsdecorationoverlay.cpp @@ -40,7 +40,7 @@ QgsDecorationOverlay::QgsDecorationOverlay( QWidget *parent ) void QgsDecorationOverlay::paintEvent( QPaintEvent * ) { - const QList< QgsMapDecoration * > decorations = QgisApp::instance()->activeDecorations(); + const QList decorations = QgisApp::instance()->activeDecorations(); if ( decorations.empty() ) return; diff --git a/src/app/decorations/qgsdecorationscalebar.cpp b/src/app/decorations/qgsdecorationscalebar.cpp index ae72c34deb5e..e8a831b910bc 100644 --- a/src/app/decorations/qgsdecorationscalebar.cpp +++ b/src/app/decorations/qgsdecorationscalebar.cpp @@ -151,19 +151,19 @@ void QgsDecorationScaleBar::setupScaleBar() case 0: case 1: { - std::unique_ptr< QgsTicksScaleBarRenderer > tickStyle = std::make_unique< QgsTicksScaleBarRenderer >(); + std::unique_ptr tickStyle = std::make_unique(); tickStyle->setTickPosition( mStyleIndex == 0 ? QgsTicksScaleBarRenderer::TicksDown : QgsTicksScaleBarRenderer::TicksUp ); mStyle = std::move( tickStyle ); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); + std::unique_ptr fillSymbol = std::make_unique(); fillSymbol->setColor( mColor ); // Compatibility with pre 3.2 configuration - if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol->symbolLayer( 0 ) ) ) + if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast( fillSymbol->symbolLayer( 0 ) ) ) { fill->setStrokeStyle( Qt::NoPen ); } mSettings.setFillSymbol( fillSymbol.release() ); - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); + std::unique_ptr lineSymbol = std::make_unique(); lineSymbol->setColor( mColor ); // Compatibility with pre 3.2 configuration lineSymbol->setWidth( 0.3 ); lineSymbol->setOutputUnit( Qgis::RenderUnit::Millimeters ); @@ -175,27 +175,27 @@ void QgsDecorationScaleBar::setupScaleBar() case 2: case 3: { - mStyle = std::make_unique< QgsSingleBoxScaleBarRenderer >(); + mStyle = std::make_unique(); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); + std::unique_ptr fillSymbol = std::make_unique(); fillSymbol->setColor( mColor ); - if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol->symbolLayer( 0 ) ) ) + if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast( fillSymbol->symbolLayer( 0 ) ) ) { fill->setStrokeStyle( Qt::NoPen ); } mSettings.setFillSymbol( fillSymbol.release() ); - std::unique_ptr< QgsFillSymbol > fillSymbol2 = std::make_unique< QgsFillSymbol >(); + std::unique_ptr fillSymbol2 = std::make_unique(); fillSymbol2->setColor( QColor( 255, 255, 255, 0 ) ); - if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol2->symbolLayer( 0 ) ) ) + if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast( fillSymbol2->symbolLayer( 0 ) ) ) { fill->setStrokeStyle( Qt::NoPen ); } mSettings.setAlternateFillSymbol( fillSymbol2.release() ); mSettings.setHeight( mStyleIndex == 2 ? 1 : 3 ); - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); + std::unique_ptr lineSymbol = std::make_unique(); lineSymbol->setColor( mOutlineColor ); // Compatibility with pre 3.2 configuration lineSymbol->setWidth( mStyleIndex == 2 ? 0.2 : 0.3 ); lineSymbol->setOutputUnit( Qgis::RenderUnit::Millimeters ); @@ -229,8 +229,7 @@ double QgsDecorationScaleBar::mapWidth( const QgsMapSettings &settings ) const double measure = 0; try { - measure = da.measureLine( QgsPointXY( mapExtent.xMinimum(), yPosition ), - QgsPointXY( mapExtent.xMaximum(), yPosition ) ); + measure = da.measureLine( QgsPointXY( mapExtent.xMinimum(), yPosition ), QgsPointXY( mapExtent.xMaximum(), yPosition ) ); } catch ( QgsCsException & ) { @@ -271,7 +270,7 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender //If scale bar is very small reset to 1/4 of the canvas wide if ( scaleBarWidth < 30 ) { - scaleBarWidth = deviceWidth / 4.0; // value in pixels + scaleBarWidth = deviceWidth / 4.0; // value in pixels unitsPerSegment = scaleBarWidth * scaleBarUnitsPerPixel; // value in map units } diff --git a/src/app/decorations/qgsdecorationscalebar.h b/src/app/decorations/qgsdecorationscalebar.h index 56ddff9f2e4e..61dc6c23afec 100644 --- a/src/app/decorations/qgsdecorationscalebar.h +++ b/src/app/decorations/qgsdecorationscalebar.h @@ -31,7 +31,7 @@ class QPainter; #include #include "qgis_app.h" -class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem +class APP_EXPORT QgsDecorationScaleBar : public QgsDecorationItem { Q_OBJECT public: @@ -51,7 +51,6 @@ class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem void setupScaleBar(); private: - //! The size preferred size of the scale bar int mPreferredSize; //! Should we snap to integer times power of 10? @@ -70,7 +69,7 @@ class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem QgsScaleBarSettings mSettings; //! Scalebar style - std::unique_ptr< QgsScaleBarRenderer > mStyle; + std::unique_ptr mStyle; //! Margin percentage values int mMarginHorizontal = 0; diff --git a/src/app/decorations/qgsdecorationscalebardialog.cpp b/src/app/decorations/qgsdecorationscalebardialog.cpp index ac392febb7b0..7245756620ed 100644 --- a/src/app/decorations/qgsdecorationscalebardialog.cpp +++ b/src/app/decorations/qgsdecorationscalebardialog.cpp @@ -64,8 +64,7 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft ); cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter ); cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight ); - connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int ) - { + connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { spnHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 ); } ); cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) ); @@ -74,11 +73,11 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar spnHorizontal->setValue( mDeco.mMarginHorizontal ); spnVertical->setValue( mDeco.mMarginVertical ); wgtUnitSelection->setUnits( - { - Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::Percentage, - Qgis::RenderUnit::Pixels - } ); + { Qgis::RenderUnit::Millimeters, + Qgis::RenderUnit::Percentage, + Qgis::RenderUnit::Pixels + } + ); wgtUnitSelection->setUnit( mDeco.mMarginUnit ); grpEnable->setChecked( mDeco.enabled() ); @@ -110,7 +109,7 @@ void QgsDecorationScaleBarDialog::showHelp() void QgsDecorationScaleBarDialog::apply() { - mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) ); + mDeco.setPlacement( static_cast( cboPlacement->currentData().toInt() ) ); mDeco.mMarginUnit = wgtUnitSelection->unit(); mDeco.mMarginHorizontal = spnHorizontal->value(); mDeco.mMarginVertical = spnVertical->value(); diff --git a/src/app/decorations/qgsdecorationtitle.cpp b/src/app/decorations/qgsdecorationtitle.cpp index 890e9d6839aa..7f684d82b431 100644 --- a/src/app/decorations/qgsdecorationtitle.cpp +++ b/src/app/decorations/qgsdecorationtitle.cpp @@ -219,4 +219,3 @@ void QgsDecorationTitle::render( const QgsMapSettings &mapSettings, QgsRenderCon // Paint label to canvas QgsTextRenderer::drawText( QPointF( xOffset, yOffset ), 0.0, horizontalAlignment, displayStringList, context, mTextFormat ); } - diff --git a/src/app/decorations/qgsdecorationtitle.h b/src/app/decorations/qgsdecorationtitle.h index e57e25a82db6..03789bf80008 100644 --- a/src/app/decorations/qgsdecorationtitle.h +++ b/src/app/decorations/qgsdecorationtitle.h @@ -33,7 +33,6 @@ class APP_EXPORT QgsDecorationTitle : public QgsDecorationItem { Q_OBJECT public: - //! Constructor QgsDecorationTitle( QObject *parent = nullptr ); diff --git a/src/app/decorations/qgsdecorationtitledialog.cpp b/src/app/decorations/qgsdecorationtitledialog.cpp index f15dacfcfe94..0b08e563acd8 100644 --- a/src/app/decorations/qgsdecorationtitledialog.cpp +++ b/src/app/decorations/qgsdecorationtitledialog.cpp @@ -74,8 +74,7 @@ QgsDecorationTitleDialog::QgsDecorationTitleDialog( QgsDecorationTitle &deco, QW cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft ); cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter ); cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight ); - connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int ) - { + connect( cboPlacement, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { spnHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 ); } ); cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) ); @@ -84,11 +83,11 @@ QgsDecorationTitleDialog::QgsDecorationTitleDialog( QgsDecorationTitle &deco, QW spnHorizontal->setValue( mDeco.mMarginHorizontal ); spnVertical->setValue( mDeco.mMarginVertical ); wgtUnitSelection->setUnits( - { - Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::Percentage, - Qgis::RenderUnit::Pixels - } ); + { Qgis::RenderUnit::Millimeters, + Qgis::RenderUnit::Percentage, + Qgis::RenderUnit::Pixels + } + ); wgtUnitSelection->setUnit( mDeco.mMarginUnit ); // font settings @@ -129,7 +128,7 @@ void QgsDecorationTitleDialog::apply() mDeco.setTextFormat( mButtonFontStyle->textFormat() ); mDeco.mLabelText = txtTitleText->toPlainText(); mDeco.mBackgroundColor = pbnBackgroundColor->color(); - mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) ); + mDeco.setPlacement( static_cast( cboPlacement->currentData().toInt() ) ); mDeco.mMarginUnit = wgtUnitSelection->unit(); mDeco.mMarginHorizontal = spnHorizontal->value(); mDeco.mMarginVertical = spnVertical->value(); diff --git a/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp b/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp index c531f5b8d149..0553b893da38 100644 --- a/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp +++ b/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp @@ -45,9 +45,9 @@ QgsDocumentationPanelWidget::QgsDocumentationPanelWidget( QWidget *parent ) mWebViewContainer->layout()->addWidget( mWebView ); - connect( mActionPyQgis, &QAction::triggered, this, [] {QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::PyQgis, Qgis::DocumentationBrowser::DeveloperToolsPanel );} ); - connect( mActionQt, &QAction::triggered, this, [] {QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::Qt, Qgis::DocumentationBrowser::DeveloperToolsPanel );} ); - connect( mActionOpenInBrowser, &QAction::triggered, this, [this] {QgisApp::instance()->openURL( mWebView->url().toString(), false );} ); + connect( mActionPyQgis, &QAction::triggered, this, [] { QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::PyQgis, Qgis::DocumentationBrowser::DeveloperToolsPanel ); } ); + connect( mActionQt, &QAction::triggered, this, [] { QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::Qt, Qgis::DocumentationBrowser::DeveloperToolsPanel ); } ); + connect( mActionOpenInBrowser, &QAction::triggered, this, [this] { QgisApp::instance()->openURL( mWebView->url().toString(), false ); } ); } void QgsDocumentationPanelWidget::showUrl( const QUrl &url ) diff --git a/src/app/devtools/documentation/qgsdocumentationpanelwidget.h b/src/app/devtools/documentation/qgsdocumentationpanelwidget.h index 75038ad8cb64..c8c33faeef5f 100644 --- a/src/app/devtools/documentation/qgsdocumentationpanelwidget.h +++ b/src/app/devtools/documentation/qgsdocumentationpanelwidget.h @@ -37,7 +37,6 @@ class QgsDocumentationPanelWidget : public QgsDevToolWidget, private Ui::QgsDocu Q_OBJECT public: - /** * Constructor for QgsDocumentationPanelWidget. */ @@ -47,14 +46,11 @@ class QgsDocumentationPanelWidget : public QgsDevToolWidget, private Ui::QgsDocu void showUrl( const QUrl &url ); private: - #ifdef HAVE_WEBENGINE QWebEngineView *mWebView = nullptr; #else QgsWebView *mWebView = nullptr; #endif - - }; diff --git a/src/app/devtools/networklogger/qgsnetworklogger.cpp b/src/app/devtools/networklogger/qgsnetworklogger.cpp index d29d55828887..4d7dc56b88b2 100644 --- a/src/app/devtools/networklogger/qgsnetworklogger.cpp +++ b/src/app/devtools/networklogger/qgsnetworklogger.cpp @@ -25,7 +25,7 @@ QgsNetworkLogger::QgsNetworkLogger( QgsNetworkAccessManager *manager, QObject *parent ) : QAbstractItemModel( parent ) , mNam( manager ) - , mRootNode( std::make_unique< QgsNetworkLoggerRootNode >() ) + , mRootNode( std::make_unique() ) { // logger must be created on the main thread Q_ASSERT( QThread::currentThread() == QApplication::instance()->thread() ); @@ -46,19 +46,19 @@ void QgsNetworkLogger::enableLogging( bool enabled ) { if ( enabled ) { - connect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated, Qt::UniqueConnection ); - connect( mNam, qOverload< const QgsNetworkRequestParameters &>( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated, Qt::UniqueConnection ); - connect( mNam, qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished, Qt::UniqueConnection ); - connect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut, Qt::UniqueConnection ); + connect( mNam, qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated, Qt::UniqueConnection ); + connect( mNam, qOverload( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated, Qt::UniqueConnection ); + connect( mNam, qOverload( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished, Qt::UniqueConnection ); + connect( mNam, qOverload( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut, Qt::UniqueConnection ); connect( mNam, &QgsNetworkAccessManager::downloadProgress, this, &QgsNetworkLogger::downloadProgress, Qt::UniqueConnection ); connect( mNam, &QgsNetworkAccessManager::requestEncounteredSslErrors, this, &QgsNetworkLogger::requestEncounteredSslErrors, Qt::UniqueConnection ); } else { - disconnect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated ); - disconnect( mNam, qOverload< const QgsNetworkRequestParameters &>( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated ); - disconnect( mNam, qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished ); - disconnect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut ); + disconnect( mNam, qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated ); + disconnect( mNam, qOverload( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated ); + disconnect( mNam, qOverload( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished ); + disconnect( mNam, qOverload( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut ); disconnect( mNam, &QgsNetworkAccessManager::downloadProgress, this, &QgsNetworkLogger::downloadProgress ); disconnect( mNam, &QgsNetworkAccessManager::requestEncounteredSslErrors, this, &QgsNetworkLogger::requestEncounteredSslErrors ); } @@ -79,7 +79,7 @@ void QgsNetworkLogger::requestAboutToBeCreated( QgsNetworkRequestParameters para beginInsertRows( QModelIndex(), childCount, childCount ); - std::unique_ptr< QgsNetworkLoggerRequestGroup > group = std::make_unique< QgsNetworkLoggerRequestGroup >( parameters ); + std::unique_ptr group = std::make_unique( parameters ); mRequestGroups.insert( parameters.requestId(), group.get() ); mRootNode->addChild( std::move( group ) ); endInsertRows(); @@ -145,7 +145,7 @@ void QgsNetworkLogger::downloadProgress( int requestId, qint64 bytesReceived, qi requestGroup->setProgress( bytesReceived, bytesTotal ); - emit dataChanged( requestIndex, requestIndex, QVector() << Qt::ToolTipRole ); + emit dataChanged( requestIndex, requestIndex, QVector() << Qt::ToolTipRole ); } void QgsNetworkLogger::requestEncounteredSslErrors( int requestId, const QList &errors ) @@ -177,7 +177,7 @@ QList QgsNetworkLogger::actions( const QModelIndex &index, QObject *p { QgsDevToolsModelNode *node = index2node( index ); if ( !node ) - return QList< QAction * >(); + return QList(); return node->actions( parent ); } @@ -200,7 +200,7 @@ QModelIndex QgsNetworkLogger::indexOfParentLayerTreeNode( QgsDevToolsModelNode * QgsDevToolsModelGroup *grandParentNode = parentNode->parent(); if ( !grandParentNode ) - return QModelIndex(); // root node -> invalid index + return QModelIndex(); // root node -> invalid index int row = grandParentNode->indexOf( parentNode ); Q_ASSERT( row >= 0 ); @@ -210,8 +210,8 @@ QModelIndex QgsNetworkLogger::indexOfParentLayerTreeNode( QgsDevToolsModelNode * void QgsNetworkLogger::removeRequestRows( const QList &rows ) { - QList< int > res = rows; - std::sort( res.begin(), res.end(), std::greater< int >() ); + QList res = rows; + std::sort( res.begin(), res.end(), std::greater() ); for ( int row : std::as_const( res ) ) { @@ -246,11 +246,10 @@ int QgsNetworkLogger::columnCount( const QModelIndex &parent ) const QModelIndex QgsNetworkLogger::index( int row, int column, const QModelIndex &parent ) const { - if ( column < 0 || column >= columnCount( parent ) || - row < 0 || row >= rowCount( parent ) ) + if ( column < 0 || column >= columnCount( parent ) || row < 0 || row >= rowCount( parent ) ) return QModelIndex(); - QgsDevToolsModelGroup *n = dynamic_cast< QgsDevToolsModelGroup * >( index2node( parent ) ); + QgsDevToolsModelGroup *n = dynamic_cast( index2node( parent ) ); if ( !n ) return QModelIndex(); // have no children @@ -343,7 +342,7 @@ void QgsNetworkLoggerProxyModel::setShowCached( bool show ) bool QgsNetworkLoggerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const { QgsDevToolsModelNode *node = mLogger->index2node( mLogger->index( source_row, 0, source_parent ) ); - if ( QgsNetworkLoggerRequestGroup *request = dynamic_cast< QgsNetworkLoggerRequestGroup * >( node ) ) + if ( QgsNetworkLoggerRequestGroup *request = dynamic_cast( node ) ) { if ( ( request->status() == QgsNetworkLoggerRequestGroup::Status::Complete || request->status() == QgsNetworkLoggerRequestGroup::Status::Canceled ) & !mShowSuccessful ) diff --git a/src/app/devtools/networklogger/qgsnetworklogger.h b/src/app/devtools/networklogger/qgsnetworklogger.h index 9245e8f6aea1..9ca34d523b95 100644 --- a/src/app/devtools/networklogger/qgsnetworklogger.h +++ b/src/app/devtools/networklogger/qgsnetworklogger.h @@ -38,7 +38,6 @@ class QgsNetworkLogger : public QAbstractItemModel Q_OBJECT public: - /** * Constructor for QgsNetworkLogger, logging requests from the specified \a manager. * @@ -73,12 +72,12 @@ class QgsNetworkLogger : public QAbstractItemModel * * The actions should be parented to \a parent. */ - QList< QAction * > actions( const QModelIndex &index, QObject *parent ); + QList actions( const QModelIndex &index, QObject *parent ); /** * Removes a list of request \a rows from the log. */ - void removeRequestRows( const QList< int > &rows ); + void removeRequestRows( const QList &rows ); /** * Returns the root node of the log. @@ -108,7 +107,6 @@ class QgsNetworkLogger : public QAbstractItemModel void requestEncounteredSslErrors( int requestId, const QList &errors ); private: - //! Returns index for a given node QModelIndex node2index( QgsDevToolsModelNode *node ) const; QModelIndex indexOfParentLayerTreeNode( QgsDevToolsModelNode *parentNode ) const; @@ -116,10 +114,9 @@ class QgsNetworkLogger : public QAbstractItemModel QgsNetworkAccessManager *mNam = nullptr; bool mIsLogging = false; - std::unique_ptr< QgsNetworkLoggerRootNode > mRootNode; - - QHash< int, QgsNetworkLoggerRequestGroup * > mRequestGroups; + std::unique_ptr mRootNode; + QHash mRequestGroups; }; /** @@ -134,7 +131,6 @@ class QgsNetworkLoggerProxyModel : public QSortFilterProxyModel { Q_OBJECT public: - /** * Constructor for QgsNetworkLoggerProxyModel, filtering the specified network \a logger. */ @@ -164,7 +160,6 @@ class QgsNetworkLoggerProxyModel : public QSortFilterProxyModel bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override; private: - QgsNetworkLogger *mLogger = nullptr; QString mFilterString; diff --git a/src/app/devtools/networklogger/qgsnetworkloggernode.cpp b/src/app/devtools/networklogger/qgsnetworkloggernode.cpp index e52cd9ffb9cb..317ff3534199 100644 --- a/src/app/devtools/networklogger/qgsnetworkloggernode.cpp +++ b/src/app/devtools/networklogger/qgsnetworkloggernode.cpp @@ -33,7 +33,6 @@ QgsNetworkLoggerRootNode::QgsNetworkLoggerRootNode() : QgsDevToolsModelGroup( QString() ) { - } QVariant QgsNetworkLoggerRootNode::data( int ) const @@ -49,7 +48,7 @@ void QgsNetworkLoggerRootNode::removeRow( int row ) QVariant QgsNetworkLoggerRootNode::toVariant() const { QVariantList res; - for ( const std::unique_ptr< QgsDevToolsModelNode > &child : mChildren ) + for ( const std::unique_ptr &child : mChildren ) res << child->toVariant(); return res; } @@ -73,8 +72,8 @@ QgsNetworkLoggerRequestGroup::QgsNetworkLoggerRequestGroup( const QgsNetworkRequ mHeaders.append( qMakePair( QString( header ), QString( request.request().rawHeader( header ) ) ) ); } - std::unique_ptr< QgsNetworkLoggerRequestDetailsGroup > detailsGroup = std::make_unique< QgsNetworkLoggerRequestDetailsGroup >( request ); - mDetailsGroup = static_cast< QgsNetworkLoggerRequestDetailsGroup * >( addChild( std::move( detailsGroup ) ) ); + std::unique_ptr detailsGroup = std::make_unique( request ); + mDetailsGroup = static_cast( addChild( std::move( detailsGroup ) ) ); mTimer.start(); } @@ -84,9 +83,7 @@ QVariant QgsNetworkLoggerRequestGroup::data( int role ) const switch ( role ) { case Qt::DisplayRole: - return QStringLiteral( "%1 %2 %3" ).arg( QString::number( mRequestId ), - mOperation == QNetworkAccessManager::Operation::CustomOperation ? mVerb : operationToString( mOperation ), - mUrl.url() ); + return QStringLiteral( "%1 %2 %3" ).arg( QString::number( mRequestId ), mOperation == QNetworkAccessManager::Operation::CustomOperation ? mVerb : operationToString( mOperation ), mUrl.url() ); case Qt::ToolTipRole: { @@ -101,17 +98,11 @@ QVariant QgsNetworkLoggerRequestGroup::data( int role ) const // ?? adding
instead of \n after (very long) url seems to break url up // COMPLETE, Status: 200 - text/xml; charset=utf-8 - 2334 bytes - 657 milliseconds return QStringLiteral( "%1
%2 - Status: %3 - %4 - %5 bytes - %6 msec - %7 replies" ) - .arg( mUrl.url(), - statusToString( mStatus ), - QString::number( mHttpStatus ), - mContentType, - bytes, - mStatus == Status::Pending ? QString::number( mTimer.elapsed() / 1000 ) : QString::number( mTotalTime ), - QString::number( mReplies ) ); + .arg( mUrl.url(), statusToString( mStatus ), QString::number( mHttpStatus ), mContentType, bytes, mStatus == Status::Pending ? QString::number( mTimer.elapsed() / 1000 ) : QString::number( mTotalTime ), QString::number( mReplies ) ); } case RoleStatus: - return static_cast< int >( mStatus ); + return static_cast( mStatus ); case RoleId: return mRequestId; @@ -159,26 +150,23 @@ QVariant QgsNetworkLoggerRequestGroup::data( int role ) const QList QgsNetworkLoggerRequestGroup::actions( QObject *parent ) { - QList< QAction * > res; + QList res; QAction *openUrlAction = new QAction( QObject::tr( "Open URL" ), parent ); - QObject::connect( openUrlAction, &QAction::triggered, openUrlAction, [ = ] - { + QObject::connect( openUrlAction, &QAction::triggered, openUrlAction, [=] { QDesktopServices::openUrl( mUrl ); } ); res << openUrlAction; QAction *copyUrlAction = new QAction( QObject::tr( "Copy URL" ), parent ); - QObject::connect( copyUrlAction, &QAction::triggered, openUrlAction, [ = ] - { + QObject::connect( copyUrlAction, &QAction::triggered, openUrlAction, [=] { QApplication::clipboard()->setText( mUrl.url() ); } ); res << copyUrlAction; QAction *copyAsCurlAction = new QAction( QObject::tr( "Copy As cURL" ), parent ); - QObject::connect( copyAsCurlAction, &QAction::triggered, copyAsCurlAction, [ = ] - { + QObject::connect( copyAsCurlAction, &QAction::triggered, copyAsCurlAction, [=] { QString curlHeaders; - for ( const QPair< QString, QString > &header : std::as_const( mHeaders ) ) + for ( const QPair &header : std::as_const( mHeaders ) ) curlHeaders += QStringLiteral( "-H '%1: %2' " ).arg( header.first, header.second ); switch ( mOperation ) @@ -217,21 +205,16 @@ QList QgsNetworkLoggerRequestGroup::actions( QObject *parent ) || ( mOperation == QNetworkAccessManager::CustomOperation && !mData.isEmpty() ) ) curlData = QStringLiteral( "--data '%1' " ).arg( QString( mData ) ); - QString curlCmd = QStringLiteral( "curl '%1' %2 %3--compressed" ).arg( - mUrl.url(), - curlHeaders, - curlData ); + QString curlCmd = QStringLiteral( "curl '%1' %2 %3--compressed" ).arg( mUrl.url(), curlHeaders, curlData ); QApplication::clipboard()->setText( curlCmd ); } ); res << copyAsCurlAction; QAction *copyJsonAction = new QAction( QObject::tr( "Copy as JSON" ), parent ); - QObject::connect( copyJsonAction, &QAction::triggered, openUrlAction, [ = ] - { + QObject::connect( copyJsonAction, &QAction::triggered, openUrlAction, [=] { const QVariant value = toVariant(); const QString json = QString::fromStdString( QgsJsonUtils::jsonFromVariant( value ).dump( 2 ) ); QApplication::clipboard()->setText( json ); - } ); res << copyJsonAction; @@ -290,8 +273,8 @@ void QgsNetworkLoggerRequestGroup::setReply( const QgsNetworkReplyContent &reply mContentType = reply.rawHeader( "Content - Type" ); mReplyFromCache = reply.attribute( QNetworkRequest::SourceIsFromCacheAttribute ).toBool(); - std::unique_ptr< QgsNetworkLoggerReplyGroup > replyGroup = std::make_unique< QgsNetworkLoggerReplyGroup >( reply ) ; - mReplyGroup = static_cast< QgsNetworkLoggerReplyGroup * >( addChild( std::move( replyGroup ) ) ); + std::unique_ptr replyGroup = std::make_unique( reply ); + mReplyGroup = static_cast( addChild( std::move( replyGroup ) ) ); } void QgsNetworkLoggerRequestGroup::setTimedOut() @@ -311,8 +294,8 @@ void QgsNetworkLoggerRequestGroup::setSslErrors( const QList &errors mHasSslErrors = !errors.empty(); if ( mHasSslErrors ) { - std::unique_ptr< QgsNetworkLoggerSslErrorGroup > errorGroup = std::make_unique< QgsNetworkLoggerSslErrorGroup >( errors ); - mSslErrorsGroup = static_cast< QgsNetworkLoggerSslErrorGroup * >( addChild( std::move( errorGroup ) ) ); + std::unique_ptr errorGroup = std::make_unique( errors ); + mSslErrorsGroup = static_cast( addChild( std::move( errorGroup ) ) ); } } @@ -380,24 +363,22 @@ QString QgsNetworkLoggerRequestGroup::cacheControlToString( QNetworkRequest::Cac QgsNetworkLoggerRequestDetailsGroup::QgsNetworkLoggerRequestDetailsGroup( const QgsNetworkRequestParameters &request ) : QgsDevToolsModelGroup( QObject::tr( "Request" ) ) { - addKeyValueNode( QObject::tr( "Operation" ), request.operation() == QNetworkAccessManager::Operation::CustomOperation - ? request.request().attribute( QNetworkRequest::CustomVerbAttribute ).toString() - : QgsNetworkLoggerRequestGroup::operationToString( request.operation() ) ); + addKeyValueNode( QObject::tr( "Operation" ), request.operation() == QNetworkAccessManager::Operation::CustomOperation ? request.request().attribute( QNetworkRequest::CustomVerbAttribute ).toString() : QgsNetworkLoggerRequestGroup::operationToString( request.operation() ) ); addKeyValueNode( QObject::tr( "Thread" ), request.originatingThreadId() ); addKeyValueNode( QObject::tr( "Initiator" ), request.initiatorClassName().isEmpty() ? QObject::tr( "unknown" ) : request.initiatorClassName() ); if ( request.initiatorRequestId().isValid() ) addKeyValueNode( QObject::tr( "ID" ), request.initiatorRequestId().toString() ); - addKeyValueNode( QObject::tr( "Cache (control)" ), QgsNetworkLoggerRequestGroup::cacheControlToString( static_cast< QNetworkRequest::CacheLoadControl >( request.request().attribute( QNetworkRequest::CacheLoadControlAttribute ).toInt() ) ) ); + addKeyValueNode( QObject::tr( "Cache (control)" ), QgsNetworkLoggerRequestGroup::cacheControlToString( static_cast( request.request().attribute( QNetworkRequest::CacheLoadControlAttribute ).toInt() ) ) ); addKeyValueNode( QObject::tr( "Cache (save)" ), request.request().attribute( QNetworkRequest::CacheSaveControlAttribute ).toBool() ? QObject::tr( "Can store result in cache" ) : QObject::tr( "Result cannot be stored in cache" ) ); if ( !QUrlQuery( request.request().url() ).queryItems().isEmpty() ) { - std::unique_ptr< QgsNetworkLoggerRequestQueryGroup > queryGroup = std::make_unique< QgsNetworkLoggerRequestQueryGroup >( request.request().url() ); - mQueryGroup = static_cast< QgsNetworkLoggerRequestQueryGroup * >( addChild( std::move( queryGroup ) ) ); + std::unique_ptr queryGroup = std::make_unique( request.request().url() ); + mQueryGroup = static_cast( addChild( std::move( queryGroup ) ) ); } - std::unique_ptr< QgsNetworkLoggerRequestHeadersGroup > requestHeadersGroup = std::make_unique< QgsNetworkLoggerRequestHeadersGroup >( request ); - mRequestHeaders = static_cast< QgsNetworkLoggerRequestHeadersGroup * >( addChild( std::move( requestHeadersGroup ) ) ); + std::unique_ptr requestHeadersGroup = std::make_unique( request ); + mRequestHeaders = static_cast( addChild( std::move( requestHeadersGroup ) ) ); switch ( request.operation() ) { @@ -408,8 +389,8 @@ QgsNetworkLoggerRequestDetailsGroup::QgsNetworkLoggerRequestDetailsGroup( const case QNetworkAccessManager::PostOperation: case QNetworkAccessManager::PutOperation: { - std::unique_ptr< QgsNetworkLoggerPostContentGroup > postContentGroup = std::make_unique< QgsNetworkLoggerPostContentGroup >( request ); - mPostContent = static_cast< QgsNetworkLoggerPostContentGroup * >( addChild( std::move( postContentGroup ) ) ); + std::unique_ptr postContentGroup = std::make_unique( request ); + mPostContent = static_cast( addChild( std::move( postContentGroup ) ) ); break; } @@ -419,8 +400,8 @@ QgsNetworkLoggerRequestDetailsGroup::QgsNetworkLoggerRequestDetailsGroup( const { if ( !request.content().isEmpty() ) { - std::unique_ptr< QgsNetworkLoggerPostContentGroup > postContentGroup = std::make_unique< QgsNetworkLoggerPostContentGroup >( request ); - mPostContent = static_cast< QgsNetworkLoggerPostContentGroup * >( addChild( std::move( postContentGroup ) ) ); + std::unique_ptr postContentGroup = std::make_unique( request ); + mPostContent = static_cast( addChild( std::move( postContentGroup ) ) ); } break; } @@ -448,9 +429,9 @@ QgsNetworkLoggerRequestQueryGroup::QgsNetworkLoggerRequestQueryGroup( const QUrl : QgsDevToolsModelGroup( QObject::tr( "Query" ) ) { QUrlQuery query( url ); - const QList > queryItems = query.queryItems(); + const QList> queryItems = query.queryItems(); - for ( const QPair< QString, QString > &query : queryItems ) + for ( const QPair &query : queryItems ) { addKeyValueNode( query.first, query.second ); } @@ -491,13 +472,13 @@ QgsNetworkLoggerReplyGroup::QgsNetworkLoggerReplyGroup( const QgsNetworkReplyCon addKeyValueNode( QObject::tr( "Status" ), reply.attribute( QNetworkRequest::HttpStatusCodeAttribute ).toString() ); if ( reply.error() != QNetworkReply::NoError ) { - addKeyValueNode( QObject::tr( "Error Code" ), QString::number( static_cast< int >( reply.error() ) ) ); + addKeyValueNode( QObject::tr( "Error Code" ), QString::number( static_cast( reply.error() ) ) ); addKeyValueNode( QObject::tr( "Error" ), reply.errorString() ); } addKeyValueNode( QObject::tr( "Cache (result)" ), reply.attribute( QNetworkRequest::SourceIsFromCacheAttribute ).toBool() ? QObject::tr( "Used entry from cache" ) : QObject::tr( "Read from network" ) ); - std::unique_ptr< QgsNetworkLoggerReplyHeadersGroup > headersGroup = std::make_unique< QgsNetworkLoggerReplyHeadersGroup >( reply ); - mReplyHeaders = static_cast< QgsNetworkLoggerReplyHeadersGroup * >( addChild( std::move( headersGroup ) ) ); + std::unique_ptr headersGroup = std::make_unique( reply ); + mReplyHeaders = static_cast( addChild( std::move( headersGroup ) ) ); } QVariant QgsNetworkLoggerReplyGroup::toVariant() const diff --git a/src/app/devtools/networklogger/qgsnetworkloggernode.h b/src/app/devtools/networklogger/qgsnetworkloggernode.h index effe28f0babf..f4200063fe06 100644 --- a/src/app/devtools/networklogger/qgsnetworkloggernode.h +++ b/src/app/devtools/networklogger/qgsnetworkloggernode.h @@ -36,7 +36,6 @@ class QAction; class QgsNetworkLoggerRootNode final : public QgsDevToolsModelGroup { public: - QgsNetworkLoggerRootNode(); QVariant data( int role = Qt::DisplayRole ) const override final; @@ -81,14 +80,13 @@ class QgsNetworkLoggerSslErrorGroup; class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup { public: - //! Request statu enum class Status { - Pending, //!< Request underway + Pending, //!< Request underway Complete, //!< Request was successfully completed - Error, //!< Request encountered an error - TimeOut, //!< Request timed out + Error, //!< Request encountered an error + TimeOut, //!< Request timed out Canceled, //!< Request was manually canceled }; @@ -98,7 +96,7 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup */ QgsNetworkLoggerRequestGroup( const QgsNetworkRequestParameters &request ); QVariant data( int role = Qt::DisplayRole ) const override; - QList< QAction * > actions( QObject *parent ) override final; + QList actions( QObject *parent ) override final; QVariant toVariant() const override; /** @@ -126,7 +124,7 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup * * Will automatically create children encapsulating the reply details. */ - void setReply( const QgsNetworkReplyContent &reply ); + void setReply( const QgsNetworkReplyContent &reply ); /** * Flags the reply as having timed out. @@ -159,7 +157,6 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup static QString cacheControlToString( QNetworkRequest::CacheLoadControl control ); private: - QUrl mUrl; int mRequestId = 0; QNetworkAccessManager::Operation mOperation; @@ -175,7 +172,7 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup Status mStatus = Status::Pending; bool mHasSslErrors = false; bool mReplyFromCache = false; - QList< QPair< QString, QString > > mHeaders; + QList> mHeaders; QgsNetworkLoggerRequestDetailsGroup *mDetailsGroup = nullptr; QgsNetworkLoggerReplyGroup *mReplyGroup = nullptr; QgsNetworkLoggerSslErrorGroup *mSslErrorsGroup = nullptr; @@ -213,7 +210,6 @@ class QgsNetworkLoggerPostContentGroup; class QgsNetworkLoggerRequestDetailsGroup final : public QgsDevToolsModelGroup { public: - /** * Constructor for QgsNetworkLoggerRequestDetailsGroup, populated from the * specified \a request details. @@ -222,7 +218,6 @@ class QgsNetworkLoggerRequestDetailsGroup final : public QgsDevToolsModelGroup QVariant toVariant() const override; private: - QgsNetworkLoggerRequestQueryGroup *mQueryGroup = nullptr; QgsNetworkLoggerRequestHeadersGroup *mRequestHeaders = nullptr; QgsNetworkLoggerPostContentGroup *mPostContent = nullptr; @@ -245,13 +240,11 @@ class QgsNetworkLoggerRequestDetailsGroup final : public QgsDevToolsModelGroup class QgsNetworkLoggerRequestHeadersGroup final : public QgsDevToolsModelGroup { public: - /** * Constructor for QgsNetworkLoggerRequestHeadersGroup, populated from the * specified \a request details. */ QgsNetworkLoggerRequestHeadersGroup( const QgsNetworkRequestParameters &request ); - }; @@ -271,13 +264,11 @@ class QgsNetworkLoggerRequestHeadersGroup final : public QgsDevToolsModelGroup class QgsNetworkLoggerRequestQueryGroup final : public QgsDevToolsModelGroup { public: - /** * Constructor for QgsNetworkLoggerRequestQueryGroup, populated from the * specified \a url. */ QgsNetworkLoggerRequestQueryGroup( const QUrl &url ); - }; /** @@ -295,7 +286,6 @@ class QgsNetworkLoggerRequestQueryGroup final : public QgsDevToolsModelGroup class QgsNetworkLoggerPostContentGroup final : public QgsDevToolsModelGroup { public: - /** * Constructor for QgsNetworkLoggerPostContentGroup, populated from the * specified \a request details. @@ -324,7 +314,6 @@ class QgsNetworkLoggerReplyHeadersGroup; class QgsNetworkLoggerReplyGroup final : public QgsDevToolsModelGroup { public: - /** * Constructor for QgsNetworkLoggerReplyGroup, populated from the * specified \a reply details. @@ -333,9 +322,7 @@ class QgsNetworkLoggerReplyGroup final : public QgsDevToolsModelGroup QVariant toVariant() const override; private: - QgsNetworkLoggerReplyHeadersGroup *mReplyHeaders = nullptr; - }; /** @@ -355,13 +342,11 @@ class QgsNetworkLoggerReplyGroup final : public QgsDevToolsModelGroup class QgsNetworkLoggerReplyHeadersGroup final : public QgsDevToolsModelGroup { public: - /** * Constructor for QgsNetworkLoggerReplyHeadersGroup, populated from the * specified \a reply details. */ QgsNetworkLoggerReplyHeadersGroup( const QgsNetworkReplyContent &reply ); - }; /** @@ -381,7 +366,6 @@ class QgsNetworkLoggerReplyHeadersGroup final : public QgsDevToolsModelGroup class QgsNetworkLoggerSslErrorGroup final : public QgsDevToolsModelGroup { public: - /** * Constructor for QgsNetworkLoggerSslErrorGroup, populated from the * specified \a errors. @@ -391,5 +375,4 @@ class QgsNetworkLoggerSslErrorGroup final : public QgsDevToolsModelGroup }; - #endif // QGSNETWORKLOGGERNODE_H diff --git a/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.cpp b/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.cpp index cce84eeb97e7..3fac2140e01f 100644 --- a/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.cpp +++ b/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.cpp @@ -51,22 +51,20 @@ QgsNetworkLoggerTreeView::QgsNetworkLoggerTreeView( QgsNetworkLogger *logger, QW setContextMenuPolicy( Qt::CustomContextMenu ); connect( this, &QgsNetworkLoggerTreeView::customContextMenuRequested, this, &QgsNetworkLoggerTreeView::contextMenu ); - connect( verticalScrollBar(), &QAbstractSlider::sliderMoved, this, [this]( int value ) - { + connect( verticalScrollBar(), &QAbstractSlider::sliderMoved, this, [this]( int value ) { if ( value == verticalScrollBar()->maximum() ) mAutoScroll = true; else mAutoScroll = false; } ); - connect( mLogger, &QAbstractItemModel::rowsInserted, this, [ = ] - { + connect( mLogger, &QAbstractItemModel::rowsInserted, this, [=] { if ( mLogger->rowCount() > ( QgsNetworkLogger::MAX_LOGGED_REQUESTS * 1.2 ) ) // 20 % more as buffer { // never trim expanded nodes const int toTrim = mLogger->rowCount() - QgsNetworkLogger::MAX_LOGGED_REQUESTS; int trimmed = 0; - QList< int > rowsToTrim; + QList rowsToTrim; rowsToTrim.reserve( toTrim ); for ( int i = 0; i < mLogger->rowCount(); ++i ) { @@ -132,7 +130,7 @@ void QgsNetworkLoggerTreeView::contextMenu( QPoint point ) { mMenu->clear(); - const QList< QAction * > actions = mLogger->actions( modelIndex, mMenu ); + const QList actions = mLogger->actions( modelIndex, mMenu ); mMenu->addActions( actions ); if ( !mMenu->actions().empty() ) { @@ -185,15 +183,12 @@ QgsNetworkLoggerPanelWidget::QgsNetworkLoggerPanelWidget( QgsNetworkLogger *logg connect( mActionShowSuccessful, &QAction::toggled, mTreeView, &QgsNetworkLoggerTreeView::setShowSuccessful ); connect( mActionShowCached, &QAction::toggled, mTreeView, &QgsNetworkLoggerTreeView::setShowCached ); connect( mActionClear, &QAction::triggered, mLogger, &QgsNetworkLogger::clear ); - connect( mActionRecord, &QAction::toggled, this, [ = ]( bool enabled ) - { + connect( mActionRecord, &QAction::toggled, this, [=]( bool enabled ) { QgsSettings().setValue( QStringLiteral( "logNetworkRequests" ), enabled, QgsSettings::App ); mLogger->enableLogging( enabled ); } ); - connect( mActionSaveLog, &QAction::triggered, this, [ = ]() - { - if ( QMessageBox::warning( this, tr( "Save Network Log" ), - tr( "Security warning: network logs may contain sensitive data including usernames or passwords. Treat this log as confidential and be careful who you share it with. Continue?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No ) + connect( mActionSaveLog, &QAction::triggered, this, [=]() { + if ( QMessageBox::warning( this, tr( "Save Network Log" ), tr( "Security warning: network logs may contain sensitive data including usernames or passwords. Treat this log as confidential and be careful who you share it with. Continue?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No ) return; const QString saveFilePath = QFileDialog::getSaveFileName( this, tr( "Save Network Log" ), QDir::homePath(), tr( "Log files" ) + " (*.json)" ); @@ -231,8 +226,7 @@ QgsNetworkLoggerPanelWidget::QgsNetworkLoggerPanelWidget( QgsNetworkLogger *logg mToolbar->addSeparator(); QCheckBox *disableCacheCheck = new QCheckBox( tr( "Disable cache" ) ); - connect( disableCacheCheck, &QCheckBox::toggled, this, [ = ]( bool checked ) - { + connect( disableCacheCheck, &QCheckBox::toggled, this, [=]( bool checked ) { // note -- we deliberately do NOT store this as a permanent setting in QSettings // as it is designed to be a temporary debugging tool only and we don't want // users to accidentally leave this enabled and cause unnecessary server load... diff --git a/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.h b/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.h index a4061007f262..e152c2c2e617 100644 --- a/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.h +++ b/src/app/devtools/networklogger/qgsnetworkloggerpanelwidget.h @@ -29,11 +29,10 @@ class QgsNetworkLoggerProxyModel; * * \since QGIS 3.14 */ -class QgsNetworkLoggerTreeView: public QTreeView +class QgsNetworkLoggerTreeView : public QTreeView { Q_OBJECT public: - /** * Constructor for QgsNetworkLoggerTreeView, attached to the specified \a logger. */ @@ -66,7 +65,6 @@ class QgsNetworkLoggerTreeView: public QTreeView void contextMenu( QPoint point ); private: - void expandChildren( const QModelIndex &index ); QMenu *mMenu = nullptr; QgsNetworkLogger *mLogger = nullptr; @@ -87,14 +85,12 @@ class QgsNetworkLoggerPanelWidget : public QgsDevToolWidget, private Ui::QgsNetw Q_OBJECT public: - /** * Constructor for QgsNetworkLoggerPanelWidget, linked with the specified \a logger. */ QgsNetworkLoggerPanelWidget( QgsNetworkLogger *logger, QWidget *parent ); private: - QgsNetworkLoggerTreeView *mTreeView = nullptr; QgsNetworkLogger *mLogger = nullptr; }; diff --git a/src/app/devtools/networklogger/qgsnetworkloggerwidgetfactory.h b/src/app/devtools/networklogger/qgsnetworkloggerwidgetfactory.h index ebb916c1fbc1..fee42613af6f 100644 --- a/src/app/devtools/networklogger/qgsnetworkloggerwidgetfactory.h +++ b/src/app/devtools/networklogger/qgsnetworkloggerwidgetfactory.h @@ -19,15 +19,13 @@ class QgsNetworkLogger; -class QgsNetworkLoggerWidgetFactory: public QgsDevToolWidgetFactory +class QgsNetworkLoggerWidgetFactory : public QgsDevToolWidgetFactory { public: - QgsNetworkLoggerWidgetFactory( QgsNetworkLogger *logger ); QgsDevToolWidget *createWidget( QWidget *parent = nullptr ) const override; private: - QgsNetworkLogger *mLogger = nullptr; }; diff --git a/src/app/devtools/profiler/qgsprofilerpanelwidget.cpp b/src/app/devtools/profiler/qgsprofilerpanelwidget.cpp index 8e39a04a568f..20645fcfa020 100644 --- a/src/app/devtools/profiler/qgsprofilerpanelwidget.cpp +++ b/src/app/devtools/profiler/qgsprofilerpanelwidget.cpp @@ -39,10 +39,9 @@ QgsProfilerPanelWidget::QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QW //mTreeView->resizeColumnToContents( 0 ); //mTreeView->resizeColumnToContents( 1 ); - mTreeView->setItemDelegateForColumn( 1, new CostDelegate( static_cast< int >( QgsRuntimeProfilerNode::CustomRole::Elapsed ), static_cast< int >( QgsRuntimeProfilerNode::CustomRole::ParentElapsed ), mTreeView ) ); + mTreeView->setItemDelegateForColumn( 1, new CostDelegate( static_cast( QgsRuntimeProfilerNode::CustomRole::Elapsed ), static_cast( QgsRuntimeProfilerNode::CustomRole::ParentElapsed ), mTreeView ) ); - connect( mProfiler, &QgsRuntimeProfiler::groupAdded, this, [ = ]( const QString & group ) - { + connect( mProfiler, &QgsRuntimeProfiler::groupAdded, this, [=]( const QString &group ) { mCategoryComboBox->addItem( QgsRuntimeProfiler::translateGroupName( group ).isEmpty() ? group : QgsRuntimeProfiler::translateGroupName( group ), group ); if ( mCategoryComboBox->count() == 1 ) { @@ -51,8 +50,7 @@ QgsProfilerPanelWidget::QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QW } } ); - connect( mCategoryComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int ) - { + connect( mCategoryComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { mProxyModel->setGroup( mCategoryComboBox->currentData().toString() ); } ); @@ -88,7 +86,7 @@ void QgsProfilerProxyModel::setGroup( const QString &group ) bool QgsProfilerProxyModel::filterAcceptsRow( int row, const QModelIndex &source_parent ) const { const QModelIndex index = sourceModel()->index( row, 0, source_parent ); - return sourceModel()->data( index, static_cast< int >( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString() == mGroup; + return sourceModel()->data( index, static_cast( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString() == mGroup; } @@ -154,4 +152,3 @@ void CostDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, QStyledItemDelegate::paint( painter, option, index ); } } - diff --git a/src/app/devtools/profiler/qgsprofilerpanelwidget.h b/src/app/devtools/profiler/qgsprofilerpanelwidget.h index 402c2ea00ba2..abf6c68cd923 100644 --- a/src/app/devtools/profiler/qgsprofilerpanelwidget.h +++ b/src/app/devtools/profiler/qgsprofilerpanelwidget.h @@ -28,7 +28,6 @@ class QgsProfilerProxyModel : public QSortFilterProxyModel Q_OBJECT public: - QgsProfilerProxyModel( QgsRuntimeProfiler *profiler, QObject *parent ); void setGroup( const QString &group ); @@ -37,11 +36,7 @@ class QgsProfilerProxyModel : public QSortFilterProxyModel bool filterAcceptsRow( int row, const QModelIndex &source_parent ) const override; private: - QString mGroup; - - - }; /** @@ -56,17 +51,14 @@ class QgsProfilerPanelWidget : public QgsDevToolWidget, private Ui::QgsProfilerP Q_OBJECT public: - /** * Constructor for QgsProfilerPanelWidget. */ QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QWidget *parent ); private: - QgsRuntimeProfiler *mProfiler = nullptr; QgsProfilerProxyModel *mProxyModel = nullptr; - }; // adapted from KDAB's "hotspot" diff --git a/src/app/devtools/profiler/qgsprofilerwidgetfactory.h b/src/app/devtools/profiler/qgsprofilerwidgetfactory.h index de5ba6ed42b8..8c6ba8aaea7b 100644 --- a/src/app/devtools/profiler/qgsprofilerwidgetfactory.h +++ b/src/app/devtools/profiler/qgsprofilerwidgetfactory.h @@ -19,17 +19,14 @@ class QgsRuntimeProfiler; -class QgsProfilerWidgetFactory: public QgsDevToolWidgetFactory +class QgsProfilerWidgetFactory : public QgsDevToolWidgetFactory { public: - QgsProfilerWidgetFactory( QgsRuntimeProfiler *profiler ); QgsDevToolWidget *createWidget( QWidget *parent = nullptr ) const override; private: - QgsRuntimeProfiler *mProfiler = nullptr; - }; diff --git a/src/app/devtools/qgsappdevtoolutils.h b/src/app/devtools/qgsappdevtoolutils.h index d4027b4c0fce..650a5aac3c99 100644 --- a/src/app/devtools/qgsappdevtoolutils.h +++ b/src/app/devtools/qgsappdevtoolutils.h @@ -33,10 +33,10 @@ class QgsScopedDevToolWidgetFactory QgsScopedDevToolWidgetFactory(); ~QgsScopedDevToolWidgetFactory(); - void reset( std::unique_ptr< QgsDevToolWidgetFactory > factory = nullptr ); + void reset( std::unique_ptr factory = nullptr ); private: - std::unique_ptr< QgsDevToolWidgetFactory > mFactory; + std::unique_ptr mFactory; }; diff --git a/src/app/devtools/qgsdevtoolsmodelnode.cpp b/src/app/devtools/qgsdevtoolsmodelnode.cpp index b7088ecd2388..762713691f3b 100644 --- a/src/app/devtools/qgsdevtoolsmodelnode.cpp +++ b/src/app/devtools/qgsdevtoolsmodelnode.cpp @@ -39,7 +39,7 @@ QVariant QgsDevToolsModelNode::toVariant() const QList QgsDevToolsModelNode::actions( QObject * ) { - return QList< QAction * >(); + return QList(); } @@ -66,8 +66,7 @@ QgsDevToolsModelNode *QgsDevToolsModelGroup::addChild( std::unique_ptrmParent == this ); - auto it = std::find_if( mChildren.begin(), mChildren.end(), [&]( const std::unique_ptr &p ) - { + auto it = std::find_if( mChildren.begin(), mChildren.end(), [&]( const std::unique_ptr &p ) { return p.get() == child; } ); if ( it != mChildren.end() ) @@ -77,8 +76,8 @@ int QgsDevToolsModelGroup::indexOf( QgsDevToolsModelNode *child ) const QgsDevToolsModelNode *QgsDevToolsModelGroup::childAt( int index ) { - Q_ASSERT( static_cast< std::size_t >( index ) < mChildren.size() ); - return mChildren[ index ].get(); + Q_ASSERT( static_cast( index ) < mChildren.size() ); + return mChildren[index].get(); } void QgsDevToolsModelGroup::clear() @@ -102,9 +101,9 @@ QVariant QgsDevToolsModelGroup::data( int role ) const QVariant QgsDevToolsModelGroup::toVariant() const { QVariantMap res; - for ( const std::unique_ptr< QgsDevToolsModelNode > &child : mChildren ) + for ( const std::unique_ptr &child : mChildren ) { - if ( const QgsDevToolsModelValueNode *valueNode = dynamic_cast< const QgsDevToolsModelValueNode *>( child.get() ) ) + if ( const QgsDevToolsModelValueNode *valueNode = dynamic_cast( child.get() ) ) { res.insert( valueNode->key(), valueNode->value() ); } @@ -121,7 +120,6 @@ QgsDevToolsModelValueNode::QgsDevToolsModelValueNode( const QString &key, const , mValue( value ) , mColor( color ) { - } QVariant QgsDevToolsModelValueNode::data( int role ) const @@ -148,11 +146,10 @@ QVariant QgsDevToolsModelValueNode::data( int role ) const QList QgsDevToolsModelValueNode::actions( QObject *parent ) { - QList< QAction * > res; + QList res; QAction *copyAction = new QAction( QObject::tr( "Copy" ), parent ); - QObject::connect( copyAction, &QAction::triggered, copyAction, [ = ] - { + QObject::connect( copyAction, &QAction::triggered, copyAction, [=] { QApplication::clipboard()->setText( QStringLiteral( "%1: %2" ).arg( mKey, mValue ) ); } ); @@ -167,6 +164,5 @@ QList QgsDevToolsModelValueNode::actions( QObject *parent ) void QgsDevToolsModelGroup::addKeyValueNode( const QString &key, const QString &value, const QColor &color ) { - addChild( std::make_unique< QgsDevToolsModelValueNode >( key, value, color ) ); + addChild( std::make_unique( key, value, color ) ); } - diff --git a/src/app/devtools/qgsdevtoolsmodelnode.h b/src/app/devtools/qgsdevtoolsmodelnode.h index 328cb936301a..7a3396e6d0f4 100644 --- a/src/app/devtools/qgsdevtoolsmodelnode.h +++ b/src/app/devtools/qgsdevtoolsmodelnode.h @@ -33,15 +33,14 @@ class QgsDevToolsModelGroup; class QgsDevToolsModelNode { public: - //! Custom node data roles enum Roles { RoleStatus = Qt::UserRole + 1, //!< Request status role - RoleId, //!< Request ID role - RoleElapsedTime, //!< Elapsed time - RoleMaximumTime, //!< Maximum encountered elapsed time - RoleSort, //!< Sort order role + RoleId, //!< Request ID role + RoleElapsedTime, //!< Elapsed time + RoleMaximumTime, //!< Maximum encountered elapsed time + RoleSort, //!< Sort order role }; virtual ~QgsDevToolsModelNode(); @@ -68,7 +67,7 @@ class QgsDevToolsModelNode * * The actions should be parented to \a parent. */ - virtual QList< QAction * > actions( QObject *parent ); + virtual QList actions( QObject *parent ); /** * Converts the node's contents to a variant. @@ -76,11 +75,9 @@ class QgsDevToolsModelNode virtual QVariant toVariant() const; protected: - QgsDevToolsModelNode(); private: - QgsDevToolsModelGroup *mParent = nullptr; friend class QgsDevToolsModelGroup; }; @@ -93,13 +90,12 @@ class QgsDevToolsModelNode class QgsDevToolsModelGroup : public QgsDevToolsModelNode { public: - /** * Adds a \a child node to this node. * * Returns a pointer to the newly added node. */ - QgsDevToolsModelNode *addChild( std::unique_ptr< QgsDevToolsModelNode > child ); + QgsDevToolsModelNode *addChild( std::unique_ptr child ); /** * Returns the index of the specified \a child node. @@ -123,7 +119,6 @@ class QgsDevToolsModelGroup : public QgsDevToolsModelNode QVariant toVariant() const override; protected: - /** * Constructor for a QgsDevToolsModelGroup, with the specified \a title. */ @@ -135,12 +130,10 @@ class QgsDevToolsModelGroup : public QgsDevToolsModelNode void addKeyValueNode( const QString &key, const QString &value, const QColor &color = QColor() ); protected: - std::deque< std::unique_ptr< QgsDevToolsModelNode > > mChildren; + std::deque> mChildren; private: - QString mGroupTitle; - }; /** @@ -151,7 +144,6 @@ class QgsDevToolsModelGroup : public QgsDevToolsModelNode class QgsDevToolsModelValueNode : public QgsDevToolsModelNode { public: - /** * Constructor for QgsDevToolsModelValueNode, with the specified \a key (usually translated) and \a value. */ @@ -169,10 +161,9 @@ class QgsDevToolsModelValueNode : public QgsDevToolsModelNode QVariant data( int role = Qt::DisplayRole ) const override final; int childCount() const override final { return 0; } - QList< QAction * > actions( QObject *parent ) override final; + QList actions( QObject *parent ) override final; private: - QString mKey; QString mValue; QColor mColor; diff --git a/src/app/devtools/querylogger/qgsappquerylogger.cpp b/src/app/devtools/querylogger/qgsappquerylogger.cpp index 6477ce5e922d..a112ab640f47 100644 --- a/src/app/devtools/querylogger/qgsappquerylogger.cpp +++ b/src/app/devtools/querylogger/qgsappquerylogger.cpp @@ -27,7 +27,7 @@ QgsAppQueryLogger::QgsAppQueryLogger( QObject *parent ) : QAbstractItemModel( parent ) - , mRootNode( std::make_unique< QgsDatabaseQueryLoggerRootNode >() ) + , mRootNode( std::make_unique() ) { // logger must be created on the main thread Q_ASSERT( QThread::currentThread() == QApplication::instance()->thread() ); @@ -53,7 +53,7 @@ void QgsAppQueryLogger::queryLogged( const QgsDatabaseQueryLogEntry &query ) beginInsertRows( QModelIndex(), childCount, childCount ); - std::unique_ptr< QgsDatabaseQueryLoggerQueryGroup > group = std::make_unique< QgsDatabaseQueryLoggerQueryGroup >( query ); + std::unique_ptr group = std::make_unique( query ); mQueryGroups.insert( query.queryId, group.get() ); mRootNode->addChild( std::move( group ) ); endInsertRows(); @@ -75,7 +75,7 @@ void QgsAppQueryLogger::queryFinished( const QgsDatabaseQueryLogEntry &query ) queryGroup->setSql( query.query ); } - const long long newMaxCost = std::max< long long >( static_cast< long long >( query.finishedTime - query.startedTime ), mMaxCost ); + const long long newMaxCost = std::max( static_cast( query.finishedTime - query.startedTime ), mMaxCost ); // Calculate the number of children: if error or not fetched rows 1 row is added else 2 rows are added beginInsertRows( requestIndex, queryGroup->childCount(), queryGroup->childCount() + ( query.fetchedRows != -1 ? 1 : 0 ) ); @@ -103,7 +103,7 @@ QList QgsAppQueryLogger::actions( const QModelIndex &index, QObject * { QgsDevToolsModelNode *node = index2node( index ); if ( !node ) - return QList< QAction * >(); + return QList(); return node->actions( parent ); } @@ -126,7 +126,7 @@ QModelIndex QgsAppQueryLogger::indexOfParentLayerTreeNode( QgsDevToolsModelNode QgsDevToolsModelGroup *grandParentNode = parentNode->parent(); if ( !grandParentNode ) - return QModelIndex(); // root node -> invalid index + return QModelIndex(); // root node -> invalid index int row = grandParentNode->indexOf( parentNode ); Q_ASSERT( row >= 0 ); @@ -136,8 +136,8 @@ QModelIndex QgsAppQueryLogger::indexOfParentLayerTreeNode( QgsDevToolsModelNode void QgsAppQueryLogger::removeRequestRows( const QList &rows ) { - QList< int > res = rows; - std::sort( res.begin(), res.end(), std::greater< int >() ); + QList res = rows; + std::sort( res.begin(), res.end(), std::greater() ); for ( int row : std::as_const( res ) ) { @@ -172,11 +172,10 @@ int QgsAppQueryLogger::columnCount( const QModelIndex &parent ) const QModelIndex QgsAppQueryLogger::index( int row, int column, const QModelIndex &parent ) const { - if ( column < 0 || column >= columnCount( parent ) || - row < 0 || row >= rowCount( parent ) ) + if ( column < 0 || column >= columnCount( parent ) || row < 0 || row >= rowCount( parent ) ) return QModelIndex(); - QgsDevToolsModelGroup *n = dynamic_cast< QgsDevToolsModelGroup * >( index2node( parent ) ); + QgsDevToolsModelGroup *n = dynamic_cast( index2node( parent ) ); if ( !n ) return QModelIndex(); // have no children @@ -281,10 +280,10 @@ void QgsDatabaseQueryLoggerProxyModel::setFilterString( const QString &string ) bool QgsDatabaseQueryLoggerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const { - if ( ! mFilterString.isEmpty() ) + if ( !mFilterString.isEmpty() ) { QgsDevToolsModelNode *node = mLogger->index2node( mLogger->index( source_row, 0, source_parent ) ); - if ( QgsDatabaseQueryLoggerQueryGroup *request = dynamic_cast< QgsDatabaseQueryLoggerQueryGroup * >( node ) ) + if ( QgsDatabaseQueryLoggerQueryGroup *request = dynamic_cast( node ) ) { if ( request->data().toString().contains( mFilterString, Qt::CaseInsensitive ) ) { @@ -329,7 +328,7 @@ void QueryCostDelegate::paint( QPainter *painter, const QStyleOptionViewItem &op const auto fraction = std::abs( float( cost ) / totalCost ); auto rect = option.rect; - rect.setWidth( static_cast< int >( rect.width() * fraction ) ); + rect.setWidth( static_cast( rect.width() * fraction ) ); const auto &brush = painter->brush(); const auto &pen = painter->pen(); @@ -344,7 +343,7 @@ void QueryCostDelegate::paint( QPainter *painter, const QStyleOptionViewItem &op painter->drawRect( option.rect ); } - const auto color = QColor::fromHsv( static_cast< int >( 120 - fraction * 120 ), 255, 255, static_cast< int >( ( -( ( fraction - 1 ) * ( fraction - 1 ) ) ) * 120 + 120 ) ); + const auto color = QColor::fromHsv( static_cast( 120 - fraction * 120 ), 255, 255, static_cast( ( -( ( fraction - 1 ) * ( fraction - 1 ) ) ) * 120 + 120 ) ); painter->setBrush( color ); painter->drawRect( rect ); diff --git a/src/app/devtools/querylogger/qgsappquerylogger.h b/src/app/devtools/querylogger/qgsappquerylogger.h index 6033bc349f3f..c1b758e0bb05 100644 --- a/src/app/devtools/querylogger/qgsappquerylogger.h +++ b/src/app/devtools/querylogger/qgsappquerylogger.h @@ -39,7 +39,6 @@ class QgsAppQueryLogger : public QAbstractItemModel Q_OBJECT public: - /** * Constructor for QgsAppQueryLogger, logging requests from the specified \a manager. * @@ -68,12 +67,12 @@ class QgsAppQueryLogger : public QAbstractItemModel * * The actions should be parented to \a parent. */ - QList< QAction * > actions( const QModelIndex &index, QObject *parent ); + QList actions( const QModelIndex &index, QObject *parent ); /** * Removes a list of request \a rows from the log. */ - void removeRequestRows( const QList< int > &rows ); + void removeRequestRows( const QList &rows ); /** * Returns the root node of the log. @@ -94,16 +93,14 @@ class QgsAppQueryLogger : public QAbstractItemModel void queryFinished( const QgsDatabaseQueryLogEntry &query ); private: - //! Returns index for a given node QModelIndex node2index( QgsDevToolsModelNode *node ) const; QModelIndex indexOfParentLayerTreeNode( QgsDevToolsModelNode *parentNode ) const; - std::unique_ptr< QgsDatabaseQueryLoggerRootNode > mRootNode; + std::unique_ptr mRootNode; long long mMaxCost = 0; - QHash< int, QgsDatabaseQueryLoggerQueryGroup * > mQueryGroups; - + QHash mQueryGroups; }; /** @@ -116,7 +113,6 @@ class QgsDatabaseQueryLoggerProxyModel : public QSortFilterProxyModel { Q_OBJECT public: - /** * Constructor for QgsDatabaseQueryLoggerProxyModel, filtering the specified network \a logger. */ @@ -131,7 +127,6 @@ class QgsDatabaseQueryLoggerProxyModel : public QSortFilterProxyModel bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override; private: - QgsAppQueryLogger *mLogger = nullptr; QString mFilterString; diff --git a/src/app/devtools/querylogger/qgsdatabasequeryloggernode.cpp b/src/app/devtools/querylogger/qgsdatabasequeryloggernode.cpp index 68158cec2ff9..15eb4eb76bca 100644 --- a/src/app/devtools/querylogger/qgsdatabasequeryloggernode.cpp +++ b/src/app/devtools/querylogger/qgsdatabasequeryloggernode.cpp @@ -34,7 +34,6 @@ QgsDatabaseQueryLoggerRootNode::QgsDatabaseQueryLoggerRootNode() : QgsDevToolsModelGroup( QString() ) { - } QVariant QgsDatabaseQueryLoggerRootNode::data( int ) const @@ -50,7 +49,7 @@ void QgsDatabaseQueryLoggerRootNode::removeRow( int row ) QVariant QgsDatabaseQueryLoggerRootNode::toVariant() const { QVariantList res; - for ( const std::unique_ptr< QgsDevToolsModelNode > &child : mChildren ) + for ( const std::unique_ptr &child : mChildren ) res << child->toVariant(); return res; } @@ -80,7 +79,6 @@ QgsDatabaseQueryLoggerQueryGroup::QgsDatabaseQueryLoggerQueryGroup( const QgsDat addKeyValueNode( QObject::tr( "Initiator" ), query.initiatorClass.isEmpty() ? QObject::tr( "unknown" ) : query.initiatorClass ); if ( !query.origin.isEmpty() ) addKeyValueNode( QObject::tr( "Location" ), query.origin ); - } QVariant QgsDatabaseQueryLoggerQueryGroup::data( int role ) const @@ -88,8 +86,7 @@ QVariant QgsDatabaseQueryLoggerQueryGroup::data( int role ) const switch ( role ) { case Qt::DisplayRole: - return QStringLiteral( "%1 %2" ).arg( QString::number( mQueryId ), - mSql ); + return QStringLiteral( "%1 %2" ).arg( QString::number( mQueryId ), mSql ); case QgsDevToolsModelNode::RoleSort: return mQueryId; @@ -122,7 +119,7 @@ QVariant QgsDatabaseQueryLoggerQueryGroup::data( int role ) const } case RoleStatus: - return static_cast< int >( mStatus ); + return static_cast( mStatus ); case RoleId: return mQueryId; @@ -161,27 +158,24 @@ QVariant QgsDatabaseQueryLoggerQueryGroup::data( int role ) const default: break; } - return QVariant( ); + return QVariant(); } QList QgsDatabaseQueryLoggerQueryGroup::actions( QObject *parent ) { - QList< QAction * > res; + QList res; QAction *copyUrlAction = new QAction( QObject::tr( "Copy SQL" ), parent ); - QObject::connect( copyUrlAction, &QAction::triggered, copyUrlAction, [ = ] - { + QObject::connect( copyUrlAction, &QAction::triggered, copyUrlAction, [=] { QApplication::clipboard()->setText( mSql ); } ); res << copyUrlAction; QAction *copyJsonAction = new QAction( QObject::tr( "Copy as JSON" ), parent ); - QObject::connect( copyJsonAction, &QAction::triggered, copyJsonAction, [ = ] - { + QObject::connect( copyJsonAction, &QAction::triggered, copyJsonAction, [=] { const QVariant value = toVariant(); const QString json = QString::fromStdString( QgsJsonUtils::jsonFromVariant( value ).dump( 2 ) ); QApplication::clipboard()->setText( json ); - } ); res << copyJsonAction; @@ -195,7 +189,7 @@ QVariant QgsDatabaseQueryLoggerQueryGroup::toVariant() const for ( const auto &child : std::as_const( mChildren ) ) { - if ( const QgsDevToolsModelValueNode *valueNode = dynamic_cast< const QgsDevToolsModelValueNode *>( child.get() ) ) + if ( const QgsDevToolsModelValueNode *valueNode = dynamic_cast( child.get() ) ) { res.insert( valueNode->key(), valueNode->value() ); } @@ -254,5 +248,3 @@ const QString &QgsDatabaseQueryLoggerQueryGroup::sql() const { return mSql; } - - diff --git a/src/app/devtools/querylogger/qgsdatabasequeryloggernode.h b/src/app/devtools/querylogger/qgsdatabasequeryloggernode.h index 07bc5e97ef7d..58c68f9a5517 100644 --- a/src/app/devtools/querylogger/qgsdatabasequeryloggernode.h +++ b/src/app/devtools/querylogger/qgsdatabasequeryloggernode.h @@ -34,7 +34,6 @@ class QAction; class QgsDatabaseQueryLoggerRootNode final : public QgsDevToolsModelGroup { public: - QgsDatabaseQueryLoggerRootNode(); QVariant data( int role = Qt::DisplayRole ) const override final; @@ -62,14 +61,13 @@ class QgsDatabaseQueryLoggerRootNode final : public QgsDevToolsModelGroup class QgsDatabaseQueryLoggerQueryGroup final : public QgsDevToolsModelGroup { public: - //! Query status enum class Status { - Pending, //!< Query underway + Pending, //!< Query underway Complete, //!< Query was successfully completed - Error, //!< Query encountered an error - TimeOut, //!< Query timed out + Error, //!< Query encountered an error + TimeOut, //!< Query timed out Canceled, //!< Query was manually canceled }; @@ -79,7 +77,7 @@ class QgsDatabaseQueryLoggerQueryGroup final : public QgsDevToolsModelGroup */ QgsDatabaseQueryLoggerQueryGroup( const QgsDatabaseQueryLogEntry &query ); QVariant data( int role = Qt::DisplayRole ) const override; - QList< QAction * > actions( QObject *parent ) override final; + QList actions( QObject *parent ) override final; QVariant toVariant() const override; /** @@ -87,7 +85,7 @@ class QgsDatabaseQueryLoggerQueryGroup final : public QgsDevToolsModelGroup * * Will automatically create children encapsulating the completed details. */ - void setFinished( const QgsDatabaseQueryLogEntry &query ); + void setFinished( const QgsDatabaseQueryLogEntry &query ); /** * Returns the query's status. @@ -115,7 +113,6 @@ class QgsDatabaseQueryLoggerQueryGroup final : public QgsDevToolsModelGroup const QString &sql() const; private: - QString mSql; int mQueryId = 0; QByteArray mData; diff --git a/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.cpp b/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.cpp index 352f37d7fb08..57ee9c8ab094 100644 --- a/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.cpp +++ b/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.cpp @@ -50,8 +50,7 @@ QgsDatabaseQueryLoggerTreeView::QgsDatabaseQueryLoggerTreeView( QgsAppQueryLogge mProxyModel->setSortRole( QgsDevToolsModelNode::RoleSort ); setModel( mProxyModel ); - connect( mProxyModel, &QAbstractItemModel::rowsInserted, this, [this]( const QModelIndex & parent, int first, int last ) - { + connect( mProxyModel, &QAbstractItemModel::rowsInserted, this, [this]( const QModelIndex &parent, int first, int last ) { // we want all second level items to be spanned for ( int row = first; row <= last; ++row ) { @@ -68,22 +67,20 @@ QgsDatabaseQueryLoggerTreeView::QgsDatabaseQueryLoggerTreeView( QgsAppQueryLogge setContextMenuPolicy( Qt::CustomContextMenu ); connect( this, &QgsDatabaseQueryLoggerTreeView::customContextMenuRequested, this, &QgsDatabaseQueryLoggerTreeView::contextMenu ); - connect( verticalScrollBar(), &QAbstractSlider::sliderMoved, this, [this]( int value ) - { + connect( verticalScrollBar(), &QAbstractSlider::sliderMoved, this, [this]( int value ) { if ( value == verticalScrollBar()->maximum() ) mAutoScroll = true; else mAutoScroll = false; } ); - connect( mLogger, &QAbstractItemModel::rowsInserted, this, [ = ] - { + connect( mLogger, &QAbstractItemModel::rowsInserted, this, [=] { if ( mLogger->rowCount() > ( QgsAppQueryLogger::MAX_LOGGED_REQUESTS * 1.2 ) ) // 20 % more as buffer { // never trim expanded nodes const int toTrim = mLogger->rowCount() - QgsAppQueryLogger::MAX_LOGGED_REQUESTS; int trimmed = 0; - QList< int > rowsToTrim; + QList rowsToTrim; rowsToTrim.reserve( toTrim ); for ( int i = 0; i < mLogger->rowCount(); ++i ) { @@ -134,7 +131,7 @@ void QgsDatabaseQueryLoggerTreeView::contextMenu( QPoint point ) { mMenu->clear(); - const QList< QAction * > actions = mLogger->actions( modelIndex, mMenu ); + const QList actions = mLogger->actions( modelIndex, mMenu ); mMenu->addActions( actions ); if ( !mMenu->actions().empty() ) { @@ -185,15 +182,12 @@ QgsDatabaseQueryLoggerPanelWidget::QgsDatabaseQueryLoggerPanelWidget( QgsAppQuer connect( mFilterLineEdit, &QgsFilterLineEdit::textChanged, mTreeView, &QgsDatabaseQueryLoggerTreeView::setFilterString ); connect( mActionClear, &QAction::triggered, mLogger, &QgsAppQueryLogger::clear ); - connect( mActionRecord, &QAction::toggled, this, [ = ]( bool enabled ) - { + connect( mActionRecord, &QAction::toggled, this, [=]( bool enabled ) { QgsSettings().setValue( QStringLiteral( "logDatabaseQueries" ), enabled, QgsSettings::App ); QgsApplication::databaseQueryLog()->setEnabled( enabled ); } ); - connect( mActionSaveLog, &QAction::triggered, this, [ = ]() - { - if ( QMessageBox::warning( this, tr( "Save Database Query Log" ), - tr( "Security warning: query logs may contain sensitive data including usernames or passwords. Treat this log as confidential and be careful who you share it with. Continue?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No ) + connect( mActionSaveLog, &QAction::triggered, this, [=]() { + if ( QMessageBox::warning( this, tr( "Save Database Query Log" ), tr( "Security warning: query logs may contain sensitive data including usernames or passwords. Treat this log as confidential and be careful who you share it with. Continue?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No ) return; const QString saveFilePath = QFileDialog::getSaveFileName( this, tr( "Save Query Log" ), QDir::homePath(), tr( "Log files" ) + " (*.json)" ); diff --git a/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.h b/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.h index 380f66f55a36..af820f59cd21 100644 --- a/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.h +++ b/src/app/devtools/querylogger/qgsqueryloggerpanelwidget.h @@ -27,11 +27,10 @@ class QgsDatabaseQueryLoggerProxyModel; * \class QgsDatabaseQueryLoggerTreeView * \brief A custom QTreeView subclass for showing logged database queries. */ -class QgsDatabaseQueryLoggerTreeView: public QTreeView +class QgsDatabaseQueryLoggerTreeView : public QTreeView { Q_OBJECT public: - /** * Constructor for QgsDatabaseQueryLoggerTreeView, attached to the specified \a logger. */ @@ -49,7 +48,6 @@ class QgsDatabaseQueryLoggerTreeView: public QTreeView void contextMenu( QPoint point ); private: - void expandChildren( const QModelIndex &index ); QMenu *mMenu = nullptr; QgsAppQueryLogger *mLogger = nullptr; @@ -68,14 +66,13 @@ class QgsDatabaseQueryLoggerPanelWidget : public QgsDevToolWidget, private Ui::Q Q_OBJECT public: - /** * Constructor for QgsDatabaseQueryLoggerPanelWidget, linked with the specified \a logger. */ QgsDatabaseQueryLoggerPanelWidget( QgsAppQueryLogger *logger, QWidget *parent ); ~QgsDatabaseQueryLoggerPanelWidget() override; - private: + private: QgsDatabaseQueryLoggerTreeView *mTreeView = nullptr; QgsAppQueryLogger *mLogger = nullptr; }; diff --git a/src/app/devtools/querylogger/qgsqueryloggerwidgetfactory.h b/src/app/devtools/querylogger/qgsqueryloggerwidgetfactory.h index fcb22810fd3b..0159396cd005 100644 --- a/src/app/devtools/querylogger/qgsqueryloggerwidgetfactory.h +++ b/src/app/devtools/querylogger/qgsqueryloggerwidgetfactory.h @@ -19,15 +19,13 @@ class QgsAppQueryLogger; -class QgsDatabaseQueryLoggerWidgetFactory: public QgsDevToolWidgetFactory +class QgsDatabaseQueryLoggerWidgetFactory : public QgsDevToolWidgetFactory { public: - QgsDatabaseQueryLoggerWidgetFactory( QgsAppQueryLogger *logger ); QgsDevToolWidget *createWidget( QWidget *parent = nullptr ) const override; private: - QgsAppQueryLogger *mLogger = nullptr; }; diff --git a/src/app/dwg/qgsdwgimportdialog.cpp b/src/app/dwg/qgsdwgimportdialog.cpp index 68252641c40f..8d4cbc1ccae4 100644 --- a/src/app/dwg/qgsdwgimportdialog.cpp +++ b/src/app/dwg/qgsdwgimportdialog.cpp @@ -99,7 +99,7 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f ) mPanTool = new QgsMapToolPan( mMapCanvas ); mMapCanvas->setMapTool( mPanTool ); - if ( ! QgsVectorFileWriter::supportedFormatExtensions().contains( QStringLiteral( "gpkg" ) ) ) + if ( !QgsVectorFileWriter::supportedFormatExtensions().contains( QStringLiteral( "gpkg" ) ) ) { bar->pushMessage( tr( "GDAL/OGR not built with GPKG (sqlite3) support. You will not be able to export the DWG in a GPKG." ), Qgis::MessageLevel::Critical ); } @@ -162,8 +162,7 @@ void QgsDwgImportDialog::drawingFileWidgetFileChanged( const QString &filename ) if ( fileInfoSourceDrawing.exists() ) { - QFileInfo fileInfoTargetDatabase( fileInfoSourceDrawing.path(), - QString( "%1.gpkg" ).arg( fileInfoSourceDrawing.baseName() ) ); + QFileInfo fileInfoTargetDatabase( fileInfoSourceDrawing.path(), QString( "%1.gpkg" ).arg( fileInfoSourceDrawing.baseName() ) ); mDatabaseFileWidget->setFilePath( fileInfoTargetDatabase.filePath() ); } @@ -421,7 +420,7 @@ QList QgsDwgImportDialog::createLayers( const QStringList &lay // 6 QuadrantBelowLeft, 7 QuadrantBelow, 8 QuadrantBelowRight, pls.dataDefinedProperties().setProperty( - static_cast< int >( QgsPalLayerSettings::Property::Hali ), + static_cast( QgsPalLayerSettings::Property::Hali ), QgsProperty::fromExpression( QStringLiteral( "CASE" " WHEN etype=%1 THEN" @@ -437,12 +436,13 @@ QList QgsDwgImportDialog::createLayers( const QStringList &lay " ELSE 'Left'" " END" " END" - ).arg( DRW::MTEXT ) - ) + ) + .arg( DRW::MTEXT ) + ) ); pls.dataDefinedProperties().setProperty( - static_cast< int >( QgsPalLayerSettings::Property::Vali ), + static_cast( QgsPalLayerSettings::Property::Vali ), QgsProperty::fromExpression( QStringLiteral( "CASE" " WHEN etype=%1 THEN" @@ -459,8 +459,9 @@ QList QgsDwgImportDialog::createLayers( const QStringList &lay " ELSE 'Base'" " END" " END" - ).arg( DRW::MTEXT ) - ) + ) + .arg( DRW::MTEXT ) + ) ); pls.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromExpression( QStringLiteral( "360-angle" ) ) ); @@ -498,7 +499,7 @@ QList QgsDwgImportDialog::createLayers( const QStringList &lay void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &name, const QStringList &layers, bool visible ) { QgsLayerTreeGroup *layerGroup = group->addGroup( name ); - QgsDebugMsgLevel( QStringLiteral( " %1" ).arg( name ), 2 ) ; + QgsDebugMsgLevel( QStringLiteral( " %1" ).arg( name ), 2 ); Q_ASSERT( layerGroup ); const QList layersList = createLayers( layers ); @@ -583,13 +584,13 @@ void QgsDwgImportDialog::showHelp() void QgsDwgImportDialog::layersClicked( QTableWidgetItem *item ) { - if ( ! item ) + if ( !item ) return; if ( item->column() != static_cast( ColumnIndex::Name ) ) item = mLayers->item( item->row(), static_cast( ColumnIndex::Name ) ); - if ( ! item ) + if ( !item ) return; const QgsTemporaryCursorOverride waitCursor( Qt::WaitCursor ); diff --git a/src/app/dwg/qgsdwgimportdialog.h b/src/app/dwg/qgsdwgimportdialog.h index 32da49ea988a..de8dbf141f98 100644 --- a/src/app/dwg/qgsdwgimportdialog.h +++ b/src/app/dwg/qgsdwgimportdialog.h @@ -48,7 +48,6 @@ class APP_EXPORT QgsDwgImportDialog : public QDialog, private Ui::QgsDwgImportBa void useCurvesClicked(); private: - enum class ColumnIndex : int { Name = 0, diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index 987ec0016f81..5d68c1b54097 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -52,15 +52,31 @@ #include #include -#define LOG( x ) { QgsDebugMsgLevel( x, 2 ); QgsMessageLog::logMessage( x, QObject::tr( "DWG/DXF import" ) ); } -#define ONCE( x ) { static bool show=true; if( show ) LOG( x ); show=false; } -#define NYI( x ) { static bool show=true; if( show ) LOG( QObject::tr("Not yet implemented %1").arg( x ) ); show=false; } -#define SETSTRING(a) setString(dfn, f, #a, decode(data.a)) -#define SETSTRINGPTR(a) setString(dfn, f.get(), #a, decode(data.a)) -#define SETDOUBLE(a) setDouble(dfn, f, #a, data.a) -#define SETDOUBLEPTR(a) setDouble(dfn, f.get(), #a, data.a) -#define SETINTEGER(a) setInteger(dfn, f, #a, data.a) -#define SETINTEGERPTR(a) setInteger(dfn, f.get(), #a, data.a) +#define LOG( x ) \ + { \ + QgsDebugMsgLevel( x, 2 ); \ + QgsMessageLog::logMessage( x, QObject::tr( "DWG/DXF import" ) ); \ + } +#define ONCE( x ) \ + { \ + static bool show = true; \ + if ( show ) \ + LOG( x ); \ + show = false; \ + } +#define NYI( x ) \ + { \ + static bool show = true; \ + if ( show ) \ + LOG( QObject::tr( "Not yet implemented %1" ).arg( x ) ); \ + show = false; \ + } +#define SETSTRING( a ) setString( dfn, f, #a, decode( data.a ) ) +#define SETSTRINGPTR( a ) setString( dfn, f.get(), #a, decode( data.a ) ) +#define SETDOUBLE( a ) setDouble( dfn, f, #a, data.a ) +#define SETDOUBLEPTR( a ) setDouble( dfn, f.get(), #a, data.a ) +#define SETINTEGER( a ) setInteger( dfn, f, #a, data.a ) +#define SETINTEGERPTR( a ) setInteger( dfn, f.get(), #a, data.a ) #ifdef _MSC_VER #define strcasecmp( a, b ) stricmp( a, b ) @@ -70,11 +86,10 @@ class QgsDrwDebugPrinter : public DRW::DebugPrinter { public: - explicit QgsDrwDebugPrinter( int debugLevel = 4 ) : mTS( &mBuf ) , mLevel( debugLevel ) - { } + {} ~QgsDrwDebugPrinter() override { @@ -178,7 +193,7 @@ class QgsDrwDebugPrinter : public DRW::DebugPrinter } private: - std::ios_base::fmtflags flags{std::cerr.flags()}; + std::ios_base::fmtflags flags { std::cerr.flags() }; QString mBuf; QTextStream mTS; QString mFile; @@ -212,8 +227,7 @@ QgsDwgImporter::QgsDwgImporter( const QString &database, const QgsCoordinateRefe // setup custom debug printer for libdxfrw static std::once_flag initialized; - std::call_once( initialized, [ = ]( ) - { + std::call_once( initialized, [=]() { DRW::setCustomDebugPrinter( new QgsDrwDebugPrinter( 4 ) ); } ); @@ -246,7 +260,7 @@ bool QgsDwgImporter::exec( const QString &sql, bool logError ) if ( logError ) { LOG( tr( "SQL statement failed\nDatabase: %1\nSQL: %2\nError: %3" ) - .arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); + .arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); } return false; } @@ -272,7 +286,7 @@ OGRLayerH QgsDwgImporter::query( const QString &sql ) return layer; LOG( tr( "SQL statement failed\nDatabase: %1\nSQL: %2\nError: %3" ) - .arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); + .arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); OGR_DS_ReleaseResultSet( mDs.get(), layer ); @@ -287,7 +301,7 @@ void QgsDwgImporter::startTransaction() if ( !mInTransaction ) { LOG( tr( "Could not start transaction\nDatabase: %1\nError: %2" ) - .arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); + .arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); } } @@ -298,7 +312,7 @@ void QgsDwgImporter::commitTransaction() if ( mInTransaction && GDALDatasetCommitTransaction( mDs.get() ) != OGRERR_NONE ) { LOG( tr( "Could not commit transaction\nDatabase: %1\nError: %2" ) - .arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); + .arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); } mInTransaction = false; } @@ -449,228 +463,61 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa struct field { - field( const QString &name, OGRFieldType ogrType, int width = -1, int precision = -1 ) - : mName( name ), mOgrType( ogrType ), mWidth( width ), mPrecision( precision ) - {} + field( const QString &name, OGRFieldType ogrType, int width = -1, int precision = -1 ) + : mName( name ), mOgrType( ogrType ), mWidth( width ), mPrecision( precision ) + {} - QString mName; - OGRFieldType mOgrType; - int mWidth; - int mPrecision; + QString mName; + OGRFieldType mOgrType; + int mWidth; + int mPrecision; }; struct table { - table( const QString &name, const QString &desc, OGRwkbGeometryType wkbType, const QList &fields ) - : mName( name ), mDescription( desc ), mWkbType( wkbType ), mFields( fields ) - {} + table( const QString &name, const QString &desc, OGRwkbGeometryType wkbType, const QList &fields ) + : mName( name ), mDescription( desc ), mWkbType( wkbType ), mFields( fields ) + {} - QString mName; - QString mDescription; - OGRwkbGeometryType mWkbType; - QList mFields; + QString mName; + QString mDescription; + OGRwkbGeometryType mWkbType; + QList mFields; }; -#define ENTITY_ATTRIBUTES \ - << field( "handle", OFTInteger ) \ - << field( "block", OFTInteger ) \ - << field( "etype", OFTInteger ) \ - << field( "space", OFTInteger ) \ - << field( "layer", OFTString ) \ - << field( "olinetype", OFTString ) \ - << field( "linetype", OFTString ) \ - << field( "color", OFTString ) \ - << field( "ocolor", OFTInteger ) \ - << field( "color24", OFTInteger ) \ - << field( "transparency", OFTInteger ) \ - << field( "lweight", OFTInteger ) \ - << field( "linewidth", OFTReal ) \ - << field( "ltscale", OFTReal ) \ - << field( "visible", OFTInteger ) +#define ENTITY_ATTRIBUTES \ + << field( "handle", OFTInteger ) \ + << field( "block", OFTInteger ) \ + << field( "etype", OFTInteger ) \ + << field( "space", OFTInteger ) \ + << field( "layer", OFTString ) \ + << field( "olinetype", OFTString ) \ + << field( "linetype", OFTString ) \ + << field( "color", OFTString ) \ + << field( "ocolor", OFTInteger ) \ + << field( "color24", OFTInteger ) \ + << field( "transparency", OFTInteger ) \ + << field( "lweight", OFTInteger ) \ + << field( "linewidth", OFTReal ) \ + << field( "ltscale", OFTReal ) \ + << field( "visible", OFTInteger ) const QList tables = QList
() - << table( QStringLiteral( "drawing" ), tr( "Imported drawings" ), wkbNone, QList() - << field( QStringLiteral( "path" ), OFTString ) - << field( QStringLiteral( "comments" ), OFTString ) - << field( QStringLiteral( "importdat" ), OFTDateTime ) - << field( QStringLiteral( "lastmodified" ), OFTDateTime ) - << field( QStringLiteral( "crs" ), OFTInteger ) - ) - << table( QStringLiteral( "headers" ), tr( "Headers" ), wkbNone, QList() - << field( QStringLiteral( "k" ), OFTString ) - << field( QStringLiteral( "v" ), OFTString ) - ) - << table( QStringLiteral( "linetypes" ), tr( "Line types" ), wkbNone, QList() - << field( QStringLiteral( "name" ), OFTString ) - << field( QStringLiteral( "desc" ), OFTString ) - << field( QStringLiteral( "path" ), OFTRealList ) - ) - << table( QStringLiteral( "layers" ), tr( "Layer list" ), wkbNone, QList() - << field( QStringLiteral( "name" ), OFTString ) - << field( QStringLiteral( "linetype" ), OFTString ) - << field( QStringLiteral( "color" ), OFTString ) - << field( QStringLiteral( "ocolor" ), OFTInteger ) - << field( QStringLiteral( "color24" ), OFTInteger ) - << field( QStringLiteral( "transparency" ), OFTInteger ) - << field( QStringLiteral( "lweight" ), OFTInteger ) - << field( QStringLiteral( "linewidth" ), OFTReal ) - << field( QStringLiteral( "flags" ), OFTInteger ) - ) - << table( QStringLiteral( "dimstyles" ), tr( "Dimension styles" ), wkbNone, QList() - << field( QStringLiteral( "name" ), OFTString ) - << field( QStringLiteral( "dimpost" ), OFTString ) - << field( QStringLiteral( "dimapost" ), OFTString ) - << field( QStringLiteral( "dimblk" ), OFTString ) - << field( QStringLiteral( "dimblk1" ), OFTString ) - << field( QStringLiteral( "dimblk2" ), OFTString ) - << field( QStringLiteral( "dimscale" ), OFTReal ) - << field( QStringLiteral( "dimasz" ), OFTReal ) - << field( QStringLiteral( "dimexo" ), OFTReal ) - << field( QStringLiteral( "dimdli" ), OFTReal ) - << field( QStringLiteral( "dimexe" ), OFTReal ) - << field( QStringLiteral( "dimrnd" ), OFTReal ) - << field( QStringLiteral( "dimdle" ), OFTReal ) - << field( QStringLiteral( "dimtp" ), OFTReal ) - << field( QStringLiteral( "dimtm" ), OFTReal ) - << field( QStringLiteral( "dimfxl" ), OFTReal ) - << field( QStringLiteral( "dimtxt" ), OFTReal ) - << field( QStringLiteral( "dimcen" ), OFTReal ) - << field( QStringLiteral( "dimtsz" ), OFTReal ) - << field( QStringLiteral( "dimaltf" ), OFTReal ) - << field( QStringLiteral( "dimlfac" ), OFTReal ) - << field( QStringLiteral( "dimtvp" ), OFTReal ) - << field( QStringLiteral( "dimtfac" ), OFTReal ) - << field( QStringLiteral( "dimgap" ), OFTReal ) - << field( QStringLiteral( "dimaltrnd" ), OFTReal ) - << field( QStringLiteral( "dimtol" ), OFTInteger ) - << field( QStringLiteral( "dimlim" ), OFTInteger ) - << field( QStringLiteral( "dimtih" ), OFTInteger ) - << field( QStringLiteral( "dimtoh" ), OFTInteger ) - << field( QStringLiteral( "dimse1" ), OFTInteger ) - << field( QStringLiteral( "dimse2" ), OFTInteger ) - << field( QStringLiteral( "dimtad" ), OFTInteger ) - << field( QStringLiteral( "dimzin" ), OFTInteger ) - << field( QStringLiteral( "dimazin" ), OFTInteger ) - << field( QStringLiteral( "dimalt" ), OFTInteger ) - << field( QStringLiteral( "dimaltd" ), OFTInteger ) - << field( QStringLiteral( "dimtofl" ), OFTInteger ) - << field( QStringLiteral( "dimsah" ), OFTInteger ) - << field( QStringLiteral( "dimtix" ), OFTInteger ) - << field( QStringLiteral( "dimsoxd" ), OFTInteger ) - << field( QStringLiteral( "dimclrd" ), OFTInteger ) - << field( QStringLiteral( "dimclre" ), OFTInteger ) - << field( QStringLiteral( "dimclrt" ), OFTInteger ) - << field( QStringLiteral( "dimadec" ), OFTInteger ) - << field( QStringLiteral( "dimunit" ), OFTInteger ) - << field( QStringLiteral( "dimdec" ), OFTInteger ) - << field( QStringLiteral( "dimtdec" ), OFTInteger ) - << field( QStringLiteral( "dimaltu" ), OFTInteger ) - << field( QStringLiteral( "dimalttd" ), OFTInteger ) - << field( QStringLiteral( "dimaunit" ), OFTInteger ) - << field( QStringLiteral( "dimfrac" ), OFTInteger ) - << field( QStringLiteral( "dimlunit" ), OFTInteger ) - << field( QStringLiteral( "dimdsep" ), OFTInteger ) - << field( QStringLiteral( "dimtmove" ), OFTInteger ) - << field( QStringLiteral( "dimjust" ), OFTInteger ) - << field( QStringLiteral( "dimsd1" ), OFTInteger ) - << field( QStringLiteral( "dimsd2" ), OFTInteger ) - << field( QStringLiteral( "dimtolj" ), OFTInteger ) - << field( QStringLiteral( "dimtzin" ), OFTInteger ) - << field( QStringLiteral( "dimaltz" ), OFTInteger ) - << field( QStringLiteral( "dimaltttz" ), OFTInteger ) - << field( QStringLiteral( "dimfit" ), OFTInteger ) - << field( QStringLiteral( "dimupt" ), OFTInteger ) - << field( QStringLiteral( "dimatfit" ), OFTInteger ) - << field( QStringLiteral( "dimfxlon" ), OFTInteger ) - << field( QStringLiteral( "dimtxsty" ), OFTString ) - << field( QStringLiteral( "dimldrblk" ), OFTString ) - << field( QStringLiteral( "dimlwd" ), OFTInteger ) - << field( QStringLiteral( "dimlwe" ), OFTInteger ) - ) - << table( QStringLiteral( "textstyles" ), tr( "Text styles" ), wkbNone, QList() - << field( QStringLiteral( "name" ), OFTString ) - << field( QStringLiteral( "height" ), OFTReal ) - << field( QStringLiteral( "width" ), OFTReal ) - << field( QStringLiteral( "oblique" ), OFTReal ) - << field( QStringLiteral( "genFlag" ), OFTInteger ) - << field( QStringLiteral( "lastHeight" ), OFTReal ) - << field( QStringLiteral( "font" ), OFTString ) - << field( QStringLiteral( "bigFont" ), OFTString ) - << field( QStringLiteral( "fontFamily" ), OFTInteger ) - ) - << table( QStringLiteral( "appdata" ), tr( "Application data" ), wkbNone, QList() - << field( QStringLiteral( "handle" ), OFTInteger ) - << field( QStringLiteral( "i" ), OFTInteger ) - << field( QStringLiteral( "value" ), OFTString ) - ) - << table( QStringLiteral( "blocks" ), tr( "BLOCK entities" ), wkbPoint25D, QList() - ENTITY_ATTRIBUTES - << field( QStringLiteral( "thickness" ), OFTReal ) - << field( QStringLiteral( "ext" ), OFTRealList ) - << field( QStringLiteral( "name" ), OFTString ) - << field( QStringLiteral( "flags" ), OFTInteger ) - ) - << table( QStringLiteral( "points" ), tr( "POINT entities" ), wkbPoint25D, QList() - ENTITY_ATTRIBUTES - << field( QStringLiteral( "thickness" ), OFTReal ) - << field( QStringLiteral( "ext" ), OFTRealList ) - ) - << table( QStringLiteral( "lines" ), tr( "LINE entities" ), lineGeomType, QList() - ENTITY_ATTRIBUTES - << field( QStringLiteral( "thickness" ), OFTReal ) - << field( QStringLiteral( "ext" ), OFTRealList ) - << field( QStringLiteral( "width" ), OFTReal ) - ) - << table( QStringLiteral( "polylines" ), tr( "POLYLINE entities" ), lineGeomType, QList() - ENTITY_ATTRIBUTES - << field( QStringLiteral( "width" ), OFTReal ) - << field( QStringLiteral( "thickness" ), OFTReal ) - << field( QStringLiteral( "ext" ), OFTRealList ) ) - << table( QStringLiteral( "texts" ), tr( "TEXT entities" ), wkbPoint25D, QList() - ENTITY_ATTRIBUTES - << field( QStringLiteral( "thickness" ), OFTReal ) - << field( QStringLiteral( "ext" ), OFTRealList ) - << field( QStringLiteral( "height" ), OFTReal ) - << field( QStringLiteral( "text" ), OFTString ) - << field( QStringLiteral( "angle" ), OFTReal ) - << field( QStringLiteral( "widthscale" ), OFTReal ) - << field( QStringLiteral( "oblique" ), OFTReal ) - << field( QStringLiteral( "style" ), OFTString ) - << field( QStringLiteral( "textgen" ), OFTInteger ) - << field( QStringLiteral( "alignh" ), OFTInteger ) - << field( QStringLiteral( "alignv" ), OFTInteger ) - << field( QStringLiteral( "interlin" ), OFTReal ) - ) - << table( QStringLiteral( "hatches" ), tr( "HATCH entities" ), hatchGeomType, QList() - ENTITY_ATTRIBUTES - << field( QStringLiteral( "thickness" ), OFTReal ) - << field( QStringLiteral( "ext" ), OFTRealList ) - << field( QStringLiteral( "name" ), OFTString ) - << field( QStringLiteral( "solid" ), OFTInteger ) - << field( QStringLiteral( "associative" ), OFTInteger ) - << field( QStringLiteral( "hstyle" ), OFTInteger ) - << field( QStringLiteral( "hpattern" ), OFTInteger ) - << field( QStringLiteral( "doubleflag" ), OFTInteger ) - << field( QStringLiteral( "angle" ), OFTReal ) - << field( QStringLiteral( "scale" ), OFTReal ) - << field( QStringLiteral( "deflines" ), OFTInteger ) - ) - << table( QStringLiteral( "inserts" ), tr( "INSERT entities" ), wkbPoint25D, QList() - ENTITY_ATTRIBUTES - << field( QStringLiteral( "thickness" ), OFTReal ) - << field( QStringLiteral( "ext" ), OFTRealList ) - << field( QStringLiteral( "name" ), OFTString ) - << field( QStringLiteral( "xscale" ), OFTReal ) - << field( QStringLiteral( "yscale" ), OFTReal ) - << field( QStringLiteral( "zscale" ), OFTReal ) - << field( QStringLiteral( "angle" ), OFTReal ) - << field( QStringLiteral( "colcount" ), OFTReal ) - << field( QStringLiteral( "rowcount" ), OFTReal ) - << field( QStringLiteral( "colspace" ), OFTReal ) - << field( QStringLiteral( "rowspace" ), OFTReal ) - ) - ; + << table( QStringLiteral( "drawing" ), tr( "Imported drawings" ), wkbNone, QList() << field( QStringLiteral( "path" ), OFTString ) << field( QStringLiteral( "comments" ), OFTString ) << field( QStringLiteral( "importdat" ), OFTDateTime ) << field( QStringLiteral( "lastmodified" ), OFTDateTime ) << field( QStringLiteral( "crs" ), OFTInteger ) ) + << table( QStringLiteral( "headers" ), tr( "Headers" ), wkbNone, QList() << field( QStringLiteral( "k" ), OFTString ) << field( QStringLiteral( "v" ), OFTString ) ) + << table( QStringLiteral( "linetypes" ), tr( "Line types" ), wkbNone, QList() << field( QStringLiteral( "name" ), OFTString ) << field( QStringLiteral( "desc" ), OFTString ) << field( QStringLiteral( "path" ), OFTRealList ) ) + << table( QStringLiteral( "layers" ), tr( "Layer list" ), wkbNone, QList() << field( QStringLiteral( "name" ), OFTString ) << field( QStringLiteral( "linetype" ), OFTString ) << field( QStringLiteral( "color" ), OFTString ) << field( QStringLiteral( "ocolor" ), OFTInteger ) << field( QStringLiteral( "color24" ), OFTInteger ) << field( QStringLiteral( "transparency" ), OFTInteger ) << field( QStringLiteral( "lweight" ), OFTInteger ) << field( QStringLiteral( "linewidth" ), OFTReal ) << field( QStringLiteral( "flags" ), OFTInteger ) ) + << table( QStringLiteral( "dimstyles" ), tr( "Dimension styles" ), wkbNone, QList() << field( QStringLiteral( "name" ), OFTString ) << field( QStringLiteral( "dimpost" ), OFTString ) << field( QStringLiteral( "dimapost" ), OFTString ) << field( QStringLiteral( "dimblk" ), OFTString ) << field( QStringLiteral( "dimblk1" ), OFTString ) << field( QStringLiteral( "dimblk2" ), OFTString ) << field( QStringLiteral( "dimscale" ), OFTReal ) << field( QStringLiteral( "dimasz" ), OFTReal ) << field( QStringLiteral( "dimexo" ), OFTReal ) << field( QStringLiteral( "dimdli" ), OFTReal ) << field( QStringLiteral( "dimexe" ), OFTReal ) << field( QStringLiteral( "dimrnd" ), OFTReal ) << field( QStringLiteral( "dimdle" ), OFTReal ) << field( QStringLiteral( "dimtp" ), OFTReal ) << field( QStringLiteral( "dimtm" ), OFTReal ) << field( QStringLiteral( "dimfxl" ), OFTReal ) << field( QStringLiteral( "dimtxt" ), OFTReal ) << field( QStringLiteral( "dimcen" ), OFTReal ) << field( QStringLiteral( "dimtsz" ), OFTReal ) << field( QStringLiteral( "dimaltf" ), OFTReal ) << field( QStringLiteral( "dimlfac" ), OFTReal ) << field( QStringLiteral( "dimtvp" ), OFTReal ) << field( QStringLiteral( "dimtfac" ), OFTReal ) << field( QStringLiteral( "dimgap" ), OFTReal ) << field( QStringLiteral( "dimaltrnd" ), OFTReal ) << field( QStringLiteral( "dimtol" ), OFTInteger ) << field( QStringLiteral( "dimlim" ), OFTInteger ) << field( QStringLiteral( "dimtih" ), OFTInteger ) << field( QStringLiteral( "dimtoh" ), OFTInteger ) << field( QStringLiteral( "dimse1" ), OFTInteger ) << field( QStringLiteral( "dimse2" ), OFTInteger ) << field( QStringLiteral( "dimtad" ), OFTInteger ) << field( QStringLiteral( "dimzin" ), OFTInteger ) << field( QStringLiteral( "dimazin" ), OFTInteger ) << field( QStringLiteral( "dimalt" ), OFTInteger ) << field( QStringLiteral( "dimaltd" ), OFTInteger ) << field( QStringLiteral( "dimtofl" ), OFTInteger ) << field( QStringLiteral( "dimsah" ), OFTInteger ) << field( QStringLiteral( "dimtix" ), OFTInteger ) << field( QStringLiteral( "dimsoxd" ), OFTInteger ) << field( QStringLiteral( "dimclrd" ), OFTInteger ) << field( QStringLiteral( "dimclre" ), OFTInteger ) << field( QStringLiteral( "dimclrt" ), OFTInteger ) << field( QStringLiteral( "dimadec" ), OFTInteger ) << field( QStringLiteral( "dimunit" ), OFTInteger ) << field( QStringLiteral( "dimdec" ), OFTInteger ) << field( QStringLiteral( "dimtdec" ), OFTInteger ) << field( QStringLiteral( "dimaltu" ), OFTInteger ) << field( QStringLiteral( "dimalttd" ), OFTInteger ) << field( QStringLiteral( "dimaunit" ), OFTInteger ) << field( QStringLiteral( "dimfrac" ), OFTInteger ) << field( QStringLiteral( "dimlunit" ), OFTInteger ) << field( QStringLiteral( "dimdsep" ), OFTInteger ) << field( QStringLiteral( "dimtmove" ), OFTInteger ) << field( QStringLiteral( "dimjust" ), OFTInteger ) << field( QStringLiteral( "dimsd1" ), OFTInteger ) << field( QStringLiteral( "dimsd2" ), OFTInteger ) << field( QStringLiteral( "dimtolj" ), OFTInteger ) << field( QStringLiteral( "dimtzin" ), OFTInteger ) << field( QStringLiteral( "dimaltz" ), OFTInteger ) << field( QStringLiteral( "dimaltttz" ), OFTInteger ) << field( QStringLiteral( "dimfit" ), OFTInteger ) << field( QStringLiteral( "dimupt" ), OFTInteger ) << field( QStringLiteral( "dimatfit" ), OFTInteger ) << field( QStringLiteral( "dimfxlon" ), OFTInteger ) << field( QStringLiteral( "dimtxsty" ), OFTString ) << field( QStringLiteral( "dimldrblk" ), OFTString ) << field( QStringLiteral( "dimlwd" ), OFTInteger ) << field( QStringLiteral( "dimlwe" ), OFTInteger ) ) + << table( QStringLiteral( "textstyles" ), tr( "Text styles" ), wkbNone, QList() << field( QStringLiteral( "name" ), OFTString ) << field( QStringLiteral( "height" ), OFTReal ) << field( QStringLiteral( "width" ), OFTReal ) << field( QStringLiteral( "oblique" ), OFTReal ) << field( QStringLiteral( "genFlag" ), OFTInteger ) << field( QStringLiteral( "lastHeight" ), OFTReal ) << field( QStringLiteral( "font" ), OFTString ) << field( QStringLiteral( "bigFont" ), OFTString ) << field( QStringLiteral( "fontFamily" ), OFTInteger ) ) + << table( QStringLiteral( "appdata" ), tr( "Application data" ), wkbNone, QList() << field( QStringLiteral( "handle" ), OFTInteger ) << field( QStringLiteral( "i" ), OFTInteger ) << field( QStringLiteral( "value" ), OFTString ) ) + << table( QStringLiteral( "blocks" ), tr( "BLOCK entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES << field( QStringLiteral( "thickness" ), OFTReal ) << field( QStringLiteral( "ext" ), OFTRealList ) << field( QStringLiteral( "name" ), OFTString ) << field( QStringLiteral( "flags" ), OFTInteger ) ) + << table( QStringLiteral( "points" ), tr( "POINT entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES << field( QStringLiteral( "thickness" ), OFTReal ) << field( QStringLiteral( "ext" ), OFTRealList ) ) + << table( QStringLiteral( "lines" ), tr( "LINE entities" ), lineGeomType, QList() ENTITY_ATTRIBUTES << field( QStringLiteral( "thickness" ), OFTReal ) << field( QStringLiteral( "ext" ), OFTRealList ) << field( QStringLiteral( "width" ), OFTReal ) ) + << table( QStringLiteral( "polylines" ), tr( "POLYLINE entities" ), lineGeomType, QList() ENTITY_ATTRIBUTES << field( QStringLiteral( "width" ), OFTReal ) << field( QStringLiteral( "thickness" ), OFTReal ) << field( QStringLiteral( "ext" ), OFTRealList ) ) + << table( QStringLiteral( "texts" ), tr( "TEXT entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES << field( QStringLiteral( "thickness" ), OFTReal ) << field( QStringLiteral( "ext" ), OFTRealList ) << field( QStringLiteral( "height" ), OFTReal ) << field( QStringLiteral( "text" ), OFTString ) << field( QStringLiteral( "angle" ), OFTReal ) << field( QStringLiteral( "widthscale" ), OFTReal ) << field( QStringLiteral( "oblique" ), OFTReal ) << field( QStringLiteral( "style" ), OFTString ) << field( QStringLiteral( "textgen" ), OFTInteger ) << field( QStringLiteral( "alignh" ), OFTInteger ) << field( QStringLiteral( "alignv" ), OFTInteger ) << field( QStringLiteral( "interlin" ), OFTReal ) ) + << table( QStringLiteral( "hatches" ), tr( "HATCH entities" ), hatchGeomType, QList() ENTITY_ATTRIBUTES << field( QStringLiteral( "thickness" ), OFTReal ) << field( QStringLiteral( "ext" ), OFTRealList ) << field( QStringLiteral( "name" ), OFTString ) << field( QStringLiteral( "solid" ), OFTInteger ) << field( QStringLiteral( "associative" ), OFTInteger ) << field( QStringLiteral( "hstyle" ), OFTInteger ) << field( QStringLiteral( "hpattern" ), OFTInteger ) << field( QStringLiteral( "doubleflag" ), OFTInteger ) << field( QStringLiteral( "angle" ), OFTReal ) << field( QStringLiteral( "scale" ), OFTReal ) << field( QStringLiteral( "deflines" ), OFTInteger ) ) + << table( QStringLiteral( "inserts" ), tr( "INSERT entities" ), wkbPoint25D, QList() ENTITY_ATTRIBUTES << field( QStringLiteral( "thickness" ), OFTReal ) << field( QStringLiteral( "ext" ), OFTRealList ) << field( QStringLiteral( "name" ), OFTString ) << field( QStringLiteral( "xscale" ), OFTReal ) << field( QStringLiteral( "yscale" ), OFTReal ) << field( QStringLiteral( "zscale" ), OFTReal ) << field( QStringLiteral( "angle" ), OFTReal ) << field( QStringLiteral( "colcount" ), OFTReal ) << field( QStringLiteral( "rowcount" ), OFTReal ) << field( QStringLiteral( "colspace" ), OFTReal ) << field( QStringLiteral( "rowspace" ), OFTReal ) ); OGRSFDriverH driver = OGRGetDriverByName( "GPKG" ); if ( !driver ) @@ -760,26 +607,10 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa OGR_F_SetFieldString( f.get(), pathIdx, fi.canonicalFilePath().toUtf8().constData() ); QDateTime d( fi.lastModified() ); - OGR_F_SetFieldDateTime( f.get(), lastmodifiedIdx, - d.date().year(), - d.date().month(), - d.date().day(), - d.time().hour(), - d.time().minute(), - d.time().second(), - 0 - ); + OGR_F_SetFieldDateTime( f.get(), lastmodifiedIdx, d.date().year(), d.date().month(), d.date().day(), d.time().hour(), d.time().minute(), d.time().second(), 0 ); d = QDateTime::currentDateTime(); - OGR_F_SetFieldDateTime( f.get(), importdatIdx, - d.date().year(), - d.date().month(), - d.date().day(), - d.time().hour(), - d.time().minute(), - d.time().second(), - 0 - ); + OGR_F_SetFieldDateTime( f.get(), importdatIdx, d.date().year(), d.date().month(), d.date().day(), d.time().hour(), d.time().minute(), d.time().second(), 0 ); OGR_F_SetFieldInteger( f.get(), crsIdx, mCrs ); @@ -922,8 +753,7 @@ void QgsDwgImporter::addHeader( const DRW_Header *data ) if ( k == QLatin1String( "$DWGCODEPAGE" ) ) { - const QHash encodingMap - { + const QHash encodingMap { { "ASCII", "" }, { "8859_1", "ISO-8859-1" }, { "8859_2", "ISO-8859-2" }, @@ -990,9 +820,7 @@ void QgsDwgImporter::addHeader( const DRW_Header *data ) case DRW_Variant::COORD: v = QStringLiteral( "%1,%2,%3" ) - .arg( qgsDoubleToString( it->second->content.v->x ), - qgsDoubleToString( it->second->content.v->y ), - qgsDoubleToString( it->second->content.v->z ) ); + .arg( qgsDoubleToString( it->second->content.v->x ), qgsDoubleToString( it->second->content.v->y ), qgsDoubleToString( it->second->content.v->z ) ); break; case DRW_Variant::INVALID: @@ -1005,10 +833,8 @@ void QgsDwgImporter::addHeader( const DRW_Header *data ) if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE ) { LOG( tr( "Could not add %3 %1 [%2]" ) - .arg( k, - QString::fromUtf8( CPLGetLastErrorMsg() ), - tr( "header record" ) ) - ); + .arg( k, QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "header record" ) ) + ); } } } @@ -1078,10 +904,8 @@ void QgsDwgImporter::addLType( const DRW_LType &data ) if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE ) { LOG( tr( "Could not add %3 %1 [%2]" ) - .arg( data.name.c_str(), - QString::fromUtf8( CPLGetLastErrorMsg() ), - tr( "line type" ) ) - ); + .arg( data.name.c_str(), QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line type" ) ) + ); } } @@ -1110,19 +934,19 @@ QString QgsDwgImporter::colorString( int color, int color24, int transparency, c color = -color; return QStringLiteral( "%1,%2,%3,%4" ) - .arg( DRW::dxfColors[color][0] ) - .arg( DRW::dxfColors[color][1] ) - .arg( DRW::dxfColors[color][2] ) - .arg( 255 - ( transparency & 0xff ) ); + .arg( DRW::dxfColors[color][0] ) + .arg( DRW::dxfColors[color][1] ) + .arg( DRW::dxfColors[color][2] ) + .arg( 255 - ( transparency & 0xff ) ); } } else { return QStringLiteral( "%1,%2,%3,%4" ) - .arg( ( color24 & 0xff0000 ) >> 16 ) - .arg( ( color24 & 0x00ff00 ) >> 8 ) - .arg( ( color24 & 0x0000ff ) ) - .arg( 255 - ( transparency & 0xff ) ); + .arg( ( color24 & 0xff0000 ) >> 16 ) + .arg( ( color24 & 0x00ff00 ) >> 8 ) + .arg( ( color24 & 0x0000ff ) ) + .arg( 255 - ( transparency & 0xff ) ); } } @@ -1170,8 +994,8 @@ void QgsDwgImporter::addLayer( const DRW_Layer &data ) if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE ) { LOG( tr( "Could not add %3 %1 [%2]" ) - .arg( name, QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "layer" ) ) - ); + .arg( name, QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "layer" ) ) + ); } } @@ -1382,8 +1206,8 @@ void QgsDwgImporter::addDimStyle( const DRW_Dimstyle &data ) if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE ) { LOG( tr( "Could not add %3 %1 [%2]" ) - .arg( name, QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "dimension style" ) ) - ); + .arg( name, QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "dimension style" ) ) + ); } } @@ -1415,8 +1239,8 @@ void QgsDwgImporter::addTextStyle( const DRW_Textstyle &data ) if ( OGR_L_CreateFeature( layer, f.get() ) != OGRERR_NONE ) { LOG( tr( "Could not add %3 %1 [%2]" ) - .arg( name, QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "text style" ) ) - ); + .arg( name, QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "text style" ) ) + ); } } @@ -1481,8 +1305,8 @@ void QgsDwgImporter::addBlock( const DRW_Block &data ) if ( !createFeature( layer, f.get(), p ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "block" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "block" ) ) + ); } } @@ -1548,8 +1372,8 @@ void QgsDwgImporter::addPoint( const DRW_Point &data ) if ( !createFeature( layer, f, p ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) + ); } } @@ -1575,11 +1399,7 @@ bool QgsDwgImporter::circularStringFromArc( const DRW_Arc &data, QgsCircularStri const double a1 = data.isccw ? half : -half; const double a2 = data.isccw ? data.endangle : -data.endangle; - c.setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + std::cos( a0 ) * data.radius, data.basePoint.y + std::sin( a0 ) * data.radius ) - << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + std::cos( a1 ) * data.radius, data.basePoint.y + std::sin( a1 ) * data.radius ) - << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + std::cos( a2 ) * data.radius, data.basePoint.y + std::sin( a2 ) * data.radius ) - ); + c.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + std::cos( a0 ) * data.radius, data.basePoint.y + std::sin( a0 ) * data.radius ) << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + std::cos( a1 ) * data.radius, data.basePoint.y + std::sin( a1 ) * data.radius ) << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + std::cos( a2 ) * data.radius, data.basePoint.y + std::sin( a2 ) * data.radius ) ); return true; } @@ -1590,8 +1410,8 @@ void QgsDwgImporter::addArc( const DRW_Arc &data ) if ( !circularStringFromArc( data, c ) ) { LOG( tr( "Could not create circular string from %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "arc" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "arc" ) ) + ); return; } @@ -1610,8 +1430,8 @@ void QgsDwgImporter::addArc( const DRW_Arc &data ) if ( !createFeature( layer, f, c ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "arc" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "arc" ) ) + ); } } @@ -1631,17 +1451,13 @@ void QgsDwgImporter::addCircle( const DRW_Circle &data ) setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); QgsCircularString c; - c.setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x - data.radius, data.basePoint.y, data.basePoint.z ) - << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + data.radius, data.basePoint.y, data.basePoint.z ) - << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x - data.radius, data.basePoint.y, data.basePoint.z ) - ); + c.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x - data.radius, data.basePoint.y, data.basePoint.z ) << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x + data.radius, data.basePoint.y, data.basePoint.z ) << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x - data.radius, data.basePoint.y, data.basePoint.z ) ); if ( !createFeature( layer, f, c ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "circle" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "circle" ) ) + ); } } @@ -1707,10 +1523,7 @@ bool QgsDwgImporter::curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoun const double r = c / 2.0 / std::sin( a ); const double h = r * ( 1 - std::cos( a ) ); - s << QgsPoint( Qgis::WkbType::PointZ, - data.vertlist[i0]->x + 0.5 * dx + h * dy / c, - data.vertlist[i0]->y + 0.5 * dy - h * dx / c, - data.elevation ); + s << QgsPoint( Qgis::WkbType::PointZ, data.vertlist[i0]->x + 0.5 * dx + h * dy / c, data.vertlist[i0]->y + 0.5 * dy - h * dx / c, data.elevation ); } } @@ -1791,8 +1604,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) if ( !createFeature( layer, f, cc ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) + ); } cc.clear(); @@ -1823,10 +1636,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) const double r = c / 2.0 / std::sin( a ); const double h = r * ( 1 - std::cos( a ) ); - s << QgsPoint( Qgis::WkbType::PointZ, - p0.x() + 0.5 * dx + h * dy / c, - p0.y() + 0.5 * dy - h * dx / c, - data.elevation ); + s << QgsPoint( Qgis::WkbType::PointZ, p0.x() + 0.5 * dx + h * dy / c, p0.y() + 0.5 * dy - h * dx / c, data.elevation ); } s << p1; @@ -1854,13 +1664,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) QgsPolygon poly; QgsLineString *ls = new QgsLineString(); - ls->setPoints( QgsPointSequence() - << QgsPoint( ps + vs ) - << QgsPoint( pe + ve ) - << QgsPoint( pe - ve ) - << QgsPoint( ps - vs ) - << QgsPoint( ps + vs ) - ); + ls->setPoints( QgsPointSequence() << QgsPoint( ps + vs ) << QgsPoint( pe + ve ) << QgsPoint( pe - ve ) << QgsPoint( ps - vs ) << QgsPoint( ps + vs ) ); ls->addZValue( data.elevation ); poly.setExteriorRing( ls ); // QgsDebugMsgLevel( QStringLiteral( "write poly:%1" ).arg( poly.asWkt() ), 2 ); @@ -1868,8 +1672,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) if ( !createFeature( layer, f, poly ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) + ); } } } @@ -1912,8 +1716,8 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data ) if ( !createFeature( layer, f, cc ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) + ); } } } @@ -1944,13 +1748,7 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) const double endWidth = data.vertlist[i0]->stawidth == 0.0 ? data.defstawidth : data.vertlist[i0]->endwidth; const bool hasBulge( data.vertlist[i0]->bulge != 0.0 ); - QgsDebugMsgLevel( QStringLiteral( "i:%1,%2/%3 width=%4 staWidth=%5 endWidth=%6 hadBulge=%7 hasBulge=%8 l=%9 <=> %10" ) - .arg( i0 ).arg( i1 ).arg( n ) - .arg( width ).arg( staWidth ).arg( endWidth ) - .arg( hadBulge ).arg( hasBulge ) - .arg( p0.asWkt() ) - .arg( p1.asWkt() ), 5 - ); + QgsDebugMsgLevel( QStringLiteral( "i:%1,%2/%3 width=%4 staWidth=%5 endWidth=%6 hadBulge=%7 hasBulge=%8 l=%9 <=> %10" ).arg( i0 ).arg( i1 ).arg( n ).arg( width ).arg( staWidth ).arg( endWidth ).arg( hadBulge ).arg( hasBulge ).arg( p0.asWkt() ).arg( p1.asWkt() ), 5 ); if ( !s.empty() && ( width != staWidth || width != endWidth || hadBulge != hasBulge ) ) { @@ -1999,8 +1797,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) if ( !createFeature( layer, f, cc ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) + ); } cc.clear(); @@ -2026,10 +1824,7 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) const double r = c / 2.0 / std::sin( a ); const double h = r * ( 1 - std::cos( a ) ); - s << QgsPoint( Qgis::WkbType::PointZ, - p0.x() + 0.5 * dx + h * dy / c, - p0.y() + 0.5 * dy - h * dx / c, - p0.z() + 0.5 * dz ); + s << QgsPoint( Qgis::WkbType::PointZ, p0.x() + 0.5 * dx + h * dy / c, p0.y() + 0.5 * dy - h * dx / c, p0.z() + 0.5 * dz ); } s << p1; @@ -2075,8 +1870,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) if ( !createFeature( layer, f, poly ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) + ); } } } @@ -2119,8 +1914,8 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data ) if ( !createFeature( layer, f, cc ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) + ); } } } @@ -2167,9 +1962,7 @@ static std::vector knotu( const DRW_Spline &data, size_t num, size_t ord } } -static std::vector rbasis( size_t c, double t, size_t npts, - const std::vector &x, - const std::vector &h ) +static std::vector rbasis( size_t c, double t, size_t npts, const std::vector &x, const std::vector &h ) { const size_t nplusc = npts + c; std::vector temp( nplusc, 0. ); @@ -2224,11 +2017,7 @@ static std::vector rbasis( size_t c, double t, size_t npts, /** * Generates a rational B-spline curve using a uniform open knot vector. */ -static void rbspline( const DRW_Spline &data, - size_t npts, size_t k, int p1, - const std::vector &b, - const std::vector &h, - std::vector &p ) +static void rbspline( const DRW_Spline &data, size_t npts, size_t k, int p1, const std::vector &b, const std::vector &h, std::vector &p ) { const size_t nplusc = npts + k; @@ -2253,11 +2042,7 @@ static void rbspline( const DRW_Spline &data, } } -static void rbsplinu( const DRW_Spline &data, - size_t npts, size_t k, int p1, - const std::vector &b, - const std::vector &h, - std::vector &p ) +static void rbsplinu( const DRW_Spline &data, size_t npts, size_t k, int p1, const std::vector &b, const std::vector &h, std::vector &p ) { size_t const nplusc = npts + k; @@ -2289,17 +2074,12 @@ bool QgsDwgImporter::lineFromSpline( const DRW_Spline &data, QgsLineString &l ) if ( data.degree < 1 || data.degree > 3 ) { QgsDebugError( QStringLiteral( "%1: unknown spline degree %2" ) - .arg( data.handle, 0, 16 ) - .arg( data.degree ) ); + .arg( data.handle, 0, 16 ) + .arg( data.degree ) ); return false; } - QgsDebugMsgLevel( QStringLiteral( "degree: %1 ncontrol:%2 knotslist.size():%3 controllist.size():%4 fitlist.size():%5" ) - .arg( data.degree ) - .arg( data.ncontrol ) - .arg( data.knotslist.size() ) - .arg( data.controllist.size() ) - .arg( data.fitlist.size() ), 5 ); + QgsDebugMsgLevel( QStringLiteral( "degree: %1 ncontrol:%2 knotslist.size():%3 controllist.size():%4 fitlist.size():%5" ).arg( data.degree ).arg( data.ncontrol ).arg( data.knotslist.size() ).arg( data.controllist.size() ).arg( data.fitlist.size() ), 5 ); std::vector cps; for ( size_t i = 0; i < data.controllist.size(); ++i ) @@ -2356,8 +2136,8 @@ void QgsDwgImporter::addSpline( const DRW_Spline *data ) if ( !lineFromSpline( *data, l ) ) { LOG( tr( "Could not create line from %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "spline" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "spline" ) ) + ); return; } @@ -2373,8 +2153,8 @@ void QgsDwgImporter::addSpline( const DRW_Spline *data ) if ( !createFeature( layer, f, l ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "spline" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "spline" ) ) + ); } } @@ -2414,8 +2194,8 @@ void QgsDwgImporter::addInsert( const DRW_Insert &data ) if ( !createFeature( layer, f, p ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) + ); } } @@ -2452,10 +2232,10 @@ void QgsDwgImporter::addSolid( const DRW_Solid &data ) // pt1 pt2 // pt3 pt4 QgsPointSequence s; - s << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x, data.basePoint.y, data.basePoint.z ); - s << QgsPoint( Qgis::WkbType::PointZ, data.secPoint.x, data.secPoint.y, data.basePoint.z ); + s << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x, data.basePoint.y, data.basePoint.z ); + s << QgsPoint( Qgis::WkbType::PointZ, data.secPoint.x, data.secPoint.y, data.basePoint.z ); s << QgsPoint( Qgis::WkbType::PointZ, data.forthPoint.x, data.forthPoint.y, data.basePoint.z ); - s << QgsPoint( Qgis::WkbType::PointZ, data.thirdPoint.x, data.thirdPoint.y, data.basePoint.z ); + s << QgsPoint( Qgis::WkbType::PointZ, data.thirdPoint.x, data.thirdPoint.y, data.basePoint.z ); s << s[0]; QgsLineString *ls = new QgsLineString(); @@ -2465,8 +2245,8 @@ void QgsDwgImporter::addSolid( const DRW_Solid &data ) if ( !createFeature( layer, f, poly ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) + ); } } @@ -2503,8 +2283,8 @@ void QgsDwgImporter::addMText( const DRW_MText &data ) if ( !createFeature( layer, f, p ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) + ); } } @@ -2538,16 +2318,13 @@ void QgsDwgImporter::addText( const DRW_Text &data ) setPoint( dfn, f, QStringLiteral( "ext" ), data.extPoint ); - const QgsPoint p( Qgis::WkbType::PointZ, - ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.x : data.basePoint.x, - ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.y : data.basePoint.y, - ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.z : data.basePoint.z ); + const QgsPoint p( Qgis::WkbType::PointZ, ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.x : data.basePoint.x, ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.y : data.basePoint.y, ( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.z : data.basePoint.z ); if ( !createFeature( layer, f, p ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "point" ) ) + ); } } @@ -2629,13 +2406,13 @@ void QgsDwgImporter::addHatch( const DRW_Hatch *pdata ) QgsCurvePolygon p; - if ( static_cast< int >( data.looplist.size() ) != data.loopsnum ) + if ( static_cast( data.looplist.size() ) != data.loopsnum ) { LOG( tr( "0x%1: %2 instead of %3 loops found" ) - .arg( data.handle, 0, 16 ) - .arg( data.looplist.size() ) - .arg( data.loopsnum ) - ); + .arg( data.handle, 0, 16 ) + .arg( data.looplist.size() ) + .arg( data.loopsnum ) + ); } for ( std::vector::size_type i = 0; i < data.looplist.size(); i++ ) @@ -2655,9 +2432,7 @@ void QgsDwgImporter::addHatch( const DRW_Hatch *pdata ) else if ( const DRW_Line *l = dynamic_cast( entity ) ) { QgsLineString *ls = new QgsLineString(); - ls->setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZ, l->basePoint.x, l->basePoint.y, l->basePoint.z ) - << QgsPoint( Qgis::WkbType::PointZ, l->secPoint.x, l->secPoint.y, l->secPoint.z ) ); + ls->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, l->basePoint.x, l->basePoint.y, l->basePoint.z ) << QgsPoint( Qgis::WkbType::PointZ, l->secPoint.x, l->secPoint.y, l->secPoint.z ) ); if ( j > 0 ) ls->moveVertex( QgsVertexId( 0, 0, 0 ), cc->endPoint() ); @@ -2716,8 +2491,8 @@ void QgsDwgImporter::addHatch( const DRW_Hatch *pdata ) if ( !createFeature( layer, f, p ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "polygon" ) ) + ); } } @@ -2738,15 +2513,13 @@ void QgsDwgImporter::addLine( const DRW_Line &data ) QgsLineString l; - l.setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x, data.basePoint.y, data.basePoint.z ) - << QgsPoint( Qgis::WkbType::PointZ, data.secPoint.x, data.secPoint.y, data.secPoint.z ) ); + l.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, data.basePoint.x, data.basePoint.y, data.basePoint.z ) << QgsPoint( Qgis::WkbType::PointZ, data.secPoint.x, data.secPoint.y, data.secPoint.z ) ); if ( !createFeature( layer, f, l ) ) { LOG( tr( "Could not add %2 [%1]" ) - .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) - ); + .arg( QString::fromUtf8( CPLGetLastErrorMsg() ), tr( "line string" ) ) + ); } } @@ -2862,14 +2635,16 @@ bool QgsDwgImporter::expandInserts( QString &error, int block, QTransform base ) if ( xscaleIdx < 0 || yscaleIdx < 0 || zscaleIdx < 0 || angleIdx < 0 || nameIdx < 0 || layerIdx < 0 || linetypeIdx < 0 || colorIdx < 0 || linewidthIdx < 0 ) { QgsDebugError( QStringLiteral( "not all fields found (nameIdx=%1 xscaleIdx=%2 yscaleIdx=%3 zscaleIdx=%4 angleIdx=%5 layerIdx=%6 linetypeIdx=%7 color=%8 linewidthIdx=%9)" ) - .arg( nameIdx ) - .arg( xscaleIdx ).arg( yscaleIdx ).arg( zscaleIdx ) - .arg( angleIdx ) - .arg( layerIdx ) - .arg( linetypeIdx ) - .arg( colorIdx ) - .arg( linewidthIdx ) - ); + .arg( nameIdx ) + .arg( xscaleIdx ) + .arg( yscaleIdx ) + .arg( zscaleIdx ) + .arg( angleIdx ) + .arg( layerIdx ) + .arg( linetypeIdx ) + .arg( colorIdx ) + .arg( linewidthIdx ) + ); return false; } @@ -2937,11 +2712,7 @@ bool QgsDwgImporter::expandInserts( QString &error, int block, QTransform base ) const QgsPointXY b = mBlockBases.value( name ); - QgsDebugMsgLevel( QStringLiteral( "Resolving %1/%2: p=%3,%4 b=%5,%6 scale=%7,%8 angle=%9" ) - .arg( name ).arg( handle, 0, 16 ) - .arg( p.x() ).arg( p.y() ) - .arg( b.x() ).arg( b.y() ) - .arg( xscale ).arg( yscale ).arg( angle ), 5 ); + QgsDebugMsgLevel( QStringLiteral( "Resolving %1/%2: p=%3,%4 b=%5,%6 scale=%7,%8 angle=%9" ).arg( name ).arg( handle, 0, 16 ).arg( p.x() ).arg( p.y() ).arg( b.x() ).arg( b.y() ).arg( xscale ).arg( yscale ).arg( angle ), 5 ); QTransform t; @@ -2949,7 +2720,7 @@ bool QgsDwgImporter::expandInserts( QString &error, int block, QTransform base ) t *= base; OGRLayerH src = nullptr; - const QStringList types {"hatches", "lines", "polylines", "texts", "points"}; + const QStringList types { "hatches", "lines", "polylines", "texts", "points" }; for ( const QString &name : types ) { if ( src ) @@ -2974,8 +2745,11 @@ bool QgsDwgImporter::expandInserts( QString &error, int block, QTransform base ) if ( blockIdx < 0 || layerIdx < 0 || colorIdx < 0 ) { QgsDebugError( QStringLiteral( "%1: fields not found (blockIdx=%2, layerIdx=%3 colorIdx=%4)" ) - .arg( name ).arg( blockIdx ).arg( layerIdx ).arg( colorIdx ) - ); + .arg( name ) + .arg( blockIdx ) + .arg( layerIdx ) + .arg( colorIdx ) + ); OGR_DS_ReleaseResultSet( mDs.get(), src ); continue; } @@ -3060,9 +2834,7 @@ bool QgsDwgImporter::expandInserts( QString &error, int block, QTransform base ) { if ( errors < 1000 ) { - QgsMessageLog::logMessage( tr( "Could not copy feature of block %2 from layer %1 [Errors: %3]" ) - .arg( name ).arg( handle ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ), - tr( "DWG/DXF import" ) ); + QgsMessageLog::logMessage( tr( "Could not copy feature of block %2 from layer %1 [Errors: %3]" ).arg( name ).arg( handle ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ), tr( "DWG/DXF import" ) ); } else if ( errors == 1000 ) { @@ -3151,15 +2923,15 @@ void QgsDwgImporter::cleanText( QString &res ) const thread_local QRegularExpression fontSettingRe( QStringLiteral( "\\\\f[0-9A-Za-z| ]{0,};" ) ); res = res.replace( fontSettingRe, QString( "" ) ); // font setting const thread_local QRegularExpression groupingRe( QStringLiteral( "([^\\\\]|^){" ) ); - res = res.replace( groupingRe, QStringLiteral( "\\1" ) ); // grouping + res = res.replace( groupingRe, QStringLiteral( "\\1" ) ); // grouping const thread_local QRegularExpression groupingRe2( QStringLiteral( "([^\\\\])}" ) ); res = res.replace( groupingRe2, QStringLiteral( "\\1" ) ); const thread_local QRegularExpression textDecorationRe( QStringLiteral( "([^\\\\]|^)\\\\[loLOkx]" ) ); - res = res.replace( textDecorationRe, QStringLiteral( "\\1" ) ); // underline, overstrike, strike through + res = res.replace( textDecorationRe, QStringLiteral( "\\1" ) ); // underline, overstrike, strike through const thread_local QRegularExpression textSizeRe( QStringLiteral( "([^\\\\]|^)\\\\[HhWwAaCcQq]\\d*(\\.\\d*)?[xX]?;?" ) ); - res = res.replace( textSizeRe, QStringLiteral( "\\1" ) ); // text height, width, alignment, color and slanting + res = res.replace( textSizeRe, QStringLiteral( "\\1" ) ); // text height, width, alignment, color and slanting const thread_local QRegularExpression alignmentRe( QStringLiteral( "([^\\\\]|^)\\\\[ACQ]\\d+;" ) ); - res = res.replace( alignmentRe, QStringLiteral( "\\1" ) ); // alignment, color and slanting + res = res.replace( alignmentRe, QStringLiteral( "\\1" ) ); // alignment, color and slanting if ( res == prev ) break; diff --git a/src/app/elevation/qgselevationprofileexportsettingswidget.h b/src/app/elevation/qgselevationprofileexportsettingswidget.h index 8529d52099f2..f6e76cbfb1de 100644 --- a/src/app/elevation/qgselevationprofileexportsettingswidget.h +++ b/src/app/elevation/qgselevationprofileexportsettingswidget.h @@ -30,7 +30,6 @@ class QgsElevationProfileExportSettingsWidget : public QWidget, private Ui::QgsE { Q_OBJECT public: - QgsElevationProfileExportSettingsWidget( QWidget *parent = nullptr ); /** @@ -42,7 +41,6 @@ class QgsElevationProfileExportSettingsWidget : public QWidget, private Ui::QgsE * Updates plot settings based on the widget's state. */ void updatePlotSettings( Qgs2DPlot &plot ); - }; #endif // QGSELEVATIONPROFILEEXPORTSETTINGSWIDGET_H diff --git a/src/app/elevation/qgselevationprofileimageexportdialog.cpp b/src/app/elevation/qgselevationprofileimageexportdialog.cpp index ace026bd2329..821c0734b08c 100644 --- a/src/app/elevation/qgselevationprofileimageexportdialog.cpp +++ b/src/app/elevation/qgselevationprofileimageexportdialog.cpp @@ -53,4 +53,3 @@ QSize QgsElevationProfileImageExportDialog::imageSize() const { return QSize( mWidthSpinBox->value(), mHeightSpinBox->value() ); } - diff --git a/src/app/elevation/qgselevationprofileimageexportdialog.h b/src/app/elevation/qgselevationprofileimageexportdialog.h index a8500c84168e..7694ca47212d 100644 --- a/src/app/elevation/qgselevationprofileimageexportdialog.h +++ b/src/app/elevation/qgselevationprofileimageexportdialog.h @@ -32,7 +32,6 @@ class QgsElevationProfileImageExportDialog : public QDialog, private Ui::QgsElev { Q_OBJECT public: - QgsElevationProfileImageExportDialog( QWidget *parent = nullptr ); /** @@ -49,7 +48,6 @@ class QgsElevationProfileImageExportDialog : public QDialog, private Ui::QgsElev QSize imageSize() const; private: - QgsElevationProfileExportSettingsWidget *mProfileSettingsWidget = nullptr; }; diff --git a/src/app/elevation/qgselevationprofilepdfexportdialog.cpp b/src/app/elevation/qgselevationprofilepdfexportdialog.cpp index d84416c9d8d4..1d52bb0a7d28 100644 --- a/src/app/elevation/qgselevationprofilepdfexportdialog.cpp +++ b/src/app/elevation/qgselevationprofilepdfexportdialog.cpp @@ -37,7 +37,7 @@ QgsElevationProfilePdfExportDialog::QgsElevationProfilePdfExportDialog( QWidget mPageOrientationComboBox->addItem( tr( "Portrait" ), QgsLayoutItemPage::Portrait ); mPageOrientationComboBox->addItem( tr( "Landscape" ), QgsLayoutItemPage::Landscape ); - const QList< QgsPageSize> sizes = QgsApplication::pageSizeRegistry()->entries(); + const QList sizes = QgsApplication::pageSizeRegistry()->entries(); for ( const QgsPageSize &size : sizes ) { mPageSizeComboBox->addItem( size.displayName, size.name ); @@ -59,8 +59,8 @@ QgsElevationProfilePdfExportDialog::QgsElevationProfilePdfExportDialog( QWidget connect( mPageSizeComboBox, static_cast( &QComboBox::currentIndexChanged ), this, &QgsElevationProfilePdfExportDialog::pageSizeChanged ); connect( mPageOrientationComboBox, static_cast( &QComboBox::currentIndexChanged ), this, &QgsElevationProfilePdfExportDialog::orientationChanged ); - connect( mWidthSpin, static_cast< void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsElevationProfilePdfExportDialog::setToCustomSize ); - connect( mHeightSpin, static_cast< void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsElevationProfilePdfExportDialog::setToCustomSize ); + connect( mWidthSpin, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsElevationProfilePdfExportDialog::setToCustomSize ); + connect( mHeightSpin, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsElevationProfilePdfExportDialog::setToCustomSize ); whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->findData( QStringLiteral( "A4" ) ) ); mLockAspectRatio->setEnabled( false ); diff --git a/src/app/elevation/qgselevationprofilepdfexportdialog.h b/src/app/elevation/qgselevationprofilepdfexportdialog.h index db034a9fb2dd..a4a238515ffe 100644 --- a/src/app/elevation/qgselevationprofilepdfexportdialog.h +++ b/src/app/elevation/qgselevationprofilepdfexportdialog.h @@ -32,7 +32,6 @@ class QgsElevationProfilePdfExportDialog : public QDialog, private Ui::QgsElevat { Q_OBJECT public: - QgsElevationProfilePdfExportDialog( QWidget *parent = nullptr ); /** @@ -54,7 +53,6 @@ class QgsElevationProfilePdfExportDialog : public QDialog, private Ui::QgsElevat void setToCustomSize(); private: - QgsElevationProfileExportSettingsWidget *mProfileSettingsWidget = nullptr; QgsLayoutMeasurementConverter mConverter; bool mSettingPresetSize = false; diff --git a/src/app/elevation/qgselevationprofiletoolidentify.cpp b/src/app/elevation/qgselevationprofiletoolidentify.cpp index bc0fd3b04059..1e9dd52ba4ca 100644 --- a/src/app/elevation/qgselevationprofiletoolidentify.cpp +++ b/src/app/elevation/qgselevationprofiletoolidentify.cpp @@ -57,7 +57,7 @@ void QgsElevationProfileToolIdentify::plotPressEvent( QgsPlotMouseEvent *event ) } // don't allow the band to be dragged outside of the plot area - const QRectF plotArea = qgis::down_cast< QgsElevationProfileCanvas * >( mCanvas )->plotArea(); + const QRectF plotArea = qgis::down_cast( mCanvas )->plotArea(); if ( !plotArea.contains( event->pos() ) ) { mMousePressStartPos = constrainPointToRect( event->pos(), plotArea ); @@ -93,7 +93,7 @@ void QgsElevationProfileToolIdentify::plotReleaseEvent( QgsPlotMouseEvent *event if ( !clickOnly ) { // don't allow the band to be dragged outside of the plot area - const QRectF plotArea = qgis::down_cast< QgsElevationProfileCanvas * >( mCanvas )->plotArea(); + const QRectF plotArea = qgis::down_cast( mCanvas )->plotArea(); QPointF end; if ( !plotArea.contains( event->pos() ) ) { @@ -104,11 +104,11 @@ void QgsElevationProfileToolIdentify::plotReleaseEvent( QgsPlotMouseEvent *event end = event->snappedPoint().toQPointF(); } - results = qgis::down_cast< QgsElevationProfileCanvas * >( mCanvas )->identify( QRectF( mSnappedMousePressStartPos.toQPointF(), end ) ); + results = qgis::down_cast( mCanvas )->identify( QRectF( mSnappedMousePressStartPos.toQPointF(), end ) ); } else { - results = qgis::down_cast< QgsElevationProfileCanvas * >( mCanvas )->identify( mSnappedMousePressStartPos.toQPointF() ); + results = qgis::down_cast( mCanvas )->identify( mSnappedMousePressStartPos.toQPointF() ); } if ( results.empty() ) @@ -135,7 +135,7 @@ void QgsElevationProfileToolIdentify::plotMoveEvent( QgsPlotMouseEvent *event ) } // don't allow the band to be dragged outside of the plot area - const QRectF plotArea = qgis::down_cast< QgsElevationProfileCanvas * >( mCanvas )->plotArea(); + const QRectF plotArea = qgis::down_cast( mCanvas )->plotArea(); QPointF movePoint; if ( !plotArea.contains( event->pos() ) ) { @@ -148,4 +148,3 @@ void QgsElevationProfileToolIdentify::plotMoveEvent( QgsPlotMouseEvent *event ) mRubberBand->update( movePoint, Qt::KeyboardModifiers() ); } - diff --git a/src/app/elevation/qgselevationprofiletoolidentify.h b/src/app/elevation/qgselevationprofiletoolidentify.h index 9f82877592e5..675e87d10a87 100644 --- a/src/app/elevation/qgselevationprofiletoolidentify.h +++ b/src/app/elevation/qgselevationprofiletoolidentify.h @@ -26,11 +26,9 @@ class QgsElevationProfileCanvas; class QgsElevationProfileToolIdentify : public QgsPlotTool { - Q_OBJECT public: - QgsElevationProfileToolIdentify( QgsElevationProfileCanvas *canvas ); ~QgsElevationProfileToolIdentify() override; @@ -38,8 +36,8 @@ class QgsElevationProfileToolIdentify : public QgsPlotTool void plotPressEvent( QgsPlotMouseEvent *event ) override; void plotReleaseEvent( QgsPlotMouseEvent *event ) override; void plotMoveEvent( QgsPlotMouseEvent *event ) override; - private: + private: //! Start position for mouse press QPointF mMousePressStartPos; QgsPointXY mSnappedMousePressStartPos; @@ -47,8 +45,7 @@ class QgsElevationProfileToolIdentify : public QgsPlotTool bool mMarquee = false; //! Rubber band item - std::unique_ptr< QgsPlotRectangularRubberBand > mRubberBand; - + std::unique_ptr mRubberBand; }; #endif // QGSELEVATIONPROFILETOOLIDENTIFY_H diff --git a/src/app/elevation/qgselevationprofiletoolmeasure.cpp b/src/app/elevation/qgselevationprofiletoolmeasure.cpp index acccf467212f..a05123f74626 100644 --- a/src/app/elevation/qgselevationprofiletoolmeasure.cpp +++ b/src/app/elevation/qgselevationprofiletoolmeasure.cpp @@ -65,9 +65,7 @@ void QgsProfileMeasureResultsDialog::setCrs( const QgsCoordinateReferenceSystem bool QgsProfileMeasureResultsDialog::eventFilter( QObject *object, QEvent *event ) { - if ( object == this && ( event->type() == QEvent::Close || - event->type() == QEvent::Destroy || - event->type() == QEvent::Hide ) ) + if ( object == this && ( event->type() == QEvent::Close || event->type() == QEvent::Destroy || event->type() == QEvent::Hide ) ) { emit closed(); } @@ -147,14 +145,12 @@ QgsElevationProfileToolMeasure::QgsElevationProfileToolMeasure( QgsElevationProf mDialog = new QgsProfileMeasureResultsDialog(); connect( this, &QgsElevationProfileToolMeasure::cleared, mDialog, &QDialog::hide ); - connect( this, &QgsElevationProfileToolMeasure::measureChanged, mDialog, [ = ]( double totalDistance, double deltaCurve, double deltaElevation ) - { + connect( this, &QgsElevationProfileToolMeasure::measureChanged, mDialog, [=]( double totalDistance, double deltaCurve, double deltaElevation ) { mDialog->setCrs( mElevationCanvas->crs() ); mDialog->setMeasures( totalDistance, deltaCurve, deltaElevation ); mDialog->show(); } ); - connect( mDialog, &QgsProfileMeasureResultsDialog::closed, this, [ = ] - { + connect( mDialog, &QgsProfileMeasureResultsDialog::closed, this, [=] { mMeasureInProgress = false; mRubberBand->hide(); emit cleared(); @@ -254,8 +250,7 @@ void QgsElevationProfileToolMeasure::updateRubberBand() double elevation1 = mStartPoint.elevation(); double distance2 = mEndPoint.distance(); double elevation2 = mEndPoint.elevation(); - QgsClipper::clipLineSegment( distanceRange.lower(), distanceRange.upper(), elevationRange.lower(), elevationRange.upper(), - distance1, elevation1, distance2, elevation2 ); + QgsClipper::clipLineSegment( distanceRange.lower(), distanceRange.upper(), elevationRange.lower(), elevationRange.upper(), distance1, elevation1, distance2, elevation2 ); const QgsPointXY p1 = mElevationCanvas->plotPointToCanvasPoint( QgsProfilePoint( distance1, elevation1 ) ); const QgsPointXY p2 = mElevationCanvas->plotPointToCanvasPoint( QgsProfilePoint( distance2, elevation2 ) ); diff --git a/src/app/elevation/qgselevationprofiletoolmeasure.h b/src/app/elevation/qgselevationprofiletoolmeasure.h index 4ef90a352ec5..5baae83a0eca 100644 --- a/src/app/elevation/qgselevationprofiletoolmeasure.h +++ b/src/app/elevation/qgselevationprofiletoolmeasure.h @@ -33,7 +33,6 @@ class QgsProfileMeasureResultsDialog : public QDialog Q_OBJECT public: - QgsProfileMeasureResultsDialog(); void setCrs( const QgsCoordinateReferenceSystem &crs ); @@ -49,13 +48,11 @@ class QgsProfileMeasureResultsDialog : public QDialog void clear(); private: - QLabel *mTotalLabel = nullptr; QLabel *mDistanceLabel = nullptr; QLabel *mElevationLabel = nullptr; QgsCoordinateReferenceSystem mCrs; - }; class QgsElevationProfileToolMeasure : public QgsPlotTool @@ -92,7 +89,6 @@ class QgsElevationProfileToolMeasure : public QgsPlotTool QgsProfilePoint mStartPoint; QgsProfilePoint mEndPoint; bool mMeasureInProgress = false; - }; #endif // QGSELEVATIONPROFILETOOLMEASURE_H diff --git a/src/app/elevation/qgselevationprofilewidget.cpp b/src/app/elevation/qgselevationprofilewidget.cpp index 1861e85ccbd9..d30c409046b7 100644 --- a/src/app/elevation/qgselevationprofilewidget.cpp +++ b/src/app/elevation/qgselevationprofilewidget.cpp @@ -110,9 +110,9 @@ void QgsElevationProfileLayersDialog::setHiddenLayers( const QListsetExceptedLayerList( layers ); } -QList< QgsMapLayer *> QgsElevationProfileLayersDialog::selectedLayers() const +QList QgsElevationProfileLayersDialog::selectedLayers() const { - QList< QgsMapLayer * > layers; + QList layers; const QModelIndexList selection = listMapLayers->selectionModel()->selectedIndexes(); for ( const QModelIndex &index : selection ) @@ -135,7 +135,7 @@ void QgsElevationProfileLayersDialog::filterVisible( bool enabled ) if ( enabled ) mModel->setLayerAllowlist( mVisibleLayers ); else - mModel->setLayerAllowlist( QList< QgsMapLayer * >() ); + mModel->setLayerAllowlist( QList() ); } @@ -164,8 +164,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) mCanvas->setLockAxisScales( settingLockAxis->value() ); mCanvas->setBackgroundColor( settingBackgroundColor->value() ); - connect( QgsGui::instance(), &QgsGui::optionsChanged, this, [ = ] - { + connect( QgsGui::instance(), &QgsGui::optionsChanged, this, [=] { mCanvas->setBackgroundColor( settingBackgroundColor->value() ); } ); @@ -174,8 +173,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) mLayerTreeView = new QgsAppElevationProfileLayerTreeView( mLayerTree.get() ); connect( mLayerTreeView, &QgsAppElevationProfileLayerTreeView::addLayers, this, &QgsElevationProfileWidget::addLayersInternal ); - connect( mLayerTreeView, &QAbstractItemView::doubleClicked, this, [ = ]( const QModelIndex & index ) - { + connect( mLayerTreeView, &QAbstractItemView::doubleClicked, this, [=]( const QModelIndex &index ) { if ( QgsMapLayer *layer = mLayerTreeView->indexToLayer( index ) ) { QgisApp::instance()->showLayerProperties( layer, QStringLiteral( "mOptsPage_Elevation" ) ); @@ -196,8 +194,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) QAction *showLayerTree = new QAction( tr( "Show Layer Tree" ), this ); showLayerTree->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mIconLayerTree.svg" ) ) ); showLayerTree->setCheckable( true ); - connect( showLayerTree, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( showLayerTree, &QAction::toggled, this, [=]( bool checked ) { settingShowLayerTree->setValue( checked ); mLayerTreeView->setVisible( checked ); } ); @@ -209,8 +206,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) mCaptureCurveAction = new QAction( tr( "Capture Curve" ), this ); mCaptureCurveAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionCaptureLine.svg" ) ) ); mCaptureCurveAction->setCheckable( true ); - connect( mCaptureCurveAction, &QAction::triggered, this, [ = ] - { + connect( mCaptureCurveAction, &QAction::triggered, this, [=] { if ( mCaptureCurveMapTool && mMainCanvas ) { mMainCanvas->setMapTool( mCaptureCurveMapTool.get() ); @@ -221,8 +217,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) mCaptureCurveFromFeatureAction = new QAction( tr( "Capture Curve From Feature" ), this ); mCaptureCurveFromFeatureAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionCaptureCurveFromFeature.svg" ) ) ); mCaptureCurveFromFeatureAction->setCheckable( true ); - connect( mCaptureCurveFromFeatureAction, &QAction::triggered, this, [ = ] - { + connect( mCaptureCurveFromFeatureAction, &QAction::triggered, this, [=] { if ( mCaptureCurveFromFeatureMapTool && mMainCanvas ) { mMainCanvas->setMapTool( mCaptureCurveFromFeatureMapTool.get() ); @@ -242,8 +237,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) mNudgeRightAction->setEnabled( false ); toolBar->addAction( mNudgeRightAction ); - auto createShortcuts = [ = ]( const QString & objectName, void ( QgsElevationProfileWidget::* slot )() ) - { + auto createShortcuts = [=]( const QString &objectName, void ( QgsElevationProfileWidget::*slot )() ) { if ( QShortcut *sc = QgsGui::shortcutsManager()->shortcutByName( objectName ) ) connect( sc, &QShortcut::activated, this, slot ); }; @@ -262,7 +256,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) identifyToolAction->setCheckable( true ); identifyToolAction->setChecked( true ); mIdentifyTool->setAction( identifyToolAction ); - connect( identifyToolAction, &QAction::triggered, mPanTool, [ = ] { mCanvas->setTool( mIdentifyTool ); } ); + connect( identifyToolAction, &QAction::triggered, mPanTool, [=] { mCanvas->setTool( mIdentifyTool ); } ); toolBar->addAction( identifyToolAction ); QAction *panToolAction = new QAction( tr( "Pan" ), this ); @@ -270,21 +264,21 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) panToolAction->setCheckable( true ); panToolAction->setChecked( false ); mPanTool->setAction( panToolAction ); - connect( panToolAction, &QAction::triggered, mPanTool, [ = ] { mCanvas->setTool( mPanTool ); } ); + connect( panToolAction, &QAction::triggered, mPanTool, [=] { mCanvas->setTool( mPanTool ); } ); toolBar->addAction( panToolAction ); QAction *zoomXAxisToolAction = new QAction( tr( "Zoom X Axis" ), this ); zoomXAxisToolAction->setCheckable( true ); zoomXAxisToolAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomInXAxis.svg" ) ) ); mXAxisZoomTool->setAction( zoomXAxisToolAction ); - connect( zoomXAxisToolAction, &QAction::triggered, mXAxisZoomTool, [ = ] { mCanvas->setTool( mXAxisZoomTool ); } ); + connect( zoomXAxisToolAction, &QAction::triggered, mXAxisZoomTool, [=] { mCanvas->setTool( mXAxisZoomTool ); } ); toolBar->addAction( zoomXAxisToolAction ); QAction *zoomToolAction = new QAction( tr( "Zoom" ), this ); zoomToolAction->setCheckable( true ); zoomToolAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ) ); mZoomTool->setAction( zoomToolAction ); - connect( zoomToolAction, &QAction::triggered, mZoomTool, [ = ] { mCanvas->setTool( mZoomTool ); } ); + connect( zoomToolAction, &QAction::triggered, mZoomTool, [=] { mCanvas->setTool( mZoomTool ); } ); toolBar->addAction( zoomToolAction ); QAction *resetViewAction = new QAction( tr( "Zoom Full" ), this ); @@ -299,14 +293,13 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) connect( enabledSnappingAction, &QAction::toggled, mCanvas, &QgsElevationProfileCanvas::setSnappingEnabled ); toolBar->addAction( enabledSnappingAction ); - mMeasureTool = std::make_unique< QgsElevationProfileToolMeasure> ( mCanvas ); + mMeasureTool = std::make_unique( mCanvas ); QAction *measureToolAction = new QAction( tr( "Measure Distances" ), this ); measureToolAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMeasure.svg" ) ) ); measureToolAction->setCheckable( true ); mMeasureTool->setAction( measureToolAction ); - connect( measureToolAction, &QAction::triggered, this, [ = ] - { + connect( measureToolAction, &QAction::triggered, this, [=] { mCanvas->setTool( mMeasureTool.get() ); } ); toolBar->addAction( measureToolAction ); @@ -353,7 +346,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) mLockRatioAction = new QAction( tr( "Lock Distance/Elevation Scales" ), this ); mLockRatioAction->setCheckable( true ); - mLockRatioAction->setChecked( settingLockAxis->value( ) ); + mLockRatioAction->setChecked( settingLockAxis->value() ); connect( mLockRatioAction, &QAction::toggled, this, &QgsElevationProfileWidget::axisScaleLockToggled ); mOptionsMenu->addAction( mLockRatioAction ); @@ -386,8 +379,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) action->setData( QVariant::fromValue( unit ) ); action->setCheckable( true ); action->setActionGroup( unitGroup ); - connect( action, &QAction::toggled, this, [ = ]( bool active ) - { + connect( action, &QAction::toggled, this, [=]( bool active ) { if ( active ) { mCanvas->setDistanceUnit( unit ); @@ -395,11 +387,10 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) } ); mDistanceUnitMenu->addAction( action ); } - connect( mDistanceUnitMenu, &QMenu::aboutToShow, this, [ = ] - { + connect( mDistanceUnitMenu, &QMenu::aboutToShow, this, [=] { for ( QAction *action : mDistanceUnitMenu->actions() ) { - if ( action->data().value< Qgis::DistanceUnit >() == mCanvas->distanceUnit() && !action->isChecked() ) + if ( action->data().value() == mCanvas->distanceUnit() && !action->isChecked() ) action->setChecked( true ); } } ); @@ -410,8 +401,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) mSettingsAction = new QgsElevationProfileWidgetSettingsAction( mOptionsMenu ); mSettingsAction->toleranceSpinBox()->setValue( settingTolerance->value() ); - connect( mSettingsAction->toleranceSpinBox(), qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value ) - { + connect( mSettingsAction->toleranceSpinBox(), qOverload( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) { settingTolerance->setValue( value ); createOrUpdateRubberBands(); scheduleUpdate(); @@ -452,7 +442,7 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) layout->addLayout( topLayout ); QSplitter *splitter = new QSplitter( Qt::Horizontal ); - splitter->addWidget( mLayerTreeView ) ; + splitter->addWidget( mLayerTreeView ); splitter->addWidget( mCanvas ); layout->addWidget( splitter ); splitter->setCollapsible( 0, false ); @@ -461,19 +451,17 @@ QgsElevationProfileWidget::QgsElevationProfileWidget( const QString &name ) QgsSettings settings; splitter->restoreState( settings.value( QStringLiteral( "Windows/ElevationProfile/SplitState" ) ).toByteArray() ); - connect( splitter, &QSplitter::splitterMoved, this, [splitter] - { + connect( splitter, &QSplitter::splitterMoved, this, [splitter] { QgsSettings settings; settings.setValue( QStringLiteral( "Windows/ElevationProfile/SplitState" ), splitter->saveState() ); } ); setLayout( layout ); - mDockableWidgetHelper = new QgsDockableWidgetHelper( true, mCanvasName, this, QgisApp::instance(), Qt::BottomDockWidgetArea, QStringList(), true ); + mDockableWidgetHelper = new QgsDockableWidgetHelper( true, mCanvasName, this, QgisApp::instance(), Qt::BottomDockWidgetArea, QStringList(), true ); QToolButton *toggleButton = mDockableWidgetHelper->createDockUndockToolButton(); toggleButton->setToolTip( tr( "Dock Elevation Profile View" ) ); toolBar->addWidget( toggleButton ); - connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [ = ]() - { + connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [=]() { close(); } ); @@ -515,11 +503,10 @@ void QgsElevationProfileWidget::setMainCanvas( QgsMapCanvas *canvas ) { mMainCanvas = canvas; - mCaptureCurveMapTool = std::make_unique< QgsMapToolProfileCurve >( canvas, QgisApp::instance()->cadDockWidget() ); + mCaptureCurveMapTool = std::make_unique( canvas, QgisApp::instance()->cadDockWidget() ); mCaptureCurveMapTool->setAction( mCaptureCurveAction ); - connect( mCaptureCurveMapTool.get(), &QgsMapToolProfileCurve::curveCaptured, this, [ = ]( const QgsGeometry & curve ) { setProfileCurve( curve, true ); } ); - connect( mCaptureCurveMapTool.get(), &QgsMapToolProfileCurve::captureStarted, this, [ = ] - { + connect( mCaptureCurveMapTool.get(), &QgsMapToolProfileCurve::curveCaptured, this, [=]( const QgsGeometry &curve ) { setProfileCurve( curve, true ); } ); + connect( mCaptureCurveMapTool.get(), &QgsMapToolProfileCurve::captureStarted, this, [=] { // if capturing a new curve, we just hide the existing rubber band -- if the user cancels the new curve digitizing then we'll // re-show the old curve rubber band if ( mRubberBand ) @@ -529,8 +516,7 @@ void QgsElevationProfileWidget::setMainCanvas( QgsMapCanvas *canvas ) if ( mMapPointRubberBand ) mMapPointRubberBand->hide(); } ); - connect( mCaptureCurveMapTool.get(), &QgsMapToolProfileCurve::captureCanceled, this, [ = ] - { + connect( mCaptureCurveMapTool.get(), &QgsMapToolProfileCurve::captureCanceled, this, [=] { if ( mRubberBand ) mRubberBand->show(); if ( mToleranceRubberBand ) @@ -539,9 +525,9 @@ void QgsElevationProfileWidget::setMainCanvas( QgsMapCanvas *canvas ) mMapPointRubberBand->show(); } ); - mCaptureCurveFromFeatureMapTool = std::make_unique< QgsMapToolProfileCurveFromFeature >( canvas ); + mCaptureCurveFromFeatureMapTool = std::make_unique( canvas ); mCaptureCurveFromFeatureMapTool->setAction( mCaptureCurveFromFeatureAction ); - connect( mCaptureCurveFromFeatureMapTool.get(), &QgsMapToolProfileCurveFromFeature::curveCaptured, this, [ = ]( const QgsGeometry & curve ) { setProfileCurve( curve, true ); } ); + connect( mCaptureCurveFromFeatureMapTool.get(), &QgsMapToolProfileCurveFromFeature::curveCaptured, this, [=]( const QgsGeometry &curve ) { setProfileCurve( curve, true ); } ); mMapPointRubberBand.reset( new QgsRubberBand( canvas, Qgis::GeometryType::Point ) ); mMapPointRubberBand->setZValue( 1000 ); @@ -553,8 +539,7 @@ void QgsElevationProfileWidget::setMainCanvas( QgsMapCanvas *canvas ) mMapPointRubberBand->hide(); mCanvas->setDistanceUnit( mMainCanvas->mapSettings().destinationCrs().mapUnits() ); - connect( mMainCanvas, &QgsMapCanvas::destinationCrsChanged, this, [ = ] - { + connect( mMainCanvas, &QgsMapCanvas::destinationCrsChanged, this, [=] { mCanvas->setDistanceUnit( mMainCanvas->mapSettings().destinationCrs().mapUnits() ); } ); } @@ -571,7 +556,7 @@ void QgsElevationProfileWidget::addLayers() // The add layers dialog should only show layers which CAN have elevation, yet currently don't // have it enabled. So collect layers which don't match this criteria now for filtering out. - QList< QgsMapLayer * > layersWhichAlreadyHaveElevationOrCannotHaveElevation; + QList layersWhichAlreadyHaveElevationOrCannotHaveElevation; for ( auto it = allMapLayers.constBegin(); it != allMapLayers.constEnd(); ++it ) { if ( !QgsElevationUtils::canEnableElevationForLayer( it.value() ) || it.value()->elevationProperties()->hasElevation() ) @@ -592,7 +577,7 @@ void QgsElevationProfileWidget::addLayers() void QgsElevationProfileWidget::addLayersInternal( const QList &layers ) { - QList< QgsMapLayer * > updatedLayers; + QList updatedLayers; if ( !layers.empty() ) { for ( QgsMapLayer *layer : layers ) @@ -618,7 +603,7 @@ void QgsElevationProfileWidget::addLayersInternal( const QList &l void QgsElevationProfileWidget::updateCanvasLayers() { QList layers; - const QList< QgsMapLayer * > layerOrder = mLayerTree->layerOrder(); + const QList layerOrder = mLayerTree->layerOrder(); layers.reserve( layerOrder.size() ); for ( QgsMapLayer *layer : layerOrder ) { @@ -648,11 +633,9 @@ void QgsElevationProfileWidget::onTotalPendingJobsCountChanged( int count ) mJobProgressBarTimer.setSingleShot( true ); mJobProgressBarTimer.setInterval( 500 ); disconnect( mJobProgressBarTimerConnection ); - mJobProgressBarTimerConnection = connect( &mJobProgressBarTimer, &QTimer::timeout, this, [ = ]() - { + mJobProgressBarTimerConnection = connect( &mJobProgressBarTimer, &QTimer::timeout, this, [=]() { mProgressPendingJobs->setVisible( true ); - } - ); + } ); mJobProgressBarTimer.start(); } else @@ -704,12 +687,12 @@ void QgsElevationProfileWidget::updatePlot() if ( !mProfileCurve.isEmpty() ) { - if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve *>( mProfileCurve.constGet()->simplifiedTypeRef() ) ) + if ( const QgsCurve *curve = qgsgeometry_cast( mProfileCurve.constGet()->simplifiedTypeRef() ) ) { mCanvas->setProfileCurve( curve->clone() ); mCanvas->refresh(); } - else if ( const QgsMultiCurve *multiCurve = qgsgeometry_cast< const QgsMultiCurve *>( mProfileCurve.constGet()->simplifiedTypeRef() ) ) + else if ( const QgsMultiCurve *multiCurve = qgsgeometry_cast( mProfileCurve.constGet()->simplifiedTypeRef() ) ) { // hm, just grab the first part! mCanvas->setProfileCurve( multiCurve->curveN( 0 )->clone() ); @@ -750,10 +733,11 @@ void QgsElevationProfileWidget::exportAsPdf() this->raise(); #endif outputFileName = QFileDialog::getSaveFileName( - this, - tr( "Export to PDF" ), - outputFileName, - tr( "PDF Format" ) + " (*.pdf *.PDF)" ); + this, + tr( "Export to PDF" ), + outputFileName, + tr( "PDF Format" ) + " (*.pdf *.PDF)" + ); this->activateWindow(); if ( outputFileName.isEmpty() ) { @@ -771,9 +755,7 @@ void QgsElevationProfileWidget::exportAsPdf() QPdfWriter pdfWriter( outputFileName ); const QgsLayoutSize pageSizeMM = dialog.pageSizeMM(); - QPageLayout pageLayout( QPageSize( pageSizeMM.toQSizeF(), QPageSize::Millimeter ), - QPageLayout::Portrait, - QMarginsF( 0, 0, 0, 0 ) ); + QPageLayout pageLayout( QPageSize( pageSizeMM.toQSizeF(), QPageSize::Millimeter ), QPageLayout::Portrait, QMarginsF( 0, 0, 0, 0 ) ); pageLayout.setMode( QPageLayout::FullPageMode ); pdfWriter.setPageLayout( pageLayout ); pdfWriter.setPageMargins( QMarginsF( 0, 0, 0, 0 ) ); @@ -798,8 +780,7 @@ void QgsElevationProfileWidget::exportAsPdf() Qgs2DPlot plotSettings; dialog.updatePlotSettings( plotSettings ); - mCanvas->render( rc, rc.convertToPainterUnits( pageSizeMM.width(), Qgis::RenderUnit::Millimeters ), - rc.convertToPainterUnits( pageSizeMM.height(), Qgis::RenderUnit::Millimeters ), plotSettings ); + mCanvas->render( rc, rc.convertToPainterUnits( pageSizeMM.width(), Qgis::RenderUnit::Millimeters ), rc.convertToPainterUnits( pageSizeMM.height(), Qgis::RenderUnit::Millimeters ), plotSettings ); p.end(); QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as PDF" ), tr( "Successfully saved the profile to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ) ); @@ -855,19 +836,18 @@ void QgsElevationProfileWidget::exportAsImage() image.save( fileWithExtension.first ); QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as Image" ), tr( "Successfully saved the profile to %2" ).arg( QUrl::fromLocalFile( fileWithExtension.first ).toString(), QDir::toNativeSeparators( fileWithExtension.first ) ) ); - } void QgsElevationProfileWidget::exportResults( Qgis::ProfileExportType type ) { - std::unique_ptr< QgsCurve > profileCurve; + std::unique_ptr profileCurve; if ( !mProfileCurve.isEmpty() ) { - if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve *>( mProfileCurve.constGet()->simplifiedTypeRef() ) ) + if ( const QgsCurve *curve = qgsgeometry_cast( mProfileCurve.constGet()->simplifiedTypeRef() ) ) { profileCurve.reset( curve->clone() ); } - else if ( const QgsMultiCurve *multiCurve = qgsgeometry_cast< const QgsMultiCurve *>( mProfileCurve.constGet()->simplifiedTypeRef() ) ) + else if ( const QgsMultiCurve *multiCurve = qgsgeometry_cast( mProfileCurve.constGet()->simplifiedTypeRef() ) ) { // hm, just grab the first part! profileCurve.reset( multiCurve->curveN( 0 )->clone() ); @@ -898,21 +878,20 @@ void QgsElevationProfileWidget::exportResults( Qgis::ProfileExportType type ) context.appendScope( QgsExpressionContextUtils::projectScope( QgsProject::instance() ) ); request.setExpressionContext( context ); - const QList< QgsMapLayer * > layersToGenerate = mCanvas->layers(); - QList< QgsAbstractProfileSource * > sources; - const QList< QgsAbstractProfileSource * > registrySources = QgsApplication::profileSourceRegistry()->profileSources(); + const QList layersToGenerate = mCanvas->layers(); + QList sources; + const QList registrySources = QgsApplication::profileSourceRegistry()->profileSources(); sources.reserve( layersToGenerate.size() + registrySources.size() ); sources << registrySources; for ( QgsMapLayer *layer : layersToGenerate ) { - if ( QgsAbstractProfileSource *source = dynamic_cast< QgsAbstractProfileSource * >( layer ) ) + if ( QgsAbstractProfileSource *source = dynamic_cast( layer ) ) sources.append( source ); } QgsProfileExporterTask *exportTask = new QgsProfileExporterTask( sources, request, type, file, QgsProject::instance()->transformContext() ); - connect( exportTask, &QgsTask::taskCompleted, this, [exportTask] - { + connect( exportTask, &QgsTask::taskCompleted, this, [exportTask] { switch ( exportTask->result() ) { case QgsProfileExporterTask::ExportResult::Success: @@ -982,7 +961,7 @@ void QgsElevationProfileWidget::renameProfileTriggered() } } -void QgsElevationProfileWidget::createOrUpdateRubberBands( ) +void QgsElevationProfileWidget::createOrUpdateRubberBands() { if ( !mRubberBand ) { @@ -992,18 +971,18 @@ void QgsElevationProfileWidget::createOrUpdateRubberBands( ) QgsSymbolLayerList layers; - std::unique_ptr< QgsSimpleLineSymbolLayer > bottomLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr bottomLayer = std::make_unique(); bottomLayer->setWidth( 0.8 ); bottomLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); bottomLayer->setColor( QColor( 40, 40, 40, 100 ) ); bottomLayer->setPenCapStyle( Qt::PenCapStyle::FlatCap ); layers.append( bottomLayer.release() ); - std::unique_ptr< QgsMarkerLineSymbolLayer > arrowLayer = std::make_unique< QgsMarkerLineSymbolLayer >(); + std::unique_ptr arrowLayer = std::make_unique(); arrowLayer->setPlacements( Qgis::MarkerLinePlacement::CentralPoint ); QgsSymbolLayerList markerLayers; - std::unique_ptr< QgsSimpleMarkerSymbolLayer > arrowSymbolLayer = std::make_unique< QgsSimpleMarkerSymbolLayer >( Qgis::MarkerShape::EquilateralTriangle ); + std::unique_ptr arrowSymbolLayer = std::make_unique( Qgis::MarkerShape::EquilateralTriangle ); arrowSymbolLayer->setSize( 4 ); arrowSymbolLayer->setAngle( 90 ); arrowSymbolLayer->setSizeUnit( Qgis::RenderUnit::Millimeters ); @@ -1012,12 +991,12 @@ void QgsElevationProfileWidget::createOrUpdateRubberBands( ) arrowSymbolLayer->setStrokeWidth( 0.2 ); markerLayers.append( arrowSymbolLayer.release() ); - std::unique_ptr< QgsMarkerSymbol > markerSymbol = std::make_unique< QgsMarkerSymbol >( markerLayers ); + std::unique_ptr markerSymbol = std::make_unique( markerLayers ); arrowLayer->setSubSymbol( markerSymbol.release() ); layers.append( arrowLayer.release() ); - std::unique_ptr< QgsSimpleLineSymbolLayer > topLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr topLayer = std::make_unique(); topLayer->setWidth( 0.4 ); topLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); topLayer->setColor( QColor( 255, 255, 255, 255 ) ); @@ -1025,7 +1004,7 @@ void QgsElevationProfileWidget::createOrUpdateRubberBands( ) topLayer->setPenCapStyle( Qt::PenCapStyle::FlatCap ); layers.append( topLayer.release() ); - std::unique_ptr< QgsLineSymbol > symbol = std::make_unique< QgsLineSymbol >( layers ); + std::unique_ptr symbol = std::make_unique( layers ); mRubberBand->setSymbol( symbol.release() ); mRubberBand->updatePosition(); @@ -1044,12 +1023,12 @@ void QgsElevationProfileWidget::createOrUpdateRubberBands( ) QgsSymbolLayerList layers; - std::unique_ptr< QgsSimpleFillSymbolLayer > bottomLayer = std::make_unique< QgsSimpleFillSymbolLayer >(); + std::unique_ptr bottomLayer = std::make_unique(); bottomLayer->setColor( QColor( 40, 40, 40, 50 ) ); bottomLayer->setStrokeColor( QColor( 255, 255, 255, 150 ) ); layers.append( bottomLayer.release() ); - std::unique_ptr< QgsFillSymbol > symbol = std::make_unique< QgsFillSymbol >( layers ); + std::unique_ptr symbol = std::make_unique( layers ); mToleranceRubberBand->setSymbol( symbol.release() ); } @@ -1073,7 +1052,7 @@ void QgsElevationProfileWidget::onProjectElevationPropertiesChanged() { if ( layer->type() == Qgis::LayerType::Vector ) { - QgsVectorLayerElevationProperties *elevationProperties = qgis::down_cast< QgsVectorLayerElevationProperties * >( layer->elevationProperties() ); + QgsVectorLayerElevationProperties *elevationProperties = qgis::down_cast( layer->elevationProperties() ); switch ( elevationProperties->clamping() ) { case Qgis::AltitudeClamping::Relative: @@ -1117,7 +1096,6 @@ QgsElevationProfileWidgetSettingsAction::QgsElevationProfileWidgetSettingsAction QgsAppElevationProfileLayerTreeView::QgsAppElevationProfileLayerTreeView( QgsLayerTree *rootNode, QWidget *parent ) : QgsElevationProfileLayerTreeView( rootNode, parent ) { - } void QgsAppElevationProfileLayerTreeView::contextMenuEvent( QContextMenuEvent *event ) @@ -1131,8 +1109,7 @@ void QgsAppElevationProfileLayerTreeView::contextMenuEvent( QContextMenuEvent *e QMenu *menu = new QMenu(); QAction *propertiesAction = new QAction( tr( "Properties…" ), menu ); - connect( propertiesAction, &QAction::triggered, this, [layer] - { + connect( propertiesAction, &QAction::triggered, this, [layer] { QgisApp::instance()->showLayerProperties( layer, QStringLiteral( "mOptsPage_Elevation" ) ); } ); menu->addAction( propertiesAction ); diff --git a/src/app/elevation/qgselevationprofilewidget.h b/src/app/elevation/qgselevationprofilewidget.h index c3ff54682bb6..02995afee0cc 100644 --- a/src/app/elevation/qgselevationprofilewidget.h +++ b/src/app/elevation/qgselevationprofilewidget.h @@ -59,15 +59,13 @@ class QgsAppElevationProfileLayerTreeView : public QgsElevationProfileLayerTreeV { Q_OBJECT public: - explicit QgsAppElevationProfileLayerTreeView( QgsLayerTree *rootNode, QWidget *parent = nullptr ); protected: - void contextMenuEvent( QContextMenuEvent *event ) override; }; -class QgsElevationProfileLayersDialog: public QDialog, private Ui::QgsElevationProfileAddLayersDialogBase +class QgsElevationProfileLayersDialog : public QDialog, private Ui::QgsElevationProfileAddLayersDialogBase { Q_OBJECT @@ -75,23 +73,21 @@ class QgsElevationProfileLayersDialog: public QDialog, private Ui::QgsElevationP QgsElevationProfileLayersDialog( QWidget *parent = nullptr ); void setVisibleLayers( const QList &layers ); void setHiddenLayers( const QList &layers ); - QList< QgsMapLayer * > selectedLayers() const; + QList selectedLayers() const; private slots: void filterVisible( bool enabled ); private: - QgsMapLayerProxyModel *mModel = nullptr; - QList< QgsMapLayer * > mVisibleLayers; + QList mVisibleLayers; }; class QgsElevationProfileWidget : public QWidget { Q_OBJECT public: - static const QgsSettingsEntryDouble *settingTolerance; static const QgsSettingsEntryBool *settingShowLayerTree; static const QgsSettingsEntryBool *settingLockAxis; @@ -161,9 +157,9 @@ class QgsElevationProfileWidget : public QWidget QMenu *mDistanceUnitMenu = nullptr; QgsDockableWidgetHelper *mDockableWidgetHelper = nullptr; - std::unique_ptr< QgsMapToolProfileCurve > mCaptureCurveMapTool; - std::unique_ptr< QgsMapToolProfileCurveFromFeature > mCaptureCurveFromFeatureMapTool; - std::unique_ptr< QgsElevationProfileToolMeasure > mMeasureTool; + std::unique_ptr mCaptureCurveMapTool; + std::unique_ptr mCaptureCurveFromFeatureMapTool; + std::unique_ptr mMeasureTool; QgsGeometry mProfileCurve; QObjectUniquePtr mMapPointRubberBand; @@ -181,18 +177,17 @@ class QgsElevationProfileWidget : public QWidget QgsElevationProfileWidgetSettingsAction *mSettingsAction = nullptr; - std::unique_ptr< QgsLayerTree > mLayerTree; + std::unique_ptr mLayerTree; QgsLayerTreeRegistryBridge *mLayerTreeBridge = nullptr; QgsElevationProfileLayerTreeView *mLayerTreeView = nullptr; }; -class QgsElevationProfileWidgetSettingsAction: public QWidgetAction +class QgsElevationProfileWidgetSettingsAction : public QWidgetAction { Q_OBJECT public: - QgsElevationProfileWidgetSettingsAction( QWidget *parent = nullptr ); QgsDoubleSpinBox *toleranceSpinBox() { return mToleranceWidget; } diff --git a/src/app/elevation/qgsmaptoolprofilecurve.cpp b/src/app/elevation/qgsmaptoolprofilecurve.cpp index 4157c2796f92..35968f5ab2cb 100644 --- a/src/app/elevation/qgsmaptoolprofilecurve.cpp +++ b/src/app/elevation/qgsmaptoolprofilecurve.cpp @@ -23,8 +23,7 @@ QgsMapToolProfileCurve::QgsMapToolProfileCurve( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) : QgsMapToolCapture( canvas, cadDockWidget, CaptureMode::CaptureLine ) { - connect( canvas, &QgsMapCanvas::mapToolSet, this, [ = ]( QgsMapTool * tool, QgsMapTool * ) - { + connect( canvas, &QgsMapCanvas::mapToolSet, this, [=]( QgsMapTool *tool, QgsMapTool * ) { if ( tool != this ) mPreviousTool = tool; } ); diff --git a/src/app/elevation/qgsmaptoolprofilecurve.h b/src/app/elevation/qgsmaptoolprofilecurve.h index c808af12e071..65de8981c238 100644 --- a/src/app/elevation/qgsmaptoolprofilecurve.h +++ b/src/app/elevation/qgsmaptoolprofilecurve.h @@ -44,9 +44,7 @@ class QgsMapToolProfileCurve : public QgsMapToolCapture private: void lineCaptured( const QgsCurve *line ) override; - QPointer< QgsMapTool > mPreviousTool; - - + QPointer mPreviousTool; }; #endif // QGSMAPTOOLPROFILECURVE_H diff --git a/src/app/elevation/qgsmaptoolprofilecurvefromfeature.cpp b/src/app/elevation/qgsmaptoolprofilecurvefromfeature.cpp index 064a380d8ab6..9fc0d9c24ba8 100644 --- a/src/app/elevation/qgsmaptoolprofilecurvefromfeature.cpp +++ b/src/app/elevation/qgsmaptoolprofilecurvefromfeature.cpp @@ -39,7 +39,7 @@ void QgsMapToolProfileCurveFromFeature::canvasPressEvent( QgsMapMouseEvent *e ) e->ignore(); const QList results = QgsIdentifyMenu::findFeaturesOnCanvas( e, mCanvas, { Qgis::GeometryType::Line } ); - if ( results.empty( ) ) + if ( results.empty() ) return; QgsIdentifyMenu *menu = new QgsIdentifyMenu( mCanvas ); @@ -67,4 +67,3 @@ void QgsMapToolProfileCurveFromFeature::canvasPressEvent( QgsMapMouseEvent *e ) } } } - diff --git a/src/app/georeferencer/qgsgcpcanvasitem.cpp b/src/app/georeferencer/qgsgcpcanvasitem.cpp index 24d9f9c294c3..b36fec71583e 100644 --- a/src/app/georeferencer/qgsgcpcanvasitem.cpp +++ b/src/app/georeferencer/qgsgcpcanvasitem.cpp @@ -94,8 +94,7 @@ void QgsGCPCanvasItem::paint( QPainter *p ) textFont.setPixelSize( fontSizePainterUnits( 12, context ) ); p->setFont( textFont ); const QRectF textBounds = p->boundingRect( 3 * context.scaleFactor(), 3 * context.scaleFactor(), 5 * context.scaleFactor(), 5 * context.scaleFactor(), Qt::AlignLeft, msg ); - mTextBoxRect = QRectF( textBounds.x() - context.scaleFactor() * 1, textBounds.y() - context.scaleFactor() * 1, - textBounds.width() + 2 * context.scaleFactor(), textBounds.height() + 2 * context.scaleFactor() ); + mTextBoxRect = QRectF( textBounds.x() - context.scaleFactor() * 1, textBounds.y() - context.scaleFactor() * 1, textBounds.width() + 2 * context.scaleFactor(), textBounds.height() + 2 * context.scaleFactor() ); p->drawRect( mTextBoxRect ); p->drawText( textBounds, Qt::AlignLeft, msg ); } @@ -198,7 +197,6 @@ void QgsGCPCanvasItem::drawResidualArrow( QPainter *p, const QgsRenderContext &c const double rf = residualToScreenFactor(); p->setPen( mResidualPen ); p->drawLine( QPointF( 0, 0 ), QPointF( residual.rx() * rf, residual.ry() * rf ) ); - } double QgsGCPCanvasItem::residualToScreenFactor() const @@ -242,4 +240,3 @@ double QgsGCPCanvasItem::fontSizePainterUnits( double points, const QgsRenderCon { return points * 0.3527 * c.scaleFactor(); } - diff --git a/src/app/georeferencer/qgsgcpcanvasitem.h b/src/app/georeferencer/qgsgcpcanvasitem.h index 4a7b12ee5393..84cb5fc3958b 100644 --- a/src/app/georeferencer/qgsgcpcanvasitem.h +++ b/src/app/georeferencer/qgsgcpcanvasitem.h @@ -24,10 +24,10 @@ class QgsMapCanvas; class QgsGeorefDataPoint; -class QgsGCPCanvasItem final: public QgsMapCanvasItem +class QgsGCPCanvasItem final : public QgsMapCanvasItem { public: - QgsGCPCanvasItem( QgsMapCanvas *mapCanvas, QgsGeorefDataPoint *dataPoint, bool isGCPSource/* = true*/ ); + QgsGCPCanvasItem( QgsMapCanvas *mapCanvas, QgsGeorefDataPoint *dataPoint, bool isGCPSource /* = true*/ ); //! draws point information void paint( QPainter *p ) override; @@ -47,7 +47,6 @@ class QgsGCPCanvasItem final: public QgsMapCanvasItem void setPointColor( const QColor &color ); private: - QgsGeorefDataPoint *mDataPoint = nullptr; QSizeF mTextBounds; QBrush mPointBrush; diff --git a/src/app/georeferencer/qgsgcplist.cpp b/src/app/georeferencer/qgsgcplist.cpp index e0f7955582e3..75f547f40b61 100644 --- a/src/app/georeferencer/qgsgcplist.cpp +++ b/src/app/georeferencer/qgsgcplist.cpp @@ -152,14 +152,9 @@ bool QgsGCPList::saveGcps( const QString &filePath, const QgsCoordinateReference { const QgsPointXY transformedDestinationPoint = pt->transformedDestinationPoint( targetCrs, context ); points << QStringLiteral( "%1,%2,%3,%4,%5,%6,%7,%8" ) - .arg( qgsDoubleToString( transformedDestinationPoint.x() ), - qgsDoubleToString( transformedDestinationPoint.y() ), - qgsDoubleToString( pt->sourcePoint().x() ), - qgsDoubleToString( pt->sourcePoint().y() ) ) - .arg( pt->isEnabled() ) - .arg( qgsDoubleToString( pt->residual().x() ), - qgsDoubleToString( pt->residual().y() ), - qgsDoubleToString( std::sqrt( pt->residual().x() * pt->residual().x() + pt->residual().y() * pt->residual().y() ) ) ); + .arg( qgsDoubleToString( transformedDestinationPoint.x() ), qgsDoubleToString( transformedDestinationPoint.y() ), qgsDoubleToString( pt->sourcePoint().x() ), qgsDoubleToString( pt->sourcePoint().y() ) ) + .arg( pt->isEnabled() ) + .arg( qgsDoubleToString( pt->residual().x() ), qgsDoubleToString( pt->residual().y() ), qgsDoubleToString( std::sqrt( pt->residual().x() * pt->residual().x() + pt->residual().y() * pt->residual().y() ) ) ); points << Qt::endl; } return true; @@ -210,7 +205,7 @@ QList QgsGCPList::loadGcps( const QString &filePath, const QgsCoord lineNumber++; QStringList ls; if ( line.contains( ',' ) ) // in previous format "\t" is delimiter of points in new - "," - ls = line.split( ',' ); // points from new georeferencer + ls = line.split( ',' ); // points from new georeferencer else ls = line.split( '\t' ); // points from prev georeferencer @@ -221,7 +216,7 @@ QList QgsGCPList::loadGcps( const QString &filePath, const QgsCoord } const QgsPointXY destinationPoint( ls.at( 0 ).toDouble(), ls.at( 1 ).toDouble() ); // map x,y - const QgsPointXY sourcePoint( ls.at( 2 ).toDouble(), ls.at( 3 ).toDouble() ); // source x,y + const QgsPointXY sourcePoint( ls.at( 2 ).toDouble(), ls.at( 3 ).toDouble() ); // source x,y bool enable = true; if ( ls.count() >= 5 ) { diff --git a/src/app/georeferencer/qgsgcplist.h b/src/app/georeferencer/qgsgcplist.h index 0cc3ec5a45f2..2fd99e700550 100644 --- a/src/app/georeferencer/qgsgcplist.h +++ b/src/app/georeferencer/qgsgcplist.h @@ -33,19 +33,18 @@ class QgsGeorefTransform; * * The container does NOT own the points -- they have to be manually deleted elsewhere!! */ -class APP_EXPORT QgsGCPList : public QList +class APP_EXPORT QgsGCPList : public QList { public: QgsGCPList() = default; QgsGCPList( const QgsGCPList &list ) = delete; - QgsGCPList &operator =( const QgsGCPList &list ) = delete; + QgsGCPList &operator=( const QgsGCPList &list ) = delete; /** * Creates vectors of source and destination points, where the destination points are all transformed to the * specified \a targetCrs. */ - void createGCPVectors( QVector &sourcePoints, QVector &destinationPoints, - const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const; + void createGCPVectors( QVector &sourcePoints, QVector &destinationPoints, const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context ) const; /** * Returns the count of currently enabled data points. @@ -60,14 +59,12 @@ class APP_EXPORT QgsGCPList : public QList * \param context transform context * \param residualUnit units for residual calculation. Supported values are QgsUnitTypes::RenderPixels or QgsUnitTypes::RenderMapUnits */ - void updateResiduals( QgsGeorefTransform *georefTransform, - const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context, - Qgis::RenderUnit residualUnit ); + void updateResiduals( QgsGeorefTransform *georefTransform, const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context, Qgis::RenderUnit residualUnit ); /** * Returns the container as a list of GCP points. */ - QList< QgsGcpPoint > asPoints() const; + QList asPoints() const; /** * Saves the GCPs to a text file. @@ -79,9 +76,7 @@ class APP_EXPORT QgsGCPList : public QList * * \returns TRUE on success */ - bool saveGcps( const QString &filePath, - const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context, - QString &error ) const; + bool saveGcps( const QString &filePath, const QgsCoordinateReferenceSystem &targetCrs, const QgsCoordinateTransformContext &context, QString &error ) const; /** * Loads GCPs from a text file. @@ -93,11 +88,7 @@ class APP_EXPORT QgsGCPList : public QList * * \returns TRUE on success */ - static QList< QgsGcpPoint > loadGcps( const QString &filePath, - const QgsCoordinateReferenceSystem &defaultDestinationCrs, - QgsCoordinateReferenceSystem &actualDestinationCrs, - QString &error ); - + static QList loadGcps( const QString &filePath, const QgsCoordinateReferenceSystem &defaultDestinationCrs, QgsCoordinateReferenceSystem &actualDestinationCrs, QString &error ); }; #endif diff --git a/src/app/georeferencer/qgsgcplistmodel.cpp b/src/app/georeferencer/qgsgcplistmodel.cpp index 37f732527f32..33f37397a9a8 100644 --- a/src/app/georeferencer/qgsgcplistmodel.cpp +++ b/src/app/georeferencer/qgsgcplistmodel.cpp @@ -50,8 +50,7 @@ void QgsGCPListModel::setTargetCrs( const QgsCoordinateReferenceSystem &targetCr mTargetCrs = targetCrs; mTransformContext = context; updateResiduals(); - emit dataChanged( index( 0, static_cast< int >( Column::DestinationX ) ), - index( rowCount() - 1, static_cast< int >( Column::DestinationY ) ) ); + emit dataChanged( index( 0, static_cast( Column::DestinationX ) ), index( rowCount() - 1, static_cast( Column::DestinationY ) ) ); } int QgsGCPListModel::rowCount( const QModelIndex & ) const @@ -61,7 +60,7 @@ int QgsGCPListModel::rowCount( const QModelIndex & ) const int QgsGCPListModel::columnCount( const QModelIndex & ) const { - return static_cast< int >( Column::LastColumn ); + return static_cast( Column::LastColumn ); } QVariant QgsGCPListModel::data( const QModelIndex &index, int role ) const @@ -73,7 +72,7 @@ QVariant QgsGCPListModel::data( const QModelIndex &index, int role ) const || index.column() >= columnCount() ) return QVariant(); - const Column column = static_cast< Column >( index.column() ); + const Column column = static_cast( index.column() ); const QgsGeorefDataPoint *point = mGCPList->at( index.row() ); switch ( role ) @@ -219,9 +218,8 @@ QVariant QgsGCPListModel::data( const QModelIndex &index, int role ) const break; } - case static_cast< int >( Role::SourcePointRole ): + case static_cast( Role::SourcePointRole ): return point->sourcePoint(); - } return QVariant(); } @@ -236,13 +234,13 @@ bool QgsGCPListModel::setData( const QModelIndex &index, const QVariant &value, return false; QgsGeorefDataPoint *point = mGCPList->at( index.row() ); - const Column column = static_cast< Column >( index.column() ); + const Column column = static_cast( index.column() ); switch ( column ) { case QgsGCPListModel::Column::Enabled: if ( role == Qt::CheckStateRole ) { - const bool checked = static_cast< Qt::CheckState >( value.toInt() ) == Qt::Checked; + const bool checked = static_cast( value.toInt() ) == Qt::Checked; point->setEnabled( checked ); emit dataChanged( index, index ); updateResiduals(); @@ -303,7 +301,7 @@ Qt::ItemFlags QgsGCPListModel::flags( const QModelIndex &index ) const || index.column() >= columnCount() ) return QAbstractTableModel::flags( index ); - const Column column = static_cast< Column >( index.column() ); + const Column column = static_cast( index.column() ); switch ( column ) { case QgsGCPListModel::Column::Enabled: @@ -354,7 +352,7 @@ QVariant QgsGCPListModel::headerData( int section, Qt::Orientation orientation, break; } - switch ( static_cast< Column >( section ) ) + switch ( static_cast( section ) ) { case QgsGCPListModel::Column::Enabled: return tr( "Enabled" ); @@ -367,7 +365,7 @@ QVariant QgsGCPListModel::headerData( int section, Qt::Orientation orientation, case QgsGCPListModel::Column::DestinationX: case QgsGCPListModel::Column::DestinationY: { - const QString heading = static_cast< Column >( section ) == QgsGCPListModel::Column::DestinationX ? tr( "Dest. X" ) : tr( "Dest. Y" ); + const QString heading = static_cast( section ) == QgsGCPListModel::Column::DestinationX ? tr( "Dest. X" ) : tr( "Dest. Y" ); switch ( role ) { case Qt::DisplayRole: @@ -430,8 +428,7 @@ void QgsGCPListModel::updateResiduals() return; mGCPList->updateResiduals( mGeorefTransform, mTargetCrs, mTransformContext, residualUnit() ); - emit dataChanged( index( 0, static_cast< int >( Column::ResidualDx ) ), - index( rowCount() - 1, static_cast< int >( Column::TotalResidual ) ) ); + emit dataChanged( index( 0, static_cast( Column::ResidualDx ) ), index( rowCount() - 1, static_cast( Column::TotalResidual ) ) ); } QString QgsGCPListModel::formatNumber( double number ) @@ -444,5 +441,3 @@ QString QgsGCPListModel::formatNumber( double number ) return QLocale().toString( number, 'f', decimalPlaces ); } - - diff --git a/src/app/georeferencer/qgsgcplistmodel.h b/src/app/georeferencer/qgsgcplistmodel.h index b8830aaa2048..9d8b40bbc981 100644 --- a/src/app/georeferencer/qgsgcplistmodel.h +++ b/src/app/georeferencer/qgsgcplistmodel.h @@ -87,7 +87,7 @@ class APP_EXPORT QgsGCPListModel : public QAbstractTableModel QgsCoordinateReferenceSystem mTargetCrs; QgsCoordinateTransformContext mTransformContext; - QgsGCPList *mGCPList = nullptr; + QgsGCPList *mGCPList = nullptr; QgsGeorefTransform *mGeorefTransform = nullptr; }; diff --git a/src/app/georeferencer/qgsgcplistwidget.cpp b/src/app/georeferencer/qgsgcplistwidget.cpp index aa14ded55dc5..07585c3ea7fa 100644 --- a/src/app/georeferencer/qgsgcplistwidget.cpp +++ b/src/app/georeferencer/qgsgcplistwidget.cpp @@ -48,20 +48,16 @@ QgsGCPListWidget::QgsGCPListWidget( QWidget *parent ) setAlternatingRowColors( true ); // set delegates for items - setItemDelegateForColumn( static_cast< int >( QgsGCPListModel::Column::SourceX ), mCoordDelegate ); - setItemDelegateForColumn( static_cast< int >( QgsGCPListModel::Column::SourceY ), mCoordDelegate ); - setItemDelegateForColumn( static_cast< int >( QgsGCPListModel::Column::DestinationX ), mDmsAndDdDelegate ); - setItemDelegateForColumn( static_cast< int >( QgsGCPListModel::Column::DestinationY ), mDmsAndDdDelegate ); - - connect( this, &QAbstractItemView::doubleClicked, - this, &QgsGCPListWidget::itemDoubleClicked ); - connect( this, &QAbstractItemView::clicked, - this, &QgsGCPListWidget::itemClicked ); - connect( this, &QWidget::customContextMenuRequested, - this, &QgsGCPListWidget::showContextMenu ); - - connect( mGCPListModel, &QgsGCPListModel::pointEnabled, this, [ = ]( QgsGeorefDataPoint * point, int row ) - { + setItemDelegateForColumn( static_cast( QgsGCPListModel::Column::SourceX ), mCoordDelegate ); + setItemDelegateForColumn( static_cast( QgsGCPListModel::Column::SourceY ), mCoordDelegate ); + setItemDelegateForColumn( static_cast( QgsGCPListModel::Column::DestinationX ), mDmsAndDdDelegate ); + setItemDelegateForColumn( static_cast( QgsGCPListModel::Column::DestinationY ), mDmsAndDdDelegate ); + + connect( this, &QAbstractItemView::doubleClicked, this, &QgsGCPListWidget::itemDoubleClicked ); + connect( this, &QAbstractItemView::clicked, this, &QgsGCPListWidget::itemClicked ); + connect( this, &QWidget::customContextMenuRequested, this, &QgsGCPListWidget::showContextMenu ); + + connect( mGCPListModel, &QgsGCPListModel::pointEnabled, this, [=]( QgsGeorefDataPoint *point, int row ) { emit pointEnabled( point, row ); adjustTableContent(); return; @@ -176,7 +172,7 @@ void QgsGCPListWidget::showContextMenu( QPoint p ) if ( !mGCPList || 0 == mGCPList->count() ) return; - QMenu m;// = new QMenu(this); + QMenu m; // = new QMenu(this); const QModelIndex index = indexAt( p ); if ( index == QModelIndex() ) return; @@ -185,8 +181,7 @@ void QgsGCPListWidget::showContextMenu( QPoint p ) setCurrentIndex( index ); QAction *jumpToPointAction = new QAction( tr( "Recenter" ), this ); - connect( jumpToPointAction, &QAction::triggered, this, [ = ] - { + connect( jumpToPointAction, &QAction::triggered, this, [=] { const QModelIndex sourceIndex = static_cast( model() )->mapToSource( currentIndex() ); mPrevRow = sourceIndex.row(); mPrevColumn = sourceIndex.column(); @@ -208,7 +203,7 @@ void QgsGCPListWidget::removeRow() void QgsGCPListWidget::jumpToSourcePoint( const QModelIndex &modelIndex ) { - const QgsPointXY sourcePoint = mGCPListModel->data( modelIndex, static_cast< int >( QgsGCPListModel::Role::SourcePointRole ) ).value< QgsPointXY >(); + const QgsPointXY sourcePoint = mGCPListModel->data( modelIndex, static_cast( QgsGCPListModel::Role::SourcePointRole ) ).value(); if ( !sourcePoint.isEmpty() ) { emit jumpToGCP( sourcePoint ); diff --git a/src/app/georeferencer/qgsgcplistwidget.h b/src/app/georeferencer/qgsgcplistwidget.h index 54ec5d19a9ee..02fcd7796dcd 100644 --- a/src/app/georeferencer/qgsgcplistwidget.h +++ b/src/app/georeferencer/qgsgcplistwidget.h @@ -74,11 +74,11 @@ class QgsGCPListWidget : public QgsTableView void createItemContextMenu(); void adjustTableContent(); - QgsGCPList *mGCPList = nullptr; - QgsGCPListModel *mGCPListModel = nullptr; + QgsGCPList *mGCPList = nullptr; + QgsGCPListModel *mGCPListModel = nullptr; - QgsDmsAndDdDelegate *mDmsAndDdDelegate = nullptr; - QgsCoordDelegate *mCoordDelegate = nullptr; + QgsDmsAndDdDelegate *mDmsAndDdDelegate = nullptr; + QgsCoordDelegate *mCoordDelegate = nullptr; int mPrevRow = 0; int mPrevColumn = 0; diff --git a/src/app/georeferencer/qgsgeorefconfigdialog.cpp b/src/app/georeferencer/qgsgeorefconfigdialog.cpp index 28ce31004b43..460836363408 100644 --- a/src/app/georeferencer/qgsgeorefconfigdialog.cpp +++ b/src/app/georeferencer/qgsgeorefconfigdialog.cpp @@ -138,6 +138,4 @@ void QgsGeorefConfigDialog::writeSettings() s.setValue( QStringLiteral( "/Plugin-GeoReferencer/Config/WidthPDFMap" ), mPaperSizeComboBox->currentData().toSizeF().width() ); s.setValue( QStringLiteral( "/Plugin-GeoReferencer/Config/HeightPDFMap" ), mPaperSizeComboBox->currentData().toSizeF().height() ); - } - diff --git a/src/app/georeferencer/qgsgeorefdatapoint.cpp b/src/app/georeferencer/qgsgeorefdatapoint.cpp index 06a05eb88739..16f94b720235 100644 --- a/src/app/georeferencer/qgsgeorefdatapoint.cpp +++ b/src/app/georeferencer/qgsgeorefdatapoint.cpp @@ -21,9 +21,7 @@ #include "qgsgeorefdatapoint.h" #include "moc_qgsgeorefdatapoint.cpp" -QgsGeorefDataPoint::QgsGeorefDataPoint( QgsMapCanvas *srcCanvas, QgsMapCanvas *dstCanvas, - const QgsPointXY &sourceCoordinates, const QgsPointXY &destinationPoint, - const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled ) +QgsGeorefDataPoint::QgsGeorefDataPoint( QgsMapCanvas *srcCanvas, QgsMapCanvas *dstCanvas, const QgsPointXY &sourceCoordinates, const QgsPointXY &destinationPoint, const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled ) : mSrcCanvas( srcCanvas ) , mDstCanvas( dstCanvas ) , mGcpPoint( sourceCoordinates, destinationPoint, destinationPointCrs, enabled ) diff --git a/src/app/georeferencer/qgsgeorefdatapoint.h b/src/app/georeferencer/qgsgeorefdatapoint.h index 63d2904629c6..9e85024786b3 100644 --- a/src/app/georeferencer/qgsgeorefdatapoint.h +++ b/src/app/georeferencer/qgsgeorefdatapoint.h @@ -32,7 +32,6 @@ class APP_EXPORT QgsGeorefDataPoint : public QObject Q_OBJECT public: - /** * Constructor for QgsGeorefDataPoint * \param srcCanvas @@ -42,9 +41,7 @@ class APP_EXPORT QgsGeorefDataPoint : public QObject * \param destinationPointCrs CRS of destination point * \param enabled whether the point is currently enabled */ - QgsGeorefDataPoint( QgsMapCanvas *srcCanvas, QgsMapCanvas *dstCanvas, - const QgsPointXY &sourceCoordinates, const QgsPointXY &destinationPoint, - const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled ); + QgsGeorefDataPoint( QgsMapCanvas *srcCanvas, QgsMapCanvas *dstCanvas, const QgsPointXY &sourceCoordinates, const QgsPointXY &destinationPoint, const QgsCoordinateReferenceSystem &destinationPointCrs, bool enabled ); QgsGeorefDataPoint( const QgsGeorefDataPoint &p ); ~QgsGeorefDataPoint() override; diff --git a/src/app/georeferencer/qgsgeorefdelegates.cpp b/src/app/georeferencer/qgsgeorefdelegates.cpp index 369af63b695c..51b68104372e 100644 --- a/src/app/georeferencer/qgsgeorefdelegates.cpp +++ b/src/app/georeferencer/qgsgeorefdelegates.cpp @@ -31,8 +31,7 @@ QgsDmsAndDdDelegate::QgsDmsAndDdDelegate( QWidget *parent ) { } -QWidget *QgsDmsAndDdDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &/*option*/, - const QModelIndex &/*index*/ ) const +QWidget *QgsDmsAndDdDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex & /*index*/ ) const { QLineEdit *editor = new QLineEdit( parent ); QgsDMSAndDDValidator *validator = new QgsDMSAndDDValidator( editor ); @@ -49,8 +48,7 @@ void QgsDmsAndDdDelegate::setEditorData( QWidget *editor, const QModelIndex &ind lineEdit->setText( value ); } -void QgsDmsAndDdDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const +void QgsDmsAndDdDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const { QLineEdit *lineEdit = static_cast( editor ); const QString stringValue = lineEdit->text(); @@ -63,8 +61,7 @@ void QgsDmsAndDdDelegate::setModelData( QWidget *editor, QAbstractItemModel *mod model->setData( index, value, Qt::EditRole ); } -void QgsDmsAndDdDelegate::updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, - const QModelIndex &/*index*/ ) const +void QgsDmsAndDdDelegate::updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & /*index*/ ) const { editor->setGeometry( option.rect ); } @@ -92,8 +89,7 @@ QgsCoordDelegate::QgsCoordDelegate( QWidget *parent ) { } -QWidget *QgsCoordDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &/*option*/, - const QModelIndex &/*index*/ ) const +QWidget *QgsCoordDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex & /*index*/ ) const { QLineEdit *editor = new QLineEdit( parent ); const thread_local QRegularExpression re( QStringLiteral( "-?\\d*(\\.\\d+)?" ) ); diff --git a/src/app/georeferencer/qgsgeorefdelegates.h b/src/app/georeferencer/qgsgeorefdelegates.h index dd82515dddc3..193286803162 100644 --- a/src/app/georeferencer/qgsgeorefdelegates.h +++ b/src/app/georeferencer/qgsgeorefdelegates.h @@ -24,15 +24,12 @@ class QgsDmsAndDdDelegate : public QStyledItemDelegate public: explicit QgsDmsAndDdDelegate( QWidget *parent = nullptr ); - QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; + QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; void setEditorData( QWidget *editor, const QModelIndex &index ) const override; - void setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const override; + void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override; - void updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; + void updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; private: double dmsToDD( const QString &dms ) const; @@ -45,15 +42,12 @@ class QgsCoordDelegate : public QStyledItemDelegate public: explicit QgsCoordDelegate( QWidget *parent = nullptr ); - QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; + QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; void setEditorData( QWidget *editor, const QModelIndex &index ) const override; - void setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const override; + void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override; - void updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; + void updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; }; #endif // QGSDELEGATES_H diff --git a/src/app/georeferencer/qgsgeorefmainwindow.cpp b/src/app/georeferencer/qgsgeorefmainwindow.cpp index 49650a47dc88..f9813b8e06a3 100644 --- a/src/app/georeferencer/qgsgeorefmainwindow.cpp +++ b/src/app/georeferencer/qgsgeorefmainwindow.cpp @@ -202,10 +202,7 @@ void QgsGeoreferencerMainWindow::closeEvent( QCloseEvent *e ) void QgsGeoreferencerMainWindow::reset() { - if ( QMessageBox::question( this, - tr( "Reset Georeferencer" ), - tr( "Reset georeferencer and clear all GCP points?" ), - QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel ) != QMessageBox::Cancel ) + if ( QMessageBox::question( this, tr( "Reset Georeferencer" ), tr( "Reset georeferencer and clear all GCP points?" ), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel ) != QMessageBox::Cancel ) { mFileName.clear(); mModifiedFileName.clear(); @@ -244,7 +241,6 @@ void QgsGeoreferencerMainWindow::openLayer( Qgis::LayerType layerType, const QSt QString otherFiles = tr( "All other files (*)" ); switch ( layerType ) { - case Qgis::LayerType::Raster: { QString lastUsedFilter = settingLastRasterFileFilter->value(); @@ -321,8 +317,7 @@ void QgsGeoreferencerMainWindow::openLayer( Qgis::LayerType layerType, const QSt case Qgis::LayerType::Raster: if ( !QgsRasterLayer::isValidRasterFileName( mFileName, errMsg ) ) { - mMessageBar->pushMessage( tr( "Open Raster" ), tr( "%1 is not a supported raster data source.%2" ).arg( mFileName, - !errMsg.isEmpty() ? QStringLiteral( " (%1)" ).arg( errMsg ) : QString() ), Qgis::MessageLevel::Critical ); + mMessageBar->pushMessage( tr( "Open Raster" ), tr( "%1 is not a supported raster data source.%2" ).arg( mFileName, !errMsg.isEmpty() ? QStringLiteral( " (%1)" ).arg( errMsg ) : QString() ), Qgis::MessageLevel::Critical ); return; } break; @@ -375,7 +370,7 @@ void QgsGeoreferencerMainWindow::openLayer( Qgis::LayerType layerType, const QSt // load previously added points mGCPpointsFileName = mFileName + ".points"; QString error; - ( void )loadGCPs( error ); + ( void ) loadGCPs( error ); if ( mLayer ) mCanvas->setExtent( mLayer->extent() ); @@ -407,7 +402,7 @@ void QgsGeoreferencerMainWindow::dropEvent( QDropEvent *event ) // get the file list QList::iterator i; - QListurls = event->mimeData()->urls(); + QList urls = event->mimeData()->urls(); QString file; for ( i = urls.begin(); i != urls.end(); ++i ) { @@ -421,8 +416,7 @@ void QgsGeoreferencerMainWindow::dropEvent( QDropEvent *event ) } } - connect( timer, &QTimer::timeout, this, [this, timer, file] - { + connect( timer, &QTimer::timeout, this, [this, timer, file] { // TODO -- consider using querySublayers to determine this instead if ( QgsRasterLayer::isValidRasterFileName( file ) ) openLayer( Qgis::LayerType::Raster, file ); @@ -531,8 +525,7 @@ void QgsGeoreferencerMainWindow::generateGDALScript() int order = polynomialOrder( mTransformMethod ); if ( order != 0 ) { - gdalwarpCommand = generateGDALwarpCommand( resamplingStr, mCompressionMethod, mUseZeroForTrans, order, - mUserResX, mUserResY ); + gdalwarpCommand = generateGDALwarpCommand( resamplingStr, mCompressionMethod, mUseZeroForTrans, order, mUserResX, mUserResY ); showGDALScript( QStringList() << translateCommand << gdalwarpCommand ); } else @@ -571,9 +564,7 @@ void QgsGeoreferencerMainWindow::generateGDALScript() if ( isIncompatibleTransformMethod ) { - mMessageBar->pushMessage( tr( "Invalid Transform" ), tr( "GDAL scripting is not supported for %1 transformation." ) - .arg( QgsGcpTransformerInterface::methodToString( mTransformMethod ) ) - , Qgis::MessageLevel::Critical ); + mMessageBar->pushMessage( tr( "Invalid Transform" ), tr( "GDAL scripting is not supported for %1 transformation." ).arg( QgsGcpTransformerInterface::methodToString( mTransformMethod ) ), Qgis::MessageLevel::Critical ); } } @@ -655,8 +646,7 @@ void QgsGeoreferencerMainWindow::linkGeorefToQgis( bool link ) } } -void QgsGeoreferencerMainWindow::addPoint( const QgsPointXY &sourceCoords, const QgsPointXY &destinationMapCoords, const QgsCoordinateReferenceSystem &destinationCrs, - bool enable, bool finalize ) +void QgsGeoreferencerMainWindow::addPoint( const QgsPointXY &sourceCoords, const QgsPointXY &destinationMapCoords, const QgsCoordinateReferenceSystem &destinationCrs, bool enable, bool finalize ) { QgsGeorefDataPoint *pnt = new QgsGeorefDataPoint( mCanvas, QgisApp::instance()->mapCanvas(), sourceCoords, destinationMapCoords, destinationCrs, enable ); mPoints.append( pnt ); @@ -776,12 +766,10 @@ void QgsGeoreferencerMainWindow::showCoordDialog( const QgsPointXY &sourceCoordi { mNewlyAddedPoint = new QgsGeorefDataPoint( mCanvas, QgisApp::instance()->mapCanvas(), sourceCoordinates, QgsPointXY(), QgsCoordinateReferenceSystem(), true ); mMapCoordsDialog = new QgsMapCoordsDialog( QgisApp::instance()->mapCanvas(), mNewlyAddedPoint, lastProjection, this ); - connect( mMapCoordsDialog, &QgsMapCoordsDialog::pointAdded, this, [ = ]( const QgsPointXY & sourceLayerCoordinate, const QgsPointXY & destinationCoordinate, const QgsCoordinateReferenceSystem & destinationCrs ) - { + connect( mMapCoordsDialog, &QgsMapCoordsDialog::pointAdded, this, [=]( const QgsPointXY &sourceLayerCoordinate, const QgsPointXY &destinationCoordinate, const QgsCoordinateReferenceSystem &destinationCrs ) { addPoint( sourceLayerCoordinate, destinationCoordinate, destinationCrs ); } ); - connect( mMapCoordsDialog, &QObject::destroyed, this, [ = ] - { + connect( mMapCoordsDialog, &QObject::destroyed, this, [=] { delete mNewlyAddedPoint; mNewlyAddedPoint = nullptr; } ); @@ -796,8 +784,7 @@ void QgsGeoreferencerMainWindow::showCoordDialog( const QgsPointXY &sourceCoordi void QgsGeoreferencerMainWindow::loadGCPsDialog() { QString selectedFile = mFileName.isEmpty() ? QString() : mFileName + ".points"; - mGCPpointsFileName = QFileDialog::getOpenFileName( this, tr( "Load GCP Points" ), - selectedFile, tr( "GCP file" ) + " (*.points)" ); + mGCPpointsFileName = QFileDialog::getOpenFileName( this, tr( "Load GCP Points" ), selectedFile, tr( "GCP file" ) + " (*.points)" ); if ( mGCPpointsFileName.isEmpty() ) return; @@ -821,9 +808,7 @@ void QgsGeoreferencerMainWindow::saveGCPsDialog() } QString selectedFile = mFileName.isEmpty() ? QString() : mFileName + ".points"; - mGCPpointsFileName = QFileDialog::getSaveFileName( this, tr( "Save GCP Points" ), - selectedFile, - tr( "GCP file" ) + " (*.points)" ); + mGCPpointsFileName = QFileDialog::getSaveFileName( this, tr( "Save GCP Points" ), selectedFile, tr( "GCP file" ) + " (*.points)" ); if ( mGCPpointsFileName.isEmpty() ) return; @@ -1009,9 +994,9 @@ void QgsGeoreferencerMainWindow::createActions() connect( mActionReset, &QAction::triggered, this, &QgsGeoreferencerMainWindow::reset ); mActionOpenRaster->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ) ); - connect( mActionOpenRaster, &QAction::triggered, this, [ = ] { openLayer( Qgis::LayerType::Raster ); } ); + connect( mActionOpenRaster, &QAction::triggered, this, [=] { openLayer( Qgis::LayerType::Raster ); } ); - connect( mActionOpenVector, &QAction::triggered, this, [ = ] { openLayer( Qgis::LayerType::Vector ); } ); + connect( mActionOpenVector, &QAction::triggered, this, [=] { openLayer( Qgis::LayerType::Vector ); } ); mActionStartGeoref->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionStart.svg" ) ) ); connect( mActionStartGeoref, &QAction::triggered, this, &QgsGeoreferencerMainWindow::georeference ); @@ -1078,8 +1063,7 @@ void QgsGeoreferencerMainWindow::createActions() connect( mActionFullHistogramStretch, &QAction::triggered, this, &QgsGeoreferencerMainWindow::fullHistogramStretch ); mActionFullHistogramStretch->setEnabled( false ); - mActionQuit->setShortcuts( QList() << QKeySequence( QStringLiteral( "CTRL+Q" ) ) - << QKeySequence( Qt::Key_Escape ) ); + mActionQuit->setShortcuts( QList() << QKeySequence( QStringLiteral( "CTRL+Q" ) ) << QKeySequence( Qt::Key_Escape ) ); connect( mActionQuit, &QAction::triggered, this, &QWidget::close ); } @@ -1127,32 +1111,24 @@ void QgsGeoreferencerMainWindow::createMapCanvas() mToolAddPoint = new QgsGeorefToolAddPoint( mCanvas ); mToolAddPoint->setAction( mActionAddPoint ); - connect( mToolAddPoint, &QgsGeorefToolAddPoint::showCoordDialog, - this, &QgsGeoreferencerMainWindow::showCoordDialog ); + connect( mToolAddPoint, &QgsGeorefToolAddPoint::showCoordDialog, this, &QgsGeoreferencerMainWindow::showCoordDialog ); mToolDeletePoint = new QgsGeorefToolDeletePoint( mCanvas ); mToolDeletePoint->setAction( mActionDeletePoint ); - connect( mToolDeletePoint, &QgsGeorefToolDeletePoint::deleteDataPoint, - this, static_cast( &QgsGeoreferencerMainWindow::deleteDataPoint ) ); + connect( mToolDeletePoint, &QgsGeorefToolDeletePoint::deleteDataPoint, this, static_cast( &QgsGeoreferencerMainWindow::deleteDataPoint ) ); mToolMovePoint = new QgsGeorefToolMovePoint( mCanvas ); mToolMovePoint->setAction( mActionMoveGCPPoint ); - connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointPressed, - this, &QgsGeoreferencerMainWindow::selectPoint ); - connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointMoved, - this, &QgsGeoreferencerMainWindow::movePoint ); - connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointReleased, - this, &QgsGeoreferencerMainWindow::releasePoint ); + connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointPressed, this, &QgsGeoreferencerMainWindow::selectPoint ); + connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointMoved, this, &QgsGeoreferencerMainWindow::movePoint ); + connect( mToolMovePoint, &QgsGeorefToolMovePoint::pointReleased, this, &QgsGeoreferencerMainWindow::releasePoint ); // Point in QGIS Map mToolMovePointQgis = new QgsGeorefToolMovePoint( QgisApp::instance()->mapCanvas() ); mToolMovePointQgis->setAction( mActionMoveGCPPoint ); - connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointPressed, - this, &QgsGeoreferencerMainWindow::selectPoint ); - connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointMoved, - this, &QgsGeoreferencerMainWindow::movePoint ); - connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointReleased, - this, &QgsGeoreferencerMainWindow::releasePoint ); + connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointPressed, this, &QgsGeoreferencerMainWindow::selectPoint ); + connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointMoved, this, &QgsGeoreferencerMainWindow::movePoint ); + connect( mToolMovePointQgis, &QgsGeorefToolMovePoint::pointReleased, this, &QgsGeoreferencerMainWindow::releasePoint ); QgsSettings s; double zoomFactor = s.value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toDouble(); @@ -1172,8 +1148,7 @@ void QgsGeoreferencerMainWindow::createMapCanvas() void QgsGeoreferencerMainWindow::createMenus() { // Get platform for menu layout customization (Gnome, Kde, Mac, Win) - QDialogButtonBox::ButtonLayout layout = - QDialogButtonBox::ButtonLayout( style()->styleHint( QStyle::SH_DialogButtonLayout, nullptr, this ) ); + QDialogButtonBox::ButtonLayout layout = QDialogButtonBox::ButtonLayout( style()->styleHint( QStyle::SH_DialogButtonLayout, nullptr, this ) ); mPanelMenu = new QMenu( tr( "Panels" ) ); mPanelMenu->setObjectName( QStringLiteral( "mPanelMenu" ) ); @@ -1212,8 +1187,7 @@ void QgsGeoreferencerMainWindow::createDockWidgets() dockWidgetGCPpoints->setWidget( mGCPListWidget ); connect( mGCPListWidget, &QgsGCPListWidget::jumpToGCP, this, &QgsGeoreferencerMainWindow::recenterOnPoint ); - connect( mGCPListWidget, static_cast( &QgsGCPListWidget::deleteDataPoint ), - this, static_cast( &QgsGeoreferencerMainWindow::deleteDataPoint ) ); + connect( mGCPListWidget, static_cast( &QgsGCPListWidget::deleteDataPoint ), this, static_cast( &QgsGeoreferencerMainWindow::deleteDataPoint ) ); connect( mGCPListWidget, &QgsGCPListWidget::pointEnabled, this, &QgsGeoreferencerMainWindow::updateGeorefTransform ); } @@ -1293,7 +1267,7 @@ void QgsGeoreferencerMainWindow::setupConnections() connect( mCanvas, &QgsMapCanvas::zoomNextStatusChanged, mActionZoomNext, &QAction::setEnabled ); // Connect mapCanvas rotation widget - connect( mRotationEdit, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsGeoreferencerMainWindow::updateCanvasRotation ); + connect( mRotationEdit, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsGeoreferencerMainWindow::updateCanvasRotation ); connect( QgisApp::instance()->mapCanvas(), &QgsMapCanvas::destinationCrsChanged, this, &QgsGeoreferencerMainWindow::invalidateCanvasCoords ); } @@ -1316,7 +1290,7 @@ void QgsGeoreferencerMainWindow::loadSource( Qgis::LayerType layerType, const QS QgsVectorLayer::LayerOptions options( QgsProject::instance()->transformContext() ); // never prompt for a crs selection for the input layer! options.skipCrsValidation = true; - mLayer = std::make_unique< QgsVectorLayer >( uri, QStringLiteral( "Vector" ), provider, options ); + mLayer = std::make_unique( uri, QStringLiteral( "Vector" ), provider, options ); break; } @@ -1325,7 +1299,7 @@ void QgsGeoreferencerMainWindow::loadSource( Qgis::LayerType layerType, const QS QgsRasterLayer::LayerOptions options( true, QgsProject::instance()->transformContext() ); // never prompt for a crs selection for the input raster! options.skipCrsValidation = true; - mLayer = std::make_unique< QgsRasterLayer >( uri, QStringLiteral( "Raster" ), provider, options ); + mLayer = std::make_unique( uri, QStringLiteral( "Raster" ), provider, options ); break; } @@ -1420,10 +1394,7 @@ void QgsGeoreferencerMainWindow::writeSettings() bool QgsGeoreferencerMainWindow::loadGCPs( QString &error ) { QgsCoordinateReferenceSystem actualDestinationCrs; - const QList< QgsGcpPoint > points = QgsGCPList::loadGcps( mGCPpointsFileName, - mTargetCrs, - actualDestinationCrs, - error ); + const QList points = QgsGCPList::loadGcps( mGCPpointsFileName, mTargetCrs, actualDestinationCrs, error ); if ( !error.isEmpty() ) return false; @@ -1468,10 +1439,7 @@ QgsGeoreferencerMainWindow::SaveGCPs QgsGeoreferencerMainWindow::checkNeedGCPSav if ( !equalGCPlists( mSavedPoints, mPoints ) ) { - QMessageBox::StandardButton a = QMessageBox::question( this, tr( "Save GCPs" ), - tr( "Save GCP points?" ), - QMessageBox::Save | QMessageBox::Discard - | QMessageBox::Cancel ); + QMessageBox::StandardButton a = QMessageBox::question( this, tr( "Save GCPs" ), tr( "Save GCP points?" ), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel ); if ( a == QMessageBox::Save ) { return QgsGeoreferencerMainWindow::GCPSAVE; @@ -1489,8 +1457,7 @@ bool QgsGeoreferencerMainWindow::georeference() if ( !validate() ) return false; - if ( mLayer->type() == Qgis::LayerType::Raster && mCreateWorldFileOnly && ( QgsGcpTransformerInterface::TransformMethod::Linear == mGeorefTransform.transformParametrisation() || - QgsGcpTransformerInterface::TransformMethod::Helmert == mGeorefTransform.transformParametrisation() ) ) + if ( mLayer->type() == Qgis::LayerType::Raster && mCreateWorldFileOnly && ( QgsGcpTransformerInterface::TransformMethod::Linear == mGeorefTransform.transformParametrisation() || QgsGcpTransformerInterface::TransformMethod::Helmert == mGeorefTransform.transformParametrisation() ) ) { QgsPointXY origin; double pixelXSize, pixelYSize, rotation; @@ -1504,12 +1471,10 @@ bool QgsGeoreferencerMainWindow::georeference() { if ( QFile::exists( mWorldFileName ) ) { - int r = QMessageBox::question( this, tr( "Georeference" ), - tr( "

The selected file already seems to have a " - "world file! Do you want to replace it with the " - "new world file?

" ), - QMessageBox::Yes | QMessageBox::Default, - QMessageBox::No | QMessageBox::Escape ); + int r = QMessageBox::question( this, tr( "Georeference" ), tr( "

The selected file already seems to have a " + "world file! Do you want to replace it with the " + "new world file?

" ), + QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ); if ( r == QMessageBox::No ) return false; else @@ -1555,7 +1520,6 @@ bool QgsGeoreferencerMainWindow::georeference() bool QgsGeoreferencerMainWindow::georeferenceRaster() { - QgsImageWarperTask *task = new QgsImageWarperTask( mFileName, mModifiedFileName, @@ -1565,16 +1529,15 @@ bool QgsGeoreferencerMainWindow::georeferenceRaster() mCompressionMethod, mTargetCrs, mUserResX, - mUserResY ); + mUserResY + ); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Georeferencing layer…" ), tr( "Abort" ), 0, 100, this ); + std::unique_ptr progressDialog = std::make_unique( tr( "Georeferencing layer…" ), tr( "Abort" ), 0, 100, this ); progressDialog->setWindowTitle( tr( "Georeferencer" ) ); - connect( task, &QgsTask::progressChanged, progressDialog.get(), [ & ]( double progress ) - { - progressDialog->setValue( static_cast< int >( progress ) ); + connect( task, &QgsTask::progressChanged, progressDialog.get(), [&]( double progress ) { + progressDialog->setValue( static_cast( progress ) ); } ); - connect( progressDialog.get(), &QProgressDialog::canceled, task, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, task, [&] { task->cancel(); } ); progressDialog->show(); @@ -1583,15 +1546,13 @@ bool QgsGeoreferencerMainWindow::georeferenceRaster() // for illustrating that the task is running in the main window otherwise, so stick with the dialog for now QEventLoop loop; bool result = true; - connect( task, &QgsTask::taskCompleted, &loop, [&loop, this] - { + connect( task, &QgsTask::taskCompleted, &loop, [&loop, this] { postProcessGeoreferencedLayer( mCreateWorldFileOnly ? mFileName : mModifiedFileName, Qgis::LayerType::Raster, QStringLiteral( "gdal" ) ); loop.quit(); } ); - connect( task, &QgsTask::taskTerminated, &loop, [&loop, this, task, &result] - { + connect( task, &QgsTask::taskTerminated, &loop, [&loop, this, task, &result] { switch ( task->result() ) { case QgsImageWarper::Result::Success: @@ -1629,17 +1590,14 @@ bool QgsGeoreferencerMainWindow::georeferenceRaster() bool QgsGeoreferencerMainWindow::georeferenceVector() { - QgsVectorWarperTask *task = new QgsVectorWarperTask( mTransformMethod, - mPoints.asPoints(), mTargetCrs, qobject_cast< QgsVectorLayer * >( mLayer.get() ), mModifiedFileName ); + QgsVectorWarperTask *task = new QgsVectorWarperTask( mTransformMethod, mPoints.asPoints(), mTargetCrs, qobject_cast( mLayer.get() ), mModifiedFileName ); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Georeferencing layer…" ), tr( "Abort" ), 0, 100, this ); + std::unique_ptr progressDialog = std::make_unique( tr( "Georeferencing layer…" ), tr( "Abort" ), 0, 100, this ); progressDialog->setWindowTitle( tr( "Georeferencer" ) ); - connect( task, &QgsTask::progressChanged, progressDialog.get(), [ & ]( double progress ) - { - progressDialog->setValue( static_cast< int >( progress ) ); + connect( task, &QgsTask::progressChanged, progressDialog.get(), [&]( double progress ) { + progressDialog->setValue( static_cast( progress ) ); } ); - connect( progressDialog.get(), &QProgressDialog::canceled, task, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, task, [&] { task->cancel(); } ); progressDialog->show(); @@ -1648,14 +1606,12 @@ bool QgsGeoreferencerMainWindow::georeferenceVector() // for illustrating that the task is running in the main window otherwise, so stick with the dialog for now QEventLoop loop; bool result = true; - connect( task, &QgsTask::taskCompleted, &loop, [&loop, this] - { + connect( task, &QgsTask::taskCompleted, &loop, [&loop, this] { postProcessGeoreferencedLayer( mModifiedFileName, Qgis::LayerType::Vector, QStringLiteral( "ogr" ) ); loop.quit(); } ); - connect( task, &QgsTask::taskTerminated, &loop, [&loop, this, task, &result] - { + connect( task, &QgsTask::taskTerminated, &loop, [&loop, this, task, &result] { if ( task->result() != QgsVectorWarperTask::Result::Canceled ) { mMessageBar->pushMessage( tr( "Transform Failed" ), task->errorMessage(), Qgis::MessageLevel::Critical ); @@ -1812,7 +1768,7 @@ bool QgsGeoreferencerMainWindow::writePDFMapFile( const QString &fileName, const //create layout QgsLayout layout( QgsProject::instance() ); - std::unique_ptr< QgsLayoutItemPage > page = std::make_unique< QgsLayoutItemPage >( &layout ); + std::unique_ptr page = std::make_unique( &layout ); double leftMargin = 8; double topMargin = 8; @@ -1879,10 +1835,10 @@ bool QgsGeoreferencerMainWindow::writePDFReportFile( const QString &fileName, co //create layout A4 with 300 dpi QgsLayout layout( QgsProject::instance() ); - std::unique_ptr< QgsLayoutItemPage > page = std::make_unique< QgsLayoutItemPage >( &layout ); + std::unique_ptr page = std::make_unique( &layout ); page->setPageSize( QgsLayoutSize( 210, 297 ) ); //A4 layout.pageCollection()->addPage( page.release() ); - std::unique_ptr< QgsLayoutItemPage > page2 = std::make_unique< QgsLayoutItemPage >( &layout ); + std::unique_ptr page2 = std::make_unique( &layout ); page2->setPageSize( QgsLayoutSize( 210, 297 ) ); //A4 layout.pageCollection()->addPage( page2.release() ); @@ -2057,12 +2013,12 @@ bool QgsGeoreferencerMainWindow::writePDFReportFile( const QString &fileName, co gcpTable->setColumns( gcpTableColumns ); QgsGCPList::const_iterator gcpIt = mPoints.constBegin(); - QVector< QStringList > gcpTableContents; + QVector gcpTableContents; for ( ; gcpIt != mPoints.constEnd(); ++gcpIt ) { QStringList currentGCPStrings; QPointF residual = ( *gcpIt )->residual(); - double residualTot = std::sqrt( residual.x() * residual.x() + residual.y() * residual.y() ); + double residualTot = std::sqrt( residual.x() * residual.x() + residual.y() * residual.y() ); currentGCPStrings << QString::number( ( *gcpIt )->id() ); if ( ( *gcpIt )->isEnabled() ) @@ -2077,7 +2033,7 @@ bool QgsGeoreferencerMainWindow::writePDFReportFile( const QString &fileName, co const QgsPointXY transformedDestinationPoint = ( *gcpIt )->transformedDestinationPoint( mTargetCrs, QgsProject::instance()->transformContext() ); currentGCPStrings << QString::number( ( *gcpIt )->sourcePoint().x(), 'f', 0 ) << QString::number( ( *gcpIt )->sourcePoint().y(), 'f', 0 ) << QString::number( transformedDestinationPoint.x(), 'f', 3 ) - << QString::number( transformedDestinationPoint.y(), 'f', 3 ) << QString::number( residual.x() ) << QString::number( residual.y() ) << QString::number( residualTot ); + << QString::number( transformedDestinationPoint.y(), 'f', 3 ) << QString::number( residual.x() ) << QString::number( residual.y() ) << QString::number( residualTot ); gcpTableContents << currentGCPStrings; } @@ -2144,8 +2100,7 @@ void QgsGeoreferencerMainWindow::showGDALScript( const QStringList &commands ) // create window to show gdal script QDialogButtonBox *bbxGdalScript = new QDialogButtonBox( QDialogButtonBox::Cancel, Qt::Horizontal, this ); - QPushButton *pbnCopyInClipBoard = new QPushButton( QgsApplication::getThemeIcon( QStringLiteral( "/mActionEditPaste.svg" ) ), - tr( "Copy to Clipboard" ), bbxGdalScript ); + QPushButton *pbnCopyInClipBoard = new QPushButton( QgsApplication::getThemeIcon( QStringLiteral( "/mActionEditPaste.svg" ) ), tr( "Copy to Clipboard" ), bbxGdalScript ); bbxGdalScript->addButton( pbnCopyInClipBoard, QDialogButtonBox::AcceptRole ); QPlainTextEdit *pteScript = new QPlainTextEdit(); @@ -2185,11 +2140,7 @@ QString QgsGeoreferencerMainWindow::generateGDALtranslateCommand( bool generateT { const QgsPointXY pixel = mGeorefTransform.toSourcePixel( pt->sourcePoint() ); const QgsPointXY transformedDestinationPoint = pt->transformedDestinationPoint( mTargetCrs, QgsProject::instance()->transformContext() ); - gdalCommand << QStringLiteral( "-gcp %1 %2 %3 %4" ).arg( - qgsDoubleToString( pixel.x(), 3 ), - qgsDoubleToString( -pixel.y(), 3 ), - qgsDoubleToString( transformedDestinationPoint.x(), precision ), - qgsDoubleToString( transformedDestinationPoint.y(), precision ) ); + gdalCommand << QStringLiteral( "-gcp %1 %2 %3 %4" ).arg( qgsDoubleToString( pixel.x(), 3 ), qgsDoubleToString( -pixel.y(), 3 ), qgsDoubleToString( transformedDestinationPoint.x(), precision ), qgsDoubleToString( transformedDestinationPoint.y(), precision ) ); } QFileInfo rasterFileInfo( mFileName ); @@ -2210,11 +2161,7 @@ QString QgsGeoreferencerMainWindow::generateGDALogr2ogrCommand() const for ( QgsGeorefDataPoint *pt : std::as_const( mPoints ) ) { const QgsPointXY dest = pt->transformedDestinationPoint( mTargetCrs, QgsProject::instance()->transformContext() ); - gdalCommand << QStringLiteral( "-gcp %1 %2 %3 %4" ).arg( - qgsDoubleToString( pt->sourcePoint().x(), sourcePrecision ), - qgsDoubleToString( pt->sourcePoint().y(), sourcePrecision ), - qgsDoubleToString( dest.x(), destPrecision ), - qgsDoubleToString( dest.y(), destPrecision ) ); + gdalCommand << QStringLiteral( "-gcp %1 %2 %3 %4" ).arg( qgsDoubleToString( pt->sourcePoint().x(), sourcePrecision ), qgsDoubleToString( pt->sourcePoint().y(), sourcePrecision ), qgsDoubleToString( dest.x(), destPrecision ), qgsDoubleToString( dest.y(), destPrecision ) ); } switch ( mTransformMethod ) @@ -2249,8 +2196,7 @@ QString QgsGeoreferencerMainWindow::generateGDALogr2ogrCommand() const return gdalCommand.join( QLatin1Char( ' ' ) ); } -QString QgsGeoreferencerMainWindow::generateGDALwarpCommand( const QString &resampling, const QString &compress, - bool useZeroForTrans, int order, double targetResX, double targetResY ) +QString QgsGeoreferencerMainWindow::generateGDALwarpCommand( const QString &resampling, const QString &compress, bool useZeroForTrans, int order, double targetResX, double targetResY ) { QStringList gdalCommand; gdalCommand << QStringLiteral( "gdalwarp" ) << QStringLiteral( "-r" ) << resampling; @@ -2301,8 +2247,7 @@ bool QgsGeoreferencerMainWindow::validate() return false; } - if ( mModifiedFileName.isEmpty() && ( !mCreateWorldFileOnly - || ( QgsGcpTransformerInterface::TransformMethod::Linear != mTransformMethod && QgsGcpTransformerInterface::TransformMethod::Helmert != mTransformMethod ) ) ) + if ( mModifiedFileName.isEmpty() && ( !mCreateWorldFileOnly || ( QgsGcpTransformerInterface::TransformMethod::Linear != mTransformMethod && QgsGcpTransformerInterface::TransformMethod::Helmert != mTransformMethod ) ) ) { QMessageBox::information( this, tr( "Georeferencer" ), tr( "Please set output file name." ) ); showTransformSettingsDialog(); @@ -2311,9 +2256,7 @@ bool QgsGeoreferencerMainWindow::validate() if ( mPoints.count() < static_cast( mGeorefTransform.minimumGcpCount() ) ) { - mMessageBar->pushMessage( tr( "Not Enough GCPs" ), tr( "%1 transformation requires at least %n GCPs. Please define more.", nullptr, mGeorefTransform.minimumGcpCount() ) - .arg( QgsGcpTransformerInterface::methodToString( mTransformMethod ) ) - , Qgis::MessageLevel::Critical ); + mMessageBar->pushMessage( tr( "Not Enough GCPs" ), tr( "%1 transformation requires at least %n GCPs. Please define more.", nullptr, mGeorefTransform.minimumGcpCount() ).arg( QgsGcpTransformerInterface::methodToString( mTransformMethod ) ), Qgis::MessageLevel::Critical ); return false; } @@ -2349,9 +2292,7 @@ bool QgsGeoreferencerMainWindow::updateGeorefTransform() // Samples the given rectangle at numSamples per edge. // Returns an axis aligned bounding box which contains the transformed samples. -QgsRectangle QgsGeoreferencerMainWindow::transformViewportBoundingBox( const QgsRectangle &canvasExtent, - QgsGeorefTransform &t, - bool rasterToWorld, uint numSamples ) +QgsRectangle QgsGeoreferencerMainWindow::transformViewportBoundingBox( const QgsRectangle &canvasExtent, QgsGeorefTransform &t, bool rasterToWorld, uint numSamples ) { double minX, minY; double maxX, maxY; @@ -2364,7 +2305,7 @@ QgsRectangle QgsGeoreferencerMainWindow::transformViewportBoundingBox( const Qgs double dY = canvasExtent.yMaximum(); double stepX = numSamples ? ( dX - oX ) / ( numSamples - 1 ) : 0.0; double stepY = numSamples ? ( dY - oY ) / ( numSamples - 1 ) : 0.0; - for ( uint s = 0u; s < numSamples; s++ ) + for ( uint s = 0u; s < numSamples; s++ ) { for ( uint edge = 0; edge < 4; edge++ ) { @@ -2446,9 +2387,7 @@ bool QgsGeoreferencerMainWindow::checkFileExisting( const QString &fileName, con { if ( QFile::exists( fileName ) ) { - int r = QMessageBox::question( this, title, question, - QMessageBox::Yes | QMessageBox::Default, - QMessageBox::No | QMessageBox::Escape ); + int r = QMessageBox::question( this, title, question, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ); if ( r == QMessageBox::No ) return false; else @@ -2459,7 +2398,7 @@ bool QgsGeoreferencerMainWindow::checkFileExisting( const QString &fileName, con return true; } -bool QgsGeoreferencerMainWindow::equalGCPlists( const QList< QgsGcpPoint > &list1, const QgsGCPList &list2 ) +bool QgsGeoreferencerMainWindow::equalGCPlists( const QList &list1, const QgsGCPList &list2 ) { if ( list1.count() != list2.count() ) return false; diff --git a/src/app/georeferencer/qgsgeorefmainwindow.h b/src/app/georeferencer/qgsgeorefmainwindow.h index eea426053e92..eb609e575a2a 100644 --- a/src/app/georeferencer/qgsgeorefmainwindow.h +++ b/src/app/georeferencer/qgsgeorefmainwindow.h @@ -116,8 +116,7 @@ class APP_EXPORT QgsGeoreferencerMainWindow : public QMainWindow, private Ui::Qg * \param enable * \param finalize */ - void addPoint( const QgsPointXY &sourceCoords, const QgsPointXY &destinationMapCoords, - const QgsCoordinateReferenceSystem &destinationCrs, bool enable = true, bool finalize = true ); + void addPoint( const QgsPointXY &sourceCoords, const QgsPointXY &destinationMapCoords, const QgsCoordinateReferenceSystem &destinationCrs, bool enable = true, bool finalize = true ); void deleteDataPoint( QPoint pixelCoords ); void deleteDataPoint( int index ); @@ -204,13 +203,11 @@ class APP_EXPORT QgsGeoreferencerMainWindow : public QMainWindow, private Ui::Qg * For values in the range 1 to 3, the parameter "order" prescribes the degree of the interpolating polynomials to use, * a value of -1 indicates that thin plate spline interpolation should be used for warping. */ - QString generateGDALwarpCommand( const QString &resampling, const QString &compress, bool useZeroForTrans, int order, - double targetResX, double targetResY ); + QString generateGDALwarpCommand( const QString &resampling, const QString &compress, bool useZeroForTrans, int order, double targetResX, double targetResY ); // utils bool validate(); - QgsRectangle transformViewportBoundingBox( const QgsRectangle &canvasExtent, QgsGeorefTransform &t, - bool rasterToWorld = true, uint numSamples = 4 ); + QgsRectangle transformViewportBoundingBox( const QgsRectangle &canvasExtent, QgsGeorefTransform &t, bool rasterToWorld = true, uint numSamples = 4 ); QString convertResamplingEnumToString( QgsImageWarper::ResamplingMethod resampling ); int polynomialOrder( QgsGeorefTransform::TransformMethod transform ); QString guessWorldFileName( const QString &sourceFileName ); @@ -261,7 +258,7 @@ class APP_EXPORT QgsGeoreferencerMainWindow : public QMainWindow, private Ui::Qg QString mPdfOutputFile; QString mPdfOutputMapFile; bool mSaveGcp = false; - double mUserResX, mUserResY; // User specified target scale + double mUserResX, mUserResY; // User specified target scale QgsGcpTransformerInterface::TransformMethod mTransformMethod = QgsGcpTransformerInterface::TransformMethod::InvalidTransform; QgsImageWarper::ResamplingMethod mResamplingMethod; @@ -270,10 +267,10 @@ class APP_EXPORT QgsGeoreferencerMainWindow : public QMainWindow, private Ui::Qg bool mCreateWorldFileOnly = false; QgsGCPList mPoints; - QList< QgsGcpPoint > mSavedPoints; + QList mSavedPoints; QgsMapCanvas *mCanvas = nullptr; - std::unique_ptr< QgsMapLayer > mLayer; + std::unique_ptr mLayer; QgsMapTool *mToolZoomIn = nullptr; QgsMapTool *mToolZoomOut = nullptr; diff --git a/src/app/georeferencer/qgsgeoreftransform.cpp b/src/app/georeferencer/qgsgeoreftransform.cpp index ce4f085c8867..4ffdcb201157 100644 --- a/src/app/georeferencer/qgsgeoreftransform.cpp +++ b/src/app/georeferencer/qgsgeoreftransform.cpp @@ -66,9 +66,7 @@ QgsPointXY QgsGeorefTransform::toSourceCoordinate( const QgsPointXY &pixel ) con bool QgsGeorefTransform::providesAccurateInverseTransformation() const { - return ( mTransformParametrisation == TransformMethod::Linear - || mTransformParametrisation == TransformMethod::Helmert - || mTransformParametrisation == TransformMethod::PolynomialOrder1 ); + return ( mTransformParametrisation == TransformMethod::Linear || mTransformParametrisation == TransformMethod::Helmert || mTransformParametrisation == TransformMethod::PolynomialOrder1 ); } bool QgsGeorefTransform::parametersInitialized() const @@ -78,7 +76,7 @@ bool QgsGeorefTransform::parametersInitialized() const QgsGcpTransformerInterface *QgsGeorefTransform::clone() const { - std::unique_ptr< QgsGeorefTransform > res( new QgsGeorefTransform( *this ) ); + std::unique_ptr res( new QgsGeorefTransform( *this ) ); res->updateParametersFromGcps( mSourceCoordinates, mDestinationCoordinates, mInvertYAxis ); return res.release(); } @@ -95,7 +93,7 @@ bool QgsGeorefTransform::updateParametersFromGcps( const QVector &so } if ( sourceCoordinates.size() != destinationCoordinates.size() ) // Defensive sanity check { - throw ( std::domain_error( "Internal error: GCP mapping is not one-to-one" ) ); + throw( std::domain_error( "Internal error: GCP mapping is not one-to-one" ) ); } if ( sourceCoordinates.size() < minimumGcpCount() ) { @@ -169,7 +167,6 @@ bool QgsGeorefTransform::getLinearOriginScale( QgsPointXY &origin, double &scale bool QgsGeorefTransform::getOriginScaleRotation( QgsPointXY &origin, double &scaleX, double &scaleY, double &rotation ) const { - if ( mTransformParametrisation == TransformMethod::Linear ) { rotation = 0.0; @@ -180,7 +177,7 @@ bool QgsGeorefTransform::getOriginScaleRotation( QgsPointXY &origin, double &sca { double scale; QgsHelmertGeorefTransform *transform = dynamic_cast( mGeorefTransformImplementation.get() ); - if ( !transform || ! transform->getOriginScaleRotation( origin, scale, rotation ) ) + if ( !transform || !transform->getOriginScaleRotation( origin, scale, rotation ) ) { return false; } @@ -205,5 +202,3 @@ bool QgsGeorefTransform::transformPrivate( const QgsPointXY &src, QgsPointXY &ds dst.setY( y ); return true; } - - diff --git a/src/app/georeferencer/qgsgeoreftransform.h b/src/app/georeferencer/qgsgeoreftransform.h index 5646907cbbff..587ec1a5e28c 100644 --- a/src/app/georeferencer/qgsgeoreftransform.h +++ b/src/app/georeferencer/qgsgeoreftransform.h @@ -36,7 +36,6 @@ class APP_EXPORT QgsGeorefTransform : public QgsGcpTransformerInterface { public: - explicit QgsGeorefTransform( TransformMethod parametrisation ); QgsGeorefTransform(); ~QgsGeorefTransform() override; @@ -119,7 +118,7 @@ class APP_EXPORT QgsGeorefTransform : public QgsGcpTransformerInterface private: // shallow copy constructor QgsGeorefTransform( const QgsGeorefTransform &other ); - QgsGeorefTransform &operator= ( const QgsGeorefTransform & ) = delete; + QgsGeorefTransform &operator=( const QgsGeorefTransform & ) = delete; bool transformPrivate( const QgsPointXY &src, QgsPointXY &dst, bool inverseTransform ) const; @@ -127,7 +126,7 @@ class APP_EXPORT QgsGeorefTransform : public QgsGcpTransformerInterface QVector mDestinationCoordinates; bool mInvertYAxis = false; - std::unique_ptr< QgsGcpTransformerInterface > mGeorefTransformImplementation; + std::unique_ptr mGeorefTransformImplementation; TransformMethod mTransformParametrisation = TransformMethod::InvalidTransform; bool mParametersInitialized = false; diff --git a/src/app/georeferencer/qgsimagewarper.cpp b/src/app/georeferencer/qgsimagewarper.cpp index 397305b0a46e..a88c9dc51768 100644 --- a/src/app/georeferencer/qgsimagewarper.cpp +++ b/src/app/georeferencer/qgsimagewarper.cpp @@ -35,9 +35,7 @@ QgsImageWarper::QgsImageWarper() { } -bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, ResamplingMethod resampling, - const GDALTransformerFunc &pfnTransform, - gdal::dataset_unique_ptr &hSrcDS, gdal::warp_options_unique_ptr &psWarpOptions ) const +bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, ResamplingMethod resampling, const GDALTransformerFunc &pfnTransform, gdal::dataset_unique_ptr &hSrcDS, gdal::warp_options_unique_ptr &psWarpOptions ) const { // Open input file GDALAllRegister(); @@ -49,10 +47,8 @@ bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, ResamplingMet psWarpOptions.reset( GDALCreateWarpOptions() ); psWarpOptions->hSrcDS = hSrcDS.get(); psWarpOptions->nBandCount = GDALGetRasterCount( hSrcDS.get() ); - psWarpOptions->panSrcBands = - ( int * ) CPLMalloc( sizeof( int ) * psWarpOptions->nBandCount ); - psWarpOptions->panDstBands = - ( int * ) CPLMalloc( sizeof( int ) * psWarpOptions->nBandCount ); + psWarpOptions->panSrcBands = ( int * ) CPLMalloc( sizeof( int ) * psWarpOptions->nBandCount ); + psWarpOptions->panDstBands = ( int * ) CPLMalloc( sizeof( int ) * psWarpOptions->nBandCount ); for ( int i = 0; i < psWarpOptions->nBandCount; ++i ) { psWarpOptions->panSrcBands[i] = i + 1; @@ -65,9 +61,7 @@ bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, ResamplingMet return true; } -bool QgsImageWarper::createDestinationDataset( const QString &outputName, GDALDatasetH hSrcDS, gdal::dataset_unique_ptr &hDstDS, - uint resX, uint resY, double *adfGeoTransform, bool useZeroAsTrans, - const QString &compression, const QgsCoordinateReferenceSystem &crs ) +bool QgsImageWarper::createDestinationDataset( const QString &outputName, GDALDatasetH hSrcDS, gdal::dataset_unique_ptr &hDstDS, uint resX, uint resY, double *adfGeoTransform, bool useZeroAsTrans, const QString &compression, const QgsCoordinateReferenceSystem &crs ) { // create the output file GDALDriverH driver = GDALGetDriverByName( "GTiff" ); @@ -77,11 +71,7 @@ bool QgsImageWarper::createDestinationDataset( const QString &outputName, GDALDa } char **papszOptions = nullptr; papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", compression.toLatin1() ); - hDstDS.reset( GDALCreate( driver, - outputName.toUtf8().constData(), resX, resY, - GDALGetRasterCount( hSrcDS ), - GDALGetRasterDataType( GDALGetRasterBand( hSrcDS, 1 ) ), - papszOptions ) ); + hDstDS.reset( GDALCreate( driver, outputName.toUtf8().constData(), resX, resY, GDALGetRasterCount( hSrcDS ), GDALGetRasterDataType( GDALGetRasterBand( hSrcDS, 1 ) ), papszOptions ) ); if ( !hDstDS ) { return false; @@ -133,15 +123,7 @@ bool QgsImageWarper::createDestinationDataset( const QString &outputName, GDALDa return true; } -QgsImageWarper::Result QgsImageWarper::warpFile( const QString &input, - const QString &output, - const QgsGeorefTransform &georefTransform, - ResamplingMethod resampling, - bool useZeroAsTrans, - const QString &compression, - const QgsCoordinateReferenceSystem &crs, - QgsFeedback *feedback, - double destResX, double destResY ) +QgsImageWarper::Result QgsImageWarper::warpFile( const QString &input, const QString &output, const QgsGeorefTransform &georefTransform, ResamplingMethod resampling, bool useZeroAsTrans, const QString &compression, const QgsCoordinateReferenceSystem &crs, QgsFeedback *feedback, double destResX, double destResY ) { if ( !georefTransform.parametersInitialized() ) return QgsImageWarper::Result::InvalidParameters; @@ -156,9 +138,7 @@ QgsImageWarper::Result QgsImageWarper::warpFile( const QString &input, double adfGeoTransform[6]; int destPixels, destLines; - CPLErr eErr = GDALSuggestedWarpOutput( hSrcDS.get(), georefTransform.GDALTransformer(), - georefTransform.GDALTransformerArgs(), - adfGeoTransform, &destPixels, &destLines ); + CPLErr eErr = GDALSuggestedWarpOutput( hSrcDS.get(), georefTransform.GDALTransformer(), georefTransform.GDALTransformerArgs(), adfGeoTransform, &destPixels, &destLines ); if ( eErr != CE_None ) { return QgsImageWarper::Result::TransformError; @@ -181,7 +161,7 @@ QgsImageWarper::Result QgsImageWarper::warpFile( const QString &input, // Assert that the north-up convention is fulfilled by GDALSuggestedWarpOutput (should always be the case) // Asserts are bad as they just crash out, changed to just return false. TS - if ( adfGeoTransform[0] <= 0.0 || adfGeoTransform[5] >= 0.0 ) + if ( adfGeoTransform[0] <= 0.0 || adfGeoTransform[5] >= 0.0 ) { QgsDebugError( QStringLiteral( "Image is not north up after GDALSuggestedWarpOutput, bailing out." ) ); return QgsImageWarper::Result::InvalidParameters; @@ -193,33 +173,29 @@ QgsImageWarper::Result QgsImageWarper::warpFile( const QString &input, const double minY = adfGeoTransform[3] + adfGeoTransform[5] * destLines; // Update line and pixel count to match extent at user-specified resolution - destPixels = ( int )( ( ( maxX - minX ) / destResX ) + 0.5 ); - destLines = ( int )( ( ( minY - maxY ) / destResY ) + 0.5 ); + destPixels = ( int ) ( ( ( maxX - minX ) / destResX ) + 0.5 ); + destLines = ( int ) ( ( ( minY - maxY ) / destResY ) + 0.5 ); adfGeoTransform[0] = minX; adfGeoTransform[3] = maxY; adfGeoTransform[1] = destResX; adfGeoTransform[5] = destResY; } - if ( !createDestinationDataset( output, hSrcDS.get(), hDstDS, destPixels, destLines, - adfGeoTransform, useZeroAsTrans, compression, - crs ) ) + if ( !createDestinationDataset( output, hSrcDS.get(), hDstDS, destPixels, destLines, adfGeoTransform, useZeroAsTrans, compression, crs ) ) { return QgsImageWarper::Result::DestinationCreationError; } // Set GDAL callbacks for the progress dialog - psWarpOptions->pProgressArg = reinterpret_cast< void * >( feedback ); + psWarpOptions->pProgressArg = reinterpret_cast( feedback ); psWarpOptions->pfnProgress = updateWarpProgress; psWarpOptions->hSrcDS = hSrcDS.get(); psWarpOptions->hDstDS = hDstDS.get(); // Create a transformer which transforms from source to destination pixels (and vice versa) - psWarpOptions->pfnTransformer = GeoToPixelTransform; - psWarpOptions->pTransformerArg = addGeoToPixelTransform( georefTransform.GDALTransformer(), - georefTransform.GDALTransformerArgs(), - adfGeoTransform ); + psWarpOptions->pfnTransformer = GeoToPixelTransform; + psWarpOptions->pTransformerArg = addGeoToPixelTransform( georefTransform.GDALTransformer(), georefTransform.GDALTransformerArgs(), adfGeoTransform ); // Initialize and execute the warp operation. GDALWarpOperation oOperation; @@ -228,7 +204,8 @@ QgsImageWarper::Result QgsImageWarper::warpFile( const QString &input, eErr = oOperation.ChunkAndWarpImage( 0, 0, destPixels, destLines ); destroyGeoToPixelTransform( psWarpOptions->pTransformerArg ); - return feedback->isCanceled() ? QgsImageWarper::Result::Canceled : eErr == CE_None ? QgsImageWarper::Result::Success : QgsImageWarper::Result::WarpFailure; + return feedback->isCanceled() ? QgsImageWarper::Result::Canceled : eErr == CE_None ? QgsImageWarper::Result::Success + : QgsImageWarper::Result::WarpFailure; } void *QgsImageWarper::addGeoToPixelTransform( GDALTransformerFunc GDALTransformer, void *GDALTransformerArg, double *padfGeotransform ) const @@ -245,7 +222,7 @@ void *QgsImageWarper::addGeoToPixelTransform( GDALTransformerFunc GDALTransforme delete chain; return nullptr; } - return ( void * )chain; + return ( void * ) chain; } void QgsImageWarper::destroyGeoToPixelTransform( void *GeoToPixelTransformArg ) const @@ -253,8 +230,7 @@ void QgsImageWarper::destroyGeoToPixelTransform( void *GeoToPixelTransformArg ) delete static_cast( GeoToPixelTransformArg ); } -int QgsImageWarper::GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, int nPointCount, - double *x, double *y, double *z, int *panSuccess ) +int QgsImageWarper::GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess ) { TransformChain *chain = static_cast( pTransformerArg ); if ( !chain ) @@ -319,7 +295,7 @@ GDALResampleAlg QgsImageWarper::toGDALResampleAlg( const QgsImageWarper::Resampl case ResamplingMethod::NearestNeighbour: return GRA_NearestNeighbour; case ResamplingMethod::Bilinear: - return GRA_Bilinear; + return GRA_Bilinear; case ResamplingMethod::Cubic: return GRA_Cubic; case ResamplingMethod::CubicSpline: @@ -335,16 +311,11 @@ GDALResampleAlg QgsImageWarper::toGDALResampleAlg( const QgsImageWarper::Resampl // QgsImageWarperTask // -QgsImageWarperTask::QgsImageWarperTask( const QString &input, const QString &output, - const QgsGeorefTransform &georefTransform, - QgsImageWarper::ResamplingMethod resampling, - bool useZeroAsTrans, const QString &compression, - const QgsCoordinateReferenceSystem &crs, - double destResX, double destResY ) +QgsImageWarperTask::QgsImageWarperTask( const QString &input, const QString &output, const QgsGeorefTransform &georefTransform, QgsImageWarper::ResamplingMethod resampling, bool useZeroAsTrans, const QString &compression, const QgsCoordinateReferenceSystem &crs, double destResX, double destResY ) : QgsTask( tr( "Warping %1" ).arg( input ), QgsTask::CanCancel ) , mInput( input ) , mOutput( output ) - , mTransform( qgis::down_cast< QgsGeorefTransform * >( georefTransform.clone() ) ) + , mTransform( qgis::down_cast( georefTransform.clone() ) ) , mResamplingMethod( resampling ) , mUseZeroAsTrans( useZeroAsTrans ) , mCompression( compression ) @@ -364,21 +335,22 @@ void QgsImageWarperTask::cancel() bool QgsImageWarperTask::run() { - mFeedback = std::make_unique< QgsFeedback >(); + mFeedback = std::make_unique(); connect( mFeedback.get(), &QgsFeedback::progressChanged, this, &QgsTask::progressChanged ); QgsImageWarper warper; mResult = warper.warpFile( - mInput, - mOutput, - *mTransform.get(), - mResamplingMethod, - mUseZeroAsTrans, - mCompression, - mDestinationCrs, - mFeedback.get(), - mDestinationResX, - mDestinationResY ); + mInput, + mOutput, + *mTransform.get(), + mResamplingMethod, + mUseZeroAsTrans, + mCompression, + mDestinationCrs, + mFeedback.get(), + mDestinationResX, + mDestinationResY + ); mFeedback.reset(); return mResult == QgsImageWarper::Result::Success; diff --git a/src/app/georeferencer/qgsimagewarper.h b/src/app/georeferencer/qgsimagewarper.h index 1dda49856081..398a7cbbd520 100644 --- a/src/app/georeferencer/qgsimagewarper.h +++ b/src/app/georeferencer/qgsimagewarper.h @@ -21,7 +21,7 @@ #include #include -#include"qgis_app.h" +#include "qgis_app.h" #include "qgscoordinatereferencesystem.h" #include "qgsogrutils.h" #include "qgstaskmanager.h" @@ -36,7 +36,6 @@ class APP_EXPORT QgsImageWarper Q_GADGET public: - QgsImageWarper(); enum class ResamplingMethod : int @@ -52,13 +51,13 @@ class APP_EXPORT QgsImageWarper //! Task results enum class Result { - Success, //!< Warping completed successfully - Canceled, //!< Task was canceled before completion - InvalidParameters, //!< Invalid transform parameters - SourceError, //!< Error reading source - TransformError, //!< Error creating GDAL transformer + Success, //!< Warping completed successfully + Canceled, //!< Task was canceled before completion + InvalidParameters, //!< Invalid transform parameters + SourceError, //!< Error reading source + TransformError, //!< Error creating GDAL transformer DestinationCreationError, //!< Error creating destination file - WarpFailure, //!< Failed warping source + WarpFailure, //!< Failed warping source }; Q_ENUM( Result ) @@ -75,28 +74,19 @@ class APP_EXPORT QgsImageWarper * \param destResX The desired horizontal resolution of the output file, in target georeferenced units. A value of zero means automatic selection. * \param destResY The desired vertical resolution of the output file, in target georeferenced units. A value of zero means automatic selection. */ - Result warpFile( const QString &input, - const QString &output, - const QgsGeorefTransform &georefTransform, - ResamplingMethod resampling, - bool useZeroAsTrans, - const QString &compression, - const QgsCoordinateReferenceSystem &crs, - QgsFeedback *feedback, - double destResX = 0.0, double destResY = 0.0 ); + Result warpFile( const QString &input, const QString &output, const QgsGeorefTransform &georefTransform, ResamplingMethod resampling, bool useZeroAsTrans, const QString &compression, const QgsCoordinateReferenceSystem &crs, QgsFeedback *feedback, double destResX = 0.0, double destResY = 0.0 ); private: struct TransformChain { - GDALTransformerFunc GDALTransformer; - void *GDALTransformerArg = nullptr; - double adfGeotransform[6]; - double adfInvGeotransform[6]; + GDALTransformerFunc GDALTransformer; + void *GDALTransformerArg = nullptr; + double adfGeotransform[6]; + double adfInvGeotransform[6]; }; //! \sa addGeoToPixelTransform - static int GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, int nPointCount, - double *x, double *y, double *z, int *panSuccess ); + static int GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess ); /** * \brief Appends a transform from geocoordinates to pixel/line coordinates to the given GDAL transformer. @@ -109,12 +99,9 @@ class APP_EXPORT QgsImageWarper void *addGeoToPixelTransform( GDALTransformerFunc GDALTransformer, void *GDALTransformerArg, double *padfGeotransform ) const; void destroyGeoToPixelTransform( void *GeoToPixelTransformArg ) const; - bool openSrcDSAndGetWarpOpt( const QString &input, ResamplingMethod resampling, - const GDALTransformerFunc &pfnTransform, gdal::dataset_unique_ptr &hSrcDS, - gdal::warp_options_unique_ptr &psWarpOptions ) const; + bool openSrcDSAndGetWarpOpt( const QString &input, ResamplingMethod resampling, const GDALTransformerFunc &pfnTransform, gdal::dataset_unique_ptr &hSrcDS, gdal::warp_options_unique_ptr &psWarpOptions ) const; - bool createDestinationDataset( const QString &outputName, GDALDatasetH hSrcDS, gdal::dataset_unique_ptr &hDstDS, uint resX, uint resY, - double *adfGeoTransform, bool useZeroAsTrans, const QString &compression, const QgsCoordinateReferenceSystem &crs ); + bool createDestinationDataset( const QString &outputName, GDALDatasetH hSrcDS, gdal::dataset_unique_ptr &hDstDS, uint resX, uint resY, double *adfGeoTransform, bool useZeroAsTrans, const QString &compression, const QgsCoordinateReferenceSystem &crs ); //! \brief GDAL progress callback, used to display warping progress via a QProgressDialog static int CPL_STDCALL updateWarpProgress( double dfComplete, const char *pszMessage, void *pProgressArg ); @@ -128,7 +115,6 @@ class QgsImageWarperTask : public QgsTask Q_OBJECT public: - /** * Constructor for QgsImageWarperTask. * @@ -142,14 +128,7 @@ class QgsImageWarperTask : public QgsTask * \param destResX The desired horizontal resolution of the output file, in target georeferenced units. A value of zero means automatic selection. * \param destResY The desired vertical resolution of the output file, in target georeferenced units. A value of zero means automatic selection. */ - QgsImageWarperTask( const QString &input, - const QString &output, - const QgsGeorefTransform &georefTransform, - QgsImageWarper::ResamplingMethod resampling, - bool useZeroAsTrans, - const QString &compression, - const QgsCoordinateReferenceSystem &crs, - double destResX = 0.0, double destResY = 0.0 ); + QgsImageWarperTask( const QString &input, const QString &output, const QgsGeorefTransform &georefTransform, QgsImageWarper::ResamplingMethod resampling, bool useZeroAsTrans, const QString &compression, const QgsCoordinateReferenceSystem &crs, double destResX = 0.0, double destResY = 0.0 ); void cancel() override; @@ -159,14 +138,12 @@ class QgsImageWarperTask : public QgsTask QgsImageWarper::Result result() const { return mResult; } protected: - bool run() override; private: - QString mInput; QString mOutput; - std::unique_ptr< QgsGeorefTransform > mTransform; + std::unique_ptr mTransform; QgsImageWarper::ResamplingMethod mResamplingMethod = QgsImageWarper::ResamplingMethod::Bilinear; bool mUseZeroAsTrans = false; QString mCompression; @@ -174,7 +151,7 @@ class QgsImageWarperTask : public QgsTask double mDestinationResX = 0; double mDestinationResY = 0; - std::unique_ptr< QgsFeedback > mFeedback; + std::unique_ptr mFeedback; QgsImageWarper::Result mResult = QgsImageWarper::Result::Success; }; diff --git a/src/app/georeferencer/qgsmapcoordsdialog.cpp b/src/app/georeferencer/qgsmapcoordsdialog.cpp index 1cac1cb063d2..2fecb44222c8 100644 --- a/src/app/georeferencer/qgsmapcoordsdialog.cpp +++ b/src/app/georeferencer/qgsmapcoordsdialog.cpp @@ -57,8 +57,7 @@ QgsMapCoordsDialog::QgsMapCoordsDialog( QgsMapCanvas *qgisCanvas, QgsGeorefDataP connect( mPointFromCanvasPushButton, &QAbstractButton::clicked, this, &QgsMapCoordsDialog::setToolEmitPoint ); - connect( mToolEmitPoint, &QgsGeorefMapToolEmitPoint::canvasClicked, - this, &QgsMapCoordsDialog::maybeSetXY ); + connect( mToolEmitPoint, &QgsGeorefMapToolEmitPoint::canvasClicked, this, &QgsMapCoordsDialog::maybeSetXY ); connect( mToolEmitPoint, &QgsGeorefMapToolEmitPoint::mouseReleased, this, &QgsMapCoordsDialog::setPrevTool ); connect( leXCoord, &QLineEdit::textChanged, this, &QgsMapCoordsDialog::updateOK ); diff --git a/src/app/georeferencer/qgsmapcoordsdialog.h b/src/app/georeferencer/qgsmapcoordsdialog.h index dd9ff0c47e87..8c47e8cea1a1 100644 --- a/src/app/georeferencer/qgsmapcoordsdialog.h +++ b/src/app/georeferencer/qgsmapcoordsdialog.h @@ -49,7 +49,6 @@ class QgsGeorefMapToolEmitPoint : public QgsMapTool void mouseReleased(); private: - QgsPointLocator::Match mapPointMatch( QMouseEvent *e ); std::unique_ptr mSnapIndicator; @@ -60,7 +59,6 @@ class QgsMapCoordsDialog : public QDialog, private Ui::QgsMapCoordsDialogBase Q_OBJECT public: - /** * Constructor for QgsMapCoordsDialog. * \param qgisCanvas diff --git a/src/app/georeferencer/qgsrasterchangecoords.cpp b/src/app/georeferencer/qgsrasterchangecoords.cpp index 8b2fe2d229c2..2086387068a1 100644 --- a/src/app/georeferencer/qgsrasterchangecoords.cpp +++ b/src/app/georeferencer/qgsrasterchangecoords.cpp @@ -54,7 +54,7 @@ QVector QgsRasterChangeCoords::getPixelCoords( const QVector( std::log10( scaleBarWidthUnits ) ); scaleBarWidthUnits /= std::pow( 10.0, nDecPlaces ); - scaleBarWidthUnits = ( int )( scaleBarWidthUnits + 0.5 ); + scaleBarWidthUnits = ( int ) ( scaleBarWidthUnits + 0.5 ); scaleBarWidthUnits *= std::pow( 10.0, nDecPlaces ); initialScaleBarWidth = scaleBarWidthUnits * minMMPixelRatio; } @@ -177,7 +177,6 @@ void QgsResidualPlotItem::setGCPList( const QgsGCPList &list ) void QgsResidualPlotItem::draw( QgsLayoutItemRenderContext & ) { - } double QgsResidualPlotItem::maxMMToPixelRatioForGCP( const QgsGeorefDataPoint *p, double pixelXMM, double pixelYMM ) @@ -188,7 +187,7 @@ double QgsResidualPlotItem::maxMMToPixelRatioForGCP( const QgsGeorefDataPoint *p } //calculate intersections with upper / lower frame edge depending on the residual y sign - double upDownDist = std::numeric_limits::max(); //distance to frame intersection with lower or upper frame + double upDownDist = std::numeric_limits::max(); //distance to frame intersection with lower or upper frame double leftRightDist = std::numeric_limits::max(); //distance to frame intersection with left or right frame const QPointF residual = p->residual(); diff --git a/src/app/georeferencer/qgsresidualplotitem.h b/src/app/georeferencer/qgsresidualplotitem.h index 793dfc96fd06..4965c6c0502d 100644 --- a/src/app/georeferencer/qgsresidualplotitem.h +++ b/src/app/georeferencer/qgsresidualplotitem.h @@ -24,7 +24,7 @@ * A composer item to visualise the distribution of georeference residuals. For the visualisation, * the length of the residual arrows are scaled. */ -class QgsResidualPlotItem: public QgsLayoutItem +class QgsResidualPlotItem : public QgsLayoutItem { Q_OBJECT @@ -40,13 +40,14 @@ class QgsResidualPlotItem: public QgsLayoutItem void setGCPList( const QgsGCPList &list ); const QgsGCPList &GCPList() const { return mGCPList; } - void setExtent( const QgsRectangle &rect ) { mExtent = rect;} + void setExtent( const QgsRectangle &rect ) { mExtent = rect; } QgsRectangle extent() const { return mExtent; } void setConvertScaleToMapUnits( bool convert ) { mConvertScaleToMapUnits = convert; } bool convertScaleToMapUnits() const { return mConvertScaleToMapUnits; } void draw( QgsLayoutItemRenderContext &context ) override; + private: //gcp list QgsGCPList mGCPList; diff --git a/src/app/georeferencer/qgstransformsettingsdialog.cpp b/src/app/georeferencer/qgstransformsettingsdialog.cpp index 7eaef1c8d89f..56fad3d9f114 100644 --- a/src/app/georeferencer/qgstransformsettingsdialog.cpp +++ b/src/app/georeferencer/qgstransformsettingsdialog.cpp @@ -76,8 +76,7 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( Qgis::LayerType type, co outputFile->setDialogTitle( tr( "Destination File" ) ); const QString lastDestinationFolder = settingLastDestinationFolder->value(); outputFile->setDefaultRoot( lastDestinationFolder.isEmpty() ? QDir::homePath() : lastDestinationFolder ); - connect( outputFile, &QgsFileWidget::fileChanged, this, [ = ] - { + connect( outputFile, &QgsFileWidget::fileChanged, this, [=] { settingLastDestinationFolder->setValue( QFileInfo( outputFile->filePath() ).absolutePath() ); } ); @@ -86,8 +85,7 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( Qgis::LayerType type, co mPdfMap->setDialogTitle( tr( "Save Map File As" ) ); const QString lastPdfFolder = settingLastPdfFolder->value(); mPdfMap->setDefaultRoot( lastPdfFolder.isEmpty() ? QDir::homePath() : lastPdfFolder ); - connect( mPdfMap, &QgsFileWidget::fileChanged, this, [ = ] - { + connect( mPdfMap, &QgsFileWidget::fileChanged, this, [=] { settingLastPdfFolder->setValue( QFileInfo( mPdfMap->filePath() ).absolutePath() ); } ); @@ -95,8 +93,7 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( Qgis::LayerType type, co mPdfReport->setFilter( tr( "PDF files" ) + " (*.pdf *.PDF)" ); mPdfReport->setDialogTitle( tr( "Save Report File As" ) ); mPdfReport->setDefaultRoot( lastPdfFolder.isEmpty() ? QDir::homePath() : lastPdfFolder ); - connect( mPdfReport, &QgsFileWidget::fileChanged, this, [ = ] - { + connect( mPdfReport, &QgsFileWidget::fileChanged, this, [=] { settingLastPdfFolder->setValue( QFileInfo( mPdfMap->filePath() ).absolutePath() ); } ); @@ -117,11 +114,11 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( Qgis::LayerType type, co cmbCompressionComboBox->addItem( tr( "PACKBITS" ), QStringLiteral( "PACKBITS" ) ); cmbCompressionComboBox->addItem( tr( "DEFLATE" ), QStringLiteral( "DEFLATE" ) ); - cmbResampling->addItem( tr( "Nearest Neighbour" ), static_cast< int >( QgsImageWarper::ResamplingMethod::NearestNeighbour ) ); - cmbResampling->addItem( tr( "Bilinear (2x2 Kernel)" ), static_cast< int >( QgsImageWarper::ResamplingMethod::Bilinear ) ); - cmbResampling->addItem( tr( "Cubic (4x4 Kernel)" ), static_cast< int >( QgsImageWarper::ResamplingMethod::Cubic ) ); - cmbResampling->addItem( tr( "Cubic B-Spline (4x4 Kernel)" ), static_cast< int >( QgsImageWarper::ResamplingMethod::CubicSpline ) ); - cmbResampling->addItem( tr( "Lanczos (6x6 Kernel)" ), static_cast< int >( QgsImageWarper::ResamplingMethod::Lanczos ) ); + cmbResampling->addItem( tr( "Nearest Neighbour" ), static_cast( QgsImageWarper::ResamplingMethod::NearestNeighbour ) ); + cmbResampling->addItem( tr( "Bilinear (2x2 Kernel)" ), static_cast( QgsImageWarper::ResamplingMethod::Bilinear ) ); + cmbResampling->addItem( tr( "Cubic (4x4 Kernel)" ), static_cast( QgsImageWarper::ResamplingMethod::Cubic ) ); + cmbResampling->addItem( tr( "Cubic B-Spline (4x4 Kernel)" ), static_cast( QgsImageWarper::ResamplingMethod::CubicSpline ) ); + cmbResampling->addItem( tr( "Lanczos (6x6 Kernel)" ), static_cast( QgsImageWarper::ResamplingMethod::Lanczos ) ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsTransformSettingsDialog::showHelp ); } @@ -152,7 +149,7 @@ QgsGcpTransformerInterface::TransformMethod QgsTransformSettingsDialog::transfor if ( cmbTransformType->currentIndex() == -1 ) return QgsGcpTransformerInterface::TransformMethod::InvalidTransform; else - return static_cast< QgsGcpTransformerInterface::TransformMethod >( cmbTransformType->currentData().toInt() ); + return static_cast( cmbTransformType->currentData().toInt() ); } void QgsTransformSettingsDialog::setTransformMethod( QgsGcpTransformerInterface::TransformMethod method ) @@ -160,17 +157,17 @@ void QgsTransformSettingsDialog::setTransformMethod( QgsGcpTransformerInterface: if ( method == QgsGcpTransformerInterface::TransformMethod::InvalidTransform ) cmbTransformType->setCurrentIndex( 0 ); else - cmbTransformType->setCurrentIndex( cmbTransformType->findData( static_cast< int >( method ) ) ); + cmbTransformType->setCurrentIndex( cmbTransformType->findData( static_cast( method ) ) ); } QgsImageWarper::ResamplingMethod QgsTransformSettingsDialog::resamplingMethod() const { - return static_cast< QgsImageWarper::ResamplingMethod >( cmbResampling->currentData().toInt() ); + return static_cast( cmbResampling->currentData().toInt() ); } void QgsTransformSettingsDialog::setResamplingMethod( QgsImageWarper::ResamplingMethod method ) { - cmbResampling->setCurrentIndex( cmbResampling->findData( static_cast< int >( method ) ) ); + cmbResampling->setCurrentIndex( cmbResampling->findData( static_cast( method ) ) ); } QString QgsTransformSettingsDialog::compressionMethod() const @@ -240,7 +237,8 @@ void QgsTransformSettingsDialog::setLoadInProject( bool enabled ) } void QgsTransformSettingsDialog::outputResolution( - double &resX, double &resY ) + double &resX, double &resY +) { resX = 0.0; resY = 0.0; @@ -288,8 +286,7 @@ void QgsTransformSettingsDialog::accept() void QgsTransformSettingsDialog::cmbTransformType_currentIndexChanged( const QString & ) { if ( cmbTransformType->currentIndex() != -1 - && ( static_cast< QgsGcpTransformerInterface::TransformMethod >( cmbTransformType->currentData().toInt() ) == QgsGcpTransformerInterface::TransformMethod::Linear - || static_cast< QgsGcpTransformerInterface::TransformMethod >( cmbTransformType->currentData().toInt() ) == QgsGcpTransformerInterface::TransformMethod::Helmert ) ) + && ( static_cast( cmbTransformType->currentData().toInt() ) == QgsGcpTransformerInterface::TransformMethod::Linear || static_cast( cmbTransformType->currentData().toInt() ) == QgsGcpTransformerInterface::TransformMethod::Helmert ) ) { mWorldFileCheckBox->setEnabled( true ); } diff --git a/src/app/georeferencer/qgstransformsettingsdialog.h b/src/app/georeferencer/qgstransformsettingsdialog.h index 2a6f50e9346c..bfa183e5c924 100644 --- a/src/app/georeferencer/qgstransformsettingsdialog.h +++ b/src/app/georeferencer/qgstransformsettingsdialog.h @@ -27,7 +27,6 @@ class QgsTransformSettingsDialog : public QDialog, private Ui::QgsTransformSetti Q_OBJECT public: - static const QgsSettingsEntryString *settingLastDestinationFolder; static const QgsSettingsEntryString *settingLastPdfFolder; diff --git a/src/app/georeferencer/qgsvalidateddoublespinbox.cpp b/src/app/georeferencer/qgsvalidateddoublespinbox.cpp index f7097eb2caeb..3600edbe9e09 100644 --- a/src/app/georeferencer/qgsvalidateddoublespinbox.cpp +++ b/src/app/georeferencer/qgsvalidateddoublespinbox.cpp @@ -18,7 +18,7 @@ QgsValidatedDoubleSpinBox::QgsValidatedDoubleSpinBox( QWidget *widget ) : QDoubleSpinBox( widget ) -{ } +{} QValidator::State QgsValidatedDoubleSpinBox::validate( QString &input, int &pos ) const { diff --git a/src/app/gps/qgsappgpsconnection.cpp b/src/app/gps/qgsappgpsconnection.cpp index fea63598b260..0822f1ec47bc 100644 --- a/src/app/gps/qgsappgpsconnection.cpp +++ b/src/app/gps/qgsappgpsconnection.cpp @@ -29,7 +29,6 @@ QgsAppGpsConnection::QgsAppGpsConnection( QObject *parent ) : QObject( parent ) { - } QgsAppGpsConnection::~QgsAppGpsConnection() @@ -47,7 +46,7 @@ QgsGpsConnection *QgsAppGpsConnection::connection() bool QgsAppGpsConnection::isConnected() const { - return static_cast< bool >( mConnection ); + return static_cast( mConnection ); } void QgsAppGpsConnection::setConnection( QgsGpsConnection *connection ) @@ -89,7 +88,7 @@ void QgsAppGpsConnection::connectGps() { connectionType = QgsGpsConnection::settingsGpsConnectionType->value(); gpsdHost = QgsGpsConnection::settingsGpsdHostName->value(); - gpsdPort = static_cast< int >( QgsGpsConnection::settingsGpsdPortNumber->value() ); + gpsdPort = static_cast( QgsGpsConnection::settingsGpsdPortNumber->value() ); gpsdDevice = QgsGpsConnection::settingsGpsdDeviceName->value(); serialDevice = QgsGpsConnection::settingsGpsSerialDevice->value(); } @@ -160,13 +159,13 @@ void QgsAppGpsConnection::connectGps() mDetector = new QgsGpsDetector( port, false ); connect( mDetector, &QgsGpsDetector::connectionDetected, this, &QgsAppGpsConnection::onConnectionDetected ); connect( mDetector, &QgsGpsDetector::detectionFailed, this, &QgsAppGpsConnection::onTimeOut ); - mDetector->advance(); // start the detection process + mDetector->advance(); // start the detection process } void QgsAppGpsConnection::disconnectGps() { // we don't actually delete the connection until everything has had time to respond to the cleanup signals - std::unique_ptr< QgsGpsConnection > oldConnection( mConnection ); + std::unique_ptr oldConnection( mConnection ); mConnection = nullptr; emit disconnected(); @@ -242,8 +241,7 @@ void QgsAppGpsConnection::showGpsConnectFailureWarning( const QString &message ) QgisApp::instance()->statusBarIface()->clearMessage(); mConnectionMessageItem = QgisApp::instance()->messageBar()->createMessage( QString(), message ); QPushButton *configureButton = new QPushButton( tr( "Configure Device…" ) ); - connect( configureButton, &QPushButton::clicked, configureButton, [ = ] - { + connect( configureButton, &QPushButton::clicked, configureButton, [=] { QgisApp::instance()->showOptionsDialog( QgisApp::instance(), QStringLiteral( "mGpsOptions" ) ); } ); mConnectionMessageItem->layout()->addWidget( configureButton ); @@ -265,4 +263,3 @@ void QgsAppGpsConnection::showMessage( Qgis::MessageLevel level, const QString & mConnectionMessageItem = QgisApp::instance()->messageBar()->createMessage( QString(), message ); QgisApp::instance()->messageBar()->pushWidget( mConnectionMessageItem, level, QgsMessageBar::defaultMessageTimeout( level ) ); } - diff --git a/src/app/gps/qgsappgpsconnection.h b/src/app/gps/qgsappgpsconnection.h index 7b992c8cfeb2..d0e55a81f25d 100644 --- a/src/app/gps/qgsappgpsconnection.h +++ b/src/app/gps/qgsappgpsconnection.h @@ -41,7 +41,6 @@ class APP_EXPORT QgsAppGpsConnection : public QObject Q_OBJECT public: - QgsAppGpsConnection( QObject *parent ); ~QgsAppGpsConnection() override; @@ -146,15 +145,14 @@ class APP_EXPORT QgsAppGpsConnection : public QObject void setConnectionPrivate( QgsGpsConnection *connection ); private: - void showStatusBarMessage( const QString &msg ); void showGpsConnectFailureWarning( const QString &message ); void showMessage( Qgis::MessageLevel level, const QString &message ); - QPointer< QgsGpsDetector > mDetector; + QPointer mDetector; QgsGpsConnection *mConnection = nullptr; - QPointer< QgsMessageBarItem > mConnectionMessageItem; + QPointer mConnectionMessageItem; }; diff --git a/src/app/gps/qgsappgpsdigitizing.cpp b/src/app/gps/qgsappgpsdigitizing.cpp index 51ae6f7cca40..9319b7df7237 100644 --- a/src/app/gps/qgsappgpsdigitizing.cpp +++ b/src/app/gps/qgsappgpsdigitizing.cpp @@ -42,7 +42,6 @@ QgsUpdateGpsDetailsAction::QgsUpdateGpsDetailsAction( QgsAppGpsConnection *conne , mConnection( connection ) , mDigitizing( digitizing ) { - } bool QgsUpdateGpsDetailsAction::canRunUsingLayer( QgsMapLayer * ) const @@ -59,7 +58,7 @@ bool QgsUpdateGpsDetailsAction::canRunUsingLayer( QgsMapLayer *layer, const QgsM void QgsUpdateGpsDetailsAction::triggerForFeature( QgsMapLayer *layer, const QgsFeature &, const QgsMapLayerActionContext &context ) { QgsVectorLayer *vlayer = QgsProject::instance()->gpsSettings()->destinationLayer(); - if ( !vlayer || ! mConnection || !mConnection->isConnected() + if ( !vlayer || !mConnection || !mConnection->isConnected() || layer != vlayer ) return; @@ -90,8 +89,7 @@ void QgsUpdateGpsDetailsAction::triggerForFeature( QgsMapLayer *layer, const Qgs catch ( QgsCsException & ) { if ( QgsMessageBar *messageBar = context.messageBar() ) - messageBar->pushCritical( QString(), - tr( "Error reprojecting GPS location to layer CRS." ) ); + messageBar->pushCritical( QString(), tr( "Error reprojecting GPS location to layer CRS." ) ); return; } @@ -127,12 +125,10 @@ QgsAppGpsDigitizing::QgsAppGpsDigitizing( QgsAppGpsConnection *connection, QgsMa QgsGui::mapLayerActionRegistry()->addMapLayerAction( mUpdateGpsDetailsAction ); mCanvasToWgs84Transform = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), mWgs84CRS, QgsProject::instance() ); - connect( mCanvas, &QgsMapCanvas::destinationCrsChanged, this, [ = ] - { + connect( mCanvas, &QgsMapCanvas::destinationCrsChanged, this, [=] { mCanvasToWgs84Transform = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), mWgs84CRS, QgsProject::instance() ); } ); - connect( QgsProject::instance(), &QgsProject::transformContextChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::transformContextChanged, this, [=] { setTransformContext( QgsProject::instance()->transformContext() ); mCanvasToWgs84Transform = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), mWgs84CRS, transformContext() ); } ); @@ -140,8 +136,7 @@ QgsAppGpsDigitizing::QgsAppGpsDigitizing( QgsAppGpsConnection *connection, QgsMa setEllipsoid( QgsProject::instance()->ellipsoid() ); - connect( QgsProject::instance(), &QgsProject::ellipsoidChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::ellipsoidChanged, this, [=] { setEllipsoid( QgsProject::instance()->ellipsoid() ); } ); @@ -151,28 +146,25 @@ QgsAppGpsDigitizing::QgsAppGpsDigitizing( QgsAppGpsConnection *connection, QgsMa connect( QgsGui::instance(), &QgsGui::optionsChanged, this, &QgsAppGpsDigitizing::gpsSettingsChanged ); gpsSettingsChanged(); - connect( QgisApp::instance(), &QgisApp::activeLayerChanged, this, [ = ]( QgsMapLayer * layer ) - { + connect( QgisApp::instance(), &QgisApp::activeLayerChanged, this, [=]( QgsMapLayer *layer ) { if ( QgsProject::instance()->gpsSettings()->destinationFollowsActiveLayer() ) { - QgsProject::instance()->gpsSettings()->setDestinationLayer( qobject_cast< QgsVectorLayer *> ( layer ) ); + QgsProject::instance()->gpsSettings()->setDestinationLayer( qobject_cast( layer ) ); } } ); - connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::destinationFollowsActiveLayerChanged, this, [ = ]( bool enabled ) - { + connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::destinationFollowsActiveLayerChanged, this, [=]( bool enabled ) { if ( enabled ) { - QgsProject::instance()->gpsSettings()->setDestinationLayer( qobject_cast< QgsVectorLayer *> ( QgisApp::instance()->activeLayer() ) ); + QgsProject::instance()->gpsSettings()->setDestinationLayer( qobject_cast( QgisApp::instance()->activeLayer() ) ); } } ); if ( QgsProject::instance()->gpsSettings()->destinationFollowsActiveLayer() ) { - QgsProject::instance()->gpsSettings()->setDestinationLayer( qobject_cast< QgsVectorLayer *> ( QgisApp::instance()->activeLayer() ) ); + QgsProject::instance()->gpsSettings()->setDestinationLayer( qobject_cast( QgisApp::instance()->activeLayer() ) ); } setAutomaticallyAddTrackVertices( QgsProject::instance()->gpsSettings()->automaticallyAddTrackVertices() ); - connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::automaticallyAddTrackVerticesChanged, this, [ = ]( bool enabled ) - { + connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::automaticallyAddTrackVerticesChanged, this, [=]( bool enabled ) { setAutomaticallyAddTrackVertices( enabled ); } ); @@ -206,7 +198,7 @@ QgsAttributeMap QgsAppGpsDigitizing::derivedAttributes() const const QVariant ts = timestamp( vlayer, idx ); if ( ts.isValid() ) { - attrMap[ idx ] = ts; + attrMap[idx] = ts; } } return attrMap; @@ -271,8 +263,7 @@ void QgsAppGpsDigitizing::createFeature() } catch ( QgsCsException & ) { - QgisApp::instance()->messageBar()->pushCritical( tr( "Add Feature" ), - tr( "Error reprojecting feature to layer CRS." ) ); + QgisApp::instance()->messageBar()->pushCritical( tr( "Add Feature" ), tr( "Error reprojecting feature to layer CRS." ) ); return; } @@ -339,8 +330,8 @@ void QgsAppGpsDigitizing::createFeature() QgisApp::instance()->messageBar()->pushCritical( tr( "Save Layer Edits" ), tr( "Could not commit changes to layer %1\n\nErrors: %2\n" ) - .arg( vlayer->name(), - vlayer->commitErrors().join( QLatin1String( "\n " ) ) ) ); + .arg( vlayer->name(), vlayer->commitErrors().join( QLatin1String( "\n " ) ) ) + ); } vlayer->startEditing(); @@ -376,10 +367,7 @@ void QgsAppGpsDigitizing::createFeature() { if ( !vlayer->commitChanges() ) { - QgisApp::instance()->messageBar()->pushCritical( tr( "Save Layer Edits" ), - tr( "Could not commit changes to layer %1\n\nErrors: %2\n" ) - .arg( vlayer->name(), - vlayer->commitErrors().join( QLatin1String( "\n " ) ) ) ); + QgisApp::instance()->messageBar()->pushCritical( tr( "Save Layer Edits" ), tr( "Could not commit changes to layer %1\n\nErrors: %2\n" ).arg( vlayer->name(), vlayer->commitErrors().join( QLatin1String( "\n " ) ) ) ); } vlayer->startEditing(); @@ -400,7 +388,6 @@ void QgsAppGpsDigitizing::createFeature() case QgsFeatureAction::AddFeatureResult::FeatureError: QgisApp::instance()->messageBar()->pushCritical( QString(), tr( "Could not create new feature in layer %1" ).arg( vlayer->name() ) ); break; - } mBlockGpsStateChanged--; @@ -440,7 +427,7 @@ void QgsAppGpsDigitizing::updateTrackAppearance() { doc.setContent( trackLineSymbolXml ); elem = doc.documentElement(); - std::unique_ptr< QgsLineSymbol > trackLineSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); + std::unique_ptr trackLineSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); if ( trackLineSymbol ) { mRubberBand->setSymbol( trackLineSymbol.release() ); diff --git a/src/app/gps/qgsappgpsdigitizing.h b/src/app/gps/qgsappgpsdigitizing.h index 9d64d0672bb4..7265413a9c7e 100644 --- a/src/app/gps/qgsappgpsdigitizing.h +++ b/src/app/gps/qgsappgpsdigitizing.h @@ -39,23 +39,21 @@ class QgsUpdateGpsDetailsAction : public QgsMapLayerAction Q_OBJECT public: - QgsUpdateGpsDetailsAction( QgsAppGpsConnection *connection, QgsAppGpsDigitizing *digitizing, QObject *parent ); bool canRunUsingLayer( QgsMapLayer *layer ) const override; bool canRunUsingLayer( QgsMapLayer *layer, const QgsMapLayerActionContext &context ) const override; void triggerForFeature( QgsMapLayer *layer, const QgsFeature &feature, const QgsMapLayerActionContext &context ) override; + private: QgsAppGpsConnection *mConnection = nullptr; QgsAppGpsDigitizing *mDigitizing = nullptr; - }; -class APP_EXPORT QgsAppGpsDigitizing: public QgsGpsLogger +class APP_EXPORT QgsAppGpsDigitizing : public QgsGpsLogger { Q_OBJECT public: - static const QgsSettingsEntryString *settingTrackLineSymbol; QgsAppGpsDigitizing( QgsAppGpsConnection *connection, QgsMapCanvas *canvas, QObject *parent = nullptr ); diff --git a/src/app/gps/qgsappgpslogging.cpp b/src/app/gps/qgsappgpslogging.cpp index 0d8f16d11295..e969a3f31f09 100644 --- a/src/app/gps/qgsappgpslogging.cpp +++ b/src/app/gps/qgsappgpslogging.cpp @@ -31,30 +31,28 @@ const QgsSettingsEntryString *QgsAppGpsLogging::settingLastLogFolder = new QgsSe const QgsSettingsEntryString *QgsAppGpsLogging::settingLastGpkgLog = new QgsSettingsEntryString( QStringLiteral( "last-gpkg-log" ), QgsSettingsTree::sTreeGps, QString(), QStringLiteral( "Last used Geopackage/Spatialite file for logging GPS locations" ) ); -const std::vector< std::tuple< Qgis::GpsInformationComponent, std::tuple< QMetaType::Type, QString >>> QgsAppGpsLogging::sPointFields -{ - { Qgis::GpsInformationComponent::Timestamp, { QMetaType::Type::QDateTime, QStringLiteral( "timestamp" )}}, - { Qgis::GpsInformationComponent::Altitude, { QMetaType::Type::Double, QStringLiteral( "altitude" )}}, - { Qgis::GpsInformationComponent::EllipsoidAltitude, { QMetaType::Type::Double, QStringLiteral( "altitude_wgs84" )}}, - { Qgis::GpsInformationComponent::GroundSpeed, { QMetaType::Type::Double, QStringLiteral( "ground_speed" )}}, - { Qgis::GpsInformationComponent::Bearing, { QMetaType::Type::Double, QStringLiteral( "bearing" )}}, - { Qgis::GpsInformationComponent::Pdop, { QMetaType::Type::Double, QStringLiteral( "pdop" )}}, - { Qgis::GpsInformationComponent::Hdop, { QMetaType::Type::Double, QStringLiteral( "hdop" )}}, - { Qgis::GpsInformationComponent::Vdop, { QMetaType::Type::Double, QStringLiteral( "vdop" )}}, - { Qgis::GpsInformationComponent::HorizontalAccuracy, { QMetaType::Type::Double, QStringLiteral( "horizontal_accuracy" )}}, - { Qgis::GpsInformationComponent::VerticalAccuracy, { QMetaType::Type::Double, QStringLiteral( "vertical_accuracy" )}}, - { Qgis::GpsInformationComponent::HvAccuracy, { QMetaType::Type::Double, QStringLiteral( "hv_accuracy" )}}, - { Qgis::GpsInformationComponent::SatellitesUsed, { QMetaType::Type::Double, QStringLiteral( "satellites_used" )}}, - { Qgis::GpsInformationComponent::TrackDistanceSinceLastPoint, { QMetaType::Type::Double, QStringLiteral( "distance_since_previous" )}}, - { Qgis::GpsInformationComponent::TrackTimeSinceLastPoint, { QMetaType::Type::Double, QStringLiteral( "time_since_previous" )}}, +const std::vector>> QgsAppGpsLogging::sPointFields { + { Qgis::GpsInformationComponent::Timestamp, { QMetaType::Type::QDateTime, QStringLiteral( "timestamp" ) } }, + { Qgis::GpsInformationComponent::Altitude, { QMetaType::Type::Double, QStringLiteral( "altitude" ) } }, + { Qgis::GpsInformationComponent::EllipsoidAltitude, { QMetaType::Type::Double, QStringLiteral( "altitude_wgs84" ) } }, + { Qgis::GpsInformationComponent::GroundSpeed, { QMetaType::Type::Double, QStringLiteral( "ground_speed" ) } }, + { Qgis::GpsInformationComponent::Bearing, { QMetaType::Type::Double, QStringLiteral( "bearing" ) } }, + { Qgis::GpsInformationComponent::Pdop, { QMetaType::Type::Double, QStringLiteral( "pdop" ) } }, + { Qgis::GpsInformationComponent::Hdop, { QMetaType::Type::Double, QStringLiteral( "hdop" ) } }, + { Qgis::GpsInformationComponent::Vdop, { QMetaType::Type::Double, QStringLiteral( "vdop" ) } }, + { Qgis::GpsInformationComponent::HorizontalAccuracy, { QMetaType::Type::Double, QStringLiteral( "horizontal_accuracy" ) } }, + { Qgis::GpsInformationComponent::VerticalAccuracy, { QMetaType::Type::Double, QStringLiteral( "vertical_accuracy" ) } }, + { Qgis::GpsInformationComponent::HvAccuracy, { QMetaType::Type::Double, QStringLiteral( "hv_accuracy" ) } }, + { Qgis::GpsInformationComponent::SatellitesUsed, { QMetaType::Type::Double, QStringLiteral( "satellites_used" ) } }, + { Qgis::GpsInformationComponent::TrackDistanceSinceLastPoint, { QMetaType::Type::Double, QStringLiteral( "distance_since_previous" ) } }, + { Qgis::GpsInformationComponent::TrackTimeSinceLastPoint, { QMetaType::Type::Double, QStringLiteral( "time_since_previous" ) } }, }; -const std::vector< std::tuple< Qgis::GpsInformationComponent, std::tuple< QMetaType::Type, QString >>> QgsAppGpsLogging::sTrackFields -{ - { Qgis::GpsInformationComponent::TrackStartTime, { QMetaType::Type::QDateTime, QStringLiteral( "start_time" )}}, - { Qgis::GpsInformationComponent::TrackEndTime, { QMetaType::Type::QDateTime, QStringLiteral( "end_time" )}}, - { Qgis::GpsInformationComponent::TotalTrackLength, { QMetaType::Type::Double, QStringLiteral( "track_length" )}}, - { Qgis::GpsInformationComponent::TrackDistanceFromStart, { QMetaType::Type::Double, QStringLiteral( "distance_from_start" )}}, +const std::vector>> QgsAppGpsLogging::sTrackFields { + { Qgis::GpsInformationComponent::TrackStartTime, { QMetaType::Type::QDateTime, QStringLiteral( "start_time" ) } }, + { Qgis::GpsInformationComponent::TrackEndTime, { QMetaType::Type::QDateTime, QStringLiteral( "end_time" ) } }, + { Qgis::GpsInformationComponent::TotalTrackLength, { QMetaType::Type::Double, QStringLiteral( "track_length" ) } }, + { Qgis::GpsInformationComponent::TrackDistanceFromStart, { QMetaType::Type::Double, QStringLiteral( "distance_from_start" ) } }, }; @@ -62,13 +60,11 @@ QgsAppGpsLogging::QgsAppGpsLogging( QgsAppGpsConnection *connection, QObject *pa : QObject( parent ) , mConnection( connection ) { - connect( QgsProject::instance(), &QgsProject::transformContextChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::transformContextChanged, this, [=] { if ( mGpkgLogger ) mGpkgLogger->setTransformContext( QgsProject::instance()->transformContext() ); } ); - connect( QgsProject::instance(), &QgsProject::ellipsoidChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::ellipsoidChanged, this, [=] { if ( mGpkgLogger ) mGpkgLogger->setEllipsoid( QgsProject::instance()->ellipsoid() ); } ); @@ -76,8 +72,7 @@ QgsAppGpsLogging::QgsAppGpsLogging( QgsAppGpsConnection *connection, QObject *pa connect( mConnection, &QgsAppGpsConnection::connected, this, &QgsAppGpsLogging::gpsConnected ); connect( mConnection, &QgsAppGpsConnection::disconnected, this, &QgsAppGpsLogging::gpsDisconnected ); - connect( QgsGui::instance(), &QgsGui::optionsChanged, this, [ = ] - { + connect( QgsGui::instance(), &QgsGui::optionsChanged, this, [=] { if ( mGpkgLogger ) mGpkgLogger->updateGpsSettings(); } ); @@ -108,7 +103,7 @@ void QgsAppGpsLogging::setNmeaLogFile( const QString &filename ) void QgsAppGpsLogging::setNmeaLoggingEnabled( bool enabled ) { - if ( enabled == static_cast< bool >( mLogFile ) ) + if ( enabled == static_cast( mLogFile ) ) return; if ( mLogFile && !enabled ) @@ -186,10 +181,10 @@ void QgsAppGpsLogging::startNmeaLogging() { if ( !mLogFile ) { - mLogFile = std::make_unique< QFile >( mNmeaLogFile ); + mLogFile = std::make_unique( mNmeaLogFile ); } - if ( mLogFile->open( QIODevice::Append ) ) // open in binary and explicitly output CR + LF per NMEA + if ( mLogFile->open( QIODevice::Append ) ) // open in binary and explicitly output CR + LF per NMEA { mLogFileTextStream.setDevice( mLogFile.get() ); @@ -201,7 +196,7 @@ void QgsAppGpsLogging::startNmeaLogging() connect( mConnection, &QgsAppGpsConnection::nmeaSentenceReceived, this, &QgsAppGpsLogging::logNmeaSentence ); // added to handle raw data } - else // error opening file + else // error opening file { mLogFile.reset(); @@ -222,7 +217,7 @@ void QgsAppGpsLogging::stopNmeaLogging() void QgsAppGpsLogging::createGpkgLogger() { - mGpkgLogger = std::make_unique< QgsVectorLayerGpsLogger >( mConnection->connection() ); + mGpkgLogger = std::make_unique( mConnection->connection() ); mGpkgLogger->setTransformContext( QgsProject::instance()->transformContext() ); mGpkgLogger->setEllipsoid( QgsProject::instance()->ellipsoid() ); mGpkgLogger->updateGpsSettings(); @@ -234,13 +229,13 @@ void QgsAppGpsLogging::createGpkgLogger() uriParts.insert( QStringLiteral( "path" ), mGpkgLogFile ); uriParts.insert( QStringLiteral( "layerName" ), QStringLiteral( "gps_points" ) ); - mGpkgPointsLayer = std::make_unique< QgsVectorLayer >( QgsProviderRegistry::instance()->encodeUri( QStringLiteral( "ogr" ), uriParts ) ); + mGpkgPointsLayer = std::make_unique( QgsProviderRegistry::instance()->encodeUri( QStringLiteral( "ogr" ), uriParts ) ); if ( mGpkgPointsLayer->isValid() ) { for ( const auto &it : sPointFields ) { Qgis::GpsInformationComponent component; - std::tuple< QMetaType::Type, QString > fieldTypeToName; + std::tuple fieldTypeToName; QMetaType::Type fieldType; QString fieldName; std::tie( component, fieldTypeToName ) = it; @@ -263,13 +258,13 @@ void QgsAppGpsLogging::createGpkgLogger() } uriParts.insert( QStringLiteral( "layerName" ), QStringLiteral( "gps_tracks" ) ); - mGpkgTracksLayer = std::make_unique< QgsVectorLayer >( QgsProviderRegistry::instance()->encodeUri( QStringLiteral( "ogr" ), uriParts ) ); + mGpkgTracksLayer = std::make_unique( QgsProviderRegistry::instance()->encodeUri( QStringLiteral( "ogr" ), uriParts ) ); if ( mGpkgTracksLayer->isValid() ) { for ( const auto &it : sTrackFields ) { Qgis::GpsInformationComponent component; - std::tuple< QMetaType::Type, QString > fieldTypeToName; + std::tuple fieldTypeToName; QMetaType::Type fieldType; QString fieldName; std::tie( component, fieldTypeToName ) = it; @@ -290,7 +285,6 @@ void QgsAppGpsLogging::createGpkgLogger() mGpkgTracksLayer.reset(); return; } - } bool QgsAppGpsLogging::createOrUpdateLogDatabase() @@ -305,7 +299,7 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() bool newFile = false; if ( !QFile::exists( mGpkgLogFile ) ) { - if ( ! ogrMetadata->createDatabase( mGpkgLogFile, error ) ) + if ( !ogrMetadata->createDatabase( mGpkgLogFile, error ) ) { QgisApp::instance()->messageBar()->pushCritical( tr( "Create GPS Log" ), tr( "Database creation failed: %1" ).arg( error ) ); emit gpkgLoggingFailed(); @@ -318,14 +312,14 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() bool createPointLayer = true; if ( !newFile ) { - std::unique_ptr< QgsVectorLayer > testLayer = std::make_unique< QgsVectorLayer>( ogrMetadata->encodeUri( {{QStringLiteral( "path" ), mGpkgLogFile }, {QStringLiteral( "layerName" ), QStringLiteral( "gps_points" )}} ), QString(), QStringLiteral( "ogr" ) ); + std::unique_ptr testLayer = std::make_unique( ogrMetadata->encodeUri( { { QStringLiteral( "path" ), mGpkgLogFile }, { QStringLiteral( "layerName" ), QStringLiteral( "gps_points" ) } } ), QString(), QStringLiteral( "ogr" ) ); if ( testLayer->isValid() ) { createPointLayer = false; } } - QMap< int, int > unusedMap; + QMap unusedMap; QVariantMap options; options.insert( QStringLiteral( "driverName" ), QgsVectorFileWriter::driverForExtension( fi.suffix() ) ); options.insert( QStringLiteral( "update" ), true ); @@ -336,7 +330,7 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() for ( const auto &it : sPointFields ) { Qgis::GpsInformationComponent component; - std::tuple< QMetaType::Type, QString > fieldTypeToName; + std::tuple fieldTypeToName; QMetaType::Type fieldType; QString fieldName; std::tie( component, fieldTypeToName ) = it; @@ -344,11 +338,7 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() pointFields.append( QgsField( fieldName, fieldType ) ); } - const Qgis::VectorExportResult result = ogrMetadata->createEmptyLayer( mGpkgLogFile, - pointFields, - QgsGpsLogger::settingsGpsStoreAttributeInMValues->value() ? Qgis::WkbType::PointZM : Qgis::WkbType::PointZ, - QgsCoordinateReferenceSystem( "EPSG:4326" ), - false, unusedMap, error, &options ); + const Qgis::VectorExportResult result = ogrMetadata->createEmptyLayer( mGpkgLogFile, pointFields, QgsGpsLogger::settingsGpsStoreAttributeInMValues->value() ? Qgis::WkbType::PointZM : Qgis::WkbType::PointZ, QgsCoordinateReferenceSystem( "EPSG:4326" ), false, unusedMap, error, &options ); if ( result != Qgis::VectorExportResult::Success ) { QgisApp::instance()->messageBar()->pushCritical( tr( "Create GPS Log" ), tr( "Database creation failed: %1" ).arg( error ) ); @@ -363,7 +353,7 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() bool createTracksLayer = true; if ( !newFile ) { - std::unique_ptr< QgsVectorLayer > testLayer = std::make_unique< QgsVectorLayer>( ogrMetadata->encodeUri( {{QStringLiteral( "path" ), mGpkgLogFile }, {QStringLiteral( "layerName" ), QStringLiteral( "gps_tracks" )}} ), QString(), QStringLiteral( "ogr" ) ); + std::unique_ptr testLayer = std::make_unique( ogrMetadata->encodeUri( { { QStringLiteral( "path" ), mGpkgLogFile }, { QStringLiteral( "layerName" ), QStringLiteral( "gps_tracks" ) } } ), QString(), QStringLiteral( "ogr" ) ); if ( testLayer->isValid() ) { createTracksLayer = false; @@ -376,7 +366,7 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() for ( const auto &it : sTrackFields ) { Qgis::GpsInformationComponent component; - std::tuple< QMetaType::Type, QString > fieldTypeToName; + std::tuple fieldTypeToName; QMetaType::Type fieldType; QString fieldName; std::tie( component, fieldTypeToName ) = it; @@ -384,11 +374,7 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() tracksFields.append( QgsField( fieldName, fieldType ) ); } - const Qgis::VectorExportResult result = ogrMetadata->createEmptyLayer( mGpkgLogFile, - tracksFields, - QgsGpsLogger::settingsGpsStoreAttributeInMValues->value() ? Qgis::WkbType::LineStringZM : Qgis::WkbType::LineStringZ, - QgsCoordinateReferenceSystem( "EPSG:4326" ), - false, unusedMap, error, &options ); + const Qgis::VectorExportResult result = ogrMetadata->createEmptyLayer( mGpkgLogFile, tracksFields, QgsGpsLogger::settingsGpsStoreAttributeInMValues->value() ? Qgis::WkbType::LineStringZM : Qgis::WkbType::LineStringZ, QgsCoordinateReferenceSystem( "EPSG:4326" ), false, unusedMap, error, &options ); if ( result != Qgis::VectorExportResult::Success ) { QgisApp::instance()->messageBar()->pushCritical( tr( "Create GPS Log" ), tr( "Database creation failed: %1" ).arg( error ) ); @@ -400,4 +386,3 @@ bool QgsAppGpsLogging::createOrUpdateLogDatabase() } return false; } - diff --git a/src/app/gps/qgsappgpslogging.h b/src/app/gps/qgsappgpslogging.h index dc82d4251fb3..186dcbc44662 100644 --- a/src/app/gps/qgsappgpslogging.h +++ b/src/app/gps/qgsappgpslogging.h @@ -31,12 +31,11 @@ class QgsVectorLayerGpsLogger; class QgsVectorLayer; class QgsSettingsEntryString; -class APP_EXPORT QgsAppGpsLogging: public QObject +class APP_EXPORT QgsAppGpsLogging : public QObject { Q_OBJECT public: - static const QgsSettingsEntryString *settingLastLogFolder; static const QgsSettingsEntryString *settingLastGpkgLog; @@ -63,7 +62,6 @@ class APP_EXPORT QgsAppGpsLogging: public QObject void stopNmeaLogging(); private: - void createGpkgLogger(); bool createOrUpdateLogDatabase(); void createGpkgLogDatabase(); @@ -74,17 +72,16 @@ class APP_EXPORT QgsAppGpsLogging: public QObject QString mNmeaLogFile; bool mEnableNmeaLogging = false; - std::unique_ptr< QFile > mLogFile; + std::unique_ptr mLogFile; QTextStream mLogFileTextStream; QString mGpkgLogFile; - std::unique_ptr< QgsVectorLayerGpsLogger > mGpkgLogger; - std::unique_ptr< QgsVectorLayer > mGpkgPointsLayer; - std::unique_ptr< QgsVectorLayer > mGpkgTracksLayer; - - static const std::vector< std::tuple< Qgis::GpsInformationComponent, std::tuple< QMetaType::Type, QString >>> sPointFields; - static const std::vector< std::tuple< Qgis::GpsInformationComponent, std::tuple< QMetaType::Type, QString >>> sTrackFields; + std::unique_ptr mGpkgLogger; + std::unique_ptr mGpkgPointsLayer; + std::unique_ptr mGpkgTracksLayer; + static const std::vector>> sPointFields; + static const std::vector>> sTrackFields; }; #endif // QGSAPPGPSLOGGING_H diff --git a/src/app/gps/qgsappgpssettingsmenu.cpp b/src/app/gps/qgsappgpssettingsmenu.cpp index b3dc3fcf8c0d..e12826c00dca 100644 --- a/src/app/gps/qgsappgpssettingsmenu.cpp +++ b/src/app/gps/qgsappgpssettingsmenu.cpp @@ -68,7 +68,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) Qgis::MapRecenteringMode mapCenteringMode = Qgis::MapRecenteringMode::WhenOutsideVisibleExtent; bool rotateMap = false; - if ( QgsGpsCanvasBridge::settingShowBearingLine->exists( ) ) + if ( QgsGpsCanvasBridge::settingShowBearingLine->exists() ) { showLocationMarker = QgsGpsMarker::settingShowLocationMarker->value(); showBearingLine = QgsGpsCanvasBridge::settingShowBearingLine->value(); @@ -101,8 +101,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) mShowLocationMarkerAction = new QAction( tr( "Show Location Marker" ), this ); mShowLocationMarkerAction->setCheckable( true ); mShowLocationMarkerAction->setChecked( showLocationMarker ); - connect( mShowLocationMarkerAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( mShowLocationMarkerAction, &QAction::toggled, this, [=]( bool checked ) { emit locationMarkerToggled( checked ); QgsGpsMarker::settingShowLocationMarker->setValue( checked ); } ); @@ -112,8 +111,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) mShowBearingLineAction = new QAction( tr( "Show Bearing Line" ), this ); mShowBearingLineAction->setCheckable( true ); mShowBearingLineAction->setChecked( showBearingLine ); - connect( mShowBearingLineAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( mShowBearingLineAction, &QAction::toggled, this, [=]( bool checked ) { emit bearingLineToggled( checked ); QgsGpsCanvasBridge::settingShowBearingLine->setValue( checked ); } ); @@ -124,8 +122,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) mRotateMapAction = new QAction( tr( "Rotate Map to Match GPS Direction" ), this ); mRotateMapAction->setCheckable( true ); mRotateMapAction->setChecked( rotateMap ); - connect( mRotateMapAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( mRotateMapAction, &QAction::toggled, this, [=]( bool checked ) { QgsGpsCanvasBridge::settingRotateMap->setValue( checked ); emit rotateMapToggled( checked ); } ); @@ -151,8 +148,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) break; } - connect( mRadioAlwaysRecenter, &QRadioButton::toggled, this, [ = ]( bool checked ) - { + connect( mRadioAlwaysRecenter, &QRadioButton::toggled, this, [=]( bool checked ) { if ( checked ) { QgsGpsCanvasBridge::settingMapCenteringMode->setValue( Qgis::MapRecenteringMode::Always ); @@ -160,8 +156,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) } } ); - connect( mRadioRecenterWhenOutside, &QRadioButton::toggled, this, [ = ]( bool checked ) - { + connect( mRadioRecenterWhenOutside, &QRadioButton::toggled, this, [=]( bool checked ) { if ( checked ) { QgsGpsCanvasBridge::settingMapCenteringMode->setValue( Qgis::MapRecenteringMode::WhenOutsideVisibleExtent ); @@ -169,8 +164,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) } } ); - connect( mRadioNeverRecenter, &QRadioButton::toggled, this, [ = ]( bool checked ) - { + connect( mRadioNeverRecenter, &QRadioButton::toggled, this, [=]( bool checked ) { if ( checked ) { QgsGpsCanvasBridge::settingMapCenteringMode->setValue( Qgis::MapRecenteringMode::Never ); @@ -186,8 +180,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) mAutoAddTrackVerticesAction = new QAction( tr( "Automatically Add Track Vertices" ), this ); mAutoAddTrackVerticesAction->setCheckable( true ); mAutoAddTrackVerticesAction->setChecked( QgsProject::instance()->gpsSettings()->automaticallyAddTrackVertices() ); - connect( mAutoAddTrackVerticesAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( mAutoAddTrackVerticesAction, &QAction::toggled, this, [=]( bool checked ) { if ( checked != QgsProject::instance()->gpsSettings()->automaticallyAddTrackVertices() ) { QgsProject::instance()->gpsSettings()->setAutomaticallyAddTrackVertices( checked ); @@ -201,8 +194,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) mAutoSaveAddedFeatureAction = new QAction( tr( "Automatically Save Added Feature" ), this ); mAutoSaveAddedFeatureAction->setCheckable( true ); mAutoSaveAddedFeatureAction->setChecked( QgsProject::instance()->gpsSettings()->automaticallyCommitFeatures() ); - connect( mAutoSaveAddedFeatureAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( mAutoSaveAddedFeatureAction, &QAction::toggled, this, [=]( bool checked ) { if ( checked != QgsProject::instance()->gpsSettings()->automaticallyCommitFeatures() ) { QgsProject::instance()->gpsSettings()->setAutomaticallyCommitFeatures( checked ); @@ -225,17 +217,14 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) mActionGpkgLog = new QAction( tr( "Log to GeoPackage/Spatialite…" ), this ); mActionGpkgLog->setCheckable( true ); - connect( mActionGpkgLog, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( mActionGpkgLog, &QAction::toggled, this, [=]( bool checked ) { if ( checked ) { const QString lastGpkgLog = QgsAppGpsLogging::settingLastGpkgLog->value(); const QString initialPath = lastGpkgLog.isEmpty() ? QDir::homePath() : lastGpkgLog; QString selectedFilter; - QString fileName = QFileDialog::getSaveFileName( this, tr( "GPS Log File" ), initialPath, - tr( "GeoPackage" ) + " (*.gpkg *.GPKG);;" + tr( "SpatiaLite" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db);;", - &selectedFilter, QFileDialog::Option::DontConfirmOverwrite ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "GPS Log File" ), initialPath, tr( "GeoPackage" ) + " (*.gpkg *.GPKG);;" + tr( "SpatiaLite" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db);;", &selectedFilter, QFileDialog::Option::DontConfirmOverwrite ); if ( fileName.isEmpty() ) { mActionGpkgLog->setChecked( false ); @@ -257,8 +246,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) mActionNmeaLog = new QAction( tr( "Log NMEA Sentences…" ), this ); mActionNmeaLog->setCheckable( true ); - connect( mActionNmeaLog, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( mActionNmeaLog, &QAction::toggled, this, [=]( bool checked ) { if ( checked ) { const QString lastLogFolder = QgsAppGpsLogging::settingLastLogFolder->value(); @@ -289,8 +277,7 @@ QgsAppGpsSettingsMenu::QgsAppGpsSettingsMenu( QWidget *parent ) QAction *settingsAction = new QAction( tr( "GPS Settings…" ), this ); settingsAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOptions.svg" ) ) ); - connect( settingsAction, &QAction::triggered, this, [ = ] - { + connect( settingsAction, &QAction::triggered, this, [=] { QgisApp::instance()->showOptionsDialog( QgisApp::instance(), QStringLiteral( "mGpsOptions" ) ); } ); @@ -348,8 +335,8 @@ void QgsAppGpsSettingsMenu::timeStampMenuAboutToShow() { fieldAction->setText( tr( "Do Not Store" ) ); } - fieldAction->setIcon( mFieldProxyModel->data( mFieldProxyModel->index( row, 0 ), Qt::DecorationRole ).value< QIcon >() ); - const QString fieldName = mFieldProxyModel->data( mFieldProxyModel->index( row, 0 ), static_cast< int >( QgsFieldModel::CustomRole::FieldName ) ).toString(); + fieldAction->setIcon( mFieldProxyModel->data( mFieldProxyModel->index( row, 0 ), Qt::DecorationRole ).value() ); + const QString fieldName = mFieldProxyModel->data( mFieldProxyModel->index( row, 0 ), static_cast( QgsFieldModel::CustomRole::FieldName ) ).toString(); fieldAction->setData( fieldName ); fieldAction->setCheckable( true ); if ( currentTimeStampField == fieldName ) @@ -357,8 +344,7 @@ void QgsAppGpsSettingsMenu::timeStampMenuAboutToShow() foundPreviousField = true; fieldAction->setChecked( currentTimeStampField == fieldName ); } - connect( fieldAction, &QAction::triggered, this, [ = ]() - { + connect( fieldAction, &QAction::triggered, this, [=]() { if ( QgsProject::instance()->gpsSettings()->destinationTimeStampField() != fieldName ) { QgsProject::instance()->gpsSettings()->setDestinationTimeStampField( QgsProject::instance()->gpsSettings()->destinationLayer(), fieldName ); @@ -373,4 +359,3 @@ void QgsAppGpsSettingsMenu::timeStampMenuAboutToShow() mTimeStampDestinationFieldMenu->actions().at( 0 )->setChecked( true ); } } - diff --git a/src/app/gps/qgsappgpssettingsmenu.h b/src/app/gps/qgsappgpssettingsmenu.h index a9c988f03815..59fcaba7c6c7 100644 --- a/src/app/gps/qgsappgpssettingsmenu.h +++ b/src/app/gps/qgsappgpssettingsmenu.h @@ -25,12 +25,11 @@ class QRadioButton; class QgsFieldProxyModel; -class QgsGpsMapRotationAction: public QWidgetAction +class QgsGpsMapRotationAction : public QWidgetAction { Q_OBJECT public: - QgsGpsMapRotationAction( QWidget *parent = nullptr ); QRadioButton *radioAlwaysRecenter() { return mRadioAlwaysRecenter; } @@ -41,7 +40,6 @@ class QgsGpsMapRotationAction: public QWidgetAction QRadioButton *mRadioAlwaysRecenter = nullptr; QRadioButton *mRadioRecenterWhenOutside = nullptr; QRadioButton *mRadioNeverRecenter = nullptr; - }; class APP_EXPORT QgsAppGpsSettingsMenu : public QMenu @@ -49,7 +47,6 @@ class APP_EXPORT QgsAppGpsSettingsMenu : public QMenu Q_OBJECT public: - QgsAppGpsSettingsMenu( QWidget *parent ); bool locationMarkerVisible() const; @@ -76,7 +73,6 @@ class APP_EXPORT QgsAppGpsSettingsMenu : public QMenu void timeStampMenuAboutToShow(); private: - QAction *mShowLocationMarkerAction = nullptr; QAction *mShowBearingLineAction = nullptr; QAction *mRotateMapAction = nullptr; @@ -93,7 +89,6 @@ class APP_EXPORT QgsAppGpsSettingsMenu : public QMenu QMenu *mTimeStampDestinationFieldMenu = nullptr; friend class TestQgsGpsIntegration; - }; #endif // QGSAPPGPSSETTINGSMANAGER_H diff --git a/src/app/gps/qgsgpsbearingitem.cpp b/src/app/gps/qgsgpsbearingitem.cpp index 04493b12bb8d..02a13a60d210 100644 --- a/src/app/gps/qgsgpsbearingitem.cpp +++ b/src/app/gps/qgsgpsbearingitem.cpp @@ -91,8 +91,7 @@ void QgsGpsBearingItem::updateLine() double totalLength = 0; try { - totalLength = 2 * da1.measureLine( mMapCanvas->mapSettings().extent().center(), QgsPointXY( mMapCanvas->mapSettings().extent().xMaximum(), - mMapCanvas->mapSettings().extent().yMaximum() ) ); + totalLength = 2 * da1.measureLine( mMapCanvas->mapSettings().extent().center(), QgsPointXY( mMapCanvas->mapSettings().extent().xMaximum(), mMapCanvas->mapSettings().extent().yMaximum() ) ); } catch ( QgsCsException & ) { diff --git a/src/app/gps/qgsgpsbearingitem.h b/src/app/gps/qgsgpsbearingitem.h index bf93c32177f7..52772aceea16 100644 --- a/src/app/gps/qgsgpsbearingitem.h +++ b/src/app/gps/qgsgpsbearingitem.h @@ -43,7 +43,6 @@ class QgsGpsBearingItem : public QObject, public QgsMapCanvasLineSymbolItem void updatePosition() override; protected: - //! coordinates of the point in the center (map units) QgsPointXY mCenter; @@ -55,7 +54,6 @@ class QgsGpsBearingItem : public QObject, public QgsMapCanvasLineSymbolItem QgsCoordinateReferenceSystem mWgs84CRS; double mBearing = 0; - }; #endif // QGSGPSBEARINGITEM_H diff --git a/src/app/gps/qgsgpscanvasbridge.cpp b/src/app/gps/qgsgpscanvasbridge.cpp index 51c74a5b9c14..bb036bc9207e 100644 --- a/src/app/gps/qgsgpscanvasbridge.cpp +++ b/src/app/gps/qgsgpscanvasbridge.cpp @@ -59,19 +59,16 @@ QgsGpsCanvasBridge::QgsGpsCanvasBridge( QgsAppGpsConnection *connection, QgsMapC connect( QgsGui::instance(), &QgsGui::optionsChanged, this, &QgsGpsCanvasBridge::gpsSettingsChanged ); mCanvasToWgs84Transform = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), mWgs84CRS, QgsProject::instance() ); - connect( mCanvas, &QgsMapCanvas::destinationCrsChanged, this, [ = ] - { + connect( mCanvas, &QgsMapCanvas::destinationCrsChanged, this, [=] { mCanvasToWgs84Transform = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), mWgs84CRS, QgsProject::instance() ); } ); - connect( QgsProject::instance(), &QgsProject::transformContextChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::transformContextChanged, this, [=] { mCanvasToWgs84Transform = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), mWgs84CRS, QgsProject::instance() ); } ); mDistanceCalculator.setEllipsoid( QgsProject::instance()->ellipsoid() ); mDistanceCalculator.setSourceCrs( mWgs84CRS, QgsProject::instance()->transformContext() ); - connect( QgsProject::instance(), &QgsProject::ellipsoidChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::ellipsoidChanged, this, [=] { mDistanceCalculator.setEllipsoid( QgsProject::instance()->ellipsoid() ); } ); @@ -79,8 +76,7 @@ QgsGpsCanvasBridge::QgsGpsCanvasBridge( QgsAppGpsConnection *connection, QgsMapC connect( mCanvas, &QgsMapCanvas::tapAndHoldGestureOccurred, this, &QgsGpsCanvasBridge::tapAndHold ); mBearingNumericFormat.reset( QgsLocalDefaultSettings::bearingFormat() ); - connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::bearingFormatChanged, this, [ = ] - { + connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::bearingFormatChanged, this, [=] { mBearingNumericFormat.reset( QgsProject::instance()->displaySettings()->bearingFormat()->clone() ); updateGpsDistanceStatusMessage( false ); } ); @@ -158,7 +154,6 @@ void QgsGpsCanvasBridge::tapAndHold( const QgsPointXY &mapPoint, QTapAndHoldGest } catch ( QgsCsException & ) { - } } @@ -180,7 +175,7 @@ void QgsGpsCanvasBridge::updateBearingAppearance() { doc.setContent( bearingLineSymbolXml ); elem = doc.documentElement(); - std::unique_ptr< QgsLineSymbol > bearingSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); + std::unique_ptr bearingSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); if ( bearingSymbol ) { mMapBearingItem->setSymbol( std::move( bearingSymbol ) ); @@ -196,8 +191,8 @@ void QgsGpsCanvasBridge::gpsSettingsChanged() if ( QgsGpsConnection::settingsGpsConnectionType->exists() ) { mBearingFromTravelDirection = QgsGpsConnection::settingGpsBearingFromTravelDirection->value(); - mMapExtentMultiplier = static_cast< int >( QgsGpsCanvasBridge::settingMapExtentRecenteringThreshold->value() ); - mMapRotateInterval = static_cast< int >( QgsGpsCanvasBridge::settingMapRotateInterval->value() ); + mMapExtentMultiplier = static_cast( QgsGpsCanvasBridge::settingMapExtentRecenteringThreshold->value() ); + mMapRotateInterval = static_cast( QgsGpsCanvasBridge::settingMapRotateInterval->value() ); } else { @@ -211,7 +206,7 @@ void QgsGpsCanvasBridge::gpsSettingsChanged() void QgsGpsCanvasBridge::gpsDisconnected() { - if ( mMapMarker ) // marker should not be shown on GPS disconnected - not current position + if ( mMapMarker ) // marker should not be shown on GPS disconnected - not current position { delete mMapMarker; mMapMarker = nullptr; @@ -250,7 +245,7 @@ void QgsGpsCanvasBridge::gpsStateChanged( const QgsGpsInformation &info ) { const QgsPointXY point = mCanvasToWgs84Transform.transform( myNewCenter, Qgis::TransformDirection::Reverse ); //keep the extent the same just center the map canvas in the display so our feature is in the middle - const QgsRectangle rect( point, point ); // empty rect can be used to set new extent that is centered on the point used to construct the rect + const QgsRectangle rect( point, point ); // empty rect can be used to set new extent that is centered on the point used to construct the rect // testing if position is outside some proportion of the map extent // this is a user setting - useful range: 5% to 100% (0.05 to 1.0) @@ -258,8 +253,7 @@ void QgsGpsCanvasBridge::gpsStateChanged( const QgsGpsInformation &info ) extentLimit.scale( mMapExtentMultiplier * 0.01 ); // only change the extents if the point is beyond the current extents to minimize repaints - if ( mCenteringMode == Qgis::MapRecenteringMode::Always || - ( mCenteringMode == Qgis::MapRecenteringMode::WhenOutsideVisibleExtent && !extentLimit.contains( point ) ) ) + if ( mCenteringMode == Qgis::MapRecenteringMode::Always || ( mCenteringMode == Qgis::MapRecenteringMode::WhenOutsideVisibleExtent && !extentLimit.contains( point ) ) ) { mCanvas->setExtent( rect, true ); mCanvas->refresh(); @@ -267,7 +261,6 @@ void QgsGpsCanvasBridge::gpsStateChanged( const QgsGpsInformation &info ) } catch ( QgsCsException & ) { - } break; @@ -296,7 +289,6 @@ void QgsGpsCanvasBridge::gpsStateChanged( const QgsGpsInformation &info ) } catch ( QgsException & ) { - } } } @@ -308,12 +300,10 @@ void QgsGpsCanvasBridge::gpsStateChanged( const QgsGpsInformation &info ) } catch ( QgsCsException & ) { - } - } - if ( mRotateMap && ( !mLastRotateTimer.isValid() || mLastRotateTimer.hasExpired( static_cast< long long >( mMapRotateInterval ) * 1000 ) ) ) + if ( mRotateMap && ( !mLastRotateTimer.isValid() || mLastRotateTimer.hasExpired( static_cast( mMapRotateInterval ) * 1000 ) ) ) { const QgsCoordinateTransform wgs84ToCanvas( mWgs84CRS, mCanvas->mapSettings().destinationCrs(), QgsProject::instance()->transformContext() ); @@ -329,8 +319,7 @@ void QgsGpsCanvasBridge::gpsStateChanged( const QgsGpsInformation &info ) double totalLength = 0; try { - totalLength = da1.measureLine( mCanvas->mapSettings().extent().center(), QgsPointXY( mCanvas->mapSettings().extent().xMaximum(), - mCanvas->mapSettings().extent().yMaximum() ) ); + totalLength = da1.measureLine( mCanvas->mapSettings().extent().center(), QgsPointXY( mCanvas->mapSettings().extent().xMaximum(), mCanvas->mapSettings().extent().yMaximum() ) ); } catch ( QgsCsException & ) { @@ -402,8 +391,6 @@ void QgsGpsCanvasBridge::gpsStateChanged( const QgsGpsInformation &info ) mMapMarker = nullptr; } } - - } void QgsGpsCanvasBridge::cursorCoordinateChanged( const QgsPointXY &point ) @@ -418,7 +405,6 @@ void QgsGpsCanvasBridge::cursorCoordinateChanged( const QgsPointXY &point ) } catch ( QgsCsException & ) { - } } @@ -444,19 +430,15 @@ void QgsGpsCanvasBridge::updateGpsDistanceStatusMessage( bool forceDisplay ) try { - const double distance = mDistanceCalculator.convertLengthMeasurement( mDistanceCalculator.measureLine( QVector< QgsPointXY >() << mLastCursorPosWgs84 << mLastGpsPosition ), - QgsProject::instance()->distanceUnits() ); + const double distance = mDistanceCalculator.convertLengthMeasurement( mDistanceCalculator.measureLine( QVector() << mLastCursorPosWgs84 << mLastGpsPosition ), QgsProject::instance()->distanceUnits() ); const double bearing = 180 * mDistanceCalculator.bearing( mLastGpsPosition, mLastCursorPosWgs84 ) / M_PI; const int distanceDecimalPlaces = QgsSettings().value( QStringLiteral( "qgis/measure/decimalplaces" ), "3" ).toInt(); const QString distanceString = QgsDistanceArea::formatDistance( distance, distanceDecimalPlaces, QgsProject::instance()->distanceUnits() ); const QString bearingString = mBearingNumericFormat->formatDouble( bearing, QgsNumericFormatContext() ); - QgisApp::instance()->statusBarIface()->showMessage( tr( "%1 (%2) from GPS location" ).arg( distanceString, bearingString ), forceDisplay ? GPS_DISTANCE_MESSAGE_TIMEOUT_MS - : GPS_DISTANCE_MESSAGE_TIMEOUT_MS - static_cast< int >( mLastForcedStatusUpdate.elapsed() ) ); + QgisApp::instance()->statusBarIface()->showMessage( tr( "%1 (%2) from GPS location" ).arg( distanceString, bearingString ), forceDisplay ? GPS_DISTANCE_MESSAGE_TIMEOUT_MS : GPS_DISTANCE_MESSAGE_TIMEOUT_MS - static_cast( mLastForcedStatusUpdate.elapsed() ) ); } catch ( QgsCsException & ) { - } } - diff --git a/src/app/gps/qgsgpscanvasbridge.h b/src/app/gps/qgsgpscanvasbridge.h index dff11da85c73..5acb41b02241 100644 --- a/src/app/gps/qgsgpscanvasbridge.h +++ b/src/app/gps/qgsgpscanvasbridge.h @@ -43,7 +43,6 @@ class APP_EXPORT QgsGpsCanvasBridge : public QObject, public QgsMapCanvasInterac Q_OBJECT public: - static const QgsSettingsEntryBool *settingShowBearingLine; static const QgsSettingsEntryString *settingBearingLineSymbol; static const QgsSettingsEntryInteger *settingMapExtentRecenteringThreshold; @@ -75,7 +74,6 @@ class APP_EXPORT QgsGpsCanvasBridge : public QObject, public QgsMapCanvasInterac void updateGpsDistanceStatusMessage( bool forceDisplay ); private: - QgsAppGpsConnection *mConnection = nullptr; QgsMapCanvas *mCanvas = nullptr; @@ -105,7 +103,7 @@ class APP_EXPORT QgsGpsCanvasBridge : public QObject, public QgsMapCanvasInterac QElapsedTimer mLastForcedStatusUpdate; - std::unique_ptr< QgsBearingNumericFormat > mBearingNumericFormat; + std::unique_ptr mBearingNumericFormat; }; #endif // QGSGPSCANVASBRIDGE_H diff --git a/src/app/gps/qgsgpsinformationwidget.cpp b/src/app/gps/qgsgpsinformationwidget.cpp index aedb8a10fb66..46640a545e31 100644 --- a/src/app/gps/qgsgpsinformationwidget.cpp +++ b/src/app/gps/qgsgpsinformationwidget.cpp @@ -54,8 +54,7 @@ #include -QgsGpsInformationWidget::QgsGpsInformationWidget( QgsAppGpsConnection *connection, - QgsMapCanvas *mapCanvas, QgsAppGpsDigitizing *digitizing, QWidget *parent ) +QgsGpsInformationWidget::QgsGpsInformationWidget( QgsAppGpsConnection *connection, QgsMapCanvas *mapCanvas, QgsAppGpsDigitizing *digitizing, QWidget *parent ) : QgsPanelWidget( parent ) , mConnection( connection ) , mMapCanvas( mapCanvas ) @@ -82,14 +81,14 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsAppGpsConnection *connectio // Set up the graph for signal strength // mPlot = new QwtPlot( mpHistogramWidget ); - mPlot->setAutoReplot( false ); // plot on demand + mPlot->setAutoReplot( false ); // plot on demand //mPlot->setTitle(QObject::tr("Signal Status")); //mPlot->insertLegend(new QwtLegend(), QwtPlot::BottomLegend); // Set axis titles //mPlot->setAxisTitle(QwtPlot::xBottom, QObject::tr("Satellite")); //mPlot->setAxisTitle(QwtPlot::yLeft, QObject::tr("Value")); mPlot->setAxisScale( QwtPlot::xBottom, 0, 20 ); - mPlot->setAxisScale( QwtPlot::yLeft, 0, 60 ); // max is 50dB SNR, I believe - SLM + mPlot->setAxisScale( QwtPlot::yLeft, 0, 60 ); // max is 50dB SNR, I believe - SLM // add a grid QwtPlotGrid *mGrid = new QwtPlotGrid(); mGrid->enableX( false ); @@ -114,46 +113,46 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsAppGpsConnection *connectio // #ifdef WITH_QWTPOLAR QWidget *mpPolarWidget = mStackedWidget->widget( 2 ); - mpSatellitesWidget = new QwtPolarPlot( /*QwtText( tr( "Satellite View" ), QwtText::PlainText ),*/ mpPolarWidget ); // possible title for graph removed for now as it is too large in small windows - mpSatellitesWidget->setAutoReplot( false ); // plot on demand (after all data has been handled) + mpSatellitesWidget = new QwtPolarPlot( /*QwtText( tr( "Satellite View" ), QwtText::PlainText ),*/ mpPolarWidget ); // possible title for graph removed for now as it is too large in small windows + mpSatellitesWidget->setAutoReplot( false ); // plot on demand (after all data has been handled) mpSatellitesWidget->setPlotBackground( Qt::white ); // scales mpSatellitesWidget->setScale( QwtPolar::ScaleAzimuth, 360, //min - reverse the min/max values to get compass orientation - increasing clockwise - 0, //max - 90 //interval - just show cardinal and intermediate (NE, N, NW, etc.) compass points (in degrees) - ); - mpSatellitesWidget->setAzimuthOrigin( M_PI_2 ); // to get compass orientation - need to rotate 90 deg. ccw; this is in Radians (not indicated in QwtPolarPlot docs) + 0, //max + 90 //interval - just show cardinal and intermediate (NE, N, NW, etc.) compass points (in degrees) + ); + mpSatellitesWidget->setAzimuthOrigin( M_PI_2 ); // to get compass orientation - need to rotate 90 deg. ccw; this is in Radians (not indicated in QwtPolarPlot docs) -// mpSatellitesWidget->setScaleMaxMinor( QwtPolar::ScaleRadius, 2 ); // seems unnecessary + // mpSatellitesWidget->setScaleMaxMinor( QwtPolar::ScaleRadius, 2 ); // seems unnecessary mpSatellitesWidget->setScale( QwtPolar::ScaleRadius, 90, //min - reverse the min/max to get 0 at edge, 90 at center - 0, //max - 45 //interval - ); + 0, //max + 45 //interval + ); // grids, axes mpSatellitesGrid = new QwtPolarGrid(); - mpSatellitesGrid->setGridAttribute( QwtPolarGrid::AutoScaling, false ); // This fixes the issue of autoscaling on the Radius grid. It is ON by default AND is separate from the scaleData.doAutoScale in QwtPolarPlot::setScale(), etc. THIS IS VERY TRICKY! + mpSatellitesGrid->setGridAttribute( QwtPolarGrid::AutoScaling, false ); // This fixes the issue of autoscaling on the Radius grid. It is ON by default AND is separate from the scaleData.doAutoScale in QwtPolarPlot::setScale(), etc. THIS IS VERY TRICKY! mpSatellitesGrid->setPen( QPen( Qt::black ) ); - QPen minorPen( Qt::gray ); // moved outside of for loop; NOTE setting the minor pen isn't necessary if the minor grids aren't shown + QPen minorPen( Qt::gray ); // moved outside of for loop; NOTE setting the minor pen isn't necessary if the minor grids aren't shown for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) { //mpSatellitesGrid->showGrid( scaleId ); //mpSatellitesGrid->showMinorGrid(scaleId); mpSatellitesGrid->setMinorGridPen( scaleId, minorPen ); } -// mpSatellitesGrid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ) ); + // mpSatellitesGrid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ) ); mpSatellitesGrid->showAxis( QwtPolar::AxisAzimuth, true ); - mpSatellitesGrid->showAxis( QwtPolar::AxisLeft, false ); //alt axis - mpSatellitesGrid->showAxis( QwtPolar::AxisRight, false );//alt axis - mpSatellitesGrid->showAxis( QwtPolar::AxisTop, false );//alt axis - mpSatellitesGrid->showAxis( QwtPolar::AxisBottom, false );//alt axis + mpSatellitesGrid->showAxis( QwtPolar::AxisLeft, false ); //alt axis + mpSatellitesGrid->showAxis( QwtPolar::AxisRight, false ); //alt axis + mpSatellitesGrid->showAxis( QwtPolar::AxisTop, false ); //alt axis + mpSatellitesGrid->showAxis( QwtPolar::AxisBottom, false ); //alt axis mpSatellitesGrid->showGrid( QwtPolar::ScaleAzimuth, false ); // hide the grid; just show ticks at edge mpSatellitesGrid->showGrid( QwtPolar::ScaleRadius, true ); -// mpSatellitesGrid->showMinorGrid( QwtPolar::ScaleAzimuth, true ); - mpSatellitesGrid->showMinorGrid( QwtPolar::ScaleRadius, true ); // for 22.5, 67.5 degree circles + // mpSatellitesGrid->showMinorGrid( QwtPolar::ScaleAzimuth, true ); + mpSatellitesGrid->showMinorGrid( QwtPolar::ScaleRadius, true ); // for 22.5, 67.5 degree circles mpSatellitesGrid->attach( mpSatellitesWidget ); //QwtLegend *legend = new QwtLegend; @@ -173,7 +172,7 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsAppGpsConnection *connectio // Restore state mDateTimeFormat = mySettings.value( QStringLiteral( "dateTimeFormat" ), "", QgsSettings::Gps ).toString(); // zero-length string signifies default format - mBtnDebug->setVisible( mySettings.value( QStringLiteral( "showDebug" ), "false", QgsSettings::Gps ).toBool() ); // use a registry setting to control - power users/devs could set it + mBtnDebug->setVisible( mySettings.value( QStringLiteral( "showDebug" ), "false", QgsSettings::Gps ).toBool() ); // use a registry setting to control - power users/devs could set it // status = unknown setStatusIndicator( Qgis::GpsFixStatus::NoData ); @@ -188,8 +187,7 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsAppGpsConnection *connectio connect( mConnection, &QgsAppGpsConnection::stateChanged, this, &QgsGpsInformationWidget::displayGPSInformation ); connect( mConnection, &QgsAppGpsConnection::fixStatusChanged, this, &QgsGpsInformationWidget::setStatusIndicator ); - connect( mConnection, &QgsAppGpsConnection::statusChanged, this, [ = ]( Qgis::DeviceConnectionStatus status ) - { + connect( mConnection, &QgsAppGpsConnection::statusChanged, this, [=]( Qgis::DeviceConnectionStatus status ) { switch ( status ) { case Qgis::DeviceConnectionStatus::Disconnected: @@ -405,11 +403,11 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in QColor myColor; // Add a marker to the polar plot - if ( currentInfo.id > 0 ) // don't show satellite if id=0 (no satellite indication) + if ( currentInfo.id > 0 ) // don't show satellite if id=0 (no satellite indication) { #ifdef WITH_QWTPOLAR QwtPolarMarker *mypMarker = new QwtPolarMarker(); -#if (QWT_POLAR_VERSION<0x010000) +#if ( QWT_POLAR_VERSION < 0x010000 ) mypMarker->setPosition( QwtPolarPoint( currentInfo.azimuth, currentInfo.elevation ) ); #else mypMarker->setPosition( QwtPointPolar( currentInfo.azimuth, currentInfo.elevation ) ); @@ -427,12 +425,10 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in QBrush symbolBrush( Qt::black ); QSize markerSize( 9, 9 ); QBrush textBgBrush( bg ); -#if (QWT_POLAR_VERSION<0x010000) - mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse, - symbolBrush, QPen( myColor ), markerSize ) ); +#if ( QWT_POLAR_VERSION < 0x010000 ) + mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse, symbolBrush, QPen( myColor ), markerSize ) ); #else - mypMarker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, - symbolBrush, QPen( myColor ), markerSize ) ); + mypMarker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, symbolBrush, QPen( myColor ), markerSize ) ); #endif mypMarker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop ); @@ -474,8 +470,7 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in { QString formattedX; QString formattedY; - QgsCoordinateUtils::formatCoordinatePartsForProject( QgsProject::instance(), QgsPointXY( info.longitude, info.latitude ), - QgsCoordinateReferenceSystem(), 8, formattedX, formattedY ); + QgsCoordinateUtils::formatCoordinatePartsForProject( QgsProject::instance(), QgsPointXY( info.longitude, info.latitude ), QgsCoordinateReferenceSystem(), 8, formattedX, formattedY ); mTxtLatitude->setText( formattedY ); mTxtLongitude->setText( formattedX ); @@ -486,11 +481,11 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in if ( mDateTimeFormat.isEmpty() ) { - mTxtDateTime->setText( info.utcDateTime.toString( Qt::TextDate ) ); // default format + mTxtDateTime->setText( info.utcDateTime.toString( Qt::TextDate ) ); // default format } else { - mTxtDateTime->setText( info.utcDateTime.toString( mDateTimeFormat ) ); //user specified format string for testing the millisecond part of time + mTxtDateTime->setText( info.utcDateTime.toString( mDateTimeFormat ) ); //user specified format string for testing the millisecond part of time } if ( std::isfinite( info.speed ) ) { @@ -545,11 +540,15 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in mTxt3Dacc->setEnabled( false ); mTxt3Dacc->setText( tr( "Not available" ) ); } - mTxtFixMode->setText( info.fixMode == 'A' ? tr( "Automatic" ) : info.fixMode == 'M' ? tr( "Manual" ) : QString() ); // A=automatic 2d/3d, M=manual; allowing for anything else - mTxtFixType->setText( info.fixType == 3 ? tr( "3D" ) : info.fixType == 2 ? tr( "2D" ) : info.fixType == 1 ? tr( "No fix" ) : QString::number( info.fixType ) ); // 1=no fix, 2=2D, 3=3D; allowing for anything else + mTxtFixMode->setText( info.fixMode == 'A' ? tr( "Automatic" ) : info.fixMode == 'M' ? tr( "Manual" ) + : QString() ); // A=automatic 2d/3d, M=manual; allowing for anything else + mTxtFixType->setText( info.fixType == 3 ? tr( "3D" ) : info.fixType == 2 ? tr( "2D" ) + : info.fixType == 1 ? tr( "No fix" ) + : QString::number( info.fixType ) ); // 1=no fix, 2=2D, 3=3D; allowing for anything else mTxtQuality->setText( info.qualityDescription() ); mTxtSatellitesUsed->setText( tr( "%1 used (%2 in view)" ).arg( info.satellitesUsed ).arg( info.satellitesInView.size() ) ); - mTxtStatus->setText( info.status == 'A' ? tr( "Valid" ) : info.status == 'V' ? tr( "Invalid" ) : QString() ); + mTxtStatus->setText( info.status == 'A' ? tr( "Valid" ) : info.status == 'V' ? tr( "Invalid" ) + : QString() ); } if ( mLastGpsPosition != myNewCenter ) diff --git a/src/app/gps/qgsgpsinformationwidget.h b/src/app/gps/qgsgpsinformationwidget.h index 8276f52a08ad..cb0b0bff60b6 100644 --- a/src/app/gps/qgsgpsinformationwidget.h +++ b/src/app/gps/qgsgpsinformationwidget.h @@ -43,11 +43,10 @@ class QgsAppGpsDigitizing; * allows the user to capture features using gps readings to * specify the geometry. */ -class APP_EXPORT QgsGpsInformationWidget: public QgsPanelWidget, private Ui::QgsGpsInformationWidgetBase +class APP_EXPORT QgsGpsInformationWidget : public QgsPanelWidget, private Ui::QgsGpsInformationWidgetBase { Q_OBJECT public: - QgsGpsInformationWidget( QgsAppGpsConnection *connection, QgsMapCanvas *mapCanvas, QgsAppGpsDigitizing *digitizing = nullptr, QWidget *parent = nullptr ); ~QgsGpsInformationWidget() override; @@ -68,12 +67,11 @@ class APP_EXPORT QgsGpsInformationWidget: public QgsPanelWidget, private Ui::Qgs void updateTrackInformation(); private: - void setStatusIndicator( Qgis::GpsFixStatus statusValue ); void showStatusBarMessage( const QString &msg ); QgsAppGpsConnection *mConnection = nullptr; - QPointer< QgsMapCanvas > mMapCanvas; + QPointer mMapCanvas; QgsAppGpsDigitizing *mDigitizing = nullptr; QwtPlot *mPlot = nullptr; @@ -81,7 +79,7 @@ class APP_EXPORT QgsGpsInformationWidget: public QgsPanelWidget, private Ui::Qgs #ifdef WITH_QWTPOLAR QwtPolarPlot *mpSatellitesWidget = nullptr; QwtPolarGrid *mpSatellitesGrid = nullptr; - QList< QwtPolarMarker * > mMarkerList; + QList mMarkerList; #endif QgsPointXY mLastGpsPosition; diff --git a/src/app/gps/qgsgpsmarker.cpp b/src/app/gps/qgsgpsmarker.cpp index c0e41c341e67..08181757f8ad 100644 --- a/src/app/gps/qgsgpsmarker.cpp +++ b/src/app/gps/qgsgpsmarker.cpp @@ -76,8 +76,8 @@ void QgsGpsMarker::setGpsPosition( const QgsPointXY &point ) void QgsGpsMarker::setMarkerRotation( double rotation ) { - QgsMarkerSymbol *renderedMarker = qgis::down_cast< QgsMarkerSymbol *>( symbol() ); - if ( !settingRotateLocationMarker->value( ) ) + QgsMarkerSymbol *renderedMarker = qgis::down_cast( symbol() ); + if ( !settingRotateLocationMarker->value() ) { renderedMarker->setAngle( mMarkerSymbol->angle() ); } @@ -95,6 +95,6 @@ void QgsGpsMarker::updateMarkerSymbol() symbolDoc.setContent( defaultSymbol ); const QDomElement markerElement = symbolDoc.documentElement(); mMarkerSymbol.reset( QgsSymbolLayerUtils::loadSymbol( markerElement, QgsReadWriteContext() ) ); - setSymbol( std::unique_ptr< QgsMarkerSymbol >( mMarkerSymbol->clone() ) ); + setSymbol( std::unique_ptr( mMarkerSymbol->clone() ) ); updateSize(); } diff --git a/src/app/gps/qgsgpsmarker.h b/src/app/gps/qgsgpsmarker.h index 57a2a36c26a9..f8e5ee33bd5c 100644 --- a/src/app/gps/qgsgpsmarker.h +++ b/src/app/gps/qgsgpsmarker.h @@ -39,7 +39,6 @@ class QgsGpsMarker : public QObject, public QgsMapCanvasMarkerSymbolItem Q_OBJECT public: - static const QgsSettingsEntryString *settingLocationMarkerSymbol; static const QgsSettingsEntryBool *settingShowLocationMarker; static const QgsSettingsEntryBool *settingRotateLocationMarker; @@ -58,7 +57,6 @@ class QgsGpsMarker : public QObject, public QgsMapCanvasMarkerSymbolItem void setMarkerRotation( double rotation ); protected: - //! Coordinates of the point in the center, in map CRS QgsPointXY mCenter; @@ -69,8 +67,7 @@ class QgsGpsMarker : public QObject, public QgsMapCanvasMarkerSymbolItem private: QgsCoordinateReferenceSystem mWgs84CRS; - std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol; - + std::unique_ptr mMarkerSymbol; }; #endif diff --git a/src/app/gps/qgsgpstoolbar.cpp b/src/app/gps/qgsgpstoolbar.cpp index d6880fd3a1fe..742a7f774c95 100644 --- a/src/app/gps/qgsgpstoolbar.cpp +++ b/src/app/gps/qgsgpstoolbar.cpp @@ -56,8 +56,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can mConnectAction->setCheckable( true ); addAction( mConnectAction ); - connect( mConnectAction, &QAction::toggled, this, [ = ]( bool connect ) - { + connect( mConnectAction, &QAction::toggled, this, [=]( bool connect ) { if ( connect ) mConnection->connectGps(); else @@ -69,8 +68,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can mRecenterAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/gpsicons/mActionRecenter.svg" ) ) ); mRecenterAction->setEnabled( false ); - connect( mRecenterAction, &QAction::triggered, this, [ = ] - { + connect( mRecenterAction, &QAction::triggered, this, [=] { if ( mConnection->lastValidLocation().isEmpty() ) return; @@ -83,7 +81,6 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can } catch ( QgsCsException & ) { - } } ); addAction( mRecenterAction ); @@ -146,8 +143,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can mCreateFeatureAction->setEnabled( false ); mAddTrackVertexAction->setEnabled( false ); mResetFeatureAction->setEnabled( false ); - connect( mConnection, &QgsAppGpsConnection::statusChanged, this, [ = ]( Qgis::DeviceConnectionStatus status ) - { + connect( mConnection, &QgsAppGpsConnection::statusChanged, this, [=]( Qgis::DeviceConnectionStatus status ) { switch ( status ) { case Qgis::DeviceConnectionStatus::Disconnected: @@ -180,17 +176,16 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can mConnectAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/gpsicons/mIconGpsDisconnect.svg" ) ) ); mConnectAction->setEnabled( true ); mRecenterAction->setEnabled( true ); - mCreateFeatureAction->setEnabled( static_cast< bool >( QgsProject::instance()->gpsSettings()->destinationLayer() ) ); + mCreateFeatureAction->setEnabled( static_cast( QgsProject::instance()->gpsSettings()->destinationLayer() ) ); mAddTrackVertexAction->setEnabled( mEnableAddVertexButton ); break; } adjustSize(); } ); - connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::destinationLayerChanged, - this, &QgsGpsToolBar::destinationLayerChanged ); + connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::destinationLayerChanged, this, &QgsGpsToolBar::destinationLayerChanged ); - connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::automaticallyAddTrackVerticesChanged, this, [ = ]( bool enabled ) { setAddVertexButtonEnabled( !enabled ); } ); + connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::automaticallyAddTrackVerticesChanged, this, [=]( bool enabled ) { setAddVertexButtonEnabled( !enabled ); } ); setAddVertexButtonEnabled( !QgsProject::instance()->gpsSettings()->automaticallyAddTrackVertices() ); adjustSize(); @@ -256,13 +251,13 @@ void QgsGpsToolBar::updateLocationLabel() break; case Qgis::GpsInformationComponent::Altitude: case Qgis::GpsInformationComponent::EllipsoidAltitude: - parts << tr( "%1 m" ).arg( value.toDouble( ) ); + parts << tr( "%1 m" ).arg( value.toDouble() ); break; case Qgis::GpsInformationComponent::GroundSpeed: - parts << tr( "%1 km/h" ).arg( value.toDouble( ) ); + parts << tr( "%1 km/h" ).arg( value.toDouble() ); break; case Qgis::GpsInformationComponent::Bearing: - parts << QString::number( value.toDouble( ) ) + QChar( 176 ); + parts << QString::number( value.toDouble() ) + QChar( 176 ); break; case Qgis::GpsInformationComponent::TotalTrackLength: @@ -271,8 +266,8 @@ void QgsGpsToolBar::updateLocationLabel() if ( mDigitizing ) { const double measurement = component == Qgis::GpsInformationComponent::TotalTrackLength - ? mDigitizing->totalTrackLength() - : mDigitizing->trackDistanceFromStart(); + ? mDigitizing->totalTrackLength() + : mDigitizing->trackDistanceFromStart(); const QgsSettings settings; const bool keepBaseUnit = settings.value( QStringLiteral( "qgis/measure/keepbaseunit" ), true ).toBool(); @@ -358,7 +353,8 @@ void QgsGpsToolBar::destinationLayerChanged( QgsVectorLayer *vlayer ) QString buttonLabel = tr( "Create Feature" ); QString buttonToolTip = tr( "Create Feature" ); - QString icon = QStringLiteral( "mActionCaptureLine.svg" );; + QString icon = QStringLiteral( "mActionCaptureLine.svg" ); + ; if ( vlayer ) { const Qgis::GeometryType layerGeometryType = vlayer->geometryType(); @@ -405,16 +401,14 @@ void QgsGpsToolBar::destinationMenuAboutToShow() { mDestinationLayerMenu->clear(); - const QString currentLayerId = QgsProject::instance()->gpsSettings()->destinationLayer() ? - QgsProject::instance()->gpsSettings()->destinationLayer()->id() : QString(); + const QString currentLayerId = QgsProject::instance()->gpsSettings()->destinationLayer() ? QgsProject::instance()->gpsSettings()->destinationLayer()->id() : QString(); QAction *followAction = new QAction( tr( "Follow Active Layer" ), mDestinationLayerMenu ); followAction->setToolTip( tr( "Always add GPS digitized features to the active layer" ) ); followAction->setCheckable( true ); followAction->setChecked( QgsProject::instance()->gpsSettings()->destinationFollowsActiveLayer() ); - connect( followAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( followAction, &QAction::toggled, this, [=]( bool checked ) { if ( checked && !QgsProject::instance()->gpsSettings()->destinationFollowsActiveLayer() ) { QgsProject::instance()->gpsSettings()->setDestinationFollowsActiveLayer( true ); @@ -429,19 +423,18 @@ void QgsGpsToolBar::destinationMenuAboutToShow() QAction *layerAction = new QAction( index.data( Qt::DisplayRole ).toString(), mDestinationLayerMenu ); layerAction->setToolTip( index.data( Qt::ToolTipRole ).toString() ); - layerAction->setIcon( index.data( Qt::DecorationRole ).value< QIcon >() ); + layerAction->setIcon( index.data( Qt::DecorationRole ).value() ); layerAction->setCheckable( true ); - const QString actionLayerId = index.data( static_cast< int >( QgsMapLayerModel::CustomRole::LayerId ) ).toString(); + const QString actionLayerId = index.data( static_cast( QgsMapLayerModel::CustomRole::LayerId ) ).toString(); if ( actionLayerId == currentLayerId && !QgsProject::instance()->gpsSettings()->destinationFollowsActiveLayer() ) layerAction->setChecked( true ); - connect( layerAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( layerAction, &QAction::toggled, this, [=]( bool checked ) { if ( checked ) { - QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( QgsProject::instance()->mapLayer( actionLayerId ) ); + QgsVectorLayer *layer = qobject_cast( QgsProject::instance()->mapLayer( actionLayerId ) ); if ( layer != QgsProject::instance()->gpsSettings()->destinationLayer() ) { QgsProject::instance()->gpsSettings()->setDestinationFollowsActiveLayer( false ); @@ -464,17 +457,16 @@ void QgsGpsToolBar::createLocationWidget() const Qgis::GpsInformationComponents visibleComponents = settingShowInToolbar->value(); - for ( const auto &it : std::vector< std::pair< Qgis::GpsInformationComponent, QString> > -{ - { Qgis::GpsInformationComponent::Location, tr( "Show Location" ) }, - { Qgis::GpsInformationComponent::Altitude, tr( "Show Altitude (Geoid)" ) }, - { Qgis::GpsInformationComponent::EllipsoidAltitude, tr( "Show Altitude (WGS-84 Ellipsoid)" ) }, - { Qgis::GpsInformationComponent::GroundSpeed, tr( "Show Ground Speed" ) }, - { Qgis::GpsInformationComponent::Bearing, tr( "Show Bearing" ) }, - { Qgis::GpsInformationComponent::TotalTrackLength, tr( "Show Total Track Length" ) }, - { Qgis::GpsInformationComponent::TrackDistanceFromStart, tr( "Show Distance from Start of Track" ) } - - } ) + for ( const auto &it : std::vector> { + { Qgis::GpsInformationComponent::Location, tr( "Show Location" ) }, + { Qgis::GpsInformationComponent::Altitude, tr( "Show Altitude (Geoid)" ) }, + { Qgis::GpsInformationComponent::EllipsoidAltitude, tr( "Show Altitude (WGS-84 Ellipsoid)" ) }, + { Qgis::GpsInformationComponent::GroundSpeed, tr( "Show Ground Speed" ) }, + { Qgis::GpsInformationComponent::Bearing, tr( "Show Bearing" ) }, + { Qgis::GpsInformationComponent::TotalTrackLength, tr( "Show Total Track Length" ) }, + { Qgis::GpsInformationComponent::TrackDistanceFromStart, tr( "Show Distance from Start of Track" ) } + + } ) { const Qgis::GpsInformationComponent component = it.first; QAction *showComponentAction = new QAction( it.second, locationMenu ); @@ -483,8 +475,7 @@ void QgsGpsToolBar::createLocationWidget() showComponentAction->setChecked( visibleComponents & component ); locationMenu->addAction( showComponentAction ); - connect( showComponentAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( showComponentAction, &QAction::toggled, this, [=]( bool checked ) { const Qgis::GpsInformationComponents currentVisibleComponents = settingShowInToolbar->value(); if ( checked ) { @@ -492,7 +483,7 @@ void QgsGpsToolBar::createLocationWidget() } else { - settingShowInToolbar->setValue( currentVisibleComponents & ~( static_cast< int >( component ) ) ); + settingShowInToolbar->setValue( currentVisibleComponents & ~( static_cast( component ) ) ); } updateLocationLabel(); } ); @@ -513,4 +504,3 @@ void QgsGpsToolBar::adjustSize() else setFixedWidth( QWIDGETSIZE_MAX ); } - diff --git a/src/app/gps/qgsgpstoolbar.h b/src/app/gps/qgsgpstoolbar.h index 178ca5922984..5f606409ddfb 100644 --- a/src/app/gps/qgsgpstoolbar.h +++ b/src/app/gps/qgsgpstoolbar.h @@ -38,7 +38,6 @@ class QgsGpsToolBar : public QToolBar Q_OBJECT public: - static const QgsSettingsEntryEnumFlag *settingShowInToolbar; QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *canvas, QWidget *parent = nullptr ); @@ -65,13 +64,12 @@ class QgsGpsToolBar : public QToolBar void destinationMenuAboutToShow(); private: - void createLocationWidget(); void adjustSize(); QgsAppGpsConnection *mConnection = nullptr; QgsMapCanvas *mCanvas = nullptr; - QPointer< QgsAppGpsDigitizing > mDigitizing; + QPointer mDigitizing; QAction *mConnectAction = nullptr; QAction *mRecenterAction = nullptr; @@ -85,7 +83,7 @@ class QgsGpsToolBar : public QToolBar QMenu *mDestinationLayerMenu = nullptr; - QPointer< QToolButton > mInformationButton; + QPointer mInformationButton; QgsCoordinateReferenceSystem mWgs84CRS; bool mEnableAddVertexButton = true; diff --git a/src/app/labeling/qgslabelpropertydialog.cpp b/src/app/labeling/qgslabelpropertydialog.cpp index 7a9456925b4a..af1d5fcccbc0 100644 --- a/src/app/labeling/qgslabelpropertydialog.cpp +++ b/src/app/labeling/qgslabelpropertydialog.cpp @@ -56,18 +56,18 @@ QgsLabelPropertyDialog::QgsLabelPropertyDialog( const QString &layerId, const QS connect( mAlwaysShowChkbx, &QCheckBox::toggled, this, &QgsLabelPropertyDialog::mAlwaysShowChkbx_toggled ); connect( mShowCalloutChkbx, &QCheckBox::toggled, this, &QgsLabelPropertyDialog::showCalloutToggled ); connect( mBufferDrawChkbx, &QCheckBox::toggled, this, &QgsLabelPropertyDialog::bufferDrawToggled ); - connect( mLabelDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mLabelDistanceSpinBox_valueChanged ); - connect( mXCoordSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mXCoordSpinBox_valueChanged ); - connect( mYCoordSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mYCoordSpinBox_valueChanged ); + connect( mLabelDistanceSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mLabelDistanceSpinBox_valueChanged ); + connect( mXCoordSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mXCoordSpinBox_valueChanged ); + connect( mYCoordSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mYCoordSpinBox_valueChanged ); connect( mFontFamilyCmbBx, &QFontComboBox::currentFontChanged, this, &QgsLabelPropertyDialog::mFontFamilyCmbBx_currentFontChanged ); connect( mFontStyleCmbBx, &QComboBox::currentTextChanged, this, &QgsLabelPropertyDialog::mFontStyleCmbBx_currentIndexChanged ); connect( mFontUnderlineBtn, &QToolButton::toggled, this, &QgsLabelPropertyDialog::mFontUnderlineBtn_toggled ); connect( mFontStrikethroughBtn, &QToolButton::toggled, this, &QgsLabelPropertyDialog::mFontStrikethroughBtn_toggled ); connect( mFontBoldBtn, &QToolButton::toggled, this, &QgsLabelPropertyDialog::mFontBoldBtn_toggled ); connect( mFontItalicBtn, &QToolButton::toggled, this, &QgsLabelPropertyDialog::mFontItalicBtn_toggled ); - connect( mFontSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mFontSizeSpinBox_valueChanged ); - connect( mBufferSizeSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mBufferSizeSpinBox_valueChanged ); - connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mRotationSpinBox_valueChanged ); + connect( mFontSizeSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mFontSizeSpinBox_valueChanged ); + connect( mBufferSizeSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mBufferSizeSpinBox_valueChanged ); + connect( mRotationSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsLabelPropertyDialog::mRotationSpinBox_valueChanged ); connect( mFontColorButton, &QgsColorButton::colorChanged, this, &QgsLabelPropertyDialog::mFontColorButton_colorChanged ); connect( mBufferColorButton, &QgsColorButton::colorChanged, this, &QgsLabelPropertyDialog::mBufferColorButton_colorChanged ); connect( mMultiLineAlignComboBox, static_cast( &QComboBox::currentIndexChanged ), this, &QgsLabelPropertyDialog::mMultiLineAlignComboBox_currentIndexChanged ); @@ -106,7 +106,7 @@ void QgsLabelPropertyDialog::buttonBox_clicked( QAbstractButton *button ) void QgsLabelPropertyDialog::init( const QString &layerId, const QString &providerId, QgsFeatureId featureId, const QString &labelText ) { //get feature attributes - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( mCanvas->layer( layerId ) ); + QgsVectorLayer *vlayer = qobject_cast( mCanvas->layer( layerId ) ); if ( !vlayer ) { return; @@ -380,7 +380,7 @@ void QgsLabelPropertyDialog::setDataDefinedValues( QgsVectorLayer *vlayer ) } bool ok = false; - switch ( static_cast< QgsPalLayerSettings::Property>( key ) ) + switch ( static_cast( key ) ) { case QgsPalLayerSettings::Property::Show: { @@ -520,12 +520,12 @@ void QgsLabelPropertyDialog::enableDataDefinedWidgets( QgsVectorLayer *vlayer ) continue; } - const int ddIndex = dataDefinedColumnIndex( static_cast< QgsPalLayerSettings::Property >( key ), vlayer, context ); - mPropertyToFieldMap[ key ] = ddIndex; + const int ddIndex = dataDefinedColumnIndex( static_cast( key ), vlayer, context ); + mPropertyToFieldMap[key] = ddIndex; if ( ddIndex < 0 ) continue; // can only modify attributes with an active data definition of a mapped field - switch ( static_cast< QgsPalLayerSettings::Property >( key ) ) + switch ( static_cast( key ) ) { case QgsPalLayerSettings::Property::Show: mShowLabelChkbx->setEnabled( true ); @@ -857,7 +857,7 @@ void QgsLabelPropertyDialog::insertChangedValue( QgsPalLayerSettings::Property p if ( mDataDefinedProperties.isActive( p ) ) { const QgsProperty prop = mDataDefinedProperties.property( p ); - if ( const int index = mPropertyToFieldMap.value( static_cast< int >( p ) ); index >= 0 ) + if ( const int index = mPropertyToFieldMap.value( static_cast( p ) ); index >= 0 ) { mChangedProperties.insert( index, value ); } @@ -866,8 +866,7 @@ void QgsLabelPropertyDialog::insertChangedValue( QgsPalLayerSettings::Property p void QgsLabelPropertyDialog::enableWidgetsForPinnedLabels() { - const bool pinned = mXCoordSpinBox->value() >= ( mXCoordSpinBox->minimum() + mXCoordSpinBox->singleStep() ) && - mYCoordSpinBox->value() >= ( mYCoordSpinBox->minimum() + mYCoordSpinBox->singleStep() ); + const bool pinned = mXCoordSpinBox->value() >= ( mXCoordSpinBox->minimum() + mXCoordSpinBox->singleStep() ) && mYCoordSpinBox->value() >= ( mYCoordSpinBox->minimum() + mYCoordSpinBox->singleStep() ); mHaliComboBox->setEnabled( pinned && mCanSetHAlignment ); mValiComboBox->setEnabled( pinned && mCanSetVAlignment ); diff --git a/src/app/labeling/qgslabelpropertydialog.h b/src/app/labeling/qgslabelpropertydialog.h index bf3d0fa7b88b..67e9d2c9251f 100644 --- a/src/app/labeling/qgslabelpropertydialog.h +++ b/src/app/labeling/qgslabelpropertydialog.h @@ -26,20 +26,11 @@ //! A dialog to enter data defined label attributes -class APP_EXPORT QgsLabelPropertyDialog: public QDialog, private Ui::QgsLabelPropertyDialogBase +class APP_EXPORT QgsLabelPropertyDialog : public QDialog, private Ui::QgsLabelPropertyDialogBase { Q_OBJECT public: - QgsLabelPropertyDialog( const QString &layerId, - const QString &providerId, - QgsFeatureId featureId, - const QFont &labelFont, - const QString &labelText, - bool isPinned, - const QgsPalLayerSettings &layerSettings, - QgsMapCanvas *canvas, - QWidget *parent = nullptr, - Qt::WindowFlags f = Qt::WindowFlags() ); + QgsLabelPropertyDialog( const QString &layerId, const QString &providerId, QgsFeatureId featureId, const QFont &labelFont, const QString &labelText, bool isPinned, const QgsPalLayerSettings &layerSettings, QgsMapCanvas *canvas, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); //! Returns properties changed by the user const QgsAttributeMap &changedProperties() const { return mChangedProperties; } @@ -113,7 +104,7 @@ class APP_EXPORT QgsLabelPropertyDialog: public QDialog, private Ui::QgsLabelPro QgsAttributeMap mChangedProperties; QgsPropertyCollection mDataDefinedProperties; - QMap< int, int > mPropertyToFieldMap; + QMap mPropertyToFieldMap; QFont mLabelFont; QFontDatabase mFontDB; diff --git a/src/app/labeling/qgsmaptoolchangelabelproperties.cpp b/src/app/labeling/qgsmaptoolchangelabelproperties.cpp index 5f7f220694f6..5f3055ee6e5d 100644 --- a/src/app/labeling/qgsmaptoolchangelabelproperties.cpp +++ b/src/app/labeling/qgsmaptoolchangelabelproperties.cpp @@ -105,15 +105,7 @@ void QgsMapToolChangeLabelProperties::canvasReleaseEvent( QgsMapMouseEvent *e ) labeltext = mCurrentLabel.pos.labelText; } - QgsLabelPropertyDialog d( mCurrentLabel.pos.layerID, - mCurrentLabel.pos.providerID, - mCurrentLabel.pos.featureId, - mCurrentLabel.pos.labelFont, - labeltext, - mCurrentLabel.pos.isPinned, - mCurrentLabel.settings, - mCanvas, - nullptr ); + QgsLabelPropertyDialog d( mCurrentLabel.pos.layerID, mCurrentLabel.pos.providerID, mCurrentLabel.pos.featureId, mCurrentLabel.pos.labelFont, labeltext, mCurrentLabel.pos.isPinned, mCurrentLabel.settings, mCanvas, nullptr ); d.setMapCanvas( canvas() ); connect( &d, &QgsLabelPropertyDialog::applied, this, &QgsMapToolChangeLabelProperties::dialogPropertiesApplied ); @@ -185,4 +177,3 @@ void QgsMapToolChangeLabelProperties::dialogPropertiesApplied() applyChanges( dlg->changedProperties() ); } - diff --git a/src/app/labeling/qgsmaptoolchangelabelproperties.h b/src/app/labeling/qgsmaptoolchangelabelproperties.h index e102fe8bbacd..11ebb896182c 100644 --- a/src/app/labeling/qgsmaptoolchangelabelproperties.h +++ b/src/app/labeling/qgsmaptoolchangelabelproperties.h @@ -21,7 +21,7 @@ #include "qgsmaptoollabel.h" #include "qgis_app.h" -class APP_EXPORT QgsMapToolChangeLabelProperties: public QgsMapToolLabel +class APP_EXPORT QgsMapToolChangeLabelProperties : public QgsMapToolLabel { Q_OBJECT @@ -33,7 +33,6 @@ class APP_EXPORT QgsMapToolChangeLabelProperties: public QgsMapToolLabel void cadCanvasMoveEvent( QgsMapMouseEvent *e ) override; protected: - /** * Applies the label property changes * \param changes attribute map of changes @@ -43,7 +42,6 @@ class APP_EXPORT QgsMapToolChangeLabelProperties: public QgsMapToolLabel private slots: void dialogPropertiesApplied(); - }; #endif // QGSMAPTOOLCHANGELABEL_H diff --git a/src/app/labeling/qgsmaptoollabel.cpp b/src/app/labeling/qgsmaptoollabel.cpp index 87777632fd34..445b92cab600 100644 --- a/src/app/labeling/qgsmaptoollabel.cpp +++ b/src/app/labeling/qgsmaptoollabel.cpp @@ -68,41 +68,41 @@ bool QgsMapToolLabel::labelAtPosition( QMouseEvent *e, QgsLabelPosition &p ) return false; QList labelPosList = labelingResults->labelsAtPosition( pt ); - labelPosList.erase( std::remove_if( labelPosList.begin(), labelPosList.end(), [this]( const QgsLabelPosition & position ) - { - if ( position.layerID.isEmpty() ) - return true; - - if ( QgsMapLayer *layer = QgsMapTool::layer( position.layerID ) ) - { - // strip out any labels from non vector layers (e.g. those from vector tile layers). Only vector layer labels - // are supported by the map tools. - switch ( layer->type() ) - { - case Qgis::LayerType::Vector: - return false; - - case Qgis::LayerType::Raster: - case Qgis::LayerType::Plugin: - case Qgis::LayerType::Mesh: - case Qgis::LayerType::VectorTile: - case Qgis::LayerType::Annotation: - case Qgis::LayerType::PointCloud: - case Qgis::LayerType::Group: - case Qgis::LayerType::TiledScene: - return true; - } - } - - return true; - } ), labelPosList.end() ); + labelPosList.erase( std::remove_if( labelPosList.begin(), labelPosList.end(), [this]( const QgsLabelPosition &position ) { + if ( position.layerID.isEmpty() ) + return true; + + if ( QgsMapLayer *layer = QgsMapTool::layer( position.layerID ) ) + { + // strip out any labels from non vector layers (e.g. those from vector tile layers). Only vector layer labels + // are supported by the map tools. + switch ( layer->type() ) + { + case Qgis::LayerType::Vector: + return false; + + case Qgis::LayerType::Raster: + case Qgis::LayerType::Plugin: + case Qgis::LayerType::Mesh: + case Qgis::LayerType::VectorTile: + case Qgis::LayerType::Annotation: + case Qgis::LayerType::PointCloud: + case Qgis::LayerType::Group: + case Qgis::LayerType::TiledScene: + return true; + } + } + + return true; + } ), + labelPosList.end() ); if ( labelPosList.empty() ) return false; // prioritize labels in the current selected layer, in case of overlaps QList activeLayerLabels; - if ( const QgsVectorLayer *currentLayer = qobject_cast< QgsVectorLayer * >( mCanvas->currentLayer() ) ) + if ( const QgsVectorLayer *currentLayer = qobject_cast( mCanvas->currentLayer() ) ) { for ( const QgsLabelPosition &pos : std::as_const( labelPosList ) ) { @@ -130,7 +130,7 @@ bool QgsMapToolLabel::labelAtPosition( QMouseEvent *e, QgsLabelPosition &p ) if ( labelPosList.count() > 1 ) { // multiple candidates found, so choose the smallest (i.e. most difficult to select otherwise) - double minSize = std::numeric_limits< double >::max(); + double minSize = std::numeric_limits::max(); for ( const QgsLabelPosition &pos : std::as_const( labelPosList ) ) { const double labelSize = pos.width * pos.height; @@ -160,40 +160,40 @@ bool QgsMapToolLabel::calloutAtPosition( QMouseEvent *e, QgsCalloutPosition &p, const double tol = QgsTolerance::vertexSearchRadius( canvas()->mapSettings() ); QList calloutPosList = labelingResults->calloutsWithinRectangle( QgsRectangle::fromCenterAndSize( pt, tol * 2, tol * 2 ) ); - calloutPosList.erase( std::remove_if( calloutPosList.begin(), calloutPosList.end(), [ this ]( const QgsCalloutPosition & position ) - { - if ( position.layerID.isEmpty() ) - return true; - - if ( QgsMapLayer *layer = QgsMapTool::layer( position.layerID ) ) - { - // strip out any callouts from non vector layers (e.g. those from vector tile layers). Only vector layer callouts - // are supported by the map tools. - switch ( layer->type() ) - { - case Qgis::LayerType::Vector: - return false; - - case Qgis::LayerType::Raster: - case Qgis::LayerType::Plugin: - case Qgis::LayerType::Mesh: - case Qgis::LayerType::VectorTile: - case Qgis::LayerType::Annotation: - case Qgis::LayerType::PointCloud: - case Qgis::LayerType::Group: - case Qgis::LayerType::TiledScene: - return true; - } - } - - return true; - } ), calloutPosList.end() ); + calloutPosList.erase( std::remove_if( calloutPosList.begin(), calloutPosList.end(), [this]( const QgsCalloutPosition &position ) { + if ( position.layerID.isEmpty() ) + return true; + + if ( QgsMapLayer *layer = QgsMapTool::layer( position.layerID ) ) + { + // strip out any callouts from non vector layers (e.g. those from vector tile layers). Only vector layer callouts + // are supported by the map tools. + switch ( layer->type() ) + { + case Qgis::LayerType::Vector: + return false; + + case Qgis::LayerType::Raster: + case Qgis::LayerType::Plugin: + case Qgis::LayerType::Mesh: + case Qgis::LayerType::VectorTile: + case Qgis::LayerType::Annotation: + case Qgis::LayerType::PointCloud: + case Qgis::LayerType::Group: + case Qgis::LayerType::TiledScene: + return true; + } + } + + return true; + } ), + calloutPosList.end() ); if ( calloutPosList.empty() ) return false; // prioritize callouts in the current selected layer, in case of overlaps QList activeLayerCallouts; - if ( const QgsVectorLayer *currentLayer = qobject_cast< QgsVectorLayer * >( mCanvas->currentLayer() ) ) + if ( const QgsVectorLayer *currentLayer = qobject_cast( mCanvas->currentLayer() ) ) { for ( const QgsCalloutPosition &pos : std::as_const( calloutPosList ) ) { @@ -362,8 +362,7 @@ QgsMapToolLabel::LabelAlignment QgsMapToolLabel::currentAlignment() } // data defined quadrant offset - if ( mCurrentLabel.settings.placement == Qgis::LabelPlacement::AroundPoint || - mCurrentLabel.settings.placement == Qgis::LabelPlacement::OverPoint ) + if ( mCurrentLabel.settings.placement == Qgis::LabelPlacement::AroundPoint || mCurrentLabel.settings.placement == Qgis::LabelPlacement::OverPoint ) { Qgis::LabelQuadrantPosition quadrantOffset = Qgis::LabelQuadrantPosition::AboveRight; @@ -374,14 +373,14 @@ QgsMapToolLabel::LabelAlignment QgsMapToolLabel::currentAlignment() // quadrant offset DD defined if ( mCurrentLabel.settings.dataDefinedProperties().isActive( QgsPalLayerSettings::Property::OffsetQuad ) ) { - QVariant exprVal = evaluateDataDefinedProperty( QgsPalLayerSettings::Property::OffsetQuad, mCurrentLabel.settings, f, static_cast< int >( quadrantOffset ) ); + QVariant exprVal = evaluateDataDefinedProperty( QgsPalLayerSettings::Property::OffsetQuad, mCurrentLabel.settings, f, static_cast( quadrantOffset ) ); if ( !QgsVariantUtils::isNull( exprVal ) ) { bool ok; int quadInt = exprVal.toInt( &ok ); if ( ok && 0 <= quadInt && quadInt <= 8 ) { - quadrantOffset = static_cast< Qgis::LabelQuadrantPosition >( quadInt ); + quadrantOffset = static_cast( quadInt ); } } } @@ -419,8 +418,7 @@ QgsMapToolLabel::LabelAlignment QgsMapToolLabel::currentAlignment() } // quadrant defined by DD alignment - if ( mCurrentLabel.settings.dataDefinedProperties().isActive( QgsPalLayerSettings::Property::Hali ) || - mCurrentLabel.settings.dataDefinedProperties().isActive( QgsPalLayerSettings::Property::Vali ) ) + if ( mCurrentLabel.settings.dataDefinedProperties().isActive( QgsPalLayerSettings::Property::Hali ) || mCurrentLabel.settings.dataDefinedProperties().isActive( QgsPalLayerSettings::Property::Vali ) ) { QString hali = QStringLiteral( "Left" ); QString vali = QStringLiteral( "Bottom" ); @@ -479,9 +477,10 @@ bool QgsMapToolLabel::currentFeature( QgsFeature &f, bool fetchGeom ) return false; } return vlayer->getFeatures( QgsFeatureRequest() - .setFilterFid( mCurrentLabel.pos.featureId ) - .setFlags( fetchGeom ? Qgis::FeatureRequestFlag::NoFlags : Qgis::FeatureRequestFlag::NoGeometry ) - ).nextFeature( f ); + .setFilterFid( mCurrentLabel.pos.featureId ) + .setFlags( fetchGeom ? Qgis::FeatureRequestFlag::NoFlags : Qgis::FeatureRequestFlag::NoGeometry ) + ) + .nextFeature( f ); } QFont QgsMapToolLabel::currentLabelFont() @@ -503,9 +502,7 @@ QFont QgsMapToolLabel::currentLabelFont() int sizeIndx = dataDefinedColumnIndex( QgsPalLayerSettings::Property::Size, mCurrentLabel.settings, vlayer ); if ( sizeIndx != -1 ) { - font.setPixelSize( QgsTextRenderer::sizeToPixel( f.attribute( sizeIndx ).toDouble(), - context, labelSettings.format().sizeUnit(), - labelSettings.format().sizeMapUnitScale() ) ); + font.setPixelSize( QgsTextRenderer::sizeToPixel( f.attribute( sizeIndx ).toDouble(), context, labelSettings.format().sizeUnit(), labelSettings.format().sizeMapUnitScale() ) ); } //family @@ -758,7 +755,6 @@ QString QgsMapToolLabel::dataDefinedColumnName( QgsPalLayerSettings::Property p, } } } - } else { @@ -829,10 +825,10 @@ bool QgsMapToolLabel::currentLabelDataDefinedPosition( double &x, bool &xSuccess && !QgsVariantUtils::isNull( attributes.at( pointCol ) ) ) { QVariant pointAsVariant = attributes.at( pointCol ); - if ( pointAsVariant.userType() == qMetaTypeId< QgsGeometry>() ) + if ( pointAsVariant.userType() == qMetaTypeId() ) { - const QgsGeometry geometry = pointAsVariant.value(); - if ( const QgsPoint *point = ( geometry.constGet() ? qgsgeometry_cast( geometry.constGet()->simplifiedTypeRef() ) : nullptr ) ) + const QgsGeometry geometry = pointAsVariant.value(); + if ( const QgsPoint *point = ( geometry.constGet() ? qgsgeometry_cast( geometry.constGet()->simplifiedTypeRef() ) : nullptr ) ) { x = point->x(); y = point->y(); @@ -855,12 +851,8 @@ bool QgsMapToolLabel::currentLabelDataDefinedPosition( double &x, bool &xSuccess return true; } -bool QgsMapToolLabel::currentLabelDataDefinedLineAnchorPercent( double &lineAnchorPercent, bool &lineAnchorPercentSuccess, int &lineAnchorPercentCol, - QString &lineAnchorClipping, bool &lineAnchorClippingSuccess, int &lineAnchorClippingCol, - QString &lineAnchorType, bool &lineAnchorTypeSuccess, int &lineAnchorTypeCol, - QString &lineAnchorTextPoint, bool &lineAnchorTextPointSuccess, int &lineAnchorTextPointCol ) const +bool QgsMapToolLabel::currentLabelDataDefinedLineAnchorPercent( double &lineAnchorPercent, bool &lineAnchorPercentSuccess, int &lineAnchorPercentCol, QString &lineAnchorClipping, bool &lineAnchorClippingSuccess, int &lineAnchorClippingCol, QString &lineAnchorType, bool &lineAnchorTypeSuccess, int &lineAnchorTypeCol, QString &lineAnchorTextPoint, bool &lineAnchorTextPointSuccess, int &lineAnchorTextPointCol ) const { - lineAnchorPercentSuccess = false; lineAnchorClippingSuccess = true; lineAnchorTypeSuccess = true; @@ -868,7 +860,7 @@ bool QgsMapToolLabel::currentLabelDataDefinedLineAnchorPercent( double &lineAnch QgsVectorLayer *vlayer = mCurrentLabel.layer; QgsFeatureId featureId = mCurrentLabel.pos.featureId; - if ( ! vlayer ) + if ( !vlayer ) { return false; } @@ -1038,7 +1030,6 @@ bool QgsMapToolLabel::changeCurrentLabelDataDefinedLineAnchorPercent( const QVar if ( !mCurrentLabel.layer->changeAttributeValue( mCurrentLabel.pos.featureId, lineAnchorTextPointCol, QStringLiteral( "start" ) ) ) return false; - } else { @@ -1063,12 +1054,12 @@ bool QgsMapToolLabel::dataDefinedShowHide( QgsVectorLayer *vlayer, QgsFeatureId if ( mCurrentLabel.pos.isDiagram ) { - if ( ! diagramCanShowHide( vlayer, showCol ) ) + if ( !diagramCanShowHide( vlayer, showCol ) ) { return false; } } - else if ( ! labelCanShowHide( vlayer, showCol ) ) + else if ( !labelCanShowHide( vlayer, showCol ) ) { return false; } @@ -1123,8 +1114,7 @@ bool QgsMapToolLabel::labelCanShowHide( QgsVectorLayer *vlayer, int &showCol ) c PropertyStatus status = PropertyStatus::DoesNotExist; for ( const QString &providerId : constSubProviders ) { - QString fieldname = dataDefinedColumnName( QgsPalLayerSettings::Property::Show, - vlayer->labeling()->settings( providerId ), vlayer, status ); + QString fieldname = dataDefinedColumnName( QgsPalLayerSettings::Property::Show, vlayer->labeling()->settings( providerId ), vlayer, status ); showCol = vlayer->fields().lookupField( fieldname ); if ( showCol != -1 ) return true; @@ -1137,7 +1127,7 @@ bool QgsMapToolLabel::isPinned() { bool rc = false; - if ( ! mCurrentLabel.pos.isDiagram ) + if ( !mCurrentLabel.pos.isDiagram ) { if ( mCurrentLabel.pos.isPinned ) { @@ -1157,8 +1147,7 @@ bool QgsMapToolLabel::isPinned() QString lineAnchorTextPoint; bool lineAnchorTextSuccess; int lineAnchorTextCol; - if ( currentLabelDataDefinedLineAnchorPercent( lineAnchor, lineAnchorSuccess, lineAnchorCol, lineAnchorClipping, lineAnchorClippingSuccess, lineAnchorClippingCol, - lineAnchorType, lineAnchorTypeSuccess, lineAnchorTypeCol, lineAnchorTextPoint, lineAnchorTextSuccess, lineAnchorTextCol ) ) + if ( currentLabelDataDefinedLineAnchorPercent( lineAnchor, lineAnchorSuccess, lineAnchorCol, lineAnchorClipping, lineAnchorClippingSuccess, lineAnchorClippingCol, lineAnchorType, lineAnchorTypeSuccess, lineAnchorTypeCol, lineAnchorTextPoint, lineAnchorTextSuccess, lineAnchorTextCol ) ) { rc = lineAnchorSuccess; } @@ -1209,11 +1198,9 @@ bool QgsMapToolLabel::labelMoveable( QgsVectorLayer *vlayer, const QgsPalLayerSe return false; } -bool QgsMapToolLabel::labelAnchorPercentMovable( QgsVectorLayer *vlayer, const QgsPalLayerSettings &settings, int &lineAnchorPercentCol, int &lineAnchorClippingCol, int &lineAnchorTypeCol, int &lineAnchorTextPointCol ) const +bool QgsMapToolLabel::labelAnchorPercentMovable( QgsVectorLayer *vlayer, const QgsPalLayerSettings &settings, int &lineAnchorPercentCol, int &lineAnchorClippingCol, int &lineAnchorTypeCol, int &lineAnchorTextPointCol ) const { - - auto checkProperty = [ & ]( const QgsPalLayerSettings::Property & property, int &col ) -> bool - { + auto checkProperty = [&]( const QgsPalLayerSettings::Property &property, int &col ) -> bool { if ( settings.dataDefinedProperties().isActive( property ) ) { PropertyStatus status = PropertyStatus::DoesNotExist; @@ -1259,7 +1246,7 @@ bool QgsMapToolLabel::diagramCanShowHide( QgsVectorLayer *vlayer, int &showCol ) QgsMapToolLabel::LabelDetails::LabelDetails( const QgsLabelPosition &p, QgsMapCanvas *canvas ) : pos( p ) { - layer = qobject_cast< QgsVectorLayer * >( canvas->layer( pos.layerID ) ); + layer = qobject_cast( canvas->layer( pos.layerID ) ); if ( layer && layer->labelsEnabled() && !p.isDiagram ) { settings = layer->labeling()->settings( pos.providerID ); @@ -1325,8 +1312,7 @@ bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsPalIndexe } // Anchor properties are for linestrings and polygons only: - if ( vlayer->geometryType() == Qgis::GeometryType::Line || - vlayer->geometryType() == Qgis::GeometryType::Polygon ) + if ( vlayer->geometryType() == Qgis::GeometryType::Line || vlayer->geometryType() == Qgis::GeometryType::Polygon ) { for ( const QgsPalLayerSettings::Property &p : std::as_const( mPalAnchorProperties ) ) { @@ -1413,7 +1399,7 @@ bool QgsMapToolLabel::createAuxiliaryFields( QgsCalloutIndexes &calloutIndexes ) bool QgsMapToolLabel::createAuxiliaryFields( QgsCalloutPosition &details, QgsCalloutIndexes &calloutIndexes ) { bool newAuxiliaryLayer = false; - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( QgsMapTool::layer( details.layerID ) ); + QgsVectorLayer *vlayer = qobject_cast( QgsMapTool::layer( details.layerID ) ); if ( !vlayer ) return newAuxiliaryLayer; @@ -1435,8 +1421,7 @@ bool QgsMapToolLabel::createAuxiliaryFields( QgsCalloutPosition &details, QgsCal int index = -1; // always use the default activated property - QgsProperty prop = vlayer->labeling() && vlayer->labeling()->settings( details.providerID ).callout() ? vlayer->labeling()->settings( details.providerID ).callout()->dataDefinedProperties().property( p ) : - QgsProperty(); + QgsProperty prop = vlayer->labeling() && vlayer->labeling()->settings( details.providerID ).callout() ? vlayer->labeling()->settings( details.providerID ).callout()->dataDefinedProperties().property( p ) : QgsProperty(); if ( prop.propertyType() == Qgis::PropertyType::Field && prop.isActive() ) { index = vlayer->fields().lookupField( prop.field() ); @@ -1517,11 +1502,7 @@ void QgsMapToolLabel::updateHoveredLabel( QgsMapMouseEvent *e ) LabelDetails newHoverLabel( labelPos, canvas() ); - if ( mCurrentHoverLabel.valid && - newHoverLabel.layer == mCurrentHoverLabel.layer && - newHoverLabel.pos.featureId == mCurrentHoverLabel.pos.featureId && - newHoverLabel.pos.providerID == mCurrentHoverLabel.pos.providerID - ) + if ( mCurrentHoverLabel.valid && newHoverLabel.layer == mCurrentHoverLabel.layer && newHoverLabel.pos.featureId == mCurrentHoverLabel.pos.featureId && newHoverLabel.pos.providerID == mCurrentHoverLabel.pos.providerID ) return; if ( !canModifyLabel( newHoverLabel ) ) @@ -1540,7 +1521,7 @@ void QgsMapToolLabel::updateHoveredLabel( QgsMapMouseEvent *e ) if ( labelPos.groupedLabelId != 0 ) { // if it's a curved label, we need to highlight ALL characters - const QList< QgsLabelPosition > allPositions = labelingResults->groupedLabelPositions( labelPos.groupedLabelId ); + const QList allPositions = labelingResults->groupedLabelPositions( labelPos.groupedLabelId ); for ( const QgsLabelPosition &position : allPositions ) { mHoverRubberBand->addGeometry( position.labelGeometry ); diff --git a/src/app/labeling/qgsmaptoollabel.h b/src/app/labeling/qgsmaptoollabel.h index ed2832c50837..e50a63b7777e 100644 --- a/src/app/labeling/qgsmaptoollabel.h +++ b/src/app/labeling/qgsmaptoollabel.h @@ -33,7 +33,7 @@ typedef QMap QgsDiagramIndexes; typedef QMap QgsCalloutIndexes; //! Base class for map tools that modify label properties -class APP_EXPORT QgsMapToolLabel: public QgsMapToolAdvancedDigitizing +class APP_EXPORT QgsMapToolLabel : public QgsMapToolAdvancedDigitizing { Q_OBJECT @@ -42,7 +42,6 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapToolAdvancedDigitizing ~QgsMapToolLabel() override; - void deactivate() override; /** @@ -89,12 +88,12 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapToolAdvancedDigitizing struct APP_EXPORT LabelDetails { - LabelDetails() = default; - explicit LabelDetails( const QgsLabelPosition &p, QgsMapCanvas *canvas ); - bool valid = false; - QgsLabelPosition pos; - QgsVectorLayer *layer = nullptr; - QgsPalLayerSettings settings; + LabelDetails() = default; + explicit LabelDetails( const QgsLabelPosition &p, QgsMapCanvas *canvas ); + bool valid = false; + QgsLabelPosition pos; + QgsVectorLayer *layer = nullptr; + QgsPalLayerSettings settings; }; //! Currently dragged label position @@ -208,7 +207,8 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapToolAdvancedDigitizing double &lineAnchorPercent, bool &lineAnchorPercentSuccess, int &lineAnchorPercentCol, QString &lineAnchorClipping, bool &lineAnchorClippingSuccess, int &lineAnchorClippingCol, QString &lineAnchorType, bool &lineAnchorTypeSuccess, int &lineAnchorTypeCol, - QString &lineAnchorTextPoint, bool &lineAnchorTextPointSuccess, int &lineAnchorTextPointCol ) const; + QString &lineAnchorTextPoint, bool &lineAnchorTextPointSuccess, int &lineAnchorTextPointCol + ) const; /** * Returns data defined rotation of current label diff --git a/src/app/labeling/qgsmaptoolmovelabel.cpp b/src/app/labeling/qgsmaptoolmovelabel.cpp index 1c61ab48952a..26a71cd527a6 100644 --- a/src/app/labeling/qgsmaptoolmovelabel.cpp +++ b/src/app/labeling/qgsmaptoolmovelabel.cpp @@ -65,7 +65,6 @@ void QgsMapToolMoveLabel::deleteRubberBands() void QgsMapToolMoveLabel::cadCanvasMoveEvent( QgsMapMouseEvent *e ) { - if ( mLabelRubberBand ) { const QgsPointXY pointMapCoords = e->mapPoint(); @@ -189,7 +188,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) clearHoveredLabel(); - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( QgsMapTool::layer( mCurrentCallout.layerID ) ); + QgsVectorLayer *vlayer = qobject_cast( QgsMapTool::layer( mCurrentCallout.layerID ) ); if ( !vlayer || xCol < 0 || yCol < 0 ) { return; @@ -313,12 +312,11 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) return; } - lineAnchorPercentCol = indexes[ QgsPalLayerSettings::Property::LineAnchorPercent ]; + lineAnchorPercentCol = indexes[QgsPalLayerSettings::Property::LineAnchorPercent]; // TODO? //lineAnchorClippingCol = indexes[ QgsPalLayerSettings::LineAnchorClipping]; //lineAnchorTypeCol = indexes[ QgsPalLayerSettings::LineAnchorType]; //lineAnchorTextPointCol = indexes[ QgsPalLayerSettings::LineAnchorTextPoint]; - } else if ( !mCurrentLabel.pos.isDiagram && !isMovableUsingPoint ) { @@ -347,8 +345,8 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) return; } - xCol = indexes[ QgsPalLayerSettings::Property::PositionX ]; - yCol = indexes[ QgsPalLayerSettings::Property::PositionY ]; + xCol = indexes[QgsPalLayerSettings::Property::PositionX]; + yCol = indexes[QgsPalLayerSettings::Property::PositionY]; } else if ( mCurrentLabel.pos.isDiagram && !diagramMoveable( vlayer, xCol, yCol ) ) { @@ -360,15 +358,13 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) if ( !diagramMoveable( vlayer, xCol, yCol ) ) return; - xCol = indexes[ QgsDiagramLayerSettings::Property::PositionX ]; - yCol = indexes[ QgsDiagramLayerSettings::Property::PositionY ]; + xCol = indexes[QgsDiagramLayerSettings::Property::PositionX]; + yCol = indexes[QgsDiagramLayerSettings::Property::PositionY]; } if ( ( isCurvedOrLine && lineAnchorPercentCol >= 0 ) || ( xCol >= 0 && yCol >= 0 ) ) { - const bool usesAuxFields = - ( isCurvedOrLine && lineAnchorPercentCol >= 0 && vlayer->fields().fieldOrigin( lineAnchorPercentCol ) == Qgis::FieldOrigin::Join ) || - ( vlayer->fields().fieldOrigin( xCol ) == Qgis::FieldOrigin::Join && vlayer->fields().fieldOrigin( yCol ) == Qgis::FieldOrigin::Join ); + const bool usesAuxFields = ( isCurvedOrLine && lineAnchorPercentCol >= 0 && vlayer->fields().fieldOrigin( lineAnchorPercentCol ) == Qgis::FieldOrigin::Join ) || ( vlayer->fields().fieldOrigin( xCol ) == Qgis::FieldOrigin::Join && vlayer->fields().fieldOrigin( yCol ) == Qgis::FieldOrigin::Join ); if ( !usesAuxFields && !vlayer->isEditable() ) { if ( vlayer->startEditing() ) @@ -419,7 +415,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) deleteRubberBands(); - QgsVectorLayer *vlayer = !isCalloutMove ? mCurrentLabel.layer : qobject_cast< QgsVectorLayer * >( QgsMapTool::layer( mCurrentCallout.layerID ) ); + QgsVectorLayer *vlayer = !isCalloutMove ? mCurrentLabel.layer : qobject_cast( QgsMapTool::layer( mCurrentCallout.layerID ) ); if ( !vlayer ) { return; @@ -451,10 +447,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) bool isCurvedOrLine = !mAnchorDetached && ( mCurrentLabel.settings.placement == Qgis::LabelPlacement::Curved || mCurrentLabel.settings.placement == Qgis::LabelPlacement::PerimeterCurved || mCurrentLabel.settings.placement == Qgis::LabelPlacement::Line ); - if ( !isCalloutMove && isCurvedOrLine && !currentLabelDataDefinedLineAnchorPercent( lineAnchorPercentOrig, lineAnchorPercentSuccess, lineAnchorPercentCol, - lineAnchorClippingOrig, lineAnchorClippingSuccess, lineAnchorClippingCol, - lineAnchorTypeOrig, lineAnchorTypeSuccess, lineAnchorTypeCol, - lineAnchorTextPointOrig, lineAnchorTextPointSuccess, lineAnchorTextPointCol ) ) + if ( !isCalloutMove && isCurvedOrLine && !currentLabelDataDefinedLineAnchorPercent( lineAnchorPercentOrig, lineAnchorPercentSuccess, lineAnchorPercentCol, lineAnchorClippingOrig, lineAnchorClippingSuccess, lineAnchorClippingCol, lineAnchorTypeOrig, lineAnchorTypeSuccess, lineAnchorTypeCol, lineAnchorTextPointOrig, lineAnchorTextPointSuccess, lineAnchorTextPointCol ) ) { return; } @@ -567,7 +560,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) QVariant yNewPos( yPosNew ); if ( xCol < vlayer->fields().count() ) { - if ( ! vlayer->fields().at( xCol ).convertCompatible( xNewPos ) ) + if ( !vlayer->fields().at( xCol ).convertCompatible( xNewPos ) ) { xNewPos = xPosNew; // revert and hope for the best } @@ -575,7 +568,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e ) if ( yCol < vlayer->fields().count() ) { - if ( ! vlayer->fields().at( yCol ).convertCompatible( yNewPos ) ) + if ( !vlayer->fields().at( yCol ).convertCompatible( yNewPos ) ) { yNewPos = yPosNew; // revert and hope for the best } @@ -660,7 +653,7 @@ void QgsMapToolMoveLabel::keyPressEvent( QKeyEvent *e ) { case Qt::Key_Delete: { - e->ignore(); // Override default shortcut management + e->ignore(); // Override default shortcut management return; } } @@ -677,13 +670,13 @@ void QgsMapToolMoveLabel::keyReleaseEvent( QKeyEvent *e ) { case Qt::Key_Delete: { - e->ignore(); // Override default shortcut management + e->ignore(); // Override default shortcut management // delete the stored label/callout position mAnchorDetached = false; const bool isCalloutMove = !mCurrentCallout.layerID.isEmpty(); const bool isCurvedOrLine = mCurrentLabel.settings.placement == Qgis::LabelPlacement::Curved || mCurrentLabel.settings.placement == Qgis::LabelPlacement::PerimeterCurved || mCurrentLabel.settings.placement == Qgis::LabelPlacement::Line; - QgsVectorLayer *vlayer = !isCalloutMove ? mCurrentLabel.layer : qobject_cast< QgsVectorLayer * >( QgsMapTool::layer( mCurrentCallout.layerID ) ); + QgsVectorLayer *vlayer = !isCalloutMove ? mCurrentLabel.layer : qobject_cast( QgsMapTool::layer( mCurrentCallout.layerID ) ); const QgsFeatureId featureId = !isCalloutMove ? mCurrentLabel.pos.featureId : mCurrentCallout.featureId; if ( vlayer ) { @@ -707,10 +700,7 @@ void QgsMapToolMoveLabel::keyReleaseEvent( QKeyEvent *e ) bool xSuccess = false; bool ySuccess = false; - if ( !isCalloutMove && isCurvedOrLine && ! currentLabelDataDefinedLineAnchorPercent( lineAnchorPercentOrig, lineAnchorPercentSuccess, lineAnchorPercentCol, - lineAnchorClippingOrig, lineAnchorClippingSuccess, lineAnchorClippingCol, - lineAnchorTypeOrig, lineAnchorTypeSuccess, lineAnchorTypeCol, - lineAnchorTextPointOrig, lineAnchorTextPointSuccess, lineAnchorTextPointCol ) ) + if ( !isCalloutMove && isCurvedOrLine && !currentLabelDataDefinedLineAnchorPercent( lineAnchorPercentOrig, lineAnchorPercentSuccess, lineAnchorPercentCol, lineAnchorClippingOrig, lineAnchorClippingSuccess, lineAnchorClippingCol, lineAnchorTypeOrig, lineAnchorTypeSuccess, lineAnchorTypeCol, lineAnchorTextPointOrig, lineAnchorTextPointSuccess, lineAnchorTextPointCol ) ) { break; } @@ -806,7 +796,7 @@ void QgsMapToolMoveLabel::keyReleaseEvent( QKeyEvent *e ) bool QgsMapToolMoveLabel::canModifyCallout( const QgsCalloutPosition &pos, bool isOrigin, int &xCol, int &yCol ) { - QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( QgsMapTool::layer( pos.layerID ) ); + QgsVectorLayer *layer = qobject_cast( QgsMapTool::layer( pos.layerID ) ); QgsPalLayerSettings settings; if ( layer && layer->labelsEnabled() ) { @@ -820,8 +810,7 @@ bool QgsMapToolMoveLabel::canModifyCallout( const QgsCalloutPosition &pos, bool return false; } - auto calloutPropertyColumnName = [callout]( QgsCallout::Property p ) - { + auto calloutPropertyColumnName = [callout]( QgsCallout::Property p ) { if ( !callout->dataDefinedProperties().isActive( p ) ) return QString(); @@ -835,7 +824,7 @@ bool QgsMapToolMoveLabel::canModifyCallout( const QgsCalloutPosition &pos, bool const QStringList subProviders = layer->labeling()->subProviders(); for ( const QString &provider : subProviders ) { - ( void )provider; + ( void ) provider; const QString xColName = isOrigin ? calloutPropertyColumnName( QgsCallout::Property::OriginX ) : calloutPropertyColumnName( QgsCallout::Property::DestinationX ); const QString yColName = isOrigin ? calloutPropertyColumnName( QgsCallout::Property::OriginY ) : calloutPropertyColumnName( QgsCallout::Property::DestinationY ); @@ -850,7 +839,7 @@ bool QgsMapToolMoveLabel::canModifyCallout( const QgsCalloutPosition &pos, bool bool QgsMapToolMoveLabel::currentCalloutDataDefinedPosition( double &x, bool &xSuccess, double &y, bool &ySuccess, int &xCol, int &yCol ) { - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( QgsMapTool::layer( mCurrentCallout.layerID ) ); + QgsVectorLayer *vlayer = qobject_cast( QgsMapTool::layer( mCurrentCallout.layerID ) ); const QgsFeatureId featureId = mCurrentCallout.featureId; xSuccess = false; @@ -889,7 +878,7 @@ QgsPointXY QgsMapToolMoveLabel::snapCalloutPointToCommonAngle( const QgsPointXY const double cursorDistance = start.distance( mapPoint ); // snap to common angles (15 degree increments) - double closestDist = std::numeric_limits< double >::max(); + double closestDist = std::numeric_limits::max(); double closestX = 0; double closestY = 0; int bestAngle = 0; @@ -916,6 +905,3 @@ QgsPointXY QgsMapToolMoveLabel::snapCalloutPointToCommonAngle( const QgsPointXY return QgsPointXY( closestX, closestY ); } - - - diff --git a/src/app/labeling/qgsmaptoolmovelabel.h b/src/app/labeling/qgsmaptoolmovelabel.h index f4ec98318d81..bdffbb9372b9 100644 --- a/src/app/labeling/qgsmaptoolmovelabel.h +++ b/src/app/labeling/qgsmaptoolmovelabel.h @@ -22,7 +22,7 @@ #include "qgis_app.h" //! A map tool for dragging label positions -class APP_EXPORT QgsMapToolMoveLabel: public QgsMapToolLabel +class APP_EXPORT QgsMapToolMoveLabel : public QgsMapToolLabel { Q_OBJECT @@ -40,7 +40,6 @@ class APP_EXPORT QgsMapToolMoveLabel: public QgsMapToolLabel void keyReleaseEvent( QKeyEvent *e ) override; protected: - bool canModifyCallout( const QgsCalloutPosition &position, bool isOrigin, int &xCol, int &yCol ) override; bool mCurrentCalloutMoveOrigin = false; @@ -60,7 +59,6 @@ class APP_EXPORT QgsMapToolMoveLabel: public QgsMapToolLabel bool mAnchorDetached = false; double mLabelTearFromLineThreshold = 0; - }; #endif // QGSMAPTOOLMOVELABEL_H diff --git a/src/app/labeling/qgsmaptoolpinlabels.cpp b/src/app/labeling/qgsmaptoolpinlabels.cpp index a60539a5ff7c..5de83f8fd925 100644 --- a/src/app/labeling/qgsmaptoolpinlabels.cpp +++ b/src/app/labeling/qgsmaptoolpinlabels.cpp @@ -136,9 +136,7 @@ void QgsMapToolPinLabels::updatePinnedLabels() } } -void QgsMapToolPinLabels::highlightLabel( const QgsLabelPosition &labelpos, - const QString &id, - const QColor &color ) +void QgsMapToolPinLabels::highlightLabel( const QgsLabelPosition &labelpos, const QString &id, const QColor &color ) { QgsRubberBand *rb = new QgsRubberBand( mCanvas, Qgis::GeometryType::Polygon ); rb->addPoint( labelpos.cornerPoints.at( 0 ) ); @@ -281,7 +279,7 @@ void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle &ext, QMouseEvent * bool labelChanged = false; QList::const_iterator it; - for ( it = labelPosList.constBegin() ; it != labelPosList.constEnd(); ++it ) + for ( it = labelPosList.constBegin(); it != labelPosList.constEnd(); ++it ) { const QgsLabelPosition &pos = *it; @@ -294,7 +292,7 @@ void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle &ext, QMouseEvent * } // unpin label - if ( isPinned() && ( doUnpin || toggleUnpinOrPin ) ) + if ( isPinned() && ( doUnpin || toggleUnpinOrPin ) ) { // unpin previously pinned label (set attribute table fields to NULL) if ( pinUnpinCurrentFeature( false ) ) @@ -374,8 +372,7 @@ bool QgsMapToolPinLabels::pinUnpinCurrentLabel( bool pin ) if ( pin ) { - -// QgsPointXY labelpoint = labelpos.cornerPoints.at( 0 ); + // QgsPointXY labelpoint = labelpos.cornerPoints.at( 0 ); QgsPointXY referencePoint; if ( !currentLabelRotationPoint( referencePoint, !preserveRot ) ) @@ -443,7 +440,7 @@ bool QgsMapToolPinLabels::pinUnpinCurrentFeature( bool pin ) { bool rc = false; - if ( ! mCurrentLabel.pos.isDiagram ) + if ( !mCurrentLabel.pos.isDiagram ) rc = pinUnpinCurrentLabel( pin ); else rc = pinUnpinCurrentDiagram( pin ); @@ -453,9 +450,8 @@ bool QgsMapToolPinLabels::pinUnpinCurrentFeature( bool pin ) bool QgsMapToolPinLabels::pinUnpinCurrentDiagram( bool pin ) { - // skip diagrams - if ( ! mCurrentLabel.pos.isDiagram ) + if ( !mCurrentLabel.pos.isDiagram ) return false; // verify attribute table has x, y fields mapped diff --git a/src/app/labeling/qgsmaptoolpinlabels.h b/src/app/labeling/qgsmaptoolpinlabels.h index 3354d67de8b9..b364d1f77a45 100644 --- a/src/app/labeling/qgsmaptoolpinlabels.h +++ b/src/app/labeling/qgsmaptoolpinlabels.h @@ -25,7 +25,7 @@ class QgsRubberBand; class QgsLabelPosition; //! A map tool for pinning (writing to attribute table) and unpinning labelpositions and rotation -class APP_EXPORT QgsMapToolPinLabels: public QgsMapToolLabel +class APP_EXPORT QgsMapToolPinLabels : public QgsMapToolLabel { Q_OBJECT @@ -60,7 +60,6 @@ class APP_EXPORT QgsMapToolPinLabels: public QgsMapToolLabel void highlightPinnedLabels(); protected: - //! Mapping of feature ids of layers that have been highlighted QMap mHighlights; @@ -76,16 +75,11 @@ class APP_EXPORT QgsMapToolPinLabels: public QgsMapToolLabel QgsRubberBand *mRubberBand = nullptr; private: - //! Highlights a given label relative to whether its pinned and editable - void highlightLabel( const QgsLabelPosition &labelpos, - const QString &id, - const QColor &color ); + void highlightLabel( const QgsLabelPosition &labelpos, const QString &id, const QColor &color ); //! Highlights a given callout relative to whether its pinned and editable - void highlightCallout( bool isOrigin, const QgsCalloutPosition &labelpos, - const QString &id, - const QColor &color ); + void highlightCallout( bool isOrigin, const QgsCalloutPosition &labelpos, const QString &id, const QColor &color ); //! Select valid labels to pin or unpin void pinUnpinLabels( const QgsRectangle &ext, QMouseEvent *e ); diff --git a/src/app/labeling/qgsmaptoolrotatelabel.cpp b/src/app/labeling/qgsmaptoolrotatelabel.cpp index a08c5f6a6402..a79e09c73785 100644 --- a/src/app/labeling/qgsmaptoolrotatelabel.cpp +++ b/src/app/labeling/qgsmaptoolrotatelabel.cpp @@ -63,7 +63,7 @@ void QgsMapToolRotateLabel::canvasMoveEvent( QgsMapMouseEvent *e ) } else { - displayValue = static_cast< int >( mCurrentRotation ); + displayValue = static_cast( mCurrentRotation ); mCtrlPressed = false; } @@ -161,8 +161,7 @@ void QgsMapToolRotateLabel::canvasPressEvent( QgsMapMouseEvent *e ) // Convert to degree mCurrentRotation = mCurrentRotation - * QgsUnitTypes::fromUnitToUnitFactor( mCurrentLabel.settings.rotationUnit(), - Qgis::AngleUnit::Degrees ); + * QgsUnitTypes::fromUnitToUnitFactor( mCurrentLabel.settings.rotationUnit(), Qgis::AngleUnit::Degrees ); mStartRotation = mCurrentRotation; createRubberBands(); @@ -173,7 +172,7 @@ void QgsMapToolRotateLabel::canvasPressEvent( QgsMapMouseEvent *e ) mRotationItem->setOrientation( QgsPointRotationItem::Clockwise ); mRotationItem->setPointLocation( mRotationPoint ); mRotationItem->setRotationUnit( mCurrentLabel.settings.rotationUnit() ); - mRotationItem->setSymbolRotation( static_cast< int >( mCurrentRotation ) ); + mRotationItem->setSymbolRotation( static_cast( mCurrentRotation ) ); } } } @@ -218,8 +217,7 @@ void QgsMapToolRotateLabel::canvasPressEvent( QgsMapMouseEvent *e ) } // Convert back to settings unit - const double rotation = rotationDegree * QgsUnitTypes::fromUnitToUnitFactor( Qgis::AngleUnit::Degrees, - mCurrentLabel.settings.rotationUnit() ); + const double rotation = rotationDegree * QgsUnitTypes::fromUnitToUnitFactor( Qgis::AngleUnit::Degrees, mCurrentLabel.settings.rotationUnit() ); vlayer->beginEditCommand( tr( "Rotated label" ) + QStringLiteral( " '%1'" ).arg( currentLabelText( 24 ) ) ); if ( !vlayer->changeAttributeValue( mCurrentLabel.pos.featureId, rotationCol, rotation ) ) @@ -252,7 +250,7 @@ void QgsMapToolRotateLabel::keyPressEvent( QKeyEvent *e ) { case Qt::Key_Delete: { - e->ignore(); // Override default shortcut management + e->ignore(); // Override default shortcut management return; } } @@ -289,7 +287,6 @@ void QgsMapToolRotateLabel::keyReleaseEvent( QKeyEvent *e ) { QgisApp::instance()->messageBar()->pushWarning( tr( "Delete Label Rotation" ), tr( "Error encountered while storing new label position" ) ); } - } vlayer->endEditCommand(); deleteRubberBands(); @@ -299,7 +296,7 @@ void QgsMapToolRotateLabel::keyReleaseEvent( QKeyEvent *e ) vlayer->triggerRepaint(); } } - e->ignore(); // Override default shortcut management + e->ignore(); // Override default shortcut management break; } @@ -317,7 +314,7 @@ void QgsMapToolRotateLabel::keyReleaseEvent( QKeyEvent *e ) int QgsMapToolRotateLabel::roundTo15Degrees( double n ) { - const int m = static_cast< int >( n / 15.0 + 0.5 ); + const int m = static_cast( n / 15.0 + 0.5 ); return ( m * 15 ); } @@ -330,7 +327,7 @@ double QgsMapToolRotateLabel::convertAzimuth( double a ) void QgsMapToolRotateLabel::createRotationPreviewBox() { mRotationPreviewBox.reset(); - const QVector< QgsPointXY > boxPoints = mCurrentLabel.pos.cornerPoints; + const QVector boxPoints = mCurrentLabel.pos.cornerPoints; if ( boxPoints.empty() ) return; @@ -351,7 +348,7 @@ void QgsMapToolRotateLabel::setRotationPreviewBox( double rotation ) if ( mCurrentLabel.pos.cornerPoints.empty() ) return; - const QVector< QgsPointXY > cornerPoints = mCurrentLabel.pos.cornerPoints; + const QVector cornerPoints = mCurrentLabel.pos.cornerPoints; for ( const QgsPointXY &cornerPoint : cornerPoints ) mRotationPreviewBox->addPoint( rotatePointClockwise( cornerPoint, mRotationPoint, rotation ) ); mRotationPreviewBox->addPoint( rotatePointClockwise( mCurrentLabel.pos.cornerPoints.at( 0 ), mRotationPoint, rotation ) ); diff --git a/src/app/labeling/qgsmaptoolrotatelabel.h b/src/app/labeling/qgsmaptoolrotatelabel.h index 5008236b878c..6f6dbc83bf2c 100644 --- a/src/app/labeling/qgsmaptoolrotatelabel.h +++ b/src/app/labeling/qgsmaptoolrotatelabel.h @@ -23,7 +23,7 @@ #include "qobjectuniqueptr.h" class QgsPointRotationItem; -class APP_EXPORT QgsMapToolRotateLabel: public QgsMapToolLabel +class APP_EXPORT QgsMapToolRotateLabel : public QgsMapToolLabel { Q_OBJECT @@ -37,7 +37,6 @@ class APP_EXPORT QgsMapToolRotateLabel: public QgsMapToolLabel void keyReleaseEvent( QKeyEvent *e ) override; protected: - static int roundTo15Degrees( double n ); //! Converts azimuth value so that 0 is corresponds to East static double convertAzimuth( double a ); diff --git a/src/app/labeling/qgsmaptoolshowhidelabels.cpp b/src/app/labeling/qgsmaptoolshowhidelabels.cpp index ba280e05bd88..e609911931ef 100644 --- a/src/app/labeling/qgsmaptoolshowhidelabels.cpp +++ b/src/app/labeling/qgsmaptoolshowhidelabels.cpp @@ -223,8 +223,7 @@ void QgsMapToolShowHideLabels::showHideLabels( QMouseEvent *e ) } } -bool QgsMapToolShowHideLabels::selectedFeatures( QgsVectorLayer *vlayer, - QgsFeatureIds &selectedFeatIds ) +bool QgsMapToolShowHideLabels::selectedFeatures( QgsVectorLayer *vlayer, QgsFeatureIds &selectedFeatIds ) { // culled from QgsMapToolSelectUtils::setSelectFeatures() @@ -264,9 +263,9 @@ bool QgsMapToolShowHideLabels::selectedFeatures( QgsVectorLayer *vlayer, QgsDebugMsgLevel( "Selection polygon: " + selectGeomTrans.asWkt(), 2 ); QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest() - .setFilterRect( selectGeomTrans.boundingBox() ) - .setFlags( Qgis::FeatureRequestFlag::NoGeometry | Qgis::FeatureRequestFlag::ExactIntersect ) - .setNoAttributes() ); + .setFilterRect( selectGeomTrans.boundingBox() ) + .setFlags( Qgis::FeatureRequestFlag::NoGeometry | Qgis::FeatureRequestFlag::ExactIntersect ) + .setNoAttributes() ); QgsFeature f; while ( fit.nextFeature( f ) ) @@ -279,8 +278,7 @@ bool QgsMapToolShowHideLabels::selectedFeatures( QgsVectorLayer *vlayer, return !selectedFeatIds.empty(); } -bool QgsMapToolShowHideLabels::selectedLabelFeatures( QgsVectorLayer *vlayer, - QList &listPos ) +bool QgsMapToolShowHideLabels::selectedLabelFeatures( QgsVectorLayer *vlayer, QList &listPos ) { listPos.clear(); @@ -297,7 +295,7 @@ bool QgsMapToolShowHideLabels::selectedLabelFeatures( QgsVectorLayer *vlayer, QList labelPosList = labelingResults->labelsWithinRect( ext ); QList::const_iterator it; - for ( it = labelPosList.constBegin() ; it != labelPosList.constEnd(); ++it ) + for ( it = labelPosList.constBegin(); it != labelPosList.constEnd(); ++it ) { const QgsLabelPosition &pos = *it; @@ -334,7 +332,7 @@ bool QgsMapToolShowHideLabels::showHide( const QgsLabelPosition &pos, bool show QgsDiagramIndexes indexes; createAuxiliaryFields( details, indexes ); - showCol = indexes[ QgsDiagramLayerSettings::Property::Show ]; + showCol = indexes[QgsDiagramLayerSettings::Property::Show]; } } else @@ -344,7 +342,7 @@ bool QgsMapToolShowHideLabels::showHide( const QgsLabelPosition &pos, bool show QgsPalIndexes indexes; createAuxiliaryFields( details, indexes ); - showCol = indexes[ QgsPalLayerSettings::Property::Show ]; + showCol = indexes[QgsPalLayerSettings::Property::Show]; } } diff --git a/src/app/labeling/qgsmaptoolshowhidelabels.h b/src/app/labeling/qgsmaptoolshowhidelabels.h index d8e46339efab..59fda20daa75 100644 --- a/src/app/labeling/qgsmaptoolshowhidelabels.h +++ b/src/app/labeling/qgsmaptoolshowhidelabels.h @@ -42,7 +42,6 @@ class APP_EXPORT QgsMapToolShowHideLabels : public QgsMapToolLabel void canvasReleaseEvent( QgsMapMouseEvent *e ) override; protected: - //! Flag to indicate a map canvas drag operation is taking place bool mDragging; @@ -57,12 +56,10 @@ class APP_EXPORT QgsMapToolShowHideLabels : public QgsMapToolLabel void showHideLabels( QMouseEvent *e ); //! Returns the features intersecting rubberband - bool selectedFeatures( QgsVectorLayer *vlayer, - QgsFeatureIds &selectedFeatIds ); + bool selectedFeatures( QgsVectorLayer *vlayer, QgsFeatureIds &selectedFeatIds ); //! Returns the label features intersecting rubberband - bool selectedLabelFeatures( QgsVectorLayer *vlayer, - QList &listPos ); + bool selectedLabelFeatures( QgsVectorLayer *vlayer, QList &listPos ); bool showHide( const QgsLabelPosition &pos, bool show ); }; diff --git a/src/app/layers/qgsapplayerhandling.cpp b/src/app/layers/qgsapplayerhandling.cpp index ff5c0ca5d013..83c97643e1dc 100644 --- a/src/app/layers/qgsapplayerhandling.cpp +++ b/src/app/layers/qgsapplayerhandling.cpp @@ -82,7 +82,7 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) { case Qgis::LayerType::Raster: { - QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( layer ); + QgsRasterLayer *rasterLayer = qobject_cast( layer ); bool ok = false; layer->loadDefaultStyle( ok ); layer->loadDefaultMetadata( ok ); @@ -90,13 +90,11 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) // if there's no (useful) terrain provider for the current project, and we know that this // layer contains elevation, then automatically set it as the terrain provider if ( !QgsProject::instance()->elevationProperties()->terrainProvider() - || ( dynamic_cast< QgsFlatTerrainProvider * >( QgsProject::instance()->elevationProperties()->terrainProvider() ) - && QgsProject::instance()->elevationProperties()->terrainProvider()->offset() == 0 - && QgsProject::instance()->elevationProperties()->terrainProvider()->scale() == 1 ) ) + || ( dynamic_cast( QgsProject::instance()->elevationProperties()->terrainProvider() ) && QgsProject::instance()->elevationProperties()->terrainProvider()->offset() == 0 && QgsProject::instance()->elevationProperties()->terrainProvider()->scale() == 1 ) ) { if ( rasterLayer->elevationProperties()->hasElevation() ) { - std::unique_ptr< QgsRasterDemTerrainProvider > terrain = std::make_unique(); + std::unique_ptr terrain = std::make_unique(); terrain->setLayer( rasterLayer ); QgsProject::instance()->elevationProperties()->setTerrainProvider( terrain.release() @@ -109,8 +107,8 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) // (but in this case we aren't sure, so don't apply the above logic which was only for layers we know are DEFINITELY dems) if ( QgsRasterLayerElevationProperties::layerLooksLikeDem( rasterLayer ) ) { - qgis::down_cast< QgsRasterLayerElevationProperties * >( rasterLayer->elevationProperties() )->setEnabled( true ); - qgis::down_cast< QgsRasterLayerElevationProperties * >( rasterLayer->elevationProperties() )->setMode( Qgis::RasterElevationMode::RepresentsElevationSurface ); + qgis::down_cast( rasterLayer->elevationProperties() )->setEnabled( true ); + qgis::down_cast( rasterLayer->elevationProperties() )->setMode( Qgis::RasterElevationMode::RepresentsElevationSurface ); } break; @@ -129,13 +127,13 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) case Qgis::LayerType::Mesh: { - QgsMeshLayer *meshLayer = qobject_cast< QgsMeshLayer *>( layer ); + QgsMeshLayer *meshLayer = qobject_cast( layer ); QDateTime referenceTime = QgsProject::instance()->timeSettings()->temporalRange().begin(); if ( !referenceTime.isValid() ) // If project reference time is invalid, use current date referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0 ), Qt::UTC ); - if ( meshLayer->dataProvider() && !qobject_cast< QgsMeshLayerTemporalProperties * >( meshLayer->temporalProperties() )->referenceTime().isValid() ) - qobject_cast< QgsMeshLayerTemporalProperties * >( meshLayer->temporalProperties() )->setReferenceTime( referenceTime, meshLayer->dataProvider()->temporalCapabilities() ); + if ( meshLayer->dataProvider() && !qobject_cast( meshLayer->temporalProperties() )->referenceTime().isValid() ) + qobject_cast( meshLayer->temporalProperties() )->setReferenceTime( referenceTime, meshLayer->dataProvider()->temporalCapabilities() ); bool ok = false; meshLayer->loadDefaultStyle( ok ); @@ -147,7 +145,7 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) { QString error; QStringList warnings; - bool ok = qobject_cast< QgsVectorTileLayer * >( layer )->loadDefaultStyle( error, warnings ); + bool ok = qobject_cast( layer )->loadDefaultStyle( error, warnings ); if ( !ok && !error.isEmpty() ) QgisApp::instance()->visibleMessageBar()->pushMessage( QObject::tr( "Error loading style" ), error, Qgis::MessageLevel::Warning ); else if ( !warnings.empty() ) @@ -171,7 +169,7 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) #ifdef HAVE_3D if ( !layer->renderer3D() ) { - std::unique_ptr< QgsTiledSceneLayer3DRenderer > renderer3D = std::make_unique< QgsTiledSceneLayer3DRenderer >(); + std::unique_ptr renderer3D = std::make_unique(); layer->setRenderer3D( renderer3D.release() ); } #endif @@ -192,11 +190,11 @@ void QgsAppLayerHandling::postProcessAddedLayer( QgsMapLayer *layer ) #ifdef HAVE_3D if ( !layer->renderer3D() ) { - QgsPointCloudLayer *pcLayer = qobject_cast< QgsPointCloudLayer * >( layer ); + QgsPointCloudLayer *pcLayer = qobject_cast( layer ); // If the layer has no 3D renderer and syncing 3D to 2D renderer is enabled, we create a renderer and set it up with the 2D renderer if ( pcLayer->sync3DRendererTo2DRenderer() ) { - std::unique_ptr< QgsPointCloudLayer3DRenderer > renderer3D = std::make_unique< QgsPointCloudLayer3DRenderer >(); + std::unique_ptr renderer3D = std::make_unique(); renderer3D->convertFrom2DRenderer( pcLayer->renderer() ); layer->setRenderer3D( renderer3D.release() ); } @@ -211,10 +209,8 @@ void QgsAppLayerHandling::addSortedLayersToLegend( QList &layers { if ( layers.size() > 1 ) { - std::sort( layers.begin(), layers.end(), []( QgsMapLayer * a, QgsMapLayer * b ) - { - const static QMap layerTypeOrdering = - { + std::sort( layers.begin(), layers.end(), []( QgsMapLayer *a, QgsMapLayer *b ) { + const static QMap layerTypeOrdering = { { Qgis::LayerType::Annotation, -1 }, { Qgis::LayerType::Vector, 0 }, { Qgis::LayerType::PointCloud, 1 }, @@ -243,7 +239,7 @@ void QgsAppLayerHandling::addSortedLayersToLegend( QList &layers layer->removeCustomProperty( QStringLiteral( "_legend_added" ) ); continue; } - emit QgsProject::instance()->legendLayersAdded( QList() << layer ); + emit QgsProject::instance() -> legendLayersAdded( QList() << layer ); } QgisApp::instance()->layerTreeView()->setCurrentLayer( layers.at( 0 ) ); } @@ -251,7 +247,7 @@ void QgsAppLayerHandling::addSortedLayersToLegend( QList &layers void QgsAppLayerHandling::postProcessAddedLayers( const QList &layers ) { std::map mapPathToReferenceCount; - std::map> mapPathToRelations; + std::map> mapPathToRelations; QgsProviderMetadata *ogrProviderMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) ); for ( QgsMapLayer *layer : layers ) @@ -260,7 +256,7 @@ void QgsAppLayerHandling::postProcessAddedLayers( const QList &la { case Qgis::LayerType::Vector: { - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer ); + QgsVectorLayer *vl = qobject_cast( layer ); // try to automatically load related tables for OGR layers if ( vl->providerType() == QLatin1String( "ogr" ) ) @@ -275,10 +271,10 @@ void QgsAppLayerHandling::postProcessAddedLayers( const QList &la const QString path = uriParts.value( QStringLiteral( "path" ) ).toString(); if ( ++mapPathToReferenceCount[path] == 2 ) { - std::unique_ptr< QgsAbstractDatabaseProviderConnection > conn { QgsMapLayerUtils::databaseConnection( vl ) }; + std::unique_ptr conn { QgsMapLayerUtils::databaseConnection( vl ) }; if ( conn && ( conn->capabilities() & QgsAbstractDatabaseProviderConnection::Capability::RetrieveRelationships ) ) { - const QList< QgsWeakRelation > relations = conn->relationships( QString(), QString() ); + const QList relations = conn->relationships( QString(), QString() ); mapPathToRelations[path] = relations; } } @@ -290,7 +286,7 @@ void QgsAppLayerHandling::postProcessAddedLayers( const QList &la { if ( !iterMapPathToRelations->second.isEmpty() ) { - QList< QgsWeakRelation > layerRelations; + QList layerRelations; for ( const QgsWeakRelation &rel : std::as_const( iterMapPathToRelations->second ) ) { const QVariantMap leftParts = ogrProviderMetadata->decodeUri( rel.referencedLayerSource() ); @@ -311,10 +307,10 @@ void QgsAppLayerHandling::postProcessAddedLayers( const QList &la } // first need to create weak relations!! - std::unique_ptr< QgsAbstractDatabaseProviderConnection > conn { QgsMapLayerUtils::databaseConnection( vl ) }; + std::unique_ptr conn { QgsMapLayerUtils::databaseConnection( vl ) }; if ( conn && ( conn->capabilities() & QgsAbstractDatabaseProviderConnection::Capability::RetrieveRelationships ) ) { - const QList< QgsWeakRelation > relations = conn->relationships( QString(), layerName ); + const QList relations = conn->relationships( QString(), layerName ); if ( !relations.isEmpty() ) { vl->setWeakRelations( relations ); @@ -338,7 +334,7 @@ void QgsAppLayerHandling::postProcessAddedLayers( const QList &la } } -QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringList &layers, const QString &encoding, const QString &dataSourceType, bool &ok, bool showWarningOnInvalid ) +QList QgsAppLayerHandling::addOgrVectorLayers( const QStringList &layers, const QString &encoding, const QString &dataSourceType, bool &ok, bool showWarningOnInvalid ) { //note: this method ONLY supports vector layers from the OGR provider! ok = false; @@ -364,10 +360,9 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis // if needed prompt for zipitem layers const QString vsiPrefix = QgsGdalUtils::vsiPrefixForPath( uri ); - if ( ! uri.startsWith( QLatin1String( "/vsi" ), Qt::CaseInsensitive ) && - QgsGdalUtils::isVsiArchivePrefix( vsiPrefix ) ) + if ( !uri.startsWith( QLatin1String( "/vsi" ), Qt::CaseInsensitive ) && QgsGdalUtils::isVsiArchivePrefix( vsiPrefix ) ) { - if ( askUserForZipItemLayers( uri, { Qgis::LayerType::Vector} ) ) + if ( askUserForZipItemLayers( uri, { Qgis::LayerType::Vector } ) ) continue; } } @@ -396,20 +391,20 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis const auto scheme { QUrl( uri ).scheme() }; const bool isRemoteUrl { scheme.startsWith( QLatin1String( "http" ) ) || scheme == QLatin1String( "ftp" ) }; - std::unique_ptr< QgsTemporaryCursorOverride > cursorOverride; + std::unique_ptr cursorOverride; if ( isVsiCurl || isRemoteUrl ) { - cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor ); + cursorOverride = std::make_unique( Qt::WaitCursor ); QgisApp::instance()->visibleMessageBar()->pushInfo( QObject::tr( "Remote layer" ), QObject::tr( "loading %1, please wait …" ).arg( uri ) ); qApp->processEvents(); } - QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) )->querySublayers( uri, Qgis::SublayerQueryFlag::IncludeSystemTables ); + QList sublayers = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) )->querySublayers( uri, Qgis::SublayerQueryFlag::IncludeSystemTables ); // filter out non-vector sublayers - sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails & sublayer ) - { - return sublayer.type() != Qgis::LayerType::Vector; - } ), sublayers.end() ); + sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails &sublayer ) { + return sublayer.type() != Qgis::LayerType::Vector; + } ), + sublayers.end() ); cursorOverride.reset(); @@ -432,7 +427,7 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis case SublayerHandling::AskUser: { // prompt user for sublayers - QgsProviderSublayersDialog dlg( uri, QString(), path, sublayers, {Qgis::LayerType::Vector}, QgisApp::instance() ); + QgsProviderSublayersDialog dlg( uri, QString(), path, sublayers, { Qgis::LayerType::Vector }, QgisApp::instance() ); if ( dlg.exec() ) sublayers = dlg.selectedLayers(); @@ -449,10 +444,10 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis // requery sublayers, resolving geometry types sublayers = QgsProviderRegistry::instance()->querySublayers( uri, Qgis::SublayerQueryFlag::ResolveGeometryType ); // filter out non-vector sublayers - sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails & sublayer ) - { - return sublayer.type() != Qgis::LayerType::Vector; - } ), sublayers.end() ); + sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails &sublayer ) { + return sublayer.type() != Qgis::LayerType::Vector; + } ), + sublayers.end() ); } break; } @@ -467,10 +462,10 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis // requery sublayers, resolving geometry types sublayers = QgsProviderRegistry::instance()->querySublayers( uri, Qgis::SublayerQueryFlag::ResolveGeometryType ); // filter out non-vector sublayers - sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails & sublayer ) - { - return sublayer.type() != Qgis::LayerType::Vector; - } ), sublayers.end() ); + sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), []( const QgsProviderSublayerDetails &sublayer ) { + return sublayer.type() != Qgis::LayerType::Vector; + } ), + sublayers.end() ); } // now add sublayers @@ -478,15 +473,12 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis { addedLayers << addSublayers( sublayers, baseName, groupName ); } - } else { QString msg = QObject::tr( "%1 is not a valid or recognized data source." ).arg( uri ); // If the failed layer was a vsicurl type, give the user a chance to try the normal download. - if ( isVsiCurl && - QMessageBox::question( QgisApp::instance(), QObject::tr( "Invalid Data Source" ), - QObject::tr( "Download with \"Protocol\" source type has failed, do you want to try the \"File\" source type?" ) ) == QMessageBox::Yes ) + if ( isVsiCurl && QMessageBox::question( QgisApp::instance(), QObject::tr( "Invalid Data Source" ), QObject::tr( "Download with \"Protocol\" source type has failed, do you want to try the \"File\" source type?" ) ) == QMessageBox::Yes ) { QString fileUri = uri; fileUri.replace( QLatin1String( "/vsicurl/" ), " " ); @@ -523,7 +515,7 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis { if ( !encoding.isEmpty() ) { - if ( QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( l ) ) + if ( QgsVectorLayer *vl = qobject_cast( l ) ) vl->setProviderEncoding( encoding ); } } @@ -534,18 +526,18 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addOgrVectorLayers( const QStringLis template std::unique_ptr createLayer( const QString &uri, const QString &name, const QString &provider ) { - return std::make_unique< L >( uri, name, provider ); + return std::make_unique( uri, name, provider ); } -template <> +template<> std::unique_ptr createLayer( const QString &uri, const QString &name, const QString & ) { const QgsVectorTileLayer::LayerOptions options( QgsProject::instance()->transformContext() ); - return std::make_unique< QgsVectorTileLayer >( uri, name, options ); + return std::make_unique( uri, name, options ); } -template <> +template<> std::unique_ptr createLayer( const QString &uri, const QString &name, const QString &provider ) { - std::unique_ptr< QgsPluginLayer > layer( QgsApplication::pluginLayerRegistry()->createLayer( provider, uri ) ); + std::unique_ptr layer( QgsApplication::pluginLayerRegistry()->createLayer( provider, uri ) ); if ( !layer ) return nullptr; @@ -600,13 +592,13 @@ template QgsPluginLayer *QgsAppLayerHandling::addLayer( const QS bool QgsAppLayerHandling::askUserForZipItemLayers( const QString &path, const QList &acceptableTypes ) { // query sublayers - QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::IncludeSystemTables ); + QList sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::IncludeSystemTables ); // filter out non-matching sublayers - sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails & sublayer ) - { - return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() ); - } ), sublayers.end() ); + sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails &sublayer ) { + return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() ); + } ), + sublayers.end() ); if ( sublayers.empty() ) return false; @@ -639,10 +631,10 @@ bool QgsAppLayerHandling::askUserForZipItemLayers( const QString &path, const QL { // requery sublayers, resolving geometry types sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::ResolveGeometryType ); - sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails & sublayer ) - { - return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() ); - } ), sublayers.end() ); + sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails &sublayer ) { + return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() ); + } ), + sublayers.end() ); } break; } @@ -656,10 +648,10 @@ bool QgsAppLayerHandling::askUserForZipItemLayers( const QString &path, const QL { // requery sublayers, resolving geometry types sublayers = QgsProviderRegistry::instance()->querySublayers( path, Qgis::SublayerQueryFlag::ResolveGeometryType ); - sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails & sublayer ) - { - return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() ); - } ), sublayers.end() ); + sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [acceptableTypes]( const QgsProviderSublayerDetails &sublayer ) { + return !acceptableTypes.empty() && !acceptableTypes.contains( sublayer.type() ); + } ), + sublayers.end() ); } // now add sublayers @@ -772,7 +764,7 @@ QList QgsAppLayerHandling::addSublayers( const QList result; + QList result; result.reserve( sortedLayers.size() ); QgsOgrProviderUtils::DeferDatasetClosing deferDatasetClosing; @@ -819,8 +811,7 @@ QList QgsAppLayerHandling::addSublayers( const QListsetName( QStringLiteral( "%1 — %2" ).arg( baseName, layerName ) ); } @@ -835,7 +826,7 @@ QList QgsAppLayerHandling::addSublayers( const QListcrs(); - const QgsGui::ProjectCrsBehavior projectCrsBehavior = QgsSettings().enumValue( QStringLiteral( "/projections/newProjectCrsBehavior" ), QgsGui::UseCrsOfFirstLayerAdded, QgsSettings::App ); + const QgsGui::ProjectCrsBehavior projectCrsBehavior = QgsSettings().enumValue( QStringLiteral( "/projections/newProjectCrsBehavior" ), QgsGui::UseCrsOfFirstLayerAdded, QgsSettings::App ); switch ( projectCrsBehavior ) { case QgsGui::UseCrsOfFirstLayerAdded: @@ -875,11 +866,10 @@ QList QgsAppLayerHandling::addSublayers( const QList QgsAppLayerHandling::openLayer( const QString &fileName, bool &ok, bool allowInteractive, bool suppressBulkLayerPostProcessing, bool addToLegend ) +QList QgsAppLayerHandling::openLayer( const QString &fileName, bool &ok, bool allowInteractive, bool suppressBulkLayerPostProcessing, bool addToLegend ) { - QList< QgsMapLayer * > openedLayers; - auto postProcessAddedLayers = [suppressBulkLayerPostProcessing, &openedLayers] - { + QList openedLayers; + auto postProcessAddedLayers = [suppressBulkLayerPostProcessing, &openedLayers] { if ( !suppressBulkLayerPostProcessing ) QgsAppLayerHandling::postProcessAddedLayers( openedLayers ); }; @@ -888,7 +878,7 @@ QList< QgsMapLayer * > QgsAppLayerHandling::openLayer( const QString &fileName, const QFileInfo fileInfo( fileName ); // highest priority = delegate to provider registry to handle - const QList< QgsProviderRegistry::ProviderCandidateDetails > candidateProviders = QgsProviderRegistry::instance()->preferredProvidersForUri( fileName ); + const QList candidateProviders = QgsProviderRegistry::instance()->preferredProvidersForUri( fileName ); if ( candidateProviders.size() == 1 && candidateProviders.at( 0 ).layerTypes().size() == 1 ) { // one good candidate provider and possible layer type -- that makes things nice and easy! @@ -942,7 +932,7 @@ QList< QgsMapLayer * > QgsAppLayerHandling::openLayer( const QString &fileName, } } - QList< QgsProviderSublayerModel::NonLayerItem > nonLayerItems; + QList nonLayerItems; if ( QgsProjectStorage *ps = QgsApplication::projectStorageRegistry()->projectStorageFromUri( fileName ) ) { const QStringList projects = ps->listProjects( fileName ); @@ -958,7 +948,7 @@ QList< QgsMapLayer * > QgsAppLayerHandling::openLayer( const QString &fileName, } // query sublayers - QList< QgsProviderSublayerDetails > sublayers = QgsProviderRegistry::instance()->querySublayers( fileName, Qgis::SublayerQueryFlag::IncludeSystemTables ); + QList sublayers = QgsProviderRegistry::instance()->querySublayers( fileName, Qgis::SublayerQueryFlag::IncludeSystemTables ); if ( !sublayers.empty() || !nonLayerItems.empty() ) { @@ -1079,19 +1069,19 @@ QList< QgsMapLayer * > QgsAppLayerHandling::openLayer( const QString &fileName, return openedLayers; } -QListQgsAppLayerHandling::addVectorLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend ) +QList QgsAppLayerHandling::addVectorLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend ) { - return addLayerPrivate< QgsVectorLayer >( Qgis::LayerType::Vector, uri, baseName, !provider.isEmpty() ? provider : QLatin1String( "ogr" ), true, addToLegend ); + return addLayerPrivate( Qgis::LayerType::Vector, uri, baseName, !provider.isEmpty() ? provider : QLatin1String( "ogr" ), true, addToLegend ); } -QListQgsAppLayerHandling::addRasterLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend ) +QList QgsAppLayerHandling::addRasterLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend ) { - return addLayerPrivate< QgsRasterLayer >( Qgis::LayerType::Raster, uri, baseName, !provider.isEmpty() ? provider : QLatin1String( "gdal" ), true, addToLegend ); + return addLayerPrivate( Qgis::LayerType::Raster, uri, baseName, !provider.isEmpty() ? provider : QLatin1String( "gdal" ), true, addToLegend ); } -QListQgsAppLayerHandling::addMeshLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend ) +QList QgsAppLayerHandling::addMeshLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend ) { - return addLayerPrivate< QgsMeshLayer >( Qgis::LayerType::Mesh, uri, baseName, provider, true, addToLegend ); + return addLayerPrivate( Qgis::LayerType::Mesh, uri, baseName, provider, true, addToLegend ); } QList QgsAppLayerHandling::addGdalRasterLayers( const QStringList &uris, bool &ok, bool showWarningOnInvalid ) @@ -1108,7 +1098,7 @@ QList QgsAppLayerHandling::addGdalRasterLayers( const QStringList // be ogr layers. We'll set returnValue to false if one or more layers fail // to load. - QList< QgsMapLayer * > res; + QList res; for ( const QString &uri : uris ) { @@ -1118,8 +1108,8 @@ QList QgsAppLayerHandling::addGdalRasterLayers( const QStringList const QString vsiPrefix = QgsGdalUtils::vsiPrefixForPath( uri ); if ( ( !uri.startsWith( QLatin1String( "/vsi" ), Qt::CaseInsensitive ) || uri.endsWith( QLatin1String( ".zip" ) ) - || uri.endsWith( QLatin1String( ".tar" ) ) ) && - QgsGdalUtils::isVsiArchivePrefix( vsiPrefix ) ) + || uri.endsWith( QLatin1String( ".tar" ) ) ) + && QgsGdalUtils::isVsiArchivePrefix( vsiPrefix ) ) { if ( askUserForZipItemLayers( uri, { Qgis::LayerType::Raster } ) ) continue; @@ -1128,10 +1118,10 @@ QList QgsAppLayerHandling::addGdalRasterLayers( const QStringList const bool isVsiCurl { uri.startsWith( QLatin1String( "/vsicurl" ), Qt::CaseInsensitive ) }; const bool isRemoteUrl { uri.startsWith( QLatin1String( "http" ) ) || uri == QLatin1String( "ftp" ) }; - std::unique_ptr< QgsTemporaryCursorOverride > cursorOverride; + std::unique_ptr cursorOverride; if ( isVsiCurl || isRemoteUrl ) { - cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor ); + cursorOverride = std::make_unique( Qt::WaitCursor ); QgisApp::instance()->visibleMessageBar()->pushInfo( QObject::tr( "Remote layer" ), QObject::tr( "loading %1, please wait …" ).arg( uri ) ); qApp->processEvents(); } @@ -1143,9 +1133,9 @@ QList QgsAppLayerHandling::addGdalRasterLayers( const QStringList // set the layer name to the file base name unless provided explicitly QString layerName; const QVariantMap uriDetails = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "gdal" ), uri ); - if ( !uriDetails[ QStringLiteral( "layerName" ) ].toString().isEmpty() ) + if ( !uriDetails[QStringLiteral( "layerName" )].toString().isEmpty() ) { - layerName = uriDetails[ QStringLiteral( "layerName" ) ].toString(); + layerName = uriDetails[QStringLiteral( "layerName" )].toString(); } else { @@ -1154,7 +1144,7 @@ QList QgsAppLayerHandling::addGdalRasterLayers( const QStringList // try to create the layer cursorOverride.reset(); - const QList layersList { addLayerPrivate< QgsRasterLayer >( Qgis::LayerType::Raster, uri, layerName, QStringLiteral( "gdal" ), showWarningOnInvalid ) }; + const QList layersList { addLayerPrivate( Qgis::LayerType::Raster, uri, layerName, QStringLiteral( "gdal" ), showWarningOnInvalid ) }; // loop and cast for ( QgsRasterLayer *layer : std::as_const( layersList ) ) @@ -1162,7 +1152,7 @@ QList QgsAppLayerHandling::addGdalRasterLayers( const QStringList res.append( layer ); } - if ( ! layersList.isEmpty() && layersList.first()->isValid() ) + if ( !layersList.isEmpty() && layersList.first()->isValid() ) { //only allow one copy of a ai grid file to be loaded at a //time to prevent the user selecting all adfs in 1 dir which @@ -1249,8 +1239,8 @@ void QgsAppLayerHandling::openLayerDefinition( const QString &filename, const Qg if ( loaded ) { - const QList< QgsReadWriteContext::ReadWriteMessage > messages = context.takeMessages(); - QVector< QgsReadWriteContext::ReadWriteMessage > shownMessages; + const QList messages = context.takeMessages(); + QVector shownMessages; for ( const QgsReadWriteContext::ReadWriteMessage &message : messages ) { if ( shownMessages.contains( message ) ) @@ -1282,7 +1272,7 @@ void QgsAppLayerHandling::addLayerDefinition( const QgsLayerTreeRegistryBridge:: openLayerDefinition( path, insertPoint ); } -QList< QgsMapLayer * > QgsAppLayerHandling::addDatabaseLayers( const QStringList &layerPathList, const QString &providerKey, bool &ok ) +QList QgsAppLayerHandling::addDatabaseLayers( const QStringList &layerPathList, const QString &providerKey, bool &ok ) { ok = false; QList myList; @@ -1310,7 +1300,7 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addDatabaseLayers( const QStringList QgsVectorLayer *layer = new QgsVectorLayer( uri.uri( false ), uri.table(), providerKey, options ); Q_CHECK_PTR( layer ); - if ( ! layer ) + if ( !layer ) { QApplication::restoreOverrideCursor(); @@ -1355,7 +1345,7 @@ QList< QgsMapLayer * > QgsAppLayerHandling::addDatabaseLayers( const QStringList } template -QListQgsAppLayerHandling::addLayerPrivate( Qgis::LayerType type, const QString &uri, const QString &name, const QString &providerKey, bool guiWarnings, bool addToLegend ) +QList QgsAppLayerHandling::addLayerPrivate( Qgis::LayerType type, const QString &uri, const QString &name, const QString &providerKey, bool guiWarnings, bool addToLegend ) { QgsSettings settings; @@ -1379,28 +1369,26 @@ QListQgsAppLayerHandling::addLayerPrivate( Qgis::LayerType type, const QStr { // run layer path through QgsPathResolver so that all inbuilt paths and other localised paths are correctly expanded path = QgsPathResolver().readPath( uriElements.value( QStringLiteral( "path" ) ).toString() ); - uriElements[ QStringLiteral( "path" ) ] = path; + uriElements[QStringLiteral( "path" )] = path; } // Not all providers implement decodeUri(), so use original uri if uriElements is empty const QString updatedUri = uriElements.isEmpty() ? uri : QgsProviderRegistry::instance()->encodeUri( providerKey, uriElements ); QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( providerKey ); - const bool canQuerySublayers = providerMetadata && - ( providerMetadata->capabilities() & QgsProviderMetadata::QuerySublayers ); + const bool canQuerySublayers = providerMetadata && ( providerMetadata->capabilities() & QgsProviderMetadata::QuerySublayers ); QList result; if ( canQuerySublayers ) { // query sublayers - QList< QgsProviderSublayerDetails > sublayers = providerMetadata ? - providerMetadata->querySublayers( updatedUri, Qgis::SublayerQueryFlag::IncludeSystemTables ) - : QgsProviderRegistry::instance()->querySublayers( updatedUri ); + QList sublayers = providerMetadata ? providerMetadata->querySublayers( updatedUri, Qgis::SublayerQueryFlag::IncludeSystemTables ) + : QgsProviderRegistry::instance()->querySublayers( updatedUri ); // filter out non-matching sublayers - sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [type]( const QgsProviderSublayerDetails & sublayer ) - { - return sublayer.type() != type; - } ), sublayers.end() ); + sublayers.erase( std::remove_if( sublayers.begin(), sublayers.end(), [type]( const QgsProviderSublayerDetails &sublayer ) { + return sublayer.type() != type; + } ), + sublayers.end() ); if ( sublayers.empty() ) { @@ -1420,13 +1408,13 @@ QListQgsAppLayerHandling::addLayerPrivate( Qgis::LayerType type, const QStr { case SublayerHandling::AskUser: { - QgsProviderSublayersDialog dlg( updatedUri, providerKey, path, sublayers, {type}, QgisApp::instance() ); + QgsProviderSublayersDialog dlg( updatedUri, providerKey, path, sublayers, { type }, QgisApp::instance() ); QString groupName = providerMetadata->suggestGroupNameForUri( uri ); if ( !groupName.isEmpty() ) dlg.setGroupName( groupName ); if ( dlg.exec() ) { - const QList< QgsProviderSublayerDetails > selectedLayers = dlg.selectedLayers(); + const QList selectedLayers = dlg.selectedLayers(); if ( !selectedLayers.isEmpty() ) { const QList layers { addSublayers( selectedLayers, baseName, dlg.groupName(), addToLegend ) }; @@ -1455,7 +1443,7 @@ QListQgsAppLayerHandling::addLayerPrivate( Qgis::LayerType type, const QStr { const QList layers { addSublayers( sublayers, name, QString(), addToLegend ) }; - if ( ! layers.isEmpty() ) + if ( !layers.isEmpty() ) { QString base( baseName ); if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() ) @@ -1476,8 +1464,8 @@ QListQgsAppLayerHandling::addLayerPrivate( Qgis::LayerType type, const QStr // contain at most one single layer QgsMapLayerFactory::LayerOptions options( QgsProject::instance()->transformContext() ); options.loadDefaultStyle = false; - result.push_back( qobject_cast< T * >( QgsMapLayerFactory::createLayer( uri, name, type, options, providerKey ) ) ); - if ( ! result.isEmpty() ) + result.push_back( qobject_cast( QgsMapLayerFactory::createLayer( uri, name, type, options, providerKey ) ) ); + if ( !result.isEmpty() ) { QString base( baseName ); if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() ) @@ -1512,13 +1500,10 @@ const QList QgsAppLayerHandling::findBrokenLayerDependencies( for ( const QgsVectorLayerRef &dependency : constDependencies ) { // I guess we need and isNull()/isValid() method for the ref - if ( dependency.layer || - ! dependency.name.isEmpty() || - ! dependency.source.isEmpty() || - ! dependency.layerId.isEmpty() ) + if ( dependency.layer || !dependency.name.isEmpty() || !dependency.source.isEmpty() || !dependency.layerId.isEmpty() ) { const QgsVectorLayer *depVl { QgsVectorLayerRef( dependency ).resolveWeakly( QgsProject::instance(), matchType ) }; - if ( ! depVl || ! depVl->isValid() ) + if ( !depVl || !depVl->isValid() ) { brokenDependencies.append( dependency ); } @@ -1534,7 +1519,7 @@ const QList QgsAppLayerHandling::findBrokenLayerDependencies( const QList weakRelations { vl->weakRelations() }; for ( const QgsWeakRelation &weakRelation : weakRelations ) { - QList< QgsVectorLayerRef > dependencies; + QList dependencies; if ( !( dependencyFlags & DependencyFlag::LoadAllRelationships ) ) { @@ -1587,7 +1572,7 @@ const QList QgsAppLayerHandling::findBrokenLayerDependencies( break; } } - if ( ! refFound ) + if ( !refFound ) { brokenDependencies.append( dependency ); } @@ -1617,7 +1602,7 @@ void QgsAppLayerHandling::resolveVectorLayerDependencies( QgsVectorLayer *vl, Qg { // Retrieve the DB connection (if any) - std::unique_ptr< QgsAbstractDatabaseProviderConnection > conn { QgsMapLayerUtils::databaseConnection( vl ) }; + std::unique_ptr conn { QgsMapLayerUtils::databaseConnection( vl ) }; if ( conn ) { QString tableSchema; @@ -1639,12 +1624,11 @@ void QgsAppLayerHandling::resolveVectorLayerDependencies( QgsVectorLayer *vl, Qg } // Helper to find layers in connections - auto layerFinder = [ &conn, &dependency, &providerName ]( const QString & tableSchema, const QString & tableName ) -> QgsVectorLayer * - { + auto layerFinder = [&conn, &dependency, &providerName]( const QString &tableSchema, const QString &tableName ) -> QgsVectorLayer * { // First try the current schema (or no schema if it's not supported from the provider) try { - const QString layerUri { conn->tableUri( tableSchema, tableName )}; + const QString layerUri { conn->tableUri( tableSchema, tableName ) }; // Aggressive doesn't mean stupid: check if a layer with the same URI // was already loaded, this catches a corner case for renamed/moved GPKGS // where the dependency was actually loaded but it was found as broken @@ -1658,10 +1642,10 @@ void QgsAppLayerHandling::resolveVectorLayerDependencies( QgsVectorLayer *vl, Qg } } // Load it! - std::unique_ptr< QgsVectorLayer > newVl = std::make_unique< QgsVectorLayer >( layerUri, !dependency.name.isEmpty() ? dependency.name : tableName, providerName ); + std::unique_ptr newVl = std::make_unique( layerUri, !dependency.name.isEmpty() ? dependency.name : tableName, providerName ); if ( newVl->isValid() ) { - return qobject_cast< QgsVectorLayer *>( QgsProject::instance()->addMapLayer( newVl.release() ) ); + return qobject_cast( QgsProject::instance()->addMapLayer( newVl.release() ) ); } } catch ( QgsProviderConnectionException & ) @@ -1674,7 +1658,7 @@ void QgsAppLayerHandling::resolveVectorLayerDependencies( QgsVectorLayer *vl, Qg loadedLayer = layerFinder( tableSchema, tableName ); // Try different schemas - if ( ! loadedLayer && conn->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::Schemas ) && ! tableSchema.isEmpty() ) + if ( !loadedLayer && conn->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::Schemas ) && !tableSchema.isEmpty() ) { const QStringList schemas { conn->schemas() }; for ( const QString &schemaName : schemas ) @@ -1691,16 +1675,14 @@ void QgsAppLayerHandling::resolveVectorLayerDependencies( QgsVectorLayer *vl, Qg } } } - if ( ! loadedLayer ) + if ( !loadedLayer ) { const QString msg { QObject::tr( "layer '%1' requires layer '%2' to be loaded but '%2' could not be found, please load it manually if possible." ).arg( vl->name(), dependency.name ) }; QgisApp::instance()->messageBar()->pushWarning( QObject::tr( "Missing layer form dependency" ), msg ); } else if ( !( dependencyFlags & DependencyFlag::SilentLoad ) ) { - QgisApp::instance()->messageBar()->pushSuccess( QObject::tr( "Missing layer form dependency" ), QObject::tr( "Layer dependency '%2' required by '%1' was automatically loaded." ) - .arg( vl->name(), - loadedLayer->name() ) ); + QgisApp::instance()->messageBar()->pushSuccess( QObject::tr( "Missing layer form dependency" ), QObject::tr( "Layer dependency '%2' required by '%1' was automatically loaded." ).arg( vl->name(), loadedLayer->name() ) ); } } } @@ -1710,10 +1692,10 @@ void QgsAppLayerHandling::resolveVectorLayerWeakRelations( QgsVectorLayer *vecto { if ( vectorLayer && vectorLayer->isValid() ) { - const QList constWeakRelations { vectorLayer->weakRelations( ) }; + const QList constWeakRelations { vectorLayer->weakRelations() }; for ( const QgsWeakRelation &rel : constWeakRelations ) { - const QList< QgsRelation > relations { rel.resolvedRelations( QgsProject::instance(), matchType ) }; + const QList relations { rel.resolvedRelations( QgsProject::instance(), matchType ) }; for ( const QgsRelation &relation : relations ) { if ( relation.isValid() ) @@ -1740,9 +1722,8 @@ void QgsAppLayerHandling::resolveVectorLayerWeakRelations( QgsVectorLayer *vecto void QgsAppLayerHandling::onVectorLayerStyleLoaded( QgsVectorLayer *vl, QgsMapLayer::StyleCategories categories ) { - if ( vl && vl->isValid( ) ) + if ( vl && vl->isValid() ) { - // Check broken dependencies in forms if ( categories.testFlag( QgsMapLayer::StyleCategory::Forms ) ) { @@ -1756,4 +1737,3 @@ void QgsAppLayerHandling::onVectorLayerStyleLoaded( QgsVectorLayer *vl, QgsMapLa } } } - diff --git a/src/app/layers/qgsapplayerhandling.h b/src/app/layers/qgsapplayerhandling.h index 6df5b3f78ce8..ebce129ce8a2 100644 --- a/src/app/layers/qgsapplayerhandling.h +++ b/src/app/layers/qgsapplayerhandling.h @@ -38,7 +38,6 @@ class APP_EXPORT QgsAppLayerHandling Q_GADGET public: - enum class SublayerHandling { AskUser, @@ -59,11 +58,7 @@ class APP_EXPORT QgsAppLayerHandling * If \a showWarningOnInvalid layers is TRUE then a user facing warning will be raised * if a uri does not result in a valid layer. */ - template< typename L> static L *addLayer( const QString &uri, - const QString &baseName, - const QString &provider, - bool addToLegend = true, - bool showWarningOnInvalid = true ); + template static L *addLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend = true, bool showWarningOnInvalid = true ); /** * Adds a vector layer from a given \a uri and \a provider. @@ -76,7 +71,7 @@ class APP_EXPORT QgsAppLayerHandling * \note This may trigger a dialog asking users to select from available sublayers in the datasource, * depending on the contents of the datasource and the user's current QGIS settings. */ - static QList< QgsVectorLayer * >addVectorLayer( const QString &uri, const QString &baseName, const QString &provider = QLatin1String( "ogr" ), bool addToLegend = true ); + static QList addVectorLayer( const QString &uri, const QString &baseName, const QString &provider = QLatin1String( "ogr" ), bool addToLegend = true ); /** * Adds a list of vector layers from a list of layer \a uris supported by the OGR provider. @@ -87,7 +82,7 @@ class APP_EXPORT QgsAppLayerHandling * If \a showWarningOnInvalid layers is TRUE then a user facing warning will be raised * if a uri does not result in a valid vector layer. */ - static QList< QgsMapLayer * > addOgrVectorLayers( const QStringList &uris, const QString &encoding, const QString &dataSourceType, bool &ok, bool showWarningOnInvalid = true ); + static QList addOgrVectorLayers( const QStringList &uris, const QString &encoding, const QString &dataSourceType, bool &ok, bool showWarningOnInvalid = true ); /** * Adds a raster layer from a given \a uri and \a provider. @@ -100,7 +95,7 @@ class APP_EXPORT QgsAppLayerHandling * \note This may trigger a dialog asking users to select from available sublayers in the datasource, * depending on the contents of the datasource and the user's current QGIS settings. */ - static QListaddRasterLayer( QString const &uri, const QString &baseName, const QString &provider = QLatin1String( "gdal" ), bool addToLegend = true ); + static QList addRasterLayer( QString const &uri, const QString &baseName, const QString &provider = QLatin1String( "gdal" ), bool addToLegend = true ); /** * Adds a list of raster layers from a list of layer \a uris supported by the GDAL provider. @@ -111,7 +106,7 @@ class APP_EXPORT QgsAppLayerHandling * If \a showWarningOnInvalid layers is TRUE then a user facing warning will be raised * if a uri does not result in a valid vector layer. */ - static QList< QgsMapLayer * > addGdalRasterLayers( const QStringList &uris, bool &ok, bool showWarningOnInvalid = true ); + static QList addGdalRasterLayers( const QStringList &uris, bool &ok, bool showWarningOnInvalid = true ); /** * Adds a mesh layer from a given \a uri and \a provider. @@ -124,7 +119,7 @@ class APP_EXPORT QgsAppLayerHandling * \note This may trigger a dialog asking users to select from available sublayers in the datasource, * depending on the contents of the datasource and the user's current QGIS settings. */ - static QList< QgsMeshLayer *>addMeshLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend = true ); + static QList addMeshLayer( const QString &uri, const QString &baseName, const QString &provider, bool addToLegend = true ); /** * Post processes an entire group of added \a layers. @@ -133,9 +128,9 @@ class APP_EXPORT QgsAppLayerHandling * method has been called for each layer in turn. All added layers will already * have been added to the project. */ - static void postProcessAddedLayers( const QList< QgsMapLayer * > &layers ); + static void postProcessAddedLayers( const QList &layers ); - static void addSortedLayersToLegend( QList< QgsMapLayer * > &layers ); + static void addSortedLayersToLegend( QList &layers ); /** * Open a map layer from a file. @@ -145,7 +140,7 @@ class APP_EXPORT QgsAppLayerHandling * * \returns a list of added map layers if the file is successfully opened */ - static QList< QgsMapLayer * > openLayer( const QString &fileName, bool &ok, bool allowInteractive = false, bool suppressBulkLayerPostProcessing = false, bool addToLegend = true ); + static QList openLayer( const QString &fileName, bool &ok, bool allowInteractive = false, bool suppressBulkLayerPostProcessing = false, bool addToLegend = true ); //! Add a 'pre-made' map layer to the project static void addMapLayer( QgsMapLayer *mapLayer, bool addToLegend = true ); @@ -164,7 +159,7 @@ class APP_EXPORT QgsAppLayerHandling static void addLayerDefinition( const QgsLayerTreeRegistryBridge::InsertionPoint *insertPoint ); //! Add a list of database layers to the map - static QList< QgsMapLayer * > addDatabaseLayers( const QStringList &layerPathList, const QString &providerKey, bool &ok ); + static QList addDatabaseLayers( const QStringList &layerPathList, const QString &providerKey, bool &ok ); /** * Flags which control the behavior of loading layer dependencies. @@ -172,7 +167,7 @@ class APP_EXPORT QgsAppLayerHandling enum class DependencyFlag : int { LoadAllRelationships = 1 << 1, //!< Causes all relationships to be loaded, regardless of whether the originating table is the referenced or referencing table. By default relationships are only loaded when the originating table is the referencing table. - SilentLoad = 1 << 2, //!< Dependencies are loaded without any user-visible notifications. + SilentLoad = 1 << 2, //!< Dependencies are loaded without any user-visible notifications. }; Q_ENUM( DependencyFlag ) Q_DECLARE_FLAGS( DependencyFlags, DependencyFlag ) @@ -185,10 +180,7 @@ class APP_EXPORT QgsAppLayerHandling * categories ("Forms" for the form widgets and "Relations" for layer weak relations). * \return a list of weak references to broken layer dependencies */ - static const QList< QgsVectorLayerRef > findBrokenLayerDependencies( QgsVectorLayer *vectorLayer, - QgsMapLayer::StyleCategories categories = QgsMapLayer::StyleCategory::AllStyleCategories, - QgsVectorLayerRef::MatchType matchType = QgsVectorLayerRef::MatchType::Name, - DependencyFlags dependencyFlags = DependencyFlags() ); + static const QList findBrokenLayerDependencies( QgsVectorLayer *vectorLayer, QgsMapLayer::StyleCategories categories = QgsMapLayer::StyleCategory::AllStyleCategories, QgsVectorLayerRef::MatchType matchType = QgsVectorLayerRef::MatchType::Name, DependencyFlags dependencyFlags = DependencyFlags() ); /** * Scans the \a vectorLayer for broken dependencies and automatically @@ -197,10 +189,7 @@ class APP_EXPORT QgsAppLayerHandling * used to exclude one of the currently implemented search categories * ("Forms" for the form widgets and "Relations" for layer weak relations). */ - static void resolveVectorLayerDependencies( QgsVectorLayer *vectorLayer, - QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories, - QgsVectorLayerRef::MatchType matchType = QgsVectorLayerRef::MatchType::Name, - DependencyFlags dependencyFlags = DependencyFlags() ); + static void resolveVectorLayerDependencies( QgsVectorLayer *vectorLayer, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories, QgsVectorLayerRef::MatchType matchType = QgsVectorLayerRef::MatchType::Name, DependencyFlags dependencyFlags = DependencyFlags() ); /** * Scans the \a vectorLayer for weak relations and automatically @@ -221,8 +210,7 @@ class APP_EXPORT QgsAppLayerHandling static void onVectorLayerStyleLoaded( QgsVectorLayer *vl, const QgsMapLayer::StyleCategories categories ); private: - - template static QListaddLayerPrivate( Qgis::LayerType type, const QString &uri, const QString &baseName, const QString &providerKey, bool guiWarnings = true, bool addToLegend = true ); + template static QList addLayerPrivate( Qgis::LayerType type, const QString &uri, const QString &baseName, const QString &providerKey, bool guiWarnings = true, bool addToLegend = true ); /** * Post processes a single added \a layer, applying any default behavior which should @@ -238,12 +226,11 @@ class APP_EXPORT QgsAppLayerHandling * This method will open a dialog so the user can select GDAL sublayers to load * \returns TRUE if any items were loaded */ - static bool askUserForZipItemLayers( const QString &path, const QList< Qgis::LayerType > &acceptableTypes ); - - static SublayerHandling shouldAskUserForSublayers( const QList< QgsProviderSublayerDetails > &layers, bool hasNonLayerItems = false ); + static bool askUserForZipItemLayers( const QString &path, const QList &acceptableTypes ); - static QList< QgsMapLayer * > addSublayers( const QList< QgsProviderSublayerDetails> &layers, const QString &baseName, const QString &groupName, bool addToLegend = true ); + static SublayerHandling shouldAskUserForSublayers( const QList &layers, bool hasNonLayerItems = false ); + static QList addSublayers( const QList &layers, const QString &baseName, const QString &groupName, bool addToLegend = true ); }; Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAppLayerHandling::DependencyFlags ); diff --git a/src/app/layout/qgslayout3dmapwidget.cpp b/src/app/layout/qgslayout3dmapwidget.cpp index c1efed1b1100..55441701f0b0 100644 --- a/src/app/layout/qgslayout3dmapwidget.cpp +++ b/src/app/layout/qgslayout3dmapwidget.cpp @@ -26,21 +26,20 @@ float _normalizedAngle( float x ) { x = std::fmod( x, 360 ); - if ( x < 0 ) x += 360; + if ( x < 0 ) + x += 360; return x; } -void _prepare3DViewsMenu( QMenu *menu, QgsLayout3DMapWidget *w, const std::function< void( Qgs3DMapCanvasWidget * ) > &slot ) +void _prepare3DViewsMenu( QMenu *menu, QgsLayout3DMapWidget *w, const std::function &slot ) { - QObject::connect( menu, &QMenu::aboutToShow, w, [menu, slot] - { + QObject::connect( menu, &QMenu::aboutToShow, w, [menu, slot] { const QList lst = QgisApp::instance()->get3DMapViews(); menu->clear(); for ( Qgs3DMapCanvasWidget *widget : lst ) { QAction *a = new QAction( widget->canvasName(), menu ); menu->addAction( a ); - QObject::connect( a, &QAction::triggered, a, [slot, widget] - { + QObject::connect( a, &QAction::triggered, a, [slot, widget] { slot( widget ); } ); } @@ -68,14 +67,13 @@ QgsLayout3DMapWidget::QgsLayout3DMapWidget( QgsLayoutItem3DMap *map3D ) mMenu3DCanvases = new QMenu( this ); mCopySettingsButton->setMenu( mMenu3DCanvases ); - _prepare3DViewsMenu( mMenu3DCanvases, this, [ = ]( Qgs3DMapCanvasWidget * widget ) - { + _prepare3DViewsMenu( mMenu3DCanvases, this, [=]( Qgs3DMapCanvasWidget *widget ) { copy3DMapSettings( widget ); } ); mMenu3DCanvasesPose = new QMenu( this ); mPoseFromViewButton->setMenu( mMenu3DCanvasesPose ); - _prepare3DViewsMenu( mMenu3DCanvasesPose, this, [ = ]( Qgs3DMapCanvasWidget * widget ) { copyCameraPose( widget ); } ); + _prepare3DViewsMenu( mMenu3DCanvasesPose, this, [=]( Qgs3DMapCanvasWidget *widget ) { copyCameraPose( widget ); } ); QList lst; lst << mCenterXSpinBox << mCenterYSpinBox << mCenterZSpinBox << mDistanceToCenterSpinBox << mPitchAngleSpinBox << mHeadingAngleSpinBox; @@ -143,7 +141,7 @@ void QgsLayout3DMapWidget::updateCameraPose() bool QgsLayout3DMapWidget::setNewItem( QgsLayoutItem *item ) { - QgsLayoutItem3DMap *newItem = qobject_cast< QgsLayoutItem3DMap * >( item ); + QgsLayoutItem3DMap *newItem = qobject_cast( item ); if ( !newItem ) return false; diff --git a/src/app/layout/qgslayout3dmapwidget.h b/src/app/layout/qgslayout3dmapwidget.h index dcce789ddec5..6bb7a5c77fef 100644 --- a/src/app/layout/qgslayout3dmapwidget.h +++ b/src/app/layout/qgslayout3dmapwidget.h @@ -44,7 +44,7 @@ class QgsLayout3DMapWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayo void updateCameraPose(); private: - QPointer< QgsLayoutItem3DMap > mMap3D; + QPointer mMap3D; QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr; QMenu *mMenu3DCanvases = nullptr; QMenu *mMenu3DCanvasesPose = nullptr; diff --git a/src/app/layout/qgslayoutappmenuprovider.cpp b/src/app/layout/qgslayoutappmenuprovider.cpp index a82829761991..831ba469e721 100644 --- a/src/app/layout/qgslayoutappmenuprovider.cpp +++ b/src/app/layout/qgslayoutappmenuprovider.cpp @@ -29,7 +29,6 @@ QgsLayoutAppMenuProvider::QgsLayoutAppMenuProvider( QgsLayoutDesignerDialog *des : QObject( nullptr ) , mDesigner( designer ) { - } QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout *layout, QPointF layoutPoint ) const @@ -42,22 +41,21 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * menu->addSeparator(); - const QList< QgsLayoutItem * > selectedItems = layout->selectedLayoutItems(); + const QList selectedItems = layout->selectedLayoutItems(); if ( !selectedItems.empty() ) { bool addedGroupAction = false; if ( selectedItems.count() > 1 ) { QAction *groupAction = new QAction( tr( "Group" ), menu ); - connect( groupAction, &QAction::triggered, this, [this]() - { + connect( groupAction, &QAction::triggered, this, [this]() { mDesigner->view()->groupSelectedItems(); } ); menu->addAction( groupAction ); addedGroupAction = true; } bool foundSelectedGroup = false; - QList< QgsLayoutItemGroup * > groups; + QList groups; layout->layoutItems( groups ); for ( QgsLayoutItemGroup *group : std::as_const( groups ) ) { @@ -70,8 +68,7 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * if ( foundSelectedGroup ) { QAction *ungroupAction = new QAction( tr( "Ungroup" ), menu ); - connect( ungroupAction, &QAction::triggered, this, [this]() - { + connect( ungroupAction, &QAction::triggered, this, [this]() { mDesigner->view()->ungroupSelectedItems(); } ); menu->addAction( ungroupAction ); @@ -82,14 +79,12 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * menu->addSeparator(); QAction *copyAction = new QAction( tr( "Copy" ), menu ); - connect( copyAction, &QAction::triggered, this, [this]() - { + connect( copyAction, &QAction::triggered, this, [this]() { mDesigner->view()->copySelectedItems( QgsLayoutView::ClipboardCopy ); } ); menu->addAction( copyAction ); QAction *cutAction = new QAction( tr( "Cut" ), menu ); - connect( cutAction, &QAction::triggered, this, [this]() - { + connect( cutAction, &QAction::triggered, this, [this]() { mDesigner->view()->copySelectedItems( QgsLayoutView::ClipboardCut ); } ); menu->addAction( cutAction ); @@ -98,8 +93,7 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * else if ( mDesigner->view()->hasItemsInClipboard() ) { QAction *pasteAction = new QAction( tr( "Paste" ), menu ); - connect( pasteAction, &QAction::triggered, this, [this, menu]() - { + connect( pasteAction, &QAction::triggered, this, [this, menu]() { QPointF pt = mDesigner->view()->mapToScene( mDesigner->view()->mapFromGlobal( menu->pos() ) ); mDesigner->view()->pasteItems( pt ); } ); @@ -113,8 +107,7 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * { const int pageNumber = layout->pageCollection()->pageNumber( page ); QAction *pagePropertiesAction = new QAction( tr( "Page Properties…" ), menu ); - connect( pagePropertiesAction, &QAction::triggered, this, [this, page]() - { + connect( pagePropertiesAction, &QAction::triggered, this, [this, page]() { mDesigner->showItemOptions( page, true ); } ); menu->addAction( pagePropertiesAction ); @@ -122,9 +115,8 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * if ( mDesigner->guideWidget() ) { QAction *manageGuidesAction = new QAction( tr( "Manage Guides for Page…" ), menu ); - QPointer< QgsLayoutGuideWidget > guideManager( mDesigner->guideWidget() ); - connect( manageGuidesAction, &QAction::triggered, this, [this, pageNumber, guideManager]() - { + QPointer guideManager( mDesigner->guideWidget() ); + connect( manageGuidesAction, &QAction::triggered, this, [this, pageNumber, guideManager]() { if ( guideManager ) { guideManager->setCurrentPage( pageNumber ); @@ -134,11 +126,8 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * menu->addAction( manageGuidesAction ); } QAction *removePageAction = new QAction( tr( "Remove Page" ), menu ); - connect( removePageAction, &QAction::triggered, this, [layout, page]() - { - if ( QMessageBox::question( nullptr, tr( "Remove Page" ), - tr( "Remove page from layout?" ), - QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + connect( removePageAction, &QAction::triggered, this, [layout, page]() { + if ( QMessageBox::question( nullptr, tr( "Remove Page" ), tr( "Remove page from layout?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { layout->pageCollection()->deletePage( page ); } @@ -154,8 +143,7 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * { QAction *itemPropertiesAction = new QAction( tr( "Item Properties…" ), menu ); QgsLayoutItem *item = selectedItems.at( 0 ); - connect( itemPropertiesAction, &QAction::triggered, this, [this, item]() - { + connect( itemPropertiesAction, &QAction::triggered, this, [this, item]() { mDesigner->showItemOptions( item, true ); } ); menu->addAction( itemPropertiesAction ); diff --git a/src/app/layout/qgslayoutappmenuprovider.h b/src/app/layout/qgslayoutappmenuprovider.h index 1f3748fb803c..6d851c7b5203 100644 --- a/src/app/layout/qgslayoutappmenuprovider.h +++ b/src/app/layout/qgslayoutappmenuprovider.h @@ -30,15 +30,12 @@ class QgsLayoutAppMenuProvider : public QObject, public QgsLayoutViewMenuProvide Q_OBJECT public: - QgsLayoutAppMenuProvider( QgsLayoutDesignerDialog *designer ); QMenu *createContextMenu( QWidget *parent, QgsLayout *layout, QPointF layoutPoint ) const override; private: - QgsLayoutDesignerDialog *mDesigner = nullptr; - }; #endif // QGSLAYOUTAPPMENUPROVIDER_H diff --git a/src/app/layout/qgslayoutdesignerdialog.cpp b/src/app/layout/qgslayoutdesignerdialog.cpp index 230ffd1328d8..0c1b3dc4425a 100644 --- a/src/app/layout/qgslayoutdesignerdialog.cpp +++ b/src/app/layout/qgslayoutdesignerdialog.cpp @@ -253,7 +253,6 @@ void QgsAppLayoutDesignerInterface::activateTool( QgsLayoutDesignerInterface::St if ( !mDesigner->mActionEditNodesItem->isChecked() ) mDesigner->mActionEditNodesItem->trigger(); break; - } } @@ -281,7 +280,6 @@ static bool cmpByText_( QAction *a, QAction *b ) class QgsAtlasExportGuard { public: - QgsAtlasExportGuard( QgsLayoutDesignerDialog *dialog ) : mDialog( dialog ) { @@ -301,7 +299,6 @@ class QgsAtlasExportGuard private: QgsLayoutDesignerDialog *mDialog = nullptr; - }; @@ -329,8 +326,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla QgsGui::enableAutoGeometryRestore( this ); mScreenHelper = new QgsScreenHelper( this ); - connect( mScreenHelper, &QgsScreenHelper::screenDpiChanged, this, [ = ]( double ) - { + connect( mScreenHelper, &QgsScreenHelper::screenDpiChanged, this, [=]( double ) { updateStatusZoom(); } ); @@ -343,7 +339,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mMessageBar = new QgsMessageBar( centralWidget() ); mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); - static_cast< QGridLayout * >( centralWidget()->layout() )->addWidget( mMessageBar, 0, 0, 1, 1, Qt::AlignTop ); + static_cast( centralWidget()->layout() )->addWidget( mMessageBar, 0, 0, 1, 1, Qt::AlignTop ); mHorizontalRuler = new QgsLayoutRuler( nullptr, Qt::Horizontal ); mVerticalRuler = new QgsLayoutRuler( nullptr, Qt::Vertical ); @@ -420,8 +416,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mActionPageSetup->setVisible( false ); #endif - connect( mActionOptions, &QAction::triggered, this, [ = ] - { + connect( mActionOptions, &QAction::triggered, this, [=] { QgisApp::instance()->showOptionsDialog( this, QStringLiteral( "mOptionsPageComposer" ) ); } ); @@ -440,7 +435,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla connect( mActionClose, &QAction::triggered, this, &QWidget::close ); // populate with initial items... - const QList< int > itemMetadataIds = QgsGui::layoutItemGuiRegistry()->itemMetadataIds(); + const QList itemMetadataIds = QgsGui::layoutItemGuiRegistry()->itemMetadataIds(); for ( int id : itemMetadataIds ) { itemTypeAdded( id ); @@ -450,14 +445,12 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mDynamicTextMenu = new QMenu( tr( "Add Dynamic Text" ), this ); - connect( mDynamicTextMenu, &QMenu::aboutToShow, this, [ = ] - { + connect( mDynamicTextMenu, &QMenu::aboutToShow, this, [=] { mDynamicTextMenu->clear(); if ( mLayout ) { // we need to rebuild this on each show, as the content varies depending on other available items... - QgsLayoutLabelWidget::buildInsertDynamicTextMenu( mLayout, mDynamicTextMenu, [ = ]( const QString & expression ) - { + QgsLayoutLabelWidget::buildInsertDynamicTextMenu( mLayout, mDynamicTextMenu, [=]( const QString &expression ) { activateNewItemCreationTool( QgsGui::layoutItemGuiRegistry()->metadataIdForItemType( QgsLayoutItemRegistry::LayoutLabel ), false ); QVariantMap properties; properties.insert( QStringLiteral( "expression" ), expression ); @@ -578,28 +571,28 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mPanTool = new QgsLayoutViewToolPan( mView ); mPanTool->setAction( mActionPan ); mToolsActionGroup->addAction( mActionPan ); - connect( mActionPan, &QAction::triggered, mPanTool, [ = ] { mView->setTool( mPanTool ); } ); + connect( mActionPan, &QAction::triggered, mPanTool, [=] { mView->setTool( mPanTool ); } ); mZoomTool = new QgsLayoutViewToolZoom( mView ); mZoomTool->setAction( mActionZoomTool ); mToolsActionGroup->addAction( mActionZoomTool ); - connect( mActionZoomTool, &QAction::triggered, mZoomTool, [ = ] { mView->setTool( mZoomTool ); } ); + connect( mActionZoomTool, &QAction::triggered, mZoomTool, [=] { mView->setTool( mZoomTool ); } ); mSelectTool = new QgsLayoutViewToolSelect( mView ); mSelectTool->setAction( mActionSelectMoveItem ); mToolsActionGroup->addAction( mActionSelectMoveItem ); - connect( mActionSelectMoveItem, &QAction::triggered, mSelectTool, [ = ] { mView->setTool( mSelectTool ); } ); + connect( mActionSelectMoveItem, &QAction::triggered, mSelectTool, [=] { mView->setTool( mSelectTool ); } ); // after creating an item with the add item tool, switch immediately to select tool - connect( mAddItemTool, &QgsLayoutViewToolAddItem::createdItem, this, [ = ] { mView->setTool( mSelectTool ); } ); - connect( mAddNodeItemTool, &QgsLayoutViewToolAddNodeItem::createdItem, this, [ = ] { mView->setTool( mSelectTool ); } ); + connect( mAddItemTool, &QgsLayoutViewToolAddItem::createdItem, this, [=] { mView->setTool( mSelectTool ); } ); + connect( mAddNodeItemTool, &QgsLayoutViewToolAddNodeItem::createdItem, this, [=] { mView->setTool( mSelectTool ); } ); mNodesTool = new QgsLayoutViewToolEditNodes( mView ); mNodesTool->setAction( mActionEditNodesItem ); mToolsActionGroup->addAction( mActionEditNodesItem ); - connect( mActionEditNodesItem, &QAction::triggered, mNodesTool, [ = ] { mView->setTool( mNodesTool ); } ); + connect( mActionEditNodesItem, &QAction::triggered, mNodesTool, [=] { mView->setTool( mNodesTool ); } ); mMoveContentTool = new QgsLayoutViewToolMoveItemContent( mView ); mMoveContentTool->setAction( mActionMoveItemContent ); mToolsActionGroup->addAction( mActionMoveItemContent ); - connect( mActionMoveItemContent, &QAction::triggered, mMoveContentTool, [ = ] { mView->setTool( mMoveContentTool ); } ); + connect( mActionMoveItemContent, &QAction::triggered, mMoveContentTool, [=] { mView->setTool( mMoveContentTool ); } ); //Ctrl+= should also trigger zoom in QShortcut *ctrlEquals = new QShortcut( QKeySequence( QStringLiteral( "Ctrl+=" ) ), this ); @@ -619,32 +612,26 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla #endif mActionPreviewModeOff->setChecked( true ); - connect( mActionPreviewModeOff, &QAction::triggered, this, [ = ] - { + connect( mActionPreviewModeOff, &QAction::triggered, this, [=] { mView->setPreviewModeEnabled( false ); } ); - connect( mActionPreviewModeMono, &QAction::triggered, this, [ = ] - { + connect( mActionPreviewModeMono, &QAction::triggered, this, [=] { mView->setPreviewMode( QgsPreviewEffect::PreviewMono ); mView->setPreviewModeEnabled( true ); } ); - connect( mActionPreviewModeGrayscale, &QAction::triggered, this, [ = ] - { + connect( mActionPreviewModeGrayscale, &QAction::triggered, this, [=] { mView->setPreviewMode( QgsPreviewEffect::PreviewGrayscale ); mView->setPreviewModeEnabled( true ); } ); - connect( mActionPreviewProtanope, &QAction::triggered, this, [ = ] - { + connect( mActionPreviewProtanope, &QAction::triggered, this, [=] { mView->setPreviewMode( QgsPreviewEffect::PreviewProtanope ); mView->setPreviewModeEnabled( true ); } ); - connect( mActionPreviewDeuteranope, &QAction::triggered, this, [ = ] - { + connect( mActionPreviewDeuteranope, &QAction::triggered, this, [=] { mView->setPreviewMode( QgsPreviewEffect::PreviewDeuteranope ); mView->setPreviewModeEnabled( true ); } ); - connect( mActionPreviewTritanope, &QAction::triggered, this, [ = ] - { + connect( mActionPreviewTritanope, &QAction::triggered, this, [=] { mView->setPreviewMode( QgsPreviewEffect::PreviewTritanope ); mView->setPreviewModeEnabled( true ); } ); @@ -678,80 +665,61 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla connect( mActionLowerItems, &QAction::triggered, this, &QgsLayoutDesignerDialog::lowerSelectedItems ); connect( mActionMoveItemsToTop, &QAction::triggered, this, &QgsLayoutDesignerDialog::moveSelectedItemsToTop ); connect( mActionMoveItemsToBottom, &QAction::triggered, this, &QgsLayoutDesignerDialog::moveSelectedItemsToBottom ); - connect( mActionAlignLeft, &QAction::triggered, this, [ = ] - { + connect( mActionAlignLeft, &QAction::triggered, this, [=] { mView->alignSelectedItems( QgsLayoutAligner::AlignLeft ); } ); - connect( mActionAlignHCenter, &QAction::triggered, this, [ = ] - { + connect( mActionAlignHCenter, &QAction::triggered, this, [=] { mView->alignSelectedItems( QgsLayoutAligner::AlignHCenter ); } ); - connect( mActionAlignRight, &QAction::triggered, this, [ = ] - { + connect( mActionAlignRight, &QAction::triggered, this, [=] { mView->alignSelectedItems( QgsLayoutAligner::AlignRight ); } ); - connect( mActionAlignTop, &QAction::triggered, this, [ = ] - { + connect( mActionAlignTop, &QAction::triggered, this, [=] { mView->alignSelectedItems( QgsLayoutAligner::AlignTop ); } ); - connect( mActionAlignVCenter, &QAction::triggered, this, [ = ] - { + connect( mActionAlignVCenter, &QAction::triggered, this, [=] { mView->alignSelectedItems( QgsLayoutAligner::AlignVCenter ); } ); - connect( mActionAlignBottom, &QAction::triggered, this, [ = ] - { + connect( mActionAlignBottom, &QAction::triggered, this, [=] { mView->alignSelectedItems( QgsLayoutAligner::AlignBottom ); } ); - connect( mActionDistributeLeft, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeLeft, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeLeft ); } ); - connect( mActionDistributeHCenter, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeHCenter, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeHCenter ); } ); - connect( mActionDistributeHSpace, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeHSpace, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeHSpace ); } ); - connect( mActionDistributeRight, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeRight, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeRight ); } ); - connect( mActionDistributeTop, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeTop, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeTop ); } ); - connect( mActionDistributeVCenter, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeVCenter, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeVCenter ); } ); - connect( mActionDistributeVSpace, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeVSpace, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeVSpace ); } ); - connect( mActionDistributeBottom, &QAction::triggered, this, [ = ] - { + connect( mActionDistributeBottom, &QAction::triggered, this, [=] { mView->distributeSelectedItems( QgsLayoutAligner::DistributeBottom ); } ); - connect( mActionResizeNarrowest, &QAction::triggered, this, [ = ] - { + connect( mActionResizeNarrowest, &QAction::triggered, this, [=] { mView->resizeSelectedItems( QgsLayoutAligner::ResizeNarrowest ); } ); - connect( mActionResizeWidest, &QAction::triggered, this, [ = ] - { + connect( mActionResizeWidest, &QAction::triggered, this, [=] { mView->resizeSelectedItems( QgsLayoutAligner::ResizeWidest ); } ); - connect( mActionResizeShortest, &QAction::triggered, this, [ = ] - { + connect( mActionResizeShortest, &QAction::triggered, this, [=] { mView->resizeSelectedItems( QgsLayoutAligner::ResizeShortest ); } ); - connect( mActionResizeTallest, &QAction::triggered, this, [ = ] - { + connect( mActionResizeTallest, &QAction::triggered, this, [=] { mView->resizeSelectedItems( QgsLayoutAligner::ResizeTallest ); } ); - connect( mActionResizeToSquare, &QAction::triggered, this, [ = ] - { + connect( mActionResizeToSquare, &QAction::triggered, this, [=] { mView->resizeSelectedItems( QgsLayoutAligner::ResizeToSquare ); } ); @@ -773,19 +741,16 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mActionHidePanels->setChecked( !docksTitle.isEmpty() ); connect( mActionHidePanels, &QAction::toggled, this, &QgsLayoutDesignerDialog::setPanelVisibility ); - connect( mActionDeleteSelection, &QAction::triggered, this, [ = ] - { + connect( mActionDeleteSelection, &QAction::triggered, this, [=] { if ( mView->tool() == mNodesTool ) mNodesTool->deleteSelectedNode(); else mView->deleteSelectedItems(); } ); - connect( mActionGroupItems, &QAction::triggered, this, [ = ] - { + connect( mActionGroupItems, &QAction::triggered, this, [=] { mView->groupSelectedItems(); } ); - connect( mActionUngroupItems, &QAction::triggered, this, [ = ] - { + connect( mActionUngroupItems, &QAction::triggered, this, [=] { mView->ungroupSelectedItems(); } ); @@ -795,8 +760,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mActionCut->setShortcuts( QKeySequence::Cut ); mActionCut->setStatusTip( tr( "Cut" ) ); mActionCut->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionEditCut.svg" ) ) ); - connect( mActionCut, &QAction::triggered, this, [ = ] - { + connect( mActionCut, &QAction::triggered, this, [=] { mView->copySelectedItems( QgsLayoutView::ClipboardCut ); } ); @@ -804,8 +768,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mActionCopy->setShortcuts( QKeySequence::Copy ); mActionCopy->setStatusTip( tr( "Copy" ) ); mActionCopy->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionEditCopy.svg" ) ) ); - connect( mActionCopy, &QAction::triggered, this, [ = ] - { + connect( mActionCopy, &QAction::triggered, this, [=] { mView->copySelectedItems( QgsLayoutView::ClipboardCopy ); } ); @@ -883,8 +846,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla connect( mHorizontalRuler, &QgsLayoutRuler::cursorPosChanged, this, &QgsLayoutDesignerDialog::updateStatusCursorPos ); connect( mVerticalRuler, &QgsLayoutRuler::cursorPosChanged, this, &QgsLayoutDesignerDialog::updateStatusCursorPos ); - connect( mView, &QgsLayoutView::itemFocused, this, [ = ]( QgsLayoutItem * item ) - { + connect( mView, &QgsLayoutView::itemFocused, this, [=]( QgsLayoutItem *item ) { showItemOptions( item, false ); } ); @@ -910,8 +872,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mGeneralPropertiesStack = new QgsPanelWidgetStack(); mGeneralDock->setWidget( mGeneralPropertiesStack ); mPanelsMenu->addAction( mGeneralDock->toggleViewAction() ); - connect( mActionLayoutProperties, &QAction::triggered, this, [ = ] - { + connect( mActionLayoutProperties, &QAction::triggered, this, [=] { mGeneralDock->setUserVisible( true ); } ); @@ -928,8 +889,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mGuideStack = new QgsPanelWidgetStack(); mGuideDock->setWidget( mGuideStack ); mPanelsMenu->addAction( mGuideDock->toggleViewAction() ); - connect( mActionManageGuides, &QAction::triggered, this, [ = ] - { + connect( mActionManageGuides, &QAction::triggered, this, [=] { mGuideDock->setUserVisible( true ); } ); @@ -1013,7 +973,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla // Create the shortcuts manager mShortcutsManager = new QgsShortcutsManager( this, "LayoutDesigner/shortcuts/" ); mShortcutsManager->registerAllChildren( this ); - mShortcutsDialog = new QgsConfigureShortcutsDialog( this, mShortcutsManager ) ; + mShortcutsDialog = new QgsConfigureShortcutsDialog( this, mShortcutsManager ); connect( mActionKeyboardShortcuts, &QAction::triggered, mShortcutsDialog, &QDialog::show ); restoreWindowState(); @@ -1060,15 +1020,15 @@ QgsAppLayoutDesignerInterface *QgsLayoutDesignerDialog::iface() QMenu *QgsLayoutDesignerDialog::createPopupMenu() { QMenu *menu = QMainWindow::createPopupMenu(); - QList< QAction * > al = menu->actions(); - QList< QAction * > panels, toolbars; + QList al = menu->actions(); + QList panels, toolbars; if ( !al.isEmpty() ) { bool found = false; for ( int i = 0; i < al.size(); ++i ) { - if ( al[ i ]->isSeparator() ) + if ( al[i]->isSeparator() ) { found = true; continue; @@ -1076,11 +1036,11 @@ QMenu *QgsLayoutDesignerDialog::createPopupMenu() if ( !found ) { - panels.append( al[ i ] ); + panels.append( al[i] ); } else { - toolbars.append( al[ i ] ); + toolbars.append( al[i] ); } } @@ -1094,8 +1054,7 @@ QMenu *QgsLayoutDesignerDialog::createPopupMenu() const auto constPanels = panels; for ( QAction *a : constPanels ) { - if ( ( a == mAtlasDock->toggleViewAction() && !dynamic_cast< QgsPrintLayout * >( mMasterLayout ) ) || - ( a == mReportDock->toggleViewAction() && !dynamic_cast< QgsReport * >( mMasterLayout ) ) ) + if ( ( a == mAtlasDock->toggleViewAction() && !dynamic_cast( mMasterLayout ) ) || ( a == mReportDock->toggleViewAction() && !dynamic_cast( mMasterLayout ) ) ) { a->setVisible( false ); } @@ -1121,8 +1080,7 @@ QMenu *QgsLayoutDesignerDialog::createPopupMenu() const auto constToolbars = toolbars; for ( QAction *a : constToolbars ) { - if ( ( a == mAtlasToolbar->toggleViewAction() && !dynamic_cast< QgsPrintLayout * >( mMasterLayout ) ) || - ( a == mReportToolbar->toggleViewAction() && !dynamic_cast< QgsReport * >( mMasterLayout ) ) ) + if ( ( a == mAtlasToolbar->toggleViewAction() && !dynamic_cast( mMasterLayout ) ) || ( a == mReportToolbar->toggleViewAction() && !dynamic_cast( mMasterLayout ) ) ) { a->setVisible( false ); } @@ -1145,7 +1103,7 @@ void QgsLayoutDesignerDialog::showGuideDock( bool show ) std::unique_ptr QgsLayoutDesignerDialog::lastExportResults() const { - return mLastExportResults ? std::make_unique< QgsLayoutDesignerInterface::ExportResults>( *mLastExportResults ) : nullptr; + return mLastExportResults ? std::make_unique( *mLastExportResults ) : nullptr; } @@ -1164,26 +1122,25 @@ void QgsLayoutDesignerDialog::setMasterLayout( QgsMasterLayoutInterface *layout { mMasterLayout = layout; - QObject *obj = dynamic_cast< QObject * >( mMasterLayout ); + QObject *obj = dynamic_cast( mMasterLayout ); if ( obj ) - connect( obj, &QObject::destroyed, this, [ = ] - { - this->close(); - } ); + connect( obj, &QObject::destroyed, this, [=] { + this->close(); + } ); setTitle( mMasterLayout->name() ); - if ( QgsPrintLayout *l = dynamic_cast< QgsPrintLayout * >( layout ) ) + if ( QgsPrintLayout *l = dynamic_cast( layout ) ) { connect( l, &QgsPrintLayout::nameChanged, this, &QgsLayoutDesignerDialog::setTitle ); setCurrentLayout( l ); } - else if ( QgsReport *r = dynamic_cast< QgsReport * >( layout ) ) + else if ( QgsReport *r = dynamic_cast( layout ) ) { connect( r, &QgsReport::nameChanged, this, &QgsLayoutDesignerDialog::setTitle ); } - if ( dynamic_cast< QgsPrintLayout * >( layout ) ) + if ( dynamic_cast( layout ) ) { createAtlasWidget(); } @@ -1200,7 +1157,7 @@ void QgsLayoutDesignerDialog::setMasterLayout( QgsMasterLayoutInterface *layout mToolbarMenu->removeAction( mAtlasToolbar->toggleViewAction() ); } - if ( dynamic_cast< QgsReport * >( layout ) ) + if ( dynamic_cast( layout ) ) { createReportWidget(); mLayoutMenu->removeAction( mActionExportAsPDF ); @@ -1247,7 +1204,7 @@ void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout ) if ( mLayout ) { disconnect( mLayout, &QgsLayout::backgroundTaskCountChanged, this, &QgsLayoutDesignerDialog::backgroundTaskCountChanged ); - QList< QgsLayoutItemMap * > maps; + QList maps; mLayout->layoutItems( maps ); for ( QgsLayoutItemMap *map : std::as_const( maps ) ) { @@ -1276,8 +1233,7 @@ void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout ) mLayoutToolbar->addAction( mRedoAction ); connect( mLayout->undoStack(), &QgsLayoutUndoStack::undoRedoOccurredForItems, this, &QgsLayoutDesignerDialog::undoRedoOccurredForItems ); - connect( mActionClearGuides, &QAction::triggered, &mLayout->guides(), [ = ] - { + connect( mActionClearGuides, &QAction::triggered, &mLayout->guides(), [=] { mLayout->guides().clear(); } ); @@ -1299,7 +1255,7 @@ void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout ) connect( mLayout, &QgsLayout::backgroundTaskCountChanged, this, &QgsLayoutDesignerDialog::backgroundTaskCountChanged ); - QList< QgsLayoutItemMap * > maps; + QList maps; mLayout->layoutItems( maps ); for ( QgsLayoutItemMap *map : std::as_const( maps ) ) { @@ -1348,7 +1304,7 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa return; } - if ( auto widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack->mainPanel() ) ) + if ( auto widget = qobject_cast( mItemPropertiesStack->mainPanel() ) ) { const QgsLayoutObject *currentItem = widget->layoutObject(); if ( currentItem == item ) @@ -1375,17 +1331,17 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa } } - std::unique_ptr< QgsLayoutItemBaseWidget > widget( QgsGui::layoutItemGuiRegistry()->createItemWidget( item ) ); + std::unique_ptr widget( QgsGui::layoutItemGuiRegistry()->createItemWidget( item ) ); delete mItemPropertiesStack->takeMainPanel(); - if ( ! widget ) + if ( !widget ) return; widget->setDesignerInterface( iface() ); widget->setReportTypeString( reportTypeString() ); widget->setMasterLayout( mMasterLayout ); - if ( QgsLayoutPagePropertiesWidget *ppWidget = qobject_cast< QgsLayoutPagePropertiesWidget * >( widget.get() ) ) + if ( QgsLayoutPagePropertiesWidget *ppWidget = qobject_cast( widget.get() ) ) connect( ppWidget, &QgsLayoutPagePropertiesWidget::pageOrientationChanged, this, &QgsLayoutDesignerDialog::pageOrientationChanged ); widget->setDockMode( true ); @@ -1394,7 +1350,6 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa mItemPropertiesStack->setMainPanel( widget.release() ); if ( bringPanelToFront ) mItemDock->setUserVisible( true ); - } void QgsLayoutDesignerDialog::open() @@ -1407,8 +1362,7 @@ void QgsLayoutDesignerDialog::open() // zoomFull() does not work properly until window has fully shown. // It's not enough to just call show on it, because the view widget won't be fully // resized to its final size until a little later...! - QTimer::singleShot( 100, this, [ = ] - { + QTimer::singleShot( 100, this, [=] { mView->zoomFull(); mView->setPaintingEnabled( true ); } ); @@ -1522,7 +1476,7 @@ void QgsLayoutDesignerDialog::setPanelVisibility( bool hidden ) for ( QTabBar *tabBar : tabBars ) { QString currentTabTitle = tabBar->tabText( tabBar->currentIndex() ); - mPanelStatus[ currentTabTitle ].isActive = true; + mPanelStatus[currentTabTitle].isActive = true; } } else @@ -1612,7 +1566,7 @@ void QgsLayoutDesignerDialog::dropEvent( QDropEvent *event ) // get the file list QList::iterator i; - QListurls = event->mimeData()->urls(); + QList urls = event->mimeData()->urls(); QStringList files; for ( i = urls.begin(); i != urls.end(); ++i ) { @@ -1627,11 +1581,10 @@ void QgsLayoutDesignerDialog::dropEvent( QDropEvent *event ) QPointF layoutPoint = mView->mapToScene( mView->mapFromGlobal( mapToGlobal( event->pos() ) ) ); - connect( timer, &QTimer::timeout, this, [this, timer, files, layoutPoint] - { + connect( timer, &QTimer::timeout, this, [this, timer, files, layoutPoint] { for ( const QString &file : std::as_const( files ) ) { - const QVector> handlers = QgisApp::instance()->customLayoutDropHandlers(); + const QVector> handlers = QgisApp::instance()->customLayoutDropHandlers(); for ( QgsLayoutCustomDropHandler *handler : handlers ) { if ( handler && handler->handleFileDrop( iface(), layoutPoint, file ) ) @@ -1788,8 +1741,7 @@ void QgsLayoutDesignerDialog::itemTypeAdded( int id ) } } - connect( action, &QAction::triggered, this, [this, id, nodeBased]() - { + connect( action, &QAction::triggered, this, [this, id, nodeBased]() { activateNewItemCreationTool( id, nodeBased ); } ); } @@ -1855,7 +1807,7 @@ void QgsLayoutDesignerDialog::updateStatusZoom() zoomLevel = mView->transform().m11() * 100 / scale100; } whileBlocking( mStatusZoomCombo )->lineEdit()->setText( tr( "%1%" ).arg( zoomLevel, 0, 'f', 1 ) ); - whileBlocking( mStatusZoomSlider )->setValue( static_cast< int >( zoomLevel ) ); + whileBlocking( mStatusZoomSlider )->setValue( static_cast( zoomLevel ) ); } void QgsLayoutDesignerDialog::updateStatusCursorPos( QPointF position ) @@ -1907,7 +1859,6 @@ void QgsLayoutDesignerDialog::addPages() case QgsLayoutAddPagesDialog::AtEnd: firstPagePosition = mLayout->pageCollection()->pageCount(); break; - } if ( dlg.numberPages() > 1 ) @@ -1920,7 +1871,6 @@ void QgsLayoutDesignerDialog::addPages() } if ( dlg.numberPages() > 1 ) mLayout->undoStack()->endMacro(); - } } @@ -1979,10 +1929,11 @@ void QgsLayoutDesignerDialog::saveAsTemplate() this->raise(); #endif QString saveFileName = QFileDialog::getSaveFileName( - this, - tr( "Save template" ), - lastSaveDir, - tr( "Layout templates" ) + " (*.qpt *.QPT)" ); + this, + tr( "Save template" ), + lastSaveDir, + tr( "Layout templates" ) + " (*.qpt *.QPT)" + ); if ( saveFileName.isEmpty() ) return; @@ -2033,7 +1984,7 @@ void QgsLayoutDesignerDialog::addItemsFromTemplate() if ( templateDoc.setContent( &templateFile ) ) { bool ok = false; - QList< QgsLayoutItem * > items = currentLayout()->loadFromTemplate( templateDoc, context, false, &ok ); + QList items = currentLayout()->loadFromTemplate( templateDoc, context, false, &ok ); if ( !ok ) { QMessageBox::warning( this, tr( "Load from Template" ), tr( "Could not read template file." ) ); @@ -2068,8 +2019,7 @@ void QgsLayoutDesignerDialog::duplicate() if ( !newDialog ) { - QMessageBox::warning( this, tr( "Duplicate Layout" ), - tr( "Layout duplication failed." ) ); + QMessageBox::warning( this, tr( "Duplicate Layout" ), tr( "Layout duplication failed." ) ); } } @@ -2103,8 +2053,7 @@ void QgsLayoutDesignerDialog::showManager() // NOTE: Avoid crash where composer that spawned modal manager from toolbar ends up // being deleted by user, but event loop tries to return to layout on manager close // (does not seem to be an issue for menu action) - QTimer::singleShot( 0, this, [ = ] - { + QTimer::singleShot( 0, this, [=] { QgisApp::instance()->showLayoutManager(); } ); } @@ -2122,8 +2071,7 @@ void QgsLayoutDesignerDialog::renameLayout() void QgsLayoutDesignerDialog::deleteLayout() { - if ( QMessageBox::question( this, tr( "Delete Layout" ), tr( "Are you sure you want to delete the layout “%1”?" ).arg( masterLayout()->name() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( this, tr( "Delete Layout" ), tr( "Are you sure you want to delete the layout “%1”?" ).arg( masterLayout()->name() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; masterLayout()->layoutProject()->layoutManager()->removeLayout( masterLayout() ); @@ -2197,9 +2145,7 @@ void QgsLayoutDesignerDialog::print() { message = tr( "Successfully printed layout." ); } - mMessageBar->pushMessage( tr( "Print layout" ), - message, - Qgis::MessageLevel::Success ); + mMessageBar->pushMessage( tr( "Print layout" ), message, Qgis::MessageLevel::Success ); break; } @@ -2219,10 +2165,7 @@ void QgsLayoutDesignerDialog::print() message = tr( "Could not create print device." ); } cursorOverride.release(); - QMessageBox::warning( this, tr( "Print Layout" ), - message, - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Print Layout" ), message, QMessageBox::Ok, QMessageBox::Ok ); break; } @@ -2240,9 +2183,7 @@ void QgsLayoutDesignerDialog::print() "resulted in a memory overflow.\n\n" "Please try a lower resolution or a smaller paper size." ); } - QMessageBox::warning( this, tr( "Memory Allocation Error" ), - message, - QMessageBox::Ok, QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Memory Allocation Error" ), message, QMessageBox::Ok, QMessageBox::Ok ); break; } @@ -2318,9 +2259,7 @@ void QgsLayoutDesignerDialog::exportToRaster() switch ( result ) { case QgsLayoutExporter::Success: - mMessageBar->pushMessage( tr( "Export layout" ), - tr( "Successfully exported layout to %2" ).arg( QUrl::fromLocalFile( fileNExt.first ).toString(), QDir::toNativeSeparators( fileNExt.first ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export layout" ), tr( "Successfully exported layout to %2" ).arg( QUrl::fromLocalFile( fileNExt.first ).toString(), QDir::toNativeSeparators( fileNExt.first ) ), Qgis::MessageLevel::Success, 0 ); // Open exported file in the default viewer if enabled if ( QgsLayoutExporter::settingOpenAfterExportingImage->value() ) @@ -2338,23 +2277,20 @@ void QgsLayoutDesignerDialog::exportToRaster() case QgsLayoutExporter::FileError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Image Export Error" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot write to %1.\n\nThis file may be open in another application." ).arg( QDir::toNativeSeparators( exporter.errorFile() ) ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Image Export Error" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot write to %1.\n\nThis file may be open in another application." ).arg( QDir::toNativeSeparators( exporter.errorFile() ) ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Image Export Error" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Trying to create image %1 (%2×%3 @ %4dpi ) " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ) - .arg( QDir::toNativeSeparators( exporter.errorFile() ) ).arg( imageSize.width() ).arg( imageSize.height() ).arg( settings.dpi ), + QMessageBox::warning( this, tr( "Image Export Error" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Trying to create image %1 (%2×%3 @ %4dpi ) " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ) + .arg( QDir::toNativeSeparators( exporter.errorFile() ) ) + .arg( imageSize.width() ) + .arg( imageSize.height() ) + .arg( settings.dpi ), QMessageBox::Ok, QMessageBox::Ok ); break; - - } mView->setPaintingEnabled( true ); } @@ -2397,10 +2333,11 @@ void QgsLayoutDesignerDialog::exportToPdf() this->raise(); #endif outputFileName = QFileDialog::getSaveFileName( - this, - tr( "Export to PDF" ), - outputFileName, - tr( "PDF Format" ) + " (*.pdf *.PDF)" ); + this, + tr( "Export to PDF" ), + outputFileName, + tr( "PDF Format" ) + " (*.pdf *.PDF)" + ); this->activateWindow(); if ( outputFileName.isEmpty() ) { @@ -2439,9 +2376,7 @@ void QgsLayoutDesignerDialog::exportToPdf() { case QgsLayoutExporter::Success: { - mMessageBar->pushMessage( tr( "Export layout" ), - tr( "Successfully exported layout to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export layout" ), tr( "Successfully exported layout to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), Qgis::MessageLevel::Success, 0 ); // Open exported file in the default viewer if enabled if ( QgsLayoutExporter::settingOpenAfterExportingPdf->value() ) @@ -2453,27 +2388,20 @@ void QgsLayoutDesignerDialog::exportToPdf() case QgsLayoutExporter::FileError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Export to PDF" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot write to %1.\n\nThis file may be open in another application." ).arg( outputFileName ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export to PDF" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot write to %1.\n\nThis file may be open in another application." ).arg( outputFileName ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::PrintError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Export to PDF" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Could not create print device." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export to PDF" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Could not create print device." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Export to PDF" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Exporting the PDF " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Export to PDF" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Exporting the PDF " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; @@ -2517,10 +2445,11 @@ void QgsLayoutDesignerDialog::exportToSvg() this->raise(); #endif outputFileName = QFileDialog::getSaveFileName( - this, - tr( "Export to SVG" ), - outputFileName, - tr( "SVG Format" ) + " (*.svg *.SVG)" ); + this, + tr( "Export to SVG" ), + outputFileName, + tr( "SVG Format" ) + " (*.svg *.SVG)" + ); this->activateWindow(); if ( outputFileName.isEmpty() ) { @@ -2557,9 +2486,7 @@ void QgsLayoutDesignerDialog::exportToSvg() { case QgsLayoutExporter::Success: { - mMessageBar->pushMessage( tr( "Export layout" ), - tr( "Successfully exported layout to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export layout" ), tr( "Successfully exported layout to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), Qgis::MessageLevel::Success, 0 ); // Open exported file in the default viewer if enabled if ( QgsLayoutExporter::settingOpenAfterExportingSvg->value() ) @@ -2571,35 +2498,25 @@ void QgsLayoutDesignerDialog::exportToSvg() case QgsLayoutExporter::FileError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Export to SVG" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot write to %1.\n\nThis file may be open in another application." ).arg( outputFileName ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export to SVG" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot write to %1.\n\nThis file may be open in another application." ).arg( outputFileName ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::SvgLayerError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Export to SVG" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot create layered SVG file %1." ).arg( outputFileName ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export to SVG" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Cannot create layered SVG file %1." ).arg( outputFileName ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::PrintError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Export to SVG" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Could not create print device." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export to SVG" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Could not create print device." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Export to SVG" ), - !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Exporting the SVG " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Export to SVG" ), !exporter.errorMessage().isEmpty() ? exporter.errorMessage() : tr( "Exporting the SVG " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; @@ -2614,7 +2531,7 @@ void QgsLayoutDesignerDialog::exportToSvg() void QgsLayoutDesignerDialog::atlasPreviewTriggered( bool checked ) { - QgsPrintLayout *printLayout = qobject_cast< QgsPrintLayout * >( mLayout ); + QgsPrintLayout *printLayout = qobject_cast( mLayout ); if ( !printLayout ) return; QgsLayoutAtlas *atlas = printLayout->atlas(); @@ -2623,8 +2540,7 @@ void QgsLayoutDesignerDialog::atlasPreviewTriggered( bool checked ) if ( checked && !atlas->enabled() ) { //no atlas current enabled - mMessageBar->pushWarning( tr( "Atlas" ), - tr( "Atlas is not enabled for this layout!" ) ); + mMessageBar->pushWarning( tr( "Atlas" ), tr( "Atlas is not enabled for this layout!" ) ); whileBlocking( mActionAtlasPreview )->setChecked( false ); return; } @@ -2688,7 +2604,7 @@ void QgsLayoutDesignerDialog::atlasPageComboEditingFinished() } bool ok = ( page > 0 ); - QgsPrintLayout *printLayout = qobject_cast< QgsPrintLayout * >( mLayout ); + QgsPrintLayout *printLayout = qobject_cast( mLayout ); if ( !printLayout ) return; QgsLayoutAtlas *atlas = printLayout->atlas(); @@ -2796,16 +2712,15 @@ void QgsLayoutDesignerDialog::printAtlas() printSettings.predefinedMapScales = QgsLayoutUtils::predefinedScales( mLayout ); QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Printing maps…" ), tr( "Abort" ), 0, 100, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Printing maps…" ), tr( "Abort" ), 0, 100, this ); progressDialog->setWindowTitle( tr( "Printing Atlas" ) ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Printing “%1”" ).arg( mMasterLayout->name() ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double progress ) - { - progressDialog->setValue( static_cast< int >( progress ) ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double progress ) { + progressDialog->setValue( static_cast( progress ) ); + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); proxyTask->setProxyProgress( progress ); @@ -2818,10 +2733,8 @@ void QgsLayoutDesignerDialog::printAtlas() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); @@ -2842,15 +2755,13 @@ void QgsLayoutDesignerDialog::printAtlas() QString message; if ( !printerName.isEmpty() ) { - message = tr( "Successfully printed atlas to %1." ).arg( printerName ); + message = tr( "Successfully printed atlas to %1." ).arg( printerName ); } else { message = tr( "Successfully printed atlas." ); } - mMessageBar->pushMessage( tr( "Print atlas" ), - message, - Qgis::MessageLevel::Success ); + mMessageBar->pushMessage( tr( "Print atlas" ), message, Qgis::MessageLevel::Success ); break; } @@ -2863,35 +2774,28 @@ void QgsLayoutDesignerDialog::printAtlas() } else if ( !printerName.isEmpty() ) { - message = tr( "Could not create print device for %1." ).arg( printerName ); + message = tr( "Could not create print device for %1." ).arg( printerName ); } else { message = tr( "Could not create print device." ); } cursorOverride.release(); - QMessageBox::warning( this, tr( "Print Atlas" ), - message, - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Print Atlas" ), message, QMessageBox::Ok, QMessageBox::Ok ); break; } case QgsLayoutExporter::MemoryError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Print Atlas" ), - !error.isEmpty() ? error : tr( "Printing the layout " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Print Atlas" ), !error.isEmpty() ? error : tr( "Printing the layout " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::IteratorError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Print Atlas" ), - !error.isEmpty() ? error : tr( "Error encountered while printing atlas." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Print Atlas" ), !error.isEmpty() ? error : tr( "Error encountered while printing atlas." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::FileError: @@ -2916,20 +2820,14 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster() if ( !printAtlas->coverageLayer() ) { - QMessageBox::warning( this, tr( "Export Atlas" ), - tr( "Error: No coverage layer is set." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas" ), tr( "Error: No coverage layer is set." ), QMessageBox::Ok, QMessageBox::Ok ); return; } // else, it has an atlas to render, so a directory must first be selected if ( printAtlas->filenameExpression().isEmpty() ) { - int res = QMessageBox::warning( nullptr, tr( "Export Atlas as Image" ), - tr( "The filename expression is empty. A default one will be used instead." ), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Ok ); + int res = QMessageBox::warning( nullptr, tr( "Export Atlas as Image" ), tr( "The filename expression is empty. A default one will be used instead." ), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok ); if ( res == QMessageBox::Cancel ) { return; @@ -2941,13 +2839,12 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster() { // Validate filename expression QString errorString; - if ( ! printAtlas->setFilenameExpression( printAtlas->filenameExpression(), errorString ) ) + if ( !printAtlas->setFilenameExpression( printAtlas->filenameExpression(), errorString ) ) { - QMessageBox::warning( nullptr, tr( "Export Atlas" ), - tr( "Output file name expression is not valid. Canceling.\n" - "Evaluation error: %1" ).arg( errorString ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( nullptr, tr( "Export Atlas" ), tr( "Output file name expression is not valid. Canceling.\n" + "Evaluation error: %1" ) + .arg( errorString ), + QMessageBox::Ok, QMessageBox::Ok ); return; } } @@ -2980,10 +2877,7 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster() // test directory (if it exists and is writable) if ( !QDir( dir ).exists() || !QFileInfo( dir ).isWritable() ) { - QMessageBox::warning( nullptr, tr( "Export Atlas" ), - tr( "Unable to write into the given output directory. Canceling." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( nullptr, tr( "Export Atlas" ), tr( "Unable to write into the given output directory. Canceling." ), QMessageBox::Ok, QMessageBox::Ok ); return; } @@ -3008,16 +2902,15 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster() QgsAtlasExportGuard exportingAtlas( this ); QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Rendering maps…" ), tr( "Abort" ), 0, 100, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Rendering maps…" ), tr( "Abort" ), 0, 100, this ); progressDialog->setWindowTitle( tr( "Exporting Atlas" ) ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Exporting “%1”" ).arg( mMasterLayout->name() ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double progress ) - { - progressDialog->setValue( static_cast< int >( progress ) ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double progress ) { + progressDialog->setValue( static_cast( progress ) ); + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); proxyTask->setProxyProgress( progress ); @@ -3030,10 +2923,8 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); @@ -3050,16 +2941,11 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster() switch ( result ) { case QgsLayoutExporter::Success: - mMessageBar->pushMessage( tr( "Export atlas" ), - tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export atlas" ), tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), Qgis::MessageLevel::Success, 0 ); break; case QgsLayoutExporter::IteratorError: - QMessageBox::warning( this, tr( "Export Atlas as Image" ), - !error.isEmpty() ? error : tr( "Error encountered while exporting atlas." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as Image" ), !error.isEmpty() ? error : tr( "Error encountered while exporting atlas." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::PrintError: @@ -3069,18 +2955,16 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster() break; case QgsLayoutExporter::FileError: - QMessageBox::warning( this, tr( "Export Atlas as Image" ), - error, - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as Image" ), error, QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: - QMessageBox::warning( this, tr( "Export Atlas as Image" ), - !error.isEmpty() ? error : tr( "Trying to create image of %2×%3 @ %4dpi " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ) - .arg( imageSize.width() ).arg( imageSize.height() ).arg( settings.dpi ), + QMessageBox::warning( this, tr( "Export Atlas as Image" ), !error.isEmpty() ? error : tr( "Trying to create image of %2×%3 @ %4dpi " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ) + .arg( imageSize.width() ) + .arg( imageSize.height() ) + .arg( settings.dpi ), QMessageBox::Ok, QMessageBox::Ok ); break; } @@ -3098,10 +2982,7 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg() if ( !printAtlas->coverageLayer() ) { - QMessageBox::warning( this, tr( "Export Atlas" ), - tr( "Error: No coverage layer is set." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas" ), tr( "Error: No coverage layer is set." ), QMessageBox::Ok, QMessageBox::Ok ); return; } @@ -3115,10 +2996,7 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg() // else, it has an atlas to render, so a directory must first be selected if ( printAtlas->filenameExpression().isEmpty() ) { - int res = QMessageBox::warning( nullptr, tr( "Export Atlas" ), - tr( "The filename expression is empty. A default one will be used instead." ), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Ok ); + int res = QMessageBox::warning( nullptr, tr( "Export Atlas" ), tr( "The filename expression is empty. A default one will be used instead." ), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok ); if ( res == QMessageBox::Cancel ) { return; @@ -3157,10 +3035,7 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg() // test directory (if it exists and is writable) if ( !QDir( dir ).exists() || !QFileInfo( dir ).isWritable() ) { - QMessageBox::warning( nullptr, tr( "Export Atlas" ), - tr( "Unable to write into the given output directory. Canceling." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( nullptr, tr( "Export Atlas" ), tr( "Unable to write into the given output directory. Canceling." ), QMessageBox::Ok, QMessageBox::Ok ); return; } @@ -3173,16 +3048,15 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg() QgsAtlasExportGuard exportingAtlas( this ); QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Rendering maps…" ), tr( "Abort" ), 0, 100, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Rendering maps…" ), tr( "Abort" ), 0, 100, this ); progressDialog->setWindowTitle( tr( "Exporting Atlas" ) ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Exporting “%1”" ).arg( mMasterLayout->name() ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double progress ) - { - progressDialog->setValue( static_cast< int >( progress ) ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double progress ) { + progressDialog->setValue( static_cast( progress ) ); + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); proxyTask->setProxyProgress( progress ); @@ -3195,10 +3069,8 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); @@ -3215,46 +3087,32 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg() { case QgsLayoutExporter::Success: { - mMessageBar->pushMessage( tr( "Export atlas" ), - tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export atlas" ), tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), Qgis::MessageLevel::Success, 0 ); break; } case QgsLayoutExporter::FileError: - QMessageBox::warning( this, tr( "Export Atlas as SVG" ), - error, QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as SVG" ), error, QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::SvgLayerError: - QMessageBox::warning( this, tr( "Export Atlas as SVG" ), - !error.isEmpty() ? error : tr( "Cannot create layered SVG file." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as SVG" ), !error.isEmpty() ? error : tr( "Cannot create layered SVG file." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::PrintError: - QMessageBox::warning( this, tr( "Export Atlas as SVG" ), - !error.isEmpty() ? error : tr( "Could not create print device." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as SVG" ), !error.isEmpty() ? error : tr( "Could not create print device." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: - QMessageBox::warning( this, tr( "Export Atlas as SVG" ), - !error.isEmpty() ? error : tr( "Exporting the SVG " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Export Atlas as SVG" ), !error.isEmpty() ? error : tr( "Exporting the SVG " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::IteratorError: - QMessageBox::warning( this, tr( "Export Atlas as SVG" ), - !error.isEmpty() ? error : tr( "Error encountered while exporting atlas." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as SVG" ), !error.isEmpty() ? error : tr( "Error encountered while exporting atlas." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::Canceled: @@ -3276,10 +3134,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() if ( !printAtlas->coverageLayer() ) { - QMessageBox::warning( this, tr( "Export Atlas" ), - tr( "Error: No coverage layer is set." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas" ), tr( "Error: No coverage layer is set." ), QMessageBox::Ok, QMessageBox::Ok ); return; } @@ -3312,10 +3167,11 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() this->raise(); #endif outputFileName = QFileDialog::getSaveFileName( - this, - tr( "Export to PDF" ), - outputFileName, - tr( "PDF Format" ) + " (*.pdf *.PDF)" ); + this, + tr( "Export to PDF" ), + outputFileName, + tr( "PDF Format" ) + " (*.pdf *.PDF)" + ); this->activateWindow(); if ( outputFileName.isEmpty() ) { @@ -3332,10 +3188,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() { if ( printAtlas->filenameExpression().isEmpty() ) { - int res = QMessageBox::warning( nullptr, tr( "Export Atlas as PDF" ), - tr( "The filename expression is empty. A default one will be used instead." ), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Ok ); + int res = QMessageBox::warning( nullptr, tr( "Export Atlas as PDF" ), tr( "The filename expression is empty. A default one will be used instead." ), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok ); if ( res == QMessageBox::Cancel ) { return; @@ -3375,10 +3228,7 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() // test directory (if it exists and is writable) if ( !QDir( dir ).exists() || !QFileInfo( dir ).isWritable() ) { - QMessageBox::warning( nullptr, tr( "Export Atlas as PDF" ), - tr( "Unable to write into the given output directory. Canceling." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( nullptr, tr( "Export Atlas as PDF" ), tr( "Unable to write into the given output directory. Canceling." ), QMessageBox::Ok, QMessageBox::Ok ); return; } @@ -3404,16 +3254,15 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() pdfSettings.rasterizeWholeImage = mLayout->customProperty( QStringLiteral( "rasterize" ), false ).toBool(); QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Rendering maps…" ), tr( "Abort" ), 0, 100, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Rendering maps…" ), tr( "Abort" ), 0, 100, this ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Exporting “%1”" ).arg( mMasterLayout->name() ) ); progressDialog->setWindowTitle( tr( "Exporting Atlas" ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double progress ) - { - progressDialog->setValue( static_cast< int >( progress ) ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double progress ) { + progressDialog->setValue( static_cast( progress ) ); + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); proxyTask->setProxyProgress( progress ); @@ -3426,10 +3275,8 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); @@ -3455,23 +3302,17 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() { if ( singleFile ) { - mMessageBar->pushMessage( tr( "Export atlas" ), - tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export atlas" ), tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), Qgis::MessageLevel::Success, 0 ); } else { - mMessageBar->pushMessage( tr( "Export atlas" ), - tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export atlas" ), tr( "Successfully exported atlas to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), Qgis::MessageLevel::Success, 0 ); } break; } case QgsLayoutExporter::FileError: - QMessageBox::warning( this, tr( "Export Atlas as PDF" ), - error, QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as PDF" ), error, QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::SvgLayerError: @@ -3479,26 +3320,19 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf() break; case QgsLayoutExporter::PrintError: - QMessageBox::warning( this, tr( "Export Atlas as PDF" ), - !error.isEmpty() ? error : tr( "Could not create print device." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as PDF" ), !error.isEmpty() ? error : tr( "Could not create print device." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: - QMessageBox::warning( this, tr( "Export Atlas as PDF" ), - !error.isEmpty() ? error : tr( "Exporting the PDF " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Export Atlas as PDF" ), !error.isEmpty() ? error : tr( "Exporting the PDF " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::IteratorError: - QMessageBox::warning( this, tr( "Export Atlas as PDF" ), - !error.isEmpty() ? error : tr( "Error encountered while exporting atlas" ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Atlas as PDF" ), !error.isEmpty() ? error : tr( "Error encountered while exporting atlas" ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::Canceled: @@ -3541,16 +3375,15 @@ void QgsLayoutDesignerDialog::exportReportToRaster() QgsAtlasExportGuard exportingAtlas( this ); QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Rendering report…" ), tr( "Abort" ), 0, 0, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Rendering report…" ), tr( "Abort" ), 0, 0, this ); progressDialog->setWindowTitle( tr( "Exporting Report" ) ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Exporting “%1”" ).arg( mMasterLayout->name() ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double ) - { + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double ) { //progressDialog->setValue( progress ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); #ifdef Q_OS_LINUX // One iteration is actually enough on Windows to get good interactivity @@ -3561,10 +3394,8 @@ void QgsLayoutDesignerDialog::exportReportToRaster() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); @@ -3573,7 +3404,7 @@ void QgsLayoutDesignerDialog::exportReportToRaster() QFileInfo fi( fileNExt.first ); QString dir = fi.path(); QString fileName = dir + '/' + fi.baseName(); - QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToImage( static_cast< QgsReport * >( mMasterLayout ), fileName, fileNExt.second, settings, error, feedback.get() ); + QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToImage( static_cast( mMasterLayout ), fileName, fileNExt.second, settings, error, feedback.get() ); proxyTask->finalize( result == QgsLayoutExporter::Success ); storeExportResults( result ); @@ -3582,16 +3413,11 @@ void QgsLayoutDesignerDialog::exportReportToRaster() switch ( result ) { case QgsLayoutExporter::Success: - mMessageBar->pushMessage( tr( "Export report" ), - tr( "Successfully exported report to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export report" ), tr( "Successfully exported report to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), Qgis::MessageLevel::Success, 0 ); break; case QgsLayoutExporter::IteratorError: - QMessageBox::warning( this, tr( "Export Report as Image" ), - !error.isEmpty() ? error : tr( "Error encountered while exporting report" ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as Image" ), !error.isEmpty() ? error : tr( "Error encountered while exporting report" ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::PrintError: @@ -3601,18 +3427,16 @@ void QgsLayoutDesignerDialog::exportReportToRaster() break; case QgsLayoutExporter::FileError: - QMessageBox::warning( this, tr( "Export Report as Image" ), - error, - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as Image" ), error, QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: - QMessageBox::warning( this, tr( "Export Report as Image" ), - !error.isEmpty() ? error : tr( "Trying to create image of %2×%3 @ %4dpi " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ) - .arg( imageSize.width() ).arg( imageSize.height() ).arg( settings.dpi ), + QMessageBox::warning( this, tr( "Export Report as Image" ), !error.isEmpty() ? error : tr( "Trying to create image of %2×%3 @ %4dpi " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ) + .arg( imageSize.width() ) + .arg( imageSize.height() ) + .arg( settings.dpi ), QMessageBox::Ok, QMessageBox::Ok ); break; } @@ -3630,10 +3454,11 @@ void QgsLayoutDesignerDialog::exportReportToSvg() QString outputFileName = defaultPath + '/' + QgsFileUtils::stringToSafeFilename( mMasterLayout->name() ) + QStringLiteral( ".svg" ); outputFileName = QFileDialog::getSaveFileName( - this, - tr( "Export Report as SVG" ), - outputFileName, - tr( "SVG Format" ) + " (*.svg *.SVG)" ); + this, + tr( "Export Report as SVG" ), + outputFileName, + tr( "SVG Format" ) + " (*.svg *.SVG)" + ); this->activateWindow(); if ( outputFileName.isEmpty() ) { @@ -3659,16 +3484,15 @@ void QgsLayoutDesignerDialog::exportReportToSvg() QgsAtlasExportGuard exportingAtlas( this ); QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Rendering maps…" ), tr( "Abort" ), 0, 0, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Rendering maps…" ), tr( "Abort" ), 0, 0, this ); progressDialog->setWindowTitle( tr( "Exporting Report" ) ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Exporting “%1”" ).arg( mMasterLayout->name() ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double ) - { + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double ) { //progressDialog->setValue( progress ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); #ifdef Q_OS_LINUX // One iteration is actually enough on Windows to get good interactivity @@ -3679,10 +3503,8 @@ void QgsLayoutDesignerDialog::exportReportToSvg() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); @@ -3691,7 +3513,7 @@ void QgsLayoutDesignerDialog::exportReportToSvg() QFileInfo fi( outputFileName ); QString outFile = fi.path() + '/' + fi.baseName(); QString dir = fi.path(); - QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToSvg( static_cast< QgsReport * >( mMasterLayout ), outFile, svgSettings, error, feedback.get() ); + QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToSvg( static_cast( mMasterLayout ), outFile, svgSettings, error, feedback.get() ); proxyTask->finalize( result == QgsLayoutExporter::Success ); storeExportResults( result ); @@ -3700,46 +3522,32 @@ void QgsLayoutDesignerDialog::exportReportToSvg() { case QgsLayoutExporter::Success: { - mMessageBar->pushMessage( tr( "Export report" ), - tr( "Successfully exported report to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export report" ), tr( "Successfully exported report to %2" ).arg( QUrl::fromLocalFile( dir ).toString(), QDir::toNativeSeparators( dir ) ), Qgis::MessageLevel::Success, 0 ); break; } case QgsLayoutExporter::FileError: - QMessageBox::warning( this, tr( "Export Report as SVG" ), - error, QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as SVG" ), error, QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::SvgLayerError: - QMessageBox::warning( this, tr( "Export Report as SVG" ), - !error.isEmpty() ? error : tr( "Cannot create layered SVG file." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as SVG" ), !error.isEmpty() ? error : tr( "Cannot create layered SVG file." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::PrintError: - QMessageBox::warning( this, tr( "Export Report as SVG" ), - !error.isEmpty() ? error : tr( "Could not create print device." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as SVG" ), !error.isEmpty() ? error : tr( "Could not create print device." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: - QMessageBox::warning( this, tr( "Export Report as SVG" ), - !error.isEmpty() ? error : tr( "Exporting the SVG " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Export Report as SVG" ), !error.isEmpty() ? error : tr( "Exporting the SVG " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::IteratorError: - QMessageBox::warning( this, tr( "Export Report as SVG" ), - !error.isEmpty() ? error : tr( "Error encountered while exporting report." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as SVG" ), !error.isEmpty() ? error : tr( "Error encountered while exporting report." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::Canceled: @@ -3764,10 +3572,11 @@ void QgsLayoutDesignerDialog::exportReportToPdf() this->raise(); #endif outputFileName = QFileDialog::getSaveFileName( - this, - tr( "Export Report as PDF" ), - outputFileName, - tr( "PDF Format" ) + " (*.pdf *.PDF)" ); + this, + tr( "Export Report as PDF" ), + outputFileName, + tr( "PDF Format" ) + " (*.pdf *.PDF)" + ); this->activateWindow(); if ( outputFileName.isEmpty() ) { @@ -3796,16 +3605,15 @@ void QgsLayoutDesignerDialog::exportReportToPdf() pdfSettings.rasterizeWholeImage = rasterize; QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Rendering maps…" ), tr( "Abort" ), 0, 0, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Rendering maps…" ), tr( "Abort" ), 0, 0, this ); progressDialog->setWindowTitle( tr( "Exporting Report" ) ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Exporting “%1”" ).arg( mMasterLayout->name() ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double ) - { + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double ) { //progressDialog->setValue( progress ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); #ifdef Q_OS_LINUX // One iteration is actually enough on Windows to get good interactivity @@ -3816,16 +3624,14 @@ void QgsLayoutDesignerDialog::exportReportToPdf() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); QgsApplication::taskManager()->addTask( proxyTask ); - QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToPdf( static_cast< QgsReport * >( mMasterLayout ), outputFileName, pdfSettings, error, feedback.get() ); + QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToPdf( static_cast( mMasterLayout ), outputFileName, pdfSettings, error, feedback.get() ); proxyTask->finalize( result == QgsLayoutExporter::Success ); storeExportResults( result ); @@ -3835,16 +3641,12 @@ void QgsLayoutDesignerDialog::exportReportToPdf() { case QgsLayoutExporter::Success: { - mMessageBar->pushMessage( tr( "Export report" ), - tr( "Successfully exported report to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), - Qgis::MessageLevel::Success, 0 ); + mMessageBar->pushMessage( tr( "Export report" ), tr( "Successfully exported report to %2" ).arg( QUrl::fromLocalFile( outputFileName ).toString(), QDir::toNativeSeparators( outputFileName ) ), Qgis::MessageLevel::Success, 0 ); break; } case QgsLayoutExporter::FileError: - QMessageBox::warning( this, tr( "Export Report as PDF" ), - error, QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as PDF" ), error, QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::SvgLayerError: @@ -3852,26 +3654,19 @@ void QgsLayoutDesignerDialog::exportReportToPdf() break; case QgsLayoutExporter::PrintError: - QMessageBox::warning( this, tr( "Export Report as PDF" ), - !error.isEmpty() ? error : tr( "Could not create print device." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as PDF" ), !error.isEmpty() ? error : tr( "Could not create print device." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::MemoryError: - QMessageBox::warning( this, tr( "Export Report as PDF" ), - !error.isEmpty() ? error : tr( "Exporting the PDF " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Export Report as PDF" ), !error.isEmpty() ? error : tr( "Exporting the PDF " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::IteratorError: - QMessageBox::warning( this, tr( "Export Report as PDF" ), - !error.isEmpty() ? error : tr( "Error encountered while exporting report." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Export Report as PDF" ), !error.isEmpty() ? error : tr( "Error encountered while exporting report." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::Canceled: @@ -3903,16 +3698,15 @@ void QgsLayoutDesignerDialog::printReport() printSettings.predefinedMapScales = QgsLayoutUtils::predefinedScales( mLayout ); QString error; - std::unique_ptr< QgsFeedback > feedback = std::make_unique< QgsFeedback >(); - std::unique_ptr< QProgressDialog > progressDialog = std::make_unique< QProgressDialog >( tr( "Printing maps…" ), tr( "Abort" ), 0, 0, this ); + std::unique_ptr feedback = std::make_unique(); + std::unique_ptr progressDialog = std::make_unique( tr( "Printing maps…" ), tr( "Abort" ), 0, 0, this ); progressDialog->setWindowTitle( tr( "Printing Report" ) ); QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( tr( "Printing “%1”" ).arg( mMasterLayout->name() ) ); - connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double ) - { + connect( feedback.get(), &QgsFeedback::progressChanged, this, [&]( double ) { //progressDialog->setValue( progress ); - progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ; + progressDialog->setLabelText( feedback->property( "progress" ).toString() ); #ifdef Q_OS_LINUX // One iteration is actually enough on Windows to get good interactivity @@ -3923,10 +3717,8 @@ void QgsLayoutDesignerDialog::printReport() { QCoreApplication::processEvents(); } - } ); - connect( progressDialog.get(), &QProgressDialog::canceled, this, [ & ] - { + connect( progressDialog.get(), &QProgressDialog::canceled, this, [&] { feedback->cancel(); } ); @@ -3935,7 +3727,7 @@ void QgsLayoutDesignerDialog::printReport() QPrinter *p = printer(); QString printerName = p->printerName(); p->setDocName( mMasterLayout->name() ); - QgsLayoutExporter::ExportResult result = QgsLayoutExporter::print( static_cast< QgsReport * >( mMasterLayout ), *p, printSettings, error, feedback.get() ); + QgsLayoutExporter::ExportResult result = QgsLayoutExporter::print( static_cast( mMasterLayout ), *p, printSettings, error, feedback.get() ); proxyTask->finalize( result == QgsLayoutExporter::Success ); storeExportResults( result ); @@ -3953,9 +3745,7 @@ void QgsLayoutDesignerDialog::printReport() { message = tr( "Successfully printed report." ); } - mMessageBar->pushMessage( tr( "Print report" ), - message, - Qgis::MessageLevel::Success ); + mMessageBar->pushMessage( tr( "Print report" ), message, Qgis::MessageLevel::Success ); break; } @@ -3975,28 +3765,21 @@ void QgsLayoutDesignerDialog::printReport() message = tr( "Could not create print device." ); } cursorOverride.release(); - QMessageBox::warning( this, tr( "Print Report" ), - message, - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Print Report" ), message, QMessageBox::Ok, QMessageBox::Ok ); break; } case QgsLayoutExporter::MemoryError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Print Report" ), - !error.isEmpty() ? error : tr( "Printing the report " - "resulted in a memory overflow.\n\n" - "Please try a lower resolution or a smaller paper size." ), + QMessageBox::warning( this, tr( "Print Report" ), !error.isEmpty() ? error : tr( "Printing the report " + "resulted in a memory overflow.\n\n" + "Please try a lower resolution or a smaller paper size." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::IteratorError: cursorOverride.release(); - QMessageBox::warning( this, tr( "Print Report" ), - !error.isEmpty() ? error : tr( "Error encountered while printing report." ), - QMessageBox::Ok, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Print Report" ), !error.isEmpty() ? error : tr( "Error encountered while printing report." ), QMessageBox::Ok, QMessageBox::Ok ); break; case QgsLayoutExporter::FileError: @@ -4052,12 +3835,12 @@ void QgsLayoutDesignerDialog::paste() layoutPoint = mView->mapToScene( viewPoint ); } - QList< QgsLayoutItem * > items; + QList items; // give custom paste handlers first shot at processing this QClipboard *clipboard = QApplication::clipboard(); const QMimeData *data = clipboard->mimeData(); - const QVector> handlers = QgisApp::instance()->customLayoutDropHandlers(); + const QVector> handlers = QgisApp::instance()->customLayoutDropHandlers(); bool handled = false; for ( QgsLayoutCustomDropHandler *handler : handlers ) { @@ -4091,7 +3874,7 @@ void QgsLayoutDesignerDialog::paste() void QgsLayoutDesignerDialog::pasteInPlace() { - QList< QgsLayoutItem * > items = mView->pasteItems( QgsLayoutView::PasteModeInPlace ); + QList items = mView->pasteItems( QgsLayoutView::PasteModeInPlace ); whileBlocking( currentLayout() )->deselectAll(); selectItems( items ); @@ -4118,7 +3901,7 @@ void QgsLayoutDesignerDialog::restoreWindowState() // restore the toolbar and dock widgets positions using Qt settings API QgsSettings settings; - if ( !restoreState( settings.value( QStringLiteral( "LayoutDesigner/state" ), QByteArray::fromRawData( reinterpret_cast< const char * >( defaultLayerDesignerUIstate ), sizeof defaultLayerDesignerUIstate ), QgsSettings::App ).toByteArray() ) ) + if ( !restoreState( settings.value( QStringLiteral( "LayoutDesigner/state" ), QByteArray::fromRawData( reinterpret_cast( defaultLayerDesignerUIstate ), sizeof defaultLayerDesignerUIstate ), QgsSettings::App ).toByteArray() ) ) { QgsDebugError( QStringLiteral( "restore of layout UI state failed" ) ); } @@ -4172,7 +3955,7 @@ void QgsLayoutDesignerDialog::createLayoutPropertiesWidget() void QgsLayoutDesignerDialog::createAtlasWidget() { - QgsPrintLayout *printLayout = dynamic_cast< QgsPrintLayout * >( mMasterLayout ); + QgsPrintLayout *printLayout = dynamic_cast( mMasterLayout ); if ( !printLayout ) return; @@ -4183,8 +3966,7 @@ void QgsLayoutDesignerDialog::createAtlasWidget() mPanelsMenu->addAction( mAtlasDock->toggleViewAction() ); - connect( atlas, &QgsLayoutAtlas::messagePushed, mStatusBar, [ = ]( const QString & message ) - { + connect( atlas, &QgsLayoutAtlas::messagePushed, mStatusBar, [=]( const QString &message ) { mStatusBar->showMessage( message ); } ); connect( atlas, &QgsLayoutAtlas::toggled, this, &QgsLayoutDesignerDialog::toggleAtlasControls ); @@ -4196,7 +3978,7 @@ void QgsLayoutDesignerDialog::createAtlasWidget() void QgsLayoutDesignerDialog::createReportWidget() { - QgsReport *report = dynamic_cast< QgsReport * >( mMasterLayout ); + QgsReport *report = dynamic_cast( mMasterLayout ); QgsReportOrganizerWidget *reportWidget = new QgsReportOrganizerWidget( mReportDock, this, report ); reportWidget->setMessageBar( mMessageBar ); mReportDock->setWidget( reportWidget ); @@ -4207,9 +3989,8 @@ void QgsLayoutDesignerDialog::createReportWidget() void QgsLayoutDesignerDialog::initializeRegistry() { sInitializedRegistry = true; - auto createPageWidget = ( []( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * - { - std::unique_ptr< QgsLayoutPagePropertiesWidget > newWidget = std::make_unique< QgsLayoutPagePropertiesWidget >( nullptr, item ); + auto createPageWidget = ( []( QgsLayoutItem *item ) -> QgsLayoutItemBaseWidget * { + std::unique_ptr newWidget = std::make_unique( nullptr, item ); return newWidget.release(); } ); @@ -4218,7 +3999,7 @@ void QgsLayoutDesignerDialog::initializeRegistry() bool QgsLayoutDesignerDialog::containsWmsLayers() const { - QList< QgsLayoutItemMap *> maps; + QList maps; mLayout->layoutItems( maps ); for ( QgsLayoutItemMap *map : std::as_const( maps ) ) @@ -4275,8 +4056,7 @@ void QgsLayoutDesignerDialog::showSvgExportWarning() void QgsLayoutDesignerDialog::showRasterizationWarning() { - if ( mLayout->customProperty( QStringLiteral( "rasterize" ), false ).toBool() || - mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool() ) + if ( mLayout->customProperty( QStringLiteral( "rasterize" ), false ).toBool() || mLayout->customProperty( QStringLiteral( "forceVector" ), false ).toBool() ) return; QgsMessageViewer m( this, QgsGuiUtils::ModalDialogFlags, false ); @@ -4317,18 +4097,15 @@ bool QgsLayoutDesignerDialog::showFileSizeWarning() // Image size double oneInchInLayoutUnits = mLayout->convertToLayoutUnits( QgsLayoutMeasurement( 1, Qgis::LayoutUnit::Inches ) ); QSizeF maxPageSize = mLayout->pageCollection()->maximumPageSize(); - const int width = static_cast< int >( mLayout->renderContext().dpi() * maxPageSize.width() / oneInchInLayoutUnits ); - const int height = static_cast< int >( mLayout->renderContext().dpi() * maxPageSize.height() / oneInchInLayoutUnits ); - const std::size_t memuse = static_cast< std::size_t >( width ) * height * 3; // pixmap + image + const int width = static_cast( mLayout->renderContext().dpi() * maxPageSize.width() / oneInchInLayoutUnits ); + const int height = static_cast( mLayout->renderContext().dpi() * maxPageSize.height() / oneInchInLayoutUnits ); + const std::size_t memuse = static_cast( width ) * height * 3; // pixmap + image QgsDebugMsgLevel( QStringLiteral( "Image %1x%2" ).arg( width ).arg( height ), 2 ); QgsDebugMsgLevel( QStringLiteral( "memuse = %1" ).arg( memuse ), 2 ); - if ( memuse > 400000000 ) // about 4500x4500 + if ( memuse > 400000000 ) // about 4500x4500 { - int answer = QMessageBox::warning( this, tr( "Export Layout" ), - tr( "To create an image of %1x%2 requires about %3 of memory. Proceed?" ) - .arg( width ).arg( height ).arg( QgsFileUtils::representFileSize( static_cast< qint64 >( memuse ) ) ), - QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok ); + int answer = QMessageBox::warning( this, tr( "Export Layout" ), tr( "To create an image of %1x%2 requires about %3 of memory. Proceed?" ).arg( width ).arg( height ).arg( QgsFileUtils::representFileSize( static_cast( memuse ) ) ), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok ); raise(); if ( answer == QMessageBox::Cancel ) @@ -4457,7 +4234,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport if ( prevLayoutSettingLabelsAsOutlines >= 0 ) { // previous layout setting takes default over project setting - prevTextRenderFormat = static_cast< Qgis::TextRenderFormat >( prevLayoutSettingLabelsAsOutlines ); + prevTextRenderFormat = static_cast( prevLayoutSettingLabelsAsOutlines ); } } @@ -4466,17 +4243,15 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport Ui::QgsSvgExportOptionsDialog options; options.setupUi( &dialog ); - connect( options.mHelpButtonBox, &QDialogButtonBox::helpRequested, this, [ & ] - { + connect( options.mHelpButtonBox, &QDialogButtonBox::helpRequested, this, [&] { QgsHelp::openHelp( QStringLiteral( "print_composer/create_output.html" ) ); - } - ); + } ); - options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Paths (Recommended)" ), static_cast< int >( Qgis::TextRenderFormat::AlwaysOutlines ) ); - options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), static_cast< int >( Qgis::TextRenderFormat::AlwaysText ) ); - options.mTextRenderFormatComboBox->addItem( tr( "Prefer Exporting Text as Text Objects" ), static_cast< int >( Qgis::TextRenderFormat::PreferText ) ); + options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Paths (Recommended)" ), static_cast( Qgis::TextRenderFormat::AlwaysOutlines ) ); + options.mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), static_cast( Qgis::TextRenderFormat::AlwaysText ) ); + options.mTextRenderFormatComboBox->addItem( tr( "Prefer Exporting Text as Text Objects" ), static_cast( Qgis::TextRenderFormat::PreferText ) ); - options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( static_cast< int >( prevTextRenderFormat ) ) ); + options.mTextRenderFormatComboBox->setCurrentIndex( options.mTextRenderFormatComboBox->findData( static_cast( prevTextRenderFormat ) ) ); options.chkMapLayersAsGroup->setChecked( layersAsGroup ); options.mClipToContentGroupBox->setChecked( cropToContents ); options.mForceVectorCheckBox->setChecked( forceVector ); @@ -4502,7 +4277,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport forceVector = options.mForceVectorCheckBox->isChecked(); disableRasterTiles = options.mDisableRasterTilingCheckBox->isChecked(); simplify = options.mSimplifyGeometriesCheckbox->isChecked(); - Qgis::TextRenderFormat textRenderFormat = static_cast< Qgis::TextRenderFormat >( options.mTextRenderFormatComboBox->currentData().toInt() ); + Qgis::TextRenderFormat textRenderFormat = static_cast( options.mTextRenderFormatComboBox->currentData().toInt() ); QgsLayoutExporter::settingOpenAfterExportingSvg->setValue( options.mOpenAfterExportingCheckBox->isChecked() ); if ( mLayout ) @@ -4516,7 +4291,7 @@ bool QgsLayoutDesignerDialog::getSvgExportSettings( QgsLayoutExporter::SvgExport mLayout->setCustomProperty( QStringLiteral( "svgCropMarginLeft" ), marginLeft ); mLayout->setCustomProperty( QStringLiteral( "svgIncludeMetadata" ), includeMetadata ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "forceVector" ), forceVector ? 1 : 0 ); - mLayout->setCustomProperty( QStringLiteral( "svgTextFormat" ), static_cast< int >( textRenderFormat ) ); + mLayout->setCustomProperty( QStringLiteral( "svgTextFormat" ), static_cast( textRenderFormat ) ); mLayout->setCustomProperty( QStringLiteral( "svgDisableRasterTiles" ), disableRasterTiles ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "svgSimplify" ), simplify ? 1 : 0 ); } @@ -4573,13 +4348,13 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport if ( prevLayoutSettingLabelsAsOutlines >= 0 ) { // previous layout setting takes default over project setting - prevTextRenderFormat = static_cast< Qgis::TextRenderFormat >( prevLayoutSettingLabelsAsOutlines ); + prevTextRenderFormat = static_cast( prevLayoutSettingLabelsAsOutlines ); } } // open options dialog QString dialogGeospatialPdfReason = geospatialPdfReason; - QList< QgsLayoutItemMap * > maps; + QList maps; if ( mLayout ) mLayout->layoutItems( maps ); @@ -4638,7 +4413,7 @@ bool QgsLayoutDesignerDialog::getPdfExportSettings( QgsLayoutExporter::PdfExport mLayout->setCustomProperty( QStringLiteral( "pdfAppendGeoreference" ), appendGeoreference ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "pdfIncludeMetadata" ), includeMetadata ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "pdfDisableRasterTiles" ), disableRasterTiles ? 1 : 0 ); - mLayout->setCustomProperty( QStringLiteral( "pdfTextFormat" ), static_cast< int >( textRenderFormat ) ); + mLayout->setCustomProperty( QStringLiteral( "pdfTextFormat" ), static_cast( textRenderFormat ) ); mLayout->setCustomProperty( QStringLiteral( "pdfSimplify" ), simplify ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "pdfCreateGeoPdf" ), geospatialPdf ? 1 : 0 ); mLayout->setCustomProperty( QStringLiteral( "pdfOgcBestPracticeFormat" ), useOgcBestPracticeFormat ? 1 : 0 ); @@ -4692,7 +4467,7 @@ void QgsLayoutDesignerDialog::toggleAtlasControls( bool atlasEnabled ) void QgsLayoutDesignerDialog::updateAtlasPageComboBox( int pageCount ) { - QgsPrintLayout *printLayout = qobject_cast< QgsPrintLayout * >( mLayout ); + QgsPrintLayout *printLayout = qobject_cast( mLayout ); if ( !printLayout ) return; @@ -4709,7 +4484,6 @@ void QgsLayoutDesignerDialog::updateAtlasPageComboBox( int pageCount ) mAtlasPageComboBox->setItemData( i - 1, fullName, Qt::UserRole + 2 ); } mAtlasPageComboBox->blockSignals( false ); - } void QgsLayoutDesignerDialog::atlasFeatureChanged( const QgsFeature &feature ) @@ -4717,7 +4491,7 @@ void QgsLayoutDesignerDialog::atlasFeatureChanged( const QgsFeature &feature ) if ( mIsExportingAtlas ) return; - QgsPrintLayout *printLayout = qobject_cast< QgsPrintLayout *>( mLayout ); + QgsPrintLayout *printLayout = qobject_cast( mLayout ); if ( !printLayout ) return; @@ -4753,7 +4527,7 @@ void QgsLayoutDesignerDialog::atlasFeatureChanged( const QgsFeature &feature ) { // a little sanity check -- if there's any maps in this layout which are set to be atlas controlled, // and we hit a feature with no geometry attached, then warn the user - QList< QgsLayoutItemMap * > maps; + QList maps; mLayout->layoutItems( maps ); for ( const QgsLayoutItemMap *map : std::as_const( maps ) ) { @@ -4774,7 +4548,7 @@ void QgsLayoutDesignerDialog::loadPredefinedScalesFromProject() QgsLayoutAtlas *QgsLayoutDesignerDialog::atlas() { - QgsPrintLayout *layout = qobject_cast< QgsPrintLayout *>( mLayout ); + QgsPrintLayout *layout = qobject_cast( mLayout ); if ( !layout ) return nullptr; return layout->atlas(); @@ -4891,7 +4665,7 @@ QPrinter *QgsLayoutDesignerDialog::printer() //only create the printer on demand - creating a printer object can be very slow //due to QTBUG-3033 if ( !mPrinter ) - mPrinter = std::make_unique< QPrinter >(); + mPrinter = std::make_unique(); return mPrinter.get(); } @@ -4967,13 +4741,12 @@ void QgsLayoutDesignerDialog::setLastExportPath( const QString &path ) const QgsSettings().setValue( QStringLiteral( "lastLayoutExportDir" ), savePath, QgsSettings::App ); } -bool QgsLayoutDesignerDialog::checkBeforeExport( ) +bool QgsLayoutDesignerDialog::checkBeforeExport() { if ( mLayout ) { QgsLayoutValidityCheckContext context( mLayout ); - return QgsValidityCheckResultsWidget::runChecks( static_cast< int >( QgsAbstractValidityCheck::Type::LayoutCheck ), &context, tr( "Checking Layout" ), - tr( "The layout generated the following warnings. Please review and address these before proceeding with the layout export." ), this ); + return QgsValidityCheckResultsWidget::runChecks( static_cast( QgsAbstractValidityCheck::Type::LayoutCheck ), &context, tr( "Checking Layout" ), tr( "The layout generated the following warnings. Please review and address these before proceeding with the layout export." ), this ); } else { @@ -5023,7 +4796,7 @@ void QgsLayoutDesignerDialog::backgroundTaskCountChanged( int total ) void QgsLayoutDesignerDialog::onMapPreviewRefreshed() { - QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( sender() ); + QgsLayoutItemMap *map = qobject_cast( sender() ); if ( !map ) return; @@ -5032,7 +4805,7 @@ void QgsLayoutDesignerDialog::onMapPreviewRefreshed() void QgsLayoutDesignerDialog::onItemAdded( QgsLayoutItem *item ) { - if ( QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( item ) ) + if ( QgsLayoutItemMap *map = qobject_cast( item ) ) { connect( map, &QgsLayoutItemMap::previewRefreshed, this, &QgsLayoutDesignerDialog::onMapPreviewRefreshed ); } @@ -5040,7 +4813,7 @@ void QgsLayoutDesignerDialog::onItemAdded( QgsLayoutItem *item ) void QgsLayoutDesignerDialog::storeExportResults( QgsLayoutExporter::ExportResult result, QgsLayoutExporter *exporter ) { - mLastExportResults = std::make_unique< QgsLayoutDesignerInterface::ExportResults >(); + mLastExportResults = std::make_unique(); mLastExportResults->result = result; if ( exporter ) @@ -5143,7 +4916,7 @@ void QgsLayoutDesignerDialog::toolButtonActionTriggered( QAction *action ) void QgsLayoutDesignerDialog::onItemDestroyed( QObject *item ) { - if ( QgsLayoutItemBaseWidget *widget = qobject_cast< QgsLayoutItemBaseWidget * >( mItemPropertiesStack->mainPanel() ) ) + if ( QgsLayoutItemBaseWidget *widget = qobject_cast( mItemPropertiesStack->mainPanel() ) ) { if ( widget->layoutObject() == item ) delete mItemPropertiesStack->takeMainPanel(); diff --git a/src/app/layout/qgslayoutdesignerdialog.h b/src/app/layout/qgslayoutdesignerdialog.h index 7c6ee723c445..dd460d84d5cf 100644 --- a/src/app/layout/qgslayoutdesignerdialog.h +++ b/src/app/layout/qgslayoutdesignerdialog.h @@ -64,7 +64,7 @@ class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface QgsMasterLayoutInterface *masterLayout() override; QgsLayoutView *view() override; QgsMessageBar *messageBar() override; - void selectItems( const QList< QgsLayoutItem * > &items ) override; + void selectItems( const QList &items ) override; void setAtlasPreviewEnabled( bool enabled ) override; void setAtlasFeature( const QgsFeature &feature ) override; bool atlasPreviewEnabled() const override; @@ -90,7 +90,6 @@ class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface void showRulers( bool visible ) override; private: - QgsLayoutDesignerDialog *mDesigner = nullptr; }; @@ -98,12 +97,11 @@ class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface * \ingroup app * \brief A window for designing layouts. */ -class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerBase +class QgsLayoutDesignerDialog : public QMainWindow, public Ui::QgsLayoutDesignerBase { Q_OBJECT public: - QgsLayoutDesignerDialog( QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() ); ~QgsLayoutDesignerDialog() override; @@ -210,7 +208,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB * * May be NULLPTR if no export has been performed in the designer. */ - std::unique_ptr< QgsLayoutDesignerInterface::ExportResults > lastExportResults() const; + std::unique_ptr lastExportResults() const; /** * Returns the keyboard shortcuts manager @@ -358,7 +356,6 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB void mapPreviewRefreshed( QgsLayoutItemMap *map ); protected: - void closeEvent( QCloseEvent * ) override; void dropEvent( QDropEvent *event ) override; void dragEnterEvent( QDragEnterEvent *event ) override; @@ -384,7 +381,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB void showPageProperties(); void statusMessageReceived( const QString &message ); void dockVisibilityChanged( bool visible ); - void undoRedoOccurredForItems( const QSet< QString > &itemUuids ); + void undoRedoOccurredForItems( const QSet &itemUuids ); void saveAsTemplate(); void addItemsFromTemplate(); void duplicate(); @@ -430,7 +427,6 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB void layoutMenuAboutToShow(); private: - static bool sInitializedRegistry; QgsAppLayoutDesignerInterface *mInterface = nullptr; @@ -467,8 +463,8 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB QgsLayoutViewToolEditNodes *mNodesTool = nullptr; QgsLayoutViewToolMoveItemContent *mMoveContentTool = nullptr; - QMap< QString, QToolButton * > mItemGroupToolButtons; - QMap< QString, QMenu * > mItemGroupSubmenus; + QMap mItemGroupToolButtons; + QMap mItemGroupSubmenus; QgsLayoutAppMenuProvider *mMenuProvider = nullptr; @@ -502,14 +498,14 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB struct PanelStatus { - PanelStatus( bool visible = true, bool active = false ) - : isVisible( visible ) - , isActive( active ) - {} - bool isVisible; - bool isActive; + PanelStatus( bool visible = true, bool active = false ) + : isVisible( visible ) + , isActive( active ) + {} + bool isVisible; + bool isActive; }; - QMap< QString, PanelStatus > mPanelStatus; + QMap mPanelStatus; bool mBlockItemOptions = false; @@ -517,7 +513,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB #if defined( HAVE_QTPRINTER ) //! Page & Printer Setup - std::unique_ptr< QPrinter > mPrinter; + std::unique_ptr mPrinter; QPrinter *printer(); void setPrinterPageOrientation( QgsLayoutItemPage::Orientation orientation ); #endif @@ -530,8 +526,8 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB bool mIsExportingAtlas = false; void storeExportResults( QgsLayoutExporter::ExportResult result, QgsLayoutExporter *exporter = nullptr ); - std::unique_ptr< QgsLayoutDesignerInterface::ExportResults> mLastExportResults; - QMap< QString, QgsLabelingResults *> mLastExportLabelingResults; + std::unique_ptr mLastExportResults; + QMap mLastExportLabelingResults; //! Shortcuts manager and dialog QgsShortcutsManager *mShortcutsManager = nullptr; diff --git a/src/app/layout/qgslayoutimagedrophandler.cpp b/src/app/layout/qgslayoutimagedrophandler.cpp index c1af5ce7b7fb..070982919dd9 100644 --- a/src/app/layout/qgslayoutimagedrophandler.cpp +++ b/src/app/layout/qgslayoutimagedrophandler.cpp @@ -27,7 +27,6 @@ QgsLayoutImageDropHandler::QgsLayoutImageDropHandler( QObject *parent ) : QgsLayoutCustomDropHandler( parent ) { - } bool QgsLayoutImageDropHandler::handleFileDrop( QgsLayoutDesignerInterface *iface, QPointF point, const QString &file ) @@ -59,7 +58,7 @@ bool QgsLayoutImageDropHandler::handleFileDrop( QgsLayoutDesignerInterface *ifac if ( !iface->layout() ) return false; - std::unique_ptr< QgsLayoutItemPicture > item = std::make_unique< QgsLayoutItemPicture >( iface->layout() ); + std::unique_ptr item = std::make_unique( iface->layout() ); const QgsLayoutPoint layoutPoint = iface->layout()->convertFromLayoutUnits( point, iface->layout()->units() ); @@ -78,7 +77,7 @@ bool QgsLayoutImageDropHandler::handleFileDrop( QgsLayoutDesignerInterface *ifac item->setReferencePoint( QgsLayoutItem::UpperLeft ); // and auto select new item for convenience - QList< QgsLayoutItem * > newSelection; + QList newSelection; newSelection << item.get(); iface->layout()->addLayoutItem( item.release() ); iface->layout()->deselectAll(); @@ -93,7 +92,7 @@ bool QgsLayoutImageDropHandler::handlePaste( QgsLayoutDesignerInterface *iface, return false; const QgsLayoutPoint layoutPoint = iface->layout()->convertFromLayoutUnits( pastePoint, iface->layout()->units() ); - std::unique_ptr< QgsLayoutItemPicture > item = std::make_unique< QgsLayoutItemPicture >( iface->layout() ); + std::unique_ptr item = std::make_unique( iface->layout() ); const QByteArray imageData = data->data( QStringLiteral( "application/x-qt-image" ) ); if ( imageData.isEmpty() ) diff --git a/src/app/layout/qgslayoutimagedrophandler.h b/src/app/layout/qgslayoutimagedrophandler.h index 258550097892..2b4fb5a401d8 100644 --- a/src/app/layout/qgslayoutimagedrophandler.h +++ b/src/app/layout/qgslayoutimagedrophandler.h @@ -23,11 +23,10 @@ class QgsLayoutImageDropHandler : public QgsLayoutCustomDropHandler Q_OBJECT public: - QgsLayoutImageDropHandler( QObject *parent = nullptr ); bool handleFileDrop( QgsLayoutDesignerInterface *iface, QPointF point, const QString &file ) override; - bool handlePaste( QgsLayoutDesignerInterface *iface, QPointF pastePoint, const QMimeData *data, QList< QgsLayoutItem * > &pastedItems ) override; + bool handlePaste( QgsLayoutDesignerInterface *iface, QPointF pastePoint, const QMimeData *data, QList &pastedItems ) override; }; #endif // QGSLAYOUTIMAGEDROPHANDLER_H diff --git a/src/app/layout/qgslayoutmanagerdialog.cpp b/src/app/layout/qgslayoutmanagerdialog.cpp index b31ecf068099..b2213ebee391 100644 --- a/src/app/layout/qgslayoutmanagerdialog.cpp +++ b/src/app/layout/qgslayoutmanagerdialog.cpp @@ -41,7 +41,8 @@ #include #include -QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags f ): QDialog( parent, f ) +QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags f ) + : QDialog( parent, f ) { setupUi( this ); connect( mAddButton, &QPushButton::clicked, this, &QgsLayoutManagerDialog::mAddButton_clicked ); @@ -58,16 +59,14 @@ QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags mTemplateFileWidget->setDefaultRoot( settings.value( QStringLiteral( "lastComposerTemplateDir" ), QString(), QgsSettings::App ).toString() ); mTemplateFileWidget->setFilePath( settings.value( QStringLiteral( "ComposerManager/templatePath" ), QString(), QgsSettings::App ).toString() ); - connect( mTemplateFileWidget, &QgsFileWidget::fileChanged, this, [ = ] - { + connect( mTemplateFileWidget, &QgsFileWidget::fileChanged, this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "ComposerManager/templatePath" ), mTemplateFileWidget->filePath(), QgsSettings::App ); QFileInfo tmplFileInfo( mTemplateFileWidget->filePath() ); settings.setValue( QStringLiteral( "lastComposerTemplateDir" ), tmplFileInfo.absolutePath(), QgsSettings::App ); } ); - mModel = new QgsLayoutManagerModel( QgsProject::instance()->layoutManager(), - this ); + mModel = new QgsLayoutManagerModel( QgsProject::instance()->layoutManager(), this ); mProxyModel = new QgsLayoutManagerProxyModel( mLayoutListView ); mProxyModel->setSourceModel( mModel ); mLayoutListView->setModel( mProxyModel ); @@ -79,8 +78,7 @@ QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags connect( mButtonBox, &QDialogButtonBox::rejected, this, &QWidget::close ); connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsLayoutManagerDialog::showHelp ); - connect( mLayoutListView->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &QgsLayoutManagerDialog::toggleButtons ); + connect( mLayoutListView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsLayoutManagerDialog::toggleButtons ); connect( mLayoutListView, &QListView::doubleClicked, this, &QgsLayoutManagerDialog::itemDoubleClicked ); connect( mShowButton, &QAbstractButton::clicked, this, &QgsLayoutManagerDialog::showClicked ); @@ -152,7 +150,6 @@ void QgsLayoutManagerDialog::addTemplates( const QMap &templat mTemplate->addItem( templateIt.key(), templateIt.value() ); } } - } void QgsLayoutManagerDialog::activate() @@ -261,11 +258,11 @@ void QgsLayoutManagerDialog::mAddButton_clicked() title = QgsProject::instance()->layoutManager()->generateUniqueTitle( QgsMasterLayoutInterface::PrintLayout ); } - std::unique_ptr< QgsPrintLayout > layout = std::make_unique< QgsPrintLayout >( QgsProject::instance() ); + std::unique_ptr layout = std::make_unique( QgsProject::instance() ); if ( loadingTemplate ) { bool loadedOK = false; - ( void )layout->loadFromTemplate( templateDoc, QgsReadWriteContext(), true, &loadedOK ); + ( void ) layout->loadFromTemplate( templateDoc, QgsReadWriteContext(), true, &loadedOK ); if ( !loadedOK ) { QMessageBox::warning( this, tr( "Create Layout" ), tr( "Invalid template file “%1”." ).arg( templateFile.fileName() ) ); @@ -322,10 +319,10 @@ void QgsLayoutManagerDialog::createReport() title = QgsProject::instance()->layoutManager()->generateUniqueTitle( QgsMasterLayoutInterface::Report ); } - std::unique_ptr< QgsReport > report = std::make_unique< QgsReport >( QgsProject::instance() ); + std::unique_ptr report = std::make_unique( QgsProject::instance() ); report->setName( title ); - std::unique_ptr< QgsLayout > header = std::make_unique< QgsLayout >( QgsProject::instance() ); + std::unique_ptr header = std::make_unique( QgsProject::instance() ); header->initializeDefaults(); report->setHeader( header.release() ); report->setHeaderEnabled( true ); @@ -392,8 +389,7 @@ void QgsLayoutManagerDialog::removeClicked() if ( layoutItems.count() == 1 ) { title = tr( "Remove Layout" ); - message = tr( "Do you really want to remove the print layout “%1”?" ).arg( - mLayoutListView->model()->data( layoutItems.at( 0 ), Qt::DisplayRole ).toString() ); + message = tr( "Do you really want to remove the print layout “%1”?" ).arg( mLayoutListView->model()->data( layoutItems.at( 0 ), Qt::DisplayRole ).toString() ); } else { @@ -467,8 +463,7 @@ void QgsLayoutManagerDialog::duplicateClicked() if ( !newDialog ) { - QMessageBox::warning( this, tr( "Duplicate Layout" ), - tr( "Layout duplication failed." ) ); + QMessageBox::warning( this, tr( "Duplicate Layout" ), tr( "Layout duplication failed." ) ); } else { @@ -508,5 +503,3 @@ void QgsLayoutManagerDialog::showHelp() { QgsHelp::openHelp( QStringLiteral( "print_composer/overview_composer.html#the-layout-manager" ) ); } - - diff --git a/src/app/layout/qgslayoutmanagerdialog.h b/src/app/layout/qgslayoutmanagerdialog.h index b0aa8d9b6e27..443aeba7bca8 100644 --- a/src/app/layout/qgslayoutmanagerdialog.h +++ b/src/app/layout/qgslayoutmanagerdialog.h @@ -32,7 +32,7 @@ class QgsLayoutManagerProxyModel; /** * A dialog that allows management of layouts within a project. */ -class QgsLayoutManagerDialog: public QDialog, private Ui::QgsLayoutManagerBase +class QgsLayoutManagerDialog : public QDialog, private Ui::QgsLayoutManagerBase { Q_OBJECT public: @@ -45,7 +45,6 @@ class QgsLayoutManagerDialog: public QDialog, private Ui::QgsLayoutManagerBase void activate(); private: - /** * Returns the default templates (key: template name, value: absolute path to template file) * \param fromUser whether to return user templates from [profile folder]/composer_templates diff --git a/src/app/layout/qgsreportfieldgroupsectionwidget.cpp b/src/app/layout/qgsreportfieldgroupsectionwidget.cpp index 042b5b6f7c22..4b36886f867a 100644 --- a/src/app/layout/qgsreportfieldgroupsectionwidget.cpp +++ b/src/app/layout/qgsreportfieldgroupsectionwidget.cpp @@ -91,7 +91,7 @@ void QgsReportSectionFieldGroupWidget::editHeader() { if ( !mSection->header() ) { - std::unique_ptr< QgsLayout > header = std::make_unique< QgsLayout >( mSection->project() ); + std::unique_ptr header = std::make_unique( mSection->project() ); header->initializeDefaults(); mSection->setHeader( header.release() ); } @@ -109,7 +109,7 @@ void QgsReportSectionFieldGroupWidget::editFooter() { if ( !mSection->footer() ) { - std::unique_ptr< QgsLayout > footer = std::make_unique< QgsLayout >( mSection->project() ); + std::unique_ptr footer = std::make_unique( mSection->project() ); footer->initializeDefaults(); mSection->setFooter( footer.release() ); } @@ -132,7 +132,7 @@ void QgsReportSectionFieldGroupWidget::editBody() { if ( !mSection->body() ) { - std::unique_ptr< QgsLayout > body = std::make_unique< QgsLayout >( mSection->project() ); + std::unique_ptr body = std::make_unique( mSection->project() ); body->initializeDefaults(); mSection->setBody( body.release() ); } @@ -153,7 +153,7 @@ void QgsReportSectionFieldGroupWidget::sortAscendingToggled( bool checked ) void QgsReportSectionFieldGroupWidget::setLayer( QgsMapLayer *layer ) { - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer ); + QgsVectorLayer *vl = qobject_cast( layer ); if ( !vl ) return; diff --git a/src/app/layout/qgsreportfieldgroupsectionwidget.h b/src/app/layout/qgsreportfieldgroupsectionwidget.h index e7f9dbaf1ac8..c31c049a6efd 100644 --- a/src/app/layout/qgsreportfieldgroupsectionwidget.h +++ b/src/app/layout/qgsreportfieldgroupsectionwidget.h @@ -23,7 +23,7 @@ class QgsLayoutDesignerDialog; class QgsReportSectionFieldGroup; class QgsReportOrganizerWidget; -class QgsReportSectionFieldGroupWidget: public QWidget, private Ui::QgsReportWidgetFieldGroupSectionBase +class QgsReportSectionFieldGroupWidget : public QWidget, private Ui::QgsReportWidgetFieldGroupSectionBase { Q_OBJECT public: @@ -44,11 +44,9 @@ class QgsReportSectionFieldGroupWidget: public QWidget, private Ui::QgsReportWid void setField( const QString &field ); private: - QgsReportOrganizerWidget *mOrganizer = nullptr; QgsReportSectionFieldGroup *mSection = nullptr; QgsLayoutDesignerDialog *mDesigner = nullptr; - }; #endif // QGSREPORTFIELDGROUPSECTIONWIDGET_H diff --git a/src/app/layout/qgsreportlayoutsectionwidget.cpp b/src/app/layout/qgsreportlayoutsectionwidget.cpp index 98747e5f61fd..08dbaa92fc61 100644 --- a/src/app/layout/qgsreportlayoutsectionwidget.cpp +++ b/src/app/layout/qgsreportlayoutsectionwidget.cpp @@ -48,7 +48,7 @@ void QgsReportLayoutSectionWidget::editBody() { if ( !mSection->body() ) { - std::unique_ptr< QgsLayout > body = std::make_unique< QgsLayout >( mSection->project() ); + std::unique_ptr body = std::make_unique( mSection->project() ); body->initializeDefaults(); mSection->setBody( body.release() ); } diff --git a/src/app/layout/qgsreportlayoutsectionwidget.h b/src/app/layout/qgsreportlayoutsectionwidget.h index f88ccafbe11f..c45c3328f77a 100644 --- a/src/app/layout/qgsreportlayoutsectionwidget.h +++ b/src/app/layout/qgsreportlayoutsectionwidget.h @@ -23,7 +23,7 @@ class QgsLayoutDesignerDialog; class QgsReportSectionLayout; class QgsReportOrganizerWidget; -class QgsReportLayoutSectionWidget: public QWidget, private Ui::QgsReportWidgetLayoutSectionBase +class QgsReportLayoutSectionWidget : public QWidget, private Ui::QgsReportWidgetLayoutSectionBase { Q_OBJECT public: @@ -35,11 +35,9 @@ class QgsReportLayoutSectionWidget: public QWidget, private Ui::QgsReportWidgetL void editBody(); private: - QgsReportOrganizerWidget *mOrganizer = nullptr; QgsReportSectionLayout *mSection = nullptr; QgsLayoutDesignerDialog *mDesigner = nullptr; - }; #endif // QGSREPORTLAYOUTSECTIONWIDGET_H diff --git a/src/app/layout/qgsreportorganizerwidget.cpp b/src/app/layout/qgsreportorganizerwidget.cpp index b1c2565592f4..a6c4af624620 100644 --- a/src/app/layout/qgsreportorganizerwidget.cpp +++ b/src/app/layout/qgsreportorganizerwidget.cpp @@ -89,7 +89,7 @@ void QgsReportOrganizerWidget::setEditedSection( QgsAbstractReportSection *secti void QgsReportOrganizerWidget::addLayoutSection() { - std::unique_ptr< QgsReportSectionLayout > section = std::make_unique< QgsReportSectionLayout >(); + std::unique_ptr section = std::make_unique(); QgsAbstractReportSection *newSection = section.get(); mSectionModel->addSection( mViewSections->currentIndex(), std::move( section ) ); const QModelIndex newIndex = mSectionModel->indexForSection( newSection ); @@ -98,7 +98,7 @@ void QgsReportOrganizerWidget::addLayoutSection() void QgsReportOrganizerWidget::addFieldGroupSection() { - std::unique_ptr< QgsReportSectionFieldGroup > section = std::make_unique< QgsReportSectionFieldGroup >(); + std::unique_ptr section = std::make_unique(); QgsAbstractReportSection *newSection = section.get(); mSectionModel->addSection( mViewSections->currentIndex(), std::move( section ) ); const QModelIndex newIndex = mSectionModel->indexForSection( newSection ); @@ -108,33 +108,30 @@ void QgsReportOrganizerWidget::addFieldGroupSection() void QgsReportOrganizerWidget::removeSection() { QgsAbstractReportSection *section = mSectionModel->sectionForIndex( mViewSections->currentIndex() ); - if ( !section || dynamic_cast< QgsReport * >( section ) ) + if ( !section || dynamic_cast( section ) ) return; //report cannot be removed - const int res = QMessageBox::question( this, tr( "Remove Section" ), - tr( "Are you sure you want to remove the report section?" ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ); + const int res = QMessageBox::question( this, tr( "Remove Section" ), tr( "Are you sure you want to remove the report section?" ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ); if ( res == QMessageBox::No ) return; - std::function< void( QgsAbstractReportSection *section ) > cleanup; - cleanup = [ =, &cleanup]( QgsAbstractReportSection * section ) - { + std::function cleanup; + cleanup = [=, &cleanup]( QgsAbstractReportSection *section ) { if ( mDesigner->currentLayout() == section->header() || mDesigner->currentLayout() == section->footer() ) mDesigner->setCurrentLayout( nullptr ); if ( section->type() == QLatin1String( "SectionFieldGroup" ) ) { - QgsReportSectionFieldGroup *fieldGroup = static_cast< QgsReportSectionFieldGroup * >( section ); + QgsReportSectionFieldGroup *fieldGroup = static_cast( section ); if ( fieldGroup->body() == mDesigner->currentLayout() ) mDesigner->setCurrentLayout( nullptr ); } if ( section->type() == QLatin1String( "SectionLayout" ) ) { - QgsReportSectionLayout *sectionLayout = static_cast< QgsReportSectionLayout * >( section ); + QgsReportSectionLayout *sectionLayout = static_cast( section ); if ( sectionLayout->body() == mDesigner->currentLayout() ) mDesigner->setCurrentLayout( nullptr ); } - const QList< QgsAbstractReportSection * > children = section->childSections(); + const QList children = section->childSections(); for ( QgsAbstractReportSection *child : children ) cleanup( child ); }; @@ -153,19 +150,19 @@ void QgsReportOrganizerWidget::selectionChanged( const QModelIndex ¤t, con mButtonRemoveSection->setEnabled( parent != mReport ); delete mConfigWidget; - if ( QgsReportSectionLayout *section = dynamic_cast< QgsReportSectionLayout * >( parent ) ) + if ( QgsReportSectionLayout *section = dynamic_cast( parent ) ) { QgsReportLayoutSectionWidget *widget = new QgsReportLayoutSectionWidget( this, mDesigner, section ); mSettingsFrame->layout()->addWidget( widget ); mConfigWidget = widget; } - else if ( QgsReportSectionFieldGroup *section = dynamic_cast< QgsReportSectionFieldGroup * >( parent ) ) + else if ( QgsReportSectionFieldGroup *section = dynamic_cast( parent ) ) { QgsReportSectionFieldGroupWidget *widget = new QgsReportSectionFieldGroupWidget( this, mDesigner, section ); mSettingsFrame->layout()->addWidget( widget ); mConfigWidget = widget; } - else if ( QgsReport *section = dynamic_cast< QgsReport * >( parent ) ) + else if ( QgsReport *section = dynamic_cast( parent ) ) { QgsReportSectionWidget *widget = new QgsReportSectionWidget( this, mDesigner, section ); mSettingsFrame->layout()->addWidget( widget ); diff --git a/src/app/layout/qgsreportorganizerwidget.h b/src/app/layout/qgsreportorganizerwidget.h index 90083f2a68fe..715a595aa157 100644 --- a/src/app/layout/qgsreportorganizerwidget.h +++ b/src/app/layout/qgsreportorganizerwidget.h @@ -24,10 +24,10 @@ class QgsReportSectionModel; class QgsReport; class QgsMessageBar; -class QgsLayoutDesignerDialog ; +class QgsLayoutDesignerDialog; class QgsAbstractReportSection; -class QgsReportOrganizerWidget: public QgsPanelWidget, private Ui::QgsReportOrganizerBase +class QgsReportOrganizerWidget : public QgsPanelWidget, private Ui::QgsReportOrganizerBase { Q_OBJECT public: @@ -44,15 +44,12 @@ class QgsReportOrganizerWidget: public QgsPanelWidget, private Ui::QgsReportOrga void selectionChanged( const QModelIndex ¤t, const QModelIndex &previous ); private: - QgsReport *mReport = nullptr; QgsReportSectionModel *mSectionModel = nullptr; QgsMessageBar *mMessageBar = nullptr; QgsLayoutDesignerDialog *mDesigner = nullptr; QWidget *mConfigWidget = nullptr; - }; - #endif // QGSREPORTORGANIZERWIDGET_H diff --git a/src/app/layout/qgsreportsectionmodel.cpp b/src/app/layout/qgsreportsectionmodel.cpp index 3fb735a354af..b212e9cb9bdc 100644 --- a/src/app/layout/qgsreportsectionmodel.cpp +++ b/src/app/layout/qgsreportsectionmodel.cpp @@ -191,7 +191,7 @@ QgsAbstractReportSection *QgsReportSectionModel::sectionForIndex( const QModelIn return nullptr; if ( !index.internalPointer() ) // top level item - return mReport; // IMPORTANT - QgsReport uses multiple inheritance, so cannot static cast the void*! + return mReport; // IMPORTANT - QgsReport uses multiple inheritance, so cannot static cast the void*! return static_cast( index.internalPointer() ); } @@ -201,8 +201,7 @@ QModelIndex QgsReportSectionModel::indexForSection( QgsAbstractReportSection *se if ( !section ) return QModelIndex(); - std::function< QModelIndex( const QModelIndex &parent, QgsAbstractReportSection *section ) > findIndex = [&]( const QModelIndex & parent, QgsAbstractReportSection * section )->QModelIndex - { + std::function findIndex = [&]( const QModelIndex &parent, QgsAbstractReportSection *section ) -> QModelIndex { for ( int row = 0; row < rowCount( parent ); ++row ) { QModelIndex current = index( row, 0, parent ); @@ -236,7 +235,6 @@ void QgsReportSectionModel::setEditedSection( QgsAbstractReportSection *section const QModelIndex newSection = indexForSection( mEditedSection ); emit dataChanged( newSection, newSection, QVector() << Qt::DecorationRole ); } - } bool QgsReportSectionModel::removeRows( int row, int count, const QModelIndex &parent ) @@ -271,4 +269,3 @@ void QgsReportSectionModel::addSection( const QModelIndex &parent, std::unique_p parentSection->appendChild( section.release() ); endInsertRows(); } - diff --git a/src/app/layout/qgsreportsectionmodel.h b/src/app/layout/qgsreportsectionmodel.h index 7a3bde61e5e6..0d4dc1f5dc92 100644 --- a/src/app/layout/qgsreportsectionmodel.h +++ b/src/app/layout/qgsreportsectionmodel.h @@ -30,7 +30,6 @@ class QgsReportSectionModel : public QAbstractItemModel Q_OBJECT public: - /** * Constructor for QgsReportSectionModel, for the specified \a report. */ @@ -38,8 +37,7 @@ class QgsReportSectionModel : public QAbstractItemModel Qt::ItemFlags flags( const QModelIndex &index ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; - QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const override; + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; bool hasChildren( const QModelIndex &parent = QModelIndex() ) const override; int columnCount( const QModelIndex & = QModelIndex() ) const override; @@ -48,7 +46,7 @@ class QgsReportSectionModel : public QAbstractItemModel QModelIndex parent( const QModelIndex &index ) const override; bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override; - void addSection( const QModelIndex &parent, std::unique_ptr< QgsAbstractReportSection > section ); + void addSection( const QModelIndex &parent, std::unique_ptr section ); /** * Returns the report section for the given \a index. diff --git a/src/app/layout/qgsreportsectionwidget.cpp b/src/app/layout/qgsreportsectionwidget.cpp index 7deaf4af47cc..fd91cea652e4 100644 --- a/src/app/layout/qgsreportsectionwidget.cpp +++ b/src/app/layout/qgsreportsectionwidget.cpp @@ -58,7 +58,7 @@ void QgsReportSectionWidget::editHeader() { if ( !mSection->header() ) { - std::unique_ptr< QgsLayout > header = std::make_unique< QgsLayout >( mSection->project() ); + std::unique_ptr header = std::make_unique( mSection->project() ); header->initializeDefaults(); mSection->setHeader( header.release() ); } @@ -75,7 +75,7 @@ void QgsReportSectionWidget::editFooter() { if ( !mSection->footer() ) { - std::unique_ptr< QgsLayout > footer = std::make_unique< QgsLayout >( mSection->project() ); + std::unique_ptr footer = std::make_unique( mSection->project() ); footer->initializeDefaults(); mSection->setFooter( footer.release() ); } @@ -87,4 +87,3 @@ void QgsReportSectionWidget::editFooter() mOrganizer->setEditedSection( mSection ); } } - diff --git a/src/app/layout/qgsreportsectionwidget.h b/src/app/layout/qgsreportsectionwidget.h index 38a558a4e09f..abda99032a94 100644 --- a/src/app/layout/qgsreportsectionwidget.h +++ b/src/app/layout/qgsreportsectionwidget.h @@ -23,7 +23,7 @@ class QgsLayoutDesignerDialog; class QgsReport; class QgsReportOrganizerWidget; -class QgsReportSectionWidget: public QWidget, private Ui::QgsReportWidgetSectionBase +class QgsReportSectionWidget : public QWidget, private Ui::QgsReportWidgetSectionBase { Q_OBJECT public: @@ -37,11 +37,9 @@ class QgsReportSectionWidget: public QWidget, private Ui::QgsReportWidgetSection void editFooter(); private: - QgsReportOrganizerWidget *mOrganizer = nullptr; QgsReport *mSection = nullptr; QgsLayoutDesignerDialog *mDesigner = nullptr; - }; #endif // QGSREPORTSECTIONWIDGET_H diff --git a/src/app/locator/qgsactionlocatorfilter.cpp b/src/app/locator/qgsactionlocatorfilter.cpp index 712cc0fecc11..9dd792b0a530 100644 --- a/src/app/locator/qgsactionlocatorfilter.cpp +++ b/src/app/locator/qgsactionlocatorfilter.cpp @@ -23,7 +23,6 @@ #include - QgsActionLocatorFilter::QgsActionLocatorFilter( const QList &parentObjectsForActions, QObject *parent ) : QgsLocatorFilter( parent ) , mActionParents( parentObjectsForActions ) @@ -51,14 +50,14 @@ void QgsActionLocatorFilter::fetchResults( const QString &string, const QgsLocat void QgsActionLocatorFilter::triggerResult( const QgsLocatorResult &result ) { - QAction *action = qobject_cast< QAction * >( qvariant_cast( result.userData() ) ); + QAction *action = qobject_cast( qvariant_cast( result.userData() ) ); if ( action ) action->trigger(); } void QgsActionLocatorFilter::searchActions( const QString &string, QWidget *parent, QList &found ) { - const QList< QWidget *> children = parent->findChildren(); + const QList children = parent->findChildren(); for ( QWidget *widget : children ) { searchActions( string, widget, found ); diff --git a/src/app/locator/qgsactionlocatorfilter.h b/src/app/locator/qgsactionlocatorfilter.h index 1239971cd518..8809b6c7a579 100644 --- a/src/app/locator/qgsactionlocatorfilter.h +++ b/src/app/locator/qgsactionlocatorfilter.h @@ -22,17 +22,14 @@ #include "qgslocatorfilter.h" - class QAction; - class APP_EXPORT QgsActionLocatorFilter : public QgsLocatorFilter { Q_OBJECT public: - QgsActionLocatorFilter( const QList &parentObjectsForActions, QObject *parent = nullptr ); QgsActionLocatorFilter *clone() const override; QString name() const override { return QStringLiteral( "actions" ); } @@ -43,12 +40,11 @@ class APP_EXPORT QgsActionLocatorFilter : public QgsLocatorFilter void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) override; void triggerResult( const QgsLocatorResult &result ) override; - private: - - QList< QWidget * > mActionParents; - void searchActions( const QString &string, QWidget *parent, QList< QAction *> &found ); + private: + QList mActionParents; + void searchActions( const QString &string, QWidget *parent, QList &found ); }; diff --git a/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp b/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp index 50f04924dacb..b3a074af8983 100644 --- a/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp +++ b/src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp @@ -64,7 +64,7 @@ QStringList QgsActiveLayerFeaturesLocatorFilter::prepare( const QString &string, QgsSettings settings; mMaxTotalResults = settings.value( QStringLiteral( "locator_filters/active_layer_features/limit_global" ), 30, QgsSettings::App ).toInt(); - QgsVectorLayer *layer = qobject_cast< QgsVectorLayer *>( QgisApp::instance()->activeLayer() ); + QgsVectorLayer *layer = qobject_cast( QgisApp::instance()->activeLayer() ); if ( !layer ) return QStringList(); @@ -93,7 +93,7 @@ QStringList QgsActiveLayerFeaturesLocatorFilter::prepare( const QString &string, QString enhancedSearch = searchString; enhancedSearch.replace( ' ', '%' ); req.setFilterExpression( QStringLiteral( "%1 ILIKE '%%2%'" ) - .arg( layer->displayExpression(), enhancedSearch ) ); + .arg( layer->displayExpression(), enhancedSearch ) ); req.setLimit( mMaxTotalResults ); mDisplayTitleIterator = layer->getFeatures( req ); } @@ -134,8 +134,7 @@ QStringList QgsActiveLayerFeaturesLocatorFilter::prepare( const QString &string, if ( field.type() == QMetaType::Type::QString ) { - expressionParts << QStringLiteral( "%1 ILIKE '%%2%'" ).arg( QgsExpression::quotedColumnRef( field.name() ), - searchString ); + expressionParts << QStringLiteral( "%1 ILIKE '%%2%'" ).arg( QgsExpression::quotedColumnRef( field.name() ), searchString ); } else if ( allowNumeric && field.isNumeric() ) { @@ -179,9 +178,7 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c QgsLocatorResult result; result.displayString = QStringLiteral( "@%1" ).arg( field ); result.description = tr( "Limit the search to the field '%1'" ).arg( field ); - result.setUserData( QVariantMap( {{QStringLiteral( "type" ), QVariant::fromValue( ResultType::FieldRestriction )}, - {QStringLiteral( "search_text" ), QStringLiteral( "%1 @%2 " ).arg( prefix(), field ) } - } ) ); + result.setUserData( QVariantMap( { { QStringLiteral( "type" ), QVariant::fromValue( ResultType::FieldRestriction ) }, { QStringLiteral( "search_text" ), QStringLiteral( "%1 @%2 " ).arg( prefix(), field ) } } ) ); result.score = 1; emit resultFetched( result ); } @@ -198,16 +195,16 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c QgsLocatorResult result; - result.displayString = mDispExpression.evaluate( &mContext ).toString(); + result.displayString = mDispExpression.evaluate( &mContext ).toString(); result.setUserData( QVariantMap( - { - {QStringLiteral( "type" ), QVariant::fromValue( ResultType::Feature )}, - {QStringLiteral( "feature_id" ), f.id()}, - {QStringLiteral( "layer_id" ), mLayerId}, - {QStringLiteral( "layer_is_spatial" ), mLayerIsSpatial} - } ) ); + { { QStringLiteral( "type" ), QVariant::fromValue( ResultType::Feature ) }, + { QStringLiteral( "feature_id" ), f.id() }, + { QStringLiteral( "layer_id" ), mLayerId }, + { QStringLiteral( "layer_is_spatial" ), mLayerIsSpatial } + } + ) ); result.icon = mLayerIcon; - result.score = static_cast< double >( searchString.length() ) / result.displayString.size(); + result.score = static_cast( searchString.length() ) / result.displayString.size(); if ( mLayerIsSpatial ) result.actions << QgsLocatorResult::ResultAction( OpenForm, tr( "Open form…" ) ); @@ -255,14 +252,14 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c result.description = mDispExpression.evaluate( &mContext ).toString(); result.setUserData( QVariantMap( - { - {QStringLiteral( "type" ), QVariant::fromValue( ResultType::Feature )}, - {QStringLiteral( "feature_id" ), f.id()}, - {QStringLiteral( "layer_id" ), mLayerId}, - {QStringLiteral( "layer_is_spatial" ), mLayerIsSpatial} - } ) ); + { { QStringLiteral( "type" ), QVariant::fromValue( ResultType::Feature ) }, + { QStringLiteral( "feature_id" ), f.id() }, + { QStringLiteral( "layer_id" ), mLayerId }, + { QStringLiteral( "layer_is_spatial" ), mLayerIsSpatial } + } + ) ); result.icon = mLayerIcon; - result.score = static_cast< double >( searchString.length() ) / result.displayString.size(); + result.score = static_cast( searchString.length() ) / result.displayString.size(); if ( mLayerIsSpatial ) result.actions << QgsLocatorResult::ResultAction( OpenForm, tr( "Open form…" ) ); @@ -342,8 +339,7 @@ void QgsActiveLayerFeaturesLocatorFilter::openConfigWidget( QWidget *parent ) QDialogButtonBox *buttonbBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, dlg.get() ); formLayout->addRow( buttonbBox ); dlg->setLayout( formLayout ); - connect( buttonbBox, &QDialogButtonBox::accepted, dlg.get(), [&]() - { + connect( buttonbBox, &QDialogButtonBox::accepted, dlg.get(), [&]() { settings.setValue( QStringLiteral( "%1/limit_global" ).arg( key ), globalLimitSpinBox->value(), QgsSettings::App ); dlg->accept(); } ); diff --git a/src/app/locator/qgsactivelayerfeatureslocatorfilter.h b/src/app/locator/qgsactivelayerfeatureslocatorfilter.h index 75f338eb74eb..8c0aeb3a5c8c 100644 --- a/src/app/locator/qgsactivelayerfeatureslocatorfilter.h +++ b/src/app/locator/qgsactivelayerfeatureslocatorfilter.h @@ -40,7 +40,7 @@ class APP_EXPORT QgsActiveLayerFeaturesLocatorFilter : public QgsLocatorFilter void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) override; void triggerResult( const QgsLocatorResult &result ) override; void triggerResultFromAction( const QgsLocatorResult &result, const int actionId ) override; - bool hasConfigWidget() const override {return true;} + bool hasConfigWidget() const override { return true; } void openConfigWidget( QWidget *parent ) override; enum class ResultType diff --git a/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp b/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp index 3b9be2287a0b..5426fad2b4c8 100644 --- a/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp +++ b/src/app/locator/qgsalllayersfeatureslocatorfilter.cpp @@ -54,7 +54,7 @@ QStringList QgsAllLayersFeaturesLocatorFilter::prepare( const QString &string, c const QMap layers = QgsProject::instance()->mapLayers(); for ( auto it = layers.constBegin(); it != layers.constEnd(); ++it ) { - QgsVectorLayer *layer = qobject_cast< QgsVectorLayer *>( it.value() ); + QgsVectorLayer *layer = qobject_cast( it.value() ); if ( !layer || !layer->dataProvider() || !layer->flags().testFlag( QgsMapLayer::Searchable ) ) continue; @@ -70,12 +70,12 @@ QStringList QgsAllLayersFeaturesLocatorFilter::prepare( const QString &string, c QString enhancedSearch = string; enhancedSearch.replace( ' ', '%' ); req.setFilterExpression( QStringLiteral( "%1 ILIKE '%%2%'" ) - .arg( layer->displayExpression(), enhancedSearch ) ); + .arg( layer->displayExpression(), enhancedSearch ) ); req.setLimit( mMaxResultsPerLayer ); QgsFeatureRequest exactMatchRequest = req; exactMatchRequest.setFilterExpression( QStringLiteral( "%1 ILIKE '%2'" ) - .arg( layer->displayExpression(), enhancedSearch ) ); + .arg( layer->displayExpression(), enhancedSearch ) ); exactMatchRequest.setLimit( mMaxResultsPerLayer ); std::shared_ptr preparedLayer( new PreparedLayer() ); @@ -124,7 +124,7 @@ void QgsAllLayersFeaturesLocatorFilter::fetchResults( const QString &string, con result.setUserData( ResultData( f.id(), preparedLayer->layerId, preparedLayer->layerIsSpatial ).toVariant() ); foundFeatureIds << f.id(); result.icon = preparedLayer->layerIcon; - result.score = static_cast< double >( string.length() ) / result.displayString.size(); + result.score = static_cast( string.length() ) / result.displayString.size(); result.actions << QgsLocatorResult::ResultAction( OpenForm, tr( "Open form…" ) ); emit resultFetched( result ); @@ -157,7 +157,7 @@ void QgsAllLayersFeaturesLocatorFilter::fetchResults( const QString &string, con result.setUserData( ResultData( f.id(), preparedLayer->layerId, preparedLayer->layerIsSpatial ).toVariant() ); result.icon = preparedLayer->layerIcon; - result.score = static_cast< double >( string.length() ) / result.displayString.size(); + result.score = static_cast( string.length() ) / result.displayString.size(); if ( preparedLayer->layerIsSpatial ) result.actions << QgsLocatorResult::ResultAction( OpenForm, tr( "Open form…" ) ); @@ -234,8 +234,7 @@ void QgsAllLayersFeaturesLocatorFilter::openConfigWidget( QWidget *parent ) QDialogButtonBox *buttonbBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, dlg.get() ); formLayout->addRow( buttonbBox ); dlg->setLayout( formLayout ); - connect( buttonbBox, &QDialogButtonBox::accepted, dlg.get(), [&]() - { + connect( buttonbBox, &QDialogButtonBox::accepted, dlg.get(), [&]() { settings.setValue( QStringLiteral( "%1/limit_global" ).arg( key ), globalLimitSpinBox->value(), QgsSettings::App ); settings.setValue( QStringLiteral( "%1/limit_per_layer" ).arg( key ), perLayerLimitSpinBox->value(), QgsSettings::App ); dlg->accept(); diff --git a/src/app/locator/qgsalllayersfeatureslocatorfilter.h b/src/app/locator/qgsalllayersfeatureslocatorfilter.h index d255c6fec2dd..ec645c6c88aa 100644 --- a/src/app/locator/qgsalllayersfeatureslocatorfilter.h +++ b/src/app/locator/qgsalllayersfeatureslocatorfilter.h @@ -41,7 +41,7 @@ class APP_EXPORT QgsAllLayersFeaturesLocatorFilter : public QgsLocatorFilter void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) override; void triggerResult( const QgsLocatorResult &result ) override; void triggerResultFromAction( const QgsLocatorResult &result, const int actionId ) override; - bool hasConfigWidget() const override {return true;} + bool hasConfigWidget() const override { return true; } void openConfigWidget( QWidget *parent ) override; private: @@ -72,12 +72,16 @@ class APP_EXPORT QgsAllLayersFeaturesLocatorFilter : public QgsLocatorFilter ResultData( QgsFeatureId id, const QString &layerId, bool layerIsSpatial ) : mId( id ), mLayerId( layerId ), mLayerIsSpatial( layerIsSpatial ) {} - QgsFeatureId id() const {return mId;} - QString layerId() const {return mLayerId;} - bool layerIsSpatial() const {return mLayerIsSpatial;} + QgsFeatureId id() const { return mId; } + QString layerId() const { return mLayerId; } + bool layerIsSpatial() const { return mLayerIsSpatial; } - QVariant toVariant() const {return QVariantList() << mId << mLayerId << mLayerIsSpatial;} - static ResultData fromVariant( QVariant const &value ) {QList dataList = value.toList(); return ResultData( dataList.at( 0 ).toLongLong(), dataList.at( 1 ).toString(), dataList.at( 2 ).toBool() );} + QVariant toVariant() const { return QVariantList() << mId << mLayerId << mLayerIsSpatial; } + static ResultData fromVariant( QVariant const &value ) + { + QList dataList = value.toList(); + return ResultData( dataList.at( 0 ).toLongLong(), dataList.at( 1 ).toString(), dataList.at( 2 ).toBool() ); + } private: QgsFeatureId mId; diff --git a/src/app/locator/qgsbookmarklocatorfilter.h b/src/app/locator/qgsbookmarklocatorfilter.h index f0dbcc68f6a9..2b038f99f87f 100644 --- a/src/app/locator/qgsbookmarklocatorfilter.h +++ b/src/app/locator/qgsbookmarklocatorfilter.h @@ -27,7 +27,6 @@ class APP_EXPORT QgsBookmarkLocatorFilter : public QgsLocatorFilter Q_OBJECT public: - QgsBookmarkLocatorFilter( QObject *parent = nullptr ); QgsBookmarkLocatorFilter *clone() const override; QString name() const override { return QStringLiteral( "bookmarks" ); } diff --git a/src/app/locator/qgsexpressioncalculatorlocatorfilter.cpp b/src/app/locator/qgsexpressioncalculatorlocatorfilter.cpp index c06d3fd3eff8..5a6538a763c8 100644 --- a/src/app/locator/qgsexpressioncalculatorlocatorfilter.cpp +++ b/src/app/locator/qgsexpressioncalculatorlocatorfilter.cpp @@ -25,7 +25,6 @@ #include - QgsExpressionCalculatorLocatorFilter::QgsExpressionCalculatorLocatorFilter( QObject *parent ) : QgsLocatorFilter( parent ) { diff --git a/src/app/locator/qgsexpressioncalculatorlocatorfilter.h b/src/app/locator/qgsexpressioncalculatorlocatorfilter.h index f65c09146177..bf9c9545f325 100644 --- a/src/app/locator/qgsexpressioncalculatorlocatorfilter.h +++ b/src/app/locator/qgsexpressioncalculatorlocatorfilter.h @@ -22,13 +22,11 @@ #include "qgslocatorfilter.h" - class APP_EXPORT QgsExpressionCalculatorLocatorFilter : public QgsLocatorFilter { Q_OBJECT public: - QgsExpressionCalculatorLocatorFilter( QObject *parent = nullptr ); QgsExpressionCalculatorLocatorFilter *clone() const override; QString name() const override { return QStringLiteral( "calculator" ); } diff --git a/src/app/locator/qgsgotolocatorfilter.cpp b/src/app/locator/qgsgotolocatorfilter.cpp index 10af5ad09021..d286a843e553 100644 --- a/src/app/locator/qgsgotolocatorfilter.cpp +++ b/src/app/locator/qgsgotolocatorfilter.cpp @@ -48,9 +48,7 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator const QLocale locale; // Coordinates such as 106.8468,-6.3804 - QRegularExpression separatorRx( QStringLiteral( "^([0-9\\-\\%1\\%2]*)[\\s%3]*([0-9\\-\\%1\\%2]*)$" ).arg( locale.decimalPoint(), - locale.groupSeparator(), - locale.decimalPoint() != ',' && locale.groupSeparator() != ',' ? QStringLiteral( "\\," ) : QString() ) ); + QRegularExpression separatorRx( QStringLiteral( "^([0-9\\-\\%1\\%2]*)[\\s%3]*([0-9\\-\\%1\\%2]*)$" ).arg( locale.decimalPoint(), locale.groupSeparator(), locale.decimalPoint() != ',' && locale.groupSeparator() != ',' ? QStringLiteral( "\\," ) : QString() ) ); QRegularExpressionMatch match = separatorRx.match( string.trimmed() ); if ( match.hasMatch() ) { @@ -74,7 +72,7 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator { // Check if the string is a pair of decimal degrees with [N,S,E,W] suffixes separatorRx = QRegularExpression( QStringLiteral( "^\\s*([-]?\\d{1,3}(?:[\\.\\%1]\\d+)?\\s*[NSEWnsew])[\\s\\,]*([-]?\\d{1,3}(?:[\\.\\%1]\\d+)?\\s*[NSEWnsew])\\s*$" ) - .arg( locale.decimalPoint() ) ); + .arg( locale.decimalPoint() ) ); match = separatorRx.match( string.trimmed() ); if ( match.hasMatch() ) { @@ -92,7 +90,7 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator { // Check if the string is a pair of degree minute second separatorRx = QRegularExpression( QStringLiteral( "^((?:([-+nsew])\\s*)?\\d{1,3}(?:[^0-9.]+[0-5]?\\d)?[^0-9.]+[0-5]?\\d(?:[\\.\\%1]\\d+)?[^0-9.,]*[-+nsew]?)[,\\s]+((?:([-+nsew])\\s*)?\\d{1,3}(?:[^0-9.]+[0-5]?\\d)?[^0-9.]+[0-5]?\\d(?:[\\.\\%1]\\d+)?[^0-9.,]*[-+nsew]?)$" ) - .arg( locale.decimalPoint() ) ); + .arg( locale.decimalPoint() ) ); match = separatorRx.match( string.trimmed() ); if ( match.hasMatch() ) { @@ -117,11 +115,10 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator if ( !posIsWgs84 && currentCrs != wgs84Crs ) { - const QgsPointXY point( currentCrsIsXY ? firstNumber : secondNumber, - currentCrsIsXY ? secondNumber : firstNumber ); + const QgsPointXY point( currentCrsIsXY ? firstNumber : secondNumber, currentCrsIsXY ? secondNumber : firstNumber ); data.insert( QStringLiteral( "point" ), point ); - const QList< Qgis::CrsAxisDirection > axisList = currentCrs.axisOrdering(); + const QList axisList = currentCrs.axisOrdering(); QString firstSuffix; QString secondSuffix; if ( axisList.size() >= 2 ) @@ -132,9 +129,7 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator QgsLocatorResult result; result.filter = this; - result.displayString = tr( "Go to %1%2 %3%4 (Map CRS, %5)" ).arg( locale.toString( firstNumber, 'g', 10 ), firstSuffix, - locale.toString( secondNumber, 'g', 10 ), secondSuffix, - currentCrs.userFriendlyIdentifier() ); + result.displayString = tr( "Go to %1%2 %3%4 (Map CRS, %5)" ).arg( locale.toString( firstNumber, 'g', 10 ), firstSuffix, locale.toString( secondNumber, 'g', 10 ), secondSuffix, currentCrs.userFriendlyIdentifier() ); result.setUserData( data ); result.score = 0.9; emit resultFetched( result ); @@ -285,10 +280,10 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator const double width = outputSize.width() * ( height / outputSize.height() ); QgsRectangle extent; - extent.setYMinimum( dataPoint.y() - height / 2.0 ); - extent.setYMaximum( dataPoint.y() + height / 2.0 ); - extent.setXMinimum( dataPoint.x() - width / 2.0 ); - extent.setXMaximum( dataPoint.x() + width / 2.0 ); + extent.setYMinimum( dataPoint.y() - height / 2.0 ); + extent.setYMaximum( dataPoint.y() + height / 2.0 ); + extent.setXMinimum( dataPoint.x() - width / 2.0 ); + extent.setXMaximum( dataPoint.x() + width / 2.0 ); QgsScaleCalculator calculator; calculator.setMapUnits( currentCrs.mapUnits() ); @@ -303,9 +298,7 @@ void QgsGotoLocatorFilter::fetchResults( const QString &string, const QgsLocator QgsLocatorResult result; result.filter = this; - result.displayString = tr( "Go to %1°N %2°E %3(%4)" ).arg( locale.toString( point.y(), 'g', 10 ), locale.toString( point.x(), 'g', 10 ), - scale > 0.0 ? tr( "at scale 1:%1 " ).arg( scale ) : QString(), - wgs84Crs.userFriendlyIdentifier() ); + result.displayString = tr( "Go to %1°N %2°E %3(%4)" ).arg( locale.toString( point.y(), 'g', 10 ), locale.toString( point.x(), 'g', 10 ), scale > 0.0 ? tr( "at scale 1:%1 " ).arg( scale ) : QString(), wgs84Crs.userFriendlyIdentifier() ); result.setUserData( data ); result.score = 1.0; emit resultFetched( result ); @@ -329,5 +322,5 @@ void QgsGotoLocatorFilter::triggerResult( const QgsLocatorResult &result ) mapCanvas->refresh(); } - mapCanvas->flashGeometries( QList< QgsGeometry >() << QgsGeometry::fromPointXY( point ) ); + mapCanvas->flashGeometries( QList() << QgsGeometry::fromPointXY( point ) ); } diff --git a/src/app/locator/qgsgotolocatorfilter.h b/src/app/locator/qgsgotolocatorfilter.h index a8a82b56d1a2..5ff3a08e6292 100644 --- a/src/app/locator/qgsgotolocatorfilter.h +++ b/src/app/locator/qgsgotolocatorfilter.h @@ -22,15 +22,11 @@ #include "qgslocatorfilter.h" - - class APP_EXPORT QgsGotoLocatorFilter : public QgsLocatorFilter { Q_OBJECT public: - - QgsGotoLocatorFilter( QObject *parent = nullptr ); QgsGotoLocatorFilter *clone() const override; virtual QString name() const override { return QStringLiteral( "goto" ); } @@ -41,7 +37,6 @@ class APP_EXPORT QgsGotoLocatorFilter : public QgsLocatorFilter void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) override; void triggerResult( const QgsLocatorResult &result ) override; - }; #endif // QGSGOTOLOCATORFILTERS_H diff --git a/src/app/locator/qgslayermetadatalocatorfilter.cpp b/src/app/locator/qgslayermetadatalocatorfilter.cpp index 015a9ed8b74f..d1c3a0e87c45 100644 --- a/src/app/locator/qgslayermetadatalocatorfilter.cpp +++ b/src/app/locator/qgslayermetadatalocatorfilter.cpp @@ -35,13 +35,12 @@ QgsLocatorFilter *QgsLayerMetadataLocatorFilter::clone() const void QgsLayerMetadataLocatorFilter::fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) { - QgsMetadataSearchContext ctx; ctx.transformContext = context.transformContext; const QList providers { QgsApplication::instance()->layerMetadataProviderRegistry()->layerMetadataProviders() }; for ( QgsAbstractLayerMetadataProvider *mdProvider : std::as_const( providers ) ) { - const QList mdRecords { mdProvider->search( ctx, string, QgsRectangle(), feedback ).metadata() }; + const QList mdRecords { mdProvider->search( ctx, string, QgsRectangle(), feedback ).metadata() }; for ( const QgsLayerMetadataProviderResult &metadata : std::as_const( mdRecords ) ) { QgsLocatorResult result; @@ -74,11 +73,10 @@ void QgsLayerMetadataLocatorFilter::triggerResult( const QgsLocatorResult &resul QgisApp::instance()->addMeshLayer( metadataResult.uri(), metadataResult.identifier(), metadataResult.dataProviderName() ); break; } - default: // unsupported + default: // unsupported { // Ignore break; } } - } diff --git a/src/app/locator/qgslayermetadatalocatorfilter.h b/src/app/locator/qgslayermetadatalocatorfilter.h index 619b9e597eb4..df0e7ea4094a 100644 --- a/src/app/locator/qgslayermetadatalocatorfilter.h +++ b/src/app/locator/qgslayermetadatalocatorfilter.h @@ -23,7 +23,6 @@ class APP_EXPORT QgsLayerMetadataLocatorFilter : public QgsLocatorFilter { Q_OBJECT public: - explicit QgsLayerMetadataLocatorFilter( QObject *parent = nullptr ); // QgsLocatorFilter interface diff --git a/src/app/locator/qgslayertreelocatorfilter.cpp b/src/app/locator/qgslayertreelocatorfilter.cpp index b6fa4c58af3c..3d0acf4a1224 100644 --- a/src/app/locator/qgslayertreelocatorfilter.cpp +++ b/src/app/locator/qgslayertreelocatorfilter.cpp @@ -39,7 +39,7 @@ void QgsLayerTreeLocatorFilter::fetchResults( const QString &string, const QgsLo for ( QgsLayerTreeLayer *layer : layers ) { // if the layer is broken, don't include it in the results - if ( ! layer->layer() ) + if ( !layer->layer() ) continue; QgsLocatorResult result; diff --git a/src/app/locator/qgslayertreelocatorfilter.h b/src/app/locator/qgslayertreelocatorfilter.h index bae0b982908f..a4a783d94b38 100644 --- a/src/app/locator/qgslayertreelocatorfilter.h +++ b/src/app/locator/qgslayertreelocatorfilter.h @@ -22,15 +22,11 @@ #include "qgslocatorfilter.h" - - - class APP_EXPORT QgsLayerTreeLocatorFilter : public QgsLocatorFilter { Q_OBJECT public: - QgsLayerTreeLocatorFilter( QObject *parent = nullptr ); QgsLayerTreeLocatorFilter *clone() const override; QString name() const override { return QStringLiteral( "layertree" ); } @@ -41,7 +37,6 @@ class APP_EXPORT QgsLayerTreeLocatorFilter : public QgsLocatorFilter void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) override; void triggerResult( const QgsLocatorResult &result ) override; - }; #endif // QGSLAYERTREELOCATORFILTERS_H diff --git a/src/app/locator/qgslayoutlocatorfilter.cpp b/src/app/locator/qgslayoutlocatorfilter.cpp index c0d26e8de0b5..437a1d293f48 100644 --- a/src/app/locator/qgslayoutlocatorfilter.cpp +++ b/src/app/locator/qgslayoutlocatorfilter.cpp @@ -34,11 +34,11 @@ QgsLayoutLocatorFilter *QgsLayoutLocatorFilter::clone() const void QgsLayoutLocatorFilter::fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback * ) { - const QList< QgsMasterLayoutInterface * > layouts = QgsProject::instance()->layoutManager()->layouts(); + const QList layouts = QgsProject::instance()->layoutManager()->layouts(); for ( QgsMasterLayoutInterface *layout : layouts ) { // if the layout is broken, don't include it in the results - if ( ! layout ) + if ( !layout ) continue; QgsLocatorResult result; diff --git a/src/app/locator/qgslayoutlocatorfilter.h b/src/app/locator/qgslayoutlocatorfilter.h index 4ad92c9a1c70..49746f5afe35 100644 --- a/src/app/locator/qgslayoutlocatorfilter.h +++ b/src/app/locator/qgslayoutlocatorfilter.h @@ -22,15 +22,11 @@ #include "qgslocatorfilter.h" - - - class APP_EXPORT QgsLayoutLocatorFilter : public QgsLocatorFilter { Q_OBJECT public: - QgsLayoutLocatorFilter( QObject *parent = nullptr ); QgsLayoutLocatorFilter *clone() const override; QString name() const override { return QStringLiteral( "layouts" ); } @@ -41,7 +37,6 @@ class APP_EXPORT QgsLayoutLocatorFilter : public QgsLocatorFilter void fetchResults( const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback ) override; void triggerResult( const QgsLocatorResult &result ) override; - }; #endif // QGSLAYOUTLOCATORFILTERS_H diff --git a/src/app/locator/qgslocatoroptionswidget.cpp b/src/app/locator/qgslocatoroptionswidget.cpp index 6bf3da31344b..9c9635f79acb 100644 --- a/src/app/locator/qgslocatoroptionswidget.cpp +++ b/src/app/locator/qgslocatoroptionswidget.cpp @@ -33,7 +33,6 @@ QgsLocatorOptionsWidget::QgsLocatorOptionsWidget( QgsLocatorWidget *locator, QWi , mLocatorWidget( locator ) , mLocator( locator->locator() ) { - mModel = new QgsLocatorFiltersModel( mLocator, this ); setModel( mModel ); @@ -103,13 +102,13 @@ QWidget *QgsLocatorFiltersModel::configButton( const QModelIndex &index, QWidget { // use a layout to get the button center aligned QWidget *w = new QWidget( parent ); - QToolButton *bt = new QToolButton( ); + QToolButton *bt = new QToolButton(); QHBoxLayout *layout = new QHBoxLayout(); layout->setContentsMargins( 0, 0, 0, 0 ); layout->addWidget( bt ); w->setLayout( layout ); - connect( bt, &QToolButton::clicked, this, [ = ]() {filter->openConfigWidget( bt );} ); + connect( bt, &QToolButton::clicked, this, [=]() { filter->openConfigWidget( bt ); } ); bt->setMaximumSize( mIconSize, mIconSize ); bt->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); bt->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/settings.svg" ) ) ); @@ -141,8 +140,7 @@ QVariant QgsLocatorFiltersModel::data( const QModelIndex &index, int role ) cons { if ( index.parent().isValid() ) return QVariant(); - if ( !index.isValid() || index.row() < 0 || index.column() < 0 || - index.row() >= rowCount( QModelIndex() ) || index.column() >= columnCount( QModelIndex() ) ) + if ( !index.isValid() || index.row() < 0 || index.column() < 0 || index.row() >= rowCount( QModelIndex() ) || index.column() >= columnCount( QModelIndex() ) ) return QVariant(); switch ( role ) @@ -199,7 +197,6 @@ QVariant QgsLocatorFiltersModel::data( const QModelIndex &index, int role ) cons if ( index.column() == Config ) return static_cast( Qt::AlignCenter ); break; - } return QVariant(); @@ -207,8 +204,7 @@ QVariant QgsLocatorFiltersModel::data( const QModelIndex &index, int role ) cons bool QgsLocatorFiltersModel::setData( const QModelIndex &index, const QVariant &value, int role ) { - if ( !index.isValid() || index.parent().isValid() || index.row() < 0 || index.column() < 0 || - index.row() >= rowCount( QModelIndex() ) || index.column() >= columnCount( QModelIndex() ) ) + if ( !index.isValid() || index.parent().isValid() || index.row() < 0 || index.column() < 0 || index.row() >= rowCount( QModelIndex() ) || index.column() >= columnCount( QModelIndex() ) ) return false; switch ( role ) @@ -243,7 +239,7 @@ bool QgsLocatorFiltersModel::setData( const QModelIndex &index, const QVariant & case Qt::CheckStateRole: { - const bool checked = static_cast< Qt::CheckState >( value.toInt() ) == Qt::Checked; + const bool checked = static_cast( value.toInt() ) == Qt::Checked; switch ( index.column() ) { case Name: @@ -271,8 +267,7 @@ bool QgsLocatorFiltersModel::setData( const QModelIndex &index, const QVariant & Qt::ItemFlags QgsLocatorFiltersModel::flags( const QModelIndex &index ) const { - if ( !index.isValid() || index.parent().isValid() || index.row() < 0 || index.column() < 0 || - index.row() >= rowCount( QModelIndex() ) || index.column() >= columnCount( QModelIndex() ) ) + if ( !index.isValid() || index.parent().isValid() || index.row() < 0 || index.column() < 0 || index.row() >= rowCount( QModelIndex() ) || index.column() >= columnCount( QModelIndex() ) ) return QAbstractTableModel::flags( index ); Qt::ItemFlags flags = QAbstractTableModel::flags( index ); @@ -323,7 +318,7 @@ QVariant QgsLocatorFiltersModel::headerData( int section, Qt::Orientation orient void QgsLocatorFiltersModel::commitChanges() { - QHash< QgsLocatorFilter *, QString >::const_iterator itp = mPrefixes.constBegin(); + QHash::const_iterator itp = mPrefixes.constBegin(); for ( ; itp != mPrefixes.constEnd(); ++itp ) { QgsLocatorFilter *filter = itp.key(); @@ -339,7 +334,7 @@ void QgsLocatorFiltersModel::commitChanges() QgsLocator::settingsLocatorFilterPrefix->remove( filter->name() ); } } - QHash< QgsLocatorFilter *, bool >::const_iterator it = mEnabledChanges.constBegin(); + QHash::const_iterator it = mEnabledChanges.constBegin(); for ( ; it != mEnabledChanges.constEnd(); ++it ) { QgsLocatorFilter *filter = it.key(); diff --git a/src/app/locator/qgslocatoroptionswidget.h b/src/app/locator/qgslocatoroptionswidget.h index b634290be6a0..d165c5c2b141 100644 --- a/src/app/locator/qgslocatoroptionswidget.h +++ b/src/app/locator/qgslocatoroptionswidget.h @@ -35,7 +35,6 @@ class QgsLocatorOptionsWidget : public QTreeView Q_OBJECT public: - QgsLocatorOptionsWidget( QgsLocatorWidget *locator, QWidget *parent = nullptr ); public slots: @@ -62,7 +61,6 @@ class QgsLocatorFiltersModel : public QAbstractTableModel Q_OBJECT public: - //! Custom model roles enum Role { @@ -90,8 +88,7 @@ class QgsLocatorFiltersModel : public QAbstractTableModel QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override; Qt::ItemFlags flags( const QModelIndex &index ) const override; - QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const override; + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; QgsLocatorFilter *filterForIndex( const QModelIndex &index ) const; @@ -100,18 +97,14 @@ class QgsLocatorFiltersModel : public QAbstractTableModel void commitChanges(); private: - QgsLocator *mLocator = nullptr; // changes are deferred to support cancellation - QHash< QgsLocatorFilter *, QString > mPrefixes; - QHash< QgsLocatorFilter *, bool > mEnabledChanges; - QHash< QgsLocatorFilter *, bool > mDefaultChanges; + QHash mPrefixes; + QHash mEnabledChanges; + QHash mDefaultChanges; int mIconSize, mRowSize; - }; #endif // QGSLOCATOROPTIONSWIDGET_H - - diff --git a/src/app/locator/qgsnominatimlocatorfilter.cpp b/src/app/locator/qgsnominatimlocatorfilter.cpp index 60344e01b204..90d2243fa539 100644 --- a/src/app/locator/qgsnominatimlocatorfilter.cpp +++ b/src/app/locator/qgsnominatimlocatorfilter.cpp @@ -35,7 +35,6 @@ QgsNominatimLocatorFilter::QgsNominatimLocatorFilter( QgsGeocoderInterface *geoc void QgsNominatimLocatorFilter::triggerResult( const QgsLocatorResult &result ) { - QgsSettings settings; if ( !settings.value( "locator_filters/nominatim_geocoder/attribution_shown", false, QgsSettings::App ).toBool() ) { @@ -43,8 +42,7 @@ void QgsNominatimLocatorFilter::triggerResult( const QgsLocatorResult &result ) QgsMessageBarItem *messageWidget = QgsMessageBar::createMessage( tr( "The Nominatim geocoder data is made available by OpenStreetMap Foundation and contributors." ) ); QPushButton *learnMoreButton = new QPushButton( tr( "Learn more" ) ); - connect( learnMoreButton, &QPushButton::clicked, learnMoreButton, [ = ] - { + connect( learnMoreButton, &QPushButton::clicked, learnMoreButton, [=] { QDesktopServices::openUrl( QStringLiteral( "https://nominatim.org/" ) ); } ); messageWidget->layout()->addWidget( learnMoreButton ); diff --git a/src/app/locator/qgsnominatimlocatorfilter.h b/src/app/locator/qgsnominatimlocatorfilter.h index 666accb686ef..5e226a120592 100644 --- a/src/app/locator/qgsnominatimlocatorfilter.h +++ b/src/app/locator/qgsnominatimlocatorfilter.h @@ -27,11 +27,9 @@ class APP_EXPORT QgsNominatimLocatorFilter : public QgsGeocoderLocatorFilter Q_OBJECT public: - QgsNominatimLocatorFilter( QgsGeocoderInterface *geocoder, QgsMapCanvas *canvas ); void triggerResult( const QgsLocatorResult &result ) override; - }; #endif // QGSNOMINATIMLOCATORFILTERS_H diff --git a/src/app/locator/qgssettingslocatorfilter.cpp b/src/app/locator/qgssettingslocatorfilter.cpp index 8bd6271e875f..3e166e4660b2 100644 --- a/src/app/locator/qgssettingslocatorfilter.cpp +++ b/src/app/locator/qgssettingslocatorfilter.cpp @@ -33,7 +33,7 @@ void QgsSettingsLocatorFilter::fetchResults( const QString &string, const QgsLoc { QMap> matchingSettingsPagesMap; - const QMap optionsPagesMap = QgisApp::instance()->optionsPagesMap(); + const QMap optionsPagesMap = QgisApp::instance()->optionsPagesMap(); for ( auto optionsPagesIterator = optionsPagesMap.constBegin(); optionsPagesIterator != optionsPagesMap.constEnd(); ++optionsPagesIterator ) { const QString title = optionsPagesIterator.key(); @@ -76,7 +76,7 @@ void QgsSettingsLocatorFilter::fetchResults( const QString &string, const QgsLoc } } -QMap QgsSettingsLocatorFilter::settingsPage( const QString &type, const QString &page ) +QMap QgsSettingsLocatorFilter::settingsPage( const QString &type, const QString &page ) { QMap returnPage; returnPage.insert( QStringLiteral( "type" ), type ); @@ -86,7 +86,6 @@ QMap QgsSettingsLocatorFilter::settingsPage( const QString &ty void QgsSettingsLocatorFilter::triggerResult( const QgsLocatorResult &result ) { - const QMap settingsPage = qvariant_cast>( result.userData() ); const QString type = settingsPage.value( QStringLiteral( "type" ) ); const QString page = settingsPage.value( QStringLiteral( "page" ) ); diff --git a/src/app/locator/qgssettingslocatorfilter.h b/src/app/locator/qgssettingslocatorfilter.h index 50d7876edde6..e32f284fed32 100644 --- a/src/app/locator/qgssettingslocatorfilter.h +++ b/src/app/locator/qgssettingslocatorfilter.h @@ -27,7 +27,6 @@ class APP_EXPORT QgsSettingsLocatorFilter : public QgsLocatorFilter Q_OBJECT public: - QgsSettingsLocatorFilter( QObject *parent = nullptr ); QgsSettingsLocatorFilter *clone() const override; QString name() const override { return QStringLiteral( "optionpages" ); } @@ -40,8 +39,7 @@ class APP_EXPORT QgsSettingsLocatorFilter : public QgsLocatorFilter void triggerResult( const QgsLocatorResult &result ) override; private: - - QMap settingsPage( const QString &type, const QString &page ); + QMap settingsPage( const QString &type, const QString &page ); }; #endif // QGSSETTINGSLOCATORFILTERS_H diff --git a/src/app/main.cpp b/src/app/main.cpp index 7bc360acc2d7..d64a6aeef29b 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -41,7 +41,7 @@ #include #include "qgsconfig.h" -#if !defined(Q_OS_WIN) +#if !defined( Q_OS_WIN ) #include "sigwatch.h" #endif @@ -68,7 +68,7 @@ typedef SInt32 SRefCon; #endif #ifdef HAVE_CRASH_HANDLER -#if defined(__GLIBC__) || defined(__FreeBSD__) +#if defined( __GLIBC__ ) || defined( __FreeBSD__ ) #define QGIS_CRASH #include #include @@ -115,7 +115,7 @@ typedef SInt32 SRefCon; /** * Print QGIS version */ -void version( ) +void version() { const QString msg = QStringLiteral( "QGIS %1 '%2' (%3)\n" ).arg( VERSION ).arg( RELEASE_NAME ).arg( QGSVERSION ); std::cout << msg.toStdString(); @@ -129,58 +129,55 @@ void usage( const QString &appName ) QStringList msg; msg - << QStringLiteral( "QGIS is a user friendly Open Source Geographic Information System.\n" ) - << QStringLiteral( "Usage: " ) << appName << QStringLiteral( " [OPTION] [FILE]\n" ) - << QStringLiteral( " OPTION:\n" ) - << QStringLiteral( "\t[-v, --version]\tdisplay version information and exit\n" ) - << QStringLiteral( "\t[-s, --snapshot filename]\temit snapshot of loaded datasets to given file\n" ) - << QStringLiteral( "\t[-w, --width width]\twidth of snapshot to emit\n" ) - << QStringLiteral( "\t[-h, --height height]\theight of snapshot to emit\n" ) - << QStringLiteral( "\t[-l, --lang language]\tuse language for interface text (changes existing override)\n" ) - << QStringLiteral( "\t[-p, --project projectfile]\tload the given QGIS project\n" ) - << QStringLiteral( "\t[-e, --extent xmin,ymin,xmax,ymax]\tset initial map extent\n" ) - << QStringLiteral( "\t[-n, --nologo]\thide splash screen\n" ) - << QStringLiteral( "\t[-V, --noversioncheck]\tdon't check for new version of QGIS at startup\n" ) - << QStringLiteral( "\t[-P, --noplugins]\tdon't restore plugins on startup\n" ) - << QStringLiteral( "\t[-B, --skipbadlayers]\tdon't prompt for missing layers\n" ) - << QStringLiteral( "\t[-C, --nocustomization]\tdon't apply GUI customization\n" ) - << QStringLiteral( "\t[-z, --customizationfile path]\tuse the given ini file as GUI customization\n" ) - << QStringLiteral( "\t[-g, --globalsettingsfile path]\tuse the given ini file as Global Settings (defaults)\n" ) - << QStringLiteral( "\t[-a, --authdbdirectory path] use the given directory for authentication database\n" ) - << QStringLiteral( "\t[-f, --code path]\trun the given python file on load\n" ) - << QStringLiteral( "\t[-F, --py-args arguments]\targuments for python. This arguments will be available for each python execution via 'sys.argv' included the file specified by '--code'. All arguments till '--' are passed to python and ignored by QGIS\n" ) - << QStringLiteral( "\t[-d, --defaultui]\tstart by resetting user ui settings to default\n" ) - << QStringLiteral( "\t[--hide-browser]\thide the browser widget\n" ) - << QStringLiteral( "\t[--dxf-export filename.dxf]\temit dxf output of loaded datasets to given file\n" ) - << QStringLiteral( "\t[--dxf-extent xmin,ymin,xmax,ymax]\tset extent to export to dxf\n" ) - << QStringLiteral( "\t[--dxf-symbology-mode none|symbollayer|feature]\tsymbology mode for dxf output\n" ) - << QStringLiteral( "\t[--dxf-scale-denom scale]\tscale for dxf output\n" ) - << QStringLiteral( "\t[--dxf-encoding encoding]\tencoding to use for dxf output\n" ) - << QStringLiteral( "\t[--dxf-map-theme maptheme]\tmap theme to use for dxf output\n" ) - << QStringLiteral( "\t[--take-screenshots output_path]\ttake screen shots for the user documentation\n" ) - << QStringLiteral( "\t[--screenshots-categories categories]\tspecify the categories of screenshot to be used (see QgsAppScreenShots::Categories).\n" ) - << QStringLiteral( "\t[--profile name]\tload a named profile from the users profiles folder.\n" ) - << QStringLiteral( "\t[-S, --profiles-path path]\tpath to store user profile folders. Will create profiles inside a {path}\\profiles folder \n" ) - << QStringLiteral( "\t[--version-migration]\tforce the settings migration from older version if found\n" ) + << QStringLiteral( "QGIS is a user friendly Open Source Geographic Information System.\n" ) + << QStringLiteral( "Usage: " ) << appName << QStringLiteral( " [OPTION] [FILE]\n" ) + << QStringLiteral( " OPTION:\n" ) + << QStringLiteral( "\t[-v, --version]\tdisplay version information and exit\n" ) + << QStringLiteral( "\t[-s, --snapshot filename]\temit snapshot of loaded datasets to given file\n" ) + << QStringLiteral( "\t[-w, --width width]\twidth of snapshot to emit\n" ) + << QStringLiteral( "\t[-h, --height height]\theight of snapshot to emit\n" ) + << QStringLiteral( "\t[-l, --lang language]\tuse language for interface text (changes existing override)\n" ) + << QStringLiteral( "\t[-p, --project projectfile]\tload the given QGIS project\n" ) + << QStringLiteral( "\t[-e, --extent xmin,ymin,xmax,ymax]\tset initial map extent\n" ) + << QStringLiteral( "\t[-n, --nologo]\thide splash screen\n" ) + << QStringLiteral( "\t[-V, --noversioncheck]\tdon't check for new version of QGIS at startup\n" ) + << QStringLiteral( "\t[-P, --noplugins]\tdon't restore plugins on startup\n" ) + << QStringLiteral( "\t[-B, --skipbadlayers]\tdon't prompt for missing layers\n" ) + << QStringLiteral( "\t[-C, --nocustomization]\tdon't apply GUI customization\n" ) + << QStringLiteral( "\t[-z, --customizationfile path]\tuse the given ini file as GUI customization\n" ) + << QStringLiteral( "\t[-g, --globalsettingsfile path]\tuse the given ini file as Global Settings (defaults)\n" ) + << QStringLiteral( "\t[-a, --authdbdirectory path] use the given directory for authentication database\n" ) + << QStringLiteral( "\t[-f, --code path]\trun the given python file on load\n" ) + << QStringLiteral( "\t[-F, --py-args arguments]\targuments for python. This arguments will be available for each python execution via 'sys.argv' included the file specified by '--code'. All arguments till '--' are passed to python and ignored by QGIS\n" ) + << QStringLiteral( "\t[-d, --defaultui]\tstart by resetting user ui settings to default\n" ) + << QStringLiteral( "\t[--hide-browser]\thide the browser widget\n" ) + << QStringLiteral( "\t[--dxf-export filename.dxf]\temit dxf output of loaded datasets to given file\n" ) + << QStringLiteral( "\t[--dxf-extent xmin,ymin,xmax,ymax]\tset extent to export to dxf\n" ) + << QStringLiteral( "\t[--dxf-symbology-mode none|symbollayer|feature]\tsymbology mode for dxf output\n" ) + << QStringLiteral( "\t[--dxf-scale-denom scale]\tscale for dxf output\n" ) + << QStringLiteral( "\t[--dxf-encoding encoding]\tencoding to use for dxf output\n" ) + << QStringLiteral( "\t[--dxf-map-theme maptheme]\tmap theme to use for dxf output\n" ) + << QStringLiteral( "\t[--take-screenshots output_path]\ttake screen shots for the user documentation\n" ) + << QStringLiteral( "\t[--screenshots-categories categories]\tspecify the categories of screenshot to be used (see QgsAppScreenShots::Categories).\n" ) + << QStringLiteral( "\t[--profile name]\tload a named profile from the users profiles folder.\n" ) + << QStringLiteral( "\t[-S, --profiles-path path]\tpath to store user profile folders. Will create profiles inside a {path}\\profiles folder \n" ) + << QStringLiteral( "\t[--version-migration]\tforce the settings migration from older version if found\n" ) #ifdef HAVE_OPENCL - << QStringLiteral( "\t[--openclprogramfolder]\t\tpath to the folder containing the sources for OpenCL programs.\n" ) + << QStringLiteral( "\t[--openclprogramfolder]\t\tpath to the folder containing the sources for OpenCL programs.\n" ) #endif - << QStringLiteral( "\t[--help]\t\tthis text\n" ) - << QStringLiteral( "\t[--]\t\ttreat all following arguments as FILEs\n\n" ) - << QStringLiteral( " FILE:\n" ) - << QStringLiteral( " Files specified on the command line can include rasters, vectors,\n" ) - << QStringLiteral( " QGIS layer definition files (.qlr) and QGIS project files (.qgs and .qgz): \n" ) - << QStringLiteral( " 1. Rasters - supported formats include GeoTiff, DEM \n" ) - << QStringLiteral( " and others supported by GDAL\n" ) - << QStringLiteral( " 2. Vectors - supported formats include ESRI Shapefiles\n" ) - << QStringLiteral( " and others supported by OGR and PostgreSQL layers using\n" ) - << QStringLiteral( " the PostGIS extension\n" ) ; // OK + << QStringLiteral( "\t[--help]\t\tthis text\n" ) + << QStringLiteral( "\t[--]\t\ttreat all following arguments as FILEs\n\n" ) + << QStringLiteral( " FILE:\n" ) + << QStringLiteral( " Files specified on the command line can include rasters, vectors,\n" ) + << QStringLiteral( " QGIS layer definition files (.qlr) and QGIS project files (.qgs and .qgz): \n" ) + << QStringLiteral( " 1. Rasters - supported formats include GeoTiff, DEM \n" ) + << QStringLiteral( " and others supported by GDAL\n" ) + << QStringLiteral( " 2. Vectors - supported formats include ESRI Shapefiles\n" ) + << QStringLiteral( " and others supported by OGR and PostgreSQL layers using\n" ) + << QStringLiteral( " the PostGIS extension\n" ); // OK #ifdef Q_OS_WIN - MessageBoxA( nullptr, - msg.join( QString() ).toLocal8Bit().constData(), - "QGIS command line options", - MB_OK ); + MessageBoxA( nullptr, msg.join( QString() ).toLocal8Bit().constData(), "QGIS command line options", MB_OK ); #else std::cout << msg.join( QString() ).toLocal8Bit().constData(); #endif @@ -216,7 +213,7 @@ void myPrint( const char *fmt, ... ) { va_list ap; va_start( ap, fmt ); -#if defined(Q_OS_WIN) +#if defined( Q_OS_WIN ) char buffer[1024]; vsnprintf( buffer, sizeof buffer, fmt, ap ); OutputDebugStringA( buffer ); @@ -259,16 +256,16 @@ static void dumpBacktrace( unsigned int depth ) QgsDebugError( QStringLiteral( "dup to stdin failed" ) ); } - close( fd[1] ); // close writing end - execl( "/usr/bin/c++filt", "c++filt", static_cast< char * >( nullptr ) ); + close( fd[1] ); // close writing end + execl( "/usr/bin/c++filt", "c++filt", static_cast( nullptr ) ); perror( "could not start c++filt" ); exit( 1 ); } myPrint( "Stacktrace (piped through c++filt):\n" ); stderr_fd = dup( STDERR_FILENO ); - close( fd[0] ); // close reading end - close( STDERR_FILENO ); // close stderr + close( fd[0] ); // close reading end + close( STDERR_FILENO ); // close stderr // stderr to pipe int stderr_new = dup( fd[1] ); @@ -279,13 +276,13 @@ static void dumpBacktrace( unsigned int depth ) QgsDebugError( QStringLiteral( "dup to stderr failed" ) ); } - close( fd[1] ); // close duped pipe + close( fd[1] ); // close duped pipe } - void **buffer = new void *[ depth ]; + void **buffer = new void *[depth]; int nptrs = backtrace( buffer, depth ); backtrace_symbols_fd( buffer, nptrs, STDERR_FILENO ); - delete [] buffer; + delete[] buffer; if ( stderr_fd >= 0 ) { int status; @@ -299,7 +296,7 @@ static void dumpBacktrace( unsigned int depth ) close( stderr_fd ); wait( &status ); } -#elif defined(Q_OS_WIN) +#elif defined( Q_OS_WIN ) // TODO Replace with incoming QgsStackTrace #else Q_UNUSED( depth ) @@ -321,7 +318,7 @@ void qgisCrash( int signal ) // than this code would suggest, see http://stackoverflow.com/a/1024937 char exename[512]; -#if defined(__FreeBSD__) +#if defined( __FreeBSD__ ) int len = readlink( "/proc/curproc/file", exename, sizeof( exename ) - 1 ); #else int len = readlink( "/proc/self/exe", exename, sizeof( exename ) - 1 ); @@ -332,7 +329,7 @@ void qgisCrash( int signal ) } else { - exename[ len ] = 0; + exename[len] = 0; char pidstr[32]; snprintf( pidstr, sizeof pidstr, "--pid=%d", getpid() ); @@ -402,25 +399,16 @@ void myMessageOutput( QtMsgType type, const QMessageLogContext &, const QString * - QtSVG warnings with regards to lack of implementation beyond Tiny SVG 1.2 */ // TODO QGIS 4 reevaluate whether all these are still required on qt 6 - if ( msg.contains( QLatin1String( "QXcbClipboard" ), Qt::CaseInsensitive ) || - msg.contains( QLatin1String( "QGestureManager::deliverEvent" ), Qt::CaseInsensitive ) || - msg.startsWith( QLatin1String( "libpng warning: iCCP: known incorrect sRGB profile" ), Qt::CaseInsensitive ) || - msg.contains( QLatin1String( "Could not add child element to parent element because the types are incorrect" ), Qt::CaseInsensitive ) || - msg.contains( QLatin1String( "OpenType support missing for" ), Qt::CaseInsensitive ) || + if ( msg.contains( QLatin1String( "QXcbClipboard" ), Qt::CaseInsensitive ) || msg.contains( QLatin1String( "QGestureManager::deliverEvent" ), Qt::CaseInsensitive ) || msg.startsWith( QLatin1String( "libpng warning: iCCP: known incorrect sRGB profile" ), Qt::CaseInsensitive ) || msg.contains( QLatin1String( "Could not add child element to parent element because the types are incorrect" ), Qt::CaseInsensitive ) || msg.contains( QLatin1String( "OpenType support missing for" ), Qt::CaseInsensitive ) || // warnings triggered by Wayland limitations, not our responsibility or anything we can fix msg.contains( QLatin1String( "Wayland does not support" ), Qt::CaseInsensitive ) || // warnings triggered from KDE libraries, not related to QGIS - msg.contains( QLatin1String( "This plugin supports grabbing the mouse only for popup windows" ), Qt::CaseInsensitive ) || - msg.contains( QLatin1String( "KLocalizedString" ), Qt::CaseInsensitive ) || - msg.contains( QLatin1String( "KServiceTypeTrader" ), Qt::CaseInsensitive ) || - msg.contains( QLatin1String( "No node found for item that was just removed" ), Qt::CaseInsensitive ) || - msg.contains( QLatin1String( "Audio notification requested" ), Qt::CaseInsensitive ) || + msg.contains( QLatin1String( "This plugin supports grabbing the mouse only for popup windows" ), Qt::CaseInsensitive ) || msg.contains( QLatin1String( "KLocalizedString" ), Qt::CaseInsensitive ) || msg.contains( QLatin1String( "KServiceTypeTrader" ), Qt::CaseInsensitive ) || msg.contains( QLatin1String( "No node found for item that was just removed" ), Qt::CaseInsensitive ) || msg.contains( QLatin1String( "Audio notification requested" ), Qt::CaseInsensitive ) || // coming from WebEngine: - msg.contains( QLatin1String( "An OpenGL Core Profile was requested, but it is not supported on the current platform" ), Qt::CaseInsensitive ) - ) + msg.contains( QLatin1String( "An OpenGL Core Profile was requested, but it is not supported on the current platform" ), Qt::CaseInsensitive ) ) break; myPrint( "Warning: %s\n", msg.toLocal8Bit().constData() ); @@ -464,7 +452,7 @@ void myMessageOutput( QtMsgType type, const QMessageLogContext &, const QString qgisCrash( -1 ); #else dumpBacktrace( 256 ); - abort(); // deliberately dump core + abort(); // deliberately dump core #endif break; // silence warnings } @@ -477,10 +465,10 @@ void myMessageOutput( QtMsgType type, const QMessageLogContext &, const QString #ifdef _MSC_VER #undef APP_EXPORT -#define APP_EXPORT __declspec(dllexport) +#define APP_EXPORT __declspec( dllexport ) #endif -#if defined(ANDROID) || defined(Q_OS_WIN) +#if defined( ANDROID ) || defined( Q_OS_WIN ) // On Android, there there is a libqgis.so instead of a qgis executable. // The main method symbol of this library needs to be exported so it can be called by java // On Windows this main is included in qgis_app and called from mainwin.cpp @@ -517,24 +505,22 @@ int main( int argc, char *argv[] ) if ( setrlimit( RLIMIT_NOFILE, &rescLimit ) == 0 ) { - QgsDebugMsgLevel( QStringLiteral( "RLIMIT_NOFILE Soft NEW: %1 / %2" ) - .arg( rescLimit.rlim_cur ).arg( rescLimit.rlim_max ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "RLIMIT_NOFILE Soft NEW: %1 / %2" ).arg( rescLimit.rlim_cur ).arg( rescLimit.rlim_max ), 2 ); } } Q_UNUSED( oldSoft ) //avoid warnings - QgsDebugMsgLevel( QStringLiteral( "RLIMIT_NOFILE Soft/Hard ORIG: %1 / %2" ) - .arg( oldSoft ).arg( rescLimit.rlim_max ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "RLIMIT_NOFILE Soft/Hard ORIG: %1 / %2" ).arg( oldSoft ).arg( rescLimit.rlim_max ), 2 ); } #endif QgsDebugMsgLevel( QStringLiteral( "Starting qgis main" ), 1 ); -#ifdef WIN32 // Windows +#ifdef WIN32 // Windows #ifdef _MSC_VER _set_fmode( _O_BINARY ); -#else //MinGW +#else //MinGW _fmode = _O_BINARY; -#endif // _MSC_VER -#endif // WIN32 +#endif // _MSC_VER +#endif // WIN32 // Set up the custom qWarning/qDebug custom handler #ifndef ANDROID @@ -559,7 +545,7 @@ int main( int argc, char *argv[] ) #endif #endif -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) // initialize random number seed - not required for Qt 6 qsrand( time( nullptr ) ); #endif @@ -586,7 +572,7 @@ int main( int argc, char *argv[] ) bool settingsMigrationForce = false; bool mySkipVersionCheck = false; bool hideBrowser = false; -#if defined(ANDROID) +#if defined( ANDROID ) QgsDebugMsgLevel( QStringLiteral( "Android: Splash hidden" ), 2 ); myHideSplash = true; #endif @@ -634,8 +620,8 @@ int main( int argc, char *argv[] ) #endif // TODO Fix android -#if defined(ANDROID) - QgsDebugMsgLevel( QStringLiteral( "Android: All params stripped" ), 2 );// Param %1" ).arg( argv[0] ) ); +#if defined( ANDROID ) + QgsDebugMsgLevel( QStringLiteral( "Android: All params stripped" ), 2 ); // Param %1" ).arg( argv[0] ) ); //put all QGIS settings in the same place QString configpath = QgsApplication::qgisSettingsDirPath(); QgsDebugMsgLevel( QStringLiteral( "Android: configpath set to %1" ).arg( configpath ), 2 ); @@ -895,8 +881,7 @@ int main( int argc, char *argv[] ) for ( int i = 0; i < args.size(); i++ ) { QString arg = QDir::toNativeSeparators( QFileInfo( args[i] ).absoluteFilePath() ); - if ( arg.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) || - arg.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ) + if ( arg.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) || arg.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ) { sProjectFileName = arg; break; @@ -913,7 +898,7 @@ int main( int argc, char *argv[] ) ///////////////////////////////////////////////////////////////////// -#if defined(Q_OS_WIN) +#if defined( Q_OS_WIN ) // FIXES #29021 // Prevent Qt from treating the AltGr key as Ctrl+Alt on Windows, which causes shortcuts to be fired // instead of entering some characters (eg "}", "|") on some keyboard layouts @@ -922,7 +907,7 @@ int main( int argc, char *argv[] ) #endif -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(ANDROID) +#if defined( Q_OS_UNIX ) && !defined( Q_OS_MAC ) && !defined( ANDROID ) bool myUseGuiFlag = nullptr != getenv( "DISPLAY" ); #else bool myUseGuiFlag = true; @@ -930,16 +915,18 @@ int main( int argc, char *argv[] ) if ( !myUseGuiFlag ) { std::cerr << QObject::tr( - "QGIS starting in non-interactive mode not supported.\n" - "You are seeing this message most likely because you " - "have no DISPLAY environment variable set.\n" - ).toUtf8().constData(); + "QGIS starting in non-interactive mode not supported.\n" + "You are seeing this message most likely because you " + "have no DISPLAY environment variable set.\n" + ) + .toUtf8() + .constData(); exit( 1 ); //exit for now until a version of qgis is capable of running non interactive } // Set up for high displays // The following values are set by default in Qt6 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QCoreApplication::setAttribute( Qt::AA_EnableHighDpiScaling, true ); QCoreApplication::setAttribute( Qt::AA_UseHighDpiPixmaps ); QGuiApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough ); @@ -958,13 +945,13 @@ int main( int argc, char *argv[] ) QCoreApplication::setAttribute( Qt::AA_DontShowIconsInMenus, false ); // this is implicit in Qt 6 now -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QCoreApplication::setAttribute( Qt::AA_DisableWindowContextHelpButton, true ); #endif // Initialize the default surface format for all // QWindow and QWindow derived components -#if !defined(QT_NO_OPENGL) +#if !defined( QT_NO_OPENGL ) QSurfaceFormat format; format.setRenderableType( QSurfaceFormat::OpenGL ); #ifdef Q_OS_MAC @@ -982,7 +969,7 @@ int main( int argc, char *argv[] ) // Enable resource sharing between OpenGL contexts // which is required for Qt WebEngine module -#if !defined(QT_NO_OPENGL) +#if !defined( QT_NO_OPENGL ) QCoreApplication::setAttribute( Qt::AA_ShareOpenGLContexts, true ); #endif @@ -1071,7 +1058,6 @@ int main( int argc, char *argv[] ) // If profile name was not explicitly set, use the policy to determine which profile to use if ( profileName.isEmpty() ) { - // If no profiles exist, use the default profile if ( manager.allProfiles().isEmpty() ) { @@ -1173,7 +1159,7 @@ int main( int argc, char *argv[] ) } // Global locale settings - if ( myLocaleOverrideFlag && ! myGlobalLocale.isEmpty( ) ) + if ( myLocaleOverrideFlag && !myGlobalLocale.isEmpty() ) { QLocale currentLocale( myGlobalLocale ); QLocale::setDefault( currentLocale ); @@ -1212,13 +1198,13 @@ int main( int argc, char *argv[] ) // Note: this flag is ka version number so that we can reset it once we change the version. // Note2: Is this a good idea can we do it better. // Note3: Updated to only show if we have a migration from QGIS 2 - see https://github.com/qgis/QGIS/pull/38616 - QString path = QSettings( "QGIS", "QGIS2" ).fileName() ; + QString path = QSettings( "QGIS", "QGIS2" ).fileName(); if ( QFile::exists( path ) ) { QgsSettings migSettings; int firstRunVersion = migSettings.value( QStringLiteral( "migration/firstRunVersionFlag" ), 0 ).toInt(); - bool showWelcome = ( firstRunVersion == 0 || Qgis::versionInt() > firstRunVersion ); - std::unique_ptr< QgsVersionMigration > migration( QgsVersionMigration::canMigrate( 20000, Qgis::versionInt() ) ); + bool showWelcome = ( firstRunVersion == 0 || Qgis::versionInt() > firstRunVersion ); + std::unique_ptr migration( QgsVersionMigration::canMigrate( 20000, Qgis::versionInt() ) ); if ( migration && ( settingsMigrationForce || migration->requiresMigration() ) ) { bool runMigration = true; @@ -1257,10 +1243,9 @@ int main( int argc, char *argv[] ) #ifdef Q_OS_WIN // For non static builds on win (static builds are not supported) // we need to be sure we can find the qt image plugins. - QCoreApplication::addLibraryPath( QApplication::applicationDirPath() - + QDir::separator() + "qtplugins" ); + QCoreApplication::addLibraryPath( QApplication::applicationDirPath() + QDir::separator() + "qtplugins" ); #endif -#if defined(Q_OS_UNIX) +#if defined( Q_OS_UNIX ) // Resulting libraryPaths has critical QGIS plugin paths first, then any Qt plugin paths, then // any dev-defined paths (in app's qt.conf) and/or user-defined paths (QT_PLUGIN_PATH env var). // @@ -1268,8 +1253,7 @@ int main( int argc, char *argv[] ) // built against a different Qt/QGIS, while still allowing custom C++ plugins to load. QStringList libPaths( QCoreApplication::libraryPaths() ); - QgsDebugMsgLevel( QStringLiteral( "Initial macOS/UNIX QCoreApplication::libraryPaths: %1" ) - .arg( libPaths.join( " " ) ), 4 ); + QgsDebugMsgLevel( QStringLiteral( "Initial macOS/UNIX QCoreApplication::libraryPaths: %1" ).arg( libPaths.join( " " ) ), 4 ); // Strip all critical paths that should always be prepended if ( libPaths.removeAll( QDir::cleanPath( QgsApplication::pluginPath() ) ) ) @@ -1288,7 +1272,7 @@ int main( int argc, char *argv[] ) // standard Qt-specific plugin subdirectories (ones never created by QGIS, e.g. 'sqldrivers' is). // Note: bundleclicked(...) is inadequate to determine which *type* of bundle was opened, e.g. release or build dir. // An app bundled with QGIS_MACAPP_BUNDLE > 0 is considered a release bundle. - QString relLibPath( QDir::cleanPath( QCoreApplication::applicationDirPath().append( "/../PlugIns" ) ) ); + QString relLibPath( QDir::cleanPath( QCoreApplication::applicationDirPath().append( "/../PlugIns" ) ) ); // Note: relLibPath becomes the defacto QT_PLUGINS_DIR of a release app bundle if ( QFile::exists( relLibPath + QStringLiteral( "/imageformats" ) ) ) { @@ -1328,8 +1312,7 @@ int main( int argc, char *argv[] ) // Redefine library search paths. QCoreApplication::setLibraryPaths( libPaths ); - QgsDebugMsgLevel( QStringLiteral( "Rewritten macOS QCoreApplication::libraryPaths: %1" ) - .arg( QCoreApplication::libraryPaths().join( " " ) ), 4 ); + QgsDebugMsgLevel( QStringLiteral( "Rewritten macOS QCoreApplication::libraryPaths: %1" ).arg( QCoreApplication::libraryPaths().join( " " ) ), 4 ); #endif #ifdef Q_OS_MAC @@ -1353,7 +1336,7 @@ int main( int argc, char *argv[] ) else { // Use the default file location - customizationfile = profileFolder + QDir::separator() + QStringLiteral( "QGIS" ) + QDir::separator() + QStringLiteral( "QGISCUSTOMIZATION3.ini" ) ; + customizationfile = profileFolder + QDir::separator() + QStringLiteral( "QGIS" ) + QDir::separator() + QStringLiteral( "QGISCUSTOMIZATION3.ini" ); } customizationsettings = new QSettings( customizationfile, QSettings::IniFormat ); @@ -1569,7 +1552,7 @@ int main( int argc, char *argv[] ) ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// - if ( ! sProjectFileName.isEmpty() ) + if ( !sProjectFileName.isEmpty() ) { // in case the project contains broken layers, interactive // "Handle Bad Layers" is displayed that could be blocked by splash screen @@ -1584,9 +1567,7 @@ int main( int argc, char *argv[] ) { QgsDebugMsgLevel( QStringLiteral( "Trying to load file : %1" ).arg( layerName ), 2 ); // don't load anything with a .qgs extension - these are project files - if ( layerName.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) || - layerName.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) || - QgsZipUtils::isZipFile( layerName ) ) + if ( layerName.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) || layerName.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) || QgsZipUtils::isZipFile( layerName ) ) { continue; } @@ -1605,7 +1586,7 @@ int main( int argc, char *argv[] ) ///////////////////////////////////////////////////////////////////// // Set initial extent if requested ///////////////////////////////////////////////////////////////////// - if ( ! myInitialExtent.isEmpty() ) + if ( !myInitialExtent.isEmpty() ) { QgsLocaleNumC l; double coords[4]; @@ -1624,7 +1605,7 @@ int main( int argc, char *argv[] ) break; } - coords[i] = QStringView {myInitialExtent}.mid( posOld, pos - posOld ).toDouble( &ok ); + coords[i] = QStringView { myInitialExtent }.mid( posOld, pos - posOld ).toDouble( &ok ); if ( !ok ) break; @@ -1634,7 +1615,7 @@ int main( int argc, char *argv[] ) // parse last coordinate if ( ok ) { - coords[3] = QStringView {myInitialExtent}.mid( posOld ).toDouble( &ok ); + coords[3] = QStringView { myInitialExtent }.mid( posOld ).toDouble( &ok ); } if ( !ok ) @@ -1707,7 +1688,7 @@ int main( int argc, char *argv[] ) dxfExport.setExtent( dxfExtent ); QStringList layerIds; - QList< QgsDxfExport::DxfLayer > layers; + QList layers; if ( !dxfMapTheme.isEmpty() ) { const auto constMapThemeVisibleLayers = QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( dxfMapTheme ); @@ -1792,7 +1773,7 @@ int main( int argc, char *argv[] ) openClProgramFolder = getenv( "QGIS_OPENCL_PROGRAM_FOLDER" ); } - if ( ! openClProgramFolder.isEmpty() ) + if ( !openClProgramFolder.isEmpty() ) { QgsOpenClUtils::setSourcePath( openClProgramFolder ); } @@ -1818,22 +1799,20 @@ int main( int argc, char *argv[] ) // Warn if the user selection policy was set to "Use last used profile" but the last used profile was not found if ( !missingLastProfile.isEmpty() ) { - qgis->messageBar()->pushWarning( QObject::tr( "Profile not found" ), - QObject::tr( "The last used profile '%1' was not found. The default profile was used instead." ).arg( missingLastProfile ) ); + qgis->messageBar()->pushWarning( QObject::tr( "Profile not found" ), QObject::tr( "The last used profile '%1' was not found. The default profile was used instead." ).arg( missingLastProfile ) ); } -#if defined(ANDROID) +#if defined( ANDROID ) // fix for Qt Ministro hiding app's menubar in favor of native Android menus qgis->menuBar()->setNativeMenuBar( false ); qgis->menuBar()->setVisible( true ); #endif -#if !defined(Q_OS_WIN) +#if !defined( Q_OS_WIN ) UnixSignalWatcher sigwatch; sigwatch.watchForSignal( SIGINT ); - QObject::connect( &sigwatch, &UnixSignalWatcher::unixSignal, &myApp, [ ]( int signal ) - { + QObject::connect( &sigwatch, &UnixSignalWatcher::unixSignal, &myApp, []( int signal ) { switch ( signal ) { case SIGINT: diff --git a/src/app/mainwin.cpp b/src/app/mainwin.cpp index c90ef7cc88f4..4644ff9943b4 100644 --- a/src/app/mainwin.cpp +++ b/src/app/mainwin.cpp @@ -89,7 +89,7 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST std::ofstream file; file.open( envfile, std::ifstream::out ); - for ( std::list::const_iterator it = vars.begin(); it != vars.end(); ++it ) + for ( std::list::const_iterator it = vars.begin(); it != vars.end(); ++it ) { if ( getenv( it->c_str() ) ) file << *it << "=" << getenv( it->c_str() ) << std::endl; @@ -133,8 +133,8 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST #pragma GCC diagnostic ignored "-Wcast-function-type" #endif HINSTANCE hKernelDLL = LoadLibrary( "kernel32.dll" ); - BOOL ( *SetDefaultDllDirectories )( DWORD ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "SetDefaultDllDirectories" ) ) : 0; - DLL_DIRECTORY_COOKIE( *AddDllDirectory )( PCWSTR ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "AddDllDirectory" ) ) : 0; + BOOL ( *SetDefaultDllDirectories )( DWORD ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "SetDefaultDllDirectories" ) ) : 0; + DLL_DIRECTORY_COOKIE ( *AddDllDirectory )( PCWSTR ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "AddDllDirectory" ) ) : 0; #ifndef _MSC_VER // MinGW #pragma GCC diagnostic pop #endif @@ -170,7 +170,7 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST #ifdef _MSC_VER HINSTANCE hGetProcIDDLL = LoadLibrary( "qgis_app.dll" ); #else -// MinGW + // MinGW HINSTANCE hGetProcIDDLL = LoadLibrary( "libqgis_app.dll" ); #endif @@ -184,9 +184,10 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST NULL, error, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), - ( LPTSTR )&errorText, + ( LPTSTR ) &errorText, 0, - NULL ); + NULL + ); std::string message = "Could not load qgis_app.dll \n Windows Error: " + std::string( errorText ) + "\n Help: \n\n Check " + basename + ".env for correct environment paths"; diff --git a/src/app/maptools/qgsappmaptools.cpp b/src/app/maptools/qgsappmaptools.cpp index c726e7c65088..7922ec7c3026 100644 --- a/src/app/maptools/qgsappmaptools.cpp +++ b/src/app/maptools/qgsappmaptools.cpp @@ -121,13 +121,11 @@ QgsMapTool *QgsAppMapTools::mapTool( QgsAppMapTools::Tool tool ) QList QgsAppMapTools::captureTools() const { - QList< QgsMapToolCapture * > res; + QList res; for ( auto it = mTools.constBegin(); it != mTools.constEnd(); ++it ) { - if ( QgsMapToolCapture *captureTool = qobject_cast< QgsMapToolCapture * >( it.value() ) ) + if ( QgsMapToolCapture *captureTool = qobject_cast( it.value() ) ) res << captureTool; } return res; } - - diff --git a/src/app/maptools/qgsappmaptools.h b/src/app/maptools/qgsappmaptools.h index 8d7bad78d0f6..af1cb8e0215c 100644 --- a/src/app/maptools/qgsappmaptools.h +++ b/src/app/maptools/qgsappmaptools.h @@ -92,24 +92,23 @@ class QgsAppMapTools /** * Returns the specified \a tool. */ - template ToolType *mapTool( Tool tool ) + template ToolType *mapTool( Tool tool ) { QgsMapTool *t = mapTool( tool ); - return qobject_cast< ToolType * >( t ); + return qobject_cast( t ); } /** * Returns a list of all QgsMapToolCapture derived tools. */ - QList< QgsMapToolCapture * > captureTools() const; + QList captureTools() const; private: - - QHash< Tool, QPointer< QgsMapTool > > mTools; + QHash> mTools; // Disable copying as we have pointer members. QgsAppMapTools( const QgsAppMapTools & ) = delete; - QgsAppMapTools &operator= ( const QgsAppMapTools & ) = delete; + QgsAppMapTools &operator=( const QgsAppMapTools & ) = delete; }; #endif // QGSAPPMAPTOOLS_H diff --git a/src/app/maptools/qgsavoidintersectionsoperation.cpp b/src/app/maptools/qgsavoidintersectionsoperation.cpp index 7277253712c0..018007361bd1 100644 --- a/src/app/maptools/qgsavoidintersectionsoperation.cpp +++ b/src/app/maptools/qgsavoidintersectionsoperation.cpp @@ -24,12 +24,11 @@ #include "qgsproject.h" #include "qgsvectorlayer.h" -QgsAvoidIntersectionsOperation::Result QgsAvoidIntersectionsOperation::apply( QgsVectorLayer *layer, QgsFeatureId fid, QgsGeometry &geom, - const QHash > &ignoreFeatures ) +QgsAvoidIntersectionsOperation::Result QgsAvoidIntersectionsOperation::apply( QgsVectorLayer *layer, QgsFeatureId fid, QgsGeometry &geom, const QHash> &ignoreFeatures ) { QgsAvoidIntersectionsOperation::Result result; - QList avoidIntersectionsLayers; + QList avoidIntersectionsLayers; switch ( QgsProject::instance()->avoidIntersectionsMode() ) { case Qgis::AvoidIntersectionsMode::AvoidIntersectionsCurrentLayer: @@ -83,8 +82,7 @@ QgsAvoidIntersectionsOperation::Result QgsAvoidIntersectionsOperation::apply( Qg QgsMessageBarItem *messageBarItem = QgisApp::instance()->messageBar()->createMessage( tr( "Avoid overlaps" ), tr( "Only the largest of multiple created geometries was preserved." ) ); QPushButton *restoreButton = new QPushButton( tr( "Restore others" ) ); QPointer layerPtr( layer ); - connect( restoreButton, &QPushButton::clicked, restoreButton, [ = ] - { + connect( restoreButton, &QPushButton::clicked, restoreButton, [=] { if ( !layerPtr ) return; layerPtr->beginEditCommand( tr( "Restored geometry parts removed by avoid overlaps" ) ); diff --git a/src/app/maptools/qgsavoidintersectionsoperation.h b/src/app/maptools/qgsavoidintersectionsoperation.h index 47ad0e62535d..6a64b4472fc9 100644 --- a/src/app/maptools/qgsavoidintersectionsoperation.h +++ b/src/app/maptools/qgsavoidintersectionsoperation.h @@ -37,7 +37,6 @@ class APP_EXPORT QgsAvoidIntersectionsOperation : public QObject Q_OBJECT public: - /** * Constructor */ @@ -45,19 +44,18 @@ class APP_EXPORT QgsAvoidIntersectionsOperation : public QObject struct Result { - Result() - : operationResult( Qgis::GeometryOperationResult::NothingHappened ), - geometryHasChanged( false ) {} + Result() + : operationResult( Qgis::GeometryOperationResult::NothingHappened ), geometryHasChanged( false ) {} - /** + /** * The result of an avoid intersection operation */ - Qgis::GeometryOperationResult operationResult; + Qgis::GeometryOperationResult operationResult; - /** + /** * True if the geometry has changed during the avoid intersection operation */ - bool geometryHasChanged; + bool geometryHasChanged; }; /** @@ -67,8 +65,7 @@ class APP_EXPORT QgsAvoidIntersectionsOperation : public QObject * \returns the operation result * \since QGIS 3.34 */ - Result apply( QgsVectorLayer *layer, QgsFeatureId fid, QgsGeometry &geom, - const QHash > &ignoreFeatures = ( QHash >() ) ); + Result apply( QgsVectorLayer *layer, QgsFeatureId fid, QgsGeometry &geom, const QHash> &ignoreFeatures = ( QHash>() ) ); signals: diff --git a/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.cpp b/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.cpp index 68da75bcd9c1..c8d1fc811fb0 100644 --- a/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.cpp +++ b/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.cpp @@ -54,7 +54,7 @@ QgsMapToolsDigitizingTechniqueManager::QgsMapToolsDigitizingTechniqueManager( QO void QgsMapToolsDigitizingTechniqueManager::setupCanvasTools() { - const QList< QgsMapToolCapture * > captureTools = QgisApp::instance()->captureTools(); + const QList captureTools = QgisApp::instance()->captureTools(); for ( QgsMapToolCapture *tool : captureTools ) { setupTool( tool ); @@ -68,14 +68,13 @@ void QgsMapToolsDigitizingTechniqueManager::setupToolBars() QActionGroup *actionGroup = new QActionGroup( digitizeMenu ); QMap::const_iterator it = mTechniqueActions.constBegin(); - for ( ; it != mTechniqueActions.constEnd(); ++ it ) + for ( ; it != mTechniqueActions.constEnd(); ++it ) { digitizeMenu->addAction( it.value() ); actionGroup->addAction( it.value() ); } QgisApp::instance()->mActionStreamDigitize->setShortcut( tr( "R", "Keyboard shortcut: toggle stream digitizing" ) ); - connect( digitizeMenu, &QMenu::triggered, this, [ = ]( QAction * action ) - { + connect( digitizeMenu, &QMenu::triggered, this, [=]( QAction *action ) { Qgis::CaptureTechnique technique = mTechniqueActions.key( action, Qgis::CaptureTechnique::StraightSegments ); if ( mDigitizeModeToolButton->defaultAction() != action ) { @@ -107,10 +106,10 @@ void QgsMapToolsDigitizingTechniqueManager::setupToolBars() { shapeButton = new QToolButton( QgisApp::instance()->mShapeDigitizeToolBar ); shapeButton->setPopupMode( QToolButton::MenuButtonPopup ); - shapeButton->setMenu( new QMenu( ) ); + shapeButton->setMenu( new QMenu() ); QgisApp::instance()->mShapeDigitizeToolBar->addWidget( shapeButton ); - QObject::connect( shapeButton, &QToolButton::triggered, this, [ = ]( QAction * action ) {setShapeTool( action->data().toString() );} ); + QObject::connect( shapeButton, &QToolButton::triggered, this, [=]( QAction *action ) { setShapeTool( action->data().toString() ); } ); mShapeCategoryButtons.insert( metadata->category(), shapeButton ); } @@ -158,7 +157,6 @@ void QgsMapToolsDigitizingTechniqueManager::setupToolBars() QgsMapToolsDigitizingTechniqueManager::~QgsMapToolsDigitizingTechniqueManager() { - } void QgsMapToolsDigitizingTechniqueManager::setCaptureTechnique( Qgis::CaptureTechnique technique, bool alsoSetShapeTool ) @@ -170,7 +168,7 @@ void QgsMapToolsDigitizingTechniqueManager::setCaptureTechnique( Qgis::CaptureTe updateDigitizeModeButton( technique ); // QgisApp::captureTools returns all registered capture tools + the eventual current capture tool - const QList< QgsMapToolCapture * > tools = QgisApp::instance()->captureTools(); + const QList tools = QgisApp::instance()->captureTools(); for ( QgsMapToolCapture *tool : tools ) { if ( tool->supportsTechnique( technique ) ) @@ -187,7 +185,7 @@ void QgsMapToolsDigitizingTechniqueManager::setCaptureTechnique( Qgis::CaptureTe { // uncheck all the shape tools QHash::iterator sit = mShapeActions.begin(); - for ( ; sit != mShapeActions.end(); ++ sit ) + for ( ; sit != mShapeActions.end(); ++sit ) sit.value()->setChecked( false ); } } @@ -207,13 +205,13 @@ void QgsMapToolsDigitizingTechniqueManager::setShapeTool( const QString &shapeTo bt->setDefaultAction( action ); } QHash::iterator sit = mShapeActions.begin(); - for ( ; sit != mShapeActions.end(); ++ sit ) + for ( ; sit != mShapeActions.end(); ++sit ) sit.value()->setChecked( sit.value() == action ); setCaptureTechnique( Qgis::CaptureTechnique::Shape, false ); // QgisApp::captureTools returns all registered capture tools + the eventual current capture tool - const QList< QgsMapToolCapture * > tools = QgisApp::instance()->captureTools(); + const QList tools = QgisApp::instance()->captureTools(); for ( QgsMapToolCapture *tool : tools ) { if ( tool->supportsTechnique( Qgis::CaptureTechnique::Shape ) ) @@ -225,7 +223,7 @@ void QgsMapToolsDigitizingTechniqueManager::setShapeTool( const QString &shapeTo void QgsMapToolsDigitizingTechniqueManager::mapToolSet( QgsMapTool *newTool, QgsMapTool * ) { - if ( QgsMapToolCapture *captureTool = qobject_cast< QgsMapToolCapture *>( newTool ) ) + if ( QgsMapToolCapture *captureTool = qobject_cast( newTool ) ) { if ( mInitializedTools.contains( captureTool ) ) return; @@ -243,12 +241,11 @@ void QgsMapToolsDigitizingTechniqueManager::setupTool( QgsMapToolCapture *tool ) { if ( tool->action() ) { - connect( tool->action(), &QAction::toggled, this, [this, tool]( bool checked ) { enableDigitizingTechniqueActions( checked, tool->action() ); } ); + connect( tool->action(), &QAction::toggled, this, [this, tool]( bool checked ) { enableDigitizingTechniqueActions( checked, tool->action() ); } ); } mInitializedTools.insert( tool ); - connect( tool, &QObject::destroyed, this, [ = ] - { + connect( tool, &QObject::destroyed, this, [=] { mInitializedTools.remove( tool ); } ); } @@ -277,12 +274,12 @@ void QgsMapToolsDigitizingTechniqueManager::enableDigitizingTechniqueActions( bo QgsSettings settings; // QgisApp::captureTools returns all registered capture tools + the eventual current capture tool - const QList< QgsMapToolCapture * > tools = QgisApp::instance()->captureTools(); + const QList tools = QgisApp::instance()->captureTools(); const Qgis::CaptureTechnique settingsCurrentTechnique = settingsDigitizingTechnique->value(); const QString currentShapeToolId = settingMapToolShapeCurrent->value(); - QSet< Qgis::CaptureTechnique > supportedTechniques; + QSet supportedTechniques; QgsMapToolCapture *currentTool = nullptr; @@ -315,14 +312,14 @@ void QgsMapToolsDigitizingTechniqueManager::enableDigitizingTechniqueActions( bo updateDigitizeModeButton( actualCurrentTechnique ); QMap::const_iterator cit = mTechniqueActions.constBegin(); - for ( ; cit != mTechniqueActions.constEnd(); ++ cit ) + for ( ; cit != mTechniqueActions.constEnd(); ++cit ) { cit.value()->setEnabled( enabled && supportedTechniques.contains( cit.key() ) ); cit.value()->setChecked( cit.value()->isEnabled() && actualCurrentTechnique == cit.key() ); } QHash::const_iterator sit = mShapeActions.constBegin(); - for ( ; sit != mShapeActions.constEnd(); ++ sit ) + for ( ; sit != mShapeActions.constEnd(); ++sit ) { sit.value()->setEnabled( enabled && supportedTechniques.contains( Qgis::CaptureTechnique::Shape ) ); sit.value()->setChecked( actualCurrentTechnique == Qgis::CaptureTechnique::Shape && sit.value()->isEnabled() && sit.key() == currentShapeToolId ); @@ -364,8 +361,7 @@ QgsStreamDigitizingSettingsAction::QgsStreamDigitizingSettingsAction( QWidget *p QLabel *label = new QLabel( tr( "Streaming Tolerance" ) ); gLayout->addWidget( label, 1, 0 ); gLayout->addWidget( mStreamToleranceSpinBox, 1, 1 ); - connect( mStreamToleranceSpinBox, qOverload( &QgsSpinBox::valueChanged ), this, [ = ]( int value ) - { + connect( mStreamToleranceSpinBox, qOverload( &QgsSpinBox::valueChanged ), this, [=]( int value ) { QgsSettingsRegistryCore::settingsDigitizingStreamTolerance->setValue( value ); } ); diff --git a/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h b/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h index e90755ad9ef8..da3606de5b43 100644 --- a/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h +++ b/src/app/maptools/qgsmaptoolsdigitizingtechniquemanager.h @@ -33,12 +33,11 @@ class QAction; class QToolButton; -class APP_EXPORT QgsStreamDigitizingSettingsAction: public QWidgetAction +class APP_EXPORT QgsStreamDigitizingSettingsAction : public QWidgetAction { Q_OBJECT public: - QgsStreamDigitizingSettingsAction( QWidget *parent = nullptr ); ~QgsStreamDigitizingSettingsAction() override; @@ -80,12 +79,10 @@ class APP_EXPORT QgsMapToolsDigitizingTechniqueManager : public QObject QHash mShapeActions; QMap mShapeCategoryButtons; - QSet< QgsMapTool * > mInitializedTools; + QSet mInitializedTools; QToolButton *mDigitizeModeToolButton = nullptr; QgsStreamDigitizingSettingsAction *mStreamDigitizingSettingsAction = nullptr; - - }; #endif // QGSMAPTOOLSDIGITIZINGTECHNIQUEMANAGER_H diff --git a/src/app/maptools/qgsmaptoolshapecircle2points.cpp b/src/app/maptools/qgsmaptoolshapecircle2points.cpp index 9fa694fb8325..7ab87d5b03f9 100644 --- a/src/app/maptools/qgsmaptoolshapecircle2points.cpp +++ b/src/app/maptools/qgsmaptoolshapecircle2points.cpp @@ -80,4 +80,3 @@ void QgsMapToolShapeCircle2Points::cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsM mCircle = QgsCircle::from2Points( mPoints.at( 0 ), mParentTool->mapPoint( *e ) ); mTempRubberBand->setGeometry( mCircle.toCircularString( true ) ); } - diff --git a/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp b/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp index 6e21f637b8c9..263824fbf78d 100644 --- a/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp +++ b/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.cpp @@ -88,12 +88,10 @@ bool QgsMapToolShapeCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEven { bool isIntersect = false; QgsPoint ptInter; - QgsGeometryUtils::segmentIntersection( mPoints.at( 0 ), mPoints.at( 1 ), - mPoints.at( 2 ), mPoints.at( 3 ), ptInter, isIntersect ); + QgsGeometryUtils::segmentIntersection( mPoints.at( 0 ), mPoints.at( 1 ), mPoints.at( 2 ), mPoints.at( 3 ), ptInter, isIntersect ); if ( !isIntersect ) { - QgisApp::instance()->messageBar()->pushMessage( tr( "Error" ), tr( "Segments are parallels" ), - Qgis::MessageLevel::Critical ); + QgisApp::instance()->messageBar()->pushMessage( tr( "Error" ), tr( "Segments are parallels" ), Qgis::MessageLevel::Critical ); clean(); } else @@ -157,9 +155,8 @@ void QgsMapToolShapeCircle2TangentsPoint::cadCanvasMoveEvent( QgsMapMouseEvent * } } -void QgsMapToolShapeCircle2TangentsPoint::getPossibleCenter( ) +void QgsMapToolShapeCircle2TangentsPoint::getPossibleCenter() { - mCenters.clear(); if ( mPoints.size() == 4 ) @@ -174,26 +171,22 @@ void QgsMapToolShapeCircle2TangentsPoint::getPossibleCenter( ) /* use magic default values (8, QgsGeometry::JoinStyleBevel, 5), is useless for segments */ const QgsGeometry line1 = QgsGeometry( l1.release() ); - const QgsGeometry line1m = line1.offsetCurve( - mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); - const QgsGeometry line1p = line1.offsetCurve( + mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); + const QgsGeometry line1m = line1.offsetCurve( -mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); + const QgsGeometry line1p = line1.offsetCurve( +mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); const QgsGeometry line2 = QgsGeometry( l2.release() ); - const QgsGeometry line2m = line2.offsetCurve( - mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); - const QgsGeometry line2p = line2.offsetCurve( + mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); + const QgsGeometry line2m = line2.offsetCurve( -mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); + const QgsGeometry line2p = line2.offsetCurve( +mRadius, 8, Qgis::JoinStyle::Bevel, 5 ); bool isIntersect = false; QgsPoint inter; - QgsGeometryUtils::segmentIntersection( QgsPoint( line1m.asPolyline().at( 0 ) ), QgsPoint( line1m.asPolyline().at( 1 ) ), - QgsPoint( line2m.asPolyline().at( 0 ) ), QgsPoint( line2m.asPolyline().at( 1 ) ), inter, isIntersect ); + QgsGeometryUtils::segmentIntersection( QgsPoint( line1m.asPolyline().at( 0 ) ), QgsPoint( line1m.asPolyline().at( 1 ) ), QgsPoint( line2m.asPolyline().at( 0 ) ), QgsPoint( line2m.asPolyline().at( 1 ) ), inter, isIntersect ); mCenters.append( QgsPoint( inter ) ); - QgsGeometryUtils::segmentIntersection( QgsPoint( line1m.asPolyline().at( 0 ) ), QgsPoint( line1m.asPolyline().at( 1 ) ), - QgsPoint( line2p.asPolyline().at( 0 ) ), QgsPoint( line2p.asPolyline().at( 1 ) ), inter, isIntersect ); + QgsGeometryUtils::segmentIntersection( QgsPoint( line1m.asPolyline().at( 0 ) ), QgsPoint( line1m.asPolyline().at( 1 ) ), QgsPoint( line2p.asPolyline().at( 0 ) ), QgsPoint( line2p.asPolyline().at( 1 ) ), inter, isIntersect ); mCenters.append( QgsPoint( inter ) ); - QgsGeometryUtils::segmentIntersection( QgsPoint( line1p.asPolyline().at( 0 ) ), QgsPoint( line1p.asPolyline().at( 1 ) ), - QgsPoint( line2m.asPolyline().at( 0 ) ), QgsPoint( line2m.asPolyline().at( 1 ) ), inter, isIntersect ); + QgsGeometryUtils::segmentIntersection( QgsPoint( line1p.asPolyline().at( 0 ) ), QgsPoint( line1p.asPolyline().at( 1 ) ), QgsPoint( line2m.asPolyline().at( 0 ) ), QgsPoint( line2m.asPolyline().at( 1 ) ), inter, isIntersect ); mCenters.append( QgsPoint( inter ) ); - QgsGeometryUtils::segmentIntersection( QgsPoint( line1p.asPolyline().at( 0 ) ), QgsPoint( line1p.asPolyline().at( 1 ) ), - QgsPoint( line2p.asPolyline().at( 0 ) ), QgsPoint( line2p.asPolyline().at( 1 ) ), inter, isIntersect ); + QgsGeometryUtils::segmentIntersection( QgsPoint( line1p.asPolyline().at( 0 ) ), QgsPoint( line1p.asPolyline().at( 1 ) ), QgsPoint( line2p.asPolyline().at( 0 ) ), QgsPoint( line2p.asPolyline().at( 1 ) ), inter, isIntersect ); mCenters.append( QgsPoint( inter ) ); } } @@ -209,7 +202,7 @@ void QgsMapToolShapeCircle2TangentsPoint::createRadiusSpinBox() mRadiusSpinBox->setValue( mRadius ); QgisApp::instance()->addUserInputWidget( mRadiusSpinBox ); mRadiusSpinBox->setFocus( Qt::TabFocusReason ); - QObject::connect( mRadiusSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, &QgsMapToolShapeCircle2TangentsPoint::radiusSpinBoxChanged ); + QObject::connect( mRadiusSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsMapToolShapeCircle2TangentsPoint::radiusSpinBoxChanged ); } void QgsMapToolShapeCircle2TangentsPoint::deleteRadiusSpinBox() @@ -224,7 +217,7 @@ void QgsMapToolShapeCircle2TangentsPoint::deleteRadiusSpinBox() void QgsMapToolShapeCircle2TangentsPoint::radiusSpinBoxChanged( double radius ) { mRadius = radius; - getPossibleCenter( ); + getPossibleCenter(); qDeleteAll( mRubberBands ); mRubberBands.clear(); diff --git a/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.h b/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.h index 2b57fc8c3f30..6e215b254783 100644 --- a/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.h +++ b/src/app/maptools/qgsmaptoolshapecircle2tangentspoint.h @@ -41,12 +41,13 @@ class APP_EXPORT QgsMapToolShapeCircle2TangentsPointMetadata : public QgsMapTool QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class QgsMapToolShapeCircle2TangentsPoint: public QgsMapToolShapeCircleAbstract +class QgsMapToolShapeCircle2TangentsPoint : public QgsMapToolShapeCircleAbstract { Q_OBJECT public: - QgsMapToolShapeCircle2TangentsPoint( QgsMapToolCapture *parentTool ) : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircle2TangentsPointMetadata::TOOL_ID, parentTool ) {} + QgsMapToolShapeCircle2TangentsPoint( QgsMapToolCapture *parentTool ) + : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircle2TangentsPointMetadata::TOOL_ID, parentTool ) {} ~QgsMapToolShapeCircle2TangentsPoint() override; bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; diff --git a/src/app/maptools/qgsmaptoolshapecircle3points.h b/src/app/maptools/qgsmaptoolshapecircle3points.h index 34eaf2cfc669..3098d2d79804 100644 --- a/src/app/maptools/qgsmaptoolshapecircle3points.h +++ b/src/app/maptools/qgsmaptoolshapecircle3points.h @@ -37,12 +37,13 @@ class APP_EXPORT QgsMapToolShapeCircle3PointsMetadata : public QgsMapToolShapeMe QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeCircle3Points: public QgsMapToolShapeCircleAbstract +class APP_EXPORT QgsMapToolShapeCircle3Points : public QgsMapToolShapeCircleAbstract { Q_OBJECT public: - QgsMapToolShapeCircle3Points( QgsMapToolCapture *parentTool ) : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircle3PointsMetadata::TOOL_ID, parentTool ) {} + QgsMapToolShapeCircle3Points( QgsMapToolCapture *parentTool ) + : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircle3PointsMetadata::TOOL_ID, parentTool ) {} bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; void cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; diff --git a/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp b/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp index 76cf0f5dbb10..a79b770edb0f 100644 --- a/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp +++ b/src/app/maptools/qgsmaptoolshapecircle3tangents.cpp @@ -154,10 +154,9 @@ void QgsMapToolShapeCircle3Tangents::cadCanvasMoveEvent( QgsMapMouseEvent *e, Qg mTempRubberBand->show(); } } - } -void QgsMapToolShapeCircle3Tangents::clean( ) +void QgsMapToolShapeCircle3Tangents::clean() { mPosPoints.clear(); QgsMapToolShapeCircleAbstract::clean(); diff --git a/src/app/maptools/qgsmaptoolshapecircle3tangents.h b/src/app/maptools/qgsmaptoolshapecircle3tangents.h index 310335bde244..57daf038539f 100644 --- a/src/app/maptools/qgsmaptoolshapecircle3tangents.h +++ b/src/app/maptools/qgsmaptoolshapecircle3tangents.h @@ -37,12 +37,13 @@ class APP_EXPORT QgsMapToolShapeCircle3TangentsMetadata : public QgsMapToolShape QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class QgsMapToolShapeCircle3Tangents: public QgsMapToolShapeCircleAbstract +class QgsMapToolShapeCircle3Tangents : public QgsMapToolShapeCircleAbstract { Q_OBJECT public: - QgsMapToolShapeCircle3Tangents( QgsMapToolCapture *parentTool ) : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircle3TangentsMetadata::TOOL_ID, parentTool ) {} + QgsMapToolShapeCircle3Tangents( QgsMapToolCapture *parentTool ) + : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircle3TangentsMetadata::TOOL_ID, parentTool ) {} bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; void cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; diff --git a/src/app/maptools/qgsmaptoolshapecircleabstract.h b/src/app/maptools/qgsmaptoolshapecircleabstract.h index 8348915007ae..d26cc6c603fc 100644 --- a/src/app/maptools/qgsmaptoolshapecircleabstract.h +++ b/src/app/maptools/qgsmaptoolshapecircleabstract.h @@ -23,31 +23,29 @@ #include "qgspointlocator.h" - struct EdgesOnlyFilter : public QgsPointLocator::MatchFilter { - bool acceptMatch( const QgsPointLocator::Match &m ) override { return m.hasEdge(); } + bool acceptMatch( const QgsPointLocator::Match &m ) override { return m.hasEdge(); } }; -class APP_EXPORT QgsMapToolShapeCircleAbstract: public QgsMapToolShapeAbstract +class APP_EXPORT QgsMapToolShapeCircleAbstract : public QgsMapToolShapeAbstract { Q_OBJECT public: - QgsMapToolShapeCircleAbstract( const QString &id, QgsMapToolCapture *parentTool ) : QgsMapToolShapeAbstract( id, parentTool ) {} + QgsMapToolShapeCircleAbstract( const QString &id, QgsMapToolCapture *parentTool ) + : QgsMapToolShapeAbstract( id, parentTool ) {} virtual ~QgsMapToolShapeCircleAbstract() = default; void clean() override; protected: - void addCircleToParentTool(); //! Circle QgsCircle mCircle; - }; #endif // QGSMAPTOOLSHAPECIRCLEABSTRACT_H diff --git a/src/app/maptools/qgsmaptoolshapecirclecenterpoint.cpp b/src/app/maptools/qgsmaptoolshapecirclecenterpoint.cpp index 7c70132dcdac..371f50a4890a 100644 --- a/src/app/maptools/qgsmaptoolshapecirclecenterpoint.cpp +++ b/src/app/maptools/qgsmaptoolshapecirclecenterpoint.cpp @@ -65,7 +65,6 @@ bool QgsMapToolShapeCircleCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent * mTempRubberBand = mParentTool->createGeometryRubberBand( type, true ); mTempRubberBand->show(); } - } else if ( e->button() == Qt::RightButton ) { diff --git a/src/app/maptools/qgsmaptoolshapecirclecenterpoint.h b/src/app/maptools/qgsmaptoolshapecirclecenterpoint.h index b51be861a044..f521918fef10 100644 --- a/src/app/maptools/qgsmaptoolshapecirclecenterpoint.h +++ b/src/app/maptools/qgsmaptoolshapecirclecenterpoint.h @@ -37,12 +37,13 @@ class APP_EXPORT QgsMapToolShapeCircleCenterPointMetadata : public QgsMapToolSha QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeCircleCenterPoint: public QgsMapToolShapeCircleAbstract +class APP_EXPORT QgsMapToolShapeCircleCenterPoint : public QgsMapToolShapeCircleAbstract { Q_OBJECT public: - QgsMapToolShapeCircleCenterPoint( QgsMapToolCapture *parentTool ) : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircleCenterPointMetadata::TOOL_ID, parentTool ) {} + QgsMapToolShapeCircleCenterPoint( QgsMapToolCapture *parentTool ) + : QgsMapToolShapeCircleAbstract( QgsMapToolShapeCircleCenterPointMetadata::TOOL_ID, parentTool ) {} bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; void cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; diff --git a/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp b/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp index e55f8b2b3f6b..2ac02acae489 100644 --- a/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp +++ b/src/app/maptools/qgsmaptoolshapecircularstringabstract.cpp @@ -63,7 +63,7 @@ void QgsMapToolShapeCircularStringAbstract::undo() mPoints.removeLast(); std::unique_ptr geomRubberBand( new QgsCircularString() ); std::unique_ptr geomTempRubberBand( new QgsLineString() ); - const int lastPositionCompleteCircularString = mPoints.size() - 1 - ( mPoints.size() + 1 ) % 2 ; + const int lastPositionCompleteCircularString = mPoints.size() - 1 - ( mPoints.size() + 1 ) % 2; geomTempRubberBand->setPoints( mPoints.mid( lastPositionCompleteCircularString ) ); if ( mTempRubberBand ) @@ -205,7 +205,7 @@ void QgsMapToolShapeCircularStringAbstract::addCurveToParentTool() if ( drawAsPolygon ) { - std::unique_ptr ls( c->curveToLine( ) ); + std::unique_ptr ls( c->curveToLine() ); mParentTool->addCurve( ls.release() ); delete c; } diff --git a/src/app/maptools/qgsmaptoolshapecircularstringabstract.h b/src/app/maptools/qgsmaptoolshapecircularstringabstract.h index 083fbe7c4bae..5704bcf083de 100644 --- a/src/app/maptools/qgsmaptoolshapecircularstringabstract.h +++ b/src/app/maptools/qgsmaptoolshapecircularstringabstract.h @@ -22,7 +22,7 @@ class QgsGeometryRubberBand; -class APP_EXPORT QgsMapToolShapeCircularStringAbstract: public QgsMapToolShapeAbstract +class APP_EXPORT QgsMapToolShapeCircularStringAbstract : public QgsMapToolShapeAbstract { Q_OBJECT public: @@ -39,7 +39,6 @@ class APP_EXPORT QgsMapToolShapeCircularStringAbstract: public QgsMapToolShapeAb void undo() override; protected: - void addCurveToParentTool(); //! The rubberband to show the already completed circular strings diff --git a/src/app/maptools/qgsmaptoolshapecircularstringradius.cpp b/src/app/maptools/qgsmaptoolshapecircularstringradius.cpp index 25baf12e777c..21e22379f5fa 100644 --- a/src/app/maptools/qgsmaptoolshapecircularstringradius.cpp +++ b/src/app/maptools/qgsmaptoolshapecircularstringradius.cpp @@ -148,8 +148,7 @@ void QgsMapToolShapeCircularStringRadius::recalculateTempRubberBand( const QgsPo { //recalculate midpoint on circle segment QgsPoint midPoint; - if ( !QgsGeometryUtils::segmentMidPoint( mPoints.at( mPoints.size() - 2 ), mTemporaryEndPoint, midPoint, mRadius, - QgsPoint( mousePosition ) ) ) + if ( !QgsGeometryUtils::segmentMidPoint( mPoints.at( mPoints.size() - 2 ), mTemporaryEndPoint, midPoint, mRadius, QgsPoint( mousePosition ) ) ) { return; } @@ -181,7 +180,7 @@ void QgsMapToolShapeCircularStringRadius::createRadiusSpinBox() mRadiusSpinBox->setPrefix( tr( "Radius: " ) ); mRadiusSpinBox->setValue( mRadius ); QgisApp::instance()->addUserInputWidget( mRadiusSpinBox ); - connect( mRadiusSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMapToolShapeCircularStringRadius::updateRadiusFromSpinBox ); + connect( mRadiusSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsMapToolShapeCircularStringRadius::updateRadiusFromSpinBox ); mRadiusSpinBox->setFocus( Qt::TabFocusReason ); } diff --git a/src/app/maptools/qgsmaptoolshapecircularstringradius.h b/src/app/maptools/qgsmaptoolshapecircularstringradius.h index e2cb97d9efe3..6e2d0b539f75 100644 --- a/src/app/maptools/qgsmaptoolshapecircularstringradius.h +++ b/src/app/maptools/qgsmaptoolshapecircularstringradius.h @@ -40,7 +40,7 @@ class APP_EXPORT QgsMapToolShapeCircularStringRadiusMetadata : public QgsMapTool QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeCircularStringRadius: public QgsMapToolShapeCircularStringAbstract +class APP_EXPORT QgsMapToolShapeCircularStringRadius : public QgsMapToolShapeCircularStringAbstract { Q_OBJECT public: diff --git a/src/app/maptools/qgsmaptoolshapeellipseabstract.cpp b/src/app/maptools/qgsmaptoolshapeellipseabstract.cpp index 05ded26d5123..bd030944e4e2 100644 --- a/src/app/maptools/qgsmaptoolshapeellipseabstract.cpp +++ b/src/app/maptools/qgsmaptoolshapeellipseabstract.cpp @@ -30,7 +30,6 @@ void QgsMapToolShapeEllipseAbstract::addEllipseToParentTool() std::unique_ptr ls( mEllipse.toLineString( segments() ) ); mParentTool->addCurve( ls.release() ); - } void QgsMapToolShapeEllipseAbstract::clean() diff --git a/src/app/maptools/qgsmaptoolshapeellipseabstract.h b/src/app/maptools/qgsmaptoolshapeellipseabstract.h index 20ff9ccff512..dfb7004a4950 100644 --- a/src/app/maptools/qgsmaptoolshapeellipseabstract.h +++ b/src/app/maptools/qgsmaptoolshapeellipseabstract.h @@ -25,7 +25,7 @@ class QgsGeometryRubberBand; class QgsSnapIndicator; -class APP_EXPORT QgsMapToolShapeEllipseAbstract: public QgsMapToolShapeAbstract +class APP_EXPORT QgsMapToolShapeEllipseAbstract : public QgsMapToolShapeAbstract { Q_OBJECT public: @@ -42,7 +42,7 @@ class APP_EXPORT QgsMapToolShapeEllipseAbstract: public QgsMapToolShapeAbstract QgsEllipse mEllipse; //! convenient method to return the number of segments - unsigned int segments( ) { return QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->value() * 12; } + unsigned int segments() { return QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->value() * 12; } }; #endif // QGSMAPTOOLSHAPEELLIPSEABSTRACT_H diff --git a/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp b/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp index 28c3f676d31b..4f77c324f28d 100644 --- a/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp +++ b/src/app/maptools/qgsmaptoolshapeellipsecenter2points.cpp @@ -56,7 +56,6 @@ bool QgsMapToolShapeEllipseCenter2Points::cadCanvasReleaseEvent( QgsMapMouseEven const QgsPoint point = mParentTool->mapPoint( *e ); if ( e->button() == Qt::LeftButton ) { - if ( mPoints.size() < 2 ) mPoints.append( point ); diff --git a/src/app/maptools/qgsmaptoolshapeellipsecenter2points.h b/src/app/maptools/qgsmaptoolshapeellipsecenter2points.h index 9e37a46e2de9..da2d6e5e73cf 100644 --- a/src/app/maptools/qgsmaptoolshapeellipsecenter2points.h +++ b/src/app/maptools/qgsmaptoolshapeellipsecenter2points.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeEllipseCenter2PointsMetadata : public QgsMapTool QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeEllipseCenter2Points: public QgsMapToolShapeEllipseAbstract +class APP_EXPORT QgsMapToolShapeEllipseCenter2Points : public QgsMapToolShapeEllipseAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshapeellipsecenterpoint.h b/src/app/maptools/qgsmaptoolshapeellipsecenterpoint.h index bdd8145081e9..808b922acfe6 100644 --- a/src/app/maptools/qgsmaptoolshapeellipsecenterpoint.h +++ b/src/app/maptools/qgsmaptoolshapeellipsecenterpoint.h @@ -37,12 +37,13 @@ class APP_EXPORT QgsMapToolShapeEllipseCenterPointMetadata : public QgsMapToolSh QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeEllipseCenterPoint: public QgsMapToolShapeEllipseAbstract +class APP_EXPORT QgsMapToolShapeEllipseCenterPoint : public QgsMapToolShapeEllipseAbstract { Q_OBJECT public: - QgsMapToolShapeEllipseCenterPoint( QgsMapToolCapture *parentTool ) : QgsMapToolShapeEllipseAbstract( QgsMapToolShapeEllipseCenterPointMetadata::TOOL_ID, parentTool ) {} + QgsMapToolShapeEllipseCenterPoint( QgsMapToolCapture *parentTool ) + : QgsMapToolShapeEllipseAbstract( QgsMapToolShapeEllipseCenterPointMetadata::TOOL_ID, parentTool ) {} bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; void cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; diff --git a/src/app/maptools/qgsmaptoolshapeellipseextent.h b/src/app/maptools/qgsmaptoolshapeellipseextent.h index 01ca27b1f048..eb4f0cfc13d2 100644 --- a/src/app/maptools/qgsmaptoolshapeellipseextent.h +++ b/src/app/maptools/qgsmaptoolshapeellipseextent.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeEllipseExtentMetadata : public QgsMapToolShapeMe QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeEllipseExtent: public QgsMapToolShapeEllipseAbstract +class APP_EXPORT QgsMapToolShapeEllipseExtent : public QgsMapToolShapeEllipseAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshapeellipsefoci.h b/src/app/maptools/qgsmaptoolshapeellipsefoci.h index 123cb6cf6d8a..ec7442951932 100644 --- a/src/app/maptools/qgsmaptoolshapeellipsefoci.h +++ b/src/app/maptools/qgsmaptoolshapeellipsefoci.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeEllipseFociMetadata : public QgsMapToolShapeMeta QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeEllipseFoci: public QgsMapToolShapeEllipseAbstract +class APP_EXPORT QgsMapToolShapeEllipseFoci : public QgsMapToolShapeEllipseAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshaperectangle3points.cpp b/src/app/maptools/qgsmaptoolshaperectangle3points.cpp index f1428728b92d..a7fd5b6380a4 100644 --- a/src/app/maptools/qgsmaptoolshaperectangle3points.cpp +++ b/src/app/maptools/qgsmaptoolshaperectangle3points.cpp @@ -76,8 +76,7 @@ QgsMapToolShapeAbstract *QgsMapToolShapeRectangle3PointsMetadata::factory( QgsMa } QgsMapToolShapeRectangle3Points::QgsMapToolShapeRectangle3Points( const QString &id, QgsMapToolShapeRectangle3PointsMetadata::CreateMode createMode, QgsMapToolCapture *parentTool ) - : QgsMapToolShapeRectangleAbstract( id, parentTool ), - mCreateMode( createMode ) + : QgsMapToolShapeRectangleAbstract( id, parentTool ), mCreateMode( createMode ) { } @@ -160,7 +159,7 @@ void QgsMapToolShapeRectangle3Points::cadCanvasMoveEvent( QgsMapMouseEvent *e, Q mRectangle = QgsQuadrilateral::rectangleFrom3Points( mPoints.at( 0 ), mPoints.at( 1 ), point, QgsQuadrilateral::Projected ); break; } - mTempRubberBand->setGeometry( mRectangle.toPolygon( ) ); + mTempRubberBand->setGeometry( mRectangle.toPolygon() ); } break; default: diff --git a/src/app/maptools/qgsmaptoolshaperectangle3points.h b/src/app/maptools/qgsmaptoolshaperectangle3points.h index 72e0819fd43e..5bf61aced62f 100644 --- a/src/app/maptools/qgsmaptoolshaperectangle3points.h +++ b/src/app/maptools/qgsmaptoolshaperectangle3points.h @@ -48,15 +48,13 @@ class APP_EXPORT QgsMapToolShapeRectangle3PointsMetadata : public QgsMapToolShap private: CreateMode mCreateMode; - }; -class APP_EXPORT QgsMapToolShapeRectangle3Points: public QgsMapToolShapeRectangleAbstract +class APP_EXPORT QgsMapToolShapeRectangle3Points : public QgsMapToolShapeRectangleAbstract { Q_OBJECT public: - QgsMapToolShapeRectangle3Points( const QString &id, QgsMapToolShapeRectangle3PointsMetadata::CreateMode createMode, QgsMapToolCapture *parentTool ); bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; diff --git a/src/app/maptools/qgsmaptoolshaperectangleabstract.cpp b/src/app/maptools/qgsmaptoolshaperectangleabstract.cpp index 7715eeaa208c..1eeae9ea44a8 100644 --- a/src/app/maptools/qgsmaptoolshaperectangleabstract.cpp +++ b/src/app/maptools/qgsmaptoolshaperectangleabstract.cpp @@ -25,21 +25,20 @@ #include "qgsmaptoolcapture.h" -void QgsMapToolShapeRectangleAbstract::addRectangleToParentTool( ) +void QgsMapToolShapeRectangleAbstract::addRectangleToParentTool() { if ( !mParentTool || !mRectangle.isValid() ) { return; } - mParentTool->clearCurve( ); + mParentTool->clearCurve(); // keep z value from the first snapped point std::unique_ptr lineString( mRectangle.toLineString() ); for ( const QgsPoint &point : std::as_const( mPoints ) ) { - if ( QgsWkbTypes::hasZ( point.wkbType() ) && - point.z() != mParentTool->defaultZValue() ) + if ( QgsWkbTypes::hasZ( point.wkbType() ) && point.z() != mParentTool->defaultZValue() ) { lineString->dropZValue(); lineString->addZValue( point.z() ); diff --git a/src/app/maptools/qgsmaptoolshaperectangleabstract.h b/src/app/maptools/qgsmaptoolshaperectangleabstract.h index a0a77df51f72..93b27bb9fcf3 100644 --- a/src/app/maptools/qgsmaptoolshaperectangleabstract.h +++ b/src/app/maptools/qgsmaptoolshaperectangleabstract.h @@ -21,7 +21,7 @@ #include "qgsquadrilateral.h" #include "qgis_app.h" -class APP_EXPORT QgsMapToolShapeRectangleAbstract: public QgsMapToolShapeAbstract +class APP_EXPORT QgsMapToolShapeRectangleAbstract : public QgsMapToolShapeAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshaperectanglecenter.cpp b/src/app/maptools/qgsmaptoolshaperectanglecenter.cpp index 62ad7512bb96..67e591a0d45a 100644 --- a/src/app/maptools/qgsmaptoolshaperectanglecenter.cpp +++ b/src/app/maptools/qgsmaptoolshaperectanglecenter.cpp @@ -90,13 +90,11 @@ void QgsMapToolShapeRectangleCenter::cadCanvasMoveEvent( QgsMapMouseEvent *e, Qg { case 1: { - const double dist = mPoints.at( 0 ).distance( point ); const double angle = mPoints.at( 0 ).azimuth( point ); mRectangle = QgsQuadrilateral::rectangleFromExtent( mPoints.at( 0 ).project( -dist, angle ), mPoints.at( 0 ).project( dist, angle ) ); mTempRubberBand->setGeometry( mRectangle.toPolygon() ); - } break; default: diff --git a/src/app/maptools/qgsmaptoolshaperectanglecenter.h b/src/app/maptools/qgsmaptoolshaperectanglecenter.h index 1cece565fcf8..503a534574a0 100644 --- a/src/app/maptools/qgsmaptoolshaperectanglecenter.h +++ b/src/app/maptools/qgsmaptoolshaperectanglecenter.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeRectangleCenterMetadata : public QgsMapToolShape QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeRectangleCenter: public QgsMapToolShapeRectangleAbstract +class APP_EXPORT QgsMapToolShapeRectangleCenter : public QgsMapToolShapeRectangleAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshaperectangleextent.h b/src/app/maptools/qgsmaptoolshaperectangleextent.h index b13f2013ef81..ed8a3192cd26 100644 --- a/src/app/maptools/qgsmaptoolshaperectangleextent.h +++ b/src/app/maptools/qgsmaptoolshaperectangleextent.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeRectangleExtentMetadata : public QgsMapToolShape QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeRectangleExtent: public QgsMapToolShapeRectangleAbstract +class APP_EXPORT QgsMapToolShapeRectangleExtent : public QgsMapToolShapeRectangleAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshaperegularpolygon2points.cpp b/src/app/maptools/qgsmaptoolshaperegularpolygon2points.cpp index 110c788ee4de..4ae5e063ae66 100644 --- a/src/app/maptools/qgsmaptoolshaperegularpolygon2points.cpp +++ b/src/app/maptools/qgsmaptoolshaperegularpolygon2points.cpp @@ -90,7 +90,7 @@ void QgsMapToolShapeRegularPolygon2Points::cadCanvasMoveEvent( QgsMapMouseEvent { Q_UNUSED( mode ) - const QgsPoint point = mParentTool->mapPoint( *e ); + const QgsPoint point = mParentTool->mapPoint( *e ); if ( mTempRubberBand ) { diff --git a/src/app/maptools/qgsmaptoolshaperegularpolygon2points.h b/src/app/maptools/qgsmaptoolshaperegularpolygon2points.h index 98a01603ab54..af87b0700228 100644 --- a/src/app/maptools/qgsmaptoolshaperegularpolygon2points.h +++ b/src/app/maptools/qgsmaptoolshaperegularpolygon2points.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeRegularPolygon2PointsMetadata : public QgsMapToo QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeRegularPolygon2Points: public QgsMapToolShapeRegularPolygonAbstract +class APP_EXPORT QgsMapToolShapeRegularPolygon2Points : public QgsMapToolShapeRegularPolygonAbstract { Q_OBJECT @@ -50,7 +50,6 @@ class APP_EXPORT QgsMapToolShapeRegularPolygon2Points: public QgsMapToolShapeReg bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; void cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) override; - }; #endif // QGSMAPTOOLSHAPEREGULARPOLYGON2POINTS_H diff --git a/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.cpp b/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.cpp index 3261c51eb3db..02b2719f1d2e 100644 --- a/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.cpp +++ b/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.cpp @@ -52,14 +52,13 @@ void QgsMapToolShapeRegularPolygonAbstract::addRegularPolygonToParentTool() { return; } - mParentTool->clearCurve( ); + mParentTool->clearCurve(); // keep z value from the first snapped point std::unique_ptr ls( mRegularPolygon.toLineString() ); for ( const QgsPoint &point : std::as_const( mPoints ) ) { - if ( QgsWkbTypes::hasZ( point.wkbType() ) && - point.z() != mParentTool->defaultZValue() ) + if ( QgsWkbTypes::hasZ( point.wkbType() ) && point.z() != mParentTool->defaultZValue() ) { ls->dropZValue(); ls->addZValue( point.z() ); diff --git a/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.h b/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.h index 09dd6faef393..76d894eb5605 100644 --- a/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.h +++ b/src/app/maptools/qgsmaptoolshaperegularpolygonabstract.h @@ -23,7 +23,7 @@ class QSpinBox; -class APP_EXPORT QgsMapToolShapeRegularPolygonAbstract: public QgsMapToolShapeAbstract +class APP_EXPORT QgsMapToolShapeRegularPolygonAbstract : public QgsMapToolShapeAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshaperegularpolygoncentercorner.h b/src/app/maptools/qgsmaptoolshaperegularpolygoncentercorner.h index a170f701913b..28599c80b487 100644 --- a/src/app/maptools/qgsmaptoolshaperegularpolygoncentercorner.h +++ b/src/app/maptools/qgsmaptoolshaperegularpolygoncentercorner.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeRegularPolygonCenterCornerMetadata : public QgsM QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeRegularPolygonCenterCorner: public QgsMapToolShapeRegularPolygonAbstract +class APP_EXPORT QgsMapToolShapeRegularPolygonCenterCorner : public QgsMapToolShapeRegularPolygonAbstract { Q_OBJECT diff --git a/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.cpp b/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.cpp index 4cc383437fc5..c347976d00a9 100644 --- a/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.cpp +++ b/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.cpp @@ -56,7 +56,6 @@ QgsMapToolShapeRegularPolygonCenterPoint::~QgsMapToolShapeRegularPolygonCenterPo bool QgsMapToolShapeRegularPolygonCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) { - const QgsPoint point = mParentTool->mapPoint( *e ); if ( e->button() == Qt::LeftButton ) diff --git a/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.h b/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.h index 2bf9e365b2a8..da3c203387cc 100644 --- a/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.h +++ b/src/app/maptools/qgsmaptoolshaperegularpolygoncenterpoint.h @@ -37,7 +37,7 @@ class APP_EXPORT QgsMapToolShapeRegularPolygonCenterPointMetadata : public QgsMa QgsMapToolShapeAbstract *factory( QgsMapToolCapture *parentTool ) const override; }; -class APP_EXPORT QgsMapToolShapeRegularPolygonCenterPoint: public QgsMapToolShapeRegularPolygonAbstract +class APP_EXPORT QgsMapToolShapeRegularPolygonCenterPoint : public QgsMapToolShapeRegularPolygonAbstract { Q_OBJECT diff --git a/src/app/mesh/qgsmaptooleditmeshframe.cpp b/src/app/mesh/qgsmaptooleditmeshframe.cpp index ef844d32f9b4..52f437180ca6 100644 --- a/src/app/mesh/qgsmaptooleditmeshframe.cpp +++ b/src/app/mesh/qgsmaptooleditmeshframe.cpp @@ -56,7 +56,8 @@ // -QgsZValueWidget::QgsZValueWidget( const QString &label, QWidget *parent ): QWidget( parent ) +QgsZValueWidget::QgsZValueWidget( const QString &label, QWidget *parent ) + : QWidget( parent ) { QHBoxLayout *layout = new QHBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); @@ -142,10 +143,10 @@ QgsMeshEditForceByLineAction::QgsMeshEditForceByLineAction( QObject *parent ) mUnitSelecionWidget = new QgsUnitSelectionWidget(); mUnitSelecionWidget->setUnits( - { - Qgis::RenderUnit::MetersInMapUnits, - Qgis::RenderUnit::MapUnits - } ); + { Qgis::RenderUnit::MetersInMapUnits, + Qgis::RenderUnit::MapUnits + } + ); Qgis::RenderUnit toleranceUnit = settings.enumValue( QStringLiteral( "UI/Mesh/ForceByLineToleranceUnit" ), Qgis::RenderUnit::MapUnits ); mUnitSelecionWidget->setUnit( toleranceUnit ); @@ -197,8 +198,7 @@ void QgsMeshEditForceByLineAction::updateSettings() QgsSettings settings; settings.setValue( QStringLiteral( "UI/Mesh/ForceByLineNewVertex" ), mCheckBoxNewVertex->isChecked() ); - settings.setEnumValue( QStringLiteral( "UI/Mesh/ForceByLineInterpolateFrom" ), - static_cast( mComboInterpolateFrom->currentData().toInt() ) ); + settings.setEnumValue( QStringLiteral( "UI/Mesh/ForceByLineInterpolateFrom" ), static_cast( mComboInterpolateFrom->currentData().toInt() ) ); settings.setValue( QStringLiteral( "UI/Mesh/ForceByLineToleranceValue" ), mToleranceSpinBox->value() ); settings.setEnumValue( QStringLiteral( "UI/Mesh/ForceByLineToleranceUnit" ), mUnitSelecionWidget->unit() ); } @@ -248,28 +248,25 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas ) mActionRemoveFaces = new QAction( tr( "Remove Current Face" ), this ); mActionSplitFaces = new QAction( tr( "Split Current Face" ), this ); - connect( mActionRemoveVerticesFillingHole, &QAction::triggered, this, [this] {removeSelectedVerticesFromMesh( true );} ); - connect( mActionRemoveVerticesWithoutFillingHole, &QAction::triggered, this, [this] {removeSelectedVerticesFromMesh( false );} ); + connect( mActionRemoveVerticesFillingHole, &QAction::triggered, this, [this] { removeSelectedVerticesFromMesh( true ); } ); + connect( mActionRemoveVerticesWithoutFillingHole, &QAction::triggered, this, [this] { removeSelectedVerticesFromMesh( false ); } ); connect( mActionRemoveFaces, &QAction::triggered, this, &QgsMapToolEditMeshFrame::removeFacesFromMesh ); connect( mActionSplitFaces, &QAction::triggered, this, &QgsMapToolEditMeshFrame::splitSelectedFaces ); - connect( mActionDigitizing, &QAction::toggled, this, [this]( bool checked ) - { + connect( mActionDigitizing, &QAction::toggled, this, [this]( bool checked ) { if ( checked ) activateWithState( Digitizing ); } ); for ( int i = 0; i < mSelectActions.count(); ++i ) { - connect( mSelectActions.at( i ), &QAction::triggered, this, [i] - { + connect( mSelectActions.at( i ), &QAction::triggered, this, [i] { QgsSettings settings; settings.setValue( QStringLiteral( "UI/Mesh/defaultSelection" ), i ); } ); } - connect( mActionSelectByPolygon, &QAction::triggered, this, [this] - { + connect( mActionSelectByPolygon, &QAction::triggered, this, [this] { if ( mActionSelectByPolygon->isChecked() ) { activateWithState( SelectingByPolygon ); @@ -278,14 +275,12 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas ) mSelectionBand->reset( Qgis::GeometryType::Polygon ); } ); - connect( mActionSelectIsolatedVertices, &QAction::triggered, this, [this] - { + connect( mActionSelectIsolatedVertices, &QAction::triggered, this, [this] { onEditingStarted(); setSelectedVertices( mCurrentEditor->freeVerticesIndexes(), Qgis::SelectBehavior::SetSelection ); } ); - connect( mActionSelectAllVertices, &QAction::triggered, this, [this] - { + connect( mActionSelectAllVertices, &QAction::triggered, this, [this] { onEditingStarted(); QList verticesIndexes = mCurrentLayer->selectVerticesByExpression( QgsExpression( "true" ) ); setSelectedVertices( verticesIndexes, Qgis::SelectBehavior::SetSelection ); @@ -294,8 +289,7 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas ) connect( mActionSelectByExpression, &QAction::triggered, this, &QgsMapToolEditMeshFrame::showSelectByExpressionDialog ); connect( mActionTransformCoordinates, &QAction::triggered, this, &QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget ); connect( mActionReindexMesh, &QAction::triggered, this, &QgsMapToolEditMeshFrame::reindexMesh ); - connect( mActionDelaunayTriangulation, &QAction::triggered, this, [this] - { + connect( mActionDelaunayTriangulation, &QAction::triggered, this, [this] { if ( mCurrentEditor && mSelectedVertices.count() >= 3 ) { QgsTemporaryCursorOverride waitCursor( Qt::WaitCursor ); @@ -307,8 +301,7 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas ) QgisApp::instance()->messageBar()->pushInfo( tr( "Delaunay triangulation" ), triangulation.message() ); } } ); - connect( mActionFacesRefinement, &QAction::triggered, this, [this] - { + connect( mActionFacesRefinement, &QAction::triggered, this, [this] { QgsTemporaryCursorOverride waitCursor( Qt::WaitCursor ); QgsMeshEditRefineFaces refinement; if ( mCurrentEditor && mSelectedFaces.count() > 0 ) @@ -318,19 +311,17 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas ) } else if ( mCurrentFaceIndex != -1 ) { - refinement.setInputFaces( {mCurrentFaceIndex} ); + refinement.setInputFaces( { mCurrentFaceIndex } ); mCurrentEditor->advancedEdit( &refinement ); } } ); - connect( mSelectionHandler.get(), &QgsMapToolSelectionHandler::geometryChanged, this, [this]( Qt::KeyboardModifiers modifiers ) - { + connect( mSelectionHandler.get(), &QgsMapToolSelectionHandler::geometryChanged, this, [this]( Qt::KeyboardModifiers modifiers ) { mIsSelectingPolygonInProgress = false; selectByGeometry( mSelectionHandler->selectedGeometry(), modifiers ); } ); - connect( mActionForceByLines, &QAction::toggled, this, [this]( bool checked ) - { + connect( mActionForceByLines, &QAction::toggled, this, [this]( bool checked ) { if ( mIsInitialized ) mForceByLineRubberBand->reset( Qgis::GeometryType::Line ); mForcingLineZValue.clear(); @@ -342,8 +333,7 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas ) } } ); - connect( cadDockWidget(), &QgsAdvancedDigitizingDockWidget::cadEnabledChanged, this, [this]( bool enable ) - { + connect( cadDockWidget(), &QgsAdvancedDigitizingDockWidget::cadEnabledChanged, this, [this]( bool enable ) { if ( !isActive() || !mCurrentEditor ) return; @@ -384,14 +374,14 @@ void QgsMapToolEditMeshFrame::setActionsEnable( bool enable ) { QList actions; actions - << mActionDigitizing - << mActionSelectByPolygon - << mActionSelectByExpression - << mActionTransformCoordinates - << mActionForceByLines - << mActionReindexMesh - << mActionSelectIsolatedVertices - << mActionSelectAllVertices; + << mActionDigitizing + << mActionSelectByPolygon + << mActionSelectByExpression + << mActionTransformCoordinates + << mActionForceByLines + << mActionReindexMesh + << mActionSelectIsolatedVertices + << mActionSelectAllVertices; for ( QAction *action : std::as_const( actions ) ) action->setEnabled( enable ); @@ -400,20 +390,20 @@ void QgsMapToolEditMeshFrame::setActionsEnable( bool enable ) QList QgsMapToolEditMeshFrame::mapToolActions() { - return QList() - << mActionDigitizing - << mActionSelectByPolygon - << mActionForceByLines; + return QList() + << mActionDigitizing + << mActionSelectByPolygon + << mActionForceByLines; } QAction *QgsMapToolEditMeshFrame::digitizeAction() const { - return mActionDigitizing; + return mActionDigitizing; } QList QgsMapToolEditMeshFrame::selectActions() const { - return mSelectActions; + return mSelectActions; } QAction *QgsMapToolEditMeshFrame::defaultSelectActions() const @@ -435,8 +425,8 @@ QAction *QgsMapToolEditMeshFrame::transformAction() const QList QgsMapToolEditMeshFrame::forceByLinesActions() const { - return QList() - << mActionForceByLines; + return QList() + << mActionForceByLines; } QAction *QgsMapToolEditMeshFrame::defaultForceAction() const @@ -493,7 +483,7 @@ void QgsMapToolEditMeshFrame::initialize() if ( !mNewFaceBand ) mNewFaceBand = createRubberBand( Qgis::GeometryType::Polygon ); mInvalidFaceColor = QColor( 255, 0, 0, mNewFaceBand->fillColor().alpha() ); //override color and keep only the transparency - mValidFaceColor = QColor( 0, 255, 0, mNewFaceBand->fillColor().alpha() ); //override color and keep only the transparency + mValidFaceColor = QColor( 0, 255, 0, mNewFaceBand->fillColor().alpha() ); //override color and keep only the transparency mNewFaceBand->setFillColor( mInvalidFaceColor ); mNewFaceBand->setVisible( false ); mNewFaceBand->setZValue( 10 ); @@ -613,7 +603,7 @@ void QgsMapToolEditMeshFrame::clearAll() mFaceRubberBand->deleteLater(); mFaceRubberBand = nullptr; - mFaceVerticesBand ->deleteLater(); + mFaceVerticesBand->deleteLater(); mFaceVerticesBand = nullptr; mVertexBand->deleteLater(); @@ -647,8 +637,8 @@ bool QgsMapToolEditMeshFrame::populateContextMenuWithEvent( QMenu *menu, QgsMapM case Digitizing: case SelectingByPolygon: { - QList newActions; - QList lastActions; + QList newActions; + QList lastActions; if ( !mSelectedVertices.isEmpty() ) { @@ -658,23 +648,19 @@ bool QgsMapToolEditMeshFrame::populateContextMenuWithEvent( QMenu *menu, QgsMapM newActions << mActionRemoveVerticesFillingHole << mActionRemoveVerticesWithoutFillingHole; } - if ( !mSelectedFaces.isEmpty() || - ( mCurrentFaceIndex != -1 && mCurrentState == Digitizing ) ) + if ( !mSelectedFaces.isEmpty() || ( mCurrentFaceIndex != -1 && mCurrentState == Digitizing ) ) { newActions << mActionRemoveFaces; } - if ( mSplittableFaceCount > 0 || - ( mCurrentFaceIndex != -1 && mCurrentEditor->faceCanBeSplit( mCurrentFaceIndex ) ) ) + if ( mSplittableFaceCount > 0 || ( mCurrentFaceIndex != -1 && mCurrentEditor->faceCanBeSplit( mCurrentFaceIndex ) ) ) newActions << mActionSplitFaces; int currentFaceSize = mCurrentFaceIndex != -1 ? nativeFace( mCurrentFaceIndex ).size() : 0; - if ( mRefinableFaceCount > 0 || - currentFaceSize == 3 || - currentFaceSize == 4 ) + if ( mRefinableFaceCount > 0 || currentFaceSize == 3 || currentFaceSize == 4 ) lastActions << mActionFacesRefinement; - const QList existingActions = menu->actions(); + const QList existingActions = menu->actions(); if ( !newActions.isEmpty() ) { if ( existingActions.isEmpty() ) @@ -728,8 +714,7 @@ QgsMapTool::Flags QgsMapToolEditMeshFrame::flags() const void QgsMapToolEditMeshFrame::forceByLineBySelectedFeature( QgsMapMouseEvent *e ) { - const QList &results = - QgsIdentifyMenu::findFeaturesOnCanvas( e, mCanvas, QList() << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ); + const QList &results = QgsIdentifyMenu::findFeaturesOnCanvas( e, mCanvas, QList() << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ); QgsIdentifyMenu *menu = new QgsIdentifyMenu( mCanvas ); menu->setExecWithSingleResult( true ); @@ -761,9 +746,7 @@ void QgsMapToolEditMeshFrame::cadCanvasPressEvent( QgsMapMouseEvent *e ) if ( !mCurrentEditor ) return; - if ( e->button() == Qt::LeftButton && - ( !mCadDockWidget->cadEnabled() || - mCadDockWidget->betweenLineConstraint() == Qgis::BetweenLineConstraint::NoConstraint ) ) + if ( e->button() == Qt::LeftButton && ( !mCadDockWidget->cadEnabled() || mCadDockWidget->betweenLineConstraint() == Qgis::BetweenLineConstraint::NoConstraint ) ) mLeftButtonPressed = true; switch ( mCurrentState ) @@ -794,7 +777,7 @@ void QgsMapToolEditMeshFrame::cadCanvasPressEvent( QgsMapMouseEvent *e ) // The workaround is to check if a feature exist under the mouse before sending the event to the selection handler. // This is not ideal because that leads to a double search but no better idea for now to allow the editing context menu with selecting by polygon - bool hasSelectableFeature = ! QgsIdentifyMenu::findFeaturesOnCanvas( e, mCanvas, QList() << Qgis::GeometryType::Polygon ).isEmpty(); + bool hasSelectableFeature = !QgsIdentifyMenu::findFeaturesOnCanvas( e, mCanvas, QList() << Qgis::GeometryType::Polygon ).isEmpty(); if ( hasSelectableFeature || mIsSelectingPolygonInProgress ) mSelectionHandler->canvasPressEvent( e ); @@ -915,14 +898,13 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) case Digitizing: if ( e->button() == Qt::LeftButton ) { - if ( mDoubleClicks ) //double clicks --> add a vertex + if ( mDoubleClicks ) //double clicks --> add a vertex { addVertex( mFirstClickPoint, e->mapPointMatch() ); mCadDockWidget->setPoints( QList() << mFirstClickPoint << mFirstClickPoint ); } - else if ( mNewFaceMarker->isVisible() && - mapPoint.distance( mNewFaceMarker->center() ) < tolerance - && mCurrentVertexIndex >= 0 ) //new face marker clicked --> start adding a new face + else if ( mNewFaceMarker->isVisible() && mapPoint.distance( mNewFaceMarker->center() ) < tolerance + && mCurrentVertexIndex >= 0 ) //new face marker clicked --> start adding a new face { clearSelection(); mCurrentState = AddingNewFace; @@ -933,34 +915,30 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) const QgsPointXY ¤tPoint = mapVertexXY( mCurrentVertexIndex ); cadDockWidget()->setPoints( QList() << currentPoint << currentPoint ); } - else if ( isSelectionGrapped( mapPoint ) && //click on a selected vertex, an edge or face box - !( e->modifiers() &Qt::ControlModifier ) ) // without control modifier that is used to remove from the selection + else if ( isSelectionGrapped( mapPoint ) && //click on a selected vertex, an edge or face box + !( e->modifiers() & Qt::ControlModifier ) ) // without control modifier that is used to remove from the selection { mCurrentState = MovingSelection; mCadDockWidget->setEnabledZ( false ); mStartMovingPoint = mapPoint; cadDockWidget()->setPoints( QList() << mapPoint << mapPoint ); } - else if ( mFlipEdgeMarker->isVisible() && - e->mapPoint().distance( mFlipEdgeMarker->center() ) < tolerance && - mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) // flip edge + else if ( mFlipEdgeMarker->isVisible() && e->mapPoint().distance( mFlipEdgeMarker->center() ) < tolerance && mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) // flip edge { clearSelection(); mCadDockWidget->clearPoints(); const QVector edgeVert = edgeVertices( mCurrentEdge ); mCurrentEditor->flipEdge( edgeVert.at( 0 ), edgeVert.at( 1 ) ); - mCurrentEdge = {-1, -1}; + mCurrentEdge = { -1, -1 }; highLight( mapPoint ); } - else if ( mMergeFaceMarker->isVisible() && - e->mapPoint().distance( mMergeFaceMarker->center() ) < tolerance && - mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) // merge two faces + else if ( mMergeFaceMarker->isVisible() && e->mapPoint().distance( mMergeFaceMarker->center() ) < tolerance && mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) // merge two faces { clearSelection(); mCadDockWidget->clearPoints(); const QVector edgeVert = edgeVertices( mCurrentEdge ); mCurrentEditor->merge( edgeVert.at( 0 ), edgeVert.at( 1 ) ); - mCurrentEdge = {-1, -1}; + mCurrentEdge = { -1, -1 }; highLight( mapPoint ); } else @@ -973,7 +951,6 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) case AddingNewFace: if ( e->button() == Qt::LeftButton ) //eventually add a vertex to the face { - if ( mCurrentVertexIndex != -1 ) { addVertexToFaceCanditate( mCurrentVertexIndex ); @@ -987,9 +964,7 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) else { bool acceptPoint = true; - if ( ! mNewFaceCandidate.isEmpty() && - mNewFaceCandidate.last() == -1 && - !mNewVerticesForNewFaceCandidate.isEmpty() ) //avoid duplicate new vertex + if ( !mNewFaceCandidate.isEmpty() && mNewFaceCandidate.last() == -1 && !mNewVerticesForNewFaceCandidate.isEmpty() ) //avoid duplicate new vertex { acceptPoint = mapPoint.distance( mNewVerticesForNewFaceCandidate.last() ) > tolerance; } @@ -1028,10 +1003,8 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QList newPosition; newPosition.reserve( verticesIndexes.count() ); - const QgsMeshVertex &mapPointInNativeCoordinate = - mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( mapPoint.x(), mapPoint.y() ) ); - const QgsMeshVertex &startingPointInNativeCoordinate = - mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( mStartMovingPoint.x(), mStartMovingPoint.y() ) ); + const QgsMeshVertex &mapPointInNativeCoordinate = mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( mapPoint.x(), mapPoint.y() ) ); + const QgsMeshVertex &startingPointInNativeCoordinate = mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( mStartMovingPoint.x(), mStartMovingPoint.y() ) ); const QgsVector &translationInLayerCoordinate = mapPointInNativeCoordinate - startingPointInNativeCoordinate; const QgsMesh &mesh = *mCurrentLayer->nativeMesh(); @@ -1045,21 +1018,15 @@ void QgsMapToolEditMeshFrame::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) else { //only one vertex, change also the Z value if snap on a 3D vector layer - if ( e->mapPointMatch().isValid() && - QgsWkbTypes::hasZ( e->mapPointMatch().layer()->wkbType() ) ) + if ( e->mapPointMatch().isValid() && QgsWkbTypes::hasZ( e->mapPointMatch().layer()->wkbType() ) ) { - const QgsMeshVertex mapPointInMapCoordinate = - QgsMeshVertex( mapPoint.x(), mapPoint.y(), e->mapPointMatch().interpolatedPoint( mCanvas->mapSettings().destinationCrs() ).z() ); - - const QgsMeshVertex &mapPointInNativeCoordinate = - mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( mapPointInMapCoordinate ) ; - mCurrentEditor->changeCoordinates( verticesIndexes, - QList() - << mapPointInNativeCoordinate ) ; + const QgsMeshVertex mapPointInMapCoordinate = QgsMeshVertex( mapPoint.x(), mapPoint.y(), e->mapPointMatch().interpolatedPoint( mCanvas->mapSettings().destinationCrs() ).z() ); + + const QgsMeshVertex &mapPointInNativeCoordinate = mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( mapPointInMapCoordinate ); + mCurrentEditor->changeCoordinates( verticesIndexes, QList() << mapPointInNativeCoordinate ); } else - mCurrentEditor->changeXYValues( verticesIndexes, QList() - << QgsPointXY( mesh.vertex( verticesIndexes.at( 0 ) ) ) + translationInLayerCoordinate ); + mCurrentEditor->changeXYValues( verticesIndexes, QList() << QgsPointXY( mesh.vertex( verticesIndexes.at( 0 ) ) ) + translationInLayerCoordinate ); } } updateSelectecVerticesMarker(); @@ -1103,7 +1070,7 @@ void QgsMapToolEditMeshFrame::moveSelection( const QgsPointXY &destinationPoint for ( int i = 0; i < vertexData.meshFixedEdges.count(); ++i ) { const QgsPointXY point2 = mapVertexXY( vertexData.meshFixedEdges.at( i ).second ); - const QgsGeometry edge( new QgsLineString( {point1, point2} ) ); + const QgsGeometry edge( new QgsLineString( { point1, point2 } ) ); mMovingEdgesRubberband->addGeometry( edge ); int associateFace = vertexData.meshFixedEdges.at( i ).first; if ( associateFace != -1 ) @@ -1113,7 +1080,7 @@ void QgsMapToolEditMeshFrame::moveSelection( const QgsPointXY &destinationPoint for ( int i = 0; i < vertexData.borderEdges.count(); ++i ) { const QgsPointXY point2 = mapVertexXY( vertexData.borderEdges.at( i ).second ) + translation; - const QgsGeometry edge( new QgsLineString( {point1, point2} ) ); + const QgsGeometry edge( new QgsLineString( { point1, point2 } ) ); mMovingEdgesRubberband->addGeometry( edge ); } @@ -1125,21 +1092,18 @@ void QgsMapToolEditMeshFrame::moveSelection( const QgsPointXY &destinationPoint mMovingFreeVertexRubberband->updatePosition(); mMovingFreeVertexRubberband->update(); - const QgsMeshVertex &mapPointInNativeCoordinate = - mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( destinationPoint.x(), destinationPoint.y() ) ); - const QgsMeshVertex &startingPointInNativeCoordinate = - mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( mStartMovingPoint.x(), mStartMovingPoint.y() ) ); + const QgsMeshVertex &mapPointInNativeCoordinate = mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( destinationPoint.x(), destinationPoint.y() ) ); + const QgsMeshVertex &startingPointInNativeCoordinate = mCurrentLayer->triangularMesh()->triangularToNativeCoordinates( QgsMeshVertex( mStartMovingPoint.x(), mStartMovingPoint.y() ) ); const QgsVector &translationInLayerCoordinate = mapPointInNativeCoordinate - startingPointInNativeCoordinate; - auto transformFunction = [translationInLayerCoordinate, this ]( int vi )-> const QgsMeshVertex - { + auto transformFunction = [translationInLayerCoordinate, this]( int vi ) -> const QgsMeshVertex { if ( mSelectedVertices.contains( vi ) ) return mCurrentLayer->nativeMesh()->vertex( vi ) + translationInLayerCoordinate; else return mCurrentLayer->nativeMesh()->vertex( vi ); }; -// we test only the faces that are deformed on the border, moving and not deformed faces are tested later + // we test only the faces that are deformed on the border, moving and not deformed faces are tested later mIsMovingAllowed = mCurrentEditor->canBeTransformed( qgis::setToList( borderMovingFace ), transformFunction ); if ( mIsMovingAllowed ) @@ -1186,8 +1150,7 @@ void QgsMapToolEditMeshFrame::select( const QgsPointXY &mapPoint, Qt::KeyboardMo QgsPointXY currentPoint = mapPoint; - if ( mSelectFaceMarker->isVisible() && - mapPoint.distance( mSelectFaceMarker->center() ) < tolerance + if ( mSelectFaceMarker->isVisible() && mapPoint.distance( mSelectFaceMarker->center() ) < tolerance && mCurrentFaceIndex >= 0 ) { setSelectedVertices( nativeFace( mCurrentFaceIndex ).toList(), behavior ); @@ -1198,9 +1161,7 @@ void QgsMapToolEditMeshFrame::select( const QgsPointXY &mapPoint, Qt::KeyboardMo setSelectedVertices( QList() << mCurrentVertexIndex, behavior ); currentPoint = mCurrentLayer->triangularMesh()->vertices().at( mCurrentVertexIndex ); } - else if ( mSelectEdgeMarker->isVisible() && - mapPoint.distance( mSelectEdgeMarker->center() ) < tolerance && - mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) + else if ( mSelectEdgeMarker->isVisible() && mapPoint.distance( mSelectEdgeMarker->center() ) < tolerance && mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) { const QVector edgeVert = edgeVertices( mCurrentEdge ); setSelectedVertices( edgeVert.toList(), behavior ); @@ -1209,8 +1170,8 @@ void QgsMapToolEditMeshFrame::select( const QgsPointXY &mapPoint, Qt::KeyboardMo currentPoint = QgsPointXY( ( v1.x() + v2.x() ) / 2, ( v1.y() + v2.y() ) / 2 ); } else - setSelectedVertices( QList(), behavior ); - mCadDockWidget->setPoints( QList < QgsPointXY>() << currentPoint << currentPoint ); + setSelectedVertices( QList(), behavior ); + mCadDockWidget->setPoints( QList() << currentPoint << currentPoint ); } void QgsMapToolEditMeshFrame::keyPressEvent( QKeyEvent *e ) @@ -1364,7 +1325,7 @@ void QgsMapToolEditMeshFrame::onEditingStopped() const QgsMeshVertex QgsMapToolEditMeshFrame::mapVertex( int index ) const { - if ( mCurrentLayer.isNull() || ! mCurrentLayer->triangularMesh() ) + if ( mCurrentLayer.isNull() || !mCurrentLayer->triangularMesh() ) return QgsMeshVertex(); return mCurrentLayer->triangularMesh()->vertices().at( index ); @@ -1378,7 +1339,7 @@ const QgsPointXY QgsMapToolEditMeshFrame::mapVertexXY( int index ) const const QgsMeshFace QgsMapToolEditMeshFrame::nativeFace( int index ) const { - if ( mCurrentLayer.isNull() || ! mCurrentLayer->nativeMesh() ) + if ( mCurrentLayer.isNull() || !mCurrentLayer->nativeMesh() ) return QgsMeshFace(); return mCurrentLayer->nativeMesh()->face( index ); @@ -1390,7 +1351,7 @@ double QgsMapToolEditMeshFrame::currentZValue() return mFirstClickZValue; else if ( mZValueWidget ) return mZValueWidget->zValue(); - else if ( mCadDockWidget->cadEnabled() ) + else if ( mCadDockWidget->cadEnabled() ) return mCadDockWidget->currentPointV2().z(); return defaultZValue(); @@ -1404,7 +1365,7 @@ void QgsMapToolEditMeshFrame::searchFace( const QgsPointXY &mapPoint ) void QgsMapToolEditMeshFrame::searchEdge( const QgsPointXY &mapPoint ) { - mCurrentEdge = {-1, -1}; + mCurrentEdge = { -1, -1 }; double tolerance = QgsTolerance::vertexSearchRadius( canvas()->mapSettings() ); QList candidateFaceIndexes; @@ -1436,7 +1397,7 @@ void QgsMapToolEditMeshFrame::searchEdge( const QgsPointXY &mapPoint ) double distance = sqrt( mapPoint.sqrDistToSegment( pt1.x(), pt1.y(), pt2.x(), pt2.y(), pointOneEdge, 0 ) ); if ( distance < tolerance && distance < minimumDistance && edgeCanBeInteractive( iv1, iv2 ) ) { - mCurrentEdge = {faceIndex, iv2}; + mCurrentEdge = { faceIndex, iv2 }; minimumDistance = distance; } } @@ -1446,7 +1407,7 @@ void QgsMapToolEditMeshFrame::searchEdge( const QgsPointXY &mapPoint ) void QgsMapToolEditMeshFrame::highLight( const QgsPointXY &mapPoint ) { highlightCurrentHoveredFace( mapPoint ); -// searchEdge( mapPoint ); + // searchEdge( mapPoint ); highlightCloseVertex( mapPoint ); highlightCloseEdge( mapPoint ); } @@ -1538,7 +1499,7 @@ QVector QgsMapToolEditMeshFrame::edgeGeometry( const QgsMapToolEditM { const QVector &vertexIndexes = edgeVertices( edge ); - return {mapVertexXY( vertexIndexes.at( 0 ) ), mapVertexXY( vertexIndexes.at( 1 ) )}; + return { mapVertexXY( vertexIndexes.at( 0 ) ), mapVertexXY( vertexIndexes.at( 1 ) ) }; } QVector QgsMapToolEditMeshFrame::edgeVertices( const QgsMapToolEditMeshFrame::Edge &edge ) const @@ -1547,7 +1508,7 @@ QVector QgsMapToolEditMeshFrame::edgeVertices( const QgsMapToolEditMeshFram int faceSize = face.count(); int posInface = ( face.indexOf( edge.second ) + faceSize - 1 ) % faceSize; - return {face.at( posInface ), edge.second}; + return { face.at( posInface ), edge.second }; } QgsPointXY QgsMapToolEditMeshFrame::newFaceMarkerPosition( int vertexIndex ) @@ -1579,7 +1540,7 @@ QgsPointXY QgsMapToolEditMeshFrame::newFaceMarkerPosition( int vertexIndex ) double crossProduct = vector1.crossProduct( vector2 ); - if ( crossProduct < - 1e-8 ) + if ( crossProduct < -1e-8 ) directionVector = ( vector1 + vector2 ).normalized(); else if ( crossProduct > 1e-8 ) directionVector = -( vector1 + vector2 ).normalized(); @@ -1617,10 +1578,7 @@ bool QgsMapToolEditMeshFrame::testNewVertexInFaceCanditate( bool testLast, int v if ( testLast ) { - if ( vertexIndex != -1 && - !mNewFaceCandidate.empty() && - vertexIndex != mNewFaceCandidate.last() && - vertexIndex != mNewFaceCandidate.first() ) + if ( vertexIndex != -1 && !mNewFaceCandidate.empty() && vertexIndex != mNewFaceCandidate.last() && vertexIndex != mNewFaceCandidate.first() ) faceToTest.append( vertexIndex ); else if ( vertexIndex == -1 ) { @@ -1692,9 +1650,9 @@ void QgsMapToolEditMeshFrame::setSelectedVertices( const QList &newSelected for ( const int vertexIndex : newSelectedVertices ) { bool contained = mSelectedVertices.contains( vertexIndex ); - if ( contained && removeVertices ) + if ( contained && removeVertices ) removeFromSelection( vertexIndex ); - else if ( ! removeVertices && !contained ) + else if ( !removeVertices && !contained ) addNewSelectedVertex( vertexIndex ); } @@ -1750,14 +1708,14 @@ void QgsMapToolEditMeshFrame::removeSelectedVerticesFromMesh( bool fillHole ) { if ( fillHole ) { - const QList remainingVertex = mCurrentEditor->removeVerticesFillHoles( mSelectedVertices.keys() ); if ( !remainingVertex.isEmpty() ) { QgisApp::instance()->messageBar()->pushWarning( tr( "Mesh editing" ), - tr( "%n vertices were not removed", nullptr, remainingVertex.count() ) ); + tr( "%n vertices were not removed", nullptr, remainingVertex.count() ) + ); } } else @@ -1767,7 +1725,8 @@ void QgsMapToolEditMeshFrame::removeSelectedVerticesFromMesh( bool fillHole ) { QgisApp::instance()->messageBar()->pushWarning( tr( "Mesh editing" ), - tr( "removing the vertex %1 leads to a topological error, operation canceled." ).arg( error.elementIndex ) ); + tr( "removing the vertex %1 leads to a topological error, operation canceled." ).arg( error.elementIndex ) + ); } } } @@ -1775,10 +1734,10 @@ void QgsMapToolEditMeshFrame::removeSelectedVerticesFromMesh( bool fillHole ) void QgsMapToolEditMeshFrame::removeFacesFromMesh() { QgsMeshEditingError error; - if ( ! mSelectedFaces.isEmpty() ) + if ( !mSelectedFaces.isEmpty() ) error = mCurrentEditor->removeFaces( mSelectedFaces.values() ); else if ( mCurrentFaceIndex != -1 ) - error = mCurrentEditor->removeFaces( {mCurrentFaceIndex} ); + error = mCurrentEditor->removeFaces( { mCurrentFaceIndex } ); else return; @@ -1786,7 +1745,8 @@ void QgsMapToolEditMeshFrame::removeFacesFromMesh() { QgisApp::instance()->messageBar()->pushWarning( tr( "Mesh editing" ), - tr( "removing the faces %1 leads to a topological error, operation canceled." ).arg( error.elementIndex ) ); + tr( "removing the faces %1 leads to a topological error, operation canceled." ).arg( error.elementIndex ) + ); } else { @@ -1800,7 +1760,7 @@ void QgsMapToolEditMeshFrame::splitSelectedFaces() if ( mSplittableFaceCount > 0 ) mCurrentEditor->splitFaces( mSelectedFaces.values() ); else if ( mCurrentFaceIndex != -1 && mCurrentEditor->faceCanBeSplit( mCurrentFaceIndex ) ) - mCurrentEditor->splitFaces( {mCurrentFaceIndex} ); + mCurrentEditor->splitFaces( { mCurrentFaceIndex } ); } void QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget( bool checked ) @@ -1828,8 +1788,7 @@ void QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget( bool checke connect( this, &QgsMapToolEditMeshFrame::selectionChange, mTransformDockWidget, &QgsMeshTransformCoordinatesDockWidget::setInput ); - connect( mTransformDockWidget, &QgsMeshTransformCoordinatesDockWidget::calculationUpdated, this, [this] - { + connect( mTransformDockWidget, &QgsMeshTransformCoordinatesDockWidget::calculationUpdated, this, [this] { mMovingFacesRubberband->reset( Qgis::GeometryType::Polygon ); mMovingEdgesRubberband->reset( Qgis::GeometryType::Line ); mMovingFreeVertexRubberband->reset( Qgis::GeometryType::Point ); @@ -1848,7 +1807,7 @@ void QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget( bool checke for ( int j = 0; j < faceSize; ++j ) faceVertices[j] = mTransformDockWidget->transformedVertex( face.at( j ) ); - faceGeometry = QgsGeometry::fromPolygonXY( {faceVertices} ); + faceGeometry = QgsGeometry::fromPolygonXY( { faceVertices } ); } else { @@ -1863,7 +1822,7 @@ void QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget( bool checke for ( int j = 0; j < faceSize; ++j ) faceVertices[j] = mTransformDockWidget->transformedVertex( face.at( j ) ); - faces[i] = QgsGeometry::fromPolygonXY( {faceVertices} ); + faces[i] = QgsGeometry::fromPolygonXY( { faceVertices } ); } QString error; faceGeometry = QgsGeometry( geomEngine->combine( faces, &error ) ); @@ -1872,19 +1831,19 @@ void QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget( bool checke QgsGeometry edgesGeom = QgsGeometry::fromMultiPolylineXY( QgsMultiPolylineXY() ); for ( QMap::const_iterator it = mSelectedVertices.constBegin(); it != mSelectedVertices.constEnd(); ++it ) { - const QgsPointXY &point1 = mTransformDockWidget->transformedVertex( it.key() ) ; + const QgsPointXY &point1 = mTransformDockWidget->transformedVertex( it.key() ); const SelectedVertexData &vertexData = it.value(); for ( int i = 0; i < vertexData.meshFixedEdges.count(); ++i ) { const QgsPointXY point2 = mTransformDockWidget->transformedVertex( vertexData.meshFixedEdges.at( i ).second ); - QgsGeometry edge( new QgsLineString( {point1, point2} ) ); + QgsGeometry edge( new QgsLineString( { point1, point2 } ) ); edgesGeom.addPart( edge ); } for ( int i = 0; i < vertexData.borderEdges.count(); ++i ) { const QgsPointXY point2 = mTransformDockWidget->transformedVertex( vertexData.borderEdges.at( i ).second ); - const QgsGeometry edge( new QgsLineString( {point1, point2} ) ); + const QgsGeometry edge( new QgsLineString( { point1, point2 } ) ); edgesGeom.addPart( edge ); } } @@ -1922,20 +1881,17 @@ void QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget( bool checke setMovingRubberBandValidity( mTransformDockWidget->isResultValid() ); } ); - connect( mTransformDockWidget, &QgsMeshTransformCoordinatesDockWidget::aboutToBeApplied, this, [this] - { + connect( mTransformDockWidget, &QgsMeshTransformCoordinatesDockWidget::aboutToBeApplied, this, [this] { mKeepSelectionOnEdit = true; } ); - connect( mTransformDockWidget, &QgsMeshTransformCoordinatesDockWidget::applied, this, [this] - { + connect( mTransformDockWidget, &QgsMeshTransformCoordinatesDockWidget::applied, this, [this] { mTransformDockWidget->setInput( mCurrentLayer, mSelectedVertices.keys() ); updateSelectecVerticesMarker(); prepareSelection(); } ); - connect( mTransformDockWidget, &QgsDockWidget::closed, this, [this] - { + connect( mTransformDockWidget, &QgsDockWidget::closed, this, [this] { mActionTransformCoordinates->setChecked( false ); if ( !mIsInitialized ) return; @@ -1944,7 +1900,6 @@ void QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget( bool checke mMovingFreeVertexRubberband->reset( Qgis::GeometryType::Point ); setMovingRubberBandValidity( false ); } ); - } void QgsMapToolEditMeshFrame::reindexMesh() @@ -1954,9 +1909,7 @@ void QgsMapToolEditMeshFrame::reindexMesh() if ( !mCurrentLayer || !mCurrentLayer->isEditable() ) return; - if ( QMessageBox::question( canvas(), tr( "Reindex Mesh" ), - tr( "Do you want to reindex the faces and vertices of the mesh layer %1?" ).arg( mCurrentLayer->name() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) + if ( QMessageBox::question( canvas(), tr( "Reindex Mesh" ), tr( "Do you want to reindex the faces and vertices of the mesh layer %1?" ).arg( mCurrentLayer->name() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::No ) return; @@ -2148,22 +2101,21 @@ void QgsMapToolEditMeshFrame::prepareSelection() { int oppositeVertex = circulator.oppositeVertexClockwise(); if ( mSelectedVertices.contains( oppositeVertex ) ) - vertexData.borderEdges.append( {circulator.currentFaceIndex(), oppositeVertex} ); + vertexData.borderEdges.append( { circulator.currentFaceIndex(), oppositeVertex } ); else - vertexData.meshFixedEdges.append( {circulator.currentFaceIndex(), oppositeVertex} ); + vertexData.meshFixedEdges.append( { circulator.currentFaceIndex(), oppositeVertex } ); mConcernedFaceBySelection.insert( circulator.currentFaceIndex() ); - } - while ( circulator.turnCounterClockwise() != firstface && circulator.currentFaceIndex() != -1 ); + } while ( circulator.turnCounterClockwise() != firstface && circulator.currentFaceIndex() != -1 ); if ( circulator.currentFaceIndex() == -1 ) { circulator.turnClockwise(); int oppositeVertex = circulator.oppositeVertexCounterClockwise(); if ( mSelectedVertices.contains( oppositeVertex ) ) - vertexData.borderEdges.append( {-1, oppositeVertex} ); + vertexData.borderEdges.append( { -1, oppositeVertex } ); else - vertexData.meshFixedEdges.append( {-1, oppositeVertex} ); + vertexData.meshFixedEdges.append( { -1, oppositeVertex } ); } } @@ -2278,7 +2230,7 @@ void QgsMapToolEditMeshFrame::updateSelectecVerticesMarker() { qDeleteAll( mSelectedVerticesMarker ); mSelectedVerticesMarker.clear(); - for ( auto it = mSelectedVertices.keyBegin(); it != mSelectedVertices.keyEnd(); it ++ ) + for ( auto it = mSelectedVertices.keyBegin(); it != mSelectedVertices.keyEnd(); it++ ) { const int vertexIndex = *it; QgsVertexMarker *marker = new QgsVertexMarker( canvas() ); @@ -2320,23 +2272,20 @@ bool QgsMapToolEditMeshFrame::isSelectionGrapped( QgsPointXY &grappedPoint ) con double tolerance = QgsTolerance::vertexSearchRadius( canvas()->mapSettings() ); - if ( mCurrentEdge.first != -1 && mCurrentEdge.second != -1 && - mSelectEdgeMarker->isVisible() && - grappedPoint.distance( mSelectEdgeMarker->center() ) < tolerance ) + if ( mCurrentEdge.first != -1 && mCurrentEdge.second != -1 && mSelectEdgeMarker->isVisible() && grappedPoint.distance( mSelectEdgeMarker->center() ) < tolerance ) { const QVector vertices = edgeVertices( mCurrentEdge ); if ( mSelectedVertices.contains( vertices.at( 0 ) ) && mSelectedVertices.contains( vertices.at( 1 ) ) ) { const QgsPointXY &point1 = mapVertexXY( vertices.at( 0 ) ); const QgsPointXY &point2 = mapVertexXY( vertices.at( 1 ) ); - grappedPoint = QgsPointXY( point1.x() + point2.x(), point1.y() + point2.y() ) / 2; + grappedPoint = QgsPointXY( point1.x() + point2.x(), point1.y() + point2.y() ) / 2; return true; } } - if ( ( mSelectFaceMarker->isVisible() && - grappedPoint.distance( mSelectFaceMarker->center() ) < tolerance + if ( ( mSelectFaceMarker->isVisible() && grappedPoint.distance( mSelectFaceMarker->center() ) < tolerance && mCurrentFaceIndex >= 0 && mSelectedFaces.contains( mCurrentFaceIndex ) ) ) { @@ -2357,16 +2306,16 @@ void QgsMapToolEditMeshFrame::forceByLineReleaseEvent( QgsMapMouseEvent *e ) if ( mCurrentVertexIndex != -1 ) { - const QgsPointXY currentPoint = mapVertexXY( mCurrentVertexIndex ); + const QgsPointXY currentPoint = mapVertexXY( mCurrentVertexIndex ); mForceByLineRubberBand->addPoint( currentPoint ); mCadDockWidget->setZ( QString::number( mapVertex( mCurrentVertexIndex ).z(), 'f' ), QgsAdvancedDigitizingDockWidget::WidgetSetMode::TextEdited ); - mCadDockWidget->setPoints( QList < QgsPointXY>() << currentPoint << currentPoint ); + mCadDockWidget->setPoints( QList() << currentPoint << currentPoint ); } else { if ( e->mapPointMatch().isValid() ) { - const QgsPoint layerPoint = e->mapPointMatch().interpolatedPoint( mCanvas->mapSettings().destinationCrs() ); + const QgsPoint layerPoint = e->mapPointMatch().interpolatedPoint( mCanvas->mapSettings().destinationCrs() ); zValue = layerPoint.z(); } @@ -2392,9 +2341,7 @@ void QgsMapToolEditMeshFrame::forceByLineReleaseEvent( QgsMapMouseEvent *e ) for ( int i = 0; i < rubbergandLines.count() - 1; ++i ) { - points.append( QgsPoint( rubbergandLines.at( i ).x(), - rubbergandLines.at( i ).y(), - mForcingLineZValue.isEmpty() ? defaultValue : mForcingLineZValue.at( i ) ) ); + points.append( QgsPoint( rubbergandLines.at( i ).x(), rubbergandLines.at( i ).y(), mForcingLineZValue.isEmpty() ? defaultValue : mForcingLineZValue.at( i ) ) ); } std::unique_ptr forcingLine = std::make_unique( points ); forceByLine( QgsGeometry( forcingLine.release() ) ); @@ -2560,7 +2507,7 @@ void QgsMapToolEditMeshFrame::highlightCloseEdge( const QgsPointXY &mapPoint ) mFlipEdgeMarker->setVisible( false ); mMergeFaceMarker->setVisible( false ); mSelectEdgeMarker->setVisible( false ); - if ( mCurrentEdge.first != -1 && mCurrentEdge.second != -1 && mCurrentState == Digitizing ) + if ( mCurrentEdge.first != -1 && mCurrentEdge.second != -1 && mCurrentState == Digitizing ) { const QVector &edgeGeom = edgeGeometry( mCurrentEdge ); mEdgeBand->addPoint( edgeGeom.at( 0 ) ); @@ -2697,7 +2644,7 @@ void QgsMapToolEditMeshFrame::clearCanvasHelpers() void QgsMapToolEditMeshFrame::clearEdgeHelpers() { - mCurrentEdge = {-1, -1}; + mCurrentEdge = { -1, -1 }; mEdgeBand->reset(); mSelectEdgeMarker->setVisible( false ); mFlipEdgeMarker->setVisible( false ); @@ -2706,7 +2653,8 @@ void QgsMapToolEditMeshFrame::clearEdgeHelpers() void QgsMapToolEditMeshFrame::addVertex( const QgsPointXY &mapPoint, - const QgsPointLocator::Match &mapPointMatch ) + const QgsPointLocator::Match &mapPointMatch +) { QgsTemporaryCursorOverride waitCursor( Qt::WaitCursor ); @@ -2715,9 +2663,7 @@ void QgsMapToolEditMeshFrame::addVertex( if ( mCadDockWidget->cadEnabled() && mCurrentFaceIndex == -1 ) zValue = currentZValue(); - else if ( mapPointMatch.isValid() && - mapPointMatch.layer() && - QgsWkbTypes::hasZ( mapPointMatch.layer()->wkbType() ) ) + else if ( mapPointMatch.isValid() && mapPointMatch.layer() && QgsWkbTypes::hasZ( mapPointMatch.layer()->wkbType() ) ) { const QgsPoint layerPoint = mapPointMatch.interpolatedPoint( mCanvas->mapSettings().destinationCrs() ); zValue = layerPoint.z(); @@ -2787,7 +2733,7 @@ int QgsMapToolEditMeshFrame::closeVertex( const QgsPointXY &mapPoint ) const double tolerance = QgsTolerance::vertexSearchRadius( canvas()->mapSettings() ); - if ( mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) + if ( mCurrentEdge.first != -1 && mCurrentEdge.second != -1 ) { const QVector &edge = edgeVertices( mCurrentEdge ); @@ -2870,7 +2816,7 @@ void QgsMapToolEditMeshFrame::showSelectByExpressionDialog() void QgsMapToolEditMeshFrame::updateStatusBarMessage() const { - if ( ! mSelectedVertices.isEmpty() ) + if ( !mSelectedVertices.isEmpty() ) { QString message; if ( mSelectedVertices.count() == 1 ) @@ -2904,7 +2850,8 @@ void QgsMapToolEditMeshFrame::updateStatusBarMessage() const distance = distArea.convertLengthMeasurement( distance, QgsProject::instance()->distanceUnits() ); formattedDistance = distArea.formatDistance( distance, 6, QgsProject::instance()->distanceUnits() ); } - catch ( QgsCsException & ) {} + catch ( QgsCsException & ) + {} } if ( formattedDistance.isEmpty() ) diff --git a/src/app/mesh/qgsmaptooleditmeshframe.h b/src/app/mesh/qgsmaptooleditmeshframe.h index 9fda26445f96..ec439b99db1a 100644 --- a/src/app/mesh/qgsmaptooleditmeshframe.h +++ b/src/app/mesh/qgsmaptooleditmeshframe.h @@ -48,7 +48,6 @@ class APP_EXPORT QgsZValueWidget : public QWidget { Q_OBJECT public: - //! Constructor QgsZValueWidget( const QString &label, QWidget *parent = nullptr ); @@ -74,7 +73,6 @@ class QgsMeshEditForceByLineAction : public QWidgetAction { Q_OBJECT public: - enum IntepolationMode { Mesh, @@ -104,7 +102,6 @@ class QgsMeshEditForceByLineAction : public QWidgetAction void updateSettings(); private: - QComboBox *mComboInterpolateFrom = nullptr; QCheckBox *mCheckBoxNewVertex = nullptr; QgsUnitSelectionWidget *mUnitSelecionWidget = nullptr; @@ -115,7 +112,6 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing { Q_OBJECT public: - //! Constructor QgsMapToolEditMeshFrame( QgsMapCanvas *canvas ); ~QgsMapToolEditMeshFrame(); @@ -169,15 +165,14 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing void updateStatusBarMessage() const; private: - enum State { - Digitizing, //!< Digitizing action can be start (add/remove vertices, selection, add/remove faces, move vertices) - AddingNewFace, //!< Adding a face has been start and the user have to choose or digitize vertices - Selecting, //!< Selection is in process - MovingSelection, //!< Moving vertex or vertices is processing + Digitizing, //!< Digitizing action can be start (add/remove vertices, selection, add/remove faces, move vertices) + AddingNewFace, //!< Adding a face has been start and the user have to choose or digitize vertices + Selecting, //!< Selection is in process + MovingSelection, //!< Moving vertex or vertices is processing SelectingByPolygon, //!< Selection elements by polygon is in progress - ForceByLines, //!< Force by a lines drawn or selected by users + ForceByLines, //!< Force by a lines drawn or selected by users }; typedef QPair Edge; //first face index, second the vertex index corresponding to the end extremity (ccw) @@ -230,9 +225,9 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing void addNewSelectedVertex( int vertexIndex ); void removeFromSelection( int vertexIndex ); bool isFaceSelected( int faceIndex ); - void setSelectedVertices( const QList &newSelectedVertices, Qgis::SelectBehavior behavior ); - void setSelectedFaces( const QList &newSelectedFaces, Qgis::SelectBehavior behavior ); - void selectByGeometry( const QgsGeometry &geometry, Qt::KeyboardModifiers modifiers ); + void setSelectedVertices( const QList &newSelectedVertices, Qgis::SelectBehavior behavior ); + void setSelectedFaces( const QList &newSelectedFaces, Qgis::SelectBehavior behavior ); + void selectByGeometry( const QgsGeometry &geometry, Qt::KeyboardModifiers modifiers ); void selectTouchedByGeometry( const QgsGeometry &geometry, Qgis::SelectBehavior behavior ); void selectContainedByGeometry( const QgsGeometry &geometry, Qgis::SelectBehavior behavior ); void applyZValueOnSelectedVertices(); @@ -251,9 +246,9 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing // members struct SelectedVertexData { - //Here edges are the indexes of the face where the following vertices (ccw) is the other extremity of the edge - QList meshFixedEdges; // that have one extremity not on the selection - QList borderEdges; // that are on the border of the selection + //Here edges are the indexes of the face where the following vertices (ccw) is the other extremity of the edge + QList meshFixedEdges; // that have one extremity not on the selection + QList borderEdges; // that are on the border of the selection }; bool mIsInitialized = false; @@ -261,11 +256,11 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing bool mLeftButtonPressed = false; bool mKeepSelectionOnEdit = false; - QPointer mCurrentLayer = nullptr; //not own + QPointer mCurrentLayer = nullptr; //not own QPointer mCurrentEditor = nullptr; // own by mesh layer std::unique_ptr mSnapIndicator; int mCurrentFaceIndex = -1; - Edge mCurrentEdge = {-1, -1}; + Edge mCurrentEdge = { -1, -1 }; int mCurrentVertexIndex = -1; QList mNewFaceCandidate; QList mNewVerticesForNewFaceCandidate; @@ -300,16 +295,16 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing QSet mConcernedFaceBySelection; QgsVertexMarker *mSelectFaceMarker = nullptr; //own by map canvas QgsVertexMarker *mSelectEdgeMarker = nullptr; //own by map canvas - QgsRubberBand *mSelectionBand = nullptr; //own by map canvas + QgsRubberBand *mSelectionBand = nullptr; //own by map canvas QPoint mStartSelectionPos; QgsRubberBand *mSelectedFacesRubberband = nullptr; //own by map canvas - QMap< int, QgsVertexMarker * > mSelectedVerticesMarker; + QMap mSelectedVerticesMarker; //! members for moving vertices QgsPointXY mStartMovingPoint; bool mCanMovingStart = false; - QgsRubberBand *mMovingEdgesRubberband = nullptr; //own by map canvas - QgsRubberBand *mMovingFacesRubberband = nullptr; //own by map canvas + QgsRubberBand *mMovingEdgesRubberband = nullptr; //own by map canvas + QgsRubberBand *mMovingFacesRubberband = nullptr; //own by map canvas QgsRubberBand *mMovingFreeVertexRubberband = nullptr; //own by map canvas bool mIsMovingAllowed = false; diff --git a/src/app/mesh/qgsmeshcalculatordialog.cpp b/src/app/mesh/qgsmeshcalculatordialog.cpp index da00a6d2e4a6..c348c038c4e0 100644 --- a/src/app/mesh/qgsmeshcalculatordialog.cpp +++ b/src/app/mesh/qgsmeshcalculatordialog.cpp @@ -41,8 +41,7 @@ #include QgsMeshCalculatorDialog::QgsMeshCalculatorDialog( QgsMeshLayer *meshLayer, QWidget *parent, Qt::WindowFlags f ) - : QDialog( parent, f ), - mLayer( meshLayer ) + : QDialog( parent, f ), mLayer( meshLayer ) { setupUi( this ); QgsGui::enableAutoGeometryRestore( this ); @@ -55,7 +54,7 @@ QgsMeshCalculatorDialog::QgsMeshCalculatorDialog( QgsMeshLayer *meshLayer, QWidg mVariableNames = model->variableNames(); getMeshDrivers(); - populateDriversComboBox( ); + populateDriversComboBox(); connect( mOutputFormatComboBox, qOverload( &QComboBox::currentIndexChanged ), this, &QgsMeshCalculatorDialog::updateInfoMessage ); connect( mOutputFormatComboBox, qOverload( &QComboBox::currentIndexChanged ), this, &QgsMeshCalculatorDialog::onOutputFormatChange ); connect( mOutputGroupNameLineEdit, &QLineEdit::textChanged, this, &QgsMeshCalculatorDialog::updateInfoMessage ); @@ -105,8 +104,7 @@ QgsMeshCalculatorDialog::QgsMeshCalculatorDialog( QgsMeshLayer *meshLayer, QWidg useFullLayerExtent(); repopulateTimeCombos(); mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); - connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "working_with_mesh/mesh_properties.html#mesh-calculator" ) ); } ); @@ -153,7 +151,7 @@ QgsRectangle QgsMeshCalculatorDialog::outputExtent() const QgsGeometry QgsMeshCalculatorDialog::maskGeometry() const { - QgsVectorLayer *mask_layer = qobject_cast ( cboLayerMask->currentLayer() ); + QgsVectorLayer *mask_layer = qobject_cast( cboLayerMask->currentLayer() ); if ( mask_layer ) { return maskGeometry( mask_layer ); @@ -180,7 +178,7 @@ QgsGeometry QgsMeshCalculatorDialog::maskGeometry( QgsVectorLayer *layer ) const { geometries.push_back( feat.geometry() ); } - const QgsGeometry ret = QgsGeometry::unaryUnion( geometries ) ; + const QgsGeometry ret = QgsGeometry::unaryUnion( geometries ); return ret; } @@ -298,10 +296,10 @@ void QgsMeshCalculatorDialog::updateInfoMessage() // expression is valid const QgsMeshCalculator::Result result = QgsMeshCalculator::expressionIsValid( - formulaString(), - meshLayer(), - requiredCapability - ); + formulaString(), + meshLayer(), + requiredCapability + ); const bool expressionValid = result == QgsMeshCalculator::Success; // selected driver is appropriate @@ -334,9 +332,7 @@ void QgsMeshCalculatorDialog::updateInfoMessage() // group name const bool groupNameValid = !groupName().isEmpty() && !mVariableNames.contains( groupName() ); - if ( expressionValid && - ( notInFile || ( driverValid && filePathValid ) ) && - groupNameValid ) + if ( expressionValid && ( notInFile || ( driverValid && filePathValid ) ) && groupNameValid ) { mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( true ); mExpressionValidLabel->setText( tr( "Expression valid" ) ); @@ -577,20 +573,17 @@ void QgsMeshCalculatorDialog::getMeshDrivers() const QList allDrivers = providerMetadata->meshDriversMetadata(); for ( const QgsMeshDriverMetadata &meta : allDrivers ) { - if ( meta.capabilities().testFlag( QgsMeshDriverMetadata::MeshDriverCapability::CanWriteFaceDatasets ) || - meta.capabilities().testFlag( QgsMeshDriverMetadata::MeshDriverCapability::CanWriteEdgeDatasets ) || - meta.capabilities().testFlag( QgsMeshDriverMetadata::MeshDriverCapability::CanWriteVertexDatasets ) ) + if ( meta.capabilities().testFlag( QgsMeshDriverMetadata::MeshDriverCapability::CanWriteFaceDatasets ) || meta.capabilities().testFlag( QgsMeshDriverMetadata::MeshDriverCapability::CanWriteEdgeDatasets ) || meta.capabilities().testFlag( QgsMeshDriverMetadata::MeshDriverCapability::CanWriteVertexDatasets ) ) mMeshDrivers[meta.name()] = meta; } } } -void QgsMeshCalculatorDialog::populateDriversComboBox( ) +void QgsMeshCalculatorDialog::populateDriversComboBox() { - whileBlocking( mOutputFormatComboBox )->clear(); - const QList< QgsMeshDriverMetadata > vals = mMeshDrivers.values(); + const QList vals = mMeshDrivers.values(); for ( const QgsMeshDriverMetadata &meta : vals ) { whileBlocking( mOutputFormatComboBox )->addItem( meta.description(), meta.name() ); diff --git a/src/app/mesh/qgsmeshcalculatordialog.h b/src/app/mesh/qgsmeshcalculatordialog.h index c26e9a66a781..1c6fc165e45f 100644 --- a/src/app/mesh/qgsmeshcalculatordialog.h +++ b/src/app/mesh/qgsmeshcalculatordialog.h @@ -23,11 +23,10 @@ #include "qgis_app.h" //! A dialog to enter a mesh calculation expression -class APP_EXPORT QgsMeshCalculatorDialog: public QDialog, private Ui::QgsMeshCalculatorDialogBase +class APP_EXPORT QgsMeshCalculatorDialog : public QDialog, private Ui::QgsMeshCalculatorDialogBase { Q_OBJECT public: - /** * Constructor for mesh calculator dialog * \param meshLayer main mesh layer, will be used for default extent and projection @@ -123,7 +122,7 @@ class APP_EXPORT QgsMeshCalculatorDialog: public QDialog, private Ui::QgsMeshCal void getMeshDrivers(); //! Populates the combo box with output formats - void populateDriversComboBox( ); + void populateDriversComboBox(); QgsMeshLayer *mLayer; QHash mMeshDrivers; diff --git a/src/app/mesh/qgsmeshelevationpropertieswidget.cpp b/src/app/mesh/qgsmeshelevationpropertieswidget.cpp index 6f5fde1dc710..9413d96612d4 100644 --- a/src/app/mesh/qgsmeshelevationpropertieswidget.cpp +++ b/src/app/mesh/qgsmeshelevationpropertieswidget.cpp @@ -48,9 +48,9 @@ QgsMeshElevationPropertiesWidget::QgsMeshElevationPropertiesWidget( QgsMeshLayer mScaleZSpinBox->setClearValue( 1 ); mLineStyleButton->setSymbolType( Qgis::SymbolType::Line ); mFillStyleButton->setSymbolType( Qgis::SymbolType::Fill ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationLine.svg" ) ), tr( "Line" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::Line ) ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillBelow.svg" ) ), tr( "Fill Below" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::FillBelow ) ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillAbove.svg" ) ), tr( "Fill Above" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::FillAbove ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationLine.svg" ) ), tr( "Line" ), static_cast( Qgis::ProfileSurfaceSymbology::Line ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillBelow.svg" ) ), tr( "Fill Below" ), static_cast( Qgis::ProfileSurfaceSymbology::FillBelow ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillAbove.svg" ) ), tr( "Fill Above" ), static_cast( Qgis::ProfileSurfaceSymbology::FillAbove ) ); mElevationLimitSpinBox->setClearValue( mElevationLimitSpinBox->minimum(), tr( "Not set" ) ); mFixedLowerSpinBox->setClearValueMode( QgsDoubleSpinBox::ClearValueMode::MinimumValue, tr( "Not set" ) ); @@ -70,28 +70,25 @@ QgsMeshElevationPropertiesWidget::QgsMeshElevationPropertiesWidget( QgsMeshLayer mCalculateFixedRangePerGroupButton->setPopupMode( QToolButton::InstantPopup ); QAction *calculateLowerAction = new QAction( "Calculate Lower by Expression…", calculateFixedRangePerGroupMenu ); calculateFixedRangePerGroupMenu->addAction( calculateLowerAction ); - connect( calculateLowerAction, &QAction::triggered, this, [this] - { + connect( calculateLowerAction, &QAction::triggered, this, [this] { calculateRangeByExpression( false ); } ); QAction *calculateUpperAction = new QAction( "Calculate Upper by Expression…", calculateFixedRangePerGroupMenu ); calculateFixedRangePerGroupMenu->addAction( calculateUpperAction ); - connect( calculateUpperAction, &QAction::triggered, this, [this] - { + connect( calculateUpperAction, &QAction::triggered, this, [this] { calculateRangeByExpression( true ); } ); syncToLayer( layer ); connect( mModeComboBox, qOverload( &QComboBox::currentIndexChanged ), this, &QgsMeshElevationPropertiesWidget::modeChanged ); - connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged ); - connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged ); - connect( mElevationLimitSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged ); + connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged ); + connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged ); + connect( mElevationLimitSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged ); connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsMeshElevationPropertiesWidget::onChanged ); connect( mFillStyleButton, &QgsSymbolButton::changed, this, &QgsMeshElevationPropertiesWidget::onChanged ); - connect( mStyleComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ] - { - switch ( static_cast< Qgis::ProfileSurfaceSymbology >( mStyleComboBox->currentData().toInt() ) ) + connect( mStyleComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=] { + switch ( static_cast( mStyleComboBox->currentData().toInt() ) ) { case Qgis::ProfileSurfaceSymbology::Line: mSymbologyStackedWidget->setCurrentWidget( mPageLine ); @@ -110,12 +107,12 @@ QgsMeshElevationPropertiesWidget::QgsMeshElevationPropertiesWidget( QgsMeshLayer void QgsMeshElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) { - mLayer = qobject_cast< QgsMeshLayer * >( layer ); + mLayer = qobject_cast( layer ); if ( !mLayer ) return; mBlockUpdates = true; - const QgsMeshLayerElevationProperties *props = qgis::down_cast< const QgsMeshLayerElevationProperties * >( mLayer->elevationProperties() ); + const QgsMeshLayerElevationProperties *props = qgis::down_cast( mLayer->elevationProperties() ); mModeComboBox->setCurrentIndex( mModeComboBox->findData( QVariant::fromValue( props->mode() ) ) ); switch ( props->mode() ) @@ -138,11 +135,11 @@ void QgsMeshElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) else mElevationLimitSpinBox->setValue( props->elevationLimit() ); - if ( props->fixedRange().lower() != std::numeric_limits< double >::lowest() ) + if ( props->fixedRange().lower() != std::numeric_limits::lowest() ) mFixedLowerSpinBox->setValue( props->fixedRange().lower() ); else mFixedLowerSpinBox->clear(); - if ( props->fixedRange().upper() != std::numeric_limits< double >::max() ) + if ( props->fixedRange().upper() != std::numeric_limits::max() ) mFixedUpperSpinBox->setValue( props->fixedRange().upper() ); else mFixedUpperSpinBox->clear(); @@ -156,7 +153,7 @@ void QgsMeshElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) mLineStyleButton->setSymbol( props->profileLineSymbol()->clone() ); mFillStyleButton->setSymbol( props->profileFillSymbol()->clone() ); - mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( static_cast ( props->profileSymbology() ) ) ); + mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( static_cast( props->profileSymbology() ) ) ); switch ( props->profileSymbology() ) { case Qgis::ProfileSurfaceSymbology::Line: @@ -176,29 +173,29 @@ void QgsMeshElevationPropertiesWidget::apply() if ( !mLayer ) return; - QgsMeshLayerElevationProperties *props = qgis::down_cast< QgsMeshLayerElevationProperties * >( mLayer->elevationProperties() ); - props->setMode( mModeComboBox->currentData().value< Qgis::MeshElevationMode >() ); + QgsMeshLayerElevationProperties *props = qgis::down_cast( mLayer->elevationProperties() ); + props->setMode( mModeComboBox->currentData().value() ); props->setZOffset( mOffsetZSpinBox->value() ); props->setZScale( mScaleZSpinBox->value() ); if ( mElevationLimitSpinBox->value() != mElevationLimitSpinBox->clearValue() ) props->setElevationLimit( mElevationLimitSpinBox->value() ); else - props->setElevationLimit( std::numeric_limits< double >::quiet_NaN() ); + props->setElevationLimit( std::numeric_limits::quiet_NaN() ); - double fixedLower = std::numeric_limits< double >::lowest(); - double fixedUpper = std::numeric_limits< double >::max(); + double fixedLower = std::numeric_limits::lowest(); + double fixedUpper = std::numeric_limits::max(); if ( mFixedLowerSpinBox->value() != mFixedLowerSpinBox->clearValue() ) fixedLower = mFixedLowerSpinBox->value(); if ( mFixedUpperSpinBox->value() != mFixedUpperSpinBox->clearValue() ) fixedUpper = mFixedUpperSpinBox->value(); - props->setFixedRange( QgsDoubleRange( fixedLower, fixedUpper, mLimitsComboBox->currentData().value< Qgis::RangeLimits >() ) ); + props->setFixedRange( QgsDoubleRange( fixedLower, fixedUpper, mLimitsComboBox->currentData().value() ) ); props->setFixedRangePerGroup( mFixedRangePerGroupModel->rangeData() ); - props->setProfileLineSymbol( mLineStyleButton->clonedSymbol< QgsLineSymbol >() ); - props->setProfileFillSymbol( mFillStyleButton->clonedSymbol< QgsFillSymbol >() ); - props->setProfileSymbology( static_cast< Qgis::ProfileSurfaceSymbology >( mStyleComboBox->currentData().toInt() ) ); + props->setProfileLineSymbol( mLineStyleButton->clonedSymbol() ); + props->setProfileFillSymbol( mFillStyleButton->clonedSymbol() ); + props->setProfileSymbology( static_cast( mStyleComboBox->currentData().toInt() ) ); mLayer->trigger3DUpdate(); } @@ -206,7 +203,7 @@ void QgsMeshElevationPropertiesWidget::modeChanged() { if ( mModeComboBox->currentData().isValid() ) { - switch ( mModeComboBox->currentData().value< Qgis::MeshElevationMode >() ) + switch ( mModeComboBox->currentData().value() ) { case Qgis::MeshElevationMode::FixedElevationRange: mStackedWidget->setCurrentWidget( mPageFixedRange ); @@ -239,19 +236,18 @@ void QgsMeshElevationPropertiesWidget::calculateRangeByExpression( bool isUpper groupScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "group_name" ), meta.name(), true, false, tr( "Group name" ) ) ); expressionContext.appendScope( groupScope ); - expressionContext.setHighlightedVariables( { QStringLiteral( "group" ), QStringLiteral( "group_name" )} ); + expressionContext.setHighlightedVariables( { QStringLiteral( "group" ), QStringLiteral( "group_name" ) } ); QgsExpressionBuilderDialog dlg = QgsExpressionBuilderDialog( nullptr, isUpper ? mFixedRangeUpperExpression : mFixedRangeLowerExpression, this, QStringLiteral( "generic" ), expressionContext ); - QList > groupChoices; + QList> groupChoices; for ( int group = 0; group < mLayer->datasetGroupCount(); ++group ) { const int groupIndex = mLayer->datasetGroupsIndexes().at( group ); const QgsMeshDatasetGroupMetadata meta = mLayer->datasetGroupMetadata( groupIndex ); groupChoices << qMakePair( meta.name(), group ); } - dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Group" ), groupChoices, [this]( const QVariant & value )-> QgsExpressionContext - { + dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Group" ), groupChoices, [this]( const QVariant &value ) -> QgsExpressionContext { return createExpressionContextForGroup( value.toInt() ); } ); @@ -287,7 +283,7 @@ QgsExpressionContext QgsMeshElevationPropertiesWidget::createExpressionContextFo const QgsMeshDatasetGroupMetadata meta = mLayer->datasetGroupMetadata( groupIndex ); groupScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "group_name" ), meta.name(), true, false, tr( "Group name" ) ) ); context.appendScope( groupScope ); - context.setHighlightedVariables( { QStringLiteral( "group" ), QStringLiteral( "group_name" )} ); + context.setHighlightedVariables( { QStringLiteral( "group" ), QStringLiteral( "group_name" ) } ); return context; } @@ -305,7 +301,7 @@ QgsMeshElevationPropertiesWidgetFactory::QgsMeshElevationPropertiesWidgetFactory QgsMapLayerConfigWidget *QgsMeshElevationPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const { - return new QgsMeshElevationPropertiesWidget( qobject_cast< QgsMeshLayer * >( layer ), canvas, parent ); + return new QgsMeshElevationPropertiesWidget( qobject_cast( layer ), canvas, parent ); } bool QgsMeshElevationPropertiesWidgetFactory::supportLayerPropertiesDialog() const @@ -336,7 +332,6 @@ QString QgsMeshElevationPropertiesWidgetFactory::layerPropertiesPagePositionHint QgsMeshGroupFixedElevationRangeModel::QgsMeshGroupFixedElevationRangeModel( QObject *parent ) : QAbstractItemModel( parent ) { - } int QgsMeshGroupFixedElevationRangeModel::columnCount( const QModelIndex & ) const @@ -412,10 +407,10 @@ QVariant QgsMeshGroupFixedElevationRangeModel::data( const QModelIndex &index, i return mGroupNames.value( group, QString::number( group ) ); case 1: - return range.lower() > std::numeric_limits< double >::lowest() ? range.lower() : QVariant(); + return range.lower() > std::numeric_limits::lowest() ? range.lower() : QVariant(); case 2: - return range.upper() < std::numeric_limits< double >::max() ? range.upper() : QVariant(); + return range.upper() < std::numeric_limits::max() ? range.upper() : QVariant(); default: break; @@ -537,7 +532,6 @@ void QgsMeshGroupFixedElevationRangeModel::setLayerData( QgsMeshLayer *layer, co QgsMeshFixedElevationRangeDelegate::QgsMeshFixedElevationRangeDelegate( QObject *parent ) : QStyledItemDelegate( parent ) { - } QWidget *QgsMeshFixedElevationRangeDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const @@ -552,7 +546,7 @@ QWidget *QgsMeshFixedElevationRangeDelegate::createEditor( QWidget *parent, cons void QgsMeshFixedElevationRangeDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const { - if ( QgsDoubleSpinBox *spin = qobject_cast< QgsDoubleSpinBox * >( editor ) ) + if ( QgsDoubleSpinBox *spin = qobject_cast( editor ) ) { model->setData( index, spin->value() ); } diff --git a/src/app/mesh/qgsmeshelevationpropertieswidget.h b/src/app/mesh/qgsmeshelevationpropertieswidget.h index a5af9b443ad1..4bfb0b7b25de 100644 --- a/src/app/mesh/qgsmeshelevationpropertieswidget.h +++ b/src/app/mesh/qgsmeshelevationpropertieswidget.h @@ -30,7 +30,6 @@ class QgsMeshGroupFixedElevationRangeModel : public QAbstractItemModel Q_OBJECT public: - QgsMeshGroupFixedElevationRangeModel( QObject *parent ); int columnCount( const QModelIndex &parent = QModelIndex() ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; @@ -41,14 +40,13 @@ class QgsMeshGroupFixedElevationRangeModel : public QAbstractItemModel QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; bool setData( const QModelIndex &index, const QVariant &value, int role ) override; - void setLayerData( QgsMeshLayer *layer, const QMap &ranges ); - QMap rangeData() const { return mRanges; } + void setLayerData( QgsMeshLayer *layer, const QMap &ranges ); + QMap rangeData() const { return mRanges; } private: - int mGroupCount = 0; - QMap mGroupNames; - QMap mRanges; + QMap mGroupNames; + QMap mRanges; }; @@ -57,20 +55,17 @@ class QgsMeshFixedElevationRangeDelegate : public QStyledItemDelegate Q_OBJECT public: - QgsMeshFixedElevationRangeDelegate( QObject *parent ); protected: QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex &index ) const override; void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override; - }; class QgsMeshElevationPropertiesWidget : public QgsMapLayerConfigWidget, private Ui::QgsMeshElevationPropertiesWidgetBase { Q_OBJECT public: - QgsMeshElevationPropertiesWidget( QgsMeshLayer *layer, QgsMapCanvas *canvas, QWidget *parent ); void syncToLayer( QgsMapLayer *layer ) final; @@ -91,7 +86,6 @@ class QgsMeshElevationPropertiesWidget : public QgsMapLayerConfigWidget, private QgsMeshGroupFixedElevationRangeModel *mFixedRangePerGroupModel = nullptr; QString mFixedRangeLowerExpression = QStringLiteral( "@group" ); QString mFixedRangeUpperExpression = QStringLiteral( "@group" ); - }; @@ -109,5 +103,4 @@ class QgsMeshElevationPropertiesWidgetFactory : public QObject, public QgsMapLay }; - #endif // QGSMESHELEVATIONPROPERTIESWIDGET_H diff --git a/src/app/mesh/qgsmeshselectbyexpressiondialog.cpp b/src/app/mesh/qgsmeshselectbyexpressiondialog.cpp index 7d4d081a59c3..153250d9fc77 100644 --- a/src/app/mesh/qgsmeshselectbyexpressiondialog.cpp +++ b/src/app/mesh/qgsmeshselectbyexpressiondialog.cpp @@ -23,8 +23,8 @@ #include "qgshelp.h" #include "qgsgui.h" -QgsMeshSelectByExpressionDialog::QgsMeshSelectByExpressionDialog( QWidget *parent ): - QDialog( parent ) +QgsMeshSelectByExpressionDialog::QgsMeshSelectByExpressionDialog( QWidget *parent ) + : QDialog( parent ) { setupUi( this ); @@ -32,7 +32,7 @@ QgsMeshSelectByExpressionDialog::QgsMeshSelectByExpressionDialog( QWidget *paren setWindowTitle( tr( "Select Mesh Elements by Expression" ) ); - mActionSelect = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mIconExpressionSelect.svg" ) ), tr( "Select" ), this ); + mActionSelect = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mIconExpressionSelect.svg" ) ), tr( "Select" ), this ); mActionAddToSelection = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mIconSelectAdd.svg" ) ), tr( "Add to current selection" ), this ); mActionRemoveFromSelection = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mIconSelectRemove.svg" ) ), tr( "Remove from current selection" ), this ); @@ -55,22 +55,19 @@ QgsMeshSelectByExpressionDialog::QgsMeshSelectByExpressionDialog( QWidget *paren onElementTypeChanged(); - connect( mActionSelect, &QAction::triggered, this, [this] - { + connect( mActionSelect, &QAction::triggered, this, [this] { emit select( mExpressionBuilder->expressionText(), Qgis::SelectBehavior::SetSelection, currentElementType() ); } ); - connect( mActionAddToSelection, &QAction::triggered, this, [this] - { + connect( mActionAddToSelection, &QAction::triggered, this, [this] { emit select( mExpressionBuilder->expressionText(), Qgis::SelectBehavior::AddToSelection, currentElementType() ); } ); - connect( mActionRemoveFromSelection, &QAction::triggered, this, [this] - { + connect( mActionRemoveFromSelection, &QAction::triggered, this, [this] { emit select( mExpressionBuilder->expressionText(), Qgis::SelectBehavior::RemoveFromSelection, currentElementType() ); } ); connect( mActionSelect, &QAction::triggered, this, &QgsMeshSelectByExpressionDialog::saveRecent ); - connect( mActionAddToSelection, &QAction::triggered, this, &QgsMeshSelectByExpressionDialog::saveRecent ); - connect( mActionRemoveFromSelection, &QAction::triggered, this, &QgsMeshSelectByExpressionDialog::saveRecent ); + connect( mActionAddToSelection, &QAction::triggered, this, &QgsMeshSelectByExpressionDialog::saveRecent ); + connect( mActionRemoveFromSelection, &QAction::triggered, this, &QgsMeshSelectByExpressionDialog::saveRecent ); connect( mButtonClose, &QPushButton::clicked, this, &QgsMeshSelectByExpressionDialog::close ); connect( mButtonZoomToSelected, &QToolButton::clicked, this, &QgsMeshSelectByExpressionDialog::zoomToSelected ); @@ -99,11 +96,11 @@ void QgsMeshSelectByExpressionDialog::saveRecent() const void QgsMeshSelectByExpressionDialog::onElementTypeChanged() const { - QgsMesh::ElementType elementType = currentElementType() ; + QgsMesh::ElementType elementType = currentElementType(); QgsSettings settings; settings.setValue( QStringLiteral( "/meshSelection/elementType" ), elementType ); - QgsExpressionContext expressionContext( {QgsExpressionContextUtils::meshExpressionScope( elementType )} ); + QgsExpressionContext expressionContext( { QgsExpressionContextUtils::meshExpressionScope( elementType ) } ); mExpressionBuilder->init( expressionContext, QStringLiteral( "mesh_vertex_selection" ), QgsExpressionBuilderWidget::LoadAll ); } diff --git a/src/app/mesh/qgsmeshselectbyexpressiondialog.h b/src/app/mesh/qgsmeshselectbyexpressiondialog.h index b36910d5e63a..80c0285f9182 100644 --- a/src/app/mesh/qgsmeshselectbyexpressiondialog.h +++ b/src/app/mesh/qgsmeshselectbyexpressiondialog.h @@ -34,7 +34,6 @@ class APP_EXPORT QgsMeshSelectByExpressionDialog : public QDialog, private Ui::Q { Q_OBJECT public: - //! Constructor QgsMeshSelectByExpressionDialog( QWidget *parent = nullptr ); diff --git a/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.cpp b/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.cpp index 21e10b424322..4c20ef5c1bb9 100644 --- a/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.cpp +++ b/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.cpp @@ -28,8 +28,8 @@ #include "qgscoordinateutils.h" #include "qgsapplication.h" -QgsMeshTransformCoordinatesDockWidget::QgsMeshTransformCoordinatesDockWidget( QWidget *parent ): - QgsDockWidget( parent ) +QgsMeshTransformCoordinatesDockWidget::QgsMeshTransformCoordinatesDockWidget( QWidget *parent ) + : QgsDockWidget( parent ) { setupUi( this ); @@ -58,12 +58,12 @@ QgsMeshTransformCoordinatesDockWidget::QgsMeshTransformCoordinatesDockWidget( QW QgsExpressionContext QgsMeshTransformCoordinatesDockWidget::createExpressionContext() const { - return QgsExpressionContext( {QgsExpressionContextUtils::meshExpressionScope( QgsMesh::Vertex )} ); + return QgsExpressionContext( { QgsExpressionContextUtils::meshExpressionScope( QgsMesh::Vertex ) } ); } QgsMeshVertex QgsMeshTransformCoordinatesDockWidget::transformedVertex( int i ) { - if ( ! mInputLayer || !mIsCalculated ) + if ( !mInputLayer || !mIsCalculated ) return QgsMeshVertex(); return mTransformVertices.transformedVertex( mInputLayer, i ); @@ -97,7 +97,7 @@ void QgsMeshTransformCoordinatesDockWidget::setInput( QgsMeshLayer *layer, const mLabelInformation->setText( tr( "No vertex selected for mesh \"%1\"" ).arg( mInputLayer->name() ) ); else mLabelInformation->setText( tr( "%n vertices of mesh layer \"%1\" to transform", nullptr, mInputVertices.count() ) - .arg( mInputLayer->name() ) ); + .arg( mInputLayer->name() ) ); } } importVertexCoordinates(); @@ -113,9 +113,7 @@ void QgsMeshTransformCoordinatesDockWidget::calculate() QgsTemporaryCursorOverride busyCursor( Qt::WaitCursor ); mTransformVertices.clear(); mTransformVertices.setInputVertices( mInputVertices ); - mTransformVertices.setExpressions( mCheckBoxX->isChecked() ? mExpressionEditX->expression() : QString(), - mCheckBoxY->isChecked() ? mExpressionEditY->expression() : QString(), - mCheckBoxZ->isChecked() ? mExpressionEditZ->expression() : QString() ); + mTransformVertices.setExpressions( mCheckBoxX->isChecked() ? mExpressionEditX->expression() : QString(), mCheckBoxY->isChecked() ? mExpressionEditY->expression() : QString(), mCheckBoxZ->isChecked() ? mExpressionEditZ->expression() : QString() ); QgsExpressionContext context; context.appendScope( QgsExpressionContextUtils::projectScope( QgsProject::instance() ) ); @@ -155,7 +153,7 @@ void QgsMeshTransformCoordinatesDockWidget::apply() emit aboutToBeApplied(); QgsTemporaryCursorOverride busyCursor( Qt::WaitCursor ); if ( mIsResultValid && mInputLayer && mInputLayer->meshEditor() ) - mInputLayer->meshEditor()->advancedEdit( & mTransformVertices ); + mInputLayer->meshEditor()->advancedEdit( &mTransformVertices ); emit applied(); } @@ -195,4 +193,3 @@ void QgsMeshTransformCoordinatesDockWidget::importVertexCoordinates() } } } - diff --git a/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.h b/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.h index 4915ad625eb7..530ea717bcf1 100644 --- a/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.h +++ b/src/app/mesh/qgsmeshtransformcoordinatesdockwidget.h @@ -30,11 +30,10 @@ class QgsMeshLayer; * * \since QGIS 3.22 */ -class APP_EXPORT QgsMeshTransformCoordinatesDockWidget: public QgsDockWidget, public QgsExpressionContextGenerator, private Ui::QgsMeshTransformCoordinatesDockWidgetBase +class APP_EXPORT QgsMeshTransformCoordinatesDockWidget : public QgsDockWidget, public QgsExpressionContextGenerator, private Ui::QgsMeshTransformCoordinatesDockWidgetBase { Q_OBJECT public: - //! Constructor QgsMeshTransformCoordinatesDockWidget( QWidget *parent ); @@ -80,7 +79,6 @@ class APP_EXPORT QgsMeshTransformCoordinatesDockWidget: public QgsDockWidget, pu QString displayCoordinateText( const QgsCoordinateReferenceSystem &crs, double value ); void importVertexCoordinates(); - }; #endif // QGSMESHTRANSFORMCOORDINATESDOCKWIDGET_H diff --git a/src/app/mesh/qgsnewmeshlayerdialog.cpp b/src/app/mesh/qgsnewmeshlayerdialog.cpp index e8de3ca601a6..5a4c9c4f48d8 100644 --- a/src/app/mesh/qgsnewmeshlayerdialog.cpp +++ b/src/app/mesh/qgsnewmeshlayerdialog.cpp @@ -29,7 +29,8 @@ #include "qgsgui.h" -QgsNewMeshLayerDialog::QgsNewMeshLayerDialog( QWidget *parent, Qt::WindowFlags fl ) : QDialog( parent, fl ) +QgsNewMeshLayerDialog::QgsNewMeshLayerDialog( QWidget *parent, Qt::WindowFlags fl ) + : QDialog( parent, fl ) { QgsProviderMetadata *meta = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) ); @@ -61,16 +62,14 @@ QgsNewMeshLayerDialog::QgsNewMeshLayerDialog( QWidget *parent, Qt::WindowFlags f mFileWidget->setFilter( filters.join( QLatin1String( ";;" ) ) ); mMeshProjectComboBox->setFilters( Qgis::LayerFilter::MeshLayer ); - connect( mFormatComboBox, static_cast( &QComboBox::currentIndexChanged ), - this, &QgsNewMeshLayerDialog::onFormatChanged ); + connect( mFormatComboBox, static_cast( &QComboBox::currentIndexChanged ), this, &QgsNewMeshLayerDialog::onFormatChanged ); connect( mFileWidget, &QgsFileWidget::fileChanged, this, &QgsNewMeshLayerDialog::onFilePathChanged ); connect( mInitializeMeshGroupBox, &QGroupBox::toggled, this, &QgsNewMeshLayerDialog::updateDialog ); connect( mMeshFileRadioButton, &QRadioButton::toggled, this, &QgsNewMeshLayerDialog::updateDialog ); connect( mMeshFromFileWidget, &QgsFileWidget::fileChanged, this, &QgsNewMeshLayerDialog::updateDialog ); connect( mMeshProjectComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsNewMeshLayerDialog::updateDialog ); - connect( buttonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( buttonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "managing_data_source/create_layers.html#creating-a-new-mesh-layer" ) ); } ); @@ -99,10 +98,7 @@ void QgsNewMeshLayerDialog::updateDialog() { updateSourceMeshframe(); - buttonBox->button( QDialogButtonBox::Ok )->setEnabled( - ! mFileWidget->filePath().isEmpty() && - mFormatComboBox->currentIndex() != -1 && - mSourceMeshFrameReady ); + buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !mFileWidget->filePath().isEmpty() && mFormatComboBox->currentIndex() != -1 && mSourceMeshFrameReady ); } void QgsNewMeshLayerDialog::updateSourceMeshframe() @@ -136,7 +132,7 @@ void QgsNewMeshLayerDialog::updateSourceMeshframe() mProjectionSelectionWidget->setEnabled( false ); - mSourceMeshFrameReady = static_cast< bool >( mSourceMeshFromFile ); + mSourceMeshFrameReady = static_cast( mSourceMeshFromFile ); QgsApplication::restoreOverrideCursor(); } @@ -162,7 +158,7 @@ void QgsNewMeshLayerDialog::onFormatChanged() const QString currentSuffix = fileInfo.suffix(); if ( !currentSuffix.isEmpty() ) - currentFilePath = currentFilePath.mid( 0, currentFilePath.lastIndexOf( '.' ) ); + currentFilePath = currentFilePath.mid( 0, currentFilePath.lastIndexOf( '.' ) ); if ( currentFilePath.right( 1 ) == QString( '.' ) ) currentFilePath.remove( currentFilePath.count() - 1, 1 ); @@ -281,4 +277,3 @@ QgsMeshLayer *QgsNewMeshLayerDialog::newLayer() const { return mNewLayer; } - diff --git a/src/app/options/qgsadvancedoptions.cpp b/src/app/options/qgsadvancedoptions.cpp index 1cb661b9c405..7c6858d8a8e8 100644 --- a/src/app/options/qgsadvancedoptions.cpp +++ b/src/app/options/qgsadvancedoptions.cpp @@ -46,8 +46,7 @@ QgsAdvancedSettingsWidget::QgsAdvancedSettingsWidget( QWidget *parent ) { createSettingsTreeWidget( true, true, true ); - connect( mAdvancedSettingsEnableButton, &QPushButton::clicked, this, [ = ] - { + connect( mAdvancedSettingsEnableButton, &QPushButton::clicked, this, [=] { settingsUseNewTreeWidget->setValue( mUseNewSettingsTree->isChecked() ); mAdvancedSettingsWarning->hide(); if ( settingsUseNewTreeWidget->value() ) @@ -73,7 +72,6 @@ void QgsAdvancedSettingsWidget::apply() // new settings tree is performing changes on apply if ( mTreeWidget ) mTreeWidget->applyChanges(); - } void QgsAdvancedSettingsWidget::createSettingsTreeWidget( bool newWidget, bool oldWidget, bool hide ) @@ -101,7 +99,6 @@ void QgsAdvancedSettingsWidget::createSettingsTreeWidget( bool newWidget, bool o QgsAdvancedSettingsOptionsFactory::QgsAdvancedSettingsOptionsFactory() : QgsOptionsWidgetFactory( QCoreApplication::translate( "QgsOptionsBase", "Advanced" ), QIcon(), QStringLiteral( "advanced" ) ) { - } QIcon QgsAdvancedSettingsOptionsFactory::icon() const diff --git a/src/app/options/qgsadvancedoptions.h b/src/app/options/qgsadvancedoptions.h index a10f0b3bae37..3596199201e6 100644 --- a/src/app/options/qgsadvancedoptions.h +++ b/src/app/options/qgsadvancedoptions.h @@ -35,7 +35,6 @@ class QgsAdvancedSettingsWidget : public QgsOptionsPageWidget, private Ui::QgsAd Q_OBJECT public: - static inline QgsSettingsTreeNode *sTreeSettings = QgsSettingsTree::sTreeApp->createChildNode( QStringLiteral( "settings" ) ); static const QgsSettingsEntryBool *settingsUseNewTreeWidget; static const QgsSettingsEntryBool *settingsShowWarning; @@ -54,7 +53,6 @@ class QgsAdvancedSettingsWidget : public QgsOptionsPageWidget, private Ui::QgsAd QgsSettingsTreeWidget *mTreeWidget = nullptr; QgsSettingsTreeWidgetOld *mTreeWidgetOld = nullptr; - }; @@ -63,12 +61,10 @@ class QgsAdvancedSettingsOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsAdvancedSettingsOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; - }; diff --git a/src/app/options/qgscodeeditoroptions.cpp b/src/app/options/qgscodeeditoroptions.cpp index 6e97d4eaa11f..8f0cae9df074 100644 --- a/src/app/options/qgscodeeditoroptions.cpp +++ b/src/app/options/qgscodeeditoroptions.cpp @@ -35,44 +35,43 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent ) mSizeSpin->setClearValue( 10 ); - mColorButtonMap = - { - {QgsCodeEditorColorScheme::ColorRole::Default, mColorDefault }, - {QgsCodeEditorColorScheme::ColorRole::Keyword, mColorKeyword }, - {QgsCodeEditorColorScheme::ColorRole::Class, mColorClass }, - {QgsCodeEditorColorScheme::ColorRole::Method, mColorFunction }, - {QgsCodeEditorColorScheme::ColorRole::Decoration, mColorDecorator }, - {QgsCodeEditorColorScheme::ColorRole::Number, mColorNumber }, - {QgsCodeEditorColorScheme::ColorRole::Comment, mColorComment }, - {QgsCodeEditorColorScheme::ColorRole::CommentLine, mColorCommentLine }, - {QgsCodeEditorColorScheme::ColorRole::CommentBlock, mColorCommentBlock }, - {QgsCodeEditorColorScheme::ColorRole::Background, mColorBackground }, - {QgsCodeEditorColorScheme::ColorRole::Cursor, mColorCursor }, - {QgsCodeEditorColorScheme::ColorRole::CaretLine, mColorCaretLine }, - {QgsCodeEditorColorScheme::ColorRole::Operator, mColorOperator }, - {QgsCodeEditorColorScheme::ColorRole::QuotedOperator, mColorQuotedOperator }, - {QgsCodeEditorColorScheme::ColorRole::Identifier, mColorIdentifier }, - {QgsCodeEditorColorScheme::ColorRole::QuotedIdentifier, mColorQuotedIdentifier }, - {QgsCodeEditorColorScheme::ColorRole::Tag, mColorTag }, - {QgsCodeEditorColorScheme::ColorRole::UnknownTag, mColorUnknownTag }, - {QgsCodeEditorColorScheme::ColorRole::SingleQuote, mColorSingleQuote }, - {QgsCodeEditorColorScheme::ColorRole::DoubleQuote, mColorDoubleQuote }, - {QgsCodeEditorColorScheme::ColorRole::TripleSingleQuote, mColorTripleSingleQuote }, - {QgsCodeEditorColorScheme::ColorRole::TripleDoubleQuote, mColorTripleDoubleQuote }, - {QgsCodeEditorColorScheme::ColorRole::MarginBackground, mColorMarginBackground }, - {QgsCodeEditorColorScheme::ColorRole::MarginForeground, mColorMarginForeground }, - {QgsCodeEditorColorScheme::ColorRole::SelectionBackground, mColorSelectionBackground }, - {QgsCodeEditorColorScheme::ColorRole::SelectionForeground, mColorSelectionForeground }, - {QgsCodeEditorColorScheme::ColorRole::MatchedBraceBackground, mColorBraceBackground }, - {QgsCodeEditorColorScheme::ColorRole::MatchedBraceForeground, mColorBraceForeground }, - {QgsCodeEditorColorScheme::ColorRole::Edge, mColorEdge }, - {QgsCodeEditorColorScheme::ColorRole::Fold, mColorFold }, - {QgsCodeEditorColorScheme::ColorRole::Error, mColorError }, - {QgsCodeEditorColorScheme::ColorRole::ErrorBackground, mColorErrorBackground }, - {QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, mColorFoldIcon }, - {QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, mColorFoldIconHalo }, - {QgsCodeEditorColorScheme::ColorRole::IndentationGuide, mColorIndentation }, - {QgsCodeEditorColorScheme::ColorRole::SearchMatchBackground, mColorSearchResult }, + mColorButtonMap = { + { QgsCodeEditorColorScheme::ColorRole::Default, mColorDefault }, + { QgsCodeEditorColorScheme::ColorRole::Keyword, mColorKeyword }, + { QgsCodeEditorColorScheme::ColorRole::Class, mColorClass }, + { QgsCodeEditorColorScheme::ColorRole::Method, mColorFunction }, + { QgsCodeEditorColorScheme::ColorRole::Decoration, mColorDecorator }, + { QgsCodeEditorColorScheme::ColorRole::Number, mColorNumber }, + { QgsCodeEditorColorScheme::ColorRole::Comment, mColorComment }, + { QgsCodeEditorColorScheme::ColorRole::CommentLine, mColorCommentLine }, + { QgsCodeEditorColorScheme::ColorRole::CommentBlock, mColorCommentBlock }, + { QgsCodeEditorColorScheme::ColorRole::Background, mColorBackground }, + { QgsCodeEditorColorScheme::ColorRole::Cursor, mColorCursor }, + { QgsCodeEditorColorScheme::ColorRole::CaretLine, mColorCaretLine }, + { QgsCodeEditorColorScheme::ColorRole::Operator, mColorOperator }, + { QgsCodeEditorColorScheme::ColorRole::QuotedOperator, mColorQuotedOperator }, + { QgsCodeEditorColorScheme::ColorRole::Identifier, mColorIdentifier }, + { QgsCodeEditorColorScheme::ColorRole::QuotedIdentifier, mColorQuotedIdentifier }, + { QgsCodeEditorColorScheme::ColorRole::Tag, mColorTag }, + { QgsCodeEditorColorScheme::ColorRole::UnknownTag, mColorUnknownTag }, + { QgsCodeEditorColorScheme::ColorRole::SingleQuote, mColorSingleQuote }, + { QgsCodeEditorColorScheme::ColorRole::DoubleQuote, mColorDoubleQuote }, + { QgsCodeEditorColorScheme::ColorRole::TripleSingleQuote, mColorTripleSingleQuote }, + { QgsCodeEditorColorScheme::ColorRole::TripleDoubleQuote, mColorTripleDoubleQuote }, + { QgsCodeEditorColorScheme::ColorRole::MarginBackground, mColorMarginBackground }, + { QgsCodeEditorColorScheme::ColorRole::MarginForeground, mColorMarginForeground }, + { QgsCodeEditorColorScheme::ColorRole::SelectionBackground, mColorSelectionBackground }, + { QgsCodeEditorColorScheme::ColorRole::SelectionForeground, mColorSelectionForeground }, + { QgsCodeEditorColorScheme::ColorRole::MatchedBraceBackground, mColorBraceBackground }, + { QgsCodeEditorColorScheme::ColorRole::MatchedBraceForeground, mColorBraceForeground }, + { QgsCodeEditorColorScheme::ColorRole::Edge, mColorEdge }, + { QgsCodeEditorColorScheme::ColorRole::Fold, mColorFold }, + { QgsCodeEditorColorScheme::ColorRole::Error, mColorError }, + { QgsCodeEditorColorScheme::ColorRole::ErrorBackground, mColorErrorBackground }, + { QgsCodeEditorColorScheme::ColorRole::FoldIconForeground, mColorFoldIcon }, + { QgsCodeEditorColorScheme::ColorRole::FoldIconHalo, mColorFoldIconHalo }, + { QgsCodeEditorColorScheme::ColorRole::IndentationGuide, mColorIndentation }, + { QgsCodeEditorColorScheme::ColorRole::SearchMatchBackground, mColorSearchResult }, }; for ( auto it = mColorButtonMap.constBegin(); it != mColorButtonMap.constEnd(); ++it ) @@ -83,7 +82,7 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent ) mColorSchemeComboBox->addItem( tr( "Default" ), QString() ); - QMap< QString, QString> themeNameToId; + QMap themeNameToId; QStringList names; const QStringList ids = QgsGui::codeEditorColorSchemeRegistry()->schemes(); for ( const QString &id : ids ) @@ -115,8 +114,7 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent ) mColorSchemeComboBox->setCurrentIndex( mColorSchemeComboBox->findData( QStringLiteral( "custom" ) ) ); } - connect( mColorSchemeComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [ = ] - { + connect( mColorSchemeComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=] { const QString theme = mColorSchemeComboBox->currentData().toString(); if ( theme != QLatin1String( "custom" ) ) { @@ -134,8 +132,7 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent ) for ( auto it = mColorButtonMap.constBegin(); it != mColorButtonMap.constEnd(); ++it ) { - connect( it.value(), &QgsColorButton::colorChanged, this, [ = ] - { + connect( it.value(), &QgsColorButton::colorChanged, this, [=] { if ( mBlockCustomColorChange ) return; @@ -150,16 +147,13 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent ) mSizeSpin->setValue( font.pointSize() ); mOverrideFontGroupBox->setChecked( !settings.value( QStringLiteral( "codeEditor/fontfamily" ), QString(), QgsSettings::Gui ).toString().isEmpty() ); - connect( mFontComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [ = ] - { + connect( mFontComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=] { updatePreview(); } ); - connect( mSizeSpin, qOverload( &QSpinBox::valueChanged ), this, [ = ] - { + connect( mSizeSpin, qOverload( &QSpinBox::valueChanged ), this, [=] { updatePreview(); } ); - connect( mOverrideFontGroupBox, &QGroupBox::toggled, this, [ = ] - { + connect( mOverrideFontGroupBox, &QGroupBox::toggled, this, [=] { updatePreview(); } ); @@ -185,13 +179,11 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent ) mListLanguage->addItem( tr( "Bash" ) ); mListLanguage->addItem( tr( "Batch" ) ); - connect( mListLanguage, &QListWidget::currentRowChanged, this, [ = ] - { + connect( mListLanguage, &QListWidget::currentRowChanged, this, [=] { mPreviewStackedWidget->setCurrentIndex( mListLanguage->currentRow() ); } ); - auto addSearchHighlight = []( QgsCodeEditor * editor, int start, int length ) - { + auto addSearchHighlight = []( QgsCodeEditor *editor, int start, int length ) { editor->SendScintilla( QsciScintilla::SCI_SETINDICATORCURRENT, QgsCodeEditor::SEARCH_RESULT_INDICATOR ); editor->SendScintilla( QsciScintilla::SCI_INDICATORFILLRANGE, start, length ); }; @@ -224,8 +216,8 @@ class SomeClass: expression:=centroid(@geometry), /* a comment */ filter:="region_name" = attribute(@parent,'name') + 55 /* a search result */ ) -)"""); - addSearchHighlight( mExpressionPreview, 190, 13 ); +)""" ); + addSearchHighlight( mExpressionPreview, 190, 13 ); mSQLPreview->setText( R"""(CREATE TABLE "my_table" ( "pk" serial NOT NULL PRIMARY KEY, @@ -236,10 +228,10 @@ class SomeClass: -- Retrieve values SELECT count(*) FROM "my_table" WHERE "a_field" > 'a value'; -- A search result -)"""); - addSearchHighlight( mSQLPreview, 209, 13 ); +)""" ); + addSearchHighlight( mSQLPreview, 209, 13 ); - mHtmlPreview->setText(R"""( + mHtmlPreview->setText( R"""( QGIS @@ -251,8 +243,8 @@ SELECT count(*) FROM "my_table" WHERE "a_field" > 'a value'; -)"""); - addSearchHighlight( mHtmlPreview, 196, 13 ); +)""" ); + addSearchHighlight( mHtmlPreview, 196, 13 ); mCssPreview->setText( R"""(@import url(print.css); @@ -278,7 +270,7 @@ ul > li, a:hover { } } )""" ); - addSearchHighlight( mCssPreview, 178, 13 ); + addSearchHighlight( mCssPreview, 178, 13 ); mJsPreview->setText( R"""(// my sample JavaScript function @@ -317,10 +309,10 @@ a_variable <- "My string" { return(x^y) } -)"""); +)""" ); addSearchHighlight( mRPreview, 181, 13 ); - mBashPreview->setText(R"""(#!/bin/bash + mBashPreview->setText( R"""(#!/bin/bash # This script takes two arguments: a directory and a file extension. # It finds all the files in the directory that have the given extension @@ -420,12 +412,12 @@ void QgsCodeEditorOptionsWidget::updatePreview() QString theme = mColorSchemeComboBox->currentData().toString(); - QMap< QgsCodeEditorColorScheme::ColorRole, QColor> colors; + QMap colors; if ( theme == QLatin1String( "custom" ) ) { for ( auto it = mColorButtonMap.constBegin(); it != mColorButtonMap.constEnd(); ++it ) { - colors[ it.key() ] = it.value()->color(); + colors[it.key()] = it.value()->color(); } theme.clear(); } @@ -455,7 +447,6 @@ void QgsCodeEditorOptionsWidget::updatePreview() QgsCodeEditorOptionsFactory::QgsCodeEditorOptionsFactory() : QgsOptionsWidgetFactory( tr( "Code Editor" ), QIcon(), QStringLiteral( "code_editor" ) ) { - } QIcon QgsCodeEditorOptionsFactory::icon() const @@ -470,7 +461,7 @@ QgsOptionsPageWidget *QgsCodeEditorOptionsFactory::createWidget( QWidget *parent QStringList QgsCodeEditorOptionsFactory::path() const { - return {QStringLiteral( "ide" ) }; + return { QStringLiteral( "ide" ) }; } QString QgsCodeEditorOptionsFactory::pagePositionHint() const diff --git a/src/app/options/qgscodeeditoroptions.h b/src/app/options/qgscodeeditoroptions.h index c1a773ef7789..a48e2a20ddef 100644 --- a/src/app/options/qgscodeeditoroptions.h +++ b/src/app/options/qgscodeeditoroptions.h @@ -33,7 +33,6 @@ class QgsCodeEditorOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsC Q_OBJECT public: - /** * Constructor for QgsCodeEditorOptionsWidget with the specified \a parent widget. */ @@ -45,16 +44,13 @@ class QgsCodeEditorOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsC void apply() override; private: - - QMap< QgsCodeEditorColorScheme::ColorRole, QgsColorButton * > mColorButtonMap; + QMap mColorButtonMap; bool mBlockCustomColorChange = false; void updatePreview(); QgsCodeEditorShell *mBashPreview = nullptr; QgsCodeEditorShell *mBatchPreview = nullptr; - - }; @@ -63,14 +59,12 @@ class QgsCodeEditorOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsCodeEditorOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QStringList path() const override; QString pagePositionHint() const override; - }; diff --git a/src/app/options/qgscustomprojectionoptions.cpp b/src/app/options/qgscustomprojectionoptions.cpp index 46081d41bdff..bb1040491e59 100644 --- a/src/app/options/qgscustomprojectionoptions.cpp +++ b/src/app/options/qgscustomprojectionoptions.cpp @@ -79,8 +79,7 @@ QgsCustomProjectionOptionsWidget::QgsCustomProjectionOptionsWidget( QWidget *par leNameList->hideColumn( QgisCrsIdColumn ); connect( leName, &QLineEdit::textChanged, this, &QgsCustomProjectionOptionsWidget::updateListFromCurrentItem ); - connect( mCrsDefinitionWidget, &QgsCrsDefinitionWidget::crsChanged, this, [ = ] - { + connect( mCrsDefinitionWidget, &QgsCrsDefinitionWidget::crsChanged, this, [=] { if ( !mBlockUpdates ) updateListFromCurrentItem(); } ); @@ -88,7 +87,7 @@ QgsCustomProjectionOptionsWidget::QgsCustomProjectionOptionsWidget( QWidget *par void QgsCustomProjectionOptionsWidget::populateList() { - const QList< QgsCoordinateReferenceSystemRegistry::UserCrsDetails > userCrsList = QgsApplication::coordinateReferenceSystemRegistry()->userCrsList(); + const QList userCrsList = QgsApplication::coordinateReferenceSystemRegistry()->userCrsList(); for ( const QgsCoordinateReferenceSystemRegistry::UserCrsDetails &details : userCrsList ) { @@ -181,18 +180,16 @@ void QgsCustomProjectionOptionsWidget::pbnRemove_clicked() return; // make sure the user really wants to delete these definitions - if ( QMessageBox::No == QMessageBox::question( this, tr( "Delete Projections" ), - tr( "Are you sure you want to delete %n projection(s)?", "number of rows", selection.size() ), - QMessageBox::Yes | QMessageBox::No ) ) + if ( QMessageBox::No == QMessageBox::question( this, tr( "Delete Projections" ), tr( "Are you sure you want to delete %n projection(s)?", "number of rows", selection.size() ), QMessageBox::Yes | QMessageBox::No ) ) return; - std::vector< int > selectedRows; + std::vector selectedRows; selectedRows.reserve( selection.size() ); for ( const QModelIndex &index : selection ) selectedRows.emplace_back( index.row() ); //sort rows in reverse order - std::sort( selectedRows.begin(), selectedRows.end(), std::greater< int >() ); + std::sort( selectedRows.begin(), selectedRows.end(), std::greater() ); for ( const int row : selectedRows ) { if ( row < 0 ) @@ -239,7 +236,7 @@ void QgsCustomProjectionOptionsWidget::leNameList_currentItemChanged( QTreeWidge previous->setText( QgisCrsNameColumn, leName->text() ); previous->setText( QgisCrsParametersColumn, multiLineWktToSingleLine( mCrsDefinitionWidget->definitionString() ) ); - previous->setData( 0, FormattedWktRole, mCrsDefinitionWidget->definitionString() ); + previous->setData( 0, FormattedWktRole, mCrsDefinitionWidget->definitionString() ); } if ( current ) @@ -291,8 +288,7 @@ bool QgsCustomProjectionOptionsWidget::isValid() } } - QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), - tr( "The definition of '%1' is not valid." ).arg( def.name ) ); + QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), tr( "The definition of '%1' is not valid." ).arg( def.name ) ); return false; } else if ( !crs.authid().isEmpty() && !crs.authid().startsWith( QLatin1String( "USER" ), Qt::CaseInsensitive ) ) @@ -309,8 +305,7 @@ bool QgsCustomProjectionOptionsWidget::isValid() if ( def.wkt.isEmpty() ) { - QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), - tr( "Cannot save '%1' — this Proj string definition is equivalent to %2.\n\nTry changing the CRS definition to a WKT format instead." ).arg( def.name, crs.authid() ) ); + QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), tr( "Cannot save '%1' — this Proj string definition is equivalent to %2.\n\nTry changing the CRS definition to a WKT format instead." ).arg( def.name, crs.authid() ) ); } else { @@ -322,13 +317,11 @@ bool QgsCustomProjectionOptionsWidget::isValid() } if ( !ref.isEmpty() && crs.toWkt( Qgis::CrsWktVariant::Preferred ).contains( ref ) ) { - QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), - tr( "Cannot save '%1' — the definition is equivalent to %2.\n\n(Try removing \"%3\" from the WKT definition.)" ).arg( def.name, crs.authid(), ref ) ); + QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), tr( "Cannot save '%1' — the definition is equivalent to %2.\n\n(Try removing \"%3\" from the WKT definition.)" ).arg( def.name, crs.authid(), ref ) ); } else { - QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), - tr( "Cannot save '%1' — the definition is equivalent to %2." ).arg( def.name, crs.authid() ) ); + QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ), tr( "Cannot save '%1' — the definition is equivalent to %2." ).arg( def.name, crs.authid() ) ); } } return false; @@ -360,13 +353,12 @@ void QgsCustomProjectionOptionsWidget::apply() { if ( mExistingCRSnames[def.id] != def.name || ( !def.wkt.isEmpty() && mExistingCRSwkt[def.id] != def.wkt ) - || ( !def.proj.isEmpty() && mExistingCRSproj[def.id] != def.proj ) - ) + || ( !def.proj.isEmpty() && mExistingCRSproj[def.id] != def.proj ) ) { saveSuccess &= saveCrs( crs, def.name, def.id, false, !def.wkt.isEmpty() ? Qgis::CrsDefinitionFormat::Wkt : Qgis::CrsDefinitionFormat::Proj ); } } - if ( ! saveSuccess ) + if ( !saveSuccess ) { QgsDebugError( QStringLiteral( "Error when saving CRS '%1'" ).arg( def.name ) ); } @@ -375,7 +367,7 @@ void QgsCustomProjectionOptionsWidget::apply() for ( int i = 0; i < mDeletedCRSs.size(); ++i ) { saveSuccess &= QgsApplication::coordinateReferenceSystemRegistry()->removeUserCrs( mDeletedCRSs[i].toLong() ); - if ( ! saveSuccess ) + if ( !saveSuccess ) { QgsDebugError( QStringLiteral( "Error deleting CRS for '%1'" ).arg( mDefinitions.at( i ).name ) ); } @@ -431,7 +423,6 @@ QString QgsCustomProjectionOptionsWidget::helpKey() const QgsCustomProjectionOptionsFactory::QgsCustomProjectionOptionsFactory() : QgsOptionsWidgetFactory( tr( "User Defined CRS" ), QIcon(), QStringLiteral( "user_defined_crs" ) ) { - } QIcon QgsCustomProjectionOptionsFactory::icon() const @@ -446,6 +437,5 @@ QgsOptionsPageWidget *QgsCustomProjectionOptionsFactory::createWidget( QWidget * QStringList QgsCustomProjectionOptionsFactory::path() const { - return {QStringLiteral( "crs_and_transforms" ) }; + return { QStringLiteral( "crs_and_transforms" ) }; } - diff --git a/src/app/options/qgscustomprojectionoptions.h b/src/app/options/qgscustomprojectionoptions.h index 8977a19db1b7..b0d914407180 100644 --- a/src/app/options/qgscustomprojectionoptions.h +++ b/src/app/options/qgscustomprojectionoptions.h @@ -33,7 +33,7 @@ class QDir; * * The resulting projection will be stored in an sqlite backend. */ -class QgsCustomProjectionOptionsWidget: public QgsOptionsPageWidget, private Ui::QgsCustomProjectionWidgetBase +class QgsCustomProjectionOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsCustomProjectionWidgetBase { Q_OBJECT public: @@ -50,23 +50,22 @@ class QgsCustomProjectionOptionsWidget: public QgsOptionsPageWidget, private Ui: void updateListFromCurrentItem(); private: - //helper functions void populateList(); bool saveCrs( const QgsCoordinateReferenceSystem &crs, const QString &name, const QString &id, bool newEntry, Qgis::CrsDefinitionFormat format ); QString multiLineWktToSingleLine( const QString &wkt ); //These two QMap store the values as they are on the database when loading - QMap mExistingCRSproj; - QMap mExistingCRSwkt; - QMap mExistingCRSnames; + QMap mExistingCRSproj; + QMap mExistingCRSwkt; + QMap mExistingCRSnames; struct Definition { - QString name; - QString id; - QString wkt; - QString proj; + QString name; + QString id; + QString wkt; + QString proj; }; enum Roles @@ -74,16 +73,20 @@ class QgsCustomProjectionOptionsWidget: public QgsOptionsPageWidget, private Ui: FormattedWktRole = Qt::UserRole + 1, }; - QList< Definition > mDefinitions; + QList mDefinitions; //vector saving the CRS to be deleted QStringList mDeletedCRSs; //Columns in the tree widget - enum Columns { QgisCrsNameColumn, QgisCrsIdColumn, QgisCrsParametersColumn }; + enum Columns + { + QgisCrsNameColumn, + QgisCrsIdColumn, + QgisCrsParametersColumn + }; int mBlockUpdates = 0; - }; @@ -92,13 +95,11 @@ class QgsCustomProjectionOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsCustomProjectionOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QStringList path() const override; - }; diff --git a/src/app/options/qgselevationoptions.cpp b/src/app/options/qgselevationoptions.cpp index fff7cf9548ba..475a6a463b69 100644 --- a/src/app/options/qgselevationoptions.cpp +++ b/src/app/options/qgselevationoptions.cpp @@ -73,4 +73,3 @@ QString QgsElevationOptionsFactory::pagePositionHint() const { return QStringLiteral( "mOptionsPageColors" ); } - diff --git a/src/app/options/qgselevationoptions.h b/src/app/options/qgselevationoptions.h index 8b6d10c04a1e..9ef35af0a54a 100644 --- a/src/app/options/qgselevationoptions.h +++ b/src/app/options/qgselevationoptions.h @@ -30,14 +30,12 @@ class QgsElevationOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsEl Q_OBJECT public: - /** * Constructor for QgsElevationOptionsWidget with the specified \a parent widget. */ QgsElevationOptionsWidget( QWidget *parent ); QString helpKey() const override; void apply() override; - }; @@ -46,7 +44,6 @@ class QgsElevationOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsElevationOptionsFactory(); QIcon icon() const override; diff --git a/src/app/options/qgsfontoptions.cpp b/src/app/options/qgsfontoptions.cpp index e96edac3a412..81f59391c6bb 100644 --- a/src/app/options/qgsfontoptions.cpp +++ b/src/app/options/qgsfontoptions.cpp @@ -31,13 +31,13 @@ QgsFontOptionsWidget::QgsFontOptionsWidget( QWidget *parent ) { setupUi( this ); - mTableReplacements->setHorizontalHeaderLabels( {tr( "Font Family" ), tr( "Replacement Family" ) } ); + mTableReplacements->setHorizontalHeaderLabels( { tr( "Font Family" ), tr( "Replacement Family" ) } ); mTableReplacements->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch ); - mTableUserFonts->setHorizontalHeaderLabels( {tr( "File" ), tr( "Font Families" ) } ); + mTableUserFonts->setHorizontalHeaderLabels( { tr( "File" ), tr( "Font Families" ) } ); mTableUserFonts->horizontalHeader()->setSectionResizeMode( QHeaderView::Interactive ); - const QMap< QString, QString > replacements = QgsApplication::fontManager()->fontFamilyReplacements(); + const QMap replacements = QgsApplication::fontManager()->fontFamilyReplacements(); mTableReplacements->setRowCount( replacements.size() ); int row = 0; for ( auto it = replacements.constBegin(); it != replacements.constEnd(); ++it ) @@ -47,17 +47,15 @@ QgsFontOptionsWidget::QgsFontOptionsWidget( QWidget *parent ) row++; } - connect( mButtonAddReplacement, &QToolButton::clicked, this, [ = ] - { + connect( mButtonAddReplacement, &QToolButton::clicked, this, [=] { mTableReplacements->setRowCount( mTableReplacements->rowCount() + 1 ); mTableReplacements->setFocus(); mTableReplacements->setCurrentCell( mTableReplacements->rowCount() - 1, 0 ); } ); - connect( mButtonRemoveReplacement, &QToolButton::clicked, this, [ = ] - { + connect( mButtonRemoveReplacement, &QToolButton::clicked, this, [=] { const QModelIndexList selection = mTableReplacements->selectionModel()->selectedRows(); - QList< int > selectedRows; + QList selectedRows; for ( const QModelIndex &index : selection ) selectedRows.append( index.row() ); @@ -71,7 +69,7 @@ QgsFontOptionsWidget::QgsFontOptionsWidget( QWidget *parent ) mCheckBoxDownloadFonts->setChecked( QgsFontManager::settingsDownloadMissingFonts->value() ); - const QMap< QString, QStringList > userFonts = QgsApplication::fontManager()->userFontToFamilyMap(); + const QMap userFonts = QgsApplication::fontManager()->userFontToFamilyMap(); mTableUserFonts->setRowCount( userFonts.size() ); mTableUserFonts->setSelectionBehavior( QAbstractItemView::SelectRows ); row = 0; @@ -88,10 +86,9 @@ QgsFontOptionsWidget::QgsFontOptionsWidget( QWidget *parent ) row++; } - connect( mButtonRemoveUserFont, &QToolButton::clicked, this, [ = ] - { + connect( mButtonRemoveUserFont, &QToolButton::clicked, this, [=] { const QModelIndexList selection = mTableUserFonts->selectionModel()->selectedRows(); - QList< int > selectedRows; + QList selectedRows; for ( const QModelIndex &index : selection ) selectedRows.append( index.row() ); @@ -102,7 +99,6 @@ QgsFontOptionsWidget::QgsFontOptionsWidget( QWidget *parent ) mTableUserFonts->removeRow( row ); } } ); - } QString QgsFontOptionsWidget::helpKey() const @@ -112,7 +108,7 @@ QString QgsFontOptionsWidget::helpKey() const void QgsFontOptionsWidget::apply() { - QMap< QString, QString > replacements; + QMap replacements; for ( int row = 0; row < mTableReplacements->rowCount(); ++row ) { const QString original = mTableReplacements->item( row, 0 )->text().trimmed(); @@ -126,8 +122,8 @@ void QgsFontOptionsWidget::apply() QgsFontManager::settingsDownloadMissingFonts->setValue( mCheckBoxDownloadFonts->isChecked() ); - const QMap< QString, QStringList > userFonts = QgsApplication::fontManager()->userFontToFamilyMap(); - QSet< QString > remainingUserFonts; + const QMap userFonts = QgsApplication::fontManager()->userFontToFamilyMap(); + QSet remainingUserFonts; for ( int row = 0; row < mTableUserFonts->rowCount(); ++row ) { const QString fileName = mTableUserFonts->item( row, 0 )->data( Qt::UserRole ).toString(); @@ -164,4 +160,3 @@ QString QgsFontOptionsFactory::pagePositionHint() const { return QStringLiteral( "mOptionsPageComposer" ); } - diff --git a/src/app/options/qgsfontoptions.h b/src/app/options/qgsfontoptions.h index efea9efdf7c7..fdacc62c0c49 100644 --- a/src/app/options/qgsfontoptions.h +++ b/src/app/options/qgsfontoptions.h @@ -31,14 +31,12 @@ class QgsFontOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsFontOpt Q_OBJECT public: - /** * Constructor for QgsFontOptionsWidget with the specified \a parent widget. */ QgsFontOptionsWidget( QWidget *parent ); QString helpKey() const override; void apply() override; - }; @@ -47,7 +45,6 @@ class QgsFontOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsFontOptionsFactory(); QIcon icon() const override; diff --git a/src/app/options/qgsgpsdeviceoptions.cpp b/src/app/options/qgsgpsdeviceoptions.cpp index ff966d2a7508..fee51b37aa22 100644 --- a/src/app/options/qgsgpsdeviceoptions.cpp +++ b/src/app/options/qgsgpsdeviceoptions.cpp @@ -36,43 +36,29 @@ QgsGpsDeviceOptionsWidget::QgsGpsDeviceOptionsWidget( QWidget *parent ) connect( mListDevices, &QListWidget::currentItemChanged, this, &QgsGpsDeviceOptionsWidget::selectedDeviceChanged ); mDescriptionBrowser->setHtml( QStringLiteral( "

%1

    " - "
  • %babel - %2
  • " - "
  • %in - %3
  • " - "
  • %out - %4
  • " - "
  • %type - %5
  • " - "
" ).arg( tr( "In the download and upload commands there can be special words that will be replaced by " - "QGIS when the commands are used. These words are:" ), - tr( "the path to GPSBabel" ), - tr( "the GPX filename when uploading or the port when downloading" ), - tr( "the port when uploading or the GPX filename when downloading" ), - tr( "GPSBabel feature type argument matching selected feature type (e.g. '-w' for waypoints, '-t' for tracks, and '-r' for routes)" ) ) ); - - const QMap< QString, QgsBabelGpsDeviceFormat * > registeredDevices = QgsApplication::gpsBabelFormatRegistry()->devices(); + "
  • %babel - %2
  • " + "
  • %in - %3
  • " + "
  • %out - %4
  • " + "
  • %type - %5
  • " + "" ) + .arg( tr( "In the download and upload commands there can be special words that will be replaced by " + "QGIS when the commands are used. These words are:" ), + tr( "the path to GPSBabel" ), tr( "the GPX filename when uploading or the port when downloading" ), tr( "the port when uploading or the GPX filename when downloading" ), tr( "GPSBabel feature type argument matching selected feature type (e.g. '-w' for waypoints, '-t' for tracks, and '-r' for routes)" ) ) ); + + const QMap registeredDevices = QgsApplication::gpsBabelFormatRegistry()->devices(); for ( auto it = registeredDevices.constBegin(); it != registeredDevices.constEnd(); ++it ) { if ( !it.value() ) continue; - const QString waypointDownloadCommand = - it.value()->importCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Waypoint, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); - const QString waypointUploadCommand = - it.value()->exportCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Waypoint, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); - const QString routeDownloadCommand = - it.value()->importCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Route, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); - const QString routeUploadCommand = - it.value()->exportCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Route, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); - const QString trackDownloadCommand = - it.value()->importCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Track, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); - const QString trackUploadCommand = - it.value()->exportCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Track, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); - - mDevices.insert( it.key(), {waypointDownloadCommand, - waypointUploadCommand, - routeDownloadCommand, - routeUploadCommand, - trackDownloadCommand, - trackUploadCommand - } ); + const QString waypointDownloadCommand = it.value()->importCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Waypoint, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); + const QString waypointUploadCommand = it.value()->exportCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Waypoint, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); + const QString routeDownloadCommand = it.value()->importCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Route, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); + const QString routeUploadCommand = it.value()->exportCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Route, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); + const QString trackDownloadCommand = it.value()->importCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Track, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); + const QString trackUploadCommand = it.value()->exportCommand( QStringLiteral( "%babel" ), Qgis::GpsFeatureType::Track, QStringLiteral( "%in" ), QStringLiteral( "%out" ) ).join( QLatin1Char( ' ' ) ); + + mDevices.insert( it.key(), { waypointDownloadCommand, waypointUploadCommand, routeDownloadCommand, routeUploadCommand, trackDownloadCommand, trackUploadCommand } ); } updateDeviceList(); @@ -129,9 +115,7 @@ void QgsGpsDeviceOptionsWidget::addNewDevice() void QgsGpsDeviceOptionsWidget::removeCurrentDevice() { - if ( QMessageBox::warning( this, tr( "Delete Device" ), - tr( "Are you sure that you want to delete this device?" ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Ok ) + if ( QMessageBox::warning( this, tr( "Delete Device" ), tr( "Are you sure that you want to delete this device?" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Ok ) { const auto iter = mDevices.find( mListDevices->currentItem()->text() ); if ( iter != mDevices.end() ) @@ -157,8 +141,7 @@ void QgsGpsDeviceOptionsWidget::updateDeviceList( const QString &selection ) // We're going to be changing the selected item, so disable our // notification of that. - disconnect( mListDevices, &QListWidget::currentItemChanged, - this, &QgsGpsDeviceOptionsWidget::selectedDeviceChanged ); + disconnect( mListDevices, &QListWidget::currentItemChanged, this, &QgsGpsDeviceOptionsWidget::selectedDeviceChanged ); mListDevices->clear(); for ( auto iter = mDevices.constBegin(); iter != mDevices.constEnd(); ++iter ) @@ -175,8 +158,7 @@ void QgsGpsDeviceOptionsWidget::updateDeviceList( const QString &selection ) // Update the display and reconnect the selection changed signal selectedDeviceChanged( mListDevices->currentItem() ); - connect( mListDevices, &QListWidget::currentItemChanged, - this, &QgsGpsDeviceOptionsWidget::selectedDeviceChanged ); + connect( mListDevices, &QListWidget::currentItemChanged, this, &QgsGpsDeviceOptionsWidget::selectedDeviceChanged ); } void QgsGpsDeviceOptionsWidget::selectedDeviceChanged( QListWidgetItem *current ) @@ -204,13 +186,7 @@ void QgsGpsDeviceOptionsWidget::updateCurrentDevice() return; const QString name = mListDevices->currentItem()->text(); - mDevices.insert( name, {leWptDown->text(), - leWptUp->text(), - leRteDown->text(), - leRteUp->text(), - leTrkDown->text(), - leTrkUp->text() - } ); + mDevices.insert( name, { leWptDown->text(), leWptUp->text(), leRteDown->text(), leRteUp->text(), leTrkDown->text(), leTrkUp->text() } ); } void QgsGpsDeviceOptionsWidget::renameCurrentDevice() @@ -222,13 +198,7 @@ void QgsGpsDeviceOptionsWidget::renameCurrentDevice() const QString newName = leDeviceName->text(); mDevices.remove( prevName ); - mDevices.insert( newName, {leWptDown->text(), - leWptUp->text(), - leRteDown->text(), - leRteUp->text(), - leTrkDown->text(), - leTrkUp->text() - } ); + mDevices.insert( newName, { leWptDown->text(), leWptUp->text(), leRteDown->text(), leRteUp->text(), leTrkDown->text(), leTrkUp->text() } ); mListDevices->currentItem()->setText( newName ); } @@ -239,7 +209,6 @@ void QgsGpsDeviceOptionsWidget::renameCurrentDevice() QgsGpsDeviceOptionsFactory::QgsGpsDeviceOptionsFactory() : QgsOptionsWidgetFactory( tr( "GPSBabel" ), QIcon(), QStringLiteral( "gpsbabel" ) ) { - } QIcon QgsGpsDeviceOptionsFactory::icon() const @@ -254,6 +223,5 @@ QgsOptionsPageWidget *QgsGpsDeviceOptionsFactory::createWidget( QWidget *parent QStringList QgsGpsDeviceOptionsFactory::path() const { - return {QStringLiteral( "gps" ) }; + return { QStringLiteral( "gps" ) }; } - diff --git a/src/app/options/qgsgpsdeviceoptions.h b/src/app/options/qgsgpsdeviceoptions.h index 9882b48f5df4..5d540c3590de 100644 --- a/src/app/options/qgsgpsdeviceoptions.h +++ b/src/app/options/qgsgpsdeviceoptions.h @@ -33,7 +33,6 @@ class QgsGpsDeviceOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsGp Q_OBJECT public: - /** * Constructor for QgsGpsDeviceOptionsWidget with the specified \a parent widget. */ @@ -50,7 +49,7 @@ class QgsGpsDeviceOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsGp void renameCurrentDevice(); private: - QMap mDevices; + QMap mDevices; bool mBlockStoringChanges = false; }; @@ -60,13 +59,11 @@ class QgsGpsDeviceOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsGpsDeviceOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QStringList path() const override; - }; diff --git a/src/app/options/qgsgpsoptions.cpp b/src/app/options/qgsgpsoptions.cpp index 7d1f8fdbc7d1..7cd37cafd3e3 100644 --- a/src/app/options/qgsgpsoptions.cpp +++ b/src/app/options/qgsgpsoptions.cpp @@ -31,7 +31,7 @@ #include const int MAXACQUISITIONINTERVAL = 3000; // max gps information acquisition suspension interval (in seconds) -const int MAXDISTANCETHRESHOLD = 200; // max gps distance threshold (in meters) +const int MAXDISTANCETHRESHOLD = 200; // max gps distance threshold (in meters) // // QgsGpsOptionsWidget @@ -72,7 +72,7 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent ) QDomDocument symbolDoc; symbolDoc.setContent( defaultSymbol ); const QDomElement markerElement = symbolDoc.documentElement(); - std::unique_ptr< QgsMarkerSymbol > gpsMarkerSymbol( QgsSymbolLayerUtils::loadSymbol( markerElement, QgsReadWriteContext() ) ); + std::unique_ptr gpsMarkerSymbol( QgsSymbolLayerUtils::loadSymbol( markerElement, QgsReadWriteContext() ) ); if ( gpsMarkerSymbol ) mGpsMarkerSymbolButton->setSymbol( gpsMarkerSymbol.release() ); @@ -90,7 +90,7 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent ) { doc.setContent( bearingLineSymbolXml ); elem = doc.documentElement(); - std::unique_ptr< QgsLineSymbol > bearingSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); + std::unique_ptr bearingSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); if ( bearingSymbol ) mBearingLineStyleButton->setSymbol( bearingSymbol.release() ); } @@ -100,7 +100,7 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent ) { doc.setContent( trackLineSymbolXml ); elem = doc.documentElement(); - std::unique_ptr< QgsLineSymbol > trackLineSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); + std::unique_ptr trackLineSymbol( QgsSymbolLayerUtils::loadSymbol( elem, QgsReadWriteContext() ) ); if ( trackLineSymbol ) mTrackLineStyleButton->setSymbol( trackLineSymbol.release() ); } @@ -167,19 +167,19 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent ) { connectionType = QgsGpsConnection::settingsGpsConnectionType->value(); gpsdHost = QgsGpsConnection::settingsGpsdHostName->value(); - gpsdPort = static_cast< int >( QgsGpsConnection::settingsGpsdPortNumber->value() ); + gpsdPort = static_cast( QgsGpsConnection::settingsGpsdPortNumber->value() ); gpsdDevice = QgsGpsConnection::settingsGpsdDeviceName->value(); - acquisitionInterval = static_cast< int >( QgsGpsConnection::settingGpsAcquisitionInterval->value() ); + acquisitionInterval = static_cast( QgsGpsConnection::settingGpsAcquisitionInterval->value() ); distanceThreshold = QgsGpsConnection::settingGpsDistanceThreshold->value(); bearingFromTravelDirection = QgsGpsConnection::settingGpsBearingFromTravelDirection->value(); - recenteringThreshold = static_cast< int >( QgsGpsCanvasBridge::settingMapExtentRecenteringThreshold->value() ); - rotateInterval = static_cast< int >( QgsGpsCanvasBridge::settingMapRotateInterval->value() ); + recenteringThreshold = static_cast( QgsGpsCanvasBridge::settingMapExtentRecenteringThreshold->value() ); + rotateInterval = static_cast( QgsGpsCanvasBridge::settingMapRotateInterval->value() ); applyLeapSeconds = QgsGpsConnection::settingGpsApplyLeapSecondsCorrection->value(); - leapSeconds = static_cast< int >( QgsGpsConnection::settingGpsLeapSeconds->value() ); + leapSeconds = static_cast( QgsGpsConnection::settingGpsLeapSeconds->value() ); timeSpec = QgsGpsConnection::settingsGpsTimeStampSpecification->value(); timeZone = QgsGpsConnection::settingsGpsTimeStampTimeZone->value(); - offsetFromUtc = static_cast< int >( QgsGpsConnection::settingsGpsTimeStampOffsetFromUtc->value() ); + offsetFromUtc = static_cast( QgsGpsConnection::settingsGpsTimeStampOffsetFromUtc->value() ); if ( QgsGpsLogger::settingsGpsStoreAttributeInMValues->value() ) { @@ -288,8 +288,7 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent ) if ( mCboTimestampFormat->currentIndex() < 0 ) mCboTimestampFormat->setCurrentIndex( 0 ); - connect( mCboTimestampFormat, qOverload< int >( &QComboBox::currentIndexChanged ), - this, &QgsGpsOptionsWidget::timestampFormatChanged ); + connect( mCboTimestampFormat, qOverload( &QComboBox::currentIndexChanged ), this, &QgsGpsOptionsWidget::timestampFormatChanged ); timestampFormatChanged( 0 ); updateTimeZones(); @@ -376,7 +375,7 @@ void QgsGpsOptionsWidget::apply() QgsGpsCanvasBridge::settingMapExtentRecenteringThreshold->setValue( mSpinMapExtentMultiplier->value() ); QgsGpsCanvasBridge::settingMapRotateInterval->setValue( mSpinMapRotateInterval->value() ); - QgsGpsConnection::settingsGpsTimeStampSpecification->setValue( static_cast< Qt::TimeSpec >( mCboTimestampFormat->currentData( ).toInt() ) ); + QgsGpsConnection::settingsGpsTimeStampSpecification->setValue( static_cast( mCboTimestampFormat->currentData().toInt() ) ); QgsGpsConnection::settingsGpsTimeStampTimeZone->setValue( mCboTimeZones->currentText() ); QgsGpsConnection::settingGpsApplyLeapSecondsCorrection->setValue( mCbxLeapSeconds->isChecked() ); QgsGpsConnection::settingGpsLeapSeconds->setValue( mLeapSeconds->value() ); @@ -389,13 +388,13 @@ void QgsGpsOptionsWidget::apply() else { QgsGpsLogger::settingsGpsStoreAttributeInMValues->setValue( true ); - QgsGpsLogger::settingsGpsMValueComponent->setValue( mComboMValueAttribute->currentData().value< Qgis::GpsInformationComponent >() ); + QgsGpsLogger::settingsGpsMValueComponent->setValue( mComboMValueAttribute->currentData().value() ); } } void QgsGpsOptionsWidget::refreshDevices() { - QList< QPair > ports = QgsGpsDetector::availablePorts(); + QList> ports = QgsGpsDetector::availablePorts(); mCboDevices->clear(); @@ -424,8 +423,8 @@ void QgsGpsOptionsWidget::refreshDevices() void QgsGpsOptionsWidget::timestampFormatChanged( int ) { - const Qt::TimeSpec currentSpec = static_cast( mCboTimestampFormat->currentData( ).toInt() ); - const bool timeZoneEnabled {currentSpec == Qt::TimeSpec::TimeZone }; + const Qt::TimeSpec currentSpec = static_cast( mCboTimestampFormat->currentData().toInt() ); + const bool timeZoneEnabled { currentSpec == Qt::TimeSpec::TimeZone }; mCboTimeZones->setEnabled( timeZoneEnabled ); mLblTimeZone->setEnabled( timeZoneEnabled ); const bool offsetFromUtcEnabled = currentSpec == Qt::TimeSpec::OffsetFromUTC; @@ -435,7 +434,7 @@ void QgsGpsOptionsWidget::timestampFormatChanged( int ) void QgsGpsOptionsWidget::updateTimeZones() { - const bool enabled = static_cast( mCboTimestampFormat->currentData( ).toInt() ) == Qt::TimeSpec::TimeZone; + const bool enabled = static_cast( mCboTimestampFormat->currentData().toInt() ) == Qt::TimeSpec::TimeZone; mCboTimeZones->setEnabled( enabled ); mLblTimeZone->setEnabled( enabled ); } @@ -446,7 +445,6 @@ void QgsGpsOptionsWidget::updateTimeZones() QgsGpsOptionsFactory::QgsGpsOptionsFactory() : QgsOptionsWidgetFactory( tr( "GPS" ), QIcon(), QStringLiteral( "gps" ) ) { - } QIcon QgsGpsOptionsFactory::icon() const diff --git a/src/app/options/qgsgpsoptions.h b/src/app/options/qgsgpsoptions.h index c8d642525e3e..a3b1999c81f2 100644 --- a/src/app/options/qgsgpsoptions.h +++ b/src/app/options/qgsgpsoptions.h @@ -31,7 +31,6 @@ class APP_EXPORT QgsGpsOptionsWidget : public QgsOptionsPageWidget, private Ui:: Q_OBJECT public: - /** * Constructor for QgsGpsOptionsWidget with the specified \a parent widget. */ @@ -45,7 +44,6 @@ class APP_EXPORT QgsGpsOptionsWidget : public QgsOptionsPageWidget, private Ui:: void timestampFormatChanged( int index ); private: - void updateTimeZones(); bool mBlockStoringChanges = false; @@ -61,13 +59,11 @@ class QgsGpsOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsGpsOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QString pagePositionHint() const override; - }; diff --git a/src/app/options/qgsideoptions.cpp b/src/app/options/qgsideoptions.cpp index 94419b41c85c..62287cb82462 100644 --- a/src/app/options/qgsideoptions.cpp +++ b/src/app/options/qgsideoptions.cpp @@ -55,8 +55,8 @@ void QgsIdeOptionsWidget::apply() void QgsIdeOptionsWidget::generateGitHubToken() { QDesktopServices::openUrl( QUrl( - QStringLiteral( "https://github.com/settings/tokens/new?description=%1&scopes=gist" ).arg( tr( "QGIS Code Editor" ) ) - ) ); + QStringLiteral( "https://github.com/settings/tokens/new?description=%1&scopes=gist" ).arg( tr( "QGIS Code Editor" ) ) + ) ); } // @@ -66,7 +66,6 @@ void QgsIdeOptionsWidget::generateGitHubToken() QgsIdeOptionsFactory::QgsIdeOptionsFactory() : QgsOptionsWidgetFactory( tr( "IDE" ), QIcon(), QStringLiteral( "ide" ) ) { - } QIcon QgsIdeOptionsFactory::icon() const diff --git a/src/app/options/qgsideoptions.h b/src/app/options/qgsideoptions.h index fc0e66eda3d2..4f57bb0c8c6e 100644 --- a/src/app/options/qgsideoptions.h +++ b/src/app/options/qgsideoptions.h @@ -28,7 +28,6 @@ class QgsIdeOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsIdeOptio Q_OBJECT public: - /** * Constructor for QgsIdeOptionsWidget with the specified \a parent widget. */ @@ -42,7 +41,6 @@ class QgsIdeOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsIdeOptio private slots: void generateGitHubToken(); - }; @@ -51,13 +49,11 @@ class QgsIdeOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsIdeOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QString pagePositionHint() const override; - }; #endif // QGSIDEOPTIONS_H diff --git a/src/app/options/qgsoptions.cpp b/src/app/options/qgsoptions.cpp index fd34c5a5c1f0..683d23c6f09f 100644 --- a/src/app/options/qgsoptions.cpp +++ b/src/app/options/qgsoptions.cpp @@ -84,7 +84,7 @@ #include #include "qgslogger.h" -#define CPL_SUPRESS_CPLUSPLUS //#spellok +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include #include #include // for setting gdal options @@ -145,10 +145,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListdata( 0, Qt::UserRole ).toString(); - for ( int i = 0; i < otherTree->topLevelItemCount(); ++ i ) + for ( int i = 0; i < otherTree->topLevelItemCount(); ++i ) { if ( QTreeWidgetItem *otherItem = otherTree->topLevelItem( i ) ) { @@ -161,12 +160,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList( &QComboBox::currentIndexChanged ), this, [ = ]( int ) { updateSampleLocaleText( ); } ); - connect( cbShowGroupSeparator, &QCheckBox::toggled, this, [ = ]( bool ) { updateSampleLocaleText(); } ); + connect( cboGlobalLocale, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { updateSampleLocaleText(); } ); + connect( cbShowGroupSeparator, &QCheckBox::toggled, this, [=]( bool ) { updateSampleLocaleText(); } ); // QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states, // switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left), @@ -185,8 +182,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListisValid() ) @@ -200,8 +196,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList( &QComboBox::activated ), this, &QgsOptions::iconSizeChanged ); - connect( cmbIconSize, qOverload< int >( &QComboBox::highlighted ), this, &QgsOptions::iconSizeChanged ); + connect( cmbIconSize, qOverload( &QComboBox::activated ), this, &QgsOptions::iconSizeChanged ); + connect( cmbIconSize, qOverload( &QComboBox::highlighted ), this, &QgsOptions::iconSizeChanged ); connect( cmbIconSize, &QComboBox::editTextChanged, this, &QgsOptions::iconSizeChanged ); connect( this, &QDialog::accepted, this, &QgsOptions::saveOptions ); @@ -495,11 +491,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetChecked( mSettings->value( QStringLiteral( "clear_auth_cache_on_errors" ), true, QgsSettings::Section::Auth ).toBool( ) ); + mAutoClearAccessCache->setChecked( mSettings->value( QStringLiteral( "clear_auth_cache_on_errors" ), true, QgsSettings::Section::Auth ).toBool() ); connect( mClearAccessCache, &QAbstractButton::clicked, this, &QgsOptions::clearAccessCache ); - connect( mAutoClearAccessCache, &QCheckBox::clicked, this, [ = ]( bool checked ) - { + connect( mAutoClearAccessCache, &QCheckBox::clicked, this, [=]( bool checked ) { mSettings->setValue( QStringLiteral( "clear_auth_cache_on_errors" ), checked, QgsSettings::Section::Auth ); } ); @@ -521,18 +516,19 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetSpecialValueText( tr( "All" ) ); cmbPromptSublayers->clear(); - cmbPromptSublayers->addItem( tr( "Always" ), static_cast< int >( Qgis::SublayerPromptMode::AlwaysAsk ) ); - cmbPromptSublayers->addItem( tr( "If Needed" ), static_cast< int >( Qgis::SublayerPromptMode::AskExcludingRasterBands ) ); //this means, prompt if there are sublayers but no band in the main dataset - cmbPromptSublayers->addItem( tr( "Never" ), static_cast< int >( Qgis::SublayerPromptMode::NeverAskSkip ) ); - cmbPromptSublayers->addItem( tr( "Load All" ), static_cast< int >( Qgis::SublayerPromptMode::NeverAskLoadAll ) ); - cmbPromptSublayers->setCurrentIndex( cmbPromptSublayers->findData( static_cast< int >( mSettings->enumValue( QStringLiteral( "/qgis/promptForSublayers" ), Qgis::SublayerPromptMode::AlwaysAsk ) ) ) ); + cmbPromptSublayers->addItem( tr( "Always" ), static_cast( Qgis::SublayerPromptMode::AlwaysAsk ) ); + cmbPromptSublayers->addItem( tr( "If Needed" ), static_cast( Qgis::SublayerPromptMode::AskExcludingRasterBands ) ); //this means, prompt if there are sublayers but no band in the main dataset + cmbPromptSublayers->addItem( tr( "Never" ), static_cast( Qgis::SublayerPromptMode::NeverAskSkip ) ); + cmbPromptSublayers->addItem( tr( "Load All" ), static_cast( Qgis::SublayerPromptMode::NeverAskLoadAll ) ); + cmbPromptSublayers->setCurrentIndex( cmbPromptSublayers->findData( static_cast( mSettings->enumValue( QStringLiteral( "/qgis/promptForSublayers" ), Qgis::SublayerPromptMode::AlwaysAsk ) ) ) ); // Scan for valid items in the browser dock cmbScanItemsInBrowser->clear(); cmbScanItemsInBrowser->addItem( tr( "Check File Contents" ), "contents" ); // 0 cmbScanItemsInBrowser->addItem( tr( "Check Extension" ), "extension" ); // 1 int index = cmbScanItemsInBrowser->findData( mSettings->value( QStringLiteral( "/qgis/scanItemsInBrowser2" ), QString() ) ); - if ( index == -1 ) index = 1; + if ( index == -1 ) + index = 1; cmbScanItemsInBrowser->setCurrentIndex( index ); // Scan for contents of compressed files (.zip) in browser dock @@ -542,7 +538,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListaddItem( tr( "Basic Scan" ), QVariant( "basic" ) ); cmbScanZipInBrowser->addItem( tr( "Full Scan" ), QVariant( "full" ) ); index = cmbScanZipInBrowser->findData( mSettings->value( QStringLiteral( "/qgis/scanZipInBrowser2" ), QString() ) ); - if ( index == -1 ) index = 1; + if ( index == -1 ) + index = 1; cmbScanZipInBrowser->setCurrentIndex( index ); mCheckMonitorDirectories->setChecked( mSettings->value( QStringLiteral( "/qgis/monitorDirectoriesInBrowser" ), true ).toBool() ); @@ -577,9 +574,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetMessage( tr( "

    Default projection for new projects

    " "Select a projection that should be used for new projects that are created in QGIS." - ) ); + ) + ); - const QgsGui::ProjectCrsBehavior projectCrsBehavior = mSettings->enumValue( QStringLiteral( "/projections/newProjectCrsBehavior" ), QgsGui::UseCrsOfFirstLayerAdded, QgsSettings::App ); + const QgsGui::ProjectCrsBehavior projectCrsBehavior = mSettings->enumValue( QStringLiteral( "/projections/newProjectCrsBehavior" ), QgsGui::UseCrsOfFirstLayerAdded, QgsSettings::App ); switch ( projectCrsBehavior ) { case QgsGui::UseCrsOfFirstLayerAdded: @@ -608,51 +606,51 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListaddItem( tr( "Meters" ), static_cast< int >( Qgis::DistanceUnit::Meters ) ); - mDistanceUnitsComboBox->addItem( tr( "Kilometers" ), static_cast< int >( Qgis::DistanceUnit::Kilometers ) ); - mDistanceUnitsComboBox->addItem( tr( "Feet" ), static_cast< int >( Qgis::DistanceUnit::Feet ) ); - mDistanceUnitsComboBox->addItem( tr( "Yards" ), static_cast< int >( Qgis::DistanceUnit::Yards ) ); - mDistanceUnitsComboBox->addItem( tr( "Miles" ), static_cast< int >( Qgis::DistanceUnit::Miles ) ); - mDistanceUnitsComboBox->addItem( tr( "Nautical Miles" ), static_cast< int >( Qgis::DistanceUnit::NauticalMiles ) ); - mDistanceUnitsComboBox->addItem( tr( "Centimeters" ), static_cast< int >( Qgis::DistanceUnit::Centimeters ) ); - mDistanceUnitsComboBox->addItem( tr( "Millimeters" ), static_cast< int >( Qgis::DistanceUnit::Millimeters ) ); - mDistanceUnitsComboBox->addItem( tr( "Inches" ), static_cast< int >( Qgis::DistanceUnit::Inches ) ); - mDistanceUnitsComboBox->addItem( tr( "Degrees" ), static_cast< int >( Qgis::DistanceUnit::Degrees ) ); - mDistanceUnitsComboBox->addItem( tr( "Map Units" ), static_cast< int >( Qgis::DistanceUnit::Unknown ) ); + mDistanceUnitsComboBox->addItem( tr( "Meters" ), static_cast( Qgis::DistanceUnit::Meters ) ); + mDistanceUnitsComboBox->addItem( tr( "Kilometers" ), static_cast( Qgis::DistanceUnit::Kilometers ) ); + mDistanceUnitsComboBox->addItem( tr( "Feet" ), static_cast( Qgis::DistanceUnit::Feet ) ); + mDistanceUnitsComboBox->addItem( tr( "Yards" ), static_cast( Qgis::DistanceUnit::Yards ) ); + mDistanceUnitsComboBox->addItem( tr( "Miles" ), static_cast( Qgis::DistanceUnit::Miles ) ); + mDistanceUnitsComboBox->addItem( tr( "Nautical Miles" ), static_cast( Qgis::DistanceUnit::NauticalMiles ) ); + mDistanceUnitsComboBox->addItem( tr( "Centimeters" ), static_cast( Qgis::DistanceUnit::Centimeters ) ); + mDistanceUnitsComboBox->addItem( tr( "Millimeters" ), static_cast( Qgis::DistanceUnit::Millimeters ) ); + mDistanceUnitsComboBox->addItem( tr( "Inches" ), static_cast( Qgis::DistanceUnit::Inches ) ); + mDistanceUnitsComboBox->addItem( tr( "Degrees" ), static_cast( Qgis::DistanceUnit::Degrees ) ); + mDistanceUnitsComboBox->addItem( tr( "Map Units" ), static_cast( Qgis::DistanceUnit::Unknown ) ); bool ok = false; Qgis::DistanceUnit distanceUnits = QgsUnitTypes::decodeDistanceUnit( mSettings->value( QStringLiteral( "/qgis/measure/displayunits" ) ).toString(), &ok ); if ( !ok ) distanceUnits = Qgis::DistanceUnit::Meters; - mDistanceUnitsComboBox->setCurrentIndex( mDistanceUnitsComboBox->findData( static_cast< int >( distanceUnits ) ) ); - - mAreaUnitsComboBox->addItem( tr( "Square Meters" ), static_cast< int >( Qgis::AreaUnit::SquareMeters ) ); - mAreaUnitsComboBox->addItem( tr( "Square Kilometers" ), static_cast< int >( Qgis::AreaUnit::SquareKilometers ) ); - mAreaUnitsComboBox->addItem( tr( "Square Feet" ), static_cast< int >( Qgis::AreaUnit::SquareFeet ) ); - mAreaUnitsComboBox->addItem( tr( "Square Yards" ), static_cast< int >( Qgis::AreaUnit::SquareYards ) ); - mAreaUnitsComboBox->addItem( tr( "Square Miles" ), static_cast< int >( Qgis::AreaUnit::SquareMiles ) ); - mAreaUnitsComboBox->addItem( tr( "Hectares" ), static_cast< int >( Qgis::AreaUnit::Hectares ) ); - mAreaUnitsComboBox->addItem( tr( "Acres" ), static_cast< int >( Qgis::AreaUnit::Acres ) ); - mAreaUnitsComboBox->addItem( tr( "Square Nautical Miles" ), static_cast< int >( Qgis::AreaUnit::SquareNauticalMiles ) ); - mAreaUnitsComboBox->addItem( tr( "Square Centimeters" ), static_cast< int >( Qgis::AreaUnit::SquareCentimeters ) ); - mAreaUnitsComboBox->addItem( tr( "Square Millimeters" ), static_cast< int >( Qgis::AreaUnit::SquareMillimeters ) ); - mAreaUnitsComboBox->addItem( tr( "Square Inches" ), static_cast< int >( Qgis::AreaUnit::SquareInches ) ); - mAreaUnitsComboBox->addItem( tr( "Square Degrees" ), static_cast< int >( Qgis::AreaUnit::SquareDegrees ) ); - mAreaUnitsComboBox->addItem( tr( "Map Units" ), static_cast< int >( Qgis::AreaUnit::Unknown ) ); + mDistanceUnitsComboBox->setCurrentIndex( mDistanceUnitsComboBox->findData( static_cast( distanceUnits ) ) ); + + mAreaUnitsComboBox->addItem( tr( "Square Meters" ), static_cast( Qgis::AreaUnit::SquareMeters ) ); + mAreaUnitsComboBox->addItem( tr( "Square Kilometers" ), static_cast( Qgis::AreaUnit::SquareKilometers ) ); + mAreaUnitsComboBox->addItem( tr( "Square Feet" ), static_cast( Qgis::AreaUnit::SquareFeet ) ); + mAreaUnitsComboBox->addItem( tr( "Square Yards" ), static_cast( Qgis::AreaUnit::SquareYards ) ); + mAreaUnitsComboBox->addItem( tr( "Square Miles" ), static_cast( Qgis::AreaUnit::SquareMiles ) ); + mAreaUnitsComboBox->addItem( tr( "Hectares" ), static_cast( Qgis::AreaUnit::Hectares ) ); + mAreaUnitsComboBox->addItem( tr( "Acres" ), static_cast( Qgis::AreaUnit::Acres ) ); + mAreaUnitsComboBox->addItem( tr( "Square Nautical Miles" ), static_cast( Qgis::AreaUnit::SquareNauticalMiles ) ); + mAreaUnitsComboBox->addItem( tr( "Square Centimeters" ), static_cast( Qgis::AreaUnit::SquareCentimeters ) ); + mAreaUnitsComboBox->addItem( tr( "Square Millimeters" ), static_cast( Qgis::AreaUnit::SquareMillimeters ) ); + mAreaUnitsComboBox->addItem( tr( "Square Inches" ), static_cast( Qgis::AreaUnit::SquareInches ) ); + mAreaUnitsComboBox->addItem( tr( "Square Degrees" ), static_cast( Qgis::AreaUnit::SquareDegrees ) ); + mAreaUnitsComboBox->addItem( tr( "Map Units" ), static_cast( Qgis::AreaUnit::Unknown ) ); Qgis::AreaUnit areaUnits = QgsUnitTypes::decodeAreaUnit( mSettings->value( QStringLiteral( "/qgis/measure/areaunits" ) ).toString(), &ok ); if ( !ok ) areaUnits = Qgis::AreaUnit::SquareMeters; - mAreaUnitsComboBox->setCurrentIndex( mAreaUnitsComboBox->findData( static_cast< int >( areaUnits ) ) ); + mAreaUnitsComboBox->setCurrentIndex( mAreaUnitsComboBox->findData( static_cast( areaUnits ) ) ); - mAngleUnitsComboBox->addItem( tr( "Degrees" ), static_cast< int >( Qgis::AngleUnit::Degrees ) ); - mAngleUnitsComboBox->addItem( tr( "Radians" ), static_cast< int >( Qgis::AngleUnit::Radians ) ); - mAngleUnitsComboBox->addItem( tr( "Gon/gradians" ), static_cast< int >( Qgis::AngleUnit::Gon ) ); - mAngleUnitsComboBox->addItem( tr( "Minutes of Arc" ), static_cast< int >( Qgis::AngleUnit::MinutesOfArc ) ); - mAngleUnitsComboBox->addItem( tr( "Seconds of Arc" ), static_cast< int >( Qgis::AngleUnit::SecondsOfArc ) ); - mAngleUnitsComboBox->addItem( tr( "Turns/revolutions" ), static_cast< int >( Qgis::AngleUnit::Turn ) ); - mAngleUnitsComboBox->addItem( tr( "Milliradians (SI Definition)" ), static_cast< int >( Qgis::AngleUnit::MilliradiansSI ) ); - mAngleUnitsComboBox->addItem( tr( "Mil (NATO/military Definition)" ), static_cast< int >( Qgis::AngleUnit::MilNATO ) ); + mAngleUnitsComboBox->addItem( tr( "Degrees" ), static_cast( Qgis::AngleUnit::Degrees ) ); + mAngleUnitsComboBox->addItem( tr( "Radians" ), static_cast( Qgis::AngleUnit::Radians ) ); + mAngleUnitsComboBox->addItem( tr( "Gon/gradians" ), static_cast( Qgis::AngleUnit::Gon ) ); + mAngleUnitsComboBox->addItem( tr( "Minutes of Arc" ), static_cast( Qgis::AngleUnit::MinutesOfArc ) ); + mAngleUnitsComboBox->addItem( tr( "Seconds of Arc" ), static_cast( Qgis::AngleUnit::SecondsOfArc ) ); + mAngleUnitsComboBox->addItem( tr( "Turns/revolutions" ), static_cast( Qgis::AngleUnit::Turn ) ); + mAngleUnitsComboBox->addItem( tr( "Milliradians (SI Definition)" ), static_cast( Qgis::AngleUnit::MilliradiansSI ) ); + mAngleUnitsComboBox->addItem( tr( "Mil (NATO/military Definition)" ), static_cast( Qgis::AngleUnit::MilNATO ) ); Qgis::AngleUnit unit = QgsUnitTypes::decodeAngleUnit( mSettings->value( QStringLiteral( "/qgis/measure/angleunits" ), QgsUnitTypes::encodeUnit( Qgis::AngleUnit::Degrees ) ).toString() ); mAngleUnitsComboBox->setCurrentIndex( mAngleUnitsComboBox->findData( static_cast( unit ) ) ); @@ -828,12 +826,13 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListenumValue( QStringLiteral( "/qgis/enablePythonEmbedded" ), Qgis::PythonEmbeddedMode::Ask ); mEnableMacrosComboBox->setCurrentIndex( mEnableMacrosComboBox->findData( QVariant::fromValue( pyEmbeddedMode ) ) ); - mDefaultPathsComboBox->addItem( tr( "Absolute" ), static_cast< int >( Qgis::FilePathType::Absolute ) ); - mDefaultPathsComboBox->addItem( tr( "Relative" ), static_cast< int >( Qgis::FilePathType::Relative ) ); + mDefaultPathsComboBox->addItem( tr( "Absolute" ), static_cast( Qgis::FilePathType::Absolute ) ); + mDefaultPathsComboBox->addItem( tr( "Relative" ), static_cast( Qgis::FilePathType::Relative ) ); mDefaultPathsComboBox->setCurrentIndex( mDefaultPathsComboBox->findData( - static_cast< int >( - mSettings->value( QStringLiteral( "/qgis/defaultProjectPathsRelative" ), QVariant( true ) ).toBool() ? Qgis::FilePathType::Relative : Qgis::FilePathType::Absolute ) + static_cast( + mSettings->value( QStringLiteral( "/qgis/defaultProjectPathsRelative" ), QVariant( true ) ).toBool() ? Qgis::FilePathType::Relative : Qgis::FilePathType::Absolute + ) ) ); @@ -843,11 +842,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetChecked( mSettings->value( QStringLiteral( "/qgis/newProjectDefault" ), QVariant( false ) ).toBool() ); - QString templateDirName = mSettings->value( QStringLiteral( "/qgis/projectTemplateDir" ), - QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); + QString templateDirName = mSettings->value( QStringLiteral( "/qgis/projectTemplateDir" ), QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); // make dir if it doesn't exist - should just be called once QDir templateDir; - if ( ! templateDir.exists( templateDirName ) ) + if ( !templateDir.exists( templateDirName ) ) { templateDir.mkdir( templateDirName ); } @@ -865,7 +863,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListvalue(); for ( const QString &scale : scalePaths ) { - if ( ! scale.isEmpty() ) + if ( !scale.isEmpty() ) { addScaleToScaleList( scale ); } @@ -888,8 +886,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetCurrentIndex( mColorSchemesComboBox->count() - 1 ); } } ); - connect( mActionRemovePalette, &QAction::triggered, this, [ = ] - { + connect( mActionRemovePalette, &QAction::triggered, this, [=] { //get current scheme QList schemeList = QgsApplication::colorSchemeRegistry()->schemes(); int prevIndex = mColorSchemesComboBox->currentIndex(); @@ -921,8 +917,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetCurrentIndex( prevIndex ); } } ); - connect( mActionNewPalette, &QAction::triggered, this, [ = ] - { + connect( mActionNewPalette, &QAction::triggered, this, [=] { if ( QgsCompoundColorWidget::createNewUserPalette( this ) ) { //refresh combobox @@ -931,9 +926,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList( mTreeCustomColors->scheme() ); + connect( mActionShowInButtons, &QAction::toggled, this, [=]( bool state ) { + QgsUserColorScheme *scheme = dynamic_cast( mTreeCustomColors->scheme() ); if ( scheme ) { scheme->setShowSchemeInMenu( state ); @@ -958,8 +952,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetCurrentIndex( mColorSchemesComboBox->findText( customSchemes.at( 0 )->schemeName() ) ); updateActionsForCurrentColorScheme( customSchemes.at( 0 ) ); } - connect( mColorSchemesComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [ = ]( int index ) - { + connect( mColorSchemesComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=]( int index ) { //save changes to scheme if ( mTreeCustomColors->isDirty() ) { @@ -1049,15 +1042,16 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList allLocales = QLocale::matchingLocales( - QLocale::AnyLanguage, - QLocale::AnyScript, - QLocale::AnyCountry ); + QLocale::AnyLanguage, + QLocale::AnyScript, + QLocale::AnyCountry + ); QSet addedLocales; for ( const auto &l : allLocales ) { // Do not add duplicates (like en_US) - if ( ! addedLocales.contains( l.name() ) ) + if ( !addedLocales.contains( l.name() ) ) { cboGlobalLocale->addItem( QStringLiteral( "%1 %2 (%3)" ).arg( QLocale::languageToString( l.language() ), QLocale::countryToString( l.country() ), l.name() ), l.name() ); addedLocales.insert( l.name() ); @@ -1095,9 +1089,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList() ) { - mDefaultSnapTypeComboBox->addItem( QgsSnappingConfig::snappingTypeToIcon( type ), - QgsSnappingConfig::snappingTypeToString( type ), - QVariant::fromValue( type ) ); + mDefaultSnapTypeComboBox->addItem( QgsSnappingConfig::snappingTypeToIcon( type ), QgsSnappingConfig::snappingTypeToString( type ), QVariant::fromValue( type ) ); } Qgis::SnappingTypes defaultSnapType = QgsSettingsRegistryCore::settingsDigitizingDefaultSnapType->value(); @@ -1168,11 +1160,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListaddItem( tr( "Dock" ), "dock" ); mSnappingMainDialogComboBox->setCurrentIndex( mSnappingMainDialogComboBox->findData( mSettings->value( QStringLiteral( "/qgis/mainSnappingWidgetMode" ), "dialog" ).toString() ) ); - mOffsetJoinStyleComboBox->addItem( tr( "Round" ), static_cast< int >( Qgis::JoinStyle::Round ) ); - mOffsetJoinStyleComboBox->addItem( tr( "Miter" ), static_cast< int >( Qgis::JoinStyle::Miter ) ); - mOffsetJoinStyleComboBox->addItem( tr( "Bevel" ), static_cast< int >( Qgis::JoinStyle::Bevel ) ); + mOffsetJoinStyleComboBox->addItem( tr( "Round" ), static_cast( Qgis::JoinStyle::Round ) ); + mOffsetJoinStyleComboBox->addItem( tr( "Miter" ), static_cast( Qgis::JoinStyle::Miter ) ); + mOffsetJoinStyleComboBox->addItem( tr( "Bevel" ), static_cast( Qgis::JoinStyle::Bevel ) ); Qgis::JoinStyle joinStyleSetting = QgsSettingsRegistryCore::settingsDigitizingOffsetJoinStyle->value(); - mOffsetJoinStyleComboBox->setCurrentIndex( mOffsetJoinStyleComboBox->findData( static_cast< int >( joinStyleSetting ) ) ); + mOffsetJoinStyleComboBox->setCurrentIndex( mOffsetJoinStyleComboBox->findData( static_cast( joinStyleSetting ) ) ); mOffsetQuadSegSpinBox->setValue( QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->value() ); mOffsetQuadSegSpinBox->setClearValue( QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->defaultValue() ); mCurveOffsetMiterLimitComboBox->setValue( QgsSettingsRegistryCore::settingsDigitizingOffsetMiterLimit->value() ); @@ -1204,7 +1196,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListaddWidget( mLocatorOptionsWidget ); mOptionsLocatorGroupBox->setLayout( locatorLayout ); - QList< QgsOptionsWidgetFactory *> factories = optionsFactories; + QList factories = optionsFactories; // ensure advanced factory is always last QgsAdvancedSettingsOptionsFactory advancedFactory; factories << &advancedFactory; @@ -1229,30 +1221,28 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetEnabled( true ); mOpenClDevicesCombo->clear(); - for ( const auto &dev : QgsOpenClUtils::devices( ) ) + for ( const auto &dev : QgsOpenClUtils::devices() ) { mOpenClDevicesCombo->addItem( QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Name, dev ), QgsOpenClUtils::deviceId( dev ) ); } // Info updater - std::function infoUpdater = [ = ]( int ) - { + std::function infoUpdater = [=]( int ) { mGPUInfoTextBrowser->setText( QgsOpenClUtils::deviceDescription( mOpenClDevicesCombo->currentData().toString() ) ); }; - connect( mOpenClDevicesCombo, qOverload< int >( &QComboBox::currentIndexChanged ), infoUpdater ); + connect( mOpenClDevicesCombo, qOverload( &QComboBox::currentIndexChanged ), infoUpdater ); mOpenClDevicesCombo->setCurrentIndex( mOpenClDevicesCombo->findData( QgsOpenClUtils::deviceId( QgsOpenClUtils::activeDevice() ) ) ); infoUpdater( -1 ); mOpenClContainerWidget->show(); @@ -1273,7 +1263,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListsetEnabled( false ); - mGPUEnableCheckBox->setChecked( QgsOpenClUtils::enabled( ) ); + mGPUEnableCheckBox->setChecked( QgsOpenClUtils::enabled() ); #else @@ -1288,7 +1278,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListinsertWidget( 0, noOpenCL ); #endif @@ -1319,14 +1310,13 @@ QgsOptions::~QgsOptions() void QgsOptions::checkPageWidgetNameMap() { - const QMap< QString, QString > pageNames = QgisApp::instance()->optionsPagesMap(); + const QMap pageNames = QgisApp::instance()->optionsPagesMap(); std::function traverseModel; // traverse through the model, collecting all entries which correspond to pages QStringList pageTitles; - traverseModel = [&]( const QModelIndex & parent ) - { + traverseModel = [&]( const QModelIndex &parent ) { for ( int row = 0; row < mTreeModel->rowCount( parent ); ++row ) { const QModelIndex currentIndex = mTreeModel->index( row, 0, parent ); @@ -1339,11 +1329,11 @@ void QgsOptions::checkPageWidgetNameMap() }; traverseModel( QModelIndex() ); - Q_ASSERT_X( pageNames.count() == pageTitles.count(), "QgsOptions::checkPageWidgetNameMap()", - QStringLiteral( "QgisApp::optionsPagesMap() is outdated, contains too many entries, " - " this is often a problem with missing translations for the entries (extra entries: %1)" ).arg( - qgsSetJoin( QSet( pageNames.keyBegin(), pageNames.keyEnd() ) - QSet( pageTitles.constBegin(), pageTitles.constEnd() ), - QStringLiteral( "," ) ) ).toLocal8Bit().constData() ); + Q_ASSERT_X( pageNames.count() == pageTitles.count(), "QgsOptions::checkPageWidgetNameMap()", QStringLiteral( "QgisApp::optionsPagesMap() is outdated, contains too many entries, " + " this is often a problem with missing translations for the entries (extra entries: %1)" ) + .arg( qgsSetJoin( QSet( pageNames.keyBegin(), pageNames.keyEnd() ) - QSet( pageTitles.constBegin(), pageTitles.constEnd() ), QStringLiteral( "," ) ) ) + .toLocal8Bit() + .constData() ); int page = 0; for ( const QString &pageTitle : std::as_const( pageTitles ) ) @@ -1396,7 +1386,7 @@ void QgsOptions::cbxProjectDefaultNew_toggled( bool checked ) if ( checked ) { QString fileName = QgsApplication::qgisSettingsDirPath() + QStringLiteral( "project_default.qgs" ); - if ( ! QFile::exists( fileName ) ) + if ( !QFile::exists( fileName ) ) { QMessageBox::information( nullptr, tr( "Save Default Project" ), tr( "You must set a default project" ) ); cbxProjectDefaultNew->setChecked( false ); @@ -1429,9 +1419,8 @@ void QgsOptions::resetProjectDefault() void QgsOptions::browseTemplateFolder() { - QString newDir = QFileDialog::getExistingDirectory( nullptr, tr( "Choose a directory to store project template files" ), - leTemplateFolder->text() ); - if ( ! newDir.isNull() ) + QString newDir = QFileDialog::getExistingDirectory( nullptr, tr( "Choose a directory to store project template files" ), leTemplateFolder->text() ); + if ( !newDir.isNull() ) { leTemplateFolder->setText( newDir ); } @@ -1468,10 +1457,7 @@ void QgsOptions::selectProjectOnLaunch() // Retrieve last used project dir from persistent settings QgsSettings settings; QString lastUsedDir = mSettings->value( QStringLiteral( "/UI/lastProjectDir" ), QDir::homePath() ).toString(); - QString projPath = QFileDialog::getOpenFileName( this, - tr( "Choose project file to open at launch" ), - lastUsedDir, - tr( "QGIS files" ) + " (*.qgs *.qgz *.QGS *.QGZ)" ); + QString projPath = QFileDialog::getOpenFileName( this, tr( "Choose project file to open at launch" ), lastUsedDir, tr( "QGIS files" ) + " (*.qgs *.qgz *.QGS *.QGZ)" ); if ( !projPath.isNull() ) { mProjectOnLaunchLineEdit->setText( projPath ); @@ -1570,13 +1556,13 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/defaultTileMaxRetry" ), mDefaultTileMaxRetrySpinBox->value() ); // Proxy stored authentication configurations - mSettings->setValue( QStringLiteral( "proxy/authcfg" ), mAuthSettings->configId( ) ); + mSettings->setValue( QStringLiteral( "proxy/authcfg" ), mAuthSettings->configId() ); //Web proxy settings mSettings->setValue( QStringLiteral( "proxy/proxyEnabled" ), grpProxy->isChecked() ); mSettings->setValue( QStringLiteral( "proxy/proxyHost" ), leProxyHost->text() ); mSettings->setValue( QStringLiteral( "proxy/proxyPort" ), leProxyPort->text() ); - mSettings->setValue( QStringLiteral( "proxy/proxyUser" ), mAuthSettings->username() ); + mSettings->setValue( QStringLiteral( "proxy/proxyUser" ), mAuthSettings->username() ); mSettings->setValue( QStringLiteral( "proxy/proxyPassword" ), mAuthSettings->password() ); mSettings->setValue( QStringLiteral( "proxy/proxyType" ), mProxyTypeComboBox->currentText() ); @@ -1616,15 +1602,13 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/checkVersion" ), cbxCheckVersion->isChecked() ); mSettings->setValue( QStringLiteral( "/qgis/dockAttributeTable" ), cbxAttributeTableDocked->isChecked() ); QgsSettingsRegistryCore::settingsAutosizeAttributeTable->setValue( cbxAutosizeAttributeTable->isChecked() ); - mSettings->setEnumValue( QStringLiteral( "/qgis/attributeTableBehavior" ), ( QgsAttributeTableFilterModel::FilterMode )cmbAttrTableBehavior->currentData().toInt() ); + mSettings->setEnumValue( QStringLiteral( "/qgis/attributeTableBehavior" ), ( QgsAttributeTableFilterModel::FilterMode ) cmbAttrTableBehavior->currentData().toInt() ); mSettings->setValue( QStringLiteral( "/qgis/attributeTableView" ), mAttrTableViewComboBox->currentData() ); mSettings->setValue( QStringLiteral( "/qgis/attributeTableRowCache" ), spinBoxAttrTableRowCache->value() ); - mSettings->setEnumValue( QStringLiteral( "/qgis/promptForSublayers" ), static_cast< Qgis::SublayerPromptMode >( cmbPromptSublayers->currentData().toInt() ) ); + mSettings->setEnumValue( QStringLiteral( "/qgis/promptForSublayers" ), static_cast( cmbPromptSublayers->currentData().toInt() ) ); - mSettings->setValue( QStringLiteral( "/qgis/scanItemsInBrowser2" ), - cmbScanItemsInBrowser->currentData().toString() ); - mSettings->setValue( QStringLiteral( "/qgis/scanZipInBrowser2" ), - cmbScanZipInBrowser->currentData().toString() ); + mSettings->setValue( QStringLiteral( "/qgis/scanItemsInBrowser2" ), cmbScanItemsInBrowser->currentData().toString() ); + mSettings->setValue( QStringLiteral( "/qgis/scanZipInBrowser2" ), cmbScanZipInBrowser->currentData().toString() ); mSettings->setValue( QStringLiteral( "/qgis/monitorDirectoriesInBrowser" ), mCheckMonitorDirectories->isChecked() ); mSettings->setValue( QStringLiteral( "/qgis/mainSnappingWidgetMode" ), mSnappingMainDialogComboBox->currentData() ); @@ -1638,7 +1622,7 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/mapTipsDelay" ), mMapTipsDelaySpinBox->value() ); QgsSettingsRegistryGui::settingsRespectScreenDPI->setValue( mRespectScreenDpiCheckBox->isChecked() ); - mSettings->setEnumValue( QStringLiteral( "/qgis/copyFeatureFormat" ), ( QgsClipboard::CopyFormat )mComboCopyFeatureFormat->currentData().toInt() ); + mSettings->setEnumValue( QStringLiteral( "/qgis/copyFeatureFormat" ), ( QgsClipboard::CopyFormat ) mComboCopyFeatureFormat->currentData().toInt() ); QgisApp::instance()->setMapTipsDelay( mMapTipsDelaySpinBox->value() ); mSettings->setValue( QStringLiteral( "/qgis/legendDoubleClickAction" ), cmbLegendDoubleClickAction->currentIndex() ); @@ -1651,8 +1635,7 @@ void QgsOptions::saveOptions() mSettings->setValue( QStringLiteral( "/qgis/askToSaveProjectChanges" ), chbAskToSaveProjectChanges->isChecked() ); mSettings->setValue( QStringLiteral( "qgis/askToDeleteLayers" ), mLayerDeleteConfirmationChkBx->isChecked() ); mSettings->setValue( QStringLiteral( "/qgis/warnOldProjectVersion" ), chbWarnOldProjectVersion->isChecked() ); - if ( ( mSettings->value( QStringLiteral( "/qgis/projectTemplateDir" ) ).toString() != leTemplateFolder->text() ) || - ( mSettings->value( QStringLiteral( "/qgis/newProjectDefault" ) ).toBool() != cbxProjectDefaultNew->isChecked() ) ) + if ( ( mSettings->value( QStringLiteral( "/qgis/projectTemplateDir" ) ).toString() != leTemplateFolder->text() ) || ( mSettings->value( QStringLiteral( "/qgis/newProjectDefault" ) ).toBool() != cbxProjectDefaultNew->isChecked() ) ) { mSettings->setValue( QStringLiteral( "/qgis/newProjectDefault" ), cbxProjectDefaultNew->isChecked() ); mSettings->setValue( QStringLiteral( "/qgis/projectTemplateDir" ), leTemplateFolder->text() ); @@ -1660,8 +1643,7 @@ void QgsOptions::saveOptions() } mSettings->setEnumValue( QStringLiteral( "/qgis/enablePythonEmbedded" ), mEnableMacrosComboBox->currentData().value() ); - mSettings->setValue( QStringLiteral( "/qgis/defaultProjectPathsRelative" ), - static_cast< Qgis::FilePathType >( mDefaultPathsComboBox->currentData().toInt() ) == Qgis::FilePathType::Relative ); + mSettings->setValue( QStringLiteral( "/qgis/defaultProjectPathsRelative" ), static_cast( mDefaultPathsComboBox->currentData().toInt() ) == Qgis::FilePathType::Relative ); mSettings->setEnumValue( QStringLiteral( "/qgis/defaultProjectFileFormat" ), mFileFormatQgsButton->isChecked() ? Qgis::ProjectFileFormat::Qgs : Qgis::ProjectFileFormat::Qgz ); @@ -1702,13 +1684,13 @@ void QgsOptions::saveOptions() //measurement settings mSettings->setValue( QStringLiteral( "measure/planimetric" ), mPlanimetricMeasurementsComboBox->isChecked(), QgsSettings::Core ); - Qgis::DistanceUnit distanceUnit = static_cast< Qgis::DistanceUnit >( mDistanceUnitsComboBox->currentData().toInt() ); + Qgis::DistanceUnit distanceUnit = static_cast( mDistanceUnitsComboBox->currentData().toInt() ); mSettings->setValue( QStringLiteral( "/qgis/measure/displayunits" ), QgsUnitTypes::encodeUnit( distanceUnit ) ); - Qgis::AreaUnit areaUnit = static_cast< Qgis::AreaUnit >( mAreaUnitsComboBox->currentData().toInt() ); + Qgis::AreaUnit areaUnit = static_cast( mAreaUnitsComboBox->currentData().toInt() ); mSettings->setValue( QStringLiteral( "/qgis/measure/areaunits" ), QgsUnitTypes::encodeUnit( areaUnit ) ); - Qgis::AngleUnit angleUnit = static_cast< Qgis::AngleUnit >( mAngleUnitsComboBox->currentData().toInt() ); + Qgis::AngleUnit angleUnit = static_cast( mAngleUnitsComboBox->currentData().toInt() ); mSettings->setValue( QStringLiteral( "/qgis/measure/angleunits" ), QgsUnitTypes::encodeUnit( angleUnit ) ); int decimalPlaces = mDecimalPlacesSpinBox->value(); @@ -1776,9 +1758,11 @@ void QgsOptions::saveOptions() QgsSettingsRegistryCore::settingsDigitizingDefaultSnappingTolerance->setValue( mDefaultSnappingToleranceSpinBox->value() ); QgsSettingsRegistryCore::settingsDigitizingSearchRadiusVertexEdit->setValue( mSearchRadiusVertexEditSpinBox->value() ); QgsSettingsRegistryCore::settingsDigitizingDefaultSnappingToleranceUnit->setValue( - ( mDefaultSnappingToleranceComboBox->currentIndex() == 0 ? Qgis::MapToolUnit::Project : Qgis::MapToolUnit::Pixels ) ); + ( mDefaultSnappingToleranceComboBox->currentIndex() == 0 ? Qgis::MapToolUnit::Project : Qgis::MapToolUnit::Pixels ) + ); QgsSettingsRegistryCore::settingsDigitizingSearchRadiusVertexEditUnit->setValue( - ( mSearchRadiusVertexEditComboBox->currentIndex() == 0 ? Qgis::MapToolUnit::Project : Qgis::MapToolUnit::Pixels ) ); + ( mSearchRadiusVertexEditComboBox->currentIndex() == 0 ? Qgis::MapToolUnit::Project : Qgis::MapToolUnit::Pixels ) + ); QgsSettingsRegistryCore::settingsDigitizingSnapColor->setValue( mSnappingMarkerColorButton->color() ); QgsSettingsRegistryCore::settingsDigitizingSnapTooltip->setValue( mSnappingTooltipsCheckbox->isChecked() ); @@ -1869,10 +1853,10 @@ void QgsOptions::saveOptions() // QgsApplication::settingsLocaleUserLocale->setValue( cboTranslation->currentData().toString() ); QgsApplication::settingsLocaleOverrideFlag->setValue( grpLocale->isChecked() ); - QgsApplication::settingsLocaleGlobalLocale->setValue( cboGlobalLocale->currentData( ).toString() ); + QgsApplication::settingsLocaleGlobalLocale->setValue( cboGlobalLocale->currentData().toString() ); // Number settings - QgsApplication::settingsLocaleShowGroupSeparator->setValue( cbShowGroupSeparator->isChecked( ) ); + QgsApplication::settingsLocaleShowGroupSeparator->setValue( cbShowGroupSeparator->isChecked() ); QgsLocalDefaultSettings::setBearingFormat( mBearingFormat.get() ); QgsLocalDefaultSettings::setGeographicCoordinateFormat( mCoordinateFormat.get() ); @@ -1964,8 +1948,7 @@ void QgsOptions::editGdalDriver( const QString &driverName ) dlg.setWindowTitle( title ); if ( driverName == QLatin1String( "_pyramids" ) ) { - QgsRasterPyramidsOptionsWidget *optionsWidget = - new QgsRasterPyramidsOptionsWidget( &dlg, QStringLiteral( "gdal" ) ); + QgsRasterPyramidsOptionsWidget *optionsWidget = new QgsRasterPyramidsOptionsWidget( &dlg, QStringLiteral( "gdal" ) ); layout->addWidget( optionsWidget ); dlg.resize( 400, 400 ); if ( dlg.exec() == QDialog::Accepted ) @@ -1973,14 +1956,11 @@ void QgsOptions::editGdalDriver( const QString &driverName ) } else { - QgsRasterFormatSaveOptionsWidget *optionsWidget = - new QgsRasterFormatSaveOptionsWidget( &dlg, driverName, - QgsRasterFormatSaveOptionsWidget::Full, QStringLiteral( "gdal" ) ); + QgsRasterFormatSaveOptionsWidget *optionsWidget = new QgsRasterFormatSaveOptionsWidget( &dlg, driverName, QgsRasterFormatSaveOptionsWidget::Full, QStringLiteral( "gdal" ) ); layout->addWidget( optionsWidget ); if ( dlg.exec() == QDialog::Accepted ) optionsWidget->apply(); } - } QStringList QgsOptions::i18nList() @@ -1995,7 +1975,8 @@ QStringList QgsOptions::i18nList() QString myFileName = myIterator.next(); // Ignore the 'en' translation file, already added as 'en_US'. - if ( myFileName.compare( QLatin1String( "qgis_en.qm" ) ) == 0 ) continue; + if ( myFileName.compare( QLatin1String( "qgis_en.qm" ) ) == 0 ) + continue; myList << myFileName.remove( QStringLiteral( "qgis_" ) ).remove( QStringLiteral( ".qm" ) ); } @@ -2089,13 +2070,13 @@ void QgsOptions::mCurrentVariablesQGISChxBx_toggled( bool qgisSpecific ) void QgsOptions::addPluginPath() { QString myDir = QFileDialog::getExistingDirectory( - this, - tr( "Choose a directory" ), - QDir::toNativeSeparators( QDir::homePath() ), - QFileDialog::Options() - ); + this, + tr( "Choose a directory" ), + QDir::toNativeSeparators( QDir::homePath() ), + QFileDialog::Options() + ); - if ( ! myDir.isEmpty() ) + if ( !myDir.isEmpty() ) { QListWidgetItem *newItem = new QListWidgetItem( mListPluginPaths ); newItem->setText( myDir ); @@ -2157,7 +2138,7 @@ void QgsOptions::moveHelpPathDown() for ( ; itemIt != selectedItems.end(); ++itemIt ) { int currentIndex = mHelpPathTreeWidget->indexOfTopLevelItem( *itemIt ); - if ( currentIndex < mHelpPathTreeWidget->topLevelItemCount() - 1 ) + if ( currentIndex < mHelpPathTreeWidget->topLevelItemCount() - 1 ) { mHelpPathTreeWidget->takeTopLevelItem( currentIndex ); mHelpPathTreeWidget->insertTopLevelItem( currentIndex + 1, *itemIt ); @@ -2169,13 +2150,13 @@ void QgsOptions::moveHelpPathDown() void QgsOptions::addTemplatePath() { QString myDir = QFileDialog::getExistingDirectory( - this, - tr( "Choose a directory" ), - QDir::toNativeSeparators( QDir::homePath() ), - QFileDialog::Options() - ); + this, + tr( "Choose a directory" ), + QDir::toNativeSeparators( QDir::homePath() ), + QFileDialog::Options() + ); - if ( ! myDir.isEmpty() ) + if ( !myDir.isEmpty() ) { QListWidgetItem *newItem = new QListWidgetItem( mListComposerTemplatePaths ); newItem->setText( myDir ); @@ -2196,13 +2177,13 @@ void QgsOptions::removeTemplatePath() void QgsOptions::addSVGPath() { QString myDir = QFileDialog::getExistingDirectory( - this, - tr( "Choose a directory" ), - QDir::toNativeSeparators( QDir::homePath() ), - QFileDialog::Options() - ); + this, + tr( "Choose a directory" ), + QDir::toNativeSeparators( QDir::homePath() ), + QFileDialog::Options() + ); - if ( ! myDir.isEmpty() ) + if ( !myDir.isEmpty() ) { QListWidgetItem *newItem = new QListWidgetItem( mListSVGPaths ); newItem->setText( myDir ); @@ -2245,17 +2226,16 @@ void QgsOptions::removeNoProxyUrl() void QgsOptions::browseCacheDirectory() { QString myDir = QFileDialog::getExistingDirectory( - this, - tr( "Choose a directory" ), - QDir::toNativeSeparators( mCacheDirectory->text() ), - QFileDialog::Options() - ); + this, + tr( "Choose a directory" ), + QDir::toNativeSeparators( mCacheDirectory->text() ), + QFileDialog::Options() + ); if ( !myDir.isEmpty() ) { mCacheDirectory->setText( QDir::toNativeSeparators( myDir ) ); } - } void QgsOptions::clearCache() @@ -2291,7 +2271,7 @@ void QgsOptions::optionsStackedWidget_CurrentChanged( int index ) Q_UNUSED( index ) // load gdal driver list when gdal tab is first opened if ( mOptionsStackedWidget->currentWidget()->objectName() == QLatin1String( "mOptionsPageGDAL" ) - && ! mLoadedGdalDriverList ) + && !mLoadedGdalDriverList ) { loadGdalDriverList(); } @@ -2309,7 +2289,7 @@ void QgsOptions::loadGdalDriverList() QMap rasterDriversFlags; QMap vectorDriversFlags; QMap myDriversExt, myDriversLongName; - QMap> driversType; + QMap> driversType; // make sure we save list when accept() mLoadedGdalDriverList = true; @@ -2336,17 +2316,17 @@ void QgsOptions::loadGdalDriverList() myDrivers << myGdalDriverDescription; if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_RASTER, nullptr ) ) == QLatin1String( "YES" ) ) { - driversType[myGdalDriverDescription].insert( static_cast< int >( Qgis::LayerType::Raster ) ); + driversType[myGdalDriverDescription].insert( static_cast( Qgis::LayerType::Raster ) ); } if ( QString( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_VECTOR, nullptr ) ) == QLatin1String( "YES" ) ) { - driversType[myGdalDriverDescription].insert( static_cast< int >( Qgis::LayerType::Vector ) ); + driversType[myGdalDriverDescription].insert( static_cast( Qgis::LayerType::Vector ) ); } QgsDebugMsgLevel( QStringLiteral( "driver #%1 - %2" ).arg( i ).arg( myGdalDriverDescription ), 2 ); // get driver R/W flags, adopted from GDALGeneralCmdLineProcessor() - if ( driversType.value( myGdalDriverDescription ).contains( static_cast< int >( Qgis::LayerType::Raster ) ) ) + if ( driversType.value( myGdalDriverDescription ).contains( static_cast( Qgis::LayerType::Raster ) ) ) { QString driverFlags = ""; if ( QgsGdalUtils::supportsRasterCreate( myGdalDriver ) ) @@ -2354,8 +2334,7 @@ void QgsOptions::loadGdalDriverList() myGdalWriteDrivers << myGdalDriverDescription; driverFlags = "rw+"; } - else if ( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_CREATECOPY, - nullptr ) ) + else if ( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_CREATECOPY, nullptr ) ) driverFlags = "rw"; else driverFlags = "ro"; @@ -2365,7 +2344,7 @@ void QgsOptions::loadGdalDriverList() rasterDriversFlags[myGdalDriverDescription] = driverFlags; } - if ( driversType.value( myGdalDriverDescription ).contains( static_cast< int >( Qgis::LayerType::Vector ) ) ) + if ( driversType.value( myGdalDriverDescription ).contains( static_cast( Qgis::LayerType::Vector ) ) ) { QString driverFlags = ""; if ( GDALGetMetadataItem( myGdalDriver, GDAL_DCAP_OPEN, nullptr ) ) @@ -2405,7 +2384,7 @@ void QgsOptions::loadGdalDriverList() for ( const QString &driverName : std::as_const( myDrivers ) ) { - const QSet< int > layerTypes = driversType[driverName]; + const QSet layerTypes = driversType[driverName]; for ( int layerType : layerTypes ) { QTreeWidgetItem *driverItem = new QTreeWidgetItem( QStringList( driverName ) ); @@ -2421,10 +2400,10 @@ void QgsOptions::loadGdalDriverList() // add driver metadata driverItem->setData( 0, Qt::UserRole, driverName ); driverItem->setText( 1, myDriversExt[driverName] ); - const QString driverFlags = static_cast< Qgis::LayerType >( layerType ) == Qgis::LayerType::Raster ? rasterDriversFlags[driverName] : vectorDriversFlags[driverName]; + const QString driverFlags = static_cast( layerType ) == Qgis::LayerType::Raster ? rasterDriversFlags[driverName] : vectorDriversFlags[driverName]; driverItem->setText( 2, driverFlags ); driverItem->setText( 3, myDriversLongName[driverName] ); - if ( static_cast< Qgis::LayerType >( layerType ) == Qgis::LayerType::Raster ) + if ( static_cast( layerType ) == Qgis::LayerType::Raster ) { lstRasterDrivers->addTopLevelItem( driverItem ); } @@ -2457,7 +2436,6 @@ void QgsOptions::loadGdalDriverList() { cmbEditCreateOptions->addItem( myName ); } - } void QgsOptions::saveGdalDriverList() @@ -2467,14 +2445,12 @@ void QgsOptions::saveGdalDriverList() auto deferredSkippedGdalDrivers = QgsApplication::deferredSkippedGdalDrivers(); QStringList skippedGdalDrivers; - auto checkDriver = [ & ]( QTreeWidgetItem * item ) - { + auto checkDriver = [&]( QTreeWidgetItem *item ) { const auto &driverName( item->text( 0 ) ); if ( item->checkState( 0 ) == Qt::Unchecked ) { skippedGdalDrivers << driverName; - if ( !deferredSkippedGdalDrivers.contains( driverName ) && - !oldSkippedGdalDrivers.contains( driverName ) ) + if ( !deferredSkippedGdalDrivers.contains( driverName ) && !oldSkippedGdalDrivers.contains( driverName ) ) { deferredSkippedGdalDrivers << driverName; driverUnregisterNeeded = true; @@ -2503,8 +2479,7 @@ void QgsOptions::saveGdalDriverList() if ( driverUnregisterNeeded ) { - QMessageBox::information( this, tr( "Drivers Disabled" ), - tr( "One or more drivers have been disabled. This will only take effect after QGIS is restarted." ) ); + QMessageBox::information( this, tr( "Drivers Disabled" ), tr( "One or more drivers have been disabled. This will only take effect after QGIS is restarted." ) ); } QgsApplication::setSkippedGdalDrivers( skippedGdalDrivers, deferredSkippedGdalDrivers ); } @@ -2512,12 +2487,12 @@ void QgsOptions::saveGdalDriverList() void QgsOptions::addScale() { int myScale = QInputDialog::getInt( - this, - tr( "Enter scale" ), - tr( "Scale denominator" ), - -1, - 1 - ); + this, + tr( "Enter scale" ), + tr( "Scale denominator" ), + -1, + 1 + ); if ( myScale != -1 ) { @@ -2547,8 +2522,7 @@ void QgsOptions::restoreDefaultScaleValues() void QgsOptions::importScales() { - QString fileName = QFileDialog::getOpenFileName( this, tr( "Load scales" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + QString fileName = QFileDialog::getOpenFileName( this, tr( "Load scales" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -2570,8 +2544,7 @@ void QgsOptions::importScales() void QgsOptions::exportScales() { - QString fileName = QFileDialog::getSaveFileName( this, tr( "Save scales" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "Save scales" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -2617,13 +2590,13 @@ void QgsOptions::removeLocalizedDataPath() void QgsOptions::addLocalizedDataPath() { QString myDir = QFileDialog::getExistingDirectory( - this, - tr( "Choose a Directory" ), - QDir::homePath(), - QFileDialog::Options() - ); + this, + tr( "Choose a Directory" ), + QDir::homePath(), + QFileDialog::Options() + ); - if ( ! myDir.isEmpty() ) + if ( !myDir.isEmpty() ) { QListWidgetItem *newItem = new QListWidgetItem( mLocalizedDataPathListWidget ); newItem->setText( myDir ); @@ -2713,8 +2686,8 @@ void QgsOptions::refreshSchemeComboBox() void QgsOptions::updateSampleLocaleText() { - QLocale locale( cboGlobalLocale->currentData( ).toString() ); - if ( cbShowGroupSeparator->isChecked( ) ) + QLocale locale( cboGlobalLocale->currentData().toString() ); + if ( cbShowGroupSeparator->isChecked() ) { locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator ); } @@ -2722,11 +2695,7 @@ void QgsOptions::updateSampleLocaleText() { locale.setNumberOptions( locale.numberOptions() |= QLocale::NumberOption::OmitGroupSeparator ); } - lblLocaleSample->setText( tr( "Sample date: %1 money: %2 int: %3 float: %4" ).arg( - QDate::currentDate().toString( locale.dateFormat( QLocale::FormatType::ShortFormat ) ), - locale.toCurrencyString( 1000.00 ), - locale.toString( 1000 ), - locale.toString( 1000.00, 'f', 2 ) ) ); + lblLocaleSample->setText( tr( "Sample date: %1 money: %2 int: %3 float: %4" ).arg( QDate::currentDate().toString( locale.dateFormat( QLocale::FormatType::ShortFormat ) ), locale.toCurrencyString( 1000.00 ), locale.toString( 1000 ), locale.toString( 1000.00, 'f', 2 ) ) ); } void QgsOptions::updateActionsForCurrentColorScheme( QgsColorScheme *scheme ) @@ -2740,7 +2709,7 @@ void QgsOptions::updateActionsForCurrentColorScheme( QgsColorScheme *scheme ) mButtonRemoveColor->setEnabled( scheme->isEditable() ); QgsUserColorScheme *userScheme = dynamic_cast( scheme ); - mActionRemovePalette->setEnabled( static_cast< bool >( userScheme ) && userScheme->isEditable() ); + mActionRemovePalette->setEnabled( static_cast( userScheme ) && userScheme->isEditable() ); if ( userScheme ) { mActionShowInButtons->setEnabled( true ); diff --git a/src/app/options/qgsoptions.h b/src/app/options/qgsoptions.h index 95fb046511de..a1112d06aedf 100644 --- a/src/app/options/qgsoptions.h +++ b/src/app/options/qgsoptions.h @@ -45,17 +45,16 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption { Q_OBJECT public: - /** * Behavior to use when encountering a layer with an unknown CRS * \since QGIS 3.10 */ enum UnknownLayerCrsBehavior { - NoAction = 0, //!< Take no action and leave as unknown CRS + NoAction = 0, //!< Take no action and leave as unknown CRS PromptUserForCrs = 1, //!< User is prompted for a CRS choice - UseProjectCrs = 2, //!< Copy the current project's CRS - UseDefaultCrs = 3, //!< Use the default layer CRS set via QGIS options + UseProjectCrs = 2, //!< Copy the current project's CRS + UseDefaultCrs = 3, //!< Use the default layer CRS set via QGIS options }; Q_ENUM( UnknownLayerCrsBehavior ) @@ -67,8 +66,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption * \param modal TRUE for modal dialog * \param optionsFactories factories for additional option pages */ - QgsOptions( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, - const QList &optionsFactories = QList() ); + QgsOptions( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, const QList &optionsFactories = QList() ); ~QgsOptions() override; @@ -285,12 +283,11 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption static const int PALETTE_LABEL_ROLE = Qt::UserRole + 2; private: - - QList< QgsOptionsPageWidget * > mAdditionalOptionWidgets; + QList mAdditionalOptionWidgets; QgsLocatorOptionsWidget *mLocatorOptionsWidget = nullptr; - std::unique_ptr< QgsBearingNumericFormat > mBearingFormat; - std::unique_ptr< QgsGeographicCoordinateNumericFormat > mCoordinateFormat; + std::unique_ptr mBearingFormat; + std::unique_ptr mCoordinateFormat; QStandardItemModel *mTreeModel = nullptr; diff --git a/src/app/options/qgsoptionsutils.cpp b/src/app/options/qgsoptionsutils.cpp index 146f58639876..09352972c8df 100644 --- a/src/app/options/qgsoptionsutils.cpp +++ b/src/app/options/qgsoptionsutils.cpp @@ -18,7 +18,7 @@ #include "qgis.h" #include "qgsoptionswidgetfactory.h" -QgsScopedOptionsWidgetFactory::QgsScopedOptionsWidgetFactory( std::unique_ptr< QgsOptionsWidgetFactory > &&factory ) +QgsScopedOptionsWidgetFactory::QgsScopedOptionsWidgetFactory( std::unique_ptr &&factory ) { reset( std::move( factory ) ); } @@ -26,7 +26,6 @@ QgsScopedOptionsWidgetFactory::QgsScopedOptionsWidgetFactory( std::unique_ptr< Q QgsScopedOptionsWidgetFactory::QgsScopedOptionsWidgetFactory( QgsScopedOptionsWidgetFactory &&other ) : mFactory( std::move( other.mFactory ) ) { - } QgsScopedOptionsWidgetFactory::~QgsScopedOptionsWidgetFactory() diff --git a/src/app/options/qgsoptionsutils.h b/src/app/options/qgsoptionsutils.h index 249e6797c3cf..63f2887bc248 100644 --- a/src/app/options/qgsoptionsutils.h +++ b/src/app/options/qgsoptionsutils.h @@ -29,15 +29,15 @@ class QgsOptionsWidgetFactory; class QgsScopedOptionsWidgetFactory { public: - QgsScopedOptionsWidgetFactory( std::unique_ptr< QgsOptionsWidgetFactory > &&factory ); + QgsScopedOptionsWidgetFactory( std::unique_ptr &&factory ); QgsScopedOptionsWidgetFactory( QgsScopedOptionsWidgetFactory &&other ); ~QgsScopedOptionsWidgetFactory(); - void reset( std::unique_ptr< QgsOptionsWidgetFactory > factory = nullptr ); + void reset( std::unique_ptr factory = nullptr ); private: - std::unique_ptr< QgsOptionsWidgetFactory > mFactory; + std::unique_ptr mFactory; }; diff --git a/src/app/options/qgsrasterrenderingoptions.cpp b/src/app/options/qgsrasterrenderingoptions.cpp index ffccac550f94..75b86a203921 100644 --- a/src/app/options/qgsrasterrenderingoptions.cpp +++ b/src/app/options/qgsrasterrenderingoptions.cpp @@ -56,19 +56,13 @@ QgsRasterRenderingOptionsWidget::QgsRasterRenderingOptionsWidget( QWidget *paren spnOversampling->setClearValue( 2.0 ); mCbEarlyResampling->setChecked( QgsRasterLayer::settingsRasterDefaultEarlyResampling->value() ); - initContrastEnhancement( cboxContrastEnhancementAlgorithmSingleBand, QStringLiteral( "singleBand" ), - QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsRasterLayer::SINGLE_BAND_ENHANCEMENT_ALGORITHM ) ); - initContrastEnhancement( cboxContrastEnhancementAlgorithmMultiBandSingleByte, QStringLiteral( "multiBandSingleByte" ), - QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsRasterLayer::MULTIPLE_BAND_SINGLE_BYTE_ENHANCEMENT_ALGORITHM ) ); - initContrastEnhancement( cboxContrastEnhancementAlgorithmMultiBandMultiByte, QStringLiteral( "multiBandMultiByte" ), - QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsRasterLayer::MULTIPLE_BAND_MULTI_BYTE_ENHANCEMENT_ALGORITHM ) ); - - initMinMaxLimits( cboxContrastEnhancementLimitsSingleBand, QStringLiteral( "singleBand" ), - QgsRasterMinMaxOrigin::limitsString( QgsRasterLayer::SINGLE_BAND_MIN_MAX_LIMITS ) ); - initMinMaxLimits( cboxContrastEnhancementLimitsMultiBandSingleByte, QStringLiteral( "multiBandSingleByte" ), - QgsRasterMinMaxOrigin::limitsString( QgsRasterLayer::MULTIPLE_BAND_SINGLE_BYTE_MIN_MAX_LIMITS ) ); - initMinMaxLimits( cboxContrastEnhancementLimitsMultiBandMultiByte, QStringLiteral( "multiBandMultiByte" ), - QgsRasterMinMaxOrigin::limitsString( QgsRasterLayer::MULTIPLE_BAND_MULTI_BYTE_MIN_MAX_LIMITS ) ); + initContrastEnhancement( cboxContrastEnhancementAlgorithmSingleBand, QStringLiteral( "singleBand" ), QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsRasterLayer::SINGLE_BAND_ENHANCEMENT_ALGORITHM ) ); + initContrastEnhancement( cboxContrastEnhancementAlgorithmMultiBandSingleByte, QStringLiteral( "multiBandSingleByte" ), QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsRasterLayer::MULTIPLE_BAND_SINGLE_BYTE_ENHANCEMENT_ALGORITHM ) ); + initContrastEnhancement( cboxContrastEnhancementAlgorithmMultiBandMultiByte, QStringLiteral( "multiBandMultiByte" ), QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsRasterLayer::MULTIPLE_BAND_MULTI_BYTE_ENHANCEMENT_ALGORITHM ) ); + + initMinMaxLimits( cboxContrastEnhancementLimitsSingleBand, QStringLiteral( "singleBand" ), QgsRasterMinMaxOrigin::limitsString( QgsRasterLayer::SINGLE_BAND_MIN_MAX_LIMITS ) ); + initMinMaxLimits( cboxContrastEnhancementLimitsMultiBandSingleByte, QStringLiteral( "multiBandSingleByte" ), QgsRasterMinMaxOrigin::limitsString( QgsRasterLayer::MULTIPLE_BAND_SINGLE_BYTE_MIN_MAX_LIMITS ) ); + initMinMaxLimits( cboxContrastEnhancementLimitsMultiBandMultiByte, QStringLiteral( "multiBandMultiByte" ), QgsRasterMinMaxOrigin::limitsString( QgsRasterLayer::MULTIPLE_BAND_MULTI_BYTE_MIN_MAX_LIMITS ) ); mRasterCumulativeCutLowerDoubleSpinBox->setValue( 100.0 * settings.value( QStringLiteral( "/Raster/cumulativeCutLower" ), QString::number( QgsRasterMinMaxOrigin::CUMULATIVE_CUT_LOWER ) ).toDouble() ); mRasterCumulativeCutLowerDoubleSpinBox->setClearValue( QgsRasterMinMaxOrigin::CUMULATIVE_CUT_LOWER * 100 ); @@ -117,14 +111,10 @@ void QgsRasterRenderingOptionsWidget::initContrastEnhancement( QComboBox *cbox, QgsSettings settings; //add items to the color enhanceContrast combo boxes - cbox->addItem( tr( "No Stretch" ), - QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::NoEnhancement ) ); - cbox->addItem( tr( "Stretch to MinMax" ), - QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::StretchToMinimumMaximum ) ); - cbox->addItem( tr( "Stretch and Clip to MinMax" ), - QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::StretchAndClipToMinimumMaximum ) ); - cbox->addItem( tr( "Clip to MinMax" ), - QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::ClipToMinimumMaximum ) ); + cbox->addItem( tr( "No Stretch" ), QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::NoEnhancement ) ); + cbox->addItem( tr( "Stretch to MinMax" ), QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::StretchToMinimumMaximum ) ); + cbox->addItem( tr( "Stretch and Clip to MinMax" ), QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::StretchAndClipToMinimumMaximum ) ); + cbox->addItem( tr( "Clip to MinMax" ), QgsContrastEnhancement::contrastEnhancementAlgorithmString( QgsContrastEnhancement::ClipToMinimumMaximum ) ); QString contrastEnhancement = settings.value( "/Raster/defaultContrastEnhancementAlgorithm/" + name, defaultVal ).toString(); cbox->setCurrentIndex( cbox->findData( contrastEnhancement ) ); @@ -142,12 +132,9 @@ void QgsRasterRenderingOptionsWidget::initMinMaxLimits( QComboBox *cbox, const Q QgsSettings settings; //add items to the color limitsContrast combo boxes - cbox->addItem( tr( "Cumulative Pixel Count Cut" ), - QgsRasterMinMaxOrigin::limitsString( Qgis::RasterRangeLimit::CumulativeCut ) ); - cbox->addItem( tr( "Minimum / Maximum" ), - QgsRasterMinMaxOrigin::limitsString( Qgis::RasterRangeLimit::MinimumMaximum ) ); - cbox->addItem( tr( "Mean +/- Standard Deviation" ), - QgsRasterMinMaxOrigin::limitsString( Qgis::RasterRangeLimit::StdDev ) ); + cbox->addItem( tr( "Cumulative Pixel Count Cut" ), QgsRasterMinMaxOrigin::limitsString( Qgis::RasterRangeLimit::CumulativeCut ) ); + cbox->addItem( tr( "Minimum / Maximum" ), QgsRasterMinMaxOrigin::limitsString( Qgis::RasterRangeLimit::MinimumMaximum ) ); + cbox->addItem( tr( "Mean +/- Standard Deviation" ), QgsRasterMinMaxOrigin::limitsString( Qgis::RasterRangeLimit::StdDev ) ); QString contrastLimits = settings.value( "/Raster/defaultContrastEnhancementLimits/" + name, defaultVal ).toString(); cbox->setCurrentIndex( cbox->findData( contrastLimits ) ); @@ -167,7 +154,6 @@ void QgsRasterRenderingOptionsWidget::saveMinMaxLimits( QComboBox *cbox, const Q QgsRasterRenderingOptionsFactory::QgsRasterRenderingOptionsFactory() : QgsOptionsWidgetFactory( tr( "Raster" ), QIcon(), QStringLiteral( "raster" ) ) { - } QIcon QgsRasterRenderingOptionsFactory::icon() const @@ -182,5 +168,5 @@ QgsOptionsPageWidget *QgsRasterRenderingOptionsFactory::createWidget( QWidget *p QStringList QgsRasterRenderingOptionsFactory::path() const { - return {QStringLiteral( "rendering" ) }; + return { QStringLiteral( "rendering" ) }; } diff --git a/src/app/options/qgsrasterrenderingoptions.h b/src/app/options/qgsrasterrenderingoptions.h index 63a57b166760..674a3b995b23 100644 --- a/src/app/options/qgsrasterrenderingoptions.h +++ b/src/app/options/qgsrasterrenderingoptions.h @@ -23,16 +23,15 @@ class QgsRasterRenderingOptionsWidget : public QgsOptionsPageWidget, private Ui: Q_OBJECT public: - QgsRasterRenderingOptionsWidget( QWidget *parent ); QString helpKey() const override; void apply() override; + private: void initContrastEnhancement( QComboBox *cbox, const QString &name, const QString &defaultVal ); void saveContrastEnhancement( QComboBox *cbox, const QString &name ); void initMinMaxLimits( QComboBox *cbox, const QString &name, const QString &defaultVal ); void saveMinMaxLimits( QComboBox *cbox, const QString &name ); - }; @@ -41,13 +40,11 @@ class QgsRasterRenderingOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsRasterRenderingOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QStringList path() const override; - }; #endif // QGSRASTERRENDERINGOPTIONS_H diff --git a/src/app/options/qgsrenderingoptions.cpp b/src/app/options/qgsrenderingoptions.cpp index dfa9bf99b7ee..de4d1eed297b 100644 --- a/src/app/options/qgsrenderingoptions.cpp +++ b/src/app/options/qgsrenderingoptions.cpp @@ -83,7 +83,7 @@ void QgsRenderingOptionsWidget::apply() // QgsRenderingOptionsFactory // QgsRenderingOptionsFactory::QgsRenderingOptionsFactory() - : QgsOptionsWidgetFactory( tr( "Rendering" ), QIcon(), QStringLiteral( "rendering" ) ) + : QgsOptionsWidgetFactory( tr( "Rendering" ), QIcon(), QStringLiteral( "rendering" ) ) { } diff --git a/src/app/options/qgsrenderingoptions.h b/src/app/options/qgsrenderingoptions.h index 2bf5f74bcd62..59d56ee23bc7 100644 --- a/src/app/options/qgsrenderingoptions.h +++ b/src/app/options/qgsrenderingoptions.h @@ -26,7 +26,6 @@ class QgsRenderingOptionsWidget : public QgsOptionsPageWidget, private Ui::QgsRe Q_OBJECT public: - QgsRenderingOptionsWidget( QWidget *parent ); QString helpKey() const override; void apply() override; @@ -38,14 +37,11 @@ class QgsRenderingOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsRenderingOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QString pagePositionHint() const override; - - }; diff --git a/src/app/options/qgsuserprofileoptions.cpp b/src/app/options/qgsuserprofileoptions.cpp index 95dfbb25ad4e..68087c8ef8ff 100644 --- a/src/app/options/qgsuserprofileoptions.cpp +++ b/src/app/options/qgsuserprofileoptions.cpp @@ -43,8 +43,7 @@ QgsUserProfileOptionsWidget::QgsUserProfileOptionsWidget( QWidget *parent ) // Connect icon size and allow profile creation mIconSize->setCurrentText( QString::number( manager->settings()->value( QStringLiteral( "/selector/iconSize" ), 24 ).toInt() ) ); - connect( mIconSize, &QComboBox::currentTextChanged, this, [manager]( const QString & text ) - { + connect( mIconSize, &QComboBox::currentTextChanged, this, [manager]( const QString &text ) { manager->settings()->setValue( QStringLiteral( "/selector/iconSize" ), text.toInt() ); manager->settings()->sync(); } ); @@ -153,7 +152,6 @@ void QgsUserProfileOptionsWidget::onAskUserChanged() QgsUserProfileOptionsFactory::QgsUserProfileOptionsFactory() : QgsOptionsWidgetFactory( tr( "User Profiles" ), QgsApplication::getThemeIcon( QStringLiteral( "/user.svg" ) ) ) { - } QgsOptionsPageWidget *QgsUserProfileOptionsFactory::createWidget( QWidget *parent ) const diff --git a/src/app/options/qgsuserprofileoptions.h b/src/app/options/qgsuserprofileoptions.h index 75a994d47400..fa556f10cc90 100644 --- a/src/app/options/qgsuserprofileoptions.h +++ b/src/app/options/qgsuserprofileoptions.h @@ -31,7 +31,6 @@ class APP_EXPORT QgsUserProfileOptionsWidget : public QgsOptionsPageWidget, priv Q_OBJECT public: - //! Constructor for QgsUserProfileOptionsWidget with the specified \a parent widget. QgsUserProfileOptionsWidget( QWidget *parent ); QString helpKey() const override; @@ -55,12 +54,10 @@ class QgsUserProfileOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsUserProfileOptionsFactory(); QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QString pagePositionHint() const override; - }; diff --git a/src/app/options/qgsuserprofileselectiondialog.cpp b/src/app/options/qgsuserprofileselectiondialog.cpp index 7c54d8d0c1c6..20617230da3d 100644 --- a/src/app/options/qgsuserprofileselectiondialog.cpp +++ b/src/app/options/qgsuserprofileselectiondialog.cpp @@ -42,7 +42,7 @@ QgsUserProfileSelectionDialog::QgsUserProfileSelectionDialog( QgsUserProfileMana mProfileListWidget->setIconSize( QSize( iconSize, iconSize ) ); // Fill the list of profiles - mProfileListWidget->clear(); // Clear bogus profiles in the Ui form + mProfileListWidget->clear(); // Clear bogus profiles in the Ui form for ( auto profile : mManager->allProfiles() ) { auto item = new QListWidgetItem( mManager->profileForName( profile )->icon(), profile ); diff --git a/src/app/options/qgsuserprofileselectiondialog.h b/src/app/options/qgsuserprofileselectiondialog.h index c7ee94ff4af5..875577d10e4b 100644 --- a/src/app/options/qgsuserprofileselectiondialog.h +++ b/src/app/options/qgsuserprofileselectiondialog.h @@ -36,7 +36,6 @@ class APP_EXPORT QgsUserProfileSelectionDialog : public QDialog, private Ui::Qgs Q_OBJECT public: - /** * Constructor for QgsUserProfileSelectionDialog. * \param manager QgsUserProfileManager manager that will be used to fill the list of profiles @@ -57,8 +56,6 @@ class APP_EXPORT QgsUserProfileSelectionDialog : public QDialog, private Ui::Qgs private: QgsUserProfileManager *mManager = nullptr; - - }; #endif // QGSUSERPROFILESELECTIONDIALOG_H diff --git a/src/app/options/qgsvectorrenderingoptions.cpp b/src/app/options/qgsvectorrenderingoptions.cpp index 547e05568e56..7577cc92a90f 100644 --- a/src/app/options/qgsvectorrenderingoptions.cpp +++ b/src/app/options/qgsvectorrenderingoptions.cpp @@ -92,7 +92,7 @@ void QgsVectorRenderingOptionsWidget::apply() QgsVectorLayer::settingsSimplifyMaxScale->setValue( mSimplifyMaximumScaleComboBox->scale() ); //curve segmentation - QgsAbstractGeometry::SegmentationToleranceType segmentationType = ( QgsAbstractGeometry::SegmentationToleranceType )mToleranceTypeComboBox->currentData().toInt(); + QgsAbstractGeometry::SegmentationToleranceType segmentationType = ( QgsAbstractGeometry::SegmentationToleranceType ) mToleranceTypeComboBox->currentData().toInt(); settings.setEnumValue( QStringLiteral( "/qgis/segmentationToleranceType" ), segmentationType ); double segmentationTolerance = mSegmentationToleranceSpinBox->value(); if ( segmentationType == QgsAbstractGeometry::MaximumAngle ) @@ -100,7 +100,6 @@ void QgsVectorRenderingOptionsWidget::apply() segmentationTolerance = segmentationTolerance / 180.0 * M_PI; //user sets angle tolerance in degrees, internal classes need value in rad } settings.setValue( QStringLiteral( "/qgis/segmentationTolerance" ), segmentationTolerance ); - } @@ -110,7 +109,6 @@ void QgsVectorRenderingOptionsWidget::apply() QgsVectorRenderingOptionsFactory::QgsVectorRenderingOptionsFactory() : QgsOptionsWidgetFactory( tr( "Vector" ), QIcon(), QStringLiteral( "vector" ) ) { - } QIcon QgsVectorRenderingOptionsFactory::icon() const @@ -125,5 +123,5 @@ QgsOptionsPageWidget *QgsVectorRenderingOptionsFactory::createWidget( QWidget *p QStringList QgsVectorRenderingOptionsFactory::path() const { - return {QStringLiteral( "rendering" ) }; + return { QStringLiteral( "rendering" ) }; } diff --git a/src/app/options/qgsvectorrenderingoptions.h b/src/app/options/qgsvectorrenderingoptions.h index e773b0f51cf5..84c06943bbb0 100644 --- a/src/app/options/qgsvectorrenderingoptions.h +++ b/src/app/options/qgsvectorrenderingoptions.h @@ -23,7 +23,6 @@ class QgsVectorRenderingOptionsWidget : public QgsOptionsPageWidget, private Ui: Q_OBJECT public: - QgsVectorRenderingOptionsWidget( QWidget *parent ); QString helpKey() const override; void apply() override; @@ -35,13 +34,11 @@ class QgsVectorRenderingOptionsFactory : public QgsOptionsWidgetFactory Q_OBJECT public: - QgsVectorRenderingOptionsFactory(); QIcon icon() const override; QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; QStringList path() const override; - }; diff --git a/src/app/pluginmanager/qgsapppluginmanagerinterface.h b/src/app/pluginmanager/qgsapppluginmanagerinterface.h index 82e2312916a3..bb57a67f68b9 100644 --- a/src/app/pluginmanager/qgsapppluginmanagerinterface.h +++ b/src/app/pluginmanager/qgsapppluginmanagerinterface.h @@ -31,7 +31,6 @@ class QgsAppPluginManagerInterface : public QgsPluginManagerInterface Q_OBJECT public: - //! Constructor explicit QgsAppPluginManagerInterface( QgsPluginManager *pluginManager ); @@ -60,7 +59,6 @@ class QgsAppPluginManagerInterface : public QgsPluginManagerInterface void pushMessage( const QString &text, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = -1 ) override; private: - //! Pointer to QgsPluginManager object QgsPluginManager *mPluginManager = nullptr; }; diff --git a/src/app/pluginmanager/qgspluginitemdelegate.cpp b/src/app/pluginmanager/qgspluginitemdelegate.cpp index 2b0b07e43ee2..e44d859e2524 100644 --- a/src/app/pluginmanager/qgspluginitemdelegate.cpp +++ b/src/app/pluginmanager/qgspluginitemdelegate.cpp @@ -26,7 +26,8 @@ #include "qgspluginsortfilterproxymodel.h" -QgsPluginItemDelegate::QgsPluginItemDelegate( QObject *parent ) : QStyledItemDelegate( parent ) {} +QgsPluginItemDelegate::QgsPluginItemDelegate( QObject *parent ) + : QStyledItemDelegate( parent ) {} QSize QgsPluginItemDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const @@ -88,12 +89,12 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem painter->setPen( option.palette.text().color() ); } - if ( ! index.data( PLUGIN_ERROR_ROLE ).toString().isEmpty() ) + if ( !index.data( PLUGIN_ERROR_ROLE ).toString().isEmpty() ) { painter->setPen( Qt::red ); } - if ( ! index.data( PLUGIN_ERROR_ROLE ).toString().isEmpty() + if ( !index.data( PLUGIN_ERROR_ROLE ).toString().isEmpty() || index.data( PLUGIN_STATUS_ROLE ).toString() == QLatin1String( "upgradeable" ) || index.data( PLUGIN_STATUS_ROLE ).toString() == QLatin1String( "new" ) ) { diff --git a/src/app/pluginmanager/qgspluginmanager.cpp b/src/app/pluginmanager/qgspluginmanager.cpp index 0ec5d6caa32d..e1d918bc0d62 100644 --- a/src/app/pluginmanager/qgspluginmanager.cpp +++ b/src/app/pluginmanager/qgspluginmanager.cpp @@ -62,7 +62,7 @@ // This doesn't work on windows and causes problems with plugins // on OS X (the code doesn't cause a problem but including dlfcn.h // renders plugins unloadable) -#if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) +#if !defined( Q_OS_WIN ) && !defined( Q_OS_MACOS ) #include #endif #endif @@ -174,7 +174,6 @@ QgsPluginManager::QgsPluginManager( QWidget *parent, bool pluginsAreEnabled, Qt: } - QgsPluginManager::~QgsPluginManager() { delete mModelProxy; @@ -186,7 +185,6 @@ QgsPluginManager::~QgsPluginManager() } - void QgsPluginManager::setPythonUtils( QgsPythonUtils *pythonUtils ) { mPythonUtils = pythonUtils; @@ -266,7 +264,7 @@ void QgsPluginManager::loadPlugin( const QString &id ) { const QMap *plugin = pluginMetadata( id ); - if ( ! plugin ) + if ( !plugin ) { return; } @@ -292,12 +290,11 @@ void QgsPluginManager::loadPlugin( const QString &id ) } - void QgsPluginManager::unloadPlugin( const QString &id ) { const QMap *plugin = pluginMetadata( id ); - if ( ! plugin ) + if ( !plugin ) { return; } @@ -319,11 +316,10 @@ void QgsPluginManager::unloadPlugin( const QString &id ) } - void QgsPluginManager::savePluginState( QString id, bool state ) { const QMap *plugin = pluginMetadata( id ); - if ( ! plugin ) + if ( !plugin ) { return; } @@ -344,11 +340,10 @@ void QgsPluginManager::savePluginState( QString id, bool state ) } - void QgsPluginManager::getCppPluginsMetadata() { QString sharedLibExtension; -#if defined(Q_OS_WIN) || defined(__CYGWIN__) +#if defined( Q_OS_WIN ) || defined( __CYGWIN__ ) sharedLibExtension = "*.dll"; #else sharedLibExtension = QStringLiteral( "*.so*" ); @@ -386,7 +381,7 @@ void QgsPluginManager::getCppPluginsMetadata() // This doesn't work on windows and causes problems with plugins // on OS X (the code doesn't cause a problem but including dlfcn.h // renders plugins unloadable) -#if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) +#if !defined( Q_OS_WIN ) && !defined( Q_OS_MACOS ) // test code to help debug loading problems // This doesn't work on windows and causes problems with plugins // on OS X (the code doesn't cause a problem but including dlfcn.h @@ -410,7 +405,7 @@ void QgsPluginManager::getCppPluginsMetadata() QgsDebugMsgLevel( "Examining: " + lib, 2 ); try { - std::unique_ptr< QLibrary > myLib = std::make_unique< QLibrary >( lib ); + std::unique_ptr myLib = std::make_unique( lib ); const bool loaded = myLib->load(); if ( !loaded ) { @@ -535,7 +530,6 @@ void QgsPluginManager::getCppPluginsMetadata() } - QStandardItem *QgsPluginManager::createSpacerItem( const QString &text, const QString &value ) { QStandardItem *mySpacerltem = new QStandardItem( text ); @@ -551,7 +545,6 @@ QStandardItem *QgsPluginManager::createSpacerItem( const QString &text, const QS } - void QgsPluginManager::reloadModelData() { mModelPlugins->clear(); @@ -563,11 +556,11 @@ void QgsPluginManager::reloadModelData() buttonUninstall->setEnabled( false ); } - for ( QMap >::const_iterator it = mPlugins.constBegin(); + for ( QMap>::const_iterator it = mPlugins.constBegin(); it != mPlugins.constEnd(); ++it ) { - if ( ! it->value( QStringLiteral( "id" ) ).isEmpty() ) + if ( !it->value( QStringLiteral( "id" ) ).isEmpty() ) { const QString baseName = it->value( QStringLiteral( "id" ) ); const QString pluginName = it->value( QStringLiteral( "name" ) ); @@ -656,21 +649,20 @@ void QgsPluginManager::reloadModelData() buttonUpgradeAll->setEnabled( hasUpgradeablePlugins() ); // Disable tabs that are empty because of no suitable plugins in the model. - mOptionsListWidget->item( PLUGMAN_TAB_NOT_INSTALLED )->setHidden( ! hasAvailablePlugins() ); - mOptionsListWidget->item( PLUGMAN_TAB_UPGRADEABLE )->setHidden( ! hasUpgradeablePlugins() ); - mOptionsListWidget->item( PLUGMAN_TAB_NEW )->setHidden( ! hasNewPlugins() ); - mOptionsListWidget->item( PLUGMAN_TAB_INVALID )->setHidden( ! hasInvalidPlugins() ); + mOptionsListWidget->item( PLUGMAN_TAB_NOT_INSTALLED )->setHidden( !hasAvailablePlugins() ); + mOptionsListWidget->item( PLUGMAN_TAB_UPGRADEABLE )->setHidden( !hasUpgradeablePlugins() ); + mOptionsListWidget->item( PLUGMAN_TAB_NEW )->setHidden( !hasNewPlugins() ); + mOptionsListWidget->item( PLUGMAN_TAB_INVALID )->setHidden( !hasInvalidPlugins() ); } - void QgsPluginManager::pluginItemChanged( QStandardItem *item ) { const QString id = item->data( PLUGIN_BASE_NAME_ROLE ).toString(); if ( item->checkState() ) { - if ( mPluginsAreEnabled && ! isPluginEnabled( id ) ) + if ( mPluginsAreEnabled && !isPluginEnabled( id ) ) { QgsDebugMsgLevel( " Loading plugin: " + id, 2 ); loadPlugin( id ); @@ -682,7 +674,7 @@ void QgsPluginManager::pluginItemChanged( QStandardItem *item ) savePluginState( id, true ); } } - else if ( ! item->checkState() ) + else if ( !item->checkState() ) { QgsDebugMsgLevel( " Unloading plugin: " + id, 2 ); unloadPlugin( id ); @@ -690,7 +682,6 @@ void QgsPluginManager::pluginItemChanged( QStandardItem *item ) } - void QgsPluginManager::showPluginDetails( QStandardItem *item ) { const QMap *metadata = pluginMetadata( item->data( PLUGIN_BASE_NAME_ROLE ).toString() ); @@ -702,41 +693,46 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) QString html = ""; + " color:" + + palette().color( QPalette::ColorRole::Text ).name() + ";" + " background-color:" + + palette().color( QPalette::ColorRole::Base ).name() + ";" + " }" + " body, table {" + " padding:0px;" + " margin:0px;" + " font-family:Verdana, Sans-serif;" + " font-size:10pt;" + " }" + " a {" + " color: " + + palette().color( QPalette::ColorRole::Link ).name() + ";" + " text-decoration:none;" + " }" + " a:hover,a:focus {" + " color: " + + palette().color( QPalette::ColorRole::Link ).name() + ";" + " text-decoration:underline;" + " }" + " a:visited {" + " color: " + + palette().color( QPalette::ColorRole::LinkVisited ).name() + ";" + " }" + " div#votes {" + " width:360px;" + " margin-left:98px;" + " padding-top:3px;" + " }" + " td {" + " vertical-align:top;" + " }" + " td.key {" + " font-weight: bold;" + " white-space:nowrap;" + " padding-right:10px;" + " text-align:right;" + " }" + ""; if ( !metadata->value( QStringLiteral( "plugin_id" ) ).isEmpty() ) { @@ -752,11 +748,13 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) " }" " div#stars {" " background-image: url('qrc:/images/themes/default/stars_full.svg');" - " background-size: 92px 16px;" /*scale to the full width*/ + " background-size: 92px 16px;" /*scale to the full width*/ " width:%1px;" " height:16px;" " }" - "" ).arg( metadata->value( QStringLiteral( "average_vote" ) ).toFloat() / 5 * 92 ); + "" + ) + .arg( metadata->value( QStringLiteral( "average_vote" ) ).toFloat() / 5 * 92 ); html += QString( "" ).arg( metadata->value( QStringLiteral( "plugin_id" ) ) ); + "" + ) + .arg( metadata->value( QStringLiteral( "plugin_id" ) ) ); #else voteRating->show(); voteLabel->show(); @@ -825,7 +825,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) // First prepare message box(es) - if ( ! metadata->value( QStringLiteral( "error" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "error" ) ).isEmpty() ) { QString errorMsg; if ( metadata->value( QStringLiteral( "error" ) ) == QLatin1String( "incompatible" ) ) @@ -842,37 +842,42 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) } html += QString( "
    " " " - "
    %1
    " ).arg( errorMsg ); + "" ) + .arg( errorMsg ); } if ( metadata->value( QStringLiteral( "status" ) ) == QLatin1String( "upgradeable" ) || metadata->value( QStringLiteral( "status_exp" ) ) == QLatin1String( "upgradeable" ) ) { html += QString( "" " " - "
    %1
    " ).arg( tr( "There is a new version available" ) ); + "" ) + .arg( tr( "There is a new version available" ) ); } if ( metadata->value( QStringLiteral( "status" ) ) == QLatin1String( "new" ) || metadata->value( QStringLiteral( "status_exp" ) ) == QLatin1String( "new" ) ) { html += QString( "" " " - "
    %1
    " ).arg( tr( "This is a new plugin" ) ); + "" ) + .arg( tr( "This is a new plugin" ) ); } if ( metadata->value( QStringLiteral( "status" ) ) == QLatin1String( "newer" ) && metadata->value( QStringLiteral( "status_exp" ) ) == QLatin1String( "newer" ) ) { html += QString( "" " " - "
    %1
    " ).arg( tr( "Installed version of this plugin is higher than any version found in repository" ) ); + "" ) + .arg( tr( "Installed version of this plugin is higher than any version found in repository" ) ); } - if ( ! metadata->value( QStringLiteral( "version_available_experimental" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "version_available_experimental" ) ).isEmpty() ) { html += QString( "" " " - "
    " " %1" "
    " ).arg( tr( "This plugin has an experimental version available" ) ); + "" ) + .arg( tr( "This plugin has an experimental version available" ) ); } if ( metadata->value( QStringLiteral( "deprecated" ) ) == QLatin1String( "true" ) ) @@ -881,14 +886,16 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) " " " %1" " " - "" ).arg( tr( "This plugin is deprecated" ) ); + "" ) + .arg( tr( "This plugin is deprecated" ) ); } if ( metadata->value( QStringLiteral( "readonly" ) ) == QLatin1String( "true" ) ) { html += QString( "" " " - "
    %1
    " ).arg( tr( "This is a core plugin, so you can't uninstall it" ) ); + "" ) + .arg( tr( "This is a core plugin, so you can't uninstall it" ) ); } // Now the metadata @@ -904,9 +911,9 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) { iconPath = "qrc" + iconPath; } - else if ( ! iconPath.startsWith( QLatin1String( "http" ) ) ) + else if ( !iconPath.startsWith( QLatin1String( "http" ) ) ) { -#if defined(Q_OS_WIN) +#if defined( Q_OS_WIN ) iconPath = "file:///" + iconPath; #else iconPath = "file://" + iconPath; @@ -925,7 +932,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) description = description.remove( stripHtml ); html += QStringLiteral( "

    %1

    " ).arg( description ); - if ( ! metadata->value( QStringLiteral( "about" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "about" ) ).isEmpty() ) { QString about = metadata->value( QStringLiteral( "about" ) ); // The regular expression ensures that a new line will be present after the closure of a paragraph tag (i.e.

    ) @@ -939,13 +946,13 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) #ifndef WITH_QTWEBKIT votes += tr( "Average rating %1" ).arg( metadata->value( "average_vote" ).toFloat(), 0, 'f', 1 ); #endif - if ( ! metadata->value( QStringLiteral( "rating_votes" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "rating_votes" ) ).isEmpty() ) { if ( !votes.isEmpty() ) votes += QLatin1String( ", " ); votes += tr( "%1 rating vote(s)" ).arg( metadata->value( QStringLiteral( "rating_votes" ) ) ); } - if ( ! metadata->value( QStringLiteral( "downloads" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "downloads" ) ).isEmpty() ) { if ( !votes.isEmpty() ) votes += QLatin1String( ", " ); @@ -968,11 +975,11 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) html += QLatin1String( "" ); html += QLatin1String( " " ); - if ( ! metadata->value( QStringLiteral( "category" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "category" ) ).isEmpty() ) { html += QStringLiteral( "%1 %2" ).arg( tr( "Category" ), metadata->value( QStringLiteral( "category" ) ) ); } - if ( ! metadata->value( QStringLiteral( "tags" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "tags" ) ).isEmpty() ) { QStringList tags = metadata->value( QStringLiteral( "tags" ) ).toLower().split( ',' ); for ( auto tag = tags.begin(); tag != tags.end(); ++tag ) @@ -982,34 +989,34 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) html += QStringLiteral( "%1 %2" ).arg( tr( "Tags" ), tags.join( QLatin1String( ", " ) ) ); } - if ( ! metadata->value( QStringLiteral( "homepage" ) ).isEmpty() || ! metadata->value( QStringLiteral( "tracker" ) ).isEmpty() || ! metadata->value( QStringLiteral( "code_repository" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "homepage" ) ).isEmpty() || !metadata->value( QStringLiteral( "tracker" ) ).isEmpty() || !metadata->value( QStringLiteral( "code_repository" ) ).isEmpty() ) { html += QStringLiteral( "%1 " ).arg( tr( "More info" ) ); - if ( ! metadata->value( QStringLiteral( "homepage" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "homepage" ) ).isEmpty() ) { html += QStringLiteral( "%2   " ).arg( metadata->value( QStringLiteral( "homepage" ) ), tr( "homepage" ) ); } - if ( ! metadata->value( QStringLiteral( "tracker" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "tracker" ) ).isEmpty() ) { html += QStringLiteral( "%2   " ).arg( metadata->value( QStringLiteral( "tracker" ) ), tr( "bug tracker" ) ); } - if ( ! metadata->value( QStringLiteral( "code_repository" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "code_repository" ) ).isEmpty() ) { html += QStringLiteral( "%2" ).arg( metadata->value( QStringLiteral( "code_repository" ) ), tr( "code repository" ) ); } html += QLatin1String( "" ); } - if ( ! metadata->value( QStringLiteral( "author_email" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "author_email" ) ).isEmpty() ) { html += QStringLiteral( "%1 %3" ).arg( tr( "Author" ), metadata->value( QStringLiteral( "author_email" ) ), metadata->value( QStringLiteral( "author_name" ) ) ); } - else if ( ! metadata->value( QStringLiteral( "author_name" ) ).isEmpty() ) + else if ( !metadata->value( QStringLiteral( "author_name" ) ).isEmpty() ) { html += QStringLiteral( "%1 %2" ).arg( tr( "Author" ), metadata->value( QStringLiteral( "author_name" ) ) ); } - if ( ! metadata->value( QStringLiteral( "version_installed" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "version_installed" ) ).isEmpty() ) { QString ver = metadata->value( QStringLiteral( "version_installed" ) ); if ( ver == QLatin1String( "-1" ) ) @@ -1026,10 +1033,8 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) localDir = QDir( localDir ).canonicalPath(); } html += QStringLiteral( "%1 %4" - ).arg( tr( "Installed version" ), - QDir::toNativeSeparators( localDir ), - QUrl::fromLocalFile( localDir ).toString(), - ver ); + ) + .arg( tr( "Installed version" ), QDir::toNativeSeparators( localDir ), QUrl::fromLocalFile( localDir ).toString(), ver ); } // use a localized date/time short format string @@ -1040,7 +1045,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) dateTimeFormat.replace( "yy", "yyyy" ); } // if we allow experimental, we show both stable and experimental versions - if ( ! metadata->value( QStringLiteral( "version_available_stable" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "version_available_stable" ) ).isEmpty() ) { QString downloadUrl = metadata->value( QStringLiteral( "download_url_stable" ) ); if ( downloadUrl.contains( QStringLiteral( "plugins.qgis.org" ) ) ) @@ -1050,7 +1055,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) } QString dateUpdatedStr; - if ( ! metadata->value( QStringLiteral( "update_date_stable" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "update_date_stable" ) ).isEmpty() ) { const QDateTime dateUpdatedUtc = QDateTime::fromString( metadata->value( QStringLiteral( "update_date_stable" ) ).trimmed(), Qt::ISODate ); if ( dateUpdatedUtc.isValid() ) @@ -1061,13 +1066,11 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) } html += QStringLiteral( "%1 %3 %4" - ).arg( tr( "Available version (stable)" ), - downloadUrl, - metadata->value( QStringLiteral( "version_available_stable" ) ), - dateUpdatedStr ); + ) + .arg( tr( "Available version (stable)" ), downloadUrl, metadata->value( QStringLiteral( "version_available_stable" ) ), dateUpdatedStr ); } - if ( ! metadata->value( QStringLiteral( "version_available_experimental" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "version_available_experimental" ) ).isEmpty() ) { QString downloadUrl = metadata->value( QStringLiteral( "download_url_experimental" ) ); if ( downloadUrl.contains( QStringLiteral( "plugins.qgis.org" ) ) ) @@ -1085,20 +1088,18 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) } html += QStringLiteral( "%1 %3 %4" - ).arg( tr( "Available version (experimental)" ), - downloadUrl, - metadata->value( QStringLiteral( "version_available_experimental" ) ), - dateUpdatedStr ); + ) + .arg( tr( "Available version (experimental)" ), downloadUrl, metadata->value( QStringLiteral( "version_available_experimental" ) ), dateUpdatedStr ); } - if ( ! metadata->value( QStringLiteral( "changelog" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "changelog" ) ).isEmpty() ) { QString changelog = metadata->value( QStringLiteral( "changelog" ) ); changelog = changelog.trimmed().replace( '\n', QLatin1String( "
    " ) ); html += QStringLiteral( "%1 %2" ).arg( tr( "Changelog" ), changelog ); } - if ( ! metadata->value( QStringLiteral( "plugin_dependencies" ) ).isEmpty() ) + if ( !metadata->value( QStringLiteral( "plugin_dependencies" ) ).isEmpty() ) { QString pluginDependencies = metadata->value( QStringLiteral( "plugin_dependencies" ) ); pluginDependencies = pluginDependencies.trimmed(); @@ -1171,7 +1172,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) buttonInstallExperimental->setEnabled( expAllowed && installExpEnabled ); buttonInstallExperimental->setVisible( expAllowed && installExpEnabled ); - buttonUninstall->setEnabled( metadata->value( QStringLiteral( "pythonic" ) ).toUpper() == QLatin1String( "TRUE" ) && metadata->value( QStringLiteral( "readonly" ) ) != QLatin1String( "true" ) && ! metadata->value( QStringLiteral( "version_installed" ) ).isEmpty() ); + buttonUninstall->setEnabled( metadata->value( QStringLiteral( "pythonic" ) ).toUpper() == QLatin1String( "TRUE" ) && metadata->value( QStringLiteral( "readonly" ) ) != QLatin1String( "true" ) && !metadata->value( QStringLiteral( "version_installed" ) ).isEmpty() ); buttonUninstall->setHidden( metadata->value( QStringLiteral( "version_installed" ) ).isEmpty() ); @@ -1180,19 +1181,16 @@ void QgsPluginManager::showPluginDetails( QStandardItem *item ) } - void QgsPluginManager::selectTabItem( int idx ) { mOptionsListWidget->setCurrentRow( idx ); } - void QgsPluginManager::clearPythonPluginMetadata() { - for ( QMap >::iterator it = mPlugins.begin(); - it != mPlugins.end(); - ) + for ( QMap>::iterator it = mPlugins.begin(); + it != mPlugins.end(); ) { if ( it->value( QStringLiteral( "pythonic" ) ) == QLatin1String( "true" ) ) { @@ -1206,17 +1204,15 @@ void QgsPluginManager::clearPythonPluginMetadata() } - void QgsPluginManager::addPluginMetadata( const QString &key, const QMap &metadata ) { mPlugins.insert( key, metadata ); } - const QMap *QgsPluginManager::pluginMetadata( const QString &key ) const { - const QMap >::const_iterator it = mPlugins.find( key ); + const QMap>::const_iterator it = mPlugins.find( key ); if ( it != mPlugins.end() ) { return &it.value(); @@ -1254,7 +1250,7 @@ void QgsPluginManager::addToRepositoryList( const QMap &reposi } const QString key = repository.value( QStringLiteral( "name" ) ); - if ( ! key.isEmpty() ) + if ( !key.isEmpty() ) { QTreeWidgetItem *a = new QTreeWidgetItem( treeRepositories ); a->setText( 1, key ); @@ -1301,7 +1297,6 @@ void QgsPluginManager::addToRepositoryList( const QMap &reposi } - // SLOTS /////////////////////////////////////////////////////////////////// @@ -1319,7 +1314,6 @@ void QgsPluginManager::reject() } - void QgsPluginManager::setCurrentTab( int idx ) { if ( idx == PLUGMAN_TAB_SETTINGS ) @@ -1378,19 +1372,23 @@ void QgsPluginManager::setCurrentTab( int idx ) { tabInfoHTML += ""; + " color: " + + palette().color( QPalette::ColorRole::Text ).name() + ";" + " background-color:" + + palette().color( QPalette::ColorRole::Base ).name() + ";" + " margin: 2px;" + " font-family: Verdana, Sans-serif;" + " font-size: 10pt;" + " }" + " a, a:hover {" + " color: " + + palette().color( QPalette::ColorRole::Link ).name() + ";" + " }" + " a:visited {" + " color: " + + palette().color( QPalette::ColorRole::LinkVisited ).name() + ";" + " }" + ""; // tabInfoHTML += ""; tabInfoHTML += it.value(); } @@ -1405,7 +1403,6 @@ void QgsPluginManager::setCurrentTab( int idx ) } - void QgsPluginManager::currentPluginChanged( const QModelIndex &index ) { if ( index.column() == 0 ) @@ -1419,7 +1416,6 @@ void QgsPluginManager::currentPluginChanged( const QModelIndex &index ) } - void QgsPluginManager::vwPlugins_doubleClicked( const QModelIndex &index ) { if ( index.column() == 0 ) @@ -1524,21 +1520,18 @@ void QgsPluginManager::buttonInstallExperimental_clicked() } - void QgsPluginManager::buttonUninstall_clicked() { QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().uninstallPlugin('%1')" ).arg( mCurrentlyDisplayedPlugin ) ); } - void QgsPluginManager::mZipFileWidget_fileChanged( const QString &filePath ) { buttonInstallFromZip->setEnabled( QFileInfo( filePath ).isFile() ); } - void QgsPluginManager::buttonInstallFromZip_clicked() { const bool showInstallFromZipWarning = settingsShowInstallFromZipWarning->value(); @@ -1566,22 +1559,19 @@ void QgsPluginManager::buttonInstallFromZip_clicked() } - void QgsPluginManager::treeRepositories_itemSelectionChanged() { - buttonEditRep->setEnabled( ! treeRepositories->selectedItems().isEmpty() ); - buttonDeleteRep->setEnabled( ! treeRepositories->selectedItems().isEmpty() ); + buttonEditRep->setEnabled( !treeRepositories->selectedItems().isEmpty() ); + buttonDeleteRep->setEnabled( !treeRepositories->selectedItems().isEmpty() ); } - void QgsPluginManager::treeRepositories_doubleClicked( const QModelIndex & ) { buttonEditRep_clicked(); } - void QgsPluginManager::setRepositoryFilter() { QTreeWidgetItem *current = treeRepositories->currentItem(); @@ -1595,7 +1585,6 @@ void QgsPluginManager::setRepositoryFilter() } - void QgsPluginManager::clearRepositoryFilter() { QgsDebugMsgLevel( QStringLiteral( "Enabling all repositories back" ), 2 ); @@ -1603,7 +1592,6 @@ void QgsPluginManager::clearRepositoryFilter() } - void QgsPluginManager::buttonRefreshRepos_clicked() { QgsDebugMsgLevel( QStringLiteral( "Refreshing repositories..." ), 2 ); @@ -1611,7 +1599,6 @@ void QgsPluginManager::buttonRefreshRepos_clicked() } - void QgsPluginManager::buttonAddRep_clicked() { QgsDebugMsgLevel( QStringLiteral( "Adding repository connection..." ), 2 ); @@ -1619,7 +1606,6 @@ void QgsPluginManager::buttonAddRep_clicked() } - void QgsPluginManager::buttonEditRep_clicked() { QTreeWidgetItem *current = treeRepositories->currentItem(); @@ -1633,7 +1619,6 @@ void QgsPluginManager::buttonEditRep_clicked() } - void QgsPluginManager::buttonDeleteRep_clicked() { QTreeWidgetItem *current = treeRepositories->currentItem(); @@ -1647,7 +1632,6 @@ void QgsPluginManager::buttonDeleteRep_clicked() } - void QgsPluginManager::ckbExperimental_toggled( bool state ) { settingsAllowExperimental->setValue( state ); @@ -1689,10 +1673,9 @@ bool QgsPluginManager::isPluginEnabled( QString key ) } - bool QgsPluginManager::hasAvailablePlugins() { - for ( QMap >::const_iterator it = mPlugins.constBegin(); + for ( QMap>::const_iterator it = mPlugins.constBegin(); it != mPlugins.constEnd(); ++it ) { @@ -1706,10 +1689,9 @@ bool QgsPluginManager::hasAvailablePlugins() } - bool QgsPluginManager::hasReinstallablePlugins() { - for ( QMap >::const_iterator it = mPlugins.constBegin(); + for ( QMap>::const_iterator it = mPlugins.constBegin(); it != mPlugins.constEnd(); ++it ) { @@ -1724,10 +1706,9 @@ bool QgsPluginManager::hasReinstallablePlugins() } - bool QgsPluginManager::hasUpgradeablePlugins() { - for ( QMap >::const_iterator it = mPlugins.constBegin(); + for ( QMap>::const_iterator it = mPlugins.constBegin(); it != mPlugins.constEnd(); ++it ) { @@ -1741,10 +1722,9 @@ bool QgsPluginManager::hasUpgradeablePlugins() } - bool QgsPluginManager::hasNewPlugins() { - for ( QMap >::const_iterator it = mPlugins.constBegin(); + for ( QMap>::const_iterator it = mPlugins.constBegin(); it != mPlugins.constEnd(); ++it ) { @@ -1758,10 +1738,9 @@ bool QgsPluginManager::hasNewPlugins() } - bool QgsPluginManager::hasNewerPlugins() { - for ( QMap >::const_iterator it = mPlugins.constBegin(); + for ( QMap>::const_iterator it = mPlugins.constBegin(); it != mPlugins.constEnd(); ++it ) { @@ -1775,14 +1754,13 @@ bool QgsPluginManager::hasNewerPlugins() } - bool QgsPluginManager::hasInvalidPlugins() { - for ( QMap >::const_iterator it = mPlugins.constBegin(); + for ( QMap>::const_iterator it = mPlugins.constBegin(); it != mPlugins.constEnd(); ++it ) { - if ( ! it->value( QStringLiteral( "error" ) ).isEmpty() ) + if ( !it->value( QStringLiteral( "error" ) ).isEmpty() ) { return true; } @@ -1792,7 +1770,6 @@ bool QgsPluginManager::hasInvalidPlugins() } - void QgsPluginManager::updateWindowTitle() { QListWidgetItem *curitem = mOptListWidget->currentItem(); @@ -1813,7 +1790,6 @@ void QgsPluginManager::updateWindowTitle() } - void QgsPluginManager::showEvent( QShowEvent *e ) { if ( mInit ) @@ -1829,7 +1805,6 @@ void QgsPluginManager::showEvent( QShowEvent *e ) } - void QgsPluginManager::pushMessage( const QString &text, Qgis::MessageLevel level, int duration ) { msgBar->pushMessage( text, level, duration ); diff --git a/src/app/pluginmanager/qgspluginmanager.h b/src/app/pluginmanager/qgspluginmanager.h index 1c61bd5a5032..fc2bc2d66ce8 100644 --- a/src/app/pluginmanager/qgspluginmanager.h +++ b/src/app/pluginmanager/qgspluginmanager.h @@ -52,7 +52,6 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag { Q_OBJECT public: - static inline QgsSettingsTreeNode *sTreePluginManager = QgsSettingsTree::treeRoot()->createChildNode( QStringLiteral( "plugin-manager" ) ); static const QgsSettingsEntryBool *settingsAutomaticallyCheckForPluginUpdates; @@ -246,7 +245,7 @@ class QgsPluginManager : public QgsOptionsDialogBase, private Ui::QgsPluginManag QMap mTabDescriptions; - QMap< QString, QMap< QString, QString > > mPlugins; + QMap> mPlugins; QString mCurrentlyDisplayedPlugin; diff --git a/src/app/pluginmanager/qgspluginmanager_texts.cpp b/src/app/pluginmanager/qgspluginmanager_texts.cpp index 6ad11e88903c..c52ce2b60255 100644 --- a/src/app/pluginmanager/qgspluginmanager_texts.cpp +++ b/src/app/pluginmanager/qgspluginmanager_texts.cpp @@ -27,7 +27,6 @@ on the 'Invalid' tab. Click on the plugin name to see more details, or to reinst " ) ); - mTabDescriptions.insert( QStringLiteral( "installed_plugins" ), tr( "

    Installed Plugins

    \ \

    \ @@ -45,7 +44,6 @@ You can change the sorting via the context menu (right click).\ " ) ); - mTabDescriptions.insert( QStringLiteral( "upgradeable_plugins" ), tr( "

    Upgradable plugins

    \ \

    \ @@ -56,7 +54,6 @@ plugins are available in the repositories.\ " ) ); - mTabDescriptions.insert( QStringLiteral( "not_installed_plugins" ), tr( "

    Not installed plugins

    \ \

    \ @@ -77,7 +74,6 @@ then click the 'Install plugin' button.\ " ) ); - mTabDescriptions.insert( QStringLiteral( "new_plugins" ), tr( "

    New plugins

    \ \

    \ @@ -88,7 +84,6 @@ Here you see brand new plugins which can be installed.\ " ) ); - mTabDescriptions.insert( QStringLiteral( "invalid_plugins" ), tr( "

    Invalid plugins

    \ \

    \ @@ -110,5 +105,4 @@ You can install them yourself, depending on your operating system. After a corre install the plugin should work.\

    \ " ) ); - } diff --git a/src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp b/src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp index 03ee062179f8..4fa205f24cf6 100644 --- a/src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp +++ b/src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp @@ -18,29 +18,27 @@ #include "moc_qgspluginsortfilterproxymodel.cpp" - -QgsPluginSortFilterProxyModel::QgsPluginSortFilterProxyModel( QObject *parent ) : QSortFilterProxyModel( parent ) +QgsPluginSortFilterProxyModel::QgsPluginSortFilterProxyModel( QObject *parent ) + : QSortFilterProxyModel( parent ) { } - bool QgsPluginSortFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const { QModelIndex inx = sourceModel()->index( sourceRow, 0, sourceParent ); - if ( ! sourceModel()->data( inx, SPACER_ROLE ).toString().isEmpty() ) + if ( !sourceModel()->data( inx, SPACER_ROLE ).toString().isEmpty() ) { // it's a status spacer. // TODO: the condition below is only suitable for status spacers - return ( filterByStatus( inx ) && mAcceptedStatuses.count() > 2 && sourceModel()->data( inx, SPACER_ROLE ).toString() == mAcceptedSpacers ); + return ( filterByStatus( inx ) && mAcceptedStatuses.count() > 2 && sourceModel()->data( inx, SPACER_ROLE ).toString() == mAcceptedSpacers ); } return ( filterByStatus( inx ) && filterByPhrase( inx ) ); } - void QgsPluginSortFilterProxyModel::setAcceptedStatuses( const QStringList &statuses ) { mAcceptedStatuses = statuses; @@ -48,7 +46,6 @@ void QgsPluginSortFilterProxyModel::setAcceptedStatuses( const QStringList &stat } - void QgsPluginSortFilterProxyModel::setAcceptedSpacers( const QString &spacers ) { mAcceptedSpacers = spacers; @@ -56,7 +53,6 @@ void QgsPluginSortFilterProxyModel::setAcceptedSpacers( const QString &spacers ) } - bool QgsPluginSortFilterProxyModel::filterByStatus( QModelIndex &index ) const { if ( mAcceptedStatuses.contains( QStringLiteral( "invalid" ) ) @@ -68,9 +64,10 @@ bool QgsPluginSortFilterProxyModel::filterByStatus( QModelIndex &index ) const QString status = sourceModel()->data( index, PLUGIN_STATUS_ROLE ).toString(); const QString statusexp = sourceModel()->data( index, PLUGIN_STATUSEXP_ROLE ).toString(); - if ( status.endsWith( 'Z' ) ) status.chop( 1 ); - if ( ! mAcceptedStatuses.isEmpty() - && ! mAcceptedStatuses.contains( QStringLiteral( "invalid" ) ) + if ( status.endsWith( 'Z' ) ) + status.chop( 1 ); + if ( !mAcceptedStatuses.isEmpty() + && !mAcceptedStatuses.contains( QStringLiteral( "invalid" ) ) && !( mAcceptedStatuses.contains( status ) || mAcceptedStatuses.contains( statusexp ) ) ) { // Don't accept if the status doesn't match @@ -82,7 +79,6 @@ bool QgsPluginSortFilterProxyModel::filterByStatus( QModelIndex &index ) const } - bool QgsPluginSortFilterProxyModel::filterByPhrase( QModelIndex &index ) const { switch ( filterRole() ) @@ -106,7 +102,6 @@ bool QgsPluginSortFilterProxyModel::filterByPhrase( QModelIndex &index ) const } - int QgsPluginSortFilterProxyModel::countWithCurrentStatus() { int result = 0; @@ -122,7 +117,6 @@ int QgsPluginSortFilterProxyModel::countWithCurrentStatus() } - void QgsPluginSortFilterProxyModel::sortPluginsByName() { setAcceptedSpacers(); @@ -131,7 +125,6 @@ void QgsPluginSortFilterProxyModel::sortPluginsByName() } - void QgsPluginSortFilterProxyModel::sortPluginsByDownloads() { setAcceptedSpacers(); @@ -140,7 +133,6 @@ void QgsPluginSortFilterProxyModel::sortPluginsByDownloads() } - void QgsPluginSortFilterProxyModel::sortPluginsByVote() { setAcceptedSpacers(); @@ -149,7 +141,6 @@ void QgsPluginSortFilterProxyModel::sortPluginsByVote() } - void QgsPluginSortFilterProxyModel::sortPluginsByStatus() { setAcceptedSpacers( QStringLiteral( "status" ) ); @@ -158,7 +149,6 @@ void QgsPluginSortFilterProxyModel::sortPluginsByStatus() } - void QgsPluginSortFilterProxyModel::sortPluginsByDateCreated() { setAcceptedSpacers(); diff --git a/src/app/pluginmanager/qgspluginsortfilterproxymodel.h b/src/app/pluginmanager/qgspluginsortfilterproxymodel.h index 791b25b2c047..5f2788ed74e1 100644 --- a/src/app/pluginmanager/qgspluginsortfilterproxymodel.h +++ b/src/app/pluginmanager/qgspluginsortfilterproxymodel.h @@ -36,7 +36,6 @@ const int PLUGIN_UPDATE_DATE = Qt::UserRole + 12; // for sorting const int SPACER_ROLE = Qt::UserRole + 20; // for sorting - /** * \brief Proxy model for filtering and sorting items in Plugin Manager */ diff --git a/src/app/pointcloud/qgspointcloudelevationpropertieswidget.cpp b/src/app/pointcloud/qgspointcloudelevationpropertieswidget.cpp index d102165fe33a..345d7878a2fb 100644 --- a/src/app/pointcloud/qgspointcloudelevationpropertieswidget.cpp +++ b/src/app/pointcloud/qgspointcloudelevationpropertieswidget.cpp @@ -42,25 +42,25 @@ QgsPointCloudElevationPropertiesWidget::QgsPointCloudElevationPropertiesWidget( mOffsetZSpinBox->setClearValue( 0 ); mScaleZSpinBox->setClearValue( 1 ); - mPointStyleComboBox->addItem( tr( "Square" ), static_cast< int >( Qgis::PointCloudSymbol::Square ) ); - mPointStyleComboBox->addItem( tr( "Circle" ), static_cast< int >( Qgis::PointCloudSymbol::Circle ) ); + mPointStyleComboBox->addItem( tr( "Square" ), static_cast( Qgis::PointCloudSymbol::Square ) ); + mPointStyleComboBox->addItem( tr( "Circle" ), static_cast( Qgis::PointCloudSymbol::Circle ) ); mPointSizeUnitWidget->setUnits( - { - Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::MapUnits, - Qgis::RenderUnit::Pixels, - Qgis::RenderUnit::Points, - Qgis::RenderUnit::Inches - } ); + { Qgis::RenderUnit::Millimeters, + Qgis::RenderUnit::MapUnits, + Qgis::RenderUnit::Pixels, + Qgis::RenderUnit::Points, + Qgis::RenderUnit::Inches + } + ); mMaxErrorUnitWidget->setUnits( - { - Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::MapUnits, - Qgis::RenderUnit::Pixels, - Qgis::RenderUnit::Points, - Qgis::RenderUnit::Inches - } ); + { Qgis::RenderUnit::Millimeters, + Qgis::RenderUnit::MapUnits, + Qgis::RenderUnit::Pixels, + Qgis::RenderUnit::Points, + Qgis::RenderUnit::Inches + } + ); mMaxErrorSpinBox->setClearValue( 0.3 ); mPointSizeSpinBox->setClearValue( 1.0 ); @@ -70,8 +70,8 @@ QgsPointCloudElevationPropertiesWidget::QgsPointCloudElevationPropertiesWidget( syncToLayer( layer ); - connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloudElevationPropertiesWidget::onChanged ); - connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloudElevationPropertiesWidget::onChanged ); + connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloudElevationPropertiesWidget::onChanged ); + connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloudElevationPropertiesWidget::onChanged ); connect( mShifPointCloudZAxisButton, &QPushButton::clicked, this, &QgsPointCloudElevationPropertiesWidget::shiftPointCloudZAxis ); connect( mPointSizeSpinBox, qOverload( &QgsDoubleSpinBox::valueChanged ), this, &QgsPointCloudElevationPropertiesWidget::onChanged ); connect( mPointSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointCloudElevationPropertiesWidget::onChanged ); @@ -89,18 +89,18 @@ QgsPointCloudElevationPropertiesWidget::QgsPointCloudElevationPropertiesWidget( void QgsPointCloudElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) { - mLayer = qobject_cast< QgsPointCloudLayer * >( layer ); + mLayer = qobject_cast( layer ); if ( !mLayer ) return; - const QgsPointCloudLayerElevationProperties *properties = qgis::down_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() ); + const QgsPointCloudLayerElevationProperties *properties = qgis::down_cast( mLayer->elevationProperties() ); mBlockUpdates = true; mOffsetZSpinBox->setValue( properties->zOffset() ); mScaleZSpinBox->setValue( properties->zScale() ); mPointSizeSpinBox->setValue( properties->pointSize() ); mPointSizeUnitWidget->setUnit( properties->pointSizeUnit() ); - mPointStyleComboBox->setCurrentIndex( mPointStyleComboBox->findData( static_cast< int >( properties->pointSymbol() ) ) ); + mPointStyleComboBox->setCurrentIndex( mPointStyleComboBox->findData( static_cast( properties->pointSymbol() ) ) ); mMaxErrorSpinBox->setValue( properties->maximumScreenError() ); mMaxErrorUnitWidget->setUnit( properties->maximumScreenErrorUnit() ); mPointColorButton->setColor( properties->pointColor() ); @@ -117,7 +117,7 @@ void QgsPointCloudElevationPropertiesWidget::apply() if ( !mLayer ) return; - QgsPointCloudLayerElevationProperties *properties = qgis::down_cast< QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() ); + QgsPointCloudLayerElevationProperties *properties = qgis::down_cast( mLayer->elevationProperties() ); const bool changed3DrelatedProperties = !qgsDoubleNear( mOffsetZSpinBox->value(), properties->zOffset() ) || !qgsDoubleNear( mScaleZSpinBox->value(), properties->zScale() ); @@ -126,7 +126,7 @@ void QgsPointCloudElevationPropertiesWidget::apply() properties->setZScale( mScaleZSpinBox->value() ); properties->setPointSize( mPointSizeSpinBox->value() ); properties->setPointSizeUnit( mPointSizeUnitWidget->unit() ); - properties->setPointSymbol( static_cast< Qgis::PointCloudSymbol >( mPointStyleComboBox->currentData().toInt() ) ); + properties->setPointSymbol( static_cast( mPointStyleComboBox->currentData().toInt() ) ); properties->setMaximumScreenError( mMaxErrorSpinBox->value() ); properties->setMaximumScreenErrorUnit( mMaxErrorUnitWidget->unit() ); properties->setPointColor( mPointColorButton->color() ); @@ -160,33 +160,24 @@ void QgsPointCloudElevationPropertiesWidget::updateVerticalCrsOptions() { case Qgis::CrsType::Compound: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a compound CRS (%1), so the layer's vertical CRS is the vertical component of this CRS (%2)." ).arg( - mLayer->crs().userFriendlyIdentifier(), - mLayer->verticalCrs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a compound CRS (%1), so the layer's vertical CRS is the vertical component of this CRS (%2)." ).arg( mLayer->crs().userFriendlyIdentifier(), mLayer->verticalCrs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Geographic3d: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geographic 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - mLayer->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geographic 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( mLayer->crs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Geocentric: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geocentric CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - mLayer->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geocentric CRS (%1), so the vertical CRS cannot be manually specified." ).arg( mLayer->crs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Projected: if ( mLayer->crs().hasVerticalAxis() ) { mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a projected 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - mLayer->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a projected 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( mLayer->crs().userFriendlyIdentifier() ) ); break; } [[fallthrough]]; @@ -219,7 +210,7 @@ QgsPointCloudElevationPropertiesWidgetFactory::QgsPointCloudElevationPropertiesW QgsMapLayerConfigWidget *QgsPointCloudElevationPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const { - return new QgsPointCloudElevationPropertiesWidget( qobject_cast< QgsPointCloudLayer * >( layer ), canvas, parent ); + return new QgsPointCloudElevationPropertiesWidget( qobject_cast( layer ), canvas, parent ); } bool QgsPointCloudElevationPropertiesWidgetFactory::supportLayerPropertiesDialog() const @@ -241,4 +232,3 @@ QString QgsPointCloudElevationPropertiesWidgetFactory::layerPropertiesPagePositi { return QStringLiteral( "mOptsPage_Metadata" ); } - diff --git a/src/app/pointcloud/qgspointcloudelevationpropertieswidget.h b/src/app/pointcloud/qgspointcloudelevationpropertieswidget.h index 09650fd2b899..78a9ccacbf99 100644 --- a/src/app/pointcloud/qgspointcloudelevationpropertieswidget.h +++ b/src/app/pointcloud/qgspointcloudelevationpropertieswidget.h @@ -28,7 +28,6 @@ class QgsPointCloudElevationPropertiesWidget : public QgsMapLayerConfigWidget, p { Q_OBJECT public: - QgsPointCloudElevationPropertiesWidget( QgsPointCloudLayer *layer, QgsMapCanvas *canvas, QWidget *parent ); void syncToLayer( QgsMapLayer *layer ) final; @@ -44,11 +43,9 @@ class QgsPointCloudElevationPropertiesWidget : public QgsMapLayerConfigWidget, p void updateVerticalCrsOptions(); private: - QgsPointCloudLayer *mLayer = nullptr; QgsProjectionSelectionWidget *mVerticalCrsWidget = nullptr; bool mBlockUpdates = false; - }; @@ -66,5 +63,4 @@ class QgsPointCloudElevationPropertiesWidgetFactory : public QObject, public Qgs }; - #endif // QGSPOINTCLOUDELEVATIONPROPERTIESWIDGET_H diff --git a/src/app/pointcloud/qgspointcloudlayerproperties.cpp b/src/app/pointcloud/qgspointcloudlayerproperties.cpp index 2db1015aeda0..1807979b7ee0 100644 --- a/src/app/pointcloud/qgspointcloudlayerproperties.cpp +++ b/src/app/pointcloud/qgspointcloudlayerproperties.cpp @@ -77,8 +77,7 @@ QgsPointCloudLayerProperties::QgsPointCloudLayerProperties( QgsPointCloudLayer * QgsSettings settings; if ( !settings.contains( QStringLiteral( "/Windows/PointCloudLayerProperties/tab" ) ) ) { - settings.setValue( QStringLiteral( "Windows/PointCloudLayerProperties/tab" ), - mOptStackedWidget->indexOf( mOptsPage_Information ) ); + settings.setValue( QStringLiteral( "Windows/PointCloudLayerProperties/tab" ), mOptStackedWidget->indexOf( mOptsPage_Information ) ); } mBtnStyle = new QPushButton( tr( "Style" ) ); @@ -130,8 +129,7 @@ QgsPointCloudLayerProperties::QgsPointCloudLayerProperties( QgsPointCloudLayer * mStatisticsCalculationWarningLabel->setHidden( mLayer->statisticsCalculationState() != QgsPointCloudLayer::PointCloudStatisticsCalculationState::Calculated ); - connect( mLayer, &QgsPointCloudLayer::statisticsCalculationStateChanged, this, [this]( QgsPointCloudLayer::PointCloudStatisticsCalculationState state ) - { + connect( mLayer, &QgsPointCloudLayer::statisticsCalculationStateChanged, this, [this]( QgsPointCloudLayer::PointCloudStatisticsCalculationState state ) { mStatisticsCalculationWarningLabel->setHidden( state != QgsPointCloudLayer::PointCloudStatisticsCalculationState::Calculated ); } ); @@ -187,8 +185,7 @@ void QgsPointCloudLayerProperties::syncToLayer() txtSubsetSQL->setReadOnly( true ); txtSubsetSQL->setCaretWidth( 0 ); txtSubsetSQL->setCaretLineVisible( false ); - pbnQueryBuilder->setEnabled( mLayer->dataProvider() && - mLayer->dataProvider()->supportsSubsetString() ); + pbnQueryBuilder->setEnabled( mLayer->dataProvider() && mLayer->dataProvider()->supportsSubsetString() ); for ( QgsMapLayerConfigWidget *w : std::as_const( mConfigWidgets ) ) w->syncToLayer( mLayer ); @@ -245,7 +242,6 @@ QgsPointCloudAttributeStatisticsModel::QgsPointCloudAttributeStatisticsModel( Qg , mLayer( layer ) , mAttributes( layer->attributes() ) { - } int QgsPointCloudAttributeStatisticsModel::columnCount( const QModelIndex & ) const @@ -284,7 +280,6 @@ QVariant QgsPointCloudAttributeStatisticsModel::data( const QModelIndex &index, return stats.mean( attr.name() ); case StDev: return stats.stDev( attr.name() ); - } return QVariant(); } @@ -301,7 +296,6 @@ QVariant QgsPointCloudAttributeStatisticsModel::data( const QModelIndex &index, case Mean: case StDev: return static_cast( Qt::AlignRight | Qt::AlignVCenter ); - } return QVariant(); } @@ -400,9 +394,8 @@ QVariant QgsPointCloudClassificationStatisticsModel::data( const QModelIndex &in case Percent: { qint64 pointCount = stats.sampledPointsCount(); - return ( ( double )stats.availableClasses( mAttribute ).value( classValue.toInt(), 0 ) ) / pointCount * 100; + return ( ( double ) stats.availableClasses( mAttribute ).value( classValue.toInt(), 0 ) ) / pointCount * 100; } - } return QVariant(); } @@ -418,7 +411,6 @@ QVariant QgsPointCloudClassificationStatisticsModel::data( const QModelIndex &in case Count: case Percent: return QVariant( Qt::AlignRight | Qt::AlignVCenter ); - } return QVariant(); } @@ -458,4 +450,3 @@ QVariant QgsPointCloudClassificationStatisticsModel::headerData( int section, Qt } return QVariant(); } - diff --git a/src/app/pointcloud/qgspointcloudlayerproperties.h b/src/app/pointcloud/qgspointcloudlayerproperties.h index a7a57b745f94..9766845513f0 100644 --- a/src/app/pointcloud/qgspointcloudlayerproperties.h +++ b/src/app/pointcloud/qgspointcloudlayerproperties.h @@ -39,7 +39,6 @@ class QgsPointCloudAttributeStatisticsModel : public QAbstractTableModel Q_OBJECT public: - enum Columns { Name, @@ -53,10 +52,9 @@ class QgsPointCloudAttributeStatisticsModel : public QAbstractTableModel int columnCount( const QModelIndex &parent = QModelIndex() ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; - QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const override; - private: + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; + private: QgsPointCloudLayer *mLayer = nullptr; QgsPointCloudAttributeCollection mAttributes; }; @@ -66,7 +64,6 @@ class QgsPointCloudClassificationStatisticsModel : public QAbstractTableModel Q_OBJECT public: - enum Columns { Value, @@ -79,10 +76,9 @@ class QgsPointCloudClassificationStatisticsModel : public QAbstractTableModel int columnCount( const QModelIndex &parent = QModelIndex() ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; - QVariant headerData( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const override; - private: + QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; + private: QgsPointCloudLayer *mLayer = nullptr; QString mAttribute; QList mClassifications; @@ -115,7 +111,6 @@ class APP_EXPORT QgsPointCloudLayerProperties : public QgsLayerPropertiesDialog, QgsMetadataWidget *mMetadataWidget = nullptr; QgsCoordinateReferenceSystem mBackupCrs; - }; #endif // QGSPOINTCLOUDLAYERPROPERTIES_H diff --git a/src/app/pointcloud/qgspointcloudlayerstylewidget.cpp b/src/app/pointcloud/qgspointcloudlayerstylewidget.cpp index 7712deb30afe..c17d79ce109d 100644 --- a/src/app/pointcloud/qgspointcloudlayerstylewidget.cpp +++ b/src/app/pointcloud/qgspointcloudlayerstylewidget.cpp @@ -30,7 +30,7 @@ QgsPointCloudRendererWidgetFactory::QgsPointCloudRendererWidgetFactory( QObject QgsMapLayerConfigWidget *QgsPointCloudRendererWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *, bool, QWidget *parent ) const { - return new QgsPointCloudRendererPropertiesWidget( qobject_cast< QgsPointCloudLayer * >( layer ), QgsStyle::defaultStyle(), parent ); + return new QgsPointCloudRendererPropertiesWidget( qobject_cast( layer ), QgsStyle::defaultStyle(), parent ); } bool QgsPointCloudRendererWidgetFactory::supportLayerPropertiesDialog() const diff --git a/src/app/pointcloud/qgspointcloudlayerstylewidget.h b/src/app/pointcloud/qgspointcloudlayerstylewidget.h index eca524290341..2a4c12f1dab7 100644 --- a/src/app/pointcloud/qgspointcloudlayerstylewidget.h +++ b/src/app/pointcloud/qgspointcloudlayerstylewidget.h @@ -33,5 +33,4 @@ class QgsPointCloudRendererWidgetFactory : public QObject, public QgsMapLayerCon }; - #endif // QGSPOINTCLOUDLAYERSTYLEWIDGET_H diff --git a/src/app/project/qgsprojectelevationsettingswidget.cpp b/src/app/project/qgsprojectelevationsettingswidget.cpp index ed78f515f01c..b877475592d9 100644 --- a/src/app/project/qgsprojectelevationsettingswidget.cpp +++ b/src/app/project/qgsprojectelevationsettingswidget.cpp @@ -59,8 +59,7 @@ QgsProjectElevationSettingsWidget::QgsProjectElevationSettingsWidget( QWidget *p mStackedWidget->setSizeMode( QgsStackedWidget::SizeMode::CurrentPageOnly ); mStackedWidget->setCurrentWidget( mPageFlat ); - connect( mComboTerrainType, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ] - { + connect( mComboTerrainType, qOverload( &QComboBox::currentIndexChanged ), this, [=] { const QString terrainType = mComboTerrainType->currentData().toString(); if ( terrainType == QLatin1String( "flat" ) ) { @@ -91,24 +90,24 @@ QgsProjectElevationSettingsWidget::QgsProjectElevationSettingsWidget( QWidget *p mStackedWidget->setCurrentWidget( mPageRasterDem ); mDemOffsetSpinBox->setValue( provider->offset() ); mDemScaleSpinBox->setValue( provider->scale() ); - mComboDemLayer->setLayer( qgis::down_cast< const QgsRasterDemTerrainProvider * >( provider )->layer() ); + mComboDemLayer->setLayer( qgis::down_cast( provider )->layer() ); } else if ( provider->type() == QLatin1String( "mesh" ) ) { mStackedWidget->setCurrentWidget( mPageMesh ); mMeshOffsetSpinBox->setValue( provider->offset() ); mMeshScaleSpinBox->setValue( provider->scale() ); - mComboMeshLayer->setLayer( qgis::down_cast< const QgsMeshTerrainProvider * >( provider )->layer() ); + mComboMeshLayer->setLayer( qgis::down_cast( provider )->layer() ); } connect( mComboDemLayer, &QgsMapLayerComboBox::layerChanged, this, &QgsProjectElevationSettingsWidget::validate ); connect( mComboMeshLayer, &QgsMapLayerComboBox::layerChanged, this, &QgsProjectElevationSettingsWidget::validate ); - if ( elevationProperties->elevationRange().lower() != std::numeric_limits< double >::lowest() ) + if ( elevationProperties->elevationRange().lower() != std::numeric_limits::lowest() ) whileBlocking( mElevationLowerSpin )->setValue( elevationProperties->elevationRange().lower() ); else whileBlocking( mElevationLowerSpin )->clear(); - if ( elevationProperties->elevationRange().upper() != std::numeric_limits< double >::max() ) + if ( elevationProperties->elevationRange().upper() != std::numeric_limits::max() ) whileBlocking( mElevationUpperSpin )->setValue( elevationProperties->elevationRange().upper() ); else whileBlocking( mElevationUpperSpin )->clear(); @@ -128,40 +127,40 @@ QgsProjectElevationSettingsWidget::QgsProjectElevationSettingsWidget( QWidget *p void QgsProjectElevationSettingsWidget::apply() { const QString terrainType = mComboTerrainType->currentData().toString(); - std::unique_ptr< QgsAbstractTerrainProvider > provider; + std::unique_ptr provider; if ( terrainType == QLatin1String( "flat" ) ) { - provider = std::make_unique< QgsFlatTerrainProvider >(); + provider = std::make_unique(); provider->setOffset( mFlatHeightSpinBox->value() ); provider->setScale( 1.0 ); } else if ( terrainType == QLatin1String( "raster" ) ) { - provider = std::make_unique< QgsRasterDemTerrainProvider >(); + provider = std::make_unique(); provider->setOffset( mDemOffsetSpinBox->value() ); provider->setScale( mDemScaleSpinBox->value() ); - QgsRasterLayer *demLayer = qobject_cast< QgsRasterLayer * >( mComboDemLayer->currentLayer() ); + QgsRasterLayer *demLayer = qobject_cast( mComboDemLayer->currentLayer() ); // always mark the terrain layer as a "dem" layer -- it seems odd for a user to have to manually set this after picking a terrain raster! - qobject_cast< QgsRasterLayerElevationProperties * >( demLayer->elevationProperties() )->setEnabled( true ); - qobject_cast< QgsRasterLayerElevationProperties * >( demLayer->elevationProperties() )->setMode( Qgis::RasterElevationMode::RepresentsElevationSurface ); - qgis::down_cast< QgsRasterDemTerrainProvider * >( provider.get() )->setLayer( demLayer ); + qobject_cast( demLayer->elevationProperties() )->setEnabled( true ); + qobject_cast( demLayer->elevationProperties() )->setMode( Qgis::RasterElevationMode::RepresentsElevationSurface ); + qgis::down_cast( provider.get() )->setLayer( demLayer ); } else if ( terrainType == QLatin1String( "mesh" ) ) { - provider = std::make_unique< QgsMeshTerrainProvider >(); + provider = std::make_unique(); provider->setOffset( mMeshOffsetSpinBox->value() ); provider->setScale( mMeshScaleSpinBox->value() ); - qgis::down_cast< QgsMeshTerrainProvider * >( provider.get() )->setLayer( qobject_cast< QgsMeshLayer * >( mComboMeshLayer->currentLayer() ) ); + qgis::down_cast( provider.get() )->setLayer( qobject_cast( mComboMeshLayer->currentLayer() ) ); } QgsProject::instance()->elevationProperties()->setTerrainProvider( provider.release() ); double zLower = mElevationLowerSpin->value(); if ( zLower == mElevationLowerSpin->clearValue() ) - zLower = std::numeric_limits< double >::lowest(); + zLower = std::numeric_limits::lowest(); double zUpper = mElevationUpperSpin->value(); if ( zUpper == mElevationUpperSpin->clearValue() ) - zUpper = std::numeric_limits< double >::max(); + zUpper = std::numeric_limits::max(); QgsProject::instance()->elevationProperties()->setElevationRange( QgsDoubleRange( zLower, zUpper ) ); @@ -176,33 +175,24 @@ void QgsProjectElevationSettingsWidget::updateVerticalCrsOptions() { case Qgis::CrsType::Compound: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a compound CRS (%1), so the project's vertical CRS is the vertical component of this CRS (%2)." ).arg( - QgsProject::instance()->crs().userFriendlyIdentifier(), - QgsProject::instance()->verticalCrs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a compound CRS (%1), so the project's vertical CRS is the vertical component of this CRS (%2)." ).arg( QgsProject::instance()->crs().userFriendlyIdentifier(), QgsProject::instance()->verticalCrs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Geographic3d: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a geographic 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - QgsProject::instance()->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a geographic 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( QgsProject::instance()->crs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Geocentric: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a geocentric CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - QgsProject::instance()->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a geocentric CRS (%1), so the vertical CRS cannot be manually specified." ).arg( QgsProject::instance()->crs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Projected: if ( QgsProject::instance()->crs().hasVerticalAxis() ) { mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a projected 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - QgsProject::instance()->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Project coordinate reference system is set to a projected 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( QgsProject::instance()->crs().userFriendlyIdentifier() ) ); break; } [[fallthrough]]; diff --git a/src/app/project/qgsprojectelevationsettingswidget.h b/src/app/project/qgsprojectelevationsettingswidget.h index 49fc838fe9c7..517e95dba674 100644 --- a/src/app/project/qgsprojectelevationsettingswidget.h +++ b/src/app/project/qgsprojectelevationsettingswidget.h @@ -28,7 +28,6 @@ class QgsProjectElevationSettingsWidget : public QgsOptionsPageWidget, private U { Q_OBJECT public: - QgsProjectElevationSettingsWidget( QWidget *parent = nullptr ); public slots: @@ -43,7 +42,6 @@ class QgsProjectElevationSettingsWidget : public QgsOptionsPageWidget, private U private: QgsElevationShadingRendererSettingsWidget *mElevationShadingSettingsWidget = nullptr; QgsProjectionSelectionWidget *mVerticalCrsWidget = nullptr; - }; @@ -57,5 +55,4 @@ class QgsProjectElevationSettingsWidgetFactory : public QgsOptionsWidgetFactory }; - #endif // QGSPROJECTELEVATIONSETTINGSWIDGET_H diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 84703b00257b..16e89d081125 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -501,7 +501,7 @@ #ifdef HAVE_PDAL_QGIS #include -#if PDAL_VERSION_MAJOR_INT > 2 || (PDAL_VERSION_MAJOR_INT == 2 && PDAL_VERSION_MINOR_INT >= 5) +#if PDAL_VERSION_MAJOR_INT > 2 || ( PDAL_VERSION_MAJOR_INT == 2 && PDAL_VERSION_MINOR_INT >= 5 ) #include "qgspdalalgorithms.h" #endif #endif @@ -691,7 +691,7 @@ void QgisApp::layerTreeViewDoubleClicked( const QModelIndex &index ) if ( !originalSymbol ) return; - std::unique_ptr< QgsSymbol > symbol( originalSymbol->clone() ); + std::unique_ptr symbol( originalSymbol->clone() ); QgsVectorLayer *vlayer = qobject_cast( node->layerNode()->layer() ); QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, this ); QgsSymbolWidgetContext context; @@ -713,7 +713,7 @@ void QgisApp::layerTreeViewDoubleClicked( const QModelIndex &index ) case 1: { QgsSettings settings; - QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ); + QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ); QgisApp::instance()->attributeTable( initialMode ); break; } @@ -730,7 +730,7 @@ void QgisApp::onActiveLayerChanged( QgsMapLayer *layer ) if ( mBlockActiveLayerChanged ) return; - const QList< QgsMapCanvas * > canvases = mapCanvases(); + const QList canvases = mapCanvases(); for ( QgsMapCanvas *canvas : canvases ) canvas->setCurrentLayer( layer ); @@ -837,8 +837,7 @@ void QgisApp::annotationItemTypeAdded( int id ) mAnnotationsToolBar->insertAction( mAnnotationsItemInsertBefore, action ); } - connect( action, &QAction::toggled, this, [this, action, id]( bool checked ) - { + connect( action, &QAction::toggled, this, [this, action, id]( bool checked ) { if ( !checked ) return; @@ -851,16 +850,15 @@ void QgisApp::annotationItemTypeAdded( int id ) tool->mapTool()->setAction( action ); mMapCanvas->setMapTool( tool->mapTool() ); - if ( qobject_cast< QgsMapToolCapture * >( tool->mapTool() ) ) + if ( qobject_cast( tool->mapTool() ) ) { mDigitizingTechniqueManager->enableDigitizingTechniqueActions( checked, action ); } connect( tool->mapTool(), &QgsMapTool::deactivated, tool->mapTool(), &QObject::deleteLater ); - connect( tool->handler(), &QgsCreateAnnotationItemMapToolHandler::itemCreated, this, [ = ] - { + connect( tool->handler(), &QgsCreateAnnotationItemMapToolHandler::itemCreated, this, [=] { QgsAnnotationItem *item = tool->handler()->takeCreatedItem(); - QgsAnnotationLayer *targetLayer = qobject_cast< QgsAnnotationLayer * >( activeLayer() ); + QgsAnnotationLayer *targetLayer = qobject_cast( activeLayer() ); if ( !targetLayer ) targetLayer = QgsProject::instance()->mainAnnotationLayer(); @@ -980,7 +978,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers QMessageBox::critical( this, tr( "Multiple Instances of QgisApp" ), - tr( "Multiple instances of QGIS application object detected.\nPlease contact the developers.\n" ) ); + tr( "Multiple instances of QGIS application object detected.\nPlease contact the developers.\n" ) + ); abort(); } @@ -1011,12 +1010,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers setDockOptions( dockOptions() | QMainWindow::GroupedDragging ); - QgsDockableWidgetHelper::sAddTabifiedDockWidgetFunction = []( Qt::DockWidgetArea dockArea, QDockWidget * dock, const QStringList & tabSiblings, bool raiseTab ) - { + QgsDockableWidgetHelper::sAddTabifiedDockWidgetFunction = []( Qt::DockWidgetArea dockArea, QDockWidget *dock, const QStringList &tabSiblings, bool raiseTab ) { QgisApp::instance()->addTabifiedDockWidget( dockArea, dock, tabSiblings, raiseTab ); }; - QgsDockableWidgetHelper::sAppStylesheetFunction = []()->QString - { + QgsDockableWidgetHelper::sAppStylesheetFunction = []() -> QString { return QgisApp::instance()->styleSheet(); }; QgsDockableWidgetHelper::sOwnerWindow = QgisApp::instance(); @@ -1060,8 +1057,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers startProfile( tr( "Building style sheet" ) ); // set up stylesheet builder and apply saved or default style options mStyleSheetBuilder = new QgisAppStyleSheet( this ); - connect( mStyleSheetBuilder, &QgisAppStyleSheet::appStyleSheetChanged, - this, &QgisApp::setAppStyleSheet ); + connect( mStyleSheetBuilder, &QgisAppStyleSheet::appStyleSheetChanged, this, &QgisApp::setAppStyleSheet ); endProfile(); QWidget *centralWidget = this->centralWidget(); @@ -1111,26 +1107,22 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers startProfile( tr( "Welcome page" ) ); mWelcomePage = new QgsWelcomePage( skipVersionCheck ); - connect( mWelcomePage, &QgsWelcomePage::projectRemoved, this, [ this ]( int row ) - { + connect( mWelcomePage, &QgsWelcomePage::projectRemoved, this, [this]( int row ) { mRecentProjects.removeAt( row ); saveRecentProjects(); updateRecentProjectPaths(); } ); - connect( mWelcomePage, &QgsWelcomePage::projectPinned, this, [ this ]( int row ) - { + connect( mWelcomePage, &QgsWelcomePage::projectPinned, this, [this]( int row ) { mRecentProjects.at( row ).pin = true; saveRecentProjects(); updateRecentProjectPaths(); } ); - connect( mWelcomePage, &QgsWelcomePage::projectUnpinned, this, [ this ]( int row ) - { + connect( mWelcomePage, &QgsWelcomePage::projectUnpinned, this, [this]( int row ) { mRecentProjects.at( row ).pin = false; saveRecentProjects(); updateRecentProjectPaths(); } ); - connect( mWelcomePage, &QgsWelcomePage::projectsCleared, this, [ this ]( bool clearPinned ) - { + connect( mWelcomePage, &QgsWelcomePage::projectsCleared, this, [this]( bool clearPinned ) { if ( clearPinned ) { mRecentProjects.clear(); @@ -1141,9 +1133,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers std::remove_if( mRecentProjects.begin(), mRecentProjects.end(), - []( const QgsRecentProjectItemsModel::RecentProjectData & recentProject ) { return !recentProject.pin; } + []( const QgsRecentProjectItemsModel::RecentProjectData &recentProject ) { return !recentProject.pin; } ), - mRecentProjects.end() + mRecentProjects.end() ); } saveRecentProjects(); @@ -1230,7 +1222,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers showBookmarksDock->setWhatsThis( tr( "Show Bookmarks Panel" ) ); mBookMarksDockWidget->setToggleVisibilityAction( mActionShowBookmarkManager ); - connect( mActionShowBookmarks, &QAction::triggered, this, [ = ] { showBookmarks(); } ); + connect( mActionShowBookmarks, &QAction::triggered, this, [=] { showBookmarks(); } ); endProfile(); @@ -1251,7 +1243,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers addDockWidget( Qt::LeftDockWidgetArea, mVertexEditorDock ); mVertexEditorDock->hide(); - mMapTools = std::make_unique< QgsAppMapTools >( mMapCanvas, mAdvancedDigitizingDockWidget ); + mMapTools = std::make_unique( mMapCanvas, mAdvancedDigitizingDockWidget ); mDigitizingTechniqueManager = new QgsMapToolsDigitizingTechniqueManager( this ); QgsGui::mapToolShapeRegistry()->addMapTool( new QgsMapToolShapeCircularStringRadiusMetadata() ); @@ -1296,8 +1288,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers mGeometryValidationDock = new QgsGeometryValidationDock( tr( "Geometry Validation" ), mMapCanvas, this ); mGeometryValidationDock->hide(); mGeometryValidationModel = new QgsGeometryValidationModel( mGeometryValidationService.get(), mGeometryValidationDock ); - connect( this, &QgisApp::activeLayerChanged, mGeometryValidationModel, [this]( QgsMapLayer * layer ) - { + connect( this, &QgisApp::activeLayerChanged, mGeometryValidationModel, [this]( QgsMapLayer *layer ) { mGeometryValidationModel->setCurrentLayer( qobject_cast( layer ) ); } ); mGeometryValidationDock->setGeometryValidationModel( mGeometryValidationModel ); @@ -1309,8 +1300,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers mSaveRollbackInProgress = false; - QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); + QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); if ( !QFileInfo::exists( templateDirName ) ) { // create default template directory @@ -1361,8 +1351,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mInfoBar, mMapLayerPanelFactories ); mMapStylingDock->setWidget( mMapStyleWidget ); connect( mMapStyleWidget, &QgsLayerStylingWidget::styleChanged, this, &QgisApp::updateLabelToolButtons ); - connect( mMapStyleWidget, &QgsLayerStylingWidget::layerStyleChanged, this, [ = ]( const QString & styleName ) - { + connect( mMapStyleWidget, &QgsLayerStylingWidget::layerStyleChanged, this, [=]( const QString &styleName ) { if ( !QgsMapLayerStyleManager::isDefault( styleName ) && !styleName.isEmpty() ) { mMapStylingDock->setWindowTitle( tr( "Layer Styling (%1)" ).arg( styleName ) ); @@ -1391,7 +1380,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers const QString lastDevToolsTab = QgsDevToolsPanelWidget::settingLastActiveTab->value(); mDevToolsWidget = new QgsDevToolsPanelWidget( mDevToolFactories ); mDevToolsDock->setWidget( mDevToolsWidget ); -// connect( mDevToolsDock, &QDockWidget::visibilityChanged, mActionStyleDock, &QAction::setChecked ); + // connect( mDevToolsDock, &QDockWidget::visibilityChanged, mActionStyleDock, &QAction::setChecked ); addDockWidget( Qt::RightDockWidgetArea, mDevToolsDock ); mDevToolsDock->hide(); @@ -1399,7 +1388,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers startProfile( tr( "Snapping dialog" ) ); mSnappingDialog = new QgsSnappingWidget( QgsProject::instance(), mMapCanvas, this ); - connect( mSnappingDialog, &QgsSnappingWidget::snappingConfigChanged, QgsProject::instance(), [ = ] { QgsProject::instance()->setSnappingConfig( mSnappingDialog->config() ); } ); + connect( mSnappingDialog, &QgsSnappingWidget::snappingConfigChanged, QgsProject::instance(), [=] { QgsProject::instance()->setSnappingConfig( mSnappingDialog->config() ); } ); QString mainSnappingWidgetMode = QgsSettings().value( QStringLiteral( "/qgis/mainSnappingWidgetMode" ), "dialog" ).toString(); if ( mainSnappingWidgetMode == QLatin1String( "dock" ) ) { @@ -1460,32 +1449,29 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget ); mBrowserWidget->hide(); // Only connect the first widget: the model is shared, there is no need to refresh multiple times. - connect( this, &QgisApp::connectionsChanged, mBrowserWidget, [ = ] - { + connect( this, &QgisApp::connectionsChanged, mBrowserWidget, [=] { if ( !mBlockBrowser1Refresh && !mBlockBrowser2Refresh ) mBrowserWidget->refresh(); } ); - connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, [ = ] - { + connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, [=] { mBlockBrowser1Refresh++; emit connectionsChanged(); mBlockBrowser1Refresh--; } ); - connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, [this]( const QString & file ) { openFile( file ); } ); - connect( mBrowserWidget, &QgsBrowserDockWidget::handleDropUriList, this, [this]( const QgsMimeDataUtils::UriList & list ) { handleDropUriList( list ); } ); + connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, [this]( const QString &file ) { openFile( file ); } ); + connect( mBrowserWidget, &QgsBrowserDockWidget::handleDropUriList, this, [this]( const QgsMimeDataUtils::UriList &list ) { handleDropUriList( list ); } ); mBrowserWidget2 = new QgsBrowserDockWidget( tr( "Browser (2)" ), mBrowserModel, this ); mBrowserWidget2->setObjectName( QStringLiteral( "Browser2" ) ); addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget2 ); mBrowserWidget2->hide(); - connect( mBrowserWidget2, &QgsBrowserDockWidget::connectionsChanged, this, [ = ] - { + connect( mBrowserWidget2, &QgsBrowserDockWidget::connectionsChanged, this, [=] { mBlockBrowser2Refresh++; emit connectionsChanged(); mBlockBrowser2Refresh--; } ); - connect( mBrowserWidget2, &QgsBrowserDockWidget::openFile, this, [this]( const QString & file ) { openFile( file ); } ); - connect( mBrowserWidget2, &QgsBrowserDockWidget::handleDropUriList, this, [this]( const QgsMimeDataUtils::UriList & list ) { handleDropUriList( list ); } ); + connect( mBrowserWidget2, &QgsBrowserDockWidget::openFile, this, [this]( const QString &file ) { openFile( file ); } ); + connect( mBrowserWidget2, &QgsBrowserDockWidget::handleDropUriList, this, [this]( const QgsMimeDataUtils::UriList &list ) { handleDropUriList( list ); } ); addDockWidget( Qt::LeftDockWidgetArea, mAdvancedDigitizingDockWidget ); mAdvancedDigitizingDockWidget->hide(); @@ -1525,7 +1511,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers connect( mGpsSettingsMenu, &QgsAppGpsSettingsMenu::nmeaLogFileChanged, mGpsLogging, &QgsAppGpsLogging::setNmeaLogFile ); connect( mGpsSettingsMenu, &QgsAppGpsSettingsMenu::gpkgLogDestinationChanged, mGpsLogging, &QgsAppGpsLogging::setGpkgLogFile ); connect( mGpsLogging, &QgsAppGpsLogging::gpkgLoggingFailed, mGpsSettingsMenu, &QgsAppGpsSettingsMenu::onGpkgLoggingFailed ); - connect( mGpsDigitizing, &QgsAppGpsDigitizing::trackIsEmptyChanged, mGpsToolBar, [ = ]( bool isEmpty ) { mGpsToolBar->setResetTrackButtonEnabled( !isEmpty ); } ); + connect( mGpsDigitizing, &QgsAppGpsDigitizing::trackIsEmptyChanged, mGpsToolBar, [=]( bool isEmpty ) { mGpsToolBar->setResetTrackButtonEnabled( !isEmpty ); } ); mpGpsWidget = new QgsGpsInformationWidget( mGpsConnection, mMapCanvas, mGpsDigitizing ); QgsPanelWidgetStack *gpsStack = new QgsPanelWidgetStack(); @@ -1561,7 +1547,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers mLogDock->hide(); connect( mMessageButton, &QAbstractButton::toggled, mLogDock, &QgsDockWidget::setUserVisible ); connect( mLogDock, &QgsDockWidget::visibilityChanged, mMessageButton, &QAbstractButton::setChecked ); - connect( QgsApplication::messageLog(), static_cast < void ( QgsMessageLog::* )( bool ) >( &QgsMessageLog::messageReceived ), this, &QgisApp::toggleLogMessageIcon ); + connect( QgsApplication::messageLog(), static_cast( &QgsMessageLog::messageReceived ), this, &QgisApp::toggleLogMessageIcon ); connect( mMessageButton, &QAbstractButton::toggled, this, &QgisApp::toggleLogMessageIcon ); mVectorLayerTools = new QgsGuiVectorLayerTools(); mVectorLayerTools->setProject( QgsProject::instance() ); @@ -1596,11 +1582,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers // QgsMessageLog::logMessage( tr( "QGIS starting…" ), QString(), Qgis::MessageLevel::Info ); - connect( QgsProject::instance(), &QgsProject::isDirtyChanged, this, [ = ] { setTitleBarText_( *this ); } ); + connect( QgsProject::instance(), &QgsProject::isDirtyChanged, this, [=] { setTitleBarText_( *this ); } ); // set QGIS specific srs validation - connect( this, &QgisApp::customCrsValidation, - this, &QgisApp::validateCrs ); + connect( this, &QgisApp::customCrsValidation, this, &QgisApp::validateCrs ); QgsCoordinateReferenceSystem::setCustomCrsValidation( customSrsValidation_ ); // set graphical message output @@ -1610,7 +1595,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers new QgsCredentialDialog( this ); mLocatorWidget->setMapCanvas( mMapCanvas ); - connect( mLocatorWidget, &QgsLocatorWidget::configTriggered, this, [ = ] { showOptionsDialog( this, QStringLiteral( "mOptionsLocatorSettings" ) ); } ); + connect( mLocatorWidget, &QgsLocatorWidget::configTriggered, this, [=] { showOptionsDialog( this, QStringLiteral( "mOptionsLocatorSettings" ) ); } ); qApp->processEvents(); @@ -1664,7 +1649,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers // populate annotation toolbar with initial items... - const QList< int > itemMetadataIds = QgsGui::annotationItemGuiRegistry()->itemMetadataIds(); + const QList itemMetadataIds = QgsGui::annotationItemGuiRegistry()->itemMetadataIds(); for ( int id : itemMetadataIds ) { annotationItemTypeAdded( id ); @@ -1852,39 +1837,31 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers connect( QgsApplication::taskManager(), &QgsTaskManager::statusChanged, this, &QgisApp::onTaskCompleteShowNotify ); - QgsGui::nativePlatformInterface()->initializeMainWindow( windowHandle(), - QgsApplication::applicationName(), - QgsApplication::organizationName(), - Qgis::version() ); + QgsGui::nativePlatformInterface()->initializeMainWindow( windowHandle(), QgsApplication::applicationName(), QgsApplication::organizationName(), Qgis::version() ); connect( QgsGui::nativePlatformInterface(), &QgsNative::usbStorageNotification, mBrowserModel, &QgsBrowserModel::refreshDrives ); // setup application progress reports from task manager - connect( QgsApplication::taskManager(), &QgsTaskManager::taskAdded, this, [] - { + connect( QgsApplication::taskManager(), &QgsTaskManager::taskAdded, this, [] { QgsGui::nativePlatformInterface()->showUndefinedApplicationProgress(); } ); - connect( QgsApplication::taskManager(), &QgsTaskManager::finalTaskProgressChanged, this, []( double val ) - { + connect( QgsApplication::taskManager(), &QgsTaskManager::finalTaskProgressChanged, this, []( double val ) { QgsGui::nativePlatformInterface()->setApplicationProgress( val ); } ); - connect( QgsApplication::taskManager(), &QgsTaskManager::allTasksFinished, this, [] - { + connect( QgsApplication::taskManager(), &QgsTaskManager::allTasksFinished, this, [] { QgsGui::nativePlatformInterface()->hideApplicationProgress(); } ); - connect( QgsApplication::taskManager(), &QgsTaskManager::countActiveTasksChanged, this, []( int count ) - { + connect( QgsApplication::taskManager(), &QgsTaskManager::countActiveTasksChanged, this, []( int count ) { QgsGui::nativePlatformInterface()->setApplicationBadgeCount( count ); } ); - ( void )new QgsAppMissingGridHandler( this ); + ( void ) new QgsAppMissingGridHandler( this ); // supposedly all actions have been added, now register them to the shortcut manager QgsGui::shortcutsManager()->registerAllChildren( this ); QgsGui::shortcutsManager()->registerAllChildren( mSnappingWidget ); // register additional action - auto registerShortcuts = [ = ]( const QString & sequence, const QString & objectName, const QString & whatsThis ) - { + auto registerShortcuts = [=]( const QString &sequence, const QString &objectName, const QString &whatsThis ) { QShortcut *sc = new QShortcut( QKeySequence( sequence ), this ); sc->setContext( Qt::ApplicationShortcut ); sc->setObjectName( objectName ); @@ -1906,8 +1883,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers registerShortcuts( QStringLiteral( "Ctrl+Shift+E" ), QStringLiteral( "m3DSetSceneExtent" ), tr( "Set 3D Scene Extent on 2D Map View" ) ); connect( QgsProject::instance()->viewsManager(), &QgsMapViewsManager::views3DListChanged, this, &QgisApp::views3DMenuAboutToShow ); - Qgs3DMapScene::sOpenScenesFunction = [this]() -> QMap< QString, Qgs3DMapScene * > - { + Qgs3DMapScene::sOpenScenesFunction = [this]() -> QMap { return map3DScenes(); }; #endif @@ -1924,24 +1900,22 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers mBearingNumericFormat.reset( QgsLocalDefaultSettings::bearingFormat() ); - mNetworkLoggerWidgetFactory.reset( std::make_unique< QgsNetworkLoggerWidgetFactory >( mNetworkLogger ) ); - mQueryLoggerWidgetFactory.reset( std::make_unique< QgsDatabaseQueryLoggerWidgetFactory >( mQueryLogger ) ); + mNetworkLoggerWidgetFactory.reset( std::make_unique( mNetworkLogger ) ); + mQueryLoggerWidgetFactory.reset( std::make_unique( mQueryLogger ) ); // update windows qApp->processEvents(); // notify user if authentication system is disabled - ( void )QgsAuthGuiUtils::isDisabled( messageBar() ); + ( void ) QgsAuthGuiUtils::isDisabled( messageBar() ); startProfile( tr( "New project" ) ); fileNewBlank(); // prepare empty project, also skips any default templates from loading updateCrsStatusBar(); endProfile(); - connect( qobject_cast< QgsMapToolModifyAnnotation * >( mMapTools->mapTool( QgsAppMapTools::AnnotationEdit ) ), &QgsMapToolModifyAnnotation::itemSelected, - mMapStyleWidget, &QgsLayerStylingWidget::setAnnotationItem ); - connect( qobject_cast< QgsMapToolModifyAnnotation * >( mMapTools->mapTool( QgsAppMapTools::AnnotationEdit ) ), &QgsMapToolModifyAnnotation::selectionCleared, - mMapStyleWidget, [this] { mMapStyleWidget->setAnnotationItem( nullptr, QString() ); } ); + connect( qobject_cast( mMapTools->mapTool( QgsAppMapTools::AnnotationEdit ) ), &QgsMapToolModifyAnnotation::itemSelected, mMapStyleWidget, &QgsLayerStylingWidget::setAnnotationItem ); + connect( qobject_cast( mMapTools->mapTool( QgsAppMapTools::AnnotationEdit ) ), &QgsMapToolModifyAnnotation::selectionCleared, mMapStyleWidget, [this] { mMapStyleWidget->setAnnotationItem( nullptr, QString() ); } ); // request notification of FileOpen events (double clicking a file icon in Mac OS X Finder) // should come after fileNewBlank to ensure project is properly set up to receive any data source files @@ -1951,17 +1925,15 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers toggleFullScreen(); #endif - mStartupProfilerWidgetFactory.reset( std::make_unique< QgsProfilerWidgetFactory >( profiler ) ); + mStartupProfilerWidgetFactory.reset( std::make_unique( profiler ) ); - auto toggleRevert = [ = ] - { - mActionRevertProject->setEnabled( QgsProject::instance()->isDirty() &&!QgsProject::instance()->fileName().isEmpty() ); + auto toggleRevert = [=] { + mActionRevertProject->setEnabled( QgsProject::instance()->isDirty() && !QgsProject::instance()->fileName().isEmpty() ); }; connect( QgsProject::instance(), &QgsProject::isDirtyChanged, mActionRevertProject, toggleRevert ); connect( QgsProject::instance(), &QgsProject::fileNameChanged, mActionRevertProject, toggleRevert ); - connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::bearingFormatChanged, this, [ = ] - { + connect( QgsProject::instance()->displaySettings(), &QgsProjectDisplaySettings::bearingFormatChanged, this, [=] { mBearingNumericFormat.reset( QgsProject::instance()->displaySettings()->bearingFormat()->clone() ); } ); connect( mMapCanvas, &QgsMapCanvas::panDistanceBearingChanged, this, &QgisApp::showPanMessage ); @@ -1969,44 +1941,40 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers // the most important part of the initialization: make sure that people can play puzzle if they need QgsPuzzleWidget *puzzleWidget = new QgsPuzzleWidget( mMapCanvas ); mCentralContainer->insertWidget( 2, puzzleWidget ); - connect( mCoordsEdit, &QgsStatusBarCoordinatesWidget::weAreBored, this, [ this, puzzleWidget ] - { + connect( mCoordsEdit, &QgsStatusBarCoordinatesWidget::weAreBored, this, [this, puzzleWidget] { if ( puzzleWidget->letsGetThePartyStarted() ) mCentralContainer->setCurrentIndex( 2 ); } ); - connect( puzzleWidget, &QgsPuzzleWidget::done, this, [ this ] - { + connect( puzzleWidget, &QgsPuzzleWidget::done, this, [this] { mCentralContainer->setCurrentIndex( 0 ); } ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsIdeOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsCodeEditorOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsRenderingOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsVectorRenderingOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsRasterRenderingOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsGpsOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsGpsDeviceOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsCustomProjectionOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsElevationOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsFontOptionsFactory >() ) ); - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< QgsUserProfileOptionsFactory >() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); #ifdef HAVE_3D - mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique< Qgs3DOptionsFactory >() ) ); + mOptionWidgetFactories.emplace_back( QgsScopedOptionsWidgetFactory( std::make_unique() ) ); #endif mAppCanvasFiltering = new QgsAppCanvasFiltering( this ); mAppCanvasFiltering->setupElevationControllerAction( mActionElevationController, mMapCanvas ); - connect( QgsApplication::fontManager(), &QgsFontManager::fontDownloaded, this, [ = ]( const QStringList & families, const QString & licenseDetails ) - { + connect( QgsApplication::fontManager(), &QgsFontManager::fontDownloaded, this, [=]( const QStringList &families, const QString &licenseDetails ) { const QString shortMessage = tr( "Installed font %1" ).arg( families.join( QLatin1String( ", " ) ) ); QgsMessageBarItem *messageWidget = QgsMessageBar::createMessage( QString(), shortMessage ); if ( !licenseDetails.isEmpty() ) { QPushButton *detailsButton = new QPushButton( tr( "View License" ) ); - connect( detailsButton, &QPushButton::clicked, this, [detailsButton, licenseDetails] - { + connect( detailsButton, &QPushButton::clicked, this, [detailsButton, licenseDetails] { QgsMessageViewer *dialog = new QgsMessageViewer( detailsButton ); dialog->setTitle( tr( "Font License" ) ); dialog->setMessage( licenseDetails, QgsMessageOutput::MessageText ); @@ -2017,21 +1985,19 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers messageBar()->pushWidget( messageWidget, Qgis::MessageLevel::Info, 0 ); // refresh canvas to get proper rendering using that font - const QList< QgsMapCanvas * > canvases = mapCanvases(); + const QList canvases = mapCanvases(); for ( QgsMapCanvas *canvas : canvases ) canvas->refreshAllLayers(); } ); - connect( QgsApplication::fontManager(), &QgsFontManager::fontDownloadErrorOccurred, this, [ = ]( const QUrl &, const QString & identifier, const QString & error ) - { + connect( QgsApplication::fontManager(), &QgsFontManager::fontDownloadErrorOccurred, this, [=]( const QUrl &, const QString &identifier, const QString &error ) { const QString shortMessage = identifier.isEmpty() ? tr( "Font installation failed" ) - : tr( "%1 font installation failed" ).arg( identifier ); + : tr( "%1 font installation failed" ).arg( identifier ); QgsMessageBarItem *messageWidget = QgsMessageBar::createMessage( QString(), shortMessage ); if ( !error.isEmpty() ) { QPushButton *detailsButton = new QPushButton( tr( "View Error" ) ); - connect( detailsButton, &QPushButton::clicked, this, [error] - { + connect( detailsButton, &QPushButton::clicked, this, [error] { QgsMessageViewer *dialog = new QgsMessageViewer( nullptr, QgsGuiUtils::ModalDialogFlags, true ); dialog->setTitle( tr( "Font Install Failed" ) ); dialog->setMessage( error, QgsMessageOutput::MessageText ); @@ -2054,25 +2020,22 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers QgsMessageBarItem *messageWidget = QgsMessageBar::createMessage( QString(), shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "More Info" ) ); - connect( detailsButton, &QPushButton::clicked, this, [detailsButton] - { + connect( detailsButton, &QPushButton::clicked, this, [detailsButton] { QgsMessageViewer *dialog = new QgsMessageViewer( detailsButton ); dialog->setTitle( tr( "Wayland Session Detected" ) ); // NOTE: black coloring MUST be specified here or the message shows white-on-white on wayland sessions 🙃 - const QString warning = QStringLiteral( "

    %1

    %2

    " ).arg( - tr( "Running QGIS in a Wayland session will result " - "in a degraded experience due to limitations in the " - "underlying Qt library and current versions of the Wayland protocol." ), - tr( "It is highly recommended that you switch to a traditional X11 session " - "for an optimal user experience." ) ); + const QString warning = QStringLiteral( "

    %1

    %2

    " ).arg( tr( "Running QGIS in a Wayland session will result " + "in a degraded experience due to limitations in the " + "underlying Qt library and current versions of the Wayland protocol." ), + tr( "It is highly recommended that you switch to a traditional X11 session " + "for an optimal user experience." ) ); dialog->setMessageAsHtml( warning ); dialog->showMessage(); } ); messageWidget->layout()->addWidget( detailsButton ); QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ) ); - connect( ignoreButton, &QPushButton::clicked, this, [this, messageWidget] - { + connect( ignoreButton, &QPushButton::clicked, this, [this, messageWidget] { QgsSettings().setValue( QStringLiteral( "/UI/displayWaylandWarning" ), false ); messageBar()->popWidget( messageWidget ); } ); @@ -2110,7 +2073,7 @@ QgisApp::QgisApp() mPanelMenu = new QMenu( this ); mProgressBar = new QProgressBar( this ); mStatusBar = new QgsStatusBar( this ); - mMapTools = std::make_unique< QgsAppMapTools >( mMapCanvas, mAdvancedDigitizingDockWidget ); + mMapTools = std::make_unique( mMapCanvas, mAdvancedDigitizingDockWidget ); mDigitizingTechniqueManager = new QgsMapToolsDigitizingTechniqueManager( this ); mVectorLayerTools = new QgsGuiVectorLayerTools(); @@ -2186,7 +2149,7 @@ QgisApp::~QgisApp() removeAnnotationItems(); // these need to be gracefully cleaned up before QgsApplication::exitQgis() - const QList browserPropertyDialogs = findChildren< QgsBrowserPropertiesDialog * >(); + const QList browserPropertyDialogs = findChildren(); for ( QgsBrowserPropertiesDialog *widget : browserPropertyDialogs ) { delete widget; @@ -2206,7 +2169,7 @@ QgisApp::~QgisApp() qDeleteAll( mCustomDropHandlers ); qDeleteAll( mCustomLayoutDropHandlers ); - const QList elevationProfileWidgets = findChildren< QgsElevationProfileWidget * >(); + const QList elevationProfileWidgets = findChildren(); for ( QgsElevationProfileWidget *widget : elevationProfileWidgets ) { widget->cancelJobs(); @@ -2261,7 +2224,7 @@ void QgisApp::dragEnterEvent( QDragEnterEvent *event ) } // check if any custom handlers can operate on the data - const QVector> handlers = mCustomDropHandlers; + const QVector> handlers = mCustomDropHandlers; for ( QgsCustomDropHandler *handler : handlers ) { if ( handler && handler->canHandleMimeData( event->mimeData() ) ) @@ -2289,7 +2252,7 @@ void QgisApp::dropEvent( QDropEvent *event ) } // first, allow custom handlers to directly operate on the mime data - const QVector> handlers = mCustomDropHandlers; + const QVector> handlers = mCustomDropHandlers; for ( QgsCustomDropHandler *handler : handlers ) { if ( handler ) @@ -2309,7 +2272,7 @@ void QgisApp::dropEvent( QDropEvent *event ) // get the file list QList::iterator i; - QListurls = event->mimeData()->urls(); + QList urls = event->mimeData()->urls(); QStringList files; for ( i = urls.begin(); i != urls.end(); ++i ) { @@ -2328,8 +2291,7 @@ void QgisApp::dropEvent( QDropEvent *event ) lst = QgsMimeDataUtils::decodeUriList( event->mimeData() ); } - connect( timer, &QTimer::timeout, this, [this, timer, files, lst, method] - { + connect( timer, &QTimer::timeout, this, [this, timer, files, lst, method] { QgsCanvasRefreshBlocker refreshBlocker; // Prevent autoSelectAddedLayer() to do any work during the iteration on @@ -2337,13 +2299,13 @@ void QgisApp::dropEvent( QDropEvent *event ) // cf https://github.com/qgis/QGIS/issues/49439 mBlockAutoSelectAddedLayer = true; - QList< QgsMapLayer * > addedLayers; + QList addedLayers; for ( const QString &file : std::as_const( files ) ) { bool handled = false; // give custom drop handlers first priority at handling the file - const QVector> handlers = mCustomDropHandlers; + const QVector> handlers = mCustomDropHandlers; for ( QgsCustomDropHandler *handler : handlers ) { if ( handler && handler->handleFileDrop( file ) ) @@ -2432,7 +2394,7 @@ void QgisApp::unregisterCustomProjectOpenHandler( QgsCustomProjectOpenHandler *h mCustomProjectOpenHandlers.removeOne( handler ); } -QVector > QgisApp::customDropHandlers() const +QVector> QgisApp::customDropHandlers() const { return mCustomDropHandlers; } @@ -2448,12 +2410,12 @@ void QgisApp::unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *han mCustomLayoutDropHandlers.removeOne( handler ); } -QVector > QgisApp::customLayoutDropHandlers() const +QVector> QgisApp::customLayoutDropHandlers() const { return mCustomLayoutDropHandlers; } -QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst, bool suppressBulkLayerPostProcessing, bool addToLegend ) +QList QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst, bool suppressBulkLayerPostProcessing, bool addToLegend ) { // avoid unnecessary work when adding lots of layers at once - defer emitting the active layer changed signal until we've // added all layers, and only emit the signal once for the final layer added @@ -2462,13 +2424,11 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi QgsScopedProxyProgressTask task( tr( "Loading layers" ) ); - auto showLayerLoadWarnings = [ = ]( const QString & title, const QString & shortMessage, const QString & longMessage, Qgis::MessageLevel level ) - { + auto showLayerLoadWarnings = [=]( const QString &title, const QString &shortMessage, const QString &longMessage, Qgis::MessageLevel level ) { QgsMessageBarItem *messageWidget = QgsMessageBar::createMessage( title, shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "Details" ) ); - connect( detailsButton, &QPushButton::clicked, this, [ = ] - { - if ( QgsMessageViewer *dialog = dynamic_cast< QgsMessageViewer * >( QgsMessageOutput::createMessageOutput() ) ) + connect( detailsButton, &QPushButton::clicked, this, [=] { + if ( QgsMessageViewer *dialog = dynamic_cast( QgsMessageOutput::createMessageOutput() ) ) { dialog->setTitle( title ); dialog->setMessage( longMessage, QgsMessageOutput::MessageHtml ); @@ -2480,9 +2440,9 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi }; // insert items in reverse order as each one is inserted on top of previous one - QList< QgsMapLayer * > addedLayers; + QList addedLayers; int count = 0; - for ( int i = lst.size() - 1 ; i >= 0 ; i--, count++ ) + for ( int i = lst.size() - 1; i >= 0; i--, count++ ) { const QgsMimeDataUtils::Uri &u = lst.at( i ); @@ -2491,7 +2451,7 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi if ( u.layerType == QLatin1String( "collection" ) ) { bool ok = false; - const QList< QgsMapLayer * > collectionLayers = QgsAppLayerHandling::openLayer( uri, ok, true, true, addToLegend ); + const QList collectionLayers = QgsAppLayerHandling::openLayer( uri, ok, true, true, addToLegend ); if ( ok ) addedLayers.append( collectionLayers ); } @@ -2542,7 +2502,7 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi QString error; QStringList warnings; - QList< QgsMapLayer * > subLayers; + QList subLayers; bool res = layer->loadDefaultStyleAndSubLayers( error, warnings, subLayers ); if ( res && !warnings.empty() ) { @@ -2557,8 +2517,7 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi message += QStringLiteral( "
  • %1
  • " ).arg( w.toHtmlEscaped().replace( '\n', QLatin1String( "
    " ) ) ); } message += QLatin1String( "" ); - showLayerLoadWarnings( tr( "Vector tiles" ), tr( "Style could not be completely converted" ), - message, Qgis::MessageLevel::Warning ); + showLayerLoadWarnings( tr( "Vector tiles" ), tr( "Style could not be completely converted" ), message, Qgis::MessageLevel::Warning ); } if ( subLayers.empty() ) @@ -2615,7 +2574,7 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi } QgsProject::instance()->addMapLayer( subLayer, false ); group->addLayer( subLayer ); - addedLayers << subLayer; + addedLayers << subLayer; } if ( !addToLegend ) @@ -2630,7 +2589,7 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi } else if ( u.layerType == QLatin1String( "plugin" ) ) { - QgsMapLayer *layer = QgsAppLayerHandling::addLayer< QgsPluginLayer> ( uri, u.name, u.providerKey, addToLegend, false ); + QgsMapLayer *layer = QgsAppLayerHandling::addLayer( uri, u.name, u.providerKey, addToLegend, false ); if ( layer ) addedLayers << layer; } @@ -2651,7 +2610,7 @@ QList< QgsMapLayer * > QgisApp::handleDropUriList( const QgsMimeDataUtils::UriLi openFile( u.uri, QStringLiteral( "project" ) ); } - task.setProgress( 100.0 * static_cast< double >( count ) / lst.size() ); + task.setProgress( 100.0 * static_cast( count ) / lst.size() ); } if ( !suppressBulkLayerPostProcessing ) @@ -2688,9 +2647,7 @@ bool QgisApp::event( QEvent *event ) QgsMessageBar *QgisApp::visibleMessageBar() { - if ( mDataSourceManagerDialog && - mDataSourceManagerDialog->isVisible() && - mDataSourceManagerDialog->isModal() ) + if ( mDataSourceManagerDialog && mDataSourceManagerDialog->isVisible() && mDataSourceManagerDialog->isModal() ) { return mDataSourceManagerDialog->messageBar(); } @@ -2707,16 +2664,14 @@ QgsDockWidget *QgisApp::logDock() void QgisApp::dataSourceManager( const QString &pageName, const QString &layerUri ) { - if ( ! mDataSourceManagerDialog ) + if ( !mDataSourceManagerDialog ) { mDataSourceManagerDialog = new QgsDataSourceManagerDialog( mBrowserModel, this, mapCanvas() ); connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh ); connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::connectionsChanged, this, &QgisApp::connectionsChanged ); - connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addLayer, - this, [this]( Qgis::LayerType type, const QString & uri, const QString & baseName, const QString & providerKey ) - { + connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addLayer, this, [this]( Qgis::LayerType type, const QString &uri, const QString &baseName, const QString &providerKey ) { switch ( type ) { case Qgis::LayerType::Raster: @@ -2726,7 +2681,7 @@ void QgisApp::dataSourceManager( const QString &pageName, const QString &layerUr case Qgis::LayerType::Vector: { if ( QgsVectorLayer *layer = addVectorLayer( uri, baseName, providerKey ) ) - QgsAppLayerHandling::postProcessAddedLayers( {layer} ); + QgsAppLayerHandling::postProcessAddedLayers( { layer } ); break; } @@ -2735,15 +2690,15 @@ void QgisApp::dataSourceManager( const QString &pageName, const QString &layerUr break; case Qgis::LayerType::VectorTile: - QgsAppLayerHandling::addLayer< QgsVectorTileLayer> ( uri, baseName, providerKey ); + QgsAppLayerHandling::addLayer( uri, baseName, providerKey ); break; case Qgis::LayerType::PointCloud: - QgsAppLayerHandling::addLayer< QgsPointCloudLayer >( uri, baseName, providerKey ); + QgsAppLayerHandling::addLayer( uri, baseName, providerKey ); break; case Qgis::LayerType::TiledScene: - QgsAppLayerHandling::addLayer< QgsTiledSceneLayer >( uri, baseName, providerKey ); + QgsAppLayerHandling::addLayer( uri, baseName, providerKey ); break; case Qgis::LayerType::Plugin: @@ -2753,44 +2708,40 @@ void QgisApp::dataSourceManager( const QString &pageName, const QString &layerUr } } ); - connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addRasterLayers, this, [ = ]( const QStringList & layersList ) - { + connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addRasterLayers, this, [=]( const QStringList &layersList ) { bool ok = false; - QList< QgsMapLayer * > addedLayers = QgsAppLayerHandling::addGdalRasterLayers( layersList, ok ); + QList addedLayers = QgsAppLayerHandling::addGdalRasterLayers( layersList, ok ); if ( ok ) QgsAppLayerHandling::postProcessAddedLayers( addedLayers ); } ); - connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addVectorLayers, this, []( const QStringList & layerList, const QString & encoding, const QString & dataSourceType ) - { + connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addVectorLayers, this, []( const QStringList &layerList, const QString &encoding, const QString &dataSourceType ) { bool ok = false; - QList< QgsMapLayer * > addedLayers = QgsAppLayerHandling::addOgrVectorLayers( layerList, encoding, dataSourceType, ok ); + QList addedLayers = QgsAppLayerHandling::addOgrVectorLayers( layerList, encoding, dataSourceType, ok ); if ( ok ) QgsAppLayerHandling::postProcessAddedLayers( addedLayers ); } ); connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::showStatusMessage, this, &QgisApp::showStatusMessage ); - connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addDatabaseLayers, this, []( const QStringList & layerPathList, const QString & providerKey ) - { + connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addDatabaseLayers, this, []( const QStringList &layerPathList, const QString &providerKey ) { bool ok = false; - QList< QgsMapLayer * > addedLayers = QgsAppLayerHandling::addDatabaseLayers( layerPathList, providerKey, ok ); + QList addedLayers = QgsAppLayerHandling::addDatabaseLayers( layerPathList, providerKey, ok ); if ( ok ) QgsAppLayerHandling::postProcessAddedLayers( addedLayers ); } ); connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::replaceSelectedVectorLayer, this, &QgisApp::replaceSelectedVectorLayer ); - connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::handleDropUriList, this, [this]( const QgsMimeDataUtils::UriList & list ) { handleDropUriList( list ); } ); + connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::handleDropUriList, this, [this]( const QgsMimeDataUtils::UriList &list ) { handleDropUriList( list ); } ); connect( this, &QgisApp::newProject, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::updateProjectHome ); - connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::openFile, this, [this]( const QString & file ) { openFile( file ); } ); + connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::openFile, this, [this]( const QString &file ) { openFile( file ); } ); } else { mDataSourceManagerDialog->reset(); } // Try to open the dialog on a particular page - if ( ! pageName.isEmpty() ) + if ( !pageName.isEmpty() ) { - - if ( ! layerUri.isEmpty() ) + if ( !layerUri.isEmpty() ) { mDataSourceManagerDialog->configureFromUri( pageName, layerUri ); } @@ -2929,21 +2880,21 @@ void QgisApp::readSettings() void QgisApp::createActions() { - mActionPluginSeparator1 = nullptr; // plugin list separator will be created when the first plugin is loaded - mActionPluginSeparator2 = nullptr; // python separator will be created only if python is found - mActionRasterSeparator = nullptr; // raster plugins list separator will be created when the first plugin is loaded + mActionPluginSeparator1 = nullptr; // plugin list separator will be created when the first plugin is loaded + mActionPluginSeparator2 = nullptr; // python separator will be created only if python is found + mActionRasterSeparator = nullptr; // raster plugins list separator will be created when the first plugin is loaded // Project Menu Items - connect( mActionNewProject, &QAction::triggered, this, [ = ] { fileNew(); } ); + connect( mActionNewProject, &QAction::triggered, this, [=] { fileNew(); } ); connect( mActionNewBlankProject, &QAction::triggered, this, &QgisApp::fileNewBlank ); connect( mActionOpenProject, &QAction::triggered, this, &QgisApp::fileOpen ); connect( mActionRevertProject, &QAction::triggered, this, &QgisApp::fileRevert ); connect( mActionSaveProject, &QAction::triggered, this, &QgisApp::fileSave ); connect( mActionCloseProject, &QAction::triggered, this, &QgisApp::fileClose ); connect( mActionSaveProjectAs, &QAction::triggered, this, &QgisApp::fileSaveAs ); - connect( mActionSaveMapAsImage, &QAction::triggered, this, [ = ] { saveMapAsImage(); } ); - connect( mActionSaveMapAsPdf, &QAction::triggered, this, [ = ] { saveMapAsPdf(); } ); + connect( mActionSaveMapAsImage, &QAction::triggered, this, [=] { saveMapAsImage(); } ); + connect( mActionSaveMapAsPdf, &QAction::triggered, this, [=] { saveMapAsPdf(); } ); connect( mActionNewMapCanvas, &QAction::triggered, this, &QgisApp::newMapCanvas ); connect( mActionNew3DMapCanvas, &QAction::triggered, this, &QgisApp::new3DMapCanvas ); connect( mActionNewPrintLayout, &QAction::triggered, this, &QgisApp::newPrintLayout ); @@ -2957,13 +2908,13 @@ void QgisApp::createActions() connect( mActionUndo, &QAction::triggered, mUndoWidget, &QgsUndoWidget::undo ); connect( mActionRedo, &QAction::triggered, mUndoWidget, &QgsUndoWidget::redo ); - connect( mActionCutFeatures, &QAction::triggered, this, [ = ] { cutSelectionToClipboard(); } ); - connect( mActionCopyFeatures, &QAction::triggered, this, [ = ] { copySelectionToClipboard(); } ); - connect( mActionPasteFeatures, &QAction::triggered, this, [ = ] { pasteFromClipboard(); } ); + connect( mActionCutFeatures, &QAction::triggered, this, [=] { cutSelectionToClipboard(); } ); + connect( mActionCopyFeatures, &QAction::triggered, this, [=] { copySelectionToClipboard(); } ); + connect( mActionPasteFeatures, &QAction::triggered, this, [=] { pasteFromClipboard(); } ); connect( mActionPasteAsNewVector, &QAction::triggered, this, &QgisApp::pasteAsNewVector ); - connect( mActionPasteAsNewMemoryVector, &QAction::triggered, this, [ = ] { pasteAsNewMemoryVector(); } ); - connect( mActionCopyStyle, &QAction::triggered, this, [ = ] { copyStyle(); } ); - connect( mActionPasteStyle, &QAction::triggered, this, [ = ] { applyStyleToGroup(); } ); + connect( mActionPasteAsNewMemoryVector, &QAction::triggered, this, [=] { pasteAsNewMemoryVector(); } ); + connect( mActionCopyStyle, &QAction::triggered, this, [=] { copyStyle(); } ); + connect( mActionPasteStyle, &QAction::triggered, this, [=] { applyStyleToGroup(); } ); connect( mActionCopyLayer, &QAction::triggered, this, &QgisApp::copyLayer ); connect( mActionPasteLayer, &QAction::triggered, this, &QgisApp::pasteLayer ); connect( mActionAddFeature, &QAction::triggered, this, &QgisApp::addFeature ); @@ -2975,7 +2926,7 @@ void QgisApp::createActions() connect( mActionReshapeFeatures, &QAction::triggered, this, &QgisApp::reshapeFeatures ); connect( mActionSplitFeatures, &QAction::triggered, this, &QgisApp::splitFeatures ); connect( mActionSplitParts, &QAction::triggered, this, &QgisApp::splitParts ); - connect( mActionDeleteSelected, &QAction::triggered, this, [ = ] { deleteSelected( nullptr, nullptr, true ); } ); + connect( mActionDeleteSelected, &QAction::triggered, this, [=] { deleteSelected( nullptr, nullptr, true ); } ); connect( mActionAddRing, &QAction::triggered, this, &QgisApp::addRing ); connect( mActionFillRing, &QAction::triggered, this, &QgisApp::fillRing ); connect( mActionAddPart, &QAction::triggered, this, &QgisApp::addPart ); @@ -2992,7 +2943,7 @@ void QgisApp::createActions() connect( mActionSnappingOptions, &QAction::triggered, this, &QgisApp::snappingOptions ); connect( mActionOffsetCurve, &QAction::triggered, this, &QgisApp::offsetCurve ); connect( mActionReverseLine, &QAction::triggered, this, &QgisApp::reverseLine ); - connect( mActionTrimExtendFeature, &QAction::triggered, this, [ = ] { mMapCanvas->setMapTool( mMapTools->mapTool( QgsAppMapTools::TrimExtendFeature ) ); } ); + connect( mActionTrimExtendFeature, &QAction::triggered, this, [=] { mMapCanvas->setMapTool( mMapTools->mapTool( QgsAppMapTools::TrimExtendFeature ) ); } ); // View Menu Items connect( mActionPan, &QAction::triggered, this, &QgisApp::pan ); @@ -3006,15 +2957,15 @@ void QgisApp::createActions() connect( mActionDeselectAll, &QAction::triggered, this, &QgisApp::deselectAll ); connect( mActionDeselectActiveLayer, &QAction::triggered, this, &QgisApp::deselectActiveLayer ); connect( mActionSelectAll, &QAction::triggered, this, &QgisApp::selectAll ); - connect( mActionReselect, &QAction::triggered, this, [ = ] - { + connect( mActionReselect, &QAction::triggered, this, [=] { QgsVectorLayer *vlayer = qobject_cast( mMapCanvas->currentLayer() ); if ( !vlayer ) { visibleMessageBar()->pushMessage( tr( "No active vector layer" ), tr( "To reselect features, choose a vector layer in the legend." ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } @@ -3028,7 +2979,7 @@ void QgisApp::createActions() connect( mActionMeasure, &QAction::triggered, this, &QgisApp::measure ); connect( mActionMeasureArea, &QAction::triggered, this, &QgisApp::measureArea ); connect( mActionMeasureAngle, &QAction::triggered, this, &QgisApp::measureAngle ); - connect( mActionMeasureBearing, &QAction::triggered, this, [ = ] { setMapTool( mMapTools->mapTool( QgsAppMapTools::MeasureBearing ) ); } ); + connect( mActionMeasureBearing, &QAction::triggered, this, [=] { setMapTool( mMapTools->mapTool( QgsAppMapTools::MeasureBearing ) ); } ); connect( mActionZoomFullExtent, &QAction::triggered, this, &QgisApp::zoomFull ); connect( mActionZoomToLayer, &QAction::triggered, this, &QgisApp::zoomToLayerExtent ); connect( mActionZoomToLayers, &QAction::triggered, this, &QgisApp::zoomToLayerExtent ); @@ -3037,7 +2988,7 @@ void QgisApp::createActions() connect( mActionZoomNext, &QAction::triggered, this, &QgisApp::zoomToNext ); connect( mActionZoomActualSize, &QAction::triggered, this, &QgisApp::zoomActualSize ); connect( mActionMapTips, &QAction::toggled, this, &QgisApp::toggleMapTips ); - connect( mActionNewBookmark, &QAction::triggered, this, [ = ] { newBookmark( true ); } ); + connect( mActionNewBookmark, &QAction::triggered, this, [=] { newBookmark( true ); } ); connect( mActionDraw, &QAction::triggered, this, [this] { refreshMapCanvas( true ); } ); connect( mActionFormAnnotation, &QAction::triggered, this, &QgisApp::addFormAnnotation ); connect( mActionHtmlAnnotation, &QAction::triggered, this, &QgisApp::addHtmlAnnotation ); @@ -3048,7 +2999,7 @@ void QgisApp::createActions() // Layer Menu Items - connect( mActionDataSourceManager, &QAction::triggered, this, [ = ]() { dataSourceManager(); } ); + connect( mActionDataSourceManager, &QAction::triggered, this, [=]() { dataSourceManager(); } ); connect( mActionNewVectorLayer, &QAction::triggered, this, &QgisApp::newVectorLayer ); #ifdef HAVE_SPATIALITE connect( mActionNewSpatiaLiteLayer, &QAction::triggered, this, &QgisApp::newSpatialiteLayer ); @@ -3062,59 +3013,55 @@ void QgisApp::createActions() connect( mActionShowMeshCalculator, &QAction::triggered, this, &QgisApp::showMeshCalculator ); connect( mActionEmbedLayers, &QAction::triggered, this, &QgisApp::embedLayers ); connect( mActionAddLayerDefinition, &QAction::triggered, this, &QgisApp::addLayerDefinition ); - connect( mActionAddOgrLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "ogr" ) ); } ); - connect( mActionAddRasterLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "gdal" ) ); } ); - connect( mActionAddMeshLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "mdal" ) ); } ); - connect( mActionAddPgLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "postgres" ) ); } ); + connect( mActionAddOgrLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "ogr" ) ); } ); + connect( mActionAddRasterLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "gdal" ) ); } ); + connect( mActionAddMeshLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "mdal" ) ); } ); + connect( mActionAddPgLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "postgres" ) ); } ); #ifdef HAVE_SPATIALITE - connect( mActionAddSpatiaLiteLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "spatialite" ) ); } ); + connect( mActionAddSpatiaLiteLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "spatialite" ) ); } ); #endif - connect( mActionAddMssqlLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "mssql" ) ); } ); - connect( mActionAddOracleLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "oracle" ) ); } ); - connect( mActionAddHanaLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "hana" ) ); } ); - connect( mActionAddWmsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "wms" ) ); } ); - connect( mActionAddXyzLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "xyz" ) ); } ); - connect( mActionAddVectorTileLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "vectortile" ) ); } ); - connect( mActionAddPointCloudLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "pointcloud" ) ); } ); - connect( mActionAddGpsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "gpx" ) ); } ); - connect( mActionAddWcsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "wcs" ) ); } ); + connect( mActionAddMssqlLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "mssql" ) ); } ); + connect( mActionAddOracleLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "oracle" ) ); } ); + connect( mActionAddHanaLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "hana" ) ); } ); + connect( mActionAddWmsLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "wms" ) ); } ); + connect( mActionAddXyzLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "xyz" ) ); } ); + connect( mActionAddVectorTileLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "vectortile" ) ); } ); + connect( mActionAddPointCloudLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "pointcloud" ) ); } ); + connect( mActionAddGpsLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "gpx" ) ); } ); + connect( mActionAddWcsLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "wcs" ) ); } ); #ifdef HAVE_SPATIALITE - connect( mActionAddWfsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "WFS" ) ); } ); + connect( mActionAddWfsLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "WFS" ) ); } ); #endif - connect( mActionAddAfsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "arcgisfeatureserver" ) ); } ); - connect( mActionAddDelimitedText, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "delimitedtext" ) ); } ); - connect( mActionAddVirtualLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "virtual" ) ); } ); - connect( mActionOpenTable, &QAction::triggered, this, [ = ] - { + connect( mActionAddAfsLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "arcgisfeatureserver" ) ); } ); + connect( mActionAddDelimitedText, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "delimitedtext" ) ); } ); + connect( mActionAddVirtualLayer, &QAction::triggered, this, [=] { dataSourceManager( QStringLiteral( "virtual" ) ); } ); + connect( mActionOpenTable, &QAction::triggered, this, [=] { QgsSettings settings; - QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ); + QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ); attributeTable( initialMode ); } ); - connect( mActionOpenTableSelected, &QAction::triggered, this, [ = ] - { + connect( mActionOpenTableSelected, &QAction::triggered, this, [=] { attributeTable( QgsAttributeTableFilterModel::ShowSelected ); } ); - connect( mActionOpenTableVisible, &QAction::triggered, this, [ = ] - { + connect( mActionOpenTableVisible, &QAction::triggered, this, [=] { attributeTable( QgsAttributeTableFilterModel::ShowVisible ); } ); - connect( mActionOpenTableEdited, &QAction::triggered, this, [ = ] - { + connect( mActionOpenTableEdited, &QAction::triggered, this, [=] { attributeTable( QgsAttributeTableFilterModel::ShowEdited ); } ); connect( mActionOpenFieldCalc, &QAction::triggered, this, &QgisApp::fieldCalculator ); - connect( mActionToggleEditing, &QAction::triggered, this, [ = ] { toggleEditing(); } ); + connect( mActionToggleEditing, &QAction::triggered, this, [=] { toggleEditing(); } ); connect( mActionSaveLayerEdits, &QAction::triggered, this, &QgisApp::saveActiveLayerEdits ); - connect( mActionSaveEdits, &QAction::triggered, this, [ = ] { saveEdits(); } ); - connect( mActionSaveAllEdits, &QAction::triggered, this, [ = ] { saveAllEdits(); } ); + connect( mActionSaveEdits, &QAction::triggered, this, [=] { saveEdits(); } ); + connect( mActionSaveAllEdits, &QAction::triggered, this, [=] { saveAllEdits(); } ); connect( mActionRollbackEdits, &QAction::triggered, this, &QgisApp::rollbackEdits ); - connect( mActionRollbackAllEdits, &QAction::triggered, this, [ = ] { rollbackAllEdits(); } ); - connect( mActionCancelEdits, &QAction::triggered, this, [ = ] { cancelEdits(); } ); - connect( mActionCancelAllEdits, &QAction::triggered, this, [ = ] { cancelAllEdits(); } ); - connect( mActionLayerSaveAs, &QAction::triggered, this, [ = ] { saveAsFile(); } ); + connect( mActionRollbackAllEdits, &QAction::triggered, this, [=] { rollbackAllEdits(); } ); + connect( mActionCancelEdits, &QAction::triggered, this, [=] { cancelEdits(); } ); + connect( mActionCancelAllEdits, &QAction::triggered, this, [=] { cancelAllEdits(); } ); + connect( mActionLayerSaveAs, &QAction::triggered, this, [=] { saveAsFile(); } ); connect( mActionSaveLayerDefinition, &QAction::triggered, this, &QgisApp::saveAsLayerDefinition ); connect( mActionRemoveLayer, &QAction::triggered, this, &QgisApp::removeLayer ); - connect( mActionDuplicateLayer, &QAction::triggered, this, [ = ] { duplicateLayers(); } ); + connect( mActionDuplicateLayer, &QAction::triggered, this, [=] { duplicateLayers(); } ); connect( mActionSetLayerScaleVisibility, &QAction::triggered, this, &QgisApp::setLayerScaleVisibility ); connect( mActionSetLayerCRS, &QAction::triggered, this, &QgisApp::setLayerCrs ); connect( mActionSetProjectCRSFromLayer, &QAction::triggered, this, &QgisApp::setProjectCrsFromLayer ); @@ -3141,7 +3088,7 @@ void QgisApp::createActions() connect( mActionToggleFullScreen, &QAction::triggered, this, &QgisApp::toggleFullScreen ); connect( mActionTogglePanelsVisibility, &QAction::triggered, this, &QgisApp::togglePanelsVisibility ); connect( mActionToggleMapOnly, &QAction::triggered, this, &QgisApp::toggleMapOnly ); - connect( mActionProjectProperties, &QAction::triggered, this, [ = ] {projectProperties( QString() );} ); + connect( mActionProjectProperties, &QAction::triggered, this, [=] { projectProperties( QString() ); } ); connect( mActionOptions, &QAction::triggered, this, &QgisApp::options ); connect( mActionCustomProjection, &QAction::triggered, this, &QgisApp::customProjection ); connect( mActionConfigureShortcuts, &QAction::triggered, this, &QgisApp::configureShortcuts ); @@ -3222,15 +3169,13 @@ void QgisApp::createActions() connect( mActionSponsors, &QAction::triggered, this, &QgisApp::sponsors ); connect( mActionShowPinnedLabels, &QAction::toggled, this, &QgisApp::showPinnedLabels ); - connect( mActionShowUnplacedLabels, &QAction::toggled, this, [ = ]( bool active ) - { + connect( mActionShowUnplacedLabels, &QAction::toggled, this, [=]( bool active ) { QgsLabelingEngineSettings engineSettings = QgsProject::instance()->labelingEngineSettings(); engineSettings.setFlag( Qgis::LabelingFlag::DrawUnplacedLabels, active ); QgsProject::instance()->setLabelingEngineSettings( engineSettings ); refreshMapCanvas( true ); } ); - connect( QgsProject::instance(), &QgsProject::labelingEngineSettingsChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::labelingEngineSettingsChanged, this, [=] { whileBlocking( mActionShowUnplacedLabels )->setChecked( QgsProject::instance()->labelingEngineSettings().testFlag( Qgis::LabelingFlag::DrawUnplacedLabels ) ); } ); connect( mActionPinLabels, &QAction::triggered, this, &QgisApp::pinLabels ); @@ -3242,30 +3187,29 @@ void QgisApp::createActions() connect( mActionDiagramProperties, &QAction::triggered, this, &QgisApp::diagramProperties ); connect( mActionCreateAnnotationLayer, &QAction::triggered, this, &QgisApp::createAnnotationLayer ); - connect( mActionModifyAnnotation, &QAction::triggered, this, [ = ] { mMapCanvas->setMapTool( mMapTools->mapTool( QgsAppMapTools::AnnotationEdit ) ); } ); - connect( mMainAnnotationLayerProperties, &QAction::triggered, this, [ = ] - { + connect( mActionModifyAnnotation, &QAction::triggered, this, [=] { mMapCanvas->setMapTool( mMapTools->mapTool( QgsAppMapTools::AnnotationEdit ) ); } ); + connect( mMainAnnotationLayerProperties, &QAction::triggered, this, [=] { showLayerProperties( QgsProject::instance()->mainAnnotationLayer() ); } ); // we can't set the shortcut these actions, because we need to restrict their context to the canvas and it's children.. for ( QWidget *widget : { - static_cast< QWidget * >( mMapCanvas ), - static_cast< QWidget * >( mLayerTreeView ) + static_cast( mMapCanvas ), + static_cast( mLayerTreeView ) } ) { QShortcut *copyShortcut = new QShortcut( QKeySequence::Copy, widget ); copyShortcut->setContext( Qt::WidgetWithChildrenShortcut ); - connect( copyShortcut, &QShortcut::activated, this, [ = ] { copySelectionToClipboard(); } ); + connect( copyShortcut, &QShortcut::activated, this, [=] { copySelectionToClipboard(); } ); QShortcut *cutShortcut = new QShortcut( QKeySequence::Cut, widget ); cutShortcut->setContext( Qt::WidgetWithChildrenShortcut ); - connect( cutShortcut, &QShortcut::activated, this, [ = ] { cutSelectionToClipboard(); } ); + connect( cutShortcut, &QShortcut::activated, this, [=] { cutSelectionToClipboard(); } ); QShortcut *pasteShortcut = new QShortcut( QKeySequence::Paste, widget ); pasteShortcut->setContext( Qt::WidgetWithChildrenShortcut ); - connect( pasteShortcut, &QShortcut::activated, this, [ = ] { pasteFromClipboard(); } ); + connect( pasteShortcut, &QShortcut::activated, this, [=] { pasteFromClipboard(); } ); QShortcut *selectAllShortcut = new QShortcut( QKeySequence::SelectAll, widget ); selectAllShortcut->setContext( Qt::WidgetWithChildrenShortcut ); @@ -3286,7 +3230,6 @@ void QgisApp::createActions() delete mActionAddHanaLayer; mActionAddHanaLayer = nullptr; #endif - } void QgisApp::showStyleManager() @@ -3307,8 +3250,10 @@ void QgisApp::showPythonDialog() return; bool res = mPythonUtils->runString( - "import console\n" - "console.show_console()\n", tr( "Failed to open Python console:" ), false ); + "import console\n" + "console.show_console()\n", + tr( "Failed to open Python console:" ), false + ); if ( !res ) { @@ -3430,17 +3375,15 @@ void QgisApp::createMenus() mToolbarMenu->setObjectName( QStringLiteral( "mToolbarMenu" ) ); // Get platform for menu layout customization (Gnome, Kde, Mac, Win) - QDialogButtonBox::ButtonLayout layout = - QDialogButtonBox::ButtonLayout( style()->styleHint( QStyle::SH_DialogButtonLayout, nullptr, this ) ); + QDialogButtonBox::ButtonLayout layout = QDialogButtonBox::ButtonLayout( style()->styleHint( QStyle::SH_DialogButtonLayout, nullptr, this ) ); // Connect once for the entire submenu. - connect( mRecentProjectsMenu, &QMenu::triggered, this, static_cast < void ( QgisApp::* )( QAction *action ) >( &QgisApp::openProject ) ); + connect( mRecentProjectsMenu, &QMenu::triggered, this, static_cast( &QgisApp::openProject ) ); QgsRecentProjectsMenuEventFilter *recentsProjectMenuEventFilter = new QgsRecentProjectsMenuEventFilter( mWelcomePage, mRecentProjectsMenu ); mRecentProjectsMenu->installEventFilter( recentsProjectMenuEventFilter ); - connect( mProjectFromTemplateMenu, &QMenu::triggered, - this, &QgisApp::fileNewFromTemplateAction ); + connect( mProjectFromTemplateMenu, &QMenu::triggered, this, &QgisApp::fileNewFromTemplateAction ); // View Menu @@ -3520,7 +3463,7 @@ void QgisApp::refreshProfileMenu() const auto constAllProfiles = userProfileManager()->allProfiles(); for ( const QString &name : constAllProfiles ) { - std::unique_ptr< QgsUserProfile > namedProfile( userProfileManager()->profileForName( name ) ); + std::unique_ptr namedProfile( userProfileManager()->profileForName( name ) ); QAction *action = new QAction( namedProfile->icon(), namedProfile->alias(), profileGroup ); action->setToolTip( namedProfile->folder() ); action->setCheckable( true ); @@ -3533,8 +3476,7 @@ void QgisApp::refreshProfileMenu() } else { - connect( action, &QAction::triggered, this, [this, name, activeName]() - { + connect( action, &QAction::triggered, this, [this, name, activeName]() { // Launch a new instance of QGIS with the selected profile userProfileManager()->loadUserProfile( name ); @@ -3542,17 +3484,15 @@ void QgisApp::refreshProfileMenu() // as checked, but we don't want to check the clicked action, so we // check again the action linked to the active profile findChild( "mActionProfile_" + activeName )->setChecked( true ); - } ); } } - mConfigMenu->addSeparator( ); + mConfigMenu->addSeparator(); QAction *openProfileFolderAction = mConfigMenu->addAction( tr( "Open Active Profile Folder" ) ); openProfileFolderAction->setObjectName( "mActionOpenActiveProfileFolder" ); - connect( openProfileFolderAction, &QAction::triggered, this, [this]() - { + connect( openProfileFolderAction, &QAction::triggered, this, [this]() { QDesktopServices::openUrl( QUrl::fromLocalFile( userProfileManager()->userProfile()->folder() ) ); } ); @@ -3602,15 +3542,13 @@ void QgisApp::createToolBars() mSnappingWidget = new QgsSnappingWidget( QgsProject::instance(), mMapCanvas, mSnappingToolBar ); mSnappingWidget->setObjectName( QStringLiteral( "mSnappingWidget" ) ); - connect( mSnappingWidget, &QgsSnappingWidget::snappingConfigChanged, QgsProject::instance(), [ = ] { QgsProject::instance()->setSnappingConfig( mSnappingWidget->config() ); } ); + connect( mSnappingWidget, &QgsSnappingWidget::snappingConfigChanged, QgsProject::instance(), [=] { QgsProject::instance()->setSnappingConfig( mSnappingWidget->config() ); } ); mSnappingToolBar->addWidget( mSnappingWidget ); mTracer = new QgsMapCanvasTracer( mMapCanvas, messageBar() ); mTracer->setActionEnableTracing( mSnappingWidget->enableTracingAction() ); mTracer->setActionEnableSnapping( mSnappingWidget->enableSnappingAction() ); - connect( mSnappingWidget->tracingOffsetSpinBox(), - static_cast< void ( QgsDoubleSpinBox::* )( double ) >( &QgsDoubleSpinBox::valueChanged ), - this, [ = ]( double v ) { mTracer->setOffset( v ); } ); + connect( mSnappingWidget->tracingOffsetSpinBox(), static_cast( &QgsDoubleSpinBox::valueChanged ), this, [=]( double v ) { mTracer->setOffset( v ); } ); mDigitizingTechniqueManager->setupToolBars(); @@ -3721,7 +3659,6 @@ void QgisApp::createToolBars() featureActionAction->setObjectName( QStringLiteral( "ActionFeatureAction" ) ); - // open table tool button bt = new QToolButton( mAttributesToolBar ); @@ -3753,7 +3690,6 @@ void QgisApp::createToolBars() connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered ); - // measure tool button bt = new QToolButton( mAttributesToolBar ); @@ -3941,8 +3877,7 @@ void QgisApp::createToolBars() for ( QAction *selectAction : selectActions ) { meshSelectToolButton->addAction( selectAction ); - connect( selectAction, &QAction::triggered, meshSelectToolButton, [selectAction, meshSelectToolButton] - { + connect( selectAction, &QAction::triggered, meshSelectToolButton, [selectAction, meshSelectToolButton] { meshSelectToolButton->setDefaultAction( selectAction ); } ); } @@ -4058,7 +3993,7 @@ void QgisApp::createStatusBar() mMagnifierWidget->setFont( statusBarFont ); connect( mMapCanvas, &QgsMapCanvas::magnificationChanged, mMagnifierWidget, &QgsStatusBarMagnifierWidget::updateMagnification ); connect( mMapCanvas, &QgsMapCanvas::scaleLockChanged, mMagnifierWidget, &QgsStatusBarMagnifierWidget::updateScaleLock ); - connect( mMagnifierWidget, &QgsStatusBarMagnifierWidget::magnificationChanged, mMapCanvas, [ = ]( double factor ) { mMapCanvas->setMagnificationFactor( factor ); } ); + connect( mMagnifierWidget, &QgsStatusBarMagnifierWidget::magnificationChanged, mMapCanvas, [=]( double factor ) { mMapCanvas->setMagnificationFactor( factor ); } ); connect( mMagnifierWidget, &QgsStatusBarMagnifierWidget::scaleLockChanged, mMapCanvas, &QgsMapCanvas::setScaleLocked ); mMagnifierWidget->updateMagnification( QSettings().value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble() ); mStatusBar->addPermanentWidget( mMagnifierWidget, 0 ); @@ -4089,7 +4024,7 @@ void QgisApp::createStatusBar() mRotationEdit->setSuffix( tr( " °" ) ); mRotationEdit->setToolTip( tr( "Current clockwise map rotation in degrees" ) ); mStatusBar->addPermanentWidget( mRotationEdit, 0 ); - connect( mRotationEdit, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgisApp::userRotation ); + connect( mRotationEdit, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgisApp::userRotation ); showRotation(); @@ -4114,9 +4049,8 @@ void QgisApp::createStatusBar() mOnTheFlyProjectionStatusButton->setMaximumHeight( mScaleWidget->height() ); mOnTheFlyProjectionStatusButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mIconProjectionEnabled.svg" ) ) ); mOnTheFlyProjectionStatusButton->setToolTip( tr( "CRS status - Click " - "to open coordinate reference system dialog" ) ); - connect( mOnTheFlyProjectionStatusButton, &QAbstractButton::clicked, - this, &QgisApp::projectPropertiesProjections );//bring up the project props dialog when clicked + "to open coordinate reference system dialog" ) ); + connect( mOnTheFlyProjectionStatusButton, &QAbstractButton::clicked, this, &QgisApp::projectPropertiesProjections ); //bring up the project props dialog when clicked mStatusBar->addPermanentWidget( mOnTheFlyProjectionStatusButton, 0 ); mStatusBar->showMessage( tr( "Ready" ) ); @@ -4132,13 +4066,13 @@ void QgisApp::createStatusBar() mLocatorWidget = new QgsLocatorWidget( mStatusBar ); mStatusBar->addPermanentWidget( mLocatorWidget, 0, QgsStatusBar::AnchorLeft ); QShortcut *locatorShortCut = new QShortcut( QKeySequence( tr( "Ctrl+K" ) ), this ); - connect( locatorShortCut, &QShortcut::activated, mLocatorWidget, [ = ] { mLocatorWidget->search( QString() ); } ); + connect( locatorShortCut, &QShortcut::activated, mLocatorWidget, [=] { mLocatorWidget->search( QString() ); } ); locatorShortCut->setObjectName( QStringLiteral( "Locator" ) ); locatorShortCut->setWhatsThis( tr( "Trigger Locator" ) ); mLocatorWidget->locator()->registerFilter( new QgsLayerTreeLocatorFilter() ); mLocatorWidget->locator()->registerFilter( new QgsLayoutLocatorFilter() ); - QList< QWidget *> actionObjects; + QList actionObjects; actionObjects << menuBar() << mAdvancedDigitizeToolBar << mShapeDigitizeToolBar @@ -4165,7 +4099,7 @@ void QgisApp::createStatusBar() mLocatorWidget->locator()->registerFilter( new QgsGotoLocatorFilter() ); mLocatorWidget->locator()->registerFilter( new QgsLayerMetadataLocatorFilter() ); - mNominatimGeocoder = std::make_unique< QgsNominatimGeocoder>(); + mNominatimGeocoder = std::make_unique(); mLocatorWidget->locator()->registerFilter( new QgsNominatimLocatorFilter( mNominatimGeocoder.get(), mMapCanvas ) ); } @@ -4411,8 +4345,7 @@ void QgisApp::setupConnections() connect( mMapCanvas, &QgsMapCanvas::zoomLastStatusChanged, mActionZoomLast, &QAction::setEnabled ); connect( mMapCanvas, &QgsMapCanvas::zoomNextStatusChanged, mActionZoomNext, &QAction::setEnabled ); - connect( mRenderSuppressionCBox, &QAbstractButton::toggled, this, [ = ]( bool flag ) - { + connect( mRenderSuppressionCBox, &QAbstractButton::toggled, this, [=]( bool flag ) { const auto canvases = mapCanvases(); for ( QgsMapCanvas *canvas : canvases ) canvas->setRenderFlag( flag ); @@ -4428,22 +4361,18 @@ void QgisApp::setupConnections() // project crs connections connect( QgsProject::instance(), &QgsProject::crsChanged, this, &QgisApp::projectCrsChanged ); - connect( QgsProject::instance()->viewSettings(), &QgsProjectViewSettings::mapScalesChanged, this, [ = ] { mScaleWidget->updateScales(); } ); + connect( QgsProject::instance()->viewSettings(), &QgsProjectViewSettings::mapScalesChanged, this, [=] { mScaleWidget->updateScales(); } ); - connect( QgsProject::instance(), &QgsProject::missingDatumTransforms, this, [ = ]( const QStringList & transforms ) - { + connect( QgsProject::instance(), &QgsProject::missingDatumTransforms, this, [=]( const QStringList &transforms ) { QString message = tr( "Transforms are not installed: %1 " ).arg( transforms.join( QLatin1String( " ," ) ) ); messageBar()->pushWarning( tr( "Missing datum transforms" ), message ); } ); - connect( QgsProject::instance(), &QgsProject::labelingEngineSettingsChanged, - mMapCanvas, [ = ] - { + connect( QgsProject::instance(), &QgsProject::labelingEngineSettingsChanged, mMapCanvas, [=] { mMapCanvas->setLabelingEngineSettings( QgsProject::instance()->labelingEngineSettings() ); } ); - connect( QgsProject::instance(), &QgsProject::backgroundColorChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::backgroundColorChanged, this, [=] { const QColor backgroundColor = QgsProject::instance()->backgroundColor(); const auto constMapCanvases = mapCanvases(); for ( QgsMapCanvas *canvas : constMapCanvases ) @@ -4457,8 +4386,7 @@ void QgisApp::setupConnections() } } ); - connect( QgsProject::instance(), &QgsProject::selectionColorChanged, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::selectionColorChanged, this, [=] { const QColor selectionColor = QgsProject::instance()->selectionColor(); const auto constMapCanvases = mapCanvases(); for ( QgsMapCanvas *canvas : constMapCanvases ) @@ -4470,55 +4398,36 @@ void QgisApp::setupConnections() connect( QgsProject::instance()->timeSettings(), &QgsProjectTimeSettings::temporalRangeChanged, this, &QgisApp::projectTemporalRangeChanged ); // connect legend signals - connect( this, &QgisApp::activeLayerChanged, - this, &QgisApp::activateDeactivateLayerRelatedActions ); - connect( this, &QgisApp::activeLayerChanged, - this, &QgisApp::setMapStyleDockLayer ); - connect( mLayerTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &QgisApp::legendLayerSelectionChanged ); - connect( mLayerTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &QgisApp::activateDeactivateMultipleLayersRelatedActions ); - connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::addedChildren, - this, &QgisApp::markDirty ); - connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::addedChildren, - this, &QgisApp::updateNewLayerInsertionPoint ); - connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::removedChildren, - this, &QgisApp::markDirty ); - connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::removedChildren, - this, &QgisApp::updateNewLayerInsertionPoint ); - connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::visibilityChanged, - this, &QgisApp::markDirty ); - connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::customPropertyChanged, - this, [ = ]( QgsLayerTreeNode *, const QString & key ) - { + connect( this, &QgisApp::activeLayerChanged, this, &QgisApp::activateDeactivateLayerRelatedActions ); + connect( this, &QgisApp::activeLayerChanged, this, &QgisApp::setMapStyleDockLayer ); + connect( mLayerTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgisApp::legendLayerSelectionChanged ); + connect( mLayerTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgisApp::activateDeactivateMultipleLayersRelatedActions ); + connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::addedChildren, this, &QgisApp::markDirty ); + connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::addedChildren, this, &QgisApp::updateNewLayerInsertionPoint ); + connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::removedChildren, this, &QgisApp::markDirty ); + connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::removedChildren, this, &QgisApp::updateNewLayerInsertionPoint ); + connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::visibilityChanged, this, &QgisApp::markDirty ); + connect( mLayerTreeView->layerTreeModel()->rootGroup(), &QgsLayerTreeNode::customPropertyChanged, this, [=]( QgsLayerTreeNode *, const QString &key ) { // only mark dirty for non-view only changes if ( !QgsLayerTreeView::viewOnlyCustomProperties().contains( key ) ) QgisApp::markDirty(); } ); - connect( mLayerTreeView, &QgsLayerTreeView::datasetsDropped, this, [ = ]( QDropEvent * event ) - { + connect( mLayerTreeView, &QgsLayerTreeView::datasetsDropped, this, [=]( QDropEvent *event ) { mLayerTreeDrop = true; dropEvent( event ); } ); // connect map layer registry - connect( QgsProject::instance(), &QgsProject::layersAdded, - this, &QgisApp::layersWereAdded ); - connect( QgsProject::instance(), - static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), - this, &QgisApp::removingLayers ); + connect( QgsProject::instance(), &QgsProject::layersAdded, this, &QgisApp::layersWereAdded ); + connect( QgsProject::instance(), static_cast( &QgsProject::layersWillBeRemoved ), this, &QgisApp::removingLayers ); // connect initialization signal - connect( this, &QgisApp::initializationCompleted, - this, &QgisApp::fileOpenAfterLaunch ); + connect( this, &QgisApp::initializationCompleted, this, &QgisApp::fileOpenAfterLaunch ); // Connect warning dialog from project reading - connect( QgsProject::instance(), &QgsProject::readVersionMismatchOccurred, - this, &QgisApp::projectVersionMismatchOccurred ); - connect( QgsProject::instance(), &QgsProject::layerLoaded, - this, [this]( int i, int n ) - { + connect( QgsProject::instance(), &QgsProject::readVersionMismatchOccurred, this, &QgisApp::projectVersionMismatchOccurred ); + connect( QgsProject::instance(), &QgsProject::layerLoaded, this, [this]( int i, int n ) { if ( !mProjectLoadingProxyTask && i < n ) { QString name = QgsProject::instance()->title().isEmpty() ? QgsProject::instance()->fileName() : QgsProject::instance()->title(); @@ -4533,7 +4442,7 @@ void QgisApp::setupConnections() if ( mProjectLoadingProxyTask ) { - mProjectLoadingProxyTask->setProxyProgress( 100.0 * static_cast< double >( i ) / n ); + mProjectLoadingProxyTask->setProxyProgress( 100.0 * static_cast( i ) / n ); if ( i >= n ) { mProjectLoadingProxyTask->finalize( true ); @@ -4541,23 +4450,17 @@ void QgisApp::setupConnections() } } } ); - connect( QgsProject::instance(), &QgsProject::loadingLayer, - this, &QgisApp::showStatusMessage ); - connect( QgsProject::instance(), &QgsProject::loadingLayerMessageReceived, - this, &QgisApp::loadingLayerMessages ); - connect( QgsProject::instance(), &QgsProject::readProject, - this, &QgisApp::readProject ); - connect( QgsProject::instance(), &QgsProject::writeProject, - this, &QgisApp::writeProject ); - - connect( this, &QgisApp::projectRead, - this, &QgisApp::fileOpenedOKAfterLaunch ); + connect( QgsProject::instance(), &QgsProject::loadingLayer, this, &QgisApp::showStatusMessage ); + connect( QgsProject::instance(), &QgsProject::loadingLayerMessageReceived, this, &QgisApp::loadingLayerMessages ); + connect( QgsProject::instance(), &QgsProject::readProject, this, &QgisApp::readProject ); + connect( QgsProject::instance(), &QgsProject::writeProject, this, &QgisApp::writeProject ); + + connect( this, &QgisApp::projectRead, this, &QgisApp::fileOpenedOKAfterLaunch ); connect( QgsProject::instance(), &QgsProject::transactionGroupsChanged, this, &QgisApp::onTransactionGroupsChanged ); // Handle dirty raster attribute tables - connect( QgsProject::instance(), qOverload & >( &QgsProject::layersWillBeRemoved ), this, [ = ]( const QList< QgsMapLayer * > &layers ) - { + connect( QgsProject::instance(), qOverload &>( &QgsProject::layersWillBeRemoved ), this, [=]( const QList &layers ) { checkUnsavedRasterAttributeTableEdits( layers, false ); } ); @@ -4581,11 +4484,10 @@ void QgisApp::setupCanvasTools() { mMapTools->mapTool( QgsAppMapTools::ZoomIn )->setAction( mActionZoomIn ); mMapTools->mapTool( QgsAppMapTools::ZoomOut )->setAction( mActionZoomOut ); - connect( mMapTools->mapTool< QgsMapToolPan >( QgsAppMapTools::Pan ), &QgsMapToolPan::panDistanceBearingChanged, this, &QgisApp::showPanMessage ); + connect( mMapTools->mapTool( QgsAppMapTools::Pan ), &QgsMapToolPan::panDistanceBearingChanged, this, &QgisApp::showPanMessage ); mMapTools->mapTool( QgsAppMapTools::Pan )->setAction( mActionPan ); mMapTools->mapTool( QgsAppMapTools::Identify )->setAction( mActionIdentify ); - connect( mMapTools->mapTool< QgsMapToolIdentifyAction >( QgsAppMapTools::Identify ), &QgsMapToolIdentifyAction::copyToClipboard, - this, &QgisApp::copyFeatures ); + connect( mMapTools->mapTool( QgsAppMapTools::Identify ), &QgsMapToolIdentifyAction::copyToClipboard, this, &QgisApp::copyFeatures ); mMapTools->mapTool( QgsAppMapTools::FeatureAction )->setAction( mActionFeatureAction ); mMapTools->mapTool( QgsAppMapTools::MeasureDistance )->setAction( mActionMeasure ); mMapTools->mapTool( QgsAppMapTools::MeasureArea )->setAction( mActionMeasureArea ); @@ -4653,9 +4555,9 @@ void QgisApp::createOverview() mOverviewMapCursor = new QCursor( Qt::OpenHandCursor ); mOverviewCanvas->setCursor( *mOverviewMapCursor ); -// QVBoxLayout *myOverviewLayout = new QVBoxLayout; -// myOverviewLayout->addWidget(overviewCanvas); -// overviewFrame->setLayout(myOverviewLayout); + // QVBoxLayout *myOverviewLayout = new QVBoxLayout; + // myOverviewLayout->addWidget(overviewCanvas); + // overviewFrame->setLayout(myOverviewLayout); mOverviewDock = new QgsDockWidget( tr( "Overview" ), this ); QShortcut *showOverviewDock = new QShortcut( QKeySequence( tr( "Ctrl+8" ) ), this ); @@ -4786,8 +4688,7 @@ QgsMapCanvasDockWidget *QgisApp::createNewMapCanvasDock( const QString &name, bo markDirty(); mapCanvas->setCustomDropHandlers( mCustomDropHandlers ); - connect( mapCanvasWidget->dockableWidgetHelper(), &QgsDockableWidgetHelper::closed, this, [ this, mapCanvasWidget] - { + connect( mapCanvasWidget->dockableWidgetHelper(), &QgsDockableWidgetHelper::closed, this, [this, mapCanvasWidget] { mOpen2DMapViews.remove( mapCanvasWidget ); mapCanvasWidget->deleteLater(); markDirty(); @@ -4805,7 +4706,7 @@ void QgisApp::setupDockWidget( QDockWidget *dockWidget, bool isFloating, QRect d if ( dockGeometry.isEmpty() ) { // try to guess a nice initial placement for view - about 3/4 along, half way down - dockWidget->setGeometry( QRect( static_cast< int >( rect().width() * 0.75 ), static_cast< int >( rect().height() * 0.5 ), 400, 400 ) ); + dockWidget->setGeometry( QRect( static_cast( rect().width() * 0.75 ), static_cast( rect().height() * 0.5 ), 400, 400 ) ); addDockWidget( area, dockWidget ); } else @@ -4840,7 +4741,7 @@ void QgisApp::closeMapCanvas( const QString &name ) } } - const auto dockWidgets = findChildren< QgsMapCanvasDockWidget * >(); + const auto dockWidgets = findChildren(); for ( QgsMapCanvasDockWidget *w : dockWidgets ) { if ( w->mapCanvas()->objectName() == name ) @@ -4863,7 +4764,7 @@ void QgisApp::closeAdditionalMapCanvases() } mOpen2DMapViews.clear(); - const auto dockWidgets = findChildren< QgsMapCanvasDockWidget * >(); + const auto dockWidgets = findChildren(); for ( QgsMapCanvasDockWidget *w : dockWidgets ) { w->close(); @@ -4947,25 +4848,24 @@ void QgisApp::initLayerTreeView() mLayerTreeView->setMessageBar( mInfoBar ); mLayerTreeView->setMenuProvider( new QgsAppLayerTreeViewMenuProvider( mLayerTreeView, mMapCanvas ) ); - new QgsLayerTreeViewFilterIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - new QgsLayerTreeViewEmbeddedIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - new QgsLayerTreeViewMemoryIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - new QgsLayerTreeViewNotesIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - new QgsLayerTreeViewTemporalIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - new QgsLayerTreeViewNoCrsIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - new QgsLayerTreeViewOfflineIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - new QgsLayerTreeViewLowAccuracyIndicatorProvider( mLayerTreeView ); // gets parented to the layer view - QgsLayerTreeViewBadLayerIndicatorProvider *badLayerIndicatorProvider = new QgsLayerTreeViewBadLayerIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewFilterIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewEmbeddedIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewMemoryIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewNotesIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewTemporalIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewNoCrsIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewOfflineIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewLowAccuracyIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + QgsLayerTreeViewBadLayerIndicatorProvider *badLayerIndicatorProvider = new QgsLayerTreeViewBadLayerIndicatorProvider( mLayerTreeView ); // gets parented to the layer view connect( badLayerIndicatorProvider, &QgsLayerTreeViewBadLayerIndicatorProvider::requestChangeDataSource, this, &QgisApp::changeDataSource ); - new QgsLayerTreeViewNonRemovableIndicatorProvider( mLayerTreeView ); // gets parented to the layer view + new QgsLayerTreeViewNonRemovableIndicatorProvider( mLayerTreeView ); // gets parented to the layer view setupLayerTreeViewFromSettings(); connect( mLayerTreeView, &QAbstractItemView::doubleClicked, this, &QgisApp::layerTreeViewDoubleClicked ); connect( mLayerTreeView, &QgsLayerTreeView::currentLayerChanged, this, &QgisApp::onActiveLayerChanged ); connect( mLayerTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgisApp::updateNewLayerInsertionPoint ); - connect( QgsProject::instance()->layerTreeRegistryBridge(), &QgsLayerTreeRegistryBridge::addedLayersToLayerTree, - this, &QgisApp::autoSelectAddedLayer ); + connect( QgsProject::instance()->layerTreeRegistryBridge(), &QgsLayerTreeRegistryBridge::addedLayersToLayerTree, this, &QgisApp::autoSelectAddedLayer ); // add group action QAction *actionAddGroup = new QAction( tr( "Add Group" ), this ); @@ -4996,12 +4896,12 @@ void QgisApp::initLayerTreeView() mFilterLegendToggleShowPrivateLayersAction = new QAction( tr( "Show Private Layers" ), this ); mFilterLegendToggleShowPrivateLayersAction->setCheckable( true ); - connect( mFilterLegendToggleShowPrivateLayersAction, &QAction::toggled, this, [ = ]( bool showPrivateLayers ) { layerTreeView()->setShowPrivateLayers( showPrivateLayers ); } ); + connect( mFilterLegendToggleShowPrivateLayersAction, &QAction::toggled, this, [=]( bool showPrivateLayers ) { layerTreeView()->setShowPrivateLayers( showPrivateLayers ); } ); filterLegendMenu->addAction( mFilterLegendToggleShowPrivateLayersAction ); mFilterLegendToggleHideValidLayersAction = new QAction( tr( "Show Broken Layers Only" ), this ); mFilterLegendToggleHideValidLayersAction->setCheckable( true ); - connect( mFilterLegendToggleHideValidLayersAction, &QAction::toggled, this, [ = ]( bool hideValidLayers ) { layerTreeView()->setHideValidLayers( hideValidLayers ); } ); + connect( mFilterLegendToggleHideValidLayersAction, &QAction::toggled, this, [=]( bool hideValidLayers ) { layerTreeView()->setHideValidLayers( hideValidLayers ); } ); filterLegendMenu->addAction( mFilterLegendToggleHideValidLayersAction ); mLegendExpressionFilterButton = new QgsLegendFilterButton( this ); @@ -5067,8 +4967,7 @@ void QgisApp::initLayerTreeView() connect( mMapCanvas, &QgsMapCanvas::renderStarting, this, &QgisApp::updateFilterLegend ); connect( mMapCanvas, &QgsMapCanvas::renderErrorOccurred, badLayerIndicatorProvider, &QgsLayerTreeViewBadLayerIndicatorProvider::reportLayerError ); - connect( mMapCanvas, &QgsMapCanvas::renderErrorOccurred, mInfoBar, [this]( const QString & error, QgsMapLayer * layer ) - { + connect( mMapCanvas, &QgsMapCanvas::renderErrorOccurred, mInfoBar, [this]( const QString &error, QgsMapLayer *layer ) { mInfoBar->pushItem( new QgsMessageBarItem( layer->name(), QgsStringUtils::insertLinks( error ), Qgis::MessageLevel::Warning ) ); } ); } @@ -5264,12 +5163,10 @@ void QgisApp::updateRecentProjectPaths() for ( const QgsRecentProjectItemsModel::RecentProjectData &recentProject : constMRecentProjects ) { QAction *action = mRecentProjectsMenu->addAction( - QStringLiteral( "%1 (%2)" ) - .arg( recentProject.title != recentProject.path - ? recentProject.title - : QFileInfo( recentProject.path ).completeBaseName(), QDir::toNativeSeparators( recentProject.path ) - ).replace( "&", "&&" ) - ); + QStringLiteral( "%1 (%2)" ) + .arg( recentProject.title != recentProject.path ? recentProject.title : QFileInfo( recentProject.path ).completeBaseName(), QDir::toNativeSeparators( recentProject.path ) ) + .replace( "&", "&&" ) + ); QgsProjectStorage *storage = QgsApplication::projectStorageRegistry()->projectStorageFromUri( recentProject.path ); @@ -5303,10 +5200,10 @@ void QgisApp::updateRecentProjectPaths() { mRecentProjectsMenu->addSeparator(); QAction *clearRecentProjectsAction = mRecentProjectsMenu->addAction( tr( "Clear List" ) ); - connect( clearRecentProjectsAction, &QAction::triggered, mWelcomePage, [ = ]() { mWelcomePage->clearRecentProjects(); } ); + connect( clearRecentProjectsAction, &QAction::triggered, mWelcomePage, [=]() { mWelcomePage->clearRecentProjects(); } ); } - std::vector< QgsNative::RecentProjectProperties > recentProjects; + std::vector recentProjects; for ( const QgsRecentProjectItemsModel::RecentProjectData &recentProject : std::as_const( mRecentProjects ) ) { QgsNative::RecentProjectProperties project; @@ -5329,14 +5226,13 @@ void QgisApp::saveRecentProjectPath( bool savePreviewImage, const QIcon &iconOve // Get canonical absolute path QgsRecentProjectItemsModel::RecentProjectData projectData; projectData.path = QgsProject::instance()->absoluteFilePath(); - QString templateDirName = QgsSettings().value( QStringLiteral( "qgis/projectTemplateDir" ), - QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); + QString templateDirName = QgsSettings().value( QStringLiteral( "qgis/projectTemplateDir" ), QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); // We don't want the template path to appear in the recent projects list. Never. if ( projectData.path.startsWith( templateDirName ) ) return; - if ( projectData.path.isEmpty() ) // in case of custom project storage + if ( projectData.path.isEmpty() ) // in case of custom project storage projectData.path = !QgsProject::instance()->fileName().isEmpty() ? QgsProject::instance()->fileName() : QgsProject::instance()->originalPath(); projectData.title = QgsProject::instance()->title(); if ( projectData.title.isEmpty() ) @@ -5394,7 +5290,7 @@ void QgisApp::saveRecentProjectPath( bool savePreviewImage, const QIcon &iconOve // Keep the list to maxProjects items by trimming excess off the bottom // And remove the associated image - while ( static_cast< uint >( mRecentProjects.count() ) > maxProjects + pinnedCount ) + while ( static_cast( mRecentProjects.count() ) > maxProjects + pinnedCount ) { const QString previewImagePath = mRecentProjects.takeLast().previewImagePath; if ( QFileInfo::exists( previewImagePath ) ) @@ -5440,8 +5336,7 @@ void QgisApp::updateProjectFromTemplates() { // get list of project files in template dir QgsSettings settings; - QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); + QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); QDir templateDir( templateDirName ); QStringList filters( QStringLiteral( "*.qgs" ) ); filters << QStringLiteral( "*.qgz" ); @@ -5509,14 +5404,12 @@ void QgisApp::restoreWindowState() QSize pos = mScreenHelper->availableGeometry().size() * 0.1; move( pos.width(), pos.height() ); } - } ///////////// END OF GUI SETUP ROUTINES /////////////// void QgisApp::sponsors() { QgsSettings settings; - QString qgisSponsorsUrl = settings.value( QStringLiteral( "qgis/qgisSponsorsUrl" ), - tr( "https://qgis.org/funding/membership/members/" ) ).toString(); + QString qgisSponsorsUrl = settings.value( QStringLiteral( "qgis/qgisSponsorsUrl" ), tr( "https://qgis.org/funding/membership/members/" ) ).toString(); openURL( qgisSponsorsUrl, false ); } @@ -5552,7 +5445,8 @@ QString QgisApp::getVersionString() else { versionString += QStringLiteral( "Release %1.%2" ) - .arg( Qgis::versionInt() / 10000 ).arg( Qgis::versionInt() / 100 % 100 ); + .arg( Qgis::versionInt() / 10000 ) + .arg( Qgis::versionInt() / 100 % 100 ); } } else @@ -5564,8 +5458,8 @@ QString QgisApp::getVersionString() versionString += QStringLiteral( " %1" ).arg( tr( "Libraries" ) ); versionString += QLatin1String( "" ); // Qt version - const QString qtVersionCompiled{ QT_VERSION_STR }; - const QString qtVersionRunning{ qVersion() }; + const QString qtVersionCompiled { QT_VERSION_STR }; + const QString qtVersionRunning { qVersion() }; versionString += QStringLiteral( "%1%2" ).arg( tr( "Qt version" ), qtVersionCompiled ); if ( qtVersionCompiled != qtVersionRunning ) { @@ -5632,14 +5526,14 @@ QString QgisApp::getVersionString() // PDAL #ifdef HAVE_PDAL_QGIS const QString pdalVersionCompiled { PDAL_VERSION }; -#if PDAL_VERSION_MAJOR_INT > 1 || (PDAL_VERSION_MAJOR_INT == 1 && PDAL_VERSION_MINOR_INT >= 7) +#if PDAL_VERSION_MAJOR_INT > 1 || ( PDAL_VERSION_MAJOR_INT == 1 && PDAL_VERSION_MINOR_INT >= 7 ) const QString pdalVersionRunningRaw { QString::fromStdString( pdal::Config::fullVersionString() ) }; #else const QString pdalVersionRunningRaw { QString::fromStdString( pdal::GetFullVersionString() ) }; #endif - const thread_local QRegularExpression pdalVersionRx { QStringLiteral( "(\\d+\\.\\d+\\.\\d+)" )}; - const QRegularExpressionMatch pdalVersionMatch{ pdalVersionRx.match( pdalVersionRunningRaw ) }; - const QString pdalVersionRunning{ pdalVersionMatch.hasMatch() ? pdalVersionMatch.captured( 1 ) : pdalVersionRunningRaw }; + const thread_local QRegularExpression pdalVersionRx { QStringLiteral( "(\\d+\\.\\d+\\.\\d+)" ) }; + const QRegularExpressionMatch pdalVersionMatch { pdalVersionRx.match( pdalVersionRunningRaw ) }; + const QString pdalVersionRunning { pdalVersionMatch.hasMatch() ? pdalVersionMatch.captured( 1 ) : pdalVersionRunningRaw }; versionString += QStringLiteral( "%1%2" ).arg( tr( "PDAL version" ), pdalVersionCompiled ); if ( pdalVersionCompiled != pdalVersionRunning ) { @@ -5789,7 +5683,7 @@ void QgisApp::fileExit() if ( QgsApplication::taskManager()->countActiveTasks() > 0 ) { QStringList tasks; - const QList< QgsTask * > activeTasks = QgsApplication::taskManager()->activeTasks(); + const QList activeTasks = QgsApplication::taskManager()->activeTasks(); for ( QgsTask *task : activeTasks ) { if ( task->flags() & QgsTask::CancelWithoutPrompt ) @@ -5806,9 +5700,7 @@ void QgisApp::fileExit() } else { - if ( QMessageBox::question( this, tr( "Active Tasks" ), - tr( "The following tasks are currently running in the background:\n\n%1\n\nDo you want to try canceling these active tasks?" ).arg( tasks.join( QLatin1Char( '\n' ) ) ), - QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + if ( QMessageBox::question( this, tr( "Active Tasks" ), tr( "The following tasks are currently running in the background:\n\n%1\n\nDo you want to try canceling these active tasks?" ).arg( tasks.join( QLatin1Char( '\n' ) ) ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { QgsApplication::taskManager()->cancelAll(); } @@ -5904,19 +5796,19 @@ bool QgisApp::fileNew( bool promptToSaveFlag, bool forceBlank ) in case a project was defined via command line */ // don't open template if last auto-opening of a project failed - if ( ! forceBlank ) + if ( !forceBlank ) { - forceBlank = ! settings.value( QStringLiteral( "qgis/projOpenedOKAtLaunch" ), QVariant( true ) ).toBool(); + forceBlank = !settings.value( QStringLiteral( "qgis/projOpenedOKAtLaunch" ), QVariant( true ) ).toBool(); } - if ( ! forceBlank && settings.value( QStringLiteral( "qgis/newProjectDefault" ), QVariant( false ) ).toBool() ) + if ( !forceBlank && settings.value( QStringLiteral( "qgis/newProjectDefault" ), QVariant( false ) ).toBool() ) { fileNewFromDefaultTemplate(); } // set the initial map tool mMapCanvas->setMapTool( mMapTools->mapTool( QgsAppMapTools::Pan ) ); - mNonEditMapTool = mMapTools->mapTool( QgsAppMapTools::Pan ); // signals are not yet setup to catch this + mNonEditMapTool = mMapTools->mapTool( QgsAppMapTools::Pan ); // signals are not yet setup to catch this prj->setDirty( false ); return true; @@ -5959,9 +5851,7 @@ void QgisApp::fileNewFromDefaultTemplate() { msgTxt = tr( "Default not found: %1" ); } - visibleMessageBar()->pushMessage( tr( "Open Template Project" ), - msgTxt.arg( projectTemplate ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Open Template Project" ), msgTxt.arg( projectTemplate ), Qgis::MessageLevel::Warning ); } void QgisApp::fileOpenAfterLaunch() @@ -6022,9 +5912,7 @@ void QgisApp::fileOpenAfterLaunch() // set auto-open project back to 'New' to avoid re-opening bad project settings.setValue( QStringLiteral( "qgis/projOpenAtLaunch" ), QVariant( 0 ) ); - visibleMessageBar()->pushMessage( autoOpenMsgTitle, - tr( "Failed to open: %1" ).arg( projPath ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( autoOpenMsgTitle, tr( "Failed to open: %1" ).arg( projPath ), Qgis::MessageLevel::Critical ); return; } @@ -6046,13 +5934,9 @@ void QgisApp::fileOpenAfterLaunch() // Is this a storage based project? const bool projectIsFromStorage = QgsApplication::projectStorageRegistry()->projectStorageFromUri( projPath ); - if ( !projectIsFromStorage && - !projPath.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) && - !projPath.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ) + if ( !projectIsFromStorage && !projPath.endsWith( QLatin1String( ".qgs" ), Qt::CaseInsensitive ) && !projPath.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) ) { - visibleMessageBar()->pushMessage( autoOpenMsgTitle, - tr( "Not valid project file: %1" ).arg( projPath ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( autoOpenMsgTitle, tr( "Not valid project file: %1" ).arg( projPath ), Qgis::MessageLevel::Warning ); return; } @@ -6063,23 +5947,17 @@ void QgisApp::fileOpenAfterLaunch() if ( !addProject( projPath ) ) { - visibleMessageBar()->pushMessage( autoOpenMsgTitle, - tr( "Project failed to open: %1" ).arg( projPath ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( autoOpenMsgTitle, tr( "Project failed to open: %1" ).arg( projPath ), Qgis::MessageLevel::Warning ); } if ( projPath.endsWith( QLatin1String( "project_default.qgs" ) ) ) { - visibleMessageBar()->pushMessage( autoOpenMsgTitle, - tr( "Default template has been reopened: %1" ).arg( projPath ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( autoOpenMsgTitle, tr( "Default template has been reopened: %1" ).arg( projPath ), Qgis::MessageLevel::Info ); } } else { - visibleMessageBar()->pushMessage( autoOpenMsgTitle, - tr( "File not found: %1" ).arg( projPath ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( autoOpenMsgTitle, tr( "File not found: %1" ).arg( projPath ), Qgis::MessageLevel::Warning ); } } @@ -6091,7 +5969,7 @@ void QgisApp::fileOpenedOKAfterLaunch() void QgisApp::fileNewFromTemplateAction( QAction *qAction ) { - if ( ! qAction ) + if ( !qAction ) return; if ( qAction->text() == tr( "< Blank >" ) ) @@ -6101,8 +5979,7 @@ void QgisApp::fileNewFromTemplateAction( QAction *qAction ) else { QgsSettings settings; - QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); + QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); fileNewFromTemplate( templateDirName + QDir::separator() + qAction->text() ); } } @@ -6140,7 +6017,7 @@ void QgisApp::newMemoryLayer() if ( newLayer ) { //then add the layer to the view - QList< QgsMapLayer * > layers; + QList layers; layers << newLayer; QgsProject::instance()->addMapLayers( layers ); @@ -6174,43 +6051,35 @@ void QgisApp::newGpxLayer() { QgsSettings settings; const QString dir = settings.value( QStringLiteral( "gps/gpxdirectory" ), QDir::homePath(), QgsSettings::App ).toString(); - QString fileName = - QFileDialog::getSaveFileName( this, - tr( "New GPX File" ), - dir, - tr( "GPS eXchange file" ) + " (*.gpx)" ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "New GPX File" ), dir, tr( "GPS eXchange file" ) + " (*.gpx)" ); if ( !fileName.isEmpty() ) { - fileName = QgsFileUtils::ensureFileNameHasExtension( fileName, { QStringLiteral( "gpx" )} ); + fileName = QgsFileUtils::ensureFileNameHasExtension( fileName, { QStringLiteral( "gpx" ) } ); const QFileInfo fileInfo( fileName ); settings.setValue( QStringLiteral( "gps/gpxdirectory" ), fileInfo.absolutePath(), QgsSettings::App ); QFile outputFile( fileName ); if ( !outputFile.open( QFile::WriteOnly | QIODevice::Truncate ) ) { - QMessageBox::warning( nullptr, tr( "New GPX File" ), - tr( "Unable to create a GPX file with the given name. " - "Try again with another name or in another " - "directory." ) ); + QMessageBox::warning( nullptr, tr( "New GPX File" ), tr( "Unable to create a GPX file with the given name. " + "Try again with another name or in another " + "directory." ) ); return; } QTextStream outStream( &outputFile ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) outStream.setCodec( "UTF-8" ); #endif outStream << "" << Qt::endl; outputFile.close(); - if ( QgsVectorLayer *trackLayer = addVectorLayer( fileName + "?type=track", - fileInfo.baseName() + ", tracks", QStringLiteral( "gpx" ) ) ) + if ( QgsVectorLayer *trackLayer = addVectorLayer( fileName + "?type=track", fileInfo.baseName() + ", tracks", QStringLiteral( "gpx" ) ) ) trackLayer->startEditing(); - if ( QgsVectorLayer *routeLayer = addVectorLayer( fileName + "?type=route", - fileInfo.baseName() + ", routes", QStringLiteral( "gpx" ) ) ) + if ( QgsVectorLayer *routeLayer = addVectorLayer( fileName + "?type=route", fileInfo.baseName() + ", routes", QStringLiteral( "gpx" ) ) ) routeLayer->startEditing(); - if ( QgsVectorLayer *waypointLayer = addVectorLayer( fileName + "?type=waypoint", - fileInfo.baseName() + ", waypoints", QStringLiteral( "gpx" ) ) ) + if ( QgsVectorLayer *waypointLayer = addVectorLayer( fileName + "?type=waypoint", fileInfo.baseName() + ", waypoints", QStringLiteral( "gpx" ) ) ) waypointLayer->startEditing(); } } @@ -6232,7 +6101,7 @@ void QgisApp::showRasterCalculator() virtualCalcParams.formula = d.formulaString(); QString errorString; - std::unique_ptr< QgsRasterCalcNode > calcNodeApp( QgsRasterCalcNode::parseRasterCalcString( d.formulaString(), errorString ) ); + std::unique_ptr calcNodeApp( QgsRasterCalcNode::parseRasterCalcString( d.formulaString(), errorString ) ); if ( !calcNodeApp ) { return; @@ -6243,8 +6112,8 @@ void QgisApp::showRasterCalculator() const QVector rasterEntries = QgsRasterCalculatorEntry::rasterEntries(); for ( const QgsRasterCalculatorEntry &r : rasterEntries ) { - if ( ( ! rLayerDictionaryRef.contains( r.ref ) ) || - uniqueRasterUriTmp.contains( qMakePair( r.raster->source(), r.ref.mid( 0, r.ref.lastIndexOf( "@" ) ) ) ) ) continue; + if ( ( !rLayerDictionaryRef.contains( r.ref ) ) || uniqueRasterUriTmp.contains( qMakePair( r.raster->source(), r.ref.mid( 0, r.ref.lastIndexOf( "@" ) ) ) ) ) + continue; uniqueRasterUriTmp.insert( qMakePair( r.raster->source(), r.ref.mid( 0, r.ref.lastIndexOf( "@" ) ) ) ); QgsRasterDataProvider::VirtualRasterInputLayers projectRLayer; @@ -6255,22 +6124,12 @@ void QgisApp::showRasterCalculator() virtualCalcParams.rInputLayers.append( projectRLayer ); } - addRasterLayer( QgsRasterDataProvider::encodeVirtualRasterProviderUri( virtualCalcParams ), - d.virtualLayerName().isEmpty() ? d.formulaString() : d.virtualLayerName(), - QStringLiteral( "virtualraster" ) ); + addRasterLayer( QgsRasterDataProvider::encodeVirtualRasterProviderUri( virtualCalcParams ), d.virtualLayerName().isEmpty() ? d.formulaString() : d.virtualLayerName(), QStringLiteral( "virtualraster" ) ); } else { //invoke analysis library - QgsRasterCalculator rc( d.formulaString(), - d.outputFile(), - d.outputFormat(), - d.outputRectangle(), - d.outputCrs(), - d.numberOfColumns(), - d.numberOfRows(), - QgsRasterCalculatorEntry::rasterEntries(), - QgsProject::instance()->transformContext() ); + QgsRasterCalculator rc( d.formulaString(), d.outputFile(), d.outputFormat(), d.outputRectangle(), d.outputCrs(), d.numberOfColumns(), d.numberOfRows(), QgsRasterCalculatorEntry::rasterEntries(), QgsProject::instance()->transformContext() ); QProgressDialog p( tr( "Calculating raster expression…" ), tr( "Abort" ), 0, 0 ); p.setWindowTitle( tr( "Raster calculator" ) ); @@ -6288,48 +6147,34 @@ void QgisApp::showRasterCalculator() { addRasterLayer( d.outputFile(), QFileInfo( d.outputFile() ).completeBaseName(), QStringLiteral( "gdal" ) ); } - visibleMessageBar()->pushMessage( tr( "Raster calculator" ), - tr( "Calculation complete." ), - Qgis::MessageLevel::Success ); + visibleMessageBar()->pushMessage( tr( "Raster calculator" ), tr( "Calculation complete." ), Qgis::MessageLevel::Success ); break; case QgsRasterCalculator::CreateOutputError: - visibleMessageBar()->pushMessage( tr( "Raster calculator" ), - tr( "Could not create destination file." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Raster calculator" ), tr( "Could not create destination file." ), Qgis::MessageLevel::Critical ); break; case QgsRasterCalculator::InputLayerError: - visibleMessageBar()->pushMessage( tr( "Raster calculator" ), - tr( "Could not read input layer." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Raster calculator" ), tr( "Could not read input layer." ), Qgis::MessageLevel::Critical ); break; case QgsRasterCalculator::Canceled: break; case QgsRasterCalculator::ParserError: - visibleMessageBar()->pushMessage( tr( "Raster calculator" ), - tr( "Could not parse raster formula." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Raster calculator" ), tr( "Could not parse raster formula." ), Qgis::MessageLevel::Critical ); break; case QgsRasterCalculator::MemoryError: - visibleMessageBar()->pushMessage( tr( "Raster calculator" ), - tr( "Insufficient memory available for operation." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Raster calculator" ), tr( "Insufficient memory available for operation." ), Qgis::MessageLevel::Critical ); break; case QgsRasterCalculator::BandError: - visibleMessageBar()->pushMessage( tr( "Raster calculator" ), - tr( "Invalid band number for input layer." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Raster calculator" ), tr( "Invalid band number for input layer." ), Qgis::MessageLevel::Critical ); break; case QgsRasterCalculator::CalculationError: - visibleMessageBar()->pushMessage( tr( "Raster calculator" ), - tr( "An error occurred while performing the calculation." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Raster calculator" ), tr( "An error occurred while performing the calculation." ), Qgis::MessageLevel::Critical ); break; } p.hide(); @@ -6361,48 +6206,34 @@ void QgisApp::showMeshCalculator() switch ( res ) { case QgsMeshCalculator::Success: - visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), - tr( "Calculation complete." ), - Qgis::MessageLevel::Success ); + visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), tr( "Calculation complete." ), Qgis::MessageLevel::Success ); break; case QgsMeshCalculator::EvaluateError: - visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), - tr( "Could not evaluate the formula." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), tr( "Could not evaluate the formula." ), Qgis::MessageLevel::Critical ); break; case QgsMeshCalculator::InvalidDatasets: - visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), - tr( "Invalid or incompatible datasets used." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), tr( "Invalid or incompatible datasets used." ), Qgis::MessageLevel::Critical ); break; case QgsMeshCalculator::CreateOutputError: - visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), - tr( "Could not create destination file." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), tr( "Could not create destination file." ), Qgis::MessageLevel::Critical ); break; case QgsMeshCalculator::InputLayerError: - visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), - tr( "Could not read input layer." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), tr( "Could not read input layer." ), Qgis::MessageLevel::Critical ); break; case QgsMeshCalculator::Canceled: break; case QgsMeshCalculator::ParserError: - visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), - tr( "Could not parse mesh formula." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), tr( "Could not parse mesh formula." ), Qgis::MessageLevel::Critical ); break; case QgsMeshCalculator::MemoryError: - visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), - tr( "Insufficient memory available for operation." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Mesh calculator" ), tr( "Insufficient memory available for operation." ), Qgis::MessageLevel::Critical ); break; } p.hide(); @@ -6444,10 +6275,7 @@ void QgisApp::fileOpen() allEntry += ')'; fileFilters.insert( 0, allEntry ); - QString fullPath = QFileDialog::getOpenFileName( this, - tr( "Open Project" ), - lastUsedDir, - fileFilters.join( QLatin1String( ";;" ) ) ); + QString fullPath = QFileDialog::getOpenFileName( this, tr( "Open Project" ), lastUsedDir, fileFilters.join( QLatin1String( ";;" ) ) ); if ( fullPath.isNull() ) { return; @@ -6465,12 +6293,10 @@ void QgisApp::fileOpen() void QgisApp::fileRevert() { - if ( QMessageBox::question( this, tr( "Revert Project" ), - tr( "Are you sure you want to discard all unsaved changes the current project?" ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::No ) + if ( QMessageBox::question( this, tr( "Revert Project" ), tr( "Are you sure you want to discard all unsaved changes the current project?" ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::No ) return; - if ( !checkUnsavedLayerEdits() || !checkMemoryLayers() || ! checkUnsavedRasterAttributeTableEdits() ) + if ( !checkUnsavedLayerEdits() || !checkMemoryLayers() || !checkUnsavedRasterAttributeTableEdits() ) return; // re-open the current project @@ -6491,7 +6317,7 @@ bool QgisApp::addProject( const QString &projectFile ) QWidgetUpdateBlocker layerTreeViewUpdateBlocker( mLayerTreeView ); bool returnCode = false; - std::unique_ptr< QgsProjectDirtyBlocker > dirtyBlocker = std::make_unique< QgsProjectDirtyBlocker >( QgsProject::instance() ); + std::unique_ptr dirtyBlocker = std::make_unique( QgsProject::instance() ); QObject connectionScope; // manually control scope of layersChanged lambda connection - we need the connection automatically destroyed when this function finishes bool badLayersHandled = false; @@ -6545,10 +6371,7 @@ bool QgisApp::addProject( const QString &projectFile ) QApplication::restoreOverrideCursor(); mStatusBar->clearMessage(); - int r = QMessageBox::critical( this, - tr( "Unable to open project" ), - QgsProject::instance()->error() + loadBackupPrompt, - buttons ); + int r = QMessageBox::critical( this, tr( "Unable to open project" ), QgsProject::instance()->error() + loadBackupPrompt, buttons ); if ( QMessageBox::Yes == r && addProject( backupFile ) ) { @@ -6565,7 +6388,6 @@ bool QgisApp::addProject( const QString &projectFile ) } else { - mProjectLastModified = QgsProject::instance()->lastModified(); setTitleBarText_( *this ); @@ -6599,7 +6421,7 @@ bool QgisApp::addProject( const QString &projectFile ) // does the project have any macros? if ( !QgsProject::instance()->readEntry( QStringLiteral( "Macros" ), QStringLiteral( "/pythonCode" ), QString() ).isEmpty() ) { - auto lambda = []() {QgisApp::instance()->enableProjectMacros();}; + auto lambda = []() { QgisApp::instance()->enableProjectMacros(); }; QgsGui::pythonEmbeddedInProjectAllowed( lambda, mInfoBar, Qgis::PythonEmbeddedType::Macro ); } @@ -6616,7 +6438,7 @@ bool QgisApp::addProject( const QString &projectFile ) QgsScopedRuntimeProfile profile( tr( "Resolve vector layer dependencies" ), QStringLiteral( "projectload" ) ); // Check for missing layer widget dependencies - const auto constVLayers { QgsProject::instance()->layers( ) }; + const auto constVLayers { QgsProject::instance()->layers() }; for ( QgsVectorLayer *vl : constVLayers ) { if ( vl->isValid() ) @@ -6638,8 +6460,7 @@ bool QgisApp::addProject( const QString &projectFile ) { // we have to delay the thumbnail creation until after the canvas has refreshed for the first time QMetaObject::Connection *connection = new QMetaObject::Connection(); - *connection = connect( mMapCanvas, &QgsMapCanvas::mapCanvasRefreshed, this, [ = ]() - { + *connection = connect( mMapCanvas, &QgsMapCanvas::mapCanvasRefreshed, this, [=]() { QObject::disconnect( *connection ); delete connection; saveRecentProjectPath( true, customHandlerIcon ); @@ -6665,7 +6486,6 @@ bool QgisApp::addProject( const QString &projectFile ) } // QgisApp::addProject(QString projectFile) - bool QgisApp::fileSave() { // if we don't have a file name, then obviously we need to get one; note @@ -6684,10 +6504,11 @@ bool QgisApp::fileSave() QString filter; QString path = QFileDialog::getSaveFileName( - this, - tr( "Choose a QGIS project file" ), - lastUsedDir + '/' + QgsProject::instance()->title(), - qgisProjectExt + QStringLiteral( ";;" ) + qgzProjectExt + QStringLiteral( ";;" ) + qgsProjectExt, &filter ); + this, + tr( "Choose a QGIS project file" ), + lastUsedDir + '/' + QgsProject::instance()->title(), + qgisProjectExt + QStringLiteral( ";;" ) + qgzProjectExt + QStringLiteral( ";;" ) + qgsProjectExt, &filter + ); if ( path.isEmpty() ) return false; @@ -6729,18 +6550,13 @@ bool QgisApp::fileSave() if ( fileExists && !mProjectLastModified.isNull() && mProjectLastModified != QgsProject::instance()->lastModified() ) { - if ( QMessageBox::warning( this, - tr( "Project Has Changed on Disk" ), - tr( "The project file on the disk has been modified externally, saving the current project will overwrite any change. Do you still want to proceed?" ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( QMessageBox::warning( this, tr( "Project Has Changed on Disk" ), tr( "The project file on the disk has been modified externally, saving the current project will overwrite any change. Do you still want to proceed?" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) return false; } - if ( fileExists && !usingProjectStorage && ! QFileInfo( QgsProject::instance()->fileName() ).isWritable() ) + if ( fileExists && !usingProjectStorage && !QFileInfo( QgsProject::instance()->fileName() ).isWritable() ) { - visibleMessageBar()->pushMessage( tr( "Insufficient permissions" ), - tr( "The project file is not writable." ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Insufficient permissions" ), tr( "The project file is not writable." ), Qgis::MessageLevel::Warning ); return false; } } @@ -6760,9 +6576,7 @@ bool QgisApp::fileSave() } else { - QMessageBox::critical( this, - tr( "Unable to save project %1" ).arg( QDir::toNativeSeparators( QgsProject::instance()->fileName() ) ), - QgsProject::instance()->error() ); + QMessageBox::critical( this, tr( "Unable to save project %1" ).arg( QDir::toNativeSeparators( QgsProject::instance()->fileName() ) ), QgsProject::instance()->error() ); mProjectLastModified = QgsProject::instance()->lastModified(); return false; } @@ -6800,10 +6614,11 @@ void QgisApp::fileSaveAs() QString filter; QString path = QFileDialog::getSaveFileName( - this, - tr( "Save Project As" ), - defaultPath, - qgisProjectExt + QStringLiteral( ";;" ) + qgzProjectExt + QStringLiteral( ";;" ) + qgsProjectExt, &filter ); + this, + tr( "Save Project As" ), + defaultPath, + qgisProjectExt + QStringLiteral( ";;" ) + qgzProjectExt + QStringLiteral( ";;" ) + qgsProjectExt, &filter + ); if ( path.isEmpty() ) return; @@ -6847,11 +6662,7 @@ void QgisApp::fileSaveAs() } else { - QMessageBox::critical( this, - tr( "Unable to save project %1" ).arg( QDir::toNativeSeparators( QgsProject::instance()->fileName() ) ), - QgsProject::instance()->error(), - QMessageBox::Ok, - Qt::NoButton ); + QMessageBox::critical( this, tr( "Unable to save project %1" ).arg( QDir::toNativeSeparators( QgsProject::instance()->fileName() ) ), QgsProject::instance()->error(), QMessageBox::Ok, Qt::NoButton ); } mProjectLastModified = fullPath.lastModified(); } // QgisApp::fileSaveAs @@ -6909,8 +6720,7 @@ void QgisApp::dxfExport() { QPushButton *detailsButton = new QPushButton( tr( "More Info" ) ); const QString feedbackMessage = dxfExport.feedbackMessage(); - connect( detailsButton, &QPushButton::clicked, this, [detailsButton, feedbackMessage] - { + connect( detailsButton, &QPushButton::clicked, this, [detailsButton, feedbackMessage] { QgsMessageViewer *dialog = new QgsMessageViewer( detailsButton ); dialog->setTitle( tr( "DXF Export" ) ); dialog->setMessageAsPlainText( feedbackMessage ); @@ -6923,20 +6733,15 @@ void QgisApp::dxfExport() } case QgsDxfExport::ExportResult::DeviceNotWritableError: - visibleMessageBar()->pushMessage( tr( "DXF export" ), - tr( "DXF export failed, device is not writable" ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "DXF export" ), tr( "DXF export failed, device is not writable" ), Qgis::MessageLevel::Critical ); break; case QgsDxfExport::ExportResult::InvalidDeviceError: - visibleMessageBar()->pushMessage( tr( "DXF export" ), - tr( "DXF export failed, the device is invalid" ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "DXF export" ), tr( "DXF export failed, the device is invalid" ), Qgis::MessageLevel::Critical ); break; case QgsDxfExport::ExportResult::EmptyExtentError: - visibleMessageBar()->pushMessage( tr( "DXF export" ), - tr( "DXF export failed, the extent could not be determined" ), Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "DXF export" ), tr( "DXF export failed, the extent could not be determined" ), Qgis::MessageLevel::Critical ); break; } QApplication::restoreOverrideCursor(); @@ -6978,7 +6783,7 @@ void QgisApp::openTemplate( const QString &fileName ) } //create new layout object - std::unique_ptr< QgsPrintLayout > layout = std::make_unique< QgsPrintLayout >( QgsProject::instance() ); + std::unique_ptr layout = std::make_unique( QgsProject::instance() ); bool loadedOk = false; layout->loadFromTemplate( templateDoc, QgsReadWriteContext(), true, &loadedOk ); if ( loadedOk ) @@ -7004,7 +6809,7 @@ void QgisApp::openProject( QAction *action ) const int projectIndex = action->data().toInt( &ok ); if ( !ok || projectIndex < 0 || projectIndex >= mRecentProjects.count() ) return; - QString project = mRecentProjects.at( projectIndex ).path; + QString project = mRecentProjects.at( projectIndex ).path; project.replace( "&&", "&" ); // possibly save any pending work before opening a different project @@ -7041,8 +6846,7 @@ void QgisApp::runScript( const QString &filePath ) if ( !showScriptWarning || msgbox.result() == QMessageBox::Yes ) { - mPythonUtils->runString( QString( "qgis.utils.run_script_from_file(\"%1\")" ).arg( filePath ), - tr( "Failed to run Python script:" ), false ); + mPythonUtils->runString( QString( "qgis.utils.run_script_from_file(\"%1\")" ).arg( filePath ), tr( "Failed to run Python script:" ), false ); } #else Q_UNUSED( filePath ) @@ -7064,9 +6868,9 @@ void QgisApp::openProject( const QString &fileName ) } // Open a file specified by a commandline argument, Drop or FileOpen event. -QList< QgsMapLayer * > QgisApp::openFile( const QString &fileName, const QString &fileTypeHint, bool suppressBulkLayerPostProcessing, bool addToLegend ) +QList QgisApp::openFile( const QString &fileName, const QString &fileTypeHint, bool suppressBulkLayerPostProcessing, bool addToLegend ) { - QList< QgsMapLayer * > res; + QList res; // check to see if we are opening a project file QFileInfo fi( fileName ); @@ -7156,7 +6960,7 @@ void QgisApp::activateTritanopePreview() void QgisApp::toggleFilterLegendByExpression( bool checked ) { QgsLayerTreeNode *node = mLayerTreeView->currentNode(); - if ( ! node ) + if ( !node ) return; if ( QgsLayerTree::isLayer( node ) ) @@ -7191,9 +6995,9 @@ void QgisApp::updateFilterLegend() } } -QList< QgsMapDecoration * > QgisApp::activeDecorations() +QList QgisApp::activeDecorations() { - QList< QgsMapDecoration * > decorations; + QList decorations; const auto constMDecorationItems = mDecorationItems; for ( QgsDecorationItem *decoration : constMDecorationItems ) { @@ -7325,10 +7129,9 @@ void QgisApp::toggleReducedView( bool viewMapOnly ) bool allWidgetsVisible = settings.value( QStringLiteral( "UI/allWidgetsVisible" ), true ).toBool(); - if ( allWidgetsVisible ) // that is: currently nothing is hidden + if ( allWidgetsVisible ) // that is: currently nothing is hidden { - - if ( viewMapOnly ) // + if ( viewMapOnly ) // { // hide also statusbar and menubar and all toolbars for ( QToolBar *toolBar : toolBars ) @@ -7372,7 +7175,7 @@ void QgisApp::toggleReducedView( bool viewMapOnly ) settings.setValue( QStringLiteral( "UI/allWidgetsVisible" ), false ); } - else // currently panels or other widgets are hidden: show ALL based on 'remembered UI settings' + else // currently panels or other widgets are hidden: show ALL based on 'remembered UI settings' { for ( QDockWidget *dock : docks ) { @@ -7520,12 +7323,12 @@ void QgisApp::toggleSelectedLayers() QgsDebugMsgLevel( QStringLiteral( "toggling selected layers!" ), 3 ); const auto constSelectedNodes = mLayerTreeView->selectedNodes(); - if ( ! constSelectedNodes.isEmpty() ) + if ( !constSelectedNodes.isEmpty() ) { bool isFirstNodeChecked = constSelectedNodes[0]->itemVisibilityChecked(); for ( QgsLayerTreeNode *node : constSelectedNodes ) { - node->setItemVisibilityChecked( ! isFirstNodeChecked ); + node->setItemVisibilityChecked( !isFirstNodeChecked ); } } } @@ -7535,11 +7338,11 @@ void QgisApp::toggleSelectedLayersIndependently() QgsDebugMsgLevel( QStringLiteral( "toggling selected layers independently!" ), 3 ); const auto constSelectedNodes = mLayerTreeView->selectedNodes(); - if ( ! constSelectedNodes.isEmpty() ) + if ( !constSelectedNodes.isEmpty() ) { for ( QgsLayerTreeNode *node : constSelectedNodes ) { - node->setItemVisibilityChecked( ! node->itemVisibilityChecked() ); + node->setItemVisibilityChecked( !node->itemVisibilityChecked() ); } } } @@ -7596,7 +7399,6 @@ void QgisApp::zoomToSelected() else mMapCanvas->zoomToSelected(); - } void QgisApp::panToSelected() @@ -7713,7 +7515,8 @@ void QgisApp::refreshFeatureActions() if ( !vlayer->isEditable() && action.isEnabledOnlyWhenEditable() ) continue; - QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QString(); + QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() + : QString(); QAction *qAction = new QAction( action.icon(), actionTitle, mFeatureActionMenu ); qAction->setData( QVariant::fromValue( action ) ); mFeatureActionMenu->addAction( qAction ); @@ -7763,8 +7566,7 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) dlg.expandPath( pathInfo.isDir() ? closestPath : pathInfo.dir().path(), true ); if ( source.contains( path ) ) { - source.replace( path, QStringLiteral( "%2" ).arg( QUrl::fromLocalFile( closestPath ).toString(), - path ) ); + source.replace( path, QStringLiteral( "%2" ).arg( QUrl::fromLocalFile( closestPath ).toString(), path ) ); } else { @@ -7772,8 +7574,7 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) const QString uriEncodedPath = QUrl( path ).toString( QUrl::FullyEncoded ); if ( source.contains( uriEncodedPath ) ) { - source.replace( uriEncodedPath, QStringLiteral( "%2" ).arg( QUrl::fromLocalFile( closestPath ).toString(), - uriEncodedPath ) ); + source.replace( uriEncodedPath, QStringLiteral( "%2" ).arg( QUrl::fromLocalFile( closestPath ).toString(), uriEncodedPath ) ); } } } @@ -7786,8 +7587,7 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) QgsMimeDataUtils::Uri uri( dlg.uri() ); if ( uri.isValid() ) { - auto fixLayer = [this]( QgsMapLayer * layer, const QgsMimeDataUtils::Uri & uri ) - { + auto fixLayer = [this]( QgsMapLayer *layer, const QgsMimeDataUtils::Uri &uri ) { bool layerWasValid( layer->isValid() ); const QString previousProvider = layer->providerType(); // Store subset string from vlayer if we are fixing a bad layer @@ -7795,9 +7595,7 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) QString subsetString; // Get the subset string directly from the data provider because // layer's method will return a null string from invalid layers - if ( vlayer && vlayer->dataProvider() && - vlayer->dataProvider()->supportsSubsetString() && - !vlayer->dataProvider()->subsetString( ).isEmpty() ) + if ( vlayer && vlayer->dataProvider() && vlayer->dataProvider()->supportsSubsetString() && !vlayer->dataProvider()->subsetString().isEmpty() ) { subsetString = vlayer->dataProvider()->subsetString(); } @@ -7831,7 +7629,7 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) // Re-apply original style and subset string when fixing bad layers if ( !( layerWasValid || layer->originalXmlProperties().isEmpty() ) ) { - if ( vlayer && ! subsetString.isEmpty() ) + if ( vlayer && !subsetString.isEmpty() ) { vlayer->setSubsetString( subsetString ); } @@ -7842,19 +7640,17 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) QDomDocument doc; if ( doc.setContent( layer->originalXmlProperties() ) ) { - QDomNode layer_node( doc.firstChild( ) ); - if ( ! layer->readSymbology( layer_node, errorMsg, context ) ) + QDomNode layer_node( doc.firstChild() ); + if ( !layer->readSymbology( layer_node, errorMsg, context ) ) { QgsDebugError( QStringLiteral( "Failed to restore original layer style from stored XML for layer %1: %2" ) - .arg( layer->name( ), - errorMsg ) ); + .arg( layer->name(), errorMsg ) ); } } else { QgsDebugError( QStringLiteral( "Failed to create XML QDomDocument for layer %1: %2" ) - .arg( layer->name( ), - errorMsg ) ); + .arg( layer->name(), errorMsg ) ); } } else if ( vlayer && !subsetString.isEmpty() ) @@ -7878,9 +7674,9 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) } // Tell the bridge that we have fixed a layer - if ( ! layerWasValid && layer->isValid() ) + if ( !layerWasValid && layer->isValid() ) { - QgsProject::instance()->layerTreeRoot()->customLayerOrderChanged( ); + QgsProject::instance()->layerTreeRoot()->customLayerOrderChanged(); } }; @@ -7893,7 +7689,7 @@ void QgisApp::changeDataSource( QgsMapLayer *layer ) const QString originalPath = originalSourceParts.value( QStringLiteral( "path" ) ).toString(); const QFileInfo originalPathFi( originalPath ); - const QMap< QString, QgsMapLayer * > layers = QgsProject::instance()->mapLayers( false ); + const QMap layers = QgsProject::instance()->mapLayers( false ); for ( auto it = layers.begin(); it != layers.end(); ++it ) { if ( it.value()->isValid() ) @@ -7979,14 +7775,11 @@ void QgisApp::commitError( QgsVectorLayer *vlayer, const QStringList &commitErro } const QString messageText = vlayer ? tr( "Could not commit changes to layer %1" ).arg( vlayer->name() ) - : tr( "Could not commit changes" ); + : tr( "Could not commit changes" ); QgsMessageViewer *mv = new QgsMessageViewer(); mv->setWindowTitle( tr( "Commit Errors" ) ); - mv->setMessageAsPlainText( messageText - + "\n\n" - + tr( "Errors: %1\n" ).arg( commitErrors.join( QLatin1String( "\n " ) ) ) - ); + mv->setMessageAsPlainText( messageText + "\n\n" + tr( "Errors: %1\n" ).arg( commitErrors.join( QLatin1String( "\n " ) ) ) ); QToolButton *showMore = new QToolButton(); QAction *act = new QAction( showMore ); @@ -8006,7 +7799,8 @@ void QgisApp::commitError( QgsVectorLayer *vlayer, const QStringList &commitErro showMore, Qgis::MessageLevel::Warning, 0, - messageBar() ); + messageBar() + ); messageBar()->pushItem( errorMsg ); } @@ -8063,10 +7857,7 @@ void QgisApp::diagramProperties() QgsVectorLayer *vlayer = qobject_cast( activeLayer() ); if ( !vlayer ) { - visibleMessageBar()->pushMessage( tr( "Diagram Properties" ), - tr( "Please select a vector layer first" ), - Qgis::MessageLevel::Info - ); + visibleMessageBar()->pushMessage( tr( "Diagram Properties" ), tr( "Please select a vector layer first" ), Qgis::MessageLevel::Info ); return; } @@ -8137,10 +7928,7 @@ QString QgisApp::saveAsRasterFile( QgsRasterLayer *rasterLayer, const bool defau return QString(); } - QgsRasterLayerSaveAsDialog d( rasterLayer, rasterLayer->dataProvider(), - mMapCanvas->extent(), rasterLayer->crs(), - mMapCanvas->mapSettings().destinationCrs(), - this ); + QgsRasterLayerSaveAsDialog d( rasterLayer, rasterLayer->dataProvider(), mMapCanvas->extent(), rasterLayer->crs(), mMapCanvas->mapSettings().destinationCrs(), this ); d.setAddToCanvas( defaultAddToCanvas ); if ( d.exec() == QDialog::Rejected ) return QString(); @@ -8176,7 +7964,7 @@ QString QgisApp::saveAsRasterFile( QgsRasterLayer *rasterLayer, const bool defau } QgsRasterNuller *nuller = new QgsRasterNuller(); - for ( int band = 1; band <= rasterLayer->dataProvider()->bandCount(); band ++ ) + for ( int band = 1; band <= rasterLayer->dataProvider()->bandCount(); band++ ) { nuller->setNoData( band, d.noData() ); } @@ -8226,18 +8014,15 @@ QString QgisApp::saveAsRasterFile( QgsRasterLayer *rasterLayer, const bool defau bool tileMode = d.tileMode(); bool addToCanvas = d.addToCanvas(); - QPointer< QgsRasterLayer > rlWeakPointer( rasterLayer ); + QPointer rlWeakPointer( rasterLayer ); QString outputLayerName = d.outputLayerName(); QString outputFormat = d.outputFormat(); - QgsRasterFileWriterTask *writerTask = new QgsRasterFileWriterTask( fileWriter, pipe.release(), d.nColumns(), d.nRows(), - d.outputRectangle(), d.outputCrs(), QgsProject::instance()->transformContext() ); + QgsRasterFileWriterTask *writerTask = new QgsRasterFileWriterTask( fileWriter, pipe.release(), d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), QgsProject::instance()->transformContext() ); // when writer is successful: - connect( writerTask, &QgsRasterFileWriterTask::writeComplete, this, - [this, tileMode, addToCanvas, rlWeakPointer, outputLayerName, outputFormat]( const QString & newFilename ) - { + connect( writerTask, &QgsRasterFileWriterTask::writeComplete, this, [this, tileMode, addToCanvas, rlWeakPointer, outputLayerName, outputFormat]( const QString &newFilename ) { QString fileName = newFilename; if ( tileMode ) { @@ -8261,15 +8046,12 @@ QString QgisApp::saveAsRasterFile( QgsRasterLayer *rasterLayer, const bool defau if ( rlWeakPointer ) emit layerSavedAs( rlWeakPointer, fileName ); - visibleMessageBar()->pushMessage( tr( "Layer Exported" ), - tr( "Successfully saved raster layer to %2" ).arg( QUrl::fromLocalFile( newFilename ).toString(), QDir::toNativeSeparators( newFilename ) ), - Qgis::MessageLevel::Success, 0 ); + visibleMessageBar()->pushMessage( tr( "Layer Exported" ), tr( "Successfully saved raster layer to %2" ).arg( QUrl::fromLocalFile( newFilename ).toString(), QDir::toNativeSeparators( newFilename ) ), Qgis::MessageLevel::Success, 0 ); } ); // when an error occurs: - connect( writerTask, qOverload< int, const QString &>( &QgsRasterFileWriterTask::errorOccurred ), this, [ = ]( int errorInt, const QString & errorMessage ) - { - const Qgis::RasterFileWriterResult error = static_cast < Qgis::RasterFileWriterResult >( errorInt ); + connect( writerTask, qOverload( &QgsRasterFileWriterTask::errorOccurred ), this, [=]( int errorInt, const QString &errorMessage ) { + const Qgis::RasterFileWriterResult error = static_cast( errorInt ); if ( error != Qgis::RasterFileWriterResult::Canceled ) { QString errorCodeStr; @@ -8284,9 +8066,7 @@ QString QgisApp::saveAsRasterFile( QgsRasterLayer *rasterLayer, const bool defau QString fullErrorMsg( tr( "Cannot write raster. Error code: %1" ).arg( errorCodeStr ) ); if ( !errorMessage.isEmpty() ) fullErrorMsg += "\n" + errorMessage; - QMessageBox::warning( this, tr( "Save Raster" ), - fullErrorMsg, - QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Save Raster" ), fullErrorMsg, QMessageBox::Ok ); } } ); @@ -8333,19 +8113,14 @@ void QgisApp::makeMemoryLayerPermanent( QgsVectorLayer *layer ) const QString layerId = layer->id(); - auto onSuccess = [this, layerId]( const QString & newFilename, - bool, - const QString & newLayerName, - const QString &, - const QString & ) - { + auto onSuccess = [this, layerId]( const QString &newFilename, bool, const QString &newLayerName, const QString &, const QString & ) { // we have to re-retrieve the layer, in case it's been removed during the lifetime of the writer task - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( QgsProject::instance()->mapLayer( layerId ) ); + QgsVectorLayer *vl = qobject_cast( QgsProject::instance()->mapLayer( layerId ) ); if ( vl ) { QgsDataProvider::ProviderOptions options; QString source = newFilename; - if ( ! newLayerName.isEmpty() ) + if ( !newLayerName.isEmpty() ) source += QStringLiteral( "|layername=%1" ).arg( newLayerName ); vl->setDataSource( source, vl->name(), QStringLiteral( "ogr" ), options ); vl->triggerRepaint(); @@ -8354,14 +8129,11 @@ void QgisApp::makeMemoryLayerPermanent( QgsVectorLayer *layer ) vl->removeCustomProperty( QStringLiteral( "OnConvertFormatRegeneratePrimaryKey" ) ); mLayerTreeView->refreshLayerSymbology( vl->id() ); - this->visibleMessageBar()->pushMessage( tr( "Layer Saved" ), - tr( "Successfully saved scratch layer to %2" ).arg( QUrl::fromLocalFile( newFilename ).toString(), QDir::toNativeSeparators( newFilename ) ), - Qgis::MessageLevel::Success, 0 ); + this->visibleMessageBar()->pushMessage( tr( "Layer Saved" ), tr( "Successfully saved scratch layer to %2" ).arg( QUrl::fromLocalFile( newFilename ).toString(), QDir::toNativeSeparators( newFilename ) ), Qgis::MessageLevel::Success, 0 ); } }; - auto onFailure = []( int error, const QString & errorMessage ) - { + auto onFailure = []( int error, const QString &errorMessage ) { if ( error != QgsVectorFileWriter::Canceled ) { QgsMessageViewer *m = new QgsMessageViewer( nullptr ); @@ -8407,11 +8179,8 @@ void QgisApp::saveStyleFile( QgsMapLayer *layer ) switch ( layer->type() ) { - case Qgis::LayerType::Vector: - QgsVectorLayerProperties( mMapCanvas, - visibleMessageBar(), - qobject_cast( layer ) ).saveStyleAs(); + QgsVectorLayerProperties( mMapCanvas, visibleMessageBar(), qobject_cast( layer ) ).saveStyleAs(); break; case Qgis::LayerType::Raster: @@ -8423,21 +8192,15 @@ void QgisApp::saveStyleFile( QgsMapLayer *layer ) break; case Qgis::LayerType::VectorTile: - QgsVectorTileLayerProperties( qobject_cast( layer ), - mMapCanvas, - visibleMessageBar() ).saveStyleToFile(); + QgsVectorTileLayerProperties( qobject_cast( layer ), mMapCanvas, visibleMessageBar() ).saveStyleToFile(); break; case Qgis::LayerType::PointCloud: - QgsPointCloudLayerProperties( qobject_cast( layer ), - mMapCanvas, - visibleMessageBar() ).saveStyleToFile(); + QgsPointCloudLayerProperties( qobject_cast( layer ), mMapCanvas, visibleMessageBar() ).saveStyleToFile(); break; case Qgis::LayerType::TiledScene: - QgsTiledSceneLayerProperties( qobject_cast( layer ), - mMapCanvas, - visibleMessageBar() ).saveStyleToFile(); + QgsTiledSceneLayerProperties( qobject_cast( layer ), mMapCanvas, visibleMessageBar() ).saveStyleToFile(); break; // Not available for these @@ -8466,7 +8229,7 @@ class QgisAppFieldValueConverter : public QgsVectorFileWriter::FieldValueConvert QgisAppFieldValueConverter *clone() const override; private: - QPointer< QgsVectorLayer > mLayer; + QPointer mLayer; QgsAttributeList mAttributesAsDisplayedValues; QStringList mAttributesExportNames; }; @@ -8528,32 +8291,24 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology const QString layerId = vlayer->id(); - auto onSuccess = [this, layerId]( const QString & newFilename, - bool addToCanvas, - const QString & layerName, - const QString & encoding, - const QString & vectorFileName ) - { + auto onSuccess = [this, layerId]( const QString &newFilename, bool addToCanvas, const QString &layerName, const QString &encoding, const QString &vectorFileName ) { if ( addToCanvas ) { QString uri( newFilename ); if ( !layerName.isEmpty() ) uri += "|layername=" + layerName; bool ok = false; - QgsAppLayerHandling::addOgrVectorLayers( {uri}, encoding, QStringLiteral( "file" ), ok ); + QgsAppLayerHandling::addOgrVectorLayers( { uri }, encoding, QStringLiteral( "file" ), ok ); } // We need to re-retrieve the map layer here, in case it's been deleted during the lifetime of the task - if ( QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( QgsProject::instance()->mapLayer( layerId ) ) ) + if ( QgsVectorLayer *vlayer = qobject_cast( QgsProject::instance()->mapLayer( layerId ) ) ) this->emit layerSavedAs( vlayer, vectorFileName ); - this->visibleMessageBar()->pushMessage( tr( "Layer Exported" ), - tr( "Successfully saved vector layer to %2" ).arg( QUrl::fromLocalFile( newFilename ).toString(), QDir::toNativeSeparators( newFilename ) ), - Qgis::MessageLevel::Success, 0 ); + this->visibleMessageBar()->pushMessage( tr( "Layer Exported" ), tr( "Successfully saved vector layer to %2" ).arg( QUrl::fromLocalFile( newFilename ).toString(), QDir::toNativeSeparators( newFilename ) ), Qgis::MessageLevel::Success, 0 ); }; - auto onFailure = []( int error, const QString & errorMessage ) - { + auto onFailure = []( int error, const QString &errorMessage ) { if ( error != QgsVectorFileWriter::Canceled ) { QgsMessageViewer *m = new QgsMessageViewer( nullptr ); @@ -8566,13 +8321,13 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology return saveAsVectorFileGeneral( vlayer, symbologyOption, onlySelected, defaultToAddToMap, onSuccess, onFailure ); } -QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOption, bool onlySelected, bool defaultToAddToMap, const std::function &onSuccess, const std::function &onFailure, QgsVectorLayerSaveAsDialog::Options options, const QString &dialogTitle ) +QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOption, bool onlySelected, bool defaultToAddToMap, const std::function &onSuccess, const std::function &onFailure, QgsVectorLayerSaveAsDialog::Options options, const QString &dialogTitle ) { QgsCoordinateReferenceSystem destCRS; if ( !symbologyOption ) { - options &= ~static_cast< int >( QgsVectorLayerSaveAsDialog::Option::Symbology ); + options &= ~static_cast( QgsVectorLayerSaveAsDialog::Option::Symbology ); } QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( vlayer, options, this ); @@ -8643,9 +8398,8 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology QgsVectorFileWriterTask *writerTask = new QgsVectorFileWriterTask( vlayer, vectorFilename, options, sinkFlags ); // when writer is successful: - connect( writerTask, &QgsVectorFileWriterTask::completed, this, [onSuccess, addToCanvas, encoding, vectorFilename, format]( const QString & newFilename, const QString & newLayer ) - { - QString layerName = newLayer; + connect( writerTask, &QgsVectorFileWriterTask::completed, this, [onSuccess, addToCanvas, encoding, vectorFilename, format]( const QString &newFilename, const QString &newLayer ) { + QString layerName = newLayer; #ifdef GDAL_DCAP_MULTIPLE_VECTOR_LAYERS GDALDriverH hDriver = GDALGetDriverByName( format.toUtf8().constData() ); if ( hDriver ) @@ -8663,8 +8417,7 @@ QString QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbology } ); // when an error occurs: - connect( writerTask, &QgsVectorFileWriterTask::errorOccurred, this, [onFailure]( int error, const QString & errorMessage ) - { + connect( writerTask, &QgsVectorFileWriterTask::errorOccurred, this, [onFailure]( int error, const QString &errorMessage ) { onFailure( error, errorMessage ); } ); @@ -8688,7 +8441,7 @@ QString QgisApp::saveAsPointCloudLayer( QgsPointCloudLayer *pclayer ) { QgsPointCloudLayerExporter *exp = new QgsPointCloudLayerExporter( pclayer ); - QgsCoordinateReferenceSystem destCRS = dialog.crsObject(); + QgsCoordinateReferenceSystem destCRS = dialog.crsObject(); if ( destCRS.isValid() ) { QgsDatumTransformDialog::run( pclayer->crs(), destCRS, this, mMapCanvas ); @@ -8728,7 +8481,7 @@ QString QgisApp::saveAsPointCloudLayer( QgsPointCloudLayer *pclayer ) if ( dialog.hasPointsLimit() ) exp->setPointsLimit( dialog.pointsLimit() ); - if ( ! dialog.layername().isEmpty() ) + if ( !dialog.layername().isEmpty() ) exp->setLayerName( dialog.layername() ); @@ -8745,22 +8498,17 @@ QString QgisApp::saveAsPointCloudLayer( QgsPointCloudLayer *pclayer ) QgsApplication::taskManager()->addTask( task ); // when writer is successful: - connect( task, &QgsPointCloudLayerExporterTask::exportComplete, this, [ this, addToCanvas, exp ]() - { + connect( task, &QgsPointCloudLayerExporterTask::exportComplete, this, [this, addToCanvas, exp]() { if ( exp->feedback() && exp->feedback()->isCanceled() ) return; std::unique_ptr ml( exp->takeExportedLayer() ); - if ( ! ml->isValid() ) + if ( !ml->isValid() ) { - if ( ! exp->lastError().isEmpty() ) - visibleMessageBar()->pushMessage( tr( "Export failed" ), - tr( "A problem occurred while exporting: %1" ).arg( exp->lastError() ), - Qgis::MessageLevel::Warning ); + if ( !exp->lastError().isEmpty() ) + visibleMessageBar()->pushMessage( tr( "Export failed" ), tr( "A problem occurred while exporting: %1" ).arg( exp->lastError() ), Qgis::MessageLevel::Warning ); else - visibleMessageBar()->pushMessage( tr( "Cannot open file" ), - tr( "Cannot open exported file: %1" ).arg( ml->error().summary() ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Cannot open file" ), tr( "Cannot open exported file: %1" ).arg( ml->error().summary() ), Qgis::MessageLevel::Warning ); } if ( addToCanvas && ml->isValid() ) @@ -8784,34 +8532,26 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *, bool checkFeaturesV if ( !layer ) { - visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), - tr( "To delete features, you must select a vector layer in the legend" ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), tr( "To delete features, you must select a vector layer in the legend" ), Qgis::MessageLevel::Info ); return; } QgsVectorLayer *vlayer = qobject_cast( layer ); if ( !vlayer ) { - visibleMessageBar()->pushMessage( tr( "No Vector Layer Selected" ), - tr( "Deleting features only works on vector layers" ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Vector Layer Selected" ), tr( "Deleting features only works on vector layers" ), Qgis::MessageLevel::Info ); return; } if ( !( vlayer->dataProvider()->capabilities() & Qgis::VectorProviderCapability::DeleteFeatures ) ) { - visibleMessageBar()->pushMessage( tr( "Provider does not support deletion" ), - tr( "Data provider does not support deleting features" ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Provider does not support deletion" ), tr( "Data provider does not support deleting features" ), Qgis::MessageLevel::Info ); return; } if ( !vlayer->isEditable() ) { - visibleMessageBar()->pushMessage( tr( "Layer not editable" ), - tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Layer not editable" ), tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ), Qgis::MessageLevel::Info ); return; } @@ -8819,9 +8559,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *, bool checkFeaturesV const int numberOfSelectedFeatures = vlayer->selectedFeatureCount(); if ( numberOfSelectedFeatures == 0 ) { - visibleMessageBar()->pushMessage( tr( "No Features Selected" ), - tr( "The current layer has no selected features" ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Features Selected" ), tr( "The current layer has no selected features" ), Qgis::MessageLevel::Info ); return; } @@ -8846,11 +8584,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *, bool checkFeaturesV if ( !allFeaturesInView ) { // for extra safety to make sure we are not removing geometries by accident - QMessageBox warning( QMessageBox::Warning, - tr( "Delete %n feature(s) from layer \"%1\"", nullptr, numberOfSelectedFeatures ).arg( vlayer->name() ), - tr( "Some of the %n selected feature(s) about to be deleted are outside of the current map view. Would you still like to continue?", nullptr, numberOfSelectedFeatures ), - QMessageBox::Yes | QMessageBox::Cancel, - mMapCanvas ); + QMessageBox warning( QMessageBox::Warning, tr( "Delete %n feature(s) from layer \"%1\"", nullptr, numberOfSelectedFeatures ).arg( vlayer->name() ), tr( "Some of the %n selected feature(s) about to be deleted are outside of the current map view. Would you still like to continue?", nullptr, numberOfSelectedFeatures ), QMessageBox::Yes | QMessageBox::Cancel, mMapCanvas ); warning.button( QMessageBox::Yes )->setText( tr( "Delete %n Feature(s)", nullptr, numberOfSelectedFeatures ) ); int res = warning.exec(); if ( res != QMessageBox::Yes ) @@ -8872,11 +8606,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *, bool checkFeaturesV } // for extra safety to make sure we know that the delete can have impact on children and joins - QMessageBox question( QMessageBox::Question, - tr( "Delete at least %n feature(s) on other layer(s)", nullptr, childrenCount ), - tr( "Delete %n feature(s) on layer \"%1\", %2 as well and all of its other descendants.\nDelete these features?", nullptr, numberOfSelectedFeatures ).arg( vlayer->name(), childrenInfo ), - QMessageBox::Yes | QMessageBox::Cancel, - mMapCanvas ); + QMessageBox question( QMessageBox::Question, tr( "Delete at least %n feature(s) on other layer(s)", nullptr, childrenCount ), tr( "Delete %n feature(s) on layer \"%1\", %2 as well and all of its other descendants.\nDelete these features?", nullptr, numberOfSelectedFeatures ).arg( vlayer->name(), childrenInfo ), QMessageBox::Yes | QMessageBox::Cancel, mMapCanvas ); question.button( QMessageBox::Yes )->setText( tr( "Delete %n Feature(s)", nullptr, numberOfSelectedFeatures ) ); int res = question.exec(); if ( res != QMessageBox::Yes ) @@ -8890,11 +8620,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *, bool checkFeaturesV const bool showConfirmation = settings.value( QStringLiteral( "askToDeleteFeatures" ), true, QgsSettings::App ).toBool(); if ( showConfirmation ) { - QMessageBox confirmMessage( QMessageBox::Question, - tr( "Delete %n feature(s) from layer \"%1\"", nullptr, numberOfSelectedFeatures ).arg( vlayer->name() ), - tr( "%n selected feature(s) are about to be deleted. Would you like to continue?", nullptr, numberOfSelectedFeatures ), - QMessageBox::Yes | QMessageBox::Cancel, - mMapCanvas ); + QMessageBox confirmMessage( QMessageBox::Question, tr( "Delete %n feature(s) from layer \"%1\"", nullptr, numberOfSelectedFeatures ).arg( vlayer->name() ), tr( "%n selected feature(s) are about to be deleted. Would you like to continue?", nullptr, numberOfSelectedFeatures ), QMessageBox::Yes | QMessageBox::Cancel, mMapCanvas ); confirmMessage.button( QMessageBox::Yes )->setText( tr( "Delete %n Feature(s)", nullptr, numberOfSelectedFeatures ) ); confirmMessage.setCheckBox( new QCheckBox( tr( "Don't show this message again" ) ) ); confirmMessage.checkBox()->setChecked( false ); @@ -8914,9 +8640,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget *, bool checkFeaturesV QgsVectorLayer::DeleteContext context( true, QgsProject::instance() ); if ( !vlayer->deleteSelectedFeatures( &deletedCount, &context ) ) { - visibleMessageBar()->pushMessage( tr( "Problem deleting features" ), - tr( "A problem occurred during deletion from layer \"%1\". %n feature(s) not deleted.", nullptr, numberOfSelectedFeatures - deletedCount ).arg( vlayer->name() ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Problem deleting features" ), tr( "A problem occurred during deletion from layer \"%1\". %n feature(s) not deleted.", nullptr, numberOfSelectedFeatures - deletedCount ).arg( vlayer->name() ), Qgis::MessageLevel::Warning ); } else { @@ -9056,19 +8780,17 @@ bool QgisApp::uniqueLayoutTitle( QWidget *parent, QString &title, bool acceptEmp QString titleMsg = chooseMsg; QStringList layoutNames; - const QList< QgsMasterLayoutInterface * > layouts = QgsProject::instance()->layoutManager()->layouts(); + const QList layouts = QgsProject::instance()->layoutManager()->layouts(); layoutNames.reserve( layouts.size() + 1 ); for ( QgsMasterLayoutInterface *l : layouts ) { layoutNames << l->name(); } - const QString windowTitle = tr( "Create %1" ).arg( QgsGui::higFlags() & QgsGui::HigDialogTitleIsTitleCase ? QgsStringUtils::capitalize( typeString, Qgis::Capitalization::TitleCase ) - : typeString ); + const QString windowTitle = tr( "Create %1" ).arg( QgsGui::higFlags() & QgsGui::HigDialogTitleIsTitleCase ? QgsStringUtils::capitalize( typeString, Qgis::Capitalization::TitleCase ) : typeString ); while ( !titleValid ) { - QgsNewNameDialog dlg( typeString, newTitle, QStringList(), layoutNames, Qt::CaseSensitive, parent ); dlg.setWindowTitle( windowTitle ); dlg.setHintString( titleMsg ); @@ -9077,8 +8799,7 @@ bool QgisApp::uniqueLayoutTitle( QWidget *parent, QString &title, bool acceptEmp dlg.setConflictingNameWarning( tr( "Title already exists!" ) ); dlg.buttonBox()->addButton( QDialogButtonBox::Help ); - connect( dlg.buttonBox(), &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( dlg.buttonBox(), &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( helpPage ); } ); @@ -9140,7 +8861,7 @@ QgsLayoutDesignerDialog *QgisApp::createNewReport( QString title ) title = QgsProject::instance()->layoutManager()->generateUniqueTitle( QgsMasterLayoutInterface::Report ); } //create new report - std::unique_ptr< QgsReport > report = std::make_unique< QgsReport >( QgsProject::instance() ); + std::unique_ptr report = std::make_unique( QgsProject::instance() ); report->setName( title ); QgsMasterLayoutInterface *layout = report.get(); QgsProject::instance()->layoutManager()->addLayout( report.release() ); @@ -9166,8 +8887,7 @@ QgsLayoutDesignerDialog *QgisApp::openLayoutDesignerDialog( QgsMasterLayoutInter //important - no parent set, otherwise Windows 10 sets the dialog as always on top of the QGIS window!! QgsLayoutDesignerDialog *newDesigner = new QgsLayoutDesignerDialog( nullptr ); newDesigner->setMasterLayout( layout ); - connect( newDesigner, &QgsLayoutDesignerDialog::aboutToClose, this, [this, newDesigner] - { + connect( newDesigner, &QgsLayoutDesignerDialog::aboutToClose, this, [this, newDesigner] { emit layoutDesignerWillBeClosed( newDesigner->iface() ); mLayoutDesignerDialogs.remove( newDesigner ); emit layoutDesignerClosed(); @@ -9210,18 +8930,16 @@ void QgisApp::deleteLayoutDesigners() void QgisApp::setupLayoutManagerConnections() { QgsLayoutManager *manager = QgsProject::instance()->layoutManager(); - connect( manager, &QgsLayoutManager::layoutAdded, this, [ = ]( const QString & name ) - { + connect( manager, &QgsLayoutManager::layoutAdded, this, [=]( const QString &name ) { QgsMasterLayoutInterface *l = QgsProject::instance()->layoutManager()->layoutByName( name ); if ( !l ) return; - QgsPrintLayout *pl = dynamic_cast< QgsPrintLayout *>( l ); + QgsPrintLayout *pl = dynamic_cast( l ); if ( !pl ) return; mAtlasFeatureActions.insert( pl, nullptr ); - connect( pl, &QgsPrintLayout::nameChanged, this, [this, pl]( const QString & name ) - { + connect( pl, &QgsPrintLayout::nameChanged, this, [this, pl]( const QString &name ) { QgsMapLayerAction *action = mAtlasFeatureActions.value( pl ); if ( action ) { @@ -9229,25 +8947,22 @@ void QgisApp::setupLayoutManagerConnections() } } ); - connect( pl->atlas(), &QgsLayoutAtlas::coverageLayerChanged, this, [this, pl]( QgsVectorLayer * coverageLayer ) - { - setupAtlasMapLayerAction( pl, static_cast< bool >( coverageLayer ) ); + connect( pl->atlas(), &QgsLayoutAtlas::coverageLayerChanged, this, [this, pl]( QgsVectorLayer *coverageLayer ) { + setupAtlasMapLayerAction( pl, static_cast( coverageLayer ) ); } ); - connect( pl->atlas(), &QgsLayoutAtlas::toggled, this, [this, pl]( bool enabled ) - { + connect( pl->atlas(), &QgsLayoutAtlas::toggled, this, [this, pl]( bool enabled ) { setupAtlasMapLayerAction( pl, enabled ); } ); setupAtlasMapLayerAction( pl, pl->atlas()->enabled() && pl->atlas()->coverageLayer() ); } ); - connect( manager, &QgsLayoutManager::layoutAboutToBeRemoved, this, [ = ]( const QString & name ) - { + connect( manager, &QgsLayoutManager::layoutAboutToBeRemoved, this, [=]( const QString &name ) { QgsMasterLayoutInterface *l = QgsProject::instance()->layoutManager()->layoutByName( name ); if ( l ) { - QgsPrintLayout *pl = dynamic_cast< QgsPrintLayout * >( l ); + QgsPrintLayout *pl = dynamic_cast( l ); if ( pl ) { QgsMapLayerAction *action = mAtlasFeatureActions.value( pl ); @@ -9308,9 +9023,9 @@ void QgisApp::close3DMapView( const QString &viewName ) mOpen3DMapViews.remove( widget ); QDomImplementation DomImplementation; - QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); if ( !QgsProject::instance()->viewsManager()->get3DViewSettings( viewName ).isNull() ) @@ -9341,9 +9056,9 @@ Qgs3DMapCanvasWidget *QgisApp::duplicate3DMapView( const QString &existingViewNa return nullptr; QDomImplementation DomImplementation; - QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); // If the 3D view is open, copy its configuration to the duplicate widget, otherwise just use the recorded @@ -9356,8 +9071,7 @@ Qgs3DMapCanvasWidget *QgisApp::duplicate3DMapView( const QString &existingViewNa newCanvasWidget->mapCanvas3D()->cameraController()->readXml( widget->mapCanvas3D()->cameraController()->writeXml( doc ) ); newCanvasWidget->animationWidget()->setAnimation( widget->animationWidget()->animation() ); - connect( QgsProject::instance(), &QgsProject::transformContextChanged, map, [map] - { + connect( QgsProject::instance(), &QgsProject::transformContextChanged, map, [map] { map->setTransformContext( QgsProject::instance()->transformContext() ); } ); } @@ -9408,27 +9122,19 @@ QList QgisApp::get3DMapViews() void QgisApp::setupDuplicateFeaturesAction() { - mDuplicateFeatureAction.reset( new QgsMapLayerAction( tr( "Duplicate Feature" ), - nullptr, Qgis::MapLayerActionTarget::SingleFeature, - QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeature.svg" ) ), Qgis::MapLayerActionFlag::EnabledOnlyWhenEditable ) ); + mDuplicateFeatureAction.reset( new QgsMapLayerAction( tr( "Duplicate Feature" ), nullptr, Qgis::MapLayerActionTarget::SingleFeature, QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeature.svg" ) ), Qgis::MapLayerActionFlag::EnabledOnlyWhenEditable ) ); QgsGui::mapLayerActionRegistry()->addMapLayerAction( mDuplicateFeatureAction.get() ); - connect( mDuplicateFeatureAction.get(), &QgsMapLayerAction::triggeredForFeatureV2, this, [this]( QgsMapLayer * layer, const QgsFeature & feat, const QgsMapLayerActionContext & ) - { + connect( mDuplicateFeatureAction.get(), &QgsMapLayerAction::triggeredForFeatureV2, this, [this]( QgsMapLayer *layer, const QgsFeature &feat, const QgsMapLayerActionContext & ) { duplicateFeatures( layer, feat ); - } - ); + } ); - mDuplicateFeatureDigitizeAction.reset( new QgsMapLayerAction( tr( "Duplicate Feature and Digitize" ), - nullptr, Qgis::MapLayerActionTarget::SingleFeature, - QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeatureDigitized.svg" ) ), Qgis::MapLayerActionFlag::EnabledOnlyWhenEditable ) ); + mDuplicateFeatureDigitizeAction.reset( new QgsMapLayerAction( tr( "Duplicate Feature and Digitize" ), nullptr, Qgis::MapLayerActionTarget::SingleFeature, QgsApplication::getThemeIcon( QStringLiteral( "/mActionDuplicateFeatureDigitized.svg" ) ), Qgis::MapLayerActionFlag::EnabledOnlyWhenEditable ) ); QgsGui::mapLayerActionRegistry()->addMapLayerAction( mDuplicateFeatureDigitizeAction.get() ); - connect( mDuplicateFeatureDigitizeAction.get(), &QgsMapLayerAction::triggeredForFeatureV2, this, [this]( QgsMapLayer * layer, const QgsFeature & feat, const QgsMapLayerActionContext & ) - { + connect( mDuplicateFeatureDigitizeAction.get(), &QgsMapLayerAction::triggeredForFeatureV2, this, [this]( QgsMapLayer *layer, const QgsFeature &feat, const QgsMapLayerActionContext & ) { duplicateFeatureDigitized( layer, feat ); - } - ); + } ); } void QgisApp::setupAtlasMapLayerAction( QgsPrintLayout *layout, bool enableAction ) @@ -9444,17 +9150,13 @@ void QgisApp::setupAtlasMapLayerAction( QgsPrintLayout *layout, bool enableActio if ( enableAction ) { - action = new QgsMapLayerAction( tr( "Set as Atlas Feature for %1" ).arg( layout->name() ), - this, layout->atlas()->coverageLayer(), Qgis::MapLayerActionTarget::SingleFeature, - QgsApplication::getThemeIcon( QStringLiteral( "/mIconAtlas.svg" ) ) ); + action = new QgsMapLayerAction( tr( "Set as Atlas Feature for %1" ).arg( layout->name() ), this, layout->atlas()->coverageLayer(), Qgis::MapLayerActionTarget::SingleFeature, QgsApplication::getThemeIcon( QStringLiteral( "/mIconAtlas.svg" ) ) ); mAtlasFeatureActions.insert( layout, action ); QgsGui::mapLayerActionRegistry()->addMapLayerAction( action ); - connect( action, &QgsMapLayerAction::triggeredForFeatureV2, this, [this, layout]( QgsMapLayer * layer, const QgsFeature & feat, const QgsMapLayerActionContext & ) - { + connect( action, &QgsMapLayerAction::triggeredForFeatureV2, this, [this, layout]( QgsMapLayer *layer, const QgsFeature &feat, const QgsMapLayerActionContext & ) { Q_UNUSED( layer ) setLayoutAtlasFeature( layout, feat ); - } - ); + } ); } } @@ -9473,13 +9175,12 @@ void QgisApp::populateLayoutsMenu( QMenu *menu ) { menu->clear(); QList acts; - const QList< QgsMasterLayoutInterface * > layouts = QgsProject::instance()->layoutManager()->layouts(); + const QList layouts = QgsProject::instance()->layoutManager()->layouts(); acts.reserve( layouts.size() ); for ( QgsMasterLayoutInterface *layout : layouts ) { QAction *a = new QAction( layout->name(), menu ); - connect( a, &QAction::triggered, this, [this, layout] - { + connect( a, &QAction::triggered, this, [this, layout] { openLayoutDesignerDialog( layout ); } ); acts << a; @@ -9497,7 +9198,7 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu ) #ifdef HAVE_3D menu->clear(); QList acts; - QList< QDomElement > views = QgsProject::instance()->viewsManager()->get3DViews(); + QList views = QgsProject::instance()->viewsManager()->get3DViews(); acts.reserve( views.size() ); for ( const QDomElement &viewConfig : views ) { @@ -9506,8 +9207,7 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu ) QAction *a = new QAction( viewName, menu ); a->setCheckable( true ); a->setChecked( isOpen ); - connect( a, &QAction::triggered, this, [a]( bool isChecked ) - { + connect( a, &QAction::triggered, this, [a]( bool isChecked ) { QString viewName = a->text(); if ( isChecked ) { @@ -9542,7 +9242,7 @@ void QgisApp::views3DMenuAboutToShow() void QgisApp::showPinnedLabels( bool show ) { - mMapTools->mapTool< QgsMapToolPinLabels >( QgsAppMapTools::PinLabels )->showPinnedLabels( show ); + mMapTools->mapTool( QgsAppMapTools::PinLabels )->showPinnedLabels( show ); } void QgisApp::pinLabels() @@ -9610,7 +9310,7 @@ QList QgisApp::mapCanvases() { // filter out browser canvases -- they are children of app, but a different // kind of beast, and here we only want the main canvas or dock canvases - QList canvases = findChildren< QgsMapCanvas * >(); + QList canvases = findChildren(); for ( QgsMapCanvasDockWidget *dock : std::as_const( mOpen2DMapViews ) ) { @@ -9620,11 +9320,10 @@ QList QgisApp::mapCanvases() } } - canvases.erase( std::remove_if( canvases.begin(), canvases.end(), - []( QgsMapCanvas * canvas ) - { - return !canvas || canvas->property( "browser_canvas" ).toBool(); - } ), canvases.end() ); + canvases.erase( std::remove_if( canvases.begin(), canvases.end(), []( QgsMapCanvas *canvas ) { + return !canvas || canvas->property( "browser_canvas" ).toBool(); + } ), + canvases.end() ); return canvases; } @@ -9636,7 +9335,7 @@ QgsMapCanvasDockWidget *QgisApp::getMapCanvas( const QString &name ) return w; } - const auto dockWidgets = findChildren< QgsMapCanvasDockWidget * >(); + const auto dockWidgets = findChildren(); for ( QgsMapCanvasDockWidget *w : dockWidgets ) { if ( w->canvasName() == name ) @@ -9645,9 +9344,9 @@ QgsMapCanvasDockWidget *QgisApp::getMapCanvas( const QString &name ) return nullptr; } -QMap< QString, Qgs3DMapScene * > QgisApp::map3DScenes() +QMap QgisApp::map3DScenes() { - QMap< QString, Qgs3DMapScene * > res; + QMap res; #ifdef HAVE_3D for ( Qgs3DMapCanvasWidget *canvas3D : std::as_const( mOpen3DMapViews ) ) { @@ -9686,9 +9385,7 @@ void QgisApp::mergeAttributesOfSelectedFeatures() QgsMapLayer *activeMapLayer = activeLayer(); if ( !activeMapLayer ) { - visibleMessageBar()->pushMessage( tr( "No active layer" ), - tr( "No active layer found. Please select a layer in the layer list" ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No active layer" ), tr( "No active layer found. Please select a layer in the layer list" ), Qgis::MessageLevel::Info ); return; } @@ -9698,7 +9395,8 @@ void QgisApp::mergeAttributesOfSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Layer not editable" ), tr( "The merge features tool only works on vector layers." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9707,7 +9405,8 @@ void QgisApp::mergeAttributesOfSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Layer not editable" ), tr( "Merging features can only be done for layers in editing mode." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9719,7 +9418,8 @@ void QgisApp::mergeAttributesOfSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Not enough features selected" ), tr( "The merge tool requires at least two selected features." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9751,9 +9451,7 @@ void QgisApp::mergeAttributesOfSelectedFeatures() QVariant val = merged.at( i ); QgsField fld( vl->fields().at( i ) ); - bool isDefaultValue = vl->fields().fieldOrigin( i ) == Qgis::FieldOrigin::Provider && - vl->dataProvider() && - vl->dataProvider()->defaultValueClause( vl->fields().fieldOriginIndex( i ) ) == val; + bool isDefaultValue = vl->fields().fieldOrigin( i ) == Qgis::FieldOrigin::Provider && vl->dataProvider() && vl->dataProvider()->defaultValueClause( vl->fields().fieldOriginIndex( i ) ) == val; // convert to destination data type QString errorMessage; @@ -9765,7 +9463,8 @@ void QgisApp::mergeAttributesOfSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Invalid result" ), tr( "Could not store value '%1' in field of type %2: %3" ).arg( merged.at( i ).toString(), fld.typeName(), errorMessage ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } } else @@ -9789,7 +9488,8 @@ void QgisApp::modifyAttributesOfSelectedFeatures() visibleMessageBar()->pushMessage( tr( "No active layer" ), tr( "Please select a layer in the layer list" ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9799,7 +9499,8 @@ void QgisApp::modifyAttributesOfSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Invalid layer" ), tr( "The merge features tool only works on vector layers." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } if ( !vl->isEditable() ) @@ -9807,7 +9508,8 @@ void QgisApp::modifyAttributesOfSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Layer not editable" ), tr( "Modifying features can only be done for layers in editing mode." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9848,7 +9550,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "No active layer" ), tr( "Please select a layer in the layer list" ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } QgsVectorLayer *vl = qobject_cast( activeMapLayer ); @@ -9857,7 +9560,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Invalid layer" ), tr( "The merge features tool only works on vector layers." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } if ( !vl->isEditable() ) @@ -9865,7 +9569,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Layer not editable" ), tr( "Merging features can only be done for layers in editing mode." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9876,7 +9581,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Not enough features selected" ), tr( "The merge tool requires at least two selected features" ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9892,7 +9598,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Merge failed" ), tr( "An error occurred during the merge operation." ), - Qgis::MessageLevel::Critical ); + Qgis::MessageLevel::Critical + ); } return; } @@ -9904,7 +9611,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Merge failed" ), tr( "Resulting geometry type (multipart) is incompatible with layer type (singlepart)." ), - Qgis::MessageLevel::Critical ); + Qgis::MessageLevel::Critical + ); return; } } @@ -9924,7 +9632,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Not enough features selected" ), tr( "The merge tool requires at least two selected features" ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return; } @@ -9941,7 +9650,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Merge failed" ), tr( "An error occurred during the merge operation." ), - Qgis::MessageLevel::Critical ); + Qgis::MessageLevel::Critical + ); } return; } @@ -9953,7 +9663,8 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Merge failed" ), tr( "Resulting geometry type (multipart) is incompatible with layer type (singlepart)." ), - Qgis::MessageLevel::Critical ); + Qgis::MessageLevel::Critical + ); return; } } @@ -9968,14 +9679,16 @@ void QgisApp::mergeSelectedFeatures() visibleMessageBar()->pushMessage( tr( "Merge failed" ), errorMessage, - Qgis::MessageLevel::Critical ); + Qgis::MessageLevel::Critical + ); } else if ( success && !errorMessage.isEmpty() ) { visibleMessageBar()->pushMessage( tr( "Invalid result" ), errorMessage, - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } } @@ -10072,7 +9785,8 @@ void QgisApp::deselectActiveLayer() visibleMessageBar()->pushMessage( tr( "No active vector layer" ), tr( "To deselect all features, choose a vector layer in the legend" ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } @@ -10103,7 +9817,8 @@ void QgisApp::deselectActiveLayer() visibleMessageBar()->pushMessage( tr( "No active vector layer" ), tr( "To deselect all features, choose a vector layer in the legend" ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); break; } } @@ -10117,7 +9832,8 @@ void QgisApp::invertSelection() visibleMessageBar()->pushMessage( tr( "No active vector layer" ), tr( "To invert selection, choose a vector layer in the legend" ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } @@ -10132,7 +9848,8 @@ void QgisApp::selectAll() visibleMessageBar()->pushMessage( tr( "No active vector layer" ), tr( "To select all, choose a vector layer in the legend." ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } @@ -10147,7 +9864,8 @@ void QgisApp::selectByExpression() visibleMessageBar()->pushMessage( tr( "No active vector layer" ), tr( "To select features, choose a vector layer in the legend." ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } @@ -10166,7 +9884,8 @@ void QgisApp::selectByForm() visibleMessageBar()->pushMessage( tr( "No active vector layer" ), tr( "To select features, choose a vector layer in the legend." ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } QgsDistanceArea myDa; @@ -10184,8 +9903,7 @@ void QgisApp::selectByForm() dlg->setMessageBar( messageBar() ); dlg->setMapCanvas( mapCanvas() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); - connect( dlg, &QgsSelectByFormDialog::showFilteredFeaturesAttributeTable, dlg, [ = ]( const QString & filter ) - { + connect( dlg, &QgsSelectByFormDialog::showFilteredFeaturesAttributeTable, dlg, [=]( const QString &filter ) { if ( !vlayer->dataProvider() ) { return; @@ -10195,7 +9913,6 @@ void QgisApp::selectByForm() dialog->setFilterExpression( filter ); dialog->setView( QgsDualView::ViewMode::AttributeEditor ); dialog->show(); - } ); dlg->show(); } @@ -10225,9 +9942,7 @@ void QgisApp::cutSelectionToClipboard( QgsMapLayer *layerContainingSelection ) if ( !selectionVectorLayer->isEditable() ) { - visibleMessageBar()->pushMessage( tr( "Layer not editable" ), - tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Layer not editable" ), tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ), Qgis::MessageLevel::Info ); return; } @@ -10280,9 +9995,7 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer ) if ( !pasteVectorLayer->isEditable() ) { - visibleMessageBar()->pushMessage( tr( "Layer not editable" ), - tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Layer not editable" ), tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ), Qgis::MessageLevel::Info ); return; } @@ -10303,10 +10016,10 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer ) { QgsGeometry geom = feature.geometry(); - if ( !( geom.isEmpty() || geom.isNull( ) ) ) + if ( !( geom.isEmpty() || geom.isNull() ) ) { // avoid intersection if enabled in digitize settings - QList avoidIntersectionsLayers; + QList avoidIntersectionsLayers; switch ( QgsProject::instance()->avoidIntersectionsMode() ) { case Qgis::AvoidIntersectionsMode::AvoidIntersectionsCurrentLayer: @@ -10325,7 +10038,7 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer ) } // count collapsed geometries - if ( geom.isEmpty() || geom.isNull( ) ) + if ( geom.isEmpty() || geom.isNull() ) invalidGeometriesCount++; } } @@ -10341,10 +10054,10 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer ) { QgsGeometry geom = feature.geometry(); - if ( !( geom.isEmpty() || geom.isNull( ) ) ) + if ( !( geom.isEmpty() || geom.isNull() ) ) { // avoid intersection if enabled in digitize settings - QList avoidIntersectionsLayers; + QList avoidIntersectionsLayers; switch ( QgsProject::instance()->avoidIntersectionsMode() ) { case Qgis::AvoidIntersectionsMode::AvoidIntersectionsCurrentLayer: @@ -10362,7 +10075,7 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer ) } // count collapsed geometries - if ( geom.isEmpty() || geom.isNull( ) ) + if ( geom.isEmpty() || geom.isNull() ) invalidGeometriesCount++; } @@ -10385,8 +10098,7 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer ) { if ( ( field.constraints().constraints() & QgsFieldConstraints::ConstraintUnique && field.constraints().constraintStrength( QgsFieldConstraints::ConstraintUnique ) & QgsFieldConstraints::ConstraintStrengthHard ) || ( field.constraints().constraints() & QgsFieldConstraints::ConstraintNotNull && field.constraints().constraintStrength( QgsFieldConstraints::ConstraintNotNull ) & QgsFieldConstraints::ConstraintStrengthHard ) - || ( field.constraints().constraints() & QgsFieldConstraints::ConstraintExpression && !field.constraints().constraintExpression().isEmpty() && field.constraints().constraintStrength( QgsFieldConstraints::ConstraintExpression ) & QgsFieldConstraints::ConstraintStrengthHard ) - ) + || ( field.constraints().constraints() & QgsFieldConstraints::ConstraintExpression && !field.constraints().constraintExpression().isEmpty() && field.constraints().constraintStrength( QgsFieldConstraints::ConstraintExpression ) & QgsFieldConstraints::ConstraintStrengthHard ) ) { hasStrongConstraints = true; break; @@ -10423,8 +10135,7 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer ) QgsFixAttributeDialog *dialog = new QgsFixAttributeDialog( pasteVectorLayer, invalidFeatures, this, context ); - connect( dialog, &QgsFixAttributeDialog::finished, this, [ = ]( int feedback ) - { + connect( dialog, &QgsFixAttributeDialog::finished, this, [=]( int feedback ) { QgsFeatureList features = pastedFeatures; switch ( feedback ) { @@ -10518,20 +10229,16 @@ void QgisApp::pasteFeatures( QgsVectorLayer *pasteVectorLayer, int invalidGeomet // warn the user if the pasted features have invalid geometries if ( invalidGeometriesCount > 0 ) - message += invalidGeometriesCount == 1 ? tr( " Geometry collapsed due to intersection avoidance." ) : - tr( "%n geometries collapsed due to intersection avoidance.", nullptr, invalidGeometriesCount ); + message += invalidGeometriesCount == 1 ? tr( " Geometry collapsed due to intersection avoidance." ) : tr( "%n geometries collapsed due to intersection avoidance.", nullptr, invalidGeometriesCount ); - visibleMessageBar()->pushMessage( tr( "Paste features" ), - message, - level ); + visibleMessageBar()->pushMessage( tr( "Paste features" ), message, level ); pasteVectorLayer->triggerRepaint(); } void QgisApp::pasteAsNewVector() { - - std::unique_ptr< QgsVectorLayer > layer = pasteToNewMemoryVector(); + std::unique_ptr layer = pasteToNewMemoryVector(); if ( !layer ) return; @@ -10546,9 +10253,7 @@ QgsVectorLayer *QgisApp::pasteAsNewMemoryVector( const QString &layerName ) { bool ok; QString defaultName = tr( "Pasted" ); - layerNameCopy = QInputDialog::getText( this, tr( "Paste as Scratch Layer" ), - tr( "Layer name" ), QLineEdit::Normal, - defaultName, &ok ); + layerNameCopy = QInputDialog::getText( this, tr( "Paste as Scratch Layer" ), tr( "Layer name" ), QLineEdit::Normal, defaultName, &ok ); if ( !ok ) return nullptr; @@ -10558,7 +10263,7 @@ QgsVectorLayer *QgisApp::pasteAsNewMemoryVector( const QString &layerName ) } } - std::unique_ptr< QgsVectorLayer > layer = pasteToNewMemoryVector(); + std::unique_ptr layer = pasteToNewMemoryVector(); if ( !layer ) return nullptr; @@ -10593,11 +10298,11 @@ std::unique_ptr QgisApp::pasteToNewMemoryVector() { if ( typeCounts.contains( QgsWkbTypes::multiType( type ) ) ) { - typeCounts[ QgsWkbTypes::multiType( type )] = typeCounts[ QgsWkbTypes::multiType( type )] + 1; + typeCounts[QgsWkbTypes::multiType( type )] = typeCounts[QgsWkbTypes::multiType( type )] + 1; } else { - typeCounts[ type ] = typeCounts[ type ] + 1; + typeCounts[type] = typeCounts[type] + 1; } } else if ( QgsWkbTypes::isMultiType( type ) ) @@ -10605,7 +10310,7 @@ std::unique_ptr QgisApp::pasteToNewMemoryVector() if ( typeCounts.contains( QgsWkbTypes::singleType( type ) ) ) { // switch to multi type - typeCounts[type] = typeCounts[ QgsWkbTypes::singleType( type )]; + typeCounts[type] = typeCounts[QgsWkbTypes::singleType( type )]; typeCounts.remove( QgsWkbTypes::singleType( type ) ); } typeCounts[type] = typeCounts[type] + 1; @@ -10617,26 +10322,20 @@ std::unique_ptr QgisApp::pasteToNewMemoryVector() if ( features.isEmpty() ) { // should not happen - visibleMessageBar()->pushMessage( tr( "Paste features" ), - tr( "No features in clipboard." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Paste features" ), tr( "No features in clipboard." ), Qgis::MessageLevel::Info ); return nullptr; } else if ( typeCounts.size() > 1 ) { QString typeName = wkbType != Qgis::WkbType::NoGeometry ? QgsWkbTypes::displayString( wkbType ) : QStringLiteral( "none" ); - visibleMessageBar()->pushMessage( tr( "Paste features" ), - tr( "Multiple geometry types found, features with geometry different from %1 will be created without geometry." ).arg( typeName ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Paste features" ), tr( "Multiple geometry types found, features with geometry different from %1 will be created without geometry." ).arg( typeName ), Qgis::MessageLevel::Info ); } - std::unique_ptr< QgsVectorLayer > layer( QgsMemoryProviderUtils::createMemoryLayer( QStringLiteral( "pasted_features" ), QgsFields(), wkbType, clipboard()->crs() ) ); + std::unique_ptr layer( QgsMemoryProviderUtils::createMemoryLayer( QStringLiteral( "pasted_features" ), QgsFields(), wkbType, clipboard()->crs() ) ); if ( !layer->isValid() || !layer->dataProvider() ) { - visibleMessageBar()->pushMessage( tr( "Paste features" ), - tr( "Cannot create new layer." ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Paste features" ), tr( "Cannot create new layer." ), Qgis::MessageLevel::Warning ); return nullptr; } @@ -10646,18 +10345,14 @@ std::unique_ptr QgisApp::pasteToNewMemoryVector() QgsDebugMsgLevel( QStringLiteral( "field %1 (%2)" ).arg( f.name(), QVariant::typeToName( f.type() ) ), 2 ); if ( !layer->addAttribute( f ) ) { - visibleMessageBar()->pushMessage( tr( "Paste features" ), - tr( "Cannot create field %1 (%2,%3), falling back to string type" ).arg( f.name(), f.typeName(), QVariant::typeToName( f.type() ) ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Paste features" ), tr( "Cannot create field %1 (%2,%3), falling back to string type" ).arg( f.name(), f.typeName(), QVariant::typeToName( f.type() ) ), Qgis::MessageLevel::Warning ); // Fallback to string QgsField strField { f }; strField.setType( QMetaType::Type::QString ); if ( !layer->addAttribute( strField ) ) { - visibleMessageBar()->pushMessage( tr( "Paste features" ), - tr( "Cannot create field %1 (%2,%3)" ).arg( strField.name(), strField.typeName(), QVariant::typeToName( strField.type() ) ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Paste features" ), tr( "Cannot create field %1 (%2,%3)" ).arg( strField.name(), strField.typeName(), QVariant::typeToName( strField.type() ) ), Qgis::MessageLevel::Critical ); return nullptr; } } @@ -10678,7 +10373,7 @@ std::unique_ptr QgisApp::pasteToNewMemoryVector() } } - if ( ! layer->addFeatures( convertedFeatures ) || !layer->commitChanges() ) + if ( !layer->addFeatures( convertedFeatures ) || !layer->commitChanges() ) { QgsDebugError( QStringLiteral( "Cannot add features or commit changes" ) ); return nullptr; @@ -10701,9 +10396,7 @@ void QgisApp::copyStyle( QgsMapLayer *sourceLayer, QgsMapLayer::StyleCategories if ( !errorMsg.isEmpty() ) { - visibleMessageBar()->pushMessage( tr( "Cannot copy style" ), - errorMsg, - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Cannot copy style" ), errorMsg, Qgis::MessageLevel::Critical ); return; } // Copies data in text form as well, so the XML can be pasted into a text editor @@ -10726,25 +10419,19 @@ void QgisApp::pasteStyle( QgsMapLayer *destinationLayer, QgsMapLayer::StyleCateg int errorLine, errorColumn; if ( !doc.setContent( clipboard()->data( QStringLiteral( QGSCLIPBOARD_STYLE_MIME ) ), false, &errorMsg, &errorLine, &errorColumn ) ) { - - visibleMessageBar()->pushMessage( tr( "Cannot parse style" ), - errorMsg, - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Cannot parse style" ), errorMsg, Qgis::MessageLevel::Critical ); return; } bool isVectorStyle = doc.elementsByTagName( QStringLiteral( "pipe" ) ).isEmpty(); - if ( ( selectionLayer->type() == Qgis::LayerType::Raster && isVectorStyle ) || - ( selectionLayer->type() == Qgis::LayerType::Vector && !isVectorStyle ) ) + if ( ( selectionLayer->type() == Qgis::LayerType::Raster && isVectorStyle ) || ( selectionLayer->type() == Qgis::LayerType::Vector && !isVectorStyle ) ) { return; } if ( !selectionLayer->importNamedStyle( doc, errorMsg, categories ) ) { - visibleMessageBar()->pushMessage( tr( "Cannot paste style" ), - errorMsg, - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Cannot paste style" ), errorMsg, Qgis::MessageLevel::Critical ); return; } @@ -10797,8 +10484,7 @@ void QgisApp::pasteLayer() QgsSettings settings; Qgis::LayerTreeInsertionMethod insertionMethod = settings.enumValue( QStringLiteral( "/qgis/layerTreeInsertionMethod" ), Qgis::LayerTreeInsertionMethod::OptimalInInsertionGroup ); QgsLayerTreeRegistryBridge::InsertionPoint insertionPoint = layerTreeInsertionPoint(); - bool loaded = QgsLayerDefinition::loadLayerDefinition( doc, QgsProject::instance(), root, - errorMessage, readWriteContext, insertionMethod, &insertionPoint ); + bool loaded = QgsLayerDefinition::loadLayerDefinition( doc, QgsProject::instance(), root, errorMessage, readWriteContext, insertionMethod, &insertionPoint ); if ( !loaded || !errorMessage.isEmpty() ) { @@ -10837,11 +10523,9 @@ void QgisApp::canvasRefreshStarted() mRenderProgressBarTimer.setSingleShot( true ); mRenderProgressBarTimer.setInterval( 500 ); disconnect( mRenderProgressBarTimerConnection ); - mRenderProgressBarTimerConnection = connect( &mRenderProgressBarTimer, &QTimer::timeout, this, [ = ]() - { + mRenderProgressBarTimerConnection = connect( &mRenderProgressBarTimer, &QTimer::timeout, this, [=]() { showProgress( -1, 0 ); - } - ); + } ); mRenderProgressBarTimer.start(); } else @@ -10884,8 +10568,7 @@ void QgisApp::toggleEditing() const bool shouldStartEditing = mActionToggleEditing->isChecked(); for ( const auto layer : layerList ) { - if ( layer->supportsEditing() && - shouldStartEditing != layer->isEditable() ) + if ( layer->supportsEditing() && shouldStartEditing != layer->isEditable() ) { toggleEditing( layer, true ); } @@ -10894,7 +10577,7 @@ void QgisApp::toggleEditing() else { // if there are no selected layers, try to toggle the current layer - QgsMapLayer *currentLayer = activeLayer(); + QgsMapLayer *currentLayer = activeLayer(); if ( currentLayer && currentLayer->supportsEditing() ) { toggleEditing( currentLayer, true ); @@ -10904,9 +10587,7 @@ void QgisApp::toggleEditing() // active although there's no layer active!? mActionToggleEditing->setChecked( false ); mActionToggleEditing->setEnabled( false ); - visibleMessageBar()->pushMessage( tr( "Start editing failed" ), - tr( "Layer cannot be edited" ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Start editing failed" ), tr( "Layer cannot be edited" ), Qgis::MessageLevel::Warning ); } } } @@ -10955,8 +10636,8 @@ bool QgisApp::toggleEditingVectorLayer( QgsVectorLayer *vlayer, bool allowCancel QString connString = QgsTransaction::connectionString( vlayer->source() ); QString key = vlayer->providerType(); - QMap< QPair< QString, QString>, QgsTransactionGroup *> transactionGroups = QgsProject::instance()->transactionGroups(); - QMap< QPair< QString, QString>, QgsTransactionGroup *>::iterator tIt = transactionGroups .find( qMakePair( key, connString ) ); + QMap, QgsTransactionGroup *> transactionGroups = QgsProject::instance()->transactionGroups(); + QMap, QgsTransactionGroup *>::iterator tIt = transactionGroups.find( qMakePair( key, connString ) ); QgsTransactionGroup *tg = ( tIt != transactionGroups.end() ? tIt.value() : nullptr ); if ( tg && tg->layers().contains( vlayer ) && tg->modified() ) @@ -10984,9 +10665,7 @@ bool QgisApp::toggleEditingVectorLayer( QgsVectorLayer *vlayer, bool allowCancel { mActionToggleEditing->setChecked( false ); mActionToggleEditing->setEnabled( false ); - visibleMessageBar()->pushMessage( tr( "Start editing failed" ), - tr( "Provider cannot be opened for editing" ), - Qgis::MessageLevel::Warning ); + visibleMessageBar()->pushMessage( tr( "Start editing failed" ), tr( "Provider cannot be opened for editing" ), Qgis::MessageLevel::Warning ); return false; } @@ -10996,8 +10675,7 @@ bool QgisApp::toggleEditingVectorLayer( QgsVectorLayer *vlayer, bool allowCancel bool markSelectedOnly = QgsSettingsRegistryCore::settingsDigitizingMarkerOnlyForSelected->value(); // redraw only if markers will be drawn - if ( ( !markSelectedOnly || vlayer->selectedFeatureCount() > 0 ) && - ( markerType == QLatin1String( "Cross" ) || markerType == QLatin1String( "SemiTransparentCircle" ) ) ) + if ( ( !markSelectedOnly || vlayer->selectedFeatureCount() > 0 ) && ( markerType == QLatin1String( "Cross" ) || markerType == QLatin1String( "SemiTransparentCircle" ) ) ) { vlayer->triggerRepaint(); } @@ -11012,16 +10690,11 @@ bool QgisApp::toggleEditingVectorLayer( QgsVectorLayer *vlayer, bool allowCancel if ( modifiedLayers.size() == 1 ) modifiedLayerNames = ( *modifiedLayers.constBegin() )->name(); else if ( modifiedLayers.size() == 2 ) - modifiedLayerNames = tr( "%1 and %2" ).arg( ( *modifiedLayers.constBegin() )->name(), ( * ++modifiedLayers.constBegin() )->name() ); + modifiedLayerNames = tr( "%1 and %2" ).arg( ( *modifiedLayers.constBegin() )->name(), ( *++modifiedLayers.constBegin() )->name() ); else if ( modifiedLayers.size() > 2 ) - modifiedLayerNames = tr( "%1, %2, …" ).arg( ( *modifiedLayers.constBegin() )->name(), ( * ++modifiedLayers.constBegin() )->name() ); + modifiedLayerNames = tr( "%1, %2, …" ).arg( ( *modifiedLayers.constBegin() )->name(), ( *++modifiedLayers.constBegin() )->name() ); - switch ( QMessageBox::question( nullptr, - tr( "Stop Editing" ), - modifiedLayers.size() > 0 ? - tr( "Do you want to save the changes to layers %1?" ).arg( modifiedLayerNames ) : - tr( "Do you want to save the changes to layer %1?" ).arg( modifiedLayerNames ), - buttons ) ) + switch ( QMessageBox::question( nullptr, tr( "Stop Editing" ), modifiedLayers.size() > 0 ? tr( "Do you want to save the changes to layers %1?" ).arg( modifiedLayerNames ) : tr( "Do you want to save the changes to layer %1?" ).arg( modifiedLayerNames ), buttons ) ) { case QMessageBox::Cancel: res = false; @@ -11054,11 +10727,9 @@ bool QgisApp::toggleEditingVectorLayer( QgsVectorLayer *vlayer, bool allowCancel QgsCanvasRefreshBlocker refreshBlocker; QStringList rollBackErrors; - if ( ! QgsProject::instance()->rollBack( rollBackErrors, true, vlayer ) ) + if ( !QgsProject::instance()->rollBack( rollBackErrors, true, vlayer ) ) { - visibleMessageBar()->pushMessage( tr( "Error" ), - tr( "Problems during roll back: '%1'" ).arg( rollBackErrors.join( " / " ) ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Error" ), tr( "Problems during roll back: '%1'" ).arg( rollBackErrors.join( " / " ) ), Qgis::MessageLevel::Critical ); res = false; } @@ -11108,9 +10779,9 @@ bool QgisApp::toggleEditingMeshLayer( QgsMeshLayer *mlayer, bool allowCancel ) if ( !mlayer->isEditable() ) { - QMessageBox *messageBox = new QMessageBox( QMessageBox::NoIcon, tr( "Start Mesh Frame Edit" ), - tr( "Starting editing the frame of this mesh layer will remove all dataset groups.\n" - "Alternatively, you can create a new mesh layer from that one." ), QMessageBox::Cancel ); + QMessageBox *messageBox = new QMessageBox( QMessageBox::NoIcon, tr( "Start Mesh Frame Edit" ), tr( "Starting editing the frame of this mesh layer will remove all dataset groups.\n" + "Alternatively, you can create a new mesh layer from that one." ), + QMessageBox::Cancel ); messageBox->addButton( tr( "Edit Current Mesh" ), QMessageBox::NoRole ); QPushButton *editCopyButton = messageBox->addButton( tr( "Edit a Copy" ), QMessageBox::NoRole ); @@ -11146,11 +10817,11 @@ bool QgisApp::toggleEditingMeshLayer( QgsMeshLayer *mlayer, bool allowCancel ) { if ( error.errorType != Qgis::MeshEditingErrorType::NoError ) { - if ( QMessageBox::question( this, tr( "Mesh Editing" ), - tr( "At least one topological error in the mesh prevents starting editing.\n" - "Some errors can be fixed by removing invalid elements.\n\n" - "Do you want to try to fix errors before starting editing?" ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ) == QMessageBox::Yes ) + if ( QMessageBox::question( this, tr( "Mesh Editing" ), tr( "At least one topological error in the mesh prevents starting editing.\n" + "Some errors can be fixed by removing invalid elements.\n\n" + "Do you want to try to fix errors before starting editing?" ), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ) + == QMessageBox::Yes ) { QgsTemporaryCursorOverride waitCursor( Qt::WaitCursor ); res = mlayer->startFrameEditing( transform, error, true ); @@ -11161,9 +10832,9 @@ bool QgisApp::toggleEditingMeshLayer( QgsMeshLayer *mlayer, bool allowCancel ) { visibleMessageBar()->pushWarning( tr( "Mesh editing" ), - tr( "Unable to start mesh editing for layer \"%1\"" ).arg( mlayer->name() ) ); + tr( "Unable to start mesh editing for layer \"%1\"" ).arg( mlayer->name() ) + ); } - } mActionToggleEditing->setChecked( res ); @@ -11173,10 +10844,7 @@ bool QgisApp::toggleEditingMeshLayer( QgsMeshLayer *mlayer, bool allowCancel ) QMessageBox::StandardButtons buttons = QMessageBox::Save | QMessageBox::Discard; if ( allowCancel ) buttons = buttons | QMessageBox::Cancel; - switch ( QMessageBox::question( nullptr, - tr( "Stop Editing" ), - tr( "Do you want to save the changes to layer %1?" ).arg( mlayer->name() ), - buttons ) ) + switch ( QMessageBox::question( nullptr, tr( "Stop Editing" ), tr( "Do you want to save the changes to layer %1?" ).arg( mlayer->name() ), buttons ) ) { case QMessageBox::Cancel: res = false; @@ -11190,7 +10858,8 @@ bool QgisApp::toggleEditingMeshLayer( QgsMeshLayer *mlayer, bool allowCancel ) { visibleMessageBar()->pushWarning( tr( "Mesh editing" ), - tr( "Unable to save editing for layer \"%1\"" ).arg( mlayer->name() ) ); + tr( "Unable to save editing for layer \"%1\"" ).arg( mlayer->name() ) + ); res = false; } @@ -11203,9 +10872,7 @@ bool QgisApp::toggleEditingMeshLayer( QgsMeshLayer *mlayer, bool allowCancel ) QgsCanvasRefreshBlocker refreshBlocker; if ( !mlayer->rollBackFrameEditing( transform, false ) ) { - visibleMessageBar()->pushMessage( tr( "Error" ), - tr( "Problems during roll back" ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Error" ), tr( "Problems during roll back" ), Qgis::MessageLevel::Critical ); res = false; } @@ -11301,7 +10968,8 @@ void QgisApp::saveMeshLayerEdits( QgsMapLayer *layer, bool leaveEditable, bool t if ( !mlayer->commitFrameEditing( transform, leaveEditable ) ) visibleMessageBar()->pushWarning( tr( "Mesh editing" ), - tr( "Unable to save editing for layer \"%1\"" ).arg( mlayer->name() ) ); + tr( "Unable to save editing for layer \"%1\"" ).arg( mlayer->name() ) + ); if ( triggerRepaint ) { @@ -11342,15 +11010,10 @@ void QgisApp::cancelVectorLayerEdits( QgsMapLayer *layer, bool leaveEditable, bo QgsCanvasRefreshBlocker refreshBlocker; QStringList rollbackErrors; - if ( ! QgsProject::instance()->rollBack( rollbackErrors, !leaveEditable, vlayer ) ) + if ( !QgsProject::instance()->rollBack( rollbackErrors, !leaveEditable, vlayer ) ) { mSaveRollbackInProgress = false; - QMessageBox::warning( nullptr, - tr( "Error" ), - tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" ) - .arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ), - vlayer->name(), - rollbackErrors.join( QLatin1String( "\n " ) ) ) ); + QMessageBox::warning( nullptr, tr( "Error" ), tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" ).arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ), vlayer->name(), rollbackErrors.join( QLatin1String( "\n " ) ) ) ); } if ( leaveEditable ) @@ -11377,11 +11040,7 @@ void QgisApp::cancelMeshLayerEdits( QgsMapLayer *layer, bool leaveEditable, bool if ( !mlayer->rollBackFrameEditing( transform, leaveEditable ) ) { mSaveRollbackInProgress = false; - QMessageBox::warning( nullptr, - tr( "Error" ), - tr( "Could not %1 changes to layer %2" ) - .arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ), - mlayer->name() ) ); + QMessageBox::warning( nullptr, tr( "Error" ), tr( "Could not %1 changes to layer %2" ).arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ), mlayer->name() ) ); } if ( triggerRepaint ) @@ -11401,9 +11060,9 @@ void QgisApp::enableMeshEditingTools( bool enable ) QList QgisApp::captureTools() { - QList< QgsMapToolCapture * > res = mMapTools->captureTools(); + QList res = mMapTools->captureTools(); // also check current tool, in case it's a custom tool - if ( QgsMapToolCapture *currentTool = qobject_cast< QgsMapToolCapture * >( mMapCanvas->mapTool() ) ) + if ( QgsMapToolCapture *currentTool = qobject_cast( mMapCanvas->mapTool() ) ) { if ( !res.contains( currentTool ) ) res.append( currentTool ); @@ -11498,12 +11157,7 @@ void QgisApp::cancelAllEdits( bool verifyAction ) bool QgisApp::verifyEditsActionDialog( const QString &act, const QString &upon ) { bool res = false; - switch ( QMessageBox::question( nullptr, - tr( "Current edits" ), - tr( "%1 current changes for %2 layer(s)?" ) - .arg( act, - upon ), - QMessageBox::Yes | QMessageBox::No ) ) + switch ( QMessageBox::question( nullptr, tr( "Current edits" ), tr( "%1 current changes for %2 layer(s)?" ).arg( act, upon ), QMessageBox::Yes | QMessageBox::No ) ) { case QMessageBox::Yes: res = true; @@ -11528,9 +11182,7 @@ void QgisApp::updateLayerModifiedActions() QgsVectorLayer *vlayer = qobject_cast( currentLayer ); if ( QgsVectorDataProvider *dprovider = vlayer->dataProvider() ) { - enableSaveLayerEdits = ( dprovider->capabilities() & Qgis::VectorProviderCapability::ChangeAttributeValues - && vlayer->isEditable() - && vlayer->isModified() ); + enableSaveLayerEdits = ( dprovider->capabilities() & Qgis::VectorProviderCapability::ChangeAttributeValues && vlayer->isEditable() && vlayer->isModified() ); } } break; @@ -11591,9 +11243,9 @@ void QgisApp::duplicateVectorStyle( QgsVectorLayer *srcLayer, QgsVectorLayer *de if ( srcLayer->geometryType() == destLayer->geometryType() ) { QDomImplementation DomImplementation; - QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); rootNode.setAttribute( QStringLiteral( "version" ), Qgis::version() ); @@ -11614,7 +11266,6 @@ void QgisApp::layerSubsetString() void QgisApp::layerSubsetString( QgsMapLayer *mapLayer ) { - QgsVectorLayer *vlayer = qobject_cast( mapLayer ); if ( !vlayer ) { @@ -11623,8 +11274,7 @@ void QgisApp::layerSubsetString( QgsMapLayer *mapLayer ) if ( rlayer ) { QgsRasterDataProvider *provider = rlayer->dataProvider(); - if ( provider && - provider->supportsSubsetString() ) + if ( provider && provider->supportsSubsetString() ) { // PG raster is the only one for now if ( provider->name() == QLatin1String( "postgresraster" ) ) @@ -11633,8 +11283,8 @@ void QgisApp::layerSubsetString( QgsMapLayer *mapLayer ) QgsDataSourceUri vectorUri { provider->dataSourceUri() }; vectorUri.setGeometryColumn( QString() ); vectorUri.setSrid( QString() ); - QgsVectorLayer vlayer { vectorUri.uri( ), QStringLiteral( "pgrasterlayer" ), QStringLiteral( "postgres" ) }; - if ( vlayer.isValid( ) ) + QgsVectorLayer vlayer { vectorUri.uri(), QStringLiteral( "pgrasterlayer" ), QStringLiteral( "postgres" ) }; + if ( vlayer.isValid() ) { // launch the query builder QgsQueryBuilder qb { &vlayer }; @@ -11655,8 +11305,7 @@ void QgisApp::layerSubsetString( QgsMapLayer *mapLayer ) } else { - QMessageBox::warning( this, tr( "Error Setting Filter" ), - tr( "The filtered layer returned no rows. The PostgreSQL raster provider requires at least one row in order to extract the information required to create a valid layer." ) ); + QMessageBox::warning( this, tr( "Error Setting Filter" ), tr( "The filtered layer returned no rows. The PostgreSQL raster provider requires at least one row in order to extract the information required to create a valid layer." ) ); } } } @@ -11683,11 +11332,11 @@ void QgisApp::layerSubsetString( QgsMapLayer *mapLayer ) if ( joins ) { - if ( QMessageBox::question( nullptr, tr( "Filter on Joined Fields" ), - tr( "You are about to set a subset filter on a layer that has joined fields. " - "Joined fields cannot be filtered, unless you convert the layer to a virtual layer first. " - "Would you like to create a virtual layer out of this layer first?" ), - QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, tr( "Filter on Joined Fields" ), tr( "You are about to set a subset filter on a layer that has joined fields. " + "Joined fields cannot be filtered, unless you convert the layer to a virtual layer first. " + "Would you like to create a virtual layer out of this layer first?" ), + QMessageBox::Yes | QMessageBox::No ) + == QMessageBox::Yes ) { QgsVirtualLayerDefinition def = QgsVirtualLayerDefinitionUtils::fromJoinedLayer( vlayer ); const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; @@ -11776,8 +11425,7 @@ void QgisApp::projectCrsChanged() if ( !alreadyAsked.contains( it.value()->crs() ) ) { alreadyAsked.append( it.value()->crs() ); - askUserForDatumTransform( it.value()->crs(), - QgsProject::instance()->crs(), it.value() ); + askUserForDatumTransform( it.value()->crs(), QgsProject::instance()->crs(), it.value() ); } } } @@ -11794,20 +11442,19 @@ void QgisApp::projectTemporalRangeChanged() if ( currentLayer->dataProvider() ) { if ( QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( - currentLayer->providerType() ) ) + currentLayer->providerType() + ) ) { QVariantMap uri = metadata->decodeUri( currentLayer->dataProvider()->dataSourceUri() ); - if ( uri.contains( QStringLiteral( "temporalSource" ) ) && - uri.value( QStringLiteral( "temporalSource" ) ).toString() == QLatin1String( "project" ) ) + if ( uri.contains( QStringLiteral( "temporalSource" ) ) && uri.value( QStringLiteral( "temporalSource" ) ).toString() == QLatin1String( "project" ) ) { QgsDateTimeRange range = QgsProject::instance()->timeSettings()->temporalRange(); if ( range.begin().isValid() && range.end().isValid() ) { - QString time = range.begin().toString( Qt::ISODateWithMs ) + '/' + - range.end().toString( Qt::ISODateWithMs ); + QString time = range.begin().toString( Qt::ISODateWithMs ) + '/' + range.end().toString( Qt::ISODateWithMs ); - uri[ QStringLiteral( "time" ) ] = time; + uri[QStringLiteral( "time" )] = time; currentLayer->setDataSource( metadata->encodeUri( uri ), currentLayer->name(), currentLayer->providerType(), QgsDataProvider::ProviderOptions() ); } @@ -11854,8 +11501,7 @@ void QgisApp::removeLayer() } if ( !nonRemovableLayerNames.isEmpty() ) { - QMessageBox::warning( this, tr( "Required Layers" ), - tr( "The following layers are marked as required by the project:\n\n%1\n\nPlease deselect them (or unmark as required) and retry." ).arg( nonRemovableLayerNames.join( QLatin1Char( '\n' ) ) ) ); + QMessageBox::warning( this, tr( "Required Layers" ), tr( "The following layers are marked as required by the project:\n\n%1\n\nPlease deselect them (or unmark as required) and retry." ).arg( nonRemovableLayerNames.join( QLatin1Char( '\n' ) ) ) ); return; } @@ -11869,7 +11515,7 @@ void QgisApp::removeLayer() QStringList activeTaskDescriptions; for ( QgsMapLayer *layer : selectedLayers ) { - QList< QgsTask * > tasks = QgsApplication::taskManager()->tasksDependentOnLayer( layer ); + QList tasks = QgsApplication::taskManager()->tasksDependentOnLayer( layer ); if ( !tasks.isEmpty() ) { const auto constTasks = tasks; @@ -11882,8 +11528,7 @@ void QgisApp::removeLayer() if ( !activeTaskDescriptions.isEmpty() ) { - QMessageBox::warning( this, tr( "Active Tasks" ), - tr( "The following tasks are currently running which depend on this layer:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( activeTaskDescriptions.join( QLatin1Char( '\n' ) ) ) ); + QMessageBox::warning( this, tr( "Active Tasks" ), tr( "The following tasks are currently running which depend on this layer:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( activeTaskDescriptions.join( QLatin1Char( '\n' ) ) ) ); return; } @@ -11892,9 +11537,7 @@ void QgisApp::removeLayer() //validate selection if ( selectedNodes.isEmpty() ) { - visibleMessageBar()->pushMessage( tr( "No legend entries selected" ), - tr( "Select the layers and groups you want to remove in the legend." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No legend entries selected" ), tr( "Select the layers and groups you want to remove in the legend." ), Qgis::MessageLevel::Info ); return; } @@ -11912,8 +11555,7 @@ void QgisApp::removeLayer() // Check if there are any hidden layer elements and display a confirmation dialog QStringList hiddenLayerNames; - auto harvest = [ &hiddenLayerNames ]( const QgsLayerTreeNode * parent ) - { + auto harvest = [&hiddenLayerNames]( const QgsLayerTreeNode *parent ) { const auto cChildren { parent->children() }; for ( const auto &c : cChildren ) { @@ -11922,7 +11564,7 @@ void QgisApp::removeLayer() const auto treeLayer { QgsLayerTree::toLayer( c ) }; if ( treeLayer->layer() && treeLayer->layer()->flags().testFlag( QgsMapLayer::LayerFlag::Private ) ) { - hiddenLayerNames.push_back( treeLayer->layer()->name( ) ); + hiddenLayerNames.push_back( treeLayer->layer()->name() ); } } } @@ -11934,13 +11576,13 @@ void QgisApp::removeLayer() } QString message { tr( "Remove %n legend entries?", "number of legend items to remove", selectedNodes.count() ) }; - if ( ! hiddenLayerNames.isEmpty() ) + if ( !hiddenLayerNames.isEmpty() ) { - if ( hiddenLayerNames.count( ) > 10 ) + if ( hiddenLayerNames.count() > 10 ) { const int layerCount = hiddenLayerNames.count(); hiddenLayerNames = hiddenLayerNames.mid( 0, 10 ); - hiddenLayerNames.push_back( tr( "(%n more hidden layer(s))", "number of hidden layers not shown", layerCount - 10 ) ); + hiddenLayerNames.push_back( tr( "(%n more hidden layer(s))", "number of hidden layers not shown", layerCount - 10 ) ); } message.append( tr( "The following hidden layers will be removed:\n%1" ).arg( hiddenLayerNames.join( '\n' ) ) ); } @@ -11952,7 +11594,7 @@ void QgisApp::removeLayer() for ( QgsLayerTreeNode *node : selectedNodes ) { - if ( QgsLayerTreeGroup *group = qobject_cast< QgsLayerTreeGroup * >( node ) ) + if ( QgsLayerTreeGroup *group = qobject_cast( node ) ) { if ( QgsGroupLayer *groupLayer = group->groupLayer() ) { @@ -12027,29 +11669,29 @@ void QgisApp::duplicateLayers( const QList &lyrList ) dupLayer = selectedLyr->clone(); break; } - } if ( dupLayer && !dupLayer->isValid() ) { msgBars.append( new QgsMessageBarItem( - tr( "Duplicate layer: " ), - tr( "%1 (duplication resulted in invalid layer)" ).arg( selectedLyr->name() ), - Qgis::MessageLevel::Warning, - 0, - mInfoBar ) ); + tr( "Duplicate layer: " ), + tr( "%1 (duplication resulted in invalid layer)" ).arg( selectedLyr->name() ), + Qgis::MessageLevel::Warning, + 0, + mInfoBar + ) ); continue; } else if ( !unSppType.isEmpty() || !dupLayer ) { msgBars.append( new QgsMessageBarItem( - tr( "Duplicate layer: " ), - tr( "%1 (%2 type unsupported)" ) - .arg( selectedLyr->name(), - !unSppType.isEmpty() ? QStringLiteral( "'" ) + unSppType + "' " : QString() ), - Qgis::MessageLevel::Warning, - 0, - mInfoBar ) ); + tr( "Duplicate layer: " ), + tr( "%1 (%2 type unsupported)" ) + .arg( selectedLyr->name(), !unSppType.isEmpty() ? QStringLiteral( "'" ) + unSppType + "' " : QString() ), + Qgis::MessageLevel::Warning, + 0, + mInfoBar + ) ); continue; } @@ -12080,13 +11722,9 @@ void QgisApp::duplicateLayers( const QList &lyrList ) if ( errMsg.isEmpty() ) dupLayer->importNamedStyle( style, errMsg ); if ( !errMsg.isEmpty() ) - visibleMessageBar()->pushMessage( errMsg, - tr( "Cannot copy style to duplicated layer." ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( errMsg, tr( "Cannot copy style to duplicated layer." ), Qgis::MessageLevel::Critical ); else if ( qobject_cast( dupLayer ) ) - visibleMessageBar()->pushMessage( tr( "Layer duplication complete" ), - dupLayer->providerType() != QLatin1String( "memory" ) ? tr( "Note that it's using the same data source." ) : QString(), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Layer duplication complete" ), dupLayer->providerType() != QLatin1String( "memory" ) ? tr( "Note that it's using the same data source." ) : QString(), Qgis::MessageLevel::Info ); if ( !newSelection ) newSelection = dupLayer; @@ -12246,7 +11884,7 @@ void QgisApp::legendLayerZoomNative() QgsDebugMsgLevel( "Raster units per pixel : " + QString::number( layer->rasterUnitsPerPixelX() ), 2 ); QgsDebugMsgLevel( "MapUnitsPerPixel before : " + QString::number( mMapCanvas->mapUnitsPerPixel() ), 2 ); - QList< double >nativeResolutions; + QList nativeResolutions; if ( layer->dataProvider() ) { nativeResolutions = layer->dataProvider()->nativeResolutions(); @@ -12264,7 +11902,7 @@ void QgisApp::legendLayerZoomNative() if ( !nativeResolutions.empty() ) { // find closest native resolution - QList< double > diagonalNativeResolutions; + QList diagonalNativeResolutions; diagonalNativeResolutions.reserve( nativeResolutions.size() ); for ( double d : std::as_const( nativeResolutions ) ) diagonalNativeResolutions << std::sqrt( 2 * d * d ); @@ -12274,8 +11912,7 @@ void QgisApp::legendLayerZoomNative() { QgsDebugMsgLevel( QStringLiteral( "test resolution %1: %2" ).arg( i ).arg( diagonalNativeResolutions.at( i ) ), 2 ); } - if ( i == nativeResolutions.size() || - ( i > 0 && ( ( diagonalNativeResolutions.at( i ) - diagonalSize ) > ( diagonalSize - diagonalNativeResolutions.at( i - 1 ) ) ) ) ) + if ( i == nativeResolutions.size() || ( i > 0 && ( ( diagonalNativeResolutions.at( i ) - diagonalSize ) > ( diagonalSize - diagonalNativeResolutions.at( i - 1 ) ) ) ) ) { QgsDebugMsgLevel( QStringLiteral( "previous resolution" ), 2 ); i--; @@ -12336,7 +11973,7 @@ void QgisApp::applyStyleToGroup() if ( !mLayerTreeView ) return; - QList< QgsLayerTreeNode * > selectedNodes = mLayerTreeView->selectedNodes(); + QList selectedNodes = mLayerTreeView->selectedNodes(); if ( selectedNodes.isEmpty() && mLayerTreeView->currentNode() ) selectedNodes.append( mLayerTreeView->currentNode() ); @@ -12438,7 +12075,8 @@ void QgisApp::showPluginManager() class QgsPythonRunnerImpl : public QgsPythonRunner { public: - explicit QgsPythonRunnerImpl( QgsPythonUtils *pythonUtils ) : mPythonUtils( pythonUtils ) {} + explicit QgsPythonRunnerImpl( QgsPythonUtils *pythonUtils ) + : mPythonUtils( pythonUtils ) {} bool runCommand( QString command, QString messageOnError = QString() ) override { @@ -12477,7 +12115,7 @@ void QgisApp::loadPythonSupport() QgsScopedRuntimeProfile profile( tr( "Loading Python support" ) ); QString pythonlibName( QStringLiteral( "qgispython" ) ); -#if defined(Q_OS_UNIX) +#if defined( Q_OS_UNIX ) pythonlibName.prepend( QgsApplication::libraryPath() ); #endif #ifdef __MINGW32__ @@ -12500,8 +12138,8 @@ void QgisApp::loadPythonSupport() } #ifdef WITH_BINDINGS - typedef QgsPythonUtils*( *inst )(); - inst pythonlib_inst = reinterpret_cast< inst >( cast_to_fptr( pythonlib.resolve( "instance" ) ) ); + typedef QgsPythonUtils *( *inst )(); + inst pythonlib_inst = reinterpret_cast( cast_to_fptr( pythonlib.resolve( "instance" ) ) ); if ( !pythonlib_inst ) { //using stderr on purpose because we want end users to see this [TS] @@ -12595,12 +12233,11 @@ void QgisApp::options() showOptionsDialog( this ); } -QMap< QString, QString > QgisApp::projectPropertiesPagesMap() +QMap QgisApp::projectPropertiesPagesMap() { - static QMap< QString, QString > sProjectPropertiesPagesMap; + static QMap sProjectPropertiesPagesMap; static std::once_flag initialized; - std::call_once( initialized, [] - { + std::call_once( initialized, [] { sProjectPropertiesPagesMap.insert( QCoreApplication::translate( "QgsProjectPropertiesBase", "General" ), QStringLiteral( "mProjOptsGeneral" ) ); sProjectPropertiesPagesMap.insert( QCoreApplication::translate( "QgsProjectPropertiesBase", "Metadata" ), QStringLiteral( "mMetadataPage" ) ); sProjectPropertiesPagesMap.insert( QCoreApplication::translate( "QgsProjectPropertiesBase", "View Settings" ), QStringLiteral( "mViewSettingsPage" ) ); @@ -12616,7 +12253,7 @@ QMap< QString, QString > QgisApp::projectPropertiesPagesMap() sProjectPropertiesPagesMap.insert( QCoreApplication::translate( "QgsProjectPropertiesBase", "Temporal" ), QStringLiteral( "mTemporalOptions" ) ); } ); - for ( const QPointer< QgsOptionsWidgetFactory > &f : std::as_const( mProjectPropertiesWidgetFactories ) ) + for ( const QPointer &f : std::as_const( mProjectPropertiesWidgetFactories ) ) { // remove any deleted factories if ( f ) @@ -12633,12 +12270,11 @@ void QgisApp::showProjectProperties( const QString &page ) projectProperties( page ); } -QMap< QString, QString > QgisApp::settingPagesMap() +QMap QgisApp::settingPagesMap() { - static QMap< QString, QString > sSettingPagesMap; + static QMap sSettingPagesMap; static std::once_flag initialized; - std::call_once( initialized, [] - { + std::call_once( initialized, [] { sSettingPagesMap.insert( tr( "Style Manager" ), QStringLiteral( "stylemanager" ) ); sSettingPagesMap.insert( tr( "Keyboard Shortcuts" ), QStringLiteral( "shortcuts" ) ); sSettingPagesMap.insert( tr( "Custom Projections" ), QStringLiteral( "customprojection" ) ); @@ -12670,10 +12306,9 @@ void QgisApp::showSettings( const QString &page ) QMap QgisApp::optionsPagesMap() { - static QMap< QString, QString > sOptionsPagesMap; + static QMap sOptionsPagesMap; static std::once_flag initialized; - std::call_once( initialized, [] - { + std::call_once( initialized, [] { sOptionsPagesMap.insert( QCoreApplication::translate( "QgsOptionsBase", "General" ), QStringLiteral( "mOptionsPageGeneral" ) ); sOptionsPagesMap.insert( QCoreApplication::translate( "QgsOptionsBase", "System" ), QStringLiteral( "mOptionsPageSystem" ) ); sOptionsPagesMap.insert( QCoreApplication::translate( "QgsOptionsBase", "CRS Handling" ), QStringLiteral( "mOptionsPageCRS" ) ); @@ -12693,8 +12328,8 @@ QMap QgisApp::optionsPagesMap() sOptionsPagesMap.insert( QCoreApplication::translate( "QgsOptionsBase", "Advanced" ), QCoreApplication::translate( "QgsOptionsBase", "Advanced" ) ); } ); - QMap< QString, QString > pages = sOptionsPagesMap; - for ( const QPointer< QgsOptionsWidgetFactory > &f : std::as_const( mOptionsWidgetFactories ) ) + QMap pages = sOptionsPagesMap; + for ( const QPointer &f : std::as_const( mOptionsWidgetFactories ) ) { // remove any deleted factories if ( f ) @@ -12707,9 +12342,9 @@ QMap QgisApp::optionsPagesMap() QgsOptions *QgisApp::createOptionsDialog( QWidget *parent ) { - QList< QgsOptionsWidgetFactory * > factories; + QList factories; const auto constMOptionsWidgetFactories = mOptionsWidgetFactories; - for ( const QPointer< QgsOptionsWidgetFactory > &f : constMOptionsWidgetFactories ) + for ( const QPointer &f : constMOptionsWidgetFactories ) { // remove any deleted factories if ( f ) @@ -12721,7 +12356,7 @@ QgsOptions *QgisApp::createOptionsDialog( QWidget *parent ) void QgisApp::showOptionsDialog( QWidget *parent, const QString ¤tPage, int pageNumber ) { - std::unique_ptr< QgsOptions > optionsDialog( createOptionsDialog( parent ) ); + std::unique_ptr optionsDialog( createOptionsDialog( parent ) ); QgsSettings mySettings; const QStringList oldScales = QgsSettingsRegistryCore::settingsMapScales->value(); @@ -12752,7 +12387,7 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString ¤tPage, in //update any open compositions so they reflect new composer settings //we have to push the changes to the compositions here, because compositions //have no access to qgisapp and accordingly can't listen in to changes - const QList< QgsMasterLayoutInterface * > layouts = QgsProject::instance()->layoutManager()->layouts() ; + const QList layouts = QgsProject::instance()->layoutManager()->layouts(); for ( QgsMasterLayoutInterface *layout : layouts ) { layout->updateSettings(); @@ -12771,10 +12406,10 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString ¤tPage, in mScaleWidget->updateScales(); } - mMapTools->mapTool< QgsMeasureTool >( QgsAppMapTools::MeasureDistance )->updateSettings(); - mMapTools->mapTool< QgsMeasureTool >( QgsAppMapTools::MeasureArea )->updateSettings(); - mMapTools->mapTool< QgsMapToolMeasureAngle >( QgsAppMapTools::MeasureAngle )->updateSettings(); - mMapTools->mapTool< QgsMapToolMeasureBearing >( QgsAppMapTools::MeasureBearing )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureDistance )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureArea )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureAngle )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureBearing )->updateSettings(); #ifdef HAVE_3D for ( Qgs3DMapCanvasWidget *canvas3D : std::as_const( mOpen3DMapViews ) ) @@ -12817,18 +12452,14 @@ void QgisApp::histogramStretch( bool visibleAreaOnly, Qgis::RasterRangeLimit lim if ( !myLayer ) { - visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), - tr( "To perform a full histogram stretch, you need to have a raster layer selected." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), tr( "To perform a full histogram stretch, you need to have a raster layer selected." ), Qgis::MessageLevel::Info ); return; } QgsRasterLayer *myRasterLayer = qobject_cast( myLayer ); if ( !myRasterLayer ) { - visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), - tr( "To perform a full histogram stretch, you need to have a raster layer selected." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), tr( "To perform a full histogram stretch, you need to have a raster layer selected." ), Qgis::MessageLevel::Info ); return; } @@ -12888,18 +12519,14 @@ void QgisApp::adjustBrightnessContrast( int delta, bool updateBrightness ) { if ( !layer ) { - visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), - tr( "To change brightness or contrast, you need to have a raster layer selected." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), tr( "To change brightness or contrast, you need to have a raster layer selected." ), Qgis::MessageLevel::Info ); return; } QgsRasterLayer *rasterLayer = qobject_cast( layer ); if ( !rasterLayer ) { - visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), - tr( "To change brightness or contrast, you need to have a raster layer selected." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), tr( "To change brightness or contrast, you need to have a raster layer selected." ), Qgis::MessageLevel::Info ); return; } @@ -12945,18 +12572,14 @@ void QgisApp::adjustGamma( double delta ) { if ( !layer ) { - visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), - tr( "To change gamma, you need to have a raster layer selected." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), tr( "To change gamma, you need to have a raster layer selected." ), Qgis::MessageLevel::Info ); return; } QgsRasterLayer *rasterLayer = qobject_cast( layer ); if ( !rasterLayer ) { - visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), - tr( "To change gamma, you need to have a raster layer selected." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "No Layer Selected" ), tr( "To change gamma, you need to have a raster layer selected." ), Qgis::MessageLevel::Info ); return; } @@ -12985,40 +12608,35 @@ void QgisApp::pyQgisApiDocumentation() void QgisApp::reportaBug() { QgsSettings settings; - QString reportaBugUrl = settings.value( QStringLiteral( "qgis/reportaBugUrl" ), - tr( "https://qgis.org/resources/support/bug-reporting/" ) ).toString(); + QString reportaBugUrl = settings.value( QStringLiteral( "qgis/reportaBugUrl" ), tr( "https://qgis.org/resources/support/bug-reporting/" ) ).toString(); openURL( reportaBugUrl, false ); } void QgisApp::getInvolved() { QgsSettings settings; - QString getInvolvedUrl = settings.value( QStringLiteral( "qgis/getInvolved" ), - tr( "https://qgis.org/community/involve/" ) ).toString(); + QString getInvolvedUrl = settings.value( QStringLiteral( "qgis/getInvolved" ), tr( "https://qgis.org/community/involve/" ) ).toString(); openURL( getInvolvedUrl, false ); } void QgisApp::donate() { QgsSettings settings; - QString donateUrl = settings.value( QStringLiteral( "qgis/donate" ), - tr( "https://qgis.org/funding/donate/" ) ).toString(); + QString donateUrl = settings.value( QStringLiteral( "qgis/donate" ), tr( "https://qgis.org/funding/donate/" ) ).toString(); openURL( donateUrl, false ); } void QgisApp::supportProviders() { QgsSettings settings; - QString supportProvidersUrl = settings.value( QStringLiteral( "qgis/supportProvidersUrl" ), - tr( "https://qgis.org/resources/support/commercial-support/" ) ).toString(); + QString supportProvidersUrl = settings.value( QStringLiteral( "qgis/supportProvidersUrl" ), tr( "https://qgis.org/resources/support/commercial-support/" ) ).toString(); openURL( supportProvidersUrl, false ); } void QgisApp::helpQgisHomePage() { QgsSettings settings; - QString helpQgisHomePageUrl = settings.value( QStringLiteral( "qgis/helpQgisHomePageUrl" ), - QStringLiteral( "https://qgis.org" ) ).toString(); + QString helpQgisHomePageUrl = settings.value( QStringLiteral( "qgis/helpQgisHomePageUrl" ), QStringLiteral( "https://qgis.org" ) ).toString(); openURL( helpQgisHomePageUrl, false ); } @@ -13035,13 +12653,11 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory ) * QProcess creates a new browser process for each invocation and expects a * commandline application rather than a bundled application. */ - CFURLRef urlRef = CFURLCreateWithBytes( kCFAllocatorDefault, - reinterpret_cast( url.toUtf8().constData() ), url.length(), - kCFStringEncodingUTF8, nullptr ); + CFURLRef urlRef = CFURLCreateWithBytes( kCFAllocatorDefault, reinterpret_cast( url.toUtf8().constData() ), url.length(), kCFStringEncodingUTF8, nullptr ); OSStatus status = LSOpenCFURLRef( urlRef, nullptr ); Q_UNUSED( status ) CFRelease( urlRef ); -#elif defined(Q_OS_WIN) +#elif defined( Q_OS_WIN ) if ( url.startsWith( "file://", Qt::CaseInsensitive ) ) #ifdef UNICODE ShellExecute( 0, 0, url.mid( 7 ).toStdWString().c_str(), 0, 0, SW_SHOWNORMAL ); @@ -13161,7 +12777,7 @@ void QgisApp::registerMapToolHandler( QgsAbstractMapToolHandler *handler ) void QgisApp::switchToMapToolViaHandler() { - QAction *sourceAction = qobject_cast< QAction * >( sender() ); + QAction *sourceAction = qobject_cast( sender() ); if ( !sourceAction ) return; @@ -13222,18 +12838,18 @@ bool QgisApp::setActiveLayer( QgsMapLayer *layer ) void QgisApp::reloadConnections() { - emit connectionsChanged( ); + emit connectionsChanged(); } void QgisApp::showLayoutManager() { - static_cast< QgsAppWindowManager * >( QgsGui::windowManager() )->openApplicationDialog( QgsAppWindowManager::DialogLayoutManager ); + static_cast( QgsGui::windowManager() )->openApplicationDialog( QgsAppWindowManager::DialogLayoutManager ); } void QgisApp::show3DMapViewsManager() { #ifdef HAVE_3D - static_cast< QgsAppWindowManager * >( QgsGui::windowManager() )->openApplicationDialog( QgsAppWindowManager::Dialog3DMapViewsManager ); + static_cast( QgsGui::windowManager() )->openApplicationDialog( QgsAppWindowManager::Dialog3DMapViewsManager ); #endif } @@ -13305,7 +12921,7 @@ void QgisApp::newMapCanvas() int i = 1; bool existing = true; - QList< QgsMapCanvas * > existingCanvases = mapCanvases(); + QList existingCanvases = mapCanvases(); QString name; while ( existing ) { @@ -13368,16 +12984,16 @@ void QgisApp::initLayouts() new QgsLayoutItemMetadata( QgsLayoutItemRegistry::Layout3DMap, tr( "3D Map" ), tr( "3D Maps" ), QgsLayoutItem3DMap::create ) ); - auto createRubberBand = ( []( QgsLayoutView * view )->QgsLayoutViewRubberBand * - { + auto createRubberBand = ( []( QgsLayoutView *view ) -> QgsLayoutViewRubberBand * { return new QgsLayoutViewRectangularRubberBand( view ); } ); - std::unique_ptr< QgsLayoutItemGuiMetadata > map3dMetadata = std::make_unique< QgsLayoutItemGuiMetadata>( - QgsLayoutItemRegistry::Layout3DMap, tr( "3D Map" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAdd3DMap.svg" ) ), - [ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * - { - return new QgsLayout3DMapWidget( qobject_cast< QgsLayoutItem3DMap * >( item ) ); - }, createRubberBand ); + std::unique_ptr map3dMetadata = std::make_unique( + QgsLayoutItemRegistry::Layout3DMap, tr( "3D Map" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAdd3DMap.svg" ) ), + [=]( QgsLayoutItem *item ) -> QgsLayoutItemBaseWidget * { + return new QgsLayout3DMapWidget( qobject_cast( item ) ); + }, + createRubberBand + ); QgsGui::layoutItemGuiRegistry()->addLayoutItemGuiMetadata( map3dMetadata.release() ); #endif @@ -13386,10 +13002,9 @@ void QgisApp::initLayouts() mLayoutImageDropHandler = new QgsLayoutImageDropHandler( this ); registerCustomLayoutDropHandler( mLayoutImageDropHandler ); - QgsLayoutElevationProfileWidget::sBuildCopyMenuFunction = [ = ]( QgsLayoutElevationProfileWidget * layoutWidget, QMenu * menu ) - { + QgsLayoutElevationProfileWidget::sBuildCopyMenuFunction = [=]( QgsLayoutElevationProfileWidget *layoutWidget, QMenu *menu ) { menu->clear(); - const QList elevationProfileWidgets = findChildren< QgsElevationProfileWidget * >(); + const QList elevationProfileWidgets = findChildren(); if ( elevationProfileWidgets.empty() ) { @@ -13402,8 +13017,7 @@ void QgisApp::initLayouts() for ( QgsElevationProfileWidget *widget : elevationProfileWidgets ) { QAction *action = new QAction( tr( "Copy From %1" ).arg( widget->canvasName() ), menu ); - connect( action, &QAction::triggered, widget, [ = ] - { + connect( action, &QAction::triggered, widget, [=] { layoutWidget->copySettingsFromProfileCanvas( widget->profileCanvas() ); } ); menu->addAction( action ); @@ -13442,7 +13056,7 @@ Qgs3DMapCanvasWidget *QgisApp::createNew3DMapCanvasDock( const QString &name, bo QgsElevationProfileWidget *QgisApp::createNewElevationProfile() { - const QList elevationProfileWidgets = findChildren< QgsElevationProfileWidget * >(); + const QList elevationProfileWidgets = findChildren(); // find first available unused title QString title; @@ -13499,7 +13113,7 @@ Qgs3DMapCanvas *QgisApp::createNewMapCanvas3D( const QString &name ) } int i = 1; - const QList< QString > usedCanvasNames = QgsProject::instance()->viewsManager()->get3DViewsNames(); + const QList usedCanvasNames = QgsProject::instance()->viewsManager()->get3DViewsNames(); QString uniqueName = name.isEmpty() ? tr( "3D Map %1" ).arg( i ) : name; while ( usedCanvasNames.contains( uniqueName ) ) { @@ -13549,25 +13163,24 @@ Qgs3DMapCanvas *QgisApp::createNewMapCanvas3D( const QString &name ) map->setOutputDpi( QGuiApplication::primaryScreen()->logicalDotsPerInch() ); map->setRendererUsage( Qgis::RendererUsage::View ); - connect( QgsProject::instance(), &QgsProject::transformContextChanged, map, [map] - { + connect( QgsProject::instance(), &QgsProject::transformContextChanged, map, [map] { map->setTransformContext( QgsProject::instance()->transformContext() ); } ); canvasWidget->setMapSettings( map ); - const QgsRectangle canvasExtent = Qgs3DUtils::tryReprojectExtent2D( mMapCanvas->extent(), mMapCanvas->mapSettings().destinationCrs(), map->crs(), prj->transformContext() ); - float dist = static_cast< float >( std::max( canvasExtent.width(), canvasExtent.height() ) ); - canvasWidget->mapCanvas3D()->setViewFromTop( canvasExtent.center(), dist, static_cast< float >( mMapCanvas->rotation() ) ); + const QgsRectangle canvasExtent = Qgs3DUtils::tryReprojectExtent2D( mMapCanvas->extent(), mMapCanvas->mapSettings().destinationCrs(), map->crs(), prj->transformContext() ); + float dist = static_cast( std::max( canvasExtent.width(), canvasExtent.height() ) ); + canvasWidget->mapCanvas3D()->setViewFromTop( canvasExtent.center(), dist, static_cast( mMapCanvas->rotation() ) ); const Qgis::VerticalAxisInversion axisInversion = settings.enumValue( QStringLiteral( "map3d/axisInversion" ), Qgis::VerticalAxisInversion::WhenDragging, QgsSettings::App ); if ( canvasWidget->mapCanvas3D()->cameraController() ) canvasWidget->mapCanvas3D()->cameraController()->setVerticalAxisInversion( axisInversion ); QDomImplementation DomImplementation; - QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement elem3DMap = doc.createElement( QStringLiteral( "view" ) ); @@ -13639,11 +13252,7 @@ bool QgisApp::saveDirty() markDirty(); // prompt user to save - answer = QMessageBox::question( this, tr( "Save Project" ), - tr( "Do you want to save the current project? %1" ) - .arg( whyDirty ), - QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard, - hasUnsavedEdits ? QMessageBox::Cancel : QMessageBox::Save ); + answer = QMessageBox::question( this, tr( "Save Project" ), tr( "Do you want to save the current project? %1" ).arg( whyDirty ), QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard, hasUnsavedEdits ? QMessageBox::Cancel : QMessageBox::Save ); if ( QMessageBox::Save == answer ) { if ( !fileSave() ) @@ -13687,7 +13296,7 @@ bool QgisApp::checkUnsavedLayerEdits() { // note that we skip the unsaved edits check for memory layers -- it's misleading, because their contents aren't actually // saved if this is part of a project close operation. Instead we let these get picked up by checkMemoryLayers() - if ( ! vl->dataProvider() || vl->providerType() == QLatin1String( "memory" ) ) + if ( !vl->dataProvider() || vl->providerType() == QLatin1String( "memory" ) ) continue; const bool hasUnsavedEdits = ( vl->isEditable() && vl->isModified() ); @@ -13709,11 +13318,11 @@ bool QgisApp::checkUnsavedRasterAttributeTableEdits( const QList QVector rasterLayers; - if ( ! mapLayers.isEmpty() ) + if ( !mapLayers.isEmpty() ) { for ( QgsMapLayer *mapLayer : std::as_const( mapLayers ) ) { - if ( QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( mapLayer ) ) + if ( QgsRasterLayer *rasterLayer = qobject_cast( mapLayer ) ) { rasterLayers.push_back( rasterLayer ); } @@ -13737,7 +13346,7 @@ bool QgisApp::checkUnsavedRasterAttributeTableEdits( const QList dirtyRats.push_back( rat ); } } - if ( ! dirtyBands.isEmpty( ) ) + if ( !dirtyBands.isEmpty() ) { QMessageBox::StandardButtons buttons = QMessageBox::Save | QMessageBox::Discard; if ( allowCancel ) @@ -13745,34 +13354,26 @@ bool QgisApp::checkUnsavedRasterAttributeTableEdits( const QList buttons |= QMessageBox::Cancel; } - switch ( QMessageBox::question( nullptr, - tr( "Save Raster Attribute Table" ), - tr( "Do you want to save the changes to the attribute tables (bands: %1) associated with layer '%2'?" ).arg( dirtyBands.join( QLatin1String( ", " ) ), rasterLayer->name() ), - buttons ) ) + switch ( QMessageBox::question( nullptr, tr( "Save Raster Attribute Table" ), tr( "Do you want to save the changes to the attribute tables (bands: %1) associated with layer '%2'?" ).arg( dirtyBands.join( QLatin1String( ", " ) ), rasterLayer->name() ), buttons ) ) { - case QMessageBox::Save: { for ( QgsRasterAttributeTable *rat : std::as_const( dirtyRats ) ) { QString errorMessage; - if ( rat->filePath().isEmpty( ) ) + if ( rat->filePath().isEmpty() ) { - if ( ! rasterLayer->dataProvider()->writeNativeAttributeTable( &errorMessage ) ) //#spellok + if ( !rasterLayer->dataProvider()->writeNativeAttributeTable( &errorMessage ) ) //#spellok { - visibleMessageBar()->pushMessage( tr( "Error Saving Raster Attribute Table" ), - tr( "An error occurred while saving raster attribute table for layer '%1': %2" ).arg( rasterLayer->name(), errorMessage ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Error Saving Raster Attribute Table" ), tr( "An error occurred while saving raster attribute table for layer '%1': %2" ).arg( rasterLayer->name(), errorMessage ), Qgis::MessageLevel::Critical ); retVal = false; } } else { - if ( ! rat->writeToFile( rat->filePath(), &errorMessage ) ) + if ( !rat->writeToFile( rat->filePath(), &errorMessage ) ) { - visibleMessageBar()->pushMessage( tr( "Error Saving Raster Attribute Table" ), - tr( "An error occurred while saving raster attribute table for layer '%1' to VAT.DBF file '%2': %3" ).arg( rasterLayer->name(), rat->filePath(), errorMessage ), - Qgis::MessageLevel::Critical ); + visibleMessageBar()->pushMessage( tr( "Error Saving Raster Attribute Table" ), tr( "An error occurred while saving raster attribute table for layer '%1' to VAT.DBF file '%2': %3" ).arg( rasterLayer->name(), rat->filePath(), errorMessage ), Qgis::MessageLevel::Critical ); retVal = false; } } @@ -13805,7 +13406,7 @@ bool QgisApp::checkMemoryLayers() { if ( it.value() && it.value()->providerType() == QLatin1String( "memory" ) ) { - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( it.value() ); + QgsVectorLayer *vl = qobject_cast( it.value() ); if ( vl && vl->featureCount() != 0 && !vl->customProperty( QStringLiteral( "skipMemoryLayersCheck" ) ).toInt() ) { hasMemoryLayers = true; @@ -13820,16 +13421,10 @@ bool QgisApp::checkMemoryLayers() bool close = true; if ( hasTemporaryLayers ) - close &= QMessageBox::warning( this, - tr( "Close Project" ), - tr( "This project includes one or more temporary layers. These layers are not permanently saved and their contents will be lost. Are you sure you want to proceed?" ), - QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel ) == QMessageBox::Yes ; + close &= QMessageBox::warning( this, tr( "Close Project" ), tr( "This project includes one or more temporary layers. These layers are not permanently saved and their contents will be lost. Are you sure you want to proceed?" ), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel ) == QMessageBox::Yes; else if ( hasMemoryLayers ) // use the more specific warning for memory layers - close &= QMessageBox::warning( this, - tr( "Close Project" ), - tr( "This project includes one or more temporary scratch layers. These layers are not saved to disk and their contents will be permanently lost. Are you sure you want to proceed?" ), - QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel ) == QMessageBox::Yes; + close &= QMessageBox::warning( this, tr( "Close Project" ), tr( "This project includes one or more temporary scratch layers. These layers are not saved to disk and their contents will be permanently lost. Are you sure you want to proceed?" ), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel ) == QMessageBox::Yes; return close; } @@ -13846,13 +13441,13 @@ bool QgisApp::checkExitBlockers() bool QgisApp::checkTasksDependOnProject() { - QSet< QString > activeTaskDescriptions; + QSet activeTaskDescriptions; QMap layers = QgsProject::instance()->mapLayers(); QMap::const_iterator layerIt = layers.constBegin(); for ( ; layerIt != layers.constEnd(); ++layerIt ) { - QList< QgsTask * > tasks = QgsApplication::taskManager()->tasksDependentOnLayer( layerIt.value() ); + QList tasks = QgsApplication::taskManager()->tasksDependentOnLayer( layerIt.value() ); if ( !tasks.isEmpty() ) { const auto constTasks = tasks; @@ -13865,8 +13460,7 @@ bool QgisApp::checkTasksDependOnProject() if ( !activeTaskDescriptions.isEmpty() ) { - QMessageBox::warning( this, tr( "Active Tasks" ), - tr( "The following tasks are currently running which depend on layers in this project:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( qgis::setToList( activeTaskDescriptions ).join( QLatin1Char( '\n' ) ) ) ); + QMessageBox::warning( this, tr( "Active Tasks" ), tr( "The following tasks are currently running which depend on layers in this project:\n\n%1\n\nPlease cancel these tasks and retry." ).arg( qgis::setToList( activeTaskDescriptions ).join( QLatin1Char( '\n' ) ) ) ); return true; } return false; @@ -13887,7 +13481,7 @@ void QgisApp::closeProject() mLegendExpressionFilterButton->setChecked( false ); mFilterLegendByMapContentAction->setChecked( false ); - const QList elevationProfileWidgets = findChildren< QgsElevationProfileWidget * >(); + const QList elevationProfileWidgets = findChildren(); for ( QgsElevationProfileWidget *widget : elevationProfileWidgets ) { delete widget; @@ -13974,7 +13568,7 @@ QMenu *QgisApp::getPluginMenu( const QString &menuName ) // Mac doesn't have '&' keyboard shortcuts. cleanedMenuName.remove( QChar( '&' ) ); #endif - QAction *before = mActionPluginSeparator2; // python separator or end of list + QAction *before = mActionPluginSeparator2; // python separator or end of list if ( !mActionPluginSeparator1 ) { // First plugin - create plugin list separator @@ -14588,7 +14182,8 @@ void QgisApp::updateCrsStatusBar() mOnTheFlyProjectionStatusButton->setText( tr( "Unknown CRS" ) ); mOnTheFlyProjectionStatusButton->setToolTip( - tr( "Current CRS: %1" ).arg( projectCrs.userFriendlyIdentifier() ) ); + tr( "Current CRS: %1" ).arg( projectCrs.userFriendlyIdentifier() ) + ); mOnTheFlyProjectionStatusButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mIconProjectionEnabled.svg" ) ) ); } else @@ -14657,8 +14252,7 @@ void QgisApp::markDirty() void QgisApp::extentChanged() { // allow symbols in the legend update their preview if they use map units - mLayerTreeView->layerTreeModel()->setLegendMapViewData( mMapCanvas->mapUnitsPerPixel(), - static_cast< int >( std::round( mMapCanvas->mapSettings().outputDpi() ) ), mMapCanvas->scale() ); + mLayerTreeView->layerTreeModel()->setLegendMapViewData( mMapCanvas->mapUnitsPerPixel(), static_cast( std::round( mMapCanvas->mapSettings().outputDpi() ) ), mMapCanvas->scale() ); } void QgisApp::layersWereAdded( const QList &layers ) @@ -14754,7 +14348,6 @@ void QgisApp::selectionModeChanged( QgsMapToolSelect::Mode mode ) case QgsMapToolSelect::GeometryWithinIntersectWithSelection: mStatusBar->showMessage( tr( "Intersect features completely within with the current selection" ) ); break; - } } @@ -14833,9 +14426,9 @@ void QgisApp::projectPropertiesProjections() void QgisApp::projectProperties( const QString ¤tPage ) { - QList< QgsOptionsWidgetFactory * > factories; + QList factories; const auto constProjectPropertiesWidgetFactories = mProjectPropertiesWidgetFactories; - for ( const QPointer< QgsOptionsWidgetFactory > &f : constProjectPropertiesWidgetFactories ) + for ( const QPointer &f : constProjectPropertiesWidgetFactories ) { if ( f ) factories << f; @@ -14846,8 +14439,7 @@ void QgisApp::projectProperties( const QString ¤tPage ) // Be told if the mouse display precision may have changed by the user // changing things in the project properties dialog box - connect( &pp, &QgsProjectProperties::displayPrecisionChanged, this, - &QgisApp::updateMouseCoordinatePrecision ); + connect( &pp, &QgsProjectProperties::displayPrecisionChanged, this, &QgisApp::updateMouseCoordinatePrecision ); if ( !currentPage.isEmpty() ) { @@ -14856,10 +14448,10 @@ void QgisApp::projectProperties( const QString ¤tPage ) // Display the modal dialog box. pp.exec(); - mMapTools->mapTool< QgsMeasureTool >( QgsAppMapTools::MeasureDistance )->updateSettings(); - mMapTools->mapTool< QgsMeasureTool >( QgsAppMapTools::MeasureArea )->updateSettings(); - mMapTools->mapTool< QgsMapToolMeasureAngle >( QgsAppMapTools::MeasureAngle )->updateSettings(); - mMapTools->mapTool< QgsMapToolMeasureBearing >( QgsAppMapTools::MeasureBearing )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureDistance )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureArea )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureAngle )->updateSettings(); + mMapTools->mapTool( QgsAppMapTools::MeasureBearing )->updateSettings(); // Set the window title. setTitleBarText_( *this ); @@ -14912,7 +14504,7 @@ void QgisApp::selectionChanged( const QgsFeatureIds &, const QgsFeatureIds &, bo case Qgis::LayerType::VectorTile: { - QgsVectorTileLayer *vtLayer = qobject_cast< QgsVectorTileLayer * >( layer ); + QgsVectorTileLayer *vtLayer = qobject_cast( layer ); const int selectedCount = vtLayer->selectedFeatureCount(); showStatusMessage( tr( "%n feature(s) selected on layer %1.", "number of selected features", selectedCount ).arg( layer->name() ) ); break; @@ -14925,7 +14517,7 @@ void QgisApp::selectionChanged( const QgsFeatureIds &, const QgsFeatureIds &, bo case Qgis::LayerType::PointCloud: case Qgis::LayerType::Group: case Qgis::LayerType::TiledScene: - break; // not supported + break; // not supported } } @@ -15203,10 +14795,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionCopyFeatures->setEnabled( false ); mActionPasteFeatures->setEnabled( false ); mActionCopyStyle->setEnabled( false ); - mActionPasteStyle->setEnabled( mLayerTreeView && - mLayerTreeView->currentNode() && - QgsLayerTree::isGroup( mLayerTreeView->currentNode() ) && - clipboard()->hasFormat( QStringLiteral( QGSCLIPBOARD_STYLE_MIME ) ) ); + mActionPasteStyle->setEnabled( mLayerTreeView && mLayerTreeView->currentNode() && QgsLayerTree::isGroup( mLayerTreeView->currentNode() ) && clipboard()->hasFormat( QStringLiteral( QGSCLIPBOARD_STYLE_MIME ) ) ); mActionCopyLayer->setEnabled( false ); // pasting should be allowed if there is a layer in the clipboard mActionPasteLayer->setEnabled( clipboard()->hasFormat( QStringLiteral( QGSCLIPBOARD_MAPLAYER_MIME ) ) ); @@ -15701,7 +15290,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) case Qgis::LayerType::VectorTile: { - QgsVectorTileLayer *vtLayer = qobject_cast< QgsVectorTileLayer * >( layer ); + QgsVectorTileLayer *vtLayer = qobject_cast( layer ); const bool layerHasSelection = vtLayer->selectedFeatureCount() > 0; mActionLocalHistogramStretch->setEnabled( false ); mActionFullHistogramStretch->setEnabled( false ); @@ -16002,7 +15591,7 @@ void QgisApp::refreshActionFeatureAction() void QgisApp::renameView() { - QgsMapCanvasDockWidget *view = qobject_cast< QgsMapCanvasDockWidget * >( sender() ); + QgsMapCanvasDockWidget *view = qobject_cast( sender() ); if ( !view ) return; @@ -16025,8 +15614,7 @@ void QgisApp::renameView() renameDlg.setOverwriteEnabled( false ); renameDlg.setConflictingNameWarning( tr( "A view with this name already exists" ) ); renameDlg.buttonBox()->addButton( QDialogButtonBox::Help ); - connect( renameDlg.buttonBox(), &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( renameDlg.buttonBox(), &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "map_views/map_view.html" ) ); } ); @@ -16053,9 +15641,7 @@ void QgisApp::keyReleaseEvent( QKeyEvent *event ) if ( event->key() == Qt::Key_Close ) { // do something useful here - int ret = QMessageBox::question( this, tr( "Exit QGIS" ), - tr( "Do you really want to quit QGIS?" ), - QMessageBox::Yes | QMessageBox::No ); + int ret = QMessageBox::question( this, tr( "Exit QGIS" ), tr( "Do you really want to quit QGIS?" ), QMessageBox::Yes | QMessageBox::No ); switch ( ret ) { case QMessageBox::Yes: @@ -16066,7 +15652,7 @@ void QgisApp::keyReleaseEvent( QKeyEvent *event ) break; } event->setAccepted( sAccepted ); // don't close my Top Level Widget ! - sAccepted = false;// close the app next time when the user press back button + sAccepted = false; // close the app next time when the user press back button } else { @@ -16079,7 +15665,7 @@ void QgisApp::keyPressEvent( QKeyEvent *e ) { emit keyPressed( e ); -#if 0 && defined(QGISDEBUG) +#if 0 && defined( QGISDEBUG ) if ( e->key() == Qt::Key_Backslash && e->modifiers() == Qt::ControlModifier ) { QgsCrashHandler::handle( 0 ); @@ -16133,7 +15719,8 @@ void QgisApp::onTaskCompleteShowNotify( long taskId, int status ) if ( task && !( ( task->flags() & QgsTask::Hidden ) - || ( task->flags() & QgsTask::Silent ) ) + || ( task->flags() & QgsTask::Silent ) + ) && task->elapsedTime() >= minTime ) { if ( status == QgsTask::Complete ) @@ -16163,9 +15750,7 @@ void QgisApp::createPreviewImage( const QString &path, const QIcon &icon ) // Render the map canvas const double devicePixelRatio = mMapCanvas->mapSettings().devicePixelRatio(); QSize previewSize( 250, 177 ); // h = w / std::sqrt(2) - QRect previewRect( QPoint( ( mMapCanvas->width() - previewSize.width() ) / 2 - , ( mMapCanvas->height() - previewSize.height() ) / 2 ) - , previewSize ); + QRect previewRect( QPoint( ( mMapCanvas->width() - previewSize.width() ) / 2, ( mMapCanvas->height() - previewSize.height() ) / 2 ), previewSize ); QPixmap previewImage( previewSize * devicePixelRatio ); previewImage.setDevicePixelRatio( devicePixelRatio ); @@ -16249,7 +15834,7 @@ void QgisApp::zoomToBookmarkIndex( const QModelIndex &index ) QgsMapToolIdentifyAction *QgisApp::identifyMapTool() const { - return mMapTools->mapTool< QgsMapToolIdentifyAction >( QgsAppMapTools::Identify ); + return mMapTools->mapTool( QgsAppMapTools::Identify ); } QgsMapLayerActionContext QgisApp::createMapLayerActionContext() @@ -16283,7 +15868,8 @@ void QgisApp::projectVersionMismatchOccurred( const QString &projectVersion ) { QString smalltext = tr( "This project file was saved by QGIS version %1." " When saving this project file, QGIS will update it to version %2, " - "possibly rendering it unusable with older versions of QGIS." ).arg( projectVersion, Qgis::version() ); + "possibly rendering it unusable with older versions of QGIS." ) + .arg( projectVersion, Qgis::version() ); QString title = tr( "Project file is older" ); @@ -16300,7 +15886,7 @@ void QgisApp::updateUndoActions() { bool canUndo = false, canRedo = false; QgsMapLayer *layer = activeLayer(); - if ( layer && layer->isEditable() ) + if ( layer && layer->isEditable() ) { canUndo = layer->undoStack()->canUndo(); canRedo = layer->undoStack()->canRedo(); @@ -16372,8 +15958,7 @@ void QgisApp::read3DMapViewSettings( Qgs3DMapCanvasWidget *widget, QDomElement & map->setTransformContext( QgsProject::instance()->transformContext() ); map->setPathResolver( QgsProject::instance()->pathResolver() ); map->setMapThemeCollection( QgsProject::instance()->mapThemeCollection() ); - connect( QgsProject::instance(), &QgsProject::transformContextChanged, map, [map] - { + connect( QgsProject::instance(), &QgsProject::transformContextChanged, map, [map] { map->setTransformContext( QgsProject::instance()->transformContext() ); } ); @@ -16419,22 +16004,20 @@ void QgisApp::writeProject( QDomDocument &doc ) QgsLayerTree *clonedRoot = QgsProject::instance()->layerTreeRoot()->clone(); QgsLayerTreeUtils::replaceChildrenOfEmbeddedGroups( QgsLayerTree::toGroup( clonedRoot ) ); QgsLayerTreeUtils::updateEmbeddedGroupsProjectPath( QgsLayerTree::toGroup( clonedRoot ), QgsProject::instance() ); // convert absolute paths to relative paths if required - QDomElement oldLegendElem = QgsLayerTreeUtils::writeOldLegend( doc, QgsLayerTree::toGroup( clonedRoot ), - clonedRoot->hasCustomLayerOrder(), clonedRoot->customLayerOrder() ); + QDomElement oldLegendElem = QgsLayerTreeUtils::writeOldLegend( doc, QgsLayerTree::toGroup( clonedRoot ), clonedRoot->hasCustomLayerOrder(), clonedRoot->customLayerOrder() ); delete clonedRoot; QDomElement qgisNode = doc.firstChildElement( QStringLiteral( "qgis" ) ); qgisNode.appendChild( oldLegendElem ); - QgsProject::instance()->writeEntry( QStringLiteral( "Legend" ), QStringLiteral( "filterByMap" ), static_cast< bool >( layerTreeView()->layerTreeModel()->legendFilterMapSettings() ) ); + QgsProject::instance()->writeEntry( QStringLiteral( "Legend" ), QStringLiteral( "filterByMap" ), static_cast( layerTreeView()->layerTreeModel()->legendFilterMapSettings() ) ); if ( QgsProject::instance()->flags() & Qgis::ProjectFlag::RememberAttributeTableWindowsBetweenSessions ) { // save attribute tables QDomElement attributeTablesElement = doc.createElement( QStringLiteral( "attributeTables" ) ); - QSet< QgsAttributeTableDialog * > storedDialogs; - auto saveDialog = [&storedDialogs, &attributeTablesElement, &doc]( QgsAttributeTableDialog * attributeTableDialog ) - { + QSet storedDialogs; + auto saveDialog = [&storedDialogs, &attributeTablesElement, &doc]( QgsAttributeTableDialog *attributeTableDialog ) { if ( storedDialogs.contains( attributeTableDialog ) ) return; @@ -16444,10 +16027,10 @@ void QgisApp::writeProject( QDomDocument &doc ) storedDialogs.insert( attributeTableDialog ); }; - const QList topLevelWidgets = QgsApplication::topLevelWidgets(); + const QList topLevelWidgets = QgsApplication::topLevelWidgets(); for ( QWidget *widget : topLevelWidgets ) { - QList< QgsAttributeTableDialog * > dialogChildren = widget->findChildren< QgsAttributeTableDialog * >(); + QList dialogChildren = widget->findChildren(); for ( QgsAttributeTableDialog *attributeTableDialog : dialogChildren ) { saveDialog( attributeTableDialog ); @@ -16537,7 +16120,7 @@ void QgisApp::readProject( const QDomDocument &doc ) mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( true ); QDomNodeList nodes = doc.elementsByTagName( QStringLiteral( "mapViewDocks" ) ); - QList< QgsMapCanvas * > views; + QList views; if ( !nodes.isEmpty() ) { QDomNode viewNode = nodes.at( 0 ); @@ -16594,7 +16177,7 @@ void QgisApp::readProject( const QDomDocument &doc ) { const QDomElement attributeTableElement = attributeTableNodes.at( i ).toElement(); const QString layerId = attributeTableElement.attribute( QStringLiteral( "layer" ) ); - if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( QgsProject::instance()->mapLayer( layerId ) ) ) + if ( QgsVectorLayer *layer = qobject_cast( QgsProject::instance()->mapLayer( layerId ) ) ) { if ( layer->isValid() ) { @@ -16664,12 +16247,10 @@ void QgisApp::showLayerProperties( QgsMapLayer *mapLayer, const QString &page ) rasterLayerPropertiesDialog->show(); // Delete (later, for safety) since dialog cannot be reused without // updating code - connect( rasterLayerPropertiesDialog, &QgsRasterLayerProperties::accepted, [ rasterLayerPropertiesDialog ] - { + connect( rasterLayerPropertiesDialog, &QgsRasterLayerProperties::accepted, [rasterLayerPropertiesDialog] { rasterLayerPropertiesDialog->deleteLater(); } ); - connect( rasterLayerPropertiesDialog, &QgsRasterLayerProperties::rejected, [ rasterLayerPropertiesDialog ] - { + connect( rasterLayerPropertiesDialog, &QgsRasterLayerProperties::rejected, [rasterLayerPropertiesDialog] { rasterLayerPropertiesDialog->deleteLater(); } ); @@ -16708,10 +16289,9 @@ void QgisApp::showLayerProperties( QgsMapLayer *mapLayer, const QString &page ) QgsVectorLayerProperties *vectorLayerPropertiesDialog = new QgsVectorLayerProperties( mMapCanvas, visibleMessageBar(), vlayer, this ); connect( vectorLayerPropertiesDialog, static_cast( &QgsVectorLayerProperties::toggleEditing ), - this, [ = ]( QgsMapLayer * layer ) { toggleEditing( layer ); } + this, [=]( QgsMapLayer *layer ) { toggleEditing( layer ); } ); - connect( vectorLayerPropertiesDialog, &QgsVectorLayerProperties::exportAuxiliaryLayer, this, [ = ]( QgsAuxiliaryLayer * layer ) - { + connect( vectorLayerPropertiesDialog, &QgsVectorLayerProperties::exportAuxiliaryLayer, this, [=]( QgsAuxiliaryLayer *layer ) { if ( layer ) { std::unique_ptr clone; @@ -16820,9 +16400,7 @@ void QgisApp::showLayerProperties( QgsMapLayer *mapLayer, const QString &page ) if ( !plt->showLayerProperties( pl ) ) { - visibleMessageBar()->pushMessage( tr( "Warning" ), - tr( "This layer doesn't have a properties dialog." ), - Qgis::MessageLevel::Info ); + visibleMessageBar()->pushMessage( tr( "Warning" ), tr( "This layer doesn't have a properties dialog." ), Qgis::MessageLevel::Info ); } break; } @@ -16860,11 +16438,9 @@ void QgisApp::namSetup() { QgsNetworkAccessManager *nam = QgsNetworkAccessManager::instance(); - connect( nam, &QNetworkAccessManager::proxyAuthenticationRequired, - this, &QgisApp::namProxyAuthenticationRequired ); + connect( nam, &QNetworkAccessManager::proxyAuthenticationRequired, this, &QgisApp::namProxyAuthenticationRequired ); - connect( nam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestTimedOut ), - this, &QgisApp::namRequestTimedOut ); + connect( nam, qOverload( &QgsNetworkAccessManager::requestTimedOut ), this, &QgisApp::namRequestTimedOut ); nam->setAuthHandler( std::make_unique() ); #ifndef QT_NO_SSL @@ -16875,8 +16451,7 @@ void QgisApp::namSetup() void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth ) { QgsSettings settings; - if ( !settings.value( QStringLiteral( "proxy/proxyEnabled" ), false ).toBool() || - settings.value( QStringLiteral( "proxy/proxyType" ), "" ).toString() == QLatin1String( "DefaultProxy" ) ) + if ( !settings.value( QStringLiteral( "proxy/proxyEnabled" ), false ).toBool() || settings.value( QStringLiteral( "proxy/proxyType" ), "" ).toString() == QLatin1String( "DefaultProxy" ) ) { auth->setUser( QString() ); return; @@ -16888,9 +16463,10 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe for ( ;; ) { bool ok = QgsCredentials::instance()->get( - QStringLiteral( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ), - username, password, - tr( "Proxy authentication required" ) ); + QStringLiteral( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ), + username, password, + tr( "Proxy authentication required" ) + ); if ( !ok ) return; @@ -16907,7 +16483,8 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe // credentials didn't change - stored ones probably wrong? clear password and retry QgsCredentials::instance()->put( QStringLiteral( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ), - username, QString() ); + username, QString() + ); } } @@ -16917,8 +16494,7 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe void QgisApp::namRequestTimedOut( const QgsNetworkRequestParameters &request ) { - QLabel *msgLabel = new QLabel( tr( "Network request to %1 timed out, any data received is likely incomplete." ).arg( request.request().url().host() ) + - tr( " Please check the message log for further info." ), messageBar() ); + QLabel *msgLabel = new QLabel( tr( "Network request to %1 timed out, any data received is likely incomplete." ).arg( request.request().url().host() ) + tr( " Please check the message log for further info." ), messageBar() ); msgLabel->setWordWrap( true ); connect( msgLabel, &QLabel::linkActivated, mLogDock, &QWidget::show ); messageBar()->pushItem( new QgsMessageBarItem( msgLabel, Qgis::MessageLevel::Warning, QgsMessageBar::defaultMessageTimeout() ) ); @@ -16931,12 +16507,9 @@ void QgisApp::namUpdate() void QgisApp::masterPasswordSetup() { - connect( QgsApplication::authManager(), &QgsAuthManager::messageLog, - this, &QgisApp::authMessageLog ); - connect( QgsApplication::authManager(), &QgsAuthManager::passwordHelperMessageLog, - this, &QgisApp::authMessageLog ); - connect( QgsApplication::authManager(), &QgsAuthManager::authDatabaseEraseRequested, - this, &QgisApp::eraseAuthenticationDatabase ); + connect( QgsApplication::authManager(), &QgsAuthManager::messageLog, this, &QgisApp::authMessageLog ); + connect( QgsApplication::authManager(), &QgsAuthManager::passwordHelperMessageLog, this, &QgisApp::authMessageLog ); + connect( QgsApplication::authManager(), &QgsAuthManager::authDatabaseEraseRequested, this, &QgisApp::eraseAuthenticationDatabase ); } void QgisApp::eraseAuthenticationDatabase() @@ -17073,15 +16646,15 @@ void QgisApp::toolButtonActionTriggered( QAction *action ) QMenu *QgisApp::createPopupMenu() { QMenu *menu = QMainWindow::createPopupMenu(); - QList< QAction * > al = menu->actions(); - QList< QAction * > panels, toolbars; + QList al = menu->actions(); + QList panels, toolbars; if ( !al.isEmpty() ) { bool found = false; for ( int i = 0; i < al.size(); ++i ) { - if ( al[ i ]->isSeparator() ) + if ( al[i]->isSeparator() ) { found = true; continue; @@ -17089,11 +16662,11 @@ QMenu *QgisApp::createPopupMenu() if ( !found ) { - panels.append( al[ i ] ); + panels.append( al[i] ); } else { - toolbars.append( al[ i ] ); + toolbars.append( al[i] ); } } @@ -17283,8 +16856,7 @@ QgsFeature QgisApp::duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFea QString msg = tr( "Digitize the duplicate on layer %1" ).arg( layer->name() ); visibleMessageBar()->pushMessage( msg, Qgis::MessageLevel::Info ); - connect( digitizeFeature, static_cast( &QgsMapToolDigitizeFeature::digitizingCompleted ), this, [this, layer, feature, digitizeFeature]( const QgsFeature & digitizedFeature ) - { + connect( digitizeFeature, static_cast( &QgsMapToolDigitizeFeature::digitizingCompleted ), this, [this, layer, feature, digitizeFeature]( const QgsFeature &digitizedFeature ) { QString msg = tr( "Duplicate digitized" ); visibleMessageBar()->pushMessage( msg, Qgis::MessageLevel::Info ); @@ -17304,14 +16876,11 @@ QgsFeature QgisApp::duplicateFeatureDigitized( QgsMapLayer *mlayer, const QgsFea visibleMessageBar()->pushMessage( tr( "Feature on layer %1 duplicated\n%2" ).arg( layer->name(), childrenInfo ), Qgis::MessageLevel::Success ); mMapCanvas->unsetMapTool( digitizeFeature ); - } - ); + } ); - connect( digitizeFeature, static_cast( &QgsMapToolDigitizeFeature::digitizingFinished ), this, [digitizeFeature]() - { + connect( digitizeFeature, static_cast( &QgsMapToolDigitizeFeature::digitizingFinished ), this, [digitizeFeature]() { digitizeFeature->deleteLater(); - } - ); + } ); return QgsFeature(); } @@ -17323,11 +16892,9 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) if ( saving ) { QAction *action = menu->addAction( tr( "Templates" ) + QChar( 0x2026 ) ); // 0x2026 = ellipsis character - connect( action, &QAction::triggered, this, [ this ] - { + connect( action, &QAction::triggered, this, [this] { QgsSettings settings; - QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), - QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); + QString templateDirName = settings.value( QStringLiteral( "qgis/projectTemplateDir" ), QString( QgsApplication::qgisSettingsDirPath() + "project_templates" ) ).toString(); const QString originalFilename = QgsProject::instance()->fileName(); QString templateName = QFileInfo( originalFilename ).baseName(); @@ -17335,9 +16902,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) if ( templateName.isEmpty() ) { bool ok; - templateName = QInputDialog::getText( this, tr( "Template Name" ), - tr( "Name for the template" ), QLineEdit::Normal, - QString(), &ok ); + templateName = QInputDialog::getText( this, tr( "Template Name" ), tr( "Name for the template" ), QLineEdit::Normal, QString(), &ok ); if ( !ok ) return; @@ -17365,7 +16930,6 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) QgsProject::instance()->write( filePath ); QgsProject::instance()->setFileName( originalFilename ); messageBar()->pushInfo( tr( "Template saved" ), tr( "Template %1 was saved" ).arg( templateName ) ); - } ); } @@ -17378,8 +16942,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) QAction *action = menu->addAction( name + QChar( 0x2026 ) ); // 0x2026 = ellipsis character if ( saving ) { - connect( action, &QAction::triggered, this, [this, storageGuiProvider] - { + connect( action, &QAction::triggered, this, [this, storageGuiProvider] { QString uri = storageGuiProvider->showSaveGui(); if ( !uri.isEmpty() ) { @@ -17389,8 +16952,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) } else { - connect( action, &QAction::triggered, this, [this, storageGuiProvider] - { + connect( action, &QAction::triggered, this, [this, storageGuiProvider] { QString uri = storageGuiProvider->showLoadGui(); if ( !uri.isEmpty() ) { @@ -17412,8 +16974,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) QAction *action = menu->addAction( name + QChar( 0x2026 ) ); // 0x2026 = ellipsis character if ( saving ) { - connect( action, &QAction::triggered, this, [this, storage] - { + connect( action, &QAction::triggered, this, [this, storage] { Q_NOWARN_DEPRECATED_PUSH QString uri = storage->showSaveGui(); Q_NOWARN_DEPRECATED_POP @@ -17423,8 +16984,7 @@ void QgisApp::populateProjectStorageMenu( QMenu *menu, const bool saving ) } else { - connect( action, &QAction::triggered, this, [this, storage] - { + connect( action, &QAction::triggered, this, [this, storage] { Q_NOWARN_DEPRECATED_PUSH QString uri = storage->showLoadGui(); Q_NOWARN_DEPRECATED_POP @@ -17477,8 +17037,8 @@ void QgisApp::triggerCrashHandler() void QgisApp::addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockWidget, const QStringList &tabifyWith, bool raiseTab ) { - QList< QDockWidget * > dockWidgetsInArea; - const auto dockWidgets = findChildren< QDockWidget * >(); + QList dockWidgetsInArea; + const auto dockWidgets = findChildren(); for ( QDockWidget *w : dockWidgets ) { if ( w->isVisible() && dockWidgetArea( w ) == area ) @@ -17487,7 +17047,7 @@ void QgisApp::addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockW } } - addDockWidget( area, dockWidget ); // First add the dock widget, then attempt to tabify + addDockWidget( area, dockWidget ); // First add the dock widget, then attempt to tabify if ( dockWidgetsInArea.length() > 0 ) { // Get the base dock widget that we'll use to tabify our new dockWidget @@ -17504,7 +17064,7 @@ void QgisApp::addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockW if ( cw->objectName() == tabifyWith.at( i ) || cw->property( "dock_uuid" ).toString() == tabifyWith.at( i ) ) { tabifyWithDockWidget = cw; - objectNameFound = true; // Also exit the outer for loop + objectNameFound = true; // Also exit the outer for loop break; } } @@ -17516,7 +17076,7 @@ void QgisApp::addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockW } if ( !tabifyWithDockWidget ) { - tabifyWithDockWidget = dockWidgetsInArea.at( 0 ); // Last resort + tabifyWithDockWidget = dockWidgetsInArea.at( 0 ); // Last resort } if ( tabifyWithDockWidget == dockWidget ) return; @@ -17560,7 +17120,7 @@ void QgisApp::addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockW } else { - tabifyWithDockWidget->raise(); // Single base dock widget, we can just raise it + tabifyWithDockWidget->raise(); // Single base dock widget, we can just raise it } } } @@ -17582,10 +17142,9 @@ void QgisApp::showEvent( QShowEvent *event ) // because of Qt regression: https://bugreports.qt.io/browse/QTBUG-89034 // we have to wait till dialog is first shown to try to restore dock geometry or it's not correctly restored static std::once_flag firstShow; - std::call_once( firstShow, [this] - { + std::call_once( firstShow, [this] { QgsSettings settings; - if ( !restoreState( settings.value( QStringLiteral( "UI/state" ), QByteArray::fromRawData( reinterpret_cast< const char * >( defaultUIstate ), sizeof defaultUIstate ) ).toByteArray() ) ) + if ( !restoreState( settings.value( QStringLiteral( "UI/state" ), QByteArray::fromRawData( reinterpret_cast( defaultUIstate ), sizeof defaultUIstate ) ).toByteArray() ) ) { QgsDebugError( QStringLiteral( "restore of UI state failed" ) ); } @@ -17602,7 +17161,7 @@ void QgisApp::handleRenderedLayerStatistics() const for ( const QgsRenderedItemDetails *item : renderedItemResults->renderedItems() ) { - if ( const QgsRenderedLayerStatistics *layerStatistics = dynamic_cast< const QgsRenderedLayerStatistics *>( item ) ) + if ( const QgsRenderedLayerStatistics *layerStatistics = dynamic_cast( item ) ) { QgsRasterLayer *rasterLayer = qobject_cast( QgsProject::instance()->mapLayer( layerStatistics->layerId() ) ); if ( rasterLayer ) diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index e306b5958aa1..06116147f7bf 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -212,10 +212,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow Q_OBJECT public: //! Constructor - QgisApp( QSplashScreen *splash, bool restorePlugins = true, bool skipBadLayers = false, - bool skipVersionCheck = false, const QString &rootProfileLocation = QString(), - const QString &activeProfile = QString(), - QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window ); + QgisApp( QSplashScreen *splash, bool restorePlugins = true, bool skipBadLayers = false, bool skipVersionCheck = false, const QString &rootProfileLocation = QString(), const QString &activeProfile = QString(), QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window ); //! Constructor for unit tests QgisApp(); @@ -265,7 +262,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow /** * Returns a list of all map canvases open in the app. */ - QList< QgsMapCanvas * > mapCanvases(); + QList mapCanvases(); /** * Returns the 2D map canvas dock widget named \a name @@ -437,7 +434,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow * * \since QGIS 3.36 */ - QList< Qgs3DMapCanvas * > mapCanvases3D(); + QList mapCanvases3D(); /** * Create a new 3D map canvas with the specified unique \a name. @@ -536,8 +533,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QAction *actionAddFeature() { return mActionAddFeature; } QAction *actionMoveFeature() { return mActionMoveFeature; } QAction *actionMoveFeatureCopy() { return mActionMoveFeatureCopy; } - QAction *actionRotateFeature() { return mActionRotateFeature;} - QAction *actionScaleFeature() { return mActionScaleFeature;} + QAction *actionRotateFeature() { return mActionRotateFeature; } + QAction *actionScaleFeature() { return mActionScaleFeature; } QAction *actionSplitFeatures() { return mActionSplitFeatures; } QAction *actionSplitParts() { return mActionSplitParts; } QAction *actionAddRing() { return mActionAddRing; } @@ -716,7 +713,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QToolBar *helpToolBar() { return mHelpToolBar; } QToolBar *rasterToolBar() { return mRasterToolBar; } QToolBar *vectorToolBar() { return mVectorToolBar; } - QToolBar *meshToolBar() {return mMeshToolBar;} + QToolBar *meshToolBar() { return mMeshToolBar; } QToolBar *databaseToolBar() { return mDatabaseToolBar; } QToolBar *webToolBar() { return mWebToolBar; } @@ -860,7 +857,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow void unregisterCustomProjectOpenHandler( QgsCustomProjectOpenHandler *handler ); //! Returns a list of registered custom drop handlers. - QVector> customDropHandlers() const; + QVector> customDropHandlers() const; //! Register a new custom layout drop handler. void registerCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ); @@ -869,7 +866,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow void unregisterCustomLayoutDropHandler( QgsLayoutCustomDropHandler *handler ); //! Returns a list of registered custom layout drop handlers. - QVector> customLayoutDropHandlers() const; + QVector> customLayoutDropHandlers() const; //! Returns the active map layer. QgsMapLayer *activeLayer(); @@ -931,9 +928,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow * using the \a url and \a baseName. The \a baseName parameter is used * in the Map Legend so it should be formed in a meaningful way. */ - template< typename L> L *addLayer( const QString &uri, - const QString &baseName, - const QString &provider ); + template L *addLayer( const QString &uri, const QString &baseName, const QString &provider ); /** * Returns the html formatted string with current versions of the libraries and the active plugins @@ -962,14 +957,14 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow * * Returns a list of layers loaded as a result of opening the URIs. */ - QList< QgsMapLayer * > handleDropUriList( const QgsMimeDataUtils::UriList &lst, bool suppressBulkLayerPostProcessing = false, bool addToLegend = true ); + QList handleDropUriList( const QgsMimeDataUtils::UriList &lst, bool suppressBulkLayerPostProcessing = false, bool addToLegend = true ); /** * Convenience function to open either a project or a layer file. * * Returns a list of layers loaded as a result of opening the file. */ - QList< QgsMapLayer * > openFile( const QString &fileName, const QString &fileTypeHint = QString(), bool suppressBulkLayerPostProcessing = false, bool addToLegend = true ); + QList openFile( const QString &fileName, const QString &fileTypeHint = QString(), bool suppressBulkLayerPostProcessing = false, bool addToLegend = true ); void layerTreeViewDoubleClicked( const QModelIndex &index ); //! Make sure the insertion point for new layers is up-to-date with the current item in layer tree view void updateNewLayerInsertionPoint(); @@ -1094,8 +1089,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow * \param destinationLayer The layer that the clipboard will be pasted to (defaults to the active layer on the legend) * \param categories The style categories to copy */ - void pasteStyle( QgsMapLayer *destinationLayer = nullptr, - QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); + void pasteStyle( QgsMapLayer *destinationLayer = nullptr, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); //! copies group or layer on the clipboard void copyLayer(); //! pastes group or layer from the clipboard to layer tree @@ -1211,7 +1205,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow void layerSubsetString( QgsMapLayer *mapLayer ); //! change layer subset of the active layer - void layerSubsetString( ); + void layerSubsetString(); //! Sets scale visibility of selected layers void setLayerScaleVisibility(); @@ -1278,11 +1272,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //! Gets map of option pages QMap optionsPagesMap(); //! Gets map of project property pages - QMap< QString, QString > projectPropertiesPagesMap(); + QMap projectPropertiesPagesMap(); //! Gets map of setting pages - QMap< QString, QString > settingPagesMap(); + QMap settingPagesMap(); - void showProjectProperties( const QString &page = QString() ); + void showProjectProperties( const QString &page = QString() ); void showSettings( const QString &page ); // End Settings pages section @@ -2206,7 +2200,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow void activeLayerChanged( QgsMapLayer *layer ); private: - void createPreviewImage( const QString &path, const QIcon &overlayIcon = QIcon() ); void startProfile( const QString &name ); void endProfile(); @@ -2255,26 +2248,19 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QString saveAsVectorFileGeneral( QgsVectorLayer *vlayer = nullptr, bool symbologyOption = true, bool onlySelected = false, bool defaultToAddToMap = true ); - QString saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOption, bool onlySelected, bool defaultToAddToMap, - const std::function< void ( const QString &newFilename, - bool addToCanvas, - const QString &layerName, - const QString &encoding, - const QString &vectorFileName )> &onSuccess, const std::function< void ( int error, const QString &errorMessage ) > &onFailure, - QgsVectorLayerSaveAsDialog::Options dialogOptions = QgsVectorLayerSaveAsDialog::Option::AllOptions, - const QString &dialogTitle = QString() ); + QString saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOption, bool onlySelected, bool defaultToAddToMap, const std::function &onSuccess, const std::function &onFailure, QgsVectorLayerSaveAsDialog::Options dialogOptions = QgsVectorLayerSaveAsDialog::Option::AllOptions, const QString &dialogTitle = QString() ); QString saveAsPointCloudLayer( QgsPointCloudLayer *pclayer ); //! Sets project properties, including map untis - void projectProperties( const QString ¤tPage = QString() ); + void projectProperties( const QString ¤tPage = QString() ); /** * Paste features from clipboard into a new memory layer. * If no features are in clipboard an empty layer is returned. * Returns a new memory layer or NULLPTR if the operation failed. */ - std::unique_ptr< QgsVectorLayer > pasteToNewMemoryVector(); + std::unique_ptr pasteToNewMemoryVector(); //! Returns all annotation items in the canvas QList annotationItems(); @@ -2351,8 +2337,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow * The \a isFloating and \a dockGeometry arguments can be used to specify an initial floating state * and widget geometry rect for the dock. */ - void setupDockWidget( QDockWidget *dockWidget, bool isFloating = false, QRect dockGeometry = QRect(), - Qt::DockWidgetArea area = Qt::RightDockWidgetArea ); + void setupDockWidget( QDockWidget *dockWidget, bool isFloating = false, QRect dockGeometry = QRect(), Qt::DockWidgetArea area = Qt::RightDockWidgetArea ); #ifdef HAVE_3D @@ -2428,7 +2413,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow /** * Returns a list of all capture map tools. */ - QList< QgsMapToolCapture * > captureTools(); + QList captureTools(); void renderDecorationItems( QPainter *p ) const; @@ -2479,9 +2464,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow #endif QgsMapToolsDigitizingTechniqueManager *mDigitizingTechniqueManager = nullptr; - std::unique_ptr< QgsAppMapTools > mMapTools; + std::unique_ptr mMapTools; - QPointer< QgsMapTool > mNonEditMapTool; + QPointer mNonEditMapTool; QgsTaskManagerStatusBarWidget *mTaskManagerWidget = nullptr; @@ -2678,10 +2663,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QList> mOptionsWidgetFactories; QList> mProjectPropertiesWidgetFactories; - QList mDevToolFactories; + QList mDevToolFactories; - QList mApplicationExitBlockers; - QList mMapToolHandlers; + QList mApplicationExitBlockers; + QList mMapToolHandlers; QVector> mCustomDropHandlers; QVector> mCustomProjectOpenHandlers; @@ -2696,7 +2681,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QStackedWidget *mCentralContainer = nullptr; - QHash< QgsPrintLayout *, QgsMapLayerAction * > mAtlasFeatureActions; + QHash mAtlasFeatureActions; std::unique_ptr mDuplicateFeatureAction; @@ -2736,9 +2721,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow std::unique_ptr mGeometryValidationService; QgsGeometryValidationModel *mGeometryValidationModel = nullptr; QgsGeometryValidationDock *mGeometryValidationDock = nullptr; - QPointer< QgsHandleBadLayersHandler > mAppBadLayersHandler; + QPointer mAppBadLayersHandler; - std::unique_ptr< QgsBearingNumericFormat > mBearingNumericFormat; + std::unique_ptr mBearingNumericFormat; QgsNetworkLogger *mNetworkLogger = nullptr; QgsScopedDevToolWidgetFactory mNetworkLoggerWidgetFactory; @@ -2747,9 +2732,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QgsScopedDevToolWidgetFactory mQueryLoggerWidgetFactory; QgsScopedDevToolWidgetFactory mDocumentationWidgetFactory; - std::vector< QgsScopedOptionsWidgetFactory > mOptionWidgetFactories; + std::vector mOptionWidgetFactories; - QMap< QString, QToolButton * > mAnnotationItemGroupToolButtons; + QMap mAnnotationItemGroupToolButtons; QAction *mAnnotationsItemInsertBefore = nullptr; // Used to insert annotation items at the appropriate location in the annotations toolbar QgsAppCanvasFiltering *mAppCanvasFiltering = nullptr; diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index ca870fc2040e..5c9fcf46c605 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -53,23 +53,17 @@ QgisAppInterface::QgisAppInterface( QgisApp *_qgis ) , pluginManagerIface( _qgis->pluginManager() ) { // connect signals - connect( qgis, &QgisApp::activeLayerChanged, - this, &QgisInterface::currentLayerChanged ); - connect( qgis, &QgisApp::currentThemeChanged, - this, &QgisAppInterface::currentThemeChanged ); + connect( qgis, &QgisApp::activeLayerChanged, this, &QgisInterface::currentLayerChanged ); + connect( qgis, &QgisApp::currentThemeChanged, this, &QgisAppInterface::currentThemeChanged ); connect( qgis, &QgisApp::layoutDesignerOpened, this, &QgisAppInterface::layoutDesignerOpened ); connect( qgis, &QgisApp::layoutDesignerWillBeClosed, this, &QgisAppInterface::layoutDesignerWillBeClosed ); connect( qgis, &QgisApp::layoutDesignerClosed, this, &QgisAppInterface::layoutDesignerClosed ); - connect( qgis, &QgisApp::initializationCompleted, - this, &QgisInterface::initializationCompleted ); - connect( qgis, &QgisApp::newProject, - this, &QgisInterface::newProjectCreated ); - connect( qgis, &QgisApp::projectRead, - this, &QgisInterface::projectRead ); - connect( qgis, &QgisApp::layerSavedAs, - this, &QgisInterface::layerSavedAs ); + connect( qgis, &QgisApp::initializationCompleted, this, &QgisInterface::initializationCompleted ); + connect( qgis, &QgisApp::newProject, this, &QgisInterface::newProjectCreated ); + connect( qgis, &QgisApp::projectRead, this, &QgisInterface::projectRead ); + connect( qgis, &QgisApp::layerSavedAs, this, &QgisInterface::layerSavedAs ); } QgsPluginManagerInterface *QgisAppInterface::pluginManagerInterface() @@ -82,8 +76,7 @@ QgsLayerTreeView *QgisAppInterface::layerTreeView() return qgis->layerTreeView(); } -void QgisAppInterface::addCustomActionForLayerType( QAction *action, - QString menu, Qgis::LayerType type, bool allLayers ) +void QgisAppInterface::addCustomActionForLayerType( QAction *action, QString menu, Qgis::LayerType type, bool allLayers ) { QgsAppLayerTreeViewMenuProvider *menuProvider = dynamic_cast( qgis->layerTreeView()->menuProvider() ); if ( !menuProvider ) @@ -189,7 +182,7 @@ bool QgisAppInterface::newProject( bool promptToSaveFlag ) void QgisAppInterface::reloadConnections() { - qgis->reloadConnections( ); + qgis->reloadConnections(); } QgsMapLayer *QgisAppInterface::activeLayer() @@ -392,7 +385,7 @@ void QgisAppInterface::closeMapCanvas( const QString &name ) qgis->closeMapCanvas( name ); } -QList< Qgs3DMapCanvas * > QgisAppInterface::mapCanvases3D() +QList QgisAppInterface::mapCanvases3D() { return qgis->mapCanvases3D(); } @@ -500,15 +493,12 @@ QMap QgisAppInterface::defaultStyleSheetOptions() void QgisAppInterface::buildStyleSheet( const QMap &opts ) { // remove unwanted fontPointSize / fontFamily keys, which may be present from older code - QMap< QString, QVariant> newOpts = opts; - if ( newOpts.contains( QStringLiteral( "fontPointSize" ) ) && ( - newOpts.value( QStringLiteral( "fontPointSize" ) ).toDouble() == qgis->styleSheetBuilder()->defaultFont().pointSizeF() - || newOpts.value( QStringLiteral( "fontPointSize" ) ).toString() == QString::number( qgis->styleSheetBuilder()->defaultFont().pointSizeF() ) ) ) + QMap newOpts = opts; + if ( newOpts.contains( QStringLiteral( "fontPointSize" ) ) && ( newOpts.value( QStringLiteral( "fontPointSize" ) ).toDouble() == qgis->styleSheetBuilder()->defaultFont().pointSizeF() || newOpts.value( QStringLiteral( "fontPointSize" ) ).toString() == QString::number( qgis->styleSheetBuilder()->defaultFont().pointSizeF() ) ) ) { newOpts.remove( QStringLiteral( "fontPointSize" ) ); } - if ( newOpts.contains( QStringLiteral( "fontFamily" ) ) && - newOpts.value( QStringLiteral( "fontFamily" ) ).toString() == qgis->styleSheetBuilder()->defaultFont().family() ) + if ( newOpts.contains( QStringLiteral( "fontFamily" ) ) && newOpts.value( QStringLiteral( "fontFamily" ) ).toString() == qgis->styleSheetBuilder()->defaultFont().family() ) { newOpts.remove( QStringLiteral( "fontFamily" ) ); } @@ -519,15 +509,12 @@ void QgisAppInterface::buildStyleSheet( const QMap &opts ) void QgisAppInterface::saveStyleSheetOptions( const QMap &opts ) { // remove unwanted fontPointSize / fontFamily keys, which may be present from older code - QMap< QString, QVariant> newOpts = opts; - if ( newOpts.contains( QStringLiteral( "fontPointSize" ) ) && ( - newOpts.value( QStringLiteral( "fontPointSize" ) ).toDouble() == qgis->styleSheetBuilder()->defaultFont().pointSizeF() - || newOpts.value( QStringLiteral( "fontPointSize" ) ).toString() == QString::number( qgis->styleSheetBuilder()->defaultFont().pointSizeF() ) ) ) + QMap newOpts = opts; + if ( newOpts.contains( QStringLiteral( "fontPointSize" ) ) && ( newOpts.value( QStringLiteral( "fontPointSize" ) ).toDouble() == qgis->styleSheetBuilder()->defaultFont().pointSizeF() || newOpts.value( QStringLiteral( "fontPointSize" ) ).toString() == QString::number( qgis->styleSheetBuilder()->defaultFont().pointSizeF() ) ) ) { newOpts.remove( QStringLiteral( "fontPointSize" ) ); } - if ( newOpts.contains( QStringLiteral( "fontFamily" ) ) && - newOpts.value( QStringLiteral( "fontFamily" ) ).toString() == qgis->styleSheetBuilder()->defaultFont().family() ) + if ( newOpts.contains( QStringLiteral( "fontFamily" ) ) && newOpts.value( QStringLiteral( "fontFamily" ) ).toString() == qgis->styleSheetBuilder()->defaultFont().family() ) { newOpts.remove( QStringLiteral( "fontFamily" ) ); } @@ -723,7 +710,7 @@ void QgisAppInterface::addProjectExportAction( QAction *action ) if ( QMenu *menu = projectImportExportMenu() ) { // export actions come before import actions in the menu, so find separator in menu - const QList< QAction * > actions = menu->actions(); + const QList actions = menu->actions(); for ( QAction *menuAction : actions ) { if ( menuAction->isSeparator() ) @@ -907,8 +894,7 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b void QgisAppInterface::preloadForm( const QString &uifile ) { - QTimer::singleShot( 0, this, [ = ] - { + QTimer::singleShot( 0, this, [=] { cacheloadForm( uifile ); } ); } @@ -1026,4 +1012,3 @@ void QgisAppInterface::blockActiveLayerChanges( bool blocked ) { qgis->blockActiveLayerChanges( blocked ); } - diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index b67407b5d6d9..b529179e8ebd 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -41,7 +41,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface Q_OBJECT public: - /** * Constructor. * \param qgis Pointer to the QgisApp object @@ -55,8 +54,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface QgsLayerTreeView *layerTreeView() override; - void addCustomActionForLayerType( QAction *action, QString menu, - Qgis::LayerType type, bool allLayers ) override; + void addCustomActionForLayerType( QAction *action, QString menu, Qgis::LayerType type, bool allLayers ) override; void addCustomActionForLayer( QAction *action, QgsMapLayer *layer ) override; bool removeCustomActionForLayerType( QAction *action ) override; @@ -75,7 +73,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface QgsTiledSceneLayer *addTiledSceneLayer( const QString &url, const QString &baseName, const QString &providerKey ) override; bool addProject( const QString &projectName ) override; bool newProject( bool promptToSaveFlag = false ) override; - void reloadConnections( ) override; + void reloadConnections() override; QgsMapLayer *activeLayer() override; bool setActiveLayer( QgsMapLayer *layer ) override; void copySelectionToClipboard( QgsMapLayer *layer ) override; @@ -104,10 +102,10 @@ class APP_EXPORT QgisAppInterface : public QgisInterface void openURL( const QString &url, bool useQgisDocDirectory = true ) override; QgsMapCanvas *mapCanvas() override; - QList< QgsMapCanvas * > mapCanvases() override; + QList mapCanvases() override; QgsMapCanvas *createNewMapCanvas( const QString &name ) override; void closeMapCanvas( const QString &name ) override; - QList< Qgs3DMapCanvas * > mapCanvases3D() override; + QList mapCanvases3D() override; Qgs3DMapCanvas *createNewMapCanvas3D( const QString &name ) override; void closeMapCanvas3D( const QString &name ) override; QSize iconSize( bool dockedToolbar = false ) const override; @@ -171,7 +169,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface QMenu *projectMenu() override; QMenu *projectImportExportMenu() override; void addProjectImportAction( QAction *action ) override; - void removeProjectImportAction( QAction *action )override; + void removeProjectImportAction( QAction *action ) override; void addProjectExportAction( QAction *action ) override; void removeProjectExportAction( QAction *action ) override; QMenu *editMenu() override; @@ -328,7 +326,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface void cacheloadForm( const QString &uifile = QString() ); private: - //! Pointer to the QgisApp object QgisApp *qgis = nullptr; diff --git a/src/app/qgisappstylesheet.cpp b/src/app/qgisappstylesheet.cpp index da5768c095fa..c460c5464535 100644 --- a/src/app/qgisappstylesheet.cpp +++ b/src/app/qgisappstylesheet.cpp @@ -132,7 +132,8 @@ void QgisAppStyleSheet::applyStyleSheet( const QMap &opts ) " color: palette(window-text);" " background-color:palette(window);" " padding-right: 0px;" - "}" ).arg( frameMargin ); + "}" ) + .arg( frameMargin ); style += QStringLiteral( "QTreeView#mOptionsTreeView {" " background-color: rgba(69, 69, 69, 0);" @@ -149,7 +150,8 @@ void QgisAppStyleSheet::applyStyleSheet( const QMap &opts ) " color: palette(window-text);" " background-color:palette(window);" " padding-right: 0px;" - "}" ).arg( frameMargin ); + "}" ) + .arg( frameMargin ); const QString toolbarSpacing = opts.value( QStringLiteral( "toolbarSpacing" ), QString() ).toString(); if ( !toolbarSpacing.isEmpty() ) @@ -170,8 +172,7 @@ void QgisAppStyleSheet::applyStyleSheet( const QMap &opts ) "selection-background-color: %1;" "selection-color: %2;" "}" ) - .arg( palette.highlight().color().name(), - palette.highlightedText().color().name() ); + .arg( palette.highlight().color().name(), palette.highlightedText().color().name() ); } QgsDebugMsgLevel( QStringLiteral( "Stylesheet built: %1" ).arg( ss ), 2 ); @@ -237,7 +238,7 @@ void QgisAppStyleSheet::setActiveValues() QgsDebugMsgLevel( QStringLiteral( "Style name: %1" ).arg( mStyle ), 2 ); mMacStyle = mStyle.contains( QLatin1String( "macintosh" ) ); // macintosh (aqua) - mOxyStyle = mStyle.contains( QLatin1String( "oxygen" ) ); // oxygen + mOxyStyle = mStyle.contains( QLatin1String( "oxygen" ) ); // oxygen mDefaultFont = qApp->font(); // save before it is changed in any way @@ -284,5 +285,4 @@ void QgisAppStyleSheet::setActiveValues() #else mAndroidOS = false; #endif - } diff --git a/src/app/qgisappstylesheet.h b/src/app/qgisappstylesheet.h index ba1951936acc..e39d73380547 100644 --- a/src/app/qgisappstylesheet.h +++ b/src/app/qgisappstylesheet.h @@ -27,7 +27,7 @@ * \class QgisAppStyleSheet * \brief Adjustable stylesheet for the QGIS application */ -class APP_EXPORT QgisAppStyleSheet: public QObject +class APP_EXPORT QgisAppStyleSheet : public QObject { Q_OBJECT @@ -101,7 +101,7 @@ class APP_EXPORT QgisAppStyleSheet: public QObject void setActiveValues(); // qt styles - QString mStyle; // active style name (lowercase) + QString mStyle; // active style name (lowercase) bool mMacStyle = false; // macintosh (aqua) bool mOxyStyle = false; // oxygen diff --git a/src/app/qgsabout.cpp b/src/app/qgsabout.cpp index 8d424af40e4d..4225eeae7608 100644 --- a/src/app/qgsabout.cpp +++ b/src/app/qgsabout.cpp @@ -46,7 +46,7 @@ QgsAbout::QgsAbout( QWidget *parent ) connect( btnQgisUser, &QPushButton::clicked, this, &QgsAbout::btnQgisUser_clicked ); connect( btnQgisHome, &QPushButton::clicked, this, &QgsAbout::btnQgisHome_clicked ); connect( btnCopyToClipboard, &QPushButton::clicked, this, &QgsAbout::btnCopyToClipboard_clicked ); - if constexpr( QSysInfo::WordSize != 64 ) + if constexpr ( QSysInfo::WordSize != 64 ) { // 64 bit is the current standard. Only specify word size if it is not 64. initOptionsBase( true, tr( "%1 - %2 Bit" ).arg( windowTitle() ).arg( QSysInfo::WordSize ) ); @@ -91,7 +91,7 @@ void QgsAbout::init() if ( file.open( QIODevice::ReadOnly ) ) { QTextStream stream( &file ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) // Always use UTF-8 stream.setCodec( "UTF-8" ); #endif @@ -123,7 +123,7 @@ void QgsAbout::init() if ( file2.open( QIODevice::ReadOnly ) ) { QTextStream stream( &file2 ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) // Always use UTF-8 stream.setCodec( "UTF-8" ); #endif @@ -195,7 +195,7 @@ void QgsAbout::init() QString translatorHTML; QTextStream translatorStream( &translatorFile ); // Always use UTF-8 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) translatorStream.setCodec( "UTF-8" ); #endif const QString myStyle = QgsApplication::reportStyleSheet(); diff --git a/src/app/qgsanimationexportdialog.cpp b/src/app/qgsanimationexportdialog.cpp index 40f13329b394..91a6ee448930 100644 --- a/src/app/qgsanimationexportdialog.cpp +++ b/src/app/qgsanimationexportdialog.cpp @@ -29,7 +29,7 @@ #include #include -QgsAnimationExportDialog::QgsAnimationExportDialog( QWidget *parent, QgsMapCanvas *mapCanvas, const QList< QgsMapDecoration * > &decorations ) +QgsAnimationExportDialog::QgsAnimationExportDialog( QWidget *parent, QgsMapCanvas *mapCanvas, const QList &decorations ) : QDialog( parent ) , mMapCanvas( mapCanvas ) { @@ -65,16 +65,13 @@ QgsAnimationExportDialog::QgsAnimationExportDialog( QWidget *parent, QgsMapCanva const QgsSettings settings; - const QString templateText = settings.value( QStringLiteral( "ExportAnimation/fileNameTemplate" ), - QStringLiteral( "%1####.png" ).arg( QgsProject::instance()->baseName() ) - , QgsSettings::App ).toString(); + const QString templateText = settings.value( QStringLiteral( "ExportAnimation/fileNameTemplate" ), QStringLiteral( "%1####.png" ).arg( QgsProject::instance()->baseName() ), QgsSettings::App ).toString(); mTemplateLineEdit->setText( templateText ); const thread_local QRegularExpression rx( QStringLiteral( "^\\w+#+\\.{1}\\w+$" ) ); //e.g. anyprefix#####.png QValidator *validator = new QRegularExpressionValidator( rx, this ); mTemplateLineEdit->setValidator( validator ); - connect( mTemplateLineEdit, &QLineEdit::textChanged, this, [ = ] - { + connect( mTemplateLineEdit, &QLineEdit::textChanged, this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "ExportAnimation/fileNameTemplate" ), mTemplateLineEdit->text() ); } ); @@ -85,8 +82,7 @@ QgsAnimationExportDialog::QgsAnimationExportDialog( QWidget *parent, QgsMapCanva mOutputDirFileWidget->setDefaultRoot( settings.value( QStringLiteral( "ExportAnimation/lastDir" ), QString(), QgsSettings::App ).toString() ); mOutputDirFileWidget->setFilePath( settings.value( QStringLiteral( "ExportAnimation/lastDir" ), QString(), QgsSettings::App ).toString() ); - connect( mOutputDirFileWidget, &QgsFileWidget::fileChanged, this, [ = ] - { + connect( mOutputDirFileWidget, &QgsFileWidget::fileChanged, this, [=] { QgsSettings settings; settings.setValue( QStringLiteral( "ExportAnimation/lastDir" ), mOutputDirFileWidget->filePath(), QgsSettings::App ); } ); @@ -106,32 +102,30 @@ QgsAnimationExportDialog::QgsAnimationExportDialog( QWidget *parent, QgsMapCanva Qgis::TemporalUnit::IrregularStep } ) { - mTimeStepsComboBox->addItem( QgsUnitTypes::toString( u ), static_cast< int >( u ) ); + mTimeStepsComboBox->addItem( QgsUnitTypes::toString( u ), static_cast( u ) ); } - if ( const QgsTemporalNavigationObject *controller = qobject_cast< const QgsTemporalNavigationObject * >( mMapCanvas->temporalController() ) ) + if ( const QgsTemporalNavigationObject *controller = qobject_cast( mMapCanvas->temporalController() ) ) { mStartDateTime->setDateTime( controller->temporalExtents().begin() ); mEndDateTime->setDateTime( controller->temporalExtents().end() ); } mFrameDurationSpinBox->setClearValue( 1 ); mFrameDurationSpinBox->setValue( QgsProject::instance()->timeSettings()->timeStep() ); - mTimeStepsComboBox->setCurrentIndex( mTimeStepsComboBox->findData( static_cast< int >( QgsProject::instance()->timeSettings()->timeStepUnit() ) ) ); + mTimeStepsComboBox->setCurrentIndex( mTimeStepsComboBox->findData( static_cast( QgsProject::instance()->timeSettings()->timeStepUnit() ) ) ); - connect( mOutputWidthSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateOutputWidth( mOutputWidthSpinBox->value() );} ); - connect( mOutputHeightSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateOutputHeight( mOutputHeightSpinBox->value() );} ); + connect( mOutputWidthSpinBox, &QSpinBox::editingFinished, this, [=] { updateOutputWidth( mOutputWidthSpinBox->value() ); } ); + connect( mOutputHeightSpinBox, &QSpinBox::editingFinished, this, [=] { updateOutputHeight( mOutputHeightSpinBox->value() ); } ); connect( mExtentGroupBox, &QgsExtentGroupBox::extentChanged, this, &QgsAnimationExportDialog::updateExtent ); connect( mLockAspectRatio, &QgsRatioLockButton::lockChanged, this, &QgsAnimationExportDialog::lockChanged ); connect( mSetToProjectTimeButton, &QPushButton::clicked, this, &QgsAnimationExportDialog::setToProjectTime ); - connect( buttonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( buttonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "map_views/map_view.html#maptimecontrol" ) ); } ); - connect( buttonBox, &QDialogButtonBox::accepted, this, [ = ] - { + connect( buttonBox, &QDialogButtonBox::accepted, this, [=] { emit startExport(); accept(); } ); @@ -237,7 +231,7 @@ QgsDateTimeRange QgsAnimationExportDialog::animationRange() const QgsInterval QgsAnimationExportDialog::frameInterval() const { - return QgsInterval( mFrameDurationSpinBox->value(), static_cast< Qgis::TemporalUnit>( mTimeStepsComboBox->currentData().toInt() ) ); + return QgsInterval( mFrameDurationSpinBox->value(), static_cast( mTimeStepsComboBox->currentData().toInt() ) ); } void QgsAnimationExportDialog::applyMapSettings( QgsMapSettings &mapSettings ) diff --git a/src/app/qgsanimationexportdialog.h b/src/app/qgsanimationexportdialog.h index 85d5785b3ec0..93361ca3cf07 100644 --- a/src/app/qgsanimationexportdialog.h +++ b/src/app/qgsanimationexportdialog.h @@ -35,18 +35,15 @@ class QgsMapCanvas; * \brief A dialog for specifying map animation export settings. * \since QGIS 3.14 */ -class APP_EXPORT QgsAnimationExportDialog: public QDialog, private Ui::QgsAnimationExportDialogBase +class APP_EXPORT QgsAnimationExportDialog : public QDialog, private Ui::QgsAnimationExportDialogBase { Q_OBJECT public: - /** * Constructor for QgsAnimationExportDialog */ - QgsAnimationExportDialog( QWidget *parent = nullptr, - QgsMapCanvas *mapCanvas = nullptr, - const QList< QgsMapDecoration * > &decorations = QList< QgsMapDecoration * >() ); + QgsAnimationExportDialog( QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr, const QList &decorations = QList() ); //! Returns extent rectangle QgsRectangle extent() const; @@ -55,10 +52,10 @@ class APP_EXPORT QgsAnimationExportDialog: public QDialog, private Ui::QgsAnimat QSize size() const; //! Returns output directory for frames - QString outputDirectory( ) const; + QString outputDirectory() const; //! Returns filename template for frames - QString fileNameExpression( ) const; + QString fileNameExpression() const; //! Returns the overall animation range QgsDateTimeRange animationRange() const; @@ -81,7 +78,6 @@ class APP_EXPORT QgsAnimationExportDialog: public QDialog, private Ui::QgsAnimat void setToProjectTime(); private: - void lockChanged( bool locked ); void updateOutputWidth( int width ); @@ -95,7 +91,6 @@ class APP_EXPORT QgsAnimationExportDialog: public QDialog, private Ui::QgsAnimat QSize mSize; QString mInfoDetails; - }; #endif // QGSANIMATIONEXPORTDIALOG_H diff --git a/src/app/qgsannotationwidget.cpp b/src/app/qgsannotationwidget.cpp index a7016c34a9e7..044959d80c1f 100644 --- a/src/app/qgsannotationwidget.cpp +++ b/src/app/qgsannotationwidget.cpp @@ -91,12 +91,11 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWid connect( mFrameStyleButton, &QgsSymbolButton::changed, this, &QgsAnnotationWidget::changed ); connect( mMapMarkerButton, &QgsSymbolButton::changed, this, &QgsAnnotationWidget::changed ); connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsAnnotationWidget::changed ); - connect( mSpinTopMargin, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); - connect( mSpinLeftMargin, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); - connect( mSpinRightMargin, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); - connect( mSpinBottomMargin, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); + connect( mSpinTopMargin, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); + connect( mSpinLeftMargin, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); + connect( mSpinRightMargin, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); + connect( mSpinBottomMargin, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsAnnotationWidget::changed ); connect( mMapPositionFixedCheckBox, &QCheckBox::stateChanged, this, &QgsAnnotationWidget::changed ); - } QColor QgsAnnotationWidget::backgroundColor() @@ -120,10 +119,7 @@ void QgsAnnotationWidget::apply() annotation->setFillSymbol( mFrameStyleButton->clonedSymbol() ); annotation->setMarkerSymbol( mMapMarkerButton->clonedSymbol() ); annotation->setMapLayer( mLayerComboBox->currentLayer() ); - annotation->setContentsMargin( QgsMargins( mSpinLeftMargin->value(), - mSpinTopMargin->value(), - mSpinRightMargin->value(), - mSpinBottomMargin->value() ) ); + annotation->setContentsMargin( QgsMargins( mSpinLeftMargin->value(), mSpinTopMargin->value(), mSpinRightMargin->value(), mSpinBottomMargin->value() ) ); } mItem->update(); } diff --git a/src/app/qgsannotationwidget.h b/src/app/qgsannotationwidget.h index 7dec60c00f51..b6e3d663fb4d 100644 --- a/src/app/qgsannotationwidget.h +++ b/src/app/qgsannotationwidget.h @@ -32,11 +32,10 @@ class QgsSettingsEntryBool; * * Usually embedded by QgsAnnotation subclass configuration dialogs. */ -class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase +class APP_EXPORT QgsAnnotationWidget : public QWidget, private Ui::QgsAnnotationWidgetBase { Q_OBJECT public: - static const QgsSettingsEntryBool *settingLiveUpdate; QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); @@ -47,7 +46,6 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW void apply(); private: - void frameStyleChanged(); signals: @@ -59,7 +57,6 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW void changed(); private: - QgsMapCanvasAnnotationItem *mItem = nullptr; void blockAllSignals( bool block ); diff --git a/src/app/qgsappauthrequesthandler.cpp b/src/app/qgsappauthrequesthandler.cpp index 1a08b834a6f9..add5a3b4620d 100644 --- a/src/app/qgsappauthrequesthandler.cpp +++ b/src/app/qgsappauthrequesthandler.cpp @@ -49,9 +49,10 @@ void QgsAppAuthRequestHandler::handleAuthRequest( QNetworkReply *reply, QAuthent for ( ;; ) { const bool ok = QgsCredentials::instance()->get( - QStringLiteral( "%1 at %2" ).arg( auth->realm(), reply->url().host() ), - username, password, - QObject::tr( "Authentication required" ) ); + QStringLiteral( "%1 at %2" ).arg( auth->realm(), reply->url().host() ), + username, password, + QObject::tr( "Authentication required" ) + ); if ( !ok ) return; @@ -69,7 +70,8 @@ void QgsAppAuthRequestHandler::handleAuthRequest( QNetworkReply *reply, QAuthent // credentials didn't change - stored ones probably wrong? clear password and retry QgsCredentials::instance()->put( QStringLiteral( "%1 at %2" ).arg( auth->realm(), reply->url().host() ), - username, QString() ); + username, QString() + ); } } diff --git a/src/app/qgsappauthrequesthandler.h b/src/app/qgsappauthrequesthandler.h index 3821da8afe3a..db61cb516427 100644 --- a/src/app/qgsappauthrequesthandler.h +++ b/src/app/qgsappauthrequesthandler.h @@ -19,13 +19,10 @@ class QgsAppAuthRequestHandler : public QgsNetworkAuthenticationHandler { - public: - void handleAuthRequest( QNetworkReply *reply, QAuthenticator *auth ) override; void handleAuthRequestOpenBrowser( const QUrl &url ) override; void handleAuthRequestCloseBrowser() override; - }; diff --git a/src/app/qgsappbrowserproviders.cpp b/src/app/qgsappbrowserproviders.cpp index d375ea240ecb..f9bfe101a83a 100644 --- a/src/app/qgsappbrowserproviders.cpp +++ b/src/app/qgsappbrowserproviders.cpp @@ -239,8 +239,7 @@ bool QgsQptDataItem::handleDoubleClick() QList QgsQptDataItem::actions( QWidget *parent ) { QAction *newLayout = new QAction( tr( "New Layout from Template" ), parent ); - connect( newLayout, &QAction::triggered, this, [ = ] - { + connect( newLayout, &QAction::triggered, this, [=] { QgisApp::instance()->openTemplate( path() ); } ); return QList() << newLayout; @@ -284,13 +283,11 @@ bool QgsPyDataItem::handleDoubleClick() QList QgsPyDataItem::actions( QWidget *parent ) { QAction *runScript = new QAction( tr( "&Run Script" ), parent ); - connect( runScript, &QAction::triggered, this, [ = ] - { + connect( runScript, &QAction::triggered, this, [=] { QgisApp::instance()->runScript( path() ); } ); QAction *editScript = new QAction( tr( "Open in External &Editor" ), this ); - connect( editScript, &QAction::triggered, this, [ = ] - { + connect( editScript, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl::fromLocalFile( path() ) ); } ); return QList() << runScript << editScript; @@ -348,8 +345,6 @@ bool QgsPyDropHandler::handleFileDrop( const QString &file ) } - - // // QgsStyleXmlDataItem // @@ -389,14 +384,12 @@ QList QgsStyleXmlDataItem::actions( QWidget *parent ) { QAction *browseAction = new QAction( tr( "&Open Style…" ), parent ); const QString path = mPath; - connect( browseAction, &QAction::triggered, this, [path] - { + connect( browseAction, &QAction::triggered, this, [path] { browseStyle( path ); } ); QAction *importAction = new QAction( tr( "&Import Style…" ), parent ); - connect( importAction, &QAction::triggered, this, [path] - { + connect( importAction, &QAction::triggered, this, [path] { QgsStyleExportImportDialog dlg( QgsStyle::defaultStyle(), QgisApp::instance(), QgsStyleExportImportDialog::Import ); dlg.setImportFilePath( path ); dlg.exec(); @@ -409,7 +402,7 @@ void QgsStyleXmlDataItem::browseStyle( const QString &xmlPath ) QgsStyle s; s.createMemoryDatabase(); - auto cursorOverride = std::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor ); + auto cursorOverride = std::make_unique( Qt::WaitCursor ); if ( s.importXml( xmlPath ) ) { s.setFileName( xmlPath ); @@ -490,27 +483,23 @@ QVector QgsProjectRootDataItem::createChildren() QVector childItems; QgsProject p( nullptr, Qgis::ProjectCapabilities() ); - if ( !p.read( mPath, Qgis::ProjectReadFlag::DontResolveLayers - | Qgis::ProjectReadFlag::DontLoadLayouts - | Qgis::ProjectReadFlag::DontStoreOriginalStyles - | Qgis::ProjectReadFlag::DontLoad3DViews ) ) + if ( !p.read( mPath, Qgis::ProjectReadFlag::DontResolveLayers | Qgis::ProjectReadFlag::DontLoadLayouts | Qgis::ProjectReadFlag::DontStoreOriginalStyles | Qgis::ProjectReadFlag::DontLoad3DViews ) ) { childItems.append( new QgsErrorItem( nullptr, p.error(), mPath + "/error" ) ); return childItems; } // recursively create groups and layer items for project's layer tree - std::function addNodes; - addNodes = [this, &addNodes, &childItems]( QgsDataItem * parentItem, QgsLayerTreeGroup * group ) - { - const QList< QgsLayerTreeNode * > children = group->children(); + std::function addNodes; + addNodes = [this, &addNodes, &childItems]( QgsDataItem *parentItem, QgsLayerTreeGroup *group ) { + const QList children = group->children(); for ( QgsLayerTreeNode *child : children ) { switch ( child->nodeType() ) { case QgsLayerTreeNode::NodeLayer: { - if ( QgsLayerTreeLayer *layerNode = qobject_cast< QgsLayerTreeLayer * >( child ) ) + if ( QgsLayerTreeLayer *layerNode = qobject_cast( child ) ) { QgsMapLayer *layer = layerNode->layer(); #if 0 // TODO @@ -526,11 +515,7 @@ QVector QgsProjectRootDataItem::createChildren() } #endif - QgsLayerItem *layerItem = new QgsLayerItem( nullptr, layerNode->name(), - layer ? layer->source() : QString(), - layer ? layer->source() : QString(), - layer ? QgsLayerItem::typeFromMapLayer( layer ) : Qgis::BrowserLayerType::NoType, - layer ? layer->providerType() : QString() ); + QgsLayerItem *layerItem = new QgsLayerItem( nullptr, layerNode->name(), layer ? layer->source() : QString(), layer ? layer->source() : QString(), layer ? QgsLayerItem::typeFromMapLayer( layer ) : Qgis::BrowserLayerType::NoType, layer ? layer->providerType() : QString() ); layerItem->setState( Qgis::BrowserItemState::Populated ); // children are not expected layerItem->setToolTip( layer ? layer->source() : QString() ); if ( parentItem == this ) @@ -543,7 +528,7 @@ QVector QgsProjectRootDataItem::createChildren() case QgsLayerTreeNode::NodeGroup: { - if ( QgsLayerTreeGroup *groupNode = qobject_cast< QgsLayerTreeGroup * >( child ) ) + if ( QgsLayerTreeGroup *groupNode = qobject_cast( child ) ) { QgsProjectLayerTreeGroupItem *groupItem = new QgsProjectLayerTreeGroupItem( nullptr, groupNode->name() ); addNodes( groupItem, groupNode ); @@ -649,8 +634,7 @@ QgsBookmarkManagerItem::QgsBookmarkManagerItem( QgsDataItem *parent, const QStri mManager = manager; mIconName = QStringLiteral( "/mIconFolder.svg" ); - connect( mManager, &QgsBookmarkManager::bookmarkAdded, this, [ = ]( const QString & id ) - { + connect( mManager, &QgsBookmarkManager::bookmarkAdded, this, [=]( const QString &id ) { const QgsBookmark newDetails = mManager->bookmarkById( id ); if ( newDetails.group().isEmpty() ) addChildItem( new QgsBookmarkItem( this, newDetails.name(), newDetails, mManager ), true ); @@ -668,15 +652,14 @@ QgsBookmarkManagerItem::QgsBookmarkManagerItem( QgsDataItem *parent, const QStri } } } ); - connect( mManager, &QgsBookmarkManager::bookmarkChanged, this, [ = ]( const QString & id ) - { + connect( mManager, &QgsBookmarkManager::bookmarkChanged, this, [=]( const QString &id ) { const QgsBookmark newDetails = mManager->bookmarkById( id ); // have to do a deep dive to find the old item...! const QVector c = children(); for ( QgsDataItem *i : c ) { - if ( QgsBookmarkItem *bookmarkItem = qobject_cast< QgsBookmarkItem * >( i ) ) + if ( QgsBookmarkItem *bookmarkItem = qobject_cast( i ) ) { if ( bookmarkItem->bookmark().id() == id ) { @@ -706,7 +689,7 @@ QgsBookmarkManagerItem::QgsBookmarkManagerItem( QgsDataItem *parent, const QStri break; } } - else if ( QgsBookmarkGroupItem *group = qobject_cast< QgsBookmarkGroupItem * >( i ) ) + else if ( QgsBookmarkGroupItem *group = qobject_cast( i ) ) { if ( QgsBookmarkItem *bookmarkItem = group->childItemById( id ) ) { @@ -747,8 +730,7 @@ QgsBookmarkManagerItem::QgsBookmarkManagerItem( QgsDataItem *parent, const QStri } } } ); - connect( mManager, &QgsBookmarkManager::bookmarkAboutToBeRemoved, this, [ = ]( const QString & id ) - { + connect( mManager, &QgsBookmarkManager::bookmarkAboutToBeRemoved, this, [=]( const QString &id ) { const QgsBookmark b = mManager->bookmarkById( id ); if ( !b.group().isEmpty() ) { @@ -796,7 +778,7 @@ QgsBookmarkGroupItem *QgsBookmarkManagerItem::groupItem( const QString &group ) const QVector c = children(); for ( QgsDataItem *i : c ) { - if ( QgsBookmarkGroupItem *groupItem = qobject_cast< QgsBookmarkGroupItem * >( i ) ) + if ( QgsBookmarkGroupItem *groupItem = qobject_cast( i ) ) { if ( groupItem->group() == group ) { @@ -812,7 +794,7 @@ QgsBookmarkItem *QgsBookmarkManagerItem::childItemById( const QString &id ) const QVector c = children(); for ( QgsDataItem *i : c ) { - if ( QgsBookmarkItem *bookmarkItem = qobject_cast< QgsBookmarkItem * >( i ) ) + if ( QgsBookmarkItem *bookmarkItem = qobject_cast( i ) ) { if ( bookmarkItem->bookmark().id() == id ) { @@ -841,7 +823,7 @@ QgsBookmarkGroupItem::QgsBookmarkGroupItem( QgsDataItem *parent, const QString & QVector QgsBookmarkGroupItem::createChildren() { QVector children; - const QList< QgsBookmark > bookmarks = mManager->bookmarksByGroup( mName ); + const QList bookmarks = mManager->bookmarksByGroup( mName ); children.reserve( bookmarks.size() ); for ( const QgsBookmark &bookmark : bookmarks ) { @@ -860,7 +842,7 @@ QgsBookmarkItem *QgsBookmarkGroupItem::childItemById( const QString &id ) const QVector c = children(); for ( QgsDataItem *i : c ) { - if ( QgsBookmarkItem *bookmarkItem = qobject_cast< QgsBookmarkItem * >( i ) ) + if ( QgsBookmarkItem *bookmarkItem = qobject_cast( i ) ) { if ( bookmarkItem->bookmark().id() == id ) { @@ -915,7 +897,7 @@ bool QgsBookmarkDropHandler::handleCustomUriCanvasDrop( const QgsMimeDataUtils:: try { - if ( ! canvas->setReferencedExtent( b.extent() ) ) + if ( !canvas->setReferencedExtent( b.extent() ) ) { QgisApp::instance()->messageBar()->pushWarning( tr( "Zoom to Bookmark" ), tr( "Bookmark extent is empty" ) ); } @@ -939,10 +921,10 @@ QString QgsBookmarksItemGuiProvider::name() bool QgsBookmarksItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiContext ) { - if ( qobject_cast< QgsBookmarkManagerItem * >( item ) ) + if ( qobject_cast( item ) ) return true; - if ( qobject_cast< QgsBookmarkGroupItem * >( item ) ) + if ( qobject_cast( item ) ) return true; return false; @@ -950,8 +932,8 @@ bool QgsBookmarksItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiC bool QgsBookmarksItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiContext, const QMimeData *data, Qt::DropAction ) { - QgsBookmarkManagerItem *managerItem = qobject_cast< QgsBookmarkManagerItem * >( item ); - QgsBookmarkGroupItem *groupItem = qobject_cast< QgsBookmarkGroupItem * >( item ); + QgsBookmarkManagerItem *managerItem = qobject_cast( item ); + QgsBookmarkGroupItem *groupItem = qobject_cast( item ); if ( managerItem || groupItem ) { QgsBookmarkManager *target = managerItem ? managerItem->manager() : groupItem->manager(); @@ -985,63 +967,55 @@ bool QgsBookmarksItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiC void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) { - if ( qobject_cast< QgsBookmarksItem * >( item ) ) + if ( qobject_cast( item ) ) { QAction *addBookmark = new QAction( tr( "New Spatial Bookmark…" ), menu ); - connect( addBookmark, &QAction::triggered, this, [ = ] - { + connect( addBookmark, &QAction::triggered, this, [=] { QgisApp::instance()->newBookmark(); } ); menu->addAction( addBookmark ); QAction *showBookmarksPanel = new QAction( tr( "Show Spatial Bookmarks Manager" ), menu ); - connect( showBookmarksPanel, &QAction::triggered, this, [ = ] - { + connect( showBookmarksPanel, &QAction::triggered, this, [=] { QgisApp::instance()->showBookmarkManager( true ); } ); menu->addAction( showBookmarksPanel ); menu->addSeparator(); QAction *importBookmarks = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingImport.svg" ) ), tr( "Import Spatial Bookmarks…" ), menu ); - connect( importBookmarks, &QAction::triggered, this, [ = ] - { + connect( importBookmarks, &QAction::triggered, this, [=] { importBookmarksToManager( QgsApplication::bookmarkManager(), context.messageBar() ); } ); menu->addAction( importBookmarks ); QAction *exportBookmarks = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingExport.svg" ) ), tr( "Export Spatial Bookmarks…" ), menu ); - connect( exportBookmarks, &QAction::triggered, this, [ = ] - { - exportBookmarksFromManagers( QList< const QgsBookmarkManager * >() << QgsApplication::bookmarkManager() << QgsProject::instance()->bookmarkManager(), context.messageBar() ); + connect( exportBookmarks, &QAction::triggered, this, [=] { + exportBookmarksFromManagers( QList() << QgsApplication::bookmarkManager() << QgsProject::instance()->bookmarkManager(), context.messageBar() ); } ); menu->addAction( exportBookmarks ); } - else if ( QgsBookmarkManagerItem *managerItem = qobject_cast< QgsBookmarkManagerItem * >( item ) ) + else if ( QgsBookmarkManagerItem *managerItem = qobject_cast( item ) ) { QAction *addBookmark = new QAction( tr( "New Spatial Bookmark…" ), menu ); const bool inProject = managerItem->manager() != QgsApplication::bookmarkManager(); - connect( addBookmark, &QAction::triggered, this, [ = ] - { + connect( addBookmark, &QAction::triggered, this, [=] { QgisApp::instance()->newBookmark( inProject ); } ); menu->addAction( addBookmark ); menu->addSeparator(); QAction *importBookmarks = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingImport.svg" ) ), tr( "Import Spatial Bookmarks…" ), menu ); - connect( importBookmarks, &QAction::triggered, this, [ = ] - { + connect( importBookmarks, &QAction::triggered, this, [=] { importBookmarksToManager( managerItem->manager(), context.messageBar() ); } ); menu->addAction( importBookmarks ); QAction *exportBookmarks = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingExport.svg" ) ), tr( "Export Spatial Bookmarks…" ), menu ); - connect( exportBookmarks, &QAction::triggered, this, [ = ] - { - exportBookmarksFromManagers( QList< const QgsBookmarkManager * >() << managerItem->manager(), context.messageBar() ); + connect( exportBookmarks, &QAction::triggered, this, [=] { + exportBookmarksFromManagers( QList() << managerItem->manager(), context.messageBar() ); } ); menu->addAction( exportBookmarks ); } - else if ( QgsBookmarkItem *bookmarkItem = qobject_cast< QgsBookmarkItem * >( item ) ) + else if ( QgsBookmarkItem *bookmarkItem = qobject_cast( item ) ) { QAction *actionZoom = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToLayer.svg" ) ), tr( "Zoom to Bookmark" ), menu ); - connect( actionZoom, &QAction::triggered, this, [bookmarkItem, context] - { + connect( actionZoom, &QAction::triggered, this, [bookmarkItem, context] { try { if ( !QgisApp::instance()->mapCanvas()->setReferencedExtent( bookmarkItem->bookmark().extent() ) ) @@ -1063,8 +1037,7 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu menu->addSeparator(); QAction *actionEdit = new QAction( tr( "Edit Spatial Bookmark…" ), menu ); - connect( actionEdit, &QAction::triggered, this, [bookmarkItem] - { + connect( actionEdit, &QAction::triggered, this, [bookmarkItem] { QgsBookmarkEditorDialog *dlg = new QgsBookmarkEditorDialog( bookmarkItem->bookmark(), bookmarkItem->manager() == QgsProject::instance()->bookmarkManager(), QgisApp::instance(), QgisApp::instance()->mapCanvas() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); dlg->show(); @@ -1074,7 +1047,7 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu QStringList ids; for ( QgsDataItem *i : selectedItems ) { - if ( QgsBookmarkItem *b = qobject_cast< QgsBookmarkItem * >( i ) ) + if ( QgsBookmarkItem *b = qobject_cast( i ) ) { if ( b->manager() == bookmarkItem->manager() ) ids << b->bookmark().id(); @@ -1082,22 +1055,17 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu } QAction *actionDelete = new QAction( selectedItems.count() == 1 ? tr( "Delete Spatial Bookmark" ) : tr( "Delete Spatial Bookmarks" ), menu ); - connect( actionDelete, &QAction::triggered, this, [bookmarkItem, ids] - { + connect( actionDelete, &QAction::triggered, this, [bookmarkItem, ids] { if ( ids.count() == 1 ) { - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Spatial Bookmark" ), - QObject::tr( "Are you sure you want to delete the %1 bookmark?" ).arg( bookmarkItem->name() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Spatial Bookmark" ), QObject::tr( "Are you sure you want to delete the %1 bookmark?" ).arg( bookmarkItem->name() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; bookmarkItem->manager()->removeBookmark( bookmarkItem->bookmark().id() ); } else { - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Spatial Bookmarks" ), - QObject::tr( "Are you sure you want to delete the %n selected bookmark(s)?", nullptr, ids.count() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Spatial Bookmarks" ), QObject::tr( "Are you sure you want to delete the %n selected bookmark(s)?", nullptr, ids.count() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; for ( const QString &id : ids ) @@ -1106,13 +1074,13 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu } ); menu->addAction( actionDelete ); } - else if ( QgsBookmarkGroupItem *groupItem = qobject_cast< QgsBookmarkGroupItem * >( item ) ) + else if ( QgsBookmarkGroupItem *groupItem = qobject_cast( item ) ) { QStringList groups; QgsBookmarkManager *manager = groupItem->manager(); for ( QgsDataItem *i : selectedItems ) { - if ( QgsBookmarkGroupItem *g = qobject_cast< QgsBookmarkGroupItem * >( i ) ) + if ( QgsBookmarkGroupItem *g = qobject_cast( i ) ) { if ( g->manager() == manager ) groups << g->group(); @@ -1121,17 +1089,15 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu // Export bookmarks QAction *exportBookmarks = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingExport.svg" ) ), tr( "Export Spatial Bookmarks…" ), menu ); - connect( exportBookmarks, &QAction::triggered, this, [ = ] - { - exportBookmarksFromManagers( QList< const QgsBookmarkManager * >() << groupItem->manager(), context.messageBar(), groupItem->group() ); + connect( exportBookmarks, &QAction::triggered, this, [=] { + exportBookmarksFromManagers( QList() << groupItem->manager(), context.messageBar(), groupItem->group() ); } ); menu->addAction( exportBookmarks ); // Add spatial bookmark QAction *addBookmarkToGroup = new QAction( tr( "New Spatial Bookmark…" ), menu ); const bool inProject = manager != QgsApplication::bookmarkManager(); - connect( addBookmarkToGroup, &QAction::triggered, this, [ = ] - { + connect( addBookmarkToGroup, &QAction::triggered, this, [=] { QgisApp::instance()->newBookmark( inProject, groupItem->group() ); } ); menu->addAction( addBookmarkToGroup ); @@ -1140,8 +1106,7 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu // Rename bookmark group QAction *renameBookmarkGroup = new QAction( tr( "Rename Bookmark Group…" ), menu ); const QString groupName = groupItem->group(); - connect( renameBookmarkGroup, &QAction::triggered, this, [groupName, manager] - { + connect( renameBookmarkGroup, &QAction::triggered, this, [groupName, manager] { QStringList existingGroupNames = manager->groups(); existingGroupNames.removeOne( groupName ); QgsNewNameDialog dlg( @@ -1161,13 +1126,10 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu // Delete bookmark group QAction *actionDelete = new QAction( selectedItems.count() == 1 ? tr( "Delete Bookmark Group" ) : tr( "Delete Bookmark Groups" ), menu ); - connect( actionDelete, &QAction::triggered, this, [selectedItems, groups, manager] - { + connect( actionDelete, &QAction::triggered, this, [selectedItems, groups, manager] { if ( groups.count() == 1 ) { - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Bookmark Group" ), - QObject::tr( "Are you sure you want to delete the %1 bookmark group? This will delete all bookmarks in this group." ).arg( groups.at( 0 ) ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Bookmark Group" ), QObject::tr( "Are you sure you want to delete the %1 bookmark group? This will delete all bookmarks in this group." ).arg( groups.at( 0 ) ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; const QList matching = manager->bookmarksByGroup( groups.at( 0 ) ); @@ -1178,9 +1140,7 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu } else { - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Bookmark Groups" ), - QObject::tr( "Are you sure you want to delete the %n selected bookmark group(s)? This will delete all bookmarks in these groups.", nullptr, groups.count() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Bookmark Groups" ), QObject::tr( "Are you sure you want to delete the %n selected bookmark group(s)? This will delete all bookmarks in these groups.", nullptr, groups.count() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; for ( const QString &g : groups ) @@ -1199,7 +1159,7 @@ void QgsBookmarksItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu bool QgsBookmarksItemGuiProvider::handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context ) { - if ( QgsBookmarkItem *bookmarkItem = qobject_cast< QgsBookmarkItem * >( item ) ) + if ( QgsBookmarkItem *bookmarkItem = qobject_cast( item ) ) { try { @@ -1224,7 +1184,7 @@ bool QgsBookmarksItemGuiProvider::handleDoubleClick( QgsDataItem *item, QgsDataI bool QgsBookmarksItemGuiProvider::rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context ) { - if ( QgsBookmarkItem *bookmarkItem = qobject_cast< QgsBookmarkItem * >( item ) ) + if ( QgsBookmarkItem *bookmarkItem = qobject_cast( item ) ) { QgsBookmark bookmark = bookmarkItem->bookmark(); bookmark.setName( name ); @@ -1235,7 +1195,7 @@ bool QgsBookmarksItemGuiProvider::rename( QgsDataItem *item, const QString &name } return true; } - else if ( QgsBookmarkGroupItem *groupItem = qobject_cast< QgsBookmarkGroupItem * >( item ) ) + else if ( QgsBookmarkGroupItem *groupItem = qobject_cast( item ) ) { groupItem->manager()->renameGroup( groupItem->group(), name ); return true; @@ -1248,8 +1208,7 @@ void QgsBookmarksItemGuiProvider::exportBookmarksFromManagers( const QListpushSuccess( tr( "Export Bookmarks" ), tr( "Successfully exported bookmarks to %2" ) - .arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) ); + messageBar->pushSuccess( tr( "Export Bookmarks" ), tr( "Successfully exported bookmarks to %2" ).arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) ); } settings.setValue( QStringLiteral( "Windows/Bookmarks/LastUsedDirectory" ), QFileInfo( fileName ).path() ); @@ -1276,8 +1234,7 @@ void QgsBookmarksItemGuiProvider::importBookmarksToManager( QgsBookmarkManager * QgsSettings settings; const QString lastUsedDir = settings.value( QStringLiteral( "Windows/Bookmarks/LastUsedDirectory" ), QDir::homePath() ).toString(); - const QString fileName = QFileDialog::getOpenFileName( QgisApp::instance(), tr( "Import Bookmarks" ), lastUsedDir, - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( QgisApp::instance(), tr( "Import Bookmarks" ), lastUsedDir, tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -1342,8 +1299,7 @@ bool QgsHtmlDataItem::handleDoubleClick() QList QgsHtmlDataItem::actions( QWidget *parent ) { QAction *openAction = new QAction( tr( "&Open File…" ), parent ); - connect( openAction, &QAction::triggered, this, [ = ] - { + connect( openAction, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl::fromLocalFile( path() ) ); } ); return QList() << openAction; diff --git a/src/app/qgsappbrowserproviders.h b/src/app/qgsappbrowserproviders.h index ecefeff531c3..e5a38db13363 100644 --- a/src/app/qgsappbrowserproviders.h +++ b/src/app/qgsappbrowserproviders.h @@ -32,12 +32,10 @@ class QgsQlrDataItem : public QgsLayerItem Q_OBJECT public: - QgsQlrDataItem( QgsDataItem *parent, const QString &name, const QString &path ); bool hasDragEnabled() const override; QgsMimeDataUtils::Uri mimeUri() const override; QgsMimeDataUtils::UriList mimeUris() const override; - }; /** @@ -59,7 +57,6 @@ class QgsQlrDropHandler : public QgsCustomDropHandler Q_OBJECT public: - QString customUriProviderKey() const override; void handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) const override; }; @@ -72,14 +69,11 @@ class QgsQptDataItem : public QgsDataItem Q_OBJECT public: - QgsQptDataItem( QgsDataItem *parent, const QString &name, const QString &path ); bool hasDragEnabled() const override; QgsMimeDataUtils::Uri mimeUri() const override; bool handleDoubleClick() override; - QList< QAction * > actions( QWidget *parent ) override; - - + QList actions( QWidget *parent ) override; }; /** @@ -101,14 +95,12 @@ class QgsQptDropHandler : public QgsCustomDropHandler Q_OBJECT public: - QString customUriProviderKey() const override; void handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) const override; bool handleFileDrop( const QString &file ) override; }; - /** * Custom data item for py Python scripts. */ @@ -117,14 +109,11 @@ class QgsPyDataItem : public QgsDataItem Q_OBJECT public: - QgsPyDataItem( QgsDataItem *parent, const QString &name, const QString &path ); bool hasDragEnabled() const override; QgsMimeDataUtils::Uri mimeUri() const override; bool handleDoubleClick() override; - QList< QAction * > actions( QWidget *parent ) override; - - + QList actions( QWidget *parent ) override; }; /** @@ -146,7 +135,6 @@ class QgsPyDropHandler : public QgsCustomDropHandler Q_OBJECT public: - QString customUriProviderKey() const override; void handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) const override; bool handleFileDrop( const QString &file ) override; @@ -161,15 +149,13 @@ class QgsStyleXmlDataItem : public QgsDataItem Q_OBJECT public: - QgsStyleXmlDataItem( QgsDataItem *parent, const QString &name, const QString &path ); bool hasDragEnabled() const override; QgsMimeDataUtils::Uri mimeUri() const override; bool handleDoubleClick() override; - QList< QAction * > actions( QWidget *parent ) override; + QList actions( QWidget *parent ) override; static void browseStyle( const QString &xmlPath ); - }; /** @@ -191,7 +177,6 @@ class QgsStyleXmlDropHandler : public QgsCustomDropHandler Q_OBJECT public: - QString customUriProviderKey() const override; void handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) const override; bool handleFileDrop( const QString &file ) override; @@ -205,7 +190,6 @@ class APP_EXPORT QgsProjectRootDataItem : public QgsProjectItem { Q_OBJECT public: - /** * Constructor for QgsProjectRootDataItem, with the specified * project \a path. @@ -221,12 +205,10 @@ class APP_EXPORT QgsProjectLayerTreeGroupItem : public QgsDataCollectionItem { Q_OBJECT public: - /** * Constructor for QgsProjectLayerTreeGroupItem, with the specified group \a name. */ QgsProjectLayerTreeGroupItem( QgsDataItem *parent, const QString &name ); - }; /** @@ -258,20 +240,17 @@ class QgsBookmarksItemGuiProvider : public QObject, public QgsDataItemGuiProvide Q_OBJECT public: - QgsBookmarksItemGuiProvider() = default; QString name() override; bool acceptDrop( QgsDataItem *item, QgsDataItemGuiContext context ) override; bool handleDrop( QgsDataItem *item, QgsDataItemGuiContext context, const QMimeData *data, Qt::DropAction action ) override; - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context ) override; bool rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context ) override; private: - - void exportBookmarksFromManagers( const QList< const QgsBookmarkManager * > &managers, QgsMessageBar *messageBar, const QString &group = QString() ); + void exportBookmarksFromManagers( const QList &managers, QgsMessageBar *messageBar, const QString &group = QString() ); void importBookmarksToManager( QgsBookmarkManager *manager, QgsMessageBar *messageBar ); }; @@ -283,7 +262,6 @@ class APP_EXPORT QgsBookmarksItem : public QgsDataCollectionItem { Q_OBJECT public: - /** * Constructor for QgsBookmarksItem. */ @@ -297,7 +275,6 @@ class APP_EXPORT QgsBookmarksItem : public QgsDataCollectionItem QVariant sortKey() const override; private: - QgsBookmarkManager *mApplicationManager = nullptr; QgsBookmarkManager *mProjectManager = nullptr; }; @@ -312,7 +289,6 @@ class APP_EXPORT QgsBookmarkManagerItem : public QgsDataCollectionItem { Q_OBJECT public: - /** * Constructor for QgsBookmarkManagerItem. */ @@ -328,7 +304,6 @@ class APP_EXPORT QgsBookmarkManagerItem : public QgsDataCollectionItem static QIcon iconBookmarkManager(); private: - QgsBookmarkManager *mManager = nullptr; }; @@ -340,7 +315,6 @@ class APP_EXPORT QgsBookmarkGroupItem : public QgsDataCollectionItem { Q_OBJECT public: - /** * Constructor for QgsBookmarkGroupItem. */ @@ -360,7 +334,6 @@ class APP_EXPORT QgsBookmarkGroupItem : public QgsDataCollectionItem static QIcon iconBookmarkGroup(); private: - QgsBookmarkManager *mManager = nullptr; QString mGroup; }; @@ -372,7 +345,6 @@ class APP_EXPORT QgsBookmarkItem : public QgsDataItem { Q_OBJECT public: - /** * Constructor for QgsBookmarkGroupItem. */ @@ -387,7 +359,6 @@ class APP_EXPORT QgsBookmarkItem : public QgsDataItem QgsMimeDataUtils::UriList mimeUris() const override; private: - QgsBookmarkManager *mManager = nullptr; QgsBookmark mBookmark; @@ -401,7 +372,6 @@ class QgsBookmarkDropHandler : public QgsCustomDropHandler Q_OBJECT public: - QString customUriProviderKey() const override; bool canHandleCustomUriCanvasDrop( const QgsMimeDataUtils::Uri &uri, QgsMapCanvas *canvas ) override; bool handleCustomUriCanvasDrop( const QgsMimeDataUtils::Uri &uri, QgsMapCanvas *canvas ) const override; @@ -427,10 +397,9 @@ class QgsHtmlDataItem : public QgsDataItem Q_OBJECT public: - QgsHtmlDataItem( QgsDataItem *parent, const QString &name, const QString &path ); bool handleDoubleClick() override; - QList< QAction * > actions( QWidget *parent ) override; + QList actions( QWidget *parent ) override; }; #endif // QGSAPPBROWSERPROVIDERS_H diff --git a/src/app/qgsappcoordinateoperationhandlers.cpp b/src/app/qgsappcoordinateoperationhandlers.cpp index 5d0ac4c6c0b0..af353253c02b 100644 --- a/src/app/qgsappcoordinateoperationhandlers.cpp +++ b/src/app/qgsappcoordinateoperationhandlers.cpp @@ -28,45 +28,27 @@ QgsAppMissingGridHandler::QgsAppMissingGridHandler( QObject *parent ) : QObject( parent ) { - QgsCoordinateTransform::setCustomMissingRequiredGridHandler( [ = ]( const QgsCoordinateReferenceSystem & sourceCrs, - const QgsCoordinateReferenceSystem & destinationCrs, - const QgsDatumTransform::GridDetails & grid ) - { + QgsCoordinateTransform::setCustomMissingRequiredGridHandler( [=]( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::GridDetails &grid ) { emit missingRequiredGrid( sourceCrs, destinationCrs, grid ); } ); - QgsCoordinateTransform::setCustomMissingPreferredGridHandler( [ = ]( const QgsCoordinateReferenceSystem & sourceCrs, - const QgsCoordinateReferenceSystem & destinationCrs, - const QgsDatumTransform::TransformDetails & preferredOperation, - const QgsDatumTransform::TransformDetails & availableOperation ) - { + QgsCoordinateTransform::setCustomMissingPreferredGridHandler( [=]( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::TransformDetails &preferredOperation, const QgsDatumTransform::TransformDetails &availableOperation ) { emit missingPreferredGrid( sourceCrs, destinationCrs, preferredOperation, availableOperation ); } ); - QgsCoordinateTransform::setCustomCoordinateOperationCreationErrorHandler( [ = ]( const QgsCoordinateReferenceSystem & sourceCrs, - const QgsCoordinateReferenceSystem & destinationCrs, - const QString & error ) - { + QgsCoordinateTransform::setCustomCoordinateOperationCreationErrorHandler( [=]( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &error ) { emit coordinateOperationCreationError( sourceCrs, destinationCrs, error ); } ); - QgsCoordinateTransform::setCustomMissingGridUsedByContextHandler( [ = ]( const QgsCoordinateReferenceSystem & sourceCrs, - const QgsCoordinateReferenceSystem & destinationCrs, - const QgsDatumTransform::TransformDetails & desired ) - { + QgsCoordinateTransform::setCustomMissingGridUsedByContextHandler( [=]( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::TransformDetails &desired ) { emit missingGridUsedByContextHandler( sourceCrs, destinationCrs, desired ); } ); - QgsCoordinateTransform::setFallbackOperationOccurredHandler( [ = ]( const QgsCoordinateReferenceSystem & sourceCrs, - const QgsCoordinateReferenceSystem & destinationCrs, - const QString & desired ) - { + QgsCoordinateTransform::setFallbackOperationOccurredHandler( [=]( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &desired ) { emit fallbackOperationOccurred( sourceCrs, destinationCrs, desired ); } ); - QgsCoordinateTransform::setDynamicCrsToDynamicCrsWarningHandler( [ = ]( const QgsCoordinateReferenceSystem & sourceCrs, - const QgsCoordinateReferenceSystem & destinationCrs ) - { + QgsCoordinateTransform::setDynamicCrsToDynamicCrsWarningHandler( [=]( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs ) { emit dynamicToDynamicWarning( sourceCrs, destinationCrs ); } ); @@ -77,12 +59,10 @@ QgsAppMissingGridHandler::QgsAppMissingGridHandler( QObject *parent ) connect( this, &QgsAppMissingGridHandler::fallbackOperationOccurred, this, &QgsAppMissingGridHandler::onFallbackOperationOccurred, Qt::QueuedConnection ); connect( this, &QgsAppMissingGridHandler::dynamicToDynamicWarning, this, &QgsAppMissingGridHandler::onDynamicToDynamicWarning, Qt::QueuedConnection ); - connect( QgsProject::instance(), &QgsProject::cleared, this, [ = ] - { + connect( QgsProject::instance(), &QgsProject::cleared, this, [=] { mAlreadyWarnedPairsForProject.clear(); mAlreadyWarnedBallparkPairsForProject.clear(); } ); - } void QgsAppMissingGridHandler::onMissingRequiredGrid( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::GridDetails &grid ) @@ -90,8 +70,7 @@ void QgsAppMissingGridHandler::onMissingRequiredGrid( const QgsCoordinateReferen if ( !shouldWarnAboutPair( sourceCrs, destinationCrs ) ) return; - const QString shortMessage = tr( "No transform available between %1 and %2" ).arg( sourceCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), - destinationCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) ); + const QString shortMessage = tr( "No transform available between %1 and %2" ).arg( sourceCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), destinationCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) ); QString downloadMessage; const QString gridName = grid.shortName; @@ -108,15 +87,13 @@ void QgsAppMissingGridHandler::onMissingRequiredGrid( const QgsCoordinateReferen } const QString longMessage = tr( "

    No transform is available between %1 and %2.

    " - "

    This transformation requires the grid file “%3”, which is not available for use on the system.

    " ).arg( sourceCrs.userFriendlyIdentifier(), - destinationCrs.userFriendlyIdentifier(), - grid.shortName ); + "

    This transformation requires the grid file “%3”, which is not available for use on the system.

    " ) + .arg( sourceCrs.userFriendlyIdentifier(), destinationCrs.userFriendlyIdentifier(), grid.shortName ); QgsMessageBar *bar = QgisApp::instance()->messageBar(); QgsMessageBarItem *widget = QgsMessageBar::createMessage( QString(), shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "Details" ) ); - connect( detailsButton, &QPushButton::clicked, this, [longMessage, downloadMessage, bar, widget, gridName] - { + connect( detailsButton, &QPushButton::clicked, this, [longMessage, downloadMessage, bar, widget, gridName] { QgsInstallGridShiftFileDialog *dlg = new QgsInstallGridShiftFileDialog( gridName, QgisApp::instance() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); dlg->setWindowTitle( tr( "No Transformations Available" ) ); @@ -137,8 +114,7 @@ void QgsAppMissingGridHandler::onMissingPreferredGrid( const QgsCoordinateRefere if ( !shouldWarnAboutPair( sourceCrs, destinationCrs ) ) return; - const QString shortMessage = tr( "Cannot use preferred transform between %1 and %2" ).arg( sourceCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), - destinationCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) ); + const QString shortMessage = tr( "Cannot use preferred transform between %1 and %2" ).arg( sourceCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), destinationCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) ); QString gridMessage; QString downloadMessage; @@ -170,21 +146,17 @@ void QgsAppMissingGridHandler::onMissingPreferredGrid( const QgsCoordinateRefere QString accuracyMessage; if ( availableOperation.accuracy >= 0 && preferredOperation.accuracy >= 0 ) - accuracyMessage = tr( "

    Current transform “%1” has an accuracy of %2 meters, while the preferred transformation “%3” has accuracy %4 meters.

    " ).arg( availableOperation.name ) - .arg( availableOperation.accuracy ).arg( preferredOperation.name ).arg( preferredOperation.accuracy ); + accuracyMessage = tr( "

    Current transform “%1” has an accuracy of %2 meters, while the preferred transformation “%3” has accuracy %4 meters.

    " ).arg( availableOperation.name ).arg( availableOperation.accuracy ).arg( preferredOperation.name ).arg( preferredOperation.accuracy ); else if ( preferredOperation.accuracy >= 0 ) - accuracyMessage = tr( "

    Current transform “%1” has an unknown accuracy, while the preferred transformation “%2” has accuracy %3 meters.

    " ).arg( availableOperation.name ) - .arg( preferredOperation.name ).arg( preferredOperation.accuracy ); + accuracyMessage = tr( "

    Current transform “%1” has an unknown accuracy, while the preferred transformation “%2” has accuracy %3 meters.

    " ).arg( availableOperation.name ).arg( preferredOperation.name ).arg( preferredOperation.accuracy ); - const QString longMessage = tr( "

    The preferred transform between %1 and %2 is not available for use on the system.

    " ).arg( sourceCrs.userFriendlyIdentifier(), - destinationCrs.userFriendlyIdentifier() ) + const QString longMessage = tr( "

    The preferred transform between %1 and %2 is not available for use on the system.

    " ).arg( sourceCrs.userFriendlyIdentifier(), destinationCrs.userFriendlyIdentifier() ) + gridMessage + accuracyMessage; QgsMessageBar *bar = QgisApp::instance()->messageBar(); QgsMessageBarItem *widget = QgsMessageBar::createMessage( QString(), shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "Details" ) ); - connect( detailsButton, &QPushButton::clicked, this, [longMessage, downloadMessage, gridName, widget, bar] - { + connect( detailsButton, &QPushButton::clicked, this, [longMessage, downloadMessage, gridName, widget, bar] { QgsInstallGridShiftFileDialog *dlg = new QgsInstallGridShiftFileDialog( gridName, QgisApp::instance() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); dlg->setWindowTitle( tr( "Preferred Transformation Not Available" ) ); @@ -211,10 +183,9 @@ void QgsAppMissingGridHandler::onCoordinateOperationCreationError( const QgsCoor QgsMessageBar *bar = QgisApp::instance()->messageBar(); QgsMessageBarItem *widget = QgsMessageBar::createMessage( QString(), shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "Details" ) ); - connect( detailsButton, &QPushButton::clicked, this, [longMessage] - { + connect( detailsButton, &QPushButton::clicked, this, [longMessage] { // dlg has deleted on close - QgsMessageOutput * dlg( QgsMessageOutput::createMessageOutput() ); + QgsMessageOutput *dlg( QgsMessageOutput::createMessageOutput() ); dlg->setTitle( tr( "No Transformations Available" ) ); dlg->setMessage( longMessage, QgsMessageOutput::MessageHtml ); dlg->showMessage(); @@ -229,8 +200,7 @@ void QgsAppMissingGridHandler::onMissingGridUsedByContextHandler( const QgsCoord if ( !shouldWarnAboutPairForCurrentProject( sourceCrs, destinationCrs ) ) return; - const QString shortMessage = tr( "Cannot use project transform between %1 and %2" ).arg( sourceCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), - destinationCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) ); + const QString shortMessage = tr( "Cannot use project transform between %1 and %2" ).arg( sourceCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ), destinationCrs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) ); QString gridMessage; QString downloadMessage; @@ -260,16 +230,14 @@ void QgsAppMissingGridHandler::onMissingGridUsedByContextHandler( const QgsCoord gridMessage = "
      " + gridMessage + "
    "; } - const QString longMessage = tr( "

    This project specifies a preset transform between %1 and %2, which is not available for use on the system.

    " ).arg( sourceCrs.userFriendlyIdentifier(), - destinationCrs.userFriendlyIdentifier() ) + const QString longMessage = tr( "

    This project specifies a preset transform between %1 and %2, which is not available for use on the system.

    " ).arg( sourceCrs.userFriendlyIdentifier(), destinationCrs.userFriendlyIdentifier() ) + gridMessage - + tr( "

    The operation specified for use in the project is:

    %1

    " ).arg( desired.proj ) ; + + tr( "

    The operation specified for use in the project is:

    %1

    " ).arg( desired.proj ); QgsMessageBar *bar = QgisApp::instance()->messageBar(); QgsMessageBarItem *widget = QgsMessageBar::createMessage( QString(), shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "Details" ) ); - connect( detailsButton, &QPushButton::clicked, this, [longMessage, gridName, downloadMessage, bar, widget] - { + connect( detailsButton, &QPushButton::clicked, this, [longMessage, gridName, downloadMessage, bar, widget] { QgsInstallGridShiftFileDialog *dlg = new QgsInstallGridShiftFileDialog( gridName, QgisApp::instance() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); dlg->setWindowTitle( tr( "Project Transformation Not Available" ) ); @@ -296,10 +264,9 @@ void QgsAppMissingGridHandler::onFallbackOperationOccurred( const QgsCoordinateR QgsMessageBar *bar = QgisApp::instance()->messageBar(); QgsMessageBarItem *widget = QgsMessageBar::createMessage( QString(), shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "Details" ) ); - connect( detailsButton, &QPushButton::clicked, this, [longMessage] - { + connect( detailsButton, &QPushButton::clicked, this, [longMessage] { // dlg has deleted on close - QgsMessageOutput * dlg( QgsMessageOutput::createMessageOutput() ); + QgsMessageOutput *dlg( QgsMessageOutput::createMessageOutput() ); dlg->setTitle( tr( "Ballpark Transform Occurred" ) ); dlg->setMessage( longMessage, QgsMessageOutput::MessageHtml ); dlg->showMessage(); @@ -320,10 +287,9 @@ void QgsAppMissingGridHandler::onDynamicToDynamicWarning( const QgsCoordinateRef QgsMessageBar *bar = QgisApp::instance()->messageBar(); QgsMessageBarItem *widget = QgsMessageBar::createMessage( QString(), shortMessage ); QPushButton *detailsButton = new QPushButton( tr( "Details" ) ); - connect( detailsButton, &QPushButton::clicked, this, [longMessage] - { + connect( detailsButton, &QPushButton::clicked, this, [longMessage] { // dlg has deleted on close - QgsMessageOutput * dlg( QgsMessageOutput::createMessageOutput() ); + QgsMessageOutput *dlg( QgsMessageOutput::createMessageOutput() ); dlg->setTitle( tr( "Unsupported Transformation" ) ); dlg->setMessage( longMessage, QgsMessageOutput::MessageHtml ); dlg->showMessage(); diff --git a/src/app/qgsappcoordinateoperationhandlers.h b/src/app/qgsappcoordinateoperationhandlers.h index c361d1146958..8daefca29ad5 100644 --- a/src/app/qgsappcoordinateoperationhandlers.h +++ b/src/app/qgsappcoordinateoperationhandlers.h @@ -27,72 +27,46 @@ class QgsAppMissingGridHandler : public QObject { Q_OBJECT public: - QgsAppMissingGridHandler( QObject *parent ); signals: - void missingRequiredGrid( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QgsDatumTransform::GridDetails &grid ); + void missingRequiredGrid( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::GridDetails &grid ); - void missingPreferredGrid( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QgsDatumTransform::TransformDetails &preferredOperation, - const QgsDatumTransform::TransformDetails &availableOperation ); + void missingPreferredGrid( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::TransformDetails &preferredOperation, const QgsDatumTransform::TransformDetails &availableOperation ); - void coordinateOperationCreationError( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QString &error ); + void coordinateOperationCreationError( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &error ); - void missingGridUsedByContextHandler( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QgsDatumTransform::TransformDetails &desired ); + void missingGridUsedByContextHandler( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::TransformDetails &desired ); - void fallbackOperationOccurred( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QString &desired ); + void fallbackOperationOccurred( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &desired ); - void dynamicToDynamicWarning( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs ); + void dynamicToDynamicWarning( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs ); private slots: - void onMissingRequiredGrid( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QgsDatumTransform::GridDetails &grid ); + void onMissingRequiredGrid( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::GridDetails &grid ); - void onMissingPreferredGrid( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QgsDatumTransform::TransformDetails &preferredOperation, - const QgsDatumTransform::TransformDetails &availableOperation ); + void onMissingPreferredGrid( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::TransformDetails &preferredOperation, const QgsDatumTransform::TransformDetails &availableOperation ); - void onCoordinateOperationCreationError( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QString &error ); + void onCoordinateOperationCreationError( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &error ); - void onMissingGridUsedByContextHandler( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QgsDatumTransform::TransformDetails &desired ); + void onMissingGridUsedByContextHandler( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QgsDatumTransform::TransformDetails &desired ); - void onFallbackOperationOccurred( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs, - const QString &desired ); + void onFallbackOperationOccurred( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &desired ); - void onDynamicToDynamicWarning( const QgsCoordinateReferenceSystem &sourceCrs, - const QgsCoordinateReferenceSystem &destinationCrs ); + void onDynamicToDynamicWarning( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs ); private: - bool shouldWarnAboutPair( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &dest ); bool shouldWarnAboutPairForCurrentProject( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &dest ); bool shouldWarnAboutBallparkPairForCurrentProject( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &dest ); bool shouldWarnAboutDynamicCrsForCurrentProject( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &dest ); - QList< QPair< QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem > > mAlreadyWarnedPairs; - QList< QPair< QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem > > mAlreadyWarnedPairsForProject; - QList< QPair< QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem > > mAlreadyWarnedBallparkPairsForProject; - QList< QPair< QgsCoordinateReferenceSystem, QgsCoordinateReferenceSystem > > mAlreadyWarnedDynamicCrsForProject; + QList> mAlreadyWarnedPairs; + QList> mAlreadyWarnedPairsForProject; + QList> mAlreadyWarnedBallparkPairsForProject; + QList> mAlreadyWarnedDynamicCrsForProject; }; #endif // QGSAPPCOORDINATEOPERATIONHANDLERS_H diff --git a/src/app/qgsapplayertreeviewmenuprovider.cpp b/src/app/qgsapplayertreeviewmenuprovider.cpp index 0f2ab032842c..5c9cee654862 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.cpp +++ b/src/app/qgsapplayertreeviewmenuprovider.cpp @@ -111,8 +111,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() removeAction->setEnabled( removeActionEnabled() ); menu->addSeparator(); - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSetCRS.png" ) ), - tr( "Set Group &CRS…" ), QgisApp::instance(), &QgisApp::legendGroupSetCrs ); + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSetCRS.png" ) ), tr( "Set Group &CRS…" ), QgisApp::instance(), &QgisApp::legendGroupSetCrs ); menu->addAction( tr( "Set Group &WMS Data…" ), QgisApp::instance(), &QgisApp::legendGroupSetWmsData ); menu->addSeparator(); @@ -160,13 +159,12 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() QPointer layer { QgsLayerTree::toLayer( node )->layer() }; QgsRasterLayer *rlayer = qobject_cast( layer ); QgsVectorLayer *vlayer = qobject_cast( layer ); - QgsPointCloudLayer *pcLayer = qobject_cast( layer ); - QgsMeshLayer *meshLayer = qobject_cast( layer ); - QgsVectorTileLayer *vectorTileLayer = qobject_cast( layer ); + QgsPointCloudLayer *pcLayer = qobject_cast( layer ); + QgsMeshLayer *meshLayer = qobject_cast( layer ); + QgsVectorTileLayer *vectorTileLayer = qobject_cast( layer ); if ( layer && layer->isSpatial() ) { - QAction *zoomToLayers = actions->actionZoomToLayers( mCanvas, menu ); zoomToLayers->setEnabled( layer->isValid() ); menu->addAction( zoomToLayers ); @@ -176,17 +174,14 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() bool hasSelectedFeature = false; for ( const QgsMapLayer *layer : selectedLayers ) { - if ( const QgsVectorLayer *vLayer = qobject_cast( layer ) ) { - if ( vLayer->selectedFeatureCount() > 0 ) { hasSelectedFeature = true; break; } } - } QAction *actionZoomSelected = actions->actionZoomToSelection( mCanvas, menu ); actionZoomSelected->setEnabled( vlayer->isValid() && hasSelectedFeature ); @@ -205,13 +200,12 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( vlayer || vectorTileLayer || meshLayer ) { const QString iconName = vectorTileLayer || ( vlayer && vlayer->labeling() && vlayer->labeling()->type() == QLatin1String( "rule-based" ) ) - ? QStringLiteral( "labelingRuleBased.svg" ) - : QStringLiteral( "labelingSingle.svg" ); + ? QStringLiteral( "labelingRuleBased.svg" ) + : QStringLiteral( "labelingSingle.svg" ); QAction *actionShowLabels = new QAction( QgsApplication::getThemeIcon( iconName ), tr( "Show &Labels" ), menu ); actionShowLabels->setCheckable( true ); - actionShowLabels->setChecked( vectorTileLayer ? vectorTileLayer->labelsEnabled() - : meshLayer ? meshLayer->labelsEnabled() - : vlayer->labelsEnabled() ); + actionShowLabels->setChecked( vectorTileLayer ? vectorTileLayer->labelsEnabled() : meshLayer ? meshLayer->labelsEnabled() + : vlayer->labelsEnabled() ); connect( actionShowLabels, &QAction::toggled, this, &QgsAppLayerTreeViewMenuProvider::toggleLabels ); menu->addAction( actionShowLabels ); } @@ -249,106 +243,98 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() // No raster support in createSqlVectorLayer (yet) if ( vlayer ) { - const std::unique_ptr< QgsAbstractDatabaseProviderConnection> conn { QgsMapLayerUtils::databaseConnection( layer ) }; + const std::unique_ptr conn { QgsMapLayerUtils::databaseConnection( layer ) }; if ( conn ) { if ( vlayer->isSqlQuery() ) - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/dbmanager.svg" ) ), tr( "Update SQL Layer…" ), menu, [ layer, this ] - { - std::unique_ptr< QgsAbstractDatabaseProviderConnection> conn2 { QgsMapLayerUtils::databaseConnection( layer ) }; - if ( conn2 ) - { - QgsDialog dialog; - dialog.setObjectName( QStringLiteral( "SqlUpdateDialog" ) ); - dialog.setWindowTitle( tr( "%1 — Update SQL" ).arg( layer->name() ) ); - QgsGui::enableAutoGeometryRestore( &dialog ); - QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions options { conn2->sqlOptions( layer->source() ) }; - options.layerName = layer->name(); - QgsQueryResultWidget *queryResultWidget { new QgsQueryResultWidget( &dialog, conn2.release() ) }; - queryResultWidget->setWidgetMode( QgsQueryResultWidget::QueryWidgetMode::QueryLayerUpdateMode ); - queryResultWidget->setSqlVectorLayerOptions( options ); - queryResultWidget->executeQuery(); - queryResultWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); - dialog.layout()->addWidget( queryResultWidget ); - - connect( queryResultWidget, &QgsQueryResultWidget::createSqlVectorLayer, queryResultWidget, [queryResultWidget, layer, this ]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions & options ) + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/dbmanager.svg" ) ), tr( "Update SQL Layer…" ), menu, [layer, this] { + std::unique_ptr conn2 { QgsMapLayerUtils::databaseConnection( layer ) }; + if ( conn2 ) { - ( void )this; - std::unique_ptr< QgsAbstractDatabaseProviderConnection> conn3 { QgsMapLayerUtils::databaseConnection( layer ) }; - if ( conn3 ) - { - try + QgsDialog dialog; + dialog.setObjectName( QStringLiteral( "SqlUpdateDialog" ) ); + dialog.setWindowTitle( tr( "%1 — Update SQL" ).arg( layer->name() ) ); + QgsGui::enableAutoGeometryRestore( &dialog ); + QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions options { conn2->sqlOptions( layer->source() ) }; + options.layerName = layer->name(); + QgsQueryResultWidget *queryResultWidget { new QgsQueryResultWidget( &dialog, conn2.release() ) }; + queryResultWidget->setWidgetMode( QgsQueryResultWidget::QueryWidgetMode::QueryLayerUpdateMode ); + queryResultWidget->setSqlVectorLayerOptions( options ); + queryResultWidget->executeQuery(); + queryResultWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); + dialog.layout()->addWidget( queryResultWidget ); + + connect( queryResultWidget, &QgsQueryResultWidget::createSqlVectorLayer, queryResultWidget, [queryResultWidget, layer, this]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options ) { + ( void ) this; + std::unique_ptr conn3 { QgsMapLayerUtils::databaseConnection( layer ) }; + if ( conn3 ) { - std::unique_ptr sqlLayer { conn3->createSqlVectorLayer( options ) }; - if ( sqlLayer->isValid() ) + try { - layer->setDataSource( sqlLayer->source(), sqlLayer->name(), sqlLayer->dataProvider()->name(), QgsDataProvider::ProviderOptions() ); - queryResultWidget->notify( QObject::tr( "Layer Update Success" ), QObject::tr( "The SQL layer was updated successfully" ), Qgis::MessageLevel::Success ); - } - else - { - QString error { sqlLayer->dataProvider()->error().message( QgsErrorMessage::Format::Text ) }; - if ( error.isEmpty() ) + std::unique_ptr sqlLayer { conn3->createSqlVectorLayer( options ) }; + if ( sqlLayer->isValid() ) + { + layer->setDataSource( sqlLayer->source(), sqlLayer->name(), sqlLayer->dataProvider()->name(), QgsDataProvider::ProviderOptions() ); + queryResultWidget->notify( QObject::tr( "Layer Update Success" ), QObject::tr( "The SQL layer was updated successfully" ), Qgis::MessageLevel::Success ); + } + else { - error = QObject::tr( "layer is not valid, check the log messages for more information" ); + QString error { sqlLayer->dataProvider()->error().message( QgsErrorMessage::Format::Text ) }; + if ( error.isEmpty() ) + { + error = QObject::tr( "layer is not valid, check the log messages for more information" ); + } + queryResultWidget->notify( QObject::tr( "Layer Update Error" ), QObject::tr( "Error updating the SQL layer: %1" ).arg( error ), Qgis::MessageLevel::Critical ); } - queryResultWidget->notify( QObject::tr( "Layer Update Error" ), QObject::tr( "Error updating the SQL layer: %1" ).arg( error ), Qgis::MessageLevel::Critical ); + } + catch ( QgsProviderConnectionException &ex ) + { + queryResultWidget->notify( QObject::tr( "Layer Update Error" ), QObject::tr( "Error updating the SQL layer: %1" ).arg( ex.what() ), Qgis::MessageLevel::Critical ); } } - catch ( QgsProviderConnectionException &ex ) - { - queryResultWidget->notify( QObject::tr( "Layer Update Error" ), QObject::tr( "Error updating the SQL layer: %1" ).arg( ex.what() ), Qgis::MessageLevel::Critical ); - } - } - - } ); + } ); - dialog.exec(); - - } - } ); + dialog.exec(); + } + } ); // SQL dialog if ( conn->capabilities().testFlag( QgsAbstractDatabaseProviderConnection::Capability::ExecuteSql ) ) - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/dbmanager.svg" ) ), tr( "Execute SQL…" ), menu, [ layer, this ] - { - std::unique_ptr< QgsAbstractDatabaseProviderConnection> conn2 { QgsMapLayerUtils::databaseConnection( layer ) }; - if ( conn2 ) - { - QgsDialog dialog; - dialog.setObjectName( QStringLiteral( "SqlExecuteDialog" ) ); - dialog.setWindowTitle( tr( "Execute SQL" ) ); - QgsGui::enableAutoGeometryRestore( &dialog ); - QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions options { conn2->sqlOptions( layer->source() ) }; - QgsQueryResultWidget *queryResultWidget { new QgsQueryResultWidget( &dialog, conn2.release() ) }; - queryResultWidget->setSqlVectorLayerOptions( options ); - queryResultWidget->executeQuery(); - queryResultWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); - dialog.layout()->addWidget( queryResultWidget ); - - connect( queryResultWidget, &QgsQueryResultWidget::createSqlVectorLayer, queryResultWidget, [queryResultWidget, layer, this ]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions & options ) + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/dbmanager.svg" ) ), tr( "Execute SQL…" ), menu, [layer, this] { + std::unique_ptr conn2 { QgsMapLayerUtils::databaseConnection( layer ) }; + if ( conn2 ) { - ( void )this; - std::unique_ptr< QgsAbstractDatabaseProviderConnection> conn3 { QgsMapLayerUtils::databaseConnection( layer ) }; - if ( conn3 ) - { - try - { - QgsMapLayer *sqlLayer { conn3->createSqlVectorLayer( options ) }; - QgsProject::instance()->addMapLayers( { sqlLayer } ); - } - catch ( QgsProviderConnectionException &ex ) + QgsDialog dialog; + dialog.setObjectName( QStringLiteral( "SqlExecuteDialog" ) ); + dialog.setWindowTitle( tr( "Execute SQL" ) ); + QgsGui::enableAutoGeometryRestore( &dialog ); + QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions options { conn2->sqlOptions( layer->source() ) }; + QgsQueryResultWidget *queryResultWidget { new QgsQueryResultWidget( &dialog, conn2.release() ) }; + queryResultWidget->setSqlVectorLayerOptions( options ); + queryResultWidget->executeQuery(); + queryResultWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); + dialog.layout()->addWidget( queryResultWidget ); + + connect( queryResultWidget, &QgsQueryResultWidget::createSqlVectorLayer, queryResultWidget, [queryResultWidget, layer, this]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options ) { + ( void ) this; + std::unique_ptr conn3 { QgsMapLayerUtils::databaseConnection( layer ) }; + if ( conn3 ) { - queryResultWidget->notify( QObject::tr( "New SQL Layer Creation Error" ), QObject::tr( "Error creating the SQL layer: %1" ).arg( ex.what() ), Qgis::MessageLevel::Critical ); + try + { + QgsMapLayer *sqlLayer { conn3->createSqlVectorLayer( options ) }; + QgsProject::instance()->addMapLayers( { sqlLayer } ); + } + catch ( QgsProviderConnectionException &ex ) + { + queryResultWidget->notify( QObject::tr( "New SQL Layer Creation Error" ), QObject::tr( "Error creating the SQL layer: %1" ).arg( ex.what() ), Qgis::MessageLevel::Critical ); + } } - } - - } ); + } ); - dialog.exec(); - - } - } ); + dialog.exec(); + } + } ); } } @@ -399,10 +385,9 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( vlayer ) { QgsSettings settings; - const QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ); - const auto lambdaOpenAttributeTable = [ = ] { QgisApp::instance()->attributeTable( initialMode ); }; - QAction *attributeTableAction = menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOpenTable.svg" ) ), tr( "Open &Attribute Table" ), - QgisApp::instance(), lambdaOpenAttributeTable ); + const QgsAttributeTableFilterModel::FilterMode initialMode = settings.enumValue( QStringLiteral( "qgis/attributeTableBehavior" ), QgsAttributeTableFilterModel::ShowAll ); + const auto lambdaOpenAttributeTable = [=] { QgisApp::instance()->attributeTable( initialMode ); }; + QAction *attributeTableAction = menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionOpenTable.svg" ) ), tr( "Open &Attribute Table" ), QgisApp::instance(), lambdaOpenAttributeTable ); attributeTableAction->setEnabled( vlayer->isValid() ); } @@ -431,8 +416,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() } } - if ( ( rlayer && rlayer->dataProvider() && rlayer->dataProvider()->supportsSubsetString() ) || - ( pcLayer && pcLayer->dataProvider() && pcLayer->dataProvider()->supportsSubsetString() ) ) + if ( ( rlayer && rlayer->dataProvider() && rlayer->dataProvider()->supportsSubsetString() ) || ( pcLayer && pcLayer->dataProvider() && pcLayer->dataProvider()->supportsSubsetString() ) ) { menu->addAction( tr( "&Filter…" ), QgisApp::instance(), qOverload<>( &QgisApp::layerSubsetString ) ); } @@ -448,7 +432,6 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() } if ( supportsChangeDataSource ) { - QAction *a = new QAction( layer->isValid() ? tr( "C&hange Data Source…" ) : tr( "Repair Data Source…" ), menu ); if ( !layer->isValid() ) a->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mIconWarning.svg" ) ) ); @@ -459,8 +442,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() } else { - connect( a, &QAction::triggered, this, [ = ] - { + connect( a, &QAction::triggered, this, [=] { QgisApp::instance()->changeDataSource( layer ); } ); } @@ -482,18 +464,16 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() { if ( target == Qgis::MapLayerActionTarget::SingleFeature ) { - actionMenu->addAction( action->text(), action, [ = ]() - { + actionMenu->addAction( action->text(), action, [=]() { Q_NOWARN_DEPRECATED_PUSH - action->triggerForFeature( vlayer, vlayer->selectedFeatures().at( 0 ) ); + action->triggerForFeature( vlayer, vlayer->selectedFeatures().at( 0 ) ); Q_NOWARN_DEPRECATED_POP - action->triggerForFeature( vlayer, vlayer->selectedFeatures().at( 0 ), context ); + action->triggerForFeature( vlayer, vlayer->selectedFeatures().at( 0 ), context ); } ); } else if ( target == Qgis::MapLayerActionTarget::MultipleFeatures ) { - actionMenu->addAction( action->text(), action, [ = ]() - { + actionMenu->addAction( action->text(), action, [=]() { Q_NOWARN_DEPRECATED_PUSH action->triggerForFeatures( vlayer, vlayer->selectedFeatures() ); Q_NOWARN_DEPRECATED_POP @@ -542,9 +522,9 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() } } - QAction *actionCurrentCrs = new QAction( !allSameCrs ? tr( "Mixed CRS" ) - : layer->crs().isValid() ? layer->crs().userFriendlyIdentifier() - : tr( "No CRS" ), menuSetCRS ); + QAction *actionCurrentCrs = new QAction( !allSameCrs ? tr( "Mixed CRS" ) : layer->crs().isValid() ? layer->crs().userFriendlyIdentifier() + : tr( "No CRS" ), + menuSetCRS ); actionCurrentCrs->setEnabled( false ); menuSetCRS->addAction( actionCurrentCrs ); @@ -556,7 +536,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() menuSetCRS->addAction( actionSetProjectCrs ); } - const QList< QgsCoordinateReferenceSystem> recentProjections = QgsApplication::coordinateReferenceSystemRegistry()->recentCrs(); + const QList recentProjections = QgsApplication::coordinateReferenceSystemRegistry()->recentCrs(); if ( !recentProjections.isEmpty() ) { menuSetCRS->addSeparator(); @@ -567,8 +547,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() continue; QAction *action = menuSetCRS->addAction( tr( "Set to %1" ).arg( crs.userFriendlyIdentifier( Qgis::CrsIdentifierType::ShortString ) ) ); - connect( action, &QAction::triggered, this, [ = ] - { + connect( action, &QAction::triggered, this, [=] { setLayerCrs( crs ); } ); @@ -600,18 +579,18 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( vlayer->isTemporary() ) { QAction *actionMakePermanent = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionFileSave.svg" ) ), tr( "Make Permanent…" ), menu ); - connect( actionMakePermanent, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->makeMemoryLayerPermanent( vlayer ); } ); + connect( actionMakePermanent, &QAction::triggered, QgisApp::instance(), [=] { QgisApp::instance()->makeMemoryLayerPermanent( vlayer ); } ); menu->addAction( actionMakePermanent ); } // save as vector file QMenu *menuExportVector = new QMenu( tr( "E&xport" ), menu ); menuExportVector->setObjectName( QStringLiteral( "exportMenu" ) ); QAction *actionSaveAs = new QAction( tr( "Save Features &As…" ), menuExportVector ); - connect( actionSaveAs, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveAsFile(); } ); + connect( actionSaveAs, &QAction::triggered, QgisApp::instance(), [=] { QgisApp::instance()->saveAsFile(); } ); actionSaveAs->setEnabled( vlayer->isValid() ); menuExportVector->addAction( actionSaveAs ); QAction *actionSaveSelectedFeaturesAs = new QAction( tr( "Save &Selected Features As…" ), menuExportVector ); - connect( actionSaveSelectedFeaturesAs, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveAsFile( nullptr, true ); } ); + connect( actionSaveSelectedFeaturesAs, &QAction::triggered, QgisApp::instance(), [=] { QgisApp::instance()->saveAsFile( nullptr, true ); } ); actionSaveSelectedFeaturesAs->setEnabled( vlayer->isValid() && vlayer->selectedFeatureCount() > 0 ); menuExportVector->addAction( actionSaveSelectedFeaturesAs ); QAction *actionSaveAsDefinitionLayer = new QAction( tr( "Save as Layer &Definition File…" ), menuExportVector ); @@ -620,7 +599,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( vlayer->isSpatial() ) { QAction *actionSaveStyle = new QAction( tr( "Save as &QGIS Layer Style File…" ), menuExportVector ); - connect( actionSaveStyle, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveStyleFile(); } ); + connect( actionSaveStyle, &QAction::triggered, QgisApp::instance(), [=] { QgisApp::instance()->saveStyleFile(); } ); menuExportVector->addAction( actionSaveStyle ); } menu->addMenu( menuExportVector ); @@ -633,19 +612,18 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() case Qgis::LayerType::PointCloud: case Qgis::LayerType::TiledScene: { - bool enableSaveAs = ( pcLayer && pcLayer->isValid() && pcLayer->dataProvider()->hasValidIndex() ) || - ( rlayer && rlayer->isValid() ); + bool enableSaveAs = ( pcLayer && pcLayer->isValid() && pcLayer->dataProvider()->hasValidIndex() ) || ( rlayer && rlayer->isValid() ); QMenu *menuExportRaster = new QMenu( tr( "E&xport" ), menu ); menuExportRaster->setObjectName( QStringLiteral( "exportMenu" ) ); QAction *actionSaveAs = new QAction( tr( "Save &As…" ), menuExportRaster ); QAction *actionSaveAsDefinitionLayer = new QAction( tr( "Save as Layer &Definition File…" ), menuExportRaster ); QAction *actionSaveStyle = new QAction( tr( "Save as &QGIS Layer Style File…" ), menuExportRaster ); - connect( actionSaveAs, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveAsFile(); } ); + connect( actionSaveAs, &QAction::triggered, QgisApp::instance(), [=] { QgisApp::instance()->saveAsFile(); } ); menuExportRaster->addAction( actionSaveAs ); actionSaveAs->setEnabled( enableSaveAs ); connect( actionSaveAsDefinitionLayer, &QAction::triggered, QgisApp::instance(), &QgisApp::saveAsLayerDefinition ); menuExportRaster->addAction( actionSaveAsDefinitionLayer ); - connect( actionSaveStyle, &QAction::triggered, QgisApp::instance(), [ = ] { QgisApp::instance()->saveStyleFile(); } ); + connect( actionSaveStyle, &QAction::triggered, QgisApp::instance(), [=] { QgisApp::instance()->saveStyleFile(); } ); menuExportRaster->addAction( actionSaveStyle ); menu->addMenu( menuExportRaster ); } @@ -662,7 +640,6 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() duplicateLayersAction->setEnabled( false ); } break; - } menu->addSeparator(); } @@ -689,12 +666,12 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() { const QModelIndex index = model->index( row, 0 ); const QgsMapLayer::StyleCategory category = model->data( index, Qt::UserRole ).value(); - const QString name = model->data( index, static_cast< int >( QgsMapLayerStyleCategoriesModel::Role::NameRole ) ).toString(); + const QString name = model->data( index, static_cast( QgsMapLayerStyleCategoriesModel::Role::NameRole ) ).toString(); const QString tooltip = model->data( index, Qt::ToolTipRole ).toString(); const QIcon icon = model->data( index, Qt::DecorationRole ).value(); QAction *copyAction = new QAction( icon, name, copyStyleMenu ); copyAction->setToolTip( tooltip ); - connect( copyAction, &QAction::triggered, this, [ = ]() {app->copyStyle( layer, category );} ); + connect( copyAction, &QAction::triggered, this, [=]() { app->copyStyle( layer, category ); } ); copyStyleMenu->addAction( copyAction ); if ( category == QgsMapLayer::AllStyleCategories ) copyStyleMenu->addSeparator(); @@ -702,7 +679,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() } else { - menuStyleManager->addAction( tr( "Copy Style" ), app, [ = ] { app->copyStyle(); } ); + menuStyleManager->addAction( tr( "Copy Style" ), app, [=] { app->copyStyle(); } ); } if ( layer && app->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) ) @@ -728,12 +705,12 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() { const QModelIndex index = model->index( row, 0 ); const QgsMapLayer::StyleCategory category = model->data( index, Qt::UserRole ).value(); - const QString name = model->data( index, static_cast< int >( QgsMapLayerStyleCategoriesModel::Role::NameRole ) ).toString(); + const QString name = model->data( index, static_cast( QgsMapLayerStyleCategoriesModel::Role::NameRole ) ).toString(); const QString tooltip = model->data( index, Qt::ToolTipRole ).toString(); const QIcon icon = model->data( index, Qt::DecorationRole ).value(); QAction *pasteAction = new QAction( icon, name, pasteStyleMenu ); pasteAction->setToolTip( tooltip ); - connect( pasteAction, &QAction::triggered, this, [ = ]() {app->pasteStyle( layer, category );} ); + connect( pasteAction, &QAction::triggered, this, [=]() { app->pasteStyle( layer, category ); } ); pasteStyleMenu->addAction( pasteAction ); if ( category == QgsMapLayer::AllStyleCategories ) pasteStyleMenu->addSeparator(); @@ -745,7 +722,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() } else { - menuStyleManager->addAction( tr( "Paste Style" ), app, [ = ] { app->pasteStyle(); } ); + menuStyleManager->addAction( tr( "Paste Style" ), app, [=] { app->pasteStyle(); } ); } } @@ -754,10 +731,10 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( vlayer ) { - const QgsSingleSymbolRenderer *singleRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( vlayer->renderer() ); + const QgsSingleSymbolRenderer *singleRenderer = dynamic_cast( vlayer->renderer() ); if ( !singleRenderer && vlayer->renderer() && vlayer->renderer()->embeddedRenderer() ) { - singleRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( vlayer->renderer()->embeddedRenderer() ); + singleRenderer = dynamic_cast( vlayer->renderer()->embeddedRenderer() ); } if ( singleRenderer && singleRenderer->symbol() ) { @@ -788,27 +765,24 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() const QString layerId = vlayer->id(); QAction *editSymbolAction = new QAction( tr( "Edit Symbol…" ), menuStyleManager ); - connect( editSymbolAction, &QAction::triggered, this, [this, layerId] - { + connect( editSymbolAction, &QAction::triggered, this, [this, layerId] { editVectorSymbol( layerId ); } ); menuStyleManager->addAction( editSymbolAction ); QAction *copySymbolAction = new QAction( tr( "Copy Symbol" ), menuStyleManager ); - connect( copySymbolAction, &QAction::triggered, this, [this, layerId] - { + connect( copySymbolAction, &QAction::triggered, this, [this, layerId] { copyVectorSymbol( layerId ); } ); menuStyleManager->addAction( copySymbolAction ); bool enablePaste = false; - const std::unique_ptr< QgsSymbol > tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); + const std::unique_ptr tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); if ( tempSymbol ) enablePaste = true; QAction *pasteSymbolAction = new QAction( tr( "Paste Symbol" ), menuStyleManager ); - connect( pasteSymbolAction, &QAction::triggered, this, [this, layerId] - { + connect( pasteSymbolAction, &QAction::triggered, this, [this, layerId] { pasteVectorSymbol( layerId ); } ); pasteSymbolAction->setEnabled( enablePaste ); @@ -830,20 +804,15 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( layer ) { QAction *notes = new QAction( QgsLayerNotesUtils::layerHasNotes( layer ) ? tr( "Edit Layer Notes…" ) : tr( "Add Layer Notes…" ), menu ); - connect( notes, &QAction::triggered, this, [layer ] - { + connect( notes, &QAction::triggered, this, [layer] { QgsLayerNotesManager::editLayerNotes( layer, QgisApp::instance() ); } ); menu->addAction( notes ); if ( QgsLayerNotesUtils::layerHasNotes( layer ) ) { QAction *notes = new QAction( tr( "Remove Layer Notes" ), menu ); - connect( notes, &QAction::triggered, this, [layer ] - { - if ( QMessageBox::question( QgisApp::instance(), - tr( "Remove Layer Notes" ), - tr( "Are you sure you want to remove all notes for the layer “%1”?" ).arg( layer->name() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes ) + connect( notes, &QAction::triggered, this, [layer] { + if ( QMessageBox::question( QgisApp::instance(), tr( "Remove Layer Notes" ), tr( "Are you sure you want to remove all notes for the layer “%1”?" ).arg( layer->name() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes ) { QgsLayerNotesUtils::removeNotes( layer ); QgsProject::instance()->setDirty( true ); @@ -861,30 +830,26 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() { if ( node->flags() & Qt::ItemIsUserCheckable ) { - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleAllLayers.svg" ) ), tr( "&Toggle Items" ), - node, &QgsLayerTreeModelLegendNode::toggleAllItems ); - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowAllLayers.svg" ) ), tr( "&Show All Items" ), - node, &QgsLayerTreeModelLegendNode::checkAllItems ); - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionHideAllLayers.svg" ) ), tr( "&Hide All Items" ), - node, &QgsLayerTreeModelLegendNode::uncheckAllItems ); + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleAllLayers.svg" ) ), tr( "&Toggle Items" ), node, &QgsLayerTreeModelLegendNode::toggleAllItems ); + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowAllLayers.svg" ) ), tr( "&Show All Items" ), node, &QgsLayerTreeModelLegendNode::checkAllItems ); + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionHideAllLayers.svg" ) ), tr( "&Hide All Items" ), node, &QgsLayerTreeModelLegendNode::uncheckAllItems ); menu->addSeparator(); } - if ( QgsSymbolLegendNode *symbolNode = qobject_cast< QgsSymbolLegendNode * >( node ) ) + if ( QgsSymbolLegendNode *symbolNode = qobject_cast( node ) ) { // symbology item QgsMapLayer *layer = QgsLayerTree::toLayer( node->layerNode() )->layer(); const QString layerId = symbolNode->layerNode()->layerId(); - const QString ruleKey = symbolNode->data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(); + const QString ruleKey = symbolNode->data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(); if ( layer && layer->type() == Qgis::LayerType::Vector ) { QAction *selectMatching = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mIconSelected.svg" ) ), tr( "Select Features" ), menu ); menu->addAction( selectMatching ); - connect( selectMatching, &QAction::triggered, this, [layerId, ruleKey ] - { - if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( QgsProject::instance()->mapLayer( layerId ) ) ) + connect( selectMatching, &QAction::triggered, this, [layerId, ruleKey] { + if ( QgsVectorLayer *layer = qobject_cast( QgsProject::instance()->mapLayer( layerId ) ) ) { bool ok = false; QString filterExp = layer->renderer() ? layer->renderer()->legendKeyToExpression( ruleKey, layer, ok ) : QString(); @@ -902,15 +867,11 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() int count = layer->selectedFeatureCount(); if ( count > 0 ) { - QgisApp::instance()->messageBar()->pushMessage( QString(), - tr( "%n matching feature(s) selected", "matching features", count ), - Qgis::MessageLevel::Info ); + QgisApp::instance()->messageBar()->pushMessage( QString(), tr( "%n matching feature(s) selected", "matching features", count ), Qgis::MessageLevel::Info ); } else { - QgisApp::instance()->messageBar()->pushMessage( QString(), - tr( "No matching features found" ), - Qgis::MessageLevel::Info ); + QgisApp::instance()->messageBar()->pushMessage( QString(), tr( "No matching features found" ), Qgis::MessageLevel::Info ); } } } @@ -918,9 +879,8 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() QAction *showMatchingInAttributeTable = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/attributes.svg" ) ), tr( "Show in Attribute Table" ), menu ); menu->addAction( showMatchingInAttributeTable ); - connect( showMatchingInAttributeTable, &QAction::triggered, this, [layerId, ruleKey ] - { - if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( QgsProject::instance()->mapLayer( layerId ) ) ) + connect( showMatchingInAttributeTable, &QAction::triggered, this, [layerId, ruleKey] { + if ( QgsVectorLayer *layer = qobject_cast( QgsProject::instance()->mapLayer( layerId ) ) ) { bool ok = false; QString filterExp = layer->renderer() ? layer->renderer()->legendKeyToExpression( ruleKey, layer, ok ) : QString(); @@ -944,7 +904,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() //store the layer id and rule key in action, so we can later retrieve the corresponding //legend node, if it still exists colorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() ); - colorAction->setProperty( "ruleKey", symbolNode->data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString() ); + colorAction->setProperty( "ruleKey", symbolNode->data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString() ); menu->addAction( colorAction ); //add recent colors action @@ -954,7 +914,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() { QgsColorSwatchGridAction *recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menu, QStringLiteral( "symbology" ), menu ); recentColorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() ); - recentColorAction->setProperty( "ruleKey", symbolNode->data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString() ); + recentColorAction->setProperty( "ruleKey", symbolNode->data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString() ); recentColorAction->setDismissOnColorSelection( false ); menu->addAction( recentColorAction ); connect( recentColorAction, &QgsColorSwatchGridAction::colorChanged, this, &QgsAppLayerTreeViewMenuProvider::setSymbolLegendNodeColor ); @@ -966,16 +926,14 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( layer && layer->type() == Qgis::LayerType::Vector ) { QAction *editSymbolAction = new QAction( tr( "Edit Symbol…" ), menu ); - connect( editSymbolAction, &QAction::triggered, this, [this, layerId, ruleKey ] - { + connect( editSymbolAction, &QAction::triggered, this, [this, layerId, ruleKey] { editSymbolLegendNodeSymbol( layerId, ruleKey ); } ); menu->addAction( editSymbolAction ); } QAction *copySymbolAction = new QAction( tr( "Copy Symbol" ), menu ); - connect( copySymbolAction, &QAction::triggered, this, [this, layerId, ruleKey ] - { + connect( copySymbolAction, &QAction::triggered, this, [this, layerId, ruleKey] { copySymbolLegendNodeSymbol( layerId, ruleKey ); } ); menu->addAction( copySymbolAction ); @@ -983,13 +941,12 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() if ( layer && layer->type() == Qgis::LayerType::Vector ) { bool enablePaste = false; - const std::unique_ptr< QgsSymbol > tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); + const std::unique_ptr tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); if ( tempSymbol ) enablePaste = true; QAction *pasteSymbolAction = new QAction( tr( "Paste Symbol" ), menu ); - connect( pasteSymbolAction, &QAction::triggered, this, [this, layerId, ruleKey] - { + connect( pasteSymbolAction, &QAction::triggered, this, [this, layerId, ruleKey] { pasteSymbolLegendNodeSymbol( layerId, ruleKey ); } ); pasteSymbolAction->setEnabled( enablePaste ); @@ -1001,15 +958,14 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() return menu; } -void QgsAppLayerTreeViewMenuProvider::addLegendLayerAction( QAction *action, const QString &menu, - Qgis::LayerType type, bool allLayers ) +void QgsAppLayerTreeViewMenuProvider::addLegendLayerAction( QAction *action, const QString &menu, Qgis::LayerType type, bool allLayers ) { mLegendLayerActionMap[type].append( LegendLayerAction( action, menu, allLayers ) ); } bool QgsAppLayerTreeViewMenuProvider::removeLegendLayerAction( QAction *action ) { - QMap< Qgis::LayerType, QList< LegendLayerAction > >::iterator it; + QMap>::iterator it; for ( it = mLegendLayerActionMap.begin(); it != mLegendLayerActionMap.end(); ++it ) { @@ -1034,7 +990,7 @@ void QgsAppLayerTreeViewMenuProvider::addLegendLayerActionForLayer( QAction *act if ( !mLegendLayerActionMap.contains( layer->type() ) ) return; - const QMap< Qgis::LayerType, QList< LegendLayerAction > >::iterator it + const QMap>::iterator it = mLegendLayerActionMap.find( layer->type() ); for ( int i = 0; i < it->count(); i++ ) { @@ -1048,10 +1004,10 @@ void QgsAppLayerTreeViewMenuProvider::addLegendLayerActionForLayer( QAction *act void QgsAppLayerTreeViewMenuProvider::removeLegendLayerActionsForLayer( QgsMapLayer *layer ) { - if ( ! layer || ! mLegendLayerActionMap.contains( layer->type() ) ) + if ( !layer || !mLegendLayerActionMap.contains( layer->type() ) ) return; - const QMap< Qgis::LayerType, QList< LegendLayerAction > >::iterator it + const QMap>::iterator it = mLegendLayerActionMap.find( layer->type() ); for ( int i = 0; i < it->count(); i++ ) { @@ -1059,7 +1015,7 @@ void QgsAppLayerTreeViewMenuProvider::removeLegendLayerActionsForLayer( QgsMapLa } } -QList< LegendLayerAction > QgsAppLayerTreeViewMenuProvider::legendLayerActions( Qgis::LayerType type ) const +QList QgsAppLayerTreeViewMenuProvider::legendLayerActions( Qgis::LayerType type ) const { #ifdef QGISDEBUG if ( mLegendLayerActionMap.contains( type ) ) @@ -1075,7 +1031,7 @@ QList< LegendLayerAction > QgsAppLayerTreeViewMenuProvider::legendLayerActions( } #endif - return mLegendLayerActionMap.contains( type ) ? mLegendLayerActionMap.value( type ) : QList< LegendLayerAction >(); + return mLegendLayerActionMap.contains( type ) ? mLegendLayerActionMap.value( type ) : QList(); } void QgsAppLayerTreeViewMenuProvider::addCustomLayerActions( QMenu *menu, QgsMapLayer *layer ) @@ -1084,9 +1040,9 @@ void QgsAppLayerTreeViewMenuProvider::addCustomLayerActions( QMenu *menu, QgsMap return; // add custom layer actions - should this go at end? - QList< LegendLayerAction > lyrActions = legendLayerActions( layer->type() ); + QList lyrActions = legendLayerActions( layer->type() ); - if ( ! lyrActions.isEmpty() ) + if ( !lyrActions.isEmpty() ) { menu->addSeparator(); QList menus; @@ -1130,7 +1086,7 @@ void QgsAppLayerTreeViewMenuProvider::addCustomLayerActions( QMenu *menu, QgsMap break; } } - if ( ! newMenu ) + if ( !newMenu ) { // It doesn't exist, so create newMenu = new QMenu( menuName ); @@ -1153,15 +1109,15 @@ void QgsAppLayerTreeViewMenuProvider::editVectorSymbol( const QString &layerId ) if ( !layer ) return; - QgsSingleSymbolRenderer *singleRenderer = dynamic_cast< QgsSingleSymbolRenderer * >( layer->renderer() ); - std::unique_ptr< QgsSymbol > newSymbol; + QgsSingleSymbolRenderer *singleRenderer = dynamic_cast( layer->renderer() ); + std::unique_ptr newSymbol; if ( singleRenderer && singleRenderer->symbol() ) newSymbol.reset( singleRenderer->symbol()->clone() ); const QgsSingleSymbolRenderer *embeddedRenderer = nullptr; if ( !newSymbol && layer->renderer() && layer->renderer()->embeddedRenderer() ) { - embeddedRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( layer->renderer()->embeddedRenderer() ); + embeddedRenderer = dynamic_cast( layer->renderer()->embeddedRenderer() ); if ( embeddedRenderer && embeddedRenderer->symbol() ) newSymbol.reset( embeddedRenderer->symbol()->clone() ); } @@ -1201,10 +1157,10 @@ void QgsAppLayerTreeViewMenuProvider::copyVectorSymbol( const QString &layerId ) if ( !layer ) return; - const QgsSingleSymbolRenderer *singleRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( layer->renderer() ); + const QgsSingleSymbolRenderer *singleRenderer = dynamic_cast( layer->renderer() ); if ( !singleRenderer && layer->renderer() && layer->renderer()->embeddedRenderer() ) { - singleRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( layer->renderer()->embeddedRenderer() ); + singleRenderer = dynamic_cast( layer->renderer()->embeddedRenderer() ); } if ( singleRenderer ) @@ -1219,7 +1175,7 @@ void QgsAppLayerTreeViewMenuProvider::pasteVectorSymbol( const QString &layerId if ( !layer ) return; - QgsSingleSymbolRenderer *singleRenderer = dynamic_cast< QgsSingleSymbolRenderer * >( layer->renderer() ); + QgsSingleSymbolRenderer *singleRenderer = dynamic_cast( layer->renderer() ); const QgsSymbol *originalSymbol = nullptr; if ( singleRenderer ) originalSymbol = singleRenderer->symbol(); @@ -1227,11 +1183,11 @@ void QgsAppLayerTreeViewMenuProvider::pasteVectorSymbol( const QString &layerId const QgsSingleSymbolRenderer *embeddedRenderer = nullptr; if ( !singleRenderer && layer->renderer() && layer->renderer()->embeddedRenderer() ) { - embeddedRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( layer->renderer()->embeddedRenderer() ); + embeddedRenderer = dynamic_cast( layer->renderer()->embeddedRenderer() ); if ( embeddedRenderer ) originalSymbol = embeddedRenderer->symbol(); } - std::unique_ptr< QgsSymbol > tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); + std::unique_ptr tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); if ( !tempSymbol ) return; @@ -1257,7 +1213,7 @@ void QgsAppLayerTreeViewMenuProvider::pasteVectorSymbol( const QString &layerId void QgsAppLayerTreeViewMenuProvider::setVectorSymbolColor( const QColor &color ) { - QAction *action = qobject_cast< QAction *>( sender() ); + QAction *action = qobject_cast( sender() ); if ( !action ) return; @@ -1266,7 +1222,7 @@ void QgsAppLayerTreeViewMenuProvider::setVectorSymbolColor( const QColor &color if ( !layer ) return; - QgsSingleSymbolRenderer *singleRenderer = dynamic_cast< QgsSingleSymbolRenderer * >( layer->renderer() ); + QgsSingleSymbolRenderer *singleRenderer = dynamic_cast( layer->renderer() ); QgsSymbol *newSymbol = nullptr; if ( singleRenderer && singleRenderer->symbol() ) @@ -1275,7 +1231,7 @@ void QgsAppLayerTreeViewMenuProvider::setVectorSymbolColor( const QColor &color const QgsSingleSymbolRenderer *embeddedRenderer = nullptr; if ( !newSymbol && layer->renderer()->embeddedRenderer() ) { - embeddedRenderer = dynamic_cast< const QgsSingleSymbolRenderer * >( layer->renderer()->embeddedRenderer() ); + embeddedRenderer = dynamic_cast( layer->renderer()->embeddedRenderer() ); if ( embeddedRenderer && embeddedRenderer->symbol() ) newSymbol = embeddedRenderer->symbol()->clone(); } @@ -1314,7 +1270,7 @@ void QgsAppLayerTreeViewMenuProvider::editSymbolLegendNodeSymbol( const QString return; } - std::unique_ptr< QgsSymbol > symbol( originalSymbol->clone() ); + std::unique_ptr symbol( originalSymbol->clone() ); QgsVectorLayer *vlayer = qobject_cast( node->layerNode()->layer() ); QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, mView->window() ); dlg.setWindowTitle( tr( "Symbol Selector" ) ); @@ -1358,7 +1314,7 @@ void QgsAppLayerTreeViewMenuProvider::pasteSymbolLegendNodeSymbol( const QString QgsVectorLayer *vlayer = qobject_cast( node->layerNode()->layer() ); - std::unique_ptr< QgsSymbol > tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); + std::unique_ptr tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) ); if ( tempSymbol && tempSymbol->type() == originalSymbol->type() ) { node->setSymbol( tempSymbol.release() ); @@ -1372,7 +1328,7 @@ void QgsAppLayerTreeViewMenuProvider::pasteSymbolLegendNodeSymbol( const QString void QgsAppLayerTreeViewMenuProvider::setSymbolLegendNodeColor( const QColor &color ) { - QAction *action = qobject_cast< QAction *>( sender() ); + QAction *action = qobject_cast( sender() ); if ( !action ) return; @@ -1387,7 +1343,7 @@ void QgsAppLayerTreeViewMenuProvider::setSymbolLegendNodeColor( const QColor &co if ( !originalSymbol ) return; - std::unique_ptr< QgsSymbol > newSymbol( originalSymbol->clone() ); + std::unique_ptr newSymbol( originalSymbol->clone() ); newSymbol->setColor( color ); node->setSymbol( newSymbol.release() ); if ( QgsVectorLayer *layer = QgsProject::instance()->mapLayer( layerId ) ) @@ -1432,7 +1388,7 @@ void QgsAppLayerTreeViewMenuProvider::toggleLabels( bool enabled ) const QList selectedLayerNodes = mView->selectedLayerNodes(); for ( QgsLayerTreeLayer *l : selectedLayerNodes ) { - if ( QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( l->layer() ) ) + if ( QgsVectorLayer *vlayer = qobject_cast( l->layer() ) ) { if ( !vlayer->isSpatial() ) continue; @@ -1451,13 +1407,13 @@ void QgsAppLayerTreeViewMenuProvider::toggleLabels( bool enabled ) vlayer->emitStyleChanged(); vlayer->triggerRepaint(); } - else if ( QgsVectorTileLayer *vectorTilelayer = qobject_cast< QgsVectorTileLayer * >( l->layer() ) ) + else if ( QgsVectorTileLayer *vectorTilelayer = qobject_cast( l->layer() ) ) { vectorTilelayer->setLabelsEnabled( enabled ); vectorTilelayer->emitStyleChanged(); vectorTilelayer->triggerRepaint(); } - else if ( QgsMeshLayer *meshLayer = qobject_cast< QgsMeshLayer * >( l->layer() ) ) + else if ( QgsMeshLayer *meshLayer = qobject_cast( l->layer() ) ) { meshLayer->setLabelsEnabled( enabled ); meshLayer->emitStyleChanged(); diff --git a/src/app/qgsapplayertreeviewmenuprovider.h b/src/app/qgsapplayertreeviewmenuprovider.h index e3b7afabf76e..1a0f3a7c0144 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.h +++ b/src/app/qgsapplayertreeviewmenuprovider.h @@ -25,15 +25,15 @@ class QgsCoordinateReferenceSystem; struct LegendLayerAction { - LegendLayerAction( QAction *a, const QString &m, bool all ) - : action( a ) - , menu( m ) - , allLayers( all ) - {} - QAction *action = nullptr; - QString menu; - bool allLayers; - QList layers; + LegendLayerAction( QAction *a, const QString &m, bool all ) + : action( a ) + , menu( m ) + , allLayers( all ) + {} + QAction *action = nullptr; + QString menu; + bool allLayers; + QList layers; }; class QgsMapCanvas; @@ -46,21 +46,19 @@ class QgsAppLayerTreeViewMenuProvider : public QObject, public QgsLayerTreeViewM QMenu *createContextMenu() override; - void addLegendLayerAction( QAction *action, const QString &menu, - Qgis::LayerType type, bool allLayers ); + void addLegendLayerAction( QAction *action, const QString &menu, Qgis::LayerType type, bool allLayers ); bool removeLegendLayerAction( QAction *action ); void addLegendLayerActionForLayer( QAction *action, QgsMapLayer *layer ); void removeLegendLayerActionsForLayer( QgsMapLayer *layer ); - QList< LegendLayerAction > legendLayerActions( Qgis::LayerType type ) const; + QList legendLayerActions( Qgis::LayerType type ) const; protected: - void addCustomLayerActions( QMenu *menu, QgsMapLayer *layer ); QgsLayerTreeView *mView = nullptr; QgsMapCanvas *mCanvas = nullptr; - QMap< Qgis::LayerType, QList< LegendLayerAction > > mLegendLayerActionMap; + QMap> mLegendLayerActionMap; private slots: @@ -74,6 +72,7 @@ class QgsAppLayerTreeViewMenuProvider : public QObject, public QgsLayerTreeViewM void setSymbolLegendNodeColor( const QColor &color ); void setLayerCrs( const QgsCoordinateReferenceSystem &crs ); void toggleLabels( bool enabled ); + private: bool removeActionEnabled(); }; diff --git a/src/app/qgsappscreenshots.cpp b/src/app/qgsappscreenshots.cpp index 94c64ea6d531..dd44c56a9181 100644 --- a/src/app/qgsappscreenshots.cpp +++ b/src/app/qgsappscreenshots.cpp @@ -63,10 +63,7 @@ QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory ) mLineLayer->addJoin( join ); // add layers to project - QgsProject::instance()->addMapLayers( QList() - << mLineLayer - << mPolygonLayer - << mRasterLayer ); + QgsProject::instance()->addMapLayers( QList() << mLineLayer << mPolygonLayer << mRasterLayer ); } QPixmap QgsAppScreenShots::takeScreenshot( QWidget *widget, GrabMode mode, QRect crop, bool gradient ) @@ -94,10 +91,7 @@ QPixmap QgsAppScreenShots::takeScreenshot( QWidget *widget, GrabMode mode, QRect if ( !geom.isEmpty() ) { const qreal dpr = scr->devicePixelRatio(); - pixmap = pixmap.copy( static_cast( geom.x() * dpr ), - static_cast( geom.y() * dpr ), - static_cast( geom.width() * dpr ), - static_cast( geom.height() * dpr ) ); + pixmap = pixmap.copy( static_cast( geom.x() * dpr ), static_cast( geom.y() * dpr ), static_cast( geom.width() * dpr ), static_cast( geom.height() * dpr ) ); } } @@ -115,10 +109,7 @@ QPixmap QgsAppScreenShots::takeScreenshot( QWidget *widget, GrabMode mode, QRect if ( !crop.isEmpty() ) { const qreal dpr = scr->devicePixelRatio(); - crop = QRect( static_cast( crop.x() * dpr ), - static_cast( crop.y() * dpr ), - static_cast( crop.width() * dpr ), - static_cast( crop.height() * dpr ) ); + crop = QRect( static_cast( crop.x() * dpr ), static_cast( crop.y() * dpr ), static_cast( crop.width() * dpr ), static_cast( crop.height() * dpr ) ); pixmap = pixmap.copy( crop ); } @@ -154,7 +145,7 @@ void QgsAppScreenShots::saveScreenshot( QPixmap &pixmap, const QString &name, co } const QDir directory( topDirectory.absolutePath() + "/" + folder ); - const QString fileName = directory.absolutePath() + "/" + name + ".png"; + const QString fileName = directory.absolutePath() + "/" + name + ".png"; if ( !directory.exists() ) { if ( !topDirectory.mkpath( folder ) ) @@ -277,8 +268,7 @@ void QgsAppScreenShots::takeVectorLayerProperties25DSymbol() QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties( QgisApp::instance()->mapCanvas(), QgisApp::instance()->visibleMessageBar(), mPolygonLayer, QgisApp::instance() ); dlg->show(); dlg->mOptionsListWidget->setCurrentRow( 2 ); - Q_ASSERT( dlg->mOptionsListWidget->currentItem()->icon().pixmap( 24, 24 ).toImage() - == QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/symbology.svg" ) ).pixmap( 24, 24 ).toImage() ); + Q_ASSERT( dlg->mOptionsListWidget->currentItem()->icon().pixmap( 24, 24 ).toImage() == QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/symbology.svg" ) ).pixmap( 24, 24 ).toImage() ); const int idx = dlg->mRendererDialog->cboRenderers->findData( QLatin1String( "25dRenderer" ) ); Q_ASSERT( idx >= 0 ); dlg->mRendererDialog->cboRenderers->setCurrentIndex( idx ); @@ -321,9 +311,8 @@ void QgsAppScreenShots::takeGlobalOptions() // advanced settings dlg->mOptionsStackedWidget->setCurrentIndex( dlg->mOptionsStackedWidget->count() - 1 ); QCoreApplication::processEvents(); - Q_ASSERT( dlg->mOptTreeView->currentIndex().data( Qt::DecorationRole ).value< QIcon >().pixmap( 24, 24 ).toImage() - == QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ).pixmap( 24, 24 ).toImage() ); - QWidget *editor = dlg->findChild< QWidget * >( QStringLiteral( "mAdvancedSettingsEditor" ) ); + Q_ASSERT( dlg->mOptTreeView->currentIndex().data( Qt::DecorationRole ).value().pixmap( 24, 24 ).toImage() == QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ).pixmap( 24, 24 ).toImage() ); + QWidget *editor = dlg->findChild( QStringLiteral( "mAdvancedSettingsEditor" ) ); if ( editor ) editor->show(); QCoreApplication::processEvents(); diff --git a/src/app/qgsappsslerrorhandler.cpp b/src/app/qgsappsslerrorhandler.cpp index 97c13d79e0dd..df84959e1b56 100644 --- a/src/app/qgsappsslerrorhandler.cpp +++ b/src/app/qgsappsslerrorhandler.cpp @@ -26,13 +26,13 @@ void QgsAppSslErrorHandler::handleSslErrors( QNetworkReply *reply, const QListthread() ); const QString hostport( QStringLiteral( "%1:%2" ) - .arg( reply->url().host() ) - .arg( reply->url().port() != -1 ? reply->url().port() : 443 ) - .trimmed() ); + .arg( reply->url().host() ) + .arg( reply->url().port() != -1 ? reply->url().port() : 443 ) + .trimmed() ); const QString digest( QgsAuthCertUtils::shaHexForCert( reply->sslConfiguration().peerCertificate() ) ); const QString dgsthostport( QStringLiteral( "%1:%2" ).arg( digest, hostport ) ); - const QHash > &errscache( QgsApplication::authManager()->ignoredSslErrorCache() ); + const QHash> &errscache( QgsApplication::authManager()->ignoredSslErrorCache() ); if ( errscache.contains( dgsthostport ) ) { @@ -58,9 +58,7 @@ void QgsAppSslErrorHandler::handleSslErrors( QNetworkReply *reply, const QListrequest().url().toString() ) ); diff --git a/src/app/qgsappsslerrorhandler.h b/src/app/qgsappsslerrorhandler.h index 564d023d8c7a..10640da0fc4b 100644 --- a/src/app/qgsappsslerrorhandler.h +++ b/src/app/qgsappsslerrorhandler.h @@ -19,11 +19,8 @@ class QgsAppSslErrorHandler : public QgsSslErrorHandler { - public: - void handleSslErrors( QNetworkReply *reply, const QList &errors ) override; - }; diff --git a/src/app/qgsappwindowmanager.h b/src/app/qgsappwindowmanager.h index dedd725be2a3..d5f6888da510 100644 --- a/src/app/qgsappwindowmanager.h +++ b/src/app/qgsappwindowmanager.h @@ -31,11 +31,10 @@ class Qgs3DViewsManagerDialog; class QgsAppWindowManager : public QgsWindowManagerInterface { public: - //! Application-only QGIS dialogs enum ApplicationDialog { - DialogLayoutManager = 0, //!< Layout manager dialog + DialogLayoutManager = 0, //!< Layout manager dialog Dialog3DMapViewsManager = 1, //!< 3D map views manager dialog }; @@ -55,10 +54,9 @@ class QgsAppWindowManager : public QgsWindowManagerInterface QWidget *openApplicationDialog( ApplicationDialog dialog ); private: - QPointer< QgsStyleManagerDialog > mStyleManagerDialog; - QPointer< QgsLayoutManagerDialog > mLayoutManagerDialog; - QPointer< Qgs3DViewsManagerDialog > m3DMapViewsManagerDialog; - + QPointer mStyleManagerDialog; + QPointer mLayoutManagerDialog; + QPointer m3DMapViewsManagerDialog; }; diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp index 683737845324..789f3ef83ba0 100644 --- a/src/app/qgsattributetabledialog.cpp +++ b/src/app/qgsattributetabledialog.cpp @@ -94,7 +94,7 @@ void QgsAttributeTableDialog::readXml( const QDomElement &element ) void QgsAttributeTableDialog::updateMultiEditButtonState() { - if ( ! mLayer || ( mLayer->editFormConfig().layout() == Qgis::AttributeFormLayout::UiFile ) ) + if ( !mLayer || ( mLayer->editFormConfig().layout() == Qgis::AttributeFormLayout::UiFile ) ) return; mActionToggleMultiEdit->setEnabled( mLayer->isEditable() ); @@ -160,8 +160,9 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr mActionAddFeature->menu()->addAction( mActionAddFeatureViaAttributeForm ); mActionAddFeature->setIcon( settings.value( QStringLiteral( "/qgis/attributeTableLastAddFeatureMethod" ) ) == QStringLiteral( "attributeForm" ) - ? mActionAddFeatureViaAttributeForm->icon() - : mActionAddFeatureViaAttributeTable->icon() ); + ? mActionAddFeatureViaAttributeForm->icon() + : mActionAddFeatureViaAttributeTable->icon() + ); // Fix selection color on losing focus (Windows) setStyleSheet( QgisApp::instance()->styleSheet() ); @@ -169,7 +170,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr setAttribute( Qt::WA_DeleteOnClose ); layout()->setContentsMargins( 0, 0, 0, 0 ); - static_cast< QGridLayout * >( layout() )->setVerticalSpacing( 0 ); + static_cast( layout() )->setVerticalSpacing( 0 ); int size = settings.value( QStringLiteral( "/qgis/toolbarIconSize" ), 16 ).toInt(); if ( size > 32 ) @@ -199,8 +200,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr QgsFeatureRequest request; bool needsGeom = false; - if ( mLayer && mLayer->geometryType() != Qgis::GeometryType::Null && - initialMode == QgsAttributeTableFilterModel::ShowVisible ) + if ( mLayer && mLayer->geometryType() != Qgis::GeometryType::Null && initialMode == QgsAttributeTableFilterModel::ShowVisible ) { QgsMapCanvas *mc = QgisApp::instance()->mapCanvas(); QgsRectangle extent( mc->mapSettings().mapToLayerCoordinates( layer, mc->extent() ) ); @@ -281,18 +281,15 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr connect( mMainView, &QgsDualView::formModeChanged, this, &QgsAttributeTableDialog::viewModeChanged ); // info from table to application - connect( this, &QgsAttributeTableDialog::saveEdits, this, [ = ] { QgisApp::instance()->saveEdits(); } ); + connect( this, &QgsAttributeTableDialog::saveEdits, this, [=] { QgisApp::instance()->saveEdits(); } ); const bool isDocked = initiallyDocked ? *initiallyDocked : settings.value( QStringLiteral( "qgis/dockAttributeTable" ), false ).toBool(); toggleShortcuts( !isDocked ); - mDockableWidgetHelper = new QgsDockableWidgetHelper( isDocked, windowTitle(), this, QgisApp::instance(), - Qt::BottomDockWidgetArea, QStringList(), !initiallyDocked, QStringLiteral( "Windows/BetterAttributeTable/geometry" ) ); - connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [ = ]() - { + mDockableWidgetHelper = new QgsDockableWidgetHelper( isDocked, windowTitle(), this, QgisApp::instance(), Qt::BottomDockWidgetArea, QStringList(), !initiallyDocked, QStringLiteral( "Windows/BetterAttributeTable/geometry" ) ); + connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [=]() { close(); } ); - connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::dockModeToggled, this, [ = ]( bool docked ) - { + connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::dockModeToggled, this, [=]( bool docked ) { if ( docked ) { toggleShortcuts( mDockableWidgetHelper->dockWidget()->isFloating() ); @@ -400,7 +397,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr connect( mRunFieldCalcSelected, &QAbstractButton::clicked, this, &QgsAttributeTableDialog::updateFieldFromExpressionSelected ); // NW TODO Fix in 2.6 - Doesn't work with field model for some reason. // connect( mUpdateExpressionText, SIGNAL( returnPressed() ), this, SLOT( updateFieldFromExpression() ) ); - connect( mUpdateExpressionText, static_cast < void ( QgsFieldExpressionWidget::* )( const QString &, bool ) > ( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsAttributeTableDialog::updateButtonStatus ); + connect( mUpdateExpressionText, static_cast( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsAttributeTableDialog::updateButtonStatus ); mUpdateExpressionText->setLayer( mLayer ); mUpdateExpressionText->setLeftHandButtonStyle( true ); @@ -409,7 +406,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr { initialView = settings.value( QStringLiteral( "qgis/attributeTableLastView" ), QgsDualView::AttributeTable ).toInt(); } - mMainView->setView( static_cast< QgsDualView::ViewMode >( initialView ) ); + mMainView->setView( static_cast( initialView ) ); mMainViewButtonGroup->button( initialView )->setChecked( true ); if ( QgsSettingsRegistryCore::settingsAutosizeAttributeTable->value() ) @@ -447,15 +444,15 @@ QgsAttributeTableDialog::~QgsAttributeTableDialog() void QgsAttributeTableDialog::updateTitle() { - if ( ! mLayer ) + if ( !mLayer ) { return; } const QString title = tr( " %1 — Features Total: %L2, Filtered: %L3, Selected: %L4" ) - .arg( mLayer->name() ) - .arg( std::max( static_cast< long long >( mMainView->featureCount() ), mLayer->featureCount() ) ) // layer count may be estimated, so use larger of the two - .arg( mMainView->filteredFeatureCount() ) - .arg( mLayer->selectedFeatureCount() ); + .arg( mLayer->name() ) + .arg( std::max( static_cast( mMainView->featureCount() ), mLayer->featureCount() ) ) // layer count may be estimated, so use larger of the two + .arg( mMainView->filteredFeatureCount() ) + .arg( mLayer->selectedFeatureCount() ); mDockableWidgetHelper->setWindowTitle( title ); if ( mMainView->filterMode() == QgsAttributeTableFilterModel::ShowAll ) @@ -557,14 +554,14 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer *layer, const { QgsField fld = layer->fields().at( fieldindex ); - QSet< QString >referencedColumns = exp.referencedColumns(); + QSet referencedColumns = exp.referencedColumns(); referencedColumns.insert( fld.name() ); // need existing column value to store old attribute when changing field values request.setSubsetOfAttributes( referencedColumns, layer->fields() ); //go through all the features and change the new attributes QgsFeatureIterator fit = layer->getFeatures( request ); - std::unique_ptr< QgsScopedProxyProgressTask > task = std::make_unique< QgsScopedProxyProgressTask >( tr( "Calculating field" ) ); + std::unique_ptr task = std::make_unique( tr( "Calculating field" ) ); long long count = !filteredIds.isEmpty() ? filteredIds.size() : layer->featureCount(); long long i = 0; @@ -578,13 +575,13 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer *layer, const } i++; - task->setProgress( i / static_cast< double >( count ) * 100 ); + task->setProgress( i / static_cast( count ) * 100 ); context.setFeature( feature ); context.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "row_number" ), rownum, true ) ); QVariant value = exp.evaluate( &context ); - ( void )fld.convertCompatible( value ); + ( void ) fld.convertCompatible( value ); // Bail if we have a update error if ( exp.hasEvalError() ) { @@ -791,7 +788,7 @@ void QgsAttributeTableDialog::mActionCopySelectedRows_triggered() QgsFeatureStore featureStore; featureStore.setFields( fields ); QgsFeatureIterator it = mLayer->getFeatures( QgsFeatureRequest( qgis::listToSet( featureIds ) ) - .setSubsetOfAttributes( fieldNames, mLayer->fields() ) ); + .setSubsetOfAttributes( fieldNames, mLayer->fields() ) ); QgsFeatureMap featureMap; QgsFeature feature; while ( it.nextFeature( feature ) ) @@ -859,7 +856,7 @@ void QgsAttributeTableDialog::mMainView_currentChanged( int viewMode ) mActionSearchForm->setChecked( false ); QgsSettings s; - s.setValue( QStringLiteral( "/qgis/attributeTableLastView" ), static_cast< int >( viewMode ) ); + s.setValue( QStringLiteral( "/qgis/attributeTableLastView" ), static_cast( viewMode ) ); } void QgsAttributeTableDialog::mActionToggleEditing_toggled( bool ) @@ -886,7 +883,7 @@ void QgsAttributeTableDialog::editingToggled() mActionToggleEditing->blockSignals( true ); mActionToggleEditing->setChecked( isEditable ); mActionSaveEdits->setEnabled( isEditable && mLayer->isModified() ); - mActionReload->setEnabled( ! isEditable ); + mActionReload->setEnabled( !isEditable ); updateMultiEditButtonState(); if ( isEditable ) { @@ -938,7 +935,6 @@ void QgsAttributeTableDialog::editingToggled() } mActionFeatureActions->setMenu( actionMenu ); } - } void QgsAttributeTableDialog::mActionAddAttribute_triggered() @@ -1032,8 +1028,7 @@ void QgsAttributeTableDialog::openConditionalStyles() mMainView->openConditionalStyles(); } -void QgsAttributeTableDialog::setFilterExpression( const QString &filterString, QgsAttributeForm::FilterType type, - bool alwaysShowFilter ) +void QgsAttributeTableDialog::setFilterExpression( const QString &filterString, QgsAttributeForm::FilterType type, bool alwaysShowFilter ) { mFeatureFilterWidget->setFilterExpression( filterString, type, alwaysShowFilter ); } @@ -1060,9 +1055,7 @@ void QgsAttributeTableDialog::deleteFeature( const QgsFeatureId fid ) } // for extra safety to make sure we know that the delete can have impact on children and joins - int res = QMessageBox::question( this, tr( "Delete at least %n feature(s) on other layer(s)", nullptr, childrenCount ), - tr( "Delete of feature on layer \"%1\", %2 as well and all of its other descendants.\nDelete these features?" ).arg( mLayer->name() ).arg( childrenInfo ), - QMessageBox::Yes | QMessageBox::No ); + int res = QMessageBox::question( this, tr( "Delete at least %n feature(s) on other layer(s)", nullptr, childrenCount ), tr( "Delete of feature on layer \"%1\", %2 as well and all of its other descendants.\nDelete these features?" ).arg( mLayer->name() ).arg( childrenInfo ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) return; } @@ -1088,15 +1081,15 @@ void QgsAttributeTableDialog::showContextMenu( QgsActionMenu *menu, const QgsFea { if ( mLayer->isEditable() ) { - QAction *qAction = menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteSelectedFeatures.svg" ) ), tr( "Delete Feature" ) ); + QAction *qAction = menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteSelectedFeatures.svg" ) ), tr( "Delete Feature" ) ); connect( qAction, &QAction::triggered, this, [this, fid]() { deleteFeature( fid ); } ); } } void QgsAttributeTableDialog::updateLayerModifiedActions() { - bool saveEnabled { mActionToggleEditing->isEnabled() &&mLayer->isEditable() &&mLayer->isModified() }; - if ( ! saveEnabled && mActionToggleEditing->isEnabled() ) + bool saveEnabled { mActionToggleEditing->isEnabled() && mLayer->isEditable() && mLayer->isModified() }; + if ( !saveEnabled && mActionToggleEditing->isEnabled() ) { for ( const auto &referencingLayer : std::as_const( mReferencingLayers ) ) { diff --git a/src/app/qgsattributetabledialog.h b/src/app/qgsattributetabledialog.h index adf66452fcd9..cf281528a81e 100644 --- a/src/app/qgsattributetabledialog.h +++ b/src/app/qgsattributetabledialog.h @@ -41,7 +41,6 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib Q_OBJECT public: - /** * Constructor * \param layer layer pointer @@ -49,12 +48,7 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib * \param parent parent object * \param flags window flags */ - QgsAttributeTableDialog( QgsVectorLayer *layer, - QgsAttributeTableFilterModel::FilterMode initialMode = QgsAttributeTableFilterModel::ShowAll, - QWidget *parent = nullptr, - Qt::WindowFlags flags = Qt::Window, - bool *initiallyDocked = nullptr, - const QString &filterExpression = QString() ); + QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttributeTableFilterModel::FilterMode initialMode = QgsAttributeTableFilterModel::ShowAll, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::Window, bool *initiallyDocked = nullptr, const QString &filterExpression = QString() ); ~QgsAttributeTableDialog() override; QgsExpressionContext createExpressionContext() const override; @@ -82,9 +76,7 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib * Sets the filter expression to filter visible features * \param filterString filter query string. QgsExpression compatible. */ - void setFilterExpression( const QString &filterString, - QgsAttributeForm::FilterType type = QgsAttributeForm::ReplaceFilter, - bool alwaysShowFilter = false ); + void setFilterExpression( const QString &filterString, QgsAttributeForm::FilterType type = QgsAttributeForm::ReplaceFilter, bool alwaysShowFilter = false ); /** * Set the view \a mode (e.g. attribute table or attribute editor). @@ -216,7 +208,6 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib void saveEdits( QgsMapLayer *layer ); protected: - /* * Handle KeyPress event of the window * \param event @@ -239,12 +230,12 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib QDialog *mDialog = nullptr; - QPointer< QgsVectorLayer > mLayer = nullptr; + QPointer mLayer = nullptr; void updateMultiEditButtonState(); void deleteFeature( QgsFeatureId fid ); void toggleShortcuts( bool enable ); - QList< QPointer< QgsVectorLayer> > mReferencingLayers; + QList> mReferencingLayers; QAction *mActionDockUndock = nullptr; QgsDockableWidgetHelper *mDockableWidgetHelper = nullptr; diff --git a/src/app/qgsbookmarkeditordialog.cpp b/src/app/qgsbookmarkeditordialog.cpp index 948cb27030aa..b9c95533aa62 100644 --- a/src/app/qgsbookmarkeditordialog.cpp +++ b/src/app/qgsbookmarkeditordialog.cpp @@ -107,4 +107,3 @@ void QgsBookmarkEditorDialog::onAccepted() QgsProject::instance()->bookmarkManager()->moveBookmark( bookmark.id(), QgsApplication::bookmarkManager() ); } } - diff --git a/src/app/qgsbookmarkeditordialog.h b/src/app/qgsbookmarkeditordialog.h index 4cd5c10032a1..5e7627facad0 100644 --- a/src/app/qgsbookmarkeditordialog.h +++ b/src/app/qgsbookmarkeditordialog.h @@ -33,12 +33,11 @@ class QgsMapCanvas; * \brief a dialog for editing bookmarks. * \since QGIS 3.10 */ -class APP_EXPORT QgsBookmarkEditorDialog: public QDialog, private Ui::QgsBookmarkEditorDialog +class APP_EXPORT QgsBookmarkEditorDialog : public QDialog, private Ui::QgsBookmarkEditorDialog { Q_OBJECT public: - enum SaveLocation { ApplicationManager = 1, // Bookmark saved in the application bookmark manager @@ -57,12 +56,10 @@ class APP_EXPORT QgsBookmarkEditorDialog: public QDialog, private Ui::QgsBookmar void showHelp(); private: - QgsBookmark mBookmark; bool mInProject = false; QgsMapCanvas *mMapCanvas = nullptr; - }; #endif // QGSBOOKMARKEDITORDIALOG_H diff --git a/src/app/qgsbookmarks.cpp b/src/app/qgsbookmarks.cpp index 4db35e7f4ad1..6357c206fa0a 100644 --- a/src/app/qgsbookmarks.cpp +++ b/src/app/qgsbookmarks.cpp @@ -54,7 +54,7 @@ QgsBookmarks::QgsBookmarks( QWidget *parent ) connect( lstBookmarks, &QTreeView::customContextMenuRequested, this, &QgsBookmarks::lstBookmarks_customContextMenuRequested ); bookmarksDockContents->layout()->setContentsMargins( 0, 0, 0, 0 ); - static_cast< QGridLayout * >( bookmarksDockContents->layout() )->setVerticalSpacing( 0 ); + static_cast( bookmarksDockContents->layout() )->setVerticalSpacing( 0 ); QToolButton *btnImpExp = new QToolButton; btnImpExp->setAutoRaise( true ); @@ -126,9 +126,7 @@ void QgsBookmarks::deleteClicked() return; // make sure the user really wants to delete these bookmarks - if ( QMessageBox::No == QMessageBox::question( this, tr( "Delete Bookmarks" ), - tr( "Are you sure you want to delete %n bookmark(s)?", "number of rows", rows.size() ), - QMessageBox::Yes | QMessageBox::No ) ) + if ( QMessageBox::No == QMessageBox::question( this, tr( "Delete Bookmarks" ), tr( "Are you sure you want to delete %n bookmark(s)?", "number of rows", rows.size() ), QMessageBox::Yes | QMessageBox::No ) ) return; // Remove in reverse order to keep the merged model indexes @@ -170,7 +168,7 @@ void QgsBookmarks::lstBookmarks_customContextMenuRequested( QPoint pos ) menu.addAction( actionDelete ); // Get the bookmark - const QString id = lstBookmarks->model()->data( index, static_cast< int >( QgsBookmarkManagerModel::CustomRole::Id ) ).toString(); + const QString id = lstBookmarks->model()->data( index, static_cast( QgsBookmarkManagerModel::CustomRole::Id ) ).toString(); QgsBookmark bookmark = QgsApplication::bookmarkManager()->bookmarkById( id ); bool inProject = false; if ( bookmark.id().isEmpty() ) @@ -181,8 +179,7 @@ void QgsBookmarks::lstBookmarks_customContextMenuRequested( QPoint pos ) // Add an edit action (similar to the one in QgsBookmarksItemGuiProvider) QAction *actionEdit = new QAction( tr( "Edit Spatial Bookmark…" ), &menu ); - connect( actionEdit, &QAction::triggered, this, [bookmark, inProject] - { + connect( actionEdit, &QAction::triggered, this, [bookmark, inProject] { QgsBookmarkEditorDialog *dlg = new QgsBookmarkEditorDialog( bookmark, inProject, QgisApp::instance(), QgisApp::instance()->mapCanvas() ); dlg->setAttribute( Qt::WA_DeleteOnClose ); dlg->show(); @@ -201,12 +198,12 @@ void QgsBookmarks::zoomToBookmark() void QgsBookmarks::zoomToBookmarkIndex( const QModelIndex &index ) { - const QgsReferencedRectangle rect = index.data( static_cast< int >( QgsBookmarkManagerModel::CustomRole::Extent ) ).value< QgsReferencedRectangle >(); + const QgsReferencedRectangle rect = index.data( static_cast( QgsBookmarkManagerModel::CustomRole::Extent ) ).value(); try { if ( QgisApp::instance()->mapCanvas()->setReferencedExtent( rect ) ) { - QgisApp::instance()->mapCanvas()->setRotation( index.data( static_cast< int >( QgsBookmarkManagerModel::CustomRole::Rotation ) ).toDouble() ); + QgisApp::instance()->mapCanvas()->setRotation( index.data( static_cast( QgsBookmarkManagerModel::CustomRole::Rotation ) ).toDouble() ); QgisApp::instance()->mapCanvas()->refresh(); } else @@ -225,8 +222,7 @@ void QgsBookmarks::importFromXml() const QgsSettings settings; const QString lastUsedDir = settings.value( QStringLiteral( "Windows/Bookmarks/LastUsedDirectory" ), QDir::homePath() ).toString(); - const QString fileName = QFileDialog::getOpenFileName( this, tr( "Import Bookmarks" ), lastUsedDir, - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( this, tr( "Import Bookmarks" ), lastUsedDir, tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -263,7 +259,6 @@ QMap QgsBookmarks::getIndexMap() } return map; - } void QgsBookmarks::exportToXml() @@ -271,8 +266,7 @@ void QgsBookmarks::exportToXml() QgsSettings settings; const QString lastUsedDir = settings.value( QStringLiteral( "Windows/Bookmarks/LastUsedDirectory" ), QDir::homePath() ).toString(); - QString fileName = QFileDialog::getSaveFileName( this, tr( "Export Bookmarks" ), lastUsedDir, - tr( "XML files (*.xml *.XML)" ) ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "Export Bookmarks" ), lastUsedDir, tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -284,15 +278,13 @@ void QgsBookmarks::exportToXml() fileName += QLatin1String( ".xml" ); } - if ( !QgsBookmarkManager::exportToFile( fileName, QList< const QgsBookmarkManager * >() << QgsApplication::bookmarkManager() - << QgsProject::instance()->bookmarkManager() ) ) + if ( !QgsBookmarkManager::exportToFile( fileName, QList() << QgsApplication::bookmarkManager() << QgsProject::instance()->bookmarkManager() ) ) { QgisApp::instance()->messageBar()->pushWarning( tr( "Export Bookmarks" ), tr( "Error exporting bookmark file" ) ); } else { - QgisApp::instance()->messageBar()->pushSuccess( tr( "Export Bookmarks" ), tr( "Successfully exported bookmarks to %2" ) - .arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) ); + QgisApp::instance()->messageBar()->pushSuccess( tr( "Export Bookmarks" ), tr( "Successfully exported bookmarks to %2" ).arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) ); } settings.setValue( QStringLiteral( "Windows/Bookmarks/LastUsedDirectory" ), QFileInfo( fileName ).path() ); @@ -305,7 +297,6 @@ void QgsBookmarks::exportToXml() QgsDoubleSpinBoxBookmarksDelegate::QgsDoubleSpinBoxBookmarksDelegate( QObject *parent, int decimals ) : QStyledItemDelegate( parent ), mDecimals( decimals == -1 ? QgsDoubleSpinBoxBookmarksDelegate::DEFAULT_DECIMAL_PLACES : decimals ) { - } QString QgsDoubleSpinBoxBookmarksDelegate::displayText( const QVariant &value, const QLocale &locale ) const diff --git a/src/app/qgsbookmarks.h b/src/app/qgsbookmarks.h index 8adfbf066192..9dbba34aacfa 100644 --- a/src/app/qgsbookmarks.h +++ b/src/app/qgsbookmarks.h @@ -37,19 +37,15 @@ class QgsDoubleSpinBoxBookmarksDelegate : public QStyledItemDelegate Q_OBJECT public: - explicit QgsDoubleSpinBoxBookmarksDelegate( QObject *parent = nullptr, int decimals = -1 ); QString displayText( const QVariant &value, const QLocale &locale ) const override; - QWidget *createEditor( QWidget *parent, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; - private: + QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; - static const int DEFAULT_DECIMAL_PLACES; + private: + static const int DEFAULT_DECIMAL_PLACES; int mDecimals; - }; @@ -79,7 +75,6 @@ class APP_EXPORT QgsBookmarks : public QgsDockWidget, private Ui::QgsBookmarksBa QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr; void saveWindowLocation(); - }; diff --git a/src/app/qgsclipboard.cpp b/src/app/qgsclipboard.cpp index c17e135dad55..1ed6d99c14c1 100644 --- a/src/app/qgsclipboard.cpp +++ b/src/app/qgsclipboard.cpp @@ -76,7 +76,7 @@ void QgsClipboard::replaceWithCopyOf( QgsVectorTileLayer *src ) // things are a bit tricky for vector tile features, as each will have different fields // so we build a "super set" of fields first, and then make sure each feature has that superset present - const QList< QgsFeature > selectedFeatures = src->selectedFeatures(); + const QList selectedFeatures = src->selectedFeatures(); QgsFields supersetFields; for ( const QgsFeature &feature : selectedFeatures ) { @@ -123,7 +123,7 @@ void QgsClipboard::replaceWithCopyOf( QgsFeatureStore &featureStore, QgsVectorLa void QgsClipboard::generateClipboardText( QString &textContent, QString &htmlContent ) const { - CopyFormat format = QgsSettings().enumValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT ); + CopyFormat format = QgsSettings().enumValue( QStringLiteral( "qgis/copyFeatureFormat" ), AttributesWithWKT ); textContent.clear(); htmlContent.clear(); @@ -148,7 +148,7 @@ void QgsClipboard::generateClipboardText( QString &textContent, QString &htmlCon // first do the field names if ( ( format == AttributesWithWKB ) || ( format == AttributesWithWKT ) ) { - const QLatin1String geometryHeading = format == AttributesWithWKB ? QLatin1String( "wkb_geom" ) : QLatin1String( "wkt_geom" ); + const QLatin1String geometryHeading = format == AttributesWithWKB ? QLatin1String( "wkb_geom" ) : QLatin1String( "wkt_geom" ); // only include the "wkx_geom" field IF we have other fields -- otherwise it's redundant and we should just set the clipboard to WKT/WKB text directly if ( !mFeatureFields.isEmpty() ) { @@ -307,20 +307,18 @@ QgsFeatureList QgsClipboard::stringToFeatureList( const QString &string, const Q return features; // Poor man's csv parser - bool isInsideQuotes {false}; + bool isInsideQuotes { false }; QgsAttributes attrs; QgsGeometry geom; QString attrVal; - bool isFirstLine {string.startsWith( QLatin1String( "wkt_geom" ) )}; + bool isFirstLine { string.startsWith( QLatin1String( "wkt_geom" ) ) }; // it seems there is no other way to check for header - const bool hasHeader{string.startsWith( QLatin1String( "wkt_geom" ) )}; + const bool hasHeader { string.startsWith( QLatin1String( "wkt_geom" ) ) }; QgsGeometry geometry; - bool setFields {fields.isEmpty()}; + bool setFields { fields.isEmpty() }; QgsFields fieldsFromClipboard; - auto parseFunc = [ & ]( const QChar & c ) - { - + auto parseFunc = [&]( const QChar &c ) { // parse geom only if it wasn't successfully set before if ( geometry.isNull() ) { @@ -331,7 +329,7 @@ QgsFeatureList QgsClipboard::stringToFeatureList( const QString &string, const Q { if ( attrVal != QLatin1String( "wkt_geom" ) ) // ignore this one { - fieldsFromClipboard.append( QgsField{attrVal, QMetaType::Type::QString } ); + fieldsFromClipboard.append( QgsField { attrVal, QMetaType::Type::QString } ); } } else // ... or value @@ -348,7 +346,7 @@ QgsFeatureList QgsClipboard::stringToFeatureList( const QString &string, const Q } else { - QgsFeature feature{setFields ? fieldsFromClipboard : fields}; + QgsFeature feature { setFields ? fieldsFromClipboard : fields }; feature.setGeometry( geometry ); if ( hasHeader || !geometry.isNull() ) { diff --git a/src/app/qgsclipboard.h b/src/app/qgsclipboard.h index e6366b680064..f7fb51cb01e6 100644 --- a/src/app/qgsclipboard.h +++ b/src/app/qgsclipboard.h @@ -50,14 +50,13 @@ class APP_EXPORT QgsClipboard : public QObject { Q_OBJECT public: - //! Available formats for copying features as text enum CopyFormat { - AttributesOnly, //!< Tab delimited text, attributes only + AttributesOnly, //!< Tab delimited text, attributes only AttributesWithWKT, //!< Tab delimited text, with geometry in WKT format AttributesWithWKB, //!< Tab delimited text, with geometry in WKB format - GeoJSON, //!< GeoJSON FeatureCollection format + GeoJSON, //!< GeoJSON FeatureCollection format }; Q_ENUM( CopyFormat ) @@ -153,7 +152,6 @@ class APP_EXPORT QgsClipboard : public QObject void changed(); private: - /** * Set system clipboard from previously set features. */ @@ -197,7 +195,6 @@ class APP_EXPORT QgsClipboard : public QObject bool mUseSystemClipboard = false; friend class TestQgisAppClipboard; - }; #endif diff --git a/src/app/qgscrashhandler.cpp b/src/app/qgscrashhandler.cpp index f7542c94d797..46ba32129e79 100644 --- a/src/app/qgscrashhandler.cpp +++ b/src/app/qgscrashhandler.cpp @@ -40,18 +40,18 @@ LONG WINAPI QgsCrashHandler::handle( LPEXCEPTION_POINTERS exception ) if ( !QgsApplication::isRunningFromBuildDir() ) { symbolPath = QStringLiteral( "%1\\pdb;http://msdl.microsoft.com/download/symbols;http://download.osgeo.org/osgeo4w/%2/symstores/%3" ) - .arg( getenv( "QGIS_PREFIX_PATH" ) ) - .arg( QSysInfo::WordSize == 64 ? QStringLiteral( "x86_64" ) : QStringLiteral( "x86" ) ) - .arg( QFileInfo( getenv( "QGIS_PREFIX_PATH" ) ).baseName() ); + .arg( getenv( "QGIS_PREFIX_PATH" ) ) + .arg( QSysInfo::WordSize == 64 ? QStringLiteral( "x86_64" ) : QStringLiteral( "x86" ) ) + .arg( QFileInfo( getenv( "QGIS_PREFIX_PATH" ) ).baseName() ); } else { symbolPath = QStringLiteral( "%1;%2;http://msdl.microsoft.com/download/symbols" ) - .arg( getenv( "QGIS_PDB_PATH" ) ) - .arg( QgsApplication::applicationDirPath() ); + .arg( getenv( "QGIS_PDB_PATH" ) ) + .arg( QgsApplication::applicationDirPath() ); } - QString ptrStr = QString( "0x%1" ).arg( ( quintptr )exception, QT_POINTER_SIZE * 2, 16, QChar( '0' ) ); + QString ptrStr = QString( "0x%1" ).arg( ( quintptr ) exception, QT_POINTER_SIZE * 2, 16, QChar( '0' ) ); handleCrash( processID, threadID, symbolPath, ptrStr ); return TRUE; @@ -63,9 +63,7 @@ void QgsCrashHandler::handle( int ) } #endif -void QgsCrashHandler::handleCrash( int processID, int threadID, - const QString &symbolPath, - const QString &ptrStr ) +void QgsCrashHandler::handleCrash( int processID, int threadID, const QString &symbolPath, const QString &ptrStr ) { QString fileName = QStandardPaths::standardLocations( QStandardPaths::TempLocation ).at( 0 ) + "/qgis-crash-info-" + QString::number( processID ); QgsDebugMsgLevel( fileName, 2 ); @@ -85,7 +83,8 @@ void QgsCrashHandler::handleCrash( int processID, int threadID, if ( QString( Qgis::devVersion() ) == QLatin1String( "exported" ) ) { reportData.append( QStringLiteral( "QGIS code branch: Release %1.%2" ) - .arg( Qgis::versionInt() / 10000 ).arg( Qgis::versionInt() / 100 % 100 ) ); + .arg( Qgis::versionInt() / 10000 ) + .arg( Qgis::versionInt() / 100 % 100 ) ); } else { diff --git a/src/app/qgscrashhandler.h b/src/app/qgscrashhandler.h index 97d5612960b1..29ac1c6cd9ac 100644 --- a/src/app/qgscrashhandler.h +++ b/src/app/qgscrashhandler.h @@ -30,9 +30,7 @@ */ class APP_EXPORT QgsCrashHandler { - public: - /** * This class doesn't need to be created by anyone as is only used to handle * crashes in the application. @@ -48,12 +46,7 @@ class APP_EXPORT QgsCrashHandler static QString sPythonCrashLogFile; private: - - static void handleCrash( int processId, - int threadId, - const QString &symbolPath, - const QString &ptrStr - ); + static void handleCrash( int processId, int threadId, const QString &symbolPath, const QString &ptrStr ); }; diff --git a/src/app/qgscustomization.cpp b/src/app/qgscustomization.cpp index 5d23192421a9..4739ae0f6e43 100644 --- a/src/app/qgscustomization.cpp +++ b/src/app/qgscustomization.cpp @@ -55,9 +55,9 @@ bool isInternalWidget( const QString &name ) #ifdef Q_OS_MACOS QgsCustomizationDialog::QgsCustomizationDialog( QWidget *parent, QSettings *settings ) - : QMainWindow( parent, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only + : QMainWindow( parent, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only #else -QgsCustomizationDialog::QgsCustomizationDialog( QWidget * parent, QSettings * settings ) +QgsCustomizationDialog::QgsCustomizationDialog( QWidget *parent, QSettings *settings ) : QMainWindow( parent ) #endif { @@ -80,14 +80,13 @@ QgsCustomizationDialog::QgsCustomizationDialog( QWidget * parent, QSettings * se myHeaders << tr( "Object name" ) << tr( "Label" ); treeWidget->setHeaderLabels( myHeaders ); - mLastDirSettingsName = QStringLiteral( "/UI/lastCustomizationDir" ); + mLastDirSettingsName = QStringLiteral( "/UI/lastCustomizationDir" ); //treeWidget->hideColumn(0) connect( buttonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked, this, &QgsCustomizationDialog::ok ); connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsCustomizationDialog::apply ); connect( buttonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked, this, &QgsCustomizationDialog::cancel ); connect( buttonBox->button( QDialogButtonBox::Reset ), &QAbstractButton::clicked, this, &QgsCustomizationDialog::reset ); connect( buttonBox->button( QDialogButtonBox::Help ), &QAbstractButton::clicked, this, &QgsCustomizationDialog::showHelp ); - } QTreeWidgetItem *QgsCustomizationDialog::item( const QString &path, QTreeWidgetItem *widgetItem ) @@ -98,7 +97,7 @@ QTreeWidgetItem *QgsCustomizationDialog::item( const QString &path, QTreeWidgetI QStringList names = pathCopy.split( '/' ); pathCopy = QStringList( names.mid( 1 ) ).join( QLatin1Char( '/' ) ); - if ( ! widgetItem ) + if ( !widgetItem ) { for ( int i = 0; i < treeWidget->topLevelItemCount(); ++i ) { @@ -139,9 +138,8 @@ bool QgsCustomizationDialog::filterItems( const QString &text ) mTreeInitialVisible.clear(); // initially hide everything - std::function< void( QTreeWidgetItem *, bool ) > setChildrenVisible; - setChildrenVisible = [this, &setChildrenVisible]( QTreeWidgetItem * item, bool visible ) - { + std::function setChildrenVisible; + setChildrenVisible = [this, &setChildrenVisible]( QTreeWidgetItem *item, bool visible ) { for ( int i = 0; i < item->childCount(); ++i ) setChildrenVisible( item->child( i ), visible ); mTreeInitialVisible.insert( item, !item->isHidden() ); @@ -211,7 +209,6 @@ void QgsCustomizationDialog::settingsToItem( const QString &path, QTreeWidgetIte void QgsCustomizationDialog::itemToSettings( const QString &path, QTreeWidgetItem *item, QSettings *settings ) { - QString objectName = item->text( 0 ); if ( objectName.isEmpty() ) return; // object is not identifiable @@ -284,9 +281,7 @@ void QgsCustomizationDialog::actionSave_triggered( bool checked ) QSettings mySettings; QString lastDir = mySettings.value( mLastDirSettingsName, QDir::homePath() ).toString(); - QString fileName = QFileDialog::getSaveFileName( this, - tr( "Choose a customization INI file" ), - lastDir, tr( "Customization files (*.ini)" ) ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "Choose a customization INI file" ), lastDir, tr( "Customization files (*.ini)" ) ); if ( fileName.isEmpty() ) { @@ -311,9 +306,7 @@ void QgsCustomizationDialog::actionLoad_triggered( bool checked ) QSettings mySettings; QString lastDir = mySettings.value( mLastDirSettingsName, QDir::homePath() ).toString(); - QString fileName = QFileDialog::getOpenFileName( this, - tr( "Choose a customization INI file" ), - lastDir, tr( "Customization files (*.ini)" ) ); + QString fileName = QFileDialog::getOpenFileName( this, tr( "Choose a customization INI file" ), lastDir, tr( "Customization files (*.ini)" ) ); if ( fileName.isEmpty() ) return; @@ -377,9 +370,8 @@ void QgsCustomizationDialog::init() QTreeWidgetItem *QgsCustomizationDialog::createTreeItemWidgets() { - QDomDocument myDoc( QStringLiteral( "QgsWidgets" ) ); - QFile myFile( QgsApplication::pkgDataPath() + "/resources/customization.xml" ); + QFile myFile( QgsApplication::pkgDataPath() + "/resources/customization.xml" ); if ( !myFile.open( QIODevice::ReadOnly ) ) { return nullptr; @@ -731,11 +723,11 @@ void QgsCustomization::createTreeItemBrowser() mBrowserItem = new QTreeWidgetItem( data ); QVector items; - items << QStringList( {QStringLiteral( "special:Home" ), tr( "Home Folder" )} ); - items << QStringList( {QStringLiteral( "special:ProjectHome" ), tr( "Project Home Folder" )} ); - items << QStringList( {QStringLiteral( "special:Favorites" ), tr( "Favorites Folder" )} ); - items << QStringList( {QStringLiteral( "special:Drives" ), tr( "Drive Folders (e.g. C:\\)" )} ); - items << QStringList( {QStringLiteral( "special:Volumes" ), tr( "Volume Folder (MacOS only)" )} ); + items << QStringList( { QStringLiteral( "special:Home" ), tr( "Home Folder" ) } ); + items << QStringList( { QStringLiteral( "special:ProjectHome" ), tr( "Project Home Folder" ) } ); + items << QStringList( { QStringLiteral( "special:Favorites" ), tr( "Favorites Folder" ) } ); + items << QStringList( { QStringLiteral( "special:Drives" ), tr( "Drive Folders (e.g. C:\\)" ) } ); + items << QStringList( { QStringLiteral( "special:Volumes" ), tr( "Volume Folder (MacOS only)" ) } ); const auto constProviders = QgsApplication::dataItemProviderRegistry()->providers(); for ( QgsDataItemProvider *pr : constProviders ) @@ -770,7 +762,6 @@ QgsCustomization *QgsCustomization::instance() QgsCustomization::QgsCustomization() : mStatusPath( QStringLiteral( "/Customization/status" ) ) { - QSettings settings; mEnabled = settings.value( QStringLiteral( "UI/Customization/enabled" ), "false" ).toString() == QLatin1String( "true" ); } @@ -1130,8 +1121,8 @@ void QgsCustomization::loadDefault() return; // Look for default - QString path = QgsApplication::pkgDataPath() + "/resources/customization.ini"; - if ( ! QFile::exists( path ) ) + QString path = QgsApplication::pkgDataPath() + "/resources/customization.ini"; + if ( !QFile::exists( path ) ) { QgsDebugMsgLevel( "Default customization not found in " + path, 2 ); return; diff --git a/src/app/qgscustomization.h b/src/app/qgscustomization.h index e4d9ec880cd6..783b8e8358f7 100644 --- a/src/app/qgscustomization.h +++ b/src/app/qgscustomization.h @@ -117,9 +117,9 @@ class APP_EXPORT QgsCustomization : public QObject public: enum Status { - NotSet = 0, - User = 1, // Set by user - Default = 2 // Default customization loaded and set + NotSet = 0, + User = 1, // Set by user + Default = 2 // Default customization loaded and set }; Q_ENUM( Status ) @@ -138,7 +138,7 @@ class APP_EXPORT QgsCustomization : public QObject void setEnabled( bool enabled ) { mEnabled = enabled; } bool isEnabled() const { return mEnabled; } - void setSettings( QSettings *settings ) { mSettings = settings ;} + void setSettings( QSettings *settings ) { mSettings = settings; } // Returns the path to the splash screen QString splashPath() const; @@ -174,7 +174,5 @@ class APP_EXPORT QgsCustomization : public QObject private: static QgsCustomization *sInstance; - }; #endif // QGSCUSTOMIZATION_H - diff --git a/src/app/qgsdatumtransformtablewidget.cpp b/src/app/qgsdatumtransformtablewidget.cpp index 18ce0d5b15d6..0a84e12049a8 100644 --- a/src/app/qgsdatumtransformtablewidget.cpp +++ b/src/app/qgsdatumtransformtablewidget.cpp @@ -74,7 +74,7 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role ) { QString sourceCrs; QString destinationCrs; - const QPair< QString, QString> crses = mTransformContext.coordinateOperations().keys().at( index.row() ); + const QPair crses = mTransformContext.coordinateOperations().keys().at( index.row() ); sourceCrs = crses.first; destinationCrs = crses.second; const QString proj = mTransformContext.coordinateOperations().value( crses ); @@ -135,7 +135,7 @@ QVariant QgsDatumTransformTableModel::headerData( int section, Qt::Orientation o case Qt::ToolTipRole: switch ( section ) { - case SourceCrsColumn : + case SourceCrsColumn: return tr( "Source CRS" ); case DestinationCrsColumn: return tr( "Destination CRS" ); @@ -175,8 +175,7 @@ QgsDatumTransformTableWidget::QgsDatumTransformTableWidget( QWidget *parent ) connect( mAddButton, &QToolButton::clicked, this, &QgsDatumTransformTableWidget::addDatumTransform ); connect( mRemoveButton, &QToolButton::clicked, this, &QgsDatumTransformTableWidget::removeDatumTransform ); - connect( mEditButton, &QToolButton::clicked, this, [ = ] - { + connect( mEditButton, &QToolButton::clicked, this, [=] { const QModelIndexList selectedIndexes = mTableView->selectionModel()->selectedIndexes(); if ( selectedIndexes.count() > 0 ) { @@ -186,8 +185,7 @@ QgsDatumTransformTableWidget::QgsDatumTransformTableWidget( QWidget *parent ) connect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsDatumTransformTableWidget::selectionChanged ); - connect( mTableView, &QTableView::doubleClicked, this, [ = ]( const QModelIndex & index ) - { + connect( mTableView, &QTableView::doubleClicked, this, [=]( const QModelIndex &index ) { editDatumTransform( index ); } ); mEditButton->setEnabled( false ); @@ -201,7 +199,7 @@ QgsDatumTransformTableWidget::~QgsDatumTransformTableWidget() void QgsDatumTransformTableWidget::addDatumTransform() { - QgsDatumTransformDialog dlg( QgsCoordinateReferenceSystem(), QgsCoordinateReferenceSystem(), true, false, false, QPair< int, int >(), nullptr, Qt::WindowFlags(), QString(), QgisApp::instance()->mapCanvas() ); + QgsDatumTransformDialog dlg( QgsCoordinateReferenceSystem(), QgsCoordinateReferenceSystem(), true, false, false, QPair(), nullptr, Qt::WindowFlags(), QString(), QgisApp::instance()->mapCanvas() ); if ( dlg.exec() ) { const QgsDatumTransformDialog::TransformInfo dt = dlg.selectedDatumTransform(); diff --git a/src/app/qgsdatumtransformtablewidget.h b/src/app/qgsdatumtransformtablewidget.h index 9f6d88c5fc70..d68ed5d5c44d 100644 --- a/src/app/qgsdatumtransformtablewidget.h +++ b/src/app/qgsdatumtransformtablewidget.h @@ -33,10 +33,9 @@ class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel { Q_OBJECT public: - enum TableColumns { - SourceCrsColumn = 0, + SourceCrsColumn = 0, DestinationCrsColumn, ProjDefinitionColumn, AllowFallbackColumn, @@ -62,7 +61,6 @@ class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel QVariant headerData( int section, Qt::Orientation orientation, int role ) const override; private: - QgsCoordinateTransformContext mTransformContext; }; diff --git a/src/app/qgsdelattrdialog.h b/src/app/qgsdelattrdialog.h index c9d1819982e0..bbf81a98c8eb 100644 --- a/src/app/qgsdelattrdialog.h +++ b/src/app/qgsdelattrdialog.h @@ -25,7 +25,7 @@ class QgsVectorLayer; -class APP_EXPORT QgsDelAttrDialog: public QDialog, private Ui::QgsDelAttrDialogBase +class APP_EXPORT QgsDelAttrDialog : public QDialog, private Ui::QgsDelAttrDialogBase { Q_OBJECT public: diff --git a/src/app/qgsdevtoolspanelwidget.cpp b/src/app/qgsdevtoolspanelwidget.cpp index 202b33777b71..e9621bac0b7f 100644 --- a/src/app/qgsdevtoolspanelwidget.cpp +++ b/src/app/qgsdevtoolspanelwidget.cpp @@ -32,22 +32,20 @@ QgsDevToolsPanelWidget::QgsDevToolsPanelWidget( const QListsetIconSize( QgisApp::instance()->iconSize( false ) ); - mOptionsListWidget->setMaximumWidth( static_cast< int >( mOptionsListWidget->iconSize().width() * 1.18 ) ); + mOptionsListWidget->setMaximumWidth( static_cast( mOptionsListWidget->iconSize().width() * 1.18 ) ); // Add embedded documentation mDocumentationPanel = new QgsDocumentationPanelWidget( this ); - addToolWidget( mDocumentationPanel ) ; + addToolWidget( mDocumentationPanel ); for ( QgsDevToolWidgetFactory *factory : factories ) addToolFactory( factory ); - connect( mOptionsListWidget, &QListWidget::currentRowChanged, this, [ = ]( int row ) - { + connect( mOptionsListWidget, &QListWidget::currentRowChanged, this, [=]( int row ) { setCurrentTool( row ); settingLastActiveTab->setValue( mOptionsListWidget->currentItem()->data( Qt::UserRole ).toString() ); } ); - } QgsDevToolsPanelWidget::~QgsDevToolsPanelWidget() = default; @@ -155,8 +153,7 @@ void QgsDevToolsPanelWidget::showApiDocumentation( if ( api == Qgis::DocumentationApi::PyQgis || api == Qgis::DocumentationApi::PyQgisSearch ) { QgsSettings settings; - baseUrl = settings.value( QStringLiteral( "qgis/PyQgisApiUrl" ), - QString( "https://qgis.org/pyqgis/%1/" ).arg( version ) ).toString(); + baseUrl = settings.value( QStringLiteral( "qgis/PyQgisApiUrl" ), QString( "https://qgis.org/pyqgis/%1/" ).arg( version ) ).toString(); } else { @@ -168,8 +165,7 @@ void QgsDevToolsPanelWidget::showApiDocumentation( else { QgsSettings settings; - baseUrl = settings.value( QStringLiteral( "qgis/QgisApiUrl" ), - QString( "https://qgis.org/api/%1/" ).arg( version ) ).toString(); + baseUrl = settings.value( QStringLiteral( "qgis/QgisApiUrl" ), QString( "https://qgis.org/api/%1/" ).arg( version ) ).toString(); } } } @@ -216,14 +212,13 @@ void QgsDevToolsPanelWidget::showApiDocumentation( { url = "file://" + QgsApplication::pkgDataPath() + "/doc/" + url; } - if ( QgsDockWidget *dock = QgisApp::instance()->findChild< QgsDockWidget * >( "DevTools" ) ) + if ( QgsDockWidget *dock = QgisApp::instance()->findChild( "DevTools" ) ) { dock->setUserVisible( true ); } showUrl( QUrl( url ) ); break; } - } void QgsDevToolsPanelWidget::showUrl( const QUrl &url ) diff --git a/src/app/qgsdevtoolspanelwidget.h b/src/app/qgsdevtoolspanelwidget.h index 4b482fd45433..8b990cbc965e 100644 --- a/src/app/qgsdevtoolspanelwidget.h +++ b/src/app/qgsdevtoolspanelwidget.h @@ -26,7 +26,6 @@ class APP_EXPORT QgsDevToolsPanelWidget : public QWidget, private Ui::QgsDevTool { Q_OBJECT public: - static inline QgsSettingsTreeNode *sTreeDevTools = QgsSettingsTree::sTreeApp->createChildNode( QStringLiteral( "devtools" ) ); static const QgsSettingsEntryString *settingLastActiveTab; @@ -54,8 +53,7 @@ class APP_EXPORT QgsDevToolsPanelWidget : public QWidget, private Ui::QgsDevTool void setCurrentTool( int row ); private: - - QMap< QgsDevToolWidgetFactory *, int> mFactoryPages; + QMap mFactoryPages; QgsDocumentationPanelWidget *mDocumentationPanel = nullptr; }; diff --git a/src/app/qgsdiscoverrelationsdialog.cpp b/src/app/qgsdiscoverrelationsdialog.cpp index 38b71e54694e..14664cc0fe97 100644 --- a/src/app/qgsdiscoverrelationsdialog.cpp +++ b/src/app/qgsdiscoverrelationsdialog.cpp @@ -28,8 +28,7 @@ QgsDiscoverRelationsDialog::QgsDiscoverRelationsDialog( const QList mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); mButtonBox->addButton( QDialogButtonBox::Help ); - connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "working_with_vector/attribute_table.html#defining-1-n-relation" ) ); } ); connect( mRelationsTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsDiscoverRelationsDialog::onSelectionChanged ); @@ -46,10 +45,8 @@ void QgsDiscoverRelationsDialog::addRelation( const QgsRelation &rel ) QString referencingFields, referencedFields; for ( int i = 0; i < rel.fieldPairs().count(); i++ ) { - referencingFields.append( QStringLiteral( "%1%2" ).arg( ( referencingFields.isEmpty() ? "" : ", " ), - rel.fieldPairs().at( i ).referencingField() ) ); - referencedFields.append( QStringLiteral( "%1%2" ).arg( ( referencedFields.isEmpty() ? "" : ", " ), - rel.fieldPairs().at( i ).referencedField() ) ); + referencingFields.append( QStringLiteral( "%1%2" ).arg( ( referencingFields.isEmpty() ? "" : ", " ), rel.fieldPairs().at( i ).referencingField() ) ); + referencedFields.append( QStringLiteral( "%1%2" ).arg( ( referencedFields.isEmpty() ? "" : ", " ), rel.fieldPairs().at( i ).referencedField() ) ); } const int row = mRelationsTable->rowCount(); diff --git a/src/app/qgsdiscoverrelationsdialog.h b/src/app/qgsdiscoverrelationsdialog.h index ae713f0951a9..097d8a4281d6 100644 --- a/src/app/qgsdiscoverrelationsdialog.h +++ b/src/app/qgsdiscoverrelationsdialog.h @@ -48,7 +48,6 @@ class APP_EXPORT QgsDiscoverRelationsDialog : public QDialog, private Ui::QgsDis QList mFoundRelations; void addRelation( const QgsRelation &rel ); - }; #endif // QGSDISCOVERRELATIONSDLG_H diff --git a/src/app/qgsdisplayangle.h b/src/app/qgsdisplayangle.h index 637dfd285720..29515ca79d29 100644 --- a/src/app/qgsdisplayangle.h +++ b/src/app/qgsdisplayangle.h @@ -22,7 +22,7 @@ class QgsMapTool; //! A class that displays results of angle measurements with the proper unit -class APP_EXPORT QgsDisplayAngle: public QDialog, private Ui::QgsDisplayAngleBase +class APP_EXPORT QgsDisplayAngle : public QDialog, private Ui::QgsDisplayAngleBase { Q_OBJECT diff --git a/src/app/qgsdxfexportdialog.cpp b/src/app/qgsdxfexportdialog.cpp index 9cf6b6a4fe0a..657dc5ab7cfa 100644 --- a/src/app/qgsdxfexportdialog.cpp +++ b/src/app/qgsdxfexportdialog.cpp @@ -89,7 +89,7 @@ void FieldSelectorDelegate::setEditorData( QWidget *editor, const QModelIndex &i if ( index.column() == LAYER_COL ) { - QgsFilterLineEdit *le = qobject_cast< QgsFilterLineEdit * >( editor ); + QgsFilterLineEdit *le = qobject_cast( editor ); if ( le ) { le->setText( index.data().toString() ); @@ -151,10 +151,10 @@ void FieldSelectorDelegate::setModelData( QWidget *editor, QAbstractItemModel *m QgsVectorLayer *FieldSelectorDelegate::indexToLayer( const QAbstractItemModel *model, const QModelIndex &index ) const { - const QgsLayerTreeProxyModel *proxy = qobject_cast< const QgsLayerTreeProxyModel *>( model ); + const QgsLayerTreeProxyModel *proxy = qobject_cast( model ); Q_ASSERT( proxy ); - const QgsVectorLayerAndAttributeModel *m = qobject_cast< const QgsVectorLayerAndAttributeModel *>( proxy->sourceModel() ); + const QgsVectorLayerAndAttributeModel *m = qobject_cast( proxy->sourceModel() ); Q_ASSERT( m ); return m->vectorLayer( proxy->mapToSource( index ) ); @@ -162,10 +162,10 @@ QgsVectorLayer *FieldSelectorDelegate::indexToLayer( const QAbstractItemModel *m int FieldSelectorDelegate::attributeIndex( const QAbstractItemModel *model, const QgsVectorLayer *vl ) const { - const QgsLayerTreeProxyModel *proxy = qobject_cast< const QgsLayerTreeProxyModel *>( model ); + const QgsLayerTreeProxyModel *proxy = qobject_cast( model ); Q_ASSERT( proxy ); - const QgsVectorLayerAndAttributeModel *m = qobject_cast< const QgsVectorLayerAndAttributeModel *>( proxy->sourceModel() ); + const QgsVectorLayerAndAttributeModel *m = qobject_cast( proxy->sourceModel() ); Q_ASSERT( m ); return m->attributeIndex( vl ); @@ -179,7 +179,7 @@ QgsVectorLayerAndAttributeModel::QgsVectorLayerAndAttributeModel( QgsLayerTree * retrieveAllLayers( rootNode, layerIds ); for ( const auto &id : std::as_const( layerIds ) ) { - const QgsVectorLayer *vLayer = qobject_cast< const QgsVectorLayer *>( QgsProject::instance()->mapLayer( id ) ); + const QgsVectorLayer *vLayer = qobject_cast( QgsProject::instance()->mapLayer( id ) ); if ( vLayer ) { mCreateDDBlockInfo[vLayer] = DEFAULT_DXF_DATA_DEFINED_BLOCKS; @@ -207,7 +207,7 @@ Qt::ItemFlags QgsVectorLayerAndAttributeModel::flags( const QModelIndex &index ) } else if ( index.column() == ALLOW_DD_SYMBOL_BLOCKS_COL ) { - return ( vl && vl->geometryType() == Qgis::GeometryType::Point ) ? Qt::ItemIsEnabled | Qt::ItemIsUserCheckable : Qt::ItemIsEnabled ; + return ( vl && vl->geometryType() == Qgis::GeometryType::Point ) ? Qt::ItemIsEnabled | Qt::ItemIsUserCheckable : Qt::ItemIsEnabled; } else if ( index.column() == MAXIMUM_DD_SYMBOL_BLOCKS_COL ) { @@ -312,7 +312,7 @@ QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex &idx, int role } else if ( role == Qt::DisplayRole && vl && mOverriddenName.contains( vl ) ) { - return mOverriddenName[ vl ]; + return mOverriddenName[vl]; } else { @@ -330,7 +330,7 @@ QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex &idx, int role if ( vl->fields().exists( idx ) ) return vl->fields().at( idx ).name(); else - return mOverriddenName.contains( vl ) ? mOverriddenName[ vl ] : vl->name(); + return mOverriddenName.contains( vl ) ? mOverriddenName[vl] : vl->name(); } if ( role == Qt::ToolTipRole ) @@ -387,7 +387,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q if ( role == Qt::CheckStateRole ) { int i = 0; - for ( i = 0; ; i++ ) + for ( i = 0;; i++ ) { QModelIndex child = QgsVectorLayerAndAttributeModel::index( i, 0, index ); if ( !child.isValid() ) @@ -414,7 +414,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q { if ( !value.toString().trimmed().isEmpty() && value.toString() != vl->name() ) { - mOverriddenName[ vl ] = value.toString(); + mOverriddenName[vl] = value.toString(); } else { @@ -430,7 +430,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q if ( vl ) { - mAttributeIdx[ vl ] = value.toInt(); + mAttributeIdx[vl] = value.toInt(); return true; } } @@ -438,7 +438,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q { if ( vl ) { - mCreateDDBlockInfo[ vl ] = value.toBool(); + mCreateDDBlockInfo[vl] = value.toBool(); return true; } } @@ -446,7 +446,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q { if ( vl ) { - mDDBlocksMaxNumberOfClasses[ vl ] = value.toInt(); + mDDBlocksMaxNumberOfClasses[vl] = value.toInt(); return true; } } @@ -455,10 +455,10 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q } -QList< QgsDxfExport::DxfLayer > QgsVectorLayerAndAttributeModel::layers() const +QList QgsVectorLayerAndAttributeModel::layers() const { - QList< QgsDxfExport::DxfLayer > layers; - QHash< QString, int > layerIdx; + QList layers; + QHash layerIdx; for ( const QModelIndex &idx : std::as_const( mCheckedLeafs ) ) { @@ -473,31 +473,23 @@ QList< QgsDxfExport::DxfLayer > QgsVectorLayerAndAttributeModel::layers() const if ( !layerIdx.contains( vl->id() ) ) { layerIdx.insert( vl->id(), layers.size() ); - layers << QgsDxfExport::DxfLayer( vl, - mAttributeIdx.value( vl, -1 ), - mCreateDDBlockInfo.value( vl, DEFAULT_DXF_DATA_DEFINED_BLOCKS ), - mDDBlocksMaxNumberOfClasses.value( vl, -1 ), - mOverriddenName.value( vl, QString() ) ); + layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ), mCreateDDBlockInfo.value( vl, DEFAULT_DXF_DATA_DEFINED_BLOCKS ), mDDBlocksMaxNumberOfClasses.value( vl, -1 ), mOverriddenName.value( vl, QString() ) ); } } } else if ( QgsLayerTree::isLayer( node ) ) { - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( QgsLayerTree::toLayer( node )->layer() ); + QgsVectorLayer *vl = qobject_cast( QgsLayerTree::toLayer( node )->layer() ); Q_ASSERT( vl ); if ( !layerIdx.contains( vl->id() ) ) { layerIdx.insert( vl->id(), layers.size() ); - layers << QgsDxfExport::DxfLayer( vl, - mAttributeIdx.value( vl, -1 ), - mCreateDDBlockInfo.value( vl, DEFAULT_DXF_DATA_DEFINED_BLOCKS ), - mDDBlocksMaxNumberOfClasses.value( vl, -1 ), - mOverriddenName.value( vl, QString() ) ); + layers << QgsDxfExport::DxfLayer( vl, mAttributeIdx.value( vl, -1 ), mCreateDDBlockInfo.value( vl, DEFAULT_DXF_DATA_DEFINED_BLOCKS ), mDDBlocksMaxNumberOfClasses.value( vl, -1 ), mOverriddenName.value( vl, QString() ) ); } } } - QList< QgsDxfExport::DxfLayer > layersInROrder; + QList layersInROrder; QList layerOrder = mRootNode->layerOrder(); @@ -558,7 +550,7 @@ void QgsVectorLayerAndAttributeModel::applyVisibility( QSet &visibleLay { if ( QgsLayerTree::isLayer( child ) ) { - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( QgsLayerTree::toLayer( child )->layer() ); + QgsVectorLayer *vl = qobject_cast( QgsLayerTree::toLayer( child )->layer() ); if ( vl ) { QModelIndex idx = node2index( child ); @@ -583,7 +575,7 @@ void QgsVectorLayerAndAttributeModel::loadLayersOutputAttribute( QgsLayerTreeNod { if ( QgsLayerTree::isLayer( child ) ) { - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( QgsLayerTree::toLayer( child )->layer() ); + QgsVectorLayer *vl = qobject_cast( QgsLayerTree::toLayer( child )->layer() ); if ( vl ) { QModelIndex idx = node2index( child ); @@ -631,7 +623,7 @@ void QgsVectorLayerAndAttributeModel::saveLayersOutputAttribute( QgsLayerTreeNod { if ( QgsLayerTree::isLayer( child ) ) { - QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( QgsLayerTree::toLayer( child )->layer() ); + QgsVectorLayer *vl = qobject_cast( QgsLayerTree::toLayer( child )->layer() ); if ( vl ) { QModelIndex idx = node2index( child ); @@ -779,8 +771,7 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f ) connect( mDeselectDataDefinedBlocks, &QAbstractButton::clicked, this, &QgsDxfExportDialog::deselectDataDefinedBlocks ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDxfExportDialog::showHelp ); - connect( mFileName, &QgsFileWidget::fileChanged, this, [ = ]( const QString & filePath ) - { + connect( mFileName, &QgsFileWidget::fileChanged, this, [=]( const QString &filePath ) { QgsSettings settings; QFileInfo tmplFileInfo( filePath ); settings.setValue( QStringLiteral( "qgis/lastDxfDir" ), tmplFileInfo.absolutePath() ); @@ -805,7 +796,7 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f ) mSelectedFeaturesOnly->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfSelectedFeaturesOnly" ), settings.value( QStringLiteral( "qgis/lastDxfSelectedFeaturesOnly" ), "false" ).toString() ) != QLatin1String( "false" ) ); mMTextCheckBox->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfUseMText" ), settings.value( QStringLiteral( "qgis/lastDxfUseMText" ), "true" ).toString() ) != QLatin1String( "false" ) ); mForce2d->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfForce2d" ), settings.value( QStringLiteral( "qgis/lastDxfForce2d" ), "false" ).toString() ) != QLatin1String( "false" ) ); - mHairlineWidthExportCheckBox->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfHairlineWidthExport" ), settings.value( QStringLiteral( "qgis/lastDxfHairlineWidthExport" ), "false" ).toString() ) != QLatin1String( "false" ) ); + mHairlineWidthExportCheckBox->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfHairlineWidthExport" ), settings.value( QStringLiteral( "qgis/lastDxfHairlineWidthExport" ), "false" ).toString() ) != QLatin1String( "false" ) ); QStringList ids = QgsProject::instance()->mapThemeCollection()->mapThemes(); ids.prepend( QString() ); @@ -814,9 +805,7 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f ) buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); - long crsid = QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfCrs" ), - settings.value( QStringLiteral( "qgis/lastDxfCrs" ), QString::number( QgsProject::instance()->crs().srsid() ) ).toString() - ).toLong(); + long crsid = QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfCrs" ), settings.value( QStringLiteral( "qgis/lastDxfCrs" ), QString::number( QgsProject::instance()->crs().srsid() ) ).toString() ).toLong(); mCRS = QgsCoordinateReferenceSystem::fromSrsId( crsid ); mCrsSelector->setCrs( mCRS ); mCrsSelector->setLayerCrs( mCRS ); @@ -863,10 +852,7 @@ void QgsDxfExportDialog::cleanGroup( QgsLayerTreeNode *node ) const auto constChildren = node->children(); for ( QgsLayerTreeNode *child : constChildren ) { - if ( QgsLayerTree::isLayer( child ) && - ( QgsLayerTree::toLayer( child )->layer()->type() != Qgis::LayerType::Vector || - ! QgsLayerTree::toLayer( child )->layer()->isSpatial() || - ! QgsLayerTree::toLayer( child )->layer()->isValid() ) ) + if ( QgsLayerTree::isLayer( child ) && ( QgsLayerTree::toLayer( child )->layer()->type() != Qgis::LayerType::Vector || !QgsLayerTree::toLayer( child )->layer()->isSpatial() || !QgsLayerTree::toLayer( child )->layer()->isValid() ) ) { toRemove << child; continue; @@ -907,9 +893,7 @@ void QgsDxfExportDialog::deselectDataDefinedBlocks() void QgsDxfExportDialog::loadSettingsFromFile() { - const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load DXF Export Settings" ), - QgsDxfExportDialog::settingsDxfLastSettingsDir->value(), - tr( "XML file" ) + " (*.xml)" ); + const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load DXF Export Settings" ), QgsDxfExportDialog::settingsDxfLastSettingsDir->value(), tr( "XML file" ) + " (*.xml)" ); if ( fileName.isNull() ) { return; @@ -934,9 +918,7 @@ void QgsDxfExportDialog::loadSettingsFromFile() file.close(); } - if ( QMessageBox::question( this, - tr( "DXF Export - Load from XML File" ), - tr( "Are you sure you want to load settings from XML? This will change some values in the DXF Export dialog." ) ) == QMessageBox::Yes ) + if ( QMessageBox::question( this, tr( "DXF Export - Load from XML File" ), tr( "Are you sure you want to load settings from XML? This will change some values in the DXF Export dialog." ) ) == QMessageBox::Yes ) { resultFlag = loadSettingsFromXML( domDocument, errorMessage ); if ( !resultFlag ) @@ -989,7 +971,7 @@ bool QgsDxfExportDialog::loadSettingsFromXML( QDomDocument &doc, QString &errorM element = dxfElement.namedItem( QStringLiteral( "crs" ) ).toElement(); value = QgsXmlUtils::readVariant( element.firstChildElement() ); if ( !value.isNull() ) - mCrsSelector->setCrs( value.value< QgsCoordinateReferenceSystem >() ); + mCrsSelector->setCrs( value.value() ); element = dxfElement.namedItem( QStringLiteral( "map_theme" ) ).toElement(); value = QgsXmlUtils::readVariant( element.firstChildElement() ); @@ -1067,9 +1049,7 @@ bool QgsDxfExportDialog::loadSettingsFromXML( QDomDocument &doc, QString &errorM void QgsDxfExportDialog::saveSettingsToFile() { - QString outputFileName = QFileDialog::getSaveFileName( this, tr( "Save DXF Export Settings as XML" ), - QgsDxfExportDialog::settingsDxfLastSettingsDir->value(), - tr( "XML file" ) + " (*.xml)" ); + QString outputFileName = QFileDialog::getSaveFileName( this, tr( "Save DXF Export Settings as XML" ), QgsDxfExportDialog::settingsDxfLastSettingsDir->value(), tr( "XML file" ) + " (*.xml)" ); // return dialog focus on Mac activateWindow(); raise(); @@ -1089,7 +1069,7 @@ void QgsDxfExportDialog::saveSettingsToFile() saveSettingsToXML( domDocument ); const QFileInfo fileInfo( outputFileName ); - const QFileInfo dirInfo( fileInfo.path() ); //excludes file name + const QFileInfo dirInfo( fileInfo.path() ); //excludes file name if ( !dirInfo.isWritable() ) { mMessageBar->pushInfo( tr( "Save DXF Export Settings" ), tr( "The directory containing your dataset needs to be writable!" ) ); @@ -1157,9 +1137,9 @@ void QgsDxfExportDialog::saveSettingsToXML( QDomDocument &doc ) const QDomElement layerElement = domDocument.createElement( QStringLiteral( "layer" ) ); vlRef.setLayer( dxfLayer.layer() ); vlRef.writeXml( layerElement, rwContext ); - layerElement.setAttribute( QStringLiteral( "attribute-index" ), dxfLayer.layerOutputAttributeIndex() ) ; - layerElement.setAttribute( QStringLiteral( "use_symbol_blocks" ), dxfLayer.buildDataDefinedBlocks() ) ; - layerElement.setAttribute( QStringLiteral( "max_number_of_classes" ), dxfLayer.dataDefinedBlocksMaximumNumberOfClasses() ) ; + layerElement.setAttribute( QStringLiteral( "attribute-index" ), dxfLayer.layerOutputAttributeIndex() ); + layerElement.setAttribute( QStringLiteral( "use_symbol_blocks" ), dxfLayer.buildDataDefinedBlocks() ); + layerElement.setAttribute( QStringLiteral( "max_number_of_classes" ), dxfLayer.dataDefinedBlocksMaximumNumberOfClasses() ); layersElement.appendChild( layerElement ); } dxfElement.appendChild( layersElement ); @@ -1193,7 +1173,7 @@ void QgsDxfExportDialog::saveSettingsToXML( QDomDocument &doc ) const } -QList< QgsDxfExport::DxfLayer > QgsDxfExportDialog::layers() const +QList QgsDxfExportDialog::layers() const { return mModel->layers(); } @@ -1217,7 +1197,7 @@ QString QgsDxfExportDialog::saveFile() const Qgis::FeatureSymbologyExport QgsDxfExportDialog::symbologyMode() const { - return mSymbologyModeComboBox->currentData().value< Qgis::FeatureSymbologyExport >(); + return mSymbologyModeComboBox->currentData().value(); } void QgsDxfExportDialog::setOkEnabled() @@ -1235,7 +1215,6 @@ void QgsDxfExportDialog::setOkEnabled() bool ok = ( fi.absoluteDir().exists() && !fi.baseName().isEmpty() ); btn->setEnabled( ok ); - } diff --git a/src/app/qgsdxfexportdialog.h b/src/app/qgsdxfexportdialog.h index ec61f043e7c6..f336dbfa17e8 100644 --- a/src/app/qgsdxfexportdialog.h +++ b/src/app/qgsdxfexportdialog.h @@ -45,6 +45,7 @@ class FieldSelectorDelegate : public QItemDelegate QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; void setEditorData( QWidget *editor, const QModelIndex &index ) const override; void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override; + private: QgsVectorLayer *indexToLayer( const QAbstractItemModel *model, const QModelIndex &index ) const; int attributeIndex( const QAbstractItemModel *model, const QgsVectorLayer *vl ) const; @@ -62,7 +63,7 @@ class QgsVectorLayerAndAttributeModel : public QgsLayerTreeModel Qt::ItemFlags flags( const QModelIndex &index ) const override; bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override; - QList< QgsDxfExport::DxfLayer > layers() const; + QList layers() const; void saveLayersOutputAttribute( QgsLayerTreeNode *node ); void loadLayersOutputAttribute( QgsLayerTreeNode *node ); @@ -80,7 +81,7 @@ class QgsVectorLayerAndAttributeModel : public QgsLayerTreeModel private: QHash mAttributeIdx; QHash mCreateDDBlockInfo; - QHash mDDBlocksMaxNumberOfClasses; + QHash mDDBlocksMaxNumberOfClasses; QHash mOverriddenName; QSet mCheckedLeafs; @@ -104,12 +105,12 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase Q_OBJECT public: static inline QgsSettingsTreeNode *sTreeAppDdxf = QgsSettingsTree::sTreeApp->createChildNode( QStringLiteral( "dxf" ) ); - static const inline QgsSettingsEntryString *settingsDxfLastSettingsDir = new QgsSettingsEntryString( QStringLiteral( "last-settings-dir" ), sTreeAppDdxf, QDir::homePath() ); + static const inline QgsSettingsEntryString *settingsDxfLastSettingsDir = new QgsSettingsEntryString( QStringLiteral( "last-settings-dir" ), sTreeAppDdxf, QDir::homePath() ); QgsDxfExportDialog( QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); ~QgsDxfExportDialog() override; - QList< QgsDxfExport::DxfLayer > layers() const; + QList layers() const; double symbologyScale() const; Qgis::FeatureSymbologyExport symbologyMode() const; diff --git a/src/app/qgselevationshadingrenderersettingswidget.cpp b/src/app/qgselevationshadingrenderersettingswidget.cpp index 323aa33e8bb5..710fa16108b1 100644 --- a/src/app/qgselevationshadingrenderersettingswidget.cpp +++ b/src/app/qgselevationshadingrenderersettingswidget.cpp @@ -21,13 +21,13 @@ #include "qgsproject.h" #include "qgselevationshadingrenderer.h" -QgsElevationShadingRendererSettingsWidget::QgsElevationShadingRendererSettingsWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent ) : - QgsMapLayerConfigWidget( layer, canvas, parent ) +QgsElevationShadingRendererSettingsWidget::QgsElevationShadingRendererSettingsWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent ) + : QgsMapLayerConfigWidget( layer, canvas, parent ) { setupUi( this ); mCombineMethodCombo->addItem( tr( "Highest Elevation" ), QVariant::fromValue( Qgis::ElevationMapCombineMethod::HighestElevation ) ); - mCombineMethodCombo->addItem( tr( "Based on Layer's Order" ), QVariant::fromValue( Qgis::ElevationMapCombineMethod::NewerElevation ) ); + mCombineMethodCombo->addItem( tr( "Based on Layer's Order" ), QVariant::fromValue( Qgis::ElevationMapCombineMethod::NewerElevation ) ); syncToProject(); @@ -35,18 +35,18 @@ QgsElevationShadingRendererSettingsWidget::QgsElevationShadingRendererSettingsWi connect( mShadingGroupBox, &QGroupBox::toggled, this, &QgsElevationShadingRendererSettingsWidget::onChanged ); - connect( mCombineMethodCombo, qOverload( &QComboBox::currentIndexChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); + connect( mCombineMethodCombo, qOverload( &QComboBox::currentIndexChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); mEdlDistanceSpinBox->setClearValue( 0.5 ); mEdlStrengthSpinBox->setClearValue( 1000 ); connect( mEdlGroupBox, &QGroupBox::toggled, this, &QgsElevationShadingRendererSettingsWidget::onChanged ); - connect( mEdlStrengthSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); - connect( mEdlDistanceSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); + connect( mEdlStrengthSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); + connect( mEdlDistanceSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); connect( mEdlDistanceUnit, &QgsUnitSelectionWidget::changed, this, &QgsElevationShadingRendererSettingsWidget::onChanged ); connect( mHillshadingGroupBox, &QGroupBox::toggled, this, &QgsElevationShadingRendererSettingsWidget::onChanged ); mHillshadingZFactorSpinBox->setClearValue( 1.0 ); - connect( mHillshadingZFactorSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); + connect( mHillshadingZFactorSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsElevationShadingRendererSettingsWidget::onChanged ); connect( mHillshadingMultidirCheckBox, &QCheckBox::toggled, this, &QgsElevationShadingRendererSettingsWidget::onChanged ); connect( mDirectionalLightWidget, &QgsDirectionalLightWidget::directionChanged, this, &QgsElevationShadingRendererSettingsWidget::onChanged ); @@ -78,19 +78,20 @@ void QgsElevationShadingRendererSettingsWidget::syncToProject() QgsElevationShadingRenderer shadingRenderer = QgsProject::instance()->elevationShadingRenderer(); mShadingGroupBox->setChecked( shadingRenderer.isActive() ); mCombineMethodCombo->setCurrentIndex( - mCombineMethodCombo->findData( QVariant::fromValue( shadingRenderer.combinedElevationMethod() ) ) ); + mCombineMethodCombo->findData( QVariant::fromValue( shadingRenderer.combinedElevationMethod() ) ) + ); mEdlGroupBox->setChecked( shadingRenderer.isActiveEyeDomeLighting() ); mEdlStrengthSpinBox->setValue( shadingRenderer.eyeDomeLightingStrength() ); mEdlDistanceSpinBox->setValue( shadingRenderer.eyeDomeLightingDistance() ); mEdlDistanceUnit->setUnits( - { - Qgis::RenderUnit::Millimeters, - Qgis::RenderUnit::MetersInMapUnits, - Qgis::RenderUnit::MapUnits, - Qgis::RenderUnit::Pixels, - Qgis::RenderUnit::Points, - Qgis::RenderUnit::Inches - } ); + { Qgis::RenderUnit::Millimeters, + Qgis::RenderUnit::MetersInMapUnits, + Qgis::RenderUnit::MapUnits, + Qgis::RenderUnit::Pixels, + Qgis::RenderUnit::Points, + Qgis::RenderUnit::Inches + } + ); mEdlDistanceUnit->setUnit( shadingRenderer.eyeDomeLightingDistanceUnit() ); mHillshadingGroupBox->setChecked( shadingRenderer.isActiveHillshading() ); mHillshadingMultidirCheckBox->setChecked( shadingRenderer.isHillshadingMultidirectional() ); @@ -110,7 +111,8 @@ void QgsElevationShadingRendererSettingsWidget::onChanged() emit widgetChanged(); } -QgsElevationShadingRendererSettingsWidgetFactory::QgsElevationShadingRendererSettingsWidgetFactory( QObject *parent ): QObject( parent ) +QgsElevationShadingRendererSettingsWidgetFactory::QgsElevationShadingRendererSettingsWidgetFactory( QObject *parent ) + : QObject( parent ) { setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mShadingRenderer.svg" ) ) ); setTitle( tr( "Shading Renderer" ) ); diff --git a/src/app/qgsfeatureaction.cpp b/src/app/qgsfeatureaction.cpp index ed5897a2dd03..4a66dbafbd91 100644 --- a/src/app/qgsfeatureaction.cpp +++ b/src/app/qgsfeatureaction.cpp @@ -73,7 +73,7 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature ) dialog->setWindowFlags( dialog->windowFlags() | Qt::Tool ); #else dialog->setWindowFlags( dialog->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint ); - if ( ! dialog->parent() ) + if ( !dialog->parent() ) dialog->setWindowFlag( Qt::WindowStaysOnTopHint ); #endif @@ -174,7 +174,7 @@ bool QgsFeatureAction::editFeature( bool showModal ) return true; } -QgsFeatureAction::AddFeatureResult QgsFeatureAction::addFeature( const QgsAttributeMap &defaultAttributes, bool showModal, std::unique_ptr< QgsExpressionContextScope > scope, bool hideParent, std::unique_ptr highlight ) +QgsFeatureAction::AddFeatureResult QgsFeatureAction::addFeature( const QgsAttributeMap &defaultAttributes, bool showModal, std::unique_ptr scope, bool hideParent, std::unique_ptr highlight ) { if ( !mLayer || !mLayer->isEditable() ) return AddFeatureResult::LayerStateError; @@ -191,12 +191,12 @@ QgsFeatureAction::AddFeatureResult QgsFeatureAction::addFeature( const QgsAttrib { initialAttributeValues.insert( idx, defaultAttributes.value( idx ) ); } - else if ( ( reuseAllLastValues || mLayer->editFormConfig().reuseLastValue( idx ) ) && sLastUsedValues()->contains( mLayer ) && ( *sLastUsedValues() )[ mLayer ].contains( idx ) ) + else if ( ( reuseAllLastValues || mLayer->editFormConfig().reuseLastValue( idx ) ) && sLastUsedValues()->contains( mLayer ) && ( *sLastUsedValues() )[mLayer].contains( idx ) ) { // Only set initial attribute value if it's different from the default clause or we may trigger // unique constraint checks for no reason, see https://github.com/qgis/QGIS/issues/42909 - if ( mLayer->dataProvider() && mLayer->dataProvider()->defaultValueClause( idx ) != ( *sLastUsedValues() )[ mLayer ][idx] ) - initialAttributeValues.insert( idx, ( *sLastUsedValues() )[ mLayer ][idx] ); + if ( mLayer->dataProvider() && mLayer->dataProvider()->defaultValueClause( idx ) != ( *sLastUsedValues() )[mLayer][idx] ) + initialAttributeValues.insert( idx, ( *sLastUsedValues() )[mLayer][idx] ); } } @@ -208,8 +208,7 @@ QgsFeatureAction::AddFeatureResult QgsFeatureAction::addFeature( const QgsAttrib context.appendScope( scope.release() ); } - const QgsFeature newFeature = QgsVectorLayerUtils::createFeature( mLayer, mFeature->geometry(), initialAttributeValues, - &context ); + const QgsFeature newFeature = QgsVectorLayerUtils::createFeature( mLayer, mFeature->geometry(), initialAttributeValues, &context ); *mFeature = newFeature; //show the dialog to enter attribute values @@ -323,11 +322,11 @@ void QgsFeatureAction::onFeatureSaved( const QgsFeature &feature ) for ( int idx = 0; idx < fields.count(); ++idx ) { const QgsAttributes newValues = feature.attributes(); - QgsAttributeMap origValues = ( *sLastUsedValues() )[ mLayer ]; + QgsAttributeMap origValues = ( *sLastUsedValues() )[mLayer]; if ( origValues[idx] != newValues.at( idx ) ) { - QgsDebugMsgLevel( QStringLiteral( "Saving %1 for %2" ).arg( ( *sLastUsedValues() )[ mLayer ][idx].toString() ).arg( idx ), 2 ); - ( *sLastUsedValues() )[ mLayer ][idx] = newValues.at( idx ); + QgsDebugMsgLevel( QStringLiteral( "Saving %1 for %2" ).arg( ( *sLastUsedValues() )[mLayer][idx].toString() ).arg( idx ), 2 ); + ( *sLastUsedValues() )[mLayer][idx] = newValues.at( idx ); } } } diff --git a/src/app/qgsfeatureaction.h b/src/app/qgsfeatureaction.h index 17c43fd0aaa3..04f0877ab969 100644 --- a/src/app/qgsfeatureaction.h +++ b/src/app/qgsfeatureaction.h @@ -61,11 +61,7 @@ class APP_EXPORT QgsFeatureAction : public QAction * * \returns result if feature was added if showModal is true. If showModal is FALSE, returns Pending in every case */ - AddFeatureResult addFeature( const QgsAttributeMap &defaultAttributes = QgsAttributeMap(), - bool showModal = true, - std::unique_ptrscope = std::unique_ptr< QgsExpressionContextScope >(), - bool hideParent = false, - std::unique_ptr highlight = std::unique_ptr() ); + AddFeatureResult addFeature( const QgsAttributeMap &defaultAttributes = QgsAttributeMap(), bool showModal = true, std::unique_ptr scope = std::unique_ptr(), bool hideParent = false, std::unique_ptr highlight = std::unique_ptr() ); public slots: void execute(); @@ -111,7 +107,6 @@ class APP_EXPORT QgsFeatureAction : public QAction bool mFeatureSaved; bool mForceSuppressFormPopup = false; - }; #endif diff --git a/src/app/qgsfirstrundialog.cpp b/src/app/qgsfirstrundialog.cpp index c426313b159d..2eee6934b386 100644 --- a/src/app/qgsfirstrundialog.cpp +++ b/src/app/qgsfirstrundialog.cpp @@ -17,7 +17,8 @@ #include "moc_qgsfirstrundialog.cpp" #include "qgis.h" -QgsFirstRunDialog::QgsFirstRunDialog( QWidget *parent ) : QDialog( parent ) +QgsFirstRunDialog::QgsFirstRunDialog( QWidget *parent ) + : QDialog( parent ) { setupUi( this ); mWelcomeDevLabel->hide(); @@ -40,11 +41,9 @@ QgsFirstRunDialog::QgsFirstRunDialog( QWidget *parent ) : QDialog( parent ) mWelcomeProdLabel->setText( mWelcomeProdLabel->text().replace( QLatin1String( "VERSION_TOKEN" ), major.append( minor ) ) ); mWelcomeDevLabel->hide(); } - } bool QgsFirstRunDialog::migrateSettings() { return ( mImportSettingsYes->isChecked() ); } - diff --git a/src/app/qgsfixattributedialog.cpp b/src/app/qgsfixattributedialog.cpp index 4a6591636f47..8e7ec044d5d7 100644 --- a/src/app/qgsfixattributedialog.cpp +++ b/src/app/qgsfixattributedialog.cpp @@ -65,12 +65,10 @@ void QgsFixAttributeDialog::init( QgsVectorLayer *layer, const QgsAttributeEdito { buttonBox->addButton( cancelAllBtn, QDialogButtonBox::ActionRole ); buttonBox->addButton( cancelAllInvalidBtn, QDialogButtonBox::ActionRole ); - connect( cancelAllBtn, &QAbstractButton::clicked, this, [ = ]() - { + connect( cancelAllBtn, &QAbstractButton::clicked, this, [=]() { done( DiscardAll ); } ); - connect( cancelAllInvalidBtn, &QAbstractButton::clicked, this, [ = ]() - { + connect( cancelAllInvalidBtn, &QAbstractButton::clicked, this, [=]() { done( PasteValid ); } ); buttonBox->button( QDialogButtonBox::Cancel )->setText( tr( "Skip" ) ); @@ -80,8 +78,7 @@ void QgsFixAttributeDialog::init( QgsVectorLayer *layer, const QgsAttributeEdito storeAllInvalidBtn->setText( tr( "Paste Anyway" ) ); } buttonBox->addButton( storeAllInvalidBtn, QDialogButtonBox::ActionRole ); - connect( storeAllInvalidBtn, &QAbstractButton::clicked, this, [ = ]() - { + connect( storeAllInvalidBtn, &QAbstractButton::clicked, this, [=]() { done( PasteAll ); } ); connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsFixAttributeDialog::reject ); diff --git a/src/app/qgsfixattributedialog.h b/src/app/qgsfixattributedialog.h index 7c464b73cd82..17514b481b44 100644 --- a/src/app/qgsfixattributedialog.h +++ b/src/app/qgsfixattributedialog.h @@ -38,7 +38,6 @@ class APP_EXPORT QgsFixAttributeDialog : public QDialog Q_OBJECT public: - /** * Feedback code on closing the dialog */ @@ -84,4 +83,3 @@ class APP_EXPORT QgsFixAttributeDialog : public QDialog }; #endif // QGSFIXATTRIBUTEDIALOG_H - diff --git a/src/app/qgsformannotationdialog.cpp b/src/app/qgsformannotationdialog.cpp index d145d3174e7e..fe895504fc88 100644 --- a/src/app/qgsformannotationdialog.cpp +++ b/src/app/qgsformannotationdialog.cpp @@ -50,7 +50,7 @@ QgsFormAnnotationDialog::QgsFormAnnotationDialog( QgsMapCanvasAnnotationItem *it if ( item && item->annotation() ) { - QgsFormAnnotation *annotation = static_cast< QgsFormAnnotation * >( item->annotation() ); + QgsFormAnnotation *annotation = static_cast( item->annotation() ); mFileLineEdit->setText( annotation->designerForm() ); } @@ -81,7 +81,7 @@ void QgsFormAnnotationDialog::applySettingsToItem() { if ( !mFileLineEdit->text().isEmpty() ) { - QgsFormAnnotation *annotation = static_cast< QgsFormAnnotation * >( mItem->annotation() ); + QgsFormAnnotation *annotation = static_cast( mItem->annotation() ); annotation->setDesignerForm( mFileLineEdit->text() ); mItem->update(); } diff --git a/src/app/qgsformannotationdialog.h b/src/app/qgsformannotationdialog.h index 442b06aa4bda..bcd7b23894bd 100644 --- a/src/app/qgsformannotationdialog.h +++ b/src/app/qgsformannotationdialog.h @@ -21,7 +21,7 @@ class QgsAnnotationWidget; class QgsMapCanvasAnnotationItem; -class APP_EXPORT QgsFormAnnotationDialog: public QDialog, private Ui::QgsFormAnnotationDialogBase +class APP_EXPORT QgsFormAnnotationDialog : public QDialog, private Ui::QgsFormAnnotationDialogBase { Q_OBJECT public: diff --git a/src/app/qgsgeometryvalidationdock.cpp b/src/app/qgsgeometryvalidationdock.cpp index 71aa371b8931..e2d291087e5b 100644 --- a/src/app/qgsgeometryvalidationdock.cpp +++ b/src/app/qgsgeometryvalidationdock.cpp @@ -141,9 +141,7 @@ QgsCoordinateTransform QgsGeometryValidationDock::layerTransform() const if ( !mMapCanvas->currentLayer() ) return QgsCoordinateTransform(); - return QgsCoordinateTransform( mMapCanvas->currentLayer()->crs(), - mMapCanvas->mapSettings().destinationCrs(), - mMapCanvas->mapSettings().transformContext() ); + return QgsCoordinateTransform( mMapCanvas->currentLayer()->crs(), mMapCanvas->mapSettings().destinationCrs(), mMapCanvas->mapSettings().transformContext() ); } void QgsGeometryValidationDock::onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles ) @@ -182,8 +180,7 @@ void QgsGeometryValidationDock::showErrorContextMenu( const QPoint &pos ) QAction *action = new QAction( resolutionMethod.name(), mGeometryErrorContextMenu ); action->setToolTip( resolutionMethod.description() ); const int fixId = resolutionMethod.id(); - connect( action, &QAction::triggered, this, [ fixId, error, this ]() - { + connect( action, &QAction::triggered, this, [fixId, error, this]() { mGeometryValidationService->fixError( error, fixId ); } ); mGeometryErrorContextMenu->addAction( action ); @@ -266,8 +263,7 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex ¤ resolveLabel->setWordWrap( true ); layout->addWidget( resolveLabel, resolutionIndex, 1 ); const int fixId = resolutionMethod.id(); - connect( resolveBtn, &QToolButton::clicked, this, [fixId, error, this]() - { + connect( resolveBtn, &QToolButton::clicked, this, [fixId, error, this]() { mGeometryValidationService->fixError( error, fixId ); } ); resolutionIndex++; @@ -289,7 +285,7 @@ void QgsGeometryValidationDock::updateMapCanvasExtent() { switch ( mLastZoomToAction ) { - case ZoomToProblem: + case ZoomToProblem: zoomToProblem(); break; @@ -358,8 +354,7 @@ void QgsGeometryValidationDock::showHighlight( const QModelIndex ¤t ) QPropertyAnimation *featureAnimation = new QPropertyAnimation( mFeatureRubberband, "fillColor" ); featureAnimation->setEasingCurve( QEasingCurve::OutQuad ); connect( featureAnimation, &QPropertyAnimation::finished, featureAnimation, &QPropertyAnimation::deleteLater ); - connect( featureAnimation, &QPropertyAnimation::valueChanged, this, [this] - { + connect( featureAnimation, &QPropertyAnimation::valueChanged, this, [this] { mFeatureRubberband->update(); } ); @@ -374,8 +369,7 @@ void QgsGeometryValidationDock::showHighlight( const QModelIndex ¤t ) QPropertyAnimation *errorAnimation = new QPropertyAnimation( mErrorRubberband, "fillColor" ); errorAnimation->setEasingCurve( QEasingCurve::OutQuad ); connect( errorAnimation, &QPropertyAnimation::finished, errorAnimation, &QPropertyAnimation::deleteLater ); - connect( errorAnimation, &QPropertyAnimation::valueChanged, this, [this] - { + connect( errorAnimation, &QPropertyAnimation::valueChanged, this, [this] { mErrorRubberband->update(); } ); @@ -388,4 +382,3 @@ void QgsGeometryValidationDock::showHighlight( const QModelIndex ¤t ) mErrorLocationRubberband->setToGeometry( QgsGeometry( std::make_unique( locationGeometry ) ) ); } } - diff --git a/src/app/qgsgeometryvalidationdock.h b/src/app/qgsgeometryvalidationdock.h index af4940acedd4..ac33bd05faa5 100644 --- a/src/app/qgsgeometryvalidationdock.h +++ b/src/app/qgsgeometryvalidationdock.h @@ -60,7 +60,6 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal void showErrorContextMenu( const QPoint &pos ); private: - enum ZoomToAction { ZoomToFeature, diff --git a/src/app/qgsgeometryvalidationmodel.cpp b/src/app/qgsgeometryvalidationmodel.cpp index 4eec1183e51a..f12bec8f2d76 100644 --- a/src/app/qgsgeometryvalidationmodel.cpp +++ b/src/app/qgsgeometryvalidationmodel.cpp @@ -62,12 +62,12 @@ int QgsGeometryValidationModel::columnCount( const QModelIndex &parent ) const QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role ) const { - const QList< FeatureErrors > layerErrors = mErrorStorage.value( mCurrentLayer ); + const QList layerErrors = mErrorStorage.value( mCurrentLayer ); if ( index.row() >= layerErrors.size() ) { // Topology error - const QList< std::shared_ptr< QgsGeometryCheckError > > topologyErrors = mTopologyErrorStorage.value( mCurrentLayer ); + const QList> topologyErrors = mTopologyErrorStorage.value( mCurrentLayer ); auto topologyError = topologyErrors.at( index.row() - layerErrors.size() ); switch ( role ) @@ -273,7 +273,6 @@ void QgsGeometryValidationModel::onSingleGeometryCheckCleared( QgsVectorLayer *l { endRemoveRows(); } - } void QgsGeometryValidationModel::onGeometryCheckCompleted( QgsVectorLayer *layer, QgsFeatureId fid, const QList> &errors ) @@ -339,7 +338,7 @@ void QgsGeometryValidationModel::onGeometryCheckStarted( QgsVectorLayer *layer, } } -void QgsGeometryValidationModel::onTopologyChecksUpdated( QgsVectorLayer *layer, const QList > &errors ) +void QgsGeometryValidationModel::onTopologyChecksUpdated( QgsVectorLayer *layer, const QList> &errors ) { if ( errors.empty() ) return; @@ -382,8 +381,8 @@ void QgsGeometryValidationModel::onTopologyErrorUpdated( QgsVectorLayer *layer, if ( layer == mCurrentLayer ) { int i = 0; - const QList< std::shared_ptr< QgsGeometryCheckError > > errors = mTopologyErrorStorage[layer]; - for ( const std::shared_ptr< QgsGeometryCheckError > ¤tError : errors ) + const QList> errors = mTopologyErrorStorage[layer]; + for ( const std::shared_ptr ¤tError : errors ) { if ( currentError.get() == error ) { @@ -397,7 +396,7 @@ void QgsGeometryValidationModel::onTopologyErrorUpdated( QgsVectorLayer *layer, int QgsGeometryValidationModel::errorsForFeature( QgsVectorLayer *layer, QgsFeatureId fid ) { - const QList< FeatureErrors > layerErrors = mErrorStorage[layer]; + const QList layerErrors = mErrorStorage[layer]; int idx = 0; for ( const FeatureErrors &feature : layerErrors ) diff --git a/src/app/qgsgeometryvalidationmodel.h b/src/app/qgsgeometryvalidationmodel.h index f9d62d7f0e86..91f8f9dde818 100644 --- a/src/app/qgsgeometryvalidationmodel.h +++ b/src/app/qgsgeometryvalidationmodel.h @@ -26,7 +26,6 @@ class QgsGeometryValidationModel : public QAbstractItemModel Q_OBJECT public: - enum Roles { FeatureExtentRole = Qt::UserRole, @@ -63,23 +62,23 @@ class QgsGeometryValidationModel : public QAbstractItemModel private slots: void onSingleGeometryCheckCleared( QgsVectorLayer *layer ); - void onGeometryCheckCompleted( QgsVectorLayer *layer, QgsFeatureId fid, const QList > &errors ); + void onGeometryCheckCompleted( QgsVectorLayer *layer, QgsFeatureId fid, const QList> &errors ); void onGeometryCheckStarted( QgsVectorLayer *layer, QgsFeatureId fid ); - void onTopologyChecksUpdated( QgsVectorLayer *layer, const QList > &errors ); + void onTopologyChecksUpdated( QgsVectorLayer *layer, const QList> &errors ); void onTopologyChecksCleared( QgsVectorLayer *layer ); void onTopologyErrorUpdated( QgsVectorLayer *layer, QgsGeometryCheckError *error ); private: struct FeatureErrors { - FeatureErrors() = default; + FeatureErrors() = default; - FeatureErrors( QgsFeatureId fid ) - : fid( fid ) - {} + FeatureErrors( QgsFeatureId fid ) + : fid( fid ) + {} - QgsFeatureId fid = FID_NULL; - QList> errors; + QgsFeatureId fid = FID_NULL; + QList> errors; }; int errorsForFeature( QgsVectorLayer *layer, QgsFeatureId fid ); @@ -92,8 +91,8 @@ class QgsGeometryValidationModel : public QAbstractItemModel mutable QStringList mRequiredAttributes; mutable QgsExpressionContext mExpressionContext; - QMap > mErrorStorage; - QMap > > mTopologyErrorStorage; + QMap> mErrorStorage; + QMap>> mTopologyErrorStorage; mutable QgsFeature mCachedFeature; }; diff --git a/src/app/qgsgeometryvalidationservice.cpp b/src/app/qgsgeometryvalidationservice.cpp index 63aa8056322b..72a14b723807 100644 --- a/src/app/qgsgeometryvalidationservice.cpp +++ b/src/app/qgsgeometryvalidationservice.cpp @@ -85,24 +85,20 @@ void QgsGeometryValidationService::onLayersAdded( const QList &la QgsVectorLayer *vectorLayer = qobject_cast( layer ); if ( vectorLayer ) { - connect( vectorLayer->geometryOptions(), &QgsGeometryOptions::checkConfigurationChanged, this, [this, vectorLayer]() - { + connect( vectorLayer->geometryOptions(), &QgsGeometryOptions::checkConfigurationChanged, this, [this, vectorLayer]() { enableLayerChecks( vectorLayer ); } ); - connect( vectorLayer->geometryOptions(), &QgsGeometryOptions::geometryChecksChanged, this, [this, vectorLayer]() - { + connect( vectorLayer->geometryOptions(), &QgsGeometryOptions::geometryChecksChanged, this, [this, vectorLayer]() { enableLayerChecks( vectorLayer ); } ); - connect( vectorLayer, &QgsVectorLayer::destroyed, this, [vectorLayer, this]() - { + connect( vectorLayer, &QgsVectorLayer::destroyed, this, [vectorLayer, this]() { cleanupLayerChecks( vectorLayer ); mLayerChecks.remove( vectorLayer ); } ); - connect( vectorLayer, &QgsMapLayer::beforeResolveReferences, this, [this, vectorLayer]() - { + connect( vectorLayer, &QgsMapLayer::beforeResolveReferences, this, [this, vectorLayer]() { enableLayerChecks( vectorLayer ); } ); } @@ -176,7 +172,7 @@ void QgsGeometryValidationService::onEditingStopped( QgsVectorLayer *layer ) void QgsGeometryValidationService::showMessage( const QString &message ) { mMessageBar->popWidget( mMessageBarItem ); - mMessageBarItem = QgsMessageBar::createMessage( tr( "Geometry Validation" ), message ); + mMessageBarItem = QgsMessageBar::createMessage( tr( "Geometry Validation" ), message ); mMessageBarItem->setDuration( 5 ); mMessageBar->pushItem( mMessageBarItem ); } @@ -301,30 +297,25 @@ void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer ) // We keep all connections around in a list, so if in the future all checks get disabled // we can kill those connections to be sure the layer does not even get a tiny bit of overhead. checkInformation.connections - << connect( layer, &QgsVectorLayer::featureAdded, this, [this, layer]( QgsFeatureId fid ) - { - onFeatureAdded( layer, fid ); - } ); + << connect( layer, &QgsVectorLayer::featureAdded, this, [this, layer]( QgsFeatureId fid ) { + onFeatureAdded( layer, fid ); + } ); checkInformation.connections - << connect( layer, &QgsVectorLayer::geometryChanged, this, [this, layer]( QgsFeatureId fid, const QgsGeometry & geometry ) - { - onGeometryChanged( layer, fid, geometry ); - } ); + << connect( layer, &QgsVectorLayer::geometryChanged, this, [this, layer]( QgsFeatureId fid, const QgsGeometry &geometry ) { + onGeometryChanged( layer, fid, geometry ); + } ); checkInformation.connections - << connect( layer, &QgsVectorLayer::featureDeleted, this, [this, layer]( QgsFeatureId fid ) - { - onFeatureDeleted( layer, fid ); - } ); + << connect( layer, &QgsVectorLayer::featureDeleted, this, [this, layer]( QgsFeatureId fid ) { + onFeatureDeleted( layer, fid ); + } ); checkInformation.connections - << connect( layer, &QgsVectorLayer::beforeCommitChanges, this, [this, layer]( bool stopEditing ) - { - onBeforeCommitChanges( layer, stopEditing ); - } ); + << connect( layer, &QgsVectorLayer::beforeCommitChanges, this, [this, layer]( bool stopEditing ) { + onBeforeCommitChanges( layer, stopEditing ); + } ); checkInformation.connections - << connect( layer, &QgsVectorLayer::editingStopped, this, [this, layer]() - { - onEditingStopped( layer ); - } ); + << connect( layer, &QgsVectorLayer::editingStopped, this, [this, layer]() { + onEditingStopped( layer ); + } ); } } @@ -369,7 +360,7 @@ void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFea if ( !mLayerChecks.contains( layer ) ) return; - const QList< QgsSingleGeometryCheck * > checks = mLayerChecks[layer].singleFeatureChecks; + const QList checks = mLayerChecks[layer].singleFeatureChecks; if ( checks.empty() ) return; @@ -458,8 +449,7 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer, mLayerChecks[layer].topologyCheckFeedbacks = feedbacks.values(); QFutureWatcher *futureWatcher = new QFutureWatcher(); - connect( futureWatcher, &QFutureWatcherBase::finished, this, [&allErrors, layer, feedbacks, futureWatcher, stopEditing, this]() - { + connect( futureWatcher, &QFutureWatcherBase::finished, this, [&allErrors, layer, feedbacks, futureWatcher, stopEditing, this]() { QgsReadWriteLocker errorLocker( mTopologyCheckLock, QgsReadWriteLocker::Read ); layer->setAllowCommit( allErrors.empty() && mLayerChecks[layer].singleFeatureCheckErrors.empty() ); errorLocker.unlock(); @@ -487,8 +477,7 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer, mLayerChecks[layer].commitPending = false; } ); - QFuture future = QtConcurrent::map( checks, [&allErrors, layerFeatureIds, layer, layerId, feedbacks, affectedFeatureIds, this]( const QgsGeometryCheck * check ) - { + QFuture future = QtConcurrent::map( checks, [&allErrors, layerFeatureIds, layer, layerId, feedbacks, affectedFeatureIds, this]( const QgsGeometryCheck *check ) { // Watch out with the layer pointer in here. We are running in a thread, so we do not want to actually use it // except for using its address to report the error. QList errors; @@ -498,7 +487,7 @@ void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer, check->collectErrors( mFeaturePools, errors, messages, feedback, layerFeatureIds ); QgsReadWriteLocker errorLocker( mTopologyCheckLock, QgsReadWriteLocker::Write ); - QList > sharedErrors; + QList> sharedErrors; for ( QgsGeometryCheckError *err : errors ) { std::shared_ptr error( err ); diff --git a/src/app/qgsgeometryvalidationservice.h b/src/app/qgsgeometryvalidationservice.h index 18e0326036c0..27cbae70ae32 100644 --- a/src/app/qgsgeometryvalidationservice.h +++ b/src/app/qgsgeometryvalidationservice.h @@ -51,13 +51,13 @@ class QgsGeometryValidationService : public QObject public: struct FeatureError { - FeatureError() = default; - FeatureError( QgsFeatureId fid, QgsGeometry::Error error ) - : featureId( fid ) - , error( error ) - {} - QgsFeatureId featureId = std::numeric_limits::min(); - QgsGeometry::Error error; + FeatureError() = default; + FeatureError( QgsFeatureId fid, QgsGeometry::Error error ) + : featureId( fid ) + , error( error ) + {} + QgsFeatureId featureId = std::numeric_limits::min(); + QgsGeometry::Error error; }; typedef QList FeatureErrors; @@ -80,7 +80,7 @@ class QgsGeometryValidationService : public QObject void geometryCheckStarted( QgsVectorLayer *layer, QgsFeatureId fid ); void geometryCheckCompleted( QgsVectorLayer *layer, QgsFeatureId fid, const QList> &errors ); - void topologyChecksUpdated( QgsVectorLayer *layer, const QList > &errors ); + void topologyChecksUpdated( QgsVectorLayer *layer, const QList> &errors ); void topologyChecksCleared( QgsVectorLayer *layer ); void topologyErrorUpdated( QgsVectorLayer *layer, QgsGeometryCheckError *error ); @@ -112,15 +112,15 @@ class QgsGeometryValidationService : public QObject struct VectorLayerCheckInformation { - QList< QgsSingleGeometryCheck * > singleFeatureChecks; - QMap > > singleFeatureCheckErrors; - QList< QgsGeometryCheck *> topologyChecks; - QFutureWatcher *topologyCheckFutureWatcher = nullptr; - QList topologyCheckFeedbacks; // will be deleted when topologyCheckFutureWatcher is delteed - QList> topologyCheckErrors; - QList connections; - std::shared_ptr context; - bool commitPending = false; + QList singleFeatureChecks; + QMap>> singleFeatureCheckErrors; + QList topologyChecks; + QFutureWatcher *topologyCheckFutureWatcher = nullptr; + QList topologyCheckFeedbacks; // will be deleted when topologyCheckFutureWatcher is delteed + QList> topologyCheckErrors; + QList connections; + std::shared_ptr context; + bool commitPending = false; }; QReadWriteLock mTopologyCheckLock; @@ -132,7 +132,6 @@ class QgsGeometryValidationService : public QObject // when checks do complete successfully and changes need to be saved // this variable is used to indicate that it's safe to bypass the checks bool mBypassChecks = false; - }; #endif // QGSGEOMETRYVALIDATIONSERVICE_H diff --git a/src/app/qgsguivectorlayertools.cpp b/src/app/qgsguivectorlayertools.cpp index d6158fc83766..82f2ee8ae393 100644 --- a/src/app/qgsguivectorlayertools.cpp +++ b/src/app/qgsguivectorlayertools.cpp @@ -70,9 +70,7 @@ bool QgsGuiVectorLayerTools::startEditing( QgsVectorLayer *layer ) const { if ( !layer->supportsEditing() ) { - QgisApp::instance()->messageBar()->pushMessage( tr( "Start editing failed" ), - tr( "Provider cannot be opened for editing" ), - Qgis::MessageLevel::Info ); + QgisApp::instance()->messageBar()->pushMessage( tr( "Start editing failed" ), tr( "Provider cannot be opened for editing" ), Qgis::MessageLevel::Info ); return false; } @@ -115,10 +113,7 @@ bool QgsGuiVectorLayerTools::stopEditing( QgsVectorLayer *layer, bool allowCance if ( allowCancel ) buttons |= QMessageBox::Cancel; - switch ( QMessageBox::question( nullptr, - tr( "Stop Editing" ), - tr( "Do you want to save the changes to layer %1?" ).arg( layer->name() ), - buttons ) ) + switch ( QMessageBox::question( nullptr, tr( "Stop Editing" ), tr( "Do you want to save the changes to layer %1?" ).arg( layer->name() ), buttons ) ) { case QMessageBox::Cancel: res = false; @@ -141,9 +136,7 @@ bool QgsGuiVectorLayerTools::stopEditing( QgsVectorLayer *layer, bool allowCance QgisApp::instance()->freezeCanvases(); if ( !layer->rollBack() ) { - QgisApp::instance()->messageBar()->pushMessage( tr( "Error" ), - tr( "Problems during roll back" ), - Qgis::MessageLevel::Critical ); + QgisApp::instance()->messageBar()->pushMessage( tr( "Error" ), tr( "Problems during roll back" ), Qgis::MessageLevel::Critical ); res = false; } QgisApp::instance()->freezeCanvases( false ); @@ -186,7 +179,7 @@ bool QgsGuiVectorLayerTools::avoidIntersection( QgsVectorLayer *layer, QgsFeatur QgsFeatureIterator fi = layer->getFeatures( request ); QgsFeature f; - const QHash > ignoreFeatures {{ layer, request.filterFids() }}; + const QHash> ignoreFeatures { { layer, request.filterFids() } }; while ( fi.nextFeature( f ) ) { @@ -199,9 +192,7 @@ bool QgsGuiVectorLayerTools::avoidIntersection( QgsVectorLayer *layer, QgsFeatur { if ( errorMsg ) { - *errorMsg = ( geom.isEmpty() ) ? - tr( "The feature cannot be moved because 1 or more resulting geometries would be empty" ) : - tr( "An error was reported during intersection removal" ); + *errorMsg = ( geom.isEmpty() ) ? tr( "The feature cannot be moved because 1 or more resulting geometries would be empty" ) : tr( "An error was reported during intersection removal" ); } return false; @@ -216,10 +207,7 @@ void QgsGuiVectorLayerTools::commitError( QgsVectorLayer *vlayer ) const { QgsMessageViewer *mv = new QgsMessageViewer(); mv->setWindowTitle( tr( "Commit Errors" ) ); - mv->setMessageAsPlainText( tr( "Could not commit changes to layer %1" ).arg( vlayer->name() ) - + "\n\n" - + tr( "Errors: %1\n" ).arg( vlayer->commitErrors().join( QLatin1String( "\n " ) ) ) - ); + mv->setMessageAsPlainText( tr( "Could not commit changes to layer %1" ).arg( vlayer->name() ) + "\n\n" + tr( "Errors: %1\n" ).arg( vlayer->commitErrors().join( QLatin1String( "\n " ) ) ) ); QToolButton *showMore = new QToolButton(); // store pointer to vlayer in data of QAction @@ -241,7 +229,7 @@ void QgsGuiVectorLayerTools::commitError( QgsVectorLayer *vlayer ) const showMore, Qgis::MessageLevel::Warning, 0, - QgisApp::instance()->messageBar() ); + QgisApp::instance()->messageBar() + ); QgisApp::instance()->messageBar()->pushItem( errorMsg ); - } diff --git a/src/app/qgsguivectorlayertools.h b/src/app/qgsguivectorlayertools.h index 57c956c3b39c..6a3d4e5d1260 100644 --- a/src/app/qgsguivectorlayertools.h +++ b/src/app/qgsguivectorlayertools.h @@ -28,7 +28,6 @@ class QgsGuiVectorLayerTools : public QgsVectorLayerTools Q_OBJECT public: - /** * Constructor for QgsGuiVectorLayerTools. */ @@ -97,7 +96,6 @@ class QgsGuiVectorLayerTools : public QgsVectorLayerTools private: void commitError( QgsVectorLayer *vlayer ) const; bool avoidIntersection( QgsVectorLayer *layer, QgsFeatureRequest &request, QString *errorMsg = nullptr ) const; - }; #endif // QGSGUIVECTORLAYERTOOLS_H diff --git a/src/app/qgshandlebadlayers.cpp b/src/app/qgshandlebadlayers.cpp index 53068189b11a..7dc4764dc725 100644 --- a/src/app/qgshandlebadlayers.cpp +++ b/src/app/qgshandlebadlayers.cpp @@ -60,9 +60,10 @@ void QgsHandleBadLayersHandler::handleBadLayers( const QList &layers ) QgisApp::instance()->messageBar()->pushMessage( tr( "Handle unavailable layers" ), tr( "%1 of %2 unavailable layers were not fixable." ) - .arg( layers.size() - dialog->layerCount() ) - .arg( layers.size() ), - Qgis::MessageLevel::Warning ); + .arg( layers.size() - dialog->layerCount() ) + .arg( layers.size() ), + Qgis::MessageLevel::Warning + ); if ( dialog->layerCount() > 0 ) { @@ -104,13 +105,7 @@ QgsHandleBadLayers::QgsHandleBadLayers( const QList &layers ) mLayerList->setColumnCount( 5 ); mLayerList->setColumnWidth( 3, 75 ); - mLayerList->setHorizontalHeaderLabels( QStringList() - << tr( "Layer name" ) - << tr( "Type" ) - << tr( "Provider" ) - << tr( "Auth config" ) - << tr( "Datasource" ) - ); + mLayerList->setHorizontalHeaderLabels( QStringList() << tr( "Layer name" ) << tr( "Type" ) << tr( "Provider" ) << tr( "Auth config" ) << tr( "Datasource" ) ); mLayerList->horizontalHeader()->setSectionsMovable( true ); mLayerList->horizontalHeader()->setSectionResizeMode( QHeaderView::Interactive ); @@ -131,13 +126,9 @@ QgsHandleBadLayers::QgsHandleBadLayers( const QList &layers ) providerFileBased = metadata->providerCapabilities() & QgsProviderMetadata::FileBasedUris; const QString basepath = QFileInfo( datasource ).absolutePath(); - mOriginalFileBase[ layerId ].append( basepath ); + mOriginalFileBase[layerId].append( basepath ); - QgsDebugMsgLevel( QStringLiteral( "name=%1 type=%2 provider=%3 datasource='%4'" ) - .arg( name, - type, - provider, - datasource ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "name=%1 type=%2 provider=%3 datasource='%4'" ).arg( name, type, provider, datasource ), 2 ); mLayerList->setRowCount( j + 1 ); @@ -145,11 +136,11 @@ QgsHandleBadLayers::QgsHandleBadLayers( const QList &layers ) bool ok = false; item = new QTableWidgetItem( name ); - item->setData( static_cast< int >( CustomRoles::Index ), i ); - item->setData( static_cast< int >( CustomRoles::Provider ), provider ); - item->setData( static_cast< int >( CustomRoles::ProviderIsFileBased ), providerFileBased ); - item->setData( static_cast< int >( CustomRoles::LayerId ), layerId ); - item->setData( static_cast< int >( CustomRoles::LayerType ), static_cast< int >( QgsMapLayerFactory::typeFromString( type, ok ) ) ); + item->setData( static_cast( CustomRoles::Index ), i ); + item->setData( static_cast( CustomRoles::Provider ), provider ); + item->setData( static_cast( CustomRoles::ProviderIsFileBased ), providerFileBased ); + item->setData( static_cast( CustomRoles::LayerId ), layerId ); + item->setData( static_cast( CustomRoles::LayerType ), static_cast( QgsMapLayerFactory::typeFromString( type, ok ) ) ); item->setFlags( item->flags() & ~Qt::ItemIsEditable ); mLayerList->setItem( j, 0, item ); @@ -193,11 +184,11 @@ void QgsHandleBadLayers::selectionChanged() QString QgsHandleBadLayers::filename( int row ) { - const bool providerFileBased = mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::ProviderIsFileBased ) ).toBool(); + const bool providerFileBased = mLayerList->item( row, 0 )->data( static_cast( CustomRoles::ProviderIsFileBased ) ).toBool(); if ( !providerFileBased ) return QString(); - const QString provider = mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::Provider ) ).toString(); + const QString provider = mLayerList->item( row, 0 )->data( static_cast( CustomRoles::Provider ) ).toString(); const QString datasource = mLayerList->item( row, 4 )->text(); const QVariantMap parts = QgsProviderRegistry::instance()->decodeUri( provider, datasource ); @@ -209,7 +200,7 @@ void QgsHandleBadLayers::setFilename( int row, const QString &filename ) if ( !QFileInfo::exists( filename ) ) return; - const QString provider = mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::Provider ) ).toString(); + const QString provider = mLayerList->item( row, 0 )->data( static_cast( CustomRoles::Provider ) ).toString(); QTableWidgetItem *item = mLayerList->item( row, 4 ); const QString datasource = item->text(); @@ -220,9 +211,9 @@ void QgsHandleBadLayers::setFilename( int row, const QString &filename ) item->setText( QgsProviderRegistry::instance()->encodeUri( provider, parts ) ); } -QList< int > QgsHandleBadLayers::fileBasedRows( bool selectedOnly ) +QList QgsHandleBadLayers::fileBasedRows( bool selectedOnly ) { - QList< int > res; + QList res; if ( selectedOnly ) { const QList selectedItems = mLayerList->selectedItems(); @@ -232,19 +223,18 @@ QList< int > QgsHandleBadLayers::fileBasedRows( bool selectedOnly ) if ( item->column() != 0 ) continue; - const bool providerFileBased = mLayerList->item( item->row(), 0 )->data( static_cast< int >( CustomRoles::ProviderIsFileBased ) ).toBool(); + const bool providerFileBased = mLayerList->item( item->row(), 0 )->data( static_cast( CustomRoles::ProviderIsFileBased ) ).toBool(); if ( !providerFileBased ) continue; res << item->row(); } - } else { for ( int row = 0; row < mLayerList->rowCount(); row++ ) { - const bool providerFileBased = mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::ProviderIsFileBased ) ).toBool(); + const bool providerFileBased = mLayerList->item( row, 0 )->data( static_cast( CustomRoles::ProviderIsFileBased ) ).toBool(); if ( !providerFileBased ) continue; @@ -256,7 +246,7 @@ QList< int > QgsHandleBadLayers::fileBasedRows( bool selectedOnly ) void QgsHandleBadLayers::browseClicked() { - const QList< int > selectedRows = fileBasedRows( true ); + const QList selectedRows = fileBasedRows( true ); if ( selectedRows.empty() ) return; @@ -267,8 +257,8 @@ void QgsHandleBadLayers::browseClicked() QString memoryQualifier; - const Qgis::LayerType layerType = static_cast< Qgis::LayerType >( mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::LayerType ) ).toInt() ); - const QString provider = mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::Provider ) ).toString(); + const Qgis::LayerType layerType = static_cast( mLayerList->item( row, 0 )->data( static_cast( CustomRoles::LayerType ) ).toInt() ); + const QString provider = mLayerList->item( row, 0 )->data( static_cast( CustomRoles::Provider ) ).toString(); QString fileFilter; QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( provider ); @@ -340,7 +330,7 @@ void QgsHandleBadLayers::browseClicked() for ( int row : selectedRows ) { - const bool providerFileBased = mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::ProviderIsFileBased ) ).toBool(); + const bool providerFileBased = mLayerList->item( row, 0 )->data( static_cast( CustomRoles::ProviderIsFileBased ) ).toBool(); if ( !providerFileBased ) continue; @@ -374,7 +364,7 @@ void QgsHandleBadLayers::editAuthCfg() if ( row == -1 ) return; - const QString provider = mLayerList->item( row, 0 )->data( static_cast< int >( CustomRoles::Provider ) ).toString(); + const QString provider = mLayerList->item( row, 0 )->data( static_cast( CustomRoles::Provider ) ).toString(); QString prevuri = mLayerList->item( row, 4 )->text(); @@ -398,21 +388,21 @@ void QgsHandleBadLayers::apply() QDir::setCurrent( QgsProject::instance()->absolutePath() ); for ( int i = 0; i < mLayerList->rowCount(); i++ ) { - const int idx = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::Index ) ).toInt(); - QDomNode &node = const_cast( mLayers[ idx ] ); + const int idx = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::Index ) ).toInt(); + QDomNode &node = const_cast( mLayers[idx] ); QTableWidgetItem *item = mLayerList->item( i, 4 ); QString datasource = item->text(); - const QString layerId = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::LayerId ) ).toString(); + const QString layerId = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::LayerId ) ).toString(); const QString name { mLayerList->item( i, 0 )->text() }; - const QString provider = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::Provider ) ).toString(); + const QString provider = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::Provider ) ).toString(); - const bool dataSourceWasAutoRepaired = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::DataSourceWasAutoRepaired ) ).toBool(); - const bool providerFileBased = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::ProviderIsFileBased ) ).toBool(); + const bool dataSourceWasAutoRepaired = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::DataSourceWasAutoRepaired ) ).toBool(); + const bool providerFileBased = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::ProviderIsFileBased ) ).toBool(); if ( providerFileBased && !dataSourceWasAutoRepaired ) { QVariantMap providerMap = QgsProviderRegistry::instance()->decodeUri( provider, datasource ); - const QString filePath = providerMap[ QStringLiteral( "path" ) ].toString(); + const QString filePath = providerMap[QStringLiteral( "path" )].toString(); const QFileInfo dataInfo = QFileInfo( filePath ); bool fixedPath = false; @@ -437,7 +427,7 @@ void QgsHandleBadLayers::apply() if ( mapLayer ) { QString subsetString; - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer *>( mapLayer ); + QgsVectorLayer *vlayer = qobject_cast( mapLayer ); if ( vlayer ) { // store the previous layer subset string, so we can restore after fixing the data source @@ -482,7 +472,7 @@ void QgsHandleBadLayers::apply() const auto mapLayers = QgsProject::instance()->mapLayers(); for ( const auto &l : mapLayers ) { - if ( ! l->isValid() ) + if ( !l->isValid() ) toRemove << l; } QgsProject::instance()->removeMapLayers( toRemove ); @@ -490,27 +480,18 @@ void QgsHandleBadLayers::apply() } QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( false ); - } void QgsHandleBadLayers::accept() { - - if ( mLayerList->rowCount() > 0 && - QMessageBox::warning( this, - tr( "Unhandled layer will be lost." ), - tr( "There are still %n unhandled layer(s). If they are not fixed, they will be disabled/deactivated until the project is opened again.", - "unhandled layers", - mLayerList->rowCount() ), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( mLayerList->rowCount() > 0 && QMessageBox::warning( this, tr( "Unhandled layer will be lost." ), tr( "There are still %n unhandled layer(s). If they are not fixed, they will be disabled/deactivated until the project is opened again.", "unhandled layers", mLayerList->rowCount() ), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; } QList toRemove; - for ( const auto &l : QgsProject::instance()->mapLayers( ) ) + for ( const auto &l : QgsProject::instance()->mapLayers() ) { - if ( ! l->isValid() ) + if ( !l->isValid() ) toRemove << l; } QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( true ); @@ -537,7 +518,7 @@ QString QgsHandleBadLayers::checkBasepath( const QString &layerId, const QString foundPath = true; const QString newBasepath = newpathDir.absolutePath(); if ( !mAlternativeBasepaths.value( originalBase ).contains( newBasepath ) ) - mAlternativeBasepaths[ originalBase ].append( newBasepath ); + mAlternativeBasepaths[originalBase].append( newBasepath ); return newpathDir.filePath( fileName ); } else if ( mAlternativeBasepaths.contains( originalBase ) ) @@ -567,28 +548,27 @@ void QgsHandleBadLayers::autoFind() for ( int i : std::as_const( layersToFind ) ) { - const int idx = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::Index ) ).toInt(); - QDomNode &node = const_cast( mLayers[ idx ] ); + const int idx = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::Index ) ).toInt(); + QDomNode &node = const_cast( mLayers[idx] ); QTableWidgetItem *item = mLayerList->item( i, 4 ); QString datasource = item->text(); QString fileName; - const QString layerId = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::LayerId ) ).toString(); + const QString layerId = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::LayerId ) ).toString(); const QString name { mLayerList->item( i, 0 )->text() }; const QFileInfo dataInfo = QFileInfo( datasource ); const QString basepath = dataInfo.absoluteDir().path(); const QString longName = dataInfo.fileName(); - const QString provider = mLayerList->item( i, 0 )->data( static_cast< int >( CustomRoles::Provider ) ).toString(); + const QString provider = mLayerList->item( i, 0 )->data( static_cast( CustomRoles::Provider ) ).toString(); progressDialog.setValue( i ); QChar sentenceEnd = ( name.length() > 15 ) ? QChar( 0x2026 ) : '.'; - progressDialog.setLabelText( QObject::tr( "Searching for file: %1 \n [ %2 of %3 ] " ).arg( name.left( 15 ) + sentenceEnd, - QLocale().toString( i + 1 ), QLocale().toString( layersToFind.size() ) ) ); + progressDialog.setLabelText( QObject::tr( "Searching for file: %1 \n [ %2 of %3 ] " ).arg( name.left( 15 ) + sentenceEnd, QLocale().toString( i + 1 ), QLocale().toString( layersToFind.size() ) ) ); progressDialog.open(); QVariantMap providerMap = QgsProviderRegistry::instance()->decodeUri( provider, dataInfo.absoluteFilePath() ); if ( providerMap.contains( QStringLiteral( "path" ) ) ) - fileName = QFileInfo( providerMap[ QStringLiteral( "path" ) ].toString() ).fileName(); + fileName = QFileInfo( providerMap[QStringLiteral( "path" )].toString() ).fileName(); else { item->setForeground( QBrush( Qt::red ) ); @@ -655,7 +635,7 @@ void QgsHandleBadLayers::autoFind() setFilename( i, datasource ); item->setText( datasource ); item->setForeground( QBrush( Qt::green ) ); - mLayerList->item( i, 0 )->setData( static_cast< int >( CustomRoles::DataSourceWasAutoRepaired ), QVariant( true ) ); + mLayerList->item( i, 0 )->setData( static_cast( CustomRoles::DataSourceWasAutoRepaired ), QVariant( true ) ); } else { @@ -669,10 +649,7 @@ void QgsHandleBadLayers::autoFind() item->setForeground( QBrush( Qt::red ) ); } } - } QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( false ); - } - diff --git a/src/app/qgshandlebadlayers.h b/src/app/qgshandlebadlayers.h index f405655f2f7b..4e3a8fb4930c 100644 --- a/src/app/qgshandlebadlayers.h +++ b/src/app/qgshandlebadlayers.h @@ -22,8 +22,8 @@ #include "qgis_app.h" class APP_EXPORT QgsHandleBadLayersHandler - : public QObject - , public QgsProjectBadLayerHandler + : public QObject, + public QgsProjectBadLayerHandler { Q_OBJECT @@ -40,14 +40,13 @@ class APP_EXPORT QgsHandleBadLayersHandler * \since QGIS 3.6 */ void layersChanged(); - }; class QPushButton; class APP_EXPORT QgsHandleBadLayers - : public QDialog - , public Ui::QgsHandleBadLayersBase + : public QDialog, + public Ui::QgsHandleBadLayersBase { Q_OBJECT @@ -71,7 +70,6 @@ class APP_EXPORT QgsHandleBadLayers void autoFind(); private: - enum class CustomRoles : int { Index = Qt::UserRole, @@ -87,9 +85,9 @@ class APP_EXPORT QgsHandleBadLayers QPushButton *mAutoFindButton = nullptr; const QList &mLayers; // Registry of the original paths associated with a file as a backup - QHash mOriginalFileBase; + QHash mOriginalFileBase; // Keeps a registry of valid alternatives for a basepath - QHash mAlternativeBasepaths; + QHash mAlternativeBasepaths; QString filename( int row ); void setFilename( int row, const QString &filename ); diff --git a/src/app/qgshtmlannotationdialog.cpp b/src/app/qgshtmlannotationdialog.cpp index d35b70ad2053..6a2891ec40c9 100644 --- a/src/app/qgshtmlannotationdialog.cpp +++ b/src/app/qgshtmlannotationdialog.cpp @@ -48,7 +48,7 @@ QgsHtmlAnnotationDialog::QgsHtmlAnnotationDialog( QgsMapCanvasAnnotationItem *it if ( item && item->annotation() ) { - QgsHtmlAnnotation *annotation = static_cast< QgsHtmlAnnotation * >( item->annotation() ); + QgsHtmlAnnotation *annotation = static_cast( item->annotation() ); const QString file = annotation->sourceFile(); if ( !file.isEmpty() ) { @@ -88,7 +88,7 @@ void QgsHtmlAnnotationDialog::applySettingsToItem() if ( mItem && mItem->annotation() ) { - QgsHtmlAnnotation *annotation = static_cast< QgsHtmlAnnotation * >( mItem->annotation() ); + QgsHtmlAnnotation *annotation = static_cast( mItem->annotation() ); if ( mFileRadioButton->isChecked() ) { annotation->setSourceFile( mFileLineEdit->text() ); diff --git a/src/app/qgshtmlannotationdialog.h b/src/app/qgshtmlannotationdialog.h index 3ed2aca6710c..dc88319efb33 100644 --- a/src/app/qgshtmlannotationdialog.h +++ b/src/app/qgshtmlannotationdialog.h @@ -21,7 +21,7 @@ class QgsAnnotationWidget; class QgsMapCanvasAnnotationItem; -class APP_EXPORT QgsHtmlAnnotationDialog: public QDialog, private Ui::QgsFormAnnotationDialogBase +class APP_EXPORT QgsHtmlAnnotationDialog : public QDialog, private Ui::QgsFormAnnotationDialogBase { Q_OBJECT public: diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index 71e98251996f..e6ee06c249bb 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -112,7 +112,8 @@ const QgsSettingsEntryBool *QgsIdentifyResultsDialog::settingHideNullValues = ne const QgsSettingsEntryBool *QgsIdentifyResultsDialog::settingShowRelations = new QgsSettingsEntryBool( QStringLiteral( "show-relations" ), QgsSettingsTree::sTreeMap, true, QStringLiteral( "Whether to show relations in the identify feature result" ) ); -QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWebView( parent ) +QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) + : QgsWebView( parent ) { setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() ); @@ -143,7 +144,7 @@ void QgsIdentifyResultsWebView::unsupportedContent( QNetworkReply *reply ) void QgsIdentifyResultsWebView::handleDownload( QUrl url ) { - if ( ! url.isValid() ) + if ( !url.isValid() ) { QMessageBox::warning( this, tr( "Invalid URL" ), tr( "The download URL is not valid: %1" ).arg( url.toString() ) ); } @@ -155,16 +156,12 @@ void QgsIdentifyResultsWebView::handleDownload( QUrl url ) const QFileInfo info( url.toString() ); QString savePath = settings.value( DOWNLOADER_LAST_DIR_KEY ).toString(); const QString fileName = QgsFileUtils::stringToSafeFilename( info.fileName() ); - if ( ! savePath.isEmpty() && ! fileName.isEmpty() ) + if ( !savePath.isEmpty() && !fileName.isEmpty() ) { savePath = QDir::cleanPath( savePath + QDir::separator() + fileName ); } - const QString targetFile = QFileDialog::getSaveFileName( this, - tr( "Save As" ), - savePath, - info.suffix().isEmpty() ? QString() : "*." + info.suffix() - ); - if ( ! targetFile.isEmpty() ) + const QString targetFile = QFileDialog::getSaveFileName( this, tr( "Save As" ), savePath, info.suffix().isEmpty() ? QString() : "*." + info.suffix() ); + if ( !targetFile.isEmpty() ) { settings.setValue( DOWNLOADER_LAST_DIR_KEY, QFileInfo( targetFile ).dir().absolutePath() ); // Start the download @@ -336,7 +333,6 @@ void QgsIdentifyResultsWebViewItem::loadFinished( bool ok ) setFirstColumnSpanned( true ); disconnect( mWebView->page(), &QWebPage::loadFinished, this, &QgsIdentifyResultsWebViewItem::loadFinished ); - } // Tree hierarchy @@ -449,14 +445,11 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge mPlot->setSizePolicy( sizePolicy ); mPlot->updateGeometry(); - connect( lstResults, &QTreeWidget::currentItemChanged, - this, &QgsIdentifyResultsDialog::handleCurrentItemChanged ); + connect( lstResults, &QTreeWidget::currentItemChanged, this, &QgsIdentifyResultsDialog::handleCurrentItemChanged ); - connect( lstResults, &QTreeWidget::itemClicked, - this, &QgsIdentifyResultsDialog::itemClicked ); + connect( lstResults, &QTreeWidget::itemClicked, this, &QgsIdentifyResultsDialog::itemClicked ); - connect( lstResults, &QTreeWidget::itemExpanded, - this, &QgsIdentifyResultsDialog::itemExpanded ); + connect( lstResults, &QTreeWidget::itemExpanded, this, &QgsIdentifyResultsDialog::itemExpanded ); #if defined( HAVE_QTPRINTER ) connect( mActionPrint, &QAction::triggered, this, &QgsIdentifyResultsDialog::printCurrentItem ); @@ -488,7 +481,6 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge mActionHideNullValues->setChecked( QgsIdentifyResultsDialog::settingHideNullValues->value() ); settingsMenu->addAction( mActionShowRelations ); mActionShowRelations->setChecked( QgsIdentifyResultsDialog::settingShowRelations->value() ); - } QgsIdentifyResultsDialog::~QgsIdentifyResultsDialog() @@ -592,8 +584,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat connect( vlayer, &QObject::destroyed, this, &QgsIdentifyResultsDialog::layerDestroyed ); connect( vlayer, &QgsMapLayer::crsChanged, this, &QgsIdentifyResultsDialog::layerDestroyed ); connect( vlayer, &QgsVectorLayer::featureDeleted, this, &QgsIdentifyResultsDialog::featureDeleted ); - connect( vlayer, &QgsVectorLayer::attributeValueChanged, - this, &QgsIdentifyResultsDialog::attributeValueChanged ); + connect( vlayer, &QgsVectorLayer::attributeValueChanged, this, &QgsIdentifyResultsDialog::attributeValueChanged ); connect( vlayer, &QgsVectorLayer::editingStarted, this, &QgsIdentifyResultsDialog::editingToggled ); connect( vlayer, &QgsVectorLayer::editingStopped, this, &QgsIdentifyResultsDialog::editingToggled ); } @@ -604,8 +595,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat layItem->setFirstColumnSpanned( true ); const QString countSuffix = layItem->childCount() > 1 - ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) - : QString(); + ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) + : QString(); layItem->setText( 0, QStringLiteral( "%1 %2" ).arg( vlayer->name(), countSuffix ) ); @@ -678,7 +669,7 @@ bool QgsIdentifyResultsDialog::isFeatureInAncestors( QTreeWidgetItem *item, cons { if ( item->data( 0, FeatureRole ).isValid() && item->parent() && vectorLayer( item->parent() ) == vlayer ) { - const QgsFeature otherF = item->data( 0, FeatureRole ).value< QgsFeature >(); + const QgsFeature otherF = item->data( 0, FeatureRole ).value(); if ( f.id() == otherF.id() ) { return true; @@ -702,7 +693,7 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV derivedItem->setAlwaysOnTopPriority( 0 ); featItem->addChild( derivedItem ); - for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) + for ( QMap::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) { derivedItem->addChild( new QTreeWidgetItem( QStringList() << it.key() << it.value() ) ); } @@ -710,7 +701,7 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV //get valid QgsMapLayerActions for this layer QgsMapLayerActionContext context = QgisApp::instance()->createMapLayerActionContext(); - const QList< QgsMapLayerAction * > registeredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( vlayer, Qgis::MapLayerActionTarget::AllActions, context ); + const QList registeredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( vlayer, Qgis::MapLayerActionTarget::AllActions, context ); const QList actions = vlayer->actions()->actions( QStringLiteral( "Feature" ) ); if ( ( !vlayer->fields().isEmpty() || !actions.isEmpty() || !registeredActions.isEmpty() ) && !QgsSettings().value( QStringLiteral( "/Map/hideDerivedAttributes" ), false ).toBool() ) @@ -890,7 +881,7 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV italicFont.setItalic( true ); relationItem->setFont( 0, italicFont ); relationItem->setData( 0, Qt::UserRole, QVariant::fromValue( qobject_cast( relation.referencedLayer() ) ) ); - relationItem->setText( 0, tr( "%1 through %2 [%3]" ).arg( relation.referencedLayer()->name() ).arg( relation.name() ) .arg( 1 ) ) ; + relationItem->setText( 0, tr( "%1 through %2 [%3]" ).arg( relation.referencedLayer()->name() ).arg( relation.name() ).arg( 1 ) ); relationItem->setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator ); featItem->addChild( relationItem ); // setFirstColumnSpanned() to be done after addChild() to be effective @@ -921,16 +912,14 @@ void QgsIdentifyResultsDialog::mapLayerActionDestroyed() QTreeWidgetItemIterator it( lstResults ); while ( *it ) { - if ( ( *it )->data( 0, Qt::UserRole ) == "map_layer_action" && - ( *it )->data( 0, Qt::UserRole + 1 ).value< QObject *>() == sender() ) + if ( ( *it )->data( 0, Qt::UserRole ) == "map_layer_action" && ( *it )->data( 0, Qt::UserRole + 1 ).value() == sender() ) delete *it; else ++it; } } -QgsIdentifyPlotCurve::QgsIdentifyPlotCurve( const QMap &attributes, - QwtPlot *plot, const QString &title, QColor color ) +QgsIdentifyPlotCurve::QgsIdentifyPlotCurve( const QMap &attributes, QwtPlot *plot, const QString &title, QColor color ) { mPlotCurve = new QwtPlotCurve( title ); @@ -938,8 +927,7 @@ QgsIdentifyPlotCurve::QgsIdentifyPlotCurve( const QMap &attrib { color = QgsLimitedRandomColorRamp::randomColors( 1 ).at( 0 ); } - mPlotCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ), - QPen( color, 2 ), QSize( 9, 9 ) ) ); + mPlotCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ), QPen( color, 2 ), QSize( 9, 9 ) ) ); mPlotCurve->setPen( QPen( color, 2 ) ); // needed for legend QVector myData; @@ -949,7 +937,7 @@ QgsIdentifyPlotCurve::QgsIdentifyPlotCurve( const QMap &attrib it != attributes.end(); ++it ) { bool ok; - const double val {it.value().toDouble( &ok )}; + const double val { it.value().toDouble( &ok ) }; if ( ok && std::isfinite( val ) ) { myData << QPointF( double( i++ ), val ); @@ -991,7 +979,7 @@ QString QgsIdentifyResultsDialog::representValue( QgsVectorLayer *vlayer, const if ( layerCaches.contains( fieldName ) ) { - cache = layerCaches[ fieldName ]; + cache = layerCaches[fieldName]; } else { @@ -1004,13 +992,7 @@ QString QgsIdentifyResultsDialog::representValue( QgsVectorLayer *vlayer, const // Raster variant of addFeature -void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, - const QString &label, - const QMap &attributes, - const QMap &derivedAttributes, - const QgsFields &fields, - const QgsFeature &feature, - const QMap ¶ms ) +void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes, const QgsFields &fields, const QgsFeature &feature, const QMap ¶ms ) { QgsDebugMsgLevel( QStringLiteral( "feature.isValid() = %1" ).arg( feature.isValid() ), 2 ); QTreeWidgetItem *layItem = layerItem( layer ); @@ -1031,12 +1013,12 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, // Add all supported formats, best first. HTML is considered the best because // it usually holds most information. const Qgis::RasterInterfaceCapabilities capabilities = layer->dataProvider()->capabilities(); - static const QList formats - { + static const QList formats { Qgis::RasterIdentifyFormat::Html, Qgis::RasterIdentifyFormat::Feature, Qgis::RasterIdentifyFormat::Text, - Qgis::RasterIdentifyFormat::Value }; + Qgis::RasterIdentifyFormat::Value + }; for ( const auto &f : formats ) { if ( !( capabilities & QgsRasterDataProvider::identifyFormatToCapability( f ) ) ) @@ -1054,8 +1036,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, QTreeWidgetItem *formatItem = new QTreeWidgetItem( QStringList() << ' ' + tr( "Format" ) ); layItem->addChild( formatItem ); lstResults->setItemWidget( formatItem, 1, formatCombo ); - connect( formatCombo, qOverload( &QComboBox::currentIndexChanged ), - this, qOverload( &QgsIdentifyResultsDialog::formatChanged ) ); + connect( formatCombo, qOverload( &QComboBox::currentIndexChanged ), this, qOverload( &QgsIdentifyResultsDialog::formatChanged ) ); } else { @@ -1085,7 +1066,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, const auto value { attrs.at( i ) }; auto formattedValue { value.toString() }; bool isString = false; - if ( value.isValid( ) ) + if ( value.isValid() ) { if ( value.userType() == QMetaType::Type::Double ) { @@ -1115,7 +1096,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, const double val( value.toInt( &ok ) ); if ( ok ) { - formattedValue = QLocale().toString( val, 'f', 0 ); + formattedValue = QLocale().toString( val, 'f', 0 ); } } else if ( value.userType() == QMetaType::Type::LongLong ) @@ -1124,10 +1105,10 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, const double val( value.toLongLong( &ok ) ); if ( ok ) { - formattedValue = QLocale().toString( val, 'f', 0 ); + formattedValue = QLocale().toString( val, 'f', 0 ); } } - else if ( ! formattedValue.isEmpty() ) + else if ( !formattedValue.isEmpty() ) { isString = true; } @@ -1146,7 +1127,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, if ( foundLinks ) { auto valueLabel { std::make_unique( links ) }; - attrItem->setText( 1, QString( ) ); + attrItem->setText( 1, QString() ); valueLabel->setOpenExternalLinks( true ); lstResults->setItemWidget( attrItem, 1, valueLabel.release() ); } @@ -1167,8 +1148,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, { attrItem->webView()->setZoomFactor( attrItem->webView()->zoomFactor() * ( currentFormat == Qgis::RasterIdentifyFormat::Html ? 0.7 : 0.9 ) ); } - connect( attrItem->webView()->page(), &QWebPage::linkClicked, [ ]( const QUrl & url ) - { + connect( attrItem->webView()->page(), &QWebPage::linkClicked, []( const QUrl &url ) { QDesktopServices::openUrl( url ); } ); #endif @@ -1176,7 +1156,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, if ( !attributes.isEmpty() ) { QString value { attributes.begin().value() }; - if ( currentFormat == Qgis::RasterIdentifyFormat::Text ) + if ( currentFormat == Qgis::RasterIdentifyFormat::Text ) { value = QgsStringUtils::insertLinks( value ); value.prepend( QStringLiteral( "
    " ) ).append( QStringLiteral( "
    " ) ); @@ -1203,7 +1183,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, derivedItem->setAlwaysOnTopPriority( 0 ); featItem->addChild( derivedItem ); - for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) + for ( QMap::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) { derivedItem->addChild( new QTreeWidgetItem( QStringList() << it.key() << it.value() ) ); } @@ -1248,10 +1228,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer, } } -void QgsIdentifyResultsDialog::addFeature( QgsMeshLayer *layer, - const QString &label, - const QMap< QString, QString > &attributes, - const QMap< QString, QString > &derivedAttributes ) +void QgsIdentifyResultsDialog::addFeature( QgsMeshLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes ) { QTreeWidgetItem *layItem = layerItem( layer ); @@ -1274,10 +1251,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsMeshLayer *layer, return; } - QgsIdentifyResultsFeatureItem *featItem = new QgsIdentifyResultsFeatureItem( QgsFields(), - QgsFeature(), - layer->crs(), - QStringList() << label << QString() ); + QgsIdentifyResultsFeatureItem *featItem = new QgsIdentifyResultsFeatureItem( QgsFields(), QgsFeature(), layer->crs(), QStringList() << label << QString() ); layItem->addChild( featItem ); featItem->setExpanded( true ); @@ -1295,18 +1269,14 @@ void QgsIdentifyResultsDialog::addFeature( QgsMeshLayer *layer, derivedItem->setAlwaysOnTopPriority( 0 ); featItem->addChild( derivedItem ); - for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) + for ( QMap::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) { derivedItem->addChild( new QTreeWidgetItem( QStringList() << it.key() << it.value() ) ); } } } -void QgsIdentifyResultsDialog::addFeature( QgsVectorTileLayer *layer, - const QString &label, - const QgsFields &fields, - const QgsFeature &f, - const QMap< QString, QString > &derivedAttributes ) +void QgsIdentifyResultsDialog::addFeature( QgsVectorTileLayer *layer, const QString &label, const QgsFields &fields, const QgsFeature &f, const QMap &derivedAttributes ) { QTreeWidgetItem *layItem = layerItem( layer ); @@ -1332,8 +1302,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorTileLayer *layer, layItem->setFirstColumnSpanned( true ); const QString countSuffix = layItem->childCount() > 1 - ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) - : QString(); + ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) + : QString(); layItem->setText( 0, QStringLiteral( "%1 %2" ).arg( layer->name(), countSuffix ) ); if ( derivedAttributes.size() >= 0 && !QgsSettings().value( QStringLiteral( "/Map/hideDerivedAttributes" ), false ).toBool() ) @@ -1343,7 +1313,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorTileLayer *layer, derivedItem->setAlwaysOnTopPriority( 0 ); featItem->addChild( derivedItem ); - for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) + for ( QMap::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) { derivedItem->addChild( new QTreeWidgetItem( QStringList() << it.key() << it.value() ) ); } @@ -1356,7 +1326,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorTileLayer *layer, break; if ( QgsVariantUtils::isNull( attrs.at( i ) ) ) - continue; // skip attributes that are not present (there can be many of them) + continue; // skip attributes that are not present (there can be many of them) const QString value = fields.at( i ).displayString( attrs.at( i ) ); QgsTreeWidgetItem *attrItem = new QgsTreeWidgetItem( QStringList() << QString::number( i ) << value ); @@ -1388,10 +1358,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorTileLayer *layer, highlightFeature( featItem ); } -void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer, - const QString &label, - const QMap< QString, QString > &attributes, - const QMap< QString, QString > &derivedAttributes ) +void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes ) { QTreeWidgetItem *layItem = layerItem( layer ); @@ -1428,7 +1395,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer, feature.setAttribute( fieldIndex, v ); } - const QgsGeometry selectionGeometry( QgsGeometry::fromPointXY( QgsPointXY( attributes[ QStringLiteral( "X" ) ].toDouble(), attributes[ QStringLiteral( "Y" ) ].toDouble() ) ) ); + const QgsGeometry selectionGeometry( QgsGeometry::fromPointXY( QgsPointXY( attributes[QStringLiteral( "X" )].toDouble(), attributes[QStringLiteral( "Y" )].toDouble() ) ) ); feature.setGeometry( selectionGeometry ); QgsIdentifyResultsFeatureItem *featItem = new QgsIdentifyResultsFeatureItem( fields, feature, layer->crs(), QStringList() << label << QString() ); @@ -1436,8 +1403,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer, layItem->setFirstColumnSpanned( true ); const QString countSuffix = layItem->childCount() > 1 - ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) - : QString(); + ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) + : QString(); layItem->setText( 0, QStringLiteral( "%1 %2" ).arg( layer->name(), countSuffix ) ); // derived attributes @@ -1448,7 +1415,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer, derivedItem->setAlwaysOnTopPriority( 0 ); featItem->addChild( derivedItem ); - for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) + for ( QMap::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) { derivedItem->addChild( new QTreeWidgetItem( QStringList() << it.key() << it.value() ) ); } @@ -1464,10 +1431,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer, } -void QgsIdentifyResultsDialog::addFeature( QgsTiledSceneLayer *layer, - const QString &label, - const QMap< QString, QString > &attributes, - const QMap< QString, QString > &derivedAttributes ) +void QgsIdentifyResultsDialog::addFeature( QgsTiledSceneLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes ) { QTreeWidgetItem *layItem = layerItem( layer ); @@ -1489,8 +1453,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsTiledSceneLayer *layer, layItem->setFirstColumnSpanned( true ); const QString countSuffix = layItem->childCount() > 1 - ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) - : QString(); + ? QStringLiteral( " [%1]" ).arg( layItem->childCount() ) + : QString(); layItem->setText( 0, QStringLiteral( "%1 %2" ).arg( layer->name(), countSuffix ) ); // TODO: support attributes in future @@ -1503,7 +1467,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsTiledSceneLayer *layer, derivedItem->setAlwaysOnTopPriority( 0 ); featItem->addChild( derivedItem ); - for ( QMap< QString, QString>::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) + for ( QMap::const_iterator it = derivedAttributes.begin(); it != derivedAttributes.end(); ++it ) { QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << it.key() << it.value() ); attrItem->setToolTip( 1, it.value() ); @@ -1677,7 +1641,6 @@ void QgsIdentifyResultsDialog::keyPressEvent( QKeyEvent *event ) void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent *event ) { - // only handle context menu event if showing tree widget if ( stackedWidget->currentIndex() != 0 ) return; @@ -1712,7 +1675,8 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent *event ) mActionPopup->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionFormView.svg" ) ), vlayer->isEditable() ? tr( "Edit Feature Form…" ) : tr( "View Feature Form…" ), - this, &QgsIdentifyResultsDialog::featureForm ); + this, &QgsIdentifyResultsDialog::featureForm + ); } if ( featItem->feature().isValid() ) @@ -1756,11 +1720,11 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent *event ) mActionPopup->addAction( tr( "Clear Results" ), this, &QgsIdentifyResultsDialog::clear ); mActionPopup->addAction( tr( "Clear Highlights" ), this, &QgsIdentifyResultsDialog::clearHighlights ); mActionPopup->addAction( tr( "Highlight All" ), this, &QgsIdentifyResultsDialog::highlightAll ); - mActionPopup->addAction( tr( "Highlight Layer" ), this, [ = ] { highlightLayer(); } ); + mActionPopup->addAction( tr( "Highlight Layer" ), this, [=] { highlightLayer(); } ); if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() ) { - mActionPopup->addAction( tr( "Activate Layer" ), this, [ = ] { activateLayer(); } ); - mActionPopup->addAction( tr( "Layer Properties…" ), this, [ = ] { layerProperties(); } ); + mActionPopup->addAction( tr( "Activate Layer" ), this, [=] { activateLayer(); } ); + mActionPopup->addAction( tr( "Layer Properties…" ), this, [=] { layerProperties(); } ); } mActionPopup->addSeparator(); mActionPopup->addAction( tr( "Expand All" ), this, &QgsIdentifyResultsDialog::expandAll ); @@ -1785,7 +1749,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent *event ) if ( action.isEnabledOnlyWhenEditable() ) continue; - QgsFeatureAction *a = new QgsFeatureAction( action.name(), mFeatures[ featIdx ], vlayer, action.id(), idx, this ); + QgsFeatureAction *a = new QgsFeatureAction( action.name(), mFeatures[featIdx], vlayer, action.id(), idx, this ); mActionPopup->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mAction.svg" ) ), action.name(), a, &QgsFeatureAction::execute ); } } @@ -1795,7 +1759,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent *event ) { //get valid QgsMapLayerActions for this layer QgsMapLayerActionContext context = QgisApp::instance()->createMapLayerActionContext(); - const QList< QgsMapLayerAction * > registeredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( vlayer, Qgis::MapLayerActionTarget::AllActions, context ); + const QList registeredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( vlayer, Qgis::MapLayerActionTarget::AllActions, context ); if ( !registeredActions.isEmpty() ) { @@ -1809,7 +1773,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent *event ) if ( ( *actionIt )->isEnabledOnlyWhenEditable() ) continue; - QgsIdentifyResultsDialogMapLayerAction *a = new QgsIdentifyResultsDialogMapLayerAction( ( *actionIt )->text(), this, ( *actionIt ), vlayer, &( mFeatures[ featIdx ] ) ); + QgsIdentifyResultsDialogMapLayerAction *a = new QgsIdentifyResultsDialogMapLayerAction( ( *actionIt )->text(), this, ( *actionIt ), vlayer, &( mFeatures[featIdx] ) ); mActionPopup->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mAction.svg" ) ), ( *actionIt )->text(), a, &QgsIdentifyResultsDialogMapLayerAction::execute ); } } @@ -1873,14 +1837,14 @@ void QgsIdentifyResultsDialog::updateViewModes() for ( int i = 0; i < lstResults->topLevelItemCount(); i++ ) { QTreeWidgetItem *item = lstResults->topLevelItem( i ); - if ( rasterLayer( item ) ) rasterCount++; + if ( rasterLayer( item ) ) + rasterCount++; } lblViewMode->setEnabled( rasterCount > 0 ); cmbViewMode->setEnabled( rasterCount > 0 ); if ( rasterCount == 0 ) cmbViewMode->setCurrentIndex( 0 ); - } void QgsIdentifyResultsDialog::clearHighlights() @@ -1943,7 +1907,7 @@ void QgsIdentifyResultsDialog::doAction( QTreeWidgetItem *item, const QUuid &act } } - const QgsFeature feat = featItem->data( 0, FeatureRole ).value< QgsFeature >(); + const QgsFeature feat = featItem->data( 0, FeatureRole ).value(); layer->actions()->doAction( action, feat, idx, mExpressionContextScope ); } @@ -1960,7 +1924,7 @@ void QgsIdentifyResultsDialog::doMapLayerAction( QTreeWidgetItem *item, QgsMapLa if ( !action ) return; - const QgsFeature feat = featItem->data( 0, FeatureRole ).value< QgsFeature >(); + const QgsFeature feat = featItem->data( 0, FeatureRole ).value(); QgsMapLayerActionContext context = QgisApp::instance()->createMapLayerActionContext(); Q_NOWARN_DEPRECATED_PUSH action->triggerForFeature( layer, feat ); @@ -2124,8 +2088,7 @@ QgsAttributeMap QgsIdentifyResultsDialog::retrieveAttributes( QTreeWidgetItem *i if ( item->childCount() > 0 ) continue; - attributes.insert( item->data( 0, Qt::UserRole + 1 ).toInt(), - retrieveAttribute( item ) ); + attributes.insert( item->data( 0, Qt::UserRole + 1 ).toInt(), retrieveAttribute( item ) ); } return attributes; @@ -2289,8 +2252,7 @@ void QgsIdentifyResultsDialog::featureDeleted( QgsFeatureId fid ) QgsDebugMsgLevel( QStringLiteral( "item %1 / %2" ).arg( i ).arg( tblResults->rowCount() ), 2 ); QTableWidgetItem *layItem = tblResults->item( i, 0 ); QTableWidgetItem *featItem = tblResults->item( i, 1 ); - if ( layItem && layItem->data( Qt::UserRole ).value() == sender() && - featItem && STRING_TO_FID( featItem->data( Qt::UserRole ) ) == fid ) + if ( layItem && layItem->data( Qt::UserRole ).value() == sender() && featItem && STRING_TO_FID( featItem->data( Qt::UserRole ) ) == fid ) { QgsDebugMsgLevel( QStringLiteral( "removing row %1" ).arg( i ), 2 ); tblResults->removeRow( i ); @@ -2333,7 +2295,7 @@ void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx, const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vlayer, fld.name() ); value = representValue( vlayer, setup, fld.name(), val ); - QgsTreeWidgetItem *treeItem = static_cast< QgsTreeWidgetItem * >( item ); + QgsTreeWidgetItem *treeItem = static_cast( item ); treeItem->setSortData( 1, value ); treeItem->setToolTip( 1, value ); @@ -2519,11 +2481,9 @@ void QgsIdentifyResultsDialog::layerProperties() void QgsIdentifyResultsDialog::activateLayer() { - connect( this, static_cast( &QgsIdentifyResultsDialog::activateLayer ) - , QgisApp::instance(), &QgisApp::setActiveLayer ); + connect( this, static_cast( &QgsIdentifyResultsDialog::activateLayer ), QgisApp::instance(), &QgisApp::setActiveLayer ); emit activateLayer( layer( lstResults->currentItem() ) ); - disconnect( this, static_cast( &QgsIdentifyResultsDialog::activateLayer ), - QgisApp::instance(), &QgisApp::setActiveLayer ); + disconnect( this, static_cast( &QgsIdentifyResultsDialog::activateLayer ), QgisApp::instance(), &QgisApp::setActiveLayer ); } void QgsIdentifyResultsDialog::layerProperties( QTreeWidgetItem *item ) @@ -2542,7 +2502,7 @@ void QgsIdentifyResultsDialog::expandAll() // creating a potential deeply nested tree. QTreeWidgetItemIterator it( lstResults ); - for ( ; *it ; ++it ) + for ( ; *it; ++it ) { if ( ( *it )->childCount() ) lstResults->expandItem( *it ); @@ -2675,8 +2635,8 @@ void QgsIdentifyResultsDialog::mActionAutoFeatureForm_toggled( bool checked ) { QgsSettings settings; settings.setValue( QStringLiteral( "Map/identifyAutoFeatureForm" ), checked ); - mActionSelectFeaturesOnMouseOver->setEnabled( ! checked ); - if ( mSelectModeButton->defaultAction( ) == mActionSelectFeaturesOnMouseOver ) + mActionSelectFeaturesOnMouseOver->setEnabled( !checked ); + if ( mSelectModeButton->defaultAction() == mActionSelectFeaturesOnMouseOver ) { mSelectionMode = QgsMapToolSelectionHandler::SelectSimple; mSelectModeButton->setDefaultAction( mActionSelectFeatures ); @@ -2730,7 +2690,6 @@ void QgsIdentifyResultsDialog::copyFeature() void QgsIdentifyResultsDialog::toggleFeatureSelection() { - QgsIdentifyResultsFeatureItem *item = dynamic_cast( featureItem( lstResults->selectedItems().value( 0 ) ) ); if ( !item ) // should not happen @@ -2758,7 +2717,7 @@ void QgsIdentifyResultsDialog::formatChanged( int index ) return; } - const Qgis::RasterIdentifyFormat format = combo->itemData( index, Qt::UserRole ).value< Qgis::RasterIdentifyFormat >(); + const Qgis::RasterIdentifyFormat format = combo->itemData( index, Qt::UserRole ).value(); QgsDebugMsgLevel( QStringLiteral( "format = %1" ).arg( qgsEnumValueToKey( format ) ), 2 ); QgsRasterLayer *layer = qobject_cast( combo->itemData( index, Qt::UserRole + 1 ).value() ); if ( !layer ) diff --git a/src/app/qgsidentifyresultsdialog.h b/src/app/qgsidentifyresultsdialog.h index 1070a56783f3..9461be7242ac 100644 --- a/src/app/qgsidentifyresultsdialog.h +++ b/src/app/qgsidentifyresultsdialog.h @@ -66,14 +66,16 @@ class APP_EXPORT QgsIdentifyResultsWebView : public QgsWebView void print(); void downloadRequested( const QNetworkRequest &request ); void unsupportedContent( QNetworkReply *reply ); + protected: void contextMenuEvent( QContextMenuEvent * ) override; QgsWebView *createWindow( QWebPage::WebWindowType type ) override; + private: void handleDownload( QUrl url ); }; -class APP_EXPORT QgsIdentifyResultsFeatureItem: public QTreeWidgetItem +class APP_EXPORT QgsIdentifyResultsFeatureItem : public QTreeWidgetItem { public: QgsIdentifyResultsFeatureItem( const QgsFields &fields, const QgsFeature &feature, const QgsCoordinateReferenceSystem &crs, const QStringList &strings = QStringList() ); @@ -88,7 +90,7 @@ class APP_EXPORT QgsIdentifyResultsFeatureItem: public QTreeWidgetItem }; //! Tree widget item being the parent item of a referenced or referencing relation -class APP_EXPORT QgsIdentifyResultsRelationItem: public QTreeWidgetItem +class APP_EXPORT QgsIdentifyResultsRelationItem : public QTreeWidgetItem { public: //! Constructor @@ -112,7 +114,7 @@ class APP_EXPORT QgsIdentifyResultsRelationItem: public QTreeWidgetItem QgsFeature mTopFeature; }; -class APP_EXPORT QgsIdentifyResultsWebViewItem: public QObject, public QTreeWidgetItem +class APP_EXPORT QgsIdentifyResultsWebViewItem : public QObject, public QTreeWidgetItem { Q_OBJECT @@ -132,10 +134,8 @@ class APP_EXPORT QgsIdentifyResultsWebViewItem: public QObject, public QTreeWidg class APP_EXPORT QgsIdentifyPlotCurve { public: - QgsIdentifyPlotCurve() { mPlotCurve = nullptr; } - QgsIdentifyPlotCurve( const QMap &attributes, - QwtPlot *plot, const QString &title = QString(), QColor color = QColor() ); + QgsIdentifyPlotCurve( const QMap &attributes, QwtPlot *plot, const QString &title = QString(), QColor color = QColor() ); ~QgsIdentifyPlotCurve(); QgsIdentifyPlotCurve( const QgsIdentifyPlotCurve &rh ) = delete; @@ -143,15 +143,13 @@ class APP_EXPORT QgsIdentifyPlotCurve private: QwtPlotCurve *mPlotCurve = nullptr; - }; -class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBase +class APP_EXPORT QgsIdentifyResultsDialog : public QDialog, private Ui::QgsIdentifyResultsBase { Q_OBJECT public: - /** * Constructor */ @@ -163,55 +161,34 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti static const QgsSettingsEntryBool *settingShowRelations; //! Adds feature from vector layer - void addFeature( QgsVectorLayer *layer, - const QgsFeature &f, - const QMap< QString, QString > &derivedAttributes ); + void addFeature( QgsVectorLayer *layer, const QgsFeature &f, const QMap &derivedAttributes ); //! Adds feature from raster layer - void addFeature( QgsRasterLayer *layer, - const QString &label, - const QMap< QString, QString > &attributes, - const QMap< QString, QString > &derivedAttributes, - const QgsFields &fields = QgsFields(), - const QgsFeature &feature = QgsFeature(), - const QMap ¶ms = ( QMap() ) ); + void addFeature( QgsRasterLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes, const QgsFields &fields = QgsFields(), const QgsFeature &feature = QgsFeature(), const QMap ¶ms = ( QMap() ) ); /** * Adds results from mesh layer * \since QGIS 3.6 */ - void addFeature( QgsMeshLayer *layer, - const QString &label, - const QMap< QString, QString > &attributes, - const QMap< QString, QString > &derivedAttributes ); + void addFeature( QgsMeshLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes ); /** * Adds results from vector tile layer * \since QGIS 3.14 */ - void addFeature( QgsVectorTileLayer *layer, - const QString &label, - const QgsFields &fields, - const QgsFeature &feature, - const QMap< QString, QString > &derivedAttributes ); + void addFeature( QgsVectorTileLayer *layer, const QString &label, const QgsFields &fields, const QgsFeature &feature, const QMap &derivedAttributes ); /** * Adds results from point cloud layer * \since QGIS 3.18 */ - void addFeature( QgsPointCloudLayer *layer, - const QString &label, - const QMap< QString, QString > &attributes, - const QMap< QString, QString > &derivedAttributes ); + void addFeature( QgsPointCloudLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes ); /** * Adds results from tiled scene layer * \since QGIS 3.34 */ - void addFeature( QgsTiledSceneLayer *layer, - const QString &label, - const QMap< QString, QString > &attributes, - const QMap< QString, QString > &derivedAttributes ); + void addFeature( QgsTiledSceneLayer *layer, const QString &label, const QMap &attributes, const QMap &derivedAttributes ); //! Adds feature from identify results void addFeature( const QgsMapToolIdentify::IdentifyResult &result ); @@ -307,8 +284,16 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti void mActionShowRelations_toggled( bool checked ); - void mExpandAction_triggered( bool checked ) { Q_UNUSED( checked ) expandAll(); } - void mCollapseAction_triggered( bool checked ) { Q_UNUSED( checked ) collapseAll(); } + void mExpandAction_triggered( bool checked ) + { + Q_UNUSED( checked ) + expandAll(); + } + void mCollapseAction_triggered( bool checked ) + { + Q_UNUSED( checked ) + collapseAll(); + } void mActionCopy_triggered( bool checked ); @@ -330,10 +315,10 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti }; QMenu *mActionPopup = nullptr; - QHash mHighlights; + QHash mHighlights; QgsMapCanvas *mCanvas = nullptr; QList mFeatures; - QMap< QString, QMap< QString, QVariant > > mWidgetCaches; + QMap> mWidgetCaches; QgsExpressionContextScope mExpressionContextScope; QToolButton *mSelectModeButton = nullptr; diff --git a/src/app/qgslayernotesmanager.cpp b/src/app/qgslayernotesmanager.cpp index f8e49ed4b531..768a140ae6ac 100644 --- a/src/app/qgslayernotesmanager.cpp +++ b/src/app/qgslayernotesmanager.cpp @@ -50,8 +50,7 @@ QgsLayerNotesDialog::QgsLayerNotesDialog( QWidget *parent ) QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Save | QDialogButtonBox::Help | QDialogButtonBox::Cancel ); connect( buttonBox->button( QDialogButtonBox::Save ), &QPushButton::clicked, this, &QDialog::accept ); connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject ); - connect( buttonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( buttonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#layer-notes" ) ); } ); layout->addWidget( buttonBox ); diff --git a/src/app/qgslayernotesmanager.h b/src/app/qgslayernotesmanager.h index cc20834fa523..59bcd8540f13 100644 --- a/src/app/qgslayernotesmanager.h +++ b/src/app/qgslayernotesmanager.h @@ -26,7 +26,6 @@ class QgsRichTextEditor; class QgsLayerNotesManager { public: - /** * Shows a dialog allowing users to edit the notes for the specified \a layer. */ @@ -38,7 +37,6 @@ class QgsLayerNotesDialog : public QDialog Q_OBJECT public: - QgsLayerNotesDialog( QWidget *parent ); void setNotes( const QString ¬es ); diff --git a/src/app/qgslayerstylingwidget.cpp b/src/app/qgslayerstylingwidget.cpp index acbd3e98d242..af9ed23c38e1 100644 --- a/src/app/qgslayerstylingwidget.cpp +++ b/src/app/qgslayerstylingwidget.cpp @@ -79,9 +79,9 @@ QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBa mContext.setMessageBar( messageBar ); mOptionsListWidget->setIconSize( QgisApp::instance()->iconSize( false ) ); - mOptionsListWidget->setMaximumWidth( static_cast< int >( mOptionsListWidget->iconSize().width() * 1.18 ) ); + mOptionsListWidget->setMaximumWidth( static_cast( mOptionsListWidget->iconSize().width() * 1.18 ) ); - connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( QgsMapLayer * ) > ( &QgsProject::layerWillBeRemoved ), this, &QgsLayerStylingWidget::layerAboutToBeRemoved ); + connect( QgsProject::instance(), static_cast( &QgsProject::layerWillBeRemoved ), this, &QgsLayerStylingWidget::layerAboutToBeRemoved ); QgsSettings settings; mLiveApplyCheck->setChecked( settings.value( QStringLiteral( "UI/autoApplyStyling" ), true ).toBool() ); @@ -110,14 +110,7 @@ QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBa connect( mLayerCombo, &QgsMapLayerComboBox::layerChanged, this, &QgsLayerStylingWidget::setLayer ); connect( mLiveApplyCheck, &QAbstractButton::toggled, this, &QgsLayerStylingWidget::liveApplyToggled ); - mLayerCombo->setFilters( Qgis::LayerFilter::HasGeometry - | Qgis::LayerFilter::RasterLayer - | Qgis::LayerFilter::PluginLayer - | Qgis::LayerFilter::MeshLayer - | Qgis::LayerFilter::VectorTileLayer - | Qgis::LayerFilter::PointCloudLayer - | Qgis::LayerFilter::TiledSceneLayer - | Qgis::LayerFilter::AnnotationLayer ); + mLayerCombo->setFilters( Qgis::LayerFilter::HasGeometry | Qgis::LayerFilter::RasterLayer | Qgis::LayerFilter::PluginLayer | Qgis::LayerFilter::MeshLayer | Qgis::LayerFilter::VectorTileLayer | Qgis::LayerFilter::PointCloudLayer | Qgis::LayerFilter::TiledSceneLayer | Qgis::LayerFilter::AnnotationLayer ); mLayerCombo->setAdditionalLayers( { QgsProject::instance()->mainAnnotationLayer() } ); mStackedWidget->setCurrentIndex( 0 ); @@ -340,7 +333,7 @@ void QgsLayerStylingWidget::apply() QWidget *current = mWidgetStack->mainPanel(); bool styleWasChanged = false; - bool triggerRepaint = false; // whether the change needs the layer to be repainted + bool triggerRepaint = false; // whether the change needs the layer to be repainted if ( QgsMaskingWidget *widget = qobject_cast( current ) ) { widget->apply(); @@ -434,7 +427,7 @@ void QgsLayerStylingWidget::redo() void QgsLayerStylingWidget::updateCurrentWidgetLayer() { if ( !mCurrentLayer && !mContext.layerTreeGroup() ) - return; // non-spatial are ignored in setLayer() + return; // non-spatial are ignored in setLayer() mBlockAutoApply = true; @@ -516,7 +509,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() QgsVectorLayer *vlayer = qobject_cast( mCurrentLayer ); #ifdef HAVE_3D - const int tabShift = 1; // To move subsequent tabs + const int tabShift = 1; // To move subsequent tabs #else const int tabShift = 0; #endif @@ -562,7 +555,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() break; } #ifdef HAVE_3D - case 3: // 3D View + case 3: // 3D View { if ( !mVector3DWidget ) { @@ -671,7 +664,6 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() } case 3: // Attribute Tables { - if ( rlayer->attributeTableCount() > 0 ) { if ( !mRasterAttributeTableWidget ) @@ -688,15 +680,15 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() } else { - if ( ! mRasterAttributeTableDisabledWidget ) + if ( !mRasterAttributeTableDisabledWidget ) { - mRasterAttributeTableDisabledWidget = new QgsPanelWidget{ mWidgetStack }; - QVBoxLayout *layout = new QVBoxLayout{ mRasterAttributeTableDisabledWidget }; + mRasterAttributeTableDisabledWidget = new QgsPanelWidget { mWidgetStack }; + QVBoxLayout *layout = new QVBoxLayout { mRasterAttributeTableDisabledWidget }; mRasterAttributeTableDisabledWidget->setLayout( layout ); QLabel *label { new QLabel( tr( "There are no raster attribute tables associated with this data source.
    " - "If the current symbology can be converted to an attribute table you " - "can create a new attribute table using the context menu available in the " - "layer tree or in the layer properties dialog." ) )}; + "If the current symbology can be converted to an attribute table you " + "can create a new attribute table using the context menu available in the " + "layer tree or in the layer properties dialog." ) ) }; label->setWordWrap( true ); mRasterAttributeTableDisabledWidget->layout()->addWidget( label ); layout->addStretch(); @@ -726,7 +718,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() connect( mMeshStyleWidget, &QgsPanelWidget::widgetChanged, this, &QgsLayerStylingWidget::autoApply ); mWidgetStack->setMainPanel( mMeshStyleWidget ); - connect( meshLayer, &QgsMeshLayer::reloaded, this, [this] {mMeshStyleWidget->syncToLayer( mCurrentLayer );} ); + connect( meshLayer, &QgsMeshLayer::reloaded, this, [this] { mMeshStyleWidget->syncToLayer( mCurrentLayer ); } ); break; } case 1: // Labeling @@ -738,7 +730,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() break; } #ifdef HAVE_3D - case 2: // 3D View + case 2: // 3D View { if ( !mMesh3DWidget ) { @@ -749,7 +741,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer() mMesh3DWidget->syncToLayer( meshLayer ); mWidgetStack->setMainPanel( mMesh3DWidget ); - connect( meshLayer, &QgsMeshLayer::reloaded, this, [this] {mMesh3DWidget->syncToLayer( mCurrentLayer );} ); + connect( meshLayer, &QgsMeshLayer::reloaded, this, [this] { mMesh3DWidget->syncToLayer( mCurrentLayer ); } ); break; } #endif @@ -810,7 +802,7 @@ void QgsLayerStylingWidget::setCurrentPage( QgsLayerStylingWidget::Page page ) for ( int i = 0; i < mOptionsListWidget->count(); ++i ) { int data = mOptionsListWidget->item( i )->data( Qt::UserRole ).toInt(); - if ( data == static_cast< int >( page ) ) + if ( data == static_cast( page ) ) { mOptionsListWidget->setCurrentRow( i ); return; @@ -827,7 +819,7 @@ void QgsLayerStylingWidget::setAnnotationItem( QgsAnnotationLayer *layer, const mStackedWidget->setCurrentIndex( mLayerPage ); } - if ( QgsMapLayerConfigWidget *configWidget = qobject_cast< QgsMapLayerConfigWidget * >( mWidgetStack->mainPanel() ) ) + if ( QgsMapLayerConfigWidget *configWidget = qobject_cast( mWidgetStack->mainPanel() ) ) { configWidget->setMapLayerConfigWidgetContext( mContext ); } @@ -860,7 +852,7 @@ void QgsLayerStylingWidget::setLayerTreeGroup( QgsLayerTreeGroup *group ) mStackedWidget->setCurrentIndex( 1 ); - if ( QgsMapLayerConfigWidget *configWidget = qobject_cast< QgsMapLayerConfigWidget * >( mWidgetStack->mainPanel() ) ) + if ( QgsMapLayerConfigWidget *configWidget = qobject_cast( mWidgetStack->mainPanel() ) ) { configWidget->setMapLayerConfigWidgetContext( mContext ); } @@ -868,7 +860,7 @@ void QgsLayerStylingWidget::setLayerTreeGroup( QgsLayerTreeGroup *group ) void QgsLayerStylingWidget::focusDefaultWidget() { - if ( QgsMapLayerConfigWidget *configWidget = qobject_cast< QgsMapLayerConfigWidget * >( mWidgetStack->mainPanel() ) ) + if ( QgsMapLayerConfigWidget *configWidget = qobject_cast( mWidgetStack->mainPanel() ) ) { configWidget->focusDefaultWidget(); } @@ -948,7 +940,7 @@ bool QgsMapLayerStyleCommand::mergeWith( const QUndoCommand *other ) const QgsMapLayerStyleCommand *otherCmd = static_cast( other ); if ( otherCmd->mLayer != mLayer ) - return false; // should never happen though... + return false; // should never happen though... // only merge commands if they are created shortly after each other // (e.g. user keeps modifying one property) @@ -972,8 +964,7 @@ QgsLayerStyleManagerWidgetFactory::QgsLayerStyleManagerWidgetFactory() QgsMapLayerConfigWidget *QgsLayerStyleManagerWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const { Q_UNUSED( dockMode ) - return new QgsMapLayerStyleManagerWidget( layer, canvas, parent ); - + return new QgsMapLayerStyleManagerWidget( layer, canvas, parent ); } bool QgsLayerStyleManagerWidgetFactory::supportsLayer( QgsMapLayer *layer ) const diff --git a/src/app/qgslayerstylingwidget.h b/src/app/qgslayerstylingwidget.h index 832f37846814..59a196d290b4 100644 --- a/src/app/qgslayerstylingwidget.h +++ b/src/app/qgslayerstylingwidget.h @@ -92,7 +92,6 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty { Q_OBJECT public: - enum Page { Symbology = 1, @@ -102,7 +101,7 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty History, Symbology3D, RasterAttributeTables, //!< Raster attribute tables, since QGIS 3.30 - VectorDiagram, //!< Vector diagram, since QGIS 3.40 + VectorDiagram, //!< Vector diagram, since QGIS 3.40 }; QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBar *messageBar, const QList &pages, QWidget *parent = nullptr ); @@ -159,7 +158,7 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty private: void pushUndoItem( const QString &name, bool triggerRepaint = true ); - void emitLayerStyleChanged( const QString ¤tStyleName ) {emit layerStyleChanged( currentStyleName );}; + void emitLayerStyleChanged( const QString ¤tStyleName ) { emit layerStyleChanged( currentStyleName ); }; void emitLayerStyleRenamed(); int mNotSupportedPage; int mLayerPage; diff --git a/src/app/qgslayertreegrouppropertieswidget.cpp b/src/app/qgslayertreegrouppropertieswidget.cpp index aa2cd84e6f22..3a2617ae2d62 100644 --- a/src/app/qgslayertreegrouppropertieswidget.cpp +++ b/src/app/qgslayertreegrouppropertieswidget.cpp @@ -37,7 +37,7 @@ QgsLayerTreeGroupPropertiesWidget::QgsLayerTreeGroupPropertiesWidget( QgsMapCanv mEffectWidget->setPaintEffect( mPaintEffect.get() ); connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged ); - connect( mBlendModeComboBox, qOverload< int >( &QgsBlendModeComboBox::currentIndexChanged ), this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged ); + connect( mBlendModeComboBox, qOverload( &QgsBlendModeComboBox::currentIndexChanged ), this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged ); connect( mEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged ); connect( mRenderAsGroupCheckBox, &QGroupBox::toggled, this, &QgsLayerTreeGroupPropertiesWidget::onLayerPropertyChanged ); @@ -159,4 +159,3 @@ bool QgsLayerTreeGroupPropertiesWidgetFactory::supportsLayerTreeGroup( QgsLayerT { return true; } - diff --git a/src/app/qgslayertreegrouppropertieswidget.h b/src/app/qgslayertreegrouppropertieswidget.h index c109ce1de507..b03df7022e05 100644 --- a/src/app/qgslayertreegrouppropertieswidget.h +++ b/src/app/qgslayertreegrouppropertieswidget.h @@ -29,7 +29,6 @@ class QgsLayerTreeGroupPropertiesWidget : public QgsMapLayerConfigWidget, public { Q_OBJECT public: - QgsLayerTreeGroupPropertiesWidget( QgsMapCanvas *canvas, QWidget *parent ); ~QgsLayerTreeGroupPropertiesWidget() override; @@ -43,13 +42,12 @@ class QgsLayerTreeGroupPropertiesWidget : public QgsMapLayerConfigWidget, public private slots: void onLayerPropertyChanged(); - private: - QPointer< QgsLayerTreeGroup > mLayerTreeGroup; + private: + QPointer mLayerTreeGroup; bool mBlockLayerUpdates = false; - std::unique_ptr< QgsPaintEffect > mPaintEffect; - + std::unique_ptr mPaintEffect; }; @@ -67,5 +65,4 @@ class QgsLayerTreeGroupPropertiesWidgetFactory : public QObject, public QgsMapLa }; - #endif // QGSLAYERTREEGROUPPROPERTIESWIDGET_H diff --git a/src/app/qgslayertreeviewbadlayerindicator.cpp b/src/app/qgslayertreeviewbadlayerindicator.cpp index 3207f74b5acf..4866eeb8ebaf 100644 --- a/src/app/qgslayertreeviewbadlayerindicator.cpp +++ b/src/app/qgslayertreeviewbadlayerindicator.cpp @@ -66,7 +66,7 @@ void QgsLayerTreeViewBadLayerIndicatorProvider::onIndicatorClicked( const QModel else { QStringList thisLayerErrors; - QList< Error > newErrors; + QList newErrors; for ( const Error &error : std::as_const( mErrors ) ) { if ( error.layer != layer ) diff --git a/src/app/qgslayertreeviewbadlayerindicator.h b/src/app/qgslayertreeviewbadlayerindicator.h index 9af458bb052d..aa88de4008ce 100644 --- a/src/app/qgslayertreeviewbadlayerindicator.h +++ b/src/app/qgslayertreeviewbadlayerindicator.h @@ -56,15 +56,15 @@ class QgsLayerTreeViewBadLayerIndicatorProvider : public QgsLayerTreeViewIndicat struct Error { - Error( const QString &error, QgsMapLayer *layer = nullptr ) - : error( error ) - , layer( layer ) - {} - QString error; - QPointer< QgsMapLayer > layer; + Error( const QString &error, QgsMapLayer *layer = nullptr ) + : error( error ) + , layer( layer ) + {} + QString error; + QPointer layer; }; - QList< Error > mErrors; + QList mErrors; }; #endif // QGSLAYERTREEVIEWBADLAYERINDICATORPROVIDER_H diff --git a/src/app/qgslayertreeviewembeddedindicator.cpp b/src/app/qgslayertreeviewembeddedindicator.cpp index 81e62255f576..359d977d6ea5 100644 --- a/src/app/qgslayertreeviewembeddedindicator.cpp +++ b/src/app/qgslayertreeviewembeddedindicator.cpp @@ -55,9 +55,9 @@ void QgsLayerTreeViewEmbeddedIndicatorProvider::onAddedChildren( QgsLayerTreeNod } } -std::unique_ptr< QgsLayerTreeViewIndicator > QgsLayerTreeViewEmbeddedIndicatorProvider::newIndicator( const QString &project ) +std::unique_ptr QgsLayerTreeViewEmbeddedIndicatorProvider::newIndicator( const QString &project ) { - std::unique_ptr< QgsLayerTreeViewIndicator > indicator = std::make_unique< QgsLayerTreeViewIndicator >( this ); + std::unique_ptr indicator = std::make_unique( this ); indicator->setIcon( mIcon ); indicator->setToolTip( tr( "Embedded from %1" ).arg( project ) ); mIndicators.insert( indicator.get() ); diff --git a/src/app/qgslayertreeviewembeddedindicator.h b/src/app/qgslayertreeviewembeddedindicator.h index 32dcd4624d78..e49d353c7325 100644 --- a/src/app/qgslayertreeviewembeddedindicator.h +++ b/src/app/qgslayertreeviewembeddedindicator.h @@ -36,7 +36,7 @@ class QgsLayerTreeViewEmbeddedIndicatorProvider : public QObject void onAddedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo ); private: - std::unique_ptr< QgsLayerTreeViewIndicator > newIndicator( const QString &project ); + std::unique_ptr newIndicator( const QString &project ); void addIndicatorForEmbeddedLayer( QgsLayerTreeNode *node ); private: diff --git a/src/app/qgslayertreeviewfilterindicator.cpp b/src/app/qgslayertreeviewfilterindicator.cpp index ca81c3ba1287..ac23c0986e82 100644 --- a/src/app/qgslayertreeviewfilterindicator.cpp +++ b/src/app/qgslayertreeviewfilterindicator.cpp @@ -40,7 +40,7 @@ void QgsLayerTreeViewFilterIndicatorProvider::onIndicatorClicked( const QModelIn QgsVectorLayer *vl = qobject_cast( layer ); if ( vl && vl->isEditable() ) { - QgisApp::instance()->messageBar()->pushWarning( tr( "Edit filter" ), tr( "Cannot edit filter when layer is in edit mode" ) ); + QgisApp::instance()->messageBar()->pushWarning( tr( "Edit filter" ), tr( "Cannot edit filter when layer is in edit mode" ) ); return; } @@ -158,17 +158,17 @@ bool QgsLayerTreeViewFilterIndicatorProvider::acceptLayer( QgsMapLayer *layer ) case Qgis::LayerType::Vector: { QgsVectorLayer *vlayer = qobject_cast( layer ); - return ! vlayer->subsetString().isEmpty(); + return !vlayer->subsetString().isEmpty(); } case Qgis::LayerType::Raster: { QgsRasterLayer *rlayer = qobject_cast( layer ); - return ! rlayer->subsetString().isEmpty(); + return !rlayer->subsetString().isEmpty(); } case Qgis::LayerType::PointCloud: { QgsPointCloudLayer *pclayer = qobject_cast( layer ); - return ! pclayer->subsetString().isEmpty(); + return !pclayer->subsetString().isEmpty(); } case Qgis::LayerType::Annotation: case Qgis::LayerType::Group: diff --git a/src/app/qgslayertreeviewfilterindicator.h b/src/app/qgslayertreeviewfilterindicator.h index 356e8919a235..340d8d9b1c2f 100644 --- a/src/app/qgslayertreeviewfilterindicator.h +++ b/src/app/qgslayertreeviewfilterindicator.h @@ -36,7 +36,7 @@ class QgsLayerTreeViewFilterIndicatorProvider : public QgsLayerTreeViewIndicator void onIndicatorClicked( const QModelIndex &index ) override; protected: - void connectSignals( QgsMapLayer *layer ) override ; + void connectSignals( QgsMapLayer *layer ) override; void disconnectSignals( QgsMapLayer *layer ) override; }; diff --git a/src/app/qgslayertreeviewindicatorprovider.cpp b/src/app/qgslayertreeviewindicatorprovider.cpp index 2acc9927df9d..b65a744228ef 100644 --- a/src/app/qgslayertreeviewindicatorprovider.cpp +++ b/src/app/qgslayertreeviewindicatorprovider.cpp @@ -32,7 +32,6 @@ QgsLayerTreeViewIndicatorProvider::QgsLayerTreeViewIndicatorProvider( QgsLayerTr : QObject( view ) , mLayerTreeView( view ) { - QgsLayerTree *tree = mLayerTreeView->layerTreeModel()->rootGroup(); onAddedChildren( tree, 0, tree->children().count() - 1 ); @@ -54,7 +53,7 @@ void QgsLayerTreeViewIndicatorProvider::onAddedChildren( QgsLayerTreeNode *node, } else if ( QgsLayerTree::isLayer( childNode ) ) { - if ( QgsLayerTreeLayer *layerNode = qobject_cast< QgsLayerTreeLayer * >( childNode ) ) + if ( QgsLayerTreeLayer *layerNode = qobject_cast( childNode ) ) { if ( layerNode->layer() ) { @@ -87,8 +86,7 @@ void QgsLayerTreeViewIndicatorProvider::onWillRemoveChildren( QgsLayerTreeNode * else if ( QgsLayerTree::isLayer( childNode ) ) { QgsLayerTreeLayer *childLayerNode = QgsLayerTree::toLayer( childNode ); - if ( childLayerNode->layer() && - QgsLayerTreeUtils::countMapLayerInTree( mLayerTreeView->layerTreeModel()->rootGroup(), childLayerNode->layer() ) == 1 ) + if ( childLayerNode->layer() && QgsLayerTreeUtils::countMapLayerInTree( mLayerTreeView->layerTreeModel()->rootGroup(), childLayerNode->layer() ) == 1 ) disconnectSignals( childLayerNode->layer() ); } } @@ -96,16 +94,11 @@ void QgsLayerTreeViewIndicatorProvider::onWillRemoveChildren( QgsLayerTreeNode * void QgsLayerTreeViewIndicatorProvider::onLayerLoaded() { - QgsLayerTreeLayer *layerNode = qobject_cast( sender() ); if ( !layerNode ) return; - if ( !( qobject_cast( layerNode->layer() ) || - qobject_cast( layerNode->layer() ) || - qobject_cast( layerNode->layer() ) || - qobject_cast( layerNode->layer() ) || - qobject_cast( layerNode->layer() ) ) ) + if ( !( qobject_cast( layerNode->layer() ) || qobject_cast( layerNode->layer() ) || qobject_cast( layerNode->layer() ) || qobject_cast( layerNode->layer() ) || qobject_cast( layerNode->layer() ) ) ) return; if ( QgsMapLayer *mapLayer = layerNode->layer() ) @@ -166,9 +159,9 @@ void QgsLayerTreeViewIndicatorProvider::updateLayerIndicator( QgsMapLayer *layer } } -std::unique_ptr< QgsLayerTreeViewIndicator > QgsLayerTreeViewIndicatorProvider::newIndicator( QgsMapLayer *layer ) +std::unique_ptr QgsLayerTreeViewIndicatorProvider::newIndicator( QgsMapLayer *layer ) { - std::unique_ptr< QgsLayerTreeViewIndicator > indicator = std::make_unique< QgsLayerTreeViewIndicator >( this ); + std::unique_ptr indicator = std::make_unique( this ); indicator->setIcon( QgsApplication::getThemeIcon( iconName( layer ) ) ); indicator->setToolTip( tooltipText( layer ) ); connect( indicator.get(), &QgsLayerTreeViewIndicator::clicked, this, &QgsLayerTreeViewIndicatorProvider::onIndicatorClicked ); @@ -178,7 +171,6 @@ std::unique_ptr< QgsLayerTreeViewIndicator > QgsLayerTreeViewIndicatorProvider:: void QgsLayerTreeViewIndicatorProvider::addOrRemoveIndicator( QgsLayerTreeNode *node, QgsMapLayer *layer ) { - if ( acceptLayer( layer ) ) { const QList nodeIndicators = mLayerTreeView->indicators( node ); @@ -216,4 +208,3 @@ void QgsLayerTreeViewIndicatorProvider::addOrRemoveIndicator( QgsLayerTreeNode * // no indicator was there before, nothing to do } } - diff --git a/src/app/qgslayertreeviewindicatorprovider.h b/src/app/qgslayertreeviewindicatorprovider.h index a48c64f83e63..01e13d230a97 100644 --- a/src/app/qgslayertreeviewindicatorprovider.h +++ b/src/app/qgslayertreeviewindicatorprovider.h @@ -47,11 +47,9 @@ class QgsLayerTreeViewIndicatorProvider : public QObject { Q_OBJECT public: - explicit QgsLayerTreeViewIndicatorProvider( QgsLayerTreeView *view ); protected: - // Subclasses MAY override: //! Connect signals, default implementation connects layers to dataSourceChanged() virtual void connectSignals( QgsMapLayer *layer ); @@ -78,7 +76,6 @@ class QgsLayerTreeViewIndicatorProvider : public QObject void onLayerChanged(); private: - // Subclasses MUST override: //! Layer filter: layers that pass the test will get the indicator virtual bool acceptLayer( QgsMapLayer *layer ) = 0; @@ -89,7 +86,7 @@ class QgsLayerTreeViewIndicatorProvider : public QObject // End MUST overrides //! Indicator factory - std::unique_ptr< QgsLayerTreeViewIndicator > newIndicator( QgsMapLayer *layer ); + std::unique_ptr newIndicator( QgsMapLayer *layer ); //! Add or remove the indicator to the given node void addOrRemoveIndicator( QgsLayerTreeNode *node, QgsMapLayer *layer ); diff --git a/src/app/qgslayertreeviewlowaccuracyindicator.cpp b/src/app/qgslayertreeviewlowaccuracyindicator.cpp index 7c337a3defd2..258b19fba2da 100644 --- a/src/app/qgslayertreeviewlowaccuracyindicator.cpp +++ b/src/app/qgslayertreeviewlowaccuracyindicator.cpp @@ -39,7 +39,6 @@ void QgsLayerTreeViewLowAccuracyIndicatorProvider::disconnectSignals( QgsMapLaye void QgsLayerTreeViewLowAccuracyIndicatorProvider::onIndicatorClicked( const QModelIndex & ) { - } QString QgsLayerTreeViewLowAccuracyIndicatorProvider::iconName( QgsMapLayer * ) @@ -80,7 +79,6 @@ QString QgsLayerTreeViewLowAccuracyIndicatorProvider::tooltipText( QgsMapLayer * } catch ( QgsNotSupportedException & ) { - } // dynamic crs with no epoch? @@ -131,7 +129,6 @@ bool QgsLayerTreeViewLowAccuracyIndicatorProvider::acceptLayer( QgsMapLayer *lay } catch ( QgsNotSupportedException & ) { - } return false; diff --git a/src/app/qgslayertreeviewlowaccuracyindicator.h b/src/app/qgslayertreeviewlowaccuracyindicator.h index 2af2c75a5345..912bead7c023 100644 --- a/src/app/qgslayertreeviewlowaccuracyindicator.h +++ b/src/app/qgslayertreeviewlowaccuracyindicator.h @@ -30,7 +30,7 @@ class QgsLayerTreeViewLowAccuracyIndicatorProvider : public QgsLayerTreeViewIndi explicit QgsLayerTreeViewLowAccuracyIndicatorProvider( QgsLayerTreeView *view ); protected: - void connectSignals( QgsMapLayer *layer ) override ; + void connectSignals( QgsMapLayer *layer ) override; void disconnectSignals( QgsMapLayer *layer ) override; protected slots: @@ -40,7 +40,6 @@ class QgsLayerTreeViewLowAccuracyIndicatorProvider : public QgsLayerTreeViewIndi QString iconName( QgsMapLayer *layer ) override; QString tooltipText( QgsMapLayer *layer ) override; bool acceptLayer( QgsMapLayer *layer ) override; - }; #endif // QGSLAYERTREEVIEWLOWACCURACYINDICATOR_H diff --git a/src/app/qgslayertreeviewmemoryindicator.cpp b/src/app/qgslayertreeviewmemoryindicator.cpp index 6bc36a1f77a8..32fb9035a036 100644 --- a/src/app/qgslayertreeviewmemoryindicator.cpp +++ b/src/app/qgslayertreeviewmemoryindicator.cpp @@ -62,4 +62,3 @@ QString QgsLayerTreeViewMemoryIndicatorProvider::tooltipText( QgsMapLayer *layer return tr( "Temporary layer only!
    Contents will be discarded after closing QGIS." ); } - diff --git a/src/app/qgslayertreeviewnocrsindicator.cpp b/src/app/qgslayertreeviewnocrsindicator.cpp index ba6a3c20f871..6f13b95025a0 100644 --- a/src/app/qgslayertreeviewnocrsindicator.cpp +++ b/src/app/qgslayertreeviewnocrsindicator.cpp @@ -52,7 +52,7 @@ void QgsLayerTreeViewNoCrsIndicatorProvider::onIndicatorClicked( const QModelInd bool QgsLayerTreeViewNoCrsIndicatorProvider::acceptLayer( QgsMapLayer *layer ) { - return layer && layer->isValid() && layer->isSpatial() && !layer->crs().isValid() && !qobject_cast< QgsAnnotationLayer * >( layer ); + return layer && layer->isValid() && layer->isSpatial() && !layer->crs().isValid() && !qobject_cast( layer ); } QString QgsLayerTreeViewNoCrsIndicatorProvider::iconName( QgsMapLayer *layer ) diff --git a/src/app/qgslayertreeviewnocrsindicator.h b/src/app/qgslayertreeviewnocrsindicator.h index 984872ef9d36..6f9a30c86e7e 100644 --- a/src/app/qgslayertreeviewnocrsindicator.h +++ b/src/app/qgslayertreeviewnocrsindicator.h @@ -26,7 +26,6 @@ class QgsLayerTreeViewNoCrsIndicatorProvider : public QgsLayerTreeViewIndicatorP explicit QgsLayerTreeViewNoCrsIndicatorProvider( QgsLayerTreeView *view ); protected: - void connectSignals( QgsMapLayer *layer ) override; void disconnectSignals( QgsMapLayer *layer ) override; diff --git a/src/app/qgslayertreeviewnonremovableindicator.cpp b/src/app/qgslayertreeviewnonremovableindicator.cpp index ce9f3f61bd21..b7e6178537e5 100644 --- a/src/app/qgslayertreeviewnonremovableindicator.cpp +++ b/src/app/qgslayertreeviewnonremovableindicator.cpp @@ -41,7 +41,7 @@ QString QgsLayerTreeViewNonRemovableIndicatorProvider::tooltipText( QgsMapLayer bool QgsLayerTreeViewNonRemovableIndicatorProvider::acceptLayer( QgsMapLayer *layer ) { - return ! layer->flags().testFlag( QgsMapLayer::LayerFlag::Removable ); + return !layer->flags().testFlag( QgsMapLayer::LayerFlag::Removable ); } void QgsLayerTreeViewNonRemovableIndicatorProvider::connectSignals( QgsMapLayer *layer ) @@ -55,4 +55,3 @@ void QgsLayerTreeViewNonRemovableIndicatorProvider::disconnectSignals( QgsMapLay QgsLayerTreeViewIndicatorProvider::disconnectSignals( layer ); disconnect( layer, &QgsMapLayer::flagsChanged, this, &QgsLayerTreeViewNonRemovableIndicatorProvider::onLayerChanged ); } - diff --git a/src/app/qgslayertreeviewnonremovableindicator.h b/src/app/qgslayertreeviewnonremovableindicator.h index d87293241178..6a36c5ee90ee 100644 --- a/src/app/qgslayertreeviewnonremovableindicator.h +++ b/src/app/qgslayertreeviewnonremovableindicator.h @@ -33,12 +33,9 @@ class QgsLayerTreeViewNonRemovableIndicatorProvider : public QgsLayerTreeViewInd bool acceptLayer( QgsMapLayer *layer ) override; protected: - void connectSignals( QgsMapLayer *layer ) override; void disconnectSignals( QgsMapLayer *layer ) override; - }; - #endif // QGSLAYERTREEVIEWNONREMOVABLEINDICATOR_H diff --git a/src/app/qgslayertreeviewnotesindicator.cpp b/src/app/qgslayertreeviewnotesindicator.cpp index 259b80b050bf..6e8592809fdd 100644 --- a/src/app/qgslayertreeviewnotesindicator.cpp +++ b/src/app/qgslayertreeviewnotesindicator.cpp @@ -71,4 +71,3 @@ QString QgsLayerTreeViewNotesIndicatorProvider::tooltipText( QgsMapLayer *layer { return QgsLayerNotesUtils::layerNotes( layer ); } - diff --git a/src/app/qgslayertreeviewnotesindicator.h b/src/app/qgslayertreeviewnotesindicator.h index 551ad69a47c5..866d8fc926b3 100644 --- a/src/app/qgslayertreeviewnotesindicator.h +++ b/src/app/qgslayertreeviewnotesindicator.h @@ -28,8 +28,9 @@ class QgsLayerTreeViewNotesIndicatorProvider : public QgsLayerTreeViewIndicatorP protected slots: void onIndicatorClicked( const QModelIndex &index ) override; + protected: - void connectSignals( QgsMapLayer *layer ) override ; + void connectSignals( QgsMapLayer *layer ) override; void disconnectSignals( QgsMapLayer *layer ) override; private: diff --git a/src/app/qgslayertreeviewofflineindicator.cpp b/src/app/qgslayertreeviewofflineindicator.cpp index 052391119d8d..cb01b0edcf59 100644 --- a/src/app/qgslayertreeviewofflineindicator.cpp +++ b/src/app/qgslayertreeviewofflineindicator.cpp @@ -21,7 +21,6 @@ QgsLayerTreeViewOfflineIndicatorProvider::QgsLayerTreeViewOfflineIndicatorProvider( QgsLayerTreeView *view ) : QgsLayerTreeViewIndicatorProvider( view ) { - } void QgsLayerTreeViewOfflineIndicatorProvider::connectSignals( QgsMapLayer *layer ) @@ -56,4 +55,3 @@ QString QgsLayerTreeViewOfflineIndicatorProvider::tooltipText( QgsMapLayer *laye Q_UNUSED( layer ) return tr( "Offline layer" ); } - diff --git a/src/app/qgslayertreeviewtemporalindicator.cpp b/src/app/qgslayertreeviewtemporalindicator.cpp index 626b879794f6..96e4b01698f5 100644 --- a/src/app/qgslayertreeviewtemporalindicator.cpp +++ b/src/app/qgslayertreeviewtemporalindicator.cpp @@ -32,7 +32,7 @@ void QgsLayerTreeViewTemporalIndicatorProvider::connectSignals( QgsMapLayer *lay if ( !layer || !layer->temporalProperties() ) return; - connect( layer->temporalProperties(), &QgsMapLayerTemporalProperties::changed, this, [ this, layer ]( ) { this->onLayerChanged( layer ); } ); + connect( layer->temporalProperties(), &QgsMapLayerTemporalProperties::changed, this, [this, layer]() { this->onLayerChanged( layer ); } ); } void QgsLayerTreeViewTemporalIndicatorProvider::onIndicatorClicked( const QModelIndex &index ) @@ -70,8 +70,7 @@ bool QgsLayerTreeViewTemporalIndicatorProvider::acceptLayer( QgsMapLayer *layer { if ( !layer ) return false; - if ( layer->temporalProperties() && - layer->temporalProperties()->isActive() ) + if ( layer->temporalProperties() && layer->temporalProperties()->isActive() ) return true; return false; } diff --git a/src/app/qgslayertreeviewtemporalindicator.h b/src/app/qgslayertreeviewtemporalindicator.h index d741f394874d..fd10186e01ca 100644 --- a/src/app/qgslayertreeviewtemporalindicator.h +++ b/src/app/qgslayertreeviewtemporalindicator.h @@ -42,7 +42,6 @@ class QgsLayerTreeViewTemporalIndicatorProvider : public QgsLayerTreeViewIndicat bool acceptLayer( QgsMapLayer *layer ) override; QString iconName( QgsMapLayer *layer ) override; QString tooltipText( QgsMapLayer *layer ) override; - }; #endif // QGSLAYERTREEVIEWTEMPORALINDICATOR_H diff --git a/src/app/qgsmapcanvasdockwidget.cpp b/src/app/qgsmapcanvasdockwidget.cpp index 857c9d617d92..d6d455fd4720 100644 --- a/src/app/qgsmapcanvasdockwidget.cpp +++ b/src/app/qgsmapcanvasdockwidget.cpp @@ -49,7 +49,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa setAttribute( Qt::WA_DeleteOnClose ); layout()->setContentsMargins( 0, 0, 0, 0 ); - qgis::down_cast< QVBoxLayout * >( layout() )->setSpacing( 0 ); + qgis::down_cast( layout() )->setSpacing( 0 ); setWindowTitle( mCanvasName ); mToolbar->setIconSize( QgisApp::instance()->iconSize( true ) ); @@ -101,8 +101,8 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapCanvasDockWidget::mapCrsChanged ); connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapCanvasDockWidget::updateExtentRect ); connect( mActionZoomFullExtent, &QAction::triggered, mMapCanvas, &QgsMapCanvas::zoomToProjectExtent ); - connect( mActionZoomToLayers, &QAction::triggered, mMapCanvas, [ = ] { QgisApp::instance()->layerTreeView()->defaultActions()->zoomToLayers( mMapCanvas ); } ); - connect( mActionZoomToSelected, &QAction::triggered, mMapCanvas, [ = ] { mMapCanvas->zoomToSelected(); } ); + connect( mActionZoomToLayers, &QAction::triggered, mMapCanvas, [=] { QgisApp::instance()->layerTreeView()->defaultActions()->zoomToLayers( mMapCanvas ); } ); + connect( mActionZoomToSelected, &QAction::triggered, mMapCanvas, [=] { mMapCanvas->zoomToSelected(); } ); mapCrsChanged(); QgsMapSettingsAction *settingsAction = new QgsMapSettingsAction( settingsMenu ); @@ -127,11 +127,11 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa connect( mActionRename, &QAction::triggered, this, &QgsMapCanvasDockWidget::renameTriggered ); mActionShowAnnotations->setChecked( mMapCanvas->annotationsVisible() ); - connect( mActionShowAnnotations, &QAction::toggled, this, [ = ]( bool checked ) { mMapCanvas->setAnnotationsVisible( checked ); } ); + connect( mActionShowAnnotations, &QAction::toggled, this, [=]( bool checked ) { mMapCanvas->setAnnotationsVisible( checked ); } ); mActionShowCursor->setChecked( true ); - connect( mActionShowCursor, &QAction::toggled, this, [ = ]( bool checked ) { mXyMarker->setVisible( checked ); } ); + connect( mActionShowCursor, &QAction::toggled, this, [=]( bool checked ) { mXyMarker->setVisible( checked ); } ); mActionShowExtent->setChecked( false ); - connect( mActionShowExtent, &QAction::toggled, this, [ = ]( bool checked ) { mExtentRubberBand->setVisible( checked ); updateExtentRect(); } ); + connect( mActionShowExtent, &QAction::toggled, this, [=]( bool checked ) { mExtentRubberBand->setVisible( checked ); updateExtentRect(); } ); mActionShowLabels->setChecked( true ); connect( mActionShowLabels, &QAction::toggled, this, &QgsMapCanvasDockWidget::showLabels ); @@ -143,8 +143,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa mSyncScaleCheckBox = settingsAction->syncScaleCheckBox(); mScaleFactorWidget = settingsAction->scaleFactorSpinBox(); - connect( mSyncSelectionCheck, &QCheckBox::toggled, this, [ = ]( bool checked ) - { + connect( mSyncSelectionCheck, &QCheckBox::toggled, this, [=]( bool checked ) { autoZoomToSelection( checked ); if ( checked ) { @@ -155,8 +154,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa } } ); - connect( mSyncExtentCheck, &QCheckBox::toggled, this, [ = ]( bool checked ) - { + connect( mSyncExtentCheck, &QCheckBox::toggled, this, [=]( bool checked ) { if ( checked ) { syncViewCenter( mMainCanvas ); @@ -166,8 +164,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa } } ); - connect( mScaleCombo, &QgsScaleComboBox::scaleChanged, this, [ = ]( double scale ) - { + connect( mScaleCombo, &QgsScaleComboBox::scaleChanged, this, [=]( double scale ) { if ( !mBlockScaleUpdate ) { mBlockScaleUpdate = true; @@ -175,8 +172,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa mBlockScaleUpdate = false; } } ); - connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, [ = ]( double scale ) - { + connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, [=]( double scale ) { if ( !mBlockScaleUpdate ) { mBlockScaleUpdate = true; @@ -185,8 +181,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa } } ); - connect( mRotationEdit, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) - { + connect( mRotationEdit, static_cast( &QgsDoubleSpinBox::valueChanged ), this, [=]( double value ) { if ( !mBlockRotationUpdate ) { mBlockRotationUpdate = true; @@ -196,8 +191,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa } } ); - connect( mMapCanvas, &QgsMapCanvas::rotationChanged, this, [ = ]( double rotation ) - { + connect( mMapCanvas, &QgsMapCanvas::rotationChanged, this, [=]( double rotation ) { if ( !mBlockRotationUpdate ) { mBlockRotationUpdate = true; @@ -206,8 +200,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa } } ); - connect( mMagnificationEdit, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) - { + connect( mMagnificationEdit, static_cast( &QgsDoubleSpinBox::valueChanged ), this, [=]( double value ) { if ( !mBlockMagnificationUpdate ) { mBlockMagnificationUpdate = true; @@ -217,8 +210,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa } } ); - connect( mMapCanvas, &QgsMapCanvas::magnificationChanged, this, [ = ]( double factor ) - { + connect( mMapCanvas, &QgsMapCanvas::magnificationChanged, this, [=]( double factor ) { if ( !mBlockMagnificationUpdate ) { mBlockMagnificationUpdate = true; @@ -227,17 +219,14 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa } } ); - connect( mScaleFactorWidget, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsMapCanvasDockWidget::mapScaleChanged ); - connect( mSyncScaleCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked ) - { + connect( mScaleFactorWidget, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsMapCanvasDockWidget::mapScaleChanged ); + connect( mSyncScaleCheckBox, &QCheckBox::toggled, this, [=]( bool checked ) { if ( checked ) mapScaleChanged(); - } - ); + } ); mResizeTimer.setSingleShot( true ); - connect( &mResizeTimer, &QTimer::timeout, this, [ = ] - { + connect( &mResizeTimer, &QTimer::timeout, this, [=] { mBlockExtentSync = false; if ( mSyncScaleCheckBox->isChecked() ) @@ -258,8 +247,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa QToolButton *toggleButton = mDockableWidgetHelper->createDockUndockToolButton(); toggleButton->setToolTip( tr( "Dock 2D Map View" ) ); mToolbar->addWidget( toggleButton ); - connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [ = ]() - { + connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [=]() { close(); } ); } @@ -402,8 +390,7 @@ void QgsMapCanvasDockWidget::syncViewCenter( QgsMapCanvas *sourceCanvas ) QgsMapCanvas *destCanvas = sourceCanvas == mMapCanvas ? mMainCanvas : mMapCanvas; // reproject extent - QgsCoordinateTransform ct( sourceCanvas->mapSettings().destinationCrs(), - destCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); + QgsCoordinateTransform ct( sourceCanvas->mapSettings().destinationCrs(), destCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); ct.setBallparkTransformsAreAppropriate( true ); try { @@ -433,7 +420,7 @@ void QgsMapCanvasDockWidget::mapExtentChanged() if ( mBlockExtentSync ) return; - QgsMapCanvas *sourceCanvas = qobject_cast< QgsMapCanvas * >( sender() ); + QgsMapCanvas *sourceCanvas = qobject_cast( sender() ); if ( !sourceCanvas ) return; @@ -451,9 +438,7 @@ void QgsMapCanvasDockWidget::mapExtentChanged() void QgsMapCanvasDockWidget::mapCrsChanged() { - mActionSetCrs->setText( tr( "Change Map CRS (%1)…" ).arg( mMapCanvas->mapSettings().destinationCrs().isValid() ? - mMapCanvas->mapSettings().destinationCrs().authid() : - tr( "No projection" ) ) ); + mActionSetCrs->setText( tr( "Change Map CRS (%1)…" ).arg( mMapCanvas->mapSettings().destinationCrs().isValid() ? mMapCanvas->mapSettings().destinationCrs().authid() : tr( "No projection" ) ) ); } void QgsMapCanvasDockWidget::menuAboutToShow() @@ -469,8 +454,7 @@ void QgsMapCanvasDockWidget::menuAboutToShow() { actionFollowMain->setChecked( true ); } - connect( actionFollowMain, &QAction::triggered, this, [ = ] - { + connect( actionFollowMain, &QAction::triggered, this, [=] { mMapCanvas->setTheme( QString() ); mMapCanvas->refresh(); } ); @@ -485,8 +469,7 @@ void QgsMapCanvasDockWidget::menuAboutToShow() { a->setChecked( true ); } - connect( a, &QAction::triggered, this, [a, this] - { + connect( a, &QAction::triggered, this, [a, this] { mMapCanvas->setTheme( a->text() ); mMapCanvas->refresh(); } ); @@ -514,8 +497,7 @@ void QgsMapCanvasDockWidget::syncMarker( const QgsPointXY &p ) return; // reproject point - const QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(), - mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); + const QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(), mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); QgsPointXY t = p; try { @@ -548,12 +530,10 @@ void QgsMapCanvasDockWidget::updateExtentRect() // close polygon mainCanvasPoly << mainCanvasPoly.at( 0 ); QgsGeometry g = QgsGeometry::fromQPolygonF( mainCanvasPoly ); - if ( mMainCanvas->mapSettings().destinationCrs() != - mMapCanvas->mapSettings().destinationCrs() ) + if ( mMainCanvas->mapSettings().destinationCrs() != mMapCanvas->mapSettings().destinationCrs() ) { // reproject extent - const QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(), - mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); + const QgsCoordinateTransform ct( mMainCanvas->mapSettings().destinationCrs(), mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); g = g.densifyByCount( 5 ); try { @@ -572,7 +552,7 @@ void QgsMapCanvasDockWidget::showLabels( bool show ) if ( show ) flags = flags | Qgis::MapSettingsFlag::DrawLabeling; else - flags = flags & ~( static_cast< int >( Qgis::MapSettingsFlag::DrawLabeling ) ); + flags = flags & ~( static_cast( Qgis::MapSettingsFlag::DrawLabeling ) ); mMapCanvas->setMapSettingsFlags( flags ); } diff --git a/src/app/qgsmapcanvasdockwidget.h b/src/app/qgsmapcanvasdockwidget.h index 415ba5ee51f7..d128716c6289 100644 --- a/src/app/qgsmapcanvasdockwidget.h +++ b/src/app/qgsmapcanvasdockwidget.h @@ -153,7 +153,6 @@ class APP_EXPORT QgsMapCanvasDockWidget : public QWidget, private Ui::QgsMapCanv void renameTriggered(); protected: - void resizeEvent( QResizeEvent *e ) override; private slots: @@ -207,12 +206,11 @@ class APP_EXPORT QgsMapCanvasDockWidget : public QWidget, private Ui::QgsMapCanv * Allows embedding a scale, rotation and other map settings into a menu. */ -class QgsMapSettingsAction: public QWidgetAction +class QgsMapSettingsAction : public QWidgetAction { Q_OBJECT public: - QgsMapSettingsAction( QWidget *parent = nullptr ); QCheckBox *syncExtentCheck() { return mSyncExtentCheck; } diff --git a/src/app/qgsmapsavedialog.cpp b/src/app/qgsmapsavedialog.cpp index 62625815cbd1..7c4a30f288c2 100644 --- a/src/app/qgsmapsavedialog.cpp +++ b/src/app/qgsmapsavedialog.cpp @@ -48,7 +48,7 @@ #include "qgsfileutils.h" #include "qgsannotationlayer.h" -QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, const QList &decorations, const QList< QgsAnnotation *> &annotations, DialogType type ) +QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, const QList &decorations, const QList &annotations, DialogType type ) : QDialog( parent ) , mDialogType( type ) , mMapCanvas( mapCanvas ) @@ -65,7 +65,7 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co mSize = ms.outputSize(); mDevicePixelRatio = ms.devicePixelRatio(); - mResolutionSpinBox->setValue( static_cast< int >( std::round( mDpi ) ) ); + mResolutionSpinBox->setValue( static_cast( std::round( mDpi ) ) ); mExtentGroupBox->setOutputCrs( ms.destinationCrs() ); mExtentGroupBox->setCurrentExtent( mExtent, ms.destinationCrs() ); @@ -87,9 +87,9 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co } mDrawDecorations->setText( tr( "Draw active decorations: %1" ).arg( !activeDecorations.isEmpty() ? activeDecorations : tr( "none" ) ) ); - connect( mResolutionSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateDpi( mResolutionSpinBox->value() ); } ); - connect( mOutputWidthSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateOutputWidth( mOutputWidthSpinBox->value() );} ); - connect( mOutputHeightSpinBox, &QSpinBox::editingFinished, this, [ = ] { updateOutputHeight( mOutputHeightSpinBox->value() );} ); + connect( mResolutionSpinBox, &QSpinBox::editingFinished, this, [=] { updateDpi( mResolutionSpinBox->value() ); } ); + connect( mOutputWidthSpinBox, &QSpinBox::editingFinished, this, [=] { updateOutputWidth( mOutputWidthSpinBox->value() ); } ); + connect( mOutputHeightSpinBox, &QSpinBox::editingFinished, this, [=] { updateOutputHeight( mOutputHeightSpinBox->value() ); } ); connect( mExtentGroupBox, &QgsExtentGroupBox::extentChanged, this, &QgsMapSaveDialog::updateExtent ); connect( mScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsMapSaveDialog::updateScale ); connect( mLockAspectRatio, &QgsRatioLockButton::lockChanged, this, &QgsMapSaveDialog::lockChanged ); @@ -100,8 +100,7 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co { case Pdf: { - connect( mInfo, &QLabel::linkActivated, this, [this]( const QString & ) - { + connect( mInfo, &QLabel::linkActivated, this, [this]( const QString & ) { QgsMessageViewer *viewer = new QgsMessageViewer( this ); viewer->setWindowTitle( tr( "Advanced effects warning" ) ); viewer->setMessageAsPlainText( mInfoDetails ); @@ -110,9 +109,9 @@ QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, co this->setWindowTitle( tr( "Save Map as PDF" ) ); - mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Paths (Recommended)" ), static_cast< int>( Qgis::TextRenderFormat::AlwaysOutlines ) ); - mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), static_cast< int >( Qgis::TextRenderFormat::AlwaysText ) ); - mTextRenderFormatComboBox->addItem( tr( "Prefer Exporting Text as Text Objects" ), static_cast< int >( Qgis::TextRenderFormat::PreferText ) ); + mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Paths (Recommended)" ), static_cast( Qgis::TextRenderFormat::AlwaysOutlines ) ); + mTextRenderFormatComboBox->addItem( tr( "Always Export Text as Text Objects" ), static_cast( Qgis::TextRenderFormat::AlwaysText ) ); + mTextRenderFormatComboBox->addItem( tr( "Prefer Exporting Text as Text Objects" ), static_cast( Qgis::TextRenderFormat::PreferText ) ); const bool geospatialPdfAvailable = QgsAbstractGeospatialPdfExporter::geospatialPDFCreationAvailable(); mGeospatialPDFGroupBox->setEnabled( geospatialPdfAvailable ); @@ -233,7 +232,7 @@ void QgsMapSaveDialog::updateExtent( const QgsRectangle &extent ) QgsMapSettings ms = mMapCanvas->mapSettings(); ms.setRotation( 0 ); - mDpi = static_cast< int>( std::round( ms.outputDpi() ) ) ; + mDpi = static_cast( std::round( ms.outputDpi() ) ); mSize.setWidth( ms.outputSize().width() * extent.width() / ms.visibleExtent().width() ); mSize.setHeight( ms.outputSize().height() * extent.height() / ms.visibleExtent().height() ); @@ -333,7 +332,7 @@ void QgsMapSaveDialog::applyMapSettings( QgsMapSettings &mapSettings ) switch ( mDialogType ) { case Pdf: - mapSettings.setFlag( Qgis::MapSettingsFlag::Antialiasing, true ); // hardcode antialiasing when saving as PDF + mapSettings.setFlag( Qgis::MapSettingsFlag::Antialiasing, true ); // hardcode antialiasing when saving as PDF mapSettings.setFlag( Qgis::MapSettingsFlag::HighQualityImageTransforms, true ); // hardcode antialiasing when saving as PDF break; @@ -356,7 +355,7 @@ void QgsMapSaveDialog::applyMapSettings( QgsMapSettings &mapSettings ) mapSettings.setRotation( mMapCanvas->rotation() ); mapSettings.setEllipsoid( QgsProject::instance()->ellipsoid() ); - QList< QgsMapLayer * > layers = mMapCanvas->layers(); + QList layers = mMapCanvas->layers(); if ( !QgsProject::instance()->mainAnnotationLayer()->isEmpty() ) { layers.insert( 0, QgsProject::instance()->mainAnnotationLayer() ); @@ -426,8 +425,7 @@ void QgsMapSaveDialog::copyToClipboard() mapRendererTask->addDecorations( mDecorations ); } - connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, this, [ = ] - { + connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, this, [=] { QApplication::clipboard()->setImage( *img, QClipboard::Clipboard ); QApplication::restoreOverrideCursor(); QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as image" ), tr( "Successfully copied map to clipboard" ) ); @@ -436,8 +434,7 @@ void QgsMapSaveDialog::copyToClipboard() delete img; setEnabled( true ); } ); - connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, this, [ = ]( int ) - { + connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, this, [=]( int ) { QApplication::restoreOverrideCursor(); QgisApp::instance()->messageBar()->pushWarning( tr( "Save as image" ), tr( "Could not copy the map to clipboard" ) ); @@ -458,7 +455,7 @@ void QgsMapSaveDialog::onAccepted() { case Image: { - const QPair< QString, QString> fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( QgisApp::instance(), tr( "Choose a file name to save the map image as" ) ); + const QPair fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( QgisApp::instance(), tr( "Choose a file name to save the map image as" ) ); if ( !fileNameAndFilter.first.isEmpty() ) { QgsMapSettings ms = QgsMapSettings(); @@ -478,13 +475,10 @@ void QgsMapSaveDialog::onAccepted() mapRendererTask->setSaveWorldFile( saveWorldFile() ); - connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, [ = ] - { - QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as image" ), tr( "Successfully saved map to %2" ) - .arg( QUrl::fromLocalFile( fileNameAndFilter.first ).toString(), QDir::toNativeSeparators( fileNameAndFilter.first ) ) ); + connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, [=] { + QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as image" ), tr( "Successfully saved map to %2" ).arg( QUrl::fromLocalFile( fileNameAndFilter.first ).toString(), QDir::toNativeSeparators( fileNameAndFilter.first ) ) ); } ); - connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, [ = ]( int error ) - { + connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, [=]( int error ) { switch ( error ) { case QgsMapRendererTask::ImageAllocationFail: @@ -533,7 +527,7 @@ void QgsMapSaveDialog::onAccepted() ms.setSimplifyMethod( simplifyMethod ); } - ms.setTextRenderFormat( static_cast< Qgis::TextRenderFormat >( mTextRenderFormatComboBox->currentData().toInt() ) ); + ms.setTextRenderFormat( static_cast( mTextRenderFormatComboBox->currentData().toInt() ) ); QgsAbstractGeospatialPdfExporter::ExportDetails geospatialPdfExportDetails; if ( mExportMetadataCheckBox->isChecked() ) @@ -582,13 +576,10 @@ void QgsMapSaveDialog::onAccepted() mapRendererTask->setExportMetadata( exportMetadata() ); } - connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, [ = ] - { - QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as PDF" ), tr( "Successfully saved map to %2" ) - .arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) ); + connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, [=] { + QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as PDF" ), tr( "Successfully saved map to %2" ).arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) ); } ); - connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, [ = ]( int ) - { + connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, [=]( int ) { QgisApp::instance()->messageBar()->pushWarning( tr( "Save as PDF" ), tr( "Could not save the map to PDF" ) ); } ); @@ -604,8 +595,7 @@ void QgsMapSaveDialog::updatePdfExportWarning() const QStringList layers = QgsMapSettingsUtils::containsAdvancedEffects( mMapCanvas->mapSettings(), mGeospatialPDFGroupBox->isChecked() ? QgsMapSettingsUtils::EffectsCheckFlags( QgsMapSettingsUtils::EffectsCheckFlag::IgnoreGeoPdfSupportedEffects ) : QgsMapSettingsUtils::EffectsCheckFlags() ); if ( !layers.isEmpty() ) { - mInfoDetails = tr( "The following layer(s) use advanced effects:\n\n%1\n\nRasterizing map is recommended for proper rendering." ).arg( - QChar( 0x2022 ) + QStringLiteral( " " ) + layers.join( QStringLiteral( "\n" ) + QChar( 0x2022 ) + QStringLiteral( " " ) ) ); + mInfoDetails = tr( "The following layer(s) use advanced effects:\n\n%1\n\nRasterizing map is recommended for proper rendering." ).arg( QChar( 0x2022 ) + QStringLiteral( " " ) + layers.join( QStringLiteral( "\n" ) + QChar( 0x2022 ) + QStringLiteral( " " ) ) ); mInfo->setText( tr( "%1A number of layers%2 use advanced effects, rasterizing map is recommended for proper rendering." ).arg( QStringLiteral( "" ), QStringLiteral( "" ) ) ); mSaveAsRaster->setChecked( true ); } diff --git a/src/app/qgsmapsavedialog.h b/src/app/qgsmapsavedialog.h index 78cba71a75db..e79ccac251dd 100644 --- a/src/app/qgsmapsavedialog.h +++ b/src/app/qgsmapsavedialog.h @@ -35,12 +35,11 @@ class QgsMapCanvas; * \ingroup app * \brief a dialog for saving a map to an image. */ -class APP_EXPORT QgsMapSaveDialog: public QDialog, private Ui::QgsMapSaveDialog +class APP_EXPORT QgsMapSaveDialog : public QDialog, private Ui::QgsMapSaveDialog { Q_OBJECT public: - enum DialogType { Image = 1, // Image-specific dialog @@ -50,10 +49,7 @@ class APP_EXPORT QgsMapSaveDialog: public QDialog, private Ui::QgsMapSaveDialog /** * Constructor for QgsMapSaveDialog */ - QgsMapSaveDialog( QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr, - const QList< QgsMapDecoration * > &decorations = QList< QgsMapDecoration * >(), - const QList &annotations = QList< QgsAnnotation * >(), - DialogType type = Image ); + QgsMapSaveDialog( QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr, const QList &decorations = QList(), const QList &annotations = QList(), DialogType type = Image ); //! returns extent rectangle QgsRectangle extent() const; @@ -88,7 +84,6 @@ class APP_EXPORT QgsMapSaveDialog: public QDialog, private Ui::QgsMapSaveDialog void updatePdfExportWarning(); private: - void lockChanged( bool locked ); void copyToClipboard(); void checkOutputSize(); @@ -102,8 +97,8 @@ class APP_EXPORT QgsMapSaveDialog: public QDialog, private Ui::QgsMapSaveDialog DialogType mDialogType; QgsMapCanvas *mMapCanvas = nullptr; - QList< QgsMapDecoration * > mDecorations; - QList< QgsAnnotation *> mAnnotations; + QList mDecorations; + QList mAnnotations; QgsRectangle mExtent; int mDpi; diff --git a/src/app/qgsmapthemes.cpp b/src/app/qgsmapthemes.cpp index d8a912e64e67..91de8a9ae7d0 100644 --- a/src/app/qgsmapthemes.cpp +++ b/src/app/qgsmapthemes.cpp @@ -38,7 +38,6 @@ QgsMapThemes *QgsMapThemes::sInstance; QgsMapThemes::QgsMapThemes() : mMenu( new QMenu ) { - mMenu->addAction( QgisApp::instance()->actionShowAllLayers() ); mMenu->addAction( QgisApp::instance()->actionHideAllLayers() ); mMenu->addAction( QgisApp::instance()->actionShowSelectedLayers() ); @@ -51,7 +50,7 @@ QgsMapThemes::QgsMapThemes() mReplaceMenu = new QMenu( tr( "Replace Theme" ) ); mMenu->addMenu( mReplaceMenu ); mActionRenameCurrentPreset = mMenu->addAction( tr( "Rename Current Theme…" ), this, &QgsMapThemes::renameCurrentPreset ); - mActionAddPreset = mMenu->addAction( tr( "Add Theme…" ), this, [ = ] { addPreset(); } ); + mActionAddPreset = mMenu->addAction( tr( "Add Theme…" ), this, [=] { addPreset(); } ); mMenuSeparator = mMenu->addSeparator(); mActionRemoveCurrentPreset = mMenu->addAction( tr( "Remove Current Theme" ), this, &QgsMapThemes::removeCurrentPreset ); @@ -123,9 +122,7 @@ void QgsMapThemes::replaceTriggered() if ( !actionPreset ) return; - int res = QMessageBox::question( QgisApp::instance(), tr( "Replace Theme" ), - tr( "Are you sure you want to replace the existing theme “%1”?" ).arg( actionPreset->text() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ); + int res = QMessageBox::question( QgisApp::instance(), tr( "Replace Theme" ), tr( "Are you sure you want to replace the existing theme “%1”?" ).arg( actionPreset->text() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ); if ( res != QMessageBox::Yes ) return; @@ -156,7 +153,8 @@ void QgsMapThemes::renameCurrentPreset() QgsNewNameDialog dlg( tr( "theme" ), tr( "%1" ).arg( actionPreset->text() ), - QStringList(), existingNames, Qt::CaseInsensitive, mMenu ); + QStringList(), existingNames, Qt::CaseInsensitive, mMenu + ); dlg.setWindowTitle( tr( "Rename Map Theme" ) ); dlg.setHintString( tr( "Enter the new name of the map theme" ) ); @@ -178,9 +176,7 @@ void QgsMapThemes::removeCurrentPreset() { if ( actionPreset->isChecked() ) { - int res = QMessageBox::question( QgisApp::instance(), tr( "Remove Theme" ), - tr( "Are you sure you want to remove the existing theme “%1”?" ).arg( actionPreset->text() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ); + int res = QMessageBox::question( QgisApp::instance(), tr( "Remove Theme" ), tr( "Are you sure you want to remove the existing theme “%1”?" ).arg( actionPreset->text() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ); if ( res == QMessageBox::Yes ) QgsProject::instance()->mapThemeCollection()->removeMapTheme( actionPreset->text() ); break; diff --git a/src/app/qgsmapthemes.h b/src/app/qgsmapthemes.h index 64f07b6213e1..33bf4eb7c6a2 100644 --- a/src/app/qgsmapthemes.h +++ b/src/app/qgsmapthemes.h @@ -37,7 +37,6 @@ class APP_EXPORT QgsMapThemes : public QObject { Q_OBJECT public: - /** * Returns the instance QgsVisibilityPresets. */ diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index eb0c5b362a66..ed5e3e42bc9f 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -48,7 +48,7 @@ QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas *canvas, CaptureMode mo std::unique_ptr QgsMapToolAddFeature::createHighlight( QgsVectorLayer *layer, const QgsFeature &f ) { - std::unique_ptr< QgsHighlight > highlight = std::make_unique< QgsHighlight >( mCanvas, f.geometry(), layer ); + std::unique_ptr highlight = std::make_unique( mCanvas, f.geometry(), layer ); highlight->applyDefaultStyle(); switch ( f.geometry().type() ) @@ -79,10 +79,10 @@ std::unique_ptr QgsMapToolAddFeature::createHighlight( QgsVectorLa bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, const QgsFeature &f, bool showModal ) { QgsFeature feat( f ); - std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::mapToolCaptureScope( snappingMatches() ) ); + std::unique_ptr scope( QgsExpressionContextUtils::mapToolCaptureScope( snappingMatches() ) ); QgsFeatureAction *action = new QgsFeatureAction( tr( "add feature" ), feat, vlayer, QUuid(), -1, this ); - std::unique_ptr< QgsHighlight > highlight; + std::unique_ptr highlight; if ( QgsRubberBand *rb = takeRubberBand() ) { connect( action, &QgsFeatureAction::addFeatureFinished, rb, &QgsRubberBand::deleteLater ); @@ -123,10 +123,8 @@ void QgsMapToolAddFeature::featureDigitized( const QgsFeature &feature ) //add points to other features to keep topology up-to-date const bool topologicalEditing = QgsProject::instance()->topologicalEditing(); const Qgis::AvoidIntersectionsMode avoidIntersectionsMode = QgsProject::instance()->avoidIntersectionsMode(); - if ( topologicalEditing && avoidIntersectionsMode == Qgis::AvoidIntersectionsMode::AvoidIntersectionsLayers && - ( mode() == CaptureLine || mode() == CapturePolygon ) ) + if ( topologicalEditing && avoidIntersectionsMode == Qgis::AvoidIntersectionsMode::AvoidIntersectionsLayers && ( mode() == CaptureLine || mode() == CapturePolygon ) ) { - //use always topological editing for avoidIntersection. //Otherwise, no way to guarantee the geometries don't have a small gap in between. const QList intersectionLayers = QgsProject::instance()->avoidIntersectionsLayers(); diff --git a/src/app/qgsmaptooladdfeature.h b/src/app/qgsmaptooladdfeature.h index 7f332623cd1b..e552f85bb369 100644 --- a/src/app/qgsmaptooladdfeature.h +++ b/src/app/qgsmaptooladdfeature.h @@ -40,14 +40,13 @@ class APP_EXPORT QgsMapToolAddFeature : public QgsMapToolDigitizeFeature void featureDigitized( const QgsFeature &feature ) override; private: - bool addFeature( QgsVectorLayer *vlayer, const QgsFeature &f, bool showModal = true ); /** * Creates a highlight corresponding to the captured geometry map tool and transfers * ownership to the caller. */ - std::unique_ptr< QgsHighlight > createHighlight( QgsVectorLayer *layer, const QgsFeature &f ); + std::unique_ptr createHighlight( QgsVectorLayer *layer, const QgsFeature &f ); }; #endif // QGSMAPTOOLADDFEATURE_H diff --git a/src/app/qgsmaptooladdpart.cpp b/src/app/qgsmaptooladdpart.cpp index 3a47dbadf3dc..5cd491313a33 100644 --- a/src/app/qgsmaptooladdpart.cpp +++ b/src/app/qgsmaptooladdpart.cpp @@ -213,8 +213,7 @@ QgsVectorLayer *QgsMapToolAddPart::getLayerAndCheckSelection() QgsFeatureIterator selectedFeatures = layer->getSelectedFeatures(); QgsFeature selectedFeature; selectedFeatures.nextFeature( selectedFeature ); - if ( QgsWkbTypes::isSingleType( layer->wkbType() ) && - selectedFeature.geometry().constGet() ) + if ( QgsWkbTypes::isSingleType( layer->wkbType() ) && selectedFeature.geometry().constGet() ) { selectionErrorMsg = tr( "This layer does not support multipart geometries." ); } diff --git a/src/app/qgsmaptooladdpart.h b/src/app/qgsmaptooladdpart.h index 9ab97db60473..e7f5d493e277 100644 --- a/src/app/qgsmaptooladdpart.h +++ b/src/app/qgsmaptooladdpart.h @@ -37,7 +37,6 @@ class APP_EXPORT QgsMapToolAddPart : public QgsMapToolCaptureLayerGeometry void activate() override; private: - /** * Check if there is any feature selected and the layer supports adding the part * Returns a nullptr otherwise diff --git a/src/app/qgsmaptooladdring.h b/src/app/qgsmaptooladdring.h index d9893ba6b5ef..50e825d5ad86 100644 --- a/src/app/qgsmaptooladdring.h +++ b/src/app/qgsmaptooladdring.h @@ -20,7 +20,7 @@ #include "qgis_app.h" //! A tool to cut holes into polygons and multipolygon features -class APP_EXPORT QgsMapToolAddRing: public QgsMapToolCapture +class APP_EXPORT QgsMapToolAddRing : public QgsMapToolCapture { Q_OBJECT public: diff --git a/src/app/qgsmaptoolannotation.cpp b/src/app/qgsmaptoolannotation.cpp index cdec43480e36..7e30add2648e 100644 --- a/src/app/qgsmaptoolannotation.cpp +++ b/src/app/qgsmaptoolannotation.cpp @@ -117,8 +117,9 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e ) annotation->setMapPosition( mapPos ); annotation->setMapPositionCrs( mCanvas->mapSettings().destinationCrs() ); annotation->setRelativePosition( QPointF( - static_cast( e->pos().x() ) / mCanvas->width(), - static_cast( e->pos().y() ) / mCanvas->height() ) ); + static_cast( e->pos().x() ) / mCanvas->width(), + static_cast( e->pos().y() ) / mCanvas->height() + ) ); annotation->setFrameSizeMm( QSizeF( 50, 25 ) ); QgsProject::instance()->annotationManager()->addAnnotation( annotation ); @@ -127,7 +128,7 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e ) const auto constItems = mCanvas->items(); for ( QGraphicsItem *item : constItems ) { - if ( QgsMapCanvasAnnotationItem *annotationItem = dynamic_cast< QgsMapCanvasAnnotationItem * >( item ) ) + if ( QgsMapCanvasAnnotationItem *annotationItem = dynamic_cast( item ) ) { if ( annotationItem->annotation() == annotation ) { @@ -137,8 +138,6 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e ) } } } - - } void QgsMapToolAnnotation::keyPressEvent( QKeyEvent *e ) @@ -167,16 +166,14 @@ bool QgsMapToolAnnotation::populateContextMenuWithEvent( QMenu *menu, QgsMapMous return true; } menu->addSeparator(); - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleEditing.svg" ) ), tr( "Edit" ), this, [this, existingItem]() - { + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleEditing.svg" ) ), tr( "Edit" ), this, [this, existingItem]() { QDialog *dialog = createItemEditor( existingItem ); if ( dialog ) { dialog->exec(); } } ); - menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteSelected.svg" ) ), tr( "Delete" ), this, [existingItem]() - { + menu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteSelected.svg" ) ), tr( "Delete" ), this, [existingItem]() { QgsProject::instance()->annotationManager()->removeAnnotation( existingItem->annotation() ); } ); @@ -197,8 +194,7 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e ) { const QgsPointXY mapPos = transformCanvasToAnnotation( e->snapPoint(), annotation ); annotation->setMapPosition( mapPos ); - annotation->setRelativePosition( QPointF( e->pos().x() / mCanvas->width(), - e->pos().y() / mCanvas->height() ) ); + annotation->setRelativePosition( QPointF( e->pos().x() / mCanvas->width(), e->pos().y() / mCanvas->height() ) ); item->update(); QgsProject::instance()->setDirty( true ); } @@ -210,17 +206,14 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e ) const double pixelToMmScale = 25.4 / mCanvas->logicalDpiX(); const double deltaX = pixelToMmScale * ( e->pos().x() - mLastMousePosition.x() ); const double deltaY = pixelToMmScale * ( e->pos().y() - mLastMousePosition.y() ); - annotation->setFrameOffsetFromReferencePointMm( QPointF( annotation->frameOffsetFromReferencePointMm().x() + deltaX, - annotation->frameOffsetFromReferencePointMm().y() + deltaY ) ); - annotation->setRelativePosition( QPointF( newCanvasPos.x() / mCanvas->width(), - newCanvasPos.y() / mCanvas->height() ) ); + annotation->setFrameOffsetFromReferencePointMm( QPointF( annotation->frameOffsetFromReferencePointMm().x() + deltaX, annotation->frameOffsetFromReferencePointMm().y() + deltaY ) ); + annotation->setRelativePosition( QPointF( newCanvasPos.x() / mCanvas->width(), newCanvasPos.y() / mCanvas->height() ) ); } else { const QgsPointXY mapPos = transformCanvasToAnnotation( toMapCoordinates( newCanvasPos.toPoint() ), annotation ); annotation->setMapPosition( mapPos ); - annotation->setRelativePosition( QPointF( newCanvasPos.x() / mCanvas->width(), - newCanvasPos.y() / mCanvas->height() ) ); + annotation->setRelativePosition( QPointF( newCanvasPos.x() / mCanvas->width(), newCanvasPos.y() / mCanvas->height() ) ); } item->update(); QgsProject::instance()->setDirty( true ); @@ -239,29 +232,21 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e ) double relPosX = annotation->relativePosition().x(); double relPosY = annotation->relativePosition().y(); - if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRight || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp ) + if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRight || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp ) { xmax += pixelToMmScale * ( e->pos().x() - mLastMousePosition.x() ); } - if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeft || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp ) + if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeft || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp ) { xmin += pixelToMmScale * ( e->pos().x() - mLastMousePosition.x() ); relPosX = ( relPosX * mCanvas->width() + e->pos().x() - mLastMousePosition.x() ) / static_cast( mCanvas->width() ); } - if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameUp || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp ) + if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameUp || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp ) { ymin += pixelToMmScale * ( e->pos().y() - mLastMousePosition.y() ); relPosY = ( relPosY * mCanvas->height() + e->pos().y() - mLastMousePosition.y() ) / static_cast( mCanvas->height() ); } - if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameDown || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown || - mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown ) + if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameDown || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown || mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown ) { ymax += pixelToMmScale * ( e->pos().y() - mLastMousePosition.y() ); } diff --git a/src/app/qgsmaptoolannotation.h b/src/app/qgsmaptoolannotation.h index bbf42444d6b8..b1416e2a436b 100644 --- a/src/app/qgsmaptoolannotation.h +++ b/src/app/qgsmaptoolannotation.h @@ -24,7 +24,7 @@ class QgsAnnotation; -class APP_EXPORT QgsMapToolAnnotation: public QgsMapTool +class APP_EXPORT QgsMapToolAnnotation : public QgsMapTool { Q_OBJECT @@ -41,7 +41,6 @@ class APP_EXPORT QgsMapToolAnnotation: public QgsMapTool bool populateContextMenuWithEvent( QMenu *menu, QgsMapMouseEvent *event ) override; protected: - /** * Creates a new item. To be implemented by subclasses. */ diff --git a/src/app/qgsmaptooldeletepart.cpp b/src/app/qgsmaptooldeletepart.cpp index dd41c6059bd9..61eb9f0c05bb 100644 --- a/src/app/qgsmaptooldeletepart.cpp +++ b/src/app/qgsmaptooldeletepart.cpp @@ -34,9 +34,7 @@ class SelectedOnlyFilter : public QgsPointLocator::MatchFilter bool acceptMatch( const QgsPointLocator::Match &match ) override { // If there is a selection, we limit matches to selected features - if ( match.layer() && - match.layer()->selectedFeatureCount() > 0 && - !match.layer()->selectedFeatureIds().contains( match.featureId() ) ) + if ( match.layer() && match.layer()->selectedFeatureCount() > 0 && !match.layer()->selectedFeatureIds().contains( match.featureId() ) ) { return false; } @@ -101,7 +99,8 @@ void QgsMapToolDeletePart::canvasPressEvent( QgsMapMouseEvent *e ) { emit messageEmitted( tr( "If there are selected features, the delete parts tool only applies to those. Clear the selection and try again." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } } @@ -233,4 +232,3 @@ void QgsMapToolDeletePart::deactivate() { QgsMapTool::deactivate(); } - diff --git a/src/app/qgsmaptooldeletepart.h b/src/app/qgsmaptooldeletepart.h index f7cbddfe8b8d..1d3390ce11d3 100644 --- a/src/app/qgsmaptooldeletepart.h +++ b/src/app/qgsmaptooldeletepart.h @@ -24,7 +24,7 @@ class QgsVertexMarker; //! Map tool to delete vertices from line/polygon features -class APP_EXPORT QgsMapToolDeletePart: public QgsMapToolEdit +class APP_EXPORT QgsMapToolDeletePart : public QgsMapToolEdit { Q_OBJECT diff --git a/src/app/qgsmaptooldeletering.cpp b/src/app/qgsmaptooldeletering.cpp index 0b2860f78ba1..3ddd6023b5d2 100644 --- a/src/app/qgsmaptooldeletering.cpp +++ b/src/app/qgsmaptooldeletering.cpp @@ -94,7 +94,8 @@ void QgsMapToolDeleteRing::canvasPressEvent( QgsMapMouseEvent *e ) { emit messageEmitted( tr( "If there are selected features, the delete ring tool only applies to those. Clear the selection and try again." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } } @@ -139,8 +140,7 @@ QgsGeometry QgsMapToolDeleteRing::ringUnderPoint( const QgsPointXY &p, QgsFeatur const QgsFeatureIds selectedFeatureIds = vlayer->selectedFeatureIds(); while ( fit.nextFeature( f ) ) { - if ( !selectedFeatureIds.isEmpty() && - !selectedFeatureIds.contains( f.id() ) ) + if ( !selectedFeatureIds.isEmpty() && !selectedFeatureIds.contains( f.id() ) ) continue; g = f.geometry(); @@ -156,7 +156,7 @@ QgsGeometry QgsMapToolDeleteRing::ringUnderPoint( const QgsPointXY &p, QgsFeatur pol = g.asMultiPolygon(); } - for ( int i = 0; i < pol.size() ; ++i ) + for ( int i = 0; i < pol.size(); ++i ) { //for each part if ( pol[i].size() > 1 ) @@ -210,7 +210,6 @@ void QgsMapToolDeleteRing::deleteRing( QgsFeatureId fId, int beforeVertexNr, Qgs vlayer->endEditCommand(); vlayer->triggerRepaint(); } - } int QgsMapToolDeleteRing::ringNumInPolygon( const QgsGeometry &g, int vertexNr ) @@ -249,6 +248,5 @@ int QgsMapToolDeleteRing::ringNumInMultiPolygon( const QgsGeometry &g, int verte void QgsMapToolDeleteRing::deactivate() { - QgsMapTool::deactivate(); } diff --git a/src/app/qgsmaptoolfeatureaction.cpp b/src/app/qgsmaptoolfeatureaction.cpp index 9af78c9c3b2e..47e51b6dee09 100644 --- a/src/app/qgsmaptoolfeatureaction.cpp +++ b/src/app/qgsmaptoolfeatureaction.cpp @@ -149,11 +149,10 @@ bool QgsMapToolFeatureAction::doAction( QgsVectorLayer *layer, int x, int y ) featureTitle = FID_TO_STRING( feature.id() ); QAction *featureAction = featureMenu->addAction( featureTitle ); - connect( featureAction, &QAction::triggered, this, [ = ] { doActionForFeature( layer, feature, point );} ); + connect( featureAction, &QAction::triggered, this, [=] { doActionForFeature( layer, feature, point ); } ); } QAction *allFeatureAction = featureMenu->addAction( tr( "All Features" ) ); - connect( allFeatureAction, &QAction::triggered, this, [ = ] - { + connect( allFeatureAction, &QAction::triggered, this, [=] { for ( const QgsFeature &feature : std::as_const( features ) ) { doActionForFeature( layer, feature, point ); diff --git a/src/app/qgsmaptoolfillring.cpp b/src/app/qgsmaptoolfillring.cpp index d91151fa62a5..6e360a2cd0f8 100644 --- a/src/app/qgsmaptoolfillring.cpp +++ b/src/app/qgsmaptoolfillring.cpp @@ -89,7 +89,7 @@ void QgsMapToolFillRing::polygonCaptured( const QgsCurvePolygon *polygon ) { errorMessage = tr( "the inserted Ring is not closed" ); } - else if ( addRingReturnCode == Qgis::GeometryOperationResult::AddRingNotValid ) + else if ( addRingReturnCode == Qgis::GeometryOperationResult::AddRingNotValid ) { errorMessage = tr( "the inserted Ring is not a valid geometry" ); } @@ -117,7 +117,6 @@ void QgsMapToolFillRing::polygonCaptured( const QgsCurvePolygon *polygon ) void QgsMapToolFillRing::createFeature( const QgsGeometry &geometry, QgsFeatureId fid ) { - QgsVectorLayer *vlayer = getCheckLayer(); if ( !vlayer ) return; @@ -197,7 +196,7 @@ void QgsMapToolFillRing::fillRingUnderPoint( const QgsPointXY &p ) pol = g.asMultiPolygon(); } - for ( int i = 0; i < pol.size() ; ++i ) + for ( int i = 0; i < pol.size(); ++i ) { //for each part if ( pol[i].size() > 1 ) diff --git a/src/app/qgsmaptoolfillring.h b/src/app/qgsmaptoolfillring.h index 05e7acd0e9f8..072267dbdf50 100644 --- a/src/app/qgsmaptoolfillring.h +++ b/src/app/qgsmaptoolfillring.h @@ -24,7 +24,7 @@ * A tool to cut holes into polygon and multipolygon features and fill them * with new feature. Attributes are copied from parent feature. */ -class APP_EXPORT QgsMapToolFillRing: public QgsMapToolCapture +class APP_EXPORT QgsMapToolFillRing : public QgsMapToolCapture { Q_OBJECT public: diff --git a/src/app/qgsmaptoolformannotation.cpp b/src/app/qgsmaptoolformannotation.cpp index 158d06ad5861..cfdb6401ee43 100644 --- a/src/app/qgsmaptoolformannotation.cpp +++ b/src/app/qgsmaptoolformannotation.cpp @@ -23,13 +23,12 @@ #include "qgsproject.h" #include -QgsMapToolFormAnnotation::QgsMapToolFormAnnotation( QgsMapCanvas *canvas ): QgsMapToolAnnotation( canvas ) +QgsMapToolFormAnnotation::QgsMapToolFormAnnotation( QgsMapCanvas *canvas ) + : QgsMapToolAnnotation( canvas ) { - } QgsAnnotation *QgsMapToolFormAnnotation::createItem() const { return new QgsFormAnnotation(); } - diff --git a/src/app/qgsmaptoolformannotation.h b/src/app/qgsmaptoolformannotation.h index 039843dec579..5b5346073e30 100644 --- a/src/app/qgsmaptoolformannotation.h +++ b/src/app/qgsmaptoolformannotation.h @@ -21,7 +21,7 @@ #include "qgsmaptoolannotation.h" #include "qgis_app.h" -class APP_EXPORT QgsMapToolFormAnnotation: public QgsMapToolAnnotation +class APP_EXPORT QgsMapToolFormAnnotation : public QgsMapToolAnnotation { Q_OBJECT diff --git a/src/app/qgsmaptoolhtmlannotation.cpp b/src/app/qgsmaptoolhtmlannotation.cpp index cff420dc2538..6626a26cd48b 100644 --- a/src/app/qgsmaptoolhtmlannotation.cpp +++ b/src/app/qgsmaptoolhtmlannotation.cpp @@ -23,13 +23,12 @@ #include "qgsproject.h" #include -QgsMapToolHtmlAnnotation::QgsMapToolHtmlAnnotation( QgsMapCanvas *canvas ): QgsMapToolAnnotation( canvas ) +QgsMapToolHtmlAnnotation::QgsMapToolHtmlAnnotation( QgsMapCanvas *canvas ) + : QgsMapToolAnnotation( canvas ) { - } QgsAnnotation *QgsMapToolHtmlAnnotation::createItem() const { return new QgsHtmlAnnotation(); } - diff --git a/src/app/qgsmaptoolhtmlannotation.h b/src/app/qgsmaptoolhtmlannotation.h index 4c3ae209cc9a..dd7cbb7a9b12 100644 --- a/src/app/qgsmaptoolhtmlannotation.h +++ b/src/app/qgsmaptoolhtmlannotation.h @@ -21,7 +21,7 @@ #include "qgsmaptoolannotation.h" #include "qgis_app.h" -class APP_EXPORT QgsMapToolHtmlAnnotation: public QgsMapToolAnnotation +class APP_EXPORT QgsMapToolHtmlAnnotation : public QgsMapToolAnnotation { Q_OBJECT diff --git a/src/app/qgsmaptoolidentifyaction.cpp b/src/app/qgsmaptoolidentifyaction.cpp index ad9777bc9158..7a9c0c81101c 100644 --- a/src/app/qgsmaptoolidentifyaction.cpp +++ b/src/app/qgsmaptoolidentifyaction.cpp @@ -74,8 +74,7 @@ QgsIdentifyResultsDialog *QgsMapToolIdentifyAction::resultsDialog() connect( mResultsDialog.data(), static_cast( &QgsIdentifyResultsDialog::formatChanged ), this, &QgsMapToolIdentify::formatChanged ); connect( mResultsDialog.data(), &QgsIdentifyResultsDialog::copyToClipboard, this, &QgsMapToolIdentifyAction::handleCopyToClipboard ); - connect( mResultsDialog.data(), &QgsIdentifyResultsDialog::selectionModeChanged, this, [this] - { + connect( mResultsDialog.data(), &QgsIdentifyResultsDialog::selectionModeChanged, this, [this] { mSelectionHandler->setSelectionMode( mResultsDialog->selectionMode() ); } ); } @@ -223,7 +222,7 @@ void QgsMapToolIdentifyAction::clearResults() void QgsMapToolIdentifyAction::showResultsForFeature( QgsVectorLayer *vlayer, QgsFeatureId fid, const QgsPoint &pt ) { const QgsFeature feature = vlayer->getFeature( fid ); - const QMap< QString, QString > derivedAttributes = derivedAttributesForPoint( pt ); + const QMap derivedAttributes = derivedAttributesForPoint( pt ); // TODO: private in QgsMapToolIdentify //derivedAttributes.unite( featureDerivedAttributes( feature, vlayer, QgsPointXY( pt ) ) ); diff --git a/src/app/qgsmaptoolmeasureangle.cpp b/src/app/qgsmaptoolmeasureangle.cpp index d07c3f692ffe..5473c11fbe2a 100644 --- a/src/app/qgsmaptoolmeasureangle.cpp +++ b/src/app/qgsmaptoolmeasureangle.cpp @@ -33,8 +33,7 @@ QgsMapToolMeasureAngle::QgsMapToolMeasureAngle( QgsMapCanvas *canvas ) { mToolName = tr( "Measure angle" ); - connect( canvas, &QgsMapCanvas::destinationCrsChanged, - this, &QgsMapToolMeasureAngle::updateSettings ); + connect( canvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapToolMeasureAngle::updateSettings ); } QgsMapToolMeasureAngle::~QgsMapToolMeasureAngle() diff --git a/src/app/qgsmaptoolmeasureangle.h b/src/app/qgsmaptoolmeasureangle.h index 5ae36dfc797a..df383935961b 100644 --- a/src/app/qgsmaptoolmeasureangle.h +++ b/src/app/qgsmaptoolmeasureangle.h @@ -26,7 +26,7 @@ class QgsRubberBand; class QgsSnapIndicator; //! Map tool to measure angle between two segments -class APP_EXPORT QgsMapToolMeasureAngle: public QgsMapTool +class APP_EXPORT QgsMapToolMeasureAngle : public QgsMapTool { Q_OBJECT public: @@ -64,7 +64,6 @@ class APP_EXPORT QgsMapToolMeasureAngle: public QgsMapTool //! Configures distance area objects with ellipsoid / output crs void configureDistanceArea(); - }; #endif // QGSMAPTOOLMEASUREANGLE_H diff --git a/src/app/qgsmaptoolmeasurebearing.cpp b/src/app/qgsmaptoolmeasurebearing.cpp index 048ed98fba02..6e80310a2340 100644 --- a/src/app/qgsmaptoolmeasurebearing.cpp +++ b/src/app/qgsmaptoolmeasurebearing.cpp @@ -32,8 +32,7 @@ QgsMapToolMeasureBearing::QgsMapToolMeasureBearing( QgsMapCanvas *canvas ) { mToolName = tr( "Measure bearing" ); - connect( canvas, &QgsMapCanvas::destinationCrsChanged, - this, &QgsMapToolMeasureBearing::updateSettings ); + connect( canvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapToolMeasureBearing::updateSettings ); } QgsMapToolMeasureBearing::~QgsMapToolMeasureBearing() @@ -66,7 +65,6 @@ void QgsMapToolMeasureBearing::canvasMoveEvent( QgsMapMouseEvent *e ) } catch ( QgsCsException & ) { - } } } diff --git a/src/app/qgsmaptoolmeasurebearing.h b/src/app/qgsmaptoolmeasurebearing.h index c5983b4d72ec..d2f2de44f308 100644 --- a/src/app/qgsmaptoolmeasurebearing.h +++ b/src/app/qgsmaptoolmeasurebearing.h @@ -26,7 +26,7 @@ class QgsRubberBand; class QgsSnapIndicator; //! Map tool to measure bearing between two points -class APP_EXPORT QgsMapToolMeasureBearing: public QgsMapTool +class APP_EXPORT QgsMapToolMeasureBearing : public QgsMapTool { Q_OBJECT public: @@ -66,7 +66,6 @@ class APP_EXPORT QgsMapToolMeasureBearing: public QgsMapTool void configureDistanceArea(); friend class TestQgsMeasureBearingTool; - }; #endif // QGSMAPTOOLMEASUREBEARING_H diff --git a/src/app/qgsmaptoolmovefeature.cpp b/src/app/qgsmaptoolmovefeature.cpp index dbc6397bb3bf..211193eb6769 100644 --- a/src/app/qgsmaptoolmovefeature.cpp +++ b/src/app/qgsmaptoolmovefeature.cpp @@ -36,7 +36,7 @@ QgsMapToolMoveFeature::QgsMapToolMoveFeature( QgsMapCanvas *canvas, MoveMode mode ) : QgsMapToolAdvancedDigitizing( canvas, QgisApp::instance()->cadDockWidget() ) - , mSnapIndicator( std::make_unique< QgsSnapIndicator>( canvas ) ) + , mSnapIndicator( std::make_unique( canvas ) ) , mMode( mode ) { mToolName = tr( "Move feature" ); @@ -65,8 +65,8 @@ void QgsMapToolMoveFeature::cadCanvasMoveEvent( QgsMapMouseEvent *e ) // Else, recreate the rubber band from the translated geometries else { - const QgsPointXY startPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * )vlayer, mStartPointMapCoords ); - const QgsPointXY stopPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * )vlayer, e->mapPoint() ); + const QgsPointXY startPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * ) vlayer, mStartPointMapCoords ); + const QgsPointXY stopPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * ) vlayer, e->mapPoint() ); const double dx = stopPointLayerCoords.x() - startPointLayerCoords.x(); const double dy = stopPointLayerCoords.y() - startPointLayerCoords.y(); @@ -105,8 +105,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) //find first geometry under mouse cursor and store iterator to it const QgsPointXY layerCoords = toLayerCoordinates( vlayer, e->mapPoint() ); const double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->currentLayer(), mCanvas->mapSettings() ); - const QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, - layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); + const QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); if ( vlayer->selectedFeatureCount() == 0 ) { @@ -161,7 +160,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) bool allFeaturesInView = true; const QgsRectangle viewRect = mCanvas->mapSettings().mapToLayerCoordinates( vlayer, mCanvas->extent() ); - QVector selectedGeometries; + QVector selectedGeometries; while ( it.nextFeature( feat ) ) { selectedGeometries << feat.geometry(); @@ -176,9 +175,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) { // for extra safety to make sure we are not modifying geometries by accident - const int res = QMessageBox::warning( mCanvas, tr( "Move features" ), - tr( "Some of the selected features are outside of the current map view. Would you still like to continue?" ), - QMessageBox::Yes | QMessageBox::No ); + const int res = QMessageBox::warning( mCanvas, tr( "Move features" ), tr( "Some of the selected features are outside of the current map view. Would you still like to continue?" ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) { mMovedFeatures.clear(); @@ -203,8 +200,8 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) return; } - const QgsPointXY startPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * )vlayer, mStartPointMapCoords ); - const QgsPointXY stopPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * )vlayer, e->mapPoint() ); + const QgsPointXY startPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * ) vlayer, mStartPointMapCoords ); + const QgsPointXY stopPointLayerCoords = toLayerCoordinates( ( QgsMapLayer * ) vlayer, e->mapPoint() ); const double dx = stopPointLayerCoords.x() - startPointLayerCoords.x(); const double dy = stopPointLayerCoords.y() - startPointLayerCoords.y(); @@ -224,7 +221,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) connect( &avoidIntersections, &QgsAvoidIntersectionsOperation::messageEmitted, this, &QgsMapTool::messageEmitted ); // when removing intersections don't check for intersections with selected features - const QHash > ignoreFeatures {{ vlayer, mMovedFeatures }}; + const QHash> ignoreFeatures { { vlayer, mMovedFeatures } }; while ( fi.nextFeature( f ) ) { @@ -243,9 +240,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) if ( res.operationResult == Qgis::GeometryOperationResult::InvalidInputGeometryType || geom.isEmpty() ) { - const QString errorMessage = ( geom.isEmpty() ) ? - tr( "The feature cannot be moved because the resulting geometry would be empty" ) : - tr( "An error was reported during intersection removal" ); + const QString errorMessage = ( geom.isEmpty() ) ? tr( "The feature cannot be moved because the resulting geometry would be empty" ) : tr( "An error was reported during intersection removal" ); emit messageEmitted( errorMessage, Qgis::MessageLevel::Warning ); vlayer->destroyEditCommand(); diff --git a/src/app/qgsmaptoolmovefeature.h b/src/app/qgsmaptoolmovefeature.h index 27218f93bdf9..f83d59517697 100644 --- a/src/app/qgsmaptoolmovefeature.h +++ b/src/app/qgsmaptoolmovefeature.h @@ -24,15 +24,15 @@ class QgsSnapIndicator; //! Map tool for translating feature position by mouse drag -class APP_EXPORT QgsMapToolMoveFeature: public QgsMapToolAdvancedDigitizing +class APP_EXPORT QgsMapToolMoveFeature : public QgsMapToolAdvancedDigitizing { Q_OBJECT public: //! Mode for moving features enum MoveMode { - Move, //!< Move feature - CopyMove //!< Copy and move feature + Move, //!< Move feature + CopyMove //!< Copy and move feature }; QgsMapToolMoveFeature( QgsMapCanvas *canvas, MoveMode mode = Move ); @@ -48,7 +48,6 @@ class APP_EXPORT QgsMapToolMoveFeature: public QgsMapToolAdvancedDigitizing void keyReleaseEvent( QKeyEvent *e ) override; private: - void deleteRubberband(); //! Start point of the move in map coordinates @@ -69,7 +68,6 @@ class APP_EXPORT QgsMapToolMoveFeature: public QgsMapToolAdvancedDigitizing // MultiGeometry of the moved features QgsGeometry mGeom; - }; #endif diff --git a/src/app/qgsmaptooloffsetcurve.cpp b/src/app/qgsmaptooloffsetcurve.cpp index 53aacd022867..db33b45af836 100644 --- a/src/app/qgsmaptooloffsetcurve.cpp +++ b/src/app/qgsmaptooloffsetcurve.cpp @@ -38,7 +38,7 @@ QgsMapToolOffsetCurve::QgsMapToolOffsetCurve( QgsMapCanvas *canvas ) : QgsMapToolEdit( canvas ) - , mSnapIndicator( std::make_unique< QgsSnapIndicator >( canvas ) ) + , mSnapIndicator( std::make_unique( canvas ) ) { mToolName = tr( "Map tool offset curve" ); } @@ -85,8 +85,7 @@ void QgsMapToolOffsetCurve::canvasReleaseEvent( QgsMapMouseEvent *e ) } else { - match = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(), - QgsPointLocator::Types( QgsPointLocator::Edge | QgsPointLocator::Area ) ); + match = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(), QgsPointLocator::Types( QgsPointLocator::Edge | QgsPointLocator::Area ) ); } if ( auto *lLayer = match.layer() ) @@ -110,12 +109,7 @@ void QgsMapToolOffsetCurve::canvasReleaseEvent( QgsMapMouseEvent *e ) const bool hasM = QgsWkbTypes::hasZ( mSourceLayer->wkbType() ); if ( hasZ || hasM ) { - emit messageEmitted( QStringLiteral( "layer %1 has %2%3%4 geometry. %2%3%4 values be set to 0 when using offset tool." ) - .arg( mSourceLayer->name(), - hasZ ? QStringLiteral( "Z" ) : QString(), - hasZ && hasM ? QStringLiteral( "/" ) : QString(), - hasM ? QStringLiteral( "M" ) : QString() ) - , Qgis::MessageLevel::Warning ); + emit messageEmitted( QStringLiteral( "layer %1 has %2%3%4 geometry. %2%3%4 values be set to 0 when using offset tool." ).arg( mSourceLayer->name(), hasZ ? QStringLiteral( "Z" ) : QString(), hasZ && hasM ? QStringLiteral( "/" ) : QString(), hasM ? QStringLiteral( "M" ) : QString() ), Qgis::MessageLevel::Warning ); } } } @@ -342,7 +336,7 @@ void QgsMapToolOffsetCurve::applyOffset( double offset, Qt::KeyboardModifiers mo return; } - QgsVectorLayer *destLayer = qobject_cast< QgsVectorLayer * >( canvas()->currentLayer() ); + QgsVectorLayer *destLayer = qobject_cast( canvas()->currentLayer() ); if ( !destLayer ) return; @@ -352,19 +346,15 @@ void QgsMapToolOffsetCurve::applyOffset( double offset, Qt::KeyboardModifiers mo connect( &avoidIntersections, &QgsAvoidIntersectionsOperation::messageEmitted, this, &QgsMapTool::messageEmitted ); - const QSet ignoredFeatures = ( modifiers & Qt::ControlModifier ) ? - QSet() : - QSet( {mModifiedFeature} ); + const QSet ignoredFeatures = ( modifiers & Qt::ControlModifier ) ? QSet() : QSet( { mModifiedFeature } ); - const QHash > ignoreFeatures = {{ destLayer, {ignoredFeatures} }}; + const QHash> ignoreFeatures = { { destLayer, { ignoredFeatures } } }; const QgsAvoidIntersectionsOperation::Result res = avoidIntersections.apply( destLayer, mModifiedFeature, mModifiedGeometry, ignoreFeatures ); if ( res.operationResult == Qgis::GeometryOperationResult::InvalidInputGeometryType || mModifiedGeometry.isEmpty() ) { - const QString errorMessage = ( mModifiedGeometry.isEmpty() ) ? - tr( "The feature cannot be modified because the resulting geometry would be empty" ) : - tr( "An error was reported during intersection removal" ); + const QString errorMessage = ( mModifiedGeometry.isEmpty() ) ? tr( "The feature cannot be modified because the resulting geometry would be empty" ) : tr( "An error was reported during intersection removal" ); emit messageEmitted( errorMessage, Qgis::MessageLevel::Warning ); destLayer->destroyEditCommand(); @@ -472,8 +462,7 @@ void QgsMapToolOffsetCurve::canvasMoveEvent( QgsMapMouseEvent *e ) } else { - match = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(), - QgsPointLocator::Types( QgsPointLocator::Edge | QgsPointLocator::Area ) ); + match = mCanvas->snappingUtils()->snapToCurrentLayer( e->pos(), QgsPointLocator::Types( QgsPointLocator::Edge | QgsPointLocator::Area ) ); } mSnapIndicator->setMatch( match ); return; @@ -583,7 +572,6 @@ void QgsMapToolOffsetCurve::prepareGeometry( const QgsPointLocator::Match &match { mManipulatedGeometry = QgsGeometry::fromPolygonXY( poly ); } - } else { @@ -618,7 +606,7 @@ void QgsMapToolOffsetCurve::createUserInputWidget() connect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingFinished, this, &QgsMapToolOffsetCurve::applyOffsetFromWidget ); connect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingCanceled, this, &QgsMapToolOffsetCurve::cancel ); - connect( mUserInputWidget, &QgsOffsetUserWidget::offsetConfigChanged, this, [ = ] {updateGeometryAndRubberBand( mUserInputWidget->offset() );} ); + connect( mUserInputWidget, &QgsOffsetUserWidget::offsetConfigChanged, this, [=] { updateGeometryAndRubberBand( mUserInputWidget->offset() ); } ); } void QgsMapToolOffsetCurve::deleteUserInputWidget() @@ -699,39 +687,39 @@ QgsOffsetUserWidget::QgsOffsetUserWidget( QWidget *parent ) mOffsetSpinBox->setClearValue( 0.0 ); // fill comboboxes - mJoinStyleComboBox->addItem( tr( "Round" ), static_cast< int >( Qgis::JoinStyle::Round ) ); - mJoinStyleComboBox->addItem( tr( "Miter" ), static_cast< int >( Qgis::JoinStyle::Miter ) ); - mJoinStyleComboBox->addItem( tr( "Bevel" ), static_cast< int >( Qgis::JoinStyle::Bevel ) ); - mCapStyleComboBox->addItem( tr( "Round" ), static_cast< int >( Qgis::EndCapStyle::Round ) ); - mCapStyleComboBox->addItem( tr( "Flat" ), static_cast< int >( Qgis::EndCapStyle::Flat ) ); - mCapStyleComboBox->addItem( tr( "Square" ), static_cast< int >( Qgis::EndCapStyle::Square ) ); + mJoinStyleComboBox->addItem( tr( "Round" ), static_cast( Qgis::JoinStyle::Round ) ); + mJoinStyleComboBox->addItem( tr( "Miter" ), static_cast( Qgis::JoinStyle::Miter ) ); + mJoinStyleComboBox->addItem( tr( "Bevel" ), static_cast( Qgis::JoinStyle::Bevel ) ); + mCapStyleComboBox->addItem( tr( "Round" ), static_cast( Qgis::EndCapStyle::Round ) ); + mCapStyleComboBox->addItem( tr( "Flat" ), static_cast( Qgis::EndCapStyle::Flat ) ); + mCapStyleComboBox->addItem( tr( "Square" ), static_cast( Qgis::EndCapStyle::Square ) ); const Qgis::JoinStyle joinStyle = QgsSettingsRegistryCore::settingsDigitizingOffsetJoinStyle->value(); const int quadSegments = QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->value(); const double miterLimit = QgsSettingsRegistryCore::settingsDigitizingOffsetMiterLimit->value(); const Qgis::EndCapStyle capStyle = QgsSettingsRegistryCore::settingsDigitizingOffsetCapStyle->value(); - mJoinStyleComboBox->setCurrentIndex( mJoinStyleComboBox->findData( static_cast< int >( joinStyle ) ) ); + mJoinStyleComboBox->setCurrentIndex( mJoinStyleComboBox->findData( static_cast( joinStyle ) ) ); mQuadrantSpinBox->setValue( quadSegments ); mQuadrantSpinBox->setClearValue( 8 ); mMiterLimitSpinBox->setValue( miterLimit ); mMiterLimitSpinBox->setClearValue( 5.0 ); - mCapStyleComboBox->setCurrentIndex( mCapStyleComboBox->findData( static_cast< int >( capStyle ) ) ); + mCapStyleComboBox->setCurrentIndex( mCapStyleComboBox->findData( static_cast( capStyle ) ) ); // connect signals mOffsetSpinBox->installEventFilter( this ); - connect( mOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsOffsetUserWidget::offsetChanged ); + connect( mOffsetSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsOffsetUserWidget::offsetChanged ); - connect( mJoinStyleComboBox, static_cast < void ( QComboBox::* )( int ) > ( &QComboBox::currentIndexChanged ), this, [ = ] { QgsSettingsRegistryCore::settingsDigitizingOffsetJoinStyle->setValue( static_cast< Qgis::JoinStyle >( mJoinStyleComboBox->currentData().toInt() ) ); emit offsetConfigChanged(); } ); - connect( mQuadrantSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, [ = ]( const int quadSegments ) { QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->setValue( quadSegments ); emit offsetConfigChanged(); } ); - connect( mMiterLimitSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double miterLimit ) { QgsSettingsRegistryCore::settingsDigitizingOffsetMiterLimit->setValue( miterLimit ); emit offsetConfigChanged(); } ); - connect( mCapStyleComboBox, static_cast < void ( QComboBox::* )( int ) > ( &QComboBox::currentIndexChanged ), this, [ = ] { QgsSettingsRegistryCore::settingsDigitizingOffsetCapStyle->setValue( static_cast< Qgis::EndCapStyle >( mCapStyleComboBox->currentData().toInt() ) ); emit offsetConfigChanged(); } ); + connect( mJoinStyleComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=] { QgsSettingsRegistryCore::settingsDigitizingOffsetJoinStyle->setValue( static_cast< Qgis::JoinStyle >( mJoinStyleComboBox->currentData().toInt() ) ); emit offsetConfigChanged(); } ); + connect( mQuadrantSpinBox, static_cast( &QSpinBox::valueChanged ), this, [=]( const int quadSegments ) { QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->setValue( quadSegments ); emit offsetConfigChanged(); } ); + connect( mMiterLimitSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, [=]( double miterLimit ) { QgsSettingsRegistryCore::settingsDigitizingOffsetMiterLimit->setValue( miterLimit ); emit offsetConfigChanged(); } ); + connect( mCapStyleComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=] { QgsSettingsRegistryCore::settingsDigitizingOffsetCapStyle->setValue( static_cast< Qgis::EndCapStyle >( mCapStyleComboBox->currentData().toInt() ) ); emit offsetConfigChanged(); } ); const bool showAdvanced = QgsSettingsRegistryCore::settingsDigitizingOffsetShowAdvanced->value(); mShowAdvancedButton->setChecked( showAdvanced ); mAdvancedConfigWidget->setVisible( showAdvanced ); connect( mShowAdvancedButton, &QToolButton::clicked, mAdvancedConfigWidget, &QWidget::setVisible ); - connect( mShowAdvancedButton, &QToolButton::clicked, this, [ = ]( const bool clicked ) {QgsSettingsRegistryCore::settingsDigitizingConvertToCurveDistanceTolerance->setValue( clicked );} ); + connect( mShowAdvancedButton, &QToolButton::clicked, this, [=]( const bool clicked ) { QgsSettingsRegistryCore::settingsDigitizingConvertToCurveDistanceTolerance->setValue( clicked ); } ); // config focus setFocusProxy( mOffsetSpinBox ); diff --git a/src/app/qgsmaptooloffsetcurve.h b/src/app/qgsmaptooloffsetcurve.h index 5f4b654cf663..186fa118dea4 100644 --- a/src/app/qgsmaptooloffsetcurve.h +++ b/src/app/qgsmaptooloffsetcurve.h @@ -35,12 +35,11 @@ class APP_EXPORT QgsOffsetUserWidget : public QWidget, private Ui::QgsOffsetUser Q_OBJECT public: - explicit QgsOffsetUserWidget( QWidget *parent = nullptr ); void setOffset( double offset ); double offset(); - QDoubleSpinBox *editor() const {return mOffsetSpinBox;} + QDoubleSpinBox *editor() const { return mOffsetSpinBox; } void setPolygonMode( bool polygon ); @@ -54,7 +53,7 @@ class APP_EXPORT QgsOffsetUserWidget : public QWidget, private Ui::QgsOffsetUser bool eventFilter( QObject *obj, QEvent *ev ) override; }; -class APP_EXPORT QgsMapToolOffsetCurve: public QgsMapToolEdit +class APP_EXPORT QgsMapToolOffsetCurve : public QgsMapToolEdit { Q_OBJECT public: diff --git a/src/app/qgsmaptooloffsetpointsymbol.cpp b/src/app/qgsmaptooloffsetpointsymbol.cpp index 5b99d62a2297..2fc943e2fe1c 100644 --- a/src/app/qgsmaptooloffsetpointsymbol.cpp +++ b/src/app/qgsmaptooloffsetpointsymbol.cpp @@ -196,7 +196,7 @@ void QgsMapToolOffsetPointSymbol::createPreviewItem( QgsMarkerSymbol *markerSymb mOffsetItem = new QgsMapCanvasMarkerSymbolItem( mCanvas ); mOffsetItem->setOpacity( 0.7 ); - mOffsetItem->setSymbol( std::unique_ptr< QgsSymbol >( markerSymbol->clone() ) ); + mOffsetItem->setSymbol( std::unique_ptr( markerSymbol->clone() ) ); } QMap QgsMapToolOffsetPointSymbol::calculateNewOffsetAttributes( const QgsPointXY &startPoint, const QgsPointXY &endPoint ) const @@ -212,14 +212,14 @@ QMap QgsMapToolOffsetPointSymbol::calculateNewOffsetAttributes( c if ( ddOffset.propertyType() != Qgis::PropertyType::Field ) continue; - QgsMarkerSymbolLayer *ml = dynamic_cast< QgsMarkerSymbolLayer * >( layer ); + QgsMarkerSymbolLayer *ml = dynamic_cast( layer ); if ( !ml ) continue; const QPointF offset = calculateOffset( startPoint, endPoint, ml->offsetUnit() ); const int fieldIdx = mActiveLayer->fields().indexFromName( ddOffset.field() ); if ( fieldIdx >= 0 ) - newAttrValues[ fieldIdx ] = QgsSymbolLayerUtils::encodePoint( offset ); + newAttrValues[fieldIdx] = QgsSymbolLayerUtils::encodePoint( offset ); } return newAttrValues; } @@ -295,4 +295,3 @@ QPointF QgsMapToolOffsetPointSymbol::rotatedOffset( QPointF offset, double angle double c = std::cos( angle ), s = std::sin( angle ); return QPointF( offset.x() * c - offset.y() * s, offset.x() * s + offset.y() * c ); } - diff --git a/src/app/qgsmaptooloffsetpointsymbol.h b/src/app/qgsmaptooloffsetpointsymbol.h index 05c6e9172cf4..c5846dbabc7d 100644 --- a/src/app/qgsmaptooloffsetpointsymbol.h +++ b/src/app/qgsmaptooloffsetpointsymbol.h @@ -29,7 +29,7 @@ class QgsMapCanvasMarkerSymbolItem; * \brief A class that allows interactive manipulation of the offset field(s) for point layers. */ -class APP_EXPORT QgsMapToolOffsetPointSymbol: public QgsMapToolPointSymbol +class APP_EXPORT QgsMapToolOffsetPointSymbol : public QgsMapToolPointSymbol { Q_OBJECT @@ -48,13 +48,11 @@ class APP_EXPORT QgsMapToolOffsetPointSymbol: public QgsMapToolPointSymbol static bool layerIsOffsetable( QgsMapLayer *ml ); protected: - void canvasPressOnFeature( QgsMapMouseEvent *e, const QgsFeature &feature, const QgsPointXY &snappedPoint ) override; bool checkSymbolCompatibility( QgsMarkerSymbol *markerSymbol, QgsRenderContext &context ) override; void noCompatibleSymbols() override; private: - //! True when user is dragging to offset a point bool mOffsetting; @@ -62,7 +60,7 @@ class APP_EXPORT QgsMapToolOffsetPointSymbol: public QgsMapToolPointSymbol QgsMapCanvasMarkerSymbolItem *mOffsetItem = nullptr; //! Clone of first found marker symbol for feature with offset attribute set - std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol; + std::unique_ptr mMarkerSymbol; //! Feature which was clicked on QgsFeature mClickedFeature; @@ -80,7 +78,7 @@ class APP_EXPORT QgsMapToolOffsetPointSymbol: public QgsMapToolPointSymbol * Calculates the new values for offset attributes, respecting the symbol's offset units * \note start and end point are in map units */ - QMap< int, QVariant > calculateNewOffsetAttributes( const QgsPointXY &startPoint, const QgsPointXY &endPoint ) const; + QMap calculateNewOffsetAttributes( const QgsPointXY &startPoint, const QgsPointXY &endPoint ) const; /** * Updates the preview item to reflect a new offset. diff --git a/src/app/qgsmaptoolpointsymbol.cpp b/src/app/qgsmaptoolpointsymbol.cpp index 8b0222cf9fa3..2bd2a4d88414 100644 --- a/src/app/qgsmaptoolpointsymbol.cpp +++ b/src/app/qgsmaptoolpointsymbol.cpp @@ -77,7 +77,7 @@ void QgsMapToolPointSymbol::canvasPressEvent( QgsMapMouseEvent *e ) if ( !mActiveLayer->renderer() ) return; - std::unique_ptr< QgsFeatureRenderer > renderer( mActiveLayer->renderer()->clone() ); + std::unique_ptr renderer( mActiveLayer->renderer()->clone() ); QgsRenderContext context = QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ); context.expressionContext() << QgsExpressionContextUtils::layerScope( mActiveLayer ); context.expressionContext().setFeature( feature ); @@ -93,7 +93,7 @@ void QgsMapToolPointSymbol::canvasPressEvent( QgsMapMouseEvent *e ) { if ( s && s->type() == Qgis::SymbolType::Marker ) { - hasCompatibleSymbol = hasCompatibleSymbol || checkSymbolCompatibility( static_cast< QgsMarkerSymbol * >( s ), context ); + hasCompatibleSymbol = hasCompatibleSymbol || checkSymbolCompatibility( static_cast( s ), context ); } } } @@ -102,7 +102,7 @@ void QgsMapToolPointSymbol::canvasPressEvent( QgsMapMouseEvent *e ) QgsSymbol *s = renderer->originalSymbolForFeature( feature, context ); if ( s && s->type() == Qgis::SymbolType::Marker ) { - hasCompatibleSymbol = hasCompatibleSymbol || checkSymbolCompatibility( static_cast< QgsMarkerSymbol * >( s ), context ); + hasCompatibleSymbol = hasCompatibleSymbol || checkSymbolCompatibility( static_cast( s ), context ); } } @@ -112,4 +112,3 @@ void QgsMapToolPointSymbol::canvasPressEvent( QgsMapMouseEvent *e ) else noCompatibleSymbols(); } - diff --git a/src/app/qgsmaptoolpointsymbol.h b/src/app/qgsmaptoolpointsymbol.h index e97cf8f6d1db..cacc9df5aa5c 100644 --- a/src/app/qgsmaptoolpointsymbol.h +++ b/src/app/qgsmaptoolpointsymbol.h @@ -29,7 +29,7 @@ class QgsMarkerSymbol; * snapping the mouse press to a feature, and detecting whether the clicked feature has symbology which is * compatible with the map tool. */ -class APP_EXPORT QgsMapToolPointSymbol: public QgsMapToolEdit +class APP_EXPORT QgsMapToolPointSymbol : public QgsMapToolEdit { Q_OBJECT @@ -52,7 +52,6 @@ class APP_EXPORT QgsMapToolPointSymbol: public QgsMapToolEdit virtual bool checkSymbolCompatibility( QgsMarkerSymbol *markerSymbol, QgsRenderContext &context ) = 0; virtual void noCompatibleSymbols() {} - }; #endif // QGSMAPTOOLPOINTSYMBOL_H diff --git a/src/app/qgsmaptoolreshape.cpp b/src/app/qgsmaptoolreshape.cpp index b621423299b3..3a67d3a77d4b 100644 --- a/src/app/qgsmaptoolreshape.cpp +++ b/src/app/qgsmaptoolreshape.cpp @@ -141,7 +141,7 @@ void QgsMapToolReshape::reshape( QgsVectorLayer *vlayer ) } else { - std::unique_ptr< QgsLineString > segmented( captureCurve()->curveToLine() ); + std::unique_ptr segmented( captureCurve()->curveToLine() ); segmented->points( pts ); } @@ -183,7 +183,7 @@ void QgsMapToolReshape::reshape( QgsVectorLayer *vlayer ) if ( vlayer->geometryType() == Qgis::GeometryType::Polygon ) { //ignore all current layer features as they should be reshaped too - QHash > ignoreFeatures; + QHash> ignoreFeatures; ignoreFeatures.insert( vlayer, vlayer->allFeatureIds() ); const QgsAvoidIntersectionsOperation::Result res = avoidIntersections.apply( vlayer, f.id(), geom, ignoreFeatures ); @@ -216,7 +216,7 @@ void QgsMapToolReshape::reshape( QgsVectorLayer *vlayer ) { const QList sm = snappingMatches(); Q_ASSERT( pts.size() == sm.size() ); - for ( int i = 0; i < sm.size() ; ++i ) + for ( int i = 0; i < sm.size(); ++i ) { if ( sm.at( i ).layer() ) { diff --git a/src/app/qgsmaptoolreshape.h b/src/app/qgsmaptoolreshape.h index 0110a51ea87d..9e2907bb2fe9 100644 --- a/src/app/qgsmaptoolreshape.h +++ b/src/app/qgsmaptoolreshape.h @@ -20,7 +20,7 @@ #include "qgis_app.h" //! A map tool that draws a line and splits the features cut by the line -class APP_EXPORT QgsMapToolReshape: public QgsMapToolCapture +class APP_EXPORT QgsMapToolReshape : public QgsMapToolCapture { Q_OBJECT diff --git a/src/app/qgsmaptoolreverseline.cpp b/src/app/qgsmaptoolreverseline.cpp index fdefaf5640a5..3b9e31b05c05 100644 --- a/src/app/qgsmaptoolreverseline.cpp +++ b/src/app/qgsmaptoolreverseline.cpp @@ -72,7 +72,6 @@ void QgsMapToolReverseLine::canvasPressEvent( QgsMapMouseEvent *e ) mRubberBand->setToGeometry( geomPart, vlayer ); mRubberBand->show(); } - } void QgsMapToolReverseLine::canvasReleaseEvent( QgsMapMouseEvent *e ) @@ -95,20 +94,17 @@ void QgsMapToolReverseLine::canvasReleaseEvent( QgsMapMouseEvent *e ) { if ( f.geometry().isMultipart() ) { - std::unique_ptr line_reversed( static_cast( f.geometry().constGet()->clone() ) ); + std::unique_ptr line_reversed( static_cast( f.geometry().constGet()->clone() ) ); std::unique_ptr line_part( line_reversed->curveN( mPressedPartNum )->clone() ); std::unique_ptr line_part_reversed( line_part->reversed() ); line_reversed->removeGeometry( mPressedPartNum ); line_reversed->insertGeometry( line_part_reversed.release(), mPressedPartNum ); geom = QgsGeometry( line_reversed.release() ); - } else { - - geom = QgsGeometry( static_cast< const QgsCurve * >( f.geometry().constGet() )->reversed() ); - + geom = QgsGeometry( static_cast( f.geometry().constGet() )->reversed() ); } if ( !geom.isNull() ) @@ -176,4 +172,3 @@ void QgsMapToolReverseLine::deactivate() { QgsMapTool::deactivate(); } - diff --git a/src/app/qgsmaptoolreverseline.h b/src/app/qgsmaptoolreverseline.h index afef6c986e4a..b5c74a66a22c 100644 --- a/src/app/qgsmaptoolreverseline.h +++ b/src/app/qgsmaptoolreverseline.h @@ -25,7 +25,7 @@ class QgsVertexMarker; //! Map tool to delete vertices from line/polygon features -class APP_EXPORT QgsMapToolReverseLine: public QgsMapToolEdit +class APP_EXPORT QgsMapToolReverseLine : public QgsMapToolEdit { Q_OBJECT @@ -48,7 +48,7 @@ class APP_EXPORT QgsMapToolReverseLine: public QgsMapToolEdit QgsGeometry partUnderPoint( QPoint p, QgsFeatureId &fid, int &partNum ); /* Rubberband that shows the part being reversed*/ - std::unique_ptrmRubberBand; + std::unique_ptr mRubberBand; //The feature and part where the mouse cursor was pressed //This is used to check whether we are still in the same part at cursor release diff --git a/src/app/qgsmaptoolrotatefeature.cpp b/src/app/qgsmaptoolrotatefeature.cpp index bac14e5c21a7..d7d7dbc8f310 100644 --- a/src/app/qgsmaptoolrotatefeature.cpp +++ b/src/app/qgsmaptoolrotatefeature.cpp @@ -79,7 +79,7 @@ QgsAngleMagnetWidget::QgsAngleMagnetWidget( const QString &label, QWidget *paren // connect signals mAngleSpinBox->installEventFilter( this ); - connect( mAngleSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsAngleMagnetWidget::angleSpinBoxValueChanged ); + connect( mAngleSpinBox, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsAngleMagnetWidget::angleSpinBoxValueChanged ); // config focus setFocusProxy( mAngleSpinBox ); @@ -144,7 +144,7 @@ void QgsAngleMagnetWidget::angleSpinBoxValueChanged( double angle ) QgsMapToolRotateFeature::QgsMapToolRotateFeature( QgsMapCanvas *canvas ) : QgsMapToolAdvancedDigitizing( canvas, QgisApp::instance()->cadDockWidget() ) - , mSnapIndicator( std::make_unique< QgsSnapIndicator>( canvas ) ) + , mSnapIndicator( std::make_unique( canvas ) ) { mToolName = tr( "Rotate feature" ); } @@ -243,8 +243,7 @@ void QgsMapToolRotateFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) const QgsPointXY layerCoords = toLayerCoordinates( vlayer, e->mapPoint() ); const double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->currentLayer(), mCanvas->mapSettings() ); - const QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, - layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); + const QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); mAutoSetAnchorPoint = false; if ( !mAnchorPoint ) @@ -316,7 +315,7 @@ void QgsMapToolRotateFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgsFeature feat; QgsFeatureIterator it = vlayer->getSelectedFeatures(); - QVector selectedGeometries; + QVector selectedGeometries; while ( it.nextFeature( feat ) ) { selectedGeometries << feat.geometry(); @@ -421,7 +420,7 @@ void QgsMapToolRotateFeature::applyRotation( double rotation ) connect( &avoidIntersections, &QgsAvoidIntersectionsOperation::messageEmitted, this, &QgsMapTool::messageEmitted ); // when removing intersections don't check for intersections with selected features - const QHash > ignoreFeatures {{vlayer, mRotatedFeatures}}; + const QHash> ignoreFeatures { { vlayer, mRotatedFeatures } }; while ( fi.nextFeature( f ) ) { @@ -435,9 +434,7 @@ void QgsMapToolRotateFeature::applyRotation( double rotation ) if ( res.operationResult == Qgis::GeometryOperationResult::InvalidInputGeometryType || geom.isEmpty() ) { - const QString errorMessage = ( geom.isEmpty() ) ? - tr( "The feature cannot be rotated because the resulting geometry would be empty" ) : - tr( "An error was reported during intersection removal" ); + const QString errorMessage = ( geom.isEmpty() ) ? tr( "The feature cannot be rotated because the resulting geometry would be empty" ) : tr( "An error was reported during intersection removal" ); emit messageEmitted( errorMessage, Qgis::MessageLevel::Warning ); vlayer->destroyEditCommand(); @@ -503,7 +500,7 @@ void QgsMapToolRotateFeature::deleteRubberband() { delete mRubberBand; mRubberBand = nullptr; - mGeom = QgsGeometry(); + mGeom = QgsGeometry(); } void QgsMapToolRotateFeature::deactivate() @@ -548,5 +545,3 @@ void QgsMapToolRotateFeature::deleteRotationWidget() } mRotationWidget = nullptr; } - - diff --git a/src/app/qgsmaptoolrotatefeature.h b/src/app/qgsmaptoolrotatefeature.h index c73953282215..1346a038addb 100644 --- a/src/app/qgsmaptoolrotatefeature.h +++ b/src/app/qgsmaptoolrotatefeature.h @@ -34,7 +34,6 @@ class APP_EXPORT QgsAngleMagnetWidget : public QWidget Q_OBJECT public: - explicit QgsAngleMagnetWidget( const QString &label = QString(), QWidget *parent = nullptr ); void setAngle( double angle ); @@ -42,7 +41,7 @@ class APP_EXPORT QgsAngleMagnetWidget : public QWidget void setMagnet( int magnet ); int magnet() const; - QgsDoubleSpinBox *editor() const {return mAngleSpinBox;} + QgsDoubleSpinBox *editor() const { return mAngleSpinBox; } signals: void angleChanged( double angle ); @@ -66,7 +65,7 @@ class APP_EXPORT QgsAngleMagnetWidget : public QWidget //! Map tool to rotate features -class APP_EXPORT QgsMapToolRotateFeature: public QgsMapToolAdvancedDigitizing +class APP_EXPORT QgsMapToolRotateFeature : public QgsMapToolAdvancedDigitizing { Q_OBJECT public: @@ -92,7 +91,6 @@ class APP_EXPORT QgsMapToolRotateFeature: public QgsMapToolAdvancedDigitizing void cancel(); private: - QgsGeometry rotateGeometry( QgsGeometry geom, QgsPointXY point, double angle ); QgsPointXY rotatePoint( QgsPointXY point, double angle ); void deleteRubberband(); diff --git a/src/app/qgsmaptoolrotatepointsymbols.cpp b/src/app/qgsmaptoolrotatepointsymbols.cpp index aa0ed3e2d175..28c09aecf2a1 100644 --- a/src/app/qgsmaptoolrotatepointsymbols.cpp +++ b/src/app/qgsmaptoolrotatepointsymbols.cpp @@ -133,7 +133,7 @@ void QgsMapToolRotatePointSymbols::canvasPressOnFeature( QgsMapMouseEvent *e, co mRotationItem->setPointLocation( snappedPoint ); } mCurrentMouseAzimut = calculateAzimut( e->pos() ); - setPixmapItemRotation( ( int )( mCurrentMouseAzimut ) ); + setPixmapItemRotation( ( int ) ( mCurrentMouseAzimut ) ); mRotating = true; } @@ -197,7 +197,7 @@ void QgsMapToolRotatePointSymbols::canvasMoveEvent( QgsMapMouseEvent *e ) } else { - displayValue = ( int )( mCurrentRotationFeature ); + displayValue = ( int ) ( mCurrentRotationFeature ); mCtrlPressed = false; } setPixmapItemRotation( displayValue ); @@ -236,7 +236,7 @@ void QgsMapToolRotatePointSymbols::createPixmapItem( QgsMarkerSymbol *markerSymb if ( markerSymbol ) { - const std::unique_ptr< QgsSymbol > clone( markerSymbol->clone() ); + const std::unique_ptr clone( markerSymbol->clone() ); QgsMarkerSymbol *markerClone = static_cast( clone.get() ); markerClone->setDataDefinedAngle( QgsProperty() ); pointImage = markerClone->bigSymbolPreviewImage( nullptr, Qgis::SymbolPreviewFlags() ); @@ -257,7 +257,6 @@ void QgsMapToolRotatePointSymbols::setPixmapItemRotation( double rotation ) int QgsMapToolRotatePointSymbols::roundTo15Degrees( double n ) { - const int m = ( int )( n / 15.0 + 0.5 ); + const int m = ( int ) ( n / 15.0 + 0.5 ); return ( m * 15 ); } - diff --git a/src/app/qgsmaptoolrotatepointsymbols.h b/src/app/qgsmaptoolrotatepointsymbols.h index 9335463a89ef..ad3c76f2be4f 100644 --- a/src/app/qgsmaptoolrotatepointsymbols.h +++ b/src/app/qgsmaptoolrotatepointsymbols.h @@ -29,7 +29,7 @@ class QgsMarkerSymbol; * \brief A class that allows interactive manipulation the value of the rotation field(s) for point layers. */ -class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolPointSymbol +class APP_EXPORT QgsMapToolRotatePointSymbols : public QgsMapToolPointSymbol { Q_OBJECT @@ -48,13 +48,11 @@ class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolPointSymbol static bool layerIsRotatable( QgsMapLayer *ml ); protected: - void canvasPressOnFeature( QgsMapMouseEvent *e, const QgsFeature &feature, const QgsPointXY &snappedPoint ) override; bool checkSymbolCompatibility( QgsMarkerSymbol *markerSymbol, QgsRenderContext &context ) override; void noCompatibleSymbols() override; private: - //! Last azimut between mouse and edited point double mCurrentMouseAzimut; //! Last feature rotation @@ -66,7 +64,7 @@ class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolPointSymbol //! True if ctrl was pressed during the last mouse move event bool mCtrlPressed; //! Clone of first found marker symbol for feature with rotation attribute set - std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol; + std::unique_ptr mMarkerSymbol; void drawArrow( double azimut ) const; //! Calculates the azimut between mousePos and mSnappedPoint @@ -77,7 +75,6 @@ class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolPointSymbol void setPixmapItemRotation( double rotation ); //! Rounds value to 15 degree integer (used if ctrl pressed) static int roundTo15Degrees( double n ); - }; #endif // QGSMAPTOOLROTATEPOINTSYMBOLS_H diff --git a/src/app/qgsmaptoolscalefeature.cpp b/src/app/qgsmaptoolscalefeature.cpp index a6596486ee07..db61ba04e1ef 100644 --- a/src/app/qgsmaptoolscalefeature.cpp +++ b/src/app/qgsmaptoolscalefeature.cpp @@ -65,7 +65,7 @@ QgsScaleMagnetWidget::QgsScaleMagnetWidget( const QString &label, QWidget *paren // connect signals mScaleSpinBox->installEventFilter( this ); - connect( mScaleSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsScaleMagnetWidget::scaleSpinBoxValueChanged ); + connect( mScaleSpinBox, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsScaleMagnetWidget::scaleSpinBoxValueChanged ); // config focus setFocusProxy( mScaleSpinBox ); @@ -112,7 +112,7 @@ void QgsScaleMagnetWidget::scaleSpinBoxValueChanged( double scale ) QgsMapToolScaleFeature::QgsMapToolScaleFeature( QgsMapCanvas *canvas ) : QgsMapToolAdvancedDigitizing( canvas, QgisApp::instance()->cadDockWidget() ) - , mSnapIndicator( std::make_unique< QgsSnapIndicator>( canvas ) ) + , mSnapIndicator( std::make_unique( canvas ) ) { mToolName = tr( "Scale feature" ); } @@ -204,8 +204,7 @@ void QgsMapToolScaleFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) const QgsPointXY layerCoords = toLayerCoordinates( vlayer, e->mapPoint() ); const double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->currentLayer(), mCanvas->mapSettings() ); - const QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, - layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); + const QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); mAutoSetAnchorPoint = false; if ( !mAnchorPoint ) @@ -259,7 +258,7 @@ void QgsMapToolScaleFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) } else { - mFeatureCenterMapCoords = mAnchorPoint->center(); + mFeatureCenterMapCoords = mAnchorPoint->center(); } mScaledFeatures.clear(); @@ -375,7 +374,7 @@ void QgsMapToolScaleFeature::applyScaling( double scale ) connect( &avoidIntersections, &QgsAvoidIntersectionsOperation::messageEmitted, this, &QgsMapTool::messageEmitted ); // when removing intersections don't check for intersections with selected features - const QHash > ignoreFeatures {{vlayer, mScaledFeatures}}; + const QHash> ignoreFeatures { { vlayer, mScaledFeatures } }; while ( fi.nextFeature( feat ) ) { @@ -394,9 +393,7 @@ void QgsMapToolScaleFeature::applyScaling( double scale ) if ( res.operationResult == Qgis::GeometryOperationResult::InvalidInputGeometryType || geom.isEmpty() ) { - const QString errorMessage = ( geom.isEmpty() ) ? - tr( "The feature cannot be scaled because the resulting geometry would be empty" ) : - tr( "An error was reported during intersection removal" ); + const QString errorMessage = ( geom.isEmpty() ) ? tr( "The feature cannot be scaled because the resulting geometry would be empty" ) : tr( "An error was reported during intersection removal" ); emit messageEmitted( errorMessage, Qgis::MessageLevel::Warning ); vlayer->destroyEditCommand(); @@ -505,4 +502,3 @@ void QgsMapToolScaleFeature::deleteScalingWidget() } mScalingWidget = nullptr; } - diff --git a/src/app/qgsmaptoolscalefeature.h b/src/app/qgsmaptoolscalefeature.h index 84a87bec3554..373a82433721 100644 --- a/src/app/qgsmaptoolscalefeature.h +++ b/src/app/qgsmaptoolscalefeature.h @@ -34,13 +34,12 @@ class APP_EXPORT QgsScaleMagnetWidget : public QWidget Q_OBJECT public: - explicit QgsScaleMagnetWidget( const QString &label = QString(), QWidget *parent = nullptr ); void setScale( double scale ); double scale() const; - QgsDoubleSpinBox *editor() const {return mScaleSpinBox;} + QgsDoubleSpinBox *editor() const { return mScaleSpinBox; } signals: void scaleChanged( double scale ); @@ -63,7 +62,7 @@ class APP_EXPORT QgsScaleMagnetWidget : public QWidget //! Map tool to scale features -class APP_EXPORT QgsMapToolScaleFeature: public QgsMapToolAdvancedDigitizing +class APP_EXPORT QgsMapToolScaleFeature : public QgsMapToolAdvancedDigitizing { Q_OBJECT public: @@ -89,7 +88,6 @@ class APP_EXPORT QgsMapToolScaleFeature: public QgsMapToolAdvancedDigitizing void cancel(); private: - QgsGeometry scaleGeometry( QgsGeometry geom, QgsPointXY point, double scale ); QgsPointXY scalePoint( QgsPointXY point, double scale ); void deleteRubberband(); @@ -103,7 +101,7 @@ class APP_EXPORT QgsMapToolScaleFeature: public QgsMapToolAdvancedDigitizing //! Id of scaled feature QgsFeatureIds mScaledFeatures; - QVector< QgsGeometry > mOriginalGeometries; + QVector mOriginalGeometries; //! Snapping indicators std::unique_ptr mSnapIndicator; diff --git a/src/app/qgsmaptoolselect.cpp b/src/app/qgsmaptoolselect.cpp index 0a8d371ce5c2..a849c82345c8 100644 --- a/src/app/qgsmaptoolselect.cpp +++ b/src/app/qgsmaptoolselect.cpp @@ -76,10 +76,7 @@ void QgsMapToolSelect::keyPressEvent( QKeyEvent *e ) case Qt::Key_Alt: case Qt::Key_Meta: //note -- if ctrl and shift are already depressed, pressing alt reports the "meta" key eventZ - modifiersChanged( e->modifiers() & Qt::ControlModifier || e->key() == Qt::Key_Control, - e->modifiers() & Qt::ShiftModifier || e->key() == Qt::Key_Shift, - e->modifiers() & Qt::AltModifier || e->key() == Qt::Key_Alt || - ( e->modifiers() & Qt::ControlModifier && e->modifiers() & Qt::ShiftModifier && e->key() == Qt::Key_Meta ) ); + modifiersChanged( e->modifiers() & Qt::ControlModifier || e->key() == Qt::Key_Control, e->modifiers() & Qt::ShiftModifier || e->key() == Qt::Key_Shift, e->modifiers() & Qt::AltModifier || e->key() == Qt::Key_Alt || ( e->modifiers() & Qt::ControlModifier && e->modifiers() & Qt::ShiftModifier && e->key() == Qt::Key_Meta ) ); break; default: @@ -103,10 +100,7 @@ void QgsMapToolSelect::keyReleaseEvent( QKeyEvent *e ) case Qt::Key_Control: case Qt::Key_Alt: case Qt::Key_Meta: - modifiersChanged( e->modifiers() & Qt::ControlModifier && e->key() != Qt::Key_Control, - e->modifiers() & Qt::ShiftModifier && e->key() != Qt::Key_Shift, - e->modifiers() & Qt::AltModifier && e->key() != Qt::Key_Alt && - !( e->modifiers() & Qt::ControlModifier && e->modifiers() & Qt::ShiftModifier && e->key() == Qt::Key_Meta ) ); + modifiersChanged( e->modifiers() & Qt::ControlModifier && e->key() != Qt::Key_Control, e->modifiers() & Qt::ShiftModifier && e->key() != Qt::Key_Shift, e->modifiers() & Qt::AltModifier && e->key() != Qt::Key_Alt && !( e->modifiers() & Qt::ControlModifier && e->modifiers() & Qt::ShiftModifier && e->key() == Qt::Key_Meta ) ); break; default: @@ -145,10 +139,10 @@ bool QgsMapToolSelect::populateContextMenuWithEvent( QMenu *menu, QgsMapMouseEve Q_ASSERT( menu ); QgsMapLayer *layer = QgsMapToolSelectUtils::getCurrentTargetLayer( mCanvas ); - if ( !layer || layer->type() != Qgis::LayerType::Vector ) + if ( !layer || layer->type() != Qgis::LayerType::Vector ) return false; - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer ); + QgsVectorLayer *vlayer = qobject_cast( layer ); if ( !vlayer->isSpatial() ) return false; @@ -183,8 +177,7 @@ bool QgsMapToolSelect::populateContextMenuWithEvent( QMenu *menu, QgsMapMouseEve void QgsMapToolSelect::selectFeatures( Qt::KeyboardModifiers modifiers ) { - if ( mSelectionHandler->selectionMode() == QgsMapToolSelectionHandler::SelectSimple && - mSelectionHandler->selectedGeometry().type() == Qgis::GeometryType::Point ) + if ( mSelectionHandler->selectionMode() == QgsMapToolSelectionHandler::SelectSimple && mSelectionHandler->selectedGeometry().type() == Qgis::GeometryType::Point ) { QgsMapLayer *layer = QgsMapToolSelectUtils::getCurrentTargetLayer( mCanvas ); const QgsRectangle r = QgsMapToolSelectUtils::expandSelectRectangle( mSelectionHandler->selectedGeometry().asPoint(), mCanvas, layer ); diff --git a/src/app/qgsmaptoolselect.h b/src/app/qgsmaptoolselect.h index 57913ae2da67..88003bc94533 100644 --- a/src/app/qgsmaptoolselect.h +++ b/src/app/qgsmaptoolselect.h @@ -29,7 +29,6 @@ class APP_EXPORT QgsMapToolSelect : public QgsMapTool { Q_OBJECT public: - enum Mode { GeometryIntersectsSetSelection, diff --git a/src/app/qgsmaptoolselectionhandler.cpp b/src/app/qgsmaptoolselectionhandler.cpp index eb9668676e16..75dff2d699a2 100644 --- a/src/app/qgsmaptoolselectionhandler.cpp +++ b/src/app/qgsmaptoolselectionhandler.cpp @@ -57,7 +57,7 @@ QgsDistanceWidget::QgsDistanceWidget( const QString &label, QWidget *parent ) // connect signals mDistanceSpinBox->installEventFilter( this ); - connect( mDistanceSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsDistanceWidget::distanceChanged ); + connect( mDistanceSpinBox, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsDistanceWidget::distanceChanged ); // config focus setFocusProxy( mDistanceSpinBox ); @@ -97,11 +97,10 @@ bool QgsDistanceWidget::eventFilter( QObject *obj, QEvent *ev ) /// @endcond - QgsMapToolSelectionHandler::QgsMapToolSelectionHandler( QgsMapCanvas *canvas, QgsMapToolSelectionHandler::SelectionMode selectionMode ) : mCanvas( canvas ) , mSelectionMode( selectionMode ) - , mSnapIndicator( std::make_unique< QgsSnapIndicator >( canvas ) ) + , mSnapIndicator( std::make_unique( canvas ) ) , mIdentifyMenu( new QgsIdentifyMenu( mCanvas ) ) { mIdentifyMenu->setAllowMultipleReturn( false ); @@ -196,7 +195,6 @@ void QgsMapToolSelectionHandler::selectFeaturesPressEvent( QgsMapMouseEvent *e ) void QgsMapToolSelectionHandler::selectFeaturesMoveEvent( QgsMapMouseEvent *e ) { - if ( mSelectionMode == QgsMapToolSelectionHandler::SelectOnMouseOver && mCanvas->underMouse() ) { mMoveLastCursorPos = e->pos(); @@ -204,14 +202,13 @@ void QgsMapToolSelectionHandler::selectFeaturesMoveEvent( QgsMapMouseEvent *e ) // I tried all possible NOLINT placements without success, this // ugly ifdef seems to do the trick with silencing the warning. #ifndef __clang_analyzer__ - if ( ! mOnMouseMoveDelayTimer || ! mOnMouseMoveDelayTimer->isActive() ) + if ( !mOnMouseMoveDelayTimer || !mOnMouseMoveDelayTimer->isActive() ) { setSelectedGeometry( QgsGeometry::fromPointXY( toMapCoordinates( e->pos() ) ), e->modifiers() ); - mOnMouseMoveDelayTimer = std::make_unique( ); + mOnMouseMoveDelayTimer = std::make_unique(); mOnMouseMoveDelayTimer->setSingleShot( true ); - connect( mOnMouseMoveDelayTimer.get(), &QTimer::timeout, this, [ = ] - { - if ( ! mMoveLastCursorPos.isNull() ) + connect( mOnMouseMoveDelayTimer.get(), &QTimer::timeout, this, [=] { + if ( !mMoveLastCursorPos.isNull() ) { setSelectedGeometry( QgsGeometry::fromPointXY( toMapCoordinates( mMoveLastCursorPos ) ), e->modifiers() ); } @@ -468,8 +465,7 @@ void QgsMapToolSelectionHandler::updateRadiusRubberband( double radius ) for ( int i = 0; i <= RADIUS_SEGMENTS; ++i ) { const double theta = i * ( 2.0 * M_PI / RADIUS_SEGMENTS ); - const QgsPointXY radiusPoint( mRadiusCenter.x() + radius * std::cos( theta ), - mRadiusCenter.y() + radius * std::sin( theta ) ); + const QgsPointXY radiusPoint( mRadiusCenter.x() + radius * std::cos( theta ), mRadiusCenter.y() + radius * std::sin( theta ) ); mSelectionRubberBand->addPoint( radiusPoint, false ); } mSelectionRubberBand->closePoints( true ); diff --git a/src/app/qgsmaptoolselectionhandler.h b/src/app/qgsmaptoolselectionhandler.h index e8a6c472321c..95fff93a337b 100644 --- a/src/app/qgsmaptoolselectionhandler.h +++ b/src/app/qgsmaptoolselectionhandler.h @@ -46,7 +46,6 @@ class QgsDistanceWidget : public QWidget Q_OBJECT public: - //! Constrructor explicit QgsDistanceWidget( const QString &label = QString(), QWidget *parent = nullptr ); @@ -84,7 +83,6 @@ class QgsMapToolSelectionHandler : public QObject Q_OBJECT public: - //! Select features to identify by: enum SelectionMode { @@ -106,8 +104,7 @@ class QgsMapToolSelectionHandler : public QObject Q_ENUM( SelectionMode ) //! constructor - QgsMapToolSelectionHandler( QgsMapCanvas *canvas, - QgsMapToolSelectionHandler::SelectionMode selectionMode = QgsMapToolSelectionHandler::SelectionMode::SelectSimple ); + QgsMapToolSelectionHandler( QgsMapCanvas *canvas, QgsMapToolSelectionHandler::SelectionMode selectionMode = QgsMapToolSelectionHandler::SelectionMode::SelectSimple ); //! destructor ~QgsMapToolSelectionHandler() override; @@ -152,7 +149,6 @@ class QgsMapToolSelectionHandler : public QObject void cancel(); private: - void selectFeaturesMoveEvent( QgsMapMouseEvent *e ); void selectFeaturesReleaseEvent( QgsMapMouseEvent *e ); void selectFeaturesPressEvent( QgsMapMouseEvent *e ); @@ -176,7 +172,6 @@ class QgsMapToolSelectionHandler : public QObject void updateRadiusFromEdge( QgsPointXY &radiusEdge ); private: - QgsMapCanvas *mCanvas = nullptr; //! the rubberband for selection visualization diff --git a/src/app/qgsmaptoolselectutils.cpp b/src/app/qgsmaptoolselectutils.cpp index 261d69f39404..0ce04f96d9e8 100644 --- a/src/app/qgsmaptoolselectutils.cpp +++ b/src/app/qgsmaptoolselectutils.cpp @@ -71,7 +71,8 @@ QgsMapLayer *QgsMapToolSelectUtils::getCurrentTargetLayer( QgsMapCanvas *canvas QgisApp::instance()->messageBar()->pushMessage( QObject::tr( "No active vector layer" ), QObject::tr( "To select features, choose a vector layer in the layers panel" ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); } return layer; } @@ -107,7 +108,7 @@ QgsRectangle QgsMapToolSelectUtils::expandSelectRectangle( QgsPointXY mapPoint, { case Qgis::LayerType::Vector: { - QgsVectorLayer *vLayer = qobject_cast< QgsVectorLayer * >( layer ); + QgsVectorLayer *vLayer = qobject_cast( layer ); if ( vLayer->geometryType() != Qgis::GeometryType::Polygon ) { //if point or line use an artificial bounding box of 10x10 pixels @@ -176,7 +177,7 @@ bool transformSelectGeometry( const QgsGeometry &selectGeometry, QgsGeometry &se newpoly[0].resize( 41 ); QgsPolylineXY &ringOut = newpoly[0]; - ringOut[ 0 ] = ringIn.at( 0 ); + ringOut[0] = ringIn.at( 0 ); int i = 1; for ( int j = 1; j < 5; j++ ) @@ -184,10 +185,10 @@ bool transformSelectGeometry( const QgsGeometry &selectGeometry, QgsGeometry &se QgsVector v( ( ringIn.at( j ) - ringIn.at( j - 1 ) ) / 10.0 ); for ( int k = 0; k < 9; k++ ) { - ringOut[ i ] = ringOut[ i - 1 ] + v; + ringOut[i] = ringOut[i - 1] + v; i++; } - ringOut[ i++ ] = ringIn.at( j ); + ringOut[i++] = ringIn.at( j ); } selectGeomTrans = QgsGeometry::fromPolygonXY( newpoly ); } @@ -204,7 +205,8 @@ bool transformSelectGeometry( const QgsGeometry &selectGeometry, QgsGeometry &se QgisApp::instance()->messageBar()->pushMessage( QObject::tr( "CRS Exception" ), QObject::tr( "Selection extends beyond layer's coordinate system" ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); return false; } } @@ -224,7 +226,7 @@ void QgsMapToolSelectUtils::selectSingleFeature( QgsMapCanvas *canvas, const Qgs { case Qgis::LayerType::Vector: { - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer *>( layer ); + QgsVectorLayer *vlayer = qobject_cast( layer ); QgsFeatureIds selectedFeatures = getMatchingFeatures( canvas, selectGeometry, false, true ); if ( selectedFeatures.isEmpty() ) { @@ -257,7 +259,7 @@ void QgsMapToolSelectUtils::selectSingleFeature( QgsMapCanvas *canvas, const Qgs case Qgis::LayerType::VectorTile: { - QgsVectorTileLayer *vtLayer = qobject_cast< QgsVectorTileLayer *>( layer ); + QgsVectorTileLayer *vtLayer = qobject_cast( layer ); QgsCoordinateTransform ct( canvas->mapSettings().destinationCrs(), layer->crs(), QgsProject::instance() ); QgsGeometry selectGeomTrans; @@ -292,8 +294,7 @@ void QgsMapToolSelectUtils::selectSingleFeature( QgsMapCanvas *canvas, const Qgs QApplication::restoreOverrideCursor(); } -void QgsMapToolSelectUtils::setSelectedFeatures( QgsMapCanvas *canvas, const QgsGeometry &selectGeometry, - Qgis::SelectBehavior selectBehavior, bool doContains, bool singleSelect ) +void QgsMapToolSelectUtils::setSelectedFeatures( QgsMapCanvas *canvas, const QgsGeometry &selectGeometry, Qgis::SelectBehavior selectBehavior, bool doContains, bool singleSelect ) { QgsMapLayer *layer = QgsMapToolSelectUtils::getCurrentTargetLayer( canvas ); if ( !layer ) @@ -308,7 +309,7 @@ void QgsMapToolSelectUtils::setSelectedFeatures( QgsMapCanvas *canvas, const Qgs { case Qgis::LayerType::Vector: { - QgsVectorLayer *vLayer = qobject_cast< QgsVectorLayer * >( layer ); + QgsVectorLayer *vLayer = qobject_cast( layer ); QgsFeatureIds selectedFeatures = getMatchingFeatures( canvas, selectGeometry, doContains, singleSelect ); vLayer->selectByIds( selectedFeatures, selectBehavior ); break; @@ -316,7 +317,7 @@ void QgsMapToolSelectUtils::setSelectedFeatures( QgsMapCanvas *canvas, const Qgs case Qgis::LayerType::VectorTile: { - QgsVectorTileLayer *vtLayer = qobject_cast< QgsVectorTileLayer * >( layer ); + QgsVectorTileLayer *vtLayer = qobject_cast( layer ); QgsCoordinateTransform ct( canvas->mapSettings().destinationCrs(), layer->crs(), QgsProject::instance() ); QgsGeometry selectGeomTrans; if ( !transformSelectGeometry( selectGeometry, selectGeomTrans, ct ) ) @@ -354,7 +355,7 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas, return newSelectedFeatures; QgsMapLayer *targetLayer = QgsMapToolSelectUtils::getCurrentTargetLayer( canvas ); - QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( targetLayer ); + QgsVectorLayer *vlayer = qobject_cast( targetLayer ); if ( !vlayer ) return newSelectedFeatures; @@ -372,7 +373,7 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas, QgsDebugMsgLevel( "doContains: " + QString( doContains ? QStringLiteral( "T" ) : QStringLiteral( "F" ) ), 3 ); // make sure the selection geometry is valid, or intersection tests won't work correctly... - if ( !selectGeomTrans.isGeosValid( ) ) + if ( !selectGeomTrans.isGeosValid() ) { // a zero width buffer is safer than calling make valid here! selectGeomTrans = selectGeomTrans.buffer( 0, 1 ); @@ -380,7 +381,7 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas, return newSelectedFeatures; } - std::unique_ptr< QgsGeometryEngine > selectionGeometryEngine( QgsGeometry::createGeometryEngine( selectGeomTrans.constGet() ) ); + std::unique_ptr selectionGeometryEngine( QgsGeometry::createGeometryEngine( selectGeomTrans.constGet() ) ); selectionGeometryEngine->setLogErrors( false ); selectionGeometryEngine->prepareGeometry(); @@ -390,7 +391,7 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas, expressionContext << QgsExpressionContextUtils::layerScope( vlayer ); context.setExpressionContext( expressionContext ); - std::unique_ptr< QgsFeatureRenderer > r; + std::unique_ptr r; if ( vlayer->renderer() ) { r.reset( vlayer->renderer()->clone() ); @@ -441,9 +442,8 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas, // if we get an error from the contains check then it indicates that the geometry is invalid and GEOS choked on it. // in this case we consider the bounding box intersection check which has already been performed by the iterator as sufficient and // allow the feature to be selected - const bool notContained = !selectionGeometryEngine->contains( g.constGet(), &errorMessage ) && - ( errorMessage.isEmpty() || /* message will be non empty if geometry g is invalid */ - !selectionGeometryEngine->contains( g.makeValid().constGet(), &errorMessage ) ); /* second chance for invalid geometries, repair and re-test */ + const bool notContained = !selectionGeometryEngine->contains( g.constGet(), &errorMessage ) && ( errorMessage.isEmpty() || /* message will be non empty if geometry g is invalid */ + !selectionGeometryEngine->contains( g.makeValid().constGet(), &errorMessage ) ); /* second chance for invalid geometries, repair and re-test */ if ( !errorMessage.isEmpty() ) { @@ -459,9 +459,8 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas, // if we get an error from the intersects check then it indicates that the geometry is invalid and GEOS choked on it. // in this case we consider the bounding box intersection check which has already been performed by the iterator as sufficient and // allow the feature to be selected - const bool notIntersects = !selectionGeometryEngine->intersects( g.constGet(), &errorMessage ) && - ( errorMessage.isEmpty() || /* message will be non empty if geometry g is invalid */ - !selectionGeometryEngine->intersects( g.makeValid().constGet(), &errorMessage ) ); /* second chance for invalid geometries, repair and re-test */ + const bool notIntersects = !selectionGeometryEngine->intersects( g.constGet(), &errorMessage ) && ( errorMessage.isEmpty() || /* message will be non empty if geometry g is invalid */ + !selectionGeometryEngine->intersects( g.makeValid().constGet(), &errorMessage ) ); /* second chance for invalid geometries, repair and re-test */ if ( !errorMessage.isEmpty() ) { @@ -501,10 +500,7 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas, } -QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::QgsMapToolSelectMenuActions( QgsMapCanvas *canvas, - QgsVectorLayer *vectorLayer, - Qgis::SelectBehavior behavior, const QgsGeometry &selectionGeometry, - QObject *parent ) +QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::QgsMapToolSelectMenuActions( QgsMapCanvas *canvas, QgsVectorLayer *vectorLayer, Qgis::SelectBehavior behavior, const QgsGeometry &selectionGeometry, QObject *parent ) : QObject( parent ) , mCanvas( canvas ) , mVectorLayer( vectorLayer ) @@ -571,17 +567,17 @@ QgsFeatureIds QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::search( std::s QgsGeometry selectGeomTrans = data->selectGeometry; - if ( ! transformSelectGeometry( data->selectGeometry, selectGeomTrans, data->ct ) ) + if ( !transformSelectGeometry( data->selectGeometry, selectGeomTrans, data->ct ) ) return newSelectedFeatures; // make sure the selection geometry is valid, or intersection tests won't work correctly... - if ( !selectGeomTrans.isGeosValid( ) ) + if ( !selectGeomTrans.isGeosValid() ) { // a zero width buffer is safer than calling make valid here! selectGeomTrans = selectGeomTrans.buffer( 0, 1 ); } - std::unique_ptr< QgsGeometryEngine > selectionGeometryEngine( QgsGeometry::createGeometryEngine( selectGeomTrans.constGet() ) ); + std::unique_ptr selectionGeometryEngine( QgsGeometry::createGeometryEngine( selectGeomTrans.constGet() ) ); selectionGeometryEngine->setLogErrors( false ); selectionGeometryEngine->prepareGeometry(); @@ -627,9 +623,8 @@ QgsFeatureIds QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::search( std::s // if we get an error from the intersects check then it indicates that the geometry is invalid and GEOS choked on it. // in this case we consider the bounding box intersection check which has already been performed by the iterator as sufficient and // allow the feature to be selected - const bool notIntersects = !selectionGeometryEngine->intersects( g.constGet(), &errorMessage ) && - ( errorMessage.isEmpty() || /* message will be non empty if geometry g is invalid */ - !selectionGeometryEngine->intersects( g.makeValid().constGet(), &errorMessage ) ); /* second chance for invalid geometries, repair and re-test */ + const bool notIntersects = !selectionGeometryEngine->intersects( g.constGet(), &errorMessage ) && ( errorMessage.isEmpty() || /* message will be non empty if geometry g is invalid */ + !selectionGeometryEngine->intersects( g.makeValid().constGet(), &errorMessage ) ); /* second chance for invalid geometries, repair and re-test */ if ( !errorMessage.isEmpty() ) { @@ -750,9 +745,9 @@ void QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::populateChooseOneMenu( if ( featureTitle.isEmpty() ) featureTitle = tr( "Feature %1" ).arg( FID_TO_STRING( feat.id() ) ); - QAction *featureAction = new QAction( featureTitle, this ) ; - connect( featureAction, &QAction::triggered, this, [this, id]() {chooseOneCandidateFeature( id );} ); - connect( featureAction, &QAction::hovered, this, [this, id]() {this->highlightOneFeature( id );} ); + QAction *featureAction = new QAction( featureTitle, this ); + connect( featureAction, &QAction::triggered, this, [this, id]() { chooseOneCandidateFeature( id ); } ); + connect( featureAction, &QAction::hovered, this, [this, id]() { this->highlightOneFeature( id ); } ); mMenuChooseOne->addAction( featureAction ); } @@ -771,7 +766,7 @@ void QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::chooseOneCandidateFeatu void QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::chooseAllCandidateFeature() { - if ( ! mFutureWatcher ) + if ( !mFutureWatcher ) return; if ( !mFutureWatcher->isFinished() ) @@ -830,9 +825,7 @@ void QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::highlightOneFeature( Qg } } -QgsFeatureIds QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::filterIds( const QgsFeatureIds &ids, - const QgsFeatureIds &existingSelection, - Qgis::SelectBehavior behavior ) +QgsFeatureIds QgsMapToolSelectUtils::QgsMapToolSelectMenuActions::filterIds( const QgsFeatureIds &ids, const QgsFeatureIds &existingSelection, Qgis::SelectBehavior behavior ) { QgsFeatureIds effectiveFeatureIds = ids; switch ( behavior ) diff --git a/src/app/qgsmaptoolselectutils.h b/src/app/qgsmaptoolselectutils.h index 910a6b9af0f3..9760b984bd7c 100644 --- a/src/app/qgsmaptoolselectutils.h +++ b/src/app/qgsmaptoolselectutils.h @@ -64,11 +64,7 @@ namespace QgsMapToolSelectUtils * the selection rubber band (otherwise intersection is enough). * \param singleSelect only selects the closest feature to the selectGeometry. */ - void setSelectedFeatures( QgsMapCanvas *canvas, - const QgsGeometry &selectGeometry, - Qgis::SelectBehavior selectBehavior = Qgis::SelectBehavior::SetSelection, - bool doContains = true, - bool singleSelect = false ); + void setSelectedFeatures( QgsMapCanvas *canvas, const QgsGeometry &selectGeometry, Qgis::SelectBehavior selectBehavior = Qgis::SelectBehavior::SetSelection, bool doContains = true, bool singleSelect = false ); /** * Selects multiple matching features from within currently selected layer. @@ -125,7 +121,6 @@ namespace QgsMapToolSelectUtils { Q_OBJECT public: - /** * Constructor * \param canvas The map canvas where where are the selected features @@ -134,11 +129,7 @@ namespace QgsMapToolSelectUtils * \param selectionGeometry the geometry used to select the feature * \param parent a QObject that owns the instance ot this class */ - QgsMapToolSelectMenuActions( QgsMapCanvas *canvas, - QgsVectorLayer *vectorLayer, - Qgis::SelectBehavior behavior, - const QgsGeometry &selectionGeometry, - QObject *parent = nullptr ); + QgsMapToolSelectMenuActions( QgsMapCanvas *canvas, QgsVectorLayer *vectorLayer, Qgis::SelectBehavior behavior, const QgsGeometry &selectionGeometry, QObject *parent = nullptr ); ~QgsMapToolSelectMenuActions(); @@ -172,21 +163,19 @@ namespace QgsMapToolSelectUtils QString textForChooseOneMenu() const; void populateChooseOneMenu( const QgsFeatureIds &ids ); - static QgsFeatureIds filterIds( const QgsFeatureIds &ids, - const QgsFeatureIds &existingSelection, - Qgis::SelectBehavior behavior ); + static QgsFeatureIds filterIds( const QgsFeatureIds &ids, const QgsFeatureIds &existingSelection, Qgis::SelectBehavior behavior ); struct DataForSearchingJob { - bool isCanceled; - std::unique_ptr source; - QgsGeometry selectGeometry; - QgsCoordinateTransform ct; - QgsRenderContext context; - std::unique_ptr featureRenderer; - QString filterString; - Qgis::SelectBehavior selectBehavior; - QgsFeatureIds existingSelection; + bool isCanceled; + std::unique_ptr source; + QgsGeometry selectGeometry; + QgsCoordinateTransform ct; + QgsRenderContext context; + std::unique_ptr featureRenderer; + QString filterString; + Qgis::SelectBehavior selectBehavior; + QgsFeatureIds existingSelection; }; std::shared_ptr mJobData; @@ -196,6 +185,6 @@ namespace QgsMapToolSelectUtils void chooseOneCandidateFeature( QgsFeatureId id ); void highlightOneFeature( QgsFeatureId id ); }; -} +} // namespace QgsMapToolSelectUtils #endif diff --git a/src/app/qgsmaptoolsimplify.cpp b/src/app/qgsmaptoolsimplify.cpp index 32c556c83587..ae66c725c4ca 100644 --- a/src/app/qgsmaptoolsimplify.cpp +++ b/src/app/qgsmaptoolsimplify.cpp @@ -56,19 +56,18 @@ QgsSimplifyUserInputWidget::QgsSimplifyUserInputWidget( QWidget *parent ) mOptionsStackedWidget->setCurrentIndex( 1 ); // communication with map tool - connect( mToleranceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimplifyUserInputWidget::toleranceChanged ); - connect( mToleranceUnitsComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [ = ]( int ) {emit toleranceUnitsChanged( mToleranceUnitsComboBox->currentData().value() );} ); - connect( mMethodComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [ = ]( const int method ) {emit methodChanged( ( QgsMapToolSimplify::Method )method );} ); - connect( mMethodComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [ = ] - { + connect( mToleranceSpinBox, static_cast( &QDoubleSpinBox::valueChanged ), this, &QgsSimplifyUserInputWidget::toleranceChanged ); + connect( mToleranceUnitsComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=]( int ) { emit toleranceUnitsChanged( mToleranceUnitsComboBox->currentData().value() ); } ); + connect( mMethodComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=]( const int method ) { emit methodChanged( ( QgsMapToolSimplify::Method ) method ); } ); + connect( mMethodComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=] { if ( mMethodComboBox->currentData().toInt() != QgsMapToolSimplify::Smooth ) mOptionsStackedWidget->setCurrentIndex( 0 ); else mOptionsStackedWidget->setCurrentIndex( 1 ); } ); - connect( mOffsetSpin, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, [ = ]( const int offset ) {emit smoothOffsetChanged( offset / 100.0 );} ); - connect( mIterationsSpin, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsSimplifyUserInputWidget::smoothIterationsChanged ); + connect( mOffsetSpin, static_cast( &QSpinBox::valueChanged ), this, [=]( const int offset ) { emit smoothOffsetChanged( offset / 100.0 ); } ); + connect( mIterationsSpin, static_cast( &QSpinBox::valueChanged ), this, &QgsSimplifyUserInputWidget::smoothIterationsChanged ); connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsSimplifyUserInputWidget::accepted ); connect( mButtonBox, &QDialogButtonBox::rejected, this, &QgsSimplifyUserInputWidget::rejected ); @@ -80,11 +79,7 @@ QgsSimplifyUserInputWidget::QgsSimplifyUserInputWidget( QWidget *parent ) setFocusProxy( mButtonBox ); } -void QgsSimplifyUserInputWidget::setConfig( QgsMapToolSimplify::Method method, - double tolerance, - Qgis::MapToolUnit units, - double smoothOffset, - int smoothIterations ) +void QgsSimplifyUserInputWidget::setConfig( QgsMapToolSimplify::Method method, double tolerance, Qgis::MapToolUnit units, double smoothOffset, int smoothIterations ) { mMethodComboBox->setCurrentIndex( mMethodComboBox->findData( method ) ); @@ -143,8 +138,8 @@ QgsMapToolSimplify::QgsMapToolSimplify( QgsMapCanvas *canvas ) { const QgsSettings settings; mTolerance = settings.value( QStringLiteral( "digitizing/simplify_tolerance" ), 1 ).toDouble(); - mToleranceUnits = static_cast< Qgis::MapToolUnit >( settings.value( QStringLiteral( "digitizing/simplify_tolerance_units" ), 0 ).toInt() ); - mMethod = static_cast< QgsMapToolSimplify::Method >( settings.value( QStringLiteral( "digitizing/simplify_method" ), 0 ).toInt() ); + mToleranceUnits = static_cast( settings.value( QStringLiteral( "digitizing/simplify_tolerance_units" ), 0 ).toInt() ); + mMethod = static_cast( settings.value( QStringLiteral( "digitizing/simplify_method" ), 0 ).toInt() ); mSmoothIterations = settings.value( QStringLiteral( "digitizing/smooth_iterations" ), 1 ).toInt(); mSmoothOffset = settings.value( QStringLiteral( "digitizing/smooth_offset" ), 0.25 ).toDouble(); } @@ -209,7 +204,7 @@ void QgsMapToolSimplify::updateSimplificationPreview() void QgsMapToolSimplify::createUserInputWidget() { - mSimplifyUserWidget = new QgsSimplifyUserInputWidget( ); + mSimplifyUserWidget = new QgsSimplifyUserInputWidget(); mSimplifyUserWidget->setConfig( method(), tolerance(), toleranceUnits(), smoothOffset(), smoothIterations() ); connect( mSimplifyUserWidget, &QgsSimplifyUserInputWidget::methodChanged, this, &QgsMapToolSimplify::setMethod ); @@ -234,14 +229,12 @@ QgsGeometry QgsMapToolSimplify::processGeometry( const QgsGeometry &geometry, do case SimplifySnapToGrid: case SimplifyVisvalingam: { - const QgsMapToPixelSimplifier simplifier( QgsMapToPixelSimplifier::SimplifyGeometry, tolerance, mMethod == SimplifySnapToGrid ? Qgis::VectorSimplificationAlgorithm::SnapToGrid : Qgis::VectorSimplificationAlgorithm::Visvalingam ); return simplifier.simplify( geometry ); } case Smooth: return geometry.smooth( mSmoothIterations, mSmoothOffset ); - } return QgsGeometry(); //no warnings } @@ -426,8 +419,7 @@ void QgsMapToolSimplify::selectOneFeature( QPoint canvasPoint ) QgsVectorLayer *vlayer = currentVectorLayer(); const QgsPointXY layerCoords = toLayerCoordinates( vlayer, canvasPoint ); const double r = QgsTolerance::vertexSearchRadius( vlayer, mCanvas->mapSettings() ); - const QgsRectangle selectRect = QgsRectangle( layerCoords.x() - r, layerCoords.y() - r, - layerCoords.x() + r, layerCoords.y() + r ); + const QgsRectangle selectRect = QgsRectangle( layerCoords.x() - r, layerCoords.y() - r, layerCoords.x() + r, layerCoords.y() + r ); QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setNoAttributes() ); const QgsGeometry geometry = QgsGeometry::fromPointXY( layerCoords ); @@ -491,7 +483,10 @@ QString QgsMapToolSimplify::statusText() const { const int percent = mOriginalVertexCount ? ( 100 * mReducedVertexCount / mOriginalVertexCount ) : 0; QString txt = tr( "%1 feature(s): %2 to %3 vertices (%4%)" ) - .arg( mSelectedFeatures.count() ).arg( mOriginalVertexCount ).arg( mReducedVertexCount ).arg( percent ); + .arg( mSelectedFeatures.count() ) + .arg( mOriginalVertexCount ) + .arg( mReducedVertexCount ) + .arg( percent ); if ( mReducedHasErrors ) txt += '\n' + tr( "Simplification failed!" ); return txt; diff --git a/src/app/qgsmaptoolsimplify.h b/src/app/qgsmaptoolsimplify.h index 873f46886bff..f3e898115095 100644 --- a/src/app/qgsmaptoolsimplify.h +++ b/src/app/qgsmaptoolsimplify.h @@ -32,15 +32,14 @@ class QgsSimplifyUserInputWidget; //! Map tool to simplify line/polygon features -class APP_EXPORT QgsMapToolSimplify: public QgsMapToolEdit +class APP_EXPORT QgsMapToolSimplify : public QgsMapToolEdit { Q_OBJECT public: - enum Method { - SimplifyDistance = 0, - SimplifySnapToGrid = 1, + SimplifyDistance = 0, + SimplifySnapToGrid = 1, SimplifyVisvalingam = 2, Smooth = 3 }; @@ -84,7 +83,6 @@ class APP_EXPORT QgsMapToolSimplify: public QgsMapToolEdit void setMethod( QgsMapToolSimplify::Method method ); private: - void selectOneFeature( QPoint canvasPoint ); void selectFeaturesInRect(); @@ -135,15 +133,12 @@ class APP_EXPORT QgsSimplifyUserInputWidget : public QWidget, private Ui::Simpli Q_OBJECT public: - QgsSimplifyUserInputWidget( QWidget *parent = nullptr ); void updateStatusText( const QString &text ); void enableOkButton( bool enabled ); - void setConfig( QgsMapToolSimplify::Method method, double tolerance, - Qgis::MapToolUnit units, double smoothOffset, - int smoothIterations ); + void setConfig( QgsMapToolSimplify::Method method, double tolerance, Qgis::MapToolUnit units, double smoothOffset, int smoothIterations ); signals: void accepted(); diff --git a/src/app/qgsmaptoolsplitfeatures.cpp b/src/app/qgsmaptoolsplitfeatures.cpp index d1a0615a7566..ef3d3bc56708 100644 --- a/src/app/qgsmaptoolsplitfeatures.cpp +++ b/src/app/qgsmaptoolsplitfeatures.cpp @@ -89,7 +89,8 @@ void QgsMapToolSplitFeatures::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgisApp::instance()->messageBar()->pushMessage( tr( "Coordinate transform error" ), tr( "Cannot transform the point to the layers coordinate system" ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } @@ -134,20 +135,14 @@ void QgsMapToolSplitFeatures::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) switch ( returnCode ) { case Qgis::GeometryOperationResult::Success: - if ( topologicalEditing == true && - ! topologyTestPoints.isEmpty() ) + if ( topologicalEditing == true && !topologyTestPoints.isEmpty() ) { //check if we need to add topological points to other layers const auto layers = canvas()->layers( true ); for ( QgsMapLayer *layer : layers ) { QgsVectorLayer *vectorLayer = qobject_cast( layer ); - if ( vectorLayer && - vectorLayer->isEditable() && - vectorLayer->isSpatial() && - vectorLayer != vlayer && - ( vectorLayer->geometryType() == Qgis::GeometryType::Line || - vectorLayer->geometryType() == Qgis::GeometryType::Polygon ) ) + if ( vectorLayer && vectorLayer->isEditable() && vectorLayer->isSpatial() && vectorLayer != vlayer && ( vectorLayer->geometryType() == Qgis::GeometryType::Line || vectorLayer->geometryType() == Qgis::GeometryType::Polygon ) ) { vectorLayer->beginEditCommand( tr( "Topological points from Features split" ) ); const int returnValue = vectorLayer->addTopologicalPoints( topologyTestPoints ); @@ -168,26 +163,30 @@ void QgsMapToolSplitFeatures::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgisApp::instance()->messageBar()->pushMessage( tr( "No features were split" ), tr( "If there are selected features, the split tool only applies to those. If you would like to split all features under the split line, clear the selection." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); break; case Qgis::GeometryOperationResult::GeometryEngineError: QgisApp::instance()->messageBar()->pushMessage( tr( "No feature split done" ), tr( "Cut edges detected. Make sure the line splits features into multiple parts." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); break; case Qgis::GeometryOperationResult::InvalidBaseGeometry: QgisApp::instance()->messageBar()->pushMessage( tr( "No feature split done" ), tr( "The geometry is invalid. Please repair before trying to split it." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); break; default: //several intersections but only one split (most likely line) QgisApp::instance()->messageBar()->pushMessage( tr( "No feature split done" ), tr( "An error occurred during splitting." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); break; } stopCapturing(); diff --git a/src/app/qgsmaptoolsplitfeatures.h b/src/app/qgsmaptoolsplitfeatures.h index e3c674cb9752..2767bb21de2d 100644 --- a/src/app/qgsmaptoolsplitfeatures.h +++ b/src/app/qgsmaptoolsplitfeatures.h @@ -20,7 +20,7 @@ #include "qgis_app.h" //! A map tool that draws a line and splits the features cut by the line -class APP_EXPORT QgsMapToolSplitFeatures: public QgsMapToolCapture +class APP_EXPORT QgsMapToolSplitFeatures : public QgsMapToolCapture { Q_OBJECT public: diff --git a/src/app/qgsmaptoolsplitparts.cpp b/src/app/qgsmaptoolsplitparts.cpp index 0e689805d270..c1bc64432f6a 100644 --- a/src/app/qgsmaptoolsplitparts.cpp +++ b/src/app/qgsmaptoolsplitparts.cpp @@ -89,7 +89,8 @@ void QgsMapToolSplitParts::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgisApp::instance()->messageBar()->pushMessage( tr( "Coordinate transform error" ), tr( "Cannot transform the point to the layers coordinate system" ), - Qgis::MessageLevel::Info ); + Qgis::MessageLevel::Info + ); return; } @@ -119,21 +120,24 @@ void QgsMapToolSplitParts::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgisApp::instance()->messageBar()->pushMessage( tr( "No parts were split" ), tr( "If there are selected parts, the split tool only applies to those. If you would like to split all parts under the split line, clear the selection." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } else if ( returnCode == Qgis::GeometryOperationResult::GeometryEngineError ) { QgisApp::instance()->messageBar()->pushMessage( tr( "No part split done" ), tr( "Cut edges detected. Make sure the line splits parts into multiple parts." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } else if ( returnCode == Qgis::GeometryOperationResult::InvalidBaseGeometry ) { QgisApp::instance()->messageBar()->pushMessage( tr( "No part split done" ), tr( "The geometry is invalid. Please repair before trying to split it." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } else if ( returnCode != Qgis::GeometryOperationResult::Success ) { @@ -141,7 +145,8 @@ void QgsMapToolSplitParts::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgisApp::instance()->messageBar()->pushMessage( tr( "Split error" ), tr( "An error occurred during splitting." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } stopCapturing(); diff --git a/src/app/qgsmaptoolsplitparts.h b/src/app/qgsmaptoolsplitparts.h index 179e47892c7d..85d4a9e8a5da 100644 --- a/src/app/qgsmaptoolsplitparts.h +++ b/src/app/qgsmaptoolsplitparts.h @@ -19,7 +19,7 @@ #include "qgsmaptoolcapture.h" //! A map tool that draws a line and splits the parts cut by the line -class APP_EXPORT QgsMapToolSplitParts: public QgsMapToolCapture +class APP_EXPORT QgsMapToolSplitParts : public QgsMapToolCapture { Q_OBJECT public: diff --git a/src/app/qgsmaptooltrimextendfeature.cpp b/src/app/qgsmaptooltrimextendfeature.cpp index 2fc8a0c403d2..3cd9a5beb79c 100644 --- a/src/app/qgsmaptooltrimextendfeature.cpp +++ b/src/app/qgsmaptooltrimextendfeature.cpp @@ -94,7 +94,6 @@ void QgsMapToolTrimExtendFeature::canvasMoveEvent( QgsMapMouseEvent *e ) mRubberBandLimit->addPoint( p1 ); mRubberBandLimit->addPoint( p2 ); mRubberBandLimit->show(); - } else if ( mRubberBandLimit ) { @@ -248,7 +247,6 @@ void QgsMapToolTrimExtendFeature::canvasReleaseEvent( QgsMapMouseEvent *e ) if ( auto *lLayer = match.layer() ) { - lLayer->beginEditCommand( tr( "Trim/Extend feature" ) ); lLayer->changeGeometry( match.featureId(), mGeom ); if ( QgsProject::instance()->topologicalEditing() ) @@ -274,7 +272,6 @@ void QgsMapToolTrimExtendFeature::canvasReleaseEvent( QgsMapMouseEvent *e ) { deactivate(); } - } void QgsMapToolTrimExtendFeature::keyPressEvent( QKeyEvent *e ) diff --git a/src/app/qgsmaptooltrimextendfeature.h b/src/app/qgsmaptooltrimextendfeature.h index e9e232be6505..20283a13d028 100644 --- a/src/app/qgsmaptooltrimextendfeature.h +++ b/src/app/qgsmaptooltrimextendfeature.h @@ -40,11 +40,11 @@ class APP_EXPORT QgsMapToolTrimExtendFeature : public QgsMapToolEdit private: //! Rubberband that shows the limit - std::unique_ptrmRubberBandLimit; + std::unique_ptr mRubberBandLimit; //! Rubberband that shows the feature being extended - std::unique_ptrmRubberBandExtend; + std::unique_ptr mRubberBandExtend; //! Rubberband that shows the intersection point - std::unique_ptrmRubberBandIntersection; + std::unique_ptr mRubberBandIntersection; //! Points for the limit QgsPoint pLimit1, pLimit2; //! Points for extend diff --git a/src/app/qgsmeasuredialog.cpp b/src/app/qgsmeasuredialog.cpp index 0d75cf236f87..7bcc075f2faf 100644 --- a/src/app/qgsmeasuredialog.cpp +++ b/src/app/qgsmeasuredialog.cpp @@ -81,25 +81,25 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool *tool, Qt::WindowFlags f ) if ( mMeasureArea ) { if ( mUseMapUnits ) - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( Qgis::AreaUnit::Unknown ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::AreaUnit::Unknown ) ) ); else - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( QgsProject::instance()->areaUnits() ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( QgsProject::instance()->areaUnits() ) ) ); } else { if ( mUseMapUnits ) - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( Qgis::DistanceUnit::Unknown ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::DistanceUnit::Unknown ) ) ); else - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( QgsProject::instance()->distanceUnits() ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( QgsProject::instance()->distanceUnits() ) ) ); } if ( !mCanvas->mapSettings().destinationCrs().isValid() ) { mUnitsCombo->setEnabled( false ); if ( mMeasureArea ) - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( Qgis::DistanceUnit::Unknown ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::DistanceUnit::Unknown ) ) ); else - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( Qgis::AreaUnit::Unknown ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::AreaUnit::Unknown ) ) ); } updateSettings(); @@ -138,9 +138,9 @@ void QgsMeasureDialog::crsChanged() { mUnitsCombo->setEnabled( false ); if ( mMeasureArea ) - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( Qgis::DistanceUnit::Unknown ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::DistanceUnit::Unknown ) ) ); else - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( Qgis::AreaUnit::Unknown ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::AreaUnit::Unknown ) ) ); } else { @@ -167,9 +167,7 @@ void QgsMeasureDialog::updateSettings() // Calling projChanged() will set the ellipsoid and clear then re-populate the table projChanged(); - if ( mCartesian->isChecked() || !mCanvas->mapSettings().destinationCrs().isValid() || - ( mCanvas->mapSettings().destinationCrs().mapUnits() == Qgis::DistanceUnit::Degrees - && mDistanceUnits == Qgis::DistanceUnit::Degrees ) ) + if ( mCartesian->isChecked() || !mCanvas->mapSettings().destinationCrs().isValid() || ( mCanvas->mapSettings().destinationCrs().mapUnits() == Qgis::DistanceUnit::Degrees && mDistanceUnits == Qgis::DistanceUnit::Degrees ) ) { mDa.setEllipsoid( geoNone() ); } @@ -183,18 +181,18 @@ void QgsMeasureDialog::unitsChanged( int index ) { if ( mMeasureArea ) { - mAreaUnits = static_cast< Qgis::AreaUnit >( mUnitsCombo->itemData( index ).toInt() ); + mAreaUnits = static_cast( mUnitsCombo->itemData( index ).toInt() ); } else { - mDistanceUnits = static_cast< Qgis::DistanceUnit >( mUnitsCombo->itemData( index ).toInt() ); + mDistanceUnits = static_cast( mUnitsCombo->itemData( index ).toInt() ); } updateUnitsMembers(); updateUi(); } -void QgsMeasureDialog:: updateUnitsMembers() +void QgsMeasureDialog::updateUnitsMembers() { if ( mMeasureArea ) { @@ -254,7 +252,7 @@ void QgsMeasureDialog::mouseMove( const QgsPointXY &point ) } else if ( !mMeasureArea && !mTool->points().empty() ) { - const QVector< QgsPointXY > tmpPoints = mTool->points(); + const QVector tmpPoints = mTool->points(); QgsPointXY p1( tmpPoints.at( tmpPoints.size() - 1 ) ), p2( point ); double d = 0; try @@ -382,7 +380,7 @@ void QgsMeasureDialog::removeLastPoint() if ( !mTool->done() ) { // need to add the distance for the temporary mouse cursor point - const QVector< QgsPointXY > tmpPoints = mTool->points(); + const QVector tmpPoints = mTool->points(); const QgsPointXY p1( tmpPoints.at( tmpPoints.size() - 1 ) ); double d = 0; try @@ -444,7 +442,7 @@ QString QgsMeasureDialog::formatDistance( double distance, bool convertUnits ) c distance = convertLength( distance, mDistanceUnits ); int decimals = mDecimalPlaces; - if ( mDistanceUnits == Qgis::DistanceUnit::Degrees && distance < 1 ) + if ( mDistanceUnits == Qgis::DistanceUnit::Degrees && distance < 1 ) { // special handling for degrees - because we can't use smaller units (eg m->mm), we need to make sure there's // enough decimal places to show a usable measurement value @@ -474,8 +472,7 @@ void QgsMeasureDialog::updateUi() mDa.setEllipsoid( QgsProject::instance()->ellipsoid() ); mConvertToDisplayUnits = true; - const auto getEllipsoidFriendlyName = [this]() - { + const auto getEllipsoidFriendlyName = [this]() { // If mDa.ellipsoid is an acronym (e.g "EPSG:7030"), retrieve the user // friendly name ("WGS 84 (EPSG:7030)") QString ellipsoid = mDa.ellipsoid(); @@ -516,8 +513,7 @@ void QgsMeasureDialog::updateUi() && ( mAreaUnits == Qgis::AreaUnit::SquareDegrees || mAreaUnits == Qgis::AreaUnit::Unknown ) ) { //both source and destination units are degrees - toolTip += "
    * " + tr( "Both project CRS (%1) and measured area are in degrees, so area is calculated using Cartesian calculations in square degrees." ).arg( - mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); + toolTip += "
    * " + tr( "Both project CRS (%1) and measured area are in degrees, so area is calculated using Cartesian calculations in square degrees." ).arg( mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); mDa.setEllipsoid( geoNone() ); mConvertToDisplayUnits = false; //not required since we will be measuring in degrees } @@ -528,26 +524,22 @@ void QgsMeasureDialog::updateUi() { resultUnit = Qgis::AreaUnit::SquareMeters; toolTip += "
    * " + tr( "Project ellipsoidal calculation is selected." ) + ' '; - toolTip += "
    * " + tr( "The coordinates are transformed to the chosen ellipsoid (%1), and the area is calculated in %2." ).arg( getEllipsoidFriendlyName(), - QgsUnitTypes::toString( resultUnit ) ); + toolTip += "
    * " + tr( "The coordinates are transformed to the chosen ellipsoid (%1), and the area is calculated in %2." ).arg( getEllipsoidFriendlyName(), QgsUnitTypes::toString( resultUnit ) ); } else { resultUnit = QgsUnitTypes::distanceToAreaUnit( mCanvas->mapSettings().destinationCrs().mapUnits() ); toolTip += "
    * " + tr( "Project ellipsoidal calculation is not selected." ) + ' '; - toolTip += tr( "Area is calculated in %1, based on project CRS (%2)." ).arg( QgsUnitTypes::toString( resultUnit ), - mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); + toolTip += tr( "Area is calculated in %1, based on project CRS (%2)." ).arg( QgsUnitTypes::toString( resultUnit ), mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); } setWindowTitle( tr( "Measure" ) ); - if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Geographic && - QgsUnitTypes::unitType( mAreaUnits ) == Qgis::DistanceUnitType::Standard ) + if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Geographic && QgsUnitTypes::unitType( mAreaUnits ) == Qgis::DistanceUnitType::Standard ) { toolTip += QLatin1String( "
    * Area is roughly converted to square meters by using scale at equator (1 degree = 111319.49 meters)." ); resultUnit = Qgis::AreaUnit::SquareMeters; } - else if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && - QgsUnitTypes::unitType( mAreaUnits ) == Qgis::DistanceUnitType::Geographic ) + else if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && QgsUnitTypes::unitType( mAreaUnits ) == Qgis::DistanceUnitType::Geographic ) { toolTip += QLatin1String( "
    * Area is roughly converted to square degrees by using scale at equator (1 degree = 111319.49 meters)." ); resultUnit = Qgis::AreaUnit::SquareDegrees; @@ -555,15 +547,13 @@ void QgsMeasureDialog::updateUi() if ( resultUnit != mAreaUnits ) { - if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && - QgsUnitTypes::unitType( mAreaUnits ) == Qgis::DistanceUnitType::Standard ) + if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && QgsUnitTypes::unitType( mAreaUnits ) == Qgis::DistanceUnitType::Standard ) { // only shown if both conditions are true: // - the display unit is a standard distance measurement (e.g., square feet) // - either the canvas units is also a standard distance OR we are using an ellipsoid (in which case the // value will be in square meters) - toolTip += "
    * " + tr( "The value is converted from %1 to %2." ).arg( QgsUnitTypes::toString( resultUnit ), - QgsUnitTypes::toString( mAreaUnits ) ); + toolTip += "
    * " + tr( "The value is converted from %1 to %2." ).arg( QgsUnitTypes::toString( resultUnit ), QgsUnitTypes::toString( mAreaUnits ) ); } else { @@ -594,8 +584,7 @@ void QgsMeasureDialog::updateUi() && mDistanceUnits == Qgis::DistanceUnit::Degrees ) { //both source and destination units are degrees - toolTip += "
    * " + tr( "Both project CRS (%1) and measured length are in degrees, so distance is calculated using Cartesian calculations in degrees." ).arg( - mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); + toolTip += "
    * " + tr( "Both project CRS (%1) and measured length are in degrees, so distance is calculated using Cartesian calculations in degrees." ).arg( mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); mDa.setEllipsoid( geoNone() ); mConvertToDisplayUnits = false; //not required since we will be measuring in degrees } @@ -606,26 +595,22 @@ void QgsMeasureDialog::updateUi() { resultUnit = Qgis::DistanceUnit::Meters; toolTip += "
    * " + tr( "Project ellipsoidal calculation is selected." ) + ' '; - toolTip += "
    * " + tr( "The coordinates are transformed to the chosen ellipsoid (%1), and the distance is calculated in %2." ).arg( getEllipsoidFriendlyName(), - QgsUnitTypes::toString( resultUnit ) ); + toolTip += "
    * " + tr( "The coordinates are transformed to the chosen ellipsoid (%1), and the distance is calculated in %2." ).arg( getEllipsoidFriendlyName(), QgsUnitTypes::toString( resultUnit ) ); } else { resultUnit = mCanvas->mapSettings().destinationCrs().mapUnits(); toolTip += "
    * " + tr( "Project ellipsoidal calculation is not selected." ) + ' '; - toolTip += tr( "Distance is calculated in %1, based on project CRS (%2)." ).arg( QgsUnitTypes::toString( resultUnit ), - mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); + toolTip += tr( "Distance is calculated in %1, based on project CRS (%2)." ).arg( QgsUnitTypes::toString( resultUnit ), mCanvas->mapSettings().destinationCrs().userFriendlyIdentifier() ); } setWindowTitle( tr( "Measure" ) ); - if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Geographic && - QgsUnitTypes::unitType( mDistanceUnits ) == Qgis::DistanceUnitType::Standard ) + if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Geographic && QgsUnitTypes::unitType( mDistanceUnits ) == Qgis::DistanceUnitType::Standard ) { toolTip += QLatin1String( "
    * Distance is roughly converted to meters by using scale at equator (1 degree = 111319.49 meters)." ); resultUnit = Qgis::DistanceUnit::Meters; } - else if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && - QgsUnitTypes::unitType( mDistanceUnits ) == Qgis::DistanceUnitType::Geographic ) + else if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && QgsUnitTypes::unitType( mDistanceUnits ) == Qgis::DistanceUnitType::Geographic ) { toolTip += QLatin1String( "
    * Distance is roughly converted to degrees by using scale at equator (1 degree = 111319.49 meters)." ); resultUnit = Qgis::DistanceUnit::Degrees; @@ -633,15 +618,13 @@ void QgsMeasureDialog::updateUi() if ( resultUnit != mDistanceUnits ) { - if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && - QgsUnitTypes::unitType( mDistanceUnits ) == Qgis::DistanceUnitType::Standard ) + if ( QgsUnitTypes::unitType( resultUnit ) == Qgis::DistanceUnitType::Standard && QgsUnitTypes::unitType( mDistanceUnits ) == Qgis::DistanceUnitType::Standard ) { // only shown if both conditions are true: // - the display unit is a standard distance measurement (e.g., feet) // - either the canvas units is also a standard distance OR we are using an ellipsoid (in which case the // value will be in meters) - toolTip += "
    * " + tr( "The value is converted from %1 to %2." ).arg( QgsUnitTypes::toString( resultUnit ), - QgsUnitTypes::toString( mDistanceUnits ) ); + toolTip += "
    * " + tr( "The value is converted from %1 to %2." ).arg( QgsUnitTypes::toString( resultUnit ), QgsUnitTypes::toString( mDistanceUnits ) ); } else { @@ -669,22 +652,22 @@ void QgsMeasureDialog::updateUi() if ( mUseMapUnits ) mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::AreaUnit::Unknown ) ) ); else - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( mAreaUnits ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( mAreaUnits ) ) ); } else { if ( mUseMapUnits ) { - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( Qgis::DistanceUnit::Unknown ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( Qgis::DistanceUnit::Unknown ) ) ); mTable->headerItem()->setText( Columns::Distance, tr( "Segments [%1]" ).arg( QgsUnitTypes::toString( mMapDistanceUnits ) ) ); } else { - mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( mDistanceUnits ) ) ); + mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast( mDistanceUnits ) ) ); if ( mDistanceUnits != Qgis::DistanceUnit::Unknown ) - mTable->headerItem()->setText( Columns::Distance, tr( "Segments [%1]" ).arg( QgsUnitTypes::toString( mDistanceUnits ) ) ); + mTable->headerItem()->setText( Columns::Distance, tr( "Segments [%1]" ).arg( QgsUnitTypes::toString( mDistanceUnits ) ) ); else - mTable->headerItem()->setText( Columns::Distance, tr( "Segments" ) ); + mTable->headerItem()->setText( Columns::Distance, tr( "Segments" ) ); } } @@ -715,7 +698,7 @@ void QgsMeasureDialog::updateUi() QgsPointXY previousPoint, point; mTotal = 0; - const QVector< QgsPointXY > tmpPoints = mTool->points(); + const QVector tmpPoints = mTool->points(); for ( it = tmpPoints.constBegin(); it != tmpPoints.constEnd(); ++it ) { point = *it; @@ -790,9 +773,9 @@ void QgsMeasureDialog::repopulateComboBoxUnits( bool isArea ) Qgis::AreaUnit::SquareDegrees, } ) { - mUnitsCombo->addItem( QgsUnitTypes::toString( unit ), static_cast< int >( unit ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( unit ), static_cast( unit ) ); } - mUnitsCombo->addItem( tr( "map units" ), static_cast< int >( Qgis::AreaUnit::Unknown ) ); + mUnitsCombo->addItem( tr( "map units" ), static_cast( Qgis::AreaUnit::Unknown ) ); } else { @@ -811,9 +794,9 @@ void QgsMeasureDialog::repopulateComboBoxUnits( bool isArea ) Qgis::DistanceUnit::ChainsInternational } ) { - mUnitsCombo->addItem( QgsUnitTypes::toString( unit ), static_cast< int >( unit ) ); + mUnitsCombo->addItem( QgsUnitTypes::toString( unit ), static_cast( unit ) ); } - mUnitsCombo->addItem( tr( "map units" ), static_cast< int >( Qgis::DistanceUnit::Unknown ) ); + mUnitsCombo->addItem( tr( "map units" ), static_cast( Qgis::DistanceUnit::Unknown ) ); } } @@ -854,8 +837,7 @@ void QgsMeasureDialog::copyMeasurements() } - auto replaceDecimalSeparator = [ alwaysUseDecimalPoint ]( const QString & value ) -> QString - { + auto replaceDecimalSeparator = [alwaysUseDecimalPoint]( const QString &value ) -> QString { QString result = value; if ( alwaysUseDecimalPoint && QLocale().decimalPoint() != QLatin1String( "." ) ) result.replace( QLocale().decimalPoint(), QStringLiteral( "." ) ); diff --git a/src/app/qgsmeasuredialog.h b/src/app/qgsmeasuredialog.h index 3b519249b129..55833d76425f 100644 --- a/src/app/qgsmeasuredialog.h +++ b/src/app/qgsmeasuredialog.h @@ -35,7 +35,6 @@ class APP_EXPORT QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase Q_OBJECT public: - static const QgsSettingsEntryBool *settingClipboardHeader; static const QgsSettingsEntryString *settingClipboardSeparator; static const QgsSettingsEntryBool *settingClipboardAlwaysUseDecimalPoint; @@ -84,7 +83,6 @@ class APP_EXPORT QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase void projChanged(); private: - //! \since QGIS 3.32 columns enum Columns { @@ -136,13 +134,13 @@ class APP_EXPORT QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase Qgis::DistanceUnit mCanvasUnits = Qgis::DistanceUnit::Unknown; //! Current unit for distance values - Qgis::DistanceUnit mDistanceUnits = Qgis::DistanceUnit::Unknown; + Qgis::DistanceUnit mDistanceUnits = Qgis::DistanceUnit::Unknown; //! Current map unit for distance values - Qgis::DistanceUnit mMapDistanceUnits = Qgis::DistanceUnit::Unknown; + Qgis::DistanceUnit mMapDistanceUnits = Qgis::DistanceUnit::Unknown; //! Current unit for area values - Qgis::AreaUnit mAreaUnits = Qgis::AreaUnit::Unknown; + Qgis::AreaUnit mAreaUnits = Qgis::AreaUnit::Unknown; //! Our measurement object QgsDistanceArea mDa; diff --git a/src/app/qgsmeasuretool.cpp b/src/app/qgsmeasuretool.cpp index 570f272925cf..a2dabc9b652e 100644 --- a/src/app/qgsmeasuretool.cpp +++ b/src/app/qgsmeasuretool.cpp @@ -71,20 +71,16 @@ void QgsMeasureTool::activate() // If we suspect that they have data that is projected, yet the // map CRS is set to a geographic one, warn them. - if ( mCanvas->mapSettings().destinationCrs().isValid() && - mCanvas->mapSettings().destinationCrs().isGeographic() && - ( mCanvas->extent().height() > 360 || - mCanvas->extent().width() > 720 ) ) + if ( mCanvas->mapSettings().destinationCrs().isValid() && mCanvas->mapSettings().destinationCrs().isGeographic() && ( mCanvas->extent().height() > 360 || mCanvas->extent().width() > 720 ) ) { - QMessageBox::warning( nullptr, tr( "Incorrect Measure Results" ), - tr( "

    This map is defined with a geographic coordinate system " - "(latitude/longitude) " - "but the map extents suggests that it is actually a projected " - "coordinate system (e.g., Mercator). " - "If so, the results from line or area measurements will be " - "incorrect.

    " - "

    To fix this, explicitly set an appropriate map coordinate " - "system using the Settings:Project Properties menu." ) ); + QMessageBox::warning( nullptr, tr( "Incorrect Measure Results" ), tr( "

    This map is defined with a geographic coordinate system " + "(latitude/longitude) " + "but the map extents suggests that it is actually a projected " + "coordinate system (e.g., Mercator). " + "If so, the results from line or area measurements will be " + "incorrect.

    " + "

    To fix this, explicitly set an appropriate map coordinate " + "system using the Settings:Project Properties menu." ) ); mWrongProjectProjection = true; } } @@ -170,7 +166,7 @@ void QgsMeasureTool::updateSettings() int nbVertices = mRubberBandPoints->numberOfVertices(); // Add a temporary point to the rubber band if the user is currently measuring - if ( !mDone && mRubberBand->size() > 0 && nbTempVertices <= nbVertices ) + if ( !mDone && mRubberBand->size() > 0 && nbTempVertices <= nbVertices ) { mRubberBand->addPoint( mPoints.last() ); } @@ -193,7 +189,7 @@ void QgsMeasureTool::canvasMoveEvent( QgsMapMouseEvent *e ) const QgsPointXY point = e->snapPoint(); mSnapIndicator->setMatch( e->mapPointMatch() ); - if ( ! mDone ) + if ( !mDone ) { mRubberBand->movePoint( point ); mDialog->mouseMove( point ); @@ -223,7 +219,6 @@ void QgsMeasureTool::canvasReleaseEvent( QgsMapMouseEvent *e ) } mDialog->show(); - } void QgsMeasureTool::undo() @@ -250,7 +245,6 @@ void QgsMeasureTool::undo() mDialog->removeLastPoint(); } - } } @@ -290,7 +284,7 @@ void QgsMeasureTool::addPoint( const QgsPointXY &point ) mRubberBand->movePoint( point ); mRubberBand->addPoint( point ); mRubberBandPoints->addPoint( point ); - if ( ! mDone ) // Prevent the insertion of a new item in segments measure table + if ( !mDone ) // Prevent the insertion of a new item in segments measure table { mDialog->addPoint(); } diff --git a/src/app/qgsmeasuretool.h b/src/app/qgsmeasuretool.h index 89a32fe003f9..f630dbe2fcad 100644 --- a/src/app/qgsmeasuretool.h +++ b/src/app/qgsmeasuretool.h @@ -33,7 +33,6 @@ class APP_EXPORT QgsMeasureTool : public QgsMapTool Q_OBJECT public: - QgsMeasureTool( QgsMapCanvas *canvas, bool measureArea ); ~QgsMeasureTool() override; @@ -70,7 +69,6 @@ class APP_EXPORT QgsMeasureTool : public QgsMapTool void updateSettings(); protected: - QVector mPoints; QgsMeasureDialog *mDialog = nullptr; diff --git a/src/app/qgsmergeattributesdialog.cpp b/src/app/qgsmergeattributesdialog.cpp index 339930d5bc25..12396c0be474 100644 --- a/src/app/qgsmergeattributesdialog.cpp +++ b/src/app/qgsmergeattributesdialog.cpp @@ -34,22 +34,21 @@ #include #include -const QList< Qgis::Statistic > QgsMergeAttributesDialog::DISPLAY_STATS = - QList< Qgis::Statistic > () << Qgis::Statistic::Count - << Qgis::Statistic::Sum - << Qgis::Statistic::Mean - << Qgis::Statistic::Median - << Qgis::Statistic::StDev - << Qgis::Statistic::StDevSample - << Qgis::Statistic::Min - << Qgis::Statistic::Max - << Qgis::Statistic::Range - << Qgis::Statistic::Minority - << Qgis::Statistic::Majority - << Qgis::Statistic::Variety - << Qgis::Statistic::FirstQuartile - << Qgis::Statistic::ThirdQuartile - << Qgis::Statistic::InterQuartileRange; +const QList QgsMergeAttributesDialog::DISPLAY_STATS = QList() << Qgis::Statistic::Count + << Qgis::Statistic::Sum + << Qgis::Statistic::Mean + << Qgis::Statistic::Median + << Qgis::Statistic::StDev + << Qgis::Statistic::StDevSample + << Qgis::Statistic::Min + << Qgis::Statistic::Max + << Qgis::Statistic::Range + << Qgis::Statistic::Minority + << Qgis::Statistic::Majority + << Qgis::Statistic::Variety + << Qgis::Statistic::FirstQuartile + << Qgis::Statistic::ThirdQuartile + << Qgis::Statistic::InterQuartileRange; QgsMergeAttributesDialog::QgsMergeAttributesDialog( const QgsFeatureList &features, QgsVectorLayer *vl, QgsMapCanvas *canvas, QWidget *parent, Qt::WindowFlags f ) : QDialog( parent, f ) @@ -129,7 +128,7 @@ QgsMergeAttributesDialog::~QgsMergeAttributesDialog() void QgsMergeAttributesDialog::setAttributeTableConfig( const QgsAttributeTableConfig &config ) { - const QVector< QgsAttributeTableConfig::ColumnConfig > columns = config.columns(); + const QVector columns = config.columns(); for ( const QgsAttributeTableConfig::ColumnConfig &columnConfig : columns ) { if ( columnConfig.hidden ) @@ -179,15 +178,14 @@ void QgsMergeAttributesDialog::createTableWidgetContents() } mTableWidget->setColumnCount( col + 1 ); - mFieldToColumnMap[ mFields.at( idx ).name() ] = col; + mFieldToColumnMap[mFields.at( idx ).name()] = col; QTableWidgetItem *item = new QTableWidgetItem( mFields.at( idx ).name() ); item->setData( FieldIndex, idx ); mTableWidget->setHorizontalHeaderItem( col, item ); QComboBox *cb = createMergeComboBox( mFields.at( idx ).type(), col ); - if ( ( ! mVectorLayer->dataProvider()->pkAttributeIndexes().contains( mFields.fieldOriginIndex( idx ) ) && - mFields.at( idx ).constraints().constraints() & QgsFieldConstraints::ConstraintUnique ) || mHiddenAttributes.contains( idx ) ) + if ( ( !mVectorLayer->dataProvider()->pkAttributeIndexes().contains( mFields.fieldOriginIndex( idx ) ) && mFields.at( idx ).constraints().constraints() & QgsFieldConstraints::ConstraintUnique ) || mHiddenAttributes.contains( idx ) ) { cb->setCurrentIndex( cb->findData( "skip" ) ); } @@ -297,7 +295,7 @@ QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QMetaType::Type column { for ( Qgis::Statistic stat : std::as_const( DISPLAY_STATS ) ) { - newComboBox->addItem( QgsStatisticalSummary::displayName( stat ), static_cast< int >( stat ) ); + newComboBox->addItem( QgsStatisticalSummary::displayName( stat ), static_cast( stat ) ); } break; } @@ -313,8 +311,7 @@ QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QMetaType::Type column newComboBox->addItem( tr( "Skip Attribute" ), QStringLiteral( "skip" ) ); newComboBox->addItem( tr( "Manual Value" ), QStringLiteral( "manual" ) ); - connect( newComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [ = ]() - { + connect( newComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=]() { bool isManual = newComboBox->currentData() == QLatin1String( "manual" ); updateManualWidget( column, isManual ); refreshMergedValue( column ); @@ -411,7 +408,7 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col ) else { //numerical statistic - Qgis::Statistic stat = static_cast< Qgis::Statistic >( comboBox->currentData().toInt() ); + Qgis::Statistic stat = static_cast( comboBox->currentData().toInt() ); mergeResult = calcStatistic( fieldIdx, stat ); } @@ -420,7 +417,7 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col ) // Result formatting QString stringVal; - if ( mergeBehaviorString != QLatin1String( "skip" ) && mergeBehaviorString != QLatin1String( "manual" ) ) + if ( mergeBehaviorString != QLatin1String( "skip" ) && mergeBehaviorString != QLatin1String( "manual" ) ) { const QgsEditorWidgetSetup setup = mFields.at( fieldIdx ).editorWidgetSetup(); const QgsFieldFormatter *formatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() ); @@ -461,8 +458,7 @@ void QgsMergeAttributesDialog::setAllAttributesFromFeature( QgsFeatureId feature if ( !currentComboBox ) continue; - if ( ! mVectorLayer->dataProvider()->pkAttributeIndexes().contains( mVectorLayer->fields().fieldOriginIndex( i ) ) && - mVectorLayer->fields().at( i ).constraints().constraints() & QgsFieldConstraints::ConstraintUnique ) + if ( !mVectorLayer->dataProvider()->pkAttributeIndexes().contains( mVectorLayer->fields().fieldOriginIndex( i ) ) && mVectorLayer->fields().at( i ).constraints().constraints() & QgsFieldConstraints::ConstraintUnique ) { currentComboBox->setCurrentIndex( currentComboBox->findData( QStringLiteral( "skip" ) ) ); } diff --git a/src/app/qgsmergeattributesdialog.h b/src/app/qgsmergeattributesdialog.h index 82b55fdf73a6..6b3eccaceb9a 100644 --- a/src/app/qgsmergeattributesdialog.h +++ b/src/app/qgsmergeattributesdialog.h @@ -32,11 +32,10 @@ class QgsAttributeTableConfig; //! A dialog to insert the merge behavior for attributes (e.g. for the union features editing tool) -class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeAttributesDialogBase +class APP_EXPORT QgsMergeAttributesDialog : public QDialog, private Ui::QgsMergeAttributesDialogBase { Q_OBJECT public: - enum ItemDataRole { FieldIndex = Qt::UserRole //!< Index of corresponding field in source table for table header @@ -121,11 +120,10 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA QgsFields mFields; QSet mHiddenAttributes; - QMap< QString, int > mFieldToColumnMap; + QMap mFieldToColumnMap; bool mUpdating = false; - static const QList< Qgis::Statistic > DISPLAY_STATS; - + static const QList DISPLAY_STATS; }; #endif // QGSMERGEATTRIBUTESDIALOG_H diff --git a/src/app/qgsnewspatialitelayerdialog.cpp b/src/app/qgsnewspatialitelayerdialog.cpp index 08704bb37e78..e23b9942e5e0 100644 --- a/src/app/qgsnewspatialitelayerdialog.cpp +++ b/src/app/qgsnewspatialitelayerdialog.cpp @@ -51,8 +51,7 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W setupUi( this ); QgsGui::enableAutoGeometryRestore( this ); - const auto addGeomItem = [this]( Qgis::WkbType type, const QString & sqlType ) - { + const auto addGeomItem = [this]( Qgis::WkbType type, const QString &sqlType ) { mGeometryTypeBox->addItem( QgsIconUtils::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), sqlType ); }; @@ -162,8 +161,7 @@ QString QgsNewSpatialiteLayerDialog::selectedZM() const void QgsNewSpatialiteLayerDialog::checkOk() { - const bool created = !leLayerName->text().isEmpty() && mGeometryTypeBox->currentIndex() != -1 && - ( checkBoxPrimaryKey->isChecked() || mAttributeView->topLevelItemCount() > 0 ); + const bool created = !leLayerName->text().isEmpty() && mGeometryTypeBox->currentIndex() != -1 && ( checkBoxPrimaryKey->isChecked() || mAttributeView->topLevelItemCount() > 0 ); mOkButton->setEnabled( created ); } @@ -256,7 +254,7 @@ void QgsNewSpatialiteLayerDialog::pbnFindSRID_clicked() void QgsNewSpatialiteLayerDialog::nameChanged( const QString &name ) { - mAddAttributeButton->setDisabled( name.isEmpty() || ! mAttributeView->findItems( name, Qt::MatchExactly ).isEmpty() ); + mAddAttributeButton->setDisabled( name.isEmpty() || !mAttributeView->findItems( name, Qt::MatchExactly ).isEmpty() ); } void QgsNewSpatialiteLayerDialog::selectionChanged() @@ -268,15 +266,12 @@ void QgsNewSpatialiteLayerDialog::selectionChanged() bool QgsNewSpatialiteLayerDialog::createDb() { - QString dbPath = QFileDialog::getSaveFileName( this, tr( "New SpatiaLite Database File" ), - QDir::homePath(), - tr( "SpatiaLite" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db)", nullptr, QFileDialog::DontConfirmOverwrite ); + QString dbPath = QFileDialog::getSaveFileName( this, tr( "New SpatiaLite Database File" ), QDir::homePath(), tr( "SpatiaLite" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db)", nullptr, QFileDialog::DontConfirmOverwrite ); if ( dbPath.isEmpty() ) return false; - dbPath = QgsFileUtils::ensureFileNameHasExtension( dbPath, QStringList() << QStringLiteral( "sqlite" ) << QStringLiteral( "db" ) << QStringLiteral( "sqlite3" ) - << QStringLiteral( "db3" ) << QStringLiteral( "s3db" ) ); + dbPath = QgsFileUtils::ensureFileNameHasExtension( dbPath, QStringList() << QStringLiteral( "sqlite" ) << QStringLiteral( "db" ) << QStringLiteral( "sqlite3" ) << QStringLiteral( "db3" ) << QStringLiteral( "s3db" ) ); QFile newDb( dbPath ); if ( newDb.exists() ) { @@ -363,9 +358,7 @@ bool QgsNewSpatialiteLayerDialog::apply() if ( !currentFound ) { - if ( QMessageBox::question( this, windowTitle(), - tr( "The field “%1” has not been added to the fields list. Are you sure you want to proceed and discard this field?" ).arg( currentFieldName ), - QMessageBox::Ok | QMessageBox::Cancel ) != QMessageBox::Ok ) + if ( QMessageBox::question( this, windowTitle(), tr( "The field “%1” has not been added to the fields list. Are you sure you want to proceed and discard this field?" ).arg( currentFieldName ), QMessageBox::Ok | QMessageBox::Cancel ) != QMessageBox::Ok ) { return false; } @@ -402,9 +395,7 @@ bool QgsNewSpatialiteLayerDialog::apply() int rc = database.open( dbPath ); if ( rc != SQLITE_OK ) { - QMessageBox::warning( this, - tr( "SpatiaLite Database" ), - tr( "Unable to open the database: %1" ).arg( dbPath ) ); + QMessageBox::warning( this, tr( "SpatiaLite Database" ), tr( "Unable to open the database: %1" ).arg( dbPath ) ); return false; } @@ -414,9 +405,7 @@ bool QgsNewSpatialiteLayerDialog::apply() rc = sqlite3_exec( database.get(), sql.toUtf8(), nullptr, nullptr, &errmsg ); if ( rc != SQLITE_OK ) { - QMessageBox::warning( this, - tr( "Error Creating SpatiaLite Table" ), - tr( "Failed to create the SpatiaLite table %1. The database returned:\n%2" ).arg( leLayerName->text(), errmsg ) ); + QMessageBox::warning( this, tr( "Error Creating SpatiaLite Table" ), tr( "Failed to create the SpatiaLite table %1. The database returned:\n%2" ).arg( leLayerName->text(), errmsg ) ); sqlite3_free( errmsg ); return false; } @@ -425,45 +414,35 @@ bool QgsNewSpatialiteLayerDialog::apply() if ( mGeometryTypeBox->currentIndex() != 0 ) { const QString sqlAddGeom = QStringLiteral( "select AddGeometryColumn(%1,%2,%3,%4,%5)" ) - .arg( QgsSqliteUtils::quotedString( leLayerName->text() ), - QgsSqliteUtils::quotedString( leGeometryColumn->text() ) ) - .arg( mCrsId.split( ':' ).value( 1, QStringLiteral( "0" ) ).toInt() ) - .arg( QgsSqliteUtils::quotedString( selectedType() ) ) - .arg( QgsSqliteUtils::quotedString( selectedZM() ) ); + .arg( QgsSqliteUtils::quotedString( leLayerName->text() ), QgsSqliteUtils::quotedString( leGeometryColumn->text() ) ) + .arg( mCrsId.split( ':' ).value( 1, QStringLiteral( "0" ) ).toInt() ) + .arg( QgsSqliteUtils::quotedString( selectedType() ) ) + .arg( QgsSqliteUtils::quotedString( selectedZM() ) ); QgsDebugMsgLevel( sqlAddGeom, 2 ); rc = sqlite3_exec( database.get(), sqlAddGeom.toUtf8(), nullptr, nullptr, &errmsg ); if ( rc != SQLITE_OK ) { - QMessageBox::warning( this, - tr( "Error Creating Geometry Column" ), - tr( "Failed to create the geometry column. The database returned:\n%1" ).arg( errmsg ) ); + QMessageBox::warning( this, tr( "Error Creating Geometry Column" ), tr( "Failed to create the geometry column. The database returned:\n%1" ).arg( errmsg ) ); sqlite3_free( errmsg ); return false; } const QString sqlCreateIndex = QStringLiteral( "select CreateSpatialIndex(%1,%2)" ) - .arg( QgsSqliteUtils::quotedString( leLayerName->text() ), - QgsSqliteUtils::quotedString( leGeometryColumn->text() ) ); + .arg( QgsSqliteUtils::quotedString( leLayerName->text() ), QgsSqliteUtils::quotedString( leGeometryColumn->text() ) ); QgsDebugMsgLevel( sqlCreateIndex, 2 ); rc = sqlite3_exec( database.get(), sqlCreateIndex.toUtf8(), nullptr, nullptr, &errmsg ); if ( rc != SQLITE_OK ) { - QMessageBox::warning( this, - tr( "Error Creating Spatial Index" ), - tr( "Failed to create the spatial index. The database returned:\n%1" ).arg( errmsg ) ); + QMessageBox::warning( this, tr( "Error Creating Spatial Index" ), tr( "Failed to create the spatial index. The database returned:\n%1" ).arg( errmsg ) ); sqlite3_free( errmsg ); return false; } } const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; - QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "%1 table='%2'%3 sql=" ) - .arg( mDatabaseComboBox->currentConnectionUri(), - leLayerName->text(), - mGeometryTypeBox->currentIndex() != 0 ? QStringLiteral( "(%1)" ).arg( leGeometryColumn->text() ) : QString() ), - leLayerName->text(), QStringLiteral( "spatialite" ), options ); + QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "%1 table='%2'%3 sql=" ).arg( mDatabaseComboBox->currentConnectionUri(), leLayerName->text(), mGeometryTypeBox->currentIndex() != 0 ? QStringLiteral( "(%1)" ).arg( leGeometryColumn->text() ) : QString() ), leLayerName->text(), QStringLiteral( "spatialite" ), options ); if ( layer->isValid() ) { // Reload connections to refresh browser panel diff --git a/src/app/qgsnewspatialitelayerdialog.h b/src/app/qgsnewspatialitelayerdialog.h index eef98fb1747c..db837a1b2096 100644 --- a/src/app/qgsnewspatialitelayerdialog.h +++ b/src/app/qgsnewspatialitelayerdialog.h @@ -31,7 +31,7 @@ extern "C" #include "qgis_app.h" } -class APP_EXPORT QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteLayerDialogBase +class APP_EXPORT QgsNewSpatialiteLayerDialog : public QDialog, private Ui::QgsNewSpatialiteLayerDialogBase { Q_OBJECT diff --git a/src/app/qgspluginmetadata.cpp b/src/app/qgspluginmetadata.cpp index 2a6c8494af74..db1c20f495cf 100644 --- a/src/app/qgspluginmetadata.cpp +++ b/src/app/qgspluginmetadata.cpp @@ -18,14 +18,11 @@ #include "../plugins/qgisplugin.h" #include "qgspluginmetadata.h" -QgsPluginMetadata::QgsPluginMetadata( const QString &_libraryPath, - const QString &_name, - QgisPlugin *_plugin ) +QgsPluginMetadata::QgsPluginMetadata( const QString &_libraryPath, const QString &_name, QgisPlugin *_plugin ) : m_name( _name ) , libraryPath( _libraryPath ) , m_plugin( _plugin ) { - } QString QgsPluginMetadata::name() const diff --git a/src/app/qgspluginmetadata.h b/src/app/qgspluginmetadata.h index 73b28d3575f9..d9df3ad4fb64 100644 --- a/src/app/qgspluginmetadata.h +++ b/src/app/qgspluginmetadata.h @@ -35,10 +35,10 @@ class APP_EXPORT QgsPluginMetadata QString name() const; QString library() const; QgisPlugin *plugin(); + private: QString m_name; QString libraryPath; QgisPlugin *m_plugin = nullptr; }; #endif //QGSPLUGINMETADATA_H - diff --git a/src/app/qgspluginregistry.cpp b/src/app/qgspluginregistry.cpp index 7ba6f1264d8d..35f1f7dac6ad 100644 --- a/src/app/qgspluginregistry.cpp +++ b/src/app/qgspluginregistry.cpp @@ -137,10 +137,7 @@ void QgsPluginRegistry::dump() it != mPlugins.constEnd(); ++it ) { - QgsDebugMsgLevel( QStringLiteral( "PLUGIN: %1 -> (%2, %3)" ) - .arg( it.key(), - it->name(), - it->library() ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "PLUGIN: %1 -> (%2, %3)" ).arg( it.key(), it->name(), it->library() ), 1 ); } #ifdef WITH_BINDINGS @@ -261,21 +258,15 @@ bool QgsPluginRegistry::checkQgisVersion( const QString &minVersion, const QStri if ( qgisMinor == 99 ) { // we want the API version, so for x.99 bump it up to the next major release: e.g. 2.99 to 3.0.0 - qgisMajor ++; + qgisMajor++; qgisMinor = 0; qgisBugfix = 0; }; // build XxYyZz strings with trailing zeroes if needed - const QString minVer = QStringLiteral( "%1%2%3" ).arg( minVerMajor, 2, 10, QChar( '0' ) ) - .arg( minVerMinor, 2, 10, QChar( '0' ) ) - .arg( minVerBugfix, 2, 10, QChar( '0' ) ); - const QString maxVer = QStringLiteral( "%1%2%3" ).arg( maxVerMajor, 2, 10, QChar( '0' ) ) - .arg( maxVerMinor, 2, 10, QChar( '0' ) ) - .arg( maxVerBugfix, 2, 10, QChar( '0' ) ); - const QString curVer = QStringLiteral( "%1%2%3" ).arg( qgisMajor, 2, 10, QChar( '0' ) ) - .arg( qgisMinor, 2, 10, QChar( '0' ) ) - .arg( qgisBugfix, 2, 10, QChar( '0' ) ); + const QString minVer = QStringLiteral( "%1%2%3" ).arg( minVerMajor, 2, 10, QChar( '0' ) ).arg( minVerMinor, 2, 10, QChar( '0' ) ).arg( minVerBugfix, 2, 10, QChar( '0' ) ); + const QString maxVer = QStringLiteral( "%1%2%3" ).arg( maxVerMajor, 2, 10, QChar( '0' ) ).arg( maxVerMinor, 2, 10, QChar( '0' ) ).arg( maxVerBugfix, 2, 10, QChar( '0' ) ); + const QString curVer = QStringLiteral( "%1%2%3" ).arg( qgisMajor, 2, 10, QChar( '0' ) ).arg( qgisMinor, 2, 10, QChar( '0' ) ).arg( qgisBugfix, 2, 10, QChar( '0' ) ); // compare return ( minVer <= curVer && maxVer >= curVer ); @@ -294,13 +285,12 @@ void QgsPluginRegistry::loadPythonPlugin( const QString &packageName ) QgsSettings settings; // is loaded already? - if ( ! isLoaded( packageName ) ) + if ( !isLoaded( packageName ) ) { // if plugin is not compatible, disable it - if ( ! isPythonPluginCompatible( packageName ) ) + if ( !isPythonPluginCompatible( packageName ) ) { - QgsMessageLog::logMessage( QObject::tr( "Plugin \"%1\" is not compatible with this version of QGIS.\nIt will be disabled." ).arg( packageName ), - QObject::tr( "Plugins" ) ); + QgsMessageLog::logMessage( QObject::tr( "Plugin \"%1\" is not compatible with this version of QGIS.\nIt will be disabled." ).arg( packageName ), QObject::tr( "Plugins" ) ); settings.setValue( "/PythonPlugins/" + packageName, false ); return; } @@ -407,10 +397,9 @@ void QgsPluginRegistry::loadCppPlugin( const QString &fullPathName ) else { // something went wrong - QMessageBox::warning( mQgisInterface->mainWindow(), QObject::tr( "Loading Plugins" ), - QObject::tr( "There was an error loading a plugin. " - "The following diagnostic information may help the QGIS developers resolve the issue:\n%1." ) - .arg( myError ) ); + QMessageBox::warning( mQgisInterface->mainWindow(), QObject::tr( "Loading Plugins" ), QObject::tr( "There was an error loading a plugin. " + "The following diagnostic information may help the QGIS developers resolve the issue:\n%1." ) + .arg( myError ) ); //disable it to the qsettings file [ts] settings.setValue( "/Plugins/" + baseName, false ); } @@ -419,7 +408,6 @@ void QgsPluginRegistry::loadCppPlugin( const QString &fullPathName ) { QgsMessageLog::logMessage( QObject::tr( "Unable to find the class factory for %1." ).arg( fullPathName ), QObject::tr( "Plugins" ) ); } - } break; default: @@ -489,7 +477,7 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString ) const QgsScopedRuntimeProfile profile( QObject::tr( "Load plugins" ) ); -#if defined(Q_OS_WIN) || defined(__CYGWIN__) +#if defined( Q_OS_WIN ) || defined( __CYGWIN__ ) QString pluginExt = "*.dll"; #elif ANDROID QString pluginExt = "*plugin.so"; @@ -523,8 +511,8 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString ) if ( pluginCrashedPreviously ) { QToolButton *btnEnablePlugin = new QToolButton(); - btnEnablePlugin ->setText( QObject::tr( "Enable Plugin" ) ); - btnEnablePlugin ->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); + btnEnablePlugin->setText( QObject::tr( "Enable Plugin" ) ); + btnEnablePlugin->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); QToolButton *btnIgnore = new QToolButton(); btnIgnore->setText( QObject::tr( "Ignore" ) ); @@ -536,19 +524,18 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString ) btnEnablePlugin, Qgis::MessageLevel::Warning, 0, - mQgisInterface->messageBar() ); + mQgisInterface->messageBar() + ); watchdogMsg->layout()->addWidget( btnIgnore ); - QObject::connect( btnEnablePlugin, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() - { + QObject::connect( btnEnablePlugin, &QToolButton::clicked, mQgisInterface->messageBar(), [=]() { QgsSettings settings; settings.setValue( "/Plugins/" + baseName, true ); loadCppPlugin( myFullPath ); settings.remove( QStringLiteral( "/Plugins/watchDogTimestamp/%1" ).arg( baseName ) ); mQgisInterface->messageBar()->popWidget( watchdogMsg ); } ); - QObject::connect( btnIgnore, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() - { + QObject::connect( btnIgnore, &QToolButton::clicked, mQgisInterface->messageBar(), [=]() { QgsSettings settings; settings.setValue( "/Plugins/" + baseName, false ); settings.remove( "/Plugins/watchDogTimestamp/" + baseName ); @@ -560,8 +547,7 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString ) } if ( mySettings.value( "/Plugins/" + baseName ).toBool() ) { - mySettings.setValue( QStringLiteral( "Plugins/watchDogTimestamp/%1" ).arg( baseName ), - QDateTime::currentDateTime().toSecsSinceEpoch() ); + mySettings.setValue( QStringLiteral( "Plugins/watchDogTimestamp/%1" ).arg( baseName ), QDateTime::currentDateTime().toSecsSinceEpoch() ); loadCppPlugin( myFullPath ); mySettings.remove( QStringLiteral( "/Plugins/watchDogTimestamp/%1" ).arg( baseName ) ); } @@ -638,11 +624,11 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString ) btnEnablePlugin, Qgis::MessageLevel::Warning, 0, - mQgisInterface->messageBar() ); + mQgisInterface->messageBar() + ); watchdogMsg->layout()->addWidget( btnIgnore ); - QObject::connect( btnEnablePlugin, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() - { + QObject::connect( btnEnablePlugin, &QToolButton::clicked, mQgisInterface->messageBar(), [=]() { QgsSettings settings; settings.setValue( "/PythonPlugins/" + packageName, true ); if ( checkPythonPlugin( packageName ) ) @@ -654,8 +640,7 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString ) mQgisInterface->messageBar()->popWidget( watchdogMsg ); } ); - QObject::connect( btnIgnore, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() - { + QObject::connect( btnIgnore, &QToolButton::clicked, mQgisInterface->messageBar(), [=]() { QgsSettings settings; settings.setValue( "/PythonPlugins/" + packageName, false ); settings.remove( "/PythonPlugins/watchDogTimestamp/" + packageName ); @@ -669,14 +654,12 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString ) // check if the plugin was active on last session if ( mySettings.value( "/PythonPlugins/" + packageName ).toBool() ) { - mySettings.setValue( "/PythonPlugins/watchDogTimestamp/" + packageName, - QDateTime::currentDateTime().toSecsSinceEpoch() ); + mySettings.setValue( "/PythonPlugins/watchDogTimestamp/" + packageName, QDateTime::currentDateTime().toSecsSinceEpoch() ); if ( checkPythonPlugin( packageName ) ) { loadPythonPlugin( packageName ); } mySettings.remove( "/PythonPlugins/watchDogTimestamp/" + packageName ); - } } // start - temporary fix for issue #5879, more above @@ -696,18 +679,18 @@ bool QgsPluginRegistry::checkCppPlugin( const QString &pluginFullPath ) { QLibrary myLib( pluginFullPath ); const bool loaded = myLib.load(); - if ( ! loaded ) + if ( !loaded ) { QgsMessageLog::logMessage( QObject::tr( "Failed to load %1 (Reason: %2)" ).arg( myLib.fileName(), myLib.errorString() ), QObject::tr( "Plugins" ) ); return false; } name_t *myName = ( name_t * ) cast_to_fptr( myLib.resolve( "name" ) ); - description_t *myDescription = ( description_t * ) cast_to_fptr( myLib.resolve( "description" ) ); - category_t *myCategory = ( category_t * ) cast_to_fptr( myLib.resolve( "category" ) ); - version_t *myVersion = ( version_t * ) cast_to_fptr( myLib.resolve( "version" ) ); + description_t *myDescription = ( description_t * ) cast_to_fptr( myLib.resolve( "description" ) ); + category_t *myCategory = ( category_t * ) cast_to_fptr( myLib.resolve( "category" ) ); + version_t *myVersion = ( version_t * ) cast_to_fptr( myLib.resolve( "version" ) ); - if ( myName && myDescription && myVersion && myCategory ) + if ( myName && myDescription && myVersion && myCategory ) return true; QgsDebugMsgLevel( "Failed to get name, description, category or type for " + myLib.fileName(), 2 ); @@ -722,16 +705,15 @@ bool QgsPluginRegistry::checkPythonPlugin( const QString &packageName ) // get information from the plugin // if there are some problems, don't continue with metadata retrieval - pluginName = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "name" ) ); + pluginName = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "name" ) ); description = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "description" ) ); - version = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "version" ) ); + version = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "version" ) ); // for Python plugins category still optional, by default used "Plugins" category //category = mPythonUtils->getPluginMetadata( packageName, "category" ); if ( pluginName == QLatin1String( "__error__" ) || description == QLatin1String( "__error__" ) || version == QLatin1String( "__error__" ) ) { - QgsMessageLog::logMessage( QObject::tr( "Error when reading metadata of plugin %1" ).arg( packageName ), - QObject::tr( "Plugins" ) ); + QgsMessageLog::logMessage( QObject::tr( "Error when reading metadata of plugin %1" ).arg( packageName ), QObject::tr( "Plugins" ) ); return false; } @@ -745,7 +727,7 @@ bool QgsPluginRegistry::checkPythonPlugin( const QString &packageName ) bool QgsPluginRegistry::isPythonPluginCompatible( const QString &packageName ) const { #ifdef WITH_BINDINGS -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) const QString supportsQt6 = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "supportsQt6" ) ).trimmed(); if ( supportsQt6.compare( QLatin1String( "YES" ), Qt::CaseInsensitive ) != 0 && supportsQt6.compare( QLatin1String( "TRUE" ), Qt::CaseInsensitive ) != 0 ) { diff --git a/src/app/qgspointmarkeritem.cpp b/src/app/qgspointmarkeritem.cpp index 4136afbb5518..ffca8631359e 100644 --- a/src/app/qgspointmarkeritem.cpp +++ b/src/app/qgspointmarkeritem.cpp @@ -94,7 +94,7 @@ void QgsMapCanvasSymbolItem::paint( QPainter *painter ) } } -void QgsMapCanvasSymbolItem::setSymbol( std::unique_ptr< QgsSymbol > symbol ) +void QgsMapCanvasSymbolItem::setSymbol( std::unique_ptr symbol ) { mSymbol = std::move( symbol ); } @@ -126,7 +126,7 @@ double QgsMapCanvasSymbolItem::opacity() const QgsMapCanvasMarkerSymbolItem::QgsMapCanvasMarkerSymbolItem( QgsMapCanvas *canvas ) : QgsMapCanvasSymbolItem( canvas ) { - setSymbol( std::make_unique< QgsMarkerSymbol >() ); + setSymbol( std::make_unique() ); } @@ -164,13 +164,12 @@ void QgsMapCanvasMarkerSymbolItem::updatePosition() QgsMarkerSymbol *QgsMapCanvasMarkerSymbolItem::markerSymbol() { - QgsMarkerSymbol *marker = dynamic_cast< QgsMarkerSymbol * >( mSymbol.get() ); + QgsMarkerSymbol *marker = dynamic_cast( mSymbol.get() ); Q_ASSERT( marker ); return marker; } - // // QgsLineMarkerItem // @@ -178,7 +177,7 @@ QgsMarkerSymbol *QgsMapCanvasMarkerSymbolItem::markerSymbol() QgsMapCanvasLineSymbolItem::QgsMapCanvasLineSymbolItem( QgsMapCanvas *canvas ) : QgsMapCanvasSymbolItem( canvas ) { - setSymbol( std::make_unique< QgsLineSymbol >() ); + setSymbol( std::make_unique() ); } void QgsMapCanvasLineSymbolItem::setLine( const QPolygonF &line ) @@ -206,9 +205,7 @@ void QgsMapCanvasLineSymbolItem::renderSymbol( QgsRenderContext &context, const QgsLineSymbol *QgsMapCanvasLineSymbolItem::lineSymbol() { - QgsLineSymbol *symbol = dynamic_cast< QgsLineSymbol * >( mSymbol.get() ); + QgsLineSymbol *symbol = dynamic_cast( mSymbol.get() ); Q_ASSERT( symbol ); return symbol; } - - diff --git a/src/app/qgspointmarkeritem.h b/src/app/qgspointmarkeritem.h index 574afae78754..4e569f95ffbb 100644 --- a/src/app/qgspointmarkeritem.h +++ b/src/app/qgspointmarkeritem.h @@ -33,10 +33,9 @@ class QgsLineSymbol; * \class QgsMapCanvasSymbolItem * \brief Base class for map canvas items which are rendered using a QgsSymbol. */ -class APP_EXPORT QgsMapCanvasSymbolItem: public QgsMapCanvasItem +class APP_EXPORT QgsMapCanvasSymbolItem : public QgsMapCanvasItem { public: - QgsMapCanvasSymbolItem( QgsMapCanvas *canvas = nullptr ); ~QgsMapCanvasSymbolItem() override; @@ -46,7 +45,7 @@ class APP_EXPORT QgsMapCanvasSymbolItem: public QgsMapCanvasItem * Sets the symbol to use for rendering the item. * \see symbol() */ - void setSymbol( std::unique_ptr< QgsSymbol > symbol ); + void setSymbol( std::unique_ptr symbol ); /** * Returns the symbol used for rendering the item. @@ -85,17 +84,14 @@ class APP_EXPORT QgsMapCanvasSymbolItem: public QgsMapCanvasItem double opacity() const; protected: - virtual void renderSymbol( QgsRenderContext &context, const QgsFeature &feature ) = 0; QgsRenderContext renderContext( QPainter *painter ); - std::unique_ptr< QgsSymbol > mSymbol; + std::unique_ptr mSymbol; QgsFeature mFeature; private: - - std::unique_ptr< QgsDrawSourceEffect > mOpacityEffect; - + std::unique_ptr mOpacityEffect; }; /** @@ -103,10 +99,9 @@ class APP_EXPORT QgsMapCanvasSymbolItem: public QgsMapCanvasItem * \class QgsMapCanvasMarkerSymbolItem * \brief An item that shows a point marker symbol centered on a map location. */ -class APP_EXPORT QgsMapCanvasMarkerSymbolItem: public QgsMapCanvasSymbolItem +class APP_EXPORT QgsMapCanvasMarkerSymbolItem : public QgsMapCanvasSymbolItem { public: - QgsMapCanvasMarkerSymbolItem( QgsMapCanvas *canvas = nullptr ); /** @@ -126,7 +121,6 @@ class APP_EXPORT QgsMapCanvasMarkerSymbolItem: public QgsMapCanvasSymbolItem void updatePosition() override; private: - QgsPointXY mMapLocation; QPointF mLocation; QRectF mCanvasBounds; @@ -139,10 +133,9 @@ class APP_EXPORT QgsMapCanvasMarkerSymbolItem: public QgsMapCanvasSymbolItem * \class QgsMapCanvasLineSymbolItem * \brief An item that shows a line symbol over the map. */ -class APP_EXPORT QgsMapCanvasLineSymbolItem: public QgsMapCanvasSymbolItem +class APP_EXPORT QgsMapCanvasLineSymbolItem : public QgsMapCanvasSymbolItem { public: - QgsMapCanvasLineSymbolItem( QgsMapCanvas *canvas = nullptr ); /** @@ -160,7 +153,6 @@ class APP_EXPORT QgsMapCanvasLineSymbolItem: public QgsMapCanvasSymbolItem void renderSymbol( QgsRenderContext &context, const QgsFeature &feature ) override; private: - QPolygonF mLine; QgsLineSymbol *lineSymbol(); diff --git a/src/app/qgspointrotationitem.cpp b/src/app/qgspointrotationitem.cpp index 3cbbd4212356..39d55a873223 100644 --- a/src/app/qgspointrotationitem.cpp +++ b/src/app/qgspointrotationitem.cpp @@ -47,7 +47,7 @@ void QgsPointRotationItem::paint( QPainter *painter ) if ( mPixmap.width() > 0 && mPixmap.height() > 0 ) { h = std::sqrt( ( double ) mPixmap.width() * mPixmap.width() + mPixmap.height() * mPixmap.height() ) / 2; //the half of the item diagonal - dAngel = std::acos( mPixmap.width() / ( h * 2 ) ) * 180 / M_PI; //the diagonal angel of the original rect + dAngel = std::acos( mPixmap.width() / ( h * 2 ) ) * 180 / M_PI; //the diagonal angel of the original rect x = h * std::cos( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 ); y = h * std::sin( ( painterRotation( mRotation ) - dAngel ) * M_PI / 180 ); } @@ -76,12 +76,8 @@ void QgsPointRotationItem::paint( QPainter *painter ) bufferPen.setWidthF( QgsGuiUtils::scaleIconSize( 4 ) ); const QFontMetricsF fm( mFont ); QPainterPath label; - const double rotationText = mRotation * QgsUnitTypes::fromUnitToUnitFactor( Qgis::AngleUnit::Degrees, - mRotationUnit ); - label.addText( mPixmap.width(), - mPixmap.height() / 2.0 + fm.height() / 2.0, - mFont, - QgsUnitTypes::formatAngle( rotationText, -1, mRotationUnit ) ); + const double rotationText = mRotation * QgsUnitTypes::fromUnitToUnitFactor( Qgis::AngleUnit::Degrees, mRotationUnit ); + label.addText( mPixmap.width(), mPixmap.height() / 2.0 + fm.height() / 2.0, mFont, QgsUnitTypes::formatAngle( rotationText, -1, mRotationUnit ) ); painter->setPen( bufferPen ); painter->setBrush( Qt::NoBrush ); painter->drawPath( label ); @@ -139,4 +135,3 @@ int QgsPointRotationItem::painterRotation( int rotation ) const return 360 - ( rotation % 360 ); } - diff --git a/src/app/qgspointrotationitem.h b/src/app/qgspointrotationitem.h index a07108985bc1..b04d8d1d06a2 100644 --- a/src/app/qgspointrotationitem.h +++ b/src/app/qgspointrotationitem.h @@ -23,10 +23,9 @@ #include "qgis_app.h" //! An item that shows a rotated point symbol (e.g. arrow) centered to a map location together with a text displaying the rotation value -class APP_EXPORT QgsPointRotationItem: public QgsMapCanvasItem +class APP_EXPORT QgsPointRotationItem : public QgsMapCanvasItem { public: - enum Orientation { Clockwise = 0, @@ -44,7 +43,7 @@ class APP_EXPORT QgsPointRotationItem: public QgsMapCanvasItem * Sets the rotation of the symbol. * Units are degrees, starting from north direction, clockwise direction. */ - void setSymbolRotation( int r ) {mRotation = r;} + void setSymbolRotation( int r ) { mRotation = r; } /** * Sets the rotation unit. @@ -59,7 +58,6 @@ class APP_EXPORT QgsPointRotationItem: public QgsMapCanvasItem Orientation orientation() const { return mOrientation; } private: - //! Converts rotation into QPainter rotation considering mOrientation int painterRotation( int rotation ) const; //! Clockwise (default) or counterclockwise diff --git a/src/app/qgsprojectlayergroupdialog.cpp b/src/app/qgsprojectlayergroupdialog.cpp index 0f3a8558d273..6d1b716815cd 100644 --- a/src/app/qgsprojectlayergroupdialog.cpp +++ b/src/app/qgsprojectlayergroupdialog.cpp @@ -44,7 +44,6 @@ QVariant QgsEmbeddedLayerTreeModel::data( const QModelIndex &index, int role ) c } - QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget *parent, const QString &projectFile, Qt::WindowFlags f ) : QDialog( parent, f ) , mRootGroup( new QgsLayerTree ) @@ -85,7 +84,6 @@ QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget *parent, const Q QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( const QgsProject *project, QWidget *parent, Qt::WindowFlags f ) : QDialog( parent, f ) { - // Preconditions Q_ASSERT( project ); Q_ASSERT( project->layerTreeRoot() ); @@ -106,7 +104,6 @@ QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( const QgsProject *projec connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsProjectLayerGroupDialog::mButtonBox_accepted ); connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject ); connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsProjectLayerGroupDialog::showHelp ); - } QgsProjectLayerGroupDialog::~QgsProjectLayerGroupDialog() @@ -160,7 +157,7 @@ QString QgsProjectLayerGroupDialog::selectedProjectFile() const bool QgsProjectLayerGroupDialog::isValid() const { - return static_cast< bool >( mTreeView->layerTreeModel() ); + return static_cast( mTreeView->layerTreeModel() ); } void QgsProjectLayerGroupDialog::changeProjectFile() @@ -195,7 +192,6 @@ void QgsProjectLayerGroupDialog::changeProjectFile() QDomDocument projectDom; if ( QgsZipUtils::isZipFile( mProjectFileWidget->filePath() ) ) { - archive = std::make_unique(); // unzip the archive @@ -221,9 +217,9 @@ void QgsProjectLayerGroupDialog::changeProjectFile() if ( !projectDom.setContent( &projectFile, &errorMessage, &errorLine ) ) { QgsDebugError( QStringLiteral( "Error reading the project file %1 at line %2: %3" ) - .arg( projectFile.fileName() ) - .arg( errorLine ) - .arg( errorMessage ) ); + .arg( projectFile.fileName() ) + .arg( errorLine ) + .arg( errorMessage ) ); return; } @@ -234,7 +230,7 @@ void QgsProjectLayerGroupDialog::changeProjectFile() { // Use a temporary tree to read the nodes to prevent signals being delivered to the models QgsLayerTree tempTree; - tempTree.readChildrenFromXml( layerTreeElem, QgsReadWriteContext() ); + tempTree.readChildrenFromXml( layerTreeElem, QgsReadWriteContext() ); mRootGroup->insertChildNodes( -1, tempTree.abandonChildren() ); } else @@ -308,5 +304,4 @@ void QgsProjectLayerGroupDialog::mButtonBox_accepted() void QgsProjectLayerGroupDialog::showHelp() { QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#nesting-projects" ) ); - } diff --git a/src/app/qgsprojectlayergroupdialog.h b/src/app/qgsprojectlayergroupdialog.h index 271041f0c8bf..465daf34c4b1 100644 --- a/src/app/qgsprojectlayergroupdialog.h +++ b/src/app/qgsprojectlayergroupdialog.h @@ -33,7 +33,6 @@ class QgsEmbeddedLayerTreeModel : public QgsLayerTreeModel { Q_OBJECT public: - /** * Construct a new tree model with given layer tree (root node must not be NULLPTR). * The root node is not transferred by the model. @@ -54,11 +53,10 @@ class QgsEmbeddedLayerTreeModel : public QgsLayerTreeModel * * In the second case, the file selection dialog is hidden. */ -class APP_EXPORT QgsProjectLayerGroupDialog: public QDialog, private Ui::QgsProjectLayerGroupDialogBase +class APP_EXPORT QgsProjectLayerGroupDialog : public QDialog, private Ui::QgsProjectLayerGroupDialogBase { Q_OBJECT public: - //! Constructor. If a project file is given, the groups/layers are displayed directly and the file selection hidden QgsProjectLayerGroupDialog( QWidget *parent = nullptr, const QString &projectFile = QString(), Qt::WindowFlags f = Qt::WindowFlags() ); diff --git a/src/app/qgsprojectlistitemdelegate.cpp b/src/app/qgsprojectlistitemdelegate.cpp index 1da2daa95811..b1b2434bed3e 100644 --- a/src/app/qgsprojectlistitemdelegate.cpp +++ b/src/app/qgsprojectlistitemdelegate.cpp @@ -30,7 +30,6 @@ QgsProjectListItemDelegate::QgsProjectListItemDelegate( QObject *parent ) : QStyledItemDelegate( parent ) , mRoundedRectSizePixels( static_cast( Qgis::UI_SCALE_FACTOR * QApplication::fontMetrics().height() * 0.5 ) ) { - } void QgsProjectListItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const @@ -72,8 +71,7 @@ void QgsProjectListItemDelegate::paint( QPainter *painter, const QStyleOptionVie painter->setRenderHint( QPainter::SmoothPixmapTransform, true ); painter->setPen( QColor( 0, 0, 0, 0 ) ); painter->setBrush( QBrush( color ) ); - painter->drawRoundedRect( option.rect.left() + 0.625 * mRoundedRectSizePixels, option.rect.top() + 0.625 * mRoundedRectSizePixels, - option.rect.width() - 2 * 0.625 * mRoundedRectSizePixels, option.rect.height() - 2 * 0.625 * mRoundedRectSizePixels, mRoundedRectSizePixels, mRoundedRectSizePixels ); + painter->drawRoundedRect( option.rect.left() + 0.625 * mRoundedRectSizePixels, option.rect.top() + 0.625 * mRoundedRectSizePixels, option.rect.width() - 2 * 0.625 * mRoundedRectSizePixels, option.rect.height() - 2 * 0.625 * mRoundedRectSizePixels, mRoundedRectSizePixels, mRoundedRectSizePixels ); const int titleSize = static_cast( QApplication::fontMetrics().height() * 1.1 ); const int textSize = static_cast( titleSize * 0.85 ); @@ -83,21 +81,16 @@ void QgsProjectListItemDelegate::paint( QPainter *painter, const QStyleOptionVie iconSize /= w->devicePixelRatioF(); } - doc.setHtml( QStringLiteral( "

    %3%4
    %5
    %6
    " ).arg( textSize ).arg( QString::number( titleSize ), - index.data( QgsProjectListItemDelegate::TitleRole ).toString(), - index.data( QgsProjectListItemDelegate::PinRole ).toBool() ? QStringLiteral( "" ) : QString(), - mShowPath ? index.data( QgsProjectListItemDelegate::AnonymisedNativePathRole ).toString() : QString(), - index.data( QgsProjectListItemDelegate::CrsRole ).toString() ) ); + doc.setHtml( QStringLiteral( "
    %3%4
    %5
    %6
    " ).arg( textSize ).arg( QString::number( titleSize ), index.data( QgsProjectListItemDelegate::TitleRole ).toString(), index.data( QgsProjectListItemDelegate::PinRole ).toBool() ? QStringLiteral( "" ) : QString(), mShowPath ? index.data( QgsProjectListItemDelegate::AnonymisedNativePathRole ).toString() : QString(), index.data( QgsProjectListItemDelegate::CrsRole ).toString() ) ); doc.setTextWidth( option.rect.width() - ( !icon.isNull() ? iconSize.width() + 4.375 * mRoundedRectSizePixels : 4.375 * mRoundedRectSizePixels ) ); if ( !icon.isNull() ) { - painter->drawPixmap( option.rect.left() + 1.25 * mRoundedRectSizePixels, option.rect.top() + 1.25 * mRoundedRectSizePixels, - iconSize.width(), iconSize.height(), icon ); + painter->drawPixmap( option.rect.left() + 1.25 * mRoundedRectSizePixels, option.rect.top() + 1.25 * mRoundedRectSizePixels, iconSize.width(), iconSize.height(), icon ); } painter->translate( option.rect.left() + ( !icon.isNull() ? iconSize.width() + 3.125 * mRoundedRectSizePixels : 1.875 * mRoundedRectSizePixels ), option.rect.top() + 1.875 * mRoundedRectSizePixels ); - ctx.clip = QRectF( 0, 0, option.rect.width() - ( !icon.isNull() ? iconSize.width() - 4.375 * mRoundedRectSizePixels : 3.125 * mRoundedRectSizePixels ), option.rect.height() - 3.125 * mRoundedRectSizePixels ); + ctx.clip = QRectF( 0, 0, option.rect.width() - ( !icon.isNull() ? iconSize.width() - 4.375 * mRoundedRectSizePixels : 3.125 * mRoundedRectSizePixels ), option.rect.height() - 3.125 * mRoundedRectSizePixels ); doc.documentLayout()->draw( painter, ctx ); } @@ -124,11 +117,7 @@ QSize QgsProjectListItemDelegate::sizeHint( const QStyleOptionViewItem &option, const int titleSize = QApplication::fontMetrics().height() * 1.1; const int textSize = titleSize * 0.85; - doc.setHtml( QStringLiteral( "
    %3%4
    %5
    %6
    " ).arg( textSize ).arg( titleSize ) - .arg( index.data( QgsProjectListItemDelegate::TitleRole ).toString(), - index.data( QgsProjectListItemDelegate::PinRole ).toBool() ? QStringLiteral( "" ) : QString(), - index.data( QgsProjectListItemDelegate::NativePathRole ).toString(), - index.data( QgsProjectListItemDelegate::CrsRole ).toString() ) ); + doc.setHtml( QStringLiteral( "
    %3%4
    %5
    %6
    " ).arg( textSize ).arg( titleSize ).arg( index.data( QgsProjectListItemDelegate::TitleRole ).toString(), index.data( QgsProjectListItemDelegate::PinRole ).toBool() ? QStringLiteral( "" ) : QString(), index.data( QgsProjectListItemDelegate::NativePathRole ).toString(), index.data( QgsProjectListItemDelegate::CrsRole ).toString() ) ); doc.setTextWidth( width - ( !icon.isNull() ? iconSize.width() + 4.375 * mRoundedRectSizePixels : 4.375 * mRoundedRectSizePixels ) ); return QSize( width, std::max( ( double ) doc.size().height() + 1.25 * mRoundedRectSizePixels, static_cast( iconSize.height() ) ) + 2.5 * mRoundedRectSizePixels ); @@ -196,7 +185,6 @@ QgsNewsItemListItemDelegate::QgsNewsItemListItemDelegate( QObject *parent ) , mRoundedRectSizePixels( static_cast( Qgis::UI_SCALE_FACTOR * QApplication::fontMetrics().height() * 0.5 ) ) , mDismissRectSize( 20, 20 ) // TODO - hidpi friendly { - } void QgsNewsItemListItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const @@ -238,8 +226,7 @@ void QgsNewsItemListItemDelegate::paint( QPainter *painter, const QStyleOptionVi painter->setRenderHint( QPainter::SmoothPixmapTransform, true ); painter->setPen( QColor( 0, 0, 0, 0 ) ); painter->setBrush( QBrush( color ) ); - painter->drawRoundedRect( option.rect.left() + 0.625 * mRoundedRectSizePixels, option.rect.top() + 0.625 * mRoundedRectSizePixels, - option.rect.width() - 2 * 0.625 * mRoundedRectSizePixels, option.rect.height() - 2 * 0.625 * mRoundedRectSizePixels, mRoundedRectSizePixels, mRoundedRectSizePixels ); + painter->drawRoundedRect( option.rect.left() + 0.625 * mRoundedRectSizePixels, option.rect.top() + 0.625 * mRoundedRectSizePixels, option.rect.width() - 2 * 0.625 * mRoundedRectSizePixels, option.rect.height() - 2 * 0.625 * mRoundedRectSizePixels, mRoundedRectSizePixels, mRoundedRectSizePixels ); const int titleSize = static_cast( QApplication::fontMetrics().height() * 1.1 ); const int textSize = static_cast( titleSize * 0.85 ); @@ -249,18 +236,14 @@ void QgsNewsItemListItemDelegate::paint( QPainter *painter, const QStyleOptionVi iconSize /= w->devicePixelRatioF(); } - doc.setHtml( QStringLiteral( "
    %3%4%5
    " ).arg( textSize ).arg( QString::number( titleSize ), - index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), - index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool() ? QStringLiteral( "" ) : QString(), - index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Content ) ).toString() ) ); + doc.setHtml( QStringLiteral( "
    %3%4%5
    " ).arg( textSize ).arg( QString::number( titleSize ), index.data( static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), index.data( static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool() ? QStringLiteral( "" ) : QString(), index.data( static_cast( QgsNewsFeedModel::CustomRole::Content ) ).toString() ) ); doc.setTextWidth( option.rect.width() - ( !icon.isNull() ? iconSize.width() + 4.375 * mRoundedRectSizePixels : 4.375 * mRoundedRectSizePixels ) ); if ( !icon.isNull() ) { - painter->drawPixmap( option.rect.left() + 1.25 * mRoundedRectSizePixels, option.rect.top() + 1.25 * mRoundedRectSizePixels, - iconSize.width(), iconSize.height(), icon ); + painter->drawPixmap( option.rect.left() + 1.25 * mRoundedRectSizePixels, option.rect.top() + 1.25 * mRoundedRectSizePixels, iconSize.width(), iconSize.height(), icon ); } // Gross, but not well supported in Qt @@ -270,7 +253,7 @@ void QgsNewsItemListItemDelegate::paint( QPainter *painter, const QStyleOptionVi mDismissRect.setTop( 10 ); painter->translate( option.rect.left() + ( !icon.isNull() ? iconSize.width() + 3.125 * mRoundedRectSizePixels : 1.875 * mRoundedRectSizePixels ), option.rect.top() + 1.875 * mRoundedRectSizePixels ); - ctx.clip = QRectF( 0, 0, option.rect.width() - ( !icon.isNull() ? iconSize.width() - 4.375 * mRoundedRectSizePixels : 3.125 * mRoundedRectSizePixels ), option.rect.height() - 3.125 * mRoundedRectSizePixels ); + ctx.clip = QRectF( 0, 0, option.rect.width() - ( !icon.isNull() ? iconSize.width() - 4.375 * mRoundedRectSizePixels : 3.125 * mRoundedRectSizePixels ), option.rect.height() - 3.125 * mRoundedRectSizePixels ); doc.documentLayout()->draw( painter, ctx ); } @@ -296,13 +279,8 @@ QSize QgsNewsItemListItemDelegate::sizeHint( const QStyleOptionViewItem &option, const int titleSize = QApplication::fontMetrics().height() * 1.1; const int textSize = titleSize * 0.85; - doc.setHtml( QStringLiteral( "
    %3%4%5
    " ).arg( textSize ).arg( QString::number( titleSize ), - index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), - index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool() ? QStringLiteral( "" ) : QString(), - index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Content ) ).toString() ) ); + doc.setHtml( QStringLiteral( "
    %3%4%5
    " ).arg( textSize ).arg( QString::number( titleSize ), index.data( static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), index.data( static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool() ? QStringLiteral( "" ) : QString(), index.data( static_cast( QgsNewsFeedModel::CustomRole::Content ) ).toString() ) ); doc.setTextWidth( width - ( !icon.isNull() ? iconSize.width() + 4.375 * mRoundedRectSizePixels : 4.375 * mRoundedRectSizePixels ) ); return QSize( width, std::max( ( double ) doc.size().height() + 1.25 * mRoundedRectSizePixels, static_cast( iconSize.height() ) ) + 2.5 * mRoundedRectSizePixels ); } - - diff --git a/src/app/qgsprojectlistitemdelegate.h b/src/app/qgsprojectlistitemdelegate.h index becf3209610e..99acf7caabbb 100644 --- a/src/app/qgsprojectlistitemdelegate.h +++ b/src/app/qgsprojectlistitemdelegate.h @@ -58,7 +58,6 @@ class QgsProjectListItemDelegate : public QStyledItemDelegate void setShowPath( bool value ); private: - int mRoundedRectSizePixels = 5; bool mShowPath = true; QColor mColor = Qt::white; @@ -69,7 +68,6 @@ class QgsNewsItemListItemDelegate : public QStyledItemDelegate Q_OBJECT public: - explicit QgsNewsItemListItemDelegate( QObject *parent = nullptr ); void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override; @@ -82,7 +80,6 @@ class QgsNewsItemListItemDelegate : public QStyledItemDelegate QSize dismissRectSize() const { return mDismissRectSize; } private: - int mRoundedRectSizePixels = 5; QColor mColor = Qt::white; mutable QRect mDismissRect; diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp index 480e26dd3303..31c7b5dbf996 100644 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -134,9 +134,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa connect( mButtonAddStyleDatabase, &QAbstractButton::clicked, this, &QgsProjectProperties::addStyleDatabase ); connect( mButtonRemoveStyleDatabase, &QAbstractButton::clicked, this, &QgsProjectProperties::removeStyleDatabase ); connect( mButtonNewStyleDatabase, &QAbstractButton::clicked, this, &QgsProjectProperties::newStyleDatabase ); - connect( mCoordinateDisplayComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int ) { updateGuiForCoordinateType(); } ); - connect( mCoordinateCrs, &QgsProjectionSelectionWidget::crsChanged, this, [ = ]( const QgsCoordinateReferenceSystem & ) { updateGuiForCoordinateCrs(); } ); -#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) + connect( mCoordinateDisplayComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { updateGuiForCoordinateType(); } ); + connect( mCoordinateCrs, &QgsProjectionSelectionWidget::crsChanged, this, [=]( const QgsCoordinateReferenceSystem & ) { updateGuiForCoordinateCrs(); } ); +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) connect( mAddIccProfile, &QToolButton::clicked, this, static_cast( &QgsProjectProperties::addIccProfile ) ); connect( mRemoveIccProfile, &QToolButton::clicked, this, &QgsProjectProperties::removeIccProfile ); connect( mSaveIccProfile, &QToolButton::clicked, this, &QgsProjectProperties::saveIccProfile ); @@ -166,53 +166,52 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa mCoordinateDisplayComboBox->addItem( tr( "Map Geographic (degrees)" ), static_cast( Qgis::CoordinateDisplayType::MapGeographic ) ); mCoordinateDisplayComboBox->addItem( tr( "Custom Projection Units" ), static_cast( Qgis::CoordinateDisplayType::CustomCrs ) ); - mCoordinateOrderComboBox->addItem( tr( "Default" ), static_cast< int >( Qgis::CoordinateOrder::Default ) ); - mCoordinateOrderComboBox->addItem( tr( "Easting, Northing (Longitude, Latitude)" ), static_cast< int >( Qgis::CoordinateOrder::XY ) ); - mCoordinateOrderComboBox->addItem( tr( "Northing, Easting (Latitude, Longitude)" ), static_cast< int >( Qgis::CoordinateOrder::YX ) ); - - mDistanceUnitsCombo->addItem( tr( "Meters" ), static_cast< int >( Qgis::DistanceUnit::Meters ) ); - mDistanceUnitsCombo->addItem( tr( "Kilometers" ), static_cast< int >( Qgis::DistanceUnit::Kilometers ) ); - mDistanceUnitsCombo->addItem( tr( "Feet" ), static_cast< int >( Qgis::DistanceUnit::Feet ) ); - mDistanceUnitsCombo->addItem( tr( "Yards" ), static_cast< int >( Qgis::DistanceUnit::Yards ) ); - mDistanceUnitsCombo->addItem( tr( "Miles" ), static_cast< int >( Qgis::DistanceUnit::Miles ) ); - mDistanceUnitsCombo->addItem( tr( "Nautical Miles" ), static_cast< int >( Qgis::DistanceUnit::NauticalMiles ) ); - mDistanceUnitsCombo->addItem( tr( "Centimeters" ), static_cast< int >( Qgis::DistanceUnit::Centimeters ) ); - mDistanceUnitsCombo->addItem( tr( "Millimeters" ), static_cast< int >( Qgis::DistanceUnit::Millimeters ) ); - mDistanceUnitsCombo->addItem( tr( "Inches" ), static_cast< int >( Qgis::DistanceUnit::Inches ) ); - mDistanceUnitsCombo->addItem( tr( "Degrees" ), static_cast< int >( Qgis::DistanceUnit::Degrees ) ); - mDistanceUnitsCombo->addItem( tr( "Map Units" ), static_cast< int >( Qgis::DistanceUnit::Unknown ) ); - - mAreaUnitsCombo->addItem( tr( "Square Meters" ), static_cast< int >( Qgis::AreaUnit::SquareMeters ) ); - mAreaUnitsCombo->addItem( tr( "Square Kilometers" ), static_cast< int >( Qgis::AreaUnit::SquareKilometers ) ); - mAreaUnitsCombo->addItem( tr( "Square Feet" ), static_cast< int >( Qgis::AreaUnit::SquareFeet ) ); - mAreaUnitsCombo->addItem( tr( "Square Yards" ), static_cast< int >( Qgis::AreaUnit::SquareYards ) ); - mAreaUnitsCombo->addItem( tr( "Square Miles" ), static_cast< int >( Qgis::AreaUnit::SquareMiles ) ); - mAreaUnitsCombo->addItem( tr( "Hectares" ), static_cast< int >( Qgis::AreaUnit::Hectares ) ); - mAreaUnitsCombo->addItem( tr( "Acres" ), static_cast< int >( Qgis::AreaUnit::Acres ) ); - mAreaUnitsCombo->addItem( tr( "Square Nautical Miles" ), static_cast< int >( Qgis::AreaUnit::SquareNauticalMiles ) ); - mAreaUnitsCombo->addItem( tr( "Square Centimeters" ), static_cast< int >( Qgis::AreaUnit::SquareCentimeters ) ); - mAreaUnitsCombo->addItem( tr( "Square Millimeters" ), static_cast< int >( Qgis::AreaUnit::SquareMillimeters ) ); - mAreaUnitsCombo->addItem( tr( "Square Inches" ), static_cast< int >( Qgis::AreaUnit::SquareInches ) ); - mAreaUnitsCombo->addItem( tr( "Square Degrees" ), static_cast< int >( Qgis::AreaUnit::SquareDegrees ) ); - mAreaUnitsCombo->addItem( tr( "Map Units" ), static_cast< int >( Qgis::AreaUnit::Unknown ) ); - - mTransactionModeComboBox->addItem( tr( "Local Edit Buffer" ), static_cast< int >( Qgis::TransactionMode::Disabled ) ); + mCoordinateOrderComboBox->addItem( tr( "Default" ), static_cast( Qgis::CoordinateOrder::Default ) ); + mCoordinateOrderComboBox->addItem( tr( "Easting, Northing (Longitude, Latitude)" ), static_cast( Qgis::CoordinateOrder::XY ) ); + mCoordinateOrderComboBox->addItem( tr( "Northing, Easting (Latitude, Longitude)" ), static_cast( Qgis::CoordinateOrder::YX ) ); + + mDistanceUnitsCombo->addItem( tr( "Meters" ), static_cast( Qgis::DistanceUnit::Meters ) ); + mDistanceUnitsCombo->addItem( tr( "Kilometers" ), static_cast( Qgis::DistanceUnit::Kilometers ) ); + mDistanceUnitsCombo->addItem( tr( "Feet" ), static_cast( Qgis::DistanceUnit::Feet ) ); + mDistanceUnitsCombo->addItem( tr( "Yards" ), static_cast( Qgis::DistanceUnit::Yards ) ); + mDistanceUnitsCombo->addItem( tr( "Miles" ), static_cast( Qgis::DistanceUnit::Miles ) ); + mDistanceUnitsCombo->addItem( tr( "Nautical Miles" ), static_cast( Qgis::DistanceUnit::NauticalMiles ) ); + mDistanceUnitsCombo->addItem( tr( "Centimeters" ), static_cast( Qgis::DistanceUnit::Centimeters ) ); + mDistanceUnitsCombo->addItem( tr( "Millimeters" ), static_cast( Qgis::DistanceUnit::Millimeters ) ); + mDistanceUnitsCombo->addItem( tr( "Inches" ), static_cast( Qgis::DistanceUnit::Inches ) ); + mDistanceUnitsCombo->addItem( tr( "Degrees" ), static_cast( Qgis::DistanceUnit::Degrees ) ); + mDistanceUnitsCombo->addItem( tr( "Map Units" ), static_cast( Qgis::DistanceUnit::Unknown ) ); + + mAreaUnitsCombo->addItem( tr( "Square Meters" ), static_cast( Qgis::AreaUnit::SquareMeters ) ); + mAreaUnitsCombo->addItem( tr( "Square Kilometers" ), static_cast( Qgis::AreaUnit::SquareKilometers ) ); + mAreaUnitsCombo->addItem( tr( "Square Feet" ), static_cast( Qgis::AreaUnit::SquareFeet ) ); + mAreaUnitsCombo->addItem( tr( "Square Yards" ), static_cast( Qgis::AreaUnit::SquareYards ) ); + mAreaUnitsCombo->addItem( tr( "Square Miles" ), static_cast( Qgis::AreaUnit::SquareMiles ) ); + mAreaUnitsCombo->addItem( tr( "Hectares" ), static_cast( Qgis::AreaUnit::Hectares ) ); + mAreaUnitsCombo->addItem( tr( "Acres" ), static_cast( Qgis::AreaUnit::Acres ) ); + mAreaUnitsCombo->addItem( tr( "Square Nautical Miles" ), static_cast( Qgis::AreaUnit::SquareNauticalMiles ) ); + mAreaUnitsCombo->addItem( tr( "Square Centimeters" ), static_cast( Qgis::AreaUnit::SquareCentimeters ) ); + mAreaUnitsCombo->addItem( tr( "Square Millimeters" ), static_cast( Qgis::AreaUnit::SquareMillimeters ) ); + mAreaUnitsCombo->addItem( tr( "Square Inches" ), static_cast( Qgis::AreaUnit::SquareInches ) ); + mAreaUnitsCombo->addItem( tr( "Square Degrees" ), static_cast( Qgis::AreaUnit::SquareDegrees ) ); + mAreaUnitsCombo->addItem( tr( "Map Units" ), static_cast( Qgis::AreaUnit::Unknown ) ); + + mTransactionModeComboBox->addItem( tr( "Local Edit Buffer" ), static_cast( Qgis::TransactionMode::Disabled ) ); mTransactionModeComboBox->setItemData( mTransactionModeComboBox->count() - 1, tr( "Edits are buffered locally and sent to the provider when toggling layer editing mode." ), Qt::ToolTipRole ); - mTransactionModeComboBox->addItem( tr( "Automatic Transaction Groups" ), static_cast< int >( Qgis::TransactionMode::AutomaticGroups ) ); + mTransactionModeComboBox->addItem( tr( "Automatic Transaction Groups" ), static_cast( Qgis::TransactionMode::AutomaticGroups ) ); mTransactionModeComboBox->setItemData( mTransactionModeComboBox->count() - 1, tr( "Automatic transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction." ), Qt::ToolTipRole ); - mTransactionModeComboBox->addItem( tr( "Buffered Transaction Groups" ), static_cast< int >( Qgis::TransactionMode::BufferedGroups ) ); + mTransactionModeComboBox->addItem( tr( "Buffered Transaction Groups" ), static_cast( Qgis::TransactionMode::BufferedGroups ) ); mTransactionModeComboBox->setItemData( mTransactionModeComboBox->count() - 1, tr( "Buffered transactional editing means that all editable layers in the buffered transaction group are toggled synchronously and all edits are saved in a local edit buffer. Saving changes is executed within a single transaction on all layers (per provider)." ), Qt::ToolTipRole ); projectionSelector->setShowNoProjection( true ); connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsProjectProperties::apply ); - connect( this, &QDialog::finished, this, [ = ]( int result ) { if ( result == QDialog::Rejected ) cancel(); } ); + connect( this, &QDialog::finished, this, [=]( int result ) { if ( result == QDialog::Rejected ) cancel(); } ); // disconnect default connection setup by initOptionsBase for accepting dialog, and insert logic // to validate widgets before allowing dialog to be closed disconnect( mOptButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept ); - connect( mOptButtonBox, &QDialogButtonBox::accepted, this, [ = ] - { + connect( mOptButtonBox, &QDialogButtonBox::accepted, this, [=] { for ( QgsOptionsPageWidget *widget : std::as_const( mAdditionalProjectPropertiesWidgets ) ) { if ( !widget->isValid() ) @@ -225,8 +224,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa accept(); } ); - connect( projectionSelector, &QgsProjectionSelectionTreeWidget::crsSelected, this, [ = ] - { + connect( projectionSelector, &QgsProjectionSelectionTreeWidget::crsSelected, this, [=] { if ( mBlockCrsUpdates || !projectionSelector->hasValidSelection() ) return; @@ -264,12 +262,10 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa QgsGeometry g = QgsGeometry::fromQPolygonF( mainCanvasPoly ); // close polygon mainCanvasPoly << mainCanvasPoly.at( 0 ); - if ( QgsProject::instance()->crs() != - QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) ) + if ( QgsProject::instance()->crs() != QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) ) { // reproject extent - QgsCoordinateTransform ct( QgsProject::instance()->crs(), - QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), QgsProject::instance() ); + QgsCoordinateTransform ct( QgsProject::instance()->crs(), QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), QgsProject::instance() ); ct.setBallparkTransformsAreAppropriate( true ); g = g.densifyByCount( 5 ); @@ -323,10 +319,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa mProjectHomeLineEdit->setShowClearButton( true ); mProjectHomeLineEdit->setText( QDir::toNativeSeparators( QgsProject::instance()->presetHomePath() ) ); - connect( mButtonSetProjectHome, &QToolButton::clicked, this, [ = ] - { - auto getAbsoluteHome = [this]()->QString - { + connect( mButtonSetProjectHome, &QToolButton::clicked, this, [=] { + auto getAbsoluteHome = [this]() -> QString { QString currentHome = QDir::fromNativeSeparators( mProjectHomeLineEdit->text() ); if ( !currentHome.isEmpty() ) { @@ -351,14 +345,13 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa }; QString newDir = QFileDialog::getExistingDirectory( this, tr( "Select Project Home Path" ), getAbsoluteHome() ); - if ( ! newDir.isNull() ) + if ( !newDir.isNull() ) { mProjectHomeLineEdit->setText( QDir::toNativeSeparators( newDir ) ); } } ); - connect( mButtonOpenProjectFolder, &QToolButton::clicked, this, [ = ] - { + connect( mButtonOpenProjectFolder, &QToolButton::clicked, this, [=] { QString path; QString project = !QgsProject::instance()->fileName().isEmpty() ? QgsProject::instance()->fileName() : QgsProject::instance()->originalPath(); QgsProjectStorage *storage = QgsProject::instance()->projectStorage(); @@ -371,7 +364,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa { QgsGui::nativePlatformInterface()->openFileExplorerAndSelectFile( path ); } - } ); // get the manner in which the number of decimal places in the mouse @@ -392,9 +384,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa int dp = QgsProject::instance()->readNumEntry( QStringLiteral( "PositionPrecision" ), QStringLiteral( "/DecimalPlaces" ) ); spinBoxDP->setValue( dp ); - cbxAbsolutePath->addItem( tr( "Absolute" ), static_cast< int >( Qgis::FilePathType::Absolute ) ); - cbxAbsolutePath->addItem( tr( "Relative" ), static_cast< int >( Qgis::FilePathType::Relative ) ); - cbxAbsolutePath->setCurrentIndex( cbxAbsolutePath->findData( static_cast< int >( QgsProject::instance()->filePathStorage() ) ) ); + cbxAbsolutePath->addItem( tr( "Absolute" ), static_cast( Qgis::FilePathType::Absolute ) ); + cbxAbsolutePath->addItem( tr( "Relative" ), static_cast( Qgis::FilePathType::Relative ) ); + cbxAbsolutePath->setCurrentIndex( cbxAbsolutePath->findData( static_cast( QgsProject::instance()->filePathStorage() ) ) ); // populate combo box with ellipsoids // selection of the ellipsoid from settings is deferred to a later point, because it would @@ -412,7 +404,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa for ( int i = 0; i < mEllipsoidList.length(); i++ ) { // TODO - use parameters instead of acronym - if ( mEllipsoidList[ i ].acronym == QgsProject::instance()->crs().ellipsoidAcronym() ) + if ( mEllipsoidList[i].acronym == QgsProject::instance()->crs().ellipsoidAcronym() ) { index = i; break; @@ -440,10 +432,10 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa } const Qgis::CoordinateOrder axisOrder = QgsProject::instance()->displaySettings()->coordinateAxisOrder(); - mCoordinateOrderComboBox->setCurrentIndex( mCoordinateOrderComboBox->findData( static_cast< int >( axisOrder ) ) ); + mCoordinateOrderComboBox->setCurrentIndex( mCoordinateOrderComboBox->findData( static_cast( axisOrder ) ) ); - mDistanceUnitsCombo->setCurrentIndex( mDistanceUnitsCombo->findData( static_cast< int >( QgsProject::instance()->distanceUnits() ) ) ); - mAreaUnitsCombo->setCurrentIndex( mAreaUnitsCombo->findData( static_cast< int >( QgsProject::instance()->areaUnits() ) ) ); + mDistanceUnitsCombo->setCurrentIndex( mDistanceUnitsCombo->findData( static_cast( QgsProject::instance()->distanceUnits() ) ) ); + mAreaUnitsCombo->setCurrentIndex( mAreaUnitsCombo->findData( static_cast( QgsProject::instance()->areaUnits() ) ) ); //get the color selections and set the button color accordingly int myRedInt = settings.value( QStringLiteral( "qgis/default_selection_color_red" ), 255 ).toInt(); @@ -469,7 +461,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa pbnCanvasColor->setDefaultColor( defaultCanvasColor ); //get project scales - const QVector< double > projectScales = QgsProject::instance()->viewSettings()->mapScales(); + const QVector projectScales = QgsProject::instance()->viewSettings()->mapScales(); if ( !projectScales.isEmpty() ) { for ( double scale : projectScales ) @@ -497,9 +489,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa mLayerCapabilitiesTree->setSelectionBehavior( QAbstractItemView::SelectItems ); mLayerCapabilitiesTree->setSelectionMode( QAbstractItemView::MultiSelection ); mLayerCapabilitiesTree->expandAll(); - connect( mLayerCapabilitiesTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, - [ = ]( const QItemSelection & selected, const QItemSelection & deselected ) - { + connect( mLayerCapabilitiesTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, [=]( const QItemSelection &selected, const QItemSelection &deselected ) { Q_UNUSED( selected ) Q_UNUSED( deselected ) bool hasSelection = !mLayerCapabilitiesTree->selectionModel()->selectedIndexes().isEmpty(); @@ -509,22 +499,19 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa mLayerCapabilitiesTreeFilterLineEdit->setShowClearButton( true ); mLayerCapabilitiesTreeFilterLineEdit->setShowSearchIcon( true ); mLayerCapabilitiesTreeFilterLineEdit->setPlaceholderText( tr( "Filter layers…" ) ); - connect( mLayerCapabilitiesTreeFilterLineEdit, &QgsFilterLineEdit::textChanged, this, [ = ]( const QString & filterText ) - { + connect( mLayerCapabilitiesTreeFilterLineEdit, &QgsFilterLineEdit::textChanged, this, [=]( const QString &filterText ) { mLayerCapabilitiesModel->setFilterText( filterText ); mLayerCapabilitiesTree->expandAll(); } ); - connect( mLayerCapabilitiesToggleSelectionButton, &QToolButton::clicked, this, [ = ]( bool clicked ) - { + connect( mLayerCapabilitiesToggleSelectionButton, &QToolButton::clicked, this, [=]( bool clicked ) { Q_UNUSED( clicked ) const QModelIndexList indexes = mLayerCapabilitiesTree->selectionModel()->selectedIndexes(); mLayerCapabilitiesModel->toggleSelectedItems( indexes ); mLayerCapabilitiesTree->repaint(); } ); - connect( mShowSpatialLayersCheckBox, &QCheckBox::stateChanged, this, [ = ]( int state ) - { + connect( mShowSpatialLayersCheckBox, &QCheckBox::stateChanged, this, [=]( int state ) { mLayerCapabilitiesModel->setShowSpatialLayersOnly( static_cast( state ) ); } ); @@ -698,7 +685,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa values[2].toDouble(), values[3].toDouble() ), - QgsProject::instance()->crs() ); + QgsProject::instance()->crs() + ); mAdvertisedExtentServer->setOutputExtentFromOriginal(); } @@ -922,7 +910,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa QCheckBox *cbp = new QCheckBox(); cbp->setChecked( wfsLayerIdList.contains( currentLayer->id() ) ); twWFSLayers->setCellWidget( j, 1, cbp ); - connect( cbp, &QCheckBox::stateChanged, this, [ = ] { cbxWCSPubliedStateChanged( j ); } ); + connect( cbp, &QCheckBox::stateChanged, this, [=] { cbxWCSPubliedStateChanged( j ); } ); QSpinBox *psb = new QSpinBox(); psb->setValue( QgsProject::instance()->readNumEntry( QStringLiteral( "WFSLayersPrecision" ), "/" + currentLayer->id(), 8 ) ); @@ -932,7 +920,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa cbu->setEnabled( false ); if ( ( provider->capabilities() & Qgis::VectorProviderCapability::ChangeAttributeValues ) ) { - if ( ! currentLayer->isSpatial() || ( provider->capabilities() & Qgis::VectorProviderCapability::ChangeGeometries ) ) + if ( !currentLayer->isSpatial() || ( provider->capabilities() & Qgis::VectorProviderCapability::ChangeGeometries ) ) { cbu->setEnabled( true ); cbu->setChecked( wfstUpdateLayerIdList.contains( currentLayer->id() ) ); @@ -980,7 +968,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa currentLayer = it.value(); if ( currentLayer->type() == Qgis::LayerType::Raster ) { - QTableWidgetItem *twi = new QTableWidgetItem( QString::number( j ) ); twWCSLayers->setVerticalHeaderItem( j, twi ); @@ -993,7 +980,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa cbp->setChecked( wcsLayerIdList.contains( currentLayer->id() ) ); twWCSLayers->setCellWidget( j, 1, cbp ); - connect( cbp, &QCheckBox::stateChanged, this, [ = ] { cbxWCSPubliedStateChanged( j ); } ); + connect( cbp, &QCheckBox::stateChanged, this, [=] { cbxWCSPubliedStateChanged( j ); } ); j++; } @@ -1036,7 +1023,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa mColorModel->addItem( tr( "CMYK" ), QVariant::fromValue( Qgis::ColorModel::Cmyk ) ); mColorModel->setCurrentIndex( mColorModel->findData( QVariant::fromValue( QgsProject::instance()->styleSettings()->colorModel() ) ) ); -#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) mColorSpace = QgsProject::instance()->styleSettings()->colorSpace(); updateColorSpaceWidgets(); #else @@ -1120,7 +1107,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa // sync metadata title and project title fields connect( mMetadataWidget, &QgsMetadataWidget::titleChanged, titleEdit, &QLineEdit::setText, Qt::QueuedConnection ); - connect( titleEdit, &QLineEdit::textChanged, this, [ = ] { whileBlocking( mMetadataWidget )->setTitle( title() ) ;} ); + connect( titleEdit, &QLineEdit::textChanged, this, [=] { whileBlocking( mMetadataWidget )->setTitle( title() ); } ); //fill ts language checkbox QString i18nPath = QgsApplication::i18nPath(); @@ -1129,7 +1116,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa for ( const QString &qmFile : qmFileList ) { // Ignore the 'en' translation file, already added as 'en_US'. - if ( qmFile.compare( QLatin1String( "qgis_en.qm" ) ) == 0 ) continue; + if ( qmFile.compare( QLatin1String( "qgis_en.qm" ) ) == 0 ) + continue; QString qmFileName = qmFile; QString l = qmFileName.remove( QStringLiteral( "qgis_" ) ).remove( QStringLiteral( ".qm" ) ); @@ -1202,8 +1190,8 @@ QgsExpressionContext QgsProjectProperties::createExpressionContext() const { QgsExpressionContext context; context - << QgsExpressionContextUtils::globalScope() - << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); + << QgsExpressionContextUtils::globalScope() + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ); return context; } @@ -1269,7 +1257,7 @@ void QgsProjectProperties::apply() QgsProject::instance()->writeEntry( QStringLiteral( "PositionPrecision" ), QStringLiteral( "/Automatic" ), radAutomatic->isChecked() ); QgsProject::instance()->writeEntry( QStringLiteral( "PositionPrecision" ), QStringLiteral( "/DecimalPlaces" ), spinBoxDP->value() ); - const Qgis::CoordinateDisplayType coordinateType = static_cast< Qgis::CoordinateDisplayType >( mCoordinateDisplayComboBox->currentData().toInt() ); + const Qgis::CoordinateDisplayType coordinateType = static_cast( mCoordinateDisplayComboBox->currentData().toInt() ); QgsProject::instance()->displaySettings()->setCoordinateType( coordinateType ); if ( coordinateType == Qgis::CoordinateDisplayType::CustomCrs ) { @@ -1280,18 +1268,18 @@ void QgsProjectProperties::apply() QgsProject::instance()->displaySettings()->setCoordinateCustomCrs( QgsCoordinateReferenceSystem( "EPSG:4326" ) ); } - QgsProject::instance()->displaySettings()->setCoordinateAxisOrder( static_cast< Qgis::CoordinateOrder >( mCoordinateOrderComboBox->currentData().toInt() ) ); + QgsProject::instance()->displaySettings()->setCoordinateAxisOrder( static_cast( mCoordinateOrderComboBox->currentData().toInt() ) ); // Announce that we may have a new display precision setting emit displayPrecisionChanged(); - const Qgis::DistanceUnit distanceUnits = static_cast< Qgis::DistanceUnit >( mDistanceUnitsCombo->currentData().toInt() ); + const Qgis::DistanceUnit distanceUnits = static_cast( mDistanceUnitsCombo->currentData().toInt() ); QgsProject::instance()->setDistanceUnits( distanceUnits ); - const Qgis::AreaUnit areaUnits = static_cast< Qgis::AreaUnit >( mAreaUnitsCombo->currentData().toInt() ); + const Qgis::AreaUnit areaUnits = static_cast( mAreaUnitsCombo->currentData().toInt() ); QgsProject::instance()->setAreaUnits( areaUnits ); - QgsProject::instance()->setFilePathStorage( static_cast< Qgis::FilePathType >( cbxAbsolutePath->currentData().toInt() ) ); + QgsProject::instance()->setFilePathStorage( static_cast( cbxAbsolutePath->currentData().toInt() ) ); if ( mEllipsoidList.at( mEllipsoidIndex ).acronym.startsWith( QLatin1String( "PARAMETER" ) ) ) { @@ -1302,7 +1290,7 @@ void QgsProjectProperties::apply() { QgsDebugMsgLevel( QStringLiteral( "Using parameteric major/minor" ), 4 ); bool ok; - double val {QgsDoubleValidator::toDouble( leSemiMajor->text(), &ok )}; + double val { QgsDoubleValidator::toDouble( leSemiMajor->text(), &ok ) }; if ( ok ) { major = val; @@ -1314,12 +1302,12 @@ void QgsProjectProperties::apply() } } QgsProject::instance()->setEllipsoid( QStringLiteral( "PARAMETER:%1:%2" ) - .arg( major, 0, 'g', 17 ) - .arg( minor, 0, 'g', 17 ) ); + .arg( major, 0, 'g', 17 ) + .arg( minor, 0, 'g', 17 ) ); } else { - QgsProject::instance()->setEllipsoid( mEllipsoidList[ mEllipsoidIndex ].acronym ); + QgsProject::instance()->setEllipsoid( mEllipsoidList[mEllipsoidIndex].acronym ); } //set the color for selections and canvas background color @@ -1333,7 +1321,7 @@ void QgsProjectProperties::apply() } //save project scales - QVector< double > projectScales; + QVector projectScales; projectScales.reserve( lstScales->count() ); for ( int i = 0; i < lstScales->count(); ++i ) { @@ -1352,7 +1340,7 @@ void QgsProjectProperties::apply() } else { - QgsProject::instance()->viewSettings()->setMapScales( QVector< double >() ); + QgsProject::instance()->viewSettings()->setMapScales( QVector() ); QgsProject::instance()->viewSettings()->setUseProjectScales( false ); } @@ -1506,10 +1494,10 @@ void QgsProjectProperties::apply() QgsProject::instance()->writeEntry( QStringLiteral( "WMSExtent" ), QStringLiteral( "/" ), QStringList() - << qgsDoubleToString( wmsExtent.xMinimum() ) - << qgsDoubleToString( wmsExtent.yMinimum() ) - << qgsDoubleToString( wmsExtent.xMaximum() ) - << qgsDoubleToString( wmsExtent.yMaximum() ) + << qgsDoubleToString( wmsExtent.xMinimum() ) + << qgsDoubleToString( wmsExtent.yMinimum() ) + << qgsDoubleToString( wmsExtent.xMaximum() ) + << qgsDoubleToString( wmsExtent.yMaximum() ) ); } else @@ -1883,19 +1871,16 @@ void QgsProjectProperties::twWmtsItemChanged( QTreeWidgetItem *item, int column item->setCheckState( 2, Qt::Unchecked ); item->setCheckState( 3, Qt::Unchecked ); } - else if ( column == 1 && item->checkState( 1 ) && - !item->checkState( 2 ) && !item->checkState( 3 ) ) + else if ( column == 1 && item->checkState( 1 ) && !item->checkState( 2 ) && !item->checkState( 3 ) ) { item->setCheckState( 2, Qt::Checked ); item->setCheckState( 3, Qt::Checked ); } - else if ( ( column == 2 && item->checkState( 2 ) ) || - ( column == 3 && item->checkState( 3 ) ) ) + else if ( ( column == 2 && item->checkState( 2 ) ) || ( column == 3 && item->checkState( 3 ) ) ) { item->setCheckState( 1, Qt::Checked ); } - else if ( ( column == 2 && !item->checkState( 2 ) && !item->checkState( 3 ) ) || - ( column == 3 && !item->checkState( 2 ) && !item->checkState( 3 ) ) ) + else if ( ( column == 2 && !item->checkState( 2 ) && !item->checkState( 3 ) ) || ( column == 3 && !item->checkState( 2 ) && !item->checkState( 3 ) ) ) { item->setCheckState( 1, Qt::Unchecked ); } @@ -1985,7 +1970,7 @@ void QgsProjectProperties::updateGuiForMapUnits() mDistanceUnitsCombo->setItemText( idx, tr( "Unknown Units" ) ); mDistanceUnitsCombo->setCurrentIndex( idx ); } - idx = mAreaUnitsCombo->findData( static_cast< int >( Qgis::AreaUnit::Unknown ) ); + idx = mAreaUnitsCombo->findData( static_cast( Qgis::AreaUnit::Unknown ) ); if ( idx >= 0 ) { mAreaUnitsCombo->setItemText( idx, tr( "Unknown Units" ) ); @@ -2015,13 +2000,13 @@ void QgsProjectProperties::updateGuiForMapUnits() mCoordinateDisplayComboBox->setItemText( idx, mapUnitString ); //also update unit combo boxes - idx = mDistanceUnitsCombo->findData( static_cast< int >( Qgis::DistanceUnit::Unknown ) ); + idx = mDistanceUnitsCombo->findData( static_cast( Qgis::DistanceUnit::Unknown ) ); if ( idx >= 0 ) { QString mapUnitString = tr( "Map Units (%1)" ).arg( QgsUnitTypes::toString( units ) ); mDistanceUnitsCombo->setItemText( idx, mapUnitString ); } - idx = mAreaUnitsCombo->findData( static_cast< int >( Qgis::AreaUnit::Unknown ) ); + idx = mAreaUnitsCombo->findData( static_cast( Qgis::AreaUnit::Unknown ) ); if ( idx >= 0 ) { QString mapUnitString = tr( "Map Units (%1)" ).arg( QgsUnitTypes::toString( QgsUnitTypes::distanceToAreaUnit( units ) ) ); @@ -2106,9 +2091,7 @@ void QgsProjectProperties::pbnWMSSetUsedSRS_clicked() { if ( mWMSList->count() > 1 ) { - if ( QMessageBox::question( this, - tr( "Coordinate System Restrictions" ), - tr( "The current selection of coordinate systems will be lost.\nProceed?" ) ) == QMessageBox::No ) + if ( QMessageBox::question( this, tr( "Coordinate System Restrictions" ), tr( "The current selection of coordinate systems will be lost.\nProceed?" ) ) == QMessageBox::No ) return; } @@ -2272,12 +2255,12 @@ void QgsProjectProperties::pbnLaunchOWSChecker_clicked() void QgsProjectProperties::pbnAddScale_clicked() { int myScale = QInputDialog::getInt( - this, - tr( "Enter scale" ), - tr( "Scale denominator" ), - -1, - 1 - ); + this, + tr( "Enter scale" ), + tr( "Scale denominator" ), + -1, + 1 + ); if ( myScale != -1 ) { @@ -2295,8 +2278,7 @@ void QgsProjectProperties::pbnRemoveScale_clicked() void QgsProjectProperties::pbnImportScales_clicked() { - QString fileName = QFileDialog::getOpenFileName( this, tr( "Load scales" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + QString fileName = QFileDialog::getOpenFileName( this, tr( "Load scales" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -2315,7 +2297,7 @@ void QgsProjectProperties::pbnImportScales_clicked() { // Parse scale string const QStringList parts { scale.split( ':' ) }; - if ( parts.count( ) == 2 ) + if ( parts.count() == 2 ) { const double scaleDenominator { parts.at( 1 ).toDouble( &ok ) }; if ( ok ) @@ -2328,8 +2310,7 @@ void QgsProjectProperties::pbnImportScales_clicked() void QgsProjectProperties::pbnExportScales_clicked() { - QString fileName = QFileDialog::getSaveFileName( this, tr( "Save scales" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "Save scales" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); // return dialog focus on Mac activateWindow(); raise(); @@ -2361,8 +2342,8 @@ void QgsProjectProperties::pbnExportScales_clicked() void QgsProjectProperties::resetPythonMacros() { grpPythonMacros->setChecked( false ); - ptePythonMacros->setText( "def openProject():\n pass\n\n" \ - "def saveProject():\n pass\n\n" \ + ptePythonMacros->setText( "def openProject():\n pass\n\n" + "def saveProject():\n pass\n\n" "def closeProject():\n pass\n" ); } @@ -2517,7 +2498,7 @@ void QgsProjectProperties::populateEllipsoidList() myItem.semiMinor = 6370997.0; mEllipsoidList.append( myItem ); - const auto definitions {QgsEllipsoidUtils::definitions()}; + const auto definitions { QgsEllipsoidUtils::definitions() }; for ( const QgsEllipsoidUtils::EllipsoidDefinition &def : definitions ) { myItem.acronym = def.acronym; @@ -2556,8 +2537,8 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex ) if ( leSemiMajor->isModified() || leSemiMinor->isModified() ) { QgsDebugMsgLevel( QStringLiteral( "Saving major/minor" ), 4 ); - mEllipsoidList[ mEllipsoidIndex ].semiMajor = QgsDoubleValidator::toDouble( leSemiMajor->text() ); - mEllipsoidList[ mEllipsoidIndex ].semiMinor = QgsDoubleValidator::toDouble( leSemiMinor->text() ); + mEllipsoidList[mEllipsoidIndex].semiMajor = QgsDoubleValidator::toDouble( leSemiMajor->text() ); + mEllipsoidList[mEllipsoidIndex].semiMinor = QgsDoubleValidator::toDouble( leSemiMinor->text() ); } mEllipsoidIndex = newIndex; @@ -2578,7 +2559,7 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex ) leSemiMajor->setToolTip( tr( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Custom" ) ) ); leSemiMinor->setToolTip( tr( "Select %1 from pull-down menu to adjust radii" ).arg( tr( "Custom" ) ) ); } - if ( mEllipsoidList[ mEllipsoidIndex ].acronym != geoNone() ) + if ( mEllipsoidList[mEllipsoidIndex].acronym != geoNone() ) { leSemiMajor->setText( QLocale().toString( myMajor, 'f', 3 ) ); leSemiMinor->setText( QLocale().toString( myMinor, 'f', 3 ) ); @@ -2600,8 +2581,8 @@ void QgsProjectProperties::setCurrentEllipsoid( const QString &ellipsoidAcronym if ( mEllipsoidList.at( i ).acronym.startsWith( QLatin1String( "PARAMETER" ), Qt::CaseInsensitive ) ) { index = i; - mEllipsoidList[ index ].semiMajor = mySplitEllipsoid[ 1 ].toDouble(); - mEllipsoidList[ index ].semiMinor = mySplitEllipsoid[ 2 ].toDouble(); + mEllipsoidList[index].semiMajor = mySplitEllipsoid[1].toDouble(); + mEllipsoidList[index].semiMinor = mySplitEllipsoid[2].toDouble(); } } } @@ -2623,8 +2604,7 @@ void QgsProjectProperties::setCurrentEllipsoid( const QString &ellipsoidAcronym void QgsProjectProperties::mButtonAddColor_clicked() { const Qgis::ColorModel colorModel = mColorModel->currentData().value(); - const QColor defaultColor = colorModel == Qgis::ColorModel::Cmyk ? - QColor::fromCmykF( 0., 1., 1., 0. ) : QColor::fromRgbF( 1., 0., 0. ); + const QColor defaultColor = colorModel == Qgis::ColorModel::Cmyk ? QColor::fromCmykF( 0., 1., 1., 0. ) : QColor::fromRgbF( 1., 0., 0. ); QColor newColor = QgsColorDialog::getColor( defaultColor, this->parentWidget(), tr( "Select Color" ), true ); if ( !newColor.isValid() ) @@ -2660,26 +2640,28 @@ void QgsProjectProperties::addStyleDatabasePrivate( bool createNew ) initialFolder = QDir::homePath(); QString databasePath = createNew - ? QFileDialog::getSaveFileName( - this, - tr( "Create Style Database" ), - initialFolder, - tr( "Style databases" ) + " (*.db)" ) - : QFileDialog::getOpenFileName( - this, - tr( "Add Style Database" ), - initialFolder, - tr( "Style databases" ) + " (*.db *.xml)" ); + ? QFileDialog::getSaveFileName( + this, + tr( "Create Style Database" ), + initialFolder, + tr( "Style databases" ) + " (*.db)" + ) + : QFileDialog::getOpenFileName( + this, + tr( "Add Style Database" ), + initialFolder, + tr( "Style databases" ) + " (*.db *.xml)" + ); // return dialog focus on Mac activateWindow(); raise(); - if ( ! databasePath.isEmpty() ) + if ( !databasePath.isEmpty() ) { QgsStyleManagerDialog::settingLastStyleDatabaseFolder->setValue( QFileInfo( databasePath ).path() ); if ( createNew ) { - databasePath = QgsFileUtils::ensureFileNameHasExtension( databasePath, { QStringLiteral( "db" )} ); + databasePath = QgsFileUtils::ensureFileNameHasExtension( databasePath, { QStringLiteral( "db" ) } ); if ( QFile::exists( databasePath ) ) { QFile::remove( databasePath ); @@ -2707,15 +2689,16 @@ void QgsProjectProperties::removeStyleDatabase() delete mListStyleDatabases->takeItem( currentRow ); } -#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) void QgsProjectProperties::addIccProfile() { const QString iccProfileFilePath = QFileDialog::getOpenFileName( - this, - tr( "Load ICC Profile" ), - QDir::homePath(), - tr( "ICC Profile" ) + QStringLiteral( " (*.icc)" ) ); + this, + tr( "Load ICC Profile" ), + QDir::homePath(), + tr( "ICC Profile" ) + QStringLiteral( " (*.icc)" ) + ); addIccProfile( iccProfileFilePath ); } @@ -2745,8 +2728,7 @@ void QgsProjectProperties::removeIccProfile() void QgsProjectProperties::saveIccProfile() { - QString fileName = QFileDialog::getSaveFileName( this, tr( "Save ICC Profile" ), QDir::homePath(), - tr( "ICC profile files (*.icc *.ICC)" ) ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "Save ICC Profile" ), QDir::homePath(), tr( "ICC profile files (*.icc *.ICC)" ) ); if ( fileName.isEmpty() ) return; @@ -2811,7 +2793,7 @@ void QgsProjectProperties::scaleItemChanged( QListWidgetItem *changedScaleItem ) // Check if the new value is valid, restore the old value if not. const QStringList parts { changedScaleItem->text().split( ':' ) }; bool valid { parts.count() == 2 }; - double newDenominator { -1 }; // invalid + double newDenominator { -1 }; // invalid if ( valid ) { @@ -2873,7 +2855,7 @@ void QgsProjectProperties::showHelp() void QgsProjectProperties::checkPageWidgetNameMap() { - const QMap< QString, QString > pageNames = QgisApp::instance()->projectPropertiesPagesMap(); + const QMap pageNames = QgisApp::instance()->projectPropertiesPagesMap(); Q_ASSERT_X( pageNames.count() == mOptionsListWidget->count(), "QgsProjectProperties::checkPageWidgetNameMap()", "QgisApp::projectPropertiesPagesMap() is outdated, contains too many entries" ); for ( int idx = 0; idx < mOptionsListWidget->count(); ++idx ) { @@ -2906,13 +2888,14 @@ void QgsProjectProperties::onGenerateTsFileButton() const QString l = cbtsLocale->currentData().toString(); QgsProject::instance()->generateTsFile( l ); QMessageBox::information( nullptr, tr( "General TS file generated" ), tr( "TS file generated with source language %1.\n" - "- open it with Qt Linguist\n" - "- translate strings\n" - "- save the TS file with the suffix of the target language (e.g. _de.ts)\n" - "- release to get the QM file including the suffix (e.g. aproject_de.qm)\n" - "- open the original QGIS file (e.g. aproject.qgs)\n" - "- if your QGIS is set to use a specific language and the QM file for that language is found, the translated QGIS project will be generated on the fly.\n" - "- you will be redirected to this new project (e.g. aproject_de.qgs)." ).arg( l ) ) ; + "- open it with Qt Linguist\n" + "- translate strings\n" + "- save the TS file with the suffix of the target language (e.g. _de.ts)\n" + "- release to get the QM file including the suffix (e.g. aproject_de.qm)\n" + "- open the original QGIS file (e.g. aproject.qgs)\n" + "- if your QGIS is set to use a specific language and the QM file for that language is found, the translated QGIS project will be generated on the fly.\n" + "- you will be redirected to this new project (e.g. aproject_de.qgs)." ) + .arg( l ) ); } void QgsProjectProperties::customizeBearingFormat() diff --git a/src/app/qgsprojectproperties.h b/src/app/qgsprojectproperties.h index 699deebcb0ef..b4b5036277ff 100644 --- a/src/app/qgsprojectproperties.h +++ b/src/app/qgsprojectproperties.h @@ -58,8 +58,7 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui: public: //! Constructor - QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, - const QList &optionsFactories = QList() ); + QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, const QList &optionsFactories = QList() ); ~QgsProjectProperties() override; @@ -208,7 +207,7 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui: void removeStyleDatabase(); void newStyleDatabase(); -#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) /** * Called whenever user select the add ICC profile button @@ -238,7 +237,6 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui: #endif private: - /** * Called when the user sets a CRS for the project. */ @@ -265,20 +263,20 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui: // List for all ellispods, also None and Custom struct EllipsoidDefs { - QString acronym; - QString description; - double semiMajor; - double semiMinor; + QString acronym; + QString description; + double semiMajor; + double semiMinor; }; QList mEllipsoidList; int mEllipsoidIndex; bool mBlockCrsUpdates = false; QColorSpace mColorSpace; - QList< QgsOptionsPageWidget * > mAdditionalProjectPropertiesWidgets; + QList mAdditionalProjectPropertiesWidgets; - std::unique_ptr< QgsBearingNumericFormat > mBearingFormat; - std::unique_ptr< QgsGeographicCoordinateNumericFormat > mGeographicCoordinateFormat; + std::unique_ptr mBearingFormat; + std::unique_ptr mGeographicCoordinateFormat; //! populate WMTS tree void populateWmtsTree( const QgsLayerTreeGroup *treeGroup, QgsTreeWidgetItem *treeItem ); diff --git a/src/app/qgspuzzlewidget.cpp b/src/app/qgspuzzlewidget.cpp index 5dc64323a74c..9ff5b75bb86d 100644 --- a/src/app/qgspuzzlewidget.cpp +++ b/src/app/qgspuzzlewidget.cpp @@ -62,8 +62,7 @@ static void shuffle( QVector &positions, int count ) const int move = QRandomGenerator::global()->generate() % 4; cOther = cEmpty + moveX[move]; rOther = rEmpty + moveY[move]; - } - while ( cOther < 0 || cOther >= size || rOther < 0 || rOther >= size ); + } while ( cOther < 0 || cOther >= size || rOther < 0 || rOther >= size ); const int idxOther = rOther * size + cOther; std::swap( positions[idxEmpty], positions[idxOther] ); @@ -83,7 +82,7 @@ QgsPuzzleWidget::QgsPuzzleWidget( QgsMapCanvas *canvas ) void QgsPuzzleWidget::mousePressEvent( QMouseEvent *event ) { if ( mTileWidth == 0 || mTileHeight == 0 ) - return; // not initialized + return; // not initialized const int idxEmpty = findEmpty( mPositions ); const int rEmpty = idxEmpty / mSize; @@ -188,7 +187,7 @@ void QgsPuzzleWidget::updateTilePositions() { const int itemIndex = mPositions[i]; if ( itemIndex == -1 ) - continue; // empty tile + continue; // empty tile int r = i / mSize, c = i % mSize; int x = c * mTileWidth, y = r * mTileHeight; diff --git a/src/app/qgspuzzlewidget.h b/src/app/qgspuzzlewidget.h index 2529d83f7069..9ac70be7ad32 100644 --- a/src/app/qgspuzzlewidget.h +++ b/src/app/qgspuzzlewidget.h @@ -41,11 +41,11 @@ class QgsPuzzleWidget : public QGraphicsView private: QgsMapCanvas *mCanvas = nullptr; QGraphicsScene *mScene = nullptr; - int mSize = 4; //!< Number of items in one row/column + int mSize = 4; //!< Number of items in one row/column int mTileWidth = 0, mTileHeight = 0; QVector mItems; QVector mTextItems; - QVector mPositions; //!< Indices of items (-1 where the piece is missing) + QVector mPositions; //!< Indices of items (-1 where the piece is missing) }; #endif // QGSPUZZLEWIDGET_H diff --git a/src/app/qgsrasterattributetableapputils.h b/src/app/qgsrasterattributetableapputils.h index cad4aa74a391..2681766a1ad6 100644 --- a/src/app/qgsrasterattributetableapputils.h +++ b/src/app/qgsrasterattributetableapputils.h @@ -25,30 +25,28 @@ class QgsMessageBar; */ struct QgsRasterAttributeTableAppUtils { - - /** + /** * Open the Raster Attribute Table for the raster layer. * Only works on raster layers. */ - static void openRasterAttributeTable( QgsLayerTreeView *treeView ); + static void openRasterAttributeTable( QgsLayerTreeView *treeView ); - /** + /** * Creates a new Raster Attribute Table from the raster layer renderer if the * renderer supports it. * * Only works on raster layers. */ - static void createRasterAttributeTable( QgsLayerTreeView *treeView, QgsMessageBar *messageBar ); + static void createRasterAttributeTable( QgsLayerTreeView *treeView, QgsMessageBar *messageBar ); - /** + /** * Loads a Raster Attribute Table from a VAT.DBF file. * * Only works on raster layers. * */ - static void loadRasterAttributeTableFromFile( QgsLayerTreeView *treeView, QgsMessageBar *messageBar ); - + static void loadRasterAttributeTableFromFile( QgsLayerTreeView *treeView, QgsMessageBar *messageBar ); }; #endif // QGSRASTERATTRIBUTETABLEAPPUTILS_H diff --git a/src/app/qgsrastercalcdialog.cpp b/src/app/qgsrastercalcdialog.cpp index 6d36df3b9f34..ee4952640fa6 100644 --- a/src/app/qgsrastercalcdialog.cpp +++ b/src/app/qgsrastercalcdialog.cpp @@ -31,7 +31,8 @@ #include #include -QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget *parent, Qt::WindowFlags f ): QDialog( parent, f ) +QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget *parent, Qt::WindowFlags f ) + : QDialog( parent, f ) { setupUi( this ); QgsGui::enableAutoGeometryRestore( this ); @@ -96,15 +97,14 @@ QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget * mOutputLayer->setStorageMode( QgsFileWidget::SaveFile ); mOutputLayer->setDialogTitle( tr( "Enter Result File" ) ); mOutputLayer->setDefaultRoot( settings.value( QStringLiteral( "/RasterCalculator/lastOutputDir" ), QDir::homePath() ).toString() ); - connect( mOutputLayer, &QgsFileWidget::fileChanged, this, [ = ]() { setAcceptButtonState(); } ); + connect( mOutputLayer, &QgsFileWidget::fileChanged, this, [=]() { setAcceptButtonState(); } ); connect( mUseVirtualProviderCheckBox, &QCheckBox::clicked, this, &QgsRasterCalcDialog::setOutputToVirtual ); - if ( ! useVirtualProvider() ) + if ( !useVirtualProvider() ) { setOutputToVirtual(); } - } QString QgsRasterCalcDialog::formulaString() const @@ -403,7 +403,8 @@ void QgsRasterCalcDialog::mRasterBandsListWidget_itemDoubleClicked( QListWidgetI { mExpressionTextEdit->insertPlainText( quoteBandEntry( item->text() ) ); //to enable the "ok" button if someone checks the virtual provider checkbox before adding a valid expression, - if ( expressionValid() && useVirtualProvider() ) setAcceptButtonState(); + if ( expressionValid() && useVirtualProvider() ) + setAcceptButtonState(); } void QgsRasterCalcDialog::mPlusPushButton_clicked() diff --git a/src/app/qgsrastercalcdialog.h b/src/app/qgsrastercalcdialog.h index e71a5e1f6a48..bce359781259 100644 --- a/src/app/qgsrastercalcdialog.h +++ b/src/app/qgsrastercalcdialog.h @@ -24,11 +24,10 @@ #include "qgis_app.h" //! A dialog to enter a raster calculation expression -class APP_EXPORT QgsRasterCalcDialog: public QDialog, private Ui::QgsRasterCalcDialogBase +class APP_EXPORT QgsRasterCalcDialog : public QDialog, private Ui::QgsRasterCalcDialogBase { Q_OBJECT public: - /** * Constructor for raster calculator dialog * \param rasterLayer main raster layer, will be used for default extent and projection diff --git a/src/app/qgsrecentprojectsitemsmodel.cpp b/src/app/qgsrecentprojectsitemsmodel.cpp index ef999ca20d9b..1ef09e5da962 100644 --- a/src/app/qgsrecentprojectsitemsmodel.cpp +++ b/src/app/qgsrecentprojectsitemsmodel.cpp @@ -36,7 +36,6 @@ QgsRecentProjectItemsModel::QgsRecentProjectItemsModel( QObject *parent ) : QAbstractListModel( parent ) { - } void QgsRecentProjectItemsModel::setRecentProjects( const QList &recentProjects ) @@ -68,7 +67,7 @@ QVariant QgsRecentProjectItemsModel::data( const QModelIndex &index, int role ) if ( !mRecentProjects.at( index.row() ).crs.isEmpty() ) { const QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( mRecentProjects.at( index.row() ).crs ); - return QStringLiteral( "%1 (%2)" ).arg( mRecentProjects.at( index.row() ).crs, crs.userFriendlyIdentifier() ); + return QStringLiteral( "%1 (%2)" ).arg( mRecentProjects.at( index.row() ).crs, crs.userFriendlyIdentifier() ); } else { @@ -168,9 +167,9 @@ void QgsRecentProjectItemsModel::clear( bool clearPinned ) std::remove_if( mRecentProjects.begin(), mRecentProjects.end(), - []( const QgsRecentProjectItemsModel::RecentProjectData & recentProject ) { return !recentProject.pin; } + []( const QgsRecentProjectItemsModel::RecentProjectData &recentProject ) { return !recentProject.pin; } ), - mRecentProjects.end() + mRecentProjects.end() ); } endResetModel(); diff --git a/src/app/qgsrecentprojectsitemsmodel.h b/src/app/qgsrecentprojectsitemsmodel.h index bcae5f2fcefa..1d1e9d423d40 100644 --- a/src/app/qgsrecentprojectsitemsmodel.h +++ b/src/app/qgsrecentprojectsitemsmodel.h @@ -29,14 +29,14 @@ class QgsRecentProjectItemsModel : public QAbstractListModel public: struct RecentProjectData { - bool operator==( const RecentProjectData &other ) const { return other.path == this->path; } - QString path; - QString title; - QString previewImagePath; - QString crs; - mutable bool pin = false; - mutable bool checkedExists = false; - mutable bool exists = false; + bool operator==( const RecentProjectData &other ) const { return other.path == this->path; } + QString path; + QString title; + QString previewImagePath; + QString crs; + mutable bool pin = false; + mutable bool checkedExists = false; + mutable bool exists = false; }; explicit QgsRecentProjectItemsModel( QObject *parent = nullptr ); diff --git a/src/app/qgsrecentprojectsmenueventfilter.cpp b/src/app/qgsrecentprojectsmenueventfilter.cpp index 5b3abbecfb96..e66523f13d07 100644 --- a/src/app/qgsrecentprojectsmenueventfilter.cpp +++ b/src/app/qgsrecentprojectsmenueventfilter.cpp @@ -41,7 +41,6 @@ QgsRecentProjectsMenuEventFilter::QgsRecentProjectsMenuEventFilter( QgsWelcomePa bool QgsRecentProjectsMenuEventFilter::eventFilter( QObject *obj, QEvent *event ) { - if ( event->type() != QEvent::MouseButtonPress ) return QObject::eventFilter( obj, event ); @@ -89,8 +88,7 @@ bool QgsRecentProjectsMenuEventFilter::eventFilter( QObject *obj, QEvent *event if ( !path.isEmpty() ) { QAction *openFolderAction = subMenu.addAction( tr( "Open Directory…" ) ); - connect( openFolderAction, &QAction::triggered, this, [path] - { + connect( openFolderAction, &QAction::triggered, this, [path] { const QgsFocusKeeper focusKeeper; QgsGui::nativePlatformInterface()->openFileExplorerAndSelectFile( path ); } ); diff --git a/src/app/qgsrecentprojectsmenueventfilter.h b/src/app/qgsrecentprojectsmenueventfilter.h index da5a84e6eeb7..462532a98aec 100644 --- a/src/app/qgsrecentprojectsmenueventfilter.h +++ b/src/app/qgsrecentprojectsmenueventfilter.h @@ -25,7 +25,6 @@ class QgsRecentProjectsMenuEventFilter : public QObject Q_OBJECT public: - QgsRecentProjectsMenuEventFilter( QgsWelcomePage *welcomePage = nullptr, QObject *parent = nullptr ); bool eventFilter( QObject *obj, QEvent *event ) override; diff --git a/src/app/qgsrelationadddlg.cpp b/src/app/qgsrelationadddlg.cpp index 06c72fa9bbae..e40a6001eeb6 100644 --- a/src/app/qgsrelationadddlg.cpp +++ b/src/app/qgsrelationadddlg.cpp @@ -48,17 +48,16 @@ QgsCreateRelationDialog::QgsCreateRelationDialog( QWidget *parent ) mReferencingLayerCombobox->setFilters( Qgis::LayerFilter::VectorLayer ); mFieldsMappingTable->setCellWidget( 0, 1, mReferencingLayerCombobox ); - mRelationStrengthComboBox->addItem( tr( "Association" ), static_cast< int >( Qgis::RelationshipStrength::Association ) ); - mRelationStrengthComboBox->addItem( tr( "Composition" ), static_cast< int >( Qgis::RelationshipStrength::Composition ) ); + mRelationStrengthComboBox->addItem( tr( "Association" ), static_cast( Qgis::RelationshipStrength::Association ) ); + mRelationStrengthComboBox->addItem( tr( "Composition" ), static_cast( Qgis::RelationshipStrength::Composition ) ); mRelationStrengthComboBox->setToolTip( tr( "When composition is selected the child features will be duplicated too.\n" - "Duplications are made by the feature duplication action.\n" - "The default actions are activated in the Action section of the layer properties." ) ); + "Duplications are made by the feature duplication action.\n" + "The default actions are activated in the Action section of the layer properties." ) ); mButtonBox->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok ); connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsCreateRelationDialog::accept ); connect( mButtonBox, &QDialogButtonBox::rejected, this, &QgsCreateRelationDialog::reject ); - connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "working_with_vector/joins_relations.html#one-to-many-relation" ) ); } ); @@ -132,7 +131,7 @@ void QgsCreateRelationDialog::updateFieldsMappingButtons() void QgsCreateRelationDialog::updateFieldsMappingHeaders() { const int rowsCount = mFieldsMappingTable->rowCount(); - QStringList verticalHeaderLabels( {tr( "Layer" )} ); + QStringList verticalHeaderLabels( { tr( "Layer" ) } ); for ( int i = 0; i < rowsCount; i++ ) verticalHeaderLabels << tr( "Field %1" ).arg( i + 1 ); @@ -150,9 +149,9 @@ QString QgsCreateRelationDialog::referencedLayerId() const return mReferencedLayerCombobox->currentLayer()->id(); } -QList< QPair< QString, QString > > QgsCreateRelationDialog::references() const +QList> QgsCreateRelationDialog::references() const { - QList< QPair< QString, QString > > references; + QList> references; for ( int i = 0, l = mFieldsMappingTable->rowCount(); i < l; i++ ) { // ignore the layers row @@ -179,7 +178,7 @@ QString QgsCreateRelationDialog::relationName() const Qgis::RelationshipStrength QgsCreateRelationDialog::relationStrength() const { - return static_cast< Qgis::RelationshipStrength >( mRelationStrengthComboBox->currentData().toInt() ); + return static_cast( mRelationStrengthComboBox->currentData().toInt() ); } void QgsCreateRelationDialog::updateDialogButtons() diff --git a/src/app/qgsrelationadddlg.h b/src/app/qgsrelationadddlg.h index 39dc024ab2ca..f73ed1880463 100644 --- a/src/app/qgsrelationadddlg.h +++ b/src/app/qgsrelationadddlg.h @@ -45,7 +45,7 @@ class APP_EXPORT QgsCreateRelationDialog : public QDialog, private Ui::QgsRelati QString referencingLayerId() const; QString referencedLayerId() const; - QList< QPair< QString, QString > > references() const; + QList> references() const; QString relationId() const; QString relationName() const; Qgis::RelationshipStrength relationStrength() const; @@ -66,7 +66,6 @@ class APP_EXPORT QgsCreateRelationDialog : public QDialog, private Ui::QgsRelati QgsMapLayerComboBox *mReferencedLayerCombobox = nullptr; QgsMapLayerComboBox *mReferencingLayerCombobox = nullptr; - }; #endif // QGSRELATIONADDDLG_H diff --git a/src/app/qgsrelationaddpolymorphicdialog.cpp b/src/app/qgsrelationaddpolymorphicdialog.cpp index 1486737c1438..5b4dba5b8c72 100644 --- a/src/app/qgsrelationaddpolymorphicdialog.cpp +++ b/src/app/qgsrelationaddpolymorphicdialog.cpp @@ -35,15 +35,12 @@ QgsRelationAddPolymorphicDialog::QgsRelationAddPolymorphicDialog( bool isEditDia { setupUi( this ); - setWindowTitle( mIsEditDialog - ? tr( "Edit Polymorphic Relation" ) - : tr( "Add Polymorphic Relation" ) ); + setWindowTitle( mIsEditDialog ? tr( "Edit Polymorphic Relation" ) : tr( "Add Polymorphic Relation" ) ); mButtonBox->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok ); connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsRelationAddPolymorphicDialog::accept ); connect( mButtonBox, &QDialogButtonBox::rejected, this, &QgsRelationAddPolymorphicDialog::reject ); - connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [ = ] - { + connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [=] { QgsHelp::openHelp( QStringLiteral( "working_with_vector/attribute_table.html#defining-polymorphic-relations" ) ); } ); @@ -56,11 +53,11 @@ QgsRelationAddPolymorphicDialog::QgsRelationAddPolymorphicDialog( bool isEditDia mReferencedLayersComboBox->addItem( vl->name(), vl->id() ); } - mRelationStrengthComboBox->addItem( tr( "Association" ), static_cast< int >( Qgis::RelationshipStrength::Association ) ); - mRelationStrengthComboBox->addItem( tr( "Composition" ), static_cast< int >( Qgis::RelationshipStrength::Composition ) ); + mRelationStrengthComboBox->addItem( tr( "Association" ), static_cast( Qgis::RelationshipStrength::Association ) ); + mRelationStrengthComboBox->addItem( tr( "Composition" ), static_cast( Qgis::RelationshipStrength::Composition ) ); mRelationStrengthComboBox->setToolTip( tr( "When composition is selected the child features will also be duplicated and deleted.\n" - "Duplications are made by the feature duplication action.\n" - "The default actions are activated in the Action section of the layer properties." ) ); + "Duplications are made by the feature duplication action.\n" + "The default actions are activated in the Action section of the layer properties." ) ); mFieldsMappingWidget->setEnabled( false ); addFieldsRow(); @@ -72,7 +69,7 @@ QgsRelationAddPolymorphicDialog::QgsRelationAddPolymorphicDialog( bool isEditDia connect( mFieldsMappingAddButton, &QToolButton::clicked, this, &QgsRelationAddPolymorphicDialog::addFieldsRow ); connect( mFieldsMappingRemoveButton, &QToolButton::clicked, this, &QgsRelationAddPolymorphicDialog::removeFieldsRow ); connect( mReferencingLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsRelationAddPolymorphicDialog::updateDialogButtons ); - connect( mRelationStrengthComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int index ) { Q_UNUSED( index ); updateDialogButtons(); } ); + connect( mRelationStrengthComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int index ) { Q_UNUSED( index ); updateDialogButtons(); } ); connect( mReferencedLayerExpressionWidget, static_cast( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsRelationAddPolymorphicDialog::updateDialogButtons ); connect( mReferencedLayersComboBox, &QgsCheckableComboBox::checkedItemsChanged, this, &QgsRelationAddPolymorphicDialog::referencedLayersChanged ); connect( mReferencingLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsRelationAddPolymorphicDialog::updateChildRelationsComboBox ); @@ -87,7 +84,7 @@ void QgsRelationAddPolymorphicDialog::setPolymorphicRelation( const QgsPolymorph mReferencedLayerFieldComboBox->setLayer( polyRel.referencingLayer() ); mReferencedLayerFieldComboBox->setField( polyRel.referencedLayerField() ); mReferencedLayerExpressionWidget->setExpression( polyRel.referencedLayerExpression() ); - mRelationStrengthComboBox->setCurrentIndex( mRelationStrengthComboBox->findData( static_cast< int >( polyRel.strength() ) ) ); + mRelationStrengthComboBox->setCurrentIndex( mRelationStrengthComboBox->findData( static_cast( polyRel.strength() ) ) ); const QStringList layerIds = polyRel.referencedLayerIds(); for ( const QString &layerId : layerIds ) @@ -117,7 +114,7 @@ void QgsRelationAddPolymorphicDialog::addFieldsRow() referencingField->setLayer( mReferencingLayerComboBox->currentLayer() ); - connect( referencingField, &QgsFieldComboBox::fieldChanged, this, [ = ]( const QString & ) { updateDialogButtons(); } ); + connect( referencingField, &QgsFieldComboBox::fieldChanged, this, [=]( const QString & ) { updateDialogButtons(); } ); mFieldsMappingTable->insertRow( index ); mFieldsMappingTable->setCellWidget( index, 0, referencedPolymorphicField ); @@ -191,9 +188,9 @@ QStringList QgsRelationAddPolymorphicDialog::referencedLayerIds() const return QVariant( mReferencedLayersComboBox->checkedItemsData() ).toStringList(); } -QList< QPair< QString, QString > > QgsRelationAddPolymorphicDialog::fieldPairs() const +QList> QgsRelationAddPolymorphicDialog::fieldPairs() const { - QList< QPair< QString, QString > > references; + QList> references; for ( int i = 0, l = mFieldsMappingTable->rowCount(); i < l; i++ ) { QComboBox *referencedFieldComboBox = qobject_cast( mFieldsMappingTable->cellWidget( i, 0 ) ); @@ -220,7 +217,7 @@ QString QgsRelationAddPolymorphicDialog::relationName() const Qgis::RelationshipStrength QgsRelationAddPolymorphicDialog::relationStrength() const { - return static_cast< Qgis::RelationshipStrength >( mRelationStrengthComboBox->currentData().toInt() ); + return static_cast( mRelationStrengthComboBox->currentData().toInt() ); } void QgsRelationAddPolymorphicDialog::updateDialogButtons() diff --git a/src/app/qgsrelationaddpolymorphicdialog.h b/src/app/qgsrelationaddpolymorphicdialog.h index 89181d779f47..9e3f56666e08 100644 --- a/src/app/qgsrelationaddpolymorphicdialog.h +++ b/src/app/qgsrelationaddpolymorphicdialog.h @@ -51,7 +51,7 @@ class APP_EXPORT QgsRelationAddPolymorphicDialog : public QDialog, private Ui::Q /** * Returns field pairs */ - QList< QPair< QString, QString > > fieldPairs() const; + QList> fieldPairs() const; /** * Returns the polymorphic relation id @@ -95,7 +95,6 @@ class APP_EXPORT QgsRelationAddPolymorphicDialog : public QDialog, private Ui::Q void updateFieldsMapping(); bool mIsEditDialog = false; - }; #endif // QGSRELATIONADDPOLYMORPHICDIALOG_H diff --git a/src/app/qgsrelationmanagerdialog.cpp b/src/app/qgsrelationmanagerdialog.cpp index 2ad5718f6e48..18a4f6b39c82 100644 --- a/src/app/qgsrelationmanagerdialog.cpp +++ b/src/app/qgsrelationmanagerdialog.cpp @@ -30,7 +30,7 @@ QgsRelationManagerDialog::QgsRelationManagerDialog( QgsRelationManager *relation { setupUi( this ); - mRelationsTree->setItemDelegate( new RelationNameEditorDelegate( QList( {0} ), mRelationsTree ) ); + mRelationsTree->setItemDelegate( new RelationNameEditorDelegate( QList( { 0 } ), mRelationsTree ) ); connect( mBtnAddRelation, &QPushButton::clicked, this, &QgsRelationManagerDialog::mBtnAddRelation_clicked ); connect( mActionAddPolymorphicRelation, &QAction::triggered, this, &QgsRelationManagerDialog::mActionAddPolymorphicRelation_triggered ); @@ -46,7 +46,7 @@ QgsRelationManagerDialog::QgsRelationManagerDialog( QgsRelationManager *relation connect( mRelationsTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsRelationManagerDialog::onSelectionChanged ); } -void QgsRelationManagerDialog::setLayers( const QList< QgsVectorLayer * > &layers ) +void QgsRelationManagerDialog::setLayers( const QList &layers ) { mLayers = layers; @@ -83,7 +83,7 @@ bool QgsRelationManagerDialog::addRelation( const QgsRelation &rel ) int QgsRelationManagerDialog::addPolymorphicRelation( const QgsPolymorphicRelation &polyRel ) { int itemsAdded = 0; - if ( ! polyRel.isValid() ) + if ( !polyRel.isValid() ) return itemsAdded; QString referencingFields; @@ -141,7 +141,7 @@ int QgsRelationManagerDialog::addPolymorphicRelation( const QgsPolymorphicRelati bool QgsRelationManagerDialog::addRelationPrivate( const QgsRelation &rel, QTreeWidgetItem *parentItem ) { - if ( ! rel.isValid() ) + if ( !rel.isValid() ) return false; QString referencingFields = rel.fieldPairs().at( 0 ).referencingField(); @@ -205,10 +205,7 @@ void QgsRelationManagerDialog::mBtnAddRelation_clicked() QString relationId = addDlg.relationId(); if ( addDlg.relationId().isEmpty() ) relationId = QStringLiteral( "%1_%2_%3_%4" ) - .arg( addDlg.referencingLayerId().left( 10 ), - addDlg.references().at( 0 ).first, - addDlg.referencedLayerId().left( 10 ), - addDlg.references().at( 0 ).second ); + .arg( addDlg.referencingLayerId().left( 10 ), addDlg.references().at( 0 ).first, addDlg.referencedLayerId().left( 10 ), addDlg.references().at( 0 ).second ); QStringList existingNames; @@ -334,9 +331,9 @@ void QgsRelationManagerDialog::mBtnRemoveRelation_clicked() } } -QList< QgsRelation > QgsRelationManagerDialog::relations() +QList QgsRelationManagerDialog::relations() { - QList< QgsRelation > relations; + QList relations; const int rows = mRelationsTree->topLevelItemCount(); relations.reserve( rows ); @@ -356,9 +353,9 @@ QList< QgsRelation > QgsRelationManagerDialog::relations() return relations; } -QList< QgsPolymorphicRelation > QgsRelationManagerDialog::polymorphicRelations() +QList QgsRelationManagerDialog::polymorphicRelations() { - QList< QgsPolymorphicRelation > relations; + QList relations; const int rows = mRelationsTree->topLevelItemCount(); relations.reserve( rows ); @@ -380,12 +377,9 @@ QList< QgsPolymorphicRelation > QgsRelationManagerDialog::polymorphicRelations() void QgsRelationManagerDialog::onSelectionChanged() { - mBtnRemoveRelation->setEnabled( ! mRelationsTree->selectionModel()->selectedRows().isEmpty() ); + mBtnRemoveRelation->setEnabled( !mRelationsTree->selectionModel()->selectedRows().isEmpty() ); const QModelIndexList rows = mRelationsTree->selectionModel()->selectedRows(); - const bool isEditPolymorphicRelationEnabled = ( - rows.size() == 1 - && mRelationsTree->topLevelItem( rows[0].row() )->data( 0, Qt::UserRole ).value().isValid() - ); + const bool isEditPolymorphicRelationEnabled = ( rows.size() == 1 && mRelationsTree->topLevelItem( rows[0].row() )->data( 0, Qt::UserRole ).value().isValid() ); mActionEditPolymorphicRelation->setEnabled( isEditPolymorphicRelationEnabled ); } diff --git a/src/app/qgsrelationmanagerdialog.h b/src/app/qgsrelationmanagerdialog.h index 15dbd37c5825..526c41facb59 100644 --- a/src/app/qgsrelationmanagerdialog.h +++ b/src/app/qgsrelationmanagerdialog.h @@ -37,8 +37,8 @@ class APP_EXPORT QgsRelationManagerDialog : public QWidget, private Ui::QgsRelat bool addRelation( const QgsRelation &rel ); int addPolymorphicRelation( const QgsPolymorphicRelation &relation ); - QList< QgsRelation > relations(); - QList< QgsPolymorphicRelation > polymorphicRelations(); + QList relations(); + QList polymorphicRelations(); private slots: void mBtnAddRelation_clicked(); @@ -52,11 +52,11 @@ class APP_EXPORT QgsRelationManagerDialog : public QWidget, private Ui::QgsRelat bool addRelationPrivate( const QgsRelation &rel, QTreeWidgetItem *parentItem = nullptr ); QgsRelationManager *mRelationManager = nullptr; - QList< QgsVectorLayer * > mLayers; + QList mLayers; QString getUniqueId( const QString &idTmpl, const QString &ids ) const; }; -class RelationNameEditorDelegate: public QStyledItemDelegate +class RelationNameEditorDelegate : public QStyledItemDelegate { Q_OBJECT public: @@ -72,6 +72,7 @@ class RelationNameEditorDelegate: public QStyledItemDelegate return nullptr; } + private: QList mEditableColumns; }; diff --git a/src/app/qgsselectbyformdialog.cpp b/src/app/qgsselectbyformdialog.cpp index 02dc7634de00..4d4acb462591 100644 --- a/src/app/qgsselectbyformdialog.cpp +++ b/src/app/qgsselectbyformdialog.cpp @@ -73,16 +73,12 @@ void QgsSelectByFormDialog::zoomToFeatures( const QString &filter ) { if ( mMessageBar ) { - mMessageBar->pushMessage( QString(), - tr( "Zoomed to %n matching feature(s)", "number of matching features", featureCount ), - Qgis::MessageLevel::Info ); + mMessageBar->pushMessage( QString(), tr( "Zoomed to %n matching feature(s)", "number of matching features", featureCount ), Qgis::MessageLevel::Info ); } } else if ( mMessageBar ) { - mMessageBar->pushMessage( QString(), - tr( "No matching features found" ), - Qgis::MessageLevel::Info ); + mMessageBar->pushMessage( QString(), tr( "No matching features found" ), Qgis::MessageLevel::Info ); } } @@ -91,9 +87,7 @@ void QgsSelectByFormDialog::flashFeatures( const QString &filter ) const long featureCount = QgsMapCanvasUtils::flashMatchingFeatures( mMapCanvas, mLayer, filter ); if ( featureCount == 0 && mMessageBar ) { - mMessageBar->pushMessage( QString(), - tr( "No matching features found" ), - Qgis::MessageLevel::Info ); + mMessageBar->pushMessage( QString(), tr( "No matching features found" ), Qgis::MessageLevel::Info ); } } @@ -110,9 +104,7 @@ void QgsSelectByFormDialog::openFeaturesAttributeTable( const QString &filter ) { if ( mMessageBar ) { - mMessageBar->pushMessage( QString(), - tr( "No matching features found" ), - Qgis::MessageLevel::Info ); + mMessageBar->pushMessage( QString(), tr( "No matching features found" ), Qgis::MessageLevel::Info ); } } } diff --git a/src/app/qgsselectbyformdialog.h b/src/app/qgsselectbyformdialog.h index bb60dcc9c5ad..815d81070992 100644 --- a/src/app/qgsselectbyformdialog.h +++ b/src/app/qgsselectbyformdialog.h @@ -36,7 +36,6 @@ class APP_EXPORT QgsSelectByFormDialog : public QDialog Q_OBJECT public: - /** * Constructor for QgsSelectByFormDialog * \param layer vector layer to select from @@ -44,9 +43,7 @@ class APP_EXPORT QgsSelectByFormDialog : public QDialog * \param parent parent widget * \param fl window flags */ - QgsSelectByFormDialog( QgsVectorLayer *layer, - const QgsAttributeEditorContext &context = QgsAttributeEditorContext(), - QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() ); + QgsSelectByFormDialog( QgsVectorLayer *layer, const QgsAttributeEditorContext &context = QgsAttributeEditorContext(), QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() ); /** * Sets the message bar to display feedback from the form in. This is used in the search/filter @@ -71,12 +68,10 @@ class APP_EXPORT QgsSelectByFormDialog : public QDialog void showFilteredFeaturesAttributeTable( const QString &filter ); private: - QgsAttributeForm *mForm = nullptr; QgsVectorLayer *mLayer = nullptr; QgsMessageBar *mMessageBar = nullptr; QgsMapCanvas *mMapCanvas = nullptr; - }; diff --git a/src/app/qgssettingsregistryapp.cpp b/src/app/qgssettingsregistryapp.cpp index 1e459c8a80e1..6a560a1a7e84 100644 --- a/src/app/qgssettingsregistryapp.cpp +++ b/src/app/qgssettingsregistryapp.cpp @@ -28,7 +28,7 @@ #include "qgsgcptransformer.h" #endif -#if defined(_MSC_VER) +#if defined( _MSC_VER ) #ifndef SIP_RUN template class QgsSettingsEnumEditorWidgetWrapper; template class QgsSettingsEnumEditorWidgetWrapper; @@ -39,7 +39,6 @@ template class QgsSettingsEnumEditorWidgetWrappersettingsEditorWidgetRegistry()->addWrapper( new QgsSettingsEnumEditorWidgetWrapper() ); QgsGui::instance()->settingsEditorWidgetRegistry()->addWrapper( new QgsSettingsEnumEditorWidgetWrapper() ); diff --git a/src/app/qgssettingstreewidgetold.cpp b/src/app/qgssettingstreewidgetold.cpp index 43f48d33ed30..e90ac71e79ef 100644 --- a/src/app/qgssettingstreewidgetold.cpp +++ b/src/app/qgssettingstreewidgetold.cpp @@ -107,8 +107,7 @@ void QgsSettingsTreeWidgetOld::maybeRefresh() void QgsSettingsTreeWidgetOld::refresh() { - disconnect( this, &QTreeWidget::itemChanged, - this, &QgsSettingsTreeWidgetOld::updateSetting ); + disconnect( this, &QTreeWidget::itemChanged, this, &QgsSettingsTreeWidgetOld::updateSetting ); mSettings.sync(); @@ -116,7 +115,7 @@ void QgsSettingsTreeWidgetOld::refresh() QMap::const_iterator it = mSettingsMap.constBegin(); while ( it != mSettingsMap.constEnd() ) { - if ( ! mSettings.contains( it.key() ) ) + if ( !mSettings.contains( it.key() ) ) { mSettings.setValue( it.key(), it.value().at( 3 ) ); } @@ -125,8 +124,7 @@ void QgsSettingsTreeWidgetOld::refresh() updateChildItems( nullptr ); - connect( this, &QTreeWidget::itemChanged, - this, &QgsSettingsTreeWidgetOld::updateSetting ); + connect( this, &QTreeWidget::itemChanged, this, &QgsSettingsTreeWidgetOld::updateSetting ); } bool QgsSettingsTreeWidgetOld::event( QEvent *event ) @@ -162,7 +160,7 @@ void QgsSettingsTreeWidgetOld::showContextMenu( QPoint pos ) if ( !item ) return; - const Type itemType = item->data( ColumnSettings, TypeRole ).value< Type >(); + const Type itemType = item->data( ColumnSettings, TypeRole ).value(); const QString itemText = item->data( ColumnSettings, Qt::DisplayRole ).toString(); const QString itemPath = item->data( ColumnSettings, PathRole ).toString(); mContextMenu->clear(); @@ -172,17 +170,13 @@ void QgsSettingsTreeWidgetOld::showContextMenu( QPoint pos ) case Group: { QAction *deleteAction = new QAction( tr( "Delete Group…" ), mContextMenu ); - connect( deleteAction, &QAction::triggered, this, [ = ] - { - if ( QMessageBox::question( nullptr, tr( "Delete Group" ), - tr( "Are you sure you want to delete the %1 group?" ).arg( itemText ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + connect( deleteAction, &QAction::triggered, this, [=] { + if ( QMessageBox::question( nullptr, tr( "Delete Group" ), tr( "Are you sure you want to delete the %1 group?" ).arg( itemText ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; mSettings.remove( itemPath ); refresh(); - } ); mContextMenu->addAction( deleteAction ); break; @@ -191,11 +185,8 @@ void QgsSettingsTreeWidgetOld::showContextMenu( QPoint pos ) case Setting: { QAction *deleteSetting = new QAction( tr( "Delete Setting…" ), mContextMenu ); - connect( deleteSetting, &QAction::triggered, this, [ = ] - { - if ( QMessageBox::question( nullptr, tr( "Delete Setting" ), - tr( "Are you sure you want to delete the %1 setting?" ).arg( itemPath ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + connect( deleteSetting, &QAction::triggered, this, [=] { + if ( QMessageBox::question( nullptr, tr( "Delete Setting" ), tr( "Are you sure you want to delete the %1 setting?" ).arg( itemPath ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; mSettings.remove( itemPath ); @@ -205,7 +196,6 @@ void QgsSettingsTreeWidgetOld::showContextMenu( QPoint pos ) mContextMenu->addAction( deleteSetting ); break; } - } mContextMenu->exec( mapToGlobal( pos ) ); @@ -284,8 +274,7 @@ void QgsSettingsTreeWidgetOld::updateChildItems( QTreeWidgetItem *parent ) delete childAt( parent, dividerIndex ); } -QTreeWidgetItem *QgsSettingsTreeWidgetOld::createItem( const QString &text, - QTreeWidgetItem *parent, int index, const bool isGroup ) +QTreeWidgetItem *QgsSettingsTreeWidgetOld::createItem( const QString &text, QTreeWidgetItem *parent, int index, const bool isGroup ) { QTreeWidgetItem *after = nullptr; if ( index != 0 ) @@ -311,7 +300,7 @@ QTreeWidgetItem *QgsSettingsTreeWidgetOld::createItem( const QString &text, if ( mSettingsMap.contains( key ) ) { QgsDebugMsgLevel( QStringLiteral( "contains!!!!" ), 4 ); - const QStringList values = mSettingsMap[ key ]; + const QStringList values = mSettingsMap[key]; item->setText( ColumnDescription, values.at( 0 ) ); item->setToolTip( ColumnDescription, values.at( 0 ) ); item->setToolTip( ColumnSettings, values.at( 1 ) ); @@ -323,7 +312,7 @@ QTreeWidgetItem *QgsSettingsTreeWidgetOld::createItem( const QString &text, QString QgsSettingsTreeWidgetOld::itemKey( QTreeWidgetItem *item ) { - if ( ! item ) + if ( !item ) return QString(); QString key = item->text( ColumnSettings ); @@ -353,8 +342,7 @@ int QgsSettingsTreeWidgetOld::childCount( QTreeWidgetItem *parent ) return topLevelItemCount(); } -int QgsSettingsTreeWidgetOld::findChild( QTreeWidgetItem *parent, const QString &text, - int startIndex ) +int QgsSettingsTreeWidgetOld::findChild( QTreeWidgetItem *parent, const QString &text, int startIndex ) { for ( int i = startIndex; i < childCount( parent ); ++i ) { @@ -364,8 +352,7 @@ int QgsSettingsTreeWidgetOld::findChild( QTreeWidgetItem *parent, const QString return -1; } -void QgsSettingsTreeWidgetOld::moveItemForward( QTreeWidgetItem *parent, int oldIndex, - int newIndex ) +void QgsSettingsTreeWidgetOld::moveItemForward( QTreeWidgetItem *parent, int oldIndex, int newIndex ) { for ( int i = 0; i < oldIndex - newIndex; ++i ) delete childAt( parent, newIndex ); diff --git a/src/app/qgssettingstreewidgetold.h b/src/app/qgssettingstreewidgetold.h index 1dff30e8af41..8f21bd4a4449 100644 --- a/src/app/qgssettingstreewidgetold.h +++ b/src/app/qgssettingstreewidgetold.h @@ -52,19 +52,18 @@ class QgsSettingsTreeWidgetOld : public QTreeWidget Q_OBJECT public: - //! Model roles enum Roles { TypeRole = Qt::UserRole + 1, //!< Item type role, see Type enum - PathRole, //!< Complete setting path, including parent groups + PathRole, //!< Complete setting path, including parent groups }; //! Item types enum Type { Group = 0, //!< Group item - Setting, //!< Setting item + Setting, //!< Setting item }; Q_ENUM( Type ) @@ -72,7 +71,7 @@ class QgsSettingsTreeWidgetOld : public QTreeWidget QSize sizeHint() const override; - void setSettingsMap( QMap< QString, QStringList > &map ) { mSettingsMap = map; } + void setSettingsMap( QMap &map ) { mSettingsMap = map; } QString itemKey( QTreeWidgetItem *item ); public slots: @@ -89,7 +88,6 @@ class QgsSettingsTreeWidgetOld : public QTreeWidget void showContextMenu( QPoint pos ); private: - enum Columns { ColumnSettings = 0, @@ -99,8 +97,7 @@ class QgsSettingsTreeWidgetOld : public QTreeWidget }; void updateChildItems( QTreeWidgetItem *parent ); - QTreeWidgetItem *createItem( const QString &text, QTreeWidgetItem *parent, - int index, bool isGroup ); + QTreeWidgetItem *createItem( const QString &text, QTreeWidgetItem *parent, int index, bool isGroup ); QTreeWidgetItem *childAt( QTreeWidgetItem *parent, int index ); int childCount( QTreeWidgetItem *parent ); int findChild( QTreeWidgetItem *parent, const QString &text, int startIndex ); @@ -112,7 +109,7 @@ class QgsSettingsTreeWidgetOld : public QTreeWidget QIcon mGroupIcon; QIcon mKeyIcon; - QMap< QString, QStringList > mSettingsMap; + QMap mSettingsMap; QMenu *mContextMenu = nullptr; }; diff --git a/src/app/qgssnappinglayertreemodel.cpp b/src/app/qgssnappinglayertreemodel.cpp index cd18fa3a05ce..7748ac27cf37 100644 --- a/src/app/qgssnappinglayertreemodel.cpp +++ b/src/app/qgssnappinglayertreemodel.cpp @@ -136,7 +136,7 @@ void QgsSnappingLayerDelegate::setEditorData( QWidget *editor, const QModelIndex const QList actions = tb->menu()->actions(); for ( QAction *action : actions ) { - action->setChecked( type & static_cast< Qgis::SnappingTypes >( action->data().toInt() ) ); + action->setChecked( type & static_cast( action->data().toInt() ) ); } } } @@ -195,10 +195,10 @@ void QgsSnappingLayerDelegate::setModelData( QWidget *editor, QAbstractItemModel } model->setData( index, static_cast( type ), Qt::EditRole ); } - } else if ( - index.column() == QgsSnappingLayerTreeModel::UnitsColumn ) + index.column() == QgsSnappingLayerTreeModel::UnitsColumn + ) { QComboBox *w = qobject_cast( editor ); if ( w ) @@ -242,7 +242,7 @@ QgsSnappingLayerTreeModel::QgsSnappingLayerTreeModel( QgsProject *project, QgsMa { connect( project, &QgsProject::snappingConfigChanged, this, &QgsSnappingLayerTreeModel::onSnappingSettingsChanged ); connect( project, &QgsProject::avoidIntersectionsLayersChanged, this, &QgsSnappingLayerTreeModel::onSnappingSettingsChanged ); - connect( project, &QgsProject::readProject, this, [ = ] {resetLayerTreeModel();} ); + connect( project, &QgsProject::readProject, this, [=] { resetLayerTreeModel(); } ); } int QgsSnappingLayerTreeModel::columnCount( const QModelIndex &parent ) const @@ -479,7 +479,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con if ( role == Qt::CheckStateRole ) { QgsVectorLayer *vl = vectorLayer( idx ); - if ( vl && mIndividualLayerSettings.contains( vl ) ) + if ( vl && mIndividualLayerSettings.contains( vl ) ) { const QgsSnappingConfig::IndividualLayerSettings ls = mIndividualLayerSettings.value( vl ); if ( !ls.valid() ) @@ -527,7 +527,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con return Qt::Unchecked; // both - if ( hasChecked && hasUnchecked ) + if ( hasChecked && hasUnchecked ) return Qt::PartiallyChecked; if ( hasChecked ) @@ -694,7 +694,7 @@ bool QgsSnappingLayerTreeModel::setData( const QModelIndex &index, const QVarian if ( role == Qt::CheckStateRole ) { int i = 0; - for ( i = 0; ; i++ ) + for ( i = 0;; i++ ) { const QModelIndex child = QgsSnappingLayerTreeModel::index( i, LayerColumn, index ); if ( !child.isValid() ) diff --git a/src/app/qgssnappinglayertreemodel.h b/src/app/qgssnappinglayertreemodel.h index af0fad3fe7ee..f918c34725fd 100644 --- a/src/app/qgssnappinglayertreemodel.h +++ b/src/app/qgssnappinglayertreemodel.h @@ -17,7 +17,6 @@ #define QGSSNAPPINGLAYERTREEVIEW_H - #include #include @@ -77,7 +76,11 @@ class APP_EXPORT QgsSnappingLayerTreeModel : public QSortFilterProxyModel QgsLayerTreeModel *layerTreeModel() const; void setLayerTreeModel( QgsLayerTreeModel *layerTreeModel ); - void resetLayerTreeModel() { beginResetModel(); endResetModel(); } + void resetLayerTreeModel() + { + beginResetModel(); + endResetModel(); + } QgsVectorLayer *vectorLayer( const QModelIndex &idx ) const; @@ -102,7 +105,7 @@ class APP_EXPORT QgsSnappingLayerTreeModel : public QSortFilterProxyModel void hasRowchanged( QgsLayerTreeNode *node, const QHash &oldSettings ); }; -class SnappingLayerDelegateTypeMenu: public QMenu +class SnappingLayerDelegateTypeMenu : public QMenu { Q_OBJECT diff --git a/src/app/qgssnappingwidget.cpp b/src/app/qgssnappingwidget.cpp index 897d4629e26d..4223f4987d8d 100644 --- a/src/app/qgssnappingwidget.cpp +++ b/src/app/qgssnappingwidget.cpp @@ -86,7 +86,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas, connect( model, &QgsSnappingLayerTreeModel::rowsInserted, this, &QgsSnappingWidget::onSnappingTreeLayersChanged ); connect( model, &QgsSnappingLayerTreeModel::modelReset, this, &QgsSnappingWidget::onSnappingTreeLayersChanged ); connect( model, &QgsSnappingLayerTreeModel::rowsRemoved, this, &QgsSnappingWidget::onSnappingTreeLayersChanged ); - connect( mProject, &QObject::destroyed, this, [ = ] {mLayerTreeView->setModel( nullptr );} ); + connect( mProject, &QObject::destroyed, this, [=] { mLayerTreeView->setModel( nullptr ); } ); // model->setFlags( 0 ); mLayerTreeView->setModel( model ); mLayerTreeView->resizeColumnToContents( 0 ); @@ -200,7 +200,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas, mToleranceSpinBox->setMaximum( 99999999.990000 ); mToleranceSpinBox->setToolTip( tr( "Snapping Tolerance in Defined Units" ) ); mToleranceSpinBox->setObjectName( QStringLiteral( "SnappingToleranceSpinBox" ) ); - connect( mToleranceSpinBox, qOverload< double >( &QgsDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeTolerance ); + connect( mToleranceSpinBox, qOverload( &QgsDoubleSpinBox::valueChanged ), this, &QgsSnappingWidget::changeTolerance ); // units mUnitsComboBox = new QComboBox(); @@ -210,11 +210,9 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas, mUnitsComboBox->addItem( mapCanvasDistanceUnits, QVariant::fromValue( Qgis::MapToolUnit::Project ) ); mUnitsComboBox->setToolTip( tr( "Snapping Unit Type: Pixels (px) or Project/Map Units (%1)" ).arg( mapCanvasDistanceUnits ) ); mUnitsComboBox->setObjectName( QStringLiteral( "SnappingUnitComboBox" ) ); - connect( mUnitsComboBox, qOverload( &QComboBox::currentIndexChanged ), - this, &QgsSnappingWidget::changeUnit ); + connect( mUnitsComboBox, qOverload( &QComboBox::currentIndexChanged ), this, &QgsSnappingWidget::changeUnit ); - connect( mCanvas, &QgsMapCanvas::destinationCrsChanged, this, [ = ] - { + connect( mCanvas, &QgsMapCanvas::destinationCrsChanged, this, [=] { // Update map units from canvas const QString mapCanvasDistanceUnits { QgsUnitTypes::toString( mCanvas->mapSettings().mapUnits() ) }; mUnitsComboBox->setItemText( 1, mapCanvasDistanceUnits ); @@ -491,7 +489,6 @@ void QgsSnappingWidget::projectSnapSettingsChanged() } toggleSnappingWidgets( config.enabled() ); - } void QgsSnappingWidget::projectAvoidIntersectionModeChanged() @@ -581,7 +578,7 @@ void QgsSnappingWidget::changeMaxScale( double maxScale ) void QgsSnappingWidget::changeUnit( int idx ) { - Qgis::MapToolUnit unit = mUnitsComboBox->itemData( idx ).value< Qgis::MapToolUnit >(); + Qgis::MapToolUnit unit = mUnitsComboBox->itemData( idx ).value(); mConfig.setUnits( unit ); mProject->setSnappingConfig( mConfig ); @@ -621,9 +618,7 @@ void QgsSnappingWidget::onSnappingTreeLayersChanged() void QgsSnappingWidget::avoidIntersectionsModeButtonTriggered( QAction *action ) { - if ( action != mAllowIntersectionsAction && - action != mAvoidIntersectionsCurrentLayerAction && - action != mAvoidIntersectionsLayersAction ) + if ( action != mAllowIntersectionsAction && action != mAvoidIntersectionsCurrentLayerAction && action != mAvoidIntersectionsLayersAction ) { return; } @@ -648,9 +643,7 @@ void QgsSnappingWidget::avoidIntersectionsModeButtonTriggered( QAction *action ) void QgsSnappingWidget::modeButtonTriggered( QAction *action ) { - if ( action != mAllLayersAction && - action != mActiveLayerAction && - action != mAdvancedModeAction ) + if ( action != mAllLayersAction && action != mActiveLayerAction && action != mAdvancedModeAction ) { return; } @@ -712,7 +705,7 @@ void QgsSnappingWidget::snappingScaleModeTriggered( QAction *action ) if ( action == mDefaultSnappingScaleAct ) { - mode = QgsSnappingConfig::Disabled; + mode = QgsSnappingConfig::Disabled; } else if ( action == mGlobalSnappingScaleAct ) { @@ -796,7 +789,7 @@ void QgsSnappingWidget::setConfig( const QgsSnappingConfig &config ) bool QgsSnappingWidget::eventFilter( QObject *watched, QEvent *event ) { - if ( watched == mLayerTreeView && event->type() == QEvent::Show ) + if ( watched == mLayerTreeView && event->type() == QEvent::Show ) { if ( mRequireLayerTreeViewUpdate ) { diff --git a/src/app/qgssnappingwidget.h b/src/app/qgssnappingwidget.h index 9dac2334a2e4..46c3291c68ea 100644 --- a/src/app/qgssnappingwidget.h +++ b/src/app/qgssnappingwidget.h @@ -51,7 +51,6 @@ class APP_EXPORT QgsSnappingWidget : public QWidget Q_OBJECT public: - /** * Constructor * \param project The project with which this widget configuration will be synchronized @@ -157,7 +156,7 @@ class APP_EXPORT QgsSnappingWidget : public QWidget QAction *mEditAdvancedConfigAction = nullptr; QToolButton *mTypeButton = nullptr; QAction *mTypeAction = nullptr; // hide widget does not work on toolbar, action needed - QList< QAction * > mSnappingFlagActions; + QList mSnappingFlagActions; QgsDoubleSpinBox *mToleranceSpinBox = nullptr; QgsScaleWidget *mMinScaleWidget = nullptr; QgsScaleWidget *mMaxScaleWidget = nullptr; @@ -181,7 +180,7 @@ class APP_EXPORT QgsSnappingWidget : public QWidget void cleanGroup( QgsLayerTreeNode *node ); }; -class SnapTypeMenu: public QMenu +class SnapTypeMenu : public QMenu { Q_OBJECT public: diff --git a/src/app/qgsstatisticalsummarydockwidget.cpp b/src/app/qgsstatisticalsummarydockwidget.cpp index ff2383120860..f7a20dbc1657 100644 --- a/src/app/qgsstatisticalsummarydockwidget.cpp +++ b/src/app/qgsstatisticalsummarydockwidget.cpp @@ -33,12 +33,12 @@ #include #include -typedef QList< Qgis::Statistic > StatsList; -typedef QList< Qgis::StringStatistic > StringStatsList; -typedef QList< Qgis::DateTimeStatistic > DateTimeStatsList; -Q_GLOBAL_STATIC_WITH_ARGS( StatsList, sDisplayStats, ( {Qgis::Statistic::Count, Qgis::Statistic::Sum, Qgis::Statistic::Mean, Qgis::Statistic::Median, Qgis::Statistic::StDev, Qgis::Statistic::StDevSample, Qgis::Statistic::Min, Qgis::Statistic::Max, Qgis::Statistic::Range, Qgis::Statistic::Minority, Qgis::Statistic::Majority, Qgis::Statistic::Variety, Qgis::Statistic::FirstQuartile, Qgis::Statistic::ThirdQuartile, Qgis::Statistic::InterQuartileRange} ) ) -Q_GLOBAL_STATIC_WITH_ARGS( StringStatsList, sDisplayStringStats, ( {Qgis::StringStatistic::Count, Qgis::StringStatistic::CountDistinct, Qgis::StringStatistic::CountMissing, Qgis::StringStatistic::Min, Qgis::StringStatistic::Max, Qgis::StringStatistic::Minority, Qgis::StringStatistic::Majority, Qgis::StringStatistic::MinimumLength, Qgis::StringStatistic::MaximumLength, Qgis::StringStatistic::MeanLength} ) ) -Q_GLOBAL_STATIC_WITH_ARGS( DateTimeStatsList, sDisplayDateTimeStats, ( {Qgis::DateTimeStatistic::Count, Qgis::DateTimeStatistic::CountDistinct, Qgis::DateTimeStatistic::CountMissing, Qgis::DateTimeStatistic::Min, Qgis::DateTimeStatistic::Max, Qgis::DateTimeStatistic::Range} ) ) +typedef QList StatsList; +typedef QList StringStatsList; +typedef QList DateTimeStatsList; +Q_GLOBAL_STATIC_WITH_ARGS( StatsList, sDisplayStats, ( { Qgis::Statistic::Count, Qgis::Statistic::Sum, Qgis::Statistic::Mean, Qgis::Statistic::Median, Qgis::Statistic::StDev, Qgis::Statistic::StDevSample, Qgis::Statistic::Min, Qgis::Statistic::Max, Qgis::Statistic::Range, Qgis::Statistic::Minority, Qgis::Statistic::Majority, Qgis::Statistic::Variety, Qgis::Statistic::FirstQuartile, Qgis::Statistic::ThirdQuartile, Qgis::Statistic::InterQuartileRange } ) ) +Q_GLOBAL_STATIC_WITH_ARGS( StringStatsList, sDisplayStringStats, ( { Qgis::StringStatistic::Count, Qgis::StringStatistic::CountDistinct, Qgis::StringStatistic::CountMissing, Qgis::StringStatistic::Min, Qgis::StringStatistic::Max, Qgis::StringStatistic::Minority, Qgis::StringStatistic::Majority, Qgis::StringStatistic::MinimumLength, Qgis::StringStatistic::MaximumLength, Qgis::StringStatistic::MeanLength } ) ) +Q_GLOBAL_STATIC_WITH_ARGS( DateTimeStatsList, sDisplayDateTimeStats, ( { Qgis::DateTimeStatistic::Count, Qgis::DateTimeStatistic::CountDistinct, Qgis::DateTimeStatistic::CountMissing, Qgis::DateTimeStatistic::Min, Qgis::DateTimeStatistic::Max, Qgis::DateTimeStatistic::Range } ) ) #define MISSING_VALUES -1 @@ -65,9 +65,7 @@ QgsStatisticalSummaryDockWidget::QgsStatisticalSummaryDockWidget( QWidget *paren mFieldExpressionWidget->registerExpressionContextGenerator( this ); mLayerComboBox->setFilters( Qgis::LayerFilter::VectorLayer ); - mFieldExpressionWidget->setFilters( QgsFieldProxyModel::Numeric | - QgsFieldProxyModel::String | - QgsFieldProxyModel::Date ); + mFieldExpressionWidget->setFilters( QgsFieldProxyModel::Numeric | QgsFieldProxyModel::String | QgsFieldProxyModel::Date ); mLayerComboBox->setLayer( mLayerComboBox->layer( 0 ) ); mFieldExpressionWidget->setLayer( mLayerComboBox->layer( 0 ) ); @@ -89,8 +87,7 @@ QgsStatisticalSummaryDockWidget::QgsStatisticalSummaryDockWidget( QWidget *paren mPreviousFieldType = DataType::Numeric; refreshStatisticsMenu(); - connect( this, &QgsDockWidget::visibilityChanged, this, [ = ]( bool visible ) - { + connect( this, &QgsDockWidget::visibilityChanged, this, [=]( bool visible ) { if ( mPendingCalculate && visible ) refreshStatistics(); } ); @@ -123,7 +120,7 @@ void QgsStatisticalSummaryDockWidget::copyStatistics() { for ( int j = 0; j < mStatisticsTable->columnCount(); j++ ) { - QTableWidgetItem *item = mStatisticsTable->item( i, j ); + QTableWidgetItem *item = mStatisticsTable->item( i, j ); columns += item->text(); } rows += columns.join( QLatin1Char( '\t' ) ); @@ -132,9 +129,7 @@ void QgsStatisticalSummaryDockWidget::copyStatistics() if ( !rows.isEmpty() ) { - const QString text = QStringLiteral( "%1\t%2\n%3" ).arg( mStatisticsTable->horizontalHeaderItem( 0 )->text(), - mStatisticsTable->horizontalHeaderItem( 1 )->text(), - rows.join( QLatin1Char( '\n' ) ) ); + const QString text = QStringLiteral( "%1\t%2\n%3" ).arg( mStatisticsTable->horizontalHeaderItem( 0 )->text(), mStatisticsTable->horizontalHeaderItem( 1 )->text(), rows.join( QLatin1Char( '\n' ) ) ); QString html = QStringLiteral( "
    %1
    " ).arg( text ); html.replace( QLatin1String( "\t" ), QLatin1String( "" ) ).replace( QLatin1String( "\n" ), QLatin1String( "" ) ); @@ -229,13 +224,12 @@ void QgsStatisticalSummaryDockWidget::refreshStatistics() switch ( mFieldType ) { - case Numeric: { const auto displayStats = *sDisplayStats(); for ( const Qgis::Statistic stat : displayStats ) { - if ( mStatsActions.value( static_cast< int >( stat ) )->isChecked() ) + if ( mStatsActions.value( static_cast( stat ) )->isChecked() ) { statsToCalc |= stat; } @@ -247,7 +241,7 @@ void QgsStatisticalSummaryDockWidget::refreshStatistics() const auto displayStringStats = *sDisplayStringStats(); for ( const Qgis::StringStatistic stat : displayStringStats ) { - if ( mStatsActions.value( static_cast< int >( stat ) )->isChecked() ) + if ( mStatsActions.value( static_cast( stat ) )->isChecked() ) { stringStatsToCalc |= stat; } @@ -259,7 +253,7 @@ void QgsStatisticalSummaryDockWidget::refreshStatistics() const auto displayDateTimeStats = *sDisplayDateTimeStats(); for ( const Qgis::DateTimeStatistic stat : displayDateTimeStats ) { - if ( mStatsActions.value( static_cast< int >( stat ) )->isChecked() ) + if ( mStatsActions.value( static_cast( stat ) )->isChecked() ) { dateTimeStatsToCalc |= stat; } @@ -269,7 +263,7 @@ void QgsStatisticalSummaryDockWidget::refreshStatistics() } const long featureCount = selectedOnly ? mLayer->selectedFeatureCount() : mLayer->featureCount(); - std::unique_ptr< QgsStatisticsValueGatherer > gatherer = std::make_unique< QgsStatisticsValueGatherer >( mLayer, fit, featureCount, sourceFieldExp, mFieldType, statsToCalc, stringStatsToCalc, dateTimeStatsToCalc ); + std::unique_ptr gatherer = std::make_unique( mLayer, fit, featureCount, sourceFieldExp, mFieldType, statsToCalc, stringStatsToCalc, dateTimeStatsToCalc ); switch ( mFieldType ) { case DataType::Numeric: @@ -325,11 +319,11 @@ void QgsStatisticalSummaryDockWidget::updateNumericStatistics() if ( gatherer != mGatherer ) return; - QList< Qgis::Statistic > statsToDisplay; + QList statsToDisplay; const auto displayStats = *sDisplayStats(); for ( const Qgis::Statistic stat : displayStats ) { - if ( mStatsActions.value( static_cast< int >( stat ) )->isChecked() ) + if ( mStatsActions.value( static_cast( stat ) )->isChecked() ) { statsToDisplay << stat; } @@ -347,17 +341,13 @@ void QgsStatisticalSummaryDockWidget::updateNumericStatistics() for ( const Qgis::Statistic stat : std::as_const( statsToDisplay ) ) { const double val = stats->statistic( stat ); - addRow( row, QgsStatisticalSummary::displayName( stat ), - std::isnan( val ) ? QString() : QLocale().toString( val ), - stats->count() != 0 ); + addRow( row, QgsStatisticalSummary::displayName( stat ), std::isnan( val ) ? QString() : QLocale().toString( val ), stats->count() != 0 ); row++; } if ( mStatsActions.value( MISSING_VALUES )->isChecked() ) { - addRow( row, tr( "Missing (null) values" ), - QLocale().toString( stats->countMissing() ), - stats->count() != 0 || stats->countMissing() != 0 ); + addRow( row, tr( "Missing (null) values" ), QLocale().toString( stats->countMissing() ), stats->count() != 0 || stats->countMissing() != 0 ); row++; } @@ -374,11 +364,11 @@ void QgsStatisticalSummaryDockWidget::updateStringStatistics() if ( gatherer != mGatherer ) return; - QList< Qgis::StringStatistic > statsToDisplay; + QList statsToDisplay; const auto displayStringStats = *sDisplayStringStats(); for ( const Qgis::StringStatistic stat : displayStringStats ) { - if ( mStatsActions.value( static_cast< int >( stat ) )->isChecked() ) + if ( mStatsActions.value( static_cast( stat ) )->isChecked() ) { statsToDisplay << stat; } @@ -391,9 +381,7 @@ void QgsStatisticalSummaryDockWidget::updateStringStatistics() const QgsStringStatisticalSummary *stats = gatherer->stringStatsSummary(); for ( const Qgis::StringStatistic stat : std::as_const( statsToDisplay ) ) { - addRow( row, QgsStringStatisticalSummary::displayName( stat ), - stats->statistic( stat ).toString(), - stats->count() != 0 ); + addRow( row, QgsStringStatisticalSummary::displayName( stat ), stats->statistic( stat ).toString(), stats->count() != 0 ); row++; } @@ -404,7 +392,7 @@ void QgsStatisticalSummaryDockWidget::updateStringStatistics() void QgsStatisticalSummaryDockWidget::layerChanged( QgsMapLayer *layer ) { - QgsVectorLayer *newLayer = qobject_cast< QgsVectorLayer * >( layer ); + QgsVectorLayer *newLayer = qobject_cast( layer ); if ( mLayer && mLayer != newLayer ) { disconnect( mLayer, &QgsVectorLayer::selectionChanged, this, &QgsStatisticalSummaryDockWidget::layerSelectionChanged ); @@ -495,11 +483,11 @@ void QgsStatisticalSummaryDockWidget::updateDateTimeStatistics() if ( gatherer != mGatherer ) return; - QList< Qgis::DateTimeStatistic > statsToDisplay; + QList statsToDisplay; const auto displayDateTimeStats = *sDisplayDateTimeStats(); for ( const Qgis::DateTimeStatistic stat : displayDateTimeStats ) { - if ( mStatsActions.value( static_cast< int >( stat ) )->isChecked() ) + if ( mStatsActions.value( static_cast( stat ) )->isChecked() ) { statsToDisplay << stat; } @@ -512,13 +500,9 @@ void QgsStatisticalSummaryDockWidget::updateDateTimeStatistics() const QgsDateTimeStatisticalSummary *stats = gatherer->dateTimeStatsSummary(); for ( const Qgis::DateTimeStatistic stat : std::as_const( statsToDisplay ) ) { - const QString value = ( stat == Qgis::DateTimeStatistic::Range - ? tr( "%n second(s)", nullptr, stats->range().seconds() ) - : stats->statistic( stat ).toString() ); + const QString value = ( stat == Qgis::DateTimeStatistic::Range ? tr( "%n second(s)", nullptr, stats->range().seconds() ) : stats->statistic( stat ).toString() ); - addRow( row, QgsDateTimeStatisticalSummary::displayName( stat ), - value, - stats->count() != 0 ); + addRow( row, QgsDateTimeStatisticalSummary::displayName( stat ), value, stats->count() != 0 ); row++; } @@ -527,8 +511,7 @@ void QgsStatisticalSummaryDockWidget::updateDateTimeStatistics() gathererFinished(); } -void QgsStatisticalSummaryDockWidget::addRow( int row, const QString &name, const QString &value, - bool showValue ) +void QgsStatisticalSummaryDockWidget::addRow( int row, const QString &name, const QString &value, bool showValue ) { QTableWidgetItem *nameItem = new QTableWidgetItem( name ); nameItem->setToolTip( name ); @@ -560,10 +543,10 @@ void QgsStatisticalSummaryDockWidget::refreshStatisticsMenu() { QAction *action = new QAction( QgsStatisticalSummary::displayName( stat ), mStatisticsMenu ); action->setCheckable( true ); - const bool checked = settings.value( QStringLiteral( "StatisticalSummaryDock/numeric_%1" ).arg( static_cast< int >( stat ) ), true ).toBool(); + const bool checked = settings.value( QStringLiteral( "StatisticalSummaryDock/numeric_%1" ).arg( static_cast( stat ) ), true ).toBool(); action->setChecked( checked ); - action->setData( static_cast< int >( stat ) ); - mStatsActions.insert( static_cast< int >( stat ), action ); + action->setData( static_cast( stat ) ); + mStatsActions.insert( static_cast( stat ), action ); connect( action, &QAction::toggled, this, &QgsStatisticalSummaryDockWidget::statActionTriggered ); mStatisticsMenu->addAction( action ); } @@ -587,10 +570,10 @@ void QgsStatisticalSummaryDockWidget::refreshStatisticsMenu() { QAction *action = new QAction( QgsStringStatisticalSummary::displayName( stat ), mStatisticsMenu ); action->setCheckable( true ); - const bool checked = settings.value( QStringLiteral( "StatisticalSummaryDock/string_%1" ).arg( static_cast< int >( stat ) ), true ).toBool(); + const bool checked = settings.value( QStringLiteral( "StatisticalSummaryDock/string_%1" ).arg( static_cast( stat ) ), true ).toBool(); action->setChecked( checked ); - action->setData( static_cast< int >( stat ) ); - mStatsActions.insert( static_cast< int >( stat ), action ); + action->setData( static_cast( stat ) ); + mStatsActions.insert( static_cast( stat ), action ); connect( action, &QAction::toggled, this, &QgsStatisticalSummaryDockWidget::statActionTriggered ); mStatisticsMenu->addAction( action ); } @@ -603,10 +586,10 @@ void QgsStatisticalSummaryDockWidget::refreshStatisticsMenu() { QAction *action = new QAction( QgsDateTimeStatisticalSummary::displayName( stat ), mStatisticsMenu ); action->setCheckable( true ); - const bool checked = settings.value( QStringLiteral( "StatisticalSummaryDock/datetime_%1" ).arg( static_cast< int >( stat ) ), true ).toBool(); + const bool checked = settings.value( QStringLiteral( "StatisticalSummaryDock/datetime_%1" ).arg( static_cast( stat ) ), true ).toBool(); action->setChecked( checked ); - action->setData( static_cast< int >( stat ) ); - mStatsActions.insert( static_cast< int >( stat ), action ); + action->setData( static_cast( stat ) ); + mStatsActions.insert( static_cast( stat ), action ); connect( action, &QAction::toggled, this, &QgsStatisticalSummaryDockWidget::statActionTriggered ); mStatisticsMenu->addAction( action ); } @@ -648,7 +631,8 @@ QgsStatisticsValueGatherer::QgsStatisticsValueGatherer( DataType fieldType, Qgis::Statistics statsToCalculate, Qgis::StringStatistics stringStatsToCalculate, - Qgis::DateTimeStatistics dateTimeStatsToCalculate ) + Qgis::DateTimeStatistics dateTimeStatsToCalculate +) : QgsTask( tr( "Fetching statistic values" ), QgsTask::CanCancel | QgsTask::CancelWithoutPrompt ) , mFeatureIterator( fit ) , mFeatureCount( featureCount ) @@ -677,13 +661,13 @@ bool QgsStatisticsValueGatherer::run() switch ( mFieldType ) { case Numeric: - mStatsSummary = std::make_unique< QgsStatisticalSummary >( mStatsToCalculate ); + mStatsSummary = std::make_unique( mStatsToCalculate ); break; case String: - mStringStatsSummary = std::make_unique< QgsStringStatisticalSummary >( mStringStatsToCalculate ); + mStringStatsSummary = std::make_unique( mStringStatsToCalculate ); break; case DateTime: - mDateTimeStatsSummary = std::make_unique< QgsDateTimeStatisticalSummary >( mDateTimeStatsToCalculate ); + mDateTimeStatsSummary = std::make_unique( mDateTimeStatsToCalculate ); break; } @@ -731,7 +715,7 @@ bool QgsStatisticsValueGatherer::run() current++; if ( mFeatureCount > 0 ) { - setProgress( 100.0 * static_cast< double >( current ) / mFeatureCount ); + setProgress( 100.0 * static_cast( current ) / mFeatureCount ); } } diff --git a/src/app/qgsstatisticalsummarydockwidget.h b/src/app/qgsstatisticalsummarydockwidget.h index f661d85ce36b..b2923f3489ca 100644 --- a/src/app/qgsstatisticalsummarydockwidget.h +++ b/src/app/qgsstatisticalsummarydockwidget.h @@ -39,9 +39,9 @@ class QgsDateTimeStatisticalSummary; //! Enumeration of supported statistics types enum DataType { - Numeric, //!< Numeric fields: int, double, etc + Numeric, //!< Numeric fields: int, double, etc String, //!< String fields - DateTime //!< Date and DateTime fields + DateTime //!< Date and DateTime fields }; /** @@ -72,7 +72,6 @@ class QgsStatisticsValueGatherer : public QgsTask const QgsDateTimeStatisticalSummary *dateTimeStatsSummary(); private: - QgsFeatureIterator mFeatureIterator; long mFeatureCount = 0; QString mFieldExpression; @@ -85,9 +84,9 @@ class QgsStatisticsValueGatherer : public QgsTask std::unique_ptr mExpression; QgsExpressionContext mContext; - std::unique_ptr< QgsStatisticalSummary > mStatsSummary; - std::unique_ptr< QgsStringStatisticalSummary > mStringStatsSummary; - std::unique_ptr< QgsDateTimeStatisticalSummary > mDateTimeStatsSummary; + std::unique_ptr mStatsSummary; + std::unique_ptr mStringStatsSummary; + std::unique_ptr mDateTimeStatsSummary; }; /** @@ -128,11 +127,10 @@ class APP_EXPORT QgsStatisticalSummaryDockWidget : public QgsDockWidget, private void gathererFinished(); private: - QgsVectorLayer *mLayer = nullptr; - QMap< int, QAction * > mStatsActions; - QMap< QString, QString > mLastExpression; + QMap mStatsActions; + QMap mLastExpression; QAction *mSyncAction; void updateNumericStatistics(); @@ -152,7 +150,7 @@ class APP_EXPORT QgsStatisticalSummaryDockWidget : public QgsDockWidget, private QString mExpression; - QPointer< QgsStatisticsValueGatherer > mGatherer; + QPointer mGatherer; bool mPendingCalculate = false; }; diff --git a/src/app/qgsstatusbarcoordinateswidget.cpp b/src/app/qgsstatusbarcoordinateswidget.cpp index 4479d8591f11..0c4fd57b85d4 100644 --- a/src/app/qgsstatusbarcoordinateswidget.cpp +++ b/src/app/qgsstatusbarcoordinateswidget.cpp @@ -166,7 +166,7 @@ void QgsStatusBarCoordinatesWidget::validateCoordinates() } bool xOk = false; - bool yOk = false; + bool yOk = false; double first = 0; double second = 0; QString coordText = mLineEdit->text(); @@ -198,7 +198,7 @@ void QgsStatusBarCoordinatesWidget::validateCoordinates() if ( parts.size() == 2 ) { first = QLocale().toDouble( parts.at( 0 ), &xOk ); - second = QLocale().toDouble( parts.at( 1 ), &yOk ); + second = QLocale().toDouble( parts.at( 1 ), &yOk ); } } @@ -223,12 +223,11 @@ void QgsStatusBarCoordinatesWidget::validateCoordinates() const QgsCoordinateReferenceSystem displayCrs = QgsProject::instance()->displaySettings()->coordinateCrs(); const QgsCoordinateReferenceSystem canvasCrs = mMapCanvas->mapSettings().destinationCrs(); - if ( displayCrs.isValid() && canvasCrs.isValid() && displayCrs != canvasCrs ) + if ( displayCrs.isValid() && canvasCrs.isValid() && displayCrs != canvasCrs ) { const QgsCoordinateTransform ct { displayCrs, canvasCrs, QgsProject::instance()->transformContext() }; try { - centerPoint = ct.transform( centerPoint ); } catch ( const QgsCsException & ) @@ -256,10 +255,10 @@ void QgsStatusBarCoordinatesWidget::dizzy() if ( rect.x() < -d || rect.x() > d || rect.y() < -d || rect.y() > d ) return; // do not affect panning - rect.moveTo( static_cast< int >( QRandomGenerator::global()->generate() % ( 2 * d ) ) - d, static_cast< int >( QRandomGenerator::global()->generate() % ( 2 * d ) ) - d ); + rect.moveTo( static_cast( QRandomGenerator::global()->generate() % ( 2 * d ) ) - d, static_cast( QRandomGenerator::global()->generate() % ( 2 * d ) ) - d ); mMapCanvas->setSceneRect( rect ); QTransform matrix; - matrix.rotate( static_cast( QRandomGenerator::global()->generate() % ( 2 * r ) ) - r ); + matrix.rotate( static_cast( QRandomGenerator::global()->generate() % ( 2 * r ) ) - r ); mMapCanvas->setTransform( matrix ); } @@ -272,8 +271,7 @@ void QgsStatusBarCoordinatesWidget::contributors() const QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/contributors.json" ); const QFileInfo fileInfo = QFileInfo( fileName ); const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; - QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), - tr( "QGIS Contributors" ), QStringLiteral( "ogr" ), options ); + QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), tr( "QGIS Contributors" ), QStringLiteral( "ogr" ), options ); // Register this layer with the layers registry QgsProject::instance()->addMapLayer( layer ); layer->setAutoRefreshInterval( 500 ); @@ -290,8 +288,7 @@ void QgsStatusBarCoordinatesWidget::world() const QFileInfo fileInfo = QFileInfo( fileName ); QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; options.forceReadOnly = true; - QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), - tr( "World Map" ), QStringLiteral( "ogr" ), options ); + QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), tr( "World Map" ), QStringLiteral( "ogr" ), options ); // Register this layer with the layers registry QgsProject::instance()->addMapLayer( layer ); } @@ -305,8 +302,7 @@ void QgsStatusBarCoordinatesWidget::hackfests() const QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/qgis-hackfests.json" ); const QFileInfo fileInfo = QFileInfo( fileName ); const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; - QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), - tr( "QGIS Hackfests" ), QStringLiteral( "ogr" ), options ); + QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), tr( "QGIS Hackfests" ), QStringLiteral( "ogr" ), options ); // Register this layer with the layers registry QgsProject::instance()->addMapLayer( layer ); } @@ -320,13 +316,11 @@ void QgsStatusBarCoordinatesWidget::userGroups() const QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/world_map.gpkg|layername=countries" ); const QFileInfo fileInfo = QFileInfo( fileName ); const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; - QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), - tr( "User Groups" ), QStringLiteral( "ogr" ), options ); + QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(), tr( "User Groups" ), QStringLiteral( "ogr" ), options ); const QString fileNameData = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/user_groups_data.json" ); const QFileInfo fileInfoData = QFileInfo( fileNameData ); - QgsVectorLayer *layerData = new QgsVectorLayer( fileInfoData.absoluteFilePath(), - tr( "user_groups_data" ), QStringLiteral( "ogr" ), options ); + QgsVectorLayer *layerData = new QgsVectorLayer( fileInfoData.absoluteFilePath(), tr( "user_groups_data" ), QStringLiteral( "ogr" ), options ); // Register layers with the layers registry QgsProject::instance()->addMapLayers( QList() << layer << layerData ); @@ -338,7 +332,7 @@ void QgsStatusBarCoordinatesWidget::userGroups() joinInfo.setJoinFieldName( QStringLiteral( "country" ) ); joinInfo.setUsingMemoryCache( true ); joinInfo.setPrefix( QStringLiteral( "ug_" ) ); - joinInfo.setJoinFieldNamesSubset( nullptr ); // Use all join fields + joinInfo.setJoinFieldNamesSubset( nullptr ); // Use all join fields layer->addJoin( joinInfo ); // Load QML for polygon symbology and maptips @@ -391,8 +385,7 @@ void QgsStatusBarCoordinatesWidget::showExtent() } mLabel->setText( tr( "Extents" ) ); - mLineEdit->setText( QgsCoordinateUtils::formatExtentForProject( QgsProject::instance(), mMapCanvas->extent(), mMapCanvas->mapSettings().destinationCrs(), - mMousePrecisionDecimalPlaces ) ); + mLineEdit->setText( QgsCoordinateUtils::formatExtentForProject( QgsProject::instance(), mMapCanvas->extent(), mMapCanvas->mapSettings().destinationCrs(), mMousePrecisionDecimalPlaces ) ); ensureCoordinatesVisible(); } @@ -438,8 +431,7 @@ void QgsStatusBarCoordinatesWidget::updateCoordinateDisplay() if ( mLastCoordinate.isEmpty() ) mLineEdit->clear(); else - mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( QgsProject::instance(), mLastCoordinate, mMapCanvas->mapSettings().destinationCrs(), - static_cast< int >( mMousePrecisionDecimalPlaces ) ) ); + mLineEdit->setText( QgsCoordinateUtils::formatCoordinateForProject( QgsProject::instance(), mLastCoordinate, mMapCanvas->mapSettings().destinationCrs(), static_cast( mMousePrecisionDecimalPlaces ) ) ); ensureCoordinatesVisible(); } @@ -450,8 +442,8 @@ void QgsStatusBarCoordinatesWidget::coordinateDisplaySettingsChanged() const Qgis::CoordinateOrder projectOrder = QgsProject::instance()->displaySettings()->coordinateAxisOrder(); const Qgis::CoordinateOrder order = projectOrder == Qgis::CoordinateOrder::Default - ? QgsCoordinateReferenceSystemUtils::defaultCoordinateOrderForCrs( coordinateCrs ) - : projectOrder; + ? QgsCoordinateReferenceSystemUtils::defaultCoordinateOrderForCrs( coordinateCrs ) + : projectOrder; switch ( order ) { diff --git a/src/app/qgsstatusbarcoordinateswidget.h b/src/app/qgsstatusbarcoordinateswidget.h index 52f97be7947e..debae9cea5a1 100644 --- a/src/app/qgsstatusbarcoordinateswidget.h +++ b/src/app/qgsstatusbarcoordinateswidget.h @@ -90,7 +90,6 @@ class APP_EXPORT QgsStatusBarCoordinatesWidget : public QWidget bool mIsFirstSizeChange = true; QElapsedTimer mLastSizeChangeTimer; - }; #endif // QGSSTATUSBARCOORDINATESWIDGET_H diff --git a/src/app/qgsstatusbarmagnifierwidget.cpp b/src/app/qgsstatusbarmagnifierwidget.cpp index 3d158ae53104..a9dfd898c34f 100644 --- a/src/app/qgsstatusbarmagnifierwidget.cpp +++ b/src/app/qgsstatusbarmagnifierwidget.cpp @@ -55,7 +55,7 @@ QgsStatusBarMagnifierWidget::QgsStatusBarMagnifierWidget( QWidget *parent ) mSpinBox->setClearValueMode( QgsDoubleSpinBox::CustomValue ); mSpinBox->setClearValue( defaultFactor ); - connect( mSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsStatusBarMagnifierWidget::setMagnification ); + connect( mSpinBox, static_cast( &QgsDoubleSpinBox::valueChanged ), this, &QgsStatusBarMagnifierWidget::setMagnification ); mLockButton = new QToolButton(); mLockButton->setIcon( QIcon( QgsApplication::getThemeIcon( "/lockedGray.svg" ) ) ); diff --git a/src/app/qgsstatusbarmagnifierwidget.h b/src/app/qgsstatusbarmagnifierwidget.h index 4fa4cb84df48..7ca7929fdb34 100644 --- a/src/app/qgsstatusbarmagnifierwidget.h +++ b/src/app/qgsstatusbarmagnifierwidget.h @@ -35,7 +35,6 @@ class APP_EXPORT QgsStatusBarMagnifierWidget : public QWidget Q_OBJECT public: - /** * Constructor * \param parent is the parent widget diff --git a/src/app/qgsstatusbarscalewidget.cpp b/src/app/qgsstatusbarscalewidget.cpp index 591d585025fe..9e3f7e889692 100644 --- a/src/app/qgsstatusbarscalewidget.cpp +++ b/src/app/qgsstatusbarscalewidget.cpp @@ -96,7 +96,6 @@ void QgsStatusBarScaleWidget::updateScales() { if ( QgsProject::instance()->viewSettings()->useProjectScales() ) { - mScale->setPredefinedScales( QgsProject::instance()->viewSettings()->mapScales() ); } else diff --git a/src/app/qgssvgannotationdialog.cpp b/src/app/qgssvgannotationdialog.cpp index afad8c819ae4..ea7289a96a25 100644 --- a/src/app/qgssvgannotationdialog.cpp +++ b/src/app/qgssvgannotationdialog.cpp @@ -53,7 +53,7 @@ QgsSvgAnnotationDialog::QgsSvgAnnotationDialog( QgsMapCanvasAnnotationItem *item if ( mItem && mItem->annotation() ) { - QgsSvgAnnotation *annotation = static_cast< QgsSvgAnnotation * >( mItem->annotation() ); + QgsSvgAnnotation *annotation = static_cast( mItem->annotation() ); mFileLineEdit->setText( annotation->filePath() ); } @@ -99,12 +99,11 @@ void QgsSvgAnnotationDialog::applySettingsToItem() { if ( !mFileLineEdit->text().isEmpty() ) { - QgsSvgAnnotation *annotation = static_cast< QgsSvgAnnotation * >( mItem->annotation() ); + QgsSvgAnnotation *annotation = static_cast( mItem->annotation() ); annotation->setFilePath( mFileLineEdit->text() ); mItem->update(); } } - } void QgsSvgAnnotationDialog::deleteItem() diff --git a/src/app/qgssvgannotationdialog.h b/src/app/qgssvgannotationdialog.h index c390878c2f7f..bbd01ff59306 100644 --- a/src/app/qgssvgannotationdialog.h +++ b/src/app/qgssvgannotationdialog.h @@ -24,7 +24,7 @@ class QgsMapCanvasAnnotationItem; class QgsAnnotationWidget; -class APP_EXPORT QgsSvgAnnotationDialog: public QDialog, private Ui::QgsFormAnnotationDialogBase +class APP_EXPORT QgsSvgAnnotationDialog : public QDialog, private Ui::QgsFormAnnotationDialogBase { Q_OBJECT public: diff --git a/src/app/qgstemplateprojectsmodel.cpp b/src/app/qgstemplateprojectsmodel.cpp index 36ab53520f44..4e8f5ae48ad7 100644 --- a/src/app/qgstemplateprojectsmodel.cpp +++ b/src/app/qgstemplateprojectsmodel.cpp @@ -35,8 +35,7 @@ QgsTemplateProjectsModel::QgsTemplateProjectsModel( QObject *parent ) : QStandardItemModel( parent ) { const QStringList paths = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ); - const QString templateDirName = QgsSettings().value( QStringLiteral( "qgis/projectTemplateDir" ), - QString( QgsApplication::qgisSettingsDirPath() + QStringLiteral( "project_templates" ) ) ).toString(); + const QString templateDirName = QgsSettings().value( QStringLiteral( "qgis/projectTemplateDir" ), QString( QgsApplication::qgisSettingsDirPath() + QStringLiteral( "project_templates" ) ) ).toString(); for ( const QString &templatePath : paths ) { @@ -55,8 +54,8 @@ QgsTemplateProjectsModel::QgsTemplateProjectsModel( QObject *parent ) emptyProjectItem->setData( tr( "New Empty Project" ), QgsProjectListItemDelegate::TitleRole ); connect( QgsProject::instance(), &QgsProject::crsChanged, this, [emptyProjectItem]() { emptyProjectItem->setData( QgsProject::instance()->crs().userFriendlyIdentifier(), QgsProjectListItemDelegate::CrsRole ); } ); emptyProjectItem->setData( QgsProject::instance()->crs().userFriendlyIdentifier(), QgsProjectListItemDelegate::CrsRole ); - emptyProjectItem->setFlags( Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsEnabled ) ; - const double devicePixelRatio = qobject_cast< QGuiApplication * >( QCoreApplication::instance() )->devicePixelRatio(); + emptyProjectItem->setFlags( Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsEnabled ); + const double devicePixelRatio = qobject_cast( QCoreApplication::instance() )->devicePixelRatio(); QImage image( QSize( 250 * devicePixelRatio, 177 * devicePixelRatio ), QImage::Format_ARGB32 ); const QgsSettings settings; const int myRed = settings.value( QStringLiteral( "qgis/default_canvas_color_red" ), 255 ).toInt(); @@ -103,7 +102,7 @@ void QgsTemplateProjectsModel::scanDirectory( const QString &path ) // Refill with templates from this directory for ( const QFileInfo &file : files ) { - std::unique_ptr item = std::make_unique( file.fileName() ) ; + std::unique_ptr item = std::make_unique( file.fileName() ); const QString fileId = QCryptographicHash::hash( file.filePath().toUtf8(), QCryptographicHash::Sha224 ).toHex(); @@ -123,7 +122,7 @@ void QgsTemplateProjectsModel::scanDirectory( const QString &path ) item->setData( file.baseName(), QgsProjectListItemDelegate::TitleRole ); item->setData( file.filePath(), QgsProjectListItemDelegate::NativePathRole ); - item->setFlags( Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsEnabled ) ; + item->setFlags( Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsEnabled ); appendRow( item.release() ); } } diff --git a/src/app/qgstemporalcontrollerdockwidget.cpp b/src/app/qgstemporalcontrollerdockwidget.cpp index 3603ee6aa3ca..4126423800ad 100644 --- a/src/app/qgstemporalcontrollerdockwidget.cpp +++ b/src/app/qgstemporalcontrollerdockwidget.cpp @@ -59,7 +59,7 @@ bool QgsTemporalControllerDockWidget::eventFilter( QObject *object, QEvent *even { if ( event->type() == QEvent::Wheel ) { - QWheelEvent *wheelEvent = dynamic_cast< QWheelEvent * >( event ); + QWheelEvent *wheelEvent = dynamic_cast( event ); // handle horizontal wheel events by scrubbing timeline if ( wheelEvent->angleDelta().x() != 0 ) { @@ -74,8 +74,7 @@ bool QgsTemporalControllerDockWidget::eventFilter( QObject *object, QEvent *even void QgsTemporalControllerDockWidget::exportAnimation() { QgsAnimationExportDialog *dlg = new QgsAnimationExportDialog( this, QgisApp::instance()->mapCanvas(), QgisApp::instance()->activeDecorations() ); - connect( dlg, &QgsAnimationExportDialog::startExport, this, [ = ] - { + connect( dlg, &QgsAnimationExportDialog::startExport, this, [=] { QgsMapSettings s = QgisApp::instance()->mapCanvas()->mapSettings(); dlg->applyMapSettings( s ); @@ -94,9 +93,7 @@ void QgsTemporalControllerDockWidget::exportAnimation() progressDialog.setWindowModality( Qt::WindowModal ); QString error; - connect( &progressFeedback, &QgsFeedback::progressChanged, this, - [&progressDialog, &progressFeedback, &task] - { + connect( &progressFeedback, &QgsFeedback::progressChanged, this, [&progressDialog, &progressFeedback, &task] { progressDialog.setValue( static_cast( progressFeedback.progress() ) ); task.setProgress( progressFeedback.progress() ); QCoreApplication::processEvents(); @@ -126,9 +123,7 @@ void QgsTemporalControllerDockWidget::exportAnimation() } else { - QgisApp::instance()->messageBar()->pushMessage( tr( "Export Animation" ), - tr( "Successfully exported animation to %2" ).arg( QUrl::fromLocalFile( outputDir ).toString(), QDir::toNativeSeparators( outputDir ) ), - Qgis::MessageLevel::Success, 0 ); + QgisApp::instance()->messageBar()->pushMessage( tr( "Export Animation" ), tr( "Successfully exported animation to %2" ).arg( QUrl::fromLocalFile( outputDir ).toString(), QDir::toNativeSeparators( outputDir ) ), Qgis::MessageLevel::Success, 0 ); } } ); dlg->setAttribute( Qt::WA_DeleteOnClose ); diff --git a/src/app/qgstemporalcontrollerdockwidget.h b/src/app/qgstemporalcontrollerdockwidget.h index bc154bfb2db0..44f9bf7589fe 100644 --- a/src/app/qgstemporalcontrollerdockwidget.h +++ b/src/app/qgstemporalcontrollerdockwidget.h @@ -35,7 +35,6 @@ class APP_EXPORT QgsTemporalControllerDockWidget : public QgsDockWidget { Q_OBJECT public: - /** * Constructor for QgsTemporalControllerDockWidget, with the specified \a parent widget. */ @@ -51,7 +50,6 @@ class APP_EXPORT QgsTemporalControllerDockWidget : public QgsDockWidget void setMapCanvas( QgsMapCanvas *canvas ); protected: - bool eventFilter( QObject *object, QEvent *event ) override; private slots: @@ -59,10 +57,7 @@ class APP_EXPORT QgsTemporalControllerDockWidget : public QgsDockWidget void exportAnimation(); private: - QgsTemporalControllerWidget *mControllerWidget = nullptr; - - }; #endif // QGSTEMPORALCONTROLLERDOCKWIDGET_H diff --git a/src/app/qgstextannotationdialog.cpp b/src/app/qgstextannotationdialog.cpp index a00e630e0e79..072cc11487ad 100644 --- a/src/app/qgstextannotationdialog.cpp +++ b/src/app/qgstextannotationdialog.cpp @@ -46,7 +46,7 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem *it if ( mItem && mItem->annotation() ) { - QgsTextAnnotation *annotation = static_cast< QgsTextAnnotation * >( mItem->annotation() ); + QgsTextAnnotation *annotation = static_cast( mItem->annotation() ); mTextDocument.reset( annotation->document() ? annotation->document()->clone() : nullptr ); mTextEdit->setDocument( mTextDocument.get() ); } @@ -63,7 +63,7 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem *it QObject::connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsTextAnnotationDialog::applyTextToItem ); QObject::connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsTextAnnotationDialog::showHelp ); QObject::connect( mFontComboBox, &QFontComboBox::currentFontChanged, this, &QgsTextAnnotationDialog::changeCurrentFormat ); - QObject::connect( mFontSizeSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsTextAnnotationDialog::changeCurrentFormat ); + QObject::connect( mFontSizeSpinBox, static_cast( &QSpinBox::valueChanged ), this, &QgsTextAnnotationDialog::changeCurrentFormat ); QObject::connect( mBoldPushButton, &QPushButton::toggled, this, &QgsTextAnnotationDialog::changeCurrentFormat ); QObject::connect( mItalicsPushButton, &QPushButton::toggled, this, &QgsTextAnnotationDialog::changeCurrentFormat ); QObject::connect( mTextEdit, &QTextEdit::cursorPositionChanged, this, &QgsTextAnnotationDialog::setCurrentFontPropertiesToGui ); @@ -78,7 +78,6 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem *it connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsTextAnnotationDialog::onSettingsChanged ); connect( mEmbeddedWidget, &QgsAnnotationWidget::changed, this, &QgsTextAnnotationDialog::onSettingsChanged ); connect( mTextEdit, &QTextEdit::textChanged, this, &QgsTextAnnotationDialog::onSettingsChanged ); - } void QgsTextAnnotationDialog::showEvent( QShowEvent * ) @@ -107,7 +106,7 @@ void QgsTextAnnotationDialog::applyTextToItem() { if ( mItem && mTextDocument && mItem->annotation() ) { - QgsTextAnnotation *annotation = static_cast< QgsTextAnnotation * >( mItem->annotation() ); + QgsTextAnnotation *annotation = static_cast( mItem->annotation() ); //apply settings from embedded item widget if ( mEmbeddedWidget ) { diff --git a/src/app/qgstextannotationdialog.h b/src/app/qgstextannotationdialog.h index de7c33b54ff0..b7c0be2edfff 100644 --- a/src/app/qgstextannotationdialog.h +++ b/src/app/qgstextannotationdialog.h @@ -25,20 +25,19 @@ class QgsAnnotationWidget; class QgsMapCanvasAnnotationItem; -class APP_EXPORT QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnnotationDialogBase +class APP_EXPORT QgsTextAnnotationDialog : public QDialog, private Ui::QgsTextAnnotationDialogBase { Q_OBJECT public: QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem *item, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); protected: - void showEvent( QShowEvent *event ) override; private: QgsMapCanvasAnnotationItem *mItem = nullptr; //! Text document (a clone of the annotation items document) - std::unique_ptr< QTextDocument > mTextDocument; + std::unique_ptr mTextDocument; QgsAnnotationWidget *mEmbeddedWidget = nullptr; void blockAllSignals( bool block ); diff --git a/src/app/qgsundowidget.cpp b/src/app/qgsundowidget.cpp index be69cbfbb7d1..63d7c964791f 100644 --- a/src/app/qgsundowidget.cpp +++ b/src/app/qgsundowidget.cpp @@ -170,7 +170,7 @@ void QgsUndoWidget::setUndoStack( QUndoStack *undoStack ) mUndoView->setStack( undoStack ); mUndoView->setObjectName( QStringLiteral( "undoView" ) ); mGridLayout->addWidget( mUndoView, 0, 0, 1, 2 ); -// setWidget( dockWidgetContents ); + // setWidget( dockWidgetContents ); connect( mUndoStack, &QUndoStack::canUndoChanged, this, &QgsUndoWidget::undoChanged ); connect( mUndoStack, &QUndoStack::canRedoChanged, this, &QgsUndoWidget::redoChanged ); @@ -180,4 +180,3 @@ void QgsUndoWidget::setUndoStack( QUndoStack *undoStack ) mUndoButton->setDisabled( !mUndoStack->canUndo() ); mRedoButton->setDisabled( !mUndoStack->canRedo() ); } - diff --git a/src/app/qgsundowidget.h b/src/app/qgsundowidget.h index ae983f1dea62..371c325bb896 100644 --- a/src/app/qgsundowidget.h +++ b/src/app/qgsundowidget.h @@ -40,7 +40,6 @@ class APP_EXPORT QgsUndoWidget : public QgsPanelWidget { Q_OBJECT public: - QgsUndoWidget( QWidget *parent, QgsMapCanvas *mapCanvas ); /** @@ -94,7 +93,7 @@ class APP_EXPORT QgsUndoWidget : public QgsPanelWidget private: QUndoView *mUndoView = nullptr; - QPointer< QUndoStack > mUndoStack; + QPointer mUndoStack; QgsMapCanvas *mMapCanvas = nullptr; int mPreviousIndex = 0; @@ -108,4 +107,3 @@ class APP_EXPORT QgsUndoWidget : public QgsPanelWidget #endif // QGSUNDOWIDGET_H - diff --git a/src/app/qgsvariantdelegate.cpp b/src/app/qgsvariantdelegate.cpp index 5c9ab93b008c..8fc770d38052 100644 --- a/src/app/qgsvariantdelegate.cpp +++ b/src/app/qgsvariantdelegate.cpp @@ -68,9 +68,7 @@ QgsVariantDelegate::QgsVariantDelegate( QObject *parent ) mDateTimeExp.setPattern( mDateExp.pattern() + 'T' + mTimeExp.pattern() ); } -void QgsVariantDelegate::paint( QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const +void QgsVariantDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if ( index.column() == 2 ) { @@ -87,9 +85,7 @@ void QgsVariantDelegate::paint( QPainter *painter, QItemDelegate::paint( painter, option, index ); } -QWidget *QgsVariantDelegate::createEditor( QWidget *parent, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const +QWidget *QgsVariantDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { Q_UNUSED( option ) if ( index.column() != 2 ) @@ -140,8 +136,7 @@ QWidget *QgsVariantDelegate::createEditor( QWidget *parent, case QMetaType::Type::ULongLong: regExp = mUnsignedIntegerExp; break; - default: - ; + default:; } if ( QgsVariantDelegate::type( originalValue ) == QMetaType::Type::Bool ) @@ -164,32 +159,30 @@ QWidget *QgsVariantDelegate::createEditor( QWidget *parent, } } -void QgsVariantDelegate::setEditorData( QWidget *editor, - const QModelIndex &index ) const +void QgsVariantDelegate::setEditorData( QWidget *editor, const QModelIndex &index ) const { const QVariant value = index.model()->data( index, Qt::UserRole ); - if ( QComboBox *comboBox = qobject_cast( editor ) ) + if ( QComboBox *comboBox = qobject_cast( editor ) ) { comboBox->setCurrentIndex( value.toBool() ? 1 : 0 ); } - else if ( QLineEdit *lineEdit = qobject_cast( editor ) ) + else if ( QLineEdit *lineEdit = qobject_cast( editor ) ) { lineEdit->setText( displayText( value ) ); } } -void QgsVariantDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const +void QgsVariantDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const { const QVariant originalValue = index.model()->data( index, Qt::UserRole ); QVariant value; - if ( QComboBox *comboBox = qobject_cast( editor ) ) + if ( QComboBox *comboBox = qobject_cast( editor ) ) { value = comboBox->currentIndex() == 1; } - else if ( QLineEdit *lineEdit = qobject_cast( editor ) ) + else if ( QLineEdit *lineEdit = qobject_cast( editor ) ) { if ( !lineEdit->isModified() ) return; @@ -211,10 +204,7 @@ void QgsVariantDelegate::setModelData( QWidget *editor, QAbstractItemModel *mode case QMetaType::Type::QColor: { const QRegularExpressionMatch match = mColorExp.match( text ); - value = QColor( std::min( match.captured( 1 ).toInt(), 255 ), - std::min( match.captured( 2 ).toInt(), 255 ), - std::min( match.captured( 3 ).toInt(), 255 ), - std::min( match.captured( 4 ).toInt(), 255 ) ); + value = QColor( std::min( match.captured( 1 ).toInt(), 255 ), std::min( match.captured( 2 ).toInt(), 255 ), std::min( match.captured( 3 ).toInt(), 255 ), std::min( match.captured( 4 ).toInt(), 255 ) ); break; } case QMetaType::Type::QDate: @@ -242,8 +232,7 @@ void QgsVariantDelegate::setModelData( QWidget *editor, QAbstractItemModel *mode case QMetaType::Type::QRect: { const QRegularExpressionMatch match = mRectExp.match( text ); - value = QRect( match.captured( 1 ).toInt(), match.captured( 2 ).toInt(), - match.captured( 3 ).toInt(), match.captured( 4 ).toInt() ); + value = QRect( match.captured( 1 ).toInt(), match.captured( 2 ).toInt(), match.captured( 3 ).toInt(), match.captured( 4 ).toInt() ); break; } case QMetaType::Type::QSize: @@ -318,8 +307,10 @@ QString QgsVariantDelegate::displayText( const QVariant &value ) { const QColor color = qvariant_cast( value ); return QStringLiteral( "(%1,%2,%3,%4)" ) - .arg( color.red() ).arg( color.green() ) - .arg( color.blue() ).arg( color.alpha() ); + .arg( color.red() ) + .arg( color.green() ) + .arg( color.blue() ) + .arg( color.alpha() ); } case QMetaType::Type::QDate: return value.toDate().toString( Qt::ISODate ); @@ -336,8 +327,10 @@ QString QgsVariantDelegate::displayText( const QVariant &value ) { const QRect rect = value.toRect(); return QStringLiteral( "(%1,%2,%3,%4)" ) - .arg( rect.x() ).arg( rect.y() ) - .arg( rect.width() ).arg( rect.height() ); + .arg( rect.x() ) + .arg( rect.y() ) + .arg( rect.width() ) + .arg( rect.height() ); } case QMetaType::Type::QSize: { @@ -352,7 +345,6 @@ QString QgsVariantDelegate::displayText( const QVariant &value ) break; } return QStringLiteral( "<%1>" ).arg( value.toString() ); - } /* hack to get "real" type of a variant, because QVariant::type() almost always returns QString */ @@ -378,7 +370,6 @@ QMetaType::Type QgsVariantDelegate::type( const QVariant &value ) ( void ) str.toDouble( &ok ); if ( ok ) return QMetaType::Type::Double; - } // fallback to QVariant::type() diff --git a/src/app/qgsvariantdelegate.h b/src/app/qgsvariantdelegate.h index 47d772c3077e..42b1e8f81e88 100644 --- a/src/app/qgsvariantdelegate.h +++ b/src/app/qgsvariantdelegate.h @@ -51,13 +51,10 @@ class QgsVariantDelegate : public QItemDelegate public: explicit QgsVariantDelegate( QObject *parent = nullptr ); - void paint( QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; - QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; + void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; + QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; void setEditorData( QWidget *editor, const QModelIndex &index ) const override; - void setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const override; + void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override; static bool isSupportedType( QMetaType::Type type ); static QString displayText( const QVariant &value ); diff --git a/src/app/qgsvectorlayerdigitizingproperties.cpp b/src/app/qgsvectorlayerdigitizingproperties.cpp index c901a1eb4070..42ee25e9dda9 100644 --- a/src/app/qgsvectorlayerdigitizingproperties.cpp +++ b/src/app/qgsvectorlayerdigitizingproperties.cpp @@ -53,12 +53,11 @@ QgsVectorLayerDigitizingPropertiesPage::QgsVectorLayerDigitizingPropertiesPage( mRemoveDuplicateNodesCheckbox->setChecked( mRemoveDuplicateNodesManuallyActivated ); if ( !precisionStr.isNull() ) mRemoveDuplicateNodesCheckbox->setEnabled( false ); - connect( mGeometryPrecisionLineEdit, &QLineEdit::textChanged, this, [this] - { + connect( mGeometryPrecisionLineEdit, &QLineEdit::textChanged, this, [this] { if ( !mGeometryPrecisionLineEdit->text().isEmpty() ) { if ( mRemoveDuplicateNodesCheckbox->isEnabled() ) - mRemoveDuplicateNodesManuallyActivated = mRemoveDuplicateNodesCheckbox->isChecked(); + mRemoveDuplicateNodesManuallyActivated = mRemoveDuplicateNodesCheckbox->isChecked(); mRemoveDuplicateNodesCheckbox->setEnabled( false ); mRemoveDuplicateNodesCheckbox->setChecked( true ); } @@ -141,7 +140,7 @@ void QgsVectorLayerDigitizingPropertiesPage::apply() vlayer->geometryOptions()->setRemoveDuplicateNodes( mRemoveDuplicateNodesCheckbox->isChecked() ); bool ok = true; double precision( QLocale().toDouble( mGeometryPrecisionLineEdit->text(), &ok ) ); - if ( ! ok ) + if ( !ok ) precision = 0.0; vlayer->geometryOptions()->setGeometryPrecision( precision ); diff --git a/src/app/qgsversioninfo.cpp b/src/app/qgsversioninfo.cpp index 9ce63de9171e..113a365d6750 100644 --- a/src/app/qgsversioninfo.cpp +++ b/src/app/qgsversioninfo.cpp @@ -23,7 +23,6 @@ QgsVersionInfo::QgsVersionInfo( QObject *parent ) : QObject( parent ) { - } void QgsVersionInfo::checkVersion() diff --git a/src/app/qgsversionmigration.cpp b/src/app/qgsversionmigration.cpp index 2d954ebff06d..56ae5b885687 100644 --- a/src/app/qgsversionmigration.cpp +++ b/src/app/qgsversionmigration.cpp @@ -37,7 +37,7 @@ std::unique_ptr QgsVersionMigration::canMigrate( int fromVe { if ( fromVersion == 20000 && toVersion >= 29900 ) { - return std::make_unique< Qgs2To3Migration >(); + return std::make_unique(); } return nullptr; } @@ -48,7 +48,7 @@ QgsError Qgs2To3Migration::runMigration() const QgsError settingsErrors = migrateSettings(); if ( !settingsErrors.isEmpty() ) { - const QList errorList( settingsErrors.messageList( ) ); + const QList errorList( settingsErrors.messageList() ); for ( const auto &err : errorList ) { errors.append( err ); @@ -57,7 +57,7 @@ QgsError Qgs2To3Migration::runMigration() const QgsError stylesErrors = migrateStyles(); if ( !stylesErrors.isEmpty() ) { - const QList errorList( stylesErrors.messageList( ) ); + const QList errorList( stylesErrors.messageList() ); for ( const auto &err : errorList ) { errors.append( err ); @@ -66,7 +66,7 @@ QgsError Qgs2To3Migration::runMigration() const QgsError authDbErrors = migrateAuthDb(); if ( !authDbErrors.isEmpty() ) { - const QList errorList( authDbErrors.messageList( ) ); + const QList errorList( authDbErrors.messageList() ); for ( const auto &err : errorList ) { errors.append( err ); @@ -79,7 +79,7 @@ bool Qgs2To3Migration::requiresMigration() { const QgsSettings settings; const bool alreadyMigrated = settings.value( QStringLiteral( "migration/settings" ), false ).toBool(); - const int settingsMigrationVersion = settings.value( QStringLiteral( "migration/fileVersion" ), 0 ).toInt(); + const int settingsMigrationVersion = settings.value( QStringLiteral( "migration/fileVersion" ), 0 ).toInt(); QFile migrationFile( migrationFilePath() ); if ( migrationFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { @@ -120,7 +120,8 @@ QgsError Qgs2To3Migration::migrateStyles() QSqlQuery query( db ); QSqlQuery tagQuery( "SELECT name FROM tag" "JOIN tagmap ON tagmap.tag_id = tag.id" - "WHERE tagmap.symbol_id = :symbol_id", db ); + "WHERE tagmap.symbol_id = :symbol_id", + db ); QgsStyle *style = QgsStyle::defaultStyle(); if ( query.exec( "SELECT id, name, xml FROM symbol" ) ) @@ -218,7 +219,6 @@ QgsError Qgs2To3Migration::migrateSettings() const QPair key = transformKey( oldKey, newKey ); keys.append( key ); } - } inputFile.close(); newSettings.setValue( QStringLiteral( "migration/settings" ), true ); @@ -263,7 +263,7 @@ QgsError Qgs2To3Migration::migrateAuthDb() settingsDir.cdUp(); const QString newAuthDbFilePath = QStringLiteral( "%1/qgis-auth.db" ).arg( settingsDir.absolutePath() ); // Do not overwrite! - if ( QFile( newAuthDbFilePath ).exists( ) ) + if ( QFile( newAuthDbFilePath ).exists() ) { const QString msg = QStringLiteral( "Could not copy old auth DB to %1: file already exists!" ).arg( newAuthDbFilePath ); QgsDebugError( msg ); @@ -272,7 +272,7 @@ QgsError Qgs2To3Migration::migrateAuthDb() else { QFile oldDbFile( oldAuthDbFilePath ); - if ( oldDbFile.exists( ) ) + if ( oldDbFile.exists() ) { if ( oldDbFile.copy( newAuthDbFilePath ) ) { @@ -295,14 +295,14 @@ QgsError Qgs2To3Migration::migrateAuthDb() return error; } -QList > Qgs2To3Migration::walk( QString group, QString newkey ) +QList> Qgs2To3Migration::walk( QString group, QString newkey ) { mOldSettings->beginGroup( group ); - QList > foundKeys; + QList> foundKeys; const auto constChildGroups = mOldSettings->childGroups(); for ( const QString &group : constChildGroups ) { - const QList > data = walk( group, newkey ); + const QList> data = walk( group, newkey ); foundKeys.append( data ); } @@ -344,5 +344,5 @@ QPair Qgs2To3Migration::transformKey( QString fullOldKey, QStr QString Qgs2To3Migration::migrationFilePath() { - return QgsApplication::resolvePkgPath() + "/resources/2to3migration.txt"; + return QgsApplication::resolvePkgPath() + "/resources/2to3migration.txt"; } diff --git a/src/app/qgsversionmigration.h b/src/app/qgsversionmigration.h index 83a8bb9926a1..f3e8cd5cafe6 100644 --- a/src/app/qgsversionmigration.h +++ b/src/app/qgsversionmigration.h @@ -42,7 +42,7 @@ class APP_EXPORT QgsVersionMigration * \param toVersion The version migrating to. * \returns new migration object */ - static std::unique_ptr< QgsVersionMigration > canMigrate( int fromVersion, int toVersion ); + static std::unique_ptr canMigrate( int fromVersion, int toVersion ); /** * Run the version migration to convert between versions. @@ -58,6 +58,7 @@ class Qgs2To3Migration : public QgsVersionMigration public: QgsError runMigration() override; bool requiresMigration() override; + private: QgsError migrateStyles(); QgsError migrateSettings(); @@ -71,7 +72,6 @@ class Qgs2To3Migration : public QgsVersionMigration int mMigrationFileVersion = 0; QSettings *mOldSettings = nullptr; - }; #endif // QGSVERSIONMIGRATION_H diff --git a/src/app/qgswelcomepage.cpp b/src/app/qgswelcomepage.cpp index 69c2f59e9585..6275e075f9f3 100644 --- a/src/app/qgswelcomepage.cpp +++ b/src/app/qgswelcomepage.cpp @@ -156,9 +156,9 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent ) mVersionInformation->setReadOnly( true ); mVersionInformation->setOpenExternalLinks( true ); mVersionInformation->setStyleSheet( QStringLiteral( "QTextEdit { background-color: #dff0d8; color:#000000; border: 1px solid #8e998a; padding-top: 0.25em; max-height: 1.75em; min-height: 1.75em; } " - "QScrollBar { background-color: rgba(0,0,0,0); } " - "QScrollBar::add-page,QScrollBar::sub-page,QScrollBar::handle { background-color: rgba(0,0,0,0); color: rgba(0,0,0,0); } " - "QScrollBar::up-arrow,QScrollBar::down-arrow { color: rgb(0,0,0); } " ) ); + "QScrollBar { background-color: rgba(0,0,0,0); } " + "QScrollBar::add-page,QScrollBar::sub-page,QScrollBar::handle { background-color: rgba(0,0,0,0); color: rgba(0,0,0,0); } " + "QScrollBar::up-arrow,QScrollBar::down-arrow { color: rgb(0,0,0); } " ) ); mainLayout->addWidget( mVersionInformation ); mVersionInformation->setVisible( false ); @@ -224,7 +224,7 @@ void QgsWelcomePage::newsItemActivated( const QModelIndex &index ) if ( !index.isValid() ) return; - const QUrl link = index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Link ) ).toUrl(); + const QUrl link = index.data( static_cast( QgsNewsFeedModel::CustomRole::Link ) ).toUrl(); QDesktopServices::openUrl( link ); } @@ -237,8 +237,7 @@ void QgsWelcomePage::versionInfoReceived() { mVersionInformation->setVisible( true ); mVersionInformation->setText( QStringLiteral( "%1: %2" ) - .arg( tr( "New QGIS version available" ), - QgsStringUtils::insertLinks( versionInfo->downloadInfo() ) ) ); + .arg( tr( "New QGIS version available" ), QgsStringUtils::insertLinks( versionInfo->downloadInfo() ) ) ); } } @@ -269,8 +268,7 @@ void QgsWelcomePage::showContextMenuForProjects( QPoint point ) if ( !pin ) { QAction *pinAction = new QAction( tr( "Pin to List" ), menu ); - connect( pinAction, &QAction::triggered, this, [this, index] - { + connect( pinAction, &QAction::triggered, this, [this, index] { pinProject( index.row() ); } ); menu->addAction( pinAction ); @@ -278,8 +276,7 @@ void QgsWelcomePage::showContextMenuForProjects( QPoint point ) else { QAction *pinAction = new QAction( tr( "Unpin from List" ), menu ); - connect( pinAction, &QAction::triggered, this, [this, index] - { + connect( pinAction, &QAction::triggered, this, [this, index] { unpinProject( index.row() ); } ); menu->addAction( pinAction ); @@ -293,8 +290,7 @@ void QgsWelcomePage::showContextMenuForProjects( QPoint point ) if ( !path.isEmpty() ) { QAction *openFolderAction = new QAction( tr( "Open Directory…" ), menu ); - connect( openFolderAction, &QAction::triggered, this, [path] - { + connect( openFolderAction, &QAction::triggered, this, [path] { const QgsFocusKeeper focusKeeper; QgsGui::nativePlatformInterface()->openFileExplorerAndSelectFile( path ); } ); @@ -304,8 +300,7 @@ void QgsWelcomePage::showContextMenuForProjects( QPoint point ) else { QAction *rescanAction = new QAction( tr( "Refresh" ), menu ); - connect( rescanAction, &QAction::triggered, this, [this, index] - { + connect( rescanAction, &QAction::triggered, this, [this, index] { mRecentProjectsModel->recheckProject( index ); } ); menu->addAction( rescanAction ); @@ -328,16 +323,14 @@ void QgsWelcomePage::showContextMenuForProjects( QPoint point ) // to help users re-find moved/renamed projects! const QString closestPath = QgsFileUtils::findClosestExistingPath( path ); QAction *openFolderAction = new QAction( tr( "Open “%1”…" ).arg( QDir::toNativeSeparators( closestPath ) ), menu ); - connect( openFolderAction, &QAction::triggered, this, [closestPath] - { + connect( openFolderAction, &QAction::triggered, this, [closestPath] { QDesktopServices::openUrl( QUrl::fromLocalFile( closestPath ) ); } ); menu->addAction( openFolderAction ); } } QAction *removeProjectAction = new QAction( tr( "Remove from List" ), menu ); - connect( removeProjectAction, &QAction::triggered, this, [this, index] - { + connect( removeProjectAction, &QAction::triggered, this, [this, index] { removeProject( index.row() ); } ); menu->addAction( removeProjectAction ); @@ -365,8 +358,7 @@ void QgsWelcomePage::showContextMenuForTemplates( QPoint point ) if ( fileInfo.isWritable() ) { QAction *deleteFileAction = new QAction( tr( "Delete Template…" ), menu ); - connect( deleteFileAction, &QAction::triggered, this, [this, fileInfo, index] - { + connect( deleteFileAction, &QAction::triggered, this, [this, fileInfo, index] { QMessageBox msgBox( this ); msgBox.setWindowTitle( tr( "Delete Template" ) ); msgBox.setText( tr( "Do you want to delete the template %1? This action can not be undone." ).arg( index.data( QgsProjectListItemDelegate::TitleRole ).toString() ) ); @@ -392,27 +384,24 @@ void QgsWelcomePage::showContextMenuForNews( QPoint point ) if ( !index.isValid() ) return; - const int key = index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(); + const int key = index.data( static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(); QMenu *menu = new QMenu(); QAction *dismissAction = new QAction( tr( "Dismiss" ), menu ); - connect( dismissAction, &QAction::triggered, this, [this, key] - { + connect( dismissAction, &QAction::triggered, this, [this, key] { mNewsFeedParser->dismissEntry( key ); } ); menu->addAction( dismissAction ); QAction *dismissAllAction = new QAction( tr( "Dismiss All" ), menu ); - connect( dismissAllAction, &QAction::triggered, this, [this] - { + connect( dismissAllAction, &QAction::triggered, this, [this] { mNewsFeedParser->dismissAll(); } ); menu->addAction( dismissAllAction ); menu->addSeparator(); QAction *hideAction = new QAction( tr( "Hide QGIS News…" ), menu ); - connect( hideAction, &QAction::triggered, this, [this] - { - if ( QMessageBox::question( this, tr( "QGIS News" ), tr( "Are you sure you want to hide QGIS news? (The news feed can be re-enabled from the QGIS settings dialog.)" ) ) == QMessageBox::Yes ) + connect( hideAction, &QAction::triggered, this, [this] { + if ( QMessageBox::question( this, tr( "QGIS News" ), tr( "Are you sure you want to hide QGIS news? (The news feed can be re-enabled from the QGIS settings dialog.)" ) ) == QMessageBox::Yes ) { //...sad trombone... mNewsFeedParser->dismissAll(); @@ -442,7 +431,7 @@ void QgsWelcomePage::updateNewsFeedVisibility() if ( mSplitter2->sizes().first() == 0 ) { const int splitSize = mSplitter2->height() / 2; - mSplitter2->setSizes( QList< int > { splitSize, splitSize} ); + mSplitter2->setSizes( QList { splitSize, splitSize } ); } } } @@ -451,7 +440,7 @@ bool QgsWelcomePage::eventFilter( QObject *obj, QEvent *event ) { if ( obj == mNewsFeedListView->viewport() && event->type() == QEvent::MouseButtonRelease ) { - QMouseEvent *mouseEvent = dynamic_cast< QMouseEvent *>( event ); + QMouseEvent *mouseEvent = dynamic_cast( event ); if ( mouseEvent->button() == Qt::LeftButton ) { const QModelIndex index = mNewsFeedListView->indexAt( mouseEvent->pos() ); @@ -460,7 +449,7 @@ bool QgsWelcomePage::eventFilter( QObject *obj, QEvent *event ) const QPoint itemClickPoint = mouseEvent->pos() - mNewsFeedListView->visualRect( index ).topLeft(); if ( QRect( mNewsDelegate->dismissRect().left(), mNewsDelegate->dismissRect().top(), mNewsDelegate->dismissRectSize().width(), mNewsDelegate->dismissRectSize().height() ).contains( itemClickPoint ) ) { - mNewsFeedParser->dismissEntry( index.data( static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt() ); + mNewsFeedParser->dismissEntry( index.data( static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt() ); } return true; } @@ -490,11 +479,7 @@ void QgsWelcomePage::unpinProject( int row ) void QgsWelcomePage::clearRecentProjects() { - QMessageBox messageBox( QMessageBox::Question, - tr( "Recent Projects" ), - tr( "Are you sure you want to clear the list of recent projects?" ), - QMessageBox::No | QMessageBox::Yes | QMessageBox::YesToAll, - this ); + QMessageBox messageBox( QMessageBox::Question, tr( "Recent Projects" ), tr( "Are you sure you want to clear the list of recent projects?" ), QMessageBox::No | QMessageBox::Yes | QMessageBox::YesToAll, this ); messageBox.button( QMessageBox::YesToAll )->setText( tr( "Yes, including pinned projects" ) ); int answer = messageBox.exec(); if ( answer != QMessageBox::No ) @@ -504,4 +489,3 @@ void QgsWelcomePage::clearRecentProjects() emit projectsCleared( clearPinned ); } } - diff --git a/src/app/raster/qgsrasterelevationpropertieswidget.cpp b/src/app/raster/qgsrasterelevationpropertieswidget.cpp index c951b19cc862..1a58c0ddddd1 100644 --- a/src/app/raster/qgsrasterelevationpropertieswidget.cpp +++ b/src/app/raster/qgsrasterelevationpropertieswidget.cpp @@ -60,9 +60,9 @@ QgsRasterElevationPropertiesWidget::QgsRasterElevationPropertiesWidget( QgsRaste mLineStyleButton->setSymbolType( Qgis::SymbolType::Line ); mFillStyleButton->setSymbolType( Qgis::SymbolType::Fill ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationLine.svg" ) ), tr( "Line" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::Line ) ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillBelow.svg" ) ), tr( "Fill Below" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::FillBelow ) ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillAbove.svg" ) ), tr( "Fill Above" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::FillAbove ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationLine.svg" ) ), tr( "Line" ), static_cast( Qgis::ProfileSurfaceSymbology::Line ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillBelow.svg" ) ), tr( "Fill Below" ), static_cast( Qgis::ProfileSurfaceSymbology::FillBelow ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillAbove.svg" ) ), tr( "Fill Above" ), static_cast( Qgis::ProfileSurfaceSymbology::FillAbove ) ); mElevationLimitSpinBox->setClearValue( mElevationLimitSpinBox->minimum(), tr( "Not set" ) ); // NOTE -- this doesn't work, there's something broken in QgsStackedWidget which breaks the height calculations @@ -84,30 +84,27 @@ QgsRasterElevationPropertiesWidget::QgsRasterElevationPropertiesWidget( QgsRaste mCalculateFixedRangePerBandButton->setPopupMode( QToolButton::InstantPopup ); QAction *calculateLowerAction = new QAction( "Calculate Lower by Expression…", calculateFixedRangePerBandMenu ); calculateFixedRangePerBandMenu->addAction( calculateLowerAction ); - connect( calculateLowerAction, &QAction::triggered, this, [this] - { + connect( calculateLowerAction, &QAction::triggered, this, [this] { calculateRangeByExpression( false ); } ); QAction *calculateUpperAction = new QAction( "Calculate Upper by Expression…", calculateFixedRangePerBandMenu ); calculateFixedRangePerBandMenu->addAction( calculateUpperAction ); - connect( calculateUpperAction, &QAction::triggered, this, [this] - { + connect( calculateUpperAction, &QAction::triggered, this, [this] { calculateRangeByExpression( true ); } ); syncToLayer( layer ); - connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged ); - connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged ); - connect( mElevationLimitSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged ); + connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged ); + connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged ); + connect( mElevationLimitSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged ); connect( mModeComboBox, qOverload( &QComboBox::currentIndexChanged ), this, &QgsRasterElevationPropertiesWidget::modeChanged ); connect( mLimitsComboBox, qOverload( &QComboBox::currentIndexChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged ); connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsRasterElevationPropertiesWidget::onChanged ); connect( mFillStyleButton, &QgsSymbolButton::changed, this, &QgsRasterElevationPropertiesWidget::onChanged ); connect( mBandComboBox, &QgsRasterBandComboBox::bandChanged, this, &QgsRasterElevationPropertiesWidget::onChanged ); - connect( mStyleComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ] - { - switch ( static_cast< Qgis::ProfileSurfaceSymbology >( mStyleComboBox->currentData().toInt() ) ) + connect( mStyleComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=] { + switch ( static_cast( mStyleComboBox->currentData().toInt() ) ) { case Qgis::ProfileSurfaceSymbology::Line: mSymbologyStackedWidget->setCurrentWidget( mPageLine ); @@ -120,13 +117,11 @@ QgsRasterElevationPropertiesWidget::QgsRasterElevationPropertiesWidget( QgsRaste onChanged(); } ); - connect( mLowerExpressionWidget, qOverload< const QString &, bool >( &QgsFieldExpressionWidget::fieldChanged ), this, [this]( const QString & expression, bool isValid ) - { + connect( mLowerExpressionWidget, qOverload( &QgsFieldExpressionWidget::fieldChanged ), this, [this]( const QString &expression, bool isValid ) { if ( isValid ) mDynamicRangePerBandModel->setLowerExpression( expression ); } ); - connect( mUpperExpressionWidget, qOverload< const QString &, bool >( &QgsFieldExpressionWidget::fieldChanged ), this, [this]( const QString & expression, bool isValid ) - { + connect( mUpperExpressionWidget, qOverload( &QgsFieldExpressionWidget::fieldChanged ), this, [this]( const QString &expression, bool isValid ) { if ( isValid ) mDynamicRangePerBandModel->setUpperExpression( expression ); } ); @@ -136,13 +131,13 @@ QgsRasterElevationPropertiesWidget::QgsRasterElevationPropertiesWidget( QgsRaste void QgsRasterElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) { - mLayer = qobject_cast< QgsRasterLayer * >( layer ); + mLayer = qobject_cast( layer ); if ( !mLayer ) return; mBlockUpdates = true; - const QgsRasterLayerElevationProperties *props = qgis::down_cast< const QgsRasterLayerElevationProperties * >( mLayer->elevationProperties() ); + const QgsRasterLayerElevationProperties *props = qgis::down_cast( mLayer->elevationProperties() ); if ( !props->isEnabled() ) { mModeComboBox->setCurrentIndex( 0 ); @@ -181,11 +176,11 @@ void QgsRasterElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) mBandComboBox->setLayer( mLayer ); mBandComboBox->setBand( props->bandNumber() ); - if ( props->fixedRange().lower() != std::numeric_limits< double >::lowest() ) + if ( props->fixedRange().lower() != std::numeric_limits::lowest() ) mFixedLowerSpinBox->setValue( props->fixedRange().lower() ); else mFixedLowerSpinBox->clear(); - if ( props->fixedRange().upper() != std::numeric_limits< double >::max() ) + if ( props->fixedRange().upper() != std::numeric_limits::max() ) mFixedUpperSpinBox->setValue( props->fixedRange().upper() ); else mFixedUpperSpinBox->clear(); @@ -207,7 +202,7 @@ void QgsRasterElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) mFixedRangePerBandLabel->setText( tr( "This mode cannot be used with a multi-band renderer." ) ); } - mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( static_cast ( props->profileSymbology() ) ) ); + mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( static_cast( props->profileSymbology() ) ) ); switch ( props->profileSymbology() ) { case Qgis::ProfileSurfaceSymbology::Line: @@ -220,24 +215,24 @@ void QgsRasterElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) } mLowerExpressionWidget->setExpression( - props->dataDefinedProperties().property( QgsMapLayerElevationProperties::Property::RasterPerBandLowerElevation ).asExpression() ); + props->dataDefinedProperties().property( QgsMapLayerElevationProperties::Property::RasterPerBandLowerElevation ).asExpression() + ); mUpperExpressionWidget->setExpression( - props->dataDefinedProperties().property( QgsMapLayerElevationProperties::Property::RasterPerBandUpperElevation ).asExpression() ); + props->dataDefinedProperties().property( QgsMapLayerElevationProperties::Property::RasterPerBandUpperElevation ).asExpression() + ); mDynamicRangePerBandModel->setLowerExpression( mLowerExpressionWidget->expression() ); mDynamicRangePerBandModel->setUpperExpression( mUpperExpressionWidget->expression() ); - QList > bandChoices; + QList> bandChoices; for ( int band = 1; band <= mLayer->bandCount(); ++band ) { bandChoices << qMakePair( mLayer->dataProvider()->displayBandName( band ), band ); } - mLowerExpressionWidget->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant & value )-> QgsExpressionContext - { + mLowerExpressionWidget->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant &value ) -> QgsExpressionContext { return createExpressionContextForBand( value.toInt() ); } ); - mUpperExpressionWidget->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant & value )-> QgsExpressionContext - { + mUpperExpressionWidget->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant &value ) -> QgsExpressionContext { return createExpressionContextForBand( value.toInt() ); } ); @@ -254,7 +249,7 @@ void QgsRasterElevationPropertiesWidget::apply() if ( !mLayer ) return; - QgsRasterLayerElevationProperties *props = qgis::down_cast< QgsRasterLayerElevationProperties * >( mLayer->elevationProperties() ); + QgsRasterLayerElevationProperties *props = qgis::down_cast( mLayer->elevationProperties() ); if ( !mModeComboBox->currentData().isValid() ) { @@ -263,7 +258,7 @@ void QgsRasterElevationPropertiesWidget::apply() else { props->setEnabled( true ); - props->setMode( mModeComboBox->currentData().value< Qgis::RasterElevationMode >() ); + props->setMode( mModeComboBox->currentData().value() ); } props->setZOffset( mOffsetZSpinBox->value() ); @@ -271,20 +266,20 @@ void QgsRasterElevationPropertiesWidget::apply() if ( mElevationLimitSpinBox->value() != mElevationLimitSpinBox->clearValue() ) props->setElevationLimit( mElevationLimitSpinBox->value() ); else - props->setElevationLimit( std::numeric_limits< double >::quiet_NaN() ); - props->setProfileLineSymbol( mLineStyleButton->clonedSymbol< QgsLineSymbol >() ); - props->setProfileFillSymbol( mFillStyleButton->clonedSymbol< QgsFillSymbol >() ); - props->setProfileSymbology( static_cast< Qgis::ProfileSurfaceSymbology >( mStyleComboBox->currentData().toInt() ) ); + props->setElevationLimit( std::numeric_limits::quiet_NaN() ); + props->setProfileLineSymbol( mLineStyleButton->clonedSymbol() ); + props->setProfileFillSymbol( mFillStyleButton->clonedSymbol() ); + props->setProfileSymbology( static_cast( mStyleComboBox->currentData().toInt() ) ); props->setBandNumber( mBandComboBox->currentBand() ); - double fixedLower = std::numeric_limits< double >::lowest(); - double fixedUpper = std::numeric_limits< double >::max(); + double fixedLower = std::numeric_limits::lowest(); + double fixedUpper = std::numeric_limits::max(); if ( mFixedLowerSpinBox->value() != mFixedLowerSpinBox->clearValue() ) fixedLower = mFixedLowerSpinBox->value(); if ( mFixedUpperSpinBox->value() != mFixedUpperSpinBox->clearValue() ) fixedUpper = mFixedUpperSpinBox->value(); - props->setFixedRange( QgsDoubleRange( fixedLower, fixedUpper, mLimitsComboBox->currentData().value< Qgis::RangeLimits >() ) ); + props->setFixedRange( QgsDoubleRange( fixedLower, fixedUpper, mLimitsComboBox->currentData().value() ) ); props->setFixedRangePerBand( mFixedRangePerBandModel->rangeData() ); @@ -300,7 +295,7 @@ void QgsRasterElevationPropertiesWidget::modeChanged() { if ( mModeComboBox->currentData().isValid() ) { - switch ( mModeComboBox->currentData().value< Qgis::RasterElevationMode >() ) + switch ( mModeComboBox->currentData().value() ) { case Qgis::RasterElevationMode::FixedElevationRange: mStackedWidget->setCurrentWidget( mPageFixedRange ); @@ -341,17 +336,16 @@ void QgsRasterElevationPropertiesWidget::calculateRangeByExpression( bool isUppe bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_description" ), mLayer->dataProvider()->bandDescription( 1 ), true, false, tr( "Band description" ) ) ); expressionContext.appendScope( bandScope ); - expressionContext.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" )} ); + expressionContext.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" ) } ); QgsExpressionBuilderDialog dlg = QgsExpressionBuilderDialog( nullptr, isUpper ? mFixedRangeUpperExpression : mFixedRangeLowerExpression, this, QStringLiteral( "generic" ), expressionContext ); - QList > bandChoices; + QList> bandChoices; for ( int band = 1; band <= mLayer->bandCount(); ++band ) { bandChoices << qMakePair( mLayer->dataProvider()->displayBandName( band ), band ); } - dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant & value )-> QgsExpressionContext - { + dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant &value ) -> QgsExpressionContext { return createExpressionContextForBand( value.toInt() ); } ); @@ -385,7 +379,7 @@ QgsExpressionContext QgsRasterElevationPropertiesWidget::createExpressionContext bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_name" ), ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->displayBandName( band ) : QString(), true, false, tr( "Band name" ) ) ); bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_description" ), ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->bandDescription( band ) : QString(), true, false, tr( "Band description" ) ) ); context.appendScope( bandScope ); - context.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" )} ); + context.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" ) } ); return context; } @@ -403,7 +397,7 @@ QgsRasterElevationPropertiesWidgetFactory::QgsRasterElevationPropertiesWidgetFac QgsMapLayerConfigWidget *QgsRasterElevationPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const { - return new QgsRasterElevationPropertiesWidget( qobject_cast< QgsRasterLayer * >( layer ), canvas, parent ); + return new QgsRasterElevationPropertiesWidget( qobject_cast( layer ), canvas, parent ); } bool QgsRasterElevationPropertiesWidgetFactory::supportLayerPropertiesDialog() const @@ -433,7 +427,6 @@ QString QgsRasterElevationPropertiesWidgetFactory::layerPropertiesPagePositionHi QgsRasterBandFixedElevationRangeModel::QgsRasterBandFixedElevationRangeModel( QObject *parent ) : QAbstractItemModel( parent ) { - } int QgsRasterBandFixedElevationRangeModel::columnCount( const QModelIndex & ) const @@ -509,10 +502,10 @@ QVariant QgsRasterBandFixedElevationRangeModel::data( const QModelIndex &index, return mBandNames.value( band, QString::number( band ) ); case 1: - return range.lower() > std::numeric_limits< double >::lowest() ? range.lower() : QVariant(); + return range.lower() > std::numeric_limits::lowest() ? range.lower() : QVariant(); case 2: - return range.upper() < std::numeric_limits< double >::max() ? range.upper() : QVariant(); + return range.upper() < std::numeric_limits::max() ? range.upper() : QVariant(); default: break; @@ -632,7 +625,6 @@ void QgsRasterBandFixedElevationRangeModel::setLayerData( QgsRasterLayer *layer, QgsRasterBandDynamicElevationRangeModel::QgsRasterBandDynamicElevationRangeModel( QObject *parent ) : QAbstractItemModel( parent ) { - } int QgsRasterBandDynamicElevationRangeModel::columnCount( const QModelIndex & ) const @@ -677,7 +669,8 @@ Qt::ItemFlags QgsRasterBandDynamicElevationRangeModel::flags( const QModelIndex case 1: case 2: - return Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable;; + return Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable; + ; default: break; } @@ -796,7 +789,6 @@ void QgsRasterBandDynamicElevationRangeModel::setUpperExpression( const QString QgsFixedElevationRangeDelegate::QgsFixedElevationRangeDelegate( QObject *parent ) : QStyledItemDelegate( parent ) { - } QWidget *QgsFixedElevationRangeDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const @@ -811,7 +803,7 @@ QWidget *QgsFixedElevationRangeDelegate::createEditor( QWidget *parent, const QS void QgsFixedElevationRangeDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const { - if ( QgsDoubleSpinBox *spin = qobject_cast< QgsDoubleSpinBox * >( editor ) ) + if ( QgsDoubleSpinBox *spin = qobject_cast( editor ) ) { model->setData( index, spin->value() ); } diff --git a/src/app/raster/qgsrasterelevationpropertieswidget.h b/src/app/raster/qgsrasterelevationpropertieswidget.h index c632b5ab8498..c328161e3865 100644 --- a/src/app/raster/qgsrasterelevationpropertieswidget.h +++ b/src/app/raster/qgsrasterelevationpropertieswidget.h @@ -31,7 +31,6 @@ class QgsRasterBandFixedElevationRangeModel : public QAbstractItemModel Q_OBJECT public: - QgsRasterBandFixedElevationRangeModel( QObject *parent ); int columnCount( const QModelIndex &parent = QModelIndex() ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; @@ -42,14 +41,13 @@ class QgsRasterBandFixedElevationRangeModel : public QAbstractItemModel QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; bool setData( const QModelIndex &index, const QVariant &value, int role ) override; - void setLayerData( QgsRasterLayer *layer, const QMap &ranges ); - QMap rangeData() const { return mRanges; } + void setLayerData( QgsRasterLayer *layer, const QMap &ranges ); + QMap rangeData() const { return mRanges; } private: - int mBandCount = 0; - QMap mBandNames; - QMap mRanges; + QMap mBandNames; + QMap mRanges; }; class QgsRasterBandDynamicElevationRangeModel : public QAbstractItemModel @@ -57,7 +55,6 @@ class QgsRasterBandDynamicElevationRangeModel : public QAbstractItemModel Q_OBJECT public: - QgsRasterBandDynamicElevationRangeModel( QObject *parent ); int columnCount( const QModelIndex &parent = QModelIndex() ) const override; int rowCount( const QModelIndex &parent = QModelIndex() ) const override; @@ -69,9 +66,9 @@ class QgsRasterBandDynamicElevationRangeModel : public QAbstractItemModel void setLayer( QgsRasterLayer *layer ); void setLowerExpression( const QString &expression ); void setUpperExpression( const QString &expression ); - private: - QPointer< QgsRasterLayer > mLayer; + private: + QPointer mLayer; QString mLowerExpression; QString mUpperExpression; }; @@ -81,20 +78,17 @@ class QgsFixedElevationRangeDelegate : public QStyledItemDelegate Q_OBJECT public: - QgsFixedElevationRangeDelegate( QObject *parent ); protected: QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem & /*option*/, const QModelIndex &index ) const override; void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override; - }; class QgsRasterElevationPropertiesWidget : public QgsMapLayerConfigWidget, public QgsExpressionContextGenerator, private Ui::QgsRasterElevationPropertiesWidgetBase { Q_OBJECT public: - QgsRasterElevationPropertiesWidget( QgsRasterLayer *layer, QgsMapCanvas *canvas, QWidget *parent ); void syncToLayer( QgsMapLayer *layer ) final; @@ -110,7 +104,6 @@ class QgsRasterElevationPropertiesWidget : public QgsMapLayerConfigWidget, publi void calculateRangeByExpression( bool isUpper ); private: - QgsExpressionContext createExpressionContextForBand( int band ) const; QgsRasterLayer *mLayer = nullptr; @@ -119,7 +112,6 @@ class QgsRasterElevationPropertiesWidget : public QgsMapLayerConfigWidget, publi QgsRasterBandDynamicElevationRangeModel *mDynamicRangePerBandModel = nullptr; QString mFixedRangeLowerExpression = QStringLiteral( "@band" ); QString mFixedRangeUpperExpression = QStringLiteral( "@band" ); - }; @@ -137,5 +129,4 @@ class QgsRasterElevationPropertiesWidgetFactory : public QObject, public QgsMapL }; - #endif // QGSRASTERELEVATIONPROPERTIESWIDGET_H diff --git a/src/app/sensor/qgsprojectsensorsettingswidget.cpp b/src/app/sensor/qgsprojectsensorsettingswidget.cpp index 98683e87ecd8..def77843ec59 100644 --- a/src/app/sensor/qgsprojectsensorsettingswidget.cpp +++ b/src/app/sensor/qgsprojectsensorsettingswidget.cpp @@ -30,10 +30,9 @@ QgsProjectSensorSettingsWidget::QgsProjectSensorSettingsWidget( QWidget *parent QgsSensorTableWidget *widget = new QgsSensorTableWidget( this ); mPanelStack->setMainPanel( widget ); - connect( widget, &QgsPanelWidget::showPanel, this, [ = ]( QgsPanelWidget * panel ) - { + connect( widget, &QgsPanelWidget::showPanel, this, [=]( QgsPanelWidget *panel ) { mSensorIntroductionLabel->setVisible( false ); - connect( panel, &QgsPanelWidget::panelAccepted, this, [ = ]() { mSensorIntroductionLabel->setVisible( true ); } ); + connect( panel, &QgsPanelWidget::panelAccepted, this, [=]() { mSensorIntroductionLabel->setVisible( true ); } ); } ); QDomElement sensorElem = QgsProject::instance()->sensorManager()->writeXml( mPreviousSensors ); @@ -48,8 +47,7 @@ QgsProjectSensorSettingsWidget::QgsProjectSensorSettingsWidget( QWidget *parent } } - connect( QgsProject::instance()->sensorManager(), &QgsSensorManager::sensorErrorOccurred, this, [ = ]( const QString & id ) - { + connect( QgsProject::instance()->sensorManager(), &QgsSensorManager::sensorErrorOccurred, this, [=]( const QString &id ) { if ( QgsAbstractSensor *sensor = QgsProject::instance()->sensorManager()->sensor( id ) ) { mMessageBar->pushCritical( tr( "Sensor Error" ), QStringLiteral( "%1: %2" ).arg( sensor->name(), sensor->errorString() ) ); diff --git a/src/app/sensor/qgsprojectsensorsettingswidget.h b/src/app/sensor/qgsprojectsensorsettingswidget.h index 83d547d8c74a..3c2ef1c3bee1 100644 --- a/src/app/sensor/qgsprojectsensorsettingswidget.h +++ b/src/app/sensor/qgsprojectsensorsettingswidget.h @@ -25,7 +25,6 @@ class QgsProjectSensorSettingsWidget : public QgsOptionsPageWidget, private Ui:: { Q_OBJECT public: - QgsProjectSensorSettingsWidget( QWidget *parent = nullptr ); public slots: @@ -35,7 +34,6 @@ class QgsProjectSensorSettingsWidget : public QgsOptionsPageWidget, private Ui:: void cancel() override; private: - QDomDocument mPreviousSensors; QStringList mConnectedSensors; }; @@ -51,5 +49,4 @@ class QgsProjectSensorSettingsWidgetFactory : public QgsOptionsWidgetFactory }; - #endif // QGSPROJECTSENSORSETTINGSWIDGET_H diff --git a/src/app/sensor/qgssensortablewidget.cpp b/src/app/sensor/qgssensortablewidget.cpp index 48a5ed934a47..ab8af489c31d 100644 --- a/src/app/sensor/qgssensortablewidget.cpp +++ b/src/app/sensor/qgssensortablewidget.cpp @@ -37,10 +37,10 @@ QgsSensorSettingsWidget::QgsSensorSettingsWidget( QgsAbstractSensor *sensor, QWi setupUi( this ); setPanelTitle( tr( "Sensor Settings" ) ); setObjectName( QStringLiteral( "SensorSettings" ) ); - connect( this, &QgsPanelWidget::panelAccepted, this, [ = ]() { apply(); } ); + connect( this, &QgsPanelWidget::panelAccepted, this, [=]() { apply(); } ); mNameLineEdit->setText( sensor->name() ); - connect( mNameLineEdit, &QLineEdit::textChanged, this, [ = ]() { mDirty = true; } ); + connect( mNameLineEdit, &QLineEdit::textChanged, this, [=]() { mDirty = true; } ); const QMap sensorTypes = QgsGui::sensorGuiRegistry()->sensorTypes(); for ( auto sensorIt = sensorTypes.begin(); sensorIt != sensorTypes.end(); ++sensorIt ) @@ -48,8 +48,7 @@ QgsSensorSettingsWidget::QgsSensorSettingsWidget( QgsAbstractSensor *sensor, QWi mTypeComboBox->addItem( QgsGui::sensorGuiRegistry()->sensorMetadata( sensorIt.key() )->creationIcon(), sensorIt.value(), sensorIt.key() ); } mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( sensor->type() ) ); - connect( mTypeComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [ = ]() - { + connect( mTypeComboBox, static_cast( &QComboBox::currentIndexChanged ), this, [=]() { mDirty = true; setSensorWidget(); } ); @@ -71,7 +70,7 @@ void QgsSensorSettingsWidget::setSensorWidget() mSensorWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); mSensorWidget->setSensor( mSensor ); mTypeLayout->addWidget( mSensorWidget ); - connect( mSensorWidget, &QgsAbstractSensorWidget::changed, this, [ = ]() { mDirty = true; } ); + connect( mSensorWidget, &QgsAbstractSensorWidget::changed, this, [=]() { mDirty = true; } ); } } @@ -111,23 +110,21 @@ QgsSensorTableWidget::QgsSensorTableWidget( QWidget *parent ) mSensorTable->setSelectionBehavior( QAbstractItemView::SelectRows ); mSensorTable->setSelectionMode( QAbstractItemView::SingleSelection ); - connect( mSensorTable, &QAbstractItemView::doubleClicked, this, [ = ]( const QModelIndex & index ) - { + connect( mSensorTable, &QAbstractItemView::doubleClicked, this, [=]( const QModelIndex &index ) { if ( index.isValid() ) { - QgsSensorSettingsWidget *settingsWidget = new QgsSensorSettingsWidget( mSensorModel->data( index, static_cast< int >( QgsSensorModel::CustomRole::Sensor ) ).value(), this ); + QgsSensorSettingsWidget *settingsWidget = new QgsSensorSettingsWidget( mSensorModel->data( index, static_cast( QgsSensorModel::CustomRole::Sensor ) ).value(), this ); showPanel( settingsWidget ); } } ); - connect( QgsProject::instance()->sensorManager(), &QgsSensorManager::sensorStatusChanged, this, [ = ]( const QString & id ) - { + connect( QgsProject::instance()->sensorManager(), &QgsSensorManager::sensorStatusChanged, this, [=]( const QString &id ) { const QModelIndex index = mSensorTable->currentIndex(); if ( index.isValid() ) { - if ( id == mSensorModel->data( index, static_cast< int >( QgsSensorModel::CustomRole::SensorId ) ).toString() ) + if ( id == mSensorModel->data( index, static_cast( QgsSensorModel::CustomRole::SensorId ) ).toString() ) { - QgsAbstractSensor *sensor = mSensorModel->data( index, static_cast< int >( QgsSensorModel::CustomRole::Sensor ) ).value(); + QgsAbstractSensor *sensor = mSensorModel->data( index, static_cast( QgsSensorModel::CustomRole::Sensor ) ).value(); if ( sensor ) { if ( sensor->status() == Qgis::DeviceConnectionStatus::Disconnected ) @@ -143,12 +140,11 @@ QgsSensorTableWidget::QgsSensorTableWidget( QWidget *parent ) } } ); - connect( mSensorTable->selectionModel(), &QItemSelectionModel::currentChanged, this, [ = ]( const QModelIndex & current, const QModelIndex & ) - { + connect( mSensorTable->selectionModel(), &QItemSelectionModel::currentChanged, this, [=]( const QModelIndex ¤t, const QModelIndex & ) { mActionConnection->setEnabled( current.isValid() ); mActionRemoveSensor->setEnabled( current.isValid() ); mActionEditSensor->setEnabled( current.isValid() ); - if ( current.isValid() && mSensorModel->data( current, static_cast< int >( QgsSensorModel::CustomRole::SensorStatus ) ).value() == Qgis::DeviceConnectionStatus::Connected ) + if ( current.isValid() && mSensorModel->data( current, static_cast( QgsSensorModel::CustomRole::SensorStatus ) ).value() == Qgis::DeviceConnectionStatus::Connected ) { mActionConnection->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionStop.svg" ) ) ); } @@ -158,12 +154,11 @@ QgsSensorTableWidget::QgsSensorTableWidget( QWidget *parent ) } } ); - connect( mActionConnection, &QToolButton::clicked, this, [ = ]() - { + connect( mActionConnection, &QToolButton::clicked, this, [=]() { const QModelIndex index = mSensorTable->currentIndex(); if ( index.isValid() ) { - QgsAbstractSensor *sensor = mSensorModel->data( index, static_cast< int >( QgsSensorModel::CustomRole::Sensor ) ).value(); + QgsAbstractSensor *sensor = mSensorModel->data( index, static_cast( QgsSensorModel::CustomRole::Sensor ) ).value(); if ( sensor ) { if ( sensor->status() == Qgis::DeviceConnectionStatus::Disconnected ) @@ -178,8 +173,7 @@ QgsSensorTableWidget::QgsSensorTableWidget( QWidget *parent ) } } ); - connect( mActionAddSensor, &QToolButton::clicked, this, [ = ]() - { + connect( mActionAddSensor, &QToolButton::clicked, this, [=]() { QgsTcpSocketSensor *sensor = new QgsTcpSocketSensor(); sensor->setName( tr( "New sensor" ) ); QgsProject::instance()->sensorManager()->addSensor( sensor ); @@ -188,21 +182,19 @@ QgsSensorTableWidget::QgsSensorTableWidget( QWidget *parent ) showPanel( settingsWidget ); } ); - connect( mActionRemoveSensor, &QToolButton::clicked, this, [ = ]() - { + connect( mActionRemoveSensor, &QToolButton::clicked, this, [=]() { const QModelIndex index = mSensorTable->currentIndex(); if ( index.isValid() ) { - QgsProject::instance()->sensorManager()->removeSensor( mSensorModel->data( index, static_cast< int >( QgsSensorModel::CustomRole::SensorId ) ).toString() ); + QgsProject::instance()->sensorManager()->removeSensor( mSensorModel->data( index, static_cast( QgsSensorModel::CustomRole::SensorId ) ).toString() ); } } ); - connect( mActionEditSensor, &QToolButton::clicked, this, [ = ]() - { + connect( mActionEditSensor, &QToolButton::clicked, this, [=]() { const QModelIndex index = mSensorTable->currentIndex(); if ( index.isValid() ) { - QgsSensorSettingsWidget *settingsWidget = new QgsSensorSettingsWidget( mSensorModel->data( index, static_cast< int >( QgsSensorModel::CustomRole::Sensor ) ).value(), this ); + QgsSensorSettingsWidget *settingsWidget = new QgsSensorSettingsWidget( mSensorModel->data( index, static_cast( QgsSensorModel::CustomRole::Sensor ) ).value(), this ); showPanel( settingsWidget ); } } ); diff --git a/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.cpp b/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.cpp index 25d23a60f5d1..41d4705129ef 100644 --- a/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.cpp +++ b/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.cpp @@ -32,8 +32,8 @@ QgsTiledSceneElevationPropertiesWidget::QgsTiledSceneElevationPropertiesWidget( syncToLayer( layer ); - connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsTiledSceneElevationPropertiesWidget::onChanged ); - connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsTiledSceneElevationPropertiesWidget::onChanged ); + connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsTiledSceneElevationPropertiesWidget::onChanged ); + connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsTiledSceneElevationPropertiesWidget::onChanged ); connect( mShiftZAxisButton, &QPushButton::clicked, this, &QgsTiledSceneElevationPropertiesWidget::shiftSceneZAxis ); // setProperty( "helpPage", QStringLiteral( "working_with_point_clouds/point_clouds.html#elevation-properties" ) ); @@ -41,11 +41,11 @@ QgsTiledSceneElevationPropertiesWidget::QgsTiledSceneElevationPropertiesWidget( void QgsTiledSceneElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) { - mLayer = qobject_cast< QgsTiledSceneLayer * >( layer ); + mLayer = qobject_cast( layer ); if ( !mLayer ) return; - const QgsTiledSceneLayerElevationProperties *properties = qgis::down_cast< const QgsTiledSceneLayerElevationProperties * >( mLayer->elevationProperties() ); + const QgsTiledSceneLayerElevationProperties *properties = qgis::down_cast( mLayer->elevationProperties() ); mBlockUpdates = true; mOffsetZSpinBox->setValue( properties->zOffset() ); @@ -59,7 +59,7 @@ void QgsTiledSceneElevationPropertiesWidget::apply() if ( !mLayer ) return; - QgsTiledSceneLayerElevationProperties *properties = qgis::down_cast< QgsTiledSceneLayerElevationProperties * >( mLayer->elevationProperties() ); + QgsTiledSceneLayerElevationProperties *properties = qgis::down_cast( mLayer->elevationProperties() ); const bool changed3DrelatedProperties = !qgsDoubleNear( mOffsetZSpinBox->value(), properties->zOffset() ) || !qgsDoubleNear( mScaleZSpinBox->value(), properties->zScale() ); @@ -99,7 +99,7 @@ QgsTiledSceneElevationPropertiesWidgetFactory::QgsTiledSceneElevationPropertiesW QgsMapLayerConfigWidget *QgsTiledSceneElevationPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const { - return new QgsTiledSceneElevationPropertiesWidget( qobject_cast< QgsTiledSceneLayer * >( layer ), canvas, parent ); + return new QgsTiledSceneElevationPropertiesWidget( qobject_cast( layer ), canvas, parent ); } bool QgsTiledSceneElevationPropertiesWidgetFactory::supportLayerPropertiesDialog() const @@ -121,4 +121,3 @@ QString QgsTiledSceneElevationPropertiesWidgetFactory::layerPropertiesPagePositi { return QStringLiteral( "mOptsPage_Metadata" ); } - diff --git a/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.h b/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.h index 5566340bd5aa..d7b21b6ca646 100644 --- a/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.h +++ b/src/app/tiledscene/qgstiledsceneelevationpropertieswidget.h @@ -27,7 +27,6 @@ class QgsTiledSceneElevationPropertiesWidget : public QgsMapLayerConfigWidget, p { Q_OBJECT public: - QgsTiledSceneElevationPropertiesWidget( QgsTiledSceneLayer *layer, QgsMapCanvas *canvas, QWidget *parent ); void syncToLayer( QgsMapLayer *layer ) final; @@ -40,11 +39,10 @@ class QgsTiledSceneElevationPropertiesWidget : public QgsMapLayerConfigWidget, p void onChanged(); void shiftSceneZAxis(); - private: + private: QgsTiledSceneLayer *mLayer = nullptr; bool mBlockUpdates = false; - }; @@ -62,5 +60,4 @@ class QgsTiledSceneElevationPropertiesWidgetFactory : public QObject, public Qgs }; - #endif // QGSTILEDSCENEELEVATIONPROPERTIESWIDGET_H diff --git a/src/app/tiledscene/qgstiledscenelayerproperties.cpp b/src/app/tiledscene/qgstiledscenelayerproperties.cpp index d593e846f2f6..f24acdb44613 100644 --- a/src/app/tiledscene/qgstiledscenelayerproperties.cpp +++ b/src/app/tiledscene/qgstiledscenelayerproperties.cpp @@ -72,8 +72,7 @@ QgsTiledSceneLayerProperties::QgsTiledSceneLayerProperties( QgsTiledSceneLayer * QgsSettings settings; if ( !settings.contains( QStringLiteral( "/Windows/TiledSceneLayerProperties/tab" ) ) ) { - settings.setValue( QStringLiteral( "Windows/TiledSceneLayerProperties/tab" ), - mOptStackedWidget->indexOf( mOptsPage_Information ) ); + settings.setValue( QStringLiteral( "Windows/TiledSceneLayerProperties/tab" ), mOptStackedWidget->indexOf( mOptsPage_Information ) ); } mBtnStyle = new QPushButton( tr( "Style" ) ); @@ -190,4 +189,3 @@ void QgsTiledSceneLayerProperties::crsChanged( const QgsCoordinateReferenceSyste mLayer->setCrs( crs ); mMetadataWidget->crsChanged(); } - diff --git a/src/app/tiledscene/qgstiledscenelayerproperties.h b/src/app/tiledscene/qgstiledscenelayerproperties.h index f04b3a5d5bc6..fbcf0b7a697c 100644 --- a/src/app/tiledscene/qgstiledscenelayerproperties.h +++ b/src/app/tiledscene/qgstiledscenelayerproperties.h @@ -49,7 +49,6 @@ class APP_EXPORT QgsTiledSceneLayerProperties : public QgsLayerPropertiesDialog, QgsMetadataWidget *mMetadataWidget = nullptr; QgsCoordinateReferenceSystem mBackupCrs; - }; #endif // QGSTILEDSCENELAYERPROPERTIES_H diff --git a/src/app/tiledscene/qgstiledscenelayerstylewidget.cpp b/src/app/tiledscene/qgstiledscenelayerstylewidget.cpp index 402d7b288fae..faa197a85a0e 100644 --- a/src/app/tiledscene/qgstiledscenelayerstylewidget.cpp +++ b/src/app/tiledscene/qgstiledscenelayerstylewidget.cpp @@ -30,7 +30,7 @@ QgsTiledSceneRendererWidgetFactory::QgsTiledSceneRendererWidgetFactory( QObject QgsMapLayerConfigWidget *QgsTiledSceneRendererWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *, bool, QWidget *parent ) const { - return new QgsTiledSceneRendererPropertiesWidget( qobject_cast< QgsTiledSceneLayer * >( layer ), QgsStyle::defaultStyle(), parent ); + return new QgsTiledSceneRendererPropertiesWidget( qobject_cast( layer ), QgsStyle::defaultStyle(), parent ); } bool QgsTiledSceneRendererWidgetFactory::supportLayerPropertiesDialog() const diff --git a/src/app/tiledscene/qgstiledscenelayerstylewidget.h b/src/app/tiledscene/qgstiledscenelayerstylewidget.h index c4b05b4140fe..c7c0308825b0 100644 --- a/src/app/tiledscene/qgstiledscenelayerstylewidget.h +++ b/src/app/tiledscene/qgstiledscenelayerstylewidget.h @@ -33,5 +33,4 @@ class QgsTiledSceneRendererWidgetFactory : public QObject, public QgsMapLayerCon }; - #endif // QGSTILEDSCENELAYERSTYLEWIDGET_H diff --git a/src/app/ui_defaults.h b/src/app/ui_defaults.h index 08c272084286..d1ecb9d31770 100644 --- a/src/app/ui_defaults.h +++ b/src/app/ui_defaults.h @@ -1,245 +1,3570 @@ #ifndef UI_DEFAULTS_H #define UI_DEFAULTS_H -static const unsigned char defaultUIgeometry[] = -{ - 0x1, 0xd9, 0xd0, 0xcb, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x2, 0xac, 0x0, 0x0, 0x0, 0xe8, - 0x0, 0x0, 0x9, 0x87, 0x0, 0x0, 0x5, 0x46, 0x0, 0x0, 0x2, 0xac, 0x0, 0x0, 0x1, 0xd, - 0x0, 0x0, 0x9, 0x87, 0x0, 0x0, 0x5, 0x46, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, - 0xa, 0x0, 0x0, 0x0, 0x2, 0xac, 0x0, 0x0, 0x1, 0xd, 0x0, 0x0, 0x9, 0x87, 0x0, 0x0, - 0x5, 0x46, +static const unsigned char defaultUIgeometry[] = { + 0x1, + 0xd9, + 0xd0, + 0xcb, + 0x0, + 0x3, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0xac, + 0x0, + 0x0, + 0x0, + 0xe8, + 0x0, + 0x0, + 0x9, + 0x87, + 0x0, + 0x0, + 0x5, + 0x46, + 0x0, + 0x0, + 0x2, + 0xac, + 0x0, + 0x0, + 0x1, + 0xd, + 0x0, + 0x0, + 0x9, + 0x87, + 0x0, + 0x0, + 0x5, + 0x46, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xa, + 0x0, + 0x0, + 0x0, + 0x2, + 0xac, + 0x0, + 0x0, + 0x1, + 0xd, + 0x0, + 0x0, + 0x9, + 0x87, + 0x0, + 0x0, + 0x5, + 0x46, }; -static const unsigned char defaultUIstate[] = -{ - 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x1, 0x26, 0x0, 0x0, 0x3, 0xb3, 0xfc, 0x2, 0x0, 0x0, 0x0, 0xe, 0xfc, - 0x0, 0x0, 0x0, 0x66, 0x0, 0x0, 0x1, 0xe2, 0x0, 0x0, 0x0, 0x7a, 0x0, 0xff, 0xff, 0xff, - 0xfa, 0x0, 0x0, 0x0, 0x2, 0x1, 0x0, 0x0, 0x0, 0x3, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, - 0x4c, 0x0, 0x65, 0x0, 0x67, 0x0, 0x65, 0x0, 0x6e, 0x0, 0x64, 0x1, 0x0, 0x0, 0x0, 0x0, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, - 0x14, 0x0, 0x4c, 0x0, 0x61, 0x0, 0x79, 0x0, 0x65, 0x0, 0x72, 0x0, 0x4f, 0x0, 0x72, 0x0, - 0x64, 0x0, 0x65, 0x0, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, - 0x0, 0xb8, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x42, 0x0, 0x72, 0x0, - 0x6f, 0x0, 0x77, 0x0, 0x73, 0x0, 0x65, 0x0, 0x72, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, - 0xff, 0xff, 0x0, 0x0, 0x0, 0x46, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x10, 0x0, - 0x4f, 0x0, 0x76, 0x0, 0x65, 0x0, 0x72, 0x0, 0x76, 0x0, 0x69, 0x0, 0x65, 0x0, 0x77, 0x0, - 0x0, 0x0, 0x1, 0xd7, 0x0, 0x0, 0x0, 0xc4, 0x0, 0x0, 0x0, 0x15, 0x0, 0xff, 0xff, 0xff, - 0xfb, 0x0, 0x0, 0x0, 0x22, 0x0, 0x43, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x64, 0x0, - 0x69, 0x0, 0x6e, 0x0, 0x61, 0x0, 0x74, 0x0, 0x65, 0x0, 0x43, 0x0, 0x61, 0x0, 0x70, 0x0, - 0x74, 0x0, 0x75, 0x0, 0x72, 0x0, 0x65, 0x0, 0x0, 0x0, 0x1, 0x7e, 0x0, 0x0, 0x0, 0xa0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, 0x8, 0x0, 0x55, 0x0, - 0x6e, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x0, 0x0, 0x1, 0xe4, 0x0, 0x0, 0x0, 0xdc, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, 0x10, 0x0, 0x42, 0x0, 0x72, 0x0, - 0x6f, 0x0, 0x77, 0x0, 0x73, 0x0, 0x65, 0x0, 0x72, 0x0, 0x32, 0x0, 0x0, 0x0, 0x2, 0x13, - 0x0, 0x0, 0x0, 0xad, 0x0, 0x0, 0x0, 0x7e, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, - 0x1c, 0x0, 0x47, 0x0, 0x50, 0x0, 0x53, 0x0, 0x49, 0x0, 0x6e, 0x0, 0x66, 0x0, 0x6f, 0x0, - 0x72, 0x0, 0x6d, 0x0, 0x61, 0x0, 0x74, 0x0, 0x69, 0x0, 0x6f, 0x0, 0x6e, 0x0, 0x0, 0x0, - 0x1, 0xbb, 0x0, 0x0, 0x1, 0x5, 0x0, 0x0, 0x0, 0x5f, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, - 0x0, 0x0, 0x28, 0x0, 0x64, 0x0, 0x77, 0x0, 0x4f, 0x0, 0x70, 0x0, 0x65, 0x0, 0x6e, 0x0, - 0x6c, 0x0, 0x61, 0x0, 0x79, 0x0, 0x65, 0x0, 0x72, 0x0, 0x73, 0x0, 0x4f, 0x0, 0x76, 0x0, - 0x65, 0x0, 0x72, 0x0, 0x76, 0x0, 0x69, 0x0, 0x65, 0x0, 0x77, 0x0, 0x0, 0x0, 0x1, 0x64, - 0x0, 0x0, 0x1, 0x37, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, - 0x1c, 0x0, 0x75, 0x0, 0x6e, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x2f, 0x0, 0x72, 0x0, 0x65, 0x0, - 0x64, 0x0, 0x6f, 0x0, 0x20, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xf1, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, - 0x0, 0x0, 0x2e, 0x0, 0x41, 0x0, 0x64, 0x0, 0x76, 0x0, 0x61, 0x0, 0x6e, 0x0, 0x63, 0x0, - 0x65, 0x0, 0x64, 0x0, 0x44, 0x0, 0x69, 0x0, 0x67, 0x0, 0x69, 0x0, 0x74, 0x0, 0x69, 0x0, - 0x7a, 0x0, 0x69, 0x0, 0x6e, 0x0, 0x67, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, - 0x73, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xf7, 0x0, 0xff, - 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x34, 0x0, 0x53, 0x0, 0x74, 0x0, 0x61, 0x0, 0x74, 0x0, - 0x69, 0x0, 0x73, 0x0, 0x74, 0x0, 0x61, 0x0, 0x6c, 0x0, 0x53, 0x0, 0x75, 0x0, 0x6d, 0x0, - 0x6d, 0x0, 0x61, 0x0, 0x72, 0x0, 0x79, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, - 0x57, 0x0, 0x69, 0x0, 0x64, 0x0, 0x67, 0x0, 0x65, 0x0, 0x74, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, - 0x26, 0x0, 0x42, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6b, 0x0, 0x6d, 0x0, 0x61, 0x0, 0x72, 0x0, - 0x6b, 0x0, 0x73, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x57, 0x0, 0x69, 0x0, - 0x64, 0x0, 0x67, 0x0, 0x65, 0x0, 0x74, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x0, 0x0, 0x7a, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x4c, 0x0, - 0x61, 0x0, 0x79, 0x0, 0x65, 0x0, 0x72, 0x0, 0x73, 0x1, 0x0, 0x0, 0x2, 0x4e, 0x0, 0x0, - 0x1, 0xcb, 0x0, 0x0, 0x0, 0x7a, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x38, 0x0, - 0x53, 0x0, 0x74, 0x0, 0x61, 0x0, 0x74, 0x0, 0x69, 0x0, 0x73, 0x0, 0x74, 0x0, 0x69, 0x0, - 0x63, 0x0, 0x61, 0x0, 0x6c, 0x0, 0x53, 0x0, 0x75, 0x0, 0x6d, 0x0, 0x6d, 0x0, 0x61, 0x0, - 0x72, 0x0, 0x79, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x57, 0x0, 0x69, 0x0, - 0x64, 0x0, 0x67, 0x0, 0x65, 0x0, 0x74, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x0, 0x0, 0xcc, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x18, 0x0, 0x56, 0x0, - 0x65, 0x0, 0x72, 0x0, 0x74, 0x0, 0x65, 0x0, 0x78, 0x0, 0x45, 0x0, 0x64, 0x0, 0x69, 0x0, - 0x74, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, - 0x0, 0x5f, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x2a, 0x0, 0x0, - 0x2, 0x33, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x6, 0xfb, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x53, 0x0, - 0x65, 0x0, 0x78, 0x0, 0x74, 0x0, 0x61, 0x0, 0x6e, 0x0, 0x74, 0x0, 0x65, 0x0, 0x54, 0x0, - 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x62, 0x0, 0x6f, 0x0, 0x78, 0x0, 0x0, 0x0, 0x0, 0x67, - 0x0, 0x0, 0x2, 0x34, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0x0, - 0x64, 0x0, 0x0, 0x2, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfa, 0xff, 0xff, - 0xff, 0xff, 0x1, 0x0, 0x0, 0x0, 0x2, 0xfb, 0x0, 0x0, 0x0, 0x18, 0x0, 0x4c, 0x0, 0x61, - 0x0, 0x79, 0x0, 0x65, 0x0, 0x72, 0x0, 0x53, 0x0, 0x74, 0x0, 0x79, 0x0, 0x6c, 0x0, 0x69, - 0x0, 0x6e, 0x0, 0x67, 0x0, 0x0, 0x0, 0x3, 0xd6, 0x0, 0x0, 0x1, 0x2a, 0x0, 0x0, 0x1, - 0x27, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x22, 0x0, 0x50, 0x0, 0x72, 0x0, 0x6f, - 0x0, 0x63, 0x0, 0x65, 0x0, 0x73, 0x0, 0x73, 0x0, 0x69, 0x0, 0x6e, 0x0, 0x67, 0x0, 0x54, - 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x62, 0x0, 0x6f, 0x0, 0x78, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x46, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, - 0x0, 0x14, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x57, 0x0, 0x69, 0x0, 0x64, - 0x0, 0x67, 0x0, 0x65, 0x0, 0x74, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, 0x10, 0x0, 0x44, 0x0, 0x65, - 0x0, 0x76, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x73, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x5f, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, - 0x0, 0x1a, 0x0, 0x52, 0x0, 0x65, 0x0, 0x73, 0x0, 0x75, 0x0, 0x6c, 0x0, 0x74, 0x0, 0x73, - 0x0, 0x56, 0x0, 0x69, 0x0, 0x65, 0x0, 0x77, 0x0, 0x65, 0x0, 0x72, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x1, 0x1f, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, - 0x0, 0x20, 0x0, 0x74, 0x0, 0x68, 0x0, 0x65, 0x0, 0x54, 0x0, 0x69, 0x0, 0x6c, 0x0, 0x65, - 0x0, 0x53, 0x0, 0x63, 0x0, 0x61, 0x0, 0x6c, 0x0, 0x65, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, - 0x0, 0x6b, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x7b, 0x0, - 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, - 0x1, 0x0, 0x0, 0x0, 0x1, 0xfb, 0x0, 0x0, 0x0, 0x26, 0x0, 0x54, 0x0, 0x65, 0x0, 0x6d, - 0x0, 0x70, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x61, 0x0, 0x6c, 0x0, 0x20, 0x0, 0x43, 0x0, 0x6f, - 0x0, 0x6e, 0x0, 0x74, 0x0, 0x72, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x6c, 0x0, 0x65, 0x0, 0x72, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x2, 0xce, 0x0, 0xff, 0xff, - 0xff, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x3, 0xac, 0x0, 0x0, 0x1, 0x65, 0xfc, 0x1, 0x0, - 0x0, 0x0, 0x3, 0xfb, 0x0, 0x0, 0x0, 0x14, 0x0, 0x4d, 0x0, 0x65, 0x0, 0x73, 0x0, 0x73, - 0x0, 0x61, 0x0, 0x67, 0x0, 0x65, 0x0, 0x4c, 0x0, 0x6f, 0x0, 0x67, 0x0, 0x0, 0x0, 0x1, - 0x54, 0x0, 0x0, 0x3, 0xac, 0x0, 0x0, 0x0, 0x7f, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, - 0x0, 0x26, 0x0, 0x55, 0x0, 0x73, 0x0, 0x65, 0x0, 0x72, 0x0, 0x49, 0x0, 0x6e, 0x0, 0x70, - 0x0, 0x75, 0x0, 0x74, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x57, 0x0, 0x69, - 0x0, 0x64, 0x0, 0x67, 0x0, 0x65, 0x0, 0x74, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xc8, 0x0, 0x0, 0x0, 0x64, 0xfb, 0x0, 0x0, 0x0, 0x1a, 0x0, 0x50, - 0x0, 0x79, 0x0, 0x74, 0x0, 0x68, 0x0, 0x6f, 0x0, 0x6e, 0x0, 0x43, 0x0, 0x6f, 0x0, 0x6e, - 0x0, 0x73, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x65, 0x1, 0x0, 0x0, 0x1, 0x4f, 0x0, 0x0, 0x5, - 0xaf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0xb0, 0x0, 0x0, 0x3, - 0xb3, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, - 0x2, 0xfc, 0x0, 0x0, 0x0, 0xd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, - 0x0, 0x1a, 0x0, 0x6d, 0x0, 0x4c, 0x0, 0x61, 0x0, 0x79, 0x0, 0x65, 0x0, 0x72, 0x0, 0x54, - 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x2, 0x0, 0x0, 0x0, - 0xc2, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, - 0x18, 0x0, 0x6d, 0x0, 0x46, 0x0, 0x69, 0x0, 0x6c, 0x0, 0x65, 0x0, 0x54, 0x0, 0x6f, 0x0, - 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, - 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x6d, - 0x0, 0x4d, 0x0, 0x61, 0x0, 0x70, 0x0, 0x4e, 0x0, 0x61, 0x0, 0x76, 0x0, 0x54, 0x0, 0x6f, - 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x0, 0xd6, 0xff, - 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x22, 0x0, - 0x6d, 0x0, 0x53, 0x0, 0x65, 0x0, 0x6c, 0x0, 0x65, 0x0, 0x63, 0x0, 0x74, 0x0, 0x69, 0x0, - 0x6f, 0x0, 0x6e, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, - 0x72, 0x1, 0x0, 0x0, 0x2, 0xf6, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x0, 0x6d, 0x0, 0x41, 0x0, 0x74, 0x0, 0x74, 0x0, 0x72, - 0x0, 0x69, 0x0, 0x62, 0x0, 0x75, 0x0, 0x74, 0x0, 0x65, 0x0, 0x73, 0x0, 0x54, 0x0, 0x6f, - 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x3, 0xae, 0xff, - 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x32, 0x0, - 0x6d, 0x0, 0x44, 0x0, 0x61, 0x0, 0x74, 0x0, 0x61, 0x0, 0x53, 0x0, 0x6f, 0x0, 0x75, 0x0, - 0x72, 0x0, 0x63, 0x0, 0x65, 0x0, 0x4d, 0x0, 0x61, 0x0, 0x6e, 0x0, 0x61, 0x0, 0x67, 0x0, - 0x65, 0x0, 0x72, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, - 0x72, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x6d, 0x0, 0x44, 0x0, 0x69, 0x0, 0x67, 0x0, 0x69, - 0x0, 0x74, 0x0, 0x69, 0x0, 0x7a, 0x0, 0x65, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, - 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x0, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1a, 0x0, 0x6d, 0x0, 0x4c, 0x0, - 0x61, 0x0, 0x62, 0x0, 0x65, 0x0, 0x6c, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, - 0x42, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x2, 0xcc, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x6d, 0x0, 0x44, 0x0, 0x61, - 0x0, 0x74, 0x0, 0x61, 0x0, 0x62, 0x0, 0x61, 0x0, 0x73, 0x0, 0x65, 0x0, 0x54, 0x0, 0x6f, - 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x0, 0x0, 0x0, 0x2, 0x6f, 0xff, - 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, 0x0, - 0x6d, 0x0, 0x57, 0x0, 0x65, 0x0, 0x62, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, - 0x42, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x4, 0x13, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x6d, 0x0, 0x50, 0x0, 0x6c, - 0x0, 0x75, 0x0, 0x67, 0x0, 0x69, 0x0, 0x6e, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, - 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x4, 0x44, 0xff, 0xff, 0xff, 0xff, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x0, 0x6d, 0x0, 0x48, 0x0, - 0x65, 0x0, 0x6c, 0x0, 0x70, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, - 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x4, 0x75, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x6d, 0x0, 0x56, 0x0, 0x65, 0x0, 0x63, - 0x0, 0x74, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, - 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x4, 0xa6, 0x0, 0x0, 0x2, 0x29, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, - 0x30, 0x0, 0x6d, 0x0, 0x41, 0x0, 0x64, 0x0, 0x76, 0x0, 0x61, 0x0, 0x6e, 0x0, 0x63, 0x0, - 0x65, 0x0, 0x64, 0x0, 0x44, 0x0, 0x69, 0x0, 0x67, 0x0, 0x69, 0x0, 0x74, 0x0, 0x69, 0x0, - 0x7a, 0x0, 0x65, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, - 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x6d, 0x0, 0x52, 0x0, 0x61, 0x0, 0x73, 0x0, 0x74, - 0x0, 0x65, 0x0, 0x72, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, - 0x0, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0xb0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x6d, 0x0, 0x53, 0x0, 0x6e, 0x0, 0x61, 0x0, - 0x70, 0x0, 0x70, 0x0, 0x69, 0x0, 0x6e, 0x0, 0x67, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, - 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x4, - 0x0, 0x0, 0x0, 0x2a, 0x0, 0x6d, 0x0, 0x53, 0x0, 0x68, 0x0, 0x61, 0x0, 0x70, 0x0, 0x65, - 0x0, 0x44, 0x0, 0x69, 0x0, 0x67, 0x0, 0x69, 0x0, 0x74, 0x0, 0x69, 0x0, 0x7a, 0x0, 0x65, - 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x18, 0x0, 0x6d, 0x0, 0x4d, 0x0, 0x65, 0x0, 0x73, 0x0, 0x68, 0x0, 0x54, 0x0, - 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x0, 0x0, 0x0, 0x0, 0xb8, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x26, - 0x0, 0x6d, 0x0, 0x41, 0x0, 0x6e, 0x0, 0x6e, 0x0, 0x6f, 0x0, 0x74, 0x0, 0x61, 0x0, 0x74, - 0x0, 0x69, 0x0, 0x6f, 0x0, 0x6e, 0x0, 0x73, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, - 0x0, 0x42, 0x0, 0x61, 0x0, 0x72, 0x0, 0x0, 0x0, 0x0, 0xb8, 0xff, 0xff, 0xff, 0xff, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, 0x0, 0x6d, 0x0, 0x47, 0x0, - 0x70, 0x0, 0x73, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x42, 0x0, 0x61, 0x0, - 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x2, 0x4d, 0x8, 0x61, 0x0, 0x27, - 0x81, 0xd7, +static const unsigned char defaultUIstate[] = { + 0x0, + 0x0, + 0x0, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfd, + 0x0, + 0x0, + 0x0, + 0x4, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1, + 0x26, + 0x0, + 0x0, + 0x3, + 0xb3, + 0xfc, + 0x2, + 0x0, + 0x0, + 0x0, + 0xe, + 0xfc, + 0x0, + 0x0, + 0x0, + 0x66, + 0x0, + 0x0, + 0x1, + 0xe2, + 0x0, + 0x0, + 0x0, + 0x7a, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfa, + 0x0, + 0x0, + 0x0, + 0x2, + 0x1, + 0x0, + 0x0, + 0x0, + 0x3, + 0xfb, + 0x0, + 0x0, + 0x0, + 0xc, + 0x0, + 0x4c, + 0x0, + 0x65, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x6e, + 0x0, + 0x64, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x14, + 0x0, + 0x4c, + 0x0, + 0x61, + 0x0, + 0x79, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x4f, + 0x0, + 0x72, + 0x0, + 0x64, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0xb8, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0xe, + 0x0, + 0x42, + 0x0, + 0x72, + 0x0, + 0x6f, + 0x0, + 0x77, + 0x0, + 0x73, + 0x0, + 0x65, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x46, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x10, + 0x0, + 0x4f, + 0x0, + 0x76, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x76, + 0x0, + 0x69, + 0x0, + 0x65, + 0x0, + 0x77, + 0x0, + 0x0, + 0x0, + 0x1, + 0xd7, + 0x0, + 0x0, + 0x0, + 0xc4, + 0x0, + 0x0, + 0x0, + 0x15, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x22, + 0x0, + 0x43, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x72, + 0x0, + 0x64, + 0x0, + 0x69, + 0x0, + 0x6e, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x65, + 0x0, + 0x43, + 0x0, + 0x61, + 0x0, + 0x70, + 0x0, + 0x74, + 0x0, + 0x75, + 0x0, + 0x72, + 0x0, + 0x65, + 0x0, + 0x0, + 0x0, + 0x1, + 0x7e, + 0x0, + 0x0, + 0x0, + 0xa0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x8, + 0x0, + 0x55, + 0x0, + 0x6e, + 0x0, + 0x64, + 0x0, + 0x6f, + 0x0, + 0x0, + 0x0, + 0x1, + 0xe4, + 0x0, + 0x0, + 0x0, + 0xdc, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x10, + 0x0, + 0x42, + 0x0, + 0x72, + 0x0, + 0x6f, + 0x0, + 0x77, + 0x0, + 0x73, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x32, + 0x0, + 0x0, + 0x0, + 0x2, + 0x13, + 0x0, + 0x0, + 0x0, + 0xad, + 0x0, + 0x0, + 0x0, + 0x7e, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x47, + 0x0, + 0x50, + 0x0, + 0x53, + 0x0, + 0x49, + 0x0, + 0x6e, + 0x0, + 0x66, + 0x0, + 0x6f, + 0x0, + 0x72, + 0x0, + 0x6d, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x0, + 0x0, + 0x1, + 0xbb, + 0x0, + 0x0, + 0x1, + 0x5, + 0x0, + 0x0, + 0x0, + 0x5f, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x28, + 0x0, + 0x64, + 0x0, + 0x77, + 0x0, + 0x4f, + 0x0, + 0x70, + 0x0, + 0x65, + 0x0, + 0x6e, + 0x0, + 0x6c, + 0x0, + 0x61, + 0x0, + 0x79, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x73, + 0x0, + 0x4f, + 0x0, + 0x76, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x76, + 0x0, + 0x69, + 0x0, + 0x65, + 0x0, + 0x77, + 0x0, + 0x0, + 0x0, + 0x1, + 0x64, + 0x0, + 0x0, + 0x1, + 0x37, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x75, + 0x0, + 0x6e, + 0x0, + 0x64, + 0x0, + 0x6f, + 0x0, + 0x2f, + 0x0, + 0x72, + 0x0, + 0x65, + 0x0, + 0x64, + 0x0, + 0x6f, + 0x0, + 0x20, + 0x0, + 0x64, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0xf1, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x2e, + 0x0, + 0x41, + 0x0, + 0x64, + 0x0, + 0x76, + 0x0, + 0x61, + 0x0, + 0x6e, + 0x0, + 0x63, + 0x0, + 0x65, + 0x0, + 0x64, + 0x0, + 0x44, + 0x0, + 0x69, + 0x0, + 0x67, + 0x0, + 0x69, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x7a, + 0x0, + 0x69, + 0x0, + 0x6e, + 0x0, + 0x67, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x73, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0xf7, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x34, + 0x0, + 0x53, + 0x0, + 0x74, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x73, + 0x0, + 0x74, + 0x0, + 0x61, + 0x0, + 0x6c, + 0x0, + 0x53, + 0x0, + 0x75, + 0x0, + 0x6d, + 0x0, + 0x6d, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x79, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x57, + 0x0, + 0x69, + 0x0, + 0x64, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x74, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x26, + 0x0, + 0x42, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6b, + 0x0, + 0x6d, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x6b, + 0x0, + 0x73, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x57, + 0x0, + 0x69, + 0x0, + 0x64, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x74, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x7a, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0xc, + 0x0, + 0x4c, + 0x0, + 0x61, + 0x0, + 0x79, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x73, + 0x1, + 0x0, + 0x0, + 0x2, + 0x4e, + 0x0, + 0x0, + 0x1, + 0xcb, + 0x0, + 0x0, + 0x0, + 0x7a, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x38, + 0x0, + 0x53, + 0x0, + 0x74, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x73, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x63, + 0x0, + 0x61, + 0x0, + 0x6c, + 0x0, + 0x53, + 0x0, + 0x75, + 0x0, + 0x6d, + 0x0, + 0x6d, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x79, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x57, + 0x0, + 0x69, + 0x0, + 0x64, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x74, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0xcc, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x18, + 0x0, + 0x56, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x74, + 0x0, + 0x65, + 0x0, + 0x78, + 0x0, + 0x45, + 0x0, + 0x64, + 0x0, + 0x69, + 0x0, + 0x74, + 0x0, + 0x6f, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x5f, + 0x0, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x1, + 0x2a, + 0x0, + 0x0, + 0x2, + 0x33, + 0xfc, + 0x2, + 0x0, + 0x0, + 0x0, + 0x6, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x1e, + 0x0, + 0x53, + 0x0, + 0x65, + 0x0, + 0x78, + 0x0, + 0x74, + 0x0, + 0x61, + 0x0, + 0x6e, + 0x0, + 0x74, + 0x0, + 0x65, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x6f, + 0x0, + 0x78, + 0x0, + 0x0, + 0x0, + 0x0, + 0x67, + 0x0, + 0x0, + 0x2, + 0x34, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfc, + 0x0, + 0x0, + 0x0, + 0x64, + 0x0, + 0x0, + 0x2, + 0x33, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfa, + 0xff, + 0xff, + 0xff, + 0xff, + 0x1, + 0x0, + 0x0, + 0x0, + 0x2, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x18, + 0x0, + 0x4c, + 0x0, + 0x61, + 0x0, + 0x79, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x53, + 0x0, + 0x74, + 0x0, + 0x79, + 0x0, + 0x6c, + 0x0, + 0x69, + 0x0, + 0x6e, + 0x0, + 0x67, + 0x0, + 0x0, + 0x0, + 0x3, + 0xd6, + 0x0, + 0x0, + 0x1, + 0x2a, + 0x0, + 0x0, + 0x1, + 0x27, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x22, + 0x0, + 0x50, + 0x0, + 0x72, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x65, + 0x0, + 0x73, + 0x0, + 0x73, + 0x0, + 0x69, + 0x0, + 0x6e, + 0x0, + 0x67, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x6f, + 0x0, + 0x78, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x46, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x14, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x57, + 0x0, + 0x69, + 0x0, + 0x64, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x74, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x10, + 0x0, + 0x44, + 0x0, + 0x65, + 0x0, + 0x76, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x73, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x5f, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x1a, + 0x0, + 0x52, + 0x0, + 0x65, + 0x0, + 0x73, + 0x0, + 0x75, + 0x0, + 0x6c, + 0x0, + 0x74, + 0x0, + 0x73, + 0x0, + 0x56, + 0x0, + 0x69, + 0x0, + 0x65, + 0x0, + 0x77, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x1, + 0x1f, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x20, + 0x0, + 0x74, + 0x0, + 0x68, + 0x0, + 0x65, + 0x0, + 0x54, + 0x0, + 0x69, + 0x0, + 0x6c, + 0x0, + 0x65, + 0x0, + 0x53, + 0x0, + 0x63, + 0x0, + 0x61, + 0x0, + 0x6c, + 0x0, + 0x65, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x7b, + 0x0, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfc, + 0x1, + 0x0, + 0x0, + 0x0, + 0x1, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x26, + 0x0, + 0x54, + 0x0, + 0x65, + 0x0, + 0x6d, + 0x0, + 0x70, + 0x0, + 0x6f, + 0x0, + 0x72, + 0x0, + 0x61, + 0x0, + 0x6c, + 0x0, + 0x20, + 0x0, + 0x43, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x74, + 0x0, + 0x72, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x6c, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x2, + 0xce, + 0x0, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x3, + 0x0, + 0x0, + 0x3, + 0xac, + 0x0, + 0x0, + 0x1, + 0x65, + 0xfc, + 0x1, + 0x0, + 0x0, + 0x0, + 0x3, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x14, + 0x0, + 0x4d, + 0x0, + 0x65, + 0x0, + 0x73, + 0x0, + 0x73, + 0x0, + 0x61, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x4c, + 0x0, + 0x6f, + 0x0, + 0x67, + 0x0, + 0x0, + 0x0, + 0x1, + 0x54, + 0x0, + 0x0, + 0x3, + 0xac, + 0x0, + 0x0, + 0x0, + 0x7f, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x26, + 0x0, + 0x55, + 0x0, + 0x73, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x49, + 0x0, + 0x6e, + 0x0, + 0x70, + 0x0, + 0x75, + 0x0, + 0x74, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x57, + 0x0, + 0x69, + 0x0, + 0x64, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x74, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xc8, + 0x0, + 0x0, + 0x0, + 0x64, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x1a, + 0x0, + 0x50, + 0x0, + 0x79, + 0x0, + 0x74, + 0x0, + 0x68, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x43, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x73, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x65, + 0x1, + 0x0, + 0x0, + 0x1, + 0x4f, + 0x0, + 0x0, + 0x5, + 0xaf, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x5, + 0xb0, + 0x0, + 0x0, + 0x3, + 0xb3, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x0, + 0x2, + 0xfc, + 0x0, + 0x0, + 0x0, + 0xd, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x0, + 0x1a, + 0x0, + 0x6d, + 0x0, + 0x4c, + 0x0, + 0x61, + 0x0, + 0x79, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x2, + 0x0, + 0x0, + 0x0, + 0xc2, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x4, + 0x0, + 0x0, + 0x0, + 0x18, + 0x0, + 0x6d, + 0x0, + 0x46, + 0x0, + 0x69, + 0x0, + 0x6c, + 0x0, + 0x65, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x6d, + 0x0, + 0x4d, + 0x0, + 0x61, + 0x0, + 0x70, + 0x0, + 0x4e, + 0x0, + 0x61, + 0x0, + 0x76, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0xd6, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x22, + 0x0, + 0x6d, + 0x0, + 0x53, + 0x0, + 0x65, + 0x0, + 0x6c, + 0x0, + 0x65, + 0x0, + 0x63, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x2, + 0xf6, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x24, + 0x0, + 0x6d, + 0x0, + 0x41, + 0x0, + 0x74, + 0x0, + 0x74, + 0x0, + 0x72, + 0x0, + 0x69, + 0x0, + 0x62, + 0x0, + 0x75, + 0x0, + 0x74, + 0x0, + 0x65, + 0x0, + 0x73, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x3, + 0xae, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x8, + 0x0, + 0x0, + 0x0, + 0x32, + 0x0, + 0x6d, + 0x0, + 0x44, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x61, + 0x0, + 0x53, + 0x0, + 0x6f, + 0x0, + 0x75, + 0x0, + 0x72, + 0x0, + 0x63, + 0x0, + 0x65, + 0x0, + 0x4d, + 0x0, + 0x61, + 0x0, + 0x6e, + 0x0, + 0x61, + 0x0, + 0x67, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x20, + 0x0, + 0x6d, + 0x0, + 0x44, + 0x0, + 0x69, + 0x0, + 0x67, + 0x0, + 0x69, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x7a, + 0x0, + 0x65, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0xf7, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1a, + 0x0, + 0x6d, + 0x0, + 0x4c, + 0x0, + 0x61, + 0x0, + 0x62, + 0x0, + 0x65, + 0x0, + 0x6c, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x2, + 0xcc, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x20, + 0x0, + 0x6d, + 0x0, + 0x44, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x61, + 0x0, + 0x62, + 0x0, + 0x61, + 0x0, + 0x73, + 0x0, + 0x65, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x2, + 0x6f, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x16, + 0x0, + 0x6d, + 0x0, + 0x57, + 0x0, + 0x65, + 0x0, + 0x62, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x4, + 0x13, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x6d, + 0x0, + 0x50, + 0x0, + 0x6c, + 0x0, + 0x75, + 0x0, + 0x67, + 0x0, + 0x69, + 0x0, + 0x6e, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x4, + 0x44, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x18, + 0x0, + 0x6d, + 0x0, + 0x48, + 0x0, + 0x65, + 0x0, + 0x6c, + 0x0, + 0x70, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x4, + 0x75, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x6d, + 0x0, + 0x56, + 0x0, + 0x65, + 0x0, + 0x63, + 0x0, + 0x74, + 0x0, + 0x6f, + 0x0, + 0x72, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x4, + 0xa6, + 0x0, + 0x0, + 0x2, + 0x29, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x3, + 0x0, + 0x0, + 0x0, + 0x30, + 0x0, + 0x6d, + 0x0, + 0x41, + 0x0, + 0x64, + 0x0, + 0x76, + 0x0, + 0x61, + 0x0, + 0x6e, + 0x0, + 0x63, + 0x0, + 0x65, + 0x0, + 0x64, + 0x0, + 0x44, + 0x0, + 0x69, + 0x0, + 0x67, + 0x0, + 0x69, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x7a, + 0x0, + 0x65, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x6d, + 0x0, + 0x52, + 0x0, + 0x61, + 0x0, + 0x73, + 0x0, + 0x74, + 0x0, + 0x65, + 0x0, + 0x72, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0xb0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x20, + 0x0, + 0x6d, + 0x0, + 0x53, + 0x0, + 0x6e, + 0x0, + 0x61, + 0x0, + 0x70, + 0x0, + 0x70, + 0x0, + 0x69, + 0x0, + 0x6e, + 0x0, + 0x67, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x4, + 0x0, + 0x0, + 0x0, + 0x2a, + 0x0, + 0x6d, + 0x0, + 0x53, + 0x0, + 0x68, + 0x0, + 0x61, + 0x0, + 0x70, + 0x0, + 0x65, + 0x0, + 0x44, + 0x0, + 0x69, + 0x0, + 0x67, + 0x0, + 0x69, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x7a, + 0x0, + 0x65, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x18, + 0x0, + 0x6d, + 0x0, + 0x4d, + 0x0, + 0x65, + 0x0, + 0x73, + 0x0, + 0x68, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0xb8, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x26, + 0x0, + 0x6d, + 0x0, + 0x41, + 0x0, + 0x6e, + 0x0, + 0x6e, + 0x0, + 0x6f, + 0x0, + 0x74, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x73, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0xb8, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x16, + 0x0, + 0x6d, + 0x0, + 0x47, + 0x0, + 0x70, + 0x0, + 0x73, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x42, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x2, + 0x4d, + 0x8, + 0x61, + 0x0, + 0x27, + 0x81, + 0xd7, }; -static const unsigned char defaultLayerDesignerUIgeometry[] = -{ - 0x1, 0xd9, 0xd0, 0xcb, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0x0, 0x0, 0x0, 0x69, - 0x0, 0x0, 0x6, 0xbf, 0x0, 0x0, 0x3, 0xd2, 0x0, 0x0, 0x0, 0xc0, 0x0, 0x0, 0x0, 0x8d, - 0x0, 0x0, 0x6, 0xbf, 0x0, 0x0, 0x3, 0xd2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x7, 0x80, +static const unsigned char defaultLayerDesignerUIgeometry[] = { + 0x1, + 0xd9, + 0xd0, + 0xcb, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xc0, + 0x0, + 0x0, + 0x0, + 0x69, + 0x0, + 0x0, + 0x6, + 0xbf, + 0x0, + 0x0, + 0x3, + 0xd2, + 0x0, + 0x0, + 0x0, + 0xc0, + 0x0, + 0x0, + 0x0, + 0x8d, + 0x0, + 0x0, + 0x6, + 0xbf, + 0x0, + 0x0, + 0x3, + 0xd2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x7, + 0x80, }; -static const unsigned char defaultLayerDesignerUIstate[] = -{ - 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x1, 0xa9, 0x0, 0x0, 0x2, 0xc2, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x1, 0xfb, - 0x0, 0x0, 0x0, 0x14, 0x0, 0x52, 0x0, 0x65, 0x0, 0x70, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x74, - 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x2, - 0xc2, 0x0, 0x0, 0x0, 0x14, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, - 0x86, 0x0, 0x0, 0x2, 0xc2, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x2, 0xfc, 0x0, 0x0, 0x0, 0x65, - 0x0, 0x0, 0x0, 0xdc, 0x0, 0x0, 0x0, 0x78, 0x1, 0x0, 0x0, 0x1d, 0xfa, 0x0, 0x0, 0x0, - 0x0, 0x1, 0x0, 0x0, 0x0, 0x3, 0xfb, 0x0, 0x0, 0x0, 0x12, 0x0, 0x49, 0x0, 0x74, 0x0, - 0x65, 0x0, 0x6d, 0x0, 0x73, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x1, 0x0, 0x0, - 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x46, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, - 0x0, 0x0, 0x10, 0x0, 0x55, 0x0, 0x6e, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x44, 0x0, 0x6f, 0x0, - 0x63, 0x0, 0x6b, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x46, - 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x16, 0x0, 0x43, 0x0, 0x6f, 0x0, 0x6d, 0x0, - 0x6d, 0x0, 0x61, 0x0, 0x6e, 0x0, 0x64, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x1, - 0x0, 0x0, 0x3, 0x99, 0x0, 0x0, 0x1, 0x71, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfc, 0x0, 0x0, 0x1, 0x47, 0x0, 0x0, 0x1, 0xe0, 0x0, 0x0, 0x0, 0x76, 0x1, 0x0, 0x0, - 0x1d, 0xfa, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0x14, - 0x0, 0x4c, 0x0, 0x61, 0x0, 0x79, 0x0, 0x6f, 0x0, 0x75, 0x0, 0x74, 0x0, 0x44, 0x0, 0x6f, - 0x0, 0x63, 0x0, 0x6b, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, - 0x58, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x10, 0x0, 0x49, 0x0, 0x74, 0x0, 0x65, - 0x0, 0x6d, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x58, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x12, - 0x0, 0x47, 0x0, 0x75, 0x0, 0x69, 0x0, 0x64, 0x0, 0x65, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, - 0x0, 0x6b, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x58, 0x0, - 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0x12, 0x0, 0x41, 0x0, 0x74, 0x0, 0x6c, 0x0, 0x61, - 0x0, 0x73, 0x0, 0x44, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, - 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x77, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x4, 0x4c, 0x0, - 0x0, 0x2, 0xc2, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x8, 0x0, - 0x0, 0x0, 0x8, 0xfc, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, - 0x0, 0x0, 0x0, 0x1a, 0x0, 0x6d, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x73, - 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x62, 0x0, 0x61, 0x0, 0x72, 0x3, 0x0, - 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x6d, 0x0, 0x4c, 0x0, - 0x61, 0x0, 0x79, 0x0, 0x6f, 0x0, 0x75, 0x0, 0x74, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, - 0x6c, 0x0, 0x62, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1a, 0x0, 0x6d, 0x0, 0x41, - 0x0, 0x74, 0x0, 0x6c, 0x0, 0x61, 0x0, 0x73, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, 0x6c, - 0x0, 0x62, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x1, 0xd2, 0x0, 0x0, 0x3, 0x38, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x6d, 0x0, 0x52, 0x0, - 0x65, 0x0, 0x70, 0x0, 0x6f, 0x0, 0x72, 0x0, 0x74, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, 0x0, - 0x6c, 0x0, 0x62, 0x0, 0x61, 0x0, 0x72, 0x0, 0x0, 0x0, 0x1, 0x90, 0x0, 0x0, 0x4, 0x70, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x2, - 0x0, 0x0, 0x0, 0x24, 0x0, 0x6d, 0x0, 0x4e, 0x0, 0x61, 0x0, 0x76, 0x0, 0x69, 0x0, 0x67, - 0x0, 0x61, 0x0, 0x74, 0x0, 0x69, 0x0, 0x6f, 0x0, 0x6e, 0x0, 0x54, 0x0, 0x6f, 0x0, 0x6f, - 0x0, 0x6c, 0x0, 0x62, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, - 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x6d, 0x0, - 0x41, 0x0, 0x63, 0x0, 0x74, 0x0, 0x69, 0x0, 0x6f, 0x0, 0x6e, 0x0, 0x73, 0x0, 0x54, 0x0, - 0x6f, 0x0, 0x6f, 0x0, 0x6c, 0x0, 0x62, 0x0, 0x61, 0x0, 0x72, 0x1, 0x0, 0x0, 0x0, 0xb5, - 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +static const unsigned char defaultLayerDesignerUIstate[] = { + 0x0, + 0x0, + 0x0, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfd, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1, + 0xa9, + 0x0, + 0x0, + 0x2, + 0xc2, + 0xfc, + 0x2, + 0x0, + 0x0, + 0x0, + 0x1, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x14, + 0x0, + 0x52, + 0x0, + 0x65, + 0x0, + 0x70, + 0x0, + 0x6f, + 0x0, + 0x72, + 0x0, + 0x74, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x0, + 0x0, + 0x0, + 0x65, + 0x0, + 0x0, + 0x2, + 0xc2, + 0x0, + 0x0, + 0x0, + 0x14, + 0x0, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x1, + 0x86, + 0x0, + 0x0, + 0x2, + 0xc2, + 0xfc, + 0x2, + 0x0, + 0x0, + 0x0, + 0x2, + 0xfc, + 0x0, + 0x0, + 0x0, + 0x65, + 0x0, + 0x0, + 0x0, + 0xdc, + 0x0, + 0x0, + 0x0, + 0x78, + 0x1, + 0x0, + 0x0, + 0x1d, + 0xfa, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x0, + 0x3, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x12, + 0x0, + 0x49, + 0x0, + 0x74, + 0x0, + 0x65, + 0x0, + 0x6d, + 0x0, + 0x73, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x46, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x10, + 0x0, + 0x55, + 0x0, + 0x6e, + 0x0, + 0x64, + 0x0, + 0x6f, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x46, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x16, + 0x0, + 0x43, + 0x0, + 0x6f, + 0x0, + 0x6d, + 0x0, + 0x6d, + 0x0, + 0x61, + 0x0, + 0x6e, + 0x0, + 0x64, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x1, + 0x0, + 0x0, + 0x3, + 0x99, + 0x0, + 0x0, + 0x1, + 0x71, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfc, + 0x0, + 0x0, + 0x1, + 0x47, + 0x0, + 0x0, + 0x1, + 0xe0, + 0x0, + 0x0, + 0x0, + 0x76, + 0x1, + 0x0, + 0x0, + 0x1d, + 0xfa, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x4, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x14, + 0x0, + 0x4c, + 0x0, + 0x61, + 0x0, + 0x79, + 0x0, + 0x6f, + 0x0, + 0x75, + 0x0, + 0x74, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x58, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x10, + 0x0, + 0x49, + 0x0, + 0x74, + 0x0, + 0x65, + 0x0, + 0x6d, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x58, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x12, + 0x0, + 0x47, + 0x0, + 0x75, + 0x0, + 0x69, + 0x0, + 0x64, + 0x0, + 0x65, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x58, + 0x0, + 0xff, + 0xff, + 0xff, + 0xfb, + 0x0, + 0x0, + 0x0, + 0x12, + 0x0, + 0x41, + 0x0, + 0x74, + 0x0, + 0x6c, + 0x0, + 0x61, + 0x0, + 0x73, + 0x0, + 0x44, + 0x0, + 0x6f, + 0x0, + 0x63, + 0x0, + 0x6b, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x77, + 0x0, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x4, + 0x4c, + 0x0, + 0x0, + 0x2, + 0xc2, + 0x0, + 0x0, + 0x0, + 0x4, + 0x0, + 0x0, + 0x0, + 0x4, + 0x0, + 0x0, + 0x0, + 0x8, + 0x0, + 0x0, + 0x0, + 0x8, + 0xfc, + 0x0, + 0x0, + 0x0, + 0x3, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1, + 0x0, + 0x0, + 0x0, + 0x1a, + 0x0, + 0x6d, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x73, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x61, + 0x0, + 0x72, + 0x3, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x3, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x6d, + 0x0, + 0x4c, + 0x0, + 0x61, + 0x0, + 0x79, + 0x0, + 0x6f, + 0x0, + 0x75, + 0x0, + 0x74, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1a, + 0x0, + 0x6d, + 0x0, + 0x41, + 0x0, + 0x74, + 0x0, + 0x6c, + 0x0, + 0x61, + 0x0, + 0x73, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x1, + 0xd2, + 0x0, + 0x0, + 0x3, + 0x38, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1c, + 0x0, + 0x6d, + 0x0, + 0x52, + 0x0, + 0x65, + 0x0, + 0x70, + 0x0, + 0x6f, + 0x0, + 0x72, + 0x0, + 0x74, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x61, + 0x0, + 0x72, + 0x0, + 0x0, + 0x0, + 0x1, + 0x90, + 0x0, + 0x0, + 0x4, + 0x70, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x2, + 0x0, + 0x0, + 0x0, + 0x24, + 0x0, + 0x6d, + 0x0, + 0x4e, + 0x0, + 0x61, + 0x0, + 0x76, + 0x0, + 0x69, + 0x0, + 0x67, + 0x0, + 0x61, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0x0, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1e, + 0x0, + 0x6d, + 0x0, + 0x41, + 0x0, + 0x63, + 0x0, + 0x74, + 0x0, + 0x69, + 0x0, + 0x6f, + 0x0, + 0x6e, + 0x0, + 0x73, + 0x0, + 0x54, + 0x0, + 0x6f, + 0x0, + 0x6f, + 0x0, + 0x6c, + 0x0, + 0x62, + 0x0, + 0x61, + 0x0, + 0x72, + 0x1, + 0x0, + 0x0, + 0x0, + 0xb5, + 0xff, + 0xff, + 0xff, + 0xff, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, }; #endif // UI_DEFAULTS_H diff --git a/src/app/vector/qgsvectorelevationpropertieswidget.cpp b/src/app/vector/qgsvectorelevationpropertieswidget.cpp index fc63612ceb0d..e784ed745c95 100644 --- a/src/app/vector/qgsvectorelevationpropertieswidget.cpp +++ b/src/app/vector/qgsvectorelevationpropertieswidget.cpp @@ -54,37 +54,36 @@ QgsVectorElevationPropertiesWidget::QgsVectorElevationPropertiesWidget( QgsVecto mSurfaceMarkerStyleButton->setSymbolType( Qgis::SymbolType::Marker ); mElevationLimitSpinBox->setClearValue( mElevationLimitSpinBox->minimum(), tr( "Not set" ) ); - mComboClamping->addItem( tr( "Clamped to Terrain" ), static_cast< int >( Qgis::AltitudeClamping::Terrain ) ); - mComboClamping->addItem( tr( "Relative to Terrain" ), static_cast< int >( Qgis::AltitudeClamping::Relative ) ); - mComboClamping->addItem( tr( "Absolute" ), static_cast< int >( Qgis::AltitudeClamping::Absolute ) ); + mComboClamping->addItem( tr( "Clamped to Terrain" ), static_cast( Qgis::AltitudeClamping::Terrain ) ); + mComboClamping->addItem( tr( "Relative to Terrain" ), static_cast( Qgis::AltitudeClamping::Relative ) ); + mComboClamping->addItem( tr( "Absolute" ), static_cast( Qgis::AltitudeClamping::Absolute ) ); - mComboBinding->addItem( tr( "Vertex" ), static_cast< int >( Qgis::AltitudeBinding::Vertex ) ); - mComboBinding->addItem( tr( "Centroid" ), static_cast< int >( Qgis::AltitudeBinding::Centroid ) ); + mComboBinding->addItem( tr( "Vertex" ), static_cast( Qgis::AltitudeBinding::Vertex ) ); + mComboBinding->addItem( tr( "Centroid" ), static_cast( Qgis::AltitudeBinding::Centroid ) ); - mTypeComboBox->addItem( tr( "Individual Features" ), static_cast< int >( Qgis::VectorProfileType::IndividualFeatures ) ); - mTypeComboBox->addItem( tr( "Continuous Surface (e.g. Contours)" ), static_cast< int >( Qgis::VectorProfileType::ContinuousSurface ) ); + mTypeComboBox->addItem( tr( "Individual Features" ), static_cast( Qgis::VectorProfileType::IndividualFeatures ) ); + mTypeComboBox->addItem( tr( "Continuous Surface (e.g. Contours)" ), static_cast( Qgis::VectorProfileType::ContinuousSurface ) ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationLine.svg" ) ), tr( "Line" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::Line ) ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillBelow.svg" ) ), tr( "Fill Below" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::FillBelow ) ); - mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillAbove.svg" ) ), tr( "Fill Above" ), static_cast< int >( Qgis::ProfileSurfaceSymbology::FillAbove ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationLine.svg" ) ), tr( "Line" ), static_cast( Qgis::ProfileSurfaceSymbology::Line ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillBelow.svg" ) ), tr( "Fill Below" ), static_cast( Qgis::ProfileSurfaceSymbology::FillBelow ) ); + mStyleComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconSurfaceElevationFillAbove.svg" ) ), tr( "Fill Above" ), static_cast( Qgis::ProfileSurfaceSymbology::FillAbove ) ); initializeDataDefinedButton( mOffsetDDBtn, QgsMapLayerElevationProperties::Property::ZOffset ); initializeDataDefinedButton( mExtrusionDDBtn, QgsMapLayerElevationProperties::Property::ExtrusionHeight ); syncToLayer( layer ); - connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); - connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); - connect( mElevationLimitSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); - connect( mExtrusionSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); + connect( mOffsetZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); + connect( mScaleZSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); + connect( mElevationLimitSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); + connect( mExtrusionSpinBox, qOverload( &QDoubleSpinBox::valueChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); connect( mExtrusionGroupBox, &QGroupBox::toggled, this, &QgsVectorElevationPropertiesWidget::onChanged ); connect( mComboClamping, qOverload( &QComboBox::currentIndexChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); connect( mComboBinding, qOverload( &QComboBox::currentIndexChanged ), this, &QgsVectorElevationPropertiesWidget::onChanged ); connect( mComboClamping, qOverload( &QComboBox::currentIndexChanged ), this, &QgsVectorElevationPropertiesWidget::clampingChanged ); connect( mComboBinding, qOverload( &QComboBox::currentIndexChanged ), this, &QgsVectorElevationPropertiesWidget::bindingChanged ); - connect( mTypeComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [ = ] - { - switch ( static_cast< Qgis::VectorProfileType >( mTypeComboBox->currentData().toInt() ) ) + connect( mTypeComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=] { + switch ( static_cast( mTypeComboBox->currentData().toInt() ) ) { case Qgis::VectorProfileType::IndividualFeatures: mInterpretationStackedWidget->setCurrentWidget( mPageIndividualFeatures ); @@ -96,9 +95,8 @@ QgsVectorElevationPropertiesWidget::QgsVectorElevationPropertiesWidget( QgsVecto onChanged(); } ); - connect( mStyleComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ] - { - switch ( static_cast< Qgis::ProfileSurfaceSymbology >( mStyleComboBox->currentData().toInt() ) ) + connect( mStyleComboBox, qOverload( &QComboBox::currentIndexChanged ), this, [=] { + switch ( static_cast( mStyleComboBox->currentData().toInt() ) ) { case Qgis::ProfileSurfaceSymbology::Line: mSymbologyStackedWidget->setCurrentWidget( mPageLine ); @@ -130,25 +128,25 @@ QgsVectorElevationPropertiesWidget::QgsVectorElevationPropertiesWidget( QgsVecto void QgsVectorElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) { - mLayer = qobject_cast< QgsVectorLayer * >( layer ); + mLayer = qobject_cast( layer ); if ( !mLayer ) return; if ( !QgsWkbTypes::hasZ( mLayer->wkbType() ) ) { - const int clampingIndex = mComboClamping->findData( static_cast< int >( Qgis::AltitudeClamping::Relative ) ); + const int clampingIndex = mComboClamping->findData( static_cast( Qgis::AltitudeClamping::Relative ) ); if ( clampingIndex >= 0 ) mComboClamping->removeItem( clampingIndex ); } mBlockUpdates = true; - const QgsVectorLayerElevationProperties *props = qgis::down_cast< const QgsVectorLayerElevationProperties * >( mLayer->elevationProperties() ); + const QgsVectorLayerElevationProperties *props = qgis::down_cast( mLayer->elevationProperties() ); - mComboClamping->setCurrentIndex( mComboClamping->findData( static_cast< int >( props->clamping() ) ) ); + mComboClamping->setCurrentIndex( mComboClamping->findData( static_cast( props->clamping() ) ) ); if ( mComboClamping->currentIndex() == -1 ) mComboClamping->setCurrentIndex( 0 ); - mComboBinding->setCurrentIndex( mComboBinding->findData( static_cast< int >( props->binding() ) ) ); + mComboBinding->setCurrentIndex( mComboBinding->findData( static_cast( props->binding() ) ) ); mOffsetZSpinBox->setValue( props->zOffset() ); mScaleZSpinBox->setValue( props->zScale() ); if ( std::isnan( props->elevationLimit() ) ) @@ -157,7 +155,7 @@ void QgsVectorElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) mElevationLimitSpinBox->setValue( props->elevationLimit() ); mExtrusionGroupBox->setChecked( props->extrusionEnabled() ); mExtrusionSpinBox->setValue( props->extrusionHeight() ); - mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( static_cast< int >( props->type() ) ) ); + mTypeComboBox->setCurrentIndex( mTypeComboBox->findData( static_cast( props->type() ) ) ); switch ( props->type() ) { case Qgis::VectorProfileType::IndividualFeatures: @@ -167,7 +165,7 @@ void QgsVectorElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer ) mInterpretationStackedWidget->setCurrentWidget( mPageContinuousSurface ); break; } - mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( static_cast ( props->profileSymbology() ) ) ); + mStyleComboBox->setCurrentIndex( mStyleComboBox->findData( static_cast( props->profileSymbology() ) ) ); switch ( props->profileSymbology() ) { case Qgis::ProfileSurfaceSymbology::Line: @@ -227,35 +225,35 @@ void QgsVectorElevationPropertiesWidget::apply() if ( !mLayer ) return; - QgsVectorLayerElevationProperties *props = qgis::down_cast< QgsVectorLayerElevationProperties * >( mLayer->elevationProperties() ); + QgsVectorLayerElevationProperties *props = qgis::down_cast( mLayer->elevationProperties() ); props->setZOffset( mOffsetZSpinBox->value() ); props->setZScale( mScaleZSpinBox->value() ); - props->setType( static_cast< Qgis::VectorProfileType >( mTypeComboBox->currentData().toInt() ) ); - props->setClamping( static_cast< Qgis::AltitudeClamping >( mComboClamping->currentData().toInt() ) ); - props->setBinding( static_cast< Qgis::AltitudeBinding >( mComboBinding->currentData().toInt() ) ); + props->setType( static_cast( mTypeComboBox->currentData().toInt() ) ); + props->setClamping( static_cast( mComboClamping->currentData().toInt() ) ); + props->setBinding( static_cast( mComboBinding->currentData().toInt() ) ); props->setExtrusionEnabled( mExtrusionGroupBox->isChecked() ); props->setExtrusionHeight( mExtrusionSpinBox->value() ); if ( mElevationLimitSpinBox->value() != mElevationLimitSpinBox->clearValue() ) props->setElevationLimit( mElevationLimitSpinBox->value() ); else - props->setElevationLimit( std::numeric_limits< double >::quiet_NaN() ); + props->setElevationLimit( std::numeric_limits::quiet_NaN() ); props->setRespectLayerSymbology( mCheckRespectLayerSymbology->isChecked() ); props->setShowMarkerSymbolInSurfacePlots( mCheckBoxShowMarkersAtSampledPoints->isChecked() ); - props->setProfileSymbology( static_cast< Qgis::ProfileSurfaceSymbology >( mStyleComboBox->currentData().toInt() ) ); + props->setProfileSymbology( static_cast( mStyleComboBox->currentData().toInt() ) ); switch ( props->type() ) { case Qgis::VectorProfileType::IndividualFeatures: - props->setProfileLineSymbol( mLineStyleButton->clonedSymbol< QgsLineSymbol >() ); - props->setProfileFillSymbol( mFillStyleButton->clonedSymbol< QgsFillSymbol >() ); - props->setProfileMarkerSymbol( mMarkerStyleButton->clonedSymbol< QgsMarkerSymbol >() ); + props->setProfileLineSymbol( mLineStyleButton->clonedSymbol() ); + props->setProfileFillSymbol( mFillStyleButton->clonedSymbol() ); + props->setProfileMarkerSymbol( mMarkerStyleButton->clonedSymbol() ); break; case Qgis::VectorProfileType::ContinuousSurface: - props->setProfileLineSymbol( mSurfaceLineStyleButton->clonedSymbol< QgsLineSymbol >() ); - props->setProfileFillSymbol( mSurfaceFillStyleButton->clonedSymbol< QgsFillSymbol >() ); - props->setProfileMarkerSymbol( mSurfaceMarkerStyleButton->clonedSymbol< QgsMarkerSymbol >() ); + props->setProfileLineSymbol( mSurfaceLineStyleButton->clonedSymbol() ); + props->setProfileFillSymbol( mSurfaceFillStyleButton->clonedSymbol() ); + props->setProfileMarkerSymbol( mSurfaceMarkerStyleButton->clonedSymbol() ); break; } @@ -275,13 +273,11 @@ void QgsVectorElevationPropertiesWidget::clampingChanged() { bool enableScale = true; bool enableBinding = !mLayer || mLayer->geometryType() != Qgis::GeometryType::Point; - switch ( static_cast< Qgis::AltitudeClamping >( mComboClamping->currentData().toInt() ) ) + switch ( static_cast( mComboClamping->currentData().toInt() ) ) { case Qgis::AltitudeClamping::Absolute: mLabelClampingExplanation->setText( - QStringLiteral( "

    %1

    %2

    " ).arg( - tr( "Elevation will be taken directly from features." ), - tr( "Z values from the features will be used for elevation, and the terrain height will be ignored." ) ) + QStringLiteral( "

    %1

    %2

    " ).arg( tr( "Elevation will be taken directly from features." ), tr( "Z values from the features will be used for elevation, and the terrain height will be ignored." ) ) ); enableBinding = false; // not used in absolute mode @@ -297,17 +293,13 @@ void QgsVectorElevationPropertiesWidget::clampingChanged() case Qgis::AltitudeClamping::Relative: mOffsetLabel->setText( tr( "Offset" ) ); mLabelClampingExplanation->setText( - QStringLiteral( "

    %1

    %2

    " ).arg( - tr( "Elevation is relative to terrain height." ), - tr( "Any z values present in the features will be added to the terrain height." ) ) + QStringLiteral( "

    %1

    %2

    " ).arg( tr( "Elevation is relative to terrain height." ), tr( "Any z values present in the features will be added to the terrain height." ) ) ); break; case Qgis::AltitudeClamping::Terrain: mOffsetLabel->setText( tr( "Offset" ) ); mLabelClampingExplanation->setText( - QStringLiteral( "

    %1

    %2

    " ).arg( - tr( "Feature elevation will be taken directly from the terrain height." ), - tr( "Any existing z values present in the features will be ignored." ) ) + QStringLiteral( "

    %1

    %2

    " ).arg( tr( "Feature elevation will be taken directly from the terrain height." ), tr( "Any existing z values present in the features will be ignored." ) ) ); enableScale = false; // not used in terrain mode break; @@ -320,25 +312,18 @@ void QgsVectorElevationPropertiesWidget::clampingChanged() void QgsVectorElevationPropertiesWidget::bindingChanged() { - switch ( static_cast< Qgis::AltitudeBinding >( mComboBinding->currentData().toInt() ) ) + switch ( static_cast( mComboBinding->currentData().toInt() ) ) { case Qgis::AltitudeBinding::Vertex: mLabelBindingExplanation->setText( - QStringLiteral( "

    %1

    %2

    " ).arg( - tr( "Feature elevation is relative to the terrain height at every vertex." ), - tr( "The terrain will be sampled at every individual vertex before being added to the vertex's z value." ) - ) + QStringLiteral( "

    %1

    %2

    " ).arg( tr( "Feature elevation is relative to the terrain height at every vertex." ), tr( "The terrain will be sampled at every individual vertex before being added to the vertex's z value." ) ) ); break; case Qgis::AltitudeBinding::Centroid: mLabelBindingExplanation->setText( - QStringLiteral( "

    %1

    %2

    " ).arg( - tr( "Feature elevation is relative to the terrain height at feature's centroid only." ), - tr( "The terrain will be sampled once at the feature's centroid, with the centroid height being added to each vertex's z value." ) - ) + QStringLiteral( "

    %1

    %2

    " ).arg( tr( "Feature elevation is relative to the terrain height at feature's centroid only." ), tr( "The terrain will be sampled once at the feature's centroid, with the centroid height being added to each vertex's z value." ) ) ); break; - } } @@ -378,7 +363,7 @@ void QgsVectorElevationPropertiesWidget::toggleSymbolWidgets() void QgsVectorElevationPropertiesWidget::updateProperty() { QgsPropertyOverrideButton *button = qobject_cast( sender() ); - QgsMapLayerElevationProperties::Property key = static_cast< QgsMapLayerElevationProperties::Property >( button->propertyKey() ); + QgsMapLayerElevationProperties::Property key = static_cast( button->propertyKey() ); mPropertyCollection.setProperty( key, button->toProperty() ); } @@ -388,33 +373,24 @@ void QgsVectorElevationPropertiesWidget::updateVerticalCrsOptions() { case Qgis::CrsType::Compound: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a compound CRS (%1), so the layer's vertical CRS is the vertical component of this CRS (%2)." ).arg( - mLayer->crs().userFriendlyIdentifier(), - mLayer->verticalCrs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a compound CRS (%1), so the layer's vertical CRS is the vertical component of this CRS (%2)." ).arg( mLayer->crs().userFriendlyIdentifier(), mLayer->verticalCrs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Geographic3d: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geographic 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - mLayer->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geographic 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( mLayer->crs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Geocentric: mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geocentric CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - mLayer->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a geocentric CRS (%1), so the vertical CRS cannot be manually specified." ).arg( mLayer->crs().userFriendlyIdentifier() ) ); break; case Qgis::CrsType::Projected: if ( mLayer->crs().hasVerticalAxis() ) { mVerticalCrsStackedWidget->setCurrentWidget( mCrsPageDisabled ); - mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a projected 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( - mLayer->crs().userFriendlyIdentifier() - ) ); + mCrsDisabledLabel->setText( tr( "Layer coordinate reference system is set to a projected 3D CRS (%1), so the vertical CRS cannot be manually specified." ).arg( mLayer->crs().userFriendlyIdentifier() ) ); break; } [[fallthrough]]; @@ -437,7 +413,7 @@ void QgsVectorElevationPropertiesWidget::updateVerticalCrsOptions() void QgsVectorElevationPropertiesWidget::initializeDataDefinedButton( QgsPropertyOverrideButton *button, QgsMapLayerElevationProperties::Property key ) { button->blockSignals( true ); - button->init( static_cast< int >( key ), mPropertyCollection, QgsMapLayerElevationProperties::propertyDefinitions(), nullptr ); + button->init( static_cast( key ), mPropertyCollection, QgsMapLayerElevationProperties::propertyDefinitions(), nullptr ); connect( button, &QgsPropertyOverrideButton::changed, this, &QgsVectorElevationPropertiesWidget::updateProperty ); button->registerExpressionContextGenerator( this ); button->blockSignals( false ); @@ -445,7 +421,7 @@ void QgsVectorElevationPropertiesWidget::initializeDataDefinedButton( QgsPropert void QgsVectorElevationPropertiesWidget::updateDataDefinedButtons() { - const auto propertyOverrideButtons { findChildren< QgsPropertyOverrideButton * >() }; + const auto propertyOverrideButtons { findChildren() }; for ( QgsPropertyOverrideButton *button : propertyOverrideButtons ) { updateDataDefinedButton( button ); @@ -460,7 +436,7 @@ void QgsVectorElevationPropertiesWidget::updateDataDefinedButton( QgsPropertyOve if ( button->propertyKey() < 0 ) return; - QgsMapLayerElevationProperties::Property key = static_cast< QgsMapLayerElevationProperties::Property >( button->propertyKey() ); + QgsMapLayerElevationProperties::Property key = static_cast( button->propertyKey() ); whileBlocking( button )->setToProperty( mPropertyCollection.property( key ) ); whileBlocking( button )->setVectorLayer( mLayer ); } @@ -479,7 +455,7 @@ QgsVectorElevationPropertiesWidgetFactory::QgsVectorElevationPropertiesWidgetFac QgsMapLayerConfigWidget *QgsVectorElevationPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const { - return new QgsVectorElevationPropertiesWidget( qobject_cast< QgsVectorLayer * >( layer ), canvas, parent ); + return new QgsVectorElevationPropertiesWidget( qobject_cast( layer ), canvas, parent ); } bool QgsVectorElevationPropertiesWidgetFactory::supportLayerPropertiesDialog() const @@ -501,4 +477,3 @@ QString QgsVectorElevationPropertiesWidgetFactory::layerPropertiesPagePositionHi { return QStringLiteral( "mOptsPage_Metadata" ); } - diff --git a/src/app/vector/qgsvectorelevationpropertieswidget.h b/src/app/vector/qgsvectorelevationpropertieswidget.h index 38c6b2853186..63072e33d509 100644 --- a/src/app/vector/qgsvectorelevationpropertieswidget.h +++ b/src/app/vector/qgsvectorelevationpropertieswidget.h @@ -30,7 +30,6 @@ class QgsVectorElevationPropertiesWidget : public QgsMapLayerConfigWidget, priva { Q_OBJECT public: - QgsVectorElevationPropertiesWidget( QgsVectorLayer *layer, QgsMapCanvas *canvas, QWidget *parent ); void syncToLayer( QgsMapLayer *layer ) final; @@ -50,7 +49,6 @@ class QgsVectorElevationPropertiesWidget : public QgsMapLayerConfigWidget, priva void updateVerticalCrsOptions(); private: - // TODO -- consider moving these to a common elevation properties widget base class /** @@ -76,7 +74,6 @@ class QgsVectorElevationPropertiesWidget : public QgsMapLayerConfigWidget, priva QgsVectorLayer *mLayer = nullptr; bool mBlockUpdates = false; - }; @@ -94,5 +91,4 @@ class QgsVectorElevationPropertiesWidgetFactory : public QObject, public QgsMapL }; - #endif // QGSVECTORELEVATIONPROPERTIESWIDGET_H diff --git a/src/app/vertextool/qgslockedfeature.cpp b/src/app/vertextool/qgslockedfeature.cpp index a20fc1e5834a..071a695f08c8 100644 --- a/src/app/vertextool/qgslockedfeature.cpp +++ b/src/app/vertextool/qgslockedfeature.cpp @@ -34,10 +34,7 @@ #include "qgssettingsentryimpl.h" - -QgsLockedFeature::QgsLockedFeature( QgsFeatureId featureId, - QgsVectorLayer *layer, - QgsMapCanvas *canvas ) +QgsLockedFeature::QgsLockedFeature( QgsFeatureId featureId, QgsVectorLayer *layer, QgsMapCanvas *canvas ) : mFeatureId( featureId ) , mLayer( layer ) , mCanvas( canvas ) @@ -231,7 +228,6 @@ QgsGeometry *QgsLockedFeature::geometry() void QgsLockedFeature::createVertexMap() { - if ( !mGeometry ) { QgsDebugMsgLevel( QStringLiteral( "Loading feature" ), 2 ); diff --git a/src/app/vertextool/qgslockedfeature.h b/src/app/vertextool/qgslockedfeature.h index 9e0050bfecf6..9530d5087fce 100644 --- a/src/app/vertextool/qgslockedfeature.h +++ b/src/app/vertextool/qgslockedfeature.h @@ -32,12 +32,11 @@ class QgsVertexEntry; /** * Class that keeps the selected feature */ -class APP_EXPORT QgsLockedFeature: public QObject +class APP_EXPORT QgsLockedFeature : public QObject { Q_OBJECT public: - /** * Creates a locked feature * \param featureId id of feature which was selected @@ -146,7 +145,6 @@ class APP_EXPORT QgsLockedFeature: public QObject void beforeRollBack(); private: - /** * Deletes whole vertex map. */ @@ -177,8 +175,8 @@ class APP_EXPORT QgsLockedFeature: public QObject QgsGeometryValidator *mValidator = nullptr; QString mTip; - QList< QgsGeometry::Error > mGeomErrors; - QList< QgsVertexMarker * > mGeomErrorMarkers; + QList mGeomErrors; + QList mGeomErrorMarkers; }; #endif diff --git a/src/app/vertextool/qgsvertexeditor.cpp b/src/app/vertextool/qgsvertexeditor.cpp index ca53fb014a82..f0aabfcbc04d 100644 --- a/src/app/vertextool/qgsvertexeditor.cpp +++ b/src/app/vertextool/qgsvertexeditor.cpp @@ -54,7 +54,7 @@ QgsVertexEditorModel::QgsVertexEditorModel( QgsMapCanvas *canvas, QObject *paren : QAbstractTableModel( parent ) { Q_UNUSED( canvas ) - QWidget *parentWidget = qobject_cast< QWidget * >( parent ); + QWidget *parentWidget = qobject_cast( parent ); if ( parentWidget ) mWidgetFont = parentWidget->font(); } @@ -100,8 +100,7 @@ int QgsVertexEditorModel::columnCount( const QModelIndex &parent ) const QVariant QgsVertexEditorModel::data( const QModelIndex &index, int role ) const { - if ( !index.isValid() || !mLockedFeature || - ( role != Qt::DisplayRole && role != Qt::EditRole && role != MIN_RADIUS_ROLE && role != Qt::FontRole ) ) + if ( !index.isValid() || !mLockedFeature || ( role != Qt::DisplayRole && role != Qt::EditRole && role != MIN_RADIUS_ROLE && role != Qt::FontRole ) ) return QVariant(); if ( index.row() >= mLockedFeature->vertexMap().count() ) @@ -179,7 +178,6 @@ QVariant QgsVertexEditorModel::data( const QModelIndex &index, int role ) const { return QVariant(); } - } QVariant QgsVertexEditorModel::headerData( int section, Qt::Orientation orientation, int role ) const @@ -341,8 +339,7 @@ QgsVertexEditorWidget::QgsVertexEditorWidget( QgsMapCanvas *canvas ) QVBoxLayout *pageHintLayout = new QVBoxLayout(); mHintLabel = new QLabel(); - mHintLabel->setText( QStringLiteral( "%1\n\n%2" ).arg( tr( "Right click on an editable feature to show its table of vertices." ), - tr( "When a feature is bound to this panel, dragging a rectangle to select vertices on the canvas will only select those of the bound feature." ) ) ); + mHintLabel->setText( QStringLiteral( "%1\n\n%2" ).arg( tr( "Right click on an editable feature to show its table of vertices." ), tr( "When a feature is bound to this panel, dragging a rectangle to select vertices on the canvas will only select those of the bound feature." ) ) ); mHintLabel->setWordWrap( true ); pageHintLayout->addStretch(); @@ -374,8 +371,7 @@ QgsVertexEditorWidget::QgsVertexEditorWidget( QgsMapCanvas *canvas ) QAction *autoPopupAction = new QAction( tr( "Auto-open Table" ), this ); autoPopupAction->setCheckable( true ); autoPopupAction->setChecked( QgsVertexEditor::settingAutoPopupVertexEditorDock->value() ); - connect( autoPopupAction, &QAction::toggled, this, [ = ]( bool checked ) - { + connect( autoPopupAction, &QAction::toggled, this, [=]( bool checked ) { QgsVertexEditor::settingAutoPopupVertexEditorDock->setValue( checked ); } ); mWidgetMenu->addAction( autoPopupAction ); @@ -557,7 +553,6 @@ void QgsVertexEditor::closeEvent( QCloseEvent *event ) CoordinateItemDelegate::CoordinateItemDelegate( const QgsCoordinateReferenceSystem &crs, QObject *parent ) : QStyledItemDelegate( parent ), mCrs( crs ) { - } QString CoordinateItemDelegate::displayText( const QVariant &value, const QLocale & ) const @@ -589,7 +584,7 @@ void CoordinateItemDelegate::setEditorData( QWidget *editor, const QModelIndex & QLineEdit *lineEdit = qobject_cast( editor ); if ( lineEdit && index.isValid() ) { - lineEdit->setText( displayText( index.data( ).toDouble( ), QLocale() ).replace( QLocale().groupSeparator(), QString( ) ) ); + lineEdit->setText( displayText( index.data().toDouble(), QLocale() ).replace( QLocale().groupSeparator(), QString() ) ); } } diff --git a/src/app/vertextool/qgsvertexeditor.h b/src/app/vertextool/qgsvertexeditor.h index 25804806b0a5..6214255ad00d 100644 --- a/src/app/vertextool/qgsvertexeditor.h +++ b/src/app/vertextool/qgsvertexeditor.h @@ -43,8 +43,7 @@ class QgsSettingsEntryBool; class APP_EXPORT QgsVertexEntry { public: - QgsVertexEntry( const QgsPoint &p, - QgsVertexId vertexId ) + QgsVertexEntry( const QgsPoint &p, QgsVertexId vertexId ) : mSelected( false ) , mPoint( p ) , mVertexId( vertexId ) @@ -69,7 +68,6 @@ class APP_EXPORT QgsVertexEditorModel : public QAbstractTableModel { Q_OBJECT public: - QgsVertexEditorModel( QgsMapCanvas *canvas, QObject *parent = nullptr ); void setFeature( QgsLockedFeature *lockedFeature ); @@ -95,14 +93,12 @@ class APP_EXPORT QgsVertexEditorModel : public QAbstractTableModel QFont mWidgetFont; bool calcR( int row, double &r, double &minRadius ) const; - }; class APP_EXPORT QgsVertexEditorWidget : public QgsPanelWidget { Q_OBJECT public: - QgsVertexEditorWidget( QgsMapCanvas *canvas ); void updateEditor( QgsLockedFeature *lockedFeature ); @@ -125,7 +121,6 @@ class APP_EXPORT QgsVertexEditorWidget : public QgsPanelWidget void updateVertexSelection( const QItemSelection &, const QItemSelection &deselected ); private: - QLabel *mHintLabel = nullptr; QStackedWidget *mStackedWidget = nullptr; QWidget *mPageHint = nullptr; @@ -141,7 +136,6 @@ class APP_EXPORT QgsVertexEditor : public QgsDockWidget { Q_OBJECT public: - static const QgsSettingsEntryBool *settingAutoPopupVertexEditorDock; QgsVertexEditor( QgsMapCanvas *canvas ); @@ -156,9 +150,7 @@ class APP_EXPORT QgsVertexEditor : public QgsDockWidget void closeEvent( QCloseEvent *event ) override; private: - QgsVertexEditorWidget *mWidget = nullptr; - }; @@ -167,7 +159,6 @@ class APP_EXPORT CoordinateItemDelegate : public QStyledItemDelegate Q_OBJECT public: - explicit CoordinateItemDelegate( const QgsCoordinateReferenceSystem &crs, QObject *parent = nullptr ); QString displayText( const QVariant &value, const QLocale &locale ) const override; @@ -184,5 +175,4 @@ class APP_EXPORT CoordinateItemDelegate : public QStyledItemDelegate }; - #endif // QGSVERTEXEDITOR_H diff --git a/src/app/vertextool/qgsvertextool.cpp b/src/app/vertextool/qgsvertextool.cpp index 66fe2f6db824..1bd26cf3d381 100644 --- a/src/app/vertextool/qgsvertextool.cpp +++ b/src/app/vertextool/qgsvertextool.cpp @@ -63,7 +63,7 @@ uint qHash( const Vertex &v ) static bool isEndpointAtVertexIndex( const QgsGeometry &geom, int vertexIndex ) { const QgsAbstractGeometry *g = geom.constGet(); - if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve *>( g ) ) + if ( const QgsCurve *curve = qgsgeometry_cast( g ) ) { return vertexIndex == 0 || vertexIndex == curve->numPoints() - 1; } @@ -77,7 +77,7 @@ static bool isEndpointAtVertexIndex( const QgsGeometry &geom, int vertexIndex ) return vertexIndex == 0 || vertexIndex == part->numPoints() - 1; vertexIndex -= part->numPoints(); } - Q_ASSERT( false ); // should not get here + Q_ASSERT( false ); // should not get here return false; } else @@ -233,7 +233,7 @@ class SelectedMatchFilter : public QgsPointLocator::MatchFilter private: double mTolerance; - QgsLockedFeature *mLockedFeature; // not null in case of selected (locked) feature + QgsLockedFeature *mLockedFeature; // not null in case of selected (locked) feature QgsPointLocator::Match mBestSelectedMatch; }; @@ -307,7 +307,7 @@ void QgsVertexTool::activate() { if ( QgisApp::instance() && QgsVertexEditor::settingAutoPopupVertexEditorDock->value() ) { - showVertexEditor(); //#spellok + showVertexEditor(); //#spellok } if ( QgsVertexEditor *editor = vertexEditor() ) @@ -334,7 +334,7 @@ void QgsVertexTool::deactivate() mSnapIndicator->setMatch( QgsPointLocator::Match() ); - QHash< QPair, GeometryValidation>::iterator it = mValidations.begin(); + QHash, GeometryValidation>::iterator it = mValidations.begin(); for ( ; it != mValidations.end(); ++it ) it->cleanup(); mValidations.clear(); @@ -502,7 +502,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) { QgsPointLocator::Match m( *mNewVertexFromDoubleClick ); if ( mLockedFeature && ( mLockedFeature->featureId() != m.featureId() || mLockedFeature->layer() != m.layer() ) ) - return; // when a feature is bound to the vector editor, only process actions on that feature + return; // when a feature is bound to the vector editor, only process actions on that feature mNewVertexFromDoubleClick.reset(); @@ -519,9 +519,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) mouseMoveNotDragging( e ); } } - else if ( mSelectionRubberBand && - ( mSelectionMethod == SelectionNormal || - ( mSelectionMethod == SelectionPolygon && e->button() == Qt::RightButton ) ) ) + else if ( mSelectionRubberBand && ( mSelectionMethod == SelectionNormal || ( mSelectionMethod == SelectionPolygon && e->button() == Qt::RightButton ) ) ) { // only handling of selection rect being dragged QList vertices; @@ -544,7 +542,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) continue; if ( mLockedFeature && mLockedFeature->layer() != vlayer ) - continue; // with locked feature we only allow selection of its vertices + continue; // with locked feature we only allow selection of its vertices QgsGeometry layerRubberBandGeometry = rubberBandGeometry; try @@ -561,7 +559,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgsRenderContext context = QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ); context.setExpressionContext( mCanvas->createExpressionContext() ); context.expressionContext() << QgsExpressionContextUtils::layerScope( vlayer ); - std::unique_ptr< QgsFeatureRenderer > r; + std::unique_ptr r; if ( vlayer->renderer() ) { r.reset( vlayer->renderer()->clone() ); @@ -569,7 +567,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) } QgsRectangle layerRect = layerRubberBandGeometry.boundingBox(); - std::unique_ptr< QgsGeometryEngine > layerRubberBandEngine( QgsGeometry::createGeometryEngine( layerRubberBandGeometry.constGet() ) ); + std::unique_ptr layerRubberBandEngine( QgsGeometry::createGeometryEngine( layerRubberBandGeometry.constGet() ) ); layerRubberBandEngine->prepareGeometry(); QgsFeatureRequest request; @@ -586,7 +584,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) while ( fi.nextFeature( f ) ) { if ( mLockedFeature && mLockedFeature->featureId() != f.id() ) - continue; // with locked feature we only allow selection of its vertices + continue; // with locked feature we only allow selection of its vertices context.expressionContext().setFeature( f ); bool isFeatureInvisible = ( r && !r->willRenderFeature( f, context ) ); @@ -627,7 +625,8 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) QgisApp::instance()->messageBar()->pushMessage( tr( "Invisible vertices were not selected" ), tr( "Vertices belonging to features that are not displayed on the map canvas were not selected." ), - Qgis::MessageLevel::Warning ); + Qgis::MessageLevel::Warning + ); } // here's where we give precedence to vertices of selected features in case there's no bound (locked) feature @@ -658,7 +657,7 @@ void QgsVertexTool::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) mSelectionRubberBand->addPoint( toMapCoordinates( e->pos() ) ); return; } - else // selection rect is not being dragged + else // selection rect is not being dragged { if ( e->button() == Qt::LeftButton && !( e->modifiers() & Qt::ShiftModifier ) && !( e->modifiers() & Qt::ControlModifier ) ) { @@ -781,7 +780,7 @@ void QgsVertexTool::mouseMoveDraggingEdge( QgsMapMouseEvent *e ) mSnapIndicator->setMatch( QgsPointLocator::Match() ); mEdgeCenterMarker->setVisible( false ); - QgsPointXY mapPoint = toMapCoordinates( e->pos() ); // do not use e.mapPoint() as it may be snapped + QgsPointXY mapPoint = toMapCoordinates( e->pos() ); // do not use e.mapPoint() as it may be snapped moveDragBands( mapPoint ); } @@ -823,7 +822,7 @@ QgsPointLocator::Match QgsVertexTool::snapToEditableLayer( QgsMapMouseEvent *e ) QgsSnappingConfig config = oldConfig; config.setEnabled( true ); config.setMode( Qgis::SnappingMode::AdvancedConfiguration ); - config.setIntersectionSnapping( false ); // only snap to layers + config.setIntersectionSnapping( false ); // only snap to layers config.clearIndividualLayerSettings(); typedef QHash SettingsHashMap; @@ -856,7 +855,8 @@ QgsPointLocator::Match QgsVertexTool::snapToEditableLayer( QgsMapMouseEvent *e ) else { layerSettings = QgsSnappingConfig::IndividualLayerSettings( - vlayer == currentVlayer, static_cast( Qgis::SnappingType::Vertex | Qgis::SnappingType::Segment ), tol, Qgis::MapToolUnit::Project, 0.0, 0.0 ); + vlayer == currentVlayer, static_cast( Qgis::SnappingType::Vertex | Qgis::SnappingType::Segment ), tol, Qgis::MapToolUnit::Project, 0.0, 0.0 + ); } config.setIndividualLayerSettings( vlayer, layerSettings ); @@ -1014,9 +1014,9 @@ QgsPointLocator::MatchList QgsVertexTool::findEditableLayerMatches( const QgsPoi } -QSet > QgsVertexTool::findAllEditableFeatures( const QgsPointXY &mapPoint ) +QSet> QgsVertexTool::findAllEditableFeatures( const QgsPointXY &mapPoint ) { - QSet< QPair > alternatives; + QSet> alternatives; // if there is a current layer, it should have priority over other layers // because sometimes there may be match from multiple layers at one location @@ -1055,7 +1055,7 @@ void QgsVertexTool::tryToSelectFeature( QgsMapMouseEvent *e ) { // this is the first right-click on this location so we currently do not have information // about editable features at this mouse location - let's build the alternatives info - QSet< QPair > alternatives = findAllEditableFeatures( toMapCoordinates( e->pos() ) ); + QSet> alternatives = findAllEditableFeatures( toMapCoordinates( e->pos() ) ); if ( !alternatives.isEmpty() ) { QgsPointLocator::Match m = snapToEditableLayer( e ); @@ -1166,7 +1166,7 @@ QgsPointXY QgsVertexTool::positionForEndpointMarker( const QgsPointLocator::Matc double dx = pt1.x() - pt0.x(); double dy = pt1.y() - pt0.y(); double dist = 15 * canvas()->mapSettings().mapUnitsPerPixel(); - double angle = std::atan2( dy, dx ); // to the top: angle=0, to the right: angle=90, to the left: angle=-90 + double angle = std::atan2( dy, dx ); // to the top: angle=0, to the right: angle=90, to the left: angle=-90 double x = pt1.x() + std::cos( angle ) * dist; double y = pt1.y() + std::sin( angle ) * dist; return QgsPointXY( x, y ); @@ -1268,7 +1268,7 @@ void QgsVertexTool::mouseMoveNotDragging( QgsMapMouseEvent *e ) bool isNearCenter = matchEdgeCenterTest( m, mapPoint, &edgeCenter ); mEdgeCenterMarker->setCenter( edgeCenter ); mEdgeCenterMarker->setColor( isNearCenter ? Qt::red : Qt::gray ); - mEdgeCenterMarker->setVisible( !isCircularEdge ); // currently not supported for circular edges + mEdgeCenterMarker->setVisible( !isCircularEdge ); // currently not supported for circular edges mEdgeCenterMarker->update(); mEdgeBand->setVisible( !isNearCenter ); @@ -1316,7 +1316,7 @@ void QgsVertexTool::updateFeatureBand( const QgsPointLocator::Match &m ) if ( m.isValid() && m.layer() ) { if ( mFeatureBandLayer == m.layer() && mFeatureBandFid == m.featureId() ) - return; // skip regeneration of rubber band if not needed + return; // skip regeneration of rubber band if not needed QgsGeometry geom = cachedGeometry( m.layer(), m.featureId() ); mFeatureBandMarkers->setToGeometry( geometryToMultiPoint( geom ), m.layer() ); @@ -1363,7 +1363,7 @@ void QgsVertexTool::keyPressEvent( QKeyEvent *e ) } if ( mDraggingVertex || ( !mDraggingEdge && !mSelectedVertices.isEmpty() ) ) { - e->ignore(); // Override default shortcut management + e->ignore(); // Override default shortcut management deleteVertex(); } break; @@ -1372,7 +1372,7 @@ void QgsVertexTool::keyPressEvent( QKeyEvent *e ) { if ( mDraggingVertex || ( !mDraggingEdge && !mSelectedVertices.isEmpty() ) ) { - e->ignore(); // Override default shortcut management + e->ignore(); // Override default shortcut management toggleVertexCurve(); } break; @@ -1394,7 +1394,7 @@ void QgsVertexTool::keyPressEvent( QKeyEvent *e ) case Qt::Key_Period: { if ( !mDraggingVertex && !mDraggingEdge ) - highlightAdjacentVertex( + 1 ); + highlightAdjacentVertex( +1 ); break; } default: @@ -1511,7 +1511,7 @@ void QgsVertexTool::updateVertexEditor( QgsVectorLayer *layer, QgsFeatureId fid // make sure the vertex editor is alive and visible if ( QgsVertexEditor::settingAutoPopupVertexEditorDock->value() ) - showVertexEditor(); //#spellok + showVertexEditor(); //#spellok if ( QgsVertexEditor *editor = vertexEditor() ) { @@ -1548,7 +1548,7 @@ QgsVertexEditor *QgsVertexTool::vertexEditor() return QgisApp::instance() ? QgisApp::instance()->vertexEditor() : nullptr; } -void QgsVertexTool::showVertexEditor() //#spellok +void QgsVertexTool::showVertexEditor() //#spellok { if ( QgsVertexEditor *editor = vertexEditor() ) editor->setUserVisible( true ); @@ -1686,7 +1686,7 @@ void QgsVertexTool::startDragging( QgsMapMouseEvent *e ) else startDraggingEdge( m, mapPoint ); } - else // vertex + else // vertex { startDraggingMoveVertex( m ); } @@ -1742,7 +1742,7 @@ void QgsVertexTool::buildExtraVertices( const QSet &vertices, const QgsP QgsPointXY anchorPointLayer; if ( v.layer->crs() == anchorLayer->crs() ) anchorPointLayer = anchorPoint; - else // reprojection is necessary: ANCHOR -> MAP -> V + else // reprojection is necessary: ANCHOR -> MAP -> V anchorPointLayer = toLayerCoordinates( v.layer, toMapCoordinates( anchorLayer, anchorPoint ) ); QgsVector offset = pointV - anchorPointLayer; @@ -1763,7 +1763,7 @@ void QgsVertexTool::startDraggingMoveVertex( const QgsPointLocator::Match &m ) mDraggingExtraVertices.clear(); mDraggingExtraVerticesOffset.clear(); - setHighlightedVerticesVisible( false ); // hide any extra highlight of vertices until we are done with moving + setHighlightedVerticesVisible( false ); // hide any extra highlight of vertices until we are done with moving QSet movingVertices; movingVertices << *mDraggingVertex; @@ -1788,7 +1788,7 @@ void QgsVertexTool::startDraggingMoveVertex( const QgsPointLocator::Match &m ) void QgsVertexTool::buildDragBandsForVertices( const QSet &movingVertices, const QgsPointXY &dragVertexMapPoint ) { - QSet verticesInStraightBands; // always the vertex with lower index + QSet verticesInStraightBands; // always the vertex with lower index // set of middle vertices that are already in a circular rubber band // i.e. every circular band is defined by its middle circular vertex @@ -1807,14 +1807,7 @@ void QgsVertexTool::buildDragBandsForVertices( const QSet &movingVertice // the vertex is in the middle of a curved segment if ( !verticesInCircularBands.contains( v ) ) { - addDragCircularBand( v.layer, - geom.vertexAt( v0idx ), - pt, - geom.vertexAt( v1idx ), - movingVertices.contains( Vertex( v.layer, v.fid, v0idx ) ), - true, - movingVertices.contains( Vertex( v.layer, v.fid, v1idx ) ), - dragVertexMapPoint ); + addDragCircularBand( v.layer, geom.vertexAt( v0idx ), pt, geom.vertexAt( v1idx ), movingVertices.contains( Vertex( v.layer, v.fid, v0idx ) ), true, movingVertices.contains( Vertex( v.layer, v.fid, v1idx ) ), dragVertexMapPoint ); verticesInCircularBands << v; } @@ -1832,14 +1825,7 @@ void QgsVertexTool::buildDragBandsForVertices( const QSet &movingVertice // circular segment to the left if ( !verticesInCircularBands.contains( v0 ) ) { - addDragCircularBand( v.layer, - geom.vertexAt( v0idx - 1 ), - geom.vertexAt( v0idx ), - pt, - movingVertices.contains( Vertex( v.layer, v.fid, v0idx - 1 ) ), - movingVertices.contains( Vertex( v.layer, v.fid, v0idx ) ), - true, - dragVertexMapPoint ); + addDragCircularBand( v.layer, geom.vertexAt( v0idx - 1 ), geom.vertexAt( v0idx ), pt, movingVertices.contains( Vertex( v.layer, v.fid, v0idx - 1 ) ), movingVertices.contains( Vertex( v.layer, v.fid, v0idx ) ), true, dragVertexMapPoint ); verticesInCircularBands << v0; } } @@ -1848,12 +1834,7 @@ void QgsVertexTool::buildDragBandsForVertices( const QSet &movingVertice // straight segment to the left if ( !verticesInStraightBands.contains( v0 ) ) { - addDragStraightBand( v.layer, - geom.vertexAt( v0idx ), - pt, - movingVertices.contains( v0 ), - true, - dragVertexMapPoint ); + addDragStraightBand( v.layer, geom.vertexAt( v0idx ), pt, movingVertices.contains( v0 ), true, dragVertexMapPoint ); verticesInStraightBands << v0; } } @@ -1868,14 +1849,7 @@ void QgsVertexTool::buildDragBandsForVertices( const QSet &movingVertice // circular segment to the right if ( !verticesInCircularBands.contains( v1 ) ) { - addDragCircularBand( v.layer, - pt, - geom.vertexAt( v1idx ), - geom.vertexAt( v1idx + 1 ), - true, - movingVertices.contains( v1 ), - movingVertices.contains( Vertex( v.layer, v.fid, v1idx + 1 ) ), - dragVertexMapPoint ); + addDragCircularBand( v.layer, pt, geom.vertexAt( v1idx ), geom.vertexAt( v1idx + 1 ), true, movingVertices.contains( v1 ), movingVertices.contains( Vertex( v.layer, v.fid, v1idx + 1 ) ), dragVertexMapPoint ); verticesInCircularBands << v1; } } @@ -1884,12 +1858,7 @@ void QgsVertexTool::buildDragBandsForVertices( const QSet &movingVertice // straight segment to the right if ( !verticesInStraightBands.contains( v ) ) { - addDragStraightBand( v.layer, - pt, - geom.vertexAt( v1idx ), - true, - movingVertices.contains( v1 ), - dragVertexMapPoint ); + addDragStraightBand( v.layer, pt, geom.vertexAt( v1idx ), true, movingVertices.contains( v1 ), dragVertexMapPoint ); verticesInStraightBands << v; } } @@ -1984,9 +1953,7 @@ void QgsVertexTool::startDraggingAddVertex( const QgsPointLocator::Match &m ) const auto snappedSegments = layerSegmentsSnappedToSegment( vlayer, pt1, pt2 ); for ( const QgsPointLocator::Match &otherMatch : snappedSegments ) { - if ( otherMatch.layer() == m.layer() && - otherMatch.featureId() == m.featureId() && - otherMatch.vertexIndex() == m.vertexIndex() ) + if ( otherMatch.layer() == m.layer() && otherMatch.featureId() == m.featureId() && otherMatch.vertexIndex() == m.vertexIndex() ) continue; // start dragging of snapped point of current layer @@ -2067,14 +2034,14 @@ void QgsVertexTool::stopDragging() { // deactivate advanced digitizing setAdvancedDigitizingAllowed( false ); - cadDockWidget()->clear(); // clear cad points and release locks + cadDockWidget()->clear(); // clear cad points and release locks mDraggingVertex.reset(); mDraggingVertexType = NotDragging; mDraggingEdge = false; clearDragBands(); - setHighlightedVerticesVisible( true ); // highlight can be shown again + setHighlightedVerticesVisible( true ); // highlight can be shown again mSnapIndicator->setMatch( QgsPointLocator::Match() ); } @@ -2192,7 +2159,7 @@ void QgsVertexTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocato // add/move vertex if ( addingVertex ) { - if ( addingAtEndpoint && vid.vertex != 0 ) // appending? + if ( addingAtEndpoint && vid.vertex != 0 ) // appending? vid.vertex++; QgsPoint pt( layerPoint ); @@ -2285,8 +2252,8 @@ void QgsVertexTool::moveVertex( const QgsPointXY &mapPoint, const QgsPointLocato if ( QgsVertexEditor *editor = vertexEditor() ) editor->updateEditor( mLockedFeature.get() ); - setHighlightedVertices( mSelectedVertices ); // update positions of existing highlighted vertices - setHighlightedVerticesVisible( true ); // time to show highlighted vertices again + setHighlightedVertices( mSelectedVertices ); // update positions of existing highlighted vertices + setHighlightedVerticesVisible( true ); // time to show highlighted vertices again // restart startDraggingAddVertexAtEndpoint right after it finishes if ( addingAtEndpoint ) @@ -2320,7 +2287,7 @@ void QgsVertexTool::addExtraVerticesToEdits( QgsVertexTool::VertexEdits &edits, QgsPoint point; if ( dragLayer && topo.layer->crs() == dragLayer->crs() ) - point = layerPoint; // this point may come from exact match so it may be more precise + point = layerPoint; // this point may come from exact match so it may be more precise else point = QgsPoint( toLayerCoordinates( topo.layer, mapPoint ) ); @@ -2357,7 +2324,7 @@ void QgsVertexTool::addExtraSegmentsToEdits( QgsVertexTool::VertexEdits &edits, QgsPointXY point; if ( dragLayer && topo.layer->crs() == dragLayer->crs() ) - point = layerPoint; // this point may come from exact match so it may be more precise + point = layerPoint; // this point may come from exact match so it may be more precise else point = QgsPoint( toLayerCoordinates( topo.layer, mapPoint ) ); @@ -2381,10 +2348,10 @@ void QgsVertexTool::addExtraSegmentsToEdits( QgsVertexTool::VertexEdits &edits, void QgsVertexTool::applyEditsToLayers( QgsVertexTool::VertexEdits &edits ) { // when avoiding intersection, ignore current modified features - QHash > ignoreFeatures; + QHash> ignoreFeatures; if ( QgsProject::instance()->avoidIntersectionsMode() != Qgis::AvoidIntersectionsMode::AllowIntersections ) { - for ( auto itLayerEdits = edits.begin() ; itLayerEdits != edits.end(); ++itLayerEdits ) + for ( auto itLayerEdits = edits.begin(); itLayerEdits != edits.end(); ++itLayerEdits ) { QgsVectorLayer *layer = itLayerEdits.key(); const QList ids = itLayerEdits->keys(); @@ -2392,14 +2359,14 @@ void QgsVertexTool::applyEditsToLayers( QgsVertexTool::VertexEdits &edits ) } } - for ( auto itLayerEdits = edits.begin() ; itLayerEdits != edits.end(); ++itLayerEdits ) + for ( auto itLayerEdits = edits.begin(); itLayerEdits != edits.end(); ++itLayerEdits ) { QgsVectorLayer *layer = itLayerEdits.key(); layer->beginEditCommand( tr( "Moved vertex" ) ); QgsAvoidIntersectionsOperation avoidIntersections; connect( &avoidIntersections, &QgsAvoidIntersectionsOperation::messageEmitted, this, &QgsMapTool::messageEmitted ); - for ( auto itFeatEdit = itLayerEdits->begin() ; itFeatEdit != itLayerEdits->end(); ++itFeatEdit ) + for ( auto itFeatEdit = itLayerEdits->begin(); itFeatEdit != itLayerEdits->end(); ++itFeatEdit ) { const QgsAvoidIntersectionsOperation::Result res = avoidIntersections.apply( layer, itFeatEdit.key(), itFeatEdit->geom, ignoreFeatures ); if ( res.geometryHasChanged ) @@ -2436,7 +2403,7 @@ void QgsVertexTool::deleteVertex() if ( addingVertex ) { stopDragging(); - return; // just cancel the vertex + return; // just cancel the vertex } } @@ -2466,7 +2433,7 @@ void QgsVertexTool::deleteVertex() } // switch from a plain list to dictionary { layer: { fid: [vertexNr1, vertexNr2, ...] } } - QHash > > toDeleteGrouped; + QHash>> toDeleteGrouped; for ( const Vertex &vertex : std::as_const( toDelete ) ) { toDeleteGrouped[vertex.layer][vertex.fid].append( vertex.vertexId ); @@ -2475,28 +2442,27 @@ void QgsVertexTool::deleteVertex() // de-duplicate vertices in linear rings - if there is the first vertex selected, // then also the last vertex will be selected - but we want just one out of the pair // also deselect vertices of parts or rings that will be automatically removed - QHash > >::iterator lIt = toDeleteGrouped.begin(); + QHash>>::iterator lIt = toDeleteGrouped.begin(); for ( ; lIt != toDeleteGrouped.end(); ++lIt ) { QgsVectorLayer *layer = lIt.key(); - QHash > &featuresDict = lIt.value(); + QHash> &featuresDict = lIt.value(); - QHash >::iterator fIt = featuresDict.begin(); + QHash>::iterator fIt = featuresDict.begin(); for ( ; fIt != featuresDict.end(); ++fIt ) { QgsFeatureId fid = fIt.key(); QList &vertexIds = fIt.value(); - if ( vertexIds.count() >= 2 && ( layer->geometryType() == Qgis::GeometryType::Polygon || - layer->geometryType() == Qgis::GeometryType::Line ) ) + if ( vertexIds.count() >= 2 && ( layer->geometryType() == Qgis::GeometryType::Polygon || layer->geometryType() == Qgis::GeometryType::Line ) ) { std::sort( vertexIds.begin(), vertexIds.end(), std::greater() ); const QgsGeometry geom = cachedGeometry( layer, fid ); const QgsAbstractGeometry *ag = geom.constGet(); QVector> numberOfVertices; - for ( int p = 0 ; p < ag->partCount() ; ++p ) + for ( int p = 0; p < ag->partCount(); ++p ) { numberOfVertices.append( QVector() ); - for ( int r = 0 ; r < ag->ringCount( p ) ; ++r ) + for ( int r = 0; r < ag->ringCount( p ); ++r ) { numberOfVertices[p].append( ag->vertexCount( p, r ) ); } @@ -2505,14 +2471,13 @@ void QgsVertexTool::deleteVertex() // linear parts with less than 2 vertices get deleted automatically // let's keep that number and don't remove vertices beyond that point const int minAllowedVertices = geom.type() == Qgis::GeometryType::Polygon ? 4 : 2; - for ( int i = vertexIds.count() - 1; i >= 0 ; --i ) + for ( int i = vertexIds.count() - 1; i >= 0; --i ) { QgsVertexId vid; if ( geom.vertexIdFromVertexNr( vertexIds[i], vid ) ) { // also don't try to delete the first vertex of a ring since we have already deleted the last - if ( numberOfVertices.at( vid.part ).at( vid.ring ) < minAllowedVertices || - ( 0 == vid.vertex && geom.type() == Qgis::GeometryType::Polygon ) ) + if ( numberOfVertices.at( vid.part ).at( vid.ring ) < minAllowedVertices || ( 0 == vid.vertex && geom.type() == Qgis::GeometryType::Polygon ) ) vertexIds.removeOne( vertexIds.at( i ) ); else --numberOfVertices[vid.part][vid.ring]; @@ -2523,16 +2488,16 @@ void QgsVertexTool::deleteVertex() } // main for cycle to delete all selected vertices - QHash > >::iterator it = toDeleteGrouped.begin(); + QHash>>::iterator it = toDeleteGrouped.begin(); for ( ; it != toDeleteGrouped.end(); ++it ) { QgsVectorLayer *layer = it.key(); - QHash > &featuresDict = it.value(); + QHash> &featuresDict = it.value(); layer->beginEditCommand( tr( "Deleted vertex" ) ); bool success = true; - QHash >::iterator it2 = featuresDict.begin(); + QHash>::iterator it2 = featuresDict.begin(); for ( ; it2 != featuresDict.end(); ++it2 ) { QgsFeatureId fid = it2.key(); @@ -2596,7 +2561,6 @@ void QgsVertexTool::deleteVertex() void QgsVertexTool::toggleVertexCurve() { - Vertex toConvert = Vertex( nullptr, -1, -1 ); if ( mSelectedVertices.size() == 1 ) { @@ -2612,7 +2576,8 @@ void QgsVertexTool::toggleVertexCurve() QgisApp::instance()->messageBar()->pushMessage( tr( "Could not convert vertex" ), tr( "Conversion can only be done on exactly one vertex." ), - Qgis::Info ); + Qgis::Info + ); return; } @@ -2623,7 +2588,8 @@ void QgsVertexTool::toggleVertexCurve() QgisApp::instance()->messageBar()->pushMessage( tr( "Could not convert vertex" ), tr( "Cannot convert vertex before it is added." ), - Qgis::Warning ); + Qgis::Warning + ); return; } stopDragging(); @@ -2631,12 +2597,13 @@ void QgsVertexTool::toggleVertexCurve() QgsVectorLayer *layer = toConvert.layer; - if ( ! QgsWkbTypes::isCurvedType( layer->wkbType() ) ) + if ( !QgsWkbTypes::isCurvedType( layer->wkbType() ) ) { QgisApp::instance()->messageBar()->pushMessage( tr( "Could not convert vertex" ), tr( "Layer of type %1 does not support curved geometries." ).arg( QgsWkbTypes::displayString( layer->wkbType() ) ), - Qgis::Warning ); + Qgis::Warning + ); return; } @@ -2658,7 +2625,8 @@ void QgsVertexTool::toggleVertexCurve() QgisApp::instance()->messageBar()->pushMessage( tr( "Could not convert vertex" ), tr( "Start/end of vertices of features and arcs can not be converted." ), - Qgis::Warning ); + Qgis::Warning + ); } QgsVertexEditor *editor = vertexEditor(); @@ -2687,12 +2655,11 @@ void QgsVertexTool::setHighlightedVertices( const QList &listVertices, H mSelectedVerticesMarkers.clear(); } - auto createMarkerForVertex = [ = ]( const Vertex & vertex )->bool - { + auto createMarkerForVertex = [=]( const Vertex &vertex ) -> bool { QgsGeometry geom = cachedGeometryForVertex( vertex ); QgsVertexId vid; if ( !geom.vertexIdFromVertexNr( vertex.vertexId, vid ) ) - return false; // vertex may not exist anymore + return false; // vertex may not exist anymore QgsVertexMarker *marker = new QgsVertexMarker( canvas() ); marker->setIconType( QgsVertexMarker::ICON_CIRCLE ); @@ -2718,7 +2685,7 @@ void QgsVertexTool::setHighlightedVertices( const QList &listVertices, H } if ( !createMarkerForVertex( vertex ) ) - continue; // vertex may not exist anymore + continue; // vertex may not exist anymore mSelectedVertices.append( vertex ); } @@ -2760,7 +2727,7 @@ void QgsVertexTool::highlightAdjacentVertex( double offset ) if ( mSelectedVertices.isEmpty() ) return; - Vertex vertex = mSelectedVertices[0]; // simply use the first one + Vertex vertex = mSelectedVertices[0]; // simply use the first one QgsGeometry geom = cachedGeometryForVertex( vertex ); @@ -2778,7 +2745,7 @@ void QgsVertexTool::highlightAdjacentVertex( double offset ) if ( pt != QgsPointXY() ) vertex = Vertex( vertex.layer, vertex.fid, newVertexId ); setHighlightedVertices( QList() << vertex ); - zoomToVertex( vertex ); // make sure the vertex is visible + zoomToVertex( vertex ); // make sure the vertex is visible } void QgsVertexTool::initSelectionRubberBand() @@ -2828,7 +2795,7 @@ bool QgsVertexTool::matchEdgeCenterTest( const QgsPointLocator::Match &m, const QgsGeometry geom = cachedGeometry( m.layer(), m.featureId() ); if ( isCircularVertex( geom, m.vertexIndex() ) || isCircularVertex( geom, m.vertexIndex() + 1 ) ) - return false; // currently not supported for circular edges + return false; // currently not supported for circular edges QgsRectangle visible_extent = canvas()->mapSettings().visibleExtent(); if ( !visible_extent.contains( p0 ) || !visible_extent.contains( p1 ) ) @@ -2877,7 +2844,7 @@ void QgsVertexTool::validationErrorFound( const QgsGeometry::Error &e ) if ( !validator ) return; - QHash< QPair, GeometryValidation>::iterator it = mValidations.begin(); + QHash, GeometryValidation>::iterator it = mValidations.begin(); for ( ; it != mValidations.end(); ++it ) { GeometryValidation &validation = *it; @@ -2895,7 +2862,7 @@ void QgsVertexTool::validationFinished() if ( !validator ) return; - QHash< QPair, GeometryValidation>::iterator it = mValidations.begin(); + QHash, GeometryValidation>::iterator it = mValidations.begin(); for ( ; it != mValidations.end(); ++it ) { GeometryValidation &validation = *it; @@ -3013,14 +2980,12 @@ QList QgsVertexTool::verticesInRange( QgsVectorLayer *layer, QgsFeatureI // check whether we are in a linear ring int vertexIdTmp = vertexId0 - 1; QgsVertexId vidTmp; - while ( geom.vertexIdFromVertexNr( vertexIdTmp, vidTmp ) && - vidTmp.part == vid0.part && vidTmp.ring == vid0.ring ) + while ( geom.vertexIdFromVertexNr( vertexIdTmp, vidTmp ) && vidTmp.part == vid0.part && vidTmp.ring == vid0.ring ) --vertexIdTmp; int startVertexIndex = vertexIdTmp + 1; vertexIdTmp = vertexId1 + 1; - while ( geom.vertexIdFromVertexNr( vertexIdTmp, vidTmp ) && - vidTmp.part == vid0.part && vidTmp.ring == vid0.ring ) + while ( geom.vertexIdFromVertexNr( vertexIdTmp, vidTmp ) && vidTmp.part == vid0.part && vidTmp.ring == vid0.ring ) ++vertexIdTmp; int endVertexIndex = vertexIdTmp - 1; @@ -3109,7 +3074,7 @@ void QgsVertexTool::rangeMethodReleaseEvent( QgsMapMouseEvent *e ) void QgsVertexTool::rangeMethodMoveEvent( QgsMapMouseEvent *e ) { if ( e->buttons() ) - return; // only with no buttons pressed + return; // only with no buttons pressed QgsPointLocator::Match m = snapToEditableLayer( e ); diff --git a/src/app/vertextool/qgsvertextool.h b/src/app/vertextool/qgsvertextool.h index a5cced08a75f..e87998729a8a 100644 --- a/src/app/vertextool/qgsvertextool.h +++ b/src/app/vertextool/qgsvertextool.h @@ -37,36 +37,34 @@ class QgsVertexMarker; //! helper structure for a vertex being dragged struct Vertex { - Vertex( QgsVectorLayer *layer, QgsFeatureId fid, int vertexId ) - : layer( layer ) - , fid( fid ) - , vertexId( vertexId ) {} - - // TODO c++20 - replace with = default - bool operator==( const Vertex &other ) const - { - return layer == other.layer && fid == other.fid && vertexId == other.vertexId; - } - bool operator!=( const Vertex &other ) const - { - return !operator==( other ); - } - - QgsVectorLayer *layer = nullptr; - QgsFeatureId fid; - int vertexId; + Vertex( QgsVectorLayer *layer, QgsFeatureId fid, int vertexId ) + : layer( layer ) + , fid( fid ) + , vertexId( vertexId ) {} + + // TODO c++20 - replace with = default + bool operator==( const Vertex &other ) const + { + return layer == other.layer && fid == other.fid && vertexId == other.vertexId; + } + bool operator!=( const Vertex &other ) const + { + return !operator==( other ); + } + + QgsVectorLayer *layer = nullptr; + QgsFeatureId fid; + int vertexId; }; //! qHash implementation - we use Vertex in QSet uint qHash( const Vertex &v ); - class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing { Q_OBJECT public: - enum VertexToolMode { ActiveLayer, @@ -100,7 +98,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing QgsGeometry cachedGeometry( const QgsVectorLayer *layer, QgsFeatureId fid ); //! Toggle the vertex editor - void showVertexEditor(); //#spellok + void showVertexEditor(); //#spellok //! Update vertex editor to show feature from the given match void updateVertexEditor( QgsVectorLayer *layer, QgsFeatureId fid ); @@ -128,7 +126,6 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing void currentLayerChanged( QgsMapLayer *layer ); private: - void buildDragBandsForVertices( const QSet &movingVertices, const QgsPointXY &dragVertexMapPoint ); void addDragBand( const QgsPointXY &v1, const QgsPointXY &v2 ); @@ -176,7 +173,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing * The set does not contain only the closest match from each layer, but all matches in the standard * vertex search tolerance. It also includes area matches. */ - QSet > findAllEditableFeatures( const QgsPointXY &mapPoint ); + QSet> findAllEditableFeatures( const QgsPointXY &mapPoint ); /** * Implements behavior for mouse right-click to select a feature for editing (and in case of multiple @@ -226,19 +223,19 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing struct VertexEdit { - VertexEdit() {} + VertexEdit() {} - VertexEdit( QgsGeometry lgeom, QgsPoint point ) - : geom( lgeom ) - { - newPoints << point; - } + VertexEdit( QgsGeometry lgeom, QgsPoint point ) + : geom( lgeom ) + { + newPoints << point; + } - QgsGeometry geom; - QList newPoints; // new points (added or moved) + QgsGeometry geom; + QList newPoints; // new points (added or moved) }; - typedef QHash > VertexEdits; + typedef QHash> VertexEdits; void addExtraVerticesToEdits( VertexEdits &edits, const QgsPointXY &mapPoint, QgsVectorLayer *dragLayer = nullptr, const QgsPoint &layerPoint = QgsPoint() ); @@ -263,8 +260,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing enum HighlightMode { - ModeReset, //!< Reset any current selection - ModeAdd, //!< Add to current selection + ModeReset, //!< Reset any current selection + ModeAdd, //!< Add to current selection ModeSubtract, //!< Remove from current selection }; @@ -316,7 +313,6 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing void updateLockedFeatureVertices(); private: - QgsVertexEditor *vertexEditor(); // members used for temporary highlight of stuff @@ -369,22 +365,22 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing //! structure to keep information about a rubber band used for dragging of a straight line segment struct StraightBand { - QgsRubberBand *band = nullptr; //!< Pointer to the actual rubber band - QgsPointXY p0, p1; //!< What are the original positions of points (in map units) - bool moving0, moving1; //!< Which points of the band are moving with mouse cursor - QgsVector offset0, offset1; //!< If the point is moving, what is the offset from the mouse cursor + QgsRubberBand *band = nullptr; //!< Pointer to the actual rubber band + QgsPointXY p0, p1; //!< What are the original positions of points (in map units) + bool moving0, moving1; //!< Which points of the band are moving with mouse cursor + QgsVector offset0, offset1; //!< If the point is moving, what is the offset from the mouse cursor }; //! structure to keep information about a rubber band used for dragging of a circular segment struct CircularBand { - QgsRubberBand *band = nullptr; //!< Pointer to the actual rubber band - QgsPointXY p0, p1, p2; //!< What are the original positions of points (in map units) - bool moving0, moving1, moving2; //!< Which points of the band are moving with mouse cursor - QgsVector offset0, offset1, offset2; //!< If the point is moving, what is the offset from the mouse cursor + QgsRubberBand *band = nullptr; //!< Pointer to the actual rubber band + QgsPointXY p0, p1, p2; //!< What are the original positions of points (in map units) + bool moving0, moving1, moving2; //!< Which points of the band are moving with mouse cursor + QgsVector offset0, offset1, offset2; //!< If the point is moving, what is the offset from the mouse cursor - //! update geometry of the rubber band band on the current mouse cursor position (in map units) - void updateRubberBand( const QgsPointXY &mapPoint ); + //! update geometry of the rubber band band on the current mouse cursor position (in map units) + void updateRubberBand( const QgsPointXY &mapPoint ); }; //! list of active straight line rubber bands @@ -458,7 +454,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing std::unique_ptr mNewVertexFromDoubleClick; //! Geometry cache for fast access to geometries (coordinates are in their layer's CRS) - QHash > mCache; + QHash> mCache; // support for vertex editor @@ -472,9 +468,9 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing */ struct LockedFeatureAlternatives { - QPoint screenPoint; - QList< QPair > alternatives; - int index = -1; + QPoint screenPoint; + QList> alternatives; + int index = -1; }; //! Keeps information about other possible features to select with right click. Null if no info is currently held. @@ -485,26 +481,26 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing //! data structure for validation of one geometry of a vector layer struct GeometryValidation { - QgsVertexTool *tool = nullptr; //!< Pointer to the parent vertex tool (for connections / canvas) - QgsVectorLayer *layer = nullptr; //!< Pointer to the layer of the validated geometry (for reporojection) - QgsGeometryValidator *validator = nullptr; //!< Object that does validation. Non-null if active - QList errorMarkers; //!< Markers created by validation - QString errors; //!< Full error text from validation - - void start( QgsGeometry &geom, QgsVertexTool *tool, QgsVectorLayer *l ); //!< Start validation - void addError( QgsGeometry::Error e ); //!< Add another error to the validation - void cleanup(); //!< Delete everything + QgsVertexTool *tool = nullptr; //!< Pointer to the parent vertex tool (for connections / canvas) + QgsVectorLayer *layer = nullptr; //!< Pointer to the layer of the validated geometry (for reporojection) + QgsGeometryValidator *validator = nullptr; //!< Object that does validation. Non-null if active + QList errorMarkers; //!< Markers created by validation + QString errors; //!< Full error text from validation + + void start( QgsGeometry &geom, QgsVertexTool *tool, QgsVectorLayer *l ); //!< Start validation + void addError( QgsGeometry::Error e ); //!< Add another error to the validation + void cleanup(); //!< Delete everything }; //! data structure to keep validation details - QHash< QPair, GeometryValidation> mValidations; + QHash, GeometryValidation> mValidations; //! Enumeration of methods for selection of vertices enum VertexSelectionMethod { - SelectionNormal, //!< Default selection: clicking vertex starts move, ctrl+click selects vertex, dragging rectangle select multiple vertices - SelectionRange, //!< Range selection: clicking selects start vertex, next click select final vertex, vertices in the range get selected - SelectionPolygon, //!< Polygon selection: alt+click starts digitizing a polygon, subsequent clicks add vertices, right click selects vertices within the polygon + SelectionNormal, //!< Default selection: clicking vertex starts move, ctrl+click selects vertex, dragging rectangle select multiple vertices + SelectionRange, //!< Range selection: clicking selects start vertex, next click select final vertex, vertices in the range get selected + SelectionPolygon, //!< Polygon selection: alt+click starts digitizing a polygon, subsequent clicks add vertices, right click selects vertices within the polygon }; //! Current vertex selection method diff --git a/src/auth/apiheader/core/qgsauthapiheadermethod.cpp b/src/auth/apiheader/core/qgsauthapiheadermethod.cpp index 83758dbca67f..4b552825a804 100644 --- a/src/auth/apiheader/core/qgsauthapiheadermethod.cpp +++ b/src/auth/apiheader/core/qgsauthapiheadermethod.cpp @@ -41,11 +41,8 @@ QgsAuthApiHeaderMethod::QgsAuthApiHeaderMethod() { setVersion( 2 ); setExpansions( QgsAuthMethod::NetworkRequest ); - setDataProviders( QStringList() - << QStringLiteral( "ows" ) - << QStringLiteral( "wfs" ) // convert to lowercase - << QStringLiteral( "wcs" ) - << QStringLiteral( "wms" ) ); + setDataProviders( QStringList() << QStringLiteral( "ows" ) << QStringLiteral( "wfs" ) // convert to lowercase + << QStringLiteral( "wcs" ) << QStringLiteral( "wms" ) ); } QString QgsAuthApiHeaderMethod::key() const @@ -63,8 +60,7 @@ QString QgsAuthApiHeaderMethod::displayDescription() const return AUTH_METHOD_DISPLAY_DESCRIPTION; } -bool QgsAuthApiHeaderMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthApiHeaderMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( dataprovider ) const QgsAuthMethodConfig config = getMethodConfig( authcfg ); @@ -86,8 +82,7 @@ bool QgsAuthApiHeaderMethod::updateNetworkRequest( QNetworkRequest &request, con if ( !headerKey.isEmpty() ) { - request.setRawHeader( QStringLiteral( "%1" ).arg( headerKey ).toLocal8Bit(), - QStringLiteral( "%1" ).arg( headerValue ).toLocal8Bit() ); + request.setRawHeader( QStringLiteral( "%1" ).arg( headerKey ).toLocal8Bit(), QStringLiteral( "%1" ).arg( headerValue ).toLocal8Bit() ); } else { diff --git a/src/auth/apiheader/core/qgsauthapiheadermethod.h b/src/auth/apiheader/core/qgsauthapiheadermethod.h index 3126779e91fa..b8d11887e54e 100644 --- a/src/auth/apiheader/core/qgsauthapiheadermethod.h +++ b/src/auth/apiheader/core/qgsauthapiheadermethod.h @@ -30,7 +30,6 @@ class QgsAuthApiHeaderMethod : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -44,14 +43,13 @@ class QgsAuthApiHeaderMethod : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &config ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: @@ -62,7 +60,6 @@ class QgsAuthApiHeaderMethod : public QgsAuthMethod void removeMethodConfig( const QString &authcfg ); static QMap sAuthConfigCache; - }; @@ -72,7 +69,7 @@ class QgsAuthApiHeaderMethodMetadata : public QgsAuthMethodMetadata QgsAuthApiHeaderMethodMetadata() : QgsAuthMethodMetadata( QgsAuthApiHeaderMethod::AUTH_METHOD_KEY, QgsAuthApiHeaderMethod::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthApiHeaderMethod *createAuthMethod() const override {return new QgsAuthApiHeaderMethod;} + QgsAuthApiHeaderMethod *createAuthMethod() const override { return new QgsAuthApiHeaderMethod; } //QStringList supportedDataProviders() const override; }; diff --git a/src/auth/apiheader/gui/qgsauthapiheaderedit.cpp b/src/auth/apiheader/gui/qgsauthapiheaderedit.cpp index 4a2dfbefaa77..0a2b62794364 100644 --- a/src/auth/apiheader/gui/qgsauthapiheaderedit.cpp +++ b/src/auth/apiheader/gui/qgsauthapiheaderedit.cpp @@ -93,7 +93,7 @@ void QgsAuthApiHeaderEdit::removeHeaderPair() void QgsAuthApiHeaderEdit::clearHeaderPairs() { - for ( int i = tblwdgHeaderPairs->rowCount(); i > 0 ; --i ) + for ( int i = tblwdgHeaderPairs->rowCount(); i > 0; --i ) { tblwdgHeaderPairs->removeRow( i - 1 ); } diff --git a/src/auth/awss3/core/qgsauthawss3method.cpp b/src/auth/awss3/core/qgsauthawss3method.cpp index 2bfdc0394d94..da2e5255f786 100644 --- a/src/auth/awss3/core/qgsauthawss3method.cpp +++ b/src/auth/awss3/core/qgsauthawss3method.cpp @@ -59,8 +59,7 @@ QString QgsAuthAwsS3Method::displayDescription() const return AUTH_METHOD_DISPLAY_DESCRIPTION; } -bool QgsAuthAwsS3Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthAwsS3Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( dataprovider ) const QgsAuthMethodConfig config = getMethodConfig( authcfg ); @@ -80,7 +79,7 @@ bool QgsAuthAwsS3Method::updateNetworkRequest( QNetworkRequest &request, const Q const QByteArray date = currentDateTime.toString( "yyyyMMdd" ).toUtf8(); const QByteArray dateTime = currentDateTime.toString( "yyyyMMddThhmmssZ" ).toUtf8(); - QByteArray canonicalPath = QUrl::toPercentEncoding( request.url().path(), "/" ); // Don't encode slash + QByteArray canonicalPath = QUrl::toPercentEncoding( request.url().path(), "/" ); // Don't encode slash if ( canonicalPath.isEmpty() ) { canonicalPath = "/"; @@ -96,39 +95,21 @@ bool QgsAuthAwsS3Method::updateNetworkRequest( QNetworkRequest &request, const Q else { method = "GET"; - payloadHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; // Sha256 of empty payload + payloadHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; // Sha256 of empty payload request.setRawHeader( QByteArray( "X-Amz-Content-SHA256" ), payloadHash ); } - const QByteArray canonicalRequest = method + '\n' + - canonicalPath + '\n' + - '\n' + - "host:" + request.url().host().toUtf8() + '\n' + - "x-amz-content-sha256:" + payloadHash + '\n' + - "x-amz-date:" + dateTime + '\n' + - '\n' + - headerList + '\n' + - payloadHash; + const QByteArray canonicalRequest = method + '\n' + canonicalPath + '\n' + '\n' + "host:" + request.url().host().toUtf8() + '\n' + "x-amz-content-sha256:" + payloadHash + '\n' + "x-amz-date:" + dateTime + '\n' + '\n' + headerList + '\n' + payloadHash; const QByteArray canonicalRequestHash = QCryptographicHash::hash( canonicalRequest, QCryptographicHash::Sha256 ).toHex(); - const QByteArray stringToSign = encryptionMethod + '\n' + - dateTime + '\n' + - date + "/" + region + "/s3/aws4_request" + '\n' + - canonicalRequestHash; - - const QByteArray signingKey = QMessageAuthenticationCode::hash( "aws4_request", - QMessageAuthenticationCode::hash( "s3", - QMessageAuthenticationCode::hash( region, - QMessageAuthenticationCode::hash( date, QByteArray( "AWS4" + password ), - QCryptographicHash::Sha256 ), - QCryptographicHash::Sha256 ), - QCryptographicHash::Sha256 ), - QCryptographicHash::Sha256 ); + const QByteArray stringToSign = encryptionMethod + '\n' + dateTime + '\n' + date + "/" + region + "/s3/aws4_request" + '\n' + canonicalRequestHash; + + const QByteArray signingKey = QMessageAuthenticationCode::hash( "aws4_request", QMessageAuthenticationCode::hash( "s3", QMessageAuthenticationCode::hash( region, QMessageAuthenticationCode::hash( date, QByteArray( "AWS4" + password ), QCryptographicHash::Sha256 ), QCryptographicHash::Sha256 ), QCryptographicHash::Sha256 ), QCryptographicHash::Sha256 ); const QByteArray signature = QMessageAuthenticationCode::hash( stringToSign, signingKey, QCryptographicHash::Sha256 ).toHex(); const QByteArray authorizationHeader = QString( "%1 Credential=%2/%3/%4/s3/aws4_request, SignedHeaders=%5, Signature=%6" ) - .arg( encryptionMethod, username, date, region, headerList, signature ) - .toUtf8(); + .arg( encryptionMethod, username, date, region, headerList, signature ) + .toUtf8(); request.setRawHeader( QByteArray( "Host" ), request.url().host().toUtf8() ); request.setRawHeader( QByteArray( "X-Amz-Date" ), dateTime ); diff --git a/src/auth/awss3/core/qgsauthawss3method.h b/src/auth/awss3/core/qgsauthawss3method.h index 1bca2a3893b9..516be6a5d326 100644 --- a/src/auth/awss3/core/qgsauthawss3method.h +++ b/src/auth/awss3/core/qgsauthawss3method.h @@ -29,7 +29,6 @@ class QgsAuthAwsS3Method : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -43,14 +42,13 @@ class QgsAuthAwsS3Method : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: @@ -61,7 +59,6 @@ class QgsAuthAwsS3Method : public QgsAuthMethod void removeMethodConfig( const QString &authcfg ); static QMap sAuthConfigCache; - }; @@ -71,7 +68,7 @@ class QgsAuthAwsS3MethodMetadata : public QgsAuthMethodMetadata QgsAuthAwsS3MethodMetadata() : QgsAuthMethodMetadata( QgsAuthAwsS3Method::AUTH_METHOD_KEY, QgsAuthAwsS3Method::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthAwsS3Method *createAuthMethod() const override {return new QgsAuthAwsS3Method;} + QgsAuthAwsS3Method *createAuthMethod() const override { return new QgsAuthAwsS3Method; } }; #endif // QGSAUTHAWSS3METHOD_H diff --git a/src/auth/basic/core/qgsauthbasicmethod.cpp b/src/auth/basic/core/qgsauthbasicmethod.cpp index 5e25a7eb62ab..c8666bdd940d 100644 --- a/src/auth/basic/core/qgsauthbasicmethod.cpp +++ b/src/auth/basic/core/qgsauthbasicmethod.cpp @@ -41,17 +41,8 @@ QgsAuthBasicMethod::QgsAuthBasicMethod() { setVersion( 2 ); setExpansions( QgsAuthMethod::NetworkRequest | QgsAuthMethod::DataSourceUri ); - setDataProviders( QStringList() - << QStringLiteral( "postgres" ) - << QStringLiteral( "oracle" ) - << QStringLiteral( "ows" ) - << QStringLiteral( "wfs" ) // convert to lowercase - << QStringLiteral( "wcs" ) - << QStringLiteral( "wms" ) - << QStringLiteral( "ogr" ) - << QStringLiteral( "gdal" ) - << QStringLiteral( "proxy" ) ); - + setDataProviders( QStringList() << QStringLiteral( "postgres" ) << QStringLiteral( "oracle" ) << QStringLiteral( "ows" ) << QStringLiteral( "wfs" ) // convert to lowercase + << QStringLiteral( "wcs" ) << QStringLiteral( "wms" ) << QStringLiteral( "ogr" ) << QStringLiteral( "gdal" ) << QStringLiteral( "proxy" ) ); } QString QgsAuthBasicMethod::key() const @@ -70,8 +61,7 @@ QString QgsAuthBasicMethod::displayDescription() const } -bool QgsAuthBasicMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthBasicMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( dataprovider ) const QgsAuthMethodConfig mconfig = getMethodConfig( authcfg ); @@ -91,8 +81,7 @@ bool QgsAuthBasicMethod::updateNetworkRequest( QNetworkRequest &request, const Q return true; } -bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( dataprovider ) const QMutexLocker locker( &mMutex ); @@ -129,9 +118,10 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, // save CAs to temp file const QString tempFileBase = QStringLiteral( "tmp_basic_%1.pem" ); const QString caFilePath = QgsAuthCertUtils::pemTextToTempFile( - tempFileBase.arg( QUuid::createUuid().toString() ), - QgsAuthCertUtils::certsToPemText( cas ) ); - if ( ! caFilePath.isEmpty() ) + tempFileBase.arg( QUuid::createUuid().toString() ), + QgsAuthCertUtils::certsToPemText( cas ) + ); + if ( !caFilePath.isEmpty() ) { caparam = "sslrootcert='" + caFilePath + "'"; } @@ -140,8 +130,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, // Branch for OGR if ( dataprovider == QLatin1String( "ogr" ) || dataprovider == QLatin1String( "gdal" ) ) { - - if ( ! password.isEmpty() ) + if ( !password.isEmpty() ) { const QString fullUri( connectionItems.first() ); QString uri( fullUri ); @@ -151,7 +140,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, uri = uri.left( uri.indexOf( '|' ) ); } // At least username must be set... password can be empty - if ( ! username.isEmpty() ) + if ( !username.isEmpty() ) { // Inject credentials if ( uri.startsWith( QLatin1String( "PG:" ) ) ) @@ -165,7 +154,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, uri += QStringLiteral( " user='%1'" ).arg( username ); uri += QStringLiteral( " password='%1'" ).arg( password ); // add extra CAs - if ( ! caparam.isEmpty() ) + if ( !caparam.isEmpty() ) { uri += ' ' + caparam; } @@ -223,7 +212,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, else if ( uri.startsWith( QLatin1String( "OCI:" ) ) ) { // OCI:userid/password@database_instance:table,table - uri = uri.replace( QLatin1String( "OCI:/" ), QStringLiteral( "OCI:%1/%2" ).arg( username, password ) ); + uri = uri.replace( QLatin1String( "OCI:/" ), QStringLiteral( "OCI:%1/%2" ).arg( username, password ) ); } else if ( uri.startsWith( QLatin1String( "ODBC:" ) ) ) { @@ -237,8 +226,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, || uri.startsWith( "https://" ) || uri.startsWith( "/vsicurl/https://" ) || uri.startsWith( "ftp://" ) - || uri.startsWith( "/vsicurl/ftp://" ) - ) + || uri.startsWith( "/vsicurl/ftp://" ) ) { uri = uri.replace( QLatin1String( "://" ), QStringLiteral( "://%1:%2@" ).arg( username, password ) ); } @@ -254,7 +242,6 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, { QgsDebugError( QStringLiteral( "Update URI items FAILED for authcfg: %1: password empty" ).arg( authcfg ) ); } - } else // Not-ogr { @@ -282,7 +269,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, connectionItems.append( passparam ); } // add extra CAs - if ( ! caparam.isEmpty() ) + if ( !caparam.isEmpty() ) { const thread_local QRegularExpression sslcaRegExp( "^sslrootcert='.*" ); const int sslcaindx = connectionItems.indexOf( sslcaRegExp ); @@ -417,6 +404,3 @@ QGISEXTERN QgsAuthMethodMetadata *authMethodMetadataFactory() return new QgsAuthBasicMethodMetadata(); } #endif - - - diff --git a/src/auth/basic/core/qgsauthbasicmethod.h b/src/auth/basic/core/qgsauthbasicmethod.h index e2a1d44bb4b5..d3b7ee1e4556 100644 --- a/src/auth/basic/core/qgsauthbasicmethod.h +++ b/src/auth/basic/core/qgsauthbasicmethod.h @@ -31,7 +31,6 @@ class QgsAuthBasicMethod : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -45,22 +44,19 @@ class QgsAuthBasicMethod : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; - bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider = QString() ) override; - bool updateNetworkProxy( QNetworkProxy &proxy, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkProxy( QNetworkProxy &proxy, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: @@ -81,11 +77,9 @@ class QgsAuthBasicMethodMetadata : public QgsAuthMethodMetadata QgsAuthBasicMethodMetadata() : QgsAuthMethodMetadata( QgsAuthBasicMethod::AUTH_METHOD_KEY, QgsAuthBasicMethod::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthBasicMethod *createAuthMethod() const override {return new QgsAuthBasicMethod;} + QgsAuthBasicMethod *createAuthMethod() const override { return new QgsAuthBasicMethod; } //QStringList supportedDataProviders() const override; }; - - #endif // QGSAUTHBASICMETHOD_H diff --git a/src/auth/esritoken/core/qgsauthesritokenmethod.cpp b/src/auth/esritoken/core/qgsauthesritokenmethod.cpp index f47318bc86f1..233fcff30a61 100644 --- a/src/auth/esritoken/core/qgsauthesritokenmethod.cpp +++ b/src/auth/esritoken/core/qgsauthesritokenmethod.cpp @@ -40,10 +40,7 @@ QgsAuthEsriTokenMethod::QgsAuthEsriTokenMethod() { setVersion( 2 ); setExpansions( QgsAuthMethod::NetworkRequest ); - setDataProviders( QStringList() - << QStringLiteral( "arcgismapserver" ) - << QStringLiteral( "arcgisfeatureserver" ) ); - + setDataProviders( QStringList() << QStringLiteral( "arcgismapserver" ) << QStringLiteral( "arcgisfeatureserver" ) ); } QString QgsAuthEsriTokenMethod::key() const @@ -61,8 +58,7 @@ QString QgsAuthEsriTokenMethod::displayDescription() const return AUTH_METHOD_DISPLAY_DESCRIPTION; } -bool QgsAuthEsriTokenMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthEsriTokenMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( dataprovider ) const QgsAuthMethodConfig config = getMethodConfig( authcfg ); @@ -76,7 +72,7 @@ bool QgsAuthEsriTokenMethod::updateNetworkRequest( QNetworkRequest &request, con if ( !token.isEmpty() ) { - request.setRawHeader( "X-Esri-Authorization", QStringLiteral( "Bearer %1 " ).arg( token ).toLocal8Bit() ); + request.setRawHeader( "X-Esri-Authorization", QStringLiteral( "Bearer %1 " ).arg( token ).toLocal8Bit() ); } return true; } diff --git a/src/auth/esritoken/core/qgsauthesritokenmethod.h b/src/auth/esritoken/core/qgsauthesritokenmethod.h index 2edfd1b0ae0f..9244f46f16ab 100644 --- a/src/auth/esritoken/core/qgsauthesritokenmethod.h +++ b/src/auth/esritoken/core/qgsauthesritokenmethod.h @@ -30,7 +30,6 @@ class QgsAuthEsriTokenMethod : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -44,14 +43,13 @@ class QgsAuthEsriTokenMethod : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: @@ -62,7 +60,6 @@ class QgsAuthEsriTokenMethod : public QgsAuthMethod void removeMethodConfig( const QString &authcfg ); static QMap sAuthConfigCache; - }; @@ -72,7 +69,7 @@ class QgsAuthEsriTokenMethodMetadata : public QgsAuthMethodMetadata QgsAuthEsriTokenMethodMetadata() : QgsAuthMethodMetadata( QgsAuthEsriTokenMethod::AUTH_METHOD_KEY, QgsAuthEsriTokenMethod::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthEsriTokenMethod *createAuthMethod() const override {return new QgsAuthEsriTokenMethod;} + QgsAuthEsriTokenMethod *createAuthMethod() const override { return new QgsAuthEsriTokenMethod; } //QStringList supportedDataProviders() const override; }; diff --git a/src/auth/identcert/core/qgsauthidentcertmethod.cpp b/src/auth/identcert/core/qgsauthidentcertmethod.cpp index ad7f6005908d..78144aae5ec9 100644 --- a/src/auth/identcert/core/qgsauthidentcertmethod.cpp +++ b/src/auth/identcert/core/qgsauthidentcertmethod.cpp @@ -50,12 +50,8 @@ QgsAuthIdentCertMethod::QgsAuthIdentCertMethod() { setVersion( 2 ); setExpansions( QgsAuthMethod::NetworkRequest | QgsAuthMethod::DataSourceUri ); - setDataProviders( QStringList() - << QStringLiteral( "ows" ) - << QStringLiteral( "wfs" ) // convert to lowercase - << QStringLiteral( "wcs" ) - << QStringLiteral( "wms" ) - << QStringLiteral( "postgres" ) ); + setDataProviders( QStringList() << QStringLiteral( "ows" ) << QStringLiteral( "wfs" ) // convert to lowercase + << QStringLiteral( "wcs" ) << QStringLiteral( "wms" ) << QStringLiteral( "postgres" ) ); } QgsAuthIdentCertMethod::~QgsAuthIdentCertMethod() @@ -82,8 +78,7 @@ QString QgsAuthIdentCertMethod::displayDescription() const return AUTH_METHOD_DISPLAY_DESCRIPTION; } -bool QgsAuthIdentCertMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthIdentCertMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { #ifndef QT_NO_SSL Q_UNUSED( dataprovider ) @@ -121,8 +116,7 @@ bool QgsAuthIdentCertMethod::updateNetworkRequest( QNetworkRequest &request, con #endif } -bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider ) { #ifndef QT_NO_SSL Q_UNUSED( dataprovider ) @@ -142,8 +136,9 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt // save client cert to temp file const QString certFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - pkibundle->clientCert().toPem() ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + pkibundle->clientCert().toPem() + ); if ( certFilePath.isEmpty() ) { return false; @@ -151,8 +146,9 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt // save client cert key to temp file const QString keyFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - pkibundle->clientCertKey().toPem() ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + pkibundle->clientCertKey().toPem() + ); if ( keyFilePath.isEmpty() ) { return false; @@ -160,8 +156,9 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt // save CAs to temp file const QString caFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - QgsApplication::authManager()->trustedCaCertsPemText() ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + QgsApplication::authManager()->trustedCaCertsPemText() + ); if ( caFilePath.isEmpty() ) { return false; diff --git a/src/auth/identcert/core/qgsauthidentcertmethod.h b/src/auth/identcert/core/qgsauthidentcertmethod.h index b61429bb8669..59029d532e69 100644 --- a/src/auth/identcert/core/qgsauthidentcertmethod.h +++ b/src/auth/identcert/core/qgsauthidentcertmethod.h @@ -30,7 +30,6 @@ class QgsAuthIdentCertMethod : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -45,22 +44,19 @@ class QgsAuthIdentCertMethod : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; - bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: - #ifndef QT_NO_SSL QgsPkiConfigBundle *getPkiConfigBundle( const QString &authcfg ); @@ -70,7 +66,6 @@ class QgsAuthIdentCertMethod : public QgsAuthMethod static QMap sPkiConfigBundleCache; #endif - }; @@ -80,7 +75,7 @@ class QgsAuthIdentCertMethodMetadata : public QgsAuthMethodMetadata QgsAuthIdentCertMethodMetadata() : QgsAuthMethodMetadata( QgsAuthIdentCertMethod::AUTH_METHOD_KEY, QgsAuthIdentCertMethod::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthIdentCertMethod *createAuthMethod() const override {return new QgsAuthIdentCertMethod;} + QgsAuthIdentCertMethod *createAuthMethod() const override { return new QgsAuthIdentCertMethod; } //QStringList supportedDataProviders() const override; }; diff --git a/src/auth/identcert/gui/qgsauthidentcertedit.cpp b/src/auth/identcert/gui/qgsauthidentcertedit.cpp index 66d6070f9212..1fb142a1ee06 100644 --- a/src/auth/identcert/gui/qgsauthidentcertedit.cpp +++ b/src/auth/identcert/gui/qgsauthidentcertedit.cpp @@ -86,14 +86,12 @@ void QgsAuthIdentCertEdit::populateIdentityComboBox() QString org( SSL_SUBJECT_INFO( cert, QSslCertificate::Organization ) ); if ( org.isEmpty() ) org = tr( "Organization not defined" ); - idents.insert( QStringLiteral( "%1 (%2)" ).arg( QgsAuthCertUtils::resolvedCertName( cert ), org ), - QgsAuthCertUtils::shaHexForCert( cert ) ); + idents.insert( QStringLiteral( "%1 (%2)" ).arg( QgsAuthCertUtils::resolvedCertName( cert ), org ), QgsAuthCertUtils::shaHexForCert( cert ) ); } QgsStringMap::const_iterator it = idents.constBegin(); for ( ; it != idents.constEnd(); ++it ) { - cmbIdentityCert->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconCertificate.svg" ) ), - it.key(), it.value() ); + cmbIdentityCert->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconCertificate.svg" ) ), it.key(), it.value() ); } } } diff --git a/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.cpp b/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.cpp index f7e056344580..4149837e48c3 100644 --- a/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.cpp +++ b/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.cpp @@ -40,11 +40,7 @@ QgsAuthMapTilerHmacSha256Method::QgsAuthMapTilerHmacSha256Method() { setVersion( 1 ); setExpansions( QgsAuthMethod::NetworkRequest ); - setDataProviders( QStringList() - << QStringLiteral( "wms" ) - << QStringLiteral( "vectortile" ) - << QStringLiteral( "xyzvectortiles" ) ); - + setDataProviders( QStringList() << QStringLiteral( "wms" ) << QStringLiteral( "vectortile" ) << QStringLiteral( "xyzvectortiles" ) ); } QString QgsAuthMapTilerHmacSha256Method::key() const @@ -62,8 +58,7 @@ QString QgsAuthMapTilerHmacSha256Method::displayDescription() const return AUTH_METHOD_DISPLAY_DESCRIPTION; } -bool QgsAuthMapTilerHmacSha256Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthMapTilerHmacSha256Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( dataprovider ) const QgsAuthMethodConfig config = getMethodConfig( authcfg ); @@ -89,9 +84,9 @@ bool QgsAuthMapTilerHmacSha256Method::updateNetworkRequest( QNetworkRequest &req QUrlQuery query( url.query() ); query.removeQueryItem( QStringLiteral( "key" ) ); - QList > queryItems = query.queryItems(); + QList> queryItems = query.queryItems(); - queryItems.append( {QStringLiteral( "key" ), key} ); + queryItems.append( { QStringLiteral( "key" ), key } ); query.setQueryItems( queryItems ); url.setQuery( query ); diff --git a/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.h b/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.h index 20a62cb26a97..9eda4bc3fb31 100644 --- a/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.h +++ b/src/auth/maptiler_hmacsha256/core/qgsauthmaptilerhmacsha256method.h @@ -30,7 +30,6 @@ class QgsAuthMapTilerHmacSha256Method : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -44,14 +43,13 @@ class QgsAuthMapTilerHmacSha256Method : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: @@ -64,7 +62,6 @@ class QgsAuthMapTilerHmacSha256Method : public QgsAuthMethod QByteArray calculateSignature( const QString &token, const QString &keyedUrl ); static QMap sAuthConfigCache; - }; @@ -74,7 +71,7 @@ class QgsAuthMapTilerHmacSha256MethodMetadata : public QgsAuthMethodMetadata QgsAuthMapTilerHmacSha256MethodMetadata() : QgsAuthMethodMetadata( QgsAuthMapTilerHmacSha256Method::AUTH_METHOD_KEY, QgsAuthMapTilerHmacSha256Method::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthMapTilerHmacSha256Method *createAuthMethod() const override {return new QgsAuthMapTilerHmacSha256Method;} + QgsAuthMapTilerHmacSha256Method *createAuthMethod() const override { return new QgsAuthMapTilerHmacSha256Method; } }; #endif // QGSAUTHHMACSHA256METHOD_H diff --git a/src/auth/oauth2/core/qgsauthoauth2config.cpp b/src/auth/oauth2/core/qgsauthoauth2config.cpp index 65d2c3c3717f..eed54c11804e 100644 --- a/src/auth/oauth2/core/qgsauthoauth2config.cpp +++ b/src/auth/oauth2/core/qgsauthoauth2config.cpp @@ -28,7 +28,6 @@ QgsAuthOAuth2Config::QgsAuthOAuth2Config( QObject *parent ) : QObject( parent ) , mQueryPairs( QVariantMap() ) { - // internal signal bounces connect( this, &QgsAuthOAuth2Config::idChanged, this, &QgsAuthOAuth2Config::configChanged ); connect( this, &QgsAuthOAuth2Config::versionChanged, this, &QgsAuthOAuth2Config::configChanged ); @@ -275,33 +274,12 @@ void QgsAuthOAuth2Config::setToDefaults() bool QgsAuthOAuth2Config::operator==( const QgsAuthOAuth2Config &other ) const { - return ( other.version() == this->version() - && other.configType() == this->configType() - && other.grantFlow() == this->grantFlow() - && other.name() == this->name() - && other.description() == this->description() - && other.requestUrl() == this->requestUrl() - && other.tokenUrl() == this->tokenUrl() - && other.refreshTokenUrl() == this->refreshTokenUrl() - && other.redirectHost() == this->redirectHost() - && other.redirectUrl() == this->redirectUrl() - && other.redirectPort() == this->redirectPort() - && other.clientId() == this->clientId() - && other.clientSecret() == this->clientSecret() - && other.username() == this->username() - && other.password() == this->password() - && other.scope() == this->scope() - && other.apiKey() == this->apiKey() - && other.persistToken() == this->persistToken() - && other.accessMethod() == this->accessMethod() - && other.customHeader() == this->customHeader() - && other.requestTimeout() == this->requestTimeout() - && other.queryPairs() == this->queryPairs() ); + return ( other.version() == this->version() && other.configType() == this->configType() && other.grantFlow() == this->grantFlow() && other.name() == this->name() && other.description() == this->description() && other.requestUrl() == this->requestUrl() && other.tokenUrl() == this->tokenUrl() && other.refreshTokenUrl() == this->refreshTokenUrl() && other.redirectHost() == this->redirectHost() && other.redirectUrl() == this->redirectUrl() && other.redirectPort() == this->redirectPort() && other.clientId() == this->clientId() && other.clientSecret() == this->clientSecret() && other.username() == this->username() && other.password() == this->password() && other.scope() == this->scope() && other.apiKey() == this->apiKey() && other.persistToken() == this->persistToken() && other.accessMethod() == this->accessMethod() && other.customHeader() == this->customHeader() && other.requestTimeout() == this->requestTimeout() && other.queryPairs() == this->queryPairs() ); } bool QgsAuthOAuth2Config::operator!=( const QgsAuthOAuth2Config &other ) const { - return !( *this == other ); + return !( *this == other ); } bool QgsAuthOAuth2Config::isValid() const @@ -322,27 +300,15 @@ void QgsAuthOAuth2Config::validateConfigId( bool needsId ) if ( mGrantFlow == AuthCode || mGrantFlow == Implicit ) { - mValid = ( !requestUrl().isEmpty() - && !tokenUrl().isEmpty() - && !clientId().isEmpty() - && ( ( mGrantFlow == AuthCode || mGrantFlow == Pkce ) ? !clientSecret().isEmpty() : true ) - && redirectPort() > 0 - && ( needsId ? !id().isEmpty() : true ) ); + mValid = ( !requestUrl().isEmpty() && !tokenUrl().isEmpty() && !clientId().isEmpty() && ( ( mGrantFlow == AuthCode || mGrantFlow == Pkce ) ? !clientSecret().isEmpty() : true ) && redirectPort() > 0 && ( needsId ? !id().isEmpty() : true ) ); } - else if ( mGrantFlow == Pkce ) // No client secret for PKCE + else if ( mGrantFlow == Pkce ) // No client secret for PKCE { - mValid = ( !requestUrl().isEmpty() - && !tokenUrl().isEmpty() - && !clientId().isEmpty() - && redirectPort() > 0 - && ( needsId ? !id().isEmpty() : true ) ); + mValid = ( !requestUrl().isEmpty() && !tokenUrl().isEmpty() && !clientId().isEmpty() && redirectPort() > 0 && ( needsId ? !id().isEmpty() : true ) ); } else if ( mGrantFlow == ResourceOwner ) { - mValid = ( !tokenUrl().isEmpty() - && !username().isEmpty() - && !password().isEmpty() - && ( needsId ? !id().isEmpty() : true ) ); + mValid = ( !tokenUrl().isEmpty() && !username().isEmpty() && !password().isEmpty() && ( needsId ? !id().isEmpty() : true ) ); } if ( mValid != oldvalid ) @@ -350,7 +316,8 @@ void QgsAuthOAuth2Config::validateConfigId( bool needsId ) } bool QgsAuthOAuth2Config::loadConfigTxt( - const QByteArray &configtxt, QgsAuthOAuth2Config::ConfigFormat format ) + const QByteArray &configtxt, QgsAuthOAuth2Config::ConfigFormat format +) { QByteArray errStr; bool res = false; @@ -384,7 +351,8 @@ bool QgsAuthOAuth2Config::loadConfigTxt( } QByteArray QgsAuthOAuth2Config::saveConfigTxt( - QgsAuthOAuth2Config::ConfigFormat format, bool pretty, bool *ok ) const + QgsAuthOAuth2Config::ConfigFormat format, bool pretty, bool *ok +) const { QByteArray out; QByteArray errStr; @@ -454,7 +422,8 @@ QByteArray QgsAuthOAuth2Config::serializeFromVariant( const QVariantMap &variant, QgsAuthOAuth2Config::ConfigFormat format, bool pretty, - bool *ok ) + bool *ok +) { QByteArray out; QByteArray errStr; @@ -482,7 +451,8 @@ QByteArray QgsAuthOAuth2Config::serializeFromVariant( QVariantMap QgsAuthOAuth2Config::variantFromSerialized( const QByteArray &serial, QgsAuthOAuth2Config::ConfigFormat format, - bool *ok ) + bool *ok +) { QVariantMap vmap; QByteArray errStr; @@ -532,7 +502,8 @@ bool QgsAuthOAuth2Config::writeOAuth2Config( const QString &filepath, QgsAuthOAuth2Config *config, QgsAuthOAuth2Config::ConfigFormat format, - bool pretty ) + bool pretty +) { bool res = false; const QByteArray configtxt = config->saveConfigTxt( format, pretty, &res ); @@ -575,7 +546,8 @@ QList QgsAuthOAuth2Config::loadOAuth2Configs( const QString &configdirectory, QObject *parent, QgsAuthOAuth2Config::ConfigFormat format, - bool *ok ) + bool *ok +) { QList configs = QList(); const bool res = false; @@ -599,13 +571,13 @@ QList QgsAuthOAuth2Config::loadOAuth2Configs( if ( configfiles.size() > 0 ) { - QgsDebugMsgLevel( QStringLiteral( "Config files found in: %1...\n%2" ) - .arg( configdir.path(), configfiles.join( QLatin1String( ", " ) ) ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Config files found in: %1...\n%2" ).arg( configdir.path(), configfiles.join( QLatin1String( ", " ) ) ), 2 ); } else { QgsDebugMsgLevel( QStringLiteral( "No config files found in: %1" ).arg( configdir.path() ), 2 ); - if ( ok ) *ok = res; + if ( ok ) + *ok = res; return configs; } @@ -644,7 +616,8 @@ QList QgsAuthOAuth2Config::loadOAuth2Configs( configs << config; } - if ( ok ) *ok = true; + if ( ok ) + *ok = true; return configs; } @@ -653,7 +626,8 @@ QgsStringMap QgsAuthOAuth2Config::mapOAuth2Configs( const QString &configdirectory, QObject *parent, QgsAuthOAuth2Config::ConfigFormat format, - bool *ok ) + bool *ok +) { QgsStringMap configs = QgsStringMap(); const bool res = false; @@ -677,8 +651,7 @@ QgsStringMap QgsAuthOAuth2Config::mapOAuth2Configs( if ( configfiles.size() > 0 ) { - QgsDebugMsgLevel( QStringLiteral( "Config files found in: %1...\n%2" ) - .arg( configdir.path(), configfiles.join( QLatin1String( ", " ) ) ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Config files found in: %1...\n%2" ).arg( configdir.path(), configfiles.join( QLatin1String( ", " ) ) ), 2 ); } else { @@ -714,7 +687,7 @@ QgsStringMap QgsAuthOAuth2Config::mapOAuth2Configs( } // validate the config before caching it - std::unique_ptr > config( new QgsAuthOAuth2Config( parent ), []( QgsAuthOAuth2Config * cfg ) { cfg->deleteLater( );} ); + std::unique_ptr> config( new QgsAuthOAuth2Config( parent ), []( QgsAuthOAuth2Config *cfg ) { cfg->deleteLater(); } ); if ( !config->loadConfigTxt( configtxt, format ) ) { QgsDebugError( QStringLiteral( "FAILED to load config: %1" ).arg( configfile ) ); @@ -763,7 +736,8 @@ QgsStringMap QgsAuthOAuth2Config::mappedOAuth2ConfigsCache( QObject *parent, con continue; } const QgsStringMap newconfigs = QgsAuthOAuth2Config::mapOAuth2Configs( - configdirinfo.canonicalFilePath(), parent, QgsAuthOAuth2Config::JSON, &ok ); + configdirinfo.canonicalFilePath(), parent, QgsAuthOAuth2Config::JSON, &ok + ); if ( ok ) { QgsStringMap::const_iterator i = newconfigs.constBegin(); @@ -838,7 +812,7 @@ QString QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::AccessMeth QString QgsAuthOAuth2Config::tokenCacheDirectory( bool temporary ) { const QDir setdir( QgsApplication::qgisSettingsDirPath() ); - return QStringLiteral( "%1/oauth2-cache" ).arg( temporary ? QDir::tempPath() : setdir.canonicalPath() ); + return QStringLiteral( "%1/oauth2-cache" ).arg( temporary ? QDir::tempPath() : setdir.canonicalPath() ); } // static @@ -850,6 +824,5 @@ QString QgsAuthOAuth2Config::tokenCacheFile( const QString &suffix ) // static QString QgsAuthOAuth2Config::tokenCachePath( const QString &suffix, bool temporary ) { - return QStringLiteral( "%1/%2" ).arg( QgsAuthOAuth2Config::tokenCacheDirectory( temporary ), - QgsAuthOAuth2Config::tokenCacheFile( suffix ) ); + return QStringLiteral( "%1/%2" ).arg( QgsAuthOAuth2Config::tokenCacheDirectory( temporary ), QgsAuthOAuth2Config::tokenCacheFile( suffix ) ); } diff --git a/src/auth/oauth2/core/qgsauthoauth2config.h b/src/auth/oauth2/core/qgsauthoauth2config.h index 0663d8f67499..8a7a3236782b 100644 --- a/src/auth/oauth2/core/qgsauthoauth2config.h +++ b/src/auth/oauth2/core/qgsauthoauth2config.h @@ -59,7 +59,6 @@ class QgsAuthOAuth2Config : public QObject Q_PROPERTY( QString customHeader READ customHeader WRITE setCustomHeader NOTIFY customHeaderChanged ) public: - //! Configuration type enum ConfigType { @@ -103,7 +102,7 @@ class QgsAuthOAuth2Config : public QObject ConfigType configType() const { return mConfigType; } //! Authorization flow - GrantFlow grantFlow() const { return mGrantFlow; } + GrantFlow grantFlow() const { return mGrantFlow; } //! Configuration name QString name() const { return mName; } @@ -197,10 +196,7 @@ class QgsAuthOAuth2Config : public QObject * \param ok is set to FALSE in case something goes wrong, TRUE otherwise * \return serialized config */ - static QByteArray serializeFromVariant( const QVariantMap &variant, - ConfigFormat format = JSON, - bool pretty = false, - bool *ok = nullptr ); + static QByteArray serializeFromVariant( const QVariantMap &variant, ConfigFormat format = JSON, bool pretty = false, bool *ok = nullptr ); /** * Unserialize the configuration in \a serial according to \a format @@ -209,29 +205,26 @@ class QgsAuthOAuth2Config : public QObject * \param ok is set to FALSE in case something goes wrong, TRUE otherwise * \return config map */ - static QVariantMap variantFromSerialized( const QByteArray &serial, - ConfigFormat format = JSON, - bool *ok = nullptr ); + static QVariantMap variantFromSerialized( const QByteArray &serial, ConfigFormat format = JSON, bool *ok = nullptr ); //! Write config object out to a formatted file (e.g. JSON) - static bool writeOAuth2Config( const QString &filepath, - QgsAuthOAuth2Config *config, - ConfigFormat format = JSON, - bool pretty = false ); + static bool writeOAuth2Config( const QString &filepath, QgsAuthOAuth2Config *config, ConfigFormat format = JSON, bool pretty = false ); //! Load and parse a directory of configs (e.g. JSON) to objects static QList loadOAuth2Configs( const QString &configdirectory, QObject *parent = nullptr, ConfigFormat format = JSON, - bool *ok = nullptr ); + bool *ok = nullptr + ); //! Load and parse a directory of configs (e.g. JSON) to a map static QgsStringMap mapOAuth2Configs( const QString &configdirectory, QObject *parent = nullptr, ConfigFormat format = JSON, - bool *ok = nullptr ); + bool *ok = nullptr + ); /** * Returns an ordered list of locations from which stored configuration files @@ -410,7 +403,7 @@ class QgsAuthOAuth2Config : public QObject bool mPersistToken = false; AccessMethod mAccessMethod = AccessMethod::Header; QString mCustomHeader; - int mRequestTimeout = 30 ; // in seconds + int mRequestTimeout = 30; // in seconds QVariantMap mQueryPairs; bool mValid = false; }; diff --git a/src/auth/oauth2/core/qgsauthoauth2method.cpp b/src/auth/oauth2/core/qgsauthoauth2method.cpp index d463fcaeba29..15045cc6c836 100644 --- a/src/auth/oauth2/core/qgsauthoauth2method.cpp +++ b/src/auth/oauth2/core/qgsauthoauth2method.cpp @@ -87,15 +87,14 @@ void QgsOAuth2Factory::requestLink( QgsO2 *o2 ) else QMetaObject::invokeMethod( o2, &QgsO2::link, Qt::BlockingQueuedConnection ); #else - ( void )o2; + ( void ) o2; #endif } QgsO2 *QgsOAuth2Factory::createO2Private( const QString &authcfg, QgsAuthOAuth2Config *oauth2config ) { QgsO2 *o2 = nullptr; - auto createO2InThread = [ &o2, authcfg, oauth2config, this ] - { + auto createO2InThread = [&o2, authcfg, oauth2config, this] { Q_ASSERT( QThread::currentThread() == this ); oauth2config->moveToThread( this ); o2 = new QgsO2( authcfg, oauth2config, nullptr, QgsNetworkAccessManager::instance() ); @@ -126,11 +125,8 @@ QgsAuthOAuth2Method::QgsAuthOAuth2Method() { setVersion( 1 ); setExpansions( QgsAuthMethod::NetworkRequest | QgsAuthMethod::NetworkReply ); - setDataProviders( QStringList() - << QStringLiteral( "ows" ) - << QStringLiteral( "wfs" ) // convert to lowercase - << QStringLiteral( "wcs" ) - << QStringLiteral( "wms" ) ); + setDataProviders( QStringList() << QStringLiteral( "ows" ) << QStringLiteral( "wfs" ) // convert to lowercase + << QStringLiteral( "wcs" ) << QStringLiteral( "wms" ) ); const QStringList cachedirpaths = QStringList() << QgsAuthOAuth2Config::tokenCacheDirectory() @@ -179,8 +175,7 @@ QString QgsAuthOAuth2Method::displayDescription() const return AUTH_METHOD_DISPLAY_DESCRIPTION; } -bool QgsAuthOAuth2Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthOAuth2Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( dataprovider ) @@ -212,7 +207,7 @@ bool QgsAuthOAuth2Method::updateNetworkRequest( QNetworkRequest &request, const { // First, check if it is expired bool expired = false; - if ( o2->expires() > 0 ) // QStringLiteral("").toInt() result for tokens with no expiration + if ( o2->expires() > 0 ) // QStringLiteral("").toInt() result for tokens with no expiration { const int cursecs = static_cast( QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000 ); const int lExpirationDelay = o2->expirationDelay(); @@ -255,7 +250,7 @@ bool QgsAuthOAuth2Method::updateNetworkRequest( QNetworkRequest &request, const connect( o2, &QgsO2::linkingFailed, this, &QgsAuthOAuth2Method::onLinkingFailed, Qt::UniqueConnection ); connect( o2, &QgsO2::linkingSucceeded, this, &QgsAuthOAuth2Method::onLinkingSucceeded, Qt::UniqueConnection ); connect( o2, &QgsO2::getAuthCode, this, &QgsAuthOAuth2Method::onAuthCode, Qt::UniqueConnection ); - connect( this, &QgsAuthOAuth2Method::setAuthCode, o2, &QgsO2::onSetAuthCode, Qt::UniqueConnection ); + connect( this, &QgsAuthOAuth2Method::setAuthCode, o2, &QgsO2::onSetAuthCode, Qt::UniqueConnection ); //qRegisterMetaType( QStringLiteral( "QNetworkReply::NetworkError" )) // for Qt::QueuedConnection, if needed; connect( o2, &QgsO2::refreshFinished, this, &QgsAuthOAuth2Method::onRefreshFinished, Qt::UniqueConnection ); @@ -375,15 +370,15 @@ bool QgsAuthOAuth2Method::updateNetworkReply( QNetworkReply *reply, const QStrin if ( !reply ) { const QString msg = QStringLiteral( "Updated reply with token refresh connection FAILED" - " for authcfg %1: null reply object" ).arg( authcfg ); + " for authcfg %1: null reply object" ) + .arg( authcfg ); QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); return false; } reply->setProperty( "authcfg", authcfg ); // converting this to new-style Qt5 connection causes odd linking error with static o2 library - connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), - this, SLOT( onNetworkError( QNetworkReply::NetworkError ) ), Qt::QueuedConnection ); + connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( onNetworkError( QNetworkReply::NetworkError ) ), Qt::QueuedConnection ); //connect( reply, static_cast( &QNetworkReply::error ), // this, &QgsAuthOAuth2Method::onNetworkError, Qt::QueuedConnection ); @@ -413,15 +408,13 @@ void QgsAuthOAuth2Method::onLinkingSucceeded() QgsO2 *o2 = qobject_cast( sender() ); if ( !o2 ) { - QgsMessageLog::logMessage( tr( "Linking succeeded, but authenticator access FAILED: null object" ), - AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Linking succeeded, but authenticator access FAILED: null object" ), AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); return; } if ( !o2->linked() ) { - QgsMessageLog::logMessage( tr( "Linking apparently succeeded, but authenticator FAILED to verify it is linked" ), - AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Linking apparently succeeded, but authenticator FAILED to verify it is linked" ), AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); return; } @@ -456,8 +449,7 @@ void QgsAuthOAuth2Method::onReplyFinished() QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); return; } - QgsMessageLog::logMessage( tr( "Results: %1" ).arg( QString( reply->readAll() ) ), - AUTH_METHOD_KEY, Qgis::MessageLevel::Info ); + QgsMessageLog::logMessage( tr( "Results: %1" ).arg( QString( reply->readAll() ) ), AUTH_METHOD_KEY, Qgis::MessageLevel::Info ); } void QgsAuthOAuth2Method::onNetworkError( QNetworkReply::NetworkError err ) @@ -546,8 +538,7 @@ void QgsAuthOAuth2Method::onRefreshFinished( QNetworkReply::NetworkError err ) } if ( err != QNetworkReply::NoError ) { - QgsMessageLog::logMessage( tr( "Token refresh error: %1" ).arg( reply->errorString() ), - AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Token refresh error: %1" ).arg( reply->errorString() ), AUTH_METHOD_KEY, Qgis::MessageLevel::Warning ); } } @@ -563,8 +554,7 @@ void QgsAuthOAuth2Method::onAuthCode() #endif } -bool QgsAuthOAuth2Method::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthOAuth2Method::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider ) { Q_UNUSED( connectionItems ) Q_UNUSED( authcfg ) @@ -613,7 +603,7 @@ QgsO2 *QgsAuthOAuth2Method::getOAuth2Bundle( const QString &authcfg, bool fullco // do loading of method config into oauth2 config - std::unique_ptr< QgsAuthOAuth2Config > config( new QgsAuthOAuth2Config() ); + std::unique_ptr config( new QgsAuthOAuth2Config() ); if ( configmap.contains( QStringLiteral( "oauth2config" ) ) ) { const QByteArray configtxt = configmap.value( QStringLiteral( "oauth2config" ) ).toUtf8(); @@ -672,8 +662,7 @@ QgsO2 *QgsAuthOAuth2Method::getOAuth2Bundle( const QString &authcfg, bool fullco const QByteArray querypairstxt = configmap.value( QStringLiteral( "querypairs" ) ).toUtf8(); if ( !querypairstxt.isNull() && !querypairstxt.isEmpty() ) { - const QVariantMap querypairsmap = - QgsAuthOAuth2Config::variantFromSerialized( querypairstxt, QgsAuthOAuth2Config::JSON, &ok ); + const QVariantMap querypairsmap = QgsAuthOAuth2Config::variantFromSerialized( querypairstxt, QgsAuthOAuth2Config::JSON, &ok ); if ( !ok ) { QgsDebugError( QStringLiteral( "No query pairs to load OAuth2 config: FAILED to parse" ) ); @@ -695,8 +684,7 @@ QgsO2 *QgsAuthOAuth2Method::getOAuth2Bundle( const QString &authcfg, bool fullco // TODO: instantiate particular QgsO2 subclassed authenticators relative to config ??? - QgsDebugMsgLevel( QStringLiteral( "Loading authenticator object with %1 flow properties of OAuth2 config: %2" ) - .arg( QgsAuthOAuth2Config::grantFlowString( config->grantFlow() ), authcfg ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Loading authenticator object with %1 flow properties of OAuth2 config: %2" ).arg( QgsAuthOAuth2Config::grantFlowString( config->grantFlow() ), authcfg ), 2 ); QgsO2 *o2 = QgsOAuth2Factory::createO2( authcfg, config.release() ); @@ -744,4 +732,3 @@ QGISEXTERN QgsAuthMethodMetadata *authMethodMetadataFactory() return new QgsAuthOAuth2MethodMetadata(); } #endif - diff --git a/src/auth/oauth2/core/qgsauthoauth2method.h b/src/auth/oauth2/core/qgsauthoauth2method.h index 22e5a6c21a66..2e76964f40ff 100644 --- a/src/auth/oauth2/core/qgsauthoauth2method.h +++ b/src/auth/oauth2/core/qgsauthoauth2method.h @@ -49,7 +49,6 @@ class QgsOAuth2Factory : public QThread Q_OBJECT public: - /** * Creates a new QgsO2 object, ensuring that it is correctly created on the * QgsOAuth2Factory thread instance. @@ -85,7 +84,6 @@ class QgsAuthOAuth2Method : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -102,16 +100,13 @@ class QgsAuthOAuth2Method : public QgsAuthMethod QString displayDescription() const override; //! Update network \a request with given \a authcfg and optional \a dataprovider - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; //! Update network \a reply with given \a authcfg and optional \a dataprovider - bool updateNetworkReply( QNetworkReply *reply, const QString &authcfg, - const QString &dataprovider ) override; + bool updateNetworkReply( QNetworkReply *reply, const QString &authcfg, const QString &dataprovider ) override; //! Update data source \a connectionItems with given \a authcfg and optional \a dataprovider - bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider = QString() ) override; //! Clear cached configuration for given \a authcfg void clearCachedConfig( const QString &authcfg ) override; @@ -143,7 +138,7 @@ class QgsAuthOAuth2Method : public QgsAuthMethod void onAuthCode(); #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif signals: @@ -152,7 +147,6 @@ class QgsAuthOAuth2Method : public QgsAuthMethod void setAuthCode( const QString code ); private: - QgsO2 *getOAuth2Bundle( const QString &authcfg, bool fullconfig = true ); void putOAuth2Bundle( const QString &authcfg, QgsO2 *bundle ); @@ -175,7 +169,7 @@ class QgsAuthOAuth2MethodMetadata : public QgsAuthMethodMetadata QgsAuthOAuth2MethodMetadata() : QgsAuthMethodMetadata( QgsAuthOAuth2Method::AUTH_METHOD_KEY, QgsAuthOAuth2Method::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthOAuth2Method *createAuthMethod() const override {return new QgsAuthOAuth2Method;} + QgsAuthOAuth2Method *createAuthMethod() const override { return new QgsAuthOAuth2Method; } //QStringList supportedDataProviders() const override; }; diff --git a/src/auth/oauth2/core/qgso2.cpp b/src/auth/oauth2/core/qgso2.cpp index 837c655f6ffd..aa64250a7ed1 100644 --- a/src/auth/oauth2/core/qgso2.cpp +++ b/src/auth/oauth2/core/qgso2.cpp @@ -35,18 +35,15 @@ QString QgsO2::O2_OAUTH2_STATE = QStringLiteral( "state" ); -QgsO2::QgsO2( const QString &authcfg, QgsAuthOAuth2Config *oauth2config, - QObject *parent, QNetworkAccessManager *manager ) +QgsO2::QgsO2( const QString &authcfg, QgsAuthOAuth2Config *oauth2config, QObject *parent, QNetworkAccessManager *manager ) : O2( parent, manager ) , mTokenCacheFile( QString() ) , mAuthcfg( authcfg ) , mOAuth2Config( oauth2config ) { static std::once_flag initialized; - std::call_once( initialized, [ = ]( ) - { - setLoggingFunction( []( const QString & message, LogLevel level ) - { + std::call_once( initialized, [=]() { + setLoggingFunction( []( const QString &message, LogLevel level ) { #ifdef QGISDEBUG switch ( level ) { @@ -59,8 +56,8 @@ QgsO2::QgsO2( const QString &authcfg, QgsAuthOAuth2Config *oauth2config, break; } #else - ( void )message; - ( void )level; + ( void ) message; + ( void ) level; #endif } ); } ); @@ -166,10 +163,11 @@ void QgsO2::setVerificationResponseContent() if ( verhtml.open( QIODevice::ReadOnly | QIODevice::Text ) ) { setReplyContent( QString::fromUtf8( verhtml.readAll() ) - .replace( QLatin1String( "{{ H2_TITLE }}" ), tr( "QGIS OAuth2 verification has finished" ) ) - .replace( QLatin1String( "{{ H3_TITLE }}" ), tr( "If you have not been returned to QGIS, bring the application to the forefront." ) ) - .replace( QLatin1String( "{{ CLOSE_WINDOW }}" ), tr( "Close window" ) ).toUtf8() - ); + .replace( QLatin1String( "{{ H2_TITLE }}" ), tr( "QGIS OAuth2 verification has finished" ) ) + .replace( QLatin1String( "{{ H3_TITLE }}" ), tr( "If you have not been returned to QGIS, bring the application to the forefront." ) ) + .replace( QLatin1String( "{{ CLOSE_WINDOW }}" ), tr( "Close window" ) ) + .toUtf8() + ); } } @@ -259,19 +257,15 @@ void QgsO2::link() } } // Assemble initial authentication URL - QList > parameters; - parameters.append( qMakePair( QString( O2_OAUTH2_RESPONSE_TYPE ), ( grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowPkce ) ? - QString( O2_OAUTH2_GRANT_TYPE_CODE ) : - QString( O2_OAUTH2_GRANT_TYPE_TOKEN ) ) ); + QList> parameters; + parameters.append( qMakePair( QString( O2_OAUTH2_RESPONSE_TYPE ), ( grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowPkce ) ? QString( O2_OAUTH2_GRANT_TYPE_CODE ) : QString( O2_OAUTH2_GRANT_TYPE_TOKEN ) ) ); parameters.append( qMakePair( QString( O2_OAUTH2_CLIENT_ID ), clientId_ ) ); parameters.append( qMakePair( QString( O2_OAUTH2_REDIRECT_URI ), redirectUri_ ) ); if ( grantFlow_ == GrantFlowPkce ) { - pkceCodeVerifier_ = ( QUuid::createUuid().toString( QUuid::WithoutBraces ) + - QUuid::createUuid().toString( QUuid::WithoutBraces ) ).toLatin1(); - pkceCodeChallenge_ = QCryptographicHash::hash( pkceCodeVerifier_, QCryptographicHash::Sha256 ).toBase64( - QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals ); + pkceCodeVerifier_ = ( QUuid::createUuid().toString( QUuid::WithoutBraces ) + QUuid::createUuid().toString( QUuid::WithoutBraces ) ).toLatin1(); + pkceCodeChallenge_ = QCryptographicHash::hash( pkceCodeVerifier_, QCryptographicHash::Sha256 ).toBase64( QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals ); parameters.append( qMakePair( QString( O2_OAUTH2_PKCE_CODE_CHALLENGE_PARAM ), pkceCodeChallenge_ ) ); parameters.append( qMakePair( QString( O2_OAUTH2_PKCE_CODE_CHALLENGE_METHOD_PARAM ), QString( O2_OAUTH2_PKCE_CODE_CHALLENGE_METHOD_S256 ) ) ); } @@ -357,7 +351,7 @@ void QgsO2::onVerificationReceived( QMap response ) { if ( response.value( QStringLiteral( "state" ), QStringLiteral( "ignore" ) ) != state_ ) { - QgsDebugMsgLevel( QStringLiteral( "QgsO2::onVerificationReceived: Verification failed: (Response returned wrong state)" ), 3 ) ; + QgsDebugMsgLevel( QStringLiteral( "QgsO2::onVerificationReceived: Verification failed: (Response returned wrong state)" ), 3 ); emit linkingFailed(); return; } @@ -375,7 +369,6 @@ void QgsO2::onVerificationReceived( QMap response ) if ( grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowPkce ) { - // Exchange access code for access/refresh tokens QString query; if ( !apiKey_.isEmpty() ) @@ -417,7 +410,7 @@ void QgsO2::onVerificationReceived( QMap response ) if ( ok ) { QgsDebugMsgLevel( QStringLiteral( "O2::onVerificationReceived: Token expires in %1 seconds" ).arg( expiresIn ), 2 ); - setExpires( QDateTime::currentMSecsSinceEpoch() / 1000 + static_cast< qint64 >( expiresIn ) ); + setExpires( QDateTime::currentMSecsSinceEpoch() / 1000 + static_cast( expiresIn ) ); } } setLinked( true ); @@ -507,7 +500,7 @@ void QgsO2::refreshSynchronous() else { setToken( tokens.value( O2_OAUTH2_ACCESS_TOKEN ).toString() ); - setExpires( QDateTime::currentMSecsSinceEpoch() / 1000 + static_cast< qint64 >( tokens.value( O2_OAUTH2_EXPIRES_IN ).toInt() ) ); + setExpires( QDateTime::currentMSecsSinceEpoch() / 1000 + static_cast( tokens.value( O2_OAUTH2_EXPIRES_IN ).toInt() ) ); const QString refreshToken = tokens.value( O2_OAUTH2_REFRESH_TOKEN ).toString(); if ( !refreshToken.isEmpty() ) setRefreshToken( refreshToken ); @@ -528,5 +521,5 @@ void QgsO2::refreshSynchronous() void QgsO2::computeExpirationDelay() { const qint64 lExpires = expires(); - mExpirationDelay = static_cast< int >( lExpires > 0 ? lExpires - static_cast( QDateTime::currentMSecsSinceEpoch() / 1000 ) : 0 ); + mExpirationDelay = static_cast( lExpires > 0 ? lExpires - static_cast( QDateTime::currentMSecsSinceEpoch() / 1000 ) : 0 ); } diff --git a/src/auth/oauth2/core/qgso2.h b/src/auth/oauth2/core/qgso2.h index 6d3f2a6abf18..f17cef4ce5aa 100644 --- a/src/auth/oauth2/core/qgso2.h +++ b/src/auth/oauth2/core/qgso2.h @@ -25,13 +25,11 @@ class QgsAuthOAuth2Config; * \ingroup auth_plugins * \since QGIS 3.4 */ -class QgsO2: public O2 +class QgsO2 : public O2 { - Q_OBJECT public: - /** * Construct QgsO2 * \param authcfg authentication configuration id @@ -39,10 +37,7 @@ class QgsO2: public O2 * \param parent * \param manager QGIS network access manager instance */ - explicit QgsO2( const QString &authcfg, - QgsAuthOAuth2Config *oauth2config = nullptr, - QObject *parent = nullptr, - QNetworkAccessManager *manager = nullptr ); + explicit QgsO2( const QString &authcfg, QgsAuthOAuth2Config *oauth2config = nullptr, QObject *parent = nullptr, QNetworkAccessManager *manager = nullptr ); ~QgsO2() override; @@ -55,7 +50,7 @@ class QgsO2: public O2 Q_PROPERTY( QString state READ state WRITE setState NOTIFY stateChanged ) //! Retrieve oauth2 state - QString state() const { return state_; } + QString state() const { return state_; } //! Store oauth2 state to a random value when called void setState( const QString &value ); @@ -89,7 +84,6 @@ class QgsO2: public O2 void onVerificationReceived( QMap response ) override; protected: - QNetworkAccessManager *getManager() override; signals: @@ -101,7 +95,6 @@ class QgsO2: public O2 void getAuthCode(); private: - // block from calling externally -- this may be dangerous, we want to prevent // anyone from calling this from a different thread // Use instead QgsOAuth2Factory::requestLink diff --git a/src/auth/oauth2/gui/qgsauthoauth2edit.cpp b/src/auth/oauth2/gui/qgsauthoauth2edit.cpp index ff372b1ec0f6..5494ce16da70 100644 --- a/src/auth/oauth2/gui/qgsauthoauth2edit.cpp +++ b/src/auth/oauth2/gui/qgsauthoauth2edit.cpp @@ -56,8 +56,7 @@ QgsAuthOAuth2Edit::QgsAuthOAuth2Edit( QWidget *parent ) updatePredefinedLocationsTooltip(); pteDefinedDesc->setOpenLinks( false ); - connect( pteDefinedDesc, &QTextBrowser::anchorClicked, this, [ = ]( const QUrl & url ) - { + connect( pteDefinedDesc, &QTextBrowser::anchorClicked, this, [=]( const QUrl &url ) { QDesktopServices::openUrl( url ); } ); } @@ -164,27 +163,22 @@ void QgsAuthOAuth2Edit::setupConnections() connect( btnSoftStatementDir, &QToolButton::clicked, this, &QgsAuthOAuth2Edit::getSoftStatementDir ); connect( leSoftwareStatementJwtPath, &QLineEdit::textChanged, this, &QgsAuthOAuth2Edit::softwareStatementJwtPathChanged ); - connect( leSoftwareStatementConfigUrl, &QLineEdit::textChanged, this, [ = ]( const QString & txt ) - { - btnRegister->setEnabled( ! leSoftwareStatementJwtPath->text().isEmpty() - && ( QUrl( txt ).isValid() || ! mRegistrationEndpoint.isEmpty() ) ); + connect( leSoftwareStatementConfigUrl, &QLineEdit::textChanged, this, [=]( const QString &txt ) { + btnRegister->setEnabled( !leSoftwareStatementJwtPath->text().isEmpty() && ( QUrl( txt ).isValid() || !mRegistrationEndpoint.isEmpty() ) ); } ); connect( btnRegister, &QPushButton::clicked, this, &QgsAuthOAuth2Edit::getSoftwareStatementConfig ); // Custom config editing connections - connect( cmbbxGrantFlow, static_cast( &QComboBox::currentIndexChanged ), - this, &QgsAuthOAuth2Edit::updateGrantFlow ); // also updates GUI + connect( cmbbxGrantFlow, static_cast( &QComboBox::currentIndexChanged ), this, &QgsAuthOAuth2Edit::updateGrantFlow ); // also updates GUI connect( pteDescription, &QPlainTextEdit::textChanged, this, &QgsAuthOAuth2Edit::descriptionChanged ); connect( leRequestUrl, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setRequestUrl ); connect( leTokenUrl, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setTokenUrl ); connect( leRefreshTokenUrl, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setRefreshTokenUrl ); connect( leRedirectUrl, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setRedirectUrl ); - connect( comboRedirectHost, qOverload( &QComboBox::currentIndexChanged ), this, [ = ] - { + connect( comboRedirectHost, qOverload( &QComboBox::currentIndexChanged ), this, [=] { mOAuthConfigCustom->setRedirectHost( comboRedirectHost->currentData().toString() ); } ); - connect( spnbxRedirectPort, static_cast( &QSpinBox::valueChanged ), - mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setRedirectPort ); + connect( spnbxRedirectPort, static_cast( &QSpinBox::valueChanged ), mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setRedirectPort ); connect( leClientId, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setClientId ); connect( leClientSecret, &QgsPasswordLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setClientSecret ); connect( leUsername, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setUsername ); @@ -192,10 +186,8 @@ void QgsAuthOAuth2Edit::setupConnections() connect( leScope, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setScope ); connect( leApiKey, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setApiKey ); connect( chkbxTokenPersist, &QCheckBox::toggled, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setPersistToken ); - connect( cmbbxAccessMethod, static_cast( &QComboBox::currentIndexChanged ), - this, &QgsAuthOAuth2Edit::updateConfigAccessMethod ); - connect( spnbxRequestTimeout, static_cast( &QSpinBox::valueChanged ), - mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setRequestTimeout ); + connect( cmbbxAccessMethod, static_cast( &QComboBox::currentIndexChanged ), this, &QgsAuthOAuth2Edit::updateConfigAccessMethod ); + connect( spnbxRequestTimeout, static_cast( &QSpinBox::valueChanged ), mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setRequestTimeout ); connect( mTokenHeaderLineEdit, &QLineEdit::textChanged, mOAuthConfigCustom.get(), &QgsAuthOAuth2Config::setCustomHeader ); @@ -267,9 +259,7 @@ QgsStringMap QgsAuthOAuth2Edit::configMap() const { configmap.insert( QStringLiteral( "definedid" ), mDefinedId ); configmap.insert( QStringLiteral( "defineddirpath" ), leDefinedDirPath->text() ); - configmap.insert( QStringLiteral( "querypairs" ), - QgsAuthOAuth2Config::serializeFromVariant( - queryPairs(), QgsAuthOAuth2Config::JSON, false ) ); + configmap.insert( QStringLiteral( "querypairs" ), QgsAuthOAuth2Config::serializeFromVariant( queryPairs(), QgsAuthOAuth2Config::JSON, false ) ); } return configmap; @@ -336,8 +326,7 @@ void QgsAuthOAuth2Edit::loadConfig( const QgsStringMap &configmap ) const QByteArray querypairstxt = configmap.value( QStringLiteral( "querypairs" ) ).toUtf8(); if ( !querypairstxt.isNull() && !querypairstxt.isEmpty() ) { - const QVariantMap querypairsmap = - QgsAuthOAuth2Config::variantFromSerialized( querypairstxt, QgsAuthOAuth2Config::JSON, &ok ); + const QVariantMap querypairsmap = QgsAuthOAuth2Config::variantFromSerialized( querypairstxt, QgsAuthOAuth2Config::JSON, &ok ); if ( ok ) { populateQueryPairs( querypairsmap ); @@ -504,14 +493,10 @@ void QgsAuthOAuth2Edit::tabIndexChanged( int indx ) void QgsAuthOAuth2Edit::populateGrantFlows() { - cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::AuthCode ), - static_cast( QgsAuthOAuth2Config::AuthCode ) ); - cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::Implicit ), - static_cast( QgsAuthOAuth2Config::Implicit ) ); - cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::ResourceOwner ), - static_cast( QgsAuthOAuth2Config::ResourceOwner ) ); - cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::Pkce ), - static_cast( QgsAuthOAuth2Config::Pkce ) ); + cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::AuthCode ), static_cast( QgsAuthOAuth2Config::AuthCode ) ); + cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::Implicit ), static_cast( QgsAuthOAuth2Config::Implicit ) ); + cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::ResourceOwner ), static_cast( QgsAuthOAuth2Config::ResourceOwner ) ); + cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::Pkce ), static_cast( QgsAuthOAuth2Config::Pkce ) ); } @@ -593,8 +578,7 @@ void QgsAuthOAuth2Edit::selectCurrentDefinedConfig() void QgsAuthOAuth2Edit::getDefinedCustomDir() { - const QString extradir = QFileDialog::getExistingDirectory( this, tr( "Select extra directory to parse" ), - QDir::homePath(), QFileDialog::DontResolveSymlinks ); + const QString extradir = QFileDialog::getExistingDirectory( this, tr( "Select extra directory to parse" ), QDir::homePath(), QFileDialog::DontResolveSymlinks ); this->raise(); this->activateWindow(); @@ -607,8 +591,7 @@ void QgsAuthOAuth2Edit::getDefinedCustomDir() void QgsAuthOAuth2Edit::getSoftStatementDir() { - const QString softStatementFile = QFileDialog::getOpenFileName( this, tr( "Select software statement file" ), - QDir::homePath(), tr( "JSON Web Token (*.jwt)" ) ); + const QString softStatementFile = QFileDialog::getOpenFileName( this, tr( "Select software statement file" ), QDir::homePath(), tr( "JSON Web Token (*.jwt)" ) ); this->raise(); this->activateWindow(); @@ -636,8 +619,7 @@ bool QgsAuthOAuth2Edit::hasTokenCacheFile() return false; } - return ( QFile::exists( QgsAuthOAuth2Config::tokenCachePath( authcfg, false ) ) - || QFile::exists( QgsAuthOAuth2Config::tokenCachePath( authcfg, true ) ) ); + return ( QFile::exists( QgsAuthOAuth2Config::tokenCachePath( authcfg, false ) ) || QFile::exists( QgsAuthOAuth2Config::tokenCachePath( authcfg, true ) ) ); } //slot @@ -691,10 +673,10 @@ void QgsAuthOAuth2Edit::loadDefinedConfigs() const QString grantflow = QgsAuthOAuth2Config::grantFlowString( config->grantFlow() ); const QString name = QStringLiteral( "%1 (%2): %3" ) - .arg( config->name(), grantflow, config->description() ); + .arg( config->name(), grantflow, config->description() ); const QString tip = tr( "ID: %1\nGrant flow: %2\nDescription: %3" ) - .arg( i.key(), grantflow, config->description() ); + .arg( i.key(), grantflow, config->description() ); QListWidgetItem *itm = new QListWidgetItem( lstwdgDefinedConfigs ); itm->setText( name ); @@ -743,8 +725,7 @@ void QgsAuthOAuth2Edit::updateGrantFlow( int indx ) whileBlocking( cmbbxGrantFlow )->setCurrentIndex( indx ); } - const QgsAuthOAuth2Config::GrantFlow flow = - static_cast( cmbbxGrantFlow->itemData( indx ).toInt() ); + const QgsAuthOAuth2Config::GrantFlow flow = static_cast( cmbbxGrantFlow->itemData( indx ).toInt() ); mOAuthConfigCustom->setGrantFlow( flow ); // bool authcode = ( flow == QgsAuthOAuth2Config::AuthCode ); @@ -794,7 +775,8 @@ void QgsAuthOAuth2Edit::exportOAuthConfig() QSettings settings; const QString recentdir = settings.value( QStringLiteral( "UI/lastAuthSaveFileDir" ), QDir::homePath() ).toString(); const QString configpath = QFileDialog::getSaveFileName( - this, tr( "Save OAuth2 Config File" ), recentdir, QStringLiteral( "OAuth2 config files (*.json)" ) ); + this, tr( "Save OAuth2 Config File" ), recentdir, QStringLiteral( "OAuth2 config files (*.json)" ) + ); this->raise(); this->activateWindow(); @@ -814,8 +796,7 @@ void QgsAuthOAuth2Edit::exportOAuthConfig() mOAuthConfigCustom->setName( mParentName->text() ); } - if ( !QgsAuthOAuth2Config::writeOAuth2Config( configpath, mOAuthConfigCustom.get(), - QgsAuthOAuth2Config::JSON, true ) ) + if ( !QgsAuthOAuth2Config::writeOAuth2Config( configpath, mOAuthConfigCustom.get(), QgsAuthOAuth2Config::JSON, true ) ) { QgsDebugError( QStringLiteral( "FAILED to export OAuth2 config file" ) ); } @@ -832,8 +813,7 @@ void QgsAuthOAuth2Edit::importOAuthConfig() return; } - const QString configfile = - QgsAuthGuiUtils::getOpenFileName( this, tr( "Select OAuth2 Config File" ), QStringLiteral( "OAuth2 config files (*.json)" ) ); + const QString configfile = QgsAuthGuiUtils::getOpenFileName( this, tr( "Select OAuth2 Config File" ), QStringLiteral( "OAuth2 config files (*.json)" ) ); this->raise(); this->activateWindow(); @@ -878,12 +858,9 @@ void QgsAuthOAuth2Edit::descriptionChanged() void QgsAuthOAuth2Edit::populateAccessMethods() { - cmbbxAccessMethod->addItem( QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::Header ), - static_cast( QgsAuthOAuth2Config::Header ) ); - cmbbxAccessMethod->addItem( QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::Form ), - static_cast( QgsAuthOAuth2Config::Form ) ); - cmbbxAccessMethod->addItem( QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::Query ), - static_cast( QgsAuthOAuth2Config::Query ) ); + cmbbxAccessMethod->addItem( QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::Header ), static_cast( QgsAuthOAuth2Config::Header ) ); + cmbbxAccessMethod->addItem( QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::Form ), static_cast( QgsAuthOAuth2Config::Form ) ); + cmbbxAccessMethod->addItem( QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::Query ), static_cast( QgsAuthOAuth2Config::Query ) ); } @@ -958,8 +935,7 @@ QVariantMap QgsAuthOAuth2Edit::queryPairs() const { continue; } - querypairs.insert( tblwdgQueryPairs->item( i, 0 )->text(), - QVariant( tblwdgQueryPairs->item( i, 1 )->text() ) ); + querypairs.insert( tblwdgQueryPairs->item( i, 0 )->text(), QVariant( tblwdgQueryPairs->item( i, 1 )->text() ) ); } return querypairs; } @@ -982,7 +958,7 @@ void QgsAuthOAuth2Edit::removeQueryPair() void QgsAuthOAuth2Edit::clearQueryPairs() { - for ( int i = tblwdgQueryPairs->rowCount(); i > 0 ; --i ) + for ( int i = tblwdgQueryPairs->rowCount(); i > 0; --i ) { tblwdgQueryPairs->removeRow( i - 1 ); } @@ -1012,7 +988,7 @@ void QgsAuthOAuth2Edit::parseSoftwareStatement( const QString &path ) return; } const QByteArray payload = payloadParts[1]; - QByteArray decoded = QByteArray::fromBase64( payload/*, QByteArray::Base64UrlEncoding*/ ); + QByteArray decoded = QByteArray::fromBase64( payload /*, QByteArray::Base64UrlEncoding*/ ); QByteArray errStr; bool res = false; const QMap jsonData = QJsonWrapper::parseJson( decoded, &res, &errStr ).toMap(); @@ -1023,8 +999,8 @@ void QgsAuthOAuth2Edit::parseSoftwareStatement( const QString &path ) } if ( jsonData.contains( QStringLiteral( "grant_types" ) ) && jsonData.contains( QStringLiteral( "redirect_uris" ) ) ) { - const QStringList grantTypes( jsonData[QStringLiteral( "grant_types" ) ].toStringList() ); - if ( !grantTypes.isEmpty( ) ) + const QStringList grantTypes( jsonData[QStringLiteral( "grant_types" )].toStringList() ); + if ( !grantTypes.isEmpty() ) { const QString grantType = grantTypes[0]; if ( grantType == QLatin1String( "authorization_code" ) ) @@ -1037,8 +1013,8 @@ void QgsAuthOAuth2Edit::parseSoftwareStatement( const QString &path ) } } //Set redirect_uri - const QStringList redirectUris( jsonData[QStringLiteral( "redirect_uris" ) ].toStringList() ); - if ( !redirectUris.isEmpty( ) ) + const QStringList redirectUris( jsonData[QStringLiteral( "redirect_uris" )].toStringList() ); + if ( !redirectUris.isEmpty() ) { const QString redirectUri = redirectUris[0]; leRedirectUrl->setText( redirectUri ); @@ -1203,12 +1179,11 @@ void QgsAuthOAuth2Edit::updatePredefinedLocationsTooltip() locationListHtml += QLatin1String( "" ); const QString tip = QStringLiteral( "

    " ) + tr( "Defined configurations are JSON-formatted files, with a single configuration per file. " - "This allows configurations to be swapped out via filesystem tools without affecting user " - "configurations. It is recommended to use the Configure tab’s export function, then edit the " - "resulting file. See QGIS documentation for further details." ) + QStringLiteral( "

    " ) + - tr( "Configurations files can be placed in the directories:" ) + QStringLiteral( "

    " ) + locationListHtml; + "This allows configurations to be swapped out via filesystem tools without affecting user " + "configurations. It is recommended to use the Configure tab’s export function, then edit the " + "resulting file. See QGIS documentation for further details." ) + + QStringLiteral( "

    " ) + tr( "Configurations files can be placed in the directories:" ) + QStringLiteral( "

    " ) + locationListHtml; pteDefinedDesc->setHtml( tip ); lstwdgDefinedConfigs->setToolTip( tr( "Configuration files can be placed in the directories:\n\n%1" ).arg( locationList ) ); } - diff --git a/src/auth/oauth2/gui/qgsauthoauth2edit.h b/src/auth/oauth2/gui/qgsauthoauth2edit.h index 66ac76d74150..9db64bc4d9f0 100644 --- a/src/auth/oauth2/gui/qgsauthoauth2edit.h +++ b/src/auth/oauth2/gui/qgsauthoauth2edit.h @@ -34,7 +34,6 @@ class QgsAuthOAuth2Edit : public QgsAuthMethodEdit, private Ui::QgsAuthOAuth2Edi Q_OBJECT public: - //! Construct a QgsAuthOAuth2Edit instance explicit QgsAuthOAuth2Edit( QWidget *parent = nullptr ); @@ -126,7 +125,6 @@ class QgsAuthOAuth2Edit : public QgsAuthMethodEdit, private Ui::QgsAuthOAuth2Edi void networkError( QNetworkReply::NetworkError error ); private: - void initGui(); void parseSoftwareStatement( const QString &path ); diff --git a/src/auth/pkipaths/core/qgsauthpkipathsmethod.cpp b/src/auth/pkipaths/core/qgsauthpkipathsmethod.cpp index 790fa316076d..7676e1c7970e 100644 --- a/src/auth/pkipaths/core/qgsauthpkipathsmethod.cpp +++ b/src/auth/pkipaths/core/qgsauthpkipathsmethod.cpp @@ -49,12 +49,8 @@ QgsAuthPkiPathsMethod::QgsAuthPkiPathsMethod() { setVersion( 2 ); setExpansions( QgsAuthMethod::NetworkRequest | QgsAuthMethod::DataSourceUri ); - setDataProviders( QStringList() - << QStringLiteral( "ows" ) - << QStringLiteral( "wfs" ) // convert to lowercase - << QStringLiteral( "wcs" ) - << QStringLiteral( "wms" ) - << QStringLiteral( "postgres" ) ); + setDataProviders( QStringList() << QStringLiteral( "ows" ) << QStringLiteral( "wfs" ) // convert to lowercase + << QStringLiteral( "wcs" ) << QStringLiteral( "wms" ) << QStringLiteral( "postgres" ) ); } QgsAuthPkiPathsMethod::~QgsAuthPkiPathsMethod() @@ -82,8 +78,7 @@ QString QgsAuthPkiPathsMethod::displayDescription() const } -bool QgsAuthPkiPathsMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthPkiPathsMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { #ifndef QT_NO_SSL Q_UNUSED( dataprovider ) @@ -114,9 +109,9 @@ bool QgsAuthPkiPathsMethod::updateNetworkRequest( QNetworkRequest &request, cons sslConfig.setLocalCertificate( pkibundle->clientCert() ); // add extra CAs from the bundle - if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { - if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { sslConfig.setCaCertificates( pkibundle->caChain() ); } @@ -134,8 +129,7 @@ bool QgsAuthPkiPathsMethod::updateNetworkRequest( QNetworkRequest &request, cons } -bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider ) { #ifndef QT_NO_SSL Q_UNUSED( dataprovider ) @@ -155,8 +149,9 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte // save client cert to temp file const QString certFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - pkibundle->clientCert().toPem() ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + pkibundle->clientCert().toPem() + ); if ( certFilePath.isEmpty() ) { return false; @@ -164,8 +159,9 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte // save client cert key to temp file const QString keyFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - pkibundle->clientCertKey().toPem() ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + pkibundle->clientCertKey().toPem() + ); if ( keyFilePath.isEmpty() ) { return false; @@ -173,16 +169,15 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte // add extra CAs from the bundle QList cas; - if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { - if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), pkibundle->caChain() ); } else { - cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), - QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) ); + cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) ); } } else @@ -192,8 +187,9 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte // save CAs to temp file const QString caFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - QgsAuthCertUtils::certsToPemText( cas ) ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + QgsAuthCertUtils::certsToPemText( cas ) + ); if ( caFilePath.isEmpty() ) { return false; diff --git a/src/auth/pkipaths/core/qgsauthpkipathsmethod.h b/src/auth/pkipaths/core/qgsauthpkipathsmethod.h index d44fe644f80e..766a8face217 100644 --- a/src/auth/pkipaths/core/qgsauthpkipathsmethod.h +++ b/src/auth/pkipaths/core/qgsauthpkipathsmethod.h @@ -30,7 +30,6 @@ class QgsAuthPkiPathsMethod : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -45,22 +44,19 @@ class QgsAuthPkiPathsMethod : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; - bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: - #ifndef QT_NO_SSL QgsPkiConfigBundle *getPkiConfigBundle( const QString &authcfg ); @@ -70,7 +66,6 @@ class QgsAuthPkiPathsMethod : public QgsAuthMethod static QMap sPkiConfigBundleCache; #endif - }; @@ -80,7 +75,7 @@ class QgsAuthPkiPathsMethodMetadata : public QgsAuthMethodMetadata QgsAuthPkiPathsMethodMetadata() : QgsAuthMethodMetadata( QgsAuthPkiPathsMethod::AUTH_METHOD_KEY, QgsAuthPkiPathsMethod::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthPkiPathsMethod *createAuthMethod() const override {return new QgsAuthPkiPathsMethod;} + QgsAuthPkiPathsMethod *createAuthMethod() const override { return new QgsAuthPkiPathsMethod; } //QStringList supportedDataProviders() const override; }; diff --git a/src/auth/pkipaths/gui/qgsauthpkipathsedit.cpp b/src/auth/pkipaths/gui/qgsauthpkipathsedit.cpp index 3aa4581b3c4d..a256c519b70f 100644 --- a/src/auth/pkipaths/gui/qgsauthpkipathsedit.cpp +++ b/src/auth/pkipaths/gui/qgsauthpkipathsedit.cpp @@ -37,7 +37,7 @@ QgsAuthPkiPathsEdit::QgsAuthPkiPathsEdit( QWidget *parent ) setupUi( this ); connect( btnPkiPathsCert, &QToolButton::clicked, this, &QgsAuthPkiPathsEdit::btnPkiPathsCert_clicked ); connect( btnPkiPathsKey, &QToolButton::clicked, this, &QgsAuthPkiPathsEdit::btnPkiPathsKey_clicked ); - connect( cbAddCas, &QCheckBox::stateChanged, this, [ = ]( int state ) { cbAddRootCa->setEnabled( state == Qt::Checked ); } ); + connect( cbAddCas, &QCheckBox::stateChanged, this, [=]( int state ) { cbAddRootCa->setEnabled( state == Qt::Checked ); } ); lblCas->hide(); twCas->hide(); cbAddCas->hide(); @@ -74,9 +74,7 @@ bool QgsAuthPkiPathsEdit::validateConfig() const QDateTime startdate( cert.effectiveDate() ); const QDateTime enddate( cert.expiryDate() ); - writePkiMessage( lePkiPathsMsg, - tr( "%1 thru %2" ).arg( startdate.toString(), enddate.toString() ), - ( QgsAuthCertUtils::certIsCurrent( cert ) ? Valid : Invalid ) ); + writePkiMessage( lePkiPathsMsg, tr( "%1 thru %2" ).arg( startdate.toString(), enddate.toString() ), ( QgsAuthCertUtils::certIsCurrent( cert ) ? Valid : Invalid ) ); const bool certviable = QgsAuthCertUtils::certIsViable( cert ); const bool showCas( certviable && populateCas() ); @@ -94,8 +92,8 @@ QgsStringMap QgsAuthPkiPathsEdit::configMap() const config.insert( QStringLiteral( "certpath" ), lePkiPathsCert->text() ); config.insert( QStringLiteral( "keypath" ), lePkiPathsKey->text() ); config.insert( QStringLiteral( "keypass" ), lePkiPathsKeyPass->text() ); - config.insert( QStringLiteral( "addcas" ), cbAddCas->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); - config.insert( QStringLiteral( "addrootca" ), cbAddRootCa->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + config.insert( QStringLiteral( "addcas" ), cbAddCas->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + config.insert( QStringLiteral( "addrootca" ), cbAddRootCa->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); return config; } @@ -177,8 +175,7 @@ void QgsAuthPkiPathsEdit::clearPkiPathsKeyPass() void QgsAuthPkiPathsEdit::btnPkiPathsCert_clicked() { - const QString &fn = QgsAuthGuiUtils::getOpenFileName( this, tr( "Open Client Certificate File" ), - tr( "All files (*.*);;PEM (*.pem);;DER (*.der)" ) ); + const QString &fn = QgsAuthGuiUtils::getOpenFileName( this, tr( "Open Client Certificate File" ), tr( "All files (*.*);;PEM (*.pem);;DER (*.der)" ) ); if ( !fn.isEmpty() ) { lePkiPathsCert->setText( fn ); @@ -188,8 +185,7 @@ void QgsAuthPkiPathsEdit::btnPkiPathsCert_clicked() void QgsAuthPkiPathsEdit::btnPkiPathsKey_clicked() { - const QString &fn = QgsAuthGuiUtils::getOpenFileName( this, tr( "Open Private Key File" ), - tr( "All files (*.*);;PEM (*.pem);;DER (*.der)" ) ); + const QString &fn = QgsAuthGuiUtils::getOpenFileName( this, tr( "Open Private Key File" ), tr( "All files (*.*);;PEM (*.pem);;DER (*.der)" ) ); if ( !fn.isEmpty() ) { lePkiPathsKey->setText( fn ); @@ -234,7 +230,7 @@ bool QgsAuthPkiPathsEdit::populateCas() item = new QTreeWidgetItem( twCas, QStringList( cert.subjectInfo( QSslCertificate::SubjectInfo::CommonName ) ) ); } item->setIcon( 0, QgsApplication::getThemeIcon( QStringLiteral( "/mIconCertificate.svg" ) ) ); - item->setToolTip( 0, tr( "
    • Serial #: %1
    • Expiry date: %2
    " ).arg( cert.serialNumber( ), cert.expiryDate().toString( Qt::TextDate ) ) ); + item->setToolTip( 0, tr( "
    • Serial #: %1
    • Expiry date: %2
    " ).arg( cert.serialNumber(), cert.expiryDate().toString( Qt::TextDate ) ) ); prevItem = item; } twCas->expandAll(); diff --git a/src/auth/pkipkcs12/core/qgsauthpkcs12method.cpp b/src/auth/pkipkcs12/core/qgsauthpkcs12method.cpp index a6c09ed55891..965412c48c67 100644 --- a/src/auth/pkipkcs12/core/qgsauthpkcs12method.cpp +++ b/src/auth/pkipkcs12/core/qgsauthpkcs12method.cpp @@ -49,12 +49,8 @@ QgsAuthPkcs12Method::QgsAuthPkcs12Method() { setVersion( 2 ); setExpansions( QgsAuthMethod::NetworkRequest | QgsAuthMethod::DataSourceUri ); - setDataProviders( QStringList() - << QStringLiteral( "ows" ) - << QStringLiteral( "wfs" ) // convert to lowercase - << QStringLiteral( "wcs" ) - << QStringLiteral( "wms" ) - << QStringLiteral( "postgres" ) ); + setDataProviders( QStringList() << QStringLiteral( "ows" ) << QStringLiteral( "wfs" ) // convert to lowercase + << QStringLiteral( "wcs" ) << QStringLiteral( "wms" ) << QStringLiteral( "postgres" ) ); } QgsAuthPkcs12Method::~QgsAuthPkcs12Method() @@ -80,8 +76,7 @@ QString QgsAuthPkcs12Method::displayDescription() const return AUTH_METHOD_DISPLAY_DESCRIPTION; } -bool QgsAuthPkcs12Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthPkcs12Method::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider ) { #ifndef QT_NO_SSL Q_UNUSED( dataprovider ) @@ -112,9 +107,9 @@ bool QgsAuthPkcs12Method::updateNetworkRequest( QNetworkRequest &request, const sslConfig.setPrivateKey( pkibundle->clientCertKey() ); // add extra CAs from the bundle, QNAM will prepend the trusted CAs in createRequest() - if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { - if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { sslConfig.setCaCertificates( pkibundle->caChain() ); } @@ -132,8 +127,7 @@ bool QgsAuthPkcs12Method::updateNetworkRequest( QNetworkRequest &request, const #endif } -bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider ) +bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider ) { #ifndef QT_NO_SSL Q_UNUSED( dataprovider ) @@ -154,8 +148,9 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems // save client cert to temp file const QString certFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - pkibundle->clientCert().toPem() ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + pkibundle->clientCert().toPem() + ); if ( certFilePath.isEmpty() ) { return false; @@ -163,8 +158,9 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems // save client cert key to temp file const QString keyFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - pkibundle->clientCertKey().toPem() ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + pkibundle->clientCertKey().toPem() + ); if ( keyFilePath.isEmpty() ) { return false; @@ -172,16 +168,15 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems // add extra CAs from the bundle QList cas; - if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addcas" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { - if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) + if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) ) { cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), pkibundle->caChain() ); } else { - cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), - QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) ); + cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) ); } } else @@ -191,8 +186,9 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems // save CAs to temp file const QString caFilePath = QgsAuthCertUtils::pemTextToTempFile( - pkiTempFileBase.arg( QUuid::createUuid().toString() ), - QgsAuthCertUtils::certsToPemText( cas ) ); + pkiTempFileBase.arg( QUuid::createUuid().toString() ), + QgsAuthCertUtils::certsToPemText( cas ) + ); if ( caFilePath.isEmpty() ) { @@ -307,8 +303,7 @@ QgsPkiConfigBundle *QgsAuthPkcs12Method::getPkiConfigBundle( const QString &auth return bundle; } - const QStringList bundlelist = QgsAuthCertUtils::pkcs12BundleToPem( mconfig.config( QStringLiteral( "bundlepath" ) ), - mconfig.config( QStringLiteral( "bundlepass" ) ), false ); + const QStringList bundlelist = QgsAuthCertUtils::pkcs12BundleToPem( mconfig.config( QStringLiteral( "bundlepath" ) ), mconfig.config( QStringLiteral( "bundlepass" ) ), false ); if ( bundlelist.isEmpty() || bundlelist.size() < 2 ) { @@ -331,11 +326,7 @@ QgsPkiConfigBundle *QgsAuthPkcs12Method::getPkiConfigBundle( const QString &auth // .arg( !mconfig.config( QStringLiteral( "bundlepass" ) ).isNull() ? mconfig.config( QStringLiteral( "bundlepass" ) ) : QString() ), 2 ); // init key - const QSslKey clientkey( bundlelist.at( 1 ).toLatin1(), - QSsl::Rsa, - QSsl::Pem, - QSsl::PrivateKey, - !mconfig.config( QStringLiteral( "bundlepass" ) ).isNull() ? mconfig.config( QStringLiteral( "bundlepass" ) ).toUtf8() : QByteArray() ); + const QSslKey clientkey( bundlelist.at( 1 ).toLatin1(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, !mconfig.config( QStringLiteral( "bundlepass" ) ).isNull() ? mconfig.config( QStringLiteral( "bundlepass" ) ).toUtf8() : QByteArray() ); if ( clientkey.isNull() ) @@ -344,10 +335,7 @@ QgsPkiConfigBundle *QgsAuthPkcs12Method::getPkiConfigBundle( const QString &auth return bundle; } - bundle = new QgsPkiConfigBundle( mconfig, clientcert, clientkey, - QgsAuthCertUtils::pkcs12BundleCas( - mconfig.config( QStringLiteral( "bundlepath" ) ), - mconfig.config( QStringLiteral( "bundlepass" ) ) ) ); + bundle = new QgsPkiConfigBundle( mconfig, clientcert, clientkey, QgsAuthCertUtils::pkcs12BundleCas( mconfig.config( QStringLiteral( "bundlepath" ) ), mconfig.config( QStringLiteral( "bundlepass" ) ) ) ); locker.unlock(); // cache bundle diff --git a/src/auth/pkipkcs12/core/qgsauthpkcs12method.h b/src/auth/pkipkcs12/core/qgsauthpkcs12method.h index 56aa887566df..9ef21ff009c5 100644 --- a/src/auth/pkipkcs12/core/qgsauthpkcs12method.h +++ b/src/auth/pkipkcs12/core/qgsauthpkcs12method.h @@ -30,7 +30,6 @@ class QgsAuthPkcs12Method : public QgsAuthMethod Q_OBJECT public: - static const QString AUTH_METHOD_KEY; static const QString AUTH_METHOD_DESCRIPTION; static const QString AUTH_METHOD_DISPLAY_DESCRIPTION; @@ -45,23 +44,20 @@ class QgsAuthPkcs12Method : public QgsAuthMethod QString displayDescription() const override; - bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateNetworkRequest( QNetworkRequest &request, const QString &authcfg, const QString &dataprovider = QString() ) override; - bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, - const QString &dataprovider = QString() ) override; + bool updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg, const QString &dataprovider = QString() ) override; void clearCachedConfig( const QString &authcfg ) override; void updateMethodConfig( QgsAuthMethodConfig &mconfig ) override; #ifdef HAVE_GUI - QWidget *editWidget( QWidget *parent )const override; + QWidget *editWidget( QWidget *parent ) const override; #endif private: - #ifndef QT_NO_SSL QgsPkiConfigBundle *getPkiConfigBundle( const QString &authcfg ); @@ -71,7 +67,6 @@ class QgsAuthPkcs12Method : public QgsAuthMethod static QMap sPkiConfigBundleCache; #endif - }; @@ -81,7 +76,7 @@ class QgsAuthPkcs12MethodMetadata : public QgsAuthMethodMetadata QgsAuthPkcs12MethodMetadata() : QgsAuthMethodMetadata( QgsAuthPkcs12Method::AUTH_METHOD_KEY, QgsAuthPkcs12Method::AUTH_METHOD_DESCRIPTION ) {} - QgsAuthPkcs12Method *createAuthMethod() const override {return new QgsAuthPkcs12Method;} + QgsAuthPkcs12Method *createAuthMethod() const override { return new QgsAuthPkcs12Method; } //QStringList supportedDataProviders() const override; }; diff --git a/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.cpp b/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.cpp index 7571448b802f..c5ada543ebd6 100644 --- a/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.cpp +++ b/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.cpp @@ -36,7 +36,7 @@ QgsAuthPkcs12Edit::QgsAuthPkcs12Edit( QWidget *parent ) setupUi( this ); connect( lePkcs12KeyPass, &QLineEdit::textChanged, this, &QgsAuthPkcs12Edit::lePkcs12KeyPass_textChanged ); connect( btnPkcs12Bundle, &QToolButton::clicked, this, &QgsAuthPkcs12Edit::btnPkcs12Bundle_clicked ); - connect( cbAddCas, &QCheckBox::stateChanged, this, [ = ]( int state ) { cbAddRootCa->setEnabled( state == Qt::Checked ); } ); + connect( cbAddCas, &QCheckBox::stateChanged, this, [=]( int state ) { cbAddRootCa->setEnabled( state == Qt::Checked ); } ); lblCas->hide(); twCas->hide(); cbAddCas->hide(); @@ -109,9 +109,7 @@ bool QgsAuthPkcs12Edit::validateConfig() const QDateTime now( QDateTime::currentDateTime() ); const bool bundlevalid = ( now >= startdate && now <= enddate ); - writePkiMessage( lePkcs12Msg, - tr( "%1 thru %2" ).arg( startdate.toString(), enddate.toString() ), - ( bundlevalid ? Valid : Invalid ) ); + writePkiMessage( lePkcs12Msg, tr( "%1 thru %2" ).arg( startdate.toString(), enddate.toString() ), ( bundlevalid ? Valid : Invalid ) ); const bool showCas( bundlevalid && populateCas() ); lblCas->setVisible( showCas ); @@ -127,8 +125,8 @@ QgsStringMap QgsAuthPkcs12Edit::configMap() const QgsStringMap config; config.insert( QStringLiteral( "bundlepath" ), lePkcs12Bundle->text() ); config.insert( QStringLiteral( "bundlepass" ), lePkcs12KeyPass->text() ); - config.insert( QStringLiteral( "addcas" ), cbAddCas->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); - config.insert( QStringLiteral( "addrootca" ), cbAddRootCa->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + config.insert( QStringLiteral( "addcas" ), cbAddCas->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + config.insert( QStringLiteral( "addrootca" ), cbAddRootCa->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); return config; } @@ -209,8 +207,7 @@ void QgsAuthPkcs12Edit::lePkcs12KeyPass_textChanged( const QString &pass ) void QgsAuthPkcs12Edit::btnPkcs12Bundle_clicked() { - const QString &fn = QgsAuthGuiUtils::getOpenFileName( this, tr( "Open PKCS#12 Certificate Bundle" ), - tr( "PKCS#12 (*.p12 *.pfx)" ) ); + const QString &fn = QgsAuthGuiUtils::getOpenFileName( this, tr( "Open PKCS#12 Certificate Bundle" ), tr( "PKCS#12 (*.p12 *.pfx)" ) ); if ( !fn.isEmpty() ) { lePkcs12Bundle->setText( fn ); @@ -255,7 +252,7 @@ bool QgsAuthPkcs12Edit::populateCas() item = new QTreeWidgetItem( twCas, QStringList( cert.subjectInfo( QSslCertificate::SubjectInfo::CommonName ) ) ); } item->setIcon( 0, QgsApplication::getThemeIcon( QStringLiteral( "/mIconCertificate.svg" ) ) ); - item->setToolTip( 0, tr( "
    • Serial #: %1
    • Expiry date: %2
    " ).arg( cert.serialNumber( ), cert.expiryDate().toString( Qt::TextDate ) ) ); + item->setToolTip( 0, tr( "
    • Serial #: %1
    • Expiry date: %2
    " ).arg( cert.serialNumber(), cert.expiryDate().toString( Qt::TextDate ) ) ); prevItem = item; } twCas->expandAll(); diff --git a/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.h b/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.h index 364473b43eb0..267bc5db5ba2 100644 --- a/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.h +++ b/src/auth/pkipkcs12/gui/qgsauthpkcs12edit.h @@ -63,7 +63,7 @@ class QgsAuthPkcs12Edit : public QgsAuthMethodEdit, private Ui::QgsAuthPkcs12Edi private: bool validityChange( bool curvalid ); - bool populateCas( ); + bool populateCas(); QgsStringMap mConfigMap; bool mValid = false; diff --git a/src/crashhandler/qgscrashdialog.cpp b/src/crashhandler/qgscrashdialog.cpp index f5dea75c9dc8..7bb17f1e40dd 100644 --- a/src/crashhandler/qgscrashdialog.cpp +++ b/src/crashhandler/qgscrashdialog.cpp @@ -39,15 +39,14 @@ QgsCrashDialog::QgsCrashDialog( QWidget *parent ) mCrashMessage->setText( tr( "Oh dear! Something unexpected happened and QGIS ended without being able to handle the error gracefully." "

    " ) - + tr( "Are you keen to help us fix bugs? QGIS relies on donations to pay developers to do funded bug fixing to improve the stability of the software. " - "We also have a team of enthusiastic volunteers who are all working hard to improve the quality of QGIS. To do that, we need your help. " - "Find out how to help our developers." - "

    " - "Send us a helpful bug report by using the 'Copy Report' button below,
    then open a ticket on the " - "QGIS Issue Tracker." ) ); + + tr( "Are you keen to help us fix bugs? QGIS relies on donations to pay developers to do funded bug fixing to improve the stability of the software. " + "We also have a team of enthusiastic volunteers who are all working hard to improve the quality of QGIS. To do that, we need your help. " + "Find out how to help our developers." + "

    " + "Send us a helpful bug report by using the 'Copy Report' button below,
    then open a ticket on the " + "QGIS Issue Tracker." ) ); mCrashMessage->setTextInteractionFlags( Qt::TextBrowserInteraction ); mCrashMessage->setOpenExternalLinks( true ); - } void QgsCrashDialog::setBugReport( const QString &reportData ) @@ -72,18 +71,14 @@ void QgsCrashDialog::setPythonFault( const QgsCrashReport::PythonFault &fault ) case QgsCrashReport::LikelyPythonFaultCause::ProcessingScript: mCrashHeaderMessage->setText( tr( "A user script crashed QGIS" ).arg( fault.title ) ); - mCrashMessage->setText( tr( "This user script %1 caused QGIS to crash." ).arg( fault.filePath ) - + "

    " - + tr( "This is a third party custom script, and this issue should be reported to the author of that script." ) ); + mCrashMessage->setText( tr( "This user script %1 caused QGIS to crash." ).arg( fault.filePath ) + "

    " + tr( "This is a third party custom script, and this issue should be reported to the author of that script." ) ); splitter->setSizes( { 0, splitter->width() } ); mCopyReportButton->setEnabled( true ); break; case QgsCrashReport::LikelyPythonFaultCause::Plugin: mCrashHeaderMessage->setText( tr( "Plugin %1 crashed QGIS" ).arg( fault.title ) ); - mCrashMessage->setText( tr( "The plugin %1 caused QGIS to crash." ).arg( fault.title ) - + "

    " - + tr( "Please report this issue to the author of this plugin." ) ); + mCrashMessage->setText( tr( "The plugin %1 caused QGIS to crash." ).arg( fault.title ) + "

    " + tr( "Please report this issue to the author of this plugin." ) ); splitter->setSizes( { 0, splitter->width() } ); mCopyReportButton->setEnabled( true ); break; @@ -103,9 +98,7 @@ void QgsCrashDialog::showReportWidget() void QgsCrashDialog::userFeedbackText_textChanged() { - mCopyReportButton->setEnabled( !mUserFeedbackText->toPlainText().isEmpty() - || ( mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::NotPython - && mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::Unknown ) ); + mCopyReportButton->setEnabled( !mUserFeedbackText->toPlainText().isEmpty() || ( mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::NotPython && mPythonFault.cause != QgsCrashReport::LikelyPythonFaultCause::Unknown ) ); } QStringList QgsCrashDialog::splitCommand( const QString &command ) @@ -118,8 +111,8 @@ void QgsCrashDialog::createBugReport() QClipboard *clipboard = QApplication::clipboard(); const QString userText = !mUserFeedbackText->toPlainText().isEmpty() - ? ( "## User Feedback\n\n" + mUserFeedbackText->toPlainText() ) - : QString(); + ? ( "## User Feedback\n\n" + mUserFeedbackText->toPlainText() ) + : QString(); const QString details = "## Report Details\n\n" + mReportData; const QString finalText = ( !userText.isEmpty() ? ( userText + "\n\n" ) : QString() ) + details; diff --git a/src/crashhandler/qgscrashdialog.h b/src/crashhandler/qgscrashdialog.h index 2856d509abed..c95aa40ec209 100644 --- a/src/crashhandler/qgscrashdialog.h +++ b/src/crashhandler/qgscrashdialog.h @@ -33,7 +33,6 @@ class QgsCrashDialog : public QDialog, private Ui::QgsCrashDialog { Q_OBJECT public: - /** * A dialog to show a nicer crash dialog to the user. */ diff --git a/src/crashhandler/qgscrashreport.cpp b/src/crashhandler/qgscrashreport.cpp index ab86ad011a00..dc58aa48bd57 100644 --- a/src/crashhandler/qgscrashreport.cpp +++ b/src/crashhandler/qgscrashreport.cpp @@ -258,9 +258,7 @@ void QgsCrashReport::exportToCrashFolder() QString QgsCrashReport::crashReportFolder() { - return QStandardPaths::standardLocations( QStandardPaths::AppLocalDataLocation ).value( 0 ) + - "/crashes/" + - QUuid::createUuid().toString().replace( "{", "" ).replace( "}", "" ); + return QStandardPaths::standardLocations( QStandardPaths::AppLocalDataLocation ).value( 0 ) + "/crashes/" + QUuid::createUuid().toString().replace( "{", "" ).replace( "}", "" ); } void QgsCrashReport::setPythonCrashLogFilePath( const QString &path ) diff --git a/src/crashhandler/qgscrashreport.h b/src/crashhandler/qgscrashreport.h index ecc293f6ac0f..eafe2c309595 100644 --- a/src/crashhandler/qgscrashreport.h +++ b/src/crashhandler/qgscrashreport.h @@ -28,7 +28,6 @@ class QgsCrashReport { public: - /** * Include information to generate user friendly crash report for QGIS. */ @@ -37,12 +36,12 @@ class QgsCrashReport public: enum Flag { - Stack = 1 << 0, - Plugins = 1 << 1, - ProjectDetails = 1 << 2, - SystemInfo = 1 << 3, - QgisInfo = 1 << 4, - All = Stack | Plugins | ProjectDetails | SystemInfo | QgisInfo + Stack = 1 << 0, + Plugins = 1 << 1, + ProjectDetails = 1 << 2, + SystemInfo = 1 << 3, + QgisInfo = 1 << 4, + All = Stack | Plugins | ProjectDetails | SystemInfo | QgisInfo }; Q_DECLARE_FLAGS( Flags, Flag ) @@ -105,7 +104,6 @@ class QgsCrashReport class PythonFault { public: - LikelyPythonFaultCause cause = LikelyPythonFaultCause::NotPython; QString title; QString filePath; diff --git a/src/crashhandler/qgsstacktrace.cpp b/src/crashhandler/qgsstacktrace.cpp index 56936bb774e8..c4bd41b1ee82 100644 --- a/src/crashhandler/qgsstacktrace.cpp +++ b/src/crashhandler/qgsstacktrace.cpp @@ -65,19 +65,19 @@ enum BasicType btHresult = 31, }; -#define WIDEN_(x) L ## x -#define WIDEN(x) WIDEN_(x) +#define WIDEN_( x ) L##x +#define WIDEN( x ) WIDEN_( x ) typedef struct _StackTrace { - wchar_t message[2 * 1024 * 1024]; - int written; - HANDLE process; - HANDLE thread; - PCONTEXT contextRecord; - STACKFRAME64 currentStackFrame; - bool isFirstParameter; - LPVOID scratchSpace; + wchar_t message[2 * 1024 * 1024]; + int written; + HANDLE process; + HANDLE thread; + PCONTEXT contextRecord; + STACKFRAME64 currentStackFrame; + bool isFirstParameter; + LPVOID scratchSpace; } StackTrace; bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeIndex, void *valueLocation, bool whilePrintingPointer ) @@ -97,13 +97,11 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI char value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"'%c'", value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"'%c'", value ); } else { - char *value = ( char * )valueLocation; + char *value = ( char * ) valueLocation; MEMORY_BASIC_INFORMATION pageInfo = { 0 }; if ( VirtualQueryEx( stackTrace->process, value, &pageInfo, sizeof( pageInfo ) ) == 0 ) @@ -111,15 +109,13 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI return false; } - PVOID pageEndAddress = ( char * )pageInfo.BaseAddress + pageInfo.RegionSize; + PVOID pageEndAddress = ( char * ) pageInfo.BaseAddress + pageInfo.RegionSize; - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"\"" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"\"" ); for ( int charsWritten = 0; charsWritten < 100; ) { - if ( ( void * )value < pageEndAddress ) + if ( ( void * ) value < pageEndAddress ) { char next; ReadProcessMemory( stackTrace->process, value, &next, sizeof( next ), NULL ); @@ -128,16 +124,12 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI { if ( charsWritten == 100 - 1 ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"..." ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"..." ); break; } else { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%c", next ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%c", next ); charsWritten++; value++; } @@ -151,19 +143,15 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI { if ( VirtualQueryEx( stackTrace->process, pageEndAddress, &pageInfo, sizeof( pageInfo ) ) == 0 ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"" ); break; } - pageEndAddress = ( char * )pageInfo.BaseAddress + pageInfo.RegionSize; + pageEndAddress = ( char * ) pageInfo.BaseAddress + pageInfo.RegionSize; } } - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"\"" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"\"" ); } break; @@ -176,13 +164,11 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI wchar_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"'%lc'", value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"'%lc'", value ); } else { - wchar_t *value = ( wchar_t * )valueLocation; + wchar_t *value = ( wchar_t * ) valueLocation; MEMORY_BASIC_INFORMATION pageInfo = { 0 }; if ( VirtualQueryEx( stackTrace->process, value, &pageInfo, sizeof( pageInfo ) ) == 0 ) @@ -190,15 +176,13 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI return false; } - PVOID pageEndAddress = ( char * )pageInfo.BaseAddress + pageInfo.RegionSize; + PVOID pageEndAddress = ( char * ) pageInfo.BaseAddress + pageInfo.RegionSize; - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"L\"" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"L\"" ); for ( int charsWritten = 0; charsWritten < 100; ) { - if ( ( void * )( ( char * )value + 1 ) < pageEndAddress ) + if ( ( void * ) ( ( char * ) value + 1 ) < pageEndAddress ) { wchar_t next; ReadProcessMemory( stackTrace->process, value, &next, sizeof( next ), NULL ); @@ -207,16 +191,12 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI { if ( charsWritten == 100 - 1 ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"..." ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"..." ); break; } else { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%lc", next ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%lc", next ); charsWritten++; value++; } @@ -230,19 +210,15 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI { if ( VirtualQueryEx( stackTrace->process, pageEndAddress, &pageInfo, sizeof( pageInfo ) ) == 0 ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"" ); break; } - pageEndAddress = ( char * )pageInfo.BaseAddress + pageInfo.RegionSize; + pageEndAddress = ( char * ) pageInfo.BaseAddress + pageInfo.RegionSize; } } - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"\"" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"\"" ); } break; @@ -258,47 +234,39 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI switch ( length ) { - case sizeof( int8_t ) : + case sizeof( int8_t ): { int8_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRId8 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRId8 ), value ); break; } - case sizeof( int16_t ) : + case sizeof( int16_t ): { int16_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRId16 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRId16 ), value ); break; } - case sizeof( int32_t ) : + case sizeof( int32_t ): { int32_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRId32 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRId32 ), value ); break; } - case sizeof( int64_t ) : + case sizeof( int64_t ): { int64_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRId64 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRId64 ), value ); break; } @@ -322,47 +290,39 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI switch ( length ) { - case sizeof( uint8_t ) : + case sizeof( uint8_t ): { uint8_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRIu8 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRIu8 ), value ); break; } - case sizeof( uint16_t ) : + case sizeof( uint16_t ): { uint16_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRIu16 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRIu16 ), value ); break; } - case sizeof( uint32_t ) : + case sizeof( uint32_t ): { uint32_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRIu32 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRIu32 ), value ); break; } - case sizeof( uint64_t ) : + case sizeof( uint64_t ): { uint64_t value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%" WIDEN( PRIu64 ), value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%" WIDEN( PRIu64 ), value ); break; } @@ -381,9 +341,7 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI float value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%f", value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%f", value ); break; } @@ -392,9 +350,7 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI long value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%ld", value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%ld", value ); break; } @@ -403,9 +359,7 @@ bool printBasicType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, ULONG typeI unsigned long value; ReadProcessMemory( stackTrace->process, valueLocation, &value, sizeof( value ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%lu", value ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%lu", value ); break; } @@ -439,15 +393,11 @@ bool printGivenType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, enum SymTag ReadProcessMemory( stackTrace->process, valueLocation, &pointedValueLocation, sizeof( pointedValueLocation ), NULL ); - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"0x%p -> ", pointedValueLocation ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"0x%p -> ", pointedValueLocation ); - if ( pointedValueLocation < ( void * )0x1000 ) + if ( pointedValueLocation < ( void * ) 0x1000 ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"?" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"?" ); break; } @@ -471,9 +421,9 @@ bool printGivenType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, enum SymTag for ( ;; ) { - PVOID pageEndAddress = ( char * )pageInfo.BaseAddress + pageInfo.RegionSize; + PVOID pageEndAddress = ( char * ) pageInfo.BaseAddress + pageInfo.RegionSize; - if ( ( void * )( ( char * )pointedValueLocation + pointedTypeLength ) >= pageEndAddress ) + if ( ( void * ) ( ( char * ) pointedValueLocation + pointedTypeLength ) >= pageEndAddress ) { if ( VirtualQueryEx( stackTrace->process, pageEndAddress, &pageInfo, sizeof( pageInfo ) ) == 0 ) { @@ -519,44 +469,35 @@ bool printType( StackTrace *stackTrace, PSYMBOL_INFOW pSymInfo, void *valueLocat BOOL CALLBACK enumParams( _In_ PSYMBOL_INFOW pSymInfo, _In_ ULONG SymbolSize, - _In_opt_ PVOID UserContext ) + _In_opt_ PVOID UserContext +) { if ( ( pSymInfo->Flags & SYMFLAG_LOCAL ) == 0 ) { return TRUE; } - StackTrace *stackTrace = ( StackTrace * )UserContext; + StackTrace *stackTrace = ( StackTrace * ) UserContext; - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"\n" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"\n" ); if ( pSymInfo->Flags & SYMFLAG_PARAMETER ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"Parm: " ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"Parm: " ); } else if ( pSymInfo->Flags & SYMFLAG_LOCAL ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"Local: " ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"Local: " ); } - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"%ls = ", pSymInfo->Name ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"%ls = ", pSymInfo->Name ); void *valueLocation = NULL; if ( pSymInfo->Flags & SYMFLAG_REGISTER ) { if ( stackTrace->scratchSpace == NULL ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"" ); return TRUE; } @@ -620,18 +561,16 @@ BOOL CALLBACK enumParams( #endif default: - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"", pSymInfo->Register ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"", pSymInfo->Register ); return TRUE; } } else if ( pSymInfo->Flags & SYMFLAG_LOCAL ) { #ifndef _WIN64 - valueLocation = ( ( char * )stackTrace->contextRecord->Ebp ) + pSymInfo->Address; + valueLocation = ( ( char * ) stackTrace->contextRecord->Ebp ) + pSymInfo->Address; #else - valueLocation = ( ( char * )stackTrace->contextRecord->Rbp ) + pSymInfo->Address; + valueLocation = ( ( char * ) stackTrace->contextRecord->Rbp ) + pSymInfo->Address; #endif } else if ( pSymInfo->Flags & SYMFLAG_REGREL ) @@ -640,34 +579,30 @@ BOOL CALLBACK enumParams( { #ifndef _WIN64 case 22: - valueLocation = ( ( char * )stackTrace->contextRecord->Ebp ) + pSymInfo->Address; + valueLocation = ( ( char * ) stackTrace->contextRecord->Ebp ) + pSymInfo->Address; break; #else case 334: - valueLocation = ( ( char * )stackTrace->contextRecord->Rbp ) + pSymInfo->Address; + valueLocation = ( ( char * ) stackTrace->contextRecord->Rbp ) + pSymInfo->Address; break; case 335: - valueLocation = ( ( char * )stackTrace->contextRecord->Rsp ) + 0x20 + pSymInfo->Address; + valueLocation = ( ( char * ) stackTrace->contextRecord->Rsp ) + 0x20 + pSymInfo->Address; break; #endif default: - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"", pSymInfo->Register ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"", pSymInfo->Register ); return TRUE; } } else { - valueLocation = ( void * )( stackTrace->currentStackFrame.AddrFrame.Offset + pSymInfo->Address ); + valueLocation = ( void * ) ( stackTrace->currentStackFrame.AddrFrame.Offset + pSymInfo->Address ); } if ( !printType( stackTrace, pSymInfo, valueLocation ) ) { - stackTrace->written += - swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"?" ); + stackTrace->written += swprintf_s( stackTrace->message + stackTrace->written, sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"?" ); } return TRUE; @@ -680,8 +615,7 @@ void GetLastErrorAsString() DWORD errorMessageID = ::GetLastError(); LPSTR messageBuffer = nullptr; - size_t size = FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errorMessageID, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), ( LPSTR )&messageBuffer, 0, NULL ); + size_t size = FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorMessageID, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), ( LPSTR ) &messageBuffer, 0, NULL ); std::string message( messageBuffer, size ); @@ -701,7 +635,7 @@ void getStackTrace( StackTrace *stackTrace, QString symbolPath, QgsStackTrace *t } trace->symbolsLoaded = true; - SYMBOL_INFOW *symbol = ( SYMBOL_INFOW * )calloc( sizeof( *symbol ) + 256 * sizeof( wchar_t ), 1 ); + SYMBOL_INFOW *symbol = ( SYMBOL_INFOW * ) calloc( sizeof( *symbol ) + 256 * sizeof( wchar_t ), 1 ); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof( SYMBOL_INFOW ); @@ -711,17 +645,9 @@ void getStackTrace( StackTrace *stackTrace, QString symbolPath, QgsStackTrace *t DWORD machineType = IMAGE_FILE_MACHINE_AMD64; #endif - for ( int i = 0; ; i++ ) + for ( int i = 0;; i++ ) { - if ( !StackWalk64( machineType, - stackTrace->process, - stackTrace->thread, - &stackTrace->currentStackFrame, - stackTrace->contextRecord, - NULL, - SymFunctionTableAccess64, - SymGetModuleBase64, - NULL ) ) + if ( !StackWalk64( machineType, stackTrace->process, stackTrace->thread, &stackTrace->currentStackFrame, stackTrace->contextRecord, NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL ) ) { break; } @@ -731,9 +657,7 @@ void getStackTrace( StackTrace *stackTrace, QString symbolPath, QgsStackTrace *t QgsStackTrace::StackLine stackline; stackline.symbolName = QString::fromWCharArray( symbol->Name ); - stackTrace->written += - swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written - 1, - L">%02i: 0x%08llX %ls", i, symbol->Address, symbol->Name ); + stackTrace->written += swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written - 1, L">%02i: 0x%08llX %ls", i, symbol->Address, symbol->Name ); IMAGEHLP_STACK_FRAME stackFrame = { 0 }; stackFrame.InstructionOffset = symbol->Address; @@ -751,22 +675,16 @@ void getStackTrace( StackTrace *stackTrace, QString symbolPath, QgsStackTrace *t stackline.fileName = QString::fromWCharArray( lineInfo.FileName ); stackline.lineNumber = QString::number( lineInfo.LineNumber ); - stackTrace->written += - swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"\nSource: %ls:%lu", lineInfo.FileName, lineInfo.LineNumber ); + stackTrace->written += swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"\nSource: %ls:%lu", lineInfo.FileName, lineInfo.LineNumber ); } - stackTrace->written += - swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L"\n" ); + stackTrace->written += swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L"\n" ); trace->lines.append( stackline ); } else { - stackTrace->written += - swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, - L">%02i: 0x%08llX ?\n", i, stackTrace->currentStackFrame.AddrPC.Offset ); + stackTrace->written += swprintf_s( &stackTrace->message[stackTrace->written], sizeof( stackTrace->message ) / sizeof( stackTrace->message[0] ) - stackTrace->written, L">%02i: 0x%08llX ?\n", i, stackTrace->currentStackFrame.AddrPC.Offset ); } } @@ -781,7 +699,7 @@ QgsStackTrace *QgsStackTrace::trace( DWORD processId, DWORD threadId, LPEXCEPTIO EXCEPTION_POINTERS remoteException = { 0 }; CONTEXT remoteContextRecord = { 0 }; - StackTrace *stackTrace = ( StackTrace * )calloc( sizeof( *stackTrace ), 1 ); + StackTrace *stackTrace = ( StackTrace * ) calloc( sizeof( *stackTrace ), 1 ); stackTrace->process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, processId ); stackTrace->thread = OpenThread( THREAD_ALL_ACCESS, FALSE, threadId ); trace->process = stackTrace->process; @@ -796,8 +714,7 @@ QgsStackTrace *QgsStackTrace::trace( DWORD processId, DWORD threadId, LPEXCEPTIO { do { - if ( te.dwSize >= FIELD_OFFSET( THREADENTRY32, th32OwnerProcessID ) + - sizeof( te.th32OwnerProcessID ) ) + if ( te.dwSize >= FIELD_OFFSET( THREADENTRY32, th32OwnerProcessID ) + sizeof( te.th32OwnerProcessID ) ) { if ( te.th32OwnerProcessID == processId ) { @@ -807,8 +724,7 @@ QgsStackTrace *QgsStackTrace::trace( DWORD processId, DWORD threadId, LPEXCEPTIO } } te.dwSize = sizeof( te ); - } - while ( Thread32Next( h, &te ) ); + } while ( Thread32Next( h, &te ) ); } CloseHandle( h ); } @@ -866,10 +782,7 @@ bool QgsStackTrace::StackLine::isQgisModule() const bool QgsStackTrace::StackLine::isValid() const { - return !( fileName.contains( QLatin1String( "exe_common" ), Qt::CaseInsensitive ) || - fileName.contains( QLatin1String( "unknown" ), Qt::CaseInsensitive ) || - lineNumber.contains( QLatin1String( "unknown" ), Qt::CaseInsensitive ) ); - + return !( fileName.contains( QLatin1String( "exe_common" ), Qt::CaseInsensitive ) || fileName.contains( QLatin1String( "unknown" ), Qt::CaseInsensitive ) || lineNumber.contains( QLatin1String( "unknown" ), Qt::CaseInsensitive ) ); } ///@endcond diff --git a/src/crashhandler/qgsstacktrace.h b/src/crashhandler/qgsstacktrace.h index 3b1752493ed4..f473f3a24ede 100644 --- a/src/crashhandler/qgsstacktrace.h +++ b/src/crashhandler/qgsstacktrace.h @@ -37,29 +37,28 @@ class QgsStackTrace { public: - /** * Represents a line from a stack trace. */ struct StackLine { - QString moduleName; - QString symbolName; - QString fileName; - QString lineNumber; + QString moduleName; + QString symbolName; + QString fileName; + QString lineNumber; - /** + /** * Check if this stack line is part of QGIS. * \return TRUE if part of QGIS. */ - bool isQgisModule() const; + bool isQgisModule() const; - /** + /** * Check if this stack line is valid. Considered valid when the filename and line * number are known. * \return TRUE of the line is valid. */ - bool isValid() const; + bool isValid() const; }; bool symbolsLoaded; diff --git a/src/customwidgets/qgiscustomwidgets.cpp b/src/customwidgets/qgiscustomwidgets.cpp index 57b516beee45..f0d7d34321fd 100644 --- a/src/customwidgets/qgiscustomwidgets.cpp +++ b/src/customwidgets/qgiscustomwidgets.cpp @@ -78,7 +78,7 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent ) mWidgets.append( new QgsRelationReferenceWidgetPlugin( this ) ); mWidgets.append( new QgsScaleRangeWidgetPlugin( this ) ); mWidgets.append( new QgsScaleWidgetPlugin( this ) ); -// mWidgets.append( new QgsScrollAreaWidgetPlugin( this ) ); // this is causing troubles at the moment + // mWidgets.append( new QgsScrollAreaWidgetPlugin( this ) ); // this is causing troubles at the moment mWidgets.append( new QgsSpinBoxPlugin( this ) ); mWidgets.append( new QgsSymbolButtonPlugin( this ) ); } diff --git a/src/customwidgets/qgsauthconfigselectplugin.cpp b/src/customwidgets/qgsauthconfigselectplugin.cpp index 2e881964e0a6..4110a76ae45d 100644 --- a/src/customwidgets/qgsauthconfigselectplugin.cpp +++ b/src/customwidgets/qgsauthconfigselectplugin.cpp @@ -94,5 +94,5 @@ QString QgsAuthConfigSelectPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgscheckablecomboboxplugin.cpp b/src/customwidgets/qgscheckablecomboboxplugin.cpp index f295c9caf6c1..717801c6989f 100644 --- a/src/customwidgets/qgscheckablecomboboxplugin.cpp +++ b/src/customwidgets/qgscheckablecomboboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsCheckableComboBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgscollapsiblegroupboxplugin.cpp b/src/customwidgets/qgscollapsiblegroupboxplugin.cpp index 5de1b22e643b..283b49f3ac58 100644 --- a/src/customwidgets/qgscollapsiblegroupboxplugin.cpp +++ b/src/customwidgets/qgscollapsiblegroupboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsCollapsibleGroupBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgscolorbuttonplugin.cpp b/src/customwidgets/qgscolorbuttonplugin.cpp index 448caf27d47f..e8f9eaa30c68 100644 --- a/src/customwidgets/qgscolorbuttonplugin.cpp +++ b/src/customwidgets/qgscolorbuttonplugin.cpp @@ -94,5 +94,5 @@ QString QgsColorButtonPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsdatetimeeditplugin.cpp b/src/customwidgets/qgsdatetimeeditplugin.cpp index ef6bdf09c2fa..bca88b7a7546 100644 --- a/src/customwidgets/qgsdatetimeeditplugin.cpp +++ b/src/customwidgets/qgsdatetimeeditplugin.cpp @@ -94,5 +94,5 @@ QString QgsDateTimeEditPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsdockwidgetplugin.cpp b/src/customwidgets/qgsdockwidgetplugin.cpp index b6ca4270d133..6366576817ad 100644 --- a/src/customwidgets/qgsdockwidgetplugin.cpp +++ b/src/customwidgets/qgsdockwidgetplugin.cpp @@ -95,5 +95,5 @@ QString QgsDockWidgetPlugin::domXml() const " " " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsdoublespinboxplugin.cpp b/src/customwidgets/qgsdoublespinboxplugin.cpp index 8f406f79d6e7..fc04dad08db3 100644 --- a/src/customwidgets/qgsdoublespinboxplugin.cpp +++ b/src/customwidgets/qgsdoublespinboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsDoubleSpinBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsexpressionbuilderwidgetplugin.cpp b/src/customwidgets/qgsexpressionbuilderwidgetplugin.cpp index 83751dfa6117..2527bbad15eb 100644 --- a/src/customwidgets/qgsexpressionbuilderwidgetplugin.cpp +++ b/src/customwidgets/qgsexpressionbuilderwidgetplugin.cpp @@ -94,5 +94,5 @@ QString QgsExpressionBuilderWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsextentgroupboxplugin.cpp b/src/customwidgets/qgsextentgroupboxplugin.cpp index 0086ed92c79a..0529ed4e403d 100644 --- a/src/customwidgets/qgsextentgroupboxplugin.cpp +++ b/src/customwidgets/qgsextentgroupboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsExtentGroupBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsexternalresourcewidgetplugin.cpp b/src/customwidgets/qgsexternalresourcewidgetplugin.cpp index 2a6c6a8aafdb..f8d799123d59 100644 --- a/src/customwidgets/qgsexternalresourcewidgetplugin.cpp +++ b/src/customwidgets/qgsexternalresourcewidgetplugin.cpp @@ -93,5 +93,5 @@ QString QgsExternalResourceWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsfeaturelistcomboboxplugin.cpp b/src/customwidgets/qgsfeaturelistcomboboxplugin.cpp index 7c6b547d1bc7..eb8f92ee8087 100644 --- a/src/customwidgets/qgsfeaturelistcomboboxplugin.cpp +++ b/src/customwidgets/qgsfeaturelistcomboboxplugin.cpp @@ -93,5 +93,5 @@ QString QgsFeatureListComboBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsfeaturepickerwidgetplugin.cpp b/src/customwidgets/qgsfeaturepickerwidgetplugin.cpp index 0ebde7a83568..39fe9486c8e8 100644 --- a/src/customwidgets/qgsfeaturepickerwidgetplugin.cpp +++ b/src/customwidgets/qgsfeaturepickerwidgetplugin.cpp @@ -93,5 +93,5 @@ QString QgsFeaturePickerWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsfieldcomboboxplugin.cpp b/src/customwidgets/qgsfieldcomboboxplugin.cpp index a79fcea42def..593a6c78a316 100644 --- a/src/customwidgets/qgsfieldcomboboxplugin.cpp +++ b/src/customwidgets/qgsfieldcomboboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsFieldComboBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsfieldexpressionwidgetplugin.cpp b/src/customwidgets/qgsfieldexpressionwidgetplugin.cpp index df6af8f423dd..38de803160b8 100644 --- a/src/customwidgets/qgsfieldexpressionwidgetplugin.cpp +++ b/src/customwidgets/qgsfieldexpressionwidgetplugin.cpp @@ -94,5 +94,5 @@ QString QgsFieldExpressionWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsfilewidgetplugin.cpp b/src/customwidgets/qgsfilewidgetplugin.cpp index d2d570a31ed5..54f20dd28334 100644 --- a/src/customwidgets/qgsfilewidgetplugin.cpp +++ b/src/customwidgets/qgsfilewidgetplugin.cpp @@ -93,5 +93,5 @@ QString QgsFileWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsfilewidgetplugin.h b/src/customwidgets/qgsfilewidgetplugin.h index b30ca8c5050a..6076395ac5e9 100644 --- a/src/customwidgets/qgsfilewidgetplugin.h +++ b/src/customwidgets/qgsfilewidgetplugin.h @@ -23,7 +23,6 @@ #include "qgis_customwidgets.h" - class CUSTOMWIDGETS_EXPORT QgsFileWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface { Q_OBJECT diff --git a/src/customwidgets/qgsfilterlineeditplugin.cpp b/src/customwidgets/qgsfilterlineeditplugin.cpp index f6a1dd47a0ed..ca1e02f3981e 100644 --- a/src/customwidgets/qgsfilterlineeditplugin.cpp +++ b/src/customwidgets/qgsfilterlineeditplugin.cpp @@ -97,5 +97,5 @@ QString QgsFilterLineEditPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsfontbuttonplugin.cpp b/src/customwidgets/qgsfontbuttonplugin.cpp index d2e490be6f4e..93ba25333604 100644 --- a/src/customwidgets/qgsfontbuttonplugin.cpp +++ b/src/customwidgets/qgsfontbuttonplugin.cpp @@ -94,5 +94,5 @@ QString QgsFontButtonPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsmaplayercomboboxplugin.cpp b/src/customwidgets/qgsmaplayercomboboxplugin.cpp index e0f39f34423a..13ded691ae5b 100644 --- a/src/customwidgets/qgsmaplayercomboboxplugin.cpp +++ b/src/customwidgets/qgsmaplayercomboboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsMapLayerComboBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsopacitywidgetplugin.cpp b/src/customwidgets/qgsopacitywidgetplugin.cpp index 8a0349b6b1a8..645f36f73095 100644 --- a/src/customwidgets/qgsopacitywidgetplugin.cpp +++ b/src/customwidgets/qgsopacitywidgetplugin.cpp @@ -94,5 +94,5 @@ QString QgsOpacityWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgspasswordlineeditplugin.cpp b/src/customwidgets/qgspasswordlineeditplugin.cpp index 27c59cdc1399..0d8f939f2bdc 100644 --- a/src/customwidgets/qgspasswordlineeditplugin.cpp +++ b/src/customwidgets/qgspasswordlineeditplugin.cpp @@ -94,5 +94,5 @@ QString QgsPasswordLineEditPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsprojectionselectionwidgetplugin.cpp b/src/customwidgets/qgsprojectionselectionwidgetplugin.cpp index 8612b17f9b92..b7cf9476fa08 100644 --- a/src/customwidgets/qgsprojectionselectionwidgetplugin.cpp +++ b/src/customwidgets/qgsprojectionselectionwidgetplugin.cpp @@ -94,5 +94,5 @@ QString QgsProjectionSelectionWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgspropertyoverridebuttonplugin.cpp b/src/customwidgets/qgspropertyoverridebuttonplugin.cpp index 09472fc17121..7dd7d34a3901 100644 --- a/src/customwidgets/qgspropertyoverridebuttonplugin.cpp +++ b/src/customwidgets/qgspropertyoverridebuttonplugin.cpp @@ -94,5 +94,5 @@ QString QgsPropertyOverrideButtonPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsrasterbandcomboboxplugin.cpp b/src/customwidgets/qgsrasterbandcomboboxplugin.cpp index adb82af9fbd2..7a48ada6e2d2 100644 --- a/src/customwidgets/qgsrasterbandcomboboxplugin.cpp +++ b/src/customwidgets/qgsrasterbandcomboboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsRasterBandComboBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsrelationeditorwidgetplugin.cpp b/src/customwidgets/qgsrelationeditorwidgetplugin.cpp index 40e9218d7e70..8125c06c403d 100644 --- a/src/customwidgets/qgsrelationeditorwidgetplugin.cpp +++ b/src/customwidgets/qgsrelationeditorwidgetplugin.cpp @@ -97,5 +97,5 @@ QString QgsRelationEditorWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsrelationreferencewidgetplugin.cpp b/src/customwidgets/qgsrelationreferencewidgetplugin.cpp index 0947b4f0624b..2f2eaf338430 100644 --- a/src/customwidgets/qgsrelationreferencewidgetplugin.cpp +++ b/src/customwidgets/qgsrelationreferencewidgetplugin.cpp @@ -94,5 +94,5 @@ QString QgsRelationReferenceWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsscalerangewidgetplugin.cpp b/src/customwidgets/qgsscalerangewidgetplugin.cpp index 5e5f02ed3a51..a4ba705df7e1 100644 --- a/src/customwidgets/qgsscalerangewidgetplugin.cpp +++ b/src/customwidgets/qgsscalerangewidgetplugin.cpp @@ -94,5 +94,5 @@ QString QgsScaleRangeWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsscalewidgetplugin.cpp b/src/customwidgets/qgsscalewidgetplugin.cpp index b3f7d6ed44ae..bb58019fd7dc 100644 --- a/src/customwidgets/qgsscalewidgetplugin.cpp +++ b/src/customwidgets/qgsscalewidgetplugin.cpp @@ -97,5 +97,5 @@ QString QgsScaleWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsscrollareawidgetplugin.cpp b/src/customwidgets/qgsscrollareawidgetplugin.cpp index 4a633de5ae31..05bfdfdd7f93 100644 --- a/src/customwidgets/qgsscrollareawidgetplugin.cpp +++ b/src/customwidgets/qgsscrollareawidgetplugin.cpp @@ -105,5 +105,5 @@ QString QgsScrollAreaWidgetPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgsspinboxplugin.cpp b/src/customwidgets/qgsspinboxplugin.cpp index 2e2a40a40025..d111e3799a87 100644 --- a/src/customwidgets/qgsspinboxplugin.cpp +++ b/src/customwidgets/qgsspinboxplugin.cpp @@ -94,5 +94,5 @@ QString QgsSpinBoxPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/customwidgets/qgssymbolbuttonplugin.cpp b/src/customwidgets/qgssymbolbuttonplugin.cpp index e1528fa52b40..2f0203dfe43c 100644 --- a/src/customwidgets/qgssymbolbuttonplugin.cpp +++ b/src/customwidgets/qgssymbolbuttonplugin.cpp @@ -94,5 +94,5 @@ QString QgsSymbolButtonPlugin::domXml() const " \n" " \n" "\n" ) - .arg( name() ); + .arg( name() ); } diff --git a/src/native/linux/qgslinuxnative.cpp b/src/native/linux/qgslinuxnative.cpp index 2a67bf6f069e..393c7c9a26a9 100644 --- a/src/native/linux/qgslinuxnative.cpp +++ b/src/native/linux/qgslinuxnative.cpp @@ -31,10 +31,7 @@ QgsNative::Capabilities QgsLinuxNative::capabilities() const return NativeDesktopNotifications | NativeFilePropertiesDialog | NativeOpenTerminalAtPath; } -void QgsLinuxNative::initializeMainWindow( QWindow *, - const QString &, - const QString &, - const QString & ) +void QgsLinuxNative::initializeMainWindow( QWindow *, const QString &, const QString &, const QString & ) { // Hardcoded desktop file value matching our official .deb packages mDesktopFile = QStringLiteral( "org.qgis.qgis.desktop" ); @@ -48,10 +45,7 @@ void QgsLinuxNative::openFileExplorerAndSelectFile( const QString &path ) return; } - QDBusInterface iface( QStringLiteral( "org.freedesktop.FileManager1" ), - QStringLiteral( "/org/freedesktop/FileManager1" ), - QStringLiteral( "org.freedesktop.FileManager1" ), - QDBusConnection::sessionBus() ); + QDBusInterface iface( QStringLiteral( "org.freedesktop.FileManager1" ), QStringLiteral( "/org/freedesktop/FileManager1" ), QStringLiteral( "org.freedesktop.FileManager1" ), QDBusConnection::sessionBus() ); iface.call( QDBus::NoBlock, QStringLiteral( "ShowItems" ), QStringList( QUrl::fromLocalFile( path ).toString() ), QStringLiteral( "QGIS" ) ); if ( iface.lastError().type() != QDBusError::NoError ) @@ -68,10 +62,7 @@ void QgsLinuxNative::showFileProperties( const QString &path ) return; } - QDBusInterface iface( QStringLiteral( "org.freedesktop.FileManager1" ), - QStringLiteral( "/org/freedesktop/FileManager1" ), - QStringLiteral( "org.freedesktop.FileManager1" ), - QDBusConnection::sessionBus() ); + QDBusInterface iface( QStringLiteral( "org.freedesktop.FileManager1" ), QStringLiteral( "/org/freedesktop/FileManager1" ), QStringLiteral( "org.freedesktop.FileManager1" ), QDBusConnection::sessionBus() ); iface.call( QDBus::NoBlock, QStringLiteral( "ShowItemProperties" ), QStringList( QUrl::fromLocalFile( path ).toString() ), QStringLiteral( "QGIS" ) ); if ( iface.lastError().type() != QDBusError::NoError ) @@ -82,61 +73,49 @@ void QgsLinuxNative::showFileProperties( const QString &path ) void QgsLinuxNative::showUndefinedApplicationProgress() { - const QVariantMap properties - { + const QVariantMap properties { { QStringLiteral( "progress-visible" ), true }, { QStringLiteral( "progress" ), 0.0 } }; - QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), - QStringLiteral( "com.canonical.Unity.LauncherEntry" ), - QStringLiteral( "Update" ) ); - message.setArguments( {mDesktopFile, properties} ); + QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), QStringLiteral( "com.canonical.Unity.LauncherEntry" ), QStringLiteral( "Update" ) ); + message.setArguments( { mDesktopFile, properties } ); QDBusConnection::sessionBus().send( message ); } void QgsLinuxNative::setApplicationProgress( double progress ) { - const QVariantMap properties - { + const QVariantMap properties { { QStringLiteral( "progress-visible" ), true }, { QStringLiteral( "progress" ), progress / 100.0 } }; - QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), - QStringLiteral( "com.canonical.Unity.LauncherEntry" ), - QStringLiteral( "Update" ) ); - message.setArguments( {mDesktopFile, properties} ); + QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), QStringLiteral( "com.canonical.Unity.LauncherEntry" ), QStringLiteral( "Update" ) ); + message.setArguments( { mDesktopFile, properties } ); QDBusConnection::sessionBus().send( message ); } void QgsLinuxNative::hideApplicationProgress() { - const QVariantMap properties - { + const QVariantMap properties { { QStringLiteral( "progress-visible" ), false }, }; - QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), - QStringLiteral( "com.canonical.Unity.LauncherEntry" ), - QStringLiteral( "Update" ) ); - message.setArguments( {mDesktopFile, properties} ); + QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), QStringLiteral( "com.canonical.Unity.LauncherEntry" ), QStringLiteral( "Update" ) ); + message.setArguments( { mDesktopFile, properties } ); QDBusConnection::sessionBus().send( message ); } void QgsLinuxNative::setApplicationBadgeCount( int count ) { // the badge will only be shown when the count is greater than one - const QVariantMap properties - { + const QVariantMap properties { { QStringLiteral( "count-visible" ), count > 1 }, - { QStringLiteral( "count" ), static_cast< long long >( count ) } + { QStringLiteral( "count" ), static_cast( count ) } }; - QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), - QStringLiteral( "com.canonical.Unity.LauncherEntry" ), - QStringLiteral( "Update" ) ); - message.setArguments( {mDesktopFile, properties} ); + QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ), QStringLiteral( "com.canonical.Unity.LauncherEntry" ), QStringLiteral( "Update" ) ); + message.setArguments( { mDesktopFile, properties } ); QDBusConnection::sessionBus().send( message ); } @@ -153,15 +132,11 @@ bool QgsLinuxNative::openTerminalAtPath( const QString &path ) { term = QStringLiteral( "x-terminal-emulator" ); } - else if ( desktopSession.contains( QLatin1String( "gnome" ), Qt::CaseInsensitive ) || - currentDesktop.contains( QLatin1String( "gnome" ), Qt::CaseInsensitive ) || - currentDesktop.contains( QLatin1String( "unity" ), Qt::CaseInsensitive ) ) + else if ( desktopSession.contains( QLatin1String( "gnome" ), Qt::CaseInsensitive ) || currentDesktop.contains( QLatin1String( "gnome" ), Qt::CaseInsensitive ) || currentDesktop.contains( QLatin1String( "unity" ), Qt::CaseInsensitive ) ) { term = QStringLiteral( "gnome-terminal" ); } - else if ( desktopSession.contains( QLatin1String( "kde" ), Qt::CaseInsensitive ) || - currentDesktop.contains( QLatin1String( "kde" ), Qt::CaseInsensitive ) || - gdmSession.contains( QLatin1String( "kde" ), Qt::CaseInsensitive ) ) + else if ( desktopSession.contains( QLatin1String( "kde" ), Qt::CaseInsensitive ) || currentDesktop.contains( QLatin1String( "kde" ), Qt::CaseInsensitive ) || gdmSession.contains( QLatin1String( "kde" ), Qt::CaseInsensitive ) ) { term = QStringLiteral( "konsole" ); } @@ -246,10 +221,7 @@ QgsNative::NotificationResult QgsLinuxNative::showDesktopNotification( const QSt qDBusRegisterMetaType(); - QDBusInterface iface( QStringLiteral( "org.freedesktop.Notifications" ), - QStringLiteral( "/org/freedesktop/Notifications" ), - QStringLiteral( "org.freedesktop.Notifications" ), - QDBusConnection::sessionBus() ); + QDBusInterface iface( QStringLiteral( "org.freedesktop.Notifications" ), QStringLiteral( "/org/freedesktop/Notifications" ), QStringLiteral( "org.freedesktop.Notifications" ), QDBusConnection::sessionBus() ); QVariantMap hints; hints[QStringLiteral( "transient" )] = settings.transient; @@ -260,19 +232,19 @@ QgsNative::NotificationResult QgsLinuxNative::showDesktopNotification( const QSt argumentList << "qgis"; //app_name // replace_id if ( settings.messageId.isValid() ) - argumentList << static_cast< uint >( settings.messageId.toInt() ); + argumentList << static_cast( settings.messageId.toInt() ); else - argumentList << static_cast< uint >( 0 ); + argumentList << static_cast( 0 ); // app_icon if ( !settings.svgAppIconPath.isEmpty() ) argumentList << settings.svgAppIconPath; else argumentList << ""; - argumentList << summary; // summary - argumentList << body; // body - argumentList << QStringList(); // actions - argumentList << hints; // hints - argumentList << -1; // timeout in ms "If -1, the notification's expiration time is dependent on the notification server's settings, and may vary for the type of notification." + argumentList << summary; // summary + argumentList << body; // body + argumentList << QStringList(); // actions + argumentList << hints; // hints + argumentList << -1; // timeout in ms "If -1, the notification's expiration time is dependent on the notification server's settings, and may vary for the type of notification." const QDBusMessage reply = iface.callWithArgumentList( QDBus::AutoDetect, QStringLiteral( "Notify" ), argumentList ); if ( reply.type() == QDBusMessage::ErrorMessage ) diff --git a/src/native/linux/qgslinuxnative.h b/src/native/linux/qgslinuxnative.h index 32b4c056d67d..73a051dc6e74 100644 --- a/src/native/linux/qgslinuxnative.h +++ b/src/native/linux/qgslinuxnative.h @@ -36,10 +36,7 @@ class NATIVE_EXPORT QgsLinuxNative : public QgsNative public: QgsNative::Capabilities capabilities() const override; - void initializeMainWindow( QWindow *window, - const QString &applicationName, - const QString &organizationName, - const QString &version ) override; + void initializeMainWindow( QWindow *window, const QString &applicationName, const QString &organizationName, const QString &version ) override; void openFileExplorerAndSelectFile( const QString &path ) override; void showFileProperties( const QString &path ) override; void showUndefinedApplicationProgress() override; @@ -48,6 +45,7 @@ class NATIVE_EXPORT QgsLinuxNative : public QgsNative void setApplicationBadgeCount( int count ) override; bool openTerminalAtPath( const QString &path ) override; NotificationResult showDesktopNotification( const QString &summary, const QString &body, const NotificationSettings &settings = NotificationSettings() ) override; + private: QString mDesktopFile; }; diff --git a/src/native/mac/cocoainitializer.mm b/src/native/mac/cocoainitializer.mm index bbccf6349a1a..ac42e82c3e1c 100644 --- a/src/native/mac/cocoainitializer.mm +++ b/src/native/mac/cocoainitializer.mm @@ -41,21 +41,18 @@ #include #include -class CocoaInitializer::Private -{ - public: - NSAutoreleasePool *autoReleasePool_; +class CocoaInitializer::Private { +public: + NSAutoreleasePool *autoReleasePool_; }; -CocoaInitializer::CocoaInitializer() -{ +CocoaInitializer::CocoaInitializer() { d = new CocoaInitializer::Private(); NSApplicationLoad(); d->autoReleasePool_ = [[NSAutoreleasePool alloc] init]; } -CocoaInitializer::~CocoaInitializer() -{ +CocoaInitializer::~CocoaInitializer() { [d->autoReleasePool_ release]; delete d; } diff --git a/src/native/mac/qgsmacnative.h b/src/native/mac/qgsmacnative.h index 62d4a7de94e6..892423507e1a 100644 --- a/src/native/mac/qgsmacnative.h +++ b/src/native/mac/qgsmacnative.h @@ -43,7 +43,6 @@ class NATIVE_EXPORT QgsMacNative : public QgsNative private: class QgsUserNotificationCenter; QgsUserNotificationCenter *mQgsUserNotificationCenter = nullptr; - }; diff --git a/src/native/mac/qgsmacnative.mm b/src/native/mac/qgsmacnative.mm index 596ae5bd2231..a6de239c6bd8 100644 --- a/src/native/mac/qgsmacnative.mm +++ b/src/native/mac/qgsmacnative.mm @@ -19,96 +19,96 @@ #include -#include #include +#include - -@interface QgsUserNotificationCenterDelegate : NSObject +@interface QgsUserNotificationCenterDelegate + : NSObject @end @implementation QgsUserNotificationCenterDelegate -- ( BOOL )userNotificationCenter:( NSUserNotificationCenter * )center shouldPresentNotification:( NSUserNotification * )notification -{ -#pragma unused (notification) -#pragma unused (center) +- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center + shouldPresentNotification:(NSUserNotification *)notification { +#pragma unused(notification) +#pragma unused(center) return YES; } @end -class QgsMacNative::QgsUserNotificationCenter -{ - public: - QgsUserNotificationCenterDelegate *_qgsUserNotificationCenter; - NSImage *_qgisIcon; +class QgsMacNative::QgsUserNotificationCenter { +public: + QgsUserNotificationCenterDelegate *_qgsUserNotificationCenter; + NSImage *_qgisIcon; }; QgsMacNative::QgsMacNative() - : mQgsUserNotificationCenter( new QgsMacNative::QgsUserNotificationCenter() ) -{ - mQgsUserNotificationCenter->_qgsUserNotificationCenter = [[QgsUserNotificationCenterDelegate alloc] init]; - [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: mQgsUserNotificationCenter->_qgsUserNotificationCenter]; + : mQgsUserNotificationCenter( + new QgsMacNative::QgsUserNotificationCenter()) { + mQgsUserNotificationCenter->_qgsUserNotificationCenter = + [[QgsUserNotificationCenterDelegate alloc] init]; + [[NSUserNotificationCenter defaultUserNotificationCenter] + setDelegate:mQgsUserNotificationCenter->_qgsUserNotificationCenter]; } -QgsMacNative::~QgsMacNative() -{ +QgsMacNative::~QgsMacNative() { [mQgsUserNotificationCenter->_qgsUserNotificationCenter dealloc]; delete mQgsUserNotificationCenter; } -void QgsMacNative::setIconPath( const QString &iconPath ) -{ - mQgsUserNotificationCenter->_qgisIcon = [[NSImage alloc] initWithCGImage:QPixmap( iconPath ).toImage().toCGImage() size:NSZeroSize]; +void QgsMacNative::setIconPath(const QString &iconPath) { + mQgsUserNotificationCenter->_qgisIcon = + [[NSImage alloc] initWithCGImage:QPixmap(iconPath).toImage().toCGImage() + size:NSZeroSize]; } -const char *QgsMacNative::currentAppLocalizedName() -{ +const char *QgsMacNative::currentAppLocalizedName() { return [[[NSRunningApplication currentApplication] localizedName] UTF8String]; } -void QgsMacNative::currentAppActivateIgnoringOtherApps() -{ - [[NSRunningApplication currentApplication] activateWithOptions: - ( NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps )]; +void QgsMacNative::currentAppActivateIgnoringOtherApps() { + [[NSRunningApplication currentApplication] + activateWithOptions:(NSApplicationActivateAllWindows | + NSApplicationActivateIgnoringOtherApps)]; } -void QgsMacNative::openFileExplorerAndSelectFile( const QString &path ) -{ - NSString *pathStr = [[NSString alloc] initWithUTF8String:path.toUtf8().constData()]; - NSArray *fileURLs = [NSArray arrayWithObjects:[NSURL fileURLWithPath:pathStr], nil]; +void QgsMacNative::openFileExplorerAndSelectFile(const QString &path) { + NSString *pathStr = + [[NSString alloc] initWithUTF8String:path.toUtf8().constData()]; + NSArray *fileURLs = + [NSArray arrayWithObjects:[NSURL fileURLWithPath:pathStr], nil]; [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs]; } -QgsNative::Capabilities QgsMacNative::capabilities() const -{ +QgsNative::Capabilities QgsMacNative::capabilities() const { return NativeDesktopNotifications; } -QgsNative::NotificationResult QgsMacNative::showDesktopNotification( const QString &summary, - const QString &body, - const QgsNative::NotificationSettings &settings ) -{ +QgsNative::NotificationResult QgsMacNative::showDesktopNotification( + const QString &summary, const QString &body, + const QgsNative::NotificationSettings &settings) { NSUserNotification *notification = [[NSUserNotification alloc] init]; notification.title = summary.toNSString(); notification.informativeText = body.toNSString(); - notification.soundName = NSUserNotificationDefaultSoundName; //Will play a default sound + notification.soundName = + NSUserNotificationDefaultSoundName; // Will play a default sound NSImage *image = nil; - if ( settings.image.isNull() ) - { - // image application (qgis.icns) seems not to be set for now, although present in the plist - // whenever fixed, try following line (and remove corresponding code in QgsMacNative::QgsUserNotificationCenter) - // image = [[NSImage imageNamed:@"NSApplicationIcon"] retain] + if (settings.image.isNull()) { + // image application (qgis.icns) seems not to be set for now, although + // present in the plist whenever fixed, try following line (and remove + // corresponding code in QgsMacNative::QgsUserNotificationCenter) image = + // [[NSImage imageNamed:@"NSApplicationIcon"] retain] image = mQgsUserNotificationCenter->_qgisIcon; - } - else - { - const QPixmap px = QPixmap::fromImage( settings.image ); - image = [[NSImage alloc] initWithCGImage:px.toImage().toCGImage() size:NSZeroSize]; + } else { + const QPixmap px = QPixmap::fromImage(settings.image); + image = [[NSImage alloc] initWithCGImage:px.toImage().toCGImage() + size:NSZeroSize]; } notification.contentImage = image; - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification]; + [[NSUserNotificationCenter defaultUserNotificationCenter] + deliverNotification:notification]; [notification autorelease]; //[userCenterDelegate dealloc]; @@ -118,22 +118,22 @@ - ( BOOL )userNotificationCenter:( NSUserNotificationCenter * )center shouldPres return result; } -bool QgsMacNative::hasDarkTheme() -{ +bool QgsMacNative::hasDarkTheme() { #ifdef __MAC_OS_X_VERSION_MAX_ALLOWED #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - // Version comparison needs to be numeric, in case __MAC_10_10_4 is not defined, e.g. some pre-10.14 SDKs - // See: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/cross_development/Using/using.html + // Version comparison needs to be numeric, in case __MAC_10_10_4 is not + // defined, e.g. some pre-10.14 SDKs See: + // https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/cross_development/Using/using.html // Section "Conditionally Compiling for Different SDKs" - if ( [NSApp respondsToSelector:@selector( effectiveAppearance )] ) - { + if ([NSApp respondsToSelector:@selector(effectiveAppearance)]) { // compiled on macos 10.14+ AND running on macos 10.14+ // check the settings of effective appearance of the user - NSAppearanceName appearanceName = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]]; - return ( [appearanceName isEqualToString:NSAppearanceNameDarkAqua] ); - } - else - { + NSAppearanceName appearanceName = + [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames:@[ + NSAppearanceNameAqua, NSAppearanceNameDarkAqua + ]]; + return ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]); + } else { // compiled on macos 10.14+ BUT running on macos 10.13- // DarkTheme was introduced in MacOS 10.14, fallback to light theme return false; diff --git a/src/native/qgsnative.cpp b/src/native/qgsnative.cpp index 84fffb719d48..93391358d167 100644 --- a/src/native/qgsnative.cpp +++ b/src/native/qgsnative.cpp @@ -30,12 +30,8 @@ QgsNative::Capabilities QgsNative::capabilities() const return QgsNative::Capabilities(); } -void QgsNative::initializeMainWindow( QWindow *, - const QString &, - const QString &, - const QString & ) +void QgsNative::initializeMainWindow( QWindow *, const QString &, const QString &, const QString & ) { - } void QgsNative::currentAppActivateIgnoringOtherApps() @@ -51,27 +47,22 @@ void QgsNative::openFileExplorerAndSelectFile( const QString &path ) void QgsNative::showFileProperties( const QString & ) { - } void QgsNative::showUndefinedApplicationProgress() { - } void QgsNative::setApplicationProgress( double ) { - } void QgsNative::hideApplicationProgress() { - } void QgsNative::setApplicationBadgeCount( int ) { - } bool QgsNative::hasDarkTheme() @@ -93,5 +84,4 @@ QgsNative::NotificationResult QgsNative::showDesktopNotification( const QString void QgsNative::onRecentProjectsChanged( const std::vector & ) { - } diff --git a/src/native/qgsnative.h b/src/native/qgsnative.h index aaa91b0957b6..3f4b86d20ec7 100644 --- a/src/native/qgsnative.h +++ b/src/native/qgsnative.h @@ -38,13 +38,12 @@ class NATIVE_EXPORT QgsNative : public QObject Q_OBJECT public: - //! Native interface capabilities enum Capability { NativeDesktopNotifications = 1 << 1, //!< Native desktop notifications are supported. See showDesktopNotification(). NativeFilePropertiesDialog = 1 << 2, //!< Platform can show a native "file" (or folder) properties dialog. - NativeOpenTerminalAtPath = 1 << 3, //!< Platform can open a terminal (command line) at a specific path + NativeOpenTerminalAtPath = 1 << 3, //!< Platform can open a terminal (command line) at a specific path }; Q_DECLARE_FLAGS( Capabilities, Capability ) @@ -71,10 +70,7 @@ class NATIVE_EXPORT QgsNative : public QObject * * \since QGIS 3.4 */ - virtual void initializeMainWindow( QWindow *window, - const QString &applicationName, - const QString &organizationName, - const QString &version ); + virtual void initializeMainWindow( QWindow *window, const QString &applicationName, const QString &organizationName, const QString &version ); /** * Brings the QGIS app to front. The default implementation does nothing. @@ -166,22 +162,22 @@ class NATIVE_EXPORT QgsNative : public QObject */ struct NotificationSettings { - NotificationSettings() {} + NotificationSettings() {} - //! Optional image to show in notification - QImage image; + //! Optional image to show in notification + QImage image; - //! Whether the notification should be transient (the meaning varies depending on platform) - bool transient = true; + //! Whether the notification should be transient (the meaning varies depending on platform) + bool transient = true; - //! Path to application icon in SVG format - QString svgAppIconPath; + //! Path to application icon in SVG format + QString svgAppIconPath; - //! Path to application icon in png format - QString pngAppIconPath; + //! Path to application icon in png format + QString pngAppIconPath; - //! Message ID, used to replace existing messages - QVariant messageId; + //! Message ID, used to replace existing messages + QVariant messageId; }; /** @@ -189,13 +185,13 @@ class NATIVE_EXPORT QgsNative : public QObject */ struct NotificationResult { - NotificationResult() {} + NotificationResult() {} - //! True if notification was successfully sent. - bool successful = false; + //! True if notification was successfully sent. + bool successful = false; - //! Unique notification message ID, used by some platforms to identify the notification - QVariant messageId; + //! Unique notification message ID, used by some platforms to identify the notification + QVariant messageId; }; /** @@ -220,17 +216,17 @@ class NATIVE_EXPORT QgsNative : public QObject */ struct RecentProjectProperties { - //! Project name (will be project title if set, otherwise project filename) - QString name; + //! Project name (will be project title if set, otherwise project filename) + QString name; - //! Project title, if set - QString title; + //! Project title, if set + QString title; - //! Project filename - QString fileName; + //! Project filename + QString fileName; - //! Full project path - QString path; + //! Full project path + QString path; }; /** @@ -243,7 +239,7 @@ class NATIVE_EXPORT QgsNative : public QObject * * \since QGIS 3.4 */ - virtual void onRecentProjectsChanged( const std::vector< RecentProjectProperties > &recentProjects ); + virtual void onRecentProjectsChanged( const std::vector &recentProjects ); signals: @@ -258,7 +254,6 @@ class NATIVE_EXPORT QgsNative : public QObject * \since QGIS 3.4 */ void usbStorageNotification( const QString &path, bool inserted ); - }; Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNative::Capabilities ) diff --git a/src/native/win/qgswinnative.cpp b/src/native/win/qgswinnative.cpp index 7607059f13ca..021d433bf6a4 100644 --- a/src/native/win/qgswinnative.cpp +++ b/src/native/win/qgswinnative.cpp @@ -24,7 +24,7 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #include #include #include @@ -37,22 +37,21 @@ #include #ifdef UNICODE -#define _T(x) L##x +#define _T( x ) L##x #else -#define _T(x) x +#define _T( x ) x #endif struct LPITEMIDLISTDeleter { - void operator()( LPITEMIDLIST pidl ) const - { - ILFree( pidl ); - } + void operator()( LPITEMIDLIST pidl ) const + { + ILFree( pidl ); + } }; -using ITEMIDLIST_unique_ptr = std::unique_ptr< std::remove_pointer_t< LPITEMIDLIST >, LPITEMIDLISTDeleter>; - +using ITEMIDLIST_unique_ptr = std::unique_ptr, LPITEMIDLISTDeleter>; QgsNative::Capabilities QgsWinNative::capabilities() const @@ -60,13 +59,10 @@ QgsNative::Capabilities QgsWinNative::capabilities() const return mCapabilities; } -void QgsWinNative::initializeMainWindow( QWindow *window, - const QString &applicationName, - const QString &organizationName, - const QString &version ) +void QgsWinNative::initializeMainWindow( QWindow *window, const QString &applicationName, const QString &organizationName, const QString &version ) { mWindow = window; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) if ( mTaskButton ) return; // already initialized! @@ -82,10 +78,8 @@ void QgsWinNative::initializeMainWindow( QWindow *window, WinToastLib::WinToast::instance()->setAppName( appName.toStdWString() ); WinToastLib::WinToast::instance()->setAppUserModelId( - WinToastLib::WinToast::configureAUMI( organizationName.toStdWString(), - applicationName.toStdWString(), - applicationName.toStdWString(), - version.toStdWString() ) ); + WinToastLib::WinToast::configureAUMI( organizationName.toStdWString(), applicationName.toStdWString(), applicationName.toStdWString(), version.toStdWString() ) + ); if ( WinToastLib::WinToast::instance()->initialize() ) { mWinToastInitialized = true; @@ -104,19 +98,19 @@ void QgsWinNative::cleanup() mWindow = nullptr; } -std::unique_ptr< wchar_t[] > pathToWChar( const QString &path ) +std::unique_ptr pathToWChar( const QString &path ) { const QString nativePath = QDir::toNativeSeparators( path ); - std::unique_ptr< wchar_t[] > pathArray( new wchar_t[static_cast< uint>( nativePath.length() + 1 )] ); + std::unique_ptr pathArray( new wchar_t[static_cast( nativePath.length() + 1 )] ); nativePath.toWCharArray( pathArray.get() ); - pathArray[static_cast< size_t >( nativePath.length() )] = 0; + pathArray[static_cast( nativePath.length() )] = 0; return pathArray; } void QgsWinNative::openFileExplorerAndSelectFile( const QString &path ) { - std::unique_ptr< wchar_t[] > pathArray = pathToWChar( path ); + std::unique_ptr pathArray = pathToWChar( path ); ITEMIDLIST_unique_ptr pidl( ILCreateFromPathW( pathArray.get() ) ); if ( pidl ) { @@ -127,11 +121,11 @@ void QgsWinNative::openFileExplorerAndSelectFile( const QString &path ) void QgsWinNative::showFileProperties( const QString &path ) { - std::unique_ptr< wchar_t[] > pathArray = pathToWChar( path ); + std::unique_ptr pathArray = pathToWChar( path ); ITEMIDLIST_unique_ptr pidl( ILCreateFromPathW( pathArray.get() ) ); if ( pidl ) { - SHELLEXECUTEINFO info{ sizeof( info ) }; + SHELLEXECUTEINFO info { sizeof( info ) }; if ( mWindow ) info.hwnd = reinterpret_cast( mWindow->winId() ); info.nShow = SW_SHOWNORMAL; @@ -145,7 +139,7 @@ void QgsWinNative::showFileProperties( const QString &path ) void QgsWinNative::showUndefinedApplicationProgress() { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) mTaskProgress->setMaximum( 0 ); mTaskProgress->show(); #endif @@ -153,23 +147,23 @@ void QgsWinNative::showUndefinedApplicationProgress() void QgsWinNative::setApplicationProgress( double progress ) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) mTaskProgress->setMaximum( 100 ); mTaskProgress->show(); - mTaskProgress->setValue( static_cast< int >( std::round( progress ) ) ); + mTaskProgress->setValue( static_cast( std::round( progress ) ) ); #endif } void QgsWinNative::hideApplicationProgress() { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) mTaskProgress->hide(); #endif } void QgsWinNative::onRecentProjectsChanged( const std::vector &recentProjects ) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QWinJumpList jumplist; jumplist.recent()->clear(); for ( const RecentProjectProperties &recentProject : recentProjects ) @@ -187,7 +181,6 @@ void QgsWinNative::onRecentProjectsChanged( const std::vectorflags |= CREATE_NEW_CONSOLE; - args->startupInfo->dwFlags &= ~ STARTF_USESTDHANDLES; + args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES; } ); process.setWorkingDirectory( path ); @@ -247,13 +239,13 @@ bool QgsWinNative::openTerminalAtPath( const QString &path ) return process.startDetached( &pid ); } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) bool QgsWinNativeEventFilter::nativeEventFilter( const QByteArray &eventType, void *message, long * ) #else bool QgsWinNativeEventFilter::nativeEventFilter( const QByteArray &eventType, void *message, qintptr * ) #endif { - static const QByteArray sWindowsGenericMSG{ "windows_generic_MSG" }; + static const QByteArray sWindowsGenericMSG { "windows_generic_MSG" }; if ( !message || eventType != sWindowsGenericMSG ) return false; @@ -287,7 +279,7 @@ bool QgsWinNativeEventFilter::nativeEventFilter( const QByteArray &eventType, vo // need to handle disks with multiple partitions -- these are given by a single event unsigned long unitmask = broadcastVolume->dbcv_unitmask; - std::vector< QString > drives; + std::vector drives; char driveName[] = "A:/"; unitmask &= 0x3ffffff; while ( unitmask ) diff --git a/src/native/win/qgswinnative.h b/src/native/win/qgswinnative.h index c67902998128..cb98988467d7 100644 --- a/src/native/win/qgswinnative.h +++ b/src/native/win/qgswinnative.h @@ -23,9 +23,9 @@ #include #include -#pragma comment(lib,"Shell32.lib") +#pragma comment( lib, "Shell32.lib" ) -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) class QWinTaskbarButton; class QWinTaskbarProgress; #endif @@ -36,8 +36,7 @@ class QgsWinNativeEventFilter : public QObject, public QAbstractNativeEventFilte { Q_OBJECT public: - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) bool nativeEventFilter( const QByteArray &eventType, void *message, long * ) override; #else bool nativeEventFilter( const QByteArray &eventType, void *message, qintptr *result ) override; @@ -48,7 +47,6 @@ class QgsWinNativeEventFilter : public QObject, public QAbstractNativeEventFilte void usbStorageNotification( const QString &path, bool inserted ); private: - quintptr mLastMessageHash = 0; }; @@ -57,31 +55,26 @@ class NATIVE_EXPORT QgsWinNative : public QgsNative { public: Capabilities capabilities() const override; - void initializeMainWindow( QWindow *window, - const QString &applicationName, - const QString &organizationName, - const QString &version ) override; + void initializeMainWindow( QWindow *window, const QString &applicationName, const QString &organizationName, const QString &version ) override; void cleanup() override; void openFileExplorerAndSelectFile( const QString &path ) override; void showFileProperties( const QString &path ) override; void showUndefinedApplicationProgress() override; void setApplicationProgress( double progress ) override; void hideApplicationProgress() override; - void onRecentProjectsChanged( const std::vector< RecentProjectProperties > &recentProjects ) override; + void onRecentProjectsChanged( const std::vector &recentProjects ) override; NotificationResult showDesktopNotification( const QString &summary, const QString &body, const NotificationSettings &settings = NotificationSettings() ) override; bool openTerminalAtPath( const QString &path ) override; private: - QWindow *mWindow = nullptr; Capabilities mCapabilities = NativeFilePropertiesDialog | NativeOpenTerminalAtPath; bool mWinToastInitialized = false; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QWinTaskbarButton *mTaskButton = nullptr; QWinTaskbarProgress *mTaskProgress = nullptr; #endif QgsWinNativeEventFilter *mNativeEventFilter = nullptr; - }; #endif // QGSWINNATIVE_H diff --git a/src/plugins/geometry_checker/qgsgeometrycheckerdialog.cpp b/src/plugins/geometry_checker/qgsgeometrycheckerdialog.cpp index a9755f5a27b3..dd26b5b82881 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckerdialog.cpp +++ b/src/plugins/geometry_checker/qgsgeometrycheckerdialog.cpp @@ -48,8 +48,8 @@ QgsGeometryCheckerDialog::QgsGeometryCheckerDialog( QgisInterface *iface, QWidge connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject ); connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsGeometryCheckerDialog::showHelp ); - connect( dynamic_cast< QgsGeometryCheckerSetupTab * >( mTabWidget->widget( 0 ) ), &QgsGeometryCheckerSetupTab::checkerStarted, this, &QgsGeometryCheckerDialog::onCheckerStarted ); - connect( dynamic_cast< QgsGeometryCheckerSetupTab * >( mTabWidget->widget( 0 ) ), &QgsGeometryCheckerSetupTab::checkerFinished, this, &QgsGeometryCheckerDialog::onCheckerFinished ); + connect( dynamic_cast( mTabWidget->widget( 0 ) ), &QgsGeometryCheckerSetupTab::checkerStarted, this, &QgsGeometryCheckerDialog::onCheckerStarted ); + connect( dynamic_cast( mTabWidget->widget( 0 ) ), &QgsGeometryCheckerSetupTab::checkerFinished, this, &QgsGeometryCheckerDialog::onCheckerFinished ); } void QgsGeometryCheckerDialog::onCheckerStarted( QgsGeometryChecker *checker ) @@ -93,8 +93,7 @@ void QgsGeometryCheckerDialog::closeEvent( QCloseEvent *ev ) } } - if ( qobject_cast( mTabWidget->widget( 1 ) ) && - !static_cast( mTabWidget->widget( 1 ) )->isCloseable() ) + if ( qobject_cast( mTabWidget->widget( 1 ) ) && !static_cast( mTabWidget->widget( 1 ) )->isCloseable() ) { ev->ignore(); } diff --git a/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.cpp b/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.cpp index 4f5beaddd67a..683d313b10b4 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.cpp +++ b/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.cpp @@ -25,9 +25,7 @@ #include "qgsvectorlayer.h" #include "qgsgeometrycheckerror.h" -QgsGeometryCheckerFixSummaryDialog::QgsGeometryCheckerFixSummaryDialog( const Statistics &stats, - QgsGeometryChecker *checker, - QWidget *parent ) +QgsGeometryCheckerFixSummaryDialog::QgsGeometryCheckerFixSummaryDialog( const Statistics &stats, QgsGeometryChecker *checker, QWidget *parent ) : QDialog( parent ) , mChecker( checker ) { @@ -117,7 +115,7 @@ void QgsGeometryCheckerFixSummaryDialog::onTableSelectionChanged( const QItemSel QItemSelectionModel *selModel = qobject_cast( QObject::sender() ); const QAbstractItemModel *model = selModel->model(); - for ( QTableWidget *table : {ui.tableWidgetFixedErrors, ui.tableWidgetNewErrors, ui.tableWidgetNotFixed, ui.tableWidgetObsoleteErrors} ) + for ( QTableWidget *table : { ui.tableWidgetFixedErrors, ui.tableWidgetNewErrors, ui.tableWidgetNotFixed, ui.tableWidgetObsoleteErrors } ) { if ( table->selectionModel() != selModel ) { diff --git a/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.h b/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.h index 735ce9be74c6..63f94cfe1aa4 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.h +++ b/src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.h @@ -32,14 +32,14 @@ class QgsGeometryCheckerFixSummaryDialog : public QDialog public: struct Statistics { - QSet newErrors; - QSet obsoleteErrors; - QSet fixedErrors; - QSet failedErrors; - int itemCount() const - { - return newErrors.size() + obsoleteErrors.size() + fixedErrors.size() + failedErrors.size(); - } + QSet newErrors; + QSet obsoleteErrors; + QSet fixedErrors; + QSet failedErrors; + int itemCount() const + { + return newErrors.size() + obsoleteErrors.size() + fixedErrors.size() + failedErrors.size(); + } }; QgsGeometryCheckerFixSummaryDialog( const Statistics &stats, QgsGeometryChecker *checker, QWidget *parent = nullptr ); diff --git a/src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp b/src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp index 27dacb9d5efc..12d2c3361729 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp +++ b/src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp @@ -81,7 +81,7 @@ QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface *iface, connect( ui.pushButtonFixWithDefault, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::fixErrorsWithDefault ); connect( ui.pushButtonFixWithPrompt, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::fixErrorsWithPrompt ); connect( ui.pushButtonErrorResolutionSettings, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::setDefaultResolutionMethods ); - connect( ui.checkBoxHighlight, &QAbstractButton::clicked, this, [ = ] { QgsGeometryCheckerResultTab::highlightErrors(); } ); + connect( ui.checkBoxHighlight, &QAbstractButton::clicked, this, [=] { QgsGeometryCheckerResultTab::highlightErrors(); } ); connect( QgsProject::instance(), static_cast( &QgsProject::layersWillBeRemoved ), this, &QgsGeometryCheckerResultTab::checkRemovedLayer ); connect( ui.pushButtonExport, &QAbstractButton::clicked, this, &QgsGeometryCheckerResultTab::exportErrors ); @@ -112,7 +112,6 @@ QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface *iface, QgsGeometryCheckerResultTab::~QgsGeometryCheckerResultTab() { - delete mChecker; qDeleteAll( mCurrentRubberBands ); } @@ -204,7 +203,7 @@ void QgsGeometryCheckerResultTab::updateError( QgsGeometryCheckError *error, boo else if ( error->status() == QgsGeometryCheckError::StatusObsolete ) { ui.tableWidgetErrors->setRowHidden( row, true ); -// setRowStatus( row, Qt::gray, tr( "Obsolete" ), false ); + // setRowStatus( row, Qt::gray, tr( "Obsolete" ), false ); --mErrorCount; // If error was new, don't report it as obsolete since the user never got to see the new error anyways if ( statusChanged && !mStatistics.newErrors.remove( error ) ) @@ -252,7 +251,7 @@ void QgsGeometryCheckerResultTab::exportErrors() bool QgsGeometryCheckerResultTab::exportErrorsDo( const QString &file ) { - QList< QPair > attributes; + QList> attributes; attributes.append( qMakePair( QStringLiteral( "Layer" ), QStringLiteral( "String;30;" ) ) ); attributes.append( qMakePair( QStringLiteral( "FeatureID" ), QStringLiteral( "String;20;" ) ) ); attributes.append( qMakePair( QStringLiteral( "ErrorDesc" ), QStringLiteral( "String;80;" ) ) ); @@ -306,8 +305,7 @@ bool QgsGeometryCheckerResultTab::exportErrorsDo( const QString &file ) QStringList toRemove; for ( QgsMapLayer *maplayer : QgsProject::instance()->mapLayers() ) { - if ( qobject_cast( maplayer ) && - static_cast( maplayer )->dataProvider()->dataSourceUri() == layer->dataProvider()->dataSourceUri() ) + if ( qobject_cast( maplayer ) && static_cast( maplayer )->dataProvider()->dataSourceUri() == layer->dataProvider()->dataSourceUri() ) { toRemove.append( maplayer->id() ); } @@ -468,7 +466,6 @@ void QgsGeometryCheckerResultTab::openAttributeTable() void QgsGeometryCheckerResultTab::fixErrors( bool prompt ) { - //! Collect errors to fix QModelIndexList rows = ui.tableWidgetErrors->selectionModel()->selectedRows(); if ( rows.isEmpty() ) diff --git a/src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp b/src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp index c070d84e4730..47a6a2544c61 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp +++ b/src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp @@ -351,7 +351,7 @@ void QgsGeometryCheckerSetupTab::runChecks() saveOptions.fileEncoding = layer->dataProvider()->encoding(); saveOptions.driverName = outputDriverName; saveOptions.onlySelectedFeatures = selectedOnly; - QgsVectorFileWriter::WriterError err = QgsVectorFileWriter::writeAsVectorFormatV3( layer, outputPath, layer->transformContext(), saveOptions, &errMsg, nullptr, nullptr ); + QgsVectorFileWriter::WriterError err = QgsVectorFileWriter::writeAsVectorFormatV3( layer, outputPath, layer->transformContext(), saveOptions, &errMsg, nullptr, nullptr ); if ( err != QgsVectorFileWriter::NoError ) { createErrors.append( errMsg ); @@ -529,5 +529,5 @@ void QgsGeometryCheckerSetupTab::showCancelFeedback() mAbortButton->setEnabled( false ); ui.labelStatus->setText( tr( "Waiting for running checks to finish…" ) ); ui.labelStatus->show(); - ui.progressBar->hide() ; + ui.progressBar->hide(); } diff --git a/src/plugins/geometry_checker/qgsgeometrycheckfactory.cpp b/src/plugins/geometry_checker/qgsgeometrycheckfactory.cpp index bb6c7594b57d..36f94c5c0580 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckfactory.cpp +++ b/src/plugins/geometry_checker/qgsgeometrycheckfactory.cpp @@ -688,27 +688,27 @@ template<> QgsGeometryCheck *QgsGeometryCheckFactoryT::cre int allowedTypes = 0; if ( ui.checkBoxPoint->isEnabled() && ui.checkBoxPoint->isChecked() ) { - allowedTypes |= 1 << static_cast< quint32>( Qgis::WkbType::Point ); + allowedTypes |= 1 << static_cast( Qgis::WkbType::Point ); } if ( ui.checkBoxMultipoint->isEnabled() && ui.checkBoxMultipoint->isChecked() ) { - allowedTypes |= 1 << static_cast< quint32>( Qgis::WkbType::MultiPoint ); + allowedTypes |= 1 << static_cast( Qgis::WkbType::MultiPoint ); } if ( ui.checkBoxLine->isEnabled() && ui.checkBoxLine->isChecked() ) { - allowedTypes |= 1 << static_cast< quint32>( Qgis::WkbType::LineString ); + allowedTypes |= 1 << static_cast( Qgis::WkbType::LineString ); } if ( ui.checkBoxMultiline->isEnabled() && ui.checkBoxMultiline->isChecked() ) { - allowedTypes |= 1 << static_cast< quint32>( Qgis::WkbType::MultiLineString ); + allowedTypes |= 1 << static_cast( Qgis::WkbType::MultiLineString ); } if ( ui.checkBoxPolygon->isEnabled() && ui.checkBoxPolygon->isChecked() ) { - allowedTypes |= 1 << static_cast< quint32>( Qgis::WkbType::Polygon ); + allowedTypes |= 1 << static_cast( Qgis::WkbType::Polygon ); } if ( ui.checkBoxMultipolygon->isEnabled() && ui.checkBoxMultipolygon->isChecked() ) { - allowedTypes |= 1 << static_cast< quint32>( Qgis::WkbType::MultiPolygon ); + allowedTypes |= 1 << static_cast( Qgis::WkbType::MultiPolygon ); } if ( allowedTypes != 0 ) { diff --git a/src/plugins/geometry_checker/qgsgeometrycheckfactory.h b/src/plugins/geometry_checker/qgsgeometrycheckfactory.h index 400c063826b0..59110f4a0883 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckfactory.h +++ b/src/plugins/geometry_checker/qgsgeometrycheckfactory.h @@ -53,6 +53,7 @@ class QgsGeometryCheckFactoryRegistry { return instance()->mFactories; } + private: QList mFactories; QgsGeometryCheckFactoryRegistry() = default; @@ -65,13 +66,17 @@ class QgsGeometryCheckFactoryRegistry } }; -#define QGSGEOMETRYCHECKFACTORY_CONCAT(X, Y) X##Y -#define QGSGEOMETRYCHECKFACTORY_UNIQUEVAR_(X, Y) QGSGEOMETRYCHECKFACTORY_CONCAT(X, Y) -#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -# define QGSGEOMETRYCHECKFACTORY_UNUSED __attribute__((__unused__)) +#define QGSGEOMETRYCHECKFACTORY_CONCAT( X, Y ) X##Y +#define QGSGEOMETRYCHECKFACTORY_UNIQUEVAR_( X, Y ) QGSGEOMETRYCHECKFACTORY_CONCAT( X, Y ) +#if ( __GNUC__ > 2 ) || ( __GNUC__ == 2 && __GNUC_MINOR__ > 4 ) +#define QGSGEOMETRYCHECKFACTORY_UNUSED __attribute__( ( __unused__ ) ) #else -# define QGSGEOMETRYCHECKFACTORY_UNUSED +#define QGSGEOMETRYCHECKFACTORY_UNUSED #endif -#define REGISTER_QGS_GEOMETRY_CHECK_FACTORY(CheckFactory) namespace { static QGSGEOMETRYCHECKFACTORY_UNUSED bool QGSGEOMETRYCHECKFACTORY_UNIQUEVAR_(b, __LINE__) = QgsGeometryCheckFactoryRegistry::registerCheckFactory(new CheckFactory()); } +#define REGISTER_QGS_GEOMETRY_CHECK_FACTORY( CheckFactory ) \ + namespace \ + { \ + static QGSGEOMETRYCHECKFACTORY_UNUSED bool QGSGEOMETRYCHECKFACTORY_UNIQUEVAR_( b, __LINE__ ) = QgsGeometryCheckFactoryRegistry::registerCheckFactory( new CheckFactory() ); \ + } #endif // QGS_GEOMETRY_CHECK_FACTORY_H diff --git a/src/plugins/geometry_checker/qgsgeometrycheckfixdialog.cpp b/src/plugins/geometry_checker/qgsgeometrycheckfixdialog.cpp index b386109522e5..82beddacdfa6 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckfixdialog.cpp +++ b/src/plugins/geometry_checker/qgsgeometrycheckfixdialog.cpp @@ -33,8 +33,7 @@ #include "qgsgeometrychecker.h" #include "qgsgeometrycheck.h" -QgsGeometryCheckerFixDialog::QgsGeometryCheckerFixDialog( QgsGeometryChecker *checker, - const QList &errors, QWidget *parent ) +QgsGeometryCheckerFixDialog::QgsGeometryCheckerFixDialog( QgsGeometryChecker *checker, const QList &errors, QWidget *parent ) : QDialog( parent ) , mChecker( checker ) , mErrors( errors ) @@ -74,7 +73,6 @@ QgsGeometryCheckerFixDialog::QgsGeometryCheckerFixDialog( QgsGeometryChecker *ch connect( mNextBtn, &QAbstractButton::clicked, this, &QgsGeometryCheckerFixDialog::setupNextError ); connect( mFixBtn, &QAbstractButton::clicked, this, &QgsGeometryCheckerFixDialog::fixError ); connect( mSkipBtn, &QAbstractButton::clicked, this, &QgsGeometryCheckerFixDialog::skipError ); - } void QgsGeometryCheckerFixDialog::showEvent( QShowEvent * ) diff --git a/src/plugins/grass/qgsgrassaddfeature.h b/src/plugins/grass/qgsgrassaddfeature.h index a6899c8cfd57..3dad14e9c864 100644 --- a/src/plugins/grass/qgsgrassaddfeature.h +++ b/src/plugins/grass/qgsgrassaddfeature.h @@ -24,7 +24,6 @@ class QgsGrassAddFeature : public QgsMapToolAddFeature Q_OBJECT public: QgsGrassAddFeature( QgsMapCanvas *canvas, CaptureMode mode ); - }; #endif // QGSGRASSADDFEATURE_H diff --git a/src/plugins/grass/qgsgrasseditrenderer.cpp b/src/plugins/grass/qgsgrasseditrenderer.cpp index dc84958605d9..2ad8cae77f11 100644 --- a/src/plugins/grass/qgsgrasseditrenderer.cpp +++ b/src/plugins/grass/qgsgrasseditrenderer.cpp @@ -14,7 +14,7 @@ * * ***************************************************************************/ -#include +#include #include "qgscategorizedsymbolrenderer.h" #include "qgscategorizedsymbolrendererwidget.h" @@ -125,16 +125,11 @@ QgsSymbol *QgsGrassEditRenderer::symbolForFeature( const QgsFeature &feature, Qg QgsDebugMsgLevel( QString( "fid = %1 symbolCode = %2" ).arg( feature.id() ).arg( symbolCode ), 3 ); QgsSymbol *symbol = nullptr; - if ( symbolCode == QgsGrassVectorMap::TopoPoint || symbolCode == QgsGrassVectorMap::TopoCentroidIn || - symbolCode == QgsGrassVectorMap::TopoCentroidOut || symbolCode == QgsGrassVectorMap::TopoCentroidDupl || - symbolCode == QgsGrassVectorMap::TopoNode0 || symbolCode == QgsGrassVectorMap::TopoNode1 || - symbolCode == QgsGrassVectorMap::TopoNode2 ) + if ( symbolCode == QgsGrassVectorMap::TopoPoint || symbolCode == QgsGrassVectorMap::TopoCentroidIn || symbolCode == QgsGrassVectorMap::TopoCentroidOut || symbolCode == QgsGrassVectorMap::TopoCentroidDupl || symbolCode == QgsGrassVectorMap::TopoNode0 || symbolCode == QgsGrassVectorMap::TopoNode1 || symbolCode == QgsGrassVectorMap::TopoNode2 ) { symbol = mMarkerRenderer->symbolForFeature( feature, context ); } - else if ( symbolCode == QgsGrassVectorMap::TopoLine || symbolCode == QgsGrassVectorMap::TopoBoundaryError || - symbolCode == QgsGrassVectorMap::TopoBoundaryErrorLeft || symbolCode == QgsGrassVectorMap::TopoBoundaryErrorRight || - symbolCode == QgsGrassVectorMap::TopoBoundaryOk ) + else if ( symbolCode == QgsGrassVectorMap::TopoLine || symbolCode == QgsGrassVectorMap::TopoBoundaryError || symbolCode == QgsGrassVectorMap::TopoBoundaryErrorLeft || symbolCode == QgsGrassVectorMap::TopoBoundaryErrorRight || symbolCode == QgsGrassVectorMap::TopoBoundaryOk ) { symbol = mLineRenderer->symbolForFeature( feature, context ); } @@ -302,6 +297,3 @@ QgsFeatureRenderer *QgsGrassEditRendererWidget::renderer() mRenderer->setMarkerRenderer( mPointRendererWidget->renderer()->clone() ); return mRenderer; } - - - diff --git a/src/plugins/grass/qgsgrasseditrenderer.h b/src/plugins/grass/qgsgrasseditrenderer.h index deb91ed98c2e..1fffc2920c41 100644 --- a/src/plugins/grass/qgsgrasseditrenderer.h +++ b/src/plugins/grass/qgsgrasseditrenderer.h @@ -27,7 +27,6 @@ class QgsGrassEditRenderer : public QgsFeatureRenderer { public: - QgsGrassEditRenderer(); ~QgsGrassEditRenderer() override; diff --git a/src/plugins/grass/qgsgrassmapcalc.cpp b/src/plugins/grass/qgsgrassmapcalc.cpp index f2775772c882..338b9e6a53f5 100644 --- a/src/plugins/grass/qgsgrassmapcalc.cpp +++ b/src/plugins/grass/qgsgrassmapcalc.cpp @@ -39,7 +39,8 @@ QgsGrassMapcalc::QgsGrassMapcalc( QgsGrassTools *tools, QgsGrassModule *module, QgisInterface *iface, - QWidget *parent, Qt::WindowFlags f ) + QWidget *parent, Qt::WindowFlags f +) : QMainWindow( iface->mainWindow(), Qt::Dialog ) , QgsGrassMapcalcBase() , QgsGrassModuleOptions( tools, module, iface, false ) @@ -80,43 +81,37 @@ QgsGrassMapcalc::QgsGrassMapcalc( QActionGroup *ag = new QActionGroup( this ); QToolBar *tb = addToolBar( tr( "Mapcalc tools" ) ); - mActionAddMap = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_map.png" ) ), - tr( "Add map" ), this ); + mActionAddMap = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_map.png" ) ), tr( "Add map" ), this ); mActionAddMap->setCheckable( true ); ag->addAction( mActionAddMap ); tb->addAction( mActionAddMap ); connect( mActionAddMap, &QAction::triggered, this, &QgsGrassMapcalc::addMap ); - mActionAddConstant = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_constant.png" ) ), - tr( "Add constant value" ), this ); + mActionAddConstant = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_constant.png" ) ), tr( "Add constant value" ), this ); mActionAddConstant->setCheckable( true ); ag->addAction( mActionAddConstant ); tb->addAction( mActionAddConstant ); connect( mActionAddConstant, &QAction::triggered, this, &QgsGrassMapcalc::addConstant ); - mActionAddFunction = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_function.png" ) ), - tr( "Add operator or function" ), this ); + mActionAddFunction = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_function.png" ) ), tr( "Add operator or function" ), this ); mActionAddFunction->setCheckable( true ); ag->addAction( mActionAddFunction ); tb->addAction( mActionAddFunction ); connect( mActionAddFunction, &QAction::triggered, this, &QgsGrassMapcalc::addFunction ); - mActionAddConnection = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_connection.png" ) ), - tr( "Add connection" ), this ); + mActionAddConnection = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_add_connection.png" ) ), tr( "Add connection" ), this ); mActionAddConnection->setCheckable( true ); ag->addAction( mActionAddConnection ); tb->addAction( mActionAddConnection ); connect( mActionAddConnection, &QAction::triggered, this, &QgsGrassMapcalc::addConnection ); - mActionSelectItem = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_select.png" ) ), - tr( "Select item" ), this ); + mActionSelectItem = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_select.png" ) ), tr( "Select item" ), this ); mActionSelectItem->setCheckable( true ); ag->addAction( mActionSelectItem ); tb->addAction( mActionSelectItem ); connect( mActionSelectItem, &QAction::triggered, this, &QgsGrassMapcalc::selectItem ); - mActionDeleteItem = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_delete.png" ) ), - tr( "Delete selected item" ), this ); + mActionDeleteItem = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_delete.png" ) ), tr( "Delete selected item" ), this ); mActionDeleteItem->setCheckable( true ); mActionDeleteItem->setEnabled( false ); ag->addAction( mActionDeleteItem ); @@ -125,27 +120,24 @@ QgsGrassMapcalc::QgsGrassMapcalc( mActionAddMap->setChecked( true ); - mActionLoad = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_open.png" ) ), - tr( "Open" ), this ); + mActionLoad = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_open.png" ) ), tr( "Open" ), this ); tb->addAction( mActionLoad ); connect( mActionLoad, &QAction::triggered, this, &QgsGrassMapcalc::load ); - mActionSave = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_save.png" ) ), - tr( "Save" ), this ); + mActionSave = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_save.png" ) ), tr( "Save" ), this ); tb->addAction( mActionSave ); connect( mActionSave, &QAction::triggered, this, &QgsGrassMapcalc::save ); mActionSave->setEnabled( false ); - mActionSaveAs = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_save_as.png" ) ), - tr( "Save as" ), this ); + mActionSaveAs = new QAction( QgsGrassPlugin::getThemeIcon( QStringLiteral( "mapcalc_save_as.png" ) ), tr( "Save as" ), this ); tb->addAction( mActionSaveAs ); connect( mActionSaveAs, &QAction::triggered, this, &QgsGrassMapcalc::saveAs ); // Map input mMapComboBox = new QgsGrassModuleInputComboBox( QgsGrassObject::Raster, this ); - mMapComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy:: Preferred ); + mMapComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); // QComboBox does not emit activated() when item is selected in completer popup - connect( mMapComboBox, qOverload< int >( &QComboBox::activated ), this, [ = ]( int index ) { mapChanged( mMapComboBox->itemText( index ) ); } ); + connect( mMapComboBox, qOverload( &QComboBox::activated ), this, [=]( int index ) { mapChanged( mMapComboBox->itemText( index ) ); } ); connect( mMapComboBox->completer(), static_cast( &QCompleter::activated ), this, &QgsGrassMapcalc::mapChanged ); connect( mMapComboBox, &QComboBox::editTextChanged, this, &QgsGrassMapcalc::mapChanged ); bool firstSet = mMapComboBox->setFirst(); @@ -165,19 +157,19 @@ QgsGrassMapcalc::QgsGrassMapcalc( // Logical mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "==" ), 2, tr( "Equal" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "!=" ), 2, tr( "Not equal" ) ) ); - mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( ">" ), 2, tr( "Greater than" ) ) ); + mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( ">" ), 2, tr( "Greater than" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( ">=" ), 2, tr( "Greater than or equal" ) ) ); - mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "<" ), 2, tr( "Less than" ) ) ); + mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "<" ), 2, tr( "Less than" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "<=" ), 2, tr( "Less than or equal" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "&&" ), 2, tr( "And" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "||" ), 2, tr( "Or" ) ) ); t = QgsGrassMapcalcFunction::Function; - mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "abs" ), 1, tr( "Absolute value of x" ), QStringLiteral( "abs(x)" ) ) ); + mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "abs" ), 1, tr( "Absolute value of x" ), QStringLiteral( "abs(x)" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "atan" ), 1, tr( "Inverse tangent of x (result is in degrees)" ), QStringLiteral( "atan(x)" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "atan" ), 2, tr( "Inverse tangent of y/x (result is in degrees)" ), QStringLiteral( "atan(x,y)" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "col" ), 0, tr( "Current column of moving window (starts with 1)" ) ) ); - mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "cos" ), 1, tr( "Cosine of x (x is in degrees)" ), QStringLiteral( "cos(x)" ) ) ); + mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "cos" ), 1, tr( "Cosine of x (x is in degrees)" ), QStringLiteral( "cos(x)" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "double" ), 1, tr( "Convert x to double-precision floating point" ), QStringLiteral( "double(x)" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "ewres" ), 0, tr( "Current east-west resolution" ) ) ); mFunctions.push_back( QgsGrassMapcalcFunction( t, QStringLiteral( "exp" ), 1, tr( "Exponential function of x" ), QStringLiteral( "exp(x)" ) ) ); @@ -213,8 +205,7 @@ QgsGrassMapcalc::QgsGrassMapcalc( for ( unsigned int i = 0; i < mFunctions.size(); i++ ) { - mFunctionComboBox->addItem( mFunctions[i].label() - + " " + mFunctions[i].description() ); + mFunctionComboBox->addItem( mFunctions[i].label() + " " + mFunctions[i].description() ); } // Add output object @@ -222,7 +213,7 @@ QgsGrassMapcalc::QgsGrassMapcalc( mOutput->setId( nextId() ); mOutput->setValue( tr( "Output" ) ); mCanvasScene->addItem( mOutput ); - mOutput->setCenter( ( int )( mCanvasScene->width() - mOutput->rect().width() ), ( int )( mCanvasScene->height() / 2 ) ); + mOutput->setCenter( ( int ) ( mCanvasScene->width() - mOutput->rect().width() ), ( int ) ( mCanvasScene->height() / 2 ) ); mCanvasScene->update(); mOutput->QGraphicsRectItem::show(); @@ -252,7 +243,7 @@ void QgsGrassMapcalc::mousePressEvent( QMouseEvent *e ) mObject->setCenter( p.x(), p.y() ); mObject = nullptr; //addMap(); // restart - setTool( mTool ); // restart + setTool( mTool ); // restart break; case AddConnector: @@ -327,8 +318,7 @@ void QgsGrassMapcalc::mousePressEvent( QMouseEvent *e ) mView->setCursor( QCursor( Qt::CrossCursor ) ); } - if ( mConnector || - ( mObject && mObject->type() != QgsGrassMapcalcObject::Output ) ) + if ( mConnector || ( mObject && mObject->type() != QgsGrassMapcalcObject::Output ) ) { mActionDeleteItem->setEnabled( true ); } @@ -364,8 +354,8 @@ void QgsGrassMapcalc::mouseMoveEvent( QMouseEvent *e ) if ( mToolStep == 1 ) { mConnector->setPoint( 1, p ); - mConnector->setSocket( 1 ); // disconnect - mConnector->tryConnectEnd( 1 ); // try to connect + mConnector->setSocket( 1 ); // disconnect + mConnector->tryConnectEnd( 1 ); // try to connect } break; @@ -388,18 +378,16 @@ void QgsGrassMapcalc::mouseMoveEvent( QMouseEvent *e ) for ( int i = 0; i < 2; i++ ) { //QPoint pe = mConnector->point( i ); - mConnector->setSocket( i ); // disconnect - mConnector->setPoint( i, QPoint( - mStartMoveConnectorPoints[i].x() + dx, - mStartMoveConnectorPoints[i].y() + dy ) ); - mConnector->tryConnectEnd( i ); // try to connect + mConnector->setSocket( i ); // disconnect + mConnector->setPoint( i, QPoint( mStartMoveConnectorPoints[i].x() + dx, mStartMoveConnectorPoints[i].y() + dy ) ); + mConnector->tryConnectEnd( i ); // try to connect } } else { - mConnector->setSocket( end ); // disconnect + mConnector->setSocket( end ); // disconnect mConnector->setPoint( end, QPoint( p.x(), p.y() ) ); - mConnector->tryConnectEnd( end ); // try to connect + mConnector->tryConnectEnd( end ); // try to connect } } break; @@ -422,16 +410,15 @@ void QgsGrassMapcalc::mouseReleaseEvent( QMouseEvent *e ) if ( mToolStep == 1 ) { QPoint p0 = mConnector->point( 0 ); - double d = std::sqrt( std::pow( ( double )( p.x() - p0.x() ), 2.0 ) - + std::pow( ( double )( p.y() - p0.y() ), 2.0 ) ); + double d = std::sqrt( std::pow( ( double ) ( p.x() - p0.x() ), 2.0 ) + std::pow( ( double ) ( p.y() - p0.y() ), 2.0 ) ); QgsDebugMsgLevel( QString( "d = %1" ).arg( d ), 4 ); - if ( d < 5 ) // filter 'single' clicks + if ( d < 5 ) // filter 'single' clicks { - mConnector->setSocket( 0 ); // disconnect + mConnector->setSocket( 0 ); // disconnect delete mConnector; } mConnector = nullptr; - setTool( mTool ); // restart + setTool( mTool ); // restart } break; @@ -522,17 +509,13 @@ QStringList QgsGrassMapcalc::checkRegion() if ( mm.size() > 1 ) mapset = mm.at( 1 ); - if ( !QgsGrass::mapRegion( QgsGrassObject::Raster, - QgsGrass::getDefaultGisdbase(), - QgsGrass::getDefaultLocation(), mapset, map, - &window ) ) + if ( !QgsGrass::mapRegion( QgsGrassObject::Raster, QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), mapset, map, &window ) ) { QMessageBox::warning( nullptr, tr( "Warning" ), tr( "Cannot check region of map %1" ).arg( obj->value() ) ); continue; } - if ( G_window_overlap( ¤tWindow, - window.north, window.south, window.east, window.west ) == 0 ) + if ( G_window_overlap( ¤tWindow, window.north, window.south, window.east, window.west ) == 0 ) { list.append( obj->value() ); } @@ -581,10 +564,7 @@ bool QgsGrassMapcalc::inputRegion( struct Cell_head *window, QgsCoordinateRefere if ( mm.size() > 1 ) mapset = mm.at( 1 ); - if ( !QgsGrass::mapRegion( QgsGrassObject::Raster, - QgsGrass::getDefaultGisdbase(), - QgsGrass::getDefaultLocation(), mapset, map, - &mapWindow ) ) + if ( !QgsGrass::mapRegion( QgsGrassObject::Raster, QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), mapset, map, &mapWindow ) ) { QMessageBox::warning( nullptr, tr( "Warning" ), tr( "Cannot get region of map %1" ).arg( obj->value() ) ); return false; @@ -643,7 +623,6 @@ void QgsGrassMapcalc::showOptions( int tool ) void QgsGrassMapcalc::setOption() { - if ( mTool != Select ) return; if ( !mObject ) @@ -651,7 +630,7 @@ void QgsGrassMapcalc::setOption() switch ( mObject->type() ) { - case QgsGrassMapcalcObject::Map : + case QgsGrassMapcalcObject::Map: { QStringList mapMapset = mObject->value().split( '@' ); if ( !mMapComboBox->setCurrent( mapMapset.value( 0 ), mapMapset.value( 1 ) ) ) @@ -661,11 +640,11 @@ void QgsGrassMapcalc::setOption() break; } - case QgsGrassMapcalcObject::Constant : + case QgsGrassMapcalcObject::Constant: mConstantLineEdit->setText( mObject->value() ); break; - case QgsGrassMapcalcObject::Function : + case QgsGrassMapcalcObject::Function: for ( unsigned int i = 0; i < mFunctions.size(); i++ ) { if ( mFunctions[i].name() != mObject->function().name() ) @@ -680,7 +659,6 @@ void QgsGrassMapcalc::setOption() break; } - } void QgsGrassMapcalc::setTool( int tool ) @@ -739,7 +717,7 @@ void QgsGrassMapcalc::setTool( int tool ) mObject = new QgsGrassMapcalcObject( QgsGrassMapcalcObject::Function ); mObject->setId( nextId() ); //mObject->setValue ( mFunctionComboBox->currentText() ); - mObject->setFunction( mFunctions[ mFunctionComboBox->currentIndex()] ); + mObject->setFunction( mFunctions[mFunctionComboBox->currentIndex()] ); mObject->setCenter( mLastPoint.x(), mLastPoint.y() ); mCanvasScene->addItem( mObject ); mObject->QGraphicsRectItem::show(); @@ -838,8 +816,7 @@ void QgsGrassMapcalc::setToolActionsOff() void QgsGrassMapcalc::mapChanged( const QString &text ) { - - if ( ( mTool != AddMap && mTool != Select ) || !mObject ) + if ( ( mTool != AddMap && mTool != Select ) || !mObject ) return; if ( mObject->type() != QgsGrassMapcalcObject::Map ) return; @@ -850,7 +827,6 @@ void QgsGrassMapcalc::mapChanged( const QString &text ) void QgsGrassMapcalc::constantChanged() { - if ( ( mTool != AddConstant && mTool != Select ) || !mObject ) return; if ( mObject->type() != QgsGrassMapcalcObject::Constant ) @@ -862,13 +838,12 @@ void QgsGrassMapcalc::constantChanged() void QgsGrassMapcalc::functionChanged() { - if ( ( mTool != AddFunction && mTool != Select ) || !mObject ) return; if ( mObject->type() != QgsGrassMapcalcObject::Function ) return; - mObject->setFunction( mFunctions[ mFunctionComboBox->currentIndex()] ); + mObject->setFunction( mFunctions[mFunctionComboBox->currentIndex()] ); mCanvasScene->update(); } @@ -918,7 +893,7 @@ void QgsGrassMapcalc::growCanvas( int left, int right, int top, int bottom ) QPoint p = con->point( i ); p.setX( p.x() + left ); p.setY( p.y() + top ); - con->setPoint( i, p ); + con->setPoint( i, p ); } } } @@ -928,7 +903,6 @@ void QgsGrassMapcalc::growCanvas( int left, int right, int top, int bottom ) void QgsGrassMapcalc::autoGrow() { - int thresh = 15; int left = 0; @@ -955,11 +929,11 @@ void QgsGrassMapcalc::autoGrow() QgsDebugMsgLevel( QString( "r.left = %1 r.right = %2 r.top = %3 bottom = %4" ).arg( r.left() ).arg( r.right() ).arg( r.top() ).arg( r.bottom() ), 4 ); if ( r.left() - thresh < left ) - left = r.left() - thresh; + left = r.left() - thresh; if ( r.right() + thresh > right ) - right = r.right() + thresh; + right = r.right() + thresh; if ( r.top() - thresh < top ) - top = r.top() - thresh; + top = r.top() - thresh; if ( r.bottom() + thresh > bottom ) bottom = r.bottom() + thresh; @@ -975,7 +949,6 @@ void QgsGrassMapcalc::autoGrow() void QgsGrassMapcalc::saveAs() { - // Check/create 'mapcalc' directory in current mapset QString ms = QgsGrass::getDefaultGisdbase() + "/" + QgsGrass::getDefaultLocation() + "/" @@ -999,8 +972,7 @@ void QgsGrassMapcalc::saveAs() for ( ;; ) { bool ok; - name = QInputDialog::getText( this, tr( "New mapcalc" ), - tr( "Enter new mapcalc name:" ), QLineEdit::Normal, mFileName, &ok ); + name = QInputDialog::getText( this, tr( "New mapcalc" ), tr( "Enter new mapcalc name:" ), QLineEdit::Normal, mFileName, &ok ); if ( !ok ) return; name = name.trimmed(); @@ -1014,9 +986,7 @@ void QgsGrassMapcalc::saveAs() // check if exists if ( QFile::exists( mc + "/" + name ) ) { - QMessageBox::StandardButton ret = QMessageBox::question( nullptr, tr( "Warning" ), - tr( "The file already exists. Overwrite?" ), - QMessageBox::Ok | QMessageBox::Cancel ); + QMessageBox::StandardButton ret = QMessageBox::question( nullptr, tr( "Warning" ), tr( "The file already exists. Overwrite?" ), QMessageBox::Ok | QMessageBox::Cancel ); if ( ret == QMessageBox::Cancel ) continue; @@ -1051,8 +1021,7 @@ void QgsGrassMapcalc::save() QFile out( path ); if ( !out.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) { - QMessageBox::warning( this, tr( "Save mapcalc" ), - tr( "Cannot open mapcalc file" ) ); + QMessageBox::warning( this, tr( "Save mapcalc" ), tr( "Cannot open mapcalc file" ) ); return; } @@ -1060,8 +1029,8 @@ void QgsGrassMapcalc::save() stream << "\n"; stream << " width() ) - + "\" height=\"" + QString::number( mCanvasScene->height() ) - + "\"/>\n"; + + "\" height=\"" + QString::number( mCanvasScene->height() ) + + "\"/>\n"; QList l = mCanvasScene->items(); @@ -1102,37 +1071,37 @@ void QgsGrassMapcalc::save() } stream << " id() ) - + "\" x=\"" + QString::number( obj->center().x() ) - + "\" y=\"" + QString::number( obj->center().y() ) - + "\" type=\"" + type - + "\" value=\"" + val + "\""; + + "\" x=\"" + QString::number( obj->center().x() ) + + "\" y=\"" + QString::number( obj->center().y() ) + + "\" type=\"" + type + + "\" value=\"" + val + "\""; if ( obj->type() == QgsGrassMapcalcObject::Function ) { stream << " inputCount=\"" - + QString::number( obj->function().inputCount() ) + "\""; + + QString::number( obj->function().inputCount() ) + "\""; } if ( obj->type() == QgsGrassMapcalcObject::Map ) { stream << " label=\"" + obj->label() + "\""; } - stream << "/>\n"; + stream << "/>\n"; } else if ( QgsGrassMapcalcConnector *con = dynamic_cast( *it ) ) { stream << " id() ) - + "\">\n"; + + "\">\n"; for ( int i = 0; i < 2; i++ ) { stream << " point( i ).x() ) - + "\" y=\"" + QString::number( con->point( i ).y() ) - + "\""; + + "\" y=\"" + QString::number( con->point( i ).y() ) + + "\""; if ( con->object( i ) ) { stream << " object=\"" - + QString::number( con->object( i )->id() ) - + "\" socketType=\""; + + QString::number( con->object( i )->id() ) + + "\" socketType=\""; if ( con->socketDirection( i ) == QgsGrassMapcalcObject::In ) { @@ -1144,11 +1113,10 @@ void QgsGrassMapcalc::save() } stream << "\" socket=\"" - + QString::number( con->socket( i ) ) - + "\""; + + QString::number( con->socket( i ) ) + + "\""; } stream << "/>\n"; - } stream << " \n"; } @@ -1161,7 +1129,6 @@ void QgsGrassMapcalc::save() void QgsGrassMapcalc::load() { - QgsGrassSelect *sel = new QgsGrassSelect( this, QgsGrassSelect::MapCalc ); if ( sel->exec() == QDialog::Rejected ) return; @@ -1178,7 +1145,7 @@ void QgsGrassMapcalc::load() return; } - if ( ! file.open( QIODevice::ReadOnly ) ) + if ( !file.open( QIODevice::ReadOnly ) ) { QMessageBox::warning( nullptr, tr( "Warning" ), tr( "Cannot open mapcalc schema (%1)" ).arg( path ) ); @@ -1188,7 +1155,7 @@ void QgsGrassMapcalc::load() QDomDocument doc( QStringLiteral( "mapcalc" ) ); QString err; int line, column; - int parsed = doc.setContent( &file, &err, &line, &column ); + int parsed = doc.setContent( &file, &err, &line, &column ); file.close(); if ( !parsed ) { @@ -1267,12 +1234,12 @@ void QgsGrassMapcalc::load() break; } - case QgsGrassMapcalcObject::Output : + case QgsGrassMapcalcObject::Output: obj->setValue( tr( "Output" ) ); mOutput = obj; break; - case QgsGrassMapcalcObject::Function : + case QgsGrassMapcalcObject::Function: int inputCount = e.attribute( QStringLiteral( "inputCount" ), QStringLiteral( "1" ) ).toInt(); // Find function int fn = -1; @@ -1353,7 +1320,6 @@ void QgsGrassMapcalc::load() objects[objId]->setConnector( socketType, socket, con, n2 ); } } - } mFileName = sel->map; @@ -1363,7 +1329,6 @@ void QgsGrassMapcalc::load() void QgsGrassMapcalc::clear() { - setTool( Select ); QList l = mCanvasScene->items(); @@ -1396,7 +1361,6 @@ QgsGrassMapcalcObject::QgsGrassMapcalcObject( int type ) , mSelectionBoxSize( 5 ) , mOutputConnectorEnd( 0 ) { - QGraphicsRectItem::setZValue( 20 ); mInputCount = 0; @@ -1441,8 +1405,7 @@ int QgsGrassMapcalcObject::type() const return mType; } -void QgsGrassMapcalcObject::paint( QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget ) +void QgsGrassMapcalcObject::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { Q_UNUSED( option ) Q_UNUSED( widget ) @@ -1450,8 +1413,8 @@ void QgsGrassMapcalcObject::paint( QPainter *painter, painter->setPen( QPen( QColor( 0, 0, 0 ) ) ); painter->setBrush( QBrush( QColor( 255, 255, 255 ) ) ); - int xRound = ( int )( 100 * mRound / mRect.width() ); - int yRound = ( int )( 100 * mRound / mRect.height() ); + int xRound = ( int ) ( 100 * mRound / mRect.width() ); + int yRound = ( int ) ( 100 * mRound / mRect.height() ); painter->drawRoundedRect( mRect, xRound, yRound ); @@ -1463,9 +1426,7 @@ void QgsGrassMapcalcObject::paint( QPainter *painter, else painter->setBrush( QBrush( QColor( 255, 0, 0 ) ) ); - painter->drawEllipse( mInputPoints[i].x() - mSocketHalf, - mInputPoints[i].y() - mSocketHalf, - 2 * mSocketHalf + 1, 2 * mSocketHalf + 1 ); + painter->drawEllipse( mInputPoints[i].x() - mSocketHalf, mInputPoints[i].y() - mSocketHalf, 2 * mSocketHalf + 1, 2 * mSocketHalf + 1 ); } // Output socket @@ -1476,9 +1437,7 @@ void QgsGrassMapcalcObject::paint( QPainter *painter, else painter->setBrush( QBrush( QColor( 255, 0, 0 ) ) ); - painter->drawEllipse( mOutputPoint.x() - mSocketHalf, - mOutputPoint.y() - mSocketHalf, - 2 * mSocketHalf + 1, 2 * mSocketHalf + 1 ); + painter->drawEllipse( mOutputPoint.x() - mSocketHalf, mOutputPoint.y() - mSocketHalf, 2 * mSocketHalf + 1, 2 * mSocketHalf + 1 ); } // Input labels @@ -1519,8 +1478,7 @@ void QgsGrassMapcalcObject::paint( QPainter *painter, painter->drawRect( mRect.x(), mRect.y(), s, s ); painter->drawRect( mRect.x() + mRect.width() - s, mRect.y(), s, s ); - painter->drawRect( mRect.x() + mRect.width() - s, - mRect.y() + mRect.height() - s, s, s ); + painter->drawRect( mRect.x() + mRect.width() - s, mRect.y() + mRect.height() - s, s, s ); painter->drawRect( mRect.x(), mRect.y() + mRect.height() - s, s, s ); } } @@ -1538,9 +1496,9 @@ void QgsGrassMapcalcObject::resetSize() QFontMetrics metrics( mFont ); mTextHeight = metrics.height(); - mSocketHalf = ( int )( mFont.pointSize() / 3 + 1 ); - mSpace = ( int )( 1.0 * mFont.pointSize() ); - mRound = ( int )( 1.0 * mTextHeight ); + mSocketHalf = ( int ) ( mFont.pointSize() / 3 + 1 ); + mSpace = ( int ) ( 1.0 * mFont.pointSize() ); + mRound = ( int ) ( 1.0 * mTextHeight ); mMargin = 2 * mSocketHalf + 1; mInputTextWidth = 0; @@ -1596,8 +1554,7 @@ void QgsGrassMapcalcObject::resetSize() int ly = mRect.y() + mSpace; if ( mInputCount > 1 ) { - ly += ( int )( ( mInputCount * mTextHeight + - ( mInputCount - 1 ) * mSpace ) / 2 - mTextHeight / 2 ); + ly += ( int ) ( ( mInputCount * mTextHeight + ( mInputCount - 1 ) * mSpace ) / 2 - mTextHeight / 2 ); } mLabelRect.setX( lx ); mLabelRect.setY( ly ); @@ -1608,13 +1565,12 @@ void QgsGrassMapcalcObject::resetSize() for ( int i = 0; i < mInputCount; i++ ) { - mInputPoints[i] = QPoint( mRect.x() - mSocketHalf - 1, - ( int )( mRect.y() + ( i + 1 ) * ( mSpace + mTextHeight ) - mTextHeight / 2 ) ); + mInputPoints[i] = QPoint( mRect.x() - mSocketHalf - 1, ( int ) ( mRect.y() + ( i + 1 ) * ( mSpace + mTextHeight ) - mTextHeight / 2 ) ); } // Output socket mOutputPoint.setX( mRect.right() + mSocketHalf + 1 ); - mOutputPoint.setY( ( int )( mRect.y() + mRect.height() / 2 ) ); + mOutputPoint.setY( ( int ) ( mRect.y() + mRect.height() / 2 ) ); // Update all connected connectors for ( int i = 0; i < mInputCount; i++ ) @@ -1669,10 +1625,8 @@ void QgsGrassMapcalcObject::setSelected( bool s ) QGraphicsRectItem::update(); } -bool QgsGrassMapcalcObject::tryConnect( QgsGrassMapcalcConnector *connector, - int end ) +bool QgsGrassMapcalcObject::tryConnect( QgsGrassMapcalcConnector *connector, int end ) { - QPoint p = connector->point( end ); // Input @@ -1683,8 +1637,7 @@ bool QgsGrassMapcalcObject::tryConnect( QgsGrassMapcalcConnector *connector, if ( mInputConnectors[i] ) continue; // used - double d = std::sqrt( std::pow( ( double )( mInputPoints[i].x() + pos().x() - p.x() ), 2.0 ) - + std::pow( ( double )( mInputPoints[i].y() + pos().y() - p.y() ), 2.0 ) ); + double d = std::sqrt( std::pow( ( double ) ( mInputPoints[i].x() + pos().x() - p.x() ), 2.0 ) + std::pow( ( double ) ( mInputPoints[i].y() + pos().y() - p.y() ), 2.0 ) ); if ( d <= mSocketHalf ) { @@ -1699,8 +1652,7 @@ bool QgsGrassMapcalcObject::tryConnect( QgsGrassMapcalcConnector *connector, // Output if ( !connector->connected( Out ) && !mOutputConnector ) { - double d = std::sqrt( std::pow( ( double )( mOutputPoint.x() + pos().x() - p.x() ), 2.0 ) - + std::pow( ( double )( mOutputPoint.y() + pos().y() - p.y() ), 2.0 ) ); + double d = std::sqrt( std::pow( ( double ) ( mOutputPoint.x() + pos().x() - p.x() ), 2.0 ) + std::pow( ( double ) ( mOutputPoint.y() + pos().y() - p.y() ), 2.0 ) ); if ( d <= mSocketHalf ) { @@ -1714,10 +1666,8 @@ bool QgsGrassMapcalcObject::tryConnect( QgsGrassMapcalcConnector *connector, return false; } -void QgsGrassMapcalcObject::setConnector( int direction, int socket, - QgsGrassMapcalcConnector *connector, int end ) +void QgsGrassMapcalcObject::setConnector( int direction, int socket, QgsGrassMapcalcConnector *connector, int end ) { - if ( direction == In ) { mInputConnectors[socket] = connector; @@ -1734,7 +1684,6 @@ void QgsGrassMapcalcObject::setConnector( int direction, int socket, QPoint QgsGrassMapcalcObject::socketPoint( int direction, int socket ) { - if ( direction == In ) { return mInputPoints[socket] + pos().toPoint(); @@ -1783,7 +1732,6 @@ QString QgsGrassMapcalcObject::expression() exp.append( mInputConnectors[i]->expression() ); else exp.append( "null()" ); - } exp.append( ")" ); @@ -1817,8 +1765,7 @@ QgsGrassMapcalcConnector::~QgsGrassMapcalcConnector() setSocket( 1 ); } -void QgsGrassMapcalcConnector::paint( QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget ) +void QgsGrassMapcalcConnector::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) { Q_UNUSED( option ) Q_UNUSED( widget ) @@ -1826,8 +1773,7 @@ void QgsGrassMapcalcConnector::paint( QPainter *painter, { if ( mSocketObjects[i] ) { - mPoints[i] = mSocketObjects[i]->socketPoint( mSocketDir[i], - mSocket[i] ); + mPoints[i] = mSocketObjects[i]->socketPoint( mSocketDir[i], mSocket[i] ); } } @@ -1861,8 +1807,7 @@ void QgsGrassMapcalcConnector::setPoint( int index, QPoint point ) // QgsDebugMsgLevel(QString("index = %1").arg(index), 2); mPoints[index] = point; - QGraphicsLineItem::setLine( mPoints[0].x(), mPoints[0].y(), - mPoints[1].x(), mPoints[1].y() ); + QGraphicsLineItem::setLine( mPoints[0].x(), mPoints[0].y(), mPoints[1].x(), mPoints[1].y() ); QGraphicsLineItem::update(); } @@ -1881,11 +1826,9 @@ void QgsGrassMapcalcConnector::selectEnd( QPoint point ) { mSelectedEnd = -1; - double d0 = std::sqrt( std::pow( ( double )( point.x() - mPoints[0].x() ), 2.0 ) - + std::pow( ( double )( point.y() - mPoints[0].y() ), 2.0 ) ); + double d0 = std::sqrt( std::pow( ( double ) ( point.x() - mPoints[0].x() ), 2.0 ) + std::pow( ( double ) ( point.y() - mPoints[0].y() ), 2.0 ) ); - double d1 = std::sqrt( std::pow( ( double )( point.x() - mPoints[1].x() ), 2.0 ) - + std::pow( ( double )( point.y() - mPoints[1].y() ), 2.0 ) ); + double d1 = std::sqrt( std::pow( ( double ) ( point.x() - mPoints[1].x() ), 2.0 ) + std::pow( ( double ) ( point.y() - mPoints[1].y() ), 2.0 ) ); if ( d0 < 15 || d1 < 15 ) @@ -1909,7 +1852,6 @@ int QgsGrassMapcalcConnector::selectedEnd() bool QgsGrassMapcalcConnector::tryConnectEnd( int end ) { - QList l = scene()->items( mPoints[end] ); QgsGrassMapcalcObject *object = nullptr; QList::const_iterator it = l.constEnd(); @@ -1925,15 +1867,12 @@ bool QgsGrassMapcalcConnector::tryConnectEnd( int end ) return object && object->tryConnect( this, end ); } -void QgsGrassMapcalcConnector::setSocket( int end, - QgsGrassMapcalcObject *object, int direction, int socket ) +void QgsGrassMapcalcConnector::setSocket( int end, QgsGrassMapcalcObject *object, int direction, int socket ) { - // Remove old connection from object if ( mSocketObjects[end] ) { - mSocketObjects[end]->setConnector( mSocketDir[end], - mSocket[end] ); + mSocketObjects[end]->setConnector( mSocketDir[end], mSocket[end] ); mSocketObjects[end] = nullptr; } @@ -1946,8 +1885,7 @@ void QgsGrassMapcalcConnector::setSocket( int end, if ( !object ) return; // disconnect only - mSocketObjects[end]->setConnector( mSocketDir[end], - mSocket[end], this, end ); + mSocketObjects[end]->setConnector( mSocketDir[end], mSocket[end], this, end ); } bool QgsGrassMapcalcConnector::connected( int direction ) @@ -1985,9 +1923,7 @@ QgsGrassMapcalcObject *QgsGrassMapcalcConnector::object( int end ) } /************************* FUNCTION *****************************/ -QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name, - int count, QString description, QString label, QString labels, - bool drawLabel ) +QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name, int count, QString description, QString label, QString labels, bool drawLabel ) : mName( name ) , mType( type ) , mInputCount( count ) @@ -2006,8 +1942,7 @@ QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name, /******************** CANVAS VIEW ******************************/ -QgsGrassMapcalcView::QgsGrassMapcalcView( QgsGrassMapcalc *mapcalc, - QWidget *parent, Qt::WindowFlags f ) +QgsGrassMapcalcView::QgsGrassMapcalcView( QgsGrassMapcalc *mapcalc, QWidget *parent, Qt::WindowFlags f ) : QGraphicsView( parent ) { Q_UNUSED( f ) diff --git a/src/plugins/grass/qgsgrassmapcalc.h b/src/plugins/grass/qgsgrassmapcalc.h index 2b3341fcb6da..1671ebfab5b8 100644 --- a/src/plugins/grass/qgsgrassmapcalc.h +++ b/src/plugins/grass/qgsgrassmapcalc.h @@ -31,8 +31,7 @@ class QgsGrassMapcalcView; * \class QgsGrassMapcalc * \brief Interface for r.mapcalc */ -class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase, - public QgsGrassModuleOptions +class QgsGrassMapcalc : public QMainWindow, private Ui::QgsGrassMapcalcBase, public QgsGrassModuleOptions { Q_OBJECT @@ -41,7 +40,8 @@ class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase, QgsGrassMapcalc( QgsGrassTools *tools, QgsGrassModule *module, QgisInterface *iface, - QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); + QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() + ); // Current tool enum Tool @@ -58,14 +58,17 @@ class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase, // Reimplemented methods QStringList checkOutput() override; - QStringList ready() override { return QStringList() ; } + QStringList ready() override { return QStringList(); } bool requestsRegion() override { return false; } bool usesRegion() override { return true; } QStringList checkRegion() override; bool inputRegion( struct Cell_head *window, QgsCoordinateReferenceSystem &crs, bool all ) override; QStringList output( int type ) override; bool hasOutput( int type ) override - { Q_UNUSED( type ) return true; } + { + Q_UNUSED( type ) + return true; + } //! \brief receives contentsMousePressEvent from view void mousePressEvent( QMouseEvent * ) override; @@ -200,7 +203,7 @@ class QgsGrassMapcalc: public QMainWindow, private Ui::QgsGrassMapcalcBase, QAction *mActionSaveAs = nullptr; QgsGrassMapcalc( const QgsGrassMapcalc & ) = delete; - QgsGrassMapcalc &operator = ( const QgsGrassMapcalc & ) = delete; + QgsGrassMapcalc &operator=( const QgsGrassMapcalc & ) = delete; }; /* @@ -216,14 +219,12 @@ class QgsGrassMapcalcFunction }; QgsGrassMapcalcFunction() = default; - QgsGrassMapcalcFunction( int type, QString name, int count = 2, - QString description = "", QString label = "", - QString labels = "", bool drawLabel = true ); + QgsGrassMapcalcFunction( int type, QString name, int count = 2, QString description = "", QString label = "", QString labels = "", bool drawLabel = true ); ~QgsGrassMapcalcFunction() = default; QString name() const { return mName; } - int type() const { return mType; } - int inputCount() const { return mInputCount; } + int type() const { return mType; } + int inputCount() const { return mInputCount; } QString label() const { return mLabel; } QString description() const { return mDescription; } QStringList inputLabels() const { return mInputLabels; } @@ -267,9 +268,9 @@ class QgsGrassMapcalcItem virtual void setSelected( bool s ) { mSelected = s; } bool selected( void ) const { return mSelected; } -// virtual void paint ( QPainter * painter, -// const QStyleOptionGraphicsItem * option, QWidget * widget ); -// + // virtual void paint ( QPainter * painter, + // const QStyleOptionGraphicsItem * option, QWidget * widget ); + // int id() const { return mId; } void setId( int id ) { mId = id; } @@ -307,12 +308,12 @@ class QgsGrassMapcalcItem * | | * mInputHeight mLabelX */ -class QgsGrassMapcalcObject: public QGraphicsRectItem, public QgsGrassMapcalcItem +class QgsGrassMapcalcObject : public QGraphicsRectItem, public QgsGrassMapcalcItem { public: enum Type { - Map = 0, // raster map + Map = 0, // raster map Constant, Function, Output @@ -334,8 +335,7 @@ class QgsGrassMapcalcObject: public QGraphicsRectItem, public QgsGrassMapcalcIte // Set function void setFunction( QgsGrassMapcalcFunction f ); - void paint( QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget ) override; + void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) override; // Set object center void setCenter( int, int ); @@ -355,8 +355,7 @@ class QgsGrassMapcalcObject: public QGraphicsRectItem, public QgsGrassMapcalcIte QPoint socketPoint( int direction, int socket ); // Set socket's connector - void setConnector( int direction, int socket, - QgsGrassMapcalcConnector *connector = nullptr, int end = 0 ); + void setConnector( int direction, int socket, QgsGrassMapcalcConnector *connector = nullptr, int end = 0 ); // Object type int type() const override; @@ -374,7 +373,7 @@ class QgsGrassMapcalcObject: public QGraphicsRectItem, public QgsGrassMapcalcIte QString expression(); private: -// bool mSelected; + // bool mSelected; // Object type: Map,Constant,Function int mType; @@ -440,21 +439,19 @@ class QgsGrassMapcalcObject: public QGraphicsRectItem, public QgsGrassMapcalcIte // Output connector QgsGrassMapcalcConnector *mOutputConnector = nullptr; int mOutputConnectorEnd; - }; /* * Connector. * End are stored in vectors with indexes 0,1 */ -class QgsGrassMapcalcConnector: public QGraphicsLineItem, public QgsGrassMapcalcItem +class QgsGrassMapcalcConnector : public QGraphicsLineItem, public QgsGrassMapcalcItem { public: explicit QgsGrassMapcalcConnector( QGraphicsScene * ); ~QgsGrassMapcalcConnector() override; - void paint( QPainter *painter, - const QStyleOptionGraphicsItem *option, QWidget *widget ) override; + void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) override; // Set connector end point coordinates void setPoint( int, QPoint ); @@ -479,10 +476,7 @@ class QgsGrassMapcalcConnector: public QGraphicsLineItem, public QgsGrassMapcalc // If this end of connector was connected to an object // the connection is also deleted from object // If object is NULL the old connection is deleted. - void setSocket( int end, QgsGrassMapcalcObject *object = nullptr, - int direction = QgsGrassMapcalcObject::None, - int socket = 0 - ); + void setSocket( int end, QgsGrassMapcalcObject *object = nullptr, int direction = QgsGrassMapcalcObject::None, int socket = 0 ); // Return pointer to object on end QgsGrassMapcalcObject *object( int end ); @@ -516,7 +510,7 @@ class QgsGrassMapcalcConnector: public QGraphicsLineItem, public QgsGrassMapcalc }; /******************** CANVAS VIEW ******************************/ -class QgsGrassMapcalcView: public QGraphicsView +class QgsGrassMapcalcView : public QGraphicsView { Q_OBJECT @@ -531,7 +525,6 @@ class QgsGrassMapcalcView: public QGraphicsView private: QgsGrassMapcalc *mMapcalc = nullptr; - }; #endif // QGSGRASSMAPCALC_H diff --git a/src/plugins/grass/qgsgrassmodule.cpp b/src/plugins/grass/qgsgrassmodule.cpp index c04df3b68fb9..1fef97f5cd42 100644 --- a/src/plugins/grass/qgsgrassmodule.cpp +++ b/src/plugins/grass/qgsgrassmodule.cpp @@ -86,8 +86,7 @@ QProcessEnvironment QgsGrassModule::processEnvironment( bool direct ) return environment; } -QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisInterface *iface, - bool direct, QWidget *parent, Qt::WindowFlags f ) +QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisInterface *iface, bool direct, QWidget *parent, Qt::WindowFlags f ) : QWidget( parent, f ) , QgsGrassModuleBase() , mSuccess( false ) @@ -118,7 +117,7 @@ QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisIn mErrors.append( tr( "The module file (%1) not found." ).arg( mpath ) ); return; } - if ( ! qFile.open( QIODevice::ReadOnly ) ) + if ( !qFile.open( QIODevice::ReadOnly ) ) { mErrors.append( tr( "Cannot open module file (%1)" ).arg( mpath ) ); return; @@ -126,7 +125,7 @@ QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisIn QDomDocument qDoc( QStringLiteral( "qgisgrassmodule" ) ); QString err; int line, column; - if ( !qDoc.setContent( &qFile, &err, &line, &column ) ) + if ( !qDoc.setContent( &qFile, &err, &line, &column ) ) { QString errmsg = tr( "Cannot read module file (%1)" ).arg( mpath ) + tr( "\n%1\nat line %2 column %3" ).arg( err ).arg( line ).arg( column ); @@ -166,13 +165,11 @@ QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisIn layout->setContentsMargins( 0, 0, 0, 0 ); if ( xName == QLatin1String( "r.mapcalc" ) ) { - mOptions = new QgsGrassMapcalc( mTools, this, - mIface, mTabWidget->widget( 0 ) ); + mOptions = new QgsGrassMapcalc( mTools, this, mIface, mTabWidget->widget( 0 ) ); } else { - mOptions = new QgsGrassModuleStandardOptions( mTools, this, - mIface, mXName, qDocElem, mDirect, mTabWidget->widget( 0 ) ); + mOptions = new QgsGrassModuleStandardOptions( mTools, this, mIface, mXName, qDocElem, mDirect, mTabWidget->widget( 0 ) ); } layout->addWidget( dynamic_cast( mOptions ) ); @@ -229,14 +226,14 @@ QgsGrassModule::Description QgsGrassModule::description( QString path ) { return Description( tr( "Not available, description not found (%1)" ).arg( path ) ); } - if ( ! qFile.open( QIODevice::ReadOnly ) ) + if ( !qFile.open( QIODevice::ReadOnly ) ) { return Description( tr( "Not available, cannot open description (%1)" ).arg( path ) ); } QDomDocument qDoc( QStringLiteral( "qgisgrassmodule" ) ); QString err; int line, column; - if ( !qDoc.setContent( &qFile, &err, &line, &column ) ) + if ( !qDoc.setContent( &qFile, &err, &line, &column ) ) { QString errmsg = tr( "Cannot read module file (%1)" ).arg( path ) + tr( "\n%1\nat line %2 column %3" ).arg( err ).arg( line ).arg( column ); @@ -274,14 +271,14 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) if ( fi.exists() ) { QSvgRenderer pic; - if ( ! pic.load( fpath ) ) + if ( !pic.load( fpath ) ) break; QRect br( QPoint( 0, 0 ), pic.defaultSize() ); double scale = 1. * height / br.height(); - int width = ( int )( scale * br.width() ); + int width = ( int ) ( scale * br.width() ); if ( width <= 0 ) width = height; // should not happen QPixmap pixmap( width, height ); @@ -305,11 +302,11 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) QPixmap pixmap; - if ( ! pixmap.load( fpath, "PNG" ) ) + if ( !pixmap.load( fpath, "PNG" ) ) break; double scale = 1. * height / pixmap.height(); - int width = ( int )( scale * pixmap.width() ); + int width = ( int ) ( scale * pixmap.width() ); QImage img = pixmap.toImage(); img = img.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); @@ -347,7 +344,7 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) if ( iconsfi.exists() && arrowPixmap.load( arrowPath, "PNG" ) ) { double scale = 1. * height / arrowPixmap.height(); - arrowWidth = ( int )( scale * arrowPixmap.width() ); + arrowWidth = ( int ) ( scale * arrowPixmap.width() ); QImage img = arrowPixmap.toImage(); img = img.scaled( arrowWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); @@ -400,7 +397,7 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) double scale = 1. * height / br.height(); - plusWidth = ( int )( scale * br.width() ); + plusWidth = ( int ) ( scale * br.width() ); if ( plusWidth <= 0 ) plusWidth = height; // should not happen plusPixmap = QPixmap( plusWidth, height ); @@ -431,7 +428,7 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) int pos = 0; for ( int i = 0; i < pixmaps.size(); i++ ) { - if ( i == 1 && pixmaps.size() == 3 ) // + + if ( i == 1 && pixmaps.size() == 3 ) // + { pos += buffer; painter.drawPixmap( pos, 0, plusPixmap ); @@ -500,9 +497,7 @@ void QgsGrassModule::run() QStringList outsideRegion = mOptions->checkRegion(); if ( outsideRegion.size() > 0 ) { - QMessageBox questionBox( QMessageBox::Question, tr( "Warning" ), - tr( "Input %1 outside current region!" ).arg( outsideRegion.join( QLatin1Char( ',' ) ) ), - QMessageBox::Ok | QMessageBox::Cancel ); + QMessageBox questionBox( QMessageBox::Question, tr( "Warning" ), tr( "Input %1 outside current region!" ).arg( outsideRegion.join( QLatin1Char( ',' ) ) ), QMessageBox::Ok | QMessageBox::Cancel ); QPushButton *resetButton = nullptr; if ( QgsGrass::versionMajor() > 6 || ( QgsGrass::versionMajor() == 6 && QgsGrass::versionMinor() >= 1 ) ) { @@ -533,9 +528,7 @@ void QgsGrassModule::run() QStringList outputExists = mOptions->checkOutput(); if ( outputExists.size() > 0 ) { - QMessageBox::StandardButton ret = QMessageBox::question( nullptr, QStringLiteral( "Warning" ), - tr( "Output %1 exists! Overwrite?" ).arg( outputExists.join( QLatin1Char( ',' ) ) ), - QMessageBox::Ok | QMessageBox::Cancel ); + QMessageBox::StandardButton ret = QMessageBox::question( nullptr, QStringLiteral( "Warning" ), tr( "Output %1 exists! Overwrite?" ).arg( outputExists.join( QLatin1Char( ',' ) ) ), QMessageBox::Ok | QMessageBox::Cancel ); if ( ret == QMessageBox::Cancel ) return; @@ -608,7 +601,7 @@ void QgsGrassModule::run() setDirectLibraryPath( environment ); #ifdef Q_OS_WIN variables << "PATH"; -#elif defined(Q_OS_MAC) +#elif defined( Q_OS_MAC ) variables << "DYLD_LIBRARY_PATH"; #else variables << QStringLiteral( "LD_LIBRARY_PATH" ); @@ -635,7 +628,7 @@ void QgsGrassModule::run() commandHtml.replace( QLatin1String( "&" ), QLatin1String( "&" ) ); commandHtml.replace( QLatin1String( "<" ), QLatin1String( "<" ) ); commandHtml.replace( QLatin1String( ">" ), QLatin1String( ">" ) ); - mOutputTextBrowser->append( "" + commandHtml + "" ); + mOutputTextBrowser->append( "" + commandHtml + "" ); // I was not able to get scripts working on Windows // via QProcess and sh.exe (MinGW). g.parser runs wellQProcessEnvironment::systemE @@ -855,9 +848,10 @@ void QgsGrassModule::viewOutput() try { layers = QgsGrass::vectorLayers( - QgsGrass::getDefaultGisdbase(), - QgsGrass::getDefaultLocation(), - QgsGrass::getDefaultMapset(), map ); + QgsGrass::getDefaultGisdbase(), + QgsGrass::getDefaultLocation(), + QgsGrass::getDefaultMapset(), map + ); } catch ( QgsGrass::Exception &e ) { @@ -890,7 +884,8 @@ void QgsGrassModule::viewOutput() continue; QString name = QgsGrassUtils::vectorLayerName( - map, layers[j], 1 ); + map, layers[j], 1 + ); mIface->addVectorLayer( uri, name, QStringLiteral( "grass" ) ); } @@ -941,7 +936,7 @@ QString QgsGrassModule::libraryPathVariable() { #ifdef Q_OS_WIN return "PATH"; -#elif defined(Q_OS_MAC) +#elif defined( Q_OS_MAC ) return "DYLD_LIBRARY_PATH"; #else return QStringLiteral( "LD_LIBRARY_PATH" ); @@ -954,7 +949,7 @@ void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment &environment ) QString separator; #ifdef Q_OS_WIN separator = ";"; -#elif defined(Q_OS_MAC) +#elif defined( Q_OS_MAC ) separator = ":"; #else separator = QStringLiteral( ":" ); @@ -964,4 +959,3 @@ void QgsGrassModule::setDirectLibraryPath( QProcessEnvironment &environment ) environment.insert( pathVariable, lp ); QgsDebugMsgLevel( pathVariable + "=" + lp, 2 ); } - diff --git a/src/plugins/grass/qgsgrassmodule.h b/src/plugins/grass/qgsgrassmodule.h index 9e5f5ccead0f..84a3983b248d 100644 --- a/src/plugins/grass/qgsgrassmodule.h +++ b/src/plugins/grass/qgsgrassmodule.h @@ -32,7 +32,7 @@ class QDomElement; * \brief Interface to GRASS modules. * */ -class QgsGrassModule : public QWidget, private Ui::QgsGrassModuleBase +class QgsGrassModule : public QWidget, private Ui::QgsGrassModuleBase { Q_OBJECT @@ -44,12 +44,12 @@ class QgsGrassModule : public QWidget, private Ui::QgsGrassModuleBase // supported by GRASS Direct bool direct = true; Description() = default; - Description( QString lab, bool dir = false ): label( lab ), direct( dir ) { } + Description( QString lab, bool dir = false ) + : label( lab ), direct( dir ) {} }; //! Constructor - QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisInterface *iface, - bool direct, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); + QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisInterface *iface, bool direct, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); ~QgsGrassModule() override; @@ -128,7 +128,6 @@ class QgsGrassModule : public QWidget, private Ui::QgsGrassModuleBase //void mapsetChanged(); private: - /** * Set progress bar or busy indicator if percent is 100 * \param percent progress to show in % diff --git a/src/plugins/grass/qgsgrassmoduleinput.cpp b/src/plugins/grass/qgsgrassmoduleinput.cpp index e5640ddd8adc..f794b137cd52 100644 --- a/src/plugins/grass/qgsgrassmoduleinput.cpp +++ b/src/plugins/grass/qgsgrassmoduleinput.cpp @@ -259,7 +259,6 @@ void QgsGrassModuleInputModel::refreshMapset( QStandardItem *mapsetItem, const Q void QgsGrassModuleInputModel::reload() { - if ( !mWatcher->files().isEmpty() ) { mWatcher->removePaths( mWatcher->files() ); @@ -320,7 +319,7 @@ QgsGrassModuleInputModel *QgsGrassModuleInputModel::instance() QVariant QgsGrassModuleInputModel::data( const QModelIndex &index, int role ) const { QVariant data = QStandardItemModel::data( index, role ); - if ( role == Qt::DisplayRole || role == Qt::EditRole ) // EditRole for combo + if ( role == Qt::DisplayRole || role == Qt::EditRole ) // EditRole for combo { int type = QStandardItemModel::data( index, QgsGrassModuleInputModel::TypeRole ).toInt(); if ( type == QgsGrassObject::Raster || type == QgsGrassObject::Vector ) @@ -679,8 +678,7 @@ void QgsGrassModuleInputSelectedDelegate::handlePressed( const QModelIndex &inde } } -void QgsGrassModuleInputSelectedDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index ) const +void QgsGrassModuleInputSelectedDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if ( option.state & QStyle::State_MouseOver ) { @@ -700,10 +698,7 @@ void QgsGrassModuleInputSelectedDelegate::paint( QPainter *painter, const QStyle const QIcon icon = ( option.state & QStyle::State_Selected ) ? QgsGrassPlugin::getThemeIcon( "closebutton.png" ) : QgsGrassPlugin::getThemeIcon( "darkclosebutton.png" ); - QRect iconRect( option.rect.right() - option.rect.height(), - option.rect.top(), - option.rect.height(), - option.rect.height() ); + QRect iconRect( option.rect.right() - option.rect.height(), option.rect.top(), option.rect.height(), option.rect.height() ); icon.paint( painter, iconRect, Qt::AlignRight | Qt::AlignVCenter ); } @@ -728,8 +723,7 @@ QgsGrassModuleInputSelectedView::QgsGrassModuleInputSelectedView( QWidget *paren installEventFilter( this ); viewport()->installEventFilter( this ); - connect( this, &QAbstractItemView::pressed, - mDelegate, &QgsGrassModuleInputSelectedDelegate::handlePressed ); + connect( this, &QAbstractItemView::pressed, mDelegate, &QgsGrassModuleInputSelectedDelegate::handlePressed ); } void QgsGrassModuleInputSelectedView::setModel( QAbstractItemModel *model ) @@ -771,10 +765,7 @@ bool QgsGrassModuleInputSelectedView::eventFilter( QObject *obj, QEvent *event ) } /**************************** QgsGrassModuleInput ****************************/ -QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, - QgsGrassModuleStandardOptions *options, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent ) +QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, QgsGrassModuleStandardOptions *options, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) : QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ) , mType( QgsGrassObject::Vector ) , mModuleStandardOptions( options ) @@ -800,7 +791,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, // Read type mask if "typeoption" is defined QString opt = qdesc.attribute( QStringLiteral( "typeoption" ) ); - if ( ! opt.isNull() ) + if ( !opt.isNull() ) { typeNode = nodeByKey( gdesc, opt ); @@ -845,7 +836,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, // Read type mask defined in configuration opt = qdesc.attribute( QStringLiteral( "typemask" ) ); - if ( ! opt.isNull() ) + if ( !opt.isNull() ) { int mask = 0; @@ -860,9 +851,8 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, // Read "layeroption" if defined opt = qdesc.attribute( QStringLiteral( "layeroption" ) ); - if ( ! opt.isNull() ) + if ( !opt.isNull() ) { - QDomNode optNode = nodeByKey( gdesc, opt ); if ( optNode.isNull() ) @@ -915,9 +905,9 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, // Map input mComboBox = new QgsGrassModuleInputComboBox( mType, this ); - mComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy:: Preferred ); + mComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); // QComboBox does not emit activated() when item is selected in completer popup - connect( mComboBox, qOverload< int >( &QComboBox::activated ), this, [ = ]( int index ) { onActivated( mComboBox->itemText( index ) ); } ); + connect( mComboBox, qOverload( &QComboBox::activated ), this, [=]( int index ) { onActivated( mComboBox->itemText( index ) ); } ); connect( mComboBox->completer(), static_cast( &QCompleter::activated ), this, &QgsGrassModuleInput::onActivated ); connect( mComboBox, &QComboBox::editTextChanged, this, &QgsGrassModuleInput::onChanged ); mapLayout->addWidget( mComboBox ); @@ -931,7 +921,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, mRegionButton->setToolTip( tr( "Use region of this map" ) ); mRegionButton->setCheckable( true ); - mRegionButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy:: Preferred ); + mRegionButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ); mapLayout->addWidget( mRegionButton ); } @@ -963,7 +953,6 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, // Vector types if ( !typeNode.isNull() ) { - QList types; types << GV_POINT << GV_LINE << GV_BOUNDARY << GV_CENTROID << GV_AREA; for ( int type : types ) @@ -1010,7 +999,6 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module, bool QgsGrassModuleInput::useRegion() { - return mUsesRegion && mType == QgsGrassObject::Raster && mRegionButton && mRegionButton->isChecked(); } @@ -1047,7 +1035,6 @@ QStringList QgsGrassModuleInput::options() if ( !mGeometryTypeOption.isEmpty() ) { - list << mGeometryTypeOption + "=" + currentGeometryTypeNames().join( QLatin1Char( ',' ) ); } } @@ -1057,7 +1044,6 @@ QStringList QgsGrassModuleInput::options() QgsFields QgsGrassModuleInput::currentFields() { - QgsGrassVectorLayer *layer = currentLayer(); if ( !layer ) { @@ -1068,7 +1054,6 @@ QgsFields QgsGrassModuleInput::currentFields() QgsGrassObject QgsGrassModuleInput::currentGrassObject() { - QgsGrassObject grassObject( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), QString(), QString(), mType ); grassObject.setFullName( mComboBox->currentText() ); return grassObject; @@ -1185,7 +1170,6 @@ void QgsGrassModuleInput::onChanged( const QString &text ) void QgsGrassModuleInput::onLayerChanged() { - // TODO(?): support vector sublayers/types for multiple input if ( multiple() ) { @@ -1233,7 +1217,6 @@ void QgsGrassModuleInput::onLayerChanged() QString QgsGrassModuleInput::ready() { - QString error; QString noInput = tr( "no input" ); diff --git a/src/plugins/grass/qgsgrassmoduleinput.h b/src/plugins/grass/qgsgrassmoduleinput.h index 8ca805f09b6b..2f24ebe0e16b 100644 --- a/src/plugins/grass/qgsgrassmoduleinput.h +++ b/src/plugins/grass/qgsgrassmoduleinput.h @@ -82,13 +82,18 @@ class QgsGrassModuleInputModel : public QStandardItemModel void watch( const QString &path ); QString mLocationPath; // mapset watched dirs - QStringList watchedDirs() { QStringList l; l << QStringLiteral( "cellhd" ) << QStringLiteral( "vector" ) << QStringLiteral( "tgis" ); return l; } + QStringList watchedDirs() + { + QStringList l; + l << QStringLiteral( "cellhd" ) << QStringLiteral( "vector" ) << QStringLiteral( "tgis" ); + return l; + } // names of QStringList locationDirNames(); QFileSystemWatcher *mWatcher = nullptr; QgsGrassModuleInputModel( const QgsGrassModuleInputModel & ) = delete; - QgsGrassModuleInputModel &operator = ( const QgsGrassModuleInputModel & ) = delete; + QgsGrassModuleInputModel &operator=( const QgsGrassModuleInputModel & ) = delete; }; // Filter maps by type @@ -133,7 +138,11 @@ class QgsGrassModuleInputCompleterProxy : public QAbstractProxyModel public: explicit QgsGrassModuleInputCompleterProxy( QObject *parent = nullptr ); - int columnCount( const QModelIndex &parent = QModelIndex() ) const override { Q_UNUSED( parent ) return 1; } + int columnCount( const QModelIndex &parent = QModelIndex() ) const override + { + Q_UNUSED( parent ) + return 1; + } int rowCount( const QModelIndex &parent = QModelIndex() ) const override; QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; QModelIndex parent( const QModelIndex &index ) const override; @@ -233,16 +242,12 @@ class QgsGrassModuleInput : public QgsGrassModuleGroupBoxItem Q_OBJECT public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleInput( QgsGrassModule *module, - QgsGrassModuleStandardOptions *options, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleInput( QgsGrassModule *module, QgsGrassModuleStandardOptions *options, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); //! Returns list of options which will be passed to module QStringList options() override; @@ -348,7 +353,7 @@ class QgsGrassModuleInput : public QgsGrassModuleGroupBoxItem bool mUsesRegion; QgsGrassModuleInput( const QgsGrassModuleInput & ) = delete; - QgsGrassModuleInput &operator = ( const QgsGrassModuleInput & ) = delete; + QgsGrassModuleInput &operator=( const QgsGrassModuleInput & ) = delete; }; diff --git a/src/plugins/grass/qgsgrassmoduleoptions.cpp b/src/plugins/grass/qgsgrassmoduleoptions.cpp index 1300c0c5069c..558ce489ae46 100644 --- a/src/plugins/grass/qgsgrassmoduleoptions.cpp +++ b/src/plugins/grass/qgsgrassmoduleoptions.cpp @@ -44,7 +44,8 @@ QgsGrassModuleOptions::QgsGrassModuleOptions( QgsGrassTools *tools, QgsGrassModule *module, - QgisInterface *iface, bool direct ) + QgisInterface *iface, bool direct +) : mIface( iface ) , mTools( tools ) , mModule( module ) @@ -66,7 +67,8 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( QgsGrassTools *tools, QgsGrassModule *module, QgisInterface *iface, QString xname, QDomElement confDocElem, - bool direct, QWidget *parent, Qt::WindowFlags f ) + bool direct, QWidget *parent, Qt::WindowFlags f +) : QWidget( parent, f ) , QgsGrassModuleOptions( tools, module, iface, direct ) , mXName( xname ) @@ -191,13 +193,12 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( QString age = promptElem.attribute( QStringLiteral( "age" ) ); //QgsDebugMsgLevel("element = " + element + " age = " + age, 3); - if ( age == QLatin1String( "old" ) && ( element == QLatin1String( "vector" ) || element == QLatin1String( "cell" ) || - element == QLatin1String( "strds" ) || element == QLatin1String( "stvds" ) || - element == QLatin1String( "str3ds" ) || element == QLatin1String( "stds" ) ) - && confDomElement.attribute( QStringLiteral( "widget" ) ) != QLatin1String( "text" ) ) + if ( age == QLatin1String( "old" ) && ( element == QLatin1String( "vector" ) || element == QLatin1String( "cell" ) || element == QLatin1String( "strds" ) || element == QLatin1String( "stvds" ) || element == QLatin1String( "str3ds" ) || element == QLatin1String( "stds" ) ) + && confDomElement.attribute( QStringLiteral( "widget" ) ) != QLatin1String( "text" ) ) { QgsGrassModuleInput *mi = new QgsGrassModuleInput( - mModule, this, key, confDomElement, descDocElem, gnode, mDirect, this ); + mModule, this, key, confDomElement, descDocElem, gnode, mDirect, this + ); layout->addWidget( mi ); created = true; @@ -208,7 +209,8 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( if ( !created ) { QgsGrassModuleOption *so = new QgsGrassModuleOption( - mModule, key, confDomElement, descDocElem, gnode, mDirect, this ); + mModule, key, confDomElement, descDocElem, gnode, mDirect, this + ); layout->addWidget( so ); mParams.append( so ); @@ -234,7 +236,8 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( { QgsGrassModuleGdalInput *mi = new QgsGrassModuleGdalInput( mModule, QgsGrassModuleGdalInput::Ogr, key, confDomElement, - descDocElem, gnode, mDirect, this ); + descDocElem, gnode, mDirect, this + ); layout->addWidget( mi ); mParams.append( mi ); } @@ -242,7 +245,8 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( { QgsGrassModuleGdalInput *mi = new QgsGrassModuleGdalInput( mModule, QgsGrassModuleGdalInput::Gdal, key, confDomElement, - descDocElem, gnode, mDirect, this ); + descDocElem, gnode, mDirect, this + ); layout->addWidget( mi ); mParams.append( mi ); } @@ -252,7 +256,8 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( { QgsGrassModuleVectorField *mi = new QgsGrassModuleVectorField( mModule, this, key, confDomElement, - descDocElem, gnode, mDirect, this ); + descDocElem, gnode, mDirect, this + ); layout->addWidget( mi ); mParams.append( mi ); } @@ -260,7 +265,8 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( { QgsGrassModuleField *mi = new QgsGrassModuleField( mModule, key, confDomElement, - descDocElem, gnode, mDirect, this ); + descDocElem, gnode, mDirect, this + ); layout->addWidget( mi ); mParams.append( mi ); } @@ -269,21 +275,24 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( { QgsGrassModuleSelection *mi = new QgsGrassModuleSelection( mModule, this, key, confDomElement, - descDocElem, gnode, mDirect, this ); + descDocElem, gnode, mDirect, this + ); layout->addWidget( mi ); mParams.append( mi ); } else if ( optionType == QLatin1String( "file" ) ) { QgsGrassModuleFile *mi = new QgsGrassModuleFile( - mModule, key, confDomElement, descDocElem, gnode, mDirect, this ); + mModule, key, confDomElement, descDocElem, gnode, mDirect, this + ); layout->addWidget( mi ); mParams.append( mi ); } else if ( optionType == QLatin1String( "flag" ) ) { QgsGrassModuleFlag *flag = new QgsGrassModuleFlag( - mModule, key, confDomElement, descDocElem, gnode, mDirect, this ); + mModule, key, confDomElement, descDocElem, gnode, mDirect, this + ); layout->addWidget( flag ); mParams.append( flag ); @@ -372,7 +381,6 @@ QgsGrassModuleStandardOptions::QgsGrassModuleStandardOptions( { mErrors << item->errors(); } - } void QgsGrassModuleStandardOptions::switchAdvanced() @@ -473,7 +481,7 @@ QList QgsGrassModuleStandardOptions::grassProviders() if ( layer->type() == Qgis::LayerType::Vector ) { QgsVectorLayer *vector = qobject_cast( layer ); - if ( vector && vector->providerType() == QLatin1String( "grass" ) ) + if ( vector && vector->providerType() == QLatin1String( "grass" ) ) { QgsGrassProvider *provider = qobject_cast( vector->dataProvider() ); if ( provider ) @@ -494,7 +502,7 @@ QList QgsGrassModuleStandardOptions::grassRasterProvid if ( layer->type() == Qgis::LayerType::Raster ) { QgsRasterLayer *raster = qobject_cast( layer ); - if ( raster && raster->providerType() == QLatin1String( "grassraster" ) ) + if ( raster && raster->providerType() == QLatin1String( "grassraster" ) ) { QgsGrassRasterProvider *provider = qobject_cast( raster->dataProvider() ); if ( provider ) @@ -673,7 +681,7 @@ QStringList QgsGrassModuleStandardOptions::checkRegion() if ( !item ) continue; - QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 ); + QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 ); // The input may be empty, it means input is not used. if ( item->currentMap().isEmpty() ) @@ -685,8 +693,7 @@ QStringList QgsGrassModuleStandardOptions::checkRegion() continue; } - if ( G_window_overlap( ¤tWindow, - window.north, window.south, window.east, window.west ) == 0 ) + if ( G_window_overlap( ¤tWindow, window.north, window.south, window.east, window.west ) == 0 ) { list.append( item->currentMap() ); } @@ -760,7 +767,7 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, QgsCo continue; } - QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 ); + QgsDebugMsgLevel( "currentMap = " + item->currentMap(), 3 ); // The input may be empty, it means input is not used. if ( item->currentMap().isEmpty() ) { @@ -801,7 +808,8 @@ bool QgsGrassModuleStandardOptions::requestsRegion() { QgsDebugMsgLevel( "called.", 4 ); - if ( mDirect ) return true; + if ( mDirect ) + return true; for ( int i = 0; i < mParams.size(); i++ ) { @@ -841,7 +849,7 @@ bool QgsGrassModuleStandardOptions::getCurrentMapRegion( QgsGrassModuleInput *in return false; } - QgsDebugMsgLevel( "currentMap = " + input->currentMap(), 3 ); + QgsDebugMsgLevel( "currentMap = " + input->currentMap(), 3 ); if ( input->currentMap().isEmpty() ) { // The input may be empty, it means input is not used. @@ -855,10 +863,7 @@ bool QgsGrassModuleStandardOptions::getCurrentMapRegion( QgsGrassModuleInput *in { mapset = mm.value( 1 ); } - if ( !QgsGrass::mapRegion( input->type(), - QgsGrass::getDefaultGisdbase(), - QgsGrass::getDefaultLocation(), mapset, map, - window ) ) + if ( !QgsGrass::mapRegion( input->type(), QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), mapset, map, window ) ) { QgsGrass::warning( tr( "Cannot get region of map %1" ).arg( input->currentMap() ) ); return false; @@ -899,8 +904,7 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr if ( !process.waitForStarted() || !process.waitForReadyRead() || !process.waitForFinished() - || ( process.exitCode() != 0 && process.exitCode() != 255 && - ( !cmd.endsWith( QLatin1String( ".py" ) ) || process.exitCode() != 1 ) ) ) + || ( process.exitCode() != 0 && process.exitCode() != 255 && ( !cmd.endsWith( QLatin1String( ".py" ) ) || process.exitCode() != 1 ) ) ) { QString pathVariable = QgsGrassModule::libraryPathVariable(); QgsDebugError( "process.exitCode() = " + QString::number( process.exitCode() ) ); @@ -908,10 +912,7 @@ QDomDocument QgsGrassModuleStandardOptions::readInterfaceDescription( const QStr + "

    " + pathVariable + "=" + environment.value( pathVariable ) + "

    PATH=" + environment.value( QStringLiteral( "PATH" ) ) + "

    PYTHONPATH=" + environment.value( QStringLiteral( "PYTHONPATH" ) ) - + "

    " + tr( "command" ) + QStringLiteral( ": %1 %2
    %3
    %4" ) - .arg( cmd, arguments.join( QLatin1Char( ' ' ) ), - process.readAllStandardOutput().constData(), - process.readAllStandardError().constData() ); + + "

    " + tr( "command" ) + QStringLiteral( ": %1 %2
    %3
    %4" ).arg( cmd, arguments.join( QLatin1Char( ' ' ) ), process.readAllStandardOutput().constData(), process.readAllStandardError().constData() ); QgsDebugError( msg ); errors << msg; return gDoc; diff --git a/src/plugins/grass/qgsgrassmoduleoptions.h b/src/plugins/grass/qgsgrassmoduleoptions.h index 321baef2b962..23ef38c593aa 100644 --- a/src/plugins/grass/qgsgrassmoduleoptions.h +++ b/src/plugins/grass/qgsgrassmoduleoptions.h @@ -54,7 +54,8 @@ class QgsGrassModuleOptions //! Constructor QgsGrassModuleOptions( QgsGrassTools *tools, QgsGrassModule *module, - QgisInterface *iface, bool direct ); + QgisInterface *iface, bool direct + ); virtual ~QgsGrassModuleOptions() = default; @@ -64,7 +65,7 @@ class QgsGrassModuleOptions //! Check if output exists // return empty list // return list of existing output maps - virtual QStringList checkOutput() { return QStringList() ; } + virtual QStringList checkOutput() { return QStringList(); } //! Freeze output maps used in QGIS // freeze / thaw output layers @@ -72,15 +73,21 @@ class QgsGrassModuleOptions //! Check if option is ready // Returns empty string or error message - virtual QStringList ready() { return QStringList() ; } + virtual QStringList ready() { return QStringList(); } //! Gets list of current output maps virtual QStringList output( int type ) - { Q_UNUSED( type ) return QStringList(); } + { + Q_UNUSED( type ) + return QStringList(); + } //! Has any output virtual bool hasOutput( int type ) - { Q_UNUSED( type ) return true; } + { + Q_UNUSED( type ) + return true; + } //! Has raster input or output virtual bool usesRegion() { return false; } @@ -91,16 +98,21 @@ class QgsGrassModuleOptions //! Check region // return empty list // return list of input maps (both raster and vector) outside region - virtual QStringList checkRegion() { return QStringList() ; } + virtual QStringList checkRegion() { return QStringList(); } //! Gets region covering all input maps // \param all true all input maps // \param all false only the mas which were switched on virtual bool inputRegion( struct Cell_head *window, QgsCoordinateReferenceSystem &crs, bool all ) - { Q_UNUSED( window ) Q_UNUSED( crs ); Q_UNUSED( all ); return false; } + { + Q_UNUSED( window ) + Q_UNUSED( crs ); + Q_UNUSED( all ); + return false; + } //! Flag names - virtual QStringList flagNames() { return QStringList() ; } + virtual QStringList flagNames() { return QStringList(); } QStringList errors() const { return mErrors; } @@ -138,7 +150,7 @@ class QgsGrassModuleOptions * \brief Widget with GRASS standard options. * */ -class QgsGrassModuleStandardOptions: public QWidget, public QgsGrassModuleOptions +class QgsGrassModuleStandardOptions : public QWidget, public QgsGrassModuleOptions { Q_OBJECT @@ -148,7 +160,8 @@ class QgsGrassModuleStandardOptions: public QWidget, public QgsGrassModuleOption QgsGrassTools *tools, QgsGrassModule *module, QgisInterface *iface, QString xname, QDomElement confDocElem, - bool direct, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); + bool direct, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() + ); //! Gets module options as list of arguments for QProcess QStringList arguments() override; @@ -177,7 +190,6 @@ class QgsGrassModuleStandardOptions: public QWidget, public QgsGrassModuleOption void switchAdvanced(); private: - /** * Read and parse module options (--interface-description). * \param errors list to which possible errors are added diff --git a/src/plugins/grass/qgsgrassmoduleparam.cpp b/src/plugins/grass/qgsgrassmoduleparam.cpp index eaff34fb5fc6..e8d9ec471be2 100644 --- a/src/plugins/grass/qgsgrassmoduleparam.cpp +++ b/src/plugins/grass/qgsgrassmoduleparam.cpp @@ -48,8 +48,7 @@ extern "C" #endif /********************** QgsGrassModuleParam *************************/ -QgsGrassModuleParam::QgsGrassModuleParam( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct ) +QgsGrassModuleParam::QgsGrassModuleParam( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct ) : mModule( module ) , mKey( key ) , mMultiple( false ) @@ -201,9 +200,7 @@ QList QgsGrassModuleParam::nodesByType( QDomElement descDomElement, ST /***************** QgsGrassModuleGroupBoxItem *********************/ -QgsGrassModuleGroupBoxItem::QgsGrassModuleGroupBoxItem( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent ) +QgsGrassModuleGroupBoxItem::QgsGrassModuleGroupBoxItem( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) : QGroupBox( parent ) , QgsGrassModuleParam( module, key, qdesc, gdesc, gnode, direct ) { @@ -227,9 +224,7 @@ void QgsGrassModuleGroupBoxItem::adjustTitle() /***************** QgsGrassModuleMultiParam *********************/ -QgsGrassModuleMultiParam::QgsGrassModuleMultiParam( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent ) +QgsGrassModuleMultiParam::QgsGrassModuleMultiParam( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) : QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ) { adjustTitle(); @@ -241,7 +236,6 @@ QgsGrassModuleMultiParam::QgsGrassModuleMultiParam( QgsGrassModule *module, QStr mParamsLayout = new QVBoxLayout(); mLayout->insertLayout( -1, mParamsLayout ); - } void QgsGrassModuleMultiParam::showAddRemoveButtons() @@ -264,9 +258,7 @@ void QgsGrassModuleMultiParam::showAddRemoveButtons() /********************** QgsGrassModuleOption *************************/ -QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent ) +QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) : QgsGrassModuleMultiParam( module, key, qdesc, gdesc, gnode, direct, parent ) , mControlType( NoControl ) , mValueType( String ) @@ -349,7 +341,6 @@ QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key, if ( !valueElem.isNull() && valueElem.tagName() == QLatin1String( "value" ) ) { - QDomNode n = valueNode.namedItem( QStringLiteral( "name" ) ); if ( !n.isNull() ) { @@ -503,7 +494,6 @@ QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key, void QgsGrassModuleOption::addRow() { - // TODO make the widget growing with new lines. HOW???!!! QLineEdit *lineEdit = new QLineEdit( this ); mLineEdits << lineEdit; @@ -567,7 +557,6 @@ void QgsGrassModuleOption::addRow() void QgsGrassModuleOption::removeRow() { - if ( mLineEdits.size() < 2 ) { return; @@ -590,13 +579,12 @@ void QgsGrassModuleOption::browse( bool checked ) fileName = fileName + ".tif"; } mLineEdits.at( 0 )->setText( fileName ); - settings.setValue( QStringLiteral( "GRASS/lastDirectOutputDir" ), QFileInfo( fileName ).absolutePath() ); + settings.setValue( QStringLiteral( "GRASS/lastDirectOutputDir" ), QFileInfo( fileName ).absolutePath() ); } } QString QgsGrassModuleOption::outputExists() { - if ( !mIsOutput ) return QString(); @@ -758,12 +746,9 @@ QString QgsGrassModuleOption::ready() } /***************** QgsGrassModuleFlag *********************/ -QgsGrassModuleFlag::QgsGrassModuleFlag( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent ) +QgsGrassModuleFlag::QgsGrassModuleFlag( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) : QgsGrassModuleCheckBox( QString(), parent ), QgsGrassModuleParam( module, key, qdesc, gdesc, gnode, direct ) { - if ( mHidden ) hide(); @@ -790,7 +775,8 @@ QStringList QgsGrassModuleFlag::options() QgsGrassModuleGdalInput::QgsGrassModuleGdalInput( QgsGrassModule *module, Type type, QString key, QDomElement &qdesc, - QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) + QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent +) : QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ) , mType( type ) { @@ -802,9 +788,8 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput( // Read "layeroption" is defined QString opt = qdesc.attribute( QStringLiteral( "layeroption" ) ); - if ( ! opt.isNull() ) + if ( !opt.isNull() ) { - QDomNode optNode = nodeByKey( gdesc, opt ); if ( optNode.isNull() ) @@ -834,7 +819,7 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput( QVBoxLayout *l = new QVBoxLayout( this ); mLayerComboBox = new QComboBox(); - mLayerComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy:: Preferred ); + mLayerComboBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); l->addWidget( mLayerComboBox ); QLabel *lbl = new QLabel( tr( "Password" ) ); @@ -847,10 +832,8 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput( lbl->setBuddy( mLayerPassword ); - connect( QgsProject::instance(), &QgsProject::layersAdded, - this, &QgsGrassModuleGdalInput::updateQgisLayers ); - connect( QgsProject::instance(), &QgsProject::layersRemoved, - this, &QgsGrassModuleGdalInput::updateQgisLayers ); + connect( QgsProject::instance(), &QgsProject::layersAdded, this, &QgsGrassModuleGdalInput::updateQgisLayers ); + connect( QgsProject::instance(), &QgsProject::layersRemoved, this, &QgsGrassModuleGdalInput::updateQgisLayers ); // Fill in QGIS layers updateQgisLayers(); @@ -858,7 +841,6 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput( void QgsGrassModuleGdalInput::updateQgisLayers() { - QString current = mLayerComboBox->currentText(); mLayerComboBox->clear(); mUri.clear(); @@ -876,14 +858,13 @@ void QgsGrassModuleGdalInput::updateQgisLayers() for ( QgsMapLayer *layer : QgsProject::instance()->mapLayers().values() ) { - if ( !layer ) continue; + if ( !layer ) + continue; if ( mType == Ogr && layer->type() == Qgis::LayerType::Vector ) { QgsVectorLayer *vector = qobject_cast( layer ); - if ( !vector || - ( vector->providerType() != QLatin1String( "ogr" ) && vector->providerType() != QLatin1String( "postgres" ) ) - ) + if ( !vector || ( vector->providerType() != QLatin1String( "ogr" ) && vector->providerType() != QLatin1String( "postgres" ) ) ) continue; QgsDataProvider *provider = vector->dataProvider(); @@ -1013,7 +994,6 @@ QStringList QgsGrassModuleGdalInput::options() QString QgsGrassModuleGdalInput::ready() { - QString error; QgsDebugMsgLevel( QString( "count = %1" ).arg( mLayerComboBox->count() ), 3 ); @@ -1030,8 +1010,7 @@ void QgsGrassModuleGdalInput::changed( int i ) } /***************** QgsGrassModuleField *********************/ -QgsGrassModuleField::QgsGrassModuleField( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) +QgsGrassModuleField::QgsGrassModuleField( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) : QgsGrassModuleOption( module, key, qdesc, gdesc, gnode, direct, parent ) { // Validator is disabled to also allow entering of expressions @@ -1049,7 +1028,8 @@ QgsGrassModuleField::QgsGrassModuleField( QgsGrassModule *module, QString key, QgsGrassModuleVectorField::QgsGrassModuleVectorField( QgsGrassModule *module, QgsGrassModuleStandardOptions *options, QString key, QDomElement &qdesc, - QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) + QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent +) : QgsGrassModuleMultiParam( module, key, qdesc, gdesc, gnode, direct, parent ) , mModuleStandardOptions( options ) { @@ -1101,7 +1081,6 @@ void QgsGrassModuleVectorField::addRow() void QgsGrassModuleVectorField::removeRow() { - if ( mComboBoxList.size() < 2 ) { return; @@ -1112,7 +1091,6 @@ void QgsGrassModuleVectorField::removeRow() void QgsGrassModuleVectorField::updateFields() { - for ( QComboBox *comboBox : mComboBoxList ) { QString current = comboBox->currentText(); @@ -1129,7 +1107,7 @@ void QgsGrassModuleVectorField::updateFields() if ( mType.contains( field.typeName() ) ) { comboBox->addItem( field.name() ); - QgsDebugMsgLevel( "current = " + current + " field = " + field.name(), 3 ); + QgsDebugMsgLevel( "current = " + current + " field = " + field.name(), 3 ); if ( field.name() == current ) { comboBox->setCurrentIndex( index ); @@ -1167,7 +1145,8 @@ QStringList QgsGrassModuleVectorField::options() QgsGrassModuleSelection::QgsGrassModuleSelection( QgsGrassModule *module, QgsGrassModuleStandardOptions *options, QString key, QDomElement &qdesc, - QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) + QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent +) : QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ) , mModuleStandardOptions( options ) { @@ -1211,7 +1190,6 @@ QgsGrassModuleSelection::QgsGrassModuleSelection( void QgsGrassModuleSelection::onLayerChanged() { - if ( !mLayerInput ) { return; @@ -1268,7 +1246,7 @@ void QgsGrassModuleSelection::onLayerChanged() { if ( mLayerInput->currentLayer() ) { - mModeComboBox->addItem( tr( "Add to canvas layer" ) + " " + mLayerInput->currentMap() + " " + layerCode, AddLayer ); + mModeComboBox->addItem( tr( "Add to canvas layer" ) + " " + mLayerInput->currentMap() + " " + layerCode, AddLayer ); QgsGrassObject grassObject = mLayerInput->currentLayer()->grassObject(); QString uri = grassObject.mapsetPath() + "/" + grassObject.name() + "/" + layerCode; QgsDebugMsgLevel( "uri = " + uri, 3 ); @@ -1403,7 +1381,8 @@ QStringList QgsGrassModuleSelection::options() QgsGrassModuleFile::QgsGrassModuleFile( QgsGrassModule *module, QString key, QDomElement &qdesc, - QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent ) + QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent +) : QgsGrassModuleGroupBoxItem( module, key, qdesc, gdesc, gnode, direct, parent ) , mType( Old ) { @@ -1437,8 +1416,7 @@ QgsGrassModuleFile::QgsGrassModuleFile( l->addWidget( mLineEdit ); l->addWidget( mBrowseButton ); - connect( mBrowseButton, &QAbstractButton::clicked, - this, &QgsGrassModuleFile::browse ); + connect( mBrowseButton, &QAbstractButton::clicked, this, &QgsGrassModuleFile::browse ); } QStringList QgsGrassModuleFile::options() @@ -1566,4 +1544,3 @@ void QgsGrassModuleCheckBox::adjustText() QWidget::setToolTip( tt ); } } - diff --git a/src/plugins/grass/qgsgrassmoduleparam.h b/src/plugins/grass/qgsgrassmoduleparam.h index f57e1cb3747d..3f9ab26e7034 100644 --- a/src/plugins/grass/qgsgrassmoduleparam.h +++ b/src/plugins/grass/qgsgrassmoduleparam.h @@ -54,7 +54,6 @@ class QgsGrassModuleCheckBox : public QCheckBox Q_OBJECT public: - /** * \brief Constructor */ @@ -83,15 +82,13 @@ class QgsGrassModuleCheckBox : public QCheckBox class QgsGrassModuleParam { public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file * \param gnode option node in GRASS module XML description file */ - QgsGrassModuleParam( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct ); + QgsGrassModuleParam( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct ); virtual ~QgsGrassModuleParam() = default; @@ -112,7 +109,7 @@ class QgsGrassModuleParam //! Check if option is ready // Returns empty string or error message - virtual QString ready() { return QString() ; } + virtual QString ready() { return QString(); } QStringList errors() const { return mErrors; } @@ -134,7 +131,6 @@ class QgsGrassModuleParam static QList nodesByType( QDomElement descDomElement, STD_OPT optionType, const QString &age = QString() ); protected: - //! Pointer to GRASS module QgsGrassModule *mModule = nullptr; @@ -179,16 +175,13 @@ class QgsGrassModuleGroupBoxItem : public QGroupBox, public QgsGrassModuleParam Q_OBJECT public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file * \param gnode option node in GRASS module XML description file */ - QgsGrassModuleGroupBoxItem( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleGroupBoxItem( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); void resizeEvent( QResizeEvent *event ) override; @@ -208,9 +201,7 @@ class QgsGrassModuleMultiParam : public QgsGrassModuleGroupBoxItem Q_OBJECT public: - QgsGrassModuleMultiParam( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleMultiParam( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); public slots: virtual void addRow() {} @@ -247,24 +238,38 @@ class QgsGrassModuleOption : public QgsGrassModuleMultiParam Q_OBJECT public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleOption( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleOption( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); //! Control option - enum ControlType { NoControl, LineEdit, ComboBox, SpinBox, CheckBoxes }; + enum ControlType + { + NoControl, + LineEdit, + ComboBox, + SpinBox, + CheckBoxes + }; //! Control option - enum ValueType { Double, Integer, String }; + enum ValueType + { + Double, + Integer, + String + }; //! Output type - enum OutputType { None, Vector, Raster }; + enum OutputType + { + None, + Vector, + Raster + }; //! Returns list of options which will be passed to module QStringList options() override; @@ -352,19 +357,15 @@ class QgsGrassModuleFlag : public QgsGrassModuleCheckBox, public QgsGrassModuleP Q_OBJECT public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleFlag( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleFlag( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); //! Returns list of options which will be passed to module QStringList options() override; - }; /*********************** QgsGrassModuleGdalInput **********************/ @@ -378,16 +379,18 @@ class QgsGrassModuleGdalInput : public QgsGrassModuleGroupBoxItem Q_OBJECT public: - enum Type { Gdal, Ogr }; + enum Type + { + Gdal, + Ogr + }; /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleGdalInput( QgsGrassModule *module, QgsGrassModuleGdalInput::Type type, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleGdalInput( QgsGrassModule *module, QgsGrassModuleGdalInput::Type type, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); //! Reimplemented QStringList options() override; @@ -437,15 +440,12 @@ class QgsGrassModuleField : public QgsGrassModuleOption Q_OBJECT public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleField( QgsGrassModule *module, QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleField( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); }; /*********************** QgsGrassModuleVectorField **********************/ @@ -459,17 +459,12 @@ class QgsGrassModuleVectorField : public QgsGrassModuleMultiParam Q_OBJECT public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleVectorField( QgsGrassModule *module, - QgsGrassModuleStandardOptions *options, - QString key, - QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleVectorField( QgsGrassModule *module, QgsGrassModuleStandardOptions *options, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); //! Returns list of options which will be passed to module QStringList options() override; @@ -517,9 +512,9 @@ class QgsGrassModuleSelection : public QgsGrassModuleGroupBoxItem public: enum Mode { - Manual, // manual entry - Layer, // current selection of select - AddLayer, // add current layer to canvas + Manual, // manual entry + Layer, // current selection of select + AddLayer, // add current layer to canvas Expression // expression builder - possible? }; @@ -528,12 +523,7 @@ class QgsGrassModuleSelection : public QgsGrassModuleGroupBoxItem * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleSelection( QgsGrassModule *module, - QgsGrassModuleStandardOptions *options, - QString key, - QDomElement &qdesc, QDomElement &gdesc, - QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleSelection( QgsGrassModule *module, QgsGrassModuleStandardOptions *options, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); //! Returns list of options which will be passed to module QStringList options() override; @@ -574,7 +564,7 @@ class QgsGrassModuleSelection : public QgsGrassModuleGroupBoxItem QComboBox *mModeComboBox = nullptr; QgsGrassModuleSelection( const QgsGrassModuleSelection & ) = delete; - QgsGrassModuleSelection &operator = ( const QgsGrassModuleSelection & ) = delete; + QgsGrassModuleSelection &operator=( const QgsGrassModuleSelection & ) = delete; }; /*********************** QgsGrassModuleFile **********************/ @@ -588,20 +578,21 @@ class QgsGrassModuleFile : public QgsGrassModuleGroupBoxItem Q_OBJECT public: - /** * \brief Constructor * \param qdesc option element in QGIS module description XML file * \param gdesc GRASS module XML description file */ - QgsGrassModuleFile( QgsGrassModule *module, - QString key, - QDomElement &qdesc, QDomElement &gdesc, - QDomNode &gnode, - bool direct, QWidget *parent = nullptr ); + QgsGrassModuleFile( QgsGrassModule *module, QString key, QDomElement &qdesc, QDomElement &gdesc, QDomNode &gnode, bool direct, QWidget *parent = nullptr ); //! File type - enum Type { Old, New, Multiple, Directory }; + enum Type + { + Old, + New, + Multiple, + Directory + }; // Reimplemented methods from QgsGrassModuleOptions QStringList options() override; @@ -628,7 +619,7 @@ class QgsGrassModuleFile : public QgsGrassModuleGroupBoxItem QString mFilters; QgsGrassModuleFile( const QgsGrassModuleFile & ) = delete; - QgsGrassModuleFile &operator = ( const QgsGrassModuleFile & ) = delete; + QgsGrassModuleFile &operator=( const QgsGrassModuleFile & ) = delete; }; #endif // QGSGRASSMODULEPARAM_H diff --git a/src/plugins/grass/qgsgrassnewmapset.cpp b/src/plugins/grass/qgsgrassnewmapset.cpp index 20955e19b805..176af2a64c68 100644 --- a/src/plugins/grass/qgsgrassnewmapset.cpp +++ b/src/plugins/grass/qgsgrassnewmapset.cpp @@ -44,7 +44,7 @@ extern "C" { -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -62,9 +62,7 @@ QString temp3( GRASS_VERSION_MINOR ); QString temp4( GRASS_VERSION_RELEASE ); #endif -QgsGrassNewMapset::QgsGrassNewMapset( QgisInterface *iface, - QgsGrassPlugin *plugin, QWidget *parent, - Qt::WindowFlags f ) +QgsGrassNewMapset::QgsGrassNewMapset( QgisInterface *iface, QgsGrassPlugin *plugin, QWidget *parent, Qt::WindowFlags f ) : QWizard( parent, f ) , QgsGrassNewMapsetBase() , mIface( iface ) @@ -215,13 +213,11 @@ bool QgsGrassNewMapset::gisdbaseExists() /*************************** LOCATION *******************************/ void QgsGrassNewMapset::setLocationPage() { - setLocations(); } void QgsGrassNewMapset::setLocations() { - mLocationComboBox->clear(); QgsSettings settings; @@ -437,7 +433,6 @@ void QgsGrassNewMapset::setGrassProjection() /**************************** REGION ********************************/ void QgsGrassNewMapset::setRegionPage() { - // Set defaults if ( !mRegionModified ) { @@ -501,22 +496,14 @@ void QgsGrassNewMapset::setGrassRegionDefaults() const QgsCoordinateReferenceSystem selectedCrs = mProjectionSelector->crs(); QgsRectangle defaultExtent; - if ( extSet && - ( mNoProjRadioButton->isChecked() || - ( mProjRadioButton->isChecked() - && canvasCrs == selectedCrs ) - ) - ) + if ( extSet && ( mNoProjRadioButton->isChecked() || ( mProjRadioButton->isChecked() && canvasCrs == selectedCrs ) ) ) { defaultExtent = ext; } else if ( !selectedCrs.bounds().isEmpty() ) { const QgsRectangle boundsWgs84 = selectedCrs.bounds(); - QgsCoordinateTransform fromWgs84Transform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - selectedCrs, - QgsProject::instance()->transformContext() - ); + QgsCoordinateTransform fromWgs84Transform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), selectedCrs, QgsProject::instance()->transformContext() ); fromWgs84Transform.setBallparkTransformsAreAppropriate( true ); try @@ -525,7 +512,6 @@ void QgsGrassNewMapset::setGrassRegionDefaults() } catch ( QgsCsException & ) { - } } if ( defaultExtent.isEmpty() ) @@ -592,17 +578,17 @@ void QgsGrassNewMapset::checkRegion() double res = ( e - w ) / 1000; // reasonable resolution double res3 = res / 10.; - mCellHead.rows = ( int )( ( n - s ) / res ); - mCellHead.rows3 = ( int )( ( n - s ) / res3 ); - mCellHead.cols = ( int )( ( e - w ) / res ); - mCellHead.cols3 = ( int )( ( e - w ) / res3 ); + mCellHead.rows = ( int ) ( ( n - s ) / res ); + mCellHead.rows3 = ( int ) ( ( n - s ) / res3 ); + mCellHead.cols = ( int ) ( ( e - w ) / res ); + mCellHead.cols3 = ( int ) ( ( e - w ) / res3 ); mCellHead.depths = 1; - mCellHead.ew_res = res; + mCellHead.ew_res = res; mCellHead.ew_res3 = res3; - mCellHead.ns_res = res; + mCellHead.ns_res = res; mCellHead.ns_res3 = res3; - mCellHead.tb_res = 1.; + mCellHead.tb_res = 1.; // Do not override zone, it was set in setGrassProjection() //mCellHead.zone = 0; @@ -611,7 +597,6 @@ void QgsGrassNewMapset::checkRegion() void QgsGrassNewMapset::loadRegions() { - QString path = QgsApplication::pkgDataPath() + "/grass/locations.gml"; QgsDebugMsgLevel( QString( "load:%1" ).arg( path.toLocal8Bit().constData() ), 2 ); @@ -622,7 +607,7 @@ void QgsGrassNewMapset::loadRegions() QgsGrass::warning( tr( "Regions file (%1) not found." ).arg( path ) ); return; } - if ( ! file.open( QIODevice::ReadOnly ) ) + if ( !file.open( QIODevice::ReadOnly ) ) { QgsGrass::warning( tr( "Cannot open locations file (%1)" ).arg( path ) ); return; @@ -632,7 +617,7 @@ void QgsGrassNewMapset::loadRegions() QString err; int line, column; - if ( !doc.setContent( &file, &err, &line, &column ) ) + if ( !doc.setContent( &file, &err, &line, &column ) ) { QString errmsg = tr( "Cannot read locations file (%1):" ).arg( path ) + tr( "\n%1\nat line %2 column %3" ).arg( err ).arg( line ).arg( column ); @@ -711,7 +696,7 @@ void QgsGrassNewMapset::setSelectedRegion() if ( mRegionsComboBox->currentIndex() < 0 ) return; - const QgsRectangle currentRect = mRegionsComboBox->currentData().value< QgsRectangle >(); + const QgsRectangle currentRect = mRegionsComboBox->currentData().value(); std::vector points; // corners ll lr ur ul @@ -812,7 +797,6 @@ void QgsGrassNewMapset::setSelectedRegion() void QgsGrassNewMapset::setCurrentRegion() { - mRegionModified = true; checkRegion(); drawRegion(); @@ -821,14 +805,12 @@ void QgsGrassNewMapset::setCurrentRegion() void QgsGrassNewMapset::clearRegion() { - QPixmap pm = mPixmap; mRegionMap->setPixmap( pm ); } void QgsGrassNewMapset::drawRegion() { - QPixmap pm = mPixmap; mRegionMap->setPixmap( pm ); @@ -879,7 +861,6 @@ void QgsGrassNewMapset::drawRegion() double dy = ( tpoints[i + 1].y() - y ) / 3; QgsDebugMsgLevel( QString( "dx = %1 x = %2" ).arg( dx ).arg( x + j * dx ), 3 ); points << QgsPointXY( x + j * dx, y + j * dy ); - } } points << points[0]; // close polygon @@ -962,8 +943,7 @@ void QgsGrassNewMapset::drawRegion() x2 -= 360; } } - p.drawLine( 180 + shift + static_cast( x1 ), 90 - static_cast( points[i].y() ), - 180 + shift + static_cast( x2 ), 90 - static_cast( points[i + 1].y() ) ); + p.drawLine( 180 + shift + static_cast( x1 ), 90 - static_cast( points[i].y() ), 180 + shift + static_cast( x2 ), 90 - static_cast( points[i + 1].y() ) ); } } @@ -1012,7 +992,6 @@ void QgsGrassNewMapset::setMapsets() void QgsGrassNewMapset::mapsetChanged() { - button( QWizard::NextButton )->setEnabled( false ); setError( mMapsetErrorLabel ); @@ -1071,7 +1050,6 @@ void QgsGrassNewMapset::setFinishPage() void QgsGrassNewMapset::createMapset() { - // TODO: handle all possible errors better, especially half created location/mapset if ( !gisdbaseExists() ) @@ -1098,10 +1076,7 @@ void QgsGrassNewMapset::createMapset() QString error; G_TRY { - ret = G_make_location_crs( location.toUtf8().constData(), - &mCellHead, mProjInfo, mProjUnits, - mProjSrid.toUtf8().constData(), - mProjWkt.toUtf8().constData() ); + ret = G_make_location_crs( location.toUtf8().constData(), &mCellHead, mProjInfo, mProjUnits, mProjSrid.toUtf8().constData(), mProjWkt.toUtf8().constData() ); } G_CATCH( QgsGrass::Exception & e ) { @@ -1144,17 +1119,16 @@ void QgsGrassNewMapset::createMapset() if ( mOpenNewMapsetCheckBox->isChecked() ) { QString error = QgsGrass::openMapset( - mDirectoryWidget->filePath(), location, mapset ); + mDirectoryWidget->filePath(), location, mapset + ); if ( !error.isEmpty() ) { - QMessageBox::information( this, tr( "New mapset" ), - tr( "New mapset successfully created, but cannot be opened: %1" ).arg( error ) ); + QMessageBox::information( this, tr( "New mapset" ), tr( "New mapset successfully created, but cannot be opened: %1" ).arg( error ) ); } else { - QMessageBox::information( this, tr( "New mapset" ), - tr( "New mapset successfully created and set as current working mapset." ) ); + QMessageBox::information( this, tr( "New mapset" ), tr( "New mapset successfully created and set as current working mapset." ) ); mPlugin->mapsetChanged(); } @@ -1169,14 +1143,12 @@ void QgsGrassNewMapset::createMapset() void QgsGrassNewMapset::accept() { - createMapset(); } /********************************************************************/ void QgsGrassNewMapset::setError( QLabel *line, const QString &err ) { - if ( !err.isEmpty() ) { line->setText( err ); @@ -1197,7 +1169,7 @@ void QgsGrassNewMapset::setError( QLabel *line, const QString &err ) void QgsGrassNewMapset::keyPressEvent( QKeyEvent *e ) { Q_UNUSED( e ) -// QgsDebugMsgLevel(QString("key = %1").arg(e->key()), 3); + // QgsDebugMsgLevel(QString("key = %1").arg(e->key()), 3); } void QgsGrassNewMapset::pageSelected( int index ) @@ -1226,10 +1198,9 @@ void QgsGrassNewMapset::pageSelected( int index ) mProjectionSelector->show(); - connect( mProjectionSelector, &QgsProjectionSelectionTreeWidget::crsSelected, - this, &QgsGrassNewMapset::sridSelected ); + connect( mProjectionSelector, &QgsProjectionSelectionTreeWidget::crsSelected, this, &QgsGrassNewMapset::sridSelected ); - QgsCoordinateReferenceSystem srs = mIface->mapCanvas()->mapSettings().destinationCrs(); + QgsCoordinateReferenceSystem srs = mIface->mapCanvas()->mapSettings().destinationCrs(); QgsDebugMsgLevel( "srs = " + srs.toWkt(), 3 ); if ( srs.isValid() ) diff --git a/src/plugins/grass/qgsgrassnewmapset.h b/src/plugins/grass/qgsgrassnewmapset.h index 0d423290ef6e..5110780ded74 100644 --- a/src/plugins/grass/qgsgrassnewmapset.h +++ b/src/plugins/grass/qgsgrassnewmapset.h @@ -41,7 +41,6 @@ class QgsGrassNewMapset : public QWizard, private Ui::QgsGrassNewMapsetBase Q_OBJECT public: - enum Page { Database, @@ -53,9 +52,7 @@ class QgsGrassNewMapset : public QWizard, private Ui::QgsGrassNewMapsetBase }; //! Constructor - QgsGrassNewMapset( QgisInterface *iface, - QgsGrassPlugin *plugin, - QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); + QgsGrassNewMapset( QgisInterface *iface, QgsGrassPlugin *plugin, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); ~QgsGrassNewMapset(); @@ -170,6 +167,7 @@ class QgsGrassNewMapset : public QWizard, private Ui::QgsGrassNewMapsetBase //! Sets error line void setError( QLabel *line, const QString &err = QString() ); + private: //! Gets current gisdbase QString gisdbase() const; diff --git a/src/plugins/grass/qgsgrassplugin.cpp b/src/plugins/grass/qgsgrassplugin.cpp index c97026e08206..68f6d1c243a6 100644 --- a/src/plugins/grass/qgsgrassplugin.cpp +++ b/src/plugins/grass/qgsgrassplugin.cpp @@ -256,8 +256,7 @@ void QgsGrassPlugin::initGui() // Connect start/stop editing connect( QgsProject::instance(), &QgsProject::layerWasAdded, this, &QgsGrassPlugin::onLayerWasAdded ); - connect( qGisInterface->layerTreeView(), &QgsLayerTreeView::currentLayerChanged, - this, &QgsGrassPlugin::onCurrentLayerChanged ); + connect( qGisInterface->layerTreeView(), &QgsLayerTreeView::currentLayerChanged, this, &QgsGrassPlugin::onCurrentLayerChanged ); // open tools when plugin is loaded so that main app restores tools dock widget state mTools = new QgsGrassTools( qGisInterface, qGisInterface->mainWindow() ); @@ -266,11 +265,7 @@ void QgsGrassPlugin::initGui() // add edit renderer immediately so that if project was saved during editing, the layer can be loaded if ( !QgsApplication::rendererRegistry()->renderersList().contains( QStringLiteral( "grassEdit" ) ) ) { - QgsApplication::rendererRegistry()->addRenderer( new QgsRendererMetadata( QStringLiteral( "grassEdit" ), - QObject::tr( "GRASS edit" ), - QgsGrassEditRenderer::create, - QIcon( QgsApplication::defaultThemePath() + "rendererGrassSymbol.svg" ), - QgsGrassEditRendererWidget::create ) ); + QgsApplication::rendererRegistry()->addRenderer( new QgsRendererMetadata( QStringLiteral( "grassEdit" ), QObject::tr( "GRASS edit" ), QgsGrassEditRenderer::create, QIcon( QgsApplication::defaultThemePath() + "rendererGrassSymbol.svg" ), QgsGrassEditRendererWidget::create ) ); } onGisbaseChanged(); @@ -329,7 +324,6 @@ void QgsGrassPlugin::onCurrentLayerChanged( QgsMapLayer *layer ) void QgsGrassPlugin::resetEditActions() { - QgsGrassProvider *grassProvider = nullptr; QgsVectorLayer *vectorLayer = qobject_cast( qGisInterface->activeLayer() ); if ( vectorLayer ) @@ -439,7 +433,7 @@ void QgsGrassPlugin::onFieldsChanged() } QgsVectorLayer *vectorLayer = qobject_cast( layer ); - if ( vectorLayer && vectorLayer->providerType() == QLatin1String( "grass" ) && vectorLayer->dataProvider() ) + if ( vectorLayer && vectorLayer->providerType() == QLatin1String( "grass" ) && vectorLayer->dataProvider() ) { if ( vectorLayer->dataProvider()->dataSourceUri().startsWith( uri ) ) { @@ -567,16 +561,13 @@ void QgsGrassPlugin::newVector() QString name; QgsGrassElementDialog dialog( qGisInterface->mainWindow() ); - name = dialog.getItem( QStringLiteral( "vector" ), tr( "New vector name" ), - tr( "New vector name" ), QString(), QString(), &ok ); + name = dialog.getItem( QStringLiteral( "vector" ), tr( "New vector name" ), tr( "New vector name" ), QString(), QString(), &ok ); if ( !ok ) return; // Create new map - QgsGrass::setMapset( QgsGrass::getDefaultGisdbase(), - QgsGrass::getDefaultLocation(), - QgsGrass::getDefaultMapset() ); + QgsGrass::setMapset( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), QgsGrass::getDefaultMapset() ); struct Map_info *Map = nullptr; G_TRY @@ -607,8 +598,7 @@ void QgsGrassPlugin::newVector() if ( !layer ) { - QMessageBox::warning( nullptr, tr( "Warning" ), - tr( "New vector created but cannot be opened by data provider." ) ); + QMessageBox::warning( nullptr, tr( "Warning" ), tr( "New vector created but cannot be opened by data provider." ) ); return; } @@ -635,7 +625,6 @@ void QgsGrassPlugin::postRender( QPainter *painter ) void QgsGrassPlugin::displayRegion() { - mRegionBand->reset(); if ( !mRegionAction->isChecked() ) { @@ -670,7 +659,6 @@ void QgsGrassPlugin::displayRegion() void QgsGrassPlugin::switchRegion( bool on ) { - QgsSettings settings; settings.setValue( QStringLiteral( "GRASS/region/on" ), on ); @@ -686,7 +674,6 @@ void QgsGrassPlugin::switchRegion( bool on ) void QgsGrassPlugin::redrawRegion() { - displayRegion(); } @@ -697,8 +684,7 @@ void QgsGrassPlugin::openMapset() if ( !sel->exec() ) return; - QString err = QgsGrass::openMapset( sel->gisdbase, - sel->location, sel->mapset ); + QString err = QgsGrass::openMapset( sel->gisdbase, sel->location, sel->mapset ); if ( !err.isNull() ) { @@ -718,8 +704,7 @@ void QgsGrassPlugin::newMapset() { if ( !mNewMapset ) { - mNewMapset = new QgsGrassNewMapset( qGisInterface, - this, qGisInterface->mainWindow() ); + mNewMapset = new QgsGrassNewMapset( qGisInterface, this, qGisInterface->mainWindow() ); } mNewMapset->show(); mNewMapset->raise(); @@ -727,16 +712,21 @@ void QgsGrassPlugin::newMapset() void QgsGrassPlugin::projectRead() { - bool ok; QString gisdbase = QgsProject::instance()->readPath( - QgsProject::instance()->readEntry( - QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingGisdbase" ), QString(), &ok ).trimmed() - ); + QgsProject::instance()->readEntry( + QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingGisdbase" ), QString(), &ok + ) + .trimmed() + ); QString location = QgsProject::instance()->readEntry( - QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingLocation" ), QString(), &ok ).trimmed(); + QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingLocation" ), QString(), &ok + ) + .trimmed(); QString mapset = QgsProject::instance()->readEntry( - QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingMapset" ), QString(), &ok ).trimmed(); + QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingMapset" ), QString(), &ok + ) + .trimmed(); if ( gisdbase.isEmpty() || location.isEmpty() || mapset.isEmpty() ) { @@ -751,8 +741,7 @@ void QgsGrassPlugin::projectRead() QString newPath = gisdbase + "/" + location + "/" + mapset; - if ( QFileInfo( currentPath ).canonicalPath() == - QFileInfo( newPath ).canonicalPath() ) + if ( QFileInfo( currentPath ).canonicalPath() == QFileInfo( newPath ).canonicalPath() ) { // The same mapset is already open return; @@ -792,8 +781,7 @@ void QgsGrassPlugin::unload() disconnect( QgsProject::instance(), &QgsProject::layerWasAdded, this, &QgsGrassPlugin::onLayerWasAdded ); - disconnect( qGisInterface->layerTreeView(), &QgsLayerTreeView::currentLayerChanged, - this, &QgsGrassPlugin::onCurrentLayerChanged ); + disconnect( qGisInterface->layerTreeView(), &QgsLayerTreeView::currentLayerChanged, this, &QgsGrassPlugin::onCurrentLayerChanged ); for ( QgsMapLayer *layer : QgsProject::instance()->mapLayers().values() ) { diff --git a/src/plugins/grass/qgsgrassplugin.h b/src/plugins/grass/qgsgrassplugin.h index 53ab706624e3..d2889a7e2c5c 100644 --- a/src/plugins/grass/qgsgrassplugin.h +++ b/src/plugins/grass/qgsgrassplugin.h @@ -46,7 +46,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin Q_OBJECT public: - /** * Constructor for a plugin. The QgisInterface pointer is passed by * QGIS when it attempts to instantiate the plugin. @@ -154,7 +153,7 @@ class QgsGrassPlugin : public QObject, public QgisPlugin //! GRASS tools QgsGrassTools *mTools = nullptr; //! Pointer to QgsGrassNewMapset - QPointer< QgsGrassNewMapset > mNewMapset; + QPointer mNewMapset; QgsCoordinateReferenceSystem mCrs; QgsCoordinateTransform mCoordinateTransform; @@ -183,7 +182,7 @@ class QgsGrassPlugin : public QObject, public QgisPlugin // Names of layer styles before editing started QMap mOldStyles; // Original layer form suppress - QMap mFormSuppress; + QMap mFormSuppress; }; #endif // QGSGRASSPLUGIN_H diff --git a/src/plugins/grass/qgsgrassregion.cpp b/src/plugins/grass/qgsgrassregion.cpp index 91a9abda1ad9..c0eac04b1958 100644 --- a/src/plugins/grass/qgsgrassregion.cpp +++ b/src/plugins/grass/qgsgrassregion.cpp @@ -185,8 +185,7 @@ void QgsGrassRegionEdit::setSrcRegion( const QgsRectangle &rect ) mSrcRectangle = rect; } -QgsGrassRegion::QgsGrassRegion( QgisInterface *iface, - QWidget *parent, Qt::WindowFlags f ) +QgsGrassRegion::QgsGrassRegion( QgisInterface *iface, QWidget *parent, Qt::WindowFlags f ) : QWidget( parent, f ) , QgsGrassRegionBase() , mUpdatingGui( false ) @@ -225,7 +224,7 @@ QgsGrassRegion::QgsGrassRegion( QgisInterface *iface, mResRadio->setChecked( true ); radioChanged(); - connect( mRadioGroup, qOverload< QAbstractButton * >( &QButtonGroup::buttonClicked ), this, &QgsGrassRegion::radioChanged ); + connect( mRadioGroup, qOverload( &QButtonGroup::buttonClicked ), this, &QgsGrassRegion::radioChanged ); // Connect entries connect( mNorth, &QLineEdit::editingFinished, this, &QgsGrassRegion::northChanged ); @@ -441,7 +440,6 @@ void QgsGrassRegion::adjust() void QgsGrassRegion::radioChanged() { - bool res = !mRowsColsRadio->isChecked(); mEWResLabel->setEnabled( res ); @@ -515,5 +513,3 @@ void QgsGrassRegion::buttonClicked( QAbstractButton *button ) // Better to keep the tool selected until another tool is chosen? mCanvas->unsetMapTool( mRegionEdit ); } - - diff --git a/src/plugins/grass/qgsgrassregion.h b/src/plugins/grass/qgsgrassregion.h index c00cd64f077b..1101b6e921cb 100644 --- a/src/plugins/grass/qgsgrassregion.h +++ b/src/plugins/grass/qgsgrassregion.h @@ -42,14 +42,13 @@ extern "C" * \brief GRASS attributes. * */ -class QgsGrassRegion: public QWidget, private Ui::QgsGrassRegionBase +class QgsGrassRegion : public QWidget, private Ui::QgsGrassRegionBase { Q_OBJECT public: //! Constructor - QgsGrassRegion( QgisInterface *iface, - QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); + QgsGrassRegion( QgisInterface *iface, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); ~QgsGrassRegion() override; @@ -88,6 +87,7 @@ class QgsGrassRegion: public QWidget, private Ui::QgsGrassRegionBase void mDrawButton_clicked(); void canvasMapToolSet( QgsMapTool *tool ); + private: //! Pointer to plugin //QgsGrassPlugin *mPlugin; diff --git a/src/plugins/grass/qgsgrassselect.cpp b/src/plugins/grass/qgsgrassselect.cpp index 127abcfff96a..177f6d04e1aa 100644 --- a/src/plugins/grass/qgsgrassselect.cpp +++ b/src/plugins/grass/qgsgrassselect.cpp @@ -251,8 +251,7 @@ void QgsGrassSelect::setMaps() if ( type == Vector ) // vector { - QStringList list = QgsGrass::vectors( egisdbase->text(), - elocation->currentText(), emapset->currentText() ); + QStringList list = QgsGrass::vectors( egisdbase->text(), elocation->currentText(), emapset->currentText() ); for ( int j = 0; j < list.count(); j++ ) { @@ -261,13 +260,11 @@ void QgsGrassSelect::setMaps() sel = idx; idx++; } - } else if ( type == Raster ) { /* add cells */ - QStringList list = QgsGrass::rasters( egisdbase->text(), - elocation->currentText(), emapset->currentText() ); + QStringList list = QgsGrass::rasters( egisdbase->text(), elocation->currentText(), emapset->currentText() ); for ( int j = 0; j < list.count(); j++ ) { @@ -344,9 +341,7 @@ void QgsGrassSelect::setLayers() QStringList layers; try { - layers = QgsGrass::vectorLayers( egisdbase->text(), - elocation->currentText(), emapset->currentText(), - emap->currentText().toUtf8() ); + layers = QgsGrass::vectorLayers( egisdbase->text(), elocation->currentText(), emapset->currentText(), emap->currentText().toUtf8() ); } catch ( QgsGrass::Exception &e ) { @@ -399,8 +394,7 @@ void QgsGrassSelect::setLayers() void QgsGrassSelect::GisdbaseBrowse_clicked() { - QString Gisdbase = QFileDialog::getExistingDirectory( this, - tr( "Choose existing GISDBASE" ), egisdbase->text() ); + QString Gisdbase = QFileDialog::getExistingDirectory( this, tr( "Choose existing GISDBASE" ), egisdbase->text() ); if ( !Gisdbase.isNull() ) { @@ -445,8 +439,7 @@ void QgsGrassSelect::accept() { if ( elayer->count() == 0 ) { - QMessageBox::warning( nullptr, tr( "No layer" ), - tr( "No layers available in this map" ) ); + QMessageBox::warning( nullptr, tr( "No layer" ), tr( "No layers available in this map" ) ); return; } sLastVectorMap = map; diff --git a/src/plugins/grass/qgsgrassselect.h b/src/plugins/grass/qgsgrassselect.h index c97ad7a170c0..bd2465561828 100644 --- a/src/plugins/grass/qgsgrassselect.h +++ b/src/plugins/grass/qgsgrassselect.h @@ -22,7 +22,7 @@ * \brief Dialog to select GRASS layer. * */ -class QgsGrassSelect: public QDialog, private Ui::QgsGrassSelectBase +class QgsGrassSelect : public QDialog, private Ui::QgsGrassSelectBase { Q_OBJECT @@ -36,16 +36,16 @@ class QgsGrassSelect: public QDialog, private Ui::QgsGrassSelectBase MapSet, Vector, Raster, - Group, // group of rasters, used in selectedType + Group, // group of rasters, used in selectedType MapCalc // file in $MAPSET/mapcalc directory (used by QgsGrassMapcalc) }; - QString gisdbase; - QString location; - QString mapset; - QString map; - QString layer; - int selectedType; // RASTER or GROUP + QString gisdbase; + QString location; + QString mapset; + QString map; + QString layer; + int selectedType; // RASTER or GROUP public slots: void accept() override; @@ -70,8 +70,8 @@ class QgsGrassSelect: public QDialog, private Ui::QgsGrassSelectBase void setLayers(); private: - int type; // map type (mapset element) - static bool sFirst; // called first time + int type; // map type (mapset element) + static bool sFirst; // called first time static QString sLastGisdbase; // Last selected values static QString sLastLocation; static QString sLastMapset; diff --git a/src/plugins/grass/qgsgrasstools.cpp b/src/plugins/grass/qgsgrasstools.cpp index 2b7aaa48c07b..be02c6d2f888 100644 --- a/src/plugins/grass/qgsgrasstools.cpp +++ b/src/plugins/grass/qgsgrasstools.cpp @@ -85,8 +85,7 @@ QgsGrassTools::QgsGrassTools( QgisInterface *iface, QWidget *parent, const char mTreeView->setModel( mTreeModelProxy ); - connect( mTreeView, &QAbstractItemView::clicked, - this, &QgsGrassTools::itemClicked ); + connect( mTreeView, &QAbstractItemView::clicked, this, &QgsGrassTools::itemClicked ); // List view with filter mModulesListModel = new QStandardItemModel( 0, 1 ); @@ -95,8 +94,7 @@ QgsGrassTools::QgsGrassTools( QgisInterface *iface, QWidget *parent, const char mModelProxy->setFilterRole( Qt::UserRole + 2 ); mListView->setModel( mModelProxy ); - connect( mListView, &QAbstractItemView::clicked, - this, &QgsGrassTools::itemClicked ); + connect( mListView, &QAbstractItemView::clicked, this, &QgsGrassTools::itemClicked ); mListView->hide(); @@ -130,7 +128,6 @@ void QgsGrassTools::resetTitle() void QgsGrassTools::showTabs() { - resetTitle(); // Build modules tree if empty @@ -161,7 +158,7 @@ void QgsGrassTools::runModule( QString name, bool direct ) { if ( name.length() == 0 ) { - return; // Section + return; // Section } // set wait cursor because starting module may be slow because of getting temporal datasets (t.list) @@ -220,7 +217,7 @@ bool QgsGrassTools::loadConfig( QString filePath, QStandardItemModel *treeModel, QMessageBox::warning( nullptr, tr( "Warning" ), tr( "The config file (%1) not found." ).arg( filePath ) ); return false; } - if ( ! file.open( QIODevice::ReadOnly ) ) + if ( !file.open( QIODevice::ReadOnly ) ) { QMessageBox::warning( nullptr, tr( "Warning" ), tr( "Cannot open config file (%1)." ).arg( filePath ) ); return false; @@ -229,7 +226,7 @@ bool QgsGrassTools::loadConfig( QString filePath, QStandardItemModel *treeModel, QDomDocument doc( QStringLiteral( "qgisgrass" ) ); QString err; int line, column; - if ( !doc.setContent( &file, &err, &line, &column ) ) + if ( !doc.setContent( &file, &err, &line, &column ) ) { QString errmsg = tr( "Cannot read config file (%1):" ).arg( filePath ) + tr( "\n%1\nat line %2 column %3" ).arg( err ).arg( line ).arg( column ); @@ -295,7 +292,7 @@ void QgsGrassTools::addModules( QStandardItem *parent, QDomElement &element, QSt QDomElement e = n.toElement(); if ( !e.isNull() ) { -// QgsDebugMsgLevel(QString("tag = %1").arg(e.tagName()), 3); + // QgsDebugMsgLevel(QString("tag = %1").arg(e.tagName()), 3); if ( e.tagName() != QLatin1String( "section" ) && e.tagName() != QLatin1String( "grass" ) ) { @@ -327,7 +324,7 @@ void QgsGrassTools::addModules( QStandardItem *parent, QDomElement &element, QSt QString label = QApplication::translate( "grasslabel", e.attribute( QStringLiteral( "label" ) ).toUtf8() ); QgsDebugMsgLevel( QString( "label = %1" ).arg( label ), 3 ); QStandardItem *item = new QStandardItem( label ); - item->setData( label, Qt::UserRole + Label ); // original label, for debug + item->setData( label, Qt::UserRole + Label ); // original label, for debug item->setData( label, Qt::UserRole + Search ); // for filtering later addModules( item, e, treeModel, modulesListModel, direct ); @@ -348,8 +345,8 @@ void QgsGrassTools::addModules( QStandardItem *parent, QDomElement &element, QSt QString label = name + " - " + description.label; QPixmap pixmap = QgsGrassModule::pixmap( path, 32 ); QStandardItem *item = new QStandardItem( name + "\n" + description.label ); - item->setData( name, Qt::UserRole + Name ); // for calling runModule later - item->setData( label, Qt::UserRole + Label ); // original label, for debug + item->setData( name, Qt::UserRole + Name ); // for calling runModule later + item->setData( label, Qt::UserRole + Label ); // original label, for debug item->setData( label, Qt::UserRole + Search ); // for filtering later item->setData( pixmap, Qt::DecorationRole ); item->setCheckable( false ); @@ -385,7 +382,6 @@ void QgsGrassTools::addModules( QStandardItem *parent, QDomElement &element, QSt } n = n.nextSibling(); } - } // used for direct @@ -431,7 +427,6 @@ void QgsGrassTools::closeMapset() void QgsGrassTools::mapsetChanged() { - mTabWidget->setCurrentIndex( 0 ); closeTools(); mRegion->mapsetChanged(); @@ -440,7 +435,7 @@ void QgsGrassTools::mapsetChanged() QString QgsGrassTools::appDir( void ) { -#if defined(Q_OS_WIN) +#if defined( Q_OS_WIN ) return QgsGrass::shortPath( QgsApplication::applicationDirPath() ); #else return QgsApplication::applicationDirPath(); @@ -464,7 +459,6 @@ void QgsGrassTools::emitRegionChanged() void QgsGrassTools::closeTools() { - for ( int i = mTabWidget->count() - 1; i > 1; i-- ) // first is module tree, second is region { delete mTabWidget->widget( i ); @@ -531,7 +525,6 @@ void QgsGrassTools::itemClicked( const QModelIndex &index ) void QgsGrassTools::mDebugButton_clicked() { - QApplication::setOverrideCursor( Qt::BusyCursor ); int errors = 0; diff --git a/src/plugins/grass/qgsgrasstools.h b/src/plugins/grass/qgsgrasstools.h index f2b93e52a89e..8e2c7cbb9a16 100644 --- a/src/plugins/grass/qgsgrasstools.h +++ b/src/plugins/grass/qgsgrasstools.h @@ -40,14 +40,13 @@ class QgsGrassToolsTreeFilterProxyModel; * \brief Interface to GRASS modules. * */ -class QgsGrassTools: public QgsDockWidget, public Ui::QgsGrassToolsBase +class QgsGrassTools : public QgsDockWidget, public Ui::QgsGrassToolsBase { Q_OBJECT public: //! Constructor - QgsGrassTools( QgisInterface *iface, - QWidget *parent = nullptr, const char *name = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); + QgsGrassTools( QgisInterface *iface, QWidget *parent = nullptr, const char *name = nullptr, Qt::WindowFlags f = Qt::WindowFlags() ); //! Append item to model or parent @@ -106,7 +105,7 @@ class QgsGrassTools: public QgsDockWidget, public Ui::QgsGrassToolsBase enum DataOffset { Label, // original label - Name, // module name + Name, // module name Search // search text }; @@ -151,9 +150,8 @@ class QgsGrassToolsTreeFilterProxyModel : public QSortFilterProxyModel void setFilter( const QString &filter ); protected: - QAbstractItemModel *mModel = nullptr; - QString mFilter; // filter string provided + QString mFilter; // filter string provided QRegularExpression mRegExp; // regular expression constructed from filter string bool filterAcceptsString( const QString &value ) const; diff --git a/src/plugins/grass/qgsgrassutils.cpp b/src/plugins/grass/qgsgrassutils.cpp index 66eab3919cdf..8e74c2585004 100644 --- a/src/plugins/grass/qgsgrassutils.cpp +++ b/src/plugins/grass/qgsgrassutils.cpp @@ -25,8 +25,7 @@ #include #include -QString QgsGrassUtils::vectorLayerName( QString map, QString layer, - int nLayers ) +QString QgsGrassUtils::vectorLayerName( QString map, QString layer, int nLayers ) { QString name = map; if ( nLayers > 1 ) @@ -34,8 +33,7 @@ QString QgsGrassUtils::vectorLayerName( QString map, QString layer, return name; } -void QgsGrassUtils::addVectorLayers( QgisInterface *iface, - QString gisbase, QString location, QString mapset, QString map ) +void QgsGrassUtils::addVectorLayers( QgisInterface *iface, QString gisbase, QString location, QString mapset, QString map ) { QStringList layers; try @@ -77,7 +75,7 @@ bool QgsGrassUtils::itemExists( QString element, QString item ) QString QgsGrassUtils::htmlBrowserPath() { - return QgsApplication::libexecPath() + "grass/bin/qgis.g.browser" + QString::number( QgsGrass::versionMajor() ); + return QgsApplication::libexecPath() + "grass/bin/qgis.g.browser" + QString::number( QgsGrass::versionMajor() ); } QgsGrassElementDialog::QgsGrassElementDialog( QWidget *parent ) @@ -85,9 +83,7 @@ QgsGrassElementDialog::QgsGrassElementDialog( QWidget *parent ) { } -QString QgsGrassElementDialog::getItem( QString element, - QString title, QString label, - QString text, QString source, bool *ok ) +QString QgsGrassElementDialog::getItem( QString element, QString title, QString label, QString text, QString source, bool *ok ) { if ( ok ) *ok = false; @@ -147,7 +143,6 @@ QString QgsGrassElementDialog::getItem( QString element, void QgsGrassElementDialog::textChanged() { - QString text = mLineEdit->text().trimmed(); mErrorLabel->setText( QStringLiteral( " " ) ); diff --git a/src/plugins/grass/qgsgrassutils.h b/src/plugins/grass/qgsgrassutils.h index aaee0c2f2a9c..fb9fcefbac3d 100644 --- a/src/plugins/grass/qgsgrassutils.h +++ b/src/plugins/grass/qgsgrassutils.h @@ -29,7 +29,6 @@ class QgisInterface; */ class QgsGrassUtils { - public: //! Constructor QgsGrassUtils() = default; @@ -39,8 +38,7 @@ class QgsGrassUtils static QString vectorLayerName( QString map, QString layer, int nLayers ); // Add all vector layers to QGIS view - static void addVectorLayers( QgisInterface *iface, - QString gisbase, QString location, QString mapset, QString map ); + static void addVectorLayers( QgisInterface *iface, QString gisbase, QString location, QString mapset, QString map ); // Check if element exists in current mapset static bool itemExists( QString element, QString item ); @@ -53,7 +51,7 @@ class QgsGrassUtils * \class QgsGrassElementDialog * \brief Dialog for entering a name for a new GRASS element. */ -class QgsGrassElementDialog: public QObject +class QgsGrassElementDialog : public QObject { Q_OBJECT @@ -64,10 +62,7 @@ class QgsGrassElementDialog: public QObject public: //! Gets a name for new GRASS element (map) // \param source local source - QString getItem( QString element, - QString title, QString label, - QString text, QString source = QString(), - bool *ok = nullptr ); + QString getItem( QString element, QString title, QString label, QString text, QString source = QString(), bool *ok = nullptr ); public slots: void textChanged(); diff --git a/src/plugins/offline_editing/offline_editing_plugin.cpp b/src/plugins/offline_editing/offline_editing_plugin.cpp index 6be27e85198a..53119b0d3630 100644 --- a/src/plugins/offline_editing/offline_editing_plugin.cpp +++ b/src/plugins/offline_editing/offline_editing_plugin.cpp @@ -85,7 +85,7 @@ void QgsOfflineEditingPlugin::initGui() connect( mQGisIface, &QgisInterface::newProjectCreated, this, &QgsOfflineEditingPlugin::updateActions ); connect( QgsProject::instance(), &QgsProject::writeProject, this, &QgsOfflineEditingPlugin::updateActions ); connect( QgsProject::instance(), &QgsProject::layerWasAdded, this, &QgsOfflineEditingPlugin::updateActions ); - connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( const QString & ) >( &QgsProject::layerWillBeRemoved ), this, &QgsOfflineEditingPlugin::updateActions ); + connect( QgsProject::instance(), static_cast( &QgsProject::layerWillBeRemoved ), this, &QgsOfflineEditingPlugin::updateActions ); updateActions(); } diff --git a/src/plugins/offline_editing/offline_editing_plugin_gui.cpp b/src/plugins/offline_editing/offline_editing_plugin_gui.cpp index 87ee27997c95..3d2036be8e85 100644 --- a/src/plugins/offline_editing/offline_editing_plugin_gui.cpp +++ b/src/plugins/offline_editing/offline_editing_plugin_gui.cpp @@ -164,11 +164,7 @@ void QgsOfflineEditingPluginGui::mBrowseButton_clicked() case QgsOfflineEditing::GPKG: { //GeoPackage - QString fileName = QFileDialog::getSaveFileName( this, - tr( "Select target database for offline data" ), - QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ), - tr( "GeoPackage" ) + " (*.gpkg);;" - + tr( "All files" ) + " (*.*)" ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "Select target database for offline data" ), QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ), tr( "GeoPackage" ) + " (*.gpkg);;" + tr( "All files" ) + " (*.*)" ); if ( !fileName.isEmpty() ) { @@ -186,11 +182,7 @@ void QgsOfflineEditingPluginGui::mBrowseButton_clicked() case QgsOfflineEditing::SpatiaLite: { //SpaciaLite - QString fileName = QFileDialog::getSaveFileName( this, - tr( "Select target database for offline data" ), - QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ), - tr( "SpatiaLite DB" ) + " (*.sqlite);;" - + tr( "All files" ) + " (*.*)" ); + QString fileName = QFileDialog::getSaveFileName( this, tr( "Select target database for offline data" ), QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ), tr( "SpatiaLite DB" ) + " (*.sqlite);;" + tr( "All files" ) + " (*.*)" ); if ( !fileName.isEmpty() ) { @@ -281,4 +273,3 @@ void QgsOfflineEditingPluginGui::datatypeChanged( int index ) } mOfflineDataPathLineEdit->setText( QDir( mOfflineDataPath ).absoluteFilePath( mOfflineDbFile ) ); } - diff --git a/src/plugins/offline_editing/offline_editing_progress_dialog.h b/src/plugins/offline_editing/offline_editing_progress_dialog.h index 4953dd030e73..8430b4faaa31 100644 --- a/src/plugins/offline_editing/offline_editing_progress_dialog.h +++ b/src/plugins/offline_editing/offline_editing_progress_dialog.h @@ -39,4 +39,3 @@ class QgsOfflineEditingProgressDialog : public QDialog, private Ui::QgsOfflineEd }; #endif // QGS_OFFLINE_EDITING_PROGRESS_DIALOG_H - diff --git a/src/plugins/qgisplugin.h b/src/plugins/qgisplugin.h index 52b30698656c..eb67bfedb049 100644 --- a/src/plugins/qgisplugin.h +++ b/src/plugins/qgisplugin.h @@ -54,7 +54,6 @@ class QgisInterface; class QgisPlugin { public: - //! Interface to gui element collection object //virtual QgisPluginGui *gui()=0; //! Element types that can be added to the interface @@ -81,11 +80,7 @@ class QgisPlugin /** * Constructor for QgisPlugin */ - QgisPlugin( QString const &name = "", - QString const &description = "", - QString const &category = "", - QString const &version = "", - PluginType type = MapLayer ) + QgisPlugin( QString const &name = "", QString const &description = "", QString const &category = "", QString const &version = "", PluginType type = MapLayer ) : mName( name ) , mDescription( description ) , mCategory( category ) @@ -101,7 +96,7 @@ class QgisPlugin return mName; } - QString &name() + QString &name() { return mName; } @@ -125,7 +120,7 @@ class QgisPlugin } //! A brief description of the plugin - QString &description() + QString &description() { return mDescription; } @@ -137,7 +132,7 @@ class QgisPlugin } //! Plugin category - QString &category() + QString &category() { return mCategory; } @@ -150,7 +145,7 @@ class QgisPlugin //! Plugin type, either UI or map layer - QgisPlugin::PluginType &type() + QgisPlugin::PluginType &type() { return mType; } @@ -162,7 +157,6 @@ class QgisPlugin virtual void unload() = 0; private: - /// plug-in name QString mName; diff --git a/src/plugins/topology/checkDock.cpp b/src/plugins/topology/checkDock.cpp index b4cdd178fce0..f086f9881dfd 100644 --- a/src/plugins/topology/checkDock.cpp +++ b/src/plugins/topology/checkDock.cpp @@ -62,7 +62,7 @@ checkDock::checkDock( QgisInterface *qIface, QWidget *parent ) mConfigureDialog = new rulesDialog( mTest->testMap(), qIface, parent ); mTestTable = mConfigureDialog->rulesTable(); - QgsMapCanvas *canvas = qIface->mapCanvas();// mQgisApp->mapCanvas(); + QgsMapCanvas *canvas = qIface->mapCanvas(); // mQgisApp->mapCanvas(); mRBFeature1.reset( new QgsRubberBand( canvas ) ); mRBFeature2.reset( new QgsRubberBand( canvas ) ); mRBConflict.reset( new QgsRubberBand( canvas ) ); @@ -88,7 +88,7 @@ checkDock::checkDock( QgisInterface *qIface, QWidget *parent ) connect( mFixButton, &QAbstractButton::clicked, this, &checkDock::fix ); connect( mErrorTableView, &QAbstractItemView::clicked, this, &checkDock::errorListClicked ); - connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( const QString & ) >( &QgsProject::layerWillBeRemoved ), this, &checkDock::parseErrorListByLayer ); + connect( QgsProject::instance(), static_cast( &QgsProject::layerWillBeRemoved ), this, &checkDock::parseErrorListByLayer ); connect( this, &QDockWidget::visibilityChanged, this, &checkDock::updateRubberBands ); connect( qgsInterface, &QgisInterface::newProjectCreated, mConfigureDialog, &rulesDialog::clearRules ); @@ -355,17 +355,17 @@ void checkDock::runTests( ValidateType type ) const QString layer2Str = mTestTable->item( i, 4 )->text(); // test if layer1 is in the registry - if ( !( ( QgsVectorLayer * )QgsProject::instance()->mapLayers().contains( layer1Str ) ) ) + if ( !( ( QgsVectorLayer * ) QgsProject::instance()->mapLayers().contains( layer1Str ) ) ) { QgsMessageLog::logMessage( tr( "Layer %1 not found in registry." ).arg( layer1Str ), tr( "Topology plugin" ) ); return; } - QgsVectorLayer *layer1 = ( QgsVectorLayer * )QgsProject::instance()->mapLayer( layer1Str ); + QgsVectorLayer *layer1 = ( QgsVectorLayer * ) QgsProject::instance()->mapLayer( layer1Str ); QgsVectorLayer *layer2 = nullptr; - if ( ( QgsVectorLayer * )QgsProject::instance()->mapLayers().contains( layer2Str ) ) - layer2 = ( QgsVectorLayer * )QgsProject::instance()->mapLayer( layer2Str ); + if ( ( QgsVectorLayer * ) QgsProject::instance()->mapLayers().contains( layer2Str ) ) + layer2 = ( QgsVectorLayer * ) QgsProject::instance()->mapLayer( layer2Str ); QProgressDialog progress( testName, tr( "Abort" ), 0, layer1->featureCount(), this ); progress.setWindowModality( Qt::WindowModal ); diff --git a/src/plugins/topology/checkDock.h b/src/plugins/topology/checkDock.h index 8f88ea6f8a29..7c651105f3fe 100644 --- a/src/plugins/topology/checkDock.h +++ b/src/plugins/topology/checkDock.h @@ -42,7 +42,6 @@ class checkDock : public QgsDockWidget, private Ui::checkDock Q_OBJECT public: - /** * Constructor * \param qIface pointer to QgisInterface instance that is passed to the rulesDialog @@ -118,7 +117,6 @@ class checkDock : public QgsDockWidget, private Ui::checkDock void filterErrors(); private: - /** * Update check table model according to current errors * \since QGIS 3.38 diff --git a/src/plugins/topology/dockModel.cpp b/src/plugins/topology/dockModel.cpp index 8bcb87d4ff15..47eb61cfe910 100644 --- a/src/plugins/topology/dockModel.cpp +++ b/src/plugins/topology/dockModel.cpp @@ -25,7 +25,6 @@ DockModel::DockModel( QObject *parent ) { Q_UNUSED( parent ) mHeader << QObject::tr( "Error" ) << QObject::tr( "Layer" ) << QObject::tr( "Feature ID" ); - } void DockModel::setErrors( const ErrorList &errorList ) @@ -70,10 +69,10 @@ QVariant DockModel::data( const QModelIndex &index, int role ) const return QVariant(); const int row = index.row(); -// if(!row) -// { -// return QVariant(); -// } + // if(!row) + // { + // return QVariant(); + // } const int column = index.column(); if ( role == Qt::TextAlignmentRole ) diff --git a/src/plugins/topology/dockModel.h b/src/plugins/topology/dockModel.h index 9cc0d2b8a194..bb7a258dc4cd 100644 --- a/src/plugins/topology/dockModel.h +++ b/src/plugins/topology/dockModel.h @@ -30,7 +30,6 @@ class DockModel : public QAbstractTableModel Q_OBJECT public: - /** * Constructor * \param parent parent object @@ -101,7 +100,6 @@ class DockFilterModel : public QSortFilterProxyModel Q_OBJECT public: - /** * Constructor * \param parent parent object @@ -123,9 +121,7 @@ class DockFilterModel : public QSortFilterProxyModel void reload( const QModelIndex &index1, const QModelIndex &index2 ); private: - DockModel *mDockModel = nullptr; - }; #endif diff --git a/src/plugins/topology/rulesDialog.cpp b/src/plugins/topology/rulesDialog.cpp index 1d3396484497..896a5a122189 100644 --- a/src/plugins/topology/rulesDialog.cpp +++ b/src/plugins/topology/rulesDialog.cpp @@ -40,16 +40,14 @@ rulesDialog::rulesDialog( const QMap &testMap, QgisInterf mContextMenu = new QMenu( this ); QAction *selectAllAction = new QAction( tr( "Select All" ), this ); - connect( selectAllAction, &QAction::triggered, this, [ = ] - { + connect( selectAllAction, &QAction::triggered, this, [=] { mRulesTable->setRangeSelected( QTableWidgetSelectionRange( 0, 0, mRulesTable->rowCount() - 1, mRulesTable->columnCount() - 1 ), true ); } ); mContextMenu->addAction( selectAllAction ); mContextMenu->addSeparator(); QAction *enableAction = new QAction( tr( "Activate" ), this ); - connect( enableAction, &QAction::triggered, this, [ = ] - { + connect( enableAction, &QAction::triggered, this, [=] { const QModelIndexList selectedIndexes = mRulesTable->selectionModel()->selectedRows(); for ( const QModelIndex index : selectedIndexes ) { @@ -59,8 +57,7 @@ rulesDialog::rulesDialog( const QMap &testMap, QgisInterf } ); mContextMenu->addAction( enableAction ); QAction *disableAction = new QAction( tr( "Deactivate" ), this ); - connect( disableAction, &QAction::triggered, this, [ = ] - { + connect( disableAction, &QAction::triggered, this, [=] { const QModelIndexList selectedIndexes = mRulesTable->selectionModel()->selectedRows(); for ( const QModelIndex index : selectedIndexes ) { @@ -70,8 +67,7 @@ rulesDialog::rulesDialog( const QMap &testMap, QgisInterf } ); mContextMenu->addAction( disableAction ); QAction *toggleAction = new QAction( tr( "Toggle Activation" ), this ); - connect( toggleAction, &QAction::triggered, this, [ = ] - { + connect( toggleAction, &QAction::triggered, this, [=] { const QModelIndexList selectedIndexes = mRulesTable->selectionModel()->selectedRows(); for ( const QModelIndex index : selectedIndexes ) { @@ -86,8 +82,7 @@ rulesDialog::rulesDialog( const QMap &testMap, QgisInterf connect( deleteAction, &QAction::triggered, this, &rulesDialog::deleteTests ); mContextMenu->addAction( deleteAction ); - connect( mContextMenu, &QMenu::aboutToShow, this, [ = ] - { + connect( mContextMenu, &QMenu::aboutToShow, this, [=] { selectAllAction->setEnabled( mRulesTable->rowCount() > 0 ); const bool hasSelectedItems = !mRulesTable->selectionModel()->selectedIndexes().isEmpty(); enableAction->setEnabled( hasSelectedItems ); @@ -97,8 +92,7 @@ rulesDialog::rulesDialog( const QMap &testMap, QgisInterf } ); mRulesTable->setContextMenuPolicy( Qt::CustomContextMenu ); - connect( mRulesTable, &QTableWidget::customContextMenuRequested, this, [ = ] - { + connect( mRulesTable, &QTableWidget::customContextMenuRequested, this, [=] { mContextMenu->exec( QCursor::pos() ); } ); @@ -116,8 +110,7 @@ rulesDialog::rulesDialog( const QMap &testMap, QgisInterf connect( mAddTestButton, &QAbstractButton::clicked, this, &rulesDialog::addRule ); connect( mAddTestButton, &QAbstractButton::clicked, mRulesTable, &QTableView::resizeColumnsToContents ); - connect( mRulesTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, [ = ]() - { + connect( mRulesTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, [=]() { bool enabled = !mRulesTable->selectionModel()->selectedIndexes().isEmpty(); mDeleteTestButton->setEnabled( enabled ); } ); @@ -153,10 +146,10 @@ void rulesDialog::readTest( int index, QgsProject *project ) const QString layer2Id = project->readEntry( QStringLiteral( "Topol" ), "/layer2_" + postfix, QString() ); QgsVectorLayer *l1 = nullptr; - if ( !( QgsVectorLayer * )project->mapLayers().contains( layer1Id ) ) + if ( !( QgsVectorLayer * ) project->mapLayers().contains( layer1Id ) ) return; - l1 = ( QgsVectorLayer * )project->mapLayer( layer1Id ); + l1 = ( QgsVectorLayer * ) project->mapLayer( layer1Id ); if ( !l1 ) return; @@ -166,11 +159,11 @@ void rulesDialog::readTest( int index, QgsProject *project ) if ( mTestConfMap[testName].useSecondLayer ) { - if ( !( QgsVectorLayer * )project->mapLayers().contains( layer2Id ) ) + if ( !( QgsVectorLayer * ) project->mapLayers().contains( layer2Id ) ) return; else { - l2 = ( QgsVectorLayer * )project->mapLayer( layer2Id ); + l2 = ( QgsVectorLayer * ) project->mapLayer( layer2Id ); layer2Name = l2->name(); } } @@ -229,7 +222,7 @@ void rulesDialog::showControls( const QString &testName ) mLayer2Box->setVisible( true ); for ( int i = 0; i < layerList.count(); ++i ) { - QgsVectorLayer *v1 = ( QgsVectorLayer * )QgsProject::instance()->mapLayer( layerList[i] ); + QgsVectorLayer *v1 = ( QgsVectorLayer * ) QgsProject::instance()->mapLayer( layerList[i] ); if ( !v1 ) { @@ -272,9 +265,7 @@ void rulesDialog::addRule() for ( int i = 0; i < mRulesTable->rowCount(); ++i ) { - if ( mRulesTable->item( i, 0 )->text() == test && - mRulesTable->item( i, 1 )->text() == layer1 && - mRulesTable->item( i, 2 )->text() == layer2 ) + if ( mRulesTable->item( i, 0 )->text() == test && mRulesTable->item( i, 1 )->text() == layer1 && mRulesTable->item( i, 2 )->text() == layer2 ) { return; } @@ -358,7 +349,7 @@ void rulesDialog::updateRuleItems( const QString &layerName ) const QString layerId = mLayer1Box->currentData().toString(); - QgsVectorLayer *vlayer = ( QgsVectorLayer * )QgsProject::instance()->mapLayer( layerId ); + QgsVectorLayer *vlayer = ( QgsVectorLayer * ) QgsProject::instance()->mapLayer( layerId ); if ( !vlayer ) { @@ -373,7 +364,6 @@ void rulesDialog::updateRuleItems( const QString &layerName ) { mRuleBox->addItem( it.key() ); } - } } @@ -390,7 +380,7 @@ void rulesDialog::initGui() mLayer1Box->blockSignals( true ); for ( int i = 0; i < layerList.size(); ++i ) { - QgsVectorLayer *v1 = ( QgsVectorLayer * )QgsProject::instance()->mapLayer( layerList[i] ); + QgsVectorLayer *v1 = ( QgsVectorLayer * ) QgsProject::instance()->mapLayer( layerList[i] ); // add layer name to the layer combo boxes if ( v1->type() == Qgis::LayerType::Vector ) @@ -399,7 +389,6 @@ void rulesDialog::initGui() } } mLayer1Box->blockSignals( false ); - } void rulesDialog::clearRules() diff --git a/src/plugins/topology/rulesDialog.h b/src/plugins/topology/rulesDialog.h index 5c55693c9617..137a37be781c 100644 --- a/src/plugins/topology/rulesDialog.h +++ b/src/plugins/topology/rulesDialog.h @@ -106,9 +106,6 @@ class rulesDialog : public QDialog, private Ui::rulesDialog void updateRuleItems( const QString &layerName ); //! Open the associated help void showHelp(); - - - }; #endif diff --git a/src/plugins/topology/topol.h b/src/plugins/topology/topol.h index 143d99f008f7..72a7ad78cbcb 100644 --- a/src/plugins/topology/topol.h +++ b/src/plugins/topology/topol.h @@ -54,11 +54,10 @@ class checkDock; * \brief [name] plugin for QGIS * [description] */ -class Topol: public QObject, public QgisPlugin +class Topol : public QObject, public QgisPlugin { Q_OBJECT public: - ////////////////////////////////////////////////////////////////////// // // MANDATORY PLUGIN METHODS FOLLOW @@ -85,7 +84,6 @@ class Topol: public QObject, public QgisPlugin void help(); private: - //////////////////////////////////////////////////////////////////// // // MANDATORY PLUGIN PROPERTY DECLARATIONS ..... diff --git a/src/plugins/topology/topolError.cpp b/src/plugins/topology/topolError.cpp index b445b1aedd46..87d79146b21f 100644 --- a/src/plugins/topology/topolError.cpp +++ b/src/plugins/topology/topolError.cpp @@ -132,10 +132,11 @@ TopolError::TopolError( const QgsRectangle &boundingBox, const QgsGeometry &conf , mConflict( conflict ) , mFeaturePairs( featurePairs ) { - mFixMap[ QObject::tr( "Select automatic fix" )] = &TopolError::fixDummy; + mFixMap[QObject::tr( "Select automatic fix" )] = &TopolError::fixDummy; } -TopolErrorIntersection::TopolErrorIntersection( const QgsRectangle &boundingBox, const QgsGeometry &conflict, QList featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorIntersection::TopolErrorIntersection( const QgsRectangle &boundingBox, const QgsGeometry &conflict, QList featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "intersecting geometries" ); @@ -152,7 +153,8 @@ TopolErrorIntersection::TopolErrorIntersection( const QgsRectangle &boundingBox, } } -TopolErrorClose::TopolErrorClose( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorClose::TopolErrorClose( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "features too close" ); @@ -161,75 +163,88 @@ TopolErrorClose::TopolErrorClose( const QgsRectangle &boundingBox, const QgsGeom mFixMap[QObject::tr( "Snap to segment" )] = &TopolErrorClose::fixSnap; } -TopolErrorCovered::TopolErrorCovered( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorCovered::TopolErrorCovered( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "point not covered by segment" ); mFixMap[QObject::tr( "Delete point" )] = &TopolErrorCovered::fixDeleteFirst; } -TopolErrorShort::TopolErrorShort( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorShort::TopolErrorShort( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "segment too short" ); mFixMap[QObject::tr( "Delete feature" )] = &TopolErrorShort::fixDeleteFirst; } -TopolErrorValid::TopolErrorValid( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorValid::TopolErrorValid( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "invalid geometry" ); mFixMap[QObject::tr( "Delete feature" )] = &TopolErrorValid::fixDeleteFirst; } -TopolErrorDangle::TopolErrorDangle( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorDangle::TopolErrorDangle( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "dangling end" ); mFixMap[QObject::tr( "Delete feature" )] = &TopolErrorDangle::fixDeleteFirst; } -TopolErrorDuplicates::TopolErrorDuplicates( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorDuplicates::TopolErrorDuplicates( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "duplicate geometry" ); //mFixMap["Delete feature"] = &TopolErrorDuplicates::fixDeleteFirst; } -TopolErrorPseudos::TopolErrorPseudos( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorPseudos::TopolErrorPseudos( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "pseudo node" ); //mFixMap["Delete feature"] = &TopolErrorDuplicates::fixDeleteFirst; } -TopolErrorOverlaps::TopolErrorOverlaps( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorOverlaps::TopolErrorOverlaps( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "overlaps" ); //mFixMap["Delete feature"] = &TopolErrorDuplicates::fixDeleteFirst; } -TopolErrorGaps::TopolErrorGaps( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorGaps::TopolErrorGaps( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "gaps" ); //mFixMap["Delete feature"] = &TopolErrorDuplicates::fixDeleteFirst; } -TopolErrorPointNotCoveredByLineEnds::TopolErrorPointNotCoveredByLineEnds( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorPointNotCoveredByLineEnds::TopolErrorPointNotCoveredByLineEnds( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "point not covered" ); } -TopolErrorLineEndsNotCoveredByPoints::TopolErrorLineEndsNotCoveredByPoints( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorLineEndsNotCoveredByPoints::TopolErrorLineEndsNotCoveredByPoints( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "line ends not covered by point" ); } -TopolErrorPointNotInPolygon::TopolErrorPointNotInPolygon( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorPointNotInPolygon::TopolErrorPointNotInPolygon( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "point not in polygon" ); } -TopolErrorPolygonContainsPoint::TopolErrorPolygonContainsPoint( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErrorPolygonContainsPoint::TopolErrorPolygonContainsPoint( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "polygon does not contain point" ); } -TopolErroMultiPart::TopolErroMultiPart( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) : TopolError( boundingBox, conflict, featurePairs ) +TopolErroMultiPart::TopolErroMultiPart( const QgsRectangle &boundingBox, const QgsGeometry &conflict, const QList &featurePairs ) + : TopolError( boundingBox, conflict, featurePairs ) { mName = QObject::tr( "multipart feature" ); } diff --git a/src/plugins/topology/topolError.h b/src/plugins/topology/topolError.h index f1c2382d5d0f..401d5b7f8990 100644 --- a/src/plugins/topology/topolError.h +++ b/src/plugins/topology/topolError.h @@ -112,7 +112,6 @@ class TopolError bool fixUnion( const FeatureLayer &fl1, const FeatureLayer &fl2 ); public: - /** * Constructor * \param boundingBox bounding box of the two features diff --git a/src/plugins/topology/topolTest.cpp b/src/plugins/topology/topolTest.cpp index 59333cce0ccf..b651ea7a6f88 100644 --- a/src/plugins/topology/topolTest.cpp +++ b/src/plugins/topology/topolTest.cpp @@ -47,77 +47,32 @@ topolTest::topolTest( QgisInterface *qgsIface ) mTestCanceled = false; // one layer tests - mTopologyRuleMap.insert( tr( "must not have invalid geometries" ), - TopologyRule( &topolTest::checkValid, - false, false, - QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ) ); - - mTopologyRuleMap.insert( tr( "must not have dangles" ), - TopologyRule( &topolTest::checkDanglingLines, - false, false, - QList() << Qgis::GeometryType::Line ) ); - - mTopologyRuleMap.insert( tr( "must not have duplicates" ), - TopologyRule( &topolTest::checkDuplicates, - false, true, - QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ) ); - - mTopologyRuleMap.insert( tr( "must not have pseudos" ), - TopologyRule( &topolTest::checkPseudos, - false, false, - QList() << Qgis::GeometryType::Line ) ); - - mTopologyRuleMap.insert( tr( "must not overlap" ), - TopologyRule( &topolTest::checkOverlaps, - false, true, - QList() << Qgis::GeometryType::Polygon ) ); - - mTopologyRuleMap.insert( tr( "must not have gaps" ), - TopologyRule( &topolTest::checkGaps, - false, false, - QList() << Qgis::GeometryType::Polygon ) ); - - mTopologyRuleMap.insert( tr( "must not have multi-part geometries" ), - TopologyRule( &topolTest::checkMultipart, - false, false, - QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ) ); + mTopologyRuleMap.insert( tr( "must not have invalid geometries" ), TopologyRule( &topolTest::checkValid, false, false, QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ) ); + + mTopologyRuleMap.insert( tr( "must not have dangles" ), TopologyRule( &topolTest::checkDanglingLines, false, false, QList() << Qgis::GeometryType::Line ) ); + + mTopologyRuleMap.insert( tr( "must not have duplicates" ), TopologyRule( &topolTest::checkDuplicates, false, true, QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ) ); + + mTopologyRuleMap.insert( tr( "must not have pseudos" ), TopologyRule( &topolTest::checkPseudos, false, false, QList() << Qgis::GeometryType::Line ) ); + + mTopologyRuleMap.insert( tr( "must not overlap" ), TopologyRule( &topolTest::checkOverlaps, false, true, QList() << Qgis::GeometryType::Polygon ) ); + + mTopologyRuleMap.insert( tr( "must not have gaps" ), TopologyRule( &topolTest::checkGaps, false, false, QList() << Qgis::GeometryType::Polygon ) ); + + mTopologyRuleMap.insert( tr( "must not have multi-part geometries" ), TopologyRule( &topolTest::checkMultipart, false, false, QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Polygon << Qgis::GeometryType::Line ) ); // two layer tests - mTopologyRuleMap.insert( tr( "must not overlap with" ), - TopologyRule( &topolTest::checkOverlapWithLayer, - true, true, - QList() << Qgis::GeometryType::Polygon, - QList() << Qgis::GeometryType::Polygon ) ); - - mTopologyRuleMap.insert( tr( "must be covered by" ), - TopologyRule( &topolTest::checkPointCoveredBySegment, - true, true, - QList() << Qgis::GeometryType::Point, - QList() << Qgis::GeometryType::Line << Qgis::GeometryType::Polygon ) ); - - mTopologyRuleMap.insert( tr( "must be covered by endpoints of" ), - TopologyRule( &topolTest::checkPointCoveredByLineEnds, - true, true, - QList() << Qgis::GeometryType::Point, - QList() << Qgis::GeometryType::Line ) ); - - mTopologyRuleMap.insert( tr( "end points must be covered by" ), - TopologyRule( &topolTest::checkyLineEndsCoveredByPoints, - true, true, - QList() << Qgis::GeometryType::Line, - QList() << Qgis::GeometryType::Point ) ); - - mTopologyRuleMap.insert( tr( "must be inside" ), - TopologyRule( &topolTest::checkPointInPolygon, - true, true, - QList() << Qgis::GeometryType::Point, - QList() << Qgis::GeometryType::Polygon ) ); - - mTopologyRuleMap.insert( tr( "must contain" ), - TopologyRule( &topolTest::checkPolygonContainsPoint, - true, true, - QList() << Qgis::GeometryType::Polygon, - QList() << Qgis::GeometryType::Point ) ); + mTopologyRuleMap.insert( tr( "must not overlap with" ), TopologyRule( &topolTest::checkOverlapWithLayer, true, true, QList() << Qgis::GeometryType::Polygon, QList() << Qgis::GeometryType::Polygon ) ); + + mTopologyRuleMap.insert( tr( "must be covered by" ), TopologyRule( &topolTest::checkPointCoveredBySegment, true, true, QList() << Qgis::GeometryType::Point, QList() << Qgis::GeometryType::Line << Qgis::GeometryType::Polygon ) ); + + mTopologyRuleMap.insert( tr( "must be covered by endpoints of" ), TopologyRule( &topolTest::checkPointCoveredByLineEnds, true, true, QList() << Qgis::GeometryType::Point, QList() << Qgis::GeometryType::Line ) ); + + mTopologyRuleMap.insert( tr( "end points must be covered by" ), TopologyRule( &topolTest::checkyLineEndsCoveredByPoints, true, true, QList() << Qgis::GeometryType::Line, QList() << Qgis::GeometryType::Point ) ); + + mTopologyRuleMap.insert( tr( "must be inside" ), TopologyRule( &topolTest::checkPointInPolygon, true, true, QList() << Qgis::GeometryType::Point, QList() << Qgis::GeometryType::Polygon ) ); + + mTopologyRuleMap.insert( tr( "must contain" ), TopologyRule( &topolTest::checkPolygonContainsPoint, true, true, QList() << Qgis::GeometryType::Polygon, QList() << Qgis::GeometryType::Point ) ); } topolTest::~topolTest() @@ -192,7 +147,6 @@ ErrorList topolTest::checkDanglingLines( QgsVectorLayer *layer1, QgsVectorLayer endVerticesMap.insert( std::pair( startPoint, it->feature.id() ) ); endVerticesMap.insert( std::pair( endPoint, it->feature.id() ) ); - } } else @@ -218,7 +172,6 @@ ErrorList topolTest::checkDanglingLines( QgsVectorLayer *layer1, QgsVectorLayer //QgsGeometry* extentPoly = if ( repetitions == 1 ) { - const QgsGeometry conflictGeom = QgsGeometry::fromPointXY( p ); if ( isExtent ) { @@ -242,7 +195,6 @@ ErrorList topolTest::checkDanglingLines( QgsVectorLayer *layer1, QgsVectorLayer TopolErrorDangle *err = new TopolErrorDangle( bBox, conflictGeom, errorFtrLayers ); errorList << err; - } } return errorList; @@ -311,8 +263,6 @@ ErrorList topolTest::checkDuplicates( QgsVectorLayer *layer1, QgsVectorLayer *la if ( duplicate ) { - - QList fls; fls << *it << *it; QgsGeometry conflict( g1 ); @@ -333,9 +283,7 @@ ErrorList topolTest::checkDuplicates( QgsVectorLayer *layer1, QgsVectorLayer *la errorList << err; } - } - } return errorList; } @@ -389,7 +337,7 @@ ErrorList topolTest::checkOverlaps( QgsVectorLayer *layer1, QgsVectorLayer *laye continue; } - std::unique_ptr< QgsGeometryEngine > engine1( QgsGeometry::createGeometryEngine( g1.constGet() ) ); + std::unique_ptr engine1( QgsGeometry::createGeometryEngine( g1.constGet() ) ); engine1->prepareGeometry(); const QgsRectangle bb = g1.boundingBox(); @@ -456,7 +404,6 @@ ErrorList topolTest::checkOverlaps( QgsVectorLayer *layer1, QgsVectorLayer *laye errorList << err; } - } } @@ -530,7 +477,6 @@ ErrorList topolTest::checkGaps( QgsVectorLayer *layer1, QgsVectorLayer *layer2, geomList.push_back( QgsGeos::asGeos( polyGeom ).release() ); } - } else { @@ -538,7 +484,7 @@ ErrorList topolTest::checkGaps( QgsVectorLayer *layer1, QgsVectorLayer *layer2, } } - GEOSGeometry **geomArray = new GEOSGeometry*[geomList.size()]; + GEOSGeometry **geomArray = new GEOSGeometry *[geomList.size()]; for ( int i = 0; i < geomList.size(); ++i ) { //qDebug() << "filling geometry array-" << i; @@ -550,7 +496,7 @@ ErrorList topolTest::checkGaps( QgsVectorLayer *layer1, QgsVectorLayer *layer2, if ( geomList.isEmpty() ) { //qDebug() << "geometry list is empty!"; - delete [] geomArray; + delete[] geomArray; return errorList; } @@ -585,7 +531,7 @@ ErrorList topolTest::checkGaps( QgsVectorLayer *layer1, QgsVectorLayer *layer2, const QgsGeometry canvasExtentPoly = QgsGeometry::fromRect( qgsInterface->mapCanvas()->extent() ); - for ( int i = 1; i < geomColl.count() ; ++i ) + for ( int i = 1; i < geomColl.count(); ++i ) { QgsGeometry conflictGeom = geomColl[i]; if ( isExtent ) @@ -666,7 +612,6 @@ ErrorList topolTest::checkPseudos( QgsVectorLayer *layer1, QgsVectorLayer *layer endVerticesMap.insert( std::pair( startPoint, it->feature.id() ) ); endVerticesMap.insert( std::pair( endPoint, it->feature.id() ) ); - } } else @@ -716,7 +661,6 @@ ErrorList topolTest::checkPseudos( QgsVectorLayer *layer1, QgsVectorLayer *layer TopolErrorPseudos *err = new TopolErrorPseudos( bBox, conflictGeom, errorFtrLayers ); errorList << err; - } } return errorList; @@ -928,7 +872,6 @@ ErrorList topolTest::checkOverlapWithLayer( QgsVectorLayer *layer1, QgsVectorLay } - ErrorList topolTest::checkPointCoveredByLineEnds( QgsVectorLayer *layer1, QgsVectorLayer *layer2, bool isExtent ) { int i = 0; @@ -1072,7 +1015,6 @@ ErrorList topolTest::checkyLineEndsCoveredByPoints( QgsVectorLayer *layer1, QgsV touched = true; break; } - } if ( !touched ) @@ -1261,7 +1203,7 @@ ErrorList topolTest::checkMultipart( QgsVectorLayer *layer1, QgsVectorLayer *lay continue; } - if ( g.isMultipart() && qgsgeometry_cast< const QgsGeometryCollection *>( g.constGet() )->numGeometries() > 1 ) + if ( g.isMultipart() && qgsgeometry_cast( g.constGet() )->numGeometries() > 1 ) { const QgsRectangle r = g.boundingBox(); QList fls; @@ -1283,9 +1225,9 @@ void topolTest::fillFeatureMap( QgsVectorLayer *layer, const QgsRectangle &exten else { fit = layer->getFeatures( QgsFeatureRequest() - .setFilterRect( extent ) - .setFlags( Qgis::FeatureRequestFlag::ExactIntersect ) - .setNoAttributes() ); + .setFilterRect( extent ) + .setFlags( Qgis::FeatureRequestFlag::ExactIntersect ) + .setNoAttributes() ); } QgsFeature f; @@ -1309,9 +1251,9 @@ void topolTest::fillFeatureList( QgsVectorLayer *layer, const QgsRectangle &exte else { fit = layer->getFeatures( QgsFeatureRequest() - .setFilterRect( extent ) - .setFlags( Qgis::FeatureRequestFlag::ExactIntersect ) - .setNoAttributes() ); + .setFilterRect( extent ) + .setFlags( Qgis::FeatureRequestFlag::ExactIntersect ) + .setNoAttributes() ); } QgsFeature f; @@ -1323,7 +1265,6 @@ void topolTest::fillFeatureList( QgsVectorLayer *layer, const QgsRectangle &exte mFeatureList1 << FeatureLayer( layer, f ); } } - } QgsSpatialIndex *topolTest::createIndex( QgsVectorLayer *layer, const QgsRectangle &extent ) @@ -1338,9 +1279,9 @@ QgsSpatialIndex *topolTest::createIndex( QgsVectorLayer *layer, const QgsRectang else { fit = layer->getFeatures( QgsFeatureRequest() - .setFilterRect( extent ) - .setFlags( Qgis::FeatureRequestFlag::ExactIntersect ) - .setNoAttributes() ); + .setFilterRect( extent ) + .setFlags( Qgis::FeatureRequestFlag::ExactIntersect ) + .setNoAttributes() ); } @@ -1434,7 +1375,6 @@ ErrorList topolTest::runTest( const QString &testName, QgsVectorLayer *layer1, Q { if ( !mLayerIndexes.contains( layer1->id() ) ) { - mLayerIndexes[layer1->id()] = createIndex( layer1, QgsRectangle() ); } } @@ -1443,7 +1383,6 @@ ErrorList topolTest::runTest( const QString &testName, QgsVectorLayer *layer1, Q fillFeatureList( layer1, QgsRectangle() ); } } - } //call test routine diff --git a/src/plugins/topology/topolTest.h b/src/plugins/topology/topolTest.h index df3efa7aa82b..c8c9a4605417 100644 --- a/src/plugins/topology/topolTest.h +++ b/src/plugins/topology/topolTest.h @@ -29,9 +29,14 @@ class topolTest; class QgisInterface; class WKTReader; -enum ValidateType { ValidateAll, ValidateExtent, ValidateSelected }; +enum ValidateType +{ + ValidateAll, + ValidateExtent, + ValidateSelected +}; -typedef ErrorList( topolTest::*testFunction )( QgsVectorLayer *, QgsVectorLayer *, bool ); +typedef ErrorList ( topolTest::*testFunction )( QgsVectorLayer *, QgsVectorLayer *, bool ); class TopologyRule { @@ -57,12 +62,7 @@ class TopologyRule * Constructor * initializes the test to use both layers */ - explicit TopologyRule( testFunction f0 = nullptr, - bool useSecondLayer0 = true, - bool useSpatialIndex0 = false, - const QList &layer1SupportedTypes0 = QList(), - const QList &layer2SupportedTypes0 = QList() - ) + explicit TopologyRule( testFunction f0 = nullptr, bool useSecondLayer0 = true, bool useSpatialIndex0 = false, const QList &layer1SupportedTypes0 = QList(), const QList &layer2SupportedTypes0 = QList() ) : f( f0 ) , useSecondLayer( useSecondLayer0 ) , useSpatialIndex( useSpatialIndex0 ) @@ -77,7 +77,7 @@ class TopologyRule class PointComparer { public: - bool operator()( const QgsPointXY &p1, const QgsPointXY &p2 )const + bool operator()( const QgsPointXY &p1, const QgsPointXY &p2 ) const { if ( p1.x() < p2.x() ) { @@ -94,7 +94,7 @@ class PointComparer }; -class topolTest: public QObject +class topolTest : public QObject { Q_OBJECT diff --git a/src/process/main.cpp b/src/process/main.cpp index d4023c236fa5..5bed4c95f8c0 100644 --- a/src/process/main.cpp +++ b/src/process/main.cpp @@ -49,9 +49,8 @@ typedef SInt32 SRefCon; #undef QgsDebugError #undef QgsDebugMsgLevel #define QgsDebugCall -#define QgsDebugError(str) -#define QgsDebugMsgLevel(str, level) - +#define QgsDebugError( str ) +#define QgsDebugMsgLevel( str, level ) ///////////////////////////////////////////////////////////////// @@ -69,13 +68,13 @@ static QStringList sFileList; int main( int argc, char *argv[] ) { -#ifdef Q_OS_WIN // Windows +#ifdef Q_OS_WIN // Windows #ifdef _MSC_VER _set_fmode( _O_BINARY ); -#else //MinGW +#else //MinGW _fmode = _O_BINARY; -#endif // _MSC_VER -#endif // Q_OS_WIN +#endif // _MSC_VER +#endif // Q_OS_WIN // a shortcut -- let's see if we are being called without any arguments, or just the usage/version argument. // If so, let's skip the startup cost of a QCoreApplication/QgsApplication @@ -106,7 +105,7 @@ int main( int argc, char *argv[] ) if ( argc == 1 || hasHelpArgument ) { - QgsProcessingExec::showUsage( QString( argv[ 0 ] ) ); + QgsProcessingExec::showUsage( QString( argv[0] ) ); return 0; } else if ( hasVersionArgument ) @@ -184,8 +183,7 @@ int main( int argc, char *argv[] ) QgsProcessingExec exec; int res = 0; - QTimer::singleShot( 0, &app, [&exec, args, logLevel, flags, &res] - { + QTimer::singleShot( 0, &app, [&exec, args, logLevel, flags, &res] { res = exec.run( args, logLevel, flags ); QgsApplication::exitQgis(); QCoreApplication::exit( res ); diff --git a/src/process/qgsprocess.cpp b/src/process/qgsprocess.cpp index 512c3abbcb19..4f599f3f151c 100644 --- a/src/process/qgsprocess.cpp +++ b/src/process/qgsprocess.cpp @@ -25,7 +25,7 @@ #include "qgs3dalgorithms.h" #endif #ifdef HAVE_PDAL_QGIS -#if PDAL_VERSION_MAJOR_INT > 2 || (PDAL_VERSION_MAJOR_INT == 2 && PDAL_VERSION_MINOR_INT >= 5) +#if PDAL_VERSION_MAJOR_INT > 2 || ( PDAL_VERSION_MAJOR_INT == 2 && PDAL_VERSION_MINOR_INT >= 5 ) #include "qgspdalalgorithms.h" #endif #endif @@ -39,7 +39,7 @@ #include "qgsjsonutils.h" #include "qgsmessagelog.h" -#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) +#if defined( Q_OS_UNIX ) && !defined( Q_OS_ANDROID ) #include "sigwatch.h" #endif @@ -78,7 +78,7 @@ void ConsoleFeedback::reportError( const QString &error, bool fatalError ) { if ( !mJsonLog.contains( QStringLiteral( "errors" ) ) ) mJsonLog.insert( QStringLiteral( "errors" ), QStringList() ); - mJsonLog[ QStringLiteral( "errors" )] = mJsonLog.value( QStringLiteral( "errors" ) ).toStringList() << error; + mJsonLog[QStringLiteral( "errors" )] = mJsonLog.value( QStringLiteral( "errors" ) ).toStringList() << error; } QgsProcessingFeedback::reportError( error, fatalError ); } @@ -91,7 +91,7 @@ void ConsoleFeedback::pushWarning( const QString &warning ) { if ( !mJsonLog.contains( QStringLiteral( "warning" ) ) ) mJsonLog.insert( QStringLiteral( "warning" ), QStringList() ); - mJsonLog[ QStringLiteral( "warning" )] = mJsonLog.value( QStringLiteral( "warning" ) ).toStringList() << warning; + mJsonLog[QStringLiteral( "warning" )] = mJsonLog.value( QStringLiteral( "warning" ) ).toStringList() << warning; } QgsProcessingFeedback::pushWarning( warning ); } @@ -104,7 +104,7 @@ void ConsoleFeedback::pushInfo( const QString &info ) { if ( !mJsonLog.contains( QStringLiteral( "info" ) ) ) mJsonLog.insert( QStringLiteral( "info" ), QStringList() ); - mJsonLog[ QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; + mJsonLog[QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; } QgsProcessingFeedback::pushInfo( info ); } @@ -117,7 +117,7 @@ void ConsoleFeedback::pushCommandInfo( const QString &info ) { if ( !mJsonLog.contains( QStringLiteral( "info" ) ) ) mJsonLog.insert( QStringLiteral( "info" ), QStringList() ); - mJsonLog[ QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; + mJsonLog[QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; } QgsProcessingFeedback::pushCommandInfo( info ); } @@ -130,7 +130,7 @@ void ConsoleFeedback::pushDebugInfo( const QString &info ) { if ( !mJsonLog.contains( QStringLiteral( "info" ) ) ) mJsonLog.insert( QStringLiteral( "info" ), QStringList() ); - mJsonLog[ QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; + mJsonLog[QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; } QgsProcessingFeedback::pushDebugInfo( info ); } @@ -143,7 +143,7 @@ void ConsoleFeedback::pushConsoleInfo( const QString &info ) { if ( !mJsonLog.contains( QStringLiteral( "info" ) ) ) mJsonLog.insert( QStringLiteral( "info" ), QStringList() ); - mJsonLog[ QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; + mJsonLog[QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << info; } QgsProcessingFeedback::pushConsoleInfo( info ); } @@ -156,7 +156,7 @@ void ConsoleFeedback::pushFormattedMessage( const QString &html, const QString & { if ( !mJsonLog.contains( QStringLiteral( "info" ) ) ) mJsonLog.insert( QStringLiteral( "info" ), QStringList() ); - mJsonLog[ QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << text; + mJsonLog[QStringLiteral( "info" )] = mJsonLog.value( QStringLiteral( "info" ) ).toStringList() << text; } QgsProcessingFeedback::pushFormattedMessage( html, text ); } @@ -198,10 +198,10 @@ void ConsoleFeedback::showTerminalProgress( double progress ) #ifdef WITH_BINDINGS //! load Python support if possible -std::unique_ptr< QgsPythonUtils > QgsProcessingExec::loadPythonSupport() +std::unique_ptr QgsProcessingExec::loadPythonSupport() { QString pythonlibName( QStringLiteral( "qgispython" ) ); -#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) +#if defined( Q_OS_UNIX ) && !defined( Q_OS_ANDROID ) pythonlibName.prepend( QgsApplication::libraryPath() ); #endif #ifdef __MINGW32__ @@ -223,8 +223,8 @@ std::unique_ptr< QgsPythonUtils > QgsProcessingExec::loadPythonSupport() } } - typedef QgsPythonUtils*( *inst )(); - inst pythonlib_inst = reinterpret_cast< inst >( cast_to_fptr( pythonlib.resolve( "instance" ) ) ); + typedef QgsPythonUtils *( *inst )(); + inst pythonlib_inst = reinterpret_cast( cast_to_fptr( pythonlib.resolve( "instance" ) ) ); if ( !pythonlib_inst ) { //using stderr on purpose because we want end users to see this [TS] @@ -232,7 +232,7 @@ std::unique_ptr< QgsPythonUtils > QgsProcessingExec::loadPythonSupport() return nullptr; } - std::unique_ptr< QgsPythonUtils > pythonUtils( pythonlib_inst() ); + std::unique_ptr pythonUtils( pythonlib_inst() ); if ( pythonUtils ) { pythonUtils->initPython( nullptr, false ); @@ -244,16 +244,13 @@ std::unique_ptr< QgsPythonUtils > QgsProcessingExec::loadPythonSupport() QgsProcessingExec::QgsProcessingExec() { - } int QgsProcessingExec::run( const QStringList &args, Qgis::ProcessingLogLevel logLevel, Flags flags ) { mFlags = flags; - QObject::connect( QgsApplication::messageLog(), static_cast < void ( QgsMessageLog::* )( const QString &message, const QString &tag, Qgis::MessageLevel level ) >( &QgsMessageLog::messageReceived ), QgsApplication::instance(), - [ = ]( const QString & message, const QString &, Qgis::MessageLevel level ) - { + QObject::connect( QgsApplication::messageLog(), static_cast( &QgsMessageLog::messageReceived ), QgsApplication::instance(), [=]( const QString &message, const QString &, Qgis::MessageLevel level ) { if ( level == Qgis::MessageLevel::Critical ) { if ( !message.contains( QLatin1String( "DeprecationWarning:" ) ) ) @@ -461,7 +458,7 @@ int QgsProcessingExec::run( const QStringList &args, Qgis::ProcessingLogLevel lo { // upgrade previous value to list QStringList listValue = QStringList() << params.value( name ).toString() - << value; + << value; params.insert( name, listValue ); } } @@ -501,7 +498,7 @@ int QgsProcessingExec::run( const QStringList &args, Qgis::ProcessingLogLevel lo { // upgrade previous value to list QStringList listValue = QStringList() << params.value( name ).toString() - << value; + << value; params.insert( name, listValue ); } } @@ -528,7 +525,7 @@ void QgsProcessingExec::showUsage( const QString &appName ) msg << "QGIS Processing Executor - " << VERSION << " '" << RELEASE_NAME << "' (" << Qgis::version() << ")\n" - << "Usage: " << appName << " [--help] [--version] [--json] [--verbose] [--no-python] [--skip-loading-plugins] [command] [algorithm id, path to model file, or path to Python script] [parameters]\n" + << "Usage: " << appName << " [--help] [--version] [--json] [--verbose] [--no-python] [--skip-loading-plugins] [command] [algorithm id, path to model file, or path to Python script] [parameters]\n" << "\nOptions:\n" << "\t--help or -h\t\tOutput the help\n" << "\t--version or -v\t\tOutput all versions related to QGIS Process\n" @@ -729,9 +726,9 @@ int QgsProcessingExec::enablePlugin( const QString &name, bool enabled ) if ( enabled && !mPythonUtils->pluginHasProcessingProvider( name ) ) std::cout << "WARNING: Plugin does not report having a Processing provider, but enabling anyway.\n\n" - "Either the plugin does not support Processing, or the plugin's metadata is incorrect.\n" - "See https://docs.qgis.org/latest/en/docs/pyqgis_developer_cookbook/processing.html#updating-a-plugin for\n" - "instructions on how to fix the plugin metadata to remove this warning.\n\n"; + "Either the plugin does not support Processing, or the plugin's metadata is incorrect.\n" + "See https://docs.qgis.org/latest/en/docs/pyqgis_developer_cookbook/processing.html#updating-a-plugin for\n" + "instructions on how to fix the plugin metadata to remove this warning.\n\n"; if ( enabled && mPythonUtils->isPluginEnabled( name ) ) { @@ -787,11 +784,11 @@ int QgsProcessingExec::showAlgorithmHelp( const QString &inputId ) { QString id = inputId; - std::unique_ptr< QgsProcessingModelAlgorithm > model; + std::unique_ptr model; const QgsProcessingAlgorithm *alg = nullptr; if ( QFile::exists( id ) && QFileInfo( id ).suffix() == QLatin1String( "model3" ) ) { - model = std::make_unique< QgsProcessingModelAlgorithm >(); + model = std::make_unique(); if ( !model->fromFile( id ) ) { std::cerr << QStringLiteral( "File %1 is not a valid Processing model!\n" ).arg( id ).toLocal8Bit().constData(); @@ -817,7 +814,7 @@ int QgsProcessingExec::showAlgorithmHelp( const QString &inputId ) if ( !alg ) { alg = QgsApplication::processingRegistry()->algorithmById( id ); - if ( ! alg ) + if ( !alg ) { std::cerr << QStringLiteral( "Algorithm %1 not found!\n" ).arg( id ).toLocal8Bit().constData(); return 1; @@ -839,14 +836,13 @@ int QgsProcessingExec::showAlgorithmHelp( const QString &inputId ) std::cout << "Description\n"; std::cout << "----------------\n"; - if ( const QgsProcessingModelAlgorithm *model = dynamic_cast< const QgsProcessingModelAlgorithm * >( alg ) ) + if ( const QgsProcessingModelAlgorithm *model = dynamic_cast( alg ) ) { // show finer help content for models const QVariantMap help = model->helpContent(); std::cout << help.value( QStringLiteral( "ALG_DESC" ) ).toString().toLocal8Bit().constData() << '\n'; - if ( !help.value( QStringLiteral( "ALG_CREATOR" ) ).toString().isEmpty() || - !help.value( QStringLiteral( "ALG_VERSION" ) ).toString().isEmpty() ) + if ( !help.value( QStringLiteral( "ALG_CREATOR" ) ).toString().isEmpty() || !help.value( QStringLiteral( "ALG_VERSION" ) ).toString().isEmpty() ) std::cout << '\n'; if ( !help.value( QStringLiteral( "ALG_CREATOR" ) ).toString().isEmpty() ) @@ -877,7 +873,7 @@ int QgsProcessingExec::showAlgorithmHelp( const QString &inputId ) std::cout << "----------------\n\n"; QStringList flags; - for ( Qgis::ProcessingAlgorithmDocumentationFlag flag : qgsEnumList< Qgis::ProcessingAlgorithmDocumentationFlag>() ) + for ( Qgis::ProcessingAlgorithmDocumentationFlag flag : qgsEnumList() ) { if ( alg->documentationFlags() & flag ) { @@ -959,7 +955,7 @@ int QgsProcessingExec::showAlgorithmHelp( const QString &inputId ) parameterJson.insert( QStringLiteral( "raw_definition" ), p->toVariantMap() ); } - if ( ! p->help().isEmpty() ) + if ( !p->help().isEmpty() ) { if ( !( mFlags & Flag::UseJson ) ) std::cout << QStringLiteral( "\t%1\n" ).arg( p->help() ).toLocal8Bit().constData(); @@ -971,7 +967,7 @@ int QgsProcessingExec::showAlgorithmHelp( const QString &inputId ) if ( p->type() == QgsProcessingParameterEnum::typeName() ) { - const QgsProcessingParameterEnum *enumParam = static_cast< const QgsProcessingParameterEnum * >( p ); + const QgsProcessingParameterEnum *enumParam = static_cast( p ); QStringList options; QVariantMap jsonOptions; for ( int i = 0; i < enumParam->options().count(); ++i ) @@ -1064,11 +1060,11 @@ int QgsProcessingExec::execute( const QString &inputId, const QVariantMap &input QString id = inputId; - std::unique_ptr< QgsProcessingModelAlgorithm > model; + std::unique_ptr model; const QgsProcessingAlgorithm *alg = nullptr; if ( QFile::exists( id ) && QFileInfo( id ).suffix() == QLatin1String( "model3" ) ) { - model = std::make_unique< QgsProcessingModelAlgorithm >(); + model = std::make_unique(); if ( !model->fromFile( id ) ) { std::cerr << QStringLiteral( "File %1 is not a valid Processing model!\n" ).arg( id ).toLocal8Bit().constData(); @@ -1094,7 +1090,7 @@ int QgsProcessingExec::execute( const QString &inputId, const QVariantMap &input if ( !alg ) { alg = QgsApplication::processingRegistry()->algorithmById( id ); - if ( ! alg ) + if ( !alg ) { std::cerr << QStringLiteral( "Algorithm %1 not found!\n" ).arg( id ).toLocal8Bit().constData(); return 1; @@ -1205,7 +1201,7 @@ int QgsProcessingExec::execute( const QString &inputId, const QVariantMap &input context.setLogLevel( logLevel ); const QgsProcessingParameterDefinitions defs = alg->parameterDefinitions(); - QList< const QgsProcessingParameterDefinition * > missingParams; + QList missingParams; for ( const QgsProcessingParameterDefinition *p : defs ) { if ( !p->checkValueIsAcceptable( params.value( p->name() ), &context ) ) @@ -1238,12 +1234,11 @@ int QgsProcessingExec::execute( const QString &inputId, const QVariantMap &input ConsoleFeedback feedback( mFlags & Flag::UseJson ); -#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) +#if defined( Q_OS_UNIX ) && !defined( Q_OS_ANDROID ) UnixSignalWatcher sigwatch; sigwatch.watchForSignal( SIGINT ); - QObject::connect( &sigwatch, &UnixSignalWatcher::unixSignal, &feedback, [&feedback ]( int signal ) - { + QObject::connect( &sigwatch, &UnixSignalWatcher::unixSignal, &feedback, [&feedback]( int signal ) { switch ( signal ) { case SIGINT: @@ -1343,7 +1338,7 @@ void QgsProcessingExec::addAlgorithmInformation( QVariantMap &algorithmJson, con if ( algorithm->documentationFlags() != Qgis::ProcessingAlgorithmDocumentationFlags() ) { QStringList documentationFlags; - for ( Qgis::ProcessingAlgorithmDocumentationFlag flag : qgsEnumList< Qgis::ProcessingAlgorithmDocumentationFlag>() ) + for ( Qgis::ProcessingAlgorithmDocumentationFlag flag : qgsEnumList() ) { if ( algorithm->documentationFlags() & flag ) { diff --git a/src/process/qgsprocess.h b/src/process/qgsprocess.h index f7e192987ba9..47bd09797f63 100644 --- a/src/process/qgsprocess.h +++ b/src/process/qgsprocess.h @@ -35,7 +35,6 @@ class ConsoleFeedback : public QgsProcessingFeedback Q_OBJECT public: - /** * Constructor for QgsProcessingAlgorithmDialogFeedback. */ @@ -67,9 +66,7 @@ class ConsoleFeedback : public QgsProcessingFeedback class QgsProcessingExec { - public: - enum class Flag { UseJson = 1 << 0, @@ -84,19 +81,12 @@ class QgsProcessingExec static void showVersionInformation(); private: - void loadPlugins(); void listAlgorithms(); void listPlugins( bool useJson, bool showLoaded ); int enablePlugin( const QString &name, bool enabled ); int showAlgorithmHelp( const QString &id ); - int execute( const QString &algId, - const QVariantMap ¶meters, - const QString &ellipsoid, - Qgis::DistanceUnit distanceUnit, - Qgis::AreaUnit areaUnit, - Qgis::ProcessingLogLevel logLevel, - const QString &projectPath = QString() ); + int execute( const QString &algId, const QVariantMap ¶meters, const QString &ellipsoid, Qgis::DistanceUnit distanceUnit, Qgis::AreaUnit areaUnit, Qgis::ProcessingLogLevel logLevel, const QString &projectPath = QString() ); void addVersionInformation( QVariantMap &json ); void addAlgorithmInformation( QVariantMap &json, const QgsProcessingAlgorithm *algorithm ); @@ -104,7 +94,7 @@ class QgsProcessingExec Flags mFlags; #ifdef WITH_BINDINGS - std::unique_ptr< QgsPythonUtils > mPythonUtils; + std::unique_ptr mPythonUtils; std::unique_ptr loadPythonSupport(); #endif }; @@ -112,4 +102,3 @@ class QgsProcessingExec Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingExec::Flags ); #endif // QGSPROCESS_H - diff --git a/src/providers/arcgisrest/qgsafsfeatureiterator.h b/src/providers/arcgisrest/qgsafsfeatureiterator.h index 653b4ff69290..a750ad755f0c 100644 --- a/src/providers/arcgisrest/qgsafsfeatureiterator.h +++ b/src/providers/arcgisrest/qgsafsfeatureiterator.h @@ -26,7 +26,6 @@ typedef QMap QgsFeatureMap; class QgsAfsFeatureSource : public QgsAbstractFeatureSource { - public: QgsAfsFeatureSource( const std::shared_ptr &sharedData ); QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) override; @@ -55,13 +54,13 @@ class QgsAfsFeatureIterator : public QgsAbstractFeatureIteratorFromSource mFeatureIdList; - QList< QgsFeatureId > mRemainingFeatureIds; + QList mFeatureIdList; + QList mRemainingFeatureIds; QgsCoordinateTransform mTransform; QgsRectangle mFilterRect; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; QgsFeedback *mInterruptionChecker = nullptr; bool mDeferredFeaturesInFilterRectCheck = false; diff --git a/src/providers/arcgisrest/qgsafsprovider.cpp b/src/providers/arcgisrest/qgsafsprovider.cpp index cdd5b633e51d..7fcaa06f2a98 100644 --- a/src/providers/arcgisrest/qgsafsprovider.cpp +++ b/src/providers/arcgisrest/qgsafsprovider.cpp @@ -49,12 +49,11 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri, const ProviderOptions &optio mRequestHeaders = mSharedData->mDataSource.httpHeaders(); const QString &urlPrefix = mSharedData->mDataSource.param( QStringLiteral( "urlprefix" ) ); - std::unique_ptr< QgsScopedRuntimeProfile > profile; + std::unique_ptr profile; if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) ) - profile = std::make_unique< QgsScopedRuntimeProfile >( tr( "Retrieve service definition" ), QStringLiteral( "projectload" ) ); + profile = std::make_unique( tr( "Retrieve service definition" ), QStringLiteral( "projectload" ) ); - const QVariantMap layerData = QgsArcGisRestQueryUtils::getLayerInfo( mSharedData->mDataSource.param( QStringLiteral( "url" ) ), - authcfg, errorTitle, errorMessage, mRequestHeaders, urlPrefix ); + const QVariantMap layerData = QgsArcGisRestQueryUtils::getLayerInfo( mSharedData->mDataSource.param( QStringLiteral( "url" ) ), authcfg, errorTitle, errorMessage, mRequestHeaders, urlPrefix ); if ( layerData.isEmpty() ) { pushError( errorTitle + ": " + errorMessage ); @@ -76,8 +75,7 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri, const ProviderOptions &optio if ( adminUrl.contains( QStringLiteral( "/rest/services/" ) ) ) { adminUrl.replace( QLatin1String( "/rest/services/" ), QLatin1String( "/rest/admin/services/" ) ); - const QVariantMap adminData = QgsArcGisRestQueryUtils::getLayerInfo( adminUrl, - authcfg, errorTitle, errorMessage, mRequestHeaders, urlPrefix ); + const QVariantMap adminData = QgsArcGisRestQueryUtils::getLayerInfo( adminUrl, authcfg, errorTitle, errorMessage, mRequestHeaders, urlPrefix ); if ( !adminData.isEmpty() ) { mAdminUrl = adminUrl; @@ -134,7 +132,7 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri, const ProviderOptions &optio spatialExtent.bounds = QgsBox3D( originalExtent ); spatialExtent.extentCrs = extentCrs; QgsLayerMetadata::Extent metadataExtent; - metadataExtent.setSpatialExtents( QList< QgsLayerMetadata::SpatialExtent >() << spatialExtent ); + metadataExtent.setSpatialExtents( QList() << spatialExtent ); mLayerMetadata.setExtent( metadataExtent ); } if ( extentCrs.isValid() ) @@ -196,7 +194,7 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri, const ProviderOptions &optio { const QVariantMap value = v.toMap(); QVariantMap config; - config[ value.value( QStringLiteral( "name" ) ).toString() ] = value.value( QStringLiteral( "code" ) ); + config[value.value( QStringLiteral( "name" ) ).toString()] = value.value( QStringLiteral( "code" ) ); valueConfig.append( config ); } QVariantMap editorConfig; @@ -265,13 +263,11 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri, const ProviderOptions &optio const QVariantList extent = timeInfo.value( QStringLiteral( "timeExtent" ) ).toList(); if ( extent.size() == 2 ) { - lTemporalCapabilities->setAvailableTemporalRange( QgsDateTimeRange( QgsArcGisRestUtils::convertDateTime( extent.at( 0 ) ), - QgsArcGisRestUtils::convertDateTime( extent.at( 1 ) ) ) ); + lTemporalCapabilities->setAvailableTemporalRange( QgsDateTimeRange( QgsArcGisRestUtils::convertDateTime( extent.at( 0 ) ), QgsArcGisRestUtils::convertDateTime( extent.at( 1 ) ) ) ); } } - QList types - { + QList types { QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Int ), QStringLiteral( "esriFieldTypeSmallInteger" ), QMetaType::Type::Int, -1, -1, 0, 0 ), QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::LongLong ), QStringLiteral( "esriFieldTypeInteger" ), QMetaType::Type::LongLong, -1, -1, 0, 0 ), QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Double ), QStringLiteral( "esriFieldTypeDouble" ), QMetaType::Type::Double, 1, 20, 0, 20 ), @@ -287,7 +283,7 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri, const ProviderOptions &optio // Read OBJECTIDs of all features: these may not be a continuous sequence, // and we need to store these to iterate through the features. This query // also returns the name of the ObjectID field. - if ( ! mSharedData->getObjectIds( errorMessage ) ) + if ( !mSharedData->getObjectIds( errorMessage ) ) { appendError( QgsErrorMessage( errorMessage, QStringLiteral( "AFSProvider" ) ) ); return; @@ -758,8 +754,8 @@ bool QgsAfsProvider::renderInPreview( const QgsDataProvider::PreviewContext & ) } -QgsAfsProviderMetadata::QgsAfsProviderMetadata(): - QgsProviderMetadata( QgsAfsProvider::AFS_PROVIDER_KEY, QgsAfsProvider::AFS_PROVIDER_DESCRIPTION ) +QgsAfsProviderMetadata::QgsAfsProviderMetadata() + : QgsProviderMetadata( QgsAfsProvider::AFS_PROVIDER_KEY, QgsAfsProvider::AFS_PROVIDER_DESCRIPTION ) { } @@ -773,7 +769,7 @@ QList QgsAfsProviderMetadata::dataItemProviders() const QList providers; providers - << new QgsArcGisRestDataItemProvider; + << new QgsArcGisRestDataItemProvider; return providers; } @@ -820,7 +816,7 @@ QString QgsAfsProviderMetadata::encodeUri( const QVariantMap &parts ) const if ( parts.contains( QStringLiteral( "bounds" ) ) && parts.value( QStringLiteral( "bounds" ) ).userType() == qMetaTypeId() ) { - const QgsRectangle bBox = parts.value( QStringLiteral( "bounds" ) ).value< QgsRectangle >(); + const QgsRectangle bBox = parts.value( QStringLiteral( "bounds" ) ).value(); dsUri.setParam( QStringLiteral( "bbox" ), QStringLiteral( "%1,%2,%3,%4" ).arg( bBox.xMinimum() ).arg( bBox.yMinimum() ).arg( bBox.xMaximum() ).arg( bBox.yMaximum() ) ); } diff --git a/src/providers/arcgisrest/qgsafsprovider.h b/src/providers/arcgisrest/qgsafsprovider.h index 4bdf7a5452a2..e471442b4f20 100644 --- a/src/providers/arcgisrest/qgsafsprovider.h +++ b/src/providers/arcgisrest/qgsafsprovider.h @@ -39,7 +39,6 @@ class QgsAfsProvider : public QgsVectorDataProvider Q_OBJECT public: - static const inline QString AFS_PROVIDER_KEY = QStringLiteral( "arcgisfeatureserver" ); static const inline QString AFS_PROVIDER_DESCRIPTION = QStringLiteral( "ArcGIS Feature Service data provider" ); @@ -113,7 +112,7 @@ class QgsAfsProvider : public QgsVectorDataProvider void reloadProviderData() override; }; -class QgsAfsProviderMetadata: public QgsProviderMetadata +class QgsAfsProviderMetadata : public QgsProviderMetadata { Q_OBJECT public: @@ -123,7 +122,7 @@ class QgsAfsProviderMetadata: public QgsProviderMetadata QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; QgsAfsProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif // QGSAFSPROVIDER_H diff --git a/src/providers/arcgisrest/qgsafsshareddata.cpp b/src/providers/arcgisrest/qgsafsshareddata.cpp index 4f66aca174f3..96765ec53ed7 100644 --- a/src/providers/arcgisrest/qgsafsshareddata.cpp +++ b/src/providers/arcgisrest/qgsafsshareddata.cpp @@ -48,8 +48,7 @@ QgsRectangle QgsAfsSharedData::extent() const if ( mDataSource.sql().isEmpty() ) return mExtent; - return QgsArcGisRestQueryUtils::getExtent( mDataSource.param( QStringLiteral( "url" ) ), mDataSource.sql(), mDataSource.authConfigId(), - mDataSource.httpHeaders() ); + return QgsArcGisRestQueryUtils::getExtent( mDataSource.param( QStringLiteral( "url" ) ), mDataSource.sql(), mDataSource.authConfigId(), mDataSource.httpHeaders() ); } QgsAfsSharedData::QgsAfsSharedData( const QgsDataSourceUri &uri ) @@ -57,10 +56,10 @@ QgsAfsSharedData::QgsAfsSharedData( const QgsDataSourceUri &uri ) { } -std::shared_ptr< QgsAfsSharedData > QgsAfsSharedData::clone() const +std::shared_ptr QgsAfsSharedData::clone() const { QgsReadWriteLocker locker( mReadWriteLock, QgsReadWriteLocker::Read ); - std::shared_ptr< QgsAfsSharedData > copy = std::make_shared< QgsAfsSharedData >( mDataSource ); + std::shared_ptr copy = std::make_shared( mDataSource ); copy->mLimitBBox = mLimitBBox; copy->mExtent = mExtent; copy->mGeometryType = mGeometryType; @@ -110,8 +109,7 @@ bool QgsAfsSharedData::getObjectIds( QString &errorMessage ) // also returns the name of the ObjectID field. QString errorTitle; QString error; - QVariantMap objectIdData = QgsArcGisRestQueryUtils::getObjectIds( mDataSource.param( QStringLiteral( "url" ) ), mDataSource.authConfigId(), - errorTitle, error, mDataSource.httpHeaders(), mDataSource.param( QStringLiteral( "urlprefix" ) ), mLimitBBox ? mExtent : QgsRectangle(), mDataSource.sql() ); + QVariantMap objectIdData = QgsArcGisRestQueryUtils::getObjectIds( mDataSource.param( QStringLiteral( "url" ) ), mDataSource.authConfigId(), errorTitle, error, mDataSource.httpHeaders(), mDataSource.param( QStringLiteral( "urlprefix" ) ), mLimitBBox ? mExtent : QgsRectangle(), mDataSource.sql() ); if ( objectIdData.isEmpty() ) { errorMessage = QObject::tr( "getObjectIds failed: %1 - %2" ).arg( errorTitle, error ); @@ -133,8 +131,8 @@ bool QgsAfsSharedData::getObjectIds( QString &errorMessage ) QgsFieldConstraints constraints = mFields.at( idx ).constraints(); constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); - mFields[ idx ].setConstraints( constraints ); - mFields[ idx ].setReadOnly( true ); + mFields[idx].setConstraints( constraints ); + mFields[idx].setReadOnly( true ); break; } @@ -183,7 +181,7 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect while ( !featureFetched ) { startId = ( id / mMaximumFetchObjectsCount ) * mMaximumFetchObjectsCount; - const int stopId = std::min< size_t >( startId + mMaximumFetchObjectsCount, mObjectIds.length() ); + const int stopId = std::min( startId + mMaximumFetchObjectsCount, mObjectIds.length() ); objectIds.clear(); objectIds.reserve( stopId - startId ); for ( int i = startId; i < stopId; ++i ) @@ -204,9 +202,10 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect // Query QString errorTitle, errorMessage; queryData = QgsArcGisRestQueryUtils::getObjects( - mDataSource.param( QStringLiteral( "url" ) ), authcfg, objectIds, mDataSource.param( QStringLiteral( "crs" ) ), true, - QStringList(), QgsWkbTypes::hasM( mGeometryType ), QgsWkbTypes::hasZ( mGeometryType ), - filterRect, errorTitle, errorMessage, mDataSource.httpHeaders(), feedback, mDataSource.param( QStringLiteral( "urlprefix" ) ) ); + mDataSource.param( QStringLiteral( "url" ) ), authcfg, objectIds, mDataSource.param( QStringLiteral( "crs" ) ), true, + QStringList(), QgsWkbTypes::hasM( mGeometryType ), QgsWkbTypes::hasZ( mGeometryType ), + filterRect, errorTitle, errorMessage, mDataSource.httpHeaders(), feedback, mDataSource.param( QStringLiteral( "urlprefix" ) ) + ); if ( feedback && feedback->isCanceled() ) { @@ -280,8 +279,7 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect // Set geometry const QVariantMap geometryData = featureData[QStringLiteral( "geometry" )].toMap(); - std::unique_ptr< QgsAbstractGeometry > geometry( QgsArcGisRestUtils::convertGeometry( geometryData, queryData[QStringLiteral( "geometryType" )].toString(), - QgsWkbTypes::hasM( mGeometryType ), QgsWkbTypes::hasZ( mGeometryType ) ) ); + std::unique_ptr geometry( QgsArcGisRestUtils::convertGeometry( geometryData, queryData[QStringLiteral( "geometryType" )].toString(), QgsWkbTypes::hasM( mGeometryType ), QgsWkbTypes::hasZ( mGeometryType ) ) ); // Above might return 0, which is OK since in theory empty geometries are allowed if ( geometry ) feature.setGeometry( QgsGeometry( std::move( geometry ) ) ); @@ -306,8 +304,7 @@ QgsFeatureIds QgsAfsSharedData::getFeatureIdsInExtent( const QgsRectangle &exten QString errorText; const QString authcfg = mDataSource.authConfigId(); - const QList objectIdsInRect = QgsArcGisRestQueryUtils::getObjectIdsByExtent( mDataSource.param( QStringLiteral( "url" ) ), - extent, errorTitle, errorText, authcfg, mDataSource.httpHeaders(), feedback, mDataSource.sql(), mDataSource.param( QStringLiteral( "urlprefix" ) ) ); + const QList objectIdsInRect = QgsArcGisRestQueryUtils::getObjectIdsByExtent( mDataSource.param( QStringLiteral( "url" ) ), extent, errorTitle, errorText, authcfg, mDataSource.httpHeaders(), feedback, mDataSource.sql(), mDataSource.param( QStringLiteral( "urlprefix" ) ) ); QgsReadWriteLocker locker( mReadWriteLock, QgsReadWriteLocker::Read ); QgsFeatureIds ids; @@ -339,7 +336,7 @@ bool QgsAfsSharedData::deleteFeatures( const QgsFeatureIds &ids, QString &error, bool ok = false; postData( queryUrl, payload, feedback, ok, error ); - if ( ! ok ) + if ( !ok ) { return false; } @@ -474,7 +471,7 @@ bool QgsAfsSharedData::addFields( const QString &adminUrl, const QList fieldsJson.append( QgsArcGisRestUtils::fieldDefinitionToJson( field ) ); } - const QVariantMap definition {{ QStringLiteral( "fields" ), fieldsJson }}; + const QVariantMap definition { { QStringLiteral( "fields" ), fieldsJson } }; const QString json = QString::fromStdString( QgsJsonUtils::jsonFromVariant( definition ).dump( 2 ) ); @@ -518,12 +515,12 @@ bool QgsAfsSharedData::deleteFields( const QString &adminUrl, const QgsAttribute { if ( index >= 0 && index < mFields.count() ) { - fieldsJson.append( QVariantMap( {{QStringLiteral( "name" ), mFields.at( index ).name() }} ) ); + fieldsJson.append( QVariantMap( { { QStringLiteral( "name" ), mFields.at( index ).name() } } ) ); fieldNames << mFields.at( index ).name(); } } - const QVariantMap definition {{ QStringLiteral( "fields" ), fieldsJson }}; + const QVariantMap definition { { QStringLiteral( "fields" ), fieldsJson } }; const QString json = QString::fromStdString( QgsJsonUtils::jsonFromVariant( definition ).dump( 2 ) ); @@ -565,14 +562,14 @@ bool QgsAfsSharedData::addAttributeIndex( const QString &adminUrl, int attribute QVariantList indexJson; indexJson << QVariantMap( - { - {QStringLiteral( "name" ), QStringLiteral( "%1_index" ).arg( name )}, - {QStringLiteral( "fields" ), name}, - {QStringLiteral( "description" ), name} - } ); + { { QStringLiteral( "name" ), QStringLiteral( "%1_index" ).arg( name ) }, + { QStringLiteral( "fields" ), name }, + { QStringLiteral( "description" ), name } + } + ); - const QVariantMap definition {{ QStringLiteral( "indexes" ), indexJson }}; + const QVariantMap definition { { QStringLiteral( "indexes" ), indexJson } }; const QString json = QString::fromStdString( QgsJsonUtils::jsonFromVariant( definition ).dump( 2 ) ); @@ -644,7 +641,7 @@ QVariantMap QgsAfsSharedData::postData( const QUrl &url, const QByteArray &paylo const QgsBlockingNetworkRequest::ErrorCode error = networkRequest.post( request, payload, false, feedback ); -// Handle network errors + // Handle network errors if ( error != QgsBlockingNetworkRequest::NoError ) { QgsDebugError( QStringLiteral( "Network error: %1" ).arg( networkRequest.errorMessage() ) ); diff --git a/src/providers/arcgisrest/qgsafsshareddata.h b/src/providers/arcgisrest/qgsafsshareddata.h index 5456c9b7525b..3c8712b04be6 100644 --- a/src/providers/arcgisrest/qgsafsshareddata.h +++ b/src/providers/arcgisrest/qgsafsshareddata.h @@ -30,12 +30,11 @@ class QgsFeedback; */ class QgsAfsSharedData { - public: QgsAfsSharedData( const QgsDataSourceUri &uri ); //! Creates a deep copy of this shared data - std::shared_ptr< QgsAfsSharedData > clone() const; + std::shared_ptr clone() const; long long objectIdCount() const; long long featureCount() const; @@ -69,11 +68,10 @@ class QgsAfsSharedData bool hasCachedAllFeatures() const; private: - QVariantMap postData( const QUrl &url, const QByteArray &payload, QgsFeedback *feedback, bool &ok, QString &errorText ) const; friend class QgsAfsProvider; - mutable QReadWriteLock mReadWriteLock{ QReadWriteLock::Recursive }; + mutable QReadWriteLock mReadWriteLock { QReadWriteLock::Recursive }; QgsDataSourceUri mDataSource; bool mLimitBBox = false; QgsRectangle mExtent; diff --git a/src/providers/arcgisrest/qgsamsprovider.cpp b/src/providers/arcgisrest/qgsamsprovider.cpp index 92762f1dcc83..6d835c4f0152 100644 --- a/src/providers/arcgisrest/qgsamsprovider.cpp +++ b/src/providers/arcgisrest/qgsamsprovider.cpp @@ -53,16 +53,16 @@ const QString QgsAmsProvider::AMS_PROVIDER_DESCRIPTION = QStringLiteral( "ArcGIS //! a helper class for ordering tile requests according to the distance from view center struct LessThanTileRequest { - QgsPointXY center; - bool operator()( const QgsAmsProvider::TileRequest &req1, const QgsAmsProvider::TileRequest &req2 ) - { - QPointF p1 = req1.mapExtent.center(); - QPointF p2 = req2.mapExtent.center(); - // using chessboard distance (loading order more natural than euclidean/manhattan distance) - double d1 = std::max( std::fabs( center.x() - p1.x() ), std::fabs( center.y() - p1.y() ) ); - double d2 = std::max( std::fabs( center.x() - p2.x() ), std::fabs( center.y() - p2.y() ) ); - return d1 < d2; - } + QgsPointXY center; + bool operator()( const QgsAmsProvider::TileRequest &req1, const QgsAmsProvider::TileRequest &req2 ) + { + QPointF p1 = req1.mapExtent.center(); + QPointF p2 = req2.mapExtent.center(); + // using chessboard distance (loading order more natural than euclidean/manhattan distance) + double d1 = std::max( std::fabs( center.x() - p1.x() ), std::fabs( center.y() - p1.y() ) ); + double d2 = std::max( std::fabs( center.x() - p2.x() ), std::fabs( center.y() - p2.y() ) ); + return d1 < d2; + } }; QgsAmsLegendFetcher::QgsAmsLegendFetcher( QgsAmsProvider *provider, const QImage &fetchedImage ) @@ -120,7 +120,7 @@ void QgsAmsLegendFetcher::handleFinished() } QVariantMap queryResults = doc.object().toVariantMap(); QgsDataSourceUri dataSource( mProvider->dataSourceUri() ); - QVector< QPair > legendEntries; + QVector> legendEntries; const QVariantList layersList = queryResults.value( QStringLiteral( "layers" ) ).toList(); for ( const QVariant &result : layersList ) @@ -166,8 +166,7 @@ void QgsAmsLegendFetcher::handleFinished() maxImageSize.setHeight( std::max( maxImageSize.height(), legendEntry.second.height() ) ); textWidth = std::max( textWidth, fm.boundingRect( legendEntry.first ).width() + 10 ); } - double scaleFactor = maxImageSize.width() == 0 || maxImageSize.height() == 0 ? 1.0 : - std::min( 1., std::min( double( imageSize ) / maxImageSize.width(), double( imageSize ) / maxImageSize.height() ) ); + double scaleFactor = maxImageSize.width() == 0 || maxImageSize.height() == 0 ? 1.0 : std::min( 1., std::min( double( imageSize ) / maxImageSize.width(), double( imageSize ) / maxImageSize.height() ) ); mLegendImage = QImage( imageSize + padding + textWidth, verticalPadding + legendEntries.size() * ( verticalSize + verticalPadding ), QImage::Format_ARGB32 ); mLegendImage.fill( Qt::transparent ); @@ -242,7 +241,7 @@ QgsAmsProvider::QgsAmsProvider( const QString &uri, const ProviderOptions &optio spatialExtent.bounds = QgsBox3D( mExtent ); spatialExtent.extentCrs = mCrs; QgsLayerMetadata::Extent metadataExtent; - metadataExtent.setSpatialExtents( QList< QgsLayerMetadata::SpatialExtent >() << spatialExtent ); + metadataExtent.setSpatialExtents( QList() << spatialExtent ); mLayerMetadata.setExtent( metadataExtent ); mLayerMetadata.setCrs( mCrs ); @@ -258,8 +257,7 @@ QgsAmsProvider::QgsAmsProvider( const QString &uri, const ProviderOptions &optio mMaxImageHeight = mServiceInfo.value( QStringLiteral( "maxImageHeight" ) ).toInt(); QVariantList layerList = mServiceInfo["layers"].toList(); - std::function includeChildSublayers = [&]( int layerId ) - { + std::function includeChildSublayers = [&]( int layerId ) { if ( layerId < layerList.size() ) { QVariantList subLayersList = layerList[layerId].toMap()["subLayerIds"].toList(); @@ -271,7 +269,7 @@ QgsAmsProvider::QgsAmsProvider( const QString &uri, const ProviderOptions &optio } } }; - includeChildSublayers( mLayerInfo[ QStringLiteral( "id" ) ].toInt() ); + includeChildSublayers( mLayerInfo[QStringLiteral( "id" )].toInt() ); mTimestamp = QDateTime::currentDateTime(); mValid = true; @@ -320,8 +318,8 @@ QgsAmsProvider::QgsAmsProvider( const QString &uri, const ProviderOptions &optio QgsAmsProvider::QgsAmsProvider( const QgsAmsProvider &other, const QgsDataProvider::ProviderOptions &providerOptions ) : QgsRasterDataProvider( other.dataSourceUri(), providerOptions ) , mValid( other.mValid ) -// intentionally omitted: -// - mLegendFetcher + // intentionally omitted: + // - mLegendFetcher , mServiceInfo( other.mServiceInfo ) , mLayerInfo( other.mLayerInfo ) , mCrs( other.mCrs ) @@ -530,14 +528,13 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int { return QImage(); } - std::sort( lodEntries.begin(), lodEntries.end(), []( const QVariant & a, const QVariant & b ) - { + std::sort( lodEntries.begin(), lodEntries.end(), []( const QVariant &a, const QVariant &b ) { return a.toMap().value( QStringLiteral( "resolution" ) ).toDouble() > b.toMap().value( QStringLiteral( "resolution" ) ).toDouble(); } ); int level = 0; int foundLevel = -1; - QMap< int, double > levelToResMap; + QMap levelToResMap; for ( const QVariant &lodEntry : lodEntries ) { QVariantMap lodEntryMap = lodEntry.toMap(); @@ -560,17 +557,16 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int level = lodEntries.constLast().toMap().value( QStringLiteral( "level" ) ).toInt(); } - auto getRequests = [&levelToResMap, &viewExtent, tileWidth, tileHeight, ox, oy, targetRes, &dataSource]( int level, TileRequests & requests ) - { + auto getRequests = [&levelToResMap, &viewExtent, tileWidth, tileHeight, ox, oy, targetRes, &dataSource]( int level, TileRequests &requests ) { const double resolution = levelToResMap.value( level ); // Get necessary tiles to fill extent // tile_x = ox + i * (resolution * tileWidth) // tile_y = oy - j * (resolution * tileHeight) - int ixStart = static_cast< int >( std::floor( ( viewExtent.xMinimum() - ox ) / ( tileWidth * resolution ) ) ); - int iyStart = static_cast< int >( std::floor( ( oy - viewExtent.yMaximum() ) / ( tileHeight * resolution ) ) ); - int ixEnd = static_cast< int >( std::ceil( ( viewExtent.xMaximum() - ox ) / ( tileWidth * resolution ) ) ); - int iyEnd = static_cast< int >( std::ceil( ( oy - viewExtent.yMinimum() ) / ( tileHeight * resolution ) ) ); + int ixStart = static_cast( std::floor( ( viewExtent.xMinimum() - ox ) / ( tileWidth * resolution ) ) ); + int iyStart = static_cast( std::floor( ( oy - viewExtent.yMaximum() ) / ( tileHeight * resolution ) ) ); + int ixEnd = static_cast( std::ceil( ( viewExtent.xMaximum() - ox ) / ( tileWidth * resolution ) ) ); + int iyEnd = static_cast( std::ceil( ( oy - viewExtent.yMinimum() ) / ( tileHeight * resolution ) ) ); double imX = ( viewExtent.xMinimum() - ox ) / resolution; double imY = ( oy - viewExtent.yMaximum() ) / resolution; @@ -581,10 +577,7 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int for ( int ix = ixStart; ix <= ixEnd; ++ix ) { const QUrl url = QUrl( dataSource.param( QStringLiteral( "url" ) ) + QStringLiteral( "/tile/%1/%2/%3" ).arg( level ).arg( iy ).arg( ix ) ); - const QRectF tileImageRect( ( ix * tileWidth - imX ) * resScale, - ( iy * tileHeight - imY ) * resScale, - tileWidth * resScale, - tileHeight * resScale ); + const QRectF tileImageRect( ( ix * tileWidth - imX ) * resScale, ( iy * tileHeight - imY ) * resScale, tileWidth * resScale, tileHeight * resScale ); const QRectF worldRect( ox + ix * ( resolution * tileWidth ), oy - iy * ( resolution * tileHeight ), tileWidth * resolution, tileHeight * resolution ); @@ -598,8 +591,8 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int TileRequests requests; getRequests( level, requests ); - QList tileImages; // in the correct resolution - QList missing; // rectangles (in map coords) of missing tiles for this view + QList tileImages; // in the correct resolution + QList missing; // rectangles (in map coords) of missing tiles for this view QImage image( pixelWidth, pixelHeight, QImage::Format_ARGB32 ); image.fill( Qt::transparent ); @@ -635,17 +628,16 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int // from lower or higher resolution available to give the user a bit of context // while loading the right resolution p.setCompositionMode( QPainter::CompositionMode_Source ); - p.setRenderHint( QPainter::SmoothPixmapTransform, false ); // let's not waste time with bilinear filtering + p.setRenderHint( QPainter::SmoothPixmapTransform, false ); // let's not waste time with bilinear filtering - auto fetchOtherResTiles = [&getRequests]( int otherLevel, QList< TileImage> &otherResTiles, QList< QRectF > &missingRects ) - { + auto fetchOtherResTiles = [&getRequests]( int otherLevel, QList &otherResTiles, QList &missingRects ) { TileRequests otherRequests; getRequests( otherLevel, otherRequests ); QList missingRectsToDelete; for ( const TileRequest &r : std::as_const( otherRequests ) ) { QImage localImage; - if ( ! QgsTileCache::tile( r.url, localImage ) ) + if ( !QgsTileCache::tile( r.url, localImage ) ) continue; otherResTiles << TileImage( r.rect, localImage, false ); @@ -740,8 +732,8 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int int maxWidth = mMaxImageWidth > 0 ? mMaxImageWidth : pixelWidth; int maxHeight = mMaxImageHeight > 0 ? mMaxImageHeight : pixelHeight; - int nbStepWidth = std::ceil( ( float )pixelWidth / maxWidth ); - int nbStepHeight = std::ceil( ( float )pixelHeight / maxHeight ); + int nbStepWidth = std::ceil( ( float ) pixelWidth / maxWidth ); + int nbStepHeight = std::ceil( ( float ) pixelHeight / maxHeight ); for ( int currentStepWidth = 0; currentStepWidth < nbStepWidth; currentStepWidth++ ) { for ( int currentStepHeight = 0; currentStepHeight < nbStepHeight; currentStepHeight++ ) @@ -846,8 +838,7 @@ QImage QgsAmsProvider::getLegendGraphic( double /*scale*/, bool forceRefresh, co QgsImageFetcher *QgsAmsProvider::getLegendGraphicFetcher( const QgsMapSettings * /*mapSettings*/ ) { QgsAmsLegendFetcher *fetcher = new QgsAmsLegendFetcher( this, mLegendFetcher->getImage() ); - connect( fetcher, &QgsAmsLegendFetcher::fetchedNew, this, [ = ]( const QImage & fetched ) - { + connect( fetcher, &QgsAmsLegendFetcher::fetchedNew, this, [=]( const QImage &fetched ) { mLegendFetcher->setImage( fetched ); } ); return fetcher; @@ -862,7 +853,7 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPointXY &point, Qgis: query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) ); query.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryPoint" ) ); query.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "{x: %1, y: %2}" ).arg( point.x(), 0, 'f' ).arg( point.y(), 0, 'f' ) ); -// query.addQueryItem( "sr", mCrs.postgisSrid() ); + // query.addQueryItem( "sr", mCrs.postgisSrid() ); query.addQueryItem( QStringLiteral( "layers" ), QStringLiteral( "all:%1" ).arg( dataSource.param( QStringLiteral( "layer" ) ) ) ); query.addQueryItem( QStringLiteral( "imageDisplay" ), QStringLiteral( "%1,%2,%3" ).arg( width ).arg( height ).arg( dpi ) ); query.addQueryItem( QStringLiteral( "mapExtent" ), QStringLiteral( "%1,%2,%3,%4" ).arg( extent.xMinimum(), 0, 'f' ).arg( extent.yMinimum(), 0, 'f' ).arg( extent.xMaximum(), 0, 'f' ).arg( extent.yMaximum(), 0, 'f' ) ); @@ -903,7 +894,7 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPointXY &point, Qgis: featureAttributes.append( it.value().toString() ); } QgsCoordinateReferenceSystem crs; - std::unique_ptr< QgsAbstractGeometry > geometry( QgsArcGisRestUtils::convertGeometry( resultMap[QStringLiteral( "geometry" )].toMap(), resultMap[QStringLiteral( "geometryType" )].toString(), false, false, &crs ) ); + std::unique_ptr geometry( QgsArcGisRestUtils::convertGeometry( resultMap[QStringLiteral( "geometry" )].toMap(), resultMap[QStringLiteral( "geometryType" )].toString(), false, false, &crs ) ); QgsFeature feature( fields ); feature.setGeometry( QgsGeometry( std::move( geometry ) ) ); feature.setAttributes( featureAttributes ); @@ -954,7 +945,7 @@ bool QgsAmsProvider::readBlock( int /*bandNo*/, const QgsRectangle &viewExtent, // QgsAmsTiledImageDownloadHandler // -QgsAmsTiledImageDownloadHandler::QgsAmsTiledImageDownloadHandler( const QString &auth, const QgsHttpHeaders &requestHeaders, int tileReqNo, const QgsAmsProvider::TileRequests &requests, QImage *image, const QgsRectangle &viewExtent, QgsRasterBlockFeedback *feedback, const QString &urlPrefix ) +QgsAmsTiledImageDownloadHandler::QgsAmsTiledImageDownloadHandler( const QString &auth, const QgsHttpHeaders &requestHeaders, int tileReqNo, const QgsAmsProvider::TileRequests &requests, QImage *image, const QgsRectangle &viewExtent, QgsRasterBlockFeedback *feedback, const QString &urlPrefix ) : mAuth( auth ) , mRequestHeaders( requestHeaders ) , mImage( image ) @@ -1096,8 +1087,7 @@ void QgsAmsTiledImageDownloadHandler::tileReplyFinished() QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString(); QgsDebugMsgLevel( "contentType: " + contentType, 2 ); - if ( !contentType.isEmpty() && !contentType.startsWith( QLatin1String( "image/" ), Qt::CaseInsensitive ) && - contentType.compare( QLatin1String( "application/octet-stream" ), Qt::CaseInsensitive ) != 0 ) + if ( !contentType.isEmpty() && !contentType.startsWith( QLatin1String( "image/" ), Qt::CaseInsensitive ) && contentType.compare( QLatin1String( "application/octet-stream" ), Qt::CaseInsensitive ) != 0 ) { QByteArray text = reply->readAll(); QString errorTitle, errorText; @@ -1127,11 +1117,7 @@ void QgsAmsTiledImageDownloadHandler::tileReplyFinished() } else { - QgsMessageLog::logMessage( tr( "Tile request error (Status: %1; Content-Type: %2; Length: %3; URL: %4)" ) - .arg( status.toString(), - contentType ) - .arg( text.size() ) - .arg( reply->url().toString() ), tr( "WMS" ) ); + QgsMessageLog::logMessage( tr( "Tile request error (Status: %1; Content-Type: %2; Length: %3; URL: %4)" ).arg( status.toString(), contentType ).arg( text.size() ).arg( reply->url().toString() ), tr( "WMS" ) ); #ifdef QGISDEBUG QFile file( QDir::tempPath() + "/broken-image.png" ); if ( file.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) @@ -1176,7 +1162,7 @@ void QgsAmsTiledImageDownloadHandler::tileReplyFinished() else { QString errorText = tr( "Returned image is flawed [Content-Type: %1; URL: %2]" ) - .arg( contentType, reply->url().toString() ); + .arg( contentType, reply->url().toString() ); if ( mFeedback ) mFeedback->appendError( errorText ); } @@ -1191,7 +1177,6 @@ void QgsAmsTiledImageDownloadHandler::tileReplyFinished() if ( mReplies.isEmpty() ) finish(); - } else { @@ -1263,7 +1248,6 @@ void QgsAmsTiledImageDownloadHandler::repeatTileRequest( QNetworkRequest const & } - QgsAmsProviderMetadata::QgsAmsProviderMetadata() : QgsProviderMetadata( QgsAmsProvider::AMS_PROVIDER_KEY, QgsAmsProvider::AMS_PROVIDER_DESCRIPTION ) { diff --git a/src/providers/arcgisrest/qgsamsprovider.h b/src/providers/arcgisrest/qgsamsprovider.h index efff07cf0734..7b5f57da6aac 100644 --- a/src/providers/arcgisrest/qgsamsprovider.h +++ b/src/providers/arcgisrest/qgsamsprovider.h @@ -60,7 +60,6 @@ class QgsAmsLegendFetcher : public QgsImageFetcher QImage mLegendImage; QString mErrorTitle; QString mError; - }; class QgsAmsProvider : public QgsRasterDataProvider @@ -68,7 +67,6 @@ class QgsAmsProvider : public QgsRasterDataProvider Q_OBJECT public: - static const QString AMS_PROVIDER_KEY; static const QString AMS_PROVIDER_DESCRIPTION; @@ -108,32 +106,33 @@ class QgsAmsProvider : public QgsRasterDataProvider QImage getLegendGraphic( double scale = 0, bool forceRefresh = false, const QgsRectangle *visibleExtent = nullptr ) override; QgsImageFetcher *getLegendGraphicFetcher( const QgsMapSettings *mapSettings ) override; QgsRasterIdentifyResult identify( const QgsPointXY &point, Qgis::RasterIdentifyFormat format, const QgsRectangle &extent = QgsRectangle(), int width = 0, int height = 0, int dpi = 96 ) override; - QList< double > nativeResolutions() const override; + QList nativeResolutions() const override; bool ignoreExtents() const override { return true; } //! Helper struct for tile requests struct TileRequest { - TileRequest( const QUrl &u, const QRectF &r, int i, const QRectF &mapExtent ) - : url( u ) - , rect( r ) - , mapExtent( mapExtent ) - , index( i ) - {} - QUrl url; - QRectF rect; - QRectF mapExtent; - int index; + TileRequest( const QUrl &u, const QRectF &r, int i, const QRectF &mapExtent ) + : url( u ) + , rect( r ) + , mapExtent( mapExtent ) + , index( i ) + {} + QUrl url; + QRectF rect; + QRectF mapExtent; + int index; }; typedef QList TileRequests; //! Helper structure to store a cached tile image with its rectangle typedef struct TileImage { - TileImage( const QRectF &r, const QImage &i, bool smooth ): rect( r ), img( i ), smooth( smooth ) {} - QRectF rect; //!< Destination rectangle for a tile (in screen coordinates) - QImage img; //!< Cached tile to be drawn - bool smooth; + TileImage( const QRectF &r, const QImage &i, bool smooth ) + : rect( r ), img( i ), smooth( smooth ) {} + QRectF rect; //!< Destination rectangle for a tile (in screen coordinates) + QImage img; //!< Cached tile to be drawn + bool smooth; } TileImage; protected: @@ -161,7 +160,7 @@ class QgsAmsProvider : public QgsRasterDataProvider int mMaxImageWidth = 4096; int mMaxImageHeight = 4096; QgsLayerMetadata mLayerMetadata; - QList< double > mResolutions; + QList mResolutions; QString mUrlPrefix; /** @@ -175,8 +174,7 @@ class QgsAmsTiledImageDownloadHandler : public QObject { Q_OBJECT public: - - QgsAmsTiledImageDownloadHandler( const QString &auth, const QgsHttpHeaders &requestHeaders, int reqNo, const QgsAmsProvider::TileRequests &requests, QImage *image, const QgsRectangle &viewExtent, QgsRasterBlockFeedback *feedback, const QString &urlPrefix ); + QgsAmsTiledImageDownloadHandler( const QString &auth, const QgsHttpHeaders &requestHeaders, int reqNo, const QgsAmsProvider::TileRequests &requests, QImage *image, const QgsRectangle &viewExtent, QgsRasterBlockFeedback *feedback, const QString &urlPrefix ); ~QgsAmsTiledImageDownloadHandler() override; void downloadBlocking(); @@ -186,12 +184,11 @@ class QgsAmsTiledImageDownloadHandler : public QObject void canceled(); private: - enum TileAttribute { TileReqNo = QNetworkRequest::User + 0, TileIndex = QNetworkRequest::User + 1, - TileRect = QNetworkRequest::User + 2, + TileRect = QNetworkRequest::User + 2, TileRetry = QNetworkRequest::User + 3, }; @@ -223,7 +220,7 @@ class QgsAmsTiledImageDownloadHandler : public QObject QString mUrlPrefix; }; -class QgsAmsProviderMetadata: public QgsProviderMetadata +class QgsAmsProviderMetadata : public QgsProviderMetadata { Q_OBJECT public: @@ -232,7 +229,7 @@ class QgsAmsProviderMetadata: public QgsProviderMetadata QgsAmsProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif // QGSMAPSERVERPROVIDER_H diff --git a/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.cpp b/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.cpp index 718007a5cb5c..16b991da4fb4 100644 --- a/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.cpp +++ b/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.cpp @@ -33,7 +33,7 @@ void QgsArcGisRestDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selection, QgsDataItemGuiContext context ) { - if ( QgsArcGisRestRootItem *rootItem = qobject_cast< QgsArcGisRestRootItem * >( item ) ) + if ( QgsArcGisRestRootItem *rootItem = qobject_cast( item ) ) { QAction *actionNew = new QAction( tr( "New Connection…" ), menu ); connect( actionNew, &QAction::triggered, this, [rootItem] { newConnection( rootItem ); } ); @@ -47,7 +47,7 @@ void QgsArcGisRestDataItemGuiProvider::populateContextMenu( QgsDataItem *item, Q connect( actionLoadServers, &QAction::triggered, this, [rootItem] { loadConnections( rootItem ); } ); menu->addAction( actionLoadServers ); } - else if ( QgsArcGisRestConnectionItem *connectionItem = qobject_cast< QgsArcGisRestConnectionItem * >( item ) ) + else if ( QgsArcGisRestConnectionItem *connectionItem = qobject_cast( item ) ) { QAction *actionRefresh = new QAction( tr( "Refresh" ), menu ); connect( actionRefresh, &QAction::triggered, this, [connectionItem] { refreshConnection( connectionItem ); } ); @@ -63,65 +63,55 @@ void QgsArcGisRestDataItemGuiProvider::populateContextMenu( QgsDataItem *item, Q connect( actionDuplicate, &QAction::triggered, this, [connectionItem] { duplicateConnection( connectionItem ); } ); menu->addAction( actionDuplicate ); - const QList< QgsArcGisRestConnectionItem * > arcgisConnectionItems = QgsDataItem::filteredItems( selection ); + const QList arcgisConnectionItems = QgsDataItem::filteredItems( selection ); QAction *actionDelete = new QAction( arcgisConnectionItems.size() > 1 ? tr( "Remove Connections…" ) : tr( "Remove Connection…" ), menu ); - connect( actionDelete, &QAction::triggered, this, [arcgisConnectionItems, context] - { - QgsDataItemGuiProviderUtils::deleteConnections( arcgisConnectionItems, []( const QString & connectionName ) - { - QgsArcGisConnectionSettings::sTreeConnectionArcgis->deleteItem( connectionName ); - }, context ); + connect( actionDelete, &QAction::triggered, this, [arcgisConnectionItems, context] { + QgsDataItemGuiProviderUtils::deleteConnections( arcgisConnectionItems, []( const QString &connectionName ) { QgsArcGisConnectionSettings::sTreeConnectionArcgis->deleteItem( connectionName ); }, context ); } ); menu->addAction( actionDelete ); QAction *viewInfo = new QAction( tr( "View Service Info" ), menu ); - connect( viewInfo, &QAction::triggered, this, [ = ] - { + connect( viewInfo, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl( connectionItem->url() ) ); } ); menu->addAction( viewInfo ); } - else if ( QgsArcGisRestFolderItem *folderItem = qobject_cast< QgsArcGisRestFolderItem * >( item ) ) + else if ( QgsArcGisRestFolderItem *folderItem = qobject_cast( item ) ) { QAction *viewInfo = new QAction( tr( "View Service Info" ), menu ); - connect( viewInfo, &QAction::triggered, this, [ = ] - { + connect( viewInfo, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl( folderItem->path() ) ); } ); menu->addAction( viewInfo ); } - else if ( QgsArcGisFeatureServiceItem *serviceItem = qobject_cast< QgsArcGisFeatureServiceItem * >( item ) ) + else if ( QgsArcGisFeatureServiceItem *serviceItem = qobject_cast( item ) ) { QAction *viewInfo = new QAction( tr( "View Service Info" ), menu ); - connect( viewInfo, &QAction::triggered, this, [ = ] - { + connect( viewInfo, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl( serviceItem->path() ) ); } ); menu->addAction( viewInfo ); } - else if ( QgsArcGisMapServiceItem *serviceItem = qobject_cast< QgsArcGisMapServiceItem * >( item ) ) + else if ( QgsArcGisMapServiceItem *serviceItem = qobject_cast( item ) ) { QAction *viewInfo = new QAction( tr( "View Service Info" ), menu ); - connect( viewInfo, &QAction::triggered, this, [ = ] - { + connect( viewInfo, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl( serviceItem->path() ) ); } ); menu->addAction( viewInfo ); } - else if ( QgsArcGisRestParentLayerItem *layerItem = qobject_cast< QgsArcGisRestParentLayerItem * >( item ) ) + else if ( QgsArcGisRestParentLayerItem *layerItem = qobject_cast( item ) ) { QAction *viewInfo = new QAction( tr( "View Service Info" ), menu ); - connect( viewInfo, &QAction::triggered, this, [ = ] - { + connect( viewInfo, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl( layerItem->path() ) ); } ); menu->addAction( viewInfo ); } - else if ( QgsArcGisFeatureServiceLayerItem *layerItem = qobject_cast< QgsArcGisFeatureServiceLayerItem * >( item ) ) + else if ( QgsArcGisFeatureServiceLayerItem *layerItem = qobject_cast( item ) ) { QAction *viewInfo = new QAction( tr( "View Service Info" ), menu ); - connect( viewInfo, &QAction::triggered, this, [ = ] - { + connect( viewInfo, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl( layerItem->path() ) ); } ); menu->addAction( viewInfo ); @@ -133,16 +123,14 @@ void QgsArcGisRestDataItemGuiProvider::populateContextMenu( QgsDataItem *item, Q menu->addAction( addWithFilterAction ); const QgsMimeDataUtils::UriList uris = layerItem->mimeUris(); - connect( addWithFilterAction, &QAction::triggered, this, [uris, context, this] - { + connect( addWithFilterAction, &QAction::triggered, this, [uris, context, this] { addFilteredLayer( uris.value( 0 ), context ); } ); } - else if ( QgsArcGisMapServiceLayerItem *layerItem = qobject_cast< QgsArcGisMapServiceLayerItem * >( item ) ) + else if ( QgsArcGisMapServiceLayerItem *layerItem = qobject_cast( item ) ) { QAction *viewInfo = new QAction( tr( "View Service Info" ), menu ); - connect( viewInfo, &QAction::triggered, this, [ = ] - { + connect( viewInfo, &QAction::triggered, this, [=] { QDesktopServices::openUrl( QUrl( layerItem->path() ) ); } ); menu->addAction( viewInfo ); @@ -214,8 +202,7 @@ void QgsArcGisRestDataItemGuiProvider::saveConnections() void QgsArcGisRestDataItemGuiProvider::loadConnections( QgsDataItem *item ) { - const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -253,7 +240,7 @@ void QgsArcGisRestDataItemGuiProvider::addFilteredLayer( const QgsMimeDataUtils: const QString sql = w->expressionText(); ds.setSql( sql ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( ds.uri( false ), uri.name, QStringLiteral( "arcgisfeatureserver" ) ); + std::unique_ptr layer = std::make_unique( ds.uri( false ), uri.name, QStringLiteral( "arcgisfeatureserver" ) ); QgsProject::instance()->addMapLayer( layer.release() ); } } diff --git a/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.h b/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.h index 9532a2c71e00..44435d051759 100644 --- a/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.h +++ b/src/providers/arcgisrest/qgsarcgisrestdataitemguiprovider.h @@ -25,7 +25,6 @@ class QgsArcGisRestDataItemGuiProvider : public QObject, public QgsDataItemGuiPr Q_OBJECT public: - QgsArcGisRestDataItemGuiProvider() = default; QString name() override @@ -33,8 +32,7 @@ class QgsArcGisRestDataItemGuiProvider : public QObject, public QgsDataItemGuiPr return QStringLiteral( "afs_items" ); } - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; private: static void newConnection( QgsDataItem *item ); diff --git a/src/providers/arcgisrest/qgsarcgisrestdataitems.cpp b/src/providers/arcgisrest/qgsarcgisrestdataitems.cpp index 1b3e9cbfcf79..b96cd587d92b 100644 --- a/src/providers/arcgisrest/qgsarcgisrestdataitems.cpp +++ b/src/providers/arcgisrest/qgsarcgisrestdataitems.cpp @@ -73,58 +73,55 @@ void QgsArcGisRestRootItem::onConnectionsChanged() /////////////////////////////////////////////////////////////////////////////// -void addFolderItems( QVector< QgsDataItem * > &items, const QVariantMap &serviceData, const QString &baseUrl, const QString &authcfg, const QgsHttpHeaders &headers, const QString &urlPrefix, QgsDataItem *parent, - const QString &supportedFormats ) +void addFolderItems( QVector &items, const QVariantMap &serviceData, const QString &baseUrl, const QString &authcfg, const QgsHttpHeaders &headers, const QString &urlPrefix, QgsDataItem *parent, const QString &supportedFormats ) { - QgsArcGisRestQueryUtils::visitFolderItems( [parent, &baseUrl, &items, headers, urlPrefix, authcfg, supportedFormats]( const QString & name, const QString & url ) - { - std::unique_ptr< QgsArcGisRestFolderItem > folderItem = std::make_unique< QgsArcGisRestFolderItem >( parent, name, url, baseUrl, authcfg, headers, urlPrefix ); + QgsArcGisRestQueryUtils::visitFolderItems( [parent, &baseUrl, &items, headers, urlPrefix, authcfg, supportedFormats]( const QString &name, const QString &url ) { + std::unique_ptr folderItem = std::make_unique( parent, name, url, baseUrl, authcfg, headers, urlPrefix ); folderItem->setSupportedFormats( supportedFormats ); items.append( folderItem.release() ); - }, serviceData, baseUrl ); + }, + serviceData, baseUrl ); } -void addServiceItems( QVector< QgsDataItem * > &items, const QVariantMap &serviceData, const QString &baseUrl, const QString &authcfg, const QgsHttpHeaders &headers, const QString &urlPrefix, QgsDataItem *parent, - const QString &supportedFormats ) +void addServiceItems( QVector &items, const QVariantMap &serviceData, const QString &baseUrl, const QString &authcfg, const QgsHttpHeaders &headers, const QString &urlPrefix, QgsDataItem *parent, const QString &supportedFormats ) { QgsArcGisRestQueryUtils::visitServiceItems( - [&items, parent, authcfg, headers, urlPrefix, supportedFormats]( const QString & name, const QString & url, Qgis::ArcGisRestServiceType serviceType ) - { - switch ( serviceType ) - { - case Qgis::ArcGisRestServiceType::MapServer: - case Qgis::ArcGisRestServiceType::ImageServer: + [&items, parent, authcfg, headers, urlPrefix, supportedFormats]( const QString &name, const QString &url, Qgis::ArcGisRestServiceType serviceType ) { + switch ( serviceType ) { - std::unique_ptr< QgsArcGisMapServiceItem > serviceItem = std::make_unique< QgsArcGisMapServiceItem >( parent, name, url, url, authcfg, headers, urlPrefix, serviceType ); - items.append( serviceItem.release() ); - break; - } + case Qgis::ArcGisRestServiceType::MapServer: + case Qgis::ArcGisRestServiceType::ImageServer: + { + std::unique_ptr serviceItem = std::make_unique( parent, name, url, url, authcfg, headers, urlPrefix, serviceType ); + items.append( serviceItem.release() ); + break; + } - case Qgis::ArcGisRestServiceType::FeatureServer: - { - std::unique_ptr< QgsArcGisFeatureServiceItem > serviceItem = std::make_unique< QgsArcGisFeatureServiceItem >( parent, name, url, url, authcfg, headers, urlPrefix ); - serviceItem->setSupportedFormats( supportedFormats ); - items.append( serviceItem.release() ); - break; - } + case Qgis::ArcGisRestServiceType::FeatureServer: + { + std::unique_ptr serviceItem = std::make_unique( parent, name, url, url, authcfg, headers, urlPrefix ); + serviceItem->setSupportedFormats( supportedFormats ); + items.append( serviceItem.release() ); + break; + } - case Qgis::ArcGisRestServiceType::GlobeServer: - case Qgis::ArcGisRestServiceType::GPServer: - case Qgis::ArcGisRestServiceType::GeocodeServer: - case Qgis::ArcGisRestServiceType::Unknown: - break; // unsupported - } - }, serviceData, baseUrl ); + case Qgis::ArcGisRestServiceType::GlobeServer: + case Qgis::ArcGisRestServiceType::GPServer: + case Qgis::ArcGisRestServiceType::GeocodeServer: + case Qgis::ArcGisRestServiceType::Unknown: + break; // unsupported + } + }, + serviceData, baseUrl + ); } -void addLayerItems( QVector< QgsDataItem * > &items, const QVariantMap &serviceData, const QString &parentUrl, const QString &authcfg, const QgsHttpHeaders &headers, const QString urlPrefix, QgsDataItem *parent, QgsArcGisRestQueryUtils::ServiceTypeFilter serviceTypeFilter, - const QString &supportedFormats ) +void addLayerItems( QVector &items, const QVariantMap &serviceData, const QString &parentUrl, const QString &authcfg, const QgsHttpHeaders &headers, const QString urlPrefix, QgsDataItem *parent, QgsArcGisRestQueryUtils::ServiceTypeFilter serviceTypeFilter, const QString &supportedFormats ) { - QMultiMap< QString, QgsDataItem * > layerItems; - QMap< QString, QString > parents; + QMultiMap layerItems; + QMap parents; - QgsArcGisRestQueryUtils::addLayerItems( [parent, &layerItems, &parents, authcfg, headers, urlPrefix, serviceTypeFilter, supportedFormats]( const QString & parentLayerId, QgsArcGisRestQueryUtils::ServiceTypeFilter serviceType, Qgis::GeometryType geometryType, const QString & id, const QString & name, const QString & description, const QString & url, bool isParent, const QgsCoordinateReferenceSystem & crs, const QString & format ) - { + QgsArcGisRestQueryUtils::addLayerItems( [parent, &layerItems, &parents, authcfg, headers, urlPrefix, serviceTypeFilter, supportedFormats]( const QString &parentLayerId, QgsArcGisRestQueryUtils::ServiceTypeFilter serviceType, Qgis::GeometryType geometryType, const QString &id, const QString &name, const QString &description, const QString &url, bool isParent, const QgsCoordinateReferenceSystem &crs, const QString &format ) { Q_UNUSED( description ) if ( !parentLayerId.isEmpty() ) @@ -134,25 +131,25 @@ void addLayerItems( QVector< QgsDataItem * > &items, const QVariantMap &serviceD { if ( !layerItems.value( id ) ) { - std::unique_ptr< QgsArcGisRestParentLayerItem > layerItem = std::make_unique< QgsArcGisRestParentLayerItem >( parent, name, url, authcfg, headers, urlPrefix ); + std::unique_ptr layerItem = std::make_unique( parent, name, url, authcfg, headers, urlPrefix ); layerItems.insert( id, layerItem.release() ); } } else { - std::unique_ptr< QgsDataItem > layerItem; + std::unique_ptr layerItem; switch ( serviceTypeFilter == QgsArcGisRestQueryUtils::ServiceTypeFilter::AllTypes ? serviceType : serviceTypeFilter ) { case QgsArcGisRestQueryUtils::ServiceTypeFilter::Vector: - layerItem = std::make_unique< QgsArcGisFeatureServiceLayerItem >( parent, url, name, crs, authcfg, headers, urlPrefix, geometryType == Qgis::GeometryType::Polygon ? Qgis::BrowserLayerType::Polygon : - geometryType == Qgis::GeometryType::Line ? Qgis::BrowserLayerType::Line - : geometryType == Qgis::GeometryType::Point ? Qgis::BrowserLayerType::Point : - geometryType == Qgis::GeometryType::Null ? Qgis::BrowserLayerType::TableLayer : Qgis::BrowserLayerType::Vector ); + layerItem = std::make_unique( parent, url, name, crs, authcfg, headers, urlPrefix, geometryType == Qgis::GeometryType::Polygon ? Qgis::BrowserLayerType::Polygon : geometryType == Qgis::GeometryType::Line ? Qgis::BrowserLayerType::Line + : geometryType == Qgis::GeometryType::Point ? Qgis::BrowserLayerType::Point + : geometryType == Qgis::GeometryType::Null ? Qgis::BrowserLayerType::TableLayer + : Qgis::BrowserLayerType::Vector ); break; case QgsArcGisRestQueryUtils::ServiceTypeFilter::Raster: - layerItem = std::make_unique< QgsArcGisMapServiceLayerItem >( parent, url, id, name, crs, format, authcfg, headers, urlPrefix ); - static_cast< QgsArcGisMapServiceLayerItem * >( layerItem.get() )->setSupportedFormats( supportedFormats ); + layerItem = std::make_unique( parent, url, id, name, crs, format, authcfg, headers, urlPrefix ); + static_cast( layerItem.get() )->setSupportedFormats( supportedFormats ); break; case QgsArcGisRestQueryUtils::ServiceTypeFilter::AllTypes: @@ -161,8 +158,8 @@ void addLayerItems( QVector< QgsDataItem * > &items, const QVariantMap &serviceD if ( layerItem ) layerItems.insert( id, layerItem.release() ); } - - }, serviceData, parentUrl, supportedFormats, serviceTypeFilter ); + }, + serviceData, parentUrl, supportedFormats, serviceTypeFilter ); // create groups for ( auto it = layerItems.constBegin(); it != layerItems.constEnd(); ++it ) @@ -215,7 +212,7 @@ QVector QgsArcGisRestConnectionItem::createChildren() { if ( !errorMessage.isEmpty() ) { - std::unique_ptr< QgsErrorItem > error = std::make_unique< QgsErrorItem >( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); + std::unique_ptr error = std::make_unique( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); error->setToolTip( errorMessage ); items.append( error.release() ); QgsDebugError( "Connection failed - " + errorMessage ); @@ -272,7 +269,7 @@ QVector QgsArcGisPortalGroupsItem::createChildren() { if ( !errorMessage.isEmpty() ) { - std::unique_ptr< QgsErrorItem > error = std::make_unique< QgsErrorItem >( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); + std::unique_ptr error = std::make_unique( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); error->setToolTip( errorMessage ); items.append( error.release() ); QgsDebugError( "Connection failed - " + errorMessage ); @@ -283,9 +280,7 @@ QVector QgsArcGisPortalGroupsItem::createChildren() for ( const QVariant &group : groups ) { const QVariantMap groupData = group.toMap(); - items << new QgsArcGisPortalGroupItem( this, groupData.value( QStringLiteral( "id" ) ).toString(), - groupData.value( QStringLiteral( "title" ) ).toString(), - mAuthCfg, mHeaders, mUrlPrefix, mPortalCommunityEndpoint, mPortalContentEndpoint ); + items << new QgsArcGisPortalGroupItem( this, groupData.value( QStringLiteral( "id" ) ).toString(), groupData.value( QStringLiteral( "title" ) ).toString(), mAuthCfg, mHeaders, mUrlPrefix, mPortalCommunityEndpoint, mPortalContentEndpoint ); items.last()->setToolTip( groupData.value( QStringLiteral( "snippet" ) ).toString() ); } @@ -322,15 +317,12 @@ QVector QgsArcGisPortalGroupItem::createChildren() QString errorTitle; QString errorMessage; - const QVariantList groupItems = QgsArcGisPortalUtils::retrieveGroupItemsOfType( mPortalContentEndpoint, mId, mAuthCfg, QList() << static_cast< int >( Qgis::ArcGisRestServiceType::FeatureServer ) - << static_cast< int >( Qgis::ArcGisRestServiceType::MapServer ) - << static_cast< int >( Qgis::ArcGisRestServiceType::ImageServer ), - errorTitle, errorMessage, mHeaders ); + const QVariantList groupItems = QgsArcGisPortalUtils::retrieveGroupItemsOfType( mPortalContentEndpoint, mId, mAuthCfg, QList() << static_cast( Qgis::ArcGisRestServiceType::FeatureServer ) << static_cast( Qgis::ArcGisRestServiceType::MapServer ) << static_cast( Qgis::ArcGisRestServiceType::ImageServer ), errorTitle, errorMessage, mHeaders ); if ( groupItems.isEmpty() ) { if ( !errorMessage.isEmpty() ) { - std::unique_ptr< QgsErrorItem > error = std::make_unique< QgsErrorItem >( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); + std::unique_ptr error = std::make_unique( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); error->setToolTip( errorMessage ); items.append( error.release() ); QgsDebugError( "Connection failed - " + errorMessage ); @@ -344,15 +336,11 @@ QVector QgsArcGisPortalGroupItem::createChildren() if ( itemData.value( QStringLiteral( "type" ) ).toString().compare( QStringLiteral( "Feature Service" ), Qt::CaseInsensitive ) == 0 ) { - items << new QgsArcGisFeatureServiceItem( this, itemData.value( QStringLiteral( "title" ) ).toString(), - itemData.value( QStringLiteral( "url" ) ).toString(), - itemData.value( QStringLiteral( "url" ) ).toString(), mAuthCfg, mHeaders, mUrlPrefix ); + items << new QgsArcGisFeatureServiceItem( this, itemData.value( QStringLiteral( "title" ) ).toString(), itemData.value( QStringLiteral( "url" ) ).toString(), itemData.value( QStringLiteral( "url" ) ).toString(), mAuthCfg, mHeaders, mUrlPrefix ); } else { - items << new QgsArcGisMapServiceItem( this, itemData.value( QStringLiteral( "title" ) ).toString(), - itemData.value( QStringLiteral( "url" ) ).toString(), - itemData.value( QStringLiteral( "url" ) ).toString(), mAuthCfg, mHeaders, mUrlPrefix, itemData.value( QStringLiteral( "type" ) ).toString().compare( QStringLiteral( "Map Service" ), Qt::CaseInsensitive ) == 0 ? Qgis::ArcGisRestServiceType::MapServer : Qgis::ArcGisRestServiceType::ImageServer ); + items << new QgsArcGisMapServiceItem( this, itemData.value( QStringLiteral( "title" ) ).toString(), itemData.value( QStringLiteral( "url" ) ).toString(), itemData.value( QStringLiteral( "url" ) ).toString(), mAuthCfg, mHeaders, mUrlPrefix, itemData.value( QStringLiteral( "type" ) ).toString().compare( QStringLiteral( "Map Service" ), Qt::CaseInsensitive ) == 0 ? Qgis::ArcGisRestServiceType::MapServer : Qgis::ArcGisRestServiceType::ImageServer ); } } @@ -390,7 +378,7 @@ QVector QgsArcGisRestServicesItem::createChildren() { if ( !errorMessage.isEmpty() ) { - std::unique_ptr< QgsErrorItem > error = std::make_unique< QgsErrorItem >( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); + std::unique_ptr error = std::make_unique( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); error->setToolTip( errorMessage ); items.append( error.release() ); QgsDebugError( "Connection failed - " + errorMessage ); @@ -411,7 +399,6 @@ bool QgsArcGisRestServicesItem::equal( const QgsDataItem *other ) } - // // QgsArcGisRestFolderItem // @@ -444,7 +431,7 @@ QVector QgsArcGisRestFolderItem::createChildren() { if ( !errorMessage.isEmpty() ) { - std::unique_ptr< QgsErrorItem > error = std::make_unique< QgsErrorItem >( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); + std::unique_ptr error = std::make_unique( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); error->setToolTip( errorMessage ); items.append( error.release() ); QgsDebugError( "Connection failed - " + errorMessage ); @@ -495,7 +482,7 @@ QVector QgsArcGisFeatureServiceItem::createChildren() { if ( !errorMessage.isEmpty() ) { - std::unique_ptr< QgsErrorItem > error = std::make_unique< QgsErrorItem >( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); + std::unique_ptr error = std::make_unique( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); error->setToolTip( errorMessage ); items.append( error.release() ); QgsDebugError( "Connection failed - " + errorMessage ); @@ -544,7 +531,7 @@ QVector QgsArcGisMapServiceItem::createChildren() { if ( !errorMessage.isEmpty() ) { - std::unique_ptr< QgsErrorItem > error = std::make_unique< QgsErrorItem >( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); + std::unique_ptr error = std::make_unique( this, tr( "Connection failed: %1" ).arg( errorTitle ), mPath + "/error" ); error->setToolTip( errorMessage ); items.append( error.release() ); QgsDebugError( "Connection failed - " + errorMessage ); @@ -552,9 +539,8 @@ QVector QgsArcGisMapServiceItem::createChildren() return items; } - const QString supportedFormats = mServiceType == Qgis::ArcGisRestServiceType::ImageServer ? - QStringLiteral( "JPGPNG,PNG,PNG8,PNG24,JPG,BMP,GIF,TIFF,PNG32,BIP,BSQ,LERC" ) // ImageServer supported formats - : serviceData.value( QStringLiteral( "supportedImageFormatTypes" ) ).toString(); + const QString supportedFormats = mServiceType == Qgis::ArcGisRestServiceType::ImageServer ? QStringLiteral( "JPGPNG,PNG,PNG8,PNG24,JPG,BMP,GIF,TIFF,PNG32,BIP,BSQ,LERC" ) // ImageServer supported formats + : serviceData.value( QStringLiteral( "supportedImageFormatTypes" ) ).toString(); addFolderItems( items, serviceData, mBaseUrl, mAuthCfg, mHeaders, mUrlPrefix, this, supportedFormats ); addServiceItems( items, serviceData, mBaseUrl, mAuthCfg, mHeaders, mUrlPrefix, this, supportedFormats ); @@ -576,7 +562,6 @@ QgsArcGisRestLayerItem::QgsArcGisRestLayerItem( QgsDataItem *parent, const QStri : QgsLayerItem( parent, title, url, QString(), layerType, providerId ) , mCrs( crs ) { - } QgsCoordinateReferenceSystem QgsArcGisRestLayerItem::crs() const @@ -685,4 +670,3 @@ QgsDataItem *QgsArcGisRestDataItemProvider::createDataItem( const QString &path, return nullptr; } - diff --git a/src/providers/arcgisrest/qgsarcgisrestdataitems.h b/src/providers/arcgisrest/qgsarcgisrestdataitems.h index 76404d3151bf..5e70d11d4a2a 100644 --- a/src/providers/arcgisrest/qgsarcgisrestdataitems.h +++ b/src/providers/arcgisrest/qgsarcgisrestdataitems.h @@ -77,8 +77,7 @@ class QgsArcGisPortalGroupsItem : public QgsDataCollectionItem { Q_OBJECT public: - QgsArcGisPortalGroupsItem( QgsDataItem *parent, const QString &path, const QString &authcfg, const QgsHttpHeaders &headers, - const QString &urlPrefix, const QString &communityEndpoint, const QString &contentEndpoint ); + QgsArcGisPortalGroupsItem( QgsDataItem *parent, const QString &path, const QString &authcfg, const QgsHttpHeaders &headers, const QString &urlPrefix, const QString &communityEndpoint, const QString &contentEndpoint ); QVector createChildren() override; bool equal( const QgsDataItem *other ) override; @@ -100,8 +99,7 @@ class QgsArcGisPortalGroupItem : public QgsDataCollectionItem { Q_OBJECT public: - QgsArcGisPortalGroupItem( QgsDataItem *parent, const QString &groupId, const QString &name, const QString &authcfg, const QgsHttpHeaders &headers, - const QString &urlPrefix, const QString &communityEndpoint, const QString &contentEndpoint ); + QgsArcGisPortalGroupItem( QgsDataItem *parent, const QString &groupId, const QString &name, const QString &authcfg, const QgsHttpHeaders &headers, const QString &urlPrefix, const QString &communityEndpoint, const QString &contentEndpoint ); QVector createChildren() override; bool equal( const QgsDataItem *other ) override; @@ -219,16 +217,13 @@ class QgsArcGisRestParentLayerItem : public QgsDataItem { Q_OBJECT public: - QgsArcGisRestParentLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &authcfg, const QgsHttpHeaders &headers, const QString &urlPrefix ); bool equal( const QgsDataItem *other ) override; private: - QString mAuthCfg; QgsHttpHeaders mHeaders; QString mUrlPrefix; - }; /** @@ -239,9 +234,7 @@ class QgsArcGisRestLayerItem : public QgsLayerItem Q_OBJECT public: - - QgsArcGisRestLayerItem( QgsDataItem *parent, const QString &url, const QString &title, const QgsCoordinateReferenceSystem &crs, - Qgis::BrowserLayerType layerType, const QString &providerId ); + QgsArcGisRestLayerItem( QgsDataItem *parent, const QString &url, const QString &title, const QgsCoordinateReferenceSystem &crs, Qgis::BrowserLayerType layerType, const QString &providerId ); /** * Returns the CRS for the layer. @@ -249,7 +242,6 @@ class QgsArcGisRestLayerItem : public QgsLayerItem QgsCoordinateReferenceSystem crs() const; private: - QgsCoordinateReferenceSystem mCrs; }; @@ -262,10 +254,7 @@ class QgsArcGisFeatureServiceLayerItem : public QgsArcGisRestLayerItem Q_OBJECT public: - - QgsArcGisFeatureServiceLayerItem( QgsDataItem *parent, const QString &url, const QString &title, const QgsCoordinateReferenceSystem &crs, const QString &authcfg, const QgsHttpHeaders &headers, - const QString urlPrefix, Qgis::BrowserLayerType geometryType ); - + QgsArcGisFeatureServiceLayerItem( QgsDataItem *parent, const QString &url, const QString &title, const QgsCoordinateReferenceSystem &crs, const QString &authcfg, const QgsHttpHeaders &headers, const QString urlPrefix, Qgis::BrowserLayerType geometryType ); }; /** @@ -282,7 +271,6 @@ class QgsArcGisMapServiceLayerItem : public QgsArcGisRestLayerItem QString supportedFormats() const { return mSupportedFormats; } private: - QString mSupportedFormats; }; @@ -291,7 +279,6 @@ class QgsArcGisMapServiceLayerItem : public QgsArcGisRestLayerItem class QgsArcGisRestDataItemProvider : public QgsDataItemProvider { public: - QgsArcGisRestDataItemProvider(); QString name() override; diff --git a/src/providers/arcgisrest/qgsarcgisrestprovidergui.cpp b/src/providers/arcgisrest/qgsarcgisrestprovidergui.cpp index f2c2f588a62c..e939bc7b2eb2 100644 --- a/src/providers/arcgisrest/qgsarcgisrestprovidergui.cpp +++ b/src/providers/arcgisrest/qgsarcgisrestprovidergui.cpp @@ -30,7 +30,6 @@ class QgsArcGisRestSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QgsAfsProvider::AFS_PROVIDER_KEY; } QString text() const override { return QObject::tr( "ArcGIS REST Server" ); } int ordering() const override { return QgsSourceSelectProvider::OrderRemoteProvider + 150; } @@ -44,7 +43,8 @@ class QgsArcGisRestSourceSelectProvider : public QgsSourceSelectProvider class QgsArcGisRestSourceWidgetProvider : public QgsProviderSourceWidgetProvider { public: - QgsArcGisRestSourceWidgetProvider() : QgsProviderSourceWidgetProvider() {} + QgsArcGisRestSourceWidgetProvider() + : QgsProviderSourceWidgetProvider() {} QString providerKey() const override { return QgsAfsProvider::AFS_PROVIDER_KEY; diff --git a/src/providers/arcgisrest/qgsarcgisrestprovidergui.h b/src/providers/arcgisrest/qgsarcgisrestprovidergui.h index cb001e01d950..91f0a541c99d 100644 --- a/src/providers/arcgisrest/qgsarcgisrestprovidergui.h +++ b/src/providers/arcgisrest/qgsarcgisrestprovidergui.h @@ -17,7 +17,7 @@ #include "qgssourceselectprovider.h" #include "qgsafsprovider.h" -class QgsArcGisRestProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsArcGisRestProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsArcGisRestProviderGuiMetadata(); diff --git a/src/providers/arcgisrest/qgsarcgisrestsourceselect.cpp b/src/providers/arcgisrest/qgsarcgisrestsourceselect.cpp index be4abce0810c..4e4c946f13d1 100644 --- a/src/providers/arcgisrest/qgsarcgisrestsourceselect.cpp +++ b/src/providers/arcgisrest/qgsarcgisrestsourceselect.cpp @@ -47,7 +47,6 @@ QgsArcGisRestBrowserProxyModel::QgsArcGisRestBrowserProxyModel( QObject *parent ) : QgsBrowserProxyModel( parent ) { - } void QgsArcGisRestBrowserProxyModel::setConnectionName( const QString &name ) @@ -62,7 +61,7 @@ bool QgsArcGisRestBrowserProxyModel::filterAcceptsRow( int sourceRow, const QMod return false; const QModelIndex sourceIndex = mModel->index( sourceRow, 0, sourceParent ); - if ( QgsArcGisRestConnectionItem *connectionItem = qobject_cast< QgsArcGisRestConnectionItem * >( mModel->dataItem( sourceIndex ) ) ) + if ( QgsArcGisRestConnectionItem *connectionItem = qobject_cast( mModel->dataItem( sourceIndex ) ) ) { if ( connectionItem->name() != mConnectionName ) return false; @@ -156,7 +155,7 @@ QString QgsArcGisRestSourceSelect::getSelectedImageEncoding() const void QgsArcGisRestSourceSelect::showEvent( QShowEvent * ) { - if ( QgsBrowserGuiModel *model = qobject_cast< QgsBrowserGuiModel * >( browserModel() ) ) + if ( QgsBrowserGuiModel *model = qobject_cast( browserModel() ) ) { mBrowserModel = model; } @@ -182,8 +181,7 @@ void QgsArcGisRestSourceSelect::showEvent( QShowEvent * ) mBrowserView->expand( mProxyModel->index( 0, 0 ) ); mBrowserView->setHeaderHidden( true ); - mProxyModel->setShownDataItemProviderKeyFilter( QStringList() << QStringLiteral( "AFS" ) << QStringLiteral( "arcgisfeatureserver" ) - << QStringLiteral( "AMS" ) << QStringLiteral( "arcgismapserver" ) ); + mProxyModel->setShownDataItemProviderKeyFilter( QStringList() << QStringLiteral( "AFS" ) << QStringLiteral( "arcgisfeatureserver" ) << QStringLiteral( "AMS" ) << QStringLiteral( "arcgismapserver" ) ); const QModelIndex afsSourceIndex = mBrowserModel->findPath( QStringLiteral( "arcgisfeatureserver:" ) ); mBrowserView->setRootIndex( mProxyModel->mapFromSource( afsSourceIndex ) ); @@ -247,7 +245,7 @@ void QgsArcGisRestSourceSelect::deleteEntryOfServerList() { const QString selectedConnection = cmbConnections->currentText(); const QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ) - .arg( selectedConnection ); + .arg( selectedConnection ); const QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ); if ( result == QMessageBox::Yes ) { @@ -320,8 +318,7 @@ void QgsArcGisRestSourceSelect::addButtonClicked() QgsCoordinateTransform extentTransform = QgsCoordinateTransform( canvasCrs, crs, QgsProject::instance()->transformContext() ); extentTransform.setBallparkTransformsAreAppropriate( true ); extent = extentTransform.transformBoundingBox( extent ); - QgsDebugMsgLevel( QStringLiteral( "canvas transform: Canvas CRS=%1, Provider CRS=%2, BBOX=%3" ) - .arg( canvasCrs.authid(), crs.authid(), extent.asWktCoordinates() ), 3 ); + QgsDebugMsgLevel( QStringLiteral( "canvas transform: Canvas CRS=%1, Provider CRS=%2, BBOX=%3" ).arg( canvasCrs.authid(), crs.authid(), extent.asWktCoordinates() ), 3 ); } catch ( const QgsCsException & ) { @@ -362,7 +359,6 @@ void QgsArcGisRestSourceSelect::addButtonClicked() // Clear selection after layers have been added mBrowserView->selectionModel()->clearSelection(); - } void QgsArcGisRestSourceSelect::updateCrsLabel() @@ -382,7 +378,7 @@ void QgsArcGisRestSourceSelect::updateImageEncodings() return; } - if ( QgsArcGisMapServiceLayerItem *layerItem = qobject_cast< QgsArcGisMapServiceLayerItem * >( mBrowserModel->dataItem( sourceIndex ) ) ) + if ( QgsArcGisMapServiceLayerItem *layerItem = qobject_cast( mBrowserModel->dataItem( sourceIndex ) ) ) { populateImageEncodings( layerItem->supportedFormats() ); } @@ -411,7 +407,7 @@ void QgsArcGisRestSourceSelect::treeWidgetCurrentRowChanged( const QModelIndex & const QModelIndex sourceIndex = mProxyModel->mapToSource( currentIndex ); if ( sourceIndex.isValid() ) { - if ( qobject_cast< QgsArcGisFeatureServiceLayerItem * >( mBrowserModel->dataItem( sourceIndex ) ) ) + if ( qobject_cast( mBrowserModel->dataItem( sourceIndex ) ) ) { enableFilter = true; } @@ -481,8 +477,7 @@ void QgsArcGisRestSourceSelect::btnSave_clicked() void QgsArcGisRestSourceSelect::btnLoad_clicked() { - const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -550,7 +545,7 @@ QgsDataItem *QgsArcGisRestSourceSelect::indexToItem( const QModelIndex &proxyInd QgsCoordinateReferenceSystem QgsArcGisRestSourceSelect::indexToCrs( const QModelIndex &proxyIndex ) { - if ( QgsArcGisRestLayerItem *layerItem = qobject_cast< QgsArcGisRestLayerItem * >( indexToItem( proxyIndex ) ) ) + if ( QgsArcGisRestLayerItem *layerItem = qobject_cast( indexToItem( proxyIndex ) ) ) { return layerItem->crs(); } @@ -566,12 +561,12 @@ QString QgsArcGisRestSourceSelect::indexToUri( const QModelIndex &proxyIndex, QS if ( !item ) return QString(); - if ( QgsArcGisRestLayerItem *layerItem = qobject_cast< QgsArcGisRestLayerItem * >( item ) ) + if ( QgsArcGisRestLayerItem *layerItem = qobject_cast( item ) ) { layerName = layerItem->name(); QgsDataSourceUri uri( layerItem->uri() ); - if ( qobject_cast< QgsArcGisFeatureServiceLayerItem *>( layerItem ) ) + if ( qobject_cast( layerItem ) ) { if ( !extent.isNull() ) { @@ -579,7 +574,7 @@ QString QgsArcGisRestSourceSelect::indexToUri( const QModelIndex &proxyIndex, QS } serviceType = Qgis::ArcGisRestServiceType::FeatureServer; } - else if ( qobject_cast< QgsArcGisMapServiceLayerItem *>( layerItem ) ) + else if ( qobject_cast( layerItem ) ) { uri.removeParam( QStringLiteral( "format" ) ); uri.setParam( QStringLiteral( "format" ), getSelectedImageEncoding() ); @@ -592,4 +587,3 @@ QString QgsArcGisRestSourceSelect::indexToUri( const QModelIndex &proxyIndex, QS return QString(); } } - diff --git a/src/providers/arcgisrest/qgsarcgisrestsourceselect.h b/src/providers/arcgisrest/qgsarcgisrestsourceselect.h index 58403b35d52a..dac37f67e936 100644 --- a/src/providers/arcgisrest/qgsarcgisrestsourceselect.h +++ b/src/providers/arcgisrest/qgsarcgisrestsourceselect.h @@ -40,14 +40,12 @@ class QgsArcGisRestBrowserProxyModel : public QgsBrowserProxyModel Q_OBJECT public: - explicit QgsArcGisRestBrowserProxyModel( QObject *parent SIP_TRANSFERTHIS = nullptr ); void setConnectionName( const QString &name ); bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override; private: - QString mConnectionName; }; @@ -59,7 +57,6 @@ class QgsArcGisRestSourceSelect : public QgsAbstractDataSourceWidget, protected Q_OBJECT public: - //! Constructor QgsArcGisRestSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Standalone ); @@ -67,7 +64,6 @@ class QgsArcGisRestSourceSelect : public QgsAbstractDataSourceWidget, protected ~QgsArcGisRestSourceSelect() override; protected: - QgsBrowserGuiModel *mBrowserModel = nullptr; QgsArcGisRestBrowserProxyModel *mProxyModel = nullptr; @@ -109,7 +105,6 @@ class QgsArcGisRestSourceSelect : public QgsAbstractDataSourceWidget, protected void refreshModel( const QModelIndex &index ); private: - QgsDataItem *indexToItem( const QModelIndex &proxyIndex ); QgsCoordinateReferenceSystem indexToCrs( const QModelIndex &proxyIndex ); diff --git a/src/providers/arcgisrest/qgsarcgisrestsourcewidget.cpp b/src/providers/arcgisrest/qgsarcgisrestsourcewidget.cpp index 463eda6c665f..4fe56a7839b1 100644 --- a/src/providers/arcgisrest/qgsarcgisrestsourcewidget.cpp +++ b/src/providers/arcgisrest/qgsarcgisrestsourcewidget.cpp @@ -104,4 +104,3 @@ QString QgsArcGisRestSourceWidget::referer() const { return mEditReferer->text(); } - diff --git a/src/providers/arcgisrest/qgsarcgisrestsourcewidget.h b/src/providers/arcgisrest/qgsarcgisrestsourcewidget.h index 88c66d4cb674..e8c1cc02c7eb 100644 --- a/src/providers/arcgisrest/qgsarcgisrestsourcewidget.h +++ b/src/providers/arcgisrest/qgsarcgisrestsourcewidget.h @@ -43,7 +43,6 @@ class QgsArcGisRestSourceWidget : public QgsProviderSourceWidget, private Ui::Qg QString referer() const; private: - const QString mProviderKey; QVariantMap mSourceParts; }; diff --git a/src/providers/arcgisrest/qgsnewarcgisrestconnection.cpp b/src/providers/arcgisrest/qgsnewarcgisrestconnection.cpp index e2a8cbbcd28e..6963fa90d41a 100644 --- a/src/providers/arcgisrest/qgsnewarcgisrestconnection.cpp +++ b/src/providers/arcgisrest/qgsnewarcgisrestconnection.cpp @@ -113,21 +113,12 @@ bool QgsNewArcGisRestConnectionDialog::validate() bool newNameAlreadyExists = QgsArcGisConnectionSettings::sTreeConnectionArcgis->items().contains( newName ); // warn if entry was renamed to an existing connection - if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( newName, Qt::CaseInsensitive ) != 0 ) && - newNameAlreadyExists && - QMessageBox::question( this, - tr( "Save Connection" ), - tr( "Should the existing connection '%1' be overwritten?" ).arg( newName ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( newName, Qt::CaseInsensitive ) != 0 ) && newNameAlreadyExists && QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection '%1' be overwritten?" ).arg( newName ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return false; } - if ( ! mAuthSettings->password().isEmpty() && - QMessageBox::question( this, - tr( "Saving Passwords" ), - tr( "WARNING: You have entered a password. It will be stored in unsecured plain text in your project files and your home directory (Unix-like OS) or user profile (Windows). If you want to avoid this, press Cancel and either:\n\na) Don't provide a password in the connection settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your credentials in an HTTP Basic Authentication method and store them in an encrypted database." ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( !mAuthSettings->password().isEmpty() && QMessageBox::question( this, tr( "Saving Passwords" ), tr( "WARNING: You have entered a password. It will be stored in unsecured plain text in your project files and your home directory (Unix-like OS) or user profile (Windows). If you want to avoid this, press Cancel and either:\n\na) Don't provide a password in the connection settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your credentials in an HTTP Basic Authentication method and store them in an encrypted database." ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return false; } @@ -139,8 +130,8 @@ QUrl QgsNewArcGisRestConnectionDialog::urlTrimmed() const { QUrl url( txtUrl->text().trimmed() ); const QUrlQuery query( url ); - const QList > items = query.queryItems( QUrl::FullyEncoded ); - QHash< QString, QPair > params; + const QList> items = query.queryItems( QUrl::FullyEncoded ); + QHash> params; for ( const QPair &it : items ) { params.insert( it.first.toUpper(), it ); diff --git a/src/providers/arcgisrest/qgsnewarcgisrestconnection.h b/src/providers/arcgisrest/qgsnewarcgisrestconnection.h index a03fcd6c01bd..d714772810b3 100644 --- a/src/providers/arcgisrest/qgsnewarcgisrestconnection.h +++ b/src/providers/arcgisrest/qgsnewarcgisrestconnection.h @@ -34,13 +34,10 @@ class QgsNewArcGisRestConnectionDialog : public QDialog, private Ui::QgsNewArcGi Q_OBJECT public: - /** * Constructor for QgsNewArcGisRestConnectionDialog. */ - QgsNewArcGisRestConnectionDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, - const QString &connectionName = QString(), - Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); + QgsNewArcGisRestConnectionDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QString &connectionName = QString(), Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); /** * Returns the current connection name. @@ -63,7 +60,6 @@ class QgsNewArcGisRestConnectionDialog : public QDialog, private Ui::QgsNewArcGi void updateOkButtonState(); protected: - /** * Returns TRUE if dialog settings are valid, or FALSE if current * settings are not valid and the dialog should not be acceptable. @@ -78,7 +74,6 @@ class QgsNewArcGisRestConnectionDialog : public QDialog, private Ui::QgsNewArcGi private: QString mOriginalConnName; //store initial name to delete entry in case of rename void showHelp(); - }; #endif // QGSNEWARCGISRESTCONNECTION_H diff --git a/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp b/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp index 213b67b4f870..46b1b202d6d3 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp @@ -33,7 +33,6 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe : QgsAbstractFeatureIteratorFromSource( source, ownSource, request ) , mTestSubset( mSource->mSubsetExpression ) { - // Determine mode to use based on request... QgsDebugMsgLevel( QStringLiteral( "Setting up QgsDelimitedTextIterator" ), 4 ); @@ -63,7 +62,7 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe && mSource->mGeomRep == QgsDelimitedTextProvider::GeomAsWkt; // If request doesn't overlap extents, then nothing to return - if ( ! mFilterRect.intersects( mSource->mExtent.toRectangle() ) && !mTestSubset ) + if ( !mFilterRect.intersects( mSource->mExtent.toRectangle() ) && !mTestSubset ) { QgsDebugMsgLevel( QStringLiteral( "Rectangle outside layer extents - no features to return" ), 4 ); mMode = FeatureIds; @@ -148,14 +147,7 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe // if we are testing geometry (ie spatial filter), or // if testing the subset expression. if ( hasGeometry - && ( - !( mRequest.flags() & Qgis::FeatureRequestFlag::NoGeometry ) - || mTestGeometry - || mDistanceWithinEngine - || ( mTestSubset && mSource->mSubsetExpression->needsGeometry() ) - || ( request.filterType() == Qgis::FeatureRequestFilterType::Expression && request.filterExpression()->needsGeometry() ) - ) - ) + && ( !( mRequest.flags() & Qgis::FeatureRequestFlag::NoGeometry ) || mTestGeometry || mDistanceWithinEngine || ( mTestSubset && mSource->mSubsetExpression->needsGeometry() ) || ( request.filterType() == Qgis::FeatureRequestFilterType::Expression && request.filterExpression()->needsGeometry() ) ) ) { mLoadGeometry = true; } @@ -216,7 +208,7 @@ bool QgsDelimitedTextFeatureIterator::fetchFeature( QgsFeature &feature ) } else { - while ( ! gotFeature ) + while ( !gotFeature ) { qint64 fid = -1; if ( mMode == FeatureIds ) @@ -405,7 +397,7 @@ bool QgsDelimitedTextFeatureIterator::nextFeatureInternal( QgsFeature &feature ) // If we are testing subset expression, then need all attributes just in case. // Could be more sophisticated, but probably not worth it! - if ( ! mTestSubset && ( mRequest.flags() & Qgis::FeatureRequestFlag::SubsetOfAttributes ) ) + if ( !mTestSubset && ( mRequest.flags() & Qgis::FeatureRequestFlag::SubsetOfAttributes ) ) { const QgsAttributeList attrs = mRequest.subsetOfAttributes(); for ( QgsAttributeList::const_iterator i = attrs.constBegin(); i != attrs.constEnd(); ++i ) @@ -428,13 +420,12 @@ bool QgsDelimitedTextFeatureIterator::nextFeatureInternal( QgsFeature &feature ) const QVariant isOk = mSource->mSubsetExpression->evaluate( &mSource->mExpressionContext ); if ( mSource->mSubsetExpression->hasEvalError() ) continue; - if ( ! isOk.toBool() ) + if ( !isOk.toBool() ) continue; } // We have a good record, so return return true; - } return false; @@ -462,7 +453,7 @@ QgsGeometry QgsDelimitedTextFeatureIterator::loadGeometryWkt( const QStringList { geom = QgsGeometry(); } - if ( !geom.isNull() && ! testSpatialFilter( geom ) ) + if ( !geom.isNull() && !testSpatialFilter( geom ) ) { geom = QgsGeometry(); } @@ -515,11 +506,11 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature &feature, int f case QMetaType::Type::Bool: { Q_ASSERT( mSource->mFieldBooleanLiterals.contains( fieldIdx ) ); - if ( value.compare( mSource->mFieldBooleanLiterals[ fieldIdx ].first, Qt::CaseSensitivity::CaseInsensitive ) == 0 ) + if ( value.compare( mSource->mFieldBooleanLiterals[fieldIdx].first, Qt::CaseSensitivity::CaseInsensitive ) == 0 ) { val = true; } - else if ( value.compare( mSource->mFieldBooleanLiterals[ fieldIdx ].second, Qt::CaseSensitivity::CaseInsensitive ) == 0 ) + else if ( value.compare( mSource->mFieldBooleanLiterals[fieldIdx].second, Qt::CaseSensitivity::CaseInsensitive ) == 0 ) { val = false; } @@ -533,7 +524,7 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature &feature, int f { int ivalue = 0; bool ok = false; - if ( ! value.isEmpty() ) + if ( !value.isEmpty() ) ivalue = value.toInt( &ok ); if ( ok ) val = QVariant( ivalue ); @@ -543,11 +534,11 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature &feature, int f } case QMetaType::Type::LongLong: { - if ( ! value.isEmpty() ) + if ( !value.isEmpty() ) { bool ok; val = value.toLongLong( &ok ); - if ( ! ok ) + if ( !ok ) { val = QgsVariantUtils::createNullVariant( mSource->mFields.at( fieldIdx ).type() ); } @@ -562,7 +553,7 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature &feature, int f { double dvalue = 0.0; bool ok = false; - if ( ! value.isEmpty() ) + if ( !value.isEmpty() ) { if ( mSource->mDecimalPoint.isEmpty() ) { diff --git a/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.h b/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.h index 05bb5cbd2dac..8d3898080c64 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.h +++ b/src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.h @@ -23,7 +23,7 @@ #include "qgsdelimitedtextprovider.h" -class QgsDelimitedTextFeatureSource final: public QgsAbstractFeatureSource +class QgsDelimitedTextFeatureSource final : public QgsAbstractFeatureSource { public: explicit QgsDelimitedTextFeatureSource( const QgsDelimitedTextProvider *p ); @@ -32,16 +32,16 @@ class QgsDelimitedTextFeatureSource final: public QgsAbstractFeatureSource private: QgsDelimitedTextProvider::GeomRepresentationType mGeomRep; - std::unique_ptr< QgsExpression > mSubsetExpression; + std::unique_ptr mSubsetExpression; QgsExpressionContext mExpressionContext; QgsBox3D mExtent; bool mUseSpatialIndex; - std::unique_ptr< QgsSpatialIndex > mSpatialIndex; + std::unique_ptr mSpatialIndex; bool mUseSubsetIndex; QList mSubsetIndex; - std::unique_ptr< QgsDelimitedTextFile > mFile; + std::unique_ptr mFile; QgsFields mFields; - int mFieldCount; // Note: this includes field count for wkt field + int mFieldCount; // Note: this includes field count for wkt field int mXFieldIndex; int mYFieldIndex; int mZFieldIndex; @@ -59,7 +59,7 @@ class QgsDelimitedTextFeatureSource final: public QgsAbstractFeatureSource }; -class QgsDelimitedTextFeatureIterator final: public QgsAbstractFeatureIteratorFromSource +class QgsDelimitedTextFeatureIterator final : public QgsAbstractFeatureIteratorFromSource { enum IteratorMode { @@ -67,6 +67,7 @@ class QgsDelimitedTextFeatureIterator final: public QgsAbstractFeatureIteratorFr SubsetIndex, FeatureIds }; + public: QgsDelimitedTextFeatureIterator( QgsDelimitedTextFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ); @@ -91,7 +92,6 @@ class QgsDelimitedTextFeatureIterator final: public QgsAbstractFeatureIteratorFr bool fetchFeature( QgsFeature &feature ) override; private: - bool setNextFeatureId( qint64 fid ); bool nextFeatureInternal( QgsFeature &feature ); @@ -110,7 +110,7 @@ class QgsDelimitedTextFeatureIterator final: public QgsAbstractFeatureIteratorFr QgsCoordinateTransform mTransform; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; }; diff --git a/src/providers/delimitedtext/qgsdelimitedtextfile.cpp b/src/providers/delimitedtext/qgsdelimitedtextfile.cpp index 6d971f035a94..9f35beaa9b96 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextfile.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextfile.cpp @@ -40,7 +40,8 @@ QgsDelimitedTextFile::QgsDelimitedTextFile( const QString &url ) mDefaultFieldRegexp.setPatternOptions( QRegularExpression::CaseInsensitiveOption ); // The default type is CSV setTypeCSV(); - if ( ! url.isNull() ) setFromUrl( url ); + if ( !url.isNull() ) + setFromUrl( url ); // For tests const QString bufferSizeStr( getenv( "QGIS_DELIMITED_TEXT_FILE_BUFFER_SIZE" ) ); @@ -78,11 +79,11 @@ void QgsDelimitedTextFile::close() bool QgsDelimitedTextFile::open() { - if ( ! mFile ) + if ( !mFile ) { close(); mFile = new QFile( mFileName ); - if ( ! mFile->open( QIODevice::ReadOnly ) ) + if ( !mFile->open( QIODevice::ReadOnly ) ) { QgsDebugMsgLevel( "Data file " + mFileName + " could not be opened", 2 ); delete mFile; @@ -91,10 +92,10 @@ bool QgsDelimitedTextFile::open() if ( mFile ) { mCodec = QTextCodec::codecForName( !mEncoding.isEmpty() ? mEncoding.toLatin1() : QByteArray( "UTF-8" ) ); - if ( ! mCodec ) + if ( !mCodec ) { QgsDebugMsgLevel( QStringLiteral( "Wrong codec '%1' for %2, falling back to locale default." ).arg( mEncoding, mFileName ), 2 ); - mCodec = QTextCodec::codecForLocale( ); + mCodec = QTextCodec::codecForLocale(); mEncoding = mCodec->name(); } if ( mUseWatcher ) @@ -202,15 +203,15 @@ bool QgsDelimitedTextFile::setFromUrl( const QUrl &url ) } if ( query.hasQueryItem( QStringLiteral( "useHeader" ) ) ) { - mUseHeader = ! query.queryItemValue( QStringLiteral( "useHeader" ) ).toUpper().startsWith( 'N' ); + mUseHeader = !query.queryItemValue( QStringLiteral( "useHeader" ) ).toUpper().startsWith( 'N' ); } if ( query.hasQueryItem( QStringLiteral( "skipEmptyFields" ) ) ) { - mDiscardEmptyFields = ! query.queryItemValue( QStringLiteral( "skipEmptyFields" ) ).toUpper().startsWith( 'N' ); + mDiscardEmptyFields = !query.queryItemValue( QStringLiteral( "skipEmptyFields" ) ).toUpper().startsWith( 'N' ); } if ( query.hasQueryItem( QStringLiteral( "trimFields" ) ) ) { - mTrimFields = ! query.queryItemValue( QStringLiteral( "trimFields" ) ).toUpper().startsWith( 'N' ); + mTrimFields = !query.queryItemValue( QStringLiteral( "trimFields" ) ).toUpper().startsWith( 'N' ); } if ( query.hasQueryItem( QStringLiteral( "maxFields" ) ) ) { @@ -270,15 +271,18 @@ QUrl QgsDelimitedTextFile::url() } if ( mType == DelimTypeCSV ) { - if ( mDelimChars != QLatin1String( "," ) ) query.addQueryItem( QStringLiteral( "delimiter" ), encodeChars( mDelimChars ) ); - if ( mQuoteChar != QLatin1String( "\"" ) ) query.addQueryItem( QStringLiteral( "quote" ), encodeChars( mQuoteChar ) ); - if ( mEscapeChar != QLatin1String( "\"" ) ) query.addQueryItem( QStringLiteral( "escape" ), encodeChars( mEscapeChar ) ); + if ( mDelimChars != QLatin1String( "," ) ) + query.addQueryItem( QStringLiteral( "delimiter" ), encodeChars( mDelimChars ) ); + if ( mQuoteChar != QLatin1String( "\"" ) ) + query.addQueryItem( QStringLiteral( "quote" ), encodeChars( mQuoteChar ) ); + if ( mEscapeChar != QLatin1String( "\"" ) ) + query.addQueryItem( QStringLiteral( "escape" ), encodeChars( mEscapeChar ) ); } if ( mSkipLines > 0 ) { query.addQueryItem( QStringLiteral( "skipLines" ), QString::number( mSkipLines ) ); } - if ( ! mUseHeader ) + if ( !mUseHeader ) { query.addQueryItem( QStringLiteral( "useHeader" ), QStringLiteral( "No" ) ); } @@ -318,9 +322,12 @@ void QgsDelimitedTextFile::setUseWatcher( bool useWatcher ) QString QgsDelimitedTextFile::type() { - if ( mType == DelimTypeWhitespace ) return QStringLiteral( "whitespace" ); - if ( mType == DelimTypeCSV ) return QStringLiteral( "csv" ); - if ( mType == DelimTypeRegexp ) return QStringLiteral( "regexp" ); + if ( mType == DelimTypeWhitespace ) + return QStringLiteral( "whitespace" ); + if ( mType == DelimTypeCSV ) + return QStringLiteral( "csv" ); + if ( mType == DelimTypeRegexp ) + return QStringLiteral( "regexp" ); return QStringLiteral( "csv" ); } @@ -339,7 +346,7 @@ void QgsDelimitedTextFile::setTypeRegexp( const QString ®exp ) mAnchoredRegexp = regexp.startsWith( '^' ); mParser = &QgsDelimitedTextFile::parseRegexp; mDefinitionValid = !regexp.isEmpty() && mDelimRegexp.isValid(); - if ( ! mDefinitionValid ) + if ( !mDefinitionValid ) { QgsDebugMsgLevel( "Invalid regular expression in delimited text file delimiter: " + regexp, 2 ); } @@ -371,7 +378,7 @@ void QgsDelimitedTextFile::setTypeCSV( const QString &delim, const QString " mEscapeChar = decodeChars( escape ); mParser = &QgsDelimitedTextFile::parseQuoted; mDefinitionValid = !mDelimChars.isEmpty(); - if ( ! mDefinitionValid ) + if ( !mDefinitionValid ) { QgsDebugMsgLevel( QStringLiteral( "Invalid empty delimiter defined for text file delimiter" ), 2 ); } @@ -417,7 +424,8 @@ void QgsDelimitedTextFile::setFieldNames( const QStringList &names ) bool nameOk = true; const int fieldNo = mFieldNames.size() + 1; name = name.trimmed(); - if ( name.length() > mMaxNameLength ) name = name.mid( 0, mMaxNameLength ); + if ( name.length() > mMaxNameLength ) + name = name.mid( 0, mMaxNameLength ); // If the name is empty then reset it to default name if ( name.length() == 0 ) @@ -434,11 +442,11 @@ void QgsDelimitedTextFile::setFieldNames( const QStringList &names ) // Otherwise it is valid if isn't the name of an existing field... else { - nameOk = ! mFieldNames.contains( name, Qt::CaseInsensitive ); + nameOk = !mFieldNames.contains( name, Qt::CaseInsensitive ); } // If it is not a valid name then try appending a number to generate // a valid name. - if ( ! nameOk ) + if ( !nameOk ) { int suffix = 0; const QString basename = name + "_%1"; @@ -447,9 +455,11 @@ void QgsDelimitedTextFile::setFieldNames( const QStringList &names ) suffix++; name = basename.arg( suffix ); // Not OK if it is already in the name list - if ( mFieldNames.contains( name, Qt::CaseInsensitive ) ) continue; + if ( mFieldNames.contains( name, Qt::CaseInsensitive ) ) + continue; // Not OK if it is already in proposed names - if ( names.contains( name, Qt::CaseInsensitive ) ) continue; + if ( names.contains( name, Qt::CaseInsensitive ) ) + continue; break; } } @@ -462,7 +472,8 @@ QStringList &QgsDelimitedTextFile::fieldNames() { // If not yet opened then reset file to read column headers // - if ( mUseHeader && ! mFile ) reset(); + if ( mUseHeader && !mFile ) + reset(); // If have read more fields than field names, then append field names // to match the field count (will only happen if parsed some records) if ( mMaxFieldCount > mFieldNames.size() ) @@ -479,7 +490,8 @@ int QgsDelimitedTextFile::fieldIndex( const QString &name ) { // If not yet opened then reset file to read column headers // - if ( mUseHeader && ! mFile ) reset(); + if ( mUseHeader && !mFile ) + reset(); // Try to determine the field based on a default field name, includes // Field_### and simple integer fields. if ( const QRegularExpressionMatch match = mDefaultFieldRegexp.match( name ); match.capturedStart() == 0 ) @@ -488,24 +500,25 @@ int QgsDelimitedTextFile::fieldIndex( const QString &name ) } for ( int i = 0; i < mFieldNames.size(); i++ ) { - if ( mFieldNames[i].compare( name, Qt::CaseInsensitive ) == 0 ) return i; + if ( mFieldNames[i].compare( name, Qt::CaseInsensitive ) == 0 ) + return i; } return -1; - } bool QgsDelimitedTextFile::setNextRecordId( long nextRecordId ) { - if ( ! mFile ) reset(); + if ( !mFile ) + reset(); mHoldCurrentRecord = nextRecordId == mRecordLineNumber; - if ( mHoldCurrentRecord ) return true; + if ( mHoldCurrentRecord ) + return true; return setNextLineNumber( nextRecordId ); } QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextRecord( QStringList &record ) { - record.clear(); Status status = RecordOk; @@ -521,14 +534,16 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextRecord( QStringList &reco // Find the first non-blank line to read QString buffer; status = nextLine( buffer, true ); - if ( status != RecordOk ) return RecordEOF; + if ( status != RecordOk ) + return RecordEOF; mCurrentRecord.clear(); mRecordLineNumber = mLineNumber; if ( mRecordNumber >= 0 ) { mRecordNumber++; - if ( mRecordNumber > mMaxRecordNumber ) mMaxRecordNumber = mRecordNumber; + if ( mRecordNumber > mMaxRecordNumber ) + mMaxRecordNumber = mRecordNumber; } status = ( this->*mParser )( buffer, mCurrentRecord ); } @@ -539,10 +554,11 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextRecord( QStringList &reco return status; } -QgsDelimitedTextFile::Status QgsDelimitedTextFile::reset() +QgsDelimitedTextFile::Status QgsDelimitedTextFile::reset() { // Make sure the file is valid open - if ( ! isValid() || ! open() ) return InvalidDefinition; + if ( !isValid() || !open() ) + return InvalidDefinition; // Reset the file pointer mFile->seek( 0 ); @@ -556,7 +572,8 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::reset() for ( int i = mSkipLines; i-- > 0; ) { QString ignoredContent; - if ( nextLine( ignoredContent ) == RecordEOF ) return RecordEOF; + if ( nextLine( ignoredContent ) == RecordEOF ) + return RecordEOF; } // Read the column names Status result = RecordOk; @@ -566,16 +583,18 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::reset() result = nextRecord( names ); setFieldNames( names ); } - if ( result == RecordOk ) mRecordNumber = 0; + if ( result == RecordOk ) + mRecordNumber = 0; return result; } QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextLine( QString &buffer, bool skipBlank ) { - if ( ! mFile ) + if ( !mFile ) { const Status status = reset(); - if ( status != RecordOk ) return status; + if ( status != RecordOk ) + return status; } if ( mLineNumber == 0 ) { @@ -666,7 +685,8 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextLine( QString &buffer, bo } } mLineNumber++; - if ( skipBlank && buffer.isEmpty() ) continue; + if ( skipBlank && buffer.isEmpty() ) + continue; return RecordOk; } @@ -676,7 +696,8 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::nextLine( QString &buffer, bo bool QgsDelimitedTextFile::setNextLineNumber( long nextLineNumber ) { - if ( ! mFile ) return false; + if ( !mFile ) + return false; if ( mLineNumber > nextLineNumber - 1 ) { mRecordNumber = -1; @@ -686,26 +707,29 @@ bool QgsDelimitedTextFile::setNextLineNumber( long nextLineNumber ) QString buffer; while ( mLineNumber < nextLineNumber - 1 ) { - if ( nextLine( buffer, false ) != RecordOk ) return false; + if ( nextLine( buffer, false ) != RecordOk ) + return false; } return true; - } void QgsDelimitedTextFile::appendField( QStringList &record, QString field, bool quoted ) { - if ( mMaxFields > 0 && record.size() >= mMaxFields ) return; + if ( mMaxFields > 0 && record.size() >= mMaxFields ) + return; if ( quoted ) { record.append( field ); } else { - if ( mTrimFields ) field = field.trimmed(); - if ( !( mDiscardEmptyFields && field.isEmpty() ) ) record.append( field ); + if ( mTrimFields ) + field = field.trimmed(); + if ( !( mDiscardEmptyFields && field.isEmpty() ) ) + record.append( field ); } // Keep track of maximum number of non-empty fields in a record - if ( record.size() > mMaxFieldCount && ! field.isEmpty() ) + if ( record.size() > mMaxFieldCount && !field.isEmpty() ) { mMaxFieldCount = record.size(); } @@ -713,7 +737,6 @@ void QgsDelimitedTextFile::appendField( QStringList &record, QString field, bool QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseRegexp( QString &buffer, QStringList &fields ) { - // If match is anchored, then only interested in records which actually match // and extract capture groups if ( mAnchoredRegexp ) @@ -768,7 +791,8 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseRegexp( QString &buffer, pos = matchPos + matchLen; // Quit loop if we have enough fields. - if ( mMaxFields > 0 && fields.size() >= mMaxFields ) break; + if ( mMaxFields > 0 && fields.size() >= mMaxFields ) + break; } return RecordOk; } @@ -776,13 +800,13 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseRegexp( QString &buffer, QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer, QStringList &fields ) { Status status = RecordOk; - QString field; // String in which to accumulate next field - bool escaped = false; // Next char is escaped - bool quoted = false; // In quotes - QChar quoteChar( 0 ); // Actual quote character used to open quotes - bool started = false; // Non-blank chars in field or quotes started - bool ended = false; // Quoted field ended - int cp = 0; // Pointer to the next character in the buffer + QString field; // String in which to accumulate next field + bool escaped = false; // Next char is escaped + bool quoted = false; // In quotes + QChar quoteChar( 0 ); // Actual quote character used to open quotes + bool started = false; // Non-blank chars in field or quotes started + bool ended = false; // Quoted field ended + int cp = 0; // Pointer to the next character in the buffer int cpmax = buffer.size(); // End of string const bool isSingleCharDelim = mDelimChars.size() == 1; @@ -840,7 +864,7 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer, bool isQuote = false; bool isEscape = false; const bool isDelim = isSingleCharDelim ? firstDelimChar == *c : mDelimChars.contains( *c ); - if ( ! isDelim ) + if ( !isDelim ) { const bool isQuoteChar = isSingleCharQuote ? firstQuoteChar == *c : mQuoteChar.contains( *c ); isQuote = quoted ? *c == quoteChar : isQuoteChar; @@ -871,7 +895,7 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer, } } // quote char at start of field .. start of quoted fields - else if ( ! started ) + else if ( !started ) { field.clear(); quoteChar = *c; @@ -909,7 +933,7 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer, // after the end.. else if ( c->isSpace() ) { - if ( ! ended ) + if ( !ended ) field.append( *c ); } // Other chars permitted if not after quoted field @@ -928,7 +952,6 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer, if ( started ) { appendField( fields, field, ended ); - } return status; } @@ -937,4 +960,3 @@ bool QgsDelimitedTextFile::isValid() { return mDefinitionValid && QFile::exists( mFileName ) && QFileInfo( mFileName ).size() > 0; } - diff --git a/src/providers/delimitedtext/qgsdelimitedtextfile.h b/src/providers/delimitedtext/qgsdelimitedtextfile.h index bbd9fc4955af..3b0924615272 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextfile.h +++ b/src/providers/delimitedtext/qgsdelimitedtextfile.h @@ -74,11 +74,9 @@ class QTextCodec; class QgsDelimitedTextFile : public QObject { - Q_OBJECT public: - enum Status { RecordOk, @@ -355,7 +353,6 @@ class QgsDelimitedTextFile : public QObject void updateFile(); private: - /** * Open the file * @@ -398,7 +395,7 @@ class QgsDelimitedTextFile : public QObject void appendField( QStringList &record, QString field, bool quoted = false ); // Pointer to the currently selected parser - Status( QgsDelimitedTextFile::*mParser )( QString &buffer, QStringList &fields ); + Status ( QgsDelimitedTextFile::*mParser )( QString &buffer, QStringList &fields ); QString mFileName; QString mEncoding; diff --git a/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp b/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp index f15d75b49342..4a32d6f3464e 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp @@ -64,25 +64,16 @@ QRegularExpression QgsDelimitedTextProvider::sCrdDmsRegexp( QStringLiteral( "^\\ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const ProviderOptions &options, Qgis::DataProviderReadFlags flags ) : QgsVectorDataProvider( uri, options, flags ) { - // Add supported types to enable creating expression fields in field calculator - setNativeTypes( QList< NativeType >() - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Int ), QStringLiteral( "integer" ), QMetaType::Type::Int, 0, 10 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::LongLong ), QStringLiteral( "longlong" ), QMetaType::Type::LongLong ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Double ), QStringLiteral( "double" ), QMetaType::Type::Double, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Bool ), QStringLiteral( "bool" ), QMetaType::Type::Bool, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QMetaType::Type::QString, -1, -1, -1, -1 ) - - // date type - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDate ), QStringLiteral( "date" ), QMetaType::Type::QDate, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QTime ), QStringLiteral( "time" ), QMetaType::Type::QTime, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDateTime ), QStringLiteral( "datetime" ), QMetaType::Type::QDateTime, -1, -1, -1, -1 ) - ); + setNativeTypes( QList() << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Int ), QStringLiteral( "integer" ), QMetaType::Type::Int, 0, 10 ) << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::LongLong ), QStringLiteral( "longlong" ), QMetaType::Type::LongLong ) << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Double ), QStringLiteral( "double" ), QMetaType::Type::Double, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Bool ), QStringLiteral( "bool" ), QMetaType::Type::Bool, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QMetaType::Type::QString, -1, -1, -1, -1 ) + + // date type + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDate ), QStringLiteral( "date" ), QMetaType::Type::QDate, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QTime ), QStringLiteral( "time" ), QMetaType::Type::QTime, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDateTime ), QStringLiteral( "datetime" ), QMetaType::Type::QDateTime, -1, -1, -1, -1 ) ); QgsDebugMsgLevel( "Delimited text file uri is " + uri, 2 ); const QUrl url = QUrl::fromEncoded( uri.toUtf8() ); - mFile = std::make_unique< QgsDelimitedTextFile >(); + mFile = std::make_unique(); mFile->setFromUrl( url ); QString subset; @@ -126,7 +117,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr if ( query.hasQueryItem( QStringLiteral( "xyDms" ) ) ) { - mXyDms = ! query.queryItemValue( QStringLiteral( "xyDms" ) ).toLower().startsWith( 'n' ); + mXyDms = !query.queryItemValue( QStringLiteral( "xyDms" ) ).toLower().startsWith( 'n' ); } } else @@ -137,7 +128,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr mDetectTypes = true; if ( query.hasQueryItem( QStringLiteral( "detectTypes" ) ) ) - mDetectTypes = ! query.queryItemValue( QStringLiteral( "detectTypes" ) ).toLower().startsWith( 'n' ); + mDetectTypes = !query.queryItemValue( QStringLiteral( "detectTypes" ) ).toLower().startsWith( 'n' ); if ( query.hasQueryItem( QStringLiteral( "decimalPoint" ) ) ) mDecimalPoint = query.queryItemValue( QStringLiteral( "decimalPoint" ) ); @@ -147,12 +138,12 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr if ( query.hasQueryItem( QStringLiteral( "subsetIndex" ) ) ) { - mBuildSubsetIndex = ! query.queryItemValue( QStringLiteral( "subsetIndex" ) ).toLower().startsWith( 'n' ); + mBuildSubsetIndex = !query.queryItemValue( QStringLiteral( "subsetIndex" ) ).toLower().startsWith( 'n' ); } if ( query.hasQueryItem( QStringLiteral( "spatialIndex" ) ) ) { - mBuildSpatialIndex = ! query.queryItemValue( QStringLiteral( "spatialIndex" ) ).toLower().startsWith( 'n' ); + mBuildSpatialIndex = !query.queryItemValue( QStringLiteral( "spatialIndex" ) ).toLower().startsWith( 'n' ); } if ( query.hasQueryItem( QStringLiteral( "subset" ) ) ) @@ -162,10 +153,11 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr QgsDebugMsgLevel( "subset is: " + subset, 2 ); } - if ( query.hasQueryItem( QStringLiteral( "quiet" ) ) ) mShowInvalidLines = false; + if ( query.hasQueryItem( QStringLiteral( "quiet" ) ) ) + mShowInvalidLines = false; // Parse and store user-defined field types and boolean literals - const QList > queryItems { query.queryItems( QUrl::ComponentFormattingOption::FullyDecoded ) }; + const QList> queryItems { query.queryItems( QUrl::ComponentFormattingOption::FullyDecoded ) }; for ( const QPair &queryItem : std::as_const( queryItems ) ) { if ( queryItem.first.compare( QStringLiteral( "field" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 ) @@ -183,17 +175,18 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr if ( query.hasQueryItem( QStringLiteral( "booleanTrue" ) ) && query.hasQueryItem( QStringLiteral( "booleanFalse" ) ) ) { mUserDefinedBooleanLiterals = qMakePair( - query.queryItemValue( QStringLiteral( "booleanTrue" ), QUrl::ComponentFormattingOption::FullyDecoded ), - query.queryItemValue( QStringLiteral( "booleanFalse" ), QUrl::ComponentFormattingOption::FullyDecoded ) ); + query.queryItemValue( QStringLiteral( "booleanTrue" ), QUrl::ComponentFormattingOption::FullyDecoded ), + query.queryItemValue( QStringLiteral( "booleanFalse" ), QUrl::ComponentFormattingOption::FullyDecoded ) + ); } // Do an initial scan of the file to determine field names, types, // geometry type (for Wkt), extents, etc. Parameter value subset.isEmpty() // avoid redundant building indexes if we will be building a subset string, // in which case indexes will be rebuilt. - scanFile( subset.isEmpty() && ! flags.testFlag( Qgis::DataProviderReadFlag::SkipGetExtent ), /* force full scan */ false ); + scanFile( subset.isEmpty() && !flags.testFlag( Qgis::DataProviderReadFlag::SkipGetExtent ), /* force full scan */ false ); - if ( ! subset.isEmpty() ) + if ( !subset.isEmpty() ) { setSubsetString( subset ); } @@ -205,7 +198,7 @@ QgsAbstractFeatureSource *QgsDelimitedTextProvider::featureSource() const { // If the file has become invalid, rescan to check that it is still invalid. // - if ( ( mLayerValid && ! mValid ) || mRescanRequired ) + if ( ( mLayerValid && !mValid ) || mRescanRequired ) const_cast( this )->rescanFile(); return new QgsDelimitedTextFeatureSource( this ); @@ -216,10 +209,13 @@ QStringList QgsDelimitedTextProvider::readCsvtFieldTypes( const QString &filenam // Look for a file with the same name as the data file, but an extra 't' or 'T' at the end QStringList types; QFileInfo csvtInfo( filename + 't' ); - if ( ! csvtInfo.exists() ) csvtInfo.setFile( filename + 'T' ); - if ( ! csvtInfo.exists() ) return types; + if ( !csvtInfo.exists() ) + csvtInfo.setFile( filename + 'T' ); + if ( !csvtInfo.exists() ) + return types; QFile csvtFile( csvtInfo.filePath() ); - if ( ! csvtFile.open( QIODevice::ReadOnly ) ) return types; + if ( !csvtFile.open( QIODevice::ReadOnly ) ) + return types; // If anything goes wrong here, just ignore it, as the file @@ -233,11 +229,13 @@ QStringList QgsDelimitedTextProvider::readCsvtFieldTypes( const QString &filenam { QTextStream csvtStream( &csvtFile ); strTypeList = csvtStream.readLine(); - if ( strTypeList.isEmpty() ) return types; + if ( strTypeList.isEmpty() ) + return types; QString extra = csvtStream.readLine(); - while ( ! extra.isNull() ) + while ( !extra.isNull() ) { - if ( ! extra.isEmpty() ) return types; + if ( !extra.isEmpty() ) + return types; extra = csvtStream.readLine(); } } @@ -258,7 +256,10 @@ QStringList QgsDelimitedTextProvider::readCsvtFieldTypes( const QString &filenam if ( !match.hasMatch() ) { // Looks like this was supposed to be a CSVT file, so report bad formatted string - if ( message ) { *message = tr( "File type string in %1 is not correctly formatted" ).arg( csvtInfo.fileName() ); } + if ( message ) + { + *message = tr( "File type string in %1 is not correctly formatted" ).arg( csvtInfo.fileName() ); + } return types; } @@ -303,7 +304,7 @@ void QgsDelimitedTextProvider::resetIndexes() const mSubsetIndex.clear(); if ( mBuildSpatialIndex && mGeomRep != GeomNone ) - mSpatialIndex = std::make_unique< QgsSpatialIndex >(); + mSpatialIndex = std::make_unique(); } bool QgsDelimitedTextProvider::createSpatialIndex() @@ -359,7 +360,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, const bool buildSubsetIndex = buildIndexes && mBuildSubsetIndex && mGeomRep != GeomNone; - if ( ! mFile->isValid() ) + if ( !mFile->isValid() ) { // uri is invalid so the layer must be too... @@ -377,7 +378,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, if ( forceFullScan ) { const QUrl url { mFile->url() }; - mFile.reset( new QgsDelimitedTextFile( ) ); + mFile.reset( new QgsDelimitedTextFile() ); mFile->setFromUrl( url ); } @@ -444,14 +445,14 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, struct FieldTypeInformation { - bool isEmpty = true; - bool couldBeInt = false; - bool couldBeLongLong = false; - bool couldBeDouble = false; - bool couldBeDateTime = false; - bool couldBeDate = false; - bool couldBeTime = false; - bool couldBeBool = false; + bool isEmpty = true; + bool couldBeInt = false; + bool couldBeLongLong = false; + bool couldBeDouble = false; + bool couldBeDateTime = false; + bool couldBeDate = false; + bool couldBeTime = false; + bool couldBeBool = false; }; QVector fieldTypeInformation; @@ -608,7 +609,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, } } - if ( ! QgsWkbTypes::hasZ( mWkbType ) ) + if ( !QgsWkbTypes::hasZ( mWkbType ) ) { mExtent.setZMinimum( std::numeric_limits::quiet_NaN() ); mExtent.setZMinimum( std::numeric_limits::quiet_NaN() ); @@ -668,7 +669,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, typeInformation->couldBeBool = true; } - if ( ! mDetectTypes ) + if ( !mDetectTypes ) { continue; } @@ -679,11 +680,11 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, if ( typeInformation->couldBeBool ) { typeInformation->couldBeBool = false; - if ( ! boolCandidates.contains( i ) ) + if ( !boolCandidates.contains( i ) ) { - boolCandidates[ i ] = QPair(); + boolCandidates[i] = QPair(); } - if ( ! boolCandidates[i].first.isEmpty() ) + if ( !boolCandidates[i].first.isEmpty() ) { typeInformation->couldBeBool = value.compare( boolCandidates[i].first, Qt::CaseSensitivity::CaseInsensitive ) == 0 || value.compare( boolCandidates[i].second, Qt::CaseSensitivity::CaseInsensitive ) == 0; } @@ -703,21 +704,21 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, if ( typeInformation->couldBeInt ) { - ( void )value.toInt( &typeInformation->couldBeInt ); + ( void ) value.toInt( &typeInformation->couldBeInt ); } if ( typeInformation->couldBeLongLong && !typeInformation->couldBeInt ) { - ( void )value.toLongLong( &typeInformation->couldBeLongLong ); + ( void ) value.toLongLong( &typeInformation->couldBeLongLong ); } if ( typeInformation->couldBeDouble && !typeInformation->couldBeLongLong ) { - if ( ! mDecimalPoint.isEmpty() ) + if ( !mDecimalPoint.isEmpty() ) { value.replace( mDecimalPoint, QLatin1String( "." ) ); } - ( void )value.toDouble( &typeInformation->couldBeDouble ); + ( void ) value.toDouble( &typeInformation->couldBeDouble ); } if ( typeInformation->couldBeDateTime ) @@ -744,7 +745,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, } // In case of fast scan we exit after the third record (to avoid detecting booleans) - if ( ! forceFullScan && mReadFlags.testFlag( Qgis::DataProviderReadFlag::SkipFullScan ) && mNumberFeatures > 2 ) + if ( !forceFullScan && mReadFlags.testFlag( Qgis::DataProviderReadFlag::SkipFullScan ) && mNumberFeatures > 2 ) { break; } @@ -783,9 +784,9 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, QString typeName = QStringLiteral( "text" ); // User-defined types take precedence over all - if ( ! mUserDefinedFieldTypes.value( fieldNames[ fieldIdx ] ).isEmpty() ) + if ( !mUserDefinedFieldTypes.value( fieldNames[fieldIdx] ).isEmpty() ) { - typeName = mUserDefinedFieldTypes.value( fieldNames[ fieldIdx ] ); + typeName = mUserDefinedFieldTypes.value( fieldNames[fieldIdx] ); } else { @@ -882,11 +883,11 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, } QgsDebugMsgLevel( "Field count for the delimited text file is " + QString::number( attributeFields.size() ), 2 ); - QgsDebugMsgLevel( "geometry type is: " + QString::number( static_cast< quint32>( mWkbType ) ), 2 ); + QgsDebugMsgLevel( "geometry type is: " + QString::number( static_cast( mWkbType ) ), 2 ); QgsDebugMsgLevel( "feature count is: " + QString::number( mNumberFeatures ), 2 ); QStringList warnings; - if ( ! csvtMessage.isEmpty() ) + if ( !csvtMessage.isEmpty() ) warnings.append( csvtMessage ); if ( nBadFormatRecords > 0 ) warnings.append( tr( "%n record(s) discarded due to invalid format", nullptr, nBadFormatRecords ) ); @@ -908,7 +909,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan, long recordCount = mFile->recordCount(); recordCount -= recordCount / SUBSET_ID_THRESHOLD_FACTOR; mUseSubsetIndex = mSubsetIndex.size() < recordCount; - if ( ! mUseSubsetIndex ) + if ( !mUseSubsetIndex ) mSubsetIndex = QList(); } @@ -935,7 +936,7 @@ void QgsDelimitedTextProvider::rescanFile() const // In case file has been rewritten check that it is still valid mValid = mLayerValid && mFile->isValid(); - if ( ! mValid ) + if ( !mValid ) return; // Open the file and get number of rows, etc. We assume that the @@ -1011,7 +1012,7 @@ void QgsDelimitedTextProvider::rescanFile() const mNumberFeatures++; } - if ( ! QgsWkbTypes::hasZ( mWkbType ) ) + if ( !QgsWkbTypes::hasZ( mWkbType ) ) { mExtent.setZMinimum( std::numeric_limits::quiet_NaN() ); mExtent.setZMinimum( std::numeric_limits::quiet_NaN() ); @@ -1022,7 +1023,7 @@ void QgsDelimitedTextProvider::rescanFile() const long recordCount = mFile->recordCount(); recordCount -= recordCount / SUBSET_ID_THRESHOLD_FACTOR; mUseSubsetIndex = recordCount < mSubsetIndex.size(); - if ( ! mUseSubsetIndex ) + if ( !mUseSubsetIndex ) mSubsetIndex.clear(); } @@ -1050,7 +1051,7 @@ QgsGeometry QgsDelimitedTextProvider::geomFromWkt( QString &sWkt, bool wktHasPre void QgsDelimitedTextProvider::appendZM( QString &sZ, QString &sM, QgsPoint &point, const QString &decimalPoint ) { - if ( ! decimalPoint.isEmpty() ) + if ( !decimalPoint.isEmpty() ) { sZ.replace( decimalPoint, QLatin1String( "." ) ); sM.replace( decimalPoint, QLatin1String( "." ) ); @@ -1072,16 +1073,15 @@ void QgsDelimitedTextProvider::appendZM( QString &sZ, QString &sM, QgsPoint &poi } } -QList > QgsDelimitedTextProvider::booleanLiterals() const +QList> QgsDelimitedTextProvider::booleanLiterals() const { - QList > booleans - { + QList> booleans { { QStringLiteral( "true" ), QStringLiteral( "false" ) }, { QStringLiteral( "t" ), QStringLiteral( "f" ) }, { QStringLiteral( "yes" ), QStringLiteral( "no" ) }, { QStringLiteral( "1" ), QStringLiteral( "0" ) }, }; - if ( ! mUserDefinedBooleanLiterals.first.isEmpty() ) + if ( !mUserDefinedBooleanLiterals.first.isEmpty() ) { booleans.append( mUserDefinedBooleanLiterals ); } @@ -1090,7 +1090,7 @@ QList > QgsDelimitedTextProvider::booleanLiterals() cons bool QgsDelimitedTextProvider::pointFromXY( QString &sX, QString &sY, QgsPoint &pt, const QString &decimalPoint, bool xyDms ) { - if ( ! decimalPoint.isEmpty() ) + if ( !decimalPoint.isEmpty() ) { sX.replace( decimalPoint, QLatin1String( "." ) ); sY.replace( decimalPoint, QLatin1String( "." ) ); @@ -1128,7 +1128,7 @@ QgsFeatureIterator QgsDelimitedTextProvider::getFeatures( const QgsFeatureReques { // If the file has become invalid, rescan to check that it is still invalid. // - if ( ( mLayerValid && ! mValid ) || mRescanRequired ) + if ( ( mLayerValid && !mValid ) || mRescanRequired ) rescanFile(); return QgsFeatureIterator( new QgsDelimitedTextFeatureIterator( new QgsDelimitedTextFeatureSource( this ), true, request ) ); @@ -1145,7 +1145,7 @@ bool QgsDelimitedTextProvider::recordIsEmpty( QStringList &record ) const auto constRecord = record; for ( const QString &s : constRecord ) { - if ( ! s.isEmpty() ) + if ( !s.isEmpty() ) return false; } return true; @@ -1165,7 +1165,7 @@ void QgsDelimitedTextProvider::recordInvalidLine( const QString &message ) void QgsDelimitedTextProvider::reportErrors( const QStringList &messages, bool showDialog ) const { - if ( !mInvalidLines.isEmpty() || ! messages.isEmpty() ) + if ( !mInvalidLines.isEmpty() || !messages.isEmpty() ) { const QString tag( QStringLiteral( "DelimitedText" ) ); QgsMessageLog::logMessage( tr( "Errors in file %1" ).arg( mFile->fileName() ), tag ); @@ -1174,7 +1174,7 @@ void QgsDelimitedTextProvider::reportErrors( const QStringList &messages, bool s { QgsMessageLog::logMessage( message, tag ); } - if ( ! mInvalidLines.isEmpty() ) + if ( !mInvalidLines.isEmpty() ) { QgsMessageLog::logMessage( tr( "The following lines were not loaded into QGIS due to errors:" ), tag ); for ( int i = 0; i < mInvalidLines.size(); ++i ) @@ -1194,7 +1194,7 @@ void QgsDelimitedTextProvider::reportErrors( const QStringList &messages, bool s { output->appendMessage( message ); } - if ( ! mInvalidLines.isEmpty() ) + if ( !mInvalidLines.isEmpty() ) { output->appendMessage( tr( "The following lines were not loaded into QGIS due to errors:" ) ); for ( int i = 0; i < mInvalidLines.size(); ++i ) @@ -1222,11 +1222,10 @@ bool QgsDelimitedTextProvider::setSubsetString( const QString &subset, bool upda // If there is a new subset string then encode it.. - std::unique_ptr< QgsExpression > expression; - if ( ! nonNullSubset.isEmpty() ) + std::unique_ptr expression; + if ( !nonNullSubset.isEmpty() ) { - - expression = std::make_unique< QgsExpression >( nonNullSubset ); + expression = std::make_unique( nonNullSubset ); QString error; if ( expression->hasParserError() ) { @@ -1241,7 +1240,7 @@ bool QgsDelimitedTextProvider::setSubsetString( const QString &subset, bool upda error = expression->evalErrorString(); } } - if ( ! error.isEmpty() ) + if ( !error.isEmpty() ) { valid = false; expression.reset(); @@ -1272,7 +1271,7 @@ bool QgsDelimitedTextProvider::setSubsetString( const QString &subset, bool upda if ( updateFeatureCount ) { - if ( ! mCachedSubsetString.isNull() && mSubsetString == mCachedSubsetString ) + if ( !mCachedSubsetString.isNull() && mSubsetString == mCachedSubsetString ) { QgsDebugMsgLevel( QStringLiteral( "DelimitedText: Resetting cached subset string %1" ).arg( mSubsetString ), 3 ); mUseSpatialIndex = mCachedUseSpatialIndex; @@ -1331,7 +1330,7 @@ void QgsDelimitedTextProvider::setUriParameter( const QString ¶meter, const QUrlQuery query( url ); if ( query.hasQueryItem( parameter ) ) query.removeAllQueryItems( parameter ); - if ( ! value.isEmpty() ) + if ( !value.isEmpty() ) query.addQueryItem( parameter, value ); url.setQuery( query ); setDataSourceUri( QString::fromUtf8( url.toEncoded() ) ); @@ -1339,7 +1338,7 @@ void QgsDelimitedTextProvider::setUriParameter( const QString ¶meter, const void QgsDelimitedTextProvider::onFileUpdated() { - if ( ! mRescanRequired ) + if ( !mRescanRequired ) { QStringList messages; messages.append( tr( "The file has been updated by another application - reloading" ) ); @@ -1396,7 +1395,7 @@ QgsCoordinateReferenceSystem QgsDelimitedTextProvider::crs() const return mCrs; } -QString QgsDelimitedTextProvider::name() const +QString QgsDelimitedTextProvider::name() const { return TEXT_PROVIDER_KEY; } @@ -1406,7 +1405,7 @@ QString QgsDelimitedTextProvider::providerKey() return TEXT_PROVIDER_KEY; } -QString QgsDelimitedTextProvider::description() const +QString QgsDelimitedTextProvider::description() const { return TEXT_PROVIDER_DESCRIPTION; } @@ -1503,8 +1502,8 @@ QgsDataProvider *QgsDelimitedTextProviderMetadata::createProvider( const QString } -QgsDelimitedTextProviderMetadata::QgsDelimitedTextProviderMetadata(): - QgsProviderMetadata( QgsDelimitedTextProvider::TEXT_PROVIDER_KEY, QgsDelimitedTextProvider::TEXT_PROVIDER_DESCRIPTION ) +QgsDelimitedTextProviderMetadata::QgsDelimitedTextProviderMetadata() + : QgsProviderMetadata( QgsDelimitedTextProvider::TEXT_PROVIDER_KEY, QgsDelimitedTextProvider::TEXT_PROVIDER_DESCRIPTION ) { } diff --git a/src/providers/delimitedtext/qgsdelimitedtextprovider.h b/src/providers/delimitedtext/qgsdelimitedtextprovider.h index 62d28fb07923..61062ef1a3e6 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextprovider.h +++ b/src/providers/delimitedtext/qgsdelimitedtextprovider.h @@ -59,12 +59,11 @@ class QgsSpatialIndex; * between QgsDelimitedTextFile and QgsDelimitedTextProvider. * */ -class QgsDelimitedTextProvider final: public QgsVectorDataProvider +class QgsDelimitedTextProvider final : public QgsVectorDataProvider { Q_OBJECT public: - static const QString TEXT_PROVIDER_KEY; static const QString TEXT_PROVIDER_DESCRIPTION; @@ -154,8 +153,6 @@ class QgsDelimitedTextProvider final: public QgsVectorDataProvider void onFileUpdated(); private: - - //some of these methods const, as they need to be called from const methods such as extent() void rescanFile() const; void resetCachedSubset() const; @@ -180,14 +177,14 @@ class QgsDelimitedTextProvider final: public QgsVectorDataProvider mutable bool mValid = false; //! Text file - std::unique_ptr< QgsDelimitedTextFile > mFile; + std::unique_ptr mFile; // Fields GeomRepresentationType mGeomRep = GeomNone; mutable QList attributeColumns; QgsFields attributeFields; - int mFieldCount = 0; // Note: this includes field count for wkt field + int mFieldCount = 0; // Note: this includes field count for wkt field QString mWktFieldName; QString mXFieldName; QString mYFieldName; @@ -217,7 +214,7 @@ class QgsDelimitedTextProvider final: public QgsVectorDataProvider QString mSubsetString; mutable QString mCachedSubsetString; - std::unique_ptr< QgsExpression > mSubsetExpression; + std::unique_ptr mSubsetExpression; bool mBuildSubsetIndex = true; mutable QList mSubsetIndex; mutable bool mUseSubsetIndex = false; @@ -243,7 +240,7 @@ class QgsDelimitedTextProvider final: public QgsVectorDataProvider bool mBuildSpatialIndex = false; mutable bool mUseSpatialIndex; mutable bool mCachedUseSpatialIndex; - mutable std::unique_ptr< QgsSpatialIndex > mSpatialIndex; + mutable std::unique_ptr mSpatialIndex; // Store user-defined column types (i.e. types that are not automatically determined) QgsStringMap mUserDefinedFieldTypes; @@ -255,7 +252,7 @@ class QgsDelimitedTextProvider final: public QgsVectorDataProvider friend class QgsDelimitedTextFeatureSource; }; -class QgsDelimitedTextProviderMetadata final: public QgsProviderMetadata +class QgsDelimitedTextProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: @@ -267,7 +264,7 @@ class QgsDelimitedTextProviderMetadata final: public QgsProviderMetadata QString absoluteToRelativeUri( const QString &uri, const QgsReadWriteContext &context ) const override; QString relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const override; ProviderCapabilities providerCapabilities() const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif diff --git a/src/providers/delimitedtext/qgsdelimitedtextprovidergui.cpp b/src/providers/delimitedtext/qgsdelimitedtextprovidergui.cpp index 9cfa72e33da0..827f18403113 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextprovidergui.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextprovidergui.cpp @@ -26,7 +26,6 @@ class QgsDelimitedTextSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "delimitedtext" ); } QString text() const override { return QObject::tr( "Delimited Text" ); } int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 30; } diff --git a/src/providers/delimitedtext/qgsdelimitedtextprovidergui.h b/src/providers/delimitedtext/qgsdelimitedtextprovidergui.h index 6891acf142a8..5609f5617979 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextprovidergui.h +++ b/src/providers/delimitedtext/qgsdelimitedtextprovidergui.h @@ -17,7 +17,7 @@ #include "qgssourceselectprovider.h" #include "qgsdelimitedtextsourceselect.h" -class QgsDelimitedTextProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsDelimitedTextProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsDelimitedTextProviderGuiMetadata(); diff --git a/src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp b/src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp index 907dc941d8b9..144ae0edfaf5 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp @@ -40,7 +40,6 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget *parent, Qt: , mFile( std::make_unique() ) , mSettingsKey( QStringLiteral( "/Plugin-DelimitedText" ) ) { - setupUi( this ); QgsGui::enableAutoGeometryRestore( this ); setupButtons( buttonBox ); @@ -65,7 +64,7 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget *parent, Qt: cmbEncoding->setCurrentIndex( cmbEncoding->findText( QStringLiteral( "UTF-8" ) ) ); loadSettings(); - mBooleanFalse->setEnabled( ! mBooleanTrue->text().isEmpty() ); + mBooleanFalse->setEnabled( !mBooleanTrue->text().isEmpty() ); updateFieldsAndEnable(); connect( txtLayerName, &QLineEdit::textChanged, this, &QgsDelimitedTextSourceSelect::enableAccept ); @@ -87,7 +86,7 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget *parent, Qt: connect( txtEscapeChars, &QLineEdit::textChanged, this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); connect( txtDelimiterRegexp, &QLineEdit::textChanged, this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); - connect( rowCounter, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); + connect( rowCounter, static_cast( &QSpinBox::valueChanged ), this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); connect( cbxUseHeader, &QCheckBox::stateChanged, this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); connect( cbxSkipEmptyFields, &QCheckBox::stateChanged, this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); connect( cbxTrimFields, &QCheckBox::stateChanged, this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); @@ -97,14 +96,12 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget *parent, Qt: connect( crsGeometry, &QgsProjectionSelectionWidget::crsChanged, this, &QgsDelimitedTextSourceSelect::updateFieldsAndEnable ); - connect( mBooleanTrue, &QLineEdit::textChanged, mBooleanFalse, [ = ] - { - mBooleanFalse->setEnabled( ! mBooleanTrue->text().isEmpty() ); + connect( mBooleanTrue, &QLineEdit::textChanged, mBooleanFalse, [=] { + mBooleanFalse->setEnabled( !mBooleanTrue->text().isEmpty() ); updateFieldsAndEnable(); } ); - connect( mBooleanFalse, &QLineEdit::textChanged, mBooleanFalse, [ = ] - { + connect( mBooleanFalse, &QLineEdit::textChanged, mBooleanFalse, [=] { updateFieldsAndEnable(); } ); @@ -116,7 +113,7 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget *parent, Qt: connect( mFileWidget, &QgsFileWidget::fileChanged, this, &QgsDelimitedTextSourceSelect::updateFileName ); updateCrsWidgetVisibility(); - mScanWidget->hide( ); + mScanWidget->hide(); } void QgsDelimitedTextSourceSelect::addButtonClicked() @@ -140,14 +137,14 @@ void QgsDelimitedTextSourceSelect::addButtonClicked() if ( delimiterRegexp->isChecked() ) { const QRegularExpression re( txtDelimiterRegexp->text() ); - if ( ! re.isValid() ) + if ( !re.isValid() ) { QMessageBox::warning( this, tr( "Invalid regular expression" ), tr( "Please enter a valid regular expression as the delimiter, or choose a different delimiter type" ) ); txtDelimiterRegexp->setFocus(); return; } } - if ( ! mFile->isValid() ) + if ( !mFile->isValid() ) { QMessageBox::warning( this, tr( "Invalid delimited text file" ), tr( "Please enter a valid file and delimiter" ) ); return; @@ -156,7 +153,7 @@ void QgsDelimitedTextSourceSelect::addButtonClicked() cancelScanTask(); //Build the delimited text URI from the user provided information - const QString datasourceUrl { url( )}; + const QString datasourceUrl { url() }; // store the settings saveSettings(); @@ -218,7 +215,8 @@ void QgsDelimitedTextSourceSelect::loadSettings( const QString &subkey, bool loa // at startup, fetch the last used delimiter and directory from // settings QString key = mSettingsKey; - if ( ! subkey.isEmpty() ) key.append( '/' ).append( subkey ); + if ( !subkey.isEmpty() ) + key.append( '/' ).append( subkey ); // and how to use the delimiter const QString delimiterType = settings.value( key + "/delimiterType", "" ).toString(); @@ -237,15 +235,18 @@ void QgsDelimitedTextSourceSelect::loadSettings( const QString &subkey, bool loa swFileFormat->setCurrentIndex( bgFileFormat->checkedId() ); const QString encoding = settings.value( key + "/encoding", "" ).toString(); - if ( ! encoding.isEmpty() ) cmbEncoding->setCurrentIndex( cmbEncoding->findText( encoding ) ); + if ( !encoding.isEmpty() ) + cmbEncoding->setCurrentIndex( cmbEncoding->findText( encoding ) ); const QString delimiters = settings.value( key + "/delimiters", "" ).toString(); - if ( ! delimiters.isEmpty() ) setSelectedChars( delimiters ); + if ( !delimiters.isEmpty() ) + setSelectedChars( delimiters ); txtQuoteChars->setText( settings.value( key + "/quoteChars", "\"" ).toString() ); txtEscapeChars->setText( settings.value( key + "/escapeChars", "\"" ).toString() ); const QString regexp = settings.value( key + "/delimiterRegexp", "" ).toString(); - if ( ! regexp.isEmpty() ) txtDelimiterRegexp->setText( regexp ); + if ( !regexp.isEmpty() ) + txtDelimiterRegexp->setText( regexp ); rowCounter->setValue( settings.value( key + "/startFrom", 0 ).toInt() ); cbxUseHeader->setChecked( settings.value( key + "/useHeader", "true" ) != "false" ); @@ -262,9 +263,12 @@ void QgsDelimitedTextSourceSelect::loadSettings( const QString &subkey, bool loa if ( loadGeomSettings ) { const QString geomColumnType = settings.value( key + "/geomColumnType", "xy" ).toString(); - if ( geomColumnType == QLatin1String( "xy" ) ) geomTypeXY->setChecked( true ); - else if ( geomColumnType == QLatin1String( "wkt" ) ) geomTypeWKT->setChecked( true ); - else geomTypeNone->setChecked( true ); + if ( geomColumnType == QLatin1String( "xy" ) ) + geomTypeXY->setChecked( true ); + else if ( geomColumnType == QLatin1String( "wkt" ) ) + geomTypeWKT->setChecked( true ); + else + geomTypeNone->setChecked( true ); cbxXyDms->setChecked( settings.value( key + "/xyDms", "false" ) == "true" ); swGeomType->setCurrentIndex( bgGeomType->checkedId() ); const QString authid = settings.value( key + "/crs", "" ).toString(); @@ -274,14 +278,14 @@ void QgsDelimitedTextSourceSelect::loadSettings( const QString &subkey, bool loa crsGeometry->setCrs( crs ); } } - } void QgsDelimitedTextSourceSelect::saveSettings( const QString &subkey, bool saveGeomSettings ) { QgsSettings settings; QString key = mSettingsKey; - if ( ! subkey.isEmpty() ) key.append( '/' ).append( subkey ); + if ( !subkey.isEmpty() ) + key.append( '/' ).append( subkey ); settings.setValue( key + "/encoding", cmbEncoding->currentText() ); settings.setValue( key + "/geometry", saveGeometry() ); @@ -309,8 +313,10 @@ void QgsDelimitedTextSourceSelect::saveSettings( const QString &subkey, bool sav if ( saveGeomSettings ) { QString geomColumnType = QStringLiteral( "none" ); - if ( geomTypeXY->isChecked() ) geomColumnType = QStringLiteral( "xy" ); - if ( geomTypeWKT->isChecked() ) geomColumnType = QStringLiteral( "wkt" ); + if ( geomTypeXY->isChecked() ) + geomColumnType = QStringLiteral( "xy" ); + if ( geomTypeWKT->isChecked() ) + geomColumnType = QStringLiteral( "wkt" ); settings.setValue( key + "/geomColumnType", geomColumnType ); settings.setValue( key + "/xyDms", cbxXyDms->isChecked() ? "true" : "false" ); if ( crsGeometry->crs().isValid() ) @@ -318,23 +324,25 @@ void QgsDelimitedTextSourceSelect::saveSettings( const QString &subkey, bool sav settings.setValue( key + "/crs", crsGeometry->crs().authid() ); } } - } void QgsDelimitedTextSourceSelect::loadSettingsForFile( const QString &filename ) { - if ( filename.isEmpty() ) return; + if ( filename.isEmpty() ) + return; mOverriddenFields.clear(); const QFileInfo fi( filename ); const QString filetype = fi.suffix(); // Don't expect to change settings if not changing file type - if ( filetype != mLastFileType ) loadSettings( fi.suffix(), true ); + if ( filetype != mLastFileType ) + loadSettings( fi.suffix(), true ); mLastFileType = filetype; } void QgsDelimitedTextSourceSelect::saveSettingsForFile( const QString &filename ) { - if ( filename.isEmpty() ) return; + if ( filename.isEmpty() ) + return; const QFileInfo fi( filename ); saveSettings( fi.suffix(), true ); } @@ -395,7 +403,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() tblSample->setColumnCount( 0 ); tblSample->setRowCount( 0 ); - if ( ! loadDelimitedFileDefinition() ) + if ( !loadDelimitedFileDefinition() ) return; // Put a sample set of records into the sample box. Also while scanning assess suitability of @@ -413,15 +421,21 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() while ( counter < mExampleRowCount ) { const QgsDelimitedTextFile::Status status = mFile->nextRecord( values ); - if ( status == QgsDelimitedTextFile::RecordEOF ) break; - if ( status != QgsDelimitedTextFile::RecordOk ) { mBadRowCount++; continue; } + if ( status == QgsDelimitedTextFile::RecordEOF ) + break; + if ( status != QgsDelimitedTextFile::RecordOk ) + { + mBadRowCount++; + continue; + } counter++; // Look at count of non-blank fields int nv = values.size(); - while ( nv > 0 && values[nv - 1].isEmpty() ) nv--; + while ( nv > 0 && values[nv - 1].isEmpty() ) + nv--; if ( isEmpty.size() < nv ) { @@ -445,7 +459,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() value = value.mid( 0, MAX_SAMPLE_LENGTH ) + QChar( 0x2026 ); QTableWidgetItem *item = new QTableWidgetItem( value ); tblSample->setItem( counter - 1, i, item ); - if ( ! value.isEmpty() ) + if ( !value.isEmpty() ) { if ( isEmpty[i] ) { @@ -467,7 +481,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() } else { - ( void )value.toDouble( &ok ); + ( void ) value.toDouble( &ok ); } isValidCoordinate[i] = ok; } @@ -496,7 +510,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() tblSample->insertRow( 0 ); QStringList verticalHeaderLabels; - verticalHeaderLabels.push_back( QString( ) ); + verticalHeaderLabels.push_back( QString() ); for ( int i = 1; i <= tblSample->rowCount(); i++ ) { @@ -517,8 +531,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() typeCombo->addItem( QgsFields::iconForFieldType( QMetaType::Type::QDate ), QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDate ), "date" ); typeCombo->addItem( QgsFields::iconForFieldType( QMetaType::Type::QTime ), QgsVariantUtils::typeToDisplayString( QMetaType::Type::QTime ), "time" ); typeCombo->addItem( QgsFields::iconForFieldType( QMetaType::Type::QDateTime ), QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDateTime ), "datetime" ); - connect( typeCombo, qOverload( &QComboBox::currentIndexChanged ), this, [ = ]( int ) - { + connect( typeCombo, qOverload( &QComboBox::currentIndexChanged ), this, [=]( int ) { mOverriddenFields.insert( column, typeCombo->currentData().toString() ); } ); tblSample->setCellWidget( 0, column, typeCombo ); @@ -533,29 +546,25 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() mScanTask = new QgsDelimitedTextFileScanTask( url( /* skip overridden types */ true ) ); mCancelButton->show(); - connect( mScanTask, &QgsDelimitedTextFileScanTask::scanCompleted, this, [ = ]( const QgsFields & fields ) - { + connect( mScanTask, &QgsDelimitedTextFileScanTask::scanCompleted, this, [=]( const QgsFields &fields ) { updateFieldTypes( fields ); - mScanWidget->hide( ); + mScanWidget->hide(); } ); - connect( mScanTask, &QgsDelimitedTextFileScanTask::scanStarted, this, [ = ]( const QgsFields & fields ) - { + connect( mScanTask, &QgsDelimitedTextFileScanTask::scanStarted, this, [=]( const QgsFields &fields ) { updateFieldTypes( fields ); } ); connect( mCancelButton, &QPushButton::clicked, this, &QgsDelimitedTextSourceSelect::cancelScanTask ); - connect( mScanTask, &QgsDelimitedTextFileScanTask::processedCountChanged, this, [ = ]( unsigned long long recordsScanned ) - { + connect( mScanTask, &QgsDelimitedTextFileScanTask::processedCountChanged, this, [=]( unsigned long long recordsScanned ) { mScanWidget->show(); mProgressLabel->setText( tr( "Column types detection in progress: %L1 records read" ).arg( static_cast( recordsScanned ) ) ); } ); // This is required because QgsTask emits a progress changed 100 when done - connect( mScanTask, &QgsDelimitedTextFileScanTask::taskCompleted, this, [ = ] - { - mScanWidget->hide( ); + connect( mScanTask, &QgsDelimitedTextFileScanTask::taskCompleted, this, [=] { + mScanWidget->hide(); } ); QgsApplication::taskManager()->addTask( mScanTask, 100 ); @@ -574,7 +583,8 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() { const QString field = fieldList[i]; // skip empty field names - if ( field.isEmpty() ) continue; + if ( field.isEmpty() ) + continue; cmbXField->addItem( field ); cmbYField->addItem( field ); cmbZField->addItem( field ); @@ -606,7 +616,8 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() { for ( int i = 0; i < fieldList.size(); i++ ) { - if ( ! isValidWkt[i] ) continue; + if ( !isValidWkt[i] ) + continue; const int index = cmbWktField->findText( fieldList[i] ); if ( index >= 0 ) { @@ -620,11 +631,9 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() if ( !geomTypeNone->isChecked() ) { - const bool isXY = cmbWktField->currentIndex() < 0 || - ( geomTypeXY->isChecked() && - ( cmbXField->currentIndex() >= 0 && cmbYField->currentIndex() >= 0 ) ); + const bool isXY = cmbWktField->currentIndex() < 0 || ( geomTypeXY->isChecked() && ( cmbXField->currentIndex() >= 0 && cmbYField->currentIndex() >= 0 ) ); geomTypeXY->setChecked( isXY ); - geomTypeWKT->setChecked( ! isXY ); + geomTypeWKT->setChecked( !isXY ); } swGeomType->setCurrentIndex( bgGeomType->checkedId() ); @@ -637,13 +646,13 @@ void QgsDelimitedTextSourceSelect::updateFieldLists() connect( geomTypeWKT, &QAbstractButton::toggled, this, &QgsDelimitedTextSourceSelect::enableAccept ); connect( geomTypeNone, &QAbstractButton::toggled, this, &QgsDelimitedTextSourceSelect::enableAccept ); } - } bool QgsDelimitedTextSourceSelect::trySetXYField( QStringList &fields, QList &isValidNumber, const QString &xname, const QString &yname ) { // If fields already set, then nothing to do - if ( cmbXField->currentIndex() >= 0 && cmbYField->currentIndex() >= 0 ) return true; + if ( cmbXField->currentIndex() >= 0 && cmbYField->currentIndex() >= 0 ) + return true; // Try and find a valid field name matching the x field int indexX = -1; @@ -653,10 +662,13 @@ bool QgsDelimitedTextSourceSelect::trySetXYField( QStringList &fields, QListfindText( fields[i] ); - if ( indexX < 0 ) continue; + if ( indexX < 0 ) + continue; // Now look for potential y fields, like xname with x replaced with y const QString xfield( fields[i] ); @@ -664,23 +676,29 @@ bool QgsDelimitedTextSourceSelect::trySetXYField( QStringList &fields, QListfindText( fields[iy] ); break; } } - if ( indexY >= 0 ) break; + if ( indexY >= 0 ) + break; } - if ( indexY >= 0 ) break; + if ( indexY >= 0 ) + break; } if ( indexY >= 0 ) { @@ -726,7 +744,7 @@ bool QgsDelimitedTextSourceSelect::validate() { message = tr( "Please select an input file" ); } - else if ( ! QFileInfo::exists( mFileWidget->filePath() ) ) + else if ( !QFileInfo::exists( mFileWidget->filePath() ) ) { message = tr( "File %1 does not exist" ).arg( mFileWidget->filePath() ); } @@ -742,7 +760,7 @@ bool QgsDelimitedTextSourceSelect::validate() if ( message.isEmpty() && delimiterRegexp->isChecked() ) { const QRegularExpression re( txtDelimiterRegexp->text() ); - if ( ! re.isValid() ) + if ( !re.isValid() ) { message = tr( "Regular expression is not valid" ); } @@ -752,12 +770,12 @@ bool QgsDelimitedTextSourceSelect::validate() } lblRegexpError->setText( message ); } - if ( ! message.isEmpty() ) + if ( !message.isEmpty() ) { // continue... } // Hopefully won't hit this none-specific message, but just in case ... - else if ( ! mFile->isValid() ) + else if ( !mFile->isValid() ) { message = tr( "Definition of filename and delimiters is not valid" ); } @@ -770,7 +788,7 @@ bool QgsDelimitedTextSourceSelect::validate() message = message + " (" + tr( "%n badly formatted record(s) discarded", nullptr, mBadRowCount ) + ')'; } } - else if ( geomTypeXY->isChecked() && ( cmbXField->currentText().isEmpty() || cmbYField->currentText().isEmpty() ) ) + else if ( geomTypeXY->isChecked() && ( cmbXField->currentText().isEmpty() || cmbYField->currentText().isEmpty() ) ) { message = tr( "X and Y field names must be selected" ); } @@ -782,7 +800,7 @@ bool QgsDelimitedTextSourceSelect::validate() { message = tr( "The WKT field name must be selected" ); } - else if ( ! geomTypeNone->isChecked() && ! crsGeometry->crs().isValid() ) + else if ( !geomTypeNone->isChecked() && !crsGeometry->crs().isValid() ) { message = tr( "The CRS must be selected" ); } @@ -793,7 +811,6 @@ bool QgsDelimitedTextSourceSelect::validate() { message = tr( "%n badly formatted record(s) discarded from sample data", nullptr, mBadRowCount ); } - } if ( mBooleanTrue->text().isEmpty() != mBooleanFalse->text().isEmpty() ) @@ -801,7 +818,7 @@ bool QgsDelimitedTextSourceSelect::validate() message = tr( "Custom boolean values for \"true\" or \"false\" is missing." ); } - if ( ! message.isEmpty() ) + if ( !message.isEmpty() ) { QgsDebugMsgLevel( QStringLiteral( "Validation error: %1" ).arg( message ), 2 ); } @@ -812,13 +829,10 @@ bool QgsDelimitedTextSourceSelect::validate() void QgsDelimitedTextSourceSelect::updateFieldTypes( const QgsFields &fields ) { - mFields = fields; for ( int column = 0; column < tblSample->columnCount(); column++ ) { - - const QString fieldName { tblSample->horizontalHeaderItem( column )->text() }; const int fieldIdx { mFields.lookupField( fieldName ) }; if ( fieldIdx >= 0 ) @@ -827,19 +841,18 @@ void QgsDelimitedTextSourceSelect::updateFieldTypes( const QgsFields &fields ) QString fieldTypeName; if ( mOverriddenFields.contains( column ) ) { - fieldTypeName = mOverriddenFields[ column ]; + fieldTypeName = mOverriddenFields[column]; } else { fieldTypeName = mFields.field( fieldIdx ).typeName(); } - if ( typeCombo && typeCombo->currentData( ) != fieldTypeName && typeCombo->findData( fieldTypeName ) >= 0 ) + if ( typeCombo && typeCombo->currentData() != fieldTypeName && typeCombo->findData( fieldTypeName ) >= 0 ) { QgsDebugMsgLevel( QStringLiteral( "Setting field type %1 from %2 to %3" ).arg( fieldName, typeCombo->currentData().toString(), fieldTypeName ), 2 ); QgsSignalBlocker( typeCombo )->setCurrentIndex( typeCombo->findData( fieldTypeName ) ); } } - } } @@ -861,7 +874,6 @@ void QgsDelimitedTextSourceSelect::updateCrsWidgetVisibility() QString QgsDelimitedTextSourceSelect::url( bool skipOverriddenTypes ) { - QUrl url = mFile->url(); QUrlQuery query( url ); @@ -876,7 +888,7 @@ QString QgsDelimitedTextSourceSelect::url( bool skipOverriddenTypes ) query.addQueryItem( QStringLiteral( "xyDms" ), QStringLiteral( "yes" ) ); } - if ( ! mBooleanFalse->text().isEmpty() && ! mBooleanTrue->text().isEmpty() ) + if ( !mBooleanFalse->text().isEmpty() && !mBooleanTrue->text().isEmpty() ) { query.addQueryItem( QStringLiteral( "booleanFalse" ), mBooleanFalse->text() ); query.addQueryItem( QStringLiteral( "booleanTrue" ), mBooleanTrue->text() ); @@ -906,7 +918,7 @@ QString QgsDelimitedTextSourceSelect::url( bool skipOverriddenTypes ) } else if ( geomTypeWKT->isChecked() ) { - if ( ! cmbWktField->currentText().isEmpty() ) + if ( !cmbWktField->currentText().isEmpty() ) { const QString field = cmbWktField->currentText(); query.addQueryItem( QStringLiteral( "wktField" ), field ); @@ -928,10 +940,9 @@ QString QgsDelimitedTextSourceSelect::url( bool skipOverriddenTypes ) { query.addQueryItem( QStringLiteral( "crs" ), crs.authid() ); } - } - if ( ! geomTypeNone->isChecked() ) + if ( !geomTypeNone->isChecked() ) { query.addQueryItem( QStringLiteral( "spatialIndex" ), cbxSpatialIndex->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) ); } @@ -939,7 +950,7 @@ QString QgsDelimitedTextSourceSelect::url( bool skipOverriddenTypes ) query.addQueryItem( QStringLiteral( "subsetIndex" ), cbxSubsetIndex->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) ); query.addQueryItem( QStringLiteral( "watchFile" ), cbxWatchFile->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) ); - if ( ! skipOverriddenTypes ) + if ( !skipOverriddenTypes ) { // Set field types if overridden for ( int column = 0; column < tblSample->columnCount(); column++ ) @@ -953,8 +964,7 @@ QString QgsDelimitedTextSourceSelect::url( bool skipOverriddenTypes ) if ( typeCombo && typeCombo->currentData().toString() != fieldTypeName ) { QgsDebugMsgLevel( QStringLiteral( "Overriding field %1 from %2 to %3" ).arg( fieldName, fieldTypeName, typeCombo->currentData().toString() ), 2 ); - query.addQueryItem( QStringLiteral( "field" ), - QString( fieldName ).replace( ':', QLatin1String( "%3A" ) ) + ':' + typeCombo->currentData().toString() ); + query.addQueryItem( QStringLiteral( "field" ), QString( fieldName ).replace( ':', QLatin1String( "%3A" ) ) + ':' + typeCombo->currentData().toString() ); } } } @@ -979,7 +989,8 @@ bool QgsDelimitedTextFileScanTask::run() QgsDelimitedTextProvider provider( mDataSource, QgsDataProvider::ProviderOptions(), - Qgis::DataProviderReadFlag::SkipFeatureCount | Qgis::DataProviderReadFlag::SkipGetExtent | Qgis::DataProviderReadFlag::SkipFullScan ); + Qgis::DataProviderReadFlag::SkipFeatureCount | Qgis::DataProviderReadFlag::SkipGetExtent | Qgis::DataProviderReadFlag::SkipFullScan + ); connect( &mFeedback, &QgsFeedback::processedCountChanged, this, &QgsDelimitedTextFileScanTask::processedCountChanged ); diff --git a/src/providers/delimitedtext/qgsdelimitedtextsourceselect.h b/src/providers/delimitedtext/qgsdelimitedtextsourceselect.h index 645f60269b9d..18159a07f575 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextsourceselect.h +++ b/src/providers/delimitedtext/qgsdelimitedtextsourceselect.h @@ -35,18 +35,15 @@ class QgisInterface; /** * \brief The QgsDelimitedTextFileScan class scans a CSV file to identify field types. */ -class QgsDelimitedTextFileScanTask: public QgsTask +class QgsDelimitedTextFileScanTask : public QgsTask { - Q_OBJECT public: - QgsDelimitedTextFileScanTask( const QString &dataSource ) : QgsTask( QStringLiteral( "delimited text scan %1" ).arg( dataSource ) ) - , mDataSource( dataSource ) - { - }; + , mDataSource( dataSource ) { + }; ~QgsDelimitedTextFileScanTask() { @@ -79,10 +76,8 @@ class QgsDelimitedTextFileScanTask: public QgsTask void processedCountChanged( unsigned long long processedCount ); private: - QString mDataSource; QgsFeedback mFeedback; - }; /** @@ -110,7 +105,7 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private std::unique_ptr mFile; int mExampleRowCount = 20; int mBadRowCount = 0; - QgsFields mFields; //!< Stores the fields as returned by the provider to determine if their types were overridden + QgsFields mFields; //!< Stores the fields as returned by the provider to determine if their types were overridden QMap mOverriddenFields; //!< Stores user-overridden field types static constexpr int DEFAULT_MAX_FIELDS = 10000; int mMaxFields = DEFAULT_MAX_FIELDS; //!< To avoid Denial Of Service (at least in source select). Configurable through /max_fields settings sub-key. diff --git a/src/providers/gpx/gpsdata.cpp b/src/providers/gpx/gpsdata.cpp index 2e0d91a21b3b..bba24ef9618b 100644 --- a/src/providers/gpx/gpsdata.cpp +++ b/src/providers/gpx/gpsdata.cpp @@ -83,7 +83,6 @@ QgsGpsExtended::QgsGpsExtended() , yMax( -std::numeric_limits::max() ) , number( std::numeric_limits::max() ) { - } @@ -97,8 +96,7 @@ void QgsGpsExtended::writeXml( QTextStream &stream ) void QgsWaypoint::writeXml( QTextStream &stream ) { - stream << "\n"; + stream << "\n"; QgsGpsPoint::writeXml( stream ); stream << "\n"; } @@ -128,10 +126,7 @@ void QgsTrack::writeXml( QTextStream &stream ) stream << "\n"; for ( int j = 0; j < segments.at( i ).points.size(); ++j ) { - stream << "\n"; + stream << "\n"; segments[i].points[j].writeXml( stream ); stream << "\n"; } @@ -232,8 +227,7 @@ QgsGpsData::TrackIterator QgsGpsData::tracksEnd() } -QgsGpsData::WaypointIterator QgsGpsData::addWaypoint( double lat, double lon, - const QString &name, double ele ) +QgsGpsData::WaypointIterator QgsGpsData::addWaypoint( double lat, double lon, const QString &name, double ele ) { QgsWaypoint wpt; wpt.lat = lat; @@ -359,7 +353,7 @@ void QgsGpsData::removeTracks( const QgsFeatureIds &ids ) void QgsGpsData::writeXml( QTextStream &stream ) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) stream.setCodec( QTextCodec::codecForName( "UTF8" ) ); #endif stream << "\n" @@ -410,13 +404,13 @@ QgsGpsData *QgsGpsData::getData( const QString &fileName ) if ( !XML_Parse( p, buffer, readBytes, atEnd ) ) { QgsLogger::warning( QObject::tr( "Parse error at line %1 : %2" ) - .arg( XML_GetCurrentLineNumber( p ) ) - .arg( XML_ErrorString( XML_GetErrorCode( p ) ) ) ); + .arg( XML_GetCurrentLineNumber( p ) ) + .arg( XML_ErrorString( XML_GetErrorCode( p ) ) ) ); failed = true; break; } } - delete [] buffer; + delete[] buffer; XML_ParserFree( p ); if ( failed ) return nullptr; @@ -433,7 +427,7 @@ QgsGpsData *QgsGpsData::getData( const QString &fileName ) // return a pointer and increase the reference count for that file name const DataMap::iterator iter = sDataObjects.find( fileName ); ++( iter.value().second ); - return ( QgsGpsData * )( iter.value().first ); + return ( QgsGpsData * ) ( iter.value().first ); } @@ -459,7 +453,6 @@ void QgsGpsData::releaseData( const QString &fileName ) bool QgsGPXHandler::startElement( const XML_Char *qName, const XML_Char **attr ) { - if ( !std::strcmp( qName, "gpx" ) ) { parseModes.push( ParsingDocument ); @@ -496,9 +489,7 @@ bool QgsGPXHandler::startElement( const XML_Char *qName, const XML_Char **attr ) // common properties else if ( !std::strcmp( qName, "name" ) ) { - if ( parseModes.top() == ParsingWaypoint || - parseModes.top() == ParsingRoute || - parseModes.top() == ParsingTrack ) + if ( parseModes.top() == ParsingWaypoint || parseModes.top() == ParsingRoute || parseModes.top() == ParsingTrack ) { mString = &mObj->name; mCharBuffer.clear(); @@ -509,9 +500,7 @@ bool QgsGPXHandler::startElement( const XML_Char *qName, const XML_Char **attr ) } else if ( !std::strcmp( qName, "cmt" ) ) { - if ( parseModes.top() == ParsingWaypoint || - parseModes.top() == ParsingRoute || - parseModes.top() == ParsingTrack ) + if ( parseModes.top() == ParsingWaypoint || parseModes.top() == ParsingRoute || parseModes.top() == ParsingTrack ) { mString = &mObj->cmt; mCharBuffer.clear(); @@ -522,9 +511,7 @@ bool QgsGPXHandler::startElement( const XML_Char *qName, const XML_Char **attr ) } else if ( !std::strcmp( qName, "desc" ) ) { - if ( parseModes.top() == ParsingWaypoint || - parseModes.top() == ParsingRoute || - parseModes.top() == ParsingTrack ) + if ( parseModes.top() == ParsingWaypoint || parseModes.top() == ParsingRoute || parseModes.top() == ParsingTrack ) { mString = &mObj->desc; mCharBuffer.clear(); @@ -535,9 +522,7 @@ bool QgsGPXHandler::startElement( const XML_Char *qName, const XML_Char **attr ) } else if ( !std::strcmp( qName, "src" ) ) { - if ( parseModes.top() == ParsingWaypoint || - parseModes.top() == ParsingRoute || - parseModes.top() == ParsingTrack ) + if ( parseModes.top() == ParsingWaypoint || parseModes.top() == ParsingRoute || parseModes.top() == ParsingTrack ) { mString = &mObj->src; mCharBuffer.clear(); @@ -548,9 +533,7 @@ bool QgsGPXHandler::startElement( const XML_Char *qName, const XML_Char **attr ) } else if ( !std::strcmp( qName, "url" ) ) { - if ( parseModes.top() == ParsingWaypoint || - parseModes.top() == ParsingRoute || - parseModes.top() == ParsingTrack ) + if ( parseModes.top() == ParsingWaypoint || parseModes.top() == ParsingRoute || parseModes.top() == ParsingTrack ) { mString = &mObj->url; mCharBuffer.clear(); @@ -561,9 +544,7 @@ bool QgsGPXHandler::startElement( const XML_Char *qName, const XML_Char **attr ) } else if ( !std::strcmp( qName, "urlname" ) ) { - if ( parseModes.top() == ParsingWaypoint || - parseModes.top() == ParsingRoute || - parseModes.top() == ParsingTrack ) + if ( parseModes.top() == ParsingWaypoint || parseModes.top() == ParsingRoute || parseModes.top() == ParsingTrack ) { mString = &mObj->urlname; mCharBuffer.clear(); @@ -754,4 +735,3 @@ bool QgsGPXHandler::endElement( const std::string &qName ) return true; } - diff --git a/src/providers/gpx/gpsdata.h b/src/providers/gpx/gpsdata.h index 4e795bdcb6fd..2c3bf51488da 100644 --- a/src/providers/gpx/gpsdata.h +++ b/src/providers/gpx/gpsdata.h @@ -33,9 +33,9 @@ // workaround for MSVC compiler which already has defined macro max // that interferes with calling std::numeric_limits::max #ifdef _MSC_VER -# ifdef max -# undef max -# endif +#ifdef max +#undef max +#endif #endif /** @@ -139,7 +139,6 @@ class QgsTrack : public QgsGpsExtended class QgsGpsData { public: - //! This iterator type is used to iterate over waypoints. typedef QList::iterator WaypointIterator; //! This iterator type is used to iterate over routes. @@ -205,8 +204,7 @@ class QgsGpsData * waypoint will be returned (it will be waypointsEnd() if the waypoint * couldn't be added. */ - WaypointIterator addWaypoint( double lat, double lon, const QString &name = "", - double ele = -std::numeric_limits::max() ); + WaypointIterator addWaypoint( double lat, double lon, const QString &name = "", double ele = -std::numeric_limits::max() ); WaypointIterator addWaypoint( const QgsWaypoint &wpt ); @@ -267,7 +265,6 @@ class QgsGpsData //friend std::ostream& operator<<(std::ostream& os, const GPSData& d); protected: - QList waypoints; QList routes; QList tracks; @@ -276,7 +273,7 @@ class QgsGpsData double xMin, xMax, yMin, yMax; //! This is used internally to store GPS data objects (one per file). - typedef QMap > DataMap; + typedef QMap> DataMap; /** * This is the static container that maps file names to GPSData objects and @@ -287,17 +284,15 @@ class QgsGpsData //! Mutex for sDataObjects static QRecursiveMutex sDataObjectsMutex; - }; - class QgsGPXHandler { public: explicit QgsGPXHandler( QgsGpsData &data ) : mData( data ) - { } + {} /** * This function is called when expat encounters a new start element in @@ -333,7 +328,6 @@ class QgsGPXHandler } private: - enum ParseMode { ParsingDocument, diff --git a/src/providers/gpx/qgsgpxfeatureiterator.cpp b/src/providers/gpx/qgsgpxfeatureiterator.cpp index e25af07cf585..ea476320b4f2 100644 --- a/src/providers/gpx/qgsgpxfeatureiterator.cpp +++ b/src/providers/gpx/qgsgpxfeatureiterator.cpp @@ -216,7 +216,7 @@ bool QgsGPXFeatureIterator::readFid( QgsFeature &feature ) if ( mSource->mFeatureType == QgsGPXProvider::WaypointType ) { - for ( QgsGpsData::WaypointIterator it = mSource->mData->waypointsBegin() ; it != mSource->mData->waypointsEnd(); ++it ) + for ( QgsGpsData::WaypointIterator it = mSource->mData->waypointsBegin(); it != mSource->mData->waypointsEnd(); ++it ) { if ( it->id == fid ) { @@ -227,7 +227,7 @@ bool QgsGPXFeatureIterator::readFid( QgsFeature &feature ) } else if ( mSource->mFeatureType == QgsGPXProvider::RouteType ) { - for ( QgsGpsData::RouteIterator it = mSource->mData->routesBegin() ; it != mSource->mData->routesEnd(); ++it ) + for ( QgsGpsData::RouteIterator it = mSource->mData->routesBegin(); it != mSource->mData->routesEnd(); ++it ) { if ( it->id == fid ) { @@ -238,7 +238,7 @@ bool QgsGPXFeatureIterator::readFid( QgsFeature &feature ) } else if ( mSource->mFeatureType == QgsGPXProvider::TrackType ) { - for ( QgsGpsData::TrackIterator it = mSource->mData->tracksBegin() ; it != mSource->mData->tracksEnd(); ++it ) + for ( QgsGpsData::TrackIterator it = mSource->mData->tracksBegin(); it != mSource->mData->tracksEnd(); ++it ) { if ( it->id == fid ) { @@ -256,7 +256,7 @@ bool QgsGPXFeatureIterator::readWaypoint( const QgsWaypoint &wpt, QgsFeature &fe { if ( !mFilterRect.isNull() ) { - if ( ! mFilterRect.contains( wpt.lon, wpt.lat ) ) + if ( !mFilterRect.contains( wpt.lon, wpt.lat ) ) return false; } @@ -287,8 +287,7 @@ bool QgsGPXFeatureIterator::readRoute( const QgsRoute &rte, QgsFeature &feature if ( !mFilterRect.isNull() ) { - if ( ( rte.xMax < mFilterRect.xMinimum() ) || ( rte.xMin > mFilterRect.xMaximum() ) || - ( rte.yMax < mFilterRect.yMinimum() ) || ( rte.yMin > mFilterRect.yMaximum() ) ) + if ( ( rte.xMax < mFilterRect.xMinimum() ) || ( rte.xMin > mFilterRect.xMaximum() ) || ( rte.yMax < mFilterRect.yMinimum() ) || ( rte.yMin > mFilterRect.yMaximum() ) ) { delete geometry; return false; @@ -329,8 +328,7 @@ bool QgsGPXFeatureIterator::readTrack( const QgsTrack &trk, QgsFeature &feature if ( !mFilterRect.isNull() ) { - if ( ( trk.xMax < mFilterRect.xMinimum() ) || ( trk.xMin > mFilterRect.xMaximum() ) || - ( trk.yMax < mFilterRect.yMinimum() ) || ( trk.yMin > mFilterRect.yMaximum() ) ) + if ( ( trk.xMax < mFilterRect.xMinimum() ) || ( trk.xMin > mFilterRect.xMaximum() ) || ( trk.yMax < mFilterRect.yMinimum() ) || ( trk.yMin > mFilterRect.yMaximum() ) ) { delete geometry; return false; @@ -513,7 +511,7 @@ QgsGeometry *QgsGPXFeatureIterator::readTrackGeometry( const QgsTrack &trk ) // A track consists of several segments. Add all those segments into one. int totalPoints = 0; - for ( int i = 0; i < trk.segments.size(); i ++ ) + for ( int i = 0; i < trk.segments.size(); i++ ) { totalPoints += trk.segments[i].points.size(); } diff --git a/src/providers/gpx/qgsgpxfeatureiterator.h b/src/providers/gpx/qgsgpxfeatureiterator.h index 652de287346f..631003ebc454 100644 --- a/src/providers/gpx/qgsgpxfeatureiterator.h +++ b/src/providers/gpx/qgsgpxfeatureiterator.h @@ -24,7 +24,7 @@ class QgsGPXProvider; -class QgsGPXFeatureSource final: public QgsAbstractFeatureSource +class QgsGPXFeatureSource final : public QgsAbstractFeatureSource { public: explicit QgsGPXFeatureSource( const QgsGPXProvider *p ); @@ -44,7 +44,7 @@ class QgsGPXFeatureSource final: public QgsAbstractFeatureSource }; -class QgsGPXFeatureIterator final: public QgsAbstractFeatureIteratorFromSource +class QgsGPXFeatureIterator final : public QgsAbstractFeatureIteratorFromSource { public: QgsGPXFeatureIterator( QgsGPXFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ); @@ -55,11 +55,9 @@ class QgsGPXFeatureIterator final: public QgsAbstractFeatureIteratorFromSource mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; }; #endif // QGSGPXFEATUREITERATOR_H diff --git a/src/providers/gpx/qgsgpxprovider.cpp b/src/providers/gpx/qgsgpxprovider.cpp index d74287e102b1..d8810215afb1 100644 --- a/src/providers/gpx/qgsgpxprovider.cpp +++ b/src/providers/gpx/qgsgpxprovider.cpp @@ -47,19 +47,31 @@ #include "moc_qgsgpxprovider.cpp" #include "gpsdata.h" -const QStringList QgsGPXProvider::sAttributeNames = { "name", "elevation", "symbol", "number", - "comment", "description", "source", - "url", "url name", "time" - }; -const QList< QMetaType::Type > QgsGPXProvider::sAttributeTypes = { QMetaType::Type::QString, QMetaType::Type::Double, QMetaType::Type::QString, QMetaType::Type::Int, - QMetaType::Type::QString, QMetaType::Type::QString, QMetaType::Type::QString, - QMetaType::Type::QString, QMetaType::Type::QString, QMetaType::Type::QDateTime, - }; -const QList< QgsGPXProvider::DataType > QgsGPXProvider::sAttributedUsedForLayerType = -{ - QgsGPXProvider::AllType, QgsGPXProvider::WaypointType, QgsGPXProvider::TrkRteType, QgsGPXProvider::TrkRteType, - QgsGPXProvider::AllType, QgsGPXProvider::AllType, QgsGPXProvider::AllType, QgsGPXProvider::AllType, - QgsGPXProvider::AllType, QgsGPXProvider::AllType, QgsGPXProvider::WaypointType, +const QStringList QgsGPXProvider::sAttributeNames = { "name", "elevation", "symbol", "number", "comment", "description", "source", "url", "url name", "time" }; +const QList QgsGPXProvider::sAttributeTypes = { + QMetaType::Type::QString, + QMetaType::Type::Double, + QMetaType::Type::QString, + QMetaType::Type::Int, + QMetaType::Type::QString, + QMetaType::Type::QString, + QMetaType::Type::QString, + QMetaType::Type::QString, + QMetaType::Type::QString, + QMetaType::Type::QDateTime, +}; +const QList QgsGPXProvider::sAttributedUsedForLayerType = { + QgsGPXProvider::AllType, + QgsGPXProvider::WaypointType, + QgsGPXProvider::TrkRteType, + QgsGPXProvider::TrkRteType, + QgsGPXProvider::AllType, + QgsGPXProvider::AllType, + QgsGPXProvider::AllType, + QgsGPXProvider::AllType, + QgsGPXProvider::AllType, + QgsGPXProvider::AllType, + QgsGPXProvider::WaypointType, }; const QString GPX_KEY = QStringLiteral( "gpx" ); @@ -125,9 +137,7 @@ QString QgsGPXProvider::storageType() const Qgis::VectorProviderCapabilities QgsGPXProvider::capabilities() const { - return Qgis::VectorProviderCapability::AddFeatures | - Qgis::VectorProviderCapability::DeleteFeatures | - Qgis::VectorProviderCapability::ChangeAttributeValues; + return Qgis::VectorProviderCapability::AddFeatures | Qgis::VectorProviderCapability::DeleteFeatures | Qgis::VectorProviderCapability::ChangeAttributeValues; } QgsRectangle QgsGPXProvider::extent() const @@ -151,7 +161,7 @@ Qgis::WkbType QgsGPXProvider::wkbType() const long long QgsGPXProvider::featureCount() const { if ( !mData ) - return static_cast< long long >( Qgis::FeatureCountState::UnknownCount ); + return static_cast( Qgis::FeatureCountState::UnknownCount ); if ( mFeatureType == WaypointType ) return mData->getNumberOfWaypoints(); @@ -214,7 +224,6 @@ bool QgsGPXProvider::addFeature( QgsFeature &f, Flags ) // is it a waypoint? if ( mFeatureType == WaypointType && geo && wkbType == Qgis::WkbType::Point ) { - // add geometry QgsWaypoint wpt; std::memcpy( &wpt.lon, geo + 5, sizeof( double ) ); @@ -244,7 +253,6 @@ bool QgsGPXProvider::addFeature( QgsFeature &f, Flags ) // is it a route? if ( mFeatureType == RouteType && geo && wkbType == Qgis::WkbType::LineString ) { - QgsRoute rte; // reset bounds @@ -291,7 +299,6 @@ bool QgsGPXProvider::addFeature( QgsFeature &f, Flags ) // is it a track? if ( mFeatureType == TrackType && geo && wkbType == Qgis::WkbType::LineString ) { - QgsTrack trk; QgsTrackSegment trkseg; @@ -346,19 +353,19 @@ bool QgsGPXProvider::addFeature( QgsFeature &f, Flags ) switch ( mIndexToAttr.at( i ) ) { case NameAttr: - obj->name = attrs.at( i ).toString(); + obj->name = attrs.at( i ).toString(); break; case CmtAttr: - obj->cmt = attrs.at( i ).toString(); + obj->cmt = attrs.at( i ).toString(); break; case DscAttr: - obj->desc = attrs.at( i ).toString(); + obj->desc = attrs.at( i ).toString(); break; case SrcAttr: - obj->src = attrs.at( i ).toString(); + obj->src = attrs.at( i ).toString(); break; case URLAttr: - obj->url = attrs.at( i ).toString(); + obj->url = attrs.at( i ).toString(); break; case URLNameAttr: obj->urlname = attrs.at( i ).toString(); @@ -445,7 +452,6 @@ bool QgsGPXProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_ void QgsGPXProvider::changeAttributeValues( QgsGpsObject &obj, const QgsAttributeMap &attrs ) { - QgsWaypoint *wpt = dynamic_cast( &obj ); QgsGpsExtended *ext = dynamic_cast( &obj ); @@ -459,19 +465,19 @@ void QgsGPXProvider::changeAttributeValues( QgsGpsObject &obj, const QgsAttribut switch ( mIndexToAttr.at( i ) ) { case NameAttr: - obj.name = v.toString(); + obj.name = v.toString(); break; case CmtAttr: - obj.cmt = v.toString(); + obj.cmt = v.toString(); break; case DscAttr: - obj.desc = v.toString(); + obj.desc = v.toString(); break; case SrcAttr: - obj.src = v.toString(); + obj.src = v.toString(); break; case URLAttr: - obj.url = v.toString(); + obj.url = v.toString(); break; case URLNameAttr: obj.urlname = v.toString(); @@ -503,9 +509,7 @@ void QgsGPXProvider::changeAttributeValues( QgsGpsObject &obj, const QgsAttribut ext->number = num; } } - } - } QVariant QgsGPXProvider::defaultValue( int fieldId ) const @@ -535,8 +539,7 @@ QString QgsGPXProvider::encodeUri( const QVariantMap &parts ) if ( parts.value( QStringLiteral( "layerName" ) ).toString().isEmpty() ) return parts.value( QStringLiteral( "path" ) ).toString(); else - return QStringLiteral( "%1?type=%2" ).arg( parts.value( QStringLiteral( "path" ) ).toString(), - parts.value( QStringLiteral( "layerName" ) ).toString() ); + return QStringLiteral( "%1?type=%2" ).arg( parts.value( QStringLiteral( "path" ) ).toString(), parts.value( QStringLiteral( "layerName" ) ).toString() ); } QVariantMap QgsGPXProvider::decodeUri( const QString &uri ) @@ -555,8 +558,8 @@ QVariantMap QgsGPXProvider::decodeUri( const QString &uri ) return res; } -QgsGpxProviderMetadata::QgsGpxProviderMetadata(): - QgsProviderMetadata( GPX_KEY, GPX_DESCRIPTION ) +QgsGpxProviderMetadata::QgsGpxProviderMetadata() + : QgsProviderMetadata( GPX_KEY, GPX_DESCRIPTION ) { } diff --git a/src/providers/gpx/qgsgpxprovider.h b/src/providers/gpx/qgsgpxprovider.h index 397ae6183d55..a3936cb4db14 100644 --- a/src/providers/gpx/qgsgpxprovider.h +++ b/src/providers/gpx/qgsgpxprovider.h @@ -38,7 +38,7 @@ class QgsGPXFeatureIterator; * \brief Data provider for GPX (GPS eXchange) files * This provider adds the ability to load GPX files as vector layers. */ -class QgsGPXProvider final: public QgsVectorDataProvider +class QgsGPXProvider final : public QgsVectorDataProvider { Q_OBJECT @@ -72,8 +72,7 @@ class QgsGPXProvider final: public QgsVectorDataProvider /* new functions */ - void changeAttributeValues( QgsGpsObject &obj, - const QgsAttributeMap &attrs ); + void changeAttributeValues( QgsGpsObject &obj, const QgsAttributeMap &attrs ); bool addFeature( QgsFeature &f, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override; @@ -91,13 +90,21 @@ class QgsGPXProvider final: public QgsVectorDataProvider }; - enum Attribute { NameAttr = 0, EleAttr, SymAttr, NumAttr, - CmtAttr, DscAttr, SrcAttr, URLAttr, URLNameAttr, - TimeAttr - }; + enum Attribute + { + NameAttr = 0, + EleAttr, + SymAttr, + NumAttr, + CmtAttr, + DscAttr, + SrcAttr, + URLAttr, + URLNameAttr, + TimeAttr + }; private: - QgsGpsData *mData = nullptr; //! Fields @@ -110,15 +117,15 @@ class QgsGPXProvider final: public QgsVectorDataProvider DataType mFeatureType = WaypointType; static const QStringList sAttributeNames; - static const QList< QMetaType::Type > sAttributeTypes; - static const QList< DataType > sAttributedUsedForLayerType; + static const QList sAttributeTypes; + static const QList sAttributedUsedForLayerType; bool mValid = false; friend class QgsGPXFeatureSource; }; -class QgsGpxProviderMetadata final: public QgsProviderMetadata +class QgsGpxProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: @@ -130,7 +137,7 @@ class QgsGpxProviderMetadata final: public QgsProviderMetadata QVariantMap decodeUri( const QString &uri ) const override; QString absoluteToRelativeUri( const QString &uri, const QgsReadWriteContext &context ) const override; QString relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif diff --git a/src/providers/gpx/qgsgpxprovidergui.cpp b/src/providers/gpx/qgsgpxprovidergui.cpp index 9e600bdbc8a9..b50c77c33c96 100644 --- a/src/providers/gpx/qgsgpxprovidergui.cpp +++ b/src/providers/gpx/qgsgpxprovidergui.cpp @@ -25,7 +25,6 @@ class QgsGpxSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "gpx" ); } QString text() const override { return QObject::tr( "GPS" ); } int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 65; } @@ -37,7 +36,7 @@ class QgsGpxSourceSelectProvider : public QgsSourceSelectProvider }; -class QgsGpxProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsGpxProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsGpxProviderGuiMetadata() diff --git a/src/providers/gpx/qgsgpxsourceselect.cpp b/src/providers/gpx/qgsgpxsourceselect.cpp index 50bc9c723dfd..8d924a74af42 100644 --- a/src/providers/gpx/qgsgpxsourceselect.cpp +++ b/src/providers/gpx/qgsgpxsourceselect.cpp @@ -23,8 +23,8 @@ #include -QgsGpxSourceSelect::QgsGpxSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ): - QgsAbstractDataSourceWidget( parent, fl, widgetMode ) +QgsGpxSourceSelect::QgsGpxSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ) + : QgsAbstractDataSourceWidget( parent, fl, widgetMode ) { setupUi( this ); setupButtons( buttonBox ); @@ -32,14 +32,12 @@ QgsGpxSourceSelect::QgsGpxSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs mFileWidget->setDialogTitle( tr( "Open GPX Dataset" ) ); mFileWidget->setFilter( QStringLiteral( "%1 (*.gpx *.GPX)" ).arg( tr( "GPX files" ) ) ); mFileWidget->setStorageMode( QgsFileWidget::GetFile ); - connect( mFileWidget, &QgsFileWidget::fileChanged, this, [ = ]( const QString & path ) - { + connect( mFileWidget, &QgsFileWidget::fileChanged, this, [=]( const QString &path ) { mGpxPath = path; emit enableButtons( !mGpxPath.isEmpty() ); } ); - connect( mFileWidget, &QgsFileWidget::fileChanged, - this, &QgsGpxSourceSelect::enableRelevantControls ); + connect( mFileWidget, &QgsFileWidget::fileChanged, this, &QgsGpxSourceSelect::enableRelevantControls ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsGpxSourceSelect::showHelp ); } @@ -48,47 +46,38 @@ void QgsGpxSourceSelect::addButtonClicked() { if ( mGpxPath.isEmpty() ) { - QMessageBox::information( this, - tr( "Add GPX Layer" ), - tr( "No layers selected." ) ); + QMessageBox::information( this, tr( "Add GPX Layer" ), tr( "No layers selected." ) ); return; } const QFileInfo fileInfo( mGpxPath ); if ( !fileInfo.isReadable() ) { - QMessageBox::warning( nullptr, tr( "Add GPX Layer" ), - tr( "Unable to read the selected file.\n" - "Please select a valid file." ) ); + QMessageBox::warning( nullptr, tr( "Add GPX Layer" ), tr( "Unable to read the selected file.\n" + "Please select a valid file." ) ); return; } if ( cbGPXTracks->isChecked() ) { Q_NOWARN_DEPRECATED_PUSH - emit addVectorLayer( mGpxPath + "?type=track", - fileInfo.baseName() + ", tracks", QStringLiteral( "gpx" ) ); + emit addVectorLayer( mGpxPath + "?type=track", fileInfo.baseName() + ", tracks", QStringLiteral( "gpx" ) ); Q_NOWARN_DEPRECATED_POP - emit addLayer( Qgis::LayerType::Vector, mGpxPath + "?type=track", - fileInfo.baseName() + ", tracks", QStringLiteral( "gpx" ) ); + emit addLayer( Qgis::LayerType::Vector, mGpxPath + "?type=track", fileInfo.baseName() + ", tracks", QStringLiteral( "gpx" ) ); } if ( cbGPXRoutes->isChecked() ) { Q_NOWARN_DEPRECATED_PUSH - emit addVectorLayer( mGpxPath + "?type=route", - fileInfo.baseName() + ", routes", QStringLiteral( "gpx" ) ); + emit addVectorLayer( mGpxPath + "?type=route", fileInfo.baseName() + ", routes", QStringLiteral( "gpx" ) ); Q_NOWARN_DEPRECATED_POP - emit addLayer( Qgis::LayerType::Vector, mGpxPath + "?type=route", - fileInfo.baseName() + ", routes", QStringLiteral( "gpx" ) ); + emit addLayer( Qgis::LayerType::Vector, mGpxPath + "?type=route", fileInfo.baseName() + ", routes", QStringLiteral( "gpx" ) ); } if ( cbGPXWaypoints->isChecked() ) { Q_NOWARN_DEPRECATED_PUSH - emit addVectorLayer( mGpxPath + "?type=waypoint", - fileInfo.baseName() + ", waypoints", QStringLiteral( "gpx" ) ); + emit addVectorLayer( mGpxPath + "?type=waypoint", fileInfo.baseName() + ", waypoints", QStringLiteral( "gpx" ) ); Q_NOWARN_DEPRECATED_POP - emit addLayer( Qgis::LayerType::Vector, mGpxPath + "?type=waypoint", - fileInfo.baseName() + ", waypoints", QStringLiteral( "gpx" ) ); + emit addLayer( Qgis::LayerType::Vector, mGpxPath + "?type=waypoint", fileInfo.baseName() + ", waypoints", QStringLiteral( "gpx" ) ); } } diff --git a/src/providers/gpx/qgsgpxsourceselect.h b/src/providers/gpx/qgsgpxsourceselect.h index 896f962e4108..29124ba5e8db 100644 --- a/src/providers/gpx/qgsgpxsourceselect.h +++ b/src/providers/gpx/qgsgpxsourceselect.h @@ -45,7 +45,6 @@ class QgsGpxSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsGp private: QString mGpxPath; - }; #endif // QGSGPXSOURCESELECT_H diff --git a/src/providers/grass/qgis.d.rast.c b/src/providers/grass/qgis.d.rast.c index ec81be407342..3cc151b03c85 100644 --- a/src/providers/grass/qgis.d.rast.c +++ b/src/providers/grass/qgis.d.rast.c @@ -39,10 +39,10 @@ #include #include -#if defined(_MSC_VER) && _MSC_VER < 1900 +#if defined( _MSC_VER ) && _MSC_VER < 1900 #include -#define INFINITY (DBL_MAX+DBL_MAX) -#define NAN (INFINITY-INFINITY) +#define INFINITY ( DBL_MAX + DBL_MAX ) +#define NAN ( INFINITY - INFINITY ) #endif int display( char *name, char *mapset, RASTER_MAP_TYPE data_type, char *format ); @@ -109,10 +109,7 @@ int main( int argc, char **argv ) static int cell_draw( char *, char *, struct Colors *, RASTER_MAP_TYPE, char *format ); -int display( char *name, - char *mapset, - RASTER_MAP_TYPE data_type, - char *format ) +int display( char *name, char *mapset, RASTER_MAP_TYPE data_type, char *format ) { struct Colors colors; @@ -130,11 +127,7 @@ int display( char *name, return 0; } -static int cell_draw( char *name, - char *mapset, - struct Colors *colors, - RASTER_MAP_TYPE data_type, - char *format ) +static int cell_draw( char *name, char *mapset, struct Colors *colors, RASTER_MAP_TYPE data_type, char *format ) { int cellfile; void *xarray = 0; @@ -149,7 +142,7 @@ static int cell_draw( char *name, size_t raster_size; #ifdef NAN double dnul = NAN; - float fnul = ( float )( NAN ); + float fnul = ( float ) ( NAN ); #else double dnul = strtod( "NAN", 0 ); float fnul = strtof( "NAN", 0 ); @@ -160,7 +153,7 @@ static int cell_draw( char *name, assert( dnul != dnul ); assert( fnul != fnul ); - big_endian = !( *( ( char * )( &one ) ) ); + big_endian = !( *( ( char * ) ( &one ) ) ); ncols = Rast_window_cols(); nrows = Rast_window_rows(); @@ -194,8 +187,7 @@ static int cell_draw( char *name, Rast_get_row( cellfile, xarray, row, data_type ); ptr = xarray; - Rast_lookup_colors( xarray, red, grn, blu, set, ncols, colors, - data_type ); + Rast_lookup_colors( xarray, red, grn, blu, set, ncols, colors, data_type ); for ( i = 0; i < ncols; i++ ) { diff --git a/src/providers/grass/qgis.g.info.c b/src/providers/grass/qgis.g.info.c index a73570a393b4..188060c75017 100644 --- a/src/providers/grass/qgis.g.info.c +++ b/src/providers/grass/qgis.g.info.c @@ -32,7 +32,7 @@ #include #include #include -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -301,10 +301,10 @@ int main( int argc, char **argv ) double min = DBL_MAX; double max = -DBL_MAX; double sum = 0; // sum of values - int count = 0; // count of non null values + int count = 0; // count of non null values double mean = 0; double squares_sum = 0; // sum of squares - double stdev = 0; // standard deviation + double stdev = 0; // standard deviation Rast_get_cellhd( rast_opt->answer, "", &window ); window.north = atof( north_opt->answer ); @@ -350,10 +350,12 @@ int main( int argc, char **argv ) val = dcell[col]; ptr = &( dcell[col] ); } - if ( ! Rast_is_null_value( ptr, rast_type ) ) + if ( !Rast_is_null_value( ptr, rast_type ) ) { - if ( val < min ) min = val; - if ( val > max ) max = val; + if ( val < min ) + min = val; + if ( val > max ) + max = val; sum += val; count++; squares_sum += val * val; @@ -382,4 +384,3 @@ int main( int argc, char **argv ) exit( EXIT_SUCCESS ); } - diff --git a/src/providers/grass/qgis.r.in.cpp b/src/providers/grass/qgis.r.in.cpp index ebb2bfc814f5..2330a1f61c78 100644 --- a/src/providers/grass/qgis.r.in.cpp +++ b/src/providers/grass/qgis.r.in.cpp @@ -109,7 +109,7 @@ int main( int argc, char **argv ) qint32 type; stdinStream >> type; checkStream( stdinStream ); - qgis_type = ( Qgis::DataType )type; + qgis_type = ( Qgis::DataType ) type; RASTER_MAP_TYPE grass_type; switch ( qgis_type ) @@ -177,35 +177,35 @@ int main( int argc, char **argv ) { if ( grass_type == CELL_TYPE ) { - if ( ( CELL )cell[col] == ( CELL )noDataValue ) + if ( ( CELL ) cell[col] == ( CELL ) noDataValue ) { - Rast_set_c_null_value( ( CELL * )ptr, 1 ); + Rast_set_c_null_value( ( CELL * ) ptr, 1 ); } else { - Rast_set_c_value( ptr, ( CELL )( cell[col] ), grass_type ); + Rast_set_c_value( ptr, ( CELL ) ( cell[col] ), grass_type ); } } else if ( grass_type == FCELL_TYPE ) { - if ( ( FCELL )fcell[col] == ( FCELL )noDataValue ) + if ( ( FCELL ) fcell[col] == ( FCELL ) noDataValue ) { - Rast_set_f_null_value( ( FCELL * )ptr, 1 ); + Rast_set_f_null_value( ( FCELL * ) ptr, 1 ); } else { - Rast_set_f_value( ptr, ( FCELL )( fcell[col] ), grass_type ); + Rast_set_f_value( ptr, ( FCELL ) ( fcell[col] ), grass_type ); } } else if ( grass_type == DCELL_TYPE ) { - if ( ( DCELL )dcell[col] == ( DCELL )noDataValue ) + if ( ( DCELL ) dcell[col] == ( DCELL ) noDataValue ) { - Rast_set_d_null_value( ( DCELL * )ptr, 1 ); + Rast_set_d_null_value( ( DCELL * ) ptr, 1 ); } else { - Rast_set_d_value( ptr, ( DCELL )dcell[col], grass_type ); + Rast_set_d_value( ptr, ( DCELL ) dcell[col], grass_type ); } } @@ -218,7 +218,7 @@ int main( int argc, char **argv ) // we cannot in QgsGrassImport wait for this because it hangs. Setting _IONBF on stdin does not help // and there is no flush() on QProcess. // OTOH, smaller stdin buffer is probably blocking QgsGrassImport so that the import can be canceled immediately. - stdoutStream << ( bool )true; // row written + stdoutStream << ( bool ) true; // row written stdoutFile.flush(); #endif } diff --git a/src/providers/grass/qgis.v.in.cpp b/src/providers/grass/qgis.v.in.cpp index 7b7295ee7a56..ed2856cf78ef 100644 --- a/src/providers/grass/qgis.v.in.cpp +++ b/src/providers/grass/qgis.v.in.cpp @@ -150,7 +150,7 @@ int main( int argc, char **argv ) qint32 typeQint32; stdinStream >> typeQint32; checkStream( stdinStream ); - Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( typeQint32 ); + Qgis::WkbType wkbType = static_cast( typeQint32 ); Qgis::WkbType wkbFlatType = QgsWkbTypes::flatType( wkbType ); bool isPolygon = QgsWkbTypes::singleType( wkbFlatType ) == Qgis::WkbType::Polygon; @@ -187,8 +187,7 @@ int main( int argc, char **argv ) fields.extend( srcFields ); struct field_info *fieldInfo = Vect_default_field_info( finalMap, 1, nullptr, GV_1TABLE ); - if ( Vect_map_add_dblink( finalMap, 1, nullptr, fieldInfo->table, key.toLatin1().data(), - fieldInfo->database, fieldInfo->driver ) != 0 ) + if ( Vect_map_add_dblink( finalMap, 1, nullptr, fieldInfo->table, key.toLatin1().data(), fieldInfo->database, fieldInfo->driver ) != 0 ) { G_fatal_error( "Cannot add link" ); } @@ -231,7 +230,7 @@ int main( int argc, char **argv ) checkStream( stdinStream ); #ifndef Q_OS_WIN // cannot be used on Windows, see notes in qgis.r.in -//#if 0 + //#if 0 stdoutStream << true; // feature received stdoutFile.flush(); //#endif diff --git a/src/providers/grass/qgsgrass.cpp b/src/providers/grass/qgsgrass.cpp index d40d5cf1f032..9613a593ce52 100644 --- a/src/providers/grass/qgsgrass.cpp +++ b/src/providers/grass/qgsgrass.cpp @@ -65,7 +65,7 @@ extern "C" #include #endif #include -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -76,8 +76,7 @@ extern "C" #define GRASS_LOCK sMutex.lock(); #define GRASS_UNLOCK sMutex.unlock(); -QgsGrassObject::QgsGrassObject( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &name, Type type ) +QgsGrassObject::QgsGrassObject( const QString &gisdbase, const QString &location, const QString &mapset, const QString &name, Type type ) : mGisdbase( gisdbase ) , mLocation( location ) , mMapset( mapset ) @@ -137,7 +136,7 @@ bool QgsGrassObject::setFromUri( const QString &uri ) // QFileInfo.canonicalPath() on non existing file does not work (returns empty string) // QFileInfo.absolutePath() does not necessarily remove symbolic links or redundant "." or ".." QDir dir = fi.dir(); // .../mapset/vector_map - does not exist - if ( dir.cdUp() ) // .../mapset/ + if ( dir.cdUp() ) // .../mapset/ { QString path = dir.canonicalPath(); QRegExp rx( "(.*)/([^/]*)/([^/]*)" ); @@ -276,8 +275,7 @@ QString QgsGrass::shortPath( const QString &path ) if ( len == 0 || len > MAX_PATH ) { - QgsDebugMsgLevel( QString( "GetShortPathName('%1') failed with %2: %3" ) - .arg( path ).arg( len ).arg( GetLastError() ), 2 ); + QgsDebugMsgLevel( QString( "GetShortPathName('%1') failed with %2: %3" ).arg( path ).arg( len ).arg( GetLastError() ), 2 ); return path; } @@ -337,7 +335,7 @@ bool QgsGrass::init( void ) // G_no_gisinit() may end with fatal error if QGIS is run with a version of GRASS different from that used for compilation G_TRY { - G_no_gisinit(); // Doesn't check write permissions for mapset compare to G_gisinit("libgrass++"); + G_no_gisinit(); // Doesn't check write permissions for mapset compare to G_gisinit("libgrass++"); } G_CATCH( QgsGrass::Exception & e ) { @@ -684,7 +682,7 @@ void QgsGrass::loadMapsetSearchPath() { QgsDebugError( "cannot load mapset search path: " + QString( e.what() ) ); } - QgsDebugMsgLevel( QStringLiteral( "mMapsetSearchPath = " ) + mMapsetSearchPath.join( ',' ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "mMapsetSearchPath = " ) + mMapsetSearchPath.join( ',' ), 2 ); if ( mMapsetSearchPath != oldMapsetSearchPath ) { emit mapsetSearchPathChanged(); @@ -838,8 +836,7 @@ bool QgsGrass::isOwner( const QString &gisdbase, const QString &location, const return owner; } -QString QgsGrass::openMapset( const QString &gisdbase, - const QString &location, const QString &mapset ) +QString QgsGrass::openMapset( const QString &gisdbase, const QString &location, const QString &mapset ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1" ).arg( gisdbase.toUtf8().constData() ), 2 ); QgsDebugMsgLevel( QStringLiteral( "location = %1" ).arg( location.toUtf8().constData() ), 2 ); @@ -886,9 +883,10 @@ QString QgsGrass::openMapset( const QString &gisdbase, process.waitForFinished( 5000 ); QString processResult = QStringLiteral( "exitStatus=%1, exitCode=%2, errorCode=%3, error=%4 stdout=%5, stderr=%6" ) - .arg( process.exitStatus() ).arg( process.exitCode() ) - .arg( process.error() ).arg( process.errorString(), - process.readAllStandardOutput().constData(), process.readAllStandardError().constData() ); + .arg( process.exitStatus() ) + .arg( process.exitCode() ) + .arg( process.error() ) + .arg( process.errorString(), process.readAllStandardOutput().constData(), process.readAllStandardError().constData() ); QgsDebugMsgLevel( "processResult: " + processResult, 2 ); // lock exit code: @@ -959,9 +957,7 @@ QString QgsGrass::openMapset( const QString &gisdbase, while ( in.readLine( buf, 1000 ) != -1 ) { line = buf; - if ( line.contains( QLatin1String( "GISDBASE:" ) ) || - line.contains( QLatin1String( "LOCATION_NAME:" ) ) || - line.contains( QLatin1String( "MAPSET:" ) ) ) + if ( line.contains( QLatin1String( "GISDBASE:" ) ) || line.contains( QLatin1String( "LOCATION_NAME:" ) ) || line.contains( QLatin1String( "MAPSET:" ) ) ) { continue; } @@ -1021,13 +1017,12 @@ QString QgsGrass::openMapset( const QString &gisdbase, sMapsetLock = lock; - emit QgsGrass::instance()->mapsetChanged(); + emit QgsGrass::instance() -> mapsetChanged(); return QString(); } QString QgsGrass::closeMapset() { - if ( sMapsetLock.length() > 0 ) { #ifndef Q_OS_WIN @@ -1083,13 +1078,12 @@ QString QgsGrass::closeMapset() } QgsGrass::instance()->setMapsetSearchPathWatcher(); // unset watcher - emit QgsGrass::instance()->mapsetChanged(); + emit QgsGrass::instance() -> mapsetChanged(); return QString(); } bool QgsGrass::closeMapsetWarn() { - QString err = QgsGrass::closeMapset(); if ( !err.isNull() ) @@ -1102,20 +1096,15 @@ bool QgsGrass::closeMapsetWarn() void QgsGrass::saveMapset() { - // Save working mapset in project file - QgsProject::instance()->writeEntry( QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingGisdbase" ), - QgsProject::instance()->writePath( getDefaultGisdbase() ) ); + QgsProject::instance()->writeEntry( QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingGisdbase" ), QgsProject::instance()->writePath( getDefaultGisdbase() ) ); - QgsProject::instance()->writeEntry( QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingLocation" ), - getDefaultLocation() ); + QgsProject::instance()->writeEntry( QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingLocation" ), getDefaultLocation() ); - QgsProject::instance()->writeEntry( QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingMapset" ), - getDefaultMapset() ); + QgsProject::instance()->writeEntry( QStringLiteral( "GRASS" ), QStringLiteral( "/WorkingMapset" ), getDefaultMapset() ); } -void QgsGrass::createMapset( const QString &gisdbase, const QString &location, - const QString &mapset, QString &error ) +void QgsGrass::createMapset( const QString &gisdbase, const QString &location, const QString &mapset, QString &error ) { QString locationPath = gisdbase + "/" + location; QDir locationDir( locationPath ); @@ -1148,8 +1137,7 @@ QStringList QgsGrass::locations( const QString &gisdbase ) for ( unsigned int i = 0; i < d.count(); i++ ) { - if ( QFile::exists( gisdbase + "/" + d[i] - + "/PERMANENT/DEFAULT_WIND" ) ) + if ( QFile::exists( gisdbase + "/" + d[i] + "/PERMANENT/DEFAULT_WIND" ) ) { list.append( QString( d[i] ) ); } @@ -1189,10 +1177,8 @@ QStringList QgsGrass::mapsets( const QString &locationPath ) return list; } -QStringList QgsGrass::vectors( const QString &gisdbase, const QString &locationName, - const QString &mapsetName ) +QStringList QgsGrass::vectors( const QString &gisdbase, const QString &locationName, const QString &mapsetName ) { - if ( gisdbase.isEmpty() || locationName.isEmpty() || mapsetName.isEmpty() ) return QStringList(); @@ -1251,8 +1237,7 @@ QStringList QgsGrass::vectors( const QString &mapsetPath ) return list; } -bool QgsGrass::topoVersion( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &mapName, int &major, int &minor ) +bool QgsGrass::topoVersion( const QString &gisdbase, const QString &location, const QString &mapset, const QString &mapName, int &major, int &minor ) { QString path = gisdbase + "/" + location + "/" + mapset + "/vector/" + mapName + "/topo"; QFile file( path ); @@ -1274,8 +1259,7 @@ bool QgsGrass::topoVersion( const QString &gisdbase, const QString &location, return true; } -QStringList QgsGrass::vectorLayers( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &mapName ) +QStringList QgsGrass::vectorLayers( const QString &gisdbase, const QString &location, const QString &mapset, const QString &mapName ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2 mapset = %3 mapName = %4" ).arg( gisdbase, location, mapset, mapName ), 2 ); @@ -1362,10 +1346,8 @@ QStringList QgsGrass::vectorLayers( const QString &gisdbase, const QString &loca return list; } -QStringList QgsGrass::rasters( const QString &gisdbase, const QString &locationName, - const QString &mapsetName ) +QStringList QgsGrass::rasters( const QString &gisdbase, const QString &locationName, const QString &mapsetName ) { - if ( gisdbase.isEmpty() || locationName.isEmpty() || mapsetName.isEmpty() ) return QStringList(); @@ -1419,8 +1401,7 @@ QStringList QgsGrass::rasters( const QString &mapsetPath ) return list; } -QStringList QgsGrass::groups( const QString &gisdbase, const QString &locationName, - const QString &mapsetName ) +QStringList QgsGrass::groups( const QString &gisdbase, const QString &locationName, const QString &mapsetName ) { return elements( gisdbase, locationName, mapsetName, QStringLiteral( "group" ) ); } @@ -1430,8 +1411,7 @@ QStringList QgsGrass::groups( const QString &mapsetPath ) return elements( mapsetPath, QStringLiteral( "group" ) ); } -QStringList QgsGrass::elements( const QString &gisdbase, const QString &locationName, - const QString &mapsetName, const QString &element ) +QStringList QgsGrass::elements( const QString &gisdbase, const QString &locationName, const QString &mapsetName, const QString &element ) { if ( gisdbase.isEmpty() || locationName.isEmpty() || mapsetName.isEmpty() ) { @@ -1441,7 +1421,7 @@ QStringList QgsGrass::elements( const QString &gisdbase, const QString &location return QgsGrass::elements( gisdbase + "/" + locationName + "/" + mapsetName, element ); } -QStringList QgsGrass::elements( const QString &mapsetPath, const QString &element ) +QStringList QgsGrass::elements( const QString &mapsetPath, const QString &element ) { QgsDebugMsgLevel( QStringLiteral( "mapsetPath = %1 element = %2" ).arg( mapsetPath, element ), 2 ); @@ -1470,7 +1450,7 @@ QStringList QgsGrass::elements( const QString &mapsetPath, const QString &elem QStringList QgsGrass::grassObjects( const QgsGrassObject &mapsetObject, QgsGrassObject::Type type ) { - QgsDebugMsgLevel( QStringLiteral( "mapsetPath = " ) + mapsetObject.mapsetPath() + QStringLiteral( " type = " ) + QgsGrassObject::elementShort( type ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "mapsetPath = " ) + mapsetObject.mapsetPath() + QStringLiteral( " type = " ) + QgsGrassObject::elementShort( type ), 2 ); QElapsedTimer time; time.start(); QStringList list; @@ -1587,8 +1567,7 @@ QString QgsGrass::regionString( const struct Cell_head *window ) } -bool QgsGrass::defaultRegion( const QString &gisdbase, const QString &location, - struct Cell_head *window ) +bool QgsGrass::defaultRegion( const QString &gisdbase, const QString &location, struct Cell_head *window ) { initRegion( window ); QgsGrass::setLocation( gisdbase, location ); @@ -1604,9 +1583,7 @@ bool QgsGrass::defaultRegion( const QString &gisdbase, const QString &location, } } -void QgsGrass::region( const QString &gisdbase, - const QString &location, const QString &mapset, - struct Cell_head *window ) +void QgsGrass::region( const QString &gisdbase, const QString &location, const QString &mapset, struct Cell_head *window ) { QgsGrass::setLocation( gisdbase, location ); @@ -1619,9 +1596,7 @@ void QgsGrass::region( struct Cell_head *window ) region( getDefaultGisdbase(), getDefaultLocation(), getDefaultMapset(), window ); } -bool QgsGrass::writeRegion( const QString &gisbase, - const QString &location, const QString &mapset, - const struct Cell_head *window ) +bool QgsGrass::writeRegion( const QString &gisbase, const QString &location, const QString &mapset, const struct Cell_head *window ) { if ( !window ) { @@ -1655,8 +1630,7 @@ void QgsGrass::writeRegion( const struct Cell_head *window ) emit regionChanged(); } -void QgsGrass::copyRegionExtent( struct Cell_head *source, - struct Cell_head *target ) +void QgsGrass::copyRegionExtent( struct Cell_head *source, struct Cell_head *target ) { target->north = source->north; target->south = source->south; @@ -1666,8 +1640,7 @@ void QgsGrass::copyRegionExtent( struct Cell_head *source, target->bottom = source->bottom; } -void QgsGrass::copyRegionResolution( struct Cell_head *source, - struct Cell_head *target ) +void QgsGrass::copyRegionResolution( struct Cell_head *source, struct Cell_head *target ) { target->ns_res = source->ns_res; target->ew_res = source->ew_res; @@ -1676,8 +1649,7 @@ void QgsGrass::copyRegionResolution( struct Cell_head *source, target->ew_res3 = source->ew_res3; } -void QgsGrass::extendRegion( struct Cell_head *source, - struct Cell_head *target ) +void QgsGrass::extendRegion( struct Cell_head *source, struct Cell_head *target ) { if ( source->north > target->north ) target->north = source->north; @@ -1763,9 +1735,7 @@ QgsRectangle QgsGrass::extent( struct Cell_head *window ) return QgsRectangle( window->west, window->south, window->east, window->north ); } -bool QgsGrass::mapRegion( QgsGrassObject::Type type, const QString &gisdbase, - const QString &location, const QString &mapset, const QString &map, - struct Cell_head *window ) +bool QgsGrass::mapRegion( QgsGrassObject::Type type, const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, struct Cell_head *window ) { QgsDebugMsgLevel( QStringLiteral( "map = %1" ).arg( map ), 2 ); QgsDebugMsgLevel( QStringLiteral( "mapset = %1" ).arg( mapset ), 2 ); @@ -1835,10 +1805,10 @@ bool QgsGrass::mapRegion( QgsGrassObject::Type type, const QString &gisdbase, Vect_get_map_box( Map, &box ); window->north = box.N; window->south = box.S; - window->west = box.W; - window->east = box.E; - window->top = box.T; - window->bottom = box.B; + window->west = box.W; + window->east = box.E; + window->top = box.T; + window->bottom = box.B; // Is this optimal ? window->ns_res = ( window->north - window->south ) / 1000; @@ -1878,7 +1848,7 @@ QString QgsGrass::findModule( QString module ) QgsDebugMsgLevel( QStringLiteral( "called." ), 4 ); if ( QFile::exists( module ) ) { - return module; // full path + return module; // full path } QStringList extensions; @@ -1920,9 +1890,7 @@ QString QgsGrass::findModule( QString module ) return QString(); } -QProcess *QgsGrass::startModule( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &moduleName, const QStringList &arguments, - QTemporaryFile &gisrcFile, bool qgisModule ) +QProcess *QgsGrass::startModule( const QString &gisdbase, const QString &location, const QString &mapset, const QString &moduleName, const QStringList &arguments, QTemporaryFile &gisrcFile, bool qgisModule ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 ); QProcess *process = new QProcess(); @@ -1985,9 +1953,7 @@ QProcess *QgsGrass::startModule( const QString &gisdbase, const QString &locati return process; } -QByteArray QgsGrass::runModule( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &moduleName, - const QStringList &arguments, int timeOut, bool qgisModule ) +QByteArray QgsGrass::runModule( const QString &gisdbase, const QString &location, const QString &mapset, const QString &moduleName, const QStringList &arguments, int timeOut, bool qgisModule ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2 timeOut = %3" ).arg( gisdbase, location ).arg( timeOut ), 2 ); QElapsedTimer time; @@ -2001,11 +1967,7 @@ QByteArray QgsGrass::runModule( const QString &gisdbase, const QString &locatio { QgsDebugMsgLevel( QStringLiteral( "process->exitCode() = " ) + QString::number( process->exitCode() ), 2 ); - throw QgsGrass::Exception( QObject::tr( "Cannot run module" ) + "\n" - + QObject::tr( "command: %1 %2\nstdout: %3\nstderr: %4" ) - .arg( moduleName, arguments.join( QLatin1Char( ' ' ) ), - process->readAllStandardOutput().constData(), - process->readAllStandardError().constData() ) ); + throw QgsGrass::Exception( QObject::tr( "Cannot run module" ) + "\n" + QObject::tr( "command: %1 %2\nstdout: %3\nstderr: %4" ).arg( moduleName, arguments.join( QLatin1Char( ' ' ) ), process->readAllStandardOutput().constData(), process->readAllStandardError().constData() ) ); } QByteArray data = process->readAllStandardOutput(); QgsDebugMsgLevel( QStringLiteral( "time (ms) = %1" ).arg( time.elapsed() ), 2 ); @@ -2013,12 +1975,7 @@ QByteArray QgsGrass::runModule( const QString &gisdbase, const QString &locatio return data; } -QString QgsGrass::getInfo( const QString &info, const QString &gisdbase, - const QString &location, const QString &mapset, - const QString &map, const QgsGrassObject::Type type, - double x, double y, - const QgsRectangle &extent, int sampleRows, - int sampleCols, int timeOut ) +QString QgsGrass::getInfo( const QString &info, const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, const QgsGrassObject::Type type, double x, double y, const QgsRectangle &extent, int sampleRows, int sampleCols, int timeOut ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 ); @@ -2042,7 +1999,7 @@ QString QgsGrass::getInfo( const QString &info, const QString &gisdbase, QgsDebugError( QStringLiteral( "unexpected type:%1" ).arg( type ) ); return QString(); } - arguments.append( opt + "=" + map + "@" + mapset ); + arguments.append( opt + "=" + map + "@" + mapset ); } if ( info == QLatin1String( "query" ) ) { @@ -2065,8 +2022,7 @@ QString QgsGrass::getInfo( const QString &info, const QString &gisdbase, return QString( data ); } -QgsCoordinateReferenceSystem QgsGrass::crs( const QString &gisdbase, const QString &location, - QString &error ) +QgsCoordinateReferenceSystem QgsGrass::crs( const QString &gisdbase, const QString &location, QString &error ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 ); QgsCoordinateReferenceSystem crs; @@ -2159,9 +2115,7 @@ QgsCoordinateReferenceSystem QgsGrass::crsDirect( const QString &gisdbase, const return srs; } -QgsRectangle QgsGrass::extent( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &map, - QgsGrassObject::Type type, QString &error ) +QgsRectangle QgsGrass::extent( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, QgsGrassObject::Type type, QString &error ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 ); @@ -2182,8 +2136,7 @@ QgsRectangle QgsGrass::extent( const QString &gisdbase, const QString &location, return QgsRectangle( 0, 0, 0, 0 ); } -void QgsGrass::size( const QString &gisdbase, const QString &location, const QString &mapset, - const QString &map, int *cols, int *rows, QString &error ) +void QgsGrass::size( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, int *cols, int *rows, QString &error ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 ); @@ -2209,13 +2162,7 @@ void QgsGrass::size( const QString &gisdbase, const QString &location, const QSt QgsDebugMsgLevel( QStringLiteral( "raster size = %1 %2" ).arg( *cols ).arg( *rows ), 2 ); } -QHash QgsGrass::info( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &map, - QgsGrassObject::Type type, - const QString &info, - const QgsRectangle &extent, - int sampleRows, int sampleCols, - int timeOut, QString &error ) +QHash QgsGrass::info( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, QgsGrassObject::Type type, const QString &info, const QgsRectangle &extent, int sampleRows, int sampleCols, int timeOut, QString &error ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 ); QHash inf; @@ -2245,8 +2192,7 @@ QHash QgsGrass::info( const QString &gisdbase, const QString & return inf; } -QList QgsGrass::colors( const QString &gisdbase, const QString &location, const QString &mapset, - const QString &map, QString &error ) +QList QgsGrass::colors( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, QString &error ) { QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 ); QList ct; @@ -2333,7 +2279,6 @@ void QgsGrass::copyObject( const QgsGrassObject &srcObject, const QgsGrassObject bool QgsGrass::deleteObject( const QgsGrassObject &object ) { - // TODO: check if user has permissions /* @@ -2364,15 +2309,11 @@ bool QgsGrass::deleteObject( const QgsGrassObject &object ) bool QgsGrass::deleteObjectDialog( const QgsGrassObject &object ) { - - return QMessageBox::question( nullptr, QObject::tr( "Delete confirmation" ), - QObject::tr( "Are you sure you want to delete %1 %2?" ).arg( object.elementName(), object.name() ), - QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes; + return QMessageBox::question( nullptr, QObject::tr( "Delete confirmation" ), QObject::tr( "Are you sure you want to delete %1 %2?" ).arg( object.elementName(), object.name() ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes; } void QgsGrass::createVectorMap( const QgsGrassObject &object, QString &error ) { - QgsGrass::setMapset( object ); struct Map_info *Map = nullptr; @@ -2435,7 +2376,7 @@ void QgsGrass::createTable( dbDriver *driver, const QString &tableName, const Qg default: typeName = QStringLiteral( "varchar (%1)" ).arg( field.length() > 0 ? field.length() : 255 ); } - fieldsStringList << name + " " + typeName; + fieldsStringList << name + " " + typeName; } QString sql = QStringLiteral( "create table %1 (%2);" ).arg( tableName, fieldsStringList.join( QLatin1String( ", " ) ) ); @@ -2451,8 +2392,7 @@ void QgsGrass::createTable( dbDriver *driver, const QString &tableName, const Qg } } -void QgsGrass::insertRow( dbDriver *driver, const QString &tableName, - const QgsAttributes &attributes ) +void QgsGrass::insertRow( dbDriver *driver, const QString &tableName, const QgsAttributes &attributes ) { if ( !driver ) // should not happen { @@ -2498,7 +2438,7 @@ void QgsGrass::insertRow( dbDriver *driver, const QString &tableName, valueString = "'" + valueString + "'"; } - valuesStringList << valueString; + valuesStringList << valueString; } QString sql = QStringLiteral( "insert into %1 values (%2);" ).arg( tableName, valuesStringList.join( QLatin1String( ", " ) ) ); @@ -2550,8 +2490,7 @@ void QgsGrass::adjustCellHead( struct Cell_head *cellhd, int row_flag, int col_f QMap QgsGrass::vectorTypeMap() { - const thread_local QMap sVectorTypes - { + const thread_local QMap sVectorTypes { { GV_POINT, QStringLiteral( "point" ) }, { GV_CENTROID, QStringLiteral( "centroid" ) }, { GV_LINE, QStringLiteral( "line" ) }, @@ -2598,7 +2537,7 @@ int QgsGrass::versionMinor() int QgsGrass::versionRelease() { #ifdef GRASS_VERSION_RELEASE -#define QUOTE(x) #x +#define QUOTE( x ) #x return QStringLiteral( QUOTE( GRASS_VERSION_RELEASE ) ).toInt(); #else return QString( GRASS_VERSION_RELEASE ).toInt(); @@ -2687,12 +2626,12 @@ QString QgsGrass::defaultGisbase() #ifdef Q_OS_WIN // Use the applicationDirPath()/grass #ifdef _MSC_VER - gisbase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? + "/../.." : "" ) + "/grass" ); + gisbase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? +"/../.." : "" ) + "/grass" ); #else - gisbase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? + "/.." : "" ) + "/grass" ); + gisbase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? +"/.." : "" ) + "/grass" ); #endif // Use the location specified by WITH_GRASS during configure -#elif defined(Q_OS_MACOS) +#elif defined( Q_OS_MACOS ) // check for bundled GRASS, fall back to configured path gisbase = QCoreApplication::applicationDirPath().append( "/grass" ); if ( !isValidGrassBaseDir( gisbase ) ) @@ -2886,7 +2825,7 @@ void QgsGrass::vectDestroyMapStruct( struct Map_info *map ) // TODO: replace by Vect_destroy_map_struct once it appears in GRASS // TODO: until switch to hypothetical Vect_destroy_map_struct verify that Vect_destroy_map_struct cannot // call G_fatal_error, otherwise check and remove use of vectDestroyMapStruct from G_CATCH blocks - QgsDebugMsgLevel( QStringLiteral( "free map = %1" ).arg( ( quint64 )map ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "free map = %1" ).arg( ( quint64 ) map ), 2 ); qgsFree( map ); } diff --git a/src/providers/grass/qgsgrass.h b/src/providers/grass/qgsgrass.h index 39a9cfe45790..cf0f97bfe875 100644 --- a/src/providers/grass/qgsgrass.h +++ b/src/providers/grass/qgsgrass.h @@ -47,30 +47,56 @@ class QgsRectangle; class QgsAttributes; // Make the release string because it may be for example 0beta1 -#define STR(x) #x -#define EXPAND(x) STR(x) +#define STR( x ) #x +#define EXPAND( x ) STR( x ) #define GRASS_VERSION_RELEASE_STRING EXPAND( GRASS_VERSION_RELEASE ) // try/catch like macros using setjmp -#define G_TRY try { if( !setjmp(*G_fatal_longjmp(1)) ) -#define G_CATCH else { throw QgsGrass::Exception( QgsGrass::errorMessage() ); } } catch +#define G_TRY \ + try \ + { \ + if ( !setjmp( *G_fatal_longjmp( 1 ) ) ) +#define G_CATCH \ + else \ + { \ + throw QgsGrass::Exception( QgsGrass::errorMessage() ); \ + } \ + } \ + catch // Throw QgsGrass::Exception if G_fatal_error happens when calling F -#define G_FATAL_THROW(F) if( !setjmp(*G_fatal_longjmp(1)) ) { F; } else { throw QgsGrass::Exception( QgsGrass::errorMessage() ); } +#define G_FATAL_THROW( F ) \ + if ( !setjmp( *G_fatal_longjmp( 1 ) ) ) \ + { \ + F; \ + } \ + else \ + { \ + throw QgsGrass::Exception( QgsGrass::errorMessage() ); \ + } // Element info container class GRASS_LIB_EXPORT QgsGrassObject { public: //! Element type - enum Type { None, Location, Mapset, Raster, Group, Vector, Region, - Strds, Stvds, Str3ds, Stds - }; + enum Type + { + None, + Location, + Mapset, + Raster, + Group, + Vector, + Region, + Strds, + Stvds, + Str3ds, + Stds + }; QgsGrassObject() = default; - QgsGrassObject( const QString &gisdbase, const QString &location = QString(), - const QString &mapset = QString(), const QString &name = QString(), - Type type = None ); + QgsGrassObject( const QString &gisdbase, const QString &location = QString(), const QString &mapset = QString(), const QString &name = QString(), Type type = None ); QString gisdbase() const { return mGisdbase; } void setGisdbase( const QString &gisdbase ) { mGisdbase = gisdbase; } QString location() const { return mLocation; } @@ -115,11 +141,12 @@ class GRASS_LIB_EXPORT QgsGrassObject static QString newNameRegExp( Type type ); bool operator==( const QgsGrassObject &other ) const; + private: QString mGisdbase; QString mLocation; QString mMapset; - QString mName; // map name + QString mName; // map name Type mType = None; }; @@ -155,14 +182,15 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject #endif struct Exception : public std::runtime_error { - //Exception( const std::string &msg ) : std::runtime_error( msg ) {} - explicit Exception( const QString &msg ) : std::runtime_error( msg.toUtf8().constData() ) {} + //Exception( const std::string &msg ) : std::runtime_error( msg ) {} + explicit Exception( const QString &msg ) + : std::runtime_error( msg.toUtf8().constData() ) {} }; struct Color { - double value1, value2; - int red1, red2, green1, green2, blue1, blue2; + double value1, value2; + int red1, red2, green1, green2, blue1, blue2; }; QgsGrass() = default; @@ -240,13 +268,13 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject //! Error codes returned by error() enum GError { - OK, //!< OK. No error. + OK, //!< OK. No error. Warning, //!< Warning, non fatal error. Should be printed by application. - Fatal //!< Fatal error + Fatal //!< Fatal error }; //! Reset error code (to OK). Call this before a piece of code where an error is expected - static void resetError( void ); // reset error status + static void resetError( void ); // reset error status //! Check if any error occurred in lately called functions. Returns value from ERROR. static int error( void ); @@ -265,8 +293,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject * Emits signal mapsetChanged(). * \returns Empty string or error message */ - static QString openMapset( const QString &gisdbase, - const QString &location, const QString &mapset ); + static QString openMapset( const QString &gisdbase, const QString &location, const QString &mapset ); /** * \brief Close mapset if it was opened from QGIS. @@ -281,8 +308,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject static void saveMapset(); //! Create new mapset in existing location - static void createMapset( const QString &gisdbase, const QString &location, - const QString &mapset, QString &error ); + static void createMapset( const QString &gisdbase, const QString &location, const QString &mapset, QString &error ); //! Check if given directory contains a GRASS installation static bool isValidGrassBaseDir( const QString &gisbase ); @@ -295,32 +321,26 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject static QStringList mapsets( const QString &locationPath ); //! List of vectors and rasters - static QStringList vectors( const QString &gisdbase, const QString &locationName, - const QString &mapsetName ); + static QStringList vectors( const QString &gisdbase, const QString &locationName, const QString &mapsetName ); static QStringList vectors( const QString &mapsetPath ); - static QStringList rasters( const QString &gisdbase, const QString &locationName, - const QString &mapsetName ); + static QStringList rasters( const QString &gisdbase, const QString &locationName, const QString &mapsetName ); static QStringList rasters( const QString &mapsetPath ); // imagery groups - static QStringList groups( const QString &gisdbase, const QString &locationName, - const QString &mapsetName ); + static QStringList groups( const QString &gisdbase, const QString &locationName, const QString &mapsetName ); static QStringList groups( const QString &mapsetPath ); //! Gets topo file version 6, 7 or 0 if topo file does not exist - static bool topoVersion( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &mapName, int &major, int &minor ); + static bool topoVersion( const QString &gisdbase, const QString &location, const QString &mapset, const QString &mapName, int &major, int &minor ); //! Gets list of vector layers, throws QgsGrass::Exception - static QStringList vectorLayers( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &mapName ); + static QStringList vectorLayers( const QString &gisdbase, const QString &location, const QString &mapset, const QString &mapName ); //! List of elements // TODO rename elements to objects - static QStringList elements( const QString &gisdbase, const QString &locationName, - const QString &mapsetName, const QString &element ); - static QStringList elements( const QString &mapsetPath, const QString &element ); + static QStringList elements( const QString &gisdbase, const QString &locationName, const QString &mapsetName, const QString &element ); + static QStringList elements( const QString &mapsetPath, const QString &element ); //! List of existing objects static QStringList grassObjects( const QgsGrassObject &mapsetObject, QgsGrassObject::Type type ); @@ -343,23 +363,19 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject static QgsRectangle extent( struct Cell_head *window ); //! Get map region - static bool mapRegion( QgsGrassObject::Type type, const QString &gisdbase, - const QString &location, const QString &mapset, const QString &map, - struct Cell_head *window ); + static bool mapRegion( QgsGrassObject::Type type, const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, struct Cell_head *window ); //! String representation of region static QString regionString( const struct Cell_head *window ); //! Read location default region (DEFAULT_WIND) - static bool defaultRegion( const QString &gisdbase, const QString &location, - struct Cell_head *window ); + static bool defaultRegion( const QString &gisdbase, const QString &location, struct Cell_head *window ); /** * Read mapset current region (WIND) * \throws QgsGrass::Exception */ - static void region( const QString &gisdbase, const QString &location, const QString &mapset, - struct Cell_head *window ); + static void region( const QString &gisdbase, const QString &location, const QString &mapset, struct Cell_head *window ); /** * Read default mapset current region (WIND) @@ -368,8 +384,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject static void region( struct Cell_head *window ); //! Write current mapset region - static bool writeRegion( const QString &gisbase, const QString &location, const QString &mapset, - const struct Cell_head *window ); + static bool writeRegion( const QString &gisbase, const QString &location, const QString &mapset, const struct Cell_head *window ); /** * Write current mapset region @@ -379,16 +394,13 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject void writeRegion( const struct Cell_head *window ); //! Set (copy) region extent, resolution is not changed - static void copyRegionExtent( struct Cell_head *source, - struct Cell_head *target ); + static void copyRegionExtent( struct Cell_head *source, struct Cell_head *target ); //! Set (copy) region resolution, extent is not changed - static void copyRegionResolution( struct Cell_head *source, - struct Cell_head *target ); + static void copyRegionResolution( struct Cell_head *source, struct Cell_head *target ); //! Extend region in target to source - static void extendRegion( struct Cell_head *source, - struct Cell_head *target ); + static void extendRegion( struct Cell_head *source, struct Cell_head *target ); /** * Initialize GRASS library. This has to be called before any other function is used. @@ -423,16 +435,10 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject * \param qgisModule append GRASS major version (for modules built in qgis) * \throws QgsGrass::Exception */ - static QProcess *startModule( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &moduleName, - const QStringList &arguments, QTemporaryFile &gisrcFile, - bool qgisModule = true ); + static QProcess *startModule( const QString &gisdbase, const QString &location, const QString &mapset, const QString &moduleName, const QStringList &arguments, QTemporaryFile &gisrcFile, bool qgisModule = true ); //! Run a GRASS module in any gisdbase/location - static QByteArray runModule( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &moduleName, - const QStringList &arguments, int timeOut = 30000, - bool qgisModule = true ); + static QByteArray runModule( const QString &gisdbase, const QString &location, const QString &mapset, const QString &moduleName, const QStringList &arguments, int timeOut = 30000, bool qgisModule = true ); /** * Returns the info string from qgis.g.info module. @@ -448,12 +454,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject * \param sampleSize sample size for statistics * \param timeOut timeout */ - static QString getInfo( const QString &info, const QString &gisdbase, - const QString &location, const QString &mapset = "PERMANENT", - const QString &map = QString(), const QgsGrassObject::Type type = QgsGrassObject::None, - double x = 0.0, double y = 0.0, - const QgsRectangle &extent = QgsRectangle(), int sampleRows = 0, - int sampleCols = 0, int timeOut = 30000 ); + static QString getInfo( const QString &info, const QString &gisdbase, const QString &location, const QString &mapset = "PERMANENT", const QString &map = QString(), const QgsGrassObject::Type type = QgsGrassObject::None, double x = 0.0, double y = 0.0, const QgsRectangle &extent = QgsRectangle(), int sampleRows = 0, int sampleCols = 0, int timeOut = 30000 ); //! Get location projection static QgsCoordinateReferenceSystem crs( const QString &gisdbase, const QString &location, QString &error ); @@ -465,34 +466,23 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject * ! Get map extent * \param error set to error if happens */ - static QgsRectangle extent( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &map, - QgsGrassObject::Type type, QString &error ); + static QgsRectangle extent( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, QgsGrassObject::Type type, QString &error ); //! Get raster map size - static void size( const QString &gisdbase, const QString &location, const QString &mapset, - const QString &map, int *cols, int *rows, QString &error ); + static void size( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, int *cols, int *rows, QString &error ); /** * Get raster info, info is either 'info' or 'stats' * extent and sampleSize are stats options * \param error set to error if happens */ - static QHash info( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &map, - QgsGrassObject::Type type, - const QString &info, - const QgsRectangle &extent, - int sampleRows, int sampleCols, - int timeOut, QString &error ); + static QHash info( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, QgsGrassObject::Type type, const QString &info, const QgsRectangle &extent, int sampleRows, int sampleCols, int timeOut, QString &error ); //! List of Color - static QList colors( const QString &gisdbase, const QString &location, const QString &mapset, - const QString &map, QString &error ); + static QList colors( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, QString &error ); //! Get map value / feature info - static QMap query( const QString &gisdbase, const QString &location, - const QString &mapset, const QString &map, QgsGrassObject::Type type, double x, double y ); + static QMap query( const QString &gisdbase, const QString &location, const QString &mapset, const QString &map, QgsGrassObject::Type type, double x, double y ); //! Rename GRASS object, throws QgsGrass::Exception static void renameObject( const QgsGrassObject &object, const QString &newName ); @@ -520,8 +510,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject static void createTable( dbDriver *driver, const QString &tableName, const QgsFields &fields ); //! Insert row to table. Throws QgsGrass::Exception - static void insertRow( dbDriver *driver, const QString &tableName, - const QgsAttributes &attributes ); + static void insertRow( dbDriver *driver, const QString &tableName, const QgsAttributes &attributes ); //! Returns true if object is link to external data (created by r.external) static bool isExternal( const QgsGrassObject &object ); @@ -576,7 +565,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject // path to QGIS GRASS modules like qgis.g.info etc. static QString qgisGrassModulePath() { -#if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) +#if defined( _MSC_VER ) && !defined( USING_NMAKE ) && !defined( USING_NINJA ) if ( QgsApplication::isRunningFromBuildDir() ) { return QCoreApplication::applicationDirPath() + "/../../grass/modules/" + QgsApplication::cfgIntDir(); @@ -697,7 +686,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject private: static bool sNonInitializable; static int sInitialized; // Set to 1 after initialization - static bool sActive; // is active mode + static bool sActive; // is active mode static QStringList sGrassModulesPaths; static QString sDefaultGisdbase; static QString sDefaultLocation; @@ -708,7 +697,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject QFileSystemWatcher *mMapsetSearchPathWatcher = nullptr; /* last error in GRASS libraries */ - static GError sLastError; // static, because used in constructor + static GError sLastError; // static, because used in constructor static QString sErrorMessage; // error set in init() if it failed static QString sInitError; @@ -718,7 +707,7 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject // - const char* msg - in CVS from 04/2007 // this way compiler chooses suitable call static int error_routine( const char *msg, int fatal ); // static because pointer to this function is set later - static int error_routine( char *msg, int fatal ); // static because pointer to this function is set later + static int error_routine( char *msg, int fatal ); // static because pointer to this function is set later // Current mapset lock file path static QString sMapsetLock; diff --git a/src/providers/grass/qgsgrassfeatureiterator.cpp b/src/providers/grass/qgsgrassfeatureiterator.cpp index a6b533f2fd0e..fa5c917cf9d8 100644 --- a/src/providers/grass/qgsgrassfeatureiterator.cpp +++ b/src/providers/grass/qgsgrassfeatureiterator.cpp @@ -40,17 +40,17 @@ void copy_boxlist_and_destroy( struct boxlist *blist, struct ilist *list ) Vect_destroy_boxlist( blist ); } -#define Vect_select_lines_by_box(map, box, type, list) \ - { \ - struct boxlist *blist = Vect_new_boxlist(0);\ - Vect_select_lines_by_box( (map), (box), (type), blist); \ - copy_boxlist_and_destroy( blist, (list) );\ +#define Vect_select_lines_by_box( map, box, type, list ) \ + { \ + struct boxlist *blist = Vect_new_boxlist( 0 ); \ + Vect_select_lines_by_box( ( map ), ( box ), ( type ), blist ); \ + copy_boxlist_and_destroy( blist, ( list ) ); \ } -#define Vect_select_areas_by_box(map, box, list) \ - { \ - struct boxlist *blist = Vect_new_boxlist(0);\ - Vect_select_areas_by_box( (map), (box), blist); \ - copy_boxlist_and_destroy( blist, (list) );\ +#define Vect_select_areas_by_box( map, box, list ) \ + { \ + struct boxlist *blist = Vect_new_boxlist( 0 ); \ + Vect_select_areas_by_box( ( map ), ( box ), blist ); \ + copy_boxlist_and_destroy( blist, ( list ) ); \ } //QMutex QgsGrassFeatureIterator::sMutex; @@ -58,7 +58,6 @@ void copy_boxlist_and_destroy( struct boxlist *blist, struct ilist *list ) QgsGrassFeatureIterator::QgsGrassFeatureIterator( QgsGrassFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ) : QgsAbstractFeatureIteratorFromSource( source, ownSource, request ) { - // WARNING: the iterator cannot use mutex lock for its whole life, because QgsVectorLayerFeatureIterator is opening // multiple iterators if features are edited -> lock only critical sections @@ -132,11 +131,7 @@ void QgsGrassFeatureIterator::setSelectionRect( const QgsRectangle &rect, bool u if ( !useIntersect ) { // select by bounding boxes only - if ( mSource->mLayerType == QgsGrassProvider::Point || mSource->mLayerType == QgsGrassProvider::Centroid || - mSource->mLayerType == QgsGrassProvider::Line || mSource->mLayerType == QgsGrassProvider::Face || - mSource->mLayerType == QgsGrassProvider::Boundary || - mSource->mLayerType == QgsGrassProvider::TopoPoint || mSource->mLayerType == QgsGrassProvider::TopoLine || - mSource->mEditing ) + if ( mSource->mLayerType == QgsGrassProvider::Point || mSource->mLayerType == QgsGrassProvider::Centroid || mSource->mLayerType == QgsGrassProvider::Line || mSource->mLayerType == QgsGrassProvider::Face || mSource->mLayerType == QgsGrassProvider::Boundary || mSource->mLayerType == QgsGrassProvider::TopoPoint || mSource->mLayerType == QgsGrassProvider::TopoLine || mSource->mEditing ) { QgsDebugMsgLevel( "Vect_select_lines_by_box", 3 ); int type = mSource->mGrassType; @@ -170,11 +165,7 @@ void QgsGrassFeatureIterator::setSelectionRect( const QgsRectangle &rect, bool u Vect_append_point( polygon, rect.xMinimum(), rect.yMaximum(), 0 ); Vect_append_point( polygon, rect.xMinimum(), rect.yMinimum(), 0 ); - if ( mSource->mLayerType == QgsGrassProvider::Point || mSource->mLayerType == QgsGrassProvider::Centroid || - mSource->mLayerType == QgsGrassProvider::Line || mSource->mLayerType == QgsGrassProvider::Face || - mSource->mLayerType == QgsGrassProvider::Boundary || - mSource->mLayerType == QgsGrassProvider::TopoPoint || mSource->mLayerType == QgsGrassProvider::TopoLine || - mSource->mEditing ) + if ( mSource->mLayerType == QgsGrassProvider::Point || mSource->mLayerType == QgsGrassProvider::Centroid || mSource->mLayerType == QgsGrassProvider::Line || mSource->mLayerType == QgsGrassProvider::Face || mSource->mLayerType == QgsGrassProvider::Boundary || mSource->mLayerType == QgsGrassProvider::TopoPoint || mSource->mLayerType == QgsGrassProvider::TopoLine || mSource->mEditing ) { QgsDebugMsgLevel( "Vect_select_lines_by_polygon", 3 ); int type = mSource->mGrassType; @@ -304,9 +295,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature &feature ) cat = 0; type = 0; lid = 0; - QgsDebugMsgLevel( QString( "mNextLid = %1 mNextCidx = %2 numLines() = %3 cidxFieldIndex() = %4 cidxFieldNumCats() = %5" ) - .arg( mNextLid ).arg( mNextCidx ).arg( mSource->mLayer->map()->numLines() ) - .arg( mSource->mLayer->cidxFieldIndex() ).arg( mSource->mLayer->cidxFieldNumCats() ), 3 ); + QgsDebugMsgLevel( QString( "mNextLid = %1 mNextCidx = %2 numLines() = %3 cidxFieldIndex() = %4 cidxFieldNumCats() = %5" ).arg( mNextLid ).arg( mNextCidx ).arg( mSource->mLayer->map()->numLines() ).arg( mSource->mLayer->cidxFieldIndex() ).arg( mSource->mLayer->cidxFieldNumCats() ), 3 ); if ( mSource->mEditing ) { // TODO should be numLines before editing started (?), but another layer @@ -433,8 +422,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature &feature ) lid = tmpLid; cat = tmpCat; type = tmpType; - QgsDebugMsgLevel( QString( "lid = %1 field = %2 cat = %3 type= %4" ) - .arg( lid ).arg( mSource->mLayer->field() ).arg( cat ).arg( type ), 3 ); + QgsDebugMsgLevel( QString( "lid = %1 field = %2 cat = %3 type= %4" ).arg( lid ).arg( mSource->mLayer->field() ).arg( cat ).arg( type ), 3 ); featureId = makeFeatureId( lid, cat ); } @@ -454,8 +442,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature &feature ) } if ( !oldGeometry ) { - int numLinesOrAreas = ( mSource->mGrassType == GV_AREA && !mSource->mEditing ) ? - mSource->mLayer->map()->numAreas() : mSource->mLayer->map()->numLines(); + int numLinesOrAreas = ( mSource->mGrassType == GV_AREA && !mSource->mEditing ) ? mSource->mLayer->map()->numAreas() : mSource->mLayer->map()->numLines(); if ( lid == 0 || lid > numLinesOrAreas ) { QgsDebugMsgLevel( QString( "lid = %1 > numLinesOrAreas = %2 -> close" ).arg( lid ).arg( numLinesOrAreas ), 3 ); @@ -539,7 +526,8 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature &feature ) { int line = Vect_get_node_line( mSource->map(), lid, i ); QgsDebugMsgLevel( "cancel", 3 ); - if ( i > 0 ) lines += QLatin1Char( ',' ); + if ( i > 0 ) + lines += QLatin1Char( ',' ); lines += QString::number( line ); } feature.setAttribute( 1, lines ); @@ -610,7 +598,7 @@ QgsFeatureId QgsGrassFeatureIterator::makeFeatureId( int grassId, int cat, int l // Because GRASS object id and category are both int and QgsFeatureId is qint64 // we can create unique QgsFeatureId from GRASS id and cat. // Max supported layer number is 92 (max 64bit int is 9,223,372,036,854,775,807). - QgsFeatureId fid = ( QgsFeatureId )layer * 100000000000000000 + ( QgsFeatureId )grassId * 1000000000 + cat; + QgsFeatureId fid = ( QgsFeatureId ) layer * 100000000000000000 + ( QgsFeatureId ) grassId * 1000000000 + cat; QgsDebugMsgLevel( QString( "grassId = %1 cat = %2 layer = %3 fid = %4" ).arg( grassId ).arg( cat ).arg( layer ).arg( fid ), 3 ); return fid; } @@ -666,7 +654,7 @@ void QgsGrassFeatureIterator::setFeatureAttributes( int cat, QgsFeature *feature int nFields = mSource->mLayer->fields().size(); if ( nFields > 0 ) { - for ( int i = 0; i < mSource->mLayer->fields().size(); i++ ) + for ( int i = 0; i < mSource->mLayer->fields().size(); i++ ) { attlist << i; } @@ -762,5 +750,5 @@ QgsFeatureIterator QgsGrassFeatureSource::getFeatures( const QgsFeatureRequest & struct Map_info *QgsGrassFeatureSource::map() { - return mLayer->map()->map(); + return mLayer->map()->map(); } diff --git a/src/providers/grass/qgsgrassfeatureiterator.h b/src/providers/grass/qgsgrassfeatureiterator.h index 6d2e9f647a4d..bbe2b351a5e9 100644 --- a/src/providers/grass/qgsgrassfeatureiterator.h +++ b/src/providers/grass/qgsgrassfeatureiterator.h @@ -52,8 +52,8 @@ class GRASS_LIB_EXPORT QgsGrassFeatureSource : public QgsAbstractFeatureSource struct Map_info *map(); QgsGrassVectorMapLayer *mLayer = nullptr; - int mLayerType; // layer type POINT, LINE, ... - int mGrassType; // grass feature type: GV_POINT, GV_LINE | GV_BOUNDARY, GV_AREA, + int mLayerType; // layer type POINT, LINE, ... + int mGrassType; // grass feature type: GV_POINT, GV_LINE | GV_BOUNDARY, GV_AREA, Qgis::WkbType mQgisType; // WKBPoint, WKBLineString, ... @@ -111,7 +111,6 @@ class GRASS_LIB_EXPORT QgsGrassFeatureIterator : public QObject, public QgsAbstr void doClose(); private: - // create QgsFeatureId from GRASS geometry object id, cat and layer number (editing) static QgsFeatureId makeFeatureId( int grassId, int cat, int layer = 0 ); diff --git a/src/providers/grass/qgsgrassgislib.cpp b/src/providers/grass/qgsgrassgislib.cpp index bf97c753cdf4..3fde6af0473c 100644 --- a/src/providers/grass/qgsgrassgislib.cpp +++ b/src/providers/grass/qgsgrassgislib.cpp @@ -27,7 +27,7 @@ #include "qgsgrassgislibfunctions.h" extern "C" { -// defined here because too complex for parser in CMakeLists.txt + // defined here because too complex for parser in CMakeLists.txt int GRASS_LIB_EXPORT G_cell_stats_histo_eq( struct Cell_stats *statf, CELL min1, CELL max1, CELL min2, CELL max2, int zero, void ( *func )( CELL, CELL, CELL ) ); } #endif @@ -134,7 +134,7 @@ int GRASS_LIB_EXPORT QgsGrassGisLib::errorRoutine( const char *msg, int fatal ) void QgsGrassGisLib::fatal( QString msg ) { - QgsLogger::fatal( msg ); // calls qFatal which does core dump + QgsLogger::fatal( msg ); // calls qFatal which does core dump } void QgsGrassGisLib::warning( QString msg ) @@ -195,7 +195,7 @@ int GRASS_LIB_EXPORT QgsGrassGisLib::G__gisinit( const char *version, const char G_set_error_routine( &errorRoutine ); G_set_gisrc_mode( G_GISRC_MODE_MEMORY ); - G_setenv( "OVERWRITE", "1" ); // avoid checking if map exists + G_setenv( "OVERWRITE", "1" ); // avoid checking if map exists G_suppress_masking(); @@ -218,8 +218,8 @@ int GRASS_LIB_EXPORT QgsGrassGisLib::G__gisinit( const char *version, const char if ( mCrs.srsid() == 0 ) { QString myName = QString( " * %1 (%2)" ) - .arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) ) - .arg( mCrs.toProj() ); + .arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) ) + .arg( mCrs.toProj() ); mCrs.saveAsUserCRS( myName ); } } @@ -272,7 +272,7 @@ int GRASS_LIB_EXPORT QgsGrassGisLib::G__gisinit( const char *version, const char fatal( "GRASS_REGION environment variable not set" ); } - QgsDebugMsgLevel( "Getting region via true lib from GRASS_REGION: " + regionStr, 2 ); + QgsDebugMsgLevel( "Getting region via true lib from GRASS_REGION: " + regionStr, 2 ); // GRASS true lib reads GRASS_REGION environment variable G_get_window( &mWindow ); @@ -385,7 +385,7 @@ char GRASS_LIB_EXPORT *QgsGrassGisLib::G_find_cell2( const char *name, const cha return 0; } QString ms = "qgis"; - return qstrdup( ms.toLatin1() ); // memory lost + return qstrdup( ms.toLatin1() ); // memory lost } char GRASS_LIB_EXPORT *G__file_name( char *path, const char *element, const char *name, const char *mapset ) @@ -458,7 +458,8 @@ QgsGrassGisLib::Raster QgsGrassGisLib::raster( QString name ) for ( Raster raster : mRasters ) { - if ( raster.name == name ) return raster; + if ( raster.name == name ) + return raster; } QString providerKey; @@ -498,7 +499,7 @@ QgsGrassGisLib::Raster QgsGrassGisLib::raster( QString name ) Raster raster; raster.name = name; raster.band = band; - raster.provider = ( QgsRasterDataProvider * )QgsProviderRegistry::instance()->provider( providerKey, dataSource ); + raster.provider = ( QgsRasterDataProvider * ) QgsProviderRegistry::instance()->provider( providerKey, dataSource ); if ( !raster.provider || !raster.provider->isValid() ) { // No fatal, it may be used to test file existence @@ -597,7 +598,8 @@ int QgsGrassGisLib::G_open_raster_new( const char *name, RASTER_MAP_TYPE wr_type raster.provider = QgsRasterDataProvider::create( providerKey, dataSource, outputFormat, nBands, type, mColumns, mRows, geoTransform, mCrs ); if ( !raster.provider || !raster.provider->isValid() ) { - if ( raster.provider ) delete raster.provider; + if ( raster.provider ) + delete raster.provider; fatal( "Cannot create output data source: " + dataSource ); } @@ -655,7 +657,8 @@ RASTER_MAP_TYPE GRASS_LIB_EXPORT G_get_raster_map_type( int fd ) int GRASS_LIB_EXPORT G_raster_map_is_fp( const char *name, const char *mapset ) { RASTER_MAP_TYPE type = QgsGrassGisLib::instance()->G_raster_map_type( name, mapset ); - if ( type == FCELL_TYPE || type == DCELL_TYPE ) return 1; + if ( type == FCELL_TYPE || type == DCELL_TYPE ) + return 1; return 0; } @@ -768,7 +771,8 @@ int QgsGrassGisLib::readRasterRow( int fd, void *buf, int row, RASTER_MAP_TYPE d // TODO: use cached block with more rows Raster raster = mRasters.value( fd ); //if ( !raster.provider ) return -1; - if ( !raster.input ) return -1; + if ( !raster.input ) + return -1; // Create extent for current row QgsRectangle blockRect = mExtent; @@ -781,7 +785,8 @@ int QgsGrassGisLib::readRasterRow( int fd, void *buf, int row, RASTER_MAP_TYPE d blockRect.setYMinimum( yMax - yRes ); QgsRasterBlock *block = raster.input->block( raster.band, blockRect, mColumns, 1 ); - if ( !block ) return -1; + if ( !block ) + return -1; Qgis::DataType requestedType = qgisRasterType( data_type ); @@ -805,13 +810,13 @@ int QgsGrassGisLib::readRasterRow( int fd, void *buf, int row, RASTER_MAP_TYPE d switch ( data_type ) { case CELL_TYPE: - G_zero( ( char * ) & ( ( CELL * ) buf )[i], G_raster_size( data_type ) ); + G_zero( ( char * ) &( ( CELL * ) buf )[i], G_raster_size( data_type ) ); break; case FCELL_TYPE: - G_zero( ( char * ) & ( ( FCELL * ) buf )[i], G_raster_size( data_type ) ); + G_zero( ( char * ) &( ( FCELL * ) buf )[i], G_raster_size( data_type ) ); break; case DCELL_TYPE: - G_zero( ( char * ) & ( ( DCELL * ) buf )[i], G_raster_size( data_type ) ); + G_zero( ( char * ) &( ( DCELL * ) buf )[i], G_raster_size( data_type ) ); break; default: break; @@ -844,7 +849,6 @@ int QgsGrassGisLib::readRasterRow( int fd, void *buf, int row, RASTER_MAP_TYPE d } delete block; return 1; - } int GRASS_LIB_EXPORT G_get_raster_row( int fd, void *buf, int row, RASTER_MAP_TYPE data_type ) @@ -860,7 +864,7 @@ int GRASS_LIB_EXPORT G_get_raster_row_nomask( int fd, void *buf, int row, RASTER int GRASS_LIB_EXPORT G_get_c_raster_row( int fd, CELL *buf, int row ) { - return G_get_raster_row( fd, ( void * )buf, row, CELL_TYPE ); + return G_get_raster_row( fd, ( void * ) buf, row, CELL_TYPE ); } int GRASS_LIB_EXPORT G_get_c_raster_row_nomask( int fd, CELL *buf, int row ) @@ -870,29 +874,29 @@ int GRASS_LIB_EXPORT G_get_c_raster_row_nomask( int fd, CELL *buf, int row ) int GRASS_LIB_EXPORT G_get_f_raster_row( int fd, FCELL *buf, int row ) { - return G_get_raster_row( fd, ( void * )buf, row, FCELL_TYPE ); + return G_get_raster_row( fd, ( void * ) buf, row, FCELL_TYPE ); } int GRASS_LIB_EXPORT G_get_f_raster_row_nomask( int fd, FCELL *buf, int row ) { - return G_get_raster_row_nomask( fd, ( void * )buf, row, FCELL_TYPE ); + return G_get_raster_row_nomask( fd, ( void * ) buf, row, FCELL_TYPE ); } int GRASS_LIB_EXPORT G_get_d_raster_row( int fd, DCELL *buf, int row ) { - return G_get_raster_row( fd, ( void * )buf, row, DCELL_TYPE ); + return G_get_raster_row( fd, ( void * ) buf, row, DCELL_TYPE ); } int GRASS_LIB_EXPORT G_get_d_raster_row_nomask( int fd, DCELL *buf, int row ) { - return G_get_raster_row_nomask( fd, ( void * )buf, row, DCELL_TYPE ); + return G_get_raster_row_nomask( fd, ( void * ) buf, row, DCELL_TYPE ); } // reads null as zero int GRASS_LIB_EXPORT G_get_map_row( int fd, CELL *buf, int row ) { bool noDataAsZero = true; - return QgsGrassGisLib::instance()->readRasterRow( fd, ( void * )buf, row, CELL_TYPE, noDataAsZero ); + return QgsGrassGisLib::instance()->readRasterRow( fd, ( void * ) buf, row, CELL_TYPE, noDataAsZero ); } int GRASS_LIB_EXPORT G_get_map_row_nomask( int fd, CELL *buf, int row ) @@ -935,7 +939,7 @@ int QgsGrassGisLib::putRasterRow( int fd, const void *buf, RASTER_MAP_TYPE data_ //double noDataValue = rast.provider->noDataValue( rast.band ); QgsRasterBlock block( inputType, mColumns, 1, rast.noDataValue ); - memcpy( block.bits( 0 ), buf, QgsRasterBlock::typeSize( inputType )*mColumns ); + memcpy( block.bits( 0 ), buf, QgsRasterBlock::typeSize( inputType ) * mColumns ); block.convert( rast.provider->dataType( rast.band ) ); // Set no data after converting to output type @@ -1105,9 +1109,11 @@ double GRASS_LIB_EXPORT G_database_units_to_meters_factor( void ) int QgsGrassGisLib::beginCalculations( void ) { - if ( !mCrs.isValid() ) return 0; - if ( !mCrs.isGeographic() ) return 1; // planimetric - return 2; // non-planimetric + if ( !mCrs.isValid() ) + return 0; + if ( !mCrs.isGeographic() ) + return 1; // planimetric + return 2; // non-planimetric } int GRASS_LIB_EXPORT G_begin_cell_area_calculations( void ) @@ -1143,7 +1149,6 @@ double QgsGrassGisLib::distance( double e1, double n1, double e2, double n2 ) dist *= G_database_units_to_meters_factor(); } return dist; - } double GRASS_LIB_EXPORT G_distance( double e1, double n1, double e2, double n2 ) @@ -1298,7 +1303,7 @@ int G_asprintf( char **out, const char *fmt, ... ) return ret; } -typedef int G_lookup_key_value_from_file_type( const char *, const char *, char [], int ); +typedef int G_lookup_key_value_from_file_type( const char *, const char *, char[], int ); int GRASS_LIB_EXPORT G_lookup_key_value_from_file( const char *file, const char *key, char value[], int n ) { G_lookup_key_value_from_file_type *fn = ( G_lookup_key_value_from_file_type * ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_lookup_key_value_from_file" ) ); diff --git a/src/providers/grass/qgsgrassgislib.h b/src/providers/grass/qgsgrassgislib.h index 583227af4504..34bb6d0aee22 100644 --- a/src/providers/grass/qgsgrassgislib.h +++ b/src/providers/grass/qgsgrassgislib.h @@ -56,14 +56,14 @@ class GRASS_LIB_EXPORT QgsGrassGisLib class Raster { public: - int fd; // fake file descriptor + int fd; // fake file descriptor QString name; // name passed from grass module, uri QgsRasterDataProvider *provider = nullptr; QgsRasterProjector *projector = nullptr; // Input points to provider or projector QgsRasterInterface *input = nullptr; int band; - int row; // next row to be written + int row; // next row to be written double noDataValue; // output no data value Raster() diff --git a/src/providers/grass/qgsgrassimport.cpp b/src/providers/grass/qgsgrassimport.cpp index 76213f2d7566..1449423dafe4 100644 --- a/src/providers/grass/qgsgrassimport.cpp +++ b/src/providers/grass/qgsgrassimport.cpp @@ -191,8 +191,7 @@ void QgsGrassImport::cancel() } //------------------------------ QgsGrassRasterImport ------------------------------------ -QgsGrassRasterImport::QgsGrassRasterImport( QgsRasterPipe *pipe, const QgsGrassObject &grassObject, - const QgsRectangle &extent, int xSize, int ySize ) +QgsGrassRasterImport::QgsGrassRasterImport( QgsRasterPipe *pipe, const QgsGrassObject &grassObject, const QgsRectangle &extent, int xSize, int ySize ) : QgsGrassImport( grassObject ) , mPipe( pipe ) , mExtent( extent ) @@ -282,14 +281,14 @@ bool QgsGrassRasterImport::import() break; case Qgis::DataType::ARGB32: case Qgis::DataType::ARGB32_Premultiplied: - qgis_out_type = Qgis::DataType::Int32; // split to multiple bands? + qgis_out_type = Qgis::DataType::Int32; // split to multiple bands? break; case Qgis::DataType::CInt16: case Qgis::DataType::CInt32: case Qgis::DataType::CFloat32: case Qgis::DataType::CFloat64: case Qgis::DataType::UnknownDataType: - setError( tr( "Data type %1 not supported" ).arg( static_cast< int >( provider->dataType( band ) ) ) ); + setError( tr( "Data type %1 not supported" ).arg( static_cast( provider->dataType( band ) ) ) ); return false; } @@ -303,7 +302,7 @@ bool QgsGrassRasterImport::import() // raster. to keep in sync with r.in.gdal name += QStringLiteral( ".%1" ).arg( band ); } - arguments.append( "output=" + name ); // get list of all output names + arguments.append( "output=" + name ); // get list of all output names QTemporaryFile gisrcFile; try { @@ -328,8 +327,8 @@ bool QgsGrassRasterImport::import() outStream << ( qint32 ) defaultWindow.proj; outStream << ( qint32 ) defaultWindow.zone; - outStream << mExtent << ( qint32 )mXSize << ( qint32 )mYSize; - outStream << ( qint32 )qgis_out_type; + outStream << mExtent << ( qint32 ) mXSize << ( qint32 ) mYSize; + outStream << ( qint32 ) qgis_out_type; // calculate reasonable block size (5MB) int maximumTileHeight = 5000000 / mXSize; @@ -361,7 +360,7 @@ bool QgsGrassRasterImport::import() if ( !block->convert( qgis_out_type ) ) { - setError( tr( "Cannot convert block (%1) to data type %2" ).arg( block->toString() ).arg( qgsEnumValueToKey< Qgis::DataType >( qgis_out_type ) ) ); + setError( tr( "Cannot convert block (%1) to data type %2" ).arg( block->toString() ).arg( qgsEnumValueToKey( qgis_out_type ) ) ); delete block; return false; } @@ -387,7 +386,7 @@ bool QgsGrassRasterImport::import() default: // should not happen noDataValue = std::numeric_limits::max() * -1.0; } - for ( qgssize i = 0; i < ( qgssize )block->width()*block->height(); i++ ) + for ( qgssize i = 0; i < ( qgssize ) block->width() * block->height(); i++ ) { if ( block->isNoData( i ) ) { @@ -438,9 +437,10 @@ bool QgsGrassRasterImport::import() #ifdef QGISDEBUG QString stdoutString = mProcess->readAllStandardOutput().constData(); QString processResult = QStringLiteral( "exitStatus=%1, exitCode=%2, error=%3, errorString=%4 stdout=%5, stderr=%6" ) - .arg( mProcess->exitStatus() ).arg( mProcess->exitCode() ) - .arg( mProcess->error() ).arg( mProcess->errorString(), - stdoutString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ), stderrString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ) ); + .arg( mProcess->exitStatus() ) + .arg( mProcess->exitCode() ) + .arg( mProcess->error() ) + .arg( mProcess->errorString(), stdoutString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ), stderrString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ) ); QgsDebugMsgLevel( "processResult: " + processResult, 3 ); #endif @@ -550,7 +550,6 @@ QgsGrassVectorImport::~QgsGrassVectorImport() bool QgsGrassVectorImport::import() { - if ( !mProvider ) { setError( QStringLiteral( "Provider is null." ) ); @@ -597,7 +596,7 @@ bool QgsGrassVectorImport::import() Qgis::WkbType wkbType = mProvider->wkbType(); bool isPolygon = QgsWkbTypes::singleType( QgsWkbTypes::flatType( wkbType ) ) == Qgis::WkbType::Polygon; - outStream << ( qint32 )wkbType; + outStream << ( qint32 ) wkbType; outStream << mProvider->fields(); @@ -685,7 +684,7 @@ bool QgsGrassVectorImport::import() } feature = QgsFeature(); // indicate end by invalid feature - outStream << false; // not canceled + outStream << false; // not canceled outStream << feature; mProcess->waitForBytesWritten( -1 ); @@ -720,9 +719,10 @@ bool QgsGrassVectorImport::import() #ifdef QGISDEBUG QString processResult = QStringLiteral( "exitStatus=%1, exitCode=%2, error=%3, errorString=%4 stdout=%5, stderr=%6" ) - .arg( mProcess->exitStatus() ).arg( mProcess->exitCode() ) - .arg( mProcess->error() ).arg( mProcess->errorString(), - stdoutString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ), stderrString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ) ); + .arg( mProcess->exitStatus() ) + .arg( mProcess->exitCode() ) + .arg( mProcess->error() ) + .arg( mProcess->errorString(), stdoutString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ), stderrString.replace( QLatin1String( "\n" ), QLatin1String( ", " ) ) ); QgsDebugMsgLevel( "processResult: " + processResult, 3 ); #endif @@ -765,7 +765,6 @@ QgsGrassCopy::QgsGrassCopy( const QgsGrassObject &srcObject, const QgsGrassObjec bool QgsGrassCopy::import() { - try { QgsGrass::copyObject( mSrcObject, mGrassObject ); @@ -794,7 +793,6 @@ QgsGrassExternal::QgsGrassExternal( const QString &gdalSource, const QgsGrassObj bool QgsGrassExternal::import() { - try { QString cmd = QgsGrass::gisbase() + "/bin/r.external"; diff --git a/src/providers/grass/qgsgrassimport.h b/src/providers/grass/qgsgrassimport.h index 8fc9168b78e7..3affde9de75d 100644 --- a/src/providers/grass/qgsgrassimport.h +++ b/src/providers/grass/qgsgrassimport.h @@ -116,8 +116,7 @@ class GRASS_LIB_EXPORT QgsGrassRasterImport : public QgsGrassImport Q_OBJECT public: // takes pipe ownership - QgsGrassRasterImport( QgsRasterPipe *pipe, const QgsGrassObject &grassObject, - const QgsRectangle &extent, int xSize, int ySize ); + QgsGrassRasterImport( QgsRasterPipe *pipe, const QgsGrassObject &grassObject, const QgsRectangle &extent, int xSize, int ySize ); ~QgsGrassRasterImport() override; bool import() override; QString srcDescription() const override; @@ -158,7 +157,6 @@ class GRASS_LIB_EXPORT QgsGrassCopy : public QgsGrassImport private: QgsGrassObject mSrcObject; - }; // Creates link to GDAL data source with r.external @@ -173,7 +171,6 @@ class GRASS_LIB_EXPORT QgsGrassExternal : public QgsGrassImport private: QString mSource; - }; #endif // QGSGRASSIMPORT_H diff --git a/src/providers/grass/qgsgrassoptions.cpp b/src/providers/grass/qgsgrassoptions.cpp index fb11f473ccf0..47c4b9a81a92 100644 --- a/src/providers/grass/qgsgrassoptions.cpp +++ b/src/providers/grass/qgsgrassoptions.cpp @@ -97,9 +97,11 @@ void QgsGrassOptions::mGisbaseBrowseButton_clicked() // For Mac, GISBASE folder may be inside GRASS bundle. Use Qt file dialog // since Mac native dialog doesn't allow user to browse inside bundles. gisbase = QFileDialog::getExistingDirectory( - nullptr, QObject::tr( "Choose GRASS installation path (GISBASE)" ), gisbase, - QFileDialog::DontUseNativeDialog ); - if ( !gisbase.isEmpty() )gisbaseChanged(); + nullptr, QObject::tr( "Choose GRASS installation path (GISBASE)" ), gisbase, + QFileDialog::DontUseNativeDialog + ); + if ( !gisbase.isEmpty() ) + gisbaseChanged(); { mGisbaseLineEdit->setText( gisbase ); } @@ -130,9 +132,7 @@ void QgsGrassOptions::gisbaseChanged() void QgsGrassOptions::mModulesConfigBrowseButton_clicked() { - QString dir = QFileDialog::getExistingDirectory( this, - tr( "Choose a directory with configuration files (default.qgc, *.qgm)" ), - mModulesConfigDirLineEdit->text() ); + QString dir = QFileDialog::getExistingDirectory( this, tr( "Choose a directory with configuration files (default.qgc, *.qgm)" ), mModulesConfigDirLineEdit->text() ); if ( !dir.isEmpty() ) { @@ -156,8 +156,7 @@ void QgsGrassOptions::saveOptions() QgsGrass::instance()->setModulesDebug( mModulesDebugCheckBox->isChecked() ); // Browser - settings.setEnumValue( mImportSettingsPath + "/crsTransform", - ( QgsRasterProjector::Precision )mCrsTransformationComboBox->currentData().toInt() ); + settings.setEnumValue( mImportSettingsPath + "/crsTransform", ( QgsRasterProjector::Precision ) mCrsTransformationComboBox->currentData().toInt() ); settings.setValue( mImportSettingsPath + "/external", mImportExternalCheckBox->isChecked() ); diff --git a/src/providers/grass/qgsgrassoptions.h b/src/providers/grass/qgsgrassoptions.h index a4b4606d5251..1ab5cf2ee05d 100644 --- a/src/providers/grass/qgsgrassoptions.h +++ b/src/providers/grass/qgsgrassoptions.h @@ -37,7 +37,6 @@ class GRASS_LIB_EXPORT QgsGrassOptions : public QgsOptionsDialogBase, private Ui void saveOptions(); private: - QString mImportSettingsPath; QString mModulesSettingsPath; }; diff --git a/src/providers/grass/qgsgrassprovider.cpp b/src/providers/grass/qgsgrassprovider.cpp index 81e14d1767b5..45c9fbf26798 100644 --- a/src/providers/grass/qgsgrassprovider.cpp +++ b/src/providers/grass/qgsgrassprovider.cpp @@ -55,7 +55,7 @@ extern "C" { #include -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -79,9 +79,9 @@ extern "C" #ifdef Q_OS_WIN typedef qint64 grass_off_t; #else -#if defined(GRASS_OFF_T_SIZE) && GRASS_OFF_T_SIZE == 4 +#if defined( GRASS_OFF_T_SIZE ) && GRASS_OFF_T_SIZE == 4 typedef qint32 grass_off_t; -#elif defined(GRASS_OFF_T_SIZE) && GRASS_OFF_T_SIZE == 8 +#elif defined( GRASS_OFF_T_SIZE ) && GRASS_OFF_T_SIZE == 8 typedef qint64 grass_off_t; #else typedef off_t grass_off_t; // GRASS_OFF_T_SIZE undefined, default to off_t @@ -89,8 +89,8 @@ typedef off_t grass_off_t; // GRASS_OFF_T_SIZE undefined, default to off_t #endif typedef grass_off_t Vect_rewrite_line_function_type( struct Map_info *, grass_off_t, int, const struct line_pnts *, const struct line_cats * ); typedef int Vect_delete_line_function_type( struct Map_info *, grass_off_t ); -Vect_rewrite_line_function_type *Vect_rewrite_line_function_pointer = ( Vect_rewrite_line_function_type * )Vect_rewrite_line; -Vect_delete_line_function_type *Vect_delete_line_function_pointer = ( Vect_delete_line_function_type * )Vect_delete_line; +Vect_rewrite_line_function_type *Vect_rewrite_line_function_pointer = ( Vect_rewrite_line_function_type * ) Vect_rewrite_line; +Vect_delete_line_function_type *Vect_delete_line_function_pointer = ( Vect_delete_line_function_type * ) Vect_delete_line; static QString GRASS_KEY = QStringLiteral( "grass" ); @@ -116,8 +116,8 @@ QgsGrassProvider::QgsGrassProvider( const QString &uri ) mCats = Vect_new_cats_struct(); // Parse URI - QDir dir( uri ); // it is not a directory in fact - QString myURI = dir.path(); // no dupl '/' + QDir dir( uri ); // it is not a directory in fact + QString myURI = dir.path(); // no dupl '/' mLayerName = dir.dirName(); myURI = myURI.left( dir.path().lastIndexOf( '/' ) ); @@ -193,7 +193,6 @@ QgsGrassProvider::QgsGrassProvider( const QString &uri ) QgsDebugError( QString( "Invalid layer name, wrong type: %1" ).arg( mLayerName ) ); return; } - } QgsDebugMsgLevel( QString( "mLayerField: %1" ).arg( mLayerField ), 2 ); QgsDebugMsgLevel( QString( "mLayerType: %1" ).arg( mLayerType ), 2 ); @@ -233,17 +232,13 @@ QgsGrassProvider::QgsGrassProvider( const QString &uri ) loadMapInfo(); setTopoFields(); - connect( mLayer->map(), - &QgsGrassVectorMap::dataChanged, this, &QgsGrassProvider::onDataChanged ); + connect( mLayer->map(), &QgsGrassVectorMap::dataChanged, this, &QgsGrassProvider::onDataChanged ); // TODO: types according to database - setNativeTypes( QList() - << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QMetaType::Type::Int, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), QStringLiteral( "double precision" ), QMetaType::Type::Double, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Text" ), QStringLiteral( "text" ), QMetaType::Type::QString ) + setNativeTypes( QList() << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QMetaType::Type::Int, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), QStringLiteral( "double precision" ), QMetaType::Type::Double, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Text" ), QStringLiteral( "text" ), QMetaType::Type::QString ) // TODO: // << QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 ); - ); + ); // Assign default encoding if ( !textEncoding() ) @@ -357,7 +352,6 @@ void QgsGrassProvider::loadMapInfo() void QgsGrassProvider::update() { - mValid = false; if ( mLayer ) @@ -390,7 +384,6 @@ QString QgsGrassProvider::storageType() const } - QgsFeatureIterator QgsGrassProvider::getFeatures( const QgsFeatureRequest &request ) const { if ( !mValid ) @@ -546,7 +539,6 @@ void QgsGrassProvider::onDataChanged() bool QgsGrassProvider::isGrassEditable( void ) { - if ( !isValid() ) return false; @@ -567,7 +559,6 @@ bool QgsGrassProvider::isEdited( void ) void QgsGrassProvider::freeze() { - if ( !isValid() ) { return; @@ -585,7 +576,6 @@ void QgsGrassProvider::freeze() void QgsGrassProvider::thaw() { - if ( !openLayer() ) { QgsDebugError( "Cannot open layer" ); @@ -599,7 +589,6 @@ void QgsGrassProvider::thaw() bool QgsGrassProvider::closeEdit( bool newMap, QgsVectorLayer *vectorLayer ) { - if ( !isValid() ) { QgsDebugError( "not valid" ); @@ -769,8 +758,7 @@ int QgsGrassProvider::rewriteLine( int oldLid, int type, struct line_pnts *Point oldestLid = mLayer->map()->oldLids().value( oldLid ); } - QgsDebugMsgLevel( QString( "oldLid = %1 oldestLid = %2 newLine = %3 numLines = %4" ) - .arg( oldLid ).arg( oldestLid ).arg( newLid ).arg( mLayer->map()->numLines() ), 2 ); + QgsDebugMsgLevel( QString( "oldLid = %1 oldestLid = %2 newLine = %3 numLines = %4" ).arg( oldLid ).arg( oldestLid ).arg( newLid ).arg( mLayer->map()->numLines() ), 2 ); QgsDebugMsgLevel( QString( "oldLids : %1 -> %2" ).arg( newLid ).arg( oldestLid ), 2 ); mLayer->map()->oldLids()[newLid] = oldestLid; QgsDebugMsgLevel( QString( "newLids : %1 -> %2" ).arg( oldestLid ).arg( newLid ), 2 ); @@ -786,7 +774,6 @@ int QgsGrassProvider::rewriteLine( int oldLid, int type, struct line_pnts *Point int QgsGrassProvider::deleteLine( int line ) { - if ( !isEdited() ) return -1; @@ -934,7 +921,7 @@ QgsAttributeMap *QgsGrassProvider::attributes( int field, int cat ) QgsAttributeMap *att = new QgsAttributeMap; - struct field_info *fi = Vect_get_field( map(), field ); // should work also with field = 0 + struct field_info *fi = Vect_get_field( map(), field ); // should work also with field = 0 // Read attributes if ( !fi ) @@ -980,7 +967,7 @@ QgsAttributeMap *QgsGrassProvider::attributes( int field, int cat ) return att; } - dbTable *databaseTable = db_get_cursor_table( &databaseCursor ); + dbTable *databaseTable = db_get_cursor_table( &databaseCursor ); int nColumns = db_get_table_number_of_columns( databaseTable ); int more; @@ -1010,17 +997,14 @@ QgsAttributeMap *QgsGrassProvider::attributes( int field, int cat ) } - int QgsGrassProvider::numDbLinks( void ) { - return ( Vect_get_num_dblinks( map() ) ); } int QgsGrassProvider::dbLinkField( int link ) { - - struct field_info *fi = Vect_get_dblink( map(), link ); + struct field_info *fi = Vect_get_dblink( map(), link ); if ( !fi ) return 0; @@ -1063,7 +1047,7 @@ void QgsGrassProvider::setTopoFields() void QgsGrassProvider::startEditing( QgsVectorLayer *vectorLayer ) { - QgsDebugMsgLevel( "uri = " + dataSourceUri(), 2 ); + QgsDebugMsgLevel( "uri = " + dataSourceUri(), 2 ); if ( !vectorLayer || !vectorLayer->editBuffer() ) { QgsDebugError( "vector or buffer is null" ); @@ -1399,8 +1383,7 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid ) { realCat = mLayer->map()->newCats().value( fid ); } - QgsDebugMsgLevel( QString( "fid = %1 lid = %2 realLine = %3 cat = %4 realCat = %5 layerField = %6" ) - .arg( fid ).arg( lid ).arg( realLine ).arg( cat ).arg( realCat ).arg( layerField ), 2 ); + QgsDebugMsgLevel( QString( "fid = %1 lid = %2 realLine = %3 cat = %4 realCat = %5 layerField = %6" ).arg( fid ).arg( lid ).arg( realLine ).arg( cat ).arg( realCat ).arg( layerField ), 2 ); if ( realLine > 0 ) { @@ -1506,8 +1489,7 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid ) setAddedFeaturesSymbol(); } - QgsDebugMsgLevel( QString( "mLayer->cidxFieldIndex() = %1 cidxFieldNumCats() = %2" ) - .arg( mLayer->cidxFieldIndex() ).arg( mLayer->cidxFieldNumCats() ), 2 ); + QgsDebugMsgLevel( QString( "mLayer->cidxFieldIndex() = %1 cidxFieldNumCats() = %2" ).arg( mLayer->cidxFieldIndex() ).arg( mLayer->cidxFieldNumCats() ), 2 ); } void QgsGrassProvider::onFeatureDeleted( QgsFeatureId fid ) @@ -1540,8 +1522,7 @@ void QgsGrassProvider::onFeatureDeleted( QgsFeatureId fid ) realCat = mLayer->map()->newCats().value( fid ); } - QgsDebugMsgLevel( QString( "fid = %1 oldLid = %2 realLine = %3 cat = %4 realCat = %5 layerField = %6" ) - .arg( fid ).arg( oldLid ).arg( realLine ).arg( cat ).arg( realCat ).arg( layerField ), 2 ); + QgsDebugMsgLevel( QString( "fid = %1 oldLid = %2 realLine = %3 cat = %4 realCat = %5 layerField = %6" ).arg( fid ).arg( oldLid ).arg( realLine ).arg( cat ).arg( realCat ).arg( layerField ), 2 ); int type = 0; mLayer->map()->lockReadWrite(); @@ -1740,8 +1721,7 @@ void QgsGrassProvider::onAttributeValueChanged( QgsFeatureId fid, int idx, const { realCat = mLayer->map()->newCats().value( fid ); } - QgsDebugMsgLevel( QString( "fid = %1 oldLid = %2 realLine = %3 cat = %4 realCat = %5" ) - .arg( fid ).arg( oldLid ).arg( realLine ).arg( cat ).arg( realCat ), 2 ); + QgsDebugMsgLevel( QString( "fid = %1 oldLid = %2 realLine = %3 cat = %4 realCat = %5" ).arg( fid ).arg( oldLid ).arg( realLine ).arg( cat ).arg( realCat ), 2 ); // index is for current fields if ( idx < 0 || idx > mEditLayer->fields().size() ) @@ -1815,7 +1795,7 @@ void QgsGrassProvider::onAttributeValueChanged( QgsFeatureId fid, int idx, const if ( !recordExists ) { mLayer->map()->undoCommands()[undoIndex] - << new QgsGrassUndoCommandChangeAttribute( this, fid, realLine, mLayerField, realCat, false, true ); + << new QgsGrassUndoCommandChangeAttribute( this, fid, realLine, mLayerField, realCat, false, true ); } } else @@ -1850,7 +1830,7 @@ void QgsGrassProvider::onAttributeValueChanged( QgsFeatureId fid, int idx, const } mLayer->map()->undoCommands()[undoIndex] - << new QgsGrassUndoCommandChangeAttribute( this, fid, newLid, mLayerField, newCat, true, !recordExists ); + << new QgsGrassUndoCommandChangeAttribute( this, fid, newLid, mLayerField, newCat, true, !recordExists ); mLayer->map()->unlockReadWrite(); } @@ -2124,4 +2104,3 @@ QString QgsGrassProvider::description() const { return tr( "GRASS %1 vector provider" ).arg( GRASS_VERSION_MAJOR ); } - diff --git a/src/providers/grass/qgsgrassprovider.h b/src/providers/grass/qgsgrassprovider.h index fd501bc46c40..eca73da52752 100644 --- a/src/providers/grass/qgsgrassprovider.h +++ b/src/providers/grass/qgsgrassprovider.h @@ -103,12 +103,29 @@ class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider // ----------------------------------- New edit -------------------------------- // Changes are written during editing. // TODO: implement also these functions but disable during manual layer editing - bool addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override { Q_UNUSED( flist ) Q_UNUSED( flags ); return true; } - bool deleteFeatures( const QgsFeatureIds &id ) override { Q_UNUSED( id ) return true; } + bool addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override + { + Q_UNUSED( flist ) + Q_UNUSED( flags ); + return true; + } + bool deleteFeatures( const QgsFeatureIds &id ) override + { + Q_UNUSED( id ) + return true; + } bool addAttributes( const QList &attributes ) override; bool deleteAttributes( const QgsAttributeIds &attributes ) override; - bool changeAttributeValues( const QgsChangedAttributesMap &attr_map ) override { Q_UNUSED( attr_map ) return true; } - bool changeGeometryValues( const QgsGeometryMap &geometry_map ) override { Q_UNUSED( geometry_map ) return true; } + bool changeAttributeValues( const QgsChangedAttributesMap &attr_map ) override + { + Q_UNUSED( attr_map ) + return true; + } + bool changeGeometryValues( const QgsGeometryMap &geometry_map ) override + { + Q_UNUSED( geometry_map ) + return true; + } //---------------------------------------------------------------------------- @@ -367,19 +384,19 @@ class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider QString description() const override; // Layer type (layerType) - enum Type // layer name: + enum Type // layer name: { - Point = 1, //!< _point - Line, //!< _line - Face, //!< _face - Polygon, //!< _polygon - Boundary, //!< Boundary (currently not used) - Centroid, //!< Centroid (currently not used) + Point = 1, //!< _point + Line, //!< _line + Face, //!< _face + Polygon, //!< _polygon + Boundary, //!< Boundary (currently not used) + Centroid, //!< Centroid (currently not used) // topology layers, may be used to display internal GRASS topology info // useful for debugging of GRASS topology and modules using topology - TopoPoint, //!< All points with topology id - TopoLine, //!< All lines with topology id - TopoNode //!< Topology nodes + TopoPoint, //!< All points with topology id + TopoLine, //!< All lines with topology id + TopoNode //!< Topology nodes }; // Set type for next digitized feature (GV_POINT,GV_LINE, GV_BOUNDARY, GV_CENTROID, GV_AREA) diff --git a/src/providers/grass/qgsgrassprovidermodule.cpp b/src/providers/grass/qgsgrassprovidermodule.cpp index 7ce5666b7d36..ca8808d9d734 100644 --- a/src/providers/grass/qgsgrassprovidermodule.cpp +++ b/src/providers/grass/qgsgrassprovidermodule.cpp @@ -97,7 +97,8 @@ QList QgsGrassItemActions::actions( QWidget *parent ) } if ( ( mGrassObject.type() == QgsGrassObject::Raster || mGrassObject.type() == QgsGrassObject::Vector - || mGrassObject.type() == QgsGrassObject::Group ) && isMapsetOwner ) + || mGrassObject.type() == QgsGrassObject::Group ) + && isMapsetOwner ) { QAction *renameAction = new QAction( tr( "Rename…" ), parent ); connect( renameAction, &QAction::triggered, this, &QgsGrassItemActions::renameGrassObject ); @@ -130,7 +131,6 @@ QList QgsGrassItemActions::actions( QWidget *parent ) void QgsGrassItemActions::newMapset() { - QStringList existingNames = QgsGrass::mapsets( mGrassObject.gisdbase(), mGrassObject.mapsetPath() ); QgsDebugMsgLevel( QStringLiteral( "existingNames = " ) + existingNames.join( ',' ), 2 ); Qt::CaseSensitivity caseSensitivity = QgsGrass::caseSensitivity(); @@ -186,7 +186,6 @@ void QgsGrassItemActions::removeMapsetFromSearchPath() void QgsGrassItemActions::renameGrassObject() { - QStringList existingNames = QgsGrass::grassObjects( mGrassObject, mGrassObject.type() ); // remove current name to avoid warning that exists existingNames.removeOne( mGrassObject.name() ); @@ -221,15 +220,12 @@ void QgsGrassItemActions::renameGrassObject() } catch ( QgsGrass::Exception &e ) { - QgsMessageOutput::showMessage( errorTitle, - QObject::tr( "Cannot rename %1 to %2" ).arg( mGrassObject.name(), obj.name() ) + "\n" + e.what(), - QgsMessageOutput::MessageText ); + QgsMessageOutput::showMessage( errorTitle, QObject::tr( "Cannot rename %1 to %2" ).arg( mGrassObject.name(), obj.name() ) + "\n" + e.what(), QgsMessageOutput::MessageText ); } } void QgsGrassItemActions::deleteGrassObject() { - if ( !QgsGrass::deleteObjectDialog( mGrassObject ) ) return; @@ -242,7 +238,6 @@ void QgsGrassItemActions::deleteGrassObject() QString QgsGrassItemActions::newVectorMap() { - QStringList existingNames = QgsGrass::grassObjects( mGrassObject, QgsGrassObject::Vector ); QgsDebugMsgLevel( QStringLiteral( "existingNames = " ) + existingNames.join( ',' ), 2 ); Qt::CaseSensitivity caseSensitivity = QgsGrass::caseSensitivity(); @@ -353,7 +348,7 @@ QgsGrassLocationItem::QgsGrassLocationItem( QgsDataItem *parent, const QString & mType = Qgis::BrowserItemType::Directory; } -QVectorQgsGrassLocationItem::createChildren() +QVector QgsGrassLocationItem::createChildren() { QVector mapsets; @@ -426,7 +421,6 @@ QIcon QgsGrassMapsetItem::icon() void QgsGrassMapsetItem::setState( Qgis::BrowserItemState state ) { - // TODO: it seems to be causing strange icon switching during import, sometimes if ( state == Qgis::BrowserItemState::Populated ) { @@ -474,7 +468,6 @@ bool QgsGrassMapsetItem::objectInImports( const QgsGrassObject &grassObject ) QVector QgsGrassMapsetItem::createChildren() { - QVector items; QStringList vectorNames = QgsGrass::vectors( mDirPath ); @@ -529,7 +522,7 @@ QVector QgsGrassMapsetItem::createChildren() { topoError = tr( "topology version not supported" ); } - else if ( topoMinor == 0 && GRASS_VERSION_MAJOR == 7 ) + else if ( topoMinor == 0 && GRASS_VERSION_MAJOR == 7 ) { topoError = tr( "topology version 6" ); } @@ -864,8 +857,7 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData *data, Qt::DropAction ) projector->setCrs( providerCrs, mapsetCrs, QgsProject::instance()->transformContext() ); if ( useSrcRegion ) { - projector->destExtentSize( rasterProvider->extent(), rasterProvider->xSize(), rasterProvider->ySize(), - newExtent, newXSize, newYSize ); + projector->destExtentSize( rasterProvider->extent(), rasterProvider->xSize(), rasterProvider->ySize(), newExtent, newXSize, newYSize ); } QgsRasterProjector::Precision precision = settings.enumValue( QStringLiteral( "GRASS/browser/import/crsTransform" ), QgsRasterProjector::Approximate ); projector->setPrecision( precision ); @@ -929,9 +921,7 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData *data, Qt::DropAction ) if ( !errors.isEmpty() ) { - QgsMessageOutput::showMessage( tr( "Import to GRASS mapset" ), - tr( "Failed to import some layers!\n\n" ) + errors.join( QLatin1Char( '\n' ) ), - QgsMessageOutput::MessageText ); + QgsMessageOutput::showMessage( tr( "Import to GRASS mapset" ), tr( "Failed to import some layers!\n\n" ) + errors.join( QLatin1Char( '\n' ) ), QgsMessageOutput::MessageText ); } return true; @@ -943,9 +933,7 @@ void QgsGrassMapsetItem::onImportFinished( QgsGrassImport *import ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); output->setTitle( tr( "Import to GRASS mapset failed" ) ); - output->setMessage( tr( "Failed to import %1 to %2: %3" ).arg( import->srcDescription(), - import->grassObject().mapsetPath(), - import->error() ), QgsMessageOutput::MessageText ); + output->setMessage( tr( "Failed to import %1 to %2: %3" ).arg( import->srcDescription(), import->grassObject().mapsetPath(), import->error() ), QgsMessageOutput::MessageText ); output->showMessage(); } @@ -986,9 +974,7 @@ void QgsGrassMapsetItem::childrenCreated() //------------------------ QgsGrassObjectItem ---------------------------------- -QgsGrassObjectItem::QgsGrassObjectItem( QgsDataItem *parent, const QgsGrassObject &grassObject, - const QString &name, const QString &path, const QString &uri, - Qgis::BrowserLayerType layerType, const QString &providerKey ) +QgsGrassObjectItem::QgsGrassObjectItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey ) : QgsLayerItem( parent, name, path, uri, layerType, providerKey ) , QgsGrassObjectItemBase( grassObject ) { @@ -1012,7 +998,7 @@ QgsGrassVectorItem::QgsGrassVectorItem( QgsDataItem *parent, const QgsGrassObjec , mValid( valid ) { QgsDebugMsgLevel( "name = " + grassObject.name() + " path = " + path, 2 ); - mCapabilities = Qgis::BrowserItemCapability::NoCapabilities; // disable Fertile from QgsDataCollectionItem + mCapabilities = Qgis::BrowserItemCapability::NoCapabilities; // disable Fertile from QgsDataCollectionItem setCapabilities( Qgis::BrowserItemCapability::NoCapabilities ); // disable fertility if ( !mValid ) { @@ -1072,9 +1058,7 @@ bool QgsGrassVectorItem::equal( const QgsDataItem *other ) //----------------------- QgsGrassVectorLayerItem ------------------------------ -QgsGrassVectorLayerItem::QgsGrassVectorLayerItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &layerName, - const QString &path, const QString &uri, - Qgis::BrowserLayerType layerType, bool singleLayer ) +QgsGrassVectorLayerItem::QgsGrassVectorLayerItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &layerName, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, bool singleLayer ) : QgsGrassObjectItem( parent, grassObject, layerName, path, uri, layerType, QStringLiteral( "grass" ) ) , mSingleLayer( singleLayer ) { @@ -1101,8 +1085,7 @@ bool QgsGrassVectorLayerItem::equal( const QgsDataItem *other ) //----------------------- QgsGrassRasterItem ------------------------------ -QgsGrassRasterItem::QgsGrassRasterItem( QgsDataItem *parent, const QgsGrassObject &grassObject, - const QString &path, const QString &uri, bool isExternal ) +QgsGrassRasterItem::QgsGrassRasterItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &path, const QString &uri, bool isExternal ) : QgsGrassObjectItem( parent, grassObject, grassObject.name(), path, uri, Qgis::BrowserLayerType::Raster, QStringLiteral( "grassraster" ) ) , mExternal( isExternal ) { @@ -1120,13 +1103,12 @@ QIcon QgsGrassRasterItem::icon() bool QgsGrassRasterItem::equal( const QgsDataItem *other ) { const QgsGrassRasterItem *item = qobject_cast( other ); - return QgsGrassObjectItem::equal( other ) && item && mExternal == item->mExternal; + return QgsGrassObjectItem::equal( other ) && item && mExternal == item->mExternal; } //----------------------- QgsGrassGroupItem ------------------------------ -QgsGrassGroupItem::QgsGrassGroupItem( QgsDataItem *parent, const QgsGrassObject &grassObject, - const QString &path, const QString &uri ) +QgsGrassGroupItem::QgsGrassGroupItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &path, const QString &uri ) : QgsGrassObjectItem( parent, grassObject, grassObject.name(), path, uri, Qgis::BrowserLayerType::Raster, QStringLiteral( "grassraster" ) ) { } @@ -1211,8 +1193,7 @@ QWidget *QgsGrassImportItem::paramWidget() if ( mImport && mImport->progress() ) { - connect( mImport->progress(), &QgsGrassImportProgress::progressChanged, - widget, &QgsGrassImportItemWidget::onProgressChanged ); + connect( mImport->progress(), &QgsGrassImportProgress::progressChanged, widget, &QgsGrassImportItemWidget::onProgressChanged ); widget->setHtml( mImport->progress()->progressHtml() ); } @@ -1304,7 +1285,7 @@ QgsDataProvider *QgsGrassProviderMetadata::createProvider( const QString &uri, c QList QgsGrassProviderMetadata::dataItemProviders() const { - QList< QgsDataItemProvider * > providers; + QList providers; providers << new QgsGrassDataItemProvider; return providers; } diff --git a/src/providers/grass/qgsgrassprovidermodule.h b/src/providers/grass/qgsgrassprovidermodule.h index eda0bc4b8095..6fb47938debb 100644 --- a/src/providers/grass/qgsgrassprovidermodule.h +++ b/src/providers/grass/qgsgrassprovidermodule.h @@ -140,9 +140,7 @@ class QgsGrassObjectItem : public QgsLayerItem, public QgsGrassObjectItemBase { Q_OBJECT public: - QgsGrassObjectItem( QgsDataItem *parent, const QgsGrassObject &grassObject, - const QString &name, const QString &path, const QString &uri, - Qgis::BrowserLayerType layerType, const QString &providerKey ); + QgsGrassObjectItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey ); #ifdef HAVE_GUI QList actions( QWidget *parent ) override { return mActions->actions( parent ); } @@ -179,15 +177,14 @@ class QgsGrassVectorItem : public QgsDataCollectionItem, public QgsGrassObjectIt QFileSystemWatcher *mWatcher = nullptr; QgsGrassVectorItem( const QgsGrassVectorItem & ) = delete; - QgsGrassVectorItem &operator= ( const QgsGrassVectorItem & ) = delete; + QgsGrassVectorItem &operator=( const QgsGrassVectorItem & ) = delete; }; class QgsGrassVectorLayerItem : public QgsGrassObjectItem { Q_OBJECT public: - QgsGrassVectorLayerItem( QgsDataItem *parent, const QgsGrassObject &vector, const QString &layerName, - const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, bool singleLayer ); + QgsGrassVectorLayerItem( QgsDataItem *parent, const QgsGrassObject &vector, const QString &layerName, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, bool singleLayer ); QString layerName() const override; bool equal( const QgsDataItem *other ) override; @@ -201,8 +198,7 @@ class QgsGrassRasterItem : public QgsGrassObjectItem { Q_OBJECT public: - QgsGrassRasterItem( QgsDataItem *parent, const QgsGrassObject &grassObject, - const QString &path, const QString &uri, bool isExternal ); + QgsGrassRasterItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &path, const QString &uri, bool isExternal ); QIcon icon() override; bool equal( const QgsDataItem *other ) override; @@ -217,11 +213,9 @@ class QgsGrassGroupItem : public QgsGrassObjectItem { Q_OBJECT public: - QgsGrassGroupItem( QgsDataItem *parent, const QgsGrassObject &grassObject, - const QString &path, const QString &uril ); + QgsGrassGroupItem( QgsDataItem *parent, const QgsGrassObject &grassObject, const QString &path, const QString &uril ); QIcon icon() override; - }; #ifdef HAVE_GUI @@ -275,7 +269,7 @@ class QgsGrassImportItem : public QgsDataItem, public QgsGrassObjectItemBase }; -class QgsGrassProviderMetadata: public QgsProviderMetadata +class QgsGrassProviderMetadata : public QgsProviderMetadata { Q_OBJECT @@ -283,9 +277,9 @@ class QgsGrassProviderMetadata: public QgsProviderMetadata QgsGrassProviderMetadata(); QIcon icon() const override; QgsDataProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; - QList< QgsDataItemProvider * > dataItemProviders() const override; + QList dataItemProviders() const override; void initProvider() override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif // QGSGRASSPROVIDERMODULE_H diff --git a/src/providers/grass/qgsgrassrasterprovider.cpp b/src/providers/grass/qgsgrassrasterprovider.cpp index 1aaa26929fea..43b27e641196 100644 --- a/src/providers/grass/qgsgrassrasterprovider.cpp +++ b/src/providers/grass/qgsgrassrasterprovider.cpp @@ -40,8 +40,8 @@ #include #include -#define ERR(message) QGS_ERROR_MESSAGE(message,"GRASS provider") -#define QGS_ERROR(message) QgsError(message,"GRASS provider") +#define ERR( message ) QGS_ERROR_MESSAGE( message, "GRASS provider" ) +#define QGS_ERROR( message ) QgsError( message, "GRASS provider" ) // Do not use warning dialogs, providers are also created on threads (rendering) where dialogs cannot be used (constructing QPixmap icon) @@ -102,8 +102,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const &uri ) appendIfError( error ); error.clear(); - mInfo = QgsGrass::info( mGisdbase, mLocation, mMapset, mMapName, QgsGrassObject::Raster, - QStringLiteral( "info" ), QgsRectangle(), 0, 0, 3000, error ); + mInfo = QgsGrass::info( mGisdbase, mLocation, mMapset, mMapName, QgsGrassObject::Raster, QStringLiteral( "info" ), QgsRectangle(), 0, 0, 3000, error ); appendIfError( error ); mGrassDataType = mInfo[QStringLiteral( "TYPE" )].toInt(); @@ -181,10 +180,10 @@ bool QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void clearLastError(); // TODO: optimize, see extent() - QgsDebugMsgLevel( "yBlock = " + QString::number( yBlock ), 2 ); + QgsDebugMsgLevel( "yBlock = " + QString::number( yBlock ), 2 ); QStringList arguments; - arguments.append( "map=" + mMapName + "@" + mMapset ); + arguments.append( "map=" + mMapName + "@" + mMapset ); QgsRectangle ext = extent(); @@ -196,11 +195,9 @@ bool QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void QgsDebugMsgLevel( "mYBlockSize = " + QString::number( mYBlockSize ), 2 ); arguments.append( ( QStringLiteral( "window=%1,%2,%3,%4,%5,%6" ) - .arg( QgsRasterBlock::printValue( ext.xMinimum() ), - QgsRasterBlock::printValue( yMinimum ), - QgsRasterBlock::printValue( ext.xMaximum() ), - QgsRasterBlock::printValue( yMaximum ) ) - .arg( mCols ).arg( mYBlockSize ) ) ); + .arg( QgsRasterBlock::printValue( ext.xMinimum() ), QgsRasterBlock::printValue( yMinimum ), QgsRasterBlock::printValue( ext.xMaximum() ), QgsRasterBlock::printValue( yMaximum ) ) + .arg( mCols ) + .arg( mYBlockSize ) ) ); arguments.append( QStringLiteral( "format=value" ) ); QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.d.rast"; @@ -234,11 +231,11 @@ bool QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void return true; } -bool QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight, void *block, QgsRasterBlockFeedback *feedback ) +bool QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight, void *block, QgsRasterBlockFeedback *feedback ) { Q_UNUSED( feedback ) - QgsDebugMsgLevel( "pixelWidth = " + QString::number( pixelWidth ), 2 ); - QgsDebugMsgLevel( "pixelHeight = " + QString::number( pixelHeight ), 2 ); + QgsDebugMsgLevel( "pixelWidth = " + QString::number( pixelWidth ), 2 ); + QgsDebugMsgLevel( "pixelHeight = " + QString::number( pixelHeight ), 2 ); QgsDebugMsgLevel( "viewExtent: " + viewExtent.toString(), 2 ); clearLastError(); @@ -246,14 +243,12 @@ bool QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const &viewExt return false; QStringList arguments; - arguments.append( "map=" + mMapName + "@" + mMapset ); + arguments.append( "map=" + mMapName + "@" + mMapset ); arguments.append( ( QStringLiteral( "window=%1,%2,%3,%4,%5,%6" ) - .arg( QgsRasterBlock::printValue( viewExtent.xMinimum() ), - QgsRasterBlock::printValue( viewExtent.yMinimum() ), - QgsRasterBlock::printValue( viewExtent.xMaximum() ), - QgsRasterBlock::printValue( viewExtent.yMaximum() ) ) - .arg( pixelWidth ).arg( pixelHeight ) ) ); + .arg( QgsRasterBlock::printValue( viewExtent.xMinimum() ), QgsRasterBlock::printValue( viewExtent.yMinimum() ), QgsRasterBlock::printValue( viewExtent.xMaximum() ), QgsRasterBlock::printValue( viewExtent.yMaximum() ) ) + .arg( pixelWidth ) + .arg( pixelHeight ) ) ); arguments.append( QStringLiteral( "format=value" ) ); QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.d.rast"; QByteArray data; @@ -312,8 +307,7 @@ QgsRasterBandStats QgsGrassRasterProvider::bandStatistics( int bandNo, Qgis::Ras int timeout = 30000 + 0.005 * xSize() * ySize(); QString error; - QHash info = QgsGrass::info( mGisdbase, mLocation, mMapset, mMapName, QgsGrassObject::Raster, - QStringLiteral( "stats" ), extent, sampleRows, sampleCols, timeout, error ); + QHash info = QgsGrass::info( mGisdbase, mLocation, mMapset, mMapName, QgsGrassObject::Raster, QStringLiteral( "stats" ), extent, sampleRows, sampleCols, timeout, error ); if ( info.isEmpty() || !error.isEmpty() ) { @@ -334,16 +328,13 @@ QgsRasterBandStats QgsGrassRasterProvider::bandStatistics( int bandNo, Qgis::Ras QgsDebugMsgLevel( QString( "count = %1" ).arg( myRasterBandStats.elementCount ), 2 ); QgsDebugMsgLevel( QString( "stdev = %1" ).arg( myRasterBandStats.stdDev ), 2 ); - myRasterBandStats.statsGathered = Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | - Qgis::RasterBandStatistic::Range | Qgis::RasterBandStatistic::Mean | - Qgis::RasterBandStatistic::Sum | Qgis::RasterBandStatistic::SumOfSquares | - Qgis::RasterBandStatistic::StdDev; + myRasterBandStats.statsGathered = Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | Qgis::RasterBandStatistic::Range | Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::Sum | Qgis::RasterBandStatistic::SumOfSquares | Qgis::RasterBandStatistic::StdDev; mStatistics.append( myRasterBandStats ); return myRasterBandStats; } -QList QgsGrassRasterProvider::colorTable( int bandNo )const +QList QgsGrassRasterProvider::colorTable( int bandNo ) const { Q_UNUSED( bandNo ) QList ct; @@ -468,8 +459,8 @@ QgsRasterIdentifyResult QgsGrassRasterProvider::identify( const QgsPointXY &poin Qgis::RasterInterfaceCapabilities QgsGrassRasterProvider::capabilities() const { Qgis::RasterInterfaceCapabilities capability = Qgis::RasterInterfaceCapability::Identify - | Qgis::RasterInterfaceCapability::IdentifyValue - | Qgis::RasterInterfaceCapability::Size; + | Qgis::RasterInterfaceCapability::IdentifyValue + | Qgis::RasterInterfaceCapability::Size; return capability; } @@ -562,12 +553,12 @@ QString QgsGrassRasterProvider::lastError() return mLastError; } -QString QgsGrassRasterProvider::name() const +QString QgsGrassRasterProvider::name() const { return QStringLiteral( "grassraster" ); } -QString QgsGrassRasterProvider::description() const +QString QgsGrassRasterProvider::description() const { return QStringLiteral( "GRASS %1 raster provider" ).arg( GRASS_VERSION_MAJOR ); } @@ -630,7 +621,7 @@ void QgsGrassRasterValue::start() QStringList arguments; arguments.append( QStringLiteral( "info=query" ) ); - arguments.append( "rast=" + mMapName + "@" + mMapset ); + arguments.append( "rast=" + mMapName + "@" + mMapset ); try { mProcess = QgsGrass::startModule( mGisdbase, mLocation, mMapset, module, arguments, mGisrcFile ); @@ -671,8 +662,7 @@ double QgsGrassRasterValue::value( double x, double y, bool *ok ) return value; } - QString coor = QStringLiteral( "%1 %2\n" ).arg( QgsRasterBlock::printValue( x ), - QgsRasterBlock::printValue( y ) ); + QString coor = QStringLiteral( "%1 %2\n" ).arg( QgsRasterBlock::printValue( x ), QgsRasterBlock::printValue( y ) ); QgsDebugMsgLevel( "coor : " + coor, 2 ); mProcess->write( coor.toLatin1() ); // how to flush, necessary? mProcess->waitForReadyRead(); @@ -684,10 +674,9 @@ double QgsGrassRasterValue::value( double x, double y, bool *ok ) QStringList list = str.trimmed().split( ':' ); if ( list.size() == 2 ) { - if ( list[1] == QLatin1String( "error" ) ) return value; + if ( list[1] == QLatin1String( "error" ) ) + return value; value = list[1].toDouble( ok ); } return value; } - - diff --git a/src/providers/grass/qgsgrassrasterprovider.h b/src/providers/grass/qgsgrassrasterprovider.h index a40ba0002015..4830be9f68c3 100644 --- a/src/providers/grass/qgsgrassrasterprovider.h +++ b/src/providers/grass/qgsgrassrasterprovider.h @@ -64,13 +64,13 @@ class GRASS_LIB_EXPORT QgsGrassRasterValue // returns raster value, NaN for no data // OK is set to true if OK or false on error double value( double x, double y, bool *ok ); - private: + private: void start(); - QString mGisdbase; // map gisdabase - QString mLocation; // map location name (not path!) - QString mMapset; // map mapset - QString mMapName; // map name + QString mGisdbase; // map gisdabase + QString mLocation; // map location name (not path!) + QString mMapset; // map mapset + QString mMapName; // map name QTemporaryFile mGisrcFile; QProcess *mProcess = nullptr; }; @@ -89,7 +89,6 @@ class GRASS_LIB_EXPORT QgsGrassRasterProvider : public QgsRasterDataProvider Q_OBJECT public: - /** * Constructor for the provider. * @@ -183,14 +182,11 @@ class GRASS_LIB_EXPORT QgsGrassRasterProvider : public QgsRasterDataProvider int ySize() const override; bool readBlock( int bandNo, int xBlock, int yBlock, void *data ) override; - bool readBlock( int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback = nullptr ) override; + bool readBlock( int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback = nullptr ) override; - QgsRasterBandStats bandStatistics( int bandNo, - Qgis::RasterBandStatistics stats = Qgis::RasterBandStatistic::All, - const QgsRectangle &boundingBox = QgsRectangle(), - int sampleSize = 0, QgsRasterBlockFeedback *feedback = nullptr ) override; + QgsRasterBandStats bandStatistics( int bandNo, Qgis::RasterBandStatistics stats = Qgis::RasterBandStatistic::All, const QgsRectangle &boundingBox = QgsRectangle(), int sampleSize = 0, QgsRasterBlockFeedback *feedback = nullptr ) override; - QList colorTable( int bandNo )const override; + QList colorTable( int bandNo ) const override; // void buildSupportedRasterFileFilter( QString & fileFiltersString ); @@ -212,10 +208,10 @@ class GRASS_LIB_EXPORT QgsGrassRasterProvider : public QgsRasterDataProvider */ bool mValid = false; - QString mGisdbase; // map gisdabase - QString mLocation; // map location name (not path!) - QString mMapset; // map mapset - QString mMapName; // map name + QString mGisdbase; // map gisdabase + QString mLocation; // map location name (not path!) + QString mMapset; // map mapset + QString mMapName; // map name RASTER_MAP_TYPE mGrassDataType = 0; // CELL_TYPE, DCELL_TYPE, FCELL_TYPE diff --git a/src/providers/grass/qgsgrassrasterprovidermodule.cpp b/src/providers/grass/qgsgrassrasterprovidermodule.cpp index e64b411d42bd..c88f006a9b4f 100644 --- a/src/providers/grass/qgsgrassrasterprovidermodule.cpp +++ b/src/providers/grass/qgsgrassrasterprovidermodule.cpp @@ -24,17 +24,18 @@ static const QString PROVIDER_KEY = QStringLiteral( "grassraster" ); static const QString PROVIDER_DESCRIPTION = QStringLiteral( "GRASS %1 raster provider" ).arg( GRASS_VERSION_MAJOR ); -class QgsGrassRasterProviderMetadata: public QgsProviderMetadata +class QgsGrassRasterProviderMetadata : public QgsProviderMetadata { public: - QgsGrassRasterProviderMetadata(): QgsProviderMetadata( PROVIDER_KEY, PROVIDER_DESCRIPTION ) {} + QgsGrassRasterProviderMetadata() + : QgsProviderMetadata( PROVIDER_KEY, PROVIDER_DESCRIPTION ) {} QgsGrassRasterProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override { Q_UNUSED( options ); Q_UNUSED( flags ); return new QgsGrassRasterProvider( uri ); } - QList< Qgis::LayerType > supportedLayerTypes() const override + QList supportedLayerTypes() const override { return { Qgis::LayerType::Raster }; } @@ -49,4 +50,3 @@ QGISEXTERN QgsProviderMetadata *providerMetadataFactory() { return new QgsGrassRasterProviderMetadata(); } - diff --git a/src/providers/grass/qgsgrassundocommand.cpp b/src/providers/grass/qgsgrassundocommand.cpp index 757dcbf6e14f..5fc850109e34 100644 --- a/src/providers/grass/qgsgrassundocommand.cpp +++ b/src/providers/grass/qgsgrassundocommand.cpp @@ -74,4 +74,3 @@ void QgsGrassUndoCommandChangeAttribute::undo() } } } - diff --git a/src/providers/grass/qgsgrassundocommand.h b/src/providers/grass/qgsgrassundocommand.h index 57d958c0f323..d512ff2c6a72 100644 --- a/src/providers/grass/qgsgrassundocommand.h +++ b/src/providers/grass/qgsgrassundocommand.h @@ -34,6 +34,7 @@ class GRASS_LIB_EXPORT QgsGrassUndoCommandChangeAttribute : public QgsGrassUndoC public: QgsGrassUndoCommandChangeAttribute( QgsGrassProvider *provider, int fid, int lid, int field, int cat, bool deleteCat, bool deleteRecord ); void undo() override; + private: QgsGrassProvider *mProvider = nullptr; int mFid; diff --git a/src/providers/grass/qgsgrassvector.cpp b/src/providers/grass/qgsgrassvector.cpp index 925751acbe2f..598ea4e417b2 100644 --- a/src/providers/grass/qgsgrassvector.cpp +++ b/src/providers/grass/qgsgrassvector.cpp @@ -29,7 +29,7 @@ extern "C" #include #endif #include -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -108,7 +108,7 @@ QgsFields QgsGrassVectorLayer::fields() mFieldsTimeStamp.setSecsSinceEpoch( 0 ); return mFields; } - if ( dblnFileInfo.lastModified() > mFieldsTimeStamp && !mDriver.isEmpty() + if ( dblnFileInfo.lastModified() > mFieldsTimeStamp && !mDriver.isEmpty() && !mDatabase.isEmpty() && !mTable.isEmpty() && !mKey.isEmpty() ) { QgsDebugMsgLevel( "reload fields", 2 ); @@ -118,7 +118,7 @@ QgsFields QgsGrassVectorLayer::fields() QgsDebugMsgLevel( "open database " + mDatabase + " by driver " + mDriver, 2 ); QgsGrass::lock(); - QgsGrass::setMapset( mGrassObject.gisdbase(), mGrassObject.location(), mGrassObject.mapset() ); + QgsGrass::setMapset( mGrassObject.gisdbase(), mGrassObject.location(), mGrassObject.mapset() ); dbDriver *driver = db_start_driver_open_database( mDriver.toUtf8().constData(), mDatabase.toUtf8().constData() ); if ( !driver ) @@ -183,8 +183,7 @@ QgsFields QgsGrassVectorLayer::fields() /*********************** QgsGrassVector ***********************/ -QgsGrassVector::QgsGrassVector( const QString &gisdbase, const QString &location, const QString &mapset, - const QString &name, QObject *parent ) +QgsGrassVector::QgsGrassVector( const QString &gisdbase, const QString &location, const QString &mapset, const QString &name, QObject *parent ) : QObject( parent ) , mGrassObject( gisdbase, location, mapset, name ) , mNodeCount( 0 ) diff --git a/src/providers/grass/qgsgrassvector.h b/src/providers/grass/qgsgrassvector.h index c812c34d41a5..ee66d3ba4c9a 100644 --- a/src/providers/grass/qgsgrassvector.h +++ b/src/providers/grass/qgsgrassvector.h @@ -77,8 +77,7 @@ class GRASS_LIB_EXPORT QgsGrassVector : public QObject { Q_OBJECT public: - QgsGrassVector( const QString &gisdbase, const QString &location, const QString &mapset, - const QString &name, QObject *parent = nullptr ); + QgsGrassVector( const QString &gisdbase, const QString &location, const QString &mapset, const QString &name, QObject *parent = nullptr ); QgsGrassVector( const QgsGrassObject &grassObject, QObject *parent = nullptr ); @@ -92,7 +91,7 @@ class GRASS_LIB_EXPORT QgsGrassVector : public QObject * Gets numbers of primitives * \returns type/count pairs */ - QMap typeCounts() const {return mTypeCounts; } + QMap typeCounts() const { return mTypeCounts; } //! Gets total number of primitives of given type. Types may be combined by bitwise or) int typeCount( int type ) const; diff --git a/src/providers/grass/qgsgrassvectormap.cpp b/src/providers/grass/qgsgrassvectormap.cpp index 249c64aa0404..44e7f9a5d3b8 100644 --- a/src/providers/grass/qgsgrassvectormap.cpp +++ b/src/providers/grass/qgsgrassvectormap.cpp @@ -31,7 +31,7 @@ extern "C" { #include -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -112,7 +112,7 @@ bool QgsGrassVectorMap::openMap() QgsGrass::setLocation( mGrassObject.gisdbase(), mGrassObject.location() ); // Find the vector - const char *ms = G_find_vector2( mGrassObject.name().toUtf8().constData(), mGrassObject.mapset().toUtf8().constData() ); + const char *ms = G_find_vector2( mGrassObject.name().toUtf8().constData(), mGrassObject.mapset().toUtf8().constData() ); if ( !ms ) { @@ -152,9 +152,7 @@ bool QgsGrassVectorMap::openMap() } else if ( level == 1 ) { - QMessageBox::StandardButton ret = QMessageBox::question( nullptr, QStringLiteral( "Warning" ), - QObject::tr( "GRASS vector map %1 does not have topology. Build topology?" ).arg( mGrassObject.name() ), - QMessageBox::Ok | QMessageBox::Cancel ); + QMessageBox::StandardButton ret = QMessageBox::question( nullptr, QStringLiteral( "Warning" ), QObject::tr( "GRASS vector map %1 does not have topology. Build topology?" ).arg( mGrassObject.name() ), QMessageBox::Ok | QMessageBox::Cancel ); if ( ret == QMessageBox::Cancel ) { @@ -419,7 +417,7 @@ void QgsGrassVectorMap::closeLayer( QgsGrassVectorMapLayer *layer ) lockOpenCloseLayer(); layer->removeUser(); - if ( layer->userCount() == 0 ) // No more users, free sources + if ( layer->userCount() == 0 ) // No more users, free sources { QgsDebugMsgLevel( "No more users -> clear", 2 ); layer->clear(); @@ -481,7 +479,6 @@ void QgsGrassVectorMap::update() bool QgsGrassVectorMap::mapOutdated() { - QString dp = mGrassObject.mapsetPath() + "/vector/" + mGrassObject.name(); QFileInfo di( dp ); @@ -502,7 +499,6 @@ bool QgsGrassVectorMap::mapOutdated() bool QgsGrassVectorMap::attributesOutdated() { - QString dp = mGrassObject.mapsetPath() + "/vector/" + mGrassObject.name() + "/dbln"; QFileInfo di( dp ); @@ -517,19 +513,17 @@ bool QgsGrassVectorMap::attributesOutdated() int QgsGrassVectorMap::numLines() { - return ( Vect_get_num_lines( mMap ) ); } int QgsGrassVectorMap::numAreas() { - return ( Vect_get_num_areas( mMap ) ); } QString QgsGrassVectorMap::toString() { - return mGrassObject.mapsetPath() + "/" + mGrassObject.name(); + return mGrassObject.mapsetPath() + "/" + mGrassObject.name(); } void QgsGrassVectorMap::printDebug() @@ -667,7 +661,7 @@ QgsAbstractGeometry *QgsGrassVectorMap::areaGeometry( int id ) QgsPolygon *polygon = new QgsPolygon(); struct line_pnts *points = Vect_new_line_struct(); - QgsDebugMsgLevel( QString( "points= %1" ).arg( ( quint64 )points ), 3 ); + QgsDebugMsgLevel( QString( "points= %1" ).arg( ( quint64 ) points ), 3 ); // Vect_get_area_points and Vect_get_isle_pointsis using static variable -> lock // TODO: Faster to lock the whole feature iterator? Maybe only for areas? QgsGrass::lock(); @@ -694,7 +688,7 @@ QgsAbstractGeometry *QgsGrassVectorMap::areaGeometry( int id ) pointList.reserve( points->n_points ); for ( int i = 0; i < points->n_points; i++ ) { - pointList << QgsPoint( is3d() ? Qgis::WkbType::PointZ : Qgis::WkbType::Point, points->x[i], points->y[i], points->z[i] ); + pointList << QgsPoint( is3d() ? Qgis::WkbType::PointZ : Qgis::WkbType::Point, points->x[i], points->y[i], points->z[i] ); } ring = new QgsLineString(); ring->setPoints( pointList ); @@ -711,7 +705,7 @@ void QgsGrassVectorMap::closeAllIterators() // cancel and close all iterator // Iterators must be connected properly, otherwise may it result in dead lock! emit cancelIterators(); // non blocking - emit closeIterators(); // blocking + emit closeIterators(); // blocking QgsDebugMsgLevel( "iterators closed", 2 ); } diff --git a/src/providers/grass/qgsgrassvectormap.h b/src/providers/grass/qgsgrassvectormap.h index c255b4673fa4..852ff235ef85 100644 --- a/src/providers/grass/qgsgrassvectormap.h +++ b/src/providers/grass/qgsgrassvectormap.h @@ -36,8 +36,8 @@ class GRASS_LIB_EXPORT QgsGrassVectorMap : public QObject TopoUndefined = 0, TopoPoint, TopoLine, - TopoBoundaryError, // both sides topology broken - TopoBoundaryErrorLeft, // left side topology broken + TopoBoundaryError, // both sides topology broken + TopoBoundaryErrorLeft, // left side topology broken TopoBoundaryErrorRight, // right side topology broken TopoBoundaryOk, TopoCentroidIn, @@ -88,7 +88,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMap : public QObject QHash &oldGeometries() { return mOldGeometries; } QHash &oldTypes() { return mOldTypes; } QHash &newCats() { return mNewCats; } - QMap > &undoCommands() { return mUndoCommands; } + QMap> &undoCommands() { return mUndoCommands; } /** * Gets geometry of line. @@ -159,7 +159,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMap : public QObject */ TopoSymbol topoSymbol( int lid ); - static QString topoSymbolFieldName() { return QStringLiteral( "topo_symbol" ) ; } + static QString topoSymbolFieldName() { return QStringLiteral( "topo_symbol" ); } void printDebug(); @@ -199,7 +199,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMap : public QObject QDateTime mLastAttributesModified; // when attributes are changed // map header - struct Map_info *mMap = nullptr; + struct Map_info *mMap = nullptr; // Is 3D, has z coordinates bool mIs3d; // Vector layers @@ -219,7 +219,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMap : public QObject QHash mNewCats; // Map of undo commands with undo stack index as key. - QMap > mUndoCommands; + QMap> mUndoCommands; // Mutex used to avoid concurrent read/write, used only in editing mode QMutex mReadWriteMutex; diff --git a/src/providers/grass/qgsgrassvectormaplayer.cpp b/src/providers/grass/qgsgrassvectormaplayer.cpp index 6ce96b15bac5..f169c70152eb 100644 --- a/src/providers/grass/qgsgrassvectormaplayer.cpp +++ b/src/providers/grass/qgsgrassvectormaplayer.cpp @@ -28,7 +28,7 @@ extern "C" { #include -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -121,7 +121,7 @@ void QgsGrassVectorMapLayer::load() QgsGrass::lock(); // not sure if lock is necessary dbString dbstr; db_init_string( &dbstr ); - db_set_string( &dbstr, ( char * )"select * from " ); + db_set_string( &dbstr, ( char * ) "select * from " ); db_append_string( &dbstr, mFieldInfo->table ); QgsDebugMsgLevel( QString( "SQL: %1" ).arg( db_get_string( &dbstr ) ), 2 ); @@ -138,7 +138,7 @@ void QgsGrassVectorMapLayer::load() QgsDebugMsgLevel( QString( "Number of records: %1" ).arg( nRecords ), 2 ); #endif - dbTable *databaseTable = db_get_cursor_table( &databaseCursor ); + dbTable *databaseTable = db_get_cursor_table( &databaseCursor ); int nColumns = db_get_table_number_of_columns( databaseTable ); // Read columns' description @@ -172,8 +172,7 @@ void QgsGrassVectorMapLayer::load() qtype = QMetaType::Type::QString; break; } - mTableFields.append( QgsField( db_get_column_name( column ), qtype, ctypeStr, - db_get_column_length( column ), db_get_column_precision( column ) ) ); + mTableFields.append( QgsField( db_get_column_name( column ), qtype, ctypeStr, db_get_column_length( column ), db_get_column_precision( column ) ) ); mMinMax << minMax; if ( G_strcasecmp( db_get_column_name( column ), mFieldInfo->key ) == 0 ) { @@ -343,7 +342,6 @@ QStringList QgsGrassVectorMapLayer::fieldNames( const QgsFields &fields ) void QgsGrassVectorMapLayer::updateFields() { - // update fields to pass layer/buffer check when committing for ( int i = mFields.size() - 1; i >= 0; i-- ) { @@ -463,7 +461,6 @@ void QgsGrassVectorMapLayer::addTopoField( QgsFields &fields ) void QgsGrassVectorMapLayer::startEdit() { - // add topo field which is present until closeEdit when data are reloaded addTopoField( mFields ); @@ -480,7 +477,6 @@ void QgsGrassVectorMapLayer::startEdit() void QgsGrassVectorMapLayer::closeEdit() { - if ( mDriver ) { QgsDebugMsgLevel( "close driver", 2 ); @@ -605,7 +601,6 @@ void QgsGrassVectorMapLayer::createTable( const QgsFields &fields, QString &erro try { QgsGrass::createTable( mDriver, mFieldInfo->table, catFields ); - } catch ( QgsGrass::Exception &e ) { @@ -618,8 +613,7 @@ void QgsGrassVectorMapLayer::createTable( const QgsFields &fields, QString &erro if ( mFieldInfo ) { - int ret = Vect_map_add_dblink( mMap->map(), mField, nullptr, mFieldInfo->table, mFieldInfo->key, - mFieldInfo->database, mFieldInfo->driver ); + int ret = Vect_map_add_dblink( mMap->map(), mField, nullptr, mFieldInfo->table, mFieldInfo->key, mFieldInfo->database, mFieldInfo->driver ); if ( ret == -1 ) { @@ -703,7 +697,8 @@ void QgsGrassVectorMapLayer::addColumn( const QgsField &field, QString &error ) QVariant value = it.value().value( index ); QString valueString = quotedValue( value ); QString query = QStringLiteral( "UPDATE %1 SET %2 = %3 WHERE %4 = %5" ) - .arg( mFieldInfo->table, field.name(), valueString, keyColumnName() ).arg( it.key() ); + .arg( mFieldInfo->table, field.name(), valueString, keyColumnName() ) + .arg( it.key() ); QString err; executeSql( query, err ); if ( !err.isEmpty() ) @@ -870,8 +865,7 @@ void QgsGrassVectorMapLayer::insertAttributes( int cat, const QgsFeature &featur } } - QString query = QStringLiteral( "INSERT INTO %1 ( %2 ) VALUES ( %3 )" ).arg( mFieldInfo->table, - names.join( QLatin1String( ", " ) ), values.join( QLatin1Char( ',' ) ) ); + QString query = QStringLiteral( "INSERT INTO %1 ( %2 ) VALUES ( %3 )" ).arg( mFieldInfo->table, names.join( QLatin1String( ", " ) ), values.join( QLatin1Char( ',' ) ) ); executeSql( query, error ); if ( error.isEmpty() ) { @@ -990,8 +984,7 @@ void QgsGrassVectorMapLayer::updateAttributes( int cat, QgsFeature &feature, QSt return; } - QString query = QStringLiteral( "UPDATE %1 SET %2 WHERE %3 = %4" ).arg( mFieldInfo->table, - updates.join( QLatin1String( ", " ) ), mFieldInfo->key ).arg( cat ); + QString query = QStringLiteral( "UPDATE %1 SET %2 WHERE %3 = %4" ).arg( mFieldInfo->table, updates.join( QLatin1String( ", " ) ), mFieldInfo->key ).arg( cat ); executeSql( query, error ); if ( error.isEmpty() ) @@ -1054,8 +1047,7 @@ bool QgsGrassVectorMapLayer::isOrphan( int cat, QString &error ) } int t, id; - int ret = Vect_cidx_find_next( mMap->map(), fieldIndex, cat, - GV_POINTS | GV_LINES | GV_FACE, 0, &t, &id ); + int ret = Vect_cidx_find_next( mMap->map(), fieldIndex, cat, GV_POINTS | GV_LINES | GV_FACE, 0, &t, &id ); if ( ret >= 0 ) { @@ -1092,8 +1084,7 @@ void QgsGrassVectorMapLayer::changeAttributeValue( int cat, const QgsField &fiel if ( exists ) { - query = QStringLiteral( "UPDATE %1 SET %2 = %3 WHERE %4 = %5" ).arg( mFieldInfo->table, - field.name(), valueString, mFieldInfo->key ).arg( cat ); + query = QStringLiteral( "UPDATE %1 SET %2 = %3 WHERE %4 = %5" ).arg( mFieldInfo->table, field.name(), valueString, mFieldInfo->key ).arg( cat ); } else { @@ -1103,8 +1094,7 @@ void QgsGrassVectorMapLayer::changeAttributeValue( int cat, const QgsField &fiel values << QString::number( cat ); names << field.name(); values << quotedValue( value ); - query = QStringLiteral( "INSERT INTO %1 ( %2 ) VALUES ( %3 )" ).arg( mFieldInfo->table, - names.join( QLatin1String( ", " ) ), values.join( QLatin1Char( ',' ) ) ); + query = QStringLiteral( "INSERT INTO %1 ( %2 ) VALUES ( %3 )" ).arg( mFieldInfo->table, names.join( QLatin1String( ", " ) ), values.join( QLatin1Char( ',' ) ) ); } QgsDebugMsgLevel( QString( "query: %1" ).arg( query ), 2 ); @@ -1118,7 +1108,7 @@ void QgsGrassVectorMapLayer::changeAttributeValue( int cat, const QgsField &fiel QgsDebugMsgLevel( QString( "qcs: %1" ).arg( qcs.data() ), 2 ); char *cs = new char[qcs.length() + 1]; - strcpy( cs, ( const char * )qcs ); + strcpy( cs, ( const char * ) qcs ); db_set_string( &dbstr, cs ); delete[] cs; @@ -1171,7 +1161,7 @@ void QgsGrassVectorMapLayer::printCachedAttributes() for ( int cat : constKeys ) { QStringList values; - for ( int i = 0; i < mAttributes.value( cat ).size(); i++ ) + for ( int i = 0; i < mAttributes.value( cat ).size(); i++ ) { values << mAttributes.value( cat ).value( i ).toString(); } diff --git a/src/providers/grass/qgsgrassvectormaplayer.h b/src/providers/grass/qgsgrassvectormaplayer.h index 9c48391a9f01..53bcbb801e29 100644 --- a/src/providers/grass/qgsgrassvectormaplayer.h +++ b/src/providers/grass/qgsgrassvectormaplayer.h @@ -29,7 +29,7 @@ extern "C" { #include -#if defined(_MSC_VER) && defined(M_PI_4) +#if defined( _MSC_VER ) && defined( M_PI_4 ) #undef M_PI_4 //avoid redefinition warning #endif #include @@ -71,7 +71,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMapLayer : public QObject static QStringList fieldNames( const QgsFields &fields ); - QMap > &attributes() { return mAttributes; } + QMap> &attributes() { return mAttributes; } /** * Gets attribute for index corresponding to current fields(), @@ -82,7 +82,7 @@ class GRASS_LIB_EXPORT QgsGrassVectorMapLayer : public QObject bool hasTable() { return mHasTable; } int keyColumn() { return mKeyColumn; } QString keyColumnName() { return mFieldInfo ? mFieldInfo->key : QString(); } - QList< QPair > minMax() { return mMinMax; } + QList> minMax() { return mMinMax; } int userCount() { return mUsers; } void addUser(); @@ -207,13 +207,13 @@ class GRASS_LIB_EXPORT QgsGrassVectorMapLayer : public QObject QgsFields mAttributeFields; // Map of attributes with cat as key - QMap > mAttributes; + QMap> mAttributes; // Map of current original fields() indexes to mAttributes, skipping topo symbol //QMap mAttributeIndexes; // minimum and maximum values of attributes - QList > mMinMax; + QList> mMinMax; // timestamp when attributes were loaded QDateTime mLastLoaded; // number of instances using this layer diff --git a/src/providers/grass/qgsgrasswin.cpp b/src/providers/grass/qgsgrasswin.cpp index 0913fb78b204..e99f3371adcc 100644 --- a/src/providers/grass/qgsgrasswin.cpp +++ b/src/providers/grass/qgsgrasswin.cpp @@ -30,12 +30,12 @@ // Get window for pid struct EnumData { - DWORD dwProcessId; - HWND hWnd; + DWORD dwProcessId; + HWND hWnd; }; BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam ) { - EnumData &ed = *( EnumData * )lParam; + EnumData &ed = *( EnumData * ) lParam; DWORD dwProcessId = 0x0; GetWindowThreadProcessId( hWnd, &dwProcessId ); if ( ed.dwProcessId == dwProcessId ) @@ -49,8 +49,7 @@ BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam ) HWND FindWindowFromProcessId( DWORD dwProcessId ) { EnumData ed = { dwProcessId }; - if ( !EnumWindows( EnumProc, ( LPARAM )&ed ) && - ( GetLastError() == ERROR_SUCCESS ) ) + if ( !EnumWindows( EnumProc, ( LPARAM ) &ed ) && ( GetLastError() == ERROR_SUCCESS ) ) { return ed.hWnd; } @@ -63,7 +62,7 @@ void QgsGrassWin::hideWindow( int pid ) Q_UNUSED( pid ) QgsDebugMsgLevel( QString( "pid = %1" ).arg( pid ), 2 ); #ifdef Q_OS_WIN - HWND hWnd = FindWindowFromProcessId( ( DWORD )pid ); + HWND hWnd = FindWindowFromProcessId( ( DWORD ) pid ); if ( hWnd ) { QgsDebugMsgLevel( "driver window found -> minimize", 2 ); @@ -76,4 +75,3 @@ void QgsGrassWin::hideWindow( int pid ) ShowWindow( hWnd, SW_HIDE ); #endif } - diff --git a/src/providers/grass/qgsgrasswin.h b/src/providers/grass/qgsgrasswin.h index 0688949b1d2d..8fb3b1f7e741 100644 --- a/src/providers/grass/qgsgrasswin.h +++ b/src/providers/grass/qgsgrasswin.h @@ -27,4 +27,3 @@ class GRASS_LIB_EXPORT QgsGrassWin }; #endif // QGSGRASSWIN_H - diff --git a/src/providers/hana/qgshanacolumntypethread.cpp b/src/providers/hana/qgshanacolumntypethread.cpp index 0fb75e468109..3fc11446adc3 100644 --- a/src/providers/hana/qgshanacolumntypethread.cpp +++ b/src/providers/hana/qgshanacolumntypethread.cpp @@ -47,9 +47,10 @@ void QgsHanaColumnTypeThread::run() try { QVector layerProperties = conn->getLayers( - mUri.schema(), - mAllowGeometrylessTables, - mUserTablesOnly ); + mUri.schema(), + mAllowGeometrylessTables, + mUserTablesOnly + ); if ( layerProperties.isEmpty() ) return; @@ -66,7 +67,7 @@ void QgsHanaColumnTypeThread::run() QgsHanaLayerProperty &layerProperty = layerProperties[i]; emit progress( i, totalLayers ); emit progressMessage( tr( "Scanning column %1.%2.%3…" ) - .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) ); + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) ); conn->readLayerInfo( layerProperty ); if ( layerProperty.isValid ) diff --git a/src/providers/hana/qgshanacolumntypethread.h b/src/providers/hana/qgshanacolumntypethread.h index 90d51878e9a0..cd3aed5fe0df 100644 --- a/src/providers/hana/qgshanacolumntypethread.h +++ b/src/providers/hana/qgshanacolumntypethread.h @@ -49,4 +49,4 @@ class QgsHanaColumnTypeThread : public QThread QString mErrorMessage; }; -#endif // QGSHANACOLUMNTYPETHREAD_H +#endif // QGSHANACOLUMNTYPETHREAD_H diff --git a/src/providers/hana/qgshanaconnection.cpp b/src/providers/hana/qgshanaconnection.cpp index 610b456f85af..b52979e92e1f 100644 --- a/src/providers/hana/qgshanaconnection.cpp +++ b/src/providers/hana/qgshanaconnection.cpp @@ -48,8 +48,7 @@ namespace { QMap ret; DatabaseMetaDataUnicodeRef dmd = conn.getDatabaseMetaDataUnicode(); - ResultSetRef rsStats = dmd->getStatistics( nullptr, schemaName.toStdU16String().c_str(), - tableName.toStdU16String().c_str(), IndexType::UNIQUE, StatisticsAccuracy::ENSURE ); + ResultSetRef rsStats = dmd->getStatistics( nullptr, schemaName.toStdU16String().c_str(), tableName.toStdU16String().c_str(), IndexType::UNIQUE, StatisticsAccuracy::ENSURE ); QMap compositeKeys; while ( rsStats->next() ) { @@ -77,7 +76,7 @@ namespace int getSrid( PreparedStatementRef &stmt ) { int srid = -1; - ResultSetRef rsSrid = stmt->executeQuery( ); + ResultSetRef rsSrid = stmt->executeQuery(); while ( rsSrid->next() ) { Int value = rsSrid->getInt( 1 ); @@ -94,7 +93,7 @@ namespace rsSrid->close(); return srid; } -} +} // namespace QgsField AttributeField::toQgsField() const { @@ -179,7 +178,7 @@ QgsField AttributeField::toQgsField() const static const uint8_t CREDENTIALS_INPUT_MAX_ATTEMPTS = 5; static const int GEOMETRIES_SELECT_LIMIT = 10; -QgsHanaConnection::QgsHanaConnection( ConnectionRef connection, const QgsDataSourceUri &uri ) +QgsHanaConnection::QgsHanaConnection( ConnectionRef connection, const QgsDataSourceUri &uri ) : mConnection( connection ) , mUri( uri ) { @@ -225,10 +224,7 @@ QgsHanaConnection *QgsHanaConnection::createConnection( const QgsDataSourceUri & conn->setAutoCommit( false ); QString message; - auto connect = []( ConnectionRef & conn, - const QgsDataSourceUri & uri, - QString & errorMessage ) - { + auto connect = []( ConnectionRef &conn, const QgsDataSourceUri &uri, QString &errorMessage ) { try { QgsHanaConnectionStringBuilder sb( uri ); @@ -406,7 +402,7 @@ QVariant QgsHanaConnection::executeScalar( const QString &sql ) if ( resultSet->next() ) res = resultSet->getValue( 1 ); resultSet->close(); - return res; + return res; } catch ( const Exception &ex ) { @@ -424,7 +420,7 @@ QVariant QgsHanaConnection::executeScalar( const QString &sql, const QVariantLis if ( resultSet->next() ) res = resultSet->getValue( 1 ); resultSet->close(); - return res; + return res; } catch ( const Exception &ex ) { @@ -578,44 +574,46 @@ QVector QgsHanaConnection::getLayers( const QString &schemaName, bool allowGeometrylessTables, bool userTablesOnly, - const std::function &layerFilter ) + const std::function &layerFilter +) { const QString schema = mUri.schema().isEmpty() ? schemaName : mUri.schema(); const QString sqlSchemaFilter = QStringLiteral( - "SELECT DISTINCT(SCHEMA_NAME) FROM SYS.EFFECTIVE_PRIVILEGES WHERE " - "OBJECT_TYPE IN ('SCHEMA', 'TABLE', 'VIEW') AND " - "SCHEMA_NAME LIKE ? AND " - "SCHEMA_NAME NOT LIKE_REGEXPR 'SYS|_SYS.*|UIS|SAP_XS|SAP_REST|HANA_XS' AND " - "PRIVILEGE IN ('SELECT', 'CREATE ANY') AND " - "USER_NAME = CURRENT_USER AND IS_VALID = 'TRUE'" ); + "SELECT DISTINCT(SCHEMA_NAME) FROM SYS.EFFECTIVE_PRIVILEGES WHERE " + "OBJECT_TYPE IN ('SCHEMA', 'TABLE', 'VIEW') AND " + "SCHEMA_NAME LIKE ? AND " + "SCHEMA_NAME NOT LIKE_REGEXPR 'SYS|_SYS.*|UIS|SAP_XS|SAP_REST|HANA_XS' AND " + "PRIVILEGE IN ('SELECT', 'CREATE ANY') AND " + "USER_NAME = CURRENT_USER AND IS_VALID = 'TRUE'" + ); const QString sqlOwnerFilter = userTablesOnly ? QStringLiteral( "OWNER_NAME = CURRENT_USER" ) : QStringLiteral( "OWNER_NAME IS NOT NULL" ); - const QString sqlDataTypeFilter = !allowGeometrylessTables ? QStringLiteral( "DATA_TYPE_NAME IN ('ST_GEOMETRY','ST_POINT')" ) : - QStringLiteral( "DATA_TYPE_NAME IS NOT NULL" ); + const QString sqlDataTypeFilter = !allowGeometrylessTables ? QStringLiteral( "DATA_TYPE_NAME IN ('ST_GEOMETRY','ST_POINT')" ) : QStringLiteral( "DATA_TYPE_NAME IS NOT NULL" ); const QString sqlTables = QStringLiteral( - "SELECT SCHEMA_NAME, TABLE_NAME, COLUMN_NAME, DATA_TYPE_NAME, TABLE_COMMENTS FROM " - "(SELECT * FROM SYS.TABLE_COLUMNS WHERE " - "TABLE_OID IN (SELECT OBJECT_OID FROM OWNERSHIP WHERE OBJECT_TYPE = 'TABLE' AND %1) AND " - "SCHEMA_NAME IN (%2) AND %3) " - "INNER JOIN " - "(SELECT TABLE_OID AS TABLE_OID_2, COMMENTS AS TABLE_COMMENTS FROM SYS.TABLES WHERE IS_USER_DEFINED_TYPE = 'FALSE') " - "ON TABLE_OID = TABLE_OID_2" ); + "SELECT SCHEMA_NAME, TABLE_NAME, COLUMN_NAME, DATA_TYPE_NAME, TABLE_COMMENTS FROM " + "(SELECT * FROM SYS.TABLE_COLUMNS WHERE " + "TABLE_OID IN (SELECT OBJECT_OID FROM OWNERSHIP WHERE OBJECT_TYPE = 'TABLE' AND %1) AND " + "SCHEMA_NAME IN (%2) AND %3) " + "INNER JOIN " + "(SELECT TABLE_OID AS TABLE_OID_2, COMMENTS AS TABLE_COMMENTS FROM SYS.TABLES WHERE IS_USER_DEFINED_TYPE = 'FALSE') " + "ON TABLE_OID = TABLE_OID_2" + ); const QString sqlViews = QStringLiteral( - "SELECT SCHEMA_NAME, VIEW_NAME, COLUMN_NAME, DATA_TYPE_NAME, VIEW_COMMENTS FROM " - "(SELECT * FROM SYS.VIEW_COLUMNS WHERE " - "VIEW_OID IN (SELECT OBJECT_OID FROM OWNERSHIP WHERE OBJECT_TYPE = 'VIEW' AND %1) AND " - "SCHEMA_NAME IN (%2) AND %3) " - "INNER JOIN " - "(SELECT VIEW_OID AS VIEW_OID_2, COMMENTS AS VIEW_COMMENTS FROM SYS.VIEWS) " - "ON VIEW_OID = VIEW_OID_2" ); + "SELECT SCHEMA_NAME, VIEW_NAME, COLUMN_NAME, DATA_TYPE_NAME, VIEW_COMMENTS FROM " + "(SELECT * FROM SYS.VIEW_COLUMNS WHERE " + "VIEW_OID IN (SELECT OBJECT_OID FROM OWNERSHIP WHERE OBJECT_TYPE = 'VIEW' AND %1) AND " + "SCHEMA_NAME IN (%2) AND %3) " + "INNER JOIN " + "(SELECT VIEW_OID AS VIEW_OID_2, COMMENTS AS VIEW_COMMENTS FROM SYS.VIEWS) " + "ON VIEW_OID = VIEW_OID_2" + ); QMultiHash, QgsHanaLayerProperty> layers; - auto addLayers = [&]( const QString & sql, bool isView ) - { + auto addLayers = [&]( const QString &sql, bool isView ) { PreparedStatementRef stmt = mConnection->prepareStatement( QgsHanaUtils::toUtf16( sql ) ); stmt->setNString( 1, NString( schema.isEmpty() ? u"%" : schema.toStdU16String() ) ); QgsHanaResultSetRef rsLayers = QgsHanaResultSet::create( stmt ); @@ -687,7 +685,8 @@ QVector QgsHanaConnection::getLayersFull( const QString &schemaName, bool allowGeometrylessTables, bool userTablesOnly, - const std::function &layerFilter ) + const std::function &layerFilter +) { QVector layers = getLayers( schemaName, allowGeometrylessTables, userTablesOnly, layerFilter ); // We cannot use a range-based for loop as layers are modified in readLayerInfo. @@ -712,13 +711,12 @@ void QgsHanaConnection::readLayerInfo( QgsHanaLayerProperty &layerProperty ) } } -void QgsHanaConnection::readQueryFields( const QString &schemaName, const QString &sql, - const std::function &callback ) +void QgsHanaConnection::readQueryFields( const QString &schemaName, const QString &sql, const std::function &callback ) { QMap> clmComments; auto getColumnComments = [&clmComments, &conn = mConnection]( - const QString & schemaName, const QString & tableName, const QString & columnName ) - { + const QString &schemaName, const QString &tableName, const QString &columnName + ) { if ( schemaName.isEmpty() || tableName.isEmpty() || columnName.isEmpty() ) return QString(); const QString key = QStringLiteral( "%1.%2" ).arg( QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ) ); @@ -743,8 +741,8 @@ void QgsHanaConnection::readQueryFields( const QString &schemaName, const QStrin QMap> clmUniqueness; auto isColumnUnique = [&clmUniqueness, &conn = mConnection]( - const QString & schemaName, const QString & tableName, const QString & columnName ) - { + const QString &schemaName, const QString &tableName, const QString &columnName + ) { if ( schemaName.isEmpty() || tableName.isEmpty() || columnName.isEmpty() ) return false; const QString key = QStringLiteral( "%1.%2" ).arg( QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ) ); @@ -801,13 +799,12 @@ void QgsHanaConnection::readQueryFields( const QString &schemaName, const QStrin void QgsHanaConnection::readTableFields( const QString &schemaName, const QString &tableName, const std::function &callback ) { QMap> clmAutoIncrement; - auto isColumnAutoIncrement = [&]( const QString & columnName ) - { + auto isColumnAutoIncrement = [&]( const QString &columnName ) { const QString key = QStringLiteral( "%1.%2" ).arg( schemaName, tableName ); if ( !clmAutoIncrement.contains( key ) ) { QString sql = QStringLiteral( "SELECT * FROM %1.%2" ) - .arg( QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ) ); + .arg( QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ) ); PreparedStatementRef stmt = prepareStatement( sql ); ResultSetMetaDataUnicodeRef rsmd = stmt->getMetaDataUnicode(); for ( unsigned short i = 1; i <= rsmd->getColumnCount(); ++i ) @@ -821,8 +818,7 @@ void QgsHanaConnection::readTableFields( const QString &schemaName, const QStrin }; QMap> clmUniqueness; - auto isColumnUnique = [&]( const QString & columnName ) - { + auto isColumnUnique = [&]( const QString &columnName ) { const QString key = QStringLiteral( "%1.%2" ).arg( schemaName, tableName ); if ( !clmUniqueness.contains( key ) ) clmUniqueness.insert( key, getColumnsUniqueness( *mConnection, schemaName, tableName ) ); @@ -835,26 +831,23 @@ void QgsHanaConnection::readTableFields( const QString &schemaName, const QStrin while ( rsColumns->next() ) { AttributeField field; - field.schemaName = rsColumns->getString( 2/*TABLE_SCHEM*/ ); - field.tableName = rsColumns->getString( 3/*TABLE_NAME*/ ); - field.name = rsColumns->getString( 4/*COLUMN_NAME*/ ); - field.type = QgsHanaDataTypeUtils::fromInt( rsColumns->getShort( 5/*DATA_TYPE*/ ) ); - field.typeName = rsColumns->getString( 6/*TYPE_NAME*/ ); + field.schemaName = rsColumns->getString( 2 /*TABLE_SCHEM*/ ); + field.tableName = rsColumns->getString( 3 /*TABLE_NAME*/ ); + field.name = rsColumns->getString( 4 /*COLUMN_NAME*/ ); + field.type = QgsHanaDataTypeUtils::fromInt( rsColumns->getShort( 5 /*DATA_TYPE*/ ) ); + field.typeName = rsColumns->getString( 6 /*TYPE_NAME*/ ); if ( field.type == QgsHanaDataType::Unknown ) throw QgsHanaException( QString( "Type of the column '%1' is unknown" ).arg( field.name ) ); - field.size = rsColumns->getInt( 7/*COLUMN_SIZE*/ ); - field.precision = static_cast( rsColumns->getShort( 9/*DECIMAL_DIGITS*/ ) ); - field.isSigned = field.type == QgsHanaDataType::SmallInt || field.type == QgsHanaDataType::Integer || - field.type == QgsHanaDataType::BigInt || field.type == QgsHanaDataType::Decimal || - field.type == QgsHanaDataType::Numeric || field.type == QgsHanaDataType::Real || - field.type == QgsHanaDataType::Float || field.type == QgsHanaDataType::Double; - QString isNullable = rsColumns->getString( 18/*IS_NULLABLE*/ ); + field.size = rsColumns->getInt( 7 /*COLUMN_SIZE*/ ); + field.precision = static_cast( rsColumns->getShort( 9 /*DECIMAL_DIGITS*/ ) ); + field.isSigned = field.type == QgsHanaDataType::SmallInt || field.type == QgsHanaDataType::Integer || field.type == QgsHanaDataType::BigInt || field.type == QgsHanaDataType::Decimal || field.type == QgsHanaDataType::Numeric || field.type == QgsHanaDataType::Real || field.type == QgsHanaDataType::Float || field.type == QgsHanaDataType::Double; + QString isNullable = rsColumns->getString( 18 /*IS_NULLABLE*/ ); field.isNullable = ( isNullable == QLatin1String( "YES" ) || isNullable == QLatin1String( "TRUE" ) ); field.isAutoIncrement = isColumnAutoIncrement( field.name ); field.isUnique = isColumnUnique( field.name ); if ( field.type == QgsHanaDataType::Geometry ) field.srid = getColumnSrid( schemaName, tableName, field.name ); - field.comment = rsColumns->getString( 12/*REMARKS*/ ); + field.comment = rsColumns->getString( 12 /*REMARKS*/ ); callback( field ); } @@ -870,7 +863,7 @@ QVector QgsHanaConnection::getSchemas( const QString &own QString sql = QStringLiteral( "SELECT SCHEMA_NAME, SCHEMA_OWNER FROM SYS.SCHEMAS WHERE " "HAS_PRIVILEGES = 'TRUE' AND %1 AND " "SCHEMA_NAME NOT LIKE_REGEXPR 'SYS|_SYS.*|UIS|SAP_XS|SAP_REST|HANA_XS|XSSQLCC_'" ) - .arg( !ownerName.isEmpty() ? QStringLiteral( "SCHEMA_OWNER = ?" ) : QStringLiteral( "SCHEMA_OWNER IS NOT NULL" ) ); + .arg( !ownerName.isEmpty() ? QStringLiteral( "SCHEMA_OWNER = ?" ) : QStringLiteral( "SCHEMA_OWNER IS NOT NULL" ) ); QVector list; @@ -882,7 +875,7 @@ QVector QgsHanaConnection::getSchemas( const QString &own QgsHanaResultSetRef rsSchemas = QgsHanaResultSet::create( stmt ); while ( rsSchemas->next() ) { - list.push_back( {rsSchemas->getString( 1 ), rsSchemas->getString( 2 )} ); + list.push_back( { rsSchemas->getString( 1 ), rsSchemas->getString( 2 ) } ); } rsSchemas->close(); } @@ -899,9 +892,7 @@ QStringList QgsHanaConnection::getLayerPrimaryKey( const QString &schemaName, co try { DatabaseMetaDataUnicodeRef dbmd = mConnection->getDatabaseMetaDataUnicode(); - ResultSetRef rsPrimaryKeys = dbmd->getPrimaryKeys( nullptr, - QgsHanaUtils::toUtf16( schemaName ), - QgsHanaUtils::toUtf16( tableName ) ); + ResultSetRef rsPrimaryKeys = dbmd->getPrimaryKeys( nullptr, QgsHanaUtils::toUtf16( schemaName ), QgsHanaUtils::toUtf16( tableName ) ); QMap pos2Name; while ( rsPrimaryKeys->next() ) { @@ -927,12 +918,11 @@ QStringList QgsHanaConnection::getPrimaryKeyCandidates( const QgsHanaLayerProper QgsHanaResultSetRef rsColumns = getColumns( layerProperty.schemaName, layerProperty.tableName, QStringLiteral( "%" ) ); while ( rsColumns->next() ) { - QgsHanaDataType dataType = QgsHanaDataTypeUtils::fromInt( rsColumns->getValue( 5/*DATA_TYPE */ ).toInt() ); + QgsHanaDataType dataType = QgsHanaDataTypeUtils::fromInt( rsColumns->getValue( 5 /*DATA_TYPE */ ).toInt() ); // We exclude ST_GEOMETRY, REAL_VECTOR and LOB columns - if ( dataType == QgsHanaDataType::Geometry || dataType == QgsHanaDataType::RealVector || - dataType == QgsHanaDataType::LongVarBinary || dataType == QgsHanaDataType::LongVarChar || dataType == QgsHanaDataType::WLongVarChar ) + if ( dataType == QgsHanaDataType::Geometry || dataType == QgsHanaDataType::RealVector || dataType == QgsHanaDataType::LongVarBinary || dataType == QgsHanaDataType::LongVarChar || dataType == QgsHanaDataType::WLongVarChar ) continue; - ret << rsColumns->getValue( 4/*COLUMN_NAME */ ).toString(); + ret << rsColumns->getValue( 4 /*COLUMN_NAME */ ).toString(); } rsColumns->close(); return ret; @@ -945,10 +935,12 @@ Qgis::WkbType QgsHanaConnection::getColumnGeometryType( const QString &querySour Qgis::WkbType ret = Qgis::WkbType::Unknown; QString sql = QStringLiteral( "SELECT upper(%1.ST_GeometryType()), %1.ST_Is3D(), %1.ST_IsMeasured() FROM %2 " - "WHERE %1 IS NOT NULL LIMIT %3" ).arg( - QgsHanaUtils::quotedIdentifier( columnName ), - querySource, - QString::number( GEOMETRIES_SELECT_LIMIT ) ); + "WHERE %1 IS NOT NULL LIMIT %3" ) + .arg( + QgsHanaUtils::quotedIdentifier( columnName ), + querySource, + QString::number( GEOMETRIES_SELECT_LIMIT ) + ); try { @@ -957,7 +949,8 @@ Qgis::WkbType QgsHanaConnection::getColumnGeometryType( const QString &querySour while ( rsGeomInfo->next() ) { Qgis::WkbType geomType = QgsWkbTypes::singleType( QgsHanaUtils::toWkbType( - rsGeomInfo->getString( 1 ), rsGeomInfo->getInt( 2 ), rsGeomInfo->getInt( 3 ) ) ); + rsGeomInfo->getString( 1 ), rsGeomInfo->getInt( 2 ), rsGeomInfo->getInt( 3 ) + ) ); if ( geomType == Qgis::WkbType::Unknown ) continue; if ( ret == Qgis::WkbType::Unknown ) @@ -980,8 +973,7 @@ Qgis::WkbType QgsHanaConnection::getColumnGeometryType( const QString &querySour Qgis::WkbType QgsHanaConnection::getColumnGeometryType( const QString &schemaName, const QString &tableName, const QString &columnName ) { - QString querySource = QStringLiteral( "%1.%2" ).arg( QgsHanaUtils::quotedIdentifier( schemaName ), - QgsHanaUtils::quotedIdentifier( tableName ) ); + QString querySource = QStringLiteral( "%1.%2" ).arg( QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ) ); return getColumnGeometryType( querySource, columnName ); } @@ -1020,7 +1012,7 @@ int QgsHanaConnection::getColumnSrid( const QString &schemaName, const QString & try { PreparedStatementRef stmt = mConnection->prepareStatement( "SELECT SRS_ID FROM SYS.ST_GEOMETRY_COLUMNS " - "WHERE SCHEMA_NAME = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?" ); + "WHERE SCHEMA_NAME = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?" ); stmt->setNString( 1, NString( schemaName.toStdU16String() ) ); stmt->setNString( 2, NString( tableName.toStdU16String() ) ); stmt->setNString( 3, NString( columnName.toStdU16String() ) ); @@ -1029,10 +1021,7 @@ int QgsHanaConnection::getColumnSrid( const QString &schemaName, const QString & if ( srid == -1 ) { QString sql = QStringLiteral( "SELECT %1.ST_SRID() FROM %2.%3 WHERE %1 IS NOT NULL LIMIT %4" ) - .arg( QgsHanaUtils::quotedIdentifier( columnName ), - QgsHanaUtils::quotedIdentifier( schemaName ), - QgsHanaUtils::quotedIdentifier( tableName ), - QString::number( GEOMETRIES_SELECT_LIMIT ) ); + .arg( QgsHanaUtils::quotedIdentifier( columnName ), QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ), QString::number( GEOMETRIES_SELECT_LIMIT ) ); stmt = mConnection->prepareStatement( QgsHanaUtils::toUtf16( sql ) ); srid = getSrid( stmt ); } @@ -1053,9 +1042,7 @@ int QgsHanaConnection::getColumnSrid( const QString &sql, const QString &columnN try { QString query = QStringLiteral( "SELECT %1.ST_SRID() FROM (%2) WHERE %1 IS NOT NULL LIMIT %3" ) - .arg( QgsHanaUtils::quotedIdentifier( columnName ), - sql, - QString::number( GEOMETRIES_SELECT_LIMIT ) ); + .arg( QgsHanaUtils::quotedIdentifier( columnName ), sql, QString::number( GEOMETRIES_SELECT_LIMIT ) ); PreparedStatementRef stmt = mConnection->prepareStatement( QgsHanaUtils::toUtf16( query ) ); return getSrid( stmt ); } @@ -1070,8 +1057,7 @@ QgsHanaResultSetRef QgsHanaConnection::getColumns( const QString &schemaName, co try { DatabaseMetaDataUnicodeRef metadata = mConnection->getDatabaseMetaDataUnicode(); - QgsHanaResultSetRef ret( new QgsHanaResultSet( metadata->getColumns( nullptr, - QgsHanaUtils::toUtf16( schemaName ), QgsHanaUtils::toUtf16( tableName ), QgsHanaUtils::toUtf16( fieldName ) ) ) ); + QgsHanaResultSetRef ret( new QgsHanaResultSet( metadata->getColumns( nullptr, QgsHanaUtils::toUtf16( schemaName ), QgsHanaUtils::toUtf16( tableName ), QgsHanaUtils::toUtf16( fieldName ) ) ) ); return ret; } catch ( const Exception &ex ) @@ -1080,10 +1066,10 @@ QgsHanaResultSetRef QgsHanaConnection::getColumns( const QString &schemaName, co } } -bool QgsHanaConnection::isTable( const QString &schemaName, const QString &tableName ) +bool QgsHanaConnection::isTable( const QString &schemaName, const QString &tableName ) { QString sql = QStringLiteral( "SELECT COUNT(*) FROM SYS.TABLES WHERE SCHEMA_NAME = ? AND TABLE_NAME = ?" ); - return executeCountQuery( sql, {schemaName, tableName } ) == 1; + return executeCountQuery( sql, { schemaName, tableName } ) == 1; } PreparedStatementRef QgsHanaConnection::createPreparedStatement( const QString &sql, const QVariantList &args ) diff --git a/src/providers/hana/qgshanaconnection.h b/src/providers/hana/qgshanaconnection.h index a0e36abc99f9..9e9a97931d3f 100644 --- a/src/providers/hana/qgshanaconnection.h +++ b/src/providers/hana/qgshanaconnection.h @@ -28,21 +28,21 @@ struct AttributeField { - QString schemaName; - QString tableName; - QString name; - QgsHanaDataType type = QgsHanaDataType::Unknown; - int srid = -1; - QString typeName; - int size = 0; - int precision = 0; - bool isAutoIncrement = false; - bool isNullable = false; - bool isSigned = false; - bool isUnique = false; - QString comment; - - QgsField toQgsField() const; + QString schemaName; + QString tableName; + QString name; + QgsHanaDataType type = QgsHanaDataType::Unknown; + int srid = -1; + QString typeName; + int size = 0; + int precision = 0; + bool isAutoIncrement = false; + bool isNullable = false; + bool isSigned = false; + bool isUnique = false; + QString comment; + + QgsField toQgsField() const; }; using AttributeFields = QVector; @@ -78,12 +78,14 @@ class QgsHanaConnection : public QObject const QString &schemaName, bool allowGeometrylessTables, bool userTablesOnly = true, - const std::function &layerFilter = nullptr ); + const std::function &layerFilter = nullptr + ); QVector getLayersFull( const QString &schemaName, bool allowGeometrylessTables, bool userTablesOnly = true, - const std::function &layerFilter = nullptr ); + const std::function &layerFilter = nullptr + ); void readLayerInfo( QgsHanaLayerProperty &layerProperty ); void readQueryFields( const QString &schemaName, const QString &sql, const std::function &callback ); void readTableFields( const QString &schemaName, const QString &tableName, const std::function &callback ); @@ -118,4 +120,4 @@ class QgsHanaConnection : public QObject QString mUserName; }; -#endif // QGSHANACONNECTION_H +#endif // QGSHANACONNECTION_H diff --git a/src/providers/hana/qgshanaconnectionpool.cpp b/src/providers/hana/qgshanaconnectionpool.cpp index d7d9d7d2ba7e..ec0d4f7cbbc4 100644 --- a/src/providers/hana/qgshanaconnectionpool.cpp +++ b/src/providers/hana/qgshanaconnectionpool.cpp @@ -22,7 +22,7 @@ #include "qgslogger.h" QgsHanaConnectionPoolGroup::QgsHanaConnectionPoolGroup( const QString &name ) - : QgsConnectionPoolGroup( name ) + : QgsConnectionPoolGroup( name ) { initTimer( this ); } @@ -72,14 +72,16 @@ QgsHanaConnectionPool::~QgsHanaConnectionPool() QgsHanaConnectionRef::QgsHanaConnectionRef( const QgsDataSourceUri &uri ) { mConnection = std::unique_ptr( - QgsHanaConnectionPool::getConnection( QgsHanaUtils::connectionInfo( uri ) ) ); + QgsHanaConnectionPool::getConnection( QgsHanaUtils::connectionInfo( uri ) ) + ); } QgsHanaConnectionRef::QgsHanaConnectionRef( const QString &name ) { QgsHanaSettings settings( name, true ); mConnection = std::unique_ptr( - QgsHanaConnectionPool::getConnection( QgsHanaUtils::connectionInfo( settings.toDataSourceUri() ) ) ); + QgsHanaConnectionPool::getConnection( QgsHanaUtils::connectionInfo( settings.toDataSourceUri() ) ) + ); } QgsHanaConnectionRef::~QgsHanaConnectionRef() diff --git a/src/providers/hana/qgshanaconnectionpool.h b/src/providers/hana/qgshanaconnectionpool.h index 4032d4925140..038b74719725 100644 --- a/src/providers/hana/qgshanaconnectionpool.h +++ b/src/providers/hana/qgshanaconnectionpool.h @@ -50,7 +50,8 @@ inline bool qgsConnectionPool_ConnectionIsValid( QgsHanaConnection *c ) } class QgsHanaConnectionPoolGroup - : public QObject, public QgsConnectionPoolGroup + : public QObject, + public QgsConnectionPoolGroup { Q_OBJECT diff --git a/src/providers/hana/qgshanaconnectionstringbuilder.cpp b/src/providers/hana/qgshanaconnectionstringbuilder.cpp index f71c06939066..3f21511e221a 100644 --- a/src/providers/hana/qgshanaconnectionstringbuilder.cpp +++ b/src/providers/hana/qgshanaconnectionstringbuilder.cpp @@ -60,8 +60,7 @@ QString QgsHanaConnectionStringBuilder::toString() const // See notes for constructing connection string for HANA // https://help.sap.com/docs/SAP_HANA_CLIENT/f1b440ded6144a54ada97ff95dac7adf/7cab593774474f2f8db335710b2f5c50.html QRegularExpression rxSpecialChars( "\\[|\\]|\\{|\\}|\\(|\\)|\\,|\\;|\\?|\\*|\\=|\\!|\\@" ); - auto addProperty = [&props, &rxSpecialChars]( const QString & name, const QString & value ) - { + auto addProperty = [&props, &rxSpecialChars]( const QString &name, const QString &value ) { if ( value.isEmpty() ) return; diff --git a/src/providers/hana/qgshanacrsutils.cpp b/src/providers/hana/qgshanacrsutils.cpp index b90b862fdff3..457556a2a7b6 100644 --- a/src/providers/hana/qgshanacrsutils.cpp +++ b/src/providers/hana/qgshanacrsutils.cpp @@ -22,8 +22,7 @@ double QgsHanaCrsUtils::getAngularUnits( const QgsCoordinateReferenceSystem &crs ) { - auto throwUnableToGetAngularUnits = []() - { + auto throwUnableToGetAngularUnits = []() { throw QgsHanaException( "Unable to retrieve angular units from a spatial reference system" ); }; @@ -40,14 +39,7 @@ double QgsHanaCrsUtils::getAngularUnits( const QgsCoordinateReferenceSystem &crs throwUnableToGetAngularUnits(); double factor; - const bool ret = proj_cs_get_axis_info( context, pjCoordinateSystem.get(), 0, - nullptr, - nullptr, - nullptr, - &factor, - nullptr, - nullptr, - nullptr ); + const bool ret = proj_cs_get_axis_info( context, pjCoordinateSystem.get(), 0, nullptr, nullptr, nullptr, &factor, nullptr, nullptr, nullptr ); if ( !ret ) throwUnableToGetAngularUnits(); return factor; diff --git a/src/providers/hana/qgshanadataitemguiprovider.cpp b/src/providers/hana/qgshanadataitemguiprovider.cpp index 8eeff337cf40..a8776569eaee 100644 --- a/src/providers/hana/qgshanadataitemguiprovider.cpp +++ b/src/providers/hana/qgshanadataitemguiprovider.cpp @@ -31,7 +31,8 @@ #include void QgsHanaDataItemGuiProvider::populateContextMenu( - QgsDataItem *item, QMenu *menu, const QList &selection, QgsDataItemGuiContext context ) + QgsDataItem *item, QMenu *menu, const QList &selection, QgsDataItemGuiContext context +) { if ( QgsHanaRootItem *rootItem = qobject_cast( item ) ) { @@ -56,14 +57,10 @@ void QgsHanaDataItemGuiProvider::populateContextMenu( connect( actionDuplicate, &QAction::triggered, this, [connItem] { duplicateConnection( connItem ); } ); menu->addAction( actionDuplicate ); - const QList< QgsHanaConnectionItem * > hanaConnectionItems = QgsDataItem::filteredItems( selection ); + const QList hanaConnectionItems = QgsDataItem::filteredItems( selection ); QAction *actionDelete = new QAction( hanaConnectionItems.size() > 1 ? tr( "Remove Connections…" ) : tr( "Remove Connection…" ), menu ); - connect( actionDelete, &QAction::triggered, this, [hanaConnectionItems, context] - { - QgsDataItemGuiProviderUtils::deleteConnections( hanaConnectionItems, []( const QString & connectionName ) - { - QgsHanaSettings::removeConnection( connectionName ); - }, context ); + connect( actionDelete, &QAction::triggered, this, [hanaConnectionItems, context] { + QgsDataItemGuiProviderUtils::deleteConnections( hanaConnectionItems, []( const QString &connectionName ) { QgsHanaSettings::removeConnection( connectionName ); }, context ); } ); menu->addAction( actionDelete ); @@ -95,7 +92,7 @@ void QgsHanaDataItemGuiProvider::populateContextMenu( menu->addMenu( maintainMenu ); } - if ( QgsHanaLayerItem *layerItem = qobject_cast< QgsHanaLayerItem * >( item ) ) + if ( QgsHanaLayerItem *layerItem = qobject_cast( item ) ) { const QgsHanaLayerProperty &layerInfo = layerItem->layerInfo(); if ( !layerInfo.isView ) @@ -118,9 +115,7 @@ bool QgsHanaDataItemGuiProvider::deleteLayer( QgsLayerItem *item, QgsDataItemGui const QgsHanaLayerProperty &layerInfo = layerItem->layerInfo(); const QString layerName = QStringLiteral( "%1.%2" ).arg( layerInfo.schemaName, layerInfo.tableName ); const QString caption = tr( layerInfo.isView ? "Delete View" : "Delete Table" ); - if ( QMessageBox::question( nullptr, caption, - tr( "Are you sure you want to delete '%1'?" ).arg( layerName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, caption, tr( "Are you sure you want to delete '%1'?" ).arg( layerName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return false; QString errorMsg; @@ -162,7 +157,8 @@ bool QgsHanaDataItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiCo } bool QgsHanaDataItemGuiProvider::handleDrop( - QgsDataItem *item, QgsDataItemGuiContext, const QMimeData *data, Qt::DropAction ) + QgsDataItem *item, QgsDataItemGuiContext, const QMimeData *data, Qt::DropAction +) { if ( QgsHanaConnectionItem *connItem = qobject_cast( item ) ) { @@ -254,8 +250,7 @@ void QgsHanaDataItemGuiProvider::createSchema( QgsDataItem *item, QgsDataItemGui if ( errorMsg.isEmpty() ) { - notify( tr( "New Schema" ), tr( "Schema '%1' created successfully." ).arg( schemaName ), - context, Qgis::MessageLevel::Success ); + notify( tr( "New Schema" ), tr( "Schema '%1' created successfully." ).arg( schemaName ), context, Qgis::MessageLevel::Success ); item->refresh(); // the parent should be updated @@ -264,8 +259,7 @@ void QgsHanaDataItemGuiProvider::createSchema( QgsDataItem *item, QgsDataItemGui } else { - notify( tr( "New Schema" ), tr( "Unable to create schema '%1'\n%2" ).arg( schemaName, errorMsg ), - context, Qgis::MessageLevel::Warning ); + notify( tr( "New Schema" ), tr( "Unable to create schema '%1'\n%2" ).arg( schemaName, errorMsg ), context, Qgis::MessageLevel::Warning ); } } @@ -280,9 +274,7 @@ void QgsHanaDataItemGuiProvider::deleteSchema( QgsHanaSchemaItem *schemaItem, Qg const auto tables = providerConn.tables( schemaName ); if ( tables.empty() ) { - if ( QMessageBox::question( nullptr, caption, - tr( "Are you sure you want to delete '%1'?" ).arg( schemaName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, caption, tr( "Are you sure you want to delete '%1'?" ).arg( schemaName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; } else @@ -301,9 +293,7 @@ void QgsHanaDataItemGuiProvider::deleteSchema( QgsHanaSchemaItem *schemaItem, Qg } } - if ( QMessageBox::question( nullptr, caption, - tr( "Schema '%1' contains objects:\n\n%2\n\nAre you sure you want to delete the schema and all these objects?" ).arg( schemaName, tableNames ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, caption, tr( "Schema '%1' contains objects:\n\n%2\n\nAre you sure you want to delete the schema and all these objects?" ).arg( schemaName, tableNames ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; } @@ -316,15 +306,13 @@ void QgsHanaDataItemGuiProvider::deleteSchema( QgsHanaSchemaItem *schemaItem, Qg if ( errorMsg.isEmpty() ) { - notify( caption, tr( "Schema '%1' deleted successfully." ).arg( schemaName ), - context, Qgis::MessageLevel::Success ); + notify( caption, tr( "Schema '%1' deleted successfully." ).arg( schemaName ), context, Qgis::MessageLevel::Success ); if ( schemaItem->parent() ) schemaItem->parent()->refresh(); } else { - notify( caption, tr( "Unable to delete schema '%1'\n%2" ).arg( schemaName, errorMsg ), - context, Qgis::MessageLevel::Warning ); + notify( caption, tr( "Unable to delete schema '%1'\n%2" ).arg( schemaName, errorMsg ), context, Qgis::MessageLevel::Warning ); } } @@ -351,15 +339,13 @@ void QgsHanaDataItemGuiProvider::renameSchema( QgsHanaSchemaItem *schemaItem, Qg if ( errorMsg.isEmpty() ) { - notify( caption, tr( "Schema '%1' renamed successfully to '%2'." ).arg( schemaName, newSchemaName ), - context, Qgis::MessageLevel::Success ); + notify( caption, tr( "Schema '%1' renamed successfully to '%2'." ).arg( schemaName, newSchemaName ), context, Qgis::MessageLevel::Success ); if ( schemaItem->parent() ) schemaItem->parent()->refresh(); } else { - notify( caption, tr( "Unable to rename schema '%1'\n%2" ).arg( schemaName, errorMsg ), - context, Qgis::MessageLevel::Warning ); + notify( caption, tr( "Unable to rename schema '%1'\n%2" ).arg( schemaName, errorMsg ), context, Qgis::MessageLevel::Warning ); } } @@ -386,14 +372,12 @@ void QgsHanaDataItemGuiProvider::renameLayer( QgsHanaLayerItem *layerItem, QgsDa if ( errorMsg.isEmpty() ) { - notify( caption, tr( "'%1' renamed successfully to '%2'." ).arg( layerInfo.tableName, newLayerName ), - context, Qgis::MessageLevel::Success ); + notify( caption, tr( "'%1' renamed successfully to '%2'." ).arg( layerInfo.tableName, newLayerName ), context, Qgis::MessageLevel::Success ); if ( layerItem->parent() ) layerItem->parent()->refresh(); } else { - notify( caption, tr( "Unable to rename '%1'\n%2" ).arg( layerInfo.tableName, errorMsg ), - context, Qgis::MessageLevel::Warning ); + notify( caption, tr( "Unable to rename '%1'\n%2" ).arg( layerInfo.tableName, errorMsg ), context, Qgis::MessageLevel::Warning ); } } diff --git a/src/providers/hana/qgshanadataitemguiprovider.h b/src/providers/hana/qgshanadataitemguiprovider.h index 1ef37b9ce818..ea60df277126 100644 --- a/src/providers/hana/qgshanadataitemguiprovider.h +++ b/src/providers/hana/qgshanadataitemguiprovider.h @@ -26,11 +26,9 @@ class QgsHanaDataItemGuiProvider : public QObject, public QgsDataItemGuiProvider { Q_OBJECT public: - QString name() override { return QStringLiteral( "SAP HANA" ); } - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context ) override; diff --git a/src/providers/hana/qgshanadataitems.cpp b/src/providers/hana/qgshanadataitems.cpp index df68b8cf0552..11176640a402 100644 --- a/src/providers/hana/qgshanadataitems.cpp +++ b/src/providers/hana/qgshanadataitems.cpp @@ -36,13 +36,14 @@ QgsHanaConnectionItem::QgsHanaConnectionItem( QgsDataItem *parent, const QString &name, - const QString &path ) + const QString &path +) : QgsDataCollectionItem( parent, name, path, QStringLiteral( "SAP HANA" ) ) { mIconName = QStringLiteral( "mIconConnect.svg" ); mCapabilities |= Qgis::BrowserItemCapability::Collapse; - updateToolTip( QString( ), QString( ) ); + updateToolTip( QString(), QString() ); } QVector QgsHanaConnectionItem::createChildren() @@ -66,8 +67,7 @@ QVector QgsHanaConnectionItem::createChildren() updateToolTip( userName, conn->getDatabaseVersion() ); - const QVector schemas = - conn->getSchemas( settings.userTablesOnly() ? userName : QString() ); + const QVector schemas = conn->getSchemas( settings.userTablesOnly() ? userName : QString() ); if ( schemas.isEmpty() ) { @@ -77,8 +77,7 @@ QVector QgsHanaConnectionItem::createChildren() { for ( const QgsHanaSchemaProperty &schema : schemas ) { - QgsHanaSchemaItem *schemaItem = new QgsHanaSchemaItem( this, mName, schema.name, - mPath + '/' + schema.name ); + QgsHanaSchemaItem *schemaItem = new QgsHanaSchemaItem( this, mName, schema.name, mPath + '/' + schema.name ); items.append( schemaItem ); } } @@ -171,7 +170,7 @@ bool QgsHanaConnectionItem::handleDrop( const QMimeData *data, const QString &to if ( srcLayer->isValid() ) { - QgsDataSourceUri dsUri( u. uri ); + QgsDataSourceUri dsUri( u.uri ); QString geomColumn = dsUri.geometryColumn(); if ( geomColumn.isEmpty() ) { @@ -182,28 +181,23 @@ bool QgsHanaConnectionItem::handleDrop( const QMimeData *data, const QString &to uri.setDataSource( toSchema, u.name, geomColumn, QString(), dsUri.keyColumn() ); uri.setWkbType( srcLayer->wkbType() ); - std::unique_ptr< QgsVectorLayerExporterTask > exportTask( - new QgsVectorLayerExporterTask( srcLayer, uri.uri( false ), - QStringLiteral( "hana" ), srcLayer->crs(), QVariantMap(), owner ) ); + std::unique_ptr exportTask( + new QgsVectorLayerExporterTask( srcLayer, uri.uri( false ), QStringLiteral( "hana" ), srcLayer->crs(), QVariantMap(), owner ) + ); // when export is successful: - connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, - [ = ]() - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [=]() { QMessageBox::information( nullptr, tr( "Import to SAP HANA database" ), tr( "Import was successful." ) ); refreshSchema( toSchema ); } ); // when an error occurs: - connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, - [ = ]( Qgis::VectorExportResult error, const QString & errorMessage ) - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, [=]( Qgis::VectorExportResult error, const QString &errorMessage ) { if ( error != Qgis::VectorExportResult::UserCanceled ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); output->setTitle( tr( "Import to SAP HANA database" ) ); - output->setMessage( tr( "Failed to import some layers!\n\n" ) + - errorMessage, QgsMessageOutput::MessageText ); + output->setMessage( tr( "Failed to import some layers!\n\n" ) + errorMessage, QgsMessageOutput::MessageText ); output->showMessage(); } refreshSchema( toSchema ); @@ -228,8 +222,7 @@ bool QgsHanaConnectionItem::handleDrop( const QMimeData *data, const QString &to { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); output->setTitle( tr( "Import to SAP HANA database" ) ); - output->setMessage( tr( "Failed to import some layers!\n\n" ) + - importResults.join( QLatin1Char( '\n' ) ), QgsMessageOutput::MessageText ); + output->setMessage( tr( "Failed to import some layers!\n\n" ) + importResults.join( QLatin1Char( '\n' ) ), QgsMessageOutput::MessageText ); output->showMessage(); } @@ -242,7 +235,8 @@ QgsHanaLayerItem::QgsHanaLayerItem( const QString &name, const QString &path, Qgis::BrowserLayerType layerType, - const QgsHanaLayerProperty &layerProperty ) + const QgsHanaLayerProperty &layerProperty +) : QgsLayerItem( parent, name, path, QString(), layerType, QStringLiteral( "hana" ) ) , mLayerProperty( layerProperty ) { @@ -260,8 +254,7 @@ QVector QgsHanaLayerItem::createChildren() QString QgsHanaLayerItem::createUri() const { - QgsHanaConnectionItem *connItem = qobject_cast( parent() ? - parent()->parent() : nullptr ); + QgsHanaConnectionItem *connItem = qobject_cast( parent() ? parent()->parent() : nullptr ); if ( !connItem ) { @@ -288,8 +281,7 @@ QString QgsHanaLayerItem::createUri() const } QgsDataSourceUri uri = settings.toDataSourceUri(); - uri.setDataSource( mLayerProperty.schemaName, mLayerProperty.tableName, - mLayerProperty.geometryColName, mLayerProperty.sql, pkColumns.join( ',' ) ); + uri.setDataSource( mLayerProperty.schemaName, mLayerProperty.tableName, mLayerProperty.geometryColName, mLayerProperty.sql, pkColumns.join( ',' ) ); uri.setWkbType( mLayerProperty.type ); if ( uri.wkbType() != Qgis::WkbType::NoGeometry ) uri.setSrid( QString::number( mLayerProperty.srid ) ); @@ -307,7 +299,8 @@ QgsHanaSchemaItem::QgsHanaSchemaItem( QgsDataItem *parent, const QString &connectionName, const QString &name, - const QString &path ) + const QString &path +) : QgsDatabaseSchemaItem( parent, name, path, QStringLiteral( "SAP HANA" ) ) , mConnectionName( connectionName ) { @@ -329,8 +322,7 @@ QVector QgsHanaSchemaItem::createChildren() try { QgsHanaSettings settings( mConnectionName, true ); - const QVector layers = conn->getLayersFull( mSchemaName, - settings.allowGeometrylessTables(), settings.userTablesOnly() ); + const QVector layers = conn->getLayersFull( mSchemaName, settings.allowGeometrylessTables(), settings.userTablesOnly() ); items.reserve( layers.size() ); for ( const QgsHanaLayerProperty &layerInfo : layers ) @@ -364,8 +356,7 @@ QgsHanaLayerItem *QgsHanaSchemaItem::createLayer( const QgsHanaLayerProperty &la Qgis::BrowserLayerType layerType = Qgis::BrowserLayerType::TableLayer; if ( !layerProperty.geometryColName.isEmpty() && layerProperty.isGeometryValid() ) { - tip += tr( "\n%1 as %2" ).arg( layerProperty.geometryColName, - QgsWkbTypes::displayString( layerProperty.type ) ); + tip += tr( "\n%1 as %2" ).arg( layerProperty.geometryColName, QgsWkbTypes::displayString( layerProperty.type ) ); if ( layerProperty.srid >= 0 ) tip += tr( " (srid %1)" ).arg( layerProperty.srid ); @@ -396,8 +387,7 @@ QgsHanaLayerItem *QgsHanaSchemaItem::createLayer( const QgsHanaLayerProperty &la tip = tr( "as geometryless table" ); } - QgsHanaLayerItem *layerItem = new QgsHanaLayerItem( this, layerProperty.defaultName(), - mPath + '/' + layerProperty.tableName, layerType, layerProperty ); + QgsHanaLayerItem *layerItem = new QgsHanaLayerItem( this, layerProperty.defaultName(), mPath + '/' + layerProperty.tableName, layerType, layerProperty ); layerItem->setToolTip( tip ); return layerItem; } @@ -428,7 +418,8 @@ void QgsHanaRootItem::onConnectionsChanged() } QgsDataItem *QgsHanaDataItemProvider::createDataItem( - const QString &pathIn, QgsDataItem *parentItem ) + const QString &pathIn, QgsDataItem *parentItem +) { Q_UNUSED( pathIn ) return new QgsHanaRootItem( parentItem, QStringLiteral( "SAP HANA" ), QStringLiteral( "hana:" ) ); diff --git a/src/providers/hana/qgshanadataitems.h b/src/providers/hana/qgshanadataitems.h index 70272d1562c0..c68250e9ecec 100644 --- a/src/providers/hana/qgshanadataitems.h +++ b/src/providers/hana/qgshanadataitems.h @@ -70,8 +70,7 @@ class QgsHanaSchemaItem : public QgsDatabaseSchemaItem { Q_OBJECT public: - QgsHanaSchemaItem( QgsDataItem *parent, const QString &connectionName, const QString &name, - const QString &path ); + QgsHanaSchemaItem( QgsDataItem *parent, const QString &connectionName, const QString &name, const QString &path ); const QString &connectionName() const { return mConnectionName; } QVector createChildren() override; @@ -90,8 +89,7 @@ class QgsHanaLayerItem : public QgsLayerItem Q_OBJECT public: - QgsHanaLayerItem( QgsDataItem *parent, const QString &name, const QString &path, - Qgis::BrowserLayerType layerType, const QgsHanaLayerProperty &layerProperties ); + QgsHanaLayerItem( QgsDataItem *parent, const QString &name, const QString &path, Qgis::BrowserLayerType layerType, const QgsHanaLayerProperty &layerProperties ); QVector createChildren() override; diff --git a/src/providers/hana/qgshanadriver.cpp b/src/providers/hana/qgshanadriver.cpp index f7a49343ba42..31600aacb314 100644 --- a/src/providers/hana/qgshanadriver.cpp +++ b/src/providers/hana/qgshanadriver.cpp @@ -52,13 +52,13 @@ QgsHanaDriver::QgsHanaDriver() : mEnv( Environment::create() ) { QgsDebugCall; -#if defined(Q_OS_WIN) -#if defined(Q_OS_WIN64) +#if defined( Q_OS_WIN ) +#if defined( Q_OS_WIN64 ) mDriver = mEnv->isDriverInstalled( "HDBODBC" ) ? QStringLiteral( "HDBODBC" ) : QString(); #else mDriver = mEnv->isDriverInstalled( "HDBODBC32" ) ? QStringLiteral( "HDBODBC32" ) : QString(); #endif -#elif defined(Q_OS_MAC) +#elif defined( Q_OS_MAC ) mDriver = detectDriverPath( mEnv, QStringLiteral( "libodbcHDB.dylib" ), QStringLiteral( "/Applications/sap/hdbclient" ) ); #else mDriver = detectDriverPath( mEnv, QStringLiteral( "libodbcHDB.so" ), QStringLiteral( "/usr/sap/hdbclient" ) ); diff --git a/src/providers/hana/qgshanadriver.h b/src/providers/hana/qgshanadriver.h index 5776641ceb6e..89b9e067f3b0 100644 --- a/src/providers/hana/qgshanadriver.h +++ b/src/providers/hana/qgshanadriver.h @@ -44,4 +44,4 @@ class QgsHanaDriver QString mDriver; }; -#endif // QGSHANADRIVER_H +#endif // QGSHANADRIVER_H diff --git a/src/providers/hana/qgshanaexception.h b/src/providers/hana/qgshanaexception.h index 5bddd69835c0..df726f7a97bf 100644 --- a/src/providers/hana/qgshanaexception.h +++ b/src/providers/hana/qgshanaexception.h @@ -36,7 +36,7 @@ class QgsHanaException final : public QException QgsDebugError( what ); } - void raise() const override { throw *this; } + void raise() const override { throw *this; } QgsHanaException *clone() const override { @@ -52,4 +52,4 @@ class QgsHanaException final : public QException std::string mMessage; }; -#endif // QGSHANAEXCEPTION_H +#endif // QGSHANAEXCEPTION_H diff --git a/src/providers/hana/qgshanaexpressioncompiler.cpp b/src/providers/hana/qgshanaexpressioncompiler.cpp index d82819d927b0..69976f72226a 100644 --- a/src/providers/hana/qgshanaexpressioncompiler.cpp +++ b/src/providers/hana/qgshanaexpressioncompiler.cpp @@ -21,8 +21,7 @@ #include "qgslogger.h" QgsHanaExpressionCompiler::QgsHanaExpressionCompiler( QgsHanaFeatureSource *source, bool ignoreStaticNodes ) - : QgsSqlExpressionCompiler( source->mFields, QgsSqlExpressionCompiler::IntegerDivisionResultsInInteger | - QgsSqlExpressionCompiler::NoNullInBooleanLogic, ignoreStaticNodes ) + : QgsSqlExpressionCompiler( source->mFields, QgsSqlExpressionCompiler::IntegerDivisionResultsInInteger | QgsSqlExpressionCompiler::NoNullInBooleanLogic, ignoreStaticNodes ) , mGeometryColumn( source->mGeometryColumn ) { } @@ -38,8 +37,7 @@ QString QgsHanaExpressionCompiler::quotedValue( const QVariant &value, bool &ok return QgsHanaUtils::quotedValue( value ); } -static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP -{ +static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP { // mathematical functions { "sqrt", "SQRT" }, { "sign", "SIGN" }, @@ -83,24 +81,15 @@ QStringList QgsHanaExpressionCompiler::sqlArgumentsFromFunctionName( const QStri QStringList args( fnArgs ); if ( fnName == QLatin1String( "make_datetime" ) ) { - args = QStringList( QStringLiteral( "TO_TIMESTAMP('%1-%2-%3 %4:%5:%6', 'YYYY-MM-DD HH24:MI:SS')" ).arg( args[0].rightJustified( 4, '0' ) ) - .arg( args[1].rightJustified( 2, '0' ) ) - .arg( args[2].rightJustified( 2, '0' ) ) - .arg( args[3].rightJustified( 2, '0' ) ) - .arg( args[4].rightJustified( 2, '0' ) ) - .arg( args[5].rightJustified( 2, '0' ) ) ); + args = QStringList( QStringLiteral( "TO_TIMESTAMP('%1-%2-%3 %4:%5:%6', 'YYYY-MM-DD HH24:MI:SS')" ).arg( args[0].rightJustified( 4, '0' ) ).arg( args[1].rightJustified( 2, '0' ) ).arg( args[2].rightJustified( 2, '0' ) ).arg( args[3].rightJustified( 2, '0' ) ).arg( args[4].rightJustified( 2, '0' ) ).arg( args[5].rightJustified( 2, '0' ) ) ); } else if ( fnName == QLatin1String( "make_date" ) ) { - args = QStringList( QStringLiteral( "TO_DATE('%1-%2-%3', 'YYYY-MM-DD')" ).arg( args[0].rightJustified( 4, '0' ) ) - .arg( args[1].rightJustified( 2, '0' ) ) - .arg( args[2].rightJustified( 2, '0' ) ) ); + args = QStringList( QStringLiteral( "TO_DATE('%1-%2-%3', 'YYYY-MM-DD')" ).arg( args[0].rightJustified( 4, '0' ) ).arg( args[1].rightJustified( 2, '0' ) ).arg( args[2].rightJustified( 2, '0' ) ) ); } else if ( fnName == QLatin1String( "make_time" ) ) { - args = QStringList( QStringLiteral( "TO_TIME('%1:%2:%3', 'HH24:MI:SS') " ).arg( args[0].rightJustified( 2, '0' ) ) - .arg( args[1].rightJustified( 2, '0' ) ) - .arg( args[2].rightJustified( 2, '0' ) ) ); + args = QStringList( QStringLiteral( "TO_TIME('%1:%2:%3', 'HH24:MI:SS') " ).arg( args[0].rightJustified( 2, '0' ) ).arg( args[1].rightJustified( 2, '0' ) ).arg( args[2].rightJustified( 2, '0' ) ) ); } return args; } @@ -121,7 +110,8 @@ QString QgsHanaExpressionCompiler::castToText( const QString &value ) const } QgsSqlExpressionCompiler::Result QgsHanaExpressionCompiler::compileNode( - const QgsExpressionNode *node, QString &result ) + const QgsExpressionNode *node, QString &result +) { QgsSqlExpressionCompiler::Result staticRes = replaceNodeByStaticCachedValueIfPossible( node, result ); if ( staticRes != Fail ) @@ -208,8 +198,7 @@ QgsSqlExpressionCompiler::Result QgsHanaExpressionCompiler::compileNode( return Fail; // NULL can only be on the right for IS and IS NOT - if ( QLatin1String( "NULL" ) == opRight.toUpper() && - ( binOp->op() != QgsExpressionNodeBinaryOperator::boIs && binOp->op() != QgsExpressionNodeBinaryOperator::boIsNot ) ) + if ( QLatin1String( "NULL" ) == opRight.toUpper() && ( binOp->op() != QgsExpressionNodeBinaryOperator::boIs && binOp->op() != QgsExpressionNodeBinaryOperator::boIsNot ) ) return Fail; switch ( binOp->op() ) diff --git a/src/providers/hana/qgshanafeatureiterator.cpp b/src/providers/hana/qgshanafeatureiterator.cpp index 8b4b37118598..244907eb20c5 100644 --- a/src/providers/hana/qgshanafeatureiterator.cpp +++ b/src/providers/hana/qgshanafeatureiterator.cpp @@ -63,17 +63,17 @@ namespace { QString typeName = field.typeName(); QString fieldName = QgsHanaUtils::quotedIdentifier( field.name() ); - if ( field.type() == QMetaType::Type::QString && - ( typeName == QLatin1String( "ST_GEOMETRY" ) || typeName == QLatin1String( "ST_POINT" ) ) ) + if ( field.type() == QMetaType::Type::QString && ( typeName == QLatin1String( "ST_GEOMETRY" ) || typeName == QLatin1String( "ST_POINT" ) ) ) return QStringLiteral( "%1.ST_ASWKT()" ).arg( fieldName ); return fieldName; } -} +} // namespace QgsHanaFeatureIterator::QgsHanaFeatureIterator( QgsHanaFeatureSource *source, bool ownSource, - const QgsFeatureRequest &request ) + const QgsFeatureRequest &request +) : QgsAbstractFeatureIteratorFromSource( source, ownSource, request ) , mDatabaseVersion( source->mDatabaseVersion ) , mConnection( source->mUri ) @@ -197,7 +197,7 @@ bool QgsHanaFeatureIterator::fetchFeature( QgsFeature &feature ) QVariant v = mResultSet->getValue( paramIndex ); if ( !subsetOfAttributes || fetchAttributes.contains( idx ) ) feature.setAttribute( idx, v ); - fid = mSource->mPrimaryKeyCntx->lookupFid( QVariantList( { v} ) ); + fid = mSource->mPrimaryKeyCntx->lookupFid( QVariantList( { v } ) ); ++paramIndex; } break; @@ -268,14 +268,14 @@ bool QgsHanaFeatureIterator::nextFeatureFilterExpression( QgsFeature &feature ) return fetchFeature( feature ); } -QString QgsHanaFeatureIterator::getBBOXFilter( ) const +QString QgsHanaFeatureIterator::getBBOXFilter() const { if ( mDatabaseVersion.majorVersion() == 1 ) return QStringLiteral( "%1.ST_SRID(%2).ST_IntersectsRect(ST_GeomFromText(?, ?), ST_GeomFromText(?, ?)) = 1" ) - .arg( QgsHanaUtils::quotedIdentifier( mSource->mGeometryColumn ), QString::number( mSource->mSrid ) ); + .arg( QgsHanaUtils::quotedIdentifier( mSource->mGeometryColumn ), QString::number( mSource->mSrid ) ); else return QStringLiteral( "%1.ST_IntersectsRectPlanar(ST_GeomFromText(?, ?), ST_GeomFromText(?, ?)) = 1" ) - .arg( QgsHanaUtils::quotedIdentifier( mSource->mGeometryColumn ) ); + .arg( QgsHanaUtils::quotedIdentifier( mSource->mGeometryColumn ) ); } QgsRectangle QgsHanaFeatureIterator::getFilterRect() const @@ -352,8 +352,7 @@ QString QgsHanaFeatureIterator::buildSqlQuery( const QgsFeatureRequest &request limitAtProvider = false; bool subsetOfAttributes = mRequest.flags() & Qgis::FeatureRequestFlag::SubsetOfAttributes; - QgsAttributeIds attrIds = qgis::listToSet( subsetOfAttributes ? - request.subsetOfAttributes() : mSource->mFields.allAttributesList() ); + QgsAttributeIds attrIds = qgis::listToSet( subsetOfAttributes ? request.subsetOfAttributes() : mSource->mFields.allAttributesList() ); if ( subsetOfAttributes ) { @@ -387,9 +386,7 @@ QString QgsHanaFeatureIterator::buildSqlQuery( const QgsFeatureRequest &request mHasAttributes = !mAttributesToFetch.isEmpty(); // Add geometry column - if ( mSource->isSpatial() && - ( geometryRequested || ( request.filterType() == Qgis::FeatureRequestFilterType::Expression && - request.filterExpression()->needsGeometry() ) ) ) + if ( mSource->isSpatial() && ( geometryRequested || ( request.filterType() == Qgis::FeatureRequestFilterType::Expression && request.filterExpression()->needsGeometry() ) ) ) { sqlFields += QgsHanaUtils::quotedIdentifier( mSource->mGeometryColumn ); mHasGeometryColumn = true; @@ -449,7 +446,9 @@ QString QgsHanaFeatureIterator::buildSqlQuery( const QgsFeatureRequest &request break; case QgsSqlExpressionCompiler::Result::Fail: QgsDebugError( QStringLiteral( "Unable to compile filter expression: '%1'" ) - .arg( request.filterExpression()->expression() ).toStdString().c_str() ); + .arg( request.filterExpression()->expression() ) + .toStdString() + .c_str() ); break; case QgsSqlExpressionCompiler::Result::None: break; @@ -466,9 +465,7 @@ QString QgsHanaFeatureIterator::buildSqlQuery( const QgsFeatureRequest &request } } - QString sql = QStringLiteral( "SELECT %1 FROM %2" ).arg( - sqlFields.isEmpty() ? QStringLiteral( "*" ) : sqlFields.join( ',' ), - mSource->mQuery ); + QString sql = QStringLiteral( "SELECT %1 FROM %2" ).arg( sqlFields.isEmpty() ? QStringLiteral( "*" ) : sqlFields.join( ',' ), mSource->mQuery ); if ( !sqlFilter.isEmpty() ) sql += QStringLiteral( " WHERE (%1)" ).arg( sqlFilter.join( QLatin1String( ") AND (" ) ) ); @@ -484,13 +481,13 @@ QString QgsHanaFeatureIterator::buildSqlQuery( const QgsFeatureRequest &request return sql; } -QVariantList QgsHanaFeatureIterator::buildSqlQueryParameters( ) const +QVariantList QgsHanaFeatureIterator::buildSqlQueryParameters() const { if ( !( mFilterRect.isNull() || mFilterRect.isEmpty() ) && mSource->isSpatial() && mHasGeometryColumn ) { QgsRectangle filterRect = getFilterRect(); - QString ll = QStringLiteral( "POINT(%1 %2)" ).arg( QString::number( filterRect.xMinimum() ), QString::number( filterRect.yMinimum() ) ); - QString ur = QStringLiteral( "POINT(%1 %2)" ).arg( QString::number( filterRect.xMaximum() ), QString::number( filterRect.yMaximum() ) ); + QString ll = QStringLiteral( "POINT(%1 %2)" ).arg( QString::number( filterRect.xMinimum() ), QString::number( filterRect.yMinimum() ) ); + QString ur = QStringLiteral( "POINT(%1 %2)" ).arg( QString::number( filterRect.xMaximum() ), QString::number( filterRect.yMaximum() ) ); return { ll, mSource->mSrid, ur, mSource->mSrid }; } return QVariantList(); diff --git a/src/providers/hana/qgshanafeatureiterator.h b/src/providers/hana/qgshanafeatureiterator.h index ad29c77a564e..4d4ffac235f7 100644 --- a/src/providers/hana/qgshanafeatureiterator.h +++ b/src/providers/hana/qgshanafeatureiterator.h @@ -62,7 +62,8 @@ class QgsHanaFeatureIterator : public QgsAbstractFeatureIteratorFromSource &orderBys ) override; QString buildSqlQuery( const QgsFeatureRequest &request ); - QVariantList buildSqlQueryParameters( ) const; + QVariantList buildSqlQueryParameters() const; QString getBBOXFilter() const; QgsRectangle getFilterRect() const; @@ -89,7 +90,7 @@ class QgsHanaFeatureIterator : public QgsAbstractFeatureIteratorFromSource mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; QgsAttributeList mAttributesToFetch; QgsCoordinateTransform mTransform; bool mHasAttributes = false; diff --git a/src/providers/hana/qgshananewconnection.cpp b/src/providers/hana/qgshananewconnection.cpp index 5b54672eff17..809ddbb3a5f4 100644 --- a/src/providers/hana/qgshananewconnection.cpp +++ b/src/providers/hana/qgshananewconnection.cpp @@ -37,12 +37,13 @@ namespace { return ( input.isEmpty() || QString( input ).replace( ' ', QString() ).isEmpty() ); } -} +} // namespace QgsHanaNewConnection::QgsHanaNewConnection( QWidget *parent, const QString &connName, - Qt::WindowFlags fl ) + Qt::WindowFlags fl +) : QDialog( parent, fl ) , mOriginalConnName( connName ) { @@ -109,8 +110,7 @@ void QgsHanaNewConnection::accept() { if ( isStringEmpty( txtName->text() ) ) { - QMessageBox::warning( this, - tr( "Save Connection" ), tr( "Connection name cannot be empty." ), QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Save Connection" ), tr( "Connection name cannot be empty." ), QMessageBox::Ok ); return; } @@ -119,15 +119,13 @@ void QgsHanaNewConnection::accept() case QgsHanaConnectionType::HostPort: if ( isStringEmpty( txtDriver->text() ) ) { - QMessageBox::warning( this, - tr( "Save Connection" ), tr( "Driver field cannot be empty." ), QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Save Connection" ), tr( "Driver field cannot be empty." ), QMessageBox::Ok ); return; } if ( isStringEmpty( txtHost->text() ) ) { - QMessageBox::warning( this, - tr( "Save Connection" ), tr( "Host field cannot be empty." ), QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Save Connection" ), tr( "Host field cannot be empty." ), QMessageBox::Ok ); return; } @@ -135,8 +133,7 @@ void QgsHanaNewConnection::accept() { if ( isStringEmpty( txtTenantDatabaseName->text() ) ) { - QMessageBox::warning( this, - tr( "Save Connection" ), tr( "Tenant database name cannot be empty." ), QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Save Connection" ), tr( "Tenant database name cannot be empty." ), QMessageBox::Ok ); return; } } @@ -144,8 +141,7 @@ void QgsHanaNewConnection::accept() case QgsHanaConnectionType::Dsn: if ( cmbDsn->count() == 0 ) { - QMessageBox::warning( this, - tr( "Save Connection" ), tr( "DSN field cannot be empty." ), QMessageBox::Ok ); + QMessageBox::warning( this, tr( "Save Connection" ), tr( "DSN field cannot be empty." ), QMessageBox::Ok ); return; } @@ -156,24 +152,20 @@ void QgsHanaNewConnection::accept() QgsHanaSettings::setSelectedConnection( connName ); const bool hasAuthConfigID = !mAuthSettings->configId().isEmpty(); - if ( !hasAuthConfigID && mAuthSettings->storePasswordIsChecked() && - QMessageBox::question( this, - tr( "Saving Passwords" ), - tr( "WARNING: You have opted to save your password. It will be stored in unsecured " - "plain text in your project files and in your home directory (Unix-like OS) or user profile (Windows). " - "If you want to avoid this, press Cancel and either:\n\na) Don't save a password in the connection " - "settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your " - "credentials in an HTTP Basic Authentication method and store them in an encrypted database." ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( !hasAuthConfigID && mAuthSettings->storePasswordIsChecked() && QMessageBox::question( this, tr( "Saving Passwords" ), tr( "WARNING: You have opted to save your password. It will be stored in unsecured " + "plain text in your project files and in your home directory (Unix-like OS) or user profile (Windows). " + "If you want to avoid this, press Cancel and either:\n\na) Don't save a password in the connection " + "settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your " + "credentials in an HTTP Basic Authentication method and store them in an encrypted database." ), + QMessageBox::Ok | QMessageBox::Cancel ) + == QMessageBox::Cancel ) { return; } QgsHanaSettings settings( connName, true ); // warn if entry was renamed to an existing connection - if ( ( !mOriginalConnName.isNull() && mOriginalConnName.compare( connName, Qt::CaseInsensitive ) != 0 ) && - QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection %1 be overwritten?" ).arg( connName ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( ( !mOriginalConnName.isNull() && mOriginalConnName.compare( connName, Qt::CaseInsensitive ) != 0 ) && QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection %1 be overwritten?" ).arg( connName ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; } @@ -184,9 +176,9 @@ void QgsHanaNewConnection::accept() readSettingsFromControls( settings ); if ( !mAuthSettings->storeUsernameIsChecked() ) - settings.setUserName( QString( ) ); + settings.setUserName( QString() ); if ( !( mAuthSettings->storePasswordIsChecked() && !hasAuthConfigID ) ) - settings.setPassword( QString( ) ); + settings.setPassword( QString() ); settings.setSaveUserName( mAuthSettings->storeUsernameIsChecked() ); settings.setSavePassword( mAuthSettings->storePasswordIsChecked() && !hasAuthConfigID ); @@ -396,8 +388,7 @@ void QgsHanaNewConnection::resizeEvent( QResizeEvent * ) void QgsHanaNewConnection::resizeWidgets() { - auto resizeLayout = []( QLayout * layout ) - { + auto resizeLayout = []( QLayout *layout ) { QWidget *widget = layout->parentWidget(); widget->adjustSize(); widget->resize( widget->parentWidget()->width(), widget->height() ); @@ -426,8 +417,7 @@ void QgsHanaNewConnection::testConnection() case QgsHanaConnectionType::HostPort: if ( txtHost->text().isEmpty() ) warningMsg = tr( "Host name has not been specified." ); - else if ( rbtnMultipleContainers->isChecked() && rbtnTenantDatabase->isChecked() && - txtTenantDatabaseName->text().isEmpty() ) + else if ( rbtnMultipleContainers->isChecked() && rbtnTenantDatabase->isChecked() && txtTenantDatabaseName->text().isEmpty() ) warningMsg = tr( "Database has not been specified." ); else if ( txtIdentifier->text().isEmpty() ) warningMsg = tr( "Identifier has not been specified." ); @@ -440,7 +430,7 @@ void QgsHanaNewConnection::testConnection() { if ( !QgsHanaDriver::isInstalled( driver ) ) { -#if defined(Q_OS_WIN) +#if defined( Q_OS_WIN ) warningMsg = tr( "Driver with name '%1' is not installed." ).arg( driver ); #else if ( !QgsHanaDriver::isValidPath( driver ) ) @@ -498,7 +488,7 @@ QString QgsHanaNewConnection::getDatabaseName() const return QStringLiteral( "SYSTEMDB" ); } else - return QString( ); + return QString(); } void QgsHanaNewConnection::showHelp() diff --git a/src/providers/hana/qgshananewconnection.h b/src/providers/hana/qgshananewconnection.h index cdc415f0ee09..f98efed2b598 100644 --- a/src/providers/hana/qgshananewconnection.h +++ b/src/providers/hana/qgshananewconnection.h @@ -35,7 +35,8 @@ class QgsHanaNewConnection : public QDialog, private Ui::QgsHanaNewConnectionBas QgsHanaNewConnection( QWidget *parent = nullptr, const QString &connName = QString(), - Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); + Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags + ); void resizeEvent( QResizeEvent *ev ) override; diff --git a/src/providers/hana/qgshanaprimarykeys.cpp b/src/providers/hana/qgshanaprimarykeys.cpp index 2343f059410d..a0b4893dc1fd 100644 --- a/src/providers/hana/qgshanaprimarykeys.cpp +++ b/src/providers/hana/qgshanaprimarykeys.cpp @@ -38,7 +38,7 @@ namespace { return x <= ( ( INT32PK_OFFSET ) / 2 ) ? x : -( INT32PK_OFFSET - x ); } -} +} // namespace QgsFeatureId QgsHanaPrimaryKeyContext::lookupFid( const QVariantList &v ) { @@ -59,7 +59,7 @@ QVariantList QgsHanaPrimaryKeyContext::removeFid( QgsFeatureId fid ) { const QMutexLocker locker( &mMutex ); - QVariantList v = mFidToKey[ fid ]; + QVariantList v = mFidToKey[fid]; mFidToKey.remove( fid ); mKeyToFid.remove( v ); return v; @@ -142,15 +142,14 @@ QgsHanaPrimaryKeyType QgsHanaPrimaryKeyUtils::getPrimaryKeyType( const QgsField } } -QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFields &fields, QgsHanaPrimaryKeyType pkType, - const QList &pkAttrs ) +QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFields &fields, QgsHanaPrimaryKeyType pkType, const QList &pkAttrs ) { switch ( pkType ) { case PktInt: case PktInt64: { - const QString columnName = fields.at( pkAttrs[0] ).name() ; + const QString columnName = fields.at( pkAttrs[0] ).name(); return QStringLiteral( "%1=?" ).arg( QgsHanaUtils::quotedIdentifier( columnName ) ); } case PktFidMap: @@ -167,8 +166,7 @@ QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFields &fields, QgsHa return QString(); //avoid warning } -QString QgsHanaPrimaryKeyUtils::buildWhereClause( QgsFeatureId featureId, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, - const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ) +QString QgsHanaPrimaryKeyUtils::buildWhereClause( QgsFeatureId featureId, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ) { switch ( pkType ) { @@ -199,7 +197,7 @@ QString QgsHanaPrimaryKeyUtils::buildWhereClause( QgsFeatureId featureId, const QStringList conditions; for ( int i = 0; i < pkAttrs.size(); i++ ) { - const QgsField &field = fields.at( pkAttrs[i] ); + const QgsField &field = fields.at( pkAttrs[i] ); conditions << QStringLiteral( "%1=%2" ).arg( QgsHanaUtils::quotedIdentifier( field.name() ), QgsHanaUtils::toConstant( pkValues[i], field.type() ) ); } return conditions.join( QLatin1String( " AND " ) ); @@ -211,8 +209,7 @@ QString QgsHanaPrimaryKeyUtils::buildWhereClause( QgsFeatureId featureId, const return QString(); // avoid warning } -QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFeatureIds &featureIds, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, - const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ) +QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFeatureIds &featureIds, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ) { if ( featureIds.isEmpty() ) return QString(); @@ -236,7 +233,7 @@ QString QgsHanaPrimaryKeyUtils::buildWhereClause( const QgsFeatureIds &featureId } } - const QgsField &field = fields.at( pkAttrs[0] ); + const QgsField &field = fields.at( pkAttrs[0] ); return QStringLiteral( "%1 IN (%2)" ).arg( QgsHanaUtils::quotedIdentifier( field.name() ), fids.join( ',' ) ); } case PktFidMap: diff --git a/src/providers/hana/qgshanaprimarykeys.h b/src/providers/hana/qgshanaprimarykeys.h index 6469060f9ca2..a9caa7f4770f 100644 --- a/src/providers/hana/qgshanaprimarykeys.h +++ b/src/providers/hana/qgshanaprimarykeys.h @@ -45,9 +45,9 @@ class QgsHanaPrimaryKeyContext protected: QMutex mMutex; //!< Access to all data members is guarded by the mutex - QgsFeatureId mFidCounter = 0; // next feature id if map is used - QMap mKeyToFid; // map key values to feature id - QMap mFidToKey; // map feature id back to key values + QgsFeatureId mFidCounter = 0; // next feature id if map is used + QMap mKeyToFid; // map key values to feature id + QMap mFidToKey; // map feature id back to key values }; class QgsHanaPrimaryKeyUtils @@ -60,12 +60,9 @@ class QgsHanaPrimaryKeyUtils static int fidToInt( QgsFeatureId id ); static QgsFeatureId intToFid( int id ); static QgsHanaPrimaryKeyType getPrimaryKeyType( const QgsField &field ); - static QString buildWhereClause( const QgsFields &fields, QgsHanaPrimaryKeyType pkType, - const QList &pkAttrs ); - static QString buildWhereClause( QgsFeatureId featureId, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, - const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ); - static QString buildWhereClause( const QgsFeatureIds &featureIds, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, - const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ); + static QString buildWhereClause( const QgsFields &fields, QgsHanaPrimaryKeyType pkType, const QList &pkAttrs ); + static QString buildWhereClause( QgsFeatureId featureId, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ); + static QString buildWhereClause( const QgsFeatureIds &featureIds, const QgsFields &fields, QgsHanaPrimaryKeyType pkType, const QList &pkAttrs, QgsHanaPrimaryKeyContext &primaryKeyCntx ); static QString buildUriKey( const QStringList &columns ); static QStringList parseUriKey( const QString &key ); }; diff --git a/src/providers/hana/qgshanaprovider.cpp b/src/providers/hana/qgshanaprovider.cpp index ed4d3c00ade5..e66135b34f2b 100644 --- a/src/providers/hana/qgshanaprovider.cpp +++ b/src/providers/hana/qgshanaprovider.cpp @@ -62,11 +62,11 @@ namespace QString sql = QStringLiteral( "SELECT %1 FROM %2" ).arg( columns, source ); if ( !where.isEmpty() ) - sql += QStringLiteral( " WHERE " ) + where; + sql += QStringLiteral( " WHERE " ) + where; if ( !orderBy.isEmpty() ) - sql += QStringLiteral( " ORDER BY " ) + orderBy; + sql += QStringLiteral( " ORDER BY " ) + orderBy; if ( limit >= 0 ) - sql += QStringLiteral( " LIMIT " ) + QString::number( limit ); + sql += QStringLiteral( " LIMIT " ) + QString::number( limit ); return sql; } @@ -78,13 +78,13 @@ namespace return; sql = QStringLiteral( "SELECT COUNT(*) FROM SYS.ST_UNITS_OF_MEASURE WHERE UNIT_NAME = ?" ); - numUnits = conn.executeCountQuery( sql, { name} ); + numUnits = conn.executeCountQuery( sql, { name } ); if ( numUnits > 0 ) throw QgsHanaException( QObject::tr( "Unable to create a new unit of measure. " - "Unit of measure with name '%1' and different type already exist." ).arg( name ) ); + "Unit of measure with name '%1' and different type already exist." ) + .arg( name ) ); - sql = QStringLiteral( "CREATE SPATIAL UNIT OF MEASURE %1 TYPE %2 CONVERT USING %3" ).arg( - QgsHanaUtils::quotedIdentifier( name ), type, QString::number( conversionFactor ) ); + sql = QStringLiteral( "CREATE SPATIAL UNIT OF MEASURE %1 TYPE %2 CONVERT USING %3" ).arg( QgsHanaUtils::quotedIdentifier( name ), type, QString::number( conversionFactor ) ); conn.execute( sql ); } @@ -108,14 +108,12 @@ namespace QgsRectangle bounds = ct.transformBoundingBox( srs.bounds() ); QString linearUnits = srs.isGeographic() ? QStringLiteral( "NULL" ) : QgsHanaUtils::quotedIdentifier( units ); - QString angularUnits = srs.isGeographic() ? QgsHanaUtils::quotedIdentifier( units ) : QStringLiteral( "NULL" ) ; + QString angularUnits = srs.isGeographic() ? QgsHanaUtils::quotedIdentifier( units ) : QStringLiteral( "NULL" ); QString xRange = QStringLiteral( "%1 BETWEEN %2 AND %3" ) - .arg( ( srs.isGeographic() ? QStringLiteral( "LONGITUDE" ) : QStringLiteral( "X" ) ), - QString::number( bounds.xMinimum() ), QString::number( bounds.xMaximum() ) ); + .arg( ( srs.isGeographic() ? QStringLiteral( "LONGITUDE" ) : QStringLiteral( "X" ) ), QString::number( bounds.xMinimum() ), QString::number( bounds.xMaximum() ) ); QString yRange = QStringLiteral( "%1 BETWEEN %2 AND %3" ) - .arg( ( srs.isGeographic() ? QStringLiteral( "LATITUDE" ) : QStringLiteral( "Y" ) ), - QString::number( bounds.yMinimum() ), QString::number( bounds.yMaximum() ) ); + .arg( ( srs.isGeographic() ? QStringLiteral( "LATITUDE" ) : QStringLiteral( "Y" ) ), QString::number( bounds.yMinimum() ), QString::number( bounds.yMaximum() ) ); // create new spatial reference system QString sql = QStringLiteral( "CREATE SPATIAL REFERENCE SYSTEM %1 " @@ -128,15 +126,8 @@ namespace "ORGANIZATION %8 IDENTIFIED BY %9 " "DEFINITION %10 " "TRANSFORM DEFINITION %11" ) - .arg( QgsHanaUtils::quotedIdentifier( srs.description() ), - QString::number( srid ), - linearUnits, - angularUnits, - srs.isGeographic() ? QStringLiteral( "ROUND EARTH" ) : QStringLiteral( "PLANAR" ), - xRange, yRange, - QgsHanaUtils::quotedIdentifier( authName ), QString::number( srid ) ) - .arg( QgsHanaUtils::quotedString( srs.toWkt() ), - QgsHanaUtils::quotedString( srs.toProj() ) ); + .arg( QgsHanaUtils::quotedIdentifier( srs.description() ), QString::number( srid ), linearUnits, angularUnits, srs.isGeographic() ? QStringLiteral( "ROUND EARTH" ) : QStringLiteral( "PLANAR" ), xRange, yRange, QgsHanaUtils::quotedIdentifier( authName ), QString::number( srid ) ) + .arg( QgsHanaUtils::quotedString( srs.toWkt() ), QgsHanaUtils::quotedString( srs.toProj() ) ); QString errorMessage; conn.execute( sql, &errorMessage ); @@ -152,11 +143,10 @@ namespace { QgsField field = fields.at( index ); const QgsFieldConstraints &constraints = field.constraints(); - if ( constraints.constraintOrigin( QgsFieldConstraints::ConstraintNotNull ) == QgsFieldConstraints::ConstraintOriginProvider && - constraints.constraintOrigin( QgsFieldConstraints::ConstraintUnique ) == QgsFieldConstraints::ConstraintOriginProvider ) + if ( constraints.constraintOrigin( QgsFieldConstraints::ConstraintNotNull ) == QgsFieldConstraints::ConstraintOriginProvider && constraints.constraintOrigin( QgsFieldConstraints::ConstraintUnique ) == QgsFieldConstraints::ConstraintOriginProvider ) { if ( QgsHanaUtils::convertField( field ) ) - return qMakePair( field.name(), field.typeName() ); + return qMakePair( field.name(), field.typeName() ); } } @@ -173,7 +163,7 @@ namespace bool isSrsRoundEarth( QgsHanaConnection &conn, int srsId ) { QString sql = QStringLiteral( "SELECT ROUND_EARTH FROM SYS.ST_SPATIAL_REFERENCE_SYSTEMS WHERE SRS_ID = ?" ); - QVariant roundEarth = conn.executeScalar( sql, { srsId} ); + QVariant roundEarth = conn.executeScalar( sql, { srsId } ); return roundEarth.toString() == QLatin1String( "TRUE" ); } @@ -181,7 +171,8 @@ namespace PreparedStatementRef &stmt, unsigned short paramIndex, const AttributeField &field, - const QVariant &value ) + const QVariant &value + ) { bool isNull = ( value.isNull() || !value.isValid() ); @@ -261,8 +252,7 @@ namespace QDateTime dt = value.toDateTime(); QDate d = dt.date(); QTime t = dt.time(); - stmt->setTimestamp( paramIndex, makeNullable( d.year(), - d.month(), d.day(), t.hour(), t.minute(), t.second(), t.msec() ) ); + stmt->setTimestamp( paramIndex, makeNullable( d.year(), d.month(), d.day(), t.hour(), t.minute(), t.second(), t.msec() ) ); } break; case QgsHanaDataType::Char: @@ -303,7 +293,7 @@ namespace break; default: QgsDebugError( QStringLiteral( "Unknown value type ('%1') for parameter %2" ) - .arg( QString::number( static_cast( field.type ) ), QString::number( paramIndex ) ) ); + .arg( QString::number( static_cast( field.type ) ), QString::number( paramIndex ) ) ); break; } } @@ -315,7 +305,8 @@ namespace QgsHanaPrimaryKeyType pkType, const QList &pkAttrs, QgsHanaPrimaryKeyContext &pkContext, - QgsFeatureId featureId ) + QgsFeatureId featureId + ) { switch ( pkType ) { @@ -350,7 +341,7 @@ namespace break; } } -} +} // namespace static const size_t MAXIMUM_BATCH_DATA_SIZE = 4 * 1024 * 1024; @@ -359,7 +350,8 @@ const QString QgsHanaProvider::HANA_DESCRIPTION = QStringLiteral( "SAP HANA spat QgsHanaProvider::QgsHanaProvider( const QString &uri, - const ProviderOptions &options, Qgis::DataProviderReadFlags flags ) + const ProviderOptions &options, Qgis::DataProviderReadFlags flags +) : QgsVectorDataProvider( uri, options, flags ) , mUri( uri ) , mFeaturesCount( -1 ) @@ -375,8 +367,7 @@ QgsHanaProvider::QgsHanaProvider( mHasSrsPlanarEquivalent = false; mUseEstimatedMetadata = mUri.useEstimatedMetadata(); - auto appendError = [this]( const QString & message ) - { + auto appendError = [this]( const QString &message ) { this->appendError( QgsErrorMessage( message, QStringLiteral( "SAP HANA" ) ) ); }; @@ -403,8 +394,9 @@ QgsHanaProvider::QgsHanaProvider( mIsQuery = false; mQuerySource = QStringLiteral( "%1.%2" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), - QgsHanaUtils::quotedIdentifier( mTableName ) ); + QgsHanaUtils::quotedIdentifier( mSchemaName ), + QgsHanaUtils::quotedIdentifier( mTableName ) + ); } try @@ -453,9 +445,7 @@ Qgis::VectorProviderCapabilities QgsHanaProvider::capabilities() const auto capabilities = mCapabilities; if ( mPrimaryKeyAttrs.isEmpty() ) - capabilities &= ~( Qgis::VectorProviderCapability::DeleteFeatures - | Qgis::VectorProviderCapability::ChangeAttributeValues - | Qgis::VectorProviderCapability::ChangeFeatures ); + capabilities &= ~( Qgis::VectorProviderCapability::DeleteFeatures | Qgis::VectorProviderCapability::ChangeAttributeValues | Qgis::VectorProviderCapability::ChangeFeatures ); return capabilities; } @@ -518,7 +508,7 @@ QVariant QgsHanaProvider::minimumValue( int index ) const QgsHanaConnectionRef conn = createConnection(); if ( !conn.isNull() ) { - QString sql = buildQuery( QStringLiteral( "MIN(%1)" ).arg( QgsHanaUtils::quotedIdentifier( mAttributeFields[ index ].name ) ) ); + QString sql = buildQuery( QStringLiteral( "MIN(%1)" ).arg( QgsHanaUtils::quotedIdentifier( mAttributeFields[index].name ) ) ); try { @@ -529,7 +519,7 @@ QVariant QgsHanaProvider::minimumValue( int index ) const pushError( tr( "Failed to retrieve minimum value: %1" ).arg( ex.what() ) ); } } - return QVariant( ); + return QVariant(); } // Returns the maximum value of an attribute @@ -541,7 +531,7 @@ QVariant QgsHanaProvider::maximumValue( int index ) const QgsHanaConnectionRef conn = createConnection(); if ( !conn.isNull() ) { - QString sql = buildQuery( QStringLiteral( "MAX(%1)" ).arg( QgsHanaUtils::quotedIdentifier( mAttributeFields[ index ].name ) ) ); + QString sql = buildQuery( QStringLiteral( "MAX(%1)" ).arg( QgsHanaUtils::quotedIdentifier( mAttributeFields[index].name ) ) ); try { return conn->executeScalar( sql ); @@ -551,7 +541,7 @@ QVariant QgsHanaProvider::maximumValue( int index ) const pushError( tr( "Failed to retrieve maximum value: %1" ).arg( ex.what() ) ); } } - return QVariant( ); + return QVariant(); } // Returns the list of unique values of an attribute @@ -564,12 +554,8 @@ QSet QgsHanaProvider::uniqueValues( int index, int limit ) const QgsHanaConnectionRef conn = createConnection(); if ( !conn.isNull() ) { - QString fieldName = mAttributeFields[ index ].name; - QString sql = buildQuery( QStringLiteral( "DISTINCT %1" ).arg( - QgsHanaUtils::quotedIdentifier( fieldName ) ), - mQueryWhereClause, - QgsHanaUtils::quotedIdentifier( fieldName ), - limit ); + QString fieldName = mAttributeFields[index].name; + QString sql = buildQuery( QStringLiteral( "DISTINCT %1" ).arg( QgsHanaUtils::quotedIdentifier( fieldName ) ), mQueryWhereClause, QgsHanaUtils::quotedIdentifier( fieldName ), limit ); try { @@ -706,9 +692,7 @@ bool QgsHanaProvider::addFeatures( QgsFeatureList &flist, Flags flags ) } const bool allowBatchInserts = ( flags & QgsFeatureSink::FastInsert ); - const QString sql = QStringLiteral( "INSERT INTO %1.%2(%3) VALUES (%4)" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), - columnNames.join( QLatin1Char( ',' ) ), values.join( QLatin1Char( ',' ) ) ); + const QString sql = QStringLiteral( "INSERT INTO %1.%2(%3) VALUES (%4)" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), columnNames.join( QLatin1Char( ',' ) ), values.join( QLatin1Char( ',' ) ) ); try { @@ -717,7 +701,7 @@ bool QgsHanaProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( !allowBatchInserts ) { QString sqlIdentity = QStringLiteral( "SELECT CURRENT_IDENTITY_VALUE() \"current identity value\" FROM %1.%2" ) - .arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ) ); + .arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ) ); stmtIdentityValue = conn->prepareStatement( sqlIdentity ); } @@ -733,7 +717,9 @@ bool QgsHanaProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( isPointDataType && geom.wkbType() != wkbType() ) { throw QgsHanaException( tr( "Could not add feature with geometry type %1 to layer of type %2" ) - .arg( QgsWkbTypes::displayString( geom.wkbType() ), QgsWkbTypes::displayString( wkbType() ) ).toStdString().c_str() ); + .arg( QgsWkbTypes::displayString( geom.wkbType() ), QgsWkbTypes::displayString( wkbType() ) ) + .toStdString() + .c_str() ); } QByteArray wkb = geom.asWkb(); @@ -822,7 +808,7 @@ bool QgsHanaProvider::addFeatures( QgsFeatureList &flist, Flags flags ) catch ( const exception &ex ) { pushError( tr( "Failed to add features: %1" ) - .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); + .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); conn->rollback(); } @@ -854,9 +840,7 @@ bool QgsHanaProvider::deleteFeatures( const QgsFeatureIds &ids ) return false; } - const QString sql = QStringLiteral( "DELETE FROM %1.%2 WHERE %3" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), - featureIdsWhereClause ); + const QString sql = QStringLiteral( "DELETE FROM %1.%2 WHERE %3" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), featureIdsWhereClause ); try { @@ -887,8 +871,7 @@ bool QgsHanaProvider::truncate() if ( conn.isNull() ) return false; - QString sql = QStringLiteral( "TRUNCATE TABLE %1.%2" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ) ); + QString sql = QStringLiteral( "TRUNCATE TABLE %1.%2" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ) ); try { @@ -926,8 +909,7 @@ bool QgsHanaProvider::addAttributes( const QList &attributes ) columnDefs += QStringLiteral( " COMMENT " ) + QgsHanaUtils::quotedString( field.comment() ); } - QString sql = QStringLiteral( "ALTER TABLE %1.%2 ADD (%3)" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), columnDefs ); + QString sql = QStringLiteral( "ALTER TABLE %1.%2 ADD (%3)" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), columnDefs ); try { @@ -948,7 +930,7 @@ bool QgsHanaProvider::addAttributes( const QList &attributes ) catch ( const exception &ex ) { pushError( tr( "Failed to read attributes: %1" ) - .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); + .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); } return true; @@ -969,11 +951,10 @@ bool QgsHanaProvider::deleteAttributes( const QgsAttributeIds &attributes ) if ( !columnNames.isEmpty() ) columnNames += QLatin1Char( ',' ); const AttributeField &field = mAttributeFields.at( attrId ); - columnNames += QgsHanaUtils::quotedIdentifier( field.name ); + columnNames += QgsHanaUtils::quotedIdentifier( field.name ); } - QString sql = QStringLiteral( "ALTER TABLE %1.%2 DROP (%3)" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), columnNames ); + QString sql = QStringLiteral( "ALTER TABLE %1.%2 DROP (%3)" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), columnNames ); try { @@ -983,7 +964,7 @@ bool QgsHanaProvider::deleteAttributes( const QgsAttributeIds &attributes ) catch ( const QgsHanaException &ex ) { pushError( tr( "Failed to delete attributes: %1" ) - .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); + .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); conn->rollback(); return false; } @@ -995,7 +976,7 @@ bool QgsHanaProvider::deleteAttributes( const QgsAttributeIds &attributes ) catch ( const exception &ex ) { pushError( tr( "Failed to read attributes: %1" ) - .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); + .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); } return true; @@ -1025,7 +1006,7 @@ bool QgsHanaProvider::renameAttributes( const QgsFieldNameMap &fieldMap ) if ( fromName == toName ) continue; - renameCandidates.insert( {fromName, toName} ); + renameCandidates.insert( { fromName, toName } ); } if ( renameCandidates.empty() ) @@ -1041,7 +1022,7 @@ bool QgsHanaProvider::renameAttributes( const QgsFieldNameMap &fieldMap ) while ( !renameCandidates.empty() ) { bool found = false; - for ( const QPair &candidate : std::as_const( renameCandidates ) ) + for ( const QPair &candidate : std::as_const( renameCandidates ) ) { if ( resultFieldNames.contains( candidate.first ) && !resultFieldNames.contains( candidate.second ) ) { @@ -1064,12 +1045,9 @@ bool QgsHanaProvider::renameAttributes( const QgsFieldNameMap &fieldMap ) try { - for ( const QPair &kv : std::as_const( fieldsToRename ) ) + for ( const QPair &kv : std::as_const( fieldsToRename ) ) { - QString sql = QStringLiteral( "RENAME COLUMN %1.%2.%3 TO %4" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), - QgsHanaUtils::quotedIdentifier( kv.first ), - QgsHanaUtils::quotedIdentifier( kv.second ) ); + QString sql = QStringLiteral( "RENAME COLUMN %1.%2.%3 TO %4" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), QgsHanaUtils::quotedIdentifier( kv.first ), QgsHanaUtils::quotedIdentifier( kv.second ) ); conn->execute( sql ); } @@ -1099,7 +1077,7 @@ bool QgsHanaProvider::changeGeometryValues( const QgsGeometryMap &geometryMap ) if ( geometryMap.isEmpty() ) return true; - if ( mIsQuery || mGeometryColumn.isEmpty() || mPrimaryKeyAttrs.isEmpty() ) + if ( mIsQuery || mGeometryColumn.isEmpty() || mPrimaryKeyAttrs.isEmpty() ) return false; QgsHanaConnectionRef conn = createConnection(); @@ -1107,10 +1085,7 @@ bool QgsHanaProvider::changeGeometryValues( const QgsGeometryMap &geometryMap ) return false; QString fidWhereClause = QgsHanaPrimaryKeyUtils::buildWhereClause( mFields, mPrimaryKeyType, mPrimaryKeyAttrs ); - QString sql = QStringLiteral( "UPDATE %1.%2 SET %3 = ST_GeomFromWKB(?, %4) WHERE %5" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), - QgsHanaUtils::quotedIdentifier( mGeometryColumn ), QString::number( mSrid ), - fidWhereClause ); + QString sql = QStringLiteral( "UPDATE %1.%2 SET %3 = ST_GeomFromWKB(?, %4) WHERE %5" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), QgsHanaUtils::quotedIdentifier( mGeometryColumn ), QString::number( mSrid ), fidWhereClause ); try { @@ -1140,7 +1115,7 @@ bool QgsHanaProvider::changeGeometryValues( const QgsGeometryMap &geometryMap ) catch ( const exception &ex ) { pushError( tr( "Failed to change feature geometry: %1" ) - .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); + .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); conn->rollback(); return false; } @@ -1148,8 +1123,7 @@ bool QgsHanaProvider::changeGeometryValues( const QgsGeometryMap &geometryMap ) return true; } -bool QgsHanaProvider::changeFeatures( const QgsChangedAttributesMap &attrMap, - const QgsGeometryMap &geometryMap ) +bool QgsHanaProvider::changeFeatures( const QgsChangedAttributesMap &attrMap, const QgsGeometryMap &geometryMap ) { bool ret = changeAttributeValues( attrMap ); if ( ret ) @@ -1196,8 +1170,7 @@ bool QgsHanaProvider::changeAttributeValues( const QgsChangedAttributesMap &attr pkChanged = pkChanged || mPrimaryKeyAttrs.contains( fieldIndex ); auto qType = mFields.at( fieldIndex ).type(); if ( field.type == QgsHanaDataType::Geometry && qType == QMetaType::Type::QString ) - attrs << QStringLiteral( "%1=ST_GeomFromWKT(?, %2)" ).arg( - QgsHanaUtils::quotedIdentifier( field.name ), QString::number( field.srid ) ); + attrs << QStringLiteral( "%1=ST_GeomFromWKT(?, %2)" ).arg( QgsHanaUtils::quotedIdentifier( field.name ), QString::number( field.srid ) ); else if ( field.type == QgsHanaDataType::RealVector && qType == QMetaType::Type::QString ) attrs << QStringLiteral( "%1=TO_REAL_VECTOR(?)" ).arg( QgsHanaUtils::quotedIdentifier( field.name ) ); else @@ -1208,11 +1181,7 @@ bool QgsHanaProvider::changeAttributeValues( const QgsChangedAttributesMap &attr return true; const QString fidWhereClause = QgsHanaPrimaryKeyUtils::buildWhereClause( mFields, mPrimaryKeyType, mPrimaryKeyAttrs ); - const QString sql = QStringLiteral( "UPDATE %1.%2 SET %3 WHERE %4" ).arg( - QgsHanaUtils::quotedIdentifier( mSchemaName ), - QgsHanaUtils::quotedIdentifier( mTableName ), - attrs.join( QLatin1Char( ',' ) ), - fidWhereClause ); + const QString sql = QStringLiteral( "UPDATE %1.%2 SET %3 WHERE %4" ).arg( QgsHanaUtils::quotedIdentifier( mSchemaName ), QgsHanaUtils::quotedIdentifier( mTableName ), attrs.join( QLatin1Char( ',' ) ), fidWhereClause ); PreparedStatementRef stmtUpdate = conn->prepareStatement( sql ); @@ -1242,7 +1211,7 @@ bool QgsHanaProvider::changeAttributeValues( const QgsChangedAttributesMap &attr catch ( const exception &ex ) { pushError( tr( "Failed to change feature attributes: %1" ) - .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); + .arg( QgsHanaUtils::formatErrorMessage( ex.what() ) ) ); conn->rollback(); return false; } @@ -1298,7 +1267,7 @@ bool QgsHanaProvider::checkPermissionsAndSetCapabilities( QgsHanaConnection &con { QString sql = QStringLiteral( "SELECT OBJECT_NAME, OBJECT_TYPE, PRIVILEGE FROM PUBLIC.EFFECTIVE_PRIVILEGES " "WHERE USER_NAME = CURRENT_USER AND SCHEMA_NAME = ? AND IS_VALID = 'TRUE'" ); - QgsHanaResultSetRef rsPrivileges = conn.executeQuery( sql, { mSchemaName} ); + QgsHanaResultSetRef rsPrivileges = conn.executeQuery( sql, { mSchemaName } ); while ( rsPrivileges->next() ) { QString objName = rsPrivileges->getString( 1 ); @@ -1362,9 +1331,12 @@ static bool checkHANAVersion( QgsHanaConnection &conn, const QVersionNumber &pre QVersionNumber version = QgsHanaUtils::toHANAVersion( conn.getDatabaseVersion() ); switch ( version.majorVersion() ) { - case 2: return version >= premise; - case 4: return QgsHanaUtils::toHANAVersion( conn.getDatabaseCloudVersion() ) >= cloud; - default: return false; + case 2: + return version >= premise; + case 4: + return QgsHanaUtils::toHANAVersion( conn.getDatabaseCloudVersion() ) >= cloud; + default: + return false; } } catch ( const QgsHanaException &ex ) @@ -1391,20 +1363,22 @@ QgsRectangle QgsHanaProvider::estimateExtent( bool useEstimatedMetadata ) const if ( useEstimatedMetadata ) { sql = ::buildQuery( - "SYS.M_ST_GEOMETRY_COLUMNS", - "MIN_X,MIN_Y,MAX_X,MAX_Y", - QStringLiteral( "SCHEMA_NAME=%1 AND TABLE_NAME=%2 AND COLUMN_NAME=%3" ) - .arg( - QgsHanaUtils::quotedString( mSchemaName ), - QgsHanaUtils::quotedString( mTableName ), - QgsHanaUtils::quotedString( mGeometryColumn ) ), QString(), 1 ); + "SYS.M_ST_GEOMETRY_COLUMNS", + "MIN_X,MIN_Y,MAX_X,MAX_Y", + QStringLiteral( "SCHEMA_NAME=%1 AND TABLE_NAME=%2 AND COLUMN_NAME=%3" ) + .arg( + QgsHanaUtils::quotedString( mSchemaName ), + QgsHanaUtils::quotedString( mTableName ), + QgsHanaUtils::quotedString( mGeometryColumn ) + ), + QString(), 1 + ); } else { if ( isSrsRoundEarth( *conn, mSrid ) ) { - QString geomColumn = !mHasSrsPlanarEquivalent ? QgsHanaUtils::quotedIdentifier( mGeometryColumn ) : - QStringLiteral( "%1.ST_SRID(%2)" ).arg( QgsHanaUtils::quotedIdentifier( mGeometryColumn ), QString::number( QgsHanaUtils::toPlanarSRID( mSrid ) ) ); + QString geomColumn = !mHasSrsPlanarEquivalent ? QgsHanaUtils::quotedIdentifier( mGeometryColumn ) : QStringLiteral( "%1.ST_SRID(%2)" ).arg( QgsHanaUtils::quotedIdentifier( mGeometryColumn ), QString::number( QgsHanaUtils::toPlanarSRID( mSrid ) ) ); sql = buildQuery( QStringLiteral( "MIN(%1.ST_XMin()), MIN(%1.ST_YMin()), MAX(%1.ST_XMax()), MAX(%1.ST_YMax())" ).arg( geomColumn ) ); } else @@ -1452,8 +1426,7 @@ void QgsHanaProvider::readAttributeFields( QgsHanaConnection &conn ) mDefaultValues.clear(); QMap> defaultValues; - auto getColumnDefaultValue = [&defaultValues, &conn]( const QString & schemaName, const QString & tableName, const QString & columnName ) - { + auto getColumnDefaultValue = [&defaultValues, &conn]( const QString &schemaName, const QString &tableName, const QString &columnName ) { if ( schemaName.isEmpty() || tableName.isEmpty() ) return QVariant(); @@ -1472,8 +1445,7 @@ void QgsHanaProvider::readAttributeFields( QgsHanaConnection &conn ) return defaultValues[key].value( columnName ); }; - auto processField = [&]( const AttributeField & field ) - { + auto processField = [&]( const AttributeField &field ) { if ( field.name == mGeometryColumn ) return; @@ -1584,7 +1556,7 @@ void QgsHanaProvider::determinePrimaryKey( QgsHanaConnection &conn ) QgsFieldConstraints constraints = mFields.at( mPrimaryKeyAttrs.value( 0 ) ).constraints(); constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); - mFields[ mPrimaryKeyAttrs[0] ].setConstraints( constraints ); + mFields[mPrimaryKeyAttrs[0]].setConstraints( constraints ); } } @@ -1600,8 +1572,8 @@ long long QgsHanaProvider::getFeatureCount( const QString &whereClause ) const void QgsHanaProvider::updateFeatureIdMap( QgsFeatureId fid, const QgsAttributeMap &attributes ) { -// update feature id map if key was changed -// PktInt64 also uses a fid map even if it is a stand alone field. + // update feature id map if key was changed + // PktInt64 also uses a fid map even if it is a stand alone field. if ( !( mPrimaryKeyType == PktFidMap || mPrimaryKeyType == PktInt64 ) ) return; @@ -1612,7 +1584,7 @@ void QgsHanaProvider::updateFeatureIdMap( QgsFeatureId fid, const QgsAttributeMa int idx = mPrimaryKeyAttrs.at( i ); if ( !attributes.contains( idx ) ) continue; - values[i] = attributes[ idx ]; + values[i] = attributes[idx]; } mPrimaryKeyCntx->insertFid( fid, values ); @@ -1657,15 +1629,7 @@ QgsCoordinateReferenceSystem QgsHanaProvider::crs() const return srs; } -Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap *oldToNewAttrIdxMap, - QString *errorMessage, - const QMap * - ) +Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap *oldToNewAttrIdxMap, QString *errorMessage, const QMap * ) { QgsDataSourceUri dsUri( uri ); QgsHanaConnectionRef conn( dsUri ); @@ -1686,8 +1650,7 @@ Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, return Qgis::VectorExportResult::ErrorCreatingLayer; } - if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry && - !QgsHanaUtils::isGeometryTypeSupported( wkbType ) ) + if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry && !QgsHanaUtils::isGeometryTypeSupported( wkbType ) ) { if ( errorMessage ) *errorMessage = QObject::tr( "Geometry type '%1' is not supported" ).arg( QgsWkbTypes::displayString( wkbType ) ); @@ -1695,8 +1658,7 @@ Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, } QString geometryColumn = dsUri.geometryColumn(); - QString schemaTableName = QgsHanaUtils::quotedIdentifier( schemaName ) + '.' + - QgsHanaUtils::quotedIdentifier( tableName ); + QString schemaTableName = QgsHanaUtils::quotedIdentifier( schemaName ) + '.' + QgsHanaUtils::quotedIdentifier( tableName ); bool fieldsInUpperCase = false; if ( fields.size() > 0 ) @@ -1733,7 +1695,7 @@ Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, catch ( const QgsHanaException &ex ) { if ( errorMessage ) - *errorMessage = QgsHanaUtils::formatErrorMessage( ex.what(), true ); + *errorMessage = QgsHanaUtils::formatErrorMessage( ex.what(), true ); return Qgis::VectorExportResult::ErrorCreatingLayer; } } @@ -1743,7 +1705,7 @@ Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, size_t numTables = 0; try { - numTables = conn->executeCountQuery( sql, {schemaName, tableName} ); + numTables = conn->executeCountQuery( sql, { schemaName, tableName } ); } catch ( const QgsHanaException &ex ) { @@ -1757,7 +1719,7 @@ Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, if ( overwrite ) { QString sql = QStringLiteral( "DROP TABLE %1.%2" ) - .arg( QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ) ); + .arg( QgsHanaUtils::quotedIdentifier( schemaName ), QgsHanaUtils::quotedIdentifier( tableName ) ); if ( !conn->execute( sql, errorMessage ) ) return Qgis::VectorExportResult::ErrorCreatingLayer; } @@ -1773,13 +1735,12 @@ Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, if ( geometryColumn.isEmpty() ) { sql = QStringLiteral( "CREATE COLUMN TABLE %1 (%2 %3 GENERATED BY DEFAULT AS IDENTITY, PRIMARY KEY (%2))" ) - .arg( schemaTableName, QgsHanaUtils::quotedIdentifier( primaryKey ), primaryKeyType ); + .arg( schemaTableName, QgsHanaUtils::quotedIdentifier( primaryKey ), primaryKeyType ); } else { sql = QStringLiteral( "CREATE COLUMN TABLE %1 (%2 %3 GENERATED BY DEFAULT AS IDENTITY, %4 ST_GEOMETRY(%5), PRIMARY KEY (%2))" ) - .arg( schemaTableName, QgsHanaUtils::quotedIdentifier( primaryKey ), primaryKeyType, - QgsHanaUtils::quotedIdentifier( geometryColumn ), QString::number( srid ) ); + .arg( schemaTableName, QgsHanaUtils::quotedIdentifier( primaryKey ), primaryKeyType, QgsHanaUtils::quotedIdentifier( geometryColumn ), QString::number( srid ) ); } if ( !conn->execute( sql, errorMessage ) ) @@ -1789,7 +1750,7 @@ Qgis::VectorExportResult QgsHanaProvider::createEmptyLayer( const QString &uri, dsUri.setSrid( QString::number( srid ) ); QgsDataProvider::ProviderOptions providerOptions; - unique_ptr< QgsHanaProvider > provider = std::make_unique< QgsHanaProvider >( dsUri.uri( false ), providerOptions ); + unique_ptr provider = std::make_unique( dsUri.uri( false ), providerOptions ); if ( !provider->isValid() ) { @@ -1852,13 +1813,13 @@ void QgsHanaProviderMetadata::cleanupProvider() } QgsHanaProvider *QgsHanaProviderMetadata::createProvider( - const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags ) + const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags +) { QgsDataSourceUri dsUri { uri }; QgsHanaDriver *drv = QgsHanaDriver::instance(); - auto isDriverValid = [&drv]( const QString & driver ) - { + auto isDriverValid = [&drv]( const QString &driver ) { #ifdef Q_OS_WIN return drv->isInstalled( driver ); #else @@ -1868,8 +1829,7 @@ QgsHanaProvider *QgsHanaProviderMetadata::createProvider( // The following block is intended to resolve an issue when a data source was created under // another operating system. In this case, the driver parameter may differ. - if ( !drv->driver().isEmpty() && drv->driver() != dsUri.driver() && - !isDriverValid( dsUri.driver() ) && isDriverValid( drv->driver() ) ) + if ( !drv->driver().isEmpty() && drv->driver() != dsUri.driver() && !isDriverValid( dsUri.driver() ) && isDriverValid( drv->driver() ) ) { dsUri.setDriver( drv->driver() ); return new QgsHanaProvider( dsUri.uri(), options, flags ); @@ -1877,26 +1837,19 @@ QgsHanaProvider *QgsHanaProviderMetadata::createProvider( return new QgsHanaProvider( uri, options, flags ); } -QList< QgsDataItemProvider *> QgsHanaProviderMetadata::dataItemProviders() const +QList QgsHanaProviderMetadata::dataItemProviders() const { QList providers; providers << new QgsHanaDataItemProvider; return providers; } -Qgis::VectorExportResult QgsHanaProviderMetadata::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap &oldToNewAttrIdxMap, - QString &errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsHanaProviderMetadata::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) { return QgsHanaProvider::createEmptyLayer( - uri, fields, wkbType, srs, overwrite, - &oldToNewAttrIdxMap, &errorMessage, options - ); + uri, fields, wkbType, srs, overwrite, + &oldToNewAttrIdxMap, &errorMessage, options + ); } QMap QgsHanaProviderMetadata::connections( bool cached ) @@ -1919,7 +1872,7 @@ void QgsHanaProviderMetadata::deleteConnection( const QString &name ) deleteConnectionProtected( name ); } -void QgsHanaProviderMetadata::saveConnection( const QgsAbstractProviderConnection *conn, const QString &name ) +void QgsHanaProviderMetadata::saveConnection( const QgsAbstractProviderConnection *conn, const QString &name ) { saveConnectionProtected( conn, name ); } @@ -1929,42 +1882,41 @@ QVariantMap QgsHanaProviderMetadata::decodeUri( const QString &uri ) const const QgsDataSourceUri dsUri { uri }; QVariantMap uriParts; - auto setUriPart = [&dsUri, &uriParts]( const QString & key ) - { + auto setUriPart = [&dsUri, &uriParts]( const QString &key ) { if ( !dsUri.hasParam( key ) ) return; QString value = dsUri.param( key ); if ( !value.isEmpty() ) - uriParts[ key ] = value; + uriParts[key] = value; }; setUriPart( QStringLiteral( "connectionType" ) ); setUriPart( QStringLiteral( "dsn" ) ); - if ( ! dsUri.driver().isEmpty() ) - uriParts[ QStringLiteral( "driver" ) ] = dsUri.driver(); - if ( ! dsUri.database().isEmpty() ) - uriParts[ QStringLiteral( "dbname" ) ] = dsUri.database(); - if ( ! dsUri.host().isEmpty() ) - uriParts[ QStringLiteral( "host" ) ] = dsUri.host(); - if ( ! dsUri.port().isEmpty() ) - uriParts[ QStringLiteral( "port" ) ] = dsUri.port(); - if ( ! dsUri.username().isEmpty() ) - uriParts[ QStringLiteral( "username" ) ] = dsUri.username(); - if ( ! dsUri.password().isEmpty() ) - uriParts[ QStringLiteral( "password" ) ] = dsUri.password(); - if ( ! dsUri.authConfigId().isEmpty() ) - uriParts[ QStringLiteral( "authcfg" ) ] = dsUri.authConfigId(); + if ( !dsUri.driver().isEmpty() ) + uriParts[QStringLiteral( "driver" )] = dsUri.driver(); + if ( !dsUri.database().isEmpty() ) + uriParts[QStringLiteral( "dbname" )] = dsUri.database(); + if ( !dsUri.host().isEmpty() ) + uriParts[QStringLiteral( "host" )] = dsUri.host(); + if ( !dsUri.port().isEmpty() ) + uriParts[QStringLiteral( "port" )] = dsUri.port(); + if ( !dsUri.username().isEmpty() ) + uriParts[QStringLiteral( "username" )] = dsUri.username(); + if ( !dsUri.password().isEmpty() ) + uriParts[QStringLiteral( "password" )] = dsUri.password(); + if ( !dsUri.authConfigId().isEmpty() ) + uriParts[QStringLiteral( "authcfg" )] = dsUri.authConfigId(); if ( dsUri.wkbType() != Qgis::WkbType::Unknown ) - uriParts[ QStringLiteral( "type" ) ] = static_cast< quint32>( dsUri.wkbType() ); - if ( ! dsUri.schema().isEmpty() ) - uriParts[ QStringLiteral( "schema" ) ] = dsUri.schema(); - if ( ! dsUri.table().isEmpty() ) - uriParts[ QStringLiteral( "table" ) ] = dsUri.table(); - if ( ! dsUri.keyColumn().isEmpty() ) - uriParts[ QStringLiteral( "key" ) ] = dsUri.keyColumn(); - if ( ! dsUri.srid().isEmpty() ) - uriParts[ QStringLiteral( "srid" ) ] = dsUri.srid(); - uriParts[ QStringLiteral( "selectatid" ) ] = dsUri.selectAtIdDisabled(); + uriParts[QStringLiteral( "type" )] = static_cast( dsUri.wkbType() ); + if ( !dsUri.schema().isEmpty() ) + uriParts[QStringLiteral( "schema" )] = dsUri.schema(); + if ( !dsUri.table().isEmpty() ) + uriParts[QStringLiteral( "table" )] = dsUri.table(); + if ( !dsUri.keyColumn().isEmpty() ) + uriParts[QStringLiteral( "key" )] = dsUri.keyColumn(); + if ( !dsUri.srid().isEmpty() ) + uriParts[QStringLiteral( "srid" )] = dsUri.srid(); + uriParts[QStringLiteral( "selectatid" )] = dsUri.selectAtIdDisabled(); // SSL parameters setUriPart( QStringLiteral( "sslEnabled" ) ); @@ -1982,10 +1934,10 @@ QVariantMap QgsHanaProviderMetadata::decodeUri( const QString &uri ) const setUriPart( QStringLiteral( "proxyUsername" ) ); setUriPart( QStringLiteral( "proxyPassword" ) ); - if ( ! dsUri.sql().isEmpty() ) - uriParts[ QStringLiteral( "sql" ) ] = dsUri.sql(); - if ( ! dsUri.geometryColumn().isEmpty() ) - uriParts[ QStringLiteral( "geometrycolumn" ) ] = dsUri.geometryColumn(); + if ( !dsUri.sql().isEmpty() ) + uriParts[QStringLiteral( "sql" )] = dsUri.sql(); + if ( !dsUri.geometryColumn().isEmpty() ) + uriParts[QStringLiteral( "geometrycolumn" )] = dsUri.geometryColumn(); return uriParts; } @@ -1994,8 +1946,7 @@ QString QgsHanaProviderMetadata::encodeUri( const QVariantMap &parts ) const { QgsDataSourceUri dsUri; - auto setUriParam = [&parts, &dsUri]( const QString & key ) - { + auto setUriParam = [&parts, &dsUri]( const QString &key ) { if ( parts.contains( key ) ) dsUri.setParam( key, parts.value( key ).toString() ); }; diff --git a/src/providers/hana/qgshanaprovider.h b/src/providers/hana/qgshanaprovider.h index c8da83c4ac3e..4fb41933eac4 100644 --- a/src/providers/hana/qgshanaprovider.h +++ b/src/providers/hana/qgshanaprovider.h @@ -46,8 +46,7 @@ class QgsHanaProvider final : public QgsVectorDataProvider static const QString HANA_KEY; static const QString HANA_DESCRIPTION; - QgsHanaProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); + QgsHanaProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); /* Functions inherited from QgsVectorDataProvider */ @@ -62,7 +61,7 @@ class QgsHanaProvider final : public QgsVectorDataProvider QgsFields fields() const override; QVariant minimumValue( int index ) const override; QVariant maximumValue( int index ) const override; - QSet< QVariant > uniqueValues( int index, int limit = -1 ) const override; + QSet uniqueValues( int index, int limit = -1 ) const override; QString subsetString() const override; bool setSubsetString( const QString &subset, bool updateFeatureCount = true ) override; bool supportsSubsetString() const override; @@ -77,7 +76,8 @@ class QgsHanaProvider final : public QgsVectorDataProvider bool changeGeometryValues( const QgsGeometryMap &geometry_map ) override; bool changeFeatures( const QgsChangedAttributesMap &attrMap, - const QgsGeometryMap &geometryMap ) override; + const QgsGeometryMap &geometryMap + ) override; bool changeAttributeValues( const QgsChangedAttributesMap &attrMap ) override; Qgis::VectorProviderCapabilities capabilities() const override; @@ -192,7 +192,8 @@ class QgsHanaProviderMetadata : public QgsProviderMetadata bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, - const QMap *options ) override; + const QMap *options + ) override; QList dataItemProviders() const override; @@ -206,7 +207,7 @@ class QgsHanaProviderMetadata : public QgsProviderMetadata // Data source URI API QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif // QGSHANAPROVIDER_H diff --git a/src/providers/hana/qgshanaproviderconnection.cpp b/src/providers/hana/qgshanaproviderconnection.cpp index 5cc1c9267e36..336eba090816 100644 --- a/src/providers/hana/qgshanaproviderconnection.cpp +++ b/src/providers/hana/qgshanaproviderconnection.cpp @@ -74,8 +74,8 @@ QgsHanaProviderConnection::QgsHanaProviderConnection( const QString &name ) setCapabilities(); } -QgsHanaProviderConnection::QgsHanaProviderConnection( const QString &uri, const QVariantMap &configuration ): - QgsAbstractDatabaseProviderConnection( uri, configuration ) +QgsHanaProviderConnection::QgsHanaProviderConnection( const QString &uri, const QVariantMap &configuration ) + : QgsAbstractDatabaseProviderConnection( uri, configuration ) { mProviderKey = QStringLiteral( "hana" ); setCapabilities(); @@ -83,15 +83,13 @@ QgsHanaProviderConnection::QgsHanaProviderConnection( const QString &uri, const void QgsHanaProviderConnection::setCapabilities() { - mGeometryColumnCapabilities = - { + mGeometryColumnCapabilities = { //GeometryColumnCapability::Curves, not fully supported yet GeometryColumnCapability::Z, GeometryColumnCapability::M, GeometryColumnCapability::SinglePart }; - mSqlLayerDefinitionCapabilities = - { + mSqlLayerDefinitionCapabilities = { Qgis::SqlLayerDefinitionCapability::SubsetStringFilter, Qgis::SqlLayerDefinitionCapability::PrimaryKeys, Qgis::SqlLayerDefinitionCapability::GeometryColumn, @@ -115,8 +113,7 @@ void QgsHanaProviderConnection::setCapabilities() * not have the necessary privileges for one of the objects in the query. */ - mCapabilities = - { + mCapabilities = { Capability::CreateVectorTable, Capability::DropVectorTable, Capability::RenameVectorTable, @@ -168,24 +165,15 @@ void QgsHanaProviderConnection::setCapabilities() } catch ( const QgsHanaException &ex ) { - QgsMessageLog::logMessage( QObject::tr( "Unable to retrieve user privileges: %1" ) - .arg( ex.what() ), QObject::tr( "SAP HANA" ) ); + QgsMessageLog::logMessage( QObject::tr( "Unable to retrieve user privileges: %1" ).arg( ex.what() ), QObject::tr( "SAP HANA" ) ); } } // We enable all capabilities, if we were not able to retrieve them from the database. - mCapabilities |= Capability::CreateSchema | Capability::DropSchema | Capability::RenameSchema | - Capability::Schemas | Capability::Tables | Capability::TableExists; + mCapabilities |= Capability::CreateSchema | Capability::DropSchema | Capability::RenameSchema | Capability::Schemas | Capability::Tables | Capability::TableExists; } -void QgsHanaProviderConnection::createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - const QMap *options ) const +void QgsHanaProviderConnection::createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const { checkCapability( Capability::CreateVectorTable ); @@ -193,22 +181,22 @@ void QgsHanaProviderConnection::createVectorTable( const QString &schema, newUri.setSchema( schema ); newUri.setTable( name ); // Set geometry column if it's not aspatial - if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) + if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) { newUri.setGeometryColumn( options->value( QStringLiteral( "geometryColumn" ), QStringLiteral( "geom" ) ).toString() ); } QMap map; QString errCause; Qgis::VectorExportResult res = QgsHanaProvider::createEmptyLayer( - newUri.uri(), - fields, - wkbType, - srs, - overwrite, - &map, - &errCause, - options - ); + newUri.uri(), + fields, + wkbType, + srs, + overwrite, + &map, + &errCause, + options + ); if ( res != Qgis::VectorExportResult::Success ) { throw QgsProviderConnectionException( QObject::tr( "An error occurred while creating the vector layer: %1" ).arg( errCause ) ); @@ -222,7 +210,7 @@ QString QgsHanaProviderConnection::tableUri( const QString &schema, const QStrin QgsDataSourceUri dsUri( uri() ); dsUri.setTable( name ); dsUri.setSchema( schema ); - dsUri.setGeometryColumn( tableInfo .geometryColumn() ); + dsUri.setGeometryColumn( tableInfo.geometryColumn() ); return dsUri.uri( false ); } @@ -232,43 +220,38 @@ void QgsHanaProviderConnection::dropVectorTable( const QString &schema, const QS const TableProperty tableInfo = table( schema, name ); if ( tableInfo.flags().testFlag( TableFlag::View ) ) executeSqlStatement( QStringLiteral( "DROP VIEW %1.%2" ) - .arg( QgsHanaUtils::quotedIdentifier( schema ), - QgsHanaUtils::quotedIdentifier( name ) ) ); + .arg( QgsHanaUtils::quotedIdentifier( schema ), QgsHanaUtils::quotedIdentifier( name ) ) ); else executeSqlStatement( QStringLiteral( "DROP TABLE %1.%2" ) - .arg( QgsHanaUtils::quotedIdentifier( schema ), - QgsHanaUtils::quotedIdentifier( name ) ) ); + .arg( QgsHanaUtils::quotedIdentifier( schema ), QgsHanaUtils::quotedIdentifier( name ) ) ); } void QgsHanaProviderConnection::renameVectorTable( const QString &schema, const QString &name, const QString &newName ) const { checkCapability( Capability::RenameVectorTable ); executeSqlStatement( QStringLiteral( "RENAME TABLE %1.%2 TO %1.%3" ) - .arg( QgsHanaUtils::quotedIdentifier( schema ), - QgsHanaUtils::quotedIdentifier( name ), - QgsHanaUtils::quotedIdentifier( newName ) ) ); + .arg( QgsHanaUtils::quotedIdentifier( schema ), QgsHanaUtils::quotedIdentifier( name ), QgsHanaUtils::quotedIdentifier( newName ) ) ); } void QgsHanaProviderConnection::createSchema( const QString &name ) const { checkCapability( Capability::CreateSchema ); executeSqlStatement( QStringLiteral( "CREATE SCHEMA %1" ) - .arg( QgsHanaUtils::quotedIdentifier( name ) ) ); + .arg( QgsHanaUtils::quotedIdentifier( name ) ) ); } -void QgsHanaProviderConnection::dropSchema( const QString &name, bool force ) const +void QgsHanaProviderConnection::dropSchema( const QString &name, bool force ) const { checkCapability( Capability::DropSchema ); executeSqlStatement( QStringLiteral( "DROP SCHEMA %1 %2" ) - .arg( QgsHanaUtils::quotedIdentifier( name ), - force ? QStringLiteral( "CASCADE" ) : QString() ) ); + .arg( QgsHanaUtils::quotedIdentifier( name ), force ? QStringLiteral( "CASCADE" ) : QString() ) ); } void QgsHanaProviderConnection::renameSchema( const QString &name, const QString &newName ) const { checkCapability( Capability::RenameSchema ); executeSqlStatement( QStringLiteral( "RENAME SCHEMA %1 TO %2" ) - .arg( QgsHanaUtils::quotedIdentifier( name ), QgsHanaUtils::quotedIdentifier( newName ) ) ); + .arg( QgsHanaUtils::quotedIdentifier( name ), QgsHanaUtils::quotedIdentifier( newName ) ) ); } QgsAbstractDatabaseProviderConnection::QueryResult QgsHanaProviderConnection::execSql( const QString &sql, QgsFeedback *feedback ) const @@ -345,7 +328,8 @@ void QgsHanaProviderConnection::executeSqlStatement( const QString &sql ) const QList QgsHanaProviderConnection::tablesWithFilter( const QString &schema, - const TableFlags &flags, const std::function &layerFilter ) const + const TableFlags &flags, const std::function &layerFilter +) const { checkCapability( Capability::Tables ); @@ -354,10 +338,10 @@ QList QgsHanaProviderConne try { - const bool aspatial { ! flags || flags.testFlag( TableFlag::Aspatial ) }; + const bool aspatial { !flags || flags.testFlag( TableFlag::Aspatial ) }; const QVector layers = conn->getLayersFull( schema, aspatial, false, layerFilter ); tables.reserve( layers.size() ); - for ( const QgsHanaLayerProperty &layerInfo : layers ) + for ( const QgsHanaLayerProperty &layerInfo : layers ) { // Classify TableFlags prFlags; @@ -369,7 +353,7 @@ QList QgsHanaProviderConne prFlags.setFlag( QgsHanaProviderConnection::TableFlag::Aspatial ); // Filter - if ( ! flags || ( prFlags & flags ) ) + if ( !flags || ( prFlags & flags ) ) { QgsHanaProviderConnection::TableProperty property; property.setFlags( prFlags ); @@ -388,7 +372,7 @@ QList QgsHanaProviderConne // Set the candidates property.setPrimaryKeyColumns( layerInfo.pkCols ); } - else // Fetch and set the real pks + else // Fetch and set the real pks { QStringList pks = conn->getLayerPrimaryKey( layerInfo.schemaName, layerInfo.tableName ); property.setPrimaryKeyColumns( pks ); @@ -408,14 +392,13 @@ QList QgsHanaProviderConne QgsAbstractDatabaseProviderConnection::TableProperty QgsHanaProviderConnection::table( const QString &schema, const QString &table, QgsFeedback * ) const { const QString geometryColumn = QgsDataSourceUri( uri() ).geometryColumn(); - auto layerFilter = [&table, &geometryColumn]( const QgsHanaLayerProperty & layer ) - { + auto layerFilter = [&table, &geometryColumn]( const QgsHanaLayerProperty &layer ) { return layer.tableName == table && ( geometryColumn.isEmpty() || layer.geometryColName == geometryColumn ); }; const QList constTables { tablesWithFilter( schema, TableFlags(), layerFilter ) }; if ( constTables.empty() ) throw QgsProviderConnectionException( QObject::tr( "Table '%1' was not found in schema '%2'" ) - .arg( table, schema ) ); + .arg( table, schema ) ); return constTables[0]; } @@ -424,7 +407,7 @@ QList QgsHanaProviderConnection::table return tablesWithFilter( schema, flags ); } -QStringList QgsHanaProviderConnection::schemas( ) const +QStringList QgsHanaProviderConnection::schemas() const { checkCapability( Capability::Schemas ); @@ -452,8 +435,7 @@ QgsFields QgsHanaProviderConnection::fields( const QString &schema, const QStrin try { QgsFields fields; - auto processField = [&geometryColumn, &fields]( const AttributeField & field ) - { + auto processField = [&geometryColumn, &fields]( const AttributeField &field ) { if ( field.name != geometryColumn ) fields.append( field.toQgsField() ); }; @@ -506,12 +488,12 @@ QgsVectorLayer *QgsHanaProviderConnection::createSqlVectorLayer( const SqlVector throw QgsProviderConnectionException( QObject::tr( "Could not create a SQL vector layer: SQL expression is empty." ) ); } - QgsDataSourceUri tUri( uri( ) ); + QgsDataSourceUri tUri( uri() ); tUri.setSql( options.filter ); tUri.disableSelectAtId( options.disableSelectAtId ); - if ( ! options.primaryKeyColumns.isEmpty() ) + if ( !options.primaryKeyColumns.isEmpty() ) { tUri.setKeyColumn( QgsHanaPrimaryKeyUtils::buildUriKey( options.primaryKeyColumns ) ); tUri.setTable( QStringLiteral( "(%1)" ).arg( options.sql ) ); @@ -521,26 +503,26 @@ QgsVectorLayer *QgsHanaProviderConnection::createSqlVectorLayer( const SqlVector int pkId { 0 }; while ( options.sql.contains( QStringLiteral( "_uid%1_" ).arg( pkId ), Qt::CaseSensitivity::CaseInsensitive ) ) { - pkId ++; + pkId++; } tUri.setKeyColumn( QStringLiteral( "_uid%1_" ).arg( pkId ) ); int sqlId { 0 }; while ( options.sql.contains( QStringLiteral( "_subq_%1_" ).arg( sqlId ), Qt::CaseSensitivity::CaseInsensitive ) ) { - sqlId ++; + sqlId++; } tUri.setTable( QStringLiteral( "(SELECT ROW_NUMBER() over () AS \"_uid%1_\", * FROM (%2\n) AS \"_subq_%3_\"\n)" ).arg( QString::number( pkId ), options.sql, QString::number( sqlId ) ) ); } - if ( ! options.geometryColumn.isEmpty() ) + if ( !options.geometryColumn.isEmpty() ) { tUri.setGeometryColumn( options.geometryColumn ); } QgsVectorLayer::LayerOptions vectorLayerOptions { false, true }; vectorLayerOptions.skipCrsValidation = true; - return new QgsVectorLayer{ tUri.uri( false ), options.layerName.isEmpty() ? QStringLiteral( "QueryLayer" ) : options.layerName, providerKey(), vectorLayerOptions }; + return new QgsVectorLayer { tUri.uri( false ), options.layerName.isEmpty() ? QStringLiteral( "QueryLayer" ) : options.layerName, providerKey(), vectorLayerOptions }; } QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions QgsHanaProviderConnection::sqlOptions( const QString &layerSource ) @@ -559,1486 +541,1482 @@ QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions QgsHanaProviderConn QMultiMap QgsHanaProviderConnection::sqlDictionary() { return QgsAbstractDatabaseProviderConnection::sqlDictionary().unite( - { - { - Qgis::SqlKeywordCategory::Keyword, - { - QStringLiteral( "ABAP_CHAR" ), - QStringLiteral( "ABAP_DATE" ), - QStringLiteral( "ABAP_DECFLOAT16" ), - QStringLiteral( "ABAP_DECFLOAT34" ), - QStringLiteral( "ABAP_FLOAT" ), - QStringLiteral( "ABAP_HEX" ), - QStringLiteral( "ABAP_INT" ), - QStringLiteral( "ABAP_INT1" ), - QStringLiteral( "ABAP_INT2" ), - QStringLiteral( "ABAP_NUM" ), - QStringLiteral( "ABAP_PACKED" ), - QStringLiteral( "ABAP_STRING" ), - QStringLiteral( "ABAP_TIME" ), - QStringLiteral( "ABAP_XSTRING" ), - QStringLiteral( "ABAPITAB" ), - QStringLiteral( "ABAPSTRUCT" ), - QStringLiteral( "ABSOLUTE" ), - QStringLiteral( "ABSTRACT" ), - QStringLiteral( "ACCESS" ), - QStringLiteral( "ACCURACY" ), - QStringLiteral( "ACKNOWLEDGED" ), - QStringLiteral( "ACTION" ), - QStringLiteral( "ACTIONS" ), - QStringLiteral( "ACTIVATE" ), - QStringLiteral( "ADAPTER" ), - QStringLiteral( "ADD" ), - QStringLiteral( "ADD_DAYS" ), - QStringLiteral( "ADD_MONTHS" ), - QStringLiteral( "ADD_SECONDS" ), - QStringLiteral( "ADD_YEARS" ), - QStringLiteral( "ADDRESS" ), - QStringLiteral( "ADMIN" ), - QStringLiteral( "ADOPT" ), - QStringLiteral( "AFL" ), - QStringLiteral( "AFTER" ), - QStringLiteral( "AGENT" ), - QStringLiteral( "ALERT" ), - QStringLiteral( "ALGORITHM" ), - QStringLiteral( "ALIAS" ), - QStringLiteral( "ALIGNMENT" ), - QStringLiteral( "ALL" ), - QStringLiteral( "ALLATTRSFREESTYLERELEVANT" ), - QStringLiteral( "ALLOCATOR" ), - QStringLiteral( "ALLOCATORS" ), - QStringLiteral( "ALLOWED" ), - QStringLiteral( "ALPHANUM" ), - QStringLiteral( "ALPHANUM_IDENTIFIER" ), - QStringLiteral( "ALTER" ), - QStringLiteral( "ALTERNATE" ), - QStringLiteral( "ALWAYS" ), - QStringLiteral( "ANALYSIS" ), - QStringLiteral( "ANALYTIC" ), - QStringLiteral( "ANALYZE" ), - QStringLiteral( "ANCHOR" ), - QStringLiteral( "AND" ), - QStringLiteral( "ANGULAR" ), - QStringLiteral( "ANNOTATE" ), - QStringLiteral( "ANNOTATIONS" ), - QStringLiteral( "ANONYMIZATION" ), - QStringLiteral( "ANY" ), - QStringLiteral( "APPEND" ), - QStringLiteral( "APPLICATION" ), - QStringLiteral( "APPLICATION_TIME" ), - QStringLiteral( "APPLICATIONUSER" ), - QStringLiteral( "APPLY" ), - QStringLiteral( "APPLY_FILTER" ), - QStringLiteral( "ARCHIVE" ), - QStringLiteral( "AREA" ), - QStringLiteral( "ARRAY" ), - QStringLiteral( "ARRAY_AGG" ), - QStringLiteral( "AS" ), - QStringLiteral( "ASC" ), - QStringLiteral( "ASSERTION" ), - QStringLiteral( "ASSOCIATION" ), - QStringLiteral( "ASSOCIATIONS" ), - QStringLiteral( "ASYNC" ), - QStringLiteral( "ASYNCHRONOUS" ), - QStringLiteral( "AT" ), - QStringLiteral( "ATOMIC" ), - QStringLiteral( "ATTACH" ), - QStringLiteral( "ATTEMPTS" ), - QStringLiteral( "ATTRIBUTE" ), - QStringLiteral( "ATTRIBUTEMAPPING" ), - QStringLiteral( "AUDIT" ), - QStringLiteral( "AUDITING" ), - QStringLiteral( "AUTHENTICATION" ), - QStringLiteral( "AUTHORIZATION" ), - QStringLiteral( "AUTO" ), - QStringLiteral( "AUTOCOMMIT" ), - QStringLiteral( "AUTOMATIC" ), - QStringLiteral( "AUTOMERGE" ), - QStringLiteral( "AXIS" ), - QStringLiteral( "BACKINT" ), - QStringLiteral( "BACKUP" ), - QStringLiteral( "BACKUP_ID" ), - QStringLiteral( "BACKUPS" ), - QStringLiteral( "BALANCE" ), - QStringLiteral( "BASIC" ), - QStringLiteral( "BATCH" ), - QStringLiteral( "BEFORE" ), - QStringLiteral( "BEGIN" ), - QStringLiteral( "BERNOULLI" ), - QStringLiteral( "BEST" ), - QStringLiteral( "BETWEEN" ), - QStringLiteral( "BIGINT" ), - QStringLiteral( "BINARY" ), - QStringLiteral( "BINARYCONSTRAINT" ), - QStringLiteral( "BIND_AS_PARAMETER" ), - QStringLiteral( "BIND_AS_VALUE" ), - QStringLiteral( "BIND_BIGINT" ), - QStringLiteral( "BIND_CHAR" ), - QStringLiteral( "BIND_DECIMAL" ), - QStringLiteral( "BIND_DOUBLE" ), - QStringLiteral( "BIND_NCHAR" ), - QStringLiteral( "BIND_REAL" ), - QStringLiteral( "BITS" ), - QStringLiteral( "BLOB" ), - QStringLiteral( "BOOLEAN" ), - QStringLiteral( "BOTH" ), - QStringLiteral( "BOUNDARY" ), - QStringLiteral( "BREAK" ), - QStringLiteral( "BREAKUP" ), - QStringLiteral( "BTREE" ), - QStringLiteral( "BUCKETS" ), - QStringLiteral( "BUFFER" ), - QStringLiteral( "BUILTIN" ), - QStringLiteral( "BULK" ), - QStringLiteral( "BUSINESS" ), - QStringLiteral( "BY" ), - QStringLiteral( "CA" ), - QStringLiteral( "CACHE" ), - QStringLiteral( "CALCULATEDKEYFIGURE" ), - QStringLiteral( "CALCULATEDVIEWATTRIBUTE" ), - QStringLiteral( "CALCULATION" ), - QStringLiteral( "CALENDAR" ), - QStringLiteral( "CALL" ), - QStringLiteral( "CALLS" ), - QStringLiteral( "CALLSTACK" ), - QStringLiteral( "CANCEL" ), - QStringLiteral( "CAPTURE" ), - QStringLiteral( "CASCADE" ), - QStringLiteral( "CASE" ), - QStringLiteral( "CAST" ), - QStringLiteral( "CATALOG" ), - QStringLiteral( "CDS" ), - QStringLiteral( "CE_CALC" ), - QStringLiteral( "CE_JOIN" ), - QStringLiteral( "CE_PROJECTION" ), - QStringLiteral( "CELL" ), - QStringLiteral( "CELLS" ), - QStringLiteral( "CENTER" ), - QStringLiteral( "CERTIFICATE" ), - QStringLiteral( "CERTIFICATES" ), - QStringLiteral( "CHANGE" ), - QStringLiteral( "CHANGES" ), - QStringLiteral( "CHAR" ), - QStringLiteral( "CHARACTER" ), - QStringLiteral( "CHARACTERISTIC" ), - QStringLiteral( "CHECK" ), - QStringLiteral( "CHECKPOINT" ), - QStringLiteral( "CHILDRENATTRIBUTE" ), - QStringLiteral( "CLAIM" ), - QStringLiteral( "CLASS" ), - QStringLiteral( "CLEAR" ), - QStringLiteral( "CLIENT" ), - QStringLiteral( "CLIENTPKI" ), - QStringLiteral( "CLIENTSIDE" ), - QStringLiteral( "CLIP" ), - QStringLiteral( "CLOB" ), - QStringLiteral( "CLOSE" ), - QStringLiteral( "CLUSTER" ), - QStringLiteral( "CLUSTERING" ), - QStringLiteral( "CLUSTERS" ), - QStringLiteral( "COALESCE" ), - QStringLiteral( "CODE" ), - QStringLiteral( "CODEPAGE" ), - QStringLiteral( "COLLATE" ), - QStringLiteral( "COLLATION" ), - QStringLiteral( "COLLECTION" ), - QStringLiteral( "COLUMN" ), - QStringLiteral( "COLUMN_VIEW_ESTIMATION" ), - QStringLiteral( "COLUMNS" ), - QStringLiteral( "COMMENT" ), - QStringLiteral( "COMMIT" ), - QStringLiteral( "COMMITTED" ), - QStringLiteral( "COMPACT" ), - QStringLiteral( "COMPATIBILITY" ), - QStringLiteral( "COMPLETE" ), - QStringLiteral( "COMPONENT" ), - QStringLiteral( "COMPONENTS" ), - QStringLiteral( "COMPRESSED" ), - QStringLiteral( "COMPRESSION" ), - QStringLiteral( "COMPUTE" ), - QStringLiteral( "COMPUTE_REPLICA_COUNT" ), - QStringLiteral( "COMPUTE_REPLICA_TYPE" ), - QStringLiteral( "CONCAT" ), - QStringLiteral( "CONDITION" ), - QStringLiteral( "CONDITIONAL" ), - QStringLiteral( "CONFIG" ), - QStringLiteral( "CONFIGURATION" ), - QStringLiteral( "CONFIGURE" ), - QStringLiteral( "CONNECT" ), - QStringLiteral( "CONNECTION" ), - QStringLiteral( "CONSISTENCY" ), - QStringLiteral( "CONSTANT" ), - QStringLiteral( "CONSTRAINT" ), - QStringLiteral( "CONSTRAINTS" ), - QStringLiteral( "CONTAINS" ), - QStringLiteral( "CONTENT" ), - QStringLiteral( "CONTEXT" ), - QStringLiteral( "CONTINUE" ), - QStringLiteral( "CONTROL" ), - QStringLiteral( "CONTROLLED" ), - QStringLiteral( "CONV" ), - QStringLiteral( "CONVERT" ), - QStringLiteral( "COORDINATE" ), - QStringLiteral( "COPY" ), - QStringLiteral( "COREFILE" ), - QStringLiteral( "CORRELATION" ), - QStringLiteral( "COVERAGE" ), - QStringLiteral( "CPBTREE" ), - QStringLiteral( "CPU" ), - QStringLiteral( "CREATE" ), - QStringLiteral( "CREATION" ), - QStringLiteral( "CREATOR" ), - QStringLiteral( "CREDENTIAL" ), - QStringLiteral( "CRITICAL" ), - QStringLiteral( "CRON" ), - QStringLiteral( "CROSS" ), - QStringLiteral( "CS_DATE" ), - QStringLiteral( "CS_DAYDATE" ), - QStringLiteral( "CS_DECIMAL_FLOAT" ), - QStringLiteral( "CS_DOUBLE" ), - QStringLiteral( "CS_FIXED" ), - QStringLiteral( "CS_FIXEDSTRING" ), - QStringLiteral( "CS_FLOAT" ), - QStringLiteral( "CS_GEOMETRY" ), - QStringLiteral( "CS_INT" ), - QStringLiteral( "CS_LONGDATE" ), - QStringLiteral( "CS_POINT" ), - QStringLiteral( "CS_POINTZ" ), - QStringLiteral( "CS_RAW" ), - QStringLiteral( "CS_SDFLOAT" ), - QStringLiteral( "CS_SECONDDATE" ), - QStringLiteral( "CS_SECONDTIME" ), - QStringLiteral( "CS_SHORTTEXT" ), - QStringLiteral( "CS_STRING" ), - QStringLiteral( "CS_TEXT" ), - QStringLiteral( "CS_TEXT_AE" ), - QStringLiteral( "CS_TIME" ), - QStringLiteral( "CSV" ), - QStringLiteral( "CUBE" ), - QStringLiteral( "CUME_DIST" ), - QStringLiteral( "CURDATE" ), - QStringLiteral( "CURRENT" ), - QStringLiteral( "CURRENT_CONNECTION" ), - QStringLiteral( "CURRENT_DATABASE" ), - QStringLiteral( "CURRENT_DATE" ), - QStringLiteral( "CURRENT_SCHEMA" ), - QStringLiteral( "CURRENT_TIME" ), - QStringLiteral( "CURRENT_TIMESTAMP" ), - QStringLiteral( "CURRENT_TRANSACTION_ISOLATION_LEVEL" ), - QStringLiteral( "CURRENT_USER" ), - QStringLiteral( "CURRENT_UTCDATE" ), - QStringLiteral( "CURRENT_UTCTIME" ), - QStringLiteral( "CURRENT_UTCTIMESTAMP" ), - QStringLiteral( "CURRVAL" ), - QStringLiteral( "CURSOR" ), - QStringLiteral( "CURTIME" ), - QStringLiteral( "CURVE" ), - QStringLiteral( "CYCLE" ), - QStringLiteral( "D" ), - QStringLiteral( "DATA" ), - QStringLiteral( "DATABASE" ), - QStringLiteral( "DATABASES" ), - QStringLiteral( "DATAPROVISIONING" ), - QStringLiteral( "DATASET" ), - QStringLiteral( "DATASOURCE" ), - QStringLiteral( "DATAVOLUME" ), - QStringLiteral( "DATE" ), - QStringLiteral( "DATEFORMAT" ), - QStringLiteral( "DATETIME" ), - QStringLiteral( "DATS_EXTRACT" ), - QStringLiteral( "DAY" ), - QStringLiteral( "DAYDATE" ), - QStringLiteral( "DAYOFMONTH" ), - QStringLiteral( "DAYOFWEEK" ), - QStringLiteral( "DAYS_BETWEEN" ), - QStringLiteral( "DBSCAN" ), - QStringLiteral( "DBSPACE" ), - QStringLiteral( "DDIC_ACCP" ), - QStringLiteral( "DDIC_CDAY" ), - QStringLiteral( "DDIC_CHAR" ), - QStringLiteral( "DDIC_CLNT" ), - QStringLiteral( "DDIC_CUKY" ), - QStringLiteral( "DDIC_CURR" ), - QStringLiteral( "DDIC_D16D" ), - QStringLiteral( "DDIC_D16R" ), - QStringLiteral( "DDIC_D16S" ), - QStringLiteral( "DDIC_D34D" ), - QStringLiteral( "DDIC_D34R" ), - QStringLiteral( "DDIC_D34S" ), - QStringLiteral( "DDIC_DATS" ), - QStringLiteral( "DDIC_DAY" ), - QStringLiteral( "DDIC_DEC" ), - QStringLiteral( "DDIC_FLTP" ), - QStringLiteral( "DDIC_GUID" ), - QStringLiteral( "DDIC_INT1" ), - QStringLiteral( "DDIC_INT2" ), - QStringLiteral( "DDIC_INT4" ), - QStringLiteral( "DDIC_INT8" ), - QStringLiteral( "DDIC_LANG" ), - QStringLiteral( "DDIC_LCHR" ), - QStringLiteral( "DDIC_LRAW" ), - QStringLiteral( "DDIC_MIN" ), - QStringLiteral( "DDIC_MON" ), - QStringLiteral( "DDIC_NUMC" ), - QStringLiteral( "DDIC_PREC" ), - QStringLiteral( "DDIC_QUAN" ), - QStringLiteral( "DDIC_RAW" ), - QStringLiteral( "DDIC_RSTR" ), - QStringLiteral( "DDIC_SEC" ), - QStringLiteral( "DDIC_SRST" ), - QStringLiteral( "DDIC_SSTR" ), - QStringLiteral( "DDIC_STRG" ), - QStringLiteral( "DDIC_STXT" ), - QStringLiteral( "DDIC_TEXT" ), - QStringLiteral( "DDIC_TIMS" ), - QStringLiteral( "DDIC_UNIT" ), - QStringLiteral( "DDIC_UTCL" ), - QStringLiteral( "DDIC_UTCM" ), - QStringLiteral( "DDIC_UTCS" ), - QStringLiteral( "DDIC_VARC" ), - QStringLiteral( "DDIC_WEEK" ), - QStringLiteral( "DDL" ), - QStringLiteral( "DEACTIVATE" ), - QStringLiteral( "DEBUG" ), - QStringLiteral( "DEBUGGER" ), - QStringLiteral( "DEC" ), - QStringLiteral( "DECIMAL" ), - QStringLiteral( "DECLARE" ), - QStringLiteral( "DEFAULT" ), - QStringLiteral( "DEFAULTVIEW" ), - QStringLiteral( "DEFERRED" ), - QStringLiteral( "DEFINER" ), - QStringLiteral( "DEFINITION" ), - QStringLiteral( "DEFRAGMENT" ), - QStringLiteral( "DELAY" ), - QStringLiteral( "DELETE" ), - QStringLiteral( "DELIMITED" ), - QStringLiteral( "DELTA" ), - QStringLiteral( "DENSE_RANK" ), - QStringLiteral( "DEPENDENCIES" ), - QStringLiteral( "DEPENDENCY" ), - QStringLiteral( "DEPENDENT" ), - QStringLiteral( "DEPTH" ), - QStringLiteral( "DESC" ), - QStringLiteral( "DESCRIPTION" ), - QStringLiteral( "DETACH" ), - QStringLiteral( "DETECTION" ), - QStringLiteral( "DETERMINISTIC" ), - QStringLiteral( "DEV_CS_ONLY" ), - QStringLiteral( "DEV_NO_SEMI_JOIN_REDUCTION_TARGET" ), - QStringLiteral( "DEV_PROC_CE" ), - QStringLiteral( "DEV_PROC_INLINE" ), - QStringLiteral( "DEV_PROC_L" ), - QStringLiteral( "DEV_PROC_NO_INLINE" ), - QStringLiteral( "DEV_PROC_SE_FT" ), - QStringLiteral( "DEV_RS_ONLY" ), - QStringLiteral( "DEV_SEMI_JOIN_REDUCTION_TARGET" ), - QStringLiteral( "DEVELOPMENT" ), - QStringLiteral( "DIFFERENTIAL" ), - QStringLiteral( "DISABLE" ), - QStringLiteral( "DISABLED" ), - QStringLiteral( "DISCONNECT" ), - QStringLiteral( "DISK" ), - QStringLiteral( "DISTANCE" ), - QStringLiteral( "DISTINCT" ), - QStringLiteral( "DISTRIBUTE" ), - QStringLiteral( "DISTRIBUTION" ), - QStringLiteral( "DO" ), - QStringLiteral( "DOCUMENT" ), - QStringLiteral( "DOCUMENTS" ), - QStringLiteral( "DOUBLE" ), - QStringLiteral( "DPSERVER" ), - QStringLiteral( "DROP" ), - QStringLiteral( "DTAB" ), - QStringLiteral( "DUPLICATES" ), - QStringLiteral( "DURATION" ), - QStringLiteral( "DW_OPTIMIZED" ), - QStringLiteral( "DYNAMIC" ), - QStringLiteral( "DYNAMIC_RANGE_THRESHOLD" ), - QStringLiteral( "EACH" ), - QStringLiteral( "EARTH" ), - QStringLiteral( "EDGE" ), - QStringLiteral( "ELEMENTS" ), - QStringLiteral( "ELLIPSOID" ), - QStringLiteral( "ELSE" ), - QStringLiteral( "ELSEIF" ), - QStringLiteral( "EMAIL" ), - QStringLiteral( "EMERGENCY" ), - QStringLiteral( "EMPTY" ), - QStringLiteral( "ENABLE" ), - QStringLiteral( "ENABLED" ), - QStringLiteral( "ENCLOSED" ), - QStringLiteral( "ENCODED" ), - QStringLiteral( "ENCODING" ), - QStringLiteral( "ENCRYPTED" ), - QStringLiteral( "ENCRYPTION" ), - QStringLiteral( "END" ), - QStringLiteral( "ENFORCED" ), - QStringLiteral( "ENTITY" ), - QStringLiteral( "ENTRY" ), - QStringLiteral( "EPM" ), - QStringLiteral( "EPS" ), - QStringLiteral( "EQ" ), - QStringLiteral( "EQUIDISTANT" ), - QStringLiteral( "ERROR" ), - QStringLiteral( "ES" ), - QStringLiteral( "ESCAPE" ), - QStringLiteral( "ESTIMATE" ), - QStringLiteral( "ESTIMATED" ), - QStringLiteral( "ESTIMATION" ), - QStringLiteral( "EVENT" ), - QStringLiteral( "EVENTS" ), - QStringLiteral( "EVERY" ), - QStringLiteral( "EVICTION" ), - QStringLiteral( "EXACT" ), - QStringLiteral( "EXCEPT" ), - QStringLiteral( "EXCEPTION" ), - QStringLiteral( "EXCLUDE" ), - QStringLiteral( "EXCLUDED" ), - QStringLiteral( "EXCLUSIVE" ), - QStringLiteral( "EXEC" ), - QStringLiteral( "EXECUTE" ), - QStringLiteral( "EXECUTION" ), - QStringLiteral( "EXISTING" ), - QStringLiteral( "EXISTS" ), - QStringLiteral( "EXIT" ), - QStringLiteral( "EXPLAIN" ), - QStringLiteral( "EXPLICIT" ), - QStringLiteral( "EXPORT" ), - QStringLiteral( "EXPRESSION" ), - QStringLiteral( "EXPRESSIONFLAGS" ), - QStringLiteral( "EXTENDED" ), - QStringLiteral( "EXTERNAL" ), - QStringLiteral( "EXTERNAL_BACKUP_ID" ), - QStringLiteral( "EXTERNALATTRIBUTE" ), - QStringLiteral( "EXTERNALLY" ), - QStringLiteral( "EXTRACT" ), - QStringLiteral( "FACT" ), - QStringLiteral( "FACTOR" ), - QStringLiteral( "FAIL" ), - QStringLiteral( "FALLBACK" ), - QStringLiteral( "FALSE" ), - QStringLiteral( "FAST" ), - QStringLiteral( "FBO" ), - QStringLiteral( "FETCH" ), - QStringLiteral( "FIELD" ), - QStringLiteral( "FILE" ), - QStringLiteral( "FILL" ), - QStringLiteral( "FILLFACTOR" ), - QStringLiteral( "FILTER" ), - QStringLiteral( "FINALIZE" ), - QStringLiteral( "FINISH" ), - QStringLiteral( "FIRST" ), - QStringLiteral( "FLAG" ), - QStringLiteral( "FLAGS" ), - QStringLiteral( "FLATTEN" ), - QStringLiteral( "FLATTENING" ), - QStringLiteral( "FLOAT" ), - QStringLiteral( "FLUSH" ), - QStringLiteral( "FN" ), - QStringLiteral( "FOLLOWING" ), - QStringLiteral( "FOLLOWS" ), - QStringLiteral( "FOR" ), - QStringLiteral( "FORCE" ), - QStringLiteral( "FORCE_FIRST_PASSWORD_CHANGE" ), - QStringLiteral( "FORCE_RESULT_CACHE_REFRESH" ), - QStringLiteral( "FOREIGN" ), - QStringLiteral( "FOREVER" ), - QStringLiteral( "FORGY" ), - QStringLiteral( "FORMAT" ), - QStringLiteral( "FORMULA" ), - QStringLiteral( "FREESTYLESEARCHATTRIBUTE" ), - QStringLiteral( "FREESTYLETRANSLATION" ), - QStringLiteral( "FROM" ), - QStringLiteral( "FULL" ), - QStringLiteral( "FULLTEXT" ), - QStringLiteral( "FUNCTION" ), - QStringLiteral( "FUNCTION_PROFILER" ), - QStringLiteral( "FUZZINESSTHRESHOLD" ), - QStringLiteral( "FUZZY" ), - QStringLiteral( "GB" ), - QStringLiteral( "GENERATED" ), - QStringLiteral( "GET_NUM_SERVERS" ), - QStringLiteral( "GLOBAL" ), - QStringLiteral( "GLOBALDICT" ), - QStringLiteral( "GLOBALLY" ), - QStringLiteral( "GOTO" ), - QStringLiteral( "GRANT" ), - QStringLiteral( "GRANTED" ), - QStringLiteral( "GRAPH" ), - QStringLiteral( "GREATEST" ), - QStringLiteral( "GRID" ), - QStringLiteral( "GROUP" ), - QStringLiteral( "GROUP_NAME" ), - QStringLiteral( "GROUP_TYPE" ), - QStringLiteral( "GROUPING" ), - QStringLiteral( "GROUPING_FILTER" ), - QStringLiteral( "GROUPING_ID" ), - QStringLiteral( "GROUPS" ), - QStringLiteral( "GT" ), - QStringLiteral( "GUID" ), - QStringLiteral( "HANDLED" ), - QStringLiteral( "HANDOVER" ), - QStringLiteral( "HAS" ), - QStringLiteral( "HASANYPRIVILEGES" ), - QStringLiteral( "HASH" ), - QStringLiteral( "HASH_JOIN" ), - QStringLiteral( "HASSYSTEMPRIVILEGE" ), - QStringLiteral( "HAVING" ), - QStringLiteral( "HEXAGON" ), - QStringLiteral( "HEXTOBIN" ), - QStringLiteral( "HIDDEN" ), - QStringLiteral( "HIERARCHY" ), - QStringLiteral( "HIERARCHY_ANCESTORS" ), - QStringLiteral( "HIERARCHY_ANCESTORS_AGGREGATE" ), - QStringLiteral( "HIERARCHY_DESCENDANTS" ), - QStringLiteral( "HIERARCHY_DESCENDANTS_AGGREGATE" ), - QStringLiteral( "HIERARCHY_LEVELED" ), - QStringLiteral( "HIERARCHY_SIBLINGS" ), - QStringLiteral( "HIERARCHY_SPANTREE" ), - QStringLiteral( "HIERARCHY_TEMPORAL" ), - QStringLiteral( "HIERARCHYCHARACTERISTIC" ), - QStringLiteral( "HIERARCHYINDEX" ), - QStringLiteral( "HIERARCHYNAME" ), - QStringLiteral( "HIGH" ), - QStringLiteral( "HIGHLIGHTED" ), - QStringLiteral( "HILBERT" ), - QStringLiteral( "HINT" ), - QStringLiteral( "HISTOGRAM" ), - QStringLiteral( "HISTORY" ), - QStringLiteral( "HOLD" ), - QStringLiteral( "HORIZONTAL" ), - QStringLiteral( "HOST" ), - QStringLiteral( "HOSTS" ), - QStringLiteral( "HOUR" ), - QStringLiteral( "HOUSENUMBER" ), - QStringLiteral( "ID" ), - QStringLiteral( "IDENTICAL" ), - QStringLiteral( "IDENTIFIED" ), - QStringLiteral( "IDENTIFIER" ), - QStringLiteral( "IDENTITY" ), - QStringLiteral( "IF" ), - QStringLiteral( "IFNULL" ), - QStringLiteral( "IGNORE" ), - QStringLiteral( "IMMEDIATE" ), - QStringLiteral( "IMPORT" ), - QStringLiteral( "IN" ), - QStringLiteral( "INCLUDE" ), - QStringLiteral( "INCREMENT" ), - QStringLiteral( "INCREMENTAL" ), - QStringLiteral( "INDEPENDENT" ), - QStringLiteral( "INDEX" ), - QStringLiteral( "INDEX_JOIN" ), - QStringLiteral( "INDEX_UNION" ), - QStringLiteral( "INDEXALIAS" ), - QStringLiteral( "INDEXED" ), - QStringLiteral( "INDEXES" ), - QStringLiteral( "INDEXID" ), - QStringLiteral( "INDEXTYPE" ), - QStringLiteral( "INDIVIDUAL" ), - QStringLiteral( "INFO" ), - QStringLiteral( "INHERITS" ), - QStringLiteral( "INIFILE" ), - QStringLiteral( "INIT" ), - QStringLiteral( "INITIAL" ), - QStringLiteral( "INITIAL_PARTITIONS" ), - QStringLiteral( "INITIALLY" ), - QStringLiteral( "INLINE" ), - QStringLiteral( "INNER" ), - QStringLiteral( "INOUT" ), - QStringLiteral( "INSENSITIVE" ), - QStringLiteral( "INSERT" ), - QStringLiteral( "INSTEAD" ), - QStringLiteral( "INSTR" ), - QStringLiteral( "INT" ), - QStringLiteral( "INTEGER" ), - QStringLiteral( "INTERNAL" ), - QStringLiteral( "INTERSECT" ), - QStringLiteral( "INTERVAL" ), - QStringLiteral( "INTO" ), - QStringLiteral( "INVALID" ), - QStringLiteral( "INVERSE" ), - QStringLiteral( "INVERTED" ), - QStringLiteral( "INVOKER" ), - QStringLiteral( "IS" ), - QStringLiteral( "IS_EMPTY" ), - QStringLiteral( "ISAUTHORIZED" ), - QStringLiteral( "ISMEMORYINDEX" ), - QStringLiteral( "ISOLATION" ), - QStringLiteral( "ISSUER" ), - QStringLiteral( "ISTOTAL" ), - QStringLiteral( "ISTRANSACTIONAL" ), - QStringLiteral( "JOB" ), - QStringLiteral( "JOIN" ), - QStringLiteral( "JOINCONDITION" ), - QStringLiteral( "JOININDEX" ), - QStringLiteral( "JOININDEXESTIMATION" ), - QStringLiteral( "JOININDEXTYPE" ), - QStringLiteral( "JOINPATH" ), - QStringLiteral( "JSON" ), - QStringLiteral( "JSON_QUERY" ), - QStringLiteral( "JSON_TABLE" ), - QStringLiteral( "JSON_VALUE" ), - QStringLiteral( "JWT" ), - QStringLiteral( "KB" ), - QStringLiteral( "KEEP" ), - QStringLiteral( "KERBEROS" ), - QStringLiteral( "KERNEL" ), - QStringLiteral( "KERNELTRACE" ), - QStringLiteral( "KEY" ), - QStringLiteral( "KEYATTRIBUTE" ), - QStringLiteral( "KEYCOPY" ), - QStringLiteral( "KEYFIGURE" ), - QStringLiteral( "KEYPAIR" ), - QStringLiteral( "KEYS" ), - QStringLiteral( "KEYVALUE" ), - QStringLiteral( "KMEANS" ), - QStringLiteral( "L" ), - QStringLiteral( "LABEL" ), - QStringLiteral( "LAG" ), - QStringLiteral( "LANGUAGE" ), - QStringLiteral( "LAST" ), - QStringLiteral( "LAST_DAY" ), - QStringLiteral( "LATENCY" ), - QStringLiteral( "LATERAL" ), - QStringLiteral( "LAYOUT" ), - QStringLiteral( "LDAP" ), - QStringLiteral( "LEAD" ), - QStringLiteral( "LEADING" ), - QStringLiteral( "LEAF" ), - QStringLiteral( "LEAST" ), - QStringLiteral( "LEAVES" ), - QStringLiteral( "LEFT" ), - QStringLiteral( "LENGTH" ), - QStringLiteral( "LENGTHB" ), - QStringLiteral( "LEVEL" ), - QStringLiteral( "LEVELNUMBERATTRIBUTE" ), - QStringLiteral( "LEVELS" ), - QStringLiteral( "LEVELTEXTATTRIBUTE" ), - QStringLiteral( "LIBRARY" ), - QStringLiteral( "LICENSE" ), - QStringLiteral( "LIFETIME" ), - QStringLiteral( "LIKE" ), - QStringLiteral( "LIKE_REGEXPR" ), - QStringLiteral( "LIMIT" ), - QStringLiteral( "LINE" ), - QStringLiteral( "LINEAR" ), - QStringLiteral( "LINKED" ), - QStringLiteral( "LIST" ), - QStringLiteral( "LOAD" ), - QStringLiteral( "LOAD_HISTORY" ), - QStringLiteral( "LOADABLE" ), - QStringLiteral( "LOB" ), - QStringLiteral( "LOCAL" ), - QStringLiteral( "LOCALE" ), - QStringLiteral( "LOCATE" ), - QStringLiteral( "LOCATE_REGEXPR" ), - QStringLiteral( "LOCATION" ), - QStringLiteral( "LOCATIONS" ), - QStringLiteral( "LOCK" ), - QStringLiteral( "LOCKED" ), - QStringLiteral( "LOG" ), - QStringLiteral( "LOGFLUSH" ), - QStringLiteral( "LOGGING" ), - QStringLiteral( "LONGDATE" ), - QStringLiteral( "LOOKUP" ), - QStringLiteral( "LOOP" ), - QStringLiteral( "LOOPBACK" ), - QStringLiteral( "LPAD" ), - QStringLiteral( "LTRIM" ), - QStringLiteral( "MACROS" ), - QStringLiteral( "MAIN" ), - QStringLiteral( "MAJOR" ), - QStringLiteral( "MANAGEMENT" ), - QStringLiteral( "MANUAL" ), - QStringLiteral( "MANY" ), - QStringLiteral( "MAP" ), - QStringLiteral( "MAP_MERGE" ), - QStringLiteral( "MAP_REDUCE" ), - QStringLiteral( "MAPPING" ), - QStringLiteral( "MASK" ), - QStringLiteral( "MATCHED" ), - QStringLiteral( "MATCHES" ), - QStringLiteral( "MATCHING" ), - QStringLiteral( "MAXITERATIONS" ), - QStringLiteral( "MAXVALUE" ), - QStringLiteral( "MB" ), - QStringLiteral( "MDRS_TEST" ), - QStringLiteral( "MDX" ), - QStringLiteral( "MEASURE" ), - QStringLiteral( "MEASURES" ), - QStringLiteral( "MEDIUM" ), - QStringLiteral( "MEMBER" ), - QStringLiteral( "MEMORY" ), - QStringLiteral( "MERGE" ), - QStringLiteral( "MESSAGING" ), - QStringLiteral( "META" ), - QStringLiteral( "METADATA" ), - QStringLiteral( "MIGRATE" ), - QStringLiteral( "MIME" ), - QStringLiteral( "MIN_ROWS_FOR_PARTITIONING" ), - QStringLiteral( "MINING" ), - QStringLiteral( "MINOR" ), - QStringLiteral( "MINPTS" ), - QStringLiteral( "MINUS" ), - QStringLiteral( "MINUTE" ), - QStringLiteral( "MINUTES" ), - QStringLiteral( "MINVALUE" ), - QStringLiteral( "MISSING" ), - QStringLiteral( "MODE" ), - QStringLiteral( "MODEL" ), - QStringLiteral( "MODIFIED" ), - QStringLiteral( "MODIFY" ), - QStringLiteral( "MODULE" ), - QStringLiteral( "MONITOR" ), - QStringLiteral( "MONITORING" ), - QStringLiteral( "MONTH" ), - QStringLiteral( "MOVABLE" ), - QStringLiteral( "MOVE" ), - QStringLiteral( "MULTIPARENT" ), - QStringLiteral( "MULTIPLE" ), - QStringLiteral( "MULTIPROVIDERCONFIG" ), - QStringLiteral( "MVCC_SNAPSHOT_TIMESTAMP" ), - QStringLiteral( "NAME" ), - QStringLiteral( "NATIONAL" ), - QStringLiteral( "NATURAL" ), - QStringLiteral( "NCHAR" ), - QStringLiteral( "NCLOB" ), - QStringLiteral( "NEAREST" ), - QStringLiteral( "NEIGHBORS" ), - QStringLiteral( "NESTED" ), - QStringLiteral( "NESTED_LOOP_JOIN" ), - QStringLiteral( "NETAPP" ), - QStringLiteral( "NEW" ), - QStringLiteral( "NEWFACTTABLE" ), - QStringLiteral( "NEXT" ), - QStringLiteral( "NEXT_DAY" ), - QStringLiteral( "NEXTVAL" ), - QStringLiteral( "NO" ), - QStringLiteral( "NO_CALC_DIMENSION" ), - QStringLiteral( "NO_DISTINCT_FILTER" ), - QStringLiteral( "NO_INDEX" ), - QStringLiteral( "NO_INLINE" ), - QStringLiteral( "NO_ROUTE_TO" ), - QStringLiteral( "NO_USE_C2C_CONV" ), - QStringLiteral( "NO_USE_OLAP_PLAN" ), - QStringLiteral( "NO_USE_TRANSFORMATION" ), - QStringLiteral( "NO_VIRTUAL_TABLE_REPLICA" ), - QStringLiteral( "NOCOMPRESS" ), - QStringLiteral( "NODE" ), - QStringLiteral( "NON" ), - QStringLiteral( "NONE" ), - QStringLiteral( "NONLEAF" ), - QStringLiteral( "NOT" ), - QStringLiteral( "NOW" ), - QStringLiteral( "NOWAIT" ), - QStringLiteral( "NTEXT" ), - QStringLiteral( "NTILE" ), - QStringLiteral( "NULL" ), - QStringLiteral( "NULLABLE" ), - QStringLiteral( "NULLIF" ), - QStringLiteral( "NULLS" ), - QStringLiteral( "NUMA" ), - QStringLiteral( "NUMA_NODE_INDEXES" ), - QStringLiteral( "NUMBER" ), - QStringLiteral( "NUMERIC" ), - QStringLiteral( "NVARCHAR" ), - QStringLiteral( "OBJECT" ), - QStringLiteral( "OBJECTS" ), - QStringLiteral( "OCCURRENCE" ), - QStringLiteral( "OCCURRENCES_REGEXPR" ), - QStringLiteral( "ODATA" ), - QStringLiteral( "OF" ), - QStringLiteral( "OFF" ), - QStringLiteral( "OFFSET" ), - QStringLiteral( "OJ" ), - QStringLiteral( "OLAP" ), - QStringLiteral( "OLAP_PARALLEL_AGGREGATION" ), - QStringLiteral( "OLAP_SERIAL_AGGREGATION" ), - QStringLiteral( "OLD" ), - QStringLiteral( "OLYMP" ), - QStringLiteral( "ON" ), - QStringLiteral( "ONE" ), - QStringLiteral( "ONLINE" ), - QStringLiteral( "ONLY" ), - QStringLiteral( "OPEN" ), - QStringLiteral( "OPENCYPHER_TABLE" ), - QStringLiteral( "OPERATION" ), - QStringLiteral( "OPERATOR" ), - QStringLiteral( "OPTIMIZATION" ), - QStringLiteral( "OPTIMIZEMETAMODEL" ), - QStringLiteral( "OPTIMIZER" ), - QStringLiteral( "OPTION" ), - QStringLiteral( "OPTIONALLY" ), - QStringLiteral( "OR" ), - QStringLiteral( "ORDER" ), - QStringLiteral( "ORDINALITY" ), - QStringLiteral( "ORGANIZATION" ), - QStringLiteral( "ORPHAN" ), - QStringLiteral( "OS" ), - QStringLiteral( "OTHERS" ), - QStringLiteral( "OUT" ), - QStringLiteral( "OUTER" ), - QStringLiteral( "OVER" ), - QStringLiteral( "OVERLAY" ), - QStringLiteral( "OVERRIDE" ), - QStringLiteral( "OVERRIDING" ), - QStringLiteral( "OVERVIEW" ), - QStringLiteral( "OWN" ), - QStringLiteral( "OWNED" ), - QStringLiteral( "OWNER" ), - QStringLiteral( "PACKAGE" ), - QStringLiteral( "PAGE" ), - QStringLiteral( "PAGE_LOADABLE" ), - QStringLiteral( "PAGES" ), - QStringLiteral( "PARALLEL" ), - QStringLiteral( "PARALLELIZED" ), - QStringLiteral( "PARAMETER" ), - QStringLiteral( "PARAMETERS" ), - QStringLiteral( "PARENT" ), - QStringLiteral( "PARENTSATTRIBUTE" ), - QStringLiteral( "PARQUET" ), - QStringLiteral( "PART" ), - QStringLiteral( "PARTIAL" ), - QStringLiteral( "PARTITION" ), - QStringLiteral( "PARTITIONING" ), - QStringLiteral( "PARTITIONS" ), - QStringLiteral( "PARTS" ), - QStringLiteral( "PASS" ), - QStringLiteral( "PASSING" ), - QStringLiteral( "PASSPORT_TRACELEVEL" ), - QStringLiteral( "PASSWORD" ), - QStringLiteral( "PATH" ), - QStringLiteral( "PERCENT" ), - QStringLiteral( "PERCENT_RANK" ), - QStringLiteral( "PERCENTILE_CONT" ), - QStringLiteral( "PERCENTILE_DISC" ), - QStringLiteral( "PERFTRACE" ), - QStringLiteral( "PERIOD" ), - QStringLiteral( "PERSISTENCE" ), - QStringLiteral( "PERSISTENT" ), - QStringLiteral( "PERSISTENT_MEMORY" ), - QStringLiteral( "PHRASE" ), - QStringLiteral( "PHYSICAL" ), - QStringLiteral( "PIN" ), - QStringLiteral( "PLACEMENT" ), - QStringLiteral( "PLAIN" ), - QStringLiteral( "PLAN" ), - QStringLiteral( "PLAN_EXECUTION" ), - QStringLiteral( "PLANAR" ), - QStringLiteral( "PLANNING" ), - QStringLiteral( "PLANVIZ" ), - QStringLiteral( "POBJECTKEY" ), - QStringLiteral( "POLICY" ), - QStringLiteral( "POLYGON" ), - QStringLiteral( "PORT" ), - QStringLiteral( "PORTION" ), - QStringLiteral( "POSITION" ), - QStringLiteral( "POSTCODE" ), - QStringLiteral( "PPROPERTYNAME" ), - QStringLiteral( "PRECEDES" ), - QStringLiteral( "PRECEDING" ), - QStringLiteral( "PRECISION" ), - QStringLiteral( "PREDEFINED" ), - QStringLiteral( "PREFERENCE" ), - QStringLiteral( "PREFERRED" ), - QStringLiteral( "PREFIX" ), - QStringLiteral( "PRELOAD" ), - QStringLiteral( "PREPROCESS" ), - QStringLiteral( "PRESERVE" ), - QStringLiteral( "PREVIOUS" ), - QStringLiteral( "PRIMARY" ), - QStringLiteral( "PRINCIPAL" ), - QStringLiteral( "PRIOR" ), - QStringLiteral( "PRIORITY" ), - QStringLiteral( "PRIVATE" ), - QStringLiteral( "PRIVILEGE" ), - QStringLiteral( "PRIVILEGES" ), - QStringLiteral( "PROCEDURE" ), - QStringLiteral( "PROCESS" ), - QStringLiteral( "PRODUCT" ), - QStringLiteral( "PROFILE" ), - QStringLiteral( "PROFILER" ), - QStringLiteral( "PROJECTION" ), - QStringLiteral( "PROPERTIES" ), - QStringLiteral( "PROPERTY" ), - QStringLiteral( "PROTOCOL" ), - QStringLiteral( "PROVIDER" ), - QStringLiteral( "PRUNING" ), - QStringLiteral( "PSE" ), - QStringLiteral( "PTIME" ), - QStringLiteral( "PUBLIC" ), - QStringLiteral( "PURPOSE" ), - QStringLiteral( "PVALUENAME" ), - QStringLiteral( "QERROR" ), - QStringLiteral( "QTHETA" ), - QStringLiteral( "QUERY" ), - QStringLiteral( "QUEUE" ), - QStringLiteral( "RAISE" ), - QStringLiteral( "RANDOM" ), - QStringLiteral( "RANGE" ), - QStringLiteral( "RANK" ), - QStringLiteral( "RATIO" ), - QStringLiteral( "RAW" ), - QStringLiteral( "RDICT" ), - QStringLiteral( "READ" ), - QStringLiteral( "READS" ), - QStringLiteral( "REAL" ), - QStringLiteral( "REALTIME" ), - QStringLiteral( "REBUILD" ), - QStringLiteral( "RECLAIM" ), - QStringLiteral( "RECOMPILE" ), - QStringLiteral( "RECOMPILED" ), - QStringLiteral( "RECONFIGURE" ), - QStringLiteral( "RECORD" ), - QStringLiteral( "RECORD_COMMIT_TIMESTAMP" ), - QStringLiteral( "RECORD_COUNT" ), - QStringLiteral( "RECORD_ID" ), - QStringLiteral( "RECORDS" ), - QStringLiteral( "RECOVER" ), - QStringLiteral( "RECOVERY" ), - QStringLiteral( "RECURSIVE" ), - QStringLiteral( "REFERENCE" ), - QStringLiteral( "REFERENCES" ), - QStringLiteral( "REFERENCING" ), - QStringLiteral( "REFRESH" ), - QStringLiteral( "REGISTER" ), - QStringLiteral( "RELEASE" ), - QStringLiteral( "RELOAD" ), - QStringLiteral( "REMOTE" ), - QStringLiteral( "REMOTE_EXECUTE_QUERY" ), - QStringLiteral( "REMOTE_SCAN" ), - QStringLiteral( "REMOVE" ), - QStringLiteral( "RENAME" ), - QStringLiteral( "REORGANIZE" ), - QStringLiteral( "REPARTITIONING_THRESHOLD" ), - QStringLiteral( "REPEATABLE" ), - QStringLiteral( "REPLACE" ), - QStringLiteral( "REPLACE_REGEXPR" ), - QStringLiteral( "REPLAY" ), - QStringLiteral( "REPLICA" ), - QStringLiteral( "REPLICA_COUNT" ), - QStringLiteral( "REPLICA_TYPE" ), - QStringLiteral( "REPLICAS" ), - QStringLiteral( "REPLICATION" ), - QStringLiteral( "REPOSITORY" ), - QStringLiteral( "RESERVE" ), - QStringLiteral( "RESET" ), - QStringLiteral( "RESIGNAL" ), - QStringLiteral( "RESOURCE" ), - QStringLiteral( "RESTART" ), - QStringLiteral( "RESTORE" ), - QStringLiteral( "RESTRICT" ), - QStringLiteral( "RESTRICTED" ), - QStringLiteral( "RESTRICTION" ), - QStringLiteral( "RESULT" ), - QStringLiteral( "RESULT_LAG" ), - QStringLiteral( "RESULTSETS" ), - QStringLiteral( "RESUME" ), - QStringLiteral( "RETAIN" ), - QStringLiteral( "RETENTION" ), - QStringLiteral( "RETRY" ), - QStringLiteral( "RETURN" ), - QStringLiteral( "RETURNING" ), - QStringLiteral( "RETURNS" ), - QStringLiteral( "REVERSE" ), - QStringLiteral( "REVOKE" ), - QStringLiteral( "RIGHT" ), - QStringLiteral( "ROLE" ), - QStringLiteral( "ROLEGROUP" ), - QStringLiteral( "ROLLBACK" ), - QStringLiteral( "ROLLUP" ), - QStringLiteral( "ROOT" ), - QStringLiteral( "ROOT_STATEMENT_HASH" ), - QStringLiteral( "ROUND" ), - QStringLiteral( "ROUND_CEILING" ), - QStringLiteral( "ROUND_DOWN" ), - QStringLiteral( "ROUND_FLOOR" ), - QStringLiteral( "ROUND_HALF_DOWN" ), - QStringLiteral( "ROUND_HALF_EVEN" ), - QStringLiteral( "ROUND_HALF_UP" ), - QStringLiteral( "ROUND_UP" ), - QStringLiteral( "ROUNDROBIN" ), - QStringLiteral( "ROUTE" ), - QStringLiteral( "ROUTE_BY" ), - QStringLiteral( "ROUTE_BY_CARDINALITY" ), - QStringLiteral( "ROUTE_TO" ), - QStringLiteral( "ROW" ), - QStringLiteral( "ROW_NUMBER" ), - QStringLiteral( "ROWCOUNT" ), - QStringLiteral( "ROWID" ), - QStringLiteral( "ROWS" ), - QStringLiteral( "RPAD" ), - QStringLiteral( "RTREE" ), - QStringLiteral( "RTRIM" ), - QStringLiteral( "RULE" ), - QStringLiteral( "RULES" ), - QStringLiteral( "RUNTIME" ), - QStringLiteral( "RUNTIMEDUMP" ), - QStringLiteral( "SAME_PARTITION_COUNT" ), - QStringLiteral( "SAML" ), - QStringLiteral( "SAMPLE" ), - QStringLiteral( "SAMPLING" ), - QStringLiteral( "SAP_TIMEZONE_DATASET" ), - QStringLiteral( "SATISFIES" ), - QStringLiteral( "SAVE" ), - QStringLiteral( "SAVEPOINT" ), - QStringLiteral( "SCAN" ), - QStringLiteral( "SCENARIO" ), - QStringLiteral( "SCHEDULER" ), - QStringLiteral( "SCHEMA" ), - QStringLiteral( "SCHEMA_NAME" ), - QStringLiteral( "SCORE" ), - QStringLiteral( "SCRAMBLE" ), - QStringLiteral( "SCROLL" ), - QStringLiteral( "SEARCH" ), - QStringLiteral( "SECOND" ), - QStringLiteral( "SECONDDATE" ), - QStringLiteral( "SECONDS_BETWEEN" ), - QStringLiteral( "SECONDTIME" ), - QStringLiteral( "SECTIONS" ), - QStringLiteral( "SECURE" ), - QStringLiteral( "SECURITY" ), - QStringLiteral( "SEED" ), - QStringLiteral( "SELECT" ), - QStringLiteral( "SEMANTICRELATION" ), - QStringLiteral( "SEMI" ), - QStringLiteral( "SENSITIVE" ), - QStringLiteral( "SEPARATORS" ), - QStringLiteral( "SEQUENCE" ), - QStringLiteral( "SEQUENTIAL" ), - QStringLiteral( "SERIALIZABLE" ), - QStringLiteral( "SERIES" ), - QStringLiteral( "SERIES_ELEMENT_TO_PERIOD" ), - QStringLiteral( "SERIES_PERIOD_TO_ELEMENT" ), - QStringLiteral( "SERIES_ROUND" ), - QStringLiteral( "SERVICE" ), - QStringLiteral( "SERVICES" ), - QStringLiteral( "SESSION" ), - QStringLiteral( "SESSION_CONTEXT" ), - QStringLiteral( "SESSION_USER" ), - QStringLiteral( "SET" ), - QStringLiteral( "SETOLAPMODEL" ), - QStringLiteral( "SETS" ), - QStringLiteral( "SHAPEFILE" ), - QStringLiteral( "SHARE" ), - QStringLiteral( "SHARED" ), - QStringLiteral( "SHOW" ), - QStringLiteral( "SIBLING" ), - QStringLiteral( "SIDATTRIBUTE" ), - QStringLiteral( "SIGNAL" ), - QStringLiteral( "SIMPLE" ), - QStringLiteral( "SITE" ), - QStringLiteral( "SIZE" ), - QStringLiteral( "SKETCH" ), - QStringLiteral( "SKIP" ), - QStringLiteral( "SMALLDECIMAL" ), - QStringLiteral( "SMALLINT" ), - QStringLiteral( "SNAP" ), - QStringLiteral( "SNAPINT" ), - QStringLiteral( "SNAPSHOT" ), - QStringLiteral( "SOME" ), - QStringLiteral( "SORT" ), - QStringLiteral( "SOURCE" ), - QStringLiteral( "SPACE" ), - QStringLiteral( "SPARSIFY" ), - QStringLiteral( "SPATIAL" ), - QStringLiteral( "SPLITFACTOR" ), - QStringLiteral( "SQL" ), - QStringLiteral( "SQL_ERROR_CODE" ), - QStringLiteral( "SQLSCRIPT" ), - QStringLiteral( "SRID" ), - QStringLiteral( "SSL" ), - QStringLiteral( "STAB" ), - QStringLiteral( "STANDARD" ), - QStringLiteral( "START" ), - QStringLiteral( "STATEMENT" ), - QStringLiteral( "STATEMENT_NAME" ), - QStringLiteral( "STATIC" ), - QStringLiteral( "STATISTICS" ), - QStringLiteral( "STOP" ), - QStringLiteral( "STORAGE" ), - QStringLiteral( "STORE" ), - QStringLiteral( "STRING" ), - QStringLiteral( "STRIP" ), - QStringLiteral( "STRUCTURED" ), - QStringLiteral( "STRUCTUREDPRIVILEGE" ), - QStringLiteral( "SUB_TYPE" ), - QStringLiteral( "SUBJECT" ), - QStringLiteral( "SUBPARTITION" ), - QStringLiteral( "SUBPARTITIONS" ), - QStringLiteral( "SUBSCRIPTION" ), - QStringLiteral( "SUBSTR" ), - QStringLiteral( "SUBSTR_AFTER" ), - QStringLiteral( "SUBSTR_BEFORE" ), - QStringLiteral( "SUBSTR_REGEXPR" ), - QStringLiteral( "SUBSTRING" ), - QStringLiteral( "SUBSTRING_REGEXPR" ), - QStringLiteral( "SUBTOTAL" ), - QStringLiteral( "SUBTYPE" ), - QStringLiteral( "SUCCESSFUL" ), - QStringLiteral( "SUPPORT" ), - QStringLiteral( "SUSPEND" ), - QStringLiteral( "SYNC" ), - QStringLiteral( "SYNCHRONOUS" ), - QStringLiteral( "SYNONYM" ), - QStringLiteral( "SYSLOG" ), - QStringLiteral( "SYSTEM" ), - QStringLiteral( "SYSTEM_TIME" ), - QStringLiteral( "SYSTEMS" ), - QStringLiteral( "SYSUUID" ), - QStringLiteral( "T" ), - QStringLiteral( "TABLE" ), - QStringLiteral( "TABLE_NAME" ), - QStringLiteral( "TABLES" ), - QStringLiteral( "TABLESAMPLE" ), - QStringLiteral( "TAKEOVER" ), - QStringLiteral( "TARGET" ), - QStringLiteral( "TASK" ), - QStringLiteral( "TB" ), - QStringLiteral( "TEMPLATEINDEX" ), - QStringLiteral( "TEMPORARY" ), - QStringLiteral( "TENANT" ), - QStringLiteral( "TERM" ), - QStringLiteral( "TEXT" ), - QStringLiteral( "TEXTATTRIBUTE" ), - QStringLiteral( "THEN" ), - QStringLiteral( "THREAD" ), - QStringLiteral( "THREADS" ), - QStringLiteral( "THRESHOLD" ), - QStringLiteral( "THROW_ERROR" ), - QStringLiteral( "TIME" ), - QStringLiteral( "TIMELINE" ), - QStringLiteral( "TIMEOUT" ), - QStringLiteral( "TIMESTAMP" ), - QStringLiteral( "TIMEZONE" ), - QStringLiteral( "TIMS_EXTRACT" ), - QStringLiteral( "TINYINT" ), - QStringLiteral( "TM_CATEGORIZE_KNN" ), - QStringLiteral( "TM_GET_RELATED_DOCUMENTS" ), - QStringLiteral( "TM_GET_RELATED_TERMS" ), - QStringLiteral( "TM_GET_RELEVANT_DOCUMENTS" ), - QStringLiteral( "TM_GET_RELEVANT_TERMS" ), - QStringLiteral( "TM_GET_SUGGESTED_TERMS" ), - QStringLiteral( "TO" ), - QStringLiteral( "TO_BIGINT" ), - QStringLiteral( "TO_BINARY" ), - QStringLiteral( "TO_BLOB" ), - QStringLiteral( "TO_CHAR" ), - QStringLiteral( "TO_CLOB" ), - QStringLiteral( "TO_DATE" ), - QStringLiteral( "TO_DECIMAL" ), - QStringLiteral( "TO_DOUBLE" ), - QStringLiteral( "TO_INT" ), - QStringLiteral( "TO_INTEGER" ), - QStringLiteral( "TO_JSON_BOOLEAN" ), - QStringLiteral( "TO_JSON_NUMBER" ), - QStringLiteral( "TO_NCHAR" ), - QStringLiteral( "TO_NCLOB" ), - QStringLiteral( "TO_NUMBER" ), - QStringLiteral( "TO_NVARCHAR" ), - QStringLiteral( "TO_REAL" ), - QStringLiteral( "TO_SECONDDATE" ), - QStringLiteral( "TO_SMALLDECIMAL" ), - QStringLiteral( "TO_SMALLINT" ), - QStringLiteral( "TO_TIME" ), - QStringLiteral( "TO_TIMESTAMP" ), - QStringLiteral( "TO_TINYINT" ), - QStringLiteral( "TO_VARBINARY" ), - QStringLiteral( "TO_VARCHAR" ), - QStringLiteral( "TOKEN" ), - QStringLiteral( "TOLERANCE" ), - QStringLiteral( "TOOLOPTION" ), - QStringLiteral( "TOP" ), - QStringLiteral( "TOPK" ), - QStringLiteral( "TOTAL" ), - QStringLiteral( "TRACE" ), - QStringLiteral( "TRACEPROFILE" ), - QStringLiteral( "TRACES" ), - QStringLiteral( "TRAIL" ), - QStringLiteral( "TRAILING" ), - QStringLiteral( "TRANSACTION" ), - QStringLiteral( "TRANSFORM" ), - QStringLiteral( "TREE" ), - QStringLiteral( "TREX" ), - QStringLiteral( "TRIGGER" ), - QStringLiteral( "TRIGGER_UPDATE_COLUMN" ), - QStringLiteral( "TRIM" ), - QStringLiteral( "TRUE" ), - QStringLiteral( "TRUNCATE" ), - QStringLiteral( "TRUST" ), - QStringLiteral( "TS" ), - QStringLiteral( "TYPE" ), - QStringLiteral( "TYPENUMBERATTRIBUTE" ), - QStringLiteral( "TYPETEXTATTRIBUTE" ), - QStringLiteral( "UNAUTHORIZED" ), - QStringLiteral( "UNBOUNDED" ), - QStringLiteral( "UNCOMMITTED" ), - QStringLiteral( "UNCONDITIONAL" ), - QStringLiteral( "UNION" ), - QStringLiteral( "UNIQUE" ), - QStringLiteral( "UNIT" ), - QStringLiteral( "UNITCONVERSION" ), - QStringLiteral( "UNITCONVERSIONNAME" ), - QStringLiteral( "UNKNOWN" ), - QStringLiteral( "UNLOAD" ), - QStringLiteral( "UNLOCK" ), - QStringLiteral( "UNMASKED" ), - QStringLiteral( "UNNEST" ), - QStringLiteral( "UNPIN" ), - QStringLiteral( "UNREGISTER" ), - QStringLiteral( "UNSET" ), - QStringLiteral( "UNSUCCESSFUL" ), - QStringLiteral( "UNTIL" ), - QStringLiteral( "UNUSED" ), - QStringLiteral( "UP" ), - QStringLiteral( "UPDATE" ), - QStringLiteral( "UPSERT" ), - QStringLiteral( "URL" ), - QStringLiteral( "USAGE" ), - QStringLiteral( "USE_C2R_CONV" ), - QStringLiteral( "USE_COLUMN_JOIN_IMPLICIT_CAST" ), - QStringLiteral( "USE_OLAP_PLAN" ), - QStringLiteral( "USE_PREAGGR" ), - QStringLiteral( "USE_QUERY_MATCH" ), - QStringLiteral( "USE_R2C_CONV" ), - QStringLiteral( "USE_TRANSFORMATION" ), - QStringLiteral( "USE_UNION_OPT" ), - QStringLiteral( "USEINITIALREORG" ), - QStringLiteral( "USER" ), - QStringLiteral( "USERGROUP" ), - QStringLiteral( "USERS" ), - QStringLiteral( "USING" ), - QStringLiteral( "UTCTIMESTAMP" ), - QStringLiteral( "UTF16" ), - QStringLiteral( "UTF32" ), - QStringLiteral( "UTF8" ), - QStringLiteral( "VALID" ), - QStringLiteral( "VALIDATE" ), - QStringLiteral( "VALIDATED" ), - QStringLiteral( "VALIDATION" ), - QStringLiteral( "VALUE" ), - QStringLiteral( "VALUES" ), - QStringLiteral( "VARBINARY" ), - QStringLiteral( "VARCHAR" ), - QStringLiteral( "VARCHAR1" ), - QStringLiteral( "VARCHAR2" ), - QStringLiteral( "VARCHAR3" ), - QStringLiteral( "VARIABLE" ), - QStringLiteral( "VARYING" ), - QStringLiteral( "VERIFY" ), - QStringLiteral( "VERSION" ), - QStringLiteral( "VERSIONING" ), - QStringLiteral( "VERSIONS" ), - QStringLiteral( "VERTEX" ), - QStringLiteral( "VERTICAL" ), - QStringLiteral( "VIEW" ), - QStringLiteral( "VIEWATTRIBUTE" ), - QStringLiteral( "VIRTUAL" ), - QStringLiteral( "VOLUME" ), - QStringLiteral( "VOLUMES" ), - QStringLiteral( "WAIT" ), - QStringLiteral( "WAITGRAPH" ), - QStringLiteral( "WARNING" ), - QStringLiteral( "WEEKDAY" ), - QStringLiteral( "WEIGHT" ), - QStringLiteral( "WHEN" ), - QStringLiteral( "WHERE" ), - QStringLiteral( "WHILE" ), - QStringLiteral( "WHY_FOUND" ), - QStringLiteral( "WILDCARD" ), - QStringLiteral( "WINDOW" ), - QStringLiteral( "WITH" ), - QStringLiteral( "WITHIN" ), - QStringLiteral( "WITHOUT" ), - QStringLiteral( "WORK" ), - QStringLiteral( "WORKAROUND" ), - QStringLiteral( "WORKERGROUPS" ), - QStringLiteral( "WORKLOAD" ), - QStringLiteral( "WORKSPACE" ), - QStringLiteral( "WRAPPER" ), - QStringLiteral( "WRITE" ), - QStringLiteral( "X" ), - QStringLiteral( "X509" ), - QStringLiteral( "XML" ), - QStringLiteral( "XMLNAMESPACE" ), - QStringLiteral( "XMLTABLE" ), - QStringLiteral( "XTAB" ), - QStringLiteral( "Y" ), - QStringLiteral( "YEAR" ), - QStringLiteral( "YTAB" ), - QStringLiteral( "ZONE" ), - } - }, - { - Qgis::SqlKeywordCategory::Aggregate, - { - QStringLiteral( "AUTO_CORR" ), - QStringLiteral( "AVG" ), - QStringLiteral( "CORR" ), - QStringLiteral( "CORR_SPEARMAN" ), - QStringLiteral( "COUNT" ), - QStringLiteral( "CROSS_CORR" ), - QStringLiteral( "DFT" ), - QStringLiteral( "FIRST_VALUE" ), - QStringLiteral( "LAST_VALUE" ), - QStringLiteral( "MAX" ), - QStringLiteral( "MEDIAN" ), - QStringLiteral( "MIN" ), - QStringLiteral( "NTH_VALUE" ), - QStringLiteral( "STDDEV" ), - QStringLiteral( "STDDEV_POP" ), - QStringLiteral( "STDDEV_SAMP" ), - QStringLiteral( "STRING_AGG" ), - QStringLiteral( "SUM" ), - QStringLiteral( "VAR" ), - QStringLiteral( "VAR_POP" ), - QStringLiteral( "VAR_SAMP" ), - } - }, - { - Qgis::SqlKeywordCategory::Math, - { - QStringLiteral( "ABS" ), - QStringLiteral( "ACOS" ), - QStringLiteral( "ASIN" ), - QStringLiteral( "ATAN" ), - QStringLiteral( "ATAN2" ), - QStringLiteral( "BITAND" ), - QStringLiteral( "BITCOUNT" ), - QStringLiteral( "BITNOT" ), - QStringLiteral( "BITOR" ), - QStringLiteral( "BITSET" ), - QStringLiteral( "BITUNSET" ), - QStringLiteral( "BITXOR" ), - QStringLiteral( "CEIL" ), - QStringLiteral( "COS" ), - QStringLiteral( "COSH" ), - QStringLiteral( "COT" ), - QStringLiteral( "EXP" ), - QStringLiteral( "FLOOR" ), - QStringLiteral( "LN" ), - QStringLiteral( "LOG" ), - QStringLiteral( "MOD" ), - QStringLiteral( "NDIV0" ), - QStringLiteral( "POWER" ), - QStringLiteral( "RAND" ), - QStringLiteral( "RAND_SECURE" ), - QStringLiteral( "ROUND" ), - QStringLiteral( "SIGN" ), - QStringLiteral( "SIN" ), - QStringLiteral( "SINH" ), - QStringLiteral( "SQRT" ), - QStringLiteral( "TAN" ), - QStringLiteral( "TANH" ), - } - }, - { - Qgis::SqlKeywordCategory::Geospatial, - { - QStringLiteral( "ST_AlphaShape" ), - QStringLiteral( "ST_AlphaShapeAggr" ), - QStringLiteral( "ST_AlphaShapeArea" ), - QStringLiteral( "ST_AlphaShapeAreaAggr" ), - QStringLiteral( "ST_AlphaShapeEdge" ), - QStringLiteral( "ST_AlphaShapeEdgeAggr" ), - QStringLiteral( "ST_AsBinary" ), - QStringLiteral( "ST_AsEsriJSON" ), - QStringLiteral( "ST_AsEWKB" ), - QStringLiteral( "ST_AsEWKT" ), - QStringLiteral( "ST_AsGeoJSON" ), - QStringLiteral( "ST_AsSVG" ), - QStringLiteral( "ST_AsSVGAggr" ), - QStringLiteral( "ST_AsText" ), - QStringLiteral( "ST_AsWKB" ), - QStringLiteral( "ST_AsWKT" ), - QStringLiteral( "ST_Boundary" ), - QStringLiteral( "ST_Buffer" ), - QStringLiteral( "ST_CircularString" ), - QStringLiteral( "ST_Collect" ), - QStringLiteral( "ST_CollectAggr" ), - QStringLiteral( "ST_Contains" ), - QStringLiteral( "ST_ConvexHull" ), - QStringLiteral( "ST_ConvexHullAggr" ), - QStringLiteral( "ST_CoordDim" ), - QStringLiteral( "ST_CoveredBy" ), - QStringLiteral( "ST_Covers" ), - QStringLiteral( "ST_Crosses" ), - QStringLiteral( "ST_Difference" ), - QStringLiteral( "ST_Dimension" ), - QStringLiteral( "ST_Disjoint" ), - QStringLiteral( "ST_Distance" ), - QStringLiteral( "ST_Envelope" ), - QStringLiteral( "ST_EnvelopeAggr" ), - QStringLiteral( "ST_EnvelopeAggr" ), - QStringLiteral( "ST_Equals" ), - QStringLiteral( "ST_Force2D" ), - QStringLiteral( "ST_Force3DM" ), - QStringLiteral( "ST_Force3DZ" ), - QStringLiteral( "ST_Force4D" ), - QStringLiteral( "ST_GeoHash" ), - QStringLiteral( "ST_GeomFromEsriJSON" ), - QStringLiteral( "ST_GeomFromEWKB" ), - QStringLiteral( "ST_GeomFromEWKT" ), - QStringLiteral( "ST_GeomFromGeoHash" ), - QStringLiteral( "ST_GeomFromText" ), - QStringLiteral( "ST_GeomFromWKB" ), - QStringLiteral( "ST_GeomFromWKT" ), - QStringLiteral( "ST_GeometryCollection" ), - QStringLiteral( "ST_GeometryN" ), - QStringLiteral( "ST_GeometryType" ), - QStringLiteral( "ST_Intersection" ), - QStringLiteral( "ST_IntersectionAggr" ), - QStringLiteral( "ST_Intersects" ), - QStringLiteral( "ST_IntersectsFilter" ), - QStringLiteral( "ST_IntersectsRect" ), - QStringLiteral( "ST_Is3D" ), - QStringLiteral( "ST_IsEmpty" ), - QStringLiteral( "ST_IsMeasured" ), - QStringLiteral( "ST_IsSimple" ), - QStringLiteral( "ST_IsValid" ), - QStringLiteral( "ST_LineString" ), - QStringLiteral( "ST_MultiLineString" ), - QStringLiteral( "ST_MultiPoint" ), - QStringLiteral( "ST_MultiPolygon" ), - QStringLiteral( "ST_MMax" ), - QStringLiteral( "ST_MMin" ), - QStringLiteral( "ST_NumInteriorRing" ), - QStringLiteral( "ST_NumInteriorRings" ), - QStringLiteral( "ST_OrderingEquals" ), - QStringLiteral( "ST_Overlaps" ), - QStringLiteral( "ST_Perimeter" ), - QStringLiteral( "ST_Point" ), - QStringLiteral( "ST_PointOnSurface" ), - QStringLiteral( "ST_Polygon" ), - QStringLiteral( "ST_SquareGrid" ), - QStringLiteral( "ST_RectangleGrid" ), - QStringLiteral( "ST_RectangleGridBoundingBox" ), - QStringLiteral( "ST_Relate" ), - QStringLiteral( "ST_Rotate" ), - QStringLiteral( "ST_Scale" ), - QStringLiteral( "ST_Simplify" ), - QStringLiteral( "ST_SnapToGrid" ), - QStringLiteral( "ST_SRID" ), - QStringLiteral( "ST_SymDifference" ), - QStringLiteral( "ST_Touches" ), - QStringLiteral( "ST_Transform" ), - QStringLiteral( "ST_Translate" ), - QStringLiteral( "ST_Translate3D" ), - QStringLiteral( "ST_Union" ), - QStringLiteral( "ST_UnionAggr" ), - QStringLiteral( "ST_VoronoiCell" ), - QStringLiteral( "ST_Within" ), - QStringLiteral( "ST_WithinDistance" ), - QStringLiteral( "ST_XMax" ), - QStringLiteral( "ST_XMin" ), - QStringLiteral( "ST_YMax" ), - QStringLiteral( "ST_YMin" ), - QStringLiteral( "ST_ZMax" ), - QStringLiteral( "ST_ZMin" ), + { { Qgis::SqlKeywordCategory::Keyword, + { + QStringLiteral( "ABAP_CHAR" ), + QStringLiteral( "ABAP_DATE" ), + QStringLiteral( "ABAP_DECFLOAT16" ), + QStringLiteral( "ABAP_DECFLOAT34" ), + QStringLiteral( "ABAP_FLOAT" ), + QStringLiteral( "ABAP_HEX" ), + QStringLiteral( "ABAP_INT" ), + QStringLiteral( "ABAP_INT1" ), + QStringLiteral( "ABAP_INT2" ), + QStringLiteral( "ABAP_NUM" ), + QStringLiteral( "ABAP_PACKED" ), + QStringLiteral( "ABAP_STRING" ), + QStringLiteral( "ABAP_TIME" ), + QStringLiteral( "ABAP_XSTRING" ), + QStringLiteral( "ABAPITAB" ), + QStringLiteral( "ABAPSTRUCT" ), + QStringLiteral( "ABSOLUTE" ), + QStringLiteral( "ABSTRACT" ), + QStringLiteral( "ACCESS" ), + QStringLiteral( "ACCURACY" ), + QStringLiteral( "ACKNOWLEDGED" ), + QStringLiteral( "ACTION" ), + QStringLiteral( "ACTIONS" ), + QStringLiteral( "ACTIVATE" ), + QStringLiteral( "ADAPTER" ), + QStringLiteral( "ADD" ), + QStringLiteral( "ADD_DAYS" ), + QStringLiteral( "ADD_MONTHS" ), + QStringLiteral( "ADD_SECONDS" ), + QStringLiteral( "ADD_YEARS" ), + QStringLiteral( "ADDRESS" ), + QStringLiteral( "ADMIN" ), + QStringLiteral( "ADOPT" ), + QStringLiteral( "AFL" ), + QStringLiteral( "AFTER" ), + QStringLiteral( "AGENT" ), + QStringLiteral( "ALERT" ), + QStringLiteral( "ALGORITHM" ), + QStringLiteral( "ALIAS" ), + QStringLiteral( "ALIGNMENT" ), + QStringLiteral( "ALL" ), + QStringLiteral( "ALLATTRSFREESTYLERELEVANT" ), + QStringLiteral( "ALLOCATOR" ), + QStringLiteral( "ALLOCATORS" ), + QStringLiteral( "ALLOWED" ), + QStringLiteral( "ALPHANUM" ), + QStringLiteral( "ALPHANUM_IDENTIFIER" ), + QStringLiteral( "ALTER" ), + QStringLiteral( "ALTERNATE" ), + QStringLiteral( "ALWAYS" ), + QStringLiteral( "ANALYSIS" ), + QStringLiteral( "ANALYTIC" ), + QStringLiteral( "ANALYZE" ), + QStringLiteral( "ANCHOR" ), + QStringLiteral( "AND" ), + QStringLiteral( "ANGULAR" ), + QStringLiteral( "ANNOTATE" ), + QStringLiteral( "ANNOTATIONS" ), + QStringLiteral( "ANONYMIZATION" ), + QStringLiteral( "ANY" ), + QStringLiteral( "APPEND" ), + QStringLiteral( "APPLICATION" ), + QStringLiteral( "APPLICATION_TIME" ), + QStringLiteral( "APPLICATIONUSER" ), + QStringLiteral( "APPLY" ), + QStringLiteral( "APPLY_FILTER" ), + QStringLiteral( "ARCHIVE" ), + QStringLiteral( "AREA" ), + QStringLiteral( "ARRAY" ), + QStringLiteral( "ARRAY_AGG" ), + QStringLiteral( "AS" ), + QStringLiteral( "ASC" ), + QStringLiteral( "ASSERTION" ), + QStringLiteral( "ASSOCIATION" ), + QStringLiteral( "ASSOCIATIONS" ), + QStringLiteral( "ASYNC" ), + QStringLiteral( "ASYNCHRONOUS" ), + QStringLiteral( "AT" ), + QStringLiteral( "ATOMIC" ), + QStringLiteral( "ATTACH" ), + QStringLiteral( "ATTEMPTS" ), + QStringLiteral( "ATTRIBUTE" ), + QStringLiteral( "ATTRIBUTEMAPPING" ), + QStringLiteral( "AUDIT" ), + QStringLiteral( "AUDITING" ), + QStringLiteral( "AUTHENTICATION" ), + QStringLiteral( "AUTHORIZATION" ), + QStringLiteral( "AUTO" ), + QStringLiteral( "AUTOCOMMIT" ), + QStringLiteral( "AUTOMATIC" ), + QStringLiteral( "AUTOMERGE" ), + QStringLiteral( "AXIS" ), + QStringLiteral( "BACKINT" ), + QStringLiteral( "BACKUP" ), + QStringLiteral( "BACKUP_ID" ), + QStringLiteral( "BACKUPS" ), + QStringLiteral( "BALANCE" ), + QStringLiteral( "BASIC" ), + QStringLiteral( "BATCH" ), + QStringLiteral( "BEFORE" ), + QStringLiteral( "BEGIN" ), + QStringLiteral( "BERNOULLI" ), + QStringLiteral( "BEST" ), + QStringLiteral( "BETWEEN" ), + QStringLiteral( "BIGINT" ), + QStringLiteral( "BINARY" ), + QStringLiteral( "BINARYCONSTRAINT" ), + QStringLiteral( "BIND_AS_PARAMETER" ), + QStringLiteral( "BIND_AS_VALUE" ), + QStringLiteral( "BIND_BIGINT" ), + QStringLiteral( "BIND_CHAR" ), + QStringLiteral( "BIND_DECIMAL" ), + QStringLiteral( "BIND_DOUBLE" ), + QStringLiteral( "BIND_NCHAR" ), + QStringLiteral( "BIND_REAL" ), + QStringLiteral( "BITS" ), + QStringLiteral( "BLOB" ), + QStringLiteral( "BOOLEAN" ), + QStringLiteral( "BOTH" ), + QStringLiteral( "BOUNDARY" ), + QStringLiteral( "BREAK" ), + QStringLiteral( "BREAKUP" ), + QStringLiteral( "BTREE" ), + QStringLiteral( "BUCKETS" ), + QStringLiteral( "BUFFER" ), + QStringLiteral( "BUILTIN" ), + QStringLiteral( "BULK" ), + QStringLiteral( "BUSINESS" ), + QStringLiteral( "BY" ), + QStringLiteral( "CA" ), + QStringLiteral( "CACHE" ), + QStringLiteral( "CALCULATEDKEYFIGURE" ), + QStringLiteral( "CALCULATEDVIEWATTRIBUTE" ), + QStringLiteral( "CALCULATION" ), + QStringLiteral( "CALENDAR" ), + QStringLiteral( "CALL" ), + QStringLiteral( "CALLS" ), + QStringLiteral( "CALLSTACK" ), + QStringLiteral( "CANCEL" ), + QStringLiteral( "CAPTURE" ), + QStringLiteral( "CASCADE" ), + QStringLiteral( "CASE" ), + QStringLiteral( "CAST" ), + QStringLiteral( "CATALOG" ), + QStringLiteral( "CDS" ), + QStringLiteral( "CE_CALC" ), + QStringLiteral( "CE_JOIN" ), + QStringLiteral( "CE_PROJECTION" ), + QStringLiteral( "CELL" ), + QStringLiteral( "CELLS" ), + QStringLiteral( "CENTER" ), + QStringLiteral( "CERTIFICATE" ), + QStringLiteral( "CERTIFICATES" ), + QStringLiteral( "CHANGE" ), + QStringLiteral( "CHANGES" ), + QStringLiteral( "CHAR" ), + QStringLiteral( "CHARACTER" ), + QStringLiteral( "CHARACTERISTIC" ), + QStringLiteral( "CHECK" ), + QStringLiteral( "CHECKPOINT" ), + QStringLiteral( "CHILDRENATTRIBUTE" ), + QStringLiteral( "CLAIM" ), + QStringLiteral( "CLASS" ), + QStringLiteral( "CLEAR" ), + QStringLiteral( "CLIENT" ), + QStringLiteral( "CLIENTPKI" ), + QStringLiteral( "CLIENTSIDE" ), + QStringLiteral( "CLIP" ), + QStringLiteral( "CLOB" ), + QStringLiteral( "CLOSE" ), + QStringLiteral( "CLUSTER" ), + QStringLiteral( "CLUSTERING" ), + QStringLiteral( "CLUSTERS" ), + QStringLiteral( "COALESCE" ), + QStringLiteral( "CODE" ), + QStringLiteral( "CODEPAGE" ), + QStringLiteral( "COLLATE" ), + QStringLiteral( "COLLATION" ), + QStringLiteral( "COLLECTION" ), + QStringLiteral( "COLUMN" ), + QStringLiteral( "COLUMN_VIEW_ESTIMATION" ), + QStringLiteral( "COLUMNS" ), + QStringLiteral( "COMMENT" ), + QStringLiteral( "COMMIT" ), + QStringLiteral( "COMMITTED" ), + QStringLiteral( "COMPACT" ), + QStringLiteral( "COMPATIBILITY" ), + QStringLiteral( "COMPLETE" ), + QStringLiteral( "COMPONENT" ), + QStringLiteral( "COMPONENTS" ), + QStringLiteral( "COMPRESSED" ), + QStringLiteral( "COMPRESSION" ), + QStringLiteral( "COMPUTE" ), + QStringLiteral( "COMPUTE_REPLICA_COUNT" ), + QStringLiteral( "COMPUTE_REPLICA_TYPE" ), + QStringLiteral( "CONCAT" ), + QStringLiteral( "CONDITION" ), + QStringLiteral( "CONDITIONAL" ), + QStringLiteral( "CONFIG" ), + QStringLiteral( "CONFIGURATION" ), + QStringLiteral( "CONFIGURE" ), + QStringLiteral( "CONNECT" ), + QStringLiteral( "CONNECTION" ), + QStringLiteral( "CONSISTENCY" ), + QStringLiteral( "CONSTANT" ), + QStringLiteral( "CONSTRAINT" ), + QStringLiteral( "CONSTRAINTS" ), + QStringLiteral( "CONTAINS" ), + QStringLiteral( "CONTENT" ), + QStringLiteral( "CONTEXT" ), + QStringLiteral( "CONTINUE" ), + QStringLiteral( "CONTROL" ), + QStringLiteral( "CONTROLLED" ), + QStringLiteral( "CONV" ), + QStringLiteral( "CONVERT" ), + QStringLiteral( "COORDINATE" ), + QStringLiteral( "COPY" ), + QStringLiteral( "COREFILE" ), + QStringLiteral( "CORRELATION" ), + QStringLiteral( "COVERAGE" ), + QStringLiteral( "CPBTREE" ), + QStringLiteral( "CPU" ), + QStringLiteral( "CREATE" ), + QStringLiteral( "CREATION" ), + QStringLiteral( "CREATOR" ), + QStringLiteral( "CREDENTIAL" ), + QStringLiteral( "CRITICAL" ), + QStringLiteral( "CRON" ), + QStringLiteral( "CROSS" ), + QStringLiteral( "CS_DATE" ), + QStringLiteral( "CS_DAYDATE" ), + QStringLiteral( "CS_DECIMAL_FLOAT" ), + QStringLiteral( "CS_DOUBLE" ), + QStringLiteral( "CS_FIXED" ), + QStringLiteral( "CS_FIXEDSTRING" ), + QStringLiteral( "CS_FLOAT" ), + QStringLiteral( "CS_GEOMETRY" ), + QStringLiteral( "CS_INT" ), + QStringLiteral( "CS_LONGDATE" ), + QStringLiteral( "CS_POINT" ), + QStringLiteral( "CS_POINTZ" ), + QStringLiteral( "CS_RAW" ), + QStringLiteral( "CS_SDFLOAT" ), + QStringLiteral( "CS_SECONDDATE" ), + QStringLiteral( "CS_SECONDTIME" ), + QStringLiteral( "CS_SHORTTEXT" ), + QStringLiteral( "CS_STRING" ), + QStringLiteral( "CS_TEXT" ), + QStringLiteral( "CS_TEXT_AE" ), + QStringLiteral( "CS_TIME" ), + QStringLiteral( "CSV" ), + QStringLiteral( "CUBE" ), + QStringLiteral( "CUME_DIST" ), + QStringLiteral( "CURDATE" ), + QStringLiteral( "CURRENT" ), + QStringLiteral( "CURRENT_CONNECTION" ), + QStringLiteral( "CURRENT_DATABASE" ), + QStringLiteral( "CURRENT_DATE" ), + QStringLiteral( "CURRENT_SCHEMA" ), + QStringLiteral( "CURRENT_TIME" ), + QStringLiteral( "CURRENT_TIMESTAMP" ), + QStringLiteral( "CURRENT_TRANSACTION_ISOLATION_LEVEL" ), + QStringLiteral( "CURRENT_USER" ), + QStringLiteral( "CURRENT_UTCDATE" ), + QStringLiteral( "CURRENT_UTCTIME" ), + QStringLiteral( "CURRENT_UTCTIMESTAMP" ), + QStringLiteral( "CURRVAL" ), + QStringLiteral( "CURSOR" ), + QStringLiteral( "CURTIME" ), + QStringLiteral( "CURVE" ), + QStringLiteral( "CYCLE" ), + QStringLiteral( "D" ), + QStringLiteral( "DATA" ), + QStringLiteral( "DATABASE" ), + QStringLiteral( "DATABASES" ), + QStringLiteral( "DATAPROVISIONING" ), + QStringLiteral( "DATASET" ), + QStringLiteral( "DATASOURCE" ), + QStringLiteral( "DATAVOLUME" ), + QStringLiteral( "DATE" ), + QStringLiteral( "DATEFORMAT" ), + QStringLiteral( "DATETIME" ), + QStringLiteral( "DATS_EXTRACT" ), + QStringLiteral( "DAY" ), + QStringLiteral( "DAYDATE" ), + QStringLiteral( "DAYOFMONTH" ), + QStringLiteral( "DAYOFWEEK" ), + QStringLiteral( "DAYS_BETWEEN" ), + QStringLiteral( "DBSCAN" ), + QStringLiteral( "DBSPACE" ), + QStringLiteral( "DDIC_ACCP" ), + QStringLiteral( "DDIC_CDAY" ), + QStringLiteral( "DDIC_CHAR" ), + QStringLiteral( "DDIC_CLNT" ), + QStringLiteral( "DDIC_CUKY" ), + QStringLiteral( "DDIC_CURR" ), + QStringLiteral( "DDIC_D16D" ), + QStringLiteral( "DDIC_D16R" ), + QStringLiteral( "DDIC_D16S" ), + QStringLiteral( "DDIC_D34D" ), + QStringLiteral( "DDIC_D34R" ), + QStringLiteral( "DDIC_D34S" ), + QStringLiteral( "DDIC_DATS" ), + QStringLiteral( "DDIC_DAY" ), + QStringLiteral( "DDIC_DEC" ), + QStringLiteral( "DDIC_FLTP" ), + QStringLiteral( "DDIC_GUID" ), + QStringLiteral( "DDIC_INT1" ), + QStringLiteral( "DDIC_INT2" ), + QStringLiteral( "DDIC_INT4" ), + QStringLiteral( "DDIC_INT8" ), + QStringLiteral( "DDIC_LANG" ), + QStringLiteral( "DDIC_LCHR" ), + QStringLiteral( "DDIC_LRAW" ), + QStringLiteral( "DDIC_MIN" ), + QStringLiteral( "DDIC_MON" ), + QStringLiteral( "DDIC_NUMC" ), + QStringLiteral( "DDIC_PREC" ), + QStringLiteral( "DDIC_QUAN" ), + QStringLiteral( "DDIC_RAW" ), + QStringLiteral( "DDIC_RSTR" ), + QStringLiteral( "DDIC_SEC" ), + QStringLiteral( "DDIC_SRST" ), + QStringLiteral( "DDIC_SSTR" ), + QStringLiteral( "DDIC_STRG" ), + QStringLiteral( "DDIC_STXT" ), + QStringLiteral( "DDIC_TEXT" ), + QStringLiteral( "DDIC_TIMS" ), + QStringLiteral( "DDIC_UNIT" ), + QStringLiteral( "DDIC_UTCL" ), + QStringLiteral( "DDIC_UTCM" ), + QStringLiteral( "DDIC_UTCS" ), + QStringLiteral( "DDIC_VARC" ), + QStringLiteral( "DDIC_WEEK" ), + QStringLiteral( "DDL" ), + QStringLiteral( "DEACTIVATE" ), + QStringLiteral( "DEBUG" ), + QStringLiteral( "DEBUGGER" ), + QStringLiteral( "DEC" ), + QStringLiteral( "DECIMAL" ), + QStringLiteral( "DECLARE" ), + QStringLiteral( "DEFAULT" ), + QStringLiteral( "DEFAULTVIEW" ), + QStringLiteral( "DEFERRED" ), + QStringLiteral( "DEFINER" ), + QStringLiteral( "DEFINITION" ), + QStringLiteral( "DEFRAGMENT" ), + QStringLiteral( "DELAY" ), + QStringLiteral( "DELETE" ), + QStringLiteral( "DELIMITED" ), + QStringLiteral( "DELTA" ), + QStringLiteral( "DENSE_RANK" ), + QStringLiteral( "DEPENDENCIES" ), + QStringLiteral( "DEPENDENCY" ), + QStringLiteral( "DEPENDENT" ), + QStringLiteral( "DEPTH" ), + QStringLiteral( "DESC" ), + QStringLiteral( "DESCRIPTION" ), + QStringLiteral( "DETACH" ), + QStringLiteral( "DETECTION" ), + QStringLiteral( "DETERMINISTIC" ), + QStringLiteral( "DEV_CS_ONLY" ), + QStringLiteral( "DEV_NO_SEMI_JOIN_REDUCTION_TARGET" ), + QStringLiteral( "DEV_PROC_CE" ), + QStringLiteral( "DEV_PROC_INLINE" ), + QStringLiteral( "DEV_PROC_L" ), + QStringLiteral( "DEV_PROC_NO_INLINE" ), + QStringLiteral( "DEV_PROC_SE_FT" ), + QStringLiteral( "DEV_RS_ONLY" ), + QStringLiteral( "DEV_SEMI_JOIN_REDUCTION_TARGET" ), + QStringLiteral( "DEVELOPMENT" ), + QStringLiteral( "DIFFERENTIAL" ), + QStringLiteral( "DISABLE" ), + QStringLiteral( "DISABLED" ), + QStringLiteral( "DISCONNECT" ), + QStringLiteral( "DISK" ), + QStringLiteral( "DISTANCE" ), + QStringLiteral( "DISTINCT" ), + QStringLiteral( "DISTRIBUTE" ), + QStringLiteral( "DISTRIBUTION" ), + QStringLiteral( "DO" ), + QStringLiteral( "DOCUMENT" ), + QStringLiteral( "DOCUMENTS" ), + QStringLiteral( "DOUBLE" ), + QStringLiteral( "DPSERVER" ), + QStringLiteral( "DROP" ), + QStringLiteral( "DTAB" ), + QStringLiteral( "DUPLICATES" ), + QStringLiteral( "DURATION" ), + QStringLiteral( "DW_OPTIMIZED" ), + QStringLiteral( "DYNAMIC" ), + QStringLiteral( "DYNAMIC_RANGE_THRESHOLD" ), + QStringLiteral( "EACH" ), + QStringLiteral( "EARTH" ), + QStringLiteral( "EDGE" ), + QStringLiteral( "ELEMENTS" ), + QStringLiteral( "ELLIPSOID" ), + QStringLiteral( "ELSE" ), + QStringLiteral( "ELSEIF" ), + QStringLiteral( "EMAIL" ), + QStringLiteral( "EMERGENCY" ), + QStringLiteral( "EMPTY" ), + QStringLiteral( "ENABLE" ), + QStringLiteral( "ENABLED" ), + QStringLiteral( "ENCLOSED" ), + QStringLiteral( "ENCODED" ), + QStringLiteral( "ENCODING" ), + QStringLiteral( "ENCRYPTED" ), + QStringLiteral( "ENCRYPTION" ), + QStringLiteral( "END" ), + QStringLiteral( "ENFORCED" ), + QStringLiteral( "ENTITY" ), + QStringLiteral( "ENTRY" ), + QStringLiteral( "EPM" ), + QStringLiteral( "EPS" ), + QStringLiteral( "EQ" ), + QStringLiteral( "EQUIDISTANT" ), + QStringLiteral( "ERROR" ), + QStringLiteral( "ES" ), + QStringLiteral( "ESCAPE" ), + QStringLiteral( "ESTIMATE" ), + QStringLiteral( "ESTIMATED" ), + QStringLiteral( "ESTIMATION" ), + QStringLiteral( "EVENT" ), + QStringLiteral( "EVENTS" ), + QStringLiteral( "EVERY" ), + QStringLiteral( "EVICTION" ), + QStringLiteral( "EXACT" ), + QStringLiteral( "EXCEPT" ), + QStringLiteral( "EXCEPTION" ), + QStringLiteral( "EXCLUDE" ), + QStringLiteral( "EXCLUDED" ), + QStringLiteral( "EXCLUSIVE" ), + QStringLiteral( "EXEC" ), + QStringLiteral( "EXECUTE" ), + QStringLiteral( "EXECUTION" ), + QStringLiteral( "EXISTING" ), + QStringLiteral( "EXISTS" ), + QStringLiteral( "EXIT" ), + QStringLiteral( "EXPLAIN" ), + QStringLiteral( "EXPLICIT" ), + QStringLiteral( "EXPORT" ), + QStringLiteral( "EXPRESSION" ), + QStringLiteral( "EXPRESSIONFLAGS" ), + QStringLiteral( "EXTENDED" ), + QStringLiteral( "EXTERNAL" ), + QStringLiteral( "EXTERNAL_BACKUP_ID" ), + QStringLiteral( "EXTERNALATTRIBUTE" ), + QStringLiteral( "EXTERNALLY" ), + QStringLiteral( "EXTRACT" ), + QStringLiteral( "FACT" ), + QStringLiteral( "FACTOR" ), + QStringLiteral( "FAIL" ), + QStringLiteral( "FALLBACK" ), + QStringLiteral( "FALSE" ), + QStringLiteral( "FAST" ), + QStringLiteral( "FBO" ), + QStringLiteral( "FETCH" ), + QStringLiteral( "FIELD" ), + QStringLiteral( "FILE" ), + QStringLiteral( "FILL" ), + QStringLiteral( "FILLFACTOR" ), + QStringLiteral( "FILTER" ), + QStringLiteral( "FINALIZE" ), + QStringLiteral( "FINISH" ), + QStringLiteral( "FIRST" ), + QStringLiteral( "FLAG" ), + QStringLiteral( "FLAGS" ), + QStringLiteral( "FLATTEN" ), + QStringLiteral( "FLATTENING" ), + QStringLiteral( "FLOAT" ), + QStringLiteral( "FLUSH" ), + QStringLiteral( "FN" ), + QStringLiteral( "FOLLOWING" ), + QStringLiteral( "FOLLOWS" ), + QStringLiteral( "FOR" ), + QStringLiteral( "FORCE" ), + QStringLiteral( "FORCE_FIRST_PASSWORD_CHANGE" ), + QStringLiteral( "FORCE_RESULT_CACHE_REFRESH" ), + QStringLiteral( "FOREIGN" ), + QStringLiteral( "FOREVER" ), + QStringLiteral( "FORGY" ), + QStringLiteral( "FORMAT" ), + QStringLiteral( "FORMULA" ), + QStringLiteral( "FREESTYLESEARCHATTRIBUTE" ), + QStringLiteral( "FREESTYLETRANSLATION" ), + QStringLiteral( "FROM" ), + QStringLiteral( "FULL" ), + QStringLiteral( "FULLTEXT" ), + QStringLiteral( "FUNCTION" ), + QStringLiteral( "FUNCTION_PROFILER" ), + QStringLiteral( "FUZZINESSTHRESHOLD" ), + QStringLiteral( "FUZZY" ), + QStringLiteral( "GB" ), + QStringLiteral( "GENERATED" ), + QStringLiteral( "GET_NUM_SERVERS" ), + QStringLiteral( "GLOBAL" ), + QStringLiteral( "GLOBALDICT" ), + QStringLiteral( "GLOBALLY" ), + QStringLiteral( "GOTO" ), + QStringLiteral( "GRANT" ), + QStringLiteral( "GRANTED" ), + QStringLiteral( "GRAPH" ), + QStringLiteral( "GREATEST" ), + QStringLiteral( "GRID" ), + QStringLiteral( "GROUP" ), + QStringLiteral( "GROUP_NAME" ), + QStringLiteral( "GROUP_TYPE" ), + QStringLiteral( "GROUPING" ), + QStringLiteral( "GROUPING_FILTER" ), + QStringLiteral( "GROUPING_ID" ), + QStringLiteral( "GROUPS" ), + QStringLiteral( "GT" ), + QStringLiteral( "GUID" ), + QStringLiteral( "HANDLED" ), + QStringLiteral( "HANDOVER" ), + QStringLiteral( "HAS" ), + QStringLiteral( "HASANYPRIVILEGES" ), + QStringLiteral( "HASH" ), + QStringLiteral( "HASH_JOIN" ), + QStringLiteral( "HASSYSTEMPRIVILEGE" ), + QStringLiteral( "HAVING" ), + QStringLiteral( "HEXAGON" ), + QStringLiteral( "HEXTOBIN" ), + QStringLiteral( "HIDDEN" ), + QStringLiteral( "HIERARCHY" ), + QStringLiteral( "HIERARCHY_ANCESTORS" ), + QStringLiteral( "HIERARCHY_ANCESTORS_AGGREGATE" ), + QStringLiteral( "HIERARCHY_DESCENDANTS" ), + QStringLiteral( "HIERARCHY_DESCENDANTS_AGGREGATE" ), + QStringLiteral( "HIERARCHY_LEVELED" ), + QStringLiteral( "HIERARCHY_SIBLINGS" ), + QStringLiteral( "HIERARCHY_SPANTREE" ), + QStringLiteral( "HIERARCHY_TEMPORAL" ), + QStringLiteral( "HIERARCHYCHARACTERISTIC" ), + QStringLiteral( "HIERARCHYINDEX" ), + QStringLiteral( "HIERARCHYNAME" ), + QStringLiteral( "HIGH" ), + QStringLiteral( "HIGHLIGHTED" ), + QStringLiteral( "HILBERT" ), + QStringLiteral( "HINT" ), + QStringLiteral( "HISTOGRAM" ), + QStringLiteral( "HISTORY" ), + QStringLiteral( "HOLD" ), + QStringLiteral( "HORIZONTAL" ), + QStringLiteral( "HOST" ), + QStringLiteral( "HOSTS" ), + QStringLiteral( "HOUR" ), + QStringLiteral( "HOUSENUMBER" ), + QStringLiteral( "ID" ), + QStringLiteral( "IDENTICAL" ), + QStringLiteral( "IDENTIFIED" ), + QStringLiteral( "IDENTIFIER" ), + QStringLiteral( "IDENTITY" ), + QStringLiteral( "IF" ), + QStringLiteral( "IFNULL" ), + QStringLiteral( "IGNORE" ), + QStringLiteral( "IMMEDIATE" ), + QStringLiteral( "IMPORT" ), + QStringLiteral( "IN" ), + QStringLiteral( "INCLUDE" ), + QStringLiteral( "INCREMENT" ), + QStringLiteral( "INCREMENTAL" ), + QStringLiteral( "INDEPENDENT" ), + QStringLiteral( "INDEX" ), + QStringLiteral( "INDEX_JOIN" ), + QStringLiteral( "INDEX_UNION" ), + QStringLiteral( "INDEXALIAS" ), + QStringLiteral( "INDEXED" ), + QStringLiteral( "INDEXES" ), + QStringLiteral( "INDEXID" ), + QStringLiteral( "INDEXTYPE" ), + QStringLiteral( "INDIVIDUAL" ), + QStringLiteral( "INFO" ), + QStringLiteral( "INHERITS" ), + QStringLiteral( "INIFILE" ), + QStringLiteral( "INIT" ), + QStringLiteral( "INITIAL" ), + QStringLiteral( "INITIAL_PARTITIONS" ), + QStringLiteral( "INITIALLY" ), + QStringLiteral( "INLINE" ), + QStringLiteral( "INNER" ), + QStringLiteral( "INOUT" ), + QStringLiteral( "INSENSITIVE" ), + QStringLiteral( "INSERT" ), + QStringLiteral( "INSTEAD" ), + QStringLiteral( "INSTR" ), + QStringLiteral( "INT" ), + QStringLiteral( "INTEGER" ), + QStringLiteral( "INTERNAL" ), + QStringLiteral( "INTERSECT" ), + QStringLiteral( "INTERVAL" ), + QStringLiteral( "INTO" ), + QStringLiteral( "INVALID" ), + QStringLiteral( "INVERSE" ), + QStringLiteral( "INVERTED" ), + QStringLiteral( "INVOKER" ), + QStringLiteral( "IS" ), + QStringLiteral( "IS_EMPTY" ), + QStringLiteral( "ISAUTHORIZED" ), + QStringLiteral( "ISMEMORYINDEX" ), + QStringLiteral( "ISOLATION" ), + QStringLiteral( "ISSUER" ), + QStringLiteral( "ISTOTAL" ), + QStringLiteral( "ISTRANSACTIONAL" ), + QStringLiteral( "JOB" ), + QStringLiteral( "JOIN" ), + QStringLiteral( "JOINCONDITION" ), + QStringLiteral( "JOININDEX" ), + QStringLiteral( "JOININDEXESTIMATION" ), + QStringLiteral( "JOININDEXTYPE" ), + QStringLiteral( "JOINPATH" ), + QStringLiteral( "JSON" ), + QStringLiteral( "JSON_QUERY" ), + QStringLiteral( "JSON_TABLE" ), + QStringLiteral( "JSON_VALUE" ), + QStringLiteral( "JWT" ), + QStringLiteral( "KB" ), + QStringLiteral( "KEEP" ), + QStringLiteral( "KERBEROS" ), + QStringLiteral( "KERNEL" ), + QStringLiteral( "KERNELTRACE" ), + QStringLiteral( "KEY" ), + QStringLiteral( "KEYATTRIBUTE" ), + QStringLiteral( "KEYCOPY" ), + QStringLiteral( "KEYFIGURE" ), + QStringLiteral( "KEYPAIR" ), + QStringLiteral( "KEYS" ), + QStringLiteral( "KEYVALUE" ), + QStringLiteral( "KMEANS" ), + QStringLiteral( "L" ), + QStringLiteral( "LABEL" ), + QStringLiteral( "LAG" ), + QStringLiteral( "LANGUAGE" ), + QStringLiteral( "LAST" ), + QStringLiteral( "LAST_DAY" ), + QStringLiteral( "LATENCY" ), + QStringLiteral( "LATERAL" ), + QStringLiteral( "LAYOUT" ), + QStringLiteral( "LDAP" ), + QStringLiteral( "LEAD" ), + QStringLiteral( "LEADING" ), + QStringLiteral( "LEAF" ), + QStringLiteral( "LEAST" ), + QStringLiteral( "LEAVES" ), + QStringLiteral( "LEFT" ), + QStringLiteral( "LENGTH" ), + QStringLiteral( "LENGTHB" ), + QStringLiteral( "LEVEL" ), + QStringLiteral( "LEVELNUMBERATTRIBUTE" ), + QStringLiteral( "LEVELS" ), + QStringLiteral( "LEVELTEXTATTRIBUTE" ), + QStringLiteral( "LIBRARY" ), + QStringLiteral( "LICENSE" ), + QStringLiteral( "LIFETIME" ), + QStringLiteral( "LIKE" ), + QStringLiteral( "LIKE_REGEXPR" ), + QStringLiteral( "LIMIT" ), + QStringLiteral( "LINE" ), + QStringLiteral( "LINEAR" ), + QStringLiteral( "LINKED" ), + QStringLiteral( "LIST" ), + QStringLiteral( "LOAD" ), + QStringLiteral( "LOAD_HISTORY" ), + QStringLiteral( "LOADABLE" ), + QStringLiteral( "LOB" ), + QStringLiteral( "LOCAL" ), + QStringLiteral( "LOCALE" ), + QStringLiteral( "LOCATE" ), + QStringLiteral( "LOCATE_REGEXPR" ), + QStringLiteral( "LOCATION" ), + QStringLiteral( "LOCATIONS" ), + QStringLiteral( "LOCK" ), + QStringLiteral( "LOCKED" ), + QStringLiteral( "LOG" ), + QStringLiteral( "LOGFLUSH" ), + QStringLiteral( "LOGGING" ), + QStringLiteral( "LONGDATE" ), + QStringLiteral( "LOOKUP" ), + QStringLiteral( "LOOP" ), + QStringLiteral( "LOOPBACK" ), + QStringLiteral( "LPAD" ), + QStringLiteral( "LTRIM" ), + QStringLiteral( "MACROS" ), + QStringLiteral( "MAIN" ), + QStringLiteral( "MAJOR" ), + QStringLiteral( "MANAGEMENT" ), + QStringLiteral( "MANUAL" ), + QStringLiteral( "MANY" ), + QStringLiteral( "MAP" ), + QStringLiteral( "MAP_MERGE" ), + QStringLiteral( "MAP_REDUCE" ), + QStringLiteral( "MAPPING" ), + QStringLiteral( "MASK" ), + QStringLiteral( "MATCHED" ), + QStringLiteral( "MATCHES" ), + QStringLiteral( "MATCHING" ), + QStringLiteral( "MAXITERATIONS" ), + QStringLiteral( "MAXVALUE" ), + QStringLiteral( "MB" ), + QStringLiteral( "MDRS_TEST" ), + QStringLiteral( "MDX" ), + QStringLiteral( "MEASURE" ), + QStringLiteral( "MEASURES" ), + QStringLiteral( "MEDIUM" ), + QStringLiteral( "MEMBER" ), + QStringLiteral( "MEMORY" ), + QStringLiteral( "MERGE" ), + QStringLiteral( "MESSAGING" ), + QStringLiteral( "META" ), + QStringLiteral( "METADATA" ), + QStringLiteral( "MIGRATE" ), + QStringLiteral( "MIME" ), + QStringLiteral( "MIN_ROWS_FOR_PARTITIONING" ), + QStringLiteral( "MINING" ), + QStringLiteral( "MINOR" ), + QStringLiteral( "MINPTS" ), + QStringLiteral( "MINUS" ), + QStringLiteral( "MINUTE" ), + QStringLiteral( "MINUTES" ), + QStringLiteral( "MINVALUE" ), + QStringLiteral( "MISSING" ), + QStringLiteral( "MODE" ), + QStringLiteral( "MODEL" ), + QStringLiteral( "MODIFIED" ), + QStringLiteral( "MODIFY" ), + QStringLiteral( "MODULE" ), + QStringLiteral( "MONITOR" ), + QStringLiteral( "MONITORING" ), + QStringLiteral( "MONTH" ), + QStringLiteral( "MOVABLE" ), + QStringLiteral( "MOVE" ), + QStringLiteral( "MULTIPARENT" ), + QStringLiteral( "MULTIPLE" ), + QStringLiteral( "MULTIPROVIDERCONFIG" ), + QStringLiteral( "MVCC_SNAPSHOT_TIMESTAMP" ), + QStringLiteral( "NAME" ), + QStringLiteral( "NATIONAL" ), + QStringLiteral( "NATURAL" ), + QStringLiteral( "NCHAR" ), + QStringLiteral( "NCLOB" ), + QStringLiteral( "NEAREST" ), + QStringLiteral( "NEIGHBORS" ), + QStringLiteral( "NESTED" ), + QStringLiteral( "NESTED_LOOP_JOIN" ), + QStringLiteral( "NETAPP" ), + QStringLiteral( "NEW" ), + QStringLiteral( "NEWFACTTABLE" ), + QStringLiteral( "NEXT" ), + QStringLiteral( "NEXT_DAY" ), + QStringLiteral( "NEXTVAL" ), + QStringLiteral( "NO" ), + QStringLiteral( "NO_CALC_DIMENSION" ), + QStringLiteral( "NO_DISTINCT_FILTER" ), + QStringLiteral( "NO_INDEX" ), + QStringLiteral( "NO_INLINE" ), + QStringLiteral( "NO_ROUTE_TO" ), + QStringLiteral( "NO_USE_C2C_CONV" ), + QStringLiteral( "NO_USE_OLAP_PLAN" ), + QStringLiteral( "NO_USE_TRANSFORMATION" ), + QStringLiteral( "NO_VIRTUAL_TABLE_REPLICA" ), + QStringLiteral( "NOCOMPRESS" ), + QStringLiteral( "NODE" ), + QStringLiteral( "NON" ), + QStringLiteral( "NONE" ), + QStringLiteral( "NONLEAF" ), + QStringLiteral( "NOT" ), + QStringLiteral( "NOW" ), + QStringLiteral( "NOWAIT" ), + QStringLiteral( "NTEXT" ), + QStringLiteral( "NTILE" ), + QStringLiteral( "NULL" ), + QStringLiteral( "NULLABLE" ), + QStringLiteral( "NULLIF" ), + QStringLiteral( "NULLS" ), + QStringLiteral( "NUMA" ), + QStringLiteral( "NUMA_NODE_INDEXES" ), + QStringLiteral( "NUMBER" ), + QStringLiteral( "NUMERIC" ), + QStringLiteral( "NVARCHAR" ), + QStringLiteral( "OBJECT" ), + QStringLiteral( "OBJECTS" ), + QStringLiteral( "OCCURRENCE" ), + QStringLiteral( "OCCURRENCES_REGEXPR" ), + QStringLiteral( "ODATA" ), + QStringLiteral( "OF" ), + QStringLiteral( "OFF" ), + QStringLiteral( "OFFSET" ), + QStringLiteral( "OJ" ), + QStringLiteral( "OLAP" ), + QStringLiteral( "OLAP_PARALLEL_AGGREGATION" ), + QStringLiteral( "OLAP_SERIAL_AGGREGATION" ), + QStringLiteral( "OLD" ), + QStringLiteral( "OLYMP" ), + QStringLiteral( "ON" ), + QStringLiteral( "ONE" ), + QStringLiteral( "ONLINE" ), + QStringLiteral( "ONLY" ), + QStringLiteral( "OPEN" ), + QStringLiteral( "OPENCYPHER_TABLE" ), + QStringLiteral( "OPERATION" ), + QStringLiteral( "OPERATOR" ), + QStringLiteral( "OPTIMIZATION" ), + QStringLiteral( "OPTIMIZEMETAMODEL" ), + QStringLiteral( "OPTIMIZER" ), + QStringLiteral( "OPTION" ), + QStringLiteral( "OPTIONALLY" ), + QStringLiteral( "OR" ), + QStringLiteral( "ORDER" ), + QStringLiteral( "ORDINALITY" ), + QStringLiteral( "ORGANIZATION" ), + QStringLiteral( "ORPHAN" ), + QStringLiteral( "OS" ), + QStringLiteral( "OTHERS" ), + QStringLiteral( "OUT" ), + QStringLiteral( "OUTER" ), + QStringLiteral( "OVER" ), + QStringLiteral( "OVERLAY" ), + QStringLiteral( "OVERRIDE" ), + QStringLiteral( "OVERRIDING" ), + QStringLiteral( "OVERVIEW" ), + QStringLiteral( "OWN" ), + QStringLiteral( "OWNED" ), + QStringLiteral( "OWNER" ), + QStringLiteral( "PACKAGE" ), + QStringLiteral( "PAGE" ), + QStringLiteral( "PAGE_LOADABLE" ), + QStringLiteral( "PAGES" ), + QStringLiteral( "PARALLEL" ), + QStringLiteral( "PARALLELIZED" ), + QStringLiteral( "PARAMETER" ), + QStringLiteral( "PARAMETERS" ), + QStringLiteral( "PARENT" ), + QStringLiteral( "PARENTSATTRIBUTE" ), + QStringLiteral( "PARQUET" ), + QStringLiteral( "PART" ), + QStringLiteral( "PARTIAL" ), + QStringLiteral( "PARTITION" ), + QStringLiteral( "PARTITIONING" ), + QStringLiteral( "PARTITIONS" ), + QStringLiteral( "PARTS" ), + QStringLiteral( "PASS" ), + QStringLiteral( "PASSING" ), + QStringLiteral( "PASSPORT_TRACELEVEL" ), + QStringLiteral( "PASSWORD" ), + QStringLiteral( "PATH" ), + QStringLiteral( "PERCENT" ), + QStringLiteral( "PERCENT_RANK" ), + QStringLiteral( "PERCENTILE_CONT" ), + QStringLiteral( "PERCENTILE_DISC" ), + QStringLiteral( "PERFTRACE" ), + QStringLiteral( "PERIOD" ), + QStringLiteral( "PERSISTENCE" ), + QStringLiteral( "PERSISTENT" ), + QStringLiteral( "PERSISTENT_MEMORY" ), + QStringLiteral( "PHRASE" ), + QStringLiteral( "PHYSICAL" ), + QStringLiteral( "PIN" ), + QStringLiteral( "PLACEMENT" ), + QStringLiteral( "PLAIN" ), + QStringLiteral( "PLAN" ), + QStringLiteral( "PLAN_EXECUTION" ), + QStringLiteral( "PLANAR" ), + QStringLiteral( "PLANNING" ), + QStringLiteral( "PLANVIZ" ), + QStringLiteral( "POBJECTKEY" ), + QStringLiteral( "POLICY" ), + QStringLiteral( "POLYGON" ), + QStringLiteral( "PORT" ), + QStringLiteral( "PORTION" ), + QStringLiteral( "POSITION" ), + QStringLiteral( "POSTCODE" ), + QStringLiteral( "PPROPERTYNAME" ), + QStringLiteral( "PRECEDES" ), + QStringLiteral( "PRECEDING" ), + QStringLiteral( "PRECISION" ), + QStringLiteral( "PREDEFINED" ), + QStringLiteral( "PREFERENCE" ), + QStringLiteral( "PREFERRED" ), + QStringLiteral( "PREFIX" ), + QStringLiteral( "PRELOAD" ), + QStringLiteral( "PREPROCESS" ), + QStringLiteral( "PRESERVE" ), + QStringLiteral( "PREVIOUS" ), + QStringLiteral( "PRIMARY" ), + QStringLiteral( "PRINCIPAL" ), + QStringLiteral( "PRIOR" ), + QStringLiteral( "PRIORITY" ), + QStringLiteral( "PRIVATE" ), + QStringLiteral( "PRIVILEGE" ), + QStringLiteral( "PRIVILEGES" ), + QStringLiteral( "PROCEDURE" ), + QStringLiteral( "PROCESS" ), + QStringLiteral( "PRODUCT" ), + QStringLiteral( "PROFILE" ), + QStringLiteral( "PROFILER" ), + QStringLiteral( "PROJECTION" ), + QStringLiteral( "PROPERTIES" ), + QStringLiteral( "PROPERTY" ), + QStringLiteral( "PROTOCOL" ), + QStringLiteral( "PROVIDER" ), + QStringLiteral( "PRUNING" ), + QStringLiteral( "PSE" ), + QStringLiteral( "PTIME" ), + QStringLiteral( "PUBLIC" ), + QStringLiteral( "PURPOSE" ), + QStringLiteral( "PVALUENAME" ), + QStringLiteral( "QERROR" ), + QStringLiteral( "QTHETA" ), + QStringLiteral( "QUERY" ), + QStringLiteral( "QUEUE" ), + QStringLiteral( "RAISE" ), + QStringLiteral( "RANDOM" ), + QStringLiteral( "RANGE" ), + QStringLiteral( "RANK" ), + QStringLiteral( "RATIO" ), + QStringLiteral( "RAW" ), + QStringLiteral( "RDICT" ), + QStringLiteral( "READ" ), + QStringLiteral( "READS" ), + QStringLiteral( "REAL" ), + QStringLiteral( "REALTIME" ), + QStringLiteral( "REBUILD" ), + QStringLiteral( "RECLAIM" ), + QStringLiteral( "RECOMPILE" ), + QStringLiteral( "RECOMPILED" ), + QStringLiteral( "RECONFIGURE" ), + QStringLiteral( "RECORD" ), + QStringLiteral( "RECORD_COMMIT_TIMESTAMP" ), + QStringLiteral( "RECORD_COUNT" ), + QStringLiteral( "RECORD_ID" ), + QStringLiteral( "RECORDS" ), + QStringLiteral( "RECOVER" ), + QStringLiteral( "RECOVERY" ), + QStringLiteral( "RECURSIVE" ), + QStringLiteral( "REFERENCE" ), + QStringLiteral( "REFERENCES" ), + QStringLiteral( "REFERENCING" ), + QStringLiteral( "REFRESH" ), + QStringLiteral( "REGISTER" ), + QStringLiteral( "RELEASE" ), + QStringLiteral( "RELOAD" ), + QStringLiteral( "REMOTE" ), + QStringLiteral( "REMOTE_EXECUTE_QUERY" ), + QStringLiteral( "REMOTE_SCAN" ), + QStringLiteral( "REMOVE" ), + QStringLiteral( "RENAME" ), + QStringLiteral( "REORGANIZE" ), + QStringLiteral( "REPARTITIONING_THRESHOLD" ), + QStringLiteral( "REPEATABLE" ), + QStringLiteral( "REPLACE" ), + QStringLiteral( "REPLACE_REGEXPR" ), + QStringLiteral( "REPLAY" ), + QStringLiteral( "REPLICA" ), + QStringLiteral( "REPLICA_COUNT" ), + QStringLiteral( "REPLICA_TYPE" ), + QStringLiteral( "REPLICAS" ), + QStringLiteral( "REPLICATION" ), + QStringLiteral( "REPOSITORY" ), + QStringLiteral( "RESERVE" ), + QStringLiteral( "RESET" ), + QStringLiteral( "RESIGNAL" ), + QStringLiteral( "RESOURCE" ), + QStringLiteral( "RESTART" ), + QStringLiteral( "RESTORE" ), + QStringLiteral( "RESTRICT" ), + QStringLiteral( "RESTRICTED" ), + QStringLiteral( "RESTRICTION" ), + QStringLiteral( "RESULT" ), + QStringLiteral( "RESULT_LAG" ), + QStringLiteral( "RESULTSETS" ), + QStringLiteral( "RESUME" ), + QStringLiteral( "RETAIN" ), + QStringLiteral( "RETENTION" ), + QStringLiteral( "RETRY" ), + QStringLiteral( "RETURN" ), + QStringLiteral( "RETURNING" ), + QStringLiteral( "RETURNS" ), + QStringLiteral( "REVERSE" ), + QStringLiteral( "REVOKE" ), + QStringLiteral( "RIGHT" ), + QStringLiteral( "ROLE" ), + QStringLiteral( "ROLEGROUP" ), + QStringLiteral( "ROLLBACK" ), + QStringLiteral( "ROLLUP" ), + QStringLiteral( "ROOT" ), + QStringLiteral( "ROOT_STATEMENT_HASH" ), + QStringLiteral( "ROUND" ), + QStringLiteral( "ROUND_CEILING" ), + QStringLiteral( "ROUND_DOWN" ), + QStringLiteral( "ROUND_FLOOR" ), + QStringLiteral( "ROUND_HALF_DOWN" ), + QStringLiteral( "ROUND_HALF_EVEN" ), + QStringLiteral( "ROUND_HALF_UP" ), + QStringLiteral( "ROUND_UP" ), + QStringLiteral( "ROUNDROBIN" ), + QStringLiteral( "ROUTE" ), + QStringLiteral( "ROUTE_BY" ), + QStringLiteral( "ROUTE_BY_CARDINALITY" ), + QStringLiteral( "ROUTE_TO" ), + QStringLiteral( "ROW" ), + QStringLiteral( "ROW_NUMBER" ), + QStringLiteral( "ROWCOUNT" ), + QStringLiteral( "ROWID" ), + QStringLiteral( "ROWS" ), + QStringLiteral( "RPAD" ), + QStringLiteral( "RTREE" ), + QStringLiteral( "RTRIM" ), + QStringLiteral( "RULE" ), + QStringLiteral( "RULES" ), + QStringLiteral( "RUNTIME" ), + QStringLiteral( "RUNTIMEDUMP" ), + QStringLiteral( "SAME_PARTITION_COUNT" ), + QStringLiteral( "SAML" ), + QStringLiteral( "SAMPLE" ), + QStringLiteral( "SAMPLING" ), + QStringLiteral( "SAP_TIMEZONE_DATASET" ), + QStringLiteral( "SATISFIES" ), + QStringLiteral( "SAVE" ), + QStringLiteral( "SAVEPOINT" ), + QStringLiteral( "SCAN" ), + QStringLiteral( "SCENARIO" ), + QStringLiteral( "SCHEDULER" ), + QStringLiteral( "SCHEMA" ), + QStringLiteral( "SCHEMA_NAME" ), + QStringLiteral( "SCORE" ), + QStringLiteral( "SCRAMBLE" ), + QStringLiteral( "SCROLL" ), + QStringLiteral( "SEARCH" ), + QStringLiteral( "SECOND" ), + QStringLiteral( "SECONDDATE" ), + QStringLiteral( "SECONDS_BETWEEN" ), + QStringLiteral( "SECONDTIME" ), + QStringLiteral( "SECTIONS" ), + QStringLiteral( "SECURE" ), + QStringLiteral( "SECURITY" ), + QStringLiteral( "SEED" ), + QStringLiteral( "SELECT" ), + QStringLiteral( "SEMANTICRELATION" ), + QStringLiteral( "SEMI" ), + QStringLiteral( "SENSITIVE" ), + QStringLiteral( "SEPARATORS" ), + QStringLiteral( "SEQUENCE" ), + QStringLiteral( "SEQUENTIAL" ), + QStringLiteral( "SERIALIZABLE" ), + QStringLiteral( "SERIES" ), + QStringLiteral( "SERIES_ELEMENT_TO_PERIOD" ), + QStringLiteral( "SERIES_PERIOD_TO_ELEMENT" ), + QStringLiteral( "SERIES_ROUND" ), + QStringLiteral( "SERVICE" ), + QStringLiteral( "SERVICES" ), + QStringLiteral( "SESSION" ), + QStringLiteral( "SESSION_CONTEXT" ), + QStringLiteral( "SESSION_USER" ), + QStringLiteral( "SET" ), + QStringLiteral( "SETOLAPMODEL" ), + QStringLiteral( "SETS" ), + QStringLiteral( "SHAPEFILE" ), + QStringLiteral( "SHARE" ), + QStringLiteral( "SHARED" ), + QStringLiteral( "SHOW" ), + QStringLiteral( "SIBLING" ), + QStringLiteral( "SIDATTRIBUTE" ), + QStringLiteral( "SIGNAL" ), + QStringLiteral( "SIMPLE" ), + QStringLiteral( "SITE" ), + QStringLiteral( "SIZE" ), + QStringLiteral( "SKETCH" ), + QStringLiteral( "SKIP" ), + QStringLiteral( "SMALLDECIMAL" ), + QStringLiteral( "SMALLINT" ), + QStringLiteral( "SNAP" ), + QStringLiteral( "SNAPINT" ), + QStringLiteral( "SNAPSHOT" ), + QStringLiteral( "SOME" ), + QStringLiteral( "SORT" ), + QStringLiteral( "SOURCE" ), + QStringLiteral( "SPACE" ), + QStringLiteral( "SPARSIFY" ), + QStringLiteral( "SPATIAL" ), + QStringLiteral( "SPLITFACTOR" ), + QStringLiteral( "SQL" ), + QStringLiteral( "SQL_ERROR_CODE" ), + QStringLiteral( "SQLSCRIPT" ), + QStringLiteral( "SRID" ), + QStringLiteral( "SSL" ), + QStringLiteral( "STAB" ), + QStringLiteral( "STANDARD" ), + QStringLiteral( "START" ), + QStringLiteral( "STATEMENT" ), + QStringLiteral( "STATEMENT_NAME" ), + QStringLiteral( "STATIC" ), + QStringLiteral( "STATISTICS" ), + QStringLiteral( "STOP" ), + QStringLiteral( "STORAGE" ), + QStringLiteral( "STORE" ), + QStringLiteral( "STRING" ), + QStringLiteral( "STRIP" ), + QStringLiteral( "STRUCTURED" ), + QStringLiteral( "STRUCTUREDPRIVILEGE" ), + QStringLiteral( "SUB_TYPE" ), + QStringLiteral( "SUBJECT" ), + QStringLiteral( "SUBPARTITION" ), + QStringLiteral( "SUBPARTITIONS" ), + QStringLiteral( "SUBSCRIPTION" ), + QStringLiteral( "SUBSTR" ), + QStringLiteral( "SUBSTR_AFTER" ), + QStringLiteral( "SUBSTR_BEFORE" ), + QStringLiteral( "SUBSTR_REGEXPR" ), + QStringLiteral( "SUBSTRING" ), + QStringLiteral( "SUBSTRING_REGEXPR" ), + QStringLiteral( "SUBTOTAL" ), + QStringLiteral( "SUBTYPE" ), + QStringLiteral( "SUCCESSFUL" ), + QStringLiteral( "SUPPORT" ), + QStringLiteral( "SUSPEND" ), + QStringLiteral( "SYNC" ), + QStringLiteral( "SYNCHRONOUS" ), + QStringLiteral( "SYNONYM" ), + QStringLiteral( "SYSLOG" ), + QStringLiteral( "SYSTEM" ), + QStringLiteral( "SYSTEM_TIME" ), + QStringLiteral( "SYSTEMS" ), + QStringLiteral( "SYSUUID" ), + QStringLiteral( "T" ), + QStringLiteral( "TABLE" ), + QStringLiteral( "TABLE_NAME" ), + QStringLiteral( "TABLES" ), + QStringLiteral( "TABLESAMPLE" ), + QStringLiteral( "TAKEOVER" ), + QStringLiteral( "TARGET" ), + QStringLiteral( "TASK" ), + QStringLiteral( "TB" ), + QStringLiteral( "TEMPLATEINDEX" ), + QStringLiteral( "TEMPORARY" ), + QStringLiteral( "TENANT" ), + QStringLiteral( "TERM" ), + QStringLiteral( "TEXT" ), + QStringLiteral( "TEXTATTRIBUTE" ), + QStringLiteral( "THEN" ), + QStringLiteral( "THREAD" ), + QStringLiteral( "THREADS" ), + QStringLiteral( "THRESHOLD" ), + QStringLiteral( "THROW_ERROR" ), + QStringLiteral( "TIME" ), + QStringLiteral( "TIMELINE" ), + QStringLiteral( "TIMEOUT" ), + QStringLiteral( "TIMESTAMP" ), + QStringLiteral( "TIMEZONE" ), + QStringLiteral( "TIMS_EXTRACT" ), + QStringLiteral( "TINYINT" ), + QStringLiteral( "TM_CATEGORIZE_KNN" ), + QStringLiteral( "TM_GET_RELATED_DOCUMENTS" ), + QStringLiteral( "TM_GET_RELATED_TERMS" ), + QStringLiteral( "TM_GET_RELEVANT_DOCUMENTS" ), + QStringLiteral( "TM_GET_RELEVANT_TERMS" ), + QStringLiteral( "TM_GET_SUGGESTED_TERMS" ), + QStringLiteral( "TO" ), + QStringLiteral( "TO_BIGINT" ), + QStringLiteral( "TO_BINARY" ), + QStringLiteral( "TO_BLOB" ), + QStringLiteral( "TO_CHAR" ), + QStringLiteral( "TO_CLOB" ), + QStringLiteral( "TO_DATE" ), + QStringLiteral( "TO_DECIMAL" ), + QStringLiteral( "TO_DOUBLE" ), + QStringLiteral( "TO_INT" ), + QStringLiteral( "TO_INTEGER" ), + QStringLiteral( "TO_JSON_BOOLEAN" ), + QStringLiteral( "TO_JSON_NUMBER" ), + QStringLiteral( "TO_NCHAR" ), + QStringLiteral( "TO_NCLOB" ), + QStringLiteral( "TO_NUMBER" ), + QStringLiteral( "TO_NVARCHAR" ), + QStringLiteral( "TO_REAL" ), + QStringLiteral( "TO_SECONDDATE" ), + QStringLiteral( "TO_SMALLDECIMAL" ), + QStringLiteral( "TO_SMALLINT" ), + QStringLiteral( "TO_TIME" ), + QStringLiteral( "TO_TIMESTAMP" ), + QStringLiteral( "TO_TINYINT" ), + QStringLiteral( "TO_VARBINARY" ), + QStringLiteral( "TO_VARCHAR" ), + QStringLiteral( "TOKEN" ), + QStringLiteral( "TOLERANCE" ), + QStringLiteral( "TOOLOPTION" ), + QStringLiteral( "TOP" ), + QStringLiteral( "TOPK" ), + QStringLiteral( "TOTAL" ), + QStringLiteral( "TRACE" ), + QStringLiteral( "TRACEPROFILE" ), + QStringLiteral( "TRACES" ), + QStringLiteral( "TRAIL" ), + QStringLiteral( "TRAILING" ), + QStringLiteral( "TRANSACTION" ), + QStringLiteral( "TRANSFORM" ), + QStringLiteral( "TREE" ), + QStringLiteral( "TREX" ), + QStringLiteral( "TRIGGER" ), + QStringLiteral( "TRIGGER_UPDATE_COLUMN" ), + QStringLiteral( "TRIM" ), + QStringLiteral( "TRUE" ), + QStringLiteral( "TRUNCATE" ), + QStringLiteral( "TRUST" ), + QStringLiteral( "TS" ), + QStringLiteral( "TYPE" ), + QStringLiteral( "TYPENUMBERATTRIBUTE" ), + QStringLiteral( "TYPETEXTATTRIBUTE" ), + QStringLiteral( "UNAUTHORIZED" ), + QStringLiteral( "UNBOUNDED" ), + QStringLiteral( "UNCOMMITTED" ), + QStringLiteral( "UNCONDITIONAL" ), + QStringLiteral( "UNION" ), + QStringLiteral( "UNIQUE" ), + QStringLiteral( "UNIT" ), + QStringLiteral( "UNITCONVERSION" ), + QStringLiteral( "UNITCONVERSIONNAME" ), + QStringLiteral( "UNKNOWN" ), + QStringLiteral( "UNLOAD" ), + QStringLiteral( "UNLOCK" ), + QStringLiteral( "UNMASKED" ), + QStringLiteral( "UNNEST" ), + QStringLiteral( "UNPIN" ), + QStringLiteral( "UNREGISTER" ), + QStringLiteral( "UNSET" ), + QStringLiteral( "UNSUCCESSFUL" ), + QStringLiteral( "UNTIL" ), + QStringLiteral( "UNUSED" ), + QStringLiteral( "UP" ), + QStringLiteral( "UPDATE" ), + QStringLiteral( "UPSERT" ), + QStringLiteral( "URL" ), + QStringLiteral( "USAGE" ), + QStringLiteral( "USE_C2R_CONV" ), + QStringLiteral( "USE_COLUMN_JOIN_IMPLICIT_CAST" ), + QStringLiteral( "USE_OLAP_PLAN" ), + QStringLiteral( "USE_PREAGGR" ), + QStringLiteral( "USE_QUERY_MATCH" ), + QStringLiteral( "USE_R2C_CONV" ), + QStringLiteral( "USE_TRANSFORMATION" ), + QStringLiteral( "USE_UNION_OPT" ), + QStringLiteral( "USEINITIALREORG" ), + QStringLiteral( "USER" ), + QStringLiteral( "USERGROUP" ), + QStringLiteral( "USERS" ), + QStringLiteral( "USING" ), + QStringLiteral( "UTCTIMESTAMP" ), + QStringLiteral( "UTF16" ), + QStringLiteral( "UTF32" ), + QStringLiteral( "UTF8" ), + QStringLiteral( "VALID" ), + QStringLiteral( "VALIDATE" ), + QStringLiteral( "VALIDATED" ), + QStringLiteral( "VALIDATION" ), + QStringLiteral( "VALUE" ), + QStringLiteral( "VALUES" ), + QStringLiteral( "VARBINARY" ), + QStringLiteral( "VARCHAR" ), + QStringLiteral( "VARCHAR1" ), + QStringLiteral( "VARCHAR2" ), + QStringLiteral( "VARCHAR3" ), + QStringLiteral( "VARIABLE" ), + QStringLiteral( "VARYING" ), + QStringLiteral( "VERIFY" ), + QStringLiteral( "VERSION" ), + QStringLiteral( "VERSIONING" ), + QStringLiteral( "VERSIONS" ), + QStringLiteral( "VERTEX" ), + QStringLiteral( "VERTICAL" ), + QStringLiteral( "VIEW" ), + QStringLiteral( "VIEWATTRIBUTE" ), + QStringLiteral( "VIRTUAL" ), + QStringLiteral( "VOLUME" ), + QStringLiteral( "VOLUMES" ), + QStringLiteral( "WAIT" ), + QStringLiteral( "WAITGRAPH" ), + QStringLiteral( "WARNING" ), + QStringLiteral( "WEEKDAY" ), + QStringLiteral( "WEIGHT" ), + QStringLiteral( "WHEN" ), + QStringLiteral( "WHERE" ), + QStringLiteral( "WHILE" ), + QStringLiteral( "WHY_FOUND" ), + QStringLiteral( "WILDCARD" ), + QStringLiteral( "WINDOW" ), + QStringLiteral( "WITH" ), + QStringLiteral( "WITHIN" ), + QStringLiteral( "WITHOUT" ), + QStringLiteral( "WORK" ), + QStringLiteral( "WORKAROUND" ), + QStringLiteral( "WORKERGROUPS" ), + QStringLiteral( "WORKLOAD" ), + QStringLiteral( "WORKSPACE" ), + QStringLiteral( "WRAPPER" ), + QStringLiteral( "WRITE" ), + QStringLiteral( "X" ), + QStringLiteral( "X509" ), + QStringLiteral( "XML" ), + QStringLiteral( "XMLNAMESPACE" ), + QStringLiteral( "XMLTABLE" ), + QStringLiteral( "XTAB" ), + QStringLiteral( "Y" ), + QStringLiteral( "YEAR" ), + QStringLiteral( "YTAB" ), + QStringLiteral( "ZONE" ), + } + }, + { Qgis::SqlKeywordCategory::Aggregate, + { + QStringLiteral( "AUTO_CORR" ), + QStringLiteral( "AVG" ), + QStringLiteral( "CORR" ), + QStringLiteral( "CORR_SPEARMAN" ), + QStringLiteral( "COUNT" ), + QStringLiteral( "CROSS_CORR" ), + QStringLiteral( "DFT" ), + QStringLiteral( "FIRST_VALUE" ), + QStringLiteral( "LAST_VALUE" ), + QStringLiteral( "MAX" ), + QStringLiteral( "MEDIAN" ), + QStringLiteral( "MIN" ), + QStringLiteral( "NTH_VALUE" ), + QStringLiteral( "STDDEV" ), + QStringLiteral( "STDDEV_POP" ), + QStringLiteral( "STDDEV_SAMP" ), + QStringLiteral( "STRING_AGG" ), + QStringLiteral( "SUM" ), + QStringLiteral( "VAR" ), + QStringLiteral( "VAR_POP" ), + QStringLiteral( "VAR_SAMP" ), + } + }, + { Qgis::SqlKeywordCategory::Math, + { + QStringLiteral( "ABS" ), + QStringLiteral( "ACOS" ), + QStringLiteral( "ASIN" ), + QStringLiteral( "ATAN" ), + QStringLiteral( "ATAN2" ), + QStringLiteral( "BITAND" ), + QStringLiteral( "BITCOUNT" ), + QStringLiteral( "BITNOT" ), + QStringLiteral( "BITOR" ), + QStringLiteral( "BITSET" ), + QStringLiteral( "BITUNSET" ), + QStringLiteral( "BITXOR" ), + QStringLiteral( "CEIL" ), + QStringLiteral( "COS" ), + QStringLiteral( "COSH" ), + QStringLiteral( "COT" ), + QStringLiteral( "EXP" ), + QStringLiteral( "FLOOR" ), + QStringLiteral( "LN" ), + QStringLiteral( "LOG" ), + QStringLiteral( "MOD" ), + QStringLiteral( "NDIV0" ), + QStringLiteral( "POWER" ), + QStringLiteral( "RAND" ), + QStringLiteral( "RAND_SECURE" ), + QStringLiteral( "ROUND" ), + QStringLiteral( "SIGN" ), + QStringLiteral( "SIN" ), + QStringLiteral( "SINH" ), + QStringLiteral( "SQRT" ), + QStringLiteral( "TAN" ), + QStringLiteral( "TANH" ), + } + }, + { Qgis::SqlKeywordCategory::Geospatial, + { + QStringLiteral( "ST_AlphaShape" ), + QStringLiteral( "ST_AlphaShapeAggr" ), + QStringLiteral( "ST_AlphaShapeArea" ), + QStringLiteral( "ST_AlphaShapeAreaAggr" ), + QStringLiteral( "ST_AlphaShapeEdge" ), + QStringLiteral( "ST_AlphaShapeEdgeAggr" ), + QStringLiteral( "ST_AsBinary" ), + QStringLiteral( "ST_AsEsriJSON" ), + QStringLiteral( "ST_AsEWKB" ), + QStringLiteral( "ST_AsEWKT" ), + QStringLiteral( "ST_AsGeoJSON" ), + QStringLiteral( "ST_AsSVG" ), + QStringLiteral( "ST_AsSVGAggr" ), + QStringLiteral( "ST_AsText" ), + QStringLiteral( "ST_AsWKB" ), + QStringLiteral( "ST_AsWKT" ), + QStringLiteral( "ST_Boundary" ), + QStringLiteral( "ST_Buffer" ), + QStringLiteral( "ST_CircularString" ), + QStringLiteral( "ST_Collect" ), + QStringLiteral( "ST_CollectAggr" ), + QStringLiteral( "ST_Contains" ), + QStringLiteral( "ST_ConvexHull" ), + QStringLiteral( "ST_ConvexHullAggr" ), + QStringLiteral( "ST_CoordDim" ), + QStringLiteral( "ST_CoveredBy" ), + QStringLiteral( "ST_Covers" ), + QStringLiteral( "ST_Crosses" ), + QStringLiteral( "ST_Difference" ), + QStringLiteral( "ST_Dimension" ), + QStringLiteral( "ST_Disjoint" ), + QStringLiteral( "ST_Distance" ), + QStringLiteral( "ST_Envelope" ), + QStringLiteral( "ST_EnvelopeAggr" ), + QStringLiteral( "ST_EnvelopeAggr" ), + QStringLiteral( "ST_Equals" ), + QStringLiteral( "ST_Force2D" ), + QStringLiteral( "ST_Force3DM" ), + QStringLiteral( "ST_Force3DZ" ), + QStringLiteral( "ST_Force4D" ), + QStringLiteral( "ST_GeoHash" ), + QStringLiteral( "ST_GeomFromEsriJSON" ), + QStringLiteral( "ST_GeomFromEWKB" ), + QStringLiteral( "ST_GeomFromEWKT" ), + QStringLiteral( "ST_GeomFromGeoHash" ), + QStringLiteral( "ST_GeomFromText" ), + QStringLiteral( "ST_GeomFromWKB" ), + QStringLiteral( "ST_GeomFromWKT" ), + QStringLiteral( "ST_GeometryCollection" ), + QStringLiteral( "ST_GeometryN" ), + QStringLiteral( "ST_GeometryType" ), + QStringLiteral( "ST_Intersection" ), + QStringLiteral( "ST_IntersectionAggr" ), + QStringLiteral( "ST_Intersects" ), + QStringLiteral( "ST_IntersectsFilter" ), + QStringLiteral( "ST_IntersectsRect" ), + QStringLiteral( "ST_Is3D" ), + QStringLiteral( "ST_IsEmpty" ), + QStringLiteral( "ST_IsMeasured" ), + QStringLiteral( "ST_IsSimple" ), + QStringLiteral( "ST_IsValid" ), + QStringLiteral( "ST_LineString" ), + QStringLiteral( "ST_MultiLineString" ), + QStringLiteral( "ST_MultiPoint" ), + QStringLiteral( "ST_MultiPolygon" ), + QStringLiteral( "ST_MMax" ), + QStringLiteral( "ST_MMin" ), + QStringLiteral( "ST_NumInteriorRing" ), + QStringLiteral( "ST_NumInteriorRings" ), + QStringLiteral( "ST_OrderingEquals" ), + QStringLiteral( "ST_Overlaps" ), + QStringLiteral( "ST_Perimeter" ), + QStringLiteral( "ST_Point" ), + QStringLiteral( "ST_PointOnSurface" ), + QStringLiteral( "ST_Polygon" ), + QStringLiteral( "ST_SquareGrid" ), + QStringLiteral( "ST_RectangleGrid" ), + QStringLiteral( "ST_RectangleGridBoundingBox" ), + QStringLiteral( "ST_Relate" ), + QStringLiteral( "ST_Rotate" ), + QStringLiteral( "ST_Scale" ), + QStringLiteral( "ST_Simplify" ), + QStringLiteral( "ST_SnapToGrid" ), + QStringLiteral( "ST_SRID" ), + QStringLiteral( "ST_SymDifference" ), + QStringLiteral( "ST_Touches" ), + QStringLiteral( "ST_Transform" ), + QStringLiteral( "ST_Translate" ), + QStringLiteral( "ST_Translate3D" ), + QStringLiteral( "ST_Union" ), + QStringLiteral( "ST_UnionAggr" ), + QStringLiteral( "ST_VoronoiCell" ), + QStringLiteral( "ST_Within" ), + QStringLiteral( "ST_WithinDistance" ), + QStringLiteral( "ST_XMax" ), + QStringLiteral( "ST_XMin" ), + QStringLiteral( "ST_YMax" ), + QStringLiteral( "ST_YMin" ), + QStringLiteral( "ST_ZMax" ), + QStringLiteral( "ST_ZMin" ), + } } } - } ); + ); } QVariantList QgsHanaEmptyProviderResultIterator::nextRowPrivate() diff --git a/src/providers/hana/qgshanaproviderconnection.h b/src/providers/hana/qgshanaproviderconnection.h index 81e4796b72c5..fa8b97913965 100644 --- a/src/providers/hana/qgshanaproviderconnection.h +++ b/src/providers/hana/qgshanaproviderconnection.h @@ -22,7 +22,7 @@ #include "qgshanaconnectionpool.h" #include "qgshanaresultset.h" -struct QgsHanaEmptyProviderResultIterator: public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator +struct QgsHanaEmptyProviderResultIterator : public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator { // QueryResultIterator interface private: @@ -31,7 +31,7 @@ struct QgsHanaEmptyProviderResultIterator: public QgsAbstractDatabaseProviderCon long long rowCountPrivate() const override { return 0; }; }; -struct QgsHanaProviderResultIterator: public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator +struct QgsHanaProviderResultIterator : public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator { QgsHanaProviderResultIterator( QgsHanaConnectionRef &&conn, QgsHanaResultSetRef &&resultSet ); @@ -57,12 +57,7 @@ class QgsHanaProviderConnection : public QgsAbstractDatabaseProviderConnection QgsHanaProviderConnection( const QString &uri, const QVariantMap &configuration ); public: - void createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, bool overwrite, - const QMap *options ) const override; + void createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const override; QString tableUri( const QString &schema, const QString &name ) const override; void dropVectorTable( const QString &schema, const QString &name ) const override; @@ -72,9 +67,8 @@ class QgsHanaProviderConnection : public QgsAbstractDatabaseProviderConnection void renameSchema( const QString &name, const QString &newName ) const override; QueryResult execSql( const QString &sql, QgsFeedback *feedback = nullptr ) const override; QgsAbstractDatabaseProviderConnection::TableProperty table( const QString &schema, const QString &table, QgsFeedback *feedback = nullptr ) const override; - QList tables( const QString &schema, - const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; - QStringList schemas( ) const override; + QList tables( const QString &schema, const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; + QStringList schemas() const override; QgsFields fields( const QString &schema, const QString &table, QgsFeedback *feedback = nullptr ) const override; void store( const QString &name ) const override; void remove( const QString &name ) const override; @@ -88,8 +82,7 @@ class QgsHanaProviderConnection : public QgsAbstractDatabaseProviderConnection QgsHanaConnectionRef createConnection() const; void executeSqlStatement( const QString &sql ) const; void setCapabilities(); - QList tablesWithFilter( const QString &schema, - const TableFlags &flags = TableFlags(), const std::function &layerFilter = nullptr ) const; + QList tablesWithFilter( const QString &schema, const TableFlags &flags = TableFlags(), const std::function &layerFilter = nullptr ) const; }; #endif // QGSHANAPROVIDERCONNECTION_H diff --git a/src/providers/hana/qgshanaprovidergui.cpp b/src/providers/hana/qgshanaprovidergui.cpp index 2a8e1f13990a..5e50a8a87927 100644 --- a/src/providers/hana/qgshanaprovidergui.cpp +++ b/src/providers/hana/qgshanaprovidergui.cpp @@ -34,8 +34,7 @@ class QgsHanaSourceSelectProvider : public QgsSourceSelectProvider QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddHanaLayer.svg" ) ); } - QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, - QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override + QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override { return new QgsHanaSourceSelect( parent, fl, widgetMode ); } @@ -44,7 +43,8 @@ class QgsHanaSourceSelectProvider : public QgsSourceSelectProvider class QgsHanaProviderGuiMetadata : public QgsProviderGuiMetadata { public: - QgsHanaProviderGuiMetadata() : QgsProviderGuiMetadata( QgsHanaProvider::HANA_KEY ) + QgsHanaProviderGuiMetadata() + : QgsProviderGuiMetadata( QgsHanaProvider::HANA_KEY ) { } diff --git a/src/providers/hana/qgshanaresultset.cpp b/src/providers/hana/qgshanaresultset.cpp index f2484e10f435..481cdd1ecc92 100644 --- a/src/providers/hana/qgshanaresultset.cpp +++ b/src/providers/hana/qgshanaresultset.cpp @@ -48,7 +48,7 @@ namespace return res; } -} +} // namespace QgsHanaResultSet::QgsHanaResultSet( ResultSetRef &&resultSet ) : mResultSet( std::move( resultSet ) ) @@ -164,22 +164,22 @@ QVariant QgsHanaResultSet::getValue( unsigned short columnIndex ) return QgsHanaUtils::toVariant( str ); } case QgsHanaDataType::TinyInt: - if ( mMetadata ->isSigned( columnIndex ) ) + if ( mMetadata->isSigned( columnIndex ) ) return QgsHanaUtils::toVariant( mResultSet->getByte( columnIndex ) ); else return QgsHanaUtils::toVariant( mResultSet->getUByte( columnIndex ) ); case QgsHanaDataType::SmallInt: - if ( mMetadata ->isSigned( columnIndex ) ) + if ( mMetadata->isSigned( columnIndex ) ) return QgsHanaUtils::toVariant( mResultSet->getShort( columnIndex ) ); else return QgsHanaUtils::toVariant( mResultSet->getUShort( columnIndex ) ); case QgsHanaDataType::Integer: - if ( mMetadata ->isSigned( columnIndex ) ) + if ( mMetadata->isSigned( columnIndex ) ) return QgsHanaUtils::toVariant( mResultSet->getInt( columnIndex ) ); else return QgsHanaUtils::toVariant( mResultSet->getUInt( columnIndex ) ); case QgsHanaDataType::BigInt: - if ( mMetadata ->isSigned( columnIndex ) ) + if ( mMetadata->isSigned( columnIndex ) ) return QgsHanaUtils::toVariant( mResultSet->getLong( columnIndex ) ); else return QgsHanaUtils::toVariant( mResultSet->getULong( columnIndex ) ); @@ -239,11 +239,10 @@ QVariant QgsHanaResultSet::getValue( unsigned short columnIndex ) QgsGeometry QgsHanaResultSet::getGeometry( unsigned short columnIndex ) { - auto toWkbSize = []( size_t size ) - { + auto toWkbSize = []( size_t size ) { if ( size > static_cast( std::numeric_limits::max() ) ) throw QgsHanaException( "Geometry size is larger than maximum integer value" ); - return static_cast( size ); + return static_cast( size ); }; const size_t bufLength = mResultSet->getBinaryLength( columnIndex ); diff --git a/src/providers/hana/qgshanasettings.cpp b/src/providers/hana/qgshanasettings.cpp index 7ab3509c6ceb..40140f8c37eb 100644 --- a/src/providers/hana/qgshanasettings.cpp +++ b/src/providers/hana/qgshanasettings.cpp @@ -284,9 +284,9 @@ void QgsHanaSettings::save() settings.setValue( key + QStringLiteral( "/schema" ), mSchema ); settings.setValue( key + QStringLiteral( "/authcfg" ), mAuthcfg ); settings.setValue( key + QStringLiteral( "/saveUsername" ), mSaveUserName ); - settings.setValue( key + QStringLiteral( "/username" ), mSaveUserName ? mUserName : QString( ) ); + settings.setValue( key + QStringLiteral( "/username" ), mSaveUserName ? mUserName : QString() ); settings.setValue( key + QStringLiteral( "/savePassword" ), mSavePassword ); - settings.setValue( key + QStringLiteral( "/password" ), mSavePassword ? mPassword : QString( ) ); + settings.setValue( key + QStringLiteral( "/password" ), mSavePassword ? mPassword : QString() ); settings.setValue( key + QStringLiteral( "/userTablesOnly" ), mUserTablesOnly ); settings.setValue( key + QStringLiteral( "/allowGeometrylessTables" ), mAllowGeometrylessTables ); settings.setValue( key + QStringLiteral( "/estimatedMetadata" ), mUseEstimatedMetadata ); diff --git a/src/providers/hana/qgshanasettings.h b/src/providers/hana/qgshanasettings.h index c2ec200742e7..426a43e2e660 100644 --- a/src/providers/hana/qgshanasettings.h +++ b/src/providers/hana/qgshanasettings.h @@ -22,14 +22,14 @@ struct QgsHanaIdentifierType { - enum Value - { - InstanceNumber = 0, - PortNumber = 1 - }; - - static bool isValid( uint ) noexcept; - static Value fromInt( uint ); + enum Value + { + InstanceNumber = 0, + PortNumber = 1 + }; + + static bool isValid( uint ) noexcept; + static Value fromInt( uint ); }; enum class QgsHanaConnectionType : uint @@ -287,7 +287,7 @@ class QgsHanaSettings /** * Constructs an instance of QgsDataSourceUri with values of the current object. */ - QgsDataSourceUri toDataSourceUri() const ; + QgsDataSourceUri toDataSourceUri() const; /** * Loads HANA connection settings from /HANA/connections/{connection_name}. diff --git a/src/providers/hana/qgshanasourceselect.cpp b/src/providers/hana/qgshanasourceselect.cpp index 6bc7f89d123b..e710cb6cab83 100644 --- a/src/providers/hana/qgshanasourceselect.cpp +++ b/src/providers/hana/qgshanasourceselect.cpp @@ -40,7 +40,8 @@ //! Used to create an editor for when the user tries to change the contents of a cell QWidget *QgsHanaSourceSelectDelegate::createEditor( - QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const + QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index +) const { Q_UNUSED( option ); @@ -58,17 +59,17 @@ QWidget *QgsHanaSourceSelectDelegate::createEditor( QComboBox *cb = new QComboBox( parent ); for ( const Qgis::WkbType type : QList() - << Qgis::WkbType::Point - << Qgis::WkbType::LineString - << Qgis::WkbType::Polygon - << Qgis::WkbType::MultiPoint - << Qgis::WkbType::MultiLineString - << Qgis::WkbType::MultiPolygon - << Qgis::WkbType::CircularString - << Qgis::WkbType::GeometryCollection - << Qgis::WkbType::NoGeometry ) + << Qgis::WkbType::Point + << Qgis::WkbType::LineString + << Qgis::WkbType::Polygon + << Qgis::WkbType::MultiPoint + << Qgis::WkbType::MultiLineString + << Qgis::WkbType::MultiPolygon + << Qgis::WkbType::CircularString + << Qgis::WkbType::GeometryCollection + << Qgis::WkbType::NoGeometry ) { - cb->addItem( QgsHanaTableModel::iconForWkbType( type ), QgsWkbTypes::displayString( type ), static_cast< quint32>( type ) ); + cb->addItem( QgsHanaTableModel::iconForWkbType( type ), QgsWkbTypes::displayString( type ), static_cast( type ) ); } return cb; } @@ -111,7 +112,8 @@ QWidget *QgsHanaSourceSelectDelegate::createEditor( } void QgsHanaSourceSelectDelegate::setModelData( - QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const + QWidget *editor, QAbstractItemModel *model, const QModelIndex &index +) const { QComboBox *cb = qobject_cast( editor ); if ( cb ) @@ -122,7 +124,7 @@ void QgsHanaSourceSelectDelegate::setModelData( model->setData( index, QgsHanaTableModel::iconForWkbType( type ), Qt::DecorationRole ); model->setData( index, type != Qgis::WkbType::Unknown ? QgsWkbTypes::displayString( type ) : tr( "Select…" ) ); - model->setData( index, static_cast< quint32>( type ), Qt::UserRole + 2 ); + model->setData( index, static_cast( type ), Qt::UserRole + 2 ); } else if ( index.column() == QgsHanaTableModel::DbtmPkCol ) { @@ -162,8 +164,7 @@ void QgsHanaSourceSelectDelegate::setEditorData( QWidget *editor, const QModelIn if ( index.column() == QgsHanaTableModel::DbtmGeomType ) cb->setCurrentIndex( cb->findData( index.data( Qt::UserRole + 2 ).toInt() ) ); - if ( index.column() == QgsHanaTableModel::DbtmPkCol && - !index.data( Qt::UserRole + 2 ).toStringList().isEmpty() ) + if ( index.column() == QgsHanaTableModel::DbtmPkCol && !index.data( Qt::UserRole + 2 ).toStringList().isEmpty() ) { const QStringList columns = index.data( Qt::UserRole + 2 ).toStringList(); for ( const QString &colName : columns ) @@ -186,7 +187,7 @@ void QgsHanaSourceSelectDelegate::setEditorData( QWidget *editor, const QModelIn if ( le ) { bool ok; - ( void )value.toInt( &ok ); + ( void ) value.toInt( &ok ); if ( index.column() == QgsHanaTableModel::DbtmSrid && !ok ) value.clear(); @@ -197,7 +198,8 @@ void QgsHanaSourceSelectDelegate::setEditorData( QWidget *editor, const QModelIn QgsHanaSourceSelect::QgsHanaSourceSelect( QWidget *parent, Qt::WindowFlags fl, - QgsProviderRegistry::WidgetMode theWidgetMode ) + QgsProviderRegistry::WidgetMode theWidgetMode +) : QgsAbstractDbSourceSelect( parent, fl, theWidgetMode ) { QgsGui::instance()->enableAutoGeometryRestore( this ); @@ -209,8 +211,7 @@ QgsHanaSourceSelect::QgsHanaSourceSelect( connect( btnDelete, &QPushButton::clicked, this, &QgsHanaSourceSelect::btnDelete_clicked ); connect( btnSave, &QPushButton::clicked, this, &QgsHanaSourceSelect::btnSave_clicked ); connect( btnLoad, &QPushButton::clicked, this, &QgsHanaSourceSelect::btnLoad_clicked ); - connect( cmbConnections, static_cast( &QComboBox::activated ), - this, &QgsHanaSourceSelect::cmbConnections_activated ); + connect( cmbConnections, static_cast( &QComboBox::activated ), this, &QgsHanaSourceSelect::cmbConnections_activated ); setupButtons( buttonBox ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsHanaSourceSelect::showHelp ); @@ -224,20 +225,17 @@ QgsHanaSourceSelect::QgsHanaSourceSelect( mTableModel = new QgsHanaTableModel( this ); init( mTableModel, new QgsHanaSourceSelectDelegate( this ) ); - connect( mTablesTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &QgsHanaSourceSelect::treeWidgetSelectionChanged ); + connect( mTablesTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsHanaSourceSelect::treeWidgetSelectionChanged ); const QgsSettings settings; - mTablesTreeView->setSelectionMode( settings.value( QStringLiteral( "qgis/addHanaDC" ), false ).toBool() ? - QAbstractItemView::ExtendedSelection : QAbstractItemView::MultiSelection ); + mTablesTreeView->setSelectionMode( settings.value( QStringLiteral( "qgis/addHanaDC" ), false ).toBool() ? QAbstractItemView::ExtendedSelection : QAbstractItemView::MultiSelection ); restoreGeometry( settings.value( QStringLiteral( "Windows/HanaSourceSelect/geometry" ) ).toByteArray() ); mHoldDialogOpen->setChecked( settings.value( QStringLiteral( "Windows/HanaSourceSelect/HoldDialogOpen" ), false ).toBool() ); for ( int i = 0; i < mTableModel->columnCount(); i++ ) { - mTablesTreeView->setColumnWidth( i, settings.value( QStringLiteral( "Windows/HanaSourceSelect/columnWidths/%1" ) - .arg( i ), mTablesTreeView->columnWidth( i ) ).toInt() ); + mTablesTreeView->setColumnWidth( i, settings.value( QStringLiteral( "Windows/HanaSourceSelect/columnWidths/%1" ).arg( i ), mTablesTreeView->columnWidth( i ) ).toInt() ); } cbxAllowGeometrylessTables->setDisabled( true ); @@ -258,7 +256,7 @@ void QgsHanaSourceSelect::btnNew_clicked() void QgsHanaSourceSelect::btnDelete_clicked() { const QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ) - .arg( cmbConnections->currentText() ); + .arg( cmbConnections->currentText() ); if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) ) return; @@ -281,15 +279,13 @@ void QgsHanaSourceSelect::btnSave_clicked() void QgsHanaSourceSelect::btnLoad_clicked() { - const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), - QDir::homePath(), tr( "XML files (*.xml *XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *XML)" ) ); if ( fileName.isEmpty() ) { return; } - QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Import, - QgsManageConnectionsDialog::HANA, fileName ); + QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Import, QgsManageConnectionsDialog::HANA, fileName ); dlg.exec(); populateConnectionList(); } @@ -353,8 +349,7 @@ QgsHanaSourceSelect::~QgsHanaSourceSelect() for ( int i = 0; i < mTableModel->columnCount(); i++ ) { - settings.setValue( QStringLiteral( "Windows/HanaSourceSelect/columnWidths/%1" ) - .arg( i ), mTablesTreeView->columnWidth( i ) ); + settings.setValue( QStringLiteral( "Windows/HanaSourceSelect/columnWidths/%1" ).arg( i ), mTablesTreeView->columnWidth( i ) ); } } @@ -452,17 +447,12 @@ void QgsHanaSourceSelect::btnConnect_clicked() mColumnTypeTask = std::make_unique( tr( "Scanning tables for %1" ).arg( mConnectionName ) ); QgsApplication::taskManager()->addTask( mColumnTypeTask.get() ); - connect( mColumnTypeThread.get(), &QgsHanaColumnTypeThread::setLayerType, - this, &QgsHanaSourceSelect::setLayerType ); - connect( mColumnTypeThread.get(), &QThread::finished, - this, &QgsHanaSourceSelect::columnThreadFinished ); - connect( mColumnTypeThread.get(), &QgsHanaColumnTypeThread::progress, - mColumnTypeTask.get(), [&]( int i, int n ) - { + connect( mColumnTypeThread.get(), &QgsHanaColumnTypeThread::setLayerType, this, &QgsHanaSourceSelect::setLayerType ); + connect( mColumnTypeThread.get(), &QThread::finished, this, &QgsHanaSourceSelect::columnThreadFinished ); + connect( mColumnTypeThread.get(), &QgsHanaColumnTypeThread::progress, mColumnTypeTask.get(), [&]( int i, int n ) { mColumnTypeTask->setProxyProgress( 100.0 * static_cast( i ) / n ); } ); - connect( mColumnTypeThread.get(), &QgsHanaColumnTypeThread::progressMessage, - this, &QgsHanaSourceSelect::progressMessage ); + connect( mColumnTypeThread.get(), &QgsHanaColumnTypeThread::progressMessage, this, &QgsHanaSourceSelect::progressMessage ); btnConnect->setText( tr( "Stop" ) ); mColumnTypeThread->start(); @@ -522,7 +512,8 @@ void QgsHanaSourceSelect::setSql( const QModelIndex &index ) } QString QgsHanaSourceSelect::fullDescription( - const QString &schema, const QString &table, const QString &column, const QString &type ) + const QString &schema, const QString &table, const QString &column, const QString &type +) { QString desc; if ( !schema.isEmpty() ) @@ -545,7 +536,8 @@ void QgsHanaSourceSelect::setSearchExpression( const QString ®exp ) } void QgsHanaSourceSelect::treeWidgetSelectionChanged( - const QItemSelection &selected, const QItemSelection &deselected ) + const QItemSelection &selected, const QItemSelection &deselected +) { Q_UNUSED( deselected ) emit enableButtons( !selected.isEmpty() ); diff --git a/src/providers/hana/qgshanasourceselect.h b/src/providers/hana/qgshanasourceselect.h index 9fe67b44196b..8267217cb08c 100644 --- a/src/providers/hana/qgshanasourceselect.h +++ b/src/providers/hana/qgshanasourceselect.h @@ -45,11 +45,13 @@ class QgsHanaSourceSelectDelegate : public QItemDelegate QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index ) const override; + const QModelIndex &index + ) const override; void setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const override; + const QModelIndex &index + ) const override; void setEditorData( QWidget *editor, const QModelIndex &index ) const override; }; @@ -66,7 +68,6 @@ class QgsHanaSourceSelect : public QgsAbstractDbSourceSelect Q_OBJECT public: - //! static function to delete a connection static void deleteConnection( const QString &key ); @@ -74,7 +75,8 @@ class QgsHanaSourceSelect : public QgsAbstractDbSourceSelect QgsHanaSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, - QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Standalone ); + QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Standalone + ); ~QgsHanaSourceSelect() override; //! Populate the connection list combo box @@ -131,7 +133,8 @@ class QgsHanaSourceSelect : public QgsAbstractDbSourceSelect const QString &schema, const QString &table, const QString &column, - const QString &type ); + const QString &type + ); void finishList(); void showHelp(); diff --git a/src/providers/hana/qgshanatablemodel.cpp b/src/providers/hana/qgshanatablemodel.cpp index bc3b6ecf6259..81106cdc8da9 100644 --- a/src/providers/hana/qgshanatablemodel.cpp +++ b/src/providers/hana/qgshanatablemodel.cpp @@ -90,10 +90,9 @@ void QgsHanaTableModel::addTableEntry( const QString &connName, const QgsHanaLay } QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName ); - QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), - wkbType == Qgis::WkbType::Unknown ? tr( "Select…" ) : QgsWkbTypes::displayString( wkbType ) ); + QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == Qgis::WkbType::Unknown ? tr( "Select…" ) : QgsWkbTypes::displayString( wkbType ) ); typeItem->setData( wkbType == Qgis::WkbType::Unknown, Qt::UserRole + 1 ); - typeItem->setData( static_cast< quint32>( wkbType ), Qt::UserRole + 2 ); + typeItem->setData( static_cast( wkbType ), Qt::UserRole + 2 ); if ( wkbType == Qgis::WkbType::Unknown ) typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable ); @@ -137,7 +136,7 @@ void QgsHanaTableModel::addTableEntry( const QString &connName, const QgsHanaLay if ( !pkColumns.isEmpty() ) pkItem->setText( pkColumns.join( ',' ) ); - QStandardItem *selItem = new QStandardItem( QString( ) ); + QStandardItem *selItem = new QStandardItem( QString() ); selItem->setFlags( selItem->flags() | Qt::ItemIsUserCheckable ); selItem->setCheckState( Qt::Checked ); selItem->setToolTip( tr( "Disable 'Fast Access to Features at ID' capability to force keeping " @@ -157,7 +156,7 @@ void QgsHanaTableModel::addTableEntry( const QString &connName, const QgsHanaLay childItemList << selItem; childItemList << sqlItem; - for ( QStandardItem *item : std::as_const( childItemList ) ) + for ( QStandardItem *item : std::as_const( childItemList ) ) { if ( tip.isEmpty() || withTipButSelectable ) item->setFlags( item->flags() | Qt::ItemIsSelectable ); @@ -166,7 +165,7 @@ void QgsHanaTableModel::addTableEntry( const QString &connName, const QgsHanaLay if ( tip.isEmpty() ) { - item->setToolTip( QString( ) ); + item->setToolTip( QString() ); } else { @@ -310,7 +309,7 @@ bool QgsHanaTableModel::setData( const QModelIndex &idx, const QVariant &value, } item->setFlags( item->flags() | Qt::ItemIsSelectable ); - item->setToolTip( QString( ) ); + item->setToolTip( QString() ); } else { @@ -367,7 +366,7 @@ QString QgsHanaTableModel::layerURI( const QModelIndex &index, const QString &co srid = index.sibling( index.row(), DbtmSrid ).data( Qt::DisplayRole ).toString(); bool ok; - ( void )srid.toInt( &ok ); + ( void ) srid.toInt( &ok ); if ( !ok ) return QString(); } @@ -376,7 +375,7 @@ QString QgsHanaTableModel::layerURI( const QModelIndex &index, const QString &co QString sql = index.sibling( index.row(), DbtmSql ).data( Qt::DisplayRole ).toString(); QgsDataSourceUri uri( connInfo ); - uri.setDataSource( schemaName, tableName, geomColumnName, sql, QgsHanaPrimaryKeyUtils::buildUriKey( pkColumns ) ); + uri.setDataSource( schemaName, tableName, geomColumnName, sql, QgsHanaPrimaryKeyUtils::buildUriKey( pkColumns ) ); uri.setWkbType( wkbType ); uri.setSrid( srid ); uri.disableSelectAtId( !selectAtId ); diff --git a/src/providers/hana/qgshanatablemodel.h b/src/providers/hana/qgshanatablemodel.h index a5bcf48522e0..3ec7295e786b 100644 --- a/src/providers/hana/qgshanatablemodel.h +++ b/src/providers/hana/qgshanatablemodel.h @@ -23,35 +23,35 @@ //! Schema properties structure struct QgsHanaSchemaProperty { - QString name; - QString owner; + QString name; + QString owner; }; //! Layer Property structure struct QgsHanaLayerProperty { - QString schemaName; - QString tableName; - QString tableComment; - QString geometryColName; - Qgis::WkbType type; - QStringList pkCols; - int srid; - QString sql; - bool isView = false; - bool isUnique = false; - bool isValid = false; - QString errorMessage; - - QString defaultName() const - { - QString ret = tableName; - if ( !isUnique && !geometryColName.isEmpty() ) - ret += " [" + geometryColName + "]"; - return ret; - } - - bool isGeometryValid() const { return type != Qgis::WkbType::Unknown && srid >= 0; } + QString schemaName; + QString tableName; + QString tableComment; + QString geometryColName; + Qgis::WkbType type; + QStringList pkCols; + int srid; + QString sql; + bool isView = false; + bool isUnique = false; + bool isValid = false; + QString errorMessage; + + QString defaultName() const + { + QString ret = tableName; + if ( !isUnique && !geometryColName.isEmpty() ) + ret += " [" + geometryColName + "]"; + return ret; + } + + bool isGeometryValid() const { return type != Qgis::WkbType::Unknown && srid >= 0; } }; class QIcon; @@ -104,7 +104,6 @@ class QgsHanaTableModel : public QgsAbstractDbTableModel //! Number of tables in the model int mTableCount = 0; QStringList mColumns; - }; -#endif // QGSHANATABLEMODEL_H +#endif // QGSHANATABLEMODEL_H diff --git a/src/providers/hana/qgshanautils.cpp b/src/providers/hana/qgshanautils.cpp index f5d32bf24d7a..4f32ae2c7803 100644 --- a/src/providers/hana/qgshanautils.cpp +++ b/src/providers/hana/qgshanautils.cpp @@ -37,13 +37,12 @@ namespace return escaped; } -} +} // namespace QString QgsHanaUtils::connectionInfo( const QgsDataSourceUri &uri ) { QStringList connectionItems; - auto addItem = [&connectionItems]( const char *key, const QString & value, bool quoted = true ) - { + auto addItem = [&connectionItems]( const char *key, const QString &value, bool quoted = true ) { if ( quoted ) connectionItems << QStringLiteral( "%1='%2'" ).arg( key, value ); else @@ -360,8 +359,7 @@ QVariant QgsHanaUtils::toVariant( const Timestamp &value ) if ( value.isNull() ) return QgsVariantUtils::createNullVariant( QMetaType::Type::QDateTime ); else - return QVariant( QDateTime( QDate( value->year(), value->month(), value->day() ), - QTime( value->hour(), value->minute(), value->second(), value->milliseconds() ) ) ); + return QVariant( QDateTime( QDate( value->year(), value->month(), value->day() ), QTime( value->hour(), value->minute(), value->second(), value->milliseconds() ) ) ); } QVariant QgsHanaUtils::toVariant( const String &value ) @@ -460,7 +458,7 @@ constexpr int PLANAR_SRID_OFFSET = 1000000000; int QgsHanaUtils::toPlanarSRID( int srid ) { - return srid < PLANAR_SRID_OFFSET ? PLANAR_SRID_OFFSET + srid : srid; + return srid < PLANAR_SRID_OFFSET ? PLANAR_SRID_OFFSET + srid : srid; } bool QgsHanaUtils::convertField( QgsField &field ) diff --git a/src/providers/mdal/qgsmdalprovider.cpp b/src/providers/mdal/qgsmdalprovider.cpp index 3192d888a040..4de0f4dcadcd 100644 --- a/src/providers/mdal/qgsmdalprovider.cpp +++ b/src/providers/mdal/qgsmdalprovider.cpp @@ -118,7 +118,7 @@ void QgsMdalProvider::populateMesh( QgsMesh *mesh ) const } } -QVector QgsMdalProvider::vertices( ) const +QVector QgsMdalProvider::vertices() const { const int bufferSize = std::min( vertexCount(), 1000 ); QVector ret( vertexCount() ); @@ -145,7 +145,7 @@ QVector QgsMdalProvider::vertices( ) const return ret; } -QVector QgsMdalProvider::edges( ) const +QVector QgsMdalProvider::edges() const { const int edgesCount = edgeCount(); const int bufferSize = std::min( edgesCount, 1000 ); @@ -173,7 +173,7 @@ QVector QgsMdalProvider::edges( ) const return ret; } -QVector QgsMdalProvider::faces( ) const +QVector QgsMdalProvider::faces() const { const int faceOffsetsBufferLen = std::min( faceCount(), 1000 ); const int vertexIndicesBufferLen = faceOffsetsBufferLen * 4; // most usually we have quads @@ -187,11 +187,7 @@ QVector QgsMdalProvider::faces( ) const int faceIndex = 0; while ( faceIndex < facesCount ) { - int facesRead = MDAL_FI_next( it, - faceOffsetsBufferLen, - faceOffsetsBuffer.data(), - vertexIndicesBufferLen, - vertexIndicesBuffer.data() ); + int facesRead = MDAL_FI_next( it, faceOffsetsBufferLen, faceOffsetsBuffer.data(), vertexIndicesBufferLen, vertexIndicesBuffer.data() ); if ( facesRead == 0 ) break; @@ -200,8 +196,8 @@ QVector QgsMdalProvider::faces( ) const QgsMeshFace face; int startIndex = 0; if ( i > 0 ) - startIndex = faceOffsetsBuffer[ i - 1 ]; - int endIndex = faceOffsetsBuffer[ i ]; + startIndex = faceOffsetsBuffer[i - 1]; + int endIndex = faceOffsetsBuffer[i]; for ( int j = startIndex; j < endIndex; ++j ) { @@ -314,13 +310,13 @@ bool QgsMdalProvider::persistDatasetGroup( } MDAL_DatasetGroupH g = MDAL_M_addDatasetGroup( - mMeshH, - meta.name().toStdString().c_str(), - location, - meta.isScalar(), - driver, - outputFilePath.toStdString().c_str() - ); + mMeshH, + meta.name().toStdString().c_str(), + location, + meta.isScalar(), + driver, + outputFilePath.toStdString().c_str() + ); if ( !g ) return true; @@ -342,11 +338,7 @@ bool QgsMdalProvider::persistDatasetGroup( if ( !datasetActive.isEmpty() ) active = datasetActive.at( i ).active(); - MDAL_G_addDataset( g, - times.at( i ), - values.constData(), - active.isEmpty() ? nullptr : active.constData() - ); + MDAL_G_addDataset( g, times.at( i ), values.constData(), active.isEmpty() ? nullptr : active.constData() ); } MDAL_G_closeEditMode( g ); @@ -399,13 +391,13 @@ bool QgsMdalProvider::persistDatasetGroup( const QString &outputFilePath, const } MDAL_DatasetGroupH g = MDAL_M_addDatasetGroup( - mMeshH, - meta.name().toStdString().c_str(), - location, - meta.isScalar(), - driver, - outputFilePath.toStdString().c_str() - ); + mMeshH, + meta.name().toStdString().c_str(), + location, + meta.isScalar(), + driver, + outputFilePath.toStdString().c_str() + ); if ( !g ) return true; @@ -433,12 +425,7 @@ bool QgsMdalProvider::persistDatasetGroup( const QString &outputFilePath, const break; } - MDAL_G_addDataset( g, - dsm.time(), - values.values().constData(), - active.active().isEmpty() ? nullptr : active.active().constData() - ); - + MDAL_G_addDataset( g, dsm.time(), values.values().constData(), active.active().isEmpty() ? nullptr : active.active().constData() ); } if ( fail ) @@ -470,7 +457,6 @@ bool QgsMdalProvider::saveMeshFrame( const QgsMesh &mesh ) return mdalProviderMetaData.createMeshData( mesh, uriComponent.value( QStringLiteral( "path" ) ).toString(), mDriverName, crs(), mMeshMetadata ); return false; - } void QgsMdalProvider::close() @@ -527,7 +513,6 @@ void QgsMdalProvider::addGroupToTemporalCapabilities( int indexGroup ) tempCap->addDatasetTime( indexGroup, dsMeta.time() ); } } - } void QgsMdalProvider::reloadProviderData() @@ -613,15 +598,16 @@ void QgsMdalProvider::fileMeshFilters( QString &fileMeshFiltersString, QString & fileMeshDatasetFiltersString.prepend( QObject::tr( "All files" ) + " (*);;" ); // cleanup - if ( fileMeshFiltersString.endsWith( QLatin1String( ";;" ) ) ) fileMeshFiltersString.chop( 2 ); - if ( fileMeshDatasetFiltersString.endsWith( QLatin1String( ";;" ) ) ) fileMeshDatasetFiltersString.chop( 2 ); + if ( fileMeshFiltersString.endsWith( QLatin1String( ";;" ) ) ) + fileMeshFiltersString.chop( 2 ); + if ( fileMeshDatasetFiltersString.endsWith( QLatin1String( ";;" ) ) ) + fileMeshDatasetFiltersString.chop( 2 ); QgsDebugMsgLevel( "Mesh filter list built: " + fileMeshFiltersString, 2 ); QgsDebugMsgLevel( "Mesh dataset filter list built: " + fileMeshDatasetFiltersString, 2 ); } -void QgsMdalProvider::fileMeshExtensions( QStringList &fileMeshExtensions, - QStringList &fileMeshDatasetExtensions ) +void QgsMdalProvider::fileMeshExtensions( QStringList &fileMeshExtensions, QStringList &fileMeshDatasetExtensions ) { MDAL_DriverH mdalDriver; @@ -766,7 +752,7 @@ QgsMeshDatasetGroupMetadata QgsMdalProvider::datasetGroupMetadata( int groupInde QString referenceTimeString( MDAL_G_referenceTime( group ) ); if ( !referenceTimeString.isEmpty() ) - referenceTimeString.append( 'Z' );//For now provider doesn't support time zone and return always in local time, force UTC + referenceTimeString.append( 'Z' ); //For now provider doesn't support time zone and return always in local time, force UTC QDateTime referenceTime = QDateTime::fromString( referenceTimeString, Qt::ISODate ); bool isTemporal = MDAL_G_isTemporal( group ); @@ -812,7 +798,6 @@ QgsMeshDatasetMetadata QgsMdalProvider::datasetMetadata( QgsMeshDatasetIndex ind ); return meta; - } QgsMeshDatasetValue QgsMdalProvider::datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const @@ -835,11 +820,7 @@ QgsMeshDataBlock QgsMdalProvider::datasetValues( QgsMeshDatasetIndex index, int QgsMeshDataBlock ret( isScalar ? QgsMeshDataBlock::ScalarDouble : QgsMeshDataBlock::Vector2DDouble, count ); QVector buffer( isScalar ? count : 2 * count ); - int valRead = MDAL_D_data( dataset, - valueIndex, - count, - isScalar ? MDAL_DataType::SCALAR_DOUBLE : MDAL_DataType::VECTOR_2D_DOUBLE, - buffer.data() ); + int valRead = MDAL_D_data( dataset, valueIndex, count, isScalar ? MDAL_DataType::SCALAR_DOUBLE : MDAL_DataType::VECTOR_2D_DOUBLE, buffer.data() ); if ( valRead != count ) return QgsMeshDataBlock(); @@ -865,11 +846,7 @@ QgsMesh3DDataBlock QgsMdalProvider::dataset3dValues( QgsMeshDatasetIndex index, QgsMesh3DDataBlock ret( count, !isScalar ); { QVector faceToVolumeIndexBuffer( count ); - int valRead = MDAL_D_data( dataset, - faceIndex, - count, - MDAL_DataType::FACE_INDEX_TO_VOLUME_INDEX_INTEGER, - faceToVolumeIndexBuffer.data() ); + int valRead = MDAL_D_data( dataset, faceIndex, count, MDAL_DataType::FACE_INDEX_TO_VOLUME_INDEX_INTEGER, faceToVolumeIndexBuffer.data() ); if ( valRead != count ) return QgsMesh3DDataBlock(); ret.setFaceToVolumeIndex( faceToVolumeIndexBuffer ); @@ -877,11 +854,7 @@ QgsMesh3DDataBlock QgsMdalProvider::dataset3dValues( QgsMeshDatasetIndex index, { QVector verticalLevelCountBuffer( count ); - int valRead = MDAL_D_data( dataset, - faceIndex, - count, - MDAL_DataType::VERTICAL_LEVEL_COUNT_INTEGER, - verticalLevelCountBuffer.data() ); + int valRead = MDAL_D_data( dataset, faceIndex, count, MDAL_DataType::VERTICAL_LEVEL_COUNT_INTEGER, verticalLevelCountBuffer.data() ); if ( valRead != count ) return QgsMesh3DDataBlock(); @@ -899,23 +872,15 @@ QgsMesh3DDataBlock QgsMdalProvider::dataset3dValues( QgsMeshDatasetIndex index, { QVector verticalLevels( nVerticalLevelFaces ); - int valRead = MDAL_D_data( dataset, - startIndexVerticalFaces, - nVerticalLevelFaces, - MDAL_DataType::VERTICAL_LEVEL_DOUBLE, - verticalLevels.data() ); + int valRead = MDAL_D_data( dataset, startIndexVerticalFaces, nVerticalLevelFaces, MDAL_DataType::VERTICAL_LEVEL_DOUBLE, verticalLevels.data() ); if ( valRead != nVerticalLevelFaces ) return QgsMesh3DDataBlock(); ret.setVerticalLevels( verticalLevels ); } { - QVector values( isScalar ? nVolumes : 2 * nVolumes ); - int valRead = MDAL_D_data( dataset, - firstVolumeIndex, - nVolumes, - isScalar ? MDAL_DataType::SCALAR_VOLUMES_DOUBLE : MDAL_DataType::VECTOR_2D_VOLUMES_DOUBLE, - values.data() ); + QVector values( isScalar ? nVolumes : 2 * nVolumes ); + int valRead = MDAL_D_data( dataset, firstVolumeIndex, nVolumes, isScalar ? MDAL_DataType::SCALAR_VOLUMES_DOUBLE : MDAL_DataType::VECTOR_2D_VOLUMES_DOUBLE, values.data() ); if ( valRead != nVolumes ) return QgsMesh3DDataBlock(); ret.setValues( values ); @@ -985,11 +950,11 @@ static MDAL_MeshH createMDALMesh( const QgsMesh &mesh, const QString &driverName { int vertexCount = std::min( bufferSize, mesh.vertexCount() - vertexIndex ); QVector verticesCoordinates( vertexCount * 3 ); - for ( int i = 0; i < vertexCount ; ++i ) + for ( int i = 0; i < vertexCount; ++i ) { int globalIndex = vertexIndex + i; const QgsMeshVertex &vert = mesh.vertex( globalIndex ); - verticesCoordinates[i * 3 ] = vert.x(); + verticesCoordinates[i * 3] = vert.x(); verticesCoordinates[i * 3 + 1] = vert.y(); verticesCoordinates[i * 3 + 2] = vert.z(); } @@ -1056,9 +1021,7 @@ bool QgsMdalProviderMetadata::createMeshData( const QgsMesh &mesh, const QString if ( !uriComponents.contains( QStringLiteral( "driver" ) ) || !uriComponents.contains( QStringLiteral( "path" ) ) ) return false; - MDAL_MeshH mdalMesh = createMDALMesh( mesh, - uriComponents.value( QStringLiteral( "driver" ) ).toString() - , crs ); + MDAL_MeshH mdalMesh = createMDALMesh( mesh, uriComponents.value( QStringLiteral( "driver" ) ).toString(), crs ); if ( !mdalMesh ) return false; @@ -1104,14 +1067,11 @@ QString QgsMdalProviderMetadata::encodeUri( const QVariantMap &parts ) const { if ( !parts.value( QStringLiteral( "layerName" ) ).toString().isEmpty() && !parts.value( QStringLiteral( "driver" ) ).toString().isEmpty() ) { - return QStringLiteral( "%1:\"%2\":%3" ).arg( parts.value( QStringLiteral( "driver" ) ).toString(), - parts.value( QStringLiteral( "path" ) ).toString(), - parts.value( QStringLiteral( "layerName" ) ).toString() ); + return QStringLiteral( "%1:\"%2\":%3" ).arg( parts.value( QStringLiteral( "driver" ) ).toString(), parts.value( QStringLiteral( "path" ) ).toString(), parts.value( QStringLiteral( "layerName" ) ).toString() ); } else if ( !parts.value( QStringLiteral( "driver" ) ).toString().isEmpty() ) { - return QStringLiteral( "%1:\"%2\"" ).arg( parts.value( QStringLiteral( "driver" ) ).toString(), - parts.value( QStringLiteral( "path" ) ).toString() ); + return QStringLiteral( "%1:\"%2\"" ).arg( parts.value( QStringLiteral( "driver" ) ).toString(), parts.value( QStringLiteral( "path" ) ).toString() ); } else { @@ -1175,8 +1135,7 @@ QList QgsMdalProviderMetadata::querySublayers( const static QStringList sExtensions; static std::once_flag initialized; - std::call_once( initialized, [ = ]( ) - { + std::call_once( initialized, [=]() { QStringList datasetsExtensions; QgsMdalProvider::fileMeshExtensions( sExtensions, datasetsExtensions ); Q_UNUSED( datasetsExtensions ) @@ -1205,7 +1164,7 @@ QList QgsMdalProviderMetadata::querySublayers( const details.setName( QgsProviderUtils::suggestLayerNameFromFilePath( path ) ); // treat all mesh files as potentially being containers (is this correct?) details.setSkippedContainerScan( true ); - return {details}; + return { details }; } const QStringList meshNames = QString( MDAL_MeshNames( path.toUtf8() ) ).split( QStringLiteral( ";;" ) ); diff --git a/src/providers/mdal/qgsmdalprovider.h b/src/providers/mdal/qgsmdalprovider.h index c4260a578ddd..b1156bcccb6c 100644 --- a/src/providers/mdal/qgsmdalprovider.h +++ b/src/providers/mdal/qgsmdalprovider.h @@ -38,7 +38,6 @@ class QgsMdalProvider : public QgsMeshDataProvider Q_OBJECT public: - static const QString MDAL_PROVIDER_KEY; static const QString MDAL_PROVIDER_DESCRIPTION; @@ -81,19 +80,9 @@ class QgsMdalProvider : public QgsMeshDataProvider QgsMeshDriverMetadata driverMetadata() const override; - bool persistDatasetGroup( const QString &outputFilePath, - const QString &outputDriver, - const QgsMeshDatasetGroupMetadata &meta, - const QVector &datasetValues, - const QVector &datasetActive, - const QVector × - ) override; + bool persistDatasetGroup( const QString &outputFilePath, const QString &outputDriver, const QgsMeshDatasetGroupMetadata &meta, const QVector &datasetValues, const QVector &datasetActive, const QVector × ) override; - bool persistDatasetGroup( const QString &outputFilePath, - const QString &outputDriver, - QgsMeshDatasetSourceInterface *source, - int datasetGroupIndex - ) override; + bool persistDatasetGroup( const QString &outputFilePath, const QString &outputDriver, QgsMeshDatasetSourceInterface *source, int datasetGroupIndex ) override; bool saveMeshFrame( const QgsMesh &mesh ) override; @@ -122,9 +111,9 @@ class QgsMdalProvider : public QgsMeshDataProvider static void fileMeshExtensions( QStringList &fileMeshExtensions, QStringList &fileMeshDatasetExtensions ); private: - QVector vertices( ) const; - QVector edges( ) const; - QVector faces( ) const; + QVector vertices() const; + QVector edges() const; + QVector faces() const; void loadData(); void addGroupToTemporalCapabilities( int indexGroup ); MDAL_MeshH mMeshH = nullptr; @@ -140,7 +129,7 @@ class QgsMdalProvider : public QgsMeshDataProvider void reloadProviderData() override; }; -class QgsMdalProviderMetadata: public QgsProviderMetadata +class QgsMdalProviderMetadata : public QgsProviderMetadata { Q_OBJECT public: @@ -149,23 +138,16 @@ class QgsMdalProviderMetadata: public QgsProviderMetadata QString filters( Qgis::FileFilterType type ) override; QList meshDriversMetadata() override; QgsMdalProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; - bool createMeshData( const QgsMesh &mesh, - const QString &fileName, - const QString &driverName, - const QgsCoordinateReferenceSystem &crs, - const QMap &metadata = QMap() ) const override; - bool createMeshData( const QgsMesh &mesh, - const QString &uri, - const QgsCoordinateReferenceSystem &crs, - const QMap &metadata = QMap() ) const override; + bool createMeshData( const QgsMesh &mesh, const QString &fileName, const QString &driverName, const QgsCoordinateReferenceSystem &crs, const QMap &metadata = QMap() ) const override; + bool createMeshData( const QgsMesh &mesh, const QString &uri, const QgsCoordinateReferenceSystem &crs, const QMap &metadata = QMap() ) const override; QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; QString absoluteToRelativeUri( const QString &uri, const QgsReadWriteContext &context ) const override; QString relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const override; ProviderCapabilities providerCapabilities() const override; QgsProviderMetadata::ProviderMetadataCapabilities capabilities() const override; - QList< QgsProviderSublayerDetails > querySublayers( const QString &uri, Qgis::SublayerQueryFlags flags = Qgis::SublayerQueryFlags(), QgsFeedback *feedback = nullptr ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList querySublayers( const QString &uri, Qgis::SublayerQueryFlags flags = Qgis::SublayerQueryFlags(), QgsFeedback *feedback = nullptr ) const override; + QList supportedLayerTypes() const override; }; #endif //QGSMDALPROVIDER_H diff --git a/src/providers/mdal/qgsmdalprovidergui.cpp b/src/providers/mdal/qgsmdalprovidergui.cpp index c94a55271146..363500234ecd 100644 --- a/src/providers/mdal/qgsmdalprovidergui.cpp +++ b/src/providers/mdal/qgsmdalprovidergui.cpp @@ -25,7 +25,6 @@ class QgsMdalMeshSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "mdal" ); } QString text() const override { return QObject::tr( "Mesh" ); } int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 22; } @@ -37,7 +36,7 @@ class QgsMdalMeshSourceSelectProvider : public QgsSourceSelectProvider }; -class QgsMdalProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsMdalProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsMdalProviderGuiMetadata() diff --git a/src/providers/mdal/qgsmdalsourceselect.cpp b/src/providers/mdal/qgsmdalsourceselect.cpp index e6f66f5cd636..cb790d7bb633 100644 --- a/src/providers/mdal/qgsmdalsourceselect.cpp +++ b/src/providers/mdal/qgsmdalsourceselect.cpp @@ -22,8 +22,8 @@ #include "qgsproviderregistry.h" #include "qgshelp.h" -QgsMdalSourceSelect::QgsMdalSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ): - QgsAbstractDataSourceWidget( parent, fl, widgetMode ) +QgsMdalSourceSelect::QgsMdalSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ) + : QgsAbstractDataSourceWidget( parent, fl, widgetMode ) { setupUi( this ); setupButtons( buttonBox ); @@ -31,10 +31,9 @@ QgsMdalSourceSelect::QgsMdalSourceSelect( QWidget *parent, Qt::WindowFlags fl, Q mFileWidget->setDialogTitle( tr( "Open MDAL Supported Mesh Dataset(s)" ) ); mFileWidget->setFilter( QgsProviderRegistry::instance()->fileMeshFilters() ); mFileWidget->setStorageMode( QgsFileWidget::GetMultipleFiles ); - connect( mFileWidget, &QgsFileWidget::fileChanged, this, [ = ]( const QString & path ) - { + connect( mFileWidget, &QgsFileWidget::fileChanged, this, [=]( const QString &path ) { mMeshPath = path; - emit enableButtons( ! mMeshPath.isEmpty() ); + emit enableButtons( !mMeshPath.isEmpty() ); } ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsMdalSourceSelect::showHelp ); } @@ -43,9 +42,7 @@ void QgsMdalSourceSelect::addButtonClicked() { if ( mMeshPath.isEmpty() ) { - QMessageBox::information( this, - tr( "Add mesh layer" ), - tr( "No layers selected." ) ); + QMessageBox::information( this, tr( "Add mesh layer" ), tr( "No layers selected." ) ); return; } diff --git a/src/providers/mdal/qgsmdalsourceselect.h b/src/providers/mdal/qgsmdalsourceselect.h index 5280469905b8..0aa0e99f8ade 100644 --- a/src/providers/mdal/qgsmdalsourceselect.h +++ b/src/providers/mdal/qgsmdalsourceselect.h @@ -43,7 +43,6 @@ class QgsMdalSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsM private: QString mMeshPath; - }; #endif // QGMDALSOURCESELECT_H diff --git a/src/providers/mssql/qgsmssqlconnection.cpp b/src/providers/mssql/qgsmssqlconnection.cpp index 4d30c58c8d38..d97a5b87dfa6 100644 --- a/src/providers/mssql/qgsmssqlconnection.cpp +++ b/src/providers/mssql/qgsmssqlconnection.cpp @@ -148,8 +148,7 @@ bool QgsMssqlConnection::dropTable( const QString &uri, QString *errorMessage ) q.setForwardOnly( true ); const QString sql = QString( "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[%1].[%2]') AND type in (N'U')) DROP TABLE [%1].[%2]\n" "DELETE FROM geometry_columns WHERE f_table_schema = '%1' AND f_table_name = '%2'" ) - .arg( schema, - table ); + .arg( schema, table ); if ( !q.exec( sql ) ) { if ( errorMessage ) @@ -258,8 +257,7 @@ QStringList QgsMssqlConnection::schemas( std::shared_ptr db, Q bool QgsMssqlConnection::isSystemSchema( const QString &schema ) { - static const QSet< QString > sSystemSchemas - { + static const QSet sSystemSchemas { QStringLiteral( "db_owner" ), QStringLiteral( "db_securityadmin" ), QStringLiteral( "db_accessadmin" ), @@ -312,7 +310,7 @@ QgsDataSourceUri QgsMssqlConnection::connUri( const QString &connName ) { const bool saveUsername { settings.value( QStringLiteral( "saveUsername" ) ).toBool() }; uri.setParam( QStringLiteral( "saveUsername" ), saveUsername ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); - if ( ! saveUsername ) + if ( !saveUsername ) { uri.setUsername( QString() ); } @@ -321,7 +319,7 @@ QgsDataSourceUri QgsMssqlConnection::connUri( const QString &connName ) { const bool savePassword { settings.value( QStringLiteral( "savePassword" ) ).toBool() }; uri.setParam( QStringLiteral( "savePassword" ), savePassword ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); - if ( ! savePassword ) + if ( !savePassword ) { uri.setPassword( QString() ); } @@ -367,8 +365,7 @@ QList QgsMssqlConnection::nativeTypes() << QgsVectorDataProvider::NativeType( QObject::tr( "Text, fixed length unicode (nchar)" ), QStringLiteral( "nchar" ), QMetaType::Type::QString, 1, 255 ) << QgsVectorDataProvider::NativeType( QObject::tr( "Text, limited variable length unicode (nvarchar)" ), QStringLiteral( "nvarchar" ), QMetaType::Type::QString, 1, 255 ) << QgsVectorDataProvider::NativeType( QObject::tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QMetaType::Type::QString ) - << QgsVectorDataProvider::NativeType( QObject::tr( "Text, unlimited length unicode (ntext)" ), QStringLiteral( "text" ), QMetaType::Type::QString ) - ; + << QgsVectorDataProvider::NativeType( QObject::tr( "Text, unlimited length unicode (ntext)" ), QStringLiteral( "text" ), QMetaType::Type::QString ); } QStringList QgsMssqlConnection::excludedSchemasList( const QString &connName ) diff --git a/src/providers/mssql/qgsmssqlconnection.h b/src/providers/mssql/qgsmssqlconnection.h index f3bf1b28a025..baaa577e0f1d 100644 --- a/src/providers/mssql/qgsmssqlconnection.h +++ b/src/providers/mssql/qgsmssqlconnection.h @@ -35,9 +35,7 @@ class QgsMssqlDatabase; */ class QgsMssqlConnection { - public: - /** * Returns true if the connection with matching \a name should * only look in the geometry_columns metadata table when scanning for tables. @@ -261,8 +259,6 @@ class QgsMssqlConnection static void duplicateConnection( const QString &src, const QString &dst ); private: - - }; #endif // QGSMSSQLCONNECTION_H diff --git a/src/providers/mssql/qgsmssqldatabase.cpp b/src/providers/mssql/qgsmssqldatabase.cpp index 3fca86c5ead8..1fa97ebf0f78 100644 --- a/src/providers/mssql/qgsmssqldatabase.cpp +++ b/src/providers/mssql/qgsmssqldatabase.cpp @@ -26,7 +26,7 @@ QRecursiveMutex QgsMssqlDatabase::sMutex; -QMap > QgsMssqlDatabase::sConnections; +QMap> QgsMssqlDatabase::sConnections; QString QgsMssqlDatabase::connectionName( const QString &service, const QString &host, const QString &database, bool transaction ) @@ -144,11 +144,9 @@ QSqlDatabase QgsMssqlDatabase::getDatabase( const QString &service, const QStrin // and a subsequent call to QSqlDatabase::database with the same thread address (yep it happens, actually a lot) // triggers a condition in QSqlDatabase which detects the nullptr private thread data and returns an invalid database instead. // QSqlDatabase::removeDatabase is thread safe, so this is ok to do. - QObject::connect( QThread::currentThread(), &QThread::finished, QThread::currentThread(), [threadSafeConnectionName] - { + QObject::connect( QThread::currentThread(), &QThread::finished, QThread::currentThread(), [threadSafeConnectionName] { const QMutexLocker locker( &sMutex ); - QSqlDatabase::removeDatabase( threadSafeConnectionName ); - }, Qt::DirectConnection ); + QSqlDatabase::removeDatabase( threadSafeConnectionName ); }, Qt::DirectConnection ); } } else @@ -168,7 +166,7 @@ QSqlDatabase QgsMssqlDatabase::getDatabase( const QString &service, const QStrin { #ifdef Q_OS_WIN connectionString = "driver={SQL Server}"; -#elif defined (Q_OS_MAC) +#elif defined( Q_OS_MAC ) QString freeTDSDriver( QCoreApplication::applicationDirPath().append( "/lib/libtdsodbc.so" ) ); if ( QFile::exists( freeTDSDriver ) ) { diff --git a/src/providers/mssql/qgsmssqldatabase.h b/src/providers/mssql/qgsmssqldatabase.h index 948af249cee5..4940ea5ad023 100644 --- a/src/providers/mssql/qgsmssqldatabase.h +++ b/src/providers/mssql/qgsmssqldatabase.h @@ -43,7 +43,6 @@ class QgsDataSourceUri; class QgsMssqlDatabase { public: - /** * Tries to connect to a MSSQL database and returns shared pointer to the connection. On success, * the returned database object (QSqlDatabase) is already open and it is not necessary to call open(). @@ -89,7 +88,7 @@ class QgsMssqlDatabase */ static QSqlDatabase getDatabase( const QString &service, const QString &host, const QString &database, const QString &username, const QString &password, bool transaction = false ); - static QMap > sConnections; + static QMap> sConnections; static QRecursiveMutex sMutex; }; @@ -118,7 +117,6 @@ class QgsMssqlQuery : public QSqlQuery private: std::shared_ptr mDb; - }; diff --git a/src/providers/mssql/qgsmssqldataitemguiprovider.cpp b/src/providers/mssql/qgsmssqldataitemguiprovider.cpp index cea1e3a53372..f28200ab8396 100644 --- a/src/providers/mssql/qgsmssqldataitemguiprovider.cpp +++ b/src/providers/mssql/qgsmssqldataitemguiprovider.cpp @@ -29,7 +29,7 @@ void QgsMssqlDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selection, QgsDataItemGuiContext context ) { - if ( QgsMssqlRootItem *rootItem = qobject_cast< QgsMssqlRootItem * >( item ) ) + if ( QgsMssqlRootItem *rootItem = qobject_cast( item ) ) { QAction *actionNew = new QAction( tr( "New Connection…" ), menu ); connect( actionNew, &QAction::triggered, this, [rootItem] { newConnection( rootItem ); } ); @@ -43,11 +43,10 @@ void QgsMssqlDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu connect( actionLoadServers, &QAction::triggered, this, [rootItem] { loadConnections( rootItem ); } ); menu->addAction( actionLoadServers ); } - else if ( QgsMssqlConnectionItem *connItem = qobject_cast< QgsMssqlConnectionItem * >( item ) ) + else if ( QgsMssqlConnectionItem *connItem = qobject_cast( item ) ) { QAction *actionRefresh = new QAction( tr( "Refresh" ), menu ); - connect( actionRefresh, &QAction::triggered, this, [connItem] - { + connect( actionRefresh, &QAction::triggered, this, [connItem] { connItem->refresh(); if ( connItem->parent() ) connItem->parent()->refreshConnections(); @@ -64,14 +63,10 @@ void QgsMssqlDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu connect( actionDuplicate, &QAction::triggered, this, [connItem] { duplicateConnection( connItem ); } ); menu->addAction( actionDuplicate ); - const QList< QgsMssqlConnectionItem * > mssqlConnectionItems = QgsDataItem::filteredItems( selection ); + const QList mssqlConnectionItems = QgsDataItem::filteredItems( selection ); QAction *actionDelete = new QAction( mssqlConnectionItems.size() > 1 ? tr( "Remove Connections…" ) : tr( "Remove Connection…" ), menu ); - connect( actionDelete, &QAction::triggered, this, [mssqlConnectionItems, context] - { - QgsDataItemGuiProviderUtils::deleteConnections( mssqlConnectionItems, []( const QString & connectionName ) - { - QgsMssqlSourceSelect::deleteConnection( connectionName ); - }, context ); + connect( actionDelete, &QAction::triggered, this, [mssqlConnectionItems, context] { + QgsDataItemGuiProviderUtils::deleteConnections( mssqlConnectionItems, []( const QString &connectionName ) { QgsMssqlSourceSelect::deleteConnection( connectionName ); }, context ); } ); menu->addAction( actionDelete ); @@ -87,17 +82,16 @@ void QgsMssqlDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu connect( actionCreateSchema, &QAction::triggered, this, [connItem] { createSchema( connItem ); } ); menu->addAction( actionCreateSchema ); } - else if ( QgsMssqlSchemaItem *schemaItem = qobject_cast< QgsMssqlSchemaItem * >( item ) ) + else if ( QgsMssqlSchemaItem *schemaItem = qobject_cast( item ) ) { QAction *actionRefresh = new QAction( tr( "Refresh" ), menu ); - connect( actionRefresh, &QAction::triggered, this, [schemaItem] - { + connect( actionRefresh, &QAction::triggered, this, [schemaItem] { if ( schemaItem->parent() ) schemaItem->parent()->refresh(); } ); menu->addAction( actionRefresh ); } - else if ( QgsMssqlLayerItem *layerItem = qobject_cast< QgsMssqlLayerItem * >( item ) ) + else if ( QgsMssqlLayerItem *layerItem = qobject_cast( item ) ) { QMenu *maintainMenu = new QMenu( tr( "Table Operations" ), menu ); @@ -112,15 +106,13 @@ void QgsMssqlDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu bool QgsMssqlDataItemGuiProvider::deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context ) { - if ( QgsMssqlLayerItem *layerItem = qobject_cast< QgsMssqlLayerItem * >( item ) ) + if ( QgsMssqlLayerItem *layerItem = qobject_cast( item ) ) { QgsMssqlConnectionItem *connItem = qobject_cast( layerItem->parent() ? layerItem->parent()->parent() : nullptr ); const QgsMssqlLayerProperty &layerInfo = layerItem->layerInfo(); const QString typeName = layerInfo.isView ? tr( "View" ) : tr( "Table" ); - if ( QMessageBox::question( nullptr, QObject::tr( "Delete %1" ).arg( typeName ), - QObject::tr( "Are you sure you want to delete [%1].[%2]?" ).arg( layerInfo.schemaName, layerInfo.tableName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete %1" ).arg( typeName ), QObject::tr( "Are you sure you want to delete [%1].[%2]?" ).arg( layerInfo.schemaName, layerInfo.tableName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return true; QString errCause; @@ -147,9 +139,9 @@ bool QgsMssqlDataItemGuiProvider::deleteLayer( QgsLayerItem *item, QgsDataItemGu bool QgsMssqlDataItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiContext ) { - if ( qobject_cast< QgsMssqlConnectionItem * >( item ) ) + if ( qobject_cast( item ) ) return true; - if ( qobject_cast< QgsMssqlSchemaItem * >( item ) ) + if ( qobject_cast( item ) ) return true; return false; @@ -157,11 +149,11 @@ bool QgsMssqlDataItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiC bool QgsMssqlDataItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiContext, const QMimeData *data, Qt::DropAction ) { - if ( QgsMssqlConnectionItem *connItem = qobject_cast< QgsMssqlConnectionItem * >( item ) ) + if ( QgsMssqlConnectionItem *connItem = qobject_cast( item ) ) { return connItem->handleDrop( data, QString() ); } - else if ( QgsMssqlSchemaItem *schemaItem = qobject_cast< QgsMssqlSchemaItem * >( item ) ) + else if ( QgsMssqlSchemaItem *schemaItem = qobject_cast( item ) ) { QgsMssqlConnectionItem *connItem = qobject_cast( schemaItem->parent() ); if ( !connItem ) @@ -219,8 +211,7 @@ void QgsMssqlDataItemGuiProvider::createSchema( QgsMssqlConnectionItem *connItem QString error; if ( !QgsMssqlConnection::createSchema( uri, schemaName, &error ) ) { - QMessageBox::warning( nullptr, tr( "Create Schema" ), tr( "Unable to create schema %1\n%2" ).arg( schemaName, - error ) ); + QMessageBox::warning( nullptr, tr( "Create Schema" ), tr( "Unable to create schema %1\n%2" ).arg( schemaName, error ) ); return; } @@ -234,9 +225,7 @@ void QgsMssqlDataItemGuiProvider::createSchema( QgsMssqlConnectionItem *connItem void QgsMssqlDataItemGuiProvider::truncateTable( QgsMssqlLayerItem *layerItem ) { const QgsMssqlLayerProperty &layerInfo = layerItem->layerInfo(); - if ( QMessageBox::question( nullptr, QObject::tr( "Truncate Table" ), - QObject::tr( "Are you sure you want to truncate [%1].[%2]?\n\nThis will delete all data within the table." ).arg( layerInfo.schemaName, layerInfo.tableName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Truncate Table" ), QObject::tr( "Are you sure you want to truncate [%1].[%2]?\n\nThis will delete all data within the table." ).arg( layerInfo.schemaName, layerInfo.tableName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; QString errCause; @@ -259,8 +248,7 @@ void QgsMssqlDataItemGuiProvider::saveConnections() void QgsMssqlDataItemGuiProvider::loadConnections( QgsDataItem *item ) { - const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; diff --git a/src/providers/mssql/qgsmssqldataitemguiprovider.h b/src/providers/mssql/qgsmssqldataitemguiprovider.h index fb26c1eebba1..403a3ed5f0b3 100644 --- a/src/providers/mssql/qgsmssqldataitemguiprovider.h +++ b/src/providers/mssql/qgsmssqldataitemguiprovider.h @@ -25,11 +25,9 @@ class QgsMssqlDataItemGuiProvider : public QObject, public QgsDataItemGuiProvide { Q_OBJECT public: - QString name() override { return QStringLiteral( "MSSQL" ); } - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context ) override; diff --git a/src/providers/mssql/qgsmssqldataitems.cpp b/src/providers/mssql/qgsmssqldataitems.cpp index 873d018edf68..027ca1c00e7e 100644 --- a/src/providers/mssql/qgsmssqldataitems.cpp +++ b/src/providers/mssql/qgsmssqldataitems.cpp @@ -154,9 +154,9 @@ QVector QgsMssqlConnectionItem::createChildren() // issue the sql query QSqlQuery q = QSqlQuery( db->db() ); q.setForwardOnly( true ); - ( void )q.exec( query ); + ( void ) q.exec( query ); - QSet< QString > addedSchemas; + QSet addedSchemas; if ( q.isActive() ) { @@ -170,7 +170,7 @@ QVector QgsMssqlConnectionItem::createChildren() layer.srid = q.value( 3 ).toString(); layer.type = q.value( 4 ).toString(); layer.isView = q.value( 5 ).toBool(); - const int dimensions { q.value( 6 ).toInt( ) }; + const int dimensions { q.value( 6 ).toInt() }; if ( dimensions >= 3 ) { layer.type = layer.type.append( 'Z' ); @@ -192,7 +192,7 @@ QVector QgsMssqlConnectionItem::createChildren() const auto constChildren = child->children(); for ( QgsDataItem *child2 : constChildren ) { - QgsMssqlLayerItem *layerItem = qobject_cast< QgsMssqlLayerItem *>( child2 ); + QgsMssqlLayerItem *layerItem = qobject_cast( child2 ); if ( child2->name() == layer.tableName && layerItem && layerItem->disableInvalidGeometryHandling() == disableInvalidGeometryHandling ) { newLayers.append( child2 ); @@ -215,7 +215,7 @@ QVector QgsMssqlConnectionItem::createChildren() { if ( child->name() == layer.schemaName ) { - schemaItem = static_cast< QgsMssqlSchemaItem * >( child ); + schemaItem = static_cast( child ); break; } } @@ -236,10 +236,8 @@ QVector QgsMssqlConnectionItem::createChildren() { mColumnTypeThread = new QgsMssqlGeomColumnTypeThread( mService, mHost, mDatabase, mUsername, mPassword, true /* use estimated metadata */ ); - connect( mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::setLayerType, - this, &QgsMssqlConnectionItem::setLayerType ); - connect( this, &QgsMssqlConnectionItem::addGeometryColumn, - mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::addGeometryColumn ); + connect( mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::setLayerType, this, &QgsMssqlConnectionItem::setLayerType ); + connect( this, &QgsMssqlConnectionItem::addGeometryColumn, mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::addGeometryColumn ); } emit addGeometryColumn( layer ); @@ -271,7 +269,7 @@ QVector QgsMssqlConnectionItem::createChildren() for ( const QString &schema : allSchemas ) { if ( mSchemasFilteringEnabled && excludedSchema.contains( schema ) ) - continue; // user does not want it to be shown + continue; // user does not want it to be shown if ( addedSchemas.contains( schema ) ) continue; @@ -335,7 +333,7 @@ void QgsMssqlConnectionItem::setLayerType( QgsMssqlLayerProperty layerProperty ) { if ( child->name() == layerProperty.schemaName ) { - schemaItem = static_cast< QgsMssqlSchemaItem * >( child ); + schemaItem = static_cast( child ); break; } } @@ -431,11 +429,10 @@ bool QgsMssqlConnectionItem::handleDrop( const QMimeData *data, const QString &t if ( srcLayer->geometryType() != Qgis::GeometryType::Null ) uri += QLatin1String( " (geom)" ); - std::unique_ptr< QgsVectorLayerExporterTask > exportTask( QgsVectorLayerExporterTask::withLayerOwnership( srcLayer, uri, QStringLiteral( "mssql" ), srcLayer->crs() ) ); + std::unique_ptr exportTask( QgsVectorLayerExporterTask::withLayerOwnership( srcLayer, uri, QStringLiteral( "mssql" ), srcLayer->crs() ) ); // when export is successful: - connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [ = ]() - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [=]() { // this is gross - TODO - find a way to get access to messageBar from data items QMessageBox::information( nullptr, tr( "Import to MS SQL Server database" ), tr( "Import was successful." ) ); if ( state() == Qgis::BrowserItemState::Populated ) @@ -445,8 +442,7 @@ bool QgsMssqlConnectionItem::handleDrop( const QMimeData *data, const QString &t } ); // when an error occurs: - connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, [ = ]( Qgis::VectorExportResult error, const QString & errorMessage ) - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, [=]( Qgis::VectorExportResult error, const QString &errorMessage ) { if ( error != Qgis::VectorExportResult::UserCanceled ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); @@ -557,7 +553,7 @@ void QgsMssqlSchemaItem::addLayers( QgsDataItem *newLayers ) { continue; } - QgsMssqlLayerItem *layer = static_cast< QgsMssqlLayerItem * >( child )->createClone(); + QgsMssqlLayerItem *layer = static_cast( child )->createClone(); addChildItem( layer, true ); } } diff --git a/src/providers/mssql/qgsmssqldataitems.h b/src/providers/mssql/qgsmssqldataitems.h index ee7fd250fb53..ceb2827ee4b4 100644 --- a/src/providers/mssql/qgsmssqldataitems.h +++ b/src/providers/mssql/qgsmssqldataitems.h @@ -16,7 +16,6 @@ ***************************************************************************/ - #ifndef QGSMSSQLDATAITEMS_H #define QGSMSSQLDATAITEMS_H @@ -139,11 +138,9 @@ class QgsMssqlLayerItem : public QgsLayerItem private: QgsMssqlLayerProperty mLayerProperty; bool mDisableInvalidGeometryHandling = false; - }; - //! Provider for GDAL root data item class QgsMssqlDataItemProvider : public QgsDataItemProvider { diff --git a/src/providers/mssql/qgsmssqlexpressioncompiler.cpp b/src/providers/mssql/qgsmssqlexpressioncompiler.cpp index beca08868ed5..70da1df9131f 100644 --- a/src/providers/mssql/qgsmssqlexpressioncompiler.cpp +++ b/src/providers/mssql/qgsmssqlexpressioncompiler.cpp @@ -17,10 +17,7 @@ #include "qgsexpressionnodeimpl.h" QgsMssqlExpressionCompiler::QgsMssqlExpressionCompiler( QgsMssqlFeatureSource *source, bool ignoreStaticNodes ) - : QgsSqlExpressionCompiler( source->mFields, - QgsSqlExpressionCompiler::LikeIsCaseInsensitive | - QgsSqlExpressionCompiler::CaseInsensitiveStringMatch | - QgsSqlExpressionCompiler::IntegerDivisionResultsInInteger, ignoreStaticNodes ) + : QgsSqlExpressionCompiler( source->mFields, QgsSqlExpressionCompiler::LikeIsCaseInsensitive | QgsSqlExpressionCompiler::CaseInsensitiveStringMatch | QgsSqlExpressionCompiler::IntegerDivisionResultsInInteger, ignoreStaticNodes ) { } @@ -140,8 +137,7 @@ QString QgsMssqlExpressionCompiler::castToInt( const QString &value ) const return QStringLiteral( "CAST((%1) AS integer)" ).arg( value ); } -static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP -{ +static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP { { "sqrt", "sqrt" }, { "abs", "abs" }, { "cos", "cos" }, @@ -183,24 +179,15 @@ QStringList QgsMssqlExpressionCompiler::sqlArgumentsFromFunctionName( const QStr QStringList args( fnArgs ); if ( fnName == QLatin1String( "make_datetime" ) ) { - args = QStringList( QStringLiteral( "'%1-%2-%3T%4:%5:%6Z'" ).arg( args[0].rightJustified( 4, '0' ) ) - .arg( args[1].rightJustified( 2, '0' ) ) - .arg( args[2].rightJustified( 2, '0' ) ) - .arg( args[3].rightJustified( 2, '0' ) ) - .arg( args[4].rightJustified( 2, '0' ) ) - .arg( args[5].rightJustified( 2, '0' ) ) ); + args = QStringList( QStringLiteral( "'%1-%2-%3T%4:%5:%6Z'" ).arg( args[0].rightJustified( 4, '0' ) ).arg( args[1].rightJustified( 2, '0' ) ).arg( args[2].rightJustified( 2, '0' ) ).arg( args[3].rightJustified( 2, '0' ) ).arg( args[4].rightJustified( 2, '0' ) ).arg( args[5].rightJustified( 2, '0' ) ) ); } else if ( fnName == QLatin1String( "make_date" ) ) { - args = QStringList( QStringLiteral( "'%1-%2-%3'" ).arg( args[0].rightJustified( 4, '0' ) ) - .arg( args[1].rightJustified( 2, '0' ) ) - .arg( args[2].rightJustified( 2, '0' ) ) ); + args = QStringList( QStringLiteral( "'%1-%2-%3'" ).arg( args[0].rightJustified( 4, '0' ) ).arg( args[1].rightJustified( 2, '0' ) ).arg( args[2].rightJustified( 2, '0' ) ) ); } else if ( fnName == QLatin1String( "make_time" ) ) { - args = QStringList( QStringLiteral( "'%1:%2:%3'" ).arg( args[0].rightJustified( 2, '0' ) ) - .arg( args[1].rightJustified( 2, '0' ) ) - .arg( args[2].rightJustified( 2, '0' ) ) ); + args = QStringList( QStringLiteral( "'%1:%2:%3'" ).arg( args[0].rightJustified( 2, '0' ) ).arg( args[1].rightJustified( 2, '0' ) ).arg( args[2].rightJustified( 2, '0' ) ) ); } return args; } diff --git a/src/providers/mssql/qgsmssqlexpressioncompiler.h b/src/providers/mssql/qgsmssqlexpressioncompiler.h index d06afb481b85..a04ff2832a42 100644 --- a/src/providers/mssql/qgsmssqlexpressioncompiler.h +++ b/src/providers/mssql/qgsmssqlexpressioncompiler.h @@ -23,7 +23,6 @@ class QgsMssqlExpressionCompiler : public QgsSqlExpressionCompiler { public: - explicit QgsMssqlExpressionCompiler( QgsMssqlFeatureSource *source, bool ignoreStaticNodes = false ); protected: diff --git a/src/providers/mssql/qgsmssqlfeatureiterator.cpp b/src/providers/mssql/qgsmssqlfeatureiterator.cpp index 71d3fe472147..4b5cb9890264 100644 --- a/src/providers/mssql/qgsmssqlfeatureiterator.cpp +++ b/src/providers/mssql/qgsmssqlfeatureiterator.cpp @@ -246,8 +246,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest &request ) // use the faster filter method only when we don't need an exact intersect test -- filter doesn't give exact // results when the layer has a spatial index QString test = mRequest.flags() & Qgis::FeatureRequestFlag::ExactIntersect ? QStringLiteral( "STIntersects" ) : QStringLiteral( "Filter" ); - mStatement += QStringLiteral( "[%1].%2([%3]::STGeomFromText('POLYGON((%4))',%5)) = 1" ).arg( - mSource->mGeometryColName, test, mSource->mGeometryColType, r, QString::number( mSource->mSRId ) ); + mStatement += QStringLiteral( "[%1].%2([%3]::STGeomFromText('POLYGON((%4))',%5)) = 1" ).arg( mSource->mGeometryColName, test, mSource->mGeometryColType, r, QString::number( mSource->mSRId ) ); filterAdded = true; } @@ -555,7 +554,7 @@ bool QgsMssqlFeatureIterator::fetchFeature( QgsFeature &feature ) QByteArray ar = mQuery->record().value( mSource->mGeometryColName ).toByteArray(); if ( !ar.isEmpty() ) { - std::unique_ptr geom = mParser.parseSqlGeometry( reinterpret_cast< unsigned char * >( ar.data() ), ar.size() ); + std::unique_ptr geom = mParser.parseSqlGeometry( reinterpret_cast( ar.data() ), ar.size() ); if ( geom ) feature.setGeometry( QgsGeometry( std::move( geom ) ) ); } @@ -712,7 +711,7 @@ QgsMssqlFeatureSource::QgsMssqlFeatureSource( const QgsMssqlProvider *p ) , mDisableInvalidGeometryHandling( p->mDisableInvalidGeometryHandling ) , mCrs( p->crs() ) , mTransactionConn( p->transaction() ? static_cast( p->transaction() )->conn() : std::shared_ptr() ) - , mConnInfo( p->uri().uri( ) ) + , mConnInfo( p->uri().uri() ) {} QgsFeatureIterator QgsMssqlFeatureSource::getFeatures( const QgsFeatureRequest &request ) diff --git a/src/providers/mssql/qgsmssqlfeatureiterator.h b/src/providers/mssql/qgsmssqlfeatureiterator.h index 92d54152af44..78621cd85058 100644 --- a/src/providers/mssql/qgsmssqlfeatureiterator.h +++ b/src/providers/mssql/qgsmssqlfeatureiterator.h @@ -31,7 +31,7 @@ class QgsMssqlProvider; class QgsMssqlQuery; -class QgsMssqlFeatureSource final: public QgsAbstractFeatureSource +class QgsMssqlFeatureSource final : public QgsAbstractFeatureSource { public: explicit QgsMssqlFeatureSource( const QgsMssqlProvider *p ); @@ -85,7 +85,7 @@ class QgsMssqlFeatureSource final: public QgsAbstractFeatureSource friend class QgsMssqlExpressionCompiler; }; -class QgsMssqlFeatureIterator final: public QgsAbstractFeatureIteratorFromSource +class QgsMssqlFeatureIterator final : public QgsAbstractFeatureIteratorFromSource { public: QgsMssqlFeatureIterator( QgsMssqlFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ); @@ -104,17 +104,16 @@ class QgsMssqlFeatureIterator final: public QgsAbstractFeatureIteratorFromSource QString whereClauseFid( QgsFeatureId featureId ); private: - bool prepareOrderBy( const QList &orderBys ) override; double validLat( double latitude ) const; double validLon( double longitude ) const; // The current database - std::shared_ptr< QgsMssqlDatabase > mDatabase; + std::shared_ptr mDatabase; // The current sql query - std::unique_ptr< QgsMssqlQuery > mQuery; + std::unique_ptr mQuery; // The current sql statement QString mStatement; @@ -135,7 +134,7 @@ class QgsMssqlFeatureIterator final: public QgsAbstractFeatureIteratorFromSource QgsCoordinateTransform mTransform; QgsRectangle mFilterRect; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; }; #endif // QGSMSSQLFEATUREITERATOR_H diff --git a/src/providers/mssql/qgsmssqlgeomcolumntypethread.cpp b/src/providers/mssql/qgsmssqlgeomcolumntypethread.cpp index dc1dde94fe48..fd5e927adbba 100644 --- a/src/providers/mssql/qgsmssqlgeomcolumntypethread.cpp +++ b/src/providers/mssql/qgsmssqlgeomcolumntypethread.cpp @@ -49,7 +49,7 @@ void QgsMssqlGeomColumnTypeThread::run() mStopped = false; for ( QList::iterator it = layerProperties.begin(), - end = layerProperties.end(); + end = layerProperties.end(); it != end; ++it ) { QgsMssqlLayerProperty &layerProperty = *it; @@ -57,8 +57,7 @@ void QgsMssqlGeomColumnTypeThread::run() if ( !mStopped ) { const QString table = QStringLiteral( "%1[%2]" ) - .arg( layerProperty.schemaName.isEmpty() ? QString() : QStringLiteral( "[%1]." ).arg( layerProperty.schemaName ), - layerProperty.tableName ); + .arg( layerProperty.schemaName.isEmpty() ? QString() : QStringLiteral( "[%1]." ).arg( layerProperty.schemaName ), layerProperty.tableName ); const QString query = QStringLiteral( "SELECT %3" " UPPER([%1].STGeometryType())," @@ -68,10 +67,7 @@ void QgsMssqlGeomColumnTypeThread::run() " FROM %2" " WHERE [%1] IS NOT NULL %4" " GROUP BY [%1].STGeometryType(), [%1].STSrid, [%1].HasZ, [%1].HasM" ) - .arg( layerProperty.geometryColName, - table, - mUseEstimatedMetadata ? "TOP 1" : "", - layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " AND %1" ).arg( layerProperty.sql ) ); + .arg( layerProperty.geometryColName, table, mUseEstimatedMetadata ? "TOP 1" : "", layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " AND %1" ).arg( layerProperty.sql ) ); // issue the sql query std::shared_ptr db = QgsMssqlDatabase::connectDb( mService, mHost, mDatabase, mUsername, mPassword ); @@ -100,9 +96,9 @@ void QgsMssqlGeomColumnTypeThread::run() { const bool hasZ { q.value( 2 ).toString() == '1' }; const bool hasM { q.value( 3 ).toString() == '1' }; - const int dimensions { 2 + ( ( hasZ &&hasM ) ? 2 : ( ( hasZ || hasM ) ? 1 : 0 ) ) }; + const int dimensions { 2 + ( ( hasZ && hasM ) ? 2 : ( ( hasZ || hasM ) ? 1 : 0 ) ) }; QString typeName { q.value( 0 ).toString().toUpper() }; - if ( hasM && ! typeName.endsWith( 'M' ) ) + if ( hasM && !typeName.endsWith( 'M' ) ) { typeName.append( 'M' ); } diff --git a/src/providers/mssql/qgsmssqlgeometryparser.cpp b/src/providers/mssql/qgsmssqlgeometryparser.cpp index daa6d32352a3..1c5ea670fbcc 100644 --- a/src/providers/mssql/qgsmssqlgeometryparser.cpp +++ b/src/providers/mssql/qgsmssqlgeometryparser.cpp @@ -137,27 +137,27 @@ SegmentType (1 byte) #define SMT_FIRSTLINE 2 #define SMT_FIRSTARC 3 -#define ReadInt32(nPos) (*((unsigned int*)(mData + (nPos)))) +#define ReadInt32( nPos ) ( *( ( unsigned int * ) ( mData + ( nPos ) ) ) ) -#define ReadByte(nPos) (mData[nPos]) +#define ReadByte( nPos ) ( mData[nPos] ) -#define ReadDouble(nPos) (*((double*)(mData + (nPos)))) +#define ReadDouble( nPos ) ( *( ( double * ) ( mData + ( nPos ) ) ) ) -#define ParentOffset(iShape) (ReadInt32(mShapePos + (iShape) * 9 )) -#define FigureOffset(iShape) (ReadInt32(mShapePos + (iShape) * 9 + 4)) -#define ShapeType(iShape) (ReadByte(mShapePos + (iShape) * 9 + 8)) -#define SegmentType(iSegment) (ReadByte(mSegmentPos + (iSegment))) +#define ParentOffset( iShape ) ( ReadInt32( mShapePos + ( iShape ) * 9 ) ) +#define FigureOffset( iShape ) ( ReadInt32( mShapePos + ( iShape ) * 9 + 4 ) ) +#define ShapeType( iShape ) ( ReadByte( mShapePos + ( iShape ) * 9 + 8 ) ) +#define SegmentType( iSegment ) ( ReadByte( mSegmentPos + ( iSegment ) ) ) -#define NextFigureOffset(iShape) (iShape + 1 < mNumShapes? FigureOffset((iShape) +1) : mNumFigures) +#define NextFigureOffset( iShape ) ( iShape + 1 < mNumShapes ? FigureOffset( ( iShape ) + 1 ) : mNumFigures ) -#define FigureAttribute(iFigure) (ReadByte(mFigurePos + (iFigure) * 5)) -#define PointOffset(iFigure) (ReadInt32(mFigurePos + (iFigure) * 5 + 1)) -#define NextPointOffset(iFigure) (iFigure + 1 < mNumFigures? PointOffset((iFigure) +1) : mNumPoints) +#define FigureAttribute( iFigure ) ( ReadByte( mFigurePos + ( iFigure ) * 5 ) ) +#define PointOffset( iFigure ) ( ReadInt32( mFigurePos + ( iFigure ) * 5 + 1 ) ) +#define NextPointOffset( iFigure ) ( iFigure + 1 < mNumFigures ? PointOffset( ( iFigure ) + 1 ) : mNumPoints ) -#define ReadX(iPoint) (ReadDouble(mPointPos + 16 * (iPoint))) -#define ReadY(iPoint) (ReadDouble(mPointPos + 16 * (iPoint) + 8)) -#define ReadZ(iPoint) (ReadDouble(mPointPos + 16 * mNumPoints + 8 * (iPoint))) -#define ReadM(iPoint) (ReadDouble(mPointPos + 24 * mNumPoints + 8 * (iPoint))) +#define ReadX( iPoint ) ( ReadDouble( mPointPos + 16 * ( iPoint ) ) ) +#define ReadY( iPoint ) ( ReadDouble( mPointPos + 16 * ( iPoint ) + 8 ) ) +#define ReadZ( iPoint ) ( ReadDouble( mPointPos + 16 * mNumPoints + 8 * ( iPoint ) ) ) +#define ReadM( iPoint ) ( ReadDouble( mPointPos + 24 * mNumPoints + 8 * ( iPoint ) ) ) QgsMssqlGeometryParser::QgsMssqlGeometryParser() { @@ -337,26 +337,26 @@ const QgsPointSequence QgsMssqlGeometryParser::readPointSequence( int iPoint, in return pts; } -std::unique_ptr< QgsPoint > QgsMssqlGeometryParser::readPoint( int iFigure ) +std::unique_ptr QgsMssqlGeometryParser::readPoint( int iFigure ) { if ( iFigure < mNumFigures ) { const int iPoint = PointOffset( iFigure ); if ( iPoint < mNumPoints ) { - return std::make_unique< QgsPoint >( readCoordinates( iPoint ) ); + return std::make_unique( readCoordinates( iPoint ) ); } } return nullptr; } -std::unique_ptr< QgsMultiPoint > QgsMssqlGeometryParser::readMultiPoint( int iShape ) +std::unique_ptr QgsMssqlGeometryParser::readMultiPoint( int iShape ) { - std::unique_ptr< QgsMultiPoint > poMultiPoint = std::make_unique< QgsMultiPoint >(); + std::unique_ptr poMultiPoint = std::make_unique(); poMultiPoint->reserve( mNumShapes ); for ( int i = iShape + 1; i < mNumShapes; i++ ) { - if ( ParentOffset( i ) == ( unsigned int )iShape ) + if ( ParentOffset( i ) == ( unsigned int ) iShape ) { if ( ShapeType( i ) == ST_POINT ) poMultiPoint->addGeometry( readPoint( FigureOffset( i ) ).release() ); @@ -366,14 +366,14 @@ std::unique_ptr< QgsMultiPoint > QgsMssqlGeometryParser::readMultiPoint( int iSh return poMultiPoint; } -std::unique_ptr< QgsLineString > QgsMssqlGeometryParser::readLineString( int iPoint, int iNextPoint ) +std::unique_ptr QgsMssqlGeometryParser::readLineString( int iPoint, int iNextPoint ) { - QVector< double > xOut( iNextPoint - iPoint ); - QVector< double > yOut( iNextPoint - iPoint ); - QVector< double > zOut; + QVector xOut( iNextPoint - iPoint ); + QVector yOut( iNextPoint - iPoint ); + QVector zOut; if ( mProps & SP_HASZVALUES ) zOut.resize( iNextPoint - iPoint ); - QVector< double > mOut; + QVector mOut; if ( mProps & SP_HASMVALUES ) mOut.resize( iNextPoint - iPoint ); double *x = xOut.data(); @@ -383,33 +383,33 @@ std::unique_ptr< QgsLineString > QgsMssqlGeometryParser::readLineString( int iPo readCoordinates( iPoint, iNextPoint, x, y, z, m ); - return std::make_unique< QgsLineString >( xOut, yOut, zOut, mOut ); + return std::make_unique( xOut, yOut, zOut, mOut ); } -std::unique_ptr< QgsLineString > QgsMssqlGeometryParser::readLineString( int iFigure ) +std::unique_ptr QgsMssqlGeometryParser::readLineString( int iFigure ) { return readLineString( PointOffset( iFigure ), NextPointOffset( iFigure ) ); } -std::unique_ptr< QgsCircularString > QgsMssqlGeometryParser::readCircularString( int iPoint, int iNextPoint ) +std::unique_ptr QgsMssqlGeometryParser::readCircularString( int iPoint, int iNextPoint ) { - std::unique_ptr< QgsCircularString > poCircularString = std::make_unique< QgsCircularString >(); + std::unique_ptr poCircularString = std::make_unique(); poCircularString->setPoints( readPointSequence( iPoint, iNextPoint ) ); return poCircularString; } -std::unique_ptr< QgsCircularString > QgsMssqlGeometryParser::readCircularString( int iFigure ) +std::unique_ptr QgsMssqlGeometryParser::readCircularString( int iFigure ) { return readCircularString( PointOffset( iFigure ), NextPointOffset( iFigure ) ); } -std::unique_ptr< QgsMultiLineString > QgsMssqlGeometryParser::readMultiLineString( int iShape ) +std::unique_ptr QgsMssqlGeometryParser::readMultiLineString( int iShape ) { - std::unique_ptr< QgsMultiLineString > poMultiLineString = std::make_unique< QgsMultiLineString >(); + std::unique_ptr poMultiLineString = std::make_unique(); poMultiLineString->reserve( mNumShapes ); for ( int i = iShape + 1; i < mNumShapes; i++ ) { - if ( ParentOffset( i ) == ( unsigned int )iShape ) + if ( ParentOffset( i ) == ( unsigned int ) iShape ) { if ( ShapeType( i ) == ST_LINESTRING ) poMultiLineString->addGeometry( readLineString( FigureOffset( i ) ).release() ); @@ -419,13 +419,13 @@ std::unique_ptr< QgsMultiLineString > QgsMssqlGeometryParser::readMultiLineStrin return poMultiLineString; } -std::unique_ptr< QgsPolygon > QgsMssqlGeometryParser::readPolygon( int iShape ) +std::unique_ptr QgsMssqlGeometryParser::readPolygon( int iShape ) { int iFigure; int iRingCount = 0; const int iNextFigure = NextFigureOffset( iShape ); - std::unique_ptr< QgsPolygon > poPoly = std::make_unique< QgsPolygon >(); + std::unique_ptr poPoly = std::make_unique(); for ( iFigure = FigureOffset( iShape ); iFigure < iNextFigure; iFigure++ ) { if ( iRingCount == 0 ) @@ -438,13 +438,13 @@ std::unique_ptr< QgsPolygon > QgsMssqlGeometryParser::readPolygon( int iShape ) return poPoly; } -std::unique_ptr< QgsMultiPolygon > QgsMssqlGeometryParser::readMultiPolygon( int iShape ) +std::unique_ptr QgsMssqlGeometryParser::readMultiPolygon( int iShape ) { - std::unique_ptr< QgsMultiPolygon > poMultiPolygon = std::make_unique< QgsMultiPolygon >(); + std::unique_ptr poMultiPolygon = std::make_unique(); poMultiPolygon->reserve( mNumShapes ); for ( int i = iShape + 1; i < mNumShapes; i++ ) { - if ( ParentOffset( i ) == ( unsigned int )iShape ) + if ( ParentOffset( i ) == ( unsigned int ) iShape ) { if ( ShapeType( i ) == ST_POLYGON ) poMultiPolygon->addGeometry( readPolygon( i ).release() ); @@ -454,14 +454,14 @@ std::unique_ptr< QgsMultiPolygon > QgsMssqlGeometryParser::readMultiPolygon( int return poMultiPolygon; } -std::unique_ptr< QgsCompoundCurve > QgsMssqlGeometryParser::readCompoundCurve( int iFigure ) +std::unique_ptr QgsMssqlGeometryParser::readCompoundCurve( int iFigure ) { int iPoint, iNextPoint, nPointsPrepared; - std::unique_ptr< QgsCompoundCurve > poCompoundCurve = std::make_unique< QgsCompoundCurve >(); + std::unique_ptr poCompoundCurve = std::make_unique(); iPoint = PointOffset( iFigure ); iNextPoint = NextPointOffset( iFigure ) - 1; - const std::unique_ptr< QgsCurve > poGeom; + const std::unique_ptr poGeom; nPointsPrepared = 0; bool isCurve = false; @@ -517,13 +517,13 @@ std::unique_ptr< QgsCompoundCurve > QgsMssqlGeometryParser::readCompoundCurve( i return poCompoundCurve; } -std::unique_ptr< QgsCurvePolygon > QgsMssqlGeometryParser::readCurvePolygon( int iShape ) +std::unique_ptr QgsMssqlGeometryParser::readCurvePolygon( int iShape ) { int iFigure; int iRingCount = 0; const int iNextFigure = NextFigureOffset( iShape ); - std::unique_ptr< QgsCurvePolygon > poPoly = std::make_unique< QgsCurvePolygon >(); + std::unique_ptr poPoly = std::make_unique(); for ( iFigure = FigureOffset( iShape ); iFigure < iNextFigure; iFigure++ ) { switch ( FigureAttribute( iFigure ) ) @@ -552,13 +552,13 @@ std::unique_ptr< QgsCurvePolygon > QgsMssqlGeometryParser::readCurvePolygon( int return poPoly; } -std::unique_ptr< QgsGeometryCollection > QgsMssqlGeometryParser::readGeometryCollection( int iShape ) +std::unique_ptr QgsMssqlGeometryParser::readGeometryCollection( int iShape ) { - std::unique_ptr< QgsGeometryCollection> poGeomColl = std::make_unique< QgsGeometryCollection >(); + std::unique_ptr poGeomColl = std::make_unique(); poGeomColl->reserve( mNumShapes ); for ( int i = iShape + 1; i < mNumShapes; i++ ) { - if ( ParentOffset( i ) == ( unsigned int )iShape ) + if ( ParentOffset( i ) == ( unsigned int ) iShape ) { switch ( ShapeType( i ) ) { @@ -631,7 +631,7 @@ std::unique_ptr QgsMssqlGeometryParser::parseSqlGeometry( u else mPointSize = 16; - std::unique_ptr< QgsAbstractGeometry> poGeom; + std::unique_ptr poGeom; if ( mProps & SP_ISSINGLEPOINT ) { @@ -646,7 +646,7 @@ std::unique_ptr QgsMssqlGeometryParser::parseSqlGeometry( u return nullptr; } - poGeom = std::make_unique< QgsPoint >( readCoordinates( 0 ) ); + poGeom = std::make_unique( readCoordinates( 0 ) ); } else if ( mProps & SP_ISSINGLELINESEGMENT ) { @@ -661,7 +661,7 @@ std::unique_ptr QgsMssqlGeometryParser::parseSqlGeometry( u return nullptr; } - poGeom = std::make_unique< QgsLineString >( readCoordinates( 0 ), readCoordinates( 1 ) ); + poGeom = std::make_unique( readCoordinates( 0 ), readCoordinates( 1 ) ); } else { diff --git a/src/providers/mssql/qgsmssqlgeometryparser.h b/src/providers/mssql/qgsmssqlgeometryparser.h index 53a9c77d104a..b15a39008860 100644 --- a/src/providers/mssql/qgsmssqlgeometryparser.h +++ b/src/providers/mssql/qgsmssqlgeometryparser.h @@ -30,14 +30,12 @@ #include "qgspoint.h" - /** * \class QgsMssqlGeometryParser * \brief Geometry parser for SqlGeometry/SqlGeography. */ class QgsMssqlGeometryParser { - protected: unsigned char *mData = nullptr; /* version information */ @@ -64,18 +62,18 @@ class QgsMssqlGeometryParser QgsPoint readCoordinates( int iPoint ) const; void readCoordinates( int iPoint, int iNextPoint, double *x, double *y, double *z, double *m ) const; const QgsPointSequence readPointSequence( int iPoint, int iNextPoint ) const; - std::unique_ptr< QgsPoint > readPoint( int iShape ); - std::unique_ptr< QgsMultiPoint > readMultiPoint( int iShape ); - std::unique_ptr< QgsLineString > readLineString( int iPoint, int iNextPoint ); - std::unique_ptr< QgsLineString > readLineString( int iFigure ); - std::unique_ptr< QgsCircularString > readCircularString( int iPoint, int iNextPoint ); - std::unique_ptr< QgsCircularString > readCircularString( int iFigure ); - std::unique_ptr< QgsMultiLineString > readMultiLineString( int iShape ); - std::unique_ptr< QgsPolygon > readPolygon( int iShape ); - std::unique_ptr< QgsMultiPolygon > readMultiPolygon( int iShape ); - std::unique_ptr< QgsCompoundCurve > readCompoundCurve( int iFigure ); - std::unique_ptr< QgsCurvePolygon > readCurvePolygon( int iShape ); - std::unique_ptr< QgsGeometryCollection > readGeometryCollection( int iShape ); + std::unique_ptr readPoint( int iShape ); + std::unique_ptr readMultiPoint( int iShape ); + std::unique_ptr readLineString( int iPoint, int iNextPoint ); + std::unique_ptr readLineString( int iFigure ); + std::unique_ptr readCircularString( int iPoint, int iNextPoint ); + std::unique_ptr readCircularString( int iFigure ); + std::unique_ptr readMultiLineString( int iShape ); + std::unique_ptr readPolygon( int iShape ); + std::unique_ptr readMultiPolygon( int iShape ); + std::unique_ptr readCompoundCurve( int iFigure ); + std::unique_ptr readCurvePolygon( int iShape ); + std::unique_ptr readGeometryCollection( int iShape ); public: QgsMssqlGeometryParser(); diff --git a/src/providers/mssql/qgsmssqlnewconnection.cpp b/src/providers/mssql/qgsmssqlnewconnection.cpp index 9901da6420e5..374a9477ba81 100644 --- a/src/providers/mssql/qgsmssqlnewconnection.cpp +++ b/src/providers/mssql/qgsmssqlnewconnection.cpp @@ -49,8 +49,8 @@ QgsMssqlNewConnection::QgsMssqlNewConnection( QWidget *parent, const QString &co connect( txtHost, &QLineEdit::textChanged, this, &QgsMssqlNewConnection::updateOkButtonState ); connect( listDatabase, &QListWidget::currentItemChanged, this, &QgsMssqlNewConnection::updateOkButtonState ); connect( listDatabase, &QListWidget::currentItemChanged, this, &QgsMssqlNewConnection::onCurrentDataBaseChange ); - connect( groupBoxGeometryColumns, &QGroupBox::toggled, this, &QgsMssqlNewConnection::onCurrentDataBaseChange ); - connect( cb_allowGeometrylessTables, &QCheckBox::clicked, this, &QgsMssqlNewConnection::onCurrentDataBaseChange ); + connect( groupBoxGeometryColumns, &QGroupBox::toggled, this, &QgsMssqlNewConnection::onCurrentDataBaseChange ); + connect( cb_allowGeometrylessTables, &QCheckBox::clicked, this, &QgsMssqlNewConnection::onCurrentDataBaseChange ); connect( checkBoxExtentFromGeometryColumns, &QCheckBox::toggled, this, &QgsMssqlNewConnection::onExtentFromGeometryToggled ); connect( checkBoxPKFromGeometryColumns, &QCheckBox::toggled, this, &QgsMssqlNewConnection::onPrimaryKeyFromGeometryToggled ); @@ -101,22 +101,18 @@ QgsMssqlNewConnection::QgsMssqlNewConnection( QWidget *parent, const QString &co schemaView->setModel( &mSchemaModel ); schemaView->setContextMenuPolicy( Qt::CustomContextMenu ); - connect( schemaView, &QWidget::customContextMenuRequested, this, [this]( const QPoint & p ) - { + connect( schemaView, &QWidget::customContextMenuRequested, this, [this]( const QPoint &p ) { QMenu menu; - menu.addAction( tr( "Check All" ), this, [this] - { + menu.addAction( tr( "Check All" ), this, [this] { mSchemaModel.checkAll(); } ); - menu.addAction( tr( "Uncheck All" ), this, [this] - { + menu.addAction( tr( "Uncheck All" ), this, [this] { mSchemaModel.unCheckAll(); } ); menu.exec( this->schemaView->viewport()->mapToGlobal( p ) ); - } - ); + } ); onCurrentDataBaseChange(); groupBoxSchemasFilter->setCollapsed( !groupBoxSchemasFilter->isChecked() ); @@ -130,13 +126,7 @@ void QgsMssqlNewConnection::accept() settings.setValue( baseKey + "selected", txtName->text() ); // warn if entry was renamed to an existing connection - if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( txtName->text(), Qt::CaseInsensitive ) != 0 ) && - ( settings.contains( baseKey + txtName->text() + "/service" ) || - settings.contains( baseKey + txtName->text() + "/host" ) ) && - QMessageBox::question( this, - tr( "Save Connection" ), - tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( txtName->text(), Qt::CaseInsensitive ) != 0 ) && ( settings.contains( baseKey + txtName->text() + "/service" ) || settings.contains( baseKey + txtName->text() + "/host" ) ) && QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; } @@ -256,7 +246,7 @@ void QgsMssqlNewConnection::listDatabases() { QSqlQuery query = QSqlQuery( db->db() ); query.setForwardOnly( true ); - ( void )query.exec( queryStr ); + ( void ) query.exec( queryStr ); if ( !txtService->text().isEmpty() ) { @@ -303,11 +293,7 @@ std::shared_ptr QgsMssqlNewConnection::getDatabase( const QStr database = item->text(); } - return QgsMssqlDatabase::connectDb( txtService->text().trimmed(), - txtHost->text().trimmed(), - database, - txtUsername->text().trimmed(), - txtPassword->text().trimmed() ); + return QgsMssqlDatabase::connectDb( txtService->text().trimmed(), txtHost->text().trimmed(), database, txtUsername->text().trimmed(), txtPassword->text().trimmed() ); } @@ -398,7 +384,8 @@ bool QgsMssqlNewConnection::testPrimaryKeyInGeometryColumns() const return test; } -SchemaModel::SchemaModel( QObject *parent ): QAbstractListModel( parent ) +SchemaModel::SchemaModel( QObject *parent ) + : QAbstractListModel( parent ) {} int SchemaModel::rowCount( const QModelIndex &parent ) const diff --git a/src/providers/mssql/qgsmssqlnewconnection.h b/src/providers/mssql/qgsmssqlnewconnection.h index b89e189520d5..fc9fef7fa7bf 100644 --- a/src/providers/mssql/qgsmssqlnewconnection.h +++ b/src/providers/mssql/qgsmssqlnewconnection.h @@ -26,7 +26,7 @@ class QgsMssqlDatabase; //! Class that reprents a model to display available schemas on a database and choose which will be displayed in QGIS -class SchemaModel: public QAbstractListModel +class SchemaModel : public QAbstractListModel { Q_OBJECT public: @@ -59,7 +59,6 @@ class SchemaModel: public QAbstractListModel QString mDataBaseName; QStringList mSchemas; QStringList mExcludedSchemas; - }; /** @@ -96,7 +95,6 @@ class QgsMssqlNewConnection : public QDialog, private Ui::QgsMssqlNewConnectionB void onPrimaryKeyFromGeometryToggled( bool checked ); private: - QString mOriginalConnName; //store initial name to delete entry in case of rename void showHelp(); diff --git a/src/providers/mssql/qgsmssqlprovider.cpp b/src/providers/mssql/qgsmssqlprovider.cpp index 379ba6d2708e..268c9ef16a15 100644 --- a/src/providers/mssql/qgsmssqlprovider.cpp +++ b/src/providers/mssql/qgsmssqlprovider.cpp @@ -58,17 +58,16 @@ #include "qgsconfig.h" constexpr int sMssqlConQueryLogFilePrefixLength = CMAKE_SOURCE_DIR[sizeof( CMAKE_SOURCE_DIR ) - 1] == '/' ? sizeof( CMAKE_SOURCE_DIR ) + 1 : sizeof( CMAKE_SOURCE_DIR ); -#define LoggedExec(query, sql ) execLogged( query, sql, QString(QString( __FILE__ ).mid( sMssqlConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") ) -#define LoggedExecPrepared(query ) execPreparedLogged( query, QString(QString( __FILE__ ).mid( sMssqlConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") ) -#define LoggedExecMetadata(query, sql, uri ) execLogged( query, sql, uri, QString(QString( __FILE__ ).mid( sMssqlConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") ) +#define LoggedExec( query, sql ) execLogged( query, sql, QString( QString( __FILE__ ).mid( sMssqlConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) ) +#define LoggedExecPrepared( query ) execPreparedLogged( query, QString( QString( __FILE__ ).mid( sMssqlConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) ) +#define LoggedExecMetadata( query, sql, uri ) execLogged( query, sql, uri, QString( QString( __FILE__ ).mid( sMssqlConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) ) const QString QgsMssqlProvider::MSSQL_PROVIDER_KEY = QStringLiteral( "mssql" ); const QString QgsMssqlProvider::MSSQL_PROVIDER_DESCRIPTION = QStringLiteral( "MSSQL spatial data provider" ); int QgsMssqlProvider::sConnectionId = 0; -QgsMssqlProvider::QgsMssqlProvider( const QString &uri, const ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) +QgsMssqlProvider::QgsMssqlProvider( const QString &uri, const ProviderOptions &options, Qgis::DataProviderReadFlags flags ) : QgsVectorDataProvider( uri, options, flags ) , mShared( new QgsMssqlSharedData ) { @@ -96,12 +95,12 @@ QgsMssqlProvider::QgsMssqlProvider( const QString &uri, const ProviderOptions &o } mDisableInvalidGeometryHandling = anUri.hasParam( QStringLiteral( "disableInvalidGeometryHandling" ) ) - ? anUri.param( QStringLiteral( "disableInvalidGeometryHandling" ) ).toInt() - : false; + ? anUri.param( QStringLiteral( "disableInvalidGeometryHandling" ) ).toInt() + : false; mUseGeometryColumnsTableForExtent = anUri.hasParam( QStringLiteral( "extentInGeometryColumns" ) ) - ? anUri.param( QStringLiteral( "extentInGeometryColumns" ) ).toInt() - : false; + ? anUri.param( QStringLiteral( "extentInGeometryColumns" ) ).toInt() + : false; mSqlWhereClause = anUri.sql(); @@ -164,8 +163,8 @@ QgsMssqlProvider::QgsMssqlProvider( const QString &uri, const ProviderOptions &o //only for views, defined in layer data when loading layer for first time bool primaryKeyFromGeometryColumnsTable = anUri.hasParam( QStringLiteral( "primaryKeyInGeometryColumns" ) ) - ? anUri.param( QStringLiteral( "primaryKeyInGeometryColumns" ) ).toInt() - : false; + ? anUri.param( QStringLiteral( "primaryKeyInGeometryColumns" ) ).toInt() + : false; QStringList cols; if ( primaryKeyFromGeometryColumnsTable ) @@ -174,8 +173,7 @@ QgsMssqlProvider::QgsMssqlProvider( const QString &uri, const ProviderOptions &o mPrimaryKeyAttrs.clear(); primaryKeyFromGeometryColumnsTable = getPrimaryKeyFromGeometryColumns( cols ); if ( !primaryKeyFromGeometryColumnsTable ) - QgsMessageLog::logMessage( tr( "Invalid primary key from geometry_columns table for layer '%1', get primary key from the layer." ) - .arg( anUri.table() ), tr( "MS SQL Server" ) ); + QgsMessageLog::logMessage( tr( "Invalid primary key from geometry_columns table for layer '%1', get primary key from the layer." ).arg( anUri.table() ), tr( "MS SQL Server" ) ); } if ( !primaryKeyFromGeometryColumnsTable ) @@ -183,7 +181,6 @@ QgsMssqlProvider::QgsMssqlProvider( const QString &uri, const ProviderOptions &o const QString primaryKey = anUri.keyColumn(); if ( !primaryKey.isEmpty() ) { - mPrimaryKeyAttrs.clear(); cols = parseUriKey( primaryKey ); } @@ -204,10 +201,7 @@ QgsMssqlProvider::QgsMssqlProvider( const QString &uri, const ProviderOptions &o const QgsField &fld = mAttributeFields.at( idx ); - if ( mPrimaryKeyAttrs.size() == 0 && - ( fld.type() == QMetaType::Type::Int || - fld.type() == QMetaType::Type::LongLong || - ( fld.type() == QMetaType::Type::Double && fld.precision() == 0 ) ) ) + if ( mPrimaryKeyAttrs.size() == 0 && ( fld.type() == QMetaType::Type::Int || fld.type() == QMetaType::Type::LongLong || ( fld.type() == QMetaType::Type::Double && fld.precision() == 0 ) ) ) { mPrimaryKeyType = PktInt; } @@ -255,27 +249,15 @@ QgsFeatureIterator QgsMssqlProvider::getFeatures( const QgsFeatureRequest &reque QMetaType::Type QgsMssqlProvider::DecodeSqlType( const QString &sqlTypeName ) { QMetaType::Type type = QMetaType::Type::UnknownType; - if ( sqlTypeName.startsWith( QLatin1String( "decimal" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "numeric" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "real" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "float" ), Qt::CaseInsensitive ) ) + if ( sqlTypeName.startsWith( QLatin1String( "decimal" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "numeric" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "real" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "float" ), Qt::CaseInsensitive ) ) { type = QMetaType::Type::Double; } - else if ( sqlTypeName.startsWith( QLatin1String( "char" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "nchar" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "varchar" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "nvarchar" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "text" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "ntext" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "uniqueidentifier" ), Qt::CaseInsensitive ) ) + else if ( sqlTypeName.startsWith( QLatin1String( "char" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "nchar" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "varchar" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "nvarchar" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "text" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "ntext" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "uniqueidentifier" ), Qt::CaseInsensitive ) ) { type = QMetaType::Type::QString; } - else if ( sqlTypeName.startsWith( QLatin1String( "smallint" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "int" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "bit" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "tinyint" ), Qt::CaseInsensitive ) ) + else if ( sqlTypeName.startsWith( QLatin1String( "smallint" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "int" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "bit" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "tinyint" ), Qt::CaseInsensitive ) ) { type = QMetaType::Type::Int; } @@ -283,15 +265,11 @@ QMetaType::Type QgsMssqlProvider::DecodeSqlType( const QString &sqlTypeName ) { type = QMetaType::Type::LongLong; } - else if ( sqlTypeName.startsWith( QLatin1String( "binary" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "varbinary" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "image" ), Qt::CaseInsensitive ) ) + else if ( sqlTypeName.startsWith( QLatin1String( "binary" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "varbinary" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "image" ), Qt::CaseInsensitive ) ) { type = QMetaType::Type::QByteArray; } - else if ( sqlTypeName.startsWith( QLatin1String( "datetime" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "smalldatetime" ), Qt::CaseInsensitive ) || - sqlTypeName.startsWith( QLatin1String( "datetime2" ), Qt::CaseInsensitive ) ) + else if ( sqlTypeName.startsWith( QLatin1String( "datetime" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "smalldatetime" ), Qt::CaseInsensitive ) || sqlTypeName.startsWith( QLatin1String( "datetime2" ), Qt::CaseInsensitive ) ) { type = QMetaType::Type::QDateTime; } @@ -341,9 +319,9 @@ void QgsMssqlProvider::loadMetadata() bool QgsMssqlProvider::execLogged( QSqlQuery &qry, const QString &sql, const QString &queryOrigin ) const { - QgsDatabaseQueryLogWrapper logWrapper{ sql, uri().uri(), QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), queryOrigin }; + QgsDatabaseQueryLogWrapper logWrapper { sql, uri().uri(), QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), queryOrigin }; const bool res { qry.exec( sql ) }; - if ( ! res ) + if ( !res ) { logWrapper.setError( qry.lastError().text() ); } @@ -364,9 +342,9 @@ bool QgsMssqlProvider::execLogged( QSqlQuery &qry, const QString &sql, const QSt bool QgsMssqlProvider::execPreparedLogged( QSqlQuery &qry, const QString &queryOrigin ) const { - QgsDatabaseQueryLogWrapper logWrapper{ qry.lastQuery(), uri().uri(), QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), queryOrigin }; - const bool res { qry.exec( ) }; - if ( ! res ) + QgsDatabaseQueryLogWrapper logWrapper { qry.lastQuery(), uri().uri(), QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), queryOrigin }; + const bool res { qry.exec() }; + if ( !res ) { logWrapper.setError( qry.lastError().text() ); } @@ -433,7 +411,7 @@ void QgsMssqlProvider::loadFields() const QString sql2 { QStringLiteral( "SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC" " INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE CC ON TC.CONSTRAINT_NAME = CC.CONSTRAINT_NAME" " WHERE TC.CONSTRAINT_SCHEMA = '%1' AND TC.TABLE_NAME = '%2' AND TC.CONSTRAINT_TYPE = 'unique'" ) - .arg( mSchemaName, mTableName ) }; + .arg( mSchemaName, mTableName ) }; if ( !LoggedExec( query, sql2 ) ) { pushError( query.lastError().text() ); @@ -495,32 +473,19 @@ void QgsMssqlProvider::loadFields() { length = length / 2; } - field = QgsField( colName, - sqlType, - sqlTypeName, - length ); + field = QgsField( colName, sqlType, sqlTypeName, length ); } else if ( sqlType == QMetaType::Type::Double ) { - field = QgsField( colName, - sqlType, - sqlTypeName, - query.value( QStringLiteral( "PRECISION" ) ).toInt(), - sqlTypeName == QLatin1String( "decimal" ) || sqlTypeName == QLatin1String( "numeric" ) ? query.value( QStringLiteral( "SCALE" ) ).toInt() : -1 ); + field = QgsField( colName, sqlType, sqlTypeName, query.value( QStringLiteral( "PRECISION" ) ).toInt(), sqlTypeName == QLatin1String( "decimal" ) || sqlTypeName == QLatin1String( "numeric" ) ? query.value( QStringLiteral( "SCALE" ) ).toInt() : -1 ); } else if ( sqlType == QMetaType::Type::QDate || sqlType == QMetaType::Type::QDateTime || sqlType == QMetaType::Type::QTime ) { - field = QgsField( colName, - sqlType, - sqlTypeName, - -1, - -1 ); + field = QgsField( colName, sqlType, sqlTypeName, -1, -1 ); } else { - field = QgsField( colName, - sqlType, - sqlTypeName ); + field = QgsField( colName, sqlType, sqlTypeName ); } // Field nullable @@ -578,10 +543,7 @@ void QgsMssqlProvider::loadFields() const int idx = mAttributeFields.indexFromName( fidColName ); const QgsField &fld = mAttributeFields.at( idx ); - if ( !mPrimaryKeyAttrs.isEmpty() || - ( fld.type() != QMetaType::Type::Int && - fld.type() != QMetaType::Type::LongLong && - ( fld.type() != QMetaType::Type::Double || fld.precision() != 0 ) ) ) + if ( !mPrimaryKeyAttrs.isEmpty() || ( fld.type() != QMetaType::Type::Int && fld.type() != QMetaType::Type::LongLong && ( fld.type() != QMetaType::Type::Double || fld.precision() != 0 ) ) ) mPrimaryKeyType = PktFidMap; mPrimaryKeyAttrs << idx; @@ -602,7 +564,7 @@ void QgsMssqlProvider::loadFields() query.clear(); query.setForwardOnly( true ); const QString sql5 { QStringLiteral( "select count(distinct [%1]), count([%1]) from [%2].[%3]" ) - .arg( pk, mSchemaName, mTableName ) }; + .arg( pk, mSchemaName, mTableName ) }; if ( !LoggedExec( query, sql5 ) ) { QgsDebugError( QStringLiteral( "SQL:%1\n Error:%2" ).arg( query.lastQuery(), query.lastError().text() ) ); @@ -630,7 +592,7 @@ void QgsMssqlProvider::loadFields() // primary key has unique constraints QgsFieldConstraints constraints = mAttributeFields.at( mPrimaryKeyAttrs[0] ).constraints(); constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); - mAttributeFields[ mPrimaryKeyAttrs[0] ].setConstraints( constraints ); + mAttributeFields[mPrimaryKeyAttrs[0]].setConstraints( constraints ); } } @@ -691,7 +653,7 @@ QVariant QgsMssqlProvider::defaultValue( int fieldId ) const return QVariant(); const QString sql = QStringLiteral( "select %1" ) - .arg( defVal ); + .arg( defVal ); QSqlQuery query = createQuery(); query.setForwardOnly( true ); @@ -753,7 +715,7 @@ QVariant QgsMssqlProvider::minimumValue( int index ) const // get the field name const QgsField &fld = mAttributeFields.at( index ); QString sql = QStringLiteral( "select min([%1]) from " ) - .arg( fld.name() ); + .arg( fld.name() ); sql += QStringLiteral( "[%1].[%2]" ).arg( mSchemaName, mTableName ); @@ -794,7 +756,7 @@ QVariant QgsMssqlProvider::maximumValue( int index ) const // get the field name const QgsField &fld = mAttributeFields.at( index ); QString sql = QStringLiteral( "select max([%1]) from " ) - .arg( fld.name() ); + .arg( fld.name() ); sql += QStringLiteral( "[%1].[%2]" ).arg( mSchemaName, mTableName ); @@ -843,7 +805,7 @@ QSet QgsMssqlProvider::uniqueValues( int index, int limit ) const } sql += QStringLiteral( "[%1] from " ) - .arg( fld.name() ); + .arg( fld.name() ); sql += QStringLiteral( "[%1].[%2]" ).arg( mSchemaName, mTableName ); @@ -895,7 +857,7 @@ QStringList QgsMssqlProvider::uniqueStringsMatching( int index, const QString &s } sql += QStringLiteral( "[%1] from " ) - .arg( fld.name() ); + .arg( fld.name() ); sql += QStringLiteral( "[%1].[%2] WHERE" ).arg( mSchemaName, mTableName ); @@ -959,10 +921,7 @@ void QgsMssqlProvider::UpdateStatistics( bool estimate ) const if ( LoggedExec( query, statement ) ) { - if ( query.next() && ( !QgsVariantUtils::isNull( query.value( 0 ) ) || - !QgsVariantUtils::isNull( query.value( 1 ) ) || - !QgsVariantUtils::isNull( query.value( 2 ) ) || - !QgsVariantUtils::isNull( query.value( 3 ) ) ) ) + if ( query.next() && ( !QgsVariantUtils::isNull( query.value( 0 ) ) || !QgsVariantUtils::isNull( query.value( 1 ) ) || !QgsVariantUtils::isNull( query.value( 2 ) ) || !QgsVariantUtils::isNull( query.value( 3 ) ) ) ) { QgsDebugMsgLevel( QStringLiteral( "Found extents in spatial index" ), 2 ); mExtent.setXMinimum( query.value( 0 ).toDouble() ); @@ -1045,8 +1004,7 @@ void QgsMssqlProvider::UpdateStatistics( bool estimate ) const const QString statementSample = statement + ( mSqlWhereClause.isEmpty() ? " WHERE " : " AND " ) + sampleFilter; - if ( LoggedExec( query, statementSample ) && query.next() && - !QgsVariantUtils::isNull( query.value( 0 ) ) && query.value( 4 ).toInt() >= minSampleCount ) + if ( LoggedExec( query, statementSample ) && query.next() && !QgsVariantUtils::isNull( query.value( 0 ) ) && query.value( 4 ).toInt() >= minSampleCount ) { mExtent.setXMinimum( query.value( 0 ).toDouble() ); mExtent.setYMinimum( query.value( 1 ).toDouble() ); @@ -1079,7 +1037,7 @@ void QgsMssqlProvider::UpdateStatistics( bool estimate ) const while ( query.next() ) { QByteArray ar = query.value( 0 ).toByteArray(); - std::unique_ptr geom = mParser.parseSqlGeometry( reinterpret_cast< unsigned char * >( ar.data() ), ar.size() ); + std::unique_ptr geom = mParser.parseSqlGeometry( reinterpret_cast( ar.data() ), ar.size() ); if ( geom ) { const QgsRectangle rect = geom->boundingBox(); @@ -1133,7 +1091,9 @@ long long QgsMssqlProvider::featureCount() const "SELECT rows" " FROM sys.tables t" " JOIN sys.partitions p ON t.object_id = p.object_id AND p.index_id IN (0,1)" - " WHERE SCHEMA_NAME(t.schema_id) = %1 AND OBJECT_NAME(t.OBJECT_ID) = %2" ).arg( quotedValue( mSchemaName ), quotedValue( mTableName ) ); + " WHERE SCHEMA_NAME(t.schema_id) = %1 AND OBJECT_NAME(t.OBJECT_ID) = %2" + ) + .arg( quotedValue( mSchemaName ), quotedValue( mTableName ) ); if ( LoggedExec( query, statement ) && query.next() ) { @@ -1176,11 +1136,9 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList &flist, Flags flags ) { it->clearGeometry(); } - else if ( it->hasGeometry() && QgsWkbTypes::geometryType( it->geometry().wkbType() ) != - QgsWkbTypes::geometryType( mWkbType ) ) + else if ( it->hasGeometry() && QgsWkbTypes::geometryType( it->geometry().wkbType() ) != QgsWkbTypes::geometryType( mWkbType ) ) { - pushError( tr( "Could not add feature with geometry type %1 to layer of type %2" ).arg( QgsWkbTypes::displayString( it->geometry().wkbType() ), - QgsWkbTypes::displayString( mWkbType ) ) ); + pushError( tr( "Could not add feature with geometry type %1 to layer of type %2" ).arg( QgsWkbTypes::displayString( it->geometry().wkbType() ), QgsWkbTypes::displayString( mWkbType ) ) ); if ( !mSkipFailures ) return false; @@ -1495,8 +1453,7 @@ bool QgsMssqlProvider::addAttributes( const QList &attributes ) if ( statement.isEmpty() ) { - statement = QStringLiteral( "ALTER TABLE [%1].[%2] ADD " ).arg( - mSchemaName, mTableName ); + statement = QStringLiteral( "ALTER TABLE [%1].[%2] ADD " ).arg( mSchemaName, mTableName ); } else statement += ','; @@ -1700,7 +1657,7 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap &att if ( !attrs.contains( idx ) ) continue; - k[i] = attrs[ idx ]; + k[i] = attrs[idx]; } mShared->insertFid( fid, k ); @@ -1774,7 +1731,7 @@ bool QgsMssqlProvider::changeGeometryValues( const QgsGeometryMap &geometry_map query.addBindValue( wkt ); } - if ( ! LoggedExecPrepared( query ) ) + if ( !LoggedExecPrepared( query ) ) { pushError( query.lastError().text() ); return false; @@ -1884,8 +1841,7 @@ Qgis::VectorProviderCapabilities QgsMssqlProvider::capabilities() const if ( hasGeom ) cap |= Qgis::VectorProviderCapability::ChangeGeometries; - return cap | Qgis::VectorProviderCapability::DeleteFeatures | Qgis::VectorProviderCapability::ChangeAttributeValues | Qgis::VectorProviderCapability::DeleteAttributes | - Qgis::VectorProviderCapability::SelectAtId; + return cap | Qgis::VectorProviderCapability::DeleteFeatures | Qgis::VectorProviderCapability::ChangeAttributeValues | Qgis::VectorProviderCapability::DeleteAttributes | Qgis::VectorProviderCapability::SelectAtId; } bool QgsMssqlProvider::createSpatialIndex() @@ -1896,14 +1852,11 @@ bool QgsMssqlProvider::createSpatialIndex() QSqlQuery query = createQuery(); query.setForwardOnly( true ); QString statement; - statement = QStringLiteral( "CREATE SPATIAL INDEX [qgs_%1_sidx] ON [%2].[%3] ( [%4] )" ).arg( - mGeometryColName, mSchemaName, mTableName, mGeometryColName ); + statement = QStringLiteral( "CREATE SPATIAL INDEX [qgs_%1_sidx] ON [%2].[%3] ( [%4] )" ).arg( mGeometryColName, mSchemaName, mTableName, mGeometryColName ); if ( mGeometryColType == QLatin1String( "geometry" ) ) { - statement += QStringLiteral( " USING GEOMETRY_GRID WITH (BOUNDING_BOX =(%1, %2, %3, %4))" ).arg( - QString::number( mExtent.xMinimum() ), QString::number( mExtent.yMinimum() ), - QString::number( mExtent.xMaximum() ), QString::number( mExtent.yMaximum() ) ); + statement += QStringLiteral( " USING GEOMETRY_GRID WITH (BOUNDING_BOX =(%1, %2, %3, %4))" ).arg( QString::number( mExtent.xMinimum() ), QString::number( mExtent.yMinimum() ), QString::number( mExtent.xMaximum() ), QString::number( mExtent.yMaximum() ) ); } else { @@ -1931,8 +1884,7 @@ bool QgsMssqlProvider::createAttributeIndex( int field ) return false; } - statement = QStringLiteral( "CREATE NONCLUSTERED INDEX [qgs_%1_idx] ON [%2].[%3] ( [%4] )" ).arg( - mGeometryColName, mSchemaName, mTableName, mAttributeFields.at( field ).name() ); + statement = QStringLiteral( "CREATE NONCLUSTERED INDEX [qgs_%1_idx] ON [%2].[%3] ( [%4] )" ).arg( mGeometryColName, mSchemaName, mTableName, mAttributeFields.at( field ).name() ); if ( !LoggedExec( query, statement ) ) { @@ -1975,7 +1927,7 @@ QgsCoordinateReferenceSystem QgsMssqlProvider::crs() const if ( mCrs.isValid() ) return mCrs; } - else // try to load as EPSG + else // try to load as EPSG { mCrs = QgsCoordinateReferenceSystem::fromEpsgId( mSRId ); } @@ -2010,7 +1962,7 @@ QString QgsMssqlProvider::subsetString() const return mSqlWhereClause; } -QString QgsMssqlProvider::name() const +QString QgsMssqlProvider::name() const { return MSSQL_PROVIDER_KEY; } @@ -2072,7 +2024,7 @@ QString QgsMssqlProvider::subsetStringHelpUrl() const return QStringLiteral( "https://learn.microsoft.com/en-us/sql/t-sql/queries/where-transact-sql?view=sql-server-ver16" ); } -QString QgsMssqlProvider::description() const +QString QgsMssqlProvider::description() const { return MSSQL_PROVIDER_DESCRIPTION; } @@ -2206,14 +2158,7 @@ Qgis::WkbType QgsMssqlProvider::getWkbType( const QString &geometryType ) } -Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap *oldToNewAttrIdxMap, - QString *errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap *oldToNewAttrIdxMap, QString *errorMessage, const QMap *options ) { Q_UNUSED( options ) @@ -2304,7 +2249,7 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, "CREATE TABLE spatial_ref_sys (srid integer not null " "PRIMARY KEY, auth_name varchar(256), auth_srid integer, srtext varchar(2048), proj4text varchar(2048))" ); - std::unique_ptr logWrapper = std::make_unique( sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), QGS_QUERY_LOG_ORIGIN ); + std::unique_ptr logWrapper = std::make_unique( sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), QGS_QUERY_LOG_ORIGIN ); if ( !q.exec( sql ) ) { @@ -2328,11 +2273,8 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, auth_srid = sl[1]; } sql = QStringLiteral( "IF NOT EXISTS (SELECT * FROM spatial_ref_sys WHERE srid=%1) INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) VALUES (%1, %2, %3, %4, %5)" ) - .arg( srid ) - .arg( quotedValue( auth_name ), - auth_srid, - quotedValue( srs.toWkt() ), - quotedValue( srs.toProj() ) ); + .arg( srid ) + .arg( quotedValue( auth_name ), auth_srid, quotedValue( srs.toWkt() ), quotedValue( srs.toProj() ) ); logWrapper.reset( new QgsDatabaseQueryLogWrapper( sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), QGS_QUERY_LOG_ORIGIN ) ); @@ -2354,7 +2296,7 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, { // remove the old table with the same name sql = QStringLiteral( "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[%1].[%2]') AND type in (N'U')) BEGIN DROP TABLE [%1].[%2] DELETE FROM geometry_columns where f_table_schema='%1' and f_table_name='%2' END;" ) - .arg( schemaName, tableName ); + .arg( schemaName, tableName ); logWrapper.reset( new QgsDatabaseQueryLogWrapper( sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), QGS_QUERY_LOG_ORIGIN ) ); @@ -2370,7 +2312,7 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, { // test for existing sql = QStringLiteral( "SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[%1].[%2]') AND type in (N'U')" ) - .arg( schemaName, tableName ); + .arg( schemaName, tableName ); logWrapper.reset( new QgsDatabaseQueryLogWrapper( sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), QGS_QUERY_LOG_ORIGIN ) ); @@ -2398,14 +2340,7 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, "DELETE FROM geometry_columns WHERE f_table_schema = '%1' AND f_table_name = '%2'\n" "INSERT INTO [geometry_columns] ([f_table_catalog], [f_table_schema],[f_table_name], " "[f_geometry_column],[coord_dimension],[srid],[geometry_type]) VALUES ('%5', '%1', '%2', '%4', %6, %7, '%8')" ) - .arg( schemaName, - tableName, - primaryKey, - geometryColumn, - dbName, - QString::number( dim ), - QString::number( srid ), - geometryType ); + .arg( schemaName, tableName, primaryKey, geometryColumn, dbName, QString::number( dim ), QString::number( srid ), geometryType ); } else { @@ -2413,10 +2348,8 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, sql = QStringLiteral( "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[%1].[%2]') AND type in (N'U')) DROP TABLE [%1].[%2]\n" "CREATE TABLE [%1].[%2]([%3] [int] IDENTITY(1,1) NOT NULL CONSTRAINT [PK_%2] PRIMARY KEY CLUSTERED ( [%3] ASC ))\n" "DELETE FROM geometry_columns WHERE f_table_schema = '%1' AND f_table_name = '%2'\n" - ) - .arg( schemaName, - tableName, - primaryKey ); + ) + .arg( schemaName, tableName, primaryKey ); } logWrapper.reset( new QgsDatabaseQueryLogWrapper( sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProvider" ), QGS_QUERY_LOG_ORIGIN ) ); @@ -2501,7 +2434,6 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, } - /** * Class factory to return a pointer to a newly created * QgsMssqlProvider object @@ -2509,7 +2441,8 @@ Qgis::VectorExportResult QgsMssqlProvider::createEmptyLayer( const QString &uri, QgsMssqlProvider *QgsMssqlProviderMetadata::createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) + Qgis::DataProviderReadFlags flags +) { return new QgsMssqlProvider( uri, options, flags ); } @@ -2551,19 +2484,12 @@ void QgsMssqlProviderMetadata::saveConnection( const QgsAbstractProviderConnecti saveConnectionProtected( conn, name ); } -Qgis::VectorExportResult QgsMssqlProviderMetadata::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap &oldToNewAttrIdxMap, - QString &errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsMssqlProviderMetadata::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) { return QgsMssqlProvider::createEmptyLayer( - uri, fields, wkbType, srs, overwrite, - &oldToNewAttrIdxMap, &errorMessage, options - ); + uri, fields, wkbType, srs, overwrite, + &oldToNewAttrIdxMap, &errorMessage, options + ); } bool QgsMssqlProviderMetadata::styleExists( const QString &uri, const QString &styleId, QString &errorCause ) @@ -2604,11 +2530,11 @@ bool QgsMssqlProviderMetadata::styleExists( const QString &uri, const QString &s " AND f_table_name=%3" " AND f_geometry_column=%4" " AND styleName=%5" ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) - .arg( QgsMssqlProvider::quotedValue( styleId.isEmpty() ? dsUri.table() : styleId ) ); + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) + .arg( QgsMssqlProvider::quotedValue( styleId.isEmpty() ? dsUri.table() : styleId ) ); if ( !LoggedExecMetadata( query, checkQuery, uri ) ) { @@ -2626,14 +2552,7 @@ bool QgsMssqlProviderMetadata::styleExists( const QString &uri, const QString &s } } -bool QgsMssqlProviderMetadata::saveStyle( const QString &uri, - const QString &qmlStyle, - const QString &sldStyle, - const QString &styleName, - const QString &styleDescription, - const QString &uiFileContent, - bool useAsDefault, - QString &errCause ) +bool QgsMssqlProviderMetadata::saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) { const QgsDataSourceUri dsUri( uri ); // connect to database @@ -2706,31 +2625,31 @@ bool QgsMssqlProviderMetadata::saveStyle( const QString &uri, ") VALUES (" "%1,%2,%3,%4,%5,%6,%7,%8,%9,%10%12" ")" ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) - .arg( QgsMssqlProvider::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ) - .arg( QgsMssqlProvider::quotedValue( qmlStyle ) ) - .arg( QgsMssqlProvider::quotedValue( sldStyle ) ) - .arg( useAsDefault ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) - .arg( QgsMssqlProvider::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.username() ) ) - .arg( uiFileColumn ) - .arg( uiFileValue ); + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) + .arg( QgsMssqlProvider::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ) + .arg( QgsMssqlProvider::quotedValue( qmlStyle ) ) + .arg( QgsMssqlProvider::quotedValue( sldStyle ) ) + .arg( useAsDefault ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) + .arg( QgsMssqlProvider::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.username() ) ) + .arg( uiFileColumn ) + .arg( uiFileValue ); const QString checkQuery = QStringLiteral( "SELECT styleName" - " FROM layer_styles" - " WHERE f_table_catalog=%1" - " AND f_table_schema=%2" - " AND f_table_name=%3" - " AND f_geometry_column=%4" - " AND styleName=%5" ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) - .arg( QgsMssqlProvider::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ); + " FROM layer_styles" + " WHERE f_table_catalog=%1" + " AND f_table_schema=%2" + " AND f_table_name=%3" + " AND f_geometry_column=%4" + " AND styleName=%5" ) + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) + .arg( QgsMssqlProvider::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ); if ( !LoggedExecMetadata( query, checkQuery, uri ) ) { @@ -2752,29 +2671,29 @@ bool QgsMssqlProviderMetadata::saveStyle( const QString &uri, " AND f_table_name=%8" " AND f_geometry_column=%9" " AND styleName=%10" ) - .arg( useAsDefault ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) - .arg( QgsMssqlProvider::quotedValue( qmlStyle ) ) - .arg( QgsMssqlProvider::quotedValue( sldStyle ) ) - .arg( QgsMssqlProvider::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.username() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) - .arg( QgsMssqlProvider::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ); + .arg( useAsDefault ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) + .arg( QgsMssqlProvider::quotedValue( qmlStyle ) ) + .arg( QgsMssqlProvider::quotedValue( sldStyle ) ) + .arg( QgsMssqlProvider::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.username() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ) + .arg( QgsMssqlProvider::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ); } if ( useAsDefault ) { const QString removeDefaultSql = QString( "UPDATE layer_styles " - " SET useAsDefault=0" - " WHERE f_table_catalog=%1" - " AND f_table_schema=%2" - " AND f_table_name=%3" - " AND f_geometry_column=%4" ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); + " SET useAsDefault=0" + " WHERE f_table_catalog=%1" + " AND f_table_schema=%2" + " AND f_table_name=%3" + " AND f_geometry_column=%4" ) + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); sql = QStringLiteral( "%1; %2;" ).arg( removeDefaultSql, sql ); } @@ -2840,10 +2759,10 @@ QString QgsMssqlProviderMetadata::loadStoredStyle( const QString &uri, QString & " AND f_table_name=%3" " AND f_geometry_column=%4" " ORDER BY useAsDefault desc" ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); if ( !LoggedExecMetadata( query, selectQmlQuery, uri ) ) { @@ -2862,11 +2781,7 @@ QString QgsMssqlProviderMetadata::loadStoredStyle( const QString &uri, QString & return QString(); } -int QgsMssqlProviderMetadata::listStyles( const QString &uri, - QStringList &ids, - QStringList &names, - QStringList &descriptions, - QString &errCause ) +int QgsMssqlProviderMetadata::listStyles( const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause ) { const QgsDataSourceUri dsUri( uri ); // connect to database @@ -2882,7 +2797,7 @@ int QgsMssqlProviderMetadata::listStyles( const QString &uri, QSqlQuery query = QSqlQuery( db->db() ); query.setForwardOnly( true ); - QString sql { QStringLiteral( "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME= N'layer_styles'" ) }; + QString sql { QStringLiteral( "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME= N'layer_styles'" ) }; // check if layer_styles table already exist if ( !LoggedExecMetadata( query, sql, uri ) ) @@ -2899,16 +2814,16 @@ int QgsMssqlProviderMetadata::listStyles( const QString &uri, } const QString selectRelatedQuery = QString( "SELECT id,styleName,description" - " FROM layer_styles " - " WHERE f_table_catalog=%1" - " AND f_table_schema=%2" - " AND f_table_name=%3" - " AND f_geometry_column=%4" - " ORDER BY useasdefault DESC, update_time DESC" ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); + " FROM layer_styles " + " WHERE f_table_catalog=%1" + " AND f_table_schema=%2" + " AND f_table_name=%3" + " AND f_geometry_column=%4" + " ORDER BY useasdefault DESC, update_time DESC" ) + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); bool queryOk = LoggedExecMetadata( query, selectRelatedQuery, uri ); @@ -2927,13 +2842,13 @@ int QgsMssqlProviderMetadata::listStyles( const QString &uri, numberOfRelatedStyles = numberOfRelatedStyles + 1; } const QString selectOthersQuery = QString( "SELECT id,styleName,description" - " FROM layer_styles " - " WHERE NOT (f_table_catalog=%1 AND f_table_schema=%2 AND f_table_name=%3 AND f_geometry_column=%4)" - " ORDER BY update_time DESC" ) - .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) - .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); + " FROM layer_styles " + " WHERE NOT (f_table_catalog=%1 AND f_table_schema=%2 AND f_table_name=%3 AND f_geometry_column=%4)" + " ORDER BY update_time DESC" ) + .arg( QgsMssqlProvider::quotedValue( dsUri.database() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.schema() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.table() ) ) + .arg( QgsMssqlProvider::quotedValue( dsUri.geometryColumn() ) ); QgsDebugMsgLevel( selectOthersQuery, 2 ); queryOk = LoggedExecMetadata( query, selectOthersQuery, uri ); @@ -2951,8 +2866,8 @@ int QgsMssqlProviderMetadata::listStyles( const QString &uri, return numberOfRelatedStyles; } -QgsMssqlProviderMetadata::QgsMssqlProviderMetadata(): - QgsProviderMetadata( QgsMssqlProvider::MSSQL_PROVIDER_KEY, QgsMssqlProvider::MSSQL_PROVIDER_DESCRIPTION ) +QgsMssqlProviderMetadata::QgsMssqlProviderMetadata() + : QgsProviderMetadata( QgsMssqlProvider::MSSQL_PROVIDER_KEY, QgsMssqlProvider::MSSQL_PROVIDER_DESCRIPTION ) { } @@ -2978,7 +2893,7 @@ QString QgsMssqlProviderMetadata::getStyleById( const QString &uri, const QStrin QSqlQuery query = QSqlQuery( db->db() ); query.setForwardOnly( true ); - const QString sql { QStringLiteral( "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME= N'layer_styles'" ) }; + const QString sql { QStringLiteral( "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME= N'layer_styles'" ) }; if ( !LoggedExecMetadata( query, sql, uri ) ) { @@ -3022,51 +2937,50 @@ QVariantMap QgsMssqlProviderMetadata::decodeUri( const QString &uri ) const const QgsDataSourceUri dsUri { uri }; QVariantMap uriParts; - if ( ! dsUri.database().isEmpty() ) - uriParts[ QStringLiteral( "dbname" ) ] = dsUri.database(); - if ( ! dsUri.host().isEmpty() ) - uriParts[ QStringLiteral( "host" ) ] = dsUri.host(); - if ( ! dsUri.port().isEmpty() ) - uriParts[ QStringLiteral( "port" ) ] = dsUri.port(); - if ( ! dsUri.service().isEmpty() ) - uriParts[ QStringLiteral( "service" ) ] = dsUri.service(); - if ( ! dsUri.username().isEmpty() ) - uriParts[ QStringLiteral( "username" ) ] = dsUri.username(); - if ( ! dsUri.password().isEmpty() ) - uriParts[ QStringLiteral( "password" ) ] = dsUri.password(); + if ( !dsUri.database().isEmpty() ) + uriParts[QStringLiteral( "dbname" )] = dsUri.database(); + if ( !dsUri.host().isEmpty() ) + uriParts[QStringLiteral( "host" )] = dsUri.host(); + if ( !dsUri.port().isEmpty() ) + uriParts[QStringLiteral( "port" )] = dsUri.port(); + if ( !dsUri.service().isEmpty() ) + uriParts[QStringLiteral( "service" )] = dsUri.service(); + if ( !dsUri.username().isEmpty() ) + uriParts[QStringLiteral( "username" )] = dsUri.username(); + if ( !dsUri.password().isEmpty() ) + uriParts[QStringLiteral( "password" )] = dsUri.password(); // Supported? //if ( ! dsUri.authConfigId().isEmpty() ) // uriParts[ QStringLiteral( "authcfg" ) ] = dsUri.authConfigId(); if ( dsUri.wkbType() != Qgis::WkbType::Unknown ) - uriParts[ QStringLiteral( "type" ) ] = static_cast< quint32>( dsUri.wkbType() ); + uriParts[QStringLiteral( "type" )] = static_cast( dsUri.wkbType() ); // Supported? // uriParts[ QStringLiteral( "selectatid" ) ] = dsUri.selectAtIdDisabled(); - if ( ! dsUri.table().isEmpty() ) - uriParts[ QStringLiteral( "table" ) ] = dsUri.table(); - if ( ! dsUri.schema().isEmpty() ) - uriParts[ QStringLiteral( "schema" ) ] = dsUri.schema(); - if ( ! dsUri.keyColumn().isEmpty() ) - uriParts[ QStringLiteral( "key" ) ] = dsUri.keyColumn(); - if ( ! dsUri.srid().isEmpty() ) - uriParts[ QStringLiteral( "srid" ) ] = dsUri.srid(); + if ( !dsUri.table().isEmpty() ) + uriParts[QStringLiteral( "table" )] = dsUri.table(); + if ( !dsUri.schema().isEmpty() ) + uriParts[QStringLiteral( "schema" )] = dsUri.schema(); + if ( !dsUri.keyColumn().isEmpty() ) + uriParts[QStringLiteral( "key" )] = dsUri.keyColumn(); + if ( !dsUri.srid().isEmpty() ) + uriParts[QStringLiteral( "srid" )] = dsUri.srid(); - uriParts[ QStringLiteral( "estimatedmetadata" ) ] = dsUri.useEstimatedMetadata(); + uriParts[QStringLiteral( "estimatedmetadata" )] = dsUri.useEstimatedMetadata(); // is this supported? // uriParts[ QStringLiteral( "sslmode" ) ] = dsUri.sslMode(); - if ( ! dsUri.sql().isEmpty() ) - uriParts[ QStringLiteral( "sql" ) ] = dsUri.sql(); - if ( ! dsUri.geometryColumn().isEmpty() ) - uriParts[ QStringLiteral( "geometrycolumn" ) ] = dsUri.geometryColumn(); + if ( !dsUri.sql().isEmpty() ) + uriParts[QStringLiteral( "sql" )] = dsUri.sql(); + if ( !dsUri.geometryColumn().isEmpty() ) + uriParts[QStringLiteral( "geometrycolumn" )] = dsUri.geometryColumn(); // From configuration - static const QStringList configurationParameters - { + static const QStringList configurationParameters { QStringLiteral( "geometryColumnsOnly" ), QStringLiteral( "allowGeometrylessTables" ), QStringLiteral( "saveUsername" ), @@ -3081,7 +2995,7 @@ QVariantMap QgsMssqlProviderMetadata::decodeUri( const QString &uri ) const { if ( dsUri.hasParam( configParam ) ) { - uriParts[ configParam ] = dsUri.param( configParam ); + uriParts[configParam] = dsUri.param( configParam ); } } @@ -3155,7 +3069,6 @@ QList QgsMssqlProviderMetadata::supportedLayerTypes() const QString QgsMssqlProvider::typeFromMetadata( const QString &typeName, int numCoords ) { - QString type { typeName }; const bool hasM { typeName.endsWith( 'M', Qt::CaseInsensitive ) }; if ( numCoords == 4 ) @@ -3168,7 +3081,7 @@ QString QgsMssqlProvider::typeFromMetadata( const QString &typeName, int numCoor } else if ( numCoords == 3 ) { - if ( ! hasM ) + if ( !hasM ) { type.append( QStringLiteral( "Z" ) ); } @@ -3178,9 +3091,9 @@ QString QgsMssqlProvider::typeFromMetadata( const QString &typeName, int numCoor bool QgsMssqlProviderMetadata::execLogged( QSqlQuery &qry, const QString &sql, const QString &uri, const QString &queryOrigin ) const { - QgsDatabaseQueryLogWrapper logWrapper{ sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProviderMetadata" ), queryOrigin }; + QgsDatabaseQueryLogWrapper logWrapper { sql, uri, QStringLiteral( "mssql" ), QStringLiteral( "QgsMssqlProviderMetadata" ), queryOrigin }; const bool res { qry.exec( sql ) }; - if ( ! res ) + if ( !res ) { logWrapper.setError( qry.lastError().text() ); } @@ -3227,7 +3140,7 @@ QVariant QgsMssqlSharedData::removeFid( QgsFeatureId fid ) { const QMutexLocker locker( &mMutex ); - const QVariantList v = mFidToKey[ fid ]; + const QVariantList v = mFidToKey[fid]; mFidToKey.remove( fid ); mKeyToFid.remove( v ); return v; @@ -3301,7 +3214,8 @@ QString QgsMssqlProvider::whereClauseFid( QgsFeatureId featureId ) /* static */ QStringList QgsMssqlProvider::parseUriKey( const QString &key ) { - if ( key.isEmpty() ) return QStringList(); + if ( key.isEmpty() ) + return QStringList(); QStringList cols; @@ -3376,7 +3290,6 @@ bool QgsMssqlProvider::getExtentFromGeometryColumns( QgsRectangle &extent ) cons } return false; - } bool QgsMssqlProvider::getPrimaryKeyFromGeometryColumns( QStringList &primaryKeys ) diff --git a/src/providers/mssql/qgsmssqlprovider.h b/src/providers/mssql/qgsmssqlprovider.h index 0d9f313e3f9b..db7331d37f88 100644 --- a/src/providers/mssql/qgsmssqlprovider.h +++ b/src/providers/mssql/qgsmssqlprovider.h @@ -56,17 +56,15 @@ enum QgsMssqlPrimaryKeyType * \class QgsMssqlProvider * \brief Data provider for mssql server. */ -class QgsMssqlProvider final: public QgsVectorDataProvider +class QgsMssqlProvider final : public QgsVectorDataProvider { Q_OBJECT public: - static const QString MSSQL_PROVIDER_KEY; static const QString MSSQL_PROVIDER_DESCRIPTION; - explicit QgsMssqlProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, - Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); + explicit QgsMssqlProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); ~QgsMssqlProvider() override; @@ -80,8 +78,7 @@ class QgsMssqlProvider final: public QgsVectorDataProvider QVariant minimumValue( int index ) const override; QVariant maximumValue( int index ) const override; QSet uniqueValues( int index, int limit = -1 ) const override; - QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1, - QgsFeedback *feedback = nullptr ) const override; + QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1, QgsFeedback *feedback = nullptr ) const override; QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) const override; @@ -178,7 +175,6 @@ class QgsMssqlProvider final: public QgsVectorDataProvider void loadMetadata(); private: - bool execLogged( QSqlQuery &qry, const QString &sql, const QString &queryOrigin = QString() ) const; bool execPreparedLogged( QSqlQuery &qry, const QString &queryOrigin = QString() ) const; @@ -293,12 +289,12 @@ class QgsMssqlSharedData protected: QMutex mMutex; //!< Access to all data members is guarded by the mutex - QgsFeatureId mFidCounter = 0; // next feature id if map is used - QMap mKeyToFid; // map key values to feature id - QMap mFidToKey; // map feature back to fea + QgsFeatureId mFidCounter = 0; // next feature id if map is used + QMap mKeyToFid; // map key values to feature id + QMap mFidToKey; // map feature back to fea }; -class QgsMssqlProviderMetadata final: public QgsProviderMetadata +class QgsMssqlProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: @@ -309,9 +305,7 @@ class QgsMssqlProviderMetadata final: public QgsProviderMetadata QString loadStyle( const QString &uri, QString &errCause ) override; QString loadStoredStyle( const QString &uri, QString &styleName, QString &errCause ) override; bool styleExists( const QString &uri, const QString &styleId, QString &errorCause ) override; - bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, - const QString &styleName, const QString &styleDescription, - const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; + bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; Qgis::VectorExportResult createEmptyLayer( const QString &uri, @@ -321,9 +315,10 @@ class QgsMssqlProviderMetadata final: public QgsProviderMetadata bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, - const QMap *options ) override; + const QMap *options + ) override; QgsMssqlProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; - virtual QList< QgsDataItemProvider * > dataItemProviders() const override; + virtual QList dataItemProviders() const override; QgsTransaction *createTransaction( const QString &connString ) override; // Connections API @@ -336,13 +331,11 @@ class QgsMssqlProviderMetadata final: public QgsProviderMetadata // Data source URI API QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; private: - bool execLogged( QSqlQuery &qry, const QString &sql, const QString &uri, const QString &queryOrigin = QString() ) const; - }; #endif // QGSMSSQLPROVIDER_H diff --git a/src/providers/mssql/qgsmssqlproviderconnection.cpp b/src/providers/mssql/qgsmssqlproviderconnection.cpp index 4ca5f00347c4..89950f8c7c62 100644 --- a/src/providers/mssql/qgsmssqlproviderconnection.cpp +++ b/src/providers/mssql/qgsmssqlproviderconnection.cpp @@ -33,8 +33,7 @@ #include -const QStringList QgsMssqlProviderConnection::EXTRA_CONNECTION_PARAMETERS -{ +const QStringList QgsMssqlProviderConnection::EXTRA_CONNECTION_PARAMETERS { QStringLiteral( "geometryColumnsOnly" ), QStringLiteral( "allowGeometrylessTables" ), QStringLiteral( "disableInvalidGeometryHandling" ), @@ -51,8 +50,8 @@ QgsMssqlProviderConnection::QgsMssqlProviderConnection( const QString &name ) setDefaultCapabilities(); } -QgsMssqlProviderConnection::QgsMssqlProviderConnection( const QString &uri, const QVariantMap &configuration ): - QgsAbstractDatabaseProviderConnection( QString(), configuration ) +QgsMssqlProviderConnection::QgsMssqlProviderConnection( const QString &uri, const QVariantMap &configuration ) + : QgsAbstractDatabaseProviderConnection( QString(), configuration ) { mProviderKey = QStringLiteral( "mssql" ); // Additional connection information @@ -61,8 +60,7 @@ QgsMssqlProviderConnection::QgsMssqlProviderConnection( const QString &uri, cons if ( inputUri.hasParam( QStringLiteral( "estimatedMetadata" ) ) ) { - currentUri.setUseEstimatedMetadata( inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == QStringLiteral( "true" ) - || inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == '1' ); + currentUri.setUseEstimatedMetadata( inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == QStringLiteral( "true" ) || inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == '1' ); } for ( const auto ¶m : EXTRA_CONNECTION_PARAMETERS ) @@ -84,8 +82,7 @@ void QgsMssqlProviderConnection::setDefaultCapabilities() { // TODO: we might check at this point if the user actually has the privileges and return // properly filtered capabilities instead of all of them - mCapabilities = - { + mCapabilities = { Capability::DropVectorTable, Capability::CreateVectorTable, Capability::DropSchema, @@ -99,14 +96,12 @@ void QgsMssqlProviderConnection::setDefaultCapabilities() Capability::DeleteFieldCascade, Capability::AddField }; - mGeometryColumnCapabilities = - { + mGeometryColumnCapabilities = { GeometryColumnCapability::Z, GeometryColumnCapability::M, GeometryColumnCapability::Curves }; - mSqlLayerDefinitionCapabilities = - { + mSqlLayerDefinitionCapabilities = { Qgis::SqlLayerDefinitionCapability::SubsetStringFilter, Qgis::SqlLayerDefinitionCapability::PrimaryKeys, Qgis::SqlLayerDefinitionCapability::GeometryColumn, @@ -142,47 +137,36 @@ void QgsMssqlProviderConnection::dropTablePrivate( const QString &schema, const DELETE FROM geometry_columns WHERE f_table_schema = @schema AND f_table_name = @table )raw" ) - .arg( QgsMssqlProvider::quotedValue( QStringLiteral( "master" ) ), // in my testing docker, it is 'master' instead of QgsMssqlProvider::quotedValue( QgsDataSourceUri( uri() ).database() ), - QgsMssqlProvider::quotedValue( name ), - QgsMssqlProvider::quotedValue( schema ), - QgsMssqlProvider::quotedIdentifier( name ), - QgsMssqlProvider::quotedIdentifier( schema ) ) }; + .arg( QgsMssqlProvider::quotedValue( QStringLiteral( "master" ) ), // in my testing docker, it is 'master' instead of QgsMssqlProvider::quotedValue( QgsDataSourceUri( uri() ).database() ), + QgsMssqlProvider::quotedValue( name ), QgsMssqlProvider::quotedValue( schema ), QgsMssqlProvider::quotedIdentifier( name ), QgsMssqlProvider::quotedIdentifier( schema ) ) }; executeSqlPrivate( sql ); } -void QgsMssqlProviderConnection::createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - const QMap *options ) const +void QgsMssqlProviderConnection::createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const { - checkCapability( Capability::CreateVectorTable ); QgsDataSourceUri newUri { uri() }; newUri.setSchema( schema ); newUri.setTable( name ); // Set geometry column if it's not aspatial - if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) + if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) { newUri.setGeometryColumn( options->value( QStringLiteral( "geometryColumn" ), QStringLiteral( "geom" ) ).toString() ); } QMap map; QString errCause; const Qgis::VectorExportResult res = QgsMssqlProvider::createEmptyLayer( - newUri.uri(), - fields, - wkbType, - srs, - overwrite, - &map, - &errCause, - options - ); + newUri.uri(), + fields, + wkbType, + srs, + overwrite, + &map, + &errCause, + options + ); if ( res != Qgis::VectorExportResult::Success ) { throw QgsProviderConnectionException( QObject::tr( "An error occurred while creating the vector layer: %1" ).arg( errCause ) ); @@ -209,11 +193,10 @@ void QgsMssqlProviderConnection::createSchema( const QString &schemaName ) const { checkCapability( Capability::CreateSchema ); executeSqlPrivate( QStringLiteral( "CREATE SCHEMA %1" ) - .arg( QgsMssqlProvider::quotedIdentifier( schemaName ) ) ); - + .arg( QgsMssqlProvider::quotedIdentifier( schemaName ) ) ); } -void QgsMssqlProviderConnection::dropSchema( const QString &schemaName, bool force ) const +void QgsMssqlProviderConnection::dropSchema( const QString &schemaName, bool force ) const { checkCapability( Capability::DropSchema ); // We need to delete all tables first! @@ -228,7 +211,7 @@ void QgsMssqlProviderConnection::dropSchema( const QString &schemaName, bool fo } } executeSqlPrivate( QStringLiteral( "DROP SCHEMA %1" ) - .arg( QgsMssqlProvider::quotedIdentifier( schemaName ) ) ); + .arg( QgsMssqlProvider::quotedIdentifier( schemaName ) ) ); } QgsAbstractDatabaseProviderConnection::QueryResult QgsMssqlProviderConnection::execSql( const QString &sql, QgsFeedback *feedback ) const @@ -252,11 +235,10 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsMssqlProviderConnection::e if ( !db->isValid() ) { throw QgsProviderConnectionException( QObject::tr( "Connection to %1 failed: %2" ) - .arg( uri(), db->errorText() ) ); + .arg( uri(), db->errorText() ) ); } else { - if ( feedback && feedback->isCanceled() ) { return QgsAbstractDatabaseProviderConnection::QueryResult(); @@ -271,13 +253,12 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsMssqlProviderConnection::e const std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); - if ( ! q->exec( sql ) ) + if ( !q->exec( sql ) ) { const QString errorMessage { q->lastError().text() }; logWrapper.setError( errorMessage ); throw QgsProviderConnectionException( QObject::tr( "SQL error: %1 \n %2" ) - .arg( sql, errorMessage ) ); - + .arg( sql, errorMessage ) ); } if ( q->isActive() ) @@ -294,13 +275,12 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsMssqlProviderConnection::e } return results; } - } return QgsAbstractDatabaseProviderConnection::QueryResult(); } -QgssMssqlProviderResultIterator::QgssMssqlProviderResultIterator( bool resolveTypes, int columnCount, std::unique_ptr query ) +QgssMssqlProviderResultIterator::QgssMssqlProviderResultIterator( bool resolveTypes, int columnCount, std::unique_ptr query ) : mResolveTypes( resolveTypes ) , mColumnCount( columnCount ) , mQuery( std::move( query ) ) @@ -318,7 +298,7 @@ QVariantList QgssMssqlProviderResultIterator::nextRowPrivate() bool QgssMssqlProviderResultIterator::hasNextRowPrivate() const { - return ! mNextRow.isEmpty(); + return !mNextRow.isEmpty(); } QVariantList QgssMssqlProviderResultIterator::nextRowInternal() @@ -359,14 +339,10 @@ QList QgsMssqlProviderConnection::tab const QgsDataSourceUri dsUri { uri() }; // Defaults to false - const bool useGeometryColumnsOnly { dsUri.hasParam( QStringLiteral( "geometryColumnsOnly" ) ) - &&( dsUri.param( QStringLiteral( "geometryColumnsOnly" ) ) == QStringLiteral( "true" ) - || dsUri.param( QStringLiteral( "geometryColumnsOnly" ) ) == '1' ) }; + const bool useGeometryColumnsOnly { dsUri.hasParam( QStringLiteral( "geometryColumnsOnly" ) ) && ( dsUri.param( QStringLiteral( "geometryColumnsOnly" ) ) == QStringLiteral( "true" ) || dsUri.param( QStringLiteral( "geometryColumnsOnly" ) ) == '1' ) }; // Defaults to true - const bool useEstimatedMetadata { ! dsUri.hasParam( QStringLiteral( "estimatedMetadata" ) ) - || ( dsUri.param( QStringLiteral( "estimatedMetadata" ) ) == QStringLiteral( "true" ) - || dsUri.param( QStringLiteral( "estimatedMetadata" ) ) == '1' ) }; + const bool useEstimatedMetadata { !dsUri.hasParam( QStringLiteral( "estimatedMetadata" ) ) || ( dsUri.param( QStringLiteral( "estimatedMetadata" ) ) == QStringLiteral( "true" ) || dsUri.param( QStringLiteral( "estimatedMetadata" ) ) == '1' ) }; // Defaults to true because we want to list all tables if flags are not set bool allowGeometrylessTables; @@ -384,7 +360,7 @@ QList QgsMssqlProviderConnection::tab if ( useGeometryColumnsOnly ) { query += QStringLiteral( "f_table_schema, f_table_name, f_geometry_column, srid, geometry_type, 0 FROM geometry_columns WHERE f_table_schema = N%1" ) - .arg( QgsMssqlProvider::quotedValue( schema ) ); + .arg( QgsMssqlProvider::quotedValue( schema ) ); } else { @@ -402,7 +378,7 @@ QList QgsMssqlProviderConnection::tab AND (sys.types.name = 'geometry' OR sys.types.name = 'geography') AND (sys.objects.type = 'U' OR sys.objects.type = 'V') )raw" ) - .arg( QgsMssqlProvider::quotedValue( schema ) ); + .arg( QgsMssqlProvider::quotedValue( schema ) ); } if ( allowGeometrylessTables ) @@ -422,7 +398,7 @@ QList QgsMssqlProviderConnection::tab AND sys.objects.object_id = sc1.object_id ) AND (sys.objects.type = 'U' OR sys.objects.type = 'V') )raw" ) - .arg( QgsMssqlProvider::quotedValue( schema ) ); + .arg( QgsMssqlProvider::quotedValue( schema ) ); } const QList results { executeSqlPrivate( query, false ).rows() }; @@ -431,7 +407,7 @@ QList QgsMssqlProviderConnection::tab if ( feedback && feedback->isCanceled() ) break; - Q_ASSERT( row.count( ) == 6 ); + Q_ASSERT( row.count() == 6 ); QgsMssqlProviderConnection::TableProperty table; table.setSchema( row[0].toString() ); table.setTableName( row[1].toString() ); @@ -443,11 +419,10 @@ QList QgsMssqlProviderConnection::tab int geomColCount { 0 }; - if ( ! table.geometryColumn().isEmpty() ) + if ( !table.geometryColumn().isEmpty() ) { // Fetch geom cols - const QString geomColSql - { + const QString geomColSql { QStringLiteral( R"raw( SELECT %4 UPPER( %1.STGeometryType()), %1.STSrid, %1.HasZ, %1.HasM @@ -455,10 +430,8 @@ QList QgsMssqlProviderConnection::tab WHERE %1 IS NOT NULL GROUP BY %1.STGeometryType(), %1.STSrid, %1.HasZ, %1.HasM )raw" ) - .arg( QgsMssqlProvider::quotedIdentifier( table.geometryColumn() ), - QgsMssqlProvider::quotedIdentifier( table.schema() ), - QgsMssqlProvider::quotedIdentifier( table.tableName() ), - useEstimatedMetadata ? "TOP 1" : "" ) }; + .arg( QgsMssqlProvider::quotedIdentifier( table.geometryColumn() ), QgsMssqlProvider::quotedIdentifier( table.schema() ), QgsMssqlProvider::quotedIdentifier( table.tableName() ), useEstimatedMetadata ? "TOP 1" : "" ) + }; // This may fail for invalid geometries try @@ -475,27 +448,19 @@ QList QgsMssqlProviderConnection::tab { geometryType = QgsWkbTypes::addM( geometryType ); } - table.addGeometryColumnType( geometryType, - QgsCoordinateReferenceSystem::fromEpsgId( row[1].toLongLong( ) ) ); + table.addGeometryColumnType( geometryType, QgsCoordinateReferenceSystem::fromEpsgId( row[1].toLongLong() ) ); ++geomColCount; } } catch ( QgsProviderConnectionException &ex ) { - QgsMessageLog::logMessage( QObject::tr( "Error retrieving geometry type for '%1' on table %2.%3:\n%4" ) - .arg( table.geometryColumn(), - QgsMssqlProvider::quotedIdentifier( table.schema() ), - QgsMssqlProvider::quotedIdentifier( table.tableName() ), - ex.what() ), - QStringLiteral( "MSSQL" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( QObject::tr( "Error retrieving geometry type for '%1' on table %2.%3:\n%4" ).arg( table.geometryColumn(), QgsMssqlProvider::quotedIdentifier( table.schema() ), QgsMssqlProvider::quotedIdentifier( table.tableName() ), ex.what() ), QStringLiteral( "MSSQL" ), Qgis::MessageLevel::Warning ); } - } else { // Add an invalid column - table.addGeometryColumnType( Qgis::WkbType::NoGeometry, - QgsCoordinateReferenceSystem() ); + table.addGeometryColumnType( Qgis::WkbType::NoGeometry, QgsCoordinateReferenceSystem() ); table.setFlag( QgsMssqlProviderConnection::TableFlag::Aspatial ); } @@ -505,7 +470,7 @@ QList QgsMssqlProviderConnection::tab return tables; } -QStringList QgsMssqlProviderConnection::schemas( ) const +QStringList QgsMssqlProviderConnection::schemas() const { checkCapability( Capability::Schemas ); QStringList schemas; @@ -513,8 +478,7 @@ QStringList QgsMssqlProviderConnection::schemas( ) const const QgsDataSourceUri connUri( uri() ); const QgsDataSourceUri dsUri { uri() }; - const QString sql - { + const QString sql { QStringLiteral( R"raw( SELECT s.name AS schema_name, @@ -525,7 +489,8 @@ QStringList QgsMssqlProviderConnection::schemas( ) const ON u.uid = s.principal_id WHERE u.issqluser = 1 AND u.name NOT IN ('sys', 'guest', 'INFORMATION_SCHEMA') - )raw" ) + )raw" + ) }; const QList result { executeSqlPrivate( sql, false ).rows() }; @@ -572,8 +537,7 @@ void QgsMssqlProviderConnection::store( const QString &name ) const { if ( dsUri.hasParam( param ) ) { - settings.setValue( param, dsUri.param( param ) == QStringLiteral( "true" ) - || dsUri.param( param ) == '1' ); + settings.setValue( param, dsUri.param( param ) == QStringLiteral( "true" ) || dsUri.param( param ) == '1' ); } } @@ -581,8 +545,7 @@ void QgsMssqlProviderConnection::store( const QString &name ) const const auto config { configuration().keys() }; for ( const auto &p : config ) { - settings.setValue( p, configuration().value( p ) == QStringLiteral( "true" ) - || configuration().value( p ) == '1' ); + settings.setValue( p, configuration().value( p ) == QStringLiteral( "true" ) || configuration().value( p ) == '1' ); } settings.endGroup(); diff --git a/src/providers/mssql/qgsmssqlproviderconnection.h b/src/providers/mssql/qgsmssqlproviderconnection.h index 02ad8ab34ae7..a88fd5b63e57 100644 --- a/src/providers/mssql/qgsmssqlproviderconnection.h +++ b/src/providers/mssql/qgsmssqlproviderconnection.h @@ -22,13 +22,11 @@ #include -struct QgssMssqlProviderResultIterator: public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator +struct QgssMssqlProviderResultIterator : public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator { - QgssMssqlProviderResultIterator( bool resolveTypes, int columnCount, std::unique_ptr query ); private: - bool mResolveTypes = true; int mColumnCount = 0; std::unique_ptr mQuery; @@ -48,29 +46,21 @@ class QgsMssqlProviderConnection : public QgsAbstractDatabaseProviderConnection { public: - QgsMssqlProviderConnection( const QString &name ); QgsMssqlProviderConnection( const QString &uri, const QVariantMap &configuration ); // QgsAbstractProviderConnection interface public: - - void createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, bool overwrite, - const QMap *options ) const override; + void createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const override; QString tableUri( const QString &schema, const QString &name ) const override; void dropVectorTable( const QString &schema, const QString &name ) const override; void createSchema( const QString &name ) const override; void dropSchema( const QString &name, bool force = false ) const override; QgsAbstractDatabaseProviderConnection::QueryResult execSql( const QString &sql, QgsFeedback *feedback ) const override; - QList tables( const QString &schema, - const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; - QStringList schemas( ) const override; + QList tables( const QString &schema, const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; + QStringList schemas() const override; void store( const QString &name ) const override; void remove( const QString &name ) const override; QIcon icon() const override; @@ -78,16 +68,13 @@ class QgsMssqlProviderConnection : public QgsAbstractDatabaseProviderConnection QgsProviderSqlQueryBuilder *queryBuilder() const override; private: - QgsAbstractDatabaseProviderConnection::QueryResult executeSqlPrivate( const QString &sql, bool resolveTypes = true, QgsFeedback *feedback = nullptr ) const; void setDefaultCapabilities(); void dropTablePrivate( const QString &schema, const QString &name ) const; void renameTablePrivate( const QString &schema, const QString &name, const QString &newName ) const; static const QStringList EXTRA_CONNECTION_PARAMETERS; - }; - #endif // QGSMSSQLPROVIDERCONNECTION_H diff --git a/src/providers/mssql/qgsmssqlprovidergui.cpp b/src/providers/mssql/qgsmssqlprovidergui.cpp index ef931f1d1af3..139cb2984047 100644 --- a/src/providers/mssql/qgsmssqlprovidergui.cpp +++ b/src/providers/mssql/qgsmssqlprovidergui.cpp @@ -26,7 +26,6 @@ class QgsMssqlSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "mssql" ); } QString text() const override { return QObject::tr( "MS SQL Server" ); } int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 30; } @@ -38,7 +37,7 @@ class QgsMssqlSourceSelectProvider : public QgsSourceSelectProvider }; -class QgsMssqlProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsMssqlProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsMssqlProviderGuiMetadata() diff --git a/src/providers/mssql/qgsmssqlsourceselect.cpp b/src/providers/mssql/qgsmssqlsourceselect.cpp index 465d51e28bed..fbc7cb584f4d 100644 --- a/src/providers/mssql/qgsmssqlsourceselect.cpp +++ b/src/providers/mssql/qgsmssqlsourceselect.cpp @@ -85,7 +85,7 @@ QWidget *QgsMssqlSourceSelectDelegate::createEditor( QWidget *parent, const QSty Qgis::WkbType::NoGeometry } ) { - cb->addItem( QgsIconUtils::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), static_cast< quint32>( type ) ); + cb->addItem( QgsIconUtils::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), static_cast( type ) ); } cb->setCurrentIndex( cb->findData( index.data( Qt::UserRole + 2 ).toInt() ) ); return cb; @@ -122,11 +122,11 @@ void QgsMssqlSourceSelectDelegate::setModelData( QWidget *editor, QAbstractItemM { if ( index.column() == QgsMssqlTableModel::DbtmType ) { - const Qgis::WkbType type = static_cast< Qgis::WkbType >( cb->currentData().toInt() ); + const Qgis::WkbType type = static_cast( cb->currentData().toInt() ); model->setData( index, QgsIconUtils::iconForWkbType( type ), Qt::DecorationRole ); model->setData( index, type != Qgis::WkbType::Unknown ? QgsWkbTypes::translatedDisplayString( type ) : tr( "Select…" ) ); - model->setData( index, static_cast< quint32>( type ), Qt::UserRole + 2 ); + model->setData( index, static_cast( type ), Qt::UserRole + 2 ); } else if ( index.column() == QgsMssqlTableModel::DbtmPkCol ) { @@ -198,7 +198,7 @@ void QgsMssqlSourceSelect::btnNew_clicked() void QgsMssqlSourceSelect::btnDelete_clicked() { const QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ) - .arg( cmbConnections->currentText() ); + .arg( cmbConnections->currentText() ); if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) ) return; @@ -233,8 +233,7 @@ void QgsMssqlSourceSelect::btnSave_clicked() void QgsMssqlSourceSelect::btnLoad_clicked() { - const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -402,8 +401,7 @@ void QgsMssqlSourceSelect::btnConnect_clicked() if ( !db->isValid() ) { // Let user know we couldn't initialize the MSSQL provider - QMessageBox::warning( this, - tr( "MS SQL Server Provider" ), db->errorText() ); + QMessageBox::warning( this, tr( "MS SQL Server Provider" ), db->errorText() ); return; } @@ -417,10 +415,7 @@ void QgsMssqlSourceSelect::btnConnect_clicked() if ( !q.exec( testquery ) || !q.first() || q.value( 0 ).toInt() == 0 ) { QMessageBox::StandardButtons reply; - reply = QMessageBox::question( this, QStringLiteral( "Scan full database?" ), - QStringLiteral( "No geometry_columns table found. \nWould you like to search full database (might be slower)? " ), - QMessageBox::Yes | QMessageBox::No - ); + reply = QMessageBox::question( this, QStringLiteral( "Scan full database?" ), QStringLiteral( "No geometry_columns table found. \nWould you like to search full database (might be slower)? " ), QMessageBox::Yes | QMessageBox::No ); if ( reply == QMessageBox::Yes ) useGeometryColumns = false; else @@ -436,7 +431,7 @@ void QgsMssqlSourceSelect::btnConnect_clicked() // issue the sql query q = QSqlQuery( db->db() ); q.setForwardOnly( true ); - ( void )q.exec( query ); + ( void ) q.exec( query ); if ( q.isActive() ) { @@ -450,7 +445,7 @@ void QgsMssqlSourceSelect::btnConnect_clicked() layer.isView = q.value( 5 ).toBool(); layer.pkCols = QStringList(); //TODO layer.isGeography = false; - const int dimensions { q.value( 6 ).toInt( ) }; + const int dimensions { q.value( 6 ).toInt() }; layer.type = QgsMssqlProvider::typeFromMetadata( q.value( 4 ).toString().toUpper(), dimensions ); QString type = layer.type; @@ -485,7 +480,8 @@ void QgsMssqlSourceSelect::btnConnect_clicked() for ( int i = 0; i < numTopLevelItems; ++i ) { mTablesTreeView->expand( proxyModel()->mapFromSource( - mTableModel->indexFromItem( mTableModel->invisibleRootItem()->child( i ) ) ) ); + mTableModel->indexFromItem( mTableModel->invisibleRootItem()->child( i ) ) + ) ); } } } @@ -493,8 +489,7 @@ void QgsMssqlSourceSelect::btnConnect_clicked() { QApplication::restoreOverrideCursor(); // Let user know we couldn't retrieve tables from the MSSQL provider - QMessageBox::warning( this, - tr( "MS SQL Server Provider" ), q.lastError().text() ); + QMessageBox::warning( this, tr( "MS SQL Server Provider" ), q.lastError().text() ); return; } @@ -552,7 +547,7 @@ void QgsMssqlSourceSelect::setSql( const QModelIndex &index ) const QString tableName = mTableModel->itemFromIndex( index.sibling( index.row(), QgsMssqlTableModel::DbtmTable ) )->text(); const bool disableInvalidGeometryHandling = QgsMssqlConnection::isInvalidGeometryHandlingDisabled( cmbConnections->currentText() ); const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; - std::unique_ptr< QgsVectorLayer > vlayer = std::make_unique< QgsVectorLayer>( mTableModel->layerURI( index, mConnInfo, mUseEstimatedMetadata, disableInvalidGeometryHandling ), tableName, QStringLiteral( "mssql" ), options ); + std::unique_ptr vlayer = std::make_unique( mTableModel->layerURI( index, mConnInfo, mUseEstimatedMetadata, disableInvalidGeometryHandling ), tableName, QStringLiteral( "mssql" ), options ); if ( !vlayer->isValid() ) { @@ -574,13 +569,9 @@ void QgsMssqlSourceSelect::addSearchGeometryColumn( const QString &service, cons { mColumnTypeThread = new QgsMssqlGeomColumnTypeThread( service, host, database, username, password, estimateMetadata ); - connect( mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::setLayerType, - this, &QgsMssqlSourceSelect::setLayerType ); - connect( this, &QgsMssqlSourceSelect::addGeometryColumn, - mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::addGeometryColumn ); - connect( mColumnTypeThread, &QThread::finished, - this, &QgsMssqlSourceSelect::columnThreadFinished ); - + connect( mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::setLayerType, this, &QgsMssqlSourceSelect::setLayerType ); + connect( this, &QgsMssqlSourceSelect::addGeometryColumn, mColumnTypeThread, &QgsMssqlGeomColumnTypeThread::addGeometryColumn ); + connect( mColumnTypeThread, &QThread::finished, this, &QgsMssqlSourceSelect::columnThreadFinished ); } emit addGeometryColumn( layerProperty ); diff --git a/src/providers/mssql/qgsmssqlsourceselect.h b/src/providers/mssql/qgsmssqlsourceselect.h index 9a63949888a1..137e1a83e54a 100644 --- a/src/providers/mssql/qgsmssqlsourceselect.h +++ b/src/providers/mssql/qgsmssqlsourceselect.h @@ -47,8 +47,6 @@ class QgsMssqlSourceSelectDelegate : public QItemDelegate }; - - /** * \class QgsMssqlSourceSelect * \brief Dialog to create connections and add tables from MSSQL. @@ -62,7 +60,6 @@ class QgsMssqlSourceSelect : public QgsAbstractDbSourceSelect Q_OBJECT public: - //! static function to delete a connection static void deleteConnection( const QString &key ); @@ -140,7 +137,7 @@ class QgsMssqlSourceSelect : public QgsAbstractDbSourceSelect QStringList mSelectedTables; bool mUseEstimatedMetadata = false; // Storage for the range of layer type icons - QMap > mLayerIcons; + QMap> mLayerIcons; //! Model that acts as datasource for mTableTreeWidget QgsMssqlTableModel *mTableModel = nullptr; @@ -148,7 +145,6 @@ class QgsMssqlSourceSelect : public QgsAbstractDbSourceSelect void finishList(); void showHelp(); - }; #endif // QGSMSSQLSOURCESELECT_H diff --git a/src/providers/mssql/qgsmssqlsqlquerybuilder.h b/src/providers/mssql/qgsmssqlsqlquerybuilder.h index 294c41cf2e33..a8ff23e08e83 100644 --- a/src/providers/mssql/qgsmssqlsqlquerybuilder.h +++ b/src/providers/mssql/qgsmssqlsqlquerybuilder.h @@ -20,9 +20,8 @@ email : nyall dot dawson at gmail dot com #include "qgsprovidersqlquerybuilder.h" -class QgsMsSqlSqlQueryBuilder : public QgsProviderSqlQueryBuilder +class QgsMsSqlSqlQueryBuilder : public QgsProviderSqlQueryBuilder { - public: QString createLimitQueryForTable( const QString &schema, const QString &name, int limit = 10 ) const override; QString quoteIdentifier( const QString &identifier ) const override; diff --git a/src/providers/mssql/qgsmssqltablemodel.cpp b/src/providers/mssql/qgsmssqltablemodel.cpp index 485c2786f529..f4005f4fe119 100644 --- a/src/providers/mssql/qgsmssqltablemodel.cpp +++ b/src/providers/mssql/qgsmssqltablemodel.cpp @@ -25,15 +25,15 @@ QgsMssqlTableModel::QgsMssqlTableModel( QObject *parent ) : QgsAbstractDbTableModel( parent ) { - mColumns << tr( "Schema" ) - << tr( "Table" ) - << tr( "Type" ) - << tr( "Geometry column" ) - << tr( "SRID" ) - << tr( "Primary key column" ) - << tr( "Select at id" ) - << tr( "SQL" ) - << tr( "View" ); + mColumns << tr( "Schema" ) + << tr( "Table" ) + << tr( "Type" ) + << tr( "Geometry column" ) + << tr( "SRID" ) + << tr( "Primary key column" ) + << tr( "Select at id" ) + << tr( "SQL" ) + << tr( "View" ); setHorizontalHeaderLabels( mColumns ); } @@ -71,15 +71,7 @@ bool QgsMssqlTableModel::searchableColumn( int column ) const void QgsMssqlTableModel::addTableEntry( const QgsMssqlLayerProperty &layerProperty ) { - QgsDebugMsgLevel( QStringLiteral( "%1.%2.%3 type=%4 srid=%5 pk=%6 sql=%7 view=%8" ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName, - layerProperty.type, - layerProperty.srid, - layerProperty.pkCols.join( ',' ), - layerProperty.sql, - layerProperty.isView ? "yes" : "no" ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "%1.%2.%3 type=%4 srid=%5 pk=%6 sql=%7 view=%8" ).arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName, layerProperty.type, layerProperty.srid, layerProperty.pkCols.join( ',' ), layerProperty.sql, layerProperty.isView ? "yes" : "no" ), 2 ); // is there already a root item with the given scheme Name? QStandardItem *schemaItem = nullptr; @@ -111,12 +103,9 @@ void QgsMssqlTableModel::addTableEntry( const QgsMssqlLayerProperty &layerProper QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName ); schemaNameItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - QStandardItem *typeItem = new QStandardItem( QgsIconUtils::iconForWkbType( wkbType ), - needToDetect - ? tr( "Detecting…" ) - : QgsWkbTypes::displayString( wkbType ) ); + QStandardItem *typeItem = new QStandardItem( QgsIconUtils::iconForWkbType( wkbType ), needToDetect ? tr( "Detecting…" ) : QgsWkbTypes::displayString( wkbType ) ); typeItem->setData( needToDetect, Qt::UserRole + 1 ); - typeItem->setData( static_cast< quint32>( wkbType ), Qt::UserRole + 2 ); + typeItem->setData( static_cast( wkbType ), Qt::UserRole + 2 ); QStandardItem *tableItem = new QStandardItem( layerProperty.tableName ); QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName ); @@ -165,8 +154,7 @@ void QgsMssqlTableModel::addTableEntry( const QgsMssqlLayerProperty &layerProper childItemList << sqlItem; childItemList << isViewItem; - bool detailsFromThread = needToDetect || - ( wkbType != Qgis::WkbType::NoGeometry && layerProperty.srid.isEmpty() ); + bool detailsFromThread = needToDetect || ( wkbType != Qgis::WkbType::NoGeometry && layerProperty.srid.isEmpty() ); if ( detailsFromThread || pkText == tr( "Select…" ) ) { @@ -289,17 +277,17 @@ void QgsMssqlTableModel::setGeometryTypesForTable( QgsMssqlLayerProperty layerPr if ( row.empty() ) continue; - if ( row[ DbtmTable ]->text() == layerProperty.tableName && row[ DbtmGeomCol ]->text() == layerProperty.geometryColName ) + if ( row[DbtmTable]->text() == layerProperty.tableName && row[DbtmGeomCol]->text() == layerProperty.geometryColName ) { - row[ DbtmSrid ]->setText( layerProperty.srid ); + row[DbtmSrid]->setText( layerProperty.srid ); if ( typeList.isEmpty() ) { - row[ DbtmType ]->setText( tr( "Select…" ) ); - row[ DbtmType ]->setFlags( row[ DbtmType ]->flags() | Qt::ItemIsEditable ); + row[DbtmType]->setText( tr( "Select…" ) ); + row[DbtmType]->setFlags( row[DbtmType]->flags() | Qt::ItemIsEditable ); - row[ DbtmSrid ]->setText( tr( "Enter…" ) ); - row[ DbtmSrid ]->setFlags( row[ DbtmSrid ]->flags() | Qt::ItemIsEditable ); + row[DbtmSrid]->setText( tr( "Enter…" ) ); + row[DbtmSrid]->setFlags( row[DbtmSrid]->flags() | Qt::ItemIsEditable ); const auto constRow = row; for ( QStandardItem *item : constRow ) @@ -312,12 +300,12 @@ void QgsMssqlTableModel::setGeometryTypesForTable( QgsMssqlLayerProperty layerPr // update existing row Qgis::WkbType wkbType = QgsMssqlTableModel::wkbTypeFromMssql( typeList.at( 0 ) ); - row[ DbtmType ]->setIcon( QgsIconUtils::iconForWkbType( wkbType ) ); - row[ DbtmType ]->setText( QgsWkbTypes::translatedDisplayString( wkbType ) ); - row[ DbtmType ]->setData( false, Qt::UserRole + 1 ); - row[ DbtmType ]->setData( static_cast< quint32>( wkbType ), Qt::UserRole + 2 ); + row[DbtmType]->setIcon( QgsIconUtils::iconForWkbType( wkbType ) ); + row[DbtmType]->setText( QgsWkbTypes::translatedDisplayString( wkbType ) ); + row[DbtmType]->setData( false, Qt::UserRole + 1 ); + row[DbtmType]->setData( static_cast( wkbType ), Qt::UserRole + 2 ); - row[ DbtmSrid ]->setText( sridList.at( 0 ) ); + row[DbtmSrid]->setText( sridList.at( 0 ) ); Qt::ItemFlags flags = Qt::ItemIsEnabled; if ( layerProperty.pkCols.size() < 2 ) @@ -346,7 +334,7 @@ bool QgsMssqlTableModel::setData( const QModelIndex &idx, const QVariant &value, if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol ) { - Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() ); + Qgis::WkbType wkbType = static_cast( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() ); bool ok = wkbType != Qgis::WkbType::Unknown; @@ -375,7 +363,7 @@ QString QgsMssqlTableModel::layerURI( const QModelIndex &index, const QString &c if ( !index.isValid() ) return QString(); - Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( itemFromIndex( index.sibling( index.row(), DbtmType ) )->data( Qt::UserRole + 2 ).toInt() ); + Qgis::WkbType wkbType = static_cast( itemFromIndex( index.sibling( index.row(), DbtmType ) )->data( Qt::UserRole + 2 ).toInt() ); if ( wkbType == Qgis::WkbType::Unknown ) // no geometry type selected return QString(); @@ -383,8 +371,7 @@ QString QgsMssqlTableModel::layerURI( const QModelIndex &index, const QString &c QStandardItem *pkItem = itemFromIndex( index.sibling( index.row(), DbtmPkCol ) ); QString pkColumnName = pkItem->data( Qt::UserRole + 2 ).toString(); - if ( !pkItem->data( Qt::UserRole + 1 ).toStringList().isEmpty() && - !pkItem->data( Qt::UserRole + 1 ).toStringList().contains( pkColumnName ) ) + if ( !pkItem->data( Qt::UserRole + 1 ).toStringList().isEmpty() && !pkItem->data( Qt::UserRole + 1 ).toStringList().contains( pkColumnName ) ) // no valid primary candidate selected return QString(); @@ -399,7 +386,7 @@ QString QgsMssqlTableModel::layerURI( const QModelIndex &index, const QString &c srid = index.sibling( index.row(), DbtmSrid ).data( Qt::DisplayRole ).toString(); bool ok; - ( void )srid.toInt( &ok ); + ( void ) srid.toInt( &ok ); if ( !ok ) return QString(); } diff --git a/src/providers/mssql/qgsmssqltablemodel.h b/src/providers/mssql/qgsmssqltablemodel.h index 196e63a7ec81..79e17fdf3d38 100644 --- a/src/providers/mssql/qgsmssqltablemodel.h +++ b/src/providers/mssql/qgsmssqltablemodel.h @@ -24,16 +24,16 @@ //! Layer Property structure struct QgsMssqlLayerProperty { - // MSSQL layer properties - QString type; - QString schemaName; - QString tableName; - QString geometryColName; - QStringList pkCols; - QString srid; - bool isGeography; - QString sql; - bool isView; + // MSSQL layer properties + QString type; + QString schemaName; + QString tableName; + QString geometryColName; + QStringList pkCols; + QString srid; + bool isGeography; + QString sql; + bool isView; }; diff --git a/src/providers/mssql/qgsmssqltransaction.cpp b/src/providers/mssql/qgsmssqltransaction.cpp index 0eea935143dc..288c08763466 100644 --- a/src/providers/mssql/qgsmssqltransaction.cpp +++ b/src/providers/mssql/qgsmssqltransaction.cpp @@ -46,7 +46,7 @@ bool QgsMssqlTransaction::executeSql( const QString &sql, QString &error, bool i if ( isDirty ) { QgsTransaction::createSavepoint( error ); - if ( ! error.isEmpty() ) + if ( !error.isEmpty() ) { return false; } diff --git a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp index 87f9b5e0820f..92225ac59004 100644 --- a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp +++ b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp @@ -47,9 +47,9 @@ #if __cplusplus >= 201500 #define FALLTHROUGH [[fallthrough]]; -#elif defined(__clang__) +#elif defined( __clang__ ) #define FALLTHROUGH [[clang::fallthrough]]; -#elif defined(__GNUC__) && __GNUC__ >= 7 +#elif defined( __GNUC__ ) && __GNUC__ >= 7 #define FALLTHROUGH [[gnu::fallthrough]]; #else #define FALLTHROUGH @@ -84,7 +84,7 @@ #endif // This is needed for oracle oci when compiling with mingw-w64 headers -#if defined(__MINGW64_VERSION_MAJOR) && defined(_WIN64) +#if defined( __MINGW64_VERSION_MAJOR ) && defined( _WIN64 ) #define _int64 __int64 #endif @@ -117,9 +117,15 @@ Q_DECLARE_METATYPE( OCIStmt * ) QT_BEGIN_NAMESPACE #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN -enum { QOCISpatialEncoding = 2002 }; // AL16UTF16LE +enum +{ + QOCISpatialEncoding = 2002 +}; // AL16UTF16LE #else -enum { QOCISpatialEncoding = 2000 }; // AL16UTF16 +enum +{ + QOCISpatialEncoding = 2000 +}; // AL16UTF16 #endif #ifdef OCI_ATTR_CHARSET_FORM @@ -130,7 +136,7 @@ enum { QOCISpatialEncoding = 2000 }; // AL16UTF16 static const ub1 qOraCharsetForm = SQLCS_NCHAR; #endif -#if defined (OCI_UTF16ID) +#if defined( OCI_UTF16ID ) static const ub2 qOraCharset = OCI_UTF16ID; #else static const ub2 qOraCharset = OCI_UCS2ID; @@ -153,17 +159,34 @@ static QString qOraWarn( OCIError *err, int *errorCode = nullptr ); #ifndef Q_CC_SUN static // for some reason, Sun CC can't use qOraWarning when it's declared static #endif -void qOraWarningAt( const char *msg, OCIError *err, const char *function, const char *file, int line ); + void + qOraWarningAt( const char *msg, OCIError *err, const char *function, const char *file, int line ); static QSqlError qMakeError( const QString &errString, QSqlError::ErrorType type, OCIError *err ); #ifndef _MSC_VER -#define qOraWarning(msg,err) qOraWarningAt(msg,err,__PRETTY_FUNCTION__,__FILE__,__LINE__) -#define OCI_VERIFY(x) do { oci_verify(__PRETTY_FUNCTION__, __FILE__, __LINE__, x, #x); } while(0) -#define OCI_VERIFY_E(e,x) do { oci_verify(e,__PRETTY_FUNCTION__, __FILE__, __LINE__, x, #x); } while(0) +#define qOraWarning( msg, err ) qOraWarningAt( msg, err, __PRETTY_FUNCTION__, __FILE__, __LINE__ ) +#define OCI_VERIFY( x ) \ + do \ + { \ + oci_verify( __PRETTY_FUNCTION__, __FILE__, __LINE__, x, #x ); \ + } while ( 0 ) +#define OCI_VERIFY_E( e, x ) \ + do \ + { \ + oci_verify( e, __PRETTY_FUNCTION__, __FILE__, __LINE__, x, #x ); \ + } while ( 0 ) #else -#define qOraWarning(msg,err) qOraWarningAt(msg,err,__FUNCTION__,__FILE__,__LINE__) -#define OCI_VERIFY(x) do { oci_verify(__FUNCTION__, __FILE__, __LINE__, x, #x); } while(0) -#define OCI_VERIFY_E(e,x) do { oci_verify(e,__FUNCTION__, __FILE__, __LINE__, x, #x); } while(0) +#define qOraWarning( msg, err ) qOraWarningAt( msg, err, __FUNCTION__, __FILE__, __LINE__ ) +#define OCI_VERIFY( x ) \ + do \ + { \ + oci_verify( __FUNCTION__, __FILE__, __LINE__, x, #x ); \ + } while ( 0 ) +#define OCI_VERIFY_E( e, x ) \ + do \ + { \ + oci_verify( e, __FUNCTION__, __FILE__, __LINE__, x, #x ); \ + } while ( 0 ) #endif void oci_verify( OCIError *err, const char *function, const char *file, int line, int result, const char *expression ) @@ -208,9 +231,9 @@ class enter }; #ifdef _MSC_VER -#define ENTER enter here(__FUNCTION__,__FILE__,__LINE__); +#define ENTER enter here( __FUNCTION__, __FILE__, __LINE__ ); #else -#define ENTER enter here(__PRETTY_FUNCTION__,__FILE__,__LINE__); +#define ENTER enter here( __PRETTY_FUNCTION__, __FILE__, __LINE__ ); #endif int enter::level = 0; @@ -300,7 +323,7 @@ enum WKBType }; -class QOCISpatialRowId: public QSharedData +class QOCISpatialRowId : public QSharedData { public: explicit QOCISpatialRowId( OCIEnv *env ); @@ -309,14 +332,14 @@ class QOCISpatialRowId: public QSharedData OCIRowid *id = nullptr; private: - QOCISpatialRowId( const QOCISpatialRowId &other ): QSharedData( other ), id( nullptr ) { Q_ASSERT( false ); } - QOCISpatialRowId &operator= ( const QOCISpatialRowId & ) = delete; + QOCISpatialRowId( const QOCISpatialRowId &other ) + : QSharedData( other ), id( nullptr ) { Q_ASSERT( false ); } + QOCISpatialRowId &operator=( const QOCISpatialRowId & ) = delete; }; QOCISpatialRowId::QOCISpatialRowId( OCIEnv *env ) { - OCIDescriptorAlloc( env, reinterpret_cast( &id ), - OCI_DTYPE_ROWID, 0, nullptr ); + OCIDescriptorAlloc( env, reinterpret_cast( &id ), OCI_DTYPE_ROWID, 0, nullptr ); } QOCISpatialRowId::~QOCISpatialRowId() @@ -358,11 +381,12 @@ class QOCISpatialDriverPrivate : public QSqlDriverPrivate class QOCISpatialCols; class QOCISpatialResultPrivate; -class QOCISpatialResult: public QSqlCachedResult +class QOCISpatialResult : public QSqlCachedResult { Q_DECLARE_PRIVATE( QOCISpatialResult ) friend class QOCISpatialDriver; friend class QOCISpatialCols; + public: QOCISpatialResult( const QOCISpatialDriver *db ); ~QOCISpatialResult() override; @@ -383,40 +407,40 @@ class QOCISpatialResult: public QSqlCachedResult struct QOCISDOPointObj { - OCINumber x; - OCINumber y; - OCINumber z; + OCINumber x; + OCINumber y; + OCINumber z; }; struct QOCISDOGeometryObj { - OCINumber gtype; - OCINumber srid; - QOCISDOPointObj point; - OCIArray *elem_info = nullptr; - OCIArray *ordinates = nullptr; + OCINumber gtype; + OCINumber srid; + QOCISDOPointObj point; + OCIArray *elem_info = nullptr; + OCIArray *ordinates = nullptr; }; struct QOCISDOPointInd { - OCIInd _atomic; - OCIInd x; - OCIInd y; - OCIInd z; + OCIInd _atomic; + OCIInd x; + OCIInd y; + OCIInd z; }; struct QOCISDOGeometryInd { - OCIInd _atomic; - OCIInd gtype; - OCIInd srid; - QOCISDOPointInd point; - OCIInd elem_info; - OCIInd ordinates; + OCIInd _atomic; + OCIInd gtype; + OCIInd srid; + QOCISDOPointInd point; + OCIInd elem_info; + OCIInd ordinates; }; -class QOCISpatialResultPrivate: public QSqlCachedResultPrivate +class QOCISpatialResultPrivate : public QSqlCachedResultPrivate { public: Q_DECLARE_PUBLIC( QOCISpatialResult ) @@ -440,16 +464,19 @@ class QOCISpatialResultPrivate: public QSqlCachedResultPrivate QOCISDOGeometryInd *geometryInd = nullptr; void setStatementAttributes(); - int bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos, - const QVariant &val, dvoid *indPtr, ub2 *tmpSize, QList &tmpStorage ); - int bindValues( QVector &values, IndicatorArray &indicators, SizeArray &tmpSizes, - QList &tmpStorage ); - void outValues( QVector &values, IndicatorArray &indicators, - QList &tmpStorage ); + int bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos, const QVariant &val, dvoid *indPtr, ub2 *tmpSize, QList &tmpStorage ); + int bindValues( QVector &values, IndicatorArray &indicators, SizeArray &tmpSizes, QList &tmpStorage ); + void outValues( QVector &values, IndicatorArray &indicators, QList &tmpStorage ); inline bool isOutValue( int i ) const - { Q_Q( const QOCISpatialResult ); return q->bindValueType( i ) & QSql::Out; } + { + Q_Q( const QOCISpatialResult ); + return q->bindValueType( i ) & QSql::Out; + } inline bool isBinaryValue( int i ) const - { Q_Q( const QOCISpatialResult ); return q->bindValueType( i ) & QSql::Binary; } + { + Q_Q( const QOCISpatialResult ); + return q->bindValueType( i ) & QSql::Binary; + } void setCharset( dvoid *handle, ub4 type ) const { @@ -457,13 +484,10 @@ class QOCISpatialResultPrivate: public QSqlCachedResultPrivate Q_ASSERT( handle ); #ifdef OCI_ATTR_CHARSET_FORM - r = OCIAttrSet( handle, - type, + r = OCIAttrSet( handle, type, // this const cast is safe since OCI doesn't touch // the charset. - const_cast( static_cast( &qOraCharsetForm ) ), - 0, - OCI_ATTR_CHARSET_FORM, + const_cast( static_cast( &qOraCharsetForm ) ), 0, OCI_ATTR_CHARSET_FORM, //Strange Oracle bug: some Oracle servers crash the server process with non-zero error handle (mostly for 10g). //So ignore the error message here. nullptr ); @@ -473,17 +497,12 @@ class QOCISpatialResultPrivate: public QSqlCachedResultPrivate #endif #endif - r = OCIAttrSet( handle, - type, + r = OCIAttrSet( handle, type, // this const cast is safe since OCI doesn't touch // the charset. - const_cast( static_cast( &qOraCharset ) ), - 0, - OCI_ATTR_CHARSET_ID, - err ); + const_cast( static_cast( &qOraCharset ) ), 0, OCI_ATTR_CHARSET_ID, err ); if ( r != OCI_SUCCESS ) qOraWarning( "Couldn't set OCI_ATTR_CHARSET_ID: ", err ); - } }; @@ -494,27 +513,17 @@ void QOCISpatialResultPrivate::setStatementAttributes() int r = OCI_SUCCESS; - r = OCIAttrSet( sql, - OCI_HTYPE_STMT, - &prefetchRows, - 0, - OCI_ATTR_PREFETCH_ROWS, - err ); + r = OCIAttrSet( sql, OCI_HTYPE_STMT, &prefetchRows, 0, OCI_ATTR_PREFETCH_ROWS, err ); if ( r != OCI_SUCCESS ) qOraWarning( "Couldn't set OCI_ATTR_PREFETCH_ROWS: ", err ); - r = OCIAttrSet( sql, - OCI_HTYPE_STMT, - &prefetchMem, - 0, - OCI_ATTR_PREFETCH_MEMORY, - err ); + r = OCIAttrSet( sql, OCI_HTYPE_STMT, &prefetchMem, 0, OCI_ATTR_PREFETCH_MEMORY, err ); if ( r != OCI_SUCCESS ) qOraWarning( "QOCISpatialResultPrivate::setStatementAttributes:" - " Couldn't set OCI_ATTR_PREFETCH_MEMORY: ", err ); + " Couldn't set OCI_ATTR_PREFETCH_MEMORY: ", + err ); } -int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos, - const QVariant &val, dvoid *indPtr, ub2 *tmpSize, QList &tmpStorage ) +int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos, const QVariant &val, dvoid *indPtr, ub2 *tmpSize, QList &tmpStorage ) { ENTER int r = OCI_SUCCESS; @@ -523,13 +532,7 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError switch ( val.userType() ) { case QMetaType::Type::QByteArray: - r = OCIBindByPos( sql, hbnd, err, - pos + 1, - isOutValue( pos ) - ? const_cast( reinterpret_cast( data )->constData() ) - : reinterpret_cast( data )->data(), - reinterpret_cast( data )->size(), - SQLT_BIN, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + r = OCIBindByPos( sql, hbnd, err, pos + 1, isOutValue( pos ) ? const_cast( reinterpret_cast( data )->constData() ) : reinterpret_cast( data )->data(), reinterpret_cast( data )->size(), SQLT_BIN, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); qDebug() << "inout" << isOutValue( pos ) << "bytearray size" << reinterpret_cast( data )->size() << "r" << r; break; case QMetaType::Type::QTime: @@ -537,90 +540,62 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError case QMetaType::Type::QDateTime: { QByteArray ba = qMakeOraDate( val.toDateTime() ); - r = OCIBindByPos( sql, hbnd, err, - pos + 1, - ba.data(), - ba.size(), - SQLT_DAT, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + r = OCIBindByPos( sql, hbnd, err, pos + 1, ba.data(), ba.size(), SQLT_DAT, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); tmpStorage.append( ba ); break; } case QMetaType::Type::Int: - r = OCIBindByPos( sql, hbnd, err, - pos + 1, + r = OCIBindByPos( sql, hbnd, err, pos + 1, // if it's an out value, the data is already detached // so the const cast is safe. - const_cast( data ), - sizeof( int ), - SQLT_INT, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + const_cast( data ), sizeof( int ), SQLT_INT, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); break; case QMetaType::Type::UInt: - r = OCIBindByPos( sql, hbnd, err, - pos + 1, + r = OCIBindByPos( sql, hbnd, err, pos + 1, // if it's an out value, the data is already detached // so the const cast is safe. - const_cast( data ), - sizeof( uint ), - SQLT_UIN, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + const_cast( data ), sizeof( uint ), SQLT_UIN, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); break; case QMetaType::Type::LongLong: { QByteArray ba = qMakeOCINumber( val.toLongLong(), err ); - r = OCIBindByPos( sql, hbnd, err, - pos + 1, - ba.data(), - ba.size(), - SQLT_VNU, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + r = OCIBindByPos( sql, hbnd, err, pos + 1, ba.data(), ba.size(), SQLT_VNU, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); tmpStorage.append( ba ); break; } case QMetaType::Type::ULongLong: { QByteArray ba = qMakeOCINumber( val.toULongLong(), err ); - r = OCIBindByPos( sql, hbnd, err, - pos + 1, - ba.data(), - ba.size(), - SQLT_VNU, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + r = OCIBindByPos( sql, hbnd, err, pos + 1, ba.data(), ba.size(), SQLT_VNU, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); tmpStorage.append( ba ); break; } case QMetaType::Type::Double: - r = OCIBindByPos( sql, hbnd, err, - pos + 1, + r = OCIBindByPos( sql, hbnd, err, pos + 1, // if it's an out value, the data is already detached // so the const cast is safe. - const_cast( data ), - sizeof( double ), - SQLT_FLT, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + const_cast( data ), sizeof( double ), SQLT_FLT, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); break; case QMetaType::Type::QString: { const QString s = val.toString(); if ( isBinaryValue( pos ) ) { - r = OCIBindByPos( sql, hbnd, err, - pos + 1, - const_cast( s.utf16() ), - static_cast( s.length() * sizeof( QChar ) ), - SQLT_LNG, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + r = OCIBindByPos( sql, hbnd, err, pos + 1, const_cast( s.utf16() ), static_cast( s.length() * sizeof( QChar ) ), SQLT_LNG, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); break; } else if ( !isOutValue( pos ) ) { // don't detach the string - r = OCIBindByPos( sql, hbnd, err, - pos + 1, + r = OCIBindByPos( sql, hbnd, err, pos + 1, // safe since oracle doesn't touch OUT values - const_cast( s.utf16() ), - static_cast( ( s.length() + 1 ) * sizeof( QChar ) ), - SQLT_STR, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + const_cast( s.utf16() ), static_cast( ( s.length() + 1 ) * sizeof( QChar ) ), SQLT_STR, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); if ( r == OCI_SUCCESS ) setCharset( *hbnd, OCI_HTYPE_BIND ); break; } } - FALLTHROUGH + FALLTHROUGH default: { @@ -644,7 +619,7 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError } OCI_VERIFY_E( err, OCIBindByPos( sql, hbnd, err, pos + 1, nullptr, 0, SQLT_NTY, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ) ); - OCI_VERIFY_E( err, OCIBindObject( *hbnd, err, geometryTDO, ( dvoid ** )&geometryObj, nullptr, ( dvoid ** ) &geometryInd, nullptr ) ); + OCI_VERIFY_E( err, OCIBindObject( *hbnd, err, geometryTDO, ( dvoid ** ) &geometryObj, nullptr, ( dvoid ** ) &geometryInd, nullptr ) ); const QOCISpatialGeometry &g = qvariant_cast( val ); @@ -662,8 +637,8 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError else { geometryInd->_atomic = OCI_IND_NOTNULL; - geometryInd->gtype = g.gtype < 0 ? OCI_IND_NULL : OCI_IND_NOTNULL; - geometryInd->srid = g.srid < 0 ? OCI_IND_NULL : OCI_IND_NOTNULL; + geometryInd->gtype = g.gtype < 0 ? OCI_IND_NULL : OCI_IND_NOTNULL; + geometryInd->srid = g.srid < 0 ? OCI_IND_NULL : OCI_IND_NOTNULL; OCI_VERIFY_E( err, OCINumberFromInt( err, &g.gtype, sizeof( int ), OCI_NUMBER_SIGNED, &geometryObj->gtype ) ); OCI_VERIFY_E( err, OCINumberFromInt( err, &g.srid, sizeof( int ), OCI_NUMBER_SIGNED, &geometryObj->srid ) ); @@ -671,11 +646,11 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError if ( SDO_GTYPE_TT( g.gtype ) == GtPoint ) { geometryInd->point._atomic = OCI_IND_NOTNULL; - geometryInd->point.x = OCI_IND_NOTNULL; - geometryInd->point.y = OCI_IND_NOTNULL; - geometryInd->point.z = OCI_IND_NOTNULL; - geometryInd->elem_info = OCI_IND_NULL; - geometryInd->ordinates = OCI_IND_NULL; + geometryInd->point.x = OCI_IND_NOTNULL; + geometryInd->point.y = OCI_IND_NOTNULL; + geometryInd->point.z = OCI_IND_NOTNULL; + geometryInd->elem_info = OCI_IND_NULL; + geometryInd->ordinates = OCI_IND_NULL; OCI_VERIFY_E( err, OCINumberFromReal( err, &g.x, sizeof( double ), &geometryObj->point.x ) ); OCI_VERIFY_E( err, OCINumberFromReal( err, &g.y, sizeof( double ), &geometryObj->point.y ) ); @@ -684,7 +659,7 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError else { geometryInd->point._atomic = OCI_IND_NULL; - geometryInd->elem_info = g.eleminfo.size() == 0 ? OCI_IND_NULL : OCI_IND_NOTNULL; + geometryInd->elem_info = g.eleminfo.size() == 0 ? OCI_IND_NULL : OCI_IND_NOTNULL; geometryInd->ordinates = g.ordinates.size() == 0 ? OCI_IND_NULL : OCI_IND_NOTNULL; for ( int e : g.eleminfo ) @@ -712,12 +687,9 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError { // use a const pointer to prevent a detach const QOCISpatialRowIdPointer rptr = qvariant_cast( val ); - r = OCIBindByPos( sql, hbnd, err, - pos + 1, + r = OCIBindByPos( sql, hbnd, err, pos + 1, // it's an IN value, so const_cast is OK - const_cast( &rptr->id ), - -1, - SQLT_RDD, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + const_cast( &rptr->id ), -1, SQLT_RDD, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); } else if ( val.userType() >= QMetaType::Type::User ) { @@ -733,20 +705,12 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError { ba.reserve( static_cast( ( s.capacity() + 1 ) * sizeof( QChar ) ) ); *tmpSize = ba.size(); - r = OCIBindByPos( sql, hbnd, err, - pos + 1, - ba.data(), - ba.capacity(), - SQLT_STR, indPtr, tmpSize, nullptr, 0, nullptr, OCI_DEFAULT ); + r = OCIBindByPos( sql, hbnd, err, pos + 1, ba.data(), ba.capacity(), SQLT_STR, indPtr, tmpSize, nullptr, 0, nullptr, OCI_DEFAULT ); tmpStorage.append( ba ); } else { - r = OCIBindByPos( sql, hbnd, err, - pos + 1, - ba.data(), - ba.size(), - SQLT_STR, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); + r = OCIBindByPos( sql, hbnd, err, pos + 1, ba.data(), ba.size(), SQLT_STR, indPtr, nullptr, nullptr, 0, nullptr, OCI_DEFAULT ); } if ( r == OCI_SUCCESS ) setCharset( *hbnd, OCI_HTYPE_BIND ); @@ -759,8 +723,7 @@ int QOCISpatialResultPrivate::bindValue( OCIStmt *sql, OCIBind **hbnd, OCIError return r; } -int QOCISpatialResultPrivate::bindValues( QVector &values, IndicatorArray &indicators, - SizeArray &tmpSizes, QList &tmpStorage ) +int QOCISpatialResultPrivate::bindValues( QVector &values, IndicatorArray &indicators, SizeArray &tmpSizes, QList &tmpStorage ) { ENTER int r = OCI_SUCCESS; @@ -770,7 +733,7 @@ int QOCISpatialResultPrivate::bindValues( QVector &values, IndicatorAr values[i].detach(); const QVariant &val = values.at( i ); - OCIBind *hbnd = nullptr; // Oracle handles these automatically + OCIBind *hbnd = nullptr; // Oracle handles these automatically sb2 *indPtr = &indicators[i]; *indPtr = val.isNull() ? -1 : 0; @@ -802,33 +765,32 @@ static void qOraOutValue( QVariant &value, QList &storage, OCIError break; case QMetaType::Type::QString: value = QString( - reinterpret_cast( storage.takeFirst().constData() ) ); + reinterpret_cast( storage.takeFirst().constData() ) + ); break; default: break; //nothing } } -void QOCISpatialResultPrivate::outValues( QVector &values, IndicatorArray &indicators, - QList &tmpStorage ) +void QOCISpatialResultPrivate::outValues( QVector &values, IndicatorArray &indicators, QList &tmpStorage ) { ENTER for ( int i = 0; i < values.count(); ++i ) { - if ( !isOutValue( i ) ) continue; qOraOutValue( values[i], tmpStorage, err ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QMetaType::Type typ = static_cast( values.at( i ).userType() ); #else QMetaType typ = values.at( i ).metaType(); #endif if ( indicators[i] == -1 ) // NULL -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - values[i] = static_cast< QVariant::Type >( typ ); +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + values[i] = static_cast( typ ); #else values[i] = QVariant( typ ); #endif @@ -844,11 +806,7 @@ QOCISpatialDriverPrivate::QOCISpatialDriverPrivate() void QOCISpatialDriverPrivate::allocErrorHandle() { ENTER - int r = OCIHandleAlloc( env, - reinterpret_cast( &err ), - OCI_HTYPE_ERROR, - 0, - nullptr ); + int r = OCIHandleAlloc( env, reinterpret_cast( &err ), OCI_HTYPE_ERROR, 0, nullptr ); if ( r != OCI_SUCCESS ) qWarning( "QOCISpatialDriver: unable to allocate error handle" ); } @@ -862,7 +820,7 @@ OCIType *QOCISpatialDriverPrivate::tdo( QString type ) try { - OCI_VERIFY( OCIHandleAlloc( env, ( void ** ) & dschp, OCI_HTYPE_DESCRIBE, 0, nullptr ) ); + OCI_VERIFY( OCIHandleAlloc( env, ( void ** ) &dschp, OCI_HTYPE_DESCRIBE, 0, nullptr ) ); OCI_VERIFY_E( err, OCIDescribeAny( svc, err, ( dvoid * ) type.utf16(), type.length() * sizeof( QChar ), OCI_OTYPE_NAME, OCI_DEFAULT, OCI_PTYPE_TYPE, dschp ) ); OCI_VERIFY_E( err, OCIAttrGet( dschp, OCI_HTYPE_DESCRIBE, ¶mp, nullptr, OCI_ATTR_PARAM, err ) ); OCI_VERIFY_E( err, OCIAttrGet( paramp, OCI_DTYPE_PARAM, &type_ref, nullptr, OCI_ATTR_REF_TDO, err ) ); @@ -879,16 +837,16 @@ OCIType *QOCISpatialDriverPrivate::tdo( QString type ) struct OraFieldInfo { - QString name; - QMetaType::Type type; - ub1 oraIsNull; - ub4 oraType; - sb1 oraScale; - ub4 oraLength; // size in bytes - ub4 oraFieldLength; // amount of characters - sb2 oraPrecision; - QString oraTypeName; - OCIType *oraOCIType = nullptr; + QString name; + QMetaType::Type type; + ub1 oraIsNull; + ub4 oraType; + sb1 oraScale; + ub4 oraLength; // size in bytes + ub4 oraFieldLength; // amount of characters + sb2 oraPrecision; + QString oraTypeName; + OCIType *oraOCIType = nullptr; }; QString qOraWarn( OCIError *err, int *errorCode ) @@ -898,13 +856,7 @@ QString qOraWarn( OCIError *err, int *errorCode ) errbuf[0] = 0; errbuf[1] = 0; - OCIErrorGet( err, - 1, - nullptr, - &errcode, - errbuf, - sizeof( errbuf ), - OCI_HTYPE_ERROR ); + OCIErrorGet( err, 1, nullptr, &errcode, errbuf, sizeof( errbuf ), OCI_HTYPE_ERROR ); if ( errorCode ) *errorCode = errcode; return QString( reinterpret_cast( errbuf ) ); @@ -919,13 +871,7 @@ static int qOraErrorNumber( OCIError *err ) { ENTER sb4 errcode; - OCIErrorGet( err, - 1, - nullptr, - &errcode, - nullptr, - 0, - OCI_HTYPE_ERROR ); + OCIErrorGet( err, 1, nullptr, &errcode, nullptr, 0, OCI_HTYPE_ERROR ); return errcode; } @@ -974,7 +920,7 @@ QMetaType::Type qDecodeOCIType( const QString &ocitype, QSql::NumericalPrecision || ocitype == QLatin1String( "ROWID" ) || ocitype == QLatin1String( "BLOB" ) || ocitype == QLatin1String( "CFILE" ) || ocitype == QLatin1String( "BFILE" ) ) type = QMetaType::Type::QByteArray; - else if ( ocitype == QLatin1String( "DATE" ) || ocitype.startsWith( QLatin1String( "TIME" ) ) ) + else if ( ocitype == QLatin1String( "DATE" ) || ocitype.startsWith( QLatin1String( "TIME" ) ) ) type = QMetaType::Type::QDateTime; else if ( ocitype == QLatin1String( "UNDEFINED" ) ) type = QMetaType::Type::UnknownType; @@ -1065,7 +1011,7 @@ QMetaType::Type qDecodeOCIType( int ocitype, QSql::NumericalPrecisionPolicy prec static QSqlField qFromOraInf( const OraFieldInfo &ofi ) { ENTER -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QSqlField f( ofi.name, static_cast( ofi.type ) ); #else QSqlField f( ofi.name, QMetaType( ofi.type ) ); @@ -1115,11 +1061,7 @@ QByteArray qMakeOCINumber( const qlonglong &ll, OCIError *err ) ENTER QByteArray ba( sizeof( OCINumber ), 0 ); - OCINumberFromInt( err, - &ll, - sizeof( qlonglong ), - OCI_NUMBER_SIGNED, - reinterpret_cast( ba.data() ) ); + OCINumberFromInt( err, &ll, sizeof( qlonglong ), OCI_NUMBER_SIGNED, reinterpret_cast( ba.data() ) ); return ba; } @@ -1133,11 +1075,7 @@ QByteArray qMakeOCINumber( const qulonglong &ull, OCIError *err ) ENTER QByteArray ba( sizeof( OCINumber ), 0 ); - OCINumberFromInt( err, - &ull, - sizeof( qlonglong ), - OCI_NUMBER_UNSIGNED, - reinterpret_cast( ba.data() ) ); + OCINumberFromInt( err, &ull, sizeof( qlonglong ), OCI_NUMBER_UNSIGNED, reinterpret_cast( ba.data() ) ); return ba; } @@ -1145,8 +1083,7 @@ qlonglong qMakeLongLong( const char *ociNumber, OCIError *err ) { ENTER qlonglong qll = 0; - OCINumberToInt( err, reinterpret_cast( ociNumber ), sizeof( qlonglong ), - OCI_NUMBER_SIGNED, &qll ); + OCINumberToInt( err, reinterpret_cast( ociNumber ), sizeof( qlonglong ), OCI_NUMBER_SIGNED, &qll ); return qll; } @@ -1154,8 +1091,7 @@ qulonglong qMakeULongLong( const char *ociNumber, OCIError *err ) { ENTER qulonglong qull = 0; - OCINumberToInt( err, reinterpret_cast( ociNumber ), sizeof( qulonglong ), - OCI_NUMBER_UNSIGNED, &qull ); + OCINumberToInt( err, reinterpret_cast( ociNumber ), sizeof( qulonglong ), OCI_NUMBER_UNSIGNED, &qull ); return qull; } @@ -1165,13 +1101,13 @@ QDateTime qMakeDate( const char *oraDate ) int century = uchar( oraDate[0] ); if ( century >= 100 ) { - int year = uchar( oraDate[1] ); + int year = uchar( oraDate[1] ); year = ( ( century - 100 ) * 100 ) + ( year - 100 ); int month = oraDate[2]; - int day = oraDate[3]; - int hour = oraDate[4] - 1; - int min = oraDate[5] - 1; - int sec = oraDate[6] - 1; + int day = oraDate[3]; + int hour = oraDate[4] - 1; + int min = oraDate[5] - 1; + int sec = oraDate[6] - 1; return QDateTime( QDate( year, month, day ), QTime( hour, min, sec ) ); } return QDateTime(); @@ -1193,20 +1129,20 @@ class QOCISpatialCols struct Point { - Point( double x = 0, double y = 0, double z = 0 ) - : x( x ) - , y( y ) - , z( z ) - {} - - double x = 0; - double y = 0; - double z = 0; + Point( double x = 0, double y = 0, double z = 0 ) + : x( x ) + , y( y ) + , z( z ) + {} + + double x = 0; + double y = 0; + double z = 0; }; - typedef QVector< Point > PointSequence; - typedef QPair< WKBType, PointSequence > CurvePart; - typedef QVector< CurvePart > CurveParts; - typedef QVector< QPair< WKBType, CurveParts > > SurfaceRings; + typedef QVector PointSequence; + typedef QPair CurvePart; + typedef QVector CurveParts; + typedef QVector> SurfaceRings; private: char *create( int position, int size ); @@ -1238,7 +1174,11 @@ class QOCISpatialCols bool getValue( OCINumber *num, double &value ); bool getArraySize( OCIColl *coll, int &nSize ); bool getElemInfoElem( int elem, const QVector &vElem, int nOrds, int &startOffset, int &endOffset, int &etype, int &interpretation ); - static int byteorder() { static char littleEndian = htonl( 1 ) != 1; return littleEndian; } + static int byteorder() + { + static char littleEndian = htonl( 1 ) != 1; + return littleEndian; + } #ifdef QOCISPATIAL_DEBUG void dumpArrays( int nElems, int nOrds ); @@ -1255,7 +1195,7 @@ Q_DECLARE_TYPEINFO( QOCISpatialCols::Point, Q_PRIMITIVE_TYPE ); QOCISpatialCols::OraFieldInf::~OraFieldInf() { ENTER - delete [] data; + delete[] data; if ( lob ) { int r = OCIDescriptorFree( lob, OCI_DTYPE_LOB ); @@ -1276,11 +1216,7 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) sb4 parmStatus = 0; ub4 count = 1; int idx = 0; - parmStatus = OCIParamGet( d->sql, - OCI_HTYPE_STMT, - d->err, - reinterpret_cast( ¶m ), - count ); + parmStatus = OCIParamGet( d->sql, OCI_HTYPE_STMT, d->err, reinterpret_cast( ¶m ), count ); if ( parmStatus != OCI_SUCCESS ) { @@ -1297,9 +1233,9 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) else if ( ofi.oraType == SQLT_INTERVAL_YM || ofi.oraType == SQLT_INTERVAL_DS ) // since we are binding interval datatype as string, // we are not interested in the number of bytes but characters. - dataSize = 50; // magic number -#endif //SQLT_INTERVAL_DS -#endif //SQLT_INTERVAL_YM + dataSize = 50; // magic number +#endif //SQLT_INTERVAL_DS +#endif //SQLT_INTERVAL_YM else if ( ofi.oraType == SQLT_NUM || ofi.oraType == SQLT_VNU ) { if ( ofi.oraPrecision > 0 ) @@ -1319,48 +1255,16 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) switch ( ofi.type ) { case QMetaType::Type::QDateTime: - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - create( idx, dataSize + 1 ), - dataSize + 1, - SQLT_DAT, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, create( idx, dataSize + 1 ), dataSize + 1, SQLT_DAT, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); break; case QMetaType::Type::Double: - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - create( idx, sizeof( double ) - 1 ), - sizeof( double ), - SQLT_FLT, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, create( idx, sizeof( double ) - 1 ), sizeof( double ), SQLT_FLT, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); break; case QMetaType::Type::Int: - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - create( idx, sizeof( qint32 ) - 1 ), - sizeof( qint32 ), - SQLT_INT, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, create( idx, sizeof( qint32 ) - 1 ), sizeof( qint32 ), SQLT_INT, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); break; case QMetaType::Type::LongLong: - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - create( idx, sizeof( OCINumber ) ), - sizeof( OCINumber ), - SQLT_VNU, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, create( idx, sizeof( OCINumber ) ), sizeof( OCINumber ), SQLT_VNU, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); break; case QMetaType::Type::QByteArray: // RAW and LONG RAW fields can't be bound to LOB locators @@ -1368,56 +1272,22 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) if ( ofi.oraType == SQLT_BIN ) { qDebug( "binding SQLT_BIN" ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - create( idx, dataSize ), - dataSize, - SQLT_BIN, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DYNAMIC_FETCH ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, create( idx, dataSize ), dataSize, SQLT_BIN, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DYNAMIC_FETCH ); } else if ( ofi.oraType == SQLT_LBI ) { qDebug( "binding SQLT_LBI" ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - nullptr, - SB4MAXVAL, - SQLT_LBI, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DYNAMIC_FETCH ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, nullptr, SB4MAXVAL, SQLT_LBI, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DYNAMIC_FETCH ); } else if ( ofi.oraType == SQLT_CLOB ) { qDebug( "binding SQLT_CLOB" ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - createLobLocator( idx, d->env ), - -1, - SQLT_CLOB, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, createLobLocator( idx, d->env ), -1, SQLT_CLOB, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); } else if ( ofi.oraType == SQLT_NTY && ofi.oraTypeName == "SDO_GEOMETRY" ) { qDebug( "binding SQLT_NTY SDO_GEOMETRY" ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - nullptr, - 0, - SQLT_NTY, - nullptr, - nullptr, - nullptr, - OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, nullptr, 0, SQLT_NTY, nullptr, nullptr, nullptr, OCI_DEFAULT ); if ( r == OCI_SUCCESS ) { @@ -1425,11 +1295,7 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) dp->sdoind.push_back( 0 ); qDebug( "define object" ); - r = OCIDefineObject( dfn, - d->err, - ofi.oraOCIType, - ( void ** ) & dp->sdoobj.last(), nullptr, - ( void ** ) & dp->sdoind.last(), nullptr ); + r = OCIDefineObject( dfn, d->err, ofi.oraOCIType, ( void ** ) &dp->sdoobj.last(), nullptr, ( void ** ) &dp->sdoind.last(), nullptr ); } else { @@ -1439,44 +1305,20 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) else { qDebug( "binding SQLT_BLOB" ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - createLobLocator( idx, d->env ), - -1, - SQLT_BLOB, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, createLobLocator( idx, d->env ), -1, SQLT_BLOB, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); } break; case QMetaType::Type::QString: if ( ofi.oraType == SQLT_LNG ) { qDebug( "binding SQLT_LNG" ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - nullptr, - SB4MAXVAL, - SQLT_LNG, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DYNAMIC_FETCH ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, nullptr, SB4MAXVAL, SQLT_LNG, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DYNAMIC_FETCH ); } else { dataSize += dataSize + sizeof( QChar ); qDebug( "OCIDefineByPosStr(%d): %d", count, dataSize ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - create( idx, dataSize ), - dataSize, - SQLT_STR, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, create( idx, dataSize ), dataSize, SQLT_STR, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); if ( r == OCI_SUCCESS ) d->setCharset( dfn, OCI_HTYPE_DEFINE ); } @@ -1485,15 +1327,7 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) // this should make enough space even with character encoding dataSize = ( dataSize + 1 ) * sizeof( utext ); qDebug( "OCIDefineByPosDef(%d): %d", count, dataSize ); - r = OCIDefineByPos( d->sql, - &dfn, - d->err, - count, - create( idx, dataSize ), - dataSize + 1, - SQLT_STR, - &( fieldInf[idx].ind ), - nullptr, nullptr, OCI_DEFAULT ); + r = OCIDefineByPos( d->sql, &dfn, d->err, count, create( idx, dataSize ), dataSize + 1, SQLT_STR, &( fieldInf[idx].ind ), nullptr, nullptr, OCI_DEFAULT ); break; } @@ -1503,11 +1337,7 @@ QOCISpatialCols::QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ) fieldInf[idx].def = dfn; ++count; ++idx; - parmStatus = OCIParamGet( d->sql, - OCI_HTYPE_STMT, - d->err, - reinterpret_cast( ¶m ), - count ); + parmStatus = OCIParamGet( d->sql, OCI_HTYPE_STMT, d->err, reinterpret_cast( ¶m ), count ); } } @@ -1531,11 +1361,7 @@ OCILobLocator **QOCISpatialCols::createLobLocator( int position, OCIEnv *env ) { ENTER OCILobLocator *&lob = fieldInf[position].lob; - int r = OCIDescriptorAlloc( env, - reinterpret_cast( &lob ), - OCI_DTYPE_LOB, - 0, - nullptr ); + int r = OCIDescriptorAlloc( env, reinterpret_cast( &lob ), OCI_DTYPE_LOB, 0, nullptr ); if ( r != OCI_SUCCESS ) { qWarning( "QOCISpatialCols: Cannot create LOB locator" ); @@ -1548,32 +1374,29 @@ int QOCISpatialCols::readPiecewise( QVector &values, int index ) { ENTER qDebug() << "readPiecewise( index =" << index << " )"; - OCIDefine *dfn = nullptr; - ub4 typep; - ub1 in_outp; - ub4 iterp; - ub4 idxp; - ub1 piecep; - sword status; - text col [QOCISPATIAL_DYNAMIC_CHUNK_SIZE + 1]; - int fieldNum = -1; - int r = 0; - bool nullField; + OCIDefine *dfn = nullptr; + ub4 typep; + ub1 in_outp; + ub4 iterp; + ub4 idxp; + ub1 piecep; + sword status; + text col[QOCISPATIAL_DYNAMIC_CHUNK_SIZE + 1]; + int fieldNum = -1; + int r = 0; + bool nullField; bool firstPiece = true; do { - r = OCIStmtGetPieceInfo( d->sql, d->err, reinterpret_cast( &dfn ), &typep, - &in_outp, &iterp, &idxp, &piecep ); + r = OCIStmtGetPieceInfo( d->sql, d->err, reinterpret_cast( &dfn ), &typep, &in_outp, &iterp, &idxp, &piecep ); if ( r != OCI_SUCCESS ) qOraWarning( "QOCISpatialResultPrivate::readPiecewise: unable to get piece info:", d->err ); fieldNum = fieldFromDefine( dfn ); bool isStringField = fieldInf.at( fieldNum ).oraType == SQLT_LNG; ub4 chunkSize = QOCISPATIAL_DYNAMIC_CHUNK_SIZE; nullField = false; - r = OCIStmtSetPieceInfo( dfn, OCI_HTYPE_DEFINE, - d->err, col, - &chunkSize, piecep, nullptr, nullptr ); + r = OCIStmtSetPieceInfo( dfn, OCI_HTYPE_DEFINE, d->err, col, &chunkSize, piecep, nullptr, nullptr ); if ( r != OCI_SUCCESS ) qOraWarning( "QOCISpatialResultPrivate::readPiecewise: unable to set piece info:", d->err ); status = OCIStmtFetch( d->sql, d->err, 1, OCI_FETCH_NEXT, OCI_DEFAULT ); @@ -1617,8 +1440,7 @@ int QOCISpatialCols::readPiecewise( QVector &values, int index ) } firstPiece = false; } - } - while ( status == OCI_SUCCESS_WITH_INFO || status == OCI_NEED_DATA ); + } while ( status == OCI_SUCCESS_WITH_INFO || status == OCI_NEED_DATA ); return r; } @@ -1641,40 +1463,21 @@ OraFieldInfo QOCISpatialCols::qMakeOraField( const QOCISpatialResultPrivate *p, int r( 0 ); QMetaType::Type type( QMetaType::Type::UnknownType ); - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colType, - nullptr, - OCI_ATTR_DATA_TYPE, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colType, nullptr, OCI_ATTR_DATA_TYPE, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colName, - &colNameLen, - OCI_ATTR_NAME, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colName, &colNameLen, OCI_ATTR_NAME, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colLength, - nullptr, - OCI_ATTR_DATA_SIZE, /* in bytes */ + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colLength, nullptr, OCI_ATTR_DATA_SIZE, /* in bytes */ p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); #ifdef OCI_ATTR_CHAR_SIZE - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colFieldLength, - nullptr, - OCI_ATTR_CHAR_SIZE, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colFieldLength, nullptr, OCI_ATTR_CHAR_SIZE, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); #else @@ -1682,53 +1485,28 @@ OraFieldInfo QOCISpatialCols::qMakeOraField( const QOCISpatialResultPrivate *p, colFieldLength = colLength; #endif - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colPrecision, - nullptr, - OCI_ATTR_PRECISION, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colPrecision, nullptr, OCI_ATTR_PRECISION, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colScale, - nullptr, - OCI_ATTR_SCALE, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colScale, nullptr, OCI_ATTR_SCALE, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colType, - nullptr, - OCI_ATTR_DATA_TYPE, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colType, nullptr, OCI_ATTR_DATA_TYPE, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); qDebug() << "colType:" << colLength; - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colIsNull, - nullptr, - OCI_ATTR_IS_NULL, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colIsNull, nullptr, OCI_ATTR_IS_NULL, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); if ( colType == SQLT_NTY ) { qDebug() << "NTY!"; - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &colTypeName, - &colTypeNameLen, - OCI_ATTR_TYPE_NAME, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &colTypeName, &colTypeNameLen, OCI_ATTR_TYPE_NAME, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); @@ -1736,16 +1514,11 @@ OraFieldInfo QOCISpatialCols::qMakeOraField( const QOCISpatialResultPrivate *p, OCIRef *typeRef = nullptr; - r = OCIAttrGet( param, - OCI_DTYPE_PARAM, - &typeRef, - nullptr, - OCI_ATTR_REF_TDO, - p->err ); + r = OCIAttrGet( param, OCI_DTYPE_PARAM, &typeRef, nullptr, OCI_ATTR_REF_TDO, p->err ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", p->err ); - r = OCIObjectPin( d->env, d->err, typeRef, nullptr, OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE, ( void ** ) & colOCIType ); + r = OCIObjectPin( d->env, d->err, typeRef, nullptr, OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE, ( void ** ) &colOCIType ); if ( r != OCI_SUCCESS ) qOraWarning( "qMakeOraField:", d->err ); } @@ -1802,8 +1575,7 @@ OraFieldInfo QOCISpatialCols::qMakeOraField( const QOCISpatialResultPrivate *p, << "\noraPrecision:" << ofi.oraPrecision << "\noraIsNull:" << ofi.oraIsNull << "\noraTypeName:" << ofi.oraTypeName - << "\n----------------------\n" - ; + << "\n----------------------\n"; #endif return ofi; @@ -1811,17 +1583,17 @@ OraFieldInfo QOCISpatialCols::qMakeOraField( const QOCISpatialResultPrivate *p, struct QOCISpatialBatchColumn { - inline QOCISpatialBatchColumn() = default; - - OCIBind *bindh = nullptr; - ub2 bindAs = 0; - ub4 maxLen = 0; - ub4 recordCount = 0; - std::vector data; - std::vector lengths; - std::vector indicators; - ub4 maxarr_len = 0; - ub4 curelep = 0; + inline QOCISpatialBatchColumn() = default; + + OCIBind *bindh = nullptr; + ub2 bindAs = 0; + ub4 maxLen = 0; + ub4 recordCount = 0; + std::vector data; + std::vector lengths; + std::vector indicators; + ub4 maxarr_len = 0; + ub4 curelep = 0; }; bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector &boundValues, bool arrayBind ) @@ -1843,8 +1615,7 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector for ( i = 0; i < columnCount; ++i ) { QMetaType::Type tp = static_cast( boundValues.at( i ).userType() ); - fieldTypes.append( tp == QMetaType::Type::QVariantList ? static_cast( boundValues.at( i ).toList().value( 0 ).userType() ) - : tp ); + fieldTypes.append( tp == QMetaType::Type::QVariantList ? static_cast( boundValues.at( i ).toList().value( 0 ).userType() ) : tp ); } QList tmpStorage; @@ -1854,24 +1625,19 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector // figuring out buffer sizes for ( i = 0; i < columnCount; ++i ) { - if ( boundValues.at( i ).userType() != QMetaType::Type::QVariantList ) { - // not a list - create a deep-copy of the single value QOCISpatialBatchColumn &singleCol = columns[i]; singleCol.indicators.resize( 1 ); singleCol.indicators[0] = boundValues.at( i ).isNull() ? -1 : 0; - r = d->bindValue( d->sql, &singleCol.bindh, d->err, i, - boundValues.at( i ), &singleCol.indicators[0], &tmpSizes[i], tmpStorage ); + r = d->bindValue( d->sql, &singleCol.bindh, d->err, i, boundValues.at( i ), &singleCol.indicators[0], &tmpSizes[i], tmpStorage ); if ( r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO ) { qOraWarning( "QOCISpatialPrivate::execBatch: unable to bind column:", d->err ); - d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to bind column for batch execute" ), - QSqlError::StatementError, d->err ) ); + d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to bind column for batch execute" ), QSqlError::StatementError, d->err ) ); return false; } continue; @@ -2019,7 +1785,7 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector case QMetaType::Type::QString: { const QString s = val.toString(); - columns[i].lengths[row] = ( ub2 )( s.length() + 1 ) * sizeof( QChar ); + columns[i].lengths[row] = ( ub2 ) ( s.length() + 1 ) * sizeof( QChar ); memcpy( dataPtr, s.utf16(), columns[i].lengths[row] ); break; } @@ -2048,31 +1814,28 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector QOCISpatialBatchColumn &bindColumn = columns[i]; #ifdef QOCISPATIAL_DEBUG - qDebug( "OCIBindByPos(%p, %p, %p, %d, %p, %d, %d, %p, %p, 0, %d, %p, OCI_DEFAULT)", - d->sql, &bindColumn.bindh, d->err, i + 1, bindColumn.data, - bindColumn.maxLen, bindColumn.bindAs, bindColumn.indicators, bindColumn.lengths, - arrayBind ? bindColumn.maxarr_len : 0, arrayBind ? &bindColumn.curelep : 0 ); + qDebug( "OCIBindByPos(%p, %p, %p, %d, %p, %d, %d, %p, %p, 0, %d, %p, OCI_DEFAULT)", d->sql, &bindColumn.bindh, d->err, i + 1, bindColumn.data, bindColumn.maxLen, bindColumn.bindAs, bindColumn.indicators, bindColumn.lengths, arrayBind ? bindColumn.maxarr_len : 0, arrayBind ? &bindColumn.curelep : 0 ); for ( int ii = 0; ii < static_cast( bindColumn.recordCount ); ++ii ) { - qDebug( " record %d: indicator %d, length %d", ii, bindColumn.indicators[ii], - bindColumn.lengths[ii] ); + qDebug( " record %d: indicator %d, length %d", ii, bindColumn.indicators[ii], bindColumn.lengths[ii] ); } #endif // binding the column r = OCIBindByPos( - d->sql, &bindColumn.bindh, d->err, i + 1, - &bindColumn.data[0], - bindColumn.maxLen, - bindColumn.bindAs, - &bindColumn.indicators[0], - &bindColumn.lengths[0], - nullptr, - arrayBind ? bindColumn.maxarr_len : 0, - arrayBind ? &bindColumn.curelep : nullptr, - OCI_DEFAULT ); + d->sql, &bindColumn.bindh, d->err, i + 1, + &bindColumn.data[0], + bindColumn.maxLen, + bindColumn.bindAs, + &bindColumn.indicators[0], + &bindColumn.lengths[0], + nullptr, + arrayBind ? bindColumn.maxarr_len : 0, + arrayBind ? &bindColumn.curelep : nullptr, + OCI_DEFAULT + ); #ifdef QOCISPATIAL_DEBUG qDebug( "After OCIBindByPos: r = %d, bindh = %p", r, bindColumn.bindh ); @@ -2081,48 +1844,39 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector if ( r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO ) { qOraWarning( "QOCISpatialPrivate::execBatch: unable to bind column:", d->err ); - d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to bind column for batch execute" ), - QSqlError::StatementError, d->err ) ); + d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to bind column for batch execute" ), QSqlError::StatementError, d->err ) ); return false; } r = OCIBindArrayOfStruct( - columns[i].bindh, d->err, - columns[i].maxLen, - sizeof( columns[i].indicators[0] ), - sizeof( columns[i].lengths[0] ), - 0 ); + columns[i].bindh, d->err, + columns[i].maxLen, + sizeof( columns[i].indicators[0] ), + sizeof( columns[i].lengths[0] ), + 0 + ); if ( r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO ) { qOraWarning( "QOCISpatialPrivate::execBatch: unable to bind column:", d->err ); - d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to bind column for batch execute" ), - QSqlError::StatementError, d->err ) ); + d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to bind column for batch execute" ), QSqlError::StatementError, d->err ) ); return false; } } //finally we can execute - r = OCIStmtExecute( d->svc, d->sql, d->err, - arrayBind ? 1 : columns[0].recordCount, - 0, nullptr, nullptr, - d->transaction || !d->commitOnSuccess ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS ); + r = OCIStmtExecute( d->svc, d->sql, d->err, arrayBind ? 1 : columns[0].recordCount, 0, nullptr, nullptr, d->transaction || !d->commitOnSuccess ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS ); if ( r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO ) { qOraWarning( "QOCISpatialPrivate::execBatch: unable to execute batch statement:", d->err ); - d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to execute batch statement" ), - QSqlError::StatementError, d->err ) ); + d->q_func()->setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to execute batch statement" ), QSqlError::StatementError, d->err ) ); return false; } // for out parameters we copy data back to value vector for ( i = 0; i < columnCount; ++i ) { - if ( !d->isOutValue( i ) ) continue; @@ -2131,8 +1885,8 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector { qOraOutValue( boundValues[i], tmpStorage, d->err ); if ( columns[i].indicators[0] == -1 ) -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - boundValues[i] = static_cast< QVariant::Type >( tp ); +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + boundValues[i] = static_cast( tp ); #else boundValues[i] = QVariant( QMetaType( tp ) ); #endif @@ -2144,7 +1898,6 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector const char *data = columns[i].data.data(); for ( uint r = 0; r < columns[i].recordCount; ++r ) { - if ( columns[i].indicators[r] == -1 ) { ( *list )[r] = QVariant(); @@ -2153,17 +1906,16 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector switch ( columns[i].bindAs ) { - case SQLT_DAT: - ( *list )[r] = qMakeDate( data + r * columns[i].maxLen ); + ( *list )[r] = qMakeDate( data + r * columns[i].maxLen ); break; case SQLT_INT: - ( *list )[r] = *reinterpret_cast( data + r * columns[i].maxLen ); + ( *list )[r] = *reinterpret_cast( data + r * columns[i].maxLen ); break; case SQLT_UIN: - ( *list )[r] = *reinterpret_cast( data + r * columns[i].maxLen ); + ( *list )[r] = *reinterpret_cast( data + r * columns[i].maxLen ); break; case SQLT_VNU: @@ -2171,10 +1923,10 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector switch ( boundValues.at( i ).userType() ) { case QMetaType::Type::LongLong: - ( *list )[r] = qMakeLongLong( data + r * columns[i].maxLen, d->err ); + ( *list )[r] = qMakeLongLong( data + r * columns[i].maxLen, d->err ); break; case QMetaType::Type::ULongLong: - ( *list )[r] = qMakeULongLong( data + r * columns[i].maxLen, d->err ); + ( *list )[r] = qMakeULongLong( data + r * columns[i].maxLen, d->err ); break; default: break; @@ -2183,16 +1935,15 @@ bool QOCISpatialCols::execBatch( QOCISpatialResultPrivate *d, QVector } case SQLT_FLT: - ( *list )[r] = *reinterpret_cast( data + r * columns[i].maxLen ); + ( *list )[r] = *reinterpret_cast( data + r * columns[i].maxLen ); break; case SQLT_STR: - ( *list )[r] = QString( reinterpret_cast( data - + r * columns[i].maxLen ) ); + ( *list )[r] = QString( reinterpret_cast( data + r * columns[i].maxLen ) ); break; default: - ( *list )[r] = QByteArray( data + r * columns[i].maxLen, columns[i].maxLen ); + ( *list )[r] = QByteArray( data + r * columns[i].maxLen, columns[i].maxLen ); break; } } @@ -2242,18 +1993,11 @@ int qReadLob( T &buf, const QOCISpatialResultPrivate *d, OCILobLocator *lob ) buf.resize( amount ); // Read the LOB into the buffer - r = OCILobRead( d->svc, - d->err, - lob, - &amount, - 1, - buf.data(), + r = OCILobRead( d->svc, d->err, lob, &amount, 1, buf.data(), buf.size() * sz, // this argument is in bytes, not characters - nullptr, - nullptr, + nullptr, nullptr, // Extract the data from a CLOB in UTF-16 (ie. what QString uses internally) - sz == 1 ? ub2( 0 ) : ub2( QOCISpatialEncoding ), - csfrm ); + sz == 1 ? ub2( 0 ) : ub2( QOCISpatialEncoding ), csfrm ); if ( r != OCI_SUCCESS ) qOraWarning( "OCIResultPrivate::readLOBs: Cannot read LOB: ", d->err ); @@ -2279,13 +2023,13 @@ int QOCISpatialCols::readLOBs( QVector &values, int index ) const if ( isClob ) { QString str; - r = qReadLob < QString, sizeof( QChar ) > ( str, d, lob ); + r = qReadLob( str, d, lob ); var = str; } else { QByteArray buf; - r = qReadLob < QByteArray, sizeof( char ) > ( buf, d, lob ); + r = qReadLob( buf, d, lob ); var = buf; } if ( r == OCI_SUCCESS ) @@ -2343,13 +2087,11 @@ bool QOCISpatialCols::getArraySize( OCIColl *coll, int &nSize ) return false; } -bool QOCISpatialCols::getElemInfoElem( int iElem, const QVector &vElems, int nOrds, - int &startOffset, int &endOffset, - int &etype, int &interpretation ) +bool QOCISpatialCols::getElemInfoElem( int iElem, const QVector &vElems, int nOrds, int &startOffset, int &endOffset, int &etype, int &interpretation ) { - startOffset = vElems[ iElem + 0 ]; - etype = vElems[ iElem + 1 ]; - interpretation = vElems[ iElem + 2 ]; + startOffset = vElems[iElem + 0]; + etype = vElems[iElem + 1]; + interpretation = vElems[iElem + 2]; if ( iElem + 3 >= vElems.size() ) { @@ -2357,7 +2099,7 @@ bool QOCISpatialCols::getElemInfoElem( int iElem, const QVector &vElems, in } else { - endOffset = vElems[ iElem + 3 ]; + endOffset = vElems[iElem + 3]; } --startOffset; @@ -2366,9 +2108,7 @@ bool QOCISpatialCols::getElemInfoElem( int iElem, const QVector &vElems, in return true; } -QOCISpatialCols::CurveParts QOCISpatialCols::getCurveParts( int &iElem, const QVector &vElems, int nOrds, - const QVector &ordinates, int nDims, - WKBType &baseType, bool &ok ) +QOCISpatialCols::CurveParts QOCISpatialCols::getCurveParts( int &iElem, const QVector &vElems, int nOrds, const QVector &ordinates, int nDims, WKBType &baseType, bool &ok ) { ok = true; int startOffset, endOffset, etype, n; @@ -2388,9 +2128,9 @@ QOCISpatialCols::CurveParts QOCISpatialCols::getCurveParts( int &iElem, const QV points.reserve( 1 + ( endOffset - startOffset ) / nDims ); for ( int j = startOffset; j < endOffset; j += nDims ) { - double x = ordinates[ j ]; - double y = ordinates[ j + 1 ]; - double z = nDims > 2 ? ordinates[ j + 2] : 0; + double x = ordinates[j]; + double y = ordinates[j + 1]; + double z = nDims > 2 ? ordinates[j + 2] : 0; points << Point( x, y, z ); } return ( CurveParts() << qMakePair( baseType, points ) ); @@ -2417,9 +2157,9 @@ QOCISpatialCols::CurveParts QOCISpatialCols::getCurveParts( int &iElem, const QV points.reserve( 1 + ( endOffset - startOffset ) / nDims ); for ( int j = startOffset; j < endOffset; j += nDims ) { - double x = ordinates[ j ]; - double y = ordinates[ j + 1 ]; - double z = nDims > 2 ? ordinates[ j + 2] : 0; + double x = ordinates[j]; + double y = ordinates[j + 1]; + double z = nDims > 2 ? ordinates[j + 2] : 0; points << Point( x, y, z ); } parts << qMakePair( partType, points ); @@ -2453,7 +2193,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) if ( sdoind ) qDebug() << "sdoind->_atomic =" << sdoind->_atomic; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) v = QVariant( QVariant::ByteArray ); #else v = QVariant( QMetaType( QMetaType::Type::QByteArray ) ); @@ -2520,12 +2260,8 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) return false; } - if ( iType == GtPoint && - sdoind->_atomic == OCI_IND_NOTNULL && - sdoind->point.x == OCI_IND_NOTNULL && - sdoind->point.y == OCI_IND_NOTNULL ) + if ( iType == GtPoint && sdoind->_atomic == OCI_IND_NOTNULL && sdoind->point.x == OCI_IND_NOTNULL && sdoind->point.y == OCI_IND_NOTNULL ) { - double x, y, z = 0.0; if ( !getValue( &sdoobj->point.x, x ) ) { @@ -2657,8 +2393,8 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) if ( iType == GtMultiPoint ) { *ptr.ucPtr++ = byteorder(); - *ptr.iPtr++ = nDims == 2 ? WKBMultiPoint : WKBMultiPoint25D; - *ptr.iPtr++ = nPoints / nDims; + *ptr.iPtr++ = nDims == 2 ? WKBMultiPoint : WKBMultiPoint25D; + *ptr.iPtr++ = nPoints / nDims; } for ( int i = 0; i < nElems; i += 3 ) @@ -2686,11 +2422,11 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) if ( k % nDims == 0 ) { *ptr.ucPtr++ = byteorder(); - *ptr.iPtr++ = nDims == 2 ? WKBPoint : WKBPoint25D; + *ptr.iPtr++ = nDims == 2 ? WKBPoint : WKBPoint25D; } Q_ASSERT( j < nOrds ); - *ptr.dPtr++ = ordinates[ j ]; + *ptr.dPtr++ = ordinates[j]; } } @@ -2703,7 +2439,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) { Q_ASSERT( nOrds % nDims == 0 ); - QVector< QPair > lines; + QVector> lines; bool isCurved = false; for ( int i = 0; i < nElems; i += 3 ) @@ -2717,29 +2453,28 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) if ( parts.empty() ) continue; - if ( baseType == WKBCompoundCurve || baseType == WKBCompoundCurveZ || - baseType == WKBCircularString || baseType == WKBCircularStringZ ) + if ( baseType == WKBCompoundCurve || baseType == WKBCompoundCurveZ || baseType == WKBCircularString || baseType == WKBCircularStringZ ) { isCurved = true; } lines << qMakePair( baseType, parts ); } - int binarySize = 1 + sizeof( int ) ; + int binarySize = 1 + sizeof( int ); if ( iType == GtMultiLine ) binarySize += sizeof( int ); for ( int partIndex = 0; partIndex < lines.size(); ++partIndex ) { if ( iType == GtMultiLine ) binarySize += 1 + sizeof( int ); - auto &line = lines[ partIndex ]; + auto &line = lines[partIndex]; if ( line.first == WKBCompoundCurve || line.first == WKBCompoundCurveZ ) { binarySize += sizeof( int ); for ( int partNum = 0; partNum < line.second.size() - 1; ++partNum ) { - line.second[ partNum ].second.append( line.second.at( partNum + 1 ).second.first() ); + line.second[partNum].second.append( line.second.at( partNum + 1 ).second.first() ); } } @@ -2804,7 +2539,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) if ( iType == GtPolygon || iType == GtMultiPolygon ) { - QVector< QPair< WKBType, SurfaceRings > > parts; + QVector> parts; SurfaceRings currentPart; WKBType currentPartWkbType = WKBUnknown; @@ -2834,9 +2569,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) points.reserve( 1 + ( endOffset - startOffset ) / nDims ); for ( int j = startOffset; j < endOffset; j += nDims ) { - double x = ordinates[ j ]; - double y = ordinates[ j + 1 ]; - double z = nDims > 2 ? ordinates[ j + 2] : 0; + double x = ordinates[j]; + double y = ordinates[j + 1]; + double z = nDims > 2 ? ordinates[j + 2] : 0; points << Point( x, y, z ); } WKBType type = WKBUnknown; @@ -2844,7 +2579,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) { // linear ring type = nDims == 2 ? WKBLineString - : WKBLineString25D; + : WKBLineString25D; if ( currentPartWkbType == WKBUnknown ) currentPartWkbType = nDims == 2 ? WKBPolygon : WKBPolygon25D; } @@ -2853,7 +2588,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) // circular arc ring isCurved = true; type = nDims == 2 ? WKBCircularString - : WKBCircularStringZ; + : WKBCircularStringZ; currentPartWkbType = nDims == 2 ? WKBCurvePolygon : WKBCurvePolygonZ; } @@ -2862,10 +2597,10 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) else if ( etype % 1000 == 3 && n == 3 ) { // Rectangle - expand to a polygon with 5 points - double x0 = ordinates[ startOffset + 0 ]; - double y0 = ordinates[ startOffset + 1 ]; - double x1 = ordinates[ startOffset + nDims + 0 ]; - double y1 = ordinates[ startOffset + nDims + 1 ]; + double x0 = ordinates[startOffset + 0]; + double y0 = ordinates[startOffset + 1]; + double x1 = ordinates[startOffset + nDims + 0]; + double y1 = ordinates[startOffset + nDims + 1]; PointSequence points; points.reserve( 5 ); @@ -2882,12 +2617,12 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) { // Circle isCurved = true; - double x0 = ordinates[ startOffset + 0 ]; - double y0 = ordinates[ startOffset + 1 ]; - double x1 = ordinates[ startOffset + nDims + 0 ]; - double y1 = ordinates[ startOffset + nDims + 1 ]; - double x2 = ordinates[ startOffset + 2 * nDims + 0 ]; - double y2 = ordinates[ startOffset + 2 * nDims + 1 ]; + double x0 = ordinates[startOffset + 0]; + double y0 = ordinates[startOffset + 1]; + double x1 = ordinates[startOffset + nDims + 0]; + double y1 = ordinates[startOffset + nDims + 1]; + double x2 = ordinates[startOffset + 2 * nDims + 0]; + double y2 = ordinates[startOffset + 2 * nDims + 1]; currentPartWkbType = WKBCurvePolygon; currentPart << qMakePair( WKBCircularString, CurveParts() << qMakePair( WKBCircularString, circlePoints( x0, y0, x1, y1, x2, y2 ) ) ); } @@ -2909,16 +2644,14 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) if ( etype == 2 && ( n == 1 || n == 2 ) ) { - WKBType partType = ( n == 1 ) ? - ( nDims == 2 ? WKBLineString : WKBLineString25D ) : - ( nDims == 2 ? WKBCircularString : WKBCircularStringZ ); + WKBType partType = ( n == 1 ) ? ( nDims == 2 ? WKBLineString : WKBLineString25D ) : ( nDims == 2 ? WKBCircularString : WKBCircularStringZ ); PointSequence points; points.reserve( 1 + ( endOffset - startOffset ) / nDims ); for ( int j = startOffset; j < endOffset; j += nDims ) { - double x = ordinates[ j ]; - double y = ordinates[ j + 1 ]; - double z = nDims > 2 ? ordinates[ j + 2] : 0; + double x = ordinates[j]; + double y = ordinates[j + 1]; + double z = nDims > 2 ? ordinates[j + 2] : 0; points << Point( x, y, z ); } parts << qMakePair( partType, points ); @@ -2949,30 +2682,30 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) wkbSize += sizeof( int ); for ( int part = 0; part < nPolygons; ++part ) { - SurfaceRings &rings = parts[ part ].second; + SurfaceRings &rings = parts[part].second; if ( isMultiPolygon ) wkbSize += 1 + sizeof( int ); wkbSize += sizeof( int ); for ( int ringIdx = 0; ringIdx < rings.size(); ++ringIdx ) { - CurveParts &ring = rings[ ringIdx ].second; + CurveParts &ring = rings[ringIdx].second; - if ( parts[ part ].first == WKBCurvePolygon || parts[ part ].first == WKBCurvePolygonZ ) + if ( parts[part].first == WKBCurvePolygon || parts[part].first == WKBCurvePolygonZ ) { wkbSize += 1 + sizeof( int ); } - if ( rings[ ringIdx ].first == WKBCompoundCurve || rings[ ringIdx ].first == WKBCompoundCurveZ ) + if ( rings[ringIdx].first == WKBCompoundCurve || rings[ringIdx].first == WKBCompoundCurveZ ) { wkbSize += sizeof( int ); for ( int partNum = 0; partNum < ring.size() - 1; ++partNum ) { - ring[ partNum ].second.append( ring.at( partNum + 1 ).second.first() ); + ring[partNum].second.append( ring.at( partNum + 1 ).second.first() ); } } for ( const CurvePart &curvePart : qAsConst( ring ) ) { - if ( rings[ ringIdx ].first == WKBCompoundCurve || rings[ ringIdx ].first == WKBCompoundCurveZ ) + if ( rings[ringIdx].first == WKBCompoundCurve || rings[ringIdx].first == WKBCompoundCurveZ ) wkbSize += 1 + sizeof( int ); wkbSize += sizeof( int ) + curvePart.second.size() * nDims * sizeof( double ); } @@ -3002,7 +2735,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) *ptr.iPtr++ = nPolygons; } - for ( const QPair< WKBType, SurfaceRings > &rings : qAsConst( parts ) ) + for ( const QPair &rings : qAsConst( parts ) ) { if ( isMultiPolygon ) { @@ -3011,7 +2744,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index ) } *ptr.iPtr++ = rings.second.size(); - for ( const QPair< WKBType, CurveParts > &ring : rings.second ) + for ( const QPair &ring : rings.second ) { if ( rings.first == WKBCurvePolygon || rings.first == WKBCurvePolygonZ ) { @@ -3061,8 +2794,7 @@ inline bool doubleNear( double a, double b, double epsilon ) QOCISpatialCols::PointSequence QOCISpatialCols::circlePoints( double x1, double y1, double x2, double y2, double x3, double y3 ) { - auto isPerpendicular = []( double x1, double y1, double x2, double y2, double x3, double y3 )->bool - { + auto isPerpendicular = []( double x1, double y1, double x2, double y2, double x3, double y3 ) -> bool { // check the given point are perpendicular to x or y axis double yDelta_a = y2 - y1; @@ -3095,8 +2827,7 @@ QOCISpatialCols::PointSequence QOCISpatialCols::circlePoints( double x1, double return false; }; - auto toCircularStringPoints = []( double centerX, double centerY, double radius ) -> PointSequence - { + auto toCircularStringPoints = []( double centerX, double centerY, double radius ) -> PointSequence { PointSequence sequence; sequence.append( Point( centerX, centerY + radius ) ); sequence.append( Point( centerX + radius, centerY ) ); @@ -3108,7 +2839,6 @@ QOCISpatialCols::PointSequence QOCISpatialCols::circlePoints( double x1, double if ( !isPerpendicular( x1, y1, x2, y2, x3, y3 ) ) { - } else if ( !isPerpendicular( x1, y1, x3, y3, x2, y2 ) ) { @@ -3190,16 +2920,8 @@ QOCISpatialCols::PointSequence QOCISpatialCols::circlePoints( double x1, double return PointSequence(); } - centerX = ( - ( aSlope * bSlope * ( y1 - y3 ) + - bSlope * ( x1 + x2 ) - - aSlope * ( x2 + x3 ) ) / - ( 2.0 * ( bSlope - aSlope ) ) - ); - centerY = ( - -1.0 * ( centerX - ( x1 + x2 ) / 2.0 ) / - aSlope + ( y1 + y2 ) / 2.0 - ); + centerX = ( ( aSlope * bSlope * ( y1 - y3 ) + bSlope * ( x1 + x2 ) - aSlope * ( x2 + x3 ) ) / ( 2.0 * ( bSlope - aSlope ) ) ); + centerY = ( -1.0 * ( centerX - ( x1 + x2 ) / 2.0 ) / aSlope + ( y1 + y2 ) / 2.0 ); radius = std::sqrt( ( centerX - x1 ) * ( centerX - x1 ) + ( centerY - y1 ) * ( centerY - y1 ) ); return toCircularStringPoints( centerX, centerY, radius ); @@ -3217,8 +2939,8 @@ void QOCISpatialCols::getValues( QVector &v, int index ) { // got a NULL value qDebug() << "NULL"; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - v[index + i] = static_cast< QVariant::Type >( fld.typ ); +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + v[index + i] = static_cast( fld.typ ); #else v[index + i] = QVariant( QMetaType( fld.typ ) ); #endif @@ -3254,8 +2976,7 @@ void QOCISpatialCols::getValues( QVector &v, int index ) && ( fld.typ == QMetaType::Type::LongLong ) ) { qint64 qll = 0; - int r = OCINumberToInt( d->err, reinterpret_cast( fld.data ), sizeof( qint64 ), - OCI_NUMBER_SIGNED, &qll ); + int r = OCINumberToInt( d->err, reinterpret_cast( fld.data ), sizeof( qint64 ), OCI_NUMBER_SIGNED, &qll ); if ( r == OCI_SUCCESS ) { v[index + i] = qll; @@ -3288,7 +3009,7 @@ void QOCISpatialCols::getValues( QVector &v, int index ) if ( fld.oraType == SQLT_NTY && fld.oraTypeName == "SDO_GEOMETRY" ) { qDebug() << "SQLT_NTY SDO_GEOMETRY"; - convertToWkb( v[ index + i ], gcindex++ ); + convertToWkb( v[index + i], gcindex++ ); } else { @@ -3296,7 +3017,7 @@ void QOCISpatialCols::getValues( QVector &v, int index ) if ( fld.len > 0 ) v[index + i] = QByteArray( fld.data, fld.len ); else -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) v[index + i] = QVariant( QVariant::ByteArray ); #else v[index + i] = QVariant( QMetaType( QMetaType::Type::QByteArray ) ); @@ -3313,7 +3034,7 @@ void QOCISpatialCols::getValues( QVector &v, int index ) QOCISpatialResultPrivate::QOCISpatialResultPrivate( QOCISpatialResult *q, const QOCISpatialDriver *drv ) : QSqlCachedResultPrivate( q, drv ) , env( drv_d_func()->env ) - , svc( const_cast( drv_d_func()->svc ) ) + , svc( const_cast( drv_d_func()->svc ) ) , transaction( drv_d_func()->transaction ) , commitOnSuccess( drv_d_func()->commitOnSuccess ) , serverVersion( drv_d_func()->serverVersion ) @@ -3322,11 +3043,7 @@ QOCISpatialResultPrivate::QOCISpatialResultPrivate( QOCISpatialResult *q, const , geometryTDO( drv_d_func()->geometryTDO ) { ENTER - int r = OCIHandleAlloc( env, - reinterpret_cast( &err ), - OCI_HTYPE_ERROR, - 0, - nullptr ); + int r = OCIHandleAlloc( env, reinterpret_cast( &err ), OCI_HTYPE_ERROR, 0, nullptr ); if ( r != OCI_SUCCESS ) qWarning( "QOCISpatialResult: unable to alloc error handle" ); } @@ -3360,17 +3077,13 @@ QOCISpatialResultPrivate::~QOCISpatialResultPrivate() //////////////////////////////////////////////////////////////////////////// QOCISpatialResult::QOCISpatialResult( const QOCISpatialDriver *db ) - : QSqlCachedResult( *new QOCISpatialResultPrivate( this, db ) ) -{ - ENTER -} + : QSqlCachedResult( *new QOCISpatialResultPrivate( this, db ) ) { + ENTER + } -QOCISpatialResult::~QOCISpatialResult() -{ - ENTER -} + QOCISpatialResult::~QOCISpatialResult() { ENTER } -QVariant QOCISpatialResult::handle() const + QVariant QOCISpatialResult::handle() const { ENTER return QVariant::fromValue( d_func()->sql ); @@ -3424,9 +3137,7 @@ bool QOCISpatialResult::gotoNext( QSqlCachedResult::ValueCache &values, int inde default: qOraWarning( "QOCISpatialResult::gotoNext: ", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to goto next" ), - QSqlError::StatementError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to goto next" ), QSqlError::StatementError, d->err ) ); break; } @@ -3453,12 +3164,7 @@ int QOCISpatialResult::size() ENTER Q_D( QOCISpatialResult ); int rowCount; - if ( OCIAttrGet( d->sql, - OCI_HTYPE_STMT, - &rowCount, - nullptr, - OCI_ATTR_ROWS_FETCHED, - d->err ) == OCI_SUCCESS ) + if ( OCIAttrGet( d->sql, OCI_HTYPE_STMT, &rowCount, nullptr, OCI_ATTR_ROWS_FETCHED, d->err ) == OCI_SUCCESS ) { return rowCount; } @@ -3473,12 +3179,7 @@ int QOCISpatialResult::numRowsAffected() ENTER Q_D( QOCISpatialResult ); int rowCount; - OCIAttrGet( d->sql, - OCI_HTYPE_STMT, - &rowCount, - nullptr, - OCI_ATTR_ROW_COUNT, - d->err ); + OCIAttrGet( d->sql, OCI_HTYPE_STMT, &rowCount, nullptr, OCI_ATTR_ROW_COUNT, d->err ); return rowCount; } @@ -3515,32 +3216,21 @@ bool QOCISpatialResult::prepare( const QString &query ) } if ( query.isEmpty() ) return false; - r = OCIHandleAlloc( d->env, - reinterpret_cast( &d->sql ), - OCI_HTYPE_STMT, - 0, - nullptr ); + r = OCIHandleAlloc( d->env, reinterpret_cast( &d->sql ), OCI_HTYPE_STMT, 0, nullptr ); if ( r != OCI_SUCCESS ) { qOraWarning( "QOCISpatialResult::prepare: unable to alloc statement:", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to alloc statement" ), QSqlError::StatementError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to alloc statement" ), QSqlError::StatementError, d->err ) ); return false; } d->setStatementAttributes(); const OraText *txt = reinterpret_cast( query.utf16() ); const int len = query.length() * sizeof( QChar ); - r = OCIStmtPrepare( d->sql, - d->err, - txt, - len, - OCI_NTV_SYNTAX, - OCI_DEFAULT ); + r = OCIStmtPrepare( d->sql, d->err, txt, len, OCI_NTV_SYNTAX, OCI_DEFAULT ); if ( r != OCI_SUCCESS ) { qOraWarning( "QOCISpatialResult::prepare: unable to prepare statement:", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to prepare statement" ), QSqlError::StatementError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to prepare statement" ), QSqlError::StatementError, d->err ) ); return false; } @@ -3559,18 +3249,12 @@ bool QOCISpatialResult::exec() IndicatorArray indicators( boundValueCount() ); SizeArray tmpSizes( boundValueCount() ); - r = OCIAttrGet( d->sql, - OCI_HTYPE_STMT, - &stmtType, - nullptr, - OCI_ATTR_STMT_TYPE, - d->err ); + r = OCIAttrGet( d->sql, OCI_HTYPE_STMT, &stmtType, nullptr, OCI_ATTR_STMT_TYPE, d->err ); if ( r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO ) { qOraWarning( "QOCISpatialResult::exec: Unable to get statement type:", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to get statement type" ), QSqlError::StatementError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to get statement type" ), QSqlError::StatementError, d->err ) ); qWarning( "type retrieval failed with statement:%s", lastQuery().toLocal8Bit().constData() ); return false; } @@ -3585,26 +3269,17 @@ bool QOCISpatialResult::exec() && d->bindValues( boundValues(), indicators, tmpSizes, tmpStorage ) != OCI_SUCCESS ) { qOraWarning( "QOCISpatialResult::exec: unable to bind value: ", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to bind value" ), - QSqlError::StatementError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to bind value" ), QSqlError::StatementError, d->err ) ); qWarning( "bind failed with statement:%s", lastQuery().toLocal8Bit().constData() ); return false; } // execute - r = OCIStmtExecute( d->svc, - d->sql, - d->err, - iters, - 0, - nullptr, - nullptr, - mode ); + r = OCIStmtExecute( d->svc, d->sql, d->err, iters, 0, nullptr, nullptr, mode ); if ( r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO ) { qOraWarning( "QOCISpatialResult::exec: unable to execute statement:", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", - "Unable to execute statement" ), QSqlError::StatementError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to execute statement" ), QSqlError::StatementError, d->err ) ); qWarning( "execution failed with statement:%s", lastQuery().toLocal8Bit().constData() ); return false; } @@ -3612,8 +3287,7 @@ bool QOCISpatialResult::exec() if ( stmtType == OCI_STMT_SELECT ) { ub4 parmCount = 0; - int r = OCIAttrGet( d->sql, OCI_HTYPE_STMT, reinterpret_cast( &parmCount ), - nullptr, OCI_ATTR_PARAM_COUNT, d->err ); + int r = OCIAttrGet( d->sql, OCI_HTYPE_STMT, reinterpret_cast( &parmCount ), nullptr, OCI_ATTR_PARAM_COUNT, d->err ); if ( r == OCI_SUCCESS && !d->cols ) { d->sdoobj.clear(); @@ -3625,7 +3299,7 @@ bool QOCISpatialResult::exec() setSelect( true ); QSqlCachedResult::init( parmCount ); } - else /* non-SELECT */ + else /* non-SELECT */ { setSelect( false ); } @@ -3656,8 +3330,7 @@ QVariant QOCISpatialResult::lastInsertId() const { QOCISpatialRowIdPointer ptr( new QOCISpatialRowId( d->env ) ); - int r = OCIAttrGet( d->sql, OCI_HTYPE_STMT, ptr.constData()->id, - nullptr, OCI_ATTR_ROWID, d->err ); + int r = OCIAttrGet( d->sql, OCI_HTYPE_STMT, ptr.constData()->id, nullptr, OCI_ATTR_ROWID, d->err ); if ( r == OCI_SUCCESS ) return QVariant::fromValue( ptr ); } @@ -3693,19 +3366,11 @@ QOCISpatialDriver::QOCISpatialDriver( QObject *parent ) #else const ub4 mode = OCI_UTF16 | OCI_OBJECT; #endif - int r = OCIEnvCreate( &d->env, - mode, - nullptr, - nullptr, - nullptr, - nullptr, - 0, - nullptr ); + int r = OCIEnvCreate( &d->env, mode, nullptr, nullptr, nullptr, nullptr, 0, nullptr ); if ( r != OCI_SUCCESS ) { qWarning( "QOCISpatialDriver: unable to create environment" ); - setLastError( qMakeError( tr( "Unable to initialize", "QOCISpatialDriver" ), - QSqlError::ConnectionError, d->err ) ); + setLastError( qMakeError( tr( "Unable to initialize", "QOCISpatialDriver" ), QSqlError::ConnectionError, d->err ) ); return; } @@ -3783,8 +3448,7 @@ static void qParseOpts( const QString &options, QOCISpatialDriverPrivate *d ) int idx; if ( ( idx = tmp.indexOf( QLatin1Char( '=' ) ) ) == -1 ) { - qWarning( "QOCISpatialDriver::parseArgs: Invalid parameter: '%s'", - tmp.toLocal8Bit().constData() ); + qWarning( "QOCISpatialDriver::parseArgs: Invalid parameter: '%s'", tmp.toLocal8Bit().constData() ); continue; } const QString opt = tmp.left( idx ); @@ -3812,18 +3476,12 @@ static void qParseOpts( const QString &options, QOCISpatialDriverPrivate *d ) } else { - qWarning( "QOCISpatialDriver::parseArgs: Invalid parameter: '%s'", - opt.toLocal8Bit().constData() ); + qWarning( "QOCISpatialDriver::parseArgs: Invalid parameter: '%s'", opt.toLocal8Bit().constData() ); } } } -bool QOCISpatialDriver::open( const QString &db, - const QString &user, - const QString &password, - const QString &hostname, - int port, - const QString &opts ) +bool QOCISpatialDriver::open( const QString &db, const QString &user, const QString &password, const QString &hostname, int port, const QString &opts ) { ENTER Q_D( QOCISpatialDriver ); @@ -3837,14 +3495,15 @@ bool QOCISpatialDriver::open( const QString &db, // Connect without tnsnames.ora if a hostname is given QString connectionString = db; if ( !hostname.isEmpty() ) - connectionString = - QString::fromLatin1( "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=%1)(Port=%2))" - "(CONNECT_DATA=(SID=%3)))" ).arg( hostname ).arg( ( port > -1 ? port : 1521 ) ).arg( db ); + connectionString = QString::fromLatin1( "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=%1)(Port=%2))" + "(CONNECT_DATA=(SID=%3)))" ) + .arg( hostname ) + .arg( ( port > -1 ? port : 1521 ) ) + .arg( db ); r = OCIHandleAlloc( d->env, reinterpret_cast( &d->srvhp ), OCI_HTYPE_SERVER, 0, nullptr ); if ( r == OCI_SUCCESS ) - r = OCIServerAttach( d->srvhp, d->err, reinterpret_cast( connectionString.utf16() ), - connectionString.length() * sizeof( QChar ), OCI_DEFAULT ); + r = OCIServerAttach( d->srvhp, d->err, reinterpret_cast( connectionString.utf16() ), connectionString.length() * sizeof( QChar ), OCI_DEFAULT ); if ( r == OCI_SUCCESS || r == OCI_SUCCESS_WITH_INFO ) r = OCIHandleAlloc( d->env, reinterpret_cast( &d->svc ), OCI_HTYPE_SVCCTX, 0, nullptr ); if ( r == OCI_SUCCESS ) @@ -3852,11 +3511,9 @@ bool QOCISpatialDriver::open( const QString &db, if ( r == OCI_SUCCESS ) r = OCIHandleAlloc( d->env, reinterpret_cast( &d->authp ), OCI_HTYPE_SESSION, 0, nullptr ); if ( r == OCI_SUCCESS ) - r = OCIAttrSet( d->authp, OCI_HTYPE_SESSION, const_cast( user.utf16() ), - user.length() * sizeof( QChar ), OCI_ATTR_USERNAME, d->err ); + r = OCIAttrSet( d->authp, OCI_HTYPE_SESSION, const_cast( user.utf16() ), user.length() * sizeof( QChar ), OCI_ATTR_USERNAME, d->err ); if ( r == OCI_SUCCESS ) - r = OCIAttrSet( d->authp, OCI_HTYPE_SESSION, const_cast( password.utf16() ), - password.length() * sizeof( QChar ), OCI_ATTR_PASSWORD, d->err ); + r = OCIAttrSet( d->authp, OCI_HTYPE_SESSION, const_cast( password.utf16() ), password.length() * sizeof( QChar ), OCI_ATTR_PASSWORD, d->err ); OCITrans *trans = nullptr; if ( r == OCI_SUCCESS ) @@ -3905,11 +3562,7 @@ bool QOCISpatialDriver::open( const QString &db, // get server version char vertxt[512]; - r = OCIServerVersion( d->svc, - d->err, - reinterpret_cast( vertxt ), - sizeof( vertxt ), - OCI_HTYPE_SVCCTX ); + r = OCIServerVersion( d->svc, d->err, reinterpret_cast( vertxt ), sizeof( vertxt ), OCI_HTYPE_SVCCTX ); if ( r != OCI_SUCCESS ) { qWarning( "QOCISpatialDriver::open: could not get Oracle server version." ); @@ -3967,15 +3620,11 @@ bool QOCISpatialDriver::beginTransaction() qWarning( "QOCISpatialDriver::beginTransaction: Database not open" ); return false; } - int r = OCITransStart( d->svc, - d->err, - 2, - OCI_TRANS_READWRITE ); + int r = OCITransStart( d->svc, d->err, 2, OCI_TRANS_READWRITE ); if ( r == OCI_ERROR ) { qOraWarning( "QOCISpatialDriver::beginTransaction: ", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialDriver", - "Unable to begin transaction" ), QSqlError::TransactionError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialDriver", "Unable to begin transaction" ), QSqlError::TransactionError, d->err ) ); return false; } d->transaction = true; @@ -3991,14 +3640,11 @@ bool QOCISpatialDriver::commitTransaction() qWarning( "QOCISpatialDriver::commitTransaction: Database not open" ); return false; } - int r = OCITransCommit( d->svc, - d->err, - 0 ); + int r = OCITransCommit( d->svc, d->err, 0 ); if ( r == OCI_ERROR ) { qOraWarning( "QOCISpatialDriver::commitTransaction:", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialDriver", - "Unable to commit transaction" ), QSqlError::TransactionError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialDriver", "Unable to commit transaction" ), QSqlError::TransactionError, d->err ) ); return false; } d->transaction = false; @@ -4014,14 +3660,11 @@ bool QOCISpatialDriver::rollbackTransaction() qWarning( "QOCISpatialDriver::rollbackTransaction: Database not open" ); return false; } - int r = OCITransRollback( d->svc, - d->err, - 0 ); + int r = OCITransRollback( d->svc, d->err, 0 ); if ( r == OCI_ERROR ) { qOraWarning( "QOCISpatialDriver::rollbackTransaction:", d->err ); - setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialDriver", - "Unable to rollback transaction" ), QSqlError::TransactionError, d->err ) ); + setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialDriver", "Unable to rollback transaction" ), QSqlError::TransactionError, d->err ) ); return false; } d->transaction = false; @@ -4036,8 +3679,7 @@ enum Expression static QString make_where_clause( const QString &user, Expression e ) { - static const char sysUsers[][8] = - { + static const char sysUsers[][8] = { "MDSYS", "LBACSYS", "SYS", @@ -4052,9 +3694,9 @@ static QString make_where_clause( const QString &user, Expression e ) const QLatin1String join( joinC[e], -1 ); // -1: force strlen call QString result; - result.reserve( sizeof sysUsers / sizeof * sysUsers * + result.reserve( sizeof sysUsers / sizeof *sysUsers * // max-sizeof(owner != and ) - ( 9 + sizeof * sysUsers + 5 ) ); + ( 9 + sizeof *sysUsers + 5 ) ); for ( const auto &sysUser : sysUsers ) { const QLatin1String l1( sysUser, -1 ); // -1: force strlen call @@ -4153,8 +3795,7 @@ QStringList QOCISpatialDriver::tables( QSql::TableType type ) const return tl; } -void qSplitTableAndOwner( const QString &tname, QString *tbl, - QString *owner ) +void qSplitTableAndOwner( const QString &tname, QString *tbl, QString *owner ) { ENTER int i = tname.indexOf( QLatin1Char( '.' ) ); // prefixed with owner? @@ -4215,9 +3856,8 @@ QSqlRecord QOCISpatialDriver::record( const QString &tablename ) const { stmt = stmt + QLatin1String( " join all_synonyms b " "on a.owner=b.table_owner and a.table_name=b.table_name " - "where b.owner='" ) + owner + - QLatin1String( "' and b.synonym_name='" ) + table + - QLatin1Char( '\'' ); + "where b.owner='" ) + + owner + QLatin1String( "' and b.synonym_name='" ) + table + QLatin1Char( '\'' ); t.setForwardOnly( true ); t.exec( stmt ); if ( t.next() ) @@ -4237,7 +3877,7 @@ QSqlRecord QOCISpatialDriver::record( const QString &tablename ) const do { QMetaType::Type ty = qDecodeOCIType( t.value( 1 ).toString(), t.numericalPrecisionPolicy() ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QSqlField f( t.value( 0 ).toString(), static_cast( ty ) ); #else QSqlField f( t.value( 0 ).toString(), QMetaType( ty ) ); @@ -4255,8 +3895,7 @@ QSqlRecord QOCISpatialDriver::record( const QString &tablename ) const } f.setDefaultValue( t.value( 6 ) ); fil.append( f ); - } - while ( t.next() ); + } while ( t.next() ); } return fil; } @@ -4301,7 +3940,8 @@ QSqlIndex QOCISpatialDriver::primaryIndex( const QString &tablename ) const if ( !t.next() ) { stmt += QLatin1String( " and a.table_name=(select tname from sys.synonyms " - "where sname='" ) + table + QLatin1String( "' and creator=a.owner)" ); + "where sname='" ) + + table + QLatin1String( "' and creator=a.owner)" ); t.setForwardOnly( true ); t.exec( stmt ); if ( t.next() ) @@ -4321,23 +3961,19 @@ QSqlIndex QOCISpatialDriver::primaryIndex( const QString &tablename ) const idx.setName( t.value( 1 ).toString() ); do { - tt.exec( QLatin1String( "select data_type from all_tab_columns where table_name='" ) + - t.value( 2 ).toString() + QLatin1String( "' and column_name='" ) + - t.value( 0 ).toString() + QLatin1String( "' and owner='" ) + - owner + QLatin1Char( '\'' ) ); + tt.exec( QLatin1String( "select data_type from all_tab_columns where table_name='" ) + t.value( 2 ).toString() + QLatin1String( "' and column_name='" ) + t.value( 0 ).toString() + QLatin1String( "' and owner='" ) + owner + QLatin1Char( '\'' ) ); if ( !tt.next() ) { return QSqlIndex(); } QMetaType::Type ty = qDecodeOCIType( tt.value( 0 ).toString(), t.numericalPrecisionPolicy() ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QSqlField f( t.value( 0 ).toString(), static_cast( ty ) ); #else QSqlField f( t.value( 0 ).toString(), QMetaType( ty ) ); #endif idx.append( f ); - } - while ( t.next() ); + } while ( t.next() ); return idx; } return QSqlIndex(); @@ -4346,7 +3982,7 @@ QSqlIndex QOCISpatialDriver::primaryIndex( const QString &tablename ) const QString QOCISpatialDriver::formatValue( const QSqlField &field, bool trimStrings ) const { ENTER -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) switch ( static_cast( field.type() ) ) #else switch ( field.metaType().id() ) @@ -4397,10 +4033,7 @@ QString QOCISpatialDriver::formatValue( const QSqlField &field, bool trimStrings QString datestring; if ( date.isValid() ) { - datestring = QLatin1String( "TO_DATE('" ) + QString::number( date.year() ) + - QLatin1Char( '-' ) + - QString::number( date.month() ) + QLatin1Char( '-' ) + - QString::number( date.day() ) + QLatin1String( "','YYYY-MM-DD')" ); + datestring = QLatin1String( "TO_DATE('" ) + QString::number( date.year() ) + QLatin1Char( '-' ) + QString::number( date.month() ) + QLatin1Char( '-' ) + QString::number( date.day() ) + QLatin1String( "','YYYY-MM-DD')" ); } else { diff --git a/src/providers/oracle/ocispatial/qsql_ocispatial.h b/src/providers/oracle/ocispatial/qsql_ocispatial.h index f0800a6108f6..9b6e92b7620f 100644 --- a/src/providers/oracle/ocispatial/qsql_ocispatial.h +++ b/src/providers/oracle/ocispatial/qsql_ocispatial.h @@ -70,19 +70,13 @@ class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialDriver : public QSqlDriver QOCISpatialDriver( OCIEnv *env, OCISvcCtx *ctx, QObject *parent = nullptr ); ~QOCISpatialDriver() override; bool hasFeature( DriverFeature f ) const override; - bool open( const QString &db, - const QString &user, - const QString &password, - const QString &host, - int port, - const QString &connOpts ) override; + bool open( const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts ) override; void close() override; QSqlResult *createResult() const override; QStringList tables( QSql::TableType ) const override; QSqlRecord record( const QString &tablename ) const override; QSqlIndex primaryIndex( const QString &tablename ) const override; - QString formatValue( const QSqlField &field, - bool trimStrings ) const override; + QString formatValue( const QSqlField &field, bool trimStrings ) const override; QVariant handle() const override; QString escapeIdentifier( const QString &identifier, IdentifierType ) const override; @@ -90,7 +84,6 @@ class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialDriver : public QSqlDriver bool beginTransaction() override; bool commitTransaction() override; bool rollbackTransaction() override; - }; QT_END_NAMESPACE diff --git a/src/providers/oracle/ocispatial/wkbptr.h b/src/providers/oracle/ocispatial/wkbptr.h index be5f71d672a4..0253b08ee3ef 100644 --- a/src/providers/oracle/ocispatial/wkbptr.h +++ b/src/providers/oracle/ocispatial/wkbptr.h @@ -22,19 +22,19 @@ union wkbPtr { - void *vPtr = nullptr; - double *dPtr; - int *iPtr; - unsigned char *ucPtr; - char *cPtr; + void *vPtr = nullptr; + double *dPtr; + int *iPtr; + unsigned char *ucPtr; + char *cPtr; }; const int SDO_ARRAY_SIZE = 1024; -#define SDO_GTYPE_D(g) (g/1000%10) -#define SDO_GTYPE_L(g) (g/100%10) -#define SDO_GTYPE_TT(g) (g%100) -#define SDO_GTYPE(g,tt) (g*1000+tt) +#define SDO_GTYPE_D( g ) ( g / 1000 % 10 ) +#define SDO_GTYPE_L( g ) ( g / 100 % 10 ) +#define SDO_GTYPE_TT( g ) ( g % 100 ) +#define SDO_GTYPE( g, tt ) ( g * 1000 + tt ) enum SDO_GTYPE_TT { diff --git a/src/providers/oracle/qgsoraclecolumntypetask.cpp b/src/providers/oracle/qgsoraclecolumntypetask.cpp index 30dc01218507..0e321a3719cb 100644 --- a/src/providers/oracle/qgsoraclecolumntypetask.cpp +++ b/src/providers/oracle/qgsoraclecolumntypetask.cpp @@ -44,19 +44,14 @@ bool QgsOracleColumnTypeTask::run() emit progressMessage( tr( "Retrieving tables of %1…" ).arg( mName ) ); QVector layerProperties; - if ( !conn->supportedLayers( layerProperties, - mSchema, - QgsOracleConn::geometryColumnsOnly( mName ), - QgsOracleConn::userTablesOnly( mName ), - mAllowGeometrylessTables ) || - layerProperties.isEmpty() ) + if ( !conn->supportedLayers( layerProperties, mSchema, QgsOracleConn::geometryColumnsOnly( mName ), QgsOracleConn::userTablesOnly( mName ), mAllowGeometrylessTables ) || layerProperties.isEmpty() ) { return false; } int i = 0, n = layerProperties.size(); for ( QVector::iterator it = layerProperties.begin(), - end = layerProperties.end(); + end = layerProperties.end(); it != end; ++it ) { QgsOracleLayerProperty &layerProperty = *it; @@ -64,9 +59,7 @@ bool QgsOracleColumnTypeTask::run() { setProgress( ( i * 100. ) / n ); emit progressMessage( tr( "Scanning column %1.%2.%3…" ) - .arg( layerProperty.ownerName, - layerProperty.tableName, - layerProperty.geometryColName ) ); + .arg( layerProperty.ownerName, layerProperty.tableName, layerProperty.geometryColName ) ); conn->retrieveLayerTypes( layerProperty, mUseEstimatedMetadata, QgsOracleConn::onlyExistingTypes( mName ) ); } diff --git a/src/providers/oracle/qgsoraclecolumntypetask.h b/src/providers/oracle/qgsoraclecolumntypetask.h index 0aa9a03e3619..dddb10f579df 100644 --- a/src/providers/oracle/qgsoraclecolumntypetask.h +++ b/src/providers/oracle/qgsoraclecolumntypetask.h @@ -28,7 +28,6 @@ class QgsOracleColumnTypeTask : public QgsTask { Q_OBJECT public: - /** * * \param connName @@ -36,10 +35,7 @@ class QgsOracleColumnTypeTask : public QgsTask * \param useEstimatedMetaData * \param allowGeometrylessTables */ - QgsOracleColumnTypeTask( const QString &connName, - const QString &limitToSchema, - bool useEstimatedMetaData, - bool allowGeometrylessTables ); + QgsOracleColumnTypeTask( const QString &connName, const QString &limitToSchema, bool useEstimatedMetaData, bool allowGeometrylessTables ); // These functions get the layer types and pass that information out // by emitting the setLayerType() signal. diff --git a/src/providers/oracle/qgsoracleconn.cpp b/src/providers/oracle/qgsoracleconn.cpp index 1a86fbb55130..eb0a930d4256 100644 --- a/src/providers/oracle/qgsoracleconn.cpp +++ b/src/providers/oracle/qgsoracleconn.cpp @@ -99,7 +99,7 @@ QgsOracleConn::QgsOracleConn( const QgsDataSourceUri &uri, bool transaction ) if ( sBrokenConnections.contains( mConnInfo ) ) { QDateTime now( QDateTime::currentDateTime() ); - QDateTime since( sBrokenConnections[ mConnInfo ] ); + QDateTime since( sBrokenConnections[mConnInfo] ); QgsDebugError( QStringLiteral( "Broken since %1 [%2s ago]" ).arg( since.toString( Qt::ISODate ) ).arg( since.secsTo( now ) ) ); if ( since.secsTo( now ) < 30 ) @@ -156,8 +156,7 @@ QgsOracleConn::QgsOracleConn( const QgsDataSourceUri &uri, bool transaction ) } QSqlQuery qry( mDatabase ); - if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, QStringLiteral( "alter session set nls_date_format = 'yyyy-mm-dd\"T\"HH24:MI:ss'" ), - QVariantList() ) ) + if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, QStringLiteral( "alter session set nls_date_format = 'yyyy-mm-dd\"T\"HH24:MI:ss'" ), QVariantList() ) ) { mDatabase.close(); const QString error { tr( "Error: Failed to switch the default format date to ISO" ) }; @@ -242,10 +241,10 @@ QString QgsOracleConn::getLastExecutedQuery( const QSqlQuery &query ) for ( QVariant value : query.boundValues() ) { const QVariant &var { value.toString() }; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QSqlField field( QString( ), var.type() ); +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + QSqlField field( QString(), var.type() ); #else - QSqlField field( QString( ), var.metaType() ); + QSqlField field( QString(), var.metaType() ); #endif if ( var.isNull() ) @@ -283,12 +282,10 @@ bool QgsOracleConn::exec( QSqlQuery &qry, const QString &sql, const QVariantList if ( !res ) { QgsDebugError( QStringLiteral( "SQL: %1\nERROR: %2" ) - .arg( qry.lastQuery(), - qry.lastError().text() ) ); + .arg( qry.lastQuery(), qry.lastError().text() ) ); } return res; - } bool QgsOracleConn::execLogged( QSqlQuery &qry, const QString &sql, const QVariantList ¶ms, const QString &originatorClass, const QString &queryOrigin ) @@ -315,8 +312,7 @@ bool QgsOracleConn::execLogged( QSqlQuery &qry, const QString &sql, const QVaria { logWrapper.setError( qry.lastError().text() ); QgsDebugError( QStringLiteral( "SQL: %1\nERROR: %2" ) - .arg( qry.lastQuery(), - qry.lastError().text() ) ); + .arg( qry.lastQuery(), qry.lastError().text() ) ); } else { @@ -339,8 +335,7 @@ QStringList QgsOracleConn::pkCandidates( const QString &ownerName, const QString QSqlQuery qry( mDatabase ); - if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, QStringLiteral( "SELECT column_name FROM all_tab_columns WHERE owner=? AND table_name=? ORDER BY column_id" ), - QVariantList() << ownerName << viewName ) ) + if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, QStringLiteral( "SELECT column_name FROM all_tab_columns WHERE owner=? AND table_name=? ORDER BY column_id" ), QVariantList() << ownerName << viewName ) ) { const QString error { tr( "SQL: %1 [owner: %2 table_name: %3]\nerror: %4\n" ).arg( qry.lastQuery(), qry.lastError().text(), ownerName, viewName ) }; QgsMessageLog::logMessage( error, tr( "Oracle" ) ); @@ -366,17 +361,12 @@ bool QgsOracleConn::tableInfo( const QString &schema, bool geometryColumnsOnly, QString sql; QString prefix( userTablesOnly ? QStringLiteral( "user" ) : QStringLiteral( "all" ) ), - owner( userTablesOnly ? QStringLiteral( "user AS owner" ) : QStringLiteral( "c.owner" ) ); + owner( userTablesOnly ? QStringLiteral( "user AS owner" ) : QStringLiteral( "c.owner" ) ); sql = QStringLiteral( "SELECT %1,c.table_name,c.column_name,%2,o.object_type AS type" " FROM %3_%4 c" " JOIN %3_objects o ON c.table_name=o.object_name AND o.object_type IN ('TABLE','VIEW','SYNONYM')%5%6" ) - .arg( owner, - geometryColumnsOnly ? QStringLiteral( "c.srid" ) : QStringLiteral( "NULL AS srid" ), - prefix, - geometryColumnsOnly ? QStringLiteral( "sdo_geom_metadata" ) : QStringLiteral( "tab_columns" ), - userTablesOnly ? QString() : QStringLiteral( " AND c.owner=%1" ).arg( schema.isEmpty() ? QStringLiteral( "o.owner" ) : quotedValue( schema ) ), - geometryColumnsOnly ? QString() : QStringLiteral( " WHERE c.data_type='SDO_GEOMETRY'" ) ); + .arg( owner, geometryColumnsOnly ? QStringLiteral( "c.srid" ) : QStringLiteral( "NULL AS srid" ), prefix, geometryColumnsOnly ? QStringLiteral( "sdo_geom_metadata" ) : QStringLiteral( "tab_columns" ), userTablesOnly ? QString() : QStringLiteral( " AND c.owner=%1" ).arg( schema.isEmpty() ? QStringLiteral( "o.owner" ) : quotedValue( schema ) ), geometryColumnsOnly ? QString() : QStringLiteral( " WHERE c.data_type='SDO_GEOMETRY'" ) ); if ( allowGeometrylessTables ) { @@ -385,9 +375,7 @@ bool QgsOracleConn::tableInfo( const QString &schema, bool geometryColumnsOnly, " FROM %2_objects c WHERE c.object_type IN ('TABLE','VIEW','SYNONYM') " // get only geometry table without geometry column " AND NOT EXISTS( SELECT 1 FROM %2_tab_columns cols WHERE cols.table_name=c.object_name AND cols.data_type='SDO_GEOMETRY') %3" ) - .arg( owner, - prefix, - userTablesOnly || schema.isEmpty() ? QString() : QStringLiteral( " AND c.owner=%1" ).arg( quotedValue( schema ) ) ); + .arg( owner, prefix, userTablesOnly || schema.isEmpty() ? QString() : QStringLiteral( " AND c.owner=%1" ).arg( quotedValue( schema ) ) ); } QSqlQuery qry( mDatabase ); @@ -402,16 +390,15 @@ bool QgsOracleConn::tableInfo( const QString &schema, bool geometryColumnsOnly, while ( qry.next() ) { QgsOracleLayerProperty layerProperty; - layerProperty.ownerName = qry.value( 0 ).toString(); - layerProperty.tableName = qry.value( 1 ).toString(); + layerProperty.ownerName = qry.value( 0 ).toString(); + layerProperty.tableName = qry.value( 1 ).toString(); layerProperty.geometryColName = qry.value( 2 ).toString(); - layerProperty.types = QList() << ( qry.value( 2 ).isNull() ? Qgis::WkbType::NoGeometry : Qgis::WkbType::Unknown ); - layerProperty.srids = QList() << qry.value( 3 ).toInt(); - layerProperty.isView = qry.value( 4 ) != QLatin1String( "TABLE" ); + layerProperty.types = QList() << ( qry.value( 2 ).isNull() ? Qgis::WkbType::NoGeometry : Qgis::WkbType::Unknown ); + layerProperty.srids = QList() << qry.value( 3 ).toInt(); + layerProperty.isView = qry.value( 4 ) != QLatin1String( "TABLE" ); layerProperty.pkCols.clear(); mLayersSupported << layerProperty; - } @@ -511,14 +498,13 @@ bool QgsOracleConn::exec( const QString &query, bool logError, QString *errorMes if ( logError ) { const QString errorMsg { tr( "Connection error: %1 returned %2" ) - .arg( query, error ) }; - QgsMessageLog::logMessage( errorMsg, - tr( "Oracle" ) ); + .arg( query, error ) }; + QgsMessageLog::logMessage( errorMsg, tr( "Oracle" ) ); } else { const QString errorMsg { QStringLiteral( "Connection error: %1 returned %2" ) - .arg( query, error ) }; + .arg( query, error ) }; QgsDebugError( errorMsg ); } if ( errorMessage ) @@ -530,7 +516,6 @@ bool QgsOracleConn::exec( const QString &query, bool logError, QString *errorMes bool QgsOracleConn::execLogged( const QString &query, bool logError, QString *errorMessage, const QString &originatorClass, const QString &queryOrigin ) { - QMutexLocker locker( &mLock ); QgsDatabaseQueryLogWrapper logWrapper { query, mConnInfo, QStringLiteral( "oracle" ), originatorClass, queryOrigin }; @@ -542,21 +527,20 @@ bool QgsOracleConn::execLogged( const QString &query, bool logError, QString *er logWrapper.setQuery( qry.lastQuery() ); - if ( ! res ) + if ( !res ) { const QString error = qry.lastError().text(); logWrapper.setError( error ); if ( logError ) { const QString errorMsg { tr( "Connection error: %1 returned %2" ) - .arg( query, error ) }; - QgsMessageLog::logMessage( errorMsg, - tr( "Oracle" ) ); + .arg( query, error ) }; + QgsMessageLog::logMessage( errorMsg, tr( "Oracle" ) ); } else { const QString errorMsg { QStringLiteral( "Connection error: %1 returned %2" ) - .arg( query, error ) }; + .arg( query, error ) }; QgsDebugError( errorMsg ); } if ( errorMessage ) @@ -662,9 +646,7 @@ void QgsOracleConn::retrieveLayerTypes( QgsOracleLayerProperty &layerProperty, b layerProperty.pkCols = pkCandidates( layerProperty.ownerName, layerProperty.tableName ); if ( layerProperty.pkCols.isEmpty() ) { - QgsMessageLog::logMessage( tr( "View %1.%2 doesn't have integer columns for use as keys." ) - .arg( layerProperty.ownerName, layerProperty.tableName ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "View %1.%2 doesn't have integer columns for use as keys." ).arg( layerProperty.ownerName, layerProperty.tableName ), tr( "Oracle" ) ); } } @@ -677,17 +659,13 @@ void QgsOracleConn::retrieveLayerTypes( QgsOracleLayerProperty &layerProperty, b if ( useEstimatedMetadata ) { table = QStringLiteral( "(SELECT %1 FROM %2.%3 WHERE %1 IS NOT NULL%4 AND rownum<=%5)" ) - .arg( quotedIdentifier( layerProperty.geometryColName ), - quotedIdentifier( layerProperty.ownerName ), - quotedIdentifier( layerProperty.tableName ), - layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " AND (%1)" ).arg( layerProperty.sql ) ) - .arg( sGeomTypeSelectLimit ); + .arg( quotedIdentifier( layerProperty.geometryColName ), quotedIdentifier( layerProperty.ownerName ), quotedIdentifier( layerProperty.tableName ), layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " AND (%1)" ).arg( layerProperty.sql ) ) + .arg( sGeomTypeSelectLimit ); } else if ( !layerProperty.ownerName.isEmpty() ) { table = QStringLiteral( "%1.%2" ) - .arg( quotedIdentifier( layerProperty.ownerName ), - quotedIdentifier( layerProperty.tableName ) ); + .arg( quotedIdentifier( layerProperty.ownerName ), quotedIdentifier( layerProperty.tableName ) ); where = layerProperty.sql; } else @@ -721,16 +699,11 @@ void QgsOracleConn::retrieveLayerTypes( QgsOracleLayerProperty &layerProperty, b sql += QLatin1String( " FROM %2 t WHERE NOT t.%1 IS NULL%3" ); - if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, sql - .arg( quotedIdentifier( layerProperty.geometryColName ), - table, - where.isEmpty() ? QString() : QStringLiteral( " AND (%1)" ).arg( where ) ), QVariantList() ) ) + if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, sql.arg( quotedIdentifier( layerProperty.geometryColName ), table, where.isEmpty() ? QString() : QStringLiteral( " AND (%1)" ).arg( where ) ), QVariantList() ) ) { const QString error { tr( "SQL: %1\nerror: %2\n" ) - .arg( qry.lastQuery(), - qry.lastError().text() ) }; - QgsMessageLog::logMessage( error, - tr( "Oracle" ) ); + .arg( qry.lastQuery(), qry.lastError().text() ) }; + QgsMessageLog::logMessage( error, tr( "Oracle" ) ); return; } @@ -745,10 +718,7 @@ void QgsOracleConn::retrieveLayerTypes( QgsOracleLayerProperty &layerProperty, b Qgis::WkbType type = wkbTypeFromDatabase( qry.value( 0 ).toInt() ); if ( type == Qgis::WkbType::Unknown ) { - QgsMessageLog::logMessage( tr( "Unsupported geometry type %1 in %2.%3.%4 ignored" ) - .arg( qry.value( 0 ).toInt() ) - .arg( layerProperty.ownerName, layerProperty.tableName, layerProperty.geometryColName ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Unsupported geometry type %1 in %2.%3.%4 ignored" ).arg( qry.value( 0 ).toInt() ).arg( layerProperty.ownerName, layerProperty.tableName, layerProperty.geometryColName ), tr( "Oracle" ) ); continue; } QgsDebugMsgLevel( QStringLiteral( "add type %1" ).arg( qgsEnumValueToKey( type ) ), 2 ); @@ -1126,8 +1096,8 @@ int QgsOracleConn::version() else { const QString error { tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ) }; + .arg( qry.lastError().text() ) + .arg( qry.lastQuery() ) }; QgsMessageLog::logMessage( error, tr( "Oracle" ) ); return -1; } @@ -1180,9 +1150,9 @@ QString QgsOracleConn::getSpatialIndexName( const QString &ownerName, const QStr QSqlQuery qry( mDatabase ); if ( LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, QStringLiteral( "SELECT i.index_name,i.domidx_opstatus" - " FROM all_indexes i" - " JOIN all_ind_columns c ON i.owner=c.index_owner AND i.index_name=c.index_name AND c.column_name=?" - " WHERE i.table_owner=? AND i.table_name=? AND i.ityp_owner='MDSYS' AND i.ityp_name='SPATIAL_INDEX'" ), + " FROM all_indexes i" + " JOIN all_ind_columns c ON i.owner=c.index_owner AND i.index_name=c.index_name AND c.column_name=?" + " WHERE i.table_owner=? AND i.table_name=? AND i.ityp_owner='MDSYS' AND i.ityp_name='SPATIAL_INDEX'" ), QVariantList() << geometryColumn << ownerName << tableName ) ) { if ( qry.next() ) @@ -1190,12 +1160,7 @@ QString QgsOracleConn::getSpatialIndexName( const QString &ownerName, const QStr name = qry.value( 0 ).toString(); if ( qry.value( 1 ).toString() != "VALID" ) { - QgsMessageLog::logMessage( tr( "Invalid spatial index %1 on column %2.%3.%4 found - expect poor performance." ) - .arg( name ) - .arg( ownerName ) - .arg( tableName ) - .arg( geometryColumn ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Invalid spatial index %1 on column %2.%3.%4 found - expect poor performance." ).arg( name ).arg( ownerName ).arg( tableName ).arg( geometryColumn ), tr( "Oracle" ) ); isValid = false; } else @@ -1212,12 +1177,11 @@ QString QgsOracleConn::getSpatialIndexName( const QString &ownerName, const QStr else { const QString error { tr( "Probing for spatial index on column %1.%2.%3 failed [%4]" ) - .arg( ownerName ) - .arg( tableName ) - .arg( geometryColumn ) - .arg( qry.lastError().text() ) }; - QgsMessageLog::logMessage( error, - tr( "Oracle" ) ); + .arg( ownerName ) + .arg( tableName ) + .arg( geometryColumn ) + .arg( qry.lastError().text() ) }; + QgsMessageLog::logMessage( error, tr( "Oracle" ) ); isValid = false; } @@ -1232,24 +1196,22 @@ QString QgsOracleConn::createSpatialIndex( const QString &ownerName, const QStri int n = 0; const QString sql { QStringLiteral( "SELECT coalesce(substr(max(index_name),10),'0') FROM all_indexes WHERE index_name LIKE 'QGIS_IDX_%' ESCAPE '#' ORDER BY index_name" ) }; - if ( LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, sql, QVariantList() ) && - qry.next() ) + if ( LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, sql, QVariantList() ) && qry.next() ) { n = qry.value( 0 ).toInt() + 1; } const QString sql2 { QStringLiteral( "CREATE INDEX QGIS_IDX_%1 ON %2.%3(%4) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARALLEL" ) - .arg( n, 10, 10, QChar( '0' ) ) - .arg( quotedIdentifier( ownerName ) ) - .arg( quotedIdentifier( tableName ) ) - .arg( quotedIdentifier( geometryColumn ) ) }; + .arg( n, 10, 10, QChar( '0' ) ) + .arg( quotedIdentifier( ownerName ) ) + .arg( quotedIdentifier( tableName ) ) + .arg( quotedIdentifier( geometryColumn ) ) }; if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, sql2, QVariantList() ) ) { const QString error { tr( "Creation spatial index failed.\nSQL: %1\nError: %2" ) - .arg( qry.lastQuery() ) - .arg( qry.lastError().text() ) }; - QgsMessageLog::logMessage( error, - tr( "Oracle" ) ); + .arg( qry.lastQuery() ) + .arg( qry.lastError().text() ) }; + QgsMessageLog::logMessage( error, tr( "Oracle" ) ); return QString(); } @@ -1263,14 +1225,14 @@ QStringList QgsOracleConn::getPrimaryKeys( const QString &ownerName, const QStri QStringList result; if ( !LoggedExecPrivate( QStringLiteral( "QgsOracleConn" ), qry, QStringLiteral( "SELECT column_name" - " FROM all_cons_columns a" - " JOIN all_constraints b ON a.constraint_name=b.constraint_name AND a.owner=b.owner" - " WHERE b.constraint_type='P' AND b.owner=? AND b.table_name=?" ), + " FROM all_cons_columns a" + " JOIN all_constraints b ON a.constraint_name=b.constraint_name AND a.owner=b.owner" + " WHERE b.constraint_type='P' AND b.owner=? AND b.table_name=?" ), QVariantList() << ownerName << tableName ) ) { const QString error { tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ) }; + .arg( qry.lastError().text() ) + .arg( qry.lastQuery() ) }; QgsMessageLog::logMessage( error, tr( "Oracle" ) ); return result; } diff --git a/src/providers/oracle/qgsoracleconn.h b/src/providers/oracle/qgsoracleconn.h index f5b8dc325741..189681b86814 100644 --- a/src/providers/oracle/qgsoracleconn.h +++ b/src/providers/oracle/qgsoracleconn.h @@ -40,82 +40,77 @@ class QgsField; // Oracle layer properties struct QgsOracleLayerProperty { - QList types; - QList srids; - QString ownerName; - QString tableName; - QString geometryColName; - bool isView = false; - QStringList pkCols; - QString sql; - - QgsOracleLayerProperty() = default; - - int size() const { Q_ASSERT( types.size() == srids.size() ); return types.size(); } - - bool operator==( const QgsOracleLayerProperty &other ) const - { - return types == other.types && srids == other.srids && ownerName == other.ownerName && - tableName == other.tableName && geometryColName == other.geometryColName && - isView == other.isView && pkCols == other.pkCols && sql == other.sql; - } - - QgsOracleLayerProperty at( int i ) const - { - QgsOracleLayerProperty property; - - Q_ASSERT( i >= 0 && i < size() ); - - property.types << types.at( i ); - property.srids << srids.at( i ); - property.ownerName = ownerName; - property.tableName = tableName; - property.geometryColName = geometryColName; - property.isView = isView; - property.pkCols = pkCols; - property.sql = sql; - - return property; - } + QList types; + QList srids; + QString ownerName; + QString tableName; + QString geometryColName; + bool isView = false; + QStringList pkCols; + QString sql; + + QgsOracleLayerProperty() = default; + + int size() const + { + Q_ASSERT( types.size() == srids.size() ); + return types.size(); + } -#ifdef QGISDEBUG - QString toString() const - { - QString typeString; - const auto constTypes = types; - for ( Qgis::WkbType type : constTypes ) + bool operator==( const QgsOracleLayerProperty &other ) const { - if ( !typeString.isEmpty() ) - typeString += "|"; - typeString += QString::number( static_cast< quint32>( type ) ); + return types == other.types && srids == other.srids && ownerName == other.ownerName && tableName == other.tableName && geometryColName == other.geometryColName && isView == other.isView && pkCols == other.pkCols && sql == other.sql; } - QString sridString; - const auto constSrids = srids; - for ( int srid : constSrids ) + + QgsOracleLayerProperty at( int i ) const { - if ( !sridString.isEmpty() ) - sridString += "|"; - sridString += QString::number( srid ); + QgsOracleLayerProperty property; + + Q_ASSERT( i >= 0 && i < size() ); + + property.types << types.at( i ); + property.srids << srids.at( i ); + property.ownerName = ownerName; + property.tableName = tableName; + property.geometryColName = geometryColName; + property.isView = isView; + property.pkCols = pkCols; + property.sql = sql; + + return property; } - return QString( "%1.%2.%3 type=%4 srid=%5 view=%6%7 sql=%8" ) - .arg( ownerName, - tableName, - geometryColName, - typeString, - sridString, - isView ? "yes" : "no", - isView ? QString( " pk=%1" ).arg( pkCols.join( "|" ) ) : "", - sql ); - } +#ifdef QGISDEBUG + QString toString() const + { + QString typeString; + const auto constTypes = types; + for ( Qgis::WkbType type : constTypes ) + { + if ( !typeString.isEmpty() ) + typeString += "|"; + typeString += QString::number( static_cast( type ) ); + } + QString sridString; + const auto constSrids = srids; + for ( int srid : constSrids ) + { + if ( !sridString.isEmpty() ) + sridString += "|"; + sridString += QString::number( srid ); + } + + return QString( "%1.%2.%3 type=%4 srid=%5 view=%6%7 sql=%8" ) + .arg( ownerName, tableName, geometryColName, typeString, sridString, isView ? "yes" : "no", isView ? QString( " pk=%1" ).arg( pkCols.join( "|" ) ) : "", sql ); + } #endif }; #include "qgsconfig.h" constexpr int sOracleConQueryLogFilePrefixLength = CMAKE_SOURCE_DIR[sizeof( CMAKE_SOURCE_DIR ) - 1] == '/' ? sizeof( CMAKE_SOURCE_DIR ) + 1 : sizeof( CMAKE_SOURCE_DIR ); -#define LoggedExec(_class, query) execLogged( query, true, nullptr, _class, QString(QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") ) -#define LoggedExecPrivate(_class, query, sql, params ) execLogged( query, sql, params, _class, QString(QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") ) +#define LoggedExec( _class, query ) execLogged( query, true, nullptr, _class, QString( QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) ) +#define LoggedExecPrivate( _class, query, sql, params ) execLogged( query, sql, params, _class, QString( QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) ) /** @@ -125,6 +120,7 @@ constexpr int sOracleConQueryLogFilePrefixLength = CMAKE_SOURCE_DIR[sizeof( CMAK class QgsPoolOracleConn { class QgsOracleConn *mConn; + public: QgsPoolOracleConn( const QString &connInfo ); ~QgsPoolOracleConn(); @@ -176,11 +172,7 @@ class QgsOracleConn : public QObject * returned. * */ - bool supportedLayers( QVector &layers, - const QString &limitToSchema, - bool geometryTablesOnly, - bool userTablesOnly = true, - bool allowGeometrylessTables = false ); + bool supportedLayers( QVector &layers, const QString &limitToSchema, bool geometryTablesOnly, bool userTablesOnly = true, bool allowGeometrylessTables = false ); void retrieveLayerTypes( QgsOracleLayerProperty &layerProperty, bool useEstimatedMetadata, bool onlyExistingTypes ); diff --git a/src/providers/oracle/qgsoracleconnpool.cpp b/src/providers/oracle/qgsoracleconnpool.cpp index e4bb23ee3f5c..48e87b3cc547 100644 --- a/src/providers/oracle/qgsoracleconnpool.cpp +++ b/src/providers/oracle/qgsoracleconnpool.cpp @@ -33,7 +33,8 @@ void QgsOracleConnPool::cleanupInstance() sInstance = nullptr; } -QgsOracleConnPool::QgsOracleConnPool() : QgsConnectionPool() +QgsOracleConnPool::QgsOracleConnPool() + : QgsConnectionPool() { QgsDebugCall; } @@ -42,4 +43,3 @@ QgsOracleConnPool::~QgsOracleConnPool() { QgsDebugCall; } - diff --git a/src/providers/oracle/qgsoracleconnpool.h b/src/providers/oracle/qgsoracleconnpool.h index 739f53a31215..ac3c007d4c0a 100644 --- a/src/providers/oracle/qgsoracleconnpool.h +++ b/src/providers/oracle/qgsoracleconnpool.h @@ -52,7 +52,8 @@ class QgsOracleConnPoolGroup : public QObject, public QgsConnectionPoolGroup( name ) { initTimer( this ); } + explicit QgsOracleConnPoolGroup( QString name ) + : QgsConnectionPoolGroup( name ) { initTimer( this ); } protected slots: void handleConnectionExpired() { onConnectionExpired(); } @@ -61,7 +62,6 @@ class QgsOracleConnPoolGroup : public QObject, public QgsConnectionPoolGroupcurrentUser() ) { errCause = QObject::tr( "%1 not owner of the table %2." ) - .arg( ownerName ) - .arg( tableName ); + .arg( ownerName ) + .arg( tableName ); conn->disconnect(); return false; } @@ -62,15 +62,15 @@ bool deleteLayer( const QString &uri, QString &errCause ) // check the geometry column count if ( !QgsOracleProvider::execLoggedStatic( qry, QString( "SELECT count(*)" - " FROM user_tab_columns" - " WHERE table_name=? AND data_type='SDO_GEOMETRY' AND data_type_owner='MDSYS'" ), - QVariantList() << tableName, dsUri.uri(), QStringLiteral( "QgsOracleLayerItem" ), QGS_QUERY_LOG_ORIGIN ) + " FROM user_tab_columns" + " WHERE table_name=? AND data_type='SDO_GEOMETRY' AND data_type_owner='MDSYS'" ), + QVariantList() << tableName, dsUri.uri(), QStringLiteral( "QgsOracleLayerItem" ), QGS_QUERY_LOG_ORIGIN ) || !qry.next() ) { errCause = QObject::tr( "Unable to determine number of geometry columns of layer %1.%2: \n%3" ) - .arg( ownerName ) - .arg( tableName ) - .arg( qry.lastError().text() ); + .arg( ownerName ) + .arg( tableName ) + .arg( qry.lastError().text() ); conn->disconnect(); return false; } @@ -84,8 +84,8 @@ bool deleteLayer( const QString &uri, QString &errCause ) { // the table has more geometry columns, drop just the geometry column dropTable = QString( "ALTER TABLE %1 DROP COLUMN %2" ) - .arg( QgsOracleConn::quotedIdentifier( tableName ) ) - .arg( QgsOracleConn::quotedIdentifier( geometryCol ) ); + .arg( QgsOracleConn::quotedIdentifier( tableName ) ) + .arg( QgsOracleConn::quotedIdentifier( geometryCol ) ); cleanView = QString( "DELETE FROM mdsys.user_sdo_geom_metadata WHERE table_name=? AND column_name=?" ); args << tableName << geometryCol; } @@ -93,7 +93,7 @@ bool deleteLayer( const QString &uri, QString &errCause ) { // drop the table dropTable = QString( "DROP TABLE %1" ) - .arg( QgsOracleConn::quotedIdentifier( tableName ) ); + .arg( QgsOracleConn::quotedIdentifier( tableName ) ); cleanView = QString( "DELETE FROM mdsys.user_sdo_geom_metadata WHERE table_name=%1" ); args << tableName; } @@ -101,9 +101,9 @@ bool deleteLayer( const QString &uri, QString &errCause ) if ( !QgsOracleProvider::execLoggedStatic( qry, dropTable, QVariantList(), dsUri.uri(), QStringLiteral( "QgsOracleLayerItem" ), QGS_QUERY_LOG_ORIGIN ) ) { errCause = QObject::tr( "Unable to delete layer %1.%2: \n%3" ) - .arg( ownerName ) - .arg( tableName ) - .arg( qry.lastError().text() ); + .arg( ownerName ) + .arg( tableName ) + .arg( qry.lastError().text() ); conn->disconnect(); return false; } @@ -111,9 +111,9 @@ bool deleteLayer( const QString &uri, QString &errCause ) if ( !QgsOracleProvider::execLoggedStatic( qry, cleanView, args, dsUri.uri(), QStringLiteral( "QgsOracleLayerItem" ), QGS_QUERY_LOG_ORIGIN ) ) { errCause = QObject::tr( "Unable to clean metadata %1.%2: \n%3" ) - .arg( ownerName ) - .arg( tableName ) - .arg( qry.lastError().text() ); + .arg( ownerName ) + .arg( tableName ) + .arg( qry.lastError().text() ); conn->disconnect(); return false; } @@ -188,22 +188,17 @@ QVector QgsOracleConnectionItem::createChildren() if ( !mColumnTypeTask ) { - mColumnTypeTask = new QgsOracleColumnTypeTask( mName, - QgsOracleConn::restrictToSchema( mName ), - /* useEstimatedMetadata */ true, - QgsOracleConn::allowGeometrylessTables( mName ) ); + mColumnTypeTask = new QgsOracleColumnTypeTask( mName, QgsOracleConn::restrictToSchema( mName ), + /* useEstimatedMetadata */ true, QgsOracleConn::allowGeometrylessTables( mName ) ); - connect( mColumnTypeTask, &QgsOracleColumnTypeTask::setLayerType, - this, &QgsOracleConnectionItem::setLayerType ); + connect( mColumnTypeTask, &QgsOracleColumnTypeTask::setLayerType, this, &QgsOracleConnectionItem::setLayerType ); connect( mColumnTypeTask, &QgsTask::begun, this, &QgsOracleConnectionItem::taskStarted ); connect( mColumnTypeTask, &QgsTask::taskCompleted, this, &QgsOracleConnectionItem::taskFinished ); connect( mColumnTypeTask, &QgsTask::taskTerminated, this, &QgsOracleConnectionItem::taskFinished ); if ( QgsOracleRootItem::sMainWindow ) { - connect( mColumnTypeTask, &QgsOracleColumnTypeTask::progressMessage, - QgsOracleRootItem::sMainWindow->statusBar(), [ = ]( const QString & message ) - { + connect( mColumnTypeTask, &QgsOracleColumnTypeTask::progressMessage, QgsOracleRootItem::sMainWindow->statusBar(), [=]( const QString &message ) { QgsOracleRootItem::sMainWindow->statusBar()->showMessage( message ); } ); } @@ -236,7 +231,7 @@ void QgsOracleConnectionItem::setLayerType( const QgsOracleLayerProperty &layerP QgsDebugMsgLevel( layerProperty.toString(), 3 ); QgsOracleOwnerItem *ownerItem = mOwnerMap.value( layerProperty.ownerName, nullptr ); - for ( int i = 0 ; i < layerProperty.size(); i++ ) + for ( int i = 0; i < layerProperty.size(); i++ ) { Qgis::WkbType wkbType = layerProperty.types.at( i ); if ( wkbType == Qgis::WkbType::Unknown ) @@ -251,7 +246,7 @@ void QgsOracleConnectionItem::setLayerType( const QgsOracleLayerProperty &layerP ownerItem->setState( Qgis::BrowserItemState::Populating ); QgsDebugMsgLevel( "add owner item: " + layerProperty.ownerName, 3 ); addChildItem( ownerItem, true ); - mOwnerMap[ layerProperty.ownerName ] = ownerItem; + mOwnerMap[layerProperty.ownerName] = ownerItem; } QgsDebugMsgLevel( QStringLiteral( "ADD LAYER" ), 3 ); @@ -324,9 +319,7 @@ void QgsOracleConnectionItem::duplicateConnection() void QgsOracleConnectionItem::deleteConnection() { - if ( QMessageBox::question( nullptr, QObject::tr( "Remove Connection" ), - QObject::tr( "Are you sure you want to remove the connection to %1?" ).arg( mName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Remove Connection" ), QObject::tr( "Are you sure you want to remove the connection to %1?" ).arg( mName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "oracle" ) ); @@ -379,11 +372,10 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData *data, Qt::DropAction } QgsDebugMsgLevel( "URI " + uri.uri( false ), 3 ); - std::unique_ptr< QgsVectorLayerExporterTask > exportTask( QgsVectorLayerExporterTask::withLayerOwnership( srcLayer, uri.uri( false ), QStringLiteral( "oracle" ), srcLayer->crs() ) ); + std::unique_ptr exportTask( QgsVectorLayerExporterTask::withLayerOwnership( srcLayer, uri.uri( false ), QStringLiteral( "oracle" ), srcLayer->crs() ) ); // when export is successful: - connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [ = ]() - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [=]() { // this is gross - TODO - find a way to get access to messageBar from data items QMessageBox::information( nullptr, tr( "Import to Oracle database" ), tr( "Import was successful." ) ); if ( state() == Qgis::BrowserItemState::Populated ) @@ -393,8 +385,7 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData *data, Qt::DropAction } ); // when an error occurs: - connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, [ = ]( Qgis::VectorExportResult error, const QString & errorMessage ) - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, [=]( Qgis::VectorExportResult error, const QString &errorMessage ) { if ( error != Qgis::VectorExportResult::UserCanceled ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); @@ -450,9 +441,7 @@ QList QgsOracleLayerItem::actions( QWidget *parent ) bool QgsOracleLayerItem::deleteLayer() { - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Table" ), - QObject::tr( "Are you sure you want to delete %1.%2?" ).arg( mLayerProperty.ownerName, mLayerProperty.tableName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Table" ), QObject::tr( "Are you sure you want to delete %1.%2?" ).arg( mLayerProperty.ownerName, mLayerProperty.tableName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return true; QString errCause; diff --git a/src/providers/oracle/qgsoracledataitems.h b/src/providers/oracle/qgsoracledataitems.h index 104283ef782f..08777168291a 100644 --- a/src/providers/oracle/qgsoracledataitems.h +++ b/src/providers/oracle/qgsoracledataitems.h @@ -88,7 +88,7 @@ class QgsOracleConnectionItem : public QgsDataCollectionItem private: void stop(); - QMap mOwnerMap; + QMap mOwnerMap; QgsOracleColumnTypeTask *mColumnTypeTask = nullptr; void setAllAsPopulated(); }; @@ -109,7 +109,7 @@ class QgsOracleOwnerItem : public QgsDataCollectionItem }; Q_NOWARN_DEPRECATED_PUSH // deleteLayer deprecated -class QgsOracleLayerItem : public QgsLayerItem + class QgsOracleLayerItem : public QgsLayerItem { Q_OBJECT diff --git a/src/providers/oracle/qgsoracleexpressioncompiler.cpp b/src/providers/oracle/qgsoracleexpressioncompiler.cpp index c35a81e0c3ee..dbdea5ebde99 100644 --- a/src/providers/oracle/qgsoracleexpressioncompiler.cpp +++ b/src/providers/oracle/qgsoracleexpressioncompiler.cpp @@ -49,8 +49,7 @@ QgsSqlExpressionCompiler::Result QgsOracleExpressionCompiler::compileNode( const { QString op1, op2; - if ( compileNode( bin->opLeft(), op1 ) != Complete || - compileNode( bin->opRight(), op2 ) != Complete ) + if ( compileNode( bin->opLeft(), op1 ) != Complete || compileNode( bin->opRight(), op2 ) != Complete ) return Fail; switch ( bin->op() ) @@ -76,7 +75,7 @@ QgsSqlExpressionCompiler::Result QgsOracleExpressionCompiler::compileNode( const return Complete; - case QgsExpressionNodeBinaryOperator::boMod : + case QgsExpressionNodeBinaryOperator::boMod: result = QStringLiteral( "MOD(%1,%2)" ).arg( op1, op2 ); return Complete; @@ -138,8 +137,7 @@ QString QgsOracleExpressionCompiler::quotedValue( const QVariant &value, bool &o } } -static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP -{ +static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP { { "sqrt", "sqrt" }, { "abs", "abs" }, { "cos", "cos" }, @@ -169,12 +167,7 @@ QStringList QgsOracleExpressionCompiler::sqlArgumentsFromFunctionName( const QSt QStringList args( fnArgs ); if ( fnName == QLatin1String( "make_datetime" ) ) { - args = QStringList( QStringLiteral( "TIMESTAMP '%1-%2-%3 %4:%5:%6'" ).arg( args[0].rightJustified( 4, '0' ) ) - .arg( args[1].rightJustified( 2, '0' ) ) - .arg( args[2].rightJustified( 2, '0' ) ) - .arg( args[3].rightJustified( 2, '0' ) ) - .arg( args[4].rightJustified( 2, '0' ) ) - .arg( args[5].rightJustified( 2, '0' ) ) ); + args = QStringList( QStringLiteral( "TIMESTAMP '%1-%2-%3 %4:%5:%6'" ).arg( args[0].rightJustified( 4, '0' ) ).arg( args[1].rightJustified( 2, '0' ) ).arg( args[2].rightJustified( 2, '0' ) ).arg( args[3].rightJustified( 2, '0' ) ).arg( args[4].rightJustified( 2, '0' ) ).arg( args[5].rightJustified( 2, '0' ) ) ); } return args; } diff --git a/src/providers/oracle/qgsoracleexpressioncompiler.h b/src/providers/oracle/qgsoracleexpressioncompiler.h index b92c817e7d4e..e85f41a16d8d 100644 --- a/src/providers/oracle/qgsoracleexpressioncompiler.h +++ b/src/providers/oracle/qgsoracleexpressioncompiler.h @@ -23,7 +23,6 @@ class QgsOracleExpressionCompiler : public QgsSqlExpressionCompiler { public: - explicit QgsOracleExpressionCompiler( QgsOracleFeatureSource *source, bool ignoreStaticNodes = false ); protected: diff --git a/src/providers/oracle/qgsoraclefeatureiterator.cpp b/src/providers/oracle/qgsoraclefeatureiterator.cpp index 2dcb68c53f84..cb68ea8b9b5f 100644 --- a/src/providers/oracle/qgsoraclefeatureiterator.cpp +++ b/src/providers/oracle/qgsoraclefeatureiterator.cpp @@ -102,7 +102,6 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour if ( !mAttributeList.contains( attrIdx ) ) mAttributeList << attrIdx; } - } else mAttributeList = mSource->mFields.allAttributesList(); @@ -135,7 +134,7 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour ")" ); whereClause = QStringLiteral( "sdo_filter(%1,%2)='TRUE'" ) - .arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ), bbox ); + .arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ), bbox ); args << ( mSource->mSrid < 1 ? QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) : mSource->mSrid ) << mFilterRect.xMinimum() << mFilterRect.yMinimum() << mFilterRect.xMaximum() << mFilterRect.yMaximum(); @@ -146,8 +145,7 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour if ( mConnection->hasSpatial() ) { whereClause += QStringLiteral( " AND sdo_relate(%1,%2,'mask=ANYINTERACT')='TRUE'" ) - .arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ), - bbox ); + .arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ), bbox ); args << ( mSource->mSrid < 1 ? QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) : mSource->mSrid ) << mFilterRect.xMinimum() << mFilterRect.yMinimum() << mFilterRect.xMaximum() << mFilterRect.yMaximum(); } else @@ -191,7 +189,6 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour case Qgis::FeatureRequestFilterType::Expression: //handled below break; - } if ( mSource->mRequestedGeomType != Qgis::WkbType::Unknown && mSource->mRequestedGeomType != mSource->mDetectedGeomType ) @@ -300,10 +297,8 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature ) if ( !execQuery( mSql, mArgs, 1 ) ) { const QString error { QObject::tr( "Fetching features failed.\nSQL: %1\nError: %2" ) - .arg( mQry.lastQuery(), - mQry.lastError().text() ) }; - QgsMessageLog::logMessage( error, - QObject::tr( "Oracle" ) ); + .arg( mQry.lastQuery(), mQry.lastError().text() ) }; + QgsMessageLog::logMessage( error, QObject::tr( "Oracle" ) ); return false; } } @@ -538,14 +533,11 @@ bool QgsOracleFeatureIterator::openQuery( const QString &whereClause, const QVar if ( !execQuery( query, args, 1 ) ) { - const QString error { QObject::tr( "Fetching features failed.\nSQL: %1\nError: %2" ) - .arg( mQry.lastQuery(), - mQry.lastError().text() ) }; + .arg( mQry.lastQuery(), mQry.lastError().text() ) }; if ( showLog ) { - QgsMessageLog::logMessage( error, - QObject::tr( "Oracle" ) ); + QgsMessageLog::logMessage( error, QObject::tr( "Oracle" ) ); } return false; } @@ -570,10 +562,7 @@ bool QgsOracleFeatureIterator::execQuery( const QString &query, const QVariantLi // ORA-12170: TNS:Connect timeout occurred // Or if there is a problem with the network connectivity try again N times // ORA-03114: Not Connected to Oracle - if ( mQry.lastError().nativeErrorCode() == QLatin1String( "12170" ) || - mQry.lastError().nativeErrorCode().compare( QLatin1String( "ORA-12170" ), Qt::CaseInsensitive ) == 0 || - mQry.lastError().nativeErrorCode() == QLatin1String( "3114" ) || - mQry.lastError().nativeErrorCode().compare( QLatin1String( "ORA-3114" ), Qt::CaseInsensitive ) == 0 ) + if ( mQry.lastError().nativeErrorCode() == QLatin1String( "12170" ) || mQry.lastError().nativeErrorCode().compare( QLatin1String( "ORA-12170" ), Qt::CaseInsensitive ) == 0 || mQry.lastError().nativeErrorCode() == QLatin1String( "3114" ) || mQry.lastError().nativeErrorCode().compare( QLatin1String( "ORA-3114" ), Qt::CaseInsensitive ) == 0 ) { // restart connection mConnection->reconnect(); diff --git a/src/providers/oracle/qgsoraclefeatureiterator.h b/src/providers/oracle/qgsoraclefeatureiterator.h index 07ebed8fdfa8..8058c8f68a80 100644 --- a/src/providers/oracle/qgsoraclefeatureiterator.h +++ b/src/providers/oracle/qgsoraclefeatureiterator.h @@ -29,7 +29,7 @@ class QgsOracleConn; class QgsOracleProvider; -class QgsOracleFeatureSource final: public QgsAbstractFeatureSource +class QgsOracleFeatureSource final : public QgsAbstractFeatureSource { public: explicit QgsOracleFeatureSource( const QgsOracleProvider *p ); @@ -67,7 +67,7 @@ class QgsOracleFeatureSource final: public QgsAbstractFeatureSource }; -class QgsOracleFeatureIterator final: public QgsAbstractFeatureIteratorFromSource +class QgsOracleFeatureIterator final : public QgsAbstractFeatureIteratorFromSource { public: QgsOracleFeatureIterator( QgsOracleFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ); @@ -101,7 +101,7 @@ class QgsOracleFeatureIterator final: public QgsAbstractFeatureIteratorFromSourc QgsRectangle mFilterRect; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; bool mIsTransactionConnection = false; }; diff --git a/src/providers/oracle/qgsoraclenewconnection.cpp b/src/providers/oracle/qgsoraclenewconnection.cpp index 0b5d96b3d5b2..c3efc7b7f4e6 100644 --- a/src/providers/oracle/qgsoraclenewconnection.cpp +++ b/src/providers/oracle/qgsoraclenewconnection.cpp @@ -97,7 +97,7 @@ QgsOracleNewConnection::QgsOracleNewConnection( QWidget *parent, const QString & if ( settings.contains( key + QStringLiteral( "/save" ) ) ) { mAuthSettings->setUsername( settings.value( key + "/username" ).toString() ); - mAuthSettings->setStoreUsernameChecked( ! mAuthSettings->username().isEmpty() ); + mAuthSettings->setStoreUsernameChecked( !mAuthSettings->username().isEmpty() ); if ( settings.value( key + "/save" ).toString() == QLatin1String( "true" ) ) mAuthSettings->setPassword( settings.value( key + "/password" ).toString() ); @@ -120,23 +120,13 @@ void QgsOracleNewConnection::accept() settings.setValue( baseKey + QStringLiteral( "selected" ), txtName->text() ); bool hasAuthConfigID = !mAuthSettings->configId().isEmpty(); - if ( !hasAuthConfigID && mAuthSettings->storePasswordIsChecked() && - QMessageBox::question( this, - tr( "Saving Passwords" ), - tr( "WARNING: You have opted to save your password. It will be stored in plain text in your project files and in your home directory on Unix-like systems, or in your user profile on Windows. If you do not want this to happen, please press the Cancel button.\n" ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( !hasAuthConfigID && mAuthSettings->storePasswordIsChecked() && QMessageBox::question( this, tr( "Saving Passwords" ), tr( "WARNING: You have opted to save your password. It will be stored in plain text in your project files and in your home directory on Unix-like systems, or in your user profile on Windows. If you do not want this to happen, please press the Cancel button.\n" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; } // warn if entry was renamed to an existing connection - if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( txtName->text(), Qt::CaseInsensitive ) != 0 ) && - ( settings.contains( baseKey + txtName->text() + QStringLiteral( "/service" ) ) || - settings.contains( baseKey + txtName->text() + QStringLiteral( "/host" ) ) ) && - QMessageBox::question( this, - tr( "Save Connection" ), - tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( txtName->text(), Qt::CaseInsensitive ) != 0 ) && ( settings.contains( baseKey + txtName->text() + QStringLiteral( "/service" ) ) || settings.contains( baseKey + txtName->text() + QStringLiteral( "/host" ) ) ) && QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; } @@ -155,7 +145,7 @@ void QgsOracleNewConnection::accept() settings.setValue( baseKey + QStringLiteral( "/database" ), txtDatabase->text() ); settings.setValue( baseKey + QStringLiteral( "/host" ), txtHost->text() ); settings.setValue( baseKey + QStringLiteral( "/port" ), txtPort->text() ); - settings.setValue( baseKey + QStringLiteral( "/username" ), mAuthSettings->storeUsernameIsChecked( ) ? mAuthSettings->username() : QString() ); + settings.setValue( baseKey + QStringLiteral( "/username" ), mAuthSettings->storeUsernameIsChecked() ? mAuthSettings->username() : QString() ); settings.setValue( baseKey + QStringLiteral( "/password" ), mAuthSettings->storePasswordIsChecked() && !hasAuthConfigID ? mAuthSettings->password() : QString() ); settings.setValue( baseKey + QStringLiteral( "/authcfg" ), mAuthSettings->configId() ); settings.setValue( baseKey + QStringLiteral( "/userTablesOnly" ), cb_userTablesOnly->isChecked() ); @@ -165,8 +155,8 @@ void QgsOracleNewConnection::accept() settings.setValue( baseKey + QStringLiteral( "/onlyExistingTypes" ), cb_onlyExistingTypes->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); settings.setValue( baseKey + QStringLiteral( "/includeGeoAttributes" ), cb_includeGeoAttributes->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); settings.setValue( baseKey + QStringLiteral( "/projectsInDatabase" ), cb_projectsInDatabase->isChecked() ); - settings.setValue( baseKey + QStringLiteral( "/saveUsername" ), mAuthSettings->storeUsernameIsChecked( ) ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); - settings.setValue( baseKey + QStringLiteral( "/savePassword" ), mAuthSettings->storePasswordIsChecked( ) && !hasAuthConfigID ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + settings.setValue( baseKey + QStringLiteral( "/saveUsername" ), mAuthSettings->storeUsernameIsChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + settings.setValue( baseKey + QStringLiteral( "/savePassword" ), mAuthSettings->storePasswordIsChecked() && !hasAuthConfigID ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); settings.setValue( baseKey + QStringLiteral( "/dboptions" ), txtOptions->text() ); settings.setValue( baseKey + QStringLiteral( "/dbworkspace" ), txtWorkspace->text() ); settings.setValue( baseKey + QStringLiteral( "/schema" ), txtSchema->text() ); @@ -176,14 +166,14 @@ void QgsOracleNewConnection::accept() configuration.insert( QStringLiteral( "geometryColumnsOnly" ), cb_geometryColumnsOnly->isChecked() ); configuration.insert( QStringLiteral( "allowGeometrylessTables" ), cb_allowGeometrylessTables->isChecked() ); configuration.insert( QStringLiteral( "onlyExistingTypes" ), cb_onlyExistingTypes->isChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); - configuration.insert( QStringLiteral( "saveUsername" ), mAuthSettings->storeUsernameIsChecked( ) ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); - configuration.insert( QStringLiteral( "savePassword" ), mAuthSettings->storePasswordIsChecked( ) && !hasAuthConfigID ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + configuration.insert( QStringLiteral( "saveUsername" ), mAuthSettings->storeUsernameIsChecked() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); + configuration.insert( QStringLiteral( "savePassword" ), mAuthSettings->storePasswordIsChecked() && !hasAuthConfigID ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ); configuration.insert( QStringLiteral( "includeGeoAttributes" ), cb_includeGeoAttributes->isChecked() ); configuration.insert( QStringLiteral( "schema" ), txtSchema->text() ); configuration.insert( QStringLiteral( "projectsInDatabase" ), cb_projectsInDatabase->isChecked() ); QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "oracle" ) ); - QgsOracleProviderConnection *providerConnection = static_cast( providerMetadata->createConnection( txtName->text() ) ); + QgsOracleProviderConnection *providerConnection = static_cast( providerMetadata->createConnection( txtName->text() ) ); providerConnection->setUri( QgsOracleConn::connUri( txtName->text() ).uri( false ) ); providerConnection->setConfiguration( configuration ); providerMetadata->saveConnection( providerConnection, txtName->text() ); @@ -194,10 +184,7 @@ void QgsOracleNewConnection::accept() void QgsOracleNewConnection::testConnection() { QgsDataSourceUri uri; - uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), - mAuthSettings->username(), mAuthSettings->password(), - QgsDataSourceUri::SslPrefer /* meaningless for oracle */, - mAuthSettings->configId() ); + uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), mAuthSettings->username(), mAuthSettings->password(), QgsDataSourceUri::SslPrefer /* meaningless for oracle */, mAuthSettings->configId() ); if ( !txtOptions->text().isEmpty() ) uri.setParam( QStringLiteral( "dboptions" ), txtOptions->text() ); if ( !txtWorkspace->text().isEmpty() ) @@ -208,15 +195,13 @@ void QgsOracleNewConnection::testConnection() if ( conn ) { // Database successfully opened; we can now issue SQL commands. - bar->pushMessage( tr( "Connection to %1 was successful." ).arg( txtName->text() ), - Qgis::MessageLevel::Success ); + bar->pushMessage( tr( "Connection to %1 was successful." ).arg( txtName->text() ), Qgis::MessageLevel::Success ); // free connection resources QgsOracleConnPool::instance()->releaseConnection( conn ); } else { - bar->pushMessage( tr( "Connection failed - consult message log for details." ), - Qgis::MessageLevel::Warning ); + bar->pushMessage( tr( "Connection failed - consult message log for details." ), Qgis::MessageLevel::Warning ); } } diff --git a/src/providers/oracle/qgsoracleprojectstorage.cpp b/src/providers/oracle/qgsoracleprojectstorage.cpp index 26033db7e9ce..2acf3140fdf2 100644 --- a/src/providers/oracle/qgsoracleprojectstorage.cpp +++ b/src/providers/oracle/qgsoracleprojectstorage.cpp @@ -28,8 +28,8 @@ #include #define ORIGINATOR_CLASS QStringLiteral( "QgsOracleProjectStorage" ) -#define QUERY_ORIGIN QString(QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") -#define LoggedExecStatic(query, sql, args, uri ) QgsOracleProvider::execLoggedStatic( query, sql, args, uri, ORIGINATOR_CLASS, QUERY_ORIGIN ) +#define QUERY_ORIGIN QString( QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) +#define LoggedExecStatic( query, sql, args, uri ) QgsOracleProvider::execLoggedStatic( query, sql, args, uri, ORIGINATOR_CLASS, QUERY_ORIGIN ) static bool parseMetadataDocument( const QJsonDocument &doc, QgsProjectStorage::Metadata &metadata ) { @@ -40,7 +40,7 @@ static bool parseMetadataDocument( const QJsonDocument &doc, QgsProjectStorage:: metadata.lastModified = QDateTime(); if ( docObj.contains( QStringLiteral( "last_modified_time" ) ) ) { - const QString lastModifiedTimeStr = docObj[ QStringLiteral( "last_modified_time" )].toString(); + const QString lastModifiedTimeStr = docObj[QStringLiteral( "last_modified_time" )].toString(); if ( !lastModifiedTimeStr.isEmpty() ) { QDateTime lastModifiedUtc = QDateTime::fromString( lastModifiedTimeStr, Qt::ISODate ); @@ -164,17 +164,14 @@ bool QgsOracleProjectStorage::writeProject( const QString &uri, QIODevice *devic // read from device and write to the table QByteArray content = device->readAll(); - const QString metadataExpr = QStringLiteral( "%1 || to_char(current_timestamp AT TIME ZONE 'UTC', 'YYYY-MM-DD HH24:MI:SS.FF5') || %2 || sys_context('USERENV', 'CURRENT_USER') || %3" ).arg( - QgsOracleConn::quotedValue( "{ \"last_modified_time\": \"" ), - QgsOracleConn::quotedValue( "\", \"last_modified_user\": \"" ), - QgsOracleConn::quotedValue( "\" }" ) ); + const QString metadataExpr = QStringLiteral( "%1 || to_char(current_timestamp AT TIME ZONE 'UTC', 'YYYY-MM-DD HH24:MI:SS.FF5') || %2 || sys_context('USERENV', 'CURRENT_USER') || %3" ).arg( QgsOracleConn::quotedValue( "{ \"last_modified_time\": \"" ), QgsOracleConn::quotedValue( "\", \"last_modified_user\": \"" ), QgsOracleConn::quotedValue( "\" }" ) ); const QString sql( QStringLiteral( "MERGE INTO %1.\"qgis_projects\" " "USING dual " "ON (name = :projectname) " "WHEN MATCHED THEN UPDATE SET metadata = %2, content = :content " "WHEN NOT MATCHED THEN INSERT VALUES (:projectname, %2, :content)" ) - .arg( QgsOracleConn::quotedIdentifier( projectUri.owner ), metadataExpr ) ); + .arg( QgsOracleConn::quotedIdentifier( projectUri.owner ), metadataExpr ) ); QgsDatabaseQueryLogWrapper logWrapper { sql, uri, QStringLiteral( "oracle" ), ORIGINATOR_CLASS, QUERY_ORIGIN }; @@ -183,7 +180,7 @@ bool QgsOracleProjectStorage::writeProject( const QString &uri, QIODevice *devic if ( !qry.prepare( sql ) ) { QgsDebugError( QStringLiteral( "SQL: %1\nERROR: %2" ) - .arg( qry.lastQuery(), qry.lastError().text() ) ); + .arg( qry.lastQuery(), qry.lastError().text() ) ); return false; } @@ -302,13 +299,9 @@ QgsOracleProjectUri QgsOracleProjectStorage::decodeUri( const QString &uri ) const QString dbName = urlQuery.queryItemValue( QStringLiteral( "dbname" ) ); const QString service = urlQuery.queryItemValue( QStringLiteral( "service" ) ); if ( !service.isEmpty() ) - projectUri.connInfo.setConnection( service, dbName, username, password, - QgsDataSourceUri::SslPrefer /* meaningless for oracle */, - authConfigId ); + projectUri.connInfo.setConnection( service, dbName, username, password, QgsDataSourceUri::SslPrefer /* meaningless for oracle */, authConfigId ); else - projectUri.connInfo.setConnection( host, port, dbName, username, password, - QgsDataSourceUri::SslPrefer /* meaningless for oracle */, - authConfigId ); + projectUri.connInfo.setConnection( host, port, dbName, username, password, QgsDataSourceUri::SslPrefer /* meaningless for oracle */, authConfigId ); projectUri.owner = urlQuery.queryItemValue( QStringLiteral( "schema" ) ); projectUri.projectName = urlQuery.queryItemValue( QStringLiteral( "project" ) ); diff --git a/src/providers/oracle/qgsoracleprojectstorage.h b/src/providers/oracle/qgsoracleprojectstorage.h index 16488077a48a..a16141b32097 100644 --- a/src/providers/oracle/qgsoracleprojectstorage.h +++ b/src/providers/oracle/qgsoracleprojectstorage.h @@ -24,12 +24,12 @@ //! Stores information parsed from oracle project URI typedef struct { - bool valid; + bool valid; - QgsDataSourceUri connInfo; // using only the bits about connection info (server, port, username, password, service, ssl mode) + QgsDataSourceUri connInfo; // using only the bits about connection info (server, port, username, password, service, ssl mode) - QString owner; - QString projectName; + QString owner; + QString projectName; } QgsOracleProjectUri; @@ -38,7 +38,6 @@ typedef struct class QgsOracleProjectStorage : public QgsProjectStorage { public: - QString type() override { return QStringLiteral( "oracle" ); } QStringList listProjects( const QString &uri ) override; diff --git a/src/providers/oracle/qgsoracleprojectstoragedialog.cpp b/src/providers/oracle/qgsoracleprojectstoragedialog.cpp index 4ad2bdc844f1..8002687a8412 100644 --- a/src/providers/oracle/qgsoracleprojectstoragedialog.cpp +++ b/src/providers/oracle/qgsoracleprojectstoragedialog.cpp @@ -53,7 +53,7 @@ QgsOracleProjectStorageDialog::QgsOracleProjectStorageDialog( bool saving, QWidg setWindowTitle( tr( "Load project from Oracle" ) ); } - connect( mCboConnection, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsOracleProjectStorageDialog::populateOwners ); + connect( mCboConnection, qOverload( &QComboBox::currentIndexChanged ), this, &QgsOracleProjectStorageDialog::populateOwners ); mLblProjectsNotAllowed->setVisible( false ); @@ -65,7 +65,7 @@ QgsOracleProjectStorageDialog::QgsOracleProjectStorageDialog( bool saving, QWidg mCboConnection->setCurrentIndex( mCboConnection->findText( toSelect ) ); populateProjects(); - connect( mCboOwner, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsOracleProjectStorageDialog::populateProjects ); + connect( mCboOwner, qOverload( &QComboBox::currentIndexChanged ), this, &QgsOracleProjectStorageDialog::populateProjects ); connect( mCboProject, &QComboBox::currentTextChanged, this, &QgsOracleProjectStorageDialog::projectChanged ); projectChanged(); @@ -144,9 +144,7 @@ void QgsOracleProjectStorageDialog::onOK() { if ( mExistingProjects.contains( mCboProject->currentText() ) ) { - const int res = QMessageBox::question( this, tr( "Overwrite project" ), - tr( "A project with the same name already exists. Would you like to overwrite it?" ), - QMessageBox::Yes | QMessageBox::No ); + const int res = QMessageBox::question( this, tr( "Overwrite project" ), tr( "A project with the same name already exists. Would you like to overwrite it?" ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) return; } @@ -162,9 +160,7 @@ void QgsOracleProjectStorageDialog::projectChanged() void QgsOracleProjectStorageDialog::removeProject() { - const int res = QMessageBox::question( this, tr( "Remove project" ), - tr( "Do you really want to remove the project \"%1\"?" ).arg( mCboProject->currentText() ), - QMessageBox::Yes | QMessageBox::No ); + const int res = QMessageBox::question( this, tr( "Remove project" ), tr( "Do you really want to remove the project \"%1\"?" ).arg( mCboProject->currentText() ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) return; diff --git a/src/providers/oracle/qgsoracleprojectstoragedialog.h b/src/providers/oracle/qgsoracleprojectstoragedialog.h index f7f20faafa64..fe87d4812a08 100644 --- a/src/providers/oracle/qgsoracleprojectstoragedialog.h +++ b/src/providers/oracle/qgsoracleprojectstoragedialog.h @@ -42,8 +42,7 @@ class QgsOracleProjectStorageDialog : public QDialog, private Ui::QgsOracleProje void removeProject(); private: - - bool mSaving = false; //!< Whether using this dialog for loading or saving a project + bool mSaving = false; //!< Whether using this dialog for loading or saving a project QAction *mActionRemoveProject = nullptr; QStringList mExistingProjects; }; diff --git a/src/providers/oracle/qgsoracleprovider.cpp b/src/providers/oracle/qgsoracleprovider.cpp index ca6e4e1a4a7f..eb6b653706d7 100644 --- a/src/providers/oracle/qgsoracleprovider.cpp +++ b/src/providers/oracle/qgsoracleprovider.cpp @@ -56,14 +56,13 @@ #include "ocispatial/wkbptr.h" -#define LoggedExecStatic(query, sql, args, uri ) QgsOracleProvider::execLoggedStatic( query, sql, args, uri, QStringLiteral( "QgsOracleProvider" ), QString(QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") ) +#define LoggedExecStatic( query, sql, args, uri ) QgsOracleProvider::execLoggedStatic( query, sql, args, uri, QStringLiteral( "QgsOracleProvider" ), QString( QString( __FILE__ ).mid( sOracleConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) ) const QString ORACLE_KEY = "oracle"; const QString ORACLE_DESCRIPTION = "Oracle data provider"; -QgsOracleProvider::QgsOracleProvider( QString const &uri, const ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) +QgsOracleProvider::QgsOracleProvider( QString const &uri, const ProviderOptions &options, Qgis::DataProviderReadFlags flags ) : QgsVectorDataProvider( uri, options, flags ) , mValid( false ) , mIsQuery( false ) @@ -320,8 +319,8 @@ bool QgsOracleProvider::execLoggedStatic( QSqlQuery &qry, const QString &sql, co if ( !res ) { QgsDebugError( QStringLiteral( "SQL: %1\nERROR: %2" ) - .arg( qry.lastQuery() ) - .arg( qry.lastError().text() ) ); + .arg( qry.lastQuery() ) + .arg( qry.lastError().text() ) ); } logWrapper.setQuery( QgsOracleConn::getLastExecutedQuery( qry ) ); @@ -606,13 +605,11 @@ bool QgsOracleProvider::loadFields() { QgsDebugMsgLevel( QStringLiteral( "Loading fields for table %1" ).arg( mTableName ), 2 ); - if ( LoggedExecStatic( qry, QStringLiteral( "SELECT comments FROM all_tab_comments WHERE owner=? AND table_name=?" ), - QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) + if ( LoggedExecStatic( qry, QStringLiteral( "SELECT comments FROM all_tab_comments WHERE owner=? AND table_name=?" ), QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) { if ( qry.next() ) mDataComment = qry.value( 0 ).toString(); - else if ( LoggedExecStatic( qry, QStringLiteral( "SELECT comments FROM all_mview_comments WHERE owner=? AND mview_name=?" ), - QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) + else if ( LoggedExecStatic( qry, QStringLiteral( "SELECT comments FROM all_mview_comments WHERE owner=? AND mview_name=?" ), QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) { if ( qry.next() ) mDataComment = qry.value( 0 ).toString(); @@ -621,24 +618,21 @@ bool QgsOracleProvider::loadFields() else { const QString error { tr( "Loading comment for table %1.%2 failed [%3]" ) - .arg( mOwnerName ) - .arg( mTableName ) - .arg( qry.lastError().text() ) }; - QgsMessageLog::logMessage( error, - tr( "Oracle" ) ); + .arg( mOwnerName ) + .arg( mTableName ) + .arg( qry.lastError().text() ) }; + QgsMessageLog::logMessage( error, tr( "Oracle" ) ); } qry.finish(); - if ( LoggedExecStatic( qry, QStringLiteral( "SELECT column_name,comments FROM all_col_comments t WHERE t.owner=? AND t.table_name=?" ), - QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) + if ( LoggedExecStatic( qry, QStringLiteral( "SELECT column_name,comments FROM all_col_comments t WHERE t.owner=? AND t.table_name=?" ), QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) { while ( qry.next() ) { if ( qry.value( 0 ).toString() == mGeometryColumn ) continue; comments.insert( qry.value( 0 ).toString(), qry.value( 1 ).toString() ); - } } else @@ -657,16 +651,9 @@ bool QgsOracleProvider::loadFields() ",t.data_scale" ",t.char_length" ",t.char_used" - ",t.data_default" + - QString( mOracleVersion >= 12 ? - ",CASE WHEN t.virtual_column = 'YES' OR a.generation_type = 'ALWAYS' THEN 'YES' ELSE 'NO' END" : - ",t.virtual_column" ) + - " FROM all_tab_cols t" + - QString( mOracleVersion >= 12 ? - " LEFT JOIN all_tab_identity_cols a ON a.column_name = t.column_name AND a.owner = t.owner AND a.table_name = t.table_name" : - "" ) + - " WHERE t.owner=? AND t.table_name=?" - " AND t.hidden_column='NO'" ) ; + ",t.data_default" + + QString( mOracleVersion >= 12 ? ",CASE WHEN t.virtual_column = 'YES' OR a.generation_type = 'ALWAYS' THEN 'YES' ELSE 'NO' END" : ",t.virtual_column" ) + " FROM all_tab_cols t" + QString( mOracleVersion >= 12 ? " LEFT JOIN all_tab_identity_cols a ON a.column_name = t.column_name AND a.owner = t.owner AND a.table_name = t.table_name" : "" ) + " WHERE t.owner=? AND t.table_name=?" + " AND t.hidden_column='NO'" ); args << mOwnerName << mTableName; if ( !mGeometryColumn.isEmpty() ) @@ -686,14 +673,14 @@ bool QgsOracleProvider::loadFields() { while ( qry.next() ) { - QString name = qry.value( 0 ).toString(); - QString type = qry.value( 1 ).toString(); - int prec = qry.value( 2 ).toInt(); - int scale = qry.value( 3 ).toInt(); - int clength = qry.value( 4 ).toInt(); - bool cused = qry.value( 5 ).toString() == "C"; + QString name = qry.value( 0 ).toString(); + QString type = qry.value( 1 ).toString(); + int prec = qry.value( 2 ).toInt(); + int scale = qry.value( 3 ).toInt(); + int clength = qry.value( 4 ).toInt(); + bool cused = qry.value( 5 ).toString() == "C"; QVariant defValue = qry.value( 6 ); - bool alwaysGen = qry.value( 7 ).toString() == "YES"; + bool alwaysGen = qry.value( 7 ).toString() == "YES"; if ( type == "CHAR" || type == "VARCHAR2" || type == "VARCHAR" ) { @@ -722,17 +709,15 @@ bool QgsOracleProvider::loadFields() defvalues.insert( name, defValue ); alwaysGenerated.insert( name, alwaysGen ); } - } else { const QString error { tr( "Loading field types for table %1.%2 failed [%3]" ) - .arg( mOwnerName ) - .arg( mTableName ) - .arg( qry.lastError().text() ) }; + .arg( mOwnerName ) + .arg( mTableName ) + .arg( qry.lastError().text() ) }; - QgsMessageLog::logMessage( error, - tr( "Oracle" ) ); + QgsMessageLog::logMessage( error, tr( "Oracle" ) ); } if ( !mGeometryColumn.isEmpty() ) @@ -745,21 +730,17 @@ bool QgsOracleProvider::loadFields() { if ( !mHasSpatialIndex ) { - const QString sql{ QStringLiteral( "SELECT %2 FROM %1 WHERE sdo_filter(%2,mdsys.sdo_geometry(2003,%3,NULL,mdsys.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(-1,-1,1,1)))='TRUE'" ) - .arg( mQuery ) - .arg( quotedIdentifier( mGeometryColumn ) ) - .arg( mSrid < 1 ? "NULL" : QString::number( mSrid ) ) }; + const QString sql { QStringLiteral( "SELECT %2 FROM %1 WHERE sdo_filter(%2,mdsys.sdo_geometry(2003,%3,NULL,mdsys.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(-1,-1,1,1)))='TRUE'" ) + .arg( mQuery ) + .arg( quotedIdentifier( mGeometryColumn ) ) + .arg( mSrid < 1 ? "NULL" : QString::number( mSrid ) ) }; mHasSpatialIndex = LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ); } if ( !mHasSpatialIndex ) { - QgsMessageLog::logMessage( tr( "No spatial index on column %1.%2.%3 found - expect poor performance." ) - .arg( mOwnerName ) - .arg( mTableName ) - .arg( mGeometryColumn ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "No spatial index on column %1.%2.%3 found - expect poor performance." ).arg( mOwnerName ).arg( mTableName ).arg( mGeometryColumn ), tr( "Oracle" ) ); } } @@ -830,18 +811,16 @@ bool QgsOracleProvider::hasSufficientPermsAndCapabilities() { // full set of privileges for the owner mEnabledCapabilities |= Qgis::VectorProviderCapability::DeleteFeatures - | Qgis::VectorProviderCapability::ChangeAttributeValues - | Qgis::VectorProviderCapability::AddFeatures - | Qgis::VectorProviderCapability::AddAttributes - | Qgis::VectorProviderCapability::DeleteAttributes - | Qgis::VectorProviderCapability::ChangeGeometries - | Qgis::VectorProviderCapability::RenameAttributes - ; + | Qgis::VectorProviderCapability::ChangeAttributeValues + | Qgis::VectorProviderCapability::AddFeatures + | Qgis::VectorProviderCapability::AddAttributes + | Qgis::VectorProviderCapability::DeleteAttributes + | Qgis::VectorProviderCapability::ChangeGeometries + | Qgis::VectorProviderCapability::RenameAttributes; } else { - if ( LoggedExecStatic( qry, QStringLiteral( "SELECT privilege FROM all_tab_privs WHERE table_schema=? AND table_name=? AND privilege IN ('DELETE','UPDATE','INSERT','ALTER TABLE')" ), - QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) + if ( LoggedExecStatic( qry, QStringLiteral( "SELECT privilege FROM all_tab_privs WHERE table_schema=? AND table_name=? AND privilege IN ('DELETE','UPDATE','INSERT','ALTER TABLE')" ), QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) { // check grants while ( qry.next() ) @@ -868,9 +847,7 @@ bool QgsOracleProvider::hasSufficientPermsAndCapabilities() if ( !mGeometryColumn.isNull() ) { - - if ( LoggedExecStatic( qry, QStringLiteral( "SELECT 1 FROM all_col_privs WHERE table_schema=? AND table_name=? AND column_name=? AND privilege='UPDATE'" ), - QVariantList() << mOwnerName << mTableName << mGeometryColumn, mUri.uri() ) ) + if ( LoggedExecStatic( qry, QStringLiteral( "SELECT 1 FROM all_col_privs WHERE table_schema=? AND table_name=? AND column_name=? AND privilege='UPDATE'" ), QVariantList() << mOwnerName << mTableName << mGeometryColumn, mUri.uri() ) ) { if ( qry.next() ) mEnabledCapabilities |= Qgis::VectorProviderCapability::ChangeGeometries; @@ -878,23 +855,21 @@ bool QgsOracleProvider::hasSufficientPermsAndCapabilities() else { const QString error { tr( "Unable to determine geometry column access privileges for column %1.%2.\nThe error message from the database was:\n%3.\nSQL: %4" ) - .arg( mQuery ) - .arg( mGeometryColumn ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ) }; - QgsMessageLog::logMessage( error, - tr( "Oracle" ) ); + .arg( mQuery ) + .arg( mGeometryColumn ) + .arg( qry.lastError().text() ) + .arg( qry.lastQuery() ) }; + QgsMessageLog::logMessage( error, tr( "Oracle" ) ); } } } else { const QString error { tr( "Unable to determine table access privileges for the table %1.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mQuery ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ) }; - QgsMessageLog::logMessage( error, - tr( "Oracle" ) ); + .arg( mQuery ) + .arg( qry.lastError().text() ) + .arg( qry.lastQuery() ) }; + QgsMessageLog::logMessage( error, tr( "Oracle" ) ); } } } @@ -911,8 +886,8 @@ bool QgsOracleProvider::hasSufficientPermsAndCapabilities() if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) { const QString error { tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ) }; + .arg( qry.lastError().text() ) + .arg( qry.lastQuery() ) }; QgsMessageLog::logMessage( error, tr( "Oracle" ) ); return false; } @@ -952,10 +927,7 @@ bool QgsOracleProvider::determinePrimaryKey() QgsField fld = mAttributeFields.at( idx ); - if ( isInt && - fld.type() != QMetaType::Type::Int && - fld.type() != QMetaType::Type::LongLong && - !( fld.type() == QMetaType::Type::Double && fld.precision() == 0 ) ) + if ( isInt && fld.type() != QMetaType::Type::Int && fld.type() != QMetaType::Type::LongLong && !( fld.type() == QMetaType::Type::Double && fld.precision() == 0 ) ) isInt = false; mPrimaryKeyAttrs << idx; @@ -970,8 +942,8 @@ bool QgsOracleProvider::determinePrimaryKey() if ( !LoggedExecStatic( qry, QStringLiteral( "SELECT 1 FROM all_tables WHERE owner=? AND table_name=?" ), QVariantList() << mOwnerName << mTableName, mUri.uri() ) ) { const QString error { tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ) }; + .arg( qry.lastError().text() ) + .arg( qry.lastQuery() ) }; QgsMessageLog::logMessage( error, tr( "Oracle" ) ); } else if ( qry.next() ) @@ -1002,7 +974,7 @@ bool QgsOracleProvider::determinePrimaryKey() QgsFieldConstraints constraints = mAttributeFields.at( fieldIdx ).constraints(); constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); - mAttributeFields[ fieldIdx ].setConstraints( constraints ); + mAttributeFields[fieldIdx].setConstraints( constraints ); } return mValid; @@ -1023,9 +995,7 @@ void QgsOracleProvider::determinePrimaryKeyFromUriKeyColumn() if ( mUseEstimatedMetadata || uniqueData( mQuery, primaryKey ) ) { - if ( fld.type() == QMetaType::Type::Int || - fld.type() == QMetaType::Type::LongLong || - ( fld.type() == QMetaType::Type::Double && fld.precision() == 0 ) ) + if ( fld.type() == QMetaType::Type::Int || fld.type() == QMetaType::Type::LongLong || ( fld.type() == QMetaType::Type::Double && fld.precision() == 0 ) ) { mPrimaryKeyType = PktInt; } @@ -1067,12 +1037,11 @@ bool QgsOracleProvider::uniqueData( QString query, QString colName ) // This is tricky: in case of SQL query layers we have a generated uid in the form "qgis_generated_uid_%1_" which cannot be quoted as identifier. QString sql = QString( "SELECT (SELECT count(distinct %1) FROM %2)-(SELECT count(%1) FROM %2) FROM dual" ) - .arg( colName.startsWith( QLatin1String( "qgis_generated_uid_" ) ) ? colName : quotedIdentifier( colName ), mQuery ); + .arg( colName.startsWith( QLatin1String( "qgis_generated_uid_" ) ) ? colName : quotedIdentifier( colName ), mQuery ); if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) || !qry.next() ) { - QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ).arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); return false; } @@ -1091,7 +1060,7 @@ QVariant QgsOracleProvider::minimumValue( int index ) const // get the field name QgsField fld = field( index ); QString sql = QString( "SELECT min(%1) FROM %2" ) - .arg( quotedIdentifier( fld.name() ), mQuery ); + .arg( quotedIdentifier( fld.name() ), mQuery ); if ( !mSqlWhereClause.isEmpty() ) { @@ -1102,8 +1071,7 @@ QVariant QgsOracleProvider::minimumValue( int index ) const if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) { - QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ).arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); return QVariant( QString() ); } @@ -1133,15 +1101,15 @@ QSet QgsOracleProvider::uniqueValues( int index, int limit ) const // get the field name QgsField fld = field( index ); QString sql = QString( "SELECT DISTINCT %1 FROM %2" ) - .arg( quotedIdentifier( fld.name() ), mQuery ); + .arg( quotedIdentifier( fld.name() ), mQuery ); if ( !mSqlWhereClause.isEmpty() ) { sql += QString( " WHERE %1" ).arg( mSqlWhereClause ); } - sql += QString( " ORDER BY %1" ) - .arg( quotedIdentifier( fld.name() ) ); + sql += QString( " ORDER BY %1" ) + .arg( quotedIdentifier( fld.name() ) ); if ( limit >= 0 ) { @@ -1152,8 +1120,7 @@ QSet QgsOracleProvider::uniqueValues( int index, int limit ) const if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) { - QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ).arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); return QSet(); } @@ -1182,8 +1149,8 @@ QVariant QgsOracleProvider::maximumValue( int index ) const // get the field name QgsField fld = field( index ); QString sql = QString( "SELECT max(%1) FROM %2" ) - .arg( quotedIdentifier( fld.name() ) ) - .arg( mQuery ); + .arg( quotedIdentifier( fld.name() ) ) + .arg( mQuery ); if ( !mSqlWhereClause.isEmpty() ) { @@ -1194,8 +1161,7 @@ QVariant QgsOracleProvider::maximumValue( int index ) const if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) { - QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ).arg( qry.lastError().text(), qry.lastQuery() ), tr( "Oracle" ) ); return QVariant( QString() ); } @@ -1365,7 +1331,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag // look for unique attribute values to place in statement instead of passing as parameter // e.g. for defaults -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) for ( int idx = 0; idx < std::min( attributevec.size(), mAttributeFields.size() ); ++idx ) #else for ( int idx = 0; idx < std::min( attributevec.size(), static_cast( mAttributeFields.size() ) ); ++idx ) @@ -1420,8 +1386,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag QVariant value = attributevec.value( fieldId[i], QVariant() ); QgsField fld = field( fieldId[i] ); - if ( ( value.isNull() && mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() ) || - ( value.toString() == defaultValues[i] ) ) + if ( ( value.isNull() && mPrimaryKeyAttrs.contains( i ) && !defaultValues.at( i ).isEmpty() ) || ( value.toString() == defaultValues[i] ) ) { value = evaluateDefaultExpression( defaultValues[i], fld.type() ); } @@ -1500,7 +1465,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag if ( mPrimaryKeyType == PktInt ) { - features->setId( STRING_TO_FID( attributevec[ mPrimaryKeyAttrs[0] ] ) ); + features->setId( STRING_TO_FID( attributevec[mPrimaryKeyAttrs[0]] ) ); } else { @@ -1509,7 +1474,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag const auto constMPrimaryKeyAttrs = mPrimaryKeyAttrs; for ( int idx : constMPrimaryKeyAttrs ) { - primaryKeyVals << attributevec[ idx ]; + primaryKeyVals << attributevec[idx]; } features->setId( mShared->lookupFid( primaryKeyVals ) ); @@ -1562,7 +1527,7 @@ bool QgsOracleProvider::deleteFeatures( const QgsFeatureIds &id ) { QVariantList args; QString sql = QStringLiteral( "DELETE FROM %1 WHERE %2" ) - .arg( mQuery, whereClause( *it, args ) ); + .arg( mQuery, whereClause( *it, args ) ); QgsDebugMsgLevel( "delete sql: " + sql, 2 ); if ( !LoggedExecStatic( qry, sql, args, mUri.uri() ) ) @@ -1635,7 +1600,7 @@ bool QgsOracleProvider::addAttributes( const QList &attributes ) } QString sql = QString( "ALTER TABLE %1 ADD %2 %3" ) - .arg( mQuery, quotedIdentifier( iter->name() ), type ); + .arg( mQuery, quotedIdentifier( iter->name() ), type ); QgsDebugMsgLevel( sql, 2 ); if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) @@ -1646,7 +1611,7 @@ bool QgsOracleProvider::addAttributes( const QList &attributes ) if ( !iter->comment().isEmpty() ) { sql = QString( "COMMENT ON COLUMN %1.%2 IS ?" ) - .arg( mQuery, quotedIdentifier( iter->name() ) ); + .arg( mQuery, quotedIdentifier( iter->name() ) ); if ( !LoggedExecStatic( qry, sql, QVariantList() << iter->comment(), mUri.uri() ) ) { @@ -1655,7 +1620,6 @@ bool QgsOracleProvider::addAttributes( const QList &attributes ) } qry.finish(); - } if ( !conn->commit( db ) ) @@ -1712,7 +1676,7 @@ bool QgsOracleProvider::deleteAttributes( const QgsAttributeIds &ids ) QgsField fld = mAttributeFields.at( id ); QString sql = QString( "ALTER TABLE %1 DROP COLUMN %2" ) - .arg( mQuery, quotedIdentifier( fld.name() ) ); + .arg( mQuery, quotedIdentifier( fld.name() ) ); //send sql statement and do error handling if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) @@ -1794,16 +1758,11 @@ bool QgsOracleProvider::renameAttributes( const QgsFieldNameMap &renamedAttribut { QString src( mAttributeFields.at( renameIt.key() ).name() ); const QString sql { QString( "ALTER TABLE %1 RENAME COLUMN %2 TO %3" ) - .arg( mQuery, - quotedIdentifier( src ), - quotedIdentifier( renameIt.value() ) ) }; + .arg( mQuery, quotedIdentifier( src ), quotedIdentifier( renameIt.value() ) ) }; if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) { - throw OracleException( tr( "Renaming column %1 to %2 failed" ) - .arg( quotedIdentifier( src ), - quotedIdentifier( renameIt.value() ) ), - qry ); + throw OracleException( tr( "Renaming column %1 to %2 failed" ).arg( quotedIdentifier( src ), quotedIdentifier( renameIt.value() ) ), qry ); } } @@ -1923,13 +1882,13 @@ bool QgsOracleProvider::changeAttributeValues( const QgsChangedAttributesMap &at QgsGeometry g; if ( !attrs[idx].isNull() ) { - g = QgsGeometry::fromWkt( attrs[ idx ].toString() ); + g = QgsGeometry::fromWkt( attrs[idx].toString() ); } appendGeomParam( g, qry ); } else { - qry.addBindValue( attrs[ idx ] ); + qry.addBindValue( attrs[idx] ); } } @@ -1961,7 +1920,7 @@ bool QgsOracleProvider::changeAttributeValues( const QgsChangedAttributesMap &at if ( !attrs.contains( idx ) ) continue; - k[i] = attrs[ idx ]; + k[i] = attrs[idx]; } mShared->insertFid( fid, k ); @@ -1996,20 +1955,20 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry QByteArray wkb = geom.asWkb(); wkbPtr ptr; - ptr.ucPtr = !geom.isEmpty() ? reinterpret_cast< unsigned char * >( const_cast( wkb.constData() ) ) : nullptr; + ptr.ucPtr = !geom.isEmpty() ? reinterpret_cast( const_cast( wkb.constData() ) ) : nullptr; g.isNull = !ptr.ucPtr; g.gtype = -1; - g.srid = mSrid < 1 ? -1 : mSrid; + g.srid = mSrid < 1 ? -1 : mSrid; if ( !g.isNull ) { - ptr.ucPtr++; // skip endianness + ptr.ucPtr++; // skip endianness g.eleminfo.clear(); g.ordinates.clear(); int iOrdinate = 1; - Qgis::WkbType type = static_cast< Qgis::WkbType >( * ptr.iPtr++ ); + Qgis::WkbType type = static_cast( *ptr.iPtr++ ); int dim = 2; switch ( type ) @@ -2020,7 +1979,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry [[fallthrough]]; case Qgis::WkbType::Point: - g.srid = mSrid; + g.srid = mSrid; g.gtype = SDO_GTYPE( dim, GtPoint ); g.x = *ptr.dPtr++; g.y = *ptr.dPtr++; @@ -2057,7 +2016,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry g.ordinates << *ptr.dPtr++; if ( dim == 3 ) g.ordinates << *ptr.dPtr++; - iOrdinate += dim; + iOrdinate += dim; } ptr.ucPtr++; // Skip endianness of next linestring @@ -2078,9 +2037,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry { g.gtype = SDO_GTYPE( dim, GtPolygon ); int nPolygons = 1; - const QgsMultiPolygon *multipoly = - ( QgsWkbTypes::flatType( type ) == Qgis::WkbType::MultiPolygon ) ? - dynamic_cast( geom.constGet() ) : nullptr; + const QgsMultiPolygon *multipoly = ( QgsWkbTypes::flatType( type ) == Qgis::WkbType::MultiPolygon ) ? dynamic_cast( geom.constGet() ) : nullptr; if ( multipoly ) { g.gtype = SDO_GTYPE( dim, GtMultiPolygon ); @@ -2092,18 +2049,14 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry for ( int iPolygon = 0; iPolygon < nPolygons; iPolygon++ ) { - const QgsPolygon *poly = multipoly ? - dynamic_cast( multipoly->geometryN( iPolygon ) ) : - dynamic_cast( geom.constGet() ); + const QgsPolygon *poly = multipoly ? dynamic_cast( multipoly->geometryN( iPolygon ) ) : dynamic_cast( geom.constGet() ); for ( int iRing = 0, nRings = *ptr.iPtr++; iRing < nRings; iRing++ ) { g.eleminfo << iOrdinate << ( iRing == 0 ? 1003 : 2003 ) << 1; // Oracle polygons must have their exterior ring in counterclockwise // order, and the interior ring(s) in clockwise order. - const bool reverseRing = - iRing == 0 ? poly->exteriorRing()->orientation() == Qgis::AngularDirection::Clockwise : - poly->interiorRing( iRing - 1 )->orientation() == Qgis::AngularDirection::CounterClockwise; + const bool reverseRing = iRing == 0 ? poly->exteriorRing()->orientation() == Qgis::AngularDirection::Clockwise : poly->interiorRing( iRing - 1 )->orientation() == Qgis::AngularDirection::CounterClockwise; const int n = *ptr.iPtr++; if ( reverseRing ) @@ -2129,7 +2082,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry g.ordinates << *ptr.dPtr++; } } - iOrdinate += n * dim; + iOrdinate += n * dim; } ptr.ucPtr++; // Skip endianness of next polygon @@ -2186,8 +2139,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry Qgis::WkbType curveType = type; if ( type == Qgis::WkbType::MultiCurve || type == Qgis::WkbType::MultiCurveZ ) { - ptr.ucPtr++; // Skip endianness of curve - curveType = static_cast< Qgis::WkbType >( * ptr.iPtr++ ); // type of curve + ptr.ucPtr++; // Skip endianness of curve + curveType = static_cast( *ptr.iPtr++ ); // type of curve } int nLines = 1; @@ -2202,16 +2155,16 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry g.eleminfo << iOrdinate << 4 << nLines; } - ptr.ucPtr++; // Skip endianness of first linestring - lineType = static_cast< Qgis::WkbType >( * ptr.iPtr++ ); // type of first linestring + ptr.ucPtr++; // Skip endianness of first linestring + lineType = static_cast( *ptr.iPtr++ ); // type of first linestring } for ( int iLine = 0; iLine < nLines; iLine++ ) { if ( iLine > 0 ) { - ptr.ucPtr++; // Skip endianness of linestring - lineType = static_cast< Qgis::WkbType >( * ptr.iPtr++ ); // type of linestring + ptr.ucPtr++; // Skip endianness of linestring + lineType = static_cast( *ptr.iPtr++ ); // type of linestring } bool circularString = lineType == Qgis::WkbType::CircularString || lineType == Qgis::WkbType::CircularStringZ; @@ -2233,7 +2186,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry if ( dim == 3 ) g.ordinates << *ptr.dPtr++; - iOrdinate += dim; + iOrdinate += dim; } } } @@ -2251,9 +2204,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry { g.gtype = SDO_GTYPE( dim, GtPolygon ); int nSurfaces = 1; - const QgsMultiSurface *multisurface = - ( QgsWkbTypes::flatType( type ) == Qgis::WkbType::MultiSurface ) ? - dynamic_cast( geom.constGet() ) : nullptr; + const QgsMultiSurface *multisurface = ( QgsWkbTypes::flatType( type ) == Qgis::WkbType::MultiSurface ) ? dynamic_cast( geom.constGet() ) : nullptr; if ( multisurface ) { g.gtype = SDO_GTYPE( dim, GtMultiPolygon ); @@ -2262,9 +2213,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry for ( int iSurface = 0; iSurface < nSurfaces; iSurface++ ) { - const QgsCurvePolygon *curvepoly = multisurface ? - dynamic_cast( multisurface->geometryN( iSurface ) ) : - dynamic_cast( geom.constGet() ); + const QgsCurvePolygon *curvepoly = multisurface ? dynamic_cast( multisurface->geometryN( iSurface ) ) : dynamic_cast( geom.constGet() ); const int nRings = ( curvepoly->exteriorRing() ? 1 : 0 ) + curvepoly->numInteriorRings(); @@ -2275,9 +2224,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry // Oracle polygons must have their exterior ring in counterclockwise // order, and the interior ring(s) in clockwise order. - const bool reverseRing = - iRing == 0 ? ring->orientation() == Qgis::AngularDirection::Clockwise : - ring->orientation() == Qgis::AngularDirection::CounterClockwise; + const bool reverseRing = iRing == 0 ? ring->orientation() == Qgis::AngularDirection::Clockwise : ring->orientation() == Qgis::AngularDirection::CounterClockwise; std::unique_ptr reversedRing( reverseRing ? ring->reversed() : nullptr ); const QgsCurve *correctedRing = reversedRing ? reversedRing.get() : ring; const QgsCompoundCurve *compound = dynamic_cast( correctedRing ); @@ -2325,7 +2272,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry if ( dim == 3 ) g.ordinates << p.z(); - iOrdinate += dim; + iOrdinate += dim; } } } @@ -2382,14 +2329,7 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry &geom, QSqlQuery &qry } } - QgsDebugMsgLevel( QStringLiteral( "addBindValue geometry: isNull=%1 gtype=%2 srid=%3 p=%4,%5,%6 eleminfo=%7 ordinates=%8" ) - .arg( g.isNull ) - .arg( g.gtype ) - .arg( g.srid ) - .arg( g.x ).arg( g.y ).arg( g.z ) - .arg( g.eleminfo.size() ) - .arg( g.ordinates.size() ) - , 4 ); + QgsDebugMsgLevel( QStringLiteral( "addBindValue geometry: isNull=%1 gtype=%2 srid=%3 p=%4,%5,%6 eleminfo=%7 ordinates=%8" ).arg( g.isNull ).arg( g.gtype ).arg( g.srid ).arg( g.x ).arg( g.y ).arg( g.z ).arg( g.eleminfo.size() ).arg( g.ordinates.size() ), 4 ); qry.addBindValue( QVariant::fromValue( g ) ); } @@ -2412,9 +2352,9 @@ bool QgsOracleProvider::changeGeometryValues( const QgsGeometryMap &geometry_map } QString update = QString( "UPDATE %1 SET %2=? WHERE %3" ) - .arg( mQuery ) - .arg( quotedIdentifier( mGeometryColumn ) ) - .arg( pkParamWhereClause() ); + .arg( mQuery ) + .arg( quotedIdentifier( mGeometryColumn ) ) + .arg( pkParamWhereClause() ); QgsDebugMsgLevel( QStringLiteral( "SQL prepare: %1" ).arg( update ), 4 ); if ( !qry.prepare( update ) ) { @@ -2546,8 +2486,7 @@ QList QgsOracleProvider::searchLayers( const QList( layer->dataProvider() ); - if ( oracleProvider && - oracleProvider->mUri.connectionInfo( false ) == connectionInfo && oracleProvider->mOwnerName == owner && oracleProvider->mTableName == tableName ) + if ( oracleProvider && oracleProvider->mUri.connectionInfo( false ) == connectionInfo && oracleProvider->mOwnerName == owner && oracleProvider->mTableName == tableName ) { result.append( layer ); } @@ -2594,9 +2533,9 @@ QList QgsOracleProvider::discoverRelations( const QgsVectorLayer *t if ( !LoggedExecStatic( qry, sql, QVariantList() << mTableName << mOwnerName, mUri.uri() ) ) { const QString error { tr( "Unable to execute the query to get foreign keys of %1.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mTableName ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ) }; + .arg( mTableName ) + .arg( qry.lastError().text() ) + .arg( qry.lastQuery() ) }; QgsLogger::warning( error ); return result; } @@ -2679,15 +2618,7 @@ long long QgsOracleProvider::featureCount() const sql = QString( "explain plan for select 1 from %1.%2" ).arg( quotedIdentifier( mOwnerName ) ).arg( quotedIdentifier( mTableName ) ); if ( !mSqlWhereClause.isEmpty() ) sql += " WHERE " + mSqlWhereClause; - if ( LoggedExecStatic( qry, - sql, - QVariantList(), - mUri.uri() ) && - LoggedExecStatic( qry, - QStringLiteral( "SELECT dbms_xplan.display_plan(format=>'basic,rows', type=>'xml') FROM dual" ), - QVariantList(), - mUri.uri() ) && - qry.next() ) + if ( LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) && LoggedExecStatic( qry, QStringLiteral( "SELECT dbms_xplan.display_plan(format=>'basic,rows', type=>'xml') FROM dual" ), QVariantList(), mUri.uri() ) && qry.next() ) { QDomDocument plan; plan.setContent( qry.value( 0 ).toString() ); @@ -2766,16 +2697,12 @@ QgsRectangle QgsOracleProvider::extent() const const QString sql { QStringLiteral( "SELECT sdo_lb,sdo_ub FROM mdsys.all_sdo_geom_metadata m, table(m.diminfo) WHERE owner=? AND table_name=? AND column_name=? AND sdo_dimname='X'" ) }; - if ( LoggedExecStatic( qry, sql, - QVariantList() << mOwnerName << mTableName << mGeometryColumn, mUri.uri() ) && - qry.next() ) + if ( LoggedExecStatic( qry, sql, QVariantList() << mOwnerName << mTableName << mGeometryColumn, mUri.uri() ) && qry.next() ) { mLayerExtent.setXMinimum( qry.value( 0 ).toDouble() ); mLayerExtent.setXMaximum( qry.value( 1 ).toDouble() ); - if ( LoggedExecStatic( qry, QStringLiteral( "SELECT sdo_lb,sdo_ub FROM mdsys.all_sdo_geom_metadata m, table(m.diminfo) WHERE owner=? AND table_name=? AND column_name=? AND sdo_dimname='Y'" ), - QVariantList() << mOwnerName << mTableName << mGeometryColumn, mUri.uri() ) && - qry.next() ) + if ( LoggedExecStatic( qry, QStringLiteral( "SELECT sdo_lb,sdo_ub FROM mdsys.all_sdo_geom_metadata m, table(m.diminfo) WHERE owner=? AND table_name=? AND column_name=? AND sdo_dimname='Y'" ), QVariantList() << mOwnerName << mTableName << mGeometryColumn, mUri.uri() ) && qry.next() ) { mLayerExtent.setYMinimum( qry.value( 0 ).toDouble() ); mLayerExtent.setYMaximum( qry.value( 1 ).toDouble() ); @@ -2787,9 +2714,7 @@ QgsRectangle QgsOracleProvider::extent() const if ( mHasSpatialIndex && mUseEstimatedMetadata ) { const QString sql { QStringLiteral( "SELECT SDO_TUNE.EXTENT_OF(?,?) FROM dual" ) }; - ok = LoggedExecStatic( qry, - sql, - QVariantList() << QString( "%1.%2" ).arg( mOwnerName ).arg( mTableName ) << mGeometryColumn, mUri.uri() ); + ok = LoggedExecStatic( qry, sql, QVariantList() << QString( "%1.%2" ).arg( mOwnerName ).arg( mTableName ) << mGeometryColumn, mUri.uri() ); } } @@ -2849,13 +2774,11 @@ bool QgsOracleProvider::getGeometryDetails() QSqlQuery qry( *conn ); if ( mIsQuery ) { - const QString sql { QStringLiteral( "SELECT %1 FROM %2 WHERE 1=0" ).arg( quotedIdentifier( mGeometryColumn ) ).arg( mQuery ) }; + const QString sql { QStringLiteral( "SELECT %1 FROM %2 WHERE 1=0" ).arg( quotedIdentifier( mGeometryColumn ) ).arg( mQuery ) }; if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) { - QgsMessageLog::logMessage( tr( "Could not execute query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Could not execute query.\nThe error message from the database was:\n%1.\nSQL: %2" ).arg( qry.lastError().text() ).arg( qry.lastQuery() ), tr( "Oracle" ) ); mValid = false; return false; } @@ -2876,12 +2799,10 @@ bool QgsOracleProvider::getGeometryDetails() if ( !ownerName.isEmpty() ) { - { - const QString sql {QStringLiteral( "SELECT srid FROM mdsys.all_sdo_geom_metadata WHERE owner=? AND table_name=? AND column_name=?" ) }; + const QString sql { QStringLiteral( "SELECT srid FROM mdsys.all_sdo_geom_metadata WHERE owner=? AND table_name=? AND column_name=?" ) }; - if ( LoggedExecStatic( qry, sql, - QVariantList() << ownerName << tableName << geomCol, mUri.uri() ) ) + if ( LoggedExecStatic( qry, sql, QVariantList() << ownerName << tableName << geomCol, mUri.uri() ) ) { if ( qry.next() ) { @@ -2889,24 +2810,16 @@ bool QgsOracleProvider::getGeometryDetails() } else { - QgsMessageLog::logMessage( tr( "Could not retrieve SRID of %1.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mQuery ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Could not retrieve SRID of %1.\nThe error message from the database was:\n%2.\nSQL: %3" ).arg( mQuery ).arg( qry.lastError().text() ).arg( qry.lastQuery() ), tr( "Oracle" ) ); } } else { - QgsMessageLog::logMessage( tr( "Could not determine SRID of %1.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mQuery ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Could not determine SRID of %1.\nThe error message from the database was:\n%2.\nSQL: %3" ).arg( mQuery ).arg( qry.lastError().text() ).arg( qry.lastQuery() ), tr( "Oracle" ) ); } } - QString sql { mUseEstimatedMetadata ? - QStringLiteral( "SELECT DISTINCT gtype FROM (SELECT t.%1.sdo_gtype AS gtype FROM %2 t WHERE t.%1 IS NOT NULL AND rownum<100) WHERE rownum<=2" ) : - QStringLiteral( "SELECT DISTINCT t.%1.sdo_gtype FROM %2 t WHERE t.%1 IS NOT NULL AND rownum<=2" ) }; + QString sql { mUseEstimatedMetadata ? QStringLiteral( "SELECT DISTINCT gtype FROM (SELECT t.%1.sdo_gtype AS gtype FROM %2 t WHERE t.%1 IS NOT NULL AND rownum<100) WHERE rownum<=2" ) : QStringLiteral( "SELECT DISTINCT t.%1.sdo_gtype FROM %2 t WHERE t.%1 IS NOT NULL AND rownum<=2" ) }; sql = sql.arg( quotedIdentifier( geomCol ), mQuery ); @@ -2923,17 +2836,12 @@ bool QgsOracleProvider::getGeometryDetails() else { detectedType = Qgis::WkbType::Unknown; - QgsMessageLog::logMessage( tr( "%1 has no valid geometry types.\nSQL: %2" ) - .arg( mQuery ) - .arg( qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "%1 has no valid geometry types.\nSQL: %2" ).arg( mQuery ).arg( qry.lastQuery() ), tr( "Oracle" ) ); } } else { - QgsMessageLog::logMessage( tr( "Could not determine geometry type of %1.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mQuery ) - .arg( qry.lastError().text() ) - .arg( qry.lastQuery() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Could not determine geometry type of %1.\nThe error message from the database was:\n%2.\nSQL: %3" ).arg( mQuery ).arg( qry.lastError().text() ).arg( qry.lastQuery() ), tr( "Oracle" ) ); } } @@ -3039,42 +2947,24 @@ bool QgsOracleProvider::createSpatialIndex() ") WHERE table_name=? AND column_name=?" ) }; { - - if ( !LoggedExecStatic( qry, sql, - QVariantList() << r.xMinimum() << r.xMaximum() << r.yMinimum() << r.yMaximum() << mTableName << mGeometryColumn, mUri.uri() ) - ) + if ( !LoggedExecStatic( qry, sql, QVariantList() << r.xMinimum() << r.xMaximum() << r.yMinimum() << r.yMaximum() << mTableName << mGeometryColumn, mUri.uri() ) ) { - QgsMessageLog::logMessage( tr( "Could not update metadata for %1.%2.\nSQL: %3\nError: %4" ) - .arg( mTableName ) - .arg( mGeometryColumn ) - .arg( qry.lastQuery() ) - .arg( qry.lastError().text() ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Could not update metadata for %1.%2.\nSQL: %3\nError: %4" ).arg( mTableName ).arg( mGeometryColumn ).arg( qry.lastQuery() ).arg( qry.lastError().text() ), tr( "Oracle" ) ); return false; } - } if ( qry.numRowsAffected() == 0 ) { - const QString sql { QStringLiteral( "INSERT INTO mdsys.user_sdo_geom_metadata(table_name,column_name,srid,diminfo) VALUES (?,?,?,mdsys.sdo_dim_array(" "mdsys.sdo_dim_element('X', ?, ?, 0.001)," "mdsys.sdo_dim_element('Y', ?, ?, 0.001)" "))" ) }; - if ( !LoggedExecStatic( qry, sql, - QVariantList() << mTableName << mGeometryColumn << ( mSrid < 1 ? QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) : mSrid ) - << r.xMinimum() << r.xMaximum() << r.yMinimum() << r.yMaximum(), mUri.uri() ) - ) + if ( !LoggedExecStatic( qry, sql, QVariantList() << mTableName << mGeometryColumn << ( mSrid < 1 ? QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) : mSrid ) << r.xMinimum() << r.xMaximum() << r.yMinimum() << r.yMaximum(), mUri.uri() ) ) { - QgsMessageLog::logMessage( tr( "Could not insert metadata for %1.%2.\nSQL: %3\nError: %4" ) - .arg( quotedValue( mTableName ) ) - .arg( quotedValue( mGeometryColumn ) ) - .arg( qry.lastQuery() ) - .arg( qry.lastError().text() ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Could not insert metadata for %1.%2.\nSQL: %3\nError: %4" ).arg( quotedValue( mTableName ) ).arg( quotedValue( mGeometryColumn ) ).arg( qry.lastQuery() ).arg( qry.lastError().text() ), tr( "Oracle" ) ); return false; } } @@ -3094,15 +2984,11 @@ bool QgsOracleProvider::createSpatialIndex() } else { - const QString sql { QStringLiteral( "ALTER INDEX %1 REBUILD" ).arg( mSpatialIndexName ) }; if ( !LoggedExecStatic( qry, sql, QVariantList(), mUri.uri() ) ) { - QgsMessageLog::logMessage( tr( "Rebuild of spatial index failed.\nSQL: %1\nError: %2" ) - .arg( qry.lastQuery() ) - .arg( qry.lastError().text() ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Rebuild of spatial index failed.\nSQL: %1\nError: %2" ).arg( qry.lastQuery() ).arg( qry.lastError().text() ), tr( "Oracle" ) ); return false; } } @@ -3170,14 +3056,7 @@ bool QgsOracleProvider::convertField( QgsField &field ) } -Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap &oldToNewAttrIdxMap, - QString &errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) { Q_UNUSED( wkbType ) Q_UNUSED( options ) @@ -3258,8 +3137,7 @@ Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri // It's not possible to create a table without any column, so we add a fake one // if needed, and will remove it later - const QString fakeColumn = geometryColumn.isEmpty() && !hasPrimaryKey ? - QString( "fake_column_%1" ).arg( QUuid::createUuid().toString() ) : QString(); + const QString fakeColumn = geometryColumn.isEmpty() && !hasPrimaryKey ? QString( "fake_column_%1" ).arg( QUuid::createUuid().toString() ) : QString(); try { @@ -3271,12 +3149,10 @@ Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri { const QString sql { QStringLiteral( "SELECT 1 FROM all_tables WHERE owner=? AND table_name=?" ) }; - if ( !LoggedExecStatic( qry, sql, - QVariantList() << ownerName << tableName, uri ) ) + if ( !LoggedExecStatic( qry, sql, QVariantList() << ownerName << tableName, uri ) ) { throw OracleException( tr( "Could not determine table existence." ), qry ); } - } bool exists = qry.next(); @@ -3337,8 +3213,8 @@ Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri catch ( OracleException &e ) { errorMessage = QObject::tr( "Creation of data source %1 failed: \n%2" ) - .arg( ownerTableName ) - .arg( e.errorMessage() ); + .arg( ownerTableName ) + .arg( e.errorMessage() ); if ( !conn->rollback( db ) ) { @@ -3347,14 +3223,11 @@ Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri if ( created ) { - const QString sql { QStringLiteral( "DROP TABLE %1" ).arg( ownerTableName ) }; if ( !LoggedExecStatic( qry, sql, QVariantList(), uri ) ) { - QgsMessageLog::logMessage( tr( "Drop created table %1 failed.\nSQL: %2\nError: %3" ) - .arg( qry.lastQuery() ) - .arg( qry.lastError().text() ), tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Drop created table %1 failed.\nSQL: %2\nError: %3" ).arg( qry.lastQuery() ).arg( qry.lastError().text() ), tr( "Oracle" ) ); } } @@ -3447,16 +3320,13 @@ Qgis::VectorExportResult QgsOracleProvider::createEmptyLayer( const QString &uri continue; } - if ( !( options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() ) && ! convertField( fld ) ) + if ( !( options && options->value( QStringLiteral( "skipConvertFields" ), false ).toBool() ) && !convertField( fld ) ) { errorMessage = QObject::tr( "Unsupported type for field %1" ).arg( fld.name() ); return Qgis::VectorExportResult::ErrorAttributeTypeUnsupported; } - QgsDebugMsgLevel( QStringLiteral( "Field #%1 name %2 type %3 typename %4 width %5 precision %6" ) - .arg( i ) - .arg( fld.name() ).arg( QVariant::typeToName( fld.type() ) ).arg( fld.typeName() ) - .arg( fld.length() ).arg( fld.precision() ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Field #%1 name %2 type %3 typename %4 width %5 precision %6" ).arg( i ).arg( fld.name() ).arg( QVariant::typeToName( fld.type() ) ).arg( fld.typeName() ).arg( fld.length() ).arg( fld.precision() ), 2 ); flist.append( fld ); oldToNewAttrIdxMap.insert( i, offset++ ); @@ -3526,12 +3396,10 @@ void QgsOracleProvider::insertGeomMetadata( QgsOracleConn *conn, const QString & const QString sql { QStringLiteral( "SELECT srid FROM mdsys.cs_srs WHERE wktext=?" ) }; { - if ( !LoggedExecStatic( qry, sql, QVariantList() << wkt, conn->connInfo() ) ) { throw OracleException( tr( "Could not lookup WKT." ), qry ); } - } if ( qry.next() ) @@ -3540,7 +3408,6 @@ void QgsOracleProvider::insertGeomMetadata( QgsOracleConn *conn, const QString & } else { - { const QString sql { QStringLiteral( "SELECT max(srid)+1 FROM sdo_coord_ref_system" ) }; @@ -3557,8 +3424,7 @@ void QgsOracleProvider::insertGeomMetadata( QgsOracleConn *conn, const QString & " VALUES (?,?,?,?,'TRUE','TRUE','GDAL/OGR via QGIS')" ) }; - if ( !LoggedExecStatic( qry, sql, - QVariantList() << srid << srs.description() << ( srs.isGeographic() ? "GEOGRAPHIC2D" : "PROJECTED" ) << wkt, conn->connInfo() ) ) + if ( !LoggedExecStatic( qry, sql, QVariantList() << srid << srs.description() << ( srs.isGeographic() ? "GEOGRAPHIC2D" : "PROJECTED" ) << wkt, conn->connInfo() ) ) { throw OracleException( tr( "CRS not found and could not be created." ), qry ); } @@ -3566,13 +3432,11 @@ void QgsOracleProvider::insertGeomMetadata( QgsOracleConn *conn, const QString & } if ( tableName.toUpper() != tableName || geometryColumn.toUpper() != geometryColumn ) - throw OracleException( tr( "Cannot insert geometry metadata for table '%1' and geometry column '%2'. Both needs to be uppercase" ).arg( - tableName, geometryColumn ), qry ); + throw OracleException( tr( "Cannot insert geometry metadata for table '%1' and geometry column '%2'. Both needs to be uppercase" ).arg( tableName, geometryColumn ), qry ); const QString sql { QStringLiteral( "INSERT INTO mdsys.user_sdo_geom_metadata(table_name,column_name,srid,diminfo) VALUES (?,?,?,%1)" ).arg( diminfo ) }; - if ( !LoggedExecStatic( qry, sql, - QVariantList() << tableName.toUpper() << geometryColumn.toUpper() << srid, conn->connInfo() ) ) + if ( !LoggedExecStatic( qry, sql, QVariantList() << tableName.toUpper() << geometryColumn.toUpper() << srid, conn->connInfo() ) ) { throw OracleException( tr( "Could not insert metadata." ), qry ); } @@ -3605,11 +3469,7 @@ QgsCoordinateReferenceSystem QgsOracleProvider::lookupCrs( QgsOracleConn *conn, } else { - QgsMessageLog::logMessage( tr( "Lookup of Oracle SRID %1 failed.\nSQL: %2\nError: %3" ) - .arg( srsid ) - .arg( qry.lastQuery() ) - .arg( qry.lastError().text() ), - tr( "Oracle" ) ); + QgsMessageLog::logMessage( tr( "Lookup of Oracle SRID %1 failed.\nSQL: %2\nError: %3" ).arg( srsid ).arg( qry.lastQuery() ).arg( qry.lastError().text() ), tr( "Oracle" ) ); } return srs; @@ -3636,16 +3496,16 @@ QString QgsOracleProvider::getTableName() size_t QgsOracleProvider::layerCount() const { - return 1; // XXX need to return actual number of layers + return 1; // XXX need to return actual number of layers } // QgsOracleProvider::layerCount() -QString QgsOracleProvider::name() const +QString QgsOracleProvider::name() const { return ORACLE_KEY; } // QgsOracleProvider::name() -QString QgsOracleProvider::description() const +QString QgsOracleProvider::description() const { return ORACLE_DESCRIPTION; } // QgsOracleProvider::description() @@ -3654,14 +3514,15 @@ QString QgsOracleProvider::description() const QgsOracleProvider *QgsOracleProviderMetadata::createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) + Qgis::DataProviderReadFlags flags +) { return new QgsOracleProvider( uri, options, flags ); } -QList< QgsDataItemProvider * > QgsOracleProviderMetadata::dataItemProviders() const +QList QgsOracleProviderMetadata::dataItemProviders() const { - return QList< QgsDataItemProvider * >() << new QgsOracleDataItemProvider; + return QList() << new QgsOracleDataItemProvider; } QgsTransaction *QgsOracleProviderMetadata::createTransaction( const QString &connString ) @@ -3671,28 +3532,21 @@ QgsTransaction *QgsOracleProviderMetadata::createTransaction( const QString &con // --------------------------------------------------------------------------- -Qgis::VectorExportResult QgsOracleProviderMetadata::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap &oldToNewAttrIdxMap, - QString &errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsOracleProviderMetadata::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) { return QgsOracleProvider::createEmptyLayer( - uri, fields, wkbType, srs, overwrite, - oldToNewAttrIdxMap, errorMessage, options - ); + uri, fields, wkbType, srs, overwrite, + oldToNewAttrIdxMap, errorMessage, options + ); } -QgsOracleProjectStorage *gOracleProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry() +QgsOracleProjectStorage *gOracleProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry() void QgsOracleProviderMetadata::initProvider() { Q_ASSERT( !gOracleProjectStorage ); gOracleProjectStorage = new QgsOracleProjectStorage; - QgsApplication::projectStorageRegistry()->registerProjectStorage( gOracleProjectStorage ); // takes ownership + QgsApplication::projectStorageRegistry()->registerProjectStorage( gOracleProjectStorage ); // takes ownership } void QgsOracleProviderMetadata::cleanupProvider() @@ -3727,7 +3581,7 @@ QVariant QgsOracleSharedData::removeFid( QgsFeatureId fid ) { QMutexLocker locker( &mMutex ); - QVariantList v = mFidToKey[ fid ]; + QVariantList v = mFidToKey[fid]; mFidToKey.remove( fid ); mKeyToFid.remove( v ); return v; @@ -3791,12 +3645,12 @@ bool QgsOracleProviderMetadata::styleExists( const QString &uri, const QString & args << ( styleId.isEmpty() ? dsUri.table() : styleId ); if ( !LoggedExecStatic( qry, "SELECT id,stylename FROM layer_styles" - " WHERE f_table_catalog=?" - " AND f_table_schema=?" - " AND f_table_name=?" - " AND f_geometry_column" + - QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) + - " AND styleName=?", args, dsUri.uri() ) ) + " WHERE f_table_catalog=?" + " AND f_table_schema=?" + " AND f_table_name=?" + " AND f_geometry_column" + + QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) + " AND styleName=?", + args, dsUri.uri() ) ) { errorCause = QObject::tr( "Unable to check style existence [%1]" ).arg( qry.lastError().text() ); conn->disconnect(); @@ -3814,14 +3668,7 @@ bool QgsOracleProviderMetadata::styleExists( const QString &uri, const QString & } } -bool QgsOracleProviderMetadata::saveStyle( const QString &uri, - const QString &qmlStyle, - const QString &sldStyle, - const QString &styleName, - const QString &styleDescription, - const QString &uiFileContent, - bool useAsDefault, - QString &errCause ) +bool QgsOracleProviderMetadata::saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) { errCause.clear(); @@ -3846,22 +3693,22 @@ bool QgsOracleProviderMetadata::saveStyle( const QString &uri, { QgsDebugMsgLevel( QStringLiteral( "Creating layer style table." ), 2 ); - if ( !LoggedExecStatic( qry, QStringLiteral( - "CREATE TABLE layer_styles(" - "id INTEGER PRIMARY KEY," - "f_table_catalog VARCHAR2(30) NOT NULL," - "f_table_schema VARCHAR2(30) NOT NULL," - "f_table_name VARCHAR2(30) NOT NULL," - "f_geometry_column VARCHAR2(30)," - "stylename VARCHAR2(2047)," - "styleqml CLOB," - "stylesld CLOB," - "useasdefault INTEGER," - "description VARCHAR2(2047)," - "owner VARCHAR2(30)," - "ui CLOB," - "update_time timestamp" - ")" ), QVariantList(), dsUri.uri() ) ) + if ( !LoggedExecStatic( qry, QStringLiteral( "CREATE TABLE layer_styles(" + "id INTEGER PRIMARY KEY," + "f_table_catalog VARCHAR2(30) NOT NULL," + "f_table_schema VARCHAR2(30) NOT NULL," + "f_table_name VARCHAR2(30) NOT NULL," + "f_geometry_column VARCHAR2(30)," + "stylename VARCHAR2(2047)," + "styleqml CLOB," + "stylesld CLOB," + "useasdefault INTEGER," + "description VARCHAR2(2047)," + "owner VARCHAR2(30)," + "ui CLOB," + "update_time timestamp" + ")" ), + QVariantList(), dsUri.uri() ) ) { errCause = QObject::tr( "Unable to create layer style table [%1]" ).arg( qry.lastError().text() ); conn->disconnect(); @@ -3872,18 +3719,18 @@ bool QgsOracleProviderMetadata::saveStyle( const QString &uri, int id; QString sql; - QVariantList args {dsUri.database(), dsUri.schema(), dsUri.table()}; + QVariantList args { dsUri.database(), dsUri.schema(), dsUri.table() }; if ( !dsUri.geometryColumn().isEmpty() ) args << dsUri.geometryColumn(); args << ( styleName.isEmpty() ? dsUri.table() : styleName ); if ( !LoggedExecStatic( qry, "SELECT id,stylename FROM layer_styles" - " WHERE f_table_catalog=?" - " AND f_table_schema=?" - " AND f_table_name=?" - " AND f_geometry_column" + - QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) + - " AND styleName=?", args, dsUri.uri() ) ) + " WHERE f_table_catalog=?" + " AND f_table_schema=?" + " AND f_table_name=?" + " AND f_geometry_column" + + QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) + " AND styleName=?", + args, dsUri.uri() ) ) { errCause = QObject::tr( "Unable to check style existence [%1]" ).arg( qry.lastError().text() ); conn->disconnect(); @@ -3907,8 +3754,8 @@ bool QgsOracleProviderMetadata::saveStyle( const QString &uri, "owner=?" "%1" " WHERE id=%2" ) - .arg( uiFileContent.isEmpty() ? "" : ",ui=?" ) - .arg( id ); + .arg( uiFileContent.isEmpty() ? "" : ",ui=?" ) + .arg( id ); } else if ( LoggedExecStatic( qry, QStringLiteral( "select coalesce(max(id)+1,0) FROM layer_styles" ), QVariantList(), dsUri.uri() ) && qry.next() ) @@ -3922,9 +3769,9 @@ bool QgsOracleProviderMetadata::saveStyle( const QString &uri, "(select current_timestamp from dual)" "%3" ")" ) - .arg( uiFileContent.isEmpty() ? "" : ",ui" ) - .arg( id ) - .arg( QString( ",?" ).repeated( uiFileContent.isEmpty() ? 10 : 11 ) ); + .arg( uiFileContent.isEmpty() ? "" : ",ui" ) + .arg( id ) + .arg( QString( ",?" ).repeated( uiFileContent.isEmpty() ? 10 : 11 ) ); } else { @@ -3933,13 +3780,7 @@ bool QgsOracleProviderMetadata::saveStyle( const QString &uri, return false; } - args = {dsUri.database(), dsUri.schema(), dsUri.table(), dsUri.geometryColumn(), - ( styleName.isEmpty() ? dsUri.table() : styleName ), - qmlStyle, sldStyle, - ( useAsDefault ? 1 : 0 ), - ( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ), - dsUri.username() - }; + args = { dsUri.database(), dsUri.schema(), dsUri.table(), dsUri.geometryColumn(), ( styleName.isEmpty() ? dsUri.table() : styleName ), qmlStyle, sldStyle, ( useAsDefault ? 1 : 0 ), ( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ), dsUri.username() }; if ( !uiFileContent.isEmpty() ) args << uiFileContent; @@ -3954,14 +3795,15 @@ bool QgsOracleProviderMetadata::saveStyle( const QString &uri, if ( useAsDefault ) { - args = {dsUri.database(), dsUri.schema(), dsUri.table(), dsUri.geometryColumn(), id}; + args = { dsUri.database(), dsUri.schema(), dsUri.table(), dsUri.geometryColumn(), id }; if ( !LoggedExecStatic( qry, QStringLiteral( "UPDATE layer_styles" - " SET useasdefault=0,update_time=(select current_timestamp from dual)" - " WHERE f_table_catalog=?" - " AND f_table_schema=?" - " AND f_table_name=?" - " AND f_geometry_column=?" - " AND id<>?" ), args, dsUri.uri() ) ) + " SET useasdefault=0,update_time=(select current_timestamp from dual)" + " WHERE f_table_catalog=?" + " AND f_table_schema=?" + " AND f_table_name=?" + " AND f_geometry_column=?" + " AND id<>?" ), + args, dsUri.uri() ) ) { errCause = QObject::tr( "Could not reset default status [%1]" ).arg( qry.lastError().text() ); QgsDebugError( QStringLiteral( "execute update failed" ) ); @@ -4004,20 +3846,20 @@ QString QgsOracleProviderMetadata::loadStoredStyle( const QString &uri, QString QString style; - QVariantList args { dsUri.database(), dsUri.schema(), dsUri.table()}; + QVariantList args { dsUri.database(), dsUri.schema(), dsUri.table() }; if ( !dsUri.geometryColumn().isEmpty() ) args << dsUri.geometryColumn(); if ( !LoggedExecStatic( qry, "SELECT styleName, styleQML FROM (" - "SELECT styleName, styleQML" - " FROM layer_styles" - " WHERE f_table_catalog=?" - " AND f_table_schema=?" - " AND f_table_name=?" - " AND f_geometry_column" + - QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) + - " ORDER BY useAsDefault DESC" - ") WHERE rownum=1", args, dsUri.uri() ) ) + "SELECT styleName, styleQML" + " FROM layer_styles" + " WHERE f_table_catalog=?" + " AND f_table_schema=?" + " AND f_table_name=?" + " AND f_geometry_column" + + QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) + " ORDER BY useAsDefault DESC" + ") WHERE rownum=1", + args, dsUri.uri() ) ) { errCause = QObject::tr( "Could not retrieve style [%1]" ).arg( qry.lastError().text() ); } @@ -4037,11 +3879,7 @@ QString QgsOracleProviderMetadata::loadStoredStyle( const QString &uri, QString } -int QgsOracleProviderMetadata::listStyles( const QString &uri, - QStringList &ids, - QStringList &names, - QStringList &descriptions, - QString &errCause ) +int QgsOracleProviderMetadata::listStyles( const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause ) { errCause.clear(); @@ -4062,12 +3900,11 @@ int QgsOracleProviderMetadata::listStyles( const QString &uri, return -1; } - QVariantList args {dsUri.database(), dsUri.schema(), dsUri.table()}; + QVariantList args { dsUri.database(), dsUri.schema(), dsUri.table() }; if ( !dsUri.geometryColumn().isEmpty() ) args << dsUri.geometryColumn(); - if ( !LoggedExecStatic( qry, "SELECT id,styleName,description FROM layer_styles WHERE f_table_catalog=? AND f_table_schema=? AND f_table_name=? AND f_geometry_column" - + QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ), args, dsUri.uri() ) ) + if ( !LoggedExecStatic( qry, "SELECT id,styleName,description FROM layer_styles WHERE f_table_catalog=? AND f_table_schema=? AND f_table_name=? AND f_geometry_column" + QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ), args, dsUri.uri() ) ) { errCause = QObject::tr( "Could not execute select [%1]" ).arg( qry.lastError().text() ); conn->disconnect(); @@ -4092,9 +3929,7 @@ int QgsOracleProviderMetadata::listStyles( const QString &uri, if ( !dsUri.geometryColumn().isEmpty() ) args << dsUri.geometryColumn(); - if ( !LoggedExecStatic( qry, "SELECT id,styleName,description FROM layer_styles WHERE NOT (f_table_catalog=? AND f_table_schema=? AND f_table_name=? AND f_geometry_column" - + QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) - + ") ORDER BY update_time DESC", args, dsUri.uri() ) ) + if ( !LoggedExecStatic( qry, "SELECT id,styleName,description FROM layer_styles WHERE NOT (f_table_catalog=? AND f_table_schema=? AND f_table_name=? AND f_geometry_column" + QString( dsUri.geometryColumn().isEmpty() ? " IS NULL" : "=?" ) + ") ORDER BY update_time DESC", args, dsUri.uri() ) ) { errCause = QObject::tr( "Could not execute select [%1]" ).arg( qry.lastError().text() ); conn->disconnect(); @@ -4152,14 +3987,11 @@ QString QgsOracleProviderMetadata::getStyleById( const QString &uri, const QStri class QgsOracleSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "oracle" ); } QString text() const override { return QObject::tr( "Oracle" ); } int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 40; } QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddOracleLayer.svg" ) ); } - QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, - Qt::WindowFlags fl = Qt::Widget, - QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override + QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override { return new QgsOracleSourceSelect( parent, fl, widgetMode ); } @@ -4196,7 +4028,6 @@ class QgsOracleProjectStorageGuiProvider : public QgsProjectStorageGuiProvider QgsOracleProviderGuiMetadata::QgsOracleProviderGuiMetadata() : QgsProviderGuiMetadata( ORACLE_KEY ) { - } QList QgsOracleProviderGuiMetadata::sourceSelectProviders() @@ -4218,8 +4049,8 @@ void QgsOracleProviderGuiMetadata::registerGui( QMainWindow *mainWindow ) #endif -QgsOracleProviderMetadata::QgsOracleProviderMetadata(): - QgsProviderMetadata( ORACLE_KEY, ORACLE_DESCRIPTION ) +QgsOracleProviderMetadata::QgsOracleProviderMetadata() + : QgsProviderMetadata( ORACLE_KEY, ORACLE_DESCRIPTION ) { } @@ -4240,44 +4071,44 @@ QVariantMap QgsOracleProviderMetadata::decodeUri( const QString &uri ) const const QgsDataSourceUri dsUri { uri }; QVariantMap uriParts; - if ( ! dsUri.database().isEmpty() ) - uriParts[ QStringLiteral( "dbname" ) ] = dsUri.database(); - if ( ! dsUri.host().isEmpty() ) - uriParts[ QStringLiteral( "host" ) ] = dsUri.host(); - if ( ! dsUri.port().isEmpty() ) - uriParts[ QStringLiteral( "port" ) ] = dsUri.port(); - if ( ! dsUri.service().isEmpty() ) - uriParts[ QStringLiteral( "service" ) ] = dsUri.service(); - if ( ! dsUri.param( "dbworkspace" ).isEmpty() ) - uriParts[ QStringLiteral( "dbworkspace" ) ] = dsUri.param( "dbworkspace" ); - if ( ! dsUri.username().isEmpty() ) - uriParts[ QStringLiteral( "username" ) ] = dsUri.username(); - if ( ! dsUri.password().isEmpty() ) - uriParts[ QStringLiteral( "password" ) ] = dsUri.password(); - if ( ! dsUri.authConfigId().isEmpty() ) - uriParts[ QStringLiteral( "authcfg" ) ] = dsUri.authConfigId(); + if ( !dsUri.database().isEmpty() ) + uriParts[QStringLiteral( "dbname" )] = dsUri.database(); + if ( !dsUri.host().isEmpty() ) + uriParts[QStringLiteral( "host" )] = dsUri.host(); + if ( !dsUri.port().isEmpty() ) + uriParts[QStringLiteral( "port" )] = dsUri.port(); + if ( !dsUri.service().isEmpty() ) + uriParts[QStringLiteral( "service" )] = dsUri.service(); + if ( !dsUri.param( "dbworkspace" ).isEmpty() ) + uriParts[QStringLiteral( "dbworkspace" )] = dsUri.param( "dbworkspace" ); + if ( !dsUri.username().isEmpty() ) + uriParts[QStringLiteral( "username" )] = dsUri.username(); + if ( !dsUri.password().isEmpty() ) + uriParts[QStringLiteral( "password" )] = dsUri.password(); + if ( !dsUri.authConfigId().isEmpty() ) + uriParts[QStringLiteral( "authcfg" )] = dsUri.authConfigId(); if ( dsUri.wkbType() != Qgis::WkbType::Unknown ) - uriParts[ QStringLiteral( "type" ) ] = static_cast< quint32>( dsUri.wkbType() ); - if ( ! dsUri.table().isEmpty() ) - uriParts[ QStringLiteral( "table" ) ] = dsUri.table(); - if ( ! dsUri.schema().isEmpty() ) - uriParts[ QStringLiteral( "schema" ) ] = dsUri.schema(); - if ( ! dsUri.keyColumn().isEmpty() ) - uriParts[ QStringLiteral( "key" ) ] = dsUri.keyColumn(); - if ( ! dsUri.srid().isEmpty() ) - uriParts[ QStringLiteral( "srid" ) ] = dsUri.srid(); + uriParts[QStringLiteral( "type" )] = static_cast( dsUri.wkbType() ); + if ( !dsUri.table().isEmpty() ) + uriParts[QStringLiteral( "table" )] = dsUri.table(); + if ( !dsUri.schema().isEmpty() ) + uriParts[QStringLiteral( "schema" )] = dsUri.schema(); + if ( !dsUri.keyColumn().isEmpty() ) + uriParts[QStringLiteral( "key" )] = dsUri.keyColumn(); + if ( !dsUri.srid().isEmpty() ) + uriParts[QStringLiteral( "srid" )] = dsUri.srid(); if ( uri.contains( QStringLiteral( "estimatedmetadata=" ), Qt::CaseSensitivity::CaseInsensitive ) ) - uriParts[ QStringLiteral( "estimatedmetadata" ) ] = dsUri.useEstimatedMetadata(); - if ( ! dsUri.param( "includegeoattributes" ).isEmpty() ) - uriParts[ QStringLiteral( "includegeoattributes" ) ] = dsUri.param( "includegeoattributes" ); - if ( ! dsUri.sql().isEmpty() ) - uriParts[ QStringLiteral( "sql" ) ] = dsUri.sql(); - if ( ! dsUri.param( "checkPrimaryKeyUnicity" ).isEmpty() ) - uriParts[ QStringLiteral( "checkPrimaryKeyUnicity" ) ] = dsUri.param( "checkPrimaryKeyUnicity" ); - if ( ! dsUri.geometryColumn().isEmpty() ) - uriParts[ QStringLiteral( "geometrycolumn" ) ] = dsUri.geometryColumn(); - if ( ! dsUri.param( "dboptions" ).isEmpty() ) - uriParts[ QStringLiteral( "dboptions" ) ] = dsUri.param( "dboptions" ); + uriParts[QStringLiteral( "estimatedmetadata" )] = dsUri.useEstimatedMetadata(); + if ( !dsUri.param( "includegeoattributes" ).isEmpty() ) + uriParts[QStringLiteral( "includegeoattributes" )] = dsUri.param( "includegeoattributes" ); + if ( !dsUri.sql().isEmpty() ) + uriParts[QStringLiteral( "sql" )] = dsUri.sql(); + if ( !dsUri.param( "checkPrimaryKeyUnicity" ).isEmpty() ) + uriParts[QStringLiteral( "checkPrimaryKeyUnicity" )] = dsUri.param( "checkPrimaryKeyUnicity" ); + if ( !dsUri.geometryColumn().isEmpty() ) + uriParts[QStringLiteral( "geometrycolumn" )] = dsUri.geometryColumn(); + if ( !dsUri.param( "dboptions" ).isEmpty() ) + uriParts[QStringLiteral( "dboptions" )] = dsUri.param( "dboptions" ); return uriParts; } @@ -4344,7 +4175,7 @@ void QgsOracleProviderMetadata::deleteConnection( const QString &name ) deleteConnectionProtected( name ); } -void QgsOracleProviderMetadata::saveConnection( const QgsAbstractProviderConnection *conn, const QString &name ) +void QgsOracleProviderMetadata::saveConnection( const QgsAbstractProviderConnection *conn, const QString &name ) { saveConnectionProtected( conn, name ); } diff --git a/src/providers/oracle/qgsoracleprovider.h b/src/providers/oracle/qgsoracleprovider.h index 867c8c6faf2c..18c2c731a1af 100644 --- a/src/providers/oracle/qgsoracleprovider.h +++ b/src/providers/oracle/qgsoracleprovider.h @@ -59,13 +59,12 @@ enum QgsOraclePrimaryKeyType * interface defined in the QgsDataProvider class to provide access to spatial * data residing in a oracle enabled database. */ -class QgsOracleProvider final: public QgsVectorDataProvider +class QgsOracleProvider final : public QgsVectorDataProvider { Q_OBJECT Q_PROPERTY( QString workspace READ getWorkspace WRITE setWorkspace ) public: - //! Import a vector layer into the database static Qgis::VectorExportResult createEmptyLayer( const QString &uri, @@ -95,8 +94,7 @@ class QgsOracleProvider final: public QgsVectorDataProvider * \param options generic data provider options * \param flags generic data provider flags */ - explicit QgsOracleProvider( QString const &uri, const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); + explicit QgsOracleProvider( QString const &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); //! Destructor ~QgsOracleProvider() override; @@ -208,7 +206,6 @@ class QgsOracleProvider final: public QgsVectorDataProvider QList discoverRelations( const QgsVectorLayer *target, const QList &layers ) const override; private: - /** * \returns relation kind */ @@ -314,14 +311,14 @@ class QgsOracleProvider final: public QgsVectorDataProvider */ QList mAlwaysGenerated; - QString mGeometryColumn; //!< Name of the geometry column - mutable QgsRectangle mLayerExtent; //!< Rectangle that contains the extent (bounding box) of the layer - mutable long long mFeaturesCounted; //!< Number of features in the layer - int mSrid; //!< Srid of column - Qgis::VectorProviderCapabilities mEnabledCapabilities; //!< Capabilities of layer + QString mGeometryColumn; //!< Name of the geometry column + mutable QgsRectangle mLayerExtent; //!< Rectangle that contains the extent (bounding box) of the layer + mutable long long mFeaturesCounted; //!< Number of features in the layer + int mSrid; //!< Srid of column + Qgis::VectorProviderCapabilities mEnabledCapabilities; //!< Capabilities of layer - Qgis::WkbType mDetectedGeomType; //!< Geometry type detected in the database - Qgis::WkbType mRequestedGeomType; //!< Geometry type requested in the uri + Qgis::WkbType mDetectedGeomType; //!< Geometry type detected in the database + Qgis::WkbType mRequestedGeomType; //!< Geometry type requested in the uri bool getGeometryDetails(); @@ -333,23 +330,24 @@ class QgsOracleProvider final: public QgsVectorDataProvider QgsOracleTransaction *mTransaction = nullptr; - struct OracleFieldNotFound {}; //! Exception to throw + struct OracleFieldNotFound + {}; //! Exception to throw struct OracleException { OracleException( QString msg, const QSqlQuery &q ) : mWhat( tr( "Oracle error: %1\nSQL: %2\nError: %3" ) - .arg( msg ) - .arg( q.lastError().text() ) - .arg( q.lastQuery() ) - ) + .arg( msg ) + .arg( q.lastError().text() ) + .arg( q.lastQuery() ) + ) {} OracleException( QString msg, const QSqlDatabase &q ) : mWhat( tr( "Oracle error: %1\nError: %2" ) - .arg( msg ) - .arg( q.lastError().text() ) - ) + .arg( msg ) + .arg( q.lastError().text() ) + ) {} OracleException( const OracleException &e ) @@ -367,7 +365,7 @@ class QgsOracleProvider final: public QgsVectorDataProvider private: QString mWhat; - OracleException &operator= ( const OracleException & ) = delete; + OracleException &operator=( const OracleException & ) = delete; }; // A function that determines if the given schema.table.column @@ -379,12 +377,12 @@ class QgsOracleProvider final: public QgsVectorDataProvider static QString quotedIdentifier( QString ident ) { return QgsOracleConn::quotedIdentifier( ident ); } static QString quotedValue( const QVariant &value, QMetaType::Type type = QMetaType::Type::UnknownType ) { return QgsOracleConn::quotedValue( value, type ); } - QMap mKeyToFid; //!< Map key values to feature id - QMap mFidToKey; //!< Map feature back to feature id + QMap mKeyToFid; //!< Map key values to feature id + QMap mFidToKey; //!< Map feature back to feature id - bool mHasSpatialIndex; //!< Geometry column is indexed - QString mSpatialIndexName; //!< Name of spatial index of geometry column - int mOracleVersion; //!< Oracle database version + bool mHasSpatialIndex; //!< Geometry column is indexed + QString mSpatialIndexName; //!< Name of spatial index of geometry column + int mOracleVersion; //!< Oracle database version std::shared_ptr mShared; @@ -402,19 +400,9 @@ class QgsOracleProvider final: public QgsVectorDataProvider class QgsOracleUtils { public: - static QString whereClause( QgsFeatureId featureId, - const QgsFields &fields, - QgsOraclePrimaryKeyType primaryKeyType, - const QList &primaryKeyAttrs, - std::shared_ptr sharedData, - QVariantList ¶ms ); - - static QString whereClause( QgsFeatureIds featureIds, - const QgsFields &fields, - QgsOraclePrimaryKeyType primaryKeyType, - const QList &primaryKeyAttrs, - std::shared_ptr sharedData, - QVariantList ¶ms ); + static QString whereClause( QgsFeatureId featureId, const QgsFields &fields, QgsOraclePrimaryKeyType primaryKeyType, const QList &primaryKeyAttrs, std::shared_ptr sharedData, QVariantList ¶ms ); + + static QString whereClause( QgsFeatureIds featureIds, const QgsFields &fields, QgsOraclePrimaryKeyType primaryKeyType, const QList &primaryKeyAttrs, std::shared_ptr sharedData, QVariantList ¶ms ); static QString andWhereClauses( const QString &c1, const QString &c2 ); }; @@ -439,12 +427,12 @@ class QgsOracleSharedData protected: QMutex mMutex; //!< Access to all data members is guarded by the mutex - QgsFeatureId mFidCounter = 0; // next feature id if map is used - QMap mKeyToFid; // map key values to feature id - QMap mFidToKey; // map feature back to fea + QgsFeatureId mFidCounter = 0; // next feature id if map is used + QMap mKeyToFid; // map key values to feature id + QMap mFidToKey; // map feature back to fea }; -class QgsOracleProviderMetadata final: public QgsProviderMetadata +class QgsOracleProviderMetadata final : public QgsProviderMetadata { Q_OBJECT @@ -456,15 +444,10 @@ class QgsOracleProviderMetadata final: public QgsProviderMetadata QString loadStyle( const QString &uri, QString &errCause ) override; QString loadStoredStyle( const QString &uri, QString &styleName, QString &errCause ) override; bool styleExists( const QString &uri, const QString &styleId, QString &errorCause ) override; - bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, - const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; + bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; void cleanupProvider() override; void initProvider() override; - Qgis::VectorExportResult createEmptyLayer( const QString &uri, - const QgsFields &fields, Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, bool overwrite, - QMap &oldToNewAttrIdxMap, QString &errorMessage, - const QMap *options ) override; + Qgis::VectorExportResult createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) override; QgsOracleProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; QList dataItemProviders() const override; @@ -478,17 +461,15 @@ class QgsOracleProviderMetadata final: public QgsProviderMetadata QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; private: - // helper method to check if LAYER_STYLES table exists bool layerStylesTableExists( QgsOracleConn *conn, const QgsDataSourceUri &dsUri, QString &errCause ); - }; #ifdef HAVE_GUI -class QgsOracleProviderGuiMetadata final: public QgsProviderGuiMetadata +class QgsOracleProviderGuiMetadata final : public QgsProviderGuiMetadata { public: QgsOracleProviderGuiMetadata(); diff --git a/src/providers/oracle/qgsoracleproviderconnection.cpp b/src/providers/oracle/qgsoracleproviderconnection.cpp index e810390e1490..bb25a2530e19 100644 --- a/src/providers/oracle/qgsoracleproviderconnection.cpp +++ b/src/providers/oracle/qgsoracleproviderconnection.cpp @@ -28,8 +28,7 @@ #include // read from QSettings and used in the provider connection -const QStringList CONFIGURATION_PARAMETERS -{ +const QStringList CONFIGURATION_PARAMETERS { QStringLiteral( "userTablesOnly" ), QStringLiteral( "geometryColumnsOnly" ), QStringLiteral( "allowGeometrylessTables" ), @@ -43,8 +42,7 @@ const QStringList CONFIGURATION_PARAMETERS }; // read from uri and used in the provider connection -const QStringList EXTRA_CONNECTION_PARAMETERS -{ +const QStringList EXTRA_CONNECTION_PARAMETERS { QStringLiteral( "dboptions" ), QStringLiteral( "dbworkspace" ) }; @@ -62,7 +60,6 @@ class QgsOracleQuery : public QSqlQuery private: std::shared_ptr mPconn; - }; QgsOracleProviderConnection::QgsOracleProviderConnection( const QString &name ) @@ -86,8 +83,8 @@ QgsOracleProviderConnection::QgsOracleProviderConnection( const QString &name ) setConfiguration( configuration ); } -QgsOracleProviderConnection::QgsOracleProviderConnection( const QString &uri, const QVariantMap &configuration ): - QgsAbstractDatabaseProviderConnection( QgsDataSourceUri( uri ).connectionInfo( false ), configuration ) +QgsOracleProviderConnection::QgsOracleProviderConnection( const QString &uri, const QVariantMap &configuration ) + : QgsAbstractDatabaseProviderConnection( QgsDataSourceUri( uri ).connectionInfo( false ), configuration ) { mProviderKey = QStringLiteral( "oracle" ); setDefaultCapabilities(); @@ -98,8 +95,7 @@ QgsOracleProviderConnection::QgsOracleProviderConnection( const QString &uri, co if ( inputUri.hasParam( QStringLiteral( "estimatedMetadata" ) ) ) { - currentUri.setUseEstimatedMetadata( inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == QStringLiteral( "true" ) - || inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == '1' ); + currentUri.setUseEstimatedMetadata( inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == QStringLiteral( "true" ) || inputUri.param( QStringLiteral( "estimatedMetadata" ) ) == '1' ); } for ( const auto ¶m : EXTRA_CONNECTION_PARAMETERS ) @@ -117,8 +113,7 @@ void QgsOracleProviderConnection::setDefaultCapabilities() { // TODO: we might check at this point if the user actually has the privileges and return // properly filtered capabilities instead of all of them - mCapabilities = - { + mCapabilities = { Capability::DropVectorTable, Capability::DropRasterTable, Capability::CreateVectorTable, @@ -137,14 +132,12 @@ void QgsOracleProviderConnection::setDefaultCapabilities() Capability::DeleteFieldCascade, Capability::AddField, }; - mGeometryColumnCapabilities = - { + mGeometryColumnCapabilities = { GeometryColumnCapability::Z, GeometryColumnCapability::SinglePart, GeometryColumnCapability::Curves }; - mSqlLayerDefinitionCapabilities = - { + mSqlLayerDefinitionCapabilities = { Qgis::SqlLayerDefinitionCapability::SubsetStringFilter, Qgis::SqlLayerDefinitionCapability::GeometryColumn, Qgis::SqlLayerDefinitionCapability::PrimaryKeys, @@ -166,19 +159,18 @@ QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions QgsOracleProviderCo QgsVectorLayer *QgsOracleProviderConnection::createSqlVectorLayer( const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options ) const { - // Precondition if ( options.sql.isEmpty() ) { throw QgsProviderConnectionException( QObject::tr( "Could not create a SQL vector layer: SQL expression is empty." ) ); } - QgsDataSourceUri tUri( uri( ) ); + QgsDataSourceUri tUri( uri() ); tUri.setSql( options.filter ); tUri.disableSelectAtId( options.disableSelectAtId ); - if ( ! options.primaryKeyColumns.isEmpty() ) + if ( !options.primaryKeyColumns.isEmpty() ) { tUri.setKeyColumn( options.primaryKeyColumns.join( ',' ) ); tUri.setTable( QStringLiteral( "(%1)" ).arg( options.sql ) ); @@ -190,19 +182,19 @@ QgsVectorLayer *QgsOracleProviderConnection::createSqlVectorLayer( const QgsAbst int pkId { 0 }; while ( options.sql.contains( QStringLiteral( "qgis_generated_uid_%1_" ).arg( pkId ), Qt::CaseSensitivity::CaseInsensitive ) ) { - pkId ++; + pkId++; } tUri.setKeyColumn( QStringLiteral( "qgis_generated_uid_%1_" ).arg( pkId ) ); int sqlId { 0 }; while ( options.sql.contains( QStringLiteral( "qgis_generated_subq_%1_" ).arg( sqlId ), Qt::CaseSensitivity::CaseInsensitive ) ) { - sqlId ++; + sqlId++; } tUri.setTable( QStringLiteral( "(SELECT row_number() over (ORDER BY NULL) AS qgis_generated_uid_%1_, qgis_generated_subq_%3_.* FROM (%2\n) qgis_generated_subq_%3_\n)" ).arg( QString::number( pkId ), options.sql, QString::number( sqlId ) ) ); } - if ( ! options.geometryColumn.isEmpty() ) + if ( !options.geometryColumn.isEmpty() ) { tUri.setGeometryColumn( options.geometryColumn ); } @@ -210,7 +202,7 @@ QgsVectorLayer *QgsOracleProviderConnection::createSqlVectorLayer( const QgsAbst std::unique_ptr vl = std::make_unique( tUri.uri( false ), options.layerName.isEmpty() ? QStringLiteral( "QueryLayer" ) : options.layerName, providerKey() ); // Try to guess the geometry and srid - if ( ! vl->isValid() ) + if ( !vl->isValid() ) { const QString limit { QgsDataSourceUri( uri() ).useEstimatedMetadata() ? QStringLiteral( "AND ROWNUM < 100" ) : QString() }; const QString sql { QStringLiteral( R"( @@ -219,18 +211,18 @@ QgsVectorLayer *QgsOracleProviderConnection::createSqlVectorLayer( const QgsAbst FROM (%2) a WHERE a.%1 IS NOT NULL %3 ORDER BY a.%1.SDO_GTYPE - )" ).arg( options.geometryColumn, options.sql, limit ) }; + )" ) + .arg( options.geometryColumn, options.sql, limit ) }; const QList> candidates { executeSql( sql ) }; for ( const QList &row : std::as_const( candidates ) ) { bool ok; - const int type { row[ 0 ].toInt( &ok ) }; + const int type { row[0].toInt( &ok ) }; if ( ok ) { - const int srid { row[ 1 ].toInt( &ok ) }; + const int srid { row[1].toInt( &ok ) }; if ( ok ) { - Qgis::WkbType geomType { Qgis::WkbType::Unknown }; switch ( type ) @@ -343,7 +335,7 @@ void QgsOracleProviderConnection::remove( const QString &name ) const QList QgsOracleProviderConnection::nativeTypes() const { QList types; - QgsPoolOracleConn conn( QgsDataSourceUri{ uri() }.connectionInfo( false ) ); + QgsPoolOracleConn conn( QgsDataSourceUri { uri() }.connectionInfo( false ) ); if ( conn.get() ) { types = conn.get()->nativeTypes(); @@ -357,12 +349,9 @@ QList QgsOracleProviderConnection::nativeType QMultiMap QgsOracleProviderConnection::sqlDictionary() { - return - { - { - Qgis::SqlKeywordCategory::Keyword, - { - // From: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_keywd.htm + return { + { Qgis::SqlKeywordCategory::Keyword, + { // From: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_keywd.htm QStringLiteral( "ACCESS" ), QStringLiteral( "ADD" ), QStringLiteral( "ALL" ), @@ -907,10 +896,8 @@ QMultiMap QgsOracleProviderConnection::sq QStringLiteral( "SUBTYPE" ) } }, - { - Qgis::SqlKeywordCategory::Function, - { - // From: https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm + { Qgis::SqlKeywordCategory::Function, + { // From: https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm QStringLiteral( "CAST" ), QStringLiteral( "COALESCE" ), QStringLiteral( "DECODE" ), @@ -927,10 +914,8 @@ QMultiMap QgsOracleProviderConnection::sq QStringLiteral( "USERENV" ) } }, - { - Qgis::SqlKeywordCategory::Math, - { - QStringLiteral( "ABS" ), + { Qgis::SqlKeywordCategory::Math, + { QStringLiteral( "ABS" ), QStringLiteral( "ACOS" ), QStringLiteral( "ASIN" ), QStringLiteral( "ATAN" ), @@ -961,10 +946,8 @@ QMultiMap QgsOracleProviderConnection::sq QStringLiteral( "WIDTH_BUCKET" ) } }, - { - Qgis::SqlKeywordCategory::String, - { - QStringLiteral( "CHR" ), + { Qgis::SqlKeywordCategory::String, + { QStringLiteral( "CHR" ), QStringLiteral( "CONCAT" ), QStringLiteral( "INITCAP" ), QStringLiteral( "LOWER" ), @@ -994,10 +977,8 @@ QMultiMap QgsOracleProviderConnection::sq QStringLiteral( "REGEXP_INSTR" ) } }, - { - Qgis::SqlKeywordCategory::Aggregate, - { - QStringLiteral( "AVG" ), + { Qgis::SqlKeywordCategory::Aggregate, + { QStringLiteral( "AVG" ), QStringLiteral( "COLLECT" ), QStringLiteral( "CORR" ), QStringLiteral( "COUNT" ), @@ -1044,10 +1025,8 @@ QMultiMap QgsOracleProviderConnection::sq QStringLiteral( "XMLAGG" ) } }, - { - Qgis::SqlKeywordCategory::Geospatial, - { - // From http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/toc.htm + { Qgis::SqlKeywordCategory::Geospatial, + { // From http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/toc.htm // Spatial operators QStringLiteral( "SDO_ANYINTERACT" ), QStringLiteral( "SDO_CONTAINS" ), @@ -1318,10 +1297,8 @@ QMultiMap QgsOracleProviderConnection::sq QStringLiteral( "SDO_UTIL.VALIDATE_WKTGEOMETRY" ) } }, - { - Qgis::SqlKeywordCategory::Operator, - { - QStringLiteral( "AND" ), + { Qgis::SqlKeywordCategory::Operator, + { QStringLiteral( "AND" ), QStringLiteral( "OR" ), QStringLiteral( "||" ), QStringLiteral( "<" ), @@ -1357,10 +1334,8 @@ QMultiMap QgsOracleProviderConnection::sq QStringLiteral( "CASE {column} WHEN {value} THEN {value}" ) } }, - { - Qgis::SqlKeywordCategory::Constant, - { - QStringLiteral( "NULL" ), + { Qgis::SqlKeywordCategory::Constant, + { QStringLiteral( "NULL" ), QStringLiteral( "FALSE" ), QStringLiteral( "TRUE" ) } @@ -1374,7 +1349,7 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsOracleProviderConnection:: if ( feedback && feedback->isCanceled() ) return QgsAbstractDatabaseProviderConnection::QueryResult(); - std::shared_ptr pconn = std::make_shared( QgsDataSourceUri{ uri() }.connectionInfo( false ) ); + std::shared_ptr pconn = std::make_shared( QgsDataSourceUri { uri() }.connectionInfo( false ) ); if ( !pconn->get() ) { throw QgsProviderConnectionException( QObject::tr( "Connection failed: %1" ).arg( uri() ) ); @@ -1392,8 +1367,7 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsOracleProviderConnection:: { logWrapper.setError( qry->lastError().text() ); throw QgsProviderConnectionException( QObject::tr( "SQL error: %1 returned %2" ) - .arg( qry->lastQuery(), - qry->lastError().text() ) ); + .arg( qry->lastQuery(), qry->lastError().text() ) ); } if ( feedback && feedback->isCanceled() ) @@ -1436,7 +1410,7 @@ QVariantList QgsOracleProviderResultIterator::nextRowPrivate() bool QgsOracleProviderResultIterator::hasNextRowPrivate() const { - return ! mNextRow.isEmpty(); + return !mNextRow.isEmpty(); } QVariantList QgsOracleProviderResultIterator::nextRowInternal() @@ -1461,14 +1435,7 @@ long long QgsOracleProviderResultIterator::rowCountPrivate() const return mQuery->size(); } -void QgsOracleProviderConnection::createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - const QMap *options ) const +void QgsOracleProviderConnection::createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const { checkCapability( Capability::CreateVectorTable ); @@ -1476,22 +1443,22 @@ void QgsOracleProviderConnection::createVectorTable( const QString &schema, newUri.setSchema( schema ); newUri.setTable( name ); // Set geometry column and if it's not aspatial - if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) + if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) { newUri.setGeometryColumn( options->value( QStringLiteral( "geometryColumn" ), QStringLiteral( "GEOM" ) ).toString() ); } QMap map; QString errCause; const Qgis::VectorExportResult res = QgsOracleProvider::createEmptyLayer( - newUri.uri(), - fields, - wkbType, - srs, - overwrite, - map, - errCause, - options - ); + newUri.uri(), + fields, + wkbType, + srs, + overwrite, + map, + errCause, + options + ); if ( res != Qgis::VectorExportResult::Success ) throw QgsProviderConnectionException( QObject::tr( "An error occurred while creating the vector layer: %1" ).arg( errCause ) ); } @@ -1519,13 +1486,13 @@ QList QgsOracleProviderCon throw QgsProviderConnectionException( QObject::tr( "Connection failed: %1" ).arg( uri() ) ); const bool geometryColumnsOnly { configuration().value( "geometryColumnsOnly", false ).toBool() }; - const bool userTablesOnly { configuration().value( "userTablesOnly", false ).toBool() &&schema.isEmpty() }; + const bool userTablesOnly { configuration().value( "userTablesOnly", false ).toBool() && schema.isEmpty() }; const bool onlyExistingTypes { configuration().value( "onlyExistingTypes", false ).toBool() }; - const bool aspatial { ! flags || flags.testFlag( TableFlag::Aspatial ) }; + const bool aspatial { !flags || flags.testFlag( TableFlag::Aspatial ) }; QVector properties; const bool ok = conn->supportedLayers( properties, schema, geometryColumnsOnly, userTablesOnly, aspatial ); - if ( ! ok ) + if ( !ok ) { throw QgsProviderConnectionException( QObject::tr( "Could not retrieve tables: %1" ).arg( uri() ) ); } @@ -1559,7 +1526,7 @@ QList QgsOracleProviderCon QgsAbstractDatabaseProviderConnection::TableProperty property; property.setFlags( prFlags ); - for ( int i = 0; i < std::min( pr.types.size(), pr.srids.size() ) ; i++ ) + for ( int i = 0; i < std::min( pr.types.size(), pr.srids.size() ); i++ ) { property.addGeometryColumnType( pr.types.at( i ), QgsCoordinateReferenceSystem::fromEpsgId( pr.srids.at( i ) ) ); } @@ -1579,11 +1546,11 @@ void QgsOracleProviderConnection::dropVectorTable( const QString &schema, const { checkCapability( Capability::DropVectorTable ); executeSqlPrivate( QStringLiteral( "DROP TABLE %1.%2" ) - .arg( QgsOracleConn::quotedIdentifier( schema ) ) - .arg( QgsOracleConn::quotedIdentifier( name ) ) ); + .arg( QgsOracleConn::quotedIdentifier( schema ) ) + .arg( QgsOracleConn::quotedIdentifier( name ) ) ); executeSqlPrivate( QStringLiteral( "DELETE FROM user_sdo_geom_metadata WHERE TABLE_NAME = '%1'" ) - .arg( name ) ); + .arg( name ) ); } QgsAbstractDatabaseProviderConnection::QueryResult QgsOracleProviderConnection::execSql( const QString &sql, QgsFeedback *feedback ) const @@ -1596,12 +1563,10 @@ void QgsOracleProviderConnection::renameVectorTable( const QString &schema, cons { checkCapability( Capability::RenameVectorTable ); executeSqlPrivate( QStringLiteral( "ALTER TABLE %1.%2 RENAME TO %3" ) - .arg( QgsOracleConn::quotedIdentifier( schema ), - QgsOracleConn::quotedIdentifier( name ), - QgsOracleConn::quotedIdentifier( newName ) ) ); + .arg( QgsOracleConn::quotedIdentifier( schema ), QgsOracleConn::quotedIdentifier( name ), QgsOracleConn::quotedIdentifier( newName ) ) ); executeSqlPrivate( QStringLiteral( "UPDATE user_sdo_geom_metadata SET TABLE_NAME = '%1' where TABLE_NAME = '%2'" ) - .arg( newName, name ) ); + .arg( newName, name ) ); } void QgsOracleProviderConnection::createSpatialIndex( const QString &schema, const QString &name, const QgsOracleProviderConnection::SpatialIndexOptions &options ) const @@ -1656,7 +1621,7 @@ QIcon QgsOracleProviderConnection::icon() const return QgsApplication::getThemeIcon( QStringLiteral( "mIconOracle.svg" ) ); } -QStringList QgsOracleProviderConnection::schemas( ) const +QStringList QgsOracleProviderConnection::schemas() const { checkCapability( Capability::Schemas ); QStringList schemas; diff --git a/src/providers/oracle/qgsoracleproviderconnection.h b/src/providers/oracle/qgsoracleproviderconnection.h index ba38c15f1c04..30e0fe977fd8 100644 --- a/src/providers/oracle/qgsoracleproviderconnection.h +++ b/src/providers/oracle/qgsoracleproviderconnection.h @@ -21,7 +21,7 @@ class QgsOracleQuery; -struct QgsOracleProviderResultIterator: public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator +struct QgsOracleProviderResultIterator : public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator { QgsOracleProviderResultIterator( int columnCount, std::unique_ptr query ); @@ -29,7 +29,6 @@ struct QgsOracleProviderResultIterator: public QgsAbstractDatabaseProviderConnec bool hasNextRowPrivate() const override; private: - int mColumnCount = 0; std::unique_ptr mQuery; QVariantList mNextRow; @@ -42,18 +41,12 @@ class QgsOracleProviderConnection : public QgsAbstractDatabaseProviderConnection { public: - explicit QgsOracleProviderConnection( const QString &name ); QgsOracleProviderConnection( const QString &uri, const QVariantMap &configuration ); // QgsAbstractProviderConnection interface - void createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, bool overwrite, - const QMap *options ) const override; + void createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const override; QString tableUri( const QString &schema, const QString &name ) const override; void dropVectorTable( const QString &schema, const QString &name ) const override; @@ -64,8 +57,7 @@ class QgsOracleProviderConnection : public QgsAbstractDatabaseProviderConnection bool spatialIndexExists( const QString &schema, const QString &name, const QString &geometryColumn ) const override; void deleteSpatialIndex( const QString &schema, const QString &name, const QString &geometryColumn ) const override; QStringList schemas() const override; - QList tables( const QString &schema, - const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; + QList tables( const QString &schema, const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; void store( const QString &name ) const override; void remove( const QString &name ) const override; QIcon icon() const override; @@ -74,7 +66,6 @@ class QgsOracleProviderConnection : public QgsAbstractDatabaseProviderConnection QgsVectorLayer *createSqlVectorLayer( const SqlVectorLayerOptions &options ) const override; private: - QgsAbstractDatabaseProviderConnection::QueryResult executeSqlPrivate( const QString &sql, QgsFeedback *feedback = nullptr ) const; void setDefaultCapabilities(); diff --git a/src/providers/oracle/qgsoraclesourceselect.cpp b/src/providers/oracle/qgsoraclesourceselect.cpp index a1dab69123aa..81bfd2d62b8e 100644 --- a/src/providers/oracle/qgsoraclesourceselect.cpp +++ b/src/providers/oracle/qgsoraclesourceselect.cpp @@ -69,7 +69,7 @@ QWidget *QgsOracleSourceSelectDelegate::createEditor( QWidget *parent, const QSt Qgis::WkbType::NoGeometry } ) { - cb->addItem( QgsIconUtils::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), static_cast< quint32>( type ) ); + cb->addItem( QgsIconUtils::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), static_cast( type ) ); } return cb; } @@ -113,7 +113,7 @@ void QgsOracleSourceSelectDelegate::setEditorData( QWidget *editor, const QModel { QString value( index.data( Qt::DisplayRole ).toString() ); - QComboBox *cb = qobject_cast( editor ); + QComboBox *cb = qobject_cast( editor ); if ( cb ) { if ( index.column() == QgsOracleTableModel::DbtmType ) @@ -127,7 +127,7 @@ void QgsOracleSourceSelectDelegate::setEditorData( QWidget *editor, const QModel if ( le ) { bool ok; - ( void )value.toInt( &ok ); + ( void ) value.toInt( &ok ); if ( index.column() == QgsOracleTableModel::DbtmSrid && !ok ) value.clear(); @@ -142,11 +142,11 @@ void QgsOracleSourceSelectDelegate::setModelData( QWidget *editor, QAbstractItem { if ( index.column() == QgsOracleTableModel::DbtmType ) { - Qgis::WkbType type = static_cast< Qgis::WkbType >( cb->currentData().toInt() ); + Qgis::WkbType type = static_cast( cb->currentData().toInt() ); model->setData( index, QgsIconUtils::iconForWkbType( type ), Qt::DecorationRole ); model->setData( index, type != Qgis::WkbType::Unknown ? QgsWkbTypes::translatedDisplayString( type ) : tr( "Select…" ) ); - model->setData( index, static_cast< quint32>( type ), Qt::UserRole + 2 ); + model->setData( index, static_cast( type ), Qt::UserRole + 2 ); } else if ( index.column() == QgsOracleTableModel::DbtmPkCol ) { @@ -232,7 +232,7 @@ void QgsOracleSourceSelect::btnNew_clicked() void QgsOracleSourceSelect::btnDelete_clicked() { QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ) - .arg( cmbConnections->currentText() ); + .arg( cmbConnections->currentText() ); if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) ) return; @@ -253,8 +253,7 @@ void QgsOracleSourceSelect::btnSave_clicked() void QgsOracleSourceSelect::btnLoad_clicked() { - QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QStringLiteral( "." ), - tr( "XML files (*.xml *.XML)" ) ); + QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QStringLiteral( "." ), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -397,19 +396,12 @@ void QgsOracleSourceSelect::btnConnect_clicked() mIsConnected = true; mTablesTreeDelegate->setConnectionInfo( uri ); - mColumnTypeTask = new QgsOracleColumnTypeTask( cmbConnections->currentText(), - QgsOracleConn::restrictToSchema( cmbConnections->currentText() ), - uri.useEstimatedMetadata(), - cbxAllowGeometrylessTables->isChecked() ); - - connect( mColumnTypeTask, &QgsOracleColumnTypeTask::setLayerType, - this, &QgsOracleSourceSelect::setLayerType ); - connect( mColumnTypeTask, &QgsTask::taskCompleted, - this, &QgsOracleSourceSelect::columnTaskFinished ); - connect( mColumnTypeTask, &QgsTask::taskTerminated, - this, &QgsOracleSourceSelect::columnTaskFinished ); - connect( mColumnTypeTask, &QgsOracleColumnTypeTask::progressMessage, - this, &QgsAbstractDataSourceWidget::progressMessage ); + mColumnTypeTask = new QgsOracleColumnTypeTask( cmbConnections->currentText(), QgsOracleConn::restrictToSchema( cmbConnections->currentText() ), uri.useEstimatedMetadata(), cbxAllowGeometrylessTables->isChecked() ); + + connect( mColumnTypeTask, &QgsOracleColumnTypeTask::setLayerType, this, &QgsOracleSourceSelect::setLayerType ); + connect( mColumnTypeTask, &QgsTask::taskCompleted, this, &QgsOracleSourceSelect::columnTaskFinished ); + connect( mColumnTypeTask, &QgsTask::taskTerminated, this, &QgsOracleSourceSelect::columnTaskFinished ); + connect( mColumnTypeTask, &QgsOracleColumnTypeTask::progressMessage, this, &QgsAbstractDataSourceWidget::progressMessage ); btnConnect->setText( tr( "Stop" ) ); diff --git a/src/providers/oracle/qgsoraclesourceselect.h b/src/providers/oracle/qgsoraclesourceselect.h index 965017eb91bb..cadfa20f264d 100644 --- a/src/providers/oracle/qgsoraclesourceselect.h +++ b/src/providers/oracle/qgsoraclesourceselect.h @@ -55,7 +55,12 @@ class QgsOracleSourceSelectDelegate : public QItemDelegate void setConnectionInfo( const QgsDataSourceUri &connInfo ) { mConnInfo = connInfo; } protected: - void setConn( QgsOracleConn *conn ) const { if ( mConn ) QgsOracleConnPool::instance()->releaseConnection( mConn ); mConn = conn; } + void setConn( QgsOracleConn *conn ) const + { + if ( mConn ) + QgsOracleConnPool::instance()->releaseConnection( mConn ); + mConn = conn; + } QgsOracleConn *conn() const { @@ -148,7 +153,7 @@ class QgsOracleSourceSelect : public QgsAbstractDbSourceSelect QgsDataSourceUri mConnInfo; QStringList mSelectedTables; // Storage for the range of layer type icons - QMap > mLayerIcons; + QMap> mLayerIcons; //! Model that acts as datasource for mTableTreeWidget QgsOracleTableModel *mTableModel = nullptr; @@ -160,7 +165,6 @@ class QgsOracleSourceSelect : public QgsAbstractDbSourceSelect bool mIsConnected = false; void showHelp(); - }; #endif // QGSORACLESOURCESELECT_H diff --git a/src/providers/oracle/qgsoracletablecache.cpp b/src/providers/oracle/qgsoracletablecache.cpp index 7f2915934673..ee0186e3a37f 100644 --- a/src/providers/oracle/qgsoracletablecache.cpp +++ b/src/providers/oracle/qgsoracletablecache.cpp @@ -24,7 +24,6 @@ email : wonder.sk at gmail dot com #include - static bool _executeSqliteStatement( sqlite3 *db, const QString &sql ) { sqlite3_stmt *stmt = nullptr; @@ -96,7 +95,6 @@ static bool _renameConnectionInCache( sqlite3 *db, const QString &oldName, const } - QString QgsOracleTableCache::cacheDatabaseFilename() { return QgsApplication::qgisSettingsDirPath() + QDir::separator() + "data_sources_cache.db"; diff --git a/src/providers/oracle/qgsoracletablecache.h b/src/providers/oracle/qgsoracletablecache.h index 77ac7c7df56d..ac8e07ac3d9e 100644 --- a/src/providers/oracle/qgsoracletablecache.h +++ b/src/providers/oracle/qgsoracletablecache.h @@ -38,14 +38,13 @@ email : wonder.sk at gmail dot com class QgsOracleTableCache { public: - enum CacheFlag { OnlyLookIntoMetadataTable = 0x01, - OnlyLookForUserTables = 0x02, + OnlyLookForUserTables = 0x02, UseEstimatedTableMetadata = 0x04, OnlyExistingGeometryTypes = 0x08, - AllowGeometrylessTables = 0x10 + AllowGeometrylessTables = 0x10 }; Q_DECLARE_FLAGS( CacheFlags, CacheFlag ) diff --git a/src/providers/oracle/qgsoracletablemodel.cpp b/src/providers/oracle/qgsoracletablemodel.cpp index 464b7dfe3416..11b6acbf055c 100644 --- a/src/providers/oracle/qgsoracletablemodel.cpp +++ b/src/providers/oracle/qgsoracletablemodel.cpp @@ -79,8 +79,8 @@ void QgsOracleTableModel::addTableEntry( const QgsOracleLayerProperty &layerProp for ( int i = 0; i < layerProperty.size(); i++ ) { - Qgis::WkbType wkbType = layerProperty.types[ i ]; - int srid = layerProperty.srids[ i ]; + Qgis::WkbType wkbType = layerProperty.types[i]; + int srid = layerProperty.srids[i]; QString tip; @@ -101,15 +101,16 @@ void QgsOracleTableModel::addTableEntry( const QgsOracleLayerProperty &layerProp QStandardItem *ownerNameItem = new QStandardItem( layerProperty.ownerName ); QStandardItem *typeItem = new QStandardItem( QgsIconUtils::iconForWkbType( wkbType ), - wkbType == Qgis::WkbType::Unknown ? tr( "Select…" ) : QgsWkbTypes::translatedDisplayString( wkbType ) ); + wkbType == Qgis::WkbType::Unknown ? tr( "Select…" ) : QgsWkbTypes::translatedDisplayString( wkbType ) + ); typeItem->setData( wkbType == Qgis::WkbType::Unknown, Qt::UserRole + 1 ); - typeItem->setData( static_cast< quint32>( wkbType ), Qt::UserRole + 2 ); + typeItem->setData( static_cast( wkbType ), Qt::UserRole + 2 ); if ( wkbType == Qgis::WkbType::Unknown ) typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable ); QStandardItem *tableItem = new QStandardItem( layerProperty.tableName ); - QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName ); - QStandardItem *sridItem = new QStandardItem( wkbType != Qgis::WkbType::NoGeometry ? QString::number( srid ) : "" ); + QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName ); + QStandardItem *sridItem = new QStandardItem( wkbType != Qgis::WkbType::NoGeometry ? QString::number( srid ) : "" ); sridItem->setEditable( wkbType != Qgis::WkbType::NoGeometry && srid == 0 ); if ( sridItem->isEditable() ) { @@ -259,7 +260,7 @@ bool QgsOracleTableModel::setData( const QModelIndex &idx, const QVariant &value if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol ) { - Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() ); + Qgis::WkbType wkbType = static_cast( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() ); QString tip; if ( wkbType == Qgis::WkbType::Unknown ) @@ -312,7 +313,7 @@ QString QgsOracleTableModel::layerURI( const QModelIndex &index, const QgsDataSo return QString(); } - Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( itemFromIndex( index.sibling( index.row(), DbtmType ) )->data( Qt::UserRole + 2 ).toInt() ); + Qgis::WkbType wkbType = static_cast( itemFromIndex( index.sibling( index.row(), DbtmType ) )->data( Qt::UserRole + 2 ).toInt() ); if ( wkbType == Qgis::WkbType::Unknown ) { QgsDebugError( QStringLiteral( "unknown geometry type" ) ); @@ -323,7 +324,7 @@ QString QgsOracleTableModel::layerURI( const QModelIndex &index, const QgsDataSo QStandardItem *pkItem = itemFromIndex( index.sibling( index.row(), DbtmPkCol ) ); QString pkColumnName = pkItem->data( Qt::DisplayRole ).toString(); bool isView = pkItem->data( Qt::UserRole + 1 ).toBool(); - bool isSet = pkItem->data( Qt::UserRole + 2 ).toBool(); + bool isSet = pkItem->data( Qt::UserRole + 2 ).toBool(); if ( isView && !isSet ) { @@ -343,7 +344,7 @@ QString QgsOracleTableModel::layerURI( const QModelIndex &index, const QgsDataSo srid = index.sibling( index.row(), DbtmSrid ).data( Qt::DisplayRole ).toString(); bool ok; - ( void )srid.toInt( &ok ); + ( void ) srid.toInt( &ok ); if ( !ok ) { QgsDebugError( QStringLiteral( "srid not numeric" ) ); diff --git a/src/providers/oracle/qgsoracletablemodel.h b/src/providers/oracle/qgsoracletablemodel.h index b27f04a798df..98e35b27c9d0 100644 --- a/src/providers/oracle/qgsoracletablemodel.h +++ b/src/providers/oracle/qgsoracletablemodel.h @@ -69,7 +69,6 @@ class QgsOracleTableModel : public QgsAbstractDbTableModel //! Number of tables in the model int mTableCount = 0; QStringList mColumns; - }; #endif // QGSORACLETABLEMODEL_H diff --git a/src/providers/oracle/qgsoracletransaction.cpp b/src/providers/oracle/qgsoracletransaction.cpp index 60d7e03165d5..64fd3496897b 100644 --- a/src/providers/oracle/qgsoracletransaction.cpp +++ b/src/providers/oracle/qgsoracletransaction.cpp @@ -29,7 +29,6 @@ QgsOracleTransaction::QgsOracleTransaction( const QString &connString ) : QgsTransaction( connString ) { - } QgsOracleTransaction::~QgsOracleTransaction() @@ -84,7 +83,7 @@ bool QgsOracleTransaction::executeSql( const QString &sql, QString &errorMsg, bo QgsDatabaseQueryLogWrapper logWrapper { sql, mConnString, QStringLiteral( "oracle" ), QStringLiteral( "QgsOracleConn" ), QGS_QUERY_LOG_ORIGIN }; const bool res = mConn->exec( sql, true, &errorMsg ); - if ( ! errorMsg.isEmpty() ) + if ( !errorMsg.isEmpty() ) { logWrapper.setError( errorMsg ); } diff --git a/src/providers/oracle/qgsoracletransaction.h b/src/providers/oracle/qgsoracletransaction.h index 8c7d7a20801b..69b8dda1095c 100644 --- a/src/providers/oracle/qgsoracletransaction.h +++ b/src/providers/oracle/qgsoracletransaction.h @@ -45,7 +45,6 @@ class QgsOracleTransaction : public QgsTransaction bool beginTransaction( QString &error, int statementTimeout ) override; bool commitTransaction( QString &error ) override; bool rollbackTransaction( QString &error ) override; - }; ///@endcond diff --git a/src/providers/pdal/qgspdalindexingtask.cpp b/src/providers/pdal/qgspdalindexingtask.cpp index 70848dcd1046..d1d5e9b5ad9b 100644 --- a/src/providers/pdal/qgspdalindexingtask.cpp +++ b/src/providers/pdal/qgspdalindexingtask.cpp @@ -86,7 +86,7 @@ bool QgsPdalIndexingTask::runUntwine() // By default Untwine will generate an ept dataset, we use single_file flag to generate COPC files options.push_back( { "single_file", std::string() } ); - const std::vector files = {mFile.toStdString()}; + const std::vector files = { mFile.toStdString() }; untwineProcess.start( files, mOutputPath.toStdString(), options ); const int lastPercent = 0; while ( true ) @@ -143,7 +143,7 @@ QString QgsPdalIndexingTask::guessUntwineExecutableBinary() const QString untwineExecutable = QProcessEnvironment::systemEnvironment().value( QStringLiteral( "QGIS_UNTWINE_EXECUTABLE" ) ); if ( untwineExecutable.isEmpty() ) { -#if defined(Q_OS_WIN) +#if defined( Q_OS_WIN ) untwineExecutable = QgsApplication::libexecPath() + "untwine.exe"; #else untwineExecutable = QgsApplication::libexecPath() + "untwine"; @@ -173,4 +173,3 @@ bool QgsPdalIndexingTask::prepareOutputPath() } return true; } - diff --git a/src/providers/pdal/qgspdalindexingtask.h b/src/providers/pdal/qgspdalindexingtask.h index e300899d6de4..71b8cb76102b 100644 --- a/src/providers/pdal/qgspdalindexingtask.h +++ b/src/providers/pdal/qgspdalindexingtask.h @@ -19,7 +19,7 @@ #include #include "qgstaskmanager.h" -class QgsPdalIndexingTask: public QgsTask +class QgsPdalIndexingTask : public QgsTask { Q_OBJECT diff --git a/src/providers/pdal/qgspdalprovider.cpp b/src/providers/pdal/qgspdalprovider.cpp index bf62938b2718..bbaa34744577 100644 --- a/src/providers/pdal/qgspdalprovider.cpp +++ b/src/providers/pdal/qgspdalprovider.cpp @@ -47,16 +47,17 @@ QQueue QgsPdalProvider::sIndexingQueue; QgsPdalProvider::QgsPdalProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) + Qgis::DataProviderReadFlags flags +) : QgsPointCloudDataProvider( uri, options, flags ) , mIndex( nullptr ) { - std::unique_ptr< QgsScopedRuntimeProfile > profile; + std::unique_ptr profile; if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) ) - profile = std::make_unique< QgsScopedRuntimeProfile >( tr( "Open data source" ), QStringLiteral( "projectload" ) ); + profile = std::make_unique( tr( "Open data source" ), QStringLiteral( "projectload" ) ); mIsValid = load( uri ); - loadIndex( ); + loadIndex(); } Qgis::DataProviderFlags QgsPdalProvider::flags() const @@ -151,7 +152,7 @@ QgsPointCloudDataProvider::PointCloudIndexGenerationState QgsPdalProvider::index return PointCloudIndexGenerationState::NotIndexed; } -void QgsPdalProvider::loadIndex( ) +void QgsPdalProvider::loadIndex() { QGIS_PROTECT_QOBJECT_THREAD_ACCESS @@ -225,7 +226,7 @@ bool QgsPdalProvider::anyIndexingTaskExists() { QGIS_PROTECT_QOBJECT_THREAD_ACCESS - const QList< QgsTask * > tasks = QgsApplication::taskManager()->activeTasks(); + const QList tasks = QgsApplication::taskManager()->activeTasks(); for ( const QgsTask *task : tasks ) { const QgsPdalIndexingTask *indexingTask = qobject_cast( task ); @@ -349,8 +350,8 @@ bool QgsPdalProvider::load( const QString &uri ) QString QgsPdalProviderMetadata::sFilterString; QStringList QgsPdalProviderMetadata::sExtensions; -QgsPdalProviderMetadata::QgsPdalProviderMetadata(): - QgsProviderMetadata( PROVIDER_KEY, PROVIDER_DESCRIPTION ) +QgsPdalProviderMetadata::QgsPdalProviderMetadata() + : QgsProviderMetadata( PROVIDER_KEY, PROVIDER_DESCRIPTION ) { } @@ -418,7 +419,7 @@ QList QgsPdalProviderMetadata::querySublayers( const details.setProviderKey( QStringLiteral( "pdal" ) ); details.setType( Qgis::LayerType::PointCloud ); details.setName( QgsProviderUtils::suggestLayerNameFromFilePath( uri ) ); - return {details}; + return { details }; } else { @@ -466,8 +467,7 @@ void QgsPdalProviderMetadata::buildSupportedPointCloudFileFilterAndExtensions() { // get supported extensions static std::once_flag initialized; - std::call_once( initialized, [ = ] - { + std::call_once( initialized, [=] { const pdal::StageFactory f; pdal::PluginManager::loadAll(); const pdal::StringList stages = pdal::PluginManager::names(); @@ -479,7 +479,8 @@ void QgsPdalProviderMetadata::buildSupportedPointCloudFileFilterAndExtensions() const QStringList allowedReaders { QStringLiteral( "readers.las" ), QStringLiteral( "readers.e57" ), - QStringLiteral( "readers.bpf" ) }; + QStringLiteral( "readers.bpf" ) + }; // the readers.text exposes extensions (csv, txt) which are generally not // point cloud files. Add these extensions to the filters but do not expose @@ -488,7 +489,7 @@ void QgsPdalProviderMetadata::buildSupportedPointCloudFileFilterAndExtensions() // drop action. The windows which want to handle the "readers.text" reader // need to explicitly call the provider. // see for example qgspointcloudsourceselect.cpp. - const QStringList specificReaders {QStringLiteral( "readers.text" ) }; + const QStringList specificReaders { QStringLiteral( "readers.text" ) }; const QStringList readers = allowedReaders + specificReaders; QStringList filterExtensions; diff --git a/src/providers/pdal/qgspdalprovider.h b/src/providers/pdal/qgspdalprovider.h index e9896e8636c2..4d23b7bb3cae 100644 --- a/src/providers/pdal/qgspdalprovider.h +++ b/src/providers/pdal/qgspdalprovider.h @@ -24,13 +24,11 @@ class QgsPdalIndexingTask; -class QgsPdalProvider: public QgsPointCloudDataProvider +class QgsPdalProvider : public QgsPointCloudDataProvider { Q_OBJECT public: - QgsPdalProvider( const QString &uri, - const QgsDataProvider::ProviderOptions &providerOptions, - Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); + QgsPdalProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); ~QgsPdalProvider(); Qgis::DataProviderFlags flags() const override; @@ -43,9 +41,9 @@ class QgsPdalProvider: public QgsPointCloudDataProvider QString name() const override; QString description() const override; QgsPointCloudIndex *index() const override; - void loadIndex( ) override; - void generateIndex( ) override; - PointCloudIndexGenerationState indexingState( ) override; + void loadIndex() override; + void generateIndex() override; + PointCloudIndexGenerationState indexingState() override; private slots: void onGenerateIndexFinished(); @@ -79,17 +77,16 @@ class QgsPdalProviderMetadata : public QgsProviderMetadata QString encodeUri( const QVariantMap &parts ) const override; QVariantMap decodeUri( const QString &uri ) const override; int priorityForUri( const QString &uri ) const override; - QList< Qgis::LayerType > validLayerTypesForUri( const QString &uri ) const override; - QList< QgsProviderSublayerDetails > querySublayers( const QString &uri, Qgis::SublayerQueryFlags flags = Qgis::SublayerQueryFlags(), QgsFeedback *feedback = nullptr ) const override; + QList validLayerTypesForUri( const QString &uri ) const override; + QList querySublayers( const QString &uri, Qgis::SublayerQueryFlags flags = Qgis::SublayerQueryFlags(), QgsFeedback *feedback = nullptr ) const override; QString filters( Qgis::FileFilterType type ) override; ProviderCapabilities providerCapabilities() const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; private: static QString sFilterString; static QStringList sExtensions; void buildSupportedPointCloudFileFilterAndExtensions(); - }; #endif // QGSPDALPROVIDER_H diff --git a/src/providers/pdal/qgspdalprovidergui.cpp b/src/providers/pdal/qgspdalprovidergui.cpp index dabefc25b635..226bdffb2815 100644 --- a/src/providers/pdal/qgspdalprovidergui.cpp +++ b/src/providers/pdal/qgspdalprovidergui.cpp @@ -19,7 +19,7 @@ #include "qgspdalprovider.h" -class QgsPdalProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsPdalProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsPdalProviderGuiMetadata() diff --git a/src/providers/pdal/qgspdalprovidergui.h b/src/providers/pdal/qgspdalprovidergui.h index 1894b81c69c4..5ad88883afb3 100644 --- a/src/providers/pdal/qgspdalprovidergui.h +++ b/src/providers/pdal/qgspdalprovidergui.h @@ -21,7 +21,7 @@ #include "qgsproviderguimetadata.h" -class QgsPdalProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsPdalProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsPdalProviderGuiMetadata(); diff --git a/src/providers/postgres/qgscolumntypethread.cpp b/src/providers/postgres/qgscolumntypethread.cpp index ae1b5b422a0e..5119c42e1c66 100644 --- a/src/providers/postgres/qgscolumntypethread.cpp +++ b/src/providers/postgres/qgscolumntypethread.cpp @@ -57,11 +57,7 @@ void QgsGeomColumnTypeThread::run() emit progressMessage( tr( "Retrieving tables of %1…" ).arg( mName ) ); QVector layerProperties; - if ( !mConn->supportedLayers( layerProperties, - QgsPostgresConn::geometryColumnsOnly( mName ), - QgsPostgresConn::publicSchemaOnly( mName ), - mAllowGeometrylessTables ) || - layerProperties.isEmpty() ) + if ( !mConn->supportedLayers( layerProperties, QgsPostgresConn::geometryColumnsOnly( mName ), QgsPostgresConn::publicSchemaOnly( mName ), mAllowGeometrylessTables ) || layerProperties.isEmpty() ) { QgsPostgresConnPool::instance()->releaseConnection( mConn ); mConn = nullptr; @@ -77,9 +73,7 @@ void QgsGeomColumnTypeThread::run() for ( auto &layerProperty : layerProperties ) { - if ( !layerProperty.geometryColName.isNull() && - ( layerProperty.types.value( 0, Qgis::WkbType::Unknown ) == Qgis::WkbType::Unknown || - layerProperty.srids.value( 0, std::numeric_limits::min() ) == std::numeric_limits::min() ) ) + if ( !layerProperty.geometryColName.isNull() && ( layerProperty.types.value( 0, Qgis::WkbType::Unknown ) == Qgis::WkbType::Unknown || layerProperty.srids.value( 0, std::numeric_limits::min() ) == std::numeric_limits::min() ) ) { unrestrictedLayers << &layerProperty; } @@ -94,7 +88,7 @@ void QgsGeomColumnTypeThread::run() return; } - if ( ! dontResolveType ) + if ( !dontResolveType ) { mConn->retrieveLayerTypes( unrestrictedLayers, mUseEstimatedMetadata ); } diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index da74bee06daf..cded70f6b943 100644 --- a/src/providers/postgres/qgspgnewconnection.cpp +++ b/src/providers/postgres/qgspgnewconnection.cpp @@ -132,23 +132,13 @@ void QgsPgNewConnection::accept() bool hasAuthConfigID = !mAuthSettings->configId().isEmpty(); testConnection(); - if ( !hasAuthConfigID && mAuthSettings->storePasswordIsChecked( ) && - QMessageBox::question( this, - tr( "Saving Passwords" ), - tr( "WARNING: You have opted to save your password. It will be stored in unsecured plain text in your project files and in your home directory (Unix-like OS) or user profile (Windows). If you want to avoid this, press Cancel and either:\n\na) Don't save a password in the connection settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your credentials in an HTTP Basic Authentication method and store them in an encrypted database." ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( !hasAuthConfigID && mAuthSettings->storePasswordIsChecked() && QMessageBox::question( this, tr( "Saving Passwords" ), tr( "WARNING: You have opted to save your password. It will be stored in unsecured plain text in your project files and in your home directory (Unix-like OS) or user profile (Windows). If you want to avoid this, press Cancel and either:\n\na) Don't save a password in the connection settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your credentials in an HTTP Basic Authentication method and store them in an encrypted database." ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; } // warn if entry was renamed to an existing connection - if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( txtName->text(), Qt::CaseInsensitive ) != 0 ) && - ( settings.contains( baseKey + txtName->text() + "/service" ) || - settings.contains( baseKey + txtName->text() + "/host" ) ) && - QMessageBox::question( this, - tr( "Save Connection" ), - tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), - QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) + if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( txtName->text(), Qt::CaseInsensitive ) != 0 ) && ( settings.contains( baseKey + txtName->text() + "/service" ) || settings.contains( baseKey + txtName->text() + "/host" ) ) && QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) { return; } @@ -165,12 +155,12 @@ void QgsPgNewConnection::accept() settings.setValue( baseKey + "/host", txtHost->text() ); settings.setValue( baseKey + "/port", txtPort->text() ); settings.setValue( baseKey + "/database", txtDatabase->text() ); - settings.setValue( baseKey + "/username", mAuthSettings->storeUsernameIsChecked( ) ? mAuthSettings->username() : QString() ); - settings.setValue( baseKey + "/password", mAuthSettings->storePasswordIsChecked( ) && !hasAuthConfigID ? mAuthSettings->password() : QString() ); + settings.setValue( baseKey + "/username", mAuthSettings->storeUsernameIsChecked() ? mAuthSettings->username() : QString() ); + settings.setValue( baseKey + "/password", mAuthSettings->storePasswordIsChecked() && !hasAuthConfigID ? mAuthSettings->password() : QString() ); settings.setValue( baseKey + "/authcfg", mAuthSettings->configId() ); settings.setValue( baseKey + "/sslmode", cbxSSLmode->currentData().toInt() ); - settings.setValue( baseKey + "/saveUsername", mAuthSettings->storeUsernameIsChecked( ) ? "true" : "false" ); - settings.setValue( baseKey + "/savePassword", mAuthSettings->storePasswordIsChecked( ) ? "true" : "false" ); + settings.setValue( baseKey + "/saveUsername", mAuthSettings->storeUsernameIsChecked() ? "true" : "false" ); + settings.setValue( baseKey + "/savePassword", mAuthSettings->storePasswordIsChecked() ? "true" : "false" ); // remove old save setting settings.remove( baseKey + "/save" ); @@ -181,15 +171,15 @@ void QgsPgNewConnection::accept() configuration.insert( "dontResolveType", cb_dontResolveType->isChecked() ); configuration.insert( "allowGeometrylessTables", cb_allowGeometrylessTables->isChecked() ); configuration.insert( "sslmode", cbxSSLmode->currentData().toInt() ); - configuration.insert( "saveUsername", mAuthSettings->storeUsernameIsChecked( ) ? "true" : "false" ); - configuration.insert( "savePassword", mAuthSettings->storePasswordIsChecked( ) && !hasAuthConfigID ? "true" : "false" ); + configuration.insert( "saveUsername", mAuthSettings->storeUsernameIsChecked() ? "true" : "false" ); + configuration.insert( "savePassword", mAuthSettings->storePasswordIsChecked() && !hasAuthConfigID ? "true" : "false" ); configuration.insert( "estimatedMetadata", cb_useEstimatedMetadata->isChecked() ); configuration.insert( "projectsInDatabase", cb_projectsInDatabase->isChecked() ); configuration.insert( "metadataInDatabase", cb_metadataInDatabase->isChecked() ); configuration.insert( "session_role", txtSessionRole->text() ); QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "postgres" ) ); - std::unique_ptr< QgsPostgresProviderConnection > providerConnection( qgis::down_cast( providerMetadata->createConnection( txtName->text() ) ) ); + std::unique_ptr providerConnection( qgis::down_cast( providerMetadata->createConnection( txtName->text() ) ) ); providerConnection->setUri( QgsPostgresConn::connUri( txtName->text() ).uri( false ) ); providerConnection->setConfiguration( configuration ); providerMetadata->saveConnection( providerConnection.get(), txtName->text() ); @@ -219,17 +209,11 @@ void QgsPgNewConnection::testConnection() QgsDataSourceUri uri; if ( !txtService->text().isEmpty() ) { - uri.setConnection( txtService->text(), txtDatabase->text(), - mAuthSettings->username(), mAuthSettings->password(), - ( QgsDataSourceUri::SslMode ) cbxSSLmode->currentData().toInt(), - mAuthSettings->configId() ); + uri.setConnection( txtService->text(), txtDatabase->text(), mAuthSettings->username(), mAuthSettings->password(), ( QgsDataSourceUri::SslMode ) cbxSSLmode->currentData().toInt(), mAuthSettings->configId() ); } else { - uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), - mAuthSettings->username(), mAuthSettings->password(), - ( QgsDataSourceUri::SslMode ) cbxSSLmode->currentData().toInt(), - mAuthSettings->configId() ); + uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), mAuthSettings->username(), mAuthSettings->password(), ( QgsDataSourceUri::SslMode ) cbxSSLmode->currentData().toInt(), mAuthSettings->configId() ); } if ( !txtSessionRole->text().isEmpty() ) @@ -259,16 +243,14 @@ void QgsPgNewConnection::testConnection() } // Database successfully opened; we can now issue SQL commands. - bar->pushMessage( tr( "Connection to %1 was successful." ).arg( txtName->text() ), - Qgis::MessageLevel::Success ); + bar->pushMessage( tr( "Connection to %1 was successful." ).arg( txtName->text() ), Qgis::MessageLevel::Success ); // free pg connection resources conn->unref(); } else { - bar->pushMessage( tr( "Connection failed - consult message log for details." ), - Qgis::MessageLevel::Warning ); + bar->pushMessage( tr( "Connection failed - consult message log for details." ), Qgis::MessageLevel::Warning ); } } @@ -279,8 +261,6 @@ void QgsPgNewConnection::showHelp() void QgsPgNewConnection::updateOkButtonState() { - bool enabled = !txtName->text().isEmpty() && ( - !txtService->text().isEmpty() || - !txtDatabase->text().isEmpty() ); + bool enabled = !txtName->text().isEmpty() && ( !txtService->text().isEmpty() || !txtDatabase->text().isEmpty() ); buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled ); } diff --git a/src/providers/postgres/qgspgnewconnection.h b/src/providers/postgres/qgspgnewconnection.h index 9d0d5e66a90d..ddc24843c4d8 100644 --- a/src/providers/postgres/qgspgnewconnection.h +++ b/src/providers/postgres/qgspgnewconnection.h @@ -41,10 +41,10 @@ class QgsPgNewConnection : public QDialog, private Ui::QgsPgNewConnectionBase private slots: //! Updates state of the OK button depending of the filled fields void updateOkButtonState(); + private: QString mOriginalConnName; //store initial name to delete entry in case of rename void showHelp(); - }; #endif // QGSPGNEWCONNECTIONBASE_H diff --git a/src/providers/postgres/qgspgsourceselect.cpp b/src/providers/postgres/qgspgsourceselect.cpp index e4baaba880ce..10d1e7d6cd61 100644 --- a/src/providers/postgres/qgspgsourceselect.cpp +++ b/src/providers/postgres/qgspgsourceselect.cpp @@ -62,31 +62,10 @@ QWidget *QgsPgSourceSelectDelegate::createEditor( QWidget *parent, const QStyleO if ( index.column() == QgsPgTableModel::DbtmType && index.data( Qt::UserRole + 1 ).toBool() ) { QComboBox *cb = new QComboBox( parent ); - static const QList types { Qgis::WkbType::Point, - Qgis::WkbType::LineString, - Qgis::WkbType::LineStringZ, - Qgis::WkbType::LineStringM, - Qgis::WkbType::LineStringZM, - Qgis::WkbType::Polygon, - Qgis::WkbType::PolygonZ, - Qgis::WkbType::PolygonM, - Qgis::WkbType::PolygonZM, - Qgis::WkbType::MultiPoint, - Qgis::WkbType::MultiPointZ, - Qgis::WkbType::MultiPointM, - Qgis::WkbType::MultiPointZM, - Qgis::WkbType::MultiLineString, - Qgis::WkbType::MultiLineStringZ, - Qgis::WkbType::MultiLineStringM, - Qgis::WkbType::MultiLineStringZM, - Qgis::WkbType::MultiPolygon, - Qgis::WkbType::MultiPolygonZ, - Qgis::WkbType::MultiPolygonM, - Qgis::WkbType::MultiPolygonZM, - Qgis::WkbType::NoGeometry }; + static const QList types { Qgis::WkbType::Point, Qgis::WkbType::LineString, Qgis::WkbType::LineStringZ, Qgis::WkbType::LineStringM, Qgis::WkbType::LineStringZM, Qgis::WkbType::Polygon, Qgis::WkbType::PolygonZ, Qgis::WkbType::PolygonM, Qgis::WkbType::PolygonZM, Qgis::WkbType::MultiPoint, Qgis::WkbType::MultiPointZ, Qgis::WkbType::MultiPointM, Qgis::WkbType::MultiPointZM, Qgis::WkbType::MultiLineString, Qgis::WkbType::MultiLineStringZ, Qgis::WkbType::MultiLineStringM, Qgis::WkbType::MultiLineStringZM, Qgis::WkbType::MultiPolygon, Qgis::WkbType::MultiPolygonZ, Qgis::WkbType::MultiPolygonM, Qgis::WkbType::MultiPolygonZM, Qgis::WkbType::NoGeometry }; for ( Qgis::WkbType type : types ) { - cb->addItem( QgsIconUtils::iconForWkbType( type ), QgsPostgresConn::displayStringForWkbType( type ), static_cast< quint32>( type ) ); + cb->addItem( QgsIconUtils::iconForWkbType( type ), QgsPostgresConn::displayStringForWkbType( type ), static_cast( type ) ); } return cb; } @@ -132,7 +111,7 @@ void QgsPgSourceSelectDelegate::setEditorData( QWidget *editor, const QModelInde { QString value( index.data( Qt::DisplayRole ).toString() ); - QComboBox *cb = qobject_cast( editor ); + QComboBox *cb = qobject_cast( editor ); if ( cb ) { if ( index.column() == QgsPgTableModel::DbtmType ) @@ -156,7 +135,6 @@ void QgsPgSourceSelectDelegate::setEditorData( QWidget *editor, const QModelInde break; } } - } } @@ -164,7 +142,7 @@ void QgsPgSourceSelectDelegate::setEditorData( QWidget *editor, const QModelInde if ( le ) { bool ok; - ( void )value.toInt( &ok ); + ( void ) value.toInt( &ok ); if ( index.column() == QgsPgTableModel::DbtmSrid && !ok ) value.clear(); @@ -179,11 +157,11 @@ void QgsPgSourceSelectDelegate::setModelData( QWidget *editor, QAbstractItemMode { if ( index.column() == QgsPgTableModel::DbtmType ) { - Qgis::WkbType type = static_cast< Qgis::WkbType >( cb->currentData().toInt() ); + Qgis::WkbType type = static_cast( cb->currentData().toInt() ); model->setData( index, QgsIconUtils::iconForWkbType( type ), Qt::DecorationRole ); model->setData( index, type != Qgis::WkbType::Unknown ? QgsPostgresConn::displayStringForWkbType( type ) : tr( "Select…" ) ); - model->setData( index, static_cast< quint32>( type ), Qt::UserRole + 2 ); + model->setData( index, static_cast( type ), Qt::UserRole + 2 ); } else if ( index.column() == QgsPgTableModel::DbtmPkCol ) { @@ -275,7 +253,7 @@ void QgsPgSourceSelect::btnNew_clicked() void QgsPgSourceSelect::btnDelete_clicked() { QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ) - .arg( cmbConnections->currentText() ); + .arg( cmbConnections->currentText() ); if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) ) return; @@ -294,8 +272,7 @@ void QgsPgSourceSelect::btnSave_clicked() void QgsPgSourceSelect::btnLoad_clicked() { - QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; @@ -411,11 +388,11 @@ void QgsPgSourceSelect::addButtonClicked() } else { - if ( ! dbTables.isEmpty() ) + if ( !dbTables.isEmpty() ) { emit addDatabaseLayers( dbTables, QStringLiteral( "postgres" ) ); } - if ( ! rasterTables.isEmpty() ) + if ( !rasterTables.isEmpty() ) { for ( const auto &u : std::as_const( rasterTables ) ) { @@ -434,7 +411,6 @@ void QgsPgSourceSelect::addButtonClicked() // Clear selection after layers have been added mTablesTreeView->selectionModel()->clearSelection(); - } } @@ -466,17 +442,12 @@ void QgsPgSourceSelect::btnConnect_clicked() mColumnTypeTask = new QgsProxyProgressTask( tr( "Scanning tables for %1" ).arg( cmbConnections->currentText() ) ); QgsApplication::taskManager()->addTask( mColumnTypeTask ); - connect( mColumnTypeThread, &QgsGeomColumnTypeThread::setLayerType, - this, &QgsPgSourceSelect::setLayerType ); - connect( mColumnTypeThread, &QThread::finished, - this, &QgsPgSourceSelect::columnThreadFinished ); - connect( mColumnTypeThread, &QgsGeomColumnTypeThread::progress, - mColumnTypeTask, [ = ]( int i, int n ) - { - mColumnTypeTask->setProxyProgress( 100.0 * static_cast< double >( i ) / n ); + connect( mColumnTypeThread, &QgsGeomColumnTypeThread::setLayerType, this, &QgsPgSourceSelect::setLayerType ); + connect( mColumnTypeThread, &QThread::finished, this, &QgsPgSourceSelect::columnThreadFinished ); + connect( mColumnTypeThread, &QgsGeomColumnTypeThread::progress, mColumnTypeTask, [=]( int i, int n ) { + mColumnTypeTask->setProxyProgress( 100.0 * static_cast( i ) / n ); } ); - connect( mColumnTypeThread, &QgsGeomColumnTypeThread::progressMessage, - this, &QgsPgSourceSelect::progressMessage ); + connect( mColumnTypeThread, &QgsGeomColumnTypeThread::progressMessage, this, &QgsPgSourceSelect::progressMessage ); btnConnect->setText( tr( "Stop" ) ); mColumnTypeThread->start(); diff --git a/src/providers/postgres/qgspgsourceselect.h b/src/providers/postgres/qgspgsourceselect.h index dfe059a49e53..a7239289729a 100644 --- a/src/providers/postgres/qgspgsourceselect.h +++ b/src/providers/postgres/qgspgsourceselect.h @@ -140,7 +140,7 @@ class QgsPgSourceSelect : public QgsAbstractDbSourceSelect QStringList mSelectedTables; bool mUseEstimatedMetadata = false; // Storage for the range of layer type icons - QMap > mLayerIcons; + QMap> mLayerIcons; //! Model that acts as datasource for mTableTreeWidget QgsPgTableModel *mTableModel = nullptr; diff --git a/src/providers/postgres/qgspgtablemodel.cpp b/src/providers/postgres/qgspgtablemodel.cpp index 510340c22d33..1fe7362a9aa4 100644 --- a/src/providers/postgres/qgspgtablemodel.cpp +++ b/src/providers/postgres/qgspgtablemodel.cpp @@ -87,8 +87,8 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper for ( int i = 0; i < layerProperty.size(); i++ ) { - Qgis::WkbType wkbType = layerProperty.types[ i ]; - const int srid = layerProperty.srids[ i ]; + Qgis::WkbType wkbType = layerProperty.types[i]; + const int srid = layerProperty.srids[i]; if ( wkbType == Qgis::WkbType::Unknown && layerProperty.geometryColName.isEmpty() ) { @@ -97,7 +97,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper QString tip; bool withTipButSelectable = false; - if ( ! layerProperty.isRaster ) + if ( !layerProperty.isRaster ) { if ( wkbType == Qgis::WkbType::Unknown ) { @@ -125,7 +125,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper typeItem = new QStandardItem( QgsIconUtils::iconForWkbType( wkbType ), wkbType == Qgis::WkbType::Unknown ? tr( "Select…" ) : QgsPostgresConn::displayStringForWkbType( wkbType ) ); } typeItem->setData( wkbType == Qgis::WkbType::Unknown, Qt::UserRole + 1 ); - typeItem->setData( static_cast< quint32>( wkbType ), Qt::UserRole + 2 ); + typeItem->setData( static_cast( wkbType ), Qt::UserRole + 2 ); typeItem->setData( layerProperty.isRaster, Qt::UserRole + 3 ); if ( wkbType == Qgis::WkbType::Unknown ) typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable ); @@ -134,7 +134,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper QStandardItem *tableItem = new QStandardItem( layerProperty.tableName ); QStandardItem *commentItem = new QStandardItem( layerProperty.tableComment ); - if ( ! layerProperty.tableComment.isEmpty() ) + if ( !layerProperty.tableComment.isEmpty() ) { // word wrap QString commentText { layerProperty.tableComment }; @@ -144,8 +144,8 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper commentItem->setToolTip( QStringLiteral( "%1" ).arg( commentText.replace( '\n', QLatin1String( "
    " ) ) ) ); commentItem->setTextAlignment( Qt::AlignTop ); } - QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName ); - QStandardItem *sridItem = new QStandardItem( wkbType != Qgis::WkbType::NoGeometry ? QString::number( srid ) : QString() ); + QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName ); + QStandardItem *sridItem = new QStandardItem( wkbType != Qgis::WkbType::NoGeometry ? QString::number( srid ) : QString() ); sridItem->setEditable( wkbType != Qgis::WkbType::NoGeometry && srid == std::numeric_limits::min() ); if ( sridItem->isEditable() ) { @@ -183,7 +183,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper selItem->setCheckState( Qt::Checked ); selItem->setToolTip( headerData( Columns::DbtmSelectAtId, Qt::Orientation::Horizontal, Qt::ToolTipRole ).toString() ); - QStandardItem *checkPkUnicityItem = new QStandardItem( QString() ); + QStandardItem *checkPkUnicityItem = new QStandardItem( QString() ); checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() | Qt::ItemIsUserCheckable ); // Legacy: default value is determined by project option to trust layer's metadata @@ -193,7 +193,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper { case Qgis::PostgresRelKind::View: case Qgis::PostgresRelKind::MaterializedView: - checkPkUnicityItem->setCheckState( ( QgsProject::instance( )->flags() & Qgis::ProjectFlag::TrustStoredLayerStatistics ) ? Qt::CheckState::Unchecked : Qt::CheckState::Checked ); + checkPkUnicityItem->setCheckState( ( QgsProject::instance()->flags() & Qgis::ProjectFlag::TrustStoredLayerStatistics ) ? Qt::CheckState::Unchecked : Qt::CheckState::Checked ); checkPkUnicityItem->setToolTip( headerData( Columns::DbtmCheckPkUnicity, Qt::Orientation::Horizontal, Qt::ToolTipRole ).toString() ); break; @@ -207,7 +207,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper case Qgis::PostgresRelKind::ForeignTable: case Qgis::PostgresRelKind::PartitionedTable: checkPkUnicityItem->setCheckState( Qt::CheckState::Unchecked ); - checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() & ~ Qt::ItemIsEnabled ); + checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() & ~Qt::ItemIsEnabled ); checkPkUnicityItem->setToolTip( tr( "This option is only available for views and materialized views." ) ); break; } @@ -217,9 +217,9 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper // For rasters, disable if ( layerProperty.isRaster ) { - selItem->setFlags( selItem->flags() & ~ Qt::ItemIsUserCheckable ); + selItem->setFlags( selItem->flags() & ~Qt::ItemIsUserCheckable ); selItem->setCheckState( Qt::Unchecked ); - checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() & ~ Qt::ItemIsUserCheckable ); + checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() & ~Qt::ItemIsUserCheckable ); checkPkUnicityItem->setCheckState( Qt::Unchecked ); } @@ -364,7 +364,7 @@ bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, in if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol ) { - const Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() ); + const Qgis::WkbType wkbType = static_cast( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() ); QString tip; if ( wkbType == Qgis::WkbType::Unknown ) @@ -448,13 +448,9 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn const QString tableName = index.sibling( index.row(), DbtmTable ).data( Qt::DisplayRole ).toString(); const QString geomColumnName = index.sibling( index.row(), DbtmGeomCol ).data( Qt::DisplayRole ).toString(); QString connString { QStringLiteral( "PG: %1 mode=2 %2schema='%3' column='%4' table='%5'" ) - .arg( connInfo, - cols.isEmpty() ? QString() : QStringLiteral( "key='%1' " ).arg( cols.join( ',' ) ), - schemaName, - geomColumnName, - tableName ) }; + .arg( connInfo, cols.isEmpty() ? QString() : QStringLiteral( "key='%1' " ).arg( cols.join( ',' ) ), schemaName, geomColumnName, tableName ) }; const QString sql { index.sibling( index.row(), DbtmSql ).data( Qt::DisplayRole ).toString() }; - if ( ! sql.isEmpty() ) + if ( !sql.isEmpty() ) { connString.append( QStringLiteral( " sql=%1" ).arg( sql ) ); } @@ -489,7 +485,7 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn srid = index.sibling( index.row(), DbtmSrid ).data( Qt::DisplayRole ).toString(); bool ok; - ( void )srid.toInt( &ok ); + ( void ) srid.toInt( &ok ); if ( !ok ) { QgsDebugError( QStringLiteral( "srid not numeric" ) ); @@ -522,4 +518,3 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString &conn QgsDebugMsgLevel( QStringLiteral( "returning uri %1" ).arg( uri.uri( false ) ), 2 ); return uri.uri( false ); } - diff --git a/src/providers/postgres/qgspgtablemodel.h b/src/providers/postgres/qgspgtablemodel.h index 0d26d579a603..a219173a0989 100644 --- a/src/providers/postgres/qgspgtablemodel.h +++ b/src/providers/postgres/qgspgtablemodel.h @@ -55,7 +55,7 @@ class QgsPgTableModel : public QgsAbstractDbTableModel DbtmComment, DbtmGeomCol, DbtmGeomType, // Data type (geometry, geography, topogeometry, ...) - DbtmType, // Spatial type (point, line, polygon, ...) + DbtmType, // Spatial type (point, line, polygon, ...) DbtmSrid, DbtmPkCol, DbtmSelectAtId, @@ -67,7 +67,7 @@ class QgsPgTableModel : public QgsAbstractDbTableModel QString layerURI( const QModelIndex &index, const QString &connInfo, bool useEstimatedMetadata ); - void setConnectionName( const QString &connName ) { mConnName = connName; } + void setConnectionName( const QString &connName ) { mConnName = connName; } private: //! Number of tables in the model @@ -75,7 +75,6 @@ class QgsPgTableModel : public QgsAbstractDbTableModel //! connection name QString mConnName; QStringList mColumns; - }; #endif // QGSPGTABLEMODEL_H diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index 83266eb71f74..fe87882499dd 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -103,8 +103,8 @@ QString QgsPostgresResult::PQgetvalue( int row, int col ) { Q_ASSERT( mRes ); return PQgetisnull( row, col ) - ? QString() - : QString::fromUtf8( ::PQgetvalue( mRes, row, col ) ); + ? QString() + : QString::fromUtf8( ::PQgetvalue( mRes, row, col ) ); } bool QgsPostgresResult::PQgetisnull( int row, int col ) @@ -174,8 +174,7 @@ const int QgsPostgresConn::GEOM_TYPE_SELECT_LIMIT = 100; QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool readonly, bool shared, bool transaction, bool allowRequestCredentials ) { - QMap &connections = - readonly ? QgsPostgresConn::sConnectionsRO : QgsPostgresConn::sConnectionsRW; + QMap &connections = readonly ? QgsPostgresConn::sConnectionsRO : QgsPostgresConn::sConnectionsRW; // This is called from may places where shared parameter cannot be forced to false (QgsVectorLayerExporter) // and which is run in a different thread (drag and drop in browser) @@ -199,10 +198,9 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado QStringLiteral( "Using cached (%3) connection for %1 (%2)" ) - .arg( conninfo ) - .arg( reinterpret_cast( conn ) ) - .arg( readonly ? "readonly" : "read-write" ) - , + .arg( conninfo ) + .arg( reinterpret_cast( conn ) ) + .arg( readonly ? "readonly" : "read-write" ), 2 ); conn->mRef++; @@ -212,9 +210,8 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado QStringLiteral( "Cached (%2) connection for %1 not found" ) - .arg( conninfo ) - .arg( readonly ? "readonly" : "read-write" ) - , + .arg( conninfo ) + .arg( readonly ? "readonly" : "read-write" ), 2 ); } @@ -224,11 +221,10 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado QStringLiteral( "Created new (%4) connection %2 for %1%3" ) - .arg( conninfo ) - .arg( reinterpret_cast( conn ) ) - .arg( shared ? " (shared)" : "" ) - .arg( readonly ? "readonly" : "read-write" ) - , + .arg( conninfo ) + .arg( reinterpret_cast( conn ) ) + .arg( shared ? " (shared)" : "" ) + .arg( readonly ? "readonly" : "read-write" ), 2 ); @@ -239,10 +235,9 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado QStringLiteral( "New (%3) connection %2 failed for conninfo %1" ) - .arg( conninfo ) - .arg( reinterpret_cast( conn ) ) - .arg( readonly ? "readonly" : "read-write" ) - , + .arg( conninfo ) + .arg( reinterpret_cast( conn ) ) + .arg( readonly ? "readonly" : "read-write" ), 2 ); delete conn; @@ -256,10 +251,9 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado QStringLiteral( "Added connection %2 (for %1) in (%3) cache" ) - .arg( conninfo ) - .arg( reinterpret_cast( conn ) ) - .arg( readonly ? "readonly" : "read-write" ) - , + .arg( conninfo ) + .arg( reinterpret_cast( conn ) ) + .arg( readonly ? "readonly" : "read-write" ), 2 ); } @@ -287,8 +281,7 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QgsDataSourceUri &uri, bool r QStringLiteral( "Set session role failed for ROLE %1" ) - .arg( quotedValue( sessionRole ) ) - , + .arg( quotedValue( sessionRole ) ), 2 ); conn->unref(); @@ -333,14 +326,12 @@ QgsPostgresConn::QgsPostgresConn( const QString &conninfo, bool readOnly, bool s , mShared( shared ) , mTransaction( transaction ) { - QgsDebugMsgLevel( QStringLiteral( "New PostgreSQL connection for " ) + conninfo, 2 ); // expand connectionInfo QString expandedConnectionInfo = mUri.connectionInfo( true ); - auto addDefaultTimeoutAndClientEncoding = []( QString & connectString ) - { + auto addDefaultTimeoutAndClientEncoding = []( QString &connectString ) { if ( !connectString.contains( QStringLiteral( "connect_timeout=" ) ) ) { // add default timeout @@ -460,7 +451,7 @@ QgsPostgresConn::QgsPostgresConn( const QString &conninfo, bool readOnly, bool s // testInt(little-endian): 01 0...0 00 // testInt(big-endian): 00 0...0 01 // *char: ^^ - mSwapEndian = *( char * )&testInt == 1; + mSwapEndian = *( char * ) &testInt == 1; } /* Check to see if we have working PostGIS support */ @@ -531,10 +522,9 @@ void QgsPostgresConn::unref() QStringLiteral( "Cached (%1) connection for %2 (%3) removed" ) - .arg( mReadOnly ? "readonly" : "read-write" ) - .arg( mConnInfo ) - .arg( reinterpret_cast( this ) ) - , + .arg( mReadOnly ? "readonly" : "read-write" ) + .arg( mConnInfo ) + .arg( reinterpret_cast( this ) ), 2 ); } @@ -575,9 +565,8 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty &layerProperty, co // could use array_agg() and count() // array output would look like this: "{One,tWo}" QString sql = QStringLiteral( "SELECT attname, CASE WHEN typname in (%1) THEN 1 ELSE null END AS isSpatial FROM pg_attribute JOIN pg_type ON atttypid=pg_type.oid WHERE attrelid=regclass('%2.%3') AND NOT attisdropped AND attnum>0 ORDER BY attnum" ) - .arg( supportedSpatialTypes().join( ',' ) ) - .arg( quotedIdentifier( schemaName ), - quotedIdentifier( viewName ) ); + .arg( supportedSpatialTypes().join( ',' ) ) + .arg( quotedIdentifier( schemaName ), quotedIdentifier( viewName ) ); QgsDebugMsgLevel( "getting column info: " + sql, 2 ); QgsPostgresResult colRes( LoggedPQexec( "QgsPostgresConn", sql ) ); @@ -603,7 +592,6 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty &layerProperty, co { QgsMessageLog::logMessage( tr( "SQL: %1\nresult: %2\nerror: %3\n" ).arg( sql ).arg( colRes.PQresultStatus() ).arg( colRes.PQresultErrorMessage() ), tr( "PostGIS" ) ); } - } bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, const QString &schema, const QString &name ) @@ -620,25 +608,24 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP if ( i == SctGeometry ) { - tableName = QStringLiteral( "l.f_table_name" ); + tableName = QStringLiteral( "l.f_table_name" ); schemaName = QStringLiteral( "l.f_table_schema" ); columnName = QStringLiteral( "l.f_geometry_column" ); - typeName = QStringLiteral( "upper(l.type)" ); - sridName = QStringLiteral( "l.srid" ); - dimName = QStringLiteral( "l.coord_dimension" ); + typeName = QStringLiteral( "upper(l.type)" ); + sridName = QStringLiteral( "l.srid" ); + dimName = QStringLiteral( "l.coord_dimension" ); gtableName = QStringLiteral( "geometry_columns" ); } // Geography since postgis 1.5 else if ( i == SctGeography - && ( mPostgisVersionMajor >= 2 - || ( mPostgisVersionMajor == 1 && mPostgisVersionMinor >= 5 ) ) ) + && ( mPostgisVersionMajor >= 2 || ( mPostgisVersionMajor == 1 && mPostgisVersionMinor >= 5 ) ) ) { - tableName = QStringLiteral( "l.f_table_name" ); + tableName = QStringLiteral( "l.f_table_name" ); schemaName = QStringLiteral( "l.f_table_schema" ); columnName = QStringLiteral( "l.f_geography_column" ); - typeName = QStringLiteral( "upper(l.type)" ); - sridName = QStringLiteral( "l.srid" ); - dimName = QStringLiteral( "2" ); + typeName = QStringLiteral( "upper(l.type)" ); + sridName = QStringLiteral( "l.srid" ); + dimName = QStringLiteral( "2" ); gtableName = QStringLiteral( "geography_columns" ); } else if ( i == SctTopoGeometry ) @@ -647,16 +634,16 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP continue; schemaName = QStringLiteral( "l.schema_name" ); - tableName = QStringLiteral( "l.table_name" ); + tableName = QStringLiteral( "l.table_name" ); columnName = QStringLiteral( "l.feature_column" ); - typeName = "CASE " - "WHEN l.feature_type = 1 THEN 'MULTIPOINT' " - "WHEN l.feature_type = 2 THEN 'MULTILINESTRING' " - "WHEN l.feature_type = 3 THEN 'MULTIPOLYGON' " - "WHEN l.feature_type = 4 THEN 'GEOMETRYCOLLECTION' " - "END AS type"; - sridName = QStringLiteral( "(SELECT srid FROM topology.topology t WHERE l.topology_id=t.id)" ); - dimName = QStringLiteral( "2" ); + typeName = "CASE " + "WHEN l.feature_type = 1 THEN 'MULTIPOINT' " + "WHEN l.feature_type = 2 THEN 'MULTILINESTRING' " + "WHEN l.feature_type = 3 THEN 'MULTIPOLYGON' " + "WHEN l.feature_type = 4 THEN 'GEOMETRYCOLLECTION' " + "END AS type"; + sridName = QStringLiteral( "(SELECT srid FROM topology.topology t WHERE l.topology_id=t.id)" ); + dimName = QStringLiteral( "2" ); gtableName = QStringLiteral( "topology.layer" ); } else if ( i == SctPcPatch ) @@ -664,12 +651,12 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP if ( !hasPointcloud() ) continue; - tableName = QStringLiteral( "l.\"table\"" ); + tableName = QStringLiteral( "l.\"table\"" ); schemaName = QStringLiteral( "l.\"schema\"" ); columnName = QStringLiteral( "l.\"column\"" ); - typeName = QStringLiteral( "'POLYGON'" ); - sridName = QStringLiteral( "l.srid" ); - dimName = QStringLiteral( "2" ); + typeName = QStringLiteral( "'POLYGON'" ); + sridName = QStringLiteral( "l.srid" ); + dimName = QStringLiteral( "2" ); gtableName = QStringLiteral( "pointcloud_columns" ); } else if ( i == SctRaster ) @@ -677,18 +664,18 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP if ( !hasRaster() ) continue; - tableName = QStringLiteral( "l.\"r_table_name\"" ); + tableName = QStringLiteral( "l.\"r_table_name\"" ); schemaName = QStringLiteral( "l.\"r_table_schema\"" ); columnName = QStringLiteral( "l.\"r_raster_column\"" ); - typeName = QStringLiteral( "'RASTER'" ); - sridName = QStringLiteral( "l.srid" ); - dimName = QStringLiteral( "2" ); + typeName = QStringLiteral( "'RASTER'" ); + sridName = QStringLiteral( "l.srid" ); + dimName = QStringLiteral( "2" ); gtableName = QStringLiteral( "raster_columns" ); } else { QgsMessageLog::logMessage( tr( "Unsupported spatial column type %1" ) - .arg( displayStringForGeomType( ( QgsPostgresGeometryColumnType )i ) ) ); + .arg( displayStringForGeomType( ( QgsPostgresGeometryColumnType ) i ) ) ); continue; } @@ -708,12 +695,11 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP " AND n.oid=c.relnamespace" " AND has_schema_privilege(n.nspname,'usage')" " AND has_table_privilege(c.oid,'select')" // user has select privilege - ) - .arg( tableName, schemaName, columnName, typeName, sridName, dimName, gtableName ) - .arg( i ) - .arg( supportedSpatialTypes().join( ',' ) ) - .arg( mPostgresqlVersion >= 90000 ? "array_agg(a.attname ORDER BY a.attnum)" : "(SELECT array_agg(attname) FROM (SELECT unnest(array_agg(a.attname)) AS attname ORDER BY unnest(array_agg(a.attnum))) AS attname)" ) - ; + ) + .arg( tableName, schemaName, columnName, typeName, sridName, dimName, gtableName ) + .arg( i ) + .arg( supportedSpatialTypes().join( ',' ) ) + .arg( mPostgresqlVersion >= 90000 ? "array_agg(a.attname ORDER BY a.attnum)" : "(SELECT array_agg(attname) FROM (SELECT unnest(array_agg(a.attname)) AS attname ORDER BY unnest(array_agg(a.attnum))) AS attname)" ); if ( searchPublicOnly ) sql += QLatin1String( " AND n.nspname='public'" ); @@ -728,7 +714,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP foundInTables |= 1 << i; - if ( ! query.isEmpty() ) + if ( !query.isEmpty() ) query += " UNION "; query += sql; @@ -742,7 +728,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP // NOTE: we intentionally continue if the query fails // (for example because PostGIS is not installed) - if ( ! result.result() ) + if ( !result.result() ) { return false; } @@ -776,12 +762,12 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP else { QgsDebugError( QStringLiteral( "Unhandled columnType index %1" ) - . arg( columnTypeInt ) ); + .arg( columnTypeInt ) ); } int srid = ssrid.isEmpty() ? std::numeric_limits::min() : ssrid.toInt(); - if ( ! isRaster && majorVersion() >= 2 && srid == 0 ) + if ( !isRaster && majorVersion() >= 2 && srid == 0 ) { // 0 doesn't constraint => detect srid = std::numeric_limits::min(); @@ -825,7 +811,8 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP } if ( ( layerProperty.relKind == Qgis::PostgresRelKind::View - || layerProperty.relKind == Qgis::PostgresRelKind::MaterializedView ) && layerProperty.pkCols.empty() ) + || layerProperty.relKind == Qgis::PostgresRelKind::MaterializedView ) + && layerProperty.pkCols.empty() ) { //QgsDebugMsgLevel( QStringLiteral( "no key columns found." ), 2 ); continue; @@ -855,7 +842,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP " AND has_schema_privilege( n.nspname, 'usage' )" " AND has_table_privilege( c.oid, 'select' )" " AND (t.typname IN (%1) OR b.typname IN (%1))" ) - .arg( supportedSpatialTypes().join( ',' ) ); + .arg( supportedSpatialTypes().join( ',' ) ); // user has select privilege if ( searchPublicOnly ) @@ -899,14 +886,11 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP QgsDebugMsgLevel( "getting spatial table info from pg_catalog: " + sql, 2 ); - result = LoggedPQexec( QStringLiteral( "QgsPostgresConn" ), sql ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( tr( "Database connection was successful, but the accessible tables could not be determined. The error message from the database was:\n%1\n" ) - .arg( result.PQresultErrorMessage() ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Database connection was successful, but the accessible tables could not be determined. The error message from the database was:\n%1\n" ).arg( result.PQresultErrorMessage() ), tr( "PostGIS" ) ); LoggedPQexecNR( "QgsPostgresConn", QStringLiteral( "COMMIT" ) ); return false; } @@ -917,12 +901,12 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP // catalog doesn't exist in PostgreSQL so we ignore that, but we // do need to get the geometry type. - QString tableName = result.PQgetvalue( i, 0 ); // relname + QString tableName = result.PQgetvalue( i, 0 ); // relname QString schemaName = result.PQgetvalue( i, 1 ); // nspname - QString column = result.PQgetvalue( i, 2 ); // attname - QString relkind = result.PQgetvalue( i, 3 ); // relation kind - QString coltype = result.PQgetvalue( i, 4 ); // column type - QString comment = result.PQgetvalue( i, 5 ); // table comment + QString column = result.PQgetvalue( i, 2 ); // attname + QString relkind = result.PQgetvalue( i, 3 ); // relation kind + QString coltype = result.PQgetvalue( i, 4 ); // column type + QString comment = result.PQgetvalue( i, 5 ); // table comment QgsPostgresLayerProperty layerProperty; layerProperty.types = QList() << Qgis::WkbType::Unknown; @@ -945,8 +929,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP { layerProperty.geometryColType = SctTopoGeometry; } - else if ( coltype == QLatin1String( "pcpatch" ) || - coltype == QLatin1String( "pcpoint" ) ) + else if ( coltype == QLatin1String( "pcpatch" ) || coltype == QLatin1String( "pcpoint" ) ) { layerProperty.geometryColType = SctPcPatch; } @@ -961,13 +944,11 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP // TODO: use knowledge from already executed query to count // spatial fields and list attribute names... - addColumnInfo( layerProperty, schemaName, tableName, - layerProperty.relKind == Qgis::PostgresRelKind::View - || layerProperty.relKind == Qgis::PostgresRelKind::MaterializedView - || layerProperty.relKind == Qgis::PostgresRelKind::ForeignTable ); + addColumnInfo( layerProperty, schemaName, tableName, layerProperty.relKind == Qgis::PostgresRelKind::View || layerProperty.relKind == Qgis::PostgresRelKind::MaterializedView || layerProperty.relKind == Qgis::PostgresRelKind::ForeignTable ); if ( ( layerProperty.relKind == Qgis::PostgresRelKind::View - || layerProperty.relKind == Qgis::PostgresRelKind::MaterializedView ) && layerProperty.pkCols.empty() ) + || layerProperty.relKind == Qgis::PostgresRelKind::MaterializedView ) + && layerProperty.pkCols.empty() ) { //QgsDebugMsgLevel( QStringLiteral( "no key columns found." ), 2 ); continue; @@ -997,7 +978,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP " AND pg_class.oid = a.attrelid" " AND NOT a.attisdropped" " AND a.attnum > 0" ) - .arg( mPostgresqlVersion >= 90000 ? "array_agg(a.attname ORDER BY a.attnum)" : "(SELECT array_agg(attname) FROM (SELECT unnest(array_agg(a.attname)) AS attname ORDER BY unnest(array_agg(a.attnum))) AS attname)" ); + .arg( mPostgresqlVersion >= 90000 ? "array_agg(a.attname ORDER BY a.attnum)" : "(SELECT array_agg(attname) FROM (SELECT unnest(array_agg(a.attname)) AS attname ORDER BY unnest(array_agg(a.attnum))) AS attname)" ); // user has select privilege if ( searchPublicOnly ) @@ -1018,18 +999,16 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( tr( "Database connection was successful, but the accessible tables could not be determined.\nThe error message from the database was:\n%1" ) - .arg( result.PQresultErrorMessage() ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Database connection was successful, but the accessible tables could not be determined.\nThe error message from the database was:\n%1" ).arg( result.PQresultErrorMessage() ), tr( "PostGIS" ) ); return false; } for ( int i = 0; i < result.PQntuples(); i++ ) { - QString table = result.PQgetvalue( i, 0 ); // relname - QString schema = result.PQgetvalue( i, 1 ); // nspname - QString relkind = result.PQgetvalue( i, 2 ); // relation kind - QString comment = result.PQgetvalue( i, 3 ); // table comment + QString table = result.PQgetvalue( i, 0 ); // relname + QString schema = result.PQgetvalue( i, 1 ); // nspname + QString relkind = result.PQgetvalue( i, 2 ); // relation kind + QString comment = result.PQgetvalue( i, 3 ); // table comment QString attributes = result.PQgetvalue( i, 4 ); // attributes array QgsPostgresLayerProperty layerProperty; @@ -1207,9 +1186,7 @@ QString QgsPostgresConn::postgisVersion() const result = LoggedPQexec( QStringLiteral( "QgsPostgresConn" ), QStringLiteral( "SELECT postgis_geos_version(), postgis_proj_version()" ) ); mGeosAvailable = result.PQntuples() == 1 && !result.PQgetisnull( 0, 0 ); mProjAvailable = result.PQntuples() == 1 && !result.PQgetisnull( 0, 1 ); - QgsDebugMsgLevel( QStringLiteral( "geos:%1 proj:%2" ) - .arg( mGeosAvailable ? result.PQgetvalue( 0, 0 ) : "none" ) - .arg( mProjAvailable ? result.PQgetvalue( 0, 1 ) : "none" ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "geos:%1 proj:%2" ).arg( mGeosAvailable ? result.PQgetvalue( 0, 0 ) : "none" ).arg( mProjAvailable ? result.PQgetvalue( 0, 1 ) : "none" ), 2 ); } else { @@ -1230,16 +1207,16 @@ QString QgsPostgresConn::postgisVersion() const if ( mPostgisVersionMajor > 1 ) { const QString query = QStringLiteral( - "SELECT has_schema_privilege(n.oid, 'usage')" - " AND has_table_privilege(t.oid, 'select')" - " AND has_table_privilege(l.oid, 'select')" - " FROM pg_namespace n, pg_class t, pg_class l" - " WHERE n.nspname = 'topology'" - " AND t.relnamespace = n.oid" - " AND l.relnamespace = n.oid" - " AND t.relname = 'topology'" - " AND l.relname = 'layer'" - ); + "SELECT has_schema_privilege(n.oid, 'usage')" + " AND has_table_privilege(t.oid, 'select')" + " AND has_table_privilege(l.oid, 'select')" + " FROM pg_namespace n, pg_class t, pg_class l" + " WHERE n.nspname = 'topology'" + " AND t.relnamespace = n.oid" + " AND l.relnamespace = n.oid" + " AND t.relname = 'topology'" + " AND l.relname = 'layer'" + ); QgsPostgresResult result( LoggedPQexec( QStringLiteral( "QgsPostgresConn" ), query ) ); if ( result.PQntuples() >= 1 && result.PQgetvalue( 0, 0 ) == QLatin1String( "t" ) ) { @@ -1261,17 +1238,15 @@ QString QgsPostgresConn::postgisVersion() const if ( mPostgresqlVersion >= 90000 ) { QgsDebugMsgLevel( QStringLiteral( "Checking for pointcloud support" ), 2 ); - result = LoggedPQexecNoLogError( QStringLiteral( "QgsPostgresConn" ), QStringLiteral( - "SELECT has_table_privilege(c.oid, 'select')" - " AND has_table_privilege(f.oid, 'select')" - " FROM pg_class c, pg_class f, pg_namespace n, pg_extension e" - " WHERE c.relnamespace = n.oid" - " AND c.relname = 'pointcloud_columns'" - " AND f.relnamespace = n.oid" - " AND f.relname = 'pointcloud_formats'" - " AND n.oid = e.extnamespace" - " AND e.extname = 'pointcloud'" - ) ); + result = LoggedPQexecNoLogError( QStringLiteral( "QgsPostgresConn" ), QStringLiteral( "SELECT has_table_privilege(c.oid, 'select')" + " AND has_table_privilege(f.oid, 'select')" + " FROM pg_class c, pg_class f, pg_namespace n, pg_extension e" + " WHERE c.relnamespace = n.oid" + " AND c.relname = 'pointcloud_columns'" + " AND f.relnamespace = n.oid" + " AND f.relname = 'pointcloud_formats'" + " AND n.oid = e.extnamespace" + " AND e.extname = 'pointcloud'" ) ); if ( result.PQntuples() >= 1 && result.PQgetvalue( 0, 0 ) == QLatin1String( "t" ) ) { mPointcloudAvailable = true; @@ -1282,14 +1257,12 @@ QString QgsPostgresConn::postgisVersion() const QgsDebugMsgLevel( QStringLiteral( "Checking for raster support" ), 2 ); if ( mPostgisVersionMajor >= 2 ) { - result = LoggedPQexecNoLogError( QStringLiteral( "QgsPostgresConn" ), QStringLiteral( - "SELECT has_table_privilege(c.oid, 'select')" - " FROM pg_class c, pg_namespace n, pg_type t" - " WHERE c.relnamespace = n.oid" - " AND n.oid = t.typnamespace" - " AND c.relname = 'raster_columns'" - " AND t.typname = 'raster'" - ) ); + result = LoggedPQexecNoLogError( QStringLiteral( "QgsPostgresConn" ), QStringLiteral( "SELECT has_table_privilege(c.oid, 'select')" + " FROM pg_class c, pg_namespace n, pg_type t" + " WHERE c.relnamespace = n.oid" + " AND n.oid = t.typnamespace" + " AND c.relname = 'raster_columns'" + " AND t.typname = 'raster'" ) ); if ( result.PQntuples() >= 1 && result.PQgetvalue( 0, 0 ) == QLatin1String( "t" ) ) { mRasterAvailable = true; @@ -1367,8 +1340,7 @@ static QString quotedMap( const QVariantMap &map ) { ret += QLatin1Char( ',' ); } - ret.append( doubleQuotedMapValue( i.key() ) + "=>" + - doubleQuotedMapValue( i.value().toString() ) ); + ret.append( doubleQuotedMapValue( i.key() ) + "=>" + doubleQuotedMapValue( i.value().toString() ) ); } return "E'" + ret + "'::hstore"; } @@ -1523,7 +1495,9 @@ PGresult *QgsPostgresConn::PQexec( const QString &query, bool logError, bool ret if ( errorStatus != PGRES_COMMAND_OK && errorStatus != PGRES_TUPLES_OK ) { const QString error { tr( "Erroneous query: %1 returned %2 [%3]" ) - .arg( query ).arg( errorStatus ).arg( PQresultErrorMessage( res ) ) }; + .arg( query ) + .arg( errorStatus ) + .arg( PQresultErrorMessage( res ) ) }; logWrapper->setError( error ); if ( logError ) @@ -1533,7 +1507,9 @@ PGresult *QgsPostgresConn::PQexec( const QString &query, bool logError, bool ret else { QgsDebugError( QStringLiteral( "Not logged erroneous query: %1 returned %2 [%3]" ) - .arg( query ).arg( errorStatus ).arg( PQresultErrorMessage( res ) ) ); + .arg( query ) + .arg( errorStatus ) + .arg( PQresultErrorMessage( res ) ) ); } } logWrapper->setFetchedRows( PQntuples( res ) ); @@ -1542,17 +1518,20 @@ PGresult *QgsPostgresConn::PQexec( const QString &query, bool logError, bool ret if ( PQstatus() != CONNECTION_OK ) { const QString error { tr( "Connection error: %1 returned %2 [%3]" ) - .arg( query ).arg( PQstatus() ).arg( PQerrorMessage() ) }; + .arg( query ) + .arg( PQstatus() ) + .arg( PQerrorMessage() ) }; logWrapper->setError( error ); if ( logError ) { - QgsMessageLog::logMessage( error, - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( error, tr( "PostGIS" ) ); } else { QgsDebugError( QStringLiteral( "Connection error: %1 returned %2 [%3]" ) - .arg( query ).arg( PQstatus() ).arg( PQerrorMessage() ) ); + .arg( query ) + .arg( PQstatus() ) + .arg( PQerrorMessage() ) ); } } else @@ -1602,19 +1581,18 @@ PGresult *QgsPostgresConn::PQexec( const QString &query, bool logError, bool ret QgsMessageLog::logMessage( tr( "bad connection, not retrying." ), tr( "PostGIS" ) ); } return nullptr; - } int QgsPostgresConn::PQCancel() { // No locker: this is supposed to be thread safe int result = 0; - auto cancel = ::PQgetCancel( mConn ) ; + auto cancel = ::PQgetCancel( mConn ); if ( cancel ) { char errbuf[255]; result = ::PQcancel( cancel, errbuf, 255 ); - if ( ! result ) + if ( !result ) QgsDebugMsgLevel( QStringLiteral( "Error canceling the query:" ).arg( errbuf ), 3 ); } ::PQfreeCancel( cancel ); @@ -1635,8 +1613,7 @@ bool QgsPostgresConn::openCursor( const QString &cursorName, const QString &sql preStr = QStringLiteral( "BEGIN;" ); } QgsDebugMsgLevel( QStringLiteral( "Binary cursor %1 for %2" ).arg( cursorName, sql ), 3 ); - return LoggedPQexecNR( "QgsPostgresConn", QStringLiteral( "%1DECLARE %2 BINARY CURSOR%3 FOR %4" ). - arg( preStr, cursorName, !mTransaction ? QString() : QStringLiteral( " WITH HOLD" ), sql ) ); + return LoggedPQexecNR( "QgsPostgresConn", QStringLiteral( "%1DECLARE %2 BINARY CURSOR%3 FOR %4" ).arg( preStr, cursorName, !mTransaction ? QString() : QStringLiteral( " WITH HOLD" ), sql ) ); } bool QgsPostgresConn::closeCursor( const QString &cursorName ) @@ -1671,17 +1648,11 @@ bool QgsPostgresConn::PQexecNR( const QString &query, const QString &originatorC if ( errorStatus == PGRES_COMMAND_OK ) return true; - QgsMessageLog::logMessage( tr( "Query: %1 returned %2 [%3]" ) - .arg( query ) - .arg( errorStatus ) - .arg( res.PQresultErrorMessage() ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Query: %1 returned %2 [%3]" ).arg( query ).arg( errorStatus ).arg( res.PQresultErrorMessage() ), tr( "PostGIS" ) ); if ( mOpenCursors ) { - QgsMessageLog::logMessage( tr( "%1 cursor states lost.\nSQL: %2\nResult: %3 (%4)" ) - .arg( mOpenCursors ).arg( query ).arg( errorStatus ) - .arg( res.PQresultErrorMessage() ), tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "%1 cursor states lost.\nSQL: %2\nResult: %3 (%4)" ).arg( mOpenCursors ).arg( query ).arg( errorStatus ).arg( res.PQresultErrorMessage() ), tr( "PostGIS" ) ); mOpenCursors = 0; } @@ -1720,7 +1691,7 @@ PGresult *QgsPostgresConn::PQexecPrepared( const QString &stmtName, const QStrin { QMutexLocker locker( &mLock ); - const char **param = new const char *[ params.size()]; + const char **param = new const char *[params.size()]; QList qparam; qparam.reserve( params.size() ); @@ -1745,7 +1716,7 @@ PGresult *QgsPostgresConn::PQexecPrepared( const QString &stmtName, const QStrin logWrapper->setError( PQresultErrorMessage( res ) ); } - delete [] param; + delete[] param; return res; } @@ -1835,7 +1806,7 @@ qint64 QgsPostgresConn::getBinaryInt( QgsPostgresResult &queryResult, int row, i QString buf; for ( size_t i = 0; i < s; i++ ) { - buf += QStringLiteral( "%1 " ).arg( *( unsigned char * )( p + i ), 0, 16, QLatin1Char( ' ' ) ); + buf += QStringLiteral( "%1 " ).arg( *( unsigned char * ) ( p + i ), 0, 16, QLatin1Char( ' ' ) ); } QgsDebugMsgLevel( QStringLiteral( "int in hex:%1" ).arg( buf ), 2 ); @@ -1845,18 +1816,18 @@ qint64 QgsPostgresConn::getBinaryInt( QgsPostgresResult &queryResult, int row, i switch ( s ) { case 2: - oid = *( quint16 * )p; + oid = *( quint16 * ) p; if ( mSwapEndian ) oid = ntohs( oid ); /* cast to signed 16bit * See https://github.com/qgis/QGIS/issues/22258 */ - oid = ( qint16 )oid; + oid = ( qint16 ) oid; break; case 6: { - quint64 block = *( quint32 * ) p; - quint64 offset = *( quint16 * )( p + sizeof( quint32 ) ); + quint64 block = *( quint32 * ) p; + quint64 offset = *( quint16 * ) ( p + sizeof( quint32 ) ); if ( mSwapEndian ) { @@ -1871,7 +1842,7 @@ qint64 QgsPostgresConn::getBinaryInt( QgsPostgresResult &queryResult, int row, i case 8: { quint32 oid0 = *( quint32 * ) p; - quint32 oid1 = *( quint32 * )( p + sizeof( quint32 ) ); + quint32 oid1 = *( quint32 * ) ( p + sizeof( quint32 ) ); if ( mSwapEndian ) { @@ -1881,11 +1852,11 @@ qint64 QgsPostgresConn::getBinaryInt( QgsPostgresResult &queryResult, int row, i } QgsDebugMsgLevel( QStringLiteral( "oid0:%1 oid1:%2" ).arg( oid0 ).arg( oid1 ), 4 ); - oid = oid0; + oid = oid0; QgsDebugMsgLevel( QStringLiteral( "oid:%1" ).arg( oid ), 4 ); oid <<= 32; QgsDebugMsgLevel( QStringLiteral( "oid:%1" ).arg( oid ), 4 ); - oid |= oid1; + oid |= oid1; QgsDebugMsgLevel( QStringLiteral( "oid:%1" ).arg( oid ), 4 ); } break; @@ -1895,12 +1866,12 @@ qint64 QgsPostgresConn::getBinaryInt( QgsPostgresResult &queryResult, int row, i //intentional fall-through [[fallthrough]]; case 4: - oid = *( quint32 * )p; + oid = *( quint32 * ) p; if ( mSwapEndian ) oid = ntohl( oid ); /* cast to signed 32bit * See https://github.com/qgis/QGIS/issues/22258 */ - oid = ( qint32 )oid; + oid = ( qint32 ) oid; break; } @@ -1916,20 +1887,20 @@ QString QgsPostgresConn::fieldExpressionForWhereClause( const QgsField &fld, QMe { out = expr.arg( quotedIdentifier( fld.name() ) ); // if field and value havev incompatible types, rollback to text cast - if ( valueType != QMetaType::Type::UnknownType && valueType != QMetaType::Type::QDateTime && valueType != QMetaType::Type::QDate && valueType != QMetaType::Type::QTime ) + if ( valueType != QMetaType::Type::UnknownType && valueType != QMetaType::Type::QDateTime && valueType != QMetaType::Type::QDate && valueType != QMetaType::Type::QTime ) { out = out + "::text"; } } - else if ( type == QLatin1String( "int8" ) || type == QLatin1String( "serial8" ) // - || type == QLatin1String( "int2" ) || type == QLatin1String( "int4" ) || type == QLatin1String( "oid" ) || type == QLatin1String( "serial" ) // + else if ( type == QLatin1String( "int8" ) || type == QLatin1String( "serial8" ) // + || type == QLatin1String( "int2" ) || type == QLatin1String( "int4" ) || type == QLatin1String( "oid" ) || type == QLatin1String( "serial" ) // || type == QLatin1String( "real" ) || type == QLatin1String( "double precision" ) || type == QLatin1String( "float4" ) || type == QLatin1String( "float8" ) // || type == QLatin1String( "numeric" ) ) { out = expr.arg( quotedIdentifier( fld.name() ) ); // if field and value havev incompatible types, rollback to text cast - if ( valueType != QMetaType::Type::UnknownType && valueType != QMetaType::Type::Int && valueType != QMetaType::Type::LongLong && valueType != QMetaType::Type::Double ) + if ( valueType != QMetaType::Type::UnknownType && valueType != QMetaType::Type::Int && valueType != QMetaType::Type::LongLong && valueType != QMetaType::Type::Double ) { out = out + "::text"; } @@ -1963,8 +1934,7 @@ QString QgsPostgresConn::fieldExpression( const QgsField &fld, QString expr ) else if ( type == QLatin1String( "geometry" ) ) { return QStringLiteral( "%1(%2)" ) - .arg( majorVersion() < 2 ? "asewkt" : "st_asewkt", - expr ); + .arg( majorVersion() < 2 ? "asewkt" : "st_asewkt", expr ); } else if ( type == QLatin1String( "geography" ) ) { @@ -1986,41 +1956,40 @@ QList QgsPostgresConn::nativeTypes() { QList types; - types // integer types - << QgsVectorDataProvider::NativeType( tr( "Whole Number (smallint - 16bit)" ), QStringLiteral( "int2" ), QMetaType::Type::Int, -1, -1, 0, 0 ) - << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 32bit)" ), QStringLiteral( "int4" ), QMetaType::Type::Int, -1, -1, 0, 0 ) - << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 64bit)" ), QStringLiteral( "int8" ), QMetaType::Type::LongLong, -1, -1, 0, 0 ) - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (numeric)" ), QStringLiteral( "numeric" ), QMetaType::Type::Double, 1, 20, 0, 20 ) - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (decimal)" ), QStringLiteral( "decimal" ), QMetaType::Type::Double, 1, 20, 0, 20 ) - - // floating point - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (real)" ), QStringLiteral( "real" ), QMetaType::Type::Double, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Decimal Number (double)" ), QStringLiteral( "double precision" ), QMetaType::Type::Double, -1, -1, -1, -1 ) - - // string types - << QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), QStringLiteral( "char" ), QMetaType::Type::QString, 1, 255, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), QStringLiteral( "varchar" ), QMetaType::Type::QString, 1, 255, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QMetaType::Type::QString, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( tr( "Text, case-insensitive unlimited length (citext)" ), QStringLiteral( "citext" ), QMetaType::Type::QString, -1, -1, -1, -1 ) - - // date type - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDate ), QStringLiteral( "date" ), QMetaType::Type::QDate, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QTime ), QStringLiteral( "time" ), QMetaType::Type::QTime, -1, -1, -1, -1 ) - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDateTime ), QStringLiteral( "timestamp without time zone" ), QMetaType::Type::QDateTime, -1, -1, -1, -1 ) - - // complex types - << QgsVectorDataProvider::NativeType( tr( "Map (hstore)" ), QStringLiteral( "hstore" ), QMetaType::Type::QVariantMap, -1, -1, -1, -1, QMetaType::Type::QString ) - << QgsVectorDataProvider::NativeType( tr( "Array of Number (integer - 32bit)" ), QStringLiteral( "int4[]" ), QMetaType::Type::QVariantList, -1, -1, -1, -1, QMetaType::Type::Int ) - << QgsVectorDataProvider::NativeType( tr( "Array of Number (integer - 64bit)" ), QStringLiteral( "int8[]" ), QMetaType::Type::QVariantList, -1, -1, -1, -1, QMetaType::Type::LongLong ) - << QgsVectorDataProvider::NativeType( tr( "Array of Number (double)" ), QStringLiteral( "double precision[]" ), QMetaType::Type::QVariantList, -1, -1, -1, -1, QMetaType::Type::Double ) - << QgsVectorDataProvider::NativeType( tr( "Array of Text" ), QStringLiteral( "text[]" ), QMetaType::Type::QStringList, -1, -1, -1, -1, QMetaType::Type::QString ) - - // boolean - << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Bool ), QStringLiteral( "bool" ), QMetaType::Type::Bool, -1, -1, -1, -1 ) - - // binary (bytea) - << QgsVectorDataProvider::NativeType( tr( "Binary Object (bytea)" ), QStringLiteral( "bytea" ), QMetaType::Type::QByteArray, -1, -1, -1, -1 ) - ; + types // integer types + << QgsVectorDataProvider::NativeType( tr( "Whole Number (smallint - 16bit)" ), QStringLiteral( "int2" ), QMetaType::Type::Int, -1, -1, 0, 0 ) + << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 32bit)" ), QStringLiteral( "int4" ), QMetaType::Type::Int, -1, -1, 0, 0 ) + << QgsVectorDataProvider::NativeType( tr( "Whole Number (integer - 64bit)" ), QStringLiteral( "int8" ), QMetaType::Type::LongLong, -1, -1, 0, 0 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (numeric)" ), QStringLiteral( "numeric" ), QMetaType::Type::Double, 1, 20, 0, 20 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (decimal)" ), QStringLiteral( "decimal" ), QMetaType::Type::Double, 1, 20, 0, 20 ) + + // floating point + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (real)" ), QStringLiteral( "real" ), QMetaType::Type::Double, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Decimal Number (double)" ), QStringLiteral( "double precision" ), QMetaType::Type::Double, -1, -1, -1, -1 ) + + // string types + << QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), QStringLiteral( "char" ), QMetaType::Type::QString, 1, 255, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), QStringLiteral( "varchar" ), QMetaType::Type::QString, 1, 255, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QMetaType::Type::QString, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( tr( "Text, case-insensitive unlimited length (citext)" ), QStringLiteral( "citext" ), QMetaType::Type::QString, -1, -1, -1, -1 ) + + // date type + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDate ), QStringLiteral( "date" ), QMetaType::Type::QDate, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QTime ), QStringLiteral( "time" ), QMetaType::Type::QTime, -1, -1, -1, -1 ) + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::QDateTime ), QStringLiteral( "timestamp without time zone" ), QMetaType::Type::QDateTime, -1, -1, -1, -1 ) + + // complex types + << QgsVectorDataProvider::NativeType( tr( "Map (hstore)" ), QStringLiteral( "hstore" ), QMetaType::Type::QVariantMap, -1, -1, -1, -1, QMetaType::Type::QString ) + << QgsVectorDataProvider::NativeType( tr( "Array of Number (integer - 32bit)" ), QStringLiteral( "int4[]" ), QMetaType::Type::QVariantList, -1, -1, -1, -1, QMetaType::Type::Int ) + << QgsVectorDataProvider::NativeType( tr( "Array of Number (integer - 64bit)" ), QStringLiteral( "int8[]" ), QMetaType::Type::QVariantList, -1, -1, -1, -1, QMetaType::Type::LongLong ) + << QgsVectorDataProvider::NativeType( tr( "Array of Number (double)" ), QStringLiteral( "double precision[]" ), QMetaType::Type::QVariantList, -1, -1, -1, -1, QMetaType::Type::Double ) + << QgsVectorDataProvider::NativeType( tr( "Array of Text" ), QStringLiteral( "text[]" ), QMetaType::Type::QStringList, -1, -1, -1, -1, QMetaType::Type::QString ) + + // boolean + << QgsVectorDataProvider::NativeType( QgsVariantUtils::typeToDisplayString( QMetaType::Type::Bool ), QStringLiteral( "bool" ), QMetaType::Type::Bool, -1, -1, -1, -1 ) + + // binary (bytea) + << QgsVectorDataProvider::NativeType( tr( "Binary Object (bytea)" ), QStringLiteral( "bytea" ), QMetaType::Type::QByteArray, -1, -1, -1, -1 ); if ( pgVersion() >= 90200 ) { @@ -2053,13 +2022,12 @@ void QgsPostgresConn::deduceEndian() qint64 oidSelect = 0; qint64 oidBinaryCursor = 0; - if ( 0 == PQsendQuery( QStringLiteral( - "SELECT regclass('pg_class')::oid AS oidselect;" - "BEGIN;" - "DECLARE oidcursor BINARY CURSOR FOR SELECT regclass('pg_class')::oid AS oidbinarycursor;" - "FETCH FORWARD 1 FROM oidcursor;" - "CLOSE oidcursor;" - "COMMIT;" ) ) ) + if ( 0 == PQsendQuery( QStringLiteral( "SELECT regclass('pg_class')::oid AS oidselect;" + "BEGIN;" + "DECLARE oidcursor BINARY CURSOR FOR SELECT regclass('pg_class')::oid AS oidbinarycursor;" + "FETCH FORWARD 1 FROM oidcursor;" + "CLOSE oidcursor;" + "COMMIT;" ) ) ) QgsDebugMsgLevel( QStringLiteral( "PQsendQuery(...) error %1" ).arg( PQerrorMessage() ), 2 ); for ( ;; ) @@ -2076,9 +2044,7 @@ void QgsPostgresConn::deduceEndian() if ( resOID.PQresultStatus() == PGRES_FATAL_ERROR ) { errorCounter++; - QgsDebugMsgLevel( QStringLiteral( "QUERY #%1 PGRES_FATAL_ERROR %2" ) - .arg( queryCounter ) - .arg( PQerrorMessage().trimmed() ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "QUERY #%1 PGRES_FATAL_ERROR %2" ).arg( queryCounter ).arg( PQerrorMessage().trimmed() ), 2 ); continue; } @@ -2103,10 +2069,7 @@ void QgsPostgresConn::deduceEndian() return; } - QgsDebugMsgLevel( QStringLiteral( "Back to old deduceEndian(): PQstatus() - %1, queryCounter = %2, errorCounter = %3" ) - .arg( PQstatus() ) - .arg( queryCounter ) - .arg( errorCounter ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Back to old deduceEndian(): PQstatus() - %1, queryCounter = %2, errorCounter = %3" ).arg( PQstatus() ).arg( queryCounter ).arg( errorCounter ), 2 ); QgsPostgresResult res( LoggedPQexec( QStringLiteral( "QgsPostgresConn" ), QStringLiteral( "select regclass('pg_class')::oid" ) ) ); QString oidValue = res.PQgetvalue( 0, 0 ); @@ -2163,8 +2126,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l if ( !layerProperty.schemaName.isEmpty() ) { table = QStringLiteral( "%1.%2" ) - .arg( quotedIdentifier( layerProperty.schemaName ), - quotedIdentifier( layerProperty.tableName ) ); + .arg( quotedIdentifier( layerProperty.schemaName ), quotedIdentifier( layerProperty.tableName ) ); } else { @@ -2184,8 +2146,8 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l if ( srid != std::numeric_limits::min() ) { sql += QStringLiteral( "SELECT %1, array_agg( '%2:RASTER:-1'::text )" ) - .arg( i - 1 ) - .arg( srid ); + .arg( i - 1 ) + .arg( srid ); } else { @@ -2195,10 +2157,10 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l "array_agg(srid || ':RASTER:-1') " "FROM raster_columns " "WHERE r_raster_column = %2 AND r_table_schema = %3 AND r_table_name = %4" ) - .arg( i - 1 ) - .arg( quotedValue( layerProperty.geometryColName ) ) - .arg( quotedValue( layerProperty.schemaName ) ) - .arg( quotedValue( layerProperty.tableName ) ); + .arg( i - 1 ) + .arg( quotedValue( layerProperty.geometryColName ) ) + .arg( quotedValue( layerProperty.schemaName ) ) + .arg( quotedValue( layerProperty.tableName ) ); } else { @@ -2206,29 +2168,27 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l "array_agg(DISTINCT st_srid(%2) || ':RASTER:-1') " "FROM %3 " "WHERE %2 IS NOT NULL " - "%4" // SQL clause + "%4" // SQL clause "%5" ) - .arg( i - 1 ) - .arg( quotedIdentifier( layerProperty.geometryColName ) ) - .arg( table ) - .arg( layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " AND %1" ).arg( layerProperty.sql ) ) - .arg( tableScanLimit ); + .arg( i - 1 ) + .arg( quotedIdentifier( layerProperty.geometryColName ) ) + .arg( table ) + .arg( layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " AND %1" ).arg( layerProperty.sql ) ) + .arg( tableScanLimit ); } } QgsDebugMsgLevel( "Raster srids query: " + sql, 2 ); query += sql; } - else // vectors + else // vectors { // our estimation ignores that a where clause might restrict the feature type or srid if ( useEstimatedMetadata ) { table = QStringLiteral( "(SELECT %1 FROM %2 WHERE %3%1 IS NOT NULL%4) AS t" ) - .arg( quotedIdentifier( layerProperty.geometryColName ), - table, - layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " (%1) AND " ).arg( layerProperty.sql ) ) - .arg( tableScanLimit ); + .arg( quotedIdentifier( layerProperty.geometryColName ), table, layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " (%1) AND " ).arg( layerProperty.sql ) ) + .arg( tableScanLimit ); } else if ( !layerProperty.sql.isEmpty() ) { @@ -2237,8 +2197,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l QString sql = QStringLiteral( "SELECT %1, " ).arg( i - 1 ); - bool castToGeometry = layerProperty.geometryColType == SctGeography || - layerProperty.geometryColType == SctPcPatch; + bool castToGeometry = layerProperty.geometryColType == SctGeography || layerProperty.geometryColType == SctPcPatch; sql += QLatin1String( "array_agg(DISTINCT " ); @@ -2246,14 +2205,12 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l if ( srid == std::numeric_limits::min() ) { sql += QStringLiteral( "%1(%2%3)::text" ) - .arg( majorVersion() < 2 ? "srid" : "st_srid", - quotedIdentifier( layerProperty.geometryColName ), - castToGeometry ? "::geometry" : "" ); + .arg( majorVersion() < 2 ? "srid" : "st_srid", quotedIdentifier( layerProperty.geometryColName ), castToGeometry ? "::geometry" : "" ); } else { sql += QStringLiteral( "%1::text" ) - .arg( QString::number( srid ) ); + .arg( QString::number( srid ) ); } sql += " || ':' || "; @@ -2267,13 +2224,12 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l // So we have to do a subselect on the table to add the LIMIT, // see comment in the following code. sql += QStringLiteral( "UPPER(geometrytype(%1%2)) || ':' || ST_Zmflag(%1%2)" ) - .arg( quotedIdentifier( layerProperty.geometryColName ), - castToGeometry ? "::geometry" : "" ); + .arg( quotedIdentifier( layerProperty.geometryColName ), castToGeometry ? "::geometry" : "" ); } else { sql += QStringLiteral( "%1::text || ':-1'" ) - .arg( quotedValue( QgsPostgresConn::postgisWkbTypeName( type ) ) ); + .arg( quotedValue( QgsPostgresConn::postgisWkbTypeName( type ) ) ); } @@ -2283,9 +2239,9 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l { // Subselect to limit the "array_agg(DISTINCT", see previous comment. sql += QStringLiteral( " FROM (SELECT %1 FROM %2%3) AS _unused" ) - .arg( quotedIdentifier( layerProperty.geometryColName ) ) - .arg( table ) - .arg( tableScanLimit ); + .arg( quotedIdentifier( layerProperty.geometryColName ) ) + .arg( table ) + .arg( tableScanLimit ); } else { @@ -2316,33 +2272,20 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l auto srids_and_types = QgsPostgresStringUtils::parseArray( res.PQgetvalue( i, 1 ) ); QgsPostgresLayerProperty &layerProperty = *layerProperties[idx]; - QgsDebugMsgLevel( QStringLiteral( - "Layer %1.%2.%3 has %4 srid/type combinations" - ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( srids_and_types.length() ) - , 3 - ); + QgsDebugMsgLevel( QStringLiteral( "Layer %1.%2.%3 has %4 srid/type combinations" ).arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ).arg( srids_and_types.length() ), 3 ); /* Gather found types */ - QList< std::pair > foundCombinations; + QList> foundCombinations; for ( const auto &sridAndTypeVariant : srids_and_types ) { QString sridAndTypeString = sridAndTypeVariant.toString(); - QgsDebugMsgLevel( QStringLiteral( - "Analyzing layer's %1.%2.%3 sridAndType %4" - " against %6 found combinations" - ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( sridAndTypeString ) - .arg( foundCombinations.length() ) - , 3 - ); + QgsDebugMsgLevel( QStringLiteral( "Analyzing layer's %1.%2.%3 sridAndType %4" + " against %6 found combinations" ) + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) + .arg( sridAndTypeString ) + .arg( foundCombinations.length() ), + 3 ); if ( sridAndTypeString == "NULL" ) continue; @@ -2403,43 +2346,34 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l if ( multiCurveType == knownMultiCurveType ) { - QgsDebugMsgLevel( QStringLiteral( - "Upgrading type[%1] of layer %2.%3.%4 " - "to multiCurved type %5" ) - .arg( j ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( qgsEnumValueToKey( multiCurveType ) ), 3 - ); + QgsDebugMsgLevel( QStringLiteral( "Upgrading type[%1] of layer %2.%3.%4 " + "to multiCurved type %5" ) + .arg( j ) + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) + .arg( qgsEnumValueToKey( multiCurveType ) ), + 3 ); foundCombinations[j].first = multiCurveType; break; } else if ( multiType == knownMultiType ) { - QgsDebugMsgLevel( QStringLiteral( - "Upgrading type[%1] of layer %2.%3.%4 " - "to multi type %5" ) - .arg( j ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( qgsEnumValueToKey( multiType ) ), 3 - ); + QgsDebugMsgLevel( QStringLiteral( "Upgrading type[%1] of layer %2.%3.%4 " + "to multi type %5" ) + .arg( j ) + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) + .arg( qgsEnumValueToKey( multiType ) ), + 3 ); foundCombinations[j].first = multiType; break; } else if ( curveType == knownCurveType ) { - QgsDebugMsgLevel( QStringLiteral( - "Upgrading type[%1] of layer %2.%3.%4 " - "to curved type %5" ) - .arg( j ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( qgsEnumValueToKey( multiType ) ), 3 - ); + QgsDebugMsgLevel( QStringLiteral( "Upgrading type[%1] of layer %2.%3.%4 " + "to curved type %5" ) + .arg( j ) + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) + .arg( qgsEnumValueToKey( multiType ) ), + 3 ); foundCombinations[j].first = curveType; break; } @@ -2447,40 +2381,31 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l if ( j < foundCombinations.length() ) { - QgsDebugMsgLevel( QStringLiteral( - "Pre-existing compatible combination %1/%2 " - "found for layer %3.%4.%5 " - ) - .arg( j ) .arg( foundCombinations.length() ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ), 3 - ); + QgsDebugMsgLevel( QStringLiteral( "Pre-existing compatible combination %1/%2 " + "found for layer %3.%4.%5 " ) + .arg( j ) + .arg( foundCombinations.length() ) + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ), + 3 ); continue; // already found } - QgsDebugMsgLevel( QStringLiteral( - "Setting typeSridCombination[%1] of layer %2.%3.%4 " - "to srid %5 and type %6" ) - .arg( j ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( srid ) - .arg( qgsEnumValueToKey( type ) ), 3 - ); + QgsDebugMsgLevel( QStringLiteral( "Setting typeSridCombination[%1] of layer %2.%3.%4 " + "to srid %5 and type %6" ) + .arg( j ) + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) + .arg( srid ) + .arg( qgsEnumValueToKey( type ) ), + 3 ); foundCombinations << std::make_pair( type, srid ); } - QgsDebugMsgLevel( QStringLiteral( - "Completed scan of %1 srid/type combinations " - "for layer of layer %2.%3.%4 " ) - .arg( srids_and_types.length() ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ), 2 - ); + QgsDebugMsgLevel( QStringLiteral( "Completed scan of %1 srid/type combinations " + "for layer of layer %2.%3.%4 " ) + .arg( srids_and_types.length() ) + .arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ), + 2 ); /* Rewrite srids and types to match found combinations * of srids and types */ @@ -2491,20 +2416,8 @@ void QgsPostgresConn::retrieveLayerTypes( QVector &l layerProperty.types << comb.first; layerProperty.srids << comb.second; } - QgsDebugMsgLevel( QStringLiteral( - "Final layer %1.%2.%3 types: %4" ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( layerProperty.types.length() ), 2 - ); - QgsDebugMsgLevel( QStringLiteral( - "Final layer %1.%2.%3 srids: %4" ) - .arg( layerProperty.schemaName, - layerProperty.tableName, - layerProperty.geometryColName ) - .arg( layerProperty.srids.length() ), 2 - ); + QgsDebugMsgLevel( QStringLiteral( "Final layer %1.%2.%3 types: %4" ).arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ).arg( layerProperty.types.length() ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Final layer %1.%2.%3 srids: %4" ).arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ).arg( layerProperty.srids.length() ), 2 ); } } @@ -2885,8 +2798,7 @@ bool QgsPostgresConn::cancel() PGcancel *c = ::PQgetCancel( mConn ); if ( !c ) { - QgsMessageLog::logMessage( tr( "Query could not be canceled [%1]" ).arg( tr( "PQgetCancel failed" ) ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Query could not be canceled [%1]" ).arg( tr( "PQgetCancel failed" ) ), tr( "PostGIS" ) ); return false; } diff --git a/src/providers/postgres/qgspostgresconn.h b/src/providers/postgres/qgspostgresconn.h index 28575d8db4bd..ea38d2806626 100644 --- a/src/providers/postgres/qgspostgresconn.h +++ b/src/providers/postgres/qgspostgresconn.h @@ -63,9 +63,9 @@ enum QgsPostgresPrimaryKeyType //! Schema properties structure struct QgsPostgresSchemaProperty { - QString name; - QString description; - QString owner; + QString name; + QString description; + QString owner; }; @@ -73,89 +73,89 @@ struct QgsPostgresSchemaProperty // TODO: Fill to Postgres/PostGIS specifications struct QgsPostgresLayerProperty { - // Postgres/PostGIS layer properties - QList types; - QString schemaName; - QString tableName; - QString geometryColName; - QgsPostgresGeometryColumnType geometryColType; - QStringList pkCols; - QList srids; - unsigned int nSpCols; - QString sql; - Qgis::PostgresRelKind relKind = Qgis::PostgresRelKind::Unknown; - bool isRaster = false; - QString tableComment; - - // TODO: rename this ! - int size() const { Q_ASSERT( types.size() == srids.size() ); return types.size(); } - - QString defaultName() const - { - QString n = tableName; - if ( nSpCols > 1 ) n += '.' + geometryColName; - return n; - } - - QgsPostgresLayerProperty at( int i ) const - { - QgsPostgresLayerProperty property; - - Q_ASSERT( i >= 0 && i < size() ); - - property.types << types[ i ]; - property.srids << srids[ i ]; - property.schemaName = schemaName; - property.tableName = tableName; - property.geometryColName = geometryColName; - property.geometryColType = geometryColType; - property.pkCols = pkCols; - property.nSpCols = nSpCols; - property.sql = sql; - property.relKind = relKind; - property.isRaster = isRaster; - property.tableComment = tableComment; - - return property; - } + // Postgres/PostGIS layer properties + QList types; + QString schemaName; + QString tableName; + QString geometryColName; + QgsPostgresGeometryColumnType geometryColType; + QStringList pkCols; + QList srids; + unsigned int nSpCols; + QString sql; + Qgis::PostgresRelKind relKind = Qgis::PostgresRelKind::Unknown; + bool isRaster = false; + QString tableComment; + + // TODO: rename this ! + int size() const + { + Q_ASSERT( types.size() == srids.size() ); + return types.size(); + } -#ifdef QGISDEBUG - QString toString() const - { - QString typeString; - const auto constTypes = types; - for ( const Qgis::WkbType type : constTypes ) + QString defaultName() const { - if ( !typeString.isEmpty() ) - typeString += '|'; - typeString += QString::number( static_cast< quint32>( type ) ); + QString n = tableName; + if ( nSpCols > 1 ) + n += '.' + geometryColName; + return n; } - QString sridString; - const auto constSrids = srids; - for ( const int srid : constSrids ) + + QgsPostgresLayerProperty at( int i ) const { - if ( !sridString.isEmpty() ) - sridString += '|'; - sridString += QString::number( srid ); + QgsPostgresLayerProperty property; + + Q_ASSERT( i >= 0 && i < size() ); + + property.types << types[i]; + property.srids << srids[i]; + property.schemaName = schemaName; + property.tableName = tableName; + property.geometryColName = geometryColName; + property.geometryColType = geometryColType; + property.pkCols = pkCols; + property.nSpCols = nSpCols; + property.sql = sql; + property.relKind = relKind; + property.isRaster = isRaster; + property.tableComment = tableComment; + + return property; } - return QStringLiteral( "%1.%2.%3 type=%4 srid=%5 pkCols=%6 sql=%7 nSpCols=%8" ) - .arg( schemaName, - tableName, - geometryColName, - typeString, - sridString, - pkCols.join( QLatin1Char( '|' ) ), - sql ) - .arg( nSpCols ); - } +#ifdef QGISDEBUG + QString toString() const + { + QString typeString; + const auto constTypes = types; + for ( const Qgis::WkbType type : constTypes ) + { + if ( !typeString.isEmpty() ) + typeString += '|'; + typeString += QString::number( static_cast( type ) ); + } + QString sridString; + const auto constSrids = srids; + for ( const int srid : constSrids ) + { + if ( !sridString.isEmpty() ) + sridString += '|'; + sridString += QString::number( srid ); + } + + return QStringLiteral( "%1.%2.%3 type=%4 srid=%5 pkCols=%6 sql=%7 nSpCols=%8" ) + .arg( schemaName, tableName, geometryColName, typeString, sridString, pkCols.join( QLatin1Char( '|' ) ), sql ) + .arg( nSpCols ); + } #endif }; class QgsPostgresResult { public: - explicit QgsPostgresResult( PGresult *result = nullptr ) : mRes( result ) {} + explicit QgsPostgresResult( PGresult *result = nullptr ) + : mRes( result ) {} ~QgsPostgresResult(); QgsPostgresResult &operator=( PGresult *result ); @@ -182,7 +182,6 @@ class QgsPostgresResult private: PGresult *mRes = nullptr; - }; struct PGException @@ -205,6 +204,7 @@ struct PGException class QgsPoolPostgresConn { class QgsPostgresConn *mPgConn; + public: QgsPoolPostgresConn( const QString &connInfo ); ~QgsPoolPostgresConn(); @@ -214,17 +214,16 @@ class QgsPoolPostgresConn #include "qgsconfig.h" constexpr int sPostgresConQueryLogFilePrefixLength = CMAKE_SOURCE_DIR[sizeof( CMAKE_SOURCE_DIR ) - 1] == '/' ? sizeof( CMAKE_SOURCE_DIR ) + 1 : sizeof( CMAKE_SOURCE_DIR ); -#define QGS_QUERY_LOG_ORIGIN_PG_CON QString(QString( __FILE__ ).mid( sPostgresConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")") -#define LoggedPQexecNR(_class, query) PQexecNR( query, _class, QGS_QUERY_LOG_ORIGIN_PG_CON ) -#define LoggedPQexec(_class, query) PQexec( query, true, true, _class, QGS_QUERY_LOG_ORIGIN_PG_CON ) -#define LoggedPQexecNoLogError(_class, query ) PQexec( query, false, true, _class, QGS_QUERY_LOG_ORIGIN_PG_CON ) +#define QGS_QUERY_LOG_ORIGIN_PG_CON QString( QString( __FILE__ ).mid( sPostgresConQueryLogFilePrefixLength ) + ':' + QString::number( __LINE__ ) + " (" + __FUNCTION__ + ")" ) +#define LoggedPQexecNR( _class, query ) PQexecNR( query, _class, QGS_QUERY_LOG_ORIGIN_PG_CON ) +#define LoggedPQexec( _class, query ) PQexec( query, true, true, _class, QGS_QUERY_LOG_ORIGIN_PG_CON ) +#define LoggedPQexecNoLogError( _class, query ) PQexec( query, false, true, _class, QGS_QUERY_LOG_ORIGIN_PG_CON ) class QgsPostgresConn : public QObject { Q_OBJECT public: - /** * Get a new PostgreSQL connection * @@ -386,11 +385,7 @@ class QgsPostgresConn : public QObject * \param schema restrict layers to layers within specified schema * \returns true if layers were fetched successfully */ - bool supportedLayers( QVector &layers, - bool searchGeometryColumnsOnly = true, - bool searchPublicOnly = true, - bool allowGeometrylessTables = false, - const QString &schema = QString() ); + bool supportedLayers( QVector &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, const QString &schema = QString() ); /** * Get the information about a supported layer @@ -427,8 +422,7 @@ class QgsPostgresConn : public QObject * \param name restrict tables to those with specified name * \returns true if tables were successfully queried */ - bool getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, - const QString &schema = QString(), const QString &name = QString() ); + bool getTableInfo( bool searchGeometryColumnsOnly, bool searchPublicOnly, bool allowGeometrylessTables, const QString &schema = QString(), const QString &name = QString() ); qint64 getBinaryInt( QgsPostgresResult &queryResult, int row, int col ); @@ -493,7 +487,6 @@ class QgsPostgresConn : public QObject int crsToSrid( const QgsCoordinateReferenceSystem &crs ); private: - int mRef; int mOpenCursors; PGconn *mConn = nullptr; @@ -554,12 +547,7 @@ class QgsPostgresConn : public QObject * \param table restrict tables to those with specified table * \returns true if layers were fetched successfully */ - bool supportedLayersPrivate( QVector &layers, - bool searchGeometryColumnsOnly = true, - bool searchPublicOnly = true, - bool allowGeometrylessTables = false, - const QString &schema = QString(), - const QString &table = QString() ); + bool supportedLayersPrivate( QVector &layers, bool searchGeometryColumnsOnly = true, bool searchPublicOnly = true, bool allowGeometrylessTables = false, const QString &schema = QString(), const QString &table = QString() ); //! List of the supported layers QVector mLayersSupported; diff --git a/src/providers/postgres/qgspostgresconnpool.cpp b/src/providers/postgres/qgspostgresconnpool.cpp index 400c62ab3030..28cc5e56c544 100644 --- a/src/providers/postgres/qgspostgresconnpool.cpp +++ b/src/providers/postgres/qgspostgresconnpool.cpp @@ -33,7 +33,8 @@ void QgsPostgresConnPool::cleanupInstance() sInstance = nullptr; } -QgsPostgresConnPool::QgsPostgresConnPool() : QgsConnectionPool() +QgsPostgresConnPool::QgsPostgresConnPool() + : QgsConnectionPool() { QgsDebugCall; } @@ -42,4 +43,3 @@ QgsPostgresConnPool::~QgsPostgresConnPool() { QgsDebugCall; } - diff --git a/src/providers/postgres/qgspostgresconnpool.h b/src/providers/postgres/qgspostgresconnpool.h index d85531d60412..2f7c58f082d4 100644 --- a/src/providers/postgres/qgspostgresconnpool.h +++ b/src/providers/postgres/qgspostgresconnpool.h @@ -52,7 +52,8 @@ class QgsPostgresConnPoolGroup : public QObject, public QgsConnectionPoolGroup( name ) { initTimer( this ); } + explicit QgsPostgresConnPoolGroup( const QString &name ) + : QgsConnectionPoolGroup( name ) { initTimer( this ); } protected slots: void handleConnectionExpired() { onConnectionExpired(); } @@ -61,7 +62,6 @@ class QgsPostgresConnPoolGroup : public QObject, public QgsConnectionPoolGroup &selection, QgsDataItemGuiContext context ) { - if ( QgsPGRootItem *rootItem = qobject_cast< QgsPGRootItem * >( item ) ) + if ( QgsPGRootItem *rootItem = qobject_cast( item ) ) { QAction *actionNew = new QAction( tr( "New Connection…" ), menu ); connect( actionNew, &QAction::triggered, this, [rootItem] { newConnection( rootItem ); } ); @@ -48,7 +48,7 @@ void QgsPostgresDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe menu->addAction( actionLoadServers ); } - if ( QgsPGConnectionItem *connItem = qobject_cast< QgsPGConnectionItem * >( item ) ) + if ( QgsPGConnectionItem *connItem = qobject_cast( item ) ) { QAction *actionRefresh = new QAction( tr( "Refresh" ), menu ); connect( actionRefresh, &QAction::triggered, this, [connItem] { refreshConnection( connItem ); } ); @@ -64,15 +64,12 @@ void QgsPostgresDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe connect( actionDuplicate, &QAction::triggered, this, [connItem] { duplicateConnection( connItem ); } ); menu->addAction( actionDuplicate ); - const QList< QgsPGConnectionItem * > pgConnectionItems = QgsDataItem::filteredItems( selection ); + const QList pgConnectionItems = QgsDataItem::filteredItems( selection ); QAction *actionDelete = new QAction( pgConnectionItems.size() > 1 ? tr( "Remove Connections…" ) : tr( "Remove Connection…" ), menu ); - connect( actionDelete, &QAction::triggered, this, [pgConnectionItems, context] - { - QgsDataItemGuiProviderUtils::deleteConnections( pgConnectionItems, []( const QString & connectionName ) - { + connect( actionDelete, &QAction::triggered, this, [pgConnectionItems, context] { + QgsDataItemGuiProviderUtils::deleteConnections( pgConnectionItems, []( const QString &connectionName ) { QgsProviderMetadata *md = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "postgres" ) ); - md->deleteConnection( connectionName ); - }, context ); + md->deleteConnection( connectionName ); }, context ); } ); menu->addAction( actionDelete ); @@ -83,7 +80,7 @@ void QgsPostgresDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe menu->addAction( actionCreateSchema ); } - if ( QgsPGSchemaItem *schemaItem = qobject_cast< QgsPGSchemaItem * >( item ) ) + if ( QgsPGSchemaItem *schemaItem = qobject_cast( item ) ) { QAction *actionRefresh = new QAction( tr( "Refresh" ), menu ); connect( actionRefresh, &QAction::triggered, this, [schemaItem] { schemaItem->refresh(); } ); @@ -104,7 +101,7 @@ void QgsPostgresDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe menu->addMenu( maintainMenu ); } - if ( QgsPGLayerItem *layerItem = qobject_cast< QgsPGLayerItem * >( item ) ) + if ( QgsPGLayerItem *layerItem = qobject_cast( item ) ) { const QgsPostgresLayerProperty &layerInfo = layerItem->layerInfo(); const QString typeName = typeNameFromLayer( layerInfo ); @@ -135,14 +132,12 @@ void QgsPostgresDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe bool QgsPostgresDataItemGuiProvider::deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context ) { - if ( QgsPGLayerItem *layerItem = qobject_cast< QgsPGLayerItem * >( item ) ) + if ( QgsPGLayerItem *layerItem = qobject_cast( item ) ) { const QgsPostgresLayerProperty &layerInfo = layerItem->layerInfo(); const QString typeName = typeNameFromLayer( layerInfo ); - if ( QMessageBox::question( nullptr, tr( "Delete %1" ).arg( typeName ), - QObject::tr( "Are you sure you want to delete %1 '%2.%3'?" ).arg( typeName.toLower(), layerInfo.schemaName, layerInfo.tableName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, tr( "Delete %1" ).arg( typeName ), QObject::tr( "Are you sure you want to delete %1 '%2.%3'?" ).arg( typeName.toLower(), layerInfo.schemaName, layerInfo.tableName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return false; QString errCause; @@ -165,9 +160,9 @@ bool QgsPostgresDataItemGuiProvider::deleteLayer( QgsLayerItem *item, QgsDataIte bool QgsPostgresDataItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiContext ) { - if ( qobject_cast< QgsPGConnectionItem * >( item ) ) + if ( qobject_cast( item ) ) return true; - if ( qobject_cast< QgsPGSchemaItem * >( item ) ) + if ( qobject_cast( item ) ) return true; return false; @@ -175,11 +170,11 @@ bool QgsPostgresDataItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemG bool QgsPostgresDataItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiContext, const QMimeData *data, Qt::DropAction ) { - if ( QgsPGConnectionItem *connItem = qobject_cast< QgsPGConnectionItem * >( item ) ) + if ( QgsPGConnectionItem *connItem = qobject_cast( item ) ) { return connItem->handleDrop( data, QString() ); } - else if ( QgsPGSchemaItem *schemaItem = qobject_cast< QgsPGSchemaItem * >( item ) ) + else if ( QgsPGSchemaItem *schemaItem = qobject_cast( item ) ) { QgsPGConnectionItem *connItem = qobject_cast( schemaItem->parent() ); if ( !connItem ) @@ -298,8 +293,7 @@ void QgsPostgresDataItemGuiProvider::createSchema( QgsDataItem *item, QgsDataIte QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresDataItemGuiProvider", sql ) ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { - notify( tr( "New Schema" ), tr( "Unable to create schema '%1'\n%2" ).arg( schemaName, - result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); + notify( tr( "New Schema" ), tr( "Unable to create schema '%1'\n%2" ).arg( schemaName, result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); conn->unref(); return; } @@ -353,9 +347,7 @@ void QgsPostgresDataItemGuiProvider::deleteSchema( QgsPGSchemaItem *schemaItem, { objects += QStringLiteral( "\n[%1 additional objects not listed]" ).arg( count - maxListed ); } - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Schema" ), - QObject::tr( "Schema '%1' contains objects:\n\n%2\n\nAre you sure you want to delete the schema and all these objects?" ).arg( schemaItem->name(), objects ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Schema" ), QObject::tr( "Schema '%1' contains objects:\n\n%2\n\nAre you sure you want to delete the schema and all these objects?" ).arg( schemaItem->name(), objects ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) { conn->unref(); return; @@ -363,9 +355,7 @@ void QgsPostgresDataItemGuiProvider::deleteSchema( QgsPGSchemaItem *schemaItem, } else { - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Schema" ), - QObject::tr( "Are you sure you want to delete schema '%1'?" ).arg( schemaItem->name() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Schema" ), QObject::tr( "Are you sure you want to delete schema '%1'?" ).arg( schemaItem->name() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; } @@ -401,19 +391,17 @@ void QgsPostgresDataItemGuiProvider::renameSchema( QgsPGSchemaItem *schemaItem, //rename the schema const QString sql = QStringLiteral( "ALTER SCHEMA %1 RENAME TO %2" ) - .arg( schemaName, QgsPostgresConn::quotedIdentifier( dlg.name() ) ); + .arg( schemaName, QgsPostgresConn::quotedIdentifier( dlg.name() ) ); QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresDataItemGuiProvider", sql ) ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { - notify( tr( "Rename Schema" ), tr( "Unable to rename schema '%1'\n%2" ).arg( schemaItem->name(), - result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); + notify( tr( "Rename Schema" ), tr( "Unable to rename schema '%1'\n%2" ).arg( schemaItem->name(), result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); conn->unref(); return; } - notify( tr( "Rename Schema" ), tr( "Schema '%1' renamed correctly to '%2'." ).arg( schemaItem->name(), - dlg.name() ), context, Qgis::MessageLevel::Success ); + notify( tr( "Rename Schema" ), tr( "Schema '%1' renamed correctly to '%2'." ).arg( schemaItem->name(), dlg.name() ), context, Qgis::MessageLevel::Success ); conn->unref(); if ( schemaItem->parent() ) @@ -425,7 +413,8 @@ void QgsPostgresDataItemGuiProvider::renameLayer( QgsPGLayerItem *layerItem, Qgs const QgsPostgresLayerProperty &layerInfo = layerItem->layerInfo(); const QString typeName = typeNameFromLayer( layerInfo ); const QString lowerTypeName = ( layerInfo.relKind == Qgis::PostgresRelKind::View || layerInfo.relKind == Qgis::PostgresRelKind::MaterializedView ) - ? tr( "view" ) : tr( "table" ); + ? tr( "view" ) + : tr( "table" ); QgsNewNameDialog dlg( tr( "%1 %2.%3" ).arg( lowerTypeName, layerInfo.schemaName, layerInfo.tableName ), layerInfo.tableName ); dlg.setWindowTitle( tr( "Rename %1" ).arg( typeName ) ); @@ -454,8 +443,7 @@ void QgsPostgresDataItemGuiProvider::renameLayer( QgsPGLayerItem *layerItem, Qgs QString sql; if ( layerInfo.relKind == Qgis::PostgresRelKind::View || layerInfo.relKind == Qgis::PostgresRelKind::MaterializedView ) { - sql = QStringLiteral( "ALTER %1 VIEW %2 RENAME TO %3" ).arg( layerInfo.relKind == Qgis::PostgresRelKind::MaterializedView ? QStringLiteral( "MATERIALIZED" ) : QString(), - oldName, newName ); + sql = QStringLiteral( "ALTER %1 VIEW %2 RENAME TO %3" ).arg( layerInfo.relKind == Qgis::PostgresRelKind::MaterializedView ? QStringLiteral( "MATERIALIZED" ) : QString(), oldName, newName ); } else { @@ -465,14 +453,12 @@ void QgsPostgresDataItemGuiProvider::renameLayer( QgsPGLayerItem *layerItem, Qgs QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresDataItemGuiProvider", sql ) ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { - notify( tr( "Rename %1" ).arg( typeName ), tr( "Unable to rename '%1' %2\n%3" ).arg( lowerTypeName, layerItem->name(), - result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); + notify( tr( "Rename %1" ).arg( typeName ), tr( "Unable to rename '%1' %2\n%3" ).arg( lowerTypeName, layerItem->name(), result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); conn->unref(); return; } - notify( tr( "Rename %1" ).arg( typeName ), tr( "%1 '%2' renamed correctly to '%3'." ).arg( typeName, oldName, newName ), - context, Qgis::MessageLevel::Success ); + notify( tr( "Rename %1" ).arg( typeName ), tr( "%1 '%2' renamed correctly to '%3'." ).arg( typeName, oldName, newName ), context, Qgis::MessageLevel::Success ); conn->unref(); @@ -483,9 +469,7 @@ void QgsPostgresDataItemGuiProvider::renameLayer( QgsPGLayerItem *layerItem, Qgs void QgsPostgresDataItemGuiProvider::truncateTable( QgsPGLayerItem *layerItem, QgsDataItemGuiContext context ) { const QgsPostgresLayerProperty &layerInfo = layerItem->layerInfo(); - if ( QMessageBox::question( nullptr, QObject::tr( "Truncate Table" ), - QObject::tr( "Are you sure you want to truncate \"%1.%2\"?\n\nThis will delete all data within the table." ).arg( layerInfo.schemaName, layerInfo.tableName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Truncate Table" ), QObject::tr( "Are you sure you want to truncate \"%1.%2\"?\n\nThis will delete all data within the table." ).arg( layerInfo.schemaName, layerInfo.tableName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; const QgsDataSourceUri dsUri( layerItem->uri() ); @@ -510,8 +494,7 @@ void QgsPostgresDataItemGuiProvider::truncateTable( QgsPGLayerItem *layerItem, Q QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresDataItemGuiProvider", sql ) ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { - notify( tr( "Truncate Table" ), tr( "Unable to truncate '%1'\n%2" ).arg( tableName, - result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); + notify( tr( "Truncate Table" ), tr( "Unable to truncate '%1'\n%2" ).arg( tableName, result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); conn->unref(); return; } @@ -523,9 +506,7 @@ void QgsPostgresDataItemGuiProvider::truncateTable( QgsPGLayerItem *layerItem, Q void QgsPostgresDataItemGuiProvider::refreshMaterializedView( QgsPGLayerItem *layerItem, QgsDataItemGuiContext context ) { const QgsPostgresLayerProperty &layerInfo = layerItem->layerInfo(); - if ( QMessageBox::question( nullptr, QObject::tr( "Refresh Materialized View" ), - QObject::tr( "Are you sure you want to refresh the materialized view \"%1.%2\"?\n\nThis will update all data within the table." ).arg( layerInfo.schemaName, layerInfo.tableName ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Refresh Materialized View" ), QObject::tr( "Are you sure you want to refresh the materialized view \"%1.%2\"?\n\nThis will update all data within the table." ).arg( layerInfo.schemaName, layerInfo.tableName ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return; const QgsDataSourceUri dsUri( layerItem->uri() ); @@ -550,8 +531,7 @@ void QgsPostgresDataItemGuiProvider::refreshMaterializedView( QgsPGLayerItem *la QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresDataItemGuiProvider", sql ) ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { - notify( tr( "Refresh View" ), tr( "Unable to refresh the view '%1'\n%2" ).arg( tableRef, - result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); + notify( tr( "Refresh View" ), tr( "Unable to refresh the view '%1'\n%2" ).arg( tableRef, result.PQresultErrorMessage() ), context, Qgis::MessageLevel::Warning ); conn->unref(); return; } @@ -568,8 +548,7 @@ void QgsPostgresDataItemGuiProvider::saveConnections() void QgsPostgresDataItemGuiProvider::loadConnections( QgsDataItem *item ) { - const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; diff --git a/src/providers/postgres/qgspostgresdataitemguiprovider.h b/src/providers/postgres/qgspostgresdataitemguiprovider.h index 61e5cfeca2d9..98fd8c42be17 100644 --- a/src/providers/postgres/qgspostgresdataitemguiprovider.h +++ b/src/providers/postgres/qgspostgresdataitemguiprovider.h @@ -26,11 +26,9 @@ class QgsPostgresDataItemGuiProvider : public QObject, public QgsDataItemGuiProv { Q_OBJECT public: - QString name() override { return QStringLiteral( "PostGIS" ); } - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context ) override; @@ -40,7 +38,6 @@ class QgsPostgresDataItemGuiProvider : public QObject, public QgsDataItemGuiProv QWidget *createParamWidget( QgsDataItem *root, QgsDataItemGuiContext ) override; private: - static QString typeNameFromLayer( const QgsPostgresLayerProperty &layer ); static void newConnection( QgsDataItem *item ); static void editConnection( QgsDataItem *item ); @@ -54,7 +51,6 @@ class QgsPostgresDataItemGuiProvider : public QObject, public QgsDataItemGuiProv static void refreshMaterializedView( QgsPGLayerItem *layerItem, QgsDataItemGuiContext context ); static void saveConnections(); static void loadConnections( QgsDataItem *item ); - }; #endif // QGSPOSTGRESDATAITEMGUIPROVIDER_H diff --git a/src/providers/postgres/qgspostgresdataitems.cpp b/src/providers/postgres/qgspostgresdataitems.cpp index afdbbe69bce1..46ec9265c0b6 100644 --- a/src/providers/postgres/qgspostgresdataitems.cpp +++ b/src/providers/postgres/qgspostgresdataitems.cpp @@ -59,7 +59,7 @@ bool QgsPostgresUtils::deleteLayer( const QString &uri, QString &errCause ) // handle deletion of views QString sqlViewCheck = QStringLiteral( "SELECT relkind FROM pg_class WHERE oid=regclass(%1)::oid" ) - .arg( QgsPostgresConn::quotedValue( schemaTableName ) ); + .arg( QgsPostgresConn::quotedValue( schemaTableName ) ); QgsPostgresResult resViewCheck( conn->LoggedPQexec( "QgsPostgresUtils", sqlViewCheck ) ); const QString type = resViewCheck.PQgetvalue( 0, 0 ); const Qgis::PostgresRelKind relKind = QgsPostgresConn::relKindFromValue( type ); @@ -74,8 +74,7 @@ bool QgsPostgresUtils::deleteLayer( const QString &uri, QString &errCause ) if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { errCause = QObject::tr( "Unable to delete view %1: \n%2" ) - .arg( schemaTableName, - result.PQresultErrorMessage() ); + .arg( schemaTableName, result.PQresultErrorMessage() ); conn->unref(); return false; } @@ -103,14 +102,12 @@ bool QgsPostgresUtils::deleteLayer( const QString &uri, QString &errCause ) "WHERE f_table_name=relname AND f_table_schema=nspname " "AND pg_class.relnamespace=pg_namespace.oid " "AND f_table_schema=%1 AND f_table_name=%2" ) - .arg( QgsPostgresConn::quotedValue( schemaName ), - QgsPostgresConn::quotedValue( tableName ) ); + .arg( QgsPostgresConn::quotedValue( schemaName ), QgsPostgresConn::quotedValue( tableName ) ); QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresUtils", sql ) ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { errCause = QObject::tr( "Unable to delete layer %1: \n%2" ) - .arg( schemaTableName, - result.PQresultErrorMessage() ); + .arg( schemaTableName, result.PQresultErrorMessage() ); conn->unref(); return false; } @@ -121,24 +118,20 @@ bool QgsPostgresUtils::deleteLayer( const QString &uri, QString &errCause ) { // the table has more geometry columns, drop just the geometry column sql = QStringLiteral( "SELECT DropGeometryColumn(%1,%2,%3)" ) - .arg( QgsPostgresConn::quotedValue( schemaName ), - QgsPostgresConn::quotedValue( tableName ), - QgsPostgresConn::quotedValue( geometryCol ) ); + .arg( QgsPostgresConn::quotedValue( schemaName ), QgsPostgresConn::quotedValue( tableName ), QgsPostgresConn::quotedValue( geometryCol ) ); } else { // drop the table sql = QStringLiteral( "SELECT DropGeometryTable(%1,%2)" ) - .arg( QgsPostgresConn::quotedValue( schemaName ), - QgsPostgresConn::quotedValue( tableName ) ); + .arg( QgsPostgresConn::quotedValue( schemaName ), QgsPostgresConn::quotedValue( tableName ) ); } result = conn->LoggedPQexec( "QgsPostgresUtils", sql ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { errCause = QObject::tr( "Unable to delete layer %1: \n%2" ) - .arg( schemaTableName, - result.PQresultErrorMessage() ); + .arg( schemaTableName, result.PQresultErrorMessage() ); conn->unref(); return false; } @@ -168,14 +161,13 @@ bool QgsPostgresUtils::deleteSchema( const QString &schema, const QgsDataSourceU // drop the schema QString sql = QStringLiteral( "DROP SCHEMA %1 %2" ) - .arg( schemaName, cascade ? QStringLiteral( "CASCADE" ) : QString() ); + .arg( schemaName, cascade ? QStringLiteral( "CASCADE" ) : QString() ); QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresUtils", sql ) ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { errCause = QObject::tr( "Unable to delete schema %1: \n%2" ) - .arg( schemaName, - result.PQresultErrorMessage() ); + .arg( schemaName, result.PQresultErrorMessage() ); conn->unref(); return false; } @@ -195,8 +187,7 @@ QgsPGConnectionItem::QgsPGConnectionItem( QgsDataItem *parent, const QString &na QVector QgsPGConnectionItem::createChildren() { - - QVectoritems; + QVector items; QgsDataSourceUri uri = QgsPostgresConn::connUri( mName ); // TODO: we need to cancel somehow acquireConnection() if deleteLater() was called on this item to avoid later credential dialog if connection failed @@ -283,16 +274,15 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData *data, const QString &toSc if ( srcLayer->isValid() ) { - // Try to get source col from uri QString geomColumn { QStringLiteral( "geom" ) }; - if ( ! srcLayer->dataProvider()->uri().geometryColumn().isEmpty() ) + if ( !srcLayer->dataProvider()->uri().geometryColumn().isEmpty() ) { geomColumn = srcLayer->dataProvider()->uri().geometryColumn(); } - uri.setDataSource( QString(), u.name, srcLayer->geometryType() != Qgis::GeometryType::Null ? geomColumn : QString() ); + uri.setDataSource( QString(), u.name, srcLayer->geometryType() != Qgis::GeometryType::Null ? geomColumn : QString() ); QgsDebugMsgLevel( "URI " + uri.uri( false ), 2 ); @@ -301,19 +291,17 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData *data, const QString &toSc uri.setSchema( toSchema ); } - std::unique_ptr< QgsVectorLayerExporterTask > exportTask( new QgsVectorLayerExporterTask( srcLayer, uri.uri( false ), QStringLiteral( "postgres" ), srcLayer->crs(), QVariantMap(), owner ) ); + std::unique_ptr exportTask( new QgsVectorLayerExporterTask( srcLayer, uri.uri( false ), QStringLiteral( "postgres" ), srcLayer->crs(), QVariantMap(), owner ) ); // when export is successful: - connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [ = ]() - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, this, [=]() { // this is gross - TODO - find a way to get access to messageBar from data items QMessageBox::information( nullptr, tr( "Import to PostGIS database" ), tr( "Import was successful." ) ); refreshSchema( toSchema ); } ); // when an error occurs: - connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, [ = ]( Qgis::VectorExportResult error, const QString & errorMessage ) - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, this, [=]( Qgis::VectorExportResult error, const QString &errorMessage ) { if ( error != Qgis::VectorExportResult::UserCanceled ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); @@ -379,9 +367,10 @@ QString QgsPGLayerItem::createUri() QString basekey = QStringLiteral( "/PostgreSQL/connections/%1" ).arg( connName ); QStringList defPk( settings.value( - QStringLiteral( "%1/keys/%2/%3" ).arg( basekey, mLayerProperty.schemaName, mLayerProperty.tableName ), - QVariant( !mLayerProperty.pkCols.isEmpty() ? QStringList( mLayerProperty.pkCols.at( 0 ) ) : QStringList() ) - ).toStringList() ); + QStringLiteral( "%1/keys/%2/%3" ).arg( basekey, mLayerProperty.schemaName, mLayerProperty.tableName ), + QVariant( !mLayerProperty.pkCols.isEmpty() ? QStringList( mLayerProperty.pkCols.at( 0 ) ) : QStringList() ) + ) + .toStringList() ); const bool useEstimatedMetadata = QgsPostgresConn::useEstimatedMetadata( connName ); uri.setUseEstimatedMetadata( useEstimatedMetadata ); @@ -411,7 +400,7 @@ QgsPGSchemaItem::QgsPGSchemaItem( QgsDataItem *parent, const QString &connection QVector QgsPGSchemaItem::createChildren() { - QVectoritems; + QVector items; QgsDataSourceUri uri = QgsPostgresConn::connUri( mConnectionName ); QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( uri.connectionInfo( false ) ); @@ -424,10 +413,7 @@ QVector QgsPGSchemaItem::createChildren() } QVector layerProperties; - const bool ok = conn->supportedLayers( layerProperties, - QgsPostgresConn::geometryColumnsOnly( mConnectionName ), - QgsPostgresConn::publicSchemaOnly( mConnectionName ), - QgsPostgresConn::allowGeometrylessTables( mConnectionName ), mName ); + const bool ok = conn->supportedLayers( layerProperties, QgsPostgresConn::geometryColumnsOnly( mConnectionName ), QgsPostgresConn::publicSchemaOnly( mConnectionName ), QgsPostgresConn::allowGeometrylessTables( mConnectionName ), mName ); if ( !ok ) { @@ -454,11 +440,10 @@ QVector QgsPGSchemaItem::createChildren() const QList results { dbConn->searchLayerMetadata( QgsMetadataSearchContext() ) }; for ( const QgsLayerMetadataProviderResult &result : std::as_const( results ) ) { - const QgsDataSourceUri resUri { result.uri( ) }; + const QgsDataSourceUri resUri { result.uri() }; layerMetadata.insert( QStringLiteral( "%1.%2" ).arg( resUri.schema(), resUri.table() ), static_cast( result ) ); } } - } catch ( const QgsProviderConnectionException & ) { @@ -473,10 +458,7 @@ QVector QgsPGSchemaItem::createChildren() if ( layerProperty.schemaName != mName ) continue; - if ( !layerProperty.geometryColName.isNull() && - !layerProperty.isRaster && - ( layerProperty.types.value( 0, Qgis::WkbType::Unknown ) == Qgis::WkbType::Unknown || - layerProperty.srids.value( 0, std::numeric_limits::min() ) == std::numeric_limits::min() ) ) + if ( !layerProperty.geometryColName.isNull() && !layerProperty.isRaster && ( layerProperty.types.value( 0, Qgis::WkbType::Unknown ) == Qgis::WkbType::Unknown || layerProperty.srids.value( 0, std::numeric_limits::min() ) == std::numeric_limits::min() ) ) { if ( dontResolveType ) { @@ -560,7 +542,7 @@ QgsPGLayerItem *QgsPGSchemaItem::createLayer( QgsPostgresLayerProperty layerProp } Qgis::WkbType wkbType = layerProperty.types.at( 0 ); - if ( ! layerProperty.isRaster ) + if ( !layerProperty.isRaster ) { tip += tr( "\n%1 as %2" ).arg( layerProperty.geometryColName, QgsPostgresConn::displayStringForWkbType( wkbType ) ); } @@ -577,7 +559,7 @@ QgsPGLayerItem *QgsPGSchemaItem::createLayer( QgsPostgresLayerProperty layerProp Qgis::BrowserLayerType layerType = Qgis::BrowserLayerType::Raster; - if ( ! layerProperty.isRaster ) + if ( !layerProperty.isRaster ) { Qgis::GeometryType geomType = QgsWkbTypes::geometryType( wkbType ); switch ( geomType ) diff --git a/src/providers/postgres/qgspostgresdataitems.h b/src/providers/postgres/qgspostgresdataitems.h index a6e2a9243cee..8e1dba80b6f5 100644 --- a/src/providers/postgres/qgspostgresdataitems.h +++ b/src/providers/postgres/qgspostgresdataitems.h @@ -65,7 +65,6 @@ class QgsPGConnectionItem : public QgsDataCollectionItem // refresh specified schema or all schemas if schema name is empty void refreshSchema( const QString &schema ); - }; class QgsPGSchemaItem : public QgsDatabaseSchemaItem @@ -105,11 +104,9 @@ class QgsPGLayerItem : public QgsLayerItem private: QgsPostgresLayerProperty mLayerProperty; - }; - //! Provider for Postgres data item class QgsPostgresDataItemProvider : public QgsDataItemProvider { diff --git a/src/providers/postgres/qgspostgresexpressioncompiler.cpp b/src/providers/postgres/qgspostgresexpressioncompiler.cpp index 23d797c2e29b..1d37a1c906a3 100644 --- a/src/providers/postgres/qgspostgresexpressioncompiler.cpp +++ b/src/providers/postgres/qgspostgresexpressioncompiler.cpp @@ -56,8 +56,7 @@ QString QgsPostgresExpressionCompiler::quotedValue( const QVariant &value, bool return QgsPostgresConn::quotedValue( value ); } -static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP -{ +static const QMap FUNCTION_NAMES_SQL_FUNCTIONS_MAP { { "sqrt", "sqrt" }, { "radians", "radians" }, { "degrees", "degrees" }, diff --git a/src/providers/postgres/qgspostgresexpressioncompiler.h b/src/providers/postgres/qgspostgresexpressioncompiler.h index 1c2c470be6cc..d51f8aca4480 100644 --- a/src/providers/postgres/qgspostgresexpressioncompiler.h +++ b/src/providers/postgres/qgspostgresexpressioncompiler.h @@ -24,11 +24,9 @@ class QgsPostgresExpressionCompiler : public QgsSqlExpressionCompiler { public: - explicit QgsPostgresExpressionCompiler( QgsPostgresFeatureSource *source, bool ignoreStaticNodes = false ); protected: - QString quotedIdentifier( const QString &identifier ) override; QString quotedValue( const QVariant &value, bool &ok ) override; Result compileNode( const QgsExpressionNode *node, QString &str ) override; diff --git a/src/providers/postgres/qgspostgresfeatureiterator.cpp b/src/providers/postgres/qgspostgresfeatureiterator.cpp index 729059a41835..cb32b7de0b25 100644 --- a/src/providers/postgres/qgspostgresfeatureiterator.cpp +++ b/src/providers/postgres/qgspostgresfeatureiterator.cpp @@ -104,11 +104,7 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource else { // we can safely hand this off to the backend to evaluate, so that it will nicely handle it within the query planner! - whereClause = QgsPostgresUtils::andWhereClauses( whereClause, QStringLiteral( "ST_DWithin(%1,ST_GeomFromText('%2',%3),%4)" ).arg( - QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), - mRequest.referenceGeometry().asWkt(), - mSource->mRequestedSrid.isEmpty() ? mSource->mDetectedSrid : mSource->mRequestedSrid ) - .arg( mRequest.distanceWithin() ) ); + whereClause = QgsPostgresUtils::andWhereClauses( whereClause, QStringLiteral( "ST_DWithin(%1,ST_GeomFromText('%2',%3),%4)" ).arg( QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), mRequest.referenceGeometry().asWkt(), mSource->mRequestedSrid.isEmpty() ? mSource->mDetectedSrid : mSource->mRequestedSrid ).arg( mRequest.distanceWithin() ) ); } } break; @@ -385,9 +381,7 @@ bool QgsPostgresFeatureIterator::nextFeatureFilterExpression( QgsFeature &f ) bool QgsPostgresFeatureIterator::prepareSimplification( const QgsSimplifyMethod &simplifyMethod ) { // setup simplification of geometries to fetch - if ( !( mRequest.flags() & Qgis::FeatureRequestFlag::NoGeometry ) && - simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && - !simplifyMethod.forceLocalOptimization() ) + if ( !( mRequest.flags() & Qgis::FeatureRequestFlag::NoGeometry ) && simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && !simplifyMethod.forceLocalOptimization() ) { QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType(); @@ -494,25 +488,18 @@ QString QgsPostgresFeatureIterator::whereClauseRect() if ( mConn->majorVersion() < 2 ) { qBox = QStringLiteral( "setsrid('BOX3D(%1)'::box3d,%2)" ) - .arg( rect.asWktCoordinates(), - bboxSrid ); + .arg( rect.asWktCoordinates(), bboxSrid ); } else { qBox = QStringLiteral( "st_makeenvelope(%1,%2,%3,%4,%5)" ) - .arg( qgsDoubleToString( rect.xMinimum() ), - qgsDoubleToString( rect.yMinimum() ), - qgsDoubleToString( rect.xMaximum() ), - qgsDoubleToString( rect.yMaximum() ), - bboxSrid ); + .arg( qgsDoubleToString( rect.xMinimum() ), qgsDoubleToString( rect.yMinimum() ), qgsDoubleToString( rect.xMaximum() ), qgsDoubleToString( rect.yMaximum() ), bboxSrid ); } - bool castToGeometry = mSource->mSpatialColType == SctGeography || - mSource->mSpatialColType == SctPcPatch; + bool castToGeometry = mSource->mSpatialColType == SctGeography || mSource->mSpatialColType == SctPcPatch; QString whereClause; - if ( mSource->mSpatialColType == SctTopoGeometry && - mSource->mTopoLayerInfo.layerLevel == 0 ) + if ( mSource->mSpatialColType == SctTopoGeometry && mSource->mTopoLayerInfo.layerLevel == 0 ) { whereClause = QStringLiteral( R"SQL( id(%1) in ( @@ -542,21 +529,19 @@ QString QgsPostgresFeatureIterator::whereClauseRect() AND ( r.element_id = e.id OR r.element_id = -e.id ) ) )SQL" ) - // Should we bother with mBoundingBoxColumn ? - .arg( - QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), - qBox, - QgsPostgresConn::quotedIdentifier( mSource->mTopoLayerInfo.topologyName ) - ) - .arg( mSource->mTopoLayerInfo.layerId ) - .arg( mSource->mTopoLayerInfo.featureType ); + // Should we bother with mBoundingBoxColumn ? + .arg( + QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), + qBox, + QgsPostgresConn::quotedIdentifier( mSource->mTopoLayerInfo.topologyName ) + ) + .arg( mSource->mTopoLayerInfo.layerId ) + .arg( mSource->mTopoLayerInfo.featureType ); } else { whereClause = QStringLiteral( "%1%2 && %3" ) - .arg( QgsPostgresConn::quotedIdentifier( mSource->mBoundingBoxColumn ), - castToGeometry ? "::geometry" : "", - qBox ); + .arg( QgsPostgresConn::quotedIdentifier( mSource->mBoundingBoxColumn ), castToGeometry ? "::geometry" : "", qBox ); } // For geography type, using a && filter with the geography column cast as @@ -565,12 +550,7 @@ QString QgsPostgresFeatureIterator::whereClauseRect() // geography uses geodesic arcs, and not rhumb lines, so we must expand a bit the QGIS // bounding box (which assumes rhumb lines) to the south in the northern hemisphere // See https://trac.osgeo.org/postgis/ticket/2495 for some background - if ( mConn->majorVersion() >= 2 && - mSource->mSpatialColType == SctGeography && - bboxSrid == QLatin1String( "4326" ) && - std::fabs( rect.yMaximum() - rect.yMinimum() ) <= 10 && - std::fabs( rect.xMaximum() - rect.xMinimum() ) <= 10 && - std::fabs( rect.yMaximum() ) <= 70 ) + if ( mConn->majorVersion() >= 2 && mSource->mSpatialColType == SctGeography && bboxSrid == QLatin1String( "4326" ) && std::fabs( rect.yMaximum() - rect.yMinimum() ) <= 10 && std::fabs( rect.xMaximum() - rect.xMinimum() ) <= 10 && std::fabs( rect.yMaximum() ) <= 70 ) { /* The following magic constant has been obtained by running : #include "geodesic.h" @@ -612,8 +592,7 @@ QString QgsPostgresFeatureIterator::whereClauseRect() double dlat = 1.04; // For smaller filtering bounding box, use smaller bbox expansion - if ( std::fabs( rect.yMaximum() - rect.yMinimum() ) <= 1 && - std::fabs( rect.xMaximum() - rect.xMinimum() ) <= 1 ) + if ( std::fabs( rect.yMaximum() - rect.yMinimum() ) <= 1 && std::fabs( rect.xMaximum() - rect.xMinimum() ) <= 1 ) { // Value got by changing lat1 to 69 and lon2 to 1 in the above code snippet dlat = 0.013; @@ -622,14 +601,9 @@ QString QgsPostgresFeatureIterator::whereClauseRect() const double yminGeog = rect.yMinimum() >= 0 ? std::max( 0.0, rect.yMinimum() - dlat ) : rect.yMinimum(); const double ymaxGeog = rect.yMaximum() >= 0 ? rect.yMaximum() : std::min( 0.0, rect.yMaximum() + dlat ); const QString qBoxGeog = QStringLiteral( "st_makeenvelope(%1,%2,%3,%4,%5)" ) - .arg( qgsDoubleToString( rect.xMinimum() ), - qgsDoubleToString( yminGeog ), - qgsDoubleToString( rect.xMaximum() ), - qgsDoubleToString( ymaxGeog ), - bboxSrid ); + .arg( qgsDoubleToString( rect.xMinimum() ), qgsDoubleToString( yminGeog ), qgsDoubleToString( rect.xMaximum() ), qgsDoubleToString( ymaxGeog ), bboxSrid ); whereClause += QStringLiteral( " AND %1 && %2" ) - .arg( QgsPostgresConn::quotedIdentifier( mSource->mBoundingBoxColumn ), - qBoxGeog ); + .arg( QgsPostgresConn::quotedIdentifier( mSource->mBoundingBoxColumn ), qBoxGeog ); } if ( mRequest.flags() & Qgis::FeatureRequestFlag::ExactIntersect ) @@ -638,20 +612,13 @@ QString QgsPostgresFeatureIterator::whereClauseRect() if ( mConn->majorVersion() >= 2 || ( mConn->majorVersion() == 1 && mConn->minorVersion() >= 5 ) ) curveToLineFn = QStringLiteral( "st_curvetoline" ); // st_ prefix is always used whereClause += QStringLiteral( " AND %1(%2(%3%4),%5)" ) - .arg( mConn->majorVersion() < 2 ? "intersects" : "st_intersects", - curveToLineFn, - QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), - castToGeometry ? "::geometry" : "", - qBox ); + .arg( mConn->majorVersion() < 2 ? "intersects" : "st_intersects", curveToLineFn, QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), castToGeometry ? "::geometry" : "", qBox ); } if ( !mSource->mRequestedSrid.isEmpty() && ( mSource->mRequestedSrid != mSource->mDetectedSrid || mSource->mRequestedSrid.toInt() == 0 ) ) { whereClause += QStringLiteral( " AND %1(%2%3)=%4" ) - .arg( mConn->majorVersion() < 2 ? "srid" : "st_srid", - QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), - castToGeometry ? "::geometry" : "", - mSource->mRequestedSrid ); + .arg( mConn->majorVersion() < 2 ? "srid" : "st_srid", QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ), castToGeometry ? "::geometry" : "", mSource->mRequestedSrid ); } if ( mSource->mRequestedGeomType != Qgis::WkbType::Unknown && mSource->mRequestedGeomType != mSource->mDetectedGeomType ) @@ -664,7 +631,6 @@ QString QgsPostgresFeatureIterator::whereClauseRect() } - bool QgsPostgresFeatureIterator::declareCursor( const QString &whereClause, long limit, bool closeOnFail, const QString &orderBy ) { mFetchGeometry = ( !( mRequest.flags() & Qgis::FeatureRequestFlag::NoGeometry ) @@ -687,16 +653,14 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString &whereClause, long { QString geom = QgsPostgresConn::quotedIdentifier( mSource->mGeometryColumn ); - if ( mSource->mSpatialColType == SctGeography || - mSource->mSpatialColType == SctPcPatch ) + if ( mSource->mSpatialColType == SctGeography || mSource->mSpatialColType == SctPcPatch ) geom += QLatin1String( "::geometry" ); Qgis::WkbType usedGeomType = mSource->mRequestedGeomType != Qgis::WkbType::Unknown - ? mSource->mRequestedGeomType : mSource->mDetectedGeomType; + ? mSource->mRequestedGeomType + : mSource->mDetectedGeomType; - if ( !mRequest.simplifyMethod().forceLocalOptimization() && - mRequest.simplifyMethod().methodType() != QgsSimplifyMethod::NoSimplification && - QgsWkbTypes::flatType( QgsWkbTypes::singleType( usedGeomType ) ) != Qgis::WkbType::Point ) + if ( !mRequest.simplifyMethod().forceLocalOptimization() && mRequest.simplifyMethod().methodType() != QgsSimplifyMethod::NoSimplification && QgsWkbTypes::flatType( QgsWkbTypes::singleType( usedGeomType ) ) != Qgis::WkbType::Point ) { // PostGIS simplification method to use QString simplifyPostgisMethod; @@ -714,12 +678,10 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString &whereClause, long } else { - // Default to st_snaptogrid simplifyPostgisMethod = QStringLiteral( "st_snaptogrid" ); - if ( ( mConn->majorVersion() == 2 && mConn->minorVersion() >= 2 ) || - mConn->majorVersion() > 2 ) + if ( ( mConn->majorVersion() == 2 && mConn->minorVersion() >= 2 ) || mConn->majorVersion() > 2 ) { // For postgis >= 2.2 Use ST_RemoveRepeatedPoints instead // Do it only if threshold is <= 1 pixel to avoid holes in adjacent polygons @@ -746,27 +708,26 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString &whereClause, long } QgsDebugMsgLevel( QStringLiteral( "PostGIS Server side simplification : threshold %1 pixels - method %2" ) - .arg( mRequest.simplifyMethod().threshold() ) - .arg( simplifyPostgisMethod ), 3 + .arg( mRequest.simplifyMethod().threshold() ) + .arg( simplifyPostgisMethod ), + 3 ); geom = QStringLiteral( "%1(%2,%3)" ) - .arg( simplifyPostgisMethod, geom ) - .arg( mRequest.simplifyMethod().tolerance() * 0.8 ); //-> Default factor for the maximum displacement distance for simplification, similar as GeoServer does + .arg( simplifyPostgisMethod, geom ) + .arg( mRequest.simplifyMethod().tolerance() * 0.8 ); //-> Default factor for the maximum displacement distance for simplification, similar as GeoServer does // Post-simplification if ( postSimplification ) { geom = QStringLiteral( "st_simplify( %1, %2, true )" ) - .arg( geom ) - .arg( mRequest.simplifyMethod().tolerance() * 0.7 ); //-> We use a smaller tolerance than pre-filtering to be on the safe side + .arg( geom ) + .arg( mRequest.simplifyMethod().tolerance() * 0.7 ); //-> We use a smaller tolerance than pre-filtering to be on the safe side } } geom = QStringLiteral( "%1(%2,'%3')" ) - .arg( mConn->majorVersion() < 2 ? "asbinary" : "st_asbinary", - geom, - QgsPostgresProvider::endianString() ); + .arg( mConn->majorVersion() < 2 ? "asbinary" : "st_asbinary", geom, QgsPostgresProvider::endianString() ); query += delim + geom; delim = ','; @@ -857,10 +818,10 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int memcpy( &wkbType, featureGeom + 1, sizeof( wkbType ) ); Qgis::WkbType newType = QgsPostgresConn::wkbTypeFromOgcWkbType( wkbType ); - if ( static_cast< unsigned int >( newType ) != wkbType ) + if ( static_cast( newType ) != wkbType ) { // overwrite type - unsigned int n = static_cast< quint32>( newType ); + unsigned int n = static_cast( newType ); memcpy( featureGeom + 1, &n, sizeof( n ) ); } @@ -948,7 +909,6 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int } fid = mSource->mShared->lookupFid( primaryKeyVals ); - } break; diff --git a/src/providers/postgres/qgspostgresfeatureiterator.h b/src/providers/postgres/qgspostgresfeatureiterator.h index 24bca4466b98..f2799803b45b 100644 --- a/src/providers/postgres/qgspostgresfeatureiterator.h +++ b/src/providers/postgres/qgspostgresfeatureiterator.h @@ -27,7 +27,7 @@ class QgsPostgresResult; class QgsPostgresTransaction; -class QgsPostgresFeatureSource final: public QgsAbstractFeatureSource +class QgsPostgresFeatureSource final : public QgsAbstractFeatureSource { public: explicit QgsPostgresFeatureSource( const QgsPostgresProvider *p ); @@ -36,7 +36,6 @@ class QgsPostgresFeatureSource final: public QgsAbstractFeatureSource QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) override; private: - QString mConnInfo; QString mGeometryColumn; @@ -72,7 +71,7 @@ class QgsPostgresFeatureSource final: public QgsAbstractFeatureSource class QgsPostgresConn; -class QgsPostgresFeatureIterator final: public QgsAbstractFeatureIteratorFromSource +class QgsPostgresFeatureIterator final : public QgsAbstractFeatureIteratorFromSource { public: QgsPostgresFeatureIterator( QgsPostgresFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ); @@ -88,7 +87,6 @@ class QgsPostgresFeatureIterator final: public QgsAbstractFeatureIteratorFromSou bool prepareSimplification( const QgsSimplifyMethod &simplifyMethod ) override; private: - QgsPostgresConn *mConn = nullptr; @@ -131,8 +129,7 @@ class QgsPostgresFeatureIterator final: public QgsAbstractFeatureIteratorFromSou QgsCoordinateTransform mTransform; QgsRectangle mFilterRect; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; - + std::unique_ptr mDistanceWithinEngine; }; #endif // QGSPOSTGRESFEATUREITERATOR_H diff --git a/src/providers/postgres/qgspostgreslayermetadataprovider.cpp b/src/providers/postgres/qgspostgreslayermetadataprovider.cpp index b28caffd5dcb..bed69011ef8b 100644 --- a/src/providers/postgres/qgspostgreslayermetadataprovider.cpp +++ b/src/providers/postgres/qgspostgreslayermetadataprovider.cpp @@ -30,12 +30,11 @@ QgsLayerMetadataSearchResults QgsPostgresLayerMetadataProvider::search( const Qg QgsLayerMetadataSearchResults results; QgsProviderMetadata *md { QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "postgres" ) ) }; - if ( md && ( ! feedback || ! feedback->isCanceled() ) ) + if ( md && ( !feedback || !feedback->isCanceled() ) ) { - const QMap constConnections { md->connections( ) }; + const QMap constConnections { md->connections() }; for ( const QgsAbstractProviderConnection *conn : std::as_const( constConnections ) ) { - if ( feedback && feedback->isCanceled() ) { break; @@ -64,5 +63,3 @@ QgsLayerMetadataSearchResults QgsPostgresLayerMetadataProvider::search( const Qg return results; } - - diff --git a/src/providers/postgres/qgspostgreslayermetadataprovider.h b/src/providers/postgres/qgspostgreslayermetadataprovider.h index a5657ccb7bc1..8de8599f2036 100644 --- a/src/providers/postgres/qgspostgreslayermetadataprovider.h +++ b/src/providers/postgres/qgspostgreslayermetadataprovider.h @@ -21,7 +21,6 @@ class QgsPostgresLayerMetadataProvider : public QgsAbstractLayerMetadataProvider { public: - QString id() const override; QgsLayerMetadataSearchResults search( const QgsMetadataSearchContext &searchContext, const QString &searchString, const QgsRectangle &geographicExtent, QgsFeedback *feedback = nullptr ) const override; diff --git a/src/providers/postgres/qgspostgreslistener.cpp b/src/providers/postgres/qgspostgreslistener.cpp index 8c2ac366752a..c56644def416 100644 --- a/src/providers/postgres/qgspostgreslistener.cpp +++ b/src/providers/postgres/qgspostgreslistener.cpp @@ -33,9 +33,9 @@ extern "C" #include } -std::unique_ptr< QgsPostgresListener > QgsPostgresListener::create( const QString &connString ) +std::unique_ptr QgsPostgresListener::create( const QString &connString ) { - std::unique_ptr< QgsPostgresListener > res( new QgsPostgresListener( connString ) ); + std::unique_ptr res( new QgsPostgresListener( connString ) ); QgsDebugMsgLevel( QStringLiteral( "starting notification listener" ), 2 ); res->start(); diff --git a/src/providers/postgres/qgspostgreslistener.h b/src/providers/postgres/qgspostgreslistener.h index 265a44f58662..13084156c772 100644 --- a/src/providers/postgres/qgspostgreslistener.h +++ b/src/providers/postgres/qgspostgreslistener.h @@ -38,12 +38,11 @@ class QgsPostgresListener : public QThread Q_OBJECT public: - /** * create an instance if possible and starts the associated thread * /returns NULLPTR on error */ - static std::unique_ptr< QgsPostgresListener > create( const QString &connString ); + static std::unique_ptr create( const QString &connString ); ~QgsPostgresListener() override; @@ -60,7 +59,6 @@ class QgsPostgresListener : public QThread QgsPostgresListener( const QString &connString ); Q_DISABLE_COPY( QgsPostgresListener ) - }; #endif // QGSPOSTGRESLISTENER_H diff --git a/src/providers/postgres/qgspostgresprojectstorage.cpp b/src/providers/postgres/qgspostgresprojectstorage.cpp index 6882dc1008bd..ed9f90215e62 100644 --- a/src/providers/postgres/qgspostgresprojectstorage.cpp +++ b/src/providers/postgres/qgspostgresprojectstorage.cpp @@ -50,11 +50,11 @@ static bool _projectsTableExists( QgsPostgresConn &conn, const QString &schemaNa { QString tableName( "qgis_projects" ); QString sql( QStringLiteral( "SELECT COUNT(*) FROM information_schema.tables WHERE table_name=%1 and table_schema=%2" ) - .arg( QgsPostgresConn::quotedValue( tableName ), QgsPostgresConn::quotedValue( schemaName ) ) - ); + .arg( QgsPostgresConn::quotedValue( tableName ), QgsPostgresConn::quotedValue( schemaName ) ) + ); QgsPostgresResult res( conn.PQexec( sql ) ); - if ( ! res.result() ) + if ( !res.result() ) { return false; } @@ -178,18 +178,13 @@ bool QgsPostgresProjectStorage::writeProject( const QString &uri, QIODevice *dev // read from device and write to the table QByteArray content = device->readAll(); - QString metadataExpr = QStringLiteral( "(%1 || (now() at time zone 'utc')::text || %2 || current_user || %3)::jsonb" ).arg( - QgsPostgresConn::quotedValue( "{ \"last_modified_time\": \"" ), - QgsPostgresConn::quotedValue( "\", \"last_modified_user\": \"" ), - QgsPostgresConn::quotedValue( "\" }" ) - ); + QString metadataExpr = QStringLiteral( "(%1 || (now() at time zone 'utc')::text || %2 || current_user || %3)::jsonb" ).arg( QgsPostgresConn::quotedValue( "{ \"last_modified_time\": \"" ), QgsPostgresConn::quotedValue( "\", \"last_modified_user\": \"" ), QgsPostgresConn::quotedValue( "\" }" ) ); // TODO: would be useful to have QByteArray version of PQexec() to avoid bytearray -> string -> bytearray conversion QString sql( "INSERT INTO %1.qgis_projects VALUES (%2, %3, E'\\\\x" ); - sql = sql.arg( QgsPostgresConn::quotedIdentifier( projectUri.schemaName ), - QgsPostgresConn::quotedValue( projectUri.projectName ), - metadataExpr // no need to quote: already quoted - ); + sql = sql.arg( QgsPostgresConn::quotedIdentifier( projectUri.schemaName ), QgsPostgresConn::quotedValue( projectUri.projectName ), + metadataExpr // no need to quote: already quoted + ); sql += QString::fromLatin1( content.toHex() ); sql += "') ON CONFLICT (name) DO UPDATE SET content = EXCLUDED.content, metadata = EXCLUDED.metadata;"; diff --git a/src/providers/postgres/qgspostgresprojectstorage.h b/src/providers/postgres/qgspostgresprojectstorage.h index f0b7a3b91448..687e57b073ba 100644 --- a/src/providers/postgres/qgspostgresprojectstorage.h +++ b/src/providers/postgres/qgspostgresprojectstorage.h @@ -24,12 +24,12 @@ //! Stores information parsed from postgres project URI typedef struct { - bool valid; + bool valid; - QgsDataSourceUri connInfo; // using only the bits about connection info (server, port, username, password, service, ssl mode) + QgsDataSourceUri connInfo; // using only the bits about connection info (server, port, username, password, service, ssl mode) - QString schemaName; - QString projectName; + QString schemaName; + QString projectName; } QgsPostgresProjectUri; @@ -38,7 +38,6 @@ typedef struct class QgsPostgresProjectStorage : public QgsProjectStorage { public: - QString type() override { return QStringLiteral( "postgresql" ); } QStringList listProjects( const QString &uri ) override; diff --git a/src/providers/postgres/qgspostgresprojectstoragedialog.cpp b/src/providers/postgres/qgspostgresprojectstoragedialog.cpp index 62cb0d562a16..69d8770c34d5 100644 --- a/src/providers/postgres/qgspostgresprojectstoragedialog.cpp +++ b/src/providers/postgres/qgspostgresprojectstoragedialog.cpp @@ -52,7 +52,7 @@ QgsPostgresProjectStorageDialog::QgsPostgresProjectStorageDialog( bool saving, Q setWindowTitle( tr( "Load project from PostgreSQL" ) ); } - connect( mCboConnection, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsPostgresProjectStorageDialog::populateSchemas ); + connect( mCboConnection, qOverload( &QComboBox::currentIndexChanged ), this, &QgsPostgresProjectStorageDialog::populateSchemas ); mLblProjectsNotAllowed->setVisible( false ); @@ -64,7 +64,7 @@ QgsPostgresProjectStorageDialog::QgsPostgresProjectStorageDialog( bool saving, Q mCboConnection->setCurrentIndex( mCboConnection->findText( toSelect ) ); populateProjects(); - connect( mCboSchema, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsPostgresProjectStorageDialog::populateProjects ); + connect( mCboSchema, qOverload( &QComboBox::currentIndexChanged ), this, &QgsPostgresProjectStorageDialog::populateProjects ); connect( mCboProject, &QComboBox::currentTextChanged, this, &QgsPostgresProjectStorageDialog::projectChanged ); projectChanged(); @@ -151,9 +151,7 @@ void QgsPostgresProjectStorageDialog::onOK() { if ( mExistingProjects.contains( mCboProject->currentText() ) ) { - int res = QMessageBox::question( this, tr( "Overwrite project" ), - tr( "A project with the same name already exists. Would you like to overwrite it?" ), - QMessageBox::Yes | QMessageBox::No ); + int res = QMessageBox::question( this, tr( "Overwrite project" ), tr( "A project with the same name already exists. Would you like to overwrite it?" ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) return; } @@ -169,9 +167,7 @@ void QgsPostgresProjectStorageDialog::projectChanged() void QgsPostgresProjectStorageDialog::removeProject() { - int res = QMessageBox::question( this, tr( "Remove project" ), - tr( "Do you really want to remove the project \"%1\"?" ).arg( mCboProject->currentText() ), - QMessageBox::Yes | QMessageBox::No ); + int res = QMessageBox::question( this, tr( "Remove project" ), tr( "Do you really want to remove the project \"%1\"?" ).arg( mCboProject->currentText() ), QMessageBox::Yes | QMessageBox::No ); if ( res != QMessageBox::Yes ) return; diff --git a/src/providers/postgres/qgspostgresprojectstoragedialog.h b/src/providers/postgres/qgspostgresprojectstoragedialog.h index 5276ce7d07e4..0466f1a3f521 100644 --- a/src/providers/postgres/qgspostgresprojectstoragedialog.h +++ b/src/providers/postgres/qgspostgresprojectstoragedialog.h @@ -42,8 +42,7 @@ class QgsPostgresProjectStorageDialog : public QDialog, private Ui::QgsPostgresP void removeProject(); private: - - bool mSaving = false; //!< Whether using this dialog for loading or saving a project + bool mSaving = false; //!< Whether using this dialog for loading or saving a project QAction *mActionRemoveProject = nullptr; QStringList mExistingProjects; }; diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index 6cbd02377558..f104603ffb9d 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -78,7 +78,7 @@ static bool columnExists( QgsPostgresConn &conn, const QString &table, const QSt } QgsPostgresPrimaryKeyType -QgsPostgresProvider::pkType( const QgsField &f ) const + QgsPostgresProvider::pkType( const QgsField &f ) const { switch ( f.type() ) { @@ -99,13 +99,10 @@ QgsPostgresProvider::pkType( const QgsField &f ) const } - -QgsPostgresProvider::QgsPostgresProvider( QString const &uri, const ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) +QgsPostgresProvider::QgsPostgresProvider( QString const &uri, const ProviderOptions &options, Qgis::DataProviderReadFlags flags ) : QgsVectorDataProvider( uri, options, flags ) , mShared( new QgsPostgresSharedData ) { - QgsDebugMsgLevel( QStringLiteral( "URI: %1 " ).arg( uri ), 2 ); mUri = QgsDataSourceUri( uri ); @@ -126,8 +123,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const &uri, const ProviderOpti const QString checkUnicityKey { QStringLiteral( "checkPrimaryKeyUnicity" ) }; if ( mUri.hasParam( checkUnicityKey ) ) { - - if ( mUri.param( checkUnicityKey ).compare( QLatin1String( "0" ) ) == 0 ) + if ( mUri.param( checkUnicityKey ).compare( QLatin1String( "0" ) ) == 0 ) { mCheckPrimaryKeyUnicity = false; } @@ -151,8 +147,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const &uri, const ProviderOpti { mIsQuery = false; - setQuery( ( !mSchemaName.isEmpty() ? quotedIdentifier( mSchemaName ) + '.' : QString() ) - + ( !mTableName.isEmpty() ? quotedIdentifier( mTableName ) : QString() ) ); + setQuery( ( !mSchemaName.isEmpty() ? quotedIdentifier( mSchemaName ) + '.' : QString() ) + ( !mTableName.isEmpty() ? quotedIdentifier( mTableName ) : QString() ) ); } mUseEstimatedMetadata = mUri.useEstimatedMetadata(); @@ -224,7 +219,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const &uri, const ProviderOpti // Try to load metadata const QString schemaQuery = QStringLiteral( "SELECT table_schema FROM information_schema.tables WHERE table_name = 'qgis_layer_metadata'" ); QgsPostgresResult res( mConnectionRO->LoggedPQexec( "QgsPostgresProvider", schemaQuery ) ); - if ( res.PQntuples( ) > 0 ) + if ( res.PQntuples() > 0 ) { const QString schemaName = res.PQgetvalue( 0, 0 ); // TODO: also filter CRS? @@ -238,10 +233,10 @@ QgsPostgresProvider::QgsPostgresProvider( QString const &uri, const ProviderOpti AND f_geometry_column %3 AND layer_type='vector' )SQL" ) - .arg( QgsPostgresConn::quotedValue( mUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( mUri.table() ) ) - .arg( mUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( mUri.geometryColumn() ) ) ) - .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ); + .arg( QgsPostgresConn::quotedValue( mUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( mUri.table() ) ) + .arg( mUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( mUri.geometryColumn() ) ) ) + .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ); QgsPostgresResult res( mConnectionRO->LoggedPQexec( "QgsPostgresProvider", selectQuery ) ); if ( res.PQntuples() > 0 ) @@ -418,8 +413,7 @@ void QgsPostgresProvider::setTransaction( QgsTransaction *transaction ) QStringLiteral( "Set session role failed for ROLE %1" ) - .arg( quotedValue( sessionRole ) ) - , + .arg( quotedValue( sessionRole ) ), 2 ); } @@ -466,14 +460,16 @@ QString QgsPostgresProvider::geomAttrToString( const QVariant &attr, QgsPostgres int QgsPostgresProvider::crsToSrid( const QgsCoordinateReferenceSystem &crs, QgsPostgresConn *conn ) { int srid = -1; - if ( conn ) srid = conn->crsToSrid( crs ); + if ( conn ) + srid = conn->crsToSrid( crs ); return srid; } QgsCoordinateReferenceSystem QgsPostgresProvider::sridToCrs( int srid, QgsPostgresConn *conn ) { QgsCoordinateReferenceSystem crs; - if ( conn ) crs = conn->sridToCrs( srid ); + if ( conn ) + crs = conn->sridToCrs( srid ); return crs; } @@ -498,12 +494,12 @@ QString QgsPostgresProvider::quotedByteaValue( const QVariant &value ) return QStringLiteral( "NULL" ); const QByteArray ba = value.toByteArray(); - const unsigned char *buf = reinterpret_cast< const unsigned char * >( ba.constData() ); + const unsigned char *buf = reinterpret_cast( ba.constData() ); QString param; param.reserve( ba.length() * 4 ); for ( int i = 0; i < ba.length(); ++i ) { - param += QStringLiteral( "\\%1" ).arg( static_cast< int >( buf[i] ), 3, 8, QChar( '0' ) ); + param += QStringLiteral( "\\%1" ).arg( static_cast( buf[i] ), 3, 8, QChar( '0' ) ); } return QStringLiteral( "decode('%1','escape')" ).arg( param ); } @@ -526,13 +522,13 @@ QgsFeatureIterator QgsPostgresProvider::getFeatures( const QgsFeatureRequest &re } - QString QgsPostgresProvider::pkParamWhereClause( int offset, const char *alias ) const { QString whereClause; QString aliased; - if ( alias ) aliased = QStringLiteral( "%1." ).arg( alias ); + if ( alias ) + aliased = QStringLiteral( "%1." ).arg( alias ); switch ( mPrimaryKeyType ) { @@ -651,8 +647,8 @@ QString QgsPostgresUtils::whereClause( QgsFeatureId featureId, const QgsFields & { case PktTid: whereClause = QStringLiteral( "ctid='(%1,%2)'" ) - .arg( FID_TO_NUMBER( featureId ) >> 16 ) - .arg( FID_TO_NUMBER( featureId ) & 0xffff ); + .arg( FID_TO_NUMBER( featureId ) >> 16 ) + .arg( FID_TO_NUMBER( featureId ) & 0xffff ); break; case PktOid: @@ -722,8 +718,7 @@ QString QgsPostgresUtils::whereClause( QgsFeatureId featureId, const QgsFields & QString QgsPostgresUtils::whereClause( const QgsFeatureIds &featureIds, const QgsFields &fields, QgsPostgresConn *conn, QgsPostgresPrimaryKeyType pkType, const QList &pkAttrs, const std::shared_ptr &sharedData ) { - auto lookupKeyWhereClause = [ = ] - { + auto lookupKeyWhereClause = [=] { if ( featureIds.isEmpty() ) return QString(); @@ -805,7 +800,7 @@ QString QgsPostgresUtils::andWhereClauses( const QString &c1, const QString &c2 void QgsPostgresUtils::replaceInvalidXmlChars( QString &xml ) { static const QRegularExpression replaceRe { QStringLiteral( "([\\x00-\\x08\\x0B-\\x1F\\x7F])" ) }; - QRegularExpressionMatchIterator it {replaceRe.globalMatch( xml ) }; + QRegularExpressionMatchIterator it { replaceRe.globalMatch( xml ) }; while ( it.hasNext() ) { const QRegularExpressionMatch match { it.next() }; @@ -817,7 +812,7 @@ void QgsPostgresUtils::replaceInvalidXmlChars( QString &xml ) void QgsPostgresUtils::restoreInvalidXmlChars( QString &xml ) { static const QRegularExpression replaceRe { QStringLiteral( R"raw(UTF-8\[(\d+)\])raw" ) }; - QRegularExpressionMatchIterator it {replaceRe.globalMatch( xml ) }; + QRegularExpressionMatchIterator it { replaceRe.globalMatch( xml ) }; while ( it.hasNext() ) { const QRegularExpressionMatch match { it.next() }; @@ -843,11 +838,7 @@ QString QgsPostgresProvider::filterWhereClause() const if ( !mRequestedSrid.isEmpty() && ( mRequestedSrid != mDetectedSrid || mRequestedSrid.toInt() == 0 ) ) { - where += delim + QStringLiteral( "%1(%2%3)=%4" ) - .arg( connectionRO()->majorVersion() < 2 ? "srid" : "st_srid", - quotedIdentifier( mGeometryColumn ), - mSpatialColType == SctGeography ? "::geography" : "", - mRequestedSrid ); + where += delim + QStringLiteral( "%1(%2%3)=%4" ).arg( connectionRO()->majorVersion() < 2 ? "srid" : "st_srid", quotedIdentifier( mGeometryColumn ), mSpatialColType == SctGeography ? "::geography" : "", mRequestedSrid ); delim = QStringLiteral( " AND " ); } @@ -909,7 +900,7 @@ QString QgsPostgresProvider::endianString() return QStringLiteral( "NDR" ); case QgsApplication::XDR: return QStringLiteral( "XDR" ); - default : + default: return QStringLiteral( "Unknown" ); } } @@ -917,15 +908,14 @@ QString QgsPostgresProvider::endianString() struct PGTypeInfo { - QString typeName; - QString typeType; - QString typeElem; - int typeLen; + QString typeName; + QString typeType; + QString typeElem; + int typeLen; }; bool QgsPostgresProvider::loadFields() { - // Clear cached information about enum values support mShared->clearSupportsEnumValuesCache(); @@ -942,7 +932,7 @@ bool QgsPostgresProvider::loadFields() sql = QStringLiteral( "SELECT description FROM pg_description WHERE objoid=regclass(%1)::oid AND objsubid=0" ).arg( quotedValue( mQuery ) ); QgsPostgresResult tresult( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); - if ( ! tresult.result() ) + if ( !tresult.result() ) { throw PGException( tresult ); } @@ -961,9 +951,9 @@ bool QgsPostgresProvider::loadFields() QgsPostgresResult result( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); - QMap > fmtFieldTypeMap, descrMap, defValMap, identityMap, generatedMap; - QMap > attTypeIdMap; - QMap > notNullMap, uniqueMap; + QMap> fmtFieldTypeMap, descrMap, defValMap, identityMap, generatedMap; + QMap> attTypeIdMap; + QMap> notNullMap, uniqueMap; if ( result.PQnfields() > 0 ) { // Collect attribute oids @@ -1006,13 +996,12 @@ bool QgsPostgresProvider::loadFields() " LEFT OUTER JOIN ( SELECT DISTINCT indrelid, indkey, indisunique FROM pg_index WHERE indisunique ) uniq ON attrelid=indrelid AND attnum::text=indkey::text " " WHERE attrelid IN %3" - ).arg( connectionRO()->pgVersion() >= 100000 ? QStringLiteral( ", attidentity" ) : QString(), - connectionRO()->pgVersion() >= 120000 ? QStringLiteral( ", attgenerated" ) : QString(), - tableoidsFilter ); + ) + .arg( connectionRO()->pgVersion() >= 100000 ? QStringLiteral( ", attidentity" ) : QString(), connectionRO()->pgVersion() >= 120000 ? QStringLiteral( ", attgenerated" ) : QString(), tableoidsFilter ); QgsPostgresResult fmtFieldTypeResult( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); - if ( ! fmtFieldTypeResult.result() ) + if ( !fmtFieldTypeResult.result() ) { throw PGException( fmtFieldTypeResult ); } @@ -1069,8 +1058,7 @@ bool QgsPostgresProvider::loadFields() QMap typeMap; for ( int i = 0; i < typeResult.PQntuples(); ++i ) { - PGTypeInfo typeInfo = - { + PGTypeInfo typeInfo = { /* typeName = */ typeResult.PQgetvalue( i, 1 ), /* typeType = */ typeResult.PQgetvalue( i, 2 ), /* typeElem = */ typeResult.PQgetvalue( i, 3 ), @@ -1142,15 +1130,13 @@ bool QgsPostgresProvider::loadFields() fieldSize = -1; fieldPrec = 0; } - else if ( fieldTypeName == QLatin1String( "int2" ) || fieldTypeName == QLatin1String( "int4" ) || - fieldTypeName == QLatin1String( "oid" ) || fieldTypeName == QLatin1String( "serial" ) ) + else if ( fieldTypeName == QLatin1String( "int2" ) || fieldTypeName == QLatin1String( "int4" ) || fieldTypeName == QLatin1String( "oid" ) || fieldTypeName == QLatin1String( "serial" ) ) { fieldType = QMetaType::Type::Int; fieldSize = -1; fieldPrec = 0; } - else if ( fieldTypeName == QLatin1String( "real" ) || fieldTypeName == QLatin1String( "double precision" ) || - fieldTypeName == QLatin1String( "float4" ) || fieldTypeName == QLatin1String( "float8" ) ) + else if ( fieldTypeName == QLatin1String( "real" ) || fieldTypeName == QLatin1String( "double precision" ) || fieldTypeName == QLatin1String( "float4" ) || fieldTypeName == QLatin1String( "float8" ) ) { fieldType = QMetaType::Type::Double; fieldSize = -1; @@ -1176,10 +1162,7 @@ bool QgsPostgresProvider::loadFields() } else if ( formattedFieldType != QLatin1String( "numeric" ) ) { - QgsMessageLog::logMessage( tr( "Unexpected formatted field type '%1' for field %2" ) - .arg( formattedFieldType, - fieldName ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Unexpected formatted field type '%1' for field %2" ).arg( formattedFieldType, fieldName ), tr( "PostGIS" ) ); fieldSize = -1; fieldPrec = 0; } @@ -1226,20 +1209,7 @@ bool QgsPostgresProvider::loadFields() fieldType = QMetaType::Type::QByteArray; fieldSize = -1; } - else if ( fieldTypeName == QLatin1String( "text" ) || - fieldTypeName == QLatin1String( "citext" ) || - fieldTypeName == QLatin1String( "geography" ) || - fieldTypeName == QLatin1String( "inet" ) || - fieldTypeName == QLatin1String( "cidr" ) || - fieldTypeName == QLatin1String( "macaddr" ) || - fieldTypeName == QLatin1String( "macaddr8" ) || - fieldTypeName == QLatin1String( "ltree" ) || - fieldTypeName == QLatin1String( "uuid" ) || - fieldTypeName == QLatin1String( "xml" ) || - fieldTypeName == QLatin1String( "bit" ) || - fieldTypeName == QLatin1String( "varbit" ) || - fieldTypeName.startsWith( QLatin1String( "time" ) ) || - fieldTypeName.startsWith( QLatin1String( "date" ) ) ) + else if ( fieldTypeName == QLatin1String( "text" ) || fieldTypeName == QLatin1String( "citext" ) || fieldTypeName == QLatin1String( "geography" ) || fieldTypeName == QLatin1String( "inet" ) || fieldTypeName == QLatin1String( "cidr" ) || fieldTypeName == QLatin1String( "macaddr" ) || fieldTypeName == QLatin1String( "macaddr8" ) || fieldTypeName == QLatin1String( "ltree" ) || fieldTypeName == QLatin1String( "uuid" ) || fieldTypeName == QLatin1String( "xml" ) || fieldTypeName == QLatin1String( "bit" ) || fieldTypeName == QLatin1String( "varbit" ) || fieldTypeName.startsWith( QLatin1String( "time" ) ) || fieldTypeName.startsWith( QLatin1String( "date" ) ) ) { fieldType = QMetaType::Type::QString; fieldSize = -1; @@ -1265,8 +1235,7 @@ bool QgsPostgresProvider::loadFields() else { QgsDebugError( QStringLiteral( "Unexpected formatted field type '%1' for field %2" ) - .arg( formattedFieldType, - fieldName ) ); + .arg( formattedFieldType, fieldName ) ); fieldSize = -1; fieldPrec = 0; } @@ -1284,13 +1253,12 @@ bool QgsPostgresProvider::loadFields() else { QgsMessageLog::logMessage( tr( "Unexpected formatted field type '%1' for field %2" ) - .arg( formattedFieldType, - fieldName ) ); + .arg( formattedFieldType, fieldName ) ); fieldSize = -1; fieldPrec = 0; } } - else if ( fieldTypeName == QLatin1String( "hstore" ) || fieldTypeName == QLatin1String( "json" ) || fieldTypeName == QLatin1String( "jsonb" ) ) + else if ( fieldTypeName == QLatin1String( "hstore" ) || fieldTypeName == QLatin1String( "json" ) || fieldTypeName == QLatin1String( "jsonb" ) ) { fieldType = QMetaType::Type::QVariantMap; fieldSubType = QMetaType::Type::QString; @@ -1312,7 +1280,7 @@ bool QgsPostgresProvider::loadFields() { // be tolerant in case of views: this might be a field used as a key const Qgis::PostgresRelKind type = relkind(); - if ( ( type == Qgis::PostgresRelKind::View || type == Qgis::PostgresRelKind::MaterializedView ) && parseUriKey( mUri.keyColumn( ) ).contains( fieldName ) ) + if ( ( type == Qgis::PostgresRelKind::View || type == Qgis::PostgresRelKind::MaterializedView ) && parseUriKey( mUri.keyColumn() ).contains( fieldName ) ) { // Assume it is convertible to text fieldType = QMetaType::Type::QString; @@ -1355,7 +1323,7 @@ bool QgsPostgresProvider::loadFields() { QgsMessageLog::logMessage( tr( "Duplicate field %1 found\n" ).arg( fieldName ), tr( "PostGIS" ) ); // In case of read-only query layers we can safely ignore the issue and rename the duplicated field - if ( ! mIsQuery ) + if ( !mIsQuery ) { return false; } @@ -1365,7 +1333,7 @@ bool QgsPostgresProvider::loadFields() while ( i < std::numeric_limits::max() ) { const QString newName { QStringLiteral( "%1 (%2)" ).arg( fieldName ).arg( ++i ) }; - if ( ! fields.contains( newName ) ) + if ( !fields.contains( newName ) ) { fieldName = newName; break; @@ -1384,14 +1352,14 @@ bool QgsPostgresProvider::loadFields() // If this is an identity field with constraints and there is no default, let's look for a sequence: // we might have a default value created by a sequence named __seq - if ( ! identityMap[tableoid ][ attnum ].isEmpty() - && notNullMap[tableoid][ attnum ] + if ( !identityMap[tableoid][attnum].isEmpty() + && notNullMap[tableoid][attnum] && uniqueMap[tableoid][attnum] && defValMap[tableoid][attnum].isEmpty() ) { const QString seqSql = QStringLiteral( "SELECT pg_get_serial_sequence(%1, %2)" ) - .arg( quotedValue( mQuery ) ) - .arg( quotedValue( fieldName ) ); + .arg( quotedValue( mQuery ) ) + .arg( quotedValue( fieldName ) ); QgsPostgresResult seqResult( connectionRO()->PQexec( seqSql ) ); if ( seqResult.PQntuples() == 1 && !seqResult.PQgetisnull( 0, 0 ) ) { @@ -1431,7 +1399,7 @@ bool QgsPostgresProvider::loadFields() void QgsPostgresProvider::setEditorWidgets() { - if ( ! tableExists( *connectionRO(), EDITOR_WIDGET_STYLES_TABLE ) ) + if ( !tableExists( *connectionRO(), EDITOR_WIDGET_STYLES_TABLE ) ) { return; } @@ -1451,13 +1419,13 @@ void QgsPostgresProvider::setEditorWidgets() const QString sql = QStringLiteral( "SELECT field_name, type, config " "FROM %1 WHERE schema_name = %2 " "AND table_name = %3 " - "AND field_name IN ( %4 )" ) . - arg( EDITOR_WIDGET_STYLES_TABLE, quotedValue( mSchemaName ), - quotedValue( mTableName ), quotedFnames.join( "," ) ); + "AND field_name IN ( %4 )" ) + .arg( EDITOR_WIDGET_STYLES_TABLE, quotedValue( mSchemaName ), quotedValue( mTableName ), quotedFnames.join( "," ) ); QgsPostgresResult result( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); for ( int i = 0; i < result.PQntuples(); ++i ) { - if ( result.PQgetisnull( i, 2 ) ) continue; // config can be null and it's OK + if ( result.PQgetisnull( i, 2 ) ) + continue; // config can be null and it's OK const QString &configTxt = result.PQgetvalue( i, 2 ); const QString &type = result.PQgetvalue( i, 1 ); @@ -1472,7 +1440,8 @@ void QgsPostgresProvider::setEditorWidgets() { QgsMessageLog::logMessage( tr( "Cannot parse widget configuration for field %1.%2.%3\n" ) - .arg( mSchemaName, mTableName, fname ), tr( "PostGIS" ) + .arg( mSchemaName, mTableName, fname ), + tr( "PostGIS" ) ); continue; } @@ -1502,7 +1471,6 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities() if ( !mIsQuery ) { - // postgres has fast access to features at id (thanks to primary key / unique index) // the latter flag is here just for compatibility if ( !mSelectAtIdDisabled ) @@ -1515,7 +1483,8 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities() "has_table_privilege(%1,'SELECT')," // 0 (select priv) "pg_is_in_recovery()," // 1 (in recovery) "current_schema() " // 2 (current schema) - ).arg( quotedValue( mQuery ) ); + ) + .arg( quotedValue( mQuery ) ); if ( connectionRO()->pgVersion() >= 80400 ) @@ -1525,13 +1494,8 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities() ",has_table_privilege(%1,'DELETE')" // 4 (delete priv) ",has_any_column_privilege(%1,'UPDATE')" // 5 (update priv) ",%2" // 6 (geom upd priv) - ).arg( quotedValue( mQuery ), - mGeometryColumn.isNull() - ? QStringLiteral( "'f'" ) - : QStringLiteral( "has_column_privilege(%1,%2,'UPDATE')" ) - .arg( quotedValue( mQuery ), - quotedValue( mGeometryColumn ) ) - ); + ) + .arg( quotedValue( mQuery ), mGeometryColumn.isNull() ? QStringLiteral( "'f'" ) : QStringLiteral( "has_column_privilege(%1,%2,'UPDATE')" ).arg( quotedValue( mQuery ), quotedValue( mGeometryColumn ) ) ); } else { @@ -1540,25 +1504,21 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities() ",has_table_privilege(%1,'DELETE')" // 4 (delete priv) ",has_table_privilege(%1,'UPDATE')" // 5 (update priv) ",has_table_privilege(%1,'UPDATE')" // 6 (geom col priv) - ).arg( quotedValue( mQuery ) ); + ) + .arg( quotedValue( mQuery ) ); } testAccess = connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ); if ( testAccess.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( tr( "Unable to determine table access privileges for the %1 relation.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mQuery, - testAccess.PQresultErrorMessage(), - sql ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Unable to determine table access privileges for the %1 relation.\nThe error message from the database was:\n%2.\nSQL: %3" ).arg( mQuery, testAccess.PQresultErrorMessage(), sql ), tr( "PostGIS" ) ); return false; } if ( testAccess.PQgetvalue( 0, 0 ) != QLatin1String( "t" ) ) { // SELECT - QgsMessageLog::logMessage( tr( "User has no SELECT privilege on %1 relation." ) - .arg( mQuery ), tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "User has no SELECT privilege on %1 relation." ).arg( mQuery ), tr( "PostGIS" ) ); return false; } @@ -1609,9 +1569,7 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities() "pg_class.relnamespace=pg_namespace.oid AND " "%3 AND " "relname=%1 AND nspname=%2" ) - .arg( quotedValue( mTableName ), - quotedValue( mSchemaName ), - connectionRO()->pgVersion() < 80100 ? "pg_get_userbyid(relowner)=current_user" : "pg_has_role(relowner,'MEMBER')" ); + .arg( quotedValue( mTableName ), quotedValue( mSchemaName ), connectionRO()->pgVersion() < 80100 ? "pg_get_userbyid(relowner)=current_user" : "pg_has_role(relowner,'MEMBER')" ); testAccess = connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ); if ( testAccess.PQresultStatus() == PGRES_TUPLES_OK && testAccess.PQntuples() == 1 ) { @@ -1638,22 +1596,18 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities() QString pattern = QStringLiteral( "(\\\"?)%1\\1" ).arg( QgsStringUtils::qRegExpEscape( alias ) ); regex.setPattern( pattern ); regex.setPatternOptions( QRegularExpression::CaseInsensitiveOption ); - } - while ( mQuery.contains( regex ) ); + } while ( mQuery.contains( regex ) ); // convert the custom query into a subquery setQuery( QStringLiteral( "%1 AS %2" ) - .arg( mQuery, - quotedIdentifier( alias ) ) ); + .arg( mQuery, quotedIdentifier( alias ) ) ); QString sql = QStringLiteral( "SELECT * FROM %1 LIMIT 1" ).arg( mQuery ); testAccess = connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ); if ( testAccess.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( testAccess.PQresultErrorMessage(), - sql ), tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Unable to execute the query.\nThe error message from the database was:\n%1.\nSQL: %2" ).arg( testAccess.PQresultErrorMessage(), sql ), tr( "PostGIS" ) ); return false; } @@ -1675,9 +1629,7 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities() // supports layer metadata mEnabledCapabilities |= Qgis::VectorProviderCapability::ReadLayerMetadata; - if ( ( mEnabledCapabilities & Qgis::VectorProviderCapability::ChangeGeometries ) && - ( mEnabledCapabilities & Qgis::VectorProviderCapability::ChangeAttributeValues ) && - mSpatialColType != SctTopoGeometry ) + if ( ( mEnabledCapabilities & Qgis::VectorProviderCapability::ChangeGeometries ) && ( mEnabledCapabilities & Qgis::VectorProviderCapability::ChangeAttributeValues ) && mSpatialColType != SctTopoGeometry ) { mEnabledCapabilities |= Qgis::VectorProviderCapability::ChangeFeatures; } @@ -1848,7 +1800,7 @@ bool QgsPostgresProvider::determinePrimaryKey() QgsFieldConstraints constraints = mAttributeFields.at( mPrimaryKeyAttrs[0] ).constraints(); constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); - mAttributeFields[ mPrimaryKeyAttrs[0] ].setConstraints( constraints ); + mAttributeFields[mPrimaryKeyAttrs[0]].setConstraints( constraints ); } mValid = mPrimaryKeyType != PktUnknown; @@ -1859,7 +1811,8 @@ bool QgsPostgresProvider::determinePrimaryKey() /* static */ QStringList QgsPostgresProvider::parseUriKey( const QString &key ) { - if ( key.isEmpty() ) return QStringList(); + if ( key.isEmpty() ) + return QStringList(); QStringList cols; @@ -1975,9 +1928,7 @@ bool QgsPostgresProvider::uniqueData( const QString "edColNames ) { // Check to see if the given columns contain unique data QString sql = QStringLiteral( "SELECT count(distinct (%1))=count((%1)) FROM %2%3" ) - .arg( quotedColNames, - mQuery, - filterWhereClause() ); + .arg( quotedColNames, mQuery, filterWhereClause() ); QgsPostgresResult unique( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); @@ -1997,8 +1948,7 @@ QVariant QgsPostgresProvider::minimumValue( int index ) const // get the field name QgsField fld = field( index ); QString sql = QStringLiteral( "SELECT min(%1) AS %1 FROM %2" ) - .arg( quotedIdentifier( fld.name() ), - mQuery ); + .arg( quotedIdentifier( fld.name() ), mQuery ); if ( !mSqlWhereClause.isEmpty() ) { @@ -2026,8 +1976,7 @@ QSet QgsPostgresProvider::uniqueValues( int index, int limit ) const // get the field name QgsField fld = field( index ); QString sql = QStringLiteral( "SELECT DISTINCT %1 FROM %2" ) - .arg( quotedIdentifier( fld.name() ), - mQuery ); + .arg( quotedIdentifier( fld.name() ), mQuery ); if ( !mSqlWhereClause.isEmpty() ) { @@ -2065,8 +2014,7 @@ QStringList QgsPostgresProvider::uniqueStringsMatching( int index, const QString // get the field name QgsField fld = field( index ); QString sql = QStringLiteral( "SELECT DISTINCT %1 FROM %2 WHERE" ) - .arg( quotedIdentifier( fld.name() ), - mQuery ); + .arg( quotedIdentifier( fld.name() ), mQuery ); if ( !mSqlWhereClause.isEmpty() ) { @@ -2104,15 +2052,14 @@ QStringList QgsPostgresProvider::uniqueStringsMatching( int index, const QString void QgsPostgresProvider::enumValues( int index, QStringList &enumList ) const { - if ( index < 0 || index >= mAttributeFields.count() ) return; - if ( ! mShared->fieldSupportsEnumValuesIsSet( index ) ) + if ( !mShared->fieldSupportsEnumValuesIsSet( index ) ) { mShared->setFieldSupportsEnumValues( index, true ); } - else if ( ! mShared->fieldSupportsEnumValues( index ) ) + else if ( !mShared->fieldSupportsEnumValues( index ) ) { return; } @@ -2157,8 +2104,7 @@ bool QgsPostgresProvider::parseEnumRange( QStringList &enumValues, const QString enumValues.clear(); QString enumRangeSql = QStringLiteral( "SELECT enumlabel FROM pg_catalog.pg_enum WHERE enumtypid=(SELECT atttypid::regclass FROM pg_attribute WHERE attrelid=%1::regclass AND attname=%2)" ) - .arg( quotedValue( mQuery ), - quotedValue( attributeName ) ); + .arg( quotedValue( mQuery ), quotedValue( attributeName ) ); QgsPostgresResult enumRangeRes( connectionRO()->LoggedPQexec( QStringLiteral( "QgsPostgresProvider" ), enumRangeSql ) ); if ( enumRangeRes.PQresultStatus() != PGRES_TUPLES_OK ) return false; @@ -2184,33 +2130,31 @@ bool QgsPostgresProvider::parseDomainCheckConstraint( QStringList &enumValues, c if ( connectionRO()->pgVersion() < 120000 ) { domainCheckDefinitionSql = QStringLiteral( "" - "SELECT consrc FROM pg_constraint " - " WHERE contypid =(" - " SELECT oid FROM pg_type " - " WHERE typname = %1 " - " AND typnamespace =(" - " SELECT oid FROM pg_namespace WHERE nspname = %2" - " )" - " )" ) - .arg( quotedValue( domainResult.PQgetvalue( 0, 0 ) ) ) - .arg( quotedValue( domainResult.PQgetvalue( 0, 1 ) ) ); - + "SELECT consrc FROM pg_constraint " + " WHERE contypid =(" + " SELECT oid FROM pg_type " + " WHERE typname = %1 " + " AND typnamespace =(" + " SELECT oid FROM pg_namespace WHERE nspname = %2" + " )" + " )" ) + .arg( quotedValue( domainResult.PQgetvalue( 0, 0 ) ) ) + .arg( quotedValue( domainResult.PQgetvalue( 0, 1 ) ) ); } else { domainCheckDefinitionSql = QStringLiteral( "" - "SELECT pg_catalog.pg_get_constraintdef( ( " - " SELECT oid FROM pg_constraint WHERE contypid = ( " - " SELECT oid FROM pg_type " - " WHERE typname = %1 " - " AND typnamespace =(" - " SELECT oid FROM pg_namespace WHERE nspname = %2" - " )" - " )" - " ), true );" ) - .arg( quotedValue( domainResult.PQgetvalue( 0, 0 ) ) ) - .arg( quotedValue( domainResult.PQgetvalue( 0, 1 ) ) ); - + "SELECT pg_catalog.pg_get_constraintdef( ( " + " SELECT oid FROM pg_constraint WHERE contypid = ( " + " SELECT oid FROM pg_type " + " WHERE typname = %1 " + " AND typnamespace =(" + " SELECT oid FROM pg_namespace WHERE nspname = %2" + " )" + " )" + " ), true );" ) + .arg( quotedValue( domainResult.PQgetvalue( 0, 0 ) ) ) + .arg( quotedValue( domainResult.PQgetvalue( 0, 1 ) ) ); } QgsPostgresResult domainCheckRes( connectionRO()->LoggedPQexec( QStringLiteral( "QgsPostgresProvider" ), domainCheckDefinitionSql ) ); @@ -2261,8 +2205,7 @@ QVariant QgsPostgresProvider::maximumValue( int index ) const // get the field name QgsField fld = field( index ); QString sql = QStringLiteral( "SELECT max(%1) AS %1 FROM %2" ) - .arg( quotedIdentifier( fld.name() ), - mQuery ); + .arg( quotedIdentifier( fld.name() ), mQuery ); if ( !mSqlWhereClause.isEmpty() ) { @@ -2395,9 +2338,7 @@ bool QgsPostgresProvider::getTopoLayerInfo() WHERE l.schema_name=%1 AND l.table_name=%2 AND l.feature_column=%3 )SQL" ) - .arg( quotedValue( mSchemaName ), - quotedValue( mTableName ), - quotedValue( mGeometryColumn ) ); + .arg( quotedValue( mSchemaName ), quotedValue( mTableName ), quotedValue( mGeometryColumn ) ); QgsPostgresResult result( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { @@ -2405,11 +2346,7 @@ bool QgsPostgresProvider::getTopoLayerInfo() } if ( result.PQntuples() < 1 ) { - QgsMessageLog::logMessage( tr( "Could not find topology of layer %1.%2.%3" ) - .arg( quotedValue( mSchemaName ), - quotedValue( mTableName ), - quotedValue( mGeometryColumn ) ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Could not find topology of layer %1.%2.%3" ).arg( quotedValue( mSchemaName ), quotedValue( mTableName ), quotedValue( mGeometryColumn ) ), tr( "PostGIS" ) ); return false; } mTopoLayerInfo.topologyName = result.PQgetvalue( 0, 0 ); @@ -2439,12 +2376,9 @@ void QgsPostgresProvider::dropOrphanedTopoGeoms() { QString sql = QString( "DELETE FROM %1.relation WHERE layer_id = %2 AND " "topogeo_id NOT IN ( SELECT id(%3) FROM %4.%5 )" ) - .arg( quotedIdentifier( mTopoLayerInfo.topologyName ) ) - .arg( mTopoLayerInfo.layerId ) - .arg( quotedIdentifier( mGeometryColumn ), - quotedIdentifier( mSchemaName ), - quotedIdentifier( mTableName ) ) - ; + .arg( quotedIdentifier( mTopoLayerInfo.topologyName ) ) + .arg( mTopoLayerInfo.layerId ) + .arg( quotedIdentifier( mGeometryColumn ), quotedIdentifier( mSchemaName ), quotedIdentifier( mTableName ) ); QgsDebugMsgLevel( "TopoGeom orphans cleanup query: " + sql, 2 ); @@ -2473,10 +2407,9 @@ QString QgsPostgresProvider::geomParam( int offset ) const } geometry += QStringLiteral( "%1($%2%3,%4)" ) - .arg( connectionRO()->majorVersion() < 2 ? "geomfromwkb" : "st_geomfromwkb" ) - .arg( offset ) - .arg( connectionRO()->useWkbHex() ? "" : "::bytea", - mRequestedSrid.isEmpty() ? mDetectedSrid : mRequestedSrid ); + .arg( connectionRO()->majorVersion() < 2 ? "geomfromwkb" : "st_geomfromwkb" ) + .arg( offset ) + .arg( connectionRO()->useWkbHex() ? "" : "::bytea", mRequestedSrid.isEmpty() ? mDetectedSrid : mRequestedSrid ); if ( forceMulti ) { @@ -2486,8 +2419,8 @@ QString QgsPostgresProvider::geomParam( int offset ) const if ( mSpatialColType == SctTopoGeometry ) { geometry += QStringLiteral( ",%1,%2)" ) - .arg( quotedValue( mTopoLayerInfo.topologyName ) ) - .arg( mTopoLayerInfo.layerId ); + .arg( quotedValue( mTopoLayerInfo.topologyName ) ) + .arg( mTopoLayerInfo.layerId ); } return geometry; @@ -2540,8 +2473,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( ( mPrimaryKeyType == PktInt || mPrimaryKeyType == PktInt64 || mPrimaryKeyType == PktFidMap || mPrimaryKeyType == PktUint64 ) ) { - if ( mPrimaryKeyAttrs.size() == 1 && - defaultValueClause( mPrimaryKeyAttrs[0] ).startsWith( "nextval(" ) ) + if ( mPrimaryKeyAttrs.size() == 1 && defaultValueClause( mPrimaryKeyAttrs[0] ).startsWith( "nextval(" ) ) { bool foundNonEmptyPK = false; int idx = mPrimaryKeyAttrs[0]; @@ -2640,15 +2572,12 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags ) { QString val = geomAttrToString( v, connectionRO() ); values += QStringLiteral( "%1%2(%3)" ) - .arg( delim, - connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt", - quotedValue( val ) ); + .arg( delim, connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt", quotedValue( val ) ); } else if ( fieldTypeName == QLatin1String( "geography" ) ) { values += QStringLiteral( "%1st_geographyfromtext(%2)" ) - .arg( delim, - quotedValue( v.toString() ) ); + .arg( delim, quotedValue( v.toString() ) ); } else if ( fieldTypeName == QLatin1String( "jsonb" ) ) { @@ -2674,21 +2603,20 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( fieldTypeName == QLatin1String( "geometry" ) ) { values += QStringLiteral( "%1%2($%3)" ) - .arg( delim, - connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt" ) - .arg( defaultValues.size() + offset ); + .arg( delim, connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt" ) + .arg( defaultValues.size() + offset ); } else if ( fieldTypeName == QLatin1String( "geography" ) ) { values += QStringLiteral( "%1st_geographyfromtext($%2)" ) - .arg( delim ) - .arg( defaultValues.size() + offset ); + .arg( delim ) + .arg( defaultValues.size() + offset ); } else { values += QStringLiteral( "%1$%2" ) - .arg( delim ) - .arg( defaultValues.size() + offset ); + .arg( delim ) + .arg( defaultValues.size() + offset ); } defaultValues.append( defVal ); fieldId.append( idx ); @@ -2741,7 +2669,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( QgsVariantUtils::isNull( value ) ) { QgsField fld = field( attrIdx ); - v = paramValue( defaultValues[ i ], defaultValues[ i ] ); + v = paramValue( defaultValues[i], defaultValues[i] ); features->setAttribute( attrIdx, convertValue( fld.type(), fld.subType(), v, fld.typeName() ) ); } else @@ -2763,7 +2691,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags ) } else { - v = paramValue( value.toString(), defaultValues[ i ] ); + v = paramValue( value.toString(), defaultValues[i] ); } if ( v != value.toString() ) @@ -2883,7 +2811,7 @@ bool QgsPostgresProvider::deleteFeatures( const QgsFeatureIds &ids ) continue; const QString sql = QStringLiteral( "DELETE FROM %1 WHERE %2" ) - .arg( mQuery, whereClause( chunkIds ) ); + .arg( mQuery, whereClause( chunkIds ) ); QgsDebugMsgLevel( "delete sql: " + sql, 2 ); //send DELETE statement and do error handling @@ -3035,9 +2963,7 @@ bool QgsPostgresProvider::addAttributes( const QList &attributes ) if ( !iter->comment().isEmpty() ) { sql = QStringLiteral( "COMMENT ON COLUMN %1.%2 IS %3" ) - .arg( mQuery, - quotedIdentifier( iter->name() ), - quotedValue( iter->comment() ) ); + .arg( mQuery, quotedIdentifier( iter->name() ), quotedValue( iter->comment() ) ); result = conn->LoggedPQexec( "QgsPostgresProvider", sql ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) throw PGException( result ); @@ -3089,8 +3015,7 @@ bool QgsPostgresProvider::deleteAttributes( const QgsAttributeIds &ids ) QString column = mAttributeFields.at( index ).name(); QString sql = QStringLiteral( "ALTER TABLE %1 DROP COLUMN %2" ) - .arg( mQuery, - quotedIdentifier( column ) ); + .arg( mQuery, quotedIdentifier( column ) ); //send sql statement and do error handling QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresProvider", sql ) ); @@ -3143,9 +3068,7 @@ bool QgsPostgresProvider::renameAttributes( const QgsFieldNameMap &renamedAttrib } sql += QStringLiteral( "ALTER TABLE %1 RENAME COLUMN %2 TO %3;" ) - .arg( mQuery, - quotedIdentifier( mAttributeFields.at( fieldIndex ).name() ), - quotedIdentifier( renameIt.value() ) ); + .arg( mQuery, quotedIdentifier( mAttributeFields.at( fieldIndex ).name() ), quotedIdentifier( renameIt.value() ) ); } sql += QLatin1String( "COMMIT;" ); @@ -3248,23 +3171,22 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap & QString val = geomAttrToString( siter.value(), connectionRO() ); sql += QStringLiteral( "%1(%2)" ) - .arg( connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt", - quotedValue( val ) ); + .arg( connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt", quotedValue( val ) ); } else if ( fld.typeName() == QLatin1String( "geography" ) ) { sql += QStringLiteral( "st_geographyfromtext(%1)" ) - .arg( quotedValue( siter->toString() ) ); + .arg( quotedValue( siter->toString() ) ); } else if ( fld.typeName() == QLatin1String( "jsonb" ) ) { sql += QStringLiteral( "%1::jsonb" ) - .arg( quotedJsonValue( siter.value() ) ); + .arg( quotedJsonValue( siter.value() ) ); } else if ( fld.typeName() == QLatin1String( "json" ) ) { sql += QStringLiteral( "%1::json" ) - .arg( quotedJsonValue( siter.value() ) ); + .arg( quotedJsonValue( siter.value() ) ); } else if ( fld.typeName() == QLatin1String( "bytea" ) ) { @@ -3310,7 +3232,7 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap & if ( !attrs.contains( idx ) ) continue; - k[i] = attrs[ idx ]; + k[i] = attrs[idx]; } mShared->insertFid( fid, k ); @@ -3344,7 +3266,7 @@ void QgsPostgresProvider::appendGeomParam( const QgsGeometry &geom, QStringList const QgsGeometry convertedGeom( convertToProviderType( geom, wkbType() ) ); QByteArray wkb( !convertedGeom.isNull() ? convertedGeom.asWkb() : geom.asWkb() ); - const unsigned char *buf = reinterpret_cast< const unsigned char * >( wkb.constData() ); + const unsigned char *buf = reinterpret_cast( wkb.constData() ); int wkbSize = wkb.length(); for ( int i = 0; i < wkbSize; ++i ) @@ -3359,7 +3281,6 @@ void QgsPostgresProvider::appendGeomParam( const QgsGeometry &geom, QStringList bool QgsPostgresProvider::changeGeometryValues( const QgsGeometryMap &geometry_map ) { - if ( mIsQuery || mGeometryColumn.isNull() ) return false; @@ -3387,14 +3308,10 @@ bool QgsPostgresProvider::changeGeometryValues( const QgsGeometryMap &geometry_m // to avoid orphans and retain higher level in an eventual // hierarchical definition update = QStringLiteral( "SELECT id(%1) FROM %2 o WHERE %3" ) - .arg( geomParam( 1 ), - mQuery, - pkParamWhereClause( 2 ) ); + .arg( geomParam( 1 ), mQuery, pkParamWhereClause( 2 ) ); QString getid = QStringLiteral( "SELECT id(%1) FROM %2 WHERE %3" ) - .arg( quotedIdentifier( mGeometryColumn ), - mQuery, - pkParamWhereClause( 1 ) ); + .arg( quotedIdentifier( mGeometryColumn ), mQuery, pkParamWhereClause( 1 ) ); QgsDebugMsgLevel( "getting old topogeometry id: " + getid, 2 ); @@ -3402,33 +3319,31 @@ bool QgsPostgresProvider::changeGeometryValues( const QgsGeometryMap &geometry_m if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { QgsDebugError( QStringLiteral( "Exception thrown due to PQprepare of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" ) - .arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( getid ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_COMMAND_OK ) + .arg( getid ) ); throw PGException( result ); } QString replace = QString( "UPDATE %1 SET %2=" "( topology_id(%2),layer_id(%2),$1,type(%2) )" "WHERE %3" ) - .arg( mQuery, - quotedIdentifier( mGeometryColumn ), - pkParamWhereClause( 2 ) ); + .arg( mQuery, quotedIdentifier( mGeometryColumn ), pkParamWhereClause( 2 ) ); QgsDebugMsgLevel( "TopoGeom swap: " + replace, 2 ); result = conn->PQprepare( QStringLiteral( "replacetopogeom" ), replace, 2, nullptr, QStringLiteral( "QgsPostgresProvider" ), QGS_QUERY_LOG_ORIGIN ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { QgsDebugError( QStringLiteral( "Exception thrown due to PQprepare of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" ) - .arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( replace ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_COMMAND_OK ) + .arg( replace ) ); throw PGException( result ); } - } else { update = QStringLiteral( "UPDATE %1 SET %2=%3 WHERE %4" ) - .arg( mQuery, - quotedIdentifier( mGeometryColumn ), - geomParam( 1 ), - pkParamWhereClause( 2 ) ); + .arg( mQuery, quotedIdentifier( mGeometryColumn ), geomParam( 1 ), pkParamWhereClause( 2 ) ); } QgsDebugMsgLevel( "updating: " + update, 2 ); @@ -3437,7 +3352,9 @@ bool QgsPostgresProvider::changeGeometryValues( const QgsGeometryMap &geometry_m if ( result.PQresultStatus() != PGRES_COMMAND_OK && result.PQresultStatus() != PGRES_TUPLES_OK ) { QgsDebugError( QStringLiteral( "Exception thrown due to PQprepare of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" ) - .arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( update ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_COMMAND_OK ) + .arg( update ) ); throw PGException( result ); } @@ -3459,7 +3376,8 @@ bool QgsPostgresProvider::changeGeometryValues( const QgsGeometryMap &geometry_m if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { QgsDebugError( QStringLiteral( "Exception thrown due to PQexecPrepared of 'getid' returning != PGRES_TUPLES_OK (%1 != expected %2)" ) - .arg( result.PQresultStatus() ).arg( PGRES_TUPLES_OK ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_TUPLES_OK ) ); throw PGException( result ); } // TODO: watch out for NULL, handle somehow @@ -3484,29 +3402,33 @@ bool QgsPostgresProvider::changeGeometryValues( const QgsGeometryMap &geometry_m // definition and we'll leave no orphans QString replace = QString( "DELETE FROM %1.relation WHERE " "layer_id = %2 AND topogeo_id = %3" ) - .arg( quotedIdentifier( mTopoLayerInfo.topologyName ) ) - .arg( mTopoLayerInfo.layerId ) - .arg( old_tg_id ); + .arg( quotedIdentifier( mTopoLayerInfo.topologyName ) ) + .arg( mTopoLayerInfo.layerId ) + .arg( old_tg_id ); result = conn->LoggedPQexec( QStringLiteral( "QgsPostgresProvider" ), replace ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { QgsDebugError( QStringLiteral( "Exception thrown due to PQexec of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" ) - .arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( replace ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_COMMAND_OK ) + .arg( replace ) ); throw PGException( result ); } // TODO: use prepared query here replace = QString( "UPDATE %1.relation SET topogeo_id = %2 " "WHERE layer_id = %3 AND topogeo_id = %4" ) - .arg( quotedIdentifier( mTopoLayerInfo.topologyName ) ) - .arg( old_tg_id ) - .arg( mTopoLayerInfo.layerId ) - .arg( new_tg_id ); + .arg( quotedIdentifier( mTopoLayerInfo.topologyName ) ) + .arg( old_tg_id ) + .arg( mTopoLayerInfo.layerId ) + .arg( new_tg_id ); QgsDebugMsgLevel( "relation swap: " + replace, 2 ); result = conn->LoggedPQexec( QStringLiteral( "QgsPostgresProvider" ), replace ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { QgsDebugError( QStringLiteral( "Exception thrown due to PQexec of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" ) - .arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( replace ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_COMMAND_OK ) + .arg( replace ) ); throw PGException( result ); } } // if TopoGeometry @@ -3544,8 +3466,7 @@ bool QgsPostgresProvider::changeGeometryValues( const QgsGeometryMap &geometry_m return returnvalue; } -bool QgsPostgresProvider::changeFeatures( const QgsChangedAttributesMap &attr_map, - const QgsGeometryMap &geometry_map ) +bool QgsPostgresProvider::changeFeatures( const QgsChangedAttributesMap &attr_map, const QgsGeometryMap &geometry_map ) { Q_ASSERT( mSpatialColType != SctTopoGeometry ); @@ -3611,25 +3532,24 @@ bool QgsPostgresProvider::changeFeatures( const QgsChangedAttributesMap &attr_ma if ( fld.typeName() == QLatin1String( "geometry" ) ) { - QString val = geomAttrToString( siter.value(), connectionRO() ) ; + QString val = geomAttrToString( siter.value(), connectionRO() ); sql += QStringLiteral( "%1(%2)" ) - .arg( connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt", - quotedValue( val ) ); + .arg( connectionRO()->majorVersion() < 2 ? "geomfromewkt" : "st_geomfromewkt", quotedValue( val ) ); } else if ( fld.typeName() == QLatin1String( "geography" ) ) { sql += QStringLiteral( "st_geographyfromtext(%1)" ) - .arg( quotedValue( siter->toString() ) ); + .arg( quotedValue( siter->toString() ) ); } else if ( fld.typeName() == QLatin1String( "jsonb" ) ) { sql += QStringLiteral( "%1::jsonb" ) - .arg( quotedJsonValue( siter.value() ) ); + .arg( quotedJsonValue( siter.value() ) ); } else if ( fld.typeName() == QLatin1String( "json" ) ) { sql += QStringLiteral( "%1::json" ) - .arg( quotedJsonValue( siter.value() ) ); + .arg( quotedJsonValue( siter.value() ) ); } else if ( fld.typeName() == QLatin1String( "bytea" ) ) { @@ -3672,12 +3592,14 @@ bool QgsPostgresProvider::changeFeatures( const QgsChangedAttributesMap &attr_ma if ( result.PQresultStatus() != PGRES_COMMAND_OK && result.PQresultStatus() != PGRES_TUPLES_OK ) { QgsDebugError( QStringLiteral( "Exception thrown due to PQprepare of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" ) - .arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( sql ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_COMMAND_OK ) + .arg( sql ) ); throw PGException( result ); } QStringList params; - const QgsGeometry &geom = geometry_map[ fid ]; + const QgsGeometry &geom = geometry_map[fid]; appendGeomParam( geom, params ); result = conn->PQexecPrepared( QStringLiteral( "updatefeature" ), params, QStringLiteral( "QgsPostgresProvider" ), QGS_QUERY_LOG_ORIGIN ); @@ -3703,7 +3625,7 @@ bool QgsPostgresProvider::changeFeatures( const QgsChangedAttributesMap &attr_ma if ( !attrs.contains( idx ) ) continue; - k[i] = attrs[ idx ]; + k[i] = attrs[idx]; } mShared->insertFid( fid, k ); @@ -3836,7 +3758,7 @@ long long QgsPostgresProvider::featureCount() const return featuresCounted; // See: https://github.com/qgis/QGIS/issues/25285 - QGIS crashes on featureCount()) - if ( ! connectionRO() ) + if ( !connectionRO() ) { return 0; } @@ -3930,12 +3852,12 @@ bool QgsPostgresProvider::estimateExtent() const } QString sql = QStringLiteral( "SELECT %1(%2,%3,%4)" ) - .arg( - vmaj < 2 ? "estimated_extent" : ( vmaj == 2 && vmin < 1 ? "st_estimated_extent" : "st_estimatedextent" ), - quotedValue( mSchemaName ), - quotedValue( mTableName ), - quotedValue( mGeometryColumn ) - ); + .arg( + vmaj < 2 ? "estimated_extent" : ( vmaj == 2 && vmin < 1 ? "st_estimated_extent" : "st_estimatedextent" ), + quotedValue( mSchemaName ), + quotedValue( mTableName ), + quotedValue( mGeometryColumn ) + ); QgsPostgresResult result( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); @@ -3947,11 +3869,13 @@ bool QgsPostgresProvider::estimateExtent() const if ( result.PQntuples() != 1 ) { pushError( tr( "Unexpected number of tuples from estimated extent query %1: %2 (1 expected)." ) - .arg( sql ).arg( result.PQntuples() ) ); + .arg( sql ) + .arg( result.PQntuples() ) ); return false; } - if ( result.PQgetisnull( 0, 0 ) ) return false; + if ( result.PQgetisnull( 0, 0 ) ) + return false; QString box2dString = result.PQgetvalue( 0, 0 ); @@ -3959,18 +3883,18 @@ bool QgsPostgresProvider::estimateExtent() const const thread_local QRegularExpression rx2d( "\\((.+) (.+),(.+) (.+)\\)" ); const QRegularExpressionMatch match = rx2d.match( box2dString ); - if ( ! match.hasMatch() ) + if ( !match.hasMatch() ) { pushError( tr( "Unexpected format from estimated extent query %1: %2." ).arg( sql, box2dString ) ); return false; // throw instead ? } mLayerExtent.emplace( - match.captured( 1 ).toDouble(), // xmin - match.captured( 2 ).toDouble(), // ymin + match.captured( 1 ).toDouble(), // xmin + match.captured( 2 ).toDouble(), // ymin std::numeric_limits::quiet_NaN(), // zmin - match.captured( 3 ).toDouble(), // xmax - match.captured( 4 ).toDouble(), // ymax + match.captured( 3 ).toDouble(), // xmax + match.captured( 4 ).toDouble(), // ymax std::numeric_limits::quiet_NaN() // zmax ); @@ -3981,11 +3905,7 @@ bool QgsPostgresProvider::estimateExtent() const bool QgsPostgresProvider::computeExtent3D() const { QString sql = QStringLiteral( "SELECT %1(%2%3) FROM %4%5" ) - .arg( connectionRO()->majorVersion() < 2 ? "extent" : "ST_3DExtent", - quotedIdentifier( mBoundingBoxColumn ), - ( mSpatialColType == SctPcPatch || mSpatialColType == SctGeography ) ? "::geometry" : "", - mQuery, - filterWhereClause() ); + .arg( connectionRO()->majorVersion() < 2 ? "extent" : "ST_3DExtent", quotedIdentifier( mBoundingBoxColumn ), ( mSpatialColType == SctPcPatch || mSpatialColType == SctGeography ) ? "::geometry" : "", mQuery, filterWhereClause() ); QgsPostgresResult result( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); @@ -3998,7 +3918,8 @@ bool QgsPostgresProvider::computeExtent3D() const if ( result.PQntuples() != 1 ) { pushError( tr( "Unexpected number of tuples from compute extent query %1: %2 (1 expected)." ) - .arg( sql ).arg( result.PQntuples() ) ); + .arg( sql ) + .arg( result.PQntuples() ) ); return false; } @@ -4034,7 +3955,7 @@ bool QgsPostgresProvider::computeExtent3D() const match.captured( 6 ).toDouble() // zmax ); QgsDebugMsgLevel( "Set extents to computed 3D value: " + mLayerExtent->toString(), 2 ); - if ( ! elevationProperties()->containsElevationData() ) + if ( !elevationProperties()->containsElevationData() ) { // TODO: add a QgsBox3D::force2D method mLayerExtent->setZMinimum( std::numeric_limits::quiet_NaN() ); @@ -4050,11 +3971,11 @@ bool QgsPostgresProvider::computeExtent3D() const if ( match.hasMatch() ) { mLayerExtent.emplace( - match.captured( 1 ).toDouble(), // xmin - match.captured( 2 ).toDouble(), // ymin + match.captured( 1 ).toDouble(), // xmin + match.captured( 2 ).toDouble(), // ymin std::numeric_limits::quiet_NaN(), // zmin - match.captured( 3 ).toDouble(), // xmax - match.captured( 4 ).toDouble(), // ymax + match.captured( 3 ).toDouble(), // xmax + match.captured( 4 ).toDouble(), // ymax std::numeric_limits::quiet_NaN() // zmax ); QgsDebugMsgLevel( "Set extents to computed 2D value: " + mLayerExtent->toString(), 2 ); @@ -4070,13 +3991,16 @@ QgsBox3D QgsPostgresProvider::extent3D() const if ( !isValid() || mGeometryColumn.isNull() ) return QgsBox3D(); - if ( mLayerExtent.has_value() ) return *mLayerExtent; + if ( mLayerExtent.has_value() ) + return *mLayerExtent; // Return the estimated extents, if requested and possible - if ( mUseEstimatedMetadata ) estimateExtent(); + if ( mUseEstimatedMetadata ) + estimateExtent(); // Compute the extents, if estimation failed or was disabled - if ( ! mLayerExtent.has_value() ) computeExtent3D(); + if ( !mLayerExtent.has_value() ) + computeExtent3D(); if ( mLayerExtent.has_value() ) { @@ -4113,23 +4037,21 @@ bool QgsPostgresProvider::getGeometryDetails() // Trust the datasource config means that we used requested geometry type and srid // We only need to get the spatial column type - if ( ( mReadFlags & Qgis::DataProviderReadFlag::TrustDataSource ) && - mRequestedGeomType != Qgis::WkbType::Unknown && - !mRequestedSrid.isEmpty() ) + if ( ( mReadFlags & Qgis::DataProviderReadFlag::TrustDataSource ) && mRequestedGeomType != Qgis::WkbType::Unknown && !mRequestedSrid.isEmpty() ) { if ( mIsQuery ) { sql = QStringLiteral( "SELECT t.typname FROM pg_type t inner join (SELECT pg_typeof(%1) typeof FROM %2 LIMIT 1) g ON oid = g.typeof" - ).arg( quotedIdentifier( geomCol ), mQuery ); + ) + .arg( quotedIdentifier( geomCol ), mQuery ); } else { sql = QStringLiteral( "SELECT t.typname FROM pg_type t inner join (SELECT pg_typeof(%1) typeof FROM %2.%3 LIMIT 1) g ON oid = g.typeof" - ).arg( quotedIdentifier( geomCol ), - quotedIdentifier( schemaName ), - quotedIdentifier( tableName ) ); + ) + .arg( quotedIdentifier( geomCol ), quotedIdentifier( schemaName ), quotedIdentifier( tableName ) ); } QgsDebugMsgLevel( QStringLiteral( "Getting the spatial column type: %1" ).arg( sql ), 2 ); @@ -4152,7 +4074,7 @@ bool QgsPostgresProvider::getGeometryDetails() // Use requested geometry type and srid mDetectedGeomType = mRequestedGeomType; - mDetectedSrid = mRequestedSrid; + mDetectedSrid = mRequestedSrid; mValid = true; return true; } @@ -4229,9 +4151,7 @@ bool QgsPostgresProvider::getGeometryDetails() { // check geometry columns sql = QStringLiteral( "SELECT upper(type),srid,coord_dimension FROM geometry_columns WHERE f_table_name=%1 AND f_geometry_column=%2 AND f_table_schema=%3" ) - .arg( quotedValue( tableName ), - quotedValue( geomCol ), - quotedValue( schemaName ) ); + .arg( quotedValue( tableName ), quotedValue( geomCol ), quotedValue( schemaName ) ); QgsDebugMsgLevel( QStringLiteral( "Getting geometry column: %1" ).arg( sql ), 2 ); result = connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ); @@ -4254,7 +4174,8 @@ bool QgsPostgresProvider::getGeometryDetails() detectedType += QLatin1String( "ZM" ); QString ds = result.PQgetvalue( 0, 1 ); - if ( ds != QLatin1String( "0" ) ) detectedSrid = ds; + if ( ds != QLatin1String( "0" ) ) + detectedSrid = ds; mSpatialColType = SctGeometry; } else @@ -4266,9 +4187,7 @@ bool QgsPostgresProvider::getGeometryDetails() { // check geography columns sql = QStringLiteral( "SELECT upper(type),srid FROM geography_columns WHERE f_table_name=%1 AND f_geography_column=%2 AND f_table_schema=%3" ) - .arg( quotedValue( tableName ), - quotedValue( geomCol ), - quotedValue( schemaName ) ); + .arg( quotedValue( tableName ), quotedValue( geomCol ), quotedValue( schemaName ) ); QgsDebugMsgLevel( QStringLiteral( "Getting geography column: %1" ).arg( sql ), 2 ); result = connectionRO()->LoggedPQexecNoLogError( "QgsPostgresProvider", sql ); @@ -4277,9 +4196,11 @@ bool QgsPostgresProvider::getGeometryDetails() if ( result.PQntuples() == 1 ) { QString dt = result.PQgetvalue( 0, 0 ); - if ( dt != "GEOMETRY" ) detectedType = dt; + if ( dt != "GEOMETRY" ) + detectedType = dt; QString ds = result.PQgetvalue( 0, 1 ); - if ( ds != "0" ) detectedSrid = ds; + if ( ds != "0" ) + detectedSrid = ds; mSpatialColType = SctGeography; } else @@ -4299,9 +4220,7 @@ bool QgsPostgresProvider::getGeometryDetails() "END AS type, t.srid FROM topology.layer l, topology.topology t " "WHERE l.topology_id = t.id AND l.schema_name=%3 " "AND l.table_name=%1 AND l.feature_column=%2" ) - .arg( quotedValue( tableName ), - quotedValue( geomCol ), - quotedValue( schemaName ) ); + .arg( quotedValue( tableName ), quotedValue( geomCol ), quotedValue( schemaName ) ); QgsDebugMsgLevel( QStringLiteral( "Getting TopoGeometry column: %1" ).arg( sql ), 2 ); result = connectionRO()->LoggedPQexecNoLogError( "QgsPostgresProvider", sql ); @@ -4323,9 +4242,7 @@ bool QgsPostgresProvider::getGeometryDetails() { // check pointcloud columns sql = QStringLiteral( "SELECT 'POLYGON',srid FROM pointcloud_columns WHERE \"table\"=%1 AND \"column\"=%2 AND \"schema\"=%3" ) - .arg( quotedValue( tableName ), - quotedValue( geomCol ), - quotedValue( schemaName ) ); + .arg( quotedValue( tableName ), quotedValue( geomCol ), quotedValue( schemaName ) ); QgsDebugMsgLevel( QStringLiteral( "Getting pointcloud column: %1" ).arg( sql ), 2 ); result = connectionRO()->LoggedPQexecNoLogError( "QgsPostgresProvider", sql ); @@ -4350,9 +4267,7 @@ bool QgsPostgresProvider::getGeometryDetails() "WHERE a.attrelid=c.oid AND c.relnamespace=n.oid " "AND a.atttypid=t.oid " "AND n.nspname=%3 AND c.relname=%1 AND a.attname=%2" ) - .arg( quotedValue( tableName ), - quotedValue( geomCol ), - quotedValue( schemaName ) ); + .arg( quotedValue( tableName ), quotedValue( geomCol ), quotedValue( schemaName ) ); QgsDebugMsgLevel( QStringLiteral( "Getting column datatype: %1" ).arg( sql ), 2 ); result = connectionRO()->LoggedPQexecNoLogError( "QgsPostgresProvider", sql ); QgsDebugMsgLevel( QStringLiteral( "Column datatype query returned %1" ).arg( result.PQntuples() ), 2 ); @@ -4381,11 +4296,11 @@ bool QgsPostgresProvider::getGeometryDetails() if ( PGRES_TUPLES_OK == result.PQresultStatus() ) { sql = QStringLiteral( "SELECT (SELECT t.typname FROM pg_type t WHERE oid = %1), upper(postgis_typmod_type(%2)), postgis_typmod_srid(%2)" ) - .arg( QString::number( result.PQftype( 0 ) ), QString::number( result.PQfmod( 0 ) ) ); + .arg( QString::number( result.PQftype( 0 ) ), QString::number( result.PQfmod( 0 ) ) ); result = connectionRO()->LoggedPQexecNoLogError( "QgsPostgresProvider", sql ); if ( result.PQntuples() == 1 ) { - geomColType = result.PQgetvalue( 0, 0 ); + geomColType = result.PQgetvalue( 0, 0 ); detectedType = result.PQgetvalue( 0, 1 ); detectedSrid = result.PQgetvalue( 0, 2 ); if ( geomColType == QLatin1String( "geometry" ) ) @@ -4416,21 +4331,20 @@ bool QgsPostgresProvider::getGeometryDetails() } mDetectedGeomType = QgsPostgresConn::wkbTypeFromPostgis( detectedType ); - mDetectedSrid = detectedSrid; + mDetectedSrid = detectedSrid; if ( mDetectedGeomType == Qgis::WkbType::Unknown ) { - QgsPostgresLayerProperty layerProperty; if ( !mIsQuery ) { layerProperty.schemaName = schemaName; - layerProperty.tableName = tableName; + layerProperty.tableName = tableName; } else { layerProperty.schemaName.clear(); - layerProperty.tableName = mQuery; + layerProperty.tableName = mQuery; } layerProperty.geometryColName = mGeometryColumn; layerProperty.geometryColType = mSpatialColType; @@ -4462,8 +4376,7 @@ bool QgsPostgresProvider::getGeometryDetails() { Qgis::WkbType wkbType = layerProperty.types.at( i ); - if ( ( wkbType != Qgis::WkbType::Unknown && ( mRequestedGeomType == Qgis::WkbType::Unknown || mRequestedGeomType == wkbType ) ) && - ( mRequestedSrid.isEmpty() || layerProperty.srids.at( i ) == mRequestedSrid.toInt() ) ) + if ( ( wkbType != Qgis::WkbType::Unknown && ( mRequestedGeomType == Qgis::WkbType::Unknown || mRequestedGeomType == wkbType ) ) && ( mRequestedSrid.isEmpty() || layerProperty.srids.at( i ) == mRequestedSrid.toInt() ) ) break; } @@ -4474,7 +4387,7 @@ bool QgsPostgresProvider::getGeometryDetails() { // only what we requested is available mDetectedGeomType = layerProperty.types.at( 0 ); - mDetectedSrid = QString::number( layerProperty.srids.at( 0 ) ); + mDetectedSrid = QString::number( layerProperty.srids.at( 0 ) ); } } else @@ -4559,7 +4472,8 @@ bool QgsPostgresProvider::convertField( QgsField &field, const QMap *oldToNewAttrIdxMap, - QString *errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap *oldToNewAttrIdxMap, QString *errorMessage, const QMap *options ) { // populate members from the uri structure QgsDataSourceUri dsUri( uri ); @@ -4690,10 +4597,7 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u { for ( const auto &field : std::as_const( fields ) ) { - if ( field.isNumeric() && - ( field.constraints().constraints() & QgsFieldConstraints::Constraint::ConstraintUnique ) && - ( field.constraints().constraints() & QgsFieldConstraints::Constraint::ConstraintNotNull ) && - ( field.constraints().constraints() & QgsFieldConstraints::ConstraintOrigin::ConstraintOriginProvider ) ) + if ( field.isNumeric() && ( field.constraints().constraints() & QgsFieldConstraints::Constraint::ConstraintUnique ) && ( field.constraints().constraints() & QgsFieldConstraints::Constraint::ConstraintNotNull ) && ( field.constraints().constraints() & QgsFieldConstraints::ConstraintOrigin::ConstraintOriginProvider ) ) { primaryKey = field.name(); break; @@ -4742,7 +4646,8 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u } } } - if ( type.isEmpty() ) type = QStringLiteral( "serial" ); + if ( type.isEmpty() ) + type = QStringLiteral( "serial" ); else { // if the pk field's type is one of the postgres integer types, @@ -4782,8 +4687,7 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u " FROM pg_class AS cls JOIN pg_namespace AS nsp" " ON nsp.oid=cls.relnamespace " " WHERE cls.relname=%1 AND nsp.nspname=%2" ) - .arg( quotedValue( tableName ), - quotedValue( schemaName ) ); + .arg( quotedValue( tableName ), quotedValue( schemaName ) ); QgsPostgresResult result( conn->LoggedPQexec( "QgsPostgresProvider", sql ) ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) @@ -4798,15 +4702,14 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u " FROM pg_class AS cls JOIN pg_namespace AS nsp" " ON nsp.oid=cls.relnamespace " " WHERE cls.relname=%2 AND nsp.nspname=%1" ) - .arg( quotedValue( schemaName ), - quotedValue( tableName ) ); + .arg( quotedValue( schemaName ), quotedValue( tableName ) ); result = conn->LoggedPQexec( "QgsPostgresProvider", sql ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) throw PGException( result ); } - sql = QStringLiteral( "CREATE TABLE %1(" ) .arg( schemaTableName ); + sql = QStringLiteral( "CREATE TABLE %1(" ).arg( schemaTableName ); QString pk; for ( int i = 0; i < pkList.size(); ++i ) { @@ -4824,14 +4727,14 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u if ( i ) { - pk += QLatin1Char( ',' ); + pk += QLatin1Char( ',' ); sql += QLatin1Char( ',' ); } pk += col; sql += col + " " + type; } - sql += QStringLiteral( ", PRIMARY KEY (%1) )" ) .arg( pk ); + sql += QStringLiteral( ", PRIMARY KEY (%1) )" ).arg( pk ); result = conn->LoggedPQexec( "QgsPostgresProvider", sql ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) @@ -4847,12 +4750,10 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u if ( !geometryType.isEmpty() ) { sql = QStringLiteral( "SELECT AddGeometryColumn(%1,%2,%3,%4,%5,%6)" ) - .arg( quotedValue( schemaName ), - quotedValue( tableName ), - quotedValue( geometryColumn ) ) - .arg( srid ) - .arg( quotedValue( geometryType ) ) - .arg( dim ); + .arg( quotedValue( schemaName ), quotedValue( tableName ), quotedValue( geometryColumn ) ) + .arg( srid ) + .arg( quotedValue( geometryType ) ) + .arg( dim ); result = conn->LoggedPQexec( "QgsPostgresProvider", sql ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) @@ -4869,8 +4770,7 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u { if ( errorMessage ) *errorMessage = QObject::tr( "Creation of data source %1 failed: \n%2" ) - .arg( schemaTableName, - e.errorMessage() ); + .arg( schemaTableName, e.errorMessage() ); conn->LoggedPQexecNR( "QgsPostgresProvider", QStringLiteral( "ROLLBACK" ) ); conn->unref(); @@ -4885,7 +4785,7 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u QgsDataProvider::ProviderOptions providerOptions; Qgis::DataProviderReadFlags flags; - std::unique_ptr< QgsPostgresProvider > provider = std::make_unique< QgsPostgresProvider >( dsUri.uri( false ), providerOptions, flags ); + std::unique_ptr provider = std::make_unique( dsUri.uri( false ), providerOptions, flags ); if ( !provider->isValid() ) { if ( errorMessage ) @@ -4954,11 +4854,7 @@ Qgis::VectorExportResult QgsPostgresProvider::createEmptyLayer( const QString &u return Qgis::VectorExportResult::ErrorAttributeTypeUnsupported; } - QgsDebugMsgLevel( QStringLiteral( "creating field #%1 -> #%2 name %3 type %4 typename %5 width %6 precision %7" ) - .arg( fldIdx ).arg( offset ) - .arg( fld.name(), QVariant::typeToName( fld.type() ), fld.typeName() ) - .arg( fld.length() ).arg( fld.precision() ), 2 - ); + QgsDebugMsgLevel( QStringLiteral( "creating field #%1 -> #%2 name %3 type %4 typename %5 width %6 precision %7" ).arg( fldIdx ).arg( offset ).arg( fld.name(), QVariant::typeToName( fld.type() ), fld.typeName() ).arg( fld.length() ).arg( fld.precision() ), 2 ); flist.append( fld ); if ( oldToNewAttrIdxMap ) @@ -4984,7 +4880,6 @@ QgsCoordinateReferenceSystem QgsPostgresProvider::crs() const int srid = mRequestedSrid.isEmpty() ? mDetectedSrid.toInt() : mRequestedSrid.toInt(); return sridToCrs( srid, connectionRO() ); - } QString QgsPostgresProvider::subsetString() const @@ -4999,16 +4894,16 @@ QString QgsPostgresProvider::getTableName() size_t QgsPostgresProvider::layerCount() const { - return 1; // XXX need to return actual number of layers + return 1; // XXX need to return actual number of layers } // QgsPostgresProvider::layerCount() -QString QgsPostgresProvider::name() const +QString QgsPostgresProvider::name() const { return POSTGRES_KEY; } // QgsPostgresProvider::name() -QString QgsPostgresProvider::description() const +QString QgsPostgresProvider::description() const { QString pgVersion( tr( "PostgreSQL version: unknown" ) ); QString postgisVersion( tr( "unknown" ) ); @@ -5054,7 +4949,7 @@ QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QS } i += match.captured( 1 ).length() + 2; jumpSpace( txt, i ); - if ( !QStringView{txt} .mid( i ).startsWith( sep ) && i < txt.length() ) + if ( !QStringView { txt }.mid( i ).startsWith( sep ) && i < txt.length() ) { QgsMessageLog::logMessage( tr( "Cannot find separator: %1" ).arg( txt.mid( i ) ), tr( "PostGIS" ) ); return QString(); @@ -5067,14 +4962,14 @@ QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QS int start = i; for ( ; i < txt.length(); i++ ) { - if ( QStringView{txt} .mid( i ).startsWith( sep ) ) + if ( QStringView { txt }.mid( i ).startsWith( sep ) ) { - QStringView v( QStringView{txt} .mid( start, i - start ) ); + QStringView v( QStringView { txt }.mid( start, i - start ) ); i += sep.length(); return v.trimmed().toString(); } } - return QStringView{txt} .mid( start, i - start ).trimmed().toString(); + return QStringView { txt }.mid( start, i - start ).trimmed().toString(); } } @@ -5152,12 +5047,14 @@ QVariant QgsPostgresProvider::parseMultidimensionalArray( const QString &txt ) bool escaped = false; int openedBrackets = 1; int i = 0; - while ( i < text.length() && openedBrackets > 0 ) + while ( i < text.length() && openedBrackets > 0 ) { ++i; - if ( text.at( i ) == '}' && !escaped ) openedBrackets--; - else if ( text.at( i ) == '{' && !escaped ) openedBrackets++; + if ( text.at( i ) == '}' && !escaped ) + openedBrackets--; + else if ( text.at( i ) == '{' && !escaped ) + openedBrackets++; escaped = !escaped ? text.at( i ) == '\\' : false; } @@ -5171,7 +5068,6 @@ QVariant QgsPostgresProvider::parseMultidimensionalArray( const QString &txt ) text = text.mid( i ); } return values; - } QVariant QgsPostgresProvider::parseArray( const QString &txt, QMetaType::Type type, QMetaType::Type subType, const QString &typeName, QgsPostgresConn *conn ) @@ -5240,8 +5136,7 @@ QList QgsPostgresProvider::searchLayers( const QList( layer->dataProvider() ); - if ( pgProvider && - pgProvider->mUri.connectionInfo( false ) == connectionInfo && pgProvider->mSchemaName == schema && pgProvider->mTableName == tableName ) + if ( pgProvider && pgProvider->mUri.connectionInfo( false ) == connectionInfo && pgProvider->mSchemaName == schema && pgProvider->mTableName == tableName ) { result.append( layer ); } @@ -5285,23 +5180,20 @@ QList QgsPostgresProvider::discoverRelations( const QgsVectorLayer " WHERE oid = c.confrelid) as constraint_schema " " FROM pg_constraint c " " WHERE contype = 'f' " - " AND c.conrelid::regclass = " + - QgsPostgresConn::quotedValue( QString( QgsPostgresConn::quotedIdentifier( mSchemaName ) + - '.' + - QgsPostgresConn::quotedIdentifier( mTableName ) ) ) + - "::regclass ) " - "SELECT fk.conname as constraint_name, " - " a.attname as column_name, " - " fk.constraint_schema, " - " referenced_table as table_name, " - " af.attname as column_name " - "FROM foreign_keys fk " - "JOIN pg_attribute af ON af.attnum = fk.confkey " - "AND af.attrelid = fk.confrelid " - "JOIN pg_attribute a ON a.attnum = conkey " - "AND a.attrelid = fk.conrelid " - "ORDER BY fk.confrelid, " - " fk.conname ;" + " AND c.conrelid::regclass = " + + QgsPostgresConn::quotedValue( QString( QgsPostgresConn::quotedIdentifier( mSchemaName ) + '.' + QgsPostgresConn::quotedIdentifier( mTableName ) ) ) + "::regclass ) " + "SELECT fk.conname as constraint_name, " + " a.attname as column_name, " + " fk.constraint_schema, " + " referenced_table as table_name, " + " af.attname as column_name " + "FROM foreign_keys fk " + "JOIN pg_attribute af ON af.attnum = fk.confkey " + "AND af.attrelid = fk.confrelid " + "JOIN pg_attribute a ON a.attnum = conkey " + "AND a.attrelid = fk.conrelid " + "ORDER BY fk.confrelid, " + " fk.conname ;" ); QgsPostgresResult sqlResult( connectionRO()->LoggedPQexec( "QgsPostgresProvider", sql ) ); @@ -5416,7 +5308,7 @@ QgsDataProvider *QgsPostgresProviderMetadata::createProvider( const QString &uri return new QgsPostgresProvider( uri, options, flags ); } -QList< QgsDataItemProvider * > QgsPostgresProviderMetadata::dataItemProviders() const +QList QgsPostgresProviderMetadata::dataItemProviders() const { QList providers; providers << new QgsPostgresDataItemProvider; @@ -5425,19 +5317,12 @@ QList< QgsDataItemProvider * > QgsPostgresProviderMetadata::dataItemProviders() // --------------------------------------------------------------------------- -Qgis::VectorExportResult QgsPostgresProviderMetadata::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap &oldToNewAttrIdxMap, - QString &errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsPostgresProviderMetadata::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) { return QgsPostgresProvider::createEmptyLayer( - uri, fields, wkbType, srs, overwrite, - &oldToNewAttrIdxMap, &errorMessage, options - ); + uri, fields, wkbType, srs, overwrite, + &oldToNewAttrIdxMap, &errorMessage, options + ); } bool QgsPostgresProviderMetadata::styleExists( const QString &uri, const QString &styleId, QString &errorCause ) @@ -5476,14 +5361,12 @@ bool QgsPostgresProviderMetadata::styleExists( const QString &uri, const QString " AND f_geometry_column %4" " AND (type=%5 OR type IS NULL)" " AND styleName=%6" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( dsUri.geometryColumn().isEmpty() ? - QStringLiteral( "IS NULL" ) : - QStringLiteral( "= %1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) - .arg( wkbTypeString ) - .arg( QgsPostgresConn::quotedValue( styleId.isEmpty() ? dsUri.table() : styleId ) ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "= %1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) + .arg( wkbTypeString ) + .arg( QgsPostgresConn::quotedValue( styleId.isEmpty() ? dsUri.table() : styleId ) ); QgsPostgresResult res( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadata" ), checkQuery ) ); if ( res.PQresultStatus() == PGRES_TUPLES_OK ) @@ -5497,9 +5380,7 @@ bool QgsPostgresProviderMetadata::styleExists( const QString &uri, const QString } } -bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString &qmlStyleIn, const QString &sldStyleIn, - const QString &styleName, const QString &styleDescription, - const QString &uiFileContent, bool useAsDefault, QString &errCause ) +bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString &qmlStyleIn, const QString &sldStyleIn, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) { QgsDataSourceUri dsUri( uri ); @@ -5518,23 +5399,22 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & if ( !tableExists( *conn, QStringLiteral( "layer_styles" ) ) ) { - QgsPostgresResult res( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadata" ), - "CREATE TABLE layer_styles(" - "id SERIAL PRIMARY KEY" - ",f_table_catalog varchar" - ",f_table_schema varchar" - ",f_table_name varchar" - ",f_geometry_column varchar" - ",styleName text" - ",styleQML xml" - ",styleSLD xml" - ",useAsDefault boolean" - ",description text" - ",owner varchar(63) DEFAULT CURRENT_USER" - ",ui xml" - ",update_time timestamp DEFAULT CURRENT_TIMESTAMP" - ",type varchar" - ")" ) ); + QgsPostgresResult res( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadata" ), "CREATE TABLE layer_styles(" + "id SERIAL PRIMARY KEY" + ",f_table_catalog varchar" + ",f_table_schema varchar" + ",f_table_name varchar" + ",f_geometry_column varchar" + ",styleName text" + ",styleQML xml" + ",styleSLD xml" + ",useAsDefault boolean" + ",description text" + ",owner varchar(63) DEFAULT CURRENT_USER" + ",ui xml" + ",update_time timestamp DEFAULT CURRENT_TIMESTAMP" + ",type varchar" + ")" ) ); if ( res.PQresultStatus() != PGRES_COMMAND_OK ) { errCause = QObject::tr( "Unable to save layer style. It's not possible to create the destination table on the database. Maybe this is due to table permissions (user=%1). Please contact your database admin" ).arg( dsUri.username() ); @@ -5581,20 +5461,19 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & ") VALUES (" "%1,%2,%3,%4,%5,XMLPARSE(DOCUMENT %16),XMLPARSE(DOCUMENT %17),%8,%9,%10,%11%13" ")" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) - .arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ) - .arg( useAsDefault ? "true" : "false" ) - .arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( "CURRENT_USER" ) - .arg( uiFileColumn ) - .arg( uiFileValue ) - .arg( wkbTypeString ) - // Must be the final .arg replacement - see above - .arg( QgsPostgresConn::quotedValue( qmlStyle ), - QgsPostgresConn::quotedValue( sldStyle ) ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) + .arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ) + .arg( useAsDefault ? "true" : "false" ) + .arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) + .arg( "CURRENT_USER" ) + .arg( uiFileColumn ) + .arg( uiFileValue ) + .arg( wkbTypeString ) + // Must be the final .arg replacement - see above + .arg( QgsPostgresConn::quotedValue( qmlStyle ), QgsPostgresConn::quotedValue( sldStyle ) ); QString checkQuery = QString( "SELECT styleName" " FROM layer_styles" @@ -5604,12 +5483,12 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & " AND f_geometry_column %4" " AND (type=%5 OR type IS NULL)" " AND styleName=%6" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) - .arg( wkbTypeString ) - .arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) + .arg( wkbTypeString ) + .arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ); QgsPostgresResult res( conn->LoggedPQexec( "QgsPostgresProviderMetadata", checkQuery ) ); if ( res.PQntuples() > 0 ) @@ -5627,18 +5506,17 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & " AND f_geometry_column %9" " AND styleName=%10" " AND (type=%2 OR type IS NULL)" ) - .arg( useAsDefault ? "true" : "false" ) - .arg( wkbTypeString ) - .arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( "CURRENT_USER" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) - .arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ) - // Must be the final .arg replacement - see above - .arg( QgsPostgresConn::quotedValue( qmlStyle ), - QgsPostgresConn::quotedValue( sldStyle ) ); + .arg( useAsDefault ? "true" : "false" ) + .arg( wkbTypeString ) + .arg( QgsPostgresConn::quotedValue( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) + .arg( "CURRENT_USER" ) + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) + .arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) ) + // Must be the final .arg replacement - see above + .arg( QgsPostgresConn::quotedValue( qmlStyle ), QgsPostgresConn::quotedValue( sldStyle ) ); } if ( useAsDefault ) @@ -5650,11 +5528,11 @@ bool QgsPostgresProviderMetadata::saveStyle( const QString &uri, const QString & " AND f_table_name=%3" " AND f_geometry_column %4" " AND (type=%5 OR type IS NULL)" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) - .arg( wkbTypeString ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) + .arg( wkbTypeString ); sql = QStringLiteral( "BEGIN; %1; %2; COMMIT;" ).arg( removeDefaultSql, sql ); } @@ -5723,10 +5601,10 @@ QString QgsPostgresProviderMetadata::loadStoredStyle( const QString &uri, QStrin " AND f_geometry_column %4" " ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END" ",update_time DESC LIMIT 1" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( geomColumnExpr ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( geomColumnExpr ); } else { @@ -5739,11 +5617,11 @@ QString QgsPostgresProviderMetadata::loadStoredStyle( const QString &uri, QStrin " AND (type=%5 OR type IS NULL)" " ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END" ",update_time DESC LIMIT 1" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( geomColumnExpr ) - .arg( wkbTypeString ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( geomColumnExpr ) + .arg( wkbTypeString ); } QgsPostgresResult result( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadata" ), selectQmlQuery ) ); @@ -5757,8 +5635,7 @@ QString QgsPostgresProviderMetadata::loadStoredStyle( const QString &uri, QStrin return style; } -int QgsPostgresProviderMetadata::listStyles( const QString &uri, QStringList &ids, QStringList &names, - QStringList &descriptions, QString &errCause ) +int QgsPostgresProviderMetadata::listStyles( const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause ) { errCause.clear(); QgsDataSourceUri dsUri( uri ); @@ -5790,12 +5667,11 @@ int QgsPostgresProviderMetadata::listStyles( const QString &uri, QStringList &id " AND %4" " AND (type=%5 OR type IS NULL)" " ORDER BY useasdefault DESC, update_time DESC" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( dsUri.geometryColumn().isEmpty() ? "f_geometry_column is NULL" : - QString( "f_geometry_column=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) - .arg( wkbTypeString ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( dsUri.geometryColumn().isEmpty() ? "f_geometry_column is NULL" : QString( "f_geometry_column=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) + .arg( wkbTypeString ); QgsPostgresResult result( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadata" ), selectRelatedQuery ) ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) @@ -5818,13 +5694,11 @@ int QgsPostgresProviderMetadata::listStyles( const QString &uri, QStringList &id " FROM layer_styles" " WHERE NOT (f_table_catalog=%1 AND f_table_schema=%2 AND f_table_name=%3 AND f_geometry_column %4 AND type=%5)" " ORDER BY update_time DESC" ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( dsUri.geometryColumn().isEmpty() ? - QStringLiteral( "IS NULL" ) : - QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) - .arg( wkbTypeString ); + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) + .arg( wkbTypeString ); result = conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadata" ), selectOthersQuery ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) @@ -5860,14 +5734,16 @@ bool QgsPostgresProviderMetadata::deleteStyleById( const QString &uri, const QSt } else { - QString deleteStyleQuery = QStringLiteral( "DELETE FROM layer_styles WHERE id=%1" ).arg( - QgsPostgresConn::quotedValue( styleId ) ); + QString deleteStyleQuery = QStringLiteral( "DELETE FROM layer_styles WHERE id=%1" ).arg( QgsPostgresConn::quotedValue( styleId ) ); QgsPostgresResult result( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadata" ), deleteStyleQuery ) ); if ( result.PQresultStatus() != PGRES_COMMAND_OK ) { QgsDebugError( QString( "PQexec of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" ) - .arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( deleteStyleQuery ) ); + .arg( result.PQresultStatus() ) + .arg( PGRES_COMMAND_OK ) + .arg( deleteStyleQuery ) + ); QgsMessageLog::logMessage( QObject::tr( "Error executing query: %1" ).arg( deleteStyleQuery ) ); errCause = QObject::tr( "Error executing the delete query. The query was logged" ); deleted = false; @@ -5935,7 +5811,7 @@ void QgsPostgresProviderMetadata::deleteConnection( const QString &name ) deleteConnectionProtected( name ); } -void QgsPostgresProviderMetadata::saveConnection( const QgsAbstractProviderConnection *conn, const QString &name ) +void QgsPostgresProviderMetadata::saveConnection( const QgsAbstractProviderConnection *conn, const QString &name ) { saveConnectionProtected( conn, name ); } @@ -5946,23 +5822,22 @@ QgsAbstractProviderConnection *QgsPostgresProviderMetadata::createConnection( co } -QgsPostgresProjectStorage *gPgProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry() -QgsPostgresLayerMetadataProvider *gPgLayerMetadataProvider = nullptr; // when not null it is owned by QgsApplication::layerMetadataProviderRegistry() +QgsPostgresProjectStorage *gPgProjectStorage = nullptr; // when not null it is owned by QgsApplication::projectStorageRegistry() +QgsPostgresLayerMetadataProvider *gPgLayerMetadataProvider = nullptr; // when not null it is owned by QgsApplication::layerMetadataProviderRegistry() void QgsPostgresProviderMetadata::initProvider() { Q_ASSERT( !gPgProjectStorage ); gPgProjectStorage = new QgsPostgresProjectStorage; - QgsApplication::projectStorageRegistry()->registerProjectStorage( gPgProjectStorage ); // takes ownership + QgsApplication::projectStorageRegistry()->registerProjectStorage( gPgProjectStorage ); // takes ownership Q_ASSERT( !gPgLayerMetadataProvider ); gPgLayerMetadataProvider = new QgsPostgresLayerMetadataProvider(); - QgsApplication::layerMetadataProviderRegistry()->registerLayerMetadataProvider( gPgLayerMetadataProvider ); // takes ownership - + QgsApplication::layerMetadataProviderRegistry()->registerLayerMetadataProvider( gPgLayerMetadataProvider ); // takes ownership } void QgsPostgresProviderMetadata::cleanupProvider() { - QgsApplication::projectStorageRegistry()->unregisterProjectStorage( gPgProjectStorage ); // destroys the object + QgsApplication::projectStorageRegistry()->unregisterProjectStorage( gPgProjectStorage ); // destroys the object gPgProjectStorage = nullptr; QgsApplication::layerMetadataProviderRegistry()->unregisterLayerMetadataProvider( gPgLayerMetadataProvider ); gPgLayerMetadataProvider = nullptr; @@ -6031,7 +5906,7 @@ QVariantList QgsPostgresSharedData::removeFid( QgsFeatureId fid ) { QMutexLocker locker( &mMutex ); - QVariantList v = mFidToKey[ fid ]; + QVariantList v = mFidToKey[fid]; mFidToKey.remove( fid ); mKeyToFid.remove( v ); return v; @@ -6079,13 +5954,13 @@ bool QgsPostgresSharedData::fieldSupportsEnumValuesIsSet( int index ) bool QgsPostgresSharedData::fieldSupportsEnumValues( int index ) { QMutexLocker locker( &mMutex ); - return mFieldSupportsEnumValues.contains( index ) && mFieldSupportsEnumValues[ index ]; + return mFieldSupportsEnumValues.contains( index ) && mFieldSupportsEnumValues[index]; } void QgsPostgresSharedData::setFieldSupportsEnumValues( int index, bool isSupported ) { QMutexLocker locker( &mMutex ); - mFieldSupportsEnumValues[ index ] = isSupported; + mFieldSupportsEnumValues[index] = isSupported; } @@ -6112,45 +5987,45 @@ QVariantMap QgsPostgresProviderMetadata::decodeUri( const QString &uri ) const const QgsDataSourceUri dsUri { uri }; QVariantMap uriParts; - if ( ! dsUri.database().isEmpty() ) - uriParts[ QStringLiteral( "dbname" ) ] = dsUri.database(); - if ( ! dsUri.host().isEmpty() ) - uriParts[ QStringLiteral( "host" ) ] = dsUri.host(); - if ( ! dsUri.port().isEmpty() ) - uriParts[ QStringLiteral( "port" ) ] = dsUri.port(); - if ( ! dsUri.service().isEmpty() ) - uriParts[ QStringLiteral( "service" ) ] = dsUri.service(); - if ( ! dsUri.username().isEmpty() ) - uriParts[ QStringLiteral( "username" ) ] = dsUri.username(); - if ( ! dsUri.password().isEmpty() ) - uriParts[ QStringLiteral( "password" ) ] = dsUri.password(); - if ( ! dsUri.authConfigId().isEmpty() ) - uriParts[ QStringLiteral( "authcfg" ) ] = dsUri.authConfigId(); + if ( !dsUri.database().isEmpty() ) + uriParts[QStringLiteral( "dbname" )] = dsUri.database(); + if ( !dsUri.host().isEmpty() ) + uriParts[QStringLiteral( "host" )] = dsUri.host(); + if ( !dsUri.port().isEmpty() ) + uriParts[QStringLiteral( "port" )] = dsUri.port(); + if ( !dsUri.service().isEmpty() ) + uriParts[QStringLiteral( "service" )] = dsUri.service(); + if ( !dsUri.username().isEmpty() ) + uriParts[QStringLiteral( "username" )] = dsUri.username(); + if ( !dsUri.password().isEmpty() ) + uriParts[QStringLiteral( "password" )] = dsUri.password(); + if ( !dsUri.authConfigId().isEmpty() ) + uriParts[QStringLiteral( "authcfg" )] = dsUri.authConfigId(); if ( dsUri.wkbType() != Qgis::WkbType::Unknown ) - uriParts[ QStringLiteral( "type" ) ] = static_cast< quint32>( dsUri.wkbType() ); + uriParts[QStringLiteral( "type" )] = static_cast( dsUri.wkbType() ); if ( uri.contains( QStringLiteral( "selectatid=" ), Qt::CaseSensitivity::CaseInsensitive ) ) - uriParts[ QStringLiteral( "selectatid" ) ] = ! dsUri.selectAtIdDisabled(); + uriParts[QStringLiteral( "selectatid" )] = !dsUri.selectAtIdDisabled(); - if ( ! dsUri.table().isEmpty() ) - uriParts[ QStringLiteral( "table" ) ] = dsUri.table(); - if ( ! dsUri.schema().isEmpty() ) - uriParts[ QStringLiteral( "schema" ) ] = dsUri.schema(); - if ( ! dsUri.keyColumn().isEmpty() ) - uriParts[ QStringLiteral( "key" ) ] = dsUri.keyColumn(); - if ( ! dsUri.srid().isEmpty() ) - uriParts[ QStringLiteral( "srid" ) ] = dsUri.srid(); + if ( !dsUri.table().isEmpty() ) + uriParts[QStringLiteral( "table" )] = dsUri.table(); + if ( !dsUri.schema().isEmpty() ) + uriParts[QStringLiteral( "schema" )] = dsUri.schema(); + if ( !dsUri.keyColumn().isEmpty() ) + uriParts[QStringLiteral( "key" )] = dsUri.keyColumn(); + if ( !dsUri.srid().isEmpty() ) + uriParts[QStringLiteral( "srid" )] = dsUri.srid(); if ( uri.contains( QStringLiteral( "estimatedmetadata=" ), Qt::CaseSensitivity::CaseInsensitive ) ) - uriParts[ QStringLiteral( "estimatedmetadata" ) ] = dsUri.useEstimatedMetadata(); + uriParts[QStringLiteral( "estimatedmetadata" )] = dsUri.useEstimatedMetadata(); if ( uri.contains( QStringLiteral( "sslmode=" ), Qt::CaseSensitivity::CaseInsensitive ) ) - uriParts[ QStringLiteral( "sslmode" ) ] = dsUri.sslMode(); + uriParts[QStringLiteral( "sslmode" )] = dsUri.sslMode(); - if ( ! dsUri.sql().isEmpty() ) - uriParts[ QStringLiteral( "sql" ) ] = dsUri.sql(); - if ( ! dsUri.geometryColumn().isEmpty() ) - uriParts[ QStringLiteral( "geometrycolumn" ) ] = dsUri.geometryColumn(); + if ( !dsUri.sql().isEmpty() ) + uriParts[QStringLiteral( "sql" )] = dsUri.sql(); + if ( !dsUri.geometryColumn().isEmpty() ) + uriParts[QStringLiteral( "geometrycolumn" )] = dsUri.geometryColumn(); return uriParts; } @@ -6188,7 +6063,7 @@ QString QgsPostgresProviderMetadata::encodeUri( const QVariantMap &parts ) const if ( parts.contains( QStringLiteral( "estimatedmetadata" ) ) ) dsUri.setParam( QStringLiteral( "estimatedmetadata" ), parts.value( QStringLiteral( "estimatedmetadata" ) ).toString() ); if ( parts.contains( QStringLiteral( "sslmode" ) ) ) - dsUri.setParam( QStringLiteral( "sslmode" ), QgsDataSourceUri::encodeSslMode( static_cast( parts.value( QStringLiteral( "sslmode" ) ).toInt( ) ) ) ); + dsUri.setParam( QStringLiteral( "sslmode" ), QgsDataSourceUri::encodeSslMode( static_cast( parts.value( QStringLiteral( "sslmode" ) ).toInt() ) ) ); if ( parts.contains( QStringLiteral( "sql" ) ) ) dsUri.setSql( parts.value( QStringLiteral( "sql" ) ).toString() ); if ( parts.contains( QStringLiteral( "checkPrimaryKeyUnicity" ) ) ) diff --git a/src/providers/postgres/qgspostgresprovider.h b/src/providers/postgres/qgspostgresprovider.h index 2f9cde21842e..57278a3675a7 100644 --- a/src/providers/postgres/qgspostgresprovider.h +++ b/src/providers/postgres/qgspostgresprovider.h @@ -46,14 +46,13 @@ class QgsPostgresListener; * interface defined in the QgsDataProvider class to provide access to spatial * data residing in a PostgreSQL/PostGIS enabled database. */ -class QgsPostgresProvider final: public QgsVectorDataProvider +class QgsPostgresProvider final : public QgsVectorDataProvider { Q_OBJECT friend class TestQgsPostgresProvider; public: - static const QString POSTGRES_KEY; static const QString POSTGRES_DESCRIPTION; @@ -83,8 +82,7 @@ class QgsPostgresProvider final: public QgsVectorDataProvider * \param options generic data provider options * \param flags generic data provider flags */ - explicit QgsPostgresProvider( QString const &uri, const QgsDataProvider::ProviderOptions &providerOptions, - Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); + explicit QgsPostgresProvider( QString const &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); ~QgsPostgresProvider() override; @@ -151,9 +149,8 @@ class QgsPostgresProvider final: public QgsVectorDataProvider QString dataComment() const override; QVariant minimumValue( int index ) const override; QVariant maximumValue( int index ) const override; - QSet< QVariant > uniqueValues( int index, int limit = -1 ) const override; - QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1, - QgsFeedback *feedback = nullptr ) const override; + QSet uniqueValues( int index, int limit = -1 ) const override; + QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1, QgsFeedback *feedback = nullptr ) const override; void enumValues( int index, QStringList &enumList ) const override; bool isValid() const override; Qgis::ProviderStyleStorageCapabilities styleStorageCapabilities() const override; @@ -195,7 +192,7 @@ class QgsPostgresProvider final: public QgsVectorDataProvider */ // XXX For now we have disabled native transforms in the PG provider since // it appears there are problems with some of the projection definitions - bool supportsNativeTransform() {return false;} + bool supportsNativeTransform() { return false; } QString name() const override; QString description() const override; @@ -237,7 +234,6 @@ class QgsPostgresProvider final: public QgsVectorDataProvider void handlePostCloneOperations( QgsVectorDataProvider *source ) override; private: - /** * \returns relation kind */ @@ -248,16 +244,9 @@ class QgsPostgresProvider final: public QgsVectorDataProvider */ void setQuery( const QString &query ); - bool declareCursor( const QString &cursorName, - const QgsAttributeList &fetchAttributes, - bool fetchGeometry, - QString whereClause ); + bool declareCursor( const QString &cursorName, const QgsAttributeList &fetchAttributes, bool fetchGeometry, QString whereClause ); - bool getFeature( QgsPostgresResult &queryResult, - int row, - bool fetchGeometry, - QgsFeature &feature, - const QgsAttributeList &fetchAttributes ); + bool getFeature( QgsPostgresResult &queryResult, int row, bool fetchGeometry, QgsFeature &feature, const QgsAttributeList &fetchAttributes ); QString geomParam( int offset ) const; @@ -397,16 +386,16 @@ class QgsPostgresProvider final: public QgsVectorDataProvider QList mPrimaryKeyAttrs; QString mPrimaryKeyDefault; - QString mGeometryColumn; //!< Name of the geometry column - QString mBoundingBoxColumn; //!< Name of the bounding box column - mutable std::optional mLayerExtent; //!< QgsBox3D that contains the extent (bounding box) of the layer + QString mGeometryColumn; //!< Name of the geometry column + QString mBoundingBoxColumn; //!< Name of the bounding box column + mutable std::optional mLayerExtent; //!< QgsBox3D that contains the extent (bounding box) of the layer - Qgis::WkbType mDetectedGeomType = Qgis::WkbType::Unknown ; //!< Geometry type detected in the database - Qgis::WkbType mRequestedGeomType = Qgis::WkbType::Unknown ; //!< Geometry type requested in the uri - QString mDetectedSrid; //!< Spatial reference detected in the database - QString mRequestedSrid; //!< Spatial reference requested in the uri + Qgis::WkbType mDetectedGeomType = Qgis::WkbType::Unknown; //!< Geometry type detected in the database + Qgis::WkbType mRequestedGeomType = Qgis::WkbType::Unknown; //!< Geometry type requested in the uri + QString mDetectedSrid; //!< Spatial reference detected in the database + QString mRequestedSrid; //!< Spatial reference requested in the uri - std::shared_ptr mShared; //!< Mutable data shared between provider and feature sources + std::shared_ptr mShared; //!< Mutable data shared between provider and feature sources bool getGeometryDetails(); @@ -414,16 +403,16 @@ class QgsPostgresProvider final: public QgsVectorDataProvider struct TopoLayerInfo { - QString topologyName; - long layerId; - int layerLevel; - enum TopoFeatureType - { - Puntal = 1, - Lineal = 2, - Polygonal = 3, - Mixed = 4 - } featureType; + QString topologyName; + long layerId; + int layerLevel; + enum TopoFeatureType + { + Puntal = 1, + Lineal = 2, + Polygonal = 3, + Mixed = 4 + } featureType; }; TopoLayerInfo mTopoLayerInfo; @@ -439,7 +428,8 @@ class QgsPostgresProvider final: public QgsVectorDataProvider bool mSelectAtIdDisabled = false; //!< Disable support for SelectAtId - struct PGFieldNotFound {}; //! Exception to throw + struct PGFieldNotFound + {}; //! Exception to throw // A function that determines if the given columns contain unique entries bool uniqueData( const QString "edColNames ); @@ -451,8 +441,8 @@ class QgsPostgresProvider final: public QgsVectorDataProvider QString paramValue( const QString &fieldvalue, const QString &defaultValue ) const; - mutable QgsPostgresConn *mConnectionRO = nullptr ; //!< Read-only database connection (initially) - QgsPostgresConn *mConnectionRW = nullptr ; //!< Read-write database connection (on update) + mutable QgsPostgresConn *mConnectionRO = nullptr; //!< Read-only database connection (initially) + QgsPostgresConn *mConnectionRW = nullptr; //!< Read-write database connection (on update) QgsPostgresConn *connectionRO() const; QgsPostgresConn *connectionRW(); @@ -480,12 +470,12 @@ class QgsPostgresProvider final: public QgsVectorDataProvider QgsLayerMetadata mLayerMetadata; - std::unique_ptr< QgsPostgresListener > mListener; + std::unique_ptr mListener; static QgsReferencedGeometry fromEwkt( const QString &ewkt, QgsPostgresConn *conn ); static QString toEwkt( const QgsReferencedGeometry &geom, QgsPostgresConn *conn ); static QString geomAttrToString( const QVariant &attr, QgsPostgresConn *conn ); - static int crsToSrid( const QgsCoordinateReferenceSystem &crs, QgsPostgresConn *conn ); + static int crsToSrid( const QgsCoordinateReferenceSystem &crs, QgsPostgresConn *conn ); static QgsCoordinateReferenceSystem sridToCrs( int srsId, QgsPostgresConn *conn ); /** @@ -503,7 +493,6 @@ class QgsPostgresProvider final: public QgsVectorDataProvider * If false is returned, mLayerExtent is left untouched. */ bool computeExtent3D() const; - }; @@ -514,19 +503,9 @@ class QgsPostgresUtils static bool deleteLayer( const QString &uri, QString &errCause ); static bool deleteSchema( const QString &schema, const QgsDataSourceUri &uri, QString &errCause, bool cascade = false ); - static QString whereClause( QgsFeatureId featureId, - const QgsFields &fields, - QgsPostgresConn *conn, - QgsPostgresPrimaryKeyType pkType, - const QList &pkAttrs, - const std::shared_ptr &sharedData ); + static QString whereClause( QgsFeatureId featureId, const QgsFields &fields, QgsPostgresConn *conn, QgsPostgresPrimaryKeyType pkType, const QList &pkAttrs, const std::shared_ptr &sharedData ); - static QString whereClause( const QgsFeatureIds &featureIds, - const QgsFields &fields, - QgsPostgresConn *conn, - QgsPostgresPrimaryKeyType pkType, - const QList &pkAttrs, - const std::shared_ptr &sharedData ); + static QString whereClause( const QgsFeatureIds &featureIds, const QgsFields &fields, QgsPostgresConn *conn, QgsPostgresPrimaryKeyType pkType, const QList &pkAttrs, const std::shared_ptr &sharedData ); static QString andWhereClauses( const QString &c1, const QString &c2 ); @@ -574,7 +553,7 @@ class QgsPostgresSharedData QVariantList lookupKey( QgsFeatureId featureId ); void clear(); - void clearSupportsEnumValuesCache( ); + void clearSupportsEnumValuesCache(); bool fieldSupportsEnumValuesIsSet( int index ); bool fieldSupportsEnumValues( int index ); void setFieldSupportsEnumValues( int index, bool isSupported ); @@ -582,35 +561,29 @@ class QgsPostgresSharedData protected: QMutex mMutex; //!< Access to all data members is guarded by the mutex - long long mFeaturesCounted = -1 ; //!< Number of features in the layer + long long mFeaturesCounted = -1; //!< Number of features in the layer - QgsFeatureId mFidCounter = 0; // next feature id if map is used - QMap mKeyToFid; // map key values to feature id - QMap mFidToKey; // map feature id back to key values - QMap mFieldSupportsEnumValues; // map field index to bool flag supports enum values + QgsFeatureId mFidCounter = 0; // next feature id if map is used + QMap mKeyToFid; // map key values to feature id + QMap mFidToKey; // map feature id back to key values + QMap mFieldSupportsEnumValues; // map field index to bool flag supports enum values }; -class QgsPostgresProviderMetadata final: public QgsProviderMetadata +class QgsPostgresProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: QgsPostgresProviderMetadata(); QIcon icon() const override; QgsDataProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; - QList< QgsDataItemProvider * > dataItemProviders() const override; - Qgis::VectorExportResult createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap &oldToNewAttrIdxMap, QString &errorMessage, - const QMap *options ) override; + QList dataItemProviders() const override; + Qgis::VectorExportResult createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) override; bool styleExists( const QString &uri, const QString &styleId, QString &errorCause ) override; - bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, - const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; + bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; QString loadStyle( const QString &uri, QString &errCause ) override; virtual QString loadStoredStyle( const QString &uri, QString &styleName, QString &errCause ) override; - int listStyles( const QString &uri, QStringList &ids, - QStringList &names, QStringList &descriptions, QString &errCause ) override; + int listStyles( const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause ) override; bool deleteStyleById( const QString &uri, const QString &styleId, QString &errCause ) override; QString getStyleById( const QString &uri, const QString &styleId, QString &errCause ) override; QgsTransaction *createTransaction( const QString &connString ) override; @@ -623,7 +596,7 @@ class QgsPostgresProviderMetadata final: public QgsProviderMetadata void cleanupProvider() override; QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; bool saveLayerMetadata( const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage ) override; QgsProviderMetadata::ProviderCapabilities providerCapabilities() const override; }; diff --git a/src/providers/postgres/qgspostgresproviderconnection.cpp b/src/providers/postgres/qgspostgresproviderconnection.cpp index d5e16dd9c80c..e73969ab09cb 100644 --- a/src/providers/postgres/qgspostgresproviderconnection.cpp +++ b/src/providers/postgres/qgspostgresproviderconnection.cpp @@ -34,8 +34,7 @@ extern "C" } // From configuration -const QStringList QgsPostgresProviderConnection::CONFIGURATION_PARAMETERS = -{ +const QStringList QgsPostgresProviderConnection::CONFIGURATION_PARAMETERS = { QStringLiteral( "publicOnly" ), QStringLiteral( "geometryColumnsOnly" ), QStringLiteral( "dontResolveType" ), @@ -81,8 +80,8 @@ QgsPostgresProviderConnection::QgsPostgresProviderConnection( const QString &nam setDefaultCapabilities(); } -QgsPostgresProviderConnection::QgsPostgresProviderConnection( const QString &uri, const QVariantMap &configuration ): - QgsAbstractDatabaseProviderConnection( QgsDataSourceUri( uri ).connectionInfo( false ), configuration ) +QgsPostgresProviderConnection::QgsPostgresProviderConnection( const QString &uri, const QVariantMap &configuration ) + : QgsAbstractDatabaseProviderConnection( QgsDataSourceUri( uri ).connectionInfo( false ), configuration ) { mProviderKey = QStringLiteral( "postgres" ); setDefaultCapabilities(); @@ -92,8 +91,7 @@ void QgsPostgresProviderConnection::setDefaultCapabilities() { // TODO: we might check at this point if the user actually has the privileges and return // properly filtered capabilities instead of all of them - mCapabilities = - { + mCapabilities = { Capability::DropVectorTable, Capability::DropRasterTable, Capability::CreateVectorTable, @@ -117,8 +115,7 @@ void QgsPostgresProviderConnection::setDefaultCapabilities() Capability::DeleteFieldCascade, Capability::AddField }; - mGeometryColumnCapabilities = - { + mGeometryColumnCapabilities = { GeometryColumnCapability::Z, GeometryColumnCapability::M, GeometryColumnCapability::SinglePoint, @@ -127,8 +124,7 @@ void QgsPostgresProviderConnection::setDefaultCapabilities() GeometryColumnCapability::Curves, GeometryColumnCapability::PolyhedralSurfaces }; - mSqlLayerDefinitionCapabilities = - { + mSqlLayerDefinitionCapabilities = { Qgis::SqlLayerDefinitionCapability::SubsetStringFilter, Qgis::SqlLayerDefinitionCapability::PrimaryKeys, Qgis::SqlLayerDefinitionCapability::GeometryColumn, @@ -138,8 +134,7 @@ void QgsPostgresProviderConnection::setDefaultCapabilities() mCapabilities2 |= Qgis::DatabaseProviderConnectionCapability2::SetFieldComment; // see https://www.postgresql.org/docs/current/ddl-system-columns.html - mIllegalFieldNames = - { + mIllegalFieldNames = { QStringLiteral( "tableoid" ), QStringLiteral( "xmin" ), QStringLiteral( "cmin" ), @@ -153,41 +148,33 @@ void QgsPostgresProviderConnection::setDefaultCapabilities() void QgsPostgresProviderConnection::dropTablePrivate( const QString &schema, const QString &name ) const { executeSqlPrivate( QStringLiteral( "DROP TABLE %1.%2" ) - .arg( QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( name ) ) ); + .arg( QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( name ) ) ); } -void QgsPostgresProviderConnection::createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - const QMap *options ) const +void QgsPostgresProviderConnection::createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const { - checkCapability( Capability::CreateVectorTable ); QgsDataSourceUri newUri { uri() }; newUri.setSchema( schema ); newUri.setTable( name ); // Set geometry column if it's not aspatial - if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) + if ( wkbType != Qgis::WkbType::Unknown && wkbType != Qgis::WkbType::NoGeometry ) { newUri.setGeometryColumn( options->value( QStringLiteral( "geometryColumn" ), QStringLiteral( "geom" ) ).toString() ); } QMap map; QString errCause; Qgis::VectorExportResult res = QgsPostgresProvider::createEmptyLayer( - newUri.uri(), - fields, - wkbType, - srs, - overwrite, - &map, - &errCause, - options - ); + newUri.uri(), + fields, + wkbType, + srs, + overwrite, + &map, + &errCause, + options + ); if ( res != Qgis::VectorExportResult::Success ) { throw QgsProviderConnectionException( QObject::tr( "An error occurred while creating the vector layer: %1" ).arg( errCause ) ); @@ -218,9 +205,7 @@ void QgsPostgresProviderConnection::dropRasterTable( const QString &schema, cons void QgsPostgresProviderConnection::renameTablePrivate( const QString &schema, const QString &name, const QString &newName ) const { executeSqlPrivate( QStringLiteral( "ALTER TABLE %1.%2 RENAME TO %3" ) - .arg( QgsPostgresConn::quotedIdentifier( schema ), - QgsPostgresConn::quotedIdentifier( name ), - QgsPostgresConn::quotedIdentifier( newName ) ) ); + .arg( QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( name ), QgsPostgresConn::quotedIdentifier( newName ) ) ); } QList QgsPostgresProviderConnection::tablesPrivate( const QString &schema, const QString &table, const TableFlags &flags, QgsFeedback *feedback ) const @@ -242,8 +227,8 @@ QList QgsPostgresProviderC { bool ok { false }; QVector properties; - const bool aspatial { ! flags || flags.testFlag( TableFlag::Aspatial ) }; - if ( ! table.isEmpty() ) + const bool aspatial { !flags || flags.testFlag( TableFlag::Aspatial ) }; + if ( !table.isEmpty() ) { QgsPostgresLayerProperty property; ok = conn->supportedLayer( property, schema, table ); @@ -257,9 +242,9 @@ QList QgsPostgresProviderC ok = conn->supportedLayers( properties, false, schema == QStringLiteral( "public" ), aspatial, schema ); } - if ( ! ok ) + if ( !ok ) { - if ( ! table.isEmpty() ) + if ( !table.isEmpty() ) { errCause = QObject::tr( "Could not retrieve table '%2' from %1" ).arg( uri(), table ); } @@ -270,7 +255,6 @@ QList QgsPostgresProviderC } else { - bool dontResolveType = configuration().value( QStringLiteral( "dontResolveType" ), false ).toBool(); bool useEstimatedMetadata = configuration().value( QStringLiteral( "estimatedMetadata" ), false ).toBool(); @@ -304,18 +288,16 @@ QList QgsPostgresProviderC prFlags.setFlag( QgsPostgresProviderConnection::TableFlag::Aspatial ); } // Filter - if ( ! flags || ( prFlags & flags ) ) + if ( !flags || ( prFlags & flags ) ) { // retrieve layer types if needed - if ( ! dontResolveType && ( !pr.geometryColName.isNull() && - ( pr.types.value( 0, Qgis::WkbType::Unknown ) == Qgis::WkbType::Unknown || - pr.srids.value( 0, std::numeric_limits::min() ) == std::numeric_limits::min() ) ) ) + if ( !dontResolveType && ( !pr.geometryColName.isNull() && ( pr.types.value( 0, Qgis::WkbType::Unknown ) == Qgis::WkbType::Unknown || pr.srids.value( 0, std::numeric_limits::min() ) == std::numeric_limits::min() ) ) ) { conn->retrieveLayerTypes( pr, useEstimatedMetadata, feedback ); } QgsPostgresProviderConnection::TableProperty property; property.setFlags( prFlags ); - for ( int i = 0; i < std::min( pr.types.size(), pr.srids.size() ) ; i++ ) + for ( int i = 0; i < std::min( pr.types.size(), pr.srids.size() ); i++ ) { property.addGeometryColumnType( pr.types.at( i ), QgsCoordinateReferenceSystem::fromEpsgId( pr.srids.at( i ) ) ); } @@ -335,7 +317,7 @@ QList QgsPostgresProviderC // Set the candidates property.setPrimaryKeyColumns( pr.pkCols ); } - else // Fetch and set the real pks + else // Fetch and set the real pks { try { @@ -345,7 +327,9 @@ QList QgsPostgresProviderC ORDER BY CASE WHEN indisprimary THEN 1 ELSE 2 END LIMIT 1) SELECT attname FROM pg_index,pg_attribute, pkrelid WHERE indexrelid=pkrelid.idxri AND indrelid=attrelid AND pg_attribute.attnum=any(pg_index.indkey); - )" ).arg( QgsPostgresConn::quotedValue( QString( QgsPostgresConn::quotedIdentifier( pr.schemaName ) + "." + QgsPostgresConn::quotedIdentifier( pr.tableName ) ) ) ), false ); + )" ) + .arg( QgsPostgresConn::quotedValue( QString( QgsPostgresConn::quotedIdentifier( pr.schemaName ) + "." + QgsPostgresConn::quotedIdentifier( pr.tableName ) ) ) ), + false ); QStringList pkNames; for ( const QVariantList &pk : std::as_const( pks ) ) { @@ -365,7 +349,7 @@ QList QgsPostgresProviderC } QgsPostgresConnPool::instance()->releaseConnection( conn ); } - if ( ! errCause.isEmpty() ) + if ( !errCause.isEmpty() ) { throw QgsProviderConnectionException( errCause ); } @@ -388,24 +372,21 @@ void QgsPostgresProviderConnection::createSchema( const QString &name ) const { checkCapability( Capability::CreateSchema ); executeSqlPrivate( QStringLiteral( "CREATE SCHEMA %1" ) - .arg( QgsPostgresConn::quotedIdentifier( name ) ) ); - + .arg( QgsPostgresConn::quotedIdentifier( name ) ) ); } -void QgsPostgresProviderConnection::dropSchema( const QString &name, bool force ) const +void QgsPostgresProviderConnection::dropSchema( const QString &name, bool force ) const { checkCapability( Capability::DropSchema ); executeSqlPrivate( QStringLiteral( "DROP SCHEMA %1 %2" ) - .arg( QgsPostgresConn::quotedIdentifier( name ), - force ? QStringLiteral( "CASCADE" ) : QString() ) ); + .arg( QgsPostgresConn::quotedIdentifier( name ), force ? QStringLiteral( "CASCADE" ) : QString() ) ); } void QgsPostgresProviderConnection::renameSchema( const QString &name, const QString &newName ) const { checkCapability( Capability::RenameSchema ); executeSqlPrivate( QStringLiteral( "ALTER SCHEMA %1 RENAME TO %2" ) - .arg( QgsPostgresConn::quotedIdentifier( name ), - QgsPostgresConn::quotedIdentifier( newName ) ) ); + .arg( QgsPostgresConn::quotedIdentifier( name ), QgsPostgresConn::quotedIdentifier( newName ) ) ); } QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection::execSql( const QString &sql, QgsFeedback *feedback ) const @@ -421,7 +402,7 @@ QList QgsPostgresProviderConnection::executeSqlPrivate( const QStr QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection::execSqlPrivate( const QString &sql, bool resolveTypes, QgsFeedback *feedback, std::shared_ptr pgconn ) const { - if ( ! pgconn ) + if ( !pgconn ) { pgconn = std::make_shared( QgsDataSourceUri( uri() ).connectionInfo( false ) ); } @@ -437,13 +418,12 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection QgsPostgresConn *conn = pgconn->get(); - if ( ! conn ) + if ( !conn ) { throw QgsProviderConnectionException( QObject::tr( "Connection failed: %1" ).arg( uri() ) ); } else { - if ( feedback && feedback->isCanceled() ) { return results; @@ -453,8 +433,7 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection QMetaObject::Connection qtConnection; if ( feedback ) { - qtConnection = QObject::connect( feedback, &QgsFeedback::canceled, [ &pgconn ] - { + qtConnection = QObject::connect( feedback, &QgsFeedback::canceled, [&pgconn] { if ( pgconn ) pgconn->get()->PQCancel(); } ); @@ -471,25 +450,26 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection } QString errCause; - if ( conn->PQstatus() != CONNECTION_OK || ! res->result() ) + if ( conn->PQstatus() != CONNECTION_OK || !res->result() ) { errCause = QObject::tr( "Connection error: %1 returned %2 [%3]" ) - .arg( sql ).arg( conn->PQstatus() ) - .arg( conn->PQerrorMessage() ); + .arg( sql ) + .arg( conn->PQstatus() ) + .arg( conn->PQerrorMessage() ); } else { const QString err { conn->PQerrorMessage() }; - if ( ! err.isEmpty() ) + if ( !err.isEmpty() ) { errCause = QObject::tr( "SQL error: %1 returned %2 [%3]" ) - .arg( sql ) - .arg( conn->PQstatus() ) - .arg( err ); + .arg( sql ) + .arg( conn->PQstatus() ) + .arg( err ); } } - if ( ! errCause.isEmpty() ) + if ( !errCause.isEmpty() ) { throw QgsProviderConnectionException( errCause ); } @@ -498,7 +478,6 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection if ( numRows > 0 ) { - // Get column names for ( int rowIdx = 0; rowIdx < res->PQnfields(); rowIdx++ ) { @@ -527,7 +506,7 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection for ( const auto &typeRes : std::as_const( typesResolved ) ) { const QString oid { typeRes.constLast().toString() }; - if ( ! oidTypeMap.contains( oid ) ) + if ( !oidTypeMap.contains( oid ) ) { oidTypeMap.insert( typeRes.constFirst().toString(), typeRes.constLast().toString() ); } @@ -535,17 +514,15 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection for ( int rowIdx = 0; rowIdx < numFields; rowIdx++ ) { - static const QStringList intTypes = { QStringLiteral( "oid" ), - QStringLiteral( "int2" ), - QStringLiteral( "int4" ), - QStringLiteral( "int8" ), - }; - static const QStringList floatTypes = { QStringLiteral( "float4" ), - QStringLiteral( "float8" ), - QStringLiteral( "numeric" ) - }; - - const QString typName { oidTypeMap[ oids.at( rowIdx )] }; + static const QStringList intTypes = { + QStringLiteral( "oid" ), + QStringLiteral( "int2" ), + QStringLiteral( "int4" ), + QStringLiteral( "int8" ), + }; + static const QStringList floatTypes = { QStringLiteral( "float4" ), QStringLiteral( "float8" ), QStringLiteral( "numeric" ) }; + + const QString typName { oidTypeMap[oids.at( rowIdx )] }; QMetaType::Type vType { QMetaType::Type::QString }; if ( floatTypes.contains( typName ) ) { @@ -580,11 +557,11 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsPostgresProviderConnection // Just a warning, usually ok QgsDebugMsgLevel( QStringLiteral( "Unhandled PostgreSQL type %1, assuming string" ).arg( typName ), 2 ); } - static_cast( iterator.get() )->typeMap[ rowIdx ] = vType; + static_cast( iterator.get() )->typeMap[rowIdx] = vType; } } } - if ( ! errCause.isEmpty() ) + if ( !errCause.isEmpty() ) { throw QgsProviderConnectionException( errCause ); } @@ -616,7 +593,7 @@ QVariantList QgsPostgresProviderResultIterator::nextRowPrivate() if ( vType == QMetaType::Type::Bool ) { const QString boolStrVal { val.toString() }; - if ( ! boolStrVal.isEmpty() ) + if ( !boolStrVal.isEmpty() ) { val = boolStrVal == 't'; } @@ -643,18 +620,16 @@ bool QgsPostgresProviderResultIterator::hasNextRowPrivate() const long long QgsPostgresProviderResultIterator::rowCountPrivate() const { - return result ? result->PQntuples() : static_cast< long long >( Qgis::FeatureCountState::UnknownCount ); + return result ? result->PQntuples() : static_cast( Qgis::FeatureCountState::UnknownCount ); } void QgsPostgresProviderConnection::vacuum( const QString &schema, const QString &name ) const { checkCapability( Capability::Vacuum ); - if ( ! schema.isEmpty() && ! name.isEmpty() ) + if ( !schema.isEmpty() && !name.isEmpty() ) { - executeSqlPrivate( QStringLiteral( "VACUUM FULL ANALYZE %1.%2" ) - .arg( QgsPostgresConn::quotedIdentifier( schema ), - QgsPostgresConn::quotedIdentifier( name ) ), false ); + executeSqlPrivate( QStringLiteral( "VACUUM FULL ANALYZE %1.%2" ).arg( QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( name ) ), false ); } else { @@ -687,11 +662,7 @@ void QgsPostgresProviderConnection::createSpatialIndex( const QString &schema, c } const QString indexName = QStringLiteral( "sidx_%1_%2" ).arg( name, geometryColumnName ); - executeSqlPrivate( QStringLiteral( "CREATE INDEX %1 ON %2.%3 USING GIST (%4);" ) - .arg( QgsPostgresConn::quotedIdentifier( indexName ), - QgsPostgresConn::quotedIdentifier( schema ), - QgsPostgresConn::quotedIdentifier( name ), - QgsPostgresConn::quotedIdentifier( geometryColumnName ) ), false ); + executeSqlPrivate( QStringLiteral( "CREATE INDEX %1 ON %2.%3 USING GIST (%4);" ).arg( QgsPostgresConn::quotedIdentifier( indexName ), QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( name ), QgsPostgresConn::quotedIdentifier( geometryColumnName ) ), false ); } bool QgsPostgresProviderConnection::spatialIndexExists( const QString &schema, const QString &name, const QString &geometryColumn ) const @@ -710,10 +681,12 @@ bool QgsPostgresProviderConnection::spatialIndexExists( const QString &schema, c AND ns.nspname=%1 AND t.relname=%2 AND a.attname=%3; - )""" ).arg( - QgsPostgresConn::quotedValue( schema ), - QgsPostgresConn::quotedValue( name ), - QgsPostgresConn::quotedValue( geometryColumn ) ) ); + )""" ) + .arg( + QgsPostgresConn::quotedValue( schema ), + QgsPostgresConn::quotedValue( name ), + QgsPostgresConn::quotedValue( geometryColumn ) + ) ); return !res.isEmpty() && !res.at( 0 ).isEmpty() && res.at( 0 ).at( 0 ).toBool(); } @@ -733,27 +706,24 @@ void QgsPostgresProviderConnection::deleteSpatialIndex( const QString &schema, c AND ns.nspname=%1 AND t.relname=%2 AND a.attname=%3; - )""" ).arg( - QgsPostgresConn::quotedValue( schema ), - QgsPostgresConn::quotedValue( name ), - QgsPostgresConn::quotedValue( geometryColumn ) ) ); + )""" ) + .arg( + QgsPostgresConn::quotedValue( schema ), + QgsPostgresConn::quotedValue( name ), + QgsPostgresConn::quotedValue( geometryColumn ) + ) ); if ( res.isEmpty() ) throw QgsProviderConnectionException( QObject::tr( "No spatial index exists for %1.%2" ).arg( schema, name ) ); const QString indexName = res.at( 0 ).at( 0 ).toString(); - executeSqlPrivate( QStringLiteral( "DROP INDEX %1.%2" ).arg( QgsPostgresConn::quotedIdentifier( schema ), - QgsPostgresConn::quotedIdentifier( indexName ) ), false ); + executeSqlPrivate( QStringLiteral( "DROP INDEX %1.%2" ).arg( QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( indexName ) ), false ); } void QgsPostgresProviderConnection::setFieldComment( const QString &fieldName, const QString &schema, const QString &tableName, const QString &comment ) const { executeSqlPrivate( QStringLiteral( "COMMENT ON COLUMN %1.%2.%3 IS %4;" ) - .arg( QgsPostgresConn::quotedIdentifier( schema ), - QgsPostgresConn::quotedIdentifier( tableName ), - QgsPostgresConn::quotedIdentifier( fieldName ), - QgsPostgresConn::quotedValue( comment ) - ) ); + .arg( QgsPostgresConn::quotedIdentifier( schema ), QgsPostgresConn::quotedIdentifier( tableName ), QgsPostgresConn::quotedIdentifier( fieldName ), QgsPostgresConn::quotedValue( comment ) ) ); } QList QgsPostgresProviderConnection::tables( const QString &schema, const TableFlags &flags, QgsFeedback *feedback ) const @@ -764,18 +734,18 @@ QList QgsPostgresProviderConnectio QgsAbstractDatabaseProviderConnection::TableProperty QgsPostgresProviderConnection::table( const QString &schema, const QString &table, QgsFeedback *feedback ) const { const QList properties { tablesPrivate( schema, table, TableFlags(), feedback ) }; - if ( ! properties.empty() ) + if ( !properties.empty() ) { return properties.first(); } else { throw QgsProviderConnectionException( QObject::tr( "Table '%1' was not found in schema '%2'" ) - .arg( table, schema ) ); + .arg( table, schema ) ); } } -QStringList QgsPostgresProviderConnection::schemas( ) const +QStringList QgsPostgresProviderConnection::schemas() const { checkCapability( Capability::Schemas ); QStringList schemas; @@ -791,7 +761,7 @@ QStringList QgsPostgresProviderConnection::schemas( ) const QList schemaProperties; bool ok = conn->getSchemas( schemaProperties ); QgsPostgresConnPool::instance()->releaseConnection( conn ); - if ( ! ok ) + if ( !ok ) { errCause = QObject::tr( "Could not retrieve schemas: %1" ).arg( uri() ); } @@ -803,7 +773,7 @@ QStringList QgsPostgresProviderConnection::schemas( ) const } } } - if ( ! errCause.isEmpty() ) + if ( !errCause.isEmpty() ) { throw QgsProviderConnectionException( errCause ); } @@ -824,7 +794,7 @@ void QgsPostgresProviderConnection::store( const QString &name ) const // From URI const QgsDataSourceUri dsUri { uri() }; settings.setValue( "service", dsUri.service() ); - settings.setValue( "host", dsUri.host() ); + settings.setValue( "host", dsUri.host() ); settings.setValue( "port", dsUri.port() ); settings.setValue( "database", dsUri.database() ); settings.setValue( "username", dsUri.username() ); @@ -857,7 +827,7 @@ QIcon QgsPostgresProviderConnection::icon() const QList QgsPostgresProviderConnection::nativeTypes() const { QList types; - QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( QgsDataSourceUri{ uri() } .connectionInfo( false ) ); + QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( QgsDataSourceUri { uri() }.connectionInfo( false ) ); if ( conn ) { types = conn->nativeTypes(); @@ -897,12 +867,12 @@ QgsVectorLayer *QgsPostgresProviderConnection::createSqlVectorLayer( const SqlVe throw QgsProviderConnectionException( QObject::tr( "Could not create a SQL vector layer: SQL expression is empty." ) ); } - QgsDataSourceUri tUri( uri( ) ); + QgsDataSourceUri tUri( uri() ); tUri.setSql( options.filter ); tUri.disableSelectAtId( options.disableSelectAtId ); - if ( ! options.primaryKeyColumns.isEmpty() ) + if ( !options.primaryKeyColumns.isEmpty() ) { tUri.setKeyColumn( options.primaryKeyColumns.join( ',' ) ); tUri.setTable( QStringLiteral( "(%1)" ).arg( options.sql ) ); @@ -912,968 +882,964 @@ QgsVectorLayer *QgsPostgresProviderConnection::createSqlVectorLayer( const SqlVe int pkId { 0 }; while ( options.sql.contains( QStringLiteral( "_uid%1_" ).arg( pkId ), Qt::CaseSensitivity::CaseInsensitive ) ) { - pkId ++; + pkId++; } tUri.setKeyColumn( QStringLiteral( "_uid%1_" ).arg( pkId ) ); int sqlId { 0 }; while ( options.sql.contains( QStringLiteral( "_subq_%1_" ).arg( sqlId ), Qt::CaseSensitivity::CaseInsensitive ) ) { - sqlId ++; + sqlId++; } tUri.setTable( QStringLiteral( "(SELECT row_number() over () AS _uid%1_, * FROM (%2\n) AS _subq_%3_\n)" ).arg( QString::number( pkId ), options.sql, QString::number( sqlId ) ) ); } - if ( ! options.geometryColumn.isEmpty() ) + if ( !options.geometryColumn.isEmpty() ) { tUri.setGeometryColumn( options.geometryColumn ); } QgsVectorLayer::LayerOptions vectorLayerOptions { false, true }; vectorLayerOptions.skipCrsValidation = true; - return new QgsVectorLayer{ tUri.uri( false ), options.layerName.isEmpty() ? QStringLiteral( "QueryLayer" ) : options.layerName, providerKey(), vectorLayerOptions }; + return new QgsVectorLayer { tUri.uri( false ), options.layerName.isEmpty() ? QStringLiteral( "QueryLayer" ) : options.layerName, providerKey(), vectorLayerOptions }; } QMultiMap QgsPostgresProviderConnection::sqlDictionary() { return QgsAbstractDatabaseProviderConnection::sqlDictionary().unite( - { - { - Qgis::SqlKeywordCategory::Keyword, - { - QStringLiteral( "absolute" ), - QStringLiteral( "action" ), - QStringLiteral( "add" ), - QStringLiteral( "admin" ), - QStringLiteral( "after" ), - QStringLiteral( "aggregate" ), - QStringLiteral( "alias" ), - QStringLiteral( "all" ), - QStringLiteral( "allocate" ), - QStringLiteral( "alter" ), - QStringLiteral( "analyse" ), - QStringLiteral( "analyze" ), - QStringLiteral( "and" ), - QStringLiteral( "any" ), - QStringLiteral( "are" ), - QStringLiteral( "array" ), - QStringLiteral( "as" ), - QStringLiteral( "asc" ), - QStringLiteral( "asensitive" ), - QStringLiteral( "assertion" ), - QStringLiteral( "asymmetric" ), - QStringLiteral( "at" ), - QStringLiteral( "atomic" ), - QStringLiteral( "authorization" ), - QStringLiteral( "avg" ), - QStringLiteral( "before" ), - QStringLiteral( "begin" ), - QStringLiteral( "between" ), - QStringLiteral( "bigint" ), - QStringLiteral( "binary" ), - QStringLiteral( "bit" ), - QStringLiteral( "bit_length" ), - QStringLiteral( "blob" ), - QStringLiteral( "boolean" ), - QStringLiteral( "both" ), - QStringLiteral( "breadth" ), - QStringLiteral( "by" ), - QStringLiteral( "call" ), - QStringLiteral( "called" ), - QStringLiteral( "cardinality" ), - QStringLiteral( "cascade" ), - QStringLiteral( "cascaded" ), - QStringLiteral( "case" ), - QStringLiteral( "cast" ), - QStringLiteral( "catalog" ), - QStringLiteral( "ceil" ), - QStringLiteral( "ceiling" ), - QStringLiteral( "char" ), - QStringLiteral( "character" ), - QStringLiteral( "character_length" ), - QStringLiteral( "char_length" ), - QStringLiteral( "check" ), - QStringLiteral( "class" ), - QStringLiteral( "clob" ), - QStringLiteral( "close" ), - QStringLiteral( "coalesce" ), - QStringLiteral( "collate" ), - QStringLiteral( "collation" ), - QStringLiteral( "collect" ), - QStringLiteral( "column" ), - QStringLiteral( "commit" ), - QStringLiteral( "completion" ), - QStringLiteral( "condition" ), - QStringLiteral( "connect" ), - QStringLiteral( "connection" ), - QStringLiteral( "constraint" ), - QStringLiteral( "constraints" ), - QStringLiteral( "constructor" ), - QStringLiteral( "continue" ), - QStringLiteral( "convert" ), - QStringLiteral( "corr" ), - QStringLiteral( "corresponding" ), - QStringLiteral( "count" ), - QStringLiteral( "covar_pop" ), - QStringLiteral( "covar_samp" ), - QStringLiteral( "create" ), - QStringLiteral( "cross" ), - QStringLiteral( "cube" ), - QStringLiteral( "cume_dist" ), - QStringLiteral( "current" ), - QStringLiteral( "current_date" ), - QStringLiteral( "current_default_transform_group" ), - QStringLiteral( "current_path" ), - QStringLiteral( "current_role" ), - QStringLiteral( "current_time" ), - QStringLiteral( "current_timestamp" ), - QStringLiteral( "current_transform_group_for_type" ), - QStringLiteral( "current_user" ), - QStringLiteral( "cursor" ), - QStringLiteral( "cycle" ), - QStringLiteral( "data" ), - QStringLiteral( "date" ), - QStringLiteral( "day" ), - QStringLiteral( "deallocate" ), - QStringLiteral( "dec" ), - QStringLiteral( "decimal" ), - QStringLiteral( "declare" ), - QStringLiteral( "default" ), - QStringLiteral( "deferrable" ), - QStringLiteral( "deferred" ), - QStringLiteral( "delete" ), - QStringLiteral( "dense_rank" ), - QStringLiteral( "depth" ), - QStringLiteral( "deref" ), - QStringLiteral( "desc" ), - QStringLiteral( "describe" ), - QStringLiteral( "descriptor" ), - QStringLiteral( "destroy" ), - QStringLiteral( "destructor" ), - QStringLiteral( "deterministic" ), - QStringLiteral( "diagnostics" ), - QStringLiteral( "dictionary" ), - QStringLiteral( "disconnect" ), - QStringLiteral( "distinct" ), - QStringLiteral( "do" ), - QStringLiteral( "domain" ), - QStringLiteral( "double" ), - QStringLiteral( "drop" ), - QStringLiteral( "dynamic" ), - QStringLiteral( "each" ), - QStringLiteral( "element" ), - QStringLiteral( "else" ), - QStringLiteral( "end" ), - QStringLiteral( "end-exec" ), - QStringLiteral( "equals" ), - QStringLiteral( "escape" ), - QStringLiteral( "every" ), - QStringLiteral( "except" ), - QStringLiteral( "exception" ), - QStringLiteral( "exec" ), - QStringLiteral( "execute" ), - QStringLiteral( "exists" ), - QStringLiteral( "exp" ), - QStringLiteral( "external" ), - QStringLiteral( "extract" ), - QStringLiteral( "false" ), - QStringLiteral( "fetch" ), - QStringLiteral( "filter" ), - QStringLiteral( "first" ), - QStringLiteral( "float" ), - QStringLiteral( "floor" ), - QStringLiteral( "for" ), - QStringLiteral( "foreign" ), - QStringLiteral( "found" ), - QStringLiteral( "free" ), - QStringLiteral( "freeze" ), - QStringLiteral( "from" ), - QStringLiteral( "full" ), - QStringLiteral( "function" ), - QStringLiteral( "fusion" ), - QStringLiteral( "general" ), - QStringLiteral( "get" ), - QStringLiteral( "global" ), - QStringLiteral( "go" ), - QStringLiteral( "goto" ), - QStringLiteral( "grant" ), - QStringLiteral( "group" ), - QStringLiteral( "grouping" ), - QStringLiteral( "having" ), - QStringLiteral( "hold" ), - QStringLiteral( "host" ), - QStringLiteral( "hour" ), - QStringLiteral( "identity" ), - QStringLiteral( "ignore" ), - QStringLiteral( "ilike" ), - QStringLiteral( "immediate" ), - QStringLiteral( "in" ), - QStringLiteral( "indicator" ), - QStringLiteral( "initialize" ), - QStringLiteral( "initially" ), - QStringLiteral( "inner" ), - QStringLiteral( "inout" ), - QStringLiteral( "input" ), - QStringLiteral( "insensitive" ), - QStringLiteral( "insert" ), - QStringLiteral( "int" ), - QStringLiteral( "integer" ), - QStringLiteral( "intersect" ), - QStringLiteral( "intersection" ), - QStringLiteral( "interval" ), - QStringLiteral( "into" ), - QStringLiteral( "is" ), - QStringLiteral( "isnull" ), - QStringLiteral( "isolation" ), - QStringLiteral( "iterate" ), - QStringLiteral( "join" ), - QStringLiteral( "key" ), - QStringLiteral( "language" ), - QStringLiteral( "large" ), - QStringLiteral( "last" ), - QStringLiteral( "lateral" ), - QStringLiteral( "leading" ), - QStringLiteral( "left" ), - QStringLiteral( "less" ), - QStringLiteral( "level" ), - QStringLiteral( "like" ), - QStringLiteral( "limit" ), - QStringLiteral( "ln" ), - QStringLiteral( "local" ), - QStringLiteral( "localtime" ), - QStringLiteral( "localtimestamp" ), - QStringLiteral( "locator" ), - QStringLiteral( "lower" ), - QStringLiteral( "map" ), - QStringLiteral( "match" ), - QStringLiteral( "max" ), - QStringLiteral( "member" ), - QStringLiteral( "merge" ), - QStringLiteral( "method" ), - QStringLiteral( "min" ), - QStringLiteral( "minute" ), - QStringLiteral( "mod" ), - QStringLiteral( "modifies" ), - QStringLiteral( "modify" ), - QStringLiteral( "module" ), - QStringLiteral( "month" ), - QStringLiteral( "multiset" ), - QStringLiteral( "names" ), - QStringLiteral( "national" ), - QStringLiteral( "natural" ), - QStringLiteral( "nchar" ), - QStringLiteral( "nclob" ), - QStringLiteral( "new" ), - QStringLiteral( "next" ), - QStringLiteral( "no" ), - QStringLiteral( "none" ), - QStringLiteral( "normalize" ), - QStringLiteral( "not" ), - QStringLiteral( "notnull" ), - QStringLiteral( "null" ), - QStringLiteral( "nullif" ), - QStringLiteral( "numeric" ), - QStringLiteral( "object" ), - QStringLiteral( "octet_length" ), - QStringLiteral( "of" ), - QStringLiteral( "off" ), - QStringLiteral( "offset" ), - QStringLiteral( "old" ), - QStringLiteral( "on" ), - QStringLiteral( "only" ), - QStringLiteral( "open" ), - QStringLiteral( "operation" ), - QStringLiteral( "option" ), - QStringLiteral( "or" ), - QStringLiteral( "order" ), - QStringLiteral( "ordinality" ), - QStringLiteral( "out" ), - QStringLiteral( "outer" ), - QStringLiteral( "output" ), - QStringLiteral( "over" ), - QStringLiteral( "overlaps" ), - QStringLiteral( "overlay" ), - QStringLiteral( "pad" ), - QStringLiteral( "parameter" ), - QStringLiteral( "parameters" ), - QStringLiteral( "partial" ), - QStringLiteral( "partition" ), - QStringLiteral( "path" ), - QStringLiteral( "percentile_cont" ), - QStringLiteral( "percentile_disc" ), - QStringLiteral( "percent_rank" ), - QStringLiteral( "placing" ), - QStringLiteral( "position" ), - QStringLiteral( "postfix" ), - QStringLiteral( "power" ), - QStringLiteral( "precision" ), - QStringLiteral( "prefix" ), - QStringLiteral( "preorder" ), - QStringLiteral( "prepare" ), - QStringLiteral( "preserve" ), - QStringLiteral( "primary" ), - QStringLiteral( "prior" ), - QStringLiteral( "privileges" ), - QStringLiteral( "procedure" ), - QStringLiteral( "public" ), - QStringLiteral( "range" ), - QStringLiteral( "rank" ), - QStringLiteral( "read" ), - QStringLiteral( "reads" ), - QStringLiteral( "real" ), - QStringLiteral( "recursive" ), - QStringLiteral( "ref" ), - QStringLiteral( "references" ), - QStringLiteral( "referencing" ), - QStringLiteral( "regr_avgx" ), - QStringLiteral( "regr_avgy" ), - QStringLiteral( "regr_count" ), - QStringLiteral( "regr_intercept" ), - QStringLiteral( "regr_r2" ), - QStringLiteral( "regr_slope" ), - QStringLiteral( "regr_sxx" ), - QStringLiteral( "regr_sxy" ), - QStringLiteral( "regr_syy" ), - QStringLiteral( "relative" ), - QStringLiteral( "release" ), - QStringLiteral( "restrict" ), - QStringLiteral( "result" ), - QStringLiteral( "return" ), - QStringLiteral( "returning" ), - QStringLiteral( "returns" ), - QStringLiteral( "revoke" ), - QStringLiteral( "right" ), - QStringLiteral( "role" ), - QStringLiteral( "rollback" ), - QStringLiteral( "rollup" ), - QStringLiteral( "routine" ), - QStringLiteral( "row" ), - QStringLiteral( "row_number" ), - QStringLiteral( "rows" ), - QStringLiteral( "savepoint" ), - QStringLiteral( "schema" ), - QStringLiteral( "scope" ), - QStringLiteral( "scroll" ), - QStringLiteral( "search" ), - QStringLiteral( "second" ), - QStringLiteral( "section" ), - QStringLiteral( "select" ), - QStringLiteral( "sensitive" ), - QStringLiteral( "sequence" ), - QStringLiteral( "session" ), - QStringLiteral( "session_user" ), - QStringLiteral( "set" ), - QStringLiteral( "sets" ), - QStringLiteral( "similar" ), - QStringLiteral( "size" ), - QStringLiteral( "smallint" ), - QStringLiteral( "some" ), - QStringLiteral( "space" ), - QStringLiteral( "specific" ), - QStringLiteral( "specifictype" ), - QStringLiteral( "sql" ), - QStringLiteral( "sqlcode" ), - QStringLiteral( "sqlerror" ), - QStringLiteral( "sqlexception" ), - QStringLiteral( "sqlstate" ), - QStringLiteral( "sqlwarning" ), - QStringLiteral( "sqrt" ), - QStringLiteral( "start" ), - QStringLiteral( "state" ), - QStringLiteral( "statement" ), - QStringLiteral( "static" ), - QStringLiteral( "stddev_pop" ), - QStringLiteral( "stddev_samp" ), - QStringLiteral( "structure" ), - QStringLiteral( "submultiset" ), - QStringLiteral( "substring" ), - QStringLiteral( "sum" ), - QStringLiteral( "symmetric" ), - QStringLiteral( "system" ), - QStringLiteral( "system_user" ), - QStringLiteral( "table" ), - QStringLiteral( "tablesample" ), - QStringLiteral( "temporary" ), - QStringLiteral( "terminate" ), - QStringLiteral( "than" ), - QStringLiteral( "then" ), - QStringLiteral( "time" ), - QStringLiteral( "timestamp" ), - QStringLiteral( "timezone_hour" ), - QStringLiteral( "timezone_minute" ), - QStringLiteral( "to" ), - QStringLiteral( "trailing" ), - QStringLiteral( "transaction" ), - QStringLiteral( "translate" ), - QStringLiteral( "translation" ), - QStringLiteral( "treat" ), - QStringLiteral( "trigger" ), - QStringLiteral( "trim" ), - QStringLiteral( "true" ), - QStringLiteral( "uescape" ), - QStringLiteral( "under" ), - QStringLiteral( "union" ), - QStringLiteral( "unique" ), - QStringLiteral( "unknown" ), - QStringLiteral( "unnest" ), - QStringLiteral( "update" ), - QStringLiteral( "upper" ), - QStringLiteral( "usage" ), - QStringLiteral( "user" ), - QStringLiteral( "using" ), - QStringLiteral( "value" ), - QStringLiteral( "values" ), - QStringLiteral( "varchar" ), - QStringLiteral( "variable" ), - QStringLiteral( "var_pop" ), - QStringLiteral( "var_samp" ), - QStringLiteral( "varying" ), - QStringLiteral( "verbose" ), - QStringLiteral( "view" ), - QStringLiteral( "when" ), - QStringLiteral( "whenever" ), - QStringLiteral( "where" ), - QStringLiteral( "width_bucket" ), - QStringLiteral( "window" ), - QStringLiteral( "with" ), - QStringLiteral( "within" ), - QStringLiteral( "without" ), - QStringLiteral( "work" ), - QStringLiteral( "write" ), - QStringLiteral( "xml" ), - QStringLiteral( "xmlagg" ), - QStringLiteral( "xmlattributes" ), - QStringLiteral( "xmlbinary" ), - QStringLiteral( "xmlcomment" ), - QStringLiteral( "xmlconcat" ), - QStringLiteral( "xmlelement" ), - QStringLiteral( "xmlforest" ), - QStringLiteral( "xmlnamespaces" ), - QStringLiteral( "xmlparse" ), - QStringLiteral( "xmlpi" ), - QStringLiteral( "xmlroot" ), - QStringLiteral( "xmlserialize" ), - QStringLiteral( "year" ), - QStringLiteral( "zone" ), - } - }, - { - Qgis::SqlKeywordCategory::Aggregate, - { - QStringLiteral( "Max" ), - QStringLiteral( "Min" ), - QStringLiteral( "Avg" ), - QStringLiteral( "Count" ), - QStringLiteral( "Sum" ), - QStringLiteral( "Group_Concat" ), - QStringLiteral( "Total" ), - QStringLiteral( "Var_Pop" ), - QStringLiteral( "Var_Samp" ), - QStringLiteral( "StdDev_Pop" ), - QStringLiteral( "StdDev_Samp" ), - } - }, - { - Qgis::SqlKeywordCategory::Math, - { - QStringLiteral( "Abs" ), - QStringLiteral( "ACos" ), - QStringLiteral( "ASin" ), - QStringLiteral( "ATan" ), - QStringLiteral( "Cos" ), - QStringLiteral( "Cot" ), - QStringLiteral( "Degrees" ), - QStringLiteral( "Exp" ), - QStringLiteral( "Floor" ), - QStringLiteral( "Log" ), - QStringLiteral( "Log2" ), - - QStringLiteral( "Log10" ), - QStringLiteral( "Pi" ), - QStringLiteral( "Radians" ), - QStringLiteral( "Round" ), - QStringLiteral( "Sign" ), - QStringLiteral( "Sin" ), - QStringLiteral( "Sqrt" ), - QStringLiteral( "StdDev_Pop" ), - QStringLiteral( "StdDev_Samp" ), - QStringLiteral( "Tan" ), - QStringLiteral( "Var_Pop" ), - QStringLiteral( "Var_Samp" ), - } - }, - { - Qgis::SqlKeywordCategory::Geospatial, - { - // List from: - // import requests, re, html; - // result = requests.get('https://postgis.net/docs/PostGIS_Special_Functions_Index.html') - // m = re.findall('.*?', result.content.replace(b'\xc2', b'').replace(b'\xa0', b'').decode('utf8'), re.MULTILINE) - // for f_name in sorted(set(m)): - // print(f' QStringLiteral( "{html.unescape(f_name)}" ),') - - QStringLiteral( "&&" ), - QStringLiteral( "&&&" ), - QStringLiteral( "&&&(geometry,gidx)" ), - QStringLiteral( "&&&(gidx,geometry)" ), - QStringLiteral( "&&&(gidx,gidx)" ), - QStringLiteral( "&&(box2df,box2df)" ), - QStringLiteral( "&&(box2df,geometry)" ), - QStringLiteral( "&&(geometry,box2df)" ), - QStringLiteral( "&>" ), - QStringLiteral( "&<" ), - QStringLiteral( "&<|" ), - QStringLiteral( "<#>" ), - QStringLiteral( "<<#>>" ), - QStringLiteral( "<<->>" ), - QStringLiteral( "<->" ), - QStringLiteral( "=" ), - QStringLiteral( "@" ), - QStringLiteral( "@(box2df,box2df)" ), - QStringLiteral( "@(box2df,geometry)" ), - QStringLiteral( "@(geometry,box2df)" ), - QStringLiteral( "AddEdge" ), - QStringLiteral( "AddFace" ), - QStringLiteral( "AddGeometryColumn" ), - QStringLiteral( "AddNode" ), - QStringLiteral( "AddOverviewConstraints" ), - QStringLiteral( "AddRasterConstraints" ), - QStringLiteral( "AsGML" ), - QStringLiteral( "AsTopoJSON" ), - QStringLiteral( "Box2D" ), - QStringLiteral( "Box3D" ), - QStringLiteral( "CopyTopology" ), - QStringLiteral( "DropGeometryColumn" ), - QStringLiteral( "DropOverviewConstraints" ), - QStringLiteral( "DropRasterConstraints" ), - QStringLiteral( "Drop_Indexes_Generate_Script" ), - QStringLiteral( "Drop_Nation_Tables_Generate_Script" ), - QStringLiteral( "Drop_State_Tables_Generate_Script" ), - QStringLiteral( "Equals" ), - QStringLiteral( "Geocode" ), - QStringLiteral( "Geocode_Intersection" ), - QStringLiteral( "GeometryType" ), - QStringLiteral( "GetEdgeByPoint" ), - QStringLiteral( "GetFaceByPoint" ), - QStringLiteral( "GetNodeByPoint" ), - QStringLiteral( "GetNodeEdges" ), - QStringLiteral( "GetRingEdges" ), - QStringLiteral( "GetTopoGeomElements" ), - QStringLiteral( "GetTopologySRID" ), - QStringLiteral( "Get_Geocode_Setting" ), - QStringLiteral( "Get_Tract" ), - QStringLiteral( "Install_Missing_Indexes" ), - QStringLiteral( "Intersects" ), - QStringLiteral( "Loader_Generate_Census_Script" ), - QStringLiteral( "Loader_Generate_Nation_Script" ), - QStringLiteral( "Loader_Generate_Script" ), - QStringLiteral( "Missing_Indexes_Generate_Script" ), - QStringLiteral( "Normalize_Address" ), - QStringLiteral( "Pagc_Normalize_Address" ), - QStringLiteral( "Polygonize" ), - QStringLiteral( "Populate_Geometry_Columns" ), - QStringLiteral( "Populate_Topology_Layer" ), - QStringLiteral( "PostGIS_AddBBox" ), - QStringLiteral( "PostGIS_DropBBox" ), - QStringLiteral( "PostGIS_Extensions_Upgrade" ), - QStringLiteral( "PostGIS_HasBBox" ), - QStringLiteral( "PostGIS_LibXML_Version" ), - QStringLiteral( "Reverse_Geocode" ), - QStringLiteral( "ST_3DArea" ), - QStringLiteral( "ST_3DClosestPoint" ), - QStringLiteral( "ST_3DDFullyWithin" ), - QStringLiteral( "ST_3DDWithin" ), - QStringLiteral( "ST_3DDifference" ), - QStringLiteral( "ST_3DDistance" ), - QStringLiteral( "ST_3DExtent" ), - QStringLiteral( "ST_3DIntersection" ), - QStringLiteral( "ST_3DIntersects" ), - QStringLiteral( "ST_3DLength" ), - QStringLiteral( "ST_3DLineInterpolatePoint" ), - QStringLiteral( "ST_3DLongestLine" ), - QStringLiteral( "ST_3DMakeBox" ), - QStringLiteral( "ST_3DMaxDistance" ), - QStringLiteral( "ST_3DPerimeter" ), - QStringLiteral( "ST_3DShortestLine" ), - QStringLiteral( "ST_3DUnion" ), - QStringLiteral( "ST_AddBand" ), - QStringLiteral( "ST_AddEdgeModFace" ), - QStringLiteral( "ST_AddEdgeNewFaces" ), - QStringLiteral( "ST_AddMeasure" ), - QStringLiteral( "ST_AddPoint" ), - QStringLiteral( "ST_Affine" ), - QStringLiteral( "ST_Angle" ), - QStringLiteral( "ST_ApproximateMedialAxis" ), - QStringLiteral( "ST_Area" ), - QStringLiteral( "ST_AsBinary" ), - QStringLiteral( "ST_AsBinary/ST_AsWKB" ), - QStringLiteral( "ST_AsEWKB" ), - QStringLiteral( "ST_AsEWKT" ), - QStringLiteral( "ST_AsEncodedPolyline" ), - QStringLiteral( "ST_AsGDALRaster" ), - QStringLiteral( "ST_AsGML" ), - QStringLiteral( "ST_AsGeoJSON" ), - QStringLiteral( "ST_AsGeobuf" ), - QStringLiteral( "ST_AsHEXEWKB" ), - QStringLiteral( "ST_AsHexWKB" ), - QStringLiteral( "ST_AsJPEG" ), - QStringLiteral( "ST_AsKML" ), - QStringLiteral( "ST_AsLatLonText" ), - QStringLiteral( "ST_AsMVT" ), - QStringLiteral( "ST_AsMVTGeom" ), - QStringLiteral( "ST_AsPNG" ), - QStringLiteral( "ST_AsRaster" ), - QStringLiteral( "ST_AsSVG" ), - QStringLiteral( "ST_AsTIFF" ), - QStringLiteral( "ST_AsTWKB" ), - QStringLiteral( "ST_AsText" ), - QStringLiteral( "ST_AsX3D" ), - QStringLiteral( "ST_Aspect" ), - QStringLiteral( "ST_Azimuth" ), - QStringLiteral( "ST_Band" ), - QStringLiteral( "ST_BandFileSize" ), - QStringLiteral( "ST_BandFileTimestamp" ), - QStringLiteral( "ST_BandIsNoData" ), - QStringLiteral( "ST_BandMetaData" ), - QStringLiteral( "ST_BandNoDataValue" ), - QStringLiteral( "ST_BandPath" ), - QStringLiteral( "ST_BandPixelType" ), - QStringLiteral( "ST_Boundary" ), - QStringLiteral( "ST_BoundingDiagonal" ), - QStringLiteral( "ST_Box2dFromGeoHash" ), - QStringLiteral( "ST_Buffer" ), - QStringLiteral( "ST_CPAWithin" ), - QStringLiteral( "ST_Centroid" ), - QStringLiteral( "ST_ChaikinSmoothing" ), - QStringLiteral( "ST_Clip" ), - QStringLiteral( "ST_ClipByBox2D" ), - QStringLiteral( "ST_ClosestPoint" ), - QStringLiteral( "ST_ClosestPointOfApproach" ), - QStringLiteral( "ST_ClusterDBSCAN" ), - QStringLiteral( "ST_ClusterIntersecting" ), - QStringLiteral( "ST_ClusterKMeans" ), - QStringLiteral( "ST_ClusterWithin" ), - QStringLiteral( "ST_Collect" ), - QStringLiteral( "ST_CollectionExtract" ), - QStringLiteral( "ST_CollectionHomogenize" ), - QStringLiteral( "ST_ColorMap" ), - QStringLiteral( "ST_ConcaveHull" ), - QStringLiteral( "ST_ConstrainedDelaunayTriangles" ), - QStringLiteral( "ST_Contains" ), - QStringLiteral( "ST_ContainsProperly" ), - QStringLiteral( "ST_ConvexHull" ), - QStringLiteral( "ST_CoordDim" ), - QStringLiteral( "ST_Count" ), - QStringLiteral( "ST_CountAgg" ), - QStringLiteral( "ST_CoveredBy" ), - QStringLiteral( "ST_Covers" ), - QStringLiteral( "ST_CreateOverview" ), - QStringLiteral( "ST_CreateTopoGeo" ), - QStringLiteral( "ST_Crosses" ), - QStringLiteral( "ST_CurveToLine" ), - QStringLiteral( "ST_DFullyWithin" ), - QStringLiteral( "ST_DWithin" ), - QStringLiteral( "ST_DelaunayTriangles" ), - QStringLiteral( "ST_Difference" ), - QStringLiteral( "ST_Dimension" ), - QStringLiteral( "ST_Disjoint" ), - QStringLiteral( "ST_Distance" ), - QStringLiteral( "ST_DistanceCPA" ), - QStringLiteral( "ST_DistanceSphere" ), - QStringLiteral( "ST_DistanceSpheroid" ), - QStringLiteral( "ST_Distinct4ma" ), - QStringLiteral( "ST_Dump" ), - QStringLiteral( "ST_DumpAsPolygons" ), - QStringLiteral( "ST_DumpPoints" ), - QStringLiteral( "ST_DumpRings" ), - QStringLiteral( "ST_DumpValues" ), - QStringLiteral( "ST_EndPoint" ), - QStringLiteral( "ST_Envelope" ), - QStringLiteral( "ST_Equals" ), - QStringLiteral( "ST_EstimatedExtent" ), - QStringLiteral( "ST_Expand" ), - QStringLiteral( "ST_Extent" ), - QStringLiteral( "ST_ExteriorRing" ), - QStringLiteral( "ST_Extrude" ), - QStringLiteral( "ST_FilterByM" ), - QStringLiteral( "ST_FlipCoordinates" ), - QStringLiteral( "ST_Force2D" ), - QStringLiteral( "ST_Force3D" ), - QStringLiteral( "ST_Force3DM" ), - QStringLiteral( "ST_Force3DZ" ), - QStringLiteral( "ST_Force4D" ), - QStringLiteral( "ST_ForceCollection" ), - QStringLiteral( "ST_ForceCurve" ), - QStringLiteral( "ST_ForceLHR" ), - QStringLiteral( "ST_ForcePolygonCCW" ), - QStringLiteral( "ST_ForcePolygonCW" ), - QStringLiteral( "ST_ForceRHR" ), - QStringLiteral( "ST_ForceSFS" ), - QStringLiteral( "ST_FrechetDistance" ), - QStringLiteral( "ST_FromGDALRaster" ), - QStringLiteral( "ST_GDALDrivers" ), - QStringLiteral( "ST_GMLToSQL" ), - QStringLiteral( "ST_GeneratePoints" ), - QStringLiteral( "ST_GeoHash" ), - QStringLiteral( "ST_GeoReference" ), - QStringLiteral( "ST_GeogFromText" ), - QStringLiteral( "ST_GeogFromWKB" ), - QStringLiteral( "ST_GeographyFromText" ), - QStringLiteral( "ST_GeomFromEWKB" ), - QStringLiteral( "ST_GeomFromEWKT" ), - QStringLiteral( "ST_GeomFromGML" ), - QStringLiteral( "ST_GeomFromGeoHash" ), - QStringLiteral( "ST_GeomFromGeoJSON" ), - QStringLiteral( "ST_GeomFromKML" ), - QStringLiteral( "ST_GeomFromText" ), - QStringLiteral( "ST_GeomFromWKB" ), - QStringLiteral( "ST_GeometricMedian" ), - QStringLiteral( "ST_GeometryN" ), - QStringLiteral( "ST_GeometryType" ), - QStringLiteral( "ST_GetFaceEdges" ), - QStringLiteral( "ST_Grayscale" ), - QStringLiteral( "ST_HasArc" ), - QStringLiteral( "ST_HasNoBand" ), - QStringLiteral( "ST_HausdorffDistance" ), - QStringLiteral( "ST_Height" ), - QStringLiteral( "ST_Hexagon" ), - QStringLiteral( "ST_HexagonGrid" ), - QStringLiteral( "ST_HillShade" ), - QStringLiteral( "ST_Histogram" ), - QStringLiteral( "ST_InteriorRingN" ), - QStringLiteral( "ST_InterpolatePoint" ), - QStringLiteral( "ST_Intersection" ), - QStringLiteral( "ST_Intersects" ), - QStringLiteral( "ST_InvDistWeight4ma" ), - QStringLiteral( "ST_IsClosed" ), - QStringLiteral( "ST_IsCollection" ), - QStringLiteral( "ST_IsEmpty" ), - QStringLiteral( "ST_IsPlanar" ), - QStringLiteral( "ST_IsPolygonCCW" ), - QStringLiteral( "ST_IsPolygonCW" ), - QStringLiteral( "ST_IsSimple" ), - QStringLiteral( "ST_IsSolid" ), - QStringLiteral( "ST_IsValidDetail" ), - QStringLiteral( "ST_IsValidReason" ), - QStringLiteral( "ST_IsValidTrajectory" ), - QStringLiteral( "ST_Length" ), - QStringLiteral( "ST_LengthSpheroid" ), - QStringLiteral( "ST_LineCrossingDirection" ), - QStringLiteral( "ST_LineFromEncodedPolyline" ), - QStringLiteral( "ST_LineFromMultiPoint" ), - QStringLiteral( "ST_LineInterpolatePoint" ), - QStringLiteral( "ST_LineInterpolatePoints" ), - QStringLiteral( "ST_LineLocatePoint" ), - QStringLiteral( "ST_LineSubstring" ), - QStringLiteral( "ST_LineToCurve" ), - QStringLiteral( "ST_LocateAlong" ), - QStringLiteral( "ST_LocateBetween" ), - QStringLiteral( "ST_LocateBetweenElevations" ), - QStringLiteral( "ST_LongestLine" ), - QStringLiteral( "ST_M" ), - QStringLiteral( "ST_MakeBox2D" ), - QStringLiteral( "ST_MakeEmptyCoverage" ), - QStringLiteral( "ST_MakeEmptyRaster" ), - QStringLiteral( "ST_MakeEnvelope" ), - QStringLiteral( "ST_MakeLine" ), - QStringLiteral( "ST_MakePoint" ), - QStringLiteral( "ST_MakePolygon" ), - QStringLiteral( "ST_MakeSolid" ), - QStringLiteral( "ST_MakeValid" ), - QStringLiteral( "ST_MapAlgebra (callback function version)" ), - QStringLiteral( "ST_MapAlgebra (expression version)" ), - QStringLiteral( "ST_MapAlgebraExpr" ), - QStringLiteral( "ST_MapAlgebraFct" ), - QStringLiteral( "ST_MapAlgebraFctNgb" ), - QStringLiteral( "ST_Max4ma" ), - QStringLiteral( "ST_MaxDistance" ), - QStringLiteral( "ST_MaximumInscribedCircle" ), - QStringLiteral( "ST_Mean4ma" ), - QStringLiteral( "ST_MemSize" ), - QStringLiteral( "ST_MemUnion" ), - QStringLiteral( "ST_MetaData" ), - QStringLiteral( "ST_Min4ma" ), - QStringLiteral( "ST_MinConvexHull" ), - QStringLiteral( "ST_MinDist4ma" ), - QStringLiteral( "ST_MinimumBoundingCircle" ), - QStringLiteral( "ST_MinimumClearance" ), - QStringLiteral( "ST_MinimumClearanceLine" ), - QStringLiteral( "ST_MinkowskiSum" ), - QStringLiteral( "ST_ModEdgeHeal" ), - QStringLiteral( "ST_ModEdgeSplit" ), - QStringLiteral( "ST_NDims" ), - QStringLiteral( "ST_NPoints" ), - QStringLiteral( "ST_NRings" ), - QStringLiteral( "ST_NearestValue" ), - QStringLiteral( "ST_Neighborhood" ), - QStringLiteral( "ST_NewEdgeHeal" ), - QStringLiteral( "ST_Node" ), - QStringLiteral( "ST_Normalize" ), - QStringLiteral( "ST_NotSameAlignmentReason" ), - QStringLiteral( "ST_NumBands" ), - QStringLiteral( "ST_NumGeometries" ), - QStringLiteral( "ST_NumInteriorRings" ), - QStringLiteral( "ST_NumPatches" ), - QStringLiteral( "ST_OffsetCurve" ), - QStringLiteral( "ST_Orientation" ), - QStringLiteral( "ST_Overlaps" ), - QStringLiteral( "ST_PatchN" ), - QStringLiteral( "ST_Perimeter" ), - QStringLiteral( "ST_PixelAsCentroid" ), - QStringLiteral( "ST_PixelAsCentroids" ), - QStringLiteral( "ST_PixelAsPoint" ), - QStringLiteral( "ST_PixelAsPoints" ), - QStringLiteral( "ST_PixelAsPolygon" ), - QStringLiteral( "ST_PixelAsPolygons" ), - QStringLiteral( "ST_PixelHeight" ), - QStringLiteral( "ST_PixelOfValue" ), - QStringLiteral( "ST_PixelWidth" ), - QStringLiteral( "ST_PointFromGeoHash" ), - QStringLiteral( "ST_PointFromWKB" ), - QStringLiteral( "ST_PointInsideCircle" ), - QStringLiteral( "ST_PointN" ), - QStringLiteral( "ST_PointOnSurface" ), - QStringLiteral( "ST_Points" ), - QStringLiteral( "ST_Polygon" ), - QStringLiteral( "ST_Polygonize" ), - QStringLiteral( "ST_Project" ), - QStringLiteral( "ST_Quantile" ), - QStringLiteral( "ST_Range4ma" ), - QStringLiteral( "ST_RastFromHexWKB" ), - QStringLiteral( "ST_RastFromWKB" ), - QStringLiteral( "ST_RasterToWorldCoord" ), - QStringLiteral( "ST_RasterToWorldCoordX" ), - QStringLiteral( "ST_RasterToWorldCoordY" ), - QStringLiteral( "ST_Reclass" ), - QStringLiteral( "ST_ReducePrecision" ), - QStringLiteral( "ST_Relate" ), - QStringLiteral( "ST_RelateMatch" ), - QStringLiteral( "ST_RemEdgeModFace" ), - QStringLiteral( "ST_RemEdgeNewFace" ), - QStringLiteral( "ST_RemovePoint" ), - QStringLiteral( "ST_RemoveRepeatedPoints" ), - QStringLiteral( "ST_Resample" ), - QStringLiteral( "ST_Rescale" ), - QStringLiteral( "ST_Resize" ), - QStringLiteral( "ST_Reskew" ), - QStringLiteral( "ST_Retile" ), - QStringLiteral( "ST_Reverse" ), - QStringLiteral( "ST_Rotate" ), - QStringLiteral( "ST_RotateX" ), - QStringLiteral( "ST_RotateY" ), - QStringLiteral( "ST_RotateZ" ), - QStringLiteral( "ST_Rotation" ), - QStringLiteral( "ST_Roughness" ), - QStringLiteral( "ST_SRID" ), - QStringLiteral( "ST_SameAlignment" ), - QStringLiteral( "ST_Scale" ), - QStringLiteral( "ST_ScaleX" ), - QStringLiteral( "ST_ScaleY" ), - QStringLiteral( "ST_Segmentize" ), - QStringLiteral( "ST_SetBandIndex" ), - QStringLiteral( "ST_SetBandIsNoData" ), - QStringLiteral( "ST_SetBandNoDataValue" ), - QStringLiteral( "ST_SetBandPath" ), - QStringLiteral( "ST_SetEffectiveArea" ), - QStringLiteral( "ST_SetGeoReference" ), - QStringLiteral( "ST_SetPoint" ), - QStringLiteral( "ST_SetRotation" ), - QStringLiteral( "ST_SetSRID" ), - QStringLiteral( "ST_SetScale" ), - QStringLiteral( "ST_SetSkew" ), - QStringLiteral( "ST_SetUpperLeft" ), - QStringLiteral( "ST_SetValue" ), - QStringLiteral( "ST_SetValues" ), - QStringLiteral( "ST_SharedPaths" ), - QStringLiteral( "ST_ShiftLongitude" ), - QStringLiteral( "ST_ShortestLine" ), - QStringLiteral( "ST_Simplify" ), - QStringLiteral( "ST_SimplifyPreserveTopology" ), - QStringLiteral( "ST_SimplifyVW" ), - QStringLiteral( "ST_SkewX" ), - QStringLiteral( "ST_SkewY" ), - QStringLiteral( "ST_Slope" ), - QStringLiteral( "ST_Snap" ), - QStringLiteral( "ST_SnapToGrid" ), - QStringLiteral( "ST_Split" ), - QStringLiteral( "ST_Square" ), - QStringLiteral( "ST_SquareGrid" ), - QStringLiteral( "ST_StartPoint" ), - QStringLiteral( "ST_StdDev4ma" ), - QStringLiteral( "ST_StraightSkeleton" ), - QStringLiteral( "ST_Subdivide" ), - QStringLiteral( "ST_Sum4ma" ), - QStringLiteral( "ST_Summary" ), - QStringLiteral( "ST_SummaryStats" ), - QStringLiteral( "ST_SummaryStatsAgg" ), - QStringLiteral( "ST_SwapOrdinates" ), - QStringLiteral( "ST_SymDifference" ), - QStringLiteral( "ST_TPI" ), - QStringLiteral( "ST_TRI" ), - QStringLiteral( "ST_Tesselate" ), //#spellok - QStringLiteral( "ST_Tile" ), - QStringLiteral( "ST_TileEnvelope" ), - QStringLiteral( "ST_Touches" ), - QStringLiteral( "ST_TransScale" ), - QStringLiteral( "ST_Transform" ), - QStringLiteral( "ST_Translate" ), - QStringLiteral( "ST_UnaryUnion" ), - QStringLiteral( "ST_Union" ), - QStringLiteral( "ST_UpperLeftX" ), - QStringLiteral( "ST_UpperLeftY" ), - QStringLiteral( "ST_Value" ), - QStringLiteral( "ST_ValueCount" ), - QStringLiteral( "ST_Volume" ), - QStringLiteral( "ST_VoronoiLines" ), - QStringLiteral( "ST_VoronoiPolygons" ), - QStringLiteral( "ST_Width" ), - QStringLiteral( "ST_Within" ), - QStringLiteral( "ST_WorldToRasterCoord" ), - QStringLiteral( "ST_WorldToRasterCoordX" ), - QStringLiteral( "ST_WorldToRasterCoordY" ), - QStringLiteral( "ST_WrapX" ), - QStringLiteral( "ST_X" ), - QStringLiteral( "ST_XMax" ), - QStringLiteral( "ST_XMin" ), - QStringLiteral( "ST_Y" ), - QStringLiteral( "ST_YMax" ), - QStringLiteral( "ST_YMin" ), - QStringLiteral( "ST_Z" ), - QStringLiteral( "ST_ZMax" ), - QStringLiteral( "ST_ZMin" ), - QStringLiteral( "ST_Zmflag" ), - QStringLiteral( "Set_Geocode_Setting" ), - QStringLiteral( "TopoElementArray_Agg" ), - QStringLiteral( "TopoGeo_AddLineString" ), - QStringLiteral( "TopoGeo_AddPoint" ), - QStringLiteral( "TopoGeo_AddPolygon" ), - QStringLiteral( "TopoGeom_addElement" ), - QStringLiteral( "TopoGeom_remElement" ), - QStringLiteral( "TopologySummary" ), - QStringLiteral( "Topology_Load_Tiger" ), - QStringLiteral( "UpdateGeometrySRID" ), - QStringLiteral( "UpdateRasterSRID" ), - QStringLiteral( "ValidateTopology" ), - QStringLiteral( "box2d" ), - QStringLiteral( "clearTopoGeom" ), - QStringLiteral( "geometry_dump" ), - QStringLiteral( "parse_address" ), - QStringLiteral( "postgis.backend" ), - QStringLiteral( "postgis.enable_outdb_rasters" ), - QStringLiteral( "postgis.gdal_datapath" ), - QStringLiteral( "postgis.gdal_enabled_drivers" ), - QStringLiteral( "postgis_sfcgal_version" ), - QStringLiteral( "standardize_address" ), - QStringLiteral( "toTopoGeom" ), - QStringLiteral( "|=|" ), - QStringLiteral( "~" ), - QStringLiteral( "~(box2df,box2df)" ), - QStringLiteral( "~(box2df,geometry)" ), - QStringLiteral( "~(geometry,box2df)" ), - QStringLiteral( "~=" ), + { { Qgis::SqlKeywordCategory::Keyword, + { + QStringLiteral( "absolute" ), + QStringLiteral( "action" ), + QStringLiteral( "add" ), + QStringLiteral( "admin" ), + QStringLiteral( "after" ), + QStringLiteral( "aggregate" ), + QStringLiteral( "alias" ), + QStringLiteral( "all" ), + QStringLiteral( "allocate" ), + QStringLiteral( "alter" ), + QStringLiteral( "analyse" ), + QStringLiteral( "analyze" ), + QStringLiteral( "and" ), + QStringLiteral( "any" ), + QStringLiteral( "are" ), + QStringLiteral( "array" ), + QStringLiteral( "as" ), + QStringLiteral( "asc" ), + QStringLiteral( "asensitive" ), + QStringLiteral( "assertion" ), + QStringLiteral( "asymmetric" ), + QStringLiteral( "at" ), + QStringLiteral( "atomic" ), + QStringLiteral( "authorization" ), + QStringLiteral( "avg" ), + QStringLiteral( "before" ), + QStringLiteral( "begin" ), + QStringLiteral( "between" ), + QStringLiteral( "bigint" ), + QStringLiteral( "binary" ), + QStringLiteral( "bit" ), + QStringLiteral( "bit_length" ), + QStringLiteral( "blob" ), + QStringLiteral( "boolean" ), + QStringLiteral( "both" ), + QStringLiteral( "breadth" ), + QStringLiteral( "by" ), + QStringLiteral( "call" ), + QStringLiteral( "called" ), + QStringLiteral( "cardinality" ), + QStringLiteral( "cascade" ), + QStringLiteral( "cascaded" ), + QStringLiteral( "case" ), + QStringLiteral( "cast" ), + QStringLiteral( "catalog" ), + QStringLiteral( "ceil" ), + QStringLiteral( "ceiling" ), + QStringLiteral( "char" ), + QStringLiteral( "character" ), + QStringLiteral( "character_length" ), + QStringLiteral( "char_length" ), + QStringLiteral( "check" ), + QStringLiteral( "class" ), + QStringLiteral( "clob" ), + QStringLiteral( "close" ), + QStringLiteral( "coalesce" ), + QStringLiteral( "collate" ), + QStringLiteral( "collation" ), + QStringLiteral( "collect" ), + QStringLiteral( "column" ), + QStringLiteral( "commit" ), + QStringLiteral( "completion" ), + QStringLiteral( "condition" ), + QStringLiteral( "connect" ), + QStringLiteral( "connection" ), + QStringLiteral( "constraint" ), + QStringLiteral( "constraints" ), + QStringLiteral( "constructor" ), + QStringLiteral( "continue" ), + QStringLiteral( "convert" ), + QStringLiteral( "corr" ), + QStringLiteral( "corresponding" ), + QStringLiteral( "count" ), + QStringLiteral( "covar_pop" ), + QStringLiteral( "covar_samp" ), + QStringLiteral( "create" ), + QStringLiteral( "cross" ), + QStringLiteral( "cube" ), + QStringLiteral( "cume_dist" ), + QStringLiteral( "current" ), + QStringLiteral( "current_date" ), + QStringLiteral( "current_default_transform_group" ), + QStringLiteral( "current_path" ), + QStringLiteral( "current_role" ), + QStringLiteral( "current_time" ), + QStringLiteral( "current_timestamp" ), + QStringLiteral( "current_transform_group_for_type" ), + QStringLiteral( "current_user" ), + QStringLiteral( "cursor" ), + QStringLiteral( "cycle" ), + QStringLiteral( "data" ), + QStringLiteral( "date" ), + QStringLiteral( "day" ), + QStringLiteral( "deallocate" ), + QStringLiteral( "dec" ), + QStringLiteral( "decimal" ), + QStringLiteral( "declare" ), + QStringLiteral( "default" ), + QStringLiteral( "deferrable" ), + QStringLiteral( "deferred" ), + QStringLiteral( "delete" ), + QStringLiteral( "dense_rank" ), + QStringLiteral( "depth" ), + QStringLiteral( "deref" ), + QStringLiteral( "desc" ), + QStringLiteral( "describe" ), + QStringLiteral( "descriptor" ), + QStringLiteral( "destroy" ), + QStringLiteral( "destructor" ), + QStringLiteral( "deterministic" ), + QStringLiteral( "diagnostics" ), + QStringLiteral( "dictionary" ), + QStringLiteral( "disconnect" ), + QStringLiteral( "distinct" ), + QStringLiteral( "do" ), + QStringLiteral( "domain" ), + QStringLiteral( "double" ), + QStringLiteral( "drop" ), + QStringLiteral( "dynamic" ), + QStringLiteral( "each" ), + QStringLiteral( "element" ), + QStringLiteral( "else" ), + QStringLiteral( "end" ), + QStringLiteral( "end-exec" ), + QStringLiteral( "equals" ), + QStringLiteral( "escape" ), + QStringLiteral( "every" ), + QStringLiteral( "except" ), + QStringLiteral( "exception" ), + QStringLiteral( "exec" ), + QStringLiteral( "execute" ), + QStringLiteral( "exists" ), + QStringLiteral( "exp" ), + QStringLiteral( "external" ), + QStringLiteral( "extract" ), + QStringLiteral( "false" ), + QStringLiteral( "fetch" ), + QStringLiteral( "filter" ), + QStringLiteral( "first" ), + QStringLiteral( "float" ), + QStringLiteral( "floor" ), + QStringLiteral( "for" ), + QStringLiteral( "foreign" ), + QStringLiteral( "found" ), + QStringLiteral( "free" ), + QStringLiteral( "freeze" ), + QStringLiteral( "from" ), + QStringLiteral( "full" ), + QStringLiteral( "function" ), + QStringLiteral( "fusion" ), + QStringLiteral( "general" ), + QStringLiteral( "get" ), + QStringLiteral( "global" ), + QStringLiteral( "go" ), + QStringLiteral( "goto" ), + QStringLiteral( "grant" ), + QStringLiteral( "group" ), + QStringLiteral( "grouping" ), + QStringLiteral( "having" ), + QStringLiteral( "hold" ), + QStringLiteral( "host" ), + QStringLiteral( "hour" ), + QStringLiteral( "identity" ), + QStringLiteral( "ignore" ), + QStringLiteral( "ilike" ), + QStringLiteral( "immediate" ), + QStringLiteral( "in" ), + QStringLiteral( "indicator" ), + QStringLiteral( "initialize" ), + QStringLiteral( "initially" ), + QStringLiteral( "inner" ), + QStringLiteral( "inout" ), + QStringLiteral( "input" ), + QStringLiteral( "insensitive" ), + QStringLiteral( "insert" ), + QStringLiteral( "int" ), + QStringLiteral( "integer" ), + QStringLiteral( "intersect" ), + QStringLiteral( "intersection" ), + QStringLiteral( "interval" ), + QStringLiteral( "into" ), + QStringLiteral( "is" ), + QStringLiteral( "isnull" ), + QStringLiteral( "isolation" ), + QStringLiteral( "iterate" ), + QStringLiteral( "join" ), + QStringLiteral( "key" ), + QStringLiteral( "language" ), + QStringLiteral( "large" ), + QStringLiteral( "last" ), + QStringLiteral( "lateral" ), + QStringLiteral( "leading" ), + QStringLiteral( "left" ), + QStringLiteral( "less" ), + QStringLiteral( "level" ), + QStringLiteral( "like" ), + QStringLiteral( "limit" ), + QStringLiteral( "ln" ), + QStringLiteral( "local" ), + QStringLiteral( "localtime" ), + QStringLiteral( "localtimestamp" ), + QStringLiteral( "locator" ), + QStringLiteral( "lower" ), + QStringLiteral( "map" ), + QStringLiteral( "match" ), + QStringLiteral( "max" ), + QStringLiteral( "member" ), + QStringLiteral( "merge" ), + QStringLiteral( "method" ), + QStringLiteral( "min" ), + QStringLiteral( "minute" ), + QStringLiteral( "mod" ), + QStringLiteral( "modifies" ), + QStringLiteral( "modify" ), + QStringLiteral( "module" ), + QStringLiteral( "month" ), + QStringLiteral( "multiset" ), + QStringLiteral( "names" ), + QStringLiteral( "national" ), + QStringLiteral( "natural" ), + QStringLiteral( "nchar" ), + QStringLiteral( "nclob" ), + QStringLiteral( "new" ), + QStringLiteral( "next" ), + QStringLiteral( "no" ), + QStringLiteral( "none" ), + QStringLiteral( "normalize" ), + QStringLiteral( "not" ), + QStringLiteral( "notnull" ), + QStringLiteral( "null" ), + QStringLiteral( "nullif" ), + QStringLiteral( "numeric" ), + QStringLiteral( "object" ), + QStringLiteral( "octet_length" ), + QStringLiteral( "of" ), + QStringLiteral( "off" ), + QStringLiteral( "offset" ), + QStringLiteral( "old" ), + QStringLiteral( "on" ), + QStringLiteral( "only" ), + QStringLiteral( "open" ), + QStringLiteral( "operation" ), + QStringLiteral( "option" ), + QStringLiteral( "or" ), + QStringLiteral( "order" ), + QStringLiteral( "ordinality" ), + QStringLiteral( "out" ), + QStringLiteral( "outer" ), + QStringLiteral( "output" ), + QStringLiteral( "over" ), + QStringLiteral( "overlaps" ), + QStringLiteral( "overlay" ), + QStringLiteral( "pad" ), + QStringLiteral( "parameter" ), + QStringLiteral( "parameters" ), + QStringLiteral( "partial" ), + QStringLiteral( "partition" ), + QStringLiteral( "path" ), + QStringLiteral( "percentile_cont" ), + QStringLiteral( "percentile_disc" ), + QStringLiteral( "percent_rank" ), + QStringLiteral( "placing" ), + QStringLiteral( "position" ), + QStringLiteral( "postfix" ), + QStringLiteral( "power" ), + QStringLiteral( "precision" ), + QStringLiteral( "prefix" ), + QStringLiteral( "preorder" ), + QStringLiteral( "prepare" ), + QStringLiteral( "preserve" ), + QStringLiteral( "primary" ), + QStringLiteral( "prior" ), + QStringLiteral( "privileges" ), + QStringLiteral( "procedure" ), + QStringLiteral( "public" ), + QStringLiteral( "range" ), + QStringLiteral( "rank" ), + QStringLiteral( "read" ), + QStringLiteral( "reads" ), + QStringLiteral( "real" ), + QStringLiteral( "recursive" ), + QStringLiteral( "ref" ), + QStringLiteral( "references" ), + QStringLiteral( "referencing" ), + QStringLiteral( "regr_avgx" ), + QStringLiteral( "regr_avgy" ), + QStringLiteral( "regr_count" ), + QStringLiteral( "regr_intercept" ), + QStringLiteral( "regr_r2" ), + QStringLiteral( "regr_slope" ), + QStringLiteral( "regr_sxx" ), + QStringLiteral( "regr_sxy" ), + QStringLiteral( "regr_syy" ), + QStringLiteral( "relative" ), + QStringLiteral( "release" ), + QStringLiteral( "restrict" ), + QStringLiteral( "result" ), + QStringLiteral( "return" ), + QStringLiteral( "returning" ), + QStringLiteral( "returns" ), + QStringLiteral( "revoke" ), + QStringLiteral( "right" ), + QStringLiteral( "role" ), + QStringLiteral( "rollback" ), + QStringLiteral( "rollup" ), + QStringLiteral( "routine" ), + QStringLiteral( "row" ), + QStringLiteral( "row_number" ), + QStringLiteral( "rows" ), + QStringLiteral( "savepoint" ), + QStringLiteral( "schema" ), + QStringLiteral( "scope" ), + QStringLiteral( "scroll" ), + QStringLiteral( "search" ), + QStringLiteral( "second" ), + QStringLiteral( "section" ), + QStringLiteral( "select" ), + QStringLiteral( "sensitive" ), + QStringLiteral( "sequence" ), + QStringLiteral( "session" ), + QStringLiteral( "session_user" ), + QStringLiteral( "set" ), + QStringLiteral( "sets" ), + QStringLiteral( "similar" ), + QStringLiteral( "size" ), + QStringLiteral( "smallint" ), + QStringLiteral( "some" ), + QStringLiteral( "space" ), + QStringLiteral( "specific" ), + QStringLiteral( "specifictype" ), + QStringLiteral( "sql" ), + QStringLiteral( "sqlcode" ), + QStringLiteral( "sqlerror" ), + QStringLiteral( "sqlexception" ), + QStringLiteral( "sqlstate" ), + QStringLiteral( "sqlwarning" ), + QStringLiteral( "sqrt" ), + QStringLiteral( "start" ), + QStringLiteral( "state" ), + QStringLiteral( "statement" ), + QStringLiteral( "static" ), + QStringLiteral( "stddev_pop" ), + QStringLiteral( "stddev_samp" ), + QStringLiteral( "structure" ), + QStringLiteral( "submultiset" ), + QStringLiteral( "substring" ), + QStringLiteral( "sum" ), + QStringLiteral( "symmetric" ), + QStringLiteral( "system" ), + QStringLiteral( "system_user" ), + QStringLiteral( "table" ), + QStringLiteral( "tablesample" ), + QStringLiteral( "temporary" ), + QStringLiteral( "terminate" ), + QStringLiteral( "than" ), + QStringLiteral( "then" ), + QStringLiteral( "time" ), + QStringLiteral( "timestamp" ), + QStringLiteral( "timezone_hour" ), + QStringLiteral( "timezone_minute" ), + QStringLiteral( "to" ), + QStringLiteral( "trailing" ), + QStringLiteral( "transaction" ), + QStringLiteral( "translate" ), + QStringLiteral( "translation" ), + QStringLiteral( "treat" ), + QStringLiteral( "trigger" ), + QStringLiteral( "trim" ), + QStringLiteral( "true" ), + QStringLiteral( "uescape" ), + QStringLiteral( "under" ), + QStringLiteral( "union" ), + QStringLiteral( "unique" ), + QStringLiteral( "unknown" ), + QStringLiteral( "unnest" ), + QStringLiteral( "update" ), + QStringLiteral( "upper" ), + QStringLiteral( "usage" ), + QStringLiteral( "user" ), + QStringLiteral( "using" ), + QStringLiteral( "value" ), + QStringLiteral( "values" ), + QStringLiteral( "varchar" ), + QStringLiteral( "variable" ), + QStringLiteral( "var_pop" ), + QStringLiteral( "var_samp" ), + QStringLiteral( "varying" ), + QStringLiteral( "verbose" ), + QStringLiteral( "view" ), + QStringLiteral( "when" ), + QStringLiteral( "whenever" ), + QStringLiteral( "where" ), + QStringLiteral( "width_bucket" ), + QStringLiteral( "window" ), + QStringLiteral( "with" ), + QStringLiteral( "within" ), + QStringLiteral( "without" ), + QStringLiteral( "work" ), + QStringLiteral( "write" ), + QStringLiteral( "xml" ), + QStringLiteral( "xmlagg" ), + QStringLiteral( "xmlattributes" ), + QStringLiteral( "xmlbinary" ), + QStringLiteral( "xmlcomment" ), + QStringLiteral( "xmlconcat" ), + QStringLiteral( "xmlelement" ), + QStringLiteral( "xmlforest" ), + QStringLiteral( "xmlnamespaces" ), + QStringLiteral( "xmlparse" ), + QStringLiteral( "xmlpi" ), + QStringLiteral( "xmlroot" ), + QStringLiteral( "xmlserialize" ), + QStringLiteral( "year" ), + QStringLiteral( "zone" ), + } + }, + { Qgis::SqlKeywordCategory::Aggregate, + { + QStringLiteral( "Max" ), + QStringLiteral( "Min" ), + QStringLiteral( "Avg" ), + QStringLiteral( "Count" ), + QStringLiteral( "Sum" ), + QStringLiteral( "Group_Concat" ), + QStringLiteral( "Total" ), + QStringLiteral( "Var_Pop" ), + QStringLiteral( "Var_Samp" ), + QStringLiteral( "StdDev_Pop" ), + QStringLiteral( "StdDev_Samp" ), + } + }, + { Qgis::SqlKeywordCategory::Math, + { + QStringLiteral( "Abs" ), + QStringLiteral( "ACos" ), + QStringLiteral( "ASin" ), + QStringLiteral( "ATan" ), + QStringLiteral( "Cos" ), + QStringLiteral( "Cot" ), + QStringLiteral( "Degrees" ), + QStringLiteral( "Exp" ), + QStringLiteral( "Floor" ), + QStringLiteral( "Log" ), + QStringLiteral( "Log2" ), + + QStringLiteral( "Log10" ), + QStringLiteral( "Pi" ), + QStringLiteral( "Radians" ), + QStringLiteral( "Round" ), + QStringLiteral( "Sign" ), + QStringLiteral( "Sin" ), + QStringLiteral( "Sqrt" ), + QStringLiteral( "StdDev_Pop" ), + QStringLiteral( "StdDev_Samp" ), + QStringLiteral( "Tan" ), + QStringLiteral( "Var_Pop" ), + QStringLiteral( "Var_Samp" ), + } + }, + { Qgis::SqlKeywordCategory::Geospatial, + { + // List from: + // import requests, re, html; + // result = requests.get('https://postgis.net/docs/PostGIS_Special_Functions_Index.html') + // m = re.findall('.*?', result.content.replace(b'\xc2', b'').replace(b'\xa0', b'').decode('utf8'), re.MULTILINE) + // for f_name in sorted(set(m)): + // print(f' QStringLiteral( "{html.unescape(f_name)}" ),') + + QStringLiteral( "&&" ), + QStringLiteral( "&&&" ), + QStringLiteral( "&&&(geometry,gidx)" ), + QStringLiteral( "&&&(gidx,geometry)" ), + QStringLiteral( "&&&(gidx,gidx)" ), + QStringLiteral( "&&(box2df,box2df)" ), + QStringLiteral( "&&(box2df,geometry)" ), + QStringLiteral( "&&(geometry,box2df)" ), + QStringLiteral( "&>" ), + QStringLiteral( "&<" ), + QStringLiteral( "&<|" ), + QStringLiteral( "<#>" ), + QStringLiteral( "<<#>>" ), + QStringLiteral( "<<->>" ), + QStringLiteral( "<->" ), + QStringLiteral( "=" ), + QStringLiteral( "@" ), + QStringLiteral( "@(box2df,box2df)" ), + QStringLiteral( "@(box2df,geometry)" ), + QStringLiteral( "@(geometry,box2df)" ), + QStringLiteral( "AddEdge" ), + QStringLiteral( "AddFace" ), + QStringLiteral( "AddGeometryColumn" ), + QStringLiteral( "AddNode" ), + QStringLiteral( "AddOverviewConstraints" ), + QStringLiteral( "AddRasterConstraints" ), + QStringLiteral( "AsGML" ), + QStringLiteral( "AsTopoJSON" ), + QStringLiteral( "Box2D" ), + QStringLiteral( "Box3D" ), + QStringLiteral( "CopyTopology" ), + QStringLiteral( "DropGeometryColumn" ), + QStringLiteral( "DropOverviewConstraints" ), + QStringLiteral( "DropRasterConstraints" ), + QStringLiteral( "Drop_Indexes_Generate_Script" ), + QStringLiteral( "Drop_Nation_Tables_Generate_Script" ), + QStringLiteral( "Drop_State_Tables_Generate_Script" ), + QStringLiteral( "Equals" ), + QStringLiteral( "Geocode" ), + QStringLiteral( "Geocode_Intersection" ), + QStringLiteral( "GeometryType" ), + QStringLiteral( "GetEdgeByPoint" ), + QStringLiteral( "GetFaceByPoint" ), + QStringLiteral( "GetNodeByPoint" ), + QStringLiteral( "GetNodeEdges" ), + QStringLiteral( "GetRingEdges" ), + QStringLiteral( "GetTopoGeomElements" ), + QStringLiteral( "GetTopologySRID" ), + QStringLiteral( "Get_Geocode_Setting" ), + QStringLiteral( "Get_Tract" ), + QStringLiteral( "Install_Missing_Indexes" ), + QStringLiteral( "Intersects" ), + QStringLiteral( "Loader_Generate_Census_Script" ), + QStringLiteral( "Loader_Generate_Nation_Script" ), + QStringLiteral( "Loader_Generate_Script" ), + QStringLiteral( "Missing_Indexes_Generate_Script" ), + QStringLiteral( "Normalize_Address" ), + QStringLiteral( "Pagc_Normalize_Address" ), + QStringLiteral( "Polygonize" ), + QStringLiteral( "Populate_Geometry_Columns" ), + QStringLiteral( "Populate_Topology_Layer" ), + QStringLiteral( "PostGIS_AddBBox" ), + QStringLiteral( "PostGIS_DropBBox" ), + QStringLiteral( "PostGIS_Extensions_Upgrade" ), + QStringLiteral( "PostGIS_HasBBox" ), + QStringLiteral( "PostGIS_LibXML_Version" ), + QStringLiteral( "Reverse_Geocode" ), + QStringLiteral( "ST_3DArea" ), + QStringLiteral( "ST_3DClosestPoint" ), + QStringLiteral( "ST_3DDFullyWithin" ), + QStringLiteral( "ST_3DDWithin" ), + QStringLiteral( "ST_3DDifference" ), + QStringLiteral( "ST_3DDistance" ), + QStringLiteral( "ST_3DExtent" ), + QStringLiteral( "ST_3DIntersection" ), + QStringLiteral( "ST_3DIntersects" ), + QStringLiteral( "ST_3DLength" ), + QStringLiteral( "ST_3DLineInterpolatePoint" ), + QStringLiteral( "ST_3DLongestLine" ), + QStringLiteral( "ST_3DMakeBox" ), + QStringLiteral( "ST_3DMaxDistance" ), + QStringLiteral( "ST_3DPerimeter" ), + QStringLiteral( "ST_3DShortestLine" ), + QStringLiteral( "ST_3DUnion" ), + QStringLiteral( "ST_AddBand" ), + QStringLiteral( "ST_AddEdgeModFace" ), + QStringLiteral( "ST_AddEdgeNewFaces" ), + QStringLiteral( "ST_AddMeasure" ), + QStringLiteral( "ST_AddPoint" ), + QStringLiteral( "ST_Affine" ), + QStringLiteral( "ST_Angle" ), + QStringLiteral( "ST_ApproximateMedialAxis" ), + QStringLiteral( "ST_Area" ), + QStringLiteral( "ST_AsBinary" ), + QStringLiteral( "ST_AsBinary/ST_AsWKB" ), + QStringLiteral( "ST_AsEWKB" ), + QStringLiteral( "ST_AsEWKT" ), + QStringLiteral( "ST_AsEncodedPolyline" ), + QStringLiteral( "ST_AsGDALRaster" ), + QStringLiteral( "ST_AsGML" ), + QStringLiteral( "ST_AsGeoJSON" ), + QStringLiteral( "ST_AsGeobuf" ), + QStringLiteral( "ST_AsHEXEWKB" ), + QStringLiteral( "ST_AsHexWKB" ), + QStringLiteral( "ST_AsJPEG" ), + QStringLiteral( "ST_AsKML" ), + QStringLiteral( "ST_AsLatLonText" ), + QStringLiteral( "ST_AsMVT" ), + QStringLiteral( "ST_AsMVTGeom" ), + QStringLiteral( "ST_AsPNG" ), + QStringLiteral( "ST_AsRaster" ), + QStringLiteral( "ST_AsSVG" ), + QStringLiteral( "ST_AsTIFF" ), + QStringLiteral( "ST_AsTWKB" ), + QStringLiteral( "ST_AsText" ), + QStringLiteral( "ST_AsX3D" ), + QStringLiteral( "ST_Aspect" ), + QStringLiteral( "ST_Azimuth" ), + QStringLiteral( "ST_Band" ), + QStringLiteral( "ST_BandFileSize" ), + QStringLiteral( "ST_BandFileTimestamp" ), + QStringLiteral( "ST_BandIsNoData" ), + QStringLiteral( "ST_BandMetaData" ), + QStringLiteral( "ST_BandNoDataValue" ), + QStringLiteral( "ST_BandPath" ), + QStringLiteral( "ST_BandPixelType" ), + QStringLiteral( "ST_Boundary" ), + QStringLiteral( "ST_BoundingDiagonal" ), + QStringLiteral( "ST_Box2dFromGeoHash" ), + QStringLiteral( "ST_Buffer" ), + QStringLiteral( "ST_CPAWithin" ), + QStringLiteral( "ST_Centroid" ), + QStringLiteral( "ST_ChaikinSmoothing" ), + QStringLiteral( "ST_Clip" ), + QStringLiteral( "ST_ClipByBox2D" ), + QStringLiteral( "ST_ClosestPoint" ), + QStringLiteral( "ST_ClosestPointOfApproach" ), + QStringLiteral( "ST_ClusterDBSCAN" ), + QStringLiteral( "ST_ClusterIntersecting" ), + QStringLiteral( "ST_ClusterKMeans" ), + QStringLiteral( "ST_ClusterWithin" ), + QStringLiteral( "ST_Collect" ), + QStringLiteral( "ST_CollectionExtract" ), + QStringLiteral( "ST_CollectionHomogenize" ), + QStringLiteral( "ST_ColorMap" ), + QStringLiteral( "ST_ConcaveHull" ), + QStringLiteral( "ST_ConstrainedDelaunayTriangles" ), + QStringLiteral( "ST_Contains" ), + QStringLiteral( "ST_ContainsProperly" ), + QStringLiteral( "ST_ConvexHull" ), + QStringLiteral( "ST_CoordDim" ), + QStringLiteral( "ST_Count" ), + QStringLiteral( "ST_CountAgg" ), + QStringLiteral( "ST_CoveredBy" ), + QStringLiteral( "ST_Covers" ), + QStringLiteral( "ST_CreateOverview" ), + QStringLiteral( "ST_CreateTopoGeo" ), + QStringLiteral( "ST_Crosses" ), + QStringLiteral( "ST_CurveToLine" ), + QStringLiteral( "ST_DFullyWithin" ), + QStringLiteral( "ST_DWithin" ), + QStringLiteral( "ST_DelaunayTriangles" ), + QStringLiteral( "ST_Difference" ), + QStringLiteral( "ST_Dimension" ), + QStringLiteral( "ST_Disjoint" ), + QStringLiteral( "ST_Distance" ), + QStringLiteral( "ST_DistanceCPA" ), + QStringLiteral( "ST_DistanceSphere" ), + QStringLiteral( "ST_DistanceSpheroid" ), + QStringLiteral( "ST_Distinct4ma" ), + QStringLiteral( "ST_Dump" ), + QStringLiteral( "ST_DumpAsPolygons" ), + QStringLiteral( "ST_DumpPoints" ), + QStringLiteral( "ST_DumpRings" ), + QStringLiteral( "ST_DumpValues" ), + QStringLiteral( "ST_EndPoint" ), + QStringLiteral( "ST_Envelope" ), + QStringLiteral( "ST_Equals" ), + QStringLiteral( "ST_EstimatedExtent" ), + QStringLiteral( "ST_Expand" ), + QStringLiteral( "ST_Extent" ), + QStringLiteral( "ST_ExteriorRing" ), + QStringLiteral( "ST_Extrude" ), + QStringLiteral( "ST_FilterByM" ), + QStringLiteral( "ST_FlipCoordinates" ), + QStringLiteral( "ST_Force2D" ), + QStringLiteral( "ST_Force3D" ), + QStringLiteral( "ST_Force3DM" ), + QStringLiteral( "ST_Force3DZ" ), + QStringLiteral( "ST_Force4D" ), + QStringLiteral( "ST_ForceCollection" ), + QStringLiteral( "ST_ForceCurve" ), + QStringLiteral( "ST_ForceLHR" ), + QStringLiteral( "ST_ForcePolygonCCW" ), + QStringLiteral( "ST_ForcePolygonCW" ), + QStringLiteral( "ST_ForceRHR" ), + QStringLiteral( "ST_ForceSFS" ), + QStringLiteral( "ST_FrechetDistance" ), + QStringLiteral( "ST_FromGDALRaster" ), + QStringLiteral( "ST_GDALDrivers" ), + QStringLiteral( "ST_GMLToSQL" ), + QStringLiteral( "ST_GeneratePoints" ), + QStringLiteral( "ST_GeoHash" ), + QStringLiteral( "ST_GeoReference" ), + QStringLiteral( "ST_GeogFromText" ), + QStringLiteral( "ST_GeogFromWKB" ), + QStringLiteral( "ST_GeographyFromText" ), + QStringLiteral( "ST_GeomFromEWKB" ), + QStringLiteral( "ST_GeomFromEWKT" ), + QStringLiteral( "ST_GeomFromGML" ), + QStringLiteral( "ST_GeomFromGeoHash" ), + QStringLiteral( "ST_GeomFromGeoJSON" ), + QStringLiteral( "ST_GeomFromKML" ), + QStringLiteral( "ST_GeomFromText" ), + QStringLiteral( "ST_GeomFromWKB" ), + QStringLiteral( "ST_GeometricMedian" ), + QStringLiteral( "ST_GeometryN" ), + QStringLiteral( "ST_GeometryType" ), + QStringLiteral( "ST_GetFaceEdges" ), + QStringLiteral( "ST_Grayscale" ), + QStringLiteral( "ST_HasArc" ), + QStringLiteral( "ST_HasNoBand" ), + QStringLiteral( "ST_HausdorffDistance" ), + QStringLiteral( "ST_Height" ), + QStringLiteral( "ST_Hexagon" ), + QStringLiteral( "ST_HexagonGrid" ), + QStringLiteral( "ST_HillShade" ), + QStringLiteral( "ST_Histogram" ), + QStringLiteral( "ST_InteriorRingN" ), + QStringLiteral( "ST_InterpolatePoint" ), + QStringLiteral( "ST_Intersection" ), + QStringLiteral( "ST_Intersects" ), + QStringLiteral( "ST_InvDistWeight4ma" ), + QStringLiteral( "ST_IsClosed" ), + QStringLiteral( "ST_IsCollection" ), + QStringLiteral( "ST_IsEmpty" ), + QStringLiteral( "ST_IsPlanar" ), + QStringLiteral( "ST_IsPolygonCCW" ), + QStringLiteral( "ST_IsPolygonCW" ), + QStringLiteral( "ST_IsSimple" ), + QStringLiteral( "ST_IsSolid" ), + QStringLiteral( "ST_IsValidDetail" ), + QStringLiteral( "ST_IsValidReason" ), + QStringLiteral( "ST_IsValidTrajectory" ), + QStringLiteral( "ST_Length" ), + QStringLiteral( "ST_LengthSpheroid" ), + QStringLiteral( "ST_LineCrossingDirection" ), + QStringLiteral( "ST_LineFromEncodedPolyline" ), + QStringLiteral( "ST_LineFromMultiPoint" ), + QStringLiteral( "ST_LineInterpolatePoint" ), + QStringLiteral( "ST_LineInterpolatePoints" ), + QStringLiteral( "ST_LineLocatePoint" ), + QStringLiteral( "ST_LineSubstring" ), + QStringLiteral( "ST_LineToCurve" ), + QStringLiteral( "ST_LocateAlong" ), + QStringLiteral( "ST_LocateBetween" ), + QStringLiteral( "ST_LocateBetweenElevations" ), + QStringLiteral( "ST_LongestLine" ), + QStringLiteral( "ST_M" ), + QStringLiteral( "ST_MakeBox2D" ), + QStringLiteral( "ST_MakeEmptyCoverage" ), + QStringLiteral( "ST_MakeEmptyRaster" ), + QStringLiteral( "ST_MakeEnvelope" ), + QStringLiteral( "ST_MakeLine" ), + QStringLiteral( "ST_MakePoint" ), + QStringLiteral( "ST_MakePolygon" ), + QStringLiteral( "ST_MakeSolid" ), + QStringLiteral( "ST_MakeValid" ), + QStringLiteral( "ST_MapAlgebra (callback function version)" ), + QStringLiteral( "ST_MapAlgebra (expression version)" ), + QStringLiteral( "ST_MapAlgebraExpr" ), + QStringLiteral( "ST_MapAlgebraFct" ), + QStringLiteral( "ST_MapAlgebraFctNgb" ), + QStringLiteral( "ST_Max4ma" ), + QStringLiteral( "ST_MaxDistance" ), + QStringLiteral( "ST_MaximumInscribedCircle" ), + QStringLiteral( "ST_Mean4ma" ), + QStringLiteral( "ST_MemSize" ), + QStringLiteral( "ST_MemUnion" ), + QStringLiteral( "ST_MetaData" ), + QStringLiteral( "ST_Min4ma" ), + QStringLiteral( "ST_MinConvexHull" ), + QStringLiteral( "ST_MinDist4ma" ), + QStringLiteral( "ST_MinimumBoundingCircle" ), + QStringLiteral( "ST_MinimumClearance" ), + QStringLiteral( "ST_MinimumClearanceLine" ), + QStringLiteral( "ST_MinkowskiSum" ), + QStringLiteral( "ST_ModEdgeHeal" ), + QStringLiteral( "ST_ModEdgeSplit" ), + QStringLiteral( "ST_NDims" ), + QStringLiteral( "ST_NPoints" ), + QStringLiteral( "ST_NRings" ), + QStringLiteral( "ST_NearestValue" ), + QStringLiteral( "ST_Neighborhood" ), + QStringLiteral( "ST_NewEdgeHeal" ), + QStringLiteral( "ST_Node" ), + QStringLiteral( "ST_Normalize" ), + QStringLiteral( "ST_NotSameAlignmentReason" ), + QStringLiteral( "ST_NumBands" ), + QStringLiteral( "ST_NumGeometries" ), + QStringLiteral( "ST_NumInteriorRings" ), + QStringLiteral( "ST_NumPatches" ), + QStringLiteral( "ST_OffsetCurve" ), + QStringLiteral( "ST_Orientation" ), + QStringLiteral( "ST_Overlaps" ), + QStringLiteral( "ST_PatchN" ), + QStringLiteral( "ST_Perimeter" ), + QStringLiteral( "ST_PixelAsCentroid" ), + QStringLiteral( "ST_PixelAsCentroids" ), + QStringLiteral( "ST_PixelAsPoint" ), + QStringLiteral( "ST_PixelAsPoints" ), + QStringLiteral( "ST_PixelAsPolygon" ), + QStringLiteral( "ST_PixelAsPolygons" ), + QStringLiteral( "ST_PixelHeight" ), + QStringLiteral( "ST_PixelOfValue" ), + QStringLiteral( "ST_PixelWidth" ), + QStringLiteral( "ST_PointFromGeoHash" ), + QStringLiteral( "ST_PointFromWKB" ), + QStringLiteral( "ST_PointInsideCircle" ), + QStringLiteral( "ST_PointN" ), + QStringLiteral( "ST_PointOnSurface" ), + QStringLiteral( "ST_Points" ), + QStringLiteral( "ST_Polygon" ), + QStringLiteral( "ST_Polygonize" ), + QStringLiteral( "ST_Project" ), + QStringLiteral( "ST_Quantile" ), + QStringLiteral( "ST_Range4ma" ), + QStringLiteral( "ST_RastFromHexWKB" ), + QStringLiteral( "ST_RastFromWKB" ), + QStringLiteral( "ST_RasterToWorldCoord" ), + QStringLiteral( "ST_RasterToWorldCoordX" ), + QStringLiteral( "ST_RasterToWorldCoordY" ), + QStringLiteral( "ST_Reclass" ), + QStringLiteral( "ST_ReducePrecision" ), + QStringLiteral( "ST_Relate" ), + QStringLiteral( "ST_RelateMatch" ), + QStringLiteral( "ST_RemEdgeModFace" ), + QStringLiteral( "ST_RemEdgeNewFace" ), + QStringLiteral( "ST_RemovePoint" ), + QStringLiteral( "ST_RemoveRepeatedPoints" ), + QStringLiteral( "ST_Resample" ), + QStringLiteral( "ST_Rescale" ), + QStringLiteral( "ST_Resize" ), + QStringLiteral( "ST_Reskew" ), + QStringLiteral( "ST_Retile" ), + QStringLiteral( "ST_Reverse" ), + QStringLiteral( "ST_Rotate" ), + QStringLiteral( "ST_RotateX" ), + QStringLiteral( "ST_RotateY" ), + QStringLiteral( "ST_RotateZ" ), + QStringLiteral( "ST_Rotation" ), + QStringLiteral( "ST_Roughness" ), + QStringLiteral( "ST_SRID" ), + QStringLiteral( "ST_SameAlignment" ), + QStringLiteral( "ST_Scale" ), + QStringLiteral( "ST_ScaleX" ), + QStringLiteral( "ST_ScaleY" ), + QStringLiteral( "ST_Segmentize" ), + QStringLiteral( "ST_SetBandIndex" ), + QStringLiteral( "ST_SetBandIsNoData" ), + QStringLiteral( "ST_SetBandNoDataValue" ), + QStringLiteral( "ST_SetBandPath" ), + QStringLiteral( "ST_SetEffectiveArea" ), + QStringLiteral( "ST_SetGeoReference" ), + QStringLiteral( "ST_SetPoint" ), + QStringLiteral( "ST_SetRotation" ), + QStringLiteral( "ST_SetSRID" ), + QStringLiteral( "ST_SetScale" ), + QStringLiteral( "ST_SetSkew" ), + QStringLiteral( "ST_SetUpperLeft" ), + QStringLiteral( "ST_SetValue" ), + QStringLiteral( "ST_SetValues" ), + QStringLiteral( "ST_SharedPaths" ), + QStringLiteral( "ST_ShiftLongitude" ), + QStringLiteral( "ST_ShortestLine" ), + QStringLiteral( "ST_Simplify" ), + QStringLiteral( "ST_SimplifyPreserveTopology" ), + QStringLiteral( "ST_SimplifyVW" ), + QStringLiteral( "ST_SkewX" ), + QStringLiteral( "ST_SkewY" ), + QStringLiteral( "ST_Slope" ), + QStringLiteral( "ST_Snap" ), + QStringLiteral( "ST_SnapToGrid" ), + QStringLiteral( "ST_Split" ), + QStringLiteral( "ST_Square" ), + QStringLiteral( "ST_SquareGrid" ), + QStringLiteral( "ST_StartPoint" ), + QStringLiteral( "ST_StdDev4ma" ), + QStringLiteral( "ST_StraightSkeleton" ), + QStringLiteral( "ST_Subdivide" ), + QStringLiteral( "ST_Sum4ma" ), + QStringLiteral( "ST_Summary" ), + QStringLiteral( "ST_SummaryStats" ), + QStringLiteral( "ST_SummaryStatsAgg" ), + QStringLiteral( "ST_SwapOrdinates" ), + QStringLiteral( "ST_SymDifference" ), + QStringLiteral( "ST_TPI" ), + QStringLiteral( "ST_TRI" ), + QStringLiteral( "ST_Tesselate" ), //#spellok + QStringLiteral( "ST_Tile" ), + QStringLiteral( "ST_TileEnvelope" ), + QStringLiteral( "ST_Touches" ), + QStringLiteral( "ST_TransScale" ), + QStringLiteral( "ST_Transform" ), + QStringLiteral( "ST_Translate" ), + QStringLiteral( "ST_UnaryUnion" ), + QStringLiteral( "ST_Union" ), + QStringLiteral( "ST_UpperLeftX" ), + QStringLiteral( "ST_UpperLeftY" ), + QStringLiteral( "ST_Value" ), + QStringLiteral( "ST_ValueCount" ), + QStringLiteral( "ST_Volume" ), + QStringLiteral( "ST_VoronoiLines" ), + QStringLiteral( "ST_VoronoiPolygons" ), + QStringLiteral( "ST_Width" ), + QStringLiteral( "ST_Within" ), + QStringLiteral( "ST_WorldToRasterCoord" ), + QStringLiteral( "ST_WorldToRasterCoordX" ), + QStringLiteral( "ST_WorldToRasterCoordY" ), + QStringLiteral( "ST_WrapX" ), + QStringLiteral( "ST_X" ), + QStringLiteral( "ST_XMax" ), + QStringLiteral( "ST_XMin" ), + QStringLiteral( "ST_Y" ), + QStringLiteral( "ST_YMax" ), + QStringLiteral( "ST_YMin" ), + QStringLiteral( "ST_Z" ), + QStringLiteral( "ST_ZMax" ), + QStringLiteral( "ST_ZMin" ), + QStringLiteral( "ST_Zmflag" ), + QStringLiteral( "Set_Geocode_Setting" ), + QStringLiteral( "TopoElementArray_Agg" ), + QStringLiteral( "TopoGeo_AddLineString" ), + QStringLiteral( "TopoGeo_AddPoint" ), + QStringLiteral( "TopoGeo_AddPolygon" ), + QStringLiteral( "TopoGeom_addElement" ), + QStringLiteral( "TopoGeom_remElement" ), + QStringLiteral( "TopologySummary" ), + QStringLiteral( "Topology_Load_Tiger" ), + QStringLiteral( "UpdateGeometrySRID" ), + QStringLiteral( "UpdateRasterSRID" ), + QStringLiteral( "ValidateTopology" ), + QStringLiteral( "box2d" ), + QStringLiteral( "clearTopoGeom" ), + QStringLiteral( "geometry_dump" ), + QStringLiteral( "parse_address" ), + QStringLiteral( "postgis.backend" ), + QStringLiteral( "postgis.enable_outdb_rasters" ), + QStringLiteral( "postgis.gdal_datapath" ), + QStringLiteral( "postgis.gdal_enabled_drivers" ), + QStringLiteral( "postgis_sfcgal_version" ), + QStringLiteral( "standardize_address" ), + QStringLiteral( "toTopoGeom" ), + QStringLiteral( "|=|" ), + QStringLiteral( "~" ), + QStringLiteral( "~(box2df,box2df)" ), + QStringLiteral( "~(box2df,geometry)" ), + QStringLiteral( "~(geometry,box2df)" ), + QStringLiteral( "~=" ), + } } } - } ); + ); } QgsFields QgsPostgresProviderConnection::fields( const QString &schema, const QString &tableName, QgsFeedback *feedback ) const @@ -1896,7 +1862,7 @@ QgsFields QgsPostgresProviderConnection::fields( const QString &schema, const QS { QgsDataSourceUri tUri { tableUri( schema, tableName ) }; - if ( tableInfo.geometryColumnTypes().count( ) > 1 ) + if ( tableInfo.geometryColumnTypes().count() > 1 ) { const auto geomColTypes( tableInfo.geometryColumnTypes() ); TableProperty::GeometryColumnType geomCol { geomColTypes.first() }; diff --git a/src/providers/postgres/qgspostgresproviderconnection.h b/src/providers/postgres/qgspostgresproviderconnection.h index 571e837e12cc..1f294fcfab86 100644 --- a/src/providers/postgres/qgspostgresproviderconnection.h +++ b/src/providers/postgres/qgspostgresproviderconnection.h @@ -18,7 +18,7 @@ #include "qgsabstractdatabaseproviderconnection.h" #include "qgspostgresconnpool.h" -struct QgsPostgresProviderResultIterator: public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator +struct QgsPostgresProviderResultIterator : public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator { QgsPostgresProviderResultIterator( bool resolveTypes ) : mResolveTypes( resolveTypes ) @@ -28,7 +28,6 @@ struct QgsPostgresProviderResultIterator: public QgsAbstractDatabaseProviderConn std::unique_ptr result; private: - QVariantList nextRowPrivate() override; bool hasNextRowPrivate() const override; long long rowCountPrivate() const override; @@ -40,20 +39,13 @@ struct QgsPostgresProviderResultIterator: public QgsAbstractDatabaseProviderConn class QgsPostgresProviderConnection : public QgsAbstractDatabaseProviderConnection { public: - QgsPostgresProviderConnection( const QString &name ); QgsPostgresProviderConnection( const QString &uri, const QVariantMap &configuration ); // QgsAbstractProviderConnection interface public: - - void createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, bool overwrite, - const QMap *options ) const override; + void createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const override; QString tableUri( const QString &schema, const QString &name ) const override; QgsFields fields( const QString &schema, const QString &table, QgsFeedback *feedback = nullptr ) const override; @@ -70,10 +62,9 @@ class QgsPostgresProviderConnection : public QgsAbstractDatabaseProviderConnecti bool spatialIndexExists( const QString &schema, const QString &name, const QString &geometryColumn ) const override; void deleteSpatialIndex( const QString &schema, const QString &name, const QString &geometryColumn ) const override; void setFieldComment( const QString &fieldName, const QString &schema, const QString &tableName, const QString &comment ) const override; - QList tables( const QString &schema, - const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; + QList tables( const QString &schema, const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; QgsAbstractDatabaseProviderConnection::TableProperty table( const QString &schema, const QString &table, QgsFeedback *feedback = nullptr ) const override; - QStringList schemas( ) const override; + QStringList schemas() const override; void store( const QString &name ) const override; void remove( const QString &name ) const override; QIcon icon() const override; @@ -87,15 +78,12 @@ class QgsPostgresProviderConnection : public QgsAbstractDatabaseProviderConnecti static const QString SETTINGS_BASE_KEY; private: - - QList executeSqlPrivate( const QString &sql, bool resolveTypes = true, QgsFeedback *feedback = nullptr, std::shared_ptr< class QgsPoolPostgresConn > pgconn = nullptr ) const; - QgsAbstractDatabaseProviderConnection::QueryResult execSqlPrivate( const QString &sql, bool resolveTypes = true, QgsFeedback *feedback = nullptr, std::shared_ptr< class QgsPoolPostgresConn > pgconn = nullptr ) const; + QList executeSqlPrivate( const QString &sql, bool resolveTypes = true, QgsFeedback *feedback = nullptr, std::shared_ptr pgconn = nullptr ) const; + QgsAbstractDatabaseProviderConnection::QueryResult execSqlPrivate( const QString &sql, bool resolveTypes = true, QgsFeedback *feedback = nullptr, std::shared_ptr pgconn = nullptr ) const; void setDefaultCapabilities(); void dropTablePrivate( const QString &schema, const QString &name ) const; void renameTablePrivate( const QString &schema, const QString &name, const QString &newName ) const; - QList tablesPrivate( const QString &schema, const QString &table, - const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const; - + QList tablesPrivate( const QString &schema, const QString &table, const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const; }; diff --git a/src/providers/postgres/qgspostgresprovidergui.cpp b/src/providers/postgres/qgspostgresprovidergui.cpp index b92471b918a9..f45286abb67d 100644 --- a/src/providers/postgres/qgspostgresprovidergui.cpp +++ b/src/providers/postgres/qgspostgresprovidergui.cpp @@ -27,10 +27,9 @@ //! Provider for postgres source select -class QgsPostgresSourceSelectProvider : public QgsSourceSelectProvider //#spellok +class QgsPostgresSourceSelectProvider : public QgsSourceSelectProvider //#spellok { public: - QString providerKey() const override { return QStringLiteral( "postgres" ); } QString text() const override { return QObject::tr( "PostgreSQL" ); } int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 20; } @@ -68,20 +67,19 @@ class QgsPostgresProjectStorageGuiProvider : public QgsProjectStorageGuiProvider return dlg.currentProjectUri(); } - }; -QgsPostgresProviderGuiMetadata::QgsPostgresProviderGuiMetadata(): - QgsProviderGuiMetadata( QgsPostgresProvider::POSTGRES_KEY ) +QgsPostgresProviderGuiMetadata::QgsPostgresProviderGuiMetadata() + : QgsProviderGuiMetadata( QgsPostgresProvider::POSTGRES_KEY ) { - mRasterTemporalWidgetFactory = std::make_unique< QgsPostgresRasterTemporalSettingsConfigWidgetFactory>(); + mRasterTemporalWidgetFactory = std::make_unique(); } QList QgsPostgresProviderGuiMetadata::sourceSelectProviders() { QList providers; - providers << new QgsPostgresSourceSelectProvider; //#spellok + providers << new QgsPostgresSourceSelectProvider; //#spellok return providers; } diff --git a/src/providers/postgres/qgspostgresprovidergui.h b/src/providers/postgres/qgspostgresprovidergui.h index 3e0821c3b706..7b5734d252f2 100644 --- a/src/providers/postgres/qgspostgresprovidergui.h +++ b/src/providers/postgres/qgspostgresprovidergui.h @@ -22,7 +22,7 @@ #include "qgsproviderguimetadata.h" -class QgsPostgresProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsPostgresProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsPostgresProviderGuiMetadata(); @@ -33,9 +33,7 @@ class QgsPostgresProviderGuiMetadata: public QgsProviderGuiMetadata QList mapLayerConfigWidgetFactories() override; private: - - std::unique_ptr< QgsMapLayerConfigWidgetFactory > mRasterTemporalWidgetFactory; - + std::unique_ptr mRasterTemporalWidgetFactory; }; #endif // QGSPOSTGRESPROVIDERGUI_H diff --git a/src/providers/postgres/qgspostgresprovidermetadatautils.cpp b/src/providers/postgres/qgspostgresprovidermetadatautils.cpp index bae7530e822e..bcf9d226c0f4 100644 --- a/src/providers/postgres/qgspostgresprovidermetadatautils.cpp +++ b/src/providers/postgres/qgspostgresprovidermetadatautils.cpp @@ -29,29 +29,29 @@ QList QgsPostgresProviderMetadataUtils::searchLa QgsDataSourceUri dsUri( uri ); QgsPostgresConn *conn = QgsPostgresConn::connectDb( dsUri, false ); - if ( conn && ( ! feedback || ! feedback->isCanceled() ) ) + if ( conn && ( !feedback || !feedback->isCanceled() ) ) { - QString schemaName { QStringLiteral( "public" ) }; const QString schemaQuery = QStringLiteral( "SELECT table_schema FROM information_schema.tables WHERE table_name = 'qgis_layer_metadata'" ); QgsPostgresResult res( conn->LoggedPQexec( "QgsPostgresProviderMetadata", schemaQuery ) ); - if ( res.PQntuples( ) > 0 ) + if ( res.PQntuples() > 0 ) { schemaName = res.PQgetvalue( 0, 0 ); } QStringList where; - if ( ! searchString.isEmpty() ) + if ( !searchString.isEmpty() ) { where.push_back( QStringLiteral( R"SQL(( abstract ILIKE %1 OR identifier ILIKE %1 OR REGEXP_REPLACE(UPPER(array_to_string((xpath('//keyword', qmd))::varchar[], ' ')),'', '', 'g') ILIKE %1 - ))SQL" ).arg( QgsPostgresConn::quotedValue( QString( searchString ).prepend( QChar( '%' ) ).append( QChar( '%' ) ) ) ) ); + ))SQL" ) + .arg( QgsPostgresConn::quotedValue( QString( searchString ).prepend( QChar( '%' ) ).append( QChar( '%' ) ) ) ) ); } - if ( ! geographicExtent.isEmpty() ) + if ( !geographicExtent.isEmpty() ) { where.push_back( QStringLiteral( "ST_Intersects( extent, ST_GeomFromText( %1, 4326 ) )" ).arg( QgsPostgresConn::quotedValue( geographicExtent.asWktPolygon() ) ) ); } @@ -74,7 +74,8 @@ QList QgsPostgresProviderMetadataUtils::searchLa ,update_time FROM %1.qgis_layer_metadata %2 - )SQL" ).arg( QgsPostgresConn::quotedIdentifier( schemaName ), where.isEmpty() ? QString() : ( QStringLiteral( " WHERE %1 " ).arg( where.join( QLatin1String( " AND " ) ) ) ) ); + )SQL" ) + .arg( QgsPostgresConn::quotedIdentifier( schemaName ), where.isEmpty() ? QString() : ( QStringLiteral( " WHERE %1 " ).arg( where.join( QLatin1String( " AND " ) ) ) ) ); res = conn->LoggedPQexec( "QgsPostgresProviderMetadata", listQuery ); @@ -83,9 +84,8 @@ QList QgsPostgresProviderMetadataUtils::searchLa throw QgsProviderConnectionException( QObject::tr( "Error while fetching metadata from %1: %2" ).arg( dsUri.connectionInfo( false ), res.PQresultErrorMessage() ) ); } - for ( int row = 0; row < res.PQntuples( ); ++row ) + for ( int row = 0; row < res.PQntuples(); ++row ) { - if ( feedback && feedback->isCanceled() ) { break; @@ -102,7 +102,7 @@ QList QgsPostgresProviderMetadataUtils::searchLa uri.setSchema( res.PQgetvalue( row, 1 ) ); uri.setTable( res.PQgetvalue( row, 2 ) ); uri.setGeometryColumn( res.PQgetvalue( row, 3 ) ); - const Qgis::WkbType wkbType = QgsWkbTypes::parseType( res.PQgetvalue( row, 7 ) ); + const Qgis::WkbType wkbType = QgsWkbTypes::parseType( res.PQgetvalue( row, 7 ) ); uri.setWkbType( wkbType ); result.setStandardUri( QStringLiteral( "http://mrcc.com/qgis.dtd" ) ); result.setGeometryType( QgsWkbTypes::geometryType( wkbType ) ); @@ -173,15 +173,14 @@ bool QgsPostgresProviderMetadataUtils::saveLayerMetadata( const Qgis::LayerType QString schemaName { dsUri.schema().isEmpty() ? QStringLiteral( "public" ) : dsUri.schema() }; const QString schemaQuery = QStringLiteral( "SELECT table_schema FROM information_schema.tables WHERE table_name = 'qgis_layer_metadata'" ); QgsPostgresResult res( conn->LoggedPQexec( "QgsPostgresProviderMetadataUtils", schemaQuery ) ); - const bool metadataTableFound { res.PQntuples( ) > 0 }; + const bool metadataTableFound { res.PQntuples() > 0 }; if ( metadataTableFound ) { - schemaName = res.PQgetvalue( 0, 0 ) ; + schemaName = res.PQgetvalue( 0, 0 ); } else { - QgsPostgresResult res( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadataUtils" ), - QStringLiteral( R"SQL( + QgsPostgresResult res( conn->LoggedPQexec( QStringLiteral( "QgsPostgresProviderMetadataUtils" ), QStringLiteral( R"SQL( CREATE TABLE %1.qgis_layer_metadata ( id SERIAL PRIMARY KEY ,f_table_catalog VARCHAR NOT NULL @@ -200,7 +199,8 @@ bool QgsPostgresProviderMetadataUtils::saveLayerMetadata( const Qgis::LayerType ,update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UNIQUE (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, geometry_type, crs, layer_type) ) - )SQL" ).arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) ) ); + )SQL" ) + .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) ) ); if ( res.PQresultStatus() != PGRES_COMMAND_OK ) { errorMessage = QObject::tr( "Unable to save layer metadata. It's not possible to create the destination table on the database. Maybe this is due to table permissions (user=%1). Please contact your database admin" ).arg( dsUri.username() ); @@ -212,13 +212,13 @@ bool QgsPostgresProviderMetadataUtils::saveLayerMetadata( const Qgis::LayerType const QString wkbTypeString = QgsWkbTypes::displayString( dsUri.wkbType() ); const QgsCoordinateReferenceSystem metadataCrs { metadata.crs() }; - QgsCoordinateReferenceSystem destCrs {QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) }; + QgsCoordinateReferenceSystem destCrs { QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) }; QgsRectangle extents; const auto cExtents { metadata.extent().spatialExtents() }; for ( const auto &ext : std::as_const( cExtents ) ) { - QgsRectangle bbox { ext.bounds.toRectangle() }; + QgsRectangle bbox { ext.bounds.toRectangle() }; // Note: a default transform context is used here because we don't need high accuracy QgsCoordinateTransform ct { ext.extentCrs, QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), QgsCoordinateTransformContext() }; ct.transform( bbox ); @@ -265,20 +265,20 @@ bool QgsPostgresProviderMetadataUtils::saveLayerMetadata( const Qgis::LayerType ,qmd) VALUES ( %2,%3,%4,%5,%6,%7,%8,%9,ST_GeomFromText(%10, 4326),%11,%12,XMLPARSE(DOCUMENT %13)) )SQL" ) - .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) - .arg( QgsPostgresConn::quotedValue( metadata.identifier() ) ) - .arg( QgsPostgresConn::quotedValue( metadata.title() ) ) - .arg( QgsPostgresConn::quotedValue( metadata.abstract() ) ) - .arg( QgsPostgresConn::quotedValue( wkbTypeString ) ) - .arg( QgsPostgresConn::quotedValue( extents.asWktPolygon() ) ) - .arg( QgsPostgresConn::quotedValue( metadataCrs.authid() ) ) - .arg( QgsPostgresConn::quotedValue( layerTypeString ) ) - // Must be the final .arg replacement - see above - .arg( QgsPostgresConn::quotedValue( metadataXml ) ); + .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) + .arg( QgsPostgresConn::quotedValue( metadata.identifier() ) ) + .arg( QgsPostgresConn::quotedValue( metadata.title() ) ) + .arg( QgsPostgresConn::quotedValue( metadata.abstract() ) ) + .arg( QgsPostgresConn::quotedValue( wkbTypeString ) ) + .arg( QgsPostgresConn::quotedValue( extents.asWktPolygon() ) ) + .arg( QgsPostgresConn::quotedValue( metadataCrs.authid() ) ) + .arg( QgsPostgresConn::quotedValue( layerTypeString ) ) + // Must be the final .arg replacement - see above + .arg( QgsPostgresConn::quotedValue( metadataXml ) ); QString checkQuery = QStringLiteral( R"SQL( SELECT @@ -291,14 +291,12 @@ bool QgsPostgresProviderMetadataUtils::saveLayerMetadata( const Qgis::LayerType AND f_geometry_column %5 AND layer_type = %7 )SQL" ) - .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) - .arg( dsUri.geometryColumn().isEmpty() ? - QStringLiteral( "IS NULL" ) : - QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) - .arg( QgsPostgresConn::quotedValue( layerTypeString ) ); + .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.database() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( dsUri.table() ) ) + .arg( dsUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) ) ) + .arg( QgsPostgresConn::quotedValue( layerTypeString ) ); res = conn->LoggedPQexec( "QgsPostgresProviderMetadataUtils", checkQuery ); if ( res.PQntuples() > 0 ) @@ -317,16 +315,15 @@ bool QgsPostgresProviderMetadataUtils::saveLayerMetadata( const Qgis::LayerType WHERE id = %2 )SQL" ) - .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) - .arg( id ) - .arg( QgsPostgresConn::quotedValue( metadata.title() ) ) - .arg( QgsPostgresConn::quotedValue( metadata.abstract() ) ) - .arg( QgsPostgresConn::quotedValue( wkbTypeString ) ) - .arg( QgsPostgresConn::quotedValue( extents.asWktPolygon() ) ) - .arg( QgsPostgresConn::quotedValue( metadataCrs.authid() ) ) - // Must be the final .arg replacement - see above - .arg( QgsPostgresConn::quotedValue( metadataXml ) ); - + .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ) + .arg( id ) + .arg( QgsPostgresConn::quotedValue( metadata.title() ) ) + .arg( QgsPostgresConn::quotedValue( metadata.abstract() ) ) + .arg( QgsPostgresConn::quotedValue( wkbTypeString ) ) + .arg( QgsPostgresConn::quotedValue( extents.asWktPolygon() ) ) + .arg( QgsPostgresConn::quotedValue( metadataCrs.authid() ) ) + // Must be the final .arg replacement - see above + .arg( QgsPostgresConn::quotedValue( metadataXml ) ); } res = conn->LoggedPQexec( "QgsPostgresProviderMetadataUtils", upsertSql ); diff --git a/src/providers/postgres/qgspostgresprovidermetadatautils.h b/src/providers/postgres/qgspostgresprovidermetadatautils.h index 3cfba642d867..a930b13c0663 100644 --- a/src/providers/postgres/qgspostgresprovidermetadatautils.h +++ b/src/providers/postgres/qgspostgresprovidermetadatautils.h @@ -29,7 +29,6 @@ class QgsFeedback; class QgsPostgresProviderMetadataUtils { public: - static QList searchLayerMetadata( const QgsMetadataSearchContext &searchContext, const QString &uri, const QString &searchString, const QgsRectangle &geographicExtent, QgsFeedback *feedback ); static bool saveLayerMetadata( const Qgis::LayerType &layerType, const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage ); }; diff --git a/src/providers/postgres/qgspostgrestransaction.cpp b/src/providers/postgres/qgspostgrestransaction.cpp index 4d748568d00d..b3fa643a4835 100644 --- a/src/providers/postgres/qgspostgrestransaction.cpp +++ b/src/providers/postgres/qgspostgrestransaction.cpp @@ -25,7 +25,6 @@ QgsPostgresTransaction::QgsPostgresTransaction( const QString &connString ) : QgsTransaction( connString ) { - } bool QgsPostgresTransaction::beginTransaction( QString &error, int statementTimeout ) @@ -74,8 +73,7 @@ bool QgsPostgresTransaction::executeSql( const QString &sql, QString &errorMsg, QgsDebugMsgLevel( QStringLiteral( "Transaction sql: %1" ).arg( sql ), 2 ); QgsPostgresResult r( mConn->LoggedPQexec( "QgsPostgresTransaction", sql ) ); - if ( r.PQresultStatus() == PGRES_BAD_RESPONSE || - r.PQresultStatus() == PGRES_FATAL_ERROR ) + if ( r.PQresultStatus() == PGRES_BAD_RESPONSE || r.PQresultStatus() == PGRES_FATAL_ERROR ) { errorMsg = QStringLiteral( "Status %1 (%2)" ).arg( r.PQresultStatus() ).arg( r.PQresultErrorMessage() ); QgsDebugError( errorMsg ); diff --git a/src/providers/postgres/qgspostgrestransaction.h b/src/providers/postgres/qgspostgrestransaction.h index d3b82045826e..2257f4e23412 100644 --- a/src/providers/postgres/qgspostgrestransaction.h +++ b/src/providers/postgres/qgspostgrestransaction.h @@ -49,7 +49,6 @@ class QgsPostgresTransaction : public QgsTransaction bool beginTransaction( QString &error, int statementTimeout ) override; bool commitTransaction( QString &error ) override; bool rollbackTransaction( QString &error ) override; - }; #endif // QGSPOSTGRESTRANSACTION_H diff --git a/src/providers/postgres/raster/qgspostgresrasterprovider.cpp b/src/providers/postgres/raster/qgspostgresrasterprovider.cpp index f62ae56d20ab..071cd6b3a3b6 100644 --- a/src/providers/postgres/raster/qgspostgresrasterprovider.cpp +++ b/src/providers/postgres/raster/qgspostgresrasterprovider.cpp @@ -29,14 +29,13 @@ #include const QString QgsPostgresRasterProvider::PG_RASTER_PROVIDER_KEY = QStringLiteral( "postgresraster" ); -const QString QgsPostgresRasterProvider::PG_RASTER_PROVIDER_DESCRIPTION = QStringLiteral( "Postgres raster provider" ); +const QString QgsPostgresRasterProvider::PG_RASTER_PROVIDER_DESCRIPTION = QStringLiteral( "Postgres raster provider" ); QgsPostgresRasterProvider::QgsPostgresRasterProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags ) : QgsRasterDataProvider( uri, providerOptions, flags ) , mShared( new QgsPostgresRasterSharedData ) { - mUri = uri; // populate members from the uri structure @@ -110,18 +109,15 @@ QgsPostgresRasterProvider::QgsPostgresRasterProvider( const QString &uri, const } // Check if requested srid and detected srid match - if ( ! mDetectedSrid.isEmpty() && ! mRequestedSrid.isEmpty() && mRequestedSrid != mDetectedSrid ) + if ( !mDetectedSrid.isEmpty() && !mRequestedSrid.isEmpty() && mRequestedSrid != mDetectedSrid ) { - QgsMessageLog::logMessage( tr( "Requested SRID (%1) and detected SRID (%2) differ" ) - .arg( mRequestedSrid ) - .arg( mDetectedSrid ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Requested SRID (%1) and detected SRID (%2) differ" ).arg( mRequestedSrid ).arg( mDetectedSrid ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } // Try to load metadata const QString schemaQuery = QStringLiteral( "SELECT table_schema FROM information_schema.tables WHERE table_name = 'qgis_layer_metadata'" ); QgsPostgresResult res( mConnectionRO->LoggedPQexec( "QgsPostgresRasterProvider", schemaQuery ) ); - if ( res.PQntuples( ) > 0 ) + if ( res.PQntuples() > 0 ) { const QString schemaName = res.PQgetvalue( 0, 0 ); // TODO: also filter CRS? @@ -135,10 +131,10 @@ QgsPostgresRasterProvider::QgsPostgresRasterProvider( const QString &uri, const AND f_geometry_column %3 AND layer_type='raster' )SQL" ) - .arg( QgsPostgresConn::quotedValue( mUri.schema() ) ) - .arg( QgsPostgresConn::quotedValue( mUri.table() ) ) - .arg( mUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( mUri.geometryColumn() ) ) ) - .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ); + .arg( QgsPostgresConn::quotedValue( mUri.schema() ) ) + .arg( QgsPostgresConn::quotedValue( mUri.table() ) ) + .arg( mUri.geometryColumn().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "=%1" ).arg( QgsPostgresConn::quotedValue( mUri.geometryColumn() ) ) ) + .arg( QgsPostgresConn::quotedIdentifier( schemaName ) ); QgsPostgresResult res( mConnectionRO->LoggedPQexec( "QgsPostgresRasterProvider", selectQuery ) ); if ( res.PQntuples() > 0 ) @@ -216,10 +212,7 @@ bool QgsPostgresRasterProvider::hasSufficientPermsAndCapabilities() QgsPostgresResult testAccess( connectionRO()->PQexec( sql ) ); if ( testAccess.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( tr( "Unable to access the %1 relation.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mQuery, - testAccess.PQresultErrorMessage(), - sql ), tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Unable to access the %1 relation.\nThe error message from the database was:\n%2.\nSQL: %3" ).arg( mQuery, testAccess.PQresultErrorMessage(), sql ), tr( "PostGIS" ) ); return false; } @@ -275,11 +268,11 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE return false; } - const bool isSingleValue { width == 1 && height == 1 }; + const bool isSingleValue { width == 1 && height == 1 }; QString tableToQuery { mQuery }; QString whereAnd { subsetStringWithTemporalRange() }; - if ( ! whereAnd.isEmpty() ) + if ( !whereAnd.isEmpty() ) { whereAnd = whereAnd.append( QStringLiteral( " AND " ) ); } @@ -291,20 +284,17 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE sql = QStringLiteral( "SELECT ST_Value( ST_Band( %1, %2), ST_GeomFromText( %3, %4 ), FALSE ) " "FROM %5 " "WHERE %6 %1 && ST_GeomFromText( %3, %4 )" ) - .arg( quotedIdentifier( mRasterColumn ) ) - .arg( bandNo ) - .arg( quotedValue( viewExtent.center().asWkt() ) ) - .arg( mCrs.postgisSrid() ) - .arg( mQuery ) - .arg( whereAnd ); + .arg( quotedIdentifier( mRasterColumn ) ) + .arg( bandNo ) + .arg( quotedValue( viewExtent.center().asWkt() ) ) + .arg( mCrs.postgisSrid() ) + .arg( mQuery ) + .arg( whereAnd ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( tr( "Unable to access the %1 relation.\nThe error message from the database was:\n%2.\nSQL: %3" ) - .arg( mQuery, - result.PQresultErrorMessage(), - sql ), tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Unable to access the %1 relation.\nThe error message from the database was:\n%2.\nSQL: %3" ).arg( mQuery, result.PQresultErrorMessage(), sql ), tr( "PostGIS" ) ); return false; } @@ -318,13 +308,13 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE } - const Qgis::DataType dataType { mDataTypes[ static_cast( bandNo - 1 ) ] }; + const Qgis::DataType dataType { mDataTypes[static_cast( bandNo - 1 )] }; switch ( dataType ) { case Qgis::DataType::Byte: { const unsigned short byte { val.toUShort( &ok ) }; - if ( ! ok ) + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert identified value to byte" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return false; @@ -335,7 +325,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE case Qgis::DataType::UInt16: { const unsigned int uint { val.toUInt( &ok ) }; - if ( ! ok ) + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert identified value to unsigned int" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return false; @@ -346,7 +336,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE case Qgis::DataType::UInt32: { const unsigned long ulong { val.toULong( &ok ) }; - if ( ! ok ) + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert identified value to unsigned long" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return false; @@ -357,7 +347,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE case Qgis::DataType::Int16: { const int intVal { val.toInt( &ok ) }; - if ( ! ok ) + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert identified value to int" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return false; @@ -368,7 +358,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE case Qgis::DataType::Int32: { const long longVal { val.toLong( &ok ) }; - if ( ! ok ) + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert identified value to long" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return false; @@ -379,7 +369,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE case Qgis::DataType::Float32: { const float floatVal { val.toFloat( &ok ) }; - if ( ! ok ) + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert identified value to float" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return false; @@ -390,7 +380,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE case Qgis::DataType::Float64: { const double doubleVal { val.toDouble( &ok ) }; - if ( ! ok ) + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert identified value to double" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return false; @@ -407,9 +397,9 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE } else // Fetch block { - const Qgis::DataType dataType { mDataTypes[ bandNo - 1 ] }; + const Qgis::DataType dataType { mDataTypes[bandNo - 1] }; const GDALDataType gdalDataType = QgsGdalUtils::gdalDataTypeFromQgisDataType( dataType ); - const double noDataValue { mSrcNoDataValue[ bandNo - 1 ] }; + const double noDataValue { mSrcNoDataValue[bandNo - 1] }; const double xRes = viewExtent.width() / width; const double yRes = viewExtent.height() / height; @@ -420,18 +410,18 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE // TODO: round? const unsigned int desiredOverviewFactor { static_cast( minPixelSize / std::max( std::abs( mScaleX ), std::abs( mScaleY ) ) ) }; - unsigned int overviewFactor { 1 }; // no overview + unsigned int overviewFactor { 1 }; // no overview // Cannot use overviews if there is a where condition if ( whereAnd.isEmpty() ) { - const auto ovKeys { mOverViews.keys( ) }; + const auto ovKeys { mOverViews.keys() }; QList::const_reverse_iterator rit { ovKeys.rbegin() }; for ( ; rit != ovKeys.rend(); ++rit ) { if ( *rit <= desiredOverviewFactor ) { - tableToQuery = mOverViews[ *rit ]; + tableToQuery = mOverViews[*rit]; overviewFactor = *rit; QgsDebugMsgLevel( QStringLiteral( "Using overview for block read: %1" ).arg( tableToQuery ), 3 ); break; @@ -443,12 +433,11 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE //qDebug() << "View extent" << viewExtent.toString( 1 ) << width << height << minPixelSize; // Get the the tiles we need to build the block - const QgsPostgresRasterSharedData::TilesRequest tilesRequest - { + const QgsPostgresRasterSharedData::TilesRequest tilesRequest { bandNo, rasterExtent, overviewFactor, - pkSql(), // already quoted + pkSql(), // already quoted quotedIdentifier( mRasterColumn ), tableToQuery, QString::number( mCrs.postgisSrid() ), @@ -456,8 +445,7 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE connectionRO() }; - const QgsPostgresRasterSharedData::TilesResponse tileResponse - { + const QgsPostgresRasterSharedData::TilesResponse tileResponse { mShared->tiles( tilesRequest ) }; @@ -467,12 +455,12 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE // so we should not log an error here but make sure // the result buffer is filled with nodata gdal::dataset_unique_ptr dstDS { QgsGdalUtils::createSingleBandMemoryDataset( - gdalDataType, viewExtent, width, height, mCrs ) }; - if ( ! dstDS ) + gdalDataType, viewExtent, width, height, mCrs + ) }; + if ( !dstDS ) { - const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ; - QgsMessageLog::logMessage( tr( "Unable to create destination raster for tiles from %1: %2" ) - .arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ); + QgsMessageLog::logMessage( tr( "Unable to create destination raster for tiles from %1: %2" ).arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } @@ -482,23 +470,11 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE // copy to the result buffer CPLErrorReset(); - CPLErr err = GDALRasterIO( GDALGetRasterBand( dstDS.get(), 1 ), - GF_Read, - 0, - 0, - width, - height, - data, - width, - height, - gdalDataType, - 0, - 0 ); + CPLErr err = GDALRasterIO( GDALGetRasterBand( dstDS.get(), 1 ), GF_Read, 0, 0, width, height, data, width, height, gdalDataType, 0, 0 ); if ( err != CE_None ) { - const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ; - QgsMessageLog::logMessage( tr( "Unable to write raster to block from %1: %2" ) - .arg( mQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ); + QgsMessageLog::logMessage( tr( "Unable to write raster to block from %1: %2" ).arg( mQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } @@ -517,12 +493,12 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE //qDebug() << "Creating output raster: " << tilesExtent.toString() << tmpWidth << tmpHeight; gdal::dataset_unique_ptr tmpDS { QgsGdalUtils::createSingleBandMemoryDataset( - gdalDataType, tilesExtent, tmpWidth, tmpHeight, mCrs ) }; - if ( ! tmpDS ) + gdalDataType, tilesExtent, tmpWidth, tmpHeight, mCrs + ) }; + if ( !tmpDS ) { { - QgsMessageLog::logMessage( tr( "Unable to create temporary raster for tiles from %1" ) - .arg( tableToQuery ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Unable to create temporary raster for tiles from %1" ).arg( tableToQuery ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } } @@ -536,27 +512,17 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE { // Offset in px from the base raster const int xOff { static_cast( std::round( ( tile.upperLeftX - tilesExtent.xMinimum() ) / tile.scaleX ) ) }; - const int yOff { static_cast( std::round( ( tilesExtent.yMaximum() - tile.extent.yMaximum() ) / std::fabs( tile.scaleY ) ) )}; + const int yOff { static_cast( std::round( ( tilesExtent.yMaximum() - tile.extent.yMaximum() ) / std::fabs( tile.scaleY ) ) ) }; //qDebug() << "Merging tile output raster: " << tile.tileId << xOff << yOff << tile.width << tile.height ; - CPLErr err = GDALRasterIO( GDALGetRasterBand( tmpDS.get(), 1 ), - GF_Write, - xOff, - yOff, - static_cast( tile.width ), - static_cast( tile.height ), - ( void * )( tile.data.constData() ), // old-style because of const - static_cast( tile.width ), - static_cast( tile.height ), - gdalDataType, - 0, - 0 ); + CPLErr err = GDALRasterIO( GDALGetRasterBand( tmpDS.get(), 1 ), GF_Write, xOff, yOff, static_cast( tile.width ), static_cast( tile.height ), + ( void * ) ( tile.data.constData() ), // old-style because of const + static_cast( tile.width ), static_cast( tile.height ), gdalDataType, 0, 0 ); if ( err != CE_None ) { - const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ; - QgsMessageLog::logMessage( tr( "Unable to write tile to temporary raster from %1: %2" ) - .arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ); + QgsMessageLog::logMessage( tr( "Unable to write tile to temporary raster from %1: %2" ).arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } } @@ -574,45 +540,32 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE // Write data to the output block gdal::dataset_unique_ptr dstDS { QgsGdalUtils::createSingleBandMemoryDataset( - gdalDataType, viewExtent, width, height, mCrs ) }; - if ( ! dstDS ) + gdalDataType, viewExtent, width, height, mCrs + ) }; + if ( !dstDS ) { - const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ; - QgsMessageLog::logMessage( tr( "Unable to create destination raster for tiles from %1: %2" ) - .arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ); + QgsMessageLog::logMessage( tr( "Unable to create destination raster for tiles from %1: %2" ).arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } GDALSetRasterNoDataValue( GDALGetRasterBand( dstDS.get(), 1 ), noDataValue ); // Resample the raster to the final bounds and resolution - if ( ! QgsGdalUtils::resampleSingleBandRaster( tmpDS.get(), dstDS.get(), GDALResampleAlg::GRA_NearestNeighbour, nullptr ) ) + if ( !QgsGdalUtils::resampleSingleBandRaster( tmpDS.get(), dstDS.get(), GDALResampleAlg::GRA_NearestNeighbour, nullptr ) ) { - const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ; - QgsMessageLog::logMessage( tr( "Unable to resample and transform destination raster for tiles from %1: %2" ) - .arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ); + QgsMessageLog::logMessage( tr( "Unable to resample and transform destination raster for tiles from %1: %2" ).arg( tableToQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } // Copy to result buffer CPLErrorReset(); - CPLErr err = GDALRasterIO( GDALGetRasterBand( dstDS.get(), 1 ), - GF_Read, - 0, - 0, - width, - height, - data, - width, - height, - gdalDataType, - 0, - 0 ); + CPLErr err = GDALRasterIO( GDALGetRasterBand( dstDS.get(), 1 ), GF_Read, 0, 0, width, height, data, width, height, gdalDataType, 0, 0 ); if ( err != CE_None ) { - const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ) ; - QgsMessageLog::logMessage( tr( "Unable to write raster to block from %1: %2" ) - .arg( mQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + const QString lastError = QString::fromUtf8( CPLGetLastErrorMsg() ); + QgsMessageLog::logMessage( tr( "Unable to write raster to block from %1: %2" ).arg( mQuery, lastError ), tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } @@ -626,7 +579,6 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE qDebug() << reinterpret_cast( data )[ i * 4 ]; } #endif - } return true; } @@ -635,7 +587,6 @@ bool QgsPostgresRasterProvider::readBlock( int bandNo, const QgsRectangle &viewE QgsPostgresRasterProviderMetadata::QgsPostgresRasterProviderMetadata() : QgsProviderMetadata( QgsPostgresRasterProvider::PG_RASTER_PROVIDER_KEY, QgsPostgresRasterProvider::PG_RASTER_PROVIDER_DESCRIPTION ) { - } QIcon QgsPostgresRasterProviderMetadata::icon() const @@ -648,80 +599,76 @@ QVariantMap QgsPostgresRasterProviderMetadata::decodeUri( const QString &uri ) c const QgsDataSourceUri dsUri { uri }; QVariantMap decoded; - if ( ! dsUri.database().isEmpty() ) + if ( !dsUri.database().isEmpty() ) { - decoded[ QStringLiteral( "dbname" ) ] = dsUri.database(); + decoded[QStringLiteral( "dbname" )] = dsUri.database(); } - if ( ! dsUri.host().isEmpty() ) + if ( !dsUri.host().isEmpty() ) { - decoded[ QStringLiteral( "host" ) ] = dsUri.host(); + decoded[QStringLiteral( "host" )] = dsUri.host(); } - if ( ! dsUri.port().isEmpty() ) + if ( !dsUri.port().isEmpty() ) { - decoded[ QStringLiteral( "port" ) ] = dsUri.port(); + decoded[QStringLiteral( "port" )] = dsUri.port(); } - if ( ! dsUri.service().isEmpty() ) + if ( !dsUri.service().isEmpty() ) { - decoded[ QStringLiteral( "service" ) ] = dsUri.service(); + decoded[QStringLiteral( "service" )] = dsUri.service(); } - if ( ! dsUri.username().isEmpty() ) + if ( !dsUri.username().isEmpty() ) { - decoded[ QStringLiteral( "username" ) ] = dsUri.username(); + decoded[QStringLiteral( "username" )] = dsUri.username(); } - if ( ! dsUri.password().isEmpty() ) + if ( !dsUri.password().isEmpty() ) { - decoded[ QStringLiteral( "password" ) ] = dsUri.password(); + decoded[QStringLiteral( "password" )] = dsUri.password(); } - if ( ! dsUri.authConfigId().isEmpty() ) + if ( !dsUri.authConfigId().isEmpty() ) { - decoded[ QStringLiteral( "authcfg" ) ] = dsUri.authConfigId(); + decoded[QStringLiteral( "authcfg" )] = dsUri.authConfigId(); } - if ( ! dsUri.schema().isEmpty() ) + if ( !dsUri.schema().isEmpty() ) { - decoded[ QStringLiteral( "schema" ) ] = dsUri.schema(); + decoded[QStringLiteral( "schema" )] = dsUri.schema(); } - if ( ! dsUri.table().isEmpty() ) + if ( !dsUri.table().isEmpty() ) { - decoded[ QStringLiteral( "table" ) ] = dsUri.table(); + decoded[QStringLiteral( "table" )] = dsUri.table(); } - if ( ! dsUri.keyColumn().isEmpty() ) + if ( !dsUri.keyColumn().isEmpty() ) { - decoded[ QStringLiteral( "key" ) ] = dsUri.keyColumn(); + decoded[QStringLiteral( "key" )] = dsUri.keyColumn(); } - if ( ! dsUri.srid().isEmpty() ) + if ( !dsUri.srid().isEmpty() ) { - decoded[ QStringLiteral( "srid" ) ] = dsUri.srid(); + decoded[QStringLiteral( "srid" )] = dsUri.srid(); } if ( uri.contains( QStringLiteral( "estimatedmetadata=" ), Qt::CaseSensitivity::CaseInsensitive ) ) { - decoded[ QStringLiteral( "estimatedmetadata" ) ] = dsUri.useEstimatedMetadata(); + decoded[QStringLiteral( "estimatedmetadata" )] = dsUri.useEstimatedMetadata(); } if ( uri.contains( QStringLiteral( "sslmode=" ), Qt::CaseSensitivity::CaseInsensitive ) ) { - decoded[ QStringLiteral( "sslmode" ) ] = dsUri.sslMode(); + decoded[QStringLiteral( "sslmode" )] = dsUri.sslMode(); } // Do not add sql if it's empty - if ( ! dsUri.sql().isEmpty() ) + if ( !dsUri.sql().isEmpty() ) { - decoded[ QStringLiteral( "sql" ) ] = dsUri.sql(); + decoded[QStringLiteral( "sql" )] = dsUri.sql(); } - if ( ! dsUri.geometryColumn().isEmpty() ) + if ( !dsUri.geometryColumn().isEmpty() ) { - decoded[ QStringLiteral( "geometrycolumn" ) ] = dsUri.geometryColumn(); + decoded[QStringLiteral( "geometrycolumn" )] = dsUri.geometryColumn(); } // Params - const static QStringList params {{ - QStringLiteral( "temporalFieldIndex" ), - QStringLiteral( "temporalDefaultTime" ), - QStringLiteral( "enableTime" ) - }}; + const static QStringList params { { QStringLiteral( "temporalFieldIndex" ), QStringLiteral( "temporalDefaultTime" ), QStringLiteral( "enableTime" ) } }; for ( const QString &pname : std::as_const( params ) ) { if ( dsUri.hasParam( pname ) ) { - decoded[ pname ] = dsUri.param( pname ); + decoded[pname] = dsUri.param( pname ); } } @@ -759,7 +706,7 @@ QString QgsPostgresRasterProviderMetadata::encodeUri( const QVariantMap &parts ) if ( parts.contains( QStringLiteral( "estimatedmetadata" ) ) ) dsUri.setParam( QStringLiteral( "estimatedmetadata" ), parts.value( QStringLiteral( "estimatedmetadata" ) ).toString() ); if ( parts.contains( QStringLiteral( "sslmode" ) ) ) - dsUri.setParam( QStringLiteral( "sslmode" ), QgsDataSourceUri::encodeSslMode( static_cast( parts.value( QStringLiteral( "sslmode" ) ).toInt( ) ) ) ); + dsUri.setParam( QStringLiteral( "sslmode" ), QgsDataSourceUri::encodeSslMode( static_cast( parts.value( QStringLiteral( "sslmode" ) ).toInt() ) ) ); if ( parts.contains( QStringLiteral( "sql" ) ) ) dsUri.setSql( parts.value( QStringLiteral( "sql" ) ).toString() ); if ( parts.contains( QStringLiteral( "geometrycolumn" ) ) ) @@ -798,14 +745,11 @@ Qgis::DataType QgsPostgresRasterProvider::dataType( int bandNo ) const { if ( mDataTypes.size() < static_cast( bandNo ) ) { - QgsMessageLog::logMessage( tr( "Data type size for band %1 could not be found: num bands is: %2 and the type size map for bands contains: %n item(s)", nullptr, mDataSizes.size() ) - .arg( bandNo ) - .arg( mBandCount ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Data type size for band %1 could not be found: num bands is: %2 and the type size map for bands contains: %n item(s)", nullptr, mDataSizes.size() ).arg( bandNo ).arg( mBandCount ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return Qgis::DataType::UnknownDataType; } // Band is 1-based - return mDataTypes[ static_cast( bandNo ) - 1 ]; + return mDataTypes[static_cast( bandNo ) - 1]; } int QgsPostgresRasterProvider::bandCount() const @@ -877,16 +821,15 @@ QString QgsPostgresRasterProvider::htmlMetadata() const overviews.insert( QString::number( it.key() ), it.value() ); } - const QVariantMap additionalInformation - { + const QVariantMap additionalInformation { { tr( "Is Tiled" ), mIsTiled }, { tr( "Where Clause SQL" ), subsetString() }, { tr( "Pixel Size" ), QStringLiteral( "%1, %2" ).arg( mScaleX ).arg( mScaleY ) }, - { tr( "Overviews" ), overviews }, - { tr( "Primary Keys SQL" ), pkSql() }, - { tr( "Temporal Column" ), mTemporalFieldIndex >= 0 && mAttributeFields.exists( mTemporalFieldIndex ) ? mAttributeFields.field( mTemporalFieldIndex ).name() : QString() }, + { tr( "Overviews" ), overviews }, + { tr( "Primary Keys SQL" ), pkSql() }, + { tr( "Temporal Column" ), mTemporalFieldIndex >= 0 && mAttributeFields.exists( mTemporalFieldIndex ) ? mAttributeFields.field( mTemporalFieldIndex ).name() : QString() }, }; - return dumpVariantMap( additionalInformation, tr( "Additional information" ) ); + return dumpVariantMap( additionalInformation, tr( "Additional information" ) ); } QString QgsPostgresRasterProvider::lastErrorTitle() @@ -902,10 +845,10 @@ QString QgsPostgresRasterProvider::lastError() Qgis::RasterInterfaceCapabilities QgsPostgresRasterProvider::capabilities() const { const Qgis::RasterInterfaceCapabilities capability = Qgis::RasterInterfaceCapability::Identify - | Qgis::RasterInterfaceCapability::IdentifyValue - | Qgis::RasterInterfaceCapability::Size - // TODO:| QgsRasterDataProvider::BuildPyramids - | Qgis::RasterInterfaceCapability::Prefetch; + | Qgis::RasterInterfaceCapability::IdentifyValue + | Qgis::RasterInterfaceCapability::Size + // TODO:| QgsRasterDataProvider::BuildPyramids + | Qgis::RasterInterfaceCapability::Prefetch; return capability; } @@ -945,17 +888,13 @@ QString QgsPostgresRasterProvider::subsetString() const QString QgsPostgresRasterProvider::defaultTimeSubsetString( const QDateTime &defaultTime ) const { - if ( defaultTime.isValid( ) && - mTemporalFieldIndex >= 0 && - mAttributeFields.exists( mTemporalFieldIndex ) ) + if ( defaultTime.isValid() && mTemporalFieldIndex >= 0 && mAttributeFields.exists( mTemporalFieldIndex ) ) { const QgsField temporalField { mAttributeFields.field( mTemporalFieldIndex ) }; const QString typeCast { temporalField.type() != QMetaType::Type::QDateTime ? QStringLiteral( "::timestamp" ) : QString() }; const QString temporalFieldName { temporalField.name() }; - return { QStringLiteral( "%1%2 = %3" ) - .arg( quotedIdentifier( temporalFieldName ), - typeCast, - quotedValue( defaultTime.toString( Qt::DateFormat::ISODate ) ) ) }; + return { QStringLiteral( "%1%2 = %3" ) + .arg( quotedIdentifier( temporalFieldName ), typeCast, quotedValue( defaultTime.toString( Qt::DateFormat::ISODate ) ) ) }; } else { @@ -1002,42 +941,34 @@ QString QgsPostgresRasterProvider::subsetStringWithTemporalRange() const { QString temporalClause; const QgsTemporalRange requestedRange { temporalCapabilities()->requestedTemporalRange() }; - if ( ! requestedRange.isEmpty() && ! requestedRange.isInfinite() ) + if ( !requestedRange.isEmpty() && !requestedRange.isInfinite() ) { if ( requestedRange.isInstant() ) { temporalClause = QStringLiteral( "%1%2 = %3" ) - .arg( quotedIdentifier( temporalFieldName ), - typeCast, - quotedValue( requestedRange.begin().toString( Qt::DateFormat::ISODate ) ) ); + .arg( quotedIdentifier( temporalFieldName ), typeCast, quotedValue( requestedRange.begin().toString( Qt::DateFormat::ISODate ) ) ); } else { if ( requestedRange.begin().isValid() ) { temporalClause = QStringLiteral( "%1%2 %3 %4" ) - .arg( quotedIdentifier( temporalFieldName ), - typeCast, - requestedRange.includeBeginning() ? ">=" : ">", - quotedValue( requestedRange.begin().toString( Qt::DateFormat::ISODate ) ) ); + .arg( quotedIdentifier( temporalFieldName ), typeCast, requestedRange.includeBeginning() ? ">=" : ">", quotedValue( requestedRange.begin().toString( Qt::DateFormat::ISODate ) ) ); } if ( requestedRange.end().isValid() ) { - if ( ! temporalClause.isEmpty() ) + if ( !temporalClause.isEmpty() ) { temporalClause.append( QStringLiteral( " AND " ) ); } temporalClause.append( QStringLiteral( "%1%2 %3 %4" ) - .arg( quotedIdentifier( temporalFieldName ), - typeCast, - requestedRange.includeEnd() ? "<=" : "<", - quotedValue( requestedRange.end().toString( Qt::DateFormat::ISODate ) ) ) ); + .arg( quotedIdentifier( temporalFieldName ), typeCast, requestedRange.includeEnd() ? "<=" : "<", quotedValue( requestedRange.end().toString( Qt::DateFormat::ISODate ) ) ) ); } } return mSqlWhereClause.isEmpty() ? temporalClause : QStringLiteral( "%1 AND (%2)" ).arg( mSqlWhereClause, temporalClause ); } const QString defaultTimeSubset { defaultTimeSubsetString( mTemporalDefaultTime ) }; - if ( ! defaultTimeSubset.isEmpty() ) + if ( !defaultTimeSubset.isEmpty() ) { return mSqlWhereClause.isEmpty() ? defaultTimeSubset : QStringLiteral( "%1 AND (%2)" ).arg( mSqlWhereClause, defaultTimeSubset ); } @@ -1064,7 +995,6 @@ void QgsPostgresRasterProvider::disconnectDb() bool QgsPostgresRasterProvider::init() { - // WARNING: multiple failure and return points! mOverViews.clear(); @@ -1085,8 +1015,7 @@ bool QgsPostgresRasterProvider::init() // Note that a temporal filter set as temporal default value does not count as a WHERE condition // utility to get data type from string, used in both branches - auto pixelTypeFromString = [ ]( const QString & t ) -> Qgis::DataType - { + auto pixelTypeFromString = []( const QString &t ) -> Qgis::DataType { /* Pixel types 1BB - 1-bit boolean 2BUI - 2-bit unsigned integer @@ -1134,7 +1063,7 @@ bool QgsPostgresRasterProvider::init() // /////////////////////////////////////////////////////////////////// // First method: get information from metadata - if ( ! mIsQuery && mUseEstimatedMetadata && subsetString().isEmpty() ) + if ( !mIsQuery && mUseEstimatedMetadata && subsetString().isEmpty() ) { try { @@ -1144,7 +1073,7 @@ bool QgsPostgresRasterProvider::init() "regular_blocking " "FROM raster_columns WHERE " "r_table_name = %1 AND r_table_schema = %2" ) - .arg( quotedValue( mTableName ), quotedValue( mSchemaName ) ); + .arg( quotedValue( mTableName ), quotedValue( mSchemaName ) ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); @@ -1164,7 +1093,7 @@ bool QgsPostgresRasterProvider::init() mCrs.createFromSrid( result.PQgetvalue( 0, 1 ).toLong( &ok ) ); Q_NOWARN_DEPRECATED_PUSH - if ( ! ok ) + if ( !ok ) { throw QgsPostgresRasterProviderException( tr( "Cannot create CRS from EPSG: '%1'" ).arg( result.PQgetvalue( 0, 1 ) ) ); } @@ -1172,7 +1101,7 @@ bool QgsPostgresRasterProvider::init() mDetectedSrid = result.PQgetvalue( 0, 1 ); mBandCount = result.PQgetvalue( 0, 2 ).toInt( &ok ); - if ( ! ok ) + if ( !ok ) { throw QgsPostgresRasterProviderException( tr( "Cannot get band count from value: '%1'" ).arg( result.PQgetvalue( 0, 2 ) ) ); } @@ -1185,7 +1114,7 @@ bool QgsPostgresRasterProvider::init() noDataValuesArray.chop( 1 ); const QStringList noDataValues { noDataValuesArray.mid( 1 ).split( ',' ) }; - if ( mBandCount != pxTypes.count( ) || mBandCount != noDataValues.count() ) + if ( mBandCount != pxTypes.count() || mBandCount != noDataValues.count() ) { throw QgsPostgresRasterProviderException( tr( "Band count and NoData items count differ" ) ); } @@ -1201,13 +1130,11 @@ bool QgsPostgresRasterProvider::init() mDataTypes.push_back( type ); mDataSizes.push_back( QgsRasterBlock::typeSize( type ) ); double nodataValue { noDataValues.at( i ).toDouble( &ok ) }; - if ( ! ok ) + if ( !ok ) { if ( noDataValues.at( i ) != QLatin1String( "NULL" ) ) { - QgsMessageLog::logMessage( tr( "Cannot convert NoData value '%1' to double" ) - .arg( noDataValues.at( i ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Info ); + QgsMessageLog::logMessage( tr( "Cannot convert NoData value '%1' to double" ).arg( noDataValues.at( i ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Info ); } mSrcHasNoDataValue.append( false ); mUseSrcNoDataValue.append( false ); @@ -1229,20 +1156,18 @@ bool QgsPostgresRasterProvider::init() const QByteArray hexBin = QByteArray::fromHex( hexAscii ); QgsConstWkbPtr ptr { hexBin }; - if ( hexAscii.isEmpty() || ! p.fromWkb( ptr ) ) + if ( hexAscii.isEmpty() || !p.fromWkb( ptr ) ) { // Try to determine extent from raster const QString extentSql = QStringLiteral( "SELECT ST_Envelope( %1 ) " - "FROM %2 WHERE %3" ) - .arg( quotedIdentifier( mRasterColumn ), - mQuery, - subsetString().isEmpty() ? "'t'" : subsetString() ); + "FROM %2 WHERE %3" ) + .arg( quotedIdentifier( mRasterColumn ), mQuery, subsetString().isEmpty() ? "'t'" : subsetString() ); QgsPostgresResult extentResult( connectionRO()->PQexec( extentSql ) ); const QByteArray extentHexAscii { extentResult.PQgetvalue( 0, 0 ).toLatin1() }; const QByteArray extentHexBin = QByteArray::fromHex( extentHexAscii ); QgsConstWkbPtr extentPtr { extentHexBin }; - if ( extentHexAscii.isEmpty() || ! p.fromWkb( extentPtr ) ) + if ( extentHexAscii.isEmpty() || !p.fromWkb( extentPtr ) ) { throw QgsPostgresRasterProviderException( tr( "Cannot get extent from raster" ) ); } @@ -1253,14 +1178,14 @@ bool QgsPostgresRasterProvider::init() // Tile size mTileWidth = result.PQgetvalue( 0, 6 ).toInt( &ok ); - if ( ! ok ) + if ( !ok ) { throw QgsPostgresRasterProviderException( tr( "Cannot convert width '%1' to int" ).arg( result.PQgetvalue( 0, 6 ) ) ); } mTileHeight = result.PQgetvalue( 0, 7 ).toInt( &ok ); - if ( ! ok ) + if ( !ok ) { throw QgsPostgresRasterProviderException( tr( "Cannot convert height '%1' to int" ).arg( result.PQgetvalue( 0, 7 ) ) ); } @@ -1268,14 +1193,14 @@ bool QgsPostgresRasterProvider::init() mIsOutOfDb = result.PQgetvalue( 0, 8 ) == 't'; mScaleX = result.PQgetvalue( 0, 10 ).toDouble( &ok ); - if ( ! ok ) + if ( !ok ) { throw QgsPostgresRasterProviderException( tr( "Cannot convert scale X '%1' to double" ).arg( result.PQgetvalue( 0, 10 ) ) ); } mScaleY = result.PQgetvalue( 0, 11 ).toDouble( &ok ); - if ( ! ok ) + if ( !ok ) { throw QgsPostgresRasterProviderException( tr( "Cannot convert scale Y '%1' to double" ).arg( result.PQgetvalue( 0, 11 ) ) ); } @@ -1288,23 +1213,19 @@ bool QgsPostgresRasterProvider::init() // Detect overviews findOverviews(); - return initFieldsAndTemporal( ); + return initFieldsAndTemporal(); } else { - QgsMessageLog::logMessage( tr( "An error occurred while fetching raster metadata for table %1: %2\nSQL: %3" ) - .arg( mQuery ) - .arg( result.PQresultErrorMessage() ) - .arg( sql ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "An error occurred while fetching raster metadata for table %1: %2\nSQL: %3" ).arg( mQuery ).arg( result.PQresultErrorMessage() ).arg( sql ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } } catch ( QgsPostgresRasterProviderException &ex ) { QgsMessageLog::logMessage( tr( "An error occurred while fetching raster metadata for %1, proceeding with (possibly very slow) raster data analysis: %2\n" "Please consider adding raster constraints with PostGIS function AddRasterConstraints." ) - .arg( mQuery ) - .arg( ex.message ), + .arg( mQuery ) + .arg( ex.message ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } } @@ -1318,7 +1239,7 @@ bool QgsPostgresRasterProvider::init() { const QString sql = QStringLiteral( "SELECT column_name FROM information_schema.columns WHERE " "table_name = %1 AND table_schema = %2 AND udt_name = 'raster'" ) - .arg( quotedValue( mTableName ), quotedValue( mSchemaName ) ); + .arg( quotedValue( mTableName ), quotedValue( mSchemaName ) ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); @@ -1326,16 +1247,13 @@ bool QgsPostgresRasterProvider::init() { if ( result.PQntuples() > 1 ) { - QgsMessageLog::logMessage( tr( "Multiple raster column detected, using the first one" ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); - + QgsMessageLog::logMessage( tr( "Multiple raster column detected, using the first one" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } mRasterColumn = result.PQgetvalue( 0, 0 ); } else { - QgsMessageLog::logMessage( tr( "An error occurred while fetching raster column" ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "An error occurred while fetching raster column" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } } @@ -1351,13 +1269,13 @@ bool QgsPostgresRasterProvider::init() QString tableToQuery { mQuery }; - if ( ! mOverViews.isEmpty() ) + if ( !mOverViews.isEmpty() ) { tableToQuery = mOverViews.last(); } QString where; - if ( ! subsetString().isEmpty() ) + if ( !subsetString().isEmpty() ) { where = QStringLiteral( "WHERE %1" ).arg( subsetString() ); } @@ -1374,14 +1292,14 @@ bool QgsPostgresRasterProvider::init() SELECT ENCODE( ST_AsBinary( ST_Envelope( band ) ), 'hex'), (ST_Metadata( band )).*, (ST_BandMetadata( band )).* - FROM cte_band)" ).arg( quotedIdentifier( mRasterColumn ), tableToQuery, where ); + FROM cte_band)" ) + .arg( quotedIdentifier( mRasterColumn ), tableToQuery, where ); QgsDebugMsgLevel( QStringLiteral( "Raster information sql: %1" ).arg( sql ), 4 ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); if ( PGRES_TUPLES_OK == result.PQresultStatus() && result.PQntuples() > 0 ) { - // These may have been filled with defaults in the fast track mSrcNoDataValue.clear(); mSrcHasNoDataValue.clear(); @@ -1396,17 +1314,15 @@ bool QgsPostgresRasterProvider::init() { const QByteArray hexBin = QByteArray::fromHex( result.PQgetvalue( 0, 0 ).toLatin1() ); QgsConstWkbPtr ptr { hexBin }; - if ( ! p.fromWkb( ptr ) ) + if ( !p.fromWkb( ptr ) ) { - QgsMessageLog::logMessage( tr( "Cannot get extent from raster" ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Cannot get extent from raster" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } } catch ( ... ) { - QgsMessageLog::logMessage( tr( "Cannot get metadata from raster" ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Cannot get metadata from raster" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } @@ -1415,37 +1331,33 @@ bool QgsPostgresRasterProvider::init() // Tile size (in this path the raster is considered untiled, so this is actually the whole size) mTileWidth = result.PQgetvalue( 0, 3 ).toInt( &ok ); - if ( ! ok ) + if ( !ok ) { - QgsMessageLog::logMessage( tr( "Cannot convert width '%1' to int" ).arg( result.PQgetvalue( 0, 3 ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Cannot convert width '%1' to int" ).arg( result.PQgetvalue( 0, 3 ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } mTileHeight = result.PQgetvalue( 0, 4 ).toInt( &ok ); - if ( ! ok ) + if ( !ok ) { - QgsMessageLog::logMessage( tr( "Cannot convert height '%1' to int" ).arg( result.PQgetvalue( 0, 4 ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Cannot convert height '%1' to int" ).arg( result.PQgetvalue( 0, 4 ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } mScaleX = result.PQgetvalue( 0, 5 ).toDouble( &ok ); - if ( ! ok ) + if ( !ok ) { - QgsMessageLog::logMessage( tr( "Cannot convert scale X '%1' to double" ).arg( result.PQgetvalue( 0, 5 ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Cannot convert scale X '%1' to double" ).arg( result.PQgetvalue( 0, 5 ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } mScaleY = result.PQgetvalue( 0, 6 ).toDouble( &ok ); - if ( ! ok ) + if ( !ok ) { - QgsMessageLog::logMessage( tr( "Cannot convert scale Y '%1' to double" ).arg( result.PQgetvalue( 0, 6 ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Cannot convert scale Y '%1' to double" ).arg( result.PQgetvalue( 0, 6 ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } @@ -1464,10 +1376,9 @@ bool QgsPostgresRasterProvider::init() mCrs.createFromSrid( result.PQgetvalue( 0, 9 ).toLong( &ok ) ); Q_NOWARN_DEPRECATED_PUSH - if ( ! ok ) + if ( !ok ) { - QgsMessageLog::logMessage( tr( "Cannot create CRS from EPSG: '%1'" ).arg( result.PQgetvalue( 0, 9 ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Cannot create CRS from EPSG: '%1'" ).arg( result.PQgetvalue( 0, 9 ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } @@ -1480,8 +1391,7 @@ bool QgsPostgresRasterProvider::init() if ( type == Qgis::DataType::UnknownDataType ) { - QgsMessageLog::logMessage( tr( "Unsupported data type: '%1'" ).arg( result.PQgetvalue( rowNumber, 11 ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "Unsupported data type: '%1'" ).arg( result.PQgetvalue( rowNumber, 11 ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } @@ -1489,11 +1399,9 @@ bool QgsPostgresRasterProvider::init() mDataSizes.push_back( QgsRasterBlock::typeSize( type ) ); double nodataValue { result.PQgetvalue( rowNumber, 12 ).toDouble( &ok ) }; - if ( ! ok ) + if ( !ok ) { - QgsMessageLog::logMessage( tr( "Cannot convert NoData value '%1' to double, default to: %2" ) - .arg( result.PQgetvalue( rowNumber, 2 ) ) - .arg( std::numeric_limits::min() ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Info ); + QgsMessageLog::logMessage( tr( "Cannot convert NoData value '%1' to double, default to: %2" ).arg( result.PQgetvalue( rowNumber, 2 ) ).arg( std::numeric_limits::min() ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Info ); nodataValue = std::numeric_limits::min(); } @@ -1505,26 +1413,24 @@ bool QgsPostgresRasterProvider::init() } else { - QgsMessageLog::logMessage( tr( "An error occurred while fetching raster metadata" ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "An error occurred while fetching raster metadata" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } - return initFieldsAndTemporal( ); + return initFieldsAndTemporal(); } -bool QgsPostgresRasterProvider::initFieldsAndTemporal( ) +bool QgsPostgresRasterProvider::initFieldsAndTemporal() { // Populate fields - if ( ! loadFields() ) + if ( !loadFields() ) { - QgsMessageLog::logMessage( tr( "An error occurred while fetching raster fields information" ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( tr( "An error occurred while fetching raster fields information" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } QString where; - if ( ! subsetString().isEmpty() ) + if ( !subsetString().isEmpty() ) { where = QStringLiteral( "WHERE %1" ).arg( subsetString() ); } @@ -1539,10 +1445,9 @@ bool QgsPostgresRasterProvider::initFieldsAndTemporal( ) { const QString temporalFieldName { mAttributeFields.field( temporalFieldIndex ).name() }; // Calculate the range - const QString sql = QStringLiteral( "SELECT MIN(%1::timestamp), MAX(%1::timestamp) " - "FROM %2 %3" ).arg( quotedIdentifier( temporalFieldName ), - mQuery, - where ); + const QString sql = QStringLiteral( "SELECT MIN(%1::timestamp), MAX(%1::timestamp) " + "FROM %2 %3" ) + .arg( quotedIdentifier( temporalFieldName ), mQuery, where ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); @@ -1568,17 +1473,15 @@ bool QgsPostgresRasterProvider::initFieldsAndTemporal( ) } else { - QgsMessageLog::logMessage( tr( "Invalid default date in raster temporal capabilities for field %1: %2" ).arg( temporalFieldName, mUri.param( QStringLiteral( "temporalDefaultTime" ) ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Invalid default date in raster temporal capabilities for field %1: %2" ).arg( temporalFieldName, mUri.param( QStringLiteral( "temporalDefaultTime" ) ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } } // Set temporal ranges - QList< QgsDateTimeRange > allRanges; - const QString sql = QStringLiteral( "SELECT DISTINCT %1::timestamp " - "FROM %2 %3 ORDER BY %1::timestamp" ).arg( quotedIdentifier( temporalFieldName ), - mQuery, - where ); + QList allRanges; + const QString sql = QStringLiteral( "SELECT DISTINCT %1::timestamp " + "FROM %2 %3 ORDER BY %1::timestamp" ) + .arg( quotedIdentifier( temporalFieldName ), mQuery, where ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); if ( PGRES_TUPLES_OK == result.PQresultStatus() && result.PQntuples() > 0 ) @@ -1592,28 +1495,22 @@ bool QgsPostgresRasterProvider::initFieldsAndTemporal( ) } else { - QgsMessageLog::logMessage( tr( "No temporal ranges detected in raster temporal capabilities for field %1: %2" ).arg( temporalFieldName, mUri.param( QStringLiteral( "temporalDefaultTime" ) ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Info ); + QgsMessageLog::logMessage( tr( "No temporal ranges detected in raster temporal capabilities for field %1: %2" ).arg( temporalFieldName, mUri.param( QStringLiteral( "temporalDefaultTime" ) ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Info ); } } else { - QgsMessageLog::logMessage( tr( "Invalid temporal range in raster temporal capabilities for field %1: %2 - %3" ).arg( temporalFieldName, minTime.toString(), maxTime.toString() ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Invalid temporal range in raster temporal capabilities for field %1: %2 - %3" ).arg( temporalFieldName, minTime.toString(), maxTime.toString() ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } } else { - QgsMessageLog::logMessage( tr( "An error occurred while fetching raster temporal capabilities for field: %1" ).arg( temporalFieldName ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); - + QgsMessageLog::logMessage( tr( "An error occurred while fetching raster temporal capabilities for field: %1" ).arg( temporalFieldName ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } } else { - QgsMessageLog::logMessage( tr( "Invalid field index for raster temporal capabilities: %1" ) - .arg( QString::number( temporalFieldIndex ) ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Invalid field index for raster temporal capabilities: %1" ).arg( QString::number( temporalFieldIndex ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } } return true; @@ -1621,7 +1518,6 @@ bool QgsPostgresRasterProvider::initFieldsAndTemporal( ) bool QgsPostgresRasterProvider::loadFields() { - if ( !mIsQuery ) { QgsDebugMsgLevel( QStringLiteral( "Loading fields for table %1" ).arg( mTableName ), 2 ); @@ -1659,8 +1555,7 @@ bool QgsPostgresRasterProvider::loadFields() QMap typeMap; for ( int i = 0; i < typeResult.PQntuples(); ++i ) { - PGTypeInfo typeInfo = - { + PGTypeInfo typeInfo = { /* typeName = */ typeResult.PQgetvalue( i, 1 ), /* typeType = */ typeResult.PQgetvalue( i, 2 ), /* typeElem = */ typeResult.PQgetvalue( i, 3 ), @@ -1670,9 +1565,9 @@ bool QgsPostgresRasterProvider::loadFields() } - QMap > fmtFieldTypeMap, descrMap, defValMap, identityMap; - QMap > attTypeIdMap; - QMap > notNullMap, uniqueMap; + QMap> fmtFieldTypeMap, descrMap, defValMap, identityMap; + QMap> attTypeIdMap; + QMap> notNullMap, uniqueMap; if ( result.PQnfields() > 0 ) { // Collect table oids @@ -1707,7 +1602,9 @@ bool QgsPostgresRasterProvider::loadFields() " LEFT OUTER JOIN ( SELECT DISTINCT indrelid, indkey, indisunique FROM pg_index WHERE indisunique ) uniq ON attrelid=indrelid AND attnum::text=indkey::text " " WHERE attrelid IN %2" - ).arg( connectionRO()->pgVersion() >= 100000 ? QStringLiteral( ", attidentity" ) : QString() ).arg( tableoidsFilter ); + ) + .arg( connectionRO()->pgVersion() >= 100000 ? QStringLiteral( ", attidentity" ) : QString() ) + .arg( tableoidsFilter ); QgsPostgresResult fmtFieldTypeResult( connectionRO()->PQexec( sql ) ); for ( int i = 0; i < fmtFieldTypeResult.PQntuples(); ++i ) @@ -1786,15 +1683,13 @@ bool QgsPostgresRasterProvider::loadFields() fieldSize = -1; fieldPrec = 0; } - else if ( fieldTypeName == QLatin1String( "int2" ) || fieldTypeName == QLatin1String( "int4" ) || - fieldTypeName == QLatin1String( "oid" ) || fieldTypeName == QLatin1String( "serial" ) ) + else if ( fieldTypeName == QLatin1String( "int2" ) || fieldTypeName == QLatin1String( "int4" ) || fieldTypeName == QLatin1String( "oid" ) || fieldTypeName == QLatin1String( "serial" ) ) { fieldType = QMetaType::Type::Int; fieldSize = -1; fieldPrec = 0; } - else if ( fieldTypeName == QLatin1String( "real" ) || fieldTypeName == QLatin1String( "double precision" ) || - fieldTypeName == QLatin1String( "float4" ) || fieldTypeName == QLatin1String( "float8" ) ) + else if ( fieldTypeName == QLatin1String( "real" ) || fieldTypeName == QLatin1String( "double precision" ) || fieldTypeName == QLatin1String( "float4" ) || fieldTypeName == QLatin1String( "float8" ) ) { fieldType = QMetaType::Type::Double; fieldSize = -1; @@ -1820,10 +1715,7 @@ bool QgsPostgresRasterProvider::loadFields() } else if ( formattedFieldType != QLatin1String( "numeric" ) ) { - QgsMessageLog::logMessage( tr( "Unexpected formatted field type '%1' for field %2" ) - .arg( formattedFieldType, - fieldName ), - tr( "PostGIS" ) ); + QgsMessageLog::logMessage( tr( "Unexpected formatted field type '%1' for field %2" ).arg( formattedFieldType, fieldName ), tr( "PostGIS" ) ); fieldSize = -1; fieldPrec = 0; } @@ -1870,15 +1762,7 @@ bool QgsPostgresRasterProvider::loadFields() fieldType = QMetaType::Type::QByteArray; fieldSize = -1; } - else if ( fieldTypeName == QLatin1String( "text" ) || - fieldTypeName == QLatin1String( "citext" ) || - fieldTypeName == QLatin1String( "geometry" ) || - fieldTypeName == QLatin1String( "inet" ) || - fieldTypeName == QLatin1String( "ltree" ) || - fieldTypeName == QLatin1String( "uuid" ) || - fieldTypeName == QLatin1String( "xml" ) || - fieldTypeName.startsWith( QLatin1String( "time" ) ) || - fieldTypeName.startsWith( QLatin1String( "date" ) ) ) + else if ( fieldTypeName == QLatin1String( "text" ) || fieldTypeName == QLatin1String( "citext" ) || fieldTypeName == QLatin1String( "geometry" ) || fieldTypeName == QLatin1String( "inet" ) || fieldTypeName == QLatin1String( "ltree" ) || fieldTypeName == QLatin1String( "uuid" ) || fieldTypeName == QLatin1String( "xml" ) || fieldTypeName.startsWith( QLatin1String( "time" ) ) || fieldTypeName.startsWith( QLatin1String( "date" ) ) ) { fieldType = QMetaType::Type::QString; fieldSize = -1; @@ -1899,8 +1783,7 @@ bool QgsPostgresRasterProvider::loadFields() else { QgsDebugError( QStringLiteral( "Unexpected formatted field type '%1' for field %2" ) - .arg( formattedFieldType, - fieldName ) ); + .arg( formattedFieldType, fieldName ) ); fieldSize = -1; fieldPrec = 0; } @@ -1918,13 +1801,12 @@ bool QgsPostgresRasterProvider::loadFields() else { QgsMessageLog::logMessage( tr( "Unexpected formatted field type '%1' for field %2" ) - .arg( formattedFieldType, - fieldName ) ); + .arg( formattedFieldType, fieldName ) ); fieldSize = -1; fieldPrec = 0; } } - else if ( fieldTypeName == QLatin1String( "hstore" ) || fieldTypeName == QLatin1String( "json" ) || fieldTypeName == QLatin1String( "jsonb" ) ) + else if ( fieldTypeName == QLatin1String( "hstore" ) || fieldTypeName == QLatin1String( "json" ) || fieldTypeName == QLatin1String( "jsonb" ) ) { fieldType = QMetaType::Type::QVariantMap; fieldSubType = QMetaType::Type::QString; @@ -1941,7 +1823,7 @@ bool QgsPostgresRasterProvider::loadFields() // be tolerant in case of views: this might be a field used as a key const Qgis::PostgresRelKind type = relkind(); if ( ( type == Qgis::PostgresRelKind::View || type == Qgis::PostgresRelKind::MaterializedView ) - && parseUriKey( mUri.keyColumn( ) ).contains( fieldName ) ) + && parseUriKey( mUri.keyColumn() ).contains( fieldName ) ) { // Assume it is convertible to text fieldType = QMetaType::Type::QString; @@ -1990,8 +1872,8 @@ bool QgsPostgresRasterProvider::loadFields() // If this is an identity field with constraints and there is no default, let's look for a sequence: // we might have a default value created by a sequence named
    __seq - if ( ! identityMap[tableoid ][ attnum ].isEmpty() - && notNullMap[tableoid][ attnum ] + if ( !identityMap[tableoid][attnum].isEmpty() + && notNullMap[tableoid][attnum] && uniqueMap[tableoid][attnum] && defValMap[tableoid][attnum].isEmpty() ) { @@ -2003,8 +1885,7 @@ bool QgsPostgresRasterProvider::loadFields() " WHERE c.relkind = 'S' " " AND c.relname = %1 " " AND n.nspname = %2" ) - .arg( quotedValue( seqName ), - quotedValue( mSchemaName ) ); + .arg( quotedValue( seqName ), quotedValue( mSchemaName ) ); QgsPostgresResult seqResult( connectionRO()->PQexec( seqSql ) ); if ( seqResult.PQntuples() == 1 ) { @@ -2033,7 +1914,8 @@ bool QgsPostgresRasterProvider::loadFields() /* static */ QStringList QgsPostgresRasterProvider::parseUriKey( const QString &key ) { - if ( key.isEmpty() ) return QStringList(); + if ( key.isEmpty() ) + return QStringList(); QStringList cols; @@ -2096,7 +1978,6 @@ Qgis::PostgresRelKind QgsPostgresRasterProvider::relkind() const bool QgsPostgresRasterProvider::determinePrimaryKey() { - if ( !loadFields() ) { return false; @@ -2210,9 +2091,9 @@ bool QgsPostgresRasterProvider::determinePrimaryKey() sql = QStringLiteral( "SELECT attname, attnotnull, data_type FROM pg_index, pg_attribute " "JOIN information_schema.columns ON (column_name = attname AND table_name = %1 AND table_schema = %2) " "WHERE indexrelid=%3 AND indrelid=attrelid AND pg_attribute.attnum=any(pg_index.indkey)" ) - .arg( quotedValue( mTableName ) ) - .arg( quotedValue( mSchemaName ) ) - .arg( indrelid ); + .arg( quotedValue( mTableName ) ) + .arg( quotedValue( mSchemaName ) ) + .arg( indrelid ); QgsDebugMsgLevel( "Retrieving key columns: " + sql, 4 ); res = connectionRO()->PQexec( sql ); @@ -2308,7 +2189,6 @@ void QgsPostgresRasterProvider::determinePrimaryKeyFromUriKeyColumn() if ( !mPrimaryKeyAttrs.isEmpty() ) { - if ( mUseEstimatedMetadata ) { mPrimaryKeyType = PktFidMap; // Map by default @@ -2345,7 +2225,7 @@ QString QgsPostgresRasterProvider::pkSql() const return QStringLiteral( "ctid" ); default: { - if ( mPrimaryKeyAttrs.count( ) > 1 ) + if ( mPrimaryKeyAttrs.count() > 1 ) { QStringList pkeys; for ( const int &keyIndex : std::as_const( mPrimaryKeyAttrs ) ) @@ -2374,8 +2254,8 @@ QString QgsPostgresRasterProvider::dataComment() const void QgsPostgresRasterProvider::findOverviews() { const QString sql = QStringLiteral( "SELECT overview_factor, o_table_schema, o_table_name, o_raster_column " - "FROM raster_overviews WHERE r_table_schema = %1 AND r_table_name = %2" ).arg( quotedValue( mSchemaName ), - quotedValue( mTableName ) ); + "FROM raster_overviews WHERE r_table_schema = %1 AND r_table_name = %2" ) + .arg( quotedValue( mSchemaName ), quotedValue( mTableName ) ); //QgsDebugMsgLevel( QStringLiteral( "Raster overview information sql: %1" ).arg( sql ), 2 ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); @@ -2384,8 +2264,8 @@ void QgsPostgresRasterProvider::findOverviews() for ( int i = 0; i < result.PQntuples(); ++i ) { bool ok; - const unsigned int overViewFactor { static_cast< unsigned int>( result.PQgetvalue( i, 0 ).toInt( & ok ) ) }; - if ( ! ok ) + const unsigned int overViewFactor { static_cast( result.PQgetvalue( i, 0 ).toInt( &ok ) ) }; + if ( !ok ) { QgsMessageLog::logMessage( tr( "Cannot convert overview factor '%1' to int" ).arg( result.PQgetvalue( i, 0 ) ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return; @@ -2397,7 +2277,7 @@ void QgsPostgresRasterProvider::findOverviews() QgsMessageLog::logMessage( tr( "Table or schema is empty" ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); return; } - mOverViews[ overViewFactor ] = QStringLiteral( "%1.%2" ).arg( quotedIdentifier( schema ) ).arg( quotedIdentifier( table ) ); + mOverViews[overViewFactor] = QStringLiteral( "%1.%2" ).arg( quotedIdentifier( schema ) ).arg( quotedIdentifier( table ) ); } } else @@ -2444,7 +2324,7 @@ Qgis::DataType QgsPostgresRasterProvider::sourceDataType( int bandNo ) const { if ( bandNo <= mBandCount && static_cast( bandNo ) <= mDataTypes.size() ) { - return mDataTypes[ static_cast( bandNo - 1 ) ]; + return mDataTypes[static_cast( bandNo - 1 )]; } else { @@ -2483,16 +2363,16 @@ QgsRasterBandStats QgsPostgresRasterProvider::bandStatistics( int bandNo, Qgis:: double statsRatio { pixelsRatio }; // Decide if overviews can be used here - if ( subsetString().isEmpty() && ! mIsQuery && mIsTiled && extent.isEmpty() ) + if ( subsetString().isEmpty() && !mIsQuery && mIsTiled && extent.isEmpty() ) { const unsigned int desiredOverviewFactor { static_cast( 1.0 / sqrt( pixelsRatio ) ) }; - const auto ovKeys { mOverViews.keys( ) }; + const auto ovKeys { mOverViews.keys() }; QList::const_reverse_iterator rit { ovKeys.rbegin() }; for ( ; rit != ovKeys.rend(); ++rit ) { if ( *rit <= desiredOverviewFactor ) { - tableToQuery = mOverViews[ *rit ]; + tableToQuery = mOverViews[*rit]; // This should really be: *= *rit * *rit; // but we are already approximating, let's get decent statistics statsRatio = 1; @@ -2503,42 +2383,35 @@ QgsRasterBandStats QgsPostgresRasterProvider::bandStatistics( int bandNo, Qgis:: } // Query the backend - QString where { extent.isEmpty() ? QString() : QStringLiteral( "WHERE %1 && ST_GeomFromText( %2, %3 )" ) - .arg( quotedIdentifier( mRasterColumn ) ) - .arg( quotedValue( extent.asWktPolygon() ) ) - .arg( mCrs.postgisSrid() ) }; + QString where { extent.isEmpty() ? QString() : QStringLiteral( "WHERE %1 && ST_GeomFromText( %2, %3 )" ).arg( quotedIdentifier( mRasterColumn ) ).arg( quotedValue( extent.asWktPolygon() ) ).arg( mCrs.postgisSrid() ) }; - if ( ! subsetString().isEmpty() ) + if ( !subsetString().isEmpty() ) { - where.append( where.isEmpty() ? QStringLiteral( "WHERE %1" ).arg( subsetString() ) : - QStringLiteral( " AND %1" ).arg( subsetString() ) ); + where.append( where.isEmpty() ? QStringLiteral( "WHERE %1" ).arg( subsetString() ) : QStringLiteral( " AND %1" ).arg( subsetString() ) ); } const QString sql = QStringLiteral( "SELECT (ST_SummaryStatsAgg( %1, %2, TRUE, %3 )).* " - "FROM %4 %5" ).arg( quotedIdentifier( mRasterColumn ) ) - .arg( bandNo ) - .arg( std::max( 0, std::min( 1, statsRatio ) ) ) - .arg( tableToQuery, where ); + "FROM %4 %5" ) + .arg( quotedIdentifier( mRasterColumn ) ) + .arg( bandNo ) + .arg( std::max( 0, std::min( 1, statsRatio ) ) ) + .arg( tableToQuery, where ); QgsPostgresResult result( connectionRO()->PQexec( sql ) ); if ( PGRES_TUPLES_OK == result.PQresultStatus() && result.PQntuples() == 1 ) { // count | sum | mean | stddev | min | max - rasterBandStats.sum = result.PQgetvalue( 0, 1 ).toDouble( ); - rasterBandStats.mean = result.PQgetvalue( 0, 2 ).toDouble( ); - rasterBandStats.stdDev = result.PQgetvalue( 0, 3 ).toDouble( ); - rasterBandStats.minimumValue = result.PQgetvalue( 0, 4 ).toDouble( ); - rasterBandStats.maximumValue = result.PQgetvalue( 0, 5 ).toDouble( ); + rasterBandStats.sum = result.PQgetvalue( 0, 1 ).toDouble(); + rasterBandStats.mean = result.PQgetvalue( 0, 2 ).toDouble(); + rasterBandStats.stdDev = result.PQgetvalue( 0, 3 ).toDouble(); + rasterBandStats.minimumValue = result.PQgetvalue( 0, 4 ).toDouble(); + rasterBandStats.maximumValue = result.PQgetvalue( 0, 5 ).toDouble(); rasterBandStats.range = rasterBandStats.maximumValue - rasterBandStats.minimumValue; } else { - QgsMessageLog::logMessage( tr( "Error fetching statistics for %1: %2\nSQL: %3" ) - .arg( mQuery ) - .arg( result.PQresultErrorMessage() ) - .arg( sql ), - QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "Error fetching statistics for %1: %2\nSQL: %3" ).arg( mQuery ).arg( result.PQresultErrorMessage() ).arg( sql ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Warning ); } QgsDebugMsgLevel( QStringLiteral( "************ STATS **************" ), 4 ); diff --git a/src/providers/postgres/raster/qgspostgresrasterprovider.h b/src/providers/postgres/raster/qgspostgresrasterprovider.h index 89ed64af85f8..17673de36f5e 100644 --- a/src/providers/postgres/raster/qgspostgresrasterprovider.h +++ b/src/providers/postgres/raster/qgspostgresrasterprovider.h @@ -29,18 +29,15 @@ */ class QgsPostgresRasterProvider : public QgsRasterDataProvider { - Q_OBJECT public: - QgsPostgresRasterProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); explicit QgsPostgresRasterProvider( const QgsPostgresRasterProvider &other, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); virtual ~QgsPostgresRasterProvider() override = default; public: - // QgsDataProvider interface Qgis::DataProviderFlags flags() const override; virtual QgsCoordinateReferenceSystem crs() const override; @@ -89,7 +86,6 @@ class QgsPostgresRasterProvider : public QgsRasterDataProvider static QgsPostgresPrimaryKeyType pkType( const QgsField &fld ); private: - bool mValid = false; QgsCoordinateReferenceSystem mCrs; //! Data source URI struct for this layer @@ -154,10 +150,10 @@ class QgsPostgresRasterProvider : public QgsRasterDataProvider QgsLayerMetadata mLayerMetadata; - QString mDetectedSrid; //!< Spatial reference detected in the database - QString mRequestedSrid; //!< Spatial reference requested in the uri - QgsPostgresConn *mConnectionRO = nullptr ; //!< Read-only database connection (initially) - QgsPostgresConn *mConnectionRW = nullptr ; //!< Read-write database connection (on update) + QString mDetectedSrid; //!< Spatial reference detected in the database + QString mRequestedSrid; //!< Spatial reference requested in the uri + QgsPostgresConn *mConnectionRO = nullptr; //!< Read-only database connection (initially) + QgsPostgresConn *mConnectionRW = nullptr; //!< Read-write database connection (on update) /** * Data type for the primary key @@ -238,27 +234,24 @@ class QgsPostgresRasterProvider : public QgsRasterDataProvider */ struct PGTypeInfo { - QString typeName; - QString typeType; - QString typeElem; - int typeLen; + QString typeName; + QString typeType; + QString typeElem; + int typeLen; }; QStringList parseUriKey( const QString &key ); - }; - -struct QgsPostgresRasterProviderException: public std::exception +struct QgsPostgresRasterProviderException : public std::exception { + QgsPostgresRasterProviderException( const QString &msg ); - QgsPostgresRasterProviderException( const QString &msg ); - - QString message; + QString message; }; -class QgsPostgresRasterProviderMetadata: public QgsProviderMetadata +class QgsPostgresRasterProviderMetadata : public QgsProviderMetadata { Q_OBJECT public: @@ -267,11 +260,10 @@ class QgsPostgresRasterProviderMetadata: public QgsProviderMetadata QVariantMap decodeUri( const QString &uri ) const override; QgsPostgresRasterProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; QString encodeUri( const QVariantMap &parts ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; bool saveLayerMetadata( const QString &uri, const QgsLayerMetadata &metadata, QString &errorMessage ) override; QgsProviderMetadata::ProviderCapabilities providerCapabilities() const override; }; - #endif // QGSPOSTGRESRASTERPROVIDER_H diff --git a/src/providers/postgres/raster/qgspostgresrastershareddata.cpp b/src/providers/postgres/raster/qgspostgresrastershareddata.cpp index 66a912ec2bc6..4822a8fb9be1 100644 --- a/src/providers/postgres/raster/qgspostgresrastershareddata.cpp +++ b/src/providers/postgres/raster/qgspostgresrastershareddata.cpp @@ -49,22 +49,22 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::tiles( c // Create the index mSpatialIndexes.emplace( cacheKey, new QgsGenericSpatialIndex() ); mTiles.emplace( cacheKey, std::map>() ); - mLoadedIndexBounds[ cacheKey] = QgsGeometry(); + mLoadedIndexBounds[cacheKey] = QgsGeometry(); } // Now check if the requested extent was completely downloaded const QgsGeometry requestedRect { QgsGeometry::fromRect( request.extent ) }; // Fast track for first tile (where index is empty) - if ( mLoadedIndexBounds[ cacheKey ].isNull() ) + if ( mLoadedIndexBounds[cacheKey].isNull() ) { return fetchTilesIndexAndData( requestedRect, request ); } - else if ( ! mLoadedIndexBounds[ cacheKey].contains( requestedRect ) ) + else if ( !mLoadedIndexBounds[cacheKey].contains( requestedRect ) ) { // Fetch index - const QgsGeometry geomDiff { requestedRect.difference( mLoadedIndexBounds[ cacheKey ] ) }; - if ( ! fetchTilesIndex( geomDiff.isEmpty() ? requestedRect : geomDiff, request ) ) + const QgsGeometry geomDiff { requestedRect.difference( mLoadedIndexBounds[cacheKey] ) }; + if ( !fetchTilesIndex( geomDiff.isEmpty() ? requestedRect : geomDiff, request ) ) { return result; } @@ -74,16 +74,14 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::tiles( c QStringList missingTileIds; // Get intersecting tiles from the index - mSpatialIndexes[ cacheKey ]->intersects( request.extent, [ & ]( Tile * tilePtr ) -> bool - { + mSpatialIndexes[cacheKey]->intersects( request.extent, [&]( Tile *tilePtr ) -> bool { if ( tilePtr->data.size() == 0 ) { missingTileIds.push_back( QStringLiteral( "'%1'" ).arg( tilePtr->tileId ) ); } else { - result.tiles.push_back( TileBand - { + result.tiles.push_back( TileBand { tilePtr->tileId, tilePtr->srid, tilePtr->extent, @@ -103,29 +101,21 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::tiles( c } ); // Fetch missing tile data in one single query - if ( ! missingTileIds.isEmpty() ) + if ( !missingTileIds.isEmpty() ) { - const QString sql { QStringLiteral( "SELECT %1, ENCODE( ST_AsBinary( %2, TRUE ), 'hex') " "FROM %3 WHERE %4 %1 IN ( %5 )" ) - .arg( request.pk, - request.rasterColumn, - request.tableToQuery, - request.whereClause, - missingTileIds.join( ',' ) ) }; + .arg( request.pk, request.rasterColumn, request.tableToQuery, request.whereClause, missingTileIds.join( ',' ) ) }; QgsPostgresResult dataResult( request.conn->PQexec( sql ) ); if ( dataResult.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( QObject::tr( "Unable to get tile data.\nThe error message from the database was:\n%1.\nSQL: %2" ) - .arg( dataResult.PQresultErrorMessage(), - sql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QObject::tr( "Unable to get tile data.\nThe error message from the database was:\n%1.\nSQL: %2" ).arg( dataResult.PQresultErrorMessage(), sql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); } if ( dataResult.PQntuples() != missingTileIds.size() ) { - QgsMessageLog::logMessage( QObject::tr( "Missing tiles were not found while fetching tile data from backend.\nSQL: %1" ) - .arg( sql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QObject::tr( "Missing tiles were not found while fetching tile data from backend.\nSQL: %1" ).arg( sql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); } for ( int row = 0; row < dataResult.PQntuples(); ++row ) @@ -134,9 +124,7 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::tiles( c const TileIdType tileId { dataResult.PQgetvalue( row, 0 ) }; if ( tileId.isEmpty() ) { - QgsMessageLog::logMessage( QObject::tr( "Tile with ID (%1) is empty while fetching tile data from backend.\nSQL: %2" ) - .arg( dataResult.PQgetvalue( row, 0 ) ) - .arg( sql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QObject::tr( "Tile with ID (%1) is empty while fetching tile data from backend.\nSQL: %2" ).arg( dataResult.PQgetvalue( row, 0 ) ).arg( sql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); } int dataRead; @@ -144,19 +132,19 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::tiles( c Tile const *tilePtr { setTileData( cacheKey, tileId, QByteArray::fromRawData( reinterpret_cast( binaryData ), dataRead ) ) }; CPLFree( binaryData ); - if ( ! tilePtr ) + if ( !tilePtr ) { // This should never happen! QgsMessageLog::logMessage( QObject::tr( "Tile with ID (%1) could not be found in provider storage while fetching tile data " "from backend.\nSQL: %2" ) - .arg( tileId ) - .arg( sql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); - Q_ASSERT( tilePtr ); // Abort + .arg( tileId ) + .arg( sql ), + QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + Q_ASSERT( tilePtr ); // Abort } - else // Add to result + else // Add to result { - result.tiles.push_back( TileBand - { + result.tiles.push_back( TileBand { tilePtr->tileId, tilePtr->srid, tilePtr->extent, @@ -189,18 +177,17 @@ void QgsPostgresRasterSharedData::invalidateCache() QgsPostgresRasterSharedData::Tile const *QgsPostgresRasterSharedData::setTileData( const QString &cacheKey, TileIdType tileId, const QByteArray &data ) { - Q_ASSERT( ! data.isEmpty() ); - if ( mTiles.find( cacheKey ) == mTiles.end() || - mTiles[ cacheKey ].find( tileId ) == mTiles[ cacheKey ].end() ) + Q_ASSERT( !data.isEmpty() ); + if ( mTiles.find( cacheKey ) == mTiles.end() || mTiles[cacheKey].find( tileId ) == mTiles[cacheKey].end() ) { return nullptr; } - Tile *const tile { mTiles[ cacheKey ][ tileId ].get() }; + Tile *const tile { mTiles[cacheKey][tileId].get() }; const QVariantMap parsedData = QgsPostgresRasterUtils::parseWkb( data ); for ( int bandCnt = 1; bandCnt <= tile->numBands; ++bandCnt ) { - tile->data.emplace_back( parsedData[ QStringLiteral( "band%1" ).arg( bandCnt ) ].toByteArray() ); + tile->data.emplace_back( parsedData[QStringLiteral( "band%1" ).arg( bandCnt )].toByteArray() ); } return tile; } @@ -213,33 +200,27 @@ QString QgsPostgresRasterSharedData::keyFromRequest( const QgsPostgresRasterShar bool QgsPostgresRasterSharedData::fetchTilesIndex( const QgsGeometry &requestPolygon, const TilesRequest &request ) { const QString indexSql { QStringLiteral( "SELECT %1, (ST_Metadata( %2 )).* FROM %3 " - "WHERE %6 %2 && ST_GeomFromText( '%5', %4 )" ) - .arg( request.pk, - request.rasterColumn, - request.tableToQuery, - request.srid, - requestPolygon.asWkt(), - request.whereClause ) }; + "WHERE %6 %2 && ST_GeomFromText( '%5', %4 )" ) + .arg( request.pk, request.rasterColumn, request.tableToQuery, request.srid, requestPolygon.asWkt(), request.whereClause ) }; QgsPostgresResult result( request.conn->PQexec( indexSql ) ); if ( result.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( QObject::tr( "Error fetching tile index from backend.\nSQL: %1" ) - .arg( indexSql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QObject::tr( "Error fetching tile index from backend.\nSQL: %1" ).arg( indexSql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return false; } const QString cacheKey { keyFromRequest( request ) }; - if ( mLoadedIndexBounds[ cacheKey ].isNull() ) + if ( mLoadedIndexBounds[cacheKey].isNull() ) { - mLoadedIndexBounds[ cacheKey ] = requestPolygon; + mLoadedIndexBounds[cacheKey] = requestPolygon; } else { - mLoadedIndexBounds[ cacheKey ] = mLoadedIndexBounds[ cacheKey ].combine( requestPolygon ); + mLoadedIndexBounds[cacheKey] = mLoadedIndexBounds[cacheKey].combine( requestPolygon ); } QgsRectangle overallExtent; @@ -249,18 +230,18 @@ bool QgsPostgresRasterSharedData::fetchTilesIndex( const QgsGeometry &requestPol // rid | upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands const TileIdType tileId { result.PQgetvalue( i, 0 ) }; - if ( mTiles[ cacheKey ].find( tileId ) == mTiles[ cacheKey ].end() ) + if ( mTiles[cacheKey].find( tileId ) == mTiles[cacheKey].end() ) { const double upperleftx { result.PQgetvalue( i, 1 ).toDouble() }; const double upperlefty { result.PQgetvalue( i, 2 ).toDouble() }; - const long int tileWidth { result.PQgetvalue( i, 3 ).toLong( ) }; - const long int tileHeight { result.PQgetvalue( i, 4 ).toLong( ) }; - const double scalex { result.PQgetvalue( i, 5 ).toDouble( ) }; - const double scaley { result.PQgetvalue( i, 6 ).toDouble( ) }; - const double skewx { result.PQgetvalue( i, 7 ).toDouble( ) }; - const double skewy { result.PQgetvalue( i, 8 ).toDouble( ) }; - const int srid {result.PQgetvalue( i, 9 ).toInt() }; - const int numbands {result.PQgetvalue( i, 10 ).toInt() }; + const long int tileWidth { result.PQgetvalue( i, 3 ).toLong() }; + const long int tileHeight { result.PQgetvalue( i, 4 ).toLong() }; + const double scalex { result.PQgetvalue( i, 5 ).toDouble() }; + const double scaley { result.PQgetvalue( i, 6 ).toDouble() }; + const double skewx { result.PQgetvalue( i, 7 ).toDouble() }; + const double skewy { result.PQgetvalue( i, 8 ).toDouble() }; + const int srid { result.PQgetvalue( i, 9 ).toInt() }; + const int numbands { result.PQgetvalue( i, 10 ).toInt() }; double minY { upperlefty + tileHeight * scaley }; double maxY { upperlefty }; // Southing Y? @@ -268,43 +249,39 @@ bool QgsPostgresRasterSharedData::fetchTilesIndex( const QgsGeometry &requestPol { std::swap( minY, maxY ); } - const QgsRectangle extent( upperleftx, minY, upperleftx + tileWidth * scalex, maxY ); + const QgsRectangle extent( upperleftx, minY, upperleftx + tileWidth * scalex, maxY ); overallExtent.combineExtentWith( extent ); std::unique_ptr tile = std::make_unique( - tileId, - srid, - extent, - upperleftx, - maxY, - tileWidth, - tileHeight, - scalex, - scaley, - skewx, - skewy, - numbands - ); - mSpatialIndexes[ cacheKey ]->insert( tile.get(), tile->extent ); - mTiles[ cacheKey ][ tileId ] = std::move( tile ); - QgsDebugMsgLevel( QStringLiteral( "Tile added: %1, ID: %2" ) - .arg( cacheKey ) - .arg( tileId ), 3 ); + tileId, + srid, + extent, + upperleftx, + maxY, + tileWidth, + tileHeight, + scalex, + scaley, + skewx, + skewy, + numbands + ); + mSpatialIndexes[cacheKey]->insert( tile.get(), tile->extent ); + mTiles[cacheKey][tileId] = std::move( tile ); + QgsDebugMsgLevel( QStringLiteral( "Tile added: %1, ID: %2" ).arg( cacheKey ).arg( tileId ), 3 ); //qDebug() << "Tile added:" << cacheKey << " ID: " << tileId << "extent " << extent.toString( 4 ) << upperleftx << upperlefty << tileWidth << tileHeight << extent.width() << extent.height(); } else { - QgsDebugMsgLevel( QStringLiteral( "Tile already indexed: %1, ID: %2" ) - .arg( cacheKey ) - .arg( tileId ), 3 ); + QgsDebugMsgLevel( QStringLiteral( "Tile already indexed: %1, ID: %2" ).arg( cacheKey ).arg( tileId ), 3 ); } } // Include actual bounds if ( !overallExtent.isNull() ) { - mLoadedIndexBounds[ cacheKey ] = requestPolygon.combine( QgsGeometry::fromRect( overallExtent ) ); + mLoadedIndexBounds[cacheKey] = requestPolygon.combine( QgsGeometry::fromRect( overallExtent ) ); } return true; @@ -314,20 +291,14 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::fetchTil { QgsPostgresRasterSharedData::TilesResponse response; const QString indexSql { QStringLiteral( "SELECT %1, (ST_Metadata( %2 )).*, ENCODE( ST_AsBinary( %2, TRUE ), 'hex') FROM %3 " - "WHERE %6 %2 && ST_GeomFromText( '%5', %4 )" ) - .arg( request.pk, - request.rasterColumn, - request.tableToQuery, - request.srid, - requestPolygon.asWkt(), - request.whereClause ) }; + "WHERE %6 %2 && ST_GeomFromText( '%5', %4 )" ) + .arg( request.pk, request.rasterColumn, request.tableToQuery, request.srid, requestPolygon.asWkt(), request.whereClause ) }; QgsPostgresResult dataResult( request.conn->PQexec( indexSql ) ); if ( dataResult.PQresultStatus() != PGRES_TUPLES_OK ) { - QgsMessageLog::logMessage( QObject::tr( "Error fetching tile index from backend.\nSQL: %1" ) - .arg( indexSql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QObject::tr( "Error fetching tile index from backend.\nSQL: %1" ).arg( indexSql ), QObject::tr( "PostGIS" ), Qgis::MessageLevel::Critical ); return response; } @@ -339,18 +310,18 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::fetchTil // rid | upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands | data const TileIdType tileId { dataResult.PQgetvalue( row, 0 ) }; - if ( mTiles[ cacheKey ].find( tileId ) == mTiles[ cacheKey ].end() ) + if ( mTiles[cacheKey].find( tileId ) == mTiles[cacheKey].end() ) { const double upperleftx { dataResult.PQgetvalue( row, 1 ).toDouble() }; const double upperlefty { dataResult.PQgetvalue( row, 2 ).toDouble() }; - const long int tileWidth { dataResult.PQgetvalue( row, 3 ).toLong( ) }; - const long int tileHeight { dataResult.PQgetvalue( row, 4 ).toLong( ) }; - const double scalex { dataResult.PQgetvalue( row, 5 ).toDouble( ) }; - const double scaley { dataResult.PQgetvalue( row, 6 ).toDouble( ) }; - const double skewx { dataResult.PQgetvalue( row, 7 ).toDouble( ) }; - const double skewy { dataResult.PQgetvalue( row, 8 ).toDouble( ) }; - const int srid {dataResult.PQgetvalue( row, 9 ).toInt() }; - const int numbands {dataResult.PQgetvalue( row, 10 ).toInt() }; + const long int tileWidth { dataResult.PQgetvalue( row, 3 ).toLong() }; + const long int tileHeight { dataResult.PQgetvalue( row, 4 ).toLong() }; + const double scalex { dataResult.PQgetvalue( row, 5 ).toDouble() }; + const double scaley { dataResult.PQgetvalue( row, 6 ).toDouble() }; + const double skewx { dataResult.PQgetvalue( row, 7 ).toDouble() }; + const double skewy { dataResult.PQgetvalue( row, 8 ).toDouble() }; + const int srid { dataResult.PQgetvalue( row, 9 ).toInt() }; + const int numbands { dataResult.PQgetvalue( row, 10 ).toInt() }; double minY { upperlefty + tileHeight * scaley }; double maxY { upperlefty }; @@ -359,22 +330,22 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::fetchTil { std::swap( minY, maxY ); } - const QgsRectangle extent( upperleftx, minY, upperleftx + tileWidth * scalex, maxY ); + const QgsRectangle extent( upperleftx, minY, upperleftx + tileWidth * scalex, maxY ); std::unique_ptr tile = std::make_unique( - tileId, - srid, - extent, - upperleftx, - upperlefty, - tileWidth, - tileHeight, - scalex, - scaley, - skewx, - skewy, - numbands - ); + tileId, + srid, + extent, + upperleftx, + upperlefty, + tileWidth, + tileHeight, + scalex, + scaley, + skewx, + skewy, + numbands + ); int dataRead; GByte *binaryData { CPLHexToBinary( dataResult.PQgetvalue( row, 11 ).toLatin1().constData(), &dataRead ) }; @@ -382,12 +353,11 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::fetchTil CPLFree( binaryData ); for ( int bandCnt = 1; bandCnt <= tile->numBands; ++bandCnt ) { - tile->data.emplace_back( parsedData[ QStringLiteral( "band%1" ).arg( bandCnt ) ].toByteArray() ); + tile->data.emplace_back( parsedData[QStringLiteral( "band%1" ).arg( bandCnt )].toByteArray() ); } - mSpatialIndexes[ cacheKey ]->insert( tile.get(), tile->extent ); + mSpatialIndexes[cacheKey]->insert( tile.get(), tile->extent ); - response.tiles.push_back( TileBand - { + response.tiles.push_back( TileBand { tile->tileId, tile->srid, tile->extent, @@ -404,22 +374,18 @@ QgsPostgresRasterSharedData::TilesResponse QgsPostgresRasterSharedData::fetchTil response.extent.combineExtentWith( tile->extent ); - mTiles[ cacheKey ][ tileId ] = std::move( tile ); - QgsDebugMsgLevel( QStringLiteral( "Tile added: %1, ID: %2" ) - .arg( cacheKey ) - .arg( tileId ), 3 ); + mTiles[cacheKey][tileId] = std::move( tile ); + QgsDebugMsgLevel( QStringLiteral( "Tile added: %1, ID: %2" ).arg( cacheKey ).arg( tileId ), 3 ); //qDebug() << "Tile data added:" << cacheKey << " ID: " << tileId << "extent " << extent.toString( 4 ) << upperleftx << upperlefty << tileWidth << tileHeight << extent.width() << extent.height(); } else { - QgsDebugMsgLevel( QStringLiteral( "Tile and data already indexed: %1, ID: %2" ) - .arg( cacheKey ) - .arg( tileId ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Tile and data already indexed: %1, ID: %2" ).arg( cacheKey ).arg( tileId ), 2 ); } } // Include requested bounds - mLoadedIndexBounds[ cacheKey ] = requestPolygon; + mLoadedIndexBounds[cacheKey] = requestPolygon; return response; } @@ -438,7 +404,6 @@ QgsPostgresRasterSharedData::Tile::Tile( const QgsPostgresRasterSharedData::Tile , skewY( skewY ) , numBands( numBands ) { - } const QByteArray QgsPostgresRasterSharedData::Tile::bandData( int bandNo ) const diff --git a/src/providers/postgres/raster/qgspostgresrastershareddata.h b/src/providers/postgres/raster/qgspostgresrastershareddata.h index 12390b3f2cb7..cca894545cef 100644 --- a/src/providers/postgres/raster/qgspostgresrastershareddata.h +++ b/src/providers/postgres/raster/qgspostgresrastershareddata.h @@ -32,60 +32,58 @@ class QgsPostgresConn; */ class QgsPostgresRasterSharedData { - public: - //! Type for tile IDs, must be in sync with DB tile id extraction logic using TileIdType = QString; //! Tile data and metadata for a single band struct TileBand { - TileIdType tileId; - int srid; - QgsRectangle extent; - double upperLeftX; - double upperLeftY; - long int width; - long int height; - double scaleX; - double scaleY; - double skewX; - double skewY; - QByteArray data; + TileIdType tileId; + int srid; + QgsRectangle extent; + double upperLeftX; + double upperLeftY; + long int width; + long int height; + double scaleX; + double scaleY; + double skewX; + double skewY; + QByteArray data; }; //! A tiles request struct TilesRequest { - //! Band number - int bandNo; - QgsRectangle extent; - unsigned int overviewFactor; - //! PK - QString pk; - //! raster column - QString rasterColumn; - //! table name - QString tableToQuery; - //! SRID - QString srid; - //! where clause - QString whereClause; - //! RO DB connection - QgsPostgresConn *conn; + //! Band number + int bandNo; + QgsRectangle extent; + unsigned int overviewFactor; + //! PK + QString pk; + //! raster column + QString rasterColumn; + //! table name + QString tableToQuery; + //! SRID + QString srid; + //! where clause + QString whereClause; + //! RO DB connection + QgsPostgresConn *conn; }; //! A tiles response struct TilesResponse { - //! Extent of the tiles in the response - QgsRectangle extent; - //! Tiles data - QList tiles; + //! Extent of the tiles in the response + QgsRectangle extent; + //! Tiles data + QList tiles; }; - ~QgsPostgresRasterSharedData( ); + ~QgsPostgresRasterSharedData(); /** * Returns tiles (possibly with NULL data) for a given \a request @@ -101,7 +99,6 @@ class QgsPostgresRasterSharedData static QString keyFromRequest( const TilesRequest &request ); private: - //! Protect access to tiles QMutex mMutex; @@ -110,18 +107,7 @@ class QgsPostgresRasterSharedData */ struct Tile { - Tile( TileIdType tileId, - int srid, - QgsRectangle extent, - double upperLeftX, - double upperLeftY, - long int width, - long int height, - double scaleX, - double scaleY, - double skewX, - double skewY, - int numBands ); + Tile( TileIdType tileId, int srid, QgsRectangle extent, double upperLeftX, double upperLeftY, long int width, long int height, double scaleX, double scaleY, double skewX, double skewY, int numBands ); TileIdType tileId; int srid; @@ -130,7 +116,7 @@ class QgsPostgresRasterSharedData double upperLeftY; long int width; long int height; - double scaleX ; + double scaleX; double scaleY; double skewX; double skewY; @@ -142,11 +128,9 @@ class QgsPostgresRasterSharedData const QByteArray bandData( int bandNo ) const; private: - std::vector data; friend class QgsPostgresRasterSharedData; - }; bool fetchTilesData( unsigned int overviewFactor, const QList &tileIds ); @@ -160,14 +144,13 @@ class QgsPostgresRasterSharedData * and the where clause * \note cannot be a smart pointer because spatial index cannot be copied */ - std::map*> mSpatialIndexes; + std::map *> mSpatialIndexes; //! Memory manager for owned tiles (and for tileId access) std::map>> mTiles; //! Keeps track of loaded index bounds std::map mLoadedIndexBounds; - }; #endif // QGSPOSTGRESRASTERSHAREDDATA_H diff --git a/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.cpp b/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.cpp index 7486854e57c0..765cd298e092 100644 --- a/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.cpp +++ b/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.cpp @@ -22,7 +22,7 @@ QgsPostgresRasterTemporalSettingsWidget::QgsPostgresRasterTemporalSettingsWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent ) : QgsMapLayerConfigWidget( layer, canvas, parent ) - , mRasterLayer( qobject_cast< QgsRasterLayer* >( layer ) ) + , mRasterLayer( qobject_cast( layer ) ) { Q_ASSERT( mRasterLayer ); Q_ASSERT( mRasterLayer->dataProvider() ); @@ -34,13 +34,10 @@ QgsPostgresRasterTemporalSettingsWidget::QgsPostgresRasterTemporalSettingsWidget mPostgresRasterTemporalGroup->setVisible( true ); mPostgresRasterTemporalGroup->setChecked( false ); - mPostgresRasterTemporalFieldComboBox->setFilters( QgsFieldProxyModel::Filter::Date | - QgsFieldProxyModel::Filter::DateTime | - QgsFieldProxyModel::Filter::String ); + mPostgresRasterTemporalFieldComboBox->setFilters( QgsFieldProxyModel::Filter::Date | QgsFieldProxyModel::Filter::DateTime | QgsFieldProxyModel::Filter::String ); mPostgresRasterTemporalFieldComboBox->setAllowEmptyFieldName( true ); - connect( mPostgresRasterTemporalFieldComboBox, &QgsFieldComboBox::fieldChanged, this, [ = ]( const QString & fieldName ) - { - mPostgresRasterDefaultTime->setEnabled( ! fieldName.isEmpty() ); + connect( mPostgresRasterTemporalFieldComboBox, &QgsFieldComboBox::fieldChanged, this, [=]( const QString &fieldName ) { + mPostgresRasterDefaultTime->setEnabled( !fieldName.isEmpty() ); } ); mPostgresRasterDefaultTime->setAllowNull( true ); mPostgresRasterDefaultTime->setEmpty(); @@ -51,7 +48,7 @@ QgsPostgresRasterTemporalSettingsWidget::QgsPostgresRasterTemporalSettingsWidget void QgsPostgresRasterTemporalSettingsWidget::syncToLayer( QgsMapLayer *layer ) { - mRasterLayer = qobject_cast< QgsRasterLayer * >( layer ); + mRasterLayer = qobject_cast( layer ); const QgsFields fields { mRasterLayer->dataProvider()->fields() }; mPostgresRasterTemporalFieldComboBox->setFields( fields ); @@ -61,13 +58,13 @@ void QgsPostgresRasterTemporalSettingsWidget::syncToLayer( QgsMapLayer *layer ) if ( mRasterLayer->dataProvider()->uri().hasParam( QStringLiteral( "temporalFieldIndex" ) ) ) { bool ok; - const int fieldIdx { mRasterLayer->dataProvider()->uri().param( QStringLiteral( "temporalFieldIndex" ) ).toInt( &ok ) }; + const int fieldIdx { mRasterLayer->dataProvider()->uri().param( QStringLiteral( "temporalFieldIndex" ) ).toInt( &ok ) }; if ( ok && fields.exists( fieldIdx ) ) { mPostgresRasterTemporalGroup->setChecked( true ); mPostgresRasterTemporalFieldComboBox->setField( fields.field( fieldIdx ).name() ); - const QList< QgsDateTimeRange > allRanges = mRasterLayer->dataProvider()->temporalCapabilities()->allAvailableTemporalRanges(); + const QList allRanges = mRasterLayer->dataProvider()->temporalCapabilities()->allAvailableTemporalRanges(); if ( !allRanges.empty() && allRanges.size() < 50 ) { // if an appropriate number of unique ranges is known, show a combo box with these options instead of the free-form @@ -99,9 +96,7 @@ void QgsPostgresRasterTemporalSettingsWidget::syncToLayer( QgsMapLayer *layer ) void QgsPostgresRasterTemporalSettingsWidget::apply() { QgsDataSourceUri uri { mRasterLayer->dataProvider()->uri() }; - if ( mPostgresRasterTemporalGroup->isEnabled() && - mPostgresRasterTemporalGroup->isChecked() && - ! mPostgresRasterTemporalFieldComboBox->currentField().isEmpty() ) + if ( mPostgresRasterTemporalGroup->isEnabled() && mPostgresRasterTemporalGroup->isChecked() && !mPostgresRasterTemporalFieldComboBox->currentField().isEmpty() ) { const QString originaUri { uri.uri() }; const int fieldIdx { mRasterLayer->dataProvider()->fields().lookupField( mPostgresRasterTemporalFieldComboBox->currentField() ) }; @@ -123,7 +118,7 @@ void QgsPostgresRasterTemporalSettingsWidget::apply() { if ( mDefaultTimeComboBox->currentData().isValid() ) { - defaultDateTime = mDefaultTimeComboBox->currentData().value< QDateTime >(); + defaultDateTime = mDefaultTimeComboBox->currentData().value(); } } @@ -135,7 +130,7 @@ void QgsPostgresRasterTemporalSettingsWidget::apply() uri.setParam( QStringLiteral( "temporalDefaultTime" ), defaultDateTime.toString( Qt::DateFormat::ISODate ) ); } - if ( uri.uri( ) != originaUri ) + if ( uri.uri() != originaUri ) mRasterLayer->setDataSource( uri.uri(), mRasterLayer->name(), mRasterLayer->providerType(), QgsDataProvider::ProviderOptions() ); } } diff --git a/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.h b/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.h index 698de6792243..f5a519117af2 100644 --- a/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.h +++ b/src/providers/postgres/raster/qgspostgresrastertemporalsettingswidget.h @@ -36,9 +36,7 @@ class QgsPostgresRasterTemporalSettingsWidget : public QgsMapLayerConfigWidget, private slots: private: - QgsRasterLayer *mRasterLayer = nullptr; - }; class QgsPostgresRasterTemporalSettingsConfigWidgetFactory : public QgsMapLayerConfigWidgetFactory @@ -48,7 +46,6 @@ class QgsPostgresRasterTemporalSettingsConfigWidgetFactory : public QgsMapLayerC bool supportsLayer( QgsMapLayer *layer ) const override; ParentPage parentPage() const override; QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget *parent = nullptr ) const override; - }; #endif // QGSPOSTGRESRASTERTEMPORALSETTINGSWIDGET_H diff --git a/src/providers/postgres/raster/qgspostgresrasterutils.cpp b/src/providers/postgres/raster/qgspostgresrasterutils.cpp index 8e52626431b2..0968c5178ded 100644 --- a/src/providers/postgres/raster/qgspostgresrasterutils.cpp +++ b/src/providers/postgres/raster/qgspostgresrasterutils.cpp @@ -24,9 +24,7 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo const int minWkbSize { 61 }; if ( wkb.size() < minWkbSize ) { - QgsMessageLog::logMessage( QStringLiteral( "Wrong wkb size: min expected = %1, actual = %2" ) - .arg( minWkbSize ) - .arg( wkb.size() ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QStringLiteral( "Wrong wkb size: min expected = %1, actual = %2" ).arg( minWkbSize ).arg( wkb.size() ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return result; } @@ -47,29 +45,28 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo */ // Endianness - result[ QStringLiteral( "endianness" ) ] = static_cast( wkb[0] ); + result[QStringLiteral( "endianness" )] = static_cast( wkb[0] ); // NOTE: For now only little endian is supported // TODO: endianness - Q_ASSERT( result[ QStringLiteral( "endianness" ) ] == 1 ); - result[ QStringLiteral( "version" ) ] = *reinterpret_cast( &wkb.constData()[1] ); + Q_ASSERT( result[QStringLiteral( "endianness" )] == 1 ); + result[QStringLiteral( "version" )] = *reinterpret_cast( &wkb.constData()[1] ); const unsigned short int nBands { *reinterpret_cast( &wkb.constData()[3] ) }; - result[ QStringLiteral( "nBands" ) ] = nBands; - result[ QStringLiteral( "scaleX" ) ] = *reinterpret_cast( &wkb.constData()[5] ); - result[ QStringLiteral( "scaleY" ) ] = *reinterpret_cast( &wkb.constData()[13] ); - result[ QStringLiteral( "ipX" ) ] = *reinterpret_cast( &wkb.constData()[21] ); - result[ QStringLiteral( "ipY" ) ] = *reinterpret_cast( &wkb.constData()[29] ); - result[ QStringLiteral( "skewX" ) ] = *reinterpret_cast( &wkb.constData()[37] ); - result[ QStringLiteral( "skewY" ) ] = *reinterpret_cast( &wkb.constData()[45] ); - result[ QStringLiteral( "srid" ) ] = static_cast( *reinterpret_cast( &wkb.constData()[53] ) ); - result[ QStringLiteral( "width" ) ] = *reinterpret_cast( &wkb.constData()[57] ); - result[ QStringLiteral( "height" ) ] = *reinterpret_cast( &wkb.constData()[59] ); + result[QStringLiteral( "nBands" )] = nBands; + result[QStringLiteral( "scaleX" )] = *reinterpret_cast( &wkb.constData()[5] ); + result[QStringLiteral( "scaleY" )] = *reinterpret_cast( &wkb.constData()[13] ); + result[QStringLiteral( "ipX" )] = *reinterpret_cast( &wkb.constData()[21] ); + result[QStringLiteral( "ipY" )] = *reinterpret_cast( &wkb.constData()[29] ); + result[QStringLiteral( "skewX" )] = *reinterpret_cast( &wkb.constData()[37] ); + result[QStringLiteral( "skewY" )] = *reinterpret_cast( &wkb.constData()[45] ); + result[QStringLiteral( "srid" )] = static_cast( *reinterpret_cast( &wkb.constData()[53] ) ); + result[QStringLiteral( "width" )] = *reinterpret_cast( &wkb.constData()[57] ); + result[QStringLiteral( "height" )] = *reinterpret_cast( &wkb.constData()[59] ); // Band data starts at index 61 int offset = 61; - auto readBandHeader = [ & ]( ) - { - result[ QStringLiteral( "pxType" ) ] = *reinterpret_cast( &wkb.constData()[offset] ) & 0x0F; + auto readBandHeader = [&]() { + result[QStringLiteral( "pxType" )] = *reinterpret_cast( &wkb.constData()[offset] ) & 0x0F; /* | 0 'Bool1' // unsupported | 1 'Uint2' // unsupported @@ -88,87 +85,84 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo */ offset++; int pxSize = 0; // in bytes - switch ( result[ QStringLiteral( "pxType" ) ].toInt() ) + switch ( result[QStringLiteral( "pxType" )].toInt() ) { - case 3: // int8 + case 3: // int8 pxSize = 1; - result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast( &wkb.constData()[ offset ] ); + result[QStringLiteral( "nodata" )] = *reinterpret_cast( &wkb.constData()[offset] ); break; case 4: // uint8 - result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast( &wkb.constData()[ offset ] ); + result[QStringLiteral( "nodata" )] = *reinterpret_cast( &wkb.constData()[offset] ); pxSize = 1; break; case 5: // int16 - result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast( &wkb.constData()[ offset ] ); + result[QStringLiteral( "nodata" )] = *reinterpret_cast( &wkb.constData()[offset] ); pxSize = 2; break; case 6: // uint16 - result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast( &wkb.constData()[ offset ] ); + result[QStringLiteral( "nodata" )] = *reinterpret_cast( &wkb.constData()[offset] ); pxSize = 2; break; case 7: // int32 - result[ QStringLiteral( "nodata" ) ] = static_cast( *reinterpret_cast( &wkb.constData()[ offset ] ) ); + result[QStringLiteral( "nodata" )] = static_cast( *reinterpret_cast( &wkb.constData()[offset] ) ); pxSize = 4; break; case 8: // uint32 - result[ QStringLiteral( "nodata" ) ] = static_cast( *reinterpret_cast( &wkb.constData()[ offset ] ) ); + result[QStringLiteral( "nodata" )] = static_cast( *reinterpret_cast( &wkb.constData()[offset] ) ); pxSize = 4; break; - // Note: 9 is missing from the specs + // Note: 9 is missing from the specs case 10: // float 32 bit - result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast( &wkb.constData()[ offset ] ); + result[QStringLiteral( "nodata" )] = *reinterpret_cast( &wkb.constData()[offset] ); pxSize = 4; break; case 11: // double 64 bit - result[ QStringLiteral( "nodata" ) ] = *reinterpret_cast( &wkb.constData()[ offset ] ); + result[QStringLiteral( "nodata" )] = *reinterpret_cast( &wkb.constData()[offset] ); pxSize = 8; break; default: - result[ QStringLiteral( "nodata" ) ] = std::numeric_limits::min(); - QgsMessageLog::logMessage( QStringLiteral( "Unsupported pixel type: %1" ) - .arg( result[ QStringLiteral( "pxType" ) ].toInt() ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); - + result[QStringLiteral( "nodata" )] = std::numeric_limits::min(); + QgsMessageLog::logMessage( QStringLiteral( "Unsupported pixel type: %1" ).arg( result[QStringLiteral( "pxType" )].toInt() ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); } - result[ QStringLiteral( "pxSize" ) ] = pxSize; + result[QStringLiteral( "pxSize" )] = pxSize; offset += pxSize; // Init of band data - result[ QStringLiteral( "dataSize" ) ] = static_cast( pxSize ) * result[ QStringLiteral( "width" ) ].toUInt() * result[ QStringLiteral( "height" ) ].toUInt(); + result[QStringLiteral( "dataSize" )] = static_cast( pxSize ) * result[QStringLiteral( "width" )].toUInt() * result[QStringLiteral( "height" )].toUInt(); }; if ( static_cast( bandNo ) > nBands ) { - QgsMessageLog::logMessage( QStringLiteral( "Band number is not valid: %1 (nBands: %2" ) - .arg( bandNo ).arg( nBands ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QStringLiteral( "Band number is not valid: %1 (nBands: %2" ).arg( bandNo ).arg( nBands ), QStringLiteral( "PostGIS" ), Qgis::MessageLevel::Critical ); return result; } // Read bands (all bands if bandNo is 0) for ( unsigned int bandCnt = 1; bandCnt <= ( bandNo == 0 ? nBands : static_cast( bandNo ) ); ++bandCnt ) { - readBandHeader( ); + readBandHeader(); if ( bandNo == 0 || static_cast( bandNo ) == bandCnt ) { - result[ QStringLiteral( "band%1" ).arg( bandCnt )] = wkb.mid( offset, result[ QStringLiteral( "dataSize" ) ].toUInt() ); + result[QStringLiteral( "band%1" ).arg( bandCnt )] = wkb.mid( offset, result[QStringLiteral( "dataSize" )].toUInt() ); // Invert rows? - if ( result[ QStringLiteral( "scaleY" ) ].toDouble( ) > 0 ) + if ( result[QStringLiteral( "scaleY" )].toDouble() > 0 ) { - const unsigned int numRows { result[ QStringLiteral( "height" ) ].toUInt() }; - const auto rowSize { result[ QStringLiteral( "dataSize" ) ].toUInt() / numRows }; - const QByteArray &oldBa { result[ QStringLiteral( "band%1" ).arg( bandCnt )].toByteArray() }; + const unsigned int numRows { result[QStringLiteral( "height" )].toUInt() }; + const auto rowSize { result[QStringLiteral( "dataSize" )].toUInt() / numRows }; + const QByteArray &oldBa { result[QStringLiteral( "band%1" ).arg( bandCnt )].toByteArray() }; QByteArray ba; for ( qlonglong rowOffset = ( numRows - 1 ) * rowSize; rowOffset >= 0; rowOffset -= rowSize ) { ba.append( oldBa.mid( rowOffset, rowSize ) ); } - result[ QStringLiteral( "band%1" ).arg( bandCnt )] = ba; + result[QStringLiteral( "band%1" ).arg( bandCnt )] = ba; } } else { // Skip } - offset += result[ QStringLiteral( "dataSize" ) ].toUInt(); + offset += result[QStringLiteral( "dataSize" )].toUInt(); } return result; } diff --git a/src/providers/postgres/raster/qgspostgresrasterutils.h b/src/providers/postgres/raster/qgspostgresrasterutils.h index ab67fa7a5f9f..73d36a357834 100644 --- a/src/providers/postgres/raster/qgspostgresrasterutils.h +++ b/src/providers/postgres/raster/qgspostgresrasterutils.h @@ -23,14 +23,12 @@ //! Raster utility functions struct QgsPostgresRasterUtils { - - /** + /** * Parses a \a wkb raster hex and returns information as a variant map * for a particular \a bandNo or for all bands if bandNo is 0 * See: https://git.osgeo.org/gitea/postgis/postgis/src/branch/master/raster/doc/RFC2-WellKnownBinaryFormat */ - static QVariantMap parseWkb( const QByteArray &wkb, int bandNo = 0 ); - + static QVariantMap parseWkb( const QByteArray &wkb, int bandNo = 0 ); }; diff --git a/src/providers/spatialite/qgsspatialiteconnection.cpp b/src/providers/spatialite/qgsspatialiteconnection.cpp index b3f7f8c6eb7e..23067cfe6ec3 100644 --- a/src/providers/spatialite/qgsspatialiteconnection.cpp +++ b/src/providers/spatialite/qgsspatialiteconnection.cpp @@ -25,7 +25,7 @@ #include // atoi #ifdef _MSC_VER -#define strcasecmp(a,b) stricmp(a,b) +#define strcasecmp( a, b ) stricmp( a, b ) #endif const QString QgsSpatiaLiteConnection::SPATIALITE_ARRAY_PREFIX = QStringLiteral( "json" ); @@ -556,7 +556,7 @@ bool QgsSpatiaLiteConnection::checkVirtsGeometryColumns( sqlite3 *handle ) bool QgsSpatiaLiteConnection::isRasterlite1Datasource( sqlite3 *handle, const char *table ) { -// testing for RasterLite-1 datasources + // testing for RasterLite-1 datasources int ret; int i; char **results = nullptr; @@ -567,7 +567,7 @@ bool QgsSpatiaLiteConnection::isRasterlite1Datasource( sqlite3 *handle, const ch char sql[4258]; strncpy( table_raster, table, sizeof table_raster ); - table_raster[ sizeof table_raster - 1 ] = '\0'; + table_raster[sizeof table_raster - 1] = '\0'; const size_t len = strlen( table_raster ); if ( strlen( table_raster ) < 9 ) @@ -615,8 +615,8 @@ bool QgsSpatiaLiteConnection::isDeclaredHidden( sqlite3 *handle, const QString & return false; // checking if some Layer has been declared as HIDDEN const QString sql = QString( "SELECT hidden FROM geometry_columns_auth" - " WHERE f_table_name=%1 and f_geometry_column=%2" ).arg( QgsSqliteUtils::quotedString( table ), - QgsSqliteUtils::quotedString( geom ) ); + " WHERE f_table_name=%1 and f_geometry_column=%2" ) + .arg( QgsSqliteUtils::quotedString( table ), QgsSqliteUtils::quotedString( geom ) ); ret = sqlite3_get_table( handle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) @@ -650,9 +650,6 @@ bool QgsSpatiaLiteConnection::isDeclaredHidden( sqlite3 *handle, const QString & } - - - static void fcnRegexp( sqlite3_context *ctx, int /*argc*/, sqlite3_value *argv[] ) { const QRegularExpression re( reinterpret_cast( sqlite3_value_text( argv[0] ) ) ); @@ -665,9 +662,7 @@ static void fcnRegexp( sqlite3_context *ctx, int /*argc*/, sqlite3_value *argv[] } - - -QMap < QString, QgsSqliteHandle * > QgsSqliteHandle::sHandles; +QMap QgsSqliteHandle::sHandles; QMutex QgsSqliteHandle::sHandleMutex; @@ -714,8 +709,7 @@ QgsSqliteHandle *QgsSqliteHandle::openDb( const QString &dbPath, bool shared ) { // failure QgsDebugError( QStringLiteral( "Failure while connecting to: %1\n%2" ) - .arg( dbPath, - QString::fromUtf8( sqlite3_errmsg( database.get() ) ) ) ); + .arg( dbPath, QString::fromUtf8( sqlite3_errmsg( database.get() ) ) ) ); return nullptr; } @@ -731,7 +725,7 @@ QgsSqliteHandle *QgsSqliteHandle::openDb( const QString &dbPath, bool shared ) sqlite3_create_function( database.get(), "REGEXP", 2, SQLITE_UTF8, nullptr, fcnRegexp, nullptr, nullptr ); // activating Foreign Key constraints - ( void )sqlite3_exec( database.get(), "PRAGMA foreign_keys = 1", nullptr, nullptr, nullptr ); + ( void ) sqlite3_exec( database.get(), "PRAGMA foreign_keys = 1", nullptr, nullptr, nullptr ); QgsDebugMsgLevel( QStringLiteral( "Connection to the database was successful" ), 2 ); @@ -752,7 +746,7 @@ void QgsSqliteHandle::closeDb( QgsSqliteHandle *&handle ) else { const QMutexLocker locker( &sHandleMutex ); - QMap < QString, QgsSqliteHandle * >::iterator i; + QMap::iterator i; for ( i = sHandles.begin(); i != sHandles.end() && i.value() != handle; ++i ) ; diff --git a/src/providers/spatialite/qgsspatialiteconnection.h b/src/providers/spatialite/qgsspatialiteconnection.h index ec7cf2685e93..e6874e0e2a74 100644 --- a/src/providers/spatialite/qgsspatialiteconnection.h +++ b/src/providers/spatialite/qgsspatialiteconnection.h @@ -43,14 +43,14 @@ class QgsSpatiaLiteConnection : public QObject typedef struct TableEntry { - TableEntry( const QString &_tableName, const QString &_column, const QString &_type ) - : tableName( _tableName ) - , column( _column ) - , type( _type ) - {} - QString tableName; - QString column; - QString type; + TableEntry( const QString &_tableName, const QString &_column, const QString &_type ) + : tableName( _tableName ) + , column( _column ) + , type( _type ) + {} + QString tableName; + QString column; + QString type; } TableEntry; enum Error @@ -191,7 +191,7 @@ class QgsSqliteHandle QString mDbPath; bool mIsValid; - static QMap < QString, QgsSqliteHandle * > sHandles; + static QMap sHandles; static QMutex sHandleMutex; }; diff --git a/src/providers/spatialite/qgsspatialiteconnpool.cpp b/src/providers/spatialite/qgsspatialiteconnpool.cpp index e33d038e5f27..d0f788bcb4cf 100644 --- a/src/providers/spatialite/qgsspatialiteconnpool.cpp +++ b/src/providers/spatialite/qgsspatialiteconnpool.cpp @@ -23,12 +23,12 @@ QgsSpatiaLiteConnPool *QgsSpatiaLiteConnPool::sInstance = nullptr; QgsSpatiaLiteConnPool *QgsSpatiaLiteConnPool::instance() { - if ( ! sInstance ) + if ( !sInstance ) { static QMutex sMutex; QMutexLocker locker( &sMutex ); // cppcheck-suppress identicalInnerCondition - if ( ! sInstance ) + if ( !sInstance ) { sInstance = new QgsSpatiaLiteConnPool(); } diff --git a/src/providers/spatialite/qgsspatialiteconnpool.h b/src/providers/spatialite/qgsspatialiteconnpool.h index be3dc6d3e9da..98736ee4d73a 100644 --- a/src/providers/spatialite/qgsspatialiteconnpool.h +++ b/src/providers/spatialite/qgsspatialiteconnpool.h @@ -31,7 +31,7 @@ inline void qgsConnectionPool_ConnectionCreate( const QString &connInfo, QgsSqli inline void qgsConnectionPool_ConnectionDestroy( QgsSqliteHandle *c ) { - QgsSqliteHandle::closeDb( c ); // will delete itself + QgsSqliteHandle::closeDb( c ); // will delete itself } inline void qgsConnectionPool_InvalidateConnection( QgsSqliteHandle *c ) @@ -53,7 +53,8 @@ class QgsSpatiaLiteConnPoolGroup : public QObject, public QgsConnectionPoolGroup Q_OBJECT public: - explicit QgsSpatiaLiteConnPoolGroup( const QString &name ) : QgsConnectionPoolGroup( name ) { initTimer( this ); } + explicit QgsSpatiaLiteConnPoolGroup( const QString &name ) + : QgsConnectionPoolGroup( name ) { initTimer( this ); } protected slots: void handleConnectionExpired() { onConnectionExpired(); } @@ -62,13 +63,13 @@ class QgsSpatiaLiteConnPoolGroup : public QObject, public QgsConnectionPoolGroup protected: Q_DISABLE_COPY( QgsSpatiaLiteConnPoolGroup ) - }; //! SpatiaLite connection pool - singleton class QgsSpatiaLiteConnPool : public QgsConnectionPool { static QgsSpatiaLiteConnPool *sInstance; + public: static QgsSpatiaLiteConnPool *instance(); diff --git a/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp b/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp index cf4f5e66a4c0..7251ab7648b9 100644 --- a/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp +++ b/src/providers/spatialite/qgsspatialitedataitemguiprovider.cpp @@ -36,7 +36,7 @@ void QgsSpatiaLiteDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selection, QgsDataItemGuiContext context ) { - if ( QgsSLRootItem *rootItem = qobject_cast< QgsSLRootItem * >( item ) ) + if ( QgsSLRootItem *rootItem = qobject_cast( item ) ) { QAction *actionNew = new QAction( tr( "New Connection…" ), menu ); connect( actionNew, &QAction::triggered, this, [rootItem] { newConnection( rootItem ); } ); @@ -47,17 +47,14 @@ void QgsSpatiaLiteDataItemGuiProvider::populateContextMenu( QgsDataItem *item, Q menu->addAction( actionCreateDatabase ); } - if ( qobject_cast< QgsSLConnectionItem * >( item ) ) + if ( qobject_cast( item ) ) { - const QList< QgsSLConnectionItem * > slConnectionItems = QgsDataItem::filteredItems( selection ); + const QList slConnectionItems = QgsDataItem::filteredItems( selection ); QAction *actionDeleteConnection = new QAction( slConnectionItems.size() > 1 ? tr( "Remove Connections…" ) : tr( "Remove Connection…" ), menu ); - connect( actionDeleteConnection, &QAction::triggered, this, [slConnectionItems, context] - { - QgsDataItemGuiProviderUtils::deleteConnections( slConnectionItems, []( const QString & connectionName ) - { + connect( actionDeleteConnection, &QAction::triggered, this, [slConnectionItems, context] { + QgsDataItemGuiProviderUtils::deleteConnections( slConnectionItems, []( const QString &connectionName ) { QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "spatialite" ) ); - providerMetadata->deleteConnection( connectionName ); - }, context ); + providerMetadata->deleteConnection( connectionName ); }, context ); } ); menu->addAction( actionDeleteConnection ); } @@ -65,11 +62,9 @@ void QgsSpatiaLiteDataItemGuiProvider::populateContextMenu( QgsDataItem *item, Q bool QgsSpatiaLiteDataItemGuiProvider::deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context ) { - if ( QgsSLLayerItem *layerItem = qobject_cast< QgsSLLayerItem * >( item ) ) + if ( QgsSLLayerItem *layerItem = qobject_cast( item ) ) { - if ( QMessageBox::question( nullptr, QObject::tr( "Delete Object" ), - QObject::tr( "Are you sure you want to delete %1?" ).arg( layerItem->name() ), - QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) + if ( QMessageBox::question( nullptr, QObject::tr( "Delete Object" ), QObject::tr( "Are you sure you want to delete %1?" ).arg( layerItem->name() ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes ) return false; const QgsDataSourceUri uri( layerItem->uri() ); @@ -91,7 +86,7 @@ bool QgsSpatiaLiteDataItemGuiProvider::deleteLayer( QgsLayerItem *item, QgsDataI bool QgsSpatiaLiteDataItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataItemGuiContext ) { - if ( qobject_cast< QgsSLConnectionItem * >( item ) ) + if ( qobject_cast( item ) ) return true; return false; @@ -99,7 +94,7 @@ bool QgsSpatiaLiteDataItemGuiProvider::acceptDrop( QgsDataItem *item, QgsDataIte bool QgsSpatiaLiteDataItemGuiProvider::handleDrop( QgsDataItem *item, QgsDataItemGuiContext, const QMimeData *data, Qt::DropAction action ) { - if ( QgsSLConnectionItem *connItem = qobject_cast< QgsSLConnectionItem * >( item ) ) + if ( QgsSLConnectionItem *connItem = qobject_cast( item ) ) { return handleDropConnectionItem( connItem, data, action ); } @@ -120,20 +115,17 @@ void QgsSpatiaLiteDataItemGuiProvider::createDatabase( QgsDataItem *item ) const QgsSettings settings; const QString lastUsedDir = settings.value( QStringLiteral( "UI/lastSpatiaLiteDir" ), QDir::homePath() ).toString(); - QString filename = QFileDialog::getSaveFileName( nullptr, tr( "New SpatiaLite Database File" ), - lastUsedDir, - tr( "SpatiaLite" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db)" ); + QString filename = QFileDialog::getSaveFileName( nullptr, tr( "New SpatiaLite Database File" ), lastUsedDir, tr( "SpatiaLite" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db)" ); if ( filename.isEmpty() ) return; - filename = QgsFileUtils::ensureFileNameHasExtension( filename, QStringList() << QStringLiteral( "sqlite" ) << QStringLiteral( "db" ) << QStringLiteral( "sqlite3" ) - << QStringLiteral( "db3" ) << QStringLiteral( "s3db" ) ); + filename = QgsFileUtils::ensureFileNameHasExtension( filename, QStringList() << QStringLiteral( "sqlite" ) << QStringLiteral( "db" ) << QStringLiteral( "sqlite3" ) << QStringLiteral( "db3" ) << QStringLiteral( "s3db" ) ); QString errCause; if ( SpatiaLiteUtils::createDb( filename, errCause ) ) { QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "spatialite" ) ); - std::unique_ptr< QgsSpatiaLiteProviderConnection > providerConnection( qgis::down_cast( providerMetadata->createConnection( QStringLiteral( "dbname='%1'" ).arg( filename ), QVariantMap() ) ) ); + std::unique_ptr providerConnection( qgis::down_cast( providerMetadata->createConnection( QStringLiteral( "dbname='%1'" ).arg( filename ), QVariantMap() ) ) ); if ( providerConnection ) { const QFileInfo fi( filename ); @@ -181,19 +173,17 @@ bool QgsSpatiaLiteDataItemGuiProvider::handleDropConnectionItem( QgsSLConnection destUri.setDataSource( QString(), u.name, srcLayer->geometryType() != Qgis::GeometryType::Null ? QStringLiteral( "geom" ) : QString() ); QgsDebugMsgLevel( "URI " + destUri.uri(), 2 ); - std::unique_ptr< QgsVectorLayerExporterTask > exportTask( new QgsVectorLayerExporterTask( srcLayer, destUri.uri(), QStringLiteral( "spatialite" ), srcLayer->crs(), QVariantMap(), owner ) ); + std::unique_ptr exportTask( new QgsVectorLayerExporterTask( srcLayer, destUri.uri(), QStringLiteral( "spatialite" ), srcLayer->crs(), QVariantMap(), owner ) ); // when export is successful: - connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, connItem, [ = ]() - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::exportComplete, connItem, [=]() { // this is gross - TODO - find a way to get access to messageBar from data items QMessageBox::information( nullptr, tr( "Import to SpatiaLite database" ), tr( "Import was successful." ) ); connItem->refresh(); } ); // when an error occurs: - connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, connItem, [ = ]( Qgis::VectorExportResult error, const QString & errorMessage ) - { + connect( exportTask.get(), &QgsVectorLayerExporterTask::errorOccurred, connItem, [=]( Qgis::VectorExportResult error, const QString &errorMessage ) { if ( error != Qgis::VectorExportResult::UserCanceled ) { QgsMessageOutput *output = QgsMessageOutput::createMessageOutput(); diff --git a/src/providers/spatialite/qgsspatialitedataitemguiprovider.h b/src/providers/spatialite/qgsspatialitedataitemguiprovider.h index 6b1f824e9179..a9f44cd47b48 100644 --- a/src/providers/spatialite/qgsspatialitedataitemguiprovider.h +++ b/src/providers/spatialite/qgsspatialitedataitemguiprovider.h @@ -25,11 +25,9 @@ class QgsSpatiaLiteDataItemGuiProvider : public QObject, public QgsDataItemGuiPr { Q_OBJECT public: - QString name() override { return QStringLiteral( "spatialite" ); } - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; bool deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context ) override; diff --git a/src/providers/spatialite/qgsspatialitedataitems.cpp b/src/providers/spatialite/qgsspatialitedataitems.cpp index 52e804e35bbb..ad24bff1aeb2 100644 --- a/src/providers/spatialite/qgsspatialitedataitems.cpp +++ b/src/providers/spatialite/qgsspatialitedataitems.cpp @@ -306,9 +306,6 @@ bool QgsSLConnectionItem::layerCollection() const QVector QgsSLLayerItem::createChildren() { QVector children; - children.push_back( new QgsFieldsItem( this, - path() + QStringLiteral( "/columns/ " ), - uri(), - QStringLiteral( "spatialite" ), QString(), name() ) ); + children.push_back( new QgsFieldsItem( this, path() + QStringLiteral( "/columns/ " ), uri(), QStringLiteral( "spatialite" ), QString(), name() ) ); return children; } diff --git a/src/providers/spatialite/qgsspatialitedataitems.h b/src/providers/spatialite/qgsspatialitedataitems.h index 95402d456660..c682b242dfae 100644 --- a/src/providers/spatialite/qgsspatialitedataitems.h +++ b/src/providers/spatialite/qgsspatialitedataitems.h @@ -32,7 +32,6 @@ class QgsSLLayerItem : public QgsLayerItem }; - class QgsSLConnectionItem : public QgsDataCollectionItem { Q_OBJECT @@ -76,7 +75,7 @@ namespace SpatiaLiteUtils { bool createDb( const QString &dbPath, QString &errCause ); bool deleteLayer( const QString &dbPath, const QString &tableName, QString &errCause ); -} +} // namespace SpatiaLiteUtils //! Provider for SpatiaLite root data item class QgsSpatiaLiteDataItemProvider : public QgsDataItemProvider diff --git a/src/providers/spatialite/qgsspatialiteexpressioncompiler.cpp b/src/providers/spatialite/qgsspatialiteexpressioncompiler.cpp index 455cea53eb48..ff8b1023627d 100644 --- a/src/providers/spatialite/qgsspatialiteexpressioncompiler.cpp +++ b/src/providers/spatialite/qgsspatialiteexpressioncompiler.cpp @@ -23,8 +23,7 @@ QgsSpatialiteExpressionCompiler::QgsSpatialiteExpressionCompiler( const QgsField QString QgsSpatialiteExpressionCompiler::sqlFunctionFromFunctionName( const QString &fnName ) const { - static const QMap FN_NAMES - { + static const QMap FN_NAMES { { "abs", "abs" }, { "char", "char" }, { "coalesce", "coalesce" }, @@ -39,5 +38,3 @@ QString QgsSpatialiteExpressionCompiler::sqlFunctionFromFunctionName( const QStr return FN_NAMES.value( fnName, QString() ); } - - diff --git a/src/providers/spatialite/qgsspatialiteexpressioncompiler.h b/src/providers/spatialite/qgsspatialiteexpressioncompiler.h index d86454420ae1..bdadecc0359f 100644 --- a/src/providers/spatialite/qgsspatialiteexpressioncompiler.h +++ b/src/providers/spatialite/qgsspatialiteexpressioncompiler.h @@ -23,13 +23,10 @@ class QgsSpatialiteExpressionCompiler : public QgsSQLiteExpressionCompiler { public: - explicit QgsSpatialiteExpressionCompiler( const QgsFields &fields, bool ignoreStaticNodes = false ); protected: - QString sqlFunctionFromFunctionName( const QString &fnName ) const override; - }; #endif // QGSSPATIALITEEXPRESSIONCOMPILER_H diff --git a/src/providers/spatialite/qgsspatialitefeatureiterator.cpp b/src/providers/spatialite/qgsspatialitefeatureiterator.cpp index b9de4bdf8351..9d5b7b6724f2 100644 --- a/src/providers/spatialite/qgsspatialitefeatureiterator.cpp +++ b/src/providers/spatialite/qgsspatialitefeatureiterator.cpp @@ -31,9 +31,8 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ) : QgsAbstractFeatureIteratorFromSource( source, ownSource, request ) { - mSqliteHandle = source->transactionHandle(); - if ( ! mSqliteHandle ) + if ( !mSqliteHandle ) { mHandle = QgsSpatiaLiteConnPool::instance()->acquireConnection( mSource->mSqlitePath, request.timeout(), request.requestMayBeNested() ); if ( mHandle ) @@ -89,7 +88,7 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature { // some kind of MBR spatial filtering is required whereClause = whereClauseRect(); - if ( ! whereClause.isEmpty() ) + if ( !whereClause.isEmpty() ) { whereClauses.append( whereClause ); } @@ -98,7 +97,7 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature if ( !mSource->mSubsetString.isEmpty() ) { whereClause = "( " + mSource->mSubsetString + ')'; - if ( ! whereClause.isEmpty() ) + if ( !whereClause.isEmpty() ) { whereClauses.append( whereClause ); } @@ -107,7 +106,7 @@ QgsSpatiaLiteFeatureIterator::QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeature if ( request.filterType() == Qgis::FeatureRequestFilterType::Fid ) { whereClause = whereClauseFid(); - if ( ! whereClause.isEmpty() ) + if ( !whereClause.isEmpty() ) { whereClauses.append( whereClause ); } @@ -461,18 +460,14 @@ QString QgsSpatiaLiteFeatureIterator::whereClauseRect() mbrFilter += QStringLiteral( "ymax >= %1" ).arg( qgsDoubleToString( mFilterRect.yMinimum() ) ); QString idxName = QStringLiteral( "idx_%1_%2" ).arg( mSource->mIndexTable, mSource->mIndexGeometry ); whereClause += QStringLiteral( "%1 IN (SELECT pkid FROM %2 WHERE %3)" ) - .arg( mSource->mViewBased ? quotedPrimaryKey() : QStringLiteral( "ROWID" ), - QgsSqliteUtils::quotedIdentifier( idxName ), - mbrFilter ); + .arg( mSource->mViewBased ? quotedPrimaryKey() : QStringLiteral( "ROWID" ), QgsSqliteUtils::quotedIdentifier( idxName ), mbrFilter ); } else if ( mSource->mSpatialIndexMbrCache ) { // using the MbrCache spatial index QString idxName = QStringLiteral( "cache_%1_%2" ).arg( mSource->mIndexTable, mSource->mIndexGeometry ); whereClause += QStringLiteral( "%1 IN (SELECT rowid FROM %2 WHERE mbr = FilterMbrIntersects(%3))" ) - .arg( mSource->mViewBased ? quotedPrimaryKey() : QStringLiteral( "ROWID" ), - QgsSqliteUtils::quotedIdentifier( idxName ), - mbr( mFilterRect ) ); + .arg( mSource->mViewBased ? quotedPrimaryKey() : QStringLiteral( "ROWID" ), QgsSqliteUtils::quotedIdentifier( idxName ), mbr( mFilterRect ) ); } else { @@ -495,10 +490,7 @@ QString QgsSpatiaLiteFeatureIterator::whereClauseRect() QString QgsSpatiaLiteFeatureIterator::mbr( const QgsRectangle &rect ) { return QStringLiteral( "%1, %2, %3, %4" ) - .arg( qgsDoubleToString( rect.xMinimum() ), - qgsDoubleToString( rect.yMinimum() ), - qgsDoubleToString( rect.xMaximum() ), - qgsDoubleToString( rect.yMaximum() ) ); + .arg( qgsDoubleToString( rect.xMinimum() ), qgsDoubleToString( rect.yMinimum() ), qgsDoubleToString( rect.xMaximum() ), qgsDoubleToString( rect.yMaximum() ) ); } @@ -506,8 +498,7 @@ QString QgsSpatiaLiteFeatureIterator::fieldName( const QgsField &fld ) { QString fieldname = QgsSqliteUtils::quotedIdentifier( fld.name() ); const QString type = fld.typeName().toLower(); - if ( type.contains( QLatin1String( "geometry" ) ) || type.contains( QLatin1String( "point" ) ) || - type.contains( QLatin1String( "line" ) ) || type.contains( QLatin1String( "polygon" ) ) ) + if ( type.contains( QLatin1String( "geometry" ) ) || type.contains( QLatin1String( "point" ) ) || type.contains( QLatin1String( "line" ) ) || type.contains( QLatin1String( "polygon" ) ) ) { fieldname = QStringLiteral( "AsText(%1)" ).arg( fieldname ); } @@ -628,7 +619,7 @@ QVariant QgsSpatiaLiteFeatureIterator::getFeatureAttribute( sqlite3_stmt *stmt, { // assume arrays are stored as JSON QVariant result = QVariant( QgsJsonUtils::parseArray( txt, subType ) ); - if ( ! result.convert( static_cast( type ) ) ) + if ( !result.convert( static_cast( type ) ) ) { QgsDebugMsgLevel( QStringLiteral( "Could not convert JSON value to requested QVariant type" ).arg( txt ), 3 ); } @@ -665,7 +656,7 @@ void QgsSpatiaLiteFeatureIterator::getFeatureGeometry( sqlite3_stmt *stmt, int i int geom_size = 0; const void *blob = sqlite3_column_blob( stmt, ic ); int blob_size = sqlite3_column_bytes( stmt, ic ); - QgsSpatiaLiteProvider::convertToGeosWKB( ( const unsigned char * )blob, blob_size, &featureGeom, &geom_size ); + QgsSpatiaLiteProvider::convertToGeosWKB( ( const unsigned char * ) blob, blob_size, &featureGeom, &geom_size ); if ( featureGeom ) { QgsGeometry g; diff --git a/src/providers/spatialite/qgsspatialitefeatureiterator.h b/src/providers/spatialite/qgsspatialitefeatureiterator.h index 1e0beaea9637..6c4a75dbf082 100644 --- a/src/providers/spatialite/qgsspatialitefeatureiterator.h +++ b/src/providers/spatialite/qgsspatialitefeatureiterator.h @@ -29,7 +29,7 @@ extern "C" class QgsSqliteHandle; class QgsSpatiaLiteProvider; -class QgsSpatiaLiteFeatureSource final: public QgsAbstractFeatureSource +class QgsSpatiaLiteFeatureSource final : public QgsAbstractFeatureSource { public: explicit QgsSpatiaLiteFeatureSource( const QgsSpatiaLiteProvider *p ); @@ -59,7 +59,7 @@ class QgsSpatiaLiteFeatureSource final: public QgsAbstractFeatureSource friend class QgsSpatiaLiteExpressionCompiler; }; -class QgsSpatiaLiteFeatureIterator final: public QgsAbstractFeatureIteratorFromSource +class QgsSpatiaLiteFeatureIterator final : public QgsAbstractFeatureIteratorFromSource { public: QgsSpatiaLiteFeatureIterator( QgsSpatiaLiteFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ); @@ -69,12 +69,10 @@ class QgsSpatiaLiteFeatureIterator final: public QgsAbstractFeatureIteratorFromS bool close() override; protected: - bool fetchFeature( QgsFeature &feature ) override; bool nextFeatureFilterExpression( QgsFeature &f ) override; private: - QString whereClauseRect(); QString whereClauseFid(); QString whereClauseFids(); @@ -113,7 +111,7 @@ class QgsSpatiaLiteFeatureIterator final: public QgsAbstractFeatureIteratorFromS QgsRectangle mFilterRect; QgsCoordinateTransform mTransform; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; // Last prepared sql statement for logging purposes QString mLastSql; diff --git a/src/providers/spatialite/qgsspatialiteprovider.cpp b/src/providers/spatialite/qgsspatialiteprovider.cpp index cad1ece5b1d5..f38d3a7d2065 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.cpp +++ b/src/providers/spatialite/qgsspatialiteprovider.cpp @@ -106,7 +106,8 @@ bool QgsSpatiaLiteProvider::convertField( QgsField &field ) QgsField subField = field; subField.setType( field.subType() ); subField.setSubType( QMetaType::Type::UnknownType ); - if ( !convertField( subField ) ) return false; + if ( !convertField( subField ) ) + return false; fieldType = QgsSpatiaLiteConnection::SPATIALITE_ARRAY_PREFIX + subField.typeName() + QgsSpatiaLiteConnection::SPATIALITE_ARRAY_SUFFIX; fieldSize = subField.length(); fieldPrec = subField.precision(); @@ -130,15 +131,7 @@ bool QgsSpatiaLiteProvider::convertField( QgsField &field ) } - -Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap *oldToNewAttrIdxMap, - QString *errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap *oldToNewAttrIdxMap, QString *errorMessage, const QMap *options ) { Q_UNUSED( options ) @@ -226,7 +219,7 @@ Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString try { - int ret = exec_sql( sqliteHandle, "BEGIN", uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + int ret = exec_sql( sqliteHandle, "BEGIN", uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) throw SLException( errMsg ); @@ -236,27 +229,24 @@ Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString { // delete the table if exists and the related entry in geometry_columns, then re-create it sql = QStringLiteral( "DROP TABLE IF EXISTS %1" ) - .arg( QgsSqliteUtils::quotedIdentifier( tableName ) ); + .arg( QgsSqliteUtils::quotedIdentifier( tableName ) ); - ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) throw SLException( errMsg ); sql = QStringLiteral( "DELETE FROM geometry_columns WHERE upper(f_table_name) = upper(%1)" ) - .arg( QgsSqliteUtils::quotedString( tableName ) ); + .arg( QgsSqliteUtils::quotedString( tableName ) ); - ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) throw SLException( errMsg ); } sql = QStringLiteral( "CREATE TABLE %1 (%2 %3 PRIMARY KEY%4)" ) - .arg( QgsSqliteUtils::quotedIdentifier( tableName ), - QgsSqliteUtils::quotedIdentifier( primaryKey ), - primaryKeyType, - primaryKeyType == QLatin1String( "INTEGER" ) ? QStringLiteral( " AUTOINCREMENT" ) : QString() ); + .arg( QgsSqliteUtils::quotedIdentifier( tableName ), QgsSqliteUtils::quotedIdentifier( primaryKey ), primaryKeyType, primaryKeyType == QLatin1String( "INTEGER" ) ? QStringLiteral( " AUTOINCREMENT" ) : QString() ); - ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) throw SLException( errMsg ); @@ -328,13 +318,12 @@ Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString if ( !geometryType.isEmpty() ) { sql = QStringLiteral( "SELECT AddGeometryColumn(%1, %2, %3, %4, %5)" ) - .arg( QgsSqliteUtils::quotedString( tableName ), - QgsSqliteUtils::quotedString( geometryColumn ) ) - .arg( srid ) - .arg( QgsSqliteUtils::quotedString( geometryType ) ) - .arg( dim ); + .arg( QgsSqliteUtils::quotedString( tableName ), QgsSqliteUtils::quotedString( geometryColumn ) ) + .arg( srid ) + .arg( QgsSqliteUtils::quotedString( geometryType ) ) + .arg( dim ); - ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) throw SLException( errMsg ); } @@ -343,28 +332,25 @@ Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString geometryColumn = QString(); } - ret = exec_sql( sqliteHandle, "COMMIT", uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle, "COMMIT", uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) throw SLException( errMsg ); - } catch ( SLException &e ) { QgsDebugError( QStringLiteral( "creation of data source %1 failed. %2" ) - .arg( tableName, - e.errorMessage() ) - ); + .arg( tableName, e.errorMessage() ) + ); if ( errorMessage ) *errorMessage = QObject::tr( "creation of data source %1 failed. %2" ) - .arg( tableName, - e.errorMessage() ); + .arg( tableName, e.errorMessage() ); if ( toCommit ) { // ROLLBACK after some previous error - exec_sql( sqliteHandle, "ROLLBACK", uri, nullptr, QGS_QUERY_LOG_ORIGIN ); + exec_sql( sqliteHandle, "ROLLBACK", uri, nullptr, QGS_QUERY_LOG_ORIGIN ); } QgsSqliteHandle::closeDb( handle ); @@ -372,7 +358,7 @@ Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString } QgsSqliteHandle::closeDb( handle ); - QgsDebugMsgLevel( "layer " + tableName + " created.", 2 ); + QgsDebugMsgLevel( "layer " + tableName + " created.", 2 ); } // use the provider to edit the table @@ -385,7 +371,7 @@ Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString QgsDebugError( "The layer " + tableName + " just created is not valid or not supported by the provider." ); if ( errorMessage ) *errorMessage = QObject::tr( "loading of the layer %1 failed" ) - .arg( tableName ); + .arg( tableName ); delete provider; return Qgis::VectorExportResult::ErrorInvalidLayer; @@ -420,19 +406,13 @@ Qgis::VectorExportResult QgsSpatiaLiteProvider::createEmptyLayer( const QString QgsDebugError( "error creating field " + fld.name() + ": unsupported type" ); if ( errorMessage ) *errorMessage = QObject::tr( "unsupported type for field %1" ) - .arg( fld.name() ); + .arg( fld.name() ); delete provider; return Qgis::VectorExportResult::ErrorAttributeTypeUnsupported; } - QgsDebugMsgLevel( "creating field #" + QString::number( fldIdx ) + - " -> #" + QString::number( offset ) + - " name " + fld.name() + - " type " + QString( QVariant::typeToName( fld.type() ) ) + - " typename " + fld.typeName() + - " width " + QString::number( fld.length() ) + - " precision " + QString::number( fld.precision() ), 2 ); + QgsDebugMsgLevel( "creating field #" + QString::number( fldIdx ) + " -> #" + QString::number( offset ) + " name " + fld.name() + " type " + QString( QVariant::typeToName( fld.type() ) ) + " typename " + fld.typeName() + " width " + QString::number( fld.length() ) + " precision " + QString::number( fld.precision() ), 2 ); flist.append( fld ); if ( oldToNewAttrIdxMap ) @@ -502,30 +482,26 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider gaiaVectorLayerPtr lyr = nullptr; // Set special cases (views, queries, no geometry specified) - bool specialCase { mGeometryColumn.isEmpty() || - ( mQuery.startsWith( '(' ) &&mQuery.endsWith( ')' ) ) }; + bool specialCase { mGeometryColumn.isEmpty() || ( mQuery.startsWith( '(' ) && mQuery.endsWith( ')' ) ) }; // Normal case - if ( ! specialCase ) + if ( !specialCase ) { // Set pk to ROWID in case the pk passed in the URL is not usable - if ( mPrimaryKey.isEmpty() || ! tablePrimaryKeys( mTableName ).contains( mPrimaryKey ) ) + if ( mPrimaryKey.isEmpty() || !tablePrimaryKeys( mTableName ).contains( mPrimaryKey ) ) { mPrimaryKey = QStringLiteral( "ROWID" ); } // using v.4.0 Abstract Interface ret = true; - list = gaiaGetVectorLayersList( mSqliteHandle, - mTableName.toUtf8().constData(), - mGeometryColumn.toUtf8().constData(), - GAIA_VECTORS_LIST_OPTIMISTIC ); + list = gaiaGetVectorLayersList( mSqliteHandle, mTableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData(), GAIA_VECTORS_LIST_OPTIMISTIC ); if ( list ) lyr = list->First; ret = lyr && checkLayerTypeAbstractInterface( lyr ); QgsDebugMsgLevel( QStringLiteral( "Using checkLayerTypeAbstractInterface" ), 2 ); } - else // views, no geometry etc + else // views, no geometry etc { ret = checkLayerType(); } @@ -542,7 +518,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider // TODO: move after pk discovery is definitely done? mEnabledCapabilities = mPrimaryKey.isEmpty() ? Qgis::VectorProviderCapabilities() : ( Qgis::VectorProviderCapability::SelectAtId ); - if ( ( mTableBased || mViewBased ) && !mReadOnly ) + if ( ( mTableBased || mViewBased ) && !mReadOnly ) { // enabling editing only for Tables [excluding Views and VirtualShapes] mEnabledCapabilities |= Qgis::VectorProviderCapability::DeleteFeatures | Qgis::VectorProviderCapability::FastTruncate; @@ -558,7 +534,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider if ( lyr ) { // using the v.4.0 AbstractInterface - if ( !getGeometryDetailsAbstractInterface( lyr ) ) // gets srid and geometry type + if ( !getGeometryDetailsAbstractInterface( lyr ) ) // gets srid and geometry type { // the table is not a geometry table mNumberFeatures = 0; @@ -571,7 +547,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider // if DB has Z geometry we do NOT use the v.4.0 AbstractInterface as it does not retrieve Z extent data if ( lyr->GeometryType == GAIA_XY_Z || lyr->GeometryType == GAIA_XY_Z_M ) { - if ( !getTableSummary() ) // gets the extent and feature count + if ( !getTableSummary() ) // gets the extent and feature count { mNumberFeatures = 0; QgsDebugError( QStringLiteral( "Invalid SpatiaLite layer" ) ); @@ -581,7 +557,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider } else { - if ( !getTableSummaryAbstractInterface( lyr ) ) // gets the extent and feature count + if ( !getTableSummaryAbstractInterface( lyr ) ) // gets the extent and feature count { mNumberFeatures = 0; QgsDebugError( QStringLiteral( "Invalid SpatiaLite layer" ) ); @@ -598,7 +574,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider else // no v.4.0 AbstractInterface { // using the traditional methods - if ( !getGeometryDetails() ) // gets srid and geometry type + if ( !getGeometryDetails() ) // gets srid and geometry type { // the table is not a geometry table mNumberFeatures = 0; @@ -606,7 +582,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider closeDb(); return; } - if ( !getTableSummary() ) // gets the extent and feature count + if ( !getTableSummary() ) // gets the extent and feature count { mNumberFeatures = 0; QgsDebugError( QStringLiteral( "Invalid SpatiaLite layer" ) ); @@ -626,7 +602,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider } // Fallback to ROWID is pk is empty or not usable after fields configuration - if ( mTableBased && hasRowid() && ( mPrimaryKey.isEmpty() || ! tablePrimaryKeys( mTableName ).contains( mPrimaryKey ) ) ) + if ( mTableBased && hasRowid() && ( mPrimaryKey.isEmpty() || !tablePrimaryKeys( mTableName ).contains( mPrimaryKey ) ) ) { mPrimaryKey = QStringLiteral( "ROWID" ); } @@ -638,7 +614,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider setNativeTypes( QgsSpatiaLiteConnection::nativeTypes() ); // Update extent and feature count - if ( ! mSubsetString.isEmpty() ) + if ( !mSubsetString.isEmpty() ) getTableSummary(); mValid = true; @@ -649,7 +625,7 @@ QgsSpatiaLiteProvider::~QgsSpatiaLiteProvider() if ( mTransaction ) { QString errorMessage; - if ( ! mTransaction->rollback( errorMessage ) ) + if ( !mTransaction->rollback( errorMessage ) ) { QgsMessageLog::logMessage( tr( "Error closing transaction for %1" ).arg( mTableName ), tr( "SpatiaLite" ) ); } @@ -685,26 +661,16 @@ typedef QPair TypeSubType; static TypeSubType getVariantType( const QString &type ) { // making some assumptions in order to guess a more realistic type - if ( type == QLatin1String( "int" ) || - type == QLatin1String( "integer" ) || - type == QLatin1String( "integer64" ) || - type == QLatin1String( "bigint" ) || - type == QLatin1String( "smallint" ) || - type == QLatin1String( "tinyint" ) || - type == QLatin1String( "boolean" ) ) + if ( type == QLatin1String( "int" ) || type == QLatin1String( "integer" ) || type == QLatin1String( "integer64" ) || type == QLatin1String( "bigint" ) || type == QLatin1String( "smallint" ) || type == QLatin1String( "tinyint" ) || type == QLatin1String( "boolean" ) ) return TypeSubType( QMetaType::Type::LongLong, QMetaType::Type::UnknownType ); - else if ( type == QLatin1String( "real" ) || - type == QLatin1String( "double" ) || - type == QLatin1String( "double precision" ) || - type == QLatin1String( "float" ) ) + else if ( type == QLatin1String( "real" ) || type == QLatin1String( "double" ) || type == QLatin1String( "double precision" ) || type == QLatin1String( "float" ) ) return TypeSubType( QMetaType::Type::Double, QMetaType::Type::UnknownType ); else if ( type.startsWith( QgsSpatiaLiteConnection::SPATIALITE_ARRAY_PREFIX ) && type.endsWith( QgsSpatiaLiteConnection::SPATIALITE_ARRAY_SUFFIX ) ) { // New versions of OGR convert list types (StringList, IntegerList, Integer64List and RealList) // to JSON when it stores a Spatialite table. It sets the column type as JSONSTRINGLIST, // JSONINTEGERLIST, JSONINTEGER64LIST or JSONREALLIST - TypeSubType subType = getVariantType( type.mid( QgsSpatiaLiteConnection::SPATIALITE_ARRAY_PREFIX.length(), - type.length() - QgsSpatiaLiteConnection::SPATIALITE_ARRAY_PREFIX.length() - QgsSpatiaLiteConnection::SPATIALITE_ARRAY_SUFFIX.length() ) ); + TypeSubType subType = getVariantType( type.mid( QgsSpatiaLiteConnection::SPATIALITE_ARRAY_PREFIX.length(), type.length() - QgsSpatiaLiteConnection::SPATIALITE_ARRAY_PREFIX.length() - QgsSpatiaLiteConnection::SPATIALITE_ARRAY_SUFFIX.length() ) ); return TypeSubType( subType.first == QMetaType::Type::QString ? QMetaType::Type::QStringList : QMetaType::Type::QVariantList, subType.first ); } else if ( type == QLatin1String( "jsonarray" ) ) @@ -715,14 +681,13 @@ static TypeSubType getVariantType( const QString &type ) { return TypeSubType( QMetaType::Type::QByteArray, QMetaType::Type::UnknownType ); } - else if ( type == QLatin1String( "timestamp" ) || - type == QLatin1String( "datetime" ) ) + else if ( type == QLatin1String( "timestamp" ) || type == QLatin1String( "datetime" ) ) { - return TypeSubType( QMetaType::Type::QDateTime, QMetaType::Type::UnknownType ); + return TypeSubType( QMetaType::Type::QDateTime, QMetaType::Type::UnknownType ); } else if ( type == QLatin1String( "date" ) ) { - return TypeSubType( QMetaType::Type::QDate, QMetaType::Type::UnknownType ); + return TypeSubType( QMetaType::Type::QDate, QMetaType::Type::UnknownType ); } else // for sure any SQLite value can be represented as SQLITE_TEXT @@ -754,14 +719,12 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr { const char *type = "TEXT"; QMetaType::Type fieldType = QMetaType::Type::QString; // default: SQLITE_TEXT - if ( fld->IntegerValuesCount != 0 && fld->DoubleValuesCount == 0 && - fld->TextValuesCount == 0 && fld->BlobValuesCount == 0 ) + if ( fld->IntegerValuesCount != 0 && fld->DoubleValuesCount == 0 && fld->TextValuesCount == 0 && fld->BlobValuesCount == 0 ) { fieldType = QMetaType::Type::LongLong; type = "INTEGER"; } - if ( fld->DoubleValuesCount != 0 && fld->TextValuesCount == 0 && - fld->BlobValuesCount == 0 ) + if ( fld->DoubleValuesCount != 0 && fld->TextValuesCount == 0 && fld->BlobValuesCount == 0 ) { fieldType = QMetaType::Type::Double; type = "DOUBLE"; @@ -819,8 +782,7 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr } } - if ( pk.toInt() == 0 || ( type.compare( QLatin1String( "integer" ), Qt::CaseSensitivity::CaseInsensitive ) != 0 && - type.compare( QLatin1String( "bigint" ), Qt::CaseSensitivity::CaseInsensitive ) != 0 ) ) + if ( pk.toInt() == 0 || ( type.compare( QLatin1String( "integer" ), Qt::CaseSensitivity::CaseInsensitive ) != 0 && type.compare( QLatin1String( "bigint" ), Qt::CaseSensitivity::CaseInsensitive ) != 0 ) ) continue; if ( mPrimaryKeyAttrs.isEmpty() ) @@ -918,9 +880,7 @@ bool QgsSpatiaLiteProvider::versionIsAbove( sqlite3 *sqlite_handle, int major, i QString QgsSpatiaLiteProvider::tableSchemaCondition( const QgsDataSourceUri &dsUri ) { - return dsUri.schema().isEmpty() ? - QStringLiteral( "IS NULL" ) : - QStringLiteral( "= %1" ).arg( QgsSqliteUtils::quotedString( dsUri.schema( ) ) ); + return dsUri.schema().isEmpty() ? QStringLiteral( "IS NULL" ) : QStringLiteral( "= %1" ).arg( QgsSqliteUtils::quotedString( dsUri.schema() ) ); } void QgsSpatiaLiteProvider::fetchConstraints() @@ -952,7 +912,7 @@ void QgsSpatiaLiteProvider::fetchConstraints() uniqueFieldNames = QgsSqliteUtils::uniqueFields( mSqliteHandle, mTableName, errMsg ); } - QString sqlDef = QString::fromUtf8( results[ 1 ] ); + QString sqlDef = QString::fromUtf8( results[1] ); // extract definition const thread_local QRegularExpression re( QStringLiteral( R"raw(\((.+)\))raw" ), QRegularExpression::PatternOption::DotMatchesEverythingOption ); QRegularExpressionMatch match = re.match( sqlDef ); @@ -985,11 +945,10 @@ void QgsSpatiaLiteProvider::fetchConstraints() constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); if ( definition.contains( QLatin1String( "not null" ), Qt::CaseInsensitive ) || definition.contains( QLatin1String( "primary key" ), Qt::CaseInsensitive ) ) constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); - mAttributeFields[ fieldIdx ].setConstraints( constraints ); + mAttributeFields[fieldIdx].setConstraints( constraints ); } } } - } sqlite3_free_table( results ); @@ -998,9 +957,9 @@ void QgsSpatiaLiteProvider::fetchConstraints() QgsFieldConstraints constraints = mAttributeFields.at( fieldIdx ).constraints(); constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider ); constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); - mAttributeFields[ fieldIdx ].setConstraints( constraints ); + mAttributeFields[fieldIdx].setConstraints( constraints ); - if ( mAttributeFields[ fieldIdx ].name() == mPrimaryKey ) + if ( mAttributeFields[fieldIdx].name() == mPrimaryKey ) { QString sql = QStringLiteral( "SELECT sql FROM sqlite_master WHERE type = 'table' AND tbl_name like %1" ).arg( QgsSqliteUtils::quotedIdentifier( mTableName ) ); int ret = sqlite3_get_table( mSqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); @@ -1012,7 +971,7 @@ void QgsSpatiaLiteProvider::fetchConstraints() if ( rows >= 1 ) { - QString tableSql = QString::fromUtf8( results[ 1 ] ); + QString tableSql = QString::fromUtf8( results[1] ); QRegularExpression rx( QStringLiteral( "[(,]\\s*(?:%1|\"%1\"|`%1`)\\s+INTEGER PRIMARY KEY AUTOINCREMENT" ).arg( mPrimaryKey ), QRegularExpression::CaseInsensitiveOption ); if ( tableSql.contains( rx ) ) { @@ -1059,11 +1018,10 @@ void QgsSpatiaLiteProvider::insertDefaultValue( int fieldIndex, QString defaultV } } - if ( ! ok ) // Must be a SQL clause and not a literal + if ( !ok ) // Must be a SQL clause and not a literal { mDefaultValueClause.insert( fieldIndex, defaultVal ); } - } mDefaultValues.insert( fieldIndex, defaultVal ); } @@ -1094,11 +1052,7 @@ QVariant QgsSpatiaLiteProvider::defaultValue( int fieldId ) const resultVar = defaultVal; } - if ( mTransaction && - mAttributeFields.at( fieldId ).name() == mPrimaryKey && - mPrimaryKeyAutoIncrement && - mDefaultValues.value( fieldId, QString() ) == tr( "Autogenerate" ) && - providerProperty( EvaluateDefaultValues, false ).toBool() ) + if ( mTransaction && mAttributeFields.at( fieldId ).name() == mPrimaryKey && mPrimaryKeyAutoIncrement && mDefaultValues.value( fieldId, QString() ) == tr( "Autogenerate" ) && providerProperty( EvaluateDefaultValues, false ).toBool() ) { QString errorMessage; QVariant nextVal = QgsSqliteUtils::nextSequenceValue( sqliteHandle(), mTableName, errorMessage ); @@ -1118,15 +1072,14 @@ QVariant QgsSpatiaLiteProvider::defaultValue( int fieldId ) const QString QgsSpatiaLiteProvider::defaultValueClause( int fieldIndex ) const { - if ( ! mAttributeFields.exists( fieldIndex ) ) + if ( !mAttributeFields.exists( fieldIndex ) ) { return QString(); } if ( mAttributeFields.at( fieldIndex ).name() == mPrimaryKey && mPrimaryKeyAutoIncrement ) { - if ( mTransaction && - providerProperty( EvaluateDefaultValues, false ).toBool() ) + if ( mTransaction && providerProperty( EvaluateDefaultValues, false ).toBool() ) { return QString(); } @@ -1147,10 +1100,10 @@ void QgsSpatiaLiteProvider::handleError( const QString &sql, char *errorMessage, sqlite3_free( errorMessage ); } - if ( ! savepointId.isEmpty() ) + if ( !savepointId.isEmpty() ) { // ROLLBACK after some previous error - ( void )exec_sql( sqliteHandle(), QStringLiteral( "ROLLBACK TRANSACTION TO \"%1\"" ).arg( savepointId ), uri().uri(), nullptr, QGS_QUERY_LOG_ORIGIN ); + ( void ) exec_sql( sqliteHandle(), QStringLiteral( "ROLLBACK TRANSACTION TO \"%1\"" ).arg( savepointId ), uri().uri(), nullptr, QGS_QUERY_LOG_ORIGIN ); } } @@ -1158,7 +1111,7 @@ int QgsSpatiaLiteProvider::exec_sql( sqlite3 *handle, const QString &sql, const { QgsDatabaseQueryLogWrapper logWrapper( sql, uri, QStringLiteral( "spatialite" ), QStringLiteral( "QgsSpatiaLiteProvider" ), origin ); // Use transaction's handle (if any) - return sqlite3_exec( handle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg ); + return sqlite3_exec( handle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg ); } sqlite3 *QgsSpatiaLiteProvider::sqliteHandle() const @@ -1189,7 +1142,7 @@ void QgsSpatiaLiteProvider::loadFields() sql = QStringLiteral( "PRAGMA table_info(%1)" ).arg( QgsSqliteUtils::quotedIdentifier( mTableName ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -1207,8 +1160,7 @@ void QgsSpatiaLiteProvider::loadFields() continue; QString type = QString::fromUtf8( results[( i * columns ) + 2] ).toLower(); QString pk = results[( i * columns ) + 5]; - if ( pk.toInt() != 0 && ( type.compare( QLatin1String( "integer" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 || - type.compare( QLatin1String( "bigint" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 ) ) + if ( pk.toInt() != 0 && ( type.compare( QLatin1String( "integer" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 || type.compare( QLatin1String( "bigint" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 ) ) { // found a Primary Key column pkCount++; @@ -1248,10 +1200,10 @@ void QgsSpatiaLiteProvider::loadFields() { sql = QStringLiteral( "select * from %1 limit 1" ).arg( mQuery ); - if ( sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) + if ( sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) { // some error occurred - QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ), tr( "SpatiaLite" ) ); + QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ), tr( "SpatiaLite" ) ); return; } @@ -1311,14 +1263,14 @@ void QgsSpatiaLiteProvider::determineViewPrimaryKey() { QString sql = QString( "SELECT view_rowid" " FROM views_geometry_columns" - " WHERE upper(view_name) = upper(%1) and upper(view_geometry) = upper(%2)" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + " WHERE upper(view_name) = upper(%1) and upper(view_geometry) = upper(%2)" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); char **results = nullptr; int rows; int columns; char *errMsg = nullptr; - int ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + int ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK ) { if ( rows > 0 ) @@ -1341,23 +1293,20 @@ QStringList QgsSpatiaLiteProvider::tablePrimaryKeys( const QString &tableName ) int rows; int columns; char *errMsg = nullptr; - if ( sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) + if ( sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) { // some error occurred - QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ), - tr( "SpatiaLite" ) ); + QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ), tr( "SpatiaLite" ) ); } else { - int ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + int ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK ) { for ( int row = 1; row <= rows; ++row ) { QString type = QString::fromUtf8( results[( row * columns ) + 2] ).toLower(); - if ( QString::fromUtf8( results[row * columns + 5] ) == QChar( '1' ) && - ( type.compare( QLatin1String( "integer" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 || - type.compare( QLatin1String( "bigint" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 ) ) + if ( QString::fromUtf8( results[row * columns + 5] ) == QChar( '1' ) && ( type.compare( QLatin1String( "integer" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 || type.compare( QLatin1String( "bigint" ), Qt::CaseSensitivity::CaseInsensitive ) == 0 ) ) { result << QString::fromUtf8( results[row * columns + 1] ); } @@ -1384,9 +1333,9 @@ bool QgsSpatiaLiteProvider::hasTriggers() QString sql; sql = QStringLiteral( "SELECT * FROM sqlite_master WHERE type='trigger' AND tbl_name=%1" ) - .arg( QgsSqliteUtils::quotedIdentifier( mTableName ) ); + .arg( QgsSqliteUtils::quotedIdentifier( mTableName ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); sqlite3_free_table( results ); return ( ret == SQLITE_OK && rows > 0 ); } @@ -1399,7 +1348,7 @@ bool QgsSpatiaLiteProvider::hasRowid() // table without rowid column QString sql = QStringLiteral( "SELECT rowid FROM %1 WHERE 0" ).arg( QgsSqliteUtils::quotedIdentifier( mTableName ) ); char *errMsg = nullptr; - return exec_sql( sqliteHandle( ), sql, uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ) == SQLITE_OK; + return exec_sql( sqliteHandle(), sql, uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ) == SQLITE_OK; } @@ -1419,12 +1368,10 @@ QgsFeatureIterator QgsSpatiaLiteProvider::getFeatures( const QgsFeatureRequest & } -int QgsSpatiaLiteProvider::computeSizeFromGeosWKB2D( const unsigned char *blob, - int size, Qgis::WkbType type, int nDims, - int little_endian, int endian_arch ) +int QgsSpatiaLiteProvider::computeSizeFromGeosWKB2D( const unsigned char *blob, int size, Qgis::WkbType type, int nDims, int little_endian, int endian_arch ) { Q_UNUSED( size ) -// calculating the size required to store this WKB + // calculating the size required to store this WKB int rings; int points; int ib; @@ -1433,8 +1380,7 @@ int QgsSpatiaLiteProvider::computeSizeFromGeosWKB2D( const unsigned char *blob, if ( QgsWkbTypes::isMultiType( type ) ) { - gsize += computeSizeFromMultiWKB2D( p_in, nDims, little_endian, - endian_arch ); + gsize += computeSizeFromMultiWKB2D( p_in, nDims, little_endian, endian_arch ); } else { @@ -1508,12 +1454,9 @@ int QgsSpatiaLiteProvider::computeSizeFromGeosWKB2D( const unsigned char *blob, return gsize; } -int QgsSpatiaLiteProvider::computeSizeFromMultiWKB2D( const unsigned char *p_in, - int nDims, - int little_endian, - int endian_arch ) +int QgsSpatiaLiteProvider::computeSizeFromMultiWKB2D( const unsigned char *p_in, int nDims, int little_endian, int endian_arch ) { -// calculating the size required to store this WKB + // calculating the size required to store this WKB int entities; int type; int rings; @@ -1605,12 +1548,10 @@ int QgsSpatiaLiteProvider::computeSizeFromMultiWKB2D( const unsigned char *p_in, return size; } -int QgsSpatiaLiteProvider::computeSizeFromGeosWKB3D( const unsigned char *blob, - int size, Qgis::WkbType type, int nDims, - int little_endian, int endian_arch ) +int QgsSpatiaLiteProvider::computeSizeFromGeosWKB3D( const unsigned char *blob, int size, Qgis::WkbType type, int nDims, int little_endian, int endian_arch ) { Q_UNUSED( size ) -// calculating the size required to store this WKB + // calculating the size required to store this WKB int rings; int points; int ib; @@ -1619,8 +1560,7 @@ int QgsSpatiaLiteProvider::computeSizeFromGeosWKB3D( const unsigned char *blob, if ( QgsWkbTypes::isMultiType( type ) ) { - gsize += computeSizeFromMultiWKB3D( p_in, nDims, little_endian, - endian_arch ); + gsize += computeSizeFromMultiWKB3D( p_in, nDims, little_endian, endian_arch ); } else { @@ -1694,12 +1634,9 @@ int QgsSpatiaLiteProvider::computeSizeFromGeosWKB3D( const unsigned char *blob, return gsize; } -int QgsSpatiaLiteProvider::computeSizeFromMultiWKB3D( const unsigned char *p_in, - int nDims, - int little_endian, - int endian_arch ) +int QgsSpatiaLiteProvider::computeSizeFromMultiWKB3D( const unsigned char *p_in, int nDims, int little_endian, int endian_arch ) { -// calculating the size required to store this WKB + // calculating the size required to store this WKB int entities; Qgis::WkbType type; int rings; @@ -1713,7 +1650,7 @@ int QgsSpatiaLiteProvider::computeSizeFromMultiWKB3D( const unsigned char *p_in, size += 4; for ( ie = 0; ie < entities; ie++ ) { - type = static_cast< Qgis::WkbType >( gaiaImport32( p_in + 1, little_endian, endian_arch ) ); + type = static_cast( gaiaImport32( p_in + 1, little_endian, endian_arch ) ); p_in += 5; size += 5; switch ( QgsWkbTypes::geometryType( type ) ) @@ -1795,11 +1732,7 @@ int QgsSpatiaLiteProvider::computeSizeFromMultiWKB3D( const unsigned char *p_in, return size; } -void QgsSpatiaLiteProvider::convertFromGeosWKB( const unsigned char *blob, - int blob_size, - unsigned char **wkb, - int *geom_size, - int nDims ) +void QgsSpatiaLiteProvider::convertFromGeosWKB( const unsigned char *blob, int blob_size, unsigned char **wkb, int *geom_size, int nDims ) { // attempting to convert from 2D/3D GEOS own WKB Qgis::WkbType type; @@ -1816,7 +1749,7 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB( const unsigned char *blob, little_endian = GAIA_LITTLE_ENDIAN; else little_endian = GAIA_BIG_ENDIAN; - type = static_cast< Qgis::WkbType >( gaiaImport32( blob + 1, little_endian, endian_arch ) ); + type = static_cast( gaiaImport32( blob + 1, little_endian, endian_arch ) ); if ( QgsWkbTypes::hasZ( type ) || QgsWkbTypes::hasM( type ) ) gDims = 3; else if ( type != Qgis::WkbType::Unknown ) @@ -1837,37 +1770,27 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB( const unsigned char *blob, // we need creating a GAIA WKB if ( gDims == 3 ) - gsize = computeSizeFromGeosWKB3D( blob, blob_size, type, nDims, - little_endian, endian_arch ); + gsize = computeSizeFromGeosWKB3D( blob, blob_size, type, nDims, little_endian, endian_arch ); else - gsize = computeSizeFromGeosWKB2D( blob, blob_size, type, nDims, - little_endian, endian_arch ); + gsize = computeSizeFromGeosWKB2D( blob, blob_size, type, nDims, little_endian, endian_arch ); unsigned char *wkbGeom = new unsigned char[gsize]; memset( wkbGeom, '\0', gsize ); if ( gDims == 3 ) - convertFromGeosWKB3D( blob, blob_size, wkbGeom, gsize, nDims, - little_endian, endian_arch ); + convertFromGeosWKB3D( blob, blob_size, wkbGeom, gsize, nDims, little_endian, endian_arch ); else - convertFromGeosWKB2D( blob, blob_size, wkbGeom, gsize, nDims, - little_endian, endian_arch ); + convertFromGeosWKB2D( blob, blob_size, wkbGeom, gsize, nDims, little_endian, endian_arch ); *wkb = wkbGeom; *geom_size = gsize; } -void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, - int blob_size, - unsigned char *wkb, - int geom_size, - int nDims, - int little_endian, - int endian_arch ) +void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, int blob_size, unsigned char *wkb, int geom_size, int nDims, int little_endian, int endian_arch ) { Q_UNUSED( blob_size ) Q_UNUSED( geom_size ) -// attempting to convert from 2D GEOS own WKB + // attempting to convert from 2D GEOS own WKB int type; int entities; int rings; @@ -1879,8 +1802,8 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, unsigned char *p_out = wkb; double coord; -// building from GEOS 2D WKB - *p_out++ = 0x01; // little endian byte order + // building from GEOS 2D WKB + *p_out++ = 0x01; // little endian byte order type = gaiaImport32( blob + 1, little_endian, endian_arch ); switch ( type ) { @@ -2012,24 +1935,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, // setting Geometry values case GAIA_POINT: coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2042,24 +1965,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2079,24 +2002,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2129,24 +2052,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, } p_out += 4; coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2184,24 +2107,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2246,24 +2169,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2341,24 +2264,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, // setting sub-Geometry values case GAIA_POINT: coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2371,24 +2294,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2408,24 +2331,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2438,13 +2361,7 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, } } -void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, - int blob_size, - unsigned char *wkb, - int geom_size, - int nDims, - int little_endian, - int endian_arch ) +void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, int blob_size, unsigned char *wkb, int geom_size, int nDims, int little_endian, int endian_arch ) { Q_UNUSED( blob_size ) Q_UNUSED( geom_size ) @@ -2460,9 +2377,9 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, unsigned char *p_out = wkb; double coord; -// building from GEOS 3D WKB - *p_out++ = 0x01; // little endian byte order - type = static_cast< Qgis::WkbType >( gaiaImport32( blob + 1, little_endian, endian_arch ) ); + // building from GEOS 3D WKB + *p_out++ = 0x01; // little endian byte order + type = static_cast( gaiaImport32( blob + 1, little_endian, endian_arch ) ); if ( QgsWkbTypes::geometryType( type ) == Qgis::GeometryType::Point ) { if ( QgsWkbTypes::isSingleType( type ) ) @@ -2607,24 +2524,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, // setting Geometry values case Qgis::GeometryType::Point: coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2637,24 +2554,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2674,24 +2591,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2734,24 +2651,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, } p_out += 4; coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2789,24 +2706,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2851,24 +2768,24 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -2884,12 +2801,9 @@ void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, } } -void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, - int blob_size, - unsigned char **wkb, - int *geom_size ) +void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, int blob_size, unsigned char **wkb, int *geom_size ) { -// attempting to convert to 2D/3D GEOS own WKB + // attempting to convert to 2D/3D GEOS own WKB int type; int dims; int little_endian; @@ -3007,73 +2921,73 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, memset( wkbGeom, '\0', gsize ); // building GEOS 3D WKB - *wkbGeom = 0x01; // little endian byte order + *wkbGeom = 0x01; // little endian byte order type = gaiaImport32( blob + 1, little_endian, endian_arch ); switch ( type ) { // setting Geometry TYPE case GAIA_POINTZ: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::Point25D ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::Point25D ), 1, endian_arch ); break; case GAIA_POINTM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::PointM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::PointM ), 1, endian_arch ); break; case GAIA_POINTZM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::PointZM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::PointZM ), 1, endian_arch ); break; case GAIA_LINESTRINGZ: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::LineString25D ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::LineString25D ), 1, endian_arch ); break; case GAIA_LINESTRINGM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::LineStringM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::LineStringM ), 1, endian_arch ); break; case GAIA_LINESTRINGZM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::LineStringZM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::LineStringZM ), 1, endian_arch ); break; case GAIA_POLYGONZ: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::Polygon25D ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::Polygon25D ), 1, endian_arch ); break; case GAIA_POLYGONM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::PolygonM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::PolygonM ), 1, endian_arch ); break; case GAIA_POLYGONZM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::PolygonZM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::PolygonZM ), 1, endian_arch ); break; case GAIA_MULTIPOINTZ: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiPoint25D ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiPoint25D ), 1, endian_arch ); break; case GAIA_MULTIPOINTM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiPointM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiPointM ), 1, endian_arch ); break; case GAIA_MULTIPOINTZM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiPointZM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiPointZM ), 1, endian_arch ); break; case GAIA_MULTILINESTRINGZ: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiLineString25D ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiLineString25D ), 1, endian_arch ); break; case GAIA_MULTILINESTRINGM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiLineStringM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiLineStringM ), 1, endian_arch ); break; case GAIA_MULTILINESTRINGZM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiLineStringZM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiLineStringZM ), 1, endian_arch ); break; case GAIA_MULTIPOLYGONZ: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiPolygon25D ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiPolygon25D ), 1, endian_arch ); break; case GAIA_MULTIPOLYGONM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiPolygonM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiPolygonM ), 1, endian_arch ); break; case GAIA_MULTIPOLYGONZM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::MultiPolygonZM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::MultiPolygonZM ), 1, endian_arch ); break; case GAIA_GEOMETRYCOLLECTIONZ: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::GeometryCollectionZ ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::GeometryCollectionZ ), 1, endian_arch ); break; case GAIA_GEOMETRYCOLLECTIONM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::GeometryCollectionM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::GeometryCollectionM ), 1, endian_arch ); break; case GAIA_GEOMETRYCOLLECTIONZM: - gaiaExport32( wkbGeom + 1, static_cast< quint32>( Qgis::WkbType::GeometryCollectionZM ), 1, endian_arch ); + gaiaExport32( wkbGeom + 1, static_cast( Qgis::WkbType::GeometryCollectionZM ), 1, endian_arch ); break; } p_in = blob + 5; @@ -3084,33 +2998,33 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, case GAIA_POINTZ: case GAIA_POINTM: coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); break; case GAIA_POINTZM: coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); break; @@ -3123,15 +3037,15 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3144,19 +3058,19 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3176,15 +3090,15 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3204,19 +3118,19 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3232,18 +3146,18 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, { p_in += 5; *p_out++ = 0x01; - gaiaExport32( p_out, static_cast< quint32>( type == GAIA_MULTIPOINTZ ? Qgis::WkbType::Point25D : Qgis::WkbType::PointM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( type == GAIA_MULTIPOINTZ ? Qgis::WkbType::Point25D : Qgis::WkbType::PointM ), 1, endian_arch ); p_out += 4; coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3257,22 +3171,22 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, { p_in += 5; *p_out++ = 0x01; - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::PointZM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::PointZM ), 1, endian_arch ); p_out += 4; coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3287,7 +3201,7 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, { p_in += 5; *p_out++ = 0x01; - gaiaExport32( p_out, static_cast< quint32>( type == GAIA_MULTILINESTRINGZ ? Qgis::WkbType::LineString25D : Qgis::WkbType::LineStringM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( type == GAIA_MULTILINESTRINGZ ? Qgis::WkbType::LineString25D : Qgis::WkbType::LineStringM ), 1, endian_arch ); p_out += 4; points = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; @@ -3296,15 +3210,15 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3319,7 +3233,7 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, { p_in += 5; *p_out++ = 0x01; - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::LineStringZM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::LineStringZM ), 1, endian_arch ); p_out += 4; points = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; @@ -3328,19 +3242,19 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3356,7 +3270,7 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, { p_in += 5; *p_out++ = 0x01; - gaiaExport32( p_out, static_cast< quint32>( type == GAIA_MULTIPOLYGONZ ? Qgis::WkbType::Polygon25D : Qgis::WkbType::PolygonM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( type == GAIA_MULTIPOLYGONZ ? Qgis::WkbType::Polygon25D : Qgis::WkbType::PolygonM ), 1, endian_arch ); p_out += 4; rings = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; @@ -3371,15 +3285,15 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3395,7 +3309,7 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, { p_in += 5; *p_out++ = 0x01; - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::PolygonZM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::PolygonZM ), 1, endian_arch ); p_out += 4; rings = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; @@ -3410,19 +3324,19 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3444,31 +3358,31 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, switch ( type2 ) { case GAIA_POINTZ: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::Point25D ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::Point25D ), 1, endian_arch ); break; case GAIA_POINTM: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::PointM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::PointM ), 1, endian_arch ); break; case GAIA_POINTZM: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::PointZM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::PointZM ), 1, endian_arch ); break; case GAIA_LINESTRINGZ: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::LineString25D ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::LineString25D ), 1, endian_arch ); break; case GAIA_LINESTRINGM: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::LineStringM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::LineStringM ), 1, endian_arch ); break; case GAIA_LINESTRINGZM: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::LineStringZM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::LineStringZM ), 1, endian_arch ); break; case GAIA_POLYGONZ: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::Polygon25D ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::Polygon25D ), 1, endian_arch ); break; case GAIA_POLYGONM: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::PolygonM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::PolygonM ), 1, endian_arch ); break; case GAIA_POLYGONZM: - gaiaExport32( p_out, static_cast< quint32>( Qgis::WkbType::PolygonZM ), 1, endian_arch ); + gaiaExport32( p_out, static_cast( Qgis::WkbType::PolygonZM ), 1, endian_arch ); break; } p_out += 4; @@ -3478,33 +3392,33 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, case GAIA_POINTZ: case GAIA_POINTM: coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); break; case GAIA_POINTZM: coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); break; @@ -3517,15 +3431,15 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3538,19 +3452,19 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3570,15 +3484,15 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M + gaiaExport64( p_out, coord, 1, endian_arch ); // Z or M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3598,19 +3512,19 @@ void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, for ( iv = 0; iv < points; iv++ ) { coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // X + gaiaExport64( p_out, coord, 1, endian_arch ); // X p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Y + gaiaExport64( p_out, coord, 1, endian_arch ); // Y p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // Z + gaiaExport64( p_out, coord, 1, endian_arch ); // Z p_in += sizeof( double ); p_out += sizeof( double ); coord = gaiaImport64( p_in, little_endian, endian_arch ); - gaiaExport64( p_out, coord, 1, endian_arch ); // M + gaiaExport64( p_out, coord, 1, endian_arch ); // M p_in += sizeof( double ); p_out += sizeof( double ); } @@ -3823,7 +3737,7 @@ Qgis::ProviderStyleStorageCapabilities QgsSpatiaLiteProvider::styleStorageCapabi QString QgsSpatiaLiteProvider::name() const { return SPATIALITE_KEY; -} // QgsSpatiaLiteProvider::name() +} // QgsSpatiaLiteProvider::name() QString QgsSpatiaLiteProvider::providerKey() { @@ -3833,7 +3747,7 @@ QString QgsSpatiaLiteProvider::providerKey() QString QgsSpatiaLiteProvider::description() const { return SPATIALITE_DESCRIPTION; -} // QgsSpatiaLiteProvider::description() +} // QgsSpatiaLiteProvider::description() QgsFields QgsSpatiaLiteProvider::fields() const { @@ -3864,7 +3778,7 @@ QVariant QgsSpatiaLiteProvider::minimumValue( int index ) const sql += " WHERE ( " + mSubsetString + ')'; } - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, errMsg ? errMsg : tr( "unknown cause" ) ), tr( "SpatiaLite" ) ); @@ -3927,7 +3841,7 @@ QVariant QgsSpatiaLiteProvider::maximumValue( int index ) const sql += " WHERE ( " + mSubsetString + ')'; } - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, errMsg ? errMsg : tr( "unknown cause" ) ), tr( "SpatiaLite" ) ); @@ -3940,7 +3854,6 @@ QVariant QgsSpatiaLiteProvider::maximumValue( int index ) const } else { - if ( rows < 1 ) ; else @@ -3997,10 +3910,10 @@ QSet QgsSpatiaLiteProvider::uniqueValues( int index, int limit ) const } // SQLite prepared statement - if ( sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) + if ( sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) { // some error occurred - QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ), tr( "SpatiaLite" ) ); + QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ), tr( "SpatiaLite" ) ); } else { @@ -4056,7 +3969,7 @@ QSet QgsSpatiaLiteProvider::uniqueValues( int index, int limit ) const } else { - QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ), tr( "SpatiaLite" ) ); + QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ), tr( "SpatiaLite" ) ); sqlite3_finalize( stmt ); return uniqueValues; } @@ -4097,11 +4010,10 @@ QStringList QgsSpatiaLiteProvider::uniqueStringsMatching( int index, const QStri } // SQLite prepared statement - if ( sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) + if ( sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) { // some error occurred - QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ), tr( "SpatiaLite" ) ); - + QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ), tr( "SpatiaLite" ) ); } else { @@ -4130,7 +4042,7 @@ QStringList QgsSpatiaLiteProvider::uniqueStringsMatching( int index, const QStri } else { - QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ), tr( "SpatiaLite" ) ); + QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ), tr( "SpatiaLite" ) ); sqlite3_finalize( stmt ); return results; } @@ -4147,8 +4059,7 @@ QString QgsSpatiaLiteProvider::geomParam() const bool forceMulti = QgsWkbTypes::isMultiType( wkbType() ); // ST_Multi function is available from QGIS >= 2.4 - bool hasMultiFunction = mSpatialiteVersionMajor > 2 || - ( mSpatialiteVersionMajor == 2 && mSpatialiteVersionMinor >= 4 ); + bool hasMultiFunction = mSpatialiteVersionMajor > 2 || ( mSpatialiteVersionMajor == 2 && mSpatialiteVersionMinor >= 4 ); if ( forceMulti && hasMultiFunction ) { @@ -4167,7 +4078,7 @@ QString QgsSpatiaLiteProvider::geomParam() const static void deleteWkbBlob( void *wkbBlob ) { - delete[]( char * )wkbBlob; + delete[] ( char * ) wkbBlob; } bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) @@ -4183,11 +4094,11 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( flist.isEmpty() ) return true; - const QString logUri = uri( ).uri( false ); + const QString logUri = uri().uri( false ); QgsAttributes attributevec = flist[0].attributes(); - const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) }; + const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++sSavepointId ) }; ret = exec_sql( sqliteHandle(), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret == SQLITE_OK ) @@ -4208,7 +4119,6 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) for ( QgsFeatureList::iterator feature = flist.begin(); feature != flist.end(); ++feature ) { - QChar separator { baseSeparator }; QString values { baseValues }; sql = baseSql; @@ -4221,9 +4131,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) for ( int i = 0; i < attributevec.count(); ++i ) { - if ( mDefaultValues.contains( i ) && ( - mDefaultValues.value( i ) == attributevec.at( i ).toString() || - ! attributevec.at( i ).isValid() ) ) + if ( mDefaultValues.contains( i ) && ( mDefaultValues.value( i ) == attributevec.at( i ).toString() || !attributevec.at( i ).isValid() ) ) { defaultIndexes.push_back( i ); continue; @@ -4247,10 +4155,9 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) sql += ')'; // SQLite prepared statement - ret = sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ); + ret = sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ); if ( ret == SQLITE_OK ) { - // initializing the column counter ia = 0; @@ -4266,10 +4173,8 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) unsigned char *wkb = nullptr; int wkb_size; const QgsGeometry convertedGeom( QgsVectorDataProvider::convertToProviderType( feature->geometry(), wkbType() ) ); - const QByteArray featureWkb{ !convertedGeom.isNull() ? convertedGeom.asWkb() : feature->geometry().asWkb() }; - convertFromGeosWKB( reinterpret_cast( featureWkb.constData() ), - featureWkb.length(), - &wkb, &wkb_size, nDims ); + const QByteArray featureWkb { !convertedGeom.isNull() ? convertedGeom.asWkb() : feature->geometry().asWkb() }; + convertFromGeosWKB( reinterpret_cast( featureWkb.constData() ), featureWkb.length(), &wkb, &wkb_size, nDims ); if ( !wkb ) sqlite3_bind_null( stmt, ++ia ); else @@ -4377,14 +4282,14 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) // update feature id if ( !( flags & QgsFeatureSink::FastInsert ) ) { - feature->setId( sqlite3_last_insert_rowid( sqliteHandle( ) ) ); + feature->setId( sqlite3_last_insert_rowid( sqliteHandle() ) ); } mNumberFeatures++; } else { // some unexpected error occurred - const char *err = sqlite3_errmsg( sqliteHandle( ) ); + const char *err = sqlite3_errmsg( sqliteHandle() ); errMsg = ( char * ) sqlite3_malloc( ( int ) strlen( err ) + 1 ); strcpy( errMsg, err ); logWrapper.setError( errMsg ); @@ -4411,7 +4316,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( toCommit ) { // ROLLBACK after some previous error - ( void )exec_sql( sqliteHandle(), QStringLiteral( "ROLLBACK TRANSACTION TO SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), nullptr, QGS_QUERY_LOG_ORIGIN ); + ( void ) exec_sql( sqliteHandle(), QStringLiteral( "ROLLBACK TRANSACTION TO SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), nullptr, QGS_QUERY_LOG_ORIGIN ); // Also release the savepoint or it will remain on the stack. ( void ) exec_sql( sqliteHandle(), QStringLiteral( "RELEASE SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); } @@ -4443,7 +4348,7 @@ bool QgsSpatiaLiteProvider::createAttributeIndex( int field ) QString sql; QString fieldName; - const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) }; + const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++sSavepointId ) }; int ret = exec_sql( sqliteHandle(), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) @@ -4455,9 +4360,7 @@ bool QgsSpatiaLiteProvider::createAttributeIndex( int field ) fieldName = mAttributeFields.at( field ).name(); sql = QStringLiteral( "CREATE INDEX IF NOT EXISTS %1 ON \"%2\" (%3)" ) - .arg( createIndexName( mTableName, fieldName ), - mTableName, - QgsSqliteUtils::quotedIdentifier( fieldName ) ); + .arg( createIndexName( mTableName, fieldName ), mTableName, QgsSqliteUtils::quotedIdentifier( fieldName ) ); ret = exec_sql( sqliteHandle(), sql, uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { @@ -4498,7 +4401,7 @@ bool QgsSpatiaLiteProvider::deleteFeatures( const QgsFeatureIds &id ) char *errMsg = nullptr; QString sql; - const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) }; + const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++sSavepointId ) }; int ret = exec_sql( sqliteHandle(), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) @@ -4510,10 +4413,10 @@ bool QgsSpatiaLiteProvider::deleteFeatures( const QgsFeatureIds &id ) sql = QStringLiteral( "DELETE FROM %1 WHERE %2=?" ).arg( QgsSqliteUtils::quotedIdentifier( mTableName ), QgsSqliteUtils::quotedIdentifier( mPrimaryKey ) ); // SQLite prepared statement - if ( sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) + if ( sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) { // some error occurred - pushError( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ) ); + pushError( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ) ); return false; } else @@ -4537,7 +4440,7 @@ bool QgsSpatiaLiteProvider::deleteFeatures( const QgsFeatureIds &id ) else { // some unexpected error occurred - const char *err = sqlite3_errmsg( sqliteHandle( ) ); + const char *err = sqlite3_errmsg( sqliteHandle() ); errMsg = ( char * ) sqlite3_malloc( ( int ) strlen( err ) + 1 ); strcpy( errMsg, err ); handleError( sql, errMsg, savepointId ); @@ -4549,7 +4452,7 @@ bool QgsSpatiaLiteProvider::deleteFeatures( const QgsFeatureIds &id ) sqlite3_finalize( stmt ); - ret = exec_sql( sqliteHandle( ), QStringLiteral( "RELEASE SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle(), QStringLiteral( "RELEASE SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, savepointId ); @@ -4567,9 +4470,9 @@ bool QgsSpatiaLiteProvider::truncate() char *errMsg = nullptr; QString sql; - const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) }; + const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++sSavepointId ) }; - int ret = exec_sql( sqliteHandle( ), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + int ret = exec_sql( sqliteHandle(), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -4577,14 +4480,14 @@ bool QgsSpatiaLiteProvider::truncate() } sql = QStringLiteral( "DELETE FROM %1" ).arg( QgsSqliteUtils::quotedIdentifier( mTableName ) ); - ret = exec_sql( sqliteHandle( ), sql, uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle(), sql, uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, savepointId ); return false; } - ret = exec_sql( sqliteHandle( ), QStringLiteral( "RELEASE SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle(), QStringLiteral( "RELEASE SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, savepointId ); @@ -4605,9 +4508,9 @@ bool QgsSpatiaLiteProvider::addAttributes( const QList &attributes ) if ( attributes.isEmpty() ) return true; - const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) }; + const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++sSavepointId ) }; - int ret = exec_sql( sqliteHandle( ), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + int ret = exec_sql( sqliteHandle(), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -4617,10 +4520,8 @@ bool QgsSpatiaLiteProvider::addAttributes( const QList &attributes ) for ( QList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter ) { sql = QStringLiteral( "ALTER TABLE \"%1\" ADD COLUMN \"%2\" %3" ) - .arg( mTableName, - iter->name(), - iter->typeName() ); - ret = exec_sql( sqliteHandle( ), sql, uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + .arg( mTableName, iter->name(), iter->typeName() ); + ret = exec_sql( sqliteHandle(), sql, uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, savepointId ); @@ -4628,15 +4529,15 @@ bool QgsSpatiaLiteProvider::addAttributes( const QList &attributes ) } } - ret = exec_sql( sqliteHandle( ), QStringLiteral( "RELEASE SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = exec_sql( sqliteHandle(), QStringLiteral( "RELEASE SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, savepointId ); return false; } - gaiaStatisticsInvalidate( sqliteHandle( ), mTableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData() ); - update_layer_statistics( sqliteHandle( ), mTableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData() ); + gaiaStatisticsInvalidate( sqliteHandle(), mTableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData() ); + update_layer_statistics( sqliteHandle(), mTableName.toUtf8().constData(), mGeometryColumn.toUtf8().constData() ); // reload columns loadFields(); @@ -4655,9 +4556,9 @@ bool QgsSpatiaLiteProvider::changeAttributeValues( const QgsChangedAttributesMap if ( attr_map.isEmpty() ) return true; - const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) }; + const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++sSavepointId ) }; - int ret = exec_sql( sqliteHandle( ), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); + int ret = exec_sql( sqliteHandle(), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -4721,12 +4622,12 @@ bool QgsSpatiaLiteProvider::changeAttributeValues( const QgsChangedAttributesMap try { const auto jObj = QgsJsonUtils::jsonFromVariant( val ); - if ( ! jObj.is_array() ) + if ( !jObj.is_array() ) { throw json::parse_error::create( 0, 0, tr( "JSON value must be an array" ).toStdString() ); } - jRepr = QString::fromStdString( jObj.dump( ) ); - sql += QStringLiteral( "%1=%2" ).arg( QgsSqliteUtils::quotedIdentifier( fld.name() ), QgsSqliteUtils::quotedString( jRepr ) ); + jRepr = QString::fromStdString( jObj.dump() ); + sql += QStringLiteral( "%1=%2" ).arg( QgsSqliteUtils::quotedIdentifier( fld.name() ), QgsSqliteUtils::quotedString( jRepr ) ); } catch ( json::exception &ex ) { @@ -4742,7 +4643,7 @@ bool QgsSpatiaLiteProvider::changeAttributeValues( const QgsChangedAttributesMap { // binding a BLOB value sql += QStringLiteral( "%1=?" ).arg( QgsSqliteUtils::quotedIdentifier( fld.name() ) ); - bindings[ bind_parameter_idx++ ] = val; + bindings[bind_parameter_idx++] = val; } else if ( type == QMetaType::Type::QDateTime ) { @@ -4767,11 +4668,11 @@ bool QgsSpatiaLiteProvider::changeAttributeValues( const QgsChangedAttributesMap // prepare SQLite statement sqlite3_stmt *stmt = nullptr; - ret = sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ); + ret = sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ); if ( ret != SQLITE_OK ) { // some unexpected error occurred during preparation - const char *err = sqlite3_errmsg( sqliteHandle( ) ); + const char *err = sqlite3_errmsg( sqliteHandle() ); errMsg = static_cast( sqlite3_malloc( strlen( err ) + 1 ) ); strcpy( errMsg, err ); handleError( sql, errMsg, savepointId ); @@ -4802,7 +4703,7 @@ bool QgsSpatiaLiteProvider::changeAttributeValues( const QgsChangedAttributesMap if ( ret != SQLITE_OK ) { // some unexpected error occurred during binding - const char *err = sqlite3_errmsg( sqliteHandle( ) ); + const char *err = sqlite3_errmsg( sqliteHandle() ); errMsg = static_cast( sqlite3_malloc( strlen( err ) + 1 ) ); strcpy( errMsg, err ); handleError( sql, errMsg, savepointId ); @@ -4816,7 +4717,7 @@ bool QgsSpatiaLiteProvider::changeAttributeValues( const QgsChangedAttributesMap if ( ret != SQLITE_DONE ) { // some unexpected error occurred during execution of update query - const char *err = sqlite3_errmsg( sqliteHandle( ) ); + const char *err = sqlite3_errmsg( sqliteHandle() ); errMsg = static_cast( sqlite3_malloc( strlen( err ) + 1 ) ); strcpy( errMsg, err ); handleError( sql, errMsg, savepointId ); @@ -4843,7 +4744,7 @@ bool QgsSpatiaLiteProvider::changeGeometryValues( const QgsGeometryMap &geometry char *errMsg = nullptr; QString sql; - const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) }; + const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++sSavepointId ) }; int ret = exec_sql( sqliteHandle(), QStringLiteral( "SAVEPOINT \"%1\"" ).arg( savepointId ), uri().uri(), errMsg, QGS_QUERY_LOG_ORIGIN ); if ( ret != SQLITE_OK ) @@ -4852,18 +4753,16 @@ bool QgsSpatiaLiteProvider::changeGeometryValues( const QgsGeometryMap &geometry return false; } - sql = - QStringLiteral( "UPDATE %1 SET %2=GeomFromWKB(?, %3) WHERE %4=?" ) - .arg( QgsSqliteUtils::quotedIdentifier( mTableName ), - QgsSqliteUtils::quotedIdentifier( mGeometryColumn ) ) - .arg( mSrid ) - .arg( QgsSqliteUtils::quotedIdentifier( mPrimaryKey ) ); + sql = QStringLiteral( "UPDATE %1 SET %2=GeomFromWKB(?, %3) WHERE %4=?" ) + .arg( QgsSqliteUtils::quotedIdentifier( mTableName ), QgsSqliteUtils::quotedIdentifier( mGeometryColumn ) ) + .arg( mSrid ) + .arg( QgsSqliteUtils::quotedIdentifier( mPrimaryKey ) ); // SQLite prepared statement - if ( sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) + if ( sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ) != SQLITE_OK ) { // some error occurred - QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle( ) ) ), tr( "SpatiaLite" ) ); + QgsMessageLog::logMessage( tr( "SQLite error: %2\nSQL: %1" ).arg( sql, sqlite3_errmsg( sqliteHandle() ) ), tr( "SpatiaLite" ) ); } else { @@ -4877,7 +4776,7 @@ bool QgsSpatiaLiteProvider::changeGeometryValues( const QgsGeometryMap &geometry unsigned char *wkb = nullptr; int wkb_size; const QgsGeometry convertedGeom( convertToProviderType( *iter ) ); - const QByteArray iterWkb{ !convertedGeom.isNull() ? convertedGeom.asWkb() : iter->asWkb() }; + const QByteArray iterWkb { !convertedGeom.isNull() ? convertedGeom.asWkb() : iter->asWkb() }; convertFromGeosWKB( reinterpret_cast( iterWkb.constData() ), iterWkb.length(), &wkb, &wkb_size, nDims ); if ( !wkb ) sqlite3_bind_null( stmt, 1 ); @@ -4892,7 +4791,7 @@ bool QgsSpatiaLiteProvider::changeGeometryValues( const QgsGeometryMap &geometry else { // some unexpected error occurred - const char *err = sqlite3_errmsg( sqliteHandle( ) ); + const char *err = sqlite3_errmsg( sqliteHandle() ); errMsg = ( char * ) sqlite3_malloc( ( int ) strlen( err ) + 1 ); strcpy( errMsg, err ); handleError( sql, errMsg, savepointId ); @@ -4938,7 +4837,7 @@ bool QgsSpatiaLiteProvider::skipConstraintCheck( int fieldIndex, QgsFieldConstra void QgsSpatiaLiteProvider::closeDb() { -// trying to close the SQLite DB + // trying to close the SQLite DB if ( mHandle ) { QgsSqliteHandle::closeDb( mHandle ); @@ -5010,12 +4909,13 @@ bool QgsSpatiaLiteProvider::checkLayerType() // checking if is a non-spatial table sql = QString( "SELECT type FROM sqlite_master " "WHERE lower(name) = lower(%1) " - "AND type in ('table', 'view') " ).arg( QgsSqliteUtils::quotedString( mTableName ) ); + "AND type in ('table', 'view') " ) + .arg( QgsSqliteUtils::quotedString( mTableName ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK && rows == 1 ) { - QString type = QString( results[ columns + 0 ] ); + QString type = QString( results[columns + 0] ); if ( type == QLatin1String( "table" ) ) { mTableBased = true; @@ -5048,16 +4948,14 @@ bool QgsSpatiaLiteProvider::checkLayerType() QString pattern = QStringLiteral( "(\\\"?)%1\\1" ).arg( QRegularExpression::escape( alias ) ); regex.setPattern( pattern ); regex.setPatternOptions( QRegularExpression::CaseInsensitiveOption ); - } - while ( mQuery.contains( regex ) ); + } while ( mQuery.contains( regex ) ); // convert the custom query into a subquery mQuery = QStringLiteral( "%1 as %2" ) - .arg( mQuery, - QgsSqliteUtils::quotedIdentifier( alias ) ); + .arg( mQuery, QgsSqliteUtils::quotedIdentifier( alias ) ); sql = QStringLiteral( "SELECT 0, %1 FROM %2 LIMIT 1" ).arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ), mQuery ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); // Try to find a PK or try to use ROWID if ( ret == SQLITE_OK && rows == 1 ) @@ -5067,27 +4965,26 @@ bool QgsSpatiaLiteProvider::checkLayerType() // 1. find the table that provides geometry // String containing the name of the table that provides the geometry if the layer data source is based on a query QString queryGeomTableName; - if ( sqlite3_prepare_v2( sqliteHandle( ), sql.toUtf8().constData(), -1, &stmt, nullptr ) == SQLITE_OK ) + if ( sqlite3_prepare_v2( sqliteHandle(), sql.toUtf8().constData(), -1, &stmt, nullptr ) == SQLITE_OK ) { queryGeomTableName = sqlite3_column_table_name( stmt, 1 ); } // 3. Find pks QList pks; - if ( ! queryGeomTableName.isEmpty() ) + if ( !queryGeomTableName.isEmpty() ) { pks = tablePrimaryKeys( queryGeomTableName ); } // find table alias if any QString tableAlias; - if ( ! queryGeomTableName.isEmpty() ) + if ( !queryGeomTableName.isEmpty() ) { // Try first with single table alias // (I couldn't find a sqlite API call to get this information) QRegularExpression re { QStringLiteral( R"re("?%1"?\s+AS\s+(\w+))re" ).arg( queryGeomTableName ) }; - re.setPatternOptions( QRegularExpression::PatternOption::MultilineOption | - QRegularExpression::PatternOption::CaseInsensitiveOption ); + re.setPatternOptions( QRegularExpression::PatternOption::MultilineOption | QRegularExpression::PatternOption::CaseInsensitiveOption ); QRegularExpressionMatch match { re.match( mTableName ) }; if ( match.hasMatch() ) { @@ -5107,38 +5004,33 @@ bool QgsSpatiaLiteProvider::checkLayerType() const QString tableIdentifier { tableAlias.isEmpty() ? queryGeomTableName : tableAlias }; QRegularExpression injectionRe { QStringLiteral( R"re(SELECT\s([^\(]+?FROM\s+"?%1"?))re" ).arg( tableIdentifier ) }; - injectionRe.setPatternOptions( QRegularExpression::PatternOption::MultilineOption | - QRegularExpression::PatternOption::CaseInsensitiveOption ); + injectionRe.setPatternOptions( QRegularExpression::PatternOption::MultilineOption | QRegularExpression::PatternOption::CaseInsensitiveOption ); - if ( ! pks.isEmpty() ) + if ( !pks.isEmpty() ) { if ( pks.length() > 1 ) { - QgsMessageLog::logMessage( tr( "SQLite composite keys are not supported in query layer, using the first component only. %1" ) - .arg( sql ), tr( "SpatiaLite" ), Qgis::MessageLevel::Warning ); + QgsMessageLog::logMessage( tr( "SQLite composite keys are not supported in query layer, using the first component only. %1" ).arg( sql ), tr( "SpatiaLite" ), Qgis::MessageLevel::Warning ); } // Try first without any injection or manipulation - sql = QStringLiteral( "SELECT %1, %2 FROM %3 LIMIT 1" ).arg( QgsSqliteUtils::quotedIdentifier( pks.first( ) ), QgsSqliteUtils::quotedIdentifier( mGeometryColumn ), mQuery ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + sql = QStringLiteral( "SELECT %1, %2 FROM %3 LIMIT 1" ).arg( QgsSqliteUtils::quotedIdentifier( pks.first() ), QgsSqliteUtils::quotedIdentifier( mGeometryColumn ), mQuery ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK && rows == 1 ) { - mPrimaryKey = pks.first( ); + mPrimaryKey = pks.first(); } else // if that does not work, try injection with table name/alias { QString pk { QStringLiteral( "%1.%2" ).arg( QgsSqliteUtils::quotedIdentifier( alias ) ).arg( pks.first() ) }; - QString newSql( mQuery.replace( injectionRe, - QStringLiteral( R"re(SELECT %1.%2, \1)re" ) - .arg( QgsSqliteUtils::quotedIdentifier( tableIdentifier ) ) - .arg( pks.first() ) ) ); + QString newSql( mQuery.replace( injectionRe, QStringLiteral( R"re(SELECT %1.%2, \1)re" ).arg( QgsSqliteUtils::quotedIdentifier( tableIdentifier ) ).arg( pks.first() ) ) ); sql = QStringLiteral( "SELECT %1 FROM %2 LIMIT 1" ).arg( pk ).arg( newSql ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK && rows == 1 ) { mQuery = newSql; - mPrimaryKey = pks.first( ); + mPrimaryKey = pks.first(); } } } @@ -5147,24 +5039,21 @@ bool QgsSpatiaLiteProvider::checkLayerType() if ( mPrimaryKey.isEmpty() ) { // 4. check if the table has a usable ROWID - if ( ! queryGeomTableName.isEmpty() ) + if ( !queryGeomTableName.isEmpty() ) { sql = QStringLiteral( "SELECT ROWID FROM %1 WHERE ROWID IS NOT NULL LIMIT 1" ).arg( QgsSqliteUtils::quotedIdentifier( queryGeomTableName ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK || rows != 1 ) { queryGeomTableName = QString(); } } // 5. check if ROWID injection works - if ( ! queryGeomTableName.isEmpty() ) + if ( !queryGeomTableName.isEmpty() ) { - const QString newSql( mQuery.replace( injectionRe, - QStringLiteral( R"re(SELECT %1.%2, \1)re" ) - .arg( QgsSqliteUtils::quotedIdentifier( tableIdentifier ), - QStringLiteral( "ROWID" ) ) ) ); + const QString newSql( mQuery.replace( injectionRe, QStringLiteral( R"re(SELECT %1.%2, \1)re" ).arg( QgsSqliteUtils::quotedIdentifier( tableIdentifier ), QStringLiteral( "ROWID" ) ) ) ); sql = QStringLiteral( "SELECT ROWID FROM %1 WHERE ROWID IS NOT NULL LIMIT 1" ).arg( newSql ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK && rows == 1 ) { mQuery = newSql; @@ -5200,19 +5089,17 @@ bool QgsSpatiaLiteProvider::checkLayerType() "LEFT JOIN geometry_columns_auth " "USING (f_table_name, f_geometry_column) " "WHERE upper(f_table_name) = upper(%1) and upper(f_geometry_column) = upper(%2)" ) - .arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { if ( errMsg && strcmp( errMsg, "no such table: geometry_columns_auth" ) == 0 ) { sqlite3_free( errMsg ); sql = QStringLiteral( "SELECT 0 FROM geometry_columns WHERE upper(f_table_name) = upper(%1) and upper(f_geometry_column) = upper(%2)" ) - .arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); } } if ( ret == SQLITE_OK && rows == 1 ) @@ -5239,10 +5126,10 @@ bool QgsSpatiaLiteProvider::checkLayerType() // checking if this one is a View-based layer sql = QString( "SELECT view_name, view_geometry FROM views_geometry_columns" - " WHERE view_name=%1 and view_geometry=%2" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + " WHERE view_name=%1 and view_geometry=%2" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK && rows == 1 ) { mViewBased = true; @@ -5259,10 +5146,10 @@ bool QgsSpatiaLiteProvider::checkLayerType() // checking if this one is a VirtualShapefile-based layer sql = QString( "SELECT virt_name, virt_geometry FROM virts_geometry_columns" - " WHERE virt_name=%1 and virt_geometry=%2" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + " WHERE virt_name=%1 and virt_geometry=%2" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK && rows == 1 ) { mVShapeBased = true; @@ -5283,7 +5170,7 @@ bool QgsSpatiaLiteProvider::checkLayerType() mQuery = QgsSqliteUtils::quotedIdentifier( mTableName ); } -// checking for validity + // checking for validity return count == 1; } @@ -5370,9 +5257,9 @@ void QgsSpatiaLiteProvider::getViewSpatialIndexName() QString sql = QString( "SELECT f_table_name, f_geometry_column " "FROM views_geometry_columns " - "WHERE upper(view_name) = upper(%1) and upper(view_geometry) = upper(%2)" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + "WHERE upper(view_name) = upper(%1) and upper(view_geometry) = upper(%2)" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -5424,20 +5311,20 @@ bool QgsSpatiaLiteProvider::getTableGeometryDetails() mIndexGeometry = mGeometryColumn; QString sql; - if ( ! versionIsAbove( sqliteHandle( ), 3, 1 ) ) + if ( !versionIsAbove( sqliteHandle(), 3, 1 ) ) { sql = QString( "SELECT type, srid, spatial_index_enabled, coord_dimension FROM geometry_columns" - " WHERE upper(f_table_name) = upper(%1) and upper(f_geometry_column) = upper(%2)" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + " WHERE upper(f_table_name) = upper(%1) and upper(f_geometry_column) = upper(%2)" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); } else { sql = QString( "SELECT geometry_type, srid, spatial_index_enabled, coord_dimension FROM geometry_columns" - " WHERE upper(f_table_name) = upper(%1) and upper(f_geometry_column) = upper(%2)" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + " WHERE upper(f_table_name) = upper(%1) and upper(f_geometry_column) = upper(%2)" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); } - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -5470,11 +5357,11 @@ bool QgsSpatiaLiteProvider::getTableGeometryDetails() { mGeomType = Qgis::WkbType::MultiLineString; } - else if ( fType == QLatin1String( "POLYGON" ) || fType == QLatin1String( "3" ) ) + else if ( fType == QLatin1String( "POLYGON" ) || fType == QLatin1String( "3" ) ) { mGeomType = Qgis::WkbType::Polygon; } - else if ( fType == QLatin1String( "MULTIPOLYGON" ) || fType == QLatin1String( "6" ) ) + else if ( fType == QLatin1String( "MULTIPOLYGON" ) || fType == QLatin1String( "6" ) ) { mGeomType = Qgis::WkbType::MultiPolygon; } @@ -5507,7 +5394,6 @@ bool QgsSpatiaLiteProvider::getTableGeometryDetails() nDims = GAIA_XY_Z_M; mGeomType = QgsWkbTypes::zmType( mGeomType, true, true ); } - } } sqlite3_free_table( results ); @@ -5533,10 +5419,10 @@ bool QgsSpatiaLiteProvider::getViewGeometryDetails() QString sql = QString( "SELECT type, srid, spatial_index_enabled, f_table_name, f_geometry_column " " FROM views_geometry_columns" " JOIN geometry_columns USING (f_table_name, f_geometry_column)" - " WHERE upper(view_name) = upper(%1) and upper(view_geometry) = upper(%2)" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + " WHERE upper(view_name) = upper(%1) and upper(view_geometry) = upper(%2)" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -5587,7 +5473,6 @@ bool QgsSpatiaLiteProvider::getViewGeometryDetails() { mSpatialIndexMbrCache = true; } - } } sqlite3_free_table( results ); @@ -5611,10 +5496,10 @@ bool QgsSpatiaLiteProvider::getVShapeGeometryDetails() char *errMsg = nullptr; QString sql = QString( "SELECT type, srid FROM virts_geometry_columns" - " WHERE virt_name=%1 and virt_geometry=%2" ).arg( QgsSqliteUtils::quotedString( mTableName ), - QgsSqliteUtils::quotedString( mGeometryColumn ) ); + " WHERE virt_name=%1 and virt_geometry=%2" ) + .arg( QgsSqliteUtils::quotedString( mTableName ), QgsSqliteUtils::quotedString( mGeometryColumn ) ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -5654,7 +5539,6 @@ bool QgsSpatiaLiteProvider::getVShapeGeometryDetails() mGeomType = Qgis::WkbType::MultiPolygon; } mSrid = xSrid.toInt(); - } } sqlite3_free_table( results ); @@ -5683,8 +5567,7 @@ bool QgsSpatiaLiteProvider::getQueryGeometryDetails() // get stuff from the relevant column instead. This may (will?) // fail if there is no data in the relevant table. QString sql = QStringLiteral( "SELECT srid(%1), geometrytype(%1) FROM %2" ) - .arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ), - mQuery ); + .arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ), mQuery ); //it is possible that the where clause restricts the feature type if ( !mSubsetString.isEmpty() ) @@ -5694,7 +5577,7 @@ bool QgsSpatiaLiteProvider::getQueryGeometryDetails() sql += QLatin1String( " limit 1" ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -5725,13 +5608,12 @@ bool QgsSpatiaLiteProvider::getQueryGeometryDetails() " WHEN geometrytype(%1) IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON'" " END " "FROM %2" ) - .arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ), - mQuery ); + .arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ), mQuery ); if ( !mSubsetString.isEmpty() ) sql += " where " + mSubsetString; - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -5774,7 +5656,7 @@ bool QgsSpatiaLiteProvider::getSridDetails() QString sql = QStringLiteral( "SELECT auth_name||':'||auth_srid,proj4text FROM spatial_ref_sys WHERE srid=%1" ).arg( mSrid ); - ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret != SQLITE_OK ) { handleError( sql, errMsg, QString() ); @@ -5786,7 +5668,7 @@ bool QgsSpatiaLiteProvider::getSridDetails() { for ( i = 1; i <= rows; i++ ) { - mAuthId = results[( i * columns ) + 0]; + mAuthId = results[( i * columns ) + 0]; mProj4text = results[( i * columns ) + 1]; } } @@ -5802,8 +5684,7 @@ bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface( gaiaVectorLayerPtr if ( lyr->ExtentInfos ) { - mLayerExtent = QgsBox3D( lyr->ExtentInfos->MinX, lyr->ExtentInfos->MinY, std::numeric_limits::quiet_NaN(), - lyr->ExtentInfos->MaxX, lyr->ExtentInfos->MaxY, std::numeric_limits::quiet_NaN() ); + mLayerExtent = QgsBox3D( lyr->ExtentInfos->MinX, lyr->ExtentInfos->MinY, std::numeric_limits::quiet_NaN(), lyr->ExtentInfos->MaxX, lyr->ExtentInfos->MaxY, std::numeric_limits::quiet_NaN() ); // This can be wrong! see: GH #29264 // mNumberFeatures = lyr->ExtentInfos->Count; // Note: the unique ptr here does not own the handle, it is just used for the convenience @@ -5811,7 +5692,7 @@ bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface( gaiaVectorLayerPtr sqlite3_database_unique_ptr slPtr; slPtr.reset( sqliteHandle() ); int resultCode = 0; - sqlite3_statement_unique_ptr stmt { slPtr.prepare( QStringLiteral( "SELECT COUNT(1) FROM %2" ).arg( mQuery ), resultCode )}; + sqlite3_statement_unique_ptr stmt { slPtr.prepare( QStringLiteral( "SELECT COUNT(1) FROM %2" ).arg( mQuery ), resultCode ) }; if ( resultCode == SQLITE_OK ) { stmt.step(); @@ -5835,14 +5716,15 @@ bool QgsSpatiaLiteProvider::getTableSummary() QString sql = QStringLiteral( "SELECT Count(1)" ); - if ( ! mGeometryColumn.isEmpty() ) + if ( !mGeometryColumn.isEmpty() ) { sql += QStringLiteral( ", Min(MbrMinX(%1)), Min(MbrMinY(%1)), Min(ST_MinZ(%1)), Max(MbrMaxX(%1)), Max(MbrMaxY(%1)), Max(ST_MaxZ(%1))" - ).arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ) ); + ) + .arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ) ); } - sql += QStringLiteral( " FROM %1" ) .arg( mQuery ); + sql += QStringLiteral( " FROM %1" ).arg( mQuery ); if ( !mSubsetString.isEmpty() ) { @@ -5865,7 +5747,8 @@ bool QgsSpatiaLiteProvider::getTableSummary() { QgsMessageLog::logMessage( tr( "Spatialite: unexpected number of rows (%1) from aggregate query\nSQL: %2" ) - .arg( rows ) .arg( sql ) + .arg( rows ) + .arg( sql ) ); // TODO: should we ROLLBACK ? sqlite3_free_table( results ); @@ -5876,27 +5759,33 @@ bool QgsSpatiaLiteProvider::getTableSummary() QString count = results[columns + 0]; mNumberFeatures = count.toLongLong(); - if ( mNumberFeatures && ! mGeometryColumn.isEmpty() ) do + if ( mNumberFeatures && !mGeometryColumn.isEmpty() ) + do { - const QString minX = results[columns + 1]; if ( minX.isEmpty() ) break; - const QString minY = results[columns + 2]; if ( minY.isEmpty() ) break; + const QString minX = results[columns + 1]; + if ( minX.isEmpty() ) + break; + const QString minY = results[columns + 2]; + if ( minY.isEmpty() ) + break; const QString minZ = results[columns + 3]; - const QString maxX = results[columns + 4]; if ( maxX.isEmpty() ) break; - const QString maxY = results[columns + 5]; if ( maxY.isEmpty() ) break; + const QString maxX = results[columns + 4]; + if ( maxX.isEmpty() ) + break; + const QString maxY = results[columns + 5]; + if ( maxY.isEmpty() ) + break; const QString maxZ = results[columns + 6]; if ( nDims == GAIA_XY || nDims == GAIA_XY_M || minZ.isEmpty() || maxZ.isEmpty() ) { - mLayerExtent = QgsBox3D( minX.toDouble(), minY.toDouble(), std::numeric_limits::quiet_NaN(), - maxX.toDouble(), maxY.toDouble(), std::numeric_limits::quiet_NaN() ); + mLayerExtent = QgsBox3D( minX.toDouble(), minY.toDouble(), std::numeric_limits::quiet_NaN(), maxX.toDouble(), maxY.toDouble(), std::numeric_limits::quiet_NaN() ); } else { - mLayerExtent = QgsBox3D( minX.toDouble(), minY.toDouble(), minZ.toDouble(), - maxX.toDouble(), maxY.toDouble(), maxZ.toDouble() ); + mLayerExtent = QgsBox3D( minX.toDouble(), minY.toDouble(), minZ.toDouble(), maxX.toDouble(), maxY.toDouble(), maxZ.toDouble() ); } - } - while ( 0 ); + } while ( 0 ); sqlite3_free_table( results ); return true; @@ -5937,7 +5826,8 @@ QVariantMap QgsSpatiaLiteProviderMetadata::decodeUri( const QString &uri ) const QgsSpatiaLiteProvider *QgsSpatiaLiteProviderMetadata::createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) + Qgis::DataProviderReadFlags flags +) { return new QgsSpatiaLiteProvider( uri, options, flags ); } @@ -5979,19 +5869,12 @@ QgsProviderMetadata::ProviderCapabilities QgsSpatiaLiteProviderMetadata::provide } -Qgis::VectorExportResult QgsSpatiaLiteProviderMetadata::createEmptyLayer( const QString &uri, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - QMap &oldToNewAttrIdxMap, - QString &errorMessage, - const QMap *options ) +Qgis::VectorExportResult QgsSpatiaLiteProviderMetadata::createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) { return QgsSpatiaLiteProvider::createEmptyLayer( - uri, fields, wkbType, srs, overwrite, - &oldToNewAttrIdxMap, &errorMessage, options - ); + uri, fields, wkbType, srs, overwrite, + &oldToNewAttrIdxMap, &errorMessage, options + ); } bool QgsSpatiaLiteProviderMetadata::createDb( const QString &dbPath, QString &errCause ) @@ -6037,7 +5920,7 @@ Qgis::VectorLayerTypeFlags QgsSpatiaLiteProvider::vectorLayerTypeFlags() const return flags; } -QgsTransaction *QgsSpatiaLiteProvider::transaction( ) const +QgsTransaction *QgsSpatiaLiteProvider::transaction() const { return static_cast( mTransaction ); } @@ -6050,7 +5933,7 @@ QList QgsSpatiaLiteProvider::discoverRelations( const QgsVectorLaye int rows; int columns; char *errMsg = nullptr; - int ret = sqlite3_get_table( sqliteHandle( ), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); + int ret = sqlite3_get_table( sqliteHandle(), sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( ret == SQLITE_OK ) { int nbFound = 0; @@ -6149,10 +6032,10 @@ bool QgsSpatiaLiteProviderMetadata::styleExists( const QString &uri, const QStri " AND f_table_name=%2" " AND f_geometry_column=%3" " AND styleName=%4" ) - .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) - .arg( QgsSqliteUtils::quotedString( styleId.isEmpty() ? dsUri.table() : styleId ) ); + .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) + .arg( QgsSqliteUtils::quotedString( styleId.isEmpty() ? dsUri.table() : styleId ) ); ret = sqlite3_get_table( sqliteHandle, checkQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg ); @@ -6176,9 +6059,7 @@ bool QgsSpatiaLiteProviderMetadata::styleExists( const QString &uri, const QStri } } -bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, - const QString &styleName, const QString &styleDescription, - const QString &uiFileContent, bool useAsDefault, QString &errCause ) +bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) { QgsDataSourceUri dsUri( uri ); QString sqlitePath = dsUri.database(); @@ -6215,14 +6096,13 @@ bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString int howMany = 0; if ( 1 == rows ) { - howMany = atoi( results[( rows * columns ) + 0 ] ); + howMany = atoi( results[( rows * columns ) + 0] ); } sqlite3_free_table( results ); // create table if not exist if ( 0 == howMany ) { - QString createQuery = QString( "CREATE TABLE layer_styles(" "id INTEGER PRIMARY KEY AUTOINCREMENT" ",f_table_catalog varchar(256)" @@ -6238,7 +6118,7 @@ bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString ",ui text" ",update_time timestamp DEFAULT CURRENT_TIMESTAMP" ")" ); - ret = QgsSpatiaLiteProvider::exec_sql( sqliteHandle, createQuery.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = QgsSpatiaLiteProvider::exec_sql( sqliteHandle, createQuery.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( SQLITE_OK != ret ) { QgsSqliteHandle::closeDb( handle ); @@ -6260,18 +6140,18 @@ bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString ") VALUES (" "%1,%2,%3,%4,%5,%6,%7,%8,%9,%10%12" ")" ) - .arg( QgsSqliteUtils::quotedString( QString() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.schema() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) - .arg( QgsSqliteUtils::quotedString( styleName.isEmpty() ? dsUri.table() : styleName ) ) - .arg( QgsSqliteUtils::quotedString( qmlStyle ) ) - .arg( QgsSqliteUtils::quotedString( sldStyle ) ) - .arg( useAsDefault ? "1" : "0" ) - .arg( QgsSqliteUtils::quotedString( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.username() ) ) - .arg( uiFileColumn ) - .arg( uiFileValue ); + .arg( QgsSqliteUtils::quotedString( QString() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.schema() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) + .arg( QgsSqliteUtils::quotedString( styleName.isEmpty() ? dsUri.table() : styleName ) ) + .arg( QgsSqliteUtils::quotedString( qmlStyle ) ) + .arg( QgsSqliteUtils::quotedString( sldStyle ) ) + .arg( useAsDefault ? "1" : "0" ) + .arg( QgsSqliteUtils::quotedString( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.username() ) ) + .arg( uiFileColumn ) + .arg( uiFileValue ); QString checkQuery = QString( "SELECT styleName" " FROM layer_styles" @@ -6279,10 +6159,10 @@ bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString " AND f_table_name=%2" " AND f_geometry_column=%3" " AND styleName=%4" ) - .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) - .arg( QgsSqliteUtils::quotedString( styleName.isEmpty() ? dsUri.table() : styleName ) ); + .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) + .arg( QgsSqliteUtils::quotedString( styleName.isEmpty() ? dsUri.table() : styleName ) ); ret = sqlite3_get_table( sqliteHandle, checkQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( SQLITE_OK != ret ) @@ -6306,15 +6186,15 @@ bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString " AND f_table_name=%7" " AND f_geometry_column=%8" " AND styleName=%9" ) - .arg( useAsDefault ? "1" : "0" ) - .arg( QgsSqliteUtils::quotedString( qmlStyle ) ) - .arg( QgsSqliteUtils::quotedString( sldStyle ) ) - .arg( QgsSqliteUtils::quotedString( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.username() ) ) - .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) - .arg( QgsSqliteUtils::quotedString( styleName.isEmpty() ? dsUri.table() : styleName ) ); + .arg( useAsDefault ? "1" : "0" ) + .arg( QgsSqliteUtils::quotedString( qmlStyle ) ) + .arg( QgsSqliteUtils::quotedString( sldStyle ) ) + .arg( QgsSqliteUtils::quotedString( styleDescription.isEmpty() ? QDateTime::currentDateTime().toString() : styleDescription ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.username() ) ) + .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ) + .arg( QgsSqliteUtils::quotedString( styleName.isEmpty() ? dsUri.table() : styleName ) ); } if ( useAsDefault ) @@ -6324,13 +6204,13 @@ bool QgsSpatiaLiteProviderMetadata::saveStyle( const QString &uri, const QString " WHERE f_table_schema %1" " AND f_table_name=%2" " AND f_geometry_column=%3" ) - .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ); + .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ); sql = QStringLiteral( "BEGIN; %1; %2; COMMIT;" ).arg( removeDefaultSql, sql ); } - ret = QgsSpatiaLiteProvider::exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); + ret = QgsSpatiaLiteProvider::exec_sql( sqliteHandle, sql.toUtf8().constData(), uri, errMsg, QGS_QUERY_LOG_ORIGIN ); if ( SQLITE_OK != ret ) { QgsSqliteHandle::closeDb( handle ); @@ -6386,9 +6266,9 @@ QString QgsSpatiaLiteProviderMetadata::loadStoredStyle( const QString &uri, QStr " AND f_geometry_column %3" " ORDER BY CASE WHEN useAsDefault THEN 1 ELSE 2 END" ",update_time DESC LIMIT 1" ) - .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( geomColumnExpr ); + .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( geomColumnExpr ); char **results = nullptr; int rows; @@ -6402,16 +6282,15 @@ QString QgsSpatiaLiteProviderMetadata::loadStoredStyle( const QString &uri, QStr return QString(); } - styleName = ( rows == 1 ) ? QString::fromUtf8( results[( rows * columns ) + 0 ] ) : QString(); - QString style = ( rows == 1 ) ? QString::fromUtf8( results[( rows * columns ) + 1 ] ) : QString(); + styleName = ( rows == 1 ) ? QString::fromUtf8( results[( rows * columns ) + 0] ) : QString(); + QString style = ( rows == 1 ) ? QString::fromUtf8( results[( rows * columns ) + 1] ) : QString(); sqlite3_free_table( results ); QgsSqliteHandle::closeDb( handle ); return style; } -int QgsSpatiaLiteProviderMetadata::listStyles( const QString &uri, QStringList &ids, QStringList &names, - QStringList &descriptions, QString &errCause ) +int QgsSpatiaLiteProviderMetadata::listStyles( const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause ) { QgsDataSourceUri dsUri( uri ); QString sqlitePath = dsUri.database(); @@ -6446,7 +6325,7 @@ int QgsSpatiaLiteProviderMetadata::listStyles( const QString &uri, QStringList & int howMany = 0; if ( 1 == rows ) { - howMany = atoi( results[( rows * columns ) + 0 ] ); + howMany = atoi( results[( rows * columns ) + 0] ); } sqlite3_free_table( results ); @@ -6459,14 +6338,14 @@ int QgsSpatiaLiteProviderMetadata::listStyles( const QString &uri, QStringList & // get them QString selectRelatedQuery = QStringLiteral( "SELECT id,styleName,description" - " FROM layer_styles" - " WHERE f_table_schema %1" - " AND f_table_name=%2" - " AND f_geometry_column=%3" - " ORDER BY useasdefault DESC, update_time DESC" ) - .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ); + " FROM layer_styles" + " WHERE f_table_schema %1" + " AND f_table_name=%2" + " AND f_geometry_column=%3" + " ORDER BY useasdefault DESC, update_time DESC" ) + .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ); ret = sqlite3_get_table( sqliteHandle, selectRelatedQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( SQLITE_OK != ret ) @@ -6479,19 +6358,19 @@ int QgsSpatiaLiteProviderMetadata::listStyles( const QString &uri, QStringList & int numberOfRelatedStyles = rows; for ( int i = 1; i <= rows; i++ ) { - ids.append( results[( i * columns ) + 0 ] ); - names.append( QString::fromUtf8( results[( i * columns ) + 1 ] ) ); - descriptions.append( QString::fromUtf8( results[( i * columns ) + 2 ] ) ); + ids.append( results[( i * columns ) + 0] ); + names.append( QString::fromUtf8( results[( i * columns ) + 1] ) ); + descriptions.append( QString::fromUtf8( results[( i * columns ) + 2] ) ); } sqlite3_free_table( results ); QString selectOthersQuery = QStringLiteral( "SELECT id,styleName,description" - " FROM layer_styles" - " WHERE NOT (f_table_schema %1 AND f_table_name=%2 AND f_geometry_column=%3)" - " ORDER BY update_time DESC" ) - .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) - .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ); + " FROM layer_styles" + " WHERE NOT (f_table_schema %1 AND f_table_name=%2 AND f_geometry_column=%3)" + " ORDER BY update_time DESC" ) + .arg( QgsSpatiaLiteProvider::tableSchemaCondition( dsUri ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.table() ) ) + .arg( QgsSqliteUtils::quotedString( dsUri.geometryColumn() ) ); ret = sqlite3_get_table( sqliteHandle, selectOthersQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg ); if ( SQLITE_OK != ret ) @@ -6503,9 +6382,9 @@ int QgsSpatiaLiteProviderMetadata::listStyles( const QString &uri, QStringList & for ( int i = 1; i <= rows; i++ ) { - ids.append( results[( i * columns ) + 0 ] ); - names.append( QString::fromUtf8( results[( i * columns ) + 1 ] ) ); - descriptions.append( QString::fromUtf8( results[( i * columns ) + 2 ] ) ); + ids.append( results[( i * columns ) + 0] ); + names.append( QString::fromUtf8( results[( i * columns ) + 1] ) ); + descriptions.append( QString::fromUtf8( results[( i * columns ) + 2] ) ); } sqlite3_free_table( results ); @@ -6540,7 +6419,7 @@ QString QgsSpatiaLiteProviderMetadata::getStyleById( const QString &uri, const Q if ( SQLITE_OK == ret ) { if ( 1 == rows ) - style = QString::fromUtf8( results[( rows * columns ) + 0 ] ); + style = QString::fromUtf8( results[( rows * columns ) + 0] ); else errCause = QObject::tr( "Consistency error in table '%1'. Style id should be unique" ).arg( QLatin1String( "layer_styles" ) ); } @@ -6562,9 +6441,8 @@ void QgsSpatiaLiteProviderMetadata::cleanupProvider() } - -QgsSpatiaLiteProviderMetadata::QgsSpatiaLiteProviderMetadata(): - QgsProviderMetadata( QgsSpatiaLiteProvider::SPATIALITE_KEY, QgsSpatiaLiteProvider::SPATIALITE_DESCRIPTION ) +QgsSpatiaLiteProviderMetadata::QgsSpatiaLiteProviderMetadata() + : QgsProviderMetadata( QgsSpatiaLiteProvider::SPATIALITE_KEY, QgsSpatiaLiteProvider::SPATIALITE_DESCRIPTION ) { } @@ -6573,7 +6451,7 @@ QIcon QgsSpatiaLiteProviderMetadata::icon() const return QgsApplication::getThemeIcon( QStringLiteral( "mIconSpatialite.svg" ) ); } -QList< QgsDataItemProvider * > QgsSpatiaLiteProviderMetadata::dataItemProviders() const +QList QgsSpatiaLiteProviderMetadata::dataItemProviders() const { QList providers; providers << new QgsSpatiaLiteDataItemProvider; @@ -6582,15 +6460,14 @@ QList< QgsDataItemProvider * > QgsSpatiaLiteProviderMetadata::dataItemProviders( QgsTransaction *QgsSpatiaLiteProviderMetadata::createTransaction( const QString &connString ) { - const QgsDataSourceUri dsUri{ connString }; + const QgsDataSourceUri dsUri { connString }; // Cannot use QgsSpatiaLiteConnPool::instance()->acquireConnection( dsUri.database() ) }; // because it will return a read only connection, use the (cached) connection from the // layers instead. QgsSqliteHandle *ds { QgsSqliteHandle::openDb( dsUri.database() ) }; if ( !ds ) { - QgsMessageLog::logMessage( QObject::tr( "Cannot open transaction on %1, since it is not currently opened" ).arg( connString ), - QObject::tr( "spatialite" ), Qgis::MessageLevel::Critical ); + QgsMessageLog::logMessage( QObject::tr( "Cannot open transaction on %1, since it is not currently opened" ).arg( connString ), QObject::tr( "spatialite" ), Qgis::MessageLevel::Critical ); return nullptr; } return new QgsSpatiaLiteTransaction( connString, ds ); @@ -6598,7 +6475,7 @@ QgsTransaction *QgsSpatiaLiteProviderMetadata::createTransaction( const QString QMap QgsSpatiaLiteProviderMetadata::connections( bool cached ) { - return connectionsProtected< QgsSpatiaLiteProviderConnection, QgsSpatiaLiteConnection>( cached ); + return connectionsProtected( cached ); } QgsAbstractProviderConnection *QgsSpatiaLiteProviderMetadata::createConnection( const QString &connName ) diff --git a/src/providers/spatialite/qgsspatialiteprovider.h b/src/providers/spatialite/qgsspatialiteprovider.h index d43420182ec9..abce06eeeacd 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.h +++ b/src/providers/spatialite/qgsspatialiteprovider.h @@ -48,12 +48,11 @@ class QgsTransaction; * interface defined in the QgsDataProvider class to provide access to spatial * data residing in a SQLite/SpatiaLite enabled database. */ -class QgsSpatiaLiteProvider final: public QgsVectorDataProvider +class QgsSpatiaLiteProvider final : public QgsVectorDataProvider { Q_OBJECT public: - static const QString SPATIALITE_KEY; static const QString SPATIALITE_DESCRIPTION; @@ -76,7 +75,7 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider */ explicit QgsSpatiaLiteProvider( QString const &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ); - ~ QgsSpatiaLiteProvider() override; + ~QgsSpatiaLiteProvider() override; Qgis::DataProviderFlags flags() const override; QgsAbstractFeatureSource *featureSource() const override; @@ -107,8 +106,7 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider QVariant minimumValue( int index ) const override; QVariant maximumValue( int index ) const override; QSet uniqueValues( int index, int limit = -1 ) const override; - QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1, - QgsFeedback *feedback = nullptr ) const override; + QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1, QgsFeedback *feedback = nullptr ) const override; bool isValid() const override; Qgis::ProviderStyleStorageCapabilities styleStorageCapabilities() const override; @@ -146,20 +144,21 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider static QString providerKey(); // static functions - static void convertToGeosWKB( const unsigned char *blob, int blob_size, - unsigned char **wkb, int *geom_size ); - static int computeMultiWKB3Dsize( const unsigned char *p_in, int little_endian, - int endian_arch ); + static void convertToGeosWKB( const unsigned char *blob, int blob_size, unsigned char **wkb, int *geom_size ); + static int computeMultiWKB3Dsize( const unsigned char *p_in, int little_endian, int endian_arch ); - struct SLFieldNotFound {}; //! Exception to throw + struct SLFieldNotFound + {}; //! Exception to throw struct SLException { - explicit SLException( char *msg ) : errMsg( msg ) + explicit SLException( char *msg ) + : errMsg( msg ) { } - SLException( const SLException &e ) : errMsg( e.errMsg ) + SLException( const SLException &e ) + : errMsg( e.errMsg ) { } @@ -178,7 +177,6 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider private: char *errMsg = nullptr; - }; //! Check if version is above major and minor @@ -196,7 +194,6 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider static int exec_sql( sqlite3 *handle, const QString &sql, const QString &uri, char *errMsg = nullptr, const QString &origin = QString() ); private: - //! Loads fields from input file to member mAttributeFields void loadFields(); @@ -358,37 +355,18 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider bool getTableSummaryAbstractInterface( gaiaVectorLayerPtr lyr ); void loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr ); void getViewSpatialIndexName(); - bool prepareStatement( sqlite3_stmt *&stmt, - const QgsAttributeList &fetchAttributes, - bool fetchGeometry, - QString whereClause ); - bool getFeature( sqlite3_stmt *stmt, bool fetchGeometry, - QgsFeature &feature, - const QgsAttributeList &fetchAttributes ); + bool prepareStatement( sqlite3_stmt *&stmt, const QgsAttributeList &fetchAttributes, bool fetchGeometry, QString whereClause ); + bool getFeature( sqlite3_stmt *stmt, bool fetchGeometry, QgsFeature &feature, const QgsAttributeList &fetchAttributes ); void updatePrimaryKeyCapabilities(); - int computeSizeFromMultiWKB2D( const unsigned char *p_in, int nDims, - int little_endian, - int endian_arch ); - int computeSizeFromMultiWKB3D( const unsigned char *p_in, int nDims, - int little_endian, - int endian_arch ); - void convertFromGeosWKB2D( const unsigned char *blob, int blob_size, - unsigned char *wkb, int geom_size, - int nDims, int little_endian, int endian_arch ); - void convertFromGeosWKB3D( const unsigned char *blob, int blob_size, - unsigned char *wkb, int geom_size, - int nDims, int little_endian, int endian_arch ); - void convertFromGeosWKB( const unsigned char *blob, int blob_size, - unsigned char **wkb, int *geom_size, - int dims ); - int computeSizeFromGeosWKB3D( const unsigned char *blob, int size, - Qgis::WkbType type, int nDims, int little_endian, - int endian_arch ); - int computeSizeFromGeosWKB2D( const unsigned char *blob, int size, - Qgis::WkbType type, int nDims, int little_endian, - int endian_arch ); + int computeSizeFromMultiWKB2D( const unsigned char *p_in, int nDims, int little_endian, int endian_arch ); + int computeSizeFromMultiWKB3D( const unsigned char *p_in, int nDims, int little_endian, int endian_arch ); + void convertFromGeosWKB2D( const unsigned char *blob, int blob_size, unsigned char *wkb, int geom_size, int nDims, int little_endian, int endian_arch ); + void convertFromGeosWKB3D( const unsigned char *blob, int blob_size, unsigned char *wkb, int geom_size, int nDims, int little_endian, int endian_arch ); + void convertFromGeosWKB( const unsigned char *blob, int blob_size, unsigned char **wkb, int *geom_size, int dims ); + int computeSizeFromGeosWKB3D( const unsigned char *blob, int size, Qgis::WkbType type, int nDims, int little_endian, int endian_arch ); + int computeSizeFromGeosWKB2D( const unsigned char *blob, int size, Qgis::WkbType type, int nDims, int little_endian, int endian_arch ); void fetchConstraints(); @@ -402,7 +380,7 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider /** * Returns the sqlite handle to be used, if we are inside a transaction it will be the transaction's handle */ - sqlite3 *sqliteHandle( ) const; + sqlite3 *sqliteHandle() const; static QString createIndexName( QString tableName, QString field ); @@ -413,10 +391,9 @@ class QgsSpatiaLiteProvider final: public QgsVectorDataProvider virtual QString defaultValueClause( int fieldIndex ) const override; Qgis::VectorLayerTypeFlags vectorLayerTypeFlags() const override; - }; -class QgsSpatiaLiteProviderMetadata final: public QgsProviderMetadata +class QgsSpatiaLiteProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: @@ -426,27 +403,21 @@ class QgsSpatiaLiteProviderMetadata final: public QgsProviderMetadata void cleanupProvider() override; QString getStyleById( const QString &uri, const QString &styleId, QString &errCause ) override; bool styleExists( const QString &uri, const QString &styleId, QString &errorCause ) override; - bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, - const QString &styleName, const QString &styleDescription, - const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; + bool saveStyle( const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause ) override; QString loadStyle( const QString &uri, QString &errCause ) override; virtual QString loadStoredStyle( const QString &uri, QString &styleName, QString &errCause ) override; - int listStyles( const QString &uri, QStringList &ids, QStringList &names, - QStringList &descriptions, QString &errCause ) override; + int listStyles( const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause ) override; QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; QString absoluteToRelativeUri( const QString &uri, const QgsReadWriteContext &context ) const override; QString relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const override; ProviderCapabilities providerCapabilities() const override; QgsSpatiaLiteProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; - Qgis::VectorExportResult createEmptyLayer( const QString &uri, const QgsFields &fields, - Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, - bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, - const QMap *options ) override; + Qgis::VectorExportResult createEmptyLayer( const QString &uri, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, QMap &oldToNewAttrIdxMap, QString &errorMessage, const QMap *options ) override; bool createDb( const QString &dbPath, QString &errCause ) override; - QList< QgsDataItemProvider * > dataItemProviders() const override; + QList dataItemProviders() const override; // QgsProviderMetadata interface public: @@ -457,7 +428,6 @@ class QgsSpatiaLiteProviderMetadata final: public QgsProviderMetadata QgsTransaction *createTransaction( const QString &connString ) override; protected: - QgsAbstractProviderConnection *createConnection( const QString &uri, const QVariantMap &configuration ) override; }; diff --git a/src/providers/spatialite/qgsspatialiteproviderconnection.cpp b/src/providers/spatialite/qgsspatialiteproviderconnection.cpp index 636e346b077b..075e285802e9 100644 --- a/src/providers/spatialite/qgsspatialiteproviderconnection.cpp +++ b/src/providers/spatialite/qgsspatialiteproviderconnection.cpp @@ -46,8 +46,8 @@ QgsSpatiaLiteProviderConnection::QgsSpatiaLiteProviderConnection( const QString setUri( dsUri.uri() ); } -QgsSpatiaLiteProviderConnection::QgsSpatiaLiteProviderConnection( const QString &uri, const QVariantMap &configuration ): - QgsAbstractDatabaseProviderConnection( uri, configuration ) +QgsSpatiaLiteProviderConnection::QgsSpatiaLiteProviderConnection( const QString &uri, const QVariantMap &configuration ) + : QgsAbstractDatabaseProviderConnection( uri, configuration ) { mProviderKey = QStringLiteral( "spatialite" ); QgsDataSourceUri dsUri { uri }; @@ -78,38 +78,32 @@ void QgsSpatiaLiteProviderConnection::remove( const QString &name ) const QString QgsSpatiaLiteProviderConnection::tableUri( const QString &schema, const QString &name ) const { - Q_UNUSED( schema ); // spatialite does not support schema + Q_UNUSED( schema ); // spatialite does not support schema return uri() + QStringLiteral( " table=%1" ).arg( QgsSqliteUtils::quotedIdentifier( name ) ); } -void QgsSpatiaLiteProviderConnection::createVectorTable( const QString &schema, - const QString &name, - const QgsFields &fields, - Qgis::WkbType wkbType, - const QgsCoordinateReferenceSystem &srs, - bool overwrite, - const QMap *options ) const +void QgsSpatiaLiteProviderConnection::createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap *options ) const { checkCapability( Capability::CreateVectorTable ); - if ( ! schema.isEmpty() ) + if ( !schema.isEmpty() ) { QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::MessageLevel::Info ); } QMap opts { *options }; - opts[ QStringLiteral( "layerName" ) ] = QVariant( name ); - opts[ QStringLiteral( "update" ) ] = true; + opts[QStringLiteral( "layerName" )] = QVariant( name ); + opts[QStringLiteral( "update" )] = true; QMap map; QString errCause; Qgis::VectorExportResult res = QgsSpatiaLiteProvider::createEmptyLayer( - uri() + QStringLiteral( " table=%1 (geom)" ).arg( QgsSqliteUtils::quotedIdentifier( name ) ), - fields, - wkbType, - srs, - overwrite, - &map, - &errCause, - &opts - ); + uri() + QStringLiteral( " table=%1 (geom)" ).arg( QgsSqliteUtils::quotedIdentifier( name ) ), + fields, + wkbType, + srs, + overwrite, + &map, + &errCause, + &opts + ); if ( res != Qgis::VectorExportResult::Success ) { throw QgsProviderConnectionException( QObject::tr( "An error occurred while creating the vector layer: %1" ).arg( errCause ) ); @@ -137,23 +131,23 @@ QgsVectorLayer *QgsSpatiaLiteProviderConnection::createSqlVectorLayer( const Qgs throw QgsProviderConnectionException( QObject::tr( "Could not create a SQL vector layer: SQL expression is empty." ) ); } - QgsDataSourceUri tUri( uri( ) ); + QgsDataSourceUri tUri( uri() ); tUri.setSql( options.filter ); tUri.setTable( '(' + options.sql + ')' ); - if ( ! options.geometryColumn.isEmpty() ) + if ( !options.geometryColumn.isEmpty() ) { tUri.setGeometryColumn( options.geometryColumn ); } - return new QgsVectorLayer{ tUri.uri( false ), options.layerName.isEmpty() ? QStringLiteral( "QueryLayer" ) : options.layerName, providerKey() }; + return new QgsVectorLayer { tUri.uri( false ), options.layerName.isEmpty() ? QStringLiteral( "QueryLayer" ) : options.layerName, providerKey() }; } void QgsSpatiaLiteProviderConnection::dropVectorTable( const QString &schema, const QString &name ) const { checkCapability( Capability::DropVectorTable ); - if ( ! schema.isEmpty() ) + if ( !schema.isEmpty() ) { QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::MessageLevel::Info ); } @@ -183,13 +177,13 @@ void QgsSpatiaLiteProviderConnection::dropVectorTable( const QString &schema, co if ( ret != SQLITE_OK ) { QgsDebugError( QStringLiteral( "Failed to run VACUUM after deleting table on database %1" ) - .arg( pathFromUri() ) ); + .arg( pathFromUri() ) ); } QgsSqliteHandle::closeDb( hndl ); } } - if ( ! errCause.isEmpty() ) + if ( !errCause.isEmpty() ) { throw QgsProviderConnectionException( QObject::tr( "Error deleting vector/aspatial table %1: %2" ).arg( name, errCause ) ); } @@ -199,22 +193,19 @@ void QgsSpatiaLiteProviderConnection::dropVectorTable( const QString &schema, co void QgsSpatiaLiteProviderConnection::renameVectorTable( const QString &schema, const QString &name, const QString &newName ) const { checkCapability( Capability::RenameVectorTable ); - if ( ! schema.isEmpty() ) + if ( !schema.isEmpty() ) { QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::MessageLevel::Info ); } // TODO: maybe an index? QString sql( QStringLiteral( "ALTER TABLE %1 RENAME TO %2" ) - .arg( QgsSqliteUtils::quotedIdentifier( name ), - QgsSqliteUtils::quotedIdentifier( newName ) ) ); + .arg( QgsSqliteUtils::quotedIdentifier( name ), QgsSqliteUtils::quotedIdentifier( newName ) ) ); executeSqlDirect( sql ); sql = QStringLiteral( "UPDATE geometry_columns SET f_table_name = lower(%2) WHERE lower(f_table_name) = lower(%1)" ) - .arg( QgsSqliteUtils::quotedString( name ), - QgsSqliteUtils::quotedString( newName ) ); + .arg( QgsSqliteUtils::quotedString( name ), QgsSqliteUtils::quotedString( newName ) ); executeSqlDirect( sql ); sql = QStringLiteral( "UPDATE layer_styles SET f_table_name = lower(%2) WHERE f_table_name = lower(%1)" ) - .arg( QgsSqliteUtils::quotedString( name ), - QgsSqliteUtils::quotedString( newName ) ); + .arg( QgsSqliteUtils::quotedString( name ), QgsSqliteUtils::quotedString( newName ) ); try { executeSqlDirect( sql ); @@ -235,7 +226,7 @@ void QgsSpatiaLiteProviderConnection::vacuum( const QString &schema, const QStri { Q_UNUSED( name ) checkCapability( Capability::Vacuum ); - if ( ! schema.isEmpty() ) + if ( !schema.isEmpty() ) { QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::MessageLevel::Info ); } @@ -244,10 +235,9 @@ void QgsSpatiaLiteProviderConnection::vacuum( const QString &schema, const QStri void QgsSpatiaLiteProviderConnection::createSpatialIndex( const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options ) const { - checkCapability( Capability::CreateSpatialIndex ); - if ( ! schema.isEmpty() ) + if ( !schema.isEmpty() ) { QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::MessageLevel::Info ); } @@ -272,27 +262,26 @@ void QgsSpatiaLiteProviderConnection::createSpatialIndex( const QString &schema, throw QgsProviderConnectionException( QObject::tr( "Geometry column name not specified while creating spatial index" ) ); } - executeSqlPrivate( QStringLiteral( "SELECT CreateSpatialIndex(%1, %2)" ).arg( QgsSqliteUtils::quotedString( name ), - QgsSqliteUtils::quotedString( ( geometryColumnName ) ) ) ); + executeSqlPrivate( QStringLiteral( "SELECT CreateSpatialIndex(%1, %2)" ).arg( QgsSqliteUtils::quotedString( name ), QgsSqliteUtils::quotedString( ( geometryColumnName ) ) ) ); } bool QgsSpatiaLiteProviderConnection::spatialIndexExists( const QString &schema, const QString &name, const QString &geometryColumn ) const { checkCapability( Capability::CreateSpatialIndex ); - if ( ! schema.isEmpty() ) + if ( !schema.isEmpty() ) { QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::MessageLevel::Info ); } const QList res = executeSqlPrivate( QStringLiteral( "SELECT spatial_index_enabled FROM geometry_columns WHERE lower(f_table_name) = lower(%1) AND lower(f_geometry_column) = lower(%2)" ) - .arg( QgsSqliteUtils::quotedString( name ), - QgsSqliteUtils::quotedString( geometryColumn ) ) ).rows(); + .arg( QgsSqliteUtils::quotedString( name ), QgsSqliteUtils::quotedString( geometryColumn ) ) ) + .rows(); return !res.isEmpty() && !res.at( 0 ).isEmpty() && res.at( 0 ).at( 0 ).toInt() == 1; } QList QgsSpatiaLiteProviderConnection::tables( const QString &schema, const TableFlags &flags, QgsFeedback *feedback ) const { checkCapability( Capability::Tables ); - if ( ! schema.isEmpty() ) + if ( !schema.isEmpty() ) { QgsMessageLog::logMessage( QStringLiteral( "Schema is not supported by Spatialite, ignoring" ), QStringLiteral( "OGR" ), Qgis::MessageLevel::Info ); } @@ -332,7 +321,6 @@ QList QgsSpatiaLiteProviderConne } else { - const QString connectionInfo = QStringLiteral( "dbname='%1'" ).arg( QString( connection.path() ).replace( '\'', QLatin1String( "\\'" ) ) ); QgsDataSourceUri dsUri( connectionInfo ); @@ -366,7 +354,7 @@ QList QgsSpatiaLiteProviderConne property.setTableName( tableName ); // Create a layer and get information from it // Use OGR because it's way faster - std::unique_ptr< QgsVectorLayer > vl = std::make_unique( dsUri.database() + "|layername=" + dsUri.table(), QString(), QLatin1String( "ogr" ), QgsVectorLayer::LayerOptions( false, true ) ); + std::unique_ptr vl = std::make_unique( dsUri.database() + "|layername=" + dsUri.table(), QString(), QLatin1String( "ogr" ), QgsVectorLayer::LayerOptions( false, true ) ); if ( vl->isValid() ) { if ( vl->isSpatial() ) @@ -374,12 +362,12 @@ QList QgsSpatiaLiteProviderConne property.setGeometryColumnCount( 1 ); property.setGeometryColumn( entry.column ); property.setFlag( QgsSpatiaLiteProviderConnection::TableFlag::Vector ); - property.setGeometryColumnTypes( {{ vl->wkbType(), vl->crs() }} ); + property.setGeometryColumnTypes( { { vl->wkbType(), vl->crs() } } ); } else { property.setGeometryColumnCount( 0 ); - property.setGeometryColumnTypes( {{ Qgis::WkbType::NoGeometry, QgsCoordinateReferenceSystem() }} ); + property.setGeometryColumnTypes( { { Qgis::WkbType::NoGeometry, QgsCoordinateReferenceSystem() } } ); property.setFlag( QgsSpatiaLiteProviderConnection::TableFlag::Aspatial ); } @@ -397,7 +385,7 @@ QList QgsSpatiaLiteProviderConne pkNames.append( vl->fields().at( pkIdx ).name() ); } - if ( ! pkNames.isEmpty() ) + if ( !pkNames.isEmpty() ) { property.setPrimaryKeyColumns( pkNames ); } @@ -416,19 +404,19 @@ QList QgsSpatiaLiteProviderConne errCause = ex.what(); } - if ( ! errCause.isEmpty() ) + if ( !errCause.isEmpty() ) { throw QgsProviderConnectionException( QObject::tr( "Error listing tables from %1: %2" ).arg( pathFromUri(), errCause ) ); } // Filters if ( flags ) { - tableInfo.erase( std::remove_if( tableInfo.begin(), tableInfo.end(), [ & ]( const QgsAbstractDatabaseProviderConnection::TableProperty & ti ) - { - return !( ti.flags() & flags ); - } ), tableInfo.end() ); + tableInfo.erase( std::remove_if( tableInfo.begin(), tableInfo.end(), [&]( const QgsAbstractDatabaseProviderConnection::TableProperty &ti ) { + return !( ti.flags() & flags ); + } ), + tableInfo.end() ); } - return tableInfo ; + return tableInfo; } QIcon QgsSpatiaLiteProviderConnection::icon() const @@ -438,8 +426,7 @@ QIcon QgsSpatiaLiteProviderConnection::icon() const void QgsSpatiaLiteProviderConnection::setDefaultCapabilities() { - mCapabilities = - { + mCapabilities = { Capability::Tables, Capability::CreateVectorTable, Capability::DropVectorTable, @@ -454,25 +441,21 @@ void QgsSpatiaLiteProviderConnection::setDefaultCapabilities() Capability::AddField, Capability::SqlLayers, }; - mGeometryColumnCapabilities = - { + mGeometryColumnCapabilities = { GeometryColumnCapability::Z, GeometryColumnCapability::M, GeometryColumnCapability::SinglePoint, GeometryColumnCapability::SingleLineString, GeometryColumnCapability::SinglePolygon, }; - mSqlLayerDefinitionCapabilities = - { + mSqlLayerDefinitionCapabilities = { Qgis::SqlLayerDefinitionCapability::SubsetStringFilter, Qgis::SqlLayerDefinitionCapability::GeometryColumn }; - } QgsAbstractDatabaseProviderConnection::QueryResult QgsSpatiaLiteProviderConnection::executeSqlPrivate( const QString &sql, QgsFeedback *feedback ) const { - QgsDatabaseQueryLogWrapper logWrapper( sql, uri(), providerKey(), QStringLiteral( "QgsSpatiaLiteProviderConnection" ), QGS_QUERY_LOG_ORIGIN ); if ( feedback && feedback->isCanceled() ) @@ -485,7 +468,6 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsSpatiaLiteProviderConnecti gdal::dataset_unique_ptr hDS( GDALOpenEx( pathFromUri().toUtf8().constData(), GDAL_OF_VECTOR | GDAL_OF_UPDATE, nullptr, nullptr, nullptr ) ); if ( hDS ) { - if ( feedback && feedback->isCanceled() ) { logWrapper.setCanceled(); @@ -499,7 +481,6 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsSpatiaLiteProviderConnecti // Read fields if ( ogrLayer ) { - auto iterator = std::make_shared( std::move( hDS ), ogrLayer ); QgsAbstractDatabaseProviderConnection::QueryResult results( iterator ); results.setQueryExecutionTime( std::chrono::duration_cast( end - begin ).count() ); @@ -507,7 +488,6 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsSpatiaLiteProviderConnecti gdal::ogr_feature_unique_ptr fet; if ( fet.reset( OGR_L_GetNextFeature( ogrLayer ) ), fet ) { - const QgsFields fields { QgsOgrUtils::readOgrFields( fet.get(), QTextCodec::codecForName( "UTF-8" ) ) }; // geom column name @@ -534,7 +514,7 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsSpatiaLiteProviderConnecti } // Append geom - if ( ! geomColumnName.isEmpty() ) + if ( !geomColumnName.isEmpty() ) { results.appendColumn( geomColumnName ); iterator->setGeometryColumnName( geomColumnName ); @@ -546,10 +526,10 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsSpatiaLiteProviderConnecti // Check for errors if ( CE_Failure == CPLGetLastErrorType() || CE_Fatal == CPLGetLastErrorType() ) { - errCause = CPLGetLastErrorMsg( ); + errCause = CPLGetLastErrorMsg(); } - if ( ! errCause.isEmpty() ) + if ( !errCause.isEmpty() ) { logWrapper.setError( errCause ); throw QgsProviderConnectionException( QObject::tr( "Error executing SQL statement %1: %2" ).arg( sql, errCause ) ); @@ -563,9 +543,8 @@ QgsAbstractDatabaseProviderConnection::QueryResult QgsSpatiaLiteProviderConnecti // Check for errors if ( CE_Failure == CPLGetLastErrorType() || CE_Fatal == CPLGetLastErrorType() ) { - errCause = CPLGetLastErrorMsg( ); + errCause = CPLGetLastErrorMsg(); } - } else { @@ -622,21 +601,20 @@ QVariantList QgsSpatialiteProviderResultIterator::nextRowInternal() gdal::ogr_feature_unique_ptr fet; if ( fet.reset( OGR_L_GetNextFeature( mOgrLayer ) ), fet ) { - if ( ! mFields.isEmpty() ) + if ( !mFields.isEmpty() ) { QgsFeature f { QgsOgrUtils::readOgrFeature( fet.get(), mFields, QTextCodec::codecForName( "UTF-8" ) ) }; - const QgsAttributes constAttrs = f.attributes(); + const QgsAttributes constAttrs = f.attributes(); for ( const QVariant &attribute : constAttrs ) { row.push_back( attribute ); } // Geom goes last - if ( ! mGeometryColumnName.isEmpty( ) ) + if ( !mGeometryColumnName.isEmpty() ) { row.push_back( f.geometry().asWkt() ); } - } else // Fallback to strings { @@ -670,7 +648,7 @@ void QgsSpatialiteProviderResultIterator::setGeometryColumnName( const QString & bool QgsSpatialiteProviderResultIterator::hasNextRowPrivate() const { - return ! mNextRow.isEmpty(); + return !mNextRow.isEmpty(); } bool QgsSpatiaLiteProviderConnection::executeSqlDirect( const QString &sql ) const @@ -719,438 +697,406 @@ QMultiMap QgsSpatiaLiteProviderConnection */ return QgsAbstractDatabaseProviderConnection::sqlDictionary().unite( - { - { - Qgis::SqlKeywordCategory::Math, { - // SQL math functions - QStringLiteral( "Abs( x [Double precision] )" ), - QStringLiteral( "Acos( x [Double precision] )" ), - QStringLiteral( "Asin( x [Double precision] )" ), - QStringLiteral( "Atan( x [Double precision] )" ), - QStringLiteral( "Ceil( x [Double precision] )" ), - QStringLiteral( "Cos( x [Double precision] )" ), - QStringLiteral( "Cot( x [Double precision] )" ), - QStringLiteral( "Degrees( x [Double precision] )" ), - QStringLiteral( "Exp( x [Double precision] )" ), - QStringLiteral( "Floor( x [Double precision] )" ), - QStringLiteral( "Ln( x [Double precision] )" ), - QStringLiteral( "Log( b [Double precision] , x [Double precision] )" ), - QStringLiteral( "Log2( x [Double precision] )" ), - QStringLiteral( "Log10( x [Double precision] )" ), - QStringLiteral( "PI( void )" ), - QStringLiteral( "Pow( x [Double precision] , y [Double precision] )" ), - QStringLiteral( "Radians( x [Double precision] )" ), - QStringLiteral( "Sign( x [Double precision] )" ), - QStringLiteral( "Sin( x [Double precision] )" ), - QStringLiteral( "Sqrt( x [Double precision] )" ), - QStringLiteral( "Stddev_pop( x [Double precision] )" ), - QStringLiteral( "Stddev_samp( x [Double precision] )" ), - QStringLiteral( "Tan( x [Double precision] )" ), - QStringLiteral( "Var_pop( x [Double precision] )" ), - QStringLiteral( "Var_samp( x [Double precision] )" ) - } - }, - { - Qgis::SqlKeywordCategory::Function, { - - // Specific - QStringLiteral( "last_insert_rowid" ), - - // SQL Version Info [and build options testing] functions - QStringLiteral( "spatialite_version( void )" ), - QStringLiteral( "spatialite_target_cpu( void )" ), - QStringLiteral( "proj4_version( void )" ), - QStringLiteral( "geos_version( void )" ), - QStringLiteral( "lwgeom_version( void )" ), - QStringLiteral( "libxml2_version( void )" ), - QStringLiteral( "HasIconv( void )" ), - QStringLiteral( "HasMathSQL( void )" ), - QStringLiteral( "HasGeoCallbacks( void )" ), - QStringLiteral( "HasProj( void )" ), - QStringLiteral( "HasGeos( void )" ), - QStringLiteral( "HasGeosAdvanced( void )" ), - QStringLiteral( "HasGeosTrunk( void )" ), - QStringLiteral( "HasLwGeom( void )" ), - QStringLiteral( "HasLibXML2( void )" ), - QStringLiteral( "HasEpsg( void )" ), - QStringLiteral( "HasFreeXL( void )" ), - QStringLiteral( "HasGeoPackage( void )" ), - - // Generic SQL functions - QStringLiteral( "CastToInteger( value [Generic] )" ), - QStringLiteral( "CastToDouble( value [Generic] )" ), - QStringLiteral( "CastToText( value [Generic] )" ), - QStringLiteral( "CastToBlob( value [Generic] )" ), - QStringLiteral( "ForceAsNull( val1 [Generic] , val2 [Generic])" ), - QStringLiteral( "CreateUUID( void )" ), - QStringLiteral( "MD5Checksum( BLOB | TEXT )" ), - QStringLiteral( "MD5TotalChecksum( BLOB | TEXT )" ), - - // SQL utility functions for BLOB objects - QStringLiteral( "IsZipBlob( content [BLOB] )" ), - QStringLiteral( "IsPdfBlob( content [BLOB] )" ), - QStringLiteral( "IsGifBlob( image [BLOB] )" ), - QStringLiteral( "IsPngBlob( image [BLOB] )" ), - QStringLiteral( "IsTiffBlob( image [BLOB] )" ), - QStringLiteral( "IsJpegBlob( image [BLOB] )" ), - QStringLiteral( "IsExifBlob( image [BLOB] )" ), - QStringLiteral( "IsExifGpsBlob( image [BLOB] )" ), - QStringLiteral( "IsWebpBlob( image [BLOB] )" ), - QStringLiteral( "GetMimeType( payload [BLOB] )" ), - QStringLiteral( "BlobFromFile( filepath [String] )" ), - QStringLiteral( "BlobToFile( payload [BLOB] , filepath [String] )" ), - QStringLiteral( "CountUnsafeTriggers( )" ), - - // SQL functions supporting XmlBLOB - QStringLiteral( "XB_Create( xmlPayload [BLOB] )" ), - QStringLiteral( "XB_GetPayload( xmlObject [XmlBLOB] [ , indent [Integer] ] )" ), - QStringLiteral( "XB_GetDocument( xmlObject [XmlBLOB] [ , indent [Integer] ] )" ), - QStringLiteral( "XB_SchemaValidate( xmlObject [XmlBLOB] , schemaURI [Text] [ , compressed [Boolean] ] )" ), - QStringLiteral( "XB_Compress( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_Uncompress( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_IsValid( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_IsCompressed( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_IsSchemaValidated( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_IsIsoMetadata( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_IsSldSeVectorStyle( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_IsSldSeRasterStyle( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_IsSvg( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_GetDocumentSize( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_GetEncoding( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_GetSchemaURI( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_GetInternalSchemaURI( xmlPayload [BLOB] )" ), - QStringLiteral( "XB_GetFileId( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_SetFileId( xmlObject [XmlBLOB] , fileId [String] )" ), - QStringLiteral( "XB_AddFileId( xmlObject [XmlBLOB] , fileId [String] , IdNameSpacePrefix [String] , IdNameSpaceURI [String] , CsNameSpacePrefix [String] , CsNameSpaceURI [String] )" ), - QStringLiteral( "XB_GetParentId( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_SetParentId( xmlObject [XmlBLOB] , parentId [String] )" ), - QStringLiteral( "XB_AddParentId( xmlObject [XmlBLOB] , parentId [String] , IdNameSpacePrefix [String] , IdNameSpaceURI [String] , CsNameSpacePrefix [String] , CsNameSpaceURI [String] )" ), - QStringLiteral( "XB_GetTitle( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_GetAbstract( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_GetGeometry( xmlObject [XmlBLOB] )" ), - QStringLiteral( "XB_GetLastParseError( [void] )" ), - QStringLiteral( "XB_GetLastValidateError( [void] )" ), - QStringLiteral( "XB_IsValidXPathExpression( expr [Text] )" ), - QStringLiteral( "XB_GetLastXPathError( [void] )" ), - QStringLiteral( "XB_CacheFlush( [void] )" ), - QStringLiteral( "XB_LoadXML( filepath-or-URL [String] )" ), - QStringLiteral( "XB_StoreXML( XmlObject [XmlBLOB] , filepath [String] )" ), - - } - }, - { - Qgis::SqlKeywordCategory::Geospatial, { - // SQL functions reporting GEOS / LWGEOM errors and warnings - QStringLiteral( "GEOS_GetLastWarningMsg( [void] )" ), - QStringLiteral( "GEOS_GetLastErrorMsg( [void] )" ), - QStringLiteral( "GEOS_GetLastAuxErrorMsg( [void] )" ), - QStringLiteral( "GEOS_GetCriticalPointFromMsg( [void] )" ), - QStringLiteral( "LWGEOM_GetLastWarningMsg( [void] )" ), - QStringLiteral( "LWGEOM_GetLastErrorMsg( [void] )" ), - - // SQL length/distance unit-conversion functions - QStringLiteral( "CvtToKm( x [Double precision] )" ), - QStringLiteral( "CvtToDm( x [Double precision] )" ), - QStringLiteral( "CvtToCm( x [Double precision] )" ), - QStringLiteral( "CvtToMm( x [Double precision] )" ), - QStringLiteral( "CvtToKmi( x [Double precision] )" ), - QStringLiteral( "CvtToIn( x [Double precision] )" ), - QStringLiteral( "CvtToFt( x [Double precision] )" ), - QStringLiteral( "CvtToYd( x [Double precision] )" ), - QStringLiteral( "CvtToMi( x [Double precision] )" ), - QStringLiteral( "CvtToFath( x [Double precision] )" ), - QStringLiteral( "CvtToCh( x [Double precision] )" ), - QStringLiteral( "CvtToLink( x [Double precision] )" ), - QStringLiteral( "CvtToUsIn( x [Double precision] )" ), - QStringLiteral( "CvtToUsFt( x [Double precision] )" ), - QStringLiteral( "CvtToUsYd( x [Double precision] )" ), - QStringLiteral( "CvtToUsMi( x [Double precision] )" ), - QStringLiteral( "CvtToUsCh( x [Double precision] )" ), - QStringLiteral( "CvtToIndFt( x [Double precision] )" ), - QStringLiteral( "CvtToIndYd( x [Double precision] )" ), - QStringLiteral( "CvtToIndCh( x [Double precision] )" ), - - // SQL conversion functions from DD/DMS notations (longitude/latitude) - QStringLiteral( "LongLatToDMS( longitude [Double precision] , latitude [Double precision] )" ), - QStringLiteral( "LongitudeFromDMS( dms_expression [Sting] )" ), - - // SQL utility functions [ - QStringLiteral( "GeomFromExifGpsBlob( image [BLOB] )" ), - QStringLiteral( "ST_Point( x [Double precision] , y [Double precision] )" ), - QStringLiteral( "MakeLine( pt1 [PointGeometry] , pt2 [PointGeometry] )" ), - QStringLiteral( "MakeLine( geom [PointGeometry] )" ), - QStringLiteral( "MakeLine( geom [MultiPointGeometry] , direction [Boolean] )" ), - QStringLiteral( "SquareGrid( geom [ArealGeometry] , size [Double precision] [ , edges_only [Boolean] , [ origing [PointGeometry] ] ] )" ), - QStringLiteral( "TriangularGrid( geom [ArealGeometry] , size [Double precision] [ , edges_only [Boolean] , [ origing [PointGeometry] ] ] )" ), - QStringLiteral( "HexagonalGrid( geom [ArealGeometry] , size [Double precision] [ , edges_only [Boolean] , [ origing [PointGeometry] ] ] )" ), - QStringLiteral( "Extent( geom [Geometry] )" ), - QStringLiteral( "ToGARS( geom [Geometry] )" ), - QStringLiteral( "GARSMbr( code [String] )" ), - QStringLiteral( "MbrMinX( geom [Geometry])" ), - QStringLiteral( "MbrMinY( geom [Geometry])" ), - QStringLiteral( "MbrMaxX( geom [Geometry])" ), - QStringLiteral( "MbrMaxY( geom [Geometry])" ), - QStringLiteral( "ST_MinZ( geom [Geometry])" ), - QStringLiteral( "ST_MaxZ( geom [Geometry])" ), - QStringLiteral( "ST_MinM( geom [Geometry])" ), - QStringLiteral( "ST_MaxM( geom [Geometry])" ), - - // SQL functions for constructing a geometric object given its Well-known Text Representation - QStringLiteral( "GeomFromText( wkt [String] [ , SRID [Integer]] )" ), - QStringLiteral( "ST_WKTToSQL( wkt [String] )" ), - QStringLiteral( "PointFromText( wktPoint [String] [ , SRID [Integer]] )" ), - QStringLiteral( "LineFromText( wktLineString [String] [ , SRID [Integer]] )" ), - QStringLiteral( "PolyFromText( wktPolygon [String] [ , SRID [Integer]] )" ), - QStringLiteral( "MPointFromText( wktMultiPoint [String] [ , SRID [Integer]] )" ), - QStringLiteral( "MLineFromText( wktMultiLineString [String] [ , SRID [Integer]] )" ), - QStringLiteral( "MPolyFromText( wktMultiPolygon [String] [ , SRID [Integer]] )" ), - QStringLiteral( "GeomCollFromText( wktGeometryCollection [String] [ , SRID [Integer]] )" ), - QStringLiteral( "BdPolyFromText( wktMultilinestring [String] [ , SRID [Integer]] )" ), - QStringLiteral( "BdMPolyFromText( wktMultilinestring [String] [ , SRID [Integer]] )" ), - - // SQL functions for constructing a geometric object given its Well-known Binary Representation - QStringLiteral( "GeomFromWKB( wkbGeometry [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "ST_WKBToSQL( wkbGeometry [Binary] )" ), - QStringLiteral( "PointFromWKB( wkbPoint [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "LineFromWKB( wkbLineString [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "PolyFromWKB( wkbPolygon [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "MPointFromWKB( wkbMultiPoint [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "MLineFromWKB( wkbMultiLineString [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "MPolyFromWKB( wkbMultiPolygon [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "GeomCollFromWKB( wkbGeometryCollection [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "BdPolyFromWKB( wkbMultilinestring [Binary] [ , SRID [Integer]] )" ), - QStringLiteral( "BdMPolyFromWKB( wkbMultilinestring [Binary] [ , SRID [Integer]] )" ), - - // SQL functions for obtaining the Well-known Text / Well-known Binary Representation of a geometric object - QStringLiteral( "AsText( geom [Geometry] )" ), - QStringLiteral( "AsWKT( geom [Geometry] [ , precision [Integer] ] )" ), - QStringLiteral( "AsBinary( geom [Geometry] )" ), - - // SQL functions supporting exotic geometric formats - QStringLiteral( "AsSVG( geom [Geometry] [ , relative [Integer] [ , precision [Integer] ] ] )" ), - QStringLiteral( "AsKml( geom [Geometry] [ , precision [Integer] ] )" ), - QStringLiteral( "GeomFromKml( KmlGeometry [String] )" ), - QStringLiteral( "AsGml( geom [Geometry] [ , precision [Integer] ] )" ), - QStringLiteral( "GeomFromGML( gmlGeometry [String] )" ), - QStringLiteral( "AsGeoJSON( geom [Geometry] [ , precision [Integer] [ , options [Integer] ] ] )" ), - QStringLiteral( "GeomFromGeoJSON( geoJSONGeometry [String] )" ), - QStringLiteral( "AsEWKB( geom [Geometry] )" ), - QStringLiteral( "GeomFromEWKB( ewkbGeometry [String] )" ), - QStringLiteral( "AsEWKT( geom [Geometry] )" ), - QStringLiteral( "GeomFromEWKT( ewktGeometry [String] )" ), - QStringLiteral( "AsFGF( geom [Geometry] )" ), - QStringLiteral( "GeomFromFGF( fgfGeometry [Binary] [ , SRID [Integer]] )" ), - - // SQL functions on type Geometry - QStringLiteral( "Dimension( geom [Geometry] )" ), - QStringLiteral( "CoordDimension( geom [Geometry] )" ), - QStringLiteral( "ST_NDims( geom [Geometry] )" ), - QStringLiteral( "ST_Is3D( geom [Geometry] )" ), - QStringLiteral( "ST_IsMeasured( geom [Geometry] )" ), - QStringLiteral( "GeometryType( geom [Geometry] )" ), - QStringLiteral( "SRID( geom [Geometry] )" ), - QStringLiteral( "SetSRID( geom [Geometry] , SRID [Integer] )" ), - QStringLiteral( "IsEmpty( geom [Geometry] )" ), - QStringLiteral( "IsSimple( geom [Geometry] )" ), - QStringLiteral( "IsValid( geom [Geometry] )" ), - QStringLiteral( "IsValidReason( geom [Geometry] )" ), - QStringLiteral( "IsValidDetail( geom [Geometry] )" ), - QStringLiteral( "Boundary( geom [Geometry] )" ), - QStringLiteral( "Envelope( geom [Geometry] )" ), - QStringLiteral( "ST_Expand( geom [Geometry] , amount [Double precision] )" ), - QStringLiteral( "ST_NPoints( geom [Geometry] )" ), - QStringLiteral( "ST_NRings( geom [Geometry] )" ), - QStringLiteral( "ST_Reverse( geom [Geometry] )" ), - QStringLiteral( "ST_ForceLHR( geom [Geometry] )" ), - - // SQL functions attempting to repair malformed Geometries - QStringLiteral( "SanitizeGeometry( geom [Geometry] )" ), - - // SQL Geometry-compression functions - QStringLiteral( "CompressGeometry( geom [Geometry] )" ), - QStringLiteral( "UncompressGeometry( geom [Geometry] )" ), - - // SQL Geometry-type casting functions - QStringLiteral( "CastToPoint( geom [Geometry] )" ), - QStringLiteral( "CastToLinestring( geom [Geometry] )" ), - QStringLiteral( "CastToPolygon( geom [Geometry] )" ), - QStringLiteral( "CastToMultiPoint( geom [Geometry] )" ), - QStringLiteral( "CastToMultiLinestring( geom [Geometry] )" ), - QStringLiteral( "CastToMultiPolygon( geom [Geometry] )" ), - QStringLiteral( "CastToGeometryCollection( geom [Geometry] )" ), - QStringLiteral( "CastToMulti( geom [Geometry] )" ), - QStringLiteral( "CastToSingle( geom [Geometry] )" ), - - // SQL Space-dimensions casting functions - QStringLiteral( "CastToXY( geom [Geometry] )" ), - QStringLiteral( "CastToXYZ( geom [Geometry] )" ), - QStringLiteral( "CastToXYM( geom [Geometry] )" ), - QStringLiteral( "CastToXYZM( geom [Geometry] )" ), - - // SQL functions on type Point - QStringLiteral( "X( pt [Point] )" ), - QStringLiteral( "Y( pt [Point] )" ), - QStringLiteral( "Z( pt [Point] )" ), - QStringLiteral( "M( pt [Point] )" ), - - // SQL functions on type Curve [Linestring or Ring] - QStringLiteral( "StartPoint( c [Curve] )" ), - QStringLiteral( "EndPoint( c [Curve] )" ), - QStringLiteral( "GLength( c [Curve] )" ), - QStringLiteral( "Perimeter( s [Surface] )" ), - QStringLiteral( "GeodesicLength( c [Curve] )" ), - QStringLiteral( "GreatCircleLength( c [Curve] )" ), - QStringLiteral( "IsClosed( c [Curve] )" ), - QStringLiteral( "IsRing( c [Curve] )" ), - QStringLiteral( "PointOnSurface( s [Surface/Curve] )" ), - QStringLiteral( "Simplify( c [Curve] , tolerance [Double precision] )" ), - QStringLiteral( "SimplifyPreserveTopology( c [Curve] , tolerance [Double precision] )" ), - - // SQL functions on type LineString - QStringLiteral( "NumPoints( line [LineString] )" ), - QStringLiteral( "PointN( line [LineString] , n [Integer] )" ), - QStringLiteral( "AddPoint( line [LineString] , point [Point] [ , position [Integer] ] )" ), - QStringLiteral( "SetPoint( line [LineString] , position [Integer] , point [Point] )" ), - QStringLiteral( "RemovePoint( line [LineString] , position [Integer] )" ), - - // SQL functions on type Surface [Polygon or Ring] - QStringLiteral( "Centroid( s [Surface] )" ), - QStringLiteral( "Area( s [Surface] )" ), - - // SQL functions on type Polygon - QStringLiteral( "ExteriorRing( polyg [Polygon] )" ), - QStringLiteral( "NumInteriorRing( polyg [Polygon] )" ), - QStringLiteral( "InteriorRingN( polyg [Polygon] , n [Integer] )" ), - - // SQL functions on type GeomCollection - QStringLiteral( "NumGeometries( geom [GeomCollection] )" ), - QStringLiteral( "GeometryN( geom [GeomCollection] , n [Integer] )" ), - - // SQL functions that test approximate spatial relationships via MBRs - QStringLiteral( "MbrEqual( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "MbrDisjoint( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "MbrTouches( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "MbrWithin( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "MbrOverlaps( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "MbrIntersects( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "ST_EnvIntersects( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "MbrContains( geom1 [Geometry] , geom2 [Geometry] )" ), - - // SQL functions that test spatial relationships - QStringLiteral( "Equals( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Disjoint( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Touches( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Within( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Overlaps( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Crosses( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Intersects( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Contains( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Covers( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "CoveredBy( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "Relate( geom1 [Geometry] , geom2 [Geometry] , patternMatrix [String] )" ), - - // SQL functions for distance relationships - QStringLiteral( "Distance( geom1 [Geometry] , geom2 [Geometry] )" ), - - // SQL functions that implement spatial operators - QStringLiteral( "MakeValid( geom [Geometry] )" ), - QStringLiteral( "MakeValidDiscarded( geom [Geometry] )" ), - QStringLiteral( "Segmentize( geom [Geometry], dist [Double precision] )" ), - QStringLiteral( "Split( geom [Geometry], blade [Geometry] )" ), - QStringLiteral( "SplitLeft( geom [Geometry], blade [Geometry] )" ), - QStringLiteral( "SplitRight( geom [Geometry], blade [Geometry] )" ), - QStringLiteral( "Azimuth( pt1 [Geometry], pt2 [Geometry] )" ), - QStringLiteral( "Project( start_point [Geometry], distance [Double precision], azimuth [Double precision] )" ), - QStringLiteral( "SnapToGrid( geom [Geometry] , size [Double precision] )" ), - QStringLiteral( "GeoHash( geom [Geometry] )" ), - QStringLiteral( "AsX3D( geom [Geometry] )" ), - QStringLiteral( "MaxDistance( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "ST_3DDistance( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "ST_3DMaxDistance( geom1 [Geometry] , geom2 [Geometry] )" ), - QStringLiteral( "ST_Node( geom [Geometry] )" ), - QStringLiteral( "SelfIntersections( geom [Geometry] )" ), - - // SQL functions for coordinate transformations - QStringLiteral( "Transform( geom [Geometry] , newSRID [Integer] )" ), - QStringLiteral( "SridFromAuthCRS( auth_name [String] , auth_SRID [Integer] )" ), - QStringLiteral( "ShiftCoords( geom [Geometry] , shiftX [Double precision] , shiftY [Double precision] )" ), - QStringLiteral( "ST_Translate( geom [Geometry] , shiftX [Double precision] , shiftY [Double precision] , shiftZ [Double precision] )" ), - QStringLiteral( "ST_Shift_Longitude( geom [Geometry] )" ), - QStringLiteral( "NormalizeLonLat( geom [Geometry] )" ), - QStringLiteral( "ScaleCoords( geom [Geometry] , scaleX [Double precision] [ , scaleY [Double precision] ] )" ), - QStringLiteral( "RotateCoords( geom [Geometry] , angleInDegrees [Double precision] )" ), - QStringLiteral( "ReflectCoords( geom [Geometry] , xAxis [Integer] , yAxis [Integer] )" ), - QStringLiteral( "SwapCoords( geom [Geometry] )" ), - - // SQL functions for Spatial-MetaData and Spatial-Index handling - QStringLiteral( "InitSpatialMetaData( void )" ), - QStringLiteral( "InsertEpsgSrid( srid [Integer] )" ), - QStringLiteral( "DiscardGeometryColumn( table [String] , column [String] )" ), - QStringLiteral( "RegisterVirtualGeometry( table [String] )" ), - QStringLiteral( "DropVirtualGeometry( table [String] )" ), - QStringLiteral( "CreateSpatialIndex( table [String] , column [String] )" ), - QStringLiteral( "CreateMbrCache( table [String] , column [String] )" ), - QStringLiteral( "DisableSpatialIndex( table [String] , column [String] )" ), - QStringLiteral( "CheckShadowedRowid( table [String] )" ), - QStringLiteral( "CheckWithoutRowid( table [String] )" ), - QStringLiteral( "CheckSpatialIndex( void )" ), - QStringLiteral( "RecoverSpatialIndex( [ no_check" ), - QStringLiteral( "InvalidateLayerStatistics( [ void )" ), - QStringLiteral( "UpdateLayerStatistics( [ void )" ), - QStringLiteral( "GetLayerExtent( table [String] [ , column [String] [ , mode [Boolean]] ] )" ), - QStringLiteral( "CreateTopologyTables( SRID [Integer] , dims" ), - QStringLiteral( "CreateRasterCoveragesTable( [void] )" ), - - // SQL functions supporting the MetaCatalog and related Statistics - QStringLiteral( "CreateMetaCatalogTables( transaction [Integer] )" ), - QStringLiteral( "UpdateMetaCatalogStatistics( transaction [Integer] , table_name [String] , column_name [String] )" ), - - // SQL functions supporting SLD/SE Styled Layers - QStringLiteral( "CreateStylingTables()" ), - QStringLiteral( "RegisterExternalGraphic( xlink_href [String] , resource [BLOB] )" ), - QStringLiteral( "RegisterVectorStyledLayer( f_table_name [String] , f_geometry_column [String] , style [BLOB] )" ), - QStringLiteral( "RegisterRasterStyledLayer( coverage_name [String] , style [BLOB] )" ), - QStringLiteral( "RegisterStyledGroup( group_name [String] , f_table_name [String] , f_geometry_column [String] [ , paint_order [Integer] ] )" ), - QStringLiteral( "SetStyledGroupInfos( group_name [String] , title [String] , abstract [String] )" ), - QStringLiteral( "RegisterGroupStyle( group_name [String] , style [BLOB] )" ), - - // SQL functions supporting ISO Metadata - QStringLiteral( "CreateIsoMetadataTables()" ), - QStringLiteral( "RegisterIsoMetadata( scope [String] , metadata [BLOB] )" ), - QStringLiteral( "GetIsoMetadataId( fileIdentifier [String] )" ), - - // SQL functions implementing FDO/OGR compatibility - QStringLiteral( "CheckSpatialMetaData( void )" ), - QStringLiteral( "AutoFDOStart( void )" ), - QStringLiteral( "AutoFDOStop( void )" ), - QStringLiteral( "InitFDOSpatialMetaData( void )" ), - QStringLiteral( "DiscardFDOGeometryColumn( table [String] , column [String] )" ), - - // SQL functions implementing OGC GeoPackage compatibility - QStringLiteral( "CheckGeoPackageMetaData( void )" ), - QStringLiteral( "AutoGPKGStart( void )" ), - QStringLiteral( "AutoGPKGStop( void )" ), - QStringLiteral( "gpkgCreateBaseTables( void )" ), - QStringLiteral( "gpkgInsertEpsgSRID( srid [Integer] )" ), - QStringLiteral( "gpkgAddTileTriggers( tile_table_name [String] )" ), - QStringLiteral( "gpkgGetNormalZoom( tile_table_name [String] , inverted_zoom_level [Integer] )" ), - QStringLiteral( "gpkgGetNormalRow( tile_table_name [String] , normal_zoom_level [Integer] , inverted_row_number [Integer] )" ), - QStringLiteral( "gpkgGetImageType( image [Blob] )" ), - QStringLiteral( "gpkgAddGeometryTriggers( table_name [String] , geometry_column_name [String] )" ), - QStringLiteral( "gpkgAddSpatialIndex( table_name [String] , geometry_column_name [String] )" ), - QStringLiteral( "gpkgMakePoint (x [Double precision] , y [Double precision] )" ), - QStringLiteral( "gpkgMakePointZ (x [Double precision] , y [Double precision] , z [Double precision] )" ), - QStringLiteral( "gpkgMakePointM (x [Double precision] , y [Double precision] , m [Double precision] )" ), - QStringLiteral( "gpkgMakePointZM (x [Double precision] , y [Double precision] , z [Double precision] , m [Double precision] )" ), - QStringLiteral( "IsValidGPB( geom [Blob] )" ), - QStringLiteral( "AsGPB( geom [BLOB encoded geometry] )" ), - QStringLiteral( "GeomFromGPB( geom [GPKG Blob Geometry] )" ), - QStringLiteral( "CastAutomagic( geom [Blob] )" ), - QStringLiteral( "GPKG_IsAssignable( expected_type_name [String] , actual_type_name [String] )" ), - - } - } - } ); + { { Qgis::SqlKeywordCategory::Math, { // SQL math functions + QStringLiteral( "Abs( x [Double precision] )" ), QStringLiteral( "Acos( x [Double precision] )" ), QStringLiteral( "Asin( x [Double precision] )" ), QStringLiteral( "Atan( x [Double precision] )" ), QStringLiteral( "Ceil( x [Double precision] )" ), QStringLiteral( "Cos( x [Double precision] )" ), QStringLiteral( "Cot( x [Double precision] )" ), QStringLiteral( "Degrees( x [Double precision] )" ), QStringLiteral( "Exp( x [Double precision] )" ), QStringLiteral( "Floor( x [Double precision] )" ), QStringLiteral( "Ln( x [Double precision] )" ), QStringLiteral( "Log( b [Double precision] , x [Double precision] )" ), QStringLiteral( "Log2( x [Double precision] )" ), QStringLiteral( "Log10( x [Double precision] )" ), QStringLiteral( "PI( void )" ), QStringLiteral( "Pow( x [Double precision] , y [Double precision] )" ), QStringLiteral( "Radians( x [Double precision] )" ), QStringLiteral( "Sign( x [Double precision] )" ), QStringLiteral( "Sin( x [Double precision] )" ), QStringLiteral( "Sqrt( x [Double precision] )" ), QStringLiteral( "Stddev_pop( x [Double precision] )" ), QStringLiteral( "Stddev_samp( x [Double precision] )" ), QStringLiteral( "Tan( x [Double precision] )" ), QStringLiteral( "Var_pop( x [Double precision] )" ), QStringLiteral( "Var_samp( x [Double precision] )" ) + } }, + { Qgis::SqlKeywordCategory::Function, { + + // Specific + QStringLiteral( "last_insert_rowid" ), + + // SQL Version Info [and build options testing] functions + QStringLiteral( "spatialite_version( void )" ), + QStringLiteral( "spatialite_target_cpu( void )" ), + QStringLiteral( "proj4_version( void )" ), + QStringLiteral( "geos_version( void )" ), + QStringLiteral( "lwgeom_version( void )" ), + QStringLiteral( "libxml2_version( void )" ), + QStringLiteral( "HasIconv( void )" ), + QStringLiteral( "HasMathSQL( void )" ), + QStringLiteral( "HasGeoCallbacks( void )" ), + QStringLiteral( "HasProj( void )" ), + QStringLiteral( "HasGeos( void )" ), + QStringLiteral( "HasGeosAdvanced( void )" ), + QStringLiteral( "HasGeosTrunk( void )" ), + QStringLiteral( "HasLwGeom( void )" ), + QStringLiteral( "HasLibXML2( void )" ), + QStringLiteral( "HasEpsg( void )" ), + QStringLiteral( "HasFreeXL( void )" ), + QStringLiteral( "HasGeoPackage( void )" ), + + // Generic SQL functions + QStringLiteral( "CastToInteger( value [Generic] )" ), + QStringLiteral( "CastToDouble( value [Generic] )" ), + QStringLiteral( "CastToText( value [Generic] )" ), + QStringLiteral( "CastToBlob( value [Generic] )" ), + QStringLiteral( "ForceAsNull( val1 [Generic] , val2 [Generic])" ), + QStringLiteral( "CreateUUID( void )" ), + QStringLiteral( "MD5Checksum( BLOB | TEXT )" ), + QStringLiteral( "MD5TotalChecksum( BLOB | TEXT )" ), + + // SQL utility functions for BLOB objects + QStringLiteral( "IsZipBlob( content [BLOB] )" ), + QStringLiteral( "IsPdfBlob( content [BLOB] )" ), + QStringLiteral( "IsGifBlob( image [BLOB] )" ), + QStringLiteral( "IsPngBlob( image [BLOB] )" ), + QStringLiteral( "IsTiffBlob( image [BLOB] )" ), + QStringLiteral( "IsJpegBlob( image [BLOB] )" ), + QStringLiteral( "IsExifBlob( image [BLOB] )" ), + QStringLiteral( "IsExifGpsBlob( image [BLOB] )" ), + QStringLiteral( "IsWebpBlob( image [BLOB] )" ), + QStringLiteral( "GetMimeType( payload [BLOB] )" ), + QStringLiteral( "BlobFromFile( filepath [String] )" ), + QStringLiteral( "BlobToFile( payload [BLOB] , filepath [String] )" ), + QStringLiteral( "CountUnsafeTriggers( )" ), + + // SQL functions supporting XmlBLOB + QStringLiteral( "XB_Create( xmlPayload [BLOB] )" ), + QStringLiteral( "XB_GetPayload( xmlObject [XmlBLOB] [ , indent [Integer] ] )" ), + QStringLiteral( "XB_GetDocument( xmlObject [XmlBLOB] [ , indent [Integer] ] )" ), + QStringLiteral( "XB_SchemaValidate( xmlObject [XmlBLOB] , schemaURI [Text] [ , compressed [Boolean] ] )" ), + QStringLiteral( "XB_Compress( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_Uncompress( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_IsValid( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_IsCompressed( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_IsSchemaValidated( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_IsIsoMetadata( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_IsSldSeVectorStyle( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_IsSldSeRasterStyle( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_IsSvg( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_GetDocumentSize( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_GetEncoding( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_GetSchemaURI( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_GetInternalSchemaURI( xmlPayload [BLOB] )" ), + QStringLiteral( "XB_GetFileId( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_SetFileId( xmlObject [XmlBLOB] , fileId [String] )" ), + QStringLiteral( "XB_AddFileId( xmlObject [XmlBLOB] , fileId [String] , IdNameSpacePrefix [String] , IdNameSpaceURI [String] , CsNameSpacePrefix [String] , CsNameSpaceURI [String] )" ), + QStringLiteral( "XB_GetParentId( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_SetParentId( xmlObject [XmlBLOB] , parentId [String] )" ), + QStringLiteral( "XB_AddParentId( xmlObject [XmlBLOB] , parentId [String] , IdNameSpacePrefix [String] , IdNameSpaceURI [String] , CsNameSpacePrefix [String] , CsNameSpaceURI [String] )" ), + QStringLiteral( "XB_GetTitle( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_GetAbstract( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_GetGeometry( xmlObject [XmlBLOB] )" ), + QStringLiteral( "XB_GetLastParseError( [void] )" ), + QStringLiteral( "XB_GetLastValidateError( [void] )" ), + QStringLiteral( "XB_IsValidXPathExpression( expr [Text] )" ), + QStringLiteral( "XB_GetLastXPathError( [void] )" ), + QStringLiteral( "XB_CacheFlush( [void] )" ), + QStringLiteral( "XB_LoadXML( filepath-or-URL [String] )" ), + QStringLiteral( "XB_StoreXML( XmlObject [XmlBLOB] , filepath [String] )" ), + + } }, + { Qgis::SqlKeywordCategory::Geospatial, { + // SQL functions reporting GEOS / LWGEOM errors and warnings + QStringLiteral( "GEOS_GetLastWarningMsg( [void] )" ), + QStringLiteral( "GEOS_GetLastErrorMsg( [void] )" ), + QStringLiteral( "GEOS_GetLastAuxErrorMsg( [void] )" ), + QStringLiteral( "GEOS_GetCriticalPointFromMsg( [void] )" ), + QStringLiteral( "LWGEOM_GetLastWarningMsg( [void] )" ), + QStringLiteral( "LWGEOM_GetLastErrorMsg( [void] )" ), + + // SQL length/distance unit-conversion functions + QStringLiteral( "CvtToKm( x [Double precision] )" ), + QStringLiteral( "CvtToDm( x [Double precision] )" ), + QStringLiteral( "CvtToCm( x [Double precision] )" ), + QStringLiteral( "CvtToMm( x [Double precision] )" ), + QStringLiteral( "CvtToKmi( x [Double precision] )" ), + QStringLiteral( "CvtToIn( x [Double precision] )" ), + QStringLiteral( "CvtToFt( x [Double precision] )" ), + QStringLiteral( "CvtToYd( x [Double precision] )" ), + QStringLiteral( "CvtToMi( x [Double precision] )" ), + QStringLiteral( "CvtToFath( x [Double precision] )" ), + QStringLiteral( "CvtToCh( x [Double precision] )" ), + QStringLiteral( "CvtToLink( x [Double precision] )" ), + QStringLiteral( "CvtToUsIn( x [Double precision] )" ), + QStringLiteral( "CvtToUsFt( x [Double precision] )" ), + QStringLiteral( "CvtToUsYd( x [Double precision] )" ), + QStringLiteral( "CvtToUsMi( x [Double precision] )" ), + QStringLiteral( "CvtToUsCh( x [Double precision] )" ), + QStringLiteral( "CvtToIndFt( x [Double precision] )" ), + QStringLiteral( "CvtToIndYd( x [Double precision] )" ), + QStringLiteral( "CvtToIndCh( x [Double precision] )" ), + + // SQL conversion functions from DD/DMS notations (longitude/latitude) + QStringLiteral( "LongLatToDMS( longitude [Double precision] , latitude [Double precision] )" ), + QStringLiteral( "LongitudeFromDMS( dms_expression [Sting] )" ), + + // SQL utility functions [ + QStringLiteral( "GeomFromExifGpsBlob( image [BLOB] )" ), + QStringLiteral( "ST_Point( x [Double precision] , y [Double precision] )" ), + QStringLiteral( "MakeLine( pt1 [PointGeometry] , pt2 [PointGeometry] )" ), + QStringLiteral( "MakeLine( geom [PointGeometry] )" ), + QStringLiteral( "MakeLine( geom [MultiPointGeometry] , direction [Boolean] )" ), + QStringLiteral( "SquareGrid( geom [ArealGeometry] , size [Double precision] [ , edges_only [Boolean] , [ origing [PointGeometry] ] ] )" ), + QStringLiteral( "TriangularGrid( geom [ArealGeometry] , size [Double precision] [ , edges_only [Boolean] , [ origing [PointGeometry] ] ] )" ), + QStringLiteral( "HexagonalGrid( geom [ArealGeometry] , size [Double precision] [ , edges_only [Boolean] , [ origing [PointGeometry] ] ] )" ), + QStringLiteral( "Extent( geom [Geometry] )" ), + QStringLiteral( "ToGARS( geom [Geometry] )" ), + QStringLiteral( "GARSMbr( code [String] )" ), + QStringLiteral( "MbrMinX( geom [Geometry])" ), + QStringLiteral( "MbrMinY( geom [Geometry])" ), + QStringLiteral( "MbrMaxX( geom [Geometry])" ), + QStringLiteral( "MbrMaxY( geom [Geometry])" ), + QStringLiteral( "ST_MinZ( geom [Geometry])" ), + QStringLiteral( "ST_MaxZ( geom [Geometry])" ), + QStringLiteral( "ST_MinM( geom [Geometry])" ), + QStringLiteral( "ST_MaxM( geom [Geometry])" ), + + // SQL functions for constructing a geometric object given its Well-known Text Representation + QStringLiteral( "GeomFromText( wkt [String] [ , SRID [Integer]] )" ), + QStringLiteral( "ST_WKTToSQL( wkt [String] )" ), + QStringLiteral( "PointFromText( wktPoint [String] [ , SRID [Integer]] )" ), + QStringLiteral( "LineFromText( wktLineString [String] [ , SRID [Integer]] )" ), + QStringLiteral( "PolyFromText( wktPolygon [String] [ , SRID [Integer]] )" ), + QStringLiteral( "MPointFromText( wktMultiPoint [String] [ , SRID [Integer]] )" ), + QStringLiteral( "MLineFromText( wktMultiLineString [String] [ , SRID [Integer]] )" ), + QStringLiteral( "MPolyFromText( wktMultiPolygon [String] [ , SRID [Integer]] )" ), + QStringLiteral( "GeomCollFromText( wktGeometryCollection [String] [ , SRID [Integer]] )" ), + QStringLiteral( "BdPolyFromText( wktMultilinestring [String] [ , SRID [Integer]] )" ), + QStringLiteral( "BdMPolyFromText( wktMultilinestring [String] [ , SRID [Integer]] )" ), + + // SQL functions for constructing a geometric object given its Well-known Binary Representation + QStringLiteral( "GeomFromWKB( wkbGeometry [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "ST_WKBToSQL( wkbGeometry [Binary] )" ), + QStringLiteral( "PointFromWKB( wkbPoint [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "LineFromWKB( wkbLineString [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "PolyFromWKB( wkbPolygon [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "MPointFromWKB( wkbMultiPoint [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "MLineFromWKB( wkbMultiLineString [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "MPolyFromWKB( wkbMultiPolygon [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "GeomCollFromWKB( wkbGeometryCollection [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "BdPolyFromWKB( wkbMultilinestring [Binary] [ , SRID [Integer]] )" ), + QStringLiteral( "BdMPolyFromWKB( wkbMultilinestring [Binary] [ , SRID [Integer]] )" ), + + // SQL functions for obtaining the Well-known Text / Well-known Binary Representation of a geometric object + QStringLiteral( "AsText( geom [Geometry] )" ), + QStringLiteral( "AsWKT( geom [Geometry] [ , precision [Integer] ] )" ), + QStringLiteral( "AsBinary( geom [Geometry] )" ), + + // SQL functions supporting exotic geometric formats + QStringLiteral( "AsSVG( geom [Geometry] [ , relative [Integer] [ , precision [Integer] ] ] )" ), + QStringLiteral( "AsKml( geom [Geometry] [ , precision [Integer] ] )" ), + QStringLiteral( "GeomFromKml( KmlGeometry [String] )" ), + QStringLiteral( "AsGml( geom [Geometry] [ , precision [Integer] ] )" ), + QStringLiteral( "GeomFromGML( gmlGeometry [String] )" ), + QStringLiteral( "AsGeoJSON( geom [Geometry] [ , precision [Integer] [ , options [Integer] ] ] )" ), + QStringLiteral( "GeomFromGeoJSON( geoJSONGeometry [String] )" ), + QStringLiteral( "AsEWKB( geom [Geometry] )" ), + QStringLiteral( "GeomFromEWKB( ewkbGeometry [String] )" ), + QStringLiteral( "AsEWKT( geom [Geometry] )" ), + QStringLiteral( "GeomFromEWKT( ewktGeometry [String] )" ), + QStringLiteral( "AsFGF( geom [Geometry] )" ), + QStringLiteral( "GeomFromFGF( fgfGeometry [Binary] [ , SRID [Integer]] )" ), + + // SQL functions on type Geometry + QStringLiteral( "Dimension( geom [Geometry] )" ), + QStringLiteral( "CoordDimension( geom [Geometry] )" ), + QStringLiteral( "ST_NDims( geom [Geometry] )" ), + QStringLiteral( "ST_Is3D( geom [Geometry] )" ), + QStringLiteral( "ST_IsMeasured( geom [Geometry] )" ), + QStringLiteral( "GeometryType( geom [Geometry] )" ), + QStringLiteral( "SRID( geom [Geometry] )" ), + QStringLiteral( "SetSRID( geom [Geometry] , SRID [Integer] )" ), + QStringLiteral( "IsEmpty( geom [Geometry] )" ), + QStringLiteral( "IsSimple( geom [Geometry] )" ), + QStringLiteral( "IsValid( geom [Geometry] )" ), + QStringLiteral( "IsValidReason( geom [Geometry] )" ), + QStringLiteral( "IsValidDetail( geom [Geometry] )" ), + QStringLiteral( "Boundary( geom [Geometry] )" ), + QStringLiteral( "Envelope( geom [Geometry] )" ), + QStringLiteral( "ST_Expand( geom [Geometry] , amount [Double precision] )" ), + QStringLiteral( "ST_NPoints( geom [Geometry] )" ), + QStringLiteral( "ST_NRings( geom [Geometry] )" ), + QStringLiteral( "ST_Reverse( geom [Geometry] )" ), + QStringLiteral( "ST_ForceLHR( geom [Geometry] )" ), + + // SQL functions attempting to repair malformed Geometries + QStringLiteral( "SanitizeGeometry( geom [Geometry] )" ), + + // SQL Geometry-compression functions + QStringLiteral( "CompressGeometry( geom [Geometry] )" ), + QStringLiteral( "UncompressGeometry( geom [Geometry] )" ), + + // SQL Geometry-type casting functions + QStringLiteral( "CastToPoint( geom [Geometry] )" ), + QStringLiteral( "CastToLinestring( geom [Geometry] )" ), + QStringLiteral( "CastToPolygon( geom [Geometry] )" ), + QStringLiteral( "CastToMultiPoint( geom [Geometry] )" ), + QStringLiteral( "CastToMultiLinestring( geom [Geometry] )" ), + QStringLiteral( "CastToMultiPolygon( geom [Geometry] )" ), + QStringLiteral( "CastToGeometryCollection( geom [Geometry] )" ), + QStringLiteral( "CastToMulti( geom [Geometry] )" ), + QStringLiteral( "CastToSingle( geom [Geometry] )" ), + + // SQL Space-dimensions casting functions + QStringLiteral( "CastToXY( geom [Geometry] )" ), + QStringLiteral( "CastToXYZ( geom [Geometry] )" ), + QStringLiteral( "CastToXYM( geom [Geometry] )" ), + QStringLiteral( "CastToXYZM( geom [Geometry] )" ), + + // SQL functions on type Point + QStringLiteral( "X( pt [Point] )" ), + QStringLiteral( "Y( pt [Point] )" ), + QStringLiteral( "Z( pt [Point] )" ), + QStringLiteral( "M( pt [Point] )" ), + + // SQL functions on type Curve [Linestring or Ring] + QStringLiteral( "StartPoint( c [Curve] )" ), + QStringLiteral( "EndPoint( c [Curve] )" ), + QStringLiteral( "GLength( c [Curve] )" ), + QStringLiteral( "Perimeter( s [Surface] )" ), + QStringLiteral( "GeodesicLength( c [Curve] )" ), + QStringLiteral( "GreatCircleLength( c [Curve] )" ), + QStringLiteral( "IsClosed( c [Curve] )" ), + QStringLiteral( "IsRing( c [Curve] )" ), + QStringLiteral( "PointOnSurface( s [Surface/Curve] )" ), + QStringLiteral( "Simplify( c [Curve] , tolerance [Double precision] )" ), + QStringLiteral( "SimplifyPreserveTopology( c [Curve] , tolerance [Double precision] )" ), + + // SQL functions on type LineString + QStringLiteral( "NumPoints( line [LineString] )" ), + QStringLiteral( "PointN( line [LineString] , n [Integer] )" ), + QStringLiteral( "AddPoint( line [LineString] , point [Point] [ , position [Integer] ] )" ), + QStringLiteral( "SetPoint( line [LineString] , position [Integer] , point [Point] )" ), + QStringLiteral( "RemovePoint( line [LineString] , position [Integer] )" ), + + // SQL functions on type Surface [Polygon or Ring] + QStringLiteral( "Centroid( s [Surface] )" ), + QStringLiteral( "Area( s [Surface] )" ), + + // SQL functions on type Polygon + QStringLiteral( "ExteriorRing( polyg [Polygon] )" ), + QStringLiteral( "NumInteriorRing( polyg [Polygon] )" ), + QStringLiteral( "InteriorRingN( polyg [Polygon] , n [Integer] )" ), + + // SQL functions on type GeomCollection + QStringLiteral( "NumGeometries( geom [GeomCollection] )" ), + QStringLiteral( "GeometryN( geom [GeomCollection] , n [Integer] )" ), + + // SQL functions that test approximate spatial relationships via MBRs + QStringLiteral( "MbrEqual( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "MbrDisjoint( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "MbrTouches( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "MbrWithin( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "MbrOverlaps( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "MbrIntersects( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "ST_EnvIntersects( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "MbrContains( geom1 [Geometry] , geom2 [Geometry] )" ), + + // SQL functions that test spatial relationships + QStringLiteral( "Equals( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Disjoint( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Touches( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Within( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Overlaps( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Crosses( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Intersects( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Contains( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Covers( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "CoveredBy( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "Relate( geom1 [Geometry] , geom2 [Geometry] , patternMatrix [String] )" ), + + // SQL functions for distance relationships + QStringLiteral( "Distance( geom1 [Geometry] , geom2 [Geometry] )" ), + + // SQL functions that implement spatial operators + QStringLiteral( "MakeValid( geom [Geometry] )" ), + QStringLiteral( "MakeValidDiscarded( geom [Geometry] )" ), + QStringLiteral( "Segmentize( geom [Geometry], dist [Double precision] )" ), + QStringLiteral( "Split( geom [Geometry], blade [Geometry] )" ), + QStringLiteral( "SplitLeft( geom [Geometry], blade [Geometry] )" ), + QStringLiteral( "SplitRight( geom [Geometry], blade [Geometry] )" ), + QStringLiteral( "Azimuth( pt1 [Geometry], pt2 [Geometry] )" ), + QStringLiteral( "Project( start_point [Geometry], distance [Double precision], azimuth [Double precision] )" ), + QStringLiteral( "SnapToGrid( geom [Geometry] , size [Double precision] )" ), + QStringLiteral( "GeoHash( geom [Geometry] )" ), + QStringLiteral( "AsX3D( geom [Geometry] )" ), + QStringLiteral( "MaxDistance( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "ST_3DDistance( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "ST_3DMaxDistance( geom1 [Geometry] , geom2 [Geometry] )" ), + QStringLiteral( "ST_Node( geom [Geometry] )" ), + QStringLiteral( "SelfIntersections( geom [Geometry] )" ), + + // SQL functions for coordinate transformations + QStringLiteral( "Transform( geom [Geometry] , newSRID [Integer] )" ), + QStringLiteral( "SridFromAuthCRS( auth_name [String] , auth_SRID [Integer] )" ), + QStringLiteral( "ShiftCoords( geom [Geometry] , shiftX [Double precision] , shiftY [Double precision] )" ), + QStringLiteral( "ST_Translate( geom [Geometry] , shiftX [Double precision] , shiftY [Double precision] , shiftZ [Double precision] )" ), + QStringLiteral( "ST_Shift_Longitude( geom [Geometry] )" ), + QStringLiteral( "NormalizeLonLat( geom [Geometry] )" ), + QStringLiteral( "ScaleCoords( geom [Geometry] , scaleX [Double precision] [ , scaleY [Double precision] ] )" ), + QStringLiteral( "RotateCoords( geom [Geometry] , angleInDegrees [Double precision] )" ), + QStringLiteral( "ReflectCoords( geom [Geometry] , xAxis [Integer] , yAxis [Integer] )" ), + QStringLiteral( "SwapCoords( geom [Geometry] )" ), + + // SQL functions for Spatial-MetaData and Spatial-Index handling + QStringLiteral( "InitSpatialMetaData( void )" ), + QStringLiteral( "InsertEpsgSrid( srid [Integer] )" ), + QStringLiteral( "DiscardGeometryColumn( table [String] , column [String] )" ), + QStringLiteral( "RegisterVirtualGeometry( table [String] )" ), + QStringLiteral( "DropVirtualGeometry( table [String] )" ), + QStringLiteral( "CreateSpatialIndex( table [String] , column [String] )" ), + QStringLiteral( "CreateMbrCache( table [String] , column [String] )" ), + QStringLiteral( "DisableSpatialIndex( table [String] , column [String] )" ), + QStringLiteral( "CheckShadowedRowid( table [String] )" ), + QStringLiteral( "CheckWithoutRowid( table [String] )" ), + QStringLiteral( "CheckSpatialIndex( void )" ), + QStringLiteral( "RecoverSpatialIndex( [ no_check" ), + QStringLiteral( "InvalidateLayerStatistics( [ void )" ), + QStringLiteral( "UpdateLayerStatistics( [ void )" ), + QStringLiteral( "GetLayerExtent( table [String] [ , column [String] [ , mode [Boolean]] ] )" ), + QStringLiteral( "CreateTopologyTables( SRID [Integer] , dims" ), + QStringLiteral( "CreateRasterCoveragesTable( [void] )" ), + + // SQL functions supporting the MetaCatalog and related Statistics + QStringLiteral( "CreateMetaCatalogTables( transaction [Integer] )" ), + QStringLiteral( "UpdateMetaCatalogStatistics( transaction [Integer] , table_name [String] , column_name [String] )" ), + + // SQL functions supporting SLD/SE Styled Layers + QStringLiteral( "CreateStylingTables()" ), + QStringLiteral( "RegisterExternalGraphic( xlink_href [String] , resource [BLOB] )" ), + QStringLiteral( "RegisterVectorStyledLayer( f_table_name [String] , f_geometry_column [String] , style [BLOB] )" ), + QStringLiteral( "RegisterRasterStyledLayer( coverage_name [String] , style [BLOB] )" ), + QStringLiteral( "RegisterStyledGroup( group_name [String] , f_table_name [String] , f_geometry_column [String] [ , paint_order [Integer] ] )" ), + QStringLiteral( "SetStyledGroupInfos( group_name [String] , title [String] , abstract [String] )" ), + QStringLiteral( "RegisterGroupStyle( group_name [String] , style [BLOB] )" ), + + // SQL functions supporting ISO Metadata + QStringLiteral( "CreateIsoMetadataTables()" ), + QStringLiteral( "RegisterIsoMetadata( scope [String] , metadata [BLOB] )" ), + QStringLiteral( "GetIsoMetadataId( fileIdentifier [String] )" ), + + // SQL functions implementing FDO/OGR compatibility + QStringLiteral( "CheckSpatialMetaData( void )" ), + QStringLiteral( "AutoFDOStart( void )" ), + QStringLiteral( "AutoFDOStop( void )" ), + QStringLiteral( "InitFDOSpatialMetaData( void )" ), + QStringLiteral( "DiscardFDOGeometryColumn( table [String] , column [String] )" ), + + // SQL functions implementing OGC GeoPackage compatibility + QStringLiteral( "CheckGeoPackageMetaData( void )" ), + QStringLiteral( "AutoGPKGStart( void )" ), + QStringLiteral( "AutoGPKGStop( void )" ), + QStringLiteral( "gpkgCreateBaseTables( void )" ), + QStringLiteral( "gpkgInsertEpsgSRID( srid [Integer] )" ), + QStringLiteral( "gpkgAddTileTriggers( tile_table_name [String] )" ), + QStringLiteral( "gpkgGetNormalZoom( tile_table_name [String] , inverted_zoom_level [Integer] )" ), + QStringLiteral( "gpkgGetNormalRow( tile_table_name [String] , normal_zoom_level [Integer] , inverted_row_number [Integer] )" ), + QStringLiteral( "gpkgGetImageType( image [Blob] )" ), + QStringLiteral( "gpkgAddGeometryTriggers( table_name [String] , geometry_column_name [String] )" ), + QStringLiteral( "gpkgAddSpatialIndex( table_name [String] , geometry_column_name [String] )" ), + QStringLiteral( "gpkgMakePoint (x [Double precision] , y [Double precision] )" ), + QStringLiteral( "gpkgMakePointZ (x [Double precision] , y [Double precision] , z [Double precision] )" ), + QStringLiteral( "gpkgMakePointM (x [Double precision] , y [Double precision] , m [Double precision] )" ), + QStringLiteral( "gpkgMakePointZM (x [Double precision] , y [Double precision] , z [Double precision] , m [Double precision] )" ), + QStringLiteral( "IsValidGPB( geom [Blob] )" ), + QStringLiteral( "AsGPB( geom [BLOB encoded geometry] )" ), + QStringLiteral( "GeomFromGPB( geom [GPKG Blob Geometry] )" ), + QStringLiteral( "CastAutomagic( geom [Blob] )" ), + QStringLiteral( "GPKG_IsAssignable( expected_type_name [String] , actual_type_name [String] )" ), + + } } } + ); } @@ -1159,7 +1105,7 @@ void QgsSpatiaLiteProviderConnection::deleteField( const QString &fieldName, con QgsVectorLayer::LayerOptions options { false, false }; options.skipCrsValidation = true; std::unique_ptr vl { std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( pathFromUri(), tableName ), QStringLiteral( "temp_layer" ), QStringLiteral( "ogr" ), options ) }; - if ( ! vl->isValid() ) + if ( !vl->isValid() ) { throw QgsProviderConnectionException( QObject::tr( "Could not create a valid layer for table '%1'" ).arg( tableName ) ); } @@ -1167,7 +1113,7 @@ void QgsSpatiaLiteProviderConnection::deleteField( const QString &fieldName, con { throw QgsProviderConnectionException( QObject::tr( "Could not delete field '%1' of table '%2': field does not exist" ).arg( fieldName, tableName ) ); } - if ( ! vl->dataProvider()->deleteAttributes( {vl->fields().lookupField( fieldName )} ) ) + if ( !vl->dataProvider()->deleteAttributes( { vl->fields().lookupField( fieldName ) } ) ) { throw QgsProviderConnectionException( QObject::tr( "Unknown error deleting field '%1' of table '%2'" ).arg( fieldName, tableName ) ); } diff --git a/src/providers/spatialite/qgsspatialiteproviderconnection.h b/src/providers/spatialite/qgsspatialiteproviderconnection.h index 1ba2d8952233..661f8e881f32 100644 --- a/src/providers/spatialite/qgsspatialiteproviderconnection.h +++ b/src/providers/spatialite/qgsspatialiteproviderconnection.h @@ -23,7 +23,7 @@ #define SIP_NO_FILE -struct QgsSpatialiteProviderResultIterator: public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator +struct QgsSpatialiteProviderResultIterator : public QgsAbstractDatabaseProviderConnection::QueryResult::QueryResultIterator { QgsSpatialiteProviderResultIterator( gdal::dataset_unique_ptr hDS, OGRLayerH ogrLayer ); @@ -34,7 +34,6 @@ struct QgsSpatialiteProviderResultIterator: public QgsAbstractDatabaseProviderCo void setGeometryColumnName( const QString &geometryColumnName ); private: - gdal::dataset_unique_ptr mHDS; OGRLayerH mOgrLayer; QgsFields mFields; @@ -55,7 +54,6 @@ struct QgsSpatialiteProviderResultIterator: public QgsAbstractDatabaseProviderCo class QgsSpatiaLiteProviderConnection : public QgsAbstractDatabaseProviderConnection { public: - QgsSpatiaLiteProviderConnection( const QString &name ); // Note: URI must be in PG QgsDataSourceUri format ( "dbname='path_to_sqlite.db'" ) QgsSpatiaLiteProviderConnection( const QString &uri, const QVariantMap &configuration ); @@ -74,8 +72,7 @@ class QgsSpatiaLiteProviderConnection : public QgsAbstractDatabaseProviderConnec void vacuum( const QString &schema, const QString &name ) const override; void createSpatialIndex( const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options = QgsAbstractDatabaseProviderConnection::SpatialIndexOptions() ) const override; bool spatialIndexExists( const QString &schema, const QString &name, const QString &geometryColumn ) const override; - QList tables( const QString &schema = QString(), - const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; + QList tables( const QString &schema = QString(), const TableFlags &flags = TableFlags(), QgsFeedback *feedback = nullptr ) const override; QIcon icon() const override; void deleteField( const QString &fieldName, const QString &schema, const QString &tableName, bool force ) const override; QList nativeTypes() const override; @@ -83,7 +80,6 @@ class QgsSpatiaLiteProviderConnection : public QgsAbstractDatabaseProviderConnec SqlVectorLayerOptions sqlOptions( const QString &layerSource ) override; private: - void setDefaultCapabilities(); //! Use GDAL to execute SQL QgsAbstractDatabaseProviderConnection::QueryResult executeSqlPrivate( const QString &sql, QgsFeedback *feedback = nullptr ) const; @@ -93,7 +89,6 @@ class QgsSpatiaLiteProviderConnection : public QgsAbstractDatabaseProviderConnec //! extract the path from the DS URI (which is in "PG" form: 'dbname=\'/path_to.sqlite\' table="table_name" (geom_col_name)') QString pathFromUri() const; - }; diff --git a/src/providers/spatialite/qgsspatialiteprovidergui.cpp b/src/providers/spatialite/qgsspatialiteprovidergui.cpp index 0feb16e81a3c..f3f357dd4704 100644 --- a/src/providers/spatialite/qgsspatialiteprovidergui.cpp +++ b/src/providers/spatialite/qgsspatialiteprovidergui.cpp @@ -28,7 +28,6 @@ class QgsSpatialiteSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "spatialite" ); } QString text() const override { return QObject::tr( "SpatiaLite" ); } int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 10; } @@ -45,7 +44,6 @@ class QgsSpatialiteSourceSelectProvider : public QgsSourceSelectProvider }; - QgsSpatiaLiteProviderGuiMetadata::QgsSpatiaLiteProviderGuiMetadata() : QgsProviderGuiMetadata( QgsSpatiaLiteProvider::SPATIALITE_KEY ) { diff --git a/src/providers/spatialite/qgsspatialiteprovidergui.h b/src/providers/spatialite/qgsspatialiteprovidergui.h index 76f821e8ac34..ef8562f2c5be 100644 --- a/src/providers/spatialite/qgsspatialiteprovidergui.h +++ b/src/providers/spatialite/qgsspatialiteprovidergui.h @@ -20,7 +20,7 @@ #include "qgsspatialiteprovider.h" -class QgsSpatiaLiteProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsSpatiaLiteProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsSpatiaLiteProviderGuiMetadata(); @@ -28,4 +28,3 @@ class QgsSpatiaLiteProviderGuiMetadata: public QgsProviderGuiMetadata QList sourceSelectProviders() override; QList dataItemGuiProviders() override; }; - diff --git a/src/providers/spatialite/qgsspatialitesourceselect.cpp b/src/providers/spatialite/qgsspatialitesourceselect.cpp index 0ddf1bf0b870..5825ec3e1da7 100644 --- a/src/providers/spatialite/qgsspatialitesourceselect.cpp +++ b/src/providers/spatialite/qgsspatialitesourceselect.cpp @@ -41,11 +41,11 @@ email : a.furieri@lqt.it #include #ifdef _MSC_VER -#define strcasecmp(a,b) stricmp(a,b) +#define strcasecmp( a, b ) stricmp( a, b ) #endif -QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode theWidgetMode ): - QgsAbstractDbSourceSelect( parent, fl, theWidgetMode ) +QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode theWidgetMode ) + : QgsAbstractDbSourceSelect( parent, fl, theWidgetMode ) { QgsGui::enableAutoGeometryRestore( this ); @@ -61,7 +61,7 @@ QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget *parent, Qt::Windo mHoldDialogOpen->setChecked( settings.value( QStringLiteral( "Windows/SpatiaLiteSourceSelect/HoldDialogOpen" ), false ).toBool() ); setWindowTitle( tr( "Add SpatiaLite Layer(s)" ) ); - btnEdit->hide(); // hide the edit button + btnEdit->hide(); // hide the edit button btnSave->hide(); btnLoad->hide(); @@ -109,9 +109,9 @@ void QgsSpatiaLiteSourceSelect::updateStatistics() const QString msg = tr( "Are you sure you want to update the internal statistics for DB: %1?\n\n" "This could take a long time (depending on the DB size), " - "but implies better performance thereafter." ).arg( subKey ); - const QMessageBox::StandardButton result = - QMessageBox::question( this, tr( "Confirm Update Statistics" ), msg, QMessageBox::Yes | QMessageBox::No ); + "but implies better performance thereafter." ) + .arg( subKey ); + const QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Update Statistics" ), msg, QMessageBox::Yes | QMessageBox::No ); if ( result != QMessageBox::Yes ) return; @@ -119,13 +119,11 @@ void QgsSpatiaLiteSourceSelect::updateStatistics() QgsSpatiaLiteConnection conn( subKey ); if ( conn.updateStatistics() ) { - QMessageBox::information( this, tr( "Update Statistics" ), - tr( "Internal statistics successfully updated for: %1" ).arg( subKey ) ); + QMessageBox::information( this, tr( "Update Statistics" ), tr( "Internal statistics successfully updated for: %1" ).arg( subKey ) ); } else { - QMessageBox::critical( this, tr( "Update Statistics" ), - tr( "Error while updating internal statistics for: %1" ).arg( subKey ) ); + QMessageBox::critical( this, tr( "Update Statistics" ), tr( "Error while updating internal statistics for: %1" ).arg( subKey ) ); } } @@ -166,7 +164,7 @@ void QgsSpatiaLiteSourceSelect::populateConnectionList() void QgsSpatiaLiteSourceSelect::btnNew_clicked() { - if ( ! newConnection( this ) ) + if ( !newConnection( this ) ) return; populateConnectionList(); emit connectionsChanged(); @@ -178,9 +176,7 @@ bool QgsSpatiaLiteSourceSelect::newConnection( QWidget *parent ) QgsSettings settings; const QString lastUsedDir = settings.value( QStringLiteral( "UI/lastSpatiaLiteDir" ), QDir::homePath() ).toString(); - const QString myFile = QFileDialog::getOpenFileName( parent, - tr( "Choose a SpatiaLite/SQLite DB to open" ), - lastUsedDir, tr( "SpatiaLite DB" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db);;" + tr( "All files" ) + " (*)" ); + const QString myFile = QFileDialog::getOpenFileName( parent, tr( "Choose a SpatiaLite/SQLite DB to open" ), lastUsedDir, tr( "SpatiaLite DB" ) + " (*.sqlite *.db *.sqlite3 *.db3 *.s3db);;" + tr( "All files" ) + " (*)" ); if ( myFile.isEmpty() ) return false; @@ -198,12 +194,10 @@ bool QgsSpatiaLiteSourceSelect::newConnection( QWidget *parent ) //closeSpatiaLiteDb( handle ); // if there is already a connection with this name, ask for a new name - while ( ! settings.value( baseKey + savedName + "/sqlitepath", "" ).toString().isEmpty() ) + while ( !settings.value( baseKey + savedName + "/sqlitepath", "" ).toString().isEmpty() ) { bool ok; - savedName = QInputDialog::getText( nullptr, tr( "Add Connection" ), - tr( "A connection with the same name already exists,\nplease provide a new name:" ), QLineEdit::Normal, - QString(), &ok ); + savedName = QInputDialog::getText( nullptr, tr( "Add Connection" ), tr( "A connection with the same name already exists,\nplease provide a new name:" ), QLineEdit::Normal, QString(), &ok ); if ( !ok || savedName.isEmpty() ) { return false; @@ -218,7 +212,7 @@ bool QgsSpatiaLiteSourceSelect::newConnection( QWidget *parent ) // inserting this SQLite DB path QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "spatialite" ) ); - std::unique_ptr< QgsSpatiaLiteProviderConnection > providerConnection( qgis::down_cast( providerMetadata->createConnection( dsUri.uri(), QVariantMap() ) ) ); + std::unique_ptr providerConnection( qgis::down_cast( providerMetadata->createConnection( dsUri.uri(), QVariantMap() ) ) ); providerMetadata->saveConnection( providerConnection.get(), savedName ); return true; } @@ -233,7 +227,7 @@ QString QgsSpatiaLiteSourceSelect::layerURI( const QModelIndex &index ) { const int a = geomColumnName.indexOf( QLatin1String( " AS " ) ); const QString typeName = geomColumnName.mid( a + 4 ); //only the type name - geomColumnName = geomColumnName.left( a ); //only the geom column name + geomColumnName = geomColumnName.left( a ); //only the geom column name QString geomFilter; if ( typeName == QLatin1String( "POINT" ) ) @@ -274,8 +268,7 @@ void QgsSpatiaLiteSourceSelect::btnDelete_clicked() subKey.truncate( idx ); const QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ).arg( subKey ); - const QMessageBox::StandardButton result = - QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ); + const QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ); if ( result != QMessageBox::Yes ) return; @@ -290,8 +283,8 @@ void QgsSpatiaLiteSourceSelect::addButtonClicked() { m_selectedTables.clear(); - typedef QMap < int, bool >schemaInfo; - QMap < QString, schemaInfo > dbInfo; + typedef QMap schemaInfo; + QMap dbInfo; const QItemSelection selection = mTablesTreeView->selectionModel()->selection(); const QModelIndexList selectedIndices = selection.indexes(); @@ -328,7 +321,7 @@ void QgsSpatiaLiteSourceSelect::addButtonClicked() else { emit addDatabaseLayers( m_selectedTables, QStringLiteral( "spatialite" ) ); - if ( widgetMode() == QgsProviderRegistry::WidgetMode::Standalone && ! mHoldDialogOpen->isChecked() ) + if ( widgetMode() == QgsProviderRegistry::WidgetMode::Standalone && !mHoldDialogOpen->isChecked() ) { accept(); } @@ -361,24 +354,19 @@ void QgsSpatiaLiteSourceSelect::btnConnect_clicked() switch ( err ) { case QgsSpatiaLiteConnection::NotExists: - QMessageBox::critical( this, tr( "SpatiaLite DB Open Error" ), - tr( "Database does not exist: %1" ).arg( mSqlitePath ) ); + QMessageBox::critical( this, tr( "SpatiaLite DB Open Error" ), tr( "Database does not exist: %1" ).arg( mSqlitePath ) ); break; case QgsSpatiaLiteConnection::FailedToOpen: - QMessageBox::critical( this, tr( "SpatiaLite DB Open Error" ), - tr( "Failure while connecting to: %1\n\n%2" ).arg( mSqlitePath, errCause ) ); + QMessageBox::critical( this, tr( "SpatiaLite DB Open Error" ), tr( "Failure while connecting to: %1\n\n%2" ).arg( mSqlitePath, errCause ) ); break; case QgsSpatiaLiteConnection::FailedToGetTables: - QMessageBox::critical( this, tr( "SpatiaLite getTableInfo Error" ), - tr( "Failure exploring tables from: %1\n\n%2" ).arg( mSqlitePath, errCause ) ); + QMessageBox::critical( this, tr( "SpatiaLite getTableInfo Error" ), tr( "Failure exploring tables from: %1\n\n%2" ).arg( mSqlitePath, errCause ) ); break; case QgsSpatiaLiteConnection::FailedToCheckMetadata: - QMessageBox::critical( this, tr( "SpatiaLite metadata check failed" ), - tr( "Failure getting table metadata. Is %1 really a SpatiaLite database?\n\n%2" ).arg( mSqlitePath, errCause ) ); + QMessageBox::critical( this, tr( "SpatiaLite metadata check failed" ), tr( "Failure getting table metadata. Is %1 really a SpatiaLite database?\n\n%2" ).arg( mSqlitePath, errCause ) ); break; default: - QMessageBox::critical( this, tr( "SpatiaLite Error" ), - tr( "Unexpected error when working with %1\n\n%2" ).arg( mSqlitePath, errCause ) ); + QMessageBox::critical( this, tr( "SpatiaLite Error" ), tr( "Unexpected error when working with %1\n\n%2" ).arg( mSqlitePath, errCause ) ); } mSqlitePath = QString(); return; @@ -515,7 +503,6 @@ void QgsSpatiaLiteSourceSelect::showHelp() bool QgsSpatiaLiteSourceSelect::configureFromUri( const QString &uri ) { - const QgsDataSourceUri dsUri { uri }; const QString filePath { dsUri.database() }; const QString layerName { dsUri.table() }; @@ -544,7 +531,7 @@ bool QgsSpatiaLiteSourceSelect::configureFromUri( const QString &uri ) if ( idx < 0 ) { QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "spatialite" ) ); - std::unique_ptr< QgsSpatiaLiteProviderConnection > providerConnection( qgis::down_cast( providerMetadata->createConnection( uri, QVariantMap() ) ) ); + std::unique_ptr providerConnection( qgis::down_cast( providerMetadata->createConnection( uri, QVariantMap() ) ) ); providerMetadata->saveConnection( providerConnection.get(), connectionName ); populateConnectionList(); idx = cmbConnections->findText( connectionText ); @@ -553,14 +540,14 @@ bool QgsSpatiaLiteSourceSelect::configureFromUri( const QString &uri ) if ( idx >= 0 ) { cmbConnections->setCurrentIndex( idx ); - if ( ! layerName.isEmpty() ) + if ( !layerName.isEmpty() ) { btnConnect_clicked(); // Find table/layer QModelIndex index; - const QModelIndex parentIndex { mTableModel->index( 0, 0, mTableModel->invisibleRootItem()->index() )}; + const QModelIndex parentIndex { mTableModel->index( 0, 0, mTableModel->invisibleRootItem()->index() ) }; const QModelIndexList indexList { mTableModel->match( mTableModel->index( 0, 0, parentIndex ), Qt::DisplayRole, layerName, 1, Qt::MatchFlag::MatchExactly ) }; - if ( ! indexList.isEmpty() ) + if ( !indexList.isEmpty() ) { index = indexList.first(); } @@ -576,7 +563,6 @@ bool QgsSpatiaLiteSourceSelect::configureFromUri( const QString &uri ) mTableModel->setSql( index, subsetString ); } } - } return true; } diff --git a/src/providers/spatialite/qgsspatialitesourceselect.h b/src/providers/spatialite/qgsspatialitesourceselect.h index 464058c2f076..9472c0428fa9 100644 --- a/src/providers/spatialite/qgsspatialitesourceselect.h +++ b/src/providers/spatialite/qgsspatialitesourceselect.h @@ -40,12 +40,11 @@ class QPushButton; * for SpatiaLite/SQLite databases. The user can then connect and add * tables from the database to the map canvas. */ -class QgsSpatiaLiteSourceSelect: public QgsAbstractDbSourceSelect +class QgsSpatiaLiteSourceSelect : public QgsAbstractDbSourceSelect { Q_OBJECT public: - /* Open file selector to add new connection */ static bool newConnection( QWidget *parent ); @@ -100,8 +99,8 @@ class QgsSpatiaLiteSourceSelect: public QgsAbstractDbSourceSelect DbssColumns, }; - typedef QPair< QString, QString > geomPair; - typedef QList< geomPair > geomCol; + typedef QPair geomPair; + typedef QList geomCol; // Set the position of the database connection list to the last // used one. @@ -114,13 +113,12 @@ class QgsSpatiaLiteSourceSelect: public QgsAbstractDbSourceSelect QString mSqlitePath; QStringList m_selectedTables; // Storage for the range of layer type icons - QMap < QString, QPair < QString, QIcon > >mLayerIcons; + QMap> mLayerIcons; //! Model that acts as datasource for mTableTreeWidget QgsSpatiaLiteTableModel *mTableModel; QString layerURI( const QModelIndex &index ); QPushButton *mStatsButton = nullptr; - }; #endif // QGSSPATIALITESOURCESELECT_H diff --git a/src/providers/spatialite/qgsspatialitetablemodel.cpp b/src/providers/spatialite/qgsspatialitetablemodel.cpp index cdebd3dad1f6..95e940a1b462 100644 --- a/src/providers/spatialite/qgsspatialitetablemodel.cpp +++ b/src/providers/spatialite/qgsspatialitetablemodel.cpp @@ -49,14 +49,14 @@ void QgsSpatiaLiteTableModel::addTableEntry( const QString &type, const QString { //is there already a root item ? QStandardItem *dbItem = nullptr; - const QList < QStandardItem * >dbItems = findItems( mSqliteDb, Qt::MatchExactly, 0 ); + const QList dbItems = findItems( mSqliteDb, Qt::MatchExactly, 0 ); //there is already an item if ( !dbItems.isEmpty() ) { dbItem = dbItems.at( 0 ); } - else //create a new toplevel item + else //create a new toplevel item { dbItem = new QStandardItem( mSqliteDb ); dbItem->setFlags( Qt::ItemIsEnabled ); @@ -67,7 +67,7 @@ void QgsSpatiaLiteTableModel::addTableEntry( const QString &type, const QString const Qgis::WkbType wkbType = qgisTypeFromDbType( type ); const QIcon iconFile = iconForType( wkbType ); - QList < QStandardItem * >childItemList; + QList childItemList; QStandardItem *typeItem = new QStandardItem( QIcon( iconFile ), type ); typeItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); QStandardItem *tableItem = new QStandardItem( tableName ); @@ -112,12 +112,12 @@ void QgsSpatiaLiteTableModel::setSql( const QModelIndex &index, const QString &s void QgsSpatiaLiteTableModel::setGeometryTypesForTable( const QString &table, const QString &attribute, const QString &type ) { - const bool typeIsEmpty = type.isEmpty(); //true means the table has no valid geometry entry and the item for this table should be removed + const bool typeIsEmpty = type.isEmpty(); //true means the table has no valid geometry entry and the item for this table should be removed const QStringList typeList = type.split( ',' ); //find schema item and table item QStandardItem *dbItem = nullptr; - const QList < QStandardItem * >dbItems = findItems( mSqliteDb, Qt::MatchExactly, 0 ); + const QList dbItems = findItems( mSqliteDb, Qt::MatchExactly, 0 ); if ( dbItems.empty() ) { @@ -148,8 +148,7 @@ void QgsSpatiaLiteTableModel::setGeometryTypesForTable( const QString &table, co continue; } - if ( itemFromIndex( currentTableIndex )->text() == table && - ( geomColText == attribute || geomColText.startsWith( attribute + " AS " ) ) ) + if ( itemFromIndex( currentTableIndex )->text() == table && ( geomColText == attribute || geomColText.startsWith( attribute + " AS " ) ) ) { if ( typeIsEmpty ) { diff --git a/src/providers/spatialite/qgsspatialitetablemodel.h b/src/providers/spatialite/qgsspatialitetablemodel.h index a8e3fd794f58..0457b88f19dd 100644 --- a/src/providers/spatialite/qgsspatialitetablemodel.h +++ b/src/providers/spatialite/qgsspatialitetablemodel.h @@ -30,9 +30,9 @@ class QIcon; * * The tables have the following columns: Type, Tablename, Geometry Column */ -class QgsSpatiaLiteTableModel: public QgsAbstractDbTableModel +class QgsSpatiaLiteTableModel : public QgsAbstractDbTableModel { - Q_OBJECT public: + Q_OBJECT public : QgsSpatiaLiteTableModel( QObject *parent = nullptr ); diff --git a/src/providers/spatialite/qgsspatialitetransaction.cpp b/src/providers/spatialite/qgsspatialitetransaction.cpp index 242c727a301b..16ae5e0570bd 100644 --- a/src/providers/spatialite/qgsspatialitetransaction.cpp +++ b/src/providers/spatialite/qgsspatialitetransaction.cpp @@ -49,8 +49,7 @@ bool QgsSpatiaLiteTransaction::rollbackTransaction( QString &error ) bool QgsSpatiaLiteTransaction::executeSql( const QString &sql, QString &errorMsg, bool isDirty, const QString &name ) { - - if ( ! mSqliteHandle ) + if ( !mSqliteHandle ) { QgsDebugError( QStringLiteral( "Spatialite handle is not set" ) ); return false; @@ -59,7 +58,7 @@ bool QgsSpatiaLiteTransaction::executeSql( const QString &sql, QString &errorMsg if ( isDirty ) { createSavepoint( errorMsg ); - if ( ! errorMsg.isEmpty() ) + if ( !errorMsg.isEmpty() ) { QgsDebugError( errorMsg ); return false; diff --git a/src/providers/spatialite/qgsspatialitetransaction.h b/src/providers/spatialite/qgsspatialitetransaction.h index daf8e767cb96..f9b056e804cd 100644 --- a/src/providers/spatialite/qgsspatialitetransaction.h +++ b/src/providers/spatialite/qgsspatialitetransaction.h @@ -46,7 +46,6 @@ class QgsSpatiaLiteTransaction : public QgsTransaction sqlite3 *sqliteHandle() const; private: - QgsSqliteHandle *mSharedHandle = nullptr; int mSavepointId; diff --git a/src/providers/virtual/qgsembeddedlayerselectdialog.cpp b/src/providers/virtual/qgsembeddedlayerselectdialog.cpp index af5ec9528056..28eb40d0f3c7 100644 --- a/src/providers/virtual/qgsembeddedlayerselectdialog.cpp +++ b/src/providers/virtual/qgsembeddedlayerselectdialog.cpp @@ -45,7 +45,7 @@ QStringList QgsEmbeddedLayerSelectDialog::layers() const ids.reserve( selected.size() ); for ( const QModelIndex &index : selected ) { - ids << index.data( static_cast< int >( QgsMapLayerModel::CustomRole::LayerId ) ).toString(); + ids << index.data( static_cast( QgsMapLayerModel::CustomRole::LayerId ) ).toString(); } return ids; } diff --git a/src/providers/virtual/qgsembeddedlayerselectdialog.h b/src/providers/virtual/qgsembeddedlayerselectdialog.h index c48a4b5b3059..2778696e9245 100644 --- a/src/providers/virtual/qgsembeddedlayerselectdialog.h +++ b/src/providers/virtual/qgsembeddedlayerselectdialog.h @@ -35,9 +35,7 @@ class QgsEmbeddedLayerSelectDialog : public QDialog, private Ui::QgsEmbeddedLaye QStringList layers() const; private: - QgsMapLayerProxyModel *mLayerProxyModel = nullptr; - }; #endif diff --git a/src/providers/virtual/qgsslottofunction.h b/src/providers/virtual/qgsslottofunction.h index 5553a8c73d87..8cb30eff48c7 100644 --- a/src/providers/virtual/qgsslottofunction.h +++ b/src/providers/virtual/qgsslottofunction.h @@ -28,13 +28,18 @@ class QgsSlotToFunction : public QObject Q_OBJECT public: QgsSlotToFunction() = default; - QgsSlotToFunction( void ( *callback )( void * ), void *arg ) : mCallback( callback ), mArg( arg ) {} + QgsSlotToFunction( void ( *callback )( void * ), void *arg ) + : mCallback( callback ), mArg( arg ) {} public slots: - void onSignal() { if ( mCallback ) mCallback( mArg ); } + void onSignal() + { + if ( mCallback ) + mCallback( mArg ); + } + private: void ( *mCallback )( void * ) = nullptr; void *mArg = nullptr; }; #endif - diff --git a/src/providers/virtual/qgsvirtuallayerblob.cpp b/src/providers/virtual/qgsvirtuallayerblob.cpp index f56321ff23cf..1a9b8b450d63 100644 --- a/src/providers/virtual/qgsvirtuallayerblob.cpp +++ b/src/providers/virtual/qgsvirtuallayerblob.cpp @@ -68,7 +68,7 @@ void qgsGeometryToSpatialiteBlob( const QgsGeometry &geom, int32_t srid, char *& const int header_len = SpatialiteBlobHeader::LENGTH; // we segment the geometry as spatialite doesn't support curves - std::unique_ptr < QgsAbstractGeometry > segmentized( geom.constGet()->segmentize() ); + std::unique_ptr segmentized( geom.constGet()->segmentize() ); const QByteArray wkb( segmentized->asWkb() ); const int wkb_size = wkb.length(); @@ -189,7 +189,7 @@ void copySpatialiteCollectionWkbToQgsGeometry( const char *iwkb, char *owkb, uin if ( QgsWkbTypes::isMultiType( type ) ) { // multi type - const uint32_t n_elements = *( reinterpret_cast( iwkb + 5 ) ); + const uint32_t n_elements = *( reinterpret_cast( iwkb + 5 ) ); memcpy( owkb + 5, iwkb + 5, 4 ); uint32_t p = 0; for ( uint32_t i = 0; i < n_elements; i++ ) @@ -211,14 +211,14 @@ void copySpatialiteCollectionWkbToQgsGeometry( const char *iwkb, char *owkb, uin QgsGeometry spatialiteBlobToQgsGeometry( const char *blob, size_t size ) { const int header_size = SpatialiteBlobHeader::LENGTH; - const int wkb_size = static_cast< int >( size - header_size ); + const int wkb_size = static_cast( size - header_size ); char *wkb = new char[wkb_size]; uint32_t osize = 0; - copySpatialiteCollectionWkbToQgsGeometry( blob + header_size - 1, wkb, osize, /*endianness*/blob[1] ); + copySpatialiteCollectionWkbToQgsGeometry( blob + header_size - 1, wkb, osize, /*endianness*/ blob[1] ); QgsGeometry geom; - geom.fromWkb( reinterpret_cast< unsigned char * >( wkb ), wkb_size ); + geom.fromWkb( reinterpret_cast( wkb ), wkb_size ); return geom; } @@ -229,8 +229,8 @@ QPair spatialiteBlobGeometryType( const char *blob, size_t return qMakePair( Qgis::WkbType::NoGeometry, long( 0 ) ); } - const uint32_t srid = *( reinterpret_cast< const uint32_t * >( blob + 2 ) ); - const uint32_t type = *( reinterpret_cast< const uint32_t * >( blob + SpatialiteBlobHeader::LENGTH ) ); + const uint32_t srid = *( reinterpret_cast( blob + 2 ) ); + const uint32_t type = *( reinterpret_cast( blob + SpatialiteBlobHeader::LENGTH ) ); return qMakePair( static_cast( type ), long( srid ) ); } diff --git a/src/providers/virtual/qgsvirtuallayerblob.h b/src/providers/virtual/qgsvirtuallayerblob.h index 49791b4a86d2..6ade0c16d878 100644 --- a/src/providers/virtual/qgsvirtuallayerblob.h +++ b/src/providers/virtual/qgsvirtuallayerblob.h @@ -33,22 +33,22 @@ email : hugo dot mercier at oslandia dot com // mbr_end 1 7C struct SpatialiteBlobHeader { - unsigned char start = 0x00; - unsigned char endianness = 0x01; - int32_t srid = -1; - double mbrMinX = std::numeric_limits::lowest(); - double mbrMinY = std::numeric_limits::lowest(); - double mbrMaxX = std::numeric_limits::max(); - double mbrMaxY = std::numeric_limits::max(); - unsigned char end = 0x7C; + unsigned char start = 0x00; + unsigned char endianness = 0x01; + int32_t srid = -1; + double mbrMinX = std::numeric_limits::lowest(); + double mbrMinY = std::numeric_limits::lowest(); + double mbrMaxX = std::numeric_limits::max(); + double mbrMaxY = std::numeric_limits::max(); + unsigned char end = 0x7C; - SpatialiteBlobHeader() = default; + SpatialiteBlobHeader() = default; - static const size_t LENGTH = 39; + static const size_t LENGTH = 39; - void readFrom( const char *p ); + void readFrom( const char *p ); - void writeTo( char *p ) const; + void writeTo( char *p ) const; }; /** diff --git a/src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp b/src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp index baea2932118e..bc5cc58528de 100644 --- a/src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp +++ b/src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp @@ -31,7 +31,6 @@ static QString quotedColumn( QString name ) QgsVirtualLayerFeatureIterator::QgsVirtualLayerFeatureIterator( QgsVirtualLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ) : QgsAbstractFeatureIteratorFromSource( source, ownSource, request ) { - // NOTE: this is really bad and should be removed. // it's only here to guard mSource->mSqlite - because if the provider is removed // then mSqlite will be meaningless. @@ -92,9 +91,8 @@ QgsVirtualLayerFeatureIterator::QgsVirtualLayerFeatureIterator( QgsVirtualLayerF { const bool do_exact = request.flags() & Qgis::FeatureRequestFlag::ExactIntersect; wheres << quotedColumn( mSource->mDefinition.geometryField() ) + " is not null"; - wheres << QStringLiteral( "%1Intersects(%2,BuildMbr(?,?,?,?))" ) - .arg( do_exact ? "" : "Mbr", - quotedColumn( mSource->mDefinition.geometryField() ) ); + wheres << QStringLiteral( "%1Intersects(%2,BuildMbr(?,?,?,?))" ) + .arg( do_exact ? "" : "Mbr", quotedColumn( mSource->mDefinition.geometryField() ) ); binded << mFilterRect.xMinimum() << mFilterRect.yMinimum() << mFilterRect.xMaximum() << mFilterRect.yMaximum(); @@ -102,8 +100,8 @@ QgsVirtualLayerFeatureIterator::QgsVirtualLayerFeatureIterator( QgsVirtualLayerF else if ( request.filterType() == Qgis::FeatureRequestFilterType::Fid ) { wheres << QStringLiteral( "%1=%2" ) - .arg( quotedColumn( mSource->mDefinition.uid() ) ) - .arg( request.filterFid() ); + .arg( quotedColumn( mSource->mDefinition.uid() ) ) + .arg( request.filterFid() ); } else if ( request.filterType() == Qgis::FeatureRequestFilterType::Fids ) { @@ -289,8 +287,7 @@ bool QgsVirtualLayerFeatureIterator::fetchFeature( QgsFeature &feature ) feature.setFields( mSource->mFields, /* init */ true ); - if ( mSource->mDefinition.uid().isNull() && - mRequest.filterType() != Qgis::FeatureRequestFilterType::Fid ) + if ( mSource->mDefinition.uid().isNull() && mRequest.filterType() != Qgis::FeatureRequestFilterType::Fid ) { // no id column => autoincrement feature.setId( mFid++ ); @@ -363,8 +360,7 @@ bool QgsVirtualLayerFeatureIterator::fetchFeature( QgsFeature &feature ) if ( mDistanceWithinEngine->distance( feature.geometry().constGet() ) > mRequest.distanceWithin() ) skipFeature = true; } - } - while ( skipFeature ); + } while ( skipFeature ); return true; } diff --git a/src/providers/virtual/qgsvirtuallayerfeatureiterator.h b/src/providers/virtual/qgsvirtuallayerfeatureiterator.h index 2fe276f919ed..dd7c02466184 100644 --- a/src/providers/virtual/qgsvirtuallayerfeatureiterator.h +++ b/src/providers/virtual/qgsvirtuallayerfeatureiterator.h @@ -26,7 +26,7 @@ email : hugo dot mercier at oslandia dot com #include #include -class QgsVirtualLayerFeatureSource final: public QgsAbstractFeatureSource +class QgsVirtualLayerFeatureSource final : public QgsAbstractFeatureSource { public: QgsVirtualLayerFeatureSource( const QgsVirtualLayerProvider *p ); @@ -34,13 +34,12 @@ class QgsVirtualLayerFeatureSource final: public QgsAbstractFeatureSource QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) override; private: - // NOTE: this is really bad and should be removed. // it's only here to guard mSqlite - because if the provider is removed // then mSqlite will be meaningless. // this needs to be totally reworked so that mSqlite no longer depends on the provider // and can be fully encapsulated here - QPointer< const QgsVirtualLayerProvider > mProvider; + QPointer mProvider; QString mPath; QgsVirtualLayerDefinition mDefinition; @@ -53,7 +52,7 @@ class QgsVirtualLayerFeatureSource final: public QgsAbstractFeatureSource friend class QgsVirtualLayerFeatureIterator; }; -class QgsVirtualLayerFeatureIterator final: public QgsAbstractFeatureIteratorFromSource +class QgsVirtualLayerFeatureIterator final : public QgsAbstractFeatureIteratorFromSource { public: QgsVirtualLayerFeatureIterator( QgsVirtualLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request ); @@ -63,11 +62,9 @@ class QgsVirtualLayerFeatureIterator final: public QgsAbstractFeatureIteratorFro bool close() override; protected: - bool fetchFeature( QgsFeature &feature ) override; private: - std::unique_ptr mQuery; QgsAttributeList mAttributes; @@ -76,8 +73,8 @@ class QgsVirtualLayerFeatureIterator final: public QgsAbstractFeatureIteratorFro QgsCoordinateTransform mTransform; QgsRectangle mFilterRect; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; - std::unique_ptr< QgsGeometryEngine > mRectEngine; + std::unique_ptr mDistanceWithinEngine; + std::unique_ptr mRectEngine; }; #endif diff --git a/src/providers/virtual/qgsvirtuallayerprovider.cpp b/src/providers/virtual/qgsvirtuallayerprovider.cpp index 34bcb9c75a3b..1d6029df61a7 100644 --- a/src/providers/virtual/qgsvirtuallayerprovider.cpp +++ b/src/providers/virtual/qgsvirtuallayerprovider.cpp @@ -42,12 +42,15 @@ const QString QgsVirtualLayerProvider::VIRTUAL_LAYER_KEY = QStringLiteral( "virt const QString QgsVirtualLayerProvider::VIRTUAL_LAYER_DESCRIPTION = QStringLiteral( "Virtual layer data provider" ); const QString QgsVirtualLayerProvider::VIRTUAL_LAYER_QUERY_VIEW = QStringLiteral( "_query" ); -#define PROVIDER_ERROR( msg ) do { mError = QgsError( msg, QgsVirtualLayerProvider::VIRTUAL_LAYER_KEY ); QgsDebugError( msg ); } while(0) +#define PROVIDER_ERROR( msg ) \ + do \ + { \ + mError = QgsError( msg, QgsVirtualLayerProvider::VIRTUAL_LAYER_KEY ); \ + QgsDebugError( msg ); \ + } while ( 0 ) -QgsVirtualLayerProvider::QgsVirtualLayerProvider( QString const &uri, - const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) +QgsVirtualLayerProvider::QgsVirtualLayerProvider( QString const &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags ) : QgsVectorDataProvider( uri, options, flags ) { mError.clear(); @@ -131,7 +134,7 @@ bool QgsVirtualLayerProvider::loadSourceLayers() connect( vl, &QgsVectorLayer::featureAdded, this, &QgsVirtualLayerProvider::invalidateStatistics ); connect( vl, &QgsVectorLayer::featureDeleted, this, &QgsVirtualLayerProvider::invalidateStatistics ); connect( vl, &QgsVectorLayer::geometryChanged, this, &QgsVirtualLayerProvider::invalidateStatistics ); - connect( vl, &QgsVectorLayer::updatedFields, this, [ = ] { createVirtualTable( vl, layer.name() ); } ); + connect( vl, &QgsVectorLayer::updatedFields, this, [=] { createVirtualTable( vl, layer.name() ); } ); } else { @@ -233,7 +236,6 @@ bool QgsVirtualLayerProvider::createIt() QVector gFields; if ( !mDefinition.query().isEmpty() ) { - const QStringList tables = referencedTables( mDefinition.query() ); const auto constTables = tables; for ( const QString &tname : constTables ) @@ -317,10 +319,8 @@ bool QgsVirtualLayerProvider::createIt() source.replace( QLatin1String( "'" ), QLatin1String( "''" ) ); const QString encoding = mLayers.at( i ).encoding; const QString createStr = QStringLiteral( "DROP TABLE IF EXISTS \"%1\"; CREATE VIRTUAL TABLE \"%1\" USING QgsVLayer('%2','%4',%3)" ) - .arg( vname, - provider, - encoding, - source ); // source must be the last argument here, since it can contains '%x' strings that would be replaced + .arg( vname, provider, encoding, + source ); // source must be the last argument here, since it can contains '%x' strings that would be replaced Sqlite::Query::exec( mSqlite.get(), createStr ); } } @@ -422,8 +422,7 @@ bool QgsVirtualLayerProvider::createIt() // create a view const QString viewStr = QStringLiteral( "DROP VIEW IF EXISTS %1; CREATE VIEW %1 AS %2" ) - .arg( VIRTUAL_LAYER_QUERY_VIEW, - mDefinition.query() ); + .arg( VIRTUAL_LAYER_QUERY_VIEW, mDefinition.query() ); Sqlite::Query::exec( mSqlite.get(), viewStr ); } else @@ -579,10 +578,11 @@ void QgsVirtualLayerProvider::updateStatistics() const { sql += QStringLiteral( ", Min(MbrMinX(%1)), Min(MbrMinY(%1)), Max(MbrMaxX(%1)), Max(MbrMaxY(%1))" - ).arg( QgsSqliteUtils::quotedIdentifier( mDefinition.geometryField() ) ); + ) + .arg( QgsSqliteUtils::quotedIdentifier( mDefinition.geometryField() ) ); } - sql += QStringLiteral( " FROM %1" ) .arg( mTableName ); + sql += QStringLiteral( " FROM %1" ).arg( mTableName ); if ( !mSubset.isEmpty() ) { @@ -693,7 +693,8 @@ QSet QgsVirtualLayerProvider::dependencies() const QgsVirtualLayerProvider *QgsVirtualLayerProviderMetadata::createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, - Qgis::DataProviderReadFlags flags ) + Qgis::DataProviderReadFlags flags +) { return new QgsVirtualLayerProvider( uri, options, flags ); } @@ -704,7 +705,7 @@ QString QgsVirtualLayerProviderMetadata::absoluteToRelativeUri( const QString &u QStringList theURIParts; QUrlQuery query = QUrlQuery( urlSource.query() ); - QList > queryItems = query.queryItems(); + QList> queryItems = query.queryItems(); for ( int i = 0; i < queryItems.size(); i++ ) { @@ -729,7 +730,7 @@ QString QgsVirtualLayerProviderMetadata::absoluteToRelativeUri( const QString &u theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] ); } - queryItems[i].second = theURIParts.join( QLatin1Char( ':' ) ) ; + queryItems[i].second = theURIParts.join( QLatin1Char( ':' ) ); } } @@ -746,7 +747,7 @@ QString QgsVirtualLayerProviderMetadata::relativeToAbsoluteUri( const QString &u QStringList theURIParts; QUrlQuery query = QUrlQuery( urlSource.query() ); - QList > queryItems = query.queryItems(); + QList> queryItems = query.queryItems(); for ( int i = 0; i < queryItems.size(); i++ ) { @@ -780,7 +781,7 @@ QString QgsVirtualLayerProviderMetadata::relativeToAbsoluteUri( const QString &u } theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] ); - queryItems[i].second = theURIParts.join( QLatin1Char( ':' ) ) ; + queryItems[i].second = theURIParts.join( QLatin1Char( ':' ) ); } } @@ -796,8 +797,8 @@ QList QgsVirtualLayerProviderMetadata::supportedLayerTypes() co return { Qgis::LayerType::Vector }; } -QgsVirtualLayerProviderMetadata::QgsVirtualLayerProviderMetadata(): - QgsProviderMetadata( QgsVirtualLayerProvider::VIRTUAL_LAYER_KEY, QgsVirtualLayerProvider::VIRTUAL_LAYER_DESCRIPTION ) +QgsVirtualLayerProviderMetadata::QgsVirtualLayerProviderMetadata() + : QgsProviderMetadata( QgsVirtualLayerProvider::VIRTUAL_LAYER_KEY, QgsVirtualLayerProvider::VIRTUAL_LAYER_DESCRIPTION ) { } diff --git a/src/providers/virtual/qgsvirtuallayerprovider.h b/src/providers/virtual/qgsvirtuallayerprovider.h index a97c2c5c00e7..9c0e9997bae6 100644 --- a/src/providers/virtual/qgsvirtuallayerprovider.h +++ b/src/providers/virtual/qgsvirtuallayerprovider.h @@ -28,11 +28,10 @@ email : hugo dot mercier at oslandia dot com class QgsVirtualLayerFeatureIterator; -class QgsVirtualLayerProvider final: public QgsVectorDataProvider +class QgsVirtualLayerProvider final : public QgsVectorDataProvider { Q_OBJECT public: - static const QString VIRTUAL_LAYER_KEY; static const QString VIRTUAL_LAYER_DESCRIPTION; static const QString VIRTUAL_LAYER_QUERY_VIEW; @@ -68,7 +67,6 @@ class QgsVirtualLayerProvider final: public QgsVectorDataProvider static QString providerKey(); private: - // file on disk QString mPath; @@ -77,24 +75,24 @@ class QgsVirtualLayerProvider final: public QgsVectorDataProvider // underlying vector layers struct SourceLayer { - SourceLayer() = default; - SourceLayer( QgsVectorLayer *l, const QString &n = QString() ) - : layer( l ) - , name( n ) - {} - SourceLayer( const QString &p, const QString &s, const QString &n, const QString &e = QStringLiteral( "UTF-8" ) ) - : name( n ) - , source( s ) - , provider( p ) - , encoding( e ) - {} - // non-null if it refers to a live layer - QgsVectorLayer *layer = nullptr; - QString name; - // non-empty if it is an embedded layer - QString source; - QString provider; - QString encoding; + SourceLayer() = default; + SourceLayer( QgsVectorLayer *l, const QString &n = QString() ) + : layer( l ) + , name( n ) + {} + SourceLayer( const QString &p, const QString &s, const QString &n, const QString &e = QStringLiteral( "UTF-8" ) ) + : name( n ) + , source( s ) + , provider( p ) + , encoding( e ) + {} + // non-null if it refers to a live layer + QgsVectorLayer *layer = nullptr; + QString name; + // non-empty if it is an embedded layer + QString source; + QString provider; + QString encoding; }; typedef QVector SourceLayers; SourceLayers mLayers; @@ -132,10 +130,9 @@ class QgsVirtualLayerProvider final: public QgsVectorDataProvider private slots: void invalidateStatistics(); - }; -class QgsVirtualLayerProviderMetadata final: public QgsProviderMetadata +class QgsVirtualLayerProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: @@ -144,7 +141,7 @@ class QgsVirtualLayerProviderMetadata final: public QgsProviderMetadata QgsVirtualLayerProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; QString absoluteToRelativeUri( const QString &uri, const QgsReadWriteContext &context ) const override; QString relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; // clazy:excludeall=qstring-allocations diff --git a/src/providers/virtual/qgsvirtuallayerprovidergui.cpp b/src/providers/virtual/qgsvirtuallayerprovidergui.cpp index edd6bcf8dd2c..6d6e08f9e55b 100644 --- a/src/providers/virtual/qgsvirtuallayerprovidergui.cpp +++ b/src/providers/virtual/qgsvirtuallayerprovidergui.cpp @@ -24,7 +24,6 @@ class QgsVirtualSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "virtual" ); } QString text() const override { return QObject::tr( "Virtual Layer" ); } int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 60; } diff --git a/src/providers/virtual/qgsvirtuallayerprovidergui.h b/src/providers/virtual/qgsvirtuallayerprovidergui.h index 07e7ff9ba27e..17e6048e09e1 100644 --- a/src/providers/virtual/qgsvirtuallayerprovidergui.h +++ b/src/providers/virtual/qgsvirtuallayerprovidergui.h @@ -15,7 +15,7 @@ #include "qgsproviderguimetadata.h" -class QgsVirtualLayerProviderGuiMetadata final: public QgsProviderGuiMetadata +class QgsVirtualLayerProviderGuiMetadata final : public QgsProviderGuiMetadata { public: QgsVirtualLayerProviderGuiMetadata(); diff --git a/src/providers/virtual/qgsvirtuallayerqueryparser.cpp b/src/providers/virtual/qgsvirtuallayerqueryparser.cpp index acdde8916df4..843c93e322e7 100644 --- a/src/providers/virtual/qgsvirtuallayerqueryparser.cpp +++ b/src/providers/virtual/qgsvirtuallayerqueryparser.cpp @@ -35,7 +35,7 @@ namespace QgsVirtualLayerQueryParser // open an empty in-memory sqlite database and execute the query // sqlite will return an error for each missing table // this way we know the list of tables referenced by the query - const QgsScopedSqlite db( QStringLiteral( ":memory:" ), /*withExtension=*/ false ); + const QgsScopedSqlite db( QStringLiteral( ":memory:" ), /*withExtension=*/false ); const QString noSuchError = QStringLiteral( "no such table: " ); @@ -110,7 +110,7 @@ namespace QgsVirtualLayerQueryParser return defs; } -// set the type of the column type, given its text representation + // set the type of the column type, given its text representation void setColumnDefType( const QString &columnType, ColumnDef &d ) { // geometry type @@ -153,7 +153,7 @@ namespace QgsVirtualLayerQueryParser { const QString columnName = q.columnText( 1 ); const QString columnType = q.columnText( 2 ); - if ( ! columnType.startsWith( QLatin1String( "geometry" ) ) ) + if ( !columnType.startsWith( QLatin1String( "geometry" ) ) ) continue; d.setName( columnName ); @@ -288,4 +288,4 @@ namespace QgsVirtualLayerQueryParser return td; } -} // namespace +} // namespace QgsVirtualLayerQueryParser diff --git a/src/providers/virtual/qgsvirtuallayerqueryparser.h b/src/providers/virtual/qgsvirtuallayerqueryparser.h index 4752706bb70b..7d0c4929cf20 100644 --- a/src/providers/virtual/qgsvirtuallayerqueryparser.h +++ b/src/providers/virtual/qgsvirtuallayerqueryparser.h @@ -56,11 +56,19 @@ namespace QgsVirtualLayerQueryParser void setName( const QString &name ) { mName = name; } bool isGeometry() const { return mType == QMetaType::Type::User; } - void setGeometry( Qgis::WkbType wkbType ) { mType = QMetaType::Type::User; mWkbType = wkbType; } + void setGeometry( Qgis::WkbType wkbType ) + { + mType = QMetaType::Type::User; + mWkbType = wkbType; + } long srid() const { return mSrid; } void setSrid( long srid ) { mSrid = srid; } - void setScalarType( QMetaType::Type t ) { mType = t; mWkbType = Qgis::WkbType::NoGeometry; } + void setScalarType( QMetaType::Type t ) + { + mType = t; + mWkbType = Qgis::WkbType::NoGeometry; + } QMetaType::Type scalarType() const { return mType; } Qgis::WkbType wkbType() const { return mWkbType; } @@ -89,6 +97,6 @@ namespace QgsVirtualLayerQueryParser //! Gets the column types of a virtual table TableDef tableDefinitionFromVirtualTable( sqlite3 *db, const QString &tableName ); -} +} // namespace QgsVirtualLayerQueryParser #endif diff --git a/src/providers/virtual/qgsvirtuallayersourceselect.cpp b/src/providers/virtual/qgsvirtuallayersourceselect.cpp index b0cb38a8a6a5..de176916a157 100644 --- a/src/providers/virtual/qgsvirtuallayersourceselect.cpp +++ b/src/providers/virtual/qgsvirtuallayersourceselect.cpp @@ -78,29 +78,29 @@ QgsVirtualLayerSourceSelect::QgsVirtualLayerSourceSelect( QWidget *parent, Qt::W buttonBox->addButton( pbn, QDialogButtonBox::ActionRole ); connect( pbn, &QAbstractButton::clicked, this, &QgsVirtualLayerSourceSelect::testQuery ); - mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::Point ), tr( "Point" ), static_cast< long long >( Qgis::WkbType::Point ) ); - mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::LineString ), tr( "LineString" ), static_cast< long long >( Qgis::WkbType::LineString ) ); - mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::Polygon ), tr( "Polygon" ), static_cast< long long >( Qgis::WkbType::Polygon ) ); - mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::MultiPoint ), tr( "MultiPoint" ), static_cast< long long >( Qgis::WkbType::MultiPoint ) ); - mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::MultiLineString ), tr( "MultiLineString" ), static_cast< long long >( Qgis::WkbType::MultiLineString ) ); - mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::MultiPolygon ), tr( "MultiPolygon" ), static_cast< long long >( Qgis::WkbType::MultiPolygon ) ); + mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::Point ), tr( "Point" ), static_cast( Qgis::WkbType::Point ) ); + mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::LineString ), tr( "LineString" ), static_cast( Qgis::WkbType::LineString ) ); + mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::Polygon ), tr( "Polygon" ), static_cast( Qgis::WkbType::Polygon ) ); + mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::MultiPoint ), tr( "MultiPoint" ), static_cast( Qgis::WkbType::MultiPoint ) ); + mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::MultiLineString ), tr( "MultiLineString" ), static_cast( Qgis::WkbType::MultiLineString ) ); + mGeometryType->addItem( QgsIconUtils::iconForWkbType( Qgis::WkbType::MultiPolygon ), tr( "MultiPolygon" ), static_cast( Qgis::WkbType::MultiPolygon ) ); mQueryEdit->setLineNumbersVisible( true ); connect( mBrowseCRSBtn, &QAbstractButton::clicked, this, &QgsVirtualLayerSourceSelect::browseCRS ); - connect( mAddLayerBtn, &QAbstractButton::clicked, this, [ = ] { addLayerPrivate( true ); } ); + connect( mAddLayerBtn, &QAbstractButton::clicked, this, [=] { addLayerPrivate( true ); } ); connect( mRemoveLayerBtn, &QAbstractButton::clicked, this, &QgsVirtualLayerSourceSelect::removeLayer ); connect( mImportLayerBtn, &QAbstractButton::clicked, this, &QgsVirtualLayerSourceSelect::importLayer ); connect( mLayersTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &QgsVirtualLayerSourceSelect::tableRowChanged ); // prepare provider list - const QSet< QString > vectorLayerProviders = QgsProviderRegistry::instance()->providersForLayerType( Qgis::LayerType::Vector ); + const QSet vectorLayerProviders = QgsProviderRegistry::instance()->providersForLayerType( Qgis::LayerType::Vector ); mProviderList = qgis::setToList( vectorLayerProviders ); std::sort( mProviderList.begin(), mProviderList.end() ); // It needs to find the layertree view without relying on the parent // being the main window - const QList< QWidget * > widgets = qApp->allWidgets(); + const QList widgets = qApp->allWidgets(); for ( const QWidget *widget : widgets ) { if ( !mTreeView ) @@ -132,7 +132,7 @@ void QgsVirtualLayerSourceSelect::setBrowserModel( QgsBrowserModel *model ) QgsAbstractDataSourceWidget::setBrowserModel( model ); for ( int i = 0; i < mLayersTable->rowCount(); i++ ) { - qobject_cast< QgsVirtualLayerSourceWidget * >( mLayersTable->cellWidget( i, LayerColumn::Source ) )->setBrowserModel( model ); + qobject_cast( mLayersTable->cellWidget( i, LayerColumn::Source ) )->setBrowserModel( model ); } } @@ -186,7 +186,7 @@ void QgsVirtualLayerSourceSelect::layerComboChanged( int idx ) const auto constSourceLayers = def.sourceLayers(); for ( const QgsVirtualLayerDefinition::SourceLayer &l : constSourceLayers ) { - if ( ! l.isReferenced() ) + if ( !l.isReferenced() ) { addEmbeddedLayer( l.name(), l.provider(), l.encoding(), l.source() ); } @@ -215,11 +215,11 @@ QgsVirtualLayerDefinition QgsVirtualLayerSourceSelect::getVirtualLayerDef() { QgsVirtualLayerDefinition def; - if ( ! mQueryEdit->text().isEmpty() ) + if ( !mQueryEdit->text().isEmpty() ) { def.setQuery( mQueryEdit->text() ); } - if ( mUIDColumnNameChck->isChecked() && ! mUIDField->text().isEmpty() ) + if ( mUIDColumnNameChck->isChecked() && !mUIDField->text().isEmpty() ) { def.setUid( mUIDField->text() ); } @@ -241,7 +241,7 @@ QgsVirtualLayerDefinition QgsVirtualLayerSourceSelect::getVirtualLayerDef() const QString name = mLayersTable->item( i, LayerColumn::Name )->text(); const QString provider = qobject_cast( mLayersTable->cellWidget( i, LayerColumn::Provider ) )->currentData().toString(); const QString encoding = qobject_cast( mLayersTable->cellWidget( i, LayerColumn::Encoding ) )->currentText(); - const QString source = qobject_cast< QgsVirtualLayerSourceWidget * >( mLayersTable->cellWidget( i, LayerColumn::Source ) )->source(); + const QString source = qobject_cast( mLayersTable->cellWidget( i, LayerColumn::Source ) )->source(); def.addSource( name, source, provider, encoding ); } @@ -254,7 +254,7 @@ bool QgsVirtualLayerSourceSelect::preFlight() // If the definition is empty just do nothing. // TODO: a validation function that can enable/disable the test button // according to the validity of the active layer definition - if ( ! def.toString().isEmpty() ) + if ( !def.toString().isEmpty() ) { const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() }; std::unique_ptr vl( new QgsVectorLayer( def.toString(), QStringLiteral( "test" ), QStringLiteral( "virtual" ), options ) ); @@ -450,7 +450,7 @@ void QgsVirtualLayerSourceSelect::importLayer() void QgsVirtualLayerSourceSelect::addButtonClicked() { - if ( ! preFlight() ) + if ( !preFlight() ) { return; } @@ -481,7 +481,7 @@ void QgsVirtualLayerSourceSelect::addButtonClicked() } // This check is to prevent a crash, a proper implementation should handle // the Add button state when a virtual layer definition is available - if ( ! def.toString().isEmpty() ) + if ( !def.toString().isEmpty() ) { if ( replace ) { @@ -508,11 +508,11 @@ void QgsVirtualLayerSourceSelect::showHelp() void QgsVirtualLayerSourceSelect::rowSourceChanged() { - QgsVirtualLayerSourceWidget *widget = qobject_cast< QgsVirtualLayerSourceWidget * >( sender() ); + QgsVirtualLayerSourceWidget *widget = qobject_cast( sender() ); // we have to find the matching row for the source widget which was changed for ( int row = 0; row < mLayersTable->rowCount(); row++ ) { - QgsVirtualLayerSourceWidget *rowSourceWidget = qobject_cast< QgsVirtualLayerSourceWidget * >( mLayersTable->cellWidget( row, LayerColumn::Source ) ); + QgsVirtualLayerSourceWidget *rowSourceWidget = qobject_cast( mLayersTable->cellWidget( row, LayerColumn::Source ) ); if ( rowSourceWidget == widget ) { // automatically update provider to match @@ -585,7 +585,7 @@ QString QgsVirtualLayerSourceWidget::provider() const void QgsVirtualLayerSourceWidget::browseForLayer() { - QgsDataSourceSelectDialog dlg( qobject_cast< QgsBrowserGuiModel * >( mBrowserModel ), true, Qgis::LayerType::Vector, this ); + QgsDataSourceSelectDialog dlg( qobject_cast( mBrowserModel ), true, Qgis::LayerType::Vector, this ); dlg.setWindowTitle( tr( "Select Layer Source" ) ); QString source = mLineEdit->text(); @@ -594,8 +594,7 @@ void QgsVirtualLayerSourceWidget::browseForLayer() { const QString path = sourceParts.value( QStringLiteral( "path" ) ).toString(); const QString closestPath = QFile::exists( path ) ? path : QgsFileUtils::findClosestExistingPath( path ); - source.replace( path, QStringLiteral( "%2" ).arg( QUrl::fromLocalFile( closestPath ).toString(), - path ) ); + source.replace( path, QStringLiteral( "%2" ).arg( QUrl::fromLocalFile( closestPath ).toString(), path ) ); } dlg.setDescription( tr( "Current source: %1" ).arg( source ) ); diff --git a/src/providers/virtual/qgsvirtuallayersourceselect.h b/src/providers/virtual/qgsvirtuallayersourceselect.h index aedb97b3ddd1..6854bee7b3f7 100644 --- a/src/providers/virtual/qgsvirtuallayersourceselect.h +++ b/src/providers/virtual/qgsvirtuallayersourceselect.h @@ -37,7 +37,6 @@ class QgsVirtualLayerSourceWidget : public QWidget Q_OBJECT public: - QgsVirtualLayerSourceWidget( QWidget *parent = nullptr ); void setBrowserModel( QgsBrowserModel *model ); @@ -52,8 +51,8 @@ class QgsVirtualLayerSourceWidget : public QWidget public slots: void browseForLayer(); - private: + private: QLineEdit *mLineEdit = nullptr; QString mProvider; QgsBrowserModel *mBrowserModel = nullptr; @@ -89,7 +88,6 @@ class QgsVirtualLayerSourceSelect : public QgsAbstractDataSourceWidget, private void rowSourceChanged(); private: - enum LayerColumn { Name = 0, diff --git a/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp b/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp index 9fa8ee3a8a5f..88b79971292d 100644 --- a/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp +++ b/src/providers/virtual/qgsvirtuallayersqlitehelper.cpp @@ -28,7 +28,7 @@ QgsScopedSqlite::QgsScopedSqlite( const QString &path, bool withExtension ) { // register a statically-linked function as extension // for all future database connection - sqlite3_auto_extension( reinterpret_cast < void( * )() > ( qgsvlayerModuleInit ) ); + sqlite3_auto_extension( reinterpret_cast( qgsvlayerModuleInit ) ); } int r; r = sqlite3_open( path.toUtf8().constData(), &db_ ); @@ -214,18 +214,18 @@ namespace Sqlite QString Query::columnText( int i ) const { const int size = sqlite3_column_bytes( stmt_, i ); - const char *str = reinterpret_cast< const char * >( sqlite3_column_text( stmt_, i ) ); + const char *str = reinterpret_cast( sqlite3_column_text( stmt_, i ) ); return QString::fromUtf8( str, size ); } QByteArray Query::columnBlob( int i ) const { const int size = sqlite3_column_bytes( stmt_, i ); - const char *data = reinterpret_cast< const char * >( sqlite3_column_blob( stmt_, i ) ); + const char *data = reinterpret_cast( sqlite3_column_blob( stmt_, i ) ); // data is not copied. QByteArray is just here a augmented pointer return QByteArray::fromRawData( data, size ); } sqlite3_stmt *Query::stmt() { return stmt_; } -} +} // namespace Sqlite diff --git a/src/providers/virtual/qgsvirtuallayersqlitehelper.h b/src/providers/virtual/qgsvirtuallayersqlitehelper.h index 2d52ba597cc2..a14af2c62c55 100644 --- a/src/providers/virtual/qgsvirtuallayersqlitehelper.h +++ b/src/providers/virtual/qgsvirtuallayersqlitehelper.h @@ -21,10 +21,7 @@ extern "C" { #include - int qgsvlayerModuleInit( sqlite3 *db, - char **pzErrMsg, - void *unused /*const sqlite3_api_routines *pApi*/ ); - + int qgsvlayerModuleInit( sqlite3 *db, char **pzErrMsg, void *unused /*const sqlite3_api_routines *pApi*/ ); } // RAII class for sqlite3* @@ -90,6 +87,6 @@ namespace Sqlite sqlite3_stmt *stmt_ = nullptr; int nBind_; }; -} +} // namespace Sqlite #endif diff --git a/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp b/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp index 3dbc4ae80c19..8327bcd48024 100644 --- a/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp +++ b/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp @@ -68,7 +68,7 @@ void initVirtualLayerMetadata( sqlite3 *db ) void deleteGeometryBlob( void *p ) { - delete[]( reinterpret_cast< unsigned char * >( p ) ); + delete[] ( reinterpret_cast( p ) ); } //----------------------------------------------------------------------- @@ -83,9 +83,9 @@ void invalidateTable( void *b ); struct VTable { // minimal set of members (see sqlite3.h) - const sqlite3_module *pModule; /* The module for this virtual table */ - int nRef; /* NO LONGER USED */ - char *zErrMsg; /* Error message from sqlite3_mprintf() */ + const sqlite3_module *pModule; /* The module for this virtual table */ + int nRef; /* NO LONGER USED */ + char *zErrMsg; /* Error message from sqlite3_mprintf() */ VTable( sqlite3 *db, QgsVectorLayer *layer ) : pModule( nullptr ) @@ -160,7 +160,6 @@ struct VTable QgsFields fields() const { return mFields; } private: - VTable( const VTable &other ) = delete; VTable &operator=( const VTable &other ) = delete; @@ -229,7 +228,7 @@ struct VTable // the type of a column can be declared with two numeric arguments, usually for setting numeric precision // we are using them to set the geometry type and srid // these will be reused by the provider when it will introspect the query to detect types - sqlFields << QStringLiteral( "geometry geometry(%1,%2)" ).arg( static_cast< quint32>( layerType ) ).arg( provider->crs().postgisSrid() ); + sqlFields << QStringLiteral( "geometry geometry(%1,%2)" ).arg( static_cast( layerType ) ).arg( provider->crs().postgisSrid() ); // add a hidden field for rtree filtering sqlFields << QStringLiteral( "_search_frame_ HIDDEN BLOB" ); @@ -255,65 +254,65 @@ void invalidateTable( void *p ) struct VTableCursor { - // minimal set of members (see sqlite3.h) - VTable *mVtab = nullptr; + // minimal set of members (see sqlite3.h) + VTable *mVtab = nullptr; - // specific members - QgsFeature mCurrentFeature; - QgsFeatureIterator mIterator; - bool mEof; + // specific members + QgsFeature mCurrentFeature; + QgsFeatureIterator mIterator; + bool mEof; - explicit VTableCursor( VTable *vtab ) - : mVtab( vtab ) - , mEof( true ) - {} + explicit VTableCursor( VTable *vtab ) + : mVtab( vtab ) + , mEof( true ) + {} - void filter( const QgsFeatureRequest &request ) - { - if ( !mVtab->valid() ) + void filter( const QgsFeatureRequest &request ) { - mEof = true; - return; - } + if ( !mVtab->valid() ) + { + mEof = true; + return; + } - mIterator = mVtab->layer() ? mVtab->layer()->getFeatures( request ) : mVtab->provider()->getFeatures( request ); - // get on the first record - mEof = false; - next(); - } + mIterator = mVtab->layer() ? mVtab->layer()->getFeatures( request ) : mVtab->provider()->getFeatures( request ); + // get on the first record + mEof = false; + next(); + } - void next() - { - if ( !mEof ) + void next() { - mEof = !mIterator.nextFeature( mCurrentFeature ); + if ( !mEof ) + { + mEof = !mIterator.nextFeature( mCurrentFeature ); + } } - } - bool eof() const { return mEof; } + bool eof() const { return mEof; } - int nColumns() const - { - if ( !mVtab->valid() ) - return 0; - return mVtab->layer() ? mVtab->layer()->fields().count() : mVtab->provider()->fields().count(); - } + int nColumns() const + { + if ( !mVtab->valid() ) + return 0; + return mVtab->layer() ? mVtab->layer()->fields().count() : mVtab->provider()->fields().count(); + } - sqlite3_int64 currentId() const { return mCurrentFeature.id(); } + sqlite3_int64 currentId() const { return mCurrentFeature.id(); } - QVariant currentAttribute( int column ) const { return mCurrentFeature.attribute( column ); } + QVariant currentAttribute( int column ) const { return mCurrentFeature.attribute( column ); } - QPair currentGeometry() const - { - int blob_len = 0; - char *blob = nullptr; - QgsGeometry g = mCurrentFeature.geometry(); - if ( ! g.isNull() ) + QPair currentGeometry() const { - qgsGeometryToSpatialiteBlob( g, mVtab->crs(), blob, blob_len ); + int blob_len = 0; + char *blob = nullptr; + QgsGeometry g = mCurrentFeature.geometry(); + if ( !g.isNull() ) + { + qgsGeometryToSpatialiteBlob( g, mVtab->crs(), blob, blob_len ); + } + return qMakePair( blob, blob_len ); } - return qMakePair( blob, blob_len ); - } }; void getGeometryType( const QgsVectorDataProvider *provider, QString &geometryTypeStr, int &geometryDim, int &geometryWkbType, long &srid ) @@ -333,8 +332,7 @@ int vtableCreateConnect( sqlite3 *sql, void *aux, int argc, const char *const *a Q_UNUSED( aux ) Q_UNUSED( isCreated ) - auto returnStrError = [&outErr]( const QString & err ) - { + auto returnStrError = [&outErr]( const QString &err ) { if ( outErr ) { const int size = err.toUtf8().size(); @@ -375,7 +373,6 @@ int vtableCreateConnect( sqlite3 *sql, void *aux, int argc, const char *const *a return SQLITE_ERROR; } newVtab.reset( new VTable( sql, qobject_cast( l ) ) ); - } else if ( argc == 5 || argc == 6 ) { @@ -419,7 +416,7 @@ int vtableCreateConnect( sqlite3 *sql, void *aux, int argc, const char *const *a return r; } - *outVtab = reinterpret_cast< sqlite3_vtab * >( newVtab.release() ); + *outVtab = reinterpret_cast( newVtab.release() ); return SQLITE_OK; #undef RETURN_CPPSTR_ERROR } @@ -440,7 +437,7 @@ int vtableCreate( sqlite3 *sql, void *aux, int argc, const char *const *argv, sq { if ( outErr ) { - *outErr = reinterpret_cast< char * >( sqlite3_malloc( static_cast< int >( strlen( e.what() ) ) + 1 ) ); + *outErr = reinterpret_cast( sqlite3_malloc( static_cast( strlen( e.what() ) ) + 1 ) ); strcpy( *outErr, e.what() ); } return SQLITE_ERROR; @@ -482,13 +479,11 @@ int vtableRename( sqlite3_vtab *vtab, const char *newName ) int vtableBestIndex( sqlite3_vtab *pvtab, sqlite3_index_info *indexInfo ) { - VTable *vtab = reinterpret_cast< VTable * >( pvtab ); + VTable *vtab = reinterpret_cast( pvtab ); for ( int i = 0; i < indexInfo->nConstraint; i++ ) { // request for primary key filter with '=' - if ( ( indexInfo->aConstraint[i].usable ) && - ( vtab->pkColumn() == indexInfo->aConstraint[i].iColumn ) && - ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_EQ ) ) + if ( ( indexInfo->aConstraint[i].usable ) && ( vtab->pkColumn() == indexInfo->aConstraint[i].iColumn ) && ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_EQ ) ) { indexInfo->aConstraintUsage[i].argvIndex = 1; indexInfo->aConstraintUsage[i].omit = 1; @@ -500,22 +495,16 @@ int vtableBestIndex( sqlite3_vtab *pvtab, sqlite3_index_info *indexInfo ) } // request for filter with a comparison operator - if ( ( indexInfo->aConstraint[i].usable ) && - ( indexInfo->aConstraint[i].iColumn >= 0 ) && - ( indexInfo->aConstraint[i].iColumn < vtab->fields().count() ) && - ( ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_EQ ) || // if no PK - ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_GT ) || - ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_LE ) || - ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_LT ) || - ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_GE ) + if ( ( indexInfo->aConstraint[i].usable ) && ( indexInfo->aConstraint[i].iColumn >= 0 ) && ( indexInfo->aConstraint[i].iColumn < vtab->fields().count() ) && ( ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_EQ ) || // if no PK + ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_GT ) || ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_LE ) || ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_LT ) || ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_GE ) #ifdef SQLITE_INDEX_CONSTRAINT_LIKE - || ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_LIKE ) + || ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_LIKE ) #endif ) ) { indexInfo->aConstraintUsage[i].argvIndex = 1; indexInfo->aConstraintUsage[i].omit = 1; - indexInfo->idxNum = 3; // expression filter + indexInfo->idxNum = 3; // expression filter indexInfo->estimatedCost = 2.0; // probably better than no index QString expr = QgsExpression::quotedColumnRef( vtab->fields().at( indexInfo->aConstraint[i].iColumn ).name() ); @@ -546,7 +535,7 @@ int vtableBestIndex( sqlite3_vtab *pvtab, sqlite3_index_info *indexInfo ) } QByteArray ba = expr.toUtf8(); - char *cp = ( char * )sqlite3_malloc( ba.size() + 1 ); + char *cp = ( char * ) sqlite3_malloc( ba.size() + 1 ); memcpy( cp, ba.constData(), ba.size() + 1 ); indexInfo->idxStr = cp; @@ -557,8 +546,7 @@ int vtableBestIndex( sqlite3_vtab *pvtab, sqlite3_index_info *indexInfo ) // request for rtree filtering if ( ( indexInfo->aConstraint[i].usable ) && // request on _search_frame_ column - ( vtab->fields().count() + 1 == indexInfo->aConstraint[i].iColumn ) && - ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_EQ ) ) + ( vtab->fields().count() + 1 == indexInfo->aConstraint[i].iColumn ) && ( indexInfo->aConstraint[i].op == SQLITE_INDEX_CONSTRAINT_EQ ) ) { indexInfo->aConstraintUsage[i].argvIndex = 1; // do not test for equality, since it is used for filtering, not to return an actual value @@ -579,8 +567,8 @@ int vtableBestIndex( sqlite3_vtab *pvtab, sqlite3_index_info *indexInfo ) int vtableOpen( sqlite3_vtab *vtab, sqlite3_vtab_cursor **outCursor ) { - VTableCursor *ncursor = new VTableCursor( reinterpret_cast< VTable * >( vtab ) ); - *outCursor = reinterpret_cast< sqlite3_vtab_cursor * >( ncursor ); + VTableCursor *ncursor = new VTableCursor( reinterpret_cast( vtab ) ); + *outCursor = reinterpret_cast( ncursor ); return SQLITE_OK; } @@ -606,7 +594,7 @@ int vtableFilter( sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, i else if ( idxNum == 2 ) { // rtree filter - const char *blob = reinterpret_cast< const char * >( sqlite3_value_blob( argv[0] ) ); + const char *blob = reinterpret_cast( sqlite3_value_blob( argv[0] ) ); if ( blob ) { int bytes = sqlite3_value_bytes( argv[0] ); @@ -795,7 +783,7 @@ void qgisFunctionWrapper( sqlite3_context *ctxt, int nArgs, sqlite3_value **args } // add default value for any omitted optional parameters - QList< QgsExpressionFunction::Parameter > params = foo->parameters(); + QList params = foo->parameters(); for ( int i = variants.count(); i < params.count(); i++ ) variants << QVariant( params[i - 1].defaultValue() ); @@ -834,11 +822,11 @@ void qgisFunctionWrapper( sqlite3_context *ctxt, int nArgs, sqlite3_value **args default: { - if ( ret.userType() == qMetaTypeId< QgsGeometry>() ) + if ( ret.userType() == qMetaTypeId() ) { char *blob = nullptr; int size = 0; - qgsGeometryToSpatialiteBlob( ret.value(), /*srid*/0, blob, size ); + qgsGeometryToSpatialiteBlob( ret.value(), /*srid*/ 0, blob, size ); sqlite3_result_blob( ctxt, blob, size, deleteGeometryBlob ); } else if ( ret.userType() == qMetaTypeId() ) diff --git a/src/providers/virtual/qgsvirtuallayersqlitemodule.h b/src/providers/virtual/qgsvirtuallayersqlitemodule.h index 5f7a1085688b..1d93f233ff8c 100644 --- a/src/providers/virtual/qgsvirtuallayersqlitemodule.h +++ b/src/providers/virtual/qgsvirtuallayersqlitemodule.h @@ -21,25 +21,23 @@ email : hugo dot mercier at oslandia dot com extern "C" { #endif -int vtableCreate( sqlite3 *sql, void *aux, int argc, const char *const *argv, sqlite3_vtab **out_vtab, char **out_err ); -int vtableConnect( sqlite3 *sql, void *aux, int argc, const char *const *argv, sqlite3_vtab **out_vtab, char **out_err ); -int vtableRename( sqlite3_vtab *vtab, const char *new_name ); -int vtableBestIndex( sqlite3_vtab *vtab, sqlite3_index_info * ); -int vtableDisconnect( sqlite3_vtab *vtab ); -int vtableDestroy( sqlite3_vtab *vtab ); - -int vtableOpen( sqlite3_vtab *vtab, sqlite3_vtab_cursor **out_cursor ); -int vtableClose( sqlite3_vtab_cursor * ); -int vtableFilter( sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ); - -int vtableNext( sqlite3_vtab_cursor *cursor ); -int vtableEof( sqlite3_vtab_cursor *cursor ); -int vtableColumn( sqlite3_vtab_cursor *cursor, sqlite3_context *, int ); -int vtableRowId( sqlite3_vtab_cursor *cursor, sqlite3_int64 *out_rowid ); - -int qgsvlayerModuleInit( sqlite3 *db, - char **pzErrMsg, - void *unused /*const sqlite3_api_routines *pApi*/ ); + int vtableCreate( sqlite3 *sql, void *aux, int argc, const char *const *argv, sqlite3_vtab **out_vtab, char **out_err ); + int vtableConnect( sqlite3 *sql, void *aux, int argc, const char *const *argv, sqlite3_vtab **out_vtab, char **out_err ); + int vtableRename( sqlite3_vtab *vtab, const char *new_name ); + int vtableBestIndex( sqlite3_vtab *vtab, sqlite3_index_info * ); + int vtableDisconnect( sqlite3_vtab *vtab ); + int vtableDestroy( sqlite3_vtab *vtab ); + + int vtableOpen( sqlite3_vtab *vtab, sqlite3_vtab_cursor **out_cursor ); + int vtableClose( sqlite3_vtab_cursor * ); + int vtableFilter( sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ); + + int vtableNext( sqlite3_vtab_cursor *cursor ); + int vtableEof( sqlite3_vtab_cursor *cursor ); + int vtableColumn( sqlite3_vtab_cursor *cursor, sqlite3_context *, int ); + int vtableRowId( sqlite3_vtab_cursor *cursor, sqlite3_int64 *out_rowid ); + + int qgsvlayerModuleInit( sqlite3 *db, char **pzErrMsg, void *unused /*const sqlite3_api_routines *pApi*/ ); #ifdef __cplusplus } diff --git a/src/providers/virtualraster/qgsvirtualrasterprovider.cpp b/src/providers/virtualraster/qgsvirtualrasterprovider.cpp index 250234810fac..c052e4654387 100644 --- a/src/providers/virtualraster/qgsvirtualrasterprovider.cpp +++ b/src/providers/virtualraster/qgsvirtualrasterprovider.cpp @@ -25,16 +25,16 @@ QgsVirtualRasterProvider::QgsVirtualRasterProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions ) : QgsRasterDataProvider( uri, providerOptions ) { - bool ok; - QgsRasterDataProvider::VirtualRasterParameters decodedUriParams = QgsRasterDataProvider::decodeVirtualRasterProviderUri( uri, & ok ); + bool ok; + QgsRasterDataProvider::VirtualRasterParameters decodedUriParams = QgsRasterDataProvider::decodeVirtualRasterProviderUri( uri, &ok ); - if ( ! ok ) + if ( !ok ) { mValid = false; return; } - if ( ! decodedUriParams.crs.isValid() ) + if ( !decodedUriParams.crs.isValid() ) { QgsDebugError( "crs is not valid" ); mValid = false; @@ -70,8 +70,7 @@ QgsVirtualRasterProvider::QgsVirtualRasterProvider( const QString &uri, const Qg QList::iterator it; for ( it = decodedUriParams.rInputLayers.begin(); it != decodedUriParams.rInputLayers.end(); ++it ) { - - if ( ! rLayerDict.contains( it->name ) ) + if ( !rLayerDict.contains( it->name ) ) { mValid = false; return; @@ -79,7 +78,7 @@ QgsVirtualRasterProvider::QgsVirtualRasterProvider( const QString &uri, const Qg QgsRasterLayer *rProvidedLayer = new QgsRasterLayer( it->uri, it->name, it->provider ); - if ( ! rProvidedLayer->isValid() ) + if ( !rProvidedLayer->isValid() ) { mValid = false; return; @@ -95,7 +94,7 @@ QgsVirtualRasterProvider::QgsVirtualRasterProvider( const QString &uri, const Qg for ( int j = 0; j < rProvidedLayer->bandCount(); ++j ) { - if ( ! rasterRefs.contains( rProvidedLayer->name() + QStringLiteral( "@" ) + QString::number( j + 1 ) ) ) + if ( !rasterRefs.contains( rProvidedLayer->name() + QStringLiteral( "@" ) + QString::number( j + 1 ) ) ) { continue; } @@ -122,7 +121,7 @@ QgsVirtualRasterProvider::QgsVirtualRasterProvider( const QgsVirtualRasterProvid , mYBlockSize( other.mYBlockSize ) , mFormulaString( other.mFormulaString ) , mLastError( other.mLastError ) - , mRasterLayers{} // see note in other constructor above + , mRasterLayers {} // see note in other constructor above { for ( const auto &it : other.mRasterLayers ) @@ -149,15 +148,15 @@ QgsVirtualRasterProvider::~QgsVirtualRasterProvider() QgsRasterBlock *QgsVirtualRasterProvider::block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback ) { Q_UNUSED( bandNo ); - std::unique_ptr< QgsRasterBlock > tblock = std::make_unique< QgsRasterBlock >( Qgis::DataType::Float64, width, height ); - double *outputData = ( double * )( tblock->bits() ); + std::unique_ptr tblock = std::make_unique( Qgis::DataType::Float64, width, height ); + double *outputData = ( double * ) ( tblock->bits() ); - QMap< QString, QgsRasterBlock * > inputBlocks; + QMap inputBlocks; QVector::const_iterator it = mRasterEntries.constBegin(); for ( ; it != mRasterEntries.constEnd(); ++it ) { - std::unique_ptr< QgsRasterBlock > block; + std::unique_ptr block; if ( it->raster->crs() != mCrs ) { @@ -166,7 +165,7 @@ QgsRasterBlock *QgsVirtualRasterProvider::block( int bandNo, const QgsRectangle proj.setInput( it->raster->dataProvider() ); proj.setPrecision( QgsRasterProjector::Exact ); - std::unique_ptr< QgsRasterBlockFeedback > rasterBlockFeedback( new QgsRasterBlockFeedback() ); + std::unique_ptr rasterBlockFeedback( new QgsRasterBlockFeedback() ); QObject::connect( feedback, &QgsFeedback::canceled, rasterBlockFeedback.get(), &QgsRasterBlockFeedback::cancel ); block.reset( proj.block( it->bandNumber, extent, width, height, rasterBlockFeedback.get() ) ); if ( rasterBlockFeedback->isCanceled() ) @@ -189,7 +188,7 @@ QgsRasterBlock *QgsVirtualRasterProvider::block( int bandNo, const QgsRectangle { if ( feedback ) { - feedback->setProgress( 100.0 * static_cast< double >( i ) / height ); + feedback->setProgress( 100.0 * static_cast( i ) / height ); } if ( feedback && feedback->isCanceled() ) @@ -201,7 +200,7 @@ QgsRasterBlock *QgsVirtualRasterProvider::block( int bandNo, const QgsRectangle { for ( int j = 0; j < width; ++j ) { - outputData [ i * width + j ] = resultMatrix.data()[j]; + outputData[i * width + j] = resultMatrix.data()[j]; } } else @@ -265,7 +264,6 @@ int QgsVirtualRasterProvider::yBlockSize() const QgsVirtualRasterProviderMetadata::QgsVirtualRasterProviderMetadata() : QgsProviderMetadata( PROVIDER_KEY, PROVIDER_DESCRIPTION ) { - } QIcon QgsVirtualRasterProviderMetadata::icon() const @@ -287,7 +285,7 @@ QString QgsVirtualRasterProviderMetadata::absoluteToRelativeUri( const QString & { it.uri = context.pathResolver().writePath( it.uri ); } - return QgsRasterDataProvider::encodeVirtualRasterProviderUri( decodedVirtualParams ) ; + return QgsRasterDataProvider::encodeVirtualRasterProviderUri( decodedVirtualParams ); } QString QgsVirtualRasterProviderMetadata::relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const @@ -298,7 +296,7 @@ QString QgsVirtualRasterProviderMetadata::relativeToAbsoluteUri( const QString & { it.uri = context.pathResolver().readPath( it.uri ); } - return QgsRasterDataProvider::encodeVirtualRasterProviderUri( decodedVirtualParams ) ; + return QgsRasterDataProvider::encodeVirtualRasterProviderUri( decodedVirtualParams ); } @@ -357,10 +355,10 @@ QString QgsVirtualRasterProvider::providerKey() Qgis::RasterInterfaceCapabilities QgsVirtualRasterProvider::capabilities() const { const Qgis::RasterInterfaceCapabilities capability = Qgis::RasterInterfaceCapability::Identify - | Qgis::RasterInterfaceCapability::IdentifyValue - | Qgis::RasterInterfaceCapability::Size - //| Qgis::RasterInterfaceCapability::BuildPyramids - | Qgis::RasterInterfaceCapability::Prefetch; + | Qgis::RasterInterfaceCapability::IdentifyValue + | Qgis::RasterInterfaceCapability::Size + //| Qgis::RasterInterfaceCapability::BuildPyramids + | Qgis::RasterInterfaceCapability::Prefetch; return capability; } diff --git a/src/providers/virtualraster/qgsvirtualrasterprovider.h b/src/providers/virtualraster/qgsvirtualrasterprovider.h index ec3fa5b88235..05c645259d05 100644 --- a/src/providers/virtualraster/qgsvirtualrasterprovider.h +++ b/src/providers/virtualraster/qgsvirtualrasterprovider.h @@ -29,15 +29,22 @@ class QgsVirtualRasterProvider : public QgsRasterDataProvider { Q_OBJECT public: - QgsVirtualRasterProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions ); virtual ~QgsVirtualRasterProvider() override; - QgsVirtualRasterProvider &operator =( QgsVirtualRasterProvider other ) = delete; + QgsVirtualRasterProvider &operator=( QgsVirtualRasterProvider other ) = delete; QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback = nullptr ) override; - bool readBlock( int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback = nullptr ) override - { Q_UNUSED( bandNo ) Q_UNUSED( viewExtent ); Q_UNUSED( width ); Q_UNUSED( height ); Q_UNUSED( data ); Q_UNUSED( feedback ); return true; } + bool readBlock( int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback = nullptr ) override + { + Q_UNUSED( bandNo ) + Q_UNUSED( viewExtent ); + Q_UNUSED( width ); + Q_UNUSED( height ); + Q_UNUSED( data ); + Q_UNUSED( feedback ); + return true; + } // QgsDataProvider interface Qgis::DataProviderFlags flags() const override; @@ -69,7 +76,6 @@ class QgsVirtualRasterProvider : public QgsRasterDataProvider QString formulaString(); private: - QgsVirtualRasterProvider( const QgsVirtualRasterProvider &other ); bool mValid = false; @@ -86,11 +92,11 @@ class QgsVirtualRasterProvider : public QgsRasterDataProvider QVector mRasterEntries; QString mLastError; - std::unique_ptr< QgsRasterCalcNode > mCalcNode; - QVector mRasterLayers; + std::unique_ptr mCalcNode; + QVector mRasterLayers; }; -class QgsVirtualRasterProviderMetadata: public QgsProviderMetadata +class QgsVirtualRasterProviderMetadata : public QgsProviderMetadata { Q_OBJECT public: @@ -99,8 +105,7 @@ class QgsVirtualRasterProviderMetadata: public QgsProviderMetadata QgsVirtualRasterProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; QString absoluteToRelativeUri( const QString &uri, const QgsReadWriteContext &context ) const override; QString relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif // QGSVIRTUALRASTERPROVIDER_H - diff --git a/src/providers/wcs/qgswcscapabilities.cpp b/src/providers/wcs/qgswcscapabilities.cpp index 5514ace084e4..828d3d378491 100644 --- a/src/providers/wcs/qgswcscapabilities.cpp +++ b/src/providers/wcs/qgswcscapabilities.cpp @@ -43,7 +43,7 @@ #ifdef _MSC_VER #include -#define isfinite(x) _finite(x) +#define isfinite( x ) _finite( x ) #endif #ifdef QGISDEBUG @@ -71,9 +71,9 @@ QgsWcsCapabilities::QgsWcsCapabilities( const QgsWcsCapabilities &other ) , mCapabilities( other.mCapabilities ) , mCoveragesSupported( other.mCoveragesSupported ) , mCapabilitiesReply( nullptr ) // not copied from other - , mErrorTitle() // not copied from other - , mError() // not copied from other - , mErrorFormat() // not copied from other + , mErrorTitle() // not copied from other + , mError() // not copied from other + , mErrorFormat() // not copied from other , mCoverageCount( other.mCoverageCount ) , mCoverageParents( other.mCoverageParents ) , mCoverageParentIdentifiers( other.mCoverageParentIdentifiers ) @@ -194,8 +194,7 @@ bool QgsWcsCapabilities::sendRequest( QString const &url ) return false; } - if ( mCapabilitiesResponse.startsWith( "" ) || - mCapabilitiesResponse.startsWith( "" ) ) + if ( mCapabilitiesResponse.startsWith( "" ) || mCapabilitiesResponse.startsWith( "" ) ) { mErrorFormat = QStringLiteral( "text/html" ); mError = mCapabilitiesResponse; @@ -328,7 +327,8 @@ bool QgsWcsCapabilities::describeCoverage( QString const &identifier, bool force return false; } - if ( coverage->described && ! forceRefresh ) return true; + if ( coverage->described && !forceRefresh ) + return true; QString url = getDescribeCoverageUrl( coverage->identifier ); @@ -474,7 +474,8 @@ bool QgsWcsCapabilities::parseCapabilitiesDom( QByteArray const &xml, QgsWcsCapa } #endif - if ( ! convertToDom( xml ) ) return false; + if ( !convertToDom( xml ) ) + return false; QDomElement documentElement = mCapabilitiesDom.documentElement(); @@ -485,7 +486,7 @@ bool QgsWcsCapabilities::parseCapabilitiesDom( QByteArray const &xml, QgsWcsCapa if ( // We don't support 1.0, but try WCS_Capabilities tag to get version tagName != QLatin1String( "WCS_Capabilities" ) && // 1.0 - tagName != QLatin1String( "Capabilities" ) // 1.1, tags seen: Capabilities, wcs:Capabilities + tagName != QLatin1String( "Capabilities" ) // 1.1, tags seen: Capabilities, wcs:Capabilities ) { if ( tagName == QLatin1String( "ExceptionReport" ) ) @@ -499,9 +500,7 @@ bool QgsWcsCapabilities::parseCapabilitiesDom( QByteArray const &xml, QgsWcsCapa mErrorTitle = tr( "Dom Exception" ); mErrorFormat = QStringLiteral( "text/plain" ); mError = tr( "Could not get WCS capabilities in the expected format (DTD): no %1 found.\nThis might be due to an incorrect WCS Server URL.\nTag: %3\nResponse was:\n%4" ) - .arg( QStringLiteral( "Capabilities" ), - documentElement.tagName(), - QString( xml ) ); + .arg( QStringLiteral( "Capabilities" ), documentElement.tagName(), QString( xml ) ); } QgsLogger::debug( "Dom Exception: " + mError ); @@ -517,7 +516,7 @@ bool QgsWcsCapabilities::parseCapabilitiesDom( QByteArray const &xml, QgsWcsCapa mErrorTitle = tr( "Version not supported" ); mErrorFormat = QStringLiteral( "text/plain" ); mError = tr( "WCS server version %1 is not supported by QGIS (supported versions: 1.0.0, 1.1.0, 1.1.2)" ) - .arg( mVersion ); + .arg( mVersion ); QgsLogger::debug( "WCS version: " + mError ); @@ -589,7 +588,8 @@ QList QgsWcsCapabilities::domElements( const QDomElement &element, QList list; QStringList names = path.split( '.' ); - if ( names.isEmpty() ) return list; + if ( names.isEmpty() ) + return list; QString name = names.value( 0 ); names.removeFirst(); @@ -634,7 +634,8 @@ QStringList QgsWcsCapabilities::domElementsTexts( const QDomElement &element, co QDomElement QgsWcsCapabilities::domElement( const QDomElement &element, const QString &path ) { QStringList names = path.split( '.' ); - if ( names.isEmpty() ) return QDomElement(); + if ( names.isEmpty() ) + return QDomElement(); QDomElement firstChildElement = firstChild( element, names.value( 0 ) ); if ( names.size() == 1 || firstChildElement.isNull() ) @@ -765,7 +766,7 @@ void QgsWcsCapabilities::parseCoverageOfferingBrief( const QDomElement &element, if ( !coverageSummary.coverageSummary.empty() ) { - mCoverageParentIdentifiers[ coverageSummary.orderId ] = QStringList() << coverageSummary.identifier << coverageSummary.title << coverageSummary.abstract; + mCoverageParentIdentifiers[coverageSummary.orderId] = QStringList() << coverageSummary.identifier << coverageSummary.title << coverageSummary.abstract; } QgsDebugMsgLevel( QStringLiteral( "coverage orderId = %1 identifier = %2" ).arg( coverageSummary.orderId ).arg( coverageSummary.identifier ), 2 ); } @@ -779,7 +780,6 @@ void QgsWcsCapabilities::parseMetadataLink( const QDomElement &element, QgsWcsMe metadataLink.metadataType = metadataElement.attribute( QStringLiteral( "metadataType" ) ); metadataLink.xlinkHref = elementLink( metadataElement ); } - } QString QgsWcsCapabilities::elementLink( const QDomElement &element ) @@ -806,10 +806,10 @@ bool QgsWcsCapabilities::convertToDom( QByteArray const &xml ) mErrorTitle = tr( "Dom Exception" ); mErrorFormat = QStringLiteral( "text/plain" ); mError = tr( "Could not get WCS capabilities: %1 at line %2 column %3\nThis is probably due to an incorrect WCS Server URL.\nResponse was:\n\n%4" ) - .arg( errorMsg ) - .arg( errorLine ) - .arg( errorColumn ) - .arg( QString( xml ) ); + .arg( errorMsg ) + .arg( errorLine ) + .arg( errorColumn ) + .arg( QString( xml ) ); QgsLogger::debug( "Dom Exception: " + mError ); @@ -821,7 +821,8 @@ bool QgsWcsCapabilities::convertToDom( QByteArray const &xml ) bool QgsWcsCapabilities::parseDescribeCoverageDom10( QByteArray const &xml, QgsWcsCoverageSummary *coverage ) { QgsDebugMsgLevel( "coverage->identifier = " + coverage->identifier, 2 ); - if ( ! convertToDom( xml ) ) return false; + if ( !convertToDom( xml ) ) + return false; QDomElement documentElement = mCapabilitiesDom.documentElement(); @@ -833,9 +834,7 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom10( QByteArray const &xml, QgsW mErrorTitle = tr( "Dom Exception" ); mErrorFormat = QStringLiteral( "text/plain" ); mError = tr( "Could not get WCS capabilities in the expected format (DTD): no %1 found.\nThis might be due to an incorrect WCS Server URL.\nTag: %3\nResponse was:\n%4" ) - .arg( QStringLiteral( "CoverageDescription" ), - documentElement.tagName(), - QString( xml ) ); + .arg( QStringLiteral( "CoverageDescription" ), documentElement.tagName(), QString( xml ) ); QgsLogger::debug( "Dom Exception: " + mError ); @@ -844,7 +843,8 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom10( QByteArray const &xml, QgsW QDomElement coverageOfferingElement = firstChild( documentElement, QStringLiteral( "CoverageOffering" ) ); - if ( coverageOfferingElement.isNull() ) return false; + if ( coverageOfferingElement.isNull() ) + return false; QDomElement supportedCRSsElement = firstChild( coverageOfferingElement, QStringLiteral( "supportedCRSs" ) ); // requestResponseCRSs and requestCRSs + responseCRSs are alternatives @@ -1001,7 +1001,8 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom10( QByteArray const &xml, QgsW bool QgsWcsCapabilities::parseDescribeCoverageDom11( QByteArray const &xml, QgsWcsCoverageSummary *coverage ) { QgsDebugMsgLevel( "coverage->identifier = " + coverage->identifier, 2 ); - if ( ! convertToDom( xml ) ) return false; + if ( !convertToDom( xml ) ) + return false; QDomElement documentElement = mCapabilitiesDom.documentElement(); @@ -1013,9 +1014,7 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom11( QByteArray const &xml, QgsW mErrorTitle = tr( "Dom Exception" ); mErrorFormat = QStringLiteral( "text/plain" ); mError = tr( "Could not get WCS capabilities in the expected format (DTD): no %1 found.\nThis might be due to an incorrect WCS Server URL.\nTag: %3\nResponse was:\n%4" ) - .arg( QStringLiteral( "CoverageDescriptions" ), - documentElement.tagName(), - QString( xml ) ); + .arg( QStringLiteral( "CoverageDescriptions" ), documentElement.tagName(), QString( xml ) ); QgsLogger::debug( "Dom Exception: " + mError ); @@ -1037,12 +1036,13 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom11( QByteArray const &xml, QgsW QList low = parseDoubles( domElementText( el, QStringLiteral( "LowerCorner" ) ) ); QList high = parseDoubles( domElementText( el, QStringLiteral( "UpperCorner" ) ) ); - if ( low.size() != 2 && high.size() != 2 ) continue; + if ( low.size() != 2 && high.size() != 2 ) + continue; if ( el.attribute( QStringLiteral( "crs" ) ) == QLatin1String( "urn:ogc:def:crs:OGC::imageCRS" ) ) { - coverage->width = ( int )( high[0] - low[0] + 1 ); - coverage->height = ( int )( high[1] - low[1] + 1 ); + coverage->width = ( int ) ( high[0] - low[0] + 1 ); + coverage->height = ( int ) ( high[1] - low[1] + 1 ); coverage->hasSize = true; } else @@ -1213,7 +1213,7 @@ void QgsWcsCapabilities::parseCoverageSummary( const QDomElement &element, QgsWc if ( parent && parent->orderId > 1 ) // ignore Contents to put them on top level { QgsDebugMsgLevel( QStringLiteral( "coverage orderId = %1 identifier = %2 has parent %3" ).arg( coverageSummary.orderId ).arg( coverageSummary.identifier ).arg( parent->orderId ), 2 ); - mCoverageParents[ coverageSummary.orderId ] = parent->orderId; + mCoverageParents[coverageSummary.orderId] = parent->orderId; } if ( !coverageSummary.identifier.isEmpty() ) @@ -1224,10 +1224,9 @@ void QgsWcsCapabilities::parseCoverageSummary( const QDomElement &element, QgsWc if ( !coverageSummary.coverageSummary.empty() ) { - mCoverageParentIdentifiers[ coverageSummary.orderId ] = QStringList() << coverageSummary.identifier << coverageSummary.title << coverageSummary.abstract; + mCoverageParentIdentifiers[coverageSummary.orderId] = QStringList() << coverageSummary.identifier << coverageSummary.title << coverageSummary.abstract; } QgsDebugMsgLevel( QStringLiteral( "coverage orderId = %1 identifier = %2" ).arg( coverageSummary.orderId ).arg( coverageSummary.identifier ), 2 ); - } void QgsWcsCapabilities::coverageParents( QMap &parents, QMap &parentNames ) const @@ -1252,7 +1251,7 @@ QString QgsWcsCapabilities::lastErrorTitle() QString QgsWcsCapabilities::lastError() { - QgsDebugMsgLevel( "returning '" + mError + "'.", 2 ); + QgsDebugMsgLevel( "returning '" + mError + "'.", 2 ); return mError; } @@ -1295,7 +1294,8 @@ void QgsWcsCapabilities::showMessageBox( const QString &title, const QString &te QgsWcsCoverageSummary QgsWcsCapabilities::coverage( QString const &identifier ) { QgsWcsCoverageSummary *coverageSummaryPointer = coverageSummary( identifier ); - if ( coverageSummaryPointer ) return *coverageSummaryPointer; + if ( coverageSummaryPointer ) + return *coverageSummaryPointer; QgsWcsCoverageSummary coverageSummary; initCoverageSummary( coverageSummary ); diff --git a/src/providers/wcs/qgswcscapabilities.h b/src/providers/wcs/qgswcscapabilities.h index 28a87bf68ea2..818f045ed328 100644 --- a/src/providers/wcs/qgswcscapabilities.h +++ b/src/providers/wcs/qgswcscapabilities.h @@ -41,11 +41,11 @@ class QNetworkReply; */ struct QgsWcsMetadataLinkProperty { - //! Metadata type, the standard to which the metadata complies - QString metadataType; + //! Metadata type, the standard to which the metadata complies + QString metadataType; - //! Metadata link URL - QString xlinkHref; + //! Metadata link URL + QString xlinkHref; }; /** @@ -55,58 +55,58 @@ struct QgsWcsMetadataLinkProperty */ struct QgsWcsCoverageSummary { - QgsWcsCoverageSummary() = default; + QgsWcsCoverageSummary() = default; - int orderId = 0; + int orderId = 0; - //! Coverage unique identifier - QString identifier; + //! Coverage unique identifier + QString identifier; - //! Title for the coverage - QString title; + //! Title for the coverage + QString title; - //! Brief coverage description - QString abstract; + //! Brief coverage description + QString abstract; - //! Coverage CRS which GetCoverage response may be expressed - QStringList supportedCrs; + //! Coverage CRS which GetCoverage response may be expressed + QStringList supportedCrs; - //! Format identifiers, which GetCoverage response may be encoded - QStringList supportedFormat; - QList nullValues; + //! Format identifiers, which GetCoverage response may be encoded + QStringList supportedFormat; + QList nullValues; - //! Minimum bounding rectangle surrounding this coverage - QgsRectangle wgs84BoundingBox; // almost useless, we need the native - QString nativeCrs; + //! Minimum bounding rectangle surrounding this coverage + QgsRectangle wgs84BoundingBox; // almost useless, we need the native + QString nativeCrs; - //! Optional metadataLink - QgsWcsMetadataLinkProperty metadataLink; + //! Optional metadataLink + QgsWcsMetadataLinkProperty metadataLink; - //! Map of bounding boxes, key is CRS name (srsName), e.g. EPSG:4326 - QMap boundingBoxes; - QgsRectangle nativeBoundingBox; + //! Map of bounding boxes, key is CRS name (srsName), e.g. EPSG:4326 + QMap boundingBoxes; + QgsRectangle nativeBoundingBox; - //! timePosition or timePeriod (beginPosition/endPosition[/timeResolution] - used in KVP request) - QStringList times; - QVector coverageSummary; - // non reflecting Capabilities structure: - bool valid = false; - bool described = false; - // native size - int width = 0; - int height = 0; - bool hasSize = false; + //! timePosition or timePeriod (beginPosition/endPosition[/timeResolution] - used in KVP request) + QStringList times; + QVector coverageSummary; + // non reflecting Capabilities structure: + bool valid = false; + bool described = false; + // native size + int width = 0; + int height = 0; + bool hasSize = false; }; //! Capability Property structure struct QgsWcsCapabilitiesProperty { - QString version; - QString title; - QString abstract; - QString getCoverageGetUrl; - // using QgsWcsCoverageSummary for contents for simplification - QgsWcsCoverageSummary contents; + QString version; + QString title; + QString abstract; + QString getCoverageGetUrl; + // using QgsWcsCoverageSummary for contents for simplification + QgsWcsCoverageSummary contents; }; /** @@ -117,7 +117,6 @@ class QgsWcsCapabilities : public QObject Q_OBJECT public: - /** * Constructor for the provider. * @@ -258,7 +257,7 @@ class QgsWcsCapabilities : public QObject void progressChanged( int progress, int totalSteps ); //! \brief emit a signal to be caught by qgisapp and display a msg on status bar - void statusChanged( QString const &statusQString ); + void statusChanged( QString const &statusQString ); void downloadFinished(); @@ -310,8 +309,7 @@ class QgsWcsCapabilities : public QObject void parseContentMetadata( const QDomElement &element, QgsWcsCoverageSummary &coverageSummary ); //! parse the WCS Layer XML element - void parseCoverageOfferingBrief( const QDomElement &element, QgsWcsCoverageSummary &coverageSummary, - QgsWcsCoverageSummary *parent = nullptr ); + void parseCoverageOfferingBrief( const QDomElement &element, QgsWcsCoverageSummary &coverageSummary, QgsWcsCoverageSummary *parent = nullptr ); //! Parse metadata element from the document void parseMetadataLink( const QDomElement &element, QgsWcsMetadataLinkProperty &metadataLink ); @@ -319,8 +317,7 @@ class QgsWcsCapabilities : public QObject // ------------- 1.1 -------------------- //! parse the WCS Layer XML element - void parseCoverageSummary( const QDomElement &element, QgsWcsCoverageSummary &coverageSummary, - QgsWcsCoverageSummary *parent = nullptr ); + void parseCoverageSummary( const QDomElement &element, QgsWcsCoverageSummary &coverageSummary, QgsWcsCoverageSummary *parent = nullptr ); //! Data source uri QgsDataSourceUri mUri; diff --git a/src/providers/wcs/qgswcsdataitemguiprovider.cpp b/src/providers/wcs/qgswcsdataitemguiprovider.cpp index 3be66fc68770..8e8e32659463 100644 --- a/src/providers/wcs/qgswcsdataitemguiprovider.cpp +++ b/src/providers/wcs/qgswcsdataitemguiprovider.cpp @@ -30,7 +30,7 @@ void QgsWcsDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selection, QgsDataItemGuiContext context ) { - if ( QgsWCSRootItem *rootItem = qobject_cast< QgsWCSRootItem * >( item ) ) + if ( QgsWCSRootItem *rootItem = qobject_cast( item ) ) { QAction *actionNew = new QAction( tr( "New Connection…" ), menu ); connect( actionNew, &QAction::triggered, this, [rootItem] { newConnection( rootItem ); } ); @@ -45,7 +45,7 @@ void QgsWcsDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m menu->addAction( actionLoadServers ); } - if ( QgsWCSConnectionItem *connItem = qobject_cast< QgsWCSConnectionItem * >( item ) ) + if ( QgsWCSConnectionItem *connItem = qobject_cast( item ) ) { QAction *actionRefresh = new QAction( tr( "Refresh" ), menu ); connect( actionRefresh, &QAction::triggered, this, [connItem] { refreshConnection( connItem ); } ); @@ -61,14 +61,10 @@ void QgsWcsDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m connect( actionDuplicate, &QAction::triggered, this, [connItem] { duplicateConnection( connItem ); } ); menu->addAction( actionDuplicate ); - const QList< QgsWCSConnectionItem * > wcsConnectionItems = QgsDataItem::filteredItems( selection ); + const QList wcsConnectionItems = QgsDataItem::filteredItems( selection ); QAction *actionDelete = new QAction( wcsConnectionItems.size() > 1 ? tr( "Remove Connections…" ) : tr( "Remove Connection…" ), menu ); - connect( actionDelete, &QAction::triggered, this, [wcsConnectionItems, context] - { - QgsDataItemGuiProviderUtils::deleteConnections( wcsConnectionItems, []( const QString & connectionName ) - { - QgsOwsConnection::deleteConnection( QStringLiteral( "WCS" ), connectionName ); - }, context ); + connect( actionDelete, &QAction::triggered, this, [wcsConnectionItems, context] { + QgsDataItemGuiProviderUtils::deleteConnections( wcsConnectionItems, []( const QString &connectionName ) { QgsOwsConnection::deleteConnection( QStringLiteral( "WCS" ), connectionName ); }, context ); } ); menu->addAction( actionDelete ); } @@ -98,7 +94,7 @@ void QgsWcsDataItemGuiProvider::editConnection( QgsDataItem *item ) void QgsWcsDataItemGuiProvider::duplicateConnection( QgsDataItem *item ) { const QString connectionName = item->name(); - const QStringList connections = QgsOwsConnection::sTreeOwsConnections->items( {QStringLiteral( "wcs" )} ); + const QStringList connections = QgsOwsConnection::sTreeOwsConnections->items( { QStringLiteral( "wcs" ) } ); const QString newConnectionName = QgsDataItemGuiProviderUtils::uniqueName( connectionName, connections ); @@ -141,8 +137,7 @@ void QgsWcsDataItemGuiProvider::saveConnections() void QgsWcsDataItemGuiProvider::loadConnections( QgsDataItem *item ) { - const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), - tr( "XML files (*.xml *.XML)" ) ); + const QString fileName = QFileDialog::getOpenFileName( nullptr, tr( "Load Connections" ), QDir::homePath(), tr( "XML files (*.xml *.XML)" ) ); if ( fileName.isEmpty() ) { return; diff --git a/src/providers/wcs/qgswcsdataitemguiprovider.h b/src/providers/wcs/qgswcsdataitemguiprovider.h index 7bc413705404..6fe1df0240a9 100644 --- a/src/providers/wcs/qgswcsdataitemguiprovider.h +++ b/src/providers/wcs/qgswcsdataitemguiprovider.h @@ -22,11 +22,9 @@ class QgsWcsDataItemGuiProvider : public QObject, public QgsDataItemGuiProvider { Q_OBJECT public: - QString name() override { return QStringLiteral( "WCS" ); } - void populateContextMenu( QgsDataItem *item, QMenu *menu, - const QList &selectedItems, QgsDataItemGuiContext context ) override; + void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList &selectedItems, QgsDataItemGuiContext context ) override; private: static void newConnection( QgsDataItem *item ); @@ -35,7 +33,6 @@ class QgsWcsDataItemGuiProvider : public QObject, public QgsDataItemGuiProvider static void refreshConnection( QgsDataItem *item ); static void saveConnections(); static void loadConnections( QgsDataItem *item ); - }; #endif // QGSWCSDATAITEMGUIPROVIDER_H diff --git a/src/providers/wcs/qgswcsdataitems.cpp b/src/providers/wcs/qgswcsdataitems.cpp index b83a95a8f148..22ed7ac59488 100644 --- a/src/providers/wcs/qgswcsdataitems.cpp +++ b/src/providers/wcs/qgswcsdataitems.cpp @@ -186,7 +186,7 @@ QgsWCSRootItem::QgsWCSRootItem( QgsDataItem *parent, QString name, QString path populate(); } -QVectorQgsWCSRootItem::createChildren() +QVector QgsWCSRootItem::createChildren() { QVector connections; const QStringList list = QgsOwsConnection::connectionList( "WCS" ); diff --git a/src/providers/wcs/qgswcsdataitems.h b/src/providers/wcs/qgswcsdataitems.h index 439230c79531..644ddaa9e7a4 100644 --- a/src/providers/wcs/qgswcsdataitems.h +++ b/src/providers/wcs/qgswcsdataitems.h @@ -44,9 +44,7 @@ class QgsWCSLayerItem : public QgsLayerItem { Q_OBJECT public: - QgsWCSLayerItem( QgsDataItem *parent, QString name, QString path, - const QgsWcsCapabilitiesProperty &capabilitiesProperty, - const QgsDataSourceUri &dataSourceUri, const QgsWcsCoverageSummary &coverageSummary ); + QgsWCSLayerItem( QgsDataItem *parent, QString name, QString path, const QgsWcsCapabilitiesProperty &capabilitiesProperty, const QgsDataSourceUri &dataSourceUri, const QgsWcsCoverageSummary &coverageSummary ); QString createUri(); diff --git a/src/providers/wcs/qgswcsprovider.cpp b/src/providers/wcs/qgswcsprovider.cpp index bc9f2e7f80da..91c8dc9b5649 100644 --- a/src/providers/wcs/qgswcsprovider.cpp +++ b/src/providers/wcs/qgswcsprovider.cpp @@ -47,9 +47,9 @@ #include #endif -#define ERR(message) QGS_ERROR_MESSAGE(message,"WCS provider") -#define SRVERR(message) QGS_ERROR_MESSAGE(message,"WCS server") -#define QGS_ERROR(message) QgsError(message,"WCS provider") +#define ERR( message ) QGS_ERROR_MESSAGE( message, "WCS provider" ) +#define SRVERR( message ) QGS_ERROR_MESSAGE( message, "WCS server" ) +#define QGS_ERROR( message ) QgsError( message, "WCS provider" ) QString QgsWcsProvider::WCS_KEY = QStringLiteral( "wcs" ); QString QgsWcsProvider::WCS_DESCRIPTION = QStringLiteral( "OGC Web Coverage Service version 1.0/1.1 data provider" ); @@ -67,7 +67,8 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio mValid = false; mCachedMemFilename = QStringLiteral( "/vsimem/qgis/wcs/%0.dat" ).arg( reinterpret_cast( this ) ); - if ( !parseUri( uri ) ) return; + if ( !parseUri( uri ) ) + return; // GetCapabilities and DescribeCoverage // TODO(?): do only DescribeCoverage to avoid one request @@ -112,7 +113,8 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio } // We cannot continue without format, it is required - if ( mFormat.isEmpty() ) return; + if ( mFormat.isEmpty() ) + return; // It could happen (usually not with current QgsWCSSourceSelect if at least // one CRS is available) that crs is not set in uri, in that case we @@ -162,10 +164,7 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio QString crs; QgsRectangle box; // box to use to calc extent // Prefer native CRS - if ( !mCoverageSummary.nativeCrs.isEmpty() && - !mCoverageSummary.nativeBoundingBox.isEmpty() && - mCoverageSummary.supportedCrs.contains( mCoverageSummary.nativeCrs ) && - mHasSize ) + if ( !mCoverageSummary.nativeCrs.isEmpty() && !mCoverageSummary.nativeBoundingBox.isEmpty() && mCoverageSummary.supportedCrs.contains( mCoverageSummary.nativeCrs ) && mHasSize ) { box = mCoverageSummary.nativeBoundingBox; width = mWidth; @@ -223,8 +222,7 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio QgsDebugMsgLevel( QStringLiteral( "requestWidth = %1 requestHeight = %2 responseWidth = %3 responseHeight = %4)" ).arg( requestWidth ).arg( requestHeight ).arg( responseWidth ).arg( responseHeight ), 2 ); // GeoServer and ArcGIS are using for 1.1 box "pixel" edges // Mapserver is using pixel centers according to 1.1. specification - if ( ( responseWidth == requestWidth - 1 && responseHeight == requestHeight - 1 ) || - ( responseWidth == requestHeight - 1 && responseHeight == requestWidth - 1 ) ) + if ( ( responseWidth == requestWidth - 1 && responseHeight == requestHeight - 1 ) || ( responseWidth == requestHeight - 1 && responseHeight == requestWidth - 1 ) ) { mFixBox = true; QgsDebugMsgLevel( QStringLiteral( "Test response size is smaller by pixel, using mFixBox" ), 2 ); @@ -232,8 +230,7 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio // Geoserver is giving rotated raster for geographic CRS - switched axis, // Geoserver developers argue that changed axis order applies also to // returned raster, that is exaggerated IMO but we have to handle that. - if ( ( responseWidth == requestHeight && responseHeight == requestWidth ) || - ( responseWidth == requestHeight - 1 && responseHeight == requestWidth - 1 ) ) + if ( ( responseWidth == requestHeight && responseHeight == requestWidth ) || ( responseWidth == requestHeight - 1 && responseHeight == requestWidth - 1 ) ) { mFixRotate = true; QgsDebugMsgLevel( QStringLiteral( "Test response is rotated, using mFixRotate" ), 2 ); @@ -337,11 +334,15 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio if ( mHasSize ) { // This is taken from GDAL, how they come to these numbers? - if ( mWidth > 1800 ) mXBlockSize = 1024; - else mXBlockSize = mWidth; + if ( mWidth > 1800 ) + mXBlockSize = 1024; + else + mXBlockSize = mWidth; - if ( mHeight > 900 ) mYBlockSize = 512; - else mYBlockSize = mHeight; + if ( mHeight > 900 ) + mYBlockSize = 512; + else + mYBlockSize = mHeight; } mValid = true; @@ -374,21 +375,21 @@ QgsWcsProvider::QgsWcsProvider( const QgsWcsProvider &other, const QgsDataProvid , mCrsForLayer( other.mCrsForLayer ) , mQueryableForLayer( other.mQueryableForLayer ) , mCoverageCrs( other.mCoverageCrs ) - // intentionally omitted: - // - mCachedData - // - mCachedMemFilename - // - mCachedMemFile - // - mCachedGdalDataset - // - mCachedError - // - mCachedViewExtent - // - mCachedViewWidth - // - mCachedViewHeight + // intentionally omitted: + // - mCachedData + // - mCachedMemFilename + // - mCachedMemFile + // - mCachedGdalDataset + // - mCachedError + // - mCachedViewExtent + // - mCachedViewWidth + // - mCachedViewHeight , mMaxWidth( other.mMaxWidth ) , mMaxHeight( other.mMaxHeight ) - // intentionally omitted: - // - mErrorCaption - // - mError - // - mErrorFormat + // intentionally omitted: + // - mErrorCaption + // - mError + // - mErrorFormat , mCoordinateTransform( other.mCoordinateTransform ) , mExtentDirty( other.mExtentDirty ) , mGetFeatureInfoUrlBase( other.mGetFeatureInfoUrlBase ) @@ -535,7 +536,7 @@ void QgsWcsProvider::setQueryItem( QUrl &url, const QString &item, const QString url.setQuery( query ); } -bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight, void *block, QgsRasterBlockFeedback *feedback ) +bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight, void *block, QgsRasterBlockFeedback *feedback ) { // TODO: set block to null values, move that to function and call only if fails memset( block, 0, pixelWidth * pixelHeight * QgsRasterBlock::typeSize( dataType( bandNo ) ) ); @@ -549,10 +550,7 @@ bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int } // Can we reuse the previously cached coverage? - if ( !mCachedGdalDataset || - mCachedViewExtent != viewExtent || - mCachedViewWidth != pixelWidth || - mCachedViewHeight != pixelHeight ) + if ( !mCachedGdalDataset || mCachedViewExtent != viewExtent || mCachedViewWidth != pixelWidth || mCachedViewHeight != pixelHeight ) { getCache( bandNo, viewExtent, pixelWidth, pixelHeight, QString(), feedback ); } @@ -565,8 +563,7 @@ bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int // Unfortunately if the received raster does not have a CRS, the extent is the raster size // and in that case it cannot be used to verify extent QgsCoordinateReferenceSystem cacheCrs; - if ( !cacheCrs.createFromWkt( GDALGetProjectionRef( mCachedGdalDataset.get() ) ) && - !cacheCrs.createFromWkt( GDALGetGCPProjection( mCachedGdalDataset.get() ) ) ) + if ( !cacheCrs.createFromWkt( GDALGetProjectionRef( mCachedGdalDataset.get() ) ) && !cacheCrs.createFromWkt( GDALGetGCPProjection( mCachedGdalDataset.get() ) ) ) { QgsDebugMsgLevel( QStringLiteral( "Cached does not have CRS" ), 2 ); } @@ -580,10 +577,7 @@ bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int { // using qgsDoubleNear is too precise, example acceptable difference: // 179.9999999306699863 x 179.9999999306700431 - if ( !qgsDoubleNearSig( cacheExtent.xMinimum(), viewExtent.xMinimum(), 10 ) || - !qgsDoubleNearSig( cacheExtent.yMinimum(), viewExtent.yMinimum(), 10 ) || - !qgsDoubleNearSig( cacheExtent.xMaximum(), viewExtent.xMaximum(), 10 ) || - !qgsDoubleNearSig( cacheExtent.yMaximum(), viewExtent.yMaximum(), 10 ) ) + if ( !qgsDoubleNearSig( cacheExtent.xMinimum(), viewExtent.xMinimum(), 10 ) || !qgsDoubleNearSig( cacheExtent.yMinimum(), viewExtent.yMinimum(), 10 ) || !qgsDoubleNearSig( cacheExtent.xMaximum(), viewExtent.xMaximum(), 10 ) || !qgsDoubleNearSig( cacheExtent.yMaximum(), viewExtent.yMaximum(), 10 ) ) { // Just print a message so user is aware of a server side issue but don't left // the tile blank so we can deal with eventually misconfigured WCS server @@ -609,7 +603,7 @@ bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int QgsDebugMsgLevel( QStringLiteral( "pixelSize = %1" ).arg( pixelSize ), 2 ); const int size = width * height * pixelSize; void *tmpData = malloc( size ); - if ( ! tmpData ) + if ( !tmpData ) { QgsDebugError( QStringLiteral( "Couldn't allocate memory of %1 bytes" ).arg( size ) ); return false; @@ -624,7 +618,7 @@ bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int { const int destIndex = pixelSize * ( i * pixelWidth + j ); const int srcIndex = pixelSize * ( j * width + ( width - i - 1 ) ); - memcpy( ( char * )block + destIndex, ( char * )tmpData + srcIndex, pixelSize ); + memcpy( ( char * ) block + destIndex, ( char * ) tmpData + srcIndex, pixelSize ); } } free( tmpData ); @@ -653,7 +647,7 @@ bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int return true; } -void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight, QString crs, QgsRasterBlockFeedback *feedback ) const +void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight, QString crs, QgsRasterBlockFeedback *feedback ) const { Q_UNUSED( bandNo ) // delete cached data @@ -686,7 +680,8 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int } } - if ( mInvertAxisOrientation ) changeXY = !changeXY; + if ( mInvertAxisOrientation ) + changeXY = !changeXY; const double xRes = viewExtent.width() / pixelWidth; const double yRes = viewExtent.height() / pixelHeight; @@ -714,10 +709,7 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int } // Bounding box in WCS format (Warning: does not work with scientific notation) QString bbox = QString( "%1,%2,%3,%4" ) - .arg( qgsDoubleToString( extent.xMinimum() ), - qgsDoubleToString( extent.yMinimum() ), - qgsDoubleToString( extent.xMaximum() ), - qgsDoubleToString( extent.yMaximum() ) ); + .arg( qgsDoubleToString( extent.xMinimum() ), qgsDoubleToString( extent.yMinimum() ), qgsDoubleToString( extent.xMaximum() ), qgsDoubleToString( extent.yMaximum() ) ); QUrl url( mIgnoreGetCoverageUrl ? mBaseUrl : mCapabilities.getCoverageUrl() ); @@ -744,7 +736,7 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int setQueryItem( url, QStringLiteral( "BBOX" ), bbox ); - setQueryItem( url, QStringLiteral( "CRS" ), crs ); // request BBOX CRS + setQueryItem( url, QStringLiteral( "CRS" ), crs ); // request BBOX CRS setQueryItem( url, QStringLiteral( "RESPONSE_CRS" ), crs ); // response CRS setQueryItem( url, QStringLiteral( "WIDTH" ), QString::number( pixelWidth ) ); setQueryItem( url, QStringLiteral( "HEIGHT" ), QString::number( pixelHeight ) ); @@ -784,8 +776,7 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int // Mapserver 6.0.3 does not work with origin on yMinimum (lower left) // Geoserver works OK with yMinimum (lower left) const QString gridOrigin = QString( changeXY ? "%2,%1" : "%1,%2" ) - .arg( qgsDoubleToString( extent.xMinimum() ), - qgsDoubleToString( extent.yMaximum() ) ); + .arg( qgsDoubleToString( extent.xMinimum() ), qgsDoubleToString( extent.yMaximum() ) ); setQueryItem( url, QStringLiteral( "GRIDORIGIN" ), gridOrigin ); // GridOffsets WCS 1.1: @@ -802,10 +793,9 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int //double yOff = mFixRotate ? yRes : -yRes; // this was working with some servers I think const double yOff = -yRes; const QString gridOffsets = QString( changeXY ? "%2,%1" : "%1,%2" ) - //setQueryItem( url, "GRIDTYPE", "urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs" ); - //QString gridOffsets = QString( changeXY ? "%2,0,0,%1" : "%1,0,0,%2" ) - .arg( qgsDoubleToString( xRes ), - qgsDoubleToString( yOff ) ); + //setQueryItem( url, "GRIDTYPE", "urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs" ); + //QString gridOffsets = QString( changeXY ? "%2,0,0,%1" : "%1,0,0,%2" ) + .arg( qgsDoubleToString( xRes ), qgsDoubleToString( yOff ) ); setQueryItem( url, QStringLiteral( "GRIDOFFSETS" ), gridOffsets ); } @@ -839,10 +829,7 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int } #endif - mCachedMemFile = VSIFileFromMemBuffer( mCachedMemFilename.toUtf8().constData(), - ( GByte * )mCachedData.data(), - ( vsi_l_offset )mCachedData.size(), - FALSE ); + mCachedMemFile = VSIFileFromMemBuffer( mCachedMemFilename.toUtf8().constData(), ( GByte * ) mCachedData.data(), ( vsi_l_offset ) mCachedData.size(), FALSE ); if ( !mCachedMemFile ) { @@ -861,14 +848,12 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const &viewExtent, int return; } QgsDebugMsgLevel( QStringLiteral( "Dataset opened" ), 2 ); - } // For stats only, maybe change QgsRasterDataProvider::bandStatistics() to // use standard readBlock with extent bool QgsWcsProvider::readBlock( int bandNo, int xBlock, int yBlock, void *block ) { - QgsDebugMsgLevel( QStringLiteral( "xBlock = %1 yBlock = %2" ).arg( xBlock ).arg( yBlock ), 2 ); if ( !mHasSize ) @@ -952,7 +937,7 @@ void QgsWcsProvider::clearCache() const QgsDebugMsgLevel( QStringLiteral( "Cleared" ), 2 ); } -QList QgsWcsProvider::colorTable( int bandNumber )const +QList QgsWcsProvider::colorTable( int bandNumber ) const { return mColorTables.value( bandNumber - 1 ); } @@ -969,7 +954,6 @@ Qgis::RasterColorInterpretation QgsWcsProvider::colorInterpretation( int bandNo bool QgsWcsProvider::parseServiceExceptionReportDom( const QByteArray &xml, const QString &wcsVersion, QString &errorTitle, QString &errorText ) { - #ifdef QGISDEBUG //test the content of the QByteArray const QString responsestring( xml ); @@ -987,10 +971,10 @@ bool QgsWcsProvider::parseServiceExceptionReportDom( const QByteArray &xml, cons { errorTitle = tr( "Dom Exception" ); errorText = tr( "Could not get WCS Service Exception at %1 at line %2 column %3\n\nResponse was:\n\n%4" ) - .arg( errorMsg ) - .arg( errorLine ) - .arg( errorColumn ) - .arg( QString( xml ) ); + .arg( errorMsg ) + .arg( errorLine ) + .arg( errorColumn ) + .arg( QString( xml ) ); QgsLogger::debug( "Dom Exception: " + errorText ); @@ -1023,7 +1007,6 @@ bool QgsWcsProvider::parseServiceExceptionReportDom( const QByteArray &xml, cons void QgsWcsProvider::parseServiceException( QDomElement const &e, const QString &wcsVersion, QString &errorTitle, QString &errorText ) { - errorTitle = tr( "Service Exception" ); QMap exceptions; @@ -1056,10 +1039,10 @@ void QgsWcsProvider::parseServiceException( QDomElement const &e, const QString { seCode = e.attribute( QStringLiteral( "exceptionCode" ) ); // UMN Mapserver (6.0.3) has messed/switched 'locator' and 'exceptionCode' - if ( ! exceptions.contains( seCode ) ) + if ( !exceptions.contains( seCode ) ) { seCode = e.attribute( QStringLiteral( "locator" ) ); - if ( ! exceptions.contains( seCode ) ) + if ( !exceptions.contains( seCode ) ) { seCode.clear(); } @@ -1088,7 +1071,6 @@ void QgsWcsProvider::parseServiceException( QDomElement const &e, const QString } - QgsRectangle QgsWcsProvider::extent() const { if ( mExtentDirty ) @@ -1115,7 +1097,6 @@ QString QgsWcsProvider::wcsVersion() bool QgsWcsProvider::calculateExtent() const { - // Make sure we know what extents are available if ( !mCoverageSummary.described ) { @@ -1189,8 +1170,7 @@ bool QgsWcsProvider::calculateExtent() const QgsDebugMsgLevel( "mCoverageExtent = " + mCoverageExtent.toString(), 2 ); QgsDebugMsgLevel( "cacheExtent = " + cacheExtent.toString(), 2 ); QgsCoordinateReferenceSystem cacheCrs; - if ( !cacheCrs.createFromWkt( GDALGetProjectionRef( mCachedGdalDataset.get() ) ) && - !cacheCrs.createFromWkt( GDALGetGCPProjection( mCachedGdalDataset.get() ) ) ) + if ( !cacheCrs.createFromWkt( GDALGetProjectionRef( mCachedGdalDataset.get() ) ) && !cacheCrs.createFromWkt( GDALGetGCPProjection( mCachedGdalDataset.get() ) ) ) { QgsDebugMsgLevel( QStringLiteral( "Cached does not have CRS" ), 2 ); } @@ -1201,10 +1181,7 @@ bool QgsWcsProvider::calculateExtent() const // extent check for rotated, TODO: verify if ( cacheCrs.isValid() && !mFixRotate ) { - if ( !qgsDoubleNearSig( cacheExtent.xMinimum(), mCoverageExtent.xMinimum(), 10 ) || - !qgsDoubleNearSig( cacheExtent.yMinimum(), mCoverageExtent.yMinimum(), 10 ) || - !qgsDoubleNearSig( cacheExtent.xMaximum(), mCoverageExtent.xMaximum(), 10 ) || - !qgsDoubleNearSig( cacheExtent.yMaximum(), mCoverageExtent.yMaximum(), 10 ) ) + if ( !qgsDoubleNearSig( cacheExtent.xMinimum(), mCoverageExtent.xMinimum(), 10 ) || !qgsDoubleNearSig( cacheExtent.yMinimum(), mCoverageExtent.yMinimum(), 10 ) || !qgsDoubleNearSig( cacheExtent.xMaximum(), mCoverageExtent.xMaximum(), 10 ) || !qgsDoubleNearSig( cacheExtent.yMaximum(), mCoverageExtent.yMaximum(), 10 ) ) { QgsDebugMsgLevel( QStringLiteral( "cacheExtent and mCoverageExtent differ, mCoverageExtent cut to cacheExtent" ), 2 ); mCoverageExtent = cacheExtent; @@ -1266,8 +1243,7 @@ QString QgsWcsProvider::coverageMetadata( const QgsWcsCoverageSummary &coverage metadata += htmlRow( tr( "Title" ), coverage.title ); metadata += htmlRow( tr( "Abstract" ), coverage.abstract ); - if ( !coverage.metadataLink.metadataType.isNull() && - !coverage.metadataLink.xlinkHref.isNull() ) + if ( !coverage.metadataLink.metadataType.isNull() && !coverage.metadataLink.xlinkHref.isNull() ) { metadata += htmlRow( tr( "Metadata Type" ), coverage.metadataLink.metadataType ); metadata += htmlRow( tr( "Metadata Link" ), coverage.metadataLink.xlinkHref ); @@ -1331,7 +1307,7 @@ QString QgsWcsProvider::htmlMetadata() const metadata += " "; #endif - metadata += QLatin1String( "
    " ); // Nested table 1 + metadata += QLatin1String( "
    " ); // Nested table 1 // Server Properties section metadata += QLatin1String( "
    " ); @@ -1340,7 +1316,7 @@ QString QgsWcsProvider::htmlMetadata() const // Use a nested table metadata += QLatin1String( "
    " ); - metadata += QLatin1String( "" ); // Nested table 2 + metadata += QLatin1String( "
    " ); // Nested table 2 // Table header metadata += QLatin1String( "
    " ); @@ -1369,7 +1345,7 @@ QString QgsWcsProvider::htmlMetadata() const metadata += htmlRow( tr( "Get Coverage Url" ), mCapabilities.getCoverageUrl() + ( mIgnoreGetCoverageUrl ? tr( " (advertised but ignored)" ) : QString() ) ); // Close the nested table - metadata += QLatin1String( "
    " ); // End nested table 2 + metadata += QLatin1String( "
    " ); // End nested table 2 metadata += QLatin1String( "" ); // Coverage properties @@ -1379,12 +1355,13 @@ QString QgsWcsProvider::htmlMetadata() const // Dialog takes too long to open if there are too many coverages (1000 for example) int count = 0; - const QList< QgsWcsCoverageSummary> constCoverages = mCapabilities.coverages(); + const QList constCoverages = mCapabilities.coverages(); for ( const QgsWcsCoverageSummary &c : constCoverages ) { metadata += coverageMetadata( c ); count++; - if ( count >= 100 ) break; + if ( count >= 100 ) + break; } metadata += QLatin1String( "" ); if ( count < mCapabilities.coverages().size() ) @@ -1392,7 +1369,7 @@ QString QgsWcsProvider::htmlMetadata() const metadata += tr( "And %n more coverage(s)", nullptr, mCapabilities.coverages().size() - count ); } - metadata += QLatin1String( "\n" ); // End nested table 1 + metadata += QLatin1String( "\n" ); // End nested table 1 return metadata; } @@ -1401,9 +1378,9 @@ QString QgsWcsProvider::htmlCell( const QString &text ) return "" + text + ""; } -QString QgsWcsProvider:: htmlRow( const QString &text1, const QString &text2 ) +QString QgsWcsProvider::htmlRow( const QString &text1, const QString &text2 ) { - return "" + htmlCell( text1 ) + htmlCell( text2 ) + ""; + return "" + htmlCell( text1 ) + htmlCell( text2 ) + ""; } QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis::RasterIdentifyFormat format, const QgsRectangle &boundingBox, int width, int height, int /*dpi*/ ) @@ -1430,7 +1407,7 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis: QgsRectangle finalExtent = boundingBox; const int maxSize = 2000; - const int cacheSize = 1000; // tile cache size if context is not defined or small + const int cacheSize = 1000; // tile cache size if context is not defined or small const double relResTol = 0.1; // relative resolution tolerance (10%) // TODO: We are using cacheSize x cacheSize if context is not defined @@ -1441,16 +1418,15 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis: // if context size is to large we have to cut it, in that case caching big // big part does not make sense - if ( finalExtent.isEmpty() || width == 0 || height == 0 || - width > maxSize || height > maxSize ) + if ( finalExtent.isEmpty() || width == 0 || height == 0 || width > maxSize || height > maxSize ) { // context missing, use a small area around the point and highest resolution if known double xRes, yRes; if ( mHasSize ) { - xRes = mCoverageExtent.width() / mWidth; - yRes = mCoverageExtent.height() / mHeight; + xRes = mCoverageExtent.width() / mWidth; + yRes = mCoverageExtent.height() / mHeight; } else { @@ -1476,19 +1452,12 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis: width = cacheSize; height = cacheSize; - finalExtent = QgsRectangle( point.x() - xRes * width / 2, - point.y() - yRes * height / 2, - point.x() + xRes * width / 2, - point.y() + yRes * height / 2 ); + finalExtent = QgsRectangle( point.x() - xRes * width / 2, point.y() - yRes * height / 2, point.x() + xRes * width / 2, point.y() + yRes * height / 2 ); const double xResDiff = std::fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes ); const double yResDiff = std::fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes ); - if ( !mCachedGdalDataset || - !mCachedViewExtent.contains( point ) || - mCachedViewWidth == 0 || mCachedViewHeight == 0 || - xResDiff / xRes > relResTol || - yResDiff / yRes > relResTol ) + if ( !mCachedGdalDataset || !mCachedViewExtent.contains( point ) || mCachedViewWidth == 0 || mCachedViewHeight == 0 || xResDiff / xRes > relResTol || yResDiff / yRes > relResTol ) { getCache( 1, finalExtent, width, height ); } @@ -1505,10 +1474,7 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis: const double xResDiff = std::fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes ); const double yResDiff = std::fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes ); QgsDebugMsgLevel( QStringLiteral( "xRes diff = %1 yRes diff = %2 relative xResDiff = %3 relative yResDiff = %4" ).arg( xResDiff ).arg( yResDiff ).arg( xResDiff / xRes ).arg( yResDiff / yRes ), 2 ); - if ( !mCachedGdalDataset || - !mCachedViewExtent.contains( point ) || - xResDiff / xRes > relResTol || - yResDiff / yRes > relResTol ) + if ( !mCachedGdalDataset || !mCachedViewExtent.contains( point ) || xResDiff / xRes > relResTol || yResDiff / yRes > relResTol ) { // Identify map tool is now using fake context 1x1 pixel to get point/line // features from WMS. In such case we enlarge the extent to get data cached @@ -1533,8 +1499,7 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis: } } - if ( !mCachedGdalDataset || - !mCachedViewExtent.contains( point ) ) + if ( !mCachedGdalDataset || !mCachedViewExtent.contains( point ) ) { return QgsRasterIdentifyResult( QGS_ERROR( tr( "Read data error" ) ) ); } @@ -1557,8 +1522,7 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis: GDALRasterBandH gdalBand = GDALGetRasterBand( mCachedGdalDataset.get(), i ); double value; - const CPLErr err = GDALRasterIO( gdalBand, GF_Read, col, row, 1, 1, - &value, 1, 1, GDT_Float64, 0, 0 ); + const CPLErr err = GDALRasterIO( gdalBand, GF_Read, col, row, 1, 1, &value, 1, 1, GDT_Float64, 0, 0 ); if ( err != CPLE_None ) { @@ -1567,9 +1531,7 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, Qgis: } // Apply no data and user no data - if ( ( sourceHasNoDataValue( i ) && useSourceNoDataValue( i ) && - ( std::isnan( value ) || qgsDoubleNear( value, sourceNoDataValue( i ) ) ) ) || - ( QgsRasterRange::contains( value, userNoDataValues( i ) ) ) ) + if ( ( sourceHasNoDataValue( i ) && useSourceNoDataValue( i ) && ( std::isnan( value ) || qgsDoubleNear( value, sourceNoDataValue( i ) ) ) ) || ( QgsRasterRange::contains( value, userNoDataValues( i ) ) ) ) { results.insert( i, QVariant() ); } @@ -1594,7 +1556,7 @@ QString QgsWcsProvider::lastErrorTitle() QString QgsWcsProvider::lastError() { - QgsDebugMsgLevel( "returning '" + mError + "'.", 2 ); + QgsDebugMsgLevel( "returning '" + mError + "'.", 2 ); return mError; } @@ -1613,7 +1575,7 @@ QString QgsWcsProvider::providerKey() return WCS_KEY; } -QString QgsWcsProvider::description() const +QString QgsWcsProvider::description() const { return WCS_DESCRIPTION; } @@ -1665,7 +1627,8 @@ QMap QgsWcsProvider::supportedMimes() const QString mimeType = GDALGetMetadataItem( driver, "DMD_MIMETYPE", "" ); - if ( mimeType.isEmpty() ) continue; + if ( mimeType.isEmpty() ) + continue; desc = desc.isEmpty() ? mimeType : desc; @@ -1707,8 +1670,7 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl &url, QgsWcsAuthorizati QgsSetRequestInitiatorClass( request, QStringLiteral( "QgsWcsDownloadHandler" ) ); if ( !mAuth.setAuthorization( request ) ) { - QgsMessageLog::logMessage( tr( "Network request update failed for authentication config" ), - tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Network request update failed for authentication config" ), tr( "WCS" ) ); return; } request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true ); @@ -1719,8 +1681,7 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl &url, QgsWcsAuthorizati { mCacheReply->deleteLater(); mCacheReply = nullptr; - QgsMessageLog::logMessage( tr( "Network reply update failed for authentication config" ), - tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Network reply update failed for authentication config" ), tr( "WCS" ) ); finish(); return; } @@ -1758,8 +1719,7 @@ void QgsWcsDownloadHandler::cacheReplyFinished() QgsSetRequestInitiatorClass( request, QStringLiteral( "QgsWcsDownloadHandler" ) ); if ( !mAuth.setAuthorization( request ) ) { - QgsMessageLog::logMessage( tr( "Network request update failed for authentication config" ), - tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Network request update failed for authentication config" ), tr( "WCS" ) ); return; } mCacheReply = QgsNetworkAccessManager::instance()->get( request ); @@ -1767,8 +1727,7 @@ void QgsWcsDownloadHandler::cacheReplyFinished() { mCacheReply->deleteLater(); mCacheReply = nullptr; - QgsMessageLog::logMessage( tr( "Network reply update failed for authentication config" ), - tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Network reply update failed for authentication config" ), tr( "WCS" ) ); finish(); return; } @@ -1784,10 +1743,7 @@ void QgsWcsDownloadHandler::cacheReplyFinished() { const QVariant phrase = mCacheReply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ); - QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Reason phrase: %2; URL: %3)" ) - .arg( status.toInt() ) - .arg( phrase.toString(), - mCacheReply->url().toString() ), tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Reason phrase: %2; URL: %3)" ).arg( status.toInt() ).arg( phrase.toString(), mCacheReply->url().toString() ), tr( "WCS" ) ); mCacheReply->deleteLater(); mCacheReply = nullptr; @@ -1805,27 +1761,19 @@ void QgsWcsDownloadHandler::cacheReplyFinished() // Content type examples: text/xml // application/vnd.ogc.se_xml;charset=UTF-8 // application/xml - if ( contentType.startsWith( QLatin1String( "text/" ), Qt::CaseInsensitive ) || - contentType.compare( QLatin1String( "application/xml" ), Qt::CaseInsensitive ) == 0 || - contentType.startsWith( QLatin1String( "application/vnd.ogc.se_xml" ), Qt::CaseInsensitive ) ) + if ( contentType.startsWith( QLatin1String( "text/" ), Qt::CaseInsensitive ) || contentType.compare( QLatin1String( "application/xml" ), Qt::CaseInsensitive ) == 0 || contentType.startsWith( QLatin1String( "application/vnd.ogc.se_xml" ), Qt::CaseInsensitive ) ) { QString errorTitle, errorText; const QByteArray text = mCacheReply->readAll(); - if ( ( contentType.compare( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) == 0 || - contentType.compare( QLatin1String( "application/xml" ), Qt::CaseInsensitive ) == 0 || - contentType.startsWith( QLatin1String( "application/vnd.ogc.se_xml" ), Qt::CaseInsensitive ) ) + if ( ( contentType.compare( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) == 0 || contentType.compare( QLatin1String( "application/xml" ), Qt::CaseInsensitive ) == 0 || contentType.startsWith( QLatin1String( "application/vnd.ogc.se_xml" ), Qt::CaseInsensitive ) ) && QgsWcsProvider::parseServiceExceptionReportDom( text, mWcsVersion, errorTitle, errorText ) ) { mCachedError.append( SRVERR( tr( "Map request error:
    Title: %1
    Error: %2
    URL: %3)" ) - .arg( errorTitle, errorText, - mCacheReply->url().toString() ) ) ); + .arg( errorTitle, errorText, mCacheReply->url().toString() ) ) ); } else { - QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Response: %2; URL: %3)" ) - .arg( status.toInt() ) - .arg( QString::fromUtf8( text ), - mCacheReply->url().toString() ), tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Map request error (Status: %1; Response: %2; URL: %3)" ).arg( status.toInt() ).arg( QString::fromUtf8( text ), mCacheReply->url().toString() ), tr( "WCS" ) ); } mCacheReply->deleteLater(); @@ -1878,15 +1826,11 @@ void QgsWcsDownloadHandler::cacheReplyFinished() QString errorTitle, errorText; if ( QgsWcsProvider::parseServiceExceptionReportDom( body, mWcsVersion, errorTitle, errorText ) ) { - QgsMessageLog::logMessage( tr( "Map request error (Title: %1; Error: %2; URL: %3)" ) - .arg( errorTitle, errorText, - mCacheReply->url().toString() ), tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Map request error (Title: %1; Error: %2; URL: %3)" ).arg( errorTitle, errorText, mCacheReply->url().toString() ), tr( "WCS" ) ); } else { - QgsMessageLog::logMessage( tr( "Map request error (Response: %1; URL: %2)" ) - .arg( QString::fromUtf8( body ), - mCacheReply->url().toString() ), tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Map request error (Response: %1; URL: %2)" ).arg( QString::fromUtf8( body ), mCacheReply->url().toString() ), tr( "WCS" ) ); } mCacheReply->deleteLater(); @@ -1944,8 +1888,7 @@ void QgsWcsDownloadHandler::cacheReplyFinished() { mCacheReply->deleteLater(); mCacheReply = nullptr; - QgsMessageLog::logMessage( tr( "Network reply update failed for authentication config" ), - tr( "WCS" ) ); + QgsMessageLog::logMessage( tr( "Network reply update failed for authentication config" ), tr( "WCS" ) ); finish(); return; } @@ -1991,15 +1934,15 @@ void QgsWcsDownloadHandler::canceled() } -QList< QgsDataItemProvider * > QgsWcsProviderMetadata::dataItemProviders() const +QList QgsWcsProviderMetadata::dataItemProviders() const { QList providers; providers << new QgsWcsDataItemProvider; return providers; } -QgsWcsProviderMetadata::QgsWcsProviderMetadata(): - QgsProviderMetadata( QgsWcsProvider::WCS_KEY, QgsWcsProvider::WCS_DESCRIPTION ) {} +QgsWcsProviderMetadata::QgsWcsProviderMetadata() + : QgsProviderMetadata( QgsWcsProvider::WCS_KEY, QgsWcsProvider::WCS_DESCRIPTION ) {} QIcon QgsWcsProviderMetadata::icon() const { @@ -2018,16 +1961,16 @@ QVariantMap QgsWcsProviderMetadata::decodeUri( const QString &uri ) const const QUrl url( item.second ); if ( url.isLocalFile() ) { - decoded[ QStringLiteral( "path" ) ] = url.toLocalFile(); + decoded[QStringLiteral( "path" )] = url.toLocalFile(); } else { - decoded[ item.first ] = item.second; + decoded[item.first] = item.second; } } else { - decoded[ item.first ] = item.second; + decoded[item.first] = item.second; } } return decoded; @@ -2036,7 +1979,7 @@ QVariantMap QgsWcsProviderMetadata::decodeUri( const QString &uri ) const QString QgsWcsProviderMetadata::encodeUri( const QVariantMap &parts ) const { QUrlQuery query; - QList > items; + QList> items; for ( auto it = parts.constBegin(); it != parts.constEnd(); ++it ) { if ( it.key() == QLatin1String( "path" ) ) diff --git a/src/providers/wcs/qgswcsprovider.h b/src/providers/wcs/qgswcsprovider.h index 836806fad837..748f99f20a56 100644 --- a/src/providers/wcs/qgswcsprovider.h +++ b/src/providers/wcs/qgswcsprovider.h @@ -49,51 +49,51 @@ class QNetworkAccessManager; class QNetworkReply; class QNetworkRequest; -#define CPL_SUPRESS_CPLUSPLUS //#spellok +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include #include "cpl_conv.h" // TODO: merge with QgsWmsAuthorization? struct QgsWcsAuthorization { - QgsWcsAuthorization( const QString &userName = QString(), const QString &password = QString(), const QString &authcfg = QString() ) - : mUserName( userName ) - , mPassword( password ) - , mAuthCfg( authcfg ) - {} - - //! Sets authorization header - bool setAuthorization( QNetworkRequest &request ) const - { - if ( !mAuthCfg.isEmpty() ) + QgsWcsAuthorization( const QString &userName = QString(), const QString &password = QString(), const QString &authcfg = QString() ) + : mUserName( userName ) + , mPassword( password ) + , mAuthCfg( authcfg ) + {} + + //! Sets authorization header + bool setAuthorization( QNetworkRequest &request ) const { - return QgsApplication::authManager()->updateNetworkRequest( request, mAuthCfg ); + if ( !mAuthCfg.isEmpty() ) + { + return QgsApplication::authManager()->updateNetworkRequest( request, mAuthCfg ); + } + else if ( !mUserName.isNull() || !mPassword.isNull() ) + { + request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( mUserName, mPassword ).toLatin1().toBase64() ); + } + return true; } - else if ( !mUserName.isNull() || !mPassword.isNull() ) - { - request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( mUserName, mPassword ).toLatin1().toBase64() ); - } - return true; - } - //! Sets authorization reply - bool setAuthorizationReply( QNetworkReply *reply ) const - { - if ( !mAuthCfg.isEmpty() ) + //! Sets authorization reply + bool setAuthorizationReply( QNetworkReply *reply ) const { - return QgsApplication::authManager()->updateNetworkReply( reply, mAuthCfg ); + if ( !mAuthCfg.isEmpty() ) + { + return QgsApplication::authManager()->updateNetworkReply( reply, mAuthCfg ); + } + return true; } - return true; - } - //! Username for basic http authentication - QString mUserName; + //! Username for basic http authentication + QString mUserName; - //! Password for basic http authentication - QString mPassword; + //! Password for basic http authentication + QString mPassword; - //! Authentication configuration ID - QString mAuthCfg; + //! Authentication configuration ID + QString mAuthCfg; }; /** @@ -105,12 +105,11 @@ struct QgsWcsAuthorization * data residing in a OGC Web Map Service. * */ -class QgsWcsProvider final: public QgsRasterDataProvider, QgsGdalProviderBase +class QgsWcsProvider final : public QgsRasterDataProvider, QgsGdalProviderBase { Q_OBJECT public: - static QString WCS_KEY; static QString WCS_DESCRIPTION; @@ -151,12 +150,12 @@ class QgsWcsProvider final: public QgsRasterDataProvider, QgsGdalProviderBase // TODO: Document this better. - bool readBlock( int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback = nullptr ) override; + bool readBlock( int bandNo, QgsRectangle const &viewExtent, int width, int height, void *data, QgsRasterBlockFeedback *feedback = nullptr ) override; bool readBlock( int bandNo, int xBlock, int yBlock, void *block ) override; //! Download cache - void getCache( int bandNo, QgsRectangle const &viewExtent, int width, int height, QString crs = QString(), QgsRasterBlockFeedback *feedback = nullptr ) const; + void getCache( int bandNo, QgsRectangle const &viewExtent, int width, int height, QString crs = QString(), QgsRasterBlockFeedback *feedback = nullptr ) const; QgsRectangle extent() const override; @@ -188,7 +187,7 @@ class QgsWcsProvider final: public QgsRasterDataProvider, QgsGdalProviderBase QString name() const override; QString description() const override; Qgis::RasterProviderCapabilities providerCapabilities() const override; - QList colorTable( int bandNo )const override; + QList colorTable( int bandNo ) const override; static QString providerKey(); @@ -314,7 +313,7 @@ class QgsWcsProvider final: public QgsRasterDataProvider, QgsGdalProviderBase //QList mNoDataValue; //! Color tables indexed from 0 - QList< QList > mColorTables; + QList> mColorTables; /** * extents per layer (in WCS CRS:84 datum) @@ -324,7 +323,7 @@ class QgsWcsProvider final: public QgsRasterDataProvider, QgsGdalProviderBase /** * available CRSs per layer */ - QMap mCrsForLayer; + QMap mCrsForLayer; /** * WCS "queryable" per layer @@ -407,7 +406,6 @@ class QgsWcsProvider final: public QgsRasterDataProvider, QgsGdalProviderBase * Clears cache */ void reloadProviderData() override; - }; //! Handler for downloading of coverage data - output is written to mCachedData @@ -442,7 +440,7 @@ class QgsWcsDownloadHandler : public QObject static int sErrors; // this should be ideally per-provider...? }; -class QgsWcsProviderMetadata final: public QgsProviderMetadata +class QgsWcsProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: @@ -452,7 +450,7 @@ class QgsWcsProviderMetadata final: public QgsProviderMetadata QList dataItemProviders() const override; QVariantMap decodeUri( const QString &uri ) const override; QString encodeUri( const QVariantMap &parts ) const override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; #endif diff --git a/src/providers/wcs/qgswcsprovidergui.cpp b/src/providers/wcs/qgswcsprovidergui.cpp index 93827a1c9a82..8fbde6395c4f 100644 --- a/src/providers/wcs/qgswcsprovidergui.cpp +++ b/src/providers/wcs/qgswcsprovidergui.cpp @@ -30,7 +30,6 @@ class QgsWcsSourceSelectProvider : public QgsSourceSelectProvider { public: - QString providerKey() const override { return QStringLiteral( "wcs" ); } QString text() const override { return QObject::tr( "WCS" ); } int ordering() const override { return QgsSourceSelectProvider::OrderRemoteProvider + 30; } @@ -42,7 +41,6 @@ class QgsWcsSourceSelectProvider : public QgsSourceSelectProvider }; - QgsWcsSourceWidgetProvider::QgsWcsSourceWidgetProvider() {} QString QgsWcsSourceWidgetProvider::providerKey() const @@ -59,13 +57,12 @@ QgsProviderSourceWidget *QgsWcsSourceWidgetProvider::createWidget( QgsMapLayer * if ( layer->providerType() != QLatin1String( "wcs" ) ) return nullptr; - QgsOWSSourceWidget *sourceWidget = new QgsOWSSourceWidget( QLatin1String( "wcs" ), parent ); + QgsOWSSourceWidget *sourceWidget = new QgsOWSSourceWidget( QLatin1String( "wcs" ), parent ); return sourceWidget; } - QgsWcsProviderGuiMetadata::QgsWcsProviderGuiMetadata() : QgsProviderGuiMetadata( QgsWcsProvider::WCS_KEY ) { diff --git a/src/providers/wcs/qgswcsprovidergui.h b/src/providers/wcs/qgswcsprovidergui.h index 731a0ddbbdcb..5f88a17f5bf4 100644 --- a/src/providers/wcs/qgswcsprovidergui.h +++ b/src/providers/wcs/qgswcsprovidergui.h @@ -16,9 +16,9 @@ #include "qgswcsprovider.h" #include "qgsproviderguimetadata.h" -#include"qgsprovidersourcewidgetprovider.h" +#include "qgsprovidersourcewidgetprovider.h" -class QgsWcsProviderGuiMetadata: public QgsProviderGuiMetadata +class QgsWcsProviderGuiMetadata : public QgsProviderGuiMetadata { public: QgsWcsProviderGuiMetadata(); @@ -36,7 +36,4 @@ class QgsWcsSourceWidgetProvider : public QgsProviderSourceWidgetProvider QString providerKey() const override; bool canHandleLayer( QgsMapLayer *layer ) const override; QgsProviderSourceWidget *createWidget( QgsMapLayer *layer, QWidget *parent = nullptr ) override; - }; - - diff --git a/src/providers/wcs/qgswcssourceselect.cpp b/src/providers/wcs/qgswcssourceselect.cpp index 555f6d6a5538..ac39cc96e08c 100644 --- a/src/providers/wcs/qgswcssourceselect.cpp +++ b/src/providers/wcs/qgswcssourceselect.cpp @@ -34,7 +34,6 @@ QgsWCSSourceSelect::QgsWCSSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ) : QgsOWSSourceSelect( QStringLiteral( "WCS" ), parent, fl, widgetMode ) { - mTabWidget->removeTab( mTabWidget->indexOf( mLayerOrderTab ) ); mTabWidget->removeTab( mTabWidget->indexOf( mTilesetsTab ) ); mAddDefaultButton->hide(); @@ -46,7 +45,6 @@ QgsWCSSourceSelect::QgsWCSSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs void QgsWCSSourceSelect::populateLayerList() { - mLayersTreeWidget->clear(); @@ -105,7 +103,8 @@ void QgsWCSSourceSelect::populateLayerList() QString QgsWCSSourceSelect::selectedIdentifier() const { const QList selectionList = mLayersTreeWidget->selectedItems(); - if ( selectionList.size() < 1 ) return QString(); // should not happen + if ( selectionList.size() < 1 ) + return QString(); // should not happen QString identifier = selectionList.value( 0 )->data( 0, Qt::UserRole + 0 ).toString(); QgsDebugMsgLevel( " identifier = " + identifier, 2 ); return identifier; @@ -114,7 +113,8 @@ QString QgsWCSSourceSelect::selectedIdentifier() const QString QgsWCSSourceSelect::selectedTitle() const { const QList selectionList = mLayersTreeWidget->selectedItems(); - if ( selectionList.empty() ) return QString(); // should not happen + if ( selectionList.empty() ) + return QString(); // should not happen QString title = selectionList.value( 0 )->data( 0, Qt::UserRole + 1 ).toString(); QgsDebugMsgLevel( " title = " + title, 2 ); return title; @@ -125,7 +125,10 @@ void QgsWCSSourceSelect::addButtonClicked() QgsDataSourceUri uri = mUri; const QString identifier = selectedIdentifier(); - if ( identifier.isEmpty() ) { return; } + if ( identifier.isEmpty() ) + { + return; + } uri.setParam( QStringLiteral( "identifier" ), identifier ); @@ -139,13 +142,13 @@ void QgsWCSSourceSelect::addButtonClicked() uri.setParam( QStringLiteral( "crs" ), selectedCrs() ); //} - QgsDebugMsgLevel( "selectedFormat = " + selectedFormat(), 2 ); + QgsDebugMsgLevel( "selectedFormat = " + selectedFormat(), 2 ); if ( !selectedFormat().isEmpty() ) { uri.setParam( QStringLiteral( "format" ), selectedFormat() ); } - QgsDebugMsgLevel( "selectedTime = " + selectedTime(), 2 ); + QgsDebugMsgLevel( "selectedTime = " + selectedTime(), 2 ); if ( !selectedTime().isEmpty() ) { uri.setParam( QStringLiteral( "time" ), selectedTime() ); @@ -154,17 +157,12 @@ void QgsWCSSourceSelect::addButtonClicked() if ( mSpatialExtentBox->isChecked() ) { QgsRectangle spatialExtent = mSpatialExtentBox->outputExtent(); - QgsCoordinateTransform extentCrsToSSelectedCrs( mSpatialExtentBox->outputCrs(), - QgsCoordinateReferenceSystem( selectedCrs() ), - QgsProject::instance()->transformContext() ); + QgsCoordinateTransform extentCrsToSSelectedCrs( mSpatialExtentBox->outputCrs(), QgsCoordinateReferenceSystem( selectedCrs() ), QgsProject::instance()->transformContext() ); extentCrsToSSelectedCrs.setBallparkTransformsAreAppropriate( true ); spatialExtent = extentCrsToSSelectedCrs.transformBoundingBox( spatialExtent ); bool inverted = uri.hasParam( QStringLiteral( "InvertAxisOrientation" ) ); QString bbox = QString( inverted ? "%2,%1,%4,%3" : "%1,%2,%3,%4" ) - .arg( qgsDoubleToString( spatialExtent.xMinimum() ), - qgsDoubleToString( spatialExtent.yMinimum() ), - qgsDoubleToString( spatialExtent.xMaximum() ), - qgsDoubleToString( spatialExtent.yMaximum() ) ); + .arg( qgsDoubleToString( spatialExtent.xMinimum() ), qgsDoubleToString( spatialExtent.yMinimum() ), qgsDoubleToString( spatialExtent.xMaximum() ), qgsDoubleToString( spatialExtent.yMaximum() ) ); uri.setParam( QStringLiteral( "bbox" ), bbox ); } @@ -187,9 +185,11 @@ void QgsWCSSourceSelect::addButtonClicked() void QgsWCSSourceSelect::mLayersTreeWidget_itemSelectionChanged() { - const QString identifier = selectedIdentifier(); - if ( identifier.isEmpty() ) { return; } + if ( identifier.isEmpty() ) + { + return; + } mCapabilities.describeCoverage( identifier ); @@ -206,7 +206,6 @@ void QgsWCSSourceSelect::mLayersTreeWidget_itemSelectionChanged() void QgsWCSSourceSelect::updateButtons() { - if ( mLayersTreeWidget->selectedItems().isEmpty() ) { showStatusMessage( tr( "Select a layer" ) ); @@ -247,12 +246,17 @@ QList QgsWCSSourceSelect::providerFormats() QStringList QgsWCSSourceSelect::selectedLayersFormats() { - const QString identifier = selectedIdentifier(); - if ( identifier.isEmpty() ) { return QStringList(); } + if ( identifier.isEmpty() ) + { + return QStringList(); + } const QgsWcsCoverageSummary c = mCapabilities.coverage( identifier ); - if ( !c.valid ) { return QStringList(); } + if ( !c.valid ) + { + return QStringList(); + } QgsDebugMsgLevel( "supportedFormat = " + c.supportedFormat.join( "," ), 2 ); return c.supportedFormat; @@ -261,22 +265,33 @@ QStringList QgsWCSSourceSelect::selectedLayersFormats() QStringList QgsWCSSourceSelect::selectedLayersCrses() { const QString identifier = selectedIdentifier(); - if ( identifier.isEmpty() ) { return QStringList(); } + if ( identifier.isEmpty() ) + { + return QStringList(); + } const QgsWcsCoverageSummary c = mCapabilities.coverage( identifier ); - if ( !c.valid ) { return QStringList(); } + if ( !c.valid ) + { + return QStringList(); + } return c.supportedCrs; } QStringList QgsWCSSourceSelect::selectedLayersTimes() { - const QString identifier = selectedIdentifier(); - if ( identifier.isEmpty() ) { return QStringList(); } + if ( identifier.isEmpty() ) + { + return QStringList(); + } const QgsWcsCoverageSummary c = mCapabilities.coverage( identifier ); - if ( !c.valid ) { return QStringList(); } + if ( !c.valid ) + { + return QStringList(); + } QgsDebugMsgLevel( "times = " + c.times.join( "," ), 2 ); return c.times; diff --git a/src/providers/wcs/qgswcssourceselect.h b/src/providers/wcs/qgswcssourceselect.h index 1505fe1fdc93..a831b5a9362f 100644 --- a/src/providers/wcs/qgswcssourceselect.h +++ b/src/providers/wcs/qgswcssourceselect.h @@ -79,5 +79,3 @@ class QgsWCSSourceSelect : public QgsOWSSourceSelect void showHelp(); }; #endif // QGSWCSSOURCESELECT_H - - diff --git a/src/providers/wfs/oapif/qgsoapifapirequest.cpp b/src/providers/wfs/oapif/qgsoapifapirequest.cpp index fbde8e7aaa97..4eddef7e3279 100644 --- a/src/providers/wfs/oapif/qgsoapifapirequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifapirequest.cpp @@ -22,9 +22,8 @@ using namespace nlohmann; #include -QgsOapifApiRequest::QgsOapifApiRequest( const QgsDataSourceUri &baseUri, const QString &url ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), - mUrl( url ) +QgsOapifApiRequest::QgsOapifApiRequest( const QgsDataSourceUri &baseUri, const QString &url ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), mUrl( url ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main @@ -145,16 +144,15 @@ void QgsOapifApiRequest::processReply() const auto &paths = j["paths"]; if ( paths.is_object() ) { - for ( const auto& [key, val] : paths.items() ) + for ( const auto &[key, val] : paths.items() ) { const char *prefix = "/collections/"; const char *suffix = "/items"; - if ( key.size() > strlen( prefix ) + strlen( suffix ) && - key.compare( 0, strlen( prefix ), prefix ) == 0 && - key.compare( key.size() - strlen( suffix ), std::string::npos, suffix ) == 0 ) + if ( key.size() > strlen( prefix ) + strlen( suffix ) && key.compare( 0, strlen( prefix ), prefix ) == 0 && key.compare( key.size() - strlen( suffix ), std::string::npos, suffix ) == 0 ) { const std::string collection = key.substr( - strlen( prefix ), key.size() - strlen( prefix ) - strlen( suffix ) ); + strlen( prefix ), key.size() - strlen( prefix ) - strlen( suffix ) + ); if ( val.is_object() && val.contains( "get" ) ) { const auto &get = val["get"]; @@ -178,37 +176,21 @@ void QgsOapifApiRequest::processReply() parameterResolved = resolveRef( j, refStr ); } } - if ( parameterResolved && - parameterResolved->is_object() && - parameterResolved->contains( "name" ) && - parameterResolved->contains( "in" ) && - parameterResolved->contains( "style" ) && - parameterResolved->contains( "explode" ) && - parameterResolved->contains( "schema" ) ) + if ( parameterResolved && parameterResolved->is_object() && parameterResolved->contains( "name" ) && parameterResolved->contains( "in" ) && parameterResolved->contains( "style" ) && parameterResolved->contains( "explode" ) && parameterResolved->contains( "schema" ) ) { const auto &jName = ( *parameterResolved )["name"]; const auto &jIn = ( *parameterResolved )["in"]; const auto &jStyle = ( *parameterResolved )["style"]; const auto &jExplode = ( *parameterResolved )["explode"]; const auto &jSchema = ( *parameterResolved )["schema"]; - if ( jName.is_string() && jIn.is_string() && - jStyle.is_string() && jExplode.is_boolean() && - jSchema.is_object() && jSchema.contains( "type" ) ) + if ( jName.is_string() && jIn.is_string() && jStyle.is_string() && jExplode.is_boolean() && jSchema.is_object() && jSchema.contains( "type" ) ) { const auto name = jName.get(); const auto in = jIn.get(); const auto style = jStyle.get(); const bool explode = jExplode.get(); const auto jSchemaType = jSchema["type"]; - if ( in == "query" && - style == "form" && - !explode && - jSchemaType.is_string() && - name != "crs" && - name != "bbox" && name != "bbox-crs" && - name != "filter" && name != "filter-lang" && - name != "filter-crs" && name != "datetime" && - name != "limit" ) + if ( in == "query" && style == "form" && !explode && jSchemaType.is_string() && name != "crs" && name != "bbox" && name != "bbox-crs" && name != "filter" && name != "filter-lang" && name != "filter-crs" && name != "datetime" && name != "limit" ) { SimpleQueryable queryable; queryable.mType = QString::fromStdString( jSchemaType.get() ); diff --git a/src/providers/wfs/oapif/qgsoapifapirequest.h b/src/providers/wfs/oapif/qgsoapifapirequest.h index a7a31d332464..522a648ebc3a 100644 --- a/src/providers/wfs/oapif/qgsoapifapirequest.h +++ b/src/providers/wfs/oapif/qgsoapifapirequest.h @@ -55,15 +55,15 @@ class QgsOapifApiRequest : public QgsBaseNetworkRequest //! Describes a simple queryable parameter. struct SimpleQueryable { - // type as in a JSON schema: "string", "integer", "number", etc. - QString mType; + // type as in a JSON schema: "string", "integer", "number", etc. + QString mType; }; //! Describes the properties of a collection. struct CollectionProperties { - // Map of simple queryables items (that is as query parameters). The key of the map is a queryable name. - QMap mSimpleQueryables; + // Map of simple queryables items (that is as query parameters). The key of the map is a queryable name. + QMap mSimpleQueryables; }; //! Get collection properties. The key of the map is a collection name. @@ -91,7 +91,6 @@ class QgsOapifApiRequest : public QgsBaseNetworkRequest QMap mCollectionProperties; ApplicationLevelError mAppLevelError = ApplicationLevelError::NoError; - }; #endif // QGSOAPIFAPIREQUEST_H diff --git a/src/providers/wfs/oapif/qgsoapifcollection.cpp b/src/providers/wfs/oapif/qgsoapifcollection.cpp index e6cadad5acd9..2bd9109e00e7 100644 --- a/src/providers/wfs/oapif/qgsoapifcollection.cpp +++ b/src/providers/wfs/oapif/qgsoapifcollection.cpp @@ -53,9 +53,7 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) mLayerMetadata.setType( QStringLiteral( "dataset" ) ); const auto links = QgsOAPIFJson::parseLinks( j ); - const auto selfUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "self" ), - { QStringLiteral( "application/json" ) } ); + const auto selfUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "self" ), { QStringLiteral( "application/json" ) } ); if ( !selfUrl.isEmpty() ) { mLayerMetadata.setIdentifier( selfUrl ); @@ -65,9 +63,7 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) mLayerMetadata.setIdentifier( mId ); } - const auto parentUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "parent" ), - { QStringLiteral( "application/json" ) } ); + const auto parentUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "parent" ), { QStringLiteral( "application/json" ) } ); if ( !parentUrl.isEmpty() ) { mLayerMetadata.setParentIdentifier( parentUrl ); @@ -113,7 +109,8 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) if ( spatial.is_object() && spatial.contains( "bbox" ) ) { QgsCoordinateReferenceSystem crs( QgsCoordinateReferenceSystem::fromOgcWmsCrs( - QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS ) ); + QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS + ) ); if ( spatial.contains( "crs" ) ) { const auto jCrs = spatial["crs"]; @@ -126,7 +123,7 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) const auto jBboxes = spatial["bbox"]; if ( jBboxes.is_array() ) { - QList< QgsLayerMetadata::SpatialExtent > spatialExtents; + QList spatialExtents; bool firstBbox = true; for ( const auto &jBbox : jBboxes ) { @@ -160,8 +157,7 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) mBboxCrs = crs; mBbox.set( values[0], values[1], values[3], values[4] ); } - spatialExtent.bounds = QgsBox3D( values[0], values[1], values[2], - values[3], values[4], values[5] ); + spatialExtent.bounds = QgsBox3D( values[0], values[1], values[2], values[3], values[4], values[5] ); } if ( values.size() == 4 || values.size() == 6 ) { @@ -195,9 +191,10 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) mBbox.set( values[0], values[1], values[2], values[3] ); QgsLayerMetadata::SpatialExtent spatialExtent; spatialExtent.extentCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( - QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS ); + QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS + ); mLayerMetadata.setCrs( spatialExtent.extentCrs ); - metadataExtent.setSpatialExtents( QList< QgsLayerMetadata::SpatialExtent >() << spatialExtent ); + metadataExtent.setSpatialExtents( QList() << spatialExtent ); } } } @@ -211,7 +208,7 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) const auto jIntervals = temporal["interval"]; if ( jIntervals.is_array() ) { - QList< QgsDateTimeRange > temporalExtents; + QList temporalExtents; for ( const auto &jInterval : jIntervals ) { if ( jInterval.is_array() && jInterval.size() == 2 ) @@ -264,7 +261,7 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) { if ( link.rel == QLatin1String( "license" ) ) { - const auto license = !link.title.isEmpty() ? link.title : link.href; + const auto license = !link.title.isEmpty() ? link.title : link.href; if ( licenseSet.find( license ) == licenseSet.end() ) { licenseSet.insert( license ); @@ -329,9 +326,7 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) { json jCrs = j["crs"]; // Resolve "#/crs" link - if ( jCrs.is_array() && jCrs.size() == 1 && - jCrs[0].is_string() && jCrs[0].get() == "#/crs" && - jCollections.is_object() && jCollections.contains( "crs" ) ) + if ( jCrs.is_array() && jCrs.size() == 1 && jCrs[0].is_string() && jCrs[0].get() == "#/crs" && jCollections.is_object() && jCollections.contains( "crs" ) ) { jCrs = jCollections["crs"]; } @@ -363,7 +358,8 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) if ( mCrsList.isEmpty() ) { QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( - QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS ); + QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS + ); mLayerMetadata.setCrs( QgsCoordinateReferenceSystem::fromOgcWmsCrs( crs.authid() ) ); mCrsList.append( crs.authid() ); } @@ -373,9 +369,8 @@ bool QgsOapifCollection::deserialize( const json &j, const json &jCollections ) // ----------------------------------------- -QgsOapifCollectionsRequest::QgsOapifCollectionsRequest( const QgsDataSourceUri &baseUri, const QString &url ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), - mUrl( url ) +QgsOapifCollectionsRequest::QgsOapifCollectionsRequest( const QgsDataSourceUri &baseUri, const QString &url ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), mUrl( url ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main @@ -442,7 +437,7 @@ void QgsOapifCollectionsRequest::processReply() { if ( link.rel == QLatin1String( "license" ) ) { - const auto license = !link.title.isEmpty() ? link.title : link.href; + const auto license = !link.title.isEmpty() ? link.title : link.href; if ( licenseSet.find( license ) == licenseSet.end() ) { licenseSet.insert( license ); @@ -474,9 +469,7 @@ void QgsOapifCollectionsRequest::processReply() } // Paging informal extension used by api.planet.com/ - mNextUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "next" ), - { QStringLiteral( "application/json" ) } ); + mNextUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "next" ), { QStringLiteral( "application/json" ) } ); } catch ( const json::parse_error &ex ) { @@ -492,9 +485,8 @@ void QgsOapifCollectionsRequest::processReply() // ----------------------------------------- -QgsOapifCollectionRequest::QgsOapifCollectionRequest( const QgsDataSourceUri &baseUri, const QString &url ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), - mUrl( url ) +QgsOapifCollectionRequest::QgsOapifCollectionRequest( const QgsDataSourceUri &baseUri, const QString &url ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), mUrl( url ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main diff --git a/src/providers/wfs/oapif/qgsoapifcollection.h b/src/providers/wfs/oapif/qgsoapifcollection.h index 699a606d4973..da61625b4f32 100644 --- a/src/providers/wfs/oapif/qgsoapifcollection.h +++ b/src/providers/wfs/oapif/qgsoapifcollection.h @@ -30,29 +30,29 @@ using namespace nlohmann; //! Describes a collection struct QgsOapifCollection { - //! Identifier - QString mId; + //! Identifier + QString mId; - //! Title - QString mTitle; + //! Title + QString mTitle; - //! Description - QString mDescription; + //! Description + QString mDescription; - //! Bounding box - QgsRectangle mBbox; + //! Bounding box + QgsRectangle mBbox; - //! Bounding box Crs - QgsCoordinateReferenceSystem mBboxCrs; + //! Bounding box Crs + QgsCoordinateReferenceSystem mBboxCrs; - //! List of available CRS - QList mCrsList; + //! List of available CRS + QList mCrsList; - //! Layer metadata - QgsLayerMetadata mLayerMetadata; + //! Layer metadata + QgsLayerMetadata mLayerMetadata; - //! Fills a collection from its JSON serialization - bool deserialize( const json &j, const json &jCollections ); + //! Fills a collection from its JSON serialization + bool deserialize( const json &j, const json &jCollections ); }; //! Manages the /collections request @@ -100,7 +100,6 @@ class QgsOapifCollectionsRequest : public QgsBaseNetworkRequest QString mNextUrl; ApplicationLevelError mAppLevelError = ApplicationLevelError::NoError; - }; //! Manages the /collection/{collectionId} request @@ -143,7 +142,6 @@ class QgsOapifCollectionRequest : public QgsBaseNetworkRequest QgsOapifCollection mCollection; ApplicationLevelError mAppLevelError = ApplicationLevelError::NoError; - }; #endif // QGSOAPIFCOLLECTION_H diff --git a/src/providers/wfs/oapif/qgsoapifconformancerequest.cpp b/src/providers/wfs/oapif/qgsoapifconformancerequest.cpp index 240d357f4c20..df6a632d1ed3 100644 --- a/src/providers/wfs/oapif/qgsoapifconformancerequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifconformancerequest.cpp @@ -24,8 +24,8 @@ using namespace nlohmann; #include -QgsOapifConformanceRequest::QgsOapifConformanceRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) +QgsOapifConformanceRequest::QgsOapifConformanceRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main diff --git a/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.cpp b/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.cpp index f1d711468f81..ba8498ae1bb4 100644 --- a/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.cpp +++ b/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.cpp @@ -27,12 +27,9 @@ QgsOapifCql2TextExpressionCompiler::QgsOapifCql2TextExpressionCompiler( bool supportsLikeBetweenIn, bool supportsCaseI, bool supportsBasicSpatialOperators, - bool invertAxisOrientation ): - mQueryables( queryables ), - mSupportsLikeBetweenIn( supportsLikeBetweenIn ), - mSupportsCaseI( supportsCaseI ), - mSupportsBasicSpatialOperators( supportsBasicSpatialOperators ), - mInvertAxisOrientation( invertAxisOrientation ) + bool invertAxisOrientation +) + : mQueryables( queryables ), mSupportsLikeBetweenIn( supportsLikeBetweenIn ), mSupportsCaseI( supportsCaseI ), mSupportsBasicSpatialOperators( supportsBasicSpatialOperators ), mInvertAxisOrientation( invertAxisOrientation ) { } @@ -225,9 +222,7 @@ QgsOapifCql2TextExpressionCompiler::Result QgsOapifCql2TextExpressionCompiler::c return Fail; values.push_back( n->value().toInt() ); } - result = QDateTime( QDate( values[0], values[1], values[2] ), - QTime( values[3], values[4], values[5] ), - Qt::UTC ).toString( Qt::ISODateWithMs ).prepend( "TIMESTAMP('" ).append( "')" ); + result = QDateTime( QDate( values[0], values[1], values[2] ), QTime( values[3], values[4], values[5] ), Qt::UTC ).toString( Qt::ISODateWithMs ).prepend( "TIMESTAMP('" ).append( "')" ); return Complete; } } @@ -417,8 +412,7 @@ QgsOapifCql2TextExpressionCompiler::Result QgsOapifCql2TextExpressionCompiler::c // Special case to handle "datetimefield OP 'YYYY-MM-DDTHH:MM:SS'" // or "datefield OP 'YYYY-MM-DD'" // that can be suggested by the query builder - if ( n->opLeft()->nodeType() == QgsExpressionNode::ntColumnRef && - n->opRight()->nodeType() == QgsExpressionNode::ntLiteral ) + if ( n->opLeft()->nodeType() == QgsExpressionNode::ntColumnRef && n->opRight()->nodeType() == QgsExpressionNode::ntLiteral ) { const QgsExpressionNodeColumnRef *nLeft = static_cast( n->opLeft() ); const QgsExpressionNodeLiteral *nRight = static_cast( n->opRight() ); @@ -575,4 +569,3 @@ QgsOapifCql2TextExpressionCompiler::Result QgsOapifCql2TextExpressionCompiler::c return Fail; } - diff --git a/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.h b/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.h index debf39059a52..49155feef14c 100644 --- a/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.h +++ b/src/providers/wfs/oapif/qgsoapifcql2textexpressioncompiler.h @@ -37,14 +37,15 @@ class QgsOapifCql2TextExpressionCompiler bool supportsLikeBetweenIn, bool supportsCaseI, bool supportsBasicSpatialOperators, - bool invertAxisOrientation ); + bool invertAxisOrientation + ); //! Possible results from expression compilation enum Result { Complete, //!< Expression was successfully compiled and can be completely delegated to provider - Partial, //!< Expression was partially compiled, but provider will return extra records and results must be double-checked using QGIS' expression engine - Fail //!< Provider cannot handle expression + Partial, //!< Expression was partially compiled, but provider will return extra records and results must be double-checked using QGIS' expression engine + Fail //!< Provider cannot handle expression }; /** @@ -63,7 +64,6 @@ class QgsOapifCql2TextExpressionCompiler bool geometryLiteralUsed() const { return mGeometryLiteralUsed; } private: - Result compileNode( const QgsExpressionNode *node, QString &result ); Result compileNodeFunction( const QgsExpressionNodeFunction *n, QString &result ); diff --git a/src/providers/wfs/oapif/qgsoapifcreatefeaturerequest.cpp b/src/providers/wfs/oapif/qgsoapifcreatefeaturerequest.cpp index 44eb02f0833f..3f16895f4894 100644 --- a/src/providers/wfs/oapif/qgsoapifcreatefeaturerequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifcreatefeaturerequest.cpp @@ -22,8 +22,8 @@ using namespace nlohmann; #include "moc_qgsoapifcreatefeaturerequest.cpp" #include "qgsoapifprovider.h" -QgsOapifCreateFeatureRequest::QgsOapifCreateFeatureRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) +QgsOapifCreateFeatureRequest::QgsOapifCreateFeatureRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) { } diff --git a/src/providers/wfs/oapif/qgsoapifdeletefeaturerequest.cpp b/src/providers/wfs/oapif/qgsoapifdeletefeaturerequest.cpp index 249e6b8cc552..5d6238e09c57 100644 --- a/src/providers/wfs/oapif/qgsoapifdeletefeaturerequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifdeletefeaturerequest.cpp @@ -17,8 +17,8 @@ #include "qgsoapifdeletefeaturerequest.h" #include "moc_qgsoapifdeletefeaturerequest.cpp" -QgsOapifDeleteFeatureRequest::QgsOapifDeleteFeatureRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) +QgsOapifDeleteFeatureRequest::QgsOapifDeleteFeatureRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) { } diff --git a/src/providers/wfs/oapif/qgsoapifitemsrequest.cpp b/src/providers/wfs/oapif/qgsoapifitemsrequest.cpp index e40fd638d156..b8e182992a2b 100644 --- a/src/providers/wfs/oapif/qgsoapifitemsrequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifitemsrequest.cpp @@ -26,9 +26,8 @@ using namespace nlohmann; #include -QgsOapifItemsRequest::QgsOapifItemsRequest( const QgsDataSourceUri &baseUri, const QString &url ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), - mUrl( url ) +QgsOapifItemsRequest::QgsOapifItemsRequest( const QgsDataSourceUri &baseUri, const QString &url ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), mUrl( url ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main @@ -124,16 +123,14 @@ void QgsOapifItemsRequest::processReply() removeUselessSpacesFromJSONBuffer( buffer ); QgsDebugMsgLevel( QStringLiteral( "JSON compaction end time: %1" ).arg( time( nullptr ) ), 5 ); - const QString vsimemFilename = QStringLiteral( "/vsimem/oaipf_%1.json" ).arg( reinterpret_cast< quintptr >( &buffer ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); - VSIFCloseL( VSIFileFromMemBuffer( vsimemFilename.toUtf8().constData(), - const_cast( reinterpret_cast( buffer.constData() ) ), - buffer.size(), - false ) ); + const QString vsimemFilename = QStringLiteral( "/vsimem/oaipf_%1.json" ).arg( reinterpret_cast( &buffer ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); + VSIFCloseL( VSIFileFromMemBuffer( vsimemFilename.toUtf8().constData(), const_cast( reinterpret_cast( buffer.constData() ) ), buffer.size(), false ) ); QgsProviderRegistry *pReg = QgsProviderRegistry::instance(); const QgsDataProvider::ProviderOptions providerOptions; QgsDebugMsgLevel( QStringLiteral( "OGR data source open start time: %1" ).arg( time( nullptr ) ), 5 ); auto vectorProvider = std::unique_ptr( - qobject_cast< QgsVectorDataProvider * >( pReg->createProvider( "ogr", vsimemFilename, providerOptions ) ) ); + qobject_cast( pReg->createProvider( "ogr", vsimemFilename, providerOptions ) ) + ); QgsDebugMsgLevel( QStringLiteral( "OGR data source open end time: %1" ).arg( time( nullptr ) ), 5 ); if ( !vectorProvider || !vectorProvider->isValid() ) { @@ -167,7 +164,7 @@ void QgsOapifItemsRequest::processReply() try { QgsDebugMsgLevel( QStringLiteral( "json::parse() start time: %1" ).arg( time( nullptr ) ), 5 ); - const json j = json::parse( buffer.constData(), buffer.constData() + buffer.size() ); + const json j = json::parse( buffer.constData(), buffer.constData() + buffer.size() ); QgsDebugMsgLevel( QStringLiteral( "json::parse() end time: %1" ).arg( time( nullptr ) ), 5 ); if ( j.is_object() && j.contains( "features" ) ) { @@ -203,9 +200,7 @@ void QgsOapifItemsRequest::processReply() } const auto links = QgsOAPIFJson::parseLinks( j ); - mNextUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "next" ), - { QStringLiteral( "application/geo+json" ) } ); + mNextUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "next" ), { QStringLiteral( "application/geo+json" ) } ); if ( j.is_object() && j.contains( "numberMatched" ) ) { diff --git a/src/providers/wfs/oapif/qgsoapiflandingpagerequest.cpp b/src/providers/wfs/oapif/qgsoapiflandingpagerequest.cpp index a47a7ab57993..ec7591d7de14 100644 --- a/src/providers/wfs/oapif/qgsoapiflandingpagerequest.cpp +++ b/src/providers/wfs/oapif/qgsoapiflandingpagerequest.cpp @@ -24,9 +24,8 @@ using namespace nlohmann; #include -QgsOapifLandingPageRequest::QgsOapifLandingPageRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ), - mUri( uri ) +QgsOapifLandingPageRequest::QgsOapifLandingPageRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ), mUri( uri ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main @@ -88,41 +87,31 @@ void QgsOapifLandingPageRequest::processReply() const auto links = QgsOAPIFJson::parseLinks( j ); QStringList apiTypes; - apiTypes << QStringLiteral( "application/vnd.oai.openapi+json;version=3.0" ); + apiTypes << QStringLiteral( "application/vnd.oai.openapi+json;version=3.0" ); #ifndef REMOVE_SUPPORT_DRAFT_VERSIONS - apiTypes << QStringLiteral( "application/openapi+json;version=3.0" ); + apiTypes << QStringLiteral( "application/openapi+json;version=3.0" ); #endif - mApiUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "service-desc" ), - apiTypes ); + mApiUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "service-desc" ), apiTypes ); #ifndef REMOVE_SUPPORT_DRAFT_VERSIONS if ( mApiUrl.isEmpty() ) { - mApiUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "service" ), - apiTypes ); + mApiUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "service" ), apiTypes ); } #endif #ifndef REMOVE_SUPPORT_QGIS_SERVER_3_10_0_WRONG_SERVICE_DESC if ( mApiUrl.isEmpty() ) { - mApiUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "service_desc" ), - apiTypes ); + mApiUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "service_desc" ), apiTypes ); } #endif QStringList collectionsTypes; collectionsTypes << QStringLiteral( "application/json" ); - mCollectionsUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "data" ), - collectionsTypes ); + mCollectionsUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "data" ), collectionsTypes ); #ifndef REMOVE_SUPPORT_DRAFT_VERSIONS if ( mCollectionsUrl.isEmpty() ) { - mCollectionsUrl = QgsOAPIFJson::findLink( links, - QStringLiteral( "collections" ), - apiTypes ); + mCollectionsUrl = QgsOAPIFJson::findLink( links, QStringLiteral( "collections" ), apiTypes ); } #endif diff --git a/src/providers/wfs/oapif/qgsoapiflandingpagerequest.h b/src/providers/wfs/oapif/qgsoapiflandingpagerequest.h index 766ca7e037dd..9fd2e30d7b30 100644 --- a/src/providers/wfs/oapif/qgsoapiflandingpagerequest.h +++ b/src/providers/wfs/oapif/qgsoapiflandingpagerequest.h @@ -74,7 +74,6 @@ class QgsOapifLandingPageRequest : public QgsBaseNetworkRequest QString mConformanceUrl; ApplicationLevelError mAppLevelError = ApplicationLevelError::NoError; - }; #endif // QGSOAPIFLANDINGPAGEREQUEST_H diff --git a/src/providers/wfs/oapif/qgsoapifoptionsrequest.cpp b/src/providers/wfs/oapif/qgsoapifoptionsrequest.cpp index b446cb84d328..3f07f4079b3a 100644 --- a/src/providers/wfs/oapif/qgsoapifoptionsrequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifoptionsrequest.cpp @@ -16,8 +16,8 @@ #include "qgsoapifoptionsrequest.h" #include "moc_qgsoapifoptionsrequest.cpp" -QgsOapifOptionsRequest::QgsOapifOptionsRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) +QgsOapifOptionsRequest::QgsOapifOptionsRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) { } diff --git a/src/providers/wfs/oapif/qgsoapifpatchfeaturerequest.cpp b/src/providers/wfs/oapif/qgsoapifpatchfeaturerequest.cpp index 4dc3715d3b56..06805e2866be 100644 --- a/src/providers/wfs/oapif/qgsoapifpatchfeaturerequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifpatchfeaturerequest.cpp @@ -22,8 +22,8 @@ using namespace nlohmann; #include "moc_qgsoapifpatchfeaturerequest.cpp" #include "qgsoapifprovider.h" -QgsOapifPatchFeatureRequest::QgsOapifPatchFeatureRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) +QgsOapifPatchFeatureRequest::QgsOapifPatchFeatureRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) { } @@ -53,10 +53,10 @@ bool QgsOapifPatchFeatureRequest::patchFeature( const QgsOapifSharedData *shared for ( ; attMapIt != attrMap.constEnd(); ++attMapIt ) { QString fieldName = sharedData->mFields.at( attMapIt.key() ).name(); - properties[ fieldName.toStdString() ] = QgsJsonUtils::jsonFromVariant( attMapIt.value() ); + properties[fieldName.toStdString()] = QgsJsonUtils::jsonFromVariant( attMapIt.value() ); } json j; - j[ "properties" ] = properties; + j["properties"] = properties; mEmptyResponseIsValid = true; mFakeURLIncludesContentType = true; QUrl url( sharedData->mItemsUrl + QString( QStringLiteral( "/" ) + jsonId ) ); diff --git a/src/providers/wfs/oapif/qgsoapifprovider.cpp b/src/providers/wfs/oapif/qgsoapifprovider.cpp index 79d34361c917..d317293e7a5b 100644 --- a/src/providers/wfs/oapif/qgsoapifprovider.cpp +++ b/src/providers/wfs/oapif/qgsoapifprovider.cpp @@ -44,10 +44,8 @@ const QString QgsOapifProvider::OAPIF_PROVIDER_DESCRIPTION = QStringLiteral( "OG const QString QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS = QStringLiteral( "http://www.opengis.net/def/crs/OGC/1.3/CRS84" ); QgsOapifProvider::QgsOapifProvider( const QString &uri, const ProviderOptions &options, Qgis::DataProviderReadFlags flags ) - : QgsVectorDataProvider( uri, options, flags ), - mShared( new QgsOapifSharedData( uri ) ) + : QgsVectorDataProvider( uri, options, flags ), mShared( new QgsOapifSharedData( uri ) ) { - connect( mShared.get(), &QgsOapifSharedData::raiseError, this, &QgsOapifProvider::pushErrorSlot ); connect( mShared.get(), &QgsOapifSharedData::extentUpdated, this, &QgsOapifProvider::fullExtentCalculated ); @@ -152,20 +150,16 @@ bool QgsOapifProvider::init() mShared->mPageSize = 100; // fallback to arbitrary page size } - mShared->mCollectionUrl = - landingPageRequest.collectionsUrl() + QStringLiteral( "/" ) + mShared->mURI.typeName(); + mShared->mCollectionUrl = landingPageRequest.collectionsUrl() + QStringLiteral( "/" ) + mShared->mURI.typeName(); std::unique_ptr collectionRequest = std::make_unique( mShared->mURI.uri(), mShared->appendExtraQueryParameters( mShared->mCollectionUrl ) ); - if ( !collectionRequest->request( synchronous, forceRefresh ) || - collectionRequest->errorCode() != QgsBaseNetworkRequest::NoError ) + if ( !collectionRequest->request( synchronous, forceRefresh ) || collectionRequest->errorCode() != QgsBaseNetworkRequest::NoError ) { - // Retry with a trailing slash. Works around a bug with // https://geoserveis.ide.cat/servei/catalunya/inspire/ogc/features/collections/inspire:AD.Address not working // but https://geoserveis.ide.cat/servei/catalunya/inspire/ogc/features/collections/inspire:AD.Address/ working - mShared->mCollectionUrl += QStringLiteral( "/" ); + mShared->mCollectionUrl += QStringLiteral( "/" ); collectionRequest = std::make_unique( mShared->mURI.uri(), mShared->appendExtraQueryParameters( mShared->mCollectionUrl ) ); - if ( !collectionRequest->request( synchronous, forceRefresh ) || - collectionRequest->errorCode() != QgsBaseNetworkRequest::NoError ) + if ( !collectionRequest->request( synchronous, forceRefresh ) || collectionRequest->errorCode() != QgsBaseNetworkRequest::NoError ) { return false; } @@ -179,26 +173,11 @@ bool QgsOapifProvider::init() const QStringList conformanceClasses = conformanceRequest.conformanceClasses( conformanceUrl ); implementsPart2 = conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-2/1.0/conf/crs" ) ); - const bool implementsCql2Text = - ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/cql2-text" ) ) || - conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/cql2-text" ) ) ); - mShared->mServerSupportsFilterCql2Text = - ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/basic-cql2" ) ) || - conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/basic-cql2" ) ) ) && - ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/0.0/conf/filter" ) ) || - conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter" ) ) ) && - ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/0.0/conf/features-filter" ) ) || - conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter" ) ) ) && - implementsCql2Text; - mShared->mServerSupportsLikeBetweenIn = - ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/advanced-comparison-operators" ) ) || - conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/advanced-comparison-operators" ) ) ); - mShared->mServerSupportsCaseI = - ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/case-insensitive-comparison" ) ) || - conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/case-insensitive-comparison" ) ) ); - mShared->mServerSupportsBasicSpatialOperators = - ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/basic-spatial-operators" ) ) || - conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/basic-spatial-operators" ) ) ); + const bool implementsCql2Text = ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/cql2-text" ) ) || conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/cql2-text" ) ) ); + mShared->mServerSupportsFilterCql2Text = ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/basic-cql2" ) ) || conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/basic-cql2" ) ) ) && ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/0.0/conf/filter" ) ) || conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter" ) ) ) && ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/0.0/conf/features-filter" ) ) || conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter" ) ) ) && implementsCql2Text; + mShared->mServerSupportsLikeBetweenIn = ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/advanced-comparison-operators" ) ) || conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/advanced-comparison-operators" ) ) ); + mShared->mServerSupportsCaseI = ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/case-insensitive-comparison" ) ) || conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/case-insensitive-comparison" ) ) ); + mShared->mServerSupportsBasicSpatialOperators = ( conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/0.0/conf/basic-spatial-operators" ) ) || conformanceClasses.contains( QLatin1String( "http://www.opengis.net/spec/cql2/1.0/conf/basic-spatial-operators" ) ) ); } mLayerMetadata = collectionRequest->collection().mLayerMetadata; @@ -221,13 +200,13 @@ bool QgsOapifProvider::init() else { mShared->mSourceCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( - QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS ); + QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS + ); } mShared->mCapabilityExtent = collectionRequest->collection().mBbox; // Reproject extent of /collection request to the layer CRS - if ( !mShared->mCapabilityExtent.isNull() && - collectionRequest->collection().mBboxCrs != mShared->mSourceCrs ) + if ( !mShared->mCapabilityExtent.isNull() && collectionRequest->collection().mBboxCrs != mShared->mSourceCrs ) { QgsCoordinateTransform ct( collectionRequest->collection().mBboxCrs, mShared->mSourceCrs, transformContext() ); ct.setBallparkTransformsAreAppropriate( true ); @@ -249,12 +228,12 @@ bool QgsOapifProvider::init() if ( mShared->mServerSupportsFilterCql2Text ) { - const QString queryablesUrl = mShared->mCollectionUrl + QStringLiteral( "/queryables" ); + const QString queryablesUrl = mShared->mCollectionUrl + QStringLiteral( "/queryables" ); QgsOapifQueryablesRequest queryablesRequest( mShared->mURI.uri() ); mShared->mQueryables = queryablesRequest.queryables( queryablesUrl ); } - mShared->mItemsUrl = mShared->mCollectionUrl + QStringLiteral( "/items" ); + mShared->mItemsUrl = mShared->mCollectionUrl + QStringLiteral( "/items" ); QgsOapifItemsRequest itemsRequest( mShared->mURI.uri(), mShared->appendExtraQueryParameters( mShared->mItemsUrl + QStringLiteral( "?limit=10" ) ) ); if ( mShared->mCapabilityExtent.isNull() ) @@ -280,9 +259,9 @@ bool QgsOapifProvider::init() mShared->mCapabilityExtent = itemsRequest.bbox(); if ( !mShared->mCapabilityExtent.isNull() ) { - QgsCoordinateReferenceSystem defaultCrs = - QgsCoordinateReferenceSystem::fromOgcWmsCrs( - QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS ); + QgsCoordinateReferenceSystem defaultCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( + QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS + ); if ( defaultCrs != mShared->mSourceCrs ) { QgsCoordinateTransform ct( defaultCrs, mShared->mSourceCrs, transformContext() ); @@ -300,7 +279,6 @@ bool QgsOapifProvider::init() } } } - } mShared->mFields = itemsRequest.fields(); @@ -382,7 +360,7 @@ long long QgsOapifProvider::featureCount() const countExact = false; break; } - count ++; + count++; } mShared->setFeatureCount( count, countExact ); @@ -419,9 +397,7 @@ bool QgsOapifProvider::isValid() const void QgsOapifProvider::computeCapabilities( const QgsOapifItemsRequest &itemsRequest ) { - mCapabilities = Qgis::VectorProviderCapability::SelectAtId | - Qgis::VectorProviderCapability::ReadLayerMetadata | - Qgis::VectorProviderCapability::ReloadData; + mCapabilities = Qgis::VectorProviderCapability::SelectAtId | Qgis::VectorProviderCapability::ReadLayerMetadata | Qgis::VectorProviderCapability::ReloadData; // Determine edition capabilities: create (POST on /items), // update (PUT on /items/some_id) and delete (DELETE on /items/some_id) @@ -492,7 +468,6 @@ bool QgsOapifProvider::empty() const request.setLimit( 1 ); #endif return !getFeatures( request ).nextFeature( f ); - }; bool QgsOapifProvider::setSubsetString( const QString &filter, bool updateFeatureCount ) @@ -601,8 +576,7 @@ bool QgsOapifProvider::addFeatures( QgsFeatureList &flist, Flags flags ) // If there's no feature["properties"]["id"] field in the JSON returned by the // /items request, but there's a "id" field, it means that feature["id"] // is non-numeric. Thus set the one returned by the createFeature() request - if ( !( flags & QgsFeatureSink::FastInsert ) && - !mShared->mFoundIdInProperties && idFieldIdx >= 0 ) + if ( !( flags & QgsFeatureSink::FastInsert ) && !mShared->mFoundIdInProperties && idFieldIdx >= 0 ) { f.setAttribute( idFieldIdx, id ); } @@ -612,8 +586,7 @@ bool QgsOapifProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( !( flags & QgsFeatureSink::FastInsert ) ) { QgsOapifSingleItemRequest itemRequest( mShared->mURI.uri(), mShared->appendExtraQueryParameters( mShared->mItemsUrl + QString( QStringLiteral( "/" ) + id ) ) ); - if ( itemRequest.request( /*synchronous=*/ true, /*forceRefresh=*/ true ) && - itemRequest.errorCode() == QgsBaseNetworkRequest::NoError ) + if ( itemRequest.request( /*synchronous=*/true, /*forceRefresh=*/true ) && itemRequest.errorCode() == QgsBaseNetworkRequest::NoError ) { const QgsFeature &updatedFeature = itemRequest.feature(); if ( updatedFeature.isValid() ) @@ -646,9 +619,9 @@ bool QgsOapifProvider::addFeatures( QgsFeatureList &flist, Flags flags ) if ( !( flags & QgsFeatureSink::FastInsert ) ) { // And now set the feature id from the one got from the database - QMap< QString, QgsFeatureId > map; + QMap map; for ( int idx = 0; idx < serializedFeatureList.size(); idx++ ) - map[ serializedFeatureList[idx].second ] = serializedFeatureList[idx].first.id(); + map[serializedFeatureList[idx].second] = serializedFeatureList[idx].first.id(); idIt = jsonIds.constBegin(); featureIt = flist.begin(); @@ -810,7 +783,7 @@ bool QgsOapifProvider::deleteFeatures( const QgsFeatureIds &ids ) QgsOapifDeleteFeatureRequest req( uri ); QUrl url( mShared->mItemsUrl + QString( QStringLiteral( "/" ) + jsonId ) ); - if ( ! req.sendDELETE( url ) ) + if ( !req.sendDELETE( url ) ) { pushError( tr( "Feature deletion failed: %1" ).arg( req.errorMessage() ) ); return false; @@ -941,8 +914,7 @@ static QString getEncodedQueryParam( const QString &key, const QString &value ) return query.toString( QUrl::FullyEncoded ); } -static void collectTopLevelAndNodes( const QgsExpressionNode *node, - std::vector &topAndNodes ) +static void collectTopLevelAndNodes( const QgsExpressionNode *node, std::vector &topAndNodes ) { if ( node->nodeType() == QgsExpressionNode::ntBinaryOperator ) { @@ -961,7 +933,8 @@ static void collectTopLevelAndNodes( const QgsExpressionNode *node, QString QgsOapifSharedData::compileExpressionNodeUsingPart1( const QgsExpressionNode *rootNode, QgsOapifProvider::FilterTranslationState &translationState, - QString &untranslatedPart ) const + QString &untranslatedPart +) const { std::vector topAndNodes; collectTopLevelAndNodes( rootNode, topAndNodes ); @@ -979,17 +952,13 @@ QString QgsOapifSharedData::compileExpressionNodeUsingPart1( { const auto binNode = static_cast( node ); const auto op = binNode->op(); - if ( binNode->opLeft()->nodeType() == QgsExpressionNode::ntColumnRef && - binNode->opRight()->nodeType() == QgsExpressionNode::ntLiteral ) + if ( binNode->opLeft()->nodeType() == QgsExpressionNode::ntColumnRef && binNode->opRight()->nodeType() == QgsExpressionNode::ntLiteral ) { const auto left = static_cast( binNode->opLeft() ); const auto right = static_cast( binNode->opRight() ); - if ( isDateTimeField( mFields, left->name() ) && - isDateTime( right->value() ) ) + if ( isDateTimeField( mFields, left->name() ) && isDateTime( right->value() ) ) { - if ( op == QgsExpressionNodeBinaryOperator::boGE || - op == QgsExpressionNodeBinaryOperator::boGT || - op == QgsExpressionNodeBinaryOperator::boEQ ) + if ( op == QgsExpressionNodeBinaryOperator::boGE || op == QgsExpressionNodeBinaryOperator::boGT || op == QgsExpressionNodeBinaryOperator::boEQ ) { removeMe = true; if ( !minDate.isValid() || getDateTimeValue( right->value() ) > minDate ) @@ -998,9 +967,7 @@ QString QgsOapifSharedData::compileExpressionNodeUsingPart1( minDateStr = getDateTimeValueAsString( right->value() ); } } - if ( op == QgsExpressionNodeBinaryOperator::boLE || - op == QgsExpressionNodeBinaryOperator::boLT || - op == QgsExpressionNodeBinaryOperator::boEQ ) + if ( op == QgsExpressionNodeBinaryOperator::boLE || op == QgsExpressionNodeBinaryOperator::boLT || op == QgsExpressionNodeBinaryOperator::boEQ ) { removeMe = true; if ( !maxDate.isValid() || getDateTimeValue( right->value() ) < maxDate ) @@ -1010,34 +977,28 @@ QString QgsOapifSharedData::compileExpressionNodeUsingPart1( } } } - else if ( op == QgsExpressionNodeBinaryOperator::boEQ && - mFields.indexOf( left->name() ) >= 0 ) + else if ( op == QgsExpressionNodeBinaryOperator::boEQ && mFields.indexOf( left->name() ) >= 0 ) { // Filtering based on Part 1 /rec/core/fc-filters recommendation. const auto iter = mSimpleQueryables.find( left->name() ); if ( iter != mSimpleQueryables.end() ) { - if ( iter->mType == QLatin1String( "string" ) && - right->value().userType() == QMetaType::Type::QString ) + if ( iter->mType == QLatin1String( "string" ) && right->value().userType() == QMetaType::Type::QString ) { equalityComparisons << getEncodedQueryParam( left->name(), right->value().toString() ); removeMe = true; } - else if ( ( iter->mType == QLatin1String( "integer" ) || - iter->mType == QLatin1String( "number" ) ) && - right->value().userType() == QMetaType::Type::Int ) + else if ( ( iter->mType == QLatin1String( "integer" ) || iter->mType == QLatin1String( "number" ) ) && right->value().userType() == QMetaType::Type::Int ) { equalityComparisons << getEncodedQueryParam( left->name(), QString::number( right->value().toInt() ) ); removeMe = true; } - else if ( iter->mType == QLatin1String( "number" ) && - right->value().userType() == QMetaType::Type::Double ) + else if ( iter->mType == QLatin1String( "number" ) && right->value().userType() == QMetaType::Type::Double ) { equalityComparisons << getEncodedQueryParam( left->name(), QString::number( right->value().toDouble() ) ); removeMe = true; } - else if ( iter->mType == QLatin1String( "boolean" ) && - right->value().userType() == QMetaType::Type::Bool ) + else if ( iter->mType == QLatin1String( "boolean" ) && right->value().userType() == QMetaType::Type::Bool ) { equalityComparisons << getEncodedQueryParam( left->name(), right->value().toBool() ? QLatin1String( "true" ) : QLatin1String( "false" ) ); removeMe = true; @@ -1121,10 +1082,7 @@ QString QgsOapifSharedData::compileExpressionNodeUsingPart1( return ret; } -bool QgsOapifSharedData::computeFilter( const QgsExpression &expr, - QgsOapifProvider::FilterTranslationState &translationState, - QString &serverSideParameters, - QString &clientSideFilterExpression ) const +bool QgsOapifSharedData::computeFilter( const QgsExpression &expr, QgsOapifProvider::FilterTranslationState &translationState, QString &serverSideParameters, QString &clientSideFilterExpression ) const { const auto rootNode = expr.rootNode(); if ( !rootNode ) @@ -1135,7 +1093,8 @@ bool QgsOapifSharedData::computeFilter( const QgsExpression &expr, const bool invertAxisOrientation = mSourceCrs.hasAxisInverted(); QgsOapifCql2TextExpressionCompiler compiler( mQueryables, mServerSupportsLikeBetweenIn, mServerSupportsCaseI, - mServerSupportsBasicSpatialOperators, invertAxisOrientation ); + mServerSupportsBasicSpatialOperators, invertAxisOrientation + ); QgsOapifCql2TextExpressionCompiler::Result res = compiler.compile( &expr ); if ( res == QgsOapifCql2TextExpressionCompiler::Fail ) { @@ -1216,9 +1175,8 @@ void QgsOapifSharedData::pushError( const QString &errorMsg ) const // --------------------------------- -QgsOapifFeatureDownloaderImpl::QgsOapifFeatureDownloaderImpl( QgsOapifSharedData *shared, QgsFeatureDownloader *downloader, bool requestMadeFromMainThread ): - QgsFeatureDownloaderImpl( shared, downloader ), - mShared( shared ) +QgsOapifFeatureDownloaderImpl::QgsOapifFeatureDownloaderImpl( QgsOapifSharedData *shared, QgsFeatureDownloader *downloader, bool requestMadeFromMainThread ) + : QgsFeatureDownloaderImpl( shared, downloader ), mShared( shared ) { QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS( requestMadeFromMainThread ); } @@ -1337,7 +1295,7 @@ void QgsOapifFeatureDownloaderImpl::run( bool serializeFeatures, long long maxFe rect.setYMinimum( std::max( -90.0, rect.yMinimum() ) ); rect.setXMaximum( std::min( 180.0, rect.xMaximum() ) ); rect.setYMaximum( std::min( 90.0, rect.yMaximum() ) ); - if ( rect.xMinimum() > 180.0 || rect.yMinimum() > 90.0 || rect.xMaximum() < -180.0 || rect.yMaximum() < -90.0 ) + if ( rect.xMinimum() > 180.0 || rect.yMinimum() > 90.0 || rect.xMaximum() < -180.0 || rect.yMaximum() < -90.0 ) { // completely out of range. Servers could error out url.clear(); @@ -1348,14 +1306,11 @@ void QgsOapifFeatureDownloaderImpl::run( bool serializeFeatures, long long maxFe if ( mShared->mSourceCrs.hasAxisInverted() ) rect.invert(); - if ( ! rect.isNull() ) + if ( !rect.isNull() ) { url += ( hasQueryParam ? QStringLiteral( "&" ) : QStringLiteral( "?" ) ); url += QStringLiteral( "bbox=%1,%2,%3,%4" ) - .arg( qgsDoubleToString( rect.xMinimum() ), - qgsDoubleToString( rect.yMinimum() ), - qgsDoubleToString( rect.xMaximum() ), - qgsDoubleToString( rect.yMaximum() ) ); + .arg( qgsDoubleToString( rect.xMinimum() ), qgsDoubleToString( rect.yMinimum() ), qgsDoubleToString( rect.xMaximum() ), qgsDoubleToString( rect.yMaximum() ) ); if ( mShared->mSourceCrs != QgsCoordinateReferenceSystem::fromOgcWmsCrs( QgsOapifProvider::OAPIF_PROVIDER_DEFAULT_CRS ) ) @@ -1495,8 +1450,8 @@ QList QgsOapifProviderMetadata::supportedLayerTypes() const return { Qgis::LayerType::Vector }; } -QgsOapifProviderMetadata::QgsOapifProviderMetadata(): - QgsProviderMetadata( QgsOapifProvider::OAPIF_PROVIDER_KEY, QgsOapifProvider::OAPIF_PROVIDER_DESCRIPTION ) {} +QgsOapifProviderMetadata::QgsOapifProviderMetadata() + : QgsProviderMetadata( QgsOapifProvider::OAPIF_PROVIDER_KEY, QgsOapifProvider::OAPIF_PROVIDER_DESCRIPTION ) {} QIcon QgsOapifProviderMetadata::icon() const { diff --git a/src/providers/wfs/oapif/qgsoapifprovider.h b/src/providers/wfs/oapif/qgsoapifprovider.h index 79768c91b3f6..bb613b46b297 100644 --- a/src/providers/wfs/oapif/qgsoapifprovider.h +++ b/src/providers/wfs/oapif/qgsoapifprovider.h @@ -33,11 +33,10 @@ class QgsOapifSharedData; -class QgsOapifProvider final: public QgsVectorDataProvider +class QgsOapifProvider final : public QgsVectorDataProvider { Q_OBJECT public: - static const QString OAPIF_PROVIDER_KEY; static const QString OAPIF_PROVIDER_DESCRIPTION; @@ -141,18 +140,18 @@ class QgsOapifProvider final: public QgsVectorDataProvider void computeCapabilities( const QgsOapifItemsRequest &itemsRequest ); }; -class QgsOapifProviderMetadata final: public QgsProviderMetadata +class QgsOapifProviderMetadata final : public QgsProviderMetadata { Q_OBJECT public: QgsOapifProviderMetadata(); QIcon icon() const override; QgsOapifProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override; - QList< Qgis::LayerType > supportedLayerTypes() const override; + QList supportedLayerTypes() const override; }; //! Class shared between provider and feature source -class QgsOapifSharedData final: public QObject, public QgsBackgroundCachedSharedData +class QgsOapifSharedData final : public QObject, public QgsBackgroundCachedSharedData { Q_OBJECT public: @@ -240,17 +239,11 @@ class QgsOapifSharedData final: public QObject, public QgsBackgroundCachedShared QString appendExtraQueryParameters( const QString &url ) const; private: - // Translate part of an expression to a server-side filter using Part1 features only - QString compileExpressionNodeUsingPart1( const QgsExpressionNode *node, - QgsOapifProvider::FilterTranslationState &translationState, - QString &untranslatedPart ) const; + QString compileExpressionNodeUsingPart1( const QgsExpressionNode *node, QgsOapifProvider::FilterTranslationState &translationState, QString &untranslatedPart ) const; // Translate part of an expression to a server-side filter using Part1 or Part3 - bool computeFilter( const QgsExpression &expr, - QgsOapifProvider::FilterTranslationState &translationState, - QString &serverSideParameters, - QString &clientSideFilterExpression ) const; + bool computeFilter( const QgsExpression &expr, QgsOapifProvider::FilterTranslationState &translationState, QString &serverSideParameters, QString &clientSideFilterExpression ) const; //! Log error to QgsMessageLog and raise it to the provider void pushError( const QString &errorMsg ) const override; @@ -273,7 +266,7 @@ class QgsOapifSharedData final: public QObject, public QgsBackgroundCachedShared }; -class QgsOapifFeatureDownloaderImpl final: public QObject, public QgsFeatureDownloaderImpl +class QgsOapifFeatureDownloaderImpl final : public QObject, public QgsFeatureDownloaderImpl { Q_OBJECT @@ -296,7 +289,6 @@ class QgsOapifFeatureDownloaderImpl final: public QObject, public QgsFeatureDown void createProgressTask(); private: - //! Mutable data shared between provider, feature sources and downloader. QgsOapifSharedData *mShared = nullptr; diff --git a/src/providers/wfs/oapif/qgsoapifputfeaturerequest.cpp b/src/providers/wfs/oapif/qgsoapifputfeaturerequest.cpp index 5eefc03c68df..3a782499326c 100644 --- a/src/providers/wfs/oapif/qgsoapifputfeaturerequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifputfeaturerequest.cpp @@ -22,8 +22,8 @@ using namespace nlohmann; #include "moc_qgsoapifputfeaturerequest.cpp" #include "qgsoapifprovider.h" -QgsOapifPutFeatureRequest::QgsOapifPutFeatureRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) +QgsOapifPutFeatureRequest::QgsOapifPutFeatureRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) { } diff --git a/src/providers/wfs/oapif/qgsoapifqueryablesrequest.cpp b/src/providers/wfs/oapif/qgsoapifqueryablesrequest.cpp index 3bff44929cb3..b98536452539 100644 --- a/src/providers/wfs/oapif/qgsoapifqueryablesrequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifqueryablesrequest.cpp @@ -24,8 +24,8 @@ using namespace nlohmann; #include -QgsOapifQueryablesRequest::QgsOapifQueryablesRequest( const QgsDataSourceUri &uri ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) +QgsOapifQueryablesRequest::QgsOapifQueryablesRequest( const QgsDataSourceUri &uri ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( uri.username(), uri.password(), uri.authConfigId() ), "OAPIF" ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main @@ -82,10 +82,9 @@ void QgsOapifQueryablesRequest::processReply() const json jProperties = j["properties"]; if ( jProperties.is_object() ) { - for ( const auto& [key, val] : jProperties.items() ) + for ( const auto &[key, val] : jProperties.items() ) { - if ( val.is_object() && - val.contains( "type" ) ) + if ( val.is_object() && val.contains( "type" ) ) { const json jType = val["type"]; if ( jType.is_string() ) @@ -100,23 +99,21 @@ void QgsOapifQueryablesRequest::processReply() queryable.mFormat = QString::fromStdString( jFormat.get() ); } } - mQueryables[ QString::fromStdString( key ) ] = queryable; + mQueryables[QString::fromStdString( key )] = queryable; } } - else if ( val.is_object() && - val.contains( "$ref" ) ) + else if ( val.is_object() && val.contains( "$ref" ) ) { const json jRef = val["$ref"]; if ( jRef.is_string() ) { const auto ref = jRef.get(); const char *prefix = "https://geojson.org/schema/"; - if ( ref.size() > strlen( prefix ) && - ref.compare( 0, strlen( prefix ), prefix ) == 0 ) + if ( ref.size() > strlen( prefix ) && ref.compare( 0, strlen( prefix ), prefix ) == 0 ) { Queryable queryable; queryable.mIsGeometry = true; - mQueryables[ QString::fromStdString( key ) ] = queryable; + mQueryables[QString::fromStdString( key )] = queryable; } } } diff --git a/src/providers/wfs/oapif/qgsoapifqueryablesrequest.h b/src/providers/wfs/oapif/qgsoapifqueryablesrequest.h index 55c20c164100..9684cf12230d 100644 --- a/src/providers/wfs/oapif/qgsoapifqueryablesrequest.h +++ b/src/providers/wfs/oapif/qgsoapifqueryablesrequest.h @@ -32,14 +32,14 @@ class QgsOapifQueryablesRequest : public QgsBaseNetworkRequest //! Describes a queryable parameter. struct Queryable { - //! whether the parameter is a geometry - bool mIsGeometry = false; + //! whether the parameter is a geometry + bool mIsGeometry = false; - //! type as in a JSON schema: "string", "integer", "number", etc. - QString mType; + //! type as in a JSON schema: "string", "integer", "number", etc. + QString mType; - //! format as in JSON schema. e.g "date-time" if mType="string" - QString mFormat; + //! format as in JSON schema. e.g "date-time" if mType="string" + QString mFormat; }; //! Issue the request synchronously and return queryables diff --git a/src/providers/wfs/oapif/qgsoapifsingleitemrequest.cpp b/src/providers/wfs/oapif/qgsoapifsingleitemrequest.cpp index c44abe1d0541..c02caee2380b 100644 --- a/src/providers/wfs/oapif/qgsoapifsingleitemrequest.cpp +++ b/src/providers/wfs/oapif/qgsoapifsingleitemrequest.cpp @@ -24,9 +24,8 @@ #include -QgsOapifSingleItemRequest::QgsOapifSingleItemRequest( const QgsDataSourceUri &baseUri, const QString &url ): - QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), - mUrl( url ) +QgsOapifSingleItemRequest::QgsOapifSingleItemRequest( const QgsDataSourceUri &baseUri, const QString &url ) + : QgsBaseNetworkRequest( QgsAuthorizationSettings( baseUri.username(), baseUri.password(), baseUri.authConfigId() ), tr( "OAPIF" ) ), mUrl( url ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main @@ -77,15 +76,13 @@ void QgsOapifSingleItemRequest::processReply() QgsDebugMsgLevel( QStringLiteral( "parsing item response: " ) + buffer.left( 100 ) + QStringLiteral( "[... snip ...]" ) + buffer.right( 100 ), 4 ); } - const QString vsimemFilename = QStringLiteral( "/vsimem/oaipf_%1.json" ).arg( reinterpret_cast< quintptr >( &buffer ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); - VSIFCloseL( VSIFileFromMemBuffer( vsimemFilename.toUtf8().constData(), - const_cast( reinterpret_cast( buffer.constData() ) ), - buffer.size(), - false ) ); + const QString vsimemFilename = QStringLiteral( "/vsimem/oaipf_%1.json" ).arg( reinterpret_cast( &buffer ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); + VSIFCloseL( VSIFileFromMemBuffer( vsimemFilename.toUtf8().constData(), const_cast( reinterpret_cast( buffer.constData() ) ), buffer.size(), false ) ); QgsProviderRegistry *pReg = QgsProviderRegistry::instance(); const QgsDataProvider::ProviderOptions providerOptions; auto vectorProvider = std::unique_ptr( - qobject_cast< QgsVectorDataProvider * >( pReg->createProvider( "ogr", vsimemFilename, providerOptions ) ) ); + qobject_cast( pReg->createProvider( "ogr", vsimemFilename, providerOptions ) ) + ); if ( !vectorProvider || !vectorProvider->isValid() ) { VSIUnlink( vsimemFilename.toUtf8().constData() ); diff --git a/src/providers/wfs/oapif/qgsoapifutils.cpp b/src/providers/wfs/oapif/qgsoapifutils.cpp index 84a174b4f64a..3983813acef8 100644 --- a/src/providers/wfs/oapif/qgsoapifutils.cpp +++ b/src/providers/wfs/oapif/qgsoapifutils.cpp @@ -27,9 +27,7 @@ std::vector QgsOAPIFJson::parseLinks( const json &jParent ) { for ( const auto &jLink : jLinks ) { - if ( jLink.is_object() && - jLink.contains( "href" ) && - jLink.contains( "rel" ) ) + if ( jLink.is_object() && jLink.contains( "href" ) && jLink.contains( "rel" ) ) { const auto href = jLink["href"]; const auto rel = jLink["rel"]; @@ -71,9 +69,7 @@ std::vector QgsOAPIFJson::parseLinks( const json &jParent ) return links; } -QString QgsOAPIFJson::findLink( const std::vector &links, - const QString &rel, - const QStringList &preferableTypes ) +QString QgsOAPIFJson::findLink( const std::vector &links, const QString &rel, const QStringList &preferableTypes ) { QString resultHref; int resultPriority = std::numeric_limits::max(); diff --git a/src/providers/wfs/oapif/qgsoapifutils.h b/src/providers/wfs/oapif/qgsoapifutils.h index f1a904dc23dd..d2a2141270ee 100644 --- a/src/providers/wfs/oapif/qgsoapifutils.h +++ b/src/providers/wfs/oapif/qgsoapifutils.h @@ -31,11 +31,11 @@ class QgsOAPIFJson //! A OAPIF Link struct Link { - QString href; - QString rel; - QString type; - QString title; - qint64 length = -1; + QString href; + QString rel; + QString type; + QString title; + qint64 length = -1; }; //! Parses the "link" property of jParent diff --git a/src/providers/wfs/qgsauthorizationsettings.h b/src/providers/wfs/qgsauthorizationsettings.h index 45d63387de97..a0343381fd7f 100644 --- a/src/providers/wfs/qgsauthorizationsettings.h +++ b/src/providers/wfs/qgsauthorizationsettings.h @@ -26,44 +26,44 @@ // TODO: merge with QgsWmsAuthorization? struct QgsAuthorizationSettings { - QgsAuthorizationSettings( const QString &userName = QString(), const QString &password = QString(), const QString &authcfg = QString() ) - : mUserName( userName ) - , mPassword( password ) - , mAuthCfg( authcfg ) - {} + QgsAuthorizationSettings( const QString &userName = QString(), const QString &password = QString(), const QString &authcfg = QString() ) + : mUserName( userName ) + , mPassword( password ) + , mAuthCfg( authcfg ) + {} - //! update authorization for request - bool setAuthorization( QNetworkRequest &request ) const - { - if ( !mAuthCfg.isEmpty() ) // must be non-empty value + //! update authorization for request + bool setAuthorization( QNetworkRequest &request ) const { - return QgsApplication::authManager()->updateNetworkRequest( request, mAuthCfg ); + if ( !mAuthCfg.isEmpty() ) // must be non-empty value + { + return QgsApplication::authManager()->updateNetworkRequest( request, mAuthCfg ); + } + else if ( !mUserName.isNull() || !mPassword.isNull() ) // allow empty values + { + request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( mUserName, mPassword ).toLatin1().toBase64() ); + } + return true; } - else if ( !mUserName.isNull() || !mPassword.isNull() ) // allow empty values - { - request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( mUserName, mPassword ).toLatin1().toBase64() ); - } - return true; - } - //! update authorization for reply - bool setAuthorizationReply( QNetworkReply *reply ) const - { - if ( !mAuthCfg.isEmpty() ) + //! update authorization for reply + bool setAuthorizationReply( QNetworkReply *reply ) const { - return QgsApplication::authManager()->updateNetworkReply( reply, mAuthCfg ); + if ( !mAuthCfg.isEmpty() ) + { + return QgsApplication::authManager()->updateNetworkReply( reply, mAuthCfg ); + } + return true; } - return true; - } - //! Username for basic http authentication - QString mUserName; + //! Username for basic http authentication + QString mUserName; - //! Password for basic http authentication - QString mPassword; + //! Password for basic http authentication + QString mPassword; - //! Authentication configuration ID - QString mAuthCfg; + //! Authentication configuration ID + QString mAuthCfg; }; #endif // QGSAUTHORIZATIONSETTINGS_H diff --git a/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp b/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp index 27e954a9f4ec..8194c965ff6b 100644 --- a/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp +++ b/src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp @@ -48,11 +48,9 @@ const QString QgsBackgroundCachedFeatureIteratorConstants::FIELD_MD5( QStringLit // QgsFeatureDownloaderProgressTask::QgsFeatureDownloaderProgressTask( const QString &description, long long totalCount ) - : QgsTask( description, - QgsTask::CanCancel | QgsTask::CancelWithoutPrompt | QgsTask::Silent ) + : QgsTask( description, QgsTask::CanCancel | QgsTask::CancelWithoutPrompt | QgsTask::Silent ) , mTotalCount( totalCount ) { - } bool QgsFeatureDownloaderProgressTask::run() @@ -86,17 +84,17 @@ void QgsFeatureDownloaderProgressTask::finalize() void QgsFeatureDownloaderProgressTask::setDownloaded( long long count ) { - setProgress( static_cast< double >( count ) / static_cast< double >( mTotalCount ) * 100 ); + setProgress( static_cast( count ) / static_cast( mTotalCount ) * 100 ); } - // ------------------------- -QgsFeatureDownloaderImpl::QgsFeatureDownloaderImpl( QgsBackgroundCachedSharedData *shared, QgsFeatureDownloader *downloader ): mSharedBase( shared ), mDownloader( downloader ) +QgsFeatureDownloaderImpl::QgsFeatureDownloaderImpl( QgsBackgroundCachedSharedData *shared, QgsFeatureDownloader *downloader ) + : mSharedBase( shared ), mDownloader( downloader ) { // Needed because used by a signal - qRegisterMetaType< QVector >( "QVector" ); + qRegisterMetaType>( "QVector" ); } QgsFeatureDownloaderImpl::~QgsFeatureDownloaderImpl() @@ -161,10 +159,7 @@ void QgsFeatureDownloaderImpl::createProgressTask( long long numberMatched ) QgsApplication::taskManager()->addTask( mProgressTask ); } -void QgsFeatureDownloaderImpl::endOfRun( bool serializeFeatures, - bool success, int totalDownloadedFeatureCount, - bool truncatedResponse, bool interrupted, - const QString &errorMessage ) +void QgsFeatureDownloaderImpl::endOfRun( bool serializeFeatures, bool success, int totalDownloadedFeatureCount, bool truncatedResponse, bool interrupted, const QString &errorMessage ) { { QMutexLocker locker( &mMutexCreateProgressTask ); @@ -265,7 +260,8 @@ void QgsThreadedFeatureDownloader::run() QgsBackgroundCachedFeatureIterator::QgsBackgroundCachedFeatureIterator( QgsBackgroundCachedFeatureSource *source, bool ownSource, std::shared_ptr shared, - const QgsFeatureRequest &request ) + const QgsFeatureRequest &request +) : QgsAbstractFeatureIteratorFromSource( source, ownSource, request ) , mShared( shared ) , mCachedFeaturesIter( mCachedFeatures.begin() ) @@ -327,9 +323,7 @@ QgsBackgroundCachedFeatureIterator::QgsBackgroundCachedFeatureIterator( // are requested by Fid and we already have them in cache, no need to // download anything. auto cacheDataProvider = mShared->cacheDataProvider(); - if ( cacheDataProvider && - ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Fid || - ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Fids && mRequest.filterFids().size() < 100000 ) ) ) + if ( cacheDataProvider && ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Fid || ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Fids && mRequest.filterFids().size() < 100000 ) ) ) { QgsFeatureRequest requestCache; QgsFeatureIds qgisIds; @@ -361,9 +355,7 @@ QgsBackgroundCachedFeatureIterator::QgsBackgroundCachedFeatureIterator( } } - int genCounter = ( mShared->isRestrictedToRequestBBOX() && !mFilterRect.isNull() ) ? - mShared->registerToCache( this, static_cast( mRequest.limit() ), mFilterRect, serverExpression ) : - mShared->registerToCache( this, static_cast( mRequest.limit() ), QgsRectangle(), serverExpression ); + int genCounter = ( mShared->isRestrictedToRequestBBOX() && !mFilterRect.isNull() ) ? mShared->registerToCache( this, static_cast( mRequest.limit() ), mFilterRect, serverExpression ) : mShared->registerToCache( this, static_cast( mRequest.limit() ), QgsRectangle(), serverExpression ); // Reload cacheDataProvider as registerToCache() has likely refreshed it cacheDataProvider = mShared->cacheDataProvider(); mDownloadFinished = genCounter < 0; @@ -372,7 +364,7 @@ QgsBackgroundCachedFeatureIterator::QgsBackgroundCachedFeatureIterator( QgsDebugMsgLevel( QStringLiteral( "QgsBackgroundCachedFeatureIterator::constructor(): genCounter=%1 " ).arg( genCounter ), 4 ); - QgsFeatureRequest requestCache = initRequestCache( genCounter ) ; + QgsFeatureRequest requestCache = initRequestCache( genCounter ); fillRequestCache( requestCache ); mCacheIterator = cacheDataProvider->getFeatures( requestCache ); } @@ -384,8 +376,7 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::initRequestCache( int genC const QgsFields fields = mShared->fields(); auto cacheDataProvider = mShared->cacheDataProvider(); - if ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Fid || - mRequest.filterType() == Qgis::FeatureRequestFilterType::Fids ) + if ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Fid || mRequest.filterType() == Qgis::FeatureRequestFilterType::Fids ) { QgsFeatureIds qgisIds; if ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Fid ) @@ -419,7 +410,7 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::initRequestCache( int genC { // Transfer and transform context requestCache.setFilterExpression( mRequest.filterExpression()->expression() ); - QgsExpressionContext ctx { *mRequest.expressionContext( ) }; + QgsExpressionContext ctx { *mRequest.expressionContext() }; QgsExpressionContextScope *scope { ctx.activeScopeForVariable( QgsExpressionContext::EXPR_FIELDS ) }; if ( scope ) { @@ -441,9 +432,7 @@ void QgsBackgroundCachedFeatureIterator::fillRequestCache( QgsFeatureRequest req { requestCache.setFilterRect( mFilterRect ); - if ( ( !( mRequest.flags() & Qgis::FeatureRequestFlag::NoGeometry ) || !mFilterRect.isNull() ) || - ( mRequest.spatialFilterType() == Qgis::SpatialFilterType::DistanceWithin ) || - ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Expression && mRequest.filterExpression()->needsGeometry() ) ) + if ( ( !( mRequest.flags() & Qgis::FeatureRequestFlag::NoGeometry ) || !mFilterRect.isNull() ) || ( mRequest.spatialFilterType() == Qgis::SpatialFilterType::DistanceWithin ) || ( mRequest.filterType() == Qgis::FeatureRequestFilterType::Expression && mRequest.filterExpression()->needsGeometry() ) ) { mFetchGeometry = true; } @@ -478,7 +467,7 @@ void QgsBackgroundCachedFeatureIterator::fillRequestCache( QgsFeatureRequest req if ( cacheFieldIdx >= 0 && !cacheSubSet.contains( cacheFieldIdx ) ) cacheSubSet.append( cacheFieldIdx ); - if ( wfsFieldIdx >= 0 && !mSubSetAttributes.contains( wfsFieldIdx ) ) + if ( wfsFieldIdx >= 0 && !mSubSetAttributes.contains( wfsFieldIdx ) ) mSubSetAttributes.append( wfsFieldIdx ); } } @@ -538,14 +527,11 @@ void QgsBackgroundCachedFeatureIterator::connectSignals( QgsFeatureDownloader *d // We want to run the slot for that signal in the same thread as the sender // so as to avoid the list of features to accumulate without control in // memory - connect( downloader, static_cast )>( &QgsFeatureDownloader::featureReceived ), - this, &QgsBackgroundCachedFeatureIterator::featureReceivedSynchronous, Qt::DirectConnection ); + connect( downloader, static_cast )>( &QgsFeatureDownloader::featureReceived ), this, &QgsBackgroundCachedFeatureIterator::featureReceivedSynchronous, Qt::DirectConnection ); - connect( downloader, &QgsFeatureDownloader::endOfDownload, - this, &QgsBackgroundCachedFeatureIterator::endOfDownloadSynchronous, Qt::DirectConnection ); + connect( downloader, &QgsFeatureDownloader::endOfDownload, this, &QgsBackgroundCachedFeatureIterator::endOfDownloadSynchronous, Qt::DirectConnection ); - connect( downloader, &QgsFeatureDownloader::resumeMainThread, - this, &QgsBackgroundCachedFeatureIterator::resumeMainThreadSynchronous, Qt::DirectConnection ); + connect( downloader, &QgsFeatureDownloader::resumeMainThread, this, &QgsBackgroundCachedFeatureIterator::resumeMainThreadSynchronous, Qt::DirectConnection ); } void QgsBackgroundCachedFeatureIterator::endOfDownloadSynchronous( bool ) @@ -591,8 +577,8 @@ void QgsBackgroundCachedFeatureIterator::featureReceivedSynchronous( const QVect } if ( !mWriterFile && mWriterByteArray.size() > mWriteTransferThreshold ) { - const QString thisStr = QStringLiteral( "%1" ).arg( reinterpret_cast< quintptr >( this ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); - ++ mCounter; + const QString thisStr = QStringLiteral( "%1" ).arg( reinterpret_cast( this ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); + ++mCounter; mWriterFilename = QDir( mShared->acquireCacheDirectory() ).filePath( QStringLiteral( "iterator_%1_%2.bin" ).arg( thisStr ).arg( mCounter ) ); QgsDebugMsgLevel( QStringLiteral( "Transferring feature iterator cache to %1" ).arg( mWriterFilename ), 4 ); mWriterFile.reset( new QFile( mWriterFilename ) ); @@ -675,8 +661,7 @@ bool QgsBackgroundCachedFeatureIterator::fetchFeature( QgsFeature &f ) } QgsGeometry constGeom = cachedFeature.geometry(); - if ( !mFilterRect.isNull() && - ( constGeom.isNull() || !constGeom.intersects( mFilterRect ) ) ) + if ( !mFilterRect.isNull() && ( constGeom.isNull() || !constGeom.intersects( mFilterRect ) ) ) { continue; } @@ -776,8 +761,7 @@ bool QgsBackgroundCachedFeatureIterator::fetchFeature( QgsFeature &f ) } QgsGeometry constGeom = feat.geometry(); - if ( !mFilterRect.isNull() && - ( constGeom.isNull() || !constGeom.intersects( mFilterRect ) ) ) + if ( !mFilterRect.isNull() && ( constGeom.isNull() || !constGeom.intersects( mFilterRect ) ) ) { continue; } @@ -826,9 +810,7 @@ bool QgsBackgroundCachedFeatureIterator::fetchFeature( QgsFeature &f ) break; } const int delayCheckInterruption = 50; - const int timeout = ( requestTimeout > 0 ) ? - std::min( requestTimeout - ( int ) timeRequestTimeout.elapsed(), delayCheckInterruption ) : - delayCheckInterruption; + const int timeout = ( requestTimeout > 0 ) ? std::min( requestTimeout - ( int ) timeRequestTimeout.elapsed(), delayCheckInterruption ) : delayCheckInterruption; if ( timeout < 0 ) { mTimeoutOrInterruptionOccurred = true; @@ -848,7 +830,6 @@ bool QgsBackgroundCachedFeatureIterator::fetchFeature( QgsFeature &f ) break; } } - } } @@ -925,8 +906,7 @@ void QgsBackgroundCachedFeatureIterator::copyFeature( const QgsFeature &srcFeatu const QgsFields &fields = mShared->fields(); dstFeature.initAttributes( fields.size() ); - auto setAttr = [ & ]( const int i ) - { + auto setAttr = [&]( const int i ) { int idx = srcFeature.fields().indexFromName( srcIsCache ? mShared->getSpatialiteFieldNameFromUserVisibleName( fields.at( i ).name() ) : fields.at( i ).name() ); if ( idx >= 0 ) { @@ -970,7 +950,8 @@ void QgsBackgroundCachedFeatureIterator::copyFeature( const QgsFeature &srcFeatu // ------------------------- QgsBackgroundCachedFeatureSource::QgsBackgroundCachedFeatureSource( - std::shared_ptr shared ) + std::shared_ptr shared +) : mShared( shared ) { } diff --git a/src/providers/wfs/qgsbackgroundcachedfeatureiterator.h b/src/providers/wfs/qgsbackgroundcachedfeatureiterator.h index a12217076486..b2443623e50c 100644 --- a/src/providers/wfs/qgsbackgroundcachedfeatureiterator.h +++ b/src/providers/wfs/qgsbackgroundcachedfeatureiterator.h @@ -33,11 +33,11 @@ class QPushButton; struct QgsBackgroundCachedFeatureIteratorConstants { - // Special fields of the cache - static const QString FIELD_GEN_COUNTER; - static const QString FIELD_UNIQUE_ID; - static const QString FIELD_HEXWKB_GEOM; - static const QString FIELD_MD5; + // Special fields of the cache + static const QString FIELD_GEN_COUNTER; + static const QString FIELD_UNIQUE_ID; + static const QString FIELD_HEXWKB_GEOM; + static const QString FIELD_MD5; }; //! Type that associate a QgsFeature to a (hopefully) unique id across requests @@ -50,7 +50,6 @@ class QgsFeatureDownloaderProgressTask : public QgsTask Q_OBJECT public: - QgsFeatureDownloaderProgressTask( const QString &description, long long totalCount ); bool run() override; @@ -67,12 +66,10 @@ class QgsFeatureDownloaderProgressTask : public QgsTask void canceled(); private: - long long mTotalCount = 0; QWaitCondition mNotFinishedWaitCondition; QMutex mNotFinishedMutex; bool mAlreadyFinished = false; - }; class QgsBackgroundCachedSharedData; @@ -154,10 +151,7 @@ class QgsFeatureDownloaderImpl void setStopFlag(); - void endOfRun( bool serializeFeatures, - bool success, int totalDownloadedFeatureCount, - bool truncatedResponse, bool interrupted, - const QString &errorMessage ); + void endOfRun( bool serializeFeatures, bool success, int totalDownloadedFeatureCount, bool truncatedResponse, bool interrupted, const QString &errorMessage ); void connectSignals( QObject *obj, bool requestMadeFromMainThread ); @@ -168,80 +162,80 @@ class QgsFeatureDownloaderImpl }; // Sorry for ugliness. Due to QgsFeatureDownloaderImpl that cannot derive from QObject -#define QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS_BASE(requestMadeFromMainThread) \ - do { \ - if ( requestMadeFromMainThread ) \ - { \ - auto resumeMainThread = [this]() \ - { \ - emitResumeMainThread(); \ - }; \ - QObject::connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::authRequestOccurred, \ - this, resumeMainThread, Qt::DirectConnection ); \ - QObject::connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::proxyAuthenticationRequired, \ - this, resumeMainThread, Qt::DirectConnection ); \ - } \ - } while(false) +#define QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS_BASE( requestMadeFromMainThread ) \ + do \ + { \ + if ( requestMadeFromMainThread ) \ + { \ + auto resumeMainThread = [this]() { \ + emitResumeMainThread(); \ + }; \ + QObject::connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::authRequestOccurred, this, resumeMainThread, Qt::DirectConnection ); \ + QObject::connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::proxyAuthenticationRequired, this, resumeMainThread, Qt::DirectConnection ); \ + } \ + } while ( false ) #ifndef QT_NO_SSL -#define QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS(requestMadeFromMainThread) \ - do { \ - QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS_BASE(requestMadeFromMainThread); \ - if ( requestMadeFromMainThread ) \ - { \ - auto resumeMainThread = [this]() \ - { \ - emitResumeMainThread(); \ - }; \ - QObject::connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::sslErrorsOccurred, \ - this, resumeMainThread, Qt::DirectConnection ); \ - } \ - } while(false) +#define QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS( requestMadeFromMainThread ) \ + do \ + { \ + QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS_BASE( requestMadeFromMainThread ); \ + if ( requestMadeFromMainThread ) \ + { \ + auto resumeMainThread = [this]() { \ + emitResumeMainThread(); \ + }; \ + QObject::connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::sslErrorsOccurred, this, resumeMainThread, Qt::DirectConnection ); \ + } \ + } while ( false ) #else -#define QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS(requestMadeFromMainThread) \ - QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS_BASE(requestMadeFromMainThread) +#define QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS( requestMadeFromMainThread ) \ + QGS_FEATURE_DOWNLOADER_IMPL_CONNECT_SIGNALS_BASE( requestMadeFromMainThread ) #endif // Sorry for ugliness. Due to QgsFeatureDownloaderImpl that cannot derive from QObject -#define CONNECT_PROGRESS_TASK(actual_downloader_impl_class) do { \ +#define CONNECT_PROGRESS_TASK( actual_downloader_impl_class ) \ + do \ + { \ connect( mProgressTask, &QgsFeatureDownloaderProgressTask::canceled, this, &actual_downloader_impl_class::setStopFlag, Qt::DirectConnection ); \ - connect( mProgressTask, &QgsFeatureDownloaderProgressTask::canceled, this, &actual_downloader_impl_class::stop ); \ - \ - /* Make sure the progress task has not been deleted by another thread */ \ - if ( mProgressTask ) \ - { \ - connect( this, &actual_downloader_impl_class::updateProgress, mProgressTask, &QgsFeatureDownloaderProgressTask::setDownloaded ); \ - } \ - } while(0) + connect( mProgressTask, &QgsFeatureDownloaderProgressTask::canceled, this, &actual_downloader_impl_class::stop ); \ + \ + /* Make sure the progress task has not been deleted by another thread */ \ + if ( mProgressTask ) \ + { \ + connect( this, &actual_downloader_impl_class::updateProgress, mProgressTask, &QgsFeatureDownloaderProgressTask::setDownloaded ); \ + } \ + } while ( 0 ) // Sorry for ugliness. Due to QgsFeatureDownloaderImpl that cannot derive from QObject -#define DEFINE_FEATURE_DOWNLOADER_IMPL_SLOTS \ - protected: \ - void emitDoStop() override { emit doStop(); } \ +#define DEFINE_FEATURE_DOWNLOADER_IMPL_SLOTS \ +protected: \ + void emitDoStop() override { emit doStop(); } \ void setStopFlag() { QgsFeatureDownloaderImpl::setStopFlag(); } \ void stop() { QgsFeatureDownloaderImpl::stop(); } -#define CREATE_PROGRESS_TASK(actual_downloader_impl_class) \ - do { \ - /* This is a bit tricky. We want the createProgressTask() */ \ - /* method to be run into the GUI thread */ \ - mTimer = new QTimer(); \ - mTimer->setSingleShot( true ); \ - \ - /* Direct connection, since we want createProgressTask() */ \ - /* to be invoked from the same thread as timer, and not in the */ \ - /* thread of this */ \ - connect( mTimer, &QTimer::timeout, this, &actual_downloader_impl_class::createProgressTask, Qt::DirectConnection ); \ - \ - mTimer->moveToThread( qApp->thread() ); \ - QMetaObject::invokeMethod( mTimer, "start", Qt::QueuedConnection ); \ - } while (0) +#define CREATE_PROGRESS_TASK( actual_downloader_impl_class ) \ + do \ + { \ + /* This is a bit tricky. We want the createProgressTask() */ \ + /* method to be run into the GUI thread */ \ + mTimer = new QTimer(); \ + mTimer->setSingleShot( true ); \ + \ + /* Direct connection, since we want createProgressTask() */ \ + /* to be invoked from the same thread as timer, and not in the */ \ + /* thread of this */ \ + connect( mTimer, &QTimer::timeout, this, &actual_downloader_impl_class::createProgressTask, Qt::DirectConnection ); \ + \ + mTimer->moveToThread( qApp->thread() ); \ + QMetaObject::invokeMethod( mTimer, "start", Qt::QueuedConnection ); \ + } while ( 0 ) /** * Interface of the downloader, typically called by QgsThreadedFeatureDownloader. * The real work is done by the implementation passed to setImpl(). */ -class QgsFeatureDownloader: public QObject +class QgsFeatureDownloader : public QObject { Q_OBJECT public: @@ -284,7 +278,7 @@ class QgsFeatureDownloader: public QObject class QgsBackgroundCachedSharedData; //! Downloader thread -class QgsThreadedFeatureDownloader: public QThread +class QgsThreadedFeatureDownloader : public QThread { Q_OBJECT public: @@ -305,7 +299,7 @@ class QgsThreadedFeatureDownloader: public QThread void run() override; private: - QgsBackgroundCachedSharedData *mShared; //!< Mutable data shared between provider and feature sources + QgsBackgroundCachedSharedData *mShared; //!< Mutable data shared between provider and feature sources QgsFeatureDownloader *mDownloader = nullptr; QWaitCondition mWaitCond; QMutex mWaitMutex; @@ -321,15 +315,16 @@ class QgsBackgroundCachedFeatureSource; * already cached. It will actually start by consuming cache features for * initial feedback, and then process the live downloaded features. */ -class QgsBackgroundCachedFeatureIterator final: public QObject, - public QgsAbstractFeatureIteratorFromSource +class QgsBackgroundCachedFeatureIterator final : public QObject, + public QgsAbstractFeatureIteratorFromSource { Q_OBJECT public: explicit QgsBackgroundCachedFeatureIterator( QgsBackgroundCachedFeatureSource *source, bool ownSource, std::shared_ptr shared, - const QgsFeatureRequest &request ); + const QgsFeatureRequest &request + ); ~QgsBackgroundCachedFeatureIterator() override; bool rewind() override; @@ -347,8 +342,7 @@ class QgsBackgroundCachedFeatureIterator final: public QObject, void resumeMainThreadSynchronous(); private: - - std::shared_ptr mShared; //!< Mutable data shared between provider and feature sources + std::shared_ptr mShared; //!< Mutable data shared between provider and feature sources //! Subset of attributes (relatives to mShared->mFields) to fetch. Only valid if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) QgsAttributeList mSubSetAttributes; @@ -374,7 +368,7 @@ class QgsBackgroundCachedFeatureIterator final: public QObject, QByteArray mWriterByteArray; QString mWriterFilename; std::unique_ptr mWriterFile; - std::unique_ptr mWriterStream ; + std::unique_ptr mWriterStream; QByteArray mReaderByteArray; QString mReaderFilename; @@ -385,7 +379,7 @@ class QgsBackgroundCachedFeatureIterator final: public QObject, QgsCoordinateTransform mTransform; QgsRectangle mFilterRect; QgsGeometry mDistanceWithinGeom; - std::unique_ptr< QgsGeometryEngine > mDistanceWithinEngine; + std::unique_ptr mDistanceWithinEngine; //! typically to save a FilterFid/FilterFids request that will not be captured by mRequest QgsFeatureRequest mAdditionalRequest; @@ -408,7 +402,7 @@ class QgsBackgroundCachedFeatureIterator final: public QObject, //! Feature source -class QgsBackgroundCachedFeatureSource final: public QgsAbstractFeatureSource +class QgsBackgroundCachedFeatureSource final : public QgsAbstractFeatureSource { public: explicit QgsBackgroundCachedFeatureSource( std::shared_ptr shared ); @@ -416,8 +410,7 @@ class QgsBackgroundCachedFeatureSource final: public QgsAbstractFeatureSource QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) override; private: - - std::shared_ptr mShared; //!< Mutable data shared between provider and feature sources + std::shared_ptr mShared; //!< Mutable data shared between provider and feature sources }; #endif // QGSBACKGROUNDCACHEDFEATUREITERATOR_H diff --git a/src/providers/wfs/qgsbackgroundcachedshareddata.cpp b/src/providers/wfs/qgsbackgroundcachedshareddata.cpp index 8bcbef98a21a..0c7f61b1b3d3 100644 --- a/src/providers/wfs/qgsbackgroundcachedshareddata.cpp +++ b/src/providers/wfs/qgsbackgroundcachedshareddata.cpp @@ -37,9 +37,9 @@ #include QgsBackgroundCachedSharedData::QgsBackgroundCachedSharedData( - const QString &providerName, const QString &componentTranslated ): - mCacheDirectoryManager( QgsCacheDirectoryManager::singleton( ( providerName ) ) ), - mComponentTranslated( componentTranslated ) + const QString &providerName, const QString &componentTranslated +) + : mCacheDirectoryManager( QgsCacheDirectoryManager::singleton( ( providerName ) ) ), mComponentTranslated( componentTranslated ) { } @@ -100,7 +100,7 @@ void QgsBackgroundCachedSharedData::invalidateCache() QMutexLocker locker( &mMutex ); -// to prevent deadlock when waiting the end of the downloader thread that will try to take the mutex in serializeFeatures() + // to prevent deadlock when waiting the end of the downloader thread that will try to take the mutex in serializeFeatures() mMutex.unlock(); mDownloader.reset(); mMutex.lock(); @@ -212,8 +212,7 @@ bool QgsBackgroundCachedSharedData::createCache() if ( mDistinctSelect ) cacheFields.append( QgsField( QgsBackgroundCachedFeatureIteratorConstants::FIELD_MD5, QMetaType::Type::QString, QStringLiteral( "string" ) ) ); - const auto logMessageWithReason = [this]( const QString & reason ) - { + const auto logMessageWithReason = [this]( const QString &reason ) { QgsMessageLog::logMessage( QStringLiteral( "%1: %2" ).arg( QObject::tr( "Cannot create temporary SpatiaLite cache." ) ).arg( reason ), mComponentTranslated ); }; @@ -226,7 +225,7 @@ bool QgsBackgroundCachedSharedData::createCache() logMessageWithReason( QStringLiteral( "GDAL SQLite driver not available" ) ); return false; } - const QString vsimemFilename = QStringLiteral( "/vsimem/qgis_cache_template_%1/features.sqlite" ).arg( reinterpret_cast< quintptr >( this ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); + const QString vsimemFilename = QStringLiteral( "/vsimem/qgis_cache_template_%1/features.sqlite" ).arg( reinterpret_cast( this ), QT_POINTER_SIZE * 2, 16, QLatin1Char( '0' ) ); mCacheTablename = CPLGetBasename( vsimemFilename.toUtf8().constData() ); VSIUnlink( vsimemFilename.toUtf8().constData() ); const char *apszOptions[] = { "INIT_WITH_EPSG=NO", "SPATIALITE=YES", nullptr }; @@ -268,11 +267,11 @@ bool QgsBackgroundCachedSharedData::createCache() { QString sql; - ( void )sqlite3_exec( database.get(), "PRAGMA synchronous=OFF", nullptr, nullptr, nullptr ); + ( void ) sqlite3_exec( database.get(), "PRAGMA synchronous=OFF", nullptr, nullptr, nullptr ); // WAL is needed to avoid reader to block writers - ( void )sqlite3_exec( database.get(), "PRAGMA journal_mode=WAL", nullptr, nullptr, nullptr ); + ( void ) sqlite3_exec( database.get(), "PRAGMA journal_mode=WAL", nullptr, nullptr, nullptr ); - ( void )sqlite3_exec( database.get(), "BEGIN", nullptr, nullptr, nullptr ); + ( void ) sqlite3_exec( database.get(), "BEGIN", nullptr, nullptr, nullptr ); mCacheTablename = QStringLiteral( "features" ); sql = QStringLiteral( "CREATE TABLE %1 (%2 INTEGER PRIMARY KEY" ).arg( mCacheTablename, fidName ); @@ -296,7 +295,8 @@ bool QgsBackgroundCachedSharedData::createCache() if ( rc != SQLITE_OK ) { QgsDebugError( QStringLiteral( "%1 failed" ).arg( sql ) ); - if ( failedSql.isEmpty() ) failedSql = sql; + if ( failedSql.isEmpty() ) + failedSql = sql; ret = false; } @@ -305,7 +305,8 @@ bool QgsBackgroundCachedSharedData::createCache() if ( rc != SQLITE_OK ) { QgsDebugError( QStringLiteral( "%1 failed" ).arg( sql ) ); - if ( failedSql.isEmpty() ) failedSql = sql; + if ( failedSql.isEmpty() ) + failedSql = sql; ret = false; } @@ -314,7 +315,8 @@ bool QgsBackgroundCachedSharedData::createCache() if ( rc != SQLITE_OK ) { QgsDebugError( QStringLiteral( "%1 failed" ).arg( sql ) ); - if ( failedSql.isEmpty() ) failedSql = sql; + if ( failedSql.isEmpty() ) + failedSql = sql; ret = false; } @@ -326,7 +328,8 @@ bool QgsBackgroundCachedSharedData::createCache() if ( rc != SQLITE_OK ) { QgsDebugError( QStringLiteral( "%1 failed" ).arg( sql ) ); - if ( failedSql.isEmpty() ) failedSql = sql; + if ( failedSql.isEmpty() ) + failedSql = sql; ret = false; } @@ -337,12 +340,13 @@ bool QgsBackgroundCachedSharedData::createCache() if ( rc != SQLITE_OK ) { QgsDebugError( QStringLiteral( "%1 failed" ).arg( sql ) ); - if ( failedSql.isEmpty() ) failedSql = sql; + if ( failedSql.isEmpty() ) + failedSql = sql; ret = false; } } - ( void )sqlite3_exec( database.get(), "COMMIT", nullptr, nullptr, nullptr ); + ( void ) sqlite3_exec( database.get(), "COMMIT", nullptr, nullptr, nullptr ); } else { @@ -366,7 +370,8 @@ bool QgsBackgroundCachedSharedData::createCache() QgsDataProvider::ProviderOptions providerOptions; mCacheDataProvider.reset( dynamic_cast( QgsProviderRegistry::instance()->createProvider( - QStringLiteral( "spatialite" ), dsURI.uri(), providerOptions ) ) ); + QStringLiteral( "spatialite" ), dsURI.uri(), providerOptions + ) ) ); if ( mCacheDataProvider && !mCacheDataProvider->isValid() ) { mCacheDataProvider.reset(); @@ -448,8 +453,7 @@ int QgsBackgroundCachedSharedData::registerToCache( QgsBackgroundCachedFeatureIt // If the requested bbox is inside an already cached rect that didn't // hit the download limit, then we can reuse the cached features without // issuing a new request. - if ( mRegions[id].geometry().boundingBox().contains( rect ) && - !mRegions[id].attributes().value( 0 ).toBool() ) + if ( mRegions[id].geometry().boundingBox().contains( rect ) && !mRegions[id].attributes().value( 0 ).toBool() ) { QgsDebugMsgLevel( QStringLiteral( "Cached features already cover this area of interest" ), 4 ); newDownloadNeeded = false; @@ -459,8 +463,7 @@ int QgsBackgroundCachedSharedData::registerToCache( QgsBackgroundCachedFeatureIt // On the other hand, if the requested bbox is inside an already cached rect, // that hit the download limit, our larger bbox will hit it too, so no need // to re-issue a new request either. - if ( rect.contains( mRegions[id].geometry().boundingBox() ) && - mRegions[id].attributes().value( 0 ).toBool() ) + if ( rect.contains( mRegions[id].geometry().boundingBox() ) && mRegions[id].attributes().value( 0 ).toBool() ) { QgsDebugMsgLevel( QStringLiteral( "Current request is larger than a smaller request that hit the download limit, so no server download needed." ), 4 ); newDownloadNeeded = false; @@ -505,7 +508,7 @@ int QgsBackgroundCachedSharedData::registerToCache( QgsBackgroundCachedFeatureIt // Under the mutex to ensure that we will not miss features iterator->connectSignals( mDownloader->downloader() ); - return mGenCounter ++; + return mGenCounter++; } int QgsBackgroundCachedSharedData::getUpdatedCounter() @@ -513,7 +516,7 @@ int QgsBackgroundCachedSharedData::getUpdatedCounter() QMutexLocker locker( &mMutex ); if ( mDownloadFinished ) return mGenCounter; - return mGenCounter ++; + return mGenCounter++; } void QgsBackgroundCachedSharedData::serializeFeatures( QVector &featureList ) @@ -629,7 +632,7 @@ void QgsBackgroundCachedSharedData::serializeFeatures( QVector %2" ).arg( sql ).arg( errorMsg ), mComponentTranslated ); } - sql = qgs_sqlite3_mprintf( "UPDATE id_cache SET dbId = %lld WHERE uniqueId = '%q'", - dbId, - uniqueId.toUtf8().constData() ); + sql = qgs_sqlite3_mprintf( "UPDATE id_cache SET dbId = %lld WHERE uniqueId = '%q'", dbId, uniqueId.toUtf8().constData() ); if ( mCacheIdDb.exec( sql, errorMsg ) != SQLITE_OK ) { QgsMessageLog::logMessage( QObject::tr( "Problem when updating id cache: %1 -> %2" ).arg( sql ).arg( errorMsg ), mComponentTranslated ); @@ -715,19 +714,15 @@ void QgsBackgroundCachedSharedData::serializeFeatures( QVector %2" ).arg( sql ).arg( errorMsg ), mComponentTranslated ); } qgisId = mNextCachedIdQgisId; - mNextCachedIdQgisId ++; - sql = qgs_sqlite3_mprintf( "INSERT INTO id_cache (uniqueId, dbId, qgisId) VALUES ('%q', %lld, %lld)", - uniqueId.toUtf8().constData(), - dbId, - qgisId ); + mNextCachedIdQgisId++; + sql = qgs_sqlite3_mprintf( "INSERT INTO id_cache (uniqueId, dbId, qgisId) VALUES ('%q', %lld, %lld)", uniqueId.toUtf8().constData(), dbId, qgisId ); if ( mCacheIdDb.exec( sql, errorMsg ) != SQLITE_OK ) { QgsMessageLog::logMessage( QObject::tr( "Problem when updating id cache: %1 -> %2" ).arg( sql ).arg( errorMsg ), mComponentTranslated ); @@ -745,11 +740,11 @@ void QgsBackgroundCachedSharedData::serializeFeatures( QVector QgsBackgroundCachedSharedData::getExistingCachedUniqueIds( const Q // To avoid excessive memory consumption in expression building, do not // query more than 1000 ids at a time. - for ( int i = 0; i < featureList.size(); i ++ ) + for ( int i = 0; i < featureList.size(); i++ ) { if ( !first ) expr += ','; @@ -919,7 +907,6 @@ QSet QgsBackgroundCachedSharedData::getExistingCachedUniqueIds( const Q first = true; } - } return setExistingUniqueIds; @@ -936,7 +923,7 @@ QSet QgsBackgroundCachedSharedData::getExistingCachedMD5( const QVector // To avoid excessive memory consumption in expression building, do not // query more than 1000 ids at a time. - for ( int i = 0; i < featureList.size(); i ++ ) + for ( int i = 0; i < featureList.size(); i++ ) { if ( !first ) expr += QLatin1Char( ',' ); @@ -970,7 +957,6 @@ QSet QgsBackgroundCachedSharedData::getExistingCachedMD5( const QVector first = true; } - } return setExistingMD5; @@ -1081,22 +1067,21 @@ bool QgsBackgroundCachedSharedData::changeGeometryValues( const QgsGeometryMap & { QgsAttributeMap newAttrMap; newAttrMap[idx] = QString( wkb.toHex().data() ); - newChangedAttrMap[ dbId] = newAttrMap; + newChangedAttrMap[dbId] = newAttrMap; QgsGeometry polyBoundingBox = QgsGeometry::fromRect( iter.value().boundingBox() ); - newGeometryMap[ dbId] = polyBoundingBox; + newGeometryMap[dbId] = polyBoundingBox; } else { QgsAttributeMap newAttrMap; newAttrMap[idx] = QString(); - newChangedAttrMap[ dbId] = newAttrMap; - newGeometryMap[ dbId] = QgsGeometry(); + newChangedAttrMap[dbId] = newAttrMap; + newGeometryMap[dbId] = QgsGeometry(); } } - return mCacheDataProvider->changeGeometryValues( newGeometryMap ) && - mCacheDataProvider->changeAttributeValues( newChangedAttrMap ); + return mCacheDataProvider->changeGeometryValues( newGeometryMap ) && mCacheDataProvider->changeAttributeValues( newChangedAttrMap ); } // Used by WFS-T @@ -1148,7 +1133,7 @@ QString QgsBackgroundCachedSharedData::getMD5( const QgsFeature &f ) for ( int i = 0; i < attrs.size(); i++ ) { const QVariant &v = attrs[i]; - hash.addData( QByteArray( ( const char * )&i, sizeof( i ) ) ); + hash.addData( QByteArray( ( const char * ) &i, sizeof( i ) ) ); if ( QgsVariantUtils::isNull( v ) ) { // nothing to do @@ -1156,17 +1141,17 @@ QString QgsBackgroundCachedSharedData::getMD5( const QgsFeature &f ) else if ( v.userType() == QMetaType::Type::QDateTime ) { qint64 val = v.toDateTime().toMSecsSinceEpoch(); - hash.addData( QByteArray( ( const char * )&val, sizeof( val ) ) ); + hash.addData( QByteArray( ( const char * ) &val, sizeof( val ) ) ); } else if ( v.userType() == QMetaType::Type::Int ) { int val = v.toInt(); - hash.addData( QByteArray( ( const char * )&val, sizeof( val ) ) ); + hash.addData( QByteArray( ( const char * ) &val, sizeof( val ) ) ); } else if ( v.userType() == QMetaType::Type::LongLong ) { qint64 val = v.toLongLong(); - hash.addData( QByteArray( ( const char * )&val, sizeof( val ) ) ); + hash.addData( QByteArray( ( const char * ) &val, sizeof( val ) ) ); } else if ( v.userType() == QMetaType::Type::QString ) { @@ -1180,7 +1165,7 @@ QString QgsBackgroundCachedSharedData::getMD5( const QgsFeature &f ) } const int attrCount = attrs.size(); - hash.addData( QByteArray( ( const char * )&attrCount, sizeof( attrCount ) ) ); + hash.addData( QByteArray( ( const char * ) &attrCount, sizeof( attrCount ) ) ); QgsGeometry geometry = f.geometry(); if ( !geometry.isNull() ) { @@ -1200,8 +1185,7 @@ void QgsBackgroundCachedSharedData::setFeatureCount( long long featureCount, boo long long QgsBackgroundCachedSharedData::getFeatureCount( bool issueRequestIfNeeded ) { - if ( !mFeatureCountRequestIssued && !mFeatureCountExact && - supportsFastFeatureCount() && issueRequestIfNeeded ) + if ( !mFeatureCountRequestIssued && !mFeatureCountExact && supportsFastFeatureCount() && issueRequestIfNeeded ) { mFeatureCountRequestIssued = true; long long featureCount = getFeatureCountFromServer(); diff --git a/src/providers/wfs/qgsbackgroundcachedshareddata.h b/src/providers/wfs/qgsbackgroundcachedshareddata.h index 2cfdd456c5c1..56434ff4f618 100644 --- a/src/providers/wfs/qgsbackgroundcachedshareddata.h +++ b/src/providers/wfs/qgsbackgroundcachedshareddata.h @@ -189,7 +189,6 @@ class QgsBackgroundCachedSharedData virtual void pushError( const QString &errorMsg ) const = 0; protected: - //////////// Input members. Implementations should define them to meaningful values //! Attribute fields of the layer @@ -237,7 +236,6 @@ class QgsBackgroundCachedSharedData virtual bool detectPotentialServerAxisOrderIssueFromSingleFeatureExtent() const { return false; } private: - //! Cache directory manager QgsCacheDirectoryManager &mCacheDirectoryManager; @@ -269,7 +267,7 @@ class QgsBackgroundCachedSharedData QgsSpatialIndex mCachedRegions; //! Requested cached regions - QVector< QgsFeature > mRegions; + QVector mRegions; //! Limit of retrieved number of features for the current request int mRequestLimit = 0; diff --git a/src/providers/wfs/qgsbasenetworkrequest.cpp b/src/providers/wfs/qgsbasenetworkrequest.cpp index 5041b2d2a0aa..4395a92c5b34 100644 --- a/src/providers/wfs/qgsbasenetworkrequest.cpp +++ b/src/providers/wfs/qgsbasenetworkrequest.cpp @@ -67,7 +67,7 @@ QgsBaseNetworkRequest::QgsBaseNetworkRequest( const QgsAuthorizationSettings &au : mAuth( auth ) , mTranslatedComponent( translatedComponent ) { - connect( QgsNetworkAccessManager::instance(), qOverload< QNetworkReply *>( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsBaseNetworkRequest::requestTimedOut ); + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsBaseNetworkRequest::requestTimedOut ); } QgsBaseNetworkRequest::~QgsBaseNetworkRequest() @@ -144,7 +144,7 @@ bool QgsBaseNetworkRequest::sendGET( const QUrl &url, const QString &acceptHeade { modifiedUrlString += QLatin1Char( '?' ); } - modifiedUrlString += QString::fromUtf8( headerPair.first ) + QStringLiteral( "=" ) + QString::fromUtf8( headerPair.second ) ; + modifiedUrlString += QString::fromUtf8( headerPair.first ) + QStringLiteral( "=" ) + QString::fromUtf8( headerPair.second ); } QgsDebugMsgLevel( QStringLiteral( "Get %1" ).arg( modifiedUrlString ), 4 ); @@ -240,9 +240,7 @@ bool QgsBaseNetworkRequest::sendGET( const QUrl &url, const QString &acceptHeade // with a COUNT=1 into a short-lived memory cache, as they are emitted // repeatedly in interactive scenarios when adding a WFS layer. QString urlString = url.toString(); - if ( urlString.contains( QStringLiteral( "REQUEST=GetCapabilities" ) ) || - urlString.contains( QStringLiteral( "REQUEST=DescribeFeatureType" ) ) || - ( urlString.contains( QStringLiteral( "REQUEST=GetFeature" ) ) && urlString.contains( QStringLiteral( "COUNT=1" ) ) ) ) + if ( urlString.contains( QStringLiteral( "REQUEST=GetCapabilities" ) ) || urlString.contains( QStringLiteral( "REQUEST=DescribeFeatureType" ) ) || ( urlString.contains( QStringLiteral( "REQUEST=GetFeature" ) ) && urlString.contains( QStringLiteral( "COUNT=1" ) ) ) ) { QgsSettings s; if ( s.value( QStringLiteral( "qgis/wfsMemoryCacheAllowed" ), true ).toBool() ) @@ -257,15 +255,13 @@ bool QgsBaseNetworkRequest::sendGET( const QUrl &url, const QString &acceptHeade bool QgsBaseNetworkRequest::issueRequest( QNetworkRequest &request, const QByteArray &verb, const QByteArray *data, bool synchronous ) { - QWaitCondition waitCondition; QMutex waitConditionMutex; bool threadFinished = false; bool success = false; - const std::function downloaderFunction = [ this, request, synchronous, data, &verb, &waitConditionMutex, &waitCondition, &threadFinished, &success ]() - { + const std::function downloaderFunction = [this, request, synchronous, data, &verb, &waitConditionMutex, &waitCondition, &threadFinished, &success]() { if ( QThread::currentThread() != QApplication::instance()->thread() ) QgsNetworkAccessManager::instance( Qt::DirectConnection ); @@ -300,8 +296,7 @@ bool QgsBaseNetworkRequest::issueRequest( QNetworkRequest &request, const QByteA if ( synchronous ) { - auto resumeMainThread = [&waitConditionMutex, &waitCondition]() - { + auto resumeMainThread = [&waitConditionMutex, &waitCondition]() { // when this method is called we have "produced" a single authentication request -- so the buffer is now full // and it's time for the "consumer" (main thread) to do its part waitConditionMutex.lock(); @@ -441,7 +436,7 @@ bool QgsBaseNetworkRequest::sendPOSTOrPUTOrPATCH( const QUrl &url, const QByteAr } mRequestHeaders = extraHeaders; - mRequestHeaders << QNetworkReply::RawHeaderPair( "Content-Type", contentTypeHeader.toUtf8() ); + mRequestHeaders << QNetworkReply::RawHeaderPair( "Content-Type", contentTypeHeader.toUtf8() ); for ( const QNetworkReply::RawHeaderPair &headerPair : std::as_const( mRequestHeaders ) ) request.setRawHeader( headerPair.first, headerPair.second ); @@ -581,7 +576,7 @@ void QgsBaseNetworkRequest::abort() } } -void QgsBaseNetworkRequest::replyReadyRead( ) +void QgsBaseNetworkRequest::replyReadyRead() { mGotNonEmptyResponse = true; } @@ -724,8 +719,7 @@ void QgsBaseNetworkRequest::replyFinished() { const QDomElement exception = exceptionElem.firstChildElement( QStringLiteral( "Exception" ) ); mErrorMessage = tr( "WFS exception report (code=%1 text=%2)" ) - .arg( exception.attribute( QStringLiteral( "exceptionCode" ), tr( "missing" ) ), - exception.firstChildElement( QStringLiteral( "ExceptionText" ) ).text() ); + .arg( exception.attribute( QStringLiteral( "exceptionCode" ), tr( "missing" ) ), exception.firstChildElement( QStringLiteral( "ExceptionText" ) ).text() ); } } mErrorCode = QgsBaseNetworkRequest::ServerExceptionError; diff --git a/src/providers/wfs/qgsbasenetworkrequest.h b/src/providers/wfs/qgsbasenetworkrequest.h index 7e5c69cdd1a0..9b8c4af4d819 100644 --- a/src/providers/wfs/qgsbasenetworkrequest.h +++ b/src/providers/wfs/qgsbasenetworkrequest.h @@ -55,12 +55,14 @@ class QgsBaseNetworkRequest : public QObject //! Set whether to log error messages. void setLogErrors( bool enabled ) { mLogErrors = enabled; } - enum ErrorCode { NoError, - NetworkError, - TimeoutError, - ServerExceptionError, - ApplicationLevelError - }; + enum ErrorCode + { + NoError, + NetworkError, + TimeoutError, + ServerExceptionError, + ApplicationLevelError + }; //! Returns the error code (after download/post) ErrorCode errorCode() const { return mErrorCode; } @@ -135,7 +137,6 @@ class QgsBaseNetworkRequest : public QObject bool mFakeURLIncludesContentType = false; protected: - /** * Returns (translated) error message, composed with a * (possibly translated, but sometimes coming from server) reason @@ -146,7 +147,6 @@ class QgsBaseNetworkRequest : public QObject virtual int defaultExpirationInSec() { return 0; } private: - //! Request headers QList mRequestHeaders; diff --git a/src/providers/wfs/qgscachedirectorymanager.cpp b/src/providers/wfs/qgscachedirectorymanager.cpp index 1a138339d91b..66d4f5cccce6 100644 --- a/src/providers/wfs/qgscachedirectorymanager.cpp +++ b/src/providers/wfs/qgscachedirectorymanager.cpp @@ -20,7 +20,7 @@ #include "qgssettings.h" // 1 minute -#define KEEP_ALIVE_DELAY (60 * 1000) +#define KEEP_ALIVE_DELAY ( 60 * 1000 ) #include #include @@ -64,7 +64,7 @@ QString QgsCacheDirectoryManager::getBaseCacheDirectory( bool createIfNotExistin const QMutexLocker locker( &mMutex ); if ( !QDir( cacheDirectory ).exists( subDir ) ) { - QgsDebugMsgLevel( QStringLiteral( "Creating main cache dir %1/%2" ).arg( cacheDirectory ). arg( subDir ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Creating main cache dir %1/%2" ).arg( cacheDirectory ).arg( subDir ), 2 ); QDir( cacheDirectory ).mkpath( subDir ); } } @@ -90,7 +90,7 @@ QString QgsCacheDirectoryManager::getCacheDirectory( bool createIfNotExisting ) mThread->start(); } #endif - mCounter ++; + mCounter++; } return QDir( baseDirectory ).filePath( processPath ); } @@ -103,7 +103,7 @@ QString QgsCacheDirectoryManager::acquireCacheDirectory() void QgsCacheDirectoryManager::releaseCacheDirectory() { const QMutexLocker locker( &mMutex ); - mCounter --; + mCounter--; if ( mCounter == 0 ) { if ( mThread ) @@ -177,8 +177,7 @@ std::unique_ptr QgsCacheDirectoryManager::createAndAttachSHM() // Would happen on Unix in the quite unlikely situation where a past process // with the same PID as ours would have been killed before it destroyed // its shared memory segment. So we will recycle it. - if ( sharedMemory->error() == QSharedMemory::AlreadyExists && - sharedMemory->attach() && sharedMemory->size() == static_cast( sizeof( qint64 ) ) ) + if ( sharedMemory->error() == QSharedMemory::AlreadyExists && sharedMemory->attach() && sharedMemory->size() == static_cast( sizeof( qint64 ) ) ) { return sharedMemory; } @@ -240,8 +239,7 @@ void QgsCacheDirectoryManager::init() qint64 otherTimestamp; memcpy( &otherTimestamp, otherSharedMemory.data(), sizeof( qint64 ) ); otherSharedMemory.unlock(); - if ( currentTimestamp > otherTimestamp && otherTimestamp > 0 && - currentTimestamp - otherTimestamp < 2 * KEEP_ALIVE_DELAY ) + if ( currentTimestamp > otherTimestamp && otherTimestamp > 0 && currentTimestamp - otherTimestamp < 2 * KEEP_ALIVE_DELAY ) { QgsDebugMsgLevel( QStringLiteral( "Cache dir %1 kept since process seems to be still alive" ).arg( info.absoluteFilePath() ), 4 ); canDelete = false; @@ -267,8 +265,7 @@ void QgsCacheDirectoryManager::init() // Fallback to a file timestamp based method, if for some reason, // the shared memory stuff doesn't seem to work const qint64 fileTimestamp = info.lastModified().toMSecsSinceEpoch(); - if ( currentTimestamp > fileTimestamp && - currentTimestamp - fileTimestamp < 24 * 3600 * 1000 ) + if ( currentTimestamp > fileTimestamp && currentTimestamp - fileTimestamp < 24 * 3600 * 1000 ) { QgsDebugMsgLevel( QStringLiteral( "Cache dir %1 kept since last modified in the past 24 hours" ).arg( info.absoluteFilePath() ), 4 ); canDelete = false; diff --git a/src/providers/wfs/qgscachedirectorymanager.h b/src/providers/wfs/qgscachedirectorymanager.h index c43ed18a52d5..40a3e9b01669 100644 --- a/src/providers/wfs/qgscachedirectorymanager.h +++ b/src/providers/wfs/qgscachedirectorymanager.h @@ -75,7 +75,7 @@ class QgsCacheDirectoryManager #if not defined( Q_OS_ANDROID ) //! For internal use of QgsCacheDirectoryManager -class QgsCacheDirectoryManagerKeepAlive: public QThread +class QgsCacheDirectoryManagerKeepAlive : public QThread { Q_OBJECT public: @@ -85,6 +85,7 @@ class QgsCacheDirectoryManagerKeepAlive: public QThread void run() override; private slots: void updateTimestamp(); + private: std::unique_ptr mSharedMemory; }; diff --git a/src/providers/wfs/qgswfscapabilities.cpp b/src/providers/wfs/qgswfscapabilities.cpp index bf240b4c9020..d8a10bb809a6 100644 --- a/src/providers/wfs/qgswfscapabilities.cpp +++ b/src/providers/wfs/qgswfscapabilities.cpp @@ -32,8 +32,7 @@ #include QgsWfsCapabilities::QgsWfsCapabilities( const QString &uri, const QgsDataProvider::ProviderOptions &options ) - : QgsWfsRequest( QgsWFSDataSourceURI( uri ) ), - mOptions( options ) + : QgsWfsRequest( QgsWFSDataSourceURI( uri ) ), mOptions( options ) { // Using Qt::DirectConnection since the download might be running on a different thread. // In this case, the request was sent from the main thread and is executed with the main @@ -44,7 +43,7 @@ QgsWfsCapabilities::QgsWfsCapabilities( const QString &uri, const QgsDataProvide QUrl QgsWfsCapabilities::requestUrl() const { - QUrl url( mUri.baseURL( ) ); + QUrl url( mUri.baseURL() ); QUrlQuery query( url ); query.addQueryItem( QStringLiteral( "REQUEST" ), QStringLiteral( "GetCapabilities" ) ); @@ -118,9 +117,7 @@ QString QgsWfsCapabilities::Capabilities::getNamespaceParameterValue( const QStr if ( tryNameSpacing ) { QString prefixOfTypename = QgsWFSUtils::nameSpacePrefix( typeName ); - return "xmlns(" + prefixOfTypename + - ( WFSVersion.startsWith( QLatin1String( "2.0" ) ) ? "," : "=" ) + - namespaces + ")"; + return "xmlns(" + prefixOfTypename + ( WFSVersion.startsWith( QLatin1String( "2.0" ) ) ? "," : "=" ) + namespaces + ")"; } return QString(); } @@ -164,7 +161,8 @@ class CPLXMLTreeUniquePointer //! Destructor ~CPLXMLTreeUniquePointer() { - if ( the_data_ ) CPLDestroyXMLNode( the_data_ ); + if ( the_data_ ) + CPLDestroyXMLNode( the_data_ ); } /** @@ -242,9 +240,7 @@ void QgsWfsCapabilities::capabilitiesReplyFinished() //test wfs version mCaps.version = doc.attribute( QStringLiteral( "version" ) ); - if ( !mCaps.version.startsWith( QLatin1String( "1.0" ) ) && - !mCaps.version.startsWith( QLatin1String( "1.1" ) ) && - !mCaps.version.startsWith( QLatin1String( "2.0" ) ) ) + if ( !mCaps.version.startsWith( QLatin1String( "1.0" ) ) && !mCaps.version.startsWith( QLatin1String( "1.1" ) ) && !mCaps.version.startsWith( QLatin1String( "2.0" ) ) ) { mErrorCode = QgsWfsRequest::ApplicationLevelError; mAppLevelError = ApplicationLevelError::VersionNotSupported; @@ -325,8 +321,7 @@ void QgsWfsCapabilities::capabilitiesReplyFinished() QgsDebugMsgLevel( QStringLiteral( "Supports paging" ), 2 ); } } - else if ( constraint.attribute( QStringLiteral( "name" ) ) == QLatin1String( "ImplementsStandardJoins" ) || - constraint.attribute( QStringLiteral( "name" ) ) == QLatin1String( "ImplementsSpatialJoins" ) /* WFS 2.0 */ ) + else if ( constraint.attribute( QStringLiteral( "name" ) ) == QLatin1String( "ImplementsStandardJoins" ) || constraint.attribute( QStringLiteral( "name" ) ) == QLatin1String( "ImplementsSpatialJoins" ) /* WFS 2.0 */ ) { QDomElement value = constraint.firstChildElement( QStringLiteral( "DefaultValue" ) ); if ( !value.isNull() && value.text() == QLatin1String( "TRUE" ) ) @@ -429,10 +424,7 @@ void QgsWfsCapabilities::capabilitiesReplyFinished() // WFS < 2 if ( mCaps.version.startsWith( QLatin1Char( '1' ) ) ) { - parseSupportedOperations( featureTypeListElem.firstChildElement( QStringLiteral( "Operations" ) ), - insertCap, - updateCap, - deleteCap ); + parseSupportedOperations( featureTypeListElem.firstChildElement( QStringLiteral( "Operations" ) ), insertCap, updateCap, deleteCap ); } else // WFS 2.0.0 tested on GeoServer { @@ -483,7 +475,7 @@ void QgsWfsCapabilities::capabilitiesReplyFinished() { featureType.name = nameList.at( 0 ).toElement().text(); - QgsDebugMsgLevel( QStringLiteral( "featureType.name = %1" ) . arg( featureType.name ), 4 ); + QgsDebugMsgLevel( QStringLiteral( "featureType.name = %1" ).arg( featureType.name ), 4 ); if ( featureType.name.contains( ':' ) ) { QString prefixOfTypename = featureType.name.section( ':', 0, 0 ); @@ -560,18 +552,17 @@ void QgsWfsCapabilities::capabilitiesReplyFinished() // value too small for byte - << 0; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::Byte + << "EPSG:4326" + << 1.0 + << -1.0 //fails --> value too small for byte + << 0; /* @@ -1519,13 +1506,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 3" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::Byte - << "EPSG:4326" - << 1.0 - << 256.0 //fails --> value too big for byte - << 0; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::Byte + << "EPSG:4326" + << 1.0 + << 256.0 //fails --> value too big for byte + << 0; /* * Testcase 4 @@ -1538,13 +1525,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 4" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QStringLiteral( "/createConstantRaster_testcase4.tif" ) - << Qgis::DataType::Int16 - << "EPSG:4326" - << 1.0 - << 12.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QStringLiteral( "/createConstantRaster_testcase4.tif" ) + << Qgis::DataType::Int16 + << "EPSG:4326" + << 1.0 + << 12.0 + << 1; /* * Testcase 5 @@ -1557,13 +1544,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 5" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::Int16 - << "EPSG:4326" - << 1.0 - << -32769.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::Int16 + << "EPSG:4326" + << 1.0 + << -32769.0 + << 1; /* * Testcase 6 @@ -1576,13 +1563,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 6" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::Int16 - << "EPSG:4326" - << 1.0 - << 32769.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::Int16 + << "EPSG:4326" + << 1.0 + << 32769.0 + << 1; /* * Testcase 7 @@ -1595,13 +1582,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 7" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QStringLiteral( "/createConstantRaster_testcase7.tif" ) - << Qgis::DataType::UInt16 - << "EPSG:4326" - << 1.0 - << 12.0 - << 2; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QStringLiteral( "/createConstantRaster_testcase7.tif" ) + << Qgis::DataType::UInt16 + << "EPSG:4326" + << 1.0 + << 12.0 + << 2; /* * Testcase 8 @@ -1614,13 +1601,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 8" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::UInt16 - << "EPSG:4326" - << 1.0 - << -1.0 - << 2; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::UInt16 + << "EPSG:4326" + << 1.0 + << -1.0 + << 2; /* * Testcase 9 @@ -1633,13 +1620,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 9" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::UInt16 - << "EPSG:4326" - << 1.0 - << 65536.0 - << 2; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::UInt16 + << "EPSG:4326" + << 1.0 + << 65536.0 + << 2; /* * Testcase 10 @@ -1652,13 +1639,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 10" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QStringLiteral( "/createConstantRaster_testcase10.tif" ) - << Qgis::DataType::Int32 - << "EPSG:4326" - << 1.0 - << 12.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QStringLiteral( "/createConstantRaster_testcase10.tif" ) + << Qgis::DataType::Int32 + << "EPSG:4326" + << 1.0 + << 12.0 + << 3; /* * Testcase 10 @@ -1671,13 +1658,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 10" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QStringLiteral( "/createConstantRaster_testcase10.tif" ) - << Qgis::DataType::Int32 - << "EPSG:4326" - << 1.0 - << 12.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QStringLiteral( "/createConstantRaster_testcase10.tif" ) + << Qgis::DataType::Int32 + << "EPSG:4326" + << 1.0 + << 12.0 + << 3; /* * Testcase 11 @@ -1690,13 +1677,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 11" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::Int32 - << "EPSG:4326" - << 1.0 - << -2147483649.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::Int32 + << "EPSG:4326" + << 1.0 + << -2147483649.0 + << 3; /* * Testcase 12 @@ -1709,13 +1696,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 12" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::Int32 - << "EPSG:4326" - << 1.0 - << 2147483649.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::Int32 + << "EPSG:4326" + << 1.0 + << 2147483649.0 + << 3; /* * Testcase 13 @@ -1728,13 +1715,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 13" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QStringLiteral( "/createConstantRaster_testcase13.tif" ) - << Qgis::DataType::UInt32 - << "EPSG:4326" - << 1.0 - << 12.0 - << 4; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QStringLiteral( "/createConstantRaster_testcase13.tif" ) + << Qgis::DataType::UInt32 + << "EPSG:4326" + << 1.0 + << 12.0 + << 4; /* * Testcase 14 @@ -1747,13 +1734,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 14" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::UInt32 - << "EPSG:4326" - << 1.0 - << 4294967296.0 - << 4; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::UInt32 + << "EPSG:4326" + << 1.0 + << 4294967296.0 + << 4; /* * Testcase 15 @@ -1766,13 +1753,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 14" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QString() - << Qgis::DataType::UInt32 - << "EPSG:4326" - << 1.0 - << -1.0 - << 4; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QString() + << Qgis::DataType::UInt32 + << "EPSG:4326" + << 1.0 + << -1.0 + << 4; /* * Testcase 16 @@ -1785,13 +1772,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 16" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QStringLiteral( "/createConstantRaster_testcase16.tif" ) - << Qgis::DataType::Float32 - << "EPSG:4326" - << 1.0 - << 12.12 - << 5; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QStringLiteral( "/createConstantRaster_testcase16.tif" ) + << Qgis::DataType::Float32 + << "EPSG:4326" + << 1.0 + << 12.12 + << 5; /* * Testcase 17 @@ -1804,15 +1791,13 @@ void TestQgsProcessingAlgsPt1::createConstantRaster_data() * */ QTest::newRow( "testcase 17" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << QStringLiteral( "/createConstantRaster_testcase17.tif" ) - << Qgis::DataType::Float64 - << "EPSG:4326" - << 1.0 - << 12.125789212532487 - << 6; - - + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << QStringLiteral( "/createConstantRaster_testcase17.tif" ) + << Qgis::DataType::Float64 + << "EPSG:4326" + << 1.0 + << 12.125789212532487 + << 6; } void TestQgsProcessingAlgsPt1::createConstantRaster() @@ -1827,7 +1812,7 @@ void TestQgsProcessingAlgsPt1::createConstantRaster() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:createconstantrasterlayer" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:createconstantrasterlayer" ) ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -1835,7 +1820,7 @@ void TestQgsProcessingAlgsPt1::createConstantRaster() p.setCrs( QgsCoordinateReferenceSystem( crs ), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -1860,8 +1845,8 @@ void TestQgsProcessingAlgsPt1::createConstantRaster() else { //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images/expected_constantRaster" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images/expected_constantRaster" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -1870,8 +1855,8 @@ void TestQgsProcessingAlgsPt1::createConstantRaster() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); QCOMPARE( outputRaster->height(), expectedRasterLayer->height() ); @@ -1888,11 +1873,10 @@ void TestQgsProcessingAlgsPt1::createConstantRaster() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -1916,58 +1900,58 @@ void TestQgsProcessingAlgsPt1::densifyGeometries_data() QTest::addColumn( "geometryType" ); QTest::newRow( "Null geometry" ) - << QgsGeometry() - << QgsGeometry() - << 0.1 - << "Point"; + << QgsGeometry() + << QgsGeometry() + << 0.1 + << "Point"; QTest::newRow( "PointZ" ) - << QgsGeometry::fromWkt( "PointZ( 1 2 3 )" ) - << QgsGeometry::fromWkt( "PointZ( 1 2 3 )" ) - << 0.1 - << "Point"; + << QgsGeometry::fromWkt( "PointZ( 1 2 3 )" ) + << QgsGeometry::fromWkt( "PointZ( 1 2 3 )" ) + << 0.1 + << "Point"; QTest::newRow( "MultiPoint" ) - << QgsGeometry::fromWkt( "MULTIPOINT ((155 271), (150 360), (260 360), (271 265), (280 260), (270 370), (154 354), (150 260))" ) - << QgsGeometry::fromWkt( "MULTIPOINT ((155 271), (150 360), (260 360), (271 265), (280 260), (270 370), (154 354), (150 260))" ) - << 0.1 - << "Point"; + << QgsGeometry::fromWkt( "MULTIPOINT ((155 271), (150 360), (260 360), (271 265), (280 260), (270 370), (154 354), (150 260))" ) + << QgsGeometry::fromWkt( "MULTIPOINT ((155 271), (150 360), (260 360), (271 265), (280 260), (270 370), (154 354), (150 260))" ) + << 0.1 + << "Point"; QTest::newRow( "LineString big distance" ) - << QgsGeometry::fromWkt( "LineString( 0 0, 10 0, 10 10 )" ) - << QgsGeometry::fromWkt( "LineString( 0 0, 10 0, 10 10 )" ) - << 100. - << "LineString"; + << QgsGeometry::fromWkt( "LineString( 0 0, 10 0, 10 10 )" ) + << QgsGeometry::fromWkt( "LineString( 0 0, 10 0, 10 10 )" ) + << 100. + << "LineString"; QTest::newRow( "LineString small distance" ) - << QgsGeometry::fromWkt( "LineString( 0 0, 10 0, 10 10 )" ) - << QgsGeometry::fromWkt( "LineString (0 0, 2.5 0, 5 0, 7.5 0, 10 0, 10 2.5, 10 5, 10 7.5, 10 10)" ) - << 3. - << "LineString"; + << QgsGeometry::fromWkt( "LineString( 0 0, 10 0, 10 10 )" ) + << QgsGeometry::fromWkt( "LineString (0 0, 2.5 0, 5 0, 7.5 0, 10 0, 10 2.5, 10 5, 10 7.5, 10 10)" ) + << 3. + << "LineString"; QTest::newRow( "LineStringZ" ) - << QgsGeometry::fromWkt( "LineStringZ( 0 0 1, 10 0 2, 10 10 0)" ) - << QgsGeometry::fromWkt( "LineStringZ (0 0 1, 5 0 1.5, 10 0 2, 10 5 1, 10 10 0)" ) - << 6. - << "LineString"; + << QgsGeometry::fromWkt( "LineStringZ( 0 0 1, 10 0 2, 10 10 0)" ) + << QgsGeometry::fromWkt( "LineStringZ (0 0 1, 5 0 1.5, 10 0 2, 10 5 1, 10 10 0)" ) + << 6. + << "LineString"; QTest::newRow( "LineStringM" ) - << QgsGeometry::fromWkt( "LineStringM( 0 0 0, 10 0 2, 10 10 0)" ) - << QgsGeometry::fromWkt( "LineStringM (0 0 0, 2.5 0 0.5, 5 0 1, 7.5 0 1.5, 10 0 2, 10 2.5 1.5, 10 5 1, 10 7.5 0.5, 10 10 0)" ) - << 3. - << "LineString"; + << QgsGeometry::fromWkt( "LineStringM( 0 0 0, 10 0 2, 10 10 0)" ) + << QgsGeometry::fromWkt( "LineStringM (0 0 0, 2.5 0 0.5, 5 0 1, 7.5 0 1.5, 10 0 2, 10 2.5 1.5, 10 5 1, 10 7.5 0.5, 10 10 0)" ) + << 3. + << "LineString"; QTest::newRow( "LineStringZM" ) - << QgsGeometry::fromWkt( "LineStringZM( 0 0 1 10, 10 0 2 8, 10 10 0 4)" ) - << QgsGeometry::fromWkt( "LineStringZM (0 0 1 10, 5 0 1.5 9, 10 0 2 8, 10 5 1 6, 10 10 0 4)" ) - << 6. - << "LineString"; + << QgsGeometry::fromWkt( "LineStringZM( 0 0 1 10, 10 0 2 8, 10 10 0 4)" ) + << QgsGeometry::fromWkt( "LineStringZM (0 0 1 10, 5 0 1.5 9, 10 0 2 8, 10 5 1 6, 10 10 0 4)" ) + << 6. + << "LineString"; QTest::newRow( "Polygon" ) - << QgsGeometry::fromWkt( "Polygon(( 0 0, 20 0, 20 20, 0 0 ))" ) - << QgsGeometry::fromWkt( "Polygon ((0 0, 5 0, 10 0, 15 0, 20 0, 20 5, 20 10, 20 15, 20 20, 16 16, 12 12, 7.99999999999999822 7.99999999999999822, 4 4, 0 0))" ) - << 6. - << "Polygon"; + << QgsGeometry::fromWkt( "Polygon(( 0 0, 20 0, 20 20, 0 0 ))" ) + << QgsGeometry::fromWkt( "Polygon ((0 0, 5 0, 10 0, 15 0, 20 0, 20 5, 20 10, 20 15, 20 20, 16 16, 12 12, 7.99999999999999822 7.99999999999999822, 4 4, 0 0))" ) + << 6. + << "Polygon"; } void TestQgsProcessingAlgsPt1::densifyGeometries() @@ -1977,7 +1961,7 @@ void TestQgsProcessingAlgsPt1::densifyGeometries() QFETCH( double, interval ); QFETCH( QString, geometryType ); - const std::unique_ptr< QgsProcessingFeatureBasedAlgorithm > alg( featureBasedAlg( "native:densifygeometriesgivenaninterval" ) ); + const std::unique_ptr alg( featureBasedAlg( "native:densifygeometriesgivenaninterval" ) ); QVariantMap parameters; parameters.insert( QStringLiteral( "INTERVAL" ), interval ); @@ -2008,10 +1992,10 @@ void TestQgsProcessingAlgsPt1::fillNoData_data() * fillValue = 2.0 */ QTest::newRow( "testcase 1" ) - << "/raster/band1_int16_noct_epsg4326.tif" - << QStringLiteral( "/fillnodata_testcase1.tif" ) - << 1 - << 2.0; + << "/raster/band1_int16_noct_epsg4326.tif" + << QStringLiteral( "/fillnodata_testcase1.tif" ) + << 1 + << 2.0; /* * Testcase 2 @@ -2021,10 +2005,10 @@ void TestQgsProcessingAlgsPt1::fillNoData_data() * pixelSize = 1.8 */ QTest::newRow( "testcase 2" ) - << "/raster/band1_int16_noct_epsg4326.tif" - << QStringLiteral( "/fillnodata_testcase2.tif" ) - << 1 - << 1.8; + << "/raster/band1_int16_noct_epsg4326.tif" + << QStringLiteral( "/fillnodata_testcase2.tif" ) + << 1 + << 1.8; /* * Testcase 3 @@ -2034,11 +2018,10 @@ void TestQgsProcessingAlgsPt1::fillNoData_data() * pixelSize = 1.8 */ QTest::newRow( "testcase 2" ) - << "/raster/band1_float32_noct_epsg4326.tif" - << QStringLiteral( "/fillnodata_testcase3.tif" ) - << 1 - << 1.8; - + << "/raster/band1_float32_noct_epsg4326.tif" + << QStringLiteral( "/fillnodata_testcase3.tif" ) + << 1 + << 1.8; } void TestQgsProcessingAlgsPt1::fillNoData() @@ -2050,17 +2033,17 @@ void TestQgsProcessingAlgsPt1::fillNoData() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:fillnodata" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:fillnodata" ) ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt - std::unique_ptr inputRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + inputRaster, "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer = std::make_unique( myDataPath + inputRaster, "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -2071,8 +2054,8 @@ void TestQgsProcessingAlgsPt1::fillNoData() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images/fillNoData/" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images/fillNoData/" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -2086,8 +2069,8 @@ void TestQgsProcessingAlgsPt1::fillNoData() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); QCOMPARE( outputRaster->height(), expectedRasterLayer->height() ); @@ -2103,11 +2086,10 @@ void TestQgsProcessingAlgsPt1::fillNoData() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -2137,11 +2119,11 @@ void TestQgsProcessingAlgsPt1::lineDensity_data() * pixelSize = 2 */ QTest::newRow( "testcase 1" ) - << "/linedensity.gml" - << QStringLiteral( "/linedensity_testcase1.tif" ) - << 3.0 - << 2.0 - << QStringLiteral( "weight" ); + << "/linedensity.gml" + << QStringLiteral( "/linedensity_testcase1.tif" ) + << 3.0 + << 2.0 + << QStringLiteral( "weight" ); /* * Testcase 2 @@ -2151,12 +2133,11 @@ void TestQgsProcessingAlgsPt1::lineDensity_data() * pixelSize = 2 */ QTest::newRow( "testcase_2" ) - << "/linedensity.gml" - << QStringLiteral( "/linedensity_testcase2.tif" ) - << 3.0 - << 2.0 - << QString(); - + << "/linedensity.gml" + << QStringLiteral( "/linedensity_testcase2.tif" ) + << 3.0 + << 2.0 + << QString(); } void TestQgsProcessingAlgsPt1::lineDensity() @@ -2169,7 +2150,7 @@ void TestQgsProcessingAlgsPt1::lineDensity() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:linedensity" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:linedensity" ) ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -2181,7 +2162,7 @@ void TestQgsProcessingAlgsPt1::lineDensity() p.setCrs( layer->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -2193,8 +2174,8 @@ void TestQgsProcessingAlgsPt1::lineDensity() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRaster = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images/expected_raster_linedensity" + expectedDataset, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRaster->dataProvider()->clone() ); + std::unique_ptr expectedRaster = std::make_unique( myDataPath + "/control_images/expected_raster_linedensity" + expectedDataset, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRaster->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRaster->width(), expectedRaster->height(), expectedInterface->extent() ); @@ -2208,8 +2189,8 @@ void TestQgsProcessingAlgsPt1::lineDensity() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputRaster->width(), expectedRaster->width() ); QCOMPARE( outputRaster->height(), expectedRaster->height() ); @@ -2225,11 +2206,10 @@ void TestQgsProcessingAlgsPt1::lineDensity() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -2245,131 +2225,131 @@ void TestQgsProcessingAlgsPt1::lineDensity() void TestQgsProcessingAlgsPt1::rasterLogicOp_data() { - QTest::addColumn>( "input1" ); - QTest::addColumn>( "input2" ); - QTest::addColumn>( "input3" ); + QTest::addColumn>( "input1" ); + QTest::addColumn>( "input2" ); + QTest::addColumn>( "input3" ); QTest::addColumn( "treatNodataAsFalse" ); QTest::addColumn( "expectedOrNoDataCount" ); QTest::addColumn( "expectedOrTrueCount" ); QTest::addColumn( "expectedOrFalseCount" ); - QTest::addColumn>( "expectedOr" ); + QTest::addColumn>( "expectedOr" ); QTest::addColumn( "expectedAndNoDataCount" ); QTest::addColumn( "expectedAndTrueCount" ); QTest::addColumn( "expectedAndFalseCount" ); - QTest::addColumn>( "expectedAnd" ); + QTest::addColumn>( "expectedAnd" ); QTest::addColumn( "nRows" ); QTest::addColumn( "nCols" ); QTest::addColumn( "destNoDataValue" ); QTest::addColumn( "dataType" ); - QTest::newRow( "no nodata" ) << QVector< double > { 1, 2, 0, 0, 0, 0 } - << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > { 1, 2, 0, 0, 0, -1 } + QTest::newRow( "no nodata" ) << QVector { 1, 2, 0, 0, 0, 0 } + << QVector { 1, 0, 1, 1, 0, 1 } + << QVector { 1, 2, 0, 0, 0, -1 } << false << 0ULL << 5ULL << 1ULL - << QVector< double > { 1, 1, 1, 1, 0, 1 } + << QVector { 1, 1, 1, 1, 0, 1 } << 0ULL << 1ULL << 5ULL - << QVector< double > { 1, 0, 0, 0, 0, 0 } + << QVector { 1, 0, 0, 0, 0, 0 } << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "nodata" ) << QVector< double > { 1, -9999, 0, 0, 0, 0 } - << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > { 1, 2, 0, -9999, 0, -1 } + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "nodata" ) << QVector { 1, -9999, 0, 0, 0, 0 } + << QVector { 1, 0, 1, 1, 0, 1 } + << QVector { 1, 2, 0, -9999, 0, -1 } << false << 2ULL << 3ULL << 1ULL - << QVector< double > { 1, -9999, 1, -9999, 0, 1 } + << QVector { 1, -9999, 1, -9999, 0, 1 } << 2ULL << 1ULL << 3ULL - << QVector< double > { 1, -9999, 0, -9999, 0, 0 } + << QVector { 1, -9999, 0, -9999, 0, 0 } << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "nodata as false" ) << QVector< double > { 1, -9999, 0, 0, 0, 0 } - << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > { 1, 2, 0, -9999, 0, -1 } + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "nodata as false" ) << QVector { 1, -9999, 0, 0, 0, 0 } + << QVector { 1, 0, 1, 1, 0, 1 } + << QVector { 1, 2, 0, -9999, 0, -1 } << true << 0ULL << 5ULL << 1ULL - << QVector< double > { 1, 1, 1, 1, 0, 1 } + << QVector { 1, 1, 1, 1, 0, 1 } << 0ULL << 1ULL << 5ULL - << QVector< double > { 1, 0, 0, 0, 0, 0 } + << QVector { 1, 0, 0, 0, 0, 0 } << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "missing block 1" ) << QVector< double > {} - << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > { 1, 2, 0, -9999, 0, -1 } + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "missing block 1" ) << QVector {} + << QVector { 1, 0, 1, 1, 0, 1 } + << QVector { 1, 2, 0, -9999, 0, -1 } << false << 6ULL << 0ULL << 0ULL - << QVector< double > { -9999, -9999, -9999, -9999, -9999, -9999 } + << QVector { -9999, -9999, -9999, -9999, -9999, -9999 } << 6ULL << 0ULL << 0ULL - << QVector< double > { -9999, -9999, -9999, -9999, -9999, -9999 } + << QVector { -9999, -9999, -9999, -9999, -9999, -9999 } << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "missing block 1 nodata as false" ) << QVector< double > {} - << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > { 1, 2, 0, -9999, 0, -1 } - << true - << 0ULL << 5ULL << 1ULL - << QVector< double > { 1, 1, 1, 1, 0, 1 } - << 0ULL << 0ULL << 6ULL - << QVector< double > { 0, 0, 0, 0, 0, 0 } - << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "missing block 2" ) << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > {} - << QVector< double > { 1, 2, 0, -9999, 0, -1 } + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "missing block 1 nodata as false" ) << QVector {} + << QVector { 1, 0, 1, 1, 0, 1 } + << QVector { 1, 2, 0, -9999, 0, -1 } + << true + << 0ULL << 5ULL << 1ULL + << QVector { 1, 1, 1, 1, 0, 1 } + << 0ULL << 0ULL << 6ULL + << QVector { 0, 0, 0, 0, 0, 0 } + << 3 << 2 + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "missing block 2" ) << QVector { 1, 0, 1, 1, 0, 1 } + << QVector {} + << QVector { 1, 2, 0, -9999, 0, -1 } << false << 6ULL << 0ULL << 0ULL - << QVector< double > { -9999, -9999, -9999, -9999, -9999, -9999 } + << QVector { -9999, -9999, -9999, -9999, -9999, -9999 } << 6ULL << 0ULL << 0ULL - << QVector< double > { -9999, -9999, -9999, -9999, -9999, -9999 } + << QVector { -9999, -9999, -9999, -9999, -9999, -9999 } << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "missing block 2 nodata as false" ) << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > {} - << QVector< double > { 1, 2, 0, -9999, 0, -1 } - << true - << 0ULL << 5ULL << 1ULL - << QVector< double > { 1, 1, 1, 1, 0, 1 } - << 0ULL << 0ULL << 6ULL - << QVector< double > { 0, 0, 0, 0, 0, 0 } - << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "missing block 3" ) << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > { 1, 2, 0, -9999, 0, -1 } - << QVector< double > {} + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "missing block 2 nodata as false" ) << QVector { 1, 0, 1, 1, 0, 1 } + << QVector {} + << QVector { 1, 2, 0, -9999, 0, -1 } + << true + << 0ULL << 5ULL << 1ULL + << QVector { 1, 1, 1, 1, 0, 1 } + << 0ULL << 0ULL << 6ULL + << QVector { 0, 0, 0, 0, 0, 0 } + << 3 << 2 + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "missing block 3" ) << QVector { 1, 0, 1, 1, 0, 1 } + << QVector { 1, 2, 0, -9999, 0, -1 } + << QVector {} << false << 6ULL << 0ULL << 0ULL - << QVector< double > { -9999, -9999, -9999, -9999, -9999, -9999 } + << QVector { -9999, -9999, -9999, -9999, -9999, -9999 } << 6ULL << 0ULL << 0ULL - << QVector< double > { -9999, -9999, -9999, -9999, -9999, -9999 } + << QVector { -9999, -9999, -9999, -9999, -9999, -9999 } << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); - QTest::newRow( "missing block 3 nodata as false" ) << QVector< double > { 1, 0, 1, 1, 0, 1 } - << QVector< double > { 1, 2, 0, -9999, 0, -1 } - << QVector< double > {} - << true - << 0ULL << 5ULL << 1ULL - << QVector< double > { 1, 1, 1, 1, 0, 1 } - << 0ULL << 0ULL << 6ULL - << QVector< double > { 0, 0, 0, 0, 0, 0 } - << 3 << 2 - << -9999.0 << static_cast< int >( Qgis::DataType::Float32 ); + << -9999.0 << static_cast( Qgis::DataType::Float32 ); + QTest::newRow( "missing block 3 nodata as false" ) << QVector { 1, 0, 1, 1, 0, 1 } + << QVector { 1, 2, 0, -9999, 0, -1 } + << QVector {} + << true + << 0ULL << 5ULL << 1ULL + << QVector { 1, 1, 1, 1, 0, 1 } + << 0ULL << 0ULL << 6ULL + << QVector { 0, 0, 0, 0, 0, 0 } + << 3 << 2 + << -9999.0 << static_cast( Qgis::DataType::Float32 ); } void TestQgsProcessingAlgsPt1::rasterLogicOp() { - QFETCH( QVector< double >, input1 ); - QFETCH( QVector< double >, input2 ); - QFETCH( QVector< double >, input3 ); - QVector< QVector< double > > input; + QFETCH( QVector, input1 ); + QFETCH( QVector, input2 ); + QFETCH( QVector, input3 ); + QVector> input; input << input1 << input2 << input3; QFETCH( bool, treatNodataAsFalse ); QFETCH( qgssize, expectedOrNoDataCount ); QFETCH( qgssize, expectedOrTrueCount ); QFETCH( qgssize, expectedOrFalseCount ); - QFETCH( QVector< double >, expectedOr ); + QFETCH( QVector, expectedOr ); QFETCH( qgssize, expectedAndNoDataCount ); QFETCH( qgssize, expectedAndTrueCount ); QFETCH( qgssize, expectedAndFalseCount ); - QFETCH( QVector< double >, expectedAnd ); + QFETCH( QVector, expectedAnd ); QFETCH( int, nRows ); QFETCH( int, nCols ); QFETCH( double, destNoDataValue ); @@ -2381,13 +2361,12 @@ void TestQgsProcessingAlgsPt1::rasterLogicOp() const QgsRectangle extent = QgsRectangle( 0, 0, nRows, nCols ); const QgsRectangle badExtent = QgsRectangle( -100, -100, 90, 90 ); const QgsCoordinateReferenceSystem crs( QStringLiteral( "EPSG:3857" ) ); - double tform[] = - { + double tform[] = { extent.xMinimum(), extent.width() / nCols, 0.0, extent.yMaximum(), 0.0, -extent.height() / nRows }; - std::vector< QgsRasterAnalysisUtils::RasterLogicInput > inputs; + std::vector inputs; for ( int ii = 0; ii < 3; ++ii ) { // generate unique filename (need to open the file first to generate it) @@ -2398,13 +2377,13 @@ void TestQgsProcessingAlgsPt1::rasterLogicOp() // create a GeoTIFF - this will create data provider in editable mode const QString filename = tmpFile.fileName(); - std::unique_ptr< QgsRasterFileWriter > writer = std::make_unique< QgsRasterFileWriter >( filename ); + std::unique_ptr writer = std::make_unique( filename ); writer->setOutputProviderKey( QStringLiteral( "gdal" ) ); writer->setOutputFormat( QStringLiteral( "GTiff" ) ); - std::unique_ptr dp( writer->createOneBandRaster( Qgis::DataType::Float32, nCols, nRows, input[ii].empty() ? badExtent : extent, crs ) ); + std::unique_ptr dp( writer->createOneBandRaster( Qgis::DataType::Float32, nCols, nRows, input[ii].empty() ? badExtent : extent, crs ) ); QVERIFY( dp->isValid() ); dp->setNoDataValue( 1, -9999 ); - std::unique_ptr< QgsRasterBlock > block( dp->block( 1, input[ii].empty() ? badExtent : extent, nCols, nRows ) ); + std::unique_ptr block( dp->block( 1, input[ii].empty() ? badExtent : extent, nCols, nRows ) ); if ( !dp->isEditable() ) { QVERIFY( dp->setEditable( true ) ); @@ -2436,7 +2415,7 @@ void TestQgsProcessingAlgsPt1::rasterLogicOp() // create a GeoTIFF - this will create data provider in editable mode QString filename = tmpFile2.fileName(); - std::unique_ptr< QgsRasterDataProvider > dpOr( QgsRasterDataProvider::create( QStringLiteral( "gdal" ), filename, QStringLiteral( "GTiff" ), 1, static_cast< Qgis::DataType >( dataType ), 10, 10, tform, crs ) ); + std::unique_ptr dpOr( QgsRasterDataProvider::create( QStringLiteral( "gdal" ), filename, QStringLiteral( "GTiff" ), 1, static_cast( dataType ), 10, 10, tform, crs ) ); QVERIFY( dpOr->isValid() ); // make destination AND raster @@ -2446,23 +2425,22 @@ void TestQgsProcessingAlgsPt1::rasterLogicOp() // create a GeoTIFF - this will create data provider in editable mode filename = tmpFile3.fileName(); - std::unique_ptr< QgsRasterDataProvider > dpAnd( QgsRasterDataProvider::create( QStringLiteral( "gdal" ), filename, QStringLiteral( "GTiff" ), 1, static_cast< Qgis::DataType >( dataType ), 10, 10, tform, crs ) ); + std::unique_ptr dpAnd( QgsRasterDataProvider::create( QStringLiteral( "gdal" ), filename, QStringLiteral( "GTiff" ), 1, static_cast( dataType ), 10, 10, tform, crs ) ); QVERIFY( dpAnd->isValid() ); QgsFeedback feedback; qgssize noDataCount = 0; qgssize trueCount = 0; qgssize falseCount = 0; - QgsRasterAnalysisUtils::applyRasterLogicOperator( inputs, dpOr.get(), destNoDataValue, treatNodataAsFalse, nCols, nRows, - extent, &feedback, orAlg.mExtractValFunc, noDataCount, trueCount, falseCount ); + QgsRasterAnalysisUtils::applyRasterLogicOperator( inputs, dpOr.get(), destNoDataValue, treatNodataAsFalse, nCols, nRows, extent, &feedback, orAlg.mExtractValFunc, noDataCount, trueCount, falseCount ); QCOMPARE( noDataCount, expectedOrNoDataCount ); QCOMPARE( trueCount, expectedOrTrueCount ); QCOMPARE( falseCount, expectedOrFalseCount ); // read back in values - std::unique_ptr< QgsRasterBlock > block( dpOr->block( 1, extent, nCols, nRows ) ); - QVector< double > res( nCols * nRows ); + std::unique_ptr block( dpOr->block( 1, extent, nCols, nRows ) ); + QVector res( nCols * nRows ); int i = 0; for ( int row = 0; row < nRows; row++ ) { @@ -2483,8 +2461,7 @@ void TestQgsProcessingAlgsPt1::rasterLogicOp() noDataCount = 0; trueCount = 0; falseCount = 0; - QgsRasterAnalysisUtils::applyRasterLogicOperator( inputs, dpAnd.get(), destNoDataValue, treatNodataAsFalse, nCols, nRows, - extent, &feedback, andAlg.mExtractValFunc, noDataCount, trueCount, falseCount ); + QgsRasterAnalysisUtils::applyRasterLogicOperator( inputs, dpAnd.get(), destNoDataValue, treatNodataAsFalse, nCols, nRows, extent, &feedback, andAlg.mExtractValFunc, noDataCount, trueCount, falseCount ); QCOMPARE( noDataCount, expectedAndNoDataCount ); QCOMPARE( trueCount, expectedAndTrueCount ); @@ -2492,7 +2469,7 @@ void TestQgsProcessingAlgsPt1::rasterLogicOp() // read back in values block.reset( dpAnd->block( 1, extent, nCols, nRows ) ); - QVector< double > res2( nCols * nRows ); + QVector res2( nCols * nRows ); i = 0; for ( int row = 0; row < nRows; row++ ) { @@ -2524,211 +2501,210 @@ void TestQgsProcessingAlgsPt1::cellStatistics_data() * Testcase 1: sum */ QTest::newRow( "testcase_1" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 0 - << false - << QStringLiteral( "/cellstatistics_sum_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 0 + << false + << QStringLiteral( "/cellstatistics_sum_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 2: count */ QTest::newRow( "testcase_2" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 1 - << false - << QStringLiteral( "/cellstatistics_count_result.tif" ) - << Qgis::DataType::Int32; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 1 + << false + << QStringLiteral( "/cellstatistics_count_result.tif" ) + << Qgis::DataType::Int32; /* * Testcase 3: mean */ QTest::newRow( "testcase_3" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 2 - << false - << QStringLiteral( "/cellstatistics_mean_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 2 + << false + << QStringLiteral( "/cellstatistics_mean_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 4: median */ QTest::newRow( "testcase_4" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 3 - << false - << QStringLiteral( "/cellstatistics_median_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 3 + << false + << QStringLiteral( "/cellstatistics_median_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 5: Standard deviation */ QTest::newRow( "testcase_5" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 4 - << false - << QStringLiteral( "/cellstatistics_stddev_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 4 + << false + << QStringLiteral( "/cellstatistics_stddev_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 6: Variance */ QTest::newRow( "testcase_6" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 5 - << false - << QStringLiteral( "/cellstatistics_variance_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 5 + << false + << QStringLiteral( "/cellstatistics_variance_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 7: Minimum */ QTest::newRow( "testcase_7" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 6 - << false - << QStringLiteral( "/cellstatistics_min_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 6 + << false + << QStringLiteral( "/cellstatistics_min_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 8: Maximum */ QTest::newRow( "testcase_8" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 7 - << false - << QStringLiteral( "/cellstatistics_max_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 7 + << false + << QStringLiteral( "/cellstatistics_max_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 9: Minority */ QTest::newRow( "testcase_9" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 8 - << false - << QStringLiteral( "/cellstatistics_minority_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 8 + << false + << QStringLiteral( "/cellstatistics_minority_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 10: Majority */ QTest::newRow( "testcase_10" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 9 - << false - << QStringLiteral( "/cellstatistics_majority_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 9 + << false + << QStringLiteral( "/cellstatistics_majority_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 11: Range */ QTest::newRow( "testcase_11" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 10 - << false - << QStringLiteral( "/cellstatistics_range_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 10 + << false + << QStringLiteral( "/cellstatistics_range_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 12: Variety */ QTest::newRow( "testcase_12" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 11 - << false - << QStringLiteral( "/cellstatistics_variety_result.tif" ) - << Qgis::DataType::Int32; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 11 + << false + << QStringLiteral( "/cellstatistics_variety_result.tif" ) + << Qgis::DataType::Int32; /* * Testcase 13: Sum (integer) */ QTest::newRow( "testcase_13" ) - << QStringList( {"/raster/statisticsRas1_int32.tif", "/raster/statisticsRas2_int32.tif", "/raster/statisticsRas3_int32.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_int32.tif" ) - << 0 - << false - << QStringLiteral( "/cellstatistics_sum_result_int32.tif" ) - << Qgis::DataType::Int32; + << QStringList( { "/raster/statisticsRas1_int32.tif", "/raster/statisticsRas2_int32.tif", "/raster/statisticsRas3_int32.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_int32.tif" ) + << 0 + << false + << QStringLiteral( "/cellstatistics_sum_result_int32.tif" ) + << Qgis::DataType::Int32; /* * Testcase 14: sum (ignore nodata) */ QTest::newRow( "testcase_14" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 0 - << true - << QStringLiteral( "/cellstatistics_sum_ignore_nodata_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 0 + << true + << QStringLiteral( "/cellstatistics_sum_ignore_nodata_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 15: mean */ QTest::newRow( "testcase_15" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 2 - << true - << QStringLiteral( "/cellstatistics_mean_ignore_nodata_result.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 2 + << true + << QStringLiteral( "/cellstatistics_mean_ignore_nodata_result.tif" ) + << Qgis::DataType::Float64; /* * Testcase 16: Sum (integer) */ QTest::newRow( "testcase_16" ) - << QStringList( {"/raster/statisticsRas1_int32.tif", "/raster/statisticsRas2_int32.tif", "/raster/statisticsRas3_int32.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_int32.tif" ) - << 5 - << false - << QStringLiteral( "/cellstatistics_variance_result_float32.tif" ) - << Qgis::DataType::Float32; + << QStringList( { "/raster/statisticsRas1_int32.tif", "/raster/statisticsRas2_int32.tif", "/raster/statisticsRas3_int32.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_int32.tif" ) + << 5 + << false + << QStringLiteral( "/cellstatistics_variance_result_float32.tif" ) + << Qgis::DataType::Float32; /* * Testcase 17: median with even number of layers */ QTest::newRow( "testcase_17" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 3 - << false - << QStringLiteral( "/cellstatistics_median_result_fourLayers.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 3 + << false + << QStringLiteral( "/cellstatistics_median_result_fourLayers.tif" ) + << Qgis::DataType::Float64; /* * Testcase 18: median with even number of layers and integer inputs */ QTest::newRow( "testcase_18" ) - << QStringList( {"/raster/statisticsRas1_int32.tif", "/raster/statisticsRas1_int32.tif", "/raster/statisticsRas2_int32.tif", "/raster/statisticsRas3_int32.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_int32.tif" ) - << 3 - << false - << QStringLiteral( "/cellstatistics_median_result_fourLayers_float32.tif" ) - << Qgis::DataType::Float32; + << QStringList( { "/raster/statisticsRas1_int32.tif", "/raster/statisticsRas1_int32.tif", "/raster/statisticsRas2_int32.tif", "/raster/statisticsRas3_int32.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_int32.tif" ) + << 3 + << false + << QStringLiteral( "/cellstatistics_median_result_fourLayers_float32.tif" ) + << Qgis::DataType::Float32; /* * Testcase 19: sum with raster cell stacks containing only nodata */ QTest::newRow( "testcase_19" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas1_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas3_int32.tif" ) - << 0 - << true - << QStringLiteral( "/cellstatistics_sum_result_ignoreNoData.tif" ) - << Qgis::DataType::Float64; - + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas1_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas3_int32.tif" ) + << 0 + << true + << QStringLiteral( "/cellstatistics_sum_result_ignoreNoData.tif" ) + << Qgis::DataType::Float64; } void TestQgsProcessingAlgsPt1::cellStatistics() @@ -2743,7 +2719,7 @@ void TestQgsProcessingAlgsPt1::cellStatistics() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstatistics" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstatistics" ) ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -2754,13 +2730,13 @@ void TestQgsProcessingAlgsPt1::cellStatistics() inputDatasetPaths << myDataPath + raster; } - std::unique_ptr inputRasterLayer1 = std::make_unique< QgsRasterLayer >( myDataPath + inputRasters[0], "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer1 = std::make_unique( myDataPath + inputRasters[0], "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer1->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -2772,8 +2748,8 @@ void TestQgsProcessingAlgsPt1::cellStatistics() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images/expected_cellStatistics/" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images/expected_cellStatistics/" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -2787,8 +2763,8 @@ void TestQgsProcessingAlgsPt1::cellStatistics() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); @@ -2805,11 +2781,10 @@ void TestQgsProcessingAlgsPt1::cellStatistics() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -2832,22 +2807,22 @@ void TestQgsProcessingAlgsPt1::percentileFunctions_data() QTest::addColumn>( "expectedValues" ); QTest::newRow( "testcase_1" ) - << QgsRasterAnalysisUtils::NearestRankPercentile - << std::vector( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} ) - << std::vector( {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1} ) - << std::vector( {2, 2, 18, 20, 20, 24, 36, 49, 64, 98, 100} ); + << QgsRasterAnalysisUtils::NearestRankPercentile + << std::vector( { 100, 24, 49, 36, 2, 18, 98, 64, 20, 20 } ) + << std::vector( { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 } ) + << std::vector( { 2, 2, 18, 20, 20, 24, 36, 49, 64, 98, 100 } ); QTest::newRow( "testcase_2" ) - << QgsRasterAnalysisUtils::InterpolatedPercentileInc - << std::vector( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} ) - << std::vector( {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1} ) - << std::vector( {2.0, 16.4, 19.6, 20.0, 22.4, 30.0, 41.2, 53.5, 70.8, 98.2, 100} ); + << QgsRasterAnalysisUtils::InterpolatedPercentileInc + << std::vector( { 100, 24, 49, 36, 2, 18, 98, 64, 20, 20 } ) + << std::vector( { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 } ) + << std::vector( { 2.0, 16.4, 19.6, 20.0, 22.4, 30.0, 41.2, 53.5, 70.8, 98.2, 100 } ); QTest::newRow( "testcase_3" ) - << QgsRasterAnalysisUtils::InterpolatedPercentileExc - << std::vector( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} ) - << std::vector( {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1} ) - << std::vector( {-9999, 3.6, 18.4, 20, 21.6, 30, 43.8, 59.5, 91.2, 99.8, -9999} ); + << QgsRasterAnalysisUtils::InterpolatedPercentileExc + << std::vector( { 100, 24, 49, 36, 2, 18, 98, 64, 20, 20 } ) + << std::vector( { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 } ) + << std::vector( { -9999, 3.6, 18.4, 20, 21.6, 30, 43.8, 59.5, 91.2, 99.8, -9999 } ); } void TestQgsProcessingAlgsPt1::percentileFunctions() @@ -2904,125 +2879,85 @@ void TestQgsProcessingAlgsPt1::percentileRaster_data() * Testcase 1: nearest, ignoreNoData = true, dataType = Float64 */ QTest::newRow( "testcase_1" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 0 - << 0.789 - << true - << QStringLiteral( "/percentile_nearest_ignoreTrue_float64.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 0 + << 0.789 + << true + << QStringLiteral( "/percentile_nearest_ignoreTrue_float64.tif" ) + << Qgis::DataType::Float64; /* * Testcase 2: inc, ignoreNoData = true, dataType = Float64 */ QTest::newRow( "testcase_2" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 1 - << 0.789 - << true - << QStringLiteral( "/percentile_inc_ignoreTrue_float64.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 1 + << 0.789 + << true + << QStringLiteral( "/percentile_inc_ignoreTrue_float64.tif" ) + << Qgis::DataType::Float64; /* * Testcase 3: exc, ignoreNoData = true, dataType = Float64 */ QTest::newRow( "testcase_3" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 2 - << 0.789 - << true - << QStringLiteral( "/percentile_exc_ignoreTrue_float64.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 2 + << 0.789 + << true + << QStringLiteral( "/percentile_exc_ignoreTrue_float64.tif" ) + << Qgis::DataType::Float64; /* * Testcase 4: nearest, ignoreNoData = false, dataType = Float64 */ QTest::newRow( "testcase_4" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 0 - << 0.789 - << false - << QStringLiteral( "/percentile_nearest_ignoreFalse_float64.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 0 + << 0.789 + << false + << QStringLiteral( "/percentile_nearest_ignoreFalse_float64.tif" ) + << Qgis::DataType::Float64; /* * Testcase 5: inc, ignoreNoData = false, dataType = Float64 */ QTest::newRow( "testcase_5" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 1 - << 0.789 - << false - << QStringLiteral( "/percentile_inc_ignoreFalse_float64.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 1 + << 0.789 + << false + << QStringLiteral( "/percentile_inc_ignoreFalse_float64.tif" ) + << Qgis::DataType::Float64; /* * Testcase 6: exc, ignoreNoData = false, dataType = Float64 */ QTest::newRow( "testcase_6" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 2 - << 0.789 - << false - << QStringLiteral( "/percentile_exc_ignoreFalse_float64.tif" ) - << Qgis::DataType::Float64; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 2 + << 0.789 + << false + << QStringLiteral( "/percentile_exc_ignoreFalse_float64.tif" ) + << Qgis::DataType::Float64; /* * Testcase 7: exc, ignoreNoData = false, dataType = Byte */ QTest::newRow( "testcase_7" ) - << QStringList( {"/raster/rnd_percentile_raster1_byte.tif", - "/raster/rnd_percentile_raster2_byte.tif", - "/raster/rnd_percentile_raster3_byte.tif", - "/raster/rnd_percentile_raster4_byte.tif", - "/raster/rnd_percentile_raster5_byte.tif"} ) - << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) - << 0 - << 0.789 - << false - << QStringLiteral( "/percentile_nearest_ignoreFalse_byte.tif" ) - << Qgis::DataType::Byte; + << QStringList( { "/raster/rnd_percentile_raster1_byte.tif", "/raster/rnd_percentile_raster2_byte.tif", "/raster/rnd_percentile_raster3_byte.tif", "/raster/rnd_percentile_raster4_byte.tif", "/raster/rnd_percentile_raster5_byte.tif" } ) + << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) + << 0 + << 0.789 + << false + << QStringLiteral( "/percentile_nearest_ignoreFalse_byte.tif" ) + << Qgis::DataType::Byte; } @@ -3038,7 +2973,7 @@ void TestQgsProcessingAlgsPt1::percentileRaster() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstackpercentile" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstackpercentile" ) ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CMakeLists.txt @@ -3049,13 +2984,13 @@ void TestQgsProcessingAlgsPt1::percentileRaster() inputDatasetPaths << myDataPath + raster; } - std::unique_ptr inputRasterLayer1 = std::make_unique< QgsRasterLayer >( myDataPath + inputRasters[0], "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer1 = std::make_unique( myDataPath + inputRasters[0], "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer1->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -3068,8 +3003,8 @@ void TestQgsProcessingAlgsPt1::percentileRaster() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images/expected_cellStackPercentile/" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images/expected_cellStackPercentile/" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -3082,8 +3017,8 @@ void TestQgsProcessingAlgsPt1::percentileRaster() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); @@ -3100,11 +3035,10 @@ void TestQgsProcessingAlgsPt1::percentileRaster() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -3127,16 +3061,16 @@ void TestQgsProcessingAlgsPt1::percentrankFunctions_data() QTest::addColumn>( "expectedValues" ); QTest::newRow( "testcase_1" ) - << QgsRasterAnalysisUtils::InterpolatedPercentRankInc - << std::vector( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} ) - << std::vector( {-8, 2, 18, 20, 33, 47, 29, 39.5, 57, 39, 12, 100, 150} ) - << std::vector( {-9999, 0, 0.111111111111, 0.222222222222, 0.527777777778, 0.649572649573, 0.490740740741, 0.58547008547, 0.725925925926, 0.581196581197, 0.0694444444444, 1, -9999} ); + << QgsRasterAnalysisUtils::InterpolatedPercentRankInc + << std::vector( { 100, 24, 49, 36, 2, 18, 98, 64, 20, 20 } ) + << std::vector( { -8, 2, 18, 20, 33, 47, 29, 39.5, 57, 39, 12, 100, 150 } ) + << std::vector( { -9999, 0, 0.111111111111, 0.222222222222, 0.527777777778, 0.649572649573, 0.490740740741, 0.58547008547, 0.725925925926, 0.581196581197, 0.0694444444444, 1, -9999 } ); QTest::newRow( "testcase_2" ) - << QgsRasterAnalysisUtils::InterpolatedPercentRankExc - << std::vector( {100, 24, 49, 36, 2, 18, 98, 64, 20, 20} ) - << std::vector( {-8, 2, 18, 20, 33, 47, 29, 39.5, 57, 39, 12, 100, 150} ) - << std::vector( {-9999, 0.0909090909091, 0.1818181818181, 0.272727272727, 0.522727272727, 0.622377622378, 0.492424242424, 0.56993006993, 0.684848484848, 0.566433566434, 0.1477272727272, 0.909090909091, -9999} ); + << QgsRasterAnalysisUtils::InterpolatedPercentRankExc + << std::vector( { 100, 24, 49, 36, 2, 18, 98, 64, 20, 20 } ) + << std::vector( { -8, 2, 18, 20, 33, 47, 29, 39.5, 57, 39, 12, 100, 150 } ) + << std::vector( { -9999, 0.0909090909091, 0.1818181818181, 0.272727272727, 0.522727272727, 0.622377622378, 0.492424242424, 0.56993006993, 0.684848484848, 0.566433566434, 0.1477272727272, 0.909090909091, -9999 } ); } void TestQgsProcessingAlgsPt1::percentrankFunctions() @@ -3172,7 +3106,7 @@ void TestQgsProcessingAlgsPt1::percentrankFunctions() } } - std::vector cellVal = std::vector( {13, 36, 13, 44, 60} ); + std::vector cellVal = std::vector( { 13, 36, 13, 44, 60 } ); qDebug() << QgsRasterAnalysisUtils::interpolatedPercentRankInc( cellVal, 5, 13, 200 ); @@ -3195,100 +3129,72 @@ void TestQgsProcessingAlgsPt1::percentrankByRaster_data() * Testcase 1: nearest, ignoreNoData = true, dataType = Float64 */ QTest::newRow( "testcase_1" ) - << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 0 - << true - << -9999.0 - << QStringLiteral( "/percentRankByRaster_inc_ignoreTrue_float64.tif" ) - << Qgis::DataType::Float32; + << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 0 + << true + << -9999.0 + << QStringLiteral( "/percentRankByRaster_inc_ignoreTrue_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 2: inc, ignoreNoData = true, dataType = Float64 */ QTest::newRow( "testcase_2" ) - << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 1 - << true - << -9999.0 - << QStringLiteral( "/percentRankByRaster_exc_ignoreTrue_float64.tif" ) - << Qgis::DataType::Float32; + << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 1 + << true + << -9999.0 + << QStringLiteral( "/percentRankByRaster_exc_ignoreTrue_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 3: nearest, ignoreNoData = false, dataType = Float64 */ QTest::newRow( "testcase_3" ) - << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 0 - << false - << -9999.0 - << QStringLiteral( "/percentRankByRaster_inc_ignoreFalse_float64.tif" ) - << Qgis::DataType::Float32; + << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 0 + << false + << -9999.0 + << QStringLiteral( "/percentRankByRaster_inc_ignoreFalse_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 4: inc, ignoreNoData = false, dataType = Float64 */ QTest::newRow( "testcase_4" ) - << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 1 - << false - << -9999.0 - << QStringLiteral( "/percentRankByRaster_exc_ignoreFalse_float64.tif" ) - << Qgis::DataType::Float32; + << QStringLiteral( "/raster/rnd_percentrank_valueraster_float64.tif" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 1 + << false + << -9999.0 + << QStringLiteral( "/percentRankByRaster_exc_ignoreFalse_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 5: inc, ignoreNoData = false, dataType = Byte */ QTest::newRow( "testcase_5" ) - << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) - << 1 - << QStringList( {"/raster/rnd_percentile_raster1_byte.tif", - "/raster/rnd_percentile_raster2_byte.tif", - "/raster/rnd_percentile_raster3_byte.tif", - "/raster/rnd_percentile_raster4_byte.tif", - "/raster/rnd_percentile_raster5_byte.tif"} ) - << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) - << 0 - << false - << 200.0 - << QStringLiteral( "/percentRankByRaster_inc_ignoreFalse_byte.tif" ) - << Qgis::DataType::Float32; + << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) + << 1 + << QStringList( { "/raster/rnd_percentile_raster1_byte.tif", "/raster/rnd_percentile_raster2_byte.tif", "/raster/rnd_percentile_raster3_byte.tif", "/raster/rnd_percentile_raster4_byte.tif", "/raster/rnd_percentile_raster5_byte.tif" } ) + << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) + << 0 + << false + << 200.0 + << QStringLiteral( "/percentRankByRaster_inc_ignoreFalse_byte.tif" ) + << Qgis::DataType::Float32; } @@ -3306,7 +3212,7 @@ void TestQgsProcessingAlgsPt1::percentrankByRaster() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstackpercentrankfromrasterlayer" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstackpercentrankfromrasterlayer" ) ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CMakeLists.txt @@ -3317,13 +3223,13 @@ void TestQgsProcessingAlgsPt1::percentrankByRaster() inputDatasetPaths << myDataPath + raster; } - std::unique_ptr inputRasterLayer1 = std::make_unique< QgsRasterLayer >( myDataPath + inputRasters[0], "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer1 = std::make_unique( myDataPath + inputRasters[0], "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer1->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -3338,8 +3244,8 @@ void TestQgsProcessingAlgsPt1::percentrankByRaster() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images/expected_cellStackPercentrankFromRaster/" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images/expected_cellStackPercentrankFromRaster/" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -3352,8 +3258,8 @@ void TestQgsProcessingAlgsPt1::percentrankByRaster() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); @@ -3370,11 +3276,10 @@ void TestQgsProcessingAlgsPt1::percentrankByRaster() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -3403,95 +3308,67 @@ void TestQgsProcessingAlgsPt1::percentrankByValue_data() * Testcase 1: nearest, ignoreNoData = true, dataType = Float64 */ QTest::newRow( "testcase_1" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 83.327 - << 0 - << true - << -9999.0 - << QStringLiteral( "/percentRankByValue_inc_ignoreTrue_float64.tif" ) - << Qgis::DataType::Float32; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 83.327 + << 0 + << true + << -9999.0 + << QStringLiteral( "/percentRankByValue_inc_ignoreTrue_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 2: inc, ignoreNoData = true, dataType = Float64 */ QTest::newRow( "testcase_2" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 7.99 - << 1 - << true - << -9999.0 - << QStringLiteral( "/percentRankByValue_exc_ignoreTrue_float64.tif" ) - << Qgis::DataType::Float32; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 7.99 + << 1 + << true + << -9999.0 + << QStringLiteral( "/percentRankByValue_exc_ignoreTrue_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 3: nearest, ignoreNoData = false, dataType = Float64 */ QTest::newRow( "testcase_3" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 200.78 - << 0 - << false - << -9999.0 - << QStringLiteral( "/percentRankByValue_inc_ignoreFalse_float64.tif" ) - << Qgis::DataType::Float32; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 200.78 + << 0 + << false + << -9999.0 + << QStringLiteral( "/percentRankByValue_inc_ignoreFalse_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 4: inc, ignoreNoData = false, dataType = Float64 */ QTest::newRow( "testcase_4" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", - "/raster/statisticsRas4_float64.asc", - "/raster/rnd_percentile_raster1_float64.tif", - "/raster/rnd_percentile_raster2_float64.tif", - "/raster/rnd_percentile_raster3_float64.tif", - "/raster/rnd_percentile_raster4_float64.tif", - "/raster/rnd_percentile_raster5_float64.tif"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << 56.78 - << 1 - << false - << -9999.0 - << QStringLiteral( "/percentRankByValue_exc_ignoreFalse_float64.tif" ) - << Qgis::DataType::Float32; + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas4_float64.asc", "/raster/rnd_percentile_raster1_float64.tif", "/raster/rnd_percentile_raster2_float64.tif", "/raster/rnd_percentile_raster3_float64.tif", "/raster/rnd_percentile_raster4_float64.tif", "/raster/rnd_percentile_raster5_float64.tif" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << 56.78 + << 1 + << false + << -9999.0 + << QStringLiteral( "/percentRankByValue_exc_ignoreFalse_float64.tif" ) + << Qgis::DataType::Float32; /* * Testcase 5: inc, ignoreNoData = false, dataType = Byte */ QTest::newRow( "testcase_5" ) - << QStringList( {"/raster/rnd_percentile_raster1_byte.tif", - "/raster/rnd_percentile_raster2_byte.tif", - "/raster/rnd_percentile_raster3_byte.tif", - "/raster/rnd_percentile_raster4_byte.tif", - "/raster/rnd_percentile_raster5_byte.tif"} ) - << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) - << 19.0 - << 0 - << false - << 200.0 - << QStringLiteral( "/percentRankByValue_inc_ignoreFalse_byte.tif" ) - << Qgis::DataType::Float32; + << QStringList( { "/raster/rnd_percentile_raster1_byte.tif", "/raster/rnd_percentile_raster2_byte.tif", "/raster/rnd_percentile_raster3_byte.tif", "/raster/rnd_percentile_raster4_byte.tif", "/raster/rnd_percentile_raster5_byte.tif" } ) + << QStringLiteral( "/raster/rnd_percentile_raster1_byte.tif" ) + << 19.0 + << 0 + << false + << 200.0 + << QStringLiteral( "/percentRankByValue_inc_ignoreFalse_byte.tif" ) + << Qgis::DataType::Float32; } @@ -3508,7 +3385,7 @@ void TestQgsProcessingAlgsPt1::percentrankByValue() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstackpercentrankfromvalue" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:cellstackpercentrankfromvalue" ) ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CMakeLists.txt @@ -3519,13 +3396,13 @@ void TestQgsProcessingAlgsPt1::percentrankByValue() inputDatasetPaths << myDataPath + raster; } - std::unique_ptr inputRasterLayer1 = std::make_unique< QgsRasterLayer >( myDataPath + inputRasters[0], "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer1 = std::make_unique( myDataPath + inputRasters[0], "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer1->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -3539,8 +3416,8 @@ void TestQgsProcessingAlgsPt1::percentrankByValue() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images/expected_cellStackPercentrankFromValue/" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images/expected_cellStackPercentrankFromValue/" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -3553,8 +3430,8 @@ void TestQgsProcessingAlgsPt1::percentrankByValue() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); @@ -3571,11 +3448,10 @@ void TestQgsProcessingAlgsPt1::percentrankByValue() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -3603,142 +3479,142 @@ void TestQgsProcessingAlgsPt1::rasterFrequencyByComparisonOperator_data() * Testcase 1 - equal to frequency: don't ignore NoData */ QTest::newRow( "testcase_1" ) - << QStringLiteral( "native:equaltofrequency" ) - << QStringLiteral( "/raster/valueRas1_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest1.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:equaltofrequency" ) + << QStringLiteral( "/raster/valueRas1_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest1.tif" ) + << Qgis::DataType::Int32; /* * Testcase 2 - equal to frequency: ignore NoData */ QTest::newRow( "testcase_2" ) - << QStringLiteral( "native:equaltofrequency" ) - << QStringLiteral( "/raster/valueRas1_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << true - << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest2.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:equaltofrequency" ) + << QStringLiteral( "/raster/valueRas1_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << true + << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest2.tif" ) + << Qgis::DataType::Int32; /* * Testcase 3 - equal to frequency: NoData in value raster */ QTest::newRow( "testcase_3" ) - << QStringLiteral( "native:equaltofrequency" ) - << QStringLiteral( "/raster/valueRas2_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest3.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:equaltofrequency" ) + << QStringLiteral( "/raster/valueRas2_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest3.tif" ) + << Qgis::DataType::Int32; /* * Testcase 4 - equal to frequency: test with random byte raster */ QTest::newRow( "testcase_4" ) - << QStringLiteral( "native:equaltofrequency" ) - << QStringLiteral( "/raster/valueRas3_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest4.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:equaltofrequency" ) + << QStringLiteral( "/raster/valueRas3_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_equalToFrequency/equalToFrequencyTest4.tif" ) + << Qgis::DataType::Int32; /* * Testcase 5 - greater than frequency: don't ignore NoData */ QTest::newRow( "testcase_5" ) - << QStringLiteral( "native:greaterthanfrequency" ) - << QStringLiteral( "/raster/valueRas1_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest1.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:greaterthanfrequency" ) + << QStringLiteral( "/raster/valueRas1_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest1.tif" ) + << Qgis::DataType::Int32; /* * Testcase 6 - greater than frequency: ignore NoData */ QTest::newRow( "testcase_6" ) - << QStringLiteral( "native:greaterthanfrequency" ) - << QStringLiteral( "/raster/valueRas1_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << true - << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest2.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:greaterthanfrequency" ) + << QStringLiteral( "/raster/valueRas1_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << true + << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest2.tif" ) + << Qgis::DataType::Int32; /* * Testcase 7 - greater than frequency: NoData in value raster */ QTest::newRow( "testcase_7" ) - << QStringLiteral( "native:greaterthanfrequency" ) - << QStringLiteral( "/raster/valueRas2_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest3.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:greaterthanfrequency" ) + << QStringLiteral( "/raster/valueRas2_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest3.tif" ) + << Qgis::DataType::Int32; /* * Testcase 8 - greater than frequency: test with random byte raster */ QTest::newRow( "testcase_8" ) - << QStringLiteral( "native:greaterthanfrequency" ) - << QStringLiteral( "/raster/valueRas3_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest4.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:greaterthanfrequency" ) + << QStringLiteral( "/raster/valueRas3_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_greaterThanFrequency/greaterThanFrequencyTest4.tif" ) + << Qgis::DataType::Int32; /* * Testcase 9 - less than frequency: don't ignore NoData */ QTest::newRow( "testcase_9" ) - << QStringLiteral( "native:lessthanfrequency" ) - << QStringLiteral( "/raster/valueRas1_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest1.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:lessthanfrequency" ) + << QStringLiteral( "/raster/valueRas1_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest1.tif" ) + << Qgis::DataType::Int32; /* * Testcase 10 - greater than frequency: ignore NoData */ QTest::newRow( "testcase_10" ) - << QStringLiteral( "native:lessthanfrequency" ) - << QStringLiteral( "/raster/valueRas1_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << true - << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest2.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:lessthanfrequency" ) + << QStringLiteral( "/raster/valueRas1_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << true + << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest2.tif" ) + << Qgis::DataType::Int32; /* * Testcase 11 - less than frequency: NoData in value raster */ QTest::newRow( "testcase_11" ) - << QStringLiteral( "native:lessthanfrequency" ) - << QStringLiteral( "/raster/valueRas2_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest3.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:lessthanfrequency" ) + << QStringLiteral( "/raster/valueRas2_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest3.tif" ) + << Qgis::DataType::Int32; /* * Testcase 12 - less than frequency: test with random byte raster */ QTest::newRow( "testcase_12" ) - << QStringLiteral( "native:lessthanfrequency" ) - << QStringLiteral( "/raster/valueRas3_float64.asc" ) - << 1 - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << false - << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest4.tif" ) - << Qgis::DataType::Int32; + << QStringLiteral( "native:lessthanfrequency" ) + << QStringLiteral( "/raster/valueRas3_float64.asc" ) + << 1 + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << false + << QStringLiteral( "/expected_lessThanFrequency/lessThanFrequencyTest4.tif" ) + << Qgis::DataType::Int32; } void TestQgsProcessingAlgsPt1::rasterFrequencyByComparisonOperator() @@ -3753,7 +3629,7 @@ void TestQgsProcessingAlgsPt1::rasterFrequencyByComparisonOperator() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( algName ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( algName ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -3764,13 +3640,13 @@ void TestQgsProcessingAlgsPt1::rasterFrequencyByComparisonOperator() inputDatasetPaths << myDataPath + raster; } - std::unique_ptr inputRasterLayer1 = std::make_unique< QgsRasterLayer >( myDataPath + inputRasters[0], "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer1 = std::make_unique( myDataPath + inputRasters[0], "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer1->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -3782,8 +3658,8 @@ void TestQgsProcessingAlgsPt1::rasterFrequencyByComparisonOperator() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -3797,8 +3673,8 @@ void TestQgsProcessingAlgsPt1::rasterFrequencyByComparisonOperator() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); @@ -3815,11 +3691,10 @@ void TestQgsProcessingAlgsPt1::rasterFrequencyByComparisonOperator() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -3846,46 +3721,46 @@ void TestQgsProcessingAlgsPt1::rasterLocalPosition_data() QTest::addColumn( "expectedRaster" ); QTest::newRow( "testcase_1" ) - << QStringLiteral( "native:lowestpositioninrasterstack" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << false - << QStringLiteral( "/expected_lowestPosition/expectedLowestPositionTest1.tif" ); + << QStringLiteral( "native:lowestpositioninrasterstack" ) + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << false + << QStringLiteral( "/expected_lowestPosition/expectedLowestPositionTest1.tif" ); QTest::newRow( "testcase_2" ) - << QStringLiteral( "native:lowestpositioninrasterstack" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << true - << QStringLiteral( "/expected_lowestPosition/expectedLowestPositionTest2.tif" ); + << QStringLiteral( "native:lowestpositioninrasterstack" ) + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << true + << QStringLiteral( "/expected_lowestPosition/expectedLowestPositionTest2.tif" ); QTest::newRow( "testcase_3" ) - << QStringLiteral( "native:lowestpositioninrasterstack" ) - << QStringList( {"/raster/statisticsRas2_float64.asc", "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << false - << QStringLiteral( "/expected_lowestPosition/expectedLowestPositionTest3.tif" ); + << QStringLiteral( "native:lowestpositioninrasterstack" ) + << QStringList( { "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << false + << QStringLiteral( "/expected_lowestPosition/expectedLowestPositionTest3.tif" ); QTest::newRow( "testcase_4" ) - << QStringLiteral( "native:highestpositioninrasterstack" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << false - << QStringLiteral( "/expected_highestPosition/expectedHighestPositionTest1.tif" ); + << QStringLiteral( "native:highestpositioninrasterstack" ) + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << false + << QStringLiteral( "/expected_highestPosition/expectedHighestPositionTest1.tif" ); QTest::newRow( "testcase_5" ) - << QStringLiteral( "native:highestpositioninrasterstack" ) - << QStringList( {"/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << true - << QStringLiteral( "/expected_highestPosition/expectedHighestPositionTest2.tif" ); + << QStringLiteral( "native:highestpositioninrasterstack" ) + << QStringList( { "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << true + << QStringLiteral( "/expected_highestPosition/expectedHighestPositionTest2.tif" ); QTest::newRow( "testcase_6" ) - << QStringLiteral( "native:highestpositioninrasterstack" ) - << QStringList( {"/raster/statisticsRas2_float64.asc", "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas3_float64.asc"} ) - << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) - << false - << QStringLiteral( "/expected_highestPosition/expectedHighestPositionTest3.tif" ); + << QStringLiteral( "native:highestpositioninrasterstack" ) + << QStringList( { "/raster/statisticsRas2_float64.asc", "/raster/statisticsRas1_float64.asc", "/raster/statisticsRas3_float64.asc" } ) + << QStringLiteral( "/raster/statisticsRas1_float64.asc" ) + << false + << QStringLiteral( "/expected_highestPosition/expectedHighestPositionTest3.tif" ); } void TestQgsProcessingAlgsPt1::rasterLocalPosition() @@ -3898,7 +3773,7 @@ void TestQgsProcessingAlgsPt1::rasterLocalPosition() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( algName ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( algName ) ); const QString myDataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -3909,13 +3784,13 @@ void TestQgsProcessingAlgsPt1::rasterLocalPosition() inputDatasetPaths << myDataPath + raster; } - std::unique_ptr inputRasterLayer1 = std::make_unique< QgsRasterLayer >( myDataPath + inputRasters[0], "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer1 = std::make_unique( myDataPath + inputRasters[0], "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer1->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -3926,8 +3801,8 @@ void TestQgsProcessingAlgsPt1::rasterLocalPosition() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( myDataPath + "/control_images" + expectedRaster, "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( myDataPath + "/control_images" + expectedRaster, "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -3940,8 +3815,8 @@ void TestQgsProcessingAlgsPt1::rasterLocalPosition() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); QCOMPARE( outputRaster->height(), expectedRasterLayer->height() ); @@ -3957,11 +3832,10 @@ void TestQgsProcessingAlgsPt1::rasterLocalPosition() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -3996,12 +3870,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = 2 */ QTest::newRow( "testcase 1" ) - << "/raster/dem.tif" - << QStringLiteral( "/roundRasterValues_testcase1.tif" ) //no output expected: can't round integer - << 1 - << 1 - << 2 - << 10; + << "/raster/dem.tif" + << QStringLiteral( "/roundRasterValues_testcase1.tif" ) //no output expected: can't round integer + << 1 + << 1 + << 2 + << 10; /* * Testcase 2 @@ -4012,12 +3886,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = 2 */ QTest::newRow( "testcase 2" ) - << "/raster/dem.tif" - << QStringLiteral( "/roundRasterValues_testcase2.tif" ) - << 1 - << 0 - << 2 - << 10; + << "/raster/dem.tif" + << QStringLiteral( "/roundRasterValues_testcase2.tif" ) + << 1 + << 0 + << 2 + << 10; /* * Testcase 3 @@ -4028,12 +3902,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = 1 */ QTest::newRow( "testcase 3" ) - << "/raster/dem.tif" - << QStringLiteral( "/roundRasterValues_testcase3.tif" ) - << 1 - << 2 - << 1 - << 10; + << "/raster/dem.tif" + << QStringLiteral( "/roundRasterValues_testcase3.tif" ) + << 1 + << 2 + << 1 + << 10; /* * Testcase 4 @@ -4044,12 +3918,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = -1 */ QTest::newRow( "testcase 4" ) - << "/raster/dem.tif" - << QStringLiteral( "/roundRasterValues_testcase4.tif" ) - << 1 - << 1 - << -1 - << 10; + << "/raster/dem.tif" + << QStringLiteral( "/roundRasterValues_testcase4.tif" ) + << 1 + << 1 + << -1 + << 10; /* * Testcase 5 @@ -4060,12 +3934,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = -1 */ QTest::newRow( "testcase 5" ) - << "/raster/dem.tif" - << QStringLiteral( "/roundRasterValues_testcase5.tif" ) - << 1 - << 0 - << -1 - << 10; + << "/raster/dem.tif" + << QStringLiteral( "/roundRasterValues_testcase5.tif" ) + << 1 + << 0 + << -1 + << 10; /* * Testcase 6 @@ -4076,12 +3950,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = -1 */ QTest::newRow( "testcase 6" ) - << "/raster/dem.tif" - << QStringLiteral( "/roundRasterValues_testcase6.tif" ) - << 1 - << 2 - << -1 - << 10; + << "/raster/dem.tif" + << QStringLiteral( "/roundRasterValues_testcase6.tif" ) + << 1 + << 2 + << -1 + << 10; /* * Testcase 7 @@ -4092,12 +3966,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = 2 */ QTest::newRow( "testcase 7" ) - << "/raster/band1_int16_noct_epsg4326.tif" - << QStringLiteral( "/roundRasterValues_testcase7.tif" ) - << 1 - << 1 - << -1 - << 10; + << "/raster/band1_int16_noct_epsg4326.tif" + << QStringLiteral( "/roundRasterValues_testcase7.tif" ) + << 1 + << 1 + << -1 + << 10; /* * Testcase 8 @@ -4108,13 +3982,12 @@ void TestQgsProcessingAlgsPt1::roundRasterValues_data() * decimals = -1 */ QTest::newRow( "testcase 8" ) - << "/raster/band1_int16_noct_epsg4326.tif" - << QStringLiteral( "/roundRasterValues_testcase8.tif" ) - << 1 - << 1 - << -1 - << 10; - + << "/raster/band1_int16_noct_epsg4326.tif" + << QStringLiteral( "/roundRasterValues_testcase8.tif" ) + << 1 + << 1 + << -1 + << 10; } void TestQgsProcessingAlgsPt1::roundRasterValues() @@ -4128,16 +4001,16 @@ void TestQgsProcessingAlgsPt1::roundRasterValues() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:roundrastervalues" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:roundrastervalues" ) ) ); const QString rasterSource = copyTestData( inputRaster ); - std::unique_ptr inputRasterLayer = std::make_unique< QgsRasterLayer >( rasterSource, "inputDataset", "gdal" ); + std::unique_ptr inputRasterLayer = std::make_unique( rasterSource, "inputDataset", "gdal" ); //set project crs and ellipsoid from input layer p.setCrs( inputRasterLayer->crs(), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -4150,8 +4023,8 @@ void TestQgsProcessingAlgsPt1::roundRasterValues() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); //prepare expectedRaster - std::unique_ptr expectedRasterLayer = std::make_unique< QgsRasterLayer >( testDataPath( "/control_images/roundRasterValues/" + expectedRaster ), "expectedDataset", "gdal" ); - std::unique_ptr< QgsRasterInterface > expectedInterface( expectedRasterLayer->dataProvider()->clone() ); + std::unique_ptr expectedRasterLayer = std::make_unique( testDataPath( "/control_images/roundRasterValues/" + expectedRaster ), "expectedDataset", "gdal" ); + std::unique_ptr expectedInterface( expectedRasterLayer->dataProvider()->clone() ); QgsRasterIterator expectedIter( expectedInterface.get() ); expectedIter.startRasterRead( 1, expectedRasterLayer->width(), expectedRasterLayer->height(), expectedInterface->extent() ); @@ -4165,8 +4038,8 @@ void TestQgsProcessingAlgsPt1::roundRasterValues() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputRaster->width(), expectedRasterLayer->width() ); QCOMPARE( outputRaster->height(), expectedRasterLayer->height() ); @@ -4182,11 +4055,10 @@ void TestQgsProcessingAlgsPt1::roundRasterValues() int expectedIterCols = 0; int expectedIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; - std::unique_ptr< QgsRasterBlock > expectedRasterBlock; + std::unique_ptr outputRasterBlock; + std::unique_ptr expectedRasterBlock; - while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && - expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) + while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) && expectedIter.readNextRasterPart( 1, expectedIterCols, expectedIterRows, expectedRasterBlock, expectedIterLeft, expectedIterTop ) ) { for ( int row = 0; row < expectedIterRows; row++ ) { @@ -4202,10 +4074,10 @@ void TestQgsProcessingAlgsPt1::roundRasterValues() void TestQgsProcessingAlgsPt1::layoutMapExtent() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:printlayoutmapextenttolayer" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:printlayoutmapextenttolayer" ) ) ); QVERIFY( alg != nullptr ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProject p; context->setProject( &p ); @@ -4256,7 +4128,7 @@ void TestQgsProcessingAlgsPt1::layoutMapExtent() QgsFeature f; QCOMPARE( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() )->crs().authid(), QStringLiteral( "EPSG:3111" ) ); - QVERIFY( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures().nextFeature( f ) ); + QVERIFY( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures().nextFeature( f ) ); QCOMPARE( f.attribute( 0 ).toString(), QStringLiteral( "m" ) ); QCOMPARE( f.attribute( 1 ).toDouble(), 150.0 ); QCOMPARE( f.attribute( 2 ).toDouble(), 180.0 ); @@ -4275,7 +4147,7 @@ void TestQgsProcessingAlgsPt1::layoutMapExtent() QVERIFY( !results.value( QStringLiteral( "ROTATION" ) ).isValid() ); QCOMPARE( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() )->crs().authid(), QStringLiteral( "EPSG:3785" ) ); - QgsFeatureIterator it = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); + QgsFeatureIterator it = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); QgsFeature f1; QVERIFY( it.nextFeature( f1 ) ); QgsFeature f2; @@ -4296,7 +4168,7 @@ void TestQgsProcessingAlgsPt1::layoutMapExtent() QCOMPARE( f.geometry().asWkt( 0 ), QStringLiteral( "Polygon ((7475 54040, 7525 54040, 7525 53960, 7475 53960, 7475 54040))" ) ); // crs override - parameters.insert( QStringLiteral( "CRS" ), QStringLiteral( "EPSG:3111" ) ); + parameters.insert( QStringLiteral( "CRS" ), QStringLiteral( "EPSG:3111" ) ); results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); @@ -4306,7 +4178,7 @@ void TestQgsProcessingAlgsPt1::layoutMapExtent() QVERIFY( !results.value( QStringLiteral( "ROTATION" ) ).isValid() ); QCOMPARE( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() )->crs().authid(), QStringLiteral( "EPSG:3111" ) ); - it = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); + it = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); QVERIFY( it.nextFeature( f1 ) ); QVERIFY( it.nextFeature( f2 ) ); f = f1.attribute( 0 ).toString() == QLatin1String( "m" ) ? f1 : f2; @@ -4323,7 +4195,6 @@ void TestQgsProcessingAlgsPt1::layoutMapExtent() QGSCOMPARENEAR( f.attribute( 3 ).toDouble(), 1000.0, 0.0001 ); QCOMPARE( f.attribute( 4 ).toDouble(), 0.0 ); QCOMPARE( f.geometry().asWkt( 0 ), QStringLiteral( "Polygon ((-10399464 -5347896, -10399461 -5347835, -10399364 -5347840, -10399367 -5347901, -10399464 -5347896))" ) ); - } void TestQgsProcessingAlgsPt1::styleFromProject() @@ -4353,10 +4224,9 @@ void TestQgsProcessingAlgsPt1::styleFromProject() // labeling QgsPalLayerSettings settings; settings.fieldName = QStringLiteral( "Class" ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! // raster layer - QgsRasterLayer *rl = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/tenbytenraster.asc", - QStringLiteral( "rl" ) ); + QgsRasterLayer *rl = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/tenbytenraster.asc", QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); p.addMapLayer( rl ); @@ -4383,17 +4253,17 @@ void TestQgsProcessingAlgsPt1::styleFromProject() QgsTextAnnotation *annotation = new QgsTextAnnotation(); QgsSymbol *a1 = QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ); a1->setColor( QColor( 0, 200, 0 ) ); - annotation->setMarkerSymbol( static_cast< QgsMarkerSymbol * >( a1 ) ); + annotation->setMarkerSymbol( static_cast( a1 ) ); QgsSymbol *a2 = QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ); a2->setColor( QColor( 200, 200, 0 ) ); - annotation->setFillSymbol( static_cast< QgsFillSymbol * >( a2 ) ); + annotation->setFillSymbol( static_cast( a2 ) ); p.annotationManager()->addAnnotation( annotation ); // ok, run alg - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:stylefromproject" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:stylefromproject" ) ) ); QVERIFY( alg != nullptr ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -4480,10 +4350,10 @@ void TestQgsProcessingAlgsPt1::combineStyles() QVERIFY( s2.exportXml( tmpFile2.fileName() ) ); // ok, run alg - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:combinestyles" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:combinestyles" ) ) ); QVERIFY( alg != nullptr ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap parameters; parameters.insert( QStringLiteral( "INPUT" ), QStringList() << tmpFile.fileName() << tmpFile2.fileName() ); @@ -4539,10 +4409,10 @@ void TestQgsProcessingAlgsPt1::bookmarksToLayer() p.bookmarkManager()->addBookmark( b3 ); // ok, run alg - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:bookmarkstolayer" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:bookmarkstolayer" ) ) ); QVERIFY( alg != nullptr ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -4559,7 +4429,7 @@ void TestQgsProcessingAlgsPt1::bookmarksToLayer() // check result QgsFeature f; QCOMPARE( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() )->crs().authid(), QStringLiteral( "EPSG:4326" ) ); - QgsFeatureIterator it = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); + QgsFeatureIterator it = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); QVERIFY( it.nextFeature( f ) ); QCOMPARE( f.attribute( 0 ).toString(), QStringLiteral( "test name 3" ) ); QCOMPARE( f.attribute( 1 ).toString(), QString() ); @@ -4573,7 +4443,7 @@ void TestQgsProcessingAlgsPt1::bookmarksToLayer() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() )->crs().authid(), QStringLiteral( "EPSG:4326" ) ); - it = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); + it = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); QVERIFY( it.nextFeature( f ) ); QCOMPARE( f.attribute( 0 ).toString(), QStringLiteral( "test name" ) ); QCOMPARE( f.attribute( 1 ).toString(), QStringLiteral( "test group" ) ); @@ -4591,7 +4461,7 @@ void TestQgsProcessingAlgsPt1::bookmarksToLayer() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() )->crs().authid(), QStringLiteral( "EPSG:4326" ) ); - it = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); + it = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->getFeatures(); QVERIFY( it.nextFeature( f ) ); QCOMPARE( f.attribute( 0 ).toString(), QStringLiteral( "test name 3" ) ); QCOMPARE( f.attribute( 1 ).toString(), QString() ); @@ -4605,7 +4475,6 @@ void TestQgsProcessingAlgsPt1::bookmarksToLayer() QCOMPARE( f.attribute( 1 ).toString(), QString() ); QCOMPARE( f.geometry().asWkt( 0 ), QStringLiteral( "Polygon ((146 -22, 146 -22, 146 -22, 146 -22, 146 -22, 146 -22, 146 -22, 146 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -22, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 147 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -21, 146 -22, 146 -22, 146 -22, 146 -22, 146 -22, 146 -22))" ) ); QVERIFY( !it.nextFeature( f ) ); - } void TestQgsProcessingAlgsPt1::layerToBookmarks() @@ -4624,11 +4493,11 @@ void TestQgsProcessingAlgsPt1::layerToBookmarks() QgsApplication::bookmarkManager()->clear(); // run alg - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:layertobookmarks" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:layertobookmarks" ) ) ); QVERIFY( alg != nullptr ); QgsProject p; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -4686,10 +4555,10 @@ void TestQgsProcessingAlgsPt1::repairShapefile() QFile::copy( dataDir + "/points.shp", tmpPath.filePath( QStringLiteral( "points.dbf" ) ) ); // no shx!! - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( tmpPath.filePath( QStringLiteral( "points.shp" ) ) ); + std::unique_ptr layer = std::make_unique( tmpPath.filePath( QStringLiteral( "points.shp" ) ) ); QVERIFY( !layer->isValid() ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:repairshapefile" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:repairshapefile" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -4697,7 +4566,7 @@ void TestQgsProcessingAlgsPt1::repairShapefile() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -4709,7 +4578,7 @@ void TestQgsProcessingAlgsPt1::repairShapefile() QVERIFY( ok ); QCOMPARE( results.value( QStringLiteral( "OUTPUT" ) ).toString(), tmpPath.filePath( QStringLiteral( "points.shp" ) ) ); - layer = std::make_unique< QgsVectorLayer >( tmpPath.filePath( QStringLiteral( "points.shp" ) ) ); + layer = std::make_unique( tmpPath.filePath( QStringLiteral( "points.shp" ) ) ); QVERIFY( layer->isValid() ); } @@ -4720,7 +4589,7 @@ void TestQgsProcessingAlgsPt1::renameField() QVERIFY( layer->isValid() ); p.addMapLayer( layer ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:renametablefield" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:renametablefield" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -4730,7 +4599,7 @@ void TestQgsProcessingAlgsPt1::renameField() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -4750,8 +4619,7 @@ void TestQgsProcessingAlgsPt1::renameField() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->fields().at( 1 ).name(), QStringLiteral( "newname" ) ); - + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) )->fields().at( 1 ).name(), QStringLiteral( "newname" ) ); } void TestQgsProcessingAlgsPt1::compareDatasets() @@ -4770,7 +4638,7 @@ void TestQgsProcessingAlgsPt1::compareDatasets() QVERIFY( differentAttrs->isValid() ); p.addMapLayer( differentAttrs ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:detectvectorchanges" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:detectvectorchanges" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -4780,7 +4648,7 @@ void TestQgsProcessingAlgsPt1::compareDatasets() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -4826,11 +4694,11 @@ void TestQgsProcessingAlgsPt1::compareDatasets() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( results.value( QStringLiteral( "UNCHANGED_COUNT" ) ).toLongLong(), 0LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "UNCHANGED" ) ).toString() ) )->featureCount(), 0L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "UNCHANGED" ) ).toString() ) )->featureCount(), 0L ); QCOMPARE( results.value( QStringLiteral( "ADDED_COUNT" ) ).toLongLong(), 0LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "ADDED" ) ).toString() ) )->featureCount(), 0L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "ADDED" ) ).toString() ) )->featureCount(), 0L ); QCOMPARE( results.value( QStringLiteral( "DELETED_COUNT" ) ).toLongLong(), 2LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "DELETED" ) ).toString() ) )->featureCount(), 2L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "DELETED" ) ).toString() ) )->featureCount(), 2L ); // add one same to revised - note that the first attributes differs here, but we aren't considering that f.setAttributes( QgsAttributes() << 55 << QStringLiteral( "b1" ) << QStringLiteral( "g1" ) ); @@ -4840,11 +4708,11 @@ void TestQgsProcessingAlgsPt1::compareDatasets() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( results.value( QStringLiteral( "UNCHANGED_COUNT" ) ).toLongLong(), 1LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "UNCHANGED" ) ).toString() ) )->featureCount(), 1L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "UNCHANGED" ) ).toString() ) )->featureCount(), 1L ); QCOMPARE( results.value( QStringLiteral( "ADDED_COUNT" ) ).toLongLong(), 0LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "ADDED" ) ).toString() ) )->featureCount(), 0L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "ADDED" ) ).toString() ) )->featureCount(), 0L ); QCOMPARE( results.value( QStringLiteral( "DELETED_COUNT" ) ).toLongLong(), 1LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "DELETED" ) ).toString() ) )->featureCount(), 1L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "DELETED" ) ).toString() ) )->featureCount(), 1L ); // ok, let's compare the differing attribute too parameters.insert( QStringLiteral( "COMPARE_ATTRIBUTES" ), QStringLiteral( "col1;col2;pk" ) ); @@ -4862,11 +4730,11 @@ void TestQgsProcessingAlgsPt1::compareDatasets() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( results.value( QStringLiteral( "UNCHANGED_COUNT" ) ).toLongLong(), 1LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "UNCHANGED" ) ).toString() ) )->featureCount(), 1L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "UNCHANGED" ) ).toString() ) )->featureCount(), 1L ); QCOMPARE( results.value( QStringLiteral( "ADDED_COUNT" ) ).toLongLong(), 1LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "ADDED" ) ).toString() ) )->featureCount(), 1L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "ADDED" ) ).toString() ) )->featureCount(), 1L ); QCOMPARE( results.value( QStringLiteral( "DELETED_COUNT" ) ).toLongLong(), 1LL ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "DELETED" ) ).toString() ) )->featureCount(), 1L ); + QCOMPARE( qobject_cast( context->getMapLayer( results.value( QStringLiteral( "DELETED" ) ).toString() ) )->featureCount(), 1L ); // note - we skip the featureCount checks after this -- we can be confident at this stage that all sinks are correctly being populated @@ -4939,12 +4807,11 @@ void TestQgsProcessingAlgsPt1::compareDatasets() QCOMPARE( results.value( QStringLiteral( "UNCHANGED_COUNT" ) ).toLongLong(), 4LL ); QCOMPARE( results.value( QStringLiteral( "ADDED_COUNT" ) ).toLongLong(), 2LL ); QCOMPARE( results.value( QStringLiteral( "DELETED_COUNT" ) ).toLongLong(), 1LL ); - } void TestQgsProcessingAlgsPt1::shapefileEncoding() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:shpencodinginfo" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:shpencodinginfo" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -4952,7 +4819,7 @@ void TestQgsProcessingAlgsPt1::shapefileEncoding() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -4981,14 +4848,14 @@ void TestQgsProcessingAlgsPt1::shapefileEncoding() void TestQgsProcessingAlgsPt1::setLayerEncoding() { - QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( TEST_DATA_DIR ) + "/shapefile/system_encoding.shp", - QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( TEST_DATA_DIR ) + "/shapefile/system_encoding.shp", QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); QVERIFY( vl->isValid() ); QgsProject p; p.addMapLayers( - QList() << vl ); + QList() << vl + ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:setlayerencoding" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:setlayerencoding" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -4996,7 +4863,7 @@ void TestQgsProcessingAlgsPt1::setLayerEncoding() bool ok = false; QgsProcessingFeedback feedback; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap results; @@ -5008,14 +4875,12 @@ void TestQgsProcessingAlgsPt1::setLayerEncoding() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QCOMPARE( vl->dataProvider()->encoding(), QStringLiteral( "ISO-8859-1" ) ); - } class TestProcessingFeedback : public QgsProcessingFeedback { Q_OBJECT public: - void reportError( const QString &error, bool ) override { errors << error; @@ -5032,21 +4897,20 @@ class TestProcessingFeedback : public QgsProcessingFeedback QStringList errors; QStringList warnings; QStringList messages; - }; void TestQgsProcessingAlgsPt1::raiseException() { TestProcessingFeedback feedback; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:raiseexception" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:raiseexception" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; parameters.insert( QStringLiteral( "MESSAGE" ), QStringLiteral( "you done screwed up boy" ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -5073,14 +4937,14 @@ void TestQgsProcessingAlgsPt1::raiseWarning() { TestProcessingFeedback feedback; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:raisewarning" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:raisewarning" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; parameters.insert( QStringLiteral( "MESSAGE" ), QStringLiteral( "you mighta screwed up boy, but i aint so sure" ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -5107,14 +4971,14 @@ void TestQgsProcessingAlgsPt1::raiseMessage() { TestProcessingFeedback feedback; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:raisemessage" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:raisemessage" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; parameters.insert( QStringLiteral( "MESSAGE" ), QStringLiteral( "nothing screwed up boy, congrats" ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -5147,21 +5011,21 @@ void TestQgsProcessingAlgsPt1::randomFloatingPointDistributionRaster_data() QTest::addColumn( "typeId" ); QTest::newRow( "testcase 1" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Float32 - << true - << "EPSG:4326" - << 1.0 - << 0; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Float32 + << true + << "EPSG:4326" + << 1.0 + << 0; QTest::newRow( "testcase 2" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Float64 - << true - << "EPSG:4326" - << 1.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Float64 + << true + << "EPSG:4326" + << 1.0 + << 1; } void TestQgsProcessingAlgsPt1::randomFloatingPointDistributionRaster() @@ -5189,9 +5053,9 @@ void TestQgsProcessingAlgsPt1::randomFloatingPointDistributionRaster() { const QString algname = alglist[i]; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( algname ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( algname ) ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -5219,8 +5083,8 @@ void TestQgsProcessingAlgsPt1::randomFloatingPointDistributionRaster() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); } @@ -5238,53 +5102,53 @@ void TestQgsProcessingAlgsPt1::randomIntegerDistributionRaster_data() QTest::addColumn( "typeId" ); QTest::newRow( "testcase 1" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int16 - << true - << "EPSG:4326" - << 1.0 - << 0; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int16 + << true + << "EPSG:4326" + << 1.0 + << 0; QTest::newRow( "testcase 2" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt16 - << true - << "EPSG:4326" - << 1.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt16 + << true + << "EPSG:4326" + << 1.0 + << 1; QTest::newRow( "testcase 3" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int32 - << true - << "EPSG:4326" - << 1.0 - << 2; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int32 + << true + << "EPSG:4326" + << 1.0 + << 2; QTest::newRow( "testcase 4" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt32 - << true - << "EPSG:4326" - << 1.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt32 + << true + << "EPSG:4326" + << 1.0 + << 3; QTest::newRow( "testcase 5" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Float32 - << true - << "EPSG:4326" - << 1.0 - << 4; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Float32 + << true + << "EPSG:4326" + << 1.0 + << 4; QTest::newRow( "testcase 6" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Float64 - << true - << "EPSG:4326" - << 1.0 - << 5; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Float64 + << true + << "EPSG:4326" + << 1.0 + << 5; } @@ -5314,9 +5178,9 @@ void TestQgsProcessingAlgsPt1::randomIntegerDistributionRaster() { const QString algname = alglist[i]; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( algname ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( algname ) ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -5344,8 +5208,8 @@ void TestQgsProcessingAlgsPt1::randomIntegerDistributionRaster() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); } @@ -5365,186 +5229,184 @@ void TestQgsProcessingAlgsPt1::randomRaster_data() QTest::newRow( "testcase 1" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Byte - << true - << "EPSG:4326" - << 1.0 - << 1.0 - << 1.0 //should be min max - << 0; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Byte + << true + << "EPSG:4326" + << 1.0 + << 1.0 + << 1.0 //should be min max + << 0; QTest::newRow( "testcase 2" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Byte - << false - << "EPSG:4326" - << 1.0 - << -1.0 //fails --> value too small for byte - << 10.0 //fails --> value too large - << 0; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Byte + << false + << "EPSG:4326" + << 1.0 + << -1.0 //fails --> value too small for byte + << 10.0 //fails --> value too large + << 0; QTest::newRow( "testcase 3" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Byte - << false - << "EPSG:4326" - << 1.0 - << 1.0 - << 256.0 //fails --> value too big for byte - << 0; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Byte + << false + << "EPSG:4326" + << 1.0 + << 1.0 + << 256.0 //fails --> value too big for byte + << 0; QTest::newRow( "testcase 4" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int16 - << true - << "EPSG:4326" - << 1.0 - << 1.0 - << 10.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int16 + << true + << "EPSG:4326" + << 1.0 + << 1.0 + << 10.0 + << 1; QTest::newRow( "testcase 5" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int16 - << false - << "EPSG:4326" - << 1.0 - << -32769.0 - << -10.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int16 + << false + << "EPSG:4326" + << 1.0 + << -32769.0 + << -10.0 + << 1; QTest::newRow( "testcase 6" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int16 - << false - << "EPSG:4326" - << 1.0 - << 1.0 - << 32769.0 - << 1; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int16 + << false + << "EPSG:4326" + << 1.0 + << 1.0 + << 32769.0 + << 1; QTest::newRow( "testcase 7" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt16 - << false - << "EPSG:4326" - << 1.0 - << -1.0 - << 12.0 - << 2; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt16 + << false + << "EPSG:4326" + << 1.0 + << -1.0 + << 12.0 + << 2; QTest::newRow( "testcase 8" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt16 - << false - << "EPSG:4326" - << 1.0 - << 100.0 - << -1.0 - << 2; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt16 + << false + << "EPSG:4326" + << 1.0 + << 100.0 + << -1.0 + << 2; QTest::newRow( "testcase 9" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt16 - << false - << "EPSG:4326" - << 1.0 - << 0.0 - << 65536.0 - << 2; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt16 + << false + << "EPSG:4326" + << 1.0 + << 0.0 + << 65536.0 + << 2; QTest::newRow( "testcase 10" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int32 - << true - << "EPSG:4326" - << 1.0 - << 1.0 - << 12.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int32 + << true + << "EPSG:4326" + << 1.0 + << 1.0 + << 12.0 + << 3; QTest::newRow( "testcase 10" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int32 - << false - << "EPSG:4326" - << 1.0 - << 15.0 - << 12.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int32 + << false + << "EPSG:4326" + << 1.0 + << 15.0 + << 12.0 + << 3; QTest::newRow( "testcase 11" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int32 - << false - << "EPSG:4326" - << 1.0 - << -2147483649.0 - << 1.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int32 + << false + << "EPSG:4326" + << 1.0 + << -2147483649.0 + << 1.0 + << 3; QTest::newRow( "testcase 12" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Int32 - << false - << "EPSG:4326" - << 1.0 - << 1.0 - << 2147483649.0 - << 3; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Int32 + << false + << "EPSG:4326" + << 1.0 + << 1.0 + << 2147483649.0 + << 3; QTest::newRow( "testcase 13" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt32 - << true - << "EPSG:4326" - << 1.0 - << 1.0 - << 12.0 - << 4; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt32 + << true + << "EPSG:4326" + << 1.0 + << 1.0 + << 12.0 + << 4; QTest::newRow( "testcase 14" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt32 - << false - << "EPSG:4326" - << 1.0 - << 1.0 - << 4294967296.0 - << 4; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt32 + << false + << "EPSG:4326" + << 1.0 + << 1.0 + << 4294967296.0 + << 4; QTest::newRow( "testcase 14" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::UInt32 - << false - << "EPSG:4326" - << 1.0 - << -10.0 - << -1.0 - << 4; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::UInt32 + << false + << "EPSG:4326" + << 1.0 + << -10.0 + << -1.0 + << 4; QTest::newRow( "testcase 16" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Float32 - << true - << "EPSG:4326" - << 1.0 - << 0.0 - << 12.12 - << 5; + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Float32 + << true + << "EPSG:4326" + << 1.0 + << 0.0 + << 12.12 + << 5; QTest::newRow( "testcase 17" ) - << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" - << Qgis::DataType::Float64 - << true - << "EPSG:4326" - << 1.0 - << -15.0 - << 12.125789212532487 - << 6; - - + << "-3.000000000,7.000000000,-4.000000000,6.000000000 [EPSG:4326]" + << Qgis::DataType::Float64 + << true + << "EPSG:4326" + << 1.0 + << -15.0 + << 12.125789212532487 + << 6; } void TestQgsProcessingAlgsPt1::randomRaster() @@ -5596,13 +5458,13 @@ void TestQgsProcessingAlgsPt1::randomRaster() //prepare input params QgsProject p; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:createrandomuniformrasterlayer" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:createrandomuniformrasterlayer" ) ) ); //set project crs and ellipsoid from input layer p.setCrs( QgsCoordinateReferenceSystem( crs ), true ); //set project after layer has been added so that transform context/ellipsoid from crs is also set - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QVariantMap parameters; @@ -5632,8 +5494,8 @@ void TestQgsProcessingAlgsPt1::randomRaster() QVERIFY( ok ); //...and check results with expected datasets - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); - std::unique_ptr< QgsRasterInterface > outputInterface( outputRaster->dataProvider()->clone() ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputInterface( outputRaster->dataProvider()->clone() ); QCOMPARE( outputInterface->dataType( 1 ), expectedDataType ); @@ -5644,7 +5506,7 @@ void TestQgsProcessingAlgsPt1::randomRaster() int outputIterCols = 0; int outputIterRows = 0; - std::unique_ptr< QgsRasterBlock > outputRasterBlock; + std::unique_ptr outputRasterBlock; while ( outputIter.readNextRasterPart( 1, outputIterCols, outputIterRows, outputRasterBlock, outputIterLeft, outputIterTop ) ) { @@ -5673,7 +5535,7 @@ void TestQgsProcessingAlgsPt1::filterByLayerType() p.addMapLayer( rl ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:filterlayersbytype" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:filterlayersbytype" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -5681,7 +5543,7 @@ void TestQgsProcessingAlgsPt1::filterByLayerType() parameters.insert( QStringLiteral( "INPUT" ), QStringLiteral( "vl" ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QgsProcessingFeedback feedback; QVariantMap results; @@ -5713,7 +5575,7 @@ void TestQgsProcessingAlgsPt1::conditionalBranch() conditions << cond2; config.insert( QStringLiteral( "conditions" ), conditions ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:condition" ), config ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:condition" ), config ) ); QVERIFY( alg != nullptr ); QCOMPARE( alg->outputDefinitions().size(), 2 ); @@ -5725,7 +5587,7 @@ void TestQgsProcessingAlgsPt1::conditionalBranch() parameters.insert( QStringLiteral( "INPUT" ), QStringLiteral( "vl" ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok, config ); @@ -5736,14 +5598,14 @@ void TestQgsProcessingAlgsPt1::conditionalBranch() void TestQgsProcessingAlgsPt1::saveLog() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:savelog" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:savelog" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; feedback.reportError( QStringLiteral( "test" ) ); QVariantMap results; @@ -5752,7 +5614,7 @@ void TestQgsProcessingAlgsPt1::saveLog() QVERIFY( !results.value( QStringLiteral( "OUTPUT" ) ).toString().isEmpty() ); QFile file( results.value( QStringLiteral( "OUTPUT" ) ).toString() ); - QVERIFY( file.open( QFile::ReadOnly | QIODevice::Text ) ); + QVERIFY( file.open( QFile::ReadOnly | QIODevice::Text ) ); QCOMPARE( QString( file.readAll() ), QStringLiteral( "test\n" ) ); parameters.insert( QStringLiteral( "USE_HTML" ), true ); @@ -5760,13 +5622,13 @@ void TestQgsProcessingAlgsPt1::saveLog() QVERIFY( ok ); QVERIFY( !results.value( QStringLiteral( "OUTPUT" ) ).toString().isEmpty() ); QFile file2( results.value( QStringLiteral( "OUTPUT" ) ).toString() ); - QVERIFY( file2.open( QFile::ReadOnly | QIODevice::Text ) ); + QVERIFY( file2.open( QFile::ReadOnly | QIODevice::Text ) ); QCOMPARE( QString( file2.readAll() ), QStringLiteral( "test
    " ) ); } void TestQgsProcessingAlgsPt1::setProjectVariable() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:setprojectvariable" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:setprojectvariable" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -5774,7 +5636,7 @@ void TestQgsProcessingAlgsPt1::setProjectVariable() parameters.insert( QStringLiteral( "VALUE" ), 11 ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProject p; context->setProject( &p ); QgsProcessingFeedback feedback; @@ -5782,7 +5644,7 @@ void TestQgsProcessingAlgsPt1::setProjectVariable() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::projectScope( &p ) ); + std::unique_ptr scope( QgsExpressionContextUtils::projectScope( &p ) ); QCOMPARE( scope->variable( QStringLiteral( "my_var" ) ).toInt(), 11 ); //overwrite existing diff --git a/tests/src/analysis/testqgsprocessingalgspt2.cpp b/tests/src/analysis/testqgsprocessingalgspt2.cpp index 940ebb25b371..424907fd6ff9 100644 --- a/tests/src/analysis/testqgsprocessingalgspt2.cpp +++ b/tests/src/analysis/testqgsprocessingalgspt2.cpp @@ -42,18 +42,16 @@ #include "qgslinesymbol.h" -class TestQgsProcessingAlgsPt2: public QgsTest +class TestQgsProcessingAlgsPt2 : public QgsTest { Q_OBJECT public: - TestQgsProcessingAlgsPt2() : QgsTest( QStringLiteral( "Processing Algorithms Pt 2" ), QStringLiteral( "processing_algorithm" ) ) {} private: - /** * Helper function to get a feature based algorithm. */ @@ -62,10 +60,10 @@ class TestQgsProcessingAlgsPt2: public QgsTest QgsFeature runForFeature( const std::unique_ptr &alg, QgsFeature feature, const QString &layerType, QVariantMap parameters = QVariantMap() ); private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void exportLayoutPdf(); void exportLayoutPng(); @@ -111,7 +109,6 @@ class TestQgsProcessingAlgsPt2: public QgsTest void exportMetadata(); private: - QString mPointLayerPath; QgsVectorLayer *mPointsLayer = nullptr; QgsVectorLayer *mPolygonLayer = nullptr; @@ -122,10 +119,10 @@ std::unique_ptr TestQgsProcessingAlgsPt2::fe return std::unique_ptr( static_cast( QgsApplication::processingRegistry()->createAlgorithmById( id ) ) ); } -QgsFeature TestQgsProcessingAlgsPt2::runForFeature( const std::unique_ptr< QgsProcessingFeatureBasedAlgorithm > &alg, QgsFeature feature, const QString &layerType, QVariantMap parameters ) +QgsFeature TestQgsProcessingAlgsPt2::runForFeature( const std::unique_ptr &alg, QgsFeature feature, const QString &layerType, QVariantMap parameters ) { Q_ASSERT( alg.get() ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProject p; context->setProject( &p ); @@ -143,7 +140,7 @@ QgsFeature TestQgsProcessingAlgsPt2::runForFeature( const std::unique_ptr< QgsPr const auto res = alg->run( parameters, *context, &feedback, &ok ); QgsFeature result; - std::unique_ptr outputLayer( qobject_cast< QgsVectorLayer * >( context->getMapLayer( res.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); + std::unique_ptr outputLayer( qobject_cast( context->getMapLayer( res.value( QStringLiteral( "OUTPUT" ) ).toString() ) ) ); outputLayer->getFeatures().nextFeature( result ); return result; @@ -166,23 +163,23 @@ void TestQgsProcessingAlgsPt2::initTestCase() const QString pointsFileName = dataDir + "/points.shp"; const QFileInfo pointFileInfo( pointsFileName ); mPointLayerPath = pointFileInfo.filePath(); - mPointsLayer = new QgsVectorLayer( mPointLayerPath, - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( mPointLayerPath, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( mPointsLayer->isValid() ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mPointsLayer ); + QList() << mPointsLayer + ); // //create a poly layer that will be used in all tests... // const QString polysFileName = dataDir + "/polys.shp"; const QFileInfo polyFileInfo( polysFileName ); - mPolygonLayer = new QgsVectorLayer( polyFileInfo.filePath(), - QStringLiteral( "polygons" ), QStringLiteral( "ogr" ) ); + mPolygonLayer = new QgsVectorLayer( polyFileInfo.filePath(), QStringLiteral( "polygons" ), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mPolygonLayer ); + QList() << mPolygonLayer + ); QVERIFY( mPolygonLayer->isValid() ); //add a mesh layer @@ -219,7 +216,7 @@ QVariantMap pkgAlg( const QStringList &layers, const QString &outputGpkg, bool o { const QgsProcessingAlgorithm *package( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "native:package" ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; @@ -241,7 +238,7 @@ void TestQgsProcessingAlgsPt2::exportLayoutPdf() layout->setName( QStringLiteral( "my layout" ) ); p.layoutManager()->addLayout( layout ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:printlayouttopdf" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:printlayouttopdf" ) ) ); QVERIFY( alg != nullptr ); const QString outputPdf = QDir::tempPath() + "/my_layout.pdf"; @@ -253,7 +250,7 @@ void TestQgsProcessingAlgsPt2::exportLayoutPdf() parameters.insert( QStringLiteral( "OUTPUT" ), outputPdf ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QgsProcessingFeedback feedback; QVariantMap results; @@ -285,7 +282,7 @@ void TestQgsProcessingAlgsPt2::exportLayoutPng() p.layoutManager()->addLayout( layout ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:printlayouttoimage" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:printlayouttoimage" ) ) ); QVERIFY( alg != nullptr ); QString outputPng = QDir::tempPath() + "/my_layout.png"; @@ -297,7 +294,7 @@ void TestQgsProcessingAlgsPt2::exportLayoutPng() parameters.insert( QStringLiteral( "OUTPUT" ), outputPng ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QgsProcessingFeedback feedback; QVariantMap results; @@ -343,7 +340,7 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPdf() p.layoutManager()->addLayout( layout ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:atlaslayouttopdf" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:atlaslayouttopdf" ) ) ); QVERIFY( alg != nullptr ); const QString outputPdf = QDir::tempPath() + "/my_atlas_layout.pdf"; @@ -357,7 +354,7 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPdf() parameters.insert( QStringLiteral( "DPI" ), 96 ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QgsProcessingFeedback feedback; QVariantMap results; @@ -386,7 +383,7 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPdfMultiple() p.layoutManager()->addLayout( layout ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:atlaslayouttomultiplepdf" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:atlaslayouttomultiplepdf" ) ) ); QVERIFY( alg != nullptr ); const QString outputPdfDir = QDir::tempPath() + "/atlas_pdf"; @@ -402,7 +399,7 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPdfMultiple() parameters.insert( QStringLiteral( "DPI" ), 96 ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QgsProcessingFeedback feedback; QVariantMap results; @@ -433,7 +430,7 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPng() p.layoutManager()->addLayout( layout ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:atlaslayouttoimage" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:atlaslayouttoimage" ) ) ); QVERIFY( alg != nullptr ); const QDir tempDir( QDir::tempPath() ); @@ -453,7 +450,7 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPng() parameters.insert( QStringLiteral( "DPI" ), 96 ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QgsProcessingFeedback feedback; QVariantMap results; @@ -479,7 +476,7 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPng() void TestQgsProcessingAlgsPt2::tinMeshCreation() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:tinmeshcreation" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:tinmeshcreation" ) ) ); QVERIFY( alg != nullptr ); QVariantList inputLayers; @@ -503,7 +500,7 @@ void TestQgsProcessingAlgsPt2::tinMeshCreation() parameters.insert( QStringLiteral( "OUTPUT_MESH" ), QString( QDir::tempPath() + "/meshLayer.2dm" ) ); parameters.insert( QStringLiteral( "MESH_FORMAT" ), 0 ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -520,12 +517,12 @@ void TestQgsProcessingAlgsPt2::tinMeshCreation() meshLayer.updateTriangularMesh(); QVERIFY( qgsDoubleNear( meshLayer.datasetValue( QgsMeshDatasetIndex( 0, 0 ), QgsPointXY( -103.0, 39.0 ) ).scalar(), 20.0, 0.001 ) ); - QVERIFY( qgsDoubleNear( meshLayer.datasetValue( QgsMeshDatasetIndex( 0, 0 ), QgsPointXY( -86.0, 35.0 ) ).scalar(), 1.855, 0.001 ) ) ; + QVERIFY( qgsDoubleNear( meshLayer.datasetValue( QgsMeshDatasetIndex( 0, 0 ), QgsPointXY( -86.0, 35.0 ) ).scalar(), 1.855, 0.001 ) ); } void TestQgsProcessingAlgsPt2::exportMeshVertices() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshvertices" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshvertices" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -545,7 +542,7 @@ void TestQgsProcessingAlgsPt2::exportMeshVertices() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); parameters.insert( QStringLiteral( "VECTOR_OPTION" ), 2 ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -553,7 +550,7 @@ void TestQgsProcessingAlgsPt2::exportMeshVertices() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( resultLayer ); QVERIFY( resultLayer->isValid() ); QVERIFY( resultLayer->geometryType() == Qgis::GeometryType::Point ); @@ -607,7 +604,7 @@ void TestQgsProcessingAlgsPt2::exportMeshVertices() void TestQgsProcessingAlgsPt2::exportMeshFaces() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshfaces" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshfaces" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -627,7 +624,7 @@ void TestQgsProcessingAlgsPt2::exportMeshFaces() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); parameters.insert( QStringLiteral( "VECTOR_OPTION" ), 2 ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -635,7 +632,7 @@ void TestQgsProcessingAlgsPt2::exportMeshFaces() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( resultLayer ); QVERIFY( resultLayer->isValid() ); QVERIFY( resultLayer->geometryType() == Qgis::GeometryType::Polygon ); @@ -668,7 +665,7 @@ void TestQgsProcessingAlgsPt2::exportMeshFaces() void TestQgsProcessingAlgsPt2::exportMeshEdges() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshedges" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshedges" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -688,7 +685,7 @@ void TestQgsProcessingAlgsPt2::exportMeshEdges() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); parameters.insert( QStringLiteral( "VECTOR_OPTION" ), 2 ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -696,7 +693,7 @@ void TestQgsProcessingAlgsPt2::exportMeshEdges() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( resultLayer ); QVERIFY( resultLayer->isValid() ); QVERIFY( resultLayer->geometryType() == Qgis::GeometryType::Line ); @@ -737,7 +734,7 @@ void TestQgsProcessingAlgsPt2::exportMeshEdges() void TestQgsProcessingAlgsPt2::exportMeshOnGrid() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshongrid" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportmeshongrid" ) ) ); QVERIFY( alg != nullptr ); const QString dataDir = QString( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -763,7 +760,7 @@ void TestQgsProcessingAlgsPt2::exportMeshOnGrid() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); parameters.insert( QStringLiteral( "VECTOR_OPTION" ), 2 ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -771,7 +768,7 @@ void TestQgsProcessingAlgsPt2::exportMeshOnGrid() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( resultLayer ); QVERIFY( resultLayer->isValid() ); QVERIFY( resultLayer->geometryType() == Qgis::GeometryType::Point ); @@ -798,12 +795,11 @@ void TestQgsProcessingAlgsPt2::exportMeshOnGrid() QVERIFY( qgsDoubleNearSig( feat.attributes().at( 2 ).toDouble(), 5.00, 2 ) ); QVERIFY( qgsDoubleNearSig( feat.attributes().at( 3 ).toDouble(), 1.4809e-36, 2 ) ); QVERIFY( qgsDoubleNearSig( feat.attributes().at( 4 ).toDouble(), 0.0305, 2 ) ); - } void TestQgsProcessingAlgsPt2::rasterizeMesh() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshrasterize" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshrasterize" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -824,7 +820,7 @@ void TestQgsProcessingAlgsPt2::rasterizeMesh() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -832,7 +828,7 @@ void TestQgsProcessingAlgsPt2::rasterizeMesh() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - std::unique_ptr outputRaster = std::make_unique< QgsRasterLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); + std::unique_ptr outputRaster = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "output", "gdal" ); QVERIFY( outputRaster ); QVERIFY( outputRaster->isValid() ); QgsRasterDataProvider *outputProvider = outputRaster->dataProvider(); @@ -847,7 +843,7 @@ void TestQgsProcessingAlgsPt2::rasterizeMesh() // load expected result const QString dataDir = QString( TEST_DATA_DIR ); //defined in CmakeLists.txt - std::unique_ptr expectedRaster = std::make_unique< QgsRasterLayer >( dataDir + "/mesh/rasterized_mesh.tif", "expected", "gdal" ); + std::unique_ptr expectedRaster = std::make_unique( dataDir + "/mesh/rasterized_mesh.tif", "expected", "gdal" ); QVERIFY( expectedRaster ); QVERIFY( expectedRaster->isValid() ); QgsRasterDataProvider *expectedProvider = outputRaster->dataProvider(); @@ -871,7 +867,7 @@ void TestQgsProcessingAlgsPt2::rasterizeMesh() void TestQgsProcessingAlgsPt2::exportMeshContours() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshcontours" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshcontours" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -891,7 +887,7 @@ void TestQgsProcessingAlgsPt2::exportMeshContours() parameters.insert( QStringLiteral( "OUTPUT_LINES" ), QgsProcessing::TEMPORARY_OUTPUT ); parameters.insert( QStringLiteral( "OUTPUT_POLYGONS" ), QgsProcessing::TEMPORARY_OUTPUT ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -924,7 +920,7 @@ void TestQgsProcessingAlgsPt2::exportMeshContours() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *resultLinesLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_LINES" ) ).toString() ) ); + QgsVectorLayer *resultLinesLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_LINES" ) ).toString() ) ); QVERIFY( resultLinesLayer ); QVERIFY( resultLinesLayer->isValid() ); QgsAttributeList attributeList = resultLinesLayer->attributeList(); @@ -957,7 +953,7 @@ void TestQgsProcessingAlgsPt2::exportMeshContours() QCOMPARE( feat.attributes().at( 1 ).toString(), QStringLiteral( "1950-01-01 01:00:00" ) ); QCOMPARE( feat.attributes().at( 2 ).toDouble(), 2.25 ); - QgsVectorLayer *resultpolygonLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_POLYGONS" ) ).toString() ) ); + QgsVectorLayer *resultpolygonLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_POLYGONS" ) ).toString() ) ); QVERIFY( resultpolygonLayer ); QVERIFY( resultpolygonLayer->isValid() ); attributeList = resultpolygonLayer->attributeList(); @@ -1026,7 +1022,7 @@ void TestQgsProcessingAlgsPt2::exportMeshContours() void TestQgsProcessingAlgsPt2::exportMeshCrossSection() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshexportcrosssection" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshexportcrosssection" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -1048,11 +1044,9 @@ void TestQgsProcessingAlgsPt2::exportMeshCrossSection() const QString outputPath = QDir::tempPath() + "/test_mesh_xs.csv"; parameters.insert( QStringLiteral( "OUTPUT" ), outputPath ); - QgsVectorLayer *layerLine = new QgsVectorLayer( QStringLiteral( "LineString" ), - QStringLiteral( "lines_for_xs" ), - QStringLiteral( "memory" ) ); + QgsVectorLayer *layerLine = new QgsVectorLayer( QStringLiteral( "LineString" ), QStringLiteral( "lines_for_xs" ), QStringLiteral( "memory" ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -1073,7 +1067,8 @@ void TestQgsProcessingAlgsPt2::exportMeshCrossSection() flist << feat; } layerLine->dataProvider()->addFeatures( flist ); - QgsProject::instance()->addMapLayer( layerLine ); QgsProject::instance()->addMapLayer( layerLine ); + QgsProject::instance()->addMapLayer( layerLine ); + QgsProject::instance()->addMapLayer( layerLine ); parameters.insert( QStringLiteral( "INPUT_LINES" ), layerLine->name() ); results = alg->run( parameters, *context, &feedback, &ok ); @@ -1130,14 +1125,14 @@ void TestQgsProcessingAlgsPt2::exportMeshCrossSection() void TestQgsProcessingAlgsPt2::fileDownloader() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:filedownloader" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:filedownloader" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; parameters.insert( QStringLiteral( "URL" ), QStringLiteral( "https://version.qgis.org/version.txt" ) ); parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; bool ok = false; @@ -1150,7 +1145,7 @@ void TestQgsProcessingAlgsPt2::fileDownloader() void TestQgsProcessingAlgsPt2::rasterize() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:rasterize" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:rasterize" ) ) ); QVERIFY( alg != nullptr ); const QString outputTif = QDir::tempPath() + "/rasterize_output.tif"; @@ -1177,7 +1172,7 @@ void TestQgsProcessingAlgsPt2::rasterize() QVERIFY( nodePolygons ); nodePolygons->setItemVisibilityChecked( false ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &project ); QgsProcessingFeedback feedback; QVariantMap results; @@ -1201,163 +1196,53 @@ void TestQgsProcessingAlgsPt2::convertGpxFeatureType() QStringList processArgs; QStringList logArgs; - QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "/home/me/my output file.gpx" ), - QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromRoute, - processArgs, logArgs ); - QCOMPARE( processArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,wpt=rte,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "/home/me/my output file.gpx" ) - } ) ); + QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "/home/me/my output file.gpx" ), QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromRoute, processArgs, logArgs ); + QCOMPARE( processArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "-x" ), QStringLiteral( "transform,wpt=rte,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "/home/me/my output file.gpx" ) } ) ); // when showing the babel command, filenames should be wrapped in "", which is what QProcess does internally (hence the processArgs don't have these) - QCOMPARE( logArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "\"/home/me/my input file.gpx\"" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,wpt=rte,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "\"/home/me/my output file.gpx\"" ) - } ) ); + QCOMPARE( logArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "\"/home/me/my input file.gpx\"" ), QStringLiteral( "-x" ), QStringLiteral( "transform,wpt=rte,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "\"/home/me/my output file.gpx\"" ) } ) ); logArgs.clear(); processArgs.clear(); - QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "/home/me/my output file.gpx" ), - QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromTrack, - processArgs, logArgs ); - QCOMPARE( processArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,wpt=trk,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "/home/me/my output file.gpx" ) - } ) ); + QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "/home/me/my output file.gpx" ), QgsConvertGpxFeatureTypeAlgorithm::WaypointsFromTrack, processArgs, logArgs ); + QCOMPARE( processArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "-x" ), QStringLiteral( "transform,wpt=trk,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "/home/me/my output file.gpx" ) } ) ); // when showing the babel command, filenames should be wrapped in "", which is what QProcess does internally (hence the processArgs don't have these) - QCOMPARE( logArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "\"/home/me/my input file.gpx\"" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,wpt=trk,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "\"/home/me/my output file.gpx\"" ) - } ) ); + QCOMPARE( logArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "\"/home/me/my input file.gpx\"" ), QStringLiteral( "-x" ), QStringLiteral( "transform,wpt=trk,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "\"/home/me/my output file.gpx\"" ) } ) ); logArgs.clear(); processArgs.clear(); - QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "/home/me/my output file.gpx" ), - QgsConvertGpxFeatureTypeAlgorithm::RouteFromWaypoints, - processArgs, logArgs ); - QCOMPARE( processArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,rte=wpt,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "/home/me/my output file.gpx" ) - } ) ); + QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "/home/me/my output file.gpx" ), QgsConvertGpxFeatureTypeAlgorithm::RouteFromWaypoints, processArgs, logArgs ); + QCOMPARE( processArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "-x" ), QStringLiteral( "transform,rte=wpt,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "/home/me/my output file.gpx" ) } ) ); // when showing the babel command, filenames should be wrapped in "", which is what QProcess does internally (hence the processArgs don't have these) - QCOMPARE( logArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "\"/home/me/my input file.gpx\"" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,rte=wpt,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "\"/home/me/my output file.gpx\"" ) - } ) ); + QCOMPARE( logArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "\"/home/me/my input file.gpx\"" ), QStringLiteral( "-x" ), QStringLiteral( "transform,rte=wpt,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "\"/home/me/my output file.gpx\"" ) } ) ); logArgs.clear(); processArgs.clear(); - QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "/home/me/my output file.gpx" ), - QgsConvertGpxFeatureTypeAlgorithm::TrackFromWaypoints, - processArgs, logArgs ); - QCOMPARE( processArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "/home/me/my input file.gpx" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,trk=wpt,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "/home/me/my output file.gpx" ) - } ) ); + QgsConvertGpxFeatureTypeAlgorithm::createArgumentLists( QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "/home/me/my output file.gpx" ), QgsConvertGpxFeatureTypeAlgorithm::TrackFromWaypoints, processArgs, logArgs ); + QCOMPARE( processArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "/home/me/my input file.gpx" ), QStringLiteral( "-x" ), QStringLiteral( "transform,trk=wpt,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "/home/me/my output file.gpx" ) } ) ); // when showing the babel command, filenames should be wrapped in "", which is what QProcess does internally (hence the processArgs don't have these) - QCOMPARE( logArgs, QStringList( - { - QStringLiteral( "-i" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-f" ), - QStringLiteral( "\"/home/me/my input file.gpx\"" ), - QStringLiteral( "-x" ), - QStringLiteral( "transform,trk=wpt,del" ), - QStringLiteral( "-o" ), - QStringLiteral( "gpx" ), - QStringLiteral( "-F" ), - QStringLiteral( "\"/home/me/my output file.gpx\"" ) - } ) ); + QCOMPARE( logArgs, QStringList( { QStringLiteral( "-i" ), QStringLiteral( "gpx" ), QStringLiteral( "-f" ), QStringLiteral( "\"/home/me/my input file.gpx\"" ), QStringLiteral( "-x" ), QStringLiteral( "transform,trk=wpt,del" ), QStringLiteral( "-o" ), QStringLiteral( "gpx" ), QStringLiteral( "-F" ), QStringLiteral( "\"/home/me/my output file.gpx\"" ) } ) ); } class TestProcessingFeedback : public QgsProcessingFeedback { Q_OBJECT public: - void reportError( const QString &error, bool ) override { errors << error; } QStringList errors; - }; void TestQgsProcessingAlgsPt2::convertGpsData() { TestProcessingFeedback feedback; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:convertgpsdata" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:convertgpsdata" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -1367,7 +1252,7 @@ void TestQgsProcessingAlgsPt2::convertGpsData() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -1391,7 +1276,7 @@ void TestQgsProcessingAlgsPt2::convertGpsData() // garmin_xt format does support tracks! QVERIFY( ok ); - QgsVectorLayer *resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_LAYER" ) ).toString() ) ); + QgsVectorLayer *resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_LAYER" ) ).toString() ) ); QVERIFY( resultLayer ); QCOMPARE( resultLayer->providerType(), QStringLiteral( "gpx" ) ); QCOMPARE( resultLayer->wkbType(), Qgis::WkbType::LineString ); @@ -1402,7 +1287,7 @@ void TestQgsProcessingAlgsPt2::convertGpsData() ok = false; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_LAYER" ) ).toString() ) ); + resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT_LAYER" ) ).toString() ) ); QVERIFY( resultLayer ); QCOMPARE( resultLayer->providerType(), QStringLiteral( "gpx" ) ); QCOMPARE( resultLayer->wkbType(), Qgis::WkbType::LineString ); @@ -1421,7 +1306,7 @@ void TestQgsProcessingAlgsPt2::downloadGpsData() { TestProcessingFeedback feedback; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:downloadgpsdata" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:downloadgpsdata" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -1431,7 +1316,7 @@ void TestQgsProcessingAlgsPt2::downloadGpsData() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -1455,7 +1340,7 @@ void TestQgsProcessingAlgsPt2::uploadGpsData() { TestProcessingFeedback feedback; - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:downloadgpsdata" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:downloadgpsdata" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -1465,7 +1350,7 @@ void TestQgsProcessingAlgsPt2::uploadGpsData() parameters.insert( QStringLiteral( "INPUT" ), QStringLiteral( "%1/layers.gpx" ).arg( TEST_DATA_DIR ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -1487,13 +1372,13 @@ void TestQgsProcessingAlgsPt2::uploadGpsData() void TestQgsProcessingAlgsPt2::transferMainAnnotationLayer() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:transferannotationsfrommain" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:transferannotationsfrommain" ) ) ); QVERIFY( alg != nullptr ); QgsProject p; p.mainAnnotationLayer()->addItem( new QgsAnnotationMarkerItem( QgsPoint( 1, 2 ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &p ); QgsProcessingFeedback feedback; QVariantMap results; @@ -1505,14 +1390,14 @@ void TestQgsProcessingAlgsPt2::transferMainAnnotationLayer() QVERIFY( ok ); QCOMPARE( p.mainAnnotationLayer()->items().size(), 0 ); - QgsAnnotationLayer *newLayer = qobject_cast< QgsAnnotationLayer * >( p.mapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsAnnotationLayer *newLayer = qobject_cast( p.mapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QCOMPARE( newLayer->name(), QStringLiteral( "my annotations" ) ); QCOMPARE( newLayer->items().size(), 1 ); } void TestQgsProcessingAlgsPt2::exportMeshTimeSeries() { - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshexporttimeseries" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:meshexporttimeseries" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -1539,11 +1424,9 @@ void TestQgsProcessingAlgsPt2::exportMeshTimeSeries() const QString outputPath = QDir::tempPath() + "/test_mesh_ts.csv"; parameters.insert( QStringLiteral( "OUTPUT" ), outputPath ); - QgsVectorLayer *layerPoints = new QgsVectorLayer( QStringLiteral( "Point" ), - QStringLiteral( "points_for_ts" ), - QStringLiteral( "memory" ) ); + QgsVectorLayer *layerPoints = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "points_for_ts" ), QStringLiteral( "memory" ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; QVariantMap results; @@ -1565,7 +1448,8 @@ void TestQgsProcessingAlgsPt2::exportMeshTimeSeries() flist << feat; } layerPoints->dataProvider()->addFeatures( flist ); - QgsProject::instance()->addMapLayer( layerPoints ); QgsProject::instance()->addMapLayer( layerPoints ); + QgsProject::instance()->addMapLayer( layerPoints ); + QgsProject::instance()->addMapLayer( layerPoints ); parameters.insert( QStringLiteral( "INPUT_POINTS" ), layerPoints->name() ); results = alg->run( parameters, *context, &feedback, &ok ); @@ -1644,8 +1528,7 @@ void TestQgsProcessingAlgsPt2::exportMeshTimeSeries() void TestQgsProcessingAlgsPt2::extractLabels() { QgsProject project; - QgsVectorLayer *pointsLayer = new QgsVectorLayer( mPointLayerPath, - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *pointsLayer = new QgsVectorLayer( mPointLayerPath, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( mPointsLayer->isValid() ); project.addMapLayer( pointsLayer ); @@ -1656,7 +1539,7 @@ void TestQgsProcessingAlgsPt2::extractLabels() settings.setFormat( format ); pointsLayer->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:extractlabels" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:extractlabels" ) ) ); QVERIFY( alg != nullptr ); QgsReferencedRectangle extent( QgsRectangle( -120, 20, -80, 50 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); @@ -1668,7 +1551,7 @@ void TestQgsProcessingAlgsPt2::extractLabels() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &project ); QgsProcessingFeedback feedback; @@ -1676,7 +1559,7 @@ void TestQgsProcessingAlgsPt2::extractLabels() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( resultLayer ); QCOMPARE( resultLayer->wkbType(), Qgis::WkbType::Point ); QCOMPARE( resultLayer->featureCount(), 17 ); @@ -1703,7 +1586,7 @@ void TestQgsProcessingAlgsPt2::dxfExport() QgsProject project; project.addMapLayer( mPolygonLayer ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:dxfexport" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:dxfexport" ) ) ); QVERIFY( alg != nullptr ); QgsReferencedRectangle extent( QgsRectangle( -103.9, 25.0, -98.0, 29.8 ), mPolygonLayer->crs() ); @@ -1715,7 +1598,7 @@ void TestQgsProcessingAlgsPt2::dxfExport() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( &project ); TestProcessingFeedback feedback; @@ -1723,7 +1606,7 @@ void TestQgsProcessingAlgsPt2::dxfExport() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - std::unique_ptr< QgsVectorLayer > resultLayer = std::make_unique< QgsVectorLayer >( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "dxf" ); + std::unique_ptr resultLayer = std::make_unique( results.value( QStringLiteral( "OUTPUT" ) ).toString(), "dxf" ); QVERIFY( resultLayer->isValid() ); QCOMPARE( resultLayer->featureCount(), 1L ); QCOMPARE( resultLayer->wkbType(), Qgis::WkbType::LineString ); @@ -1731,7 +1614,7 @@ void TestQgsProcessingAlgsPt2::dxfExport() void TestQgsProcessingAlgsPt2::splitVectorLayer() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsFeature f; @@ -1745,7 +1628,7 @@ void TestQgsProcessingAlgsPt2::splitVectorLayer() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "Point (0 2)" ) ) ); layer->dataProvider()->addFeature( f ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:splitvectorlayer" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:splitvectorlayer" ) ) ); QVERIFY( alg != nullptr ); QDir outputDir( QDir::tempPath() + "/split_vector/" ); @@ -1759,7 +1642,7 @@ void TestQgsProcessingAlgsPt2::splitVectorLayer() parameters.insert( QStringLiteral( "OUTPUT" ), outputDir.absolutePath() ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -1773,10 +1656,10 @@ void TestQgsProcessingAlgsPt2::splitVectorLayer() void TestQgsProcessingAlgsPt2::buffer() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:buffer" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:buffer" ) ) ); QVERIFY( alg != nullptr ); // buffering empty layer should produce an empty layer @@ -1791,14 +1674,14 @@ void TestQgsProcessingAlgsPt2::buffer() parameters.insert( QStringLiteral( "OUTPUT" ), QStringLiteral( "memory:" ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); QVERIFY( !results.value( QStringLiteral( "OUTPUT" ) ).toString().isEmpty() ); - QgsVectorLayer *bufferedLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *bufferedLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( bufferedLayer->isValid() ); QCOMPARE( bufferedLayer->wkbType(), Qgis::WkbType::MultiPolygon ); QCOMPARE( bufferedLayer->featureCount(), layer->featureCount() ); @@ -1811,7 +1694,7 @@ void TestQgsProcessingAlgsPt2::buffer() QVERIFY( ok ); QVERIFY( !results.value( QStringLiteral( "OUTPUT" ) ).toString().isEmpty() ); - bufferedLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + bufferedLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( bufferedLayer->isValid() ); QCOMPARE( bufferedLayer->wkbType(), Qgis::WkbType::MultiPolygon ); QCOMPARE( bufferedLayer->featureCount(), layer->featureCount() ); @@ -1820,32 +1703,32 @@ void TestQgsProcessingAlgsPt2::buffer() void TestQgsProcessingAlgsPt2::splitWithLines() { QgsFeature l1_1, l1_2, l2_1, l2_2, p1_1, p1_2, p2_1, p2_2; - std::unique_ptr< QgsVectorLayer > lineLayer1 = std::make_unique< QgsVectorLayer >( QStringLiteral( "MultiLineString?crs=epsg:4326" ), QStringLiteral( "l1" ), QStringLiteral( "memory" ) ); + std::unique_ptr lineLayer1 = std::make_unique( QStringLiteral( "MultiLineString?crs=epsg:4326" ), QStringLiteral( "l1" ), QStringLiteral( "memory" ) ); QVERIFY( lineLayer1->isValid() ); l1_1.setGeometry( QgsGeometry::fromWkt( "MultiLineString ((19 40, 26 40),(20 39, 25 39))" ) ); l1_2.setGeometry( QgsGeometry::fromWkt( "MultiLineString ((19 35, 26 35))" ) ); lineLayer1->dataProvider()->addFeature( l1_1 ); lineLayer1->dataProvider()->addFeature( l1_2 ); - std::unique_ptr< QgsVectorLayer > lineLayer2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "MultiLineString?crs=epsg:4326" ), QStringLiteral( "l2" ), QStringLiteral( "memory" ) ); + std::unique_ptr lineLayer2 = std::make_unique( QStringLiteral( "MultiLineString?crs=epsg:4326" ), QStringLiteral( "l2" ), QStringLiteral( "memory" ) ); QVERIFY( lineLayer2->isValid() ); l2_1.setGeometry( QgsGeometry::fromWkt( "MultiLineString ((20 42, 20 34, 23 42))" ) ); l2_2.setGeometry( QgsGeometry::fromWkt( "MultiLineString ((21 42, 21 34),(23 42, 23 34, 25 42))" ) ); lineLayer2->dataProvider()->addFeature( l2_1 ); lineLayer2->dataProvider()->addFeature( l2_2 ); - std::unique_ptr< QgsVectorLayer > polygonLayer1 = std::make_unique< QgsVectorLayer >( QStringLiteral( "MultiPolygon?crs=epsg:4326" ), QStringLiteral( "p1" ), QStringLiteral( "memory" ) ); + std::unique_ptr polygonLayer1 = std::make_unique( QStringLiteral( "MultiPolygon?crs=epsg:4326" ), QStringLiteral( "p1" ), QStringLiteral( "memory" ) ); QVERIFY( polygonLayer1->isValid() ); p1_1.setGeometry( QgsGeometry::fromWkt( "MultiPolygon (((25 41, 25 38, 18 38, 18 41, 25 41),(19 39, 24 39, 24 40, 19 40, 19 39)))" ) ); p1_2.setGeometry( QgsGeometry::fromWkt( "MultiPolygon (((18 37, 21 37, 21 35, 18 35, 18 37),(19.5 36.5, 19.5 35.5, 20.5 35.5, 20.5 36.5, 19.5 36.5)),((22 37, 25 37, 25 35, 22 35, 22 37),(24 36, 24 35.5, 24.5 35.5, 24.5 36, 24 36),(23.5 35.5, 23.5 36.5, 22.5 36.5, 22.5 35.5, 23.5 35.5)))" ) ); polygonLayer1->dataProvider()->addFeature( p1_1 ); polygonLayer1->dataProvider()->addFeature( p1_2 ); - std::unique_ptr< QgsVectorLayer > polygonLayer2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "MultiPolygon?crs=epsg:4326" ), QStringLiteral( "p2" ), QStringLiteral( "memory" ) ); + std::unique_ptr polygonLayer2 = std::make_unique( QStringLiteral( "MultiPolygon?crs=epsg:4326" ), QStringLiteral( "p2" ), QStringLiteral( "memory" ) ); QVERIFY( polygonLayer2->isValid() ); p2_1.setGeometry( QgsGeometry::fromWkt( "MultiPolygon (((23 42, 20 34, 20 42, 23 42),(20.5 38.5, 21 38.5, 21.5 40.5, 20.5 40.5, 20.5 38.5)))" ) ); p2_2.setGeometry( QgsGeometry::fromWkt( "MultiPolygon (((23 34, 23 42, 25 42, 23 34),(24 40.5, 23.5 40.5, 23.5 39.5, 24 40.5)),((19.5 34.5, 17.5 34.5, 17.5 42, 18.5 42, 19.5 34.5),(18.5 37.5, 18 37.5, 18.5 36.5, 18.5 37.5)))" ) ); polygonLayer2->dataProvider()->addFeature( p2_1 ); polygonLayer2->dataProvider()->addFeature( p2_2 ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:splitwithlines" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:splitwithlines" ) ) ); QVERIFY( alg != nullptr ); // Split lineLayer1 with lineLayer2 @@ -1855,13 +1738,13 @@ void TestQgsProcessingAlgsPt2::splitWithLines() parameters.insert( QStringLiteral( "OUTPUT" ), QStringLiteral( "memory:" ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *splitLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *splitLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( splitLayer->isValid() ); QCOMPARE( splitLayer->wkbType(), Qgis::WkbType::MultiLineString ); QCOMPARE( splitLayer->featureCount(), 17 ); @@ -1873,7 +1756,7 @@ void TestQgsProcessingAlgsPt2::splitWithLines() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - splitLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + splitLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( splitLayer->isValid() ); QCOMPARE( splitLayer->wkbType(), Qgis::WkbType::MultiPolygon ); QCOMPARE( splitLayer->featureCount(), 16 ); @@ -1885,7 +1768,7 @@ void TestQgsProcessingAlgsPt2::splitWithLines() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - splitLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + splitLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( splitLayer->isValid() ); QCOMPARE( splitLayer->wkbType(), Qgis::WkbType::MultiLineString ); QCOMPARE( splitLayer->featureCount(), 21 ); @@ -1897,7 +1780,7 @@ void TestQgsProcessingAlgsPt2::splitWithLines() results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - splitLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + splitLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( splitLayer->isValid() ); QCOMPARE( splitLayer->wkbType(), Qgis::WkbType::MultiPolygon ); QCOMPARE( splitLayer->featureCount(), 20 ); @@ -1905,8 +1788,8 @@ void TestQgsProcessingAlgsPt2::splitWithLines() void TestQgsProcessingAlgsPt2::randomPointsInPolygonsFromField_data() { - QTest::addColumn< QVariant >( "num_points" ); - QTest::addColumn< int >( "expected" ); + QTest::addColumn( "num_points" ); + QTest::addColumn( "expected" ); QTest::newRow( "5" ) << QVariant::fromValue( 5 ) << 5; QTest::newRow( "NULL" ) << QVariant() << 0; @@ -1941,17 +1824,17 @@ void TestQgsProcessingAlgsPt2::randomPointsInPolygonsFromField() parameters.insert( QStringLiteral( "OUTPUT" ), QStringLiteral( "memory:" ) ); parameters.insert( QStringLiteral( "POINTS_NUMBER" ), QgsProperty::fromExpression( QStringLiteral( "num_points" ) ) ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:randompointsinpolygons" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:randompointsinpolygons" ) ) ); QVERIFY( alg != nullptr ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); QVERIFY( ok ); - QgsVectorLayer *resultLayer = qobject_cast< QgsVectorLayer * >( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); + QgsVectorLayer *resultLayer = qobject_cast( context->getMapLayer( results.value( QStringLiteral( "OUTPUT" ) ).toString() ) ); QVERIFY( resultLayer ); QCOMPARE( resultLayer->wkbType(), Qgis::WkbType::Point ); QCOMPARE( resultLayer->featureCount(), expected ); @@ -1959,7 +1842,7 @@ void TestQgsProcessingAlgsPt2::randomPointsInPolygonsFromField() void TestQgsProcessingAlgsPt2::generateElevationProfileImage() { - std::unique_ptr< QgsVectorLayer > lineLayer = std::make_unique< QgsVectorLayer >( QStringLiteral( "LineStringZ?crs=epsg:3857" ), QStringLiteral( "lines" ), QStringLiteral( "memory" ) ); + std::unique_ptr lineLayer = std::make_unique( QStringLiteral( "LineStringZ?crs=epsg:3857" ), QStringLiteral( "lines" ), QStringLiteral( "memory" ) ); QVERIFY( lineLayer->isValid() ); QgsFeature feature; feature.setGeometry( QgsGeometry::fromWkt( "LineStringZ (0 0 0, 10 10 10)" ) ); @@ -1971,7 +1854,7 @@ void TestQgsProcessingAlgsPt2::generateElevationProfileImage() properties.insert( QStringLiteral( "capstyle" ), QStringLiteral( "flat" ) ); dynamic_cast( lineLayer->renderer() )->setSymbol( QgsLineSymbol::createSimple( properties ) ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:generateelevationprofileimage" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:generateelevationprofileimage" ) ) ); QVERIFY( alg != nullptr ); QgsReferencedGeometry curve( QgsGeometry::fromWkt( "LineString(0 0, 10 10)" ), QgsCoordinateReferenceSystem( "EPSG:3857" ) ); @@ -1988,7 +1871,7 @@ void TestQgsProcessingAlgsPt2::generateElevationProfileImage() parameters.insert( QStringLiteral( "OUTPUT" ), outputImage ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -1999,10 +1882,10 @@ void TestQgsProcessingAlgsPt2::generateElevationProfileImage() void TestQgsProcessingAlgsPt2::copyMetadata() { - std::unique_ptr< QgsVectorLayer > inputLayer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "input" ), QStringLiteral( "memory" ) ); + std::unique_ptr inputLayer = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "input" ), QStringLiteral( "memory" ) ); QVERIFY( inputLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > targetLayer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "target" ), QStringLiteral( "memory" ) ); + std::unique_ptr targetLayer = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "target" ), QStringLiteral( "memory" ) ); QVERIFY( targetLayer->isValid() ); QgsLayerMetadata md; @@ -2010,7 +1893,7 @@ void TestQgsProcessingAlgsPt2::copyMetadata() md.setAbstract( QStringLiteral( "Abstract" ) ); inputLayer->setMetadata( md ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:copylayermetadata" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:copylayermetadata" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -2018,7 +1901,7 @@ void TestQgsProcessingAlgsPt2::copyMetadata() parameters.insert( QStringLiteral( "TARGET" ), QVariant::fromValue( targetLayer.get() ) ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -2033,10 +1916,10 @@ void TestQgsProcessingAlgsPt2::copyMetadata() void TestQgsProcessingAlgsPt2::applyMetadata() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "input" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "input" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:setlayermetadata" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:setlayermetadata" ) ) ); QVERIFY( alg != nullptr ); const QString dataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -2047,7 +1930,7 @@ void TestQgsProcessingAlgsPt2::applyMetadata() parameters.insert( QStringLiteral( "METADATA" ), metadataFileName ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); @@ -2062,7 +1945,7 @@ void TestQgsProcessingAlgsPt2::applyMetadata() void TestQgsProcessingAlgsPt2::exportMetadata() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "input" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "input" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsLayerMetadata md; @@ -2070,7 +1953,7 @@ void TestQgsProcessingAlgsPt2::exportMetadata() md.setAbstract( QStringLiteral( "Abstract" ) ); layer->setMetadata( md ); - std::unique_ptr< QgsProcessingAlgorithm > alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportlayermetadata" ) ) ); + std::unique_ptr alg( QgsApplication::processingRegistry()->createAlgorithmById( QStringLiteral( "native:exportlayermetadata" ) ) ); QVERIFY( alg != nullptr ); QVariantMap parameters; @@ -2078,7 +1961,7 @@ void TestQgsProcessingAlgsPt2::exportMetadata() parameters.insert( QStringLiteral( "OUTPUT" ), QgsProcessing::TEMPORARY_OUTPUT ); bool ok = false; - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); QgsProcessingFeedback feedback; QVariantMap results; results = alg->run( parameters, *context, &feedback, &ok ); diff --git a/tests/src/analysis/testqgsprocessingmodelalgorithm.cpp b/tests/src/analysis/testqgsprocessingmodelalgorithm.cpp index e6acd88e8919..7a72c5d0df3c 100644 --- a/tests/src/analysis/testqgsprocessingmodelalgorithm.cpp +++ b/tests/src/analysis/testqgsprocessingmodelalgorithm.cpp @@ -29,8 +29,8 @@ class DummyAlgorithm2 : public QgsProcessingAlgorithm { public: - - DummyAlgorithm2( const QString &name ) : mName( name ) { mFlags = QgsProcessingAlgorithm::flags(); } + DummyAlgorithm2( const QString &name ) + : mName( name ) { mFlags = QgsProcessingAlgorithm::flags(); } void initAlgorithm( const QVariantMap & = QVariantMap() ) override { @@ -48,15 +48,14 @@ class DummyAlgorithm2 : public QgsProcessingAlgorithm QString mName; Qgis::ProcessingAlgorithmFlags mFlags; - }; class DummySecurityRiskAlgorithm : public QgsProcessingAlgorithm { public: - - DummySecurityRiskAlgorithm( const QString &name ) : mName( name ) { } + DummySecurityRiskAlgorithm( const QString &name ) + : mName( name ) {} void initAlgorithm( const QVariantMap & = QVariantMap() ) override { @@ -70,14 +69,17 @@ class DummySecurityRiskAlgorithm : public QgsProcessingAlgorithm DummySecurityRiskAlgorithm *createInstance() const override { return new DummySecurityRiskAlgorithm( name() ); } QString mName; - }; class DummyRaiseExceptionAlgorithm : public QgsProcessingAlgorithm { public: - - DummyRaiseExceptionAlgorithm( const QString &name ) : mName( name ) { mFlags = QgsProcessingAlgorithm::flags(); hasPostProcessed = false; } + DummyRaiseExceptionAlgorithm( const QString &name ) + : mName( name ) + { + mFlags = QgsProcessingAlgorithm::flags(); + hasPostProcessed = false; + } static bool hasPostProcessed; ~DummyRaiseExceptionAlgorithm() { @@ -106,7 +108,6 @@ class DummyRaiseExceptionAlgorithm : public QgsProcessingAlgorithm QString mName; Qgis::ProcessingAlgorithmFlags mFlags; - }; bool DummyRaiseExceptionAlgorithm::hasPostProcessed = false; bool DummyRaiseExceptionAlgorithm::postProcessAlgorithmCalled = false; @@ -114,8 +115,7 @@ bool DummyRaiseExceptionAlgorithm::postProcessAlgorithmCalled = false; class DummyProvider4 : public QgsProcessingProvider // clazy:exclude=missing-qobject-macro { public: - - DummyProvider4() = default; + DummyProvider4() = default; QString id() const override { return QStringLiteral( "dummy4" ); } QString name() const override { return QStringLiteral( "dummy4" ); } @@ -140,25 +140,23 @@ class DummyProvider4 : public QgsProcessingProvider // clazy:exclude=missing-qob QVERIFY( addAlgorithm( new DummyRaiseExceptionAlgorithm( QStringLiteral( "raise" ) ) ) ); QVERIFY( addAlgorithm( new DummySecurityRiskAlgorithm( QStringLiteral( "risky" ) ) ) ); } - }; -class TestQgsProcessingModelAlgorithm: public QgsTest +class TestQgsProcessingModelAlgorithm : public QgsTest { Q_OBJECT public: - TestQgsProcessingModelAlgorithm() : QgsTest( QStringLiteral( "Processing Model Test" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void modelScope(); void modelerAlgorithm(); void modelExecution(); @@ -181,7 +179,6 @@ class TestQgsProcessingModelAlgorithm: public QgsTest void flags(); private: - }; void TestQgsProcessingModelAlgorithm::initTestCase() @@ -221,7 +218,7 @@ void TestQgsProcessingModelAlgorithm::modelScope() QVariantMap params; params.insert( QStringLiteral( "a_param" ), 5 ); - std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::processingModelAlgorithmScope( &alg, params, pc ) ); + std::unique_ptr scope( QgsExpressionContextUtils::processingModelAlgorithmScope( &alg, params, pc ) ); QVERIFY( scope.get() ); QCOMPARE( scope->variable( QStringLiteral( "model_name" ) ).toString(), QStringLiteral( "test" ) ); QCOMPARE( scope->variable( QStringLiteral( "model_group" ) ).toString(), QStringLiteral( "testGroup" ) ); @@ -257,7 +254,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( svSource.staticValue().toInt(), 5 ); svSource.setStaticValue( 7 ); QCOMPARE( svSource.staticValue().toInt(), 7 ); - QMap< QString, QString > friendlyNames; + QMap friendlyNames; QCOMPARE( svSource.asPythonCode( QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass, nullptr, friendlyNames ), QStringLiteral( "7" ) ); svSource = QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ); // check that calling setStaticValue flips source to StaticValue @@ -336,30 +333,18 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( expSource.asPythonCode( QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass, nullptr, friendlyNames ), QStringLiteral( "QgsExpression('1+4').evaluate()" ) ); // source equality operator - QVERIFY( QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) == - QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) != - QgsProcessingModelChildParameterSource::fromStaticValue( 7 ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) != - QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) == - QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) != - QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "b" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) != - QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) == - QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) != - QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg2" ), QStringLiteral( "out" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) != - QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out2" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) == - QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) != - QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "b" ) ) ); - QVERIFY( QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) != - QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "b" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) == QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) != QgsProcessingModelChildParameterSource::fromStaticValue( 7 ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) != QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) == QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) != QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "b" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "a" ) ) != QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) == QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) != QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg2" ), QStringLiteral( "out" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) != QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out2" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) == QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) != QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "b" ) ) ); + QVERIFY( QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "a" ) ) != QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "b" ) ) ); // a comment QgsProcessingModelComment comment; @@ -371,7 +356,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( comment.description(), QStringLiteral( "a comment" ) ); comment.setColor( QColor( 123, 45, 67 ) ); QCOMPARE( comment.color(), QColor( 123, 45, 67 ) ); - std::unique_ptr< QgsProcessingModelComment > commentClone( comment.clone() ); + std::unique_ptr commentClone( comment.clone() ); QCOMPARE( commentClone->toVariant(), comment.toVariant() ); QCOMPARE( commentClone->size(), QSizeF( 9, 8 ) ); QCOMPARE( commentClone->position(), QPointF( 11, 14 ) ); @@ -394,7 +379,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( groupBox.description(), QStringLiteral( "a comment" ) ); groupBox.setColor( QColor( 123, 45, 67 ) ); QCOMPARE( groupBox.color(), QColor( 123, 45, 67 ) ); - std::unique_ptr< QgsProcessingModelGroupBox > groupClone( groupBox.clone() ); + std::unique_ptr groupClone( groupBox.clone() ); QCOMPARE( groupClone->toVariant(), groupBox.toVariant() ); QCOMPARE( groupClone->size(), QSizeF( 9, 8 ) ); QCOMPARE( groupClone->position(), QPointF( 11, 14 ) ); @@ -409,7 +394,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( groupBox2.color(), QColor( 123, 45, 67 ) ); QCOMPARE( groupBox2.uuid(), groupBox.uuid() ); - const QMap< QString, QString > friendlyOutputNames; + const QMap friendlyOutputNames; QgsProcessingModelChildAlgorithm child( QStringLiteral( "some_id" ) ); QCOMPARE( child.algorithmId(), QStringLiteral( "some_id" ) ); QVERIFY( !child.algorithm() ); @@ -478,10 +463,10 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() child.setChildId( QStringLiteral( "my_id" ) ); QCOMPARE( child.childId(), QStringLiteral( "my_id" ) ); - child.setDependencies( QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( QStringLiteral( "a" ) ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); - QCOMPARE( child.dependencies(), QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( QStringLiteral( "a" ) ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); + child.setDependencies( QList() << QgsProcessingModelChildDependency( QStringLiteral( "a" ) ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); + QCOMPARE( child.dependencies(), QList() << QgsProcessingModelChildDependency( QStringLiteral( "a" ) ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); - QMap< QString, QgsProcessingModelChildParameterSources > sources; + QMap sources; sources.insert( QStringLiteral( "a" ), QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) ); child.setParameterSources( sources ); QCOMPARE( child.parameterSources().value( QStringLiteral( "a" ) ).at( 0 ).staticValue().toInt(), 5 ); @@ -497,7 +482,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() child.comment()->setDescription( QStringLiteral( "do something useful" ) ); QCOMPARE( child.asPythonCode( QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass, extraParams, 4, 2, friendlyNames, friendlyOutputNames ).join( '\n' ), QStringLiteral( " # desc\n # do something useful\n alg_params = {\n 'a': 5,\n 'b': [7,9],\n 'SOMETHING': SOMETHING_ELSE,\n 'SOMETHING2': SOMETHING_ELSE2\n }\n outputs['my_id'] = processing.run('native:centroids', alg_params, context=context, feedback=feedback, is_child_algorithm=True)" ) ); - std::unique_ptr< QgsProcessingModelChildAlgorithm > childClone( child.clone() ); + std::unique_ptr childClone( child.clone() ); QCOMPARE( childClone->toVariant(), child.toVariant() ); QCOMPARE( childClone->comment()->description(), QStringLiteral( "do something useful" ) ); @@ -512,7 +497,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QVERIFY( testModelOut.isMandatory() ); testModelOut.comment()->setDescription( QStringLiteral( "my comm" ) ); QCOMPARE( testModelOut.comment()->description(), QStringLiteral( "my comm" ) ); - std::unique_ptr< QgsProcessingModelOutput > outputClone( testModelOut.clone() ); + std::unique_ptr outputClone( testModelOut.clone() ); QCOMPARE( outputClone->toVariant(), testModelOut.toVariant() ); QCOMPARE( outputClone->comment()->description(), QStringLiteral( "my comm" ) ); QgsProcessingModelOutput testModelOutV; @@ -618,7 +603,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() oo.comment()->setPosition( QPointF( 313, 314 ) ); oo.comment()->setDescription( QStringLiteral( "c3" ) ); oo.comment()->setColor( QColor( 155, 14, 353 ) ); - QMap< QString, QgsProcessingModelOutput > a2Outs; + QMap a2Outs; a2Outs.insert( QStringLiteral( "out1" ), oo ); a2.setModelOutputs( a2Outs ); @@ -633,7 +618,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() a2other.setChildId( QStringLiteral( "b" ) ); a2other.setDescription( QStringLiteral( "alg2 other" ) ); const QgsProcessingModelOutput oo2; - QMap< QString, QgsProcessingModelOutput > a2Outs2; + QMap a2Outs2; a2Outs2.insert( QStringLiteral( "out1" ), oo2 ); // this one didn't already exist in the algorithm QgsProcessingModelOutput oo3; @@ -703,7 +688,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( alg.addChildAlgorithm( c3 ), QStringLiteral( "centroid_1" ) ); QgsProcessingModelChildAlgorithm c4; c4.setAlgorithmId( QStringLiteral( "centroid" ) ); - c4.setChildId( QStringLiteral( "centroid_1" ) );// dupe id + c4.setChildId( QStringLiteral( "centroid_1" ) ); // dupe id QCOMPARE( alg.addChildAlgorithm( c4 ), QStringLiteral( "centroid_2" ) ); QCOMPARE( alg.childAlgorithm( QStringLiteral( "centroid_2" ) ).childId(), QStringLiteral( "centroid_2" ) ); @@ -714,7 +699,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( pc1.parameterName(), QStringLiteral( "my_param" ) ); pc1.comment()->setDescription( QStringLiteral( "my comment" ) ); QCOMPARE( pc1.comment()->description(), QStringLiteral( "my comment" ) ); - std::unique_ptr< QgsProcessingModelParameter > paramClone( pc1.clone() ); + std::unique_ptr paramClone( pc1.clone() ); QCOMPARE( paramClone->toVariant(), pc1.toVariant() ); QCOMPARE( paramClone->comment()->description(), QStringLiteral( "my comment" ) ); QgsProcessingModelParameter pcc1; @@ -793,7 +778,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() // direct dependency QgsProcessingModelChildAlgorithm c8; c8.setChildId( QStringLiteral( "c8" ) ); - c8.setDependencies( QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( QStringLiteral( "c7" ) ) ); + c8.setDependencies( QList() << QgsProcessingModelChildDependency( QStringLiteral( "c7" ) ) ); alg3.addChildAlgorithm( c8 ); QVERIFY( alg3.dependentChildAlgorithms( QStringLiteral( "c8" ) ).isEmpty() ); QVERIFY( alg3.dependsOnChildAlgorithms( QStringLiteral( "c7" ) ).isEmpty() ); @@ -912,7 +897,6 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QVERIFY( alg3.childAlgorithm( QStringLiteral( "c7" ) ).isActive() ); - //remove child algorithm QVERIFY( !alg3.removeChildAlgorithm( QStringLiteral( "c7" ) ) ); QVERIFY( !alg3.removeChildAlgorithm( QStringLiteral( "c8" ) ) ); @@ -953,9 +937,6 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QVERIFY( alg4.otherParametersDependOnParameter( "layer" ) ); - - - // to/from XML QgsProcessingModelAlgorithm alg5( QStringLiteral( "test" ), QStringLiteral( "testGroup" ) ); alg5.helpContent().insert( QStringLiteral( "author" ), QStringLiteral( "me" ) ); @@ -974,11 +955,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() alg5c1.addParameterSources( QStringLiteral( "y" ), QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromChildOutput( "cx2", "out3" ) ); alg5c1.addParameterSources( QStringLiteral( "z" ), QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) ); alg5c1.addParameterSources( "a", QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromExpression( "2*2" ) ); - alg5c1.addParameterSources( "zm", QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromStaticValue( 6 ) - << QgsProcessingModelChildParameterSource::fromModelParameter( "p2" ) - << QgsProcessingModelChildParameterSource::fromChildOutput( "cx2", "out4" ) - << QgsProcessingModelChildParameterSource::fromExpression( "1+2" ) - << QgsProcessingModelChildParameterSource::fromStaticValue( QgsProperty::fromExpression( "1+8" ) ) ); + alg5c1.addParameterSources( "zm", QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromStaticValue( 6 ) << QgsProcessingModelChildParameterSource::fromModelParameter( "p2" ) << QgsProcessingModelChildParameterSource::fromChildOutput( "cx2", "out4" ) << QgsProcessingModelChildParameterSource::fromExpression( "1+2" ) << QgsProcessingModelChildParameterSource::fromStaticValue( QgsProperty::fromExpression( "1+8" ) ) ); alg5c1.setActive( true ); alg5c1.setLinksCollapsed( Qt::BottomEdge, true ); alg5c1.setLinksCollapsed( Qt::TopEdge, true ); @@ -1000,7 +977,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() alg5c2.setActive( false ); alg5c2.setLinksCollapsed( Qt::BottomEdge, false ); alg5c2.setLinksCollapsed( Qt::TopEdge, false ); - alg5c2.setDependencies( QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( "a" ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); + alg5c2.setDependencies( QList() << QgsProcessingModelChildDependency( "a" ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); alg5.addChildAlgorithm( alg5c2 ); QgsProcessingModelParameter alg5pc1; @@ -1067,7 +1044,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( alg6c1.parameterSources().value( "zm" ).at( 3 ).expression(), QStringLiteral( "1+2" ) ); QCOMPARE( alg6c1.parameterSources().value( "zm" ).at( 4 ).source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); QCOMPARE( alg6c1.parameterSources().value( "zm" ).at( 4 ).staticValue().userType(), qMetaTypeId() ); - QCOMPARE( alg6c1.parameterSources().value( "zm" ).at( 4 ).staticValue().value< QgsProperty >().expressionString(), QStringLiteral( "1+8" ) ); + QCOMPARE( alg6c1.parameterSources().value( "zm" ).at( 4 ).staticValue().value().expressionString(), QStringLiteral( "1+8" ) ); QCOMPARE( alg6c1.modelOutputs().count(), 1 ); QCOMPARE( alg6c1.modelOutputs().value( QStringLiteral( "a" ) ).description(), QStringLiteral( "my output" ) ); @@ -1082,7 +1059,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QVERIFY( !alg6c2.isActive() ); QVERIFY( !alg6c2.linksCollapsed( Qt::BottomEdge ) ); QVERIFY( !alg6c2.linksCollapsed( Qt::TopEdge ) ); - QCOMPARE( alg6c2.dependencies(), QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( "a" ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); + QCOMPARE( alg6c2.dependencies(), QList() << QgsProcessingModelChildDependency( "a" ) << QgsProcessingModelChildDependency( QStringLiteral( "b" ) ) ); QCOMPARE( alg6.parameterComponents().count(), 1 ); QCOMPARE( alg6.parameterComponents().value( QStringLiteral( "my_param" ) ).parameterName(), QStringLiteral( "my_param" ) ); @@ -1111,7 +1088,7 @@ void TestQgsProcessingModelAlgorithm::modelerAlgorithm() QCOMPARE( alg7.destinationParameterDefinitions().count(), 1 ); QCOMPARE( alg7.destinationParameterDefinitions().at( 0 )->name(), QStringLiteral( "my_output" ) ); QCOMPARE( alg7.destinationParameterDefinitions().at( 0 )->description(), QStringLiteral( "my output" ) ); - QCOMPARE( static_cast< const QgsProcessingDestinationParameter * >( alg7.destinationParameterDefinitions().at( 0 ) )->originalProvider()->id(), QStringLiteral( "native" ) ); + QCOMPARE( static_cast( alg7.destinationParameterDefinitions().at( 0 ) )->originalProvider()->id(), QStringLiteral( "native" ) ); QCOMPARE( alg7.outputDefinitions().count(), 1 ); QCOMPARE( alg7.outputDefinitions().at( 0 )->name(), QStringLiteral( "my_output" ) ); QCOMPARE( alg7.outputDefinitions().at( 0 )->type(), QStringLiteral( "outputVector" ) ); @@ -1196,8 +1173,8 @@ void TestQgsProcessingModelAlgorithm::modelExecution() model1.addChildAlgorithm( algc3 ); QVERIFY( model1.childOutputIsRequired( QStringLiteral( "cx1" ), QStringLiteral( "p1" ) ) ); // cx2 depends on p1 - QVERIFY( !model1.childOutputIsRequired( QStringLiteral( "cx1" ), "p2" ) ); // cx3 depends on p2, but cx3 is not active - QVERIFY( !model1.childOutputIsRequired( QStringLiteral( "cx1" ), "p3" ) ); // nothing requires p3 + QVERIFY( !model1.childOutputIsRequired( QStringLiteral( "cx1" ), "p2" ) ); // cx3 depends on p2, but cx3 is not active + QVERIFY( !model1.childOutputIsRequired( QStringLiteral( "cx1" ), "p3" ) ); // nothing requires p3 QVERIFY( !model1.childOutputIsRequired( "cx2", QStringLiteral( "p1" ) ) ); QVERIFY( !model1.childOutputIsRequired( "cx3", QStringLiteral( "p1" ) ) ); @@ -1277,7 +1254,7 @@ void TestQgsProcessingModelAlgorithm::modelExecution() QGSCOMPARENEAR( variables.value( "SOURCE_LAYER_maxx" ).value.toDouble(), -83.3333, 0.001 ); QGSCOMPARENEAR( variables.value( "SOURCE_LAYER_maxy" ).value.toDouble(), 46.8719, 0.001 ); - std::unique_ptr< QgsExpressionContextScope > childScope( model2.createExpressionContextScopeForChildAlgorithm( QStringLiteral( "cx1" ), context, modelInputs, childResults ) ); + std::unique_ptr childScope( model2.createExpressionContextScopeForChildAlgorithm( QStringLiteral( "cx1" ), context, modelInputs, childResults ) ); QCOMPARE( childScope->name(), QStringLiteral( "algorithm_inputs" ) ); QCOMPARE( childScope->variableCount(), 7 ); QCOMPARE( childScope->variable( "DIST" ).toInt(), 271 ); @@ -1315,7 +1292,7 @@ void TestQgsProcessingModelAlgorithm::modelExecution() QCOMPARE( variables.value( "cx1_OUTPUT" ).source.source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); QCOMPARE( variables.value( "cx1_OUTPUT" ).source.outputChildId(), QStringLiteral( "cx1" ) ); QCOMPARE( variables.value( "cx1_OUTPUT_minx" ).source.source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); - QCOMPARE( variables.value( "cx1_OUTPUT_minx" ).source.outputChildId(), QStringLiteral( "cx1" ) ); + QCOMPARE( variables.value( "cx1_OUTPUT_minx" ).source.outputChildId(), QStringLiteral( "cx1" ) ); QCOMPARE( variables.value( "cx1_OUTPUT_miny" ).source.source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); QCOMPARE( variables.value( "cx1_OUTPUT_miny" ).source.outputChildId(), QStringLiteral( "cx1" ) ); QCOMPARE( variables.value( "cx1_OUTPUT_maxx" ).source.source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); @@ -1342,7 +1319,7 @@ void TestQgsProcessingModelAlgorithm::modelExecution() alg2c3.addParameterSources( "INPUT", QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "cx1" ), "OUTPUT" ) ); alg2c3.addParameterSources( "EXPRESSION", QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromStaticValue( "true" ) ); alg2c3.addParameterSources( "OUTPUT", QgsProcessingModelChildParameterSources() << QgsProcessingModelChildParameterSource::fromModelParameter( "MY_OUT" ) ); - alg2c3.setDependencies( QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( "cx2" ) ); + alg2c3.setDependencies( QList() << QgsProcessingModelChildDependency( "cx2" ) ); QMap outputs3; QgsProcessingModelOutput out2( "MY_OUT" ); out2.setChildOutputName( "OUTPUT" ); @@ -1472,94 +1449,96 @@ void TestQgsProcessingModelAlgorithm::modelExecution() const QStringList actualParts = model2.asPythonCode( QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass, 2 ); QgsDebugMsgLevel( actualParts.join( '\n' ), 1 ); const QStringList expectedParts = QStringLiteral( "\"\"\"\n" - "Model exported as python.\n" - "Name : 2my model\n" - "Group : \n" - "With QGIS : %1\n" - "\"\"\"\n\n" - "from qgis.core import QgsProcessing\n" - "from qgis.core import QgsProcessingAlgorithm\n" - "from qgis.core import QgsProcessingMultiStepFeedback\n" - "from qgis.core import QgsProcessingParameterFeatureSource\n" - "from qgis.core import QgsProcessingParameterNumber\n" - "from qgis.core import QgsProcessingParameterCrs\n" - "from qgis.core import QgsProcessingParameterFeatureSink\n" - "from qgis.core import QgsProcessingParameterDefinition\n" - "from qgis.core import QgsCoordinateReferenceSystem\n" - "from qgis.core import QgsExpression\n" - "import processing\n" - "\n" - "\n" - "class MyModel(QgsProcessingAlgorithm):\n" - "\n" - " def initAlgorithm(self, config=None):\n" - " # an input\n" - " self.addParameter(QgsProcessingParameterFeatureSource('SOURCE_LAYER', '', defaultValue=None))\n" - " self.addParameter(QgsProcessingParameterNumber('DIST', '', type=QgsProcessingParameterNumber.Double, defaultValue=None))\n" - " param = QgsProcessingParameterCrs('CRS', '', defaultValue=QgsCoordinateReferenceSystem('EPSG:28355'))\n" - " param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)\n" - " self.addParameter(param)\n" - " self.addParameter(QgsProcessingParameterFeatureSink('MyModelOutput', 'my model output', type=QgsProcessing.TypeVectorPolygon, createByDefault=True, supportsAppend=True, defaultValue=None))\n" - " self.addParameter(QgsProcessingParameterFeatureSink('MyOutput', 'My output', type=QgsProcessing.TypeVectorAnyGeometry, createByDefault=True, defaultValue=None))\n" - "\n" - " def processAlgorithm(self, parameters, context, model_feedback):\n" - " # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the\n" - " # overall progress through the model\n" - " feedback = QgsProcessingMultiStepFeedback(3, model_feedback)\n" - " results = {}\n" - " outputs = {}\n" - "\n" - " # first step in my model\n" - " alg_params = {\n" - " 'DISSOLVE': False,\n" - " 'DISTANCE': parameters['DIST'],\n" - " 'END_CAP_STYLE': 1, # Flat\n" - " 'INPUT': parameters['SOURCE_LAYER'],\n" - " 'JOIN_STYLE': 2, # Bevel\n" - " 'SEGMENTS': QgsExpression('@myvar*2').evaluate(),\n" - " 'OUTPUT': parameters['MyModelOutput']\n" - " }\n" - " outputs['FirstStepInMyModel'] = processing.run('native:buffer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)\n" - " results['MyModelOutput'] = outputs['FirstStepInMyModel']['OUTPUT']\n" - "\n" - " feedback.setCurrentStep(1)\n" - " if feedback.isCanceled():\n" - " return {}\n" - "\n" - " alg_params = {\n" - " 'INPUT': outputs['FirstStepInMyModel']['OUTPUT'],\n" - " 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT\n" - " }\n" - " outputs['cx2'] = processing.run('native:centroids', alg_params, context=context, feedback=feedback, is_child_algorithm=True)\n" - "\n" - " feedback.setCurrentStep(2)\n" - " if feedback.isCanceled():\n" - " return {}\n" - "\n" - " alg_params = {\n" - " 'EXPRESSION': 'true',\n" - " 'INPUT': outputs['FirstStepInMyModel']['OUTPUT'],\n" - " 'OUTPUT': parameters['MY_OUT'],\n" - " 'OUTPUT': parameters['MyOutput']\n" - " }\n" - " outputs['cx3'] = processing.run('native:extractbyexpression', alg_params, context=context, feedback=feedback, is_child_algorithm=True)\n" - " results['MyOutput'] = outputs['cx3']['OUTPUT']\n" - " return results\n" - "\n" - " def name(self):\n" - " return '2my model'\n" - "\n" - " def displayName(self):\n" - " return '2my model'\n" - "\n" - " def group(self):\n" - " return ''\n" - "\n" - " def groupId(self):\n" - " return ''\n" - "\n" - " def createInstance(self):\n" - " return MyModel()\n" ).arg( Qgis::versionInt() ).split( '\n' ); + "Model exported as python.\n" + "Name : 2my model\n" + "Group : \n" + "With QGIS : %1\n" + "\"\"\"\n\n" + "from qgis.core import QgsProcessing\n" + "from qgis.core import QgsProcessingAlgorithm\n" + "from qgis.core import QgsProcessingMultiStepFeedback\n" + "from qgis.core import QgsProcessingParameterFeatureSource\n" + "from qgis.core import QgsProcessingParameterNumber\n" + "from qgis.core import QgsProcessingParameterCrs\n" + "from qgis.core import QgsProcessingParameterFeatureSink\n" + "from qgis.core import QgsProcessingParameterDefinition\n" + "from qgis.core import QgsCoordinateReferenceSystem\n" + "from qgis.core import QgsExpression\n" + "import processing\n" + "\n" + "\n" + "class MyModel(QgsProcessingAlgorithm):\n" + "\n" + " def initAlgorithm(self, config=None):\n" + " # an input\n" + " self.addParameter(QgsProcessingParameterFeatureSource('SOURCE_LAYER', '', defaultValue=None))\n" + " self.addParameter(QgsProcessingParameterNumber('DIST', '', type=QgsProcessingParameterNumber.Double, defaultValue=None))\n" + " param = QgsProcessingParameterCrs('CRS', '', defaultValue=QgsCoordinateReferenceSystem('EPSG:28355'))\n" + " param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)\n" + " self.addParameter(param)\n" + " self.addParameter(QgsProcessingParameterFeatureSink('MyModelOutput', 'my model output', type=QgsProcessing.TypeVectorPolygon, createByDefault=True, supportsAppend=True, defaultValue=None))\n" + " self.addParameter(QgsProcessingParameterFeatureSink('MyOutput', 'My output', type=QgsProcessing.TypeVectorAnyGeometry, createByDefault=True, defaultValue=None))\n" + "\n" + " def processAlgorithm(self, parameters, context, model_feedback):\n" + " # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the\n" + " # overall progress through the model\n" + " feedback = QgsProcessingMultiStepFeedback(3, model_feedback)\n" + " results = {}\n" + " outputs = {}\n" + "\n" + " # first step in my model\n" + " alg_params = {\n" + " 'DISSOLVE': False,\n" + " 'DISTANCE': parameters['DIST'],\n" + " 'END_CAP_STYLE': 1, # Flat\n" + " 'INPUT': parameters['SOURCE_LAYER'],\n" + " 'JOIN_STYLE': 2, # Bevel\n" + " 'SEGMENTS': QgsExpression('@myvar*2').evaluate(),\n" + " 'OUTPUT': parameters['MyModelOutput']\n" + " }\n" + " outputs['FirstStepInMyModel'] = processing.run('native:buffer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)\n" + " results['MyModelOutput'] = outputs['FirstStepInMyModel']['OUTPUT']\n" + "\n" + " feedback.setCurrentStep(1)\n" + " if feedback.isCanceled():\n" + " return {}\n" + "\n" + " alg_params = {\n" + " 'INPUT': outputs['FirstStepInMyModel']['OUTPUT'],\n" + " 'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT\n" + " }\n" + " outputs['cx2'] = processing.run('native:centroids', alg_params, context=context, feedback=feedback, is_child_algorithm=True)\n" + "\n" + " feedback.setCurrentStep(2)\n" + " if feedback.isCanceled():\n" + " return {}\n" + "\n" + " alg_params = {\n" + " 'EXPRESSION': 'true',\n" + " 'INPUT': outputs['FirstStepInMyModel']['OUTPUT'],\n" + " 'OUTPUT': parameters['MY_OUT'],\n" + " 'OUTPUT': parameters['MyOutput']\n" + " }\n" + " outputs['cx3'] = processing.run('native:extractbyexpression', alg_params, context=context, feedback=feedback, is_child_algorithm=True)\n" + " results['MyOutput'] = outputs['cx3']['OUTPUT']\n" + " return results\n" + "\n" + " def name(self):\n" + " return '2my model'\n" + "\n" + " def displayName(self):\n" + " return '2my model'\n" + "\n" + " def group(self):\n" + " return ''\n" + "\n" + " def groupId(self):\n" + " return ''\n" + "\n" + " def createInstance(self):\n" + " return MyModel()\n" ) + .arg( Qgis::versionInt() ) + .split( '\n' ); QCOMPARE( actualParts, expectedParts ); } @@ -1590,14 +1569,14 @@ void TestQgsProcessingModelAlgorithm::modelBranchPruning() QgsProcessingModelParameter param; param.setParameterName( QStringLiteral( "LAYER" ) ); model1.addModelParameter( new QgsProcessingParameterMapLayer( QStringLiteral( "LAYER" ) ), param ); - algc1.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "LAYER" ) ) ); + algc1.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "LAYER" ) ) ); model1.addChildAlgorithm( algc1 ); //then create some branches which come off this, depending on the layer type QgsProcessingModelChildAlgorithm algc2; algc2.setChildId( QStringLiteral( "buffer" ) ); algc2.setAlgorithmId( "native:buffer" ); - algc2.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "filter" ), QStringLiteral( "VECTOR" ) ) ); + algc2.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "filter" ), QStringLiteral( "VECTOR" ) ) ); QMap outputsc2; QgsProcessingModelOutput outc2( "BUFFER_OUTPUT" ); outc2.setChildOutputName( "OUTPUT" ); @@ -1608,7 +1587,7 @@ void TestQgsProcessingModelAlgorithm::modelBranchPruning() QgsProcessingModelChildAlgorithm algc3; algc3.setChildId( "buffer2" ); algc3.setAlgorithmId( "native:buffer" ); - algc3.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "buffer" ), QStringLiteral( "OUTPUT" ) ) ); + algc3.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "buffer" ), QStringLiteral( "OUTPUT" ) ) ); QMap outputsc3; QgsProcessingModelOutput outc3( "BUFFER2_OUTPUT" ); outc3.setChildOutputName( "OUTPUT" ); @@ -1618,7 +1597,7 @@ void TestQgsProcessingModelAlgorithm::modelBranchPruning() QgsProcessingModelChildAlgorithm algc4; algc4.setChildId( "buffer3" ); algc4.setAlgorithmId( "native:buffer" ); - algc4.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "buffer" ), QStringLiteral( "OUTPUT" ) ) ); + algc4.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "buffer" ), QStringLiteral( "OUTPUT" ) ) ); QMap outputsc4; QgsProcessingModelOutput outc4( "BUFFER3_OUTPUT" ); outc4.setChildOutputName( "OUTPUT" ); @@ -1630,7 +1609,7 @@ void TestQgsProcessingModelAlgorithm::modelBranchPruning() QgsProcessingModelChildAlgorithm algr2; algr2.setChildId( "fill2" ); algr2.setAlgorithmId( "native:fillnodata" ); - algr2.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "filter" ), QStringLiteral( "RASTER" ) ) ); + algr2.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "filter" ), QStringLiteral( "RASTER" ) ) ); QMap outputsr2; QgsProcessingModelOutput outr2( "RASTER_OUTPUT" ); outr2.setChildOutputName( "OUTPUT" ); @@ -1642,7 +1621,7 @@ void TestQgsProcessingModelAlgorithm::modelBranchPruning() QgsProcessingModelChildAlgorithm algr3; algr3.setChildId( "fill3" ); algr3.setAlgorithmId( "native:fillnodata" ); - algr3.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "fill2" ), QStringLiteral( "OUTPUT" ) ) ); + algr3.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "fill2" ), QStringLiteral( "OUTPUT" ) ) ); QMap outputsr3; QgsProcessingModelOutput outr3( "RASTER_OUTPUT2" ); outr3.setChildOutputName( "OUTPUT" ); @@ -1653,7 +1632,7 @@ void TestQgsProcessingModelAlgorithm::modelBranchPruning() QgsProcessingModelChildAlgorithm algr4; algr4.setChildId( "fill4" ); algr4.setAlgorithmId( "native:fillnodata" ); - algr4.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "fill2" ), QStringLiteral( "OUTPUT" ) ) ); + algr4.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "fill2" ), QStringLiteral( "OUTPUT" ) ) ); QMap outputsr4; QgsProcessingModelOutput outr4( "RASTER_OUTPUT3" ); outr4.setChildOutputName( "OUTPUT" ); @@ -1726,13 +1705,13 @@ void TestQgsProcessingModelAlgorithm::modelBranchPruningConditional() QgsProcessingModelChildAlgorithm algc2; algc2.setChildId( "exception" ); algc2.setAlgorithmId( "native:raiseexception" ); - algc2.setDependencies( QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( QStringLiteral( "branch" ), QStringLiteral( "name1" ) ) ); + algc2.setDependencies( QList() << QgsProcessingModelChildDependency( QStringLiteral( "branch" ), QStringLiteral( "name1" ) ) ); model1.addChildAlgorithm( algc2 ); QgsProcessingModelChildAlgorithm algc3; algc2.setChildId( "exception" ); algc3.setAlgorithmId( "native:raisewarning" ); - algc3.setDependencies( QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( QStringLiteral( "branch" ), QStringLiteral( "name2" ) ) ); + algc3.setDependencies( QList() << QgsProcessingModelChildDependency( QStringLiteral( "branch" ), QStringLiteral( "name2" ) ) ); model1.addChildAlgorithm( algc3 ); QgsProcessingFeedback feedback; @@ -1778,27 +1757,27 @@ void TestQgsProcessingModelAlgorithm::modelWithProviderWithLimitedTypes() QCOMPARE( alg.destinationParameterDefinitions().count(), 3 ); QCOMPARE( alg.destinationParameterDefinitions().at( 2 )->name(), QStringLiteral( "my_output_3" ) ); QCOMPARE( alg.destinationParameterDefinitions().at( 2 )->description(), QStringLiteral( "my output" ) ); - QCOMPARE( static_cast< const QgsProcessingDestinationParameter * >( alg.destinationParameterDefinitions().at( 2 ) )->originalProvider()->id(), QStringLiteral( "dummy4" ) ); - QCOMPARE( static_cast< const QgsProcessingParameterVectorDestination * >( alg.destinationParameterDefinitions().at( 2 ) )->supportedOutputVectorLayerExtensions(), QStringList() << QStringLiteral( "mif" ) ); - QCOMPARE( static_cast< const QgsProcessingParameterVectorDestination * >( alg.destinationParameterDefinitions().at( 2 ) )->defaultFileExtension(), QStringLiteral( "mif" ) ); - QVERIFY( static_cast< const QgsProcessingParameterVectorDestination * >( alg.destinationParameterDefinitions().at( 2 ) )->generateTemporaryDestination().endsWith( QLatin1String( ".mif" ) ) ); - QVERIFY( !static_cast< const QgsProcessingDestinationParameter * >( alg.destinationParameterDefinitions().at( 2 ) )->supportsNonFileBasedOutput() ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 2 ) )->originalProvider()->id(), QStringLiteral( "dummy4" ) ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 2 ) )->supportedOutputVectorLayerExtensions(), QStringList() << QStringLiteral( "mif" ) ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 2 ) )->defaultFileExtension(), QStringLiteral( "mif" ) ); + QVERIFY( static_cast( alg.destinationParameterDefinitions().at( 2 ) )->generateTemporaryDestination().endsWith( QLatin1String( ".mif" ) ) ); + QVERIFY( !static_cast( alg.destinationParameterDefinitions().at( 2 ) )->supportsNonFileBasedOutput() ); QCOMPARE( alg.destinationParameterDefinitions().at( 0 )->name(), QStringLiteral( "my_output" ) ); QCOMPARE( alg.destinationParameterDefinitions().at( 0 )->description(), QStringLiteral( "my output" ) ); - QCOMPARE( static_cast< const QgsProcessingDestinationParameter * >( alg.destinationParameterDefinitions().at( 0 ) )->originalProvider()->id(), QStringLiteral( "dummy4" ) ); - QCOMPARE( static_cast< const QgsProcessingParameterRasterDestination * >( alg.destinationParameterDefinitions().at( 0 ) )->supportedOutputRasterLayerExtensions(), QStringList() << QStringLiteral( "mig" ) ); - QCOMPARE( static_cast< const QgsProcessingParameterRasterDestination * >( alg.destinationParameterDefinitions().at( 0 ) )->defaultFileExtension(), QStringLiteral( "mig" ) ); - QVERIFY( static_cast< const QgsProcessingParameterRasterDestination * >( alg.destinationParameterDefinitions().at( 0 ) )->generateTemporaryDestination().endsWith( QLatin1String( ".mig" ) ) ); - QVERIFY( !static_cast< const QgsProcessingDestinationParameter * >( alg.destinationParameterDefinitions().at( 0 ) )->supportsNonFileBasedOutput() ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 0 ) )->originalProvider()->id(), QStringLiteral( "dummy4" ) ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 0 ) )->supportedOutputRasterLayerExtensions(), QStringList() << QStringLiteral( "mig" ) ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 0 ) )->defaultFileExtension(), QStringLiteral( "mig" ) ); + QVERIFY( static_cast( alg.destinationParameterDefinitions().at( 0 ) )->generateTemporaryDestination().endsWith( QLatin1String( ".mig" ) ) ); + QVERIFY( !static_cast( alg.destinationParameterDefinitions().at( 0 ) )->supportsNonFileBasedOutput() ); QCOMPARE( alg.destinationParameterDefinitions().at( 1 )->name(), QStringLiteral( "my_output_2" ) ); QCOMPARE( alg.destinationParameterDefinitions().at( 1 )->description(), QStringLiteral( "my output" ) ); - QCOMPARE( static_cast< const QgsProcessingDestinationParameter * >( alg.destinationParameterDefinitions().at( 1 ) )->originalProvider()->id(), QStringLiteral( "dummy4" ) ); - QCOMPARE( static_cast< const QgsProcessingParameterFeatureSink * >( alg.destinationParameterDefinitions().at( 1 ) )->supportedOutputVectorLayerExtensions(), QStringList() << QStringLiteral( "mif" ) ); - QCOMPARE( static_cast< const QgsProcessingParameterFeatureSink * >( alg.destinationParameterDefinitions().at( 1 ) )->defaultFileExtension(), QStringLiteral( "mif" ) ); - QVERIFY( static_cast< const QgsProcessingParameterFeatureSink * >( alg.destinationParameterDefinitions().at( 1 ) )->generateTemporaryDestination().endsWith( QLatin1String( ".mif" ) ) ); - QVERIFY( !static_cast< const QgsProcessingDestinationParameter * >( alg.destinationParameterDefinitions().at( 1 ) )->supportsNonFileBasedOutput() ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 1 ) )->originalProvider()->id(), QStringLiteral( "dummy4" ) ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 1 ) )->supportedOutputVectorLayerExtensions(), QStringList() << QStringLiteral( "mif" ) ); + QCOMPARE( static_cast( alg.destinationParameterDefinitions().at( 1 ) )->defaultFileExtension(), QStringLiteral( "mif" ) ); + QVERIFY( static_cast( alg.destinationParameterDefinitions().at( 1 ) )->generateTemporaryDestination().endsWith( QLatin1String( ".mif" ) ) ); + QVERIFY( !static_cast( alg.destinationParameterDefinitions().at( 1 ) )->supportsNonFileBasedOutput() ); } void TestQgsProcessingModelAlgorithm::modelVectorOutputIsCompatibleType() @@ -1816,8 +1795,8 @@ void TestQgsProcessingModelAlgorithm::modelVectorOutputIsCompatibleType() QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( QList(), Qgis::ProcessingSourceType::MapLayer ) ); // accept any vector - QList< int > dataTypes; - dataTypes << static_cast< int >( Qgis::ProcessingSourceType::Vector ); + QList dataTypes; + dataTypes << static_cast( Qgis::ProcessingSourceType::Vector ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::Vector ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorPoint ) ); @@ -1827,7 +1806,7 @@ void TestQgsProcessingModelAlgorithm::modelVectorOutputIsCompatibleType() // accept any vector with geometry dataTypes.clear(); - dataTypes << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ); + dataTypes << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::Vector ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorPoint ) ); @@ -1837,7 +1816,7 @@ void TestQgsProcessingModelAlgorithm::modelVectorOutputIsCompatibleType() // accept any point vector dataTypes.clear(); - dataTypes << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ); + dataTypes << static_cast( Qgis::ProcessingSourceType::VectorPoint ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::Vector ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorPoint ) ); @@ -1847,7 +1826,7 @@ void TestQgsProcessingModelAlgorithm::modelVectorOutputIsCompatibleType() // accept any line vector dataTypes.clear(); - dataTypes << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ); + dataTypes << static_cast( Qgis::ProcessingSourceType::VectorLine ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::Vector ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QVERIFY( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorPoint ) ); @@ -1857,7 +1836,7 @@ void TestQgsProcessingModelAlgorithm::modelVectorOutputIsCompatibleType() // accept any polygon vector dataTypes.clear(); - dataTypes << static_cast< int >( Qgis::ProcessingSourceType::VectorPolygon ); + dataTypes << static_cast( Qgis::ProcessingSourceType::VectorPolygon ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::Vector ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QVERIFY( !QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorPoint ) ); @@ -1867,7 +1846,7 @@ void TestQgsProcessingModelAlgorithm::modelVectorOutputIsCompatibleType() // accept any map layer dataTypes.clear(); - dataTypes << static_cast< int >( Qgis::ProcessingSourceType::MapLayer ); + dataTypes << static_cast( Qgis::ProcessingSourceType::MapLayer ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::Vector ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QVERIFY( QgsProcessingModelAlgorithm::vectorOutputIsCompatibleType( dataTypes, Qgis::ProcessingSourceType::VectorPoint ) ); @@ -1908,16 +1887,13 @@ void TestQgsProcessingModelAlgorithm::modelAcceptableValues() // test multiple types sources = m.availableSourcesForChild( QString(), QStringList() << "string" << "number" << "file" ); QCOMPARE( sources.count(), 4 ); - QSet< QString > res; + QSet res; res << sources.at( 0 ).parameterName(); res << sources.at( 1 ).parameterName(); res << sources.at( 2 ).parameterName(); res << sources.at( 3 ).parameterName(); - QCOMPARE( res, QSet< QString >() << QStringLiteral( "string" ) - << QStringLiteral( "string2" ) - << QStringLiteral( "number" ) - << QStringLiteral( "file" ) ); + QCOMPARE( res, QSet() << QStringLiteral( "string" ) << QStringLiteral( "string2" ) << QStringLiteral( "number" ) << QStringLiteral( "file" ) ); // check outputs QgsProcessingModelChildAlgorithm alg2c1; @@ -1929,20 +1905,20 @@ void TestQgsProcessingModelAlgorithm::modelAcceptableValues() QCOMPARE( sources.count(), 1 ); res.clear(); res << sources.at( 0 ).outputChildId() + ':' + sources.at( 0 ).outputName(); - QCOMPARE( res, QSet< QString >() << "cx1:OUTPUT" ); + QCOMPARE( res, QSet() << "cx1:OUTPUT" ); // with dependencies between child algs QgsProcessingModelChildAlgorithm alg2c2; alg2c2.setChildId( "cx2" ); alg2c2.setAlgorithmId( "native:centroids" ); - alg2c2.setDependencies( QList< QgsProcessingModelChildDependency >() << QgsProcessingModelChildDependency( QStringLiteral( "cx1" ) ) ); + alg2c2.setDependencies( QList() << QgsProcessingModelChildDependency( QStringLiteral( "cx1" ) ) ); m.addChildAlgorithm( alg2c2 ); sources = m.availableSourcesForChild( QString(), QStringList(), QStringList() << "string" << "outputVector" ); QCOMPARE( sources.count(), 2 ); res.clear(); res << sources.at( 0 ).outputChildId() + ':' + sources.at( 0 ).outputName(); res << sources.at( 1 ).outputChildId() + ':' + sources.at( 1 ).outputName(); - QCOMPARE( res, QSet< QString >() << "cx1:OUTPUT" << "cx2:OUTPUT" ); + QCOMPARE( res, QSet() << "cx1:OUTPUT" << "cx2:OUTPUT" ); sources = m.availableSourcesForChild( QStringLiteral( "cx1" ), QStringList(), QStringList() << "string" << "outputVector" ); QCOMPARE( sources.count(), 0 ); @@ -1951,7 +1927,7 @@ void TestQgsProcessingModelAlgorithm::modelAcceptableValues() QCOMPARE( sources.count(), 1 ); res.clear(); res << sources.at( 0 ).outputChildId() + ':' + sources.at( 0 ).outputName(); - QCOMPARE( res, QSet< QString >() << "cx1:OUTPUT" ); + QCOMPARE( res, QSet() << "cx1:OUTPUT" ); // test limiting by data types QgsProcessingModelAlgorithm m2; @@ -1965,19 +1941,19 @@ void TestQgsProcessingModelAlgorithm::modelAcceptableValues() QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::MapLayer ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::MapLayer ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); @@ -1985,25 +1961,25 @@ void TestQgsProcessingModelAlgorithm::modelAcceptableValues() // inputs are limited to vector layers m2.removeModelParameter( vlInput.parameterName() ); m2.removeModelParameter( fsInput.parameterName() ); - m2.addModelParameter( new QgsProcessingParameterVectorLayer( "vl", QString(), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ), vlInput ); - m2.addModelParameter( new QgsProcessingParameterFeatureSource( "fs", QString(), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ), fsInput ); + m2.addModelParameter( new QgsProcessingParameterVectorLayer( "vl", QString(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ), vlInput ); + m2.addModelParameter( new QgsProcessingParameterFeatureSource( "fs", QString(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ), fsInput ); sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source" ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::MapLayer ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::MapLayer ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); @@ -2011,25 +1987,25 @@ void TestQgsProcessingModelAlgorithm::modelAcceptableValues() // inputs are limited to vector layers with geometries m2.removeModelParameter( vlInput.parameterName() ); m2.removeModelParameter( fsInput.parameterName() ); - m2.addModelParameter( new QgsProcessingParameterVectorLayer( "vl", QString(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ), vlInput ); - m2.addModelParameter( new QgsProcessingParameterFeatureSource( "fs", QString(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ), fsInput ); + m2.addModelParameter( new QgsProcessingParameterVectorLayer( "vl", QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ), vlInput ); + m2.addModelParameter( new QgsProcessingParameterFeatureSource( "fs", QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ), fsInput ); sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source" ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::MapLayer ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::MapLayer ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); @@ -2037,29 +2013,29 @@ void TestQgsProcessingModelAlgorithm::modelAcceptableValues() // inputs are limited to vector layers with lines m2.removeModelParameter( vlInput.parameterName() ); m2.removeModelParameter( fsInput.parameterName() ); - m2.addModelParameter( new QgsProcessingParameterVectorLayer( "vl", QString(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ), vlInput ); - m2.addModelParameter( new QgsProcessingParameterFeatureSource( "fs", QString(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ), fsInput ); + m2.addModelParameter( new QgsProcessingParameterVectorLayer( "vl", QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorLine ) ), vlInput ); + m2.addModelParameter( new QgsProcessingParameterFeatureSource( "fs", QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorLine ) ), fsInput ); sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source" ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); QCOMPARE( sources.count(), 0 ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorPolygon ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) ); QCOMPARE( sources.count(), 0 ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); - sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast< int >( Qgis::ProcessingSourceType::MapLayer ) ); + sources = m2.availableSourcesForChild( QString(), QStringList() << "vector" << "source", QStringList(), QList() << static_cast( Qgis::ProcessingSourceType::MapLayer ) ); QCOMPARE( sources.count(), 2 ); QCOMPARE( sources.at( 0 ).parameterName(), QStringLiteral( "fs" ) ); QCOMPARE( sources.at( 1 ).parameterName(), QStringLiteral( "vl" ) ); @@ -2092,7 +2068,7 @@ void TestQgsProcessingModelAlgorithm::modelValidate() QgsProcessingModelChildParameterSource badSource; badSource.setSource( Qgis::ProcessingModelChildParameterSource::StaticValue ); badSource.setStaticValue( 56 ); - m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << badSource ); + m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList() << badSource ); QVERIFY( !m.validateChildAlgorithm( QStringLiteral( "cx1" ), errors ) ); QCOMPARE( errors.size(), 1 ); @@ -2100,7 +2076,7 @@ void TestQgsProcessingModelAlgorithm::modelValidate() QgsProcessingModelChildParameterSource goodSource; goodSource.setSource( Qgis::ProcessingModelChildParameterSource::Expression ); - m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "ALL_PARTS" ), QList< QgsProcessingModelChildParameterSource >() << goodSource ); + m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "ALL_PARTS" ), QList() << goodSource ); QVERIFY( !m.validateChildAlgorithm( QStringLiteral( "cx1" ), errors ) ); QCOMPARE( errors.size(), 1 ); @@ -2117,13 +2093,13 @@ void TestQgsProcessingModelAlgorithm::modelValidate() QCOMPARE( errors.at( 1 ), QStringLiteral( "Parameter INPUT_2 is mandatory" ) ); goodSource.setSource( Qgis::ProcessingModelChildParameterSource::StaticValue ); goodSource.setStaticValue( 56 ); - m.childAlgorithm( QStringLiteral( "cx3" ) ).addParameterSources( QStringLiteral( "INPUT_1" ), QList< QgsProcessingModelChildParameterSource >() << goodSource ); + m.childAlgorithm( QStringLiteral( "cx3" ) ).addParameterSources( QStringLiteral( "INPUT_1" ), QList() << goodSource ); QVERIFY( !m.validateChildAlgorithm( QStringLiteral( "cx3" ), errors ) ); QCOMPARE( errors.size(), 1 ); QCOMPARE( errors.at( 0 ), QStringLiteral( "Parameter INPUT_2 is mandatory" ) ); badSource.setSource( Qgis::ProcessingModelChildParameterSource::StaticValue ); badSource.setStaticValue( "" ); - m.childAlgorithm( QStringLiteral( "cx3" ) ).addParameterSources( QStringLiteral( "INPUT_1" ), QList< QgsProcessingModelChildParameterSource >() << badSource ); + m.childAlgorithm( QStringLiteral( "cx3" ) ).addParameterSources( QStringLiteral( "INPUT_1" ), QList() << badSource ); QVERIFY( !m.validateChildAlgorithm( QStringLiteral( "cx3" ), errors ) ); QCOMPARE( errors.size(), 2 ); QCOMPARE( errors.at( 0 ), QStringLiteral( "Value for INPUT_1 is not acceptable for this parameter" ) ); @@ -2133,7 +2109,7 @@ void TestQgsProcessingModelAlgorithm::modelValidate() badSource.setSource( Qgis::ProcessingModelChildParameterSource::ChildOutput ); badSource.setOutputChildId( QStringLiteral( "cc" ) ); - m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << badSource ); + m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList() << badSource ); QVERIFY( !m.validateChildAlgorithm( QStringLiteral( "cx1" ), errors ) ); QCOMPARE( errors.size(), 1 ); @@ -2141,7 +2117,7 @@ void TestQgsProcessingModelAlgorithm::modelValidate() badSource.setSource( Qgis::ProcessingModelChildParameterSource::ModelParameter ); badSource.setParameterName( QStringLiteral( "cc" ) ); - m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << badSource ); + m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList() << badSource ); QVERIFY( !m.validateChildAlgorithm( QStringLiteral( "cx1" ), errors ) ); QCOMPARE( errors.size(), 1 ); @@ -2149,7 +2125,7 @@ void TestQgsProcessingModelAlgorithm::modelValidate() goodSource.setSource( Qgis::ProcessingModelChildParameterSource::StaticValue ); goodSource.setStaticValue( QString( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ) ); - m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << goodSource ); + m.childAlgorithm( QStringLiteral( "cx1" ) ).addParameterSources( QStringLiteral( "INPUT" ), QList() << goodSource ); QVERIFY( m.validateChildAlgorithm( QStringLiteral( "cx1" ), errors ) ); QCOMPARE( errors.size(), 0 ); @@ -2385,7 +2361,7 @@ void TestQgsProcessingModelAlgorithm::modelWithChildException() algWhichRaisesException.setChildId( QStringLiteral( "raise" ) ); algWhichRaisesException.setDescription( QStringLiteral( "my second step" ) ); algWhichRaisesException.setAlgorithmId( "dummy4:raise" ); - algWhichRaisesException.setDependencies( {QgsProcessingModelChildDependency( QStringLiteral( "buffer" ) )} ); + algWhichRaisesException.setDependencies( { QgsProcessingModelChildDependency( QStringLiteral( "buffer" ) ) } ); m.addChildAlgorithm( algWhichRaisesException ); // run and check context details @@ -2425,7 +2401,7 @@ void TestQgsProcessingModelAlgorithm::modelWithChildException() QCOMPARE( context.modelResult().childResults().value( "raise" ).htmlLog().left( 49 ), QStringLiteral( "Prepare algorithm: raise" ) ); QVERIFY( context.modelResult().childResults().value( "raise" ).htmlLog().contains( QStringLiteral( "Error encountered while running my second step: something bad happened" ) ) ); - QSet expected{ QStringLiteral( "buffer" ) }; + QSet expected { QStringLiteral( "buffer" ) }; QCOMPARE( context.modelResult().executedChildIds(), expected ); } @@ -2472,25 +2448,17 @@ void TestQgsProcessingModelAlgorithm::modelExecuteWithPreviousState() QCOMPARE( context.modelResult().rawChildInputs().value( "calculate2" ).toMap().value( "INPUT" ).toString(), QStringLiteral( "my string_1_2" ) ); QCOMPARE( context.modelResult().rawChildOutputs().value( "calculate2" ).toMap().value( "OUTPUT" ).toString(), QStringLiteral( "my string_1_2" ) ); - QSet expected{ QStringLiteral( "calculate" ), QStringLiteral( "calculate2" ) }; + QSet expected { QStringLiteral( "calculate" ), QStringLiteral( "calculate2" ) }; QCOMPARE( context.modelResult().executedChildIds(), expected ); QgsProcessingModelResult firstResult = context.modelResult(); context.modelResult().clear(); // start with an initial state - std::unique_ptr< QgsProcessingModelInitialRunConfig > modelConfig = std::make_unique< QgsProcessingModelInitialRunConfig >(); - modelConfig->setPreviouslyExecutedChildAlgorithms( { QStringLiteral( "calculate" )} ); - modelConfig->setInitialChildInputs( QVariantMap{ { - QStringLiteral( "calculate" ), QVariantMap{ - { QStringLiteral( "INPUT" ), QStringLiteral( "a different string" ) } - } - }} ); - modelConfig->setInitialChildOutputs( QVariantMap{ { - QStringLiteral( "calculate" ), QVariantMap{ - { QStringLiteral( "OUTPUT" ), QStringLiteral( "a different string" ) } - } - }} ); + std::unique_ptr modelConfig = std::make_unique(); + modelConfig->setPreviouslyExecutedChildAlgorithms( { QStringLiteral( "calculate" ) } ); + modelConfig->setInitialChildInputs( QVariantMap { { QStringLiteral( "calculate" ), QVariantMap { { QStringLiteral( "INPUT" ), QStringLiteral( "a different string" ) } } } } ); + modelConfig->setInitialChildOutputs( QVariantMap { { QStringLiteral( "calculate" ), QVariantMap { { QStringLiteral( "OUTPUT" ), QStringLiteral( "a different string" ) } } } } ); context.setModelInitialRunConfig( std::move( modelConfig ) ); m.run( params, context, &feedback, &ok ); @@ -2529,9 +2497,9 @@ void TestQgsProcessingModelAlgorithm::modelExecuteWithPreviousState() QCOMPARE( context.temporaryLayerStore()->count(), 0 ); // test handling of temporary layers generated during earlier runs - modelConfig = std::make_unique< QgsProcessingModelInitialRunConfig >(); + modelConfig = std::make_unique(); - std::unique_ptr < QgsMapLayerStore > previousStore = std::make_unique< QgsMapLayerStore >(); + std::unique_ptr previousStore = std::make_unique(); QgsVectorLayer *layer = new QgsVectorLayer( "Point?crs=epsg:3111", "v1", "memory" ); previousStore->addMapLayer( layer ); previousStore->moveToThread( nullptr ); @@ -2633,49 +2601,49 @@ void TestQgsProcessingModelAlgorithm::renameModelParameter() algc1.setChildId( QStringLiteral( "cx1" ) ); algc1.setAlgorithmId( "native:buffer" ); - algc1.addParameterSources( QStringLiteral( "CHILD_OUTPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "filter" ), QStringLiteral( "VECTOR" ) ) ); - algc1.addParameterSources( QStringLiteral( "STATIC_VALUE" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) ); - algc1.addParameterSources( QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromStaticValue( QgsProperty::fromExpression( QStringLiteral( "@oldName * 2 + @string2" ) ) ) ); - algc1.addParameterSources( QStringLiteral( "MODEL_PARAM_1" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "oldName" ) ) ); - algc1.addParameterSources( QStringLiteral( "MODEL_PARAM_2" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "string2" ) ) ); - algc1.addParameterSources( QStringLiteral( "EXPRESSION" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@oldName * 2 + @string2" ) ) ); + algc1.addParameterSources( QStringLiteral( "CHILD_OUTPUT" ), QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "filter" ), QStringLiteral( "VECTOR" ) ) ); + algc1.addParameterSources( QStringLiteral( "STATIC_VALUE" ), QList() << QgsProcessingModelChildParameterSource::fromStaticValue( 5 ) ); + algc1.addParameterSources( QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" ), QList() << QgsProcessingModelChildParameterSource::fromStaticValue( QgsProperty::fromExpression( QStringLiteral( "@oldName * 2 + @string2" ) ) ) ); + algc1.addParameterSources( QStringLiteral( "MODEL_PARAM_1" ), QList() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "oldName" ) ) ); + algc1.addParameterSources( QStringLiteral( "MODEL_PARAM_2" ), QList() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "string2" ) ) ); + algc1.addParameterSources( QStringLiteral( "EXPRESSION" ), QList() << QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@oldName * 2 + @string2" ) ) ); m.addChildAlgorithm( algc1 ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputChildId(), QStringLiteral( "filter" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE" ) ].constFirst().staticValue(), QVariant( 5 ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" ) ].constFirst().staticValue().value< QgsProperty >().expressionString(), QStringLiteral( "@oldName * 2 + @string2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_1" ) ].constFirst().parameterName(), QStringLiteral( "oldName" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_2" ) ].constFirst().parameterName(), QStringLiteral( "string2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "EXPRESSION" ) ].constFirst().expression(), QStringLiteral( "@oldName * 2 + @string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputChildId(), QStringLiteral( "filter" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE" )].constFirst().staticValue(), QVariant( 5 ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" )].constFirst().staticValue().value().expressionString(), QStringLiteral( "@oldName * 2 + @string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_1" )].constFirst().parameterName(), QStringLiteral( "oldName" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_2" )].constFirst().parameterName(), QStringLiteral( "string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "EXPRESSION" )].constFirst().expression(), QStringLiteral( "@oldName * 2 + @string2" ) ); m.changeParameterName( QStringLiteral( "x" ), QStringLiteral( "y" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputChildId(), QStringLiteral( "filter" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE" ) ].constFirst().staticValue(), QVariant( 5 ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" ) ].constFirst().staticValue().value< QgsProperty >().expressionString(), QStringLiteral( "@oldName * 2 + @string2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_1" ) ].constFirst().parameterName(), QStringLiteral( "oldName" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_2" ) ].constFirst().parameterName(), QStringLiteral( "string2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "EXPRESSION" ) ].constFirst().expression(), QStringLiteral( "@oldName * 2 + @string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputChildId(), QStringLiteral( "filter" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE" )].constFirst().staticValue(), QVariant( 5 ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" )].constFirst().staticValue().value().expressionString(), QStringLiteral( "@oldName * 2 + @string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_1" )].constFirst().parameterName(), QStringLiteral( "oldName" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_2" )].constFirst().parameterName(), QStringLiteral( "string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "EXPRESSION" )].constFirst().expression(), QStringLiteral( "@oldName * 2 + @string2" ) ); m.changeParameterName( QStringLiteral( "oldName" ), QStringLiteral( "apricot" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputChildId(), QStringLiteral( "filter" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE" ) ].constFirst().staticValue(), QVariant( 5 ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" ) ].constFirst().staticValue().value< QgsProperty >().expressionString(), QStringLiteral( "@apricot * 2 + @string2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_1" ) ].constFirst().parameterName(), QStringLiteral( "apricot" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_2" ) ].constFirst().parameterName(), QStringLiteral( "string2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "EXPRESSION" ) ].constFirst().expression(), QStringLiteral( "@apricot * 2 + @string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputChildId(), QStringLiteral( "filter" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE" )].constFirst().staticValue(), QVariant( 5 ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" )].constFirst().staticValue().value().expressionString(), QStringLiteral( "@apricot * 2 + @string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_1" )].constFirst().parameterName(), QStringLiteral( "apricot" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_2" )].constFirst().parameterName(), QStringLiteral( "string2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "EXPRESSION" )].constFirst().expression(), QStringLiteral( "@apricot * 2 + @string2" ) ); m.changeParameterName( QStringLiteral( "string2" ), QStringLiteral( "int2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputChildId(), QStringLiteral( "filter" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "CHILD_OUTPUT" ) ].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE" ) ].constFirst().staticValue(), QVariant( 5 ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" ) ].constFirst().staticValue().value< QgsProperty >().expressionString(), QStringLiteral( "@apricot * 2 + @int2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_1" ) ].constFirst().parameterName(), QStringLiteral( "apricot" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "MODEL_PARAM_2" ) ].constFirst().parameterName(), QStringLiteral( "int2" ) ); - QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[ QStringLiteral( "EXPRESSION" ) ].constFirst().expression(), QStringLiteral( "@apricot * 2 + @int2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputChildId(), QStringLiteral( "filter" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "CHILD_OUTPUT" )].constFirst().outputName(), QStringLiteral( "VECTOR" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE" )].constFirst().staticValue(), QVariant( 5 ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "STATIC_VALUE_DD_EXPERESSION" )].constFirst().staticValue().value().expressionString(), QStringLiteral( "@apricot * 2 + @int2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_1" )].constFirst().parameterName(), QStringLiteral( "apricot" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "MODEL_PARAM_2" )].constFirst().parameterName(), QStringLiteral( "int2" ) ); + QCOMPARE( m.childAlgorithm( QStringLiteral( "cx1" ) ).parameterSources()[QStringLiteral( "EXPRESSION" )].constFirst().expression(), QStringLiteral( "@apricot * 2 + @int2" ) ); } void TestQgsProcessingModelAlgorithm::internalVersion() @@ -2707,9 +2675,8 @@ void TestQgsProcessingModelAlgorithm::modelChildOrderWithVariables() c1.setAlgorithmId( QStringLiteral( "native:stringconcatenation" ) ); // a parameter source from an expression which isn't coming from another child algorithm c1.setParameterSources( - { - {QStringLiteral( "INPUT_2" ), {QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@a_parameter || 'x'" ) )} } - } + { { QStringLiteral( "INPUT_2" ), { QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@a_parameter || 'x'" ) ) } } + } ); model.addChildAlgorithm( c1 ); @@ -2717,9 +2684,8 @@ void TestQgsProcessingModelAlgorithm::modelChildOrderWithVariables() c2.setChildId( QStringLiteral( "c2" ) ); c2.setAlgorithmId( QStringLiteral( "native:stringconcatenation" ) ); c2.setParameterSources( - { - {QStringLiteral( "INPUT_1" ), {QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@c1_CONCATENATION || 'x'" ) )} } - } + { { QStringLiteral( "INPUT_1" ), { QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@c1_CONCATENATION || 'x'" ) ) } } + } ); model.addChildAlgorithm( c2 ); @@ -2738,9 +2704,7 @@ void TestQgsProcessingModelAlgorithm::modelChildOrderWithVariables() c3.setAlgorithmId( QStringLiteral( "native:stringconcatenation" ) ); // make c1 dependent on c3's output via a variable - model.childAlgorithm( QStringLiteral( "c1" ) ).addParameterSources( - QStringLiteral( "INPUT_1" ), QList< QgsProcessingModelChildParameterSource > {QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@c3_CONCATENATION || 'x'" ) )} - ); + model.childAlgorithm( QStringLiteral( "c1" ) ).addParameterSources( QStringLiteral( "INPUT_1" ), QList { QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@c3_CONCATENATION || 'x'" ) ) } ); model.addChildAlgorithm( c3 ); QCOMPARE( model.dependsOnChildAlgorithms( QStringLiteral( "c3" ) ).size(), 0 ); @@ -2751,11 +2715,7 @@ void TestQgsProcessingModelAlgorithm::modelChildOrderWithVariables() QVERIFY( model.dependsOnChildAlgorithms( QStringLiteral( "c2" ) ).contains( QStringLiteral( "c3" ) ) ); // circular dependency -- this is ok, we just don't want to hang - model.childAlgorithm( QStringLiteral( "c3" ) ).setParameterSources( - { - {QStringLiteral( "INPUT_1" ), {QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@c2_CONCATENATION || 'x'" ) )} } - } - ); + model.childAlgorithm( QStringLiteral( "c3" ) ).setParameterSources( { { QStringLiteral( "INPUT_1" ), { QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "@c2_CONCATENATION || 'x'" ) ) } } } ); QCOMPARE( model.dependsOnChildAlgorithms( QStringLiteral( "c3" ) ).size(), 2 ); QVERIFY( model.dependsOnChildAlgorithms( QStringLiteral( "c3" ) ).contains( QStringLiteral( "c1" ) ) ); diff --git a/tests/src/analysis/testqgsprocessingpdalalgs.cpp b/tests/src/analysis/testqgsprocessingpdalalgs.cpp index f390e860f397..ddbdb4567da6 100644 --- a/tests/src/analysis/testqgsprocessingpdalalgs.cpp +++ b/tests/src/analysis/testqgsprocessingpdalalgs.cpp @@ -24,21 +24,20 @@ #include "qgspdalalgorithmbase.h" -class TestQgsProcessingPdalAlgs: public QgsTest +class TestQgsProcessingPdalAlgs : public QgsTest { Q_OBJECT public: - TestQgsProcessingPdalAlgs() : QgsTest( QStringLiteral( "Processing PDAL Algorithms Test" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void assignProjection(); void boundary(); @@ -107,15 +106,15 @@ void TestQgsProcessingPdalAlgs::updateFileListArg( QStringList &args, const QStr if ( found ) { - args[ i ] = QStringLiteral( "--input-file-list=%1" ).arg( fileName ); + args[i] = QStringLiteral( "--input-file-list=%1" ).arg( fileName ); } } void TestQgsProcessingPdalAlgs::info() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:info" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:info" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); QgsProcessingFeedback feedback; @@ -132,9 +131,9 @@ void TestQgsProcessingPdalAlgs::info() void TestQgsProcessingPdalAlgs::convertFormat() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:convertformat" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:convertformat" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -147,26 +146,19 @@ void TestQgsProcessingPdalAlgs::convertFormat() parameters.insert( QStringLiteral( "OUTPUT" ), outputPointCloud ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::reproject() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:reproject" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:reproject" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -180,28 +172,19 @@ void TestQgsProcessingPdalAlgs::reproject() parameters.insert( QStringLiteral( "OUTPUT" ), outputPointCloud ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--transform-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::assignProjection() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:assignprojection" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:assignprojection" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -215,28 +198,19 @@ void TestQgsProcessingPdalAlgs::assignProjection() parameters.insert( QStringLiteral( "OUTPUT" ), outputPointCloud ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--assign-crs=%1" ).arg( QLatin1String( "EPSG:4326" ) ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::thinByDecimate() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:thinbydecimate" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:thinbydecimate" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -249,65 +223,34 @@ void TestQgsProcessingPdalAlgs::thinByDecimate() parameters.insert( QStringLiteral( "INPUT" ), mPointCloudLayerPath ); parameters.insert( QStringLiteral( "OUTPUT" ), outputPointCloud ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=every-nth" ) - << QStringLiteral( "--step-every-nth=1" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=every-nth" ) << QStringLiteral( "--step-every-nth=1" ) ); // set points number parameters.insert( QStringLiteral( "POINTS_NUMBER" ), 200 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=every-nth" ) - << QStringLiteral( "--step-every-nth=200" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=every-nth" ) << QStringLiteral( "--step-every-nth=200" ) ); // filter exression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=every-nth" ) - << QStringLiteral( "--step-every-nth=200" ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=every-nth" ) << QStringLiteral( "--step-every-nth=200" ) << QStringLiteral( "--filter=Intensity > 50" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=every-nth" ) - << QStringLiteral( "--step-every-nth=200" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=every-nth" ) << QStringLiteral( "--step-every-nth=200" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=every-nth" ) - << QStringLiteral( "--step-every-nth=200" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=every-nth" ) << QStringLiteral( "--step-every-nth=200" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::thinByRadius() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:thinbyradius" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:thinbyradius" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -320,65 +263,34 @@ void TestQgsProcessingPdalAlgs::thinByRadius() parameters.insert( QStringLiteral( "INPUT" ), mPointCloudLayerPath ); parameters.insert( QStringLiteral( "OUTPUT" ), outputPointCloud ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=sample" ) - << QStringLiteral( "--step-sample=1" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=sample" ) << QStringLiteral( "--step-sample=1" ) ); // set sampling radius parameters.insert( QStringLiteral( "SAMPLING_RADIUS" ), 2.5 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=sample" ) - << QStringLiteral( "--step-sample=2.5" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=sample" ) << QStringLiteral( "--step-sample=2.5" ) ); // filter exression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=sample" ) - << QStringLiteral( "--step-sample=2.5" ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=sample" ) << QStringLiteral( "--step-sample=2.5" ) << QStringLiteral( "--filter=Intensity > 50" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=sample" ) - << QStringLiteral( "--step-sample=2.5" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=sample" ) << QStringLiteral( "--step-sample=2.5" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--mode=sample" ) - << QStringLiteral( "--step-sample=2.5" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "thin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--mode=sample" ) << QStringLiteral( "--step-sample=2.5" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::boundary() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:boundary" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:boundary" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -391,10 +303,7 @@ void TestQgsProcessingPdalAlgs::boundary() parameters.insert( QStringLiteral( "OUTPUT" ), outputGpkg ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputGpkg ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputGpkg ) ); // threshold requires resolution parameter parameters.insert( QStringLiteral( "THRESHOLD" ), 10 ); @@ -402,56 +311,30 @@ void TestQgsProcessingPdalAlgs::boundary() parameters.insert( QStringLiteral( "RESOLUTION" ), 3000 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputGpkg ) - << QStringLiteral( "--resolution=%1" ).arg( 3000 ) - << QStringLiteral( "--threshold=%1" ).arg( 10 ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputGpkg ) << QStringLiteral( "--resolution=%1" ).arg( 3000 ) << QStringLiteral( "--threshold=%1" ).arg( 10 ) ); // with filter expression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputGpkg ) - << QStringLiteral( "--resolution=%1" ).arg( 3000 ) - << QStringLiteral( "--threshold=%1" ).arg( 10 ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputGpkg ) << QStringLiteral( "--resolution=%1" ).arg( 3000 ) << QStringLiteral( "--threshold=%1" ).arg( 10 ) << QStringLiteral( "--filter=Intensity > 50" ) ); // with filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputGpkg ) - << QStringLiteral( "--resolution=%1" ).arg( 3000 ) - << QStringLiteral( "--threshold=%1" ).arg( 10 ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputGpkg ) << QStringLiteral( "--resolution=%1" ).arg( 3000 ) << QStringLiteral( "--threshold=%1" ).arg( 10 ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputGpkg ) - << QStringLiteral( "--resolution=%1" ).arg( 3000 ) - << QStringLiteral( "--threshold=%1" ).arg( 10 ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "boundary" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputGpkg ) << QStringLiteral( "--resolution=%1" ).arg( 3000 ) << QStringLiteral( "--threshold=%1" ).arg( 10 ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::density() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:density" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:density" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -465,32 +348,17 @@ void TestQgsProcessingPdalAlgs::density() parameters.insert( QStringLiteral( "OUTPUT" ), outputFile ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "density" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=1" ) - << QStringLiteral( "--tile-size=1000" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "density" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=1" ) << QStringLiteral( "--tile-size=1000" ) ); // change resolution parameters.insert( QStringLiteral( "RESOLUTION" ), 0.5 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "density" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=1000" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "density" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=1000" ) ); // set tile size parameters.insert( QStringLiteral( "TILE_SIZE" ), 100 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "density" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "density" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) ); // set X tile origin parameters.insert( QStringLiteral( "ORIGIN_X" ), 1 ); @@ -505,63 +373,29 @@ void TestQgsProcessingPdalAlgs::density() parameters.insert( QStringLiteral( "ORIGIN_Y" ), 10 ); parameters.insert( QStringLiteral( "ORIGIN_X" ), 1 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "density" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "density" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) ); // filter expression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "density" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "density" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "density" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "density" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "density" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "density" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::exportRasterTin() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:exportrastertin" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:exportrastertin" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -575,32 +409,17 @@ void TestQgsProcessingPdalAlgs::exportRasterTin() parameters.insert( QStringLiteral( "OUTPUT" ), outputFile ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=1" ) - << QStringLiteral( "--tile-size=1000" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=1" ) << QStringLiteral( "--tile-size=1000" ) ); // change resolution parameters.insert( QStringLiteral( "RESOLUTION" ), 0.5 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=1000" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=1000" ) ); // set tile size parameters.insert( QStringLiteral( "TILE_SIZE" ), 100 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) ); // set X tile origin parameters.insert( QStringLiteral( "ORIGIN_X" ), 1 ); @@ -615,63 +434,29 @@ void TestQgsProcessingPdalAlgs::exportRasterTin() parameters.insert( QStringLiteral( "ORIGIN_Y" ), 10 ); parameters.insert( QStringLiteral( "ORIGIN_X" ), 1 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) ); // filter expression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster_tin" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::tile() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:tile" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:tile" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -688,66 +473,38 @@ void TestQgsProcessingPdalAlgs::tile() QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) - << QStringLiteral( "--length=1000" ) - << QStringLiteral( "--output=%1" ).arg( outputDir ) - << QStringLiteral( "--temp_dir=%1" ).arg( tempFolder ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) << QStringLiteral( "--length=1000" ) << QStringLiteral( "--output=%1" ).arg( outputDir ) << QStringLiteral( "--temp_dir=%1" ).arg( tempFolder ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // override temp folder context->setTemporaryFolder( tempDir ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) - << QStringLiteral( "--length=1000" ) - << QStringLiteral( "--output=%1" ).arg( outputDir ) - << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) << QStringLiteral( "--length=1000" ) << QStringLiteral( "--output=%1" ).arg( outputDir ) << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // set tile length parameters.insert( QStringLiteral( "LENGTH" ), 150 ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) - << QStringLiteral( "--length=150" ) - << QStringLiteral( "--output=%1" ).arg( outputDir ) - << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) << QStringLiteral( "--length=150" ) << QStringLiteral( "--output=%1" ).arg( outputDir ) << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // assign crs parameters.insert( QStringLiteral( "CRS" ), QStringLiteral( "EPSG:4326" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) - << QStringLiteral( "--length=150" ) - << QStringLiteral( "--output=%1" ).arg( outputDir ) - << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) - << QStringLiteral( "--a_srs=EPSG:4326" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) << QStringLiteral( "--length=150" ) << QStringLiteral( "--output=%1" ).arg( outputDir ) << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) << QStringLiteral( "--a_srs=EPSG:4326" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) - << QStringLiteral( "--length=150" ) - << QStringLiteral( "--output=%1" ).arg( outputDir ) - << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) - << QStringLiteral( "--a_srs=EPSG:4326" ) - << QStringLiteral( "--threads=2" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "tile" ) << QStringLiteral( "--length=150" ) << QStringLiteral( "--output=%1" ).arg( outputDir ) << QStringLiteral( "--temp_dir=%1" ).arg( tempDir ) << QStringLiteral( "--a_srs=EPSG:4326" ) << QStringLiteral( "--threads=2" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); } void TestQgsProcessingPdalAlgs::exportRaster() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:exportraster" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:exportraster" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -761,46 +518,22 @@ void TestQgsProcessingPdalAlgs::exportRaster() parameters.insert( QStringLiteral( "OUTPUT" ), outputFile ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=Z" ) - << QStringLiteral( "--resolution=1" ) - << QStringLiteral( "--tile-size=1000" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=Z" ) << QStringLiteral( "--resolution=1" ) << QStringLiteral( "--tile-size=1000" ) ); // specify attribute to use parameters.insert( QStringLiteral( "ATTRIBUTE" ), QStringLiteral( "ReturnNumber" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=ReturnNumber" ) - << QStringLiteral( "--resolution=1" ) - << QStringLiteral( "--tile-size=1000" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=ReturnNumber" ) << QStringLiteral( "--resolution=1" ) << QStringLiteral( "--tile-size=1000" ) ); // change resolution parameters.insert( QStringLiteral( "RESOLUTION" ), 0.5 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=ReturnNumber" ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=1000" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=ReturnNumber" ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=1000" ) ); // set tile size parameters.insert( QStringLiteral( "TILE_SIZE" ), 100 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=ReturnNumber" ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=ReturnNumber" ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) ); // set X tile origin parameters.insert( QStringLiteral( "ORIGIN_X" ), 1 ); @@ -815,67 +548,29 @@ void TestQgsProcessingPdalAlgs::exportRaster() parameters.insert( QStringLiteral( "ORIGIN_Y" ), 10 ); parameters.insert( QStringLiteral( "ORIGIN_X" ), 1 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=ReturnNumber" ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=ReturnNumber" ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) ); // filter expression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=ReturnNumber" ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=ReturnNumber" ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=ReturnNumber" ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=ReturnNumber" ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=ReturnNumber" ) - << QStringLiteral( "--resolution=0.5" ) - << QStringLiteral( "--tile-size=100" ) - << QStringLiteral( "--tile-origin-x=1" ) - << QStringLiteral( "--tile-origin-y=10" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_raster" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=ReturnNumber" ) << QStringLiteral( "--resolution=0.5" ) << QStringLiteral( "--tile-size=100" ) << QStringLiteral( "--tile-origin-x=1" ) << QStringLiteral( "--tile-origin-y=10" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::exportVector() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:exportvector" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:exportvector" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -889,59 +584,34 @@ void TestQgsProcessingPdalAlgs::exportVector() parameters.insert( QStringLiteral( "OUTPUT" ), outputFile ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) ); // set attribute parameters.insert( QStringLiteral( "ATTRIBUTE" ), QStringLiteral( "Z" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=Z" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=Z" ) ); // filter expression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=Z" ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=Z" ) << QStringLiteral( "--filter=Intensity > 50" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=Z" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=Z" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--attribute=Z" ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "to_vector" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--attribute=Z" ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::merge() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:merge" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:merge" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -956,50 +626,32 @@ void TestQgsProcessingPdalAlgs::merge() QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // filter expression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "merge" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); } void TestQgsProcessingPdalAlgs::buildVpc() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:virtualpointcloud" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:virtualpointcloud" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -1014,63 +666,38 @@ void TestQgsProcessingPdalAlgs::buildVpc() QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // calculate exact boundaries parameters.insert( QStringLiteral( "BOUNDARY" ), true ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--boundary" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--boundary" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // calculate statistics parameters.insert( QStringLiteral( "STATISTICS" ), true ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--boundary" ) - << QStringLiteral( "--stats" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--boundary" ) << QStringLiteral( "--stats" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // build overview parameters.insert( QStringLiteral( "OVERVIEW" ), true ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--boundary" ) - << QStringLiteral( "--stats" ) - << QStringLiteral( "--overview" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--boundary" ) << QStringLiteral( "--stats" ) << QStringLiteral( "--overview" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); updateFileListArg( args, QStringLiteral( "inputFiles.txt" ) ); - QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--boundary" ) - << QStringLiteral( "--stats" ) - << QStringLiteral( "--overview" ) - << QStringLiteral( "--threads=2" ) - << QStringLiteral( "--input-file-list=inputFiles.txt" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "build_vpc" ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--boundary" ) << QStringLiteral( "--stats" ) << QStringLiteral( "--overview" ) << QStringLiteral( "--threads=2" ) << QStringLiteral( "--input-file-list=inputFiles.txt" ) ); } void TestQgsProcessingPdalAlgs::clip() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:clip" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:clip" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -1085,51 +712,29 @@ void TestQgsProcessingPdalAlgs::clip() parameters.insert( QStringLiteral( "OUTPUT" ), outputFile ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) ); // filter expression parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Intensity > 50" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) - << QStringLiteral( "--filter=Intensity > 50" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) << QStringLiteral( "--filter=Intensity > 50" ) ); // filter extent parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputFile ) - << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) - << QStringLiteral( "--filter=Intensity > 50" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "clip" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputFile ) << QStringLiteral( "--polygon=%1" ).arg( polygonsFile ) << QStringLiteral( "--filter=Intensity > 50" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } void TestQgsProcessingPdalAlgs::filter() { - QgsPdalAlgorithmBase *alg = const_cast( static_cast< const QgsPdalAlgorithmBase * >( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:filter" ) ) ) ); + QgsPdalAlgorithmBase *alg = const_cast( static_cast( QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "pdal:filter" ) ) ) ); - std::unique_ptr< QgsProcessingContext > context = std::make_unique< QgsProcessingContext >(); + std::unique_ptr context = std::make_unique(); context->setProject( QgsProject::instance() ); context->setMaximumThreads( 0 ); @@ -1142,38 +747,20 @@ void TestQgsProcessingPdalAlgs::filter() parameters.insert( QStringLiteral( "OUTPUT" ), outputPointCloud ); QStringList args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) ); parameters.insert( QStringLiteral( "FILTER_EXPRESSION" ), QStringLiteral( "Classification = 7 OR Classification = 8" ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--filter=Classification == 7 || Classification == 8" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--filter=Classification == 7 || Classification == 8" ) ); parameters.insert( QStringLiteral( "FILTER_EXTENT" ), QgsRectangle( 1, 2, 3, 4 ) ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--filter=Classification == 7 || Classification == 8" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--filter=Classification == 7 || Classification == 8" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) ); // set max threads to 2, a --threads argument should be added context->setMaximumThreads( 2 ); args = alg->createArgumentLists( parameters, *context, &feedback ); - QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) - << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) - << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) - << QStringLiteral( "--filter=Classification == 7 || Classification == 8" ) - << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) - << QStringLiteral( "--threads=2" ) - ); + QCOMPARE( args, QStringList() << QStringLiteral( "translate" ) << QStringLiteral( "--input=%1" ).arg( mPointCloudLayerPath ) << QStringLiteral( "--output=%1" ).arg( outputPointCloud ) << QStringLiteral( "--filter=Classification == 7 || Classification == 8" ) << QStringLiteral( "--bounds=([1, 3], [2, 4])" ) << QStringLiteral( "--threads=2" ) ); } QGSTEST_MAIN( TestQgsProcessingPdalAlgs ) diff --git a/tests/src/analysis/testqgsrastercalculator.cpp b/tests/src/analysis/testqgsrastercalculator.cpp index e88d45346d08..6cfc959da153 100644 --- a/tests/src/analysis/testqgsrastercalculator.cpp +++ b/tests/src/analysis/testqgsrastercalculator.cpp @@ -35,16 +35,15 @@ class TestQgsRasterCalculator : public QgsTest Q_OBJECT public: - TestQgsRasterCalculator() : QgsTest( QStringLiteral( "Raster Calculator Test" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() ;// will be called before each testfunction is executed. - void cleanup() ;// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void dualOp_data(); void dualOp(); //test operators which operate on a left&right node @@ -52,7 +51,7 @@ class TestQgsRasterCalculator : public QgsTest void singleOp_data(); void singleOp(); //test operators which operate on a single value - void singleOpMatrices(); // test single op using matrix + void singleOpMatrices(); // test single op using matrix void dualOpNumberMatrix(); // test dual op run on number and matrix void dualOpMatrixNumber(); // test dual op run on matrix and number void dualOpMatrixMatrix(); // test dual op run on matrix and matrix @@ -72,17 +71,16 @@ class TestQgsRasterCalculator : public QgsTest void testStatistics(); - void parseFunctionTypeString(); //test the parsing of the formule for the tFunction type + void parseFunctionTypeString(); //test the parsing of the formule for the tFunction type void testFunctionTypeWithLayer(); //test of conditional statement private: - QgsRasterLayer *mpLandsatRasterLayer = nullptr; QgsRasterLayer *mpLandsatRasterLayer4326 = nullptr; }; -void TestQgsRasterCalculator::initTestCase() +void TestQgsRasterCalculator::initTestCase() { // // Runs once before any tests are run @@ -100,25 +98,24 @@ void TestQgsRasterCalculator::initTestCase() QString landsatFileName = testDataDir + "landsat.tif"; QFileInfo landsatRasterFileInfo( landsatFileName ); - mpLandsatRasterLayer = new QgsRasterLayer( landsatRasterFileInfo.filePath(), - landsatRasterFileInfo.completeBaseName() ); + mpLandsatRasterLayer = new QgsRasterLayer( landsatRasterFileInfo.filePath(), landsatRasterFileInfo.completeBaseName() ); QString landsat4326FileName = testDataDir + "landsat_4326.tif"; QFileInfo landsat4326RasterFileInfo( landsat4326FileName ); - mpLandsatRasterLayer4326 = new QgsRasterLayer( landsat4326RasterFileInfo.filePath(), - landsat4326RasterFileInfo.completeBaseName() ); + mpLandsatRasterLayer4326 = new QgsRasterLayer( landsat4326RasterFileInfo.filePath(), landsat4326RasterFileInfo.completeBaseName() ); QgsProject::instance()->addMapLayers( - QList() << mpLandsatRasterLayer << mpLandsatRasterLayer4326 ); + QList() << mpLandsatRasterLayer << mpLandsatRasterLayer4326 + ); } -void TestQgsRasterCalculator::cleanupTestCase() +void TestQgsRasterCalculator::cleanupTestCase() { QgsApplication::exitQgis(); } -void TestQgsRasterCalculator::init() +void TestQgsRasterCalculator::init() { #ifdef HAVE_OPENCL QgsOpenClUtils::setEnabled( false ); @@ -127,14 +124,13 @@ void TestQgsRasterCalculator::init() #endif } -void TestQgsRasterCalculator::cleanup() +void TestQgsRasterCalculator::cleanup() { - } void TestQgsRasterCalculator::dualOp_data() { - QTest::addColumn< QgsRasterCalcNode::Operator >( "op" ); + QTest::addColumn( "op" ); QTest::addColumn( "left" ); QTest::addColumn( "right" ); QTest::addColumn( "expected" ); @@ -191,12 +187,11 @@ void TestQgsRasterCalculator::dualOp() qDebug() << "Result: " << result.number() << " expected: " << expected; QCOMPARE( result.number(), expected ); - } void TestQgsRasterCalculator::singleOp_data() { - QTest::addColumn< QgsRasterCalcNode::Operator >( "op" ); + QTest::addColumn( "op" ); QTest::addColumn( "value" ); QTest::addColumn( "expected" ); @@ -240,7 +235,6 @@ void TestQgsRasterCalculator::singleOp() qDebug() << "Result: " << result.number() << " expected: " << expected; QGSCOMPARENEAR( result.number(), expected, 0.0000000001 ); - } void TestQgsRasterCalculator::singleOpMatrices() @@ -465,12 +459,8 @@ void TestQgsRasterCalculator::calcWithLayers() QString tmpName = tmpFile.fileName(); tmpFile.close(); - QgsRasterCalculator rc( QStringLiteral( "\"landsat@1\" + 2" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 0 ); + QgsRasterCalculator rc( QStringLiteral( "\"landsat@1\" + 2" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 0 ); //open output file and check results QgsRasterLayer *result = new QgsRasterLayer( tmpName, QStringLiteral( "result" ) ); @@ -487,12 +477,8 @@ void TestQgsRasterCalculator::calcWithLayers() delete block; //now try with 2 raster bands - QgsRasterCalculator rc2( QStringLiteral( "\"landsat@1\" + \"landsat@2\"" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc2.processCalculation() ), 0 ); + QgsRasterCalculator rc2( QStringLiteral( "\"landsat@1\" + \"landsat@2\"" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc2.processCalculation() ), 0 ); //open output file and check results result = new QgsRasterLayer( tmpName, QStringLiteral( "result" ) ); @@ -532,12 +518,8 @@ void TestQgsRasterCalculator::calcWithReprojectedLayers() QString tmpName = tmpFile.fileName(); tmpFile.close(); - QgsRasterCalculator rc( QStringLiteral( "\"landsat@1\" + \"landsat_4326@2\"" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 0 ); + QgsRasterCalculator rc( QStringLiteral( "\"landsat@1\" + \"landsat_4326@2\"" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 0 ); //open output file and check results QgsRasterLayer *result = new QgsRasterLayer( tmpName, QStringLiteral( "result" ) ); @@ -556,12 +538,10 @@ void TestQgsRasterCalculator::calcWithReprojectedLayers() void TestQgsRasterCalculator::findNodes() { - - std::unique_ptr< QgsRasterCalcNode > calcNode; + std::unique_ptr calcNode; auto _test = - [ & ]( QString exp, const QgsRasterCalcNode::Type type ) -> QList - { + [&]( QString exp, const QgsRasterCalcNode::Type type ) -> QList { QString error; calcNode.reset( QgsRasterCalcNode::parseRasterCalcString( exp, error ) ); return calcNode->findNodes( type ); @@ -576,17 +556,17 @@ void TestQgsRasterCalculator::findNodes() // Test parser with valid and invalid expressions QString errorString; - const QgsRasterCalcNode *node { QgsRasterCalcNode::parseRasterCalcString( QString( ), errorString ) }; - QVERIFY( ! node ); - QVERIFY( ! errorString.isEmpty() ); + const QgsRasterCalcNode *node { QgsRasterCalcNode::parseRasterCalcString( QString(), errorString ) }; + QVERIFY( !node ); + QVERIFY( !errorString.isEmpty() ); errorString = QString(); node = QgsRasterCalcNode::parseRasterCalcString( QStringLiteral( "log10(2)" ), errorString ); QVERIFY( node ); QVERIFY( errorString.isEmpty() ); errorString = QString(); node = QgsRasterCalcNode::parseRasterCalcString( QStringLiteral( "not_a_function(2)" ), errorString ); - QVERIFY( ! node ); - QVERIFY( ! errorString.isEmpty() ); + QVERIFY( !node ); + QVERIFY( !errorString.isEmpty() ); // Test new abs, min, max errorString.clear(); @@ -605,20 +585,20 @@ void TestQgsRasterCalculator::testRasterEntries() { // Create some test layers QList layers; - QgsRasterLayer *rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/dem.tif", QStringLiteral( "dem" ) ); + QgsRasterLayer *rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/dem.tif", QStringLiteral( "dem" ) ); layers << rlayer; // Duplicate name, same source - rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/dem.tif", QStringLiteral( "dem" ) ); + rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/dem.tif", QStringLiteral( "dem" ) ); layers << rlayer; // Duplicated name different source - rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/dem_int16.tif", QStringLiteral( "dem" ) ); + rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/dem_int16.tif", QStringLiteral( "dem" ) ); layers << rlayer; // Different name and different source - rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/slope.tif", QStringLiteral( "slope" ) ); - layers << rlayer ; + rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/slope.tif", QStringLiteral( "slope" ) ); + layers << rlayer; // Different name and same source - rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/slope.tif", QStringLiteral( "slope2" ) ); - layers << rlayer ; + rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/slope.tif", QStringLiteral( "slope2" ) ); + layers << rlayer; QgsProject::instance()->addMapLayers( layers ); QVector availableRasterBands = QgsRasterCalculatorEntry::rasterEntries(); QMap entryMap; @@ -629,12 +609,12 @@ void TestQgsRasterCalculator::testRasterEntries() QStringList keys( entryMap.keys() ); keys.sort(); QCOMPARE( keys.join( ',' ), QStringLiteral( "dem@1,dem_1@1,landsat@1,landsat@2,landsat@3,landsat@4," - "landsat@5,landsat@6,landsat@7,landsat@8,landsat@9," - "landsat_4326@1,landsat_4326@2,landsat_4326@3,landsat_4326@4," - "landsat_4326@5,landsat_4326@6,landsat_4326@7,landsat_4326@8,landsat_4326@9,slope2@1" ) ); + "landsat@5,landsat@6,landsat@7,landsat@8,landsat@9," + "landsat_4326@1,landsat_4326@2,landsat_4326@3,landsat_4326@4," + "landsat_4326@5,landsat_4326@6,landsat_4326@7,landsat_4326@8,landsat_4326@9,slope2@1" ) ); } -void TestQgsRasterCalculator::errors( ) +void TestQgsRasterCalculator::errors() { QgsRasterCalculatorEntry entry1; entry1.bandNumber = 0; // bad band @@ -652,23 +632,15 @@ void TestQgsRasterCalculator::errors( ) QString tmpName = tmpFile.fileName(); tmpFile.close(); - QgsRasterCalculator rc( QStringLiteral( "\"landsat@0\"" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 6 ); + QgsRasterCalculator rc( QStringLiteral( "\"landsat@0\"" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 6 ); QCOMPARE( rc.lastError(), QStringLiteral( "Band number 0 is not valid for entry landsat@0" ) ); entry1.bandNumber = 10; // bad band entries.clear(); entries << entry1; - rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 6 ); + rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 6 ); QCOMPARE( rc.lastError(), QStringLiteral( "Band number 10 is not valid for entry landsat@0" ) ); @@ -677,12 +649,8 @@ void TestQgsRasterCalculator::errors( ) entry1.bandNumber = 1; entries.clear(); entries << entry1; - rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 2 ); + rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 2 ); QCOMPARE( rc.lastError(), QStringLiteral( "No raster layer for entry landsat@0" ) ); // bad driver @@ -690,42 +658,29 @@ void TestQgsRasterCalculator::errors( ) entry1.bandNumber = 1; entries.clear(); entries << entry1; - rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), - tmpName, - QStringLiteral( "xxxxx" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 1 ); + rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), tmpName, QStringLiteral( "xxxxx" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 1 ); QCOMPARE( rc.lastError(), QStringLiteral( "Could not obtain driver for xxxxx" ) ); // bad filename - rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), - QStringLiteral( "/goodluckwritinghere/blah/blah.tif" ), - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 1 ); + rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), QStringLiteral( "/goodluckwritinghere/blah/blah.tif" ), QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 1 ); QCOMPARE( rc.lastError(), QStringLiteral( "Could not create output /goodluckwritinghere/blah/blah.tif" ) ); // canceled QgsFeedback feedback; feedback.cancel(); - rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation( &feedback ) ), 3 ); + rc = QgsRasterCalculator( QStringLiteral( "\"landsat@0\"" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation( &feedback ) ), 3 ); QVERIFY( rc.lastError().isEmpty() ); } void TestQgsRasterCalculator::toString() { - auto _test = [ ]( QString exp, bool cStyle ) -> QString - { + auto _test = []( QString exp, bool cStyle ) -> QString { QString error; - std::unique_ptr< QgsRasterCalcNode > calcNode( QgsRasterCalcNode::parseRasterCalcString( exp, error ) ); - if ( ! error.isEmpty() ) + std::unique_ptr calcNode( QgsRasterCalcNode::parseRasterCalcString( exp, error ) ); + if ( !error.isEmpty() ) return error; return calcNode->toString( cStyle ); }; @@ -750,14 +705,13 @@ void TestQgsRasterCalculator::toString() QCOMPARE( _test( QStringLiteral( "0.5 * max( -1, 1 )" ), false ), QString( "0.5 * max( -1, 1 )" ) ); QCOMPARE( _test( QStringLiteral( "0.5 * max( -1, 1 )" ), true ), QString( "( float ) 0.5 * max( ( float ) ( -( float ) 1 ), ( float ) ( ( float ) 1 ) )" ) ); // Test regression #32477 - QCOMPARE( _test( QStringLiteral( R"raw(("r@1"<100.09)*0.1)raw" ), true ), - QString( R"raw(( float ) ( ( float ) "r@1" < ( float ) 100.09 ) * ( float ) 0.1)raw" ) ); + QCOMPARE( _test( QStringLiteral( R"raw(("r@1"<100.09)*0.1)raw" ), true ), QString( R"raw(( float ) ( ( float ) "r@1" < ( float ) 100.09 ) * ( float ) 0.1)raw" ) ); //test the conditional statement QCOMPARE( _test( QStringLiteral( "if( \"raster@1\" > 5 , 100 , 5)" ), false ), QString( "if( \"raster@1\" > 5 , 100 , 5 )" ) ); QCOMPARE( _test( QStringLiteral( "if( \"raster@1\" > 5 , 100 , 5)" ), true ), QString( " ( ( float ) ( ( float ) \"raster@1\" > ( float ) 5 ) ) ? ( ( float ) 100 ) : ( ( float ) 5 ) " ) ); QString error; - std::unique_ptr< QgsRasterCalcNode > calcNode( QgsRasterCalcNode::parseRasterCalcString( QStringLiteral( "min( \"raster@1\" )" ), error ) ); + std::unique_ptr calcNode( QgsRasterCalcNode::parseRasterCalcString( QStringLiteral( "min( \"raster@1\" )" ), error ) ); QVERIFY( calcNode == nullptr ); calcNode.reset( QgsRasterCalcNode::parseRasterCalcString( QStringLiteral( "max( \"raster@1\" )" ), error ) ); QVERIFY( calcNode == nullptr ); @@ -782,14 +736,12 @@ void TestQgsRasterCalculator::calcFormulasWithReprojectedLayers() QgsRectangle extent( 783235, 3348110, 783350, 3347960 ); - auto _chk = [ = ]( const QString & formula, const std::vector &values, bool useOpenCL ) - { - + auto _chk = [=]( const QString &formula, const std::vector &values, bool useOpenCL ) { qDebug() << formula; #ifdef HAVE_OPENCL - if ( ! QgsOpenClUtils::available() ) - return ; + if ( !QgsOpenClUtils::available() ) + return; QgsOpenClUtils::setEnabled( useOpenCL ); #else Q_UNUSED( useOpenCL ) @@ -799,19 +751,15 @@ void TestQgsRasterCalculator::calcFormulasWithReprojectedLayers() tmpFile.open(); // fileName is not available until open QString tmpName = tmpFile.fileName(); tmpFile.close(); - QgsRasterCalculator rc( formula, - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 0 ); + QgsRasterCalculator rc( formula, tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 0 ); //open output file and check results QgsRasterLayer *result = new QgsRasterLayer( tmpName, QStringLiteral( "result" ) ); QCOMPARE( result->width(), 2 ); QCOMPARE( result->height(), 3 ); QgsRasterBlock *block = result->dataProvider()->block( 1, extent, 2, 3 ); - qDebug() << "Actual:" << block->value( 0, 0 ) << block->value( 0, 1 ) << block->value( 1, 0 ) << block->value( 1, 1 ) << block->value( 2, 0 ) << block->value( 2, 1 ); - qDebug() << "Expected:" << values[0] << values[1] << values[2] << values[3] << values[4] << values[5]; + qDebug() << "Actual:" << block->value( 0, 0 ) << block->value( 0, 1 ) << block->value( 1, 0 ) << block->value( 1, 1 ) << block->value( 2, 0 ) << block->value( 2, 1 ); + qDebug() << "Expected:" << values[0] << values[1] << values[2] << values[3] << values[4] << values[5]; const double epsilon { 0.001 }; QVERIFY2( qgsDoubleNear( block->value( 0, 0 ), static_cast( values[0] ), epsilon ), formula.toUtf8().constData() ); QVERIFY2( qgsDoubleNear( block->value( 0, 1 ), static_cast( values[1] ), epsilon ), formula.toUtf8().constData() ); @@ -823,36 +771,35 @@ void TestQgsRasterCalculator::calcFormulasWithReprojectedLayers() delete block; }; - _chk( QStringLiteral( "\"landsat@1\" + \"landsat_4326@2\"" ), {264.0, 263.0, 264.0, 264.0, 266.0, 261.0}, false ); - _chk( QStringLiteral( "\"landsat@1\" + \"landsat_4326@2\"" ), {264.0, 263.0, 264.0, 264.0, 266.0, 261.0}, true ); - _chk( QStringLiteral( "\"landsat@1\"^2 + 3 + \"landsat_4326@2\"" ), {15767, 15766, 15519, 15767, 15769, 15516}, false ); - _chk( QStringLiteral( "\"landsat@1\"^2 + 3 + \"landsat_4326@2\"" ), {15767, 15766, 15519, 15767, 15769, 15516}, true ); - _chk( QStringLiteral( "0.5*((2*\"landsat@1\"+1)-sqrt((2*\"landsat@1\"+1)^2-8*(\"landsat@1\"-\"landsat_4326@2\")))" ), {-0.111504f, -0.103543f, -0.128448f, -0.111504f, -0.127425f, -0.104374f}, false ); - _chk( QStringLiteral( "0.5*((2*\"landsat@1\"+1)-sqrt((2*\"landsat@1\"+1)^2-8*(\"landsat@1\"-\"landsat_4326@2\")))" ), {-0.111504f, -0.103543f, -0.128448f, -0.111504f, -0.127425f, -0.104374f}, true ); - _chk( QStringLiteral( "\"landsat@1\" * ( \"landsat@1\" > 124 )" ), {125.0, 125.0, 0.0, 125.0, 125.0, 0.0}, false ); - _chk( QStringLiteral( "\"landsat@1\" * ( \"landsat@1\" > 124 )" ), {125.0, 125.0, 0.0, 125.0, 125.0, 0.0}, true ); + _chk( QStringLiteral( "\"landsat@1\" + \"landsat_4326@2\"" ), { 264.0, 263.0, 264.0, 264.0, 266.0, 261.0 }, false ); + _chk( QStringLiteral( "\"landsat@1\" + \"landsat_4326@2\"" ), { 264.0, 263.0, 264.0, 264.0, 266.0, 261.0 }, true ); + _chk( QStringLiteral( "\"landsat@1\"^2 + 3 + \"landsat_4326@2\"" ), { 15767, 15766, 15519, 15767, 15769, 15516 }, false ); + _chk( QStringLiteral( "\"landsat@1\"^2 + 3 + \"landsat_4326@2\"" ), { 15767, 15766, 15519, 15767, 15769, 15516 }, true ); + _chk( QStringLiteral( "0.5*((2*\"landsat@1\"+1)-sqrt((2*\"landsat@1\"+1)^2-8*(\"landsat@1\"-\"landsat_4326@2\")))" ), { -0.111504f, -0.103543f, -0.128448f, -0.111504f, -0.127425f, -0.104374f }, false ); + _chk( QStringLiteral( "0.5*((2*\"landsat@1\"+1)-sqrt((2*\"landsat@1\"+1)^2-8*(\"landsat@1\"-\"landsat_4326@2\")))" ), { -0.111504f, -0.103543f, -0.128448f, -0.111504f, -0.127425f, -0.104374f }, true ); + _chk( QStringLiteral( "\"landsat@1\" * ( \"landsat@1\" > 124 )" ), { 125.0, 125.0, 0.0, 125.0, 125.0, 0.0 }, false ); + _chk( QStringLiteral( "\"landsat@1\" * ( \"landsat@1\" > 124 )" ), { 125.0, 125.0, 0.0, 125.0, 125.0, 0.0 }, true ); // Test negative numbers _chk( QStringLiteral( "-2.5" ), { -2.5, -2.5, -2.5, -2.5, -2.5, -2.5 }, false ); _chk( QStringLiteral( "- 2.5" ), { -2.5, -2.5, -2.5, -2.5, -2.5, -2.5 }, false ); _chk( QStringLiteral( "-2.5" ), { -2.5, -2.5, -2.5, -2.5, -2.5, -2.5 }, true ); _chk( QStringLiteral( "- 2.5" ), { -2.5, -2.5, -2.5, -2.5, -2.5, -2.5 }, true ); - _chk( QStringLiteral( "-\"landsat@1\"" ), {-125, -125, -124, -125, -125, -124}, false ); - _chk( QStringLiteral( "-\"landsat@1\"" ), {-125, -125, -124, -125, -125, -124}, true ); + _chk( QStringLiteral( "-\"landsat@1\"" ), { -125, -125, -124, -125, -125, -124 }, false ); + _chk( QStringLiteral( "-\"landsat@1\"" ), { -125, -125, -124, -125, -125, -124 }, true ); // Test abs, min and max // landsat values: 125 125 124 125 125 124 // landsat_4326 values: 139 138 140 139 141 137 - _chk( QStringLiteral( "abs(-123)" ), {123, 123, 123, 123, 123, 123}, false ); - _chk( QStringLiteral( "abs(-\"landsat@1\")" ), {125, 125, 124, 125, 125, 124}, true ); - _chk( QStringLiteral( "abs(-123)" ), {123, 123, 123, 123, 123, 123}, false ); - _chk( QStringLiteral( "abs(-\"landsat@1\")" ), {125, 125, 124, 125, 125, 124}, true ); - _chk( QStringLiteral( "-\"landsat_4326@2\" + 15" ), {-124, -123, -125, -124, -126, -122}, false ); - _chk( QStringLiteral( "min(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), {-125, -125, -125, -125, -126, -124}, false ); - _chk( QStringLiteral( "min(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), {-125, -125, -125, -125, -126, -124}, true ); - _chk( QStringLiteral( "max(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), {-124, -123, -124, -124, -125, -122}, false ); - _chk( QStringLiteral( "max(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), {-124, -123, -124, -124, -125, -122}, true ); - + _chk( QStringLiteral( "abs(-123)" ), { 123, 123, 123, 123, 123, 123 }, false ); + _chk( QStringLiteral( "abs(-\"landsat@1\")" ), { 125, 125, 124, 125, 125, 124 }, true ); + _chk( QStringLiteral( "abs(-123)" ), { 123, 123, 123, 123, 123, 123 }, false ); + _chk( QStringLiteral( "abs(-\"landsat@1\")" ), { 125, 125, 124, 125, 125, 124 }, true ); + _chk( QStringLiteral( "-\"landsat_4326@2\" + 15" ), { -124, -123, -125, -124, -126, -122 }, false ); + _chk( QStringLiteral( "min(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), { -125, -125, -125, -125, -126, -124 }, false ); + _chk( QStringLiteral( "min(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), { -125, -125, -125, -125, -126, -124 }, true ); + _chk( QStringLiteral( "max(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), { -124, -123, -124, -124, -125, -122 }, false ); + _chk( QStringLiteral( "max(-\"landsat@1\", -\"landsat_4326@2\" + 15 )" ), { -124, -123, -124, -124, -125, -122 }, true ); } void TestQgsRasterCalculator::testStatistics() @@ -870,12 +817,8 @@ void TestQgsRasterCalculator::testStatistics() QgsCoordinateReferenceSystem crs( QStringLiteral( "EPSG:32633" ) ); QgsRectangle extent( 783235, 3348110, 783350, 3347960 ); - QgsRasterCalculator rc( QStringLiteral( "\"landsat@1\" * 2" ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, { entry1 }, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 0 ); + QgsRasterCalculator rc( QStringLiteral( "\"landsat@1\" * 2" ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, { entry1 }, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 0 ); //open output file and check stats are there auto ds = GDALOpenEx( tmpName.toUtf8().constData(), GDAL_OF_RASTER | GDAL_OF_READONLY, nullptr, nullptr, nullptr ); @@ -884,15 +827,14 @@ void TestQgsRasterCalculator::testStatistics() QCOMPARE( GDALGetRasterStatistics( band, true, false, &sMin, &sMax, &sMean, &sStdDev ), CE_None ); QCOMPARE( sMin, 248.0 ); QCOMPARE( sMax, 250.0 ); - } void TestQgsRasterCalculator::parseFunctionTypeString() { QString errorString; - const QgsRasterCalcNode *node { QgsRasterCalcNode::parseRasterCalcString( QString( ), errorString ) }; - QVERIFY( ! node ); - QVERIFY( ! errorString.isEmpty() ); + const QgsRasterCalcNode *node { QgsRasterCalcNode::parseRasterCalcString( QString(), errorString ) }; + QVERIFY( !node ); + QVERIFY( !errorString.isEmpty() ); errorString = QString(); node = QgsRasterCalcNode::parseRasterCalcString( QStringLiteral( "if(\"raster@1\">5,100,5)" ), errorString ); @@ -935,18 +877,14 @@ void TestQgsRasterCalculator::testFunctionTypeWithLayer() // Test with one raster as condition and numbers as first and second option // if ( landsat@1 > 124.5, 100.0 , 5.0 ) - QgsRasterCalculator rc( QStringLiteral( " if(\"landsat@1\">124.5, 100.0 , 5.0 ) " ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc.processCalculation() ), 0 ); + QgsRasterCalculator rc( QStringLiteral( " if(\"landsat@1\">124.5, 100.0 , 5.0 ) " ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc.processCalculation() ), 0 ); //open output file and check results - std::unique_ptr< QgsRasterLayer > result = std::make_unique< QgsRasterLayer >( tmpName, QStringLiteral( "result" ) ); + std::unique_ptr result = std::make_unique( tmpName, QStringLiteral( "result" ) ); QCOMPARE( result->width(), 2 ); QCOMPARE( result->height(), 3 ); - std::unique_ptr< QgsRasterBlock > block( result->dataProvider()->block( 1, extent, 2, 3 ) ); + std::unique_ptr block( result->dataProvider()->block( 1, extent, 2, 3 ) ); QCOMPARE( block->value( 0, 0 ), 100.0 ); QCOMPARE( block->value( 0, 1 ), 100.0 ); @@ -957,15 +895,11 @@ void TestQgsRasterCalculator::testFunctionTypeWithLayer() // Test with one raster as condition, one raster first option and number as second option // if ( landsat@1 > 124.5, landsat@1 + landsat@2 , 5.0 ) - QgsRasterCalculator rc2( QStringLiteral( " if(\"landsat@1\">124.5, \"landsat@1\" + \"landsat@2\" , 5.0 ) " ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc2.processCalculation() ), 0 ); + QgsRasterCalculator rc2( QStringLiteral( " if(\"landsat@1\">124.5, \"landsat@1\" + \"landsat@2\" , 5.0 ) " ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc2.processCalculation() ), 0 ); //open output file and check results - result = std::make_unique< QgsRasterLayer >( tmpName, QStringLiteral( "result" ) ); + result = std::make_unique( tmpName, QStringLiteral( "result" ) ); QCOMPARE( result->width(), 2 ); QCOMPARE( result->height(), 3 ); block.reset( result->dataProvider()->block( 1, extent, 2, 3 ) ); @@ -978,15 +912,11 @@ void TestQgsRasterCalculator::testFunctionTypeWithLayer() // Test with one raster as condition, one raster first option and number as second option // if ( landsat@1 > 124.5, landsat@1 + landsat@2 , landsat@3 ) - QgsRasterCalculator rc3( QStringLiteral( " if(\"landsat@1\">124.5, \"landsat@1\" + \"landsat@2\" , \"landsat@1\" - \"landsat@2\" ) " ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc3.processCalculation() ), 0 ); + QgsRasterCalculator rc3( QStringLiteral( " if(\"landsat@1\">124.5, \"landsat@1\" + \"landsat@2\" , \"landsat@1\" - \"landsat@2\" ) " ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc3.processCalculation() ), 0 ); //open output file and check results - result = std::make_unique< QgsRasterLayer >( tmpName, QStringLiteral( "result" ) ); + result = std::make_unique( tmpName, QStringLiteral( "result" ) ); QCOMPARE( result->width(), 2 ); QCOMPARE( result->height(), 3 ); block.reset( result->dataProvider()->block( 1, extent, 2, 3 ) ); @@ -999,15 +929,11 @@ void TestQgsRasterCalculator::testFunctionTypeWithLayer() // Test with scalar (always true) as condition, one raster first option and number as second option // if ( 5 > 4, landsat@1 + landsat@2 , 0 ) - QgsRasterCalculator rc4( QStringLiteral( " if( 5>4 , \"landsat@1\" + \"landsat@2\" , 0 ) " ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc4.processCalculation() ), 0 ); + QgsRasterCalculator rc4( QStringLiteral( " if( 5>4 , \"landsat@1\" + \"landsat@2\" , 0 ) " ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc4.processCalculation() ), 0 ); //open output file and check results - result = std::make_unique< QgsRasterLayer >( tmpName, QStringLiteral( "result" ) ); + result = std::make_unique( tmpName, QStringLiteral( "result" ) ); QCOMPARE( result->width(), 2 ); QCOMPARE( result->height(), 3 ); block.reset( result->dataProvider()->block( 1, extent, 2, 3 ) ); @@ -1020,15 +946,11 @@ void TestQgsRasterCalculator::testFunctionTypeWithLayer() // Test with scalar (always false) as condition, one raster first option and number as second option // if ( 4 > 5, landsat@1 + landsat@2 , 0 ) - QgsRasterCalculator rc5( QStringLiteral( " if( 4>5 , \"landsat@1\" + \"landsat@2\" , 0 ) " ), - tmpName, - QStringLiteral( "GTiff" ), - extent, crs, 2, 3, entries, - QgsProject::instance()->transformContext() ); - QCOMPARE( static_cast< int >( rc5.processCalculation() ), 0 ); + QgsRasterCalculator rc5( QStringLiteral( " if( 4>5 , \"landsat@1\" + \"landsat@2\" , 0 ) " ), tmpName, QStringLiteral( "GTiff" ), extent, crs, 2, 3, entries, QgsProject::instance()->transformContext() ); + QCOMPARE( static_cast( rc5.processCalculation() ), 0 ); //open output file and check results - result = std::make_unique< QgsRasterLayer >( tmpName, QStringLiteral( "result" ) ); + result = std::make_unique( tmpName, QStringLiteral( "result" ) ); QCOMPARE( result->width(), 2 ); QCOMPARE( result->height(), 3 ); block.reset( result->dataProvider()->block( 1, extent, 2, 3 ) ); diff --git a/tests/src/analysis/testqgsreclassifyutils.cpp b/tests/src/analysis/testqgsreclassifyutils.cpp index e698151c88b2..5967bc0286f2 100644 --- a/tests/src/analysis/testqgsreclassifyutils.cpp +++ b/tests/src/analysis/testqgsreclassifyutils.cpp @@ -21,32 +21,27 @@ #include "qgsrasterfilewriter.h" #include -class TestQgsReclassifyUtils: public QgsTest +class TestQgsReclassifyUtils : public QgsTest { Q_OBJECT public: - TestQgsReclassifyUtils() : QgsTest( QStringLiteral( "Reclassify Utils Test" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void reclassifyValue(); void testReclassify_data(); void testReclassify(); private: - - QVector reclassifyBlock( const QVector &input, int nRows, int nCols, - const QVector< QgsReclassifyUtils::RasterClass > &classes, - double destNoDataValue, bool useNoDataForMissing ); - + QVector reclassifyBlock( const QVector &input, int nRows, int nCols, const QVector &classes, double destNoDataValue, bool useNoDataForMissing ); }; void TestQgsReclassifyUtils::initTestCase() @@ -64,7 +59,7 @@ void TestQgsReclassifyUtils::reclassifyValue() { // no classes bool ok = false; - QVector< QgsReclassifyUtils::RasterClass > classes; + QVector classes; QCOMPARE( QgsReclassifyUtils::reclassifyValue( classes, 5.9, ok ), 5.9 ); QVERIFY( !ok ); @@ -103,96 +98,95 @@ Q_DECLARE_METATYPE( QgsReclassifyUtils::RasterClass ); void TestQgsReclassifyUtils::testReclassify_data() { - QTest::addColumn>( "input" ); + QTest::addColumn>( "input" ); QTest::addColumn( "nRows" ); QTest::addColumn( "nCols" ); - QTest::addColumn>( "classes" ); + QTest::addColumn>( "classes" ); QTest::addColumn( "destNoDataValue" ); QTest::addColumn( "useNoDataForMissing" ); QTest::addColumn( "dataType" ); - QTest::addColumn>( "expected" ); + QTest::addColumn>( "expected" ); - QTest::newRow( "no change" ) << QVector< double > { 1, 2, 3, 4, 5, 6 } + QTest::newRow( "no change" ) << QVector { 1, 2, 3, 4, 5, 6 } << 3 << 2 - << QVector< QgsReclassifyUtils::RasterClass >() - << -9999.0 << false << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { 1, 2, 3, 4, 5, 6 }; + << QVector() + << -9999.0 << false << static_cast( Qgis::DataType::Float32 ) + << QVector { 1, 2, 3, 4, 5, 6 }; - QTest::newRow( "one class" ) << QVector< double > { 1, 2, 3, 4, 5, 6 } + QTest::newRow( "one class" ) << QVector { 1, 2, 3, 4, 5, 6 } << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() + << ( QVector() << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMax, 8 ) ) - << -9999.0 << false << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { 1, 2, 3, 8, 8, 6 }; + << -9999.0 << false << static_cast( Qgis::DataType::Float32 ) + << QVector { 1, 2, 3, 8, 8, 6 }; - QTest::newRow( "byte type" ) << QVector< double > { 1, 2, 3, 4, 5, 6 } + QTest::newRow( "byte type" ) << QVector { 1, 2, 3, 4, 5, 6 } << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() + << ( QVector() << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMax, 8 ) ) - << -9999.0 << false << static_cast< int >( Qgis::DataType::Byte ) - << QVector< double > { 1, 2, 3, 8, 8, 6 }; + << -9999.0 << false << static_cast( Qgis::DataType::Byte ) + << QVector { 1, 2, 3, 8, 8, 6 }; - QTest::newRow( "two class" ) << QVector< double > { 1, 2, 3, 4, 5, 6 } + QTest::newRow( "two class" ) << QVector { 1, 2, 3, 4, 5, 6 } << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() + << ( QVector() << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMax, 8 ) << QgsReclassifyUtils::RasterClass( 1, 3, QgsRasterRange::IncludeMin, -7 ) ) - << -9999.0 << false << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { -7, -7, 3, 8, 8, 6 }; + << -9999.0 << false << static_cast( Qgis::DataType::Float32 ) + << QVector { -7, -7, 3, 8, 8, 6 }; - QTest::newRow( "infinite range" ) << QVector< double > { 1, 2, 3, 4, 5, 6 } + QTest::newRow( "infinite range" ) << QVector { 1, 2, 3, 4, 5, 6 } << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() + << ( QVector() << QgsReclassifyUtils::RasterClass( 3, std::numeric_limits::quiet_NaN(), QgsRasterRange::IncludeMax, 8 ) << QgsReclassifyUtils::RasterClass( 1, 3, QgsRasterRange::IncludeMin, -7 ) ) - << -9999.0 << false << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { -7, -7, 3, 8, 8, 8 }; + << -9999.0 << false << static_cast( Qgis::DataType::Float32 ) + << QVector { -7, -7, 3, 8, 8, 8 }; - QTest::newRow( "infinite range 2" ) << QVector< double > { 1, 2, 3, 4, 5, 6 } + QTest::newRow( "infinite range 2" ) << QVector { 1, 2, 3, 4, 5, 6 } << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() - << QgsReclassifyUtils::RasterClass( 3, 4, QgsRasterRange::IncludeMax, 8 ) - << QgsReclassifyUtils::RasterClass( std::numeric_limits::quiet_NaN(), 3, QgsRasterRange::IncludeMin, -7 ) ) - << -9999.0 << false << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { -7, -7, 3, 8, 5, 6 }; + << ( QVector() + << QgsReclassifyUtils::RasterClass( 3, 4, QgsRasterRange::IncludeMax, 8 ) + << QgsReclassifyUtils::RasterClass( std::numeric_limits::quiet_NaN(), 3, QgsRasterRange::IncludeMin, -7 ) ) + << -9999.0 << false << static_cast( Qgis::DataType::Float32 ) + << QVector { -7, -7, 3, 8, 5, 6 }; - QTest::newRow( "with source no data" ) << QVector< double > { 1, 2, -9999, 4, 5, 6 } + QTest::newRow( "with source no data" ) << QVector { 1, 2, -9999, 4, 5, 6 } << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() - << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMinAndMax, 8 ) ) - << -9999.0 << false << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { 1, 2, -9999, 8, 8, 6 }; + << ( QVector() + << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMinAndMax, 8 ) ) + << -9999.0 << false << static_cast( Qgis::DataType::Float32 ) + << QVector { 1, 2, -9999, 8, 8, 6 }; - QTest::newRow( "with dest no data" ) << QVector< double > { 1, 2, -9999, 4, 5, 6 } + QTest::newRow( "with dest no data" ) << QVector { 1, 2, -9999, 4, 5, 6 } << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() - << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMinAndMax, 8 ) ) - << -99.0 << false << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { 1, 2, -99, 8, 8, 6 }; - - QTest::newRow( "use no data for missing" ) << QVector< double > { 1, 2, -9999, 4, 5, 6 } - << 3 << 2 - << ( QVector< QgsReclassifyUtils::RasterClass >() - << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMinAndMax, 8 ) ) - << -9999.0 << true << static_cast< int >( Qgis::DataType::Float32 ) - << QVector< double > { -9999, -9999, -9999, 8, 8, -9999 }; + << ( QVector() + << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMinAndMax, 8 ) ) + << -99.0 << false << static_cast( Qgis::DataType::Float32 ) + << QVector { 1, 2, -99, 8, 8, 6 }; + + QTest::newRow( "use no data for missing" ) << QVector { 1, 2, -9999, 4, 5, 6 } + << 3 << 2 + << ( QVector() + << QgsReclassifyUtils::RasterClass( 3, 5, QgsRasterRange::IncludeMinAndMax, 8 ) ) + << -9999.0 << true << static_cast( Qgis::DataType::Float32 ) + << QVector { -9999, -9999, -9999, 8, 8, -9999 }; } void TestQgsReclassifyUtils::testReclassify() { - QFETCH( QVector< double >, input ); + QFETCH( QVector, input ); QFETCH( int, nRows ); QFETCH( int, nCols ); - QFETCH( QVector< QgsReclassifyUtils::RasterClass >, classes ); + QFETCH( QVector, classes ); QFETCH( double, destNoDataValue ); QFETCH( bool, useNoDataForMissing ); QFETCH( int, dataType ); - QFETCH( QVector< double >, expected ); + QFETCH( QVector, expected ); const QgsRectangle extent = QgsRectangle( 0, 0, nRows, nCols ); const QgsCoordinateReferenceSystem crs( QStringLiteral( "EPSG:3857" ) ); - double tform[] = - { + double tform[] = { extent.xMinimum(), extent.width() / nCols, 0.0, extent.yMaximum(), 0.0, -extent.height() / nRows }; @@ -205,13 +199,13 @@ void TestQgsReclassifyUtils::testReclassify() // create a GeoTIFF - this will create data provider in editable mode QString filename = dirPath + QStringLiteral( "/test.tif" ); - std::unique_ptr< QgsRasterFileWriter > writer = std::make_unique< QgsRasterFileWriter >( filename ); + std::unique_ptr writer = std::make_unique( filename ); writer->setOutputProviderKey( QStringLiteral( "gdal" ) ); writer->setOutputFormat( QStringLiteral( "GTiff" ) ); - std::unique_ptr dp( writer->createOneBandRaster( Qgis::DataType::Float32, nCols, nRows, extent, crs ) ); + std::unique_ptr dp( writer->createOneBandRaster( Qgis::DataType::Float32, nCols, nRows, extent, crs ) ); QVERIFY( dp->isValid() ); dp->setNoDataValue( 1, -9999 ); - std::unique_ptr< QgsRasterBlock > block( dp->block( 1, extent, nCols, nRows ) ); + std::unique_ptr block( dp->block( 1, extent, nCols, nRows ) ); if ( !dp->isEditable() ) { QVERIFY( dp->setEditable( true ) ); @@ -231,7 +225,7 @@ void TestQgsReclassifyUtils::testReclassify() // create a GeoTIFF - this will create data provider in editable mode filename = dirPath + QStringLiteral( "/test2.tif" ); - std::unique_ptr< QgsRasterDataProvider > dp2( QgsRasterDataProvider::create( QStringLiteral( "gdal" ), filename, QStringLiteral( "GTiff" ), 1, static_cast< Qgis::DataType >( dataType ), 10, 10, tform, crs ) ); + std::unique_ptr dp2( QgsRasterDataProvider::create( QStringLiteral( "gdal" ), filename, QStringLiteral( "GTiff" ), 1, static_cast( dataType ), 10, 10, tform, crs ) ); QVERIFY( dp2->isValid() ); // reclassify @@ -239,7 +233,7 @@ void TestQgsReclassifyUtils::testReclassify() // read back in values block.reset( dp2->block( 1, extent, nCols, nRows ) ); - QVector< double > res( nCols * nRows ); + QVector res( nCols * nRows ); i = 0; for ( int row = 0; row < nRows; row++ ) { diff --git a/tests/src/analysis/testqgstriangulation.cpp b/tests/src/analysis/testqgstriangulation.cpp index a3717e573241..24b712f02e52 100644 --- a/tests/src/analysis/testqgstriangulation.cpp +++ b/tests/src/analysis/testqgstriangulation.cpp @@ -27,17 +27,16 @@ class TestQgsTriangulation : public QgsTest Q_OBJECT public: - TestQgsTriangulation() : QgsTest( QStringLiteral( "Triangulation Test" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() ;// will be called before each testfunction is executed. - void cleanup() ;// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void dualEdge(); void meshTriangulation(); @@ -47,7 +46,7 @@ class TestQgsTriangulation : public QgsTest private: }; -void TestQgsTriangulation::initTestCase() +void TestQgsTriangulation::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); @@ -79,7 +78,7 @@ void TestQgsTriangulation::dualEdge() mesh = triangulation.triangulationToMesh(); QCOMPARE( mesh.vertices.count(), 3 ); QCOMPARE( mesh.faceCount(), 1 ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 2, 1} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 0, 2, 1 } ) ) ); } { @@ -96,7 +95,7 @@ void TestQgsTriangulation::dualEdge() mesh = triangulation.triangulationToMesh(); QCOMPARE( mesh.vertices.count(), 4 ); QCOMPARE( mesh.faceCount(), 2 ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 2, 1} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 0, 2, 1 } ) ) ); } { @@ -112,8 +111,8 @@ void TestQgsTriangulation::dualEdge() mesh = triangulation.triangulationToMesh(); QCOMPARE( mesh.vertices.count(), 4 ); QCOMPARE( mesh.faceCount(), 2 ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 3, 1} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {3, 2, 1} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 0, 3, 1 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( { 3, 2, 1 } ) ) ); triangulation.addPoint( QgsPoint( 2, 3, 0 ) ); mesh = triangulation.triangulationToMesh(); QCOMPARE( mesh.vertices.count(), 5 ); @@ -133,15 +132,15 @@ void TestQgsTriangulation::dualEdge() mesh = triangulation.triangulationToMesh(); QCOMPARE( mesh.vertices.count(), 4 ); QCOMPARE( mesh.faceCount(), 2 ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 3, 2} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {1, 2, 3} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 0, 3, 2 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( { 1, 2, 3 } ) ) ); triangulation.addPoint( QgsPoint( 2, 3, 0 ) ); mesh = triangulation.triangulationToMesh(); QCOMPARE( mesh.vertices.count(), 5 ); QCOMPARE( mesh.faceCount(), 3 ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 3, 2} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {1, 3, 4} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 2 ), QgsMeshFace( {1, 2, 3} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 0, 3, 2 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( { 1, 3, 4 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 2 ), QgsMeshFace( { 1, 2, 3 } ) ) ); } { @@ -189,9 +188,7 @@ void TestQgsTriangulation::meshTriangulation() meshTri.setCrs( QgsCoordinateReferenceSystem( "EPSG:32620" ) ); - std::unique_ptr< QgsVectorLayer > mLayerPointZ = std::make_unique< QgsVectorLayer >( QStringLiteral( "PointZ?crs=EPSG:32620" ), - QStringLiteral( "point Z" ), - QStringLiteral( "memory" ) ); + std::unique_ptr mLayerPointZ = std::make_unique( QStringLiteral( "PointZ?crs=EPSG:32620" ), QStringLiteral( "point Z" ), QStringLiteral( "memory" ) ); const QString wkt1 = "PointZ (684486.0 1761297.0 1)"; const QString wkt2 = "PointZ (684276.0 1761309.0 2)"; @@ -212,9 +209,7 @@ void TestQgsTriangulation::meshTriangulation() mLayerPointZ->dataProvider()->addFeatures( flist ); const QgsCoordinateTransformContext transformContext; - QgsCoordinateTransform transform( mLayerPointZ->crs(), - QgsCoordinateReferenceSystem( "EPSG:32620" ), - transformContext ); + QgsCoordinateTransform transform( mLayerPointZ->crs(), QgsCoordinateReferenceSystem( "EPSG:32620" ), transformContext ); QgsFeatureIterator fIt = mLayerPointZ->getFeatures(); meshTri.addVertices( fIt, -1, transform ); @@ -228,22 +223,18 @@ void TestQgsTriangulation::meshTriangulation() QCOMPARE( mesh.vertex( 1 ), QgsMeshVertex( 684276.0, 1761309.0, 2 ) ); QCOMPARE( mesh.vertex( 2 ), QgsMeshVertex( 684098.0, 1761401.0, 3 ) ); QCOMPARE( mesh.vertex( 3 ), QgsMeshVertex( 684292.0, 1761406.0, 4 ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 3, 1} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {1, 3, 2} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 0, 3, 1 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( { 1, 3, 2 } ) ) ); const QString wkt5 = "LineStringZ (684098.0 1761401.0 3,684210.24 1761347.92 7,684343.8 1761373.4 8,684486.0 1761297.0 1)"; - std::unique_ptr< QgsVectorLayer > mLayerBreakLine = std::make_unique< QgsVectorLayer >( QStringLiteral( "LineStringZ?crs=EPSG:32620" ), - QStringLiteral( "line" ), - QStringLiteral( "memory" ) ); + std::unique_ptr mLayerBreakLine = std::make_unique( QStringLiteral( "LineStringZ?crs=EPSG:32620" ), QStringLiteral( "line" ), QStringLiteral( "memory" ) ); QgsFeature f5; f5.setGeometry( QgsGeometry::fromWkt( wkt5 ) ); mLayerBreakLine->dataProvider()->addFeature( f5 ); - transform = QgsCoordinateTransform( mLayerBreakLine->crs(), - QgsCoordinateReferenceSystem( "EPSG:32620" ), - transformContext ); + transform = QgsCoordinateTransform( mLayerBreakLine->crs(), QgsCoordinateReferenceSystem( "EPSG:32620" ), transformContext ); fIt = mLayerBreakLine->getFeatures(); meshTri.addBreakLines( fIt, -1, transform ); @@ -252,21 +243,19 @@ void TestQgsTriangulation::meshTriangulation() QCOMPARE( mesh.vertexCount(), 6 ); QCOMPARE( mesh.faceCount(), 6 ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 3, 5} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {0, 5, 1} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 2 ), QgsMeshFace( {1, 4, 2} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 3 ), QgsMeshFace( {3, 4, 5} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 4 ), QgsMeshFace( {1, 5, 4} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 5 ), QgsMeshFace( {2, 4, 3} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 0, 3, 5 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( { 0, 5, 1 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 2 ), QgsMeshFace( { 1, 4, 2 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 3 ), QgsMeshFace( { 3, 4, 5 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 4 ), QgsMeshFace( { 1, 5, 4 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 5 ), QgsMeshFace( { 2, 4, 3 } ) ) ); } void TestQgsTriangulation::meshTriangulationWithOnlyBreakLine() { QgsMeshTriangulation meshTri; - std::unique_ptr< QgsVectorLayer > mLayerLineZ = std::make_unique< QgsVectorLayer>( QStringLiteral( "LineStringZ" ), - QStringLiteral( "break line Z" ), - QStringLiteral( "memory" ) ); + std::unique_ptr mLayerLineZ = std::make_unique( QStringLiteral( "LineStringZ" ), QStringLiteral( "break line Z" ), QStringLiteral( "memory" ) ); QStringList wktLines; @@ -292,9 +281,7 @@ void TestQgsTriangulation::meshTriangulationWithOnlyBreakLine() mLayerLineZ->dataProvider()->addFeatures( flist ); const QgsCoordinateTransformContext transformContext; - const QgsCoordinateTransform transform( mLayerLineZ->crs(), - QgsCoordinateReferenceSystem(), - transformContext ); + const QgsCoordinateTransform transform( mLayerLineZ->crs(), QgsCoordinateReferenceSystem(), transformContext ); QgsFeatureIterator fIt = mLayerLineZ->getFeatures(); meshTri.addBreakLines( fIt, -1, transform ); @@ -304,25 +291,23 @@ void TestQgsTriangulation::meshTriangulationWithOnlyBreakLine() QCOMPARE( mesh.vertexCount(), 8 ); QCOMPARE( mesh.faceCount(), 6 ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {2, 0, 4} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {0, 2, 1} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 2 ), QgsMeshFace( {1, 2, 5} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 3 ), QgsMeshFace( {2, 4, 3} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 4 ), QgsMeshFace( {4, 6, 3} ) ) ); - QVERIFY( QgsMesh::compareFaces( mesh.face( 5 ), QgsMeshFace( {4, 7, 6} ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( { 2, 0, 4 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( { 0, 2, 1 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 2 ), QgsMeshFace( { 1, 2, 5 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 3 ), QgsMeshFace( { 2, 4, 3 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 4 ), QgsMeshFace( { 4, 6, 3 } ) ) ); + QVERIFY( QgsMesh::compareFaces( mesh.face( 5 ), QgsMeshFace( { 4, 7, 6 } ) ) ); } void TestQgsTriangulation::meshTriangulationPointAndBreakLineBreakLine() { QgsMeshTriangulation meshTri; - std::unique_ptr< QgsVectorLayer > mLayerPointsZ = std::make_unique< QgsVectorLayer >( QStringLiteral( "PointZ" ), - QStringLiteral( "points Z" ), - QStringLiteral( "memory" ) ); + std::unique_ptr mLayerPointsZ = std::make_unique( QStringLiteral( "PointZ" ), QStringLiteral( "points Z" ), QStringLiteral( "memory" ) ); for ( int i = 0; i < 4; ++i ) { - for ( int j = 0 ; j < 10; ++j ) + for ( int j = 0; j < 10; ++j ) { QgsFeature feat; feat.setGeometry( QgsGeometry( new QgsPoint( i * 10.0, j * 10.0 ) ) ); @@ -331,9 +316,7 @@ void TestQgsTriangulation::meshTriangulationPointAndBreakLineBreakLine() } const QgsCoordinateTransformContext transformContext; - const QgsCoordinateTransform transform( mLayerPointsZ->crs(), - QgsCoordinateReferenceSystem(), - transformContext ); + const QgsCoordinateTransform transform( mLayerPointsZ->crs(), QgsCoordinateReferenceSystem(), transformContext ); QgsFeatureIterator fIt = mLayerPointsZ->getFeatures(); meshTri.addVertices( fIt, -1, transform ); @@ -343,9 +326,7 @@ void TestQgsTriangulation::meshTriangulationPointAndBreakLineBreakLine() QCOMPARE( mesh.vertexCount(), 40 ); QCOMPARE( mesh.faceCount(), 54 ); - std::unique_ptr< QgsVectorLayer > mLayerLineZ = std::make_unique< QgsVectorLayer >( QStringLiteral( "LineStringZ" ), - QStringLiteral( "break line Z" ), - QStringLiteral( "memory" ) ); + std::unique_ptr mLayerLineZ = std::make_unique( QStringLiteral( "LineStringZ" ), QStringLiteral( "break line Z" ), QStringLiteral( "memory" ) ); QgsFeature feat; diff --git a/tests/src/analysis/testqgszonalstatistics.cpp b/tests/src/analysis/testqgszonalstatistics.cpp index 9c4fe1ac6d74..d372f9b47546 100644 --- a/tests/src/analysis/testqgszonalstatistics.cpp +++ b/tests/src/analysis/testqgszonalstatistics.cpp @@ -33,7 +33,6 @@ class TestQgsZonalStatistics : public QgsTest Q_OBJECT public: - TestQgsZonalStatistics() : QgsTest( QStringLiteral( "Zonal Statistics Test" ) ) {} @@ -79,7 +78,8 @@ void TestQgsZonalStatistics::initTestCase() mVectorLayer = new QgsVectorLayer( mTempPath + "polys.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ); mRasterLayer = new QgsRasterLayer( mTempPath + "edge_problem.asc", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); QgsProject::instance()->addMapLayers( - QList() << mVectorLayer << mRasterLayer ); + QList() << mVectorLayer << mRasterLayer + ); } void TestQgsZonalStatistics::cleanupTestCase() @@ -201,8 +201,8 @@ void TestQgsZonalStatistics::testReprojection() const QString myTestDataPath = myDataPath + "/zonalstatistics/"; // create a reprojected version of the layer - std::unique_ptr< QgsVectorLayer > vectorLayer( new QgsVectorLayer( myTestDataPath + "polys.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ) ); - std::unique_ptr< QgsVectorLayer > reprojected( vectorLayer->materialize( QgsFeatureRequest().setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3785" ) ), QgsProject::instance()->transformContext() ) ) ); + std::unique_ptr vectorLayer( new QgsVectorLayer( myTestDataPath + "polys.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ) ); + std::unique_ptr reprojected( vectorLayer->materialize( QgsFeatureRequest().setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3785" ) ), QgsProject::instance()->transformContext() ) ) ); QCOMPARE( reprojected->featureCount(), vectorLayer->featureCount() ); QgsZonalStatistics zs( reprojected.get(), mRasterLayer, QString(), 1, Qgis::ZonalStatistic::All ); @@ -263,8 +263,8 @@ void TestQgsZonalStatistics::testNoData() const QString myTestDataPath = myDataPath + "/zonalstatistics/"; // test that zonal stats respects no data and user set no data values - std::unique_ptr< QgsRasterLayer > rasterLayer = std::make_unique< QgsRasterLayer >( myTestDataPath + "raster.tif", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); - std::unique_ptr< QgsVectorLayer > vectorLayer = std::make_unique< QgsVectorLayer >( mTempPath + "polys2.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ); + std::unique_ptr rasterLayer = std::make_unique( myTestDataPath + "raster.tif", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); + std::unique_ptr vectorLayer = std::make_unique( mTempPath + "polys2.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ); QgsZonalStatistics zs( vectorLayer.get(), rasterLayer.get(), QStringLiteral( "n" ), 1, Qgis::ZonalStatistic::All ); zs.calculateStatistics( nullptr ); @@ -288,8 +288,7 @@ void TestQgsZonalStatistics::testNoData() QCOMPARE( f.attribute( QStringLiteral( "nsum" ) ).toDouble(), 0.0 ); // with user no data - rasterLayer->dataProvider()->setUserNoDataValue( 1, QgsRasterRangeList() << QgsRasterRange( 842, 852 ) - << QgsRasterRange( 877, 891 ) ); + rasterLayer->dataProvider()->setUserNoDataValue( 1, QgsRasterRangeList() << QgsRasterRange( 842, 852 ) << QgsRasterRange( 877, 891 ) ); zs = QgsZonalStatistics( vectorLayer.get(), rasterLayer.get(), QStringLiteral( "un" ), 1, Qgis::ZonalStatistic::All ); zs.calculateStatistics( nullptr ); @@ -317,8 +316,8 @@ void TestQgsZonalStatistics::testSmallPolygons() const QString myTestDataPath = myDataPath + "/zonalstatistics/"; // test that zonal stats works ok with polygons much smaller than pixel size - const std::unique_ptr< QgsRasterLayer > rasterLayer = std::make_unique< QgsRasterLayer >( myTestDataPath + "raster.tif", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); - std::unique_ptr< QgsVectorLayer > vectorLayer = std::make_unique< QgsVectorLayer >( mTempPath + "small_polys.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ); + const std::unique_ptr rasterLayer = std::make_unique( myTestDataPath + "raster.tif", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); + std::unique_ptr vectorLayer = std::make_unique( mTempPath + "small_polys.shp", QStringLiteral( "poly" ), QStringLiteral( "ogr" ) ); QgsZonalStatistics zs( vectorLayer.get(), rasterLayer.get(), QStringLiteral( "n" ), 1, Qgis::ZonalStatistic::All ); zs.calculateStatistics( nullptr ); diff --git a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeatureline.cpp b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeatureline.cpp index d5d4a04e109a..f2b901f14ce3 100644 --- a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeatureline.cpp +++ b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeatureline.cpp @@ -46,7 +46,7 @@ namespace QTest QByteArray ba = geom.asWkt().toLatin1(); return qstrdup( ba.data() ); } -} +} // namespace QTest /** @@ -60,8 +60,8 @@ class TestQgsMapToolAddFeatureLine : public QObject TestQgsMapToolAddFeatureLine(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testNoTracing(); void testTracing(); @@ -141,7 +141,7 @@ void TestQgsMapToolAddFeatureLine::initTestCase() mLayerLine->startEditing(); mLayerLine->addFeature( lineF1 ); mFidLineF1 = lineF1.id(); - QCOMPARE( mLayerLine->featureCount(), ( long )1 ); + QCOMPARE( mLayerLine->featureCount(), ( long ) 1 ); // just one added feature QCOMPARE( mLayerLine->undoStack()->index(), 1 ); @@ -157,7 +157,7 @@ void TestQgsMapToolAddFeatureLine::initTestCase() mLayerLineCurved->startEditing(); mLayerLineCurved->addFeature( curveF1 ); mFidCurvedF1 = curveF1.id(); - QCOMPARE( mLayerLineCurved->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineCurved->featureCount(), ( long ) 1 ); // just one added feature QCOMPARE( mLayerLineCurved->undoStack()->index(), 1 ); @@ -173,7 +173,7 @@ void TestQgsMapToolAddFeatureLine::initTestCase() mLayerLineCurvedOffset->startEditing(); mLayerLineCurvedOffset->addFeature( curveF2 ); mFidCurvedF1 = curveF2.id(); - QCOMPARE( mLayerLineCurvedOffset->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineCurvedOffset->featureCount(), ( long ) 1 ); // just one added feature QCOMPARE( mLayerLineCurvedOffset->undoStack()->index(), 1 ); @@ -190,7 +190,7 @@ void TestQgsMapToolAddFeatureLine::initTestCase() mLayerLineZ->startEditing(); mLayerLineZ->addFeature( lineF2 ); - QCOMPARE( mLayerLineZ->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineZ->featureCount(), ( long ) 1 ); mLayerCloseLine = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line Closed" ), QStringLiteral( "memory" ) ); QVERIFY( mLayerCloseLine->isValid() ); @@ -215,7 +215,7 @@ void TestQgsMapToolAddFeatureLine::initTestCase() lineString2DF.setGeometry( QgsGeometry::fromWkt( "LineString ((8 8, 9 9))" ) ); mLayerLine2D->addFeature( lineString2DF ); - QCOMPARE( mLayerLine2D->featureCount(), ( long )1 ); + QCOMPARE( mLayerLine2D->featureCount(), ( long ) 1 ); // make testing layers mLayerSelfSnapLine = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line" ), QStringLiteral( "memory" ) ); @@ -225,18 +225,18 @@ void TestQgsMapToolAddFeatureLine::initTestCase() // make layers with different CRS mLayerCRS3946Line = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:3946" ), QStringLiteral( "layer line" ), QStringLiteral( "memory" ) ); - QVERIFY( mLayerCRS3946Line ->isValid() ); + QVERIFY( mLayerCRS3946Line->isValid() ); QgsProject::instance()->addMapLayers( QList() << mLayerCRS3946Line ); mLayerCRS3946Line->startEditing(); mLayerCRS3945Line = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:3945" ), QStringLiteral( "layer line" ), QStringLiteral( "memory" ) ); - QVERIFY( mLayerCRS3945Line ->isValid() ); + QVERIFY( mLayerCRS3945Line->isValid() ); QgsProject::instance()->addMapLayers( QList() << mLayerCRS3945Line ); mLayerCRS3945Line->startEditing(); // make layers with overlapping features to test topo editing mLayerTopo1 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line topo1" ), QStringLiteral( "memory" ) ); - QVERIFY( mLayerTopo1 ->isValid() ); + QVERIFY( mLayerTopo1->isValid() ); QgsProject::instance()->addMapLayers( QList() << mLayerTopo1 ); mLayerTopo1->startEditing(); @@ -245,13 +245,13 @@ void TestQgsMapToolAddFeatureLine::initTestCase() mLayerTopo1->addFeature( topoLineF1 ); mFidTopoLineF1 = topoLineF1.id(); - QCOMPARE( mLayerTopo1->featureCount(), ( long )1 ); + QCOMPARE( mLayerTopo1->featureCount(), ( long ) 1 ); // just one added feature QCOMPARE( mLayerTopo1->undoStack()->index(), 1 ); mLayerTopo2 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line topo2" ), QStringLiteral( "memory" ) ); - QVERIFY( mLayerTopo2 ->isValid() ); + QVERIFY( mLayerTopo2->isValid() ); QgsProject::instance()->addMapLayers( QList() << mLayerTopo2 ); mLayerTopo2->startEditing(); @@ -260,13 +260,13 @@ void TestQgsMapToolAddFeatureLine::initTestCase() mLayerTopo2->addFeature( topoLineF2 ); mFidTopoLineF2 = topoLineF2.id(); - QCOMPARE( mLayerTopo2->featureCount(), ( long )1 ); + QCOMPARE( mLayerTopo2->featureCount(), ( long ) 1 ); // just one added feature QCOMPARE( mLayerTopo2->undoStack()->index(), 1 ); mLayerTopo3 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line topo3" ), QStringLiteral( "memory" ) ); - QVERIFY( mLayerTopo3 ->isValid() ); + QVERIFY( mLayerTopo3->isValid() ); mLayerTopo3->startEditing(); QgsProject::instance()->addMapLayers( QList() << mLayerTopo3 ); @@ -346,7 +346,7 @@ void TestQgsMapToolAddFeatureLine::testNoTracing() QCOMPARE( mLayerLine->undoStack()->index(), 2 ); // as here, QCOMPARE with QgsGeometry uses isGeosEqual() and geos does not support curve (need to convert curve to line string), test with wkt string - QCOMPARE( mLayerLine->getFeature( newFid ).geometry().asWkt(), QStringLiteral( "CompoundCurve (CircularString (1 1, 3 2, 4 2),(4 2, 4 3))" ) ) ; + QCOMPARE( mLayerLine->getFeature( newFid ).geometry().asWkt(), QStringLiteral( "CompoundCurve (CircularString (1 1, 3 2, 4 2),(4 2, 4 3))" ) ); mLayerLine->undoStack()->undo(); QCOMPARE( mLayerLine->undoStack()->index(), 1 ); @@ -560,7 +560,7 @@ void TestQgsMapToolAddFeatureLine::testTracingWithConvertToCurves() const QgsAbstractGeometry *g = mLayerLineCurved->getFeature( newFid1 ).geometry().constGet(); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( 6, 1 ) ); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, g->vertexCount() - 1 ) ), QgsPoint( 7, 1 ) ); - QVERIFY( g->vertexCount() > 3 ); // a segmentized arc has (much) more than 3 points + QVERIFY( g->vertexCount() > 3 ); // a segmentized arc has (much) more than 3 points mLayerLineCurved->undoStack()->undo(); @@ -577,7 +577,7 @@ void TestQgsMapToolAddFeatureLine::testTracingWithConvertToCurves() g = mLayerLineCurved->getFeature( newFid2 ).geometry().constGet(); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( 6, 1 ) ); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, g->vertexCount() - 1 ) ), QgsPoint( 7, 1 ) ); - QVERIFY( g->vertexCount() == 3 ); // a true arc is composed of 3 vertices + QVERIFY( g->vertexCount() == 3 ); // a true arc is composed of 3 vertices mLayerLineCurved->undoStack()->undo(); @@ -621,7 +621,7 @@ void TestQgsMapToolAddFeatureLine::testTracingWithConvertToCurvesCustomTolerance const QgsAbstractGeometry *g = mLayerLineCurvedOffset->getFeature( newFid1 ).geometry().constGet(); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( offset + 6, offset + 1 ) ); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, g->vertexCount() - 1 ) ), QgsPoint( offset + 7, offset + 1 ) ); - QVERIFY( g->vertexCount() > 3 ); // a segmentized arc has (much) more than 3 points + QVERIFY( g->vertexCount() > 3 ); // a segmentized arc has (much) more than 3 points mLayerLineCurvedOffset->undoStack()->undo(); @@ -638,7 +638,7 @@ void TestQgsMapToolAddFeatureLine::testTracingWithConvertToCurvesCustomTolerance g = mLayerLineCurvedOffset->getFeature( newFid2 ).geometry().constGet(); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( offset + 6, offset + 1 ) ); QCOMPARE( g->vertexAt( QgsVertexId( 0, 0, g->vertexCount() - 1 ) ), QgsPoint( offset + 7, offset + 1 ) ); - QVERIFY( g->vertexCount() == 3 ); // a true arc is composed of 3 vertices + QVERIFY( g->vertexCount() == 3 ); // a true arc is composed of 3 vertices mLayerLineCurvedOffset->undoStack()->undo(); @@ -650,7 +650,6 @@ void TestQgsMapToolAddFeatureLine::testTracingWithConvertToCurvesCustomTolerance // restore the extent mCanvas->setExtent( QgsRectangle( 0, 0, 8, 8 ) ); QCOMPARE( mCanvas->mapSettings().visibleExtent(), QgsRectangle( 0, 0, 8, 8 ) ); - } void TestQgsMapToolAddFeatureLine::testCloseLine() @@ -701,7 +700,7 @@ void TestQgsMapToolAddFeatureLine::testSelfSnapping() utils.mouseClick( 2, 5.1, Qt::RightButton ); const QgsFeatureId newFid1 = utils.newFeatureId( oldFids ); - QVERIFY( ! mLayerSelfSnapLine->getFeature( newFid1 ).geometry().equals( QgsGeometry::fromWkt( targetWkt ) ) ); + QVERIFY( !mLayerSelfSnapLine->getFeature( newFid1 ).geometry().equals( QgsGeometry::fromWkt( targetWkt ) ) ); mLayerSelfSnapLine->undoStack()->undo(); // With self snapping, endpoint will snap to start point @@ -982,8 +981,7 @@ void TestQgsMapToolAddFeatureLine::testWithTopologicalEditingDifferentCanvasCrs( // the crs of canvas and the one of layer should be different QVERIFY( mLayerCRS3946Line->sourceCrs() != mCanvas->mapSettings().destinationCrs() ); - const QgsCoordinateTransform transform( mLayerCRS3946Line->sourceCrs(), mCanvas->mapSettings().destinationCrs(), - QgsProject::instance() ); + const QgsCoordinateTransform transform( mLayerCRS3946Line->sourceCrs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); // add a base line utils.mouseClick( 0, 0, Qt::LeftButton ); @@ -1036,16 +1034,13 @@ void TestQgsMapToolAddFeatureLine::testWithTopologicalEditingDifferentCanvasCrs( } - void TestQgsMapToolAddFeatureLine::testWithTopologicalEditingWIthDiffLayerWithDiffCrs() { // the crs between the 2 lines should be different QVERIFY( mLayerCRS3946Line->sourceCrs() != mLayerCRS3945Line->sourceCrs() ); - const QgsCoordinateTransform transformFrom3945( mLayerCRS3945Line->sourceCrs(), mCanvas->mapSettings().destinationCrs(), - QgsProject::instance() ); - const QgsCoordinateTransform transformFrom3946( mLayerCRS3946Line->sourceCrs(), mCanvas->mapSettings().destinationCrs(), - QgsProject::instance() ); + const QgsCoordinateTransform transformFrom3945( mLayerCRS3945Line->sourceCrs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); + const QgsCoordinateTransform transformFrom3946( mLayerCRS3946Line->sourceCrs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); // add a base line in the 3945 layer mCanvas->setCurrentLayer( mLayerCRS3945Line ); diff --git a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinem.cpp b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinem.cpp index 2d44c4fbf56e..a42ae1c3c7ff 100644 --- a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinem.cpp +++ b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinem.cpp @@ -44,7 +44,7 @@ namespace QTest QByteArray ba = geom.asWkt().toLatin1(); return qstrdup( ba.data() ); } -} +} // namespace QTest /** @@ -58,8 +58,8 @@ class TestQgsMapToolAddFeatureLineM : public QObject TestQgsMapToolAddFeatureLineM(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testM(); void testTopologicalEditingM(); @@ -111,7 +111,7 @@ void TestQgsMapToolAddFeatureLineM::initTestCase() mLayerLine->startEditing(); mLayerLine->addFeature( lineF1 ); mFidLineF1 = lineF1.id(); - QCOMPARE( mLayerLine->featureCount(), ( long )1 ); + QCOMPARE( mLayerLine->featureCount(), ( long ) 1 ); // just one added feature QCOMPARE( mLayerLine->undoStack()->index(), 1 ); @@ -128,7 +128,7 @@ void TestQgsMapToolAddFeatureLineM::initTestCase() mLayerLineM->startEditing(); mLayerLineM->addFeature( lineF2 ); - QCOMPARE( mLayerLineM->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineM->featureCount(), ( long ) 1 ); mCanvas->setFrameStyle( QFrame::NoFrame ); mCanvas->resize( 512, 512 ); diff --git a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinez.cpp b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinez.cpp index 6c6bf6217470..9d557dbe3396 100644 --- a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinez.cpp +++ b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinez.cpp @@ -47,7 +47,7 @@ namespace QTest QByteArray ba = geom.asWkt().toLatin1(); return qstrdup( ba.data() ); } -} +} // namespace QTest /** @@ -61,8 +61,8 @@ class TestQgsMapToolAddFeatureLineZ : public QObject TestQgsMapToolAddFeatureLineZ(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testZ(); void testZSnapping(); @@ -115,7 +115,7 @@ void TestQgsMapToolAddFeatureLineZ::initTestCase() mLayerLine->startEditing(); mLayerLine->addFeature( lineF1 ); mFidLineF1 = lineF1.id(); - QCOMPARE( mLayerLine->featureCount(), ( long )1 ); + QCOMPARE( mLayerLine->featureCount(), ( long ) 1 ); // just one added feature QCOMPARE( mLayerLine->undoStack()->index(), 1 ); @@ -132,7 +132,7 @@ void TestQgsMapToolAddFeatureLineZ::initTestCase() mLayerLineZ->startEditing(); mLayerLineZ->addFeature( lineF2 ); - QCOMPARE( mLayerLineZ->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineZ->featureCount(), ( long ) 1 ); mCanvas->setFrameStyle( QFrame::NoFrame ); mCanvas->resize( 512, 512 ); @@ -150,10 +150,10 @@ void TestQgsMapToolAddFeatureLineZ::initTestCase() mLayerTopoZ->startEditing(); QgsFeature topoFeat; topoFeat.setGeometry( QgsGeometry::fromWkt( "MultiLineStringZ (" - "(10 0 0, 10 10 0)," - "(20 0 10, 20 10 10)," - "(30 0 0, 30 10 10)" - ")" ) ); + "(10 0 0, 10 10 0)," + "(20 0 10, 20 10 10)," + "(30 0 0, 30 10 10)" + ")" ) ); mLayerTopoZ->addFeature( topoFeat ); QCOMPARE( mLayerTopoZ->featureCount(), ( long ) 1 ); diff --git a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinezm.cpp b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinezm.cpp index 034603093ac1..5c9a3c6d88a6 100644 --- a/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinezm.cpp +++ b/tests/src/app/maptooladdfeatureline/testqgsmaptooladdfeaturelinezm.cpp @@ -47,7 +47,7 @@ namespace QTest QByteArray ba = geom.asWkt().toLatin1(); return qstrdup( ba.data() ); } -} +} // namespace QTest /** @@ -61,8 +61,8 @@ class TestQgsMapToolAddFeatureLineZM : public QObject TestQgsMapToolAddFeatureLineZM(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testZM(); @@ -109,7 +109,7 @@ void TestQgsMapToolAddFeatureLineZM::initTestCase() mLayerLineZM->startEditing(); mLayerLineZM->addFeature( lineF ); - QCOMPARE( mLayerLineZM->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineZM->featureCount(), ( long ) 1 ); mCanvas->setFrameStyle( QFrame::NoFrame ); mCanvas->resize( 512, 512 ); @@ -182,7 +182,6 @@ void TestQgsMapToolAddFeatureLineZM::testZM() QCOMPARE( mLayerLineZM->getFeature( newFid ).geometry(), QgsGeometry::fromWkt( wkt ) ); mLayerLineZM->undoStack()->undo(); - } QGSTEST_MAIN( TestQgsMapToolAddFeatureLineZM ) diff --git a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepoint.cpp b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepoint.cpp index 8f2ee748f9e9..3f6156237add 100644 --- a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepoint.cpp +++ b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepoint.cpp @@ -45,8 +45,8 @@ class TestQgsMapToolAddFeaturePoint : public QObject TestQgsMapToolAddFeaturePoint(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testPoint(); void testMultiPoint(); //!< Test crash from regression GH #45153 @@ -97,7 +97,7 @@ void TestQgsMapToolAddFeaturePoint::initTestCase() pointF.setGeometry( QgsGeometry::fromWkt( pointWkt ) ); mLayerPoint->addFeature( pointF ); - QCOMPARE( mLayerPoint->featureCount(), ( long )1 ); + QCOMPARE( mLayerPoint->featureCount(), ( long ) 1 ); // create the tool mCaptureTool = new QgsMapToolAddFeature( mCanvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CapturePoint ); @@ -125,7 +125,7 @@ void TestQgsMapToolAddFeaturePoint::testPoint() utils.mouseClick( 4, 0, Qt::LeftButton, Qt::KeyboardModifiers(), true ); QgsFeatureId newFid = utils.newFeatureId( oldFids ); - QCOMPARE( mLayerPoint->featureCount(), ( long )2 ); + QCOMPARE( mLayerPoint->featureCount(), ( long ) 2 ); QString wkt = "Point (4 0)"; QCOMPARE( mLayerPoint->getFeature( newFid ).geometry().asWkt(), wkt ); @@ -144,7 +144,6 @@ void TestQgsMapToolAddFeaturePoint::testPoint() void TestQgsMapToolAddFeaturePoint::testMultiPoint() { - QgsVectorLayer layerMultiPoint { QStringLiteral( "MultiPoint?crs=EPSG:27700" ), QStringLiteral( "layer multi point" ), QStringLiteral( "memory" ) }; layerMultiPoint.startEditing(); mCanvas->setCurrentLayer( &layerMultiPoint ); @@ -156,7 +155,7 @@ void TestQgsMapToolAddFeaturePoint::testMultiPoint() utils.mouseClick( 4, 0, Qt::LeftButton, Qt::KeyboardModifiers(), true ); QgsFeatureId fid1 = utils.newFeatureId( oldFids ); - QCOMPARE( layerMultiPoint.featureCount(), ( long )1 ); + QCOMPARE( layerMultiPoint.featureCount(), ( long ) 1 ); QString wkt = "MultiPoint ((4 0))"; QCOMPARE( layerMultiPoint.getFeature( fid1 ).geometry().asWkt(), wkt ); @@ -165,7 +164,7 @@ void TestQgsMapToolAddFeaturePoint::testMultiPoint() oldFids = utils.existingFeatureIds(); utils.mouseClick( 6, 6, Qt::LeftButton, Qt::KeyboardModifiers(), true ); - QCOMPARE( layerMultiPoint.featureCount(), ( long )2 ); + QCOMPARE( layerMultiPoint.featureCount(), ( long ) 2 ); QgsFeatureId fid2 = utils.newFeatureId( oldFids ); @@ -174,7 +173,6 @@ void TestQgsMapToolAddFeaturePoint::testMultiPoint() layerMultiPoint.undoStack()->undo(); // first point layerMultiPoint.undoStack()->undo(); // second point - } QGSTEST_MAIN( TestQgsMapToolAddFeaturePoint ) diff --git a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointm.cpp b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointm.cpp index c42a171a1da5..064ae339de86 100644 --- a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointm.cpp +++ b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointm.cpp @@ -43,8 +43,8 @@ class TestQgsMapToolAddFeaturePointM : public QObject TestQgsMapToolAddFeaturePointM(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testPointM(); @@ -94,7 +94,7 @@ void TestQgsMapToolAddFeaturePointM::initTestCase() pointFM.setGeometry( QgsGeometry::fromWkt( pointWktM ) ); mLayerPointM->addFeature( pointFM ); - QCOMPARE( mLayerPointM->featureCount(), ( long )1 ); + QCOMPARE( mLayerPointM->featureCount(), ( long ) 1 ); // create the tool mCaptureTool = new QgsMapToolAddFeature( mCanvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CapturePoint ); @@ -124,7 +124,7 @@ void TestQgsMapToolAddFeaturePointM::testPointM() utils.mouseClick( 4, 0, Qt::LeftButton, Qt::KeyboardModifiers(), true ); QgsFeatureId newFid = utils.newFeatureId( oldFids ); - QCOMPARE( mLayerPointM->featureCount(), ( long )2 ); + QCOMPARE( mLayerPointM->featureCount(), ( long ) 2 ); QString wkt = "Point M (4 0 333)"; QCOMPARE( mLayerPointM->getFeature( newFid ).geometry().asWkt(), wkt ); diff --git a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointz.cpp b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointz.cpp index 15ef09077a73..e3e9e6519372 100644 --- a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointz.cpp +++ b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointz.cpp @@ -42,8 +42,8 @@ class TestQgsMapToolAddFeaturePointZ : public QObject TestQgsMapToolAddFeaturePointZ(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testPointZ(); void testTopologicalEditingZ(); @@ -96,7 +96,7 @@ void TestQgsMapToolAddFeaturePointZ::initTestCase() pointFZ.setGeometry( QgsGeometry::fromWkt( pointWktZ ) ); mLayerPointZ->addFeature( pointFZ ); - QCOMPARE( mLayerPointZ->featureCount(), ( long )1 ); + QCOMPARE( mLayerPointZ->featureCount(), ( long ) 1 ); // make layer for snapping mLayerPointZSnap = new QgsVectorLayer( QStringLiteral( "PointZ?crs=EPSG:27700" ), QStringLiteral( "Snap point" ), QStringLiteral( "memory" ) ); @@ -109,7 +109,7 @@ void TestQgsMapToolAddFeaturePointZ::initTestCase() pointF.setGeometry( QgsGeometry::fromWkt( pointWktZSnap ) ); mLayerPointZSnap->addFeature( pointF ); - QCOMPARE( mLayerPointZSnap->featureCount(), ( long )1 ); + QCOMPARE( mLayerPointZSnap->featureCount(), ( long ) 1 ); // make line layer for snapping mLayerLineZSnap = new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=EPSG:27700" ), QStringLiteral( "Snap line" ), QStringLiteral( "memory" ) ); @@ -121,7 +121,7 @@ void TestQgsMapToolAddFeaturePointZ::initTestCase() lineF.setGeometry( QgsGeometry::fromWkt( "LineStringZ( 1 1 1, 5 5 5)" ) ); mLayerLineZSnap->addFeature( lineF ); - QCOMPARE( mLayerLineZSnap->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineZSnap->featureCount(), ( long ) 1 ); QgsSnappingConfig cfg = mCanvas->snappingUtils()->config(); cfg.setMode( Qgis::SnappingMode::AllLayers ); @@ -165,7 +165,7 @@ void TestQgsMapToolAddFeaturePointZ::testPointZ() utils.mouseClick( 4, 0, Qt::LeftButton, Qt::KeyboardModifiers(), true ); QgsFeatureId newFid = utils.newFeatureId( oldFids ); - QCOMPARE( mLayerPointZ->featureCount(), ( long )2 ); + QCOMPARE( mLayerPointZ->featureCount(), ( long ) 2 ); QString wkt = "Point Z (4 0 333)"; QCOMPARE( mLayerPointZ->getFeature( newFid ).geometry().asWkt(), wkt ); @@ -197,13 +197,13 @@ void TestQgsMapToolAddFeaturePointZ::testTopologicalEditingZ() utils.mouseClick( 3, 3, Qt::LeftButton, Qt::KeyboardModifiers(), true ); const QgsFeatureId newFid = utils.newFeatureId( oldFids ); - QCOMPARE( mLayerPointZ->featureCount(), ( long )2 ); + QCOMPARE( mLayerPointZ->featureCount(), ( long ) 2 ); QString wkt = "Point Z (3 3 3)"; QCOMPARE( mLayerPointZ->getFeature( newFid ).geometry().asWkt(), wkt ); - QCOMPARE( mLayerLineZSnap->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineZSnap->featureCount(), ( long ) 1 ); wkt = "LineString Z (1 1 1, 3 3 3, 5 5 5)"; QgsFeature f; @@ -213,7 +213,6 @@ void TestQgsMapToolAddFeaturePointZ::testTopologicalEditingZ() QgsProject::instance()->setTopologicalEditing( topologicalEditing ); mLayerPointZ->undoStack()->undo(); mLayerLineZSnap->undoStack()->undo(); - } QGSTEST_MAIN( TestQgsMapToolAddFeaturePointZ ) diff --git a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointzm.cpp b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointzm.cpp index 66921252f50d..6c767e293312 100644 --- a/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointzm.cpp +++ b/tests/src/app/maptooladdfeaturepoint/testqgsmaptooladdfeaturepointzm.cpp @@ -43,8 +43,8 @@ class TestQgsMapToolAddFeaturePointZM : public QObject TestQgsMapToolAddFeaturePointZM(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testPointZM(); @@ -94,7 +94,7 @@ void TestQgsMapToolAddFeaturePointZM::initTestCase() pointFZM.setGeometry( QgsGeometry::fromWkt( pointWktZM ) ); mLayerPointZM->addFeature( pointFZM ); - QCOMPARE( mLayerPointZM->featureCount(), ( long )1 ); + QCOMPARE( mLayerPointZM->featureCount(), ( long ) 1 ); // create the tool mCaptureTool = new QgsMapToolAddFeature( mCanvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CapturePoint ); @@ -126,7 +126,7 @@ void TestQgsMapToolAddFeaturePointZM::testPointZM() utils.mouseClick( 4, 0, Qt::LeftButton, Qt::KeyboardModifiers(), true ); QgsFeatureId newFid = utils.newFeatureId( oldFids ); - QCOMPARE( mLayerPointZM->featureCount(), ( long )2 ); + QCOMPARE( mLayerPointZM->featureCount(), ( long ) 2 ); QString wkt = "Point ZM (4 0 123 333)"; QCOMPARE( mLayerPointZM->getFeature( newFid ).geometry().asWkt(), wkt ); diff --git a/tests/src/app/testqgisapp.cpp b/tests/src/app/testqgisapp.cpp index 40f9c165a0e8..0e3e8e650299 100644 --- a/tests/src/app/testqgisapp.cpp +++ b/tests/src/app/testqgisapp.cpp @@ -33,10 +33,10 @@ class TestQgisApp : public QObject TestQgisApp(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void addVectorLayerShp(); void addVectorLayerGeopackageSingleLayer(); @@ -101,7 +101,7 @@ void TestQgisApp::addVectorLayerShp() QVERIFY( layer->source().endsWith( QLatin1String( "points.shp" ) ) ); // cleanup - QgsProject::instance()->layerStore()->removeMapLayers( QStringList() << layer->id() ); + QgsProject::instance()->layerStore()->removeMapLayers( QStringList() << layer->id() ); } void TestQgisApp::addVectorLayerGeopackageSingleLayer() @@ -114,7 +114,7 @@ void TestQgisApp::addVectorLayerGeopackageSingleLayer() QVERIFY( layer->source().endsWith( QLatin1String( "/vsimem/test.gpkg|layername=my_layer" ) ) ); // cleanup - QgsProject::instance()->layerStore()->removeMapLayers( QStringList() << layer->id() ); + QgsProject::instance()->layerStore()->removeMapLayers( QStringList() << layer->id() ); } void TestQgisApp::addVectorLayerGeopackageSingleLayerAlreadyLayername() @@ -127,7 +127,7 @@ void TestQgisApp::addVectorLayerGeopackageSingleLayerAlreadyLayername() QVERIFY( layer->source().endsWith( QLatin1String( "/vsimem/test.gpkg|layername=my_layer" ) ) ); // cleanup - QgsProject::instance()->layerStore()->removeMapLayers( QStringList() << layer->id() ); + QgsProject::instance()->layerStore()->removeMapLayers( QStringList() << layer->id() ); } void TestQgisApp::addVectorLayerInvalid() @@ -186,6 +186,5 @@ void TestQgisApp::pasteFeature() } - QGSTEST_MAIN( TestQgisApp ) #include "testqgisapp.moc" diff --git a/tests/src/app/testqgisappclipboard.cpp b/tests/src/app/testqgisappclipboard.cpp index 645fbf7ad596..0385e5c5f148 100644 --- a/tests/src/app/testqgisappclipboard.cpp +++ b/tests/src/app/testqgisappclipboard.cpp @@ -46,10 +46,10 @@ class TestQgisAppClipboard : public QObject TestQgisAppClipboard(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void copyPaste(); void copyToText(); @@ -127,7 +127,6 @@ void TestQgisAppClipboard::copyPaste() void TestQgisAppClipboard::copyToText() { - //set clipboard to some QgsFeatures QgsFields fields; fields.append( QgsField( QStringLiteral( "int_field" ), QMetaType::Type::Int ) ); @@ -180,13 +179,13 @@ void TestQgisAppClipboard::copyToText() // GeoJSON settings.setEnumValue( QStringLiteral( "/qgis/copyFeatureFormat" ), QgsClipboard::GeoJSON ); mQgisApp->clipboard()->generateClipboardText( result, resultHtml ); - const QString expected = "{\"features\":[{\"geometry\":{\"coordinates\":[5.0,6.0],\"type\":\"Point\"},\"id\":5," - "\"properties\":{\"double_field\":9.9,\"int_field\":9,\"string_field\":\"val\"},\"type\":\"Feature\"}," - "{\"geometry\":{\"coordinates\":[7.0,8.0],\"type\":\"Point\"},\"id\":6," - "\"properties\":{\"double_field\":19.19,\"int_field\":19,\"string_field\":\"val2\"},\"type\":\"Feature\"}," - "{\"geometry\":{\"coordinates\":[9.0,10.0],\"type\":\"Point\"},\"id\":7," - "\"properties\":{\"double_field\":null,\"int_field\":null,\"string_field\":null},\"type\":\"Feature\"}]," - "\"type\":\"FeatureCollection\"}"; + const QString expected = "{\"features\":[{\"geometry\":{\"coordinates\":[5.0,6.0],\"type\":\"Point\"},\"id\":5," + "\"properties\":{\"double_field\":9.9,\"int_field\":9,\"string_field\":\"val\"},\"type\":\"Feature\"}," + "{\"geometry\":{\"coordinates\":[7.0,8.0],\"type\":\"Point\"},\"id\":6," + "\"properties\":{\"double_field\":19.19,\"int_field\":19,\"string_field\":\"val2\"},\"type\":\"Feature\"}," + "{\"geometry\":{\"coordinates\":[9.0,10.0],\"type\":\"Point\"},\"id\":7," + "\"properties\":{\"double_field\":null,\"int_field\":null,\"string_field\":null},\"type\":\"Feature\"}]," + "\"type\":\"FeatureCollection\"}"; QCOMPARE( result, expected ); // test CRS is transformed correctly for GeoJSON @@ -204,7 +203,7 @@ void TestQgisAppClipboard::copyToText() // just test coordinates as integers - that's enough to verify that reprojection has occurred // and helps avoid rounding issues const thread_local QRegularExpression regex( "\\[([-\\d.]+),([-\\d.]+)\\]" ); - const QRegularExpressionMatch match = regex.match( result ); + const QRegularExpressionMatch match = regex.match( result ); const QStringList list = match.capturedTexts(); QCOMPARE( list.count(), 3 ); @@ -252,7 +251,6 @@ void TestQgisAppClipboard::copyToText() settings.setEnumValue( QStringLiteral( "/qgis/copyFeatureFormat" ), QgsClipboard::AttributesWithWKB ); mQgisApp->clipboard()->generateClipboardText( result, resultHtml ); QCOMPARE( result, QString( "wkb_geom\tint_field\tdouble_field\tstring_field\n010100000000000000000014400000000000001840\t1\t1.1\tSingle line text\n01010000000000000000001c400000000000002040\t2\t2.2\t\"Unix Multiline \nText\"\n010100000000000000000022400000000000002440\t3\t3.3\t\"Windows Multiline \r\nText\"" ) ); - } void TestQgisAppClipboard::copyToTextNoFields() @@ -290,13 +288,12 @@ void TestQgisAppClipboard::copyToTextNoFields() // GeoJSON settings.setEnumValue( QStringLiteral( "/qgis/copyFeatureFormat" ), QgsClipboard::GeoJSON ); mQgisApp->clipboard()->generateClipboardText( result, resultHtml ); - const QString expected = "{\"features\":[{\"geometry\":{\"coordinates\":[5.0,6.0],\"type\":\"Point\"},\"id\":5,\"properties\":null,\"type\":\"Feature\"},{\"geometry\":{\"coordinates\":[7.0,8.0],\"type\":\"Point\"},\"id\":6,\"properties\":null,\"type\":\"Feature\"}],\"type\":\"FeatureCollection\"}"; + const QString expected = "{\"features\":[{\"geometry\":{\"coordinates\":[5.0,6.0],\"type\":\"Point\"},\"id\":5,\"properties\":null,\"type\":\"Feature\"},{\"geometry\":{\"coordinates\":[7.0,8.0],\"type\":\"Point\"},\"id\":6,\"properties\":null,\"type\":\"Feature\"}],\"type\":\"FeatureCollection\"}"; QCOMPARE( result, expected ); } void TestQgisAppClipboard::pasteWkt() { - // test issue GH #44989 QgsFeatureList features = mQgisApp->clipboard()->stringToFeatureList( QStringLiteral( "wkt_geom\tint_field\tstring_field\nPoint (5 6)\t1\tSingle line text\nPoint (7 8)\t2\t\"Unix Multiline \nText\"\nPoint (9 10)\t3\t\"Windows Multiline \r\nText\"" ), QgsFields() ); QCOMPARE( features.length(), 3 ); @@ -317,12 +314,12 @@ void TestQgisAppClipboard::pasteWkt() QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() ); QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); QgsGeometry featureGeom = features.at( 0 ).geometry(); - const QgsPoint *point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + const QgsPoint *point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 125.0 ); QCOMPARE( point->y(), 10.0 ); QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() ); QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); - point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() ); + point = dynamic_cast( features.at( 1 ).geometry().constGet() ); QCOMPARE( point->x(), 111.0 ); QCOMPARE( point->y(), 30.0 ); @@ -337,13 +334,13 @@ void TestQgisAppClipboard::pasteWkt() QVERIFY( !features.at( 0 ).geometry().isNull() ); QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); featureGeom = features.at( 0 ).geometry(); - point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 111.0 ); QCOMPARE( point->y(), 30.0 ); QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() ); QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); - point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() ); + point = dynamic_cast( features.at( 1 ).geometry().constGet() ); QCOMPARE( point->x(), 125.0 ); QCOMPARE( point->y(), 10.0 ); @@ -427,12 +424,12 @@ void TestQgisAppClipboard::pasteWkt() QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() ); QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); featureGeom = features.at( 0 ).geometry(); - point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 125.0 ); QCOMPARE( point->y(), 10.0 ); QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() ); QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); - point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() ); + point = dynamic_cast( features.at( 1 ).geometry().constGet() ); QCOMPARE( point->x(), 111.0 ); QCOMPARE( point->y(), 30.0 ); @@ -444,12 +441,12 @@ void TestQgisAppClipboard::pasteWkt() QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() ); QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); featureGeom = features.at( 0 ).geometry(); - point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 125.0 ); QCOMPARE( point->y(), 10.0 ); QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() ); QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); - point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() ); + point = dynamic_cast( features.at( 1 ).geometry().constGet() ); QCOMPARE( point->x(), 111.0 ); QCOMPARE( point->y(), 30.0 ); } @@ -466,7 +463,7 @@ void TestQgisAppClipboard::pasteGeoJson() QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() ); QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); const QgsGeometry featureGeom = features.at( 0 ).geometry(); - const QgsPoint *point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + const QgsPoint *point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 125.0 ); QCOMPARE( point->y(), 10.0 ); QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) ); @@ -561,7 +558,7 @@ void TestQgisAppClipboard::testVectorTileLayer() ds.setParam( "type", "xyz" ); ds.setParam( "url", QString( "file://%1/{z}-{x}-{y}.pbf" ).arg( dataDir ) ); ds.setParam( "zmax", "1" ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( ds.encodedUri(), "Vector Tiles Test" ); + std::unique_ptr layer = std::make_unique( ds.encodedUri(), "Vector Tiles Test" ); QVERIFY( layer->isValid() ); QgsGeometry selectionGeometry = QgsGeometry::fromWkt( QStringLiteral( "Polygon ((13934091.75684908032417297 -1102962.40819426625967026, 11360512.80439674854278564 -2500048.12523981928825378, 12316413.55816475301980972 -5661873.69539554417133331, 16948855.67257896065711975 -6617774.44916355609893799, 18125348.90798573195934296 -2058863.16196227818727493, 15257646.64668171107769012 -735308.27212964743375778, 13934091.75684908032417297 -1102962.40819426625967026))" ) ); @@ -570,7 +567,7 @@ void TestQgisAppClipboard::testVectorTileLayer() layer->selectByGeometry( selectionGeometry, context, Qgis::SelectBehavior::SetSelection, Qgis::SelectGeometryRelationship::Intersect ); QCOMPARE( layer->selectedFeatureCount(), 4 ); - const QList< QgsFeature > features = layer->selectedFeatures(); + const QList features = layer->selectedFeatures(); mQgisApp->clipboard()->replaceWithCopyOf( layer.get() ); @@ -583,7 +580,7 @@ void TestQgisAppClipboard::testVectorTileLayer() QgsFeatureId maritimeId = -1; QgsFeatureId oceanId = -1; - for ( const QgsFeature &feature : features ) + for ( const QgsFeature &feature : features ) { if ( feature.fields().lookupField( QStringLiteral( "maritime" ) ) > -1 ) maritimeId = feature.id(); diff --git a/tests/src/app/testqgisappdockwidgets.cpp b/tests/src/app/testqgisappdockwidgets.cpp index 07d1c3bd715d..28fc31924b4d 100644 --- a/tests/src/app/testqgisappdockwidgets.cpp +++ b/tests/src/app/testqgisappdockwidgets.cpp @@ -38,10 +38,10 @@ class TestQgisAppDockWidgets : public QObject TestQgisAppDockWidgets(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void tabifiedQDockWidgetEmptyArea(); void tabifiedQgsDockWidgetEmptyArea(); @@ -155,7 +155,7 @@ void TestQgisAppDockWidgets::tabifiedQDockWidgetOneExisting() QVERIFY( dw->isVisible() ); // Check our dock widget is tabified - const QList< QDockWidget *> tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); + const QList tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); QCOMPARE( tdw.length(), 1 ); QCOMPARE( tdw.at( 0 ), dw ); @@ -210,7 +210,7 @@ void TestQgisAppDockWidgets::tabifiedQDockWidgetOneExistingRaiseTab() QVERIFY( dw->isVisible() ); // Check our dock widget is tabified - const QList< QDockWidget *> tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); + const QList tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); QCOMPARE( tdw.length(), 1 ); QCOMPARE( tdw.at( 0 ), dw ); @@ -265,7 +265,7 @@ void TestQgisAppDockWidgets::tabifiedQgsDockWidgetOneExisting() QVERIFY( dw->isVisible() ); // Check our dock widget is tabified - const QList< QDockWidget *> tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); + const QList tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); QCOMPARE( tdw.length(), 1 ); QCOMPARE( tdw.at( 0 ), dw ); @@ -320,7 +320,7 @@ void TestQgisAppDockWidgets::tabifiedQgsDockWidgetOneExistingRaiseTab() QVERIFY( dw->isVisible() ); // Check our dock widget is tabified - const QList< QDockWidget *> tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); + const QList tdw = mQgisApp->tabifiedDockWidgets( mLayerTreeDock ); QCOMPARE( tdw.length(), 1 ); QCOMPARE( tdw.at( 0 ), dw ); @@ -558,7 +558,7 @@ void TestQgisAppDockWidgets::tabifiedQDockWidgetTwoExistingOneHidden() QgsDockWidget *mLayerTreeDock = new QgsDockWidget( tr( "Layers" ), mQgisApp ); mLayerTreeDock->setObjectName( objectName1 ); mQgisApp->addDockWidget( area, mLayerTreeDock ); - mLayerTreeDock->hide(); // This one will be hidden + mLayerTreeDock->hide(); // This one will be hidden QVERIFY( !mLayerTreeDock->isVisible() ); QgsDockWidget *mLayerOrderDock = new QgsDockWidget( tr( "Layer Order" ), mQgisApp ); mLayerOrderDock->setObjectName( objectName2 ); @@ -630,7 +630,7 @@ void TestQgisAppDockWidgets::tabifiedQDockWidgetTwoExistingOneHiddenRaiseTab() QgsDockWidget *mLayerTreeDock = new QgsDockWidget( tr( "Layers" ), mQgisApp ); mLayerTreeDock->setObjectName( objectName1 ); mQgisApp->addDockWidget( area, mLayerTreeDock ); - mLayerTreeDock->hide(); // This one will be hidden + mLayerTreeDock->hide(); // This one will be hidden QVERIFY( !mLayerTreeDock->isVisible() ); QgsDockWidget *mLayerOrderDock = new QgsDockWidget( tr( "Layer Order" ), mQgisApp ); mLayerOrderDock->setObjectName( objectName2 ); diff --git a/tests/src/app/testqgisapppython.cpp b/tests/src/app/testqgisapppython.cpp index 35e565c027c3..4ebc85da6e58 100644 --- a/tests/src/app/testqgisapppython.cpp +++ b/tests/src/app/testqgisapppython.cpp @@ -35,10 +35,10 @@ class TestQgisAppPython : public QObject TestQgisAppPython(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void hasPython(); void plugins(); diff --git a/tests/src/app/testqgsadvanceddigitizing.cpp b/tests/src/app/testqgsadvanceddigitizing.cpp index b4519aa67d41..00e76a033928 100644 --- a/tests/src/app/testqgsadvanceddigitizing.cpp +++ b/tests/src/app/testqgsadvanceddigitizing.cpp @@ -26,14 +26,14 @@ #include "testqgsmaptoolutils.h" -class TestQgsAdvancedDigitizing: public QObject +class TestQgsAdvancedDigitizing : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void distanceConstraint(); void distanceConstraintDiffCrs(); @@ -94,23 +94,19 @@ void TestQgsAdvancedDigitizing::initTestCase() // make test layers QList layers; - mLayer3950 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:3950" ), - QStringLiteral( "line layer" ), QStringLiteral( "memory" ) ); + mLayer3950 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:3950" ), QStringLiteral( "line layer" ), QStringLiteral( "memory" ) ); QVERIFY( mLayer3950->isValid() ); layers << mLayer3950; - mLayer3950ZM = new QgsVectorLayer( QStringLiteral( "LineStringZM?crs=EPSG:3950" ), - QStringLiteral( "ZM line layer" ), QStringLiteral( "memory" ) ); + mLayer3950ZM = new QgsVectorLayer( QStringLiteral( "LineStringZM?crs=EPSG:3950" ), QStringLiteral( "ZM line layer" ), QStringLiteral( "memory" ) ); QVERIFY( mLayer3950ZM->isValid() ); layers << mLayer3950ZM; - mLayer4326 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:4326" ), - QStringLiteral( "line layer diff crs" ), QStringLiteral( "memory" ) ); + mLayer4326 = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:4326" ), QStringLiteral( "line layer diff crs" ), QStringLiteral( "memory" ) ); QVERIFY( mLayer4326->isValid() ); layers << mLayer4326; - mLayer4326ZM = new QgsVectorLayer( QStringLiteral( "LineStringZM?crs=EPSG:4326" ), - QStringLiteral( "ZM line layer diff crs" ), QStringLiteral( "memory" ) ); + mLayer4326ZM = new QgsVectorLayer( QStringLiteral( "LineStringZM?crs=EPSG:4326" ), QStringLiteral( "ZM line layer diff crs" ), QStringLiteral( "memory" ) ); QVERIFY( mLayer4326ZM->isValid() ); layers << mLayer4326ZM; @@ -120,7 +116,7 @@ void TestQgsAdvancedDigitizing::initTestCase() mCanvas->setCurrentLayer( mLayer3950 ); // create advanced digitizing dock widget - mAdvancedDigitizingDockWidget = new QgsAdvancedDigitizingDockWidget( mCanvas ); + mAdvancedDigitizingDockWidget = new QgsAdvancedDigitizingDockWidget( mCanvas ); // create snapping config QgsSnappingConfig snapConfig; @@ -211,8 +207,7 @@ QString TestQgsAdvancedDigitizing::getWktFromLastAddedFeature( TestQgsMapToolAdv QgsGeometry geom = layer->getFeature( newFid ).geometry(); // transform the coordinates when canvas CRS and layer CRS are different - const QgsCoordinateTransform transform( layer->sourceCrs(), mCanvas->mapSettings().destinationCrs(), - QgsProject::instance() ); + const QgsCoordinateTransform transform( layer->sourceCrs(), mCanvas->mapSettings().destinationCrs(), QgsProject::instance() ); geom.transform( transform, Qgis::TransformDirection::Forward ); return geom.asWkt( WKT_PRECISION ); @@ -251,14 +246,12 @@ void TestQgsAdvancedDigitizing::distanceConstraint() capacities = mAdvancedDigitizingDockWidget->capacities(); QVERIFY( capacities.testFlag( QgsAdvancedDigitizingDockWidget::Distance ) ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 2, 2, Qt::LeftButton ); utils.mouseClick( 1, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 8.07 8.07)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 8.07 8.07)" ) ); // activate constraint on the third point oldFeatures = utils.existingFeatureIds(); @@ -266,14 +259,12 @@ void TestQgsAdvancedDigitizing::distanceConstraint() utils.mouseClick( 1, 1, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 3, 2, Qt::LeftButton ); utils.mouseClick( 1, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 2 2, 7 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 2 2, 7 2)" ) ); capacities = mAdvancedDigitizingDockWidget->capacities(); QVERIFY( !capacities.testFlag( QgsAdvancedDigitizingDockWidget::Distance ) ); @@ -288,14 +279,12 @@ void TestQgsAdvancedDigitizing::distanceConstraintDiffCrs() utils.mouseClick( 1, 1, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 2, 2, Qt::LeftButton ); utils.mouseClick( 1, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 8.07 8.07)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 8.07 8.07)" ) ); // activate constraint on third point oldFeatures = utils.existingFeatureIds(); @@ -303,14 +292,12 @@ void TestQgsAdvancedDigitizing::distanceConstraintDiffCrs() utils.mouseClick( 1, 1, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 3, 2, Qt::LeftButton ); utils.mouseClick( 1, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 2 2, 7 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 2 2, 7 2)" ) ); } void TestQgsAdvancedDigitizing::distanceConstraintWhenSnapping() @@ -325,8 +312,7 @@ void TestQgsAdvancedDigitizing::distanceConstraintWhenSnapping() utils.mouseClick( 2, 2, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 2 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 2 2)" ) ); oldFeatures = utils.existingFeatureIds(); // with no digitized vertex @@ -342,14 +328,12 @@ void TestQgsAdvancedDigitizing::distanceConstraintWhenSnapping() capacities = mAdvancedDigitizingDockWidget->capacities(); QVERIFY( capacities.testFlag( QgsAdvancedDigitizingDockWidget::Distance ) ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 2, 2, Qt::LeftButton ); utils.mouseClick( 1, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 8.07 8.07)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 8.07 8.07)" ) ); // activate constraint on the third point oldFeatures = utils.existingFeatureIds(); @@ -357,14 +341,12 @@ void TestQgsAdvancedDigitizing::distanceConstraintWhenSnapping() utils.mouseClick( 1, 1, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 3, 2, Qt::LeftButton ); utils.mouseClick( 1, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 2 2, 7 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 2 2, 7 2)" ) ); capacities = mAdvancedDigitizingDockWidget->capacities(); QVERIFY( !capacities.testFlag( QgsAdvancedDigitizingDockWidget::Distance ) ); @@ -387,41 +369,35 @@ void TestQgsAdvancedDigitizing::angleConstraint() capacities = mAdvancedDigitizingDockWidget->capacities(); QVERIFY( capacities.testFlag( QgsAdvancedDigitizingDockWidget::AbsoluteAngle ) ); - mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "90" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "90" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 2, 2, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 1 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 1 2)" ) ); // and in the other side oldFeatures = utils.existingFeatureIds(); utils.mouseClick( 1, 1, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "90" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "90" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 2, -2, Qt::LeftButton ); utils.mouseClick( 2, -2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 1 -2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 1 -2)" ) ); // try with an angle of 45° oldFeatures = utils.existingFeatureIds(); utils.mouseClick( 0, 0, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "45" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "45" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 0, 2, Qt::LeftButton ); utils.mouseClick( 0, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 1 1)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 1 1)" ) ); } void TestQgsAdvancedDigitizing::angleConstraintWithGeographicCrs() @@ -448,15 +424,13 @@ void TestQgsAdvancedDigitizing::angleConstraintWithGeographicCrs() // constraint angle can be forced even with geographical // should be normal ? - mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "90" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "90" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); QVERIFY( mAdvancedDigitizingDockWidget->constraintAngle()->isLocked() ); utils.mouseClick( 2, 2, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 1 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 1 2)" ) ); setCanvasCrs( QStringLiteral( "EPSG:3950" ) ); } @@ -472,32 +446,26 @@ void TestQgsAdvancedDigitizing::distanceConstraintWithAngleConstraint() // first utils.mouseClick( 0, 0, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); - mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "45" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "45" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 0, 2, Qt::LeftButton ); utils.mouseClick( 0, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 7.07 7.07)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 7.07 7.07)" ) ); // second oldFeatures = utils.existingFeatureIds(); utils.mouseClick( 0, 0, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); - mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "45" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setDistance( QStringLiteral( "10" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setAngle( QStringLiteral( "45" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( -1000, 59, Qt::LeftButton ); utils.mouseClick( 0, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, -7.07 -7.07)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, -7.07 -7.07)" ) ); } @@ -508,39 +476,31 @@ void TestQgsAdvancedDigitizing::coordinateConstraint() QVERIFY( mAdvancedDigitizingDockWidget->cadEnabled() ); - mAdvancedDigitizingDockWidget->setX( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setX( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 0, 0, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setY( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setY( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 3, 9, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setX( QStringLiteral( "6" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); - mAdvancedDigitizingDockWidget->setY( QStringLiteral( "7" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setX( QStringLiteral( "6" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setY( QStringLiteral( "7" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 0, 0, Qt::LeftButton ); utils.mouseClick( 0, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (5 0, 3 5, 6 7)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (5 0, 3 5, 6 7)" ) ); // set Z/M constraints should have no effect oldFeatures = utils.existingFeatureIds(); utils.mouseClick( 0, 0, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setZ( QStringLiteral( "3" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); - mAdvancedDigitizingDockWidget->setM( QStringLiteral( "3" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setZ( QStringLiteral( "3" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setM( QStringLiteral( "3" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 0, 2, Qt::LeftButton ); utils.mouseClick( 0, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 0 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 0 2)" ) ); } @@ -551,36 +511,27 @@ void TestQgsAdvancedDigitizing::coordinateConstraintWithZM() QVERIFY( mAdvancedDigitizingDockWidget->cadEnabled() ); - mAdvancedDigitizingDockWidget->setX( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setX( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 0, 0, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setY( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setY( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 3, 9, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setZ( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setZ( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 4, 4, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setM( QStringLiteral( "5" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setM( QStringLiteral( "5" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 6, 6, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setX( QStringLiteral( "9" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); - mAdvancedDigitizingDockWidget->setY( QStringLiteral( "9" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); - mAdvancedDigitizingDockWidget->setZ( QStringLiteral( "9" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); - mAdvancedDigitizingDockWidget->setM( QStringLiteral( "9" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setX( QStringLiteral( "9" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setY( QStringLiteral( "9" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setZ( QStringLiteral( "9" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setM( QStringLiteral( "9" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 0, 0, Qt::LeftButton ); utils.mouseClick( 0, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString ZM (5 0 33 66, 3 5 33 66, 4 4 5 66, 6 6 33 5, 9 9 9 9)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString ZM (5 0 33 66, 3 5 33 66, 4 4 5 66, 6 6 33 5, 9 9 9 9)" ) ); } void TestQgsAdvancedDigitizing::coordinateConstraintWhenSnapping() @@ -596,8 +547,7 @@ void TestQgsAdvancedDigitizing::coordinateConstraintWhenSnapping() utils.mouseClick( 2, 2, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (1 1, 2 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (1 1, 2 2)" ) ); oldFeatures = utils.existingFeatureIds(); @@ -620,20 +570,17 @@ void TestQgsAdvancedDigitizing::coordinateConstraintWhenSnapping() utils.mouseClick( 2.02, 2, Qt::LeftButton ); utils.mouseClick( 2, 2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 2, 2 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 2, 2 2)" ) ); oldFeatures = utils.existingFeatureIds(); utils.mouseClick( 0, -2, Qt::LeftButton ); - mAdvancedDigitizingDockWidget->setX( QStringLiteral( "0" ), - QgsAdvancedDigitizingDockWidget::ReturnPressed ); + mAdvancedDigitizingDockWidget->setX( QStringLiteral( "0" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); utils.mouseClick( 2.02, 2, Qt::LeftButton ); // shouldn't snap to (2 2) utils.mouseClick( -2, -2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 -2, 0 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 -2, 0 2)" ) ); oldFeatures = utils.existingFeatureIds(); @@ -644,8 +591,7 @@ void TestQgsAdvancedDigitizing::coordinateConstraintWhenSnapping() utils.mouseClick( 0, 2, Qt::LeftButton ); utils.mouseClick( -2, -2, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 -2, 2.02 2)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 -2, 2.02 2)" ) ); } void TestQgsAdvancedDigitizing::perpendicularConstraint() @@ -658,8 +604,7 @@ void TestQgsAdvancedDigitizing::perpendicularConstraint() utils.mouseClick( 0, 0, Qt::LeftButton ); utils.mouseClick( 0, 10, Qt::LeftButton ); utils.mouseClick( 1, 1, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 0 10)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 0 10)" ) ); QgsSnappingConfig snapConfig = mCanvas->snappingUtils()->config(); snapConfig.setEnabled( true ); @@ -670,15 +615,13 @@ void TestQgsAdvancedDigitizing::perpendicularConstraint() utils.mouseMove( 0.1, 4 ); QCOMPARE( mAdvancedDigitizingDockWidget->currentPointV2(), QgsPoint( 0, 4 ) ); - QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), - Qgis::BetweenLineConstraint::NoConstraint ); + QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), Qgis::BetweenLineConstraint::NoConstraint ); // digitizing a first vertex utils.mouseClick( 5, 5, Qt::LeftButton ); mAdvancedDigitizingDockWidget->lockBetweenLineConstraint( Qgis::BetweenLineConstraint::Perpendicular ); - QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), - Qgis::BetweenLineConstraint::Perpendicular ); + QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), Qgis::BetweenLineConstraint::Perpendicular ); // select the previous digitized line utils.mouseClick( 0.1, 4, Qt::LeftButton ); @@ -700,8 +643,7 @@ void TestQgsAdvancedDigitizing::xyExtensionConstraint() utils.mouseClick( 0, 0, Qt::LeftButton ); utils.mouseClick( 10, 10, Qt::LeftButton ); utils.mouseClick( 1, 1, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 10 10)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 10 10)" ) ); QgsSnappingConfig snapConfig = mCanvas->snappingUtils()->config(); snapConfig.setEnabled( true ); @@ -713,13 +655,11 @@ void TestQgsAdvancedDigitizing::xyExtensionConstraint() QCOMPARE( mAdvancedDigitizingDockWidget->currentPointV2(), QgsPoint( 5, 5 ) ); // activate xy extension constraint - QCOMPARE( mAdvancedDigitizingDockWidget->mXyVertexConstraint->lockMode(), - QgsAdvancedDigitizingDockWidget::CadConstraint::NoLock ); + QCOMPARE( mAdvancedDigitizingDockWidget->mXyVertexConstraint->lockMode(), QgsAdvancedDigitizingDockWidget::CadConstraint::NoLock ); mAdvancedDigitizingDockWidget->mXyVertexAction->trigger(); - QCOMPARE( mAdvancedDigitizingDockWidget->mXyVertexConstraint->lockMode(), - QgsAdvancedDigitizingDockWidget::CadConstraint::SoftLock ); + QCOMPARE( mAdvancedDigitizingDockWidget->mXyVertexConstraint->lockMode(), QgsAdvancedDigitizingDockWidget::CadConstraint::SoftLock ); QCOMPARE( mAdvancedDigitizingDockWidget->mLockedSnapVertices.size(), 0 ); @@ -756,8 +696,7 @@ void TestQgsAdvancedDigitizing::lineExtensionConstraint() utils.mouseClick( 0, 0, Qt::LeftButton ); utils.mouseClick( 10, 10, Qt::LeftButton ); utils.mouseClick( 1, 1, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 10 10)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 10 10)" ) ); QgsSnappingConfig snapConfig = mCanvas->snappingUtils()->config(); snapConfig.setEnabled( true ); @@ -769,13 +708,11 @@ void TestQgsAdvancedDigitizing::lineExtensionConstraint() QCOMPARE( mAdvancedDigitizingDockWidget->currentPointV2(), QgsPoint( 5, 5 ) ); // activate xy extension constraint - QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), - QgsAdvancedDigitizingDockWidget::CadConstraint::NoLock ); + QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), QgsAdvancedDigitizingDockWidget::CadConstraint::NoLock ); mAdvancedDigitizingDockWidget->mLineExtensionAction->trigger(); - QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), - QgsAdvancedDigitizingDockWidget::CadConstraint::SoftLock ); + QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), QgsAdvancedDigitizingDockWidget::CadConstraint::SoftLock ); QCOMPARE( mAdvancedDigitizingDockWidget->mLockedSnapVertices.size(), 0 ); @@ -807,8 +744,7 @@ void TestQgsAdvancedDigitizing::lineExtensionConstraintGeographicCrs() utils.mouseClick( 0, 0, Qt::LeftButton ); utils.mouseClick( 10, 10, Qt::LeftButton ); utils.mouseClick( 1, 1, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 10 10)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 10 10)" ) ); QgsSnappingConfig snapConfig = mCanvas->snappingUtils()->config(); snapConfig.setEnabled( true ); @@ -829,13 +765,11 @@ void TestQgsAdvancedDigitizing::lineExtensionConstraintGeographicCrs() QCOMPARE( mAdvancedDigitizingDockWidget->currentPointV2(), QgsPoint( 5, 5 ) ); // activate xy extension constraint - QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), - QgsAdvancedDigitizingDockWidget::CadConstraint::NoLock ); + QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), QgsAdvancedDigitizingDockWidget::CadConstraint::NoLock ); mAdvancedDigitizingDockWidget->mLineExtensionAction->trigger(); - QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), - QgsAdvancedDigitizingDockWidget::CadConstraint::SoftLock ); + QCOMPARE( mAdvancedDigitizingDockWidget->mLineExtensionConstraint->lockMode(), QgsAdvancedDigitizingDockWidget::CadConstraint::SoftLock ); QCOMPARE( mAdvancedDigitizingDockWidget->mLockedSnapVertices.size(), 0 ); @@ -885,8 +819,7 @@ void TestQgsAdvancedDigitizing::cadPointList() QCOMPARE( mAdvancedDigitizingDockWidget->pointsCount(), 6 ); utils.mouseClick( 1, 1, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 0 1, 0 2, 0 3, 0 4)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 0 1, 0 2, 0 3, 0 4)" ) ); utils.mouseMove( 1, 1 ); @@ -894,10 +827,10 @@ void TestQgsAdvancedDigitizing::cadPointList() QCOMPARE( mAdvancedDigitizingDockWidget->currentPointV2( &exist ), QgsPoint( 1, 1 ) ); QVERIFY( exist ); - QCOMPARE( mAdvancedDigitizingDockWidget->previousPointV2( &exist ), QgsPoint( ) ); + QCOMPARE( mAdvancedDigitizingDockWidget->previousPointV2( &exist ), QgsPoint() ); QVERIFY( !exist ); - QCOMPARE( mAdvancedDigitizingDockWidget->penultimatePointV2( &exist ), QgsPoint( ) ); + QCOMPARE( mAdvancedDigitizingDockWidget->penultimatePointV2( &exist ), QgsPoint() ); QVERIFY( !exist ); QCOMPARE( mAdvancedDigitizingDockWidget->pointsCount(), 1 ); @@ -917,8 +850,7 @@ void TestQgsAdvancedDigitizing::lockedSnapVertices() utils.mouseClick( 0, 4, Qt::LeftButton ); utils.mouseClick( 0, 4, Qt::RightButton ); - QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), - QStringLiteral( "LineString (0 0, 0 1, 0 2, 0 3, 0 4)" ) ); + QCOMPARE( getWktFromLastAddedFeature( utils, oldFeatures ), QStringLiteral( "LineString (0 0, 0 1, 0 2, 0 3, 0 4)" ) ); QgsSnappingConfig snapConfig = mCanvas->snappingUtils()->config(); snapConfig.setEnabled( true ); @@ -969,8 +901,8 @@ void TestQgsAdvancedDigitizing::lockedSnapVertices() // this shouldn't reset lockedSnapVertices QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().size(), 3 ); -// QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().last().point(), QgsPointXY( 0, 4 ) ); -// QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().first().point(), QgsPointXY( 0, 2 ) ); + // QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().last().point(), QgsPointXY( 0, 4 ) ); + // QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().first().point(), QgsPointXY( 0, 2 ) ); // disable line extension constraint mAdvancedDigitizingDockWidget->mXyVertexAction->trigger(); @@ -979,8 +911,8 @@ void TestQgsAdvancedDigitizing::lockedSnapVertices() // this shouldn't reset lockedSnapVertices QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().size(), 3 ); -// QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().last().point(), QgsPointXY( 0, 4 ) ); -// QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().first().point(), QgsPointXY( 0, 2 ) ); + // QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().last().point(), QgsPointXY( 0, 4 ) ); + // QCOMPARE( mAdvancedDigitizingDockWidget->lockedSnapVertices().first().point(), QgsPointXY( 0, 2 ) ); // stops digitizing utils.mouseClick( 10, 2, Qt::RightButton ); @@ -1093,8 +1025,7 @@ void TestQgsAdvancedDigitizing::releaseLockAfterDisable() QVERIFY( mAdvancedDigitizingDockWidget->cadEnabled() ); - QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), - Qgis::BetweenLineConstraint::NoConstraint ); + QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), Qgis::BetweenLineConstraint::NoConstraint ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintAngle()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintDistance()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintX()->isLocked() ); @@ -1113,8 +1044,7 @@ void TestQgsAdvancedDigitizing::releaseLockAfterDisable() mAdvancedDigitizingDockWidget->setM( QStringLiteral( "0" ), QgsAdvancedDigitizingDockWidget::ReturnPressed ); - QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), - Qgis::BetweenLineConstraint::NoConstraint ); + QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), Qgis::BetweenLineConstraint::NoConstraint ); QVERIFY( mAdvancedDigitizingDockWidget->constraintAngle()->isLocked() ); QVERIFY( mAdvancedDigitizingDockWidget->constraintDistance()->isLocked() ); QVERIFY( mAdvancedDigitizingDockWidget->constraintX()->isLocked() ); @@ -1130,8 +1060,7 @@ void TestQgsAdvancedDigitizing::releaseLockAfterDisable() QVERIFY( !mAdvancedDigitizingDockWidget->cadEnabled() ); // all constraints should be deactivated - QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), - Qgis::BetweenLineConstraint::NoConstraint ); + QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), Qgis::BetweenLineConstraint::NoConstraint ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintAngle()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintDistance()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintX()->isLocked() ); @@ -1151,8 +1080,7 @@ void TestQgsAdvancedDigitizing::releaseLockAfterDisable() QVERIFY( mAdvancedDigitizingDockWidget->cadEnabled() ); - QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), - Qgis::BetweenLineConstraint::Perpendicular ); + QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), Qgis::BetweenLineConstraint::Perpendicular ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintAngle()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintDistance()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintX()->isLocked() ); @@ -1168,8 +1096,7 @@ void TestQgsAdvancedDigitizing::releaseLockAfterDisable() QVERIFY( !mAdvancedDigitizingDockWidget->cadEnabled() ); // all constraints should be deactivated - QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), - Qgis::BetweenLineConstraint::NoConstraint ); + QCOMPARE( mAdvancedDigitizingDockWidget->betweenLineConstraint(), Qgis::BetweenLineConstraint::NoConstraint ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintAngle()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintDistance()->isLocked() ); QVERIFY( !mAdvancedDigitizingDockWidget->constraintX()->isLocked() ); diff --git a/tests/src/app/testqgsappbrowserproviders.cpp b/tests/src/app/testqgsappbrowserproviders.cpp index 8a0be5dd104e..e9e717c7f369 100644 --- a/tests/src/app/testqgsappbrowserproviders.cpp +++ b/tests/src/app/testqgsappbrowserproviders.cpp @@ -36,10 +36,10 @@ class TestQgsAppBrowserProviders : public QObject TestQgsAppBrowserProviders(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testProjectItemCreation(); @@ -106,24 +106,24 @@ void TestQgsAppBrowserProviders::testProjectItemCreation() child->populate( true ); QCOMPARE( child->children().count(), 9 ); - QVERIFY( dynamic_cast< QgsProjectLayerTreeGroupItem * >( child->children().at( 4 ) ) ); + QVERIFY( dynamic_cast( child->children().at( 4 ) ) ); QCOMPARE( child->children().at( 4 )->name(), QStringLiteral( "groupwithoutshortname" ) ); QCOMPARE( child->children().at( 4 )->children().count(), 1 ); - QVERIFY( dynamic_cast< QgsLayerItem * >( child->children().at( 4 )->children().at( 0 ) ) ); + QVERIFY( dynamic_cast( child->children().at( 4 )->children().at( 0 ) ) ); QCOMPARE( child->children().at( 4 )->children().at( 0 )->name(), QStringLiteral( "testlayer3" ) ); - QVERIFY( dynamic_cast< QgsProjectLayerTreeGroupItem * >( child->children().at( 5 ) ) ); + QVERIFY( dynamic_cast( child->children().at( 5 ) ) ); QCOMPARE( child->children().at( 5 )->name(), QStringLiteral( "groupwithshortname" ) ); QCOMPARE( child->children().at( 5 )->children().count(), 1 ); - QVERIFY( dynamic_cast< QgsLayerItem * >( child->children().at( 5 )->children().at( 0 ) ) ); + QVERIFY( dynamic_cast( child->children().at( 5 )->children().at( 0 ) ) ); QCOMPARE( child->children().at( 5 )->children().at( 0 )->name(), QStringLiteral( "testlayer2" ) ); - QVERIFY( dynamic_cast< QgsLayerItem * >( child->children().at( 7 ) ) ); + QVERIFY( dynamic_cast( child->children().at( 7 ) ) ); QCOMPARE( child->children().at( 7 )->name(), QStringLiteral( "testlayer" ) ); - QVERIFY( dynamic_cast< QgsLayerItem * >( child->children().at( 8 ) ) ); + QVERIFY( dynamic_cast( child->children().at( 8 ) ) ); QCOMPARE( child->children().at( 8 )->name(), QStringLiteral( u"testlayer \u00E8\u00E9" ) ); delete dirItem; diff --git a/tests/src/app/testqgsapplayoutvaliditychecks.cpp b/tests/src/app/testqgsapplayoutvaliditychecks.cpp index f7d83f6e14e9..195578ce9800 100644 --- a/tests/src/app/testqgsapplayoutvaliditychecks.cpp +++ b/tests/src/app/testqgsapplayoutvaliditychecks.cpp @@ -40,10 +40,10 @@ class TestQgsLayoutValidityChecks : public QObject TestQgsLayoutValidityChecks(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testScaleBarValidity(); void testNorthArrowValidity(); @@ -89,7 +89,7 @@ void TestQgsLayoutValidityChecks::testScaleBarValidity() // scalebar not linked to map QgsLayoutScaleBarValidityCheck check; QVERIFY( check.prepareCheck( &context, &f ) ); - QList< QgsValidityCheckResult > res = check.runCheck( &context, &f ); + QList res = check.runCheck( &context, &f ); QCOMPARE( res.size(), 1 ); QCOMPARE( res.at( 0 ).type, QgsValidityCheckResult::Warning ); @@ -121,7 +121,7 @@ void TestQgsLayoutValidityChecks::testNorthArrowValidity() // scalebar not linked to map QgsLayoutNorthArrowValidityCheck check; QVERIFY( check.prepareCheck( &context, &f ) ); - QList< QgsValidityCheckResult > res = check.runCheck( &context, &f ); + QList res = check.runCheck( &context, &f ); QCOMPARE( res.size(), 1 ); QCOMPARE( res.at( 0 ).type, QgsValidityCheckResult::Warning ); @@ -168,7 +168,7 @@ void TestQgsLayoutValidityChecks::testOverviewValidity() // no overviews QgsLayoutOverviewValidityCheck check; QVERIFY( check.prepareCheck( &context, &f ) ); - QList< QgsValidityCheckResult > res = check.runCheck( &context, &f ); + QList res = check.runCheck( &context, &f ); QCOMPARE( res.size(), 0 ); // overview not linked to map @@ -226,7 +226,7 @@ void TestQgsLayoutValidityChecks::testPictureValidity() picture->setPicturePath( QStringLiteral( "blaaaaaaaaaaaaaaaaah" ) ); QgsLayoutPictureSourceValidityCheck check; QVERIFY( check.prepareCheck( &context, &f ) ); - QList< QgsValidityCheckResult > res = check.runCheck( &context, &f ); + QList res = check.runCheck( &context, &f ); QCOMPARE( res.size(), 1 ); QCOMPARE( res.at( 0 ).type, QgsValidityCheckResult::Warning ); @@ -269,6 +269,5 @@ void TestQgsLayoutValidityChecks::testPictureValidity() } - QGSTEST_MAIN( TestQgsLayoutValidityChecks ) #include "testqgsapplayoutvaliditychecks.moc" diff --git a/tests/src/app/testqgsapplocatorfilters.cpp b/tests/src/app/testqgsapplocatorfilters.cpp index 952dee23e275..5a243d8ce0ac 100644 --- a/tests/src/app/testqgsapplocatorfilters.cpp +++ b/tests/src/app/testqgsapplocatorfilters.cpp @@ -41,8 +41,8 @@ class TestQgsAppLocatorFilters : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testCalculator(); void testLayers(); void testLayouts(); @@ -56,7 +56,7 @@ class TestQgsAppLocatorFilters : public QObject private: QgisApp *mQgisApp = nullptr; - QList< QgsLocatorResult > gatherResults( QgsLocatorFilter *filter, const QString &string, const QgsLocatorContext &context ); + QList gatherResults( QgsLocatorFilter *filter, const QString &string, const QgsLocatorContext &context ); }; //runs before all tests @@ -79,7 +79,7 @@ void TestQgsAppLocatorFilters::testCalculator() QgsExpressionCalculatorLocatorFilter filter; // valid expression - QList< QgsLocatorResult > results = gatherResults( &filter, QStringLiteral( "1+2" ), QgsLocatorContext() ); + QList results = gatherResults( &filter, QStringLiteral( "1+2" ), QgsLocatorContext() ); QCOMPARE( results.count(), 1 ); QCOMPARE( results.at( 0 ).userData().toInt(), 3 ); @@ -97,11 +97,11 @@ void TestQgsAppLocatorFilters::testLayers() QgsVectorLayer *l1 = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "aaaaa" ), QStringLiteral( "memory" ) ); QgsVectorLayer *l2 = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "abc" ), QStringLiteral( "memory" ) ); QgsVectorLayer *l3 = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "ccccc" ), QStringLiteral( "memory" ) ); - QgsProject::instance()->addMapLayers( QList< QgsMapLayer *>() << l1 << l2 << l3 ); + QgsProject::instance()->addMapLayers( QList() << l1 << l2 << l3 ); QgsLayerTreeLocatorFilter filter; - QList< QgsLocatorResult > results = gatherResults( &filter, QStringLiteral( "xxxxx" ), QgsLocatorContext() ); + QList results = gatherResults( &filter, QStringLiteral( "xxxxx" ), QgsLocatorContext() ); QCOMPARE( results.count(), 0 ); results = gatherResults( &filter, QStringLiteral( "aa" ), QgsLocatorContext() ); @@ -139,7 +139,7 @@ void TestQgsAppLocatorFilters::testLayouts() QgsLayoutLocatorFilter filter; - QList< QgsLocatorResult > results = gatherResults( &filter, QStringLiteral( "xxxxx" ), QgsLocatorContext() ); + QList results = gatherResults( &filter, QStringLiteral( "xxxxx" ), QgsLocatorContext() ); QCOMPARE( results.count(), 0 ); results = gatherResults( &filter, QStringLiteral( "aa" ), QgsLocatorContext() ); @@ -183,7 +183,7 @@ void TestQgsAppLocatorFilters::testSearchActiveLayer() QgsActiveLayerFeaturesLocatorFilter filter; const QgsLocatorContext context; - QList< QgsLocatorResult > results = gatherResults( &filter, QStringLiteral( "12345.6789" ), context ); + QList results = gatherResults( &filter, QStringLiteral( "12345.6789" ), context ); QCOMPARE( results.count(), 1 ); results = gatherResults( &filter, QStringLiteral( "12345.67" ), context ); @@ -272,7 +272,7 @@ void TestQgsAppLocatorFilters::testSearchAllLayers() QgsVectorLayer *l1 = new QgsVectorLayer( layerDef, QStringLiteral( "Layer 1" ), QStringLiteral( "memory" ) ); QgsVectorLayer *l2 = new QgsVectorLayer( layerDef, QStringLiteral( "Layer 2" ), QStringLiteral( "memory" ) ); - QgsProject::instance()->addMapLayers( QList< QgsMapLayer *>() << l1 << l2 ); + QgsProject::instance()->addMapLayers( QList() << l1 << l2 ); QgsFeature f1; f1.setAttributes( QVector() << 1001 << "A nice feature" << 6789 ); @@ -290,7 +290,7 @@ void TestQgsAppLocatorFilters::testSearchAllLayers() QgsAllLayersFeaturesLocatorFilter filter; const QgsLocatorContext context; - QList< QgsLocatorResult > results = gatherResults( &filter, QStringLiteral( "100" ), context ); + QList results = gatherResults( &filter, QStringLiteral( "100" ), context ); l1->setDisplayExpression( QStringLiteral( "\"my_text\" || ' is ' || \"my_number\"" ) ); l2->setDisplayExpression( QStringLiteral( "\"my_text\" || ' is ' || \"my_number\"" ) ); @@ -311,7 +311,7 @@ void TestQgsAppLocatorFilters::testSearchAllLayersPrioritizeExactMatch() const QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=my_number:integer&key=pk" ); QgsVectorLayer *l1 = new QgsVectorLayer( layerDef, QStringLiteral( "Layer 1" ), QStringLiteral( "memory" ) ); - QgsProject::instance()->addMapLayers( QList< QgsMapLayer *>() << l1 ); + QgsProject::instance()->addMapLayers( QList() << l1 ); QgsFeature f1; f1.setAttributes( QVector() << 100 << "A nice feature" << 100 ); @@ -331,7 +331,7 @@ void TestQgsAppLocatorFilters::testSearchAllLayersPrioritizeExactMatch() l1->setDisplayExpression( QStringLiteral( "\"my_number\"" ) ); - QList< QgsLocatorResult > results = gatherResults( &filter, QStringLiteral( "1" ), context ); + QList results = gatherResults( &filter, QStringLiteral( "1" ), context ); QCOMPARE( results.count(), 2 ); QCOMPARE( results.first().displayString, QStringLiteral( "1" ) ); QCOMPARE( results.last().displayString, QStringLiteral( "100" ) ); @@ -346,8 +346,8 @@ QList TestQgsAppLocatorFilters::gatherResults( QgsLocatorFilte filter->prepare( string, context ); filter->fetchResults( string, context, &f ); - QList< QgsLocatorResult > results; - for ( int i = 0; i < spy.count(); ++ i ) + QList results; + for ( int i = 0; i < spy.count(); ++i ) { const QVariant v = spy.at( i ).at( 0 ); const QgsLocatorResult result = v.value(); @@ -361,7 +361,7 @@ void TestQgsAppLocatorFilters::testGoto() QgsGotoLocatorFilter filter; // simple goto - QList< QgsLocatorResult > results = gatherResults( &filter, QStringLiteral( "4 5" ), QgsLocatorContext() ); + QList results = gatherResults( &filter, QStringLiteral( "4 5" ), QgsLocatorContext() ); QCOMPARE( results.count(), 2 ); QCOMPARE( results.at( 0 ).displayString, QObject::tr( "Go to 4 5 (Map CRS, )" ) ); QCOMPARE( results.at( 0 ).userData().toMap()[QStringLiteral( "point" )].value(), QgsPointXY( 4, 5 ) ); diff --git a/tests/src/app/testqgsattributetable.cpp b/tests/src/app/testqgsattributetable.cpp index b7f1095bb49f..236896c53d0d 100644 --- a/tests/src/app/testqgsattributetable.cpp +++ b/tests/src/app/testqgsattributetable.cpp @@ -46,8 +46,8 @@ class TestQgsAttributeTable : public QObject private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void init(); // will be called before each testfunction is executed. void cleanup() {} // will be called after every testfunction. @@ -113,14 +113,14 @@ void TestQgsAttributeTable::testFieldCalculation() //test field calculation //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); f1.setAttribute( QStringLiteral( "col1" ), 0.0 ); QgsPolylineXY line3111; line3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ); - const QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ) ; + const QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ); f1.setGeometry( line3111G ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -131,7 +131,7 @@ void TestQgsAttributeTable::testFieldCalculation() QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Meters ); // run length calculation - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); dlg->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); tempLayer->commitChanges(); @@ -144,7 +144,7 @@ void TestQgsAttributeTable::testFieldCalculation() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); - std::unique_ptr< QgsAttributeTableDialog > dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); dlg2->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); tempLayer->commitChanges(); @@ -160,7 +160,7 @@ void TestQgsAttributeTable::testFieldCalculationArea() //test $area field calculation //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -181,7 +181,7 @@ void TestQgsAttributeTable::testFieldCalculationArea() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run area calculation - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); dlg->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); tempLayer->commitChanges(); @@ -194,7 +194,7 @@ void TestQgsAttributeTable::testFieldCalculationArea() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); - std::unique_ptr< QgsAttributeTableDialog > dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); dlg2->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); tempLayer->commitChanges(); @@ -210,10 +210,10 @@ void TestQgsAttributeTable::testNoGeom() const QgsSettings s; //test that by default the attribute table DOESN'T fetch geometries (because performance) - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); QVERIFY( !dlg->mMainView->masterModel()->layerCache()->cacheGeometry() ); QVERIFY( dlg->mMainView->masterModel()->request().flags() & Qgis::FeatureRequestFlag::NoGeometry ); @@ -233,18 +233,17 @@ void TestQgsAttributeTable::testNoGeom() dlg->mFeatureFilterWidget->filterVisible(); QVERIFY( dlg->mMainView->masterModel()->layerCache()->cacheGeometry() ); QVERIFY( !( dlg->mMainView->masterModel()->request().flags() & Qgis::FeatureRequestFlag::NoGeometry ) ); - } void TestQgsAttributeTable::testVisibleTemporal() { // test attribute table opening in show feature visible mode - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsPolylineXY line; line << QgsPointXY( 0, 0 ) << QgsPointXY( 1, 1 ); - QgsGeometry geometry = QgsGeometry::fromPolylineXY( line ) ; + QgsGeometry geometry = QgsGeometry::fromPolylineXY( line ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setGeometry( geometry ); f1.setAttributes( QgsAttributes() << 1 << QDate( 2020, 1, 1 ) ); @@ -259,18 +258,18 @@ void TestQgsAttributeTable::testVisibleTemporal() f3.setAttributes( QgsAttributes() << 3 << QDate( 2020, 1, 1 ) ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - QgsVectorLayerTemporalProperties *temporalProperties = qobject_cast< QgsVectorLayerTemporalProperties *>( tempLayer->temporalProperties() ); + QgsVectorLayerTemporalProperties *temporalProperties = qobject_cast( tempLayer->temporalProperties() ); temporalProperties->setIsActive( true ); temporalProperties->setMode( Qgis::VectorTemporalMode::FeatureDateTimeStartAndEndFromFields ); temporalProperties->setStartField( QStringLiteral( "col1" ) ); mQgisApp->mapCanvas()->setDestinationCrs( QgsCoordinateReferenceSystem( "EPSG:4326" ) ); mQgisApp->mapCanvas()->resize( 500, 500 ); - mQgisApp->mapCanvas()->setLayers( QList< QgsMapLayer *>() << tempLayer.get() ); + mQgisApp->mapCanvas()->setLayers( QList() << tempLayer.get() ); mQgisApp->mapCanvas()->setExtent( QgsRectangle( -1, -1, 1, 1 ) ); mQgisApp->mapCanvas()->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 2, 1 ), QTime( 0, 0, 0 ) ) ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowVisible ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowVisible ) ); // feature id 2 is filtered out due to being out of temporal range // feature id 3 is filtered out due to being out of visible extent @@ -280,7 +279,7 @@ void TestQgsAttributeTable::testVisibleTemporal() void TestQgsAttributeTable::testSelected() { // test attribute table opening in show selected mode - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); const QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -288,7 +287,7 @@ void TestQgsAttributeTable::testSelected() const QgsFeature f3( tempLayer->dataProvider()->fields(), 3 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowSelected ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowSelected ) ); QVERIFY( !dlg->mMainView->masterModel()->layerCache()->cacheGeometry() ); //should be nothing - because no selection! @@ -314,7 +313,7 @@ void TestQgsAttributeTable::testSelected() void TestQgsAttributeTable::testEdited() { // test attribute table opening in edited features mode - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); const QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -322,7 +321,7 @@ void TestQgsAttributeTable::testEdited() const QgsFeature f3( tempLayer->dataProvider()->fields(), 3 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowEdited ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowEdited ) ); QVERIFY( !dlg->mMainView->masterModel()->layerCache()->cacheGeometry() ); //should be nothing - because no edited features! @@ -352,7 +351,7 @@ void TestQgsAttributeTable::testEdited() void TestQgsAttributeTable::testSelectedOnTop() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -366,56 +365,56 @@ void TestQgsAttributeTable::testSelectedOnTop() f3.setAttribute( 1, 5.0 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); dlg->mMainView->setSortExpression( "pk" ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); tempLayer->selectByIds( QgsFeatureIds() << 2 ); dlg->mMainView->setSelectedOnTop( true ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); dlg->mMainView->setSelectedOnTop( false ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); tempLayer->selectByIds( QgsFeatureIds() << 3 ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); dlg->mMainView->setSelectedOnTop( true ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); dlg->mMainView->setSelectedOnTop( false ); dlg->mMainView->tableView()->sortByColumn( 1, Qt::DescendingOrder ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); tempLayer->selectByIds( QgsFeatureIds() << 2 ); dlg->mMainView->setSelectedOnTop( true ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); - QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast< int >( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 0, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 2 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 1, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 3 ) ); + QCOMPARE( dlg->mMainView->mFilterModel->index( 2, 0 ).data( static_cast( QgsAttributeTableModel::CustomRole::FeatureId ) ), QVariant( 1 ) ); } void TestQgsAttributeTable::testSortByDisplayExpression() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -429,7 +428,7 @@ void TestQgsAttributeTable::testSortByDisplayExpression() f3.setAttribute( 1, 5.0 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); dlg->mMainView->mFeatureListView->setDisplayExpression( "pk" ); QgsFeatureListModel *listModel = dlg->mMainView->mFeatureListModel; @@ -447,10 +446,9 @@ void TestQgsAttributeTable::testSortByDisplayExpression() void TestQgsAttributeTable::testSortNumbers() { - QLocale::setDefault( QLocale::Italian ); - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -464,7 +462,7 @@ void TestQgsAttributeTable::testSortNumbers() f3.setAttribute( 1, 10.0001 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); QgsAttributeTableConfig cfg; cfg.setSortExpression( QStringLiteral( R"("col1")" ) ); @@ -473,7 +471,7 @@ void TestQgsAttributeTable::testSortNumbers() QgsAttributeTableConfig::ColumnConfig cfg2; cfg1.name = QStringLiteral( "pk" ); cfg2.name = QStringLiteral( "col1" ); - cfg.setColumns( {{ cfg1, cfg2 }} ); + cfg.setColumns( { { cfg1, cfg2 } } ); dlg->mMainView->setAttributeTableConfig( cfg ); @@ -483,19 +481,18 @@ void TestQgsAttributeTable::testSortNumbers() QCOMPARE( model->data( model->index( 1, 1 ), Qt::ItemDataRole::DisplayRole ).toString(), QString( "10,00010" ) ); QCOMPARE( model->data( model->index( 0, 1 ), Qt::ItemDataRole::DisplayRole ).toString(), QString( "1.001,00000" ) ); - QCOMPARE( model->data( model->index( 2, 2 ), static_cast< int >( QgsAttributeTableModel::CustomRole::Sort ) ).toDouble(), 2.001 ); - QCOMPARE( model->data( model->index( 1, 2 ), static_cast< int >( QgsAttributeTableModel::CustomRole::Sort ) ).toDouble(), 10.0001 ); - QCOMPARE( model->data( model->index( 0, 2 ), static_cast< int >( QgsAttributeTableModel::CustomRole::Sort ) ).toDouble(), 1001.0 ); + QCOMPARE( model->data( model->index( 2, 2 ), static_cast( QgsAttributeTableModel::CustomRole::Sort ) ).toDouble(), 2.001 ); + QCOMPARE( model->data( model->index( 1, 2 ), static_cast( QgsAttributeTableModel::CustomRole::Sort ) ).toDouble(), 10.0001 ); + QCOMPARE( model->data( model->index( 0, 2 ), static_cast( QgsAttributeTableModel::CustomRole::Sort ) ).toDouble(), 1001.0 ); QCOMPARE( dlg->mMainView->mTableView->horizontalHeader()->sortIndicatorSection(), 1 ); QCOMPARE( dlg->mMainView->mTableView->horizontalHeader()->sortIndicatorOrder(), Qt::SortOrder::DescendingOrder ); QVERIFY( dlg->mMainView->mTableView->horizontalHeader()->isSortIndicatorShown() ); - } void TestQgsAttributeTable::testStartMultiEditNoChanges() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=col0:integer&field=col1:integer" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?field=col0:integer&field=col1:integer" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsFeature ft1( layer->dataProvider()->fields() ); @@ -507,11 +504,11 @@ void TestQgsAttributeTable::testStartMultiEditNoChanges() layer->selectAll(); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( layer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); for ( int i = 0; i < 10; ++i ) { - dlg->mMainView->setCurrentEditSelection( {ft2.id()} ); + dlg->mMainView->setCurrentEditSelection( { ft2.id() } ); layer->startEditing(); dlg->mMainView->setMultiEditEnabled( true ); @@ -525,7 +522,7 @@ void TestQgsAttributeTable::testStartMultiEditNoChanges() QCOMPARE( fNew2.attributes().at( 1 ).toInt(), 4 ); layer->rollBack(); - dlg->mMainView->setCurrentEditSelection( {ft1.id()} ); + dlg->mMainView->setCurrentEditSelection( { ft1.id() } ); layer->startEditing(); dlg->mMainView->setMultiEditEnabled( true ); @@ -542,7 +539,7 @@ void TestQgsAttributeTable::testStartMultiEditNoChanges() void TestQgsAttributeTable::testMultiEditMakeUncommittedChanges() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=col0:integer&field=col1:integer" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?field=col0:integer&field=col1:integer" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsFeature ft1( layer->dataProvider()->fields() ); @@ -554,9 +551,9 @@ void TestQgsAttributeTable::testMultiEditMakeUncommittedChanges() layer->selectAll(); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( layer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); - dlg->mMainView->setCurrentEditSelection( {ft2.id()} ); + dlg->mMainView->setCurrentEditSelection( { ft2.id() } ); layer->startEditing(); dlg->mMainView->setMultiEditEnabled( true ); @@ -577,13 +574,13 @@ void TestQgsAttributeTable::testRegression15974() { // Test duplicated rows in attribute table + two crashes. const QString path = QDir::tempPath() + "/testshp15974.shp"; - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = QStringLiteral( "system" ); saveOptions.driverName = QStringLiteral( "ESRI Shapefile" ); QgsVectorFileWriter::writeAsVectorFormatV3( tempLayer.get(), path, tempLayer->transformContext(), saveOptions ); - std::unique_ptr< QgsVectorLayer> shpLayer( new QgsVectorLayer( path, QStringLiteral( "test" ), QStringLiteral( "ogr" ) ) ); + std::unique_ptr shpLayer( new QgsVectorLayer( path, QStringLiteral( "test" ), QStringLiteral( "ogr" ) ) ); QgsFeature f1( shpLayer->dataProvider()->fields(), 1 ); QgsGeometry geom; geom = QgsGeometry::fromWkt( QStringLiteral( "polygon((0 0, 0 1, 1 1, 1 0, 0 0))" ) ); @@ -595,7 +592,7 @@ void TestQgsAttributeTable::testRegression15974() f3.setGeometry( geom ); QVERIFY( shpLayer->startEditing() ); QVERIFY( shpLayer->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( shpLayer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( shpLayer.get() ) ); QCOMPARE( shpLayer->featureCount(), 3L ); mQgisApp->saveEdits( shpLayer.get() ); QCOMPARE( shpLayer->featureCount(), 3L ); @@ -611,7 +608,7 @@ void TestQgsAttributeTable::testRegression15974() void TestQgsAttributeTable::testOrderColumn() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -620,7 +617,7 @@ void TestQgsAttributeTable::testOrderColumn() f1.setAttribute( 2, 7 ); QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); // Issue https://github.com/qgis/QGIS/issues/28493 // When we reorder column (last column becomes first column), and we select an entire row @@ -664,7 +661,7 @@ void TestQgsAttributeTable::testOrderColumn() void TestQgsAttributeTable::testFilteredFeatures() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -682,7 +679,7 @@ void TestQgsAttributeTable::testFilteredFeatures() QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); QEventLoop loop; connect( qobject_cast( dlg->mMainView->mFilterModel ), &QgsAttributeTableFilterModel::featuresFiltered, &loop, &QEventLoop::quit ); @@ -747,7 +744,7 @@ void TestQgsAttributeTable::testFilteredFeatures() void TestQgsAttributeTable::testCopySelectedRows() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:int&field=col2:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); @@ -760,7 +757,7 @@ void TestQgsAttributeTable::testCopySelectedRows() QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 ) ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll ) ); tempLayer->selectByIds( QgsFeatureIds() << 1 << 2 ); @@ -790,12 +787,12 @@ void TestQgsAttributeTable::testCopySelectedRows() void TestQgsAttributeTable::testOpenWithFilterExpression() { // test attribute table opening in show feature visible mode - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsPolylineXY line; line << QgsPointXY( 0, 0 ) << QgsPointXY( 1, 1 ); - QgsGeometry geometry = QgsGeometry::fromPolylineXY( line ) ; + QgsGeometry geometry = QgsGeometry::fromPolylineXY( line ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setGeometry( geometry ); f1.setAttributes( QgsAttributes() << 1 << QDate( 2020, 1, 1 ) ); @@ -811,12 +808,7 @@ void TestQgsAttributeTable::testOpenWithFilterExpression() QVERIFY( tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); const QString filterExpression = QStringLiteral( "col1 < to_date('2020-02-03')" ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), - QgsAttributeTableFilterModel::ShowFilteredList, - nullptr, - Qt::Window, - nullptr, - filterExpression ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowFilteredList, nullptr, Qt::Window, nullptr, filterExpression ) ); // feature id 2 is filtered out due not matching the provided filter expression QCOMPARE( dlg->mMainView->filteredFeatures(), QgsFeatureIds() << 1 << 3 ); @@ -824,12 +816,12 @@ void TestQgsAttributeTable::testOpenWithFilterExpression() void TestQgsAttributeTable::testInvalidView() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=pk:int&field=col1:date" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsPolylineXY line; line << QgsPointXY( 0, 0 ) << QgsPointXY( 1, 1 ); - QgsGeometry geometry = QgsGeometry::fromPolylineXY( line ) ; + QgsGeometry geometry = QgsGeometry::fromPolylineXY( line ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setGeometry( geometry ); f1.setAttributes( QgsAttributes() << 1 << QDate( 2020, 1, 1 ) ); @@ -848,12 +840,7 @@ void TestQgsAttributeTable::testInvalidView() tempLayer->setConstraintExpression( 1, QStringLiteral( "col1 >= to_date('2020-02-03')" ) ); tempLayer->setFieldConstraint( 1, QgsFieldConstraints::ConstraintExpression, QgsFieldConstraints::ConstraintStrengthHard ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get(), - QgsAttributeTableFilterModel::ShowAll, - nullptr, - Qt::Window, - nullptr, - filterExpression ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( tempLayer.get(), QgsAttributeTableFilterModel::ShowAll, nullptr, Qt::Window, nullptr, filterExpression ) ); dlg->mFeatureFilterWidget->filterInvalid(); // feature id 2 is filtered out due not matching the provided filter expression @@ -862,7 +849,7 @@ void TestQgsAttributeTable::testInvalidView() void TestQgsAttributeTable::testEnsureEditSelection() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=col0:integer&field=col1:integer" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?field=col0:integer&field=col1:integer" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsFeature ft1( layer->dataProvider()->fields(), 1 ); @@ -880,14 +867,14 @@ void TestQgsAttributeTable::testEnsureEditSelection() layer->removeSelection(); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( layer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); //since the update is done by timer, we have to wait (at least one millisecond) or until the current edit selection changed qRegisterMetaType( "QgsFeature&" ); QSignalSpy spy( dlg->mMainView->mFeatureListView, &QgsFeatureListView::currentEditSelectionChanged ); // we set the index to ft3 - dlg->mMainView->setCurrentEditSelection( {ft3.id()} ); + dlg->mMainView->setCurrentEditSelection( { ft3.id() } ); // ... and the currentEditSelection is on ft3 QVERIFY( dlg->mMainView->mFeatureListView->currentEditSelection().contains( 3 ) ); @@ -925,19 +912,18 @@ void TestQgsAttributeTable::testEnsureEditSelection() void TestQgsAttributeTable::testFetchAllAttributes() { QString pointFileName = TEST_DATA_DIR + QStringLiteral( "/points.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( pointFileName ); + std::unique_ptr layer = std::make_unique( pointFileName ); QVERIFY( layer->isValid() ); QgsAttributeTableConfig config { layer->attributeTableConfig() }; config.setColumnHidden( 1, true ); layer->setAttributeTableConfig( config ); - std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( layer.get() ) ); + std::unique_ptr dlg( new QgsAttributeTableDialog( layer.get() ) ); QCOMPARE( dlg->mMainView->masterModel()->data( dlg->mMainView->masterModel()->index( 0, 0 ), Qt::DisplayRole ).toString(), "Jet" ); QCOMPARE( dlg->mMainView->masterModel()->data( dlg->mMainView->masterModel()->index( 0, 1 ), Qt::DisplayRole ).toString(), "90" ); QCOMPARE( dlg->mMainView->masterModel()->data( dlg->mMainView->masterModel()->index( 0, 2 ), Qt::DisplayRole ).toString(), "3.000" ); - } QGSTEST_MAIN( TestQgsAttributeTable ) diff --git a/tests/src/app/testqgsdecorationscalebar.cpp b/tests/src/app/testqgsdecorationscalebar.cpp index 7084d3b73fb4..188bd8c3d1dd 100644 --- a/tests/src/app/testqgsdecorationscalebar.cpp +++ b/tests/src/app/testqgsdecorationscalebar.cpp @@ -25,10 +25,10 @@ class TestQgsDecorationScalebar : public QObject TestQgsDecorationScalebar(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void mapWidth(); private: diff --git a/tests/src/app/testqgsdwgimportdialog.cpp b/tests/src/app/testqgsdwgimportdialog.cpp index d75d6ae25b7e..dc58a1fcc111 100644 --- a/tests/src/app/testqgsdwgimportdialog.cpp +++ b/tests/src/app/testqgsdwgimportdialog.cpp @@ -29,9 +29,9 @@ class TestQgsDwgImportDialog : public QObject TestQgsDwgImportDialog() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase() {} // will be called after the last testfunction was executed. - void cleanup(); // will be called after every testfunction. + void cleanup(); // will be called after every testfunction. void importDwgDocument(); void importDwgDocumentExpandBlockGeometries(); @@ -90,14 +90,10 @@ void TestQgsDwgImportDialog::importDwgDocument() QVERIFY( groupEntities ); // Group 0 - checkGroupContent( groupEntities, - "0", - QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" << "inserts" ); + checkGroupContent( groupEntities, "0", QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" << "inserts" ); // Group grün - checkGroupContent( groupEntities, - "grün", - QStringList() << "hatches" << "lines" << "polylines" ); + checkGroupContent( groupEntities, "grün", QStringList() << "hatches" << "lines" << "polylines" ); } void TestQgsDwgImportDialog::importDwgDocumentExpandBlockGeometries() @@ -132,14 +128,10 @@ void TestQgsDwgImportDialog::importDwgDocumentExpandBlockGeometries() QVERIFY( groupEntities ); // Group 0 - checkGroupContent( groupEntities, - "0", - QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" ); + checkGroupContent( groupEntities, "0", QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" ); // Group grün - checkGroupContent( groupEntities, - "grün", - QStringList() << "hatches" << "lines" << "polylines" ); + checkGroupContent( groupEntities, "grün", QStringList() << "hatches" << "lines" << "polylines" ); } void TestQgsDwgImportDialog::importDwgDocumentBlockOnlyInsertPoints() @@ -174,14 +166,10 @@ void TestQgsDwgImportDialog::importDwgDocumentBlockOnlyInsertPoints() QVERIFY( groupEntities ); // Group 0 - checkGroupContent( groupEntities, - "0", - QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" << "inserts" ); + checkGroupContent( groupEntities, "0", QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" << "inserts" ); // Group grün - checkGroupContent( groupEntities, - "grün", - QStringList() << "hatches" << "lines" << "polylines" ); + checkGroupContent( groupEntities, "grün", QStringList() << "hatches" << "lines" << "polylines" ); } void TestQgsDwgImportDialog::checkGroupContent( QgsLayerTreeGroup *parentGroup, const QString &groupName, const QStringList &contentLayerNames ) diff --git a/tests/src/app/testqgsfieldcalculator.cpp b/tests/src/app/testqgsfieldcalculator.cpp index d3568516cae9..f121d1d6b17f 100644 --- a/tests/src/app/testqgsfieldcalculator.cpp +++ b/tests/src/app/testqgsfieldcalculator.cpp @@ -34,10 +34,10 @@ class TestQgsFieldCalculator : public QObject TestQgsFieldCalculator(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testLengthCalculations(); void testAreaCalculations(); @@ -68,14 +68,14 @@ void TestQgsFieldCalculator::testLengthCalculations() //test length calculation respects ellipsoid and project distance units //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); f1.setAttribute( QStringLiteral( "col1" ), 0.0 ); QgsPolylineXY line3111; line3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ); - const QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ) ; + const QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ); f1.setGeometry( line3111G ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -87,7 +87,7 @@ void TestQgsFieldCalculator::testLengthCalculations() // run length calculation tempLayer->startEditing(); - std::unique_ptr< QgsFieldCalculator > calc( new QgsFieldCalculator( tempLayer.get() ) ); + std::unique_ptr calc( new QgsFieldCalculator( tempLayer.get() ) ); // this next part is fragile, and may need to be modified if the dialog changes: calc->mUpdateExistingGroupBox->setChecked( true ); @@ -107,7 +107,7 @@ void TestQgsFieldCalculator::testLengthCalculations() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); tempLayer->startEditing(); - std::unique_ptr< QgsFieldCalculator > calc2( new QgsFieldCalculator( tempLayer.get() ) ); + std::unique_ptr calc2( new QgsFieldCalculator( tempLayer.get() ) ); calc2->mUpdateExistingGroupBox->setChecked( true ); calc2->mExistingFieldComboBox->setCurrentIndex( 1 ); calc2->builder->setExpressionText( QStringLiteral( "$length" ) ); @@ -118,7 +118,6 @@ void TestQgsFieldCalculator::testLengthCalculations() QVERIFY( fit.nextFeature( f ) ); expected = 88360.0918635; QGSCOMPARENEAR( f.attribute( "col1" ).toDouble(), expected, 0.001 ); - } void TestQgsFieldCalculator::testAreaCalculations() @@ -126,7 +125,7 @@ void TestQgsFieldCalculator::testAreaCalculations() //test area calculation respects ellipsoid and project area units //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -136,7 +135,7 @@ void TestQgsFieldCalculator::testAreaCalculations() polygonRing3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ) << QgsPointXY( 2520109, 2397715 ) << QgsPointXY( 2520792, 2425494 ) << QgsPointXY( 2484588, 2425722 ); QgsPolygonXY polygon3111; polygon3111 << polygonRing3111; - const QgsGeometry polygon3111G = QgsGeometry::fromPolygonXY( polygon3111 ) ; + const QgsGeometry polygon3111G = QgsGeometry::fromPolygonXY( polygon3111 ); f1.setGeometry( polygon3111G ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -148,7 +147,7 @@ void TestQgsFieldCalculator::testAreaCalculations() // run area calculation tempLayer->startEditing(); - std::unique_ptr< QgsFieldCalculator > calc( new QgsFieldCalculator( tempLayer.get() ) ); + std::unique_ptr calc( new QgsFieldCalculator( tempLayer.get() ) ); // this next part is fragile, and may need to be modified if the dialog changes: calc->mUpdateExistingGroupBox->setChecked( true ); @@ -168,7 +167,7 @@ void TestQgsFieldCalculator::testAreaCalculations() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); tempLayer->startEditing(); - std::unique_ptr< QgsFieldCalculator > calc2( new QgsFieldCalculator( tempLayer.get() ) ); + std::unique_ptr calc2( new QgsFieldCalculator( tempLayer.get() ) ); calc2->mUpdateExistingGroupBox->setChecked( true ); calc2->mExistingFieldComboBox->setCurrentIndex( 1 ); calc2->builder->setExpressionText( QStringLiteral( "$area" ) ); diff --git a/tests/src/app/testqgsgeoreferencer.cpp b/tests/src/app/testqgsgeoreferencer.cpp index 0885ad4b5228..91c6025b9a4b 100644 --- a/tests/src/app/testqgsgeoreferencer.cpp +++ b/tests/src/app/testqgsgeoreferencer.cpp @@ -34,10 +34,10 @@ class TestQgsGeoreferencer : public QObject TestQgsGeoreferencer(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testGcpPoint(); void testGeorefDataPoint(); void testGcpList(); @@ -99,16 +99,11 @@ void TestQgsGeoreferencer::testGcpPoint() QVERIFY( p.isEnabled() ); // equality operator - QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) - == QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) ); - QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) - != QgsGcpPoint( QgsPointXY( 11, 22 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) ); - QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) - != QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) ); - QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) - != QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), false ) ); - QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) - != QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), true ) ); + QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) == QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) ); + QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) != QgsGcpPoint( QgsPointXY( 11, 22 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) ); + QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) != QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) ); + QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) != QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), false ) ); + QVERIFY( QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) != QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), true ) ); // transform destination point @@ -122,9 +117,7 @@ void TestQgsGeoreferencer::testGeorefDataPoint() { QgsMapCanvas c1; QgsMapCanvas c2; - QgsGeorefDataPoint p( &c1, &c2, - QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - false ); + QgsGeorefDataPoint p( &c1, &c2, QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ); QCOMPARE( p.sourcePoint(), QgsPointXY( 1, 2 ) ); p.setSourcePoint( QgsPointXY( 11, 22 ) ); @@ -140,10 +133,7 @@ void TestQgsGeoreferencer::testGeorefDataPoint() p.setEnabled( true ); QVERIFY( p.isEnabled() ); - QCOMPARE( p.point(), QgsGcpPoint( QgsPointXY( 11, 22 ), - QgsPointXY( 33, 44 ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - true ) ); + QCOMPARE( p.point(), QgsGcpPoint( QgsPointXY( 11, 22 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), true ) ); // transform destination point @@ -161,57 +151,30 @@ void TestQgsGeoreferencer::testGcpList() QgsMapCanvas c1; QgsMapCanvas c2; - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - false ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) ); QCOMPARE( list.countEnabledPoints(), 0 ); - QCOMPARE( list.asPoints(), - { - QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) - } - ); + QCOMPARE( list.asPoints(), { QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ) } ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 11, 22 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 11, 22 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ) ); QCOMPARE( list.countEnabledPoints(), 1 ); - QCOMPARE( list.asPoints(), - QList< QgsGcpPoint >( - { - QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ), - QgsGcpPoint( QgsPointXY( 11, 22 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ) - } ) ); + QCOMPARE( list.asPoints(), QList( { QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ), QgsGcpPoint( QgsPointXY( 11, 22 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ) } ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 111, 222 ), QgsPointXY( 333, 444 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 111, 222 ), QgsPointXY( 333, 444 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ) ); QCOMPARE( list.countEnabledPoints(), 2 ); - QCOMPARE( list.asPoints(), - QList< QgsGcpPoint >( - { - QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ), - QgsGcpPoint( QgsPointXY( 11, 22 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ), - QgsGcpPoint( QgsPointXY( 111, 222 ), QgsPointXY( 333, 444 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ) - } ) ); + QCOMPARE( list.asPoints(), QList( { QgsGcpPoint( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), false ), QgsGcpPoint( QgsPointXY( 11, 22 ), QgsPointXY( 33, 44 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ), QgsGcpPoint( QgsPointXY( 111, 222 ), QgsPointXY( 333, 444 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), true ) } ) ); qDeleteAll( list ); list.clear(); // create gcp vectors - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 111, 222 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 11, 22 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 111, 222 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 11, 22 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); // disabled! - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 33, 44 ), QgsPointXY( 100, 200 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - false ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 33, 44 ), QgsPointXY( 100, 200 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), false ) ); - QVector< QgsPointXY > sourcePoints; - QVector< QgsPointXY > destinationPoints; + QVector sourcePoints; + QVector destinationPoints; list.createGCPVectors( sourcePoints, destinationPoints, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsProject::instance()->transformContext() ); QCOMPARE( sourcePoints.size(), 2 ); QCOMPARE( sourcePoints.at( 0 ).x(), 111 ); @@ -224,7 +187,6 @@ void TestQgsGeoreferencer::testGcpList() QGSCOMPARENEAR( destinationPoints.at( 0 ).y(), 4865942, 10000 ); QCOMPARE( destinationPoints.at( 1 ).x(), 16697923 ); QCOMPARE( destinationPoints.at( 1 ).y(), -3503549 ); - } void TestQgsGeoreferencer::testSaveLoadGcps() @@ -233,16 +195,10 @@ void TestQgsGeoreferencer::testSaveLoadGcps() QgsGCPList list; QgsMapCanvas c1; QgsMapCanvas c2; - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 111, 222 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 11, 22 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 111, 222 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 11, 22 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); // disabled! - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 33, 44 ), QgsPointXY( 100, 200 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - false ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 33, 44 ), QgsPointXY( 100, 200 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), false ) ); QTemporaryDir dir; QVERIFY( dir.isValid() ); @@ -250,23 +206,16 @@ void TestQgsGeoreferencer::testSaveLoadGcps() QString error; - QVERIFY( list.saveGcps( tempFilename, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - QgsProject::instance()->transformContext(), error ) ); + QVERIFY( list.saveGcps( tempFilename, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsProject::instance()->transformContext(), error ) ); QVERIFY( error.isEmpty() ); // load QgsCoordinateReferenceSystem actualDestinationCrs; - QList res = QgsGCPList::loadGcps( QStringLiteral( "not real" ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - actualDestinationCrs, - error ); + QList res = QgsGCPList::loadGcps( QStringLiteral( "not real" ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), actualDestinationCrs, error ); QVERIFY( !error.isEmpty() ); - res = QgsGCPList::loadGcps( tempFilename, - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - actualDestinationCrs, - error ); + res = QgsGCPList::loadGcps( tempFilename, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), actualDestinationCrs, error ); QVERIFY( error.isEmpty() ); QCOMPARE( res.size(), 3 ); // should be loaded from txt @@ -300,16 +249,10 @@ void TestQgsGeoreferencer::testSaveLoadGcpsNoCrs() QgsGCPList list; QgsMapCanvas c1; QgsMapCanvas c2; - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 111, 222 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem(), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 11, 22 ), QgsPointXY( 34, -50 ), QgsCoordinateReferenceSystem(), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 111, 222 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem(), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 11, 22 ), QgsPointXY( 34, -50 ), QgsCoordinateReferenceSystem(), true ) ); // disabled! - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 33, 44 ), QgsPointXY( 100, 200 ), QgsCoordinateReferenceSystem(), - false ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 33, 44 ), QgsPointXY( 100, 200 ), QgsCoordinateReferenceSystem(), false ) ); QTemporaryDir dir; QVERIFY( dir.isValid() ); @@ -317,17 +260,13 @@ void TestQgsGeoreferencer::testSaveLoadGcpsNoCrs() QString error; - QVERIFY( list.saveGcps( tempFilename, QgsCoordinateReferenceSystem(), - QgsProject::instance()->transformContext(), error ) ); + QVERIFY( list.saveGcps( tempFilename, QgsCoordinateReferenceSystem(), QgsProject::instance()->transformContext(), error ) ); QVERIFY( error.isEmpty() ); // load QgsCoordinateReferenceSystem actualDestinationCrs; - QList res = QgsGCPList::loadGcps( tempFilename, - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - actualDestinationCrs, - error ); + QList res = QgsGCPList::loadGcps( tempFilename, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), actualDestinationCrs, error ); QVERIFY( error.isEmpty() ); QCOMPARE( res.size(), 3 ); // should fallback to default CRS @@ -361,10 +300,9 @@ void TestQgsGeoreferencer::testTransformClone() QgsGeorefTransform transform( QgsGcpTransformerInterface::TransformMethod::PolynomialOrder1 ); transform.loadRaster( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/rgb256x256.png" ) ); - QVERIFY( transform.updateParametersFromGcps( {QgsPointXY( 0, 0 ), QgsPointXY( 10, 0 ), QgsPointXY( 0, 30 ), QgsPointXY( 10, 30 )}, - {QgsPointXY( 10, 5 ), QgsPointXY( 16, 5 ), QgsPointXY( 10, 8 ), QgsPointXY( 16, 8 )}, true ) ); + QVERIFY( transform.updateParametersFromGcps( { QgsPointXY( 0, 0 ), QgsPointXY( 10, 0 ), QgsPointXY( 0, 30 ), QgsPointXY( 10, 30 ) }, { QgsPointXY( 10, 5 ), QgsPointXY( 16, 5 ), QgsPointXY( 10, 8 ), QgsPointXY( 16, 8 ) }, true ) ); - std::unique_ptr< QgsGeorefTransform > cloned( dynamic_cast< QgsGeorefTransform * >( transform.clone() ) ); + std::unique_ptr cloned( dynamic_cast( transform.clone() ) ); QCOMPARE( cloned->method(), QgsGcpTransformerInterface::TransformMethod::PolynomialOrder1 ); QVERIFY( !cloned->hasExistingGeoreference() ); @@ -387,10 +325,9 @@ void TestQgsGeoreferencer::testTransformClone() QgsGeorefTransform transform2( QgsGcpTransformerInterface::TransformMethod::Linear ); transform2.loadRaster( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ); - QVERIFY( transform2.updateParametersFromGcps( {QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 )}, - {QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 )}, true ) ); + QVERIFY( transform2.updateParametersFromGcps( { QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 ) }, { QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 ) }, true ) ); - cloned.reset( dynamic_cast< QgsGeorefTransform * >( transform2.clone() ) ); + cloned.reset( dynamic_cast( transform2.clone() ) ); QCOMPARE( cloned->method(), QgsGcpTransformerInterface::TransformMethod::Linear ); QVERIFY( cloned->hasExistingGeoreference() ); @@ -444,8 +381,7 @@ void TestQgsGeoreferencer::testTransformImageNoGeoference() QCOMPARE( rect.xMaximum(), 100.0 ); QCOMPARE( rect.yMaximum(), 200.0 ); - QVERIFY( transform.updateParametersFromGcps( {QgsPointXY( 0, 0 ), QgsPointXY( 10, 0 ), QgsPointXY( 0, 30 ), QgsPointXY( 10, 30 )}, - {QgsPointXY( 10, 5 ), QgsPointXY( 16, 5 ), QgsPointXY( 10, 8 ), QgsPointXY( 16, 8 )}, true ) ); + QVERIFY( transform.updateParametersFromGcps( { QgsPointXY( 0, 0 ), QgsPointXY( 10, 0 ), QgsPointXY( 0, 30 ), QgsPointXY( 10, 30 ) }, { QgsPointXY( 10, 5 ), QgsPointXY( 16, 5 ), QgsPointXY( 10, 8 ), QgsPointXY( 16, 8 ) }, true ) ); QVERIFY( transform.transform( QgsPointXY( 0, 5 ), res, true ) ); QCOMPARE( res.x(), 10 ); @@ -505,15 +441,15 @@ void TestQgsGeoreferencer::testTransformImageWithExistingGeoreference() QGSCOMPARENEAR( rect.xMinimum(), 781662.375, 0.1 ); QGSCOMPARENEAR( rect.yMinimum(), 3350923.125, 0.1 ); QGSCOMPARENEAR( rect.xMaximum(), 787362.375, 0.1 ); - QGSCOMPARENEAR( rect.yMaximum(), 3362323.125, 0.1 ); + QGSCOMPARENEAR( rect.yMaximum(), 3362323.125, 0.1 ); QVector pixelCoords = transform.mRasterChangeCoords.getPixelCoords( - { - QgsPointXY( 783414, 3350122 ), - QgsPointXY( 791344, 3349795 ), - QgsPointXY( 783077, 3340937 ), - QgsPointXY( 791134, 3341401 ) - } ) ; + { QgsPointXY( 783414, 3350122 ), + QgsPointXY( 791344, 3349795 ), + QgsPointXY( 783077, 3340937 ), + QgsPointXY( 791134, 3341401 ) + } + ); QCOMPARE( pixelCoords.size(), 4 ); QGSCOMPARENEAR( pixelCoords.at( 0 ).x(), 30.7302631579, 0.01 ); @@ -528,8 +464,7 @@ void TestQgsGeoreferencer::testTransformImageWithExistingGeoreference() QVERIFY( transform.hasExistingGeoreference() ); // when calling updateParametersFromGcps the source list MUST be in source layer CRS, not pixels! - QVERIFY( transform.updateParametersFromGcps( {QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 )}, - {QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 )}, true ) ); + QVERIFY( transform.updateParametersFromGcps( { QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 ) }, { QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 ) }, true ) ); QVERIFY( transform.transform( QgsPointXY( 30.7302631579, -14.0548245614 ), res, true ) ); QGSCOMPARENEAR( res.x(), 783414, 1 ); @@ -546,8 +481,7 @@ void TestQgsGeoreferencer::testTransformImageWithExistingGeoreference() QGSCOMPARENEAR( res.y(), -167.0548245614, 0.1 ); // with shift of 100, 200 - QVERIFY( transform.updateParametersFromGcps( {QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 )}, - {QgsPointXY( 783514, 3350322 ), QgsPointXY( 791444, 3349995 ), QgsPointXY( 783177, 334293 ), QgsPointXY( 791234, 3341601 )}, true ) ); + QVERIFY( transform.updateParametersFromGcps( { QgsPointXY( 783414, 3350122 ), QgsPointXY( 791344, 3349795 ), QgsPointXY( 783077, 334093 ), QgsPointXY( 791134, 3341401 ) }, { QgsPointXY( 783514, 3350322 ), QgsPointXY( 791444, 3349995 ), QgsPointXY( 783177, 334293 ), QgsPointXY( 791234, 3341601 ) }, true ) ); QVERIFY( transform.transform( QgsPointXY( 30.7302631579, -14.0548245614 ), res, true ) ); QGSCOMPARENEAR( res.x(), 783514, 1 ); @@ -582,8 +516,8 @@ void TestQgsGeoreferencer::testRasterChangeCoords() QGSCOMPARENEAR( transform.toColumnLine( QgsPointXY( 781662.375, 3350923.125 ) ).y(), 0.0, 0.0001 ); QGSCOMPARENEAR( transform.toColumnLine( QgsPointXY( 787362.375, 3350923.125 ) ).x(), 100.0, 0.0001 ); QGSCOMPARENEAR( transform.toColumnLine( QgsPointXY( 787362.375, 3350923.125 ) ).y(), 0.0, 0.0001 ); - QGSCOMPARENEAR( transform.toColumnLine( QgsPointXY( 787362.375, 3362323.125 ) ).x(), 100.0, 0.0001 ); - QGSCOMPARENEAR( transform.toColumnLine( QgsPointXY( 787362.375, 3362323.125 ) ).y(), 200.0, 0.0001 ); + QGSCOMPARENEAR( transform.toColumnLine( QgsPointXY( 787362.375, 3362323.125 ) ).x(), 100.0, 0.0001 ); + QGSCOMPARENEAR( transform.toColumnLine( QgsPointXY( 787362.375, 3362323.125 ) ).y(), 200.0, 0.0001 ); // load a raster with no georeferencing transform.loadRaster( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/rgb256x256.png" ) ); @@ -614,15 +548,9 @@ void TestQgsGeoreferencer::testUpdateResiduals() QgsGCPList list; QgsMapCanvas c1; QgsMapCanvas c2; - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( -35, 42 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( -35, 42 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); list.updateResiduals( &transform, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsProject::instance()->transformContext(), Qgis::RenderUnit::Pixels ); QGSCOMPARENEAR( list.at( 0 )->residual().x(), 0, 0.00001 ); @@ -670,15 +598,9 @@ void TestQgsGeoreferencer::testListModel() QgsGCPList list; QgsMapCanvas c1; QgsMapCanvas c2; - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( -35, 42 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( -35, 42 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); QgsGeorefTransform transform( QgsGcpTransformerInterface::TransformMethod::Linear ); transform.loadRaster( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ); QVERIFY( transform.hasExistingGeoreference() ); @@ -779,15 +701,9 @@ void TestQgsGeoreferencer::testListModelCrs() QgsGCPList list; QgsMapCanvas c1; QgsMapCanvas c2; - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( 17697923, -3403549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( 17697923, -3403549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); QgsGCPListModel model; model.setGCPList( &list ); @@ -852,15 +768,9 @@ void TestQgsGeoreferencer::testListModelLocalization() QgsGCPList list; QgsMapCanvas c1; QgsMapCanvas c2; - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); - list.append( new QgsGeorefDataPoint( &c1, &c2, - QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( 17697923, -3403549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 781662.375, 3350923.125 ), QgsPointXY( -30, 40 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3350923.125 ), QgsPointXY( 16697923, -3503549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); + list.append( new QgsGeorefDataPoint( &c1, &c2, QgsPointXY( 787362.375, 3362323.125 ), QgsPointXY( 17697923, -3403549 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), true ) ); QgsGCPListModel model; model.setGCPList( &list ); @@ -892,7 +802,6 @@ void TestQgsGeoreferencer::testListModelLocalization() // Revert locale to english QLocale::setDefault( defaultLocale ); - } void TestQgsGeoreferencer::testGdalCommands() @@ -907,25 +816,19 @@ void TestQgsGeoreferencer::testGdalCommands() QString command = window.generateGDALtranslateCommand(); // gdal_translate command must use source pixels, not geographic coordinates - QCOMPARE( command, QStringLiteral( "gdal_translate -of GTiff -co TFW=YES -gcp 30.73 14.055 783414.001 3350122.002 -gcp 169.853 19.792 791344 33497952 -gcp 24.818 52926.844 783077 334093 -gcp 166.169 167.055 791134 3341401 \"%1\" \"%2\"" ).arg( - QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ), - QDir::tempPath() + QStringLiteral( "/landsat.tif" ) ) ); + QCOMPARE( command, QStringLiteral( "gdal_translate -of GTiff -co TFW=YES -gcp 30.73 14.055 783414.001 3350122.002 -gcp 169.853 19.792 791344 33497952 -gcp 24.818 52926.844 783077 334093 -gcp 166.169 167.055 791134 3341401 \"%1\" \"%2\"" ).arg( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ), QDir::tempPath() + QStringLiteral( "/landsat.tif" ) ) ); command = window.generateGDALogr2ogrCommand(); - QCOMPARE( command, QStringLiteral( "ogr2ogr -gcp 783414 3350122 783414.001 3350122.002 -gcp 791344 3349795 791344 33497952 -gcp 783077 334093 783077 334093 -gcp 791134 3341401 791134 3341401 -tps -t_srs EPSG:32633 \"\" \"%1\"" ).arg( - QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ) ); + QCOMPARE( command, QStringLiteral( "ogr2ogr -gcp 783414 3350122 783414.001 3350122.002 -gcp 791344 3349795 791344 33497952 -gcp 783077 334093 783077 334093 -gcp 791134 3341401 791134 3341401 -tps -t_srs EPSG:32633 \"\" \"%1\"" ).arg( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ) ); window.mTargetCrs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ); command = window.generateGDALtranslateCommand(); QgsDebugMsgLevel( command, 1 ); - QCOMPARE( command, QStringLiteral( "gdal_translate -of GTiff -co TFW=YES -gcp 30.73 14.055 783414.00123457 3350122.00234568 -gcp 169.853 19.792 791344 33497952 -gcp 24.818 52926.844 783077 334093 -gcp 166.169 167.055 791134 3341401 \"%1\" \"%2\"" ).arg( - QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ), - QDir::tempPath() + QStringLiteral( "/landsat.tif" ) ) ); + QCOMPARE( command, QStringLiteral( "gdal_translate -of GTiff -co TFW=YES -gcp 30.73 14.055 783414.00123457 3350122.00234568 -gcp 169.853 19.792 791344 33497952 -gcp 24.818 52926.844 783077 334093 -gcp 166.169 167.055 791134 3341401 \"%1\" \"%2\"" ).arg( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ), QDir::tempPath() + QStringLiteral( "/landsat.tif" ) ) ); command = window.generateGDALogr2ogrCommand(); QgsDebugMsgLevel( command, 1 ); - QCOMPARE( command, QStringLiteral( "ogr2ogr -gcp 783414 3350122 783414.00123457 3350122.00234568 -gcp 791344 3349795 791344 33497952 -gcp 783077 334093 783077 334093 -gcp 791134 3341401 791134 3341401 -tps -t_srs EPSG:4326 \"\" \"%1\"" ).arg( - QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ) ); + QCOMPARE( command, QStringLiteral( "ogr2ogr -gcp 783414 3350122 783414.00123457 3350122.00234568 -gcp 791344 3349795 791344 33497952 -gcp 783077 334093 783077 334093 -gcp 791134 3341401 791134 3341401 -tps -t_srs EPSG:4326 \"\" \"%1\"" ).arg( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ) ); const QLocale defaultLocale = QLocale(); @@ -934,20 +837,15 @@ void TestQgsGeoreferencer::testGdalCommands() command = window.generateGDALtranslateCommand(); QgsDebugMsgLevel( command, 1 ); - QCOMPARE( command, QStringLiteral( "gdal_translate -of GTiff -co TFW=YES -gcp 30.73 14.055 783414.00123457 3350122.00234568 -gcp 169.853 19.792 791344 33497952 -gcp 24.818 52926.844 783077 334093 -gcp 166.169 167.055 791134 3341401 \"%1\" \"%2\"" ).arg( - QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ), - QDir::tempPath() + QStringLiteral( "/landsat.tif" ) ) ); + QCOMPARE( command, QStringLiteral( "gdal_translate -of GTiff -co TFW=YES -gcp 30.73 14.055 783414.00123457 3350122.00234568 -gcp 169.853 19.792 791344 33497952 -gcp 24.818 52926.844 783077 334093 -gcp 166.169 167.055 791134 3341401 \"%1\" \"%2\"" ).arg( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ), QDir::tempPath() + QStringLiteral( "/landsat.tif" ) ) ); command = window.generateGDALogr2ogrCommand(); QgsDebugMsgLevel( command, 1 ); - QCOMPARE( command, QStringLiteral( "ogr2ogr -gcp 783414 3350122 783414.00123457 3350122.00234568 -gcp 791344 3349795 791344 33497952 -gcp 783077 334093 783077 334093 -gcp 791134 3341401 791134 3341401 -tps -t_srs EPSG:4326 \"\" \"%1\"" ).arg( - QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ) ); - + QCOMPARE( command, QStringLiteral( "ogr2ogr -gcp 783414 3350122 783414.00123457 3350122.00234568 -gcp 791344 3349795 791344 33497952 -gcp 783077 334093 783077 334093 -gcp 791134 3341401 791134 3341401 -tps -t_srs EPSG:4326 \"\" \"%1\"" ).arg( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/landsat.tif" ) ) ); // Revert locale to english QLocale::setDefault( defaultLocale ); - } void TestQgsGeoreferencer::testWorldFile() diff --git a/tests/src/app/testqgsgpsintegration.cpp b/tests/src/app/testqgsgpsintegration.cpp index 737a220e7d62..e4d0f55b2d8f 100644 --- a/tests/src/app/testqgsgpsintegration.cpp +++ b/tests/src/app/testqgsgpsintegration.cpp @@ -37,7 +37,8 @@ class TestQgsGpsIntegration : public QgsTest { Q_OBJECT public: - TestQgsGpsIntegration() : QgsTest( QStringLiteral( "GPS Integration Tests" ) ) {} + TestQgsGpsIntegration() + : QgsTest( QStringLiteral( "GPS Integration Tests" ) ) {} private slots: void initTestCase(); @@ -72,30 +73,21 @@ void TestQgsGpsIntegration::initTestCase() QCoreApplication::setOrganizationName( QStringLiteral( "QGISGpsTests" ) ); QCoreApplication::setOrganizationDomain( QStringLiteral( "qgis.org" ) ); QCoreApplication::setApplicationName( QStringLiteral( "QGIS-TEST" ) ); - QgsSettings().clear( ); + QgsSettings().clear(); mQgisApp = new QgisApp(); - tempLayer = new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=intf:int" ), - QStringLiteral( "vl1" ), - QStringLiteral( "memory" ) ); - tempLayerString = new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=stringf:string&field=intf:int" ), - QStringLiteral( "vl2" ), - QStringLiteral( "memory" ) ); - tempLayerDateTime = new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=datetimef:datetime&field=intf:int" ), - QStringLiteral( "vl3" ), - QStringLiteral( "memory" ) ); - tempLayerLineString = new QgsVectorLayer( QStringLiteral( "Linestring?crs=epsg:4326&field=intf:int&field=stringf:string" ), - QStringLiteral( "vl4" ), - QStringLiteral( "memory" ) ); + tempLayer = new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=intf:int" ), QStringLiteral( "vl1" ), QStringLiteral( "memory" ) ); + tempLayerString = new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=stringf:string&field=intf:int" ), QStringLiteral( "vl2" ), QStringLiteral( "memory" ) ); + tempLayerDateTime = new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=datetimef:datetime&field=intf:int" ), QStringLiteral( "vl3" ), QStringLiteral( "memory" ) ); + tempLayerLineString = new QgsVectorLayer( QStringLiteral( "Linestring?crs=epsg:4326&field=intf:int&field=stringf:string" ), QStringLiteral( "vl4" ), QStringLiteral( "memory" ) ); QgsSettingsRegistryCore::settingsDigitizingDisableEnterAttributeValuesDialog->setValue( true ); const QString tempPath = QDir::tempPath() + QStringLiteral( "/gps_timestamp.gpkg" ); QFile::copy( TEST_DATA_DIR + QStringLiteral( "/gps_timestamp.gpkg" ), tempPath ); - tempGpkgLayerPointString = new QgsVectorLayer( QStringLiteral( "%1|layername=points" ).arg( tempPath ), - QStringLiteral( "vl4" ) ); + tempGpkgLayerPointString = new QgsVectorLayer( QStringLiteral( "%1|layername=points" ).arg( tempPath ), QStringLiteral( "vl4" ) ); Q_ASSERT( tempGpkgLayerPointString->isValid() ); Q_ASSERT( tempLayer->isValid() ); Q_ASSERT( tempLayerString->isValid() ); @@ -173,9 +165,9 @@ void TestQgsGpsIntegration::testGpsOptionsTimeZoneWidgets() // Check tz combo QgsGpsOptionsWidget widget( nullptr ); widget.mCboTimestampFormat->setCurrentIndex( widget.mCboTimestampFormat->findData( Qt::TimeSpec::UTC ) ); - QVERIFY( ! widget.mCboTimeZones->isEnabled() ); + QVERIFY( !widget.mCboTimeZones->isEnabled() ); widget.mCboTimestampFormat->setCurrentIndex( widget.mCboTimestampFormat->findData( Qt::TimeSpec::LocalTime ) ); - QVERIFY( ! widget.mCboTimeZones->isEnabled() ); + QVERIFY( !widget.mCboTimeZones->isEnabled() ); widget.mCboTimestampFormat->setCurrentIndex( widget.mCboTimestampFormat->findData( Qt::TimeSpec::TimeZone ) ); QVERIFY( widget.mCboTimeZones->isEnabled() ); } @@ -198,11 +190,11 @@ void TestQgsGpsIntegration::testStorePreferredFields() QgsProject::instance()->gpsSettings()->setDestinationTimeStampField( tempGpkgLayerPointString, QStringLiteral( "datetimef" ) ); mQgisApp->setActiveLayer( tempLayer ); - QMap< QString, QString > preferredTimeStamps = QgsProject::instance()->gpsSettings()->destinationTimeStampFields(); + QMap preferredTimeStamps = QgsProject::instance()->gpsSettings()->destinationTimeStampFields(); QVERIFY( preferredTimeStamps.contains( tempLayerString->id() ) ); - QCOMPARE( preferredTimeStamps[ tempLayerString->id() ], QStringLiteral( "stringf" ) ); + QCOMPARE( preferredTimeStamps[tempLayerString->id()], QStringLiteral( "stringf" ) ); QVERIFY( preferredTimeStamps.contains( tempLayerDateTime->id() ) ); - QCOMPARE( preferredTimeStamps[ tempLayerDateTime->id() ], QStringLiteral( "datetimef" ) ); + QCOMPARE( preferredTimeStamps[tempLayerDateTime->id()], QStringLiteral( "datetimef" ) ); } void TestQgsGpsIntegration::testTimestamp() @@ -238,7 +230,7 @@ void TestQgsGpsIntegration::testTimestamp() gpsDigitizing.mTimeStampSpec = Qt::TimeSpec::OffsetFromUTC; dt = gpsDigitizing.timestamp( tempLayerDateTime, fieldIdx ); QCOMPARE( dt.toDateTime().offsetFromUtc(), -36000 ); - QDateTime expected = dateTime.addSecs( - 36000 ); + QDateTime expected = dateTime.addSecs( -36000 ); expected.setOffsetFromUtc( -36000 ); QCOMPARE( dt.toDateTime(), expected ); @@ -302,54 +294,48 @@ void TestQgsGpsIntegration::testTimestampWrite() const QDateTime offsetFromUtcTime = dateTime.toOffsetFromUtc( -36000 ); // Test write on datetime field - QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::UTC ), dateTime ); - QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::OffsetFromUTC ), offsetFromUtcTime ); - QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::LocalTime ), localTime ); - QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::TimeZone ), tzTime ); + QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::UTC ), dateTime ); + QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::OffsetFromUTC ), offsetFromUtcTime ); + QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::LocalTime ), localTime ); + QCOMPARE( _testWrite( tempLayerDateTime, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::TimeZone ), tzTime ); // Test write on string field - QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::UTC ).toString( Qt::DateFormat::ISODate ), dateTime.toString( Qt::DateFormat::ISODate ) ); - QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::OffsetFromUTC ).toString( Qt::DateFormat::ISODate ), offsetFromUtcTime.toString( Qt::DateFormat::ISODate ) ); - QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::LocalTime ).toString( Qt::DateFormat::ISODate ), localTime.toString( Qt::DateFormat::ISODate ) ); - QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::TimeZone ).toString( Qt::DateFormat::ISODate ), tzTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::UTC ).toString( Qt::DateFormat::ISODate ), dateTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::OffsetFromUTC ).toString( Qt::DateFormat::ISODate ), offsetFromUtcTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::LocalTime ).toString( Qt::DateFormat::ISODate ), localTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::TimeZone ).toString( Qt::DateFormat::ISODate ), tzTime.toString( Qt::DateFormat::ISODate ) ); // Test write on line string field gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 1, 2 ) ); gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 3, 4 ) ); - QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::UTC ).toString( Qt::DateFormat::ISODate ), dateTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::UTC ).toString( Qt::DateFormat::ISODate ), dateTime.toString( Qt::DateFormat::ISODate ) ); gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 1, 2 ) ); gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 3, 4 ) ); - QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::OffsetFromUTC ).toString( Qt::DateFormat::ISODate ), offsetFromUtcTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::OffsetFromUTC ).toString( Qt::DateFormat::ISODate ), offsetFromUtcTime.toString( Qt::DateFormat::ISODate ) ); gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 1, 2 ) ); gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 3, 4 ) ); - QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::LocalTime ).toString( Qt::DateFormat::ISODate ), localTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::LocalTime ).toString( Qt::DateFormat::ISODate ), localTime.toString( Qt::DateFormat::ISODate ) ); gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 1, 2 ) ); gpsDigitizing.mCaptureListWgs84.push_back( QgsPoint( 3, 4 ) ); - QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::TimeZone ).toString( Qt::DateFormat::ISODate ), tzTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempLayerLineString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::TimeZone ).toString( Qt::DateFormat::ISODate ), tzTime.toString( Qt::DateFormat::ISODate ) ); // Write on GPKG // Test write on datetime field QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::UTC, true ), dateTime ); QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::OffsetFromUTC, true ), offsetFromUtcTime ); QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::LocalTime, true ), localTime ); - QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::TimeZone, true ), tzTime ); + QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "datetimef" ), Qt::TimeSpec::TimeZone, true ), tzTime ); // Test write on string field - QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), - Qt::TimeSpec::UTC, true ).toString( Qt::DateFormat::ISODate ), dateTime.toString( Qt::DateFormat::ISODate ) ); - QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), - Qt::TimeSpec::OffsetFromUTC, true ).toString( Qt::DateFormat::ISODate ), offsetFromUtcTime.toString( Qt::DateFormat::ISODate ) ); - QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), - Qt::TimeSpec::LocalTime, true ).toString( Qt::DateFormat::ISODate ), localTime.toString( Qt::DateFormat::ISODate ) ); - QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), - Qt::TimeSpec::TimeZone, true ).toString( Qt::DateFormat::ISODate ), tzTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::UTC, true ).toString( Qt::DateFormat::ISODate ), dateTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::OffsetFromUTC, true ).toString( Qt::DateFormat::ISODate ), offsetFromUtcTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::LocalTime, true ).toString( Qt::DateFormat::ISODate ), localTime.toString( Qt::DateFormat::ISODate ) ); + QCOMPARE( _testWrite( tempGpkgLayerPointString, gpsDigitizing, QStringLiteral( "stringf" ), Qt::TimeSpec::TimeZone, true ).toString( Qt::DateFormat::ISODate ), tzTime.toString( Qt::DateFormat::ISODate ) ); } void TestQgsGpsIntegration::testMultiPartLayers() { - QgsVectorLayer *multiLineString = new QgsVectorLayer( QStringLiteral( "MultiLinestring?crs=epsg:4326&field=intf:int&field=stringf:string" ), - QStringLiteral( "vl4" ), - QStringLiteral( "memory" ) ); + QgsVectorLayer *multiLineString = new QgsVectorLayer( QStringLiteral( "MultiLinestring?crs=epsg:4326&field=intf:int&field=stringf:string" ), QStringLiteral( "vl4" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( multiLineString ); QgsMapCanvas *canvas = mQgisApp->mapCanvas(); @@ -377,9 +363,7 @@ void TestQgsGpsIntegration::testMultiPartLayers() multiLineString->rollBack(); // multipolygon - QgsVectorLayer *multiPolygon = new QgsVectorLayer( QStringLiteral( "MultiPolygon?crs=epsg:4326&field=intf:int&field=stringf:string" ), - QStringLiteral( "vl4" ), - QStringLiteral( "memory" ) ); + QgsVectorLayer *multiPolygon = new QgsVectorLayer( QStringLiteral( "MultiPolygon?crs=epsg:4326&field=intf:int&field=stringf:string" ), QStringLiteral( "vl4" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( multiPolygon ); mQgisApp->setActiveLayer( multiPolygon ); @@ -436,9 +420,7 @@ void TestQgsGpsIntegration::testFollowActiveLayer() void TestQgsGpsIntegration::testTrackDistance() { - QgsVectorLayer *lineString = new QgsVectorLayer( QStringLiteral( "Linestring?crs=epsg:4326&field=intf:int&field=stringf:string" ), - QStringLiteral( "vl" ), - QStringLiteral( "memory" ) ); + QgsVectorLayer *lineString = new QgsVectorLayer( QStringLiteral( "Linestring?crs=epsg:4326&field=intf:int&field=stringf:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( lineString ); QgsMapCanvas *canvas = mQgisApp->mapCanvas(); diff --git a/tests/src/app/testqgsidentify.cpp b/tests/src/app/testqgsidentify.cpp index 58392b46e1a9..856d5077c15c 100644 --- a/tests/src/app/testqgsidentify.cpp +++ b/tests/src/app/testqgsidentify.cpp @@ -51,21 +51,21 @@ class TestQgsIdentify : public QObject TestQgsIdentify() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. - void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. - void lengthCalculation(); //test calculation of derived length attributes - void perimeterCalculation(); //test calculation of derived perimeter attribute - void areaCalculation(); //test calculation of derived area attribute + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void lengthCalculation(); //test calculation of derived length attributes + void perimeterCalculation(); //test calculation of derived perimeter attribute + void areaCalculation(); //test calculation of derived area attribute void identifyRasterFloat32(); // test pixel identification and decimal precision void identifyRasterFloat64(); // test pixel identification and decimal precision void identifyRasterTemporal(); void identifyRasterDerivedAttributes(); // test derived pixel attributes - void identifyMesh(); // test identification for mesh layer - void identifyVectorTile(); // test identification for vector tile layer - void identifyInvalidPolygons(); // test selecting invalid polygons - void clickxy(); // test if click_x and click_y variables are propagated + void identifyMesh(); // test identification for mesh layer + void identifyVectorTile(); // test identification for vector tile layer + void identifyInvalidPolygons(); // test selecting invalid polygons + void clickxy(); // test if click_x and click_y variables are propagated void closestPoint(); void testRelations(); void testPointZ(); @@ -88,7 +88,7 @@ class TestQgsIdentify : public QObject // Release return with delete [] unsigned char * - hex2bytes( const char *hex, int *size ) + hex2bytes( const char *hex, int *size ) { QByteArray ba = QByteArray::fromHex( hex ); unsigned char *out = new unsigned char[ba.size()]; @@ -186,13 +186,13 @@ void TestQgsIdentify::doAction() void TestQgsIdentify::clickxy() { // create temp layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3111" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3111" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); // add feature QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); const QgsPointXY wordPoint( 2484588, 2425722 ); - const QgsGeometry geom = QgsGeometry::fromPointXY( wordPoint ) ; + const QgsGeometry geom = QgsGeometry::fromPointXY( wordPoint ); f1.setGeometry( geom ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -219,8 +219,7 @@ void TestQgsIdentify::clickxy() // simulate a click on the canvas const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); const QPoint point = QPoint( mapPoint.x(), mapPoint.y() ); - QMouseEvent releases( QEvent::MouseButtonRelease, point, - Qt::RightButton, Qt::LeftButton, Qt::NoModifier ); + QMouseEvent releases( QEvent::MouseButtonRelease, point, Qt::RightButton, Qt::LeftButton, Qt::NoModifier ); QgsMapMouseEvent mapReleases( nullptr, &releases ); // simulate a click on the corresponding action @@ -234,7 +233,7 @@ void TestQgsIdentify::closestPoint() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineStringZM?crs=epsg:3111&field=pk:int&field=col1:double&field=url:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineStringZM?crs=epsg:3111&field=pk:int&field=col1:double&field=url:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -242,7 +241,7 @@ void TestQgsIdentify::closestPoint() f1.setAttribute( QStringLiteral( "url" ), QStringLiteral( "home: http://qgis.org" ) ); QgsPolylineXY line3111; line3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ); - const QgsGeometry line3111G = QgsGeometry::fromWkt( QStringLiteral( "LineStringZM( 2484588 2425722 11 31, 2484588 2398853 15 37)" ) ) ; + const QgsGeometry line3111G = QgsGeometry::fromWkt( QStringLiteral( "LineStringZM( 2484588 2425722 11 31, 2484588 2398853 15 37)" ) ); f1.setGeometry( line3111G ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -256,7 +255,7 @@ void TestQgsIdentify::closestPoint() QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484587, 2399800 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); QgsIdentifyResultsDialog *dlg = action->resultsDialog(); //check that closest point attributes are present @@ -307,7 +306,7 @@ void TestQgsIdentify::closestPoint() // polygons //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer2( new QgsVectorLayer( QStringLiteral( "PolygonZM?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer2( new QgsVectorLayer( QStringLiteral( "PolygonZM?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer2->isValid() ); f1 = QgsFeature( tempLayer2->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -326,8 +325,7 @@ void TestQgsIdentify::closestPoint() QCOMPARE( result.at( 0 ).mDerivedAttributes[tr( "Interpolated Z" )].left( 4 ), QStringLiteral( "1.96" ) ); QgsProject::instance()->displaySettings()->setCoordinateAxisOrder( Qgis::CoordinateOrder::YX ); - result = action->identify( static_cast< int >( mapPoint.x() ), - static_cast< int >( mapPoint.y() ), QList() << tempLayer2.get() ); + result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << tempLayer2.get() ); QCOMPARE( result.length(), 1 ); QCOMPARE( result.at( 0 ).mDerivedAttributes[tr( "Closest X" )], QStringLiteral( "2484588.000" ) ); QCOMPARE( result.at( 0 ).mDerivedAttributes[tr( "Closest Y" )], QStringLiteral( "2399800.000" ) ); @@ -339,14 +337,14 @@ void TestQgsIdentify::lengthCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); f1.setAttribute( QStringLiteral( "col1" ), 0.0 ); QgsPolylineXY line3111; line3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ); - const QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ) ; + const QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ); f1.setGeometry( line3111G ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -363,7 +361,7 @@ void TestQgsIdentify::lengthCalculation() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedLength = result.at( 0 ).mDerivedAttributes[tr( "Length (Ellipsoidal — WGS84)" )]; @@ -408,7 +406,7 @@ void TestQgsIdentify::lengthCalculation() QGSCOMPARENEAR( length, 26930.6, 0.1 ); // LineString with Z - tempLayer = std::make_unique< QgsVectorLayer>( QStringLiteral( "LineStringZ?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + tempLayer = std::make_unique( QStringLiteral( "LineStringZ?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); f1.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineStringZ(2484588 2425722 10, 2482767 2398853 1000)" ) ) ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -425,7 +423,7 @@ void TestQgsIdentify::lengthCalculation() QGSCOMPARENEAR( length, 26948.827000, 0.1 ); // CircularString with Z (no length 3d for now, not supported by circular string API) - tempLayer = std::make_unique< QgsVectorLayer>( QStringLiteral( "CircularStringZ?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + tempLayer = std::make_unique( QStringLiteral( "CircularStringZ?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); f1.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "CircularStringZ(2484588 2425722 10, 2483588 2429722 10, 2482767 2398853 1000)" ) ) ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -439,7 +437,7 @@ void TestQgsIdentify::lengthCalculation() QGSCOMPARENEAR( length, 288140.206, 0.1 ); // MultiLineString with Z - tempLayer = std::make_unique< QgsVectorLayer>( QStringLiteral( "MultiLineStringZ?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + tempLayer = std::make_unique( QStringLiteral( "MultiLineStringZ?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( tempLayer->isValid() ); f1.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "MultiLineStringZ((2484588 2425722 10, 2482767 2398853 1000), (2494588 2435722 10, 2422767 2318853 1000))" ) ) ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -454,7 +452,6 @@ void TestQgsIdentify::lengthCalculation() derivedLength = result.at( 0 ).mDerivedAttributes[tr( "Length (Cartesian — 3D)" )]; length = derivedLength.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); QGSCOMPARENEAR( length, 164126.083, 0.1 ); - } void TestQgsIdentify::perimeterCalculation() @@ -463,7 +460,7 @@ void TestQgsIdentify::perimeterCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -472,7 +469,7 @@ void TestQgsIdentify::perimeterCalculation() polygonRing3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ) << QgsPointXY( 2520109, 2397715 ) << QgsPointXY( 2520792, 2425494 ) << QgsPointXY( 2484588, 2425722 ); QgsPolygonXY polygon3111; polygon3111 << polygonRing3111; - const QgsGeometry polygon3111G = QgsGeometry::fromPolygonXY( polygon3111 ) ; + const QgsGeometry polygon3111G = QgsGeometry::fromPolygonXY( polygon3111 ); f1.setGeometry( polygon3111G ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -489,7 +486,7 @@ void TestQgsIdentify::perimeterCalculation() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedPerimeter = result.at( 0 ).mDerivedAttributes[tr( "Perimeter (Ellipsoidal — WGS84)" )]; @@ -540,7 +537,7 @@ void TestQgsIdentify::areaCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -550,7 +547,7 @@ void TestQgsIdentify::areaCalculation() polygonRing3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ) << QgsPointXY( 2520109, 2397715 ) << QgsPointXY( 2520792, 2425494 ) << QgsPointXY( 2484588, 2425722 ); QgsPolygonXY polygon3111; polygon3111 << polygonRing3111; - const QgsGeometry polygon3111G = QgsGeometry::fromPolygonXY( polygon3111 ) ; + const QgsGeometry polygon3111G = QgsGeometry::fromPolygonXY( polygon3111 ); f1.setGeometry( polygon3111G ); tempLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); @@ -567,7 +564,7 @@ void TestQgsIdentify::areaCalculation() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area (Ellipsoidal — WGS84)" )]; @@ -616,7 +613,7 @@ void TestQgsIdentify::areaCalculation() // private QList TestQgsIdentify::testIdentifyRaster( QgsRasterLayer *layer, double xGeoref, double yGeoref, bool roundToCanvasPixels ) { - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QgsIdentifyContext identifyContext; @@ -626,13 +623,13 @@ QList TestQgsIdentify::testIdentifyRaster( Q if ( roundToCanvasPixels ) return action->identify( mapPoint.x(), mapPoint.y(), QList() << layer, QgsMapToolIdentify::DefaultQgsSetting, identifyContext ); else - return action->identify( QgsGeometry::fromPointXY( QgsPointXY( xGeoref, yGeoref ) ), QgsMapToolIdentify::DefaultQgsSetting, {layer}, QgsMapToolIdentify::AllLayers, identifyContext ); + return action->identify( QgsGeometry::fromPointXY( QgsPointXY( xGeoref, yGeoref ) ), QgsMapToolIdentify::DefaultQgsSetting, { layer }, QgsMapToolIdentify::AllLayers, identifyContext ); } // private QList TestQgsIdentify::testIdentifyMesh( QgsMeshLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); //check that closest point attributes are present QgsIdentifyContext identifyContext; @@ -644,9 +641,9 @@ QList TestQgsIdentify::testIdentifyMesh( Qgs // private QList -TestQgsIdentify::testIdentifyVector( QgsVectorLayer *layer, double xGeoref, double yGeoref ) + TestQgsIdentify::testIdentifyVector( QgsVectorLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QgsIdentifyContext identifyContext; if ( canvas->mapSettings().isTemporal() ) @@ -657,9 +654,9 @@ TestQgsIdentify::testIdentifyVector( QgsVectorLayer *layer, double xGeoref, doub // private QList -TestQgsIdentify::testIdentifyVectorTile( QgsVectorTileLayer *layer, double xGeoref, double yGeoref ) + TestQgsIdentify::testIdentifyVectorTile( QgsVectorTileLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QgsIdentifyContext identifyContext; if ( canvas->mapSettings().isTemporal() ) @@ -672,26 +669,23 @@ void TestQgsIdentify::identifyRasterTemporal() { //create a temporary layer const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/test.asc"; - std::unique_ptr< QgsRasterLayer> tempLayer = std::make_unique< QgsRasterLayer >( raster ); + std::unique_ptr tempLayer = std::make_unique( raster ); QVERIFY( tempLayer->isValid() ); // activate temporal properties tempLayer->temporalProperties()->setIsActive( true ); - const QgsDateTimeRange range = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime(), Qt::UTC ), - QDateTime( QDate( 2020, 3, 31 ), QTime(), Qt::UTC ) ); - qobject_cast< QgsRasterLayerTemporalProperties * >( tempLayer->temporalProperties() )->setFixedTemporalRange( range ); + const QgsDateTimeRange range = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime(), Qt::UTC ), QDateTime( QDate( 2020, 3, 31 ), QTime(), Qt::UTC ) ); + qobject_cast( tempLayer->temporalProperties() )->setFixedTemporalRange( range ); canvas->setExtent( QgsRectangle( 0, 0, 7, 1 ) ); // invalid temporal range on canvas - canvas->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), - QDateTime( QDate( 1950, 01, 01 ), QTime( 1, 0, 0 ), Qt::UTC ) ) ); + canvas->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), QDateTime( QDate( 1950, 01, 01 ), QTime( 1, 0, 0 ), Qt::UTC ) ) ); QCOMPARE( testIdentifyRaster( tempLayer.get(), 0.5, 0.5 ).length(), 0 ); // valid temporal range on canvas - canvas->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), - QDateTime( QDate( 2050, 01, 01 ), QTime( 1, 0, 0 ), Qt::UTC ) ) ); + canvas->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), QDateTime( QDate( 2050, 01, 01 ), QTime( 1, 0, 0 ), Qt::UTC ) ) ); QCOMPARE( testIdentifyRaster( tempLayer.get(), 0.5, 0.5 ).at( 0 ).mAttributes[QStringLiteral( "Band 1" )], QString( "-999.9" ) ); } @@ -702,7 +696,7 @@ void TestQgsIdentify::identifyRasterFloat32() // By default the QgsRasterLayer forces AAIGRID_DATATYPE=Float64 CPLSetConfigOption( "AAIGRID_DATATYPE", "Float32" ); - std::unique_ptr< QgsRasterLayer> tempLayer( new QgsRasterLayer( raster ) ); + std::unique_ptr tempLayer( new QgsRasterLayer( raster ) ); CPLSetConfigOption( "AAIGRID_DATATYPE", nullptr ); QVERIFY( tempLayer->isValid() ); @@ -734,7 +728,7 @@ void TestQgsIdentify::identifyRasterFloat64() { //create a temporary layer const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/test.asc"; - std::unique_ptr< QgsRasterLayer> tempLayer( new QgsRasterLayer( raster ) ); + std::unique_ptr tempLayer( new QgsRasterLayer( raster ) ); QVERIFY( tempLayer->isValid() ); canvas->setExtent( QgsRectangle( 0, 0, 7, 1 ) ); @@ -757,14 +751,14 @@ void TestQgsIdentify::identifyRasterFloat64() void TestQgsIdentify::identifyRasterDerivedAttributes() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/dem.tif"; - std::unique_ptr< QgsRasterLayer> tempLayer( new QgsRasterLayer( raster ) ); + std::unique_ptr tempLayer( new QgsRasterLayer( raster ) ); QVERIFY( tempLayer->isValid() ); const QgsRectangle layerExtent = tempLayer->extent(); const double halfColumn = tempLayer->rasterUnitsPerPixelX() * 0.5; const double halfRow = tempLayer->rasterUnitsPerPixelY() * 0.5; - canvas->resize( tempLayer->width(), tempLayer->height() ); // make canvas fit raster 1:1 + canvas->resize( tempLayer->width(), tempLayer->height() ); // make canvas fit raster 1:1 canvas->setDestinationCrs( tempLayer->crs() ); canvas->setExtent( layerExtent ); @@ -773,56 +767,56 @@ void TestQgsIdentify::identifyRasterDerivedAttributes() // right at corner of raster results = testIdentifyRaster( tempLayer.get(), layerExtent.xMinimum() + 0.0000000001, layerExtent.yMaximum() - 0.0000000001, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString( "0" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString( "0" ) ); // offset by half a pixel results = testIdentifyRaster( tempLayer.get(), layerExtent.xMinimum() + halfColumn, layerExtent.yMaximum() - halfRow, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString( "0" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString( "0" ) ); // right at corner of raster results = testIdentifyRaster( tempLayer.get(), layerExtent.xMaximum() - 0.0000000001, layerExtent.yMaximum() - 0.0000000001, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString::number( tempLayer->width() - 1 ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString( "0" ) ); // offset by half a pixel results = testIdentifyRaster( tempLayer.get(), layerExtent.xMaximum() - halfColumn, layerExtent.yMaximum() - halfRow, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString::number( tempLayer->width() - 1 ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString( "0" ) ); // right at corner of raster results = testIdentifyRaster( tempLayer.get(), layerExtent.xMinimum() + 0.0000000001, layerExtent.yMinimum() + 0.0000000001, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString( "0" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString::number( tempLayer->height() - 1 ) ); // offset by half a pixel results = testIdentifyRaster( tempLayer.get(), layerExtent.xMinimum() + halfColumn, layerExtent.yMinimum() + halfRow, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString( "0" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString::number( tempLayer->height() - 1 ) ); // right at corner of raster results = testIdentifyRaster( tempLayer.get(), layerExtent.xMaximum() - 0.0000000001, layerExtent.yMinimum() + 0.0000000001, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString::number( tempLayer->width() - 1 ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString::number( tempLayer->height() - 1 ) ); // offset by half a pixel results = testIdentifyRaster( tempLayer.get(), layerExtent.xMaximum() - halfColumn, layerExtent.yMinimum() + halfRow, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString::number( tempLayer->width() - 1 ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString::number( tempLayer->height() - 1 ) ); const double xSomewhereCenter = layerExtent.xMinimum() + halfColumn * 2 * 201; const double ySomewhereCenter = layerExtent.yMaximum() - halfRow * 2 * 141; results = testIdentifyRaster( tempLayer.get(), xSomewhereCenter, ySomewhereCenter, false ); - QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back + QCOMPARE( results.length(), 1 ); // just to ensure that we did get a result back QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Column (0-based)" )], QString( "201" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Row (0-based)" )], QString( "141" ) ); } @@ -836,8 +830,11 @@ void TestQgsIdentify::identifyMesh() const QString vectorDs = QStringLiteral( TEST_DATA_DIR ) + "/mesh/quad_and_triangle_vertex_vector.dat"; tempLayer->dataProvider()->addDataset( vectorDs ); static_cast( - tempLayer->temporalProperties() )->setReferenceTime( - QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), tempLayer->dataProvider()->temporalCapabilities() ); + tempLayer->temporalProperties() + ) + ->setReferenceTime( + QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), tempLayer->dataProvider()->temporalCapabilities() + ); // we need to setup renderer otherwise triangular mesh // will not be populated and identify will not work @@ -857,12 +854,12 @@ void TestQgsIdentify::identifyMesh() results = testIdentifyMesh( tempLayer, 500, 500 ); QCOMPARE( results.size(), 2 ); - QCOMPARE( results[0].mAttributes[ QStringLiteral( "Scalar Value" )], QStringLiteral( "no data" ) ); + QCOMPARE( results[0].mAttributes[QStringLiteral( "Scalar Value" )], QStringLiteral( "no data" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Source" )], mesh ); QCOMPARE( results[1].mLabel, QStringLiteral( "Geometry" ) ); results = testIdentifyMesh( tempLayer, 2400, 2400 ); QCOMPARE( results.size(), 2 ); - QCOMPARE( results[0].mAttributes[ QStringLiteral( "Scalar Value" )], QStringLiteral( "42" ) ); + QCOMPARE( results[0].mAttributes[QStringLiteral( "Scalar Value" )], QStringLiteral( "42" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Source" )], mesh ); QCOMPARE( results[1].mLabel, QStringLiteral( "Geometry" ) ); QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Face Centroid X" )], QStringLiteral( "2333.33" ) ); @@ -871,23 +868,22 @@ void TestQgsIdentify::identifyMesh() QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Snapped Vertex Position X" )], QStringLiteral( "2000" ) ); QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Snapped Vertex Position Y" )], QStringLiteral( "3000" ) ); - canvas->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), - QDateTime( QDate( 1950, 01, 01 ), QTime( 1, 0, 0 ), Qt::UTC ) ) ); + canvas->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 1950, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), QDateTime( QDate( 1950, 01, 01 ), QTime( 1, 0, 0 ), Qt::UTC ) ) ); tempLayer->temporalProperties()->setIsActive( true ); results = testIdentifyMesh( tempLayer, 2400, 2400 ); QCOMPARE( results.size(), 3 ); QCOMPARE( results[0].mLabel, QStringLiteral( "Bed Elevation (active)" ) ); - QCOMPARE( results[0].mAttributes[ QStringLiteral( "Scalar Value" )], QStringLiteral( "42" ) ); + QCOMPARE( results[0].mAttributes[QStringLiteral( "Scalar Value" )], QStringLiteral( "42" ) ); QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Source" )], mesh ); - QCOMPARE( results[1].mDerivedAttributes[ QStringLiteral( "Time Step" )], QStringLiteral( "1950-01-01 00:00:00" ) ); + QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Time Step" )], QStringLiteral( "1950-01-01 00:00:00" ) ); QCOMPARE( results[1].mLabel, QStringLiteral( "VertexVectorDataset" ) ); QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Source" )], vectorDs ); - QCOMPARE( results[1].mAttributes[ QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); - QCOMPARE( results[1].mDerivedAttributes[ QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); - QCOMPARE( results[1].mDerivedAttributes[ QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); + QCOMPARE( results[1].mAttributes[QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); + QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); + QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); QCOMPARE( results[2].mLabel, QStringLiteral( "Geometry" ) ); QCOMPARE( results[2].mDerivedAttributes[QStringLiteral( "Face Centroid X" )], QStringLiteral( "2333.33" ) ); @@ -903,31 +899,31 @@ void TestQgsIdentify::identifyMesh() tempLayer->setStaticVectorDatasetIndex( QgsMeshDatasetIndex( 1, 0 ) ); results = testIdentifyMesh( tempLayer, 500, 500 ); QCOMPARE( results.size(), 2 ); - QCOMPARE( results[0].mAttributes[ QStringLiteral( "Vector Value" )], QStringLiteral( "no data" ) ); + QCOMPARE( results[0].mAttributes[QStringLiteral( "Vector Value" )], QStringLiteral( "no data" ) ); results = testIdentifyMesh( tempLayer, 2400, 2400 ); QCOMPARE( results.size(), 2 ); - QCOMPARE( results[0].mAttributes[ QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); - QCOMPARE( results[0].mDerivedAttributes[ QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); - QCOMPARE( results[0].mDerivedAttributes[ QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); + QCOMPARE( results[0].mAttributes[QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); + QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); + QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); // scalar + vector different tempLayer->setStaticScalarDatasetIndex( QgsMeshDatasetIndex( 0, 0 ) ); tempLayer->setStaticVectorDatasetIndex( QgsMeshDatasetIndex( 1, 0 ) ); results = testIdentifyMesh( tempLayer, 2400, 2400 ); QCOMPARE( results.size(), 3 ); - QCOMPARE( results[0].mAttributes[ QStringLiteral( "Scalar Value" )], QStringLiteral( "42" ) ); - QCOMPARE( results[1].mAttributes[ QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); - QCOMPARE( results[1].mDerivedAttributes[ QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); - QCOMPARE( results[1].mDerivedAttributes[ QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); + QCOMPARE( results[0].mAttributes[QStringLiteral( "Scalar Value" )], QStringLiteral( "42" ) ); + QCOMPARE( results[1].mAttributes[QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); + QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); + QCOMPARE( results[1].mDerivedAttributes[QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); // only vector tempLayer->setStaticScalarDatasetIndex( QgsMeshDatasetIndex() ); tempLayer->setStaticVectorDatasetIndex( QgsMeshDatasetIndex( 1, 0 ) ); results = testIdentifyMesh( tempLayer, 2400, 2400 ); QCOMPARE( results.size(), 2 ); - QCOMPARE( results[0].mAttributes[ QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); - QCOMPARE( results[0].mDerivedAttributes[ QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); - QCOMPARE( results[0].mDerivedAttributes[ QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); + QCOMPARE( results[0].mAttributes[QStringLiteral( "Vector Magnitude" )], QStringLiteral( "3" ) ); + QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Vector x-component" )], QStringLiteral( "1.8" ) ); + QCOMPARE( results[0].mDerivedAttributes[QStringLiteral( "Vector y-component" )], QStringLiteral( "2.4" ) ); } void TestQgsIdentify::identifyVectorTile() @@ -962,15 +958,15 @@ void TestQgsIdentify::identifyVectorTile() void TestQgsIdentify::identifyInvalidPolygons() { //create a temporary layer - std::unique_ptr< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature f1( memoryLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); // This geometry is an invalid polygon (3 distinct vertices). // GEOS reported invalidity: Points of LinearRing do not form a closed linestring f1.setGeometry( geomFromHexWKB( - "010300000001000000030000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000" - ) ); + "010300000001000000030000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000" + ) ); // TODO: check why we need the ->dataProvider() part, since // there's a QgsVectorLayer::addFeatures method too //memoryLayer->addFeatures( QgsFeatureList() << f1 ); @@ -983,7 +979,6 @@ void TestQgsIdentify::identifyInvalidPolygons() identified = testIdentifyVector( memoryLayer.get(), 6, 4 ); QCOMPARE( identified.length(), 1 ); QCOMPARE( identified[0].mFeature.attribute( "pk" ), QVariant( 1 ) ); - } void TestQgsIdentify::testRelations() @@ -1065,7 +1060,7 @@ void TestQgsIdentify::testRelations() } std::unique_ptr dialog = std::make_unique( canvas ); - dialog->addFeature( layerA, featureA, QMap< QString, QString>() ); + dialog->addFeature( layerA, featureA, QMap() ); QCOMPARE( dialog->lstResults->topLevelItemCount(), 1 ); QTreeWidgetItem *topLevelItem = dialog->lstResults->topLevelItem( 0 ); @@ -1111,7 +1106,7 @@ void TestQgsIdentify::testRelations() QgsIdentifyResultsFeatureItem *relatedFeatureItem = dynamic_cast( relationItems[0]->child( 0 ) ); QVERIFY( relatedFeatureItem ); QVERIFY( relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).isValid() ); - const QgsFeature relatedFeature = relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value< QgsFeature >(); + const QgsFeature relatedFeature = relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value(); QCOMPARE( relatedFeature.attribute( IDX_OTHER_FIELD ), OTHER_FIELD ); { @@ -1135,7 +1130,7 @@ void TestQgsIdentify::testRelations() QgsIdentifyResultsFeatureItem *childRelatedFeatureItem = dynamic_cast( childRelationItems[0]->child( 0 ) ); QVERIFY( childRelatedFeatureItem ); QVERIFY( childRelatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).isValid() ); - const QgsFeature relatedFeature = childRelatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value< QgsFeature >(); + const QgsFeature relatedFeature = childRelatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value(); QCOMPARE( relatedFeature.attribute( 0 ), PK_ID_C ); // Check that this child doesn't link back to parent feature A @@ -1149,14 +1144,13 @@ void TestQgsIdentify::testRelations() QCOMPARE( childChildRelationItems.size(), 0 ); } } - } { QgsIdentifyResultsFeatureItem *relatedFeatureItem = dynamic_cast( relationItems[0]->child( 1 ) ); QVERIFY( relatedFeatureItem ); QVERIFY( relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).isValid() ); - const QgsFeature relatedFeature = relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value< QgsFeature >(); + const QgsFeature relatedFeature = relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value(); QCOMPARE( relatedFeature.attribute( IDX_OTHER_FIELD ), OTHER_FIELD + 1 ); } @@ -1169,14 +1163,14 @@ void TestQgsIdentify::testRelations() QgsIdentifyResultsFeatureItem *relatedFeatureItem = dynamic_cast( relationItems[1]->child( 0 ) ); QVERIFY( relatedFeatureItem ); QVERIFY( relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).isValid() ); - const QgsFeature relatedFeature = relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value< QgsFeature >(); + const QgsFeature relatedFeature = relatedFeatureItem->data( 0, QgsIdentifyResultsDialog::FeatureRole ).value(); QCOMPARE( relatedFeature.attribute( IDX_OTHER_FIELD ), OTHER_FIELD ); } } void TestQgsIdentify::testPointZ() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "PointZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "PointZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QCOMPARE( tempLayer->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:4979" ) ); @@ -1195,18 +1189,18 @@ void TestQgsIdentify::testPointZ() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 134.445567853, -23.445567853 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( static_cast< int >( mapPoint.x() ), static_cast< int >( mapPoint.y() ), QList() << tempLayer.get() ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); - double z4979 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Z (EPSG:4979 - WGS 84)" )].toDouble(); - double z4985 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Z (EPSG:4985 - WGS 72)" )].toDouble(); + double z4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z (EPSG:4979 - WGS 84)" )].toDouble(); + double z4985 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z (EPSG:4985 - WGS 72)" )].toDouble(); QGSCOMPARENEAR( z4979, 5543.325, 0.001 ); QGSCOMPARENEAR( z4985, 5545.6857, 0.01 ); } void TestQgsIdentify::testLineStringZ() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QCOMPARE( tempLayer->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:4979" ) ); @@ -1226,13 +1220,13 @@ void TestQgsIdentify::testLineStringZ() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 136.46, -23.445567853 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( static_cast< int >( mapPoint.x() ), static_cast< int >( mapPoint.y() ), QList() << tempLayer.get() ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); - double interpolatedZ4979 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Interpolated Z (EPSG:4979 - WGS 84)" )].toDouble(); - double interpolatedZ4985 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Interpolated Z (EPSG:4985 - WGS 72)" )].toDouble(); - double closestZ4979 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Closest vertex Z (EPSG:4979 - WGS 84)" )].toDouble(); - double closestZ4985 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Closest vertex Z (EPSG:4985 - WGS 72)" )].toDouble(); + double interpolatedZ4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Interpolated Z (EPSG:4979 - WGS 84)" )].toDouble(); + double interpolatedZ4985 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Interpolated Z (EPSG:4985 - WGS 72)" )].toDouble(); + double closestZ4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Closest vertex Z (EPSG:4979 - WGS 84)" )].toDouble(); + double closestZ4985 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Closest vertex Z (EPSG:4985 - WGS 72)" )].toDouble(); QGSCOMPARENEAR( interpolatedZ4979, 5548.472636, 0.001 ); QGSCOMPARENEAR( interpolatedZ4985, 5550.8333350, 0.01 ); QGSCOMPARENEAR( closestZ4979, 5543.325, 0.001 ); @@ -1241,7 +1235,7 @@ void TestQgsIdentify::testLineStringZ() void TestQgsIdentify::testPolygonZ() { - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "PolygonZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "PolygonZ?crs=epsg:4979" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QCOMPARE( tempLayer->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:4979" ) ); @@ -1261,13 +1255,13 @@ void TestQgsIdentify::testPolygonZ() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 136.46, -23.445567853 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( static_cast< int >( mapPoint.x() ), static_cast< int >( mapPoint.y() ), QList() << tempLayer.get() ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); - double interpolatedZ4979 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Interpolated Z (EPSG:4979 - WGS 84)" )].toDouble(); - double interpolatedZ4985 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Interpolated Z (EPSG:4985 - WGS 72)" )].toDouble(); - double closestZ4979 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Closest vertex Z (EPSG:4979 - WGS 84)" )].toDouble(); - double closestZ4985 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Closest vertex Z (EPSG:4985 - WGS 72)" )].toDouble(); + double interpolatedZ4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Interpolated Z (EPSG:4979 - WGS 84)" )].toDouble(); + double interpolatedZ4985 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Interpolated Z (EPSG:4985 - WGS 72)" )].toDouble(); + double closestZ4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Closest vertex Z (EPSG:4979 - WGS 84)" )].toDouble(); + double closestZ4985 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Closest vertex Z (EPSG:4985 - WGS 72)" )].toDouble(); QGSCOMPARENEAR( interpolatedZ4979, 5549.9817600000, 0.02 ); QGSCOMPARENEAR( interpolatedZ4985, 5552.3424580000, 0.02 ); QGSCOMPARENEAR( closestZ4979, 5543.325, 0.001 ); @@ -1277,7 +1271,7 @@ void TestQgsIdentify::testPolygonZ() void TestQgsIdentify::identifyPointCloud() { #ifdef HAVE_EPT - std::unique_ptr< QgsPointCloudLayer > pointCloud = std::make_unique< QgsPointCloudLayer >( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/ept/rgb16/ept.json", QStringLiteral( "pointcloud" ), QStringLiteral( "ept" ) ); + std::unique_ptr pointCloud = std::make_unique( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/ept/rgb16/ept.json", QStringLiteral( "pointcloud" ), QStringLiteral( "ept" ) ); QVERIFY( pointCloud->isValid() ); pointCloud->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4979" ) ) ); QCOMPARE( pointCloud->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:4979" ) ); @@ -1294,11 +1288,11 @@ void TestQgsIdentify::identifyPointCloud() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 7.42006, 2.74911 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( static_cast< int >( mapPoint.x() ), static_cast< int >( mapPoint.y() ), QList() << pointCloud.get() ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << pointCloud.get() ); QCOMPARE( result.length(), 1 ); - double z4979 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Z (EPSG:4979 - WGS 84)" )].toDouble(); - double z4985 = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Z (EPSG:4985 - WGS 72)" )].toDouble(); + double z4979 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z (EPSG:4979 - WGS 84)" )].toDouble(); + double z4985 = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z (EPSG:4985 - WGS 72)" )].toDouble(); QGSCOMPARENEAR( z4979, -5.79000, 0.001 ); QGSCOMPARENEAR( z4985, -5.40314874, 0.001 ); #endif @@ -1307,7 +1301,7 @@ void TestQgsIdentify::identifyPointCloud() void TestQgsIdentify::identifyVirtualPointCloud() { #ifdef HAVE_COPC - std::unique_ptr< QgsPointCloudLayer > pointCloud = std::make_unique< QgsPointCloudLayer >( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/virtual/sunshine-coast/combined.vpc", QStringLiteral( "pointcloud" ), QStringLiteral( "vpc" ) ); + std::unique_ptr pointCloud = std::make_unique( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/virtual/sunshine-coast/combined.vpc", QStringLiteral( "pointcloud" ), QStringLiteral( "vpc" ) ); QVERIFY( pointCloud->isValid() ); pointCloud->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ) ); QCOMPARE( pointCloud->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:28356" ) ); @@ -1324,17 +1318,13 @@ void TestQgsIdentify::identifyVirtualPointCloud() const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( 498065.23, 7050992.90 ); - std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( static_cast< int >( mapPoint.x() ), static_cast< int >( mapPoint.y() ), QList() << pointCloud.get() ); + std::unique_ptr action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( static_cast( mapPoint.x() ), static_cast( mapPoint.y() ), QList() << pointCloud.get() ); QCOMPARE( result.length(), 1 ); - double z = result.at( 0 ).mDerivedAttributes[ QStringLiteral( "Z" )].toDouble(); + double z = result.at( 0 ).mDerivedAttributes[QStringLiteral( "Z" )].toDouble(); QGSCOMPARENEAR( z, 74.91, 0.001 ); #endif } QGSTEST_MAIN( TestQgsIdentify ) #include "testqgsidentify.moc" - - - - diff --git a/tests/src/app/testqgslabelpropertydialog.cpp b/tests/src/app/testqgslabelpropertydialog.cpp index cd23a9bcf095..e44de4cdfaf7 100644 --- a/tests/src/app/testqgslabelpropertydialog.cpp +++ b/tests/src/app/testqgslabelpropertydialog.cpp @@ -59,8 +59,7 @@ class TestQgsLabelPropertyDialog : public QObject // init vector layer const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - QgsVectorLayer *vl = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *vl = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( vl ); // activate labeling @@ -74,14 +73,14 @@ class TestQgsLabelPropertyDialog : public QObject // create auxiliary field for BufferDraw QgsAuxiliaryLayer::createProperty( QgsPalLayerSettings::Property::BufferDraw, vl ); - const QgsPropertyDefinition def = QgsPalLayerSettings::propertyDefinitions()[static_cast< int >( QgsPalLayerSettings::Property::BufferDraw )]; + const QgsPropertyDefinition def = QgsPalLayerSettings::propertyDefinitions()[static_cast( QgsPalLayerSettings::Property::BufferDraw )]; const QString propName = QgsAuxiliaryLayer::nameFromProperty( def, true ); QCOMPARE( int( al->featureCount() ), 0 ); const QgsFeatureId fid = 0; QVariant val = vl->getFeature( fid ).attribute( propName ); - const std::unique_ptr< QgsMapCanvas > mapCanvas = std::make_unique< QgsMapCanvas >(); + const std::unique_ptr mapCanvas = std::make_unique(); // init label property dialog and togle buffer draw QgsLabelPropertyDialog dialog( vl->id(), QString(), fid, QFont(), QString(), false, settings, mapCanvas.get() ); diff --git a/tests/src/app/testqgslayerpropertiesdialogs.cpp b/tests/src/app/testqgslayerpropertiesdialogs.cpp index 33783d841014..37bdd60e65ab 100644 --- a/tests/src/app/testqgslayerpropertiesdialogs.cpp +++ b/tests/src/app/testqgslayerpropertiesdialogs.cpp @@ -43,10 +43,9 @@ class DummySourceWidget : public QgsProviderSourceWidget { Q_OBJECT public: - - DummySourceWidget( QWidget *parent ) : QgsProviderSourceWidget( parent ) + DummySourceWidget( QWidget *parent ) + : QgsProviderSourceWidget( parent ) { - } void setSourceUri( const QString &uri ) override { Q_UNUSED( uri ); } @@ -57,7 +56,6 @@ class DummySourceWidget : public QgsProviderSourceWidget } QString newSource; - }; class TestQgsLayerPropertiesDialogs : public QgsTest @@ -95,8 +93,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest // valid vector layer const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + std::unique_ptr vl = std::make_unique( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QVERIFY( vl->isValid() ); QgsMapCanvas canvas; @@ -111,8 +108,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest // invalid vector layer const QString pointFileName = mTestDataDir + "xxpoints.shp"; const QFileInfo pointFileInfo( pointFileName ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "xxogr" ) ); + std::unique_ptr vl = std::make_unique( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "xxogr" ) ); QVERIFY( !vl->isValid() ); QgsMapCanvas canvas; @@ -127,8 +123,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest // start with a point layer const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + std::unique_ptr vl = std::make_unique( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QVERIFY( vl->isValid() ); vl->setSubsetString( QStringLiteral( "\"class\"='Biplane'" ) ); QCOMPARE( vl->subsetString(), QStringLiteral( "\"class\"='Biplane'" ) ); @@ -185,12 +180,11 @@ class TestQgsLayerPropertiesDialogs : public QgsTest // start with a point layer const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + std::unique_ptr vl = std::make_unique( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QVERIFY( vl->isValid() ); // point layer should have a marker symbol vl->setRenderer( new QgsSingleSymbolRenderer( new QgsMarkerSymbol() ) ); - QCOMPARE( dynamic_cast< QgsSingleSymbolRenderer * >( vl->renderer() )->symbol()->type(), Qgis::SymbolType::Marker ); + QCOMPARE( dynamic_cast( vl->renderer() )->symbol()->type(), Qgis::SymbolType::Marker ); // no change to data source QgsMapCanvas canvas; @@ -202,7 +196,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest } // renderer should still be a marker type - QCOMPARE( dynamic_cast< QgsSingleSymbolRenderer * >( vl->renderer() )->symbol()->type(), Qgis::SymbolType::Marker ); + QCOMPARE( dynamic_cast( vl->renderer() )->symbol()->type(), Qgis::SymbolType::Marker ); // change the data source to a line layer: { @@ -219,7 +213,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest // single symbol renderer with marker symbol would be nonsense now, we expected a line symbol // ie the settings for the renderer which were present in the dialog MUST be ignored and overwritten // by the logic which triggers when the geometry type is changed via a data source change - QCOMPARE( dynamic_cast< QgsSingleSymbolRenderer * >( vl->renderer() )->symbol()->type(), Qgis::SymbolType::Line ); + QCOMPARE( dynamic_cast( vl->renderer() )->symbol()->type(), Qgis::SymbolType::Line ); } void testValidRasterProperties() @@ -228,7 +222,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest QTemporaryDir tmpDir; QFile::copy( mTestDataDir + "landsat_4326.tif", tmpDir.filePath( QStringLiteral( "landsat_4326.tif" ) ) ); const QString rasterFileName = tmpDir.filePath( QStringLiteral( "landsat_4326.tif" ) ); - std::unique_ptr< QgsRasterLayer > rl = std::make_unique< QgsRasterLayer >( rasterFileName, QStringLiteral( "test" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "test" ), QStringLiteral( "gdal" ) ); QVERIFY( rl->isValid() ); QgsMapCanvas canvas; @@ -242,7 +236,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest { // invalid raster layer const QString rasterFileName = mTestDataDir + "xxlandsat_4326.tif"; - std::unique_ptr< QgsRasterLayer > rl = std::make_unique< QgsRasterLayer >( rasterFileName, QStringLiteral( "test" ), QStringLiteral( "xxgdal" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "test" ), QStringLiteral( "xxgdal" ) ); QVERIFY( !rl->isValid() ); QgsMapCanvas canvas; @@ -256,7 +250,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest { // valid mesh layer QString uri( mTestDataDir + "/mesh/quad_and_triangle.2dm" ); - std::unique_ptr< QgsMeshLayer > ml = std::make_unique< QgsMeshLayer >( uri, QStringLiteral( "test" ), QStringLiteral( "mdal" ) ); + std::unique_ptr ml = std::make_unique( uri, QStringLiteral( "test" ), QStringLiteral( "mdal" ) ); QVERIFY( ml->isValid() ); QgsMapCanvas canvas; @@ -270,7 +264,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest { // invalid mesh layer QString uri( mTestDataDir + "/mesh/xxquad_and_triangle.2dm" ); - std::unique_ptr< QgsMeshLayer > ml = std::make_unique< QgsMeshLayer >( uri, QStringLiteral( "test" ), QStringLiteral( "xmdal" ) ); + std::unique_ptr ml = std::make_unique( uri, QStringLiteral( "test" ), QStringLiteral( "xmdal" ) ); QVERIFY( !ml->isValid() ); QgsMapCanvas canvas; @@ -283,7 +277,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest void testValidPointCloudProperties() { // valid point cloud layer - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( mTestDataDir + QStringLiteral( "point_clouds/ept/sunshine-coast/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( mTestDataDir + QStringLiteral( "point_clouds/ept/sunshine-coast/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); QgsMapCanvas canvas; @@ -296,7 +290,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest void testInvalidPointCloudProperties() { // invalid point cloud layer - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( mTestDataDir + QStringLiteral( "xxpoint_clouds/ept/sunshine-coast/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "xxept" ) ); + std::unique_ptr layer = std::make_unique( mTestDataDir + QStringLiteral( "xxpoint_clouds/ept/sunshine-coast/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "xxept" ) ); QVERIFY( !layer->isValid() ); QgsMapCanvas canvas; @@ -310,7 +304,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest { // valid vector tile layer const QString srcMbtiles = QStringLiteral( "type=mbtiles&url=%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( srcMbtiles ); + std::unique_ptr layer = std::make_unique( srcMbtiles ); QVERIFY( layer->isValid() ); QgsMapCanvas canvas; @@ -324,7 +318,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest { // invalid vector tile layer const QString srcMbtiles = QStringLiteral( "type=mbtiles&url=%1/vector_tile/xxmbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( srcMbtiles ); + std::unique_ptr layer = std::make_unique( srcMbtiles ); QVERIFY( !layer->isValid() ); QgsMapCanvas canvas; @@ -337,7 +331,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest void testInvalidTileSceneProperties() { // invalid tiled scene layer - std::unique_ptr< QgsTiledSceneLayer > layer = std::make_unique< QgsTiledSceneLayer >( QStringLiteral( "xxx" ), QStringLiteral( "test" ), QStringLiteral( "xxx" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "xxx" ), QStringLiteral( "test" ), QStringLiteral( "xxx" ) ); QVERIFY( !layer->isValid() ); QgsMapCanvas canvas; @@ -350,7 +344,7 @@ class TestQgsLayerPropertiesDialogs : public QgsTest void testValidAnnotationLayerProperties() { // valid annotation layer - std::unique_ptr< QgsAnnotationLayer > layer = std::make_unique< QgsAnnotationLayer >( QStringLiteral( "xxx" ), QgsAnnotationLayer::LayerOptions( QgsCoordinateTransformContext() ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "xxx" ), QgsAnnotationLayer::LayerOptions( QgsCoordinateTransformContext() ) ); QVERIFY( layer->isValid() ); QgsMapCanvas canvas; diff --git a/tests/src/app/testqgsmapcanvasdockwidget.cpp b/tests/src/app/testqgsmapcanvasdockwidget.cpp index 38ae123b9bec..01aaee57a0bc 100644 --- a/tests/src/app/testqgsmapcanvasdockwidget.cpp +++ b/tests/src/app/testqgsmapcanvasdockwidget.cpp @@ -38,10 +38,10 @@ class TestQgsMapCanvasDockWidget : public QObject TestQgsMapCanvasDockWidget(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}; // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {}; // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testNoSync(); void testScaleSync(); diff --git a/tests/src/app/testqgsmaptooladdpart.cpp b/tests/src/app/testqgsmaptooladdpart.cpp index 6915440a68b1..bad36f099e3d 100644 --- a/tests/src/app/testqgsmaptooladdpart.cpp +++ b/tests/src/app/testqgsmaptooladdpart.cpp @@ -30,15 +30,15 @@ * \ingroup UnitTests * This is a unit test for the add part map tool */ -class TestQgsMapToolAddPart: public QObject +class TestQgsMapToolAddPart : public QObject { Q_OBJECT public: TestQgsMapToolAddPart(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testAddPart(); void testAddPartClockWise(); @@ -90,7 +90,7 @@ void TestQgsMapToolAddPart::initTestCase() const QString wkt( "MultiPolygon (((2 2, 4 2, 4 4, 2 4)))" ); f.setGeometry( QgsGeometry::fromWkt( wkt ) ); mLayerMultiPolygon->dataProvider()->addFeatures( QgsFeatureList() << f ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), wkt ); mCanvas->setCurrentLayer( mLayerMultiPolygon ); @@ -122,52 +122,52 @@ void TestQgsMapToolAddPart::testAddPart() { mLayerMultiPolygon->select( 1 ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 5, 5 ), - Qt::LeftButton - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 5, 5 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 5, 5 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 5, 5 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 6, 5 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 6, 5 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 6, 6 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 6, 6 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 5, 6 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 5, 6 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 5, 5 ), - Qt::RightButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 5, 5 ), + Qt::RightButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); const QString wkt = "MultiPolygon (((2 2, 4 2, 4 4, 2 4)),((5 5, 5 5, 6 5, 6 6, 5 6, 5 5)))"; @@ -179,44 +179,44 @@ void TestQgsMapToolAddPart::testAddPartClockWise() mLayerMultiPolygon->select( 1 ); // Draw in clockwise - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 15, 15 ), - Qt::LeftButton - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 15, 15 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 15, 16 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 15, 16 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 16, 16 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 16, 16 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 16, 15 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 16, 15 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 15, 15 ), - Qt::RightButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 15, 15 ), + Qt::RightButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); const QString wkt = "MultiPolygon (((2 2, 4 2, 4 4, 2 4)),((5 5, 5 5, 6 5, 6 6, 5 6, 5 5)),((15 15, 16 15, 16 16, 15 16, 15 15)))"; @@ -226,9 +226,9 @@ void TestQgsMapToolAddPart::testAddPartClockWise() void TestQgsMapToolAddPart::testAddPartToSingleGeometryLess() { QMap> geomTypes; - geomTypes.insert( {"Point"}, {QgsPoint( 0, 0 )} ); - geomTypes.insert( {"LineString", "CompoundCurve"}, {QgsPoint( 0, 0 ), QgsPoint( 1, 1 )} ); - geomTypes.insert( {"Polygon", "CurvePolygon"}, {QgsPoint( 0, 0 ), QgsPoint( 1, 0 ), QgsPoint( 1, 1 ), QgsPoint( 0, 1 )} ); + geomTypes.insert( { "Point" }, { QgsPoint( 0, 0 ) } ); + geomTypes.insert( { "LineString", "CompoundCurve" }, { QgsPoint( 0, 0 ), QgsPoint( 1, 1 ) } ); + geomTypes.insert( { "Polygon", "CurvePolygon" }, { QgsPoint( 0, 0 ), QgsPoint( 1, 0 ), QgsPoint( 1, 1 ), QgsPoint( 0, 1 ) } ); for ( auto it = geomTypes.constBegin(); it != geomTypes.constEnd(); it++ ) @@ -242,7 +242,7 @@ void TestQgsMapToolAddPart::testAddPartToSingleGeometryLess() vl->startEditing(); QgsFeature f; vl->dataProvider()->addFeatures( QgsFeatureList() << f ); - QCOMPARE( vl->featureCount(), ( long )1 ); + QCOMPARE( vl->featureCount(), ( long ) 1 ); QVERIFY( vl->getFeature( 1 ).geometry().isNull() ); mCanvas->setCurrentLayer( vl ); @@ -251,26 +251,26 @@ void TestQgsMapToolAddPart::testAddPartToSingleGeometryLess() QCOMPARE( mCanvas->mapSettings().outputSize(), QSize( 512, 512 ) ); QCOMPARE( mCanvas->mapSettings().visibleExtent(), QgsRectangle( 0, 0, 8, 8 ) ); - std::unique_ptr< QgsMapMouseEvent > event; + std::unique_ptr event; for ( const QgsPoint &point : it.value() ) { event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( point.x(), point.y() ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( point.x(), point.y() ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); } event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 0, 0 ), - Qt::RightButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 0, 0 ), + Qt::RightButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); - QVERIFY2( ! vl->getFeature( 1 ).geometry().isNull(), QString( "failed for %1" ).arg( geomType ).toLocal8Bit().data() ); + QVERIFY2( !vl->getFeature( 1 ).geometry().isNull(), QString( "failed for %1" ).arg( geomType ).toLocal8Bit().data() ); } } } diff --git a/tests/src/app/testqgsmaptooladdring.cpp b/tests/src/app/testqgsmaptooladdring.cpp index 395409c1bc67..3cb84d43ae26 100644 --- a/tests/src/app/testqgsmaptooladdring.cpp +++ b/tests/src/app/testqgsmaptooladdring.cpp @@ -30,15 +30,15 @@ * \ingroup UnitTests * This is a unit test for the add ring map tool */ -class TestQgsMapToolAddRing: public QObject +class TestQgsMapToolAddRing : public QObject { Q_OBJECT public: TestQgsMapToolAddRing(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testAddRing(); void testAddRingClockWise(); @@ -89,7 +89,7 @@ void TestQgsMapToolAddRing::initTestCase() const QString wkt( "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0)))" ); f.setGeometry( QgsGeometry::fromWkt( wkt ) ); mLayerMultiPolygon->dataProvider()->addFeatures( QgsFeatureList() << f ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), wkt ); mCanvas->setCurrentLayer( mLayerMultiPolygon ); @@ -121,44 +121,44 @@ void TestQgsMapToolAddRing::testAddRing() { mLayerMultiPolygon->select( 1 ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 1, 1 ), - Qt::LeftButton - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 1, 1 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 1, 2 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 1, 2 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 2, 2 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 2, 2 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 2, 1 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 2, 1 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 1, 1 ), - Qt::RightButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 1, 1 ), + Qt::RightButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1)))"; @@ -170,44 +170,44 @@ void TestQgsMapToolAddRing::testAddRingClockWise() mLayerMultiPolygon->select( 1 ); // Draw in clockwise - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 3, 3 ), - Qt::LeftButton - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 3, 3 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 4, 3 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 4, 3 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 4, 4 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 4, 4 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 3, 4 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 3, 4 ), + Qt::LeftButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 3, 3 ), - Qt::RightButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 3, 3 ), + Qt::RightButton + ) ); mCaptureTool->cadCanvasReleaseEvent( event.get() ); const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1),(3 3, 3 4, 4 4, 4 3, 3 3)))"; diff --git a/tests/src/app/testqgsmaptoolcircle.cpp b/tests/src/app/testqgsmaptoolcircle.cpp index 3e7e8eb1d2ab..d030e7ec6f07 100644 --- a/tests/src/app/testqgsmaptoolcircle.cpp +++ b/tests/src/app/testqgsmaptoolcircle.cpp @@ -54,15 +54,16 @@ class TestQgsMapToolCircle : public QObject QgsMapCanvas *mCanvas = nullptr; std::map> mVectorLayerMap = {}; - const QList mCoordinateList = - { + const QList mCoordinateList = { "XY", "XYZ", "XYM", "XYZM" }; - const QList mDrawingCircleMethods = - { - "2Points", "2PointsWithDeletedVertex", - "3Points", "3PointsWithDeletedVertex", - "centerPoint", "centerPointWithDeletedVertex", + const QList mDrawingCircleMethods = { + "2Points", + "2PointsWithDeletedVertex", + "3Points", + "3PointsWithDeletedVertex", + "centerPoint", + "centerPointWithDeletedVertex", }; QMap mDrawFunctionUserNames = {}; QMap> mDrawFunctionPtrMap = {}; @@ -141,33 +142,93 @@ void TestQgsMapToolCircle::initAttributs() mDrawFunctionPtrMap["centerPoint"] = std::bind( &TestQgsMapToolCircle::drawCircleFromCenterPoint, this ); mDrawFunctionPtrMap["centerPointWithDeletedVertex"] = std::bind( &TestQgsMapToolCircle::drawCircleFromCenterPointWithDeletedVertex, this ); - mExpectedWkts[QStringLiteral( "XY" "2Points" )] = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::Point ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::Point ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XY" "2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XY" "2Points" )]; - mExpectedWkts[QStringLiteral( "XY" "3Points" )] = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::Point ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::Point ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::Point ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XY" "3PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XY" "3Points" )]; - mExpectedWkts[QStringLiteral( "XY" "centerPoint" )] = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::Point ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::Point ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XY" "centerPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XY" "centerPoint" )] ; - - mExpectedWkts[QStringLiteral( "XYZ" "2Points" )] = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZ ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZ" "2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZ" "2Points" )]; - mExpectedWkts[QStringLiteral( "XYZ" "3Points" )] = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::PointZ ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZ" "3PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZ" "3Points" )]; - mExpectedWkts[QStringLiteral( "XYZ" "centerPoint" )] = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZ ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZ" "centerPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZ" "centerPoint" )] ; - - mExpectedWkts[QStringLiteral( "XYM" "2Points" )] = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYM" "2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYM" "2Points" )]; - mExpectedWkts[QStringLiteral( "XYM" "3Points" )] = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointM ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::PointM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYM" "3PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYM" "3Points" )]; - mExpectedWkts[QStringLiteral( "XYM" "centerPoint" )] = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYM" "centerPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYM" "centerPoint" )] ; - - mExpectedWkts[QStringLiteral( "XYZM" "2Points" )] = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZM" "2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZM" "2Points" )]; - mExpectedWkts[QStringLiteral( "XYZM" "3Points" )] = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::PointZM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZM" "3PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZM" "3Points" )]; - mExpectedWkts[QStringLiteral( "XYZM" "centerPoint" )] = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZM" "centerPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZM" "centerPoint" )] ; + mExpectedWkts[QStringLiteral( "XY" + "2Points" )] + = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::Point ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::Point ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XY" + "2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XY" + "2Points" )]; + mExpectedWkts[QStringLiteral( "XY" + "3Points" )] + = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::Point ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::Point ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::Point ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XY" + "3PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XY" + "3Points" )]; + mExpectedWkts[QStringLiteral( "XY" + "centerPoint" )] + = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::Point ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::Point ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XY" + "centerPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XY" + "centerPoint" )]; + + mExpectedWkts[QStringLiteral( "XYZ" + "2Points" )] + = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZ ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZ" + "2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZ" + "2Points" )]; + mExpectedWkts[QStringLiteral( "XYZ" + "3Points" )] + = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::PointZ ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZ" + "3PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZ" + "3Points" )]; + mExpectedWkts[QStringLiteral( "XYZ" + "centerPoint" )] + = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZ ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZ" + "centerPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZ" + "centerPoint" )]; + + mExpectedWkts[QStringLiteral( "XYM" + "2Points" )] + = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYM" + "2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYM" + "2Points" )]; + mExpectedWkts[QStringLiteral( "XYM" + "3Points" )] + = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointM ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::PointM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYM" + "3PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYM" + "3Points" )]; + mExpectedWkts[QStringLiteral( "XYM" + "centerPoint" )] + = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYM" + "centerPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYM" + "centerPoint" )]; + + mExpectedWkts[QStringLiteral( "XYZM" + "2Points" )] + = QgsCircle::from2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZM" + "2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZM" + "2Points" )]; + mExpectedWkts[QStringLiteral( "XYZM" + "3Points" )] + = QgsCircle::from3Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 1, 1, Z, M, Qgis::WkbType::PointZM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZM" + "3PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZM" + "3Points" )]; + mExpectedWkts[QStringLiteral( "XYZM" + "centerPoint" )] + = QgsCircle::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 2, Z, M, Qgis::WkbType::PointZM ) ).toCircularString( true )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZM" + "centerPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZM" + "centerPoint" )]; } void TestQgsMapToolCircle::cleanupTestCase() @@ -184,7 +245,7 @@ void TestQgsMapToolCircle::resetMapTool( QgsMapToolShapeMetadata *metadata ) { mMapTool->clean(); mMapTool->setCurrentCaptureTechnique( Qgis::CaptureTechnique::Shape ); - mMapTool->setCurrentShapeMapTool( metadata ) ; + mMapTool->setCurrentShapeMapTool( metadata ); } QgsFeatureId TestQgsMapToolCircle::drawCircleFrom2Points() @@ -310,7 +371,7 @@ void TestQgsMapToolCircle::testCircle_data() Q_ASSERT( compoundCurveGeom != nullptr ); const QgsCurve *curveGeom = compoundCurveGeom->curveAt( 0 ); Q_ASSERT( curveGeom != nullptr ); - QTest::newRow( rowStringName.toStdString().c_str() ) << curveGeom->asWkt( WKT_PRECISION ) << wkt << mLayer->featureCount() << ( long )1; + QTest::newRow( rowStringName.toStdString().c_str() ) << curveGeom->asWkt( WKT_PRECISION ) << wkt << mLayer->featureCount() << ( long ) 1; mLayer->rollBack(); } diff --git a/tests/src/app/testqgsmaptoolcircularstring.cpp b/tests/src/app/testqgsmaptoolcircularstring.cpp index ebc4590f7246..0e06647a87fb 100644 --- a/tests/src/app/testqgsmaptoolcircularstring.cpp +++ b/tests/src/app/testqgsmaptoolcircularstring.cpp @@ -77,7 +77,7 @@ void TestQgsMapToolCircularString::initTestCase() mMapTool = new QgsMapToolAddFeature( mCanvas, QgisApp::instance()->cadDockWidget(), QgsMapToolCapture::CaptureLine ); mMapTool->setCurrentCaptureTechnique( Qgis::CaptureTechnique::Shape ); -// mCanvas->setMapTool( mMapTool ); + // mCanvas->setMapTool( mMapTool ); } void TestQgsMapToolCircularString::cleanupTestCase() @@ -94,7 +94,7 @@ void TestQgsMapToolCircularString::cleanup() void TestQgsMapToolCircularString::resetMapTool( QgsMapToolShapeMetadata *metadata ) { mMapTool->setCurrentCaptureTechnique( Qgis::CaptureTechnique::Shape ); - mMapTool->setCurrentShapeMapTool( metadata ) ; + mMapTool->setCurrentShapeMapTool( metadata ); } void TestQgsMapToolCircularString::testAddCircularStringCurvePoint() @@ -111,7 +111,7 @@ void TestQgsMapToolCircularString::testAddCircularStringCurvePoint() utils.mouseClick( 0, 2, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "CompoundCurve Z (CircularString Z (0 0 333, 1 1 333, 0 2 333))"; @@ -136,7 +136,7 @@ void TestQgsMapToolCircularString::testAddCircularStringRadius() utils.mouseClick( 0, 2, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "CompoundCurve Z (CircularString Z (0 0 111, 0.17912878474779187 0.82087121525220819 111, 1 1 111))"; @@ -165,7 +165,7 @@ void TestQgsMapToolCircularString::testAddCircularStringRadiusWithDeletedVertex( utils.mouseClick( 0, 2, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "CompoundCurve Z (CircularString Z (0 0 111, 0.17912878474779187 0.82087121525220819 111, 1 1 111))"; @@ -200,7 +200,7 @@ void TestQgsMapToolCircularString::testAddCircularStringAfterClassicDigitizing() utilsCircular.mouseClick( 4, 2, Qt::RightButton ); const QgsFeatureId newFid = utilsCircular.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); qDebug() << f.geometry().asWkt(); diff --git a/tests/src/app/testqgsmaptooldeletepart.cpp b/tests/src/app/testqgsmaptooldeletepart.cpp index 8b8579a8147b..a45a64c34d23 100644 --- a/tests/src/app/testqgsmaptooldeletepart.cpp +++ b/tests/src/app/testqgsmaptooldeletepart.cpp @@ -30,16 +30,16 @@ * \ingroup UnitTests * This is a unit test for the delete part map tool */ -class TestQgsMapToolDeletePart: public QObject +class TestQgsMapToolDeletePart : public QObject { Q_OBJECT public: TestQgsMapToolDeletePart(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void cleanup(); // will be called after every testfunction. void testDeletePart(); void testDeleteLastPart(); @@ -101,7 +101,7 @@ void TestQgsMapToolDeletePart::initTestCase() f2.setGeometry( QgsGeometry::fromWkt( mWkt2 ) ); f3.setGeometry( QgsGeometry::fromWkt( mWkt3 ) ); mLayerMultiPolygon->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), mWkt1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), mWkt2 ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); @@ -114,7 +114,7 @@ void TestQgsMapToolDeletePart::initTestCase() f2.setGeometry( QgsGeometry::fromWkt( mWkt5 ) ); f3.setGeometry( QgsGeometry::fromWkt( mWkt6 ) ); mLayerPolygon->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ); - QCOMPARE( mLayerPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerPolygon->getFeature( 1 ).geometry().asWkt(), mWkt4 ); QCOMPARE( mLayerPolygon->getFeature( 2 ).geometry().asWkt(), mWkt5 ); QCOMPARE( mLayerPolygon->getFeature( 3 ).geometry().asWkt(), mWkt6 ); @@ -143,19 +143,19 @@ void TestQgsMapToolDeletePart::cleanup() void TestQgsMapToolDeletePart::click( double x, double y ) { - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonPress, - mapToPoint( x, y ), - Qt::LeftButton - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonPress, + mapToPoint( x, y ), + Qt::LeftButton + ) ); mCaptureTool->canvasPressEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( x, y ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( x, y ), + Qt::LeftButton + ) ); mCaptureTool->canvasReleaseEvent( event.get() ); } @@ -171,14 +171,14 @@ void TestQgsMapToolDeletePart::testDeletePart() mCanvas->setCurrentLayer( mLayerMultiPolygon ); click( 2.5, 2.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 4, 0 7, 7 7, 7 4, 0 4),(1 6, 1 5, 2 5, 2 6, 1 6),(5 6, 5 5, 6 5, 6 6, 5 6)))" ) ); // delete a part from a multi polygon residing in a singlepart layer mCanvas->setCurrentLayer( mLayerPolygon ); click( 2.5, 2.5 ); - QCOMPARE( mLayerPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 4, 0 7, 7 7, 7 4, 0 4),(1 6, 1 5, 2 5, 2 6, 1 6),(5 6, 5 5, 6 5, 6 6, 5 6)))" ) ); } @@ -187,14 +187,14 @@ void TestQgsMapToolDeletePart::testDeleteLastPart() mCanvas->setCurrentLayer( mLayerMultiPolygon ); click( 0.5, 3.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QVERIFY2( mLayerMultiPolygon->getFeature( 1 ).geometry().isEmpty(), mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt().toLocal8Bit().constData() ); // also for singlepart layer mCanvas->setCurrentLayer( mLayerPolygon ); click( 0.5, 3.5 ); - QCOMPARE( mLayerPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 3 ); QVERIFY2( mLayerPolygon->getFeature( 1 ).geometry().isEmpty(), mLayerPolygon->getFeature( 1 ).geometry().asWkt().toLocal8Bit().constData() ); } @@ -205,7 +205,7 @@ void TestQgsMapToolDeletePart::testDeletePartSelected() mLayerMultiPolygon->select( 1 ); click( 0.5, 0.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QVERIFY2( mLayerMultiPolygon->getFeature( 1 ).geometry().isEmpty(), mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt().toLocal8Bit().constData() ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), mWkt2 ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); @@ -215,7 +215,7 @@ void TestQgsMapToolDeletePart::testDeletePartSelected() mLayerMultiPolygon->select( 2 ); click( 0.5, 0.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), mWkt1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 4, 0 7, 7 7, 7 4, 0 4),(1 6, 1 5, 2 5, 2 6, 1 6),(5 6, 5 5, 6 5, 6 6, 5 6)))" ) ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); @@ -226,7 +226,7 @@ void TestQgsMapToolDeletePart::testDeletePartSelected() mLayerMultiPolygon->select( 3 ); click( 0.5, 0.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), mWkt1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), mWkt2 ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); diff --git a/tests/src/app/testqgsmaptooldeletering.cpp b/tests/src/app/testqgsmaptooldeletering.cpp index 49329a1d8e7c..5d734c3dfc9f 100644 --- a/tests/src/app/testqgsmaptooldeletering.cpp +++ b/tests/src/app/testqgsmaptooldeletering.cpp @@ -30,16 +30,16 @@ * \ingroup UnitTests * This is a unit test for the delete ring map tool */ -class TestQgsMapToolDeleteRing: public QObject +class TestQgsMapToolDeleteRing : public QObject { Q_OBJECT public: TestQgsMapToolDeleteRing(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void cleanup(); // will be called after every testfunction. void testDeleteRing(); void testDeleteRingInPart(); @@ -98,7 +98,7 @@ void TestQgsMapToolDeleteRing::initTestCase() f2.setGeometry( QgsGeometry::fromWkt( mWkt2 ) ); f3.setGeometry( QgsGeometry::fromWkt( mWkt3 ) ); mLayerMultiPolygon->dataProvider()->addFeatures( QgsFeatureList() << f1 << f2 << f3 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), mWkt1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), mWkt2 ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); @@ -128,19 +128,19 @@ void TestQgsMapToolDeleteRing::cleanup() void TestQgsMapToolDeleteRing::click( double x, double y ) { - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonPress, - mapToPoint( x, y ), - Qt::LeftButton - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonPress, + mapToPoint( x, y ), + Qt::LeftButton + ) ); mCaptureTool->canvasPressEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( x, y ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( x, y ), + Qt::LeftButton + ) ); mCaptureTool->canvasReleaseEvent( event.get() ); } @@ -155,13 +155,13 @@ void TestQgsMapToolDeleteRing::testDeleteRing() { click( 2, 3.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 4 0, 4 7, 0 7, 0 0)))" ) ); // further clicking does nothing click( 2, 3.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 4 0, 4 7, 0 7, 0 0)))" ) ); } @@ -170,7 +170,7 @@ void TestQgsMapToolDeleteRing::testDeleteRingInPart() // clicking outside an inner ring does nothing click( 0.5, 0.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), mWkt1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), mWkt2 ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); @@ -178,22 +178,22 @@ void TestQgsMapToolDeleteRing::testDeleteRingInPart() // now delete inner rings click( 1.5, 1.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 0 3, 7 3, 7 0, 0 0),(5 1, 6 1, 6 2, 5 2, 5 1)),((0 4, 0 7, 7 7, 7 4, 0 4),(1 6, 1 5, 2 5, 2 6, 1 6),(5 6, 5 5, 6 5, 6 6, 5 6)))" ) ); click( 1.5, 5.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 0 3, 7 3, 7 0, 0 0),(5 1, 6 1, 6 2, 5 2, 5 1)),((0 4, 0 7, 7 7, 7 4, 0 4),(5 6, 5 5, 6 5, 6 6, 5 6)))" ) ); click( 5.5, 1.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 0 3, 7 3, 7 0, 0 0)),((0 4, 0 7, 7 7, 7 4, 0 4),(5 6, 5 5, 6 5, 6 6, 5 6)))" ) ); click( 5.5, 5.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 0 3, 7 3, 7 0, 0 0)),((0 4, 0 7, 7 7, 7 4, 0 4)))" ) ); } @@ -204,7 +204,7 @@ void TestQgsMapToolDeleteRing::testDeleteRingSelected() click( 1.5, 1.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 4 0, 4 7, 0 7, 0 0)))" ) ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), mWkt2 ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); @@ -214,7 +214,7 @@ void TestQgsMapToolDeleteRing::testDeleteRingSelected() mLayerMultiPolygon->select( 2 ); click( 1.5, 1.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), mWkt1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), QStringLiteral( "MultiPolygon (((0 0, 0 3, 7 3, 7 0, 0 0),(5 1, 6 1, 6 2, 5 2, 5 1)),((0 4, 0 7, 7 7, 7 4, 0 4),(1 6, 1 5, 2 5, 2 6, 1 6),(5 6, 5 5, 6 5, 6 6, 5 6)))" ) ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); @@ -225,7 +225,7 @@ void TestQgsMapToolDeleteRing::testDeleteRingSelected() mLayerMultiPolygon->select( 3 ); click( 1.5, 1.5 ); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), mWkt1 ); QCOMPARE( mLayerMultiPolygon->getFeature( 2 ).geometry().asWkt(), mWkt2 ); QCOMPARE( mLayerMultiPolygon->getFeature( 3 ).geometry().asWkt(), mWkt3 ); diff --git a/tests/src/app/testqgsmaptooleditannotation.cpp b/tests/src/app/testqgsmaptooleditannotation.cpp index 015906536ded..407f2730783d 100644 --- a/tests/src/app/testqgsmaptooleditannotation.cpp +++ b/tests/src/app/testqgsmaptooleditannotation.cpp @@ -40,10 +40,10 @@ class TestQgsMapToolEditAnnotation : public QObject TestQgsMapToolEditAnnotation() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testSelectItem(); void testDeleteItem(); @@ -51,7 +51,6 @@ class TestQgsMapToolEditAnnotation : public QObject void testMoveNode(); void testDeleteNode(); void testAddNode(); - }; void TestQgsMapToolEditAnnotation::initTestCase() @@ -196,13 +195,13 @@ void TestQgsMapToolEditAnnotation::testDeleteItem() utils.mouseMove( 9, 9 ); utils.mouseClick( 9, 9, Qt::LeftButton, Qt::KeyboardModifiers(), true ); utils.keyClick( Qt::Key_Delete ); - QCOMPARE( qgis::listToSet( layer->items().keys() ), QSet< QString >( { i1id, i2id, i3id } ) ); + QCOMPARE( qgis::listToSet( layer->items().keys() ), QSet( { i1id, i2id, i3id } ) ); // with selected item utils.mouseMove( 1.5, 1.5 ); utils.mouseClick( 1.5, 1.5, Qt::LeftButton, Qt::KeyboardModifiers(), true ); utils.keyClick( Qt::Key_Delete ); - QCOMPARE( qgis::listToSet( layer->items().keys() ), QSet< QString >( { i2id, i3id } ) ); + QCOMPARE( qgis::listToSet( layer->items().keys() ), QSet( { i2id, i3id } ) ); while ( !canvas.isDrawing() ) { QgsApplication::processEvents(); @@ -212,7 +211,7 @@ void TestQgsMapToolEditAnnotation::testDeleteItem() utils.mouseMove( 1.5, 4.5 ); utils.mouseClick( 1.5, 4.5, Qt::LeftButton, Qt::KeyboardModifiers(), true ); utils.keyClick( Qt::Key_Delete ); - QCOMPARE( qgis::listToSet( layer->items().keys() ), QSet< QString >( { i3id } ) ); + QCOMPARE( qgis::listToSet( layer->items().keys() ), QSet( { i3id } ) ); } void TestQgsMapToolEditAnnotation::testMoveItem() @@ -232,7 +231,7 @@ void TestQgsMapToolEditAnnotation::testMoveItem() QgsAnnotationPolygonItem *item1 = new QgsAnnotationPolygonItem( new QgsPolygon( new QgsLineString( QVector { QgsPoint( 1, 1 ), QgsPoint( 5, 1 ), QgsPoint( 5, 5 ), QgsPoint( 1, 5 ), QgsPoint( 1, 1 ) } ) ) ); item1->setZIndex( 1 ); const QString i1id = layer->addItem( item1 ); - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); layer->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); @@ -273,7 +272,7 @@ void TestQgsMapToolEditAnnotation::testMoveItem() QCOMPARE( canvas.renderedItemResults()->renderedItems().size(), 1 ); // check that item was moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((4 4, 8 4, 8 8, 4 8, 4 4))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((4 4, 8 4, 8 8, 4 8, 4 4))" ) ); // start a new move // click on item -- it should already be selected, so this will start a new move, not emit the itemSelected signal @@ -291,7 +290,7 @@ void TestQgsMapToolEditAnnotation::testMoveItem() QCOMPARE( canvas.renderedItemResults()->renderedItems().size(), 1 ); // check that item was moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((0.9 1, 4.9 1, 4.9 5, 0.9 5, 0.9 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((0.9 1, 4.9 1, 4.9 5, 0.9 5, 0.9 1))" ) ); // start a move then cancel it via right click utils.mouseMove( 1.6, 1.6 ); @@ -301,7 +300,7 @@ void TestQgsMapToolEditAnnotation::testMoveItem() utils.mouseMove( 4.5, 4.5 ); utils.mouseClick( 4.5, 4.5, Qt::RightButton, Qt::KeyboardModifiers(), true ); // check that item was NOT moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((0.9 1, 4.9 1, 4.9 5, 0.9 5, 0.9 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((0.9 1, 4.9 1, 4.9 5, 0.9 5, 0.9 1))" ) ); // cancel a move via escape key utils.mouseMove( 1.6, 1.6 ); @@ -314,7 +313,7 @@ void TestQgsMapToolEditAnnotation::testMoveItem() //... so next click is not "finish move", but "clear selection" utils.mouseClick( 4.5, 4.5, Qt::LeftButton, Qt::KeyboardModifiers(), true ); // check that item was NOT moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((0.9 1, 4.9 1, 4.9 5, 0.9 5, 0.9 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((0.9 1, 4.9 1, 4.9 5, 0.9 5, 0.9 1))" ) ); } void TestQgsMapToolEditAnnotation::testMoveNode() @@ -334,7 +333,7 @@ void TestQgsMapToolEditAnnotation::testMoveNode() QgsAnnotationPolygonItem *item1 = new QgsAnnotationPolygonItem( new QgsPolygon( new QgsLineString( QVector { QgsPoint( 1, 1 ), QgsPoint( 5, 1 ), QgsPoint( 5, 5 ), QgsPoint( 1, 5 ), QgsPoint( 1, 1 ) } ) ) ); item1->setZIndex( 1 ); const QString i1id = layer->addItem( item1 ); - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); layer->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); @@ -376,7 +375,7 @@ void TestQgsMapToolEditAnnotation::testMoveNode() QCOMPARE( canvas.renderedItemResults()->renderedItems().size(), 1 ); // check that item was moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 4.5 4.5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 4.5 4.5, 1 5, 1 1))" ) ); // start a new move node // click on item -- it should already be selected, so this will start a new move, not emit the itemSelected signal @@ -394,7 +393,7 @@ void TestQgsMapToolEditAnnotation::testMoveNode() QCOMPARE( canvas.renderedItemResults()->renderedItems().size(), 1 ); // check that item was moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((1 1, 5.5 1.5, 4.5 4.5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((1 1, 5.5 1.5, 4.5 4.5, 1 5, 1 1))" ) ); // start a move then cancel it via right click utils.mouseMove( 4.5, 4.5 ); @@ -404,7 +403,7 @@ void TestQgsMapToolEditAnnotation::testMoveNode() utils.mouseMove( 4.9, 4.9 ); utils.mouseClick( 4.9, 4.9, Qt::RightButton, Qt::KeyboardModifiers(), true ); // check that node was NOT moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((1 1, 5.5 1.5, 4.5 4.5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((1 1, 5.5 1.5, 4.5 4.5, 1 5, 1 1))" ) ); // cancel a move via escape key utils.mouseMove( 4.5, 4.5 ); @@ -417,7 +416,7 @@ void TestQgsMapToolEditAnnotation::testMoveNode() //... so next click is not "finish move", but "clear selection" utils.mouseClick( 6.5, 6.5, Qt::LeftButton, Qt::KeyboardModifiers(), true ); // check that node was NOT moved - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((1 1, 5.5 1.5, 4.5 4.5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt( 1 ), QStringLiteral( "Polygon ((1 1, 5.5 1.5, 4.5 4.5, 1 5, 1 1))" ) ); } void TestQgsMapToolEditAnnotation::testDeleteNode() @@ -437,7 +436,7 @@ void TestQgsMapToolEditAnnotation::testDeleteNode() QgsAnnotationPolygonItem *item1 = new QgsAnnotationPolygonItem( new QgsPolygon( new QgsLineString( QVector { QgsPoint( 1, 1 ), QgsPoint( 5, 1 ), QgsPoint( 5, 5 ), QgsPoint( 1, 5 ), QgsPoint( 1, 1 ) } ) ) ); item1->setZIndex( 1 ); const QString i1id = layer->addItem( item1 ); - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); layer->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); @@ -478,7 +477,7 @@ void TestQgsMapToolEditAnnotation::testDeleteNode() QCOMPARE( canvas.renderedItemResults()->renderedItems().size(), 1 ); // check that node was deleted - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 1 5, 1 1))" ) ); // start a new delete node // click on item -- it should already be selected, so this will start a new move, not emit the itemSelected signal @@ -515,7 +514,7 @@ void TestQgsMapToolEditAnnotation::testAddNode() QgsAnnotationPolygonItem *item1 = new QgsAnnotationPolygonItem( new QgsPolygon( new QgsLineString( QVector { QgsPoint( 1, 1 ), QgsPoint( 5, 1 ), QgsPoint( 5, 5 ), QgsPoint( 1, 5 ), QgsPoint( 1, 1 ) } ) ) ); item1->setZIndex( 1 ); const QString i1id = layer->addItem( item1 ); - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 5, 1 5, 1 1))" ) ); layer->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); @@ -553,7 +552,7 @@ void TestQgsMapToolEditAnnotation::testAddNode() QCOMPARE( canvas.renderedItemResults()->renderedItems().size(), 1 ); // check that node was added - QCOMPARE( qgis::down_cast< QgsAnnotationPolygonItem * >( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 3, 5 5, 1 5, 1 1))" ) ); + QCOMPARE( qgis::down_cast( layer->item( i1id ) )->geometry()->asWkt(), QStringLiteral( "Polygon ((1 1, 5 1, 5 3, 5 5, 1 5, 1 1))" ) ); } diff --git a/tests/src/app/testqgsmaptooleditmesh.cpp b/tests/src/app/testqgsmaptooleditmesh.cpp index fcf0336cb425..d09e34129dd5 100644 --- a/tests/src/app/testqgsmaptooleditmesh.cpp +++ b/tests/src/app/testqgsmaptooleditmesh.cpp @@ -28,10 +28,10 @@ class TestQgsMapToolEditMesh : public QObject TestQgsMapToolEditMesh() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase() {};// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase() {}; // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void hoverElements(); @@ -92,17 +92,17 @@ void TestQgsMapToolEditMesh::hoverElements() mEditMeshMapTool->mActionDigitizing->trigger(); tool.mouseMove( 3.31376427, 47.97500487 ); QCOMPARE( mEditMeshMapTool->mCurrentFaceIndex, 8 ); - QVERIFY( mEditMeshMapTool->mCurrentEdge == QgsMapToolEditMeshFrame::Edge( {-1, -1} ) ); + QVERIFY( mEditMeshMapTool->mCurrentEdge == QgsMapToolEditMeshFrame::Edge( { -1, -1 } ) ); QCOMPARE( mEditMeshMapTool->mCurrentVertexIndex, -1 ); tool.mouseMove( 3.31368247, 47.97500500 ); QCOMPARE( mEditMeshMapTool->mCurrentFaceIndex, 8 ); - QVERIFY( mEditMeshMapTool->mCurrentEdge == QgsMapToolEditMeshFrame::Edge( {8, 5} ) ); + QVERIFY( mEditMeshMapTool->mCurrentEdge == QgsMapToolEditMeshFrame::Edge( { 8, 5 } ) ); QCOMPARE( mEditMeshMapTool->mCurrentVertexIndex, -1 ); tool.mouseMove( 3.31368064, 47.97503705 ); QCOMPARE( mEditMeshMapTool->mCurrentFaceIndex, 8 ); - QVERIFY( mEditMeshMapTool->mCurrentEdge == QgsMapToolEditMeshFrame::Edge( {8, 5} ) ); + QVERIFY( mEditMeshMapTool->mCurrentEdge == QgsMapToolEditMeshFrame::Edge( { 8, 5 } ) ); QCOMPARE( mEditMeshMapTool->mCurrentVertexIndex, 10 ); } @@ -162,20 +162,20 @@ void TestQgsMapToolEditMesh::editMesh() QCOMPARE( meshLayerQuadFlower->meshEditor()->freeVerticesIndexes().count(), 0 ); // add a free vertex - tool.mouseDoubleClick( 2500, 3500, Qt::LeftButton ); // 9 + tool.mouseDoubleClick( 2500, 3500, Qt::LeftButton ); // 9 QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 8 ); QCOMPARE( meshLayerQuadFlower->meshVertexCount(), 10 ); QCOMPARE( meshLayerQuadFlower->meshEditor()->freeVerticesIndexes().count(), 1 ); // add a face - tool.mouseMove( 1999, 2999 ); //move near a vertex + tool.mouseMove( 1999, 2999 ); //move near a vertex tool.mouseMove( 2000 + offsetInMapUnits / sqrt( 2 ), 3000 + offsetInMapUnits / sqrt( 2 ) ); //move on the new face marker tool.mouseClick( 2000 + offsetInMapUnits / sqrt( 4 ), 3000 + offsetInMapUnits / sqrt( 2 ), Qt::LeftButton ); - tool.mouseMove( 2499, 3501 ); //move near the new free vertex - tool.mouseClick( 2501, 3499, Qt::LeftButton ); // click near the vertex - tool.mouseMove( 2490, 2600 ); //move elsewhere - tool.mouseMove( 2495, 2500 ); //move near another vertex - tool.mouseClick( 2495, 2500, Qt::LeftButton ); // click near the vertex + tool.mouseMove( 2499, 3501 ); //move near the new free vertex + tool.mouseClick( 2501, 3499, Qt::LeftButton ); // click near the vertex + tool.mouseMove( 2490, 2600 ); //move elsewhere + tool.mouseMove( 2495, 2500 ); //move near another vertex + tool.mouseClick( 2495, 2500, Qt::LeftButton ); // click near the vertex tool.mouseClick( 5000, 5000, Qt::RightButton ); // valid the face QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 9 ); @@ -190,9 +190,9 @@ void TestQgsMapToolEditMesh::editMesh() tool.mouseMove( 3000, 3500 ); //move to a new place outsite the mesh (cross edge of new face: invalid) tool.mouseClick( 3000, 3500, Qt::LeftButton ); tool.mouseMove( 2500, 2500 ); - tool.mouseClick( 2500, 2500, Qt::LeftButton );// close the face - tool.mouseClick( 5000, 5000, Qt::RightButton ); // valid the fac - QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 9 ); //-> face not added + tool.mouseClick( 2500, 2500, Qt::LeftButton ); // close the face + tool.mouseClick( 5000, 5000, Qt::RightButton ); // valid the fac + QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 9 ); //-> face not added QCOMPARE( meshLayerQuadFlower->meshVertexCount(), 10 ); //-> vertices not added tool.keyClick( Qt::Key_Backspace ); tool.keyClick( Qt::Key_Backspace ); @@ -324,9 +324,9 @@ void TestQgsMapToolEditMesh::editMesh() // select only one vertex tool.mouseMove( 1520, 1516.66 ); - tool.mouseClick( 1520, 1516.66, Qt::LeftButton ); //select vertex + tool.mouseClick( 1520, 1516.66, Qt::LeftButton ); //select vertex tool.mouseMove( 1521, 1516.66 ); - tool.mouseClick( 1520, 1516.66, Qt::LeftButton ); //start move + tool.mouseClick( 1520, 1516.66, Qt::LeftButton ); //start move tool.mouseMove( 1500, 1500 ); tool.mouseClick( 1500, 1500, Qt::LeftButton ); //end move QgsPointXY vertexPosition = meshLayerQuadFlower->snapOnElement( QgsMesh::Vertex, QgsPointXY( 1520, 1480 ), 30 ); @@ -334,7 +334,7 @@ void TestQgsMapToolEditMesh::editMesh() // select an edge and move it tool.mouseMove( 1760, 1758 ); - tool.mouseClick( 1760, 1758, Qt::LeftButton ); + tool.mouseClick( 1760, 1758, Qt::LeftButton ); tool.mouseMove( 1760, 1758 ); tool.mouseClick( 1760, 1760, Qt::LeftButton ); tool.mouseMove( 1800, 1760 ); diff --git a/tests/src/app/testqgsmaptoolellipse.cpp b/tests/src/app/testqgsmaptoolellipse.cpp index b51322d853e7..247fc9f8da32 100644 --- a/tests/src/app/testqgsmaptoolellipse.cpp +++ b/tests/src/app/testqgsmaptoolellipse.cpp @@ -40,7 +40,7 @@ class TestQgsMapToolEllipse : public QObject TestQgsMapToolEllipse() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. void testEllipse_data(); @@ -52,16 +52,18 @@ class TestQgsMapToolEllipse : public QObject QgsMapCanvas *mCanvas = nullptr; std::map> mVectorLayerMap = {}; - const QList mCoordinateList = - { + const QList mCoordinateList = { "XY", "XYZ", "XYM", "XYZM" }; - const QList mDrawingEllipseMethods = - { - "CenterAndPoint", "CenterAndPointWithDeletedVertex", - "CenterAnd2Points", "CenterAnd2PointsWithDeletedVertex", - "FromExtent", "FromExtentWithDeletedVertex", - "FromFoci", "FromFociWithDeletedVertex", + const QList mDrawingEllipseMethods = { + "CenterAndPoint", + "CenterAndPointWithDeletedVertex", + "CenterAnd2Points", + "CenterAnd2PointsWithDeletedVertex", + "FromExtent", + "FromExtentWithDeletedVertex", + "FromFoci", + "FromFociWithDeletedVertex", }; QMap mDrawFunctionUserNames = {}; QMap> mDrawFunctionPtrMap = {}; @@ -84,7 +86,7 @@ class TestQgsMapToolEllipse : public QObject const double M = 222.0; const int WKT_PRECISION = 2; - unsigned int segments( ) { return QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->value() * 12; } + unsigned int segments() { return QgsSettingsRegistryCore::settingsDigitizingOffsetQuadSeg->value() * 12; } }; @@ -148,41 +150,121 @@ void TestQgsMapToolEllipse::initAttributs() mDrawFunctionPtrMap["FromFoci"] = std::bind( &TestQgsMapToolEllipse::drawEllipseFromFoci, this ); mDrawFunctionPtrMap["FromFociWithDeletedVertex"] = std::bind( &TestQgsMapToolEllipse::drawEllipseFromFociWithDeletedVertex, this ); - mExpectedWkts[QStringLiteral( "XY" "CenterAndPoint" )] = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 1, -1 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XY" "CenterAndPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XY" "CenterAndPoint" )]; - mExpectedWkts[QStringLiteral( "XY" "CenterAnd2Points" )] = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0 ), QgsPoint( 0, 1 ), QgsPoint( 0, -1 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XY" "CenterAnd2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XY" "CenterAnd2Points" )]; - mExpectedWkts[QStringLiteral( "XY" "FromExtent" )] = QgsEllipse::fromExtent( QgsPoint( 0, 0 ), QgsPoint( 2, 2 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XY" "FromExtentWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XY" "FromExtent" )]; - mExpectedWkts[QStringLiteral( "XY" "FromFoci" )] = QgsEllipse::fromFoci( QgsPoint( 0, 0 ), QgsPoint( 1, -1 ), QgsPoint( 0, -1 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XY" "FromFociWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XY" "FromFoci" )]; - - mExpectedWkts[QStringLiteral( "XYZ" "CenterAndPoint" )] = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZ" "CenterAndPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZ" "CenterAndPoint" )]; - mExpectedWkts[QStringLiteral( "XYZ" "CenterAnd2Points" )] = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 1, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZ" "CenterAnd2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZ" "CenterAnd2Points" )]; - mExpectedWkts[QStringLiteral( "XYZ" "FromExtent" )] = QgsEllipse::fromExtent( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 2, 2, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZ" "FromExtentWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZ" "FromExtent" )]; - mExpectedWkts[QStringLiteral( "XYZ" "FromFoci" )] = QgsEllipse::fromFoci( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZ" "FromFociWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZ" "FromFoci" )]; - - mExpectedWkts[QStringLiteral( "XYM" "CenterAndPoint" )] = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYM" "CenterAndPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYM" "CenterAndPoint" )]; - mExpectedWkts[QStringLiteral( "XYM" "CenterAnd2Points" )] = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 1, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYM" "CenterAnd2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYM" "CenterAnd2Points" )]; - mExpectedWkts[QStringLiteral( "XYM" "FromExtent" )] = QgsEllipse::fromExtent( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 2, 2, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYM" "FromExtentWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYM" "FromExtent" )]; - mExpectedWkts[QStringLiteral( "XYM" "FromFoci" )] = QgsEllipse::fromFoci( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYM" "FromFociWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYM" "FromFoci" )]; - - mExpectedWkts[QStringLiteral( "XYZM" "CenterAndPoint" )] = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZM" "CenterAndPointWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZM" "CenterAndPoint" )]; - mExpectedWkts[QStringLiteral( "XYZM" "CenterAnd2Points" )] = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 1, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZM" "CenterAnd2PointsWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZM" "CenterAnd2Points" )]; - mExpectedWkts[QStringLiteral( "XYZM" "FromExtent" )] = QgsEllipse::fromExtent( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 2, 2, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZM" "FromExtentWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZM" "FromExtent" )]; - mExpectedWkts[QStringLiteral( "XYZM" "FromFoci" )] = QgsEllipse::fromFoci( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); - mExpectedWkts[QStringLiteral( "XYZM" "FromFociWithDeletedVertex" )] = mExpectedWkts[QStringLiteral( "XYZM" "FromFoci" )]; + mExpectedWkts[QStringLiteral( "XY" + "CenterAndPoint" )] + = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 1, -1 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XY" + "CenterAndPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XY" + "CenterAndPoint" )]; + mExpectedWkts[QStringLiteral( "XY" + "CenterAnd2Points" )] + = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0 ), QgsPoint( 0, 1 ), QgsPoint( 0, -1 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XY" + "CenterAnd2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XY" + "CenterAnd2Points" )]; + mExpectedWkts[QStringLiteral( "XY" + "FromExtent" )] + = QgsEllipse::fromExtent( QgsPoint( 0, 0 ), QgsPoint( 2, 2 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XY" + "FromExtentWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XY" + "FromExtent" )]; + mExpectedWkts[QStringLiteral( "XY" + "FromFoci" )] + = QgsEllipse::fromFoci( QgsPoint( 0, 0 ), QgsPoint( 1, -1 ), QgsPoint( 0, -1 ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XY" + "FromFociWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XY" + "FromFoci" )]; + + mExpectedWkts[QStringLiteral( "XYZ" + "CenterAndPoint" )] + = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZ" + "CenterAndPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZ" + "CenterAndPoint" )]; + mExpectedWkts[QStringLiteral( "XYZ" + "CenterAnd2Points" )] + = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, 1, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZ" + "CenterAnd2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZ" + "CenterAnd2Points" )]; + mExpectedWkts[QStringLiteral( "XYZ" + "FromExtent" )] + = QgsEllipse::fromExtent( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 2, 2, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZ" + "FromExtentWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZ" + "FromExtent" )]; + mExpectedWkts[QStringLiteral( "XYZ" + "FromFoci" )] + = QgsEllipse::fromFoci( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZ ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZ ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZ" + "FromFociWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZ" + "FromFoci" )]; + + mExpectedWkts[QStringLiteral( "XYM" + "CenterAndPoint" )] + = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYM" + "CenterAndPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYM" + "CenterAndPoint" )]; + mExpectedWkts[QStringLiteral( "XYM" + "CenterAnd2Points" )] + = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, 1, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYM" + "CenterAnd2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYM" + "CenterAnd2Points" )]; + mExpectedWkts[QStringLiteral( "XYM" + "FromExtent" )] + = QgsEllipse::fromExtent( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 2, 2, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYM" + "FromExtentWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYM" + "FromExtent" )]; + mExpectedWkts[QStringLiteral( "XYM" + "FromFoci" )] + = QgsEllipse::fromFoci( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYM" + "FromFociWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYM" + "FromFoci" )]; + + mExpectedWkts[QStringLiteral( "XYZM" + "CenterAndPoint" )] + = QgsEllipse::fromCenterPoint( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZM" + "CenterAndPointWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZM" + "CenterAndPoint" )]; + mExpectedWkts[QStringLiteral( "XYZM" + "CenterAnd2Points" )] + = QgsEllipse::fromCenter2Points( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, 1, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZM" + "CenterAnd2PointsWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZM" + "CenterAnd2Points" )]; + mExpectedWkts[QStringLiteral( "XYZM" + "FromExtent" )] + = QgsEllipse::fromExtent( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 2, 2, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZM" + "FromExtentWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZM" + "FromExtent" )]; + mExpectedWkts[QStringLiteral( "XYZM" + "FromFoci" )] + = QgsEllipse::fromFoci( QgsPoint( 0, 0, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 1, -1, Z, M, Qgis::WkbType::PointZM ), QgsPoint( 0, -1, Z, M, Qgis::WkbType::PointZM ) ).toLineString( segments() )->asWkt( WKT_PRECISION ); + mExpectedWkts[QStringLiteral( "XYZM" + "FromFociWithDeletedVertex" )] + = mExpectedWkts[QStringLiteral( "XYZM" + "FromFoci" )]; } void TestQgsMapToolEllipse::cleanupTestCase() @@ -201,7 +283,7 @@ void TestQgsMapToolEllipse::resetMapTool( QgsMapToolShapeMetadata *metadata ) { mMapTool->clean(); mMapTool->setCurrentCaptureTechnique( Qgis::CaptureTechnique::Shape ); - mMapTool->setCurrentShapeMapTool( metadata ) ; + mMapTool->setCurrentShapeMapTool( metadata ); } QgsFeatureId TestQgsMapToolEllipse::drawEllipseFromCenterAndPoint() @@ -347,7 +429,7 @@ void TestQgsMapToolEllipse::testEllipse_data() wkt = mExpectedWkts[coordinate + drawMethod]; rowStringName = coordinate + " " + mDrawFunctionUserNames[drawMethod]; - QTest::newRow( rowStringName.toStdString().c_str() ) << f.geometry().asWkt( WKT_PRECISION ) << wkt << mLayer->featureCount() << ( long )1; + QTest::newRow( rowStringName.toStdString().c_str() ) << f.geometry().asWkt( WKT_PRECISION ) << wkt << mLayer->featureCount() << ( long ) 1; mLayer->rollBack(); } diff --git a/tests/src/app/testqgsmaptoollabel.cpp b/tests/src/app/testqgsmaptoollabel.cpp index e28df36436fe..676a1e9a0594 100644 --- a/tests/src/app/testqgsmaptoollabel.cpp +++ b/tests/src/app/testqgsmaptoollabel.cpp @@ -38,14 +38,12 @@ class TestQgsMapToolLabel : public QObject TestQgsMapToolLabel() = default; private: - private slots: void initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void cleanupTestCase() @@ -55,7 +53,7 @@ class TestQgsMapToolLabel : public QObject void testSelectLabel() { - std::unique_ptr< QgsVectorLayer > vl1 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:3946&field=text:string" ), QStringLiteral( "vl1" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl1 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=text:string" ), QStringLiteral( "vl1" ), QStringLiteral( "memory" ) ); QVERIFY( vl1->isValid() ); QgsFeature f1; f1.setAttributes( QgsAttributes() << QStringLiteral( "label" ) ); @@ -65,7 +63,7 @@ class TestQgsMapToolLabel : public QObject f1.setAttributes( QgsAttributes() << QStringLiteral( "l" ) ); QVERIFY( vl1->dataProvider()->addFeature( f1 ) ); - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:3946&field=text:string" ), QStringLiteral( "vl1" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=text:string" ), QStringLiteral( "vl1" ), QStringLiteral( "memory" ) ); QVERIFY( vl2->isValid() ); f1.setGeometry( QgsGeometry::fromPointXY( QgsPointXY( 1, 1 ) ) ); f1.setAttributes( QgsAttributes() << QStringLiteral( "label" ) ); @@ -77,10 +75,10 @@ class TestQgsMapToolLabel : public QObject f1.setAttributes( QgsAttributes() << QStringLiteral( "label3" ) ); QVERIFY( vl2->dataProvider()->addFeature( f1 ) ); - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3946" ) ) ); canvas->setLayers( QList() << vl1.get() << vl2.get() ); - const std::unique_ptr< QgsAdvancedDigitizingDockWidget > advancedDigitizingDockWidget = std::make_unique< QgsAdvancedDigitizingDockWidget >( canvas.get() ); + const std::unique_ptr advancedDigitizingDockWidget = std::make_unique( canvas.get() ); QgsMapSettings mapSettings; mapSettings.setOutputSize( QSize( 500, 500 ) ); @@ -97,15 +95,15 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( canvas->mapSettings().outputSize(), QSize( 500, 500 ) ); QCOMPARE( canvas->mapSettings().visibleExtent(), QgsRectangle( -1, -1, 4, 4 ) ); - std::unique_ptr< QgsMapToolLabel > tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); // no labels yet QgsPointXY pt; pt = tool->canvas()->mapSettings().mapToPixel().transform( 1, 1 ); - std::unique_ptr< QMouseEvent > event( new QMouseEvent( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ) ); + std::unique_ptr event( new QMouseEvent( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ) ); QgsLabelPosition pos; QVERIFY( !tool->labelAtPosition( event.get(), pos ) ); @@ -137,19 +135,19 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( pos.labelText, QStringLiteral( "label" ) ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 3 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); QCOMPARE( pos.labelText, QStringLiteral( "l" ) ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 1 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( !tool->labelAtPosition( event.get(), pos ) ); // label second layer @@ -163,56 +161,56 @@ class TestQgsMapToolLabel : public QObject // should prioritize current layer canvas->setCurrentLayer( vl1.get() ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 1, 1 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); QCOMPARE( pos.labelText, QStringLiteral( "label" ) ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 3 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); QCOMPARE( pos.labelText, QStringLiteral( "l" ) ); //... but fallback to any labels if nothing in current layer pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 1 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl2->id() ); QCOMPARE( pos.labelText, QStringLiteral( "label3" ) ); canvas->setCurrentLayer( vl2.get() ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 1, 1 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl2->id() ); QCOMPARE( pos.labelText, QStringLiteral( "label" ) ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 3 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl2->id() ); QCOMPARE( pos.labelText, QStringLiteral( "label2" ) ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 1 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl2->id() ); QCOMPARE( pos.labelText, QStringLiteral( "label3" ) ); @@ -221,10 +219,10 @@ class TestQgsMapToolLabel : public QObject // when multiple candidates exist, pick the smallest pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 3 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); QCOMPARE( pos.labelText, QStringLiteral( "l" ) ); @@ -243,10 +241,10 @@ class TestQgsMapToolLabel : public QObject f1.setAttributes( QgsAttributes() << QStringLiteral( "center" ) << QStringLiteral( "base" ) ); QVERIFY( vl1->dataProvider()->addFeature( f1 ) ); - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3946" ) ) ); canvas->setLayers( QList() << vl1 ); - const std::unique_ptr< QgsAdvancedDigitizingDockWidget > advancedDigitizingDockWidget = std::make_unique< QgsAdvancedDigitizingDockWidget >( canvas.get() ); + const std::unique_ptr advancedDigitizingDockWidget = std::make_unique( canvas.get() ); QgsMapSettings mapSettings; mapSettings.setOutputSize( QSize( 500, 500 ) ); @@ -263,7 +261,7 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( canvas->mapSettings().outputSize(), QSize( 500, 500 ) ); QCOMPARE( canvas->mapSettings().visibleExtent(), QgsRectangle( -1, -1, 4, 4 ) ); - std::unique_ptr< QgsMapToolLabel > tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); // add some labels QgsPalLayerSettings pls1; @@ -291,10 +289,10 @@ class TestQgsMapToolLabel : public QObject QVERIFY( canvas->labelingResults() ); QgsPointXY pt; pt = tool->canvas()->mapSettings().mapToPixel().transform( 1, 1 ); - std::unique_ptr< QMouseEvent > event( new QMouseEvent( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ) ); + std::unique_ptr event( new QMouseEvent( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ) ); QgsLabelPosition pos; QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); @@ -323,10 +321,10 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( labelAlignment, QgsMapToolLabel::LabelAlignment::TopRight ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 3 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); @@ -346,10 +344,10 @@ class TestQgsMapToolLabel : public QObject loop.exec(); pt = tool->canvas()->mapSettings().mapToPixel().transform( 1, 1 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); @@ -360,10 +358,10 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( labelAlignment, QgsMapToolLabel::LabelAlignment::CapLeft ); pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 3 ); - event = std::make_unique< QMouseEvent >( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ); + event = std::make_unique( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ); QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); @@ -387,10 +385,10 @@ class TestQgsMapToolLabel : public QObject f1.setAttributes( QgsAttributes() << QStringLiteral( "center" ) << QStringLiteral( "base" ) ); QVERIFY( vl1->dataProvider()->addFeature( f1 ) ); - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3946" ) ) ); canvas->setLayers( QList() << vl1 ); - const std::unique_ptr< QgsAdvancedDigitizingDockWidget > advancedDigitizingDockWidget = std::make_unique< QgsAdvancedDigitizingDockWidget >( canvas.get() ); + const std::unique_ptr advancedDigitizingDockWidget = std::make_unique( canvas.get() ); QgsMapSettings mapSettings; mapSettings.setOutputSize( QSize( 500, 500 ) ); @@ -407,7 +405,7 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( canvas->mapSettings().outputSize(), QSize( 500, 500 ) ); QCOMPARE( canvas->mapSettings().visibleExtent(), QgsRectangle( -1, -1, 4, 4 ) ); - std::unique_ptr< QgsMapToolLabel > tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); // add some labels QgsPalLayerSettings pls1; @@ -435,10 +433,10 @@ class TestQgsMapToolLabel : public QObject QVERIFY( canvas->labelingResults() ); QgsPointXY pt; pt = tool->canvas()->mapSettings().mapToPixel().transform( 1, 1 ); - std::unique_ptr< QMouseEvent > event( new QMouseEvent( - QEvent::MouseButtonPress, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier - ) ); + std::unique_ptr event( new QMouseEvent( + QEvent::MouseButtonPress, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier + ) ); QgsLabelPosition pos; QVERIFY( tool->labelAtPosition( event.get(), pos ) ); QCOMPARE( pos.layerID, vl1->id() ); @@ -482,12 +480,12 @@ class TestQgsMapToolLabel : public QObject QVERIFY( vl1->isValid() ); QgsProject::instance()->addMapLayer( vl1 ); - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3946" ) ) ); canvas->setLayers( QList() << vl1 ); - const std::unique_ptr< QgsAdvancedDigitizingDockWidget > advancedDigitizingDockWidget = std::make_unique< QgsAdvancedDigitizingDockWidget >( canvas.get() ); + const std::unique_ptr advancedDigitizingDockWidget = std::make_unique( canvas.get() ); - std::unique_ptr< QgsMapToolLabel > tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); + std::unique_ptr tool( new QgsMapToolLabel( canvas.get(), advancedDigitizingDockWidget.get() ) ); QgsExpressionContextUtils::setProjectVariable( QgsProject::instance(), QStringLiteral( "var_1" ), QStringLiteral( "1" ) ); @@ -593,8 +591,6 @@ class TestQgsMapToolLabel : public QObject QCOMPARE( tool->dataDefinedColumnName( QgsPalLayerSettings::Property::PositionX, pls1, vl1, status ), QString() ); QCOMPARE( status, QgsMapToolLabel::PropertyStatus::CurrentExpressionInvalid ); } - - }; QGSTEST_MAIN( TestQgsMapToolLabel ) diff --git a/tests/src/app/testqgsmaptoolmovefeature.cpp b/tests/src/app/testqgsmaptoolmovefeature.cpp index 004327eee9e3..a43695f7396f 100644 --- a/tests/src/app/testqgsmaptoolmovefeature.cpp +++ b/tests/src/app/testqgsmaptoolmovefeature.cpp @@ -35,15 +35,15 @@ * \ingroup UnitTests * This is a unit test for the vertex tool */ -class TestQgsMapToolMoveFeature: public QObject +class TestQgsMapToolMoveFeature : public QObject { Q_OBJECT public: TestQgsMapToolMoveFeature(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testMoveFeature(); void testCopyMoveFeature(); @@ -104,7 +104,7 @@ void TestQgsMapToolMoveFeature::initTestCase() QgsFeatureList flist; flist << f1 << f2; mLayerBase->dataProvider()->addFeatures( flist ); - QCOMPARE( mLayerBase->featureCount(), ( long )2 ); + QCOMPARE( mLayerBase->featureCount(), ( long ) 2 ); QCOMPARE( mLayerBase->getFeature( 1 ).geometry().asWkt(), wkt1 ); QCOMPARE( mLayerBase->getFeature( 2 ).geometry().asWkt(), wkt2 ); diff --git a/tests/src/app/testqgsmaptooloffsetcurve.cpp b/tests/src/app/testqgsmaptooloffsetcurve.cpp index f14cf642f4bd..063ddb54af07 100644 --- a/tests/src/app/testqgsmaptooloffsetcurve.cpp +++ b/tests/src/app/testqgsmaptooloffsetcurve.cpp @@ -29,15 +29,15 @@ * \ingroup UnitTests * This is a unit test for the vertex tool */ -class TestQgsMapToolOffsetCurve: public QObject +class TestQgsMapToolOffsetCurve : public QObject { Q_OBJECT public: TestQgsMapToolOffsetCurve(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testOffsetCurveDefault(); void testOffsetCurveJoinStyle(); diff --git a/tests/src/app/testqgsmaptoolrectangle.cpp b/tests/src/app/testqgsmaptoolrectangle.cpp index 31e3fb5c0093..c742e272890e 100644 --- a/tests/src/app/testqgsmaptoolrectangle.cpp +++ b/tests/src/app/testqgsmaptoolrectangle.cpp @@ -100,7 +100,7 @@ void TestQgsMapToolRectangle::cleanup() void TestQgsMapToolRectangle::resetMapTool( QgsMapToolShapeMetadata *metadata ) { - mMapTool->setCurrentShapeMapTool( metadata ) ; + mMapTool->setCurrentShapeMapTool( metadata ); } void TestQgsMapToolRectangle::testRectangleFromCenter() diff --git a/tests/src/app/testqgsmaptoolregularpolygon.cpp b/tests/src/app/testqgsmaptoolregularpolygon.cpp index fa60e0e49319..754ee2d86743 100644 --- a/tests/src/app/testqgsmaptoolregularpolygon.cpp +++ b/tests/src/app/testqgsmaptoolregularpolygon.cpp @@ -98,7 +98,7 @@ void TestQgsMapToolRegularPolygon::cleanup() void TestQgsMapToolRegularPolygon::resetMapTool( QgsMapToolShapeMetadata *metadata ) { - mMapTool->setCurrentShapeMapTool( metadata ) ; + mMapTool->setCurrentShapeMapTool( metadata ); } void TestQgsMapToolRegularPolygon::testRegularPolygonFrom2Points() @@ -115,7 +115,7 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFrom2Points() utils.mouseClick( 2, 1, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "LineString Z (0 0 333, 2 1 333, 4 0 333, 4 -2 333, 2 -3 333, 0 -2 333, 0 0 333)"; @@ -140,7 +140,7 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFrom2PointsWithDeletedVerte utils.mouseClick( 2, 1, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "LineString Z (0 0 333, 2 1 333, 4 0 333, 4 -2 333, 2 -3 333, 0 -2 333, 0 0 333)"; @@ -165,7 +165,7 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPoint() utils.mouseClick( 2, 1, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "LineString Z (1 2 222, 3 0 222, 1 -2 222, -1 -2 222, -3 0 222, -1 2 222, 1 2 222)"; @@ -190,7 +190,7 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndPointWithDelet utils.mouseClick( 2, 1, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "LineString Z (1 2 222, 3 0 222, 1 -2 222, -1 -2 222, -3 0 222, -1 2 222, 1 2 222)"; @@ -215,7 +215,7 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCroner() utils.mouseClick( 2, 1, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "LineString Z (2 1 111, 2 -1 111, 0 -2 111, -2 -1 111, -2 1 111, 0 2 111, 2 1 111)"; @@ -240,7 +240,7 @@ void TestQgsMapToolRegularPolygon::testRegularPolygonFromCenterAndCronerWithDele utils.mouseClick( 2, 1, Qt::RightButton ); const QgsFeatureId newFid = utils.newFeatureId(); - QCOMPARE( mLayer->featureCount(), ( long )1 ); + QCOMPARE( mLayer->featureCount(), ( long ) 1 ); const QgsFeature f = mLayer->getFeature( newFid ); const QString wkt = "LineString Z (2 1 111, 2 -1 111, 0 -2 111, -2 -1 111, -2 1 111, 0 2 111, 2 1 111)"; diff --git a/tests/src/app/testqgsmaptoolreshape.cpp b/tests/src/app/testqgsmaptoolreshape.cpp index dd0a888c1923..4a9cbbcf7153 100644 --- a/tests/src/app/testqgsmaptoolreshape.cpp +++ b/tests/src/app/testqgsmaptoolreshape.cpp @@ -32,15 +32,15 @@ * \ingroup UnitTests * This is a unit test for the vertex tool */ -class TestQgsMapToolReshape: public QObject +class TestQgsMapToolReshape : public QObject { Q_OBJECT public: TestQgsMapToolReshape(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testReshapeZ(); void testTopologicalEditing(); @@ -117,7 +117,7 @@ void TestQgsMapToolReshape::initTestCase() QgsFeatureList flist; flist << f1 << f2; mLayerLineZ->dataProvider()->addFeatures( flist ); - QCOMPARE( mLayerLineZ->featureCount(), ( long )2 ); + QCOMPARE( mLayerLineZ->featureCount(), ( long ) 2 ); QCOMPARE( mLayerLineZ->getFeature( 1 ).geometry().asWkt(), wkt1 ); QCOMPARE( mLayerLineZ->getFeature( 2 ).geometry().asWkt(), wkt2 ); @@ -132,7 +132,7 @@ void TestQgsMapToolReshape::initTestCase() QgsFeatureList flistPoint; flistPoint << f3 << f4; mLayerPointZ->dataProvider()->addFeatures( flistPoint ); - QCOMPARE( mLayerPointZ->featureCount(), ( long )2 ); + QCOMPARE( mLayerPointZ->featureCount(), ( long ) 2 ); QCOMPARE( mLayerPointZ->getFeature( 1 ).geometry().asWkt(), wkt3 ); QCOMPARE( mLayerPointZ->getFeature( 2 ).geometry().asWkt(), wkt4 ); @@ -143,7 +143,7 @@ void TestQgsMapToolReshape::initTestCase() QgsFeatureList flistPolygon; flistPolygon << f5; mLayerPolygonZ->dataProvider()->addFeatures( flistPolygon ); - QCOMPARE( mLayerPolygonZ->featureCount(), ( long )1 ); + QCOMPARE( mLayerPolygonZ->featureCount(), ( long ) 1 ); QCOMPARE( mLayerPolygonZ->getFeature( 1 ).geometry().asWkt(), wkt5 ); mLayerTopo->startEditing(); @@ -156,7 +156,7 @@ void TestQgsMapToolReshape::initTestCase() QgsFeatureList flistTopo; flistTopo << f6 << f7; mLayerTopo->dataProvider()->addFeatures( flistTopo ); - QCOMPARE( mLayerTopo->featureCount(), ( long )2 ); + QCOMPARE( mLayerTopo->featureCount(), ( long ) 2 ); QCOMPARE( mLayerTopo->getFeature( 1 ).geometry().asWkt(), wkt6 ); QCOMPARE( mLayerTopo->getFeature( 2 ).geometry().asWkt(), wkt7 ); @@ -231,7 +231,6 @@ void TestQgsMapToolReshape::testReshapeZ() const QString wkt3 = "LineString Z (0 0 0, 1 1 0, 1 2 0, 2 1 5, 5 5 5, 6 6 6, 7 5 4, 3 2 1)"; QCOMPARE( mLayerLineZ->getFeature( 1 ).geometry().asWkt(), wkt3 ); mLayerLineZ->undoStack()->undo(); - } void TestQgsMapToolReshape::testTopologicalEditing() diff --git a/tests/src/app/testqgsmaptoolreverseline.cpp b/tests/src/app/testqgsmaptoolreverseline.cpp index 079bbdde318a..413dba1c66ec 100644 --- a/tests/src/app/testqgsmaptoolreverseline.cpp +++ b/tests/src/app/testqgsmaptoolreverseline.cpp @@ -70,28 +70,29 @@ void TestQgsMapToolReverseLine::cleanupTestCase() void TestQgsMapToolReverseLine::testReverseCurve() { //create a temporary layer - std::unique_ptr< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature curve( memoryLayer->dataProvider()->fields(), 1 ); curve.setAttribute( QStringLiteral( "pk" ), 1 ); curve.setGeometry( QgsGeometry::fromWkt( QStringLiteral( - "CircularString(10 10, 5 5)" ) ) ); + "CircularString(10 10, 5 5)" + ) ) ); memoryLayer->dataProvider()->addFeatures( QgsFeatureList() << curve ); mCanvas->setLayers( QList() << memoryLayer.get() ); mCanvas->setCurrentLayer( memoryLayer.get() ); - std::unique_ptr< QgsMapToolReverseLine > tool( new QgsMapToolReverseLine( mCanvas ) ); + std::unique_ptr tool( new QgsMapToolReverseLine( mCanvas ) ); memoryLayer->startEditing(); const QgsPointXY mapPoint = mCanvas->getCoordinateTransform()->transform( 5, 5 ); - const std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( mapPoint.x(), mapPoint.y() ) - ) ); + const std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + QPoint( mapPoint.x(), mapPoint.y() ) + ) ); // trigger mouseRelease handler tool->canvasPressEvent( event.get() ); tool->canvasReleaseEvent( event.get() ); @@ -100,33 +101,33 @@ void TestQgsMapToolReverseLine::testReverseCurve() const QString wkt = "CircularString (5 5, 10 10)"; QCOMPARE( f.geometry().asWkt(), wkt ); memoryLayer->rollBack(); - } void TestQgsMapToolReverseLine::testReverseLineString() { //create a temporary layer - std::unique_ptr< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature line( memoryLayer->dataProvider()->fields(), 1 ); line.setAttribute( QStringLiteral( "pk" ), 1 ); line.setGeometry( QgsGeometry::fromWkt( QStringLiteral( - "LineStringZ(0 0 0, 10 10 10, 5 5 5)" ) ) ); + "LineStringZ(0 0 0, 10 10 10, 5 5 5)" + ) ) ); memoryLayer->dataProvider()->addFeatures( QgsFeatureList() << line ); mCanvas->setLayers( QList() << memoryLayer.get() ); mCanvas->setCurrentLayer( memoryLayer.get() ); - std::unique_ptr< QgsMapToolReverseLine > tool( new QgsMapToolReverseLine( mCanvas ) ); + std::unique_ptr tool( new QgsMapToolReverseLine( mCanvas ) ); memoryLayer->startEditing(); const QgsPointXY mapPoint = mCanvas->getCoordinateTransform()->transform( 6, 6 ); - const std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( mapPoint.x(), mapPoint.y() ) - ) ); + const std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + QPoint( mapPoint.x(), mapPoint.y() ) + ) ); // trigger mouseRelease handler tool->canvasPressEvent( event.get() ); tool->canvasReleaseEvent( event.get() ); @@ -142,27 +143,28 @@ void TestQgsMapToolReverseLine::testReverseLineString() void TestQgsMapToolReverseLine::testReverseMultiLineString() { //create a temporary layer - std::unique_ptr< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "MultiLineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "MultiLineStringZ?crs=EPSG:3946&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature multi( memoryLayer->dataProvider()->fields(), 1 ); multi.setAttribute( QStringLiteral( "pk" ), 1 ); multi.setGeometry( QgsGeometry::fromWkt( QStringLiteral( - "MultiLineString Z((0 0 0, 10 10 10, 5 5 5), (100 100 100, 120 120 120))" ) ) ); + "MultiLineString Z((0 0 0, 10 10 10, 5 5 5), (100 100 100, 120 120 120))" + ) ) ); memoryLayer->dataProvider()->addFeatures( QgsFeatureList() << multi ); mCanvas->setLayers( QList() << memoryLayer.get() ); mCanvas->setCurrentLayer( memoryLayer.get() ); - std::unique_ptr< QgsMapToolReverseLine > tool( new QgsMapToolReverseLine( mCanvas ) ); + std::unique_ptr tool( new QgsMapToolReverseLine( mCanvas ) ); memoryLayer->startEditing(); QgsPointXY mapPoint = mCanvas->getCoordinateTransform()->transform( 6, 6 ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( mapPoint.x(), mapPoint.y() ) - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + QPoint( mapPoint.x(), mapPoint.y() ) + ) ); // trigger mouseRelease handler tool->canvasPressEvent( event.get() ); tool->canvasReleaseEvent( event.get() ); @@ -173,10 +175,10 @@ void TestQgsMapToolReverseLine::testReverseMultiLineString() mapPoint = mCanvas->getCoordinateTransform()->transform( 110, 110 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( mapPoint.x(), mapPoint.y() ) - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( mapPoint.x(), mapPoint.y() ) + ) ); // trigger mouseRelease handler tool->canvasPressEvent( event.get() ); tool->canvasReleaseEvent( event.get() ); diff --git a/tests/src/app/testqgsmaptoolrotatefeature.cpp b/tests/src/app/testqgsmaptoolrotatefeature.cpp index 4c56a83bce90..b997bb25eaa2 100644 --- a/tests/src/app/testqgsmaptoolrotatefeature.cpp +++ b/tests/src/app/testqgsmaptoolrotatefeature.cpp @@ -33,15 +33,15 @@ * \ingroup UnitTests * This is a unit test for the vertex tool */ -class TestQgsMapToolRotateFeature: public QObject +class TestQgsMapToolRotateFeature : public QObject { Q_OBJECT public: TestQgsMapToolRotateFeature(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testRotateFeature(); void testRotateFeatureManualAnchor(); @@ -240,8 +240,6 @@ void TestQgsMapToolRotateFeature::testRotateFeatureManualAnchorSnapping() cfg.setTolerance( tolerance ); cfg.setUnits( units ); mCanvas->snappingUtils()->setConfig( cfg ); - - } void TestQgsMapToolRotateFeature::testAvoidIntersectionsAndTopoEdit() diff --git a/tests/src/app/testqgsmaptoolscalefeature.cpp b/tests/src/app/testqgsmaptoolscalefeature.cpp index f03e316a17d2..7d02df40f5b6 100644 --- a/tests/src/app/testqgsmaptoolscalefeature.cpp +++ b/tests/src/app/testqgsmaptoolscalefeature.cpp @@ -33,15 +33,15 @@ * \ingroup UnitTests * This is a unit test for the vertex tool */ -class TestQgsMapToolScaleFeature: public QObject +class TestQgsMapToolScaleFeature : public QObject { Q_OBJECT public: TestQgsMapToolScaleFeature(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testScaleFeature(); void testScaleFeatureWithAnchor(); diff --git a/tests/src/app/testqgsmaptoolselect.cpp b/tests/src/app/testqgsmaptoolselect.cpp index f2b1f7ff7251..6c3ffd26ef77 100644 --- a/tests/src/app/testqgsmaptoolselect.cpp +++ b/tests/src/app/testqgsmaptoolselect.cpp @@ -36,10 +36,10 @@ class TestQgsMapToolSelect : public QObject TestQgsMapToolSelect() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void selectInvalidPolygons(); // test selecting invalid polygons @@ -50,7 +50,7 @@ class TestQgsMapToolSelect : public QObject // Release return with delete [] unsigned char * - hex2bytes( const char *hex, int *size ) + hex2bytes( const char *hex, int *size ) { QByteArray ba = QByteArray::fromHex( hex ); unsigned char *out = new unsigned char[ba.size()]; @@ -69,7 +69,6 @@ class TestQgsMapToolSelect : public QObject geom.fromWkb( wkb, wkbsize ); return geom; } - }; void TestQgsMapToolSelect::initTestCase() @@ -105,19 +104,19 @@ void TestQgsMapToolSelect::cleanup() // private QgsFeatureList -TestQgsMapToolSelect::testSelectVector( QgsVectorLayer *layer, double xGeoref, double yGeoref ) + TestQgsMapToolSelect::testSelectVector( QgsVectorLayer *layer, double xGeoref, double yGeoref ) { - std::unique_ptr< QgsMapToolSelect > tool( new QgsMapToolSelect( canvas ) ); + std::unique_ptr tool( new QgsMapToolSelect( canvas ) ); const QgsPointXY mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); // make given vector layer current canvas->setCurrentLayer( layer ); - const std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - canvas, - QEvent::MouseButtonRelease, - QPoint( mapPoint.x(), mapPoint.y() ) - ) ); + const std::unique_ptr event( new QgsMapMouseEvent( + canvas, + QEvent::MouseButtonRelease, + QPoint( mapPoint.x(), mapPoint.y() ) + ) ); // trigger mouseRelease handler tool->canvasReleaseEvent( event.get() ); @@ -129,15 +128,15 @@ TestQgsMapToolSelect::testSelectVector( QgsVectorLayer *layer, double xGeoref, d void TestQgsMapToolSelect::selectInvalidPolygons() { //create a temporary layer - std::unique_ptr< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature f1( memoryLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); // This geometry is an invalid polygon (3 distinct vertices). // GEOS reported invalidity: Points of LinearRing do not form a closed linestring f1.setGeometry( geomFromHexWKB( - "010300000001000000030000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000" - ) ); + "010300000001000000030000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000" + ) ); memoryLayer->dataProvider()->addFeatures( QgsFeatureList() << f1 ); canvas->setExtent( QgsRectangle( 0, 0, 10, 10 ) ); @@ -147,7 +146,6 @@ void TestQgsMapToolSelect::selectInvalidPolygons() selected = testSelectVector( memoryLayer.get(), 6, 4 ); QCOMPARE( selected.length(), 1 ); QCOMPARE( selected[0].attribute( "pk" ), QVariant( 1 ) ); - } diff --git a/tests/src/app/testqgsmaptoolsplitfeatures.cpp b/tests/src/app/testqgsmaptoolsplitfeatures.cpp index a29f91cb1e19..6b6ec31b4cf6 100644 --- a/tests/src/app/testqgsmaptoolsplitfeatures.cpp +++ b/tests/src/app/testqgsmaptoolsplitfeatures.cpp @@ -97,16 +97,12 @@ void TestQgsMapToolSplitFeatures::initTestCase() mCanvas->show(); // to make the canvas resize mCanvas->hide(); - QgsProject::instance()->addMapLayers( QList() << mMultiLineStringLayer - << mPolygonLayer - << mMultiPolygonLayer ); + QgsProject::instance()->addMapLayers( QList() << mMultiLineStringLayer << mPolygonLayer << mMultiPolygonLayer ); // set layers in canvas - mCanvas->setLayers( QList() << mMultiLineStringLayer - << mPolygonLayer - << mMultiPolygonLayer ); + mCanvas->setLayers( QList() << mMultiLineStringLayer << mPolygonLayer << mMultiPolygonLayer ); - QgsMapToolSplitFeatures *mapTool = new QgsMapToolSplitFeatures( mCanvas ) ; + QgsMapToolSplitFeatures *mapTool = new QgsMapToolSplitFeatures( mCanvas ); mCanvas->setMapTool( mapTool ); mUtils = new TestQgsMapToolUtils( mapTool ); } @@ -129,7 +125,6 @@ void TestQgsMapToolSplitFeatures::cleanup() QPoint TestQgsMapToolSplitFeatures::mapToPoint( double x, double y ) { - const QgsPointXY mapPoint = mCanvas->mapSettings().mapToPixel().transform( x, y ); return QPoint( std::round( mapPoint.x() ), std::round( mapPoint.y() ) ); diff --git a/tests/src/app/testqgsmaptoolsplitparts.cpp b/tests/src/app/testqgsmaptoolsplitparts.cpp index ddb25417f070..a1586116aaf3 100644 --- a/tests/src/app/testqgsmaptoolsplitparts.cpp +++ b/tests/src/app/testqgsmaptoolsplitparts.cpp @@ -91,7 +91,6 @@ void TestQgsMapToolSplitParts::cleanupTestCase() QPoint TestQgsMapToolSplitParts::mapToPoint( double x, double y ) { - const QgsPointXY mapPoint = mCanvas->mapSettings().mapToPixel().transform( x, y ); return QPoint( std::round( mapPoint.x() ), std::round( mapPoint.y() ) ); @@ -99,36 +98,35 @@ QPoint TestQgsMapToolSplitParts::mapToPoint( double x, double y ) void TestQgsMapToolSplitParts::testSplitMultiLineString() { - mCanvas->setCurrentLayer( mMultiLineStringLayer ); - QgsMapToolSplitParts *mapTool = new QgsMapToolSplitParts( mCanvas ) ; + QgsMapToolSplitParts *mapTool = new QgsMapToolSplitParts( mCanvas ); mCanvas->setMapTool( mapTool ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 4, 7 ), - Qt::LeftButton - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 4, 7 ), + Qt::LeftButton + ) ); mapTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 4, -1 ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 4, -1 ), + Qt::LeftButton + ) ); mapTool->cadCanvasReleaseEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - mapToPoint( 4, -1 ), - Qt::RightButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + mapToPoint( 4, -1 ), + Qt::RightButton + ) ); mapTool->cadCanvasReleaseEvent( event.get() ); - QCOMPARE( mMultiLineStringLayer->featureCount(), ( long )2 ); + QCOMPARE( mMultiLineStringLayer->featureCount(), ( long ) 2 ); QCOMPARE( mMultiLineStringLayer->getFeature( lineF1.id() ).geometry().asWkt(), QStringLiteral( "MultiLineString ((0 0, 4 0),(4 0, 10 0))" ) ); QCOMPARE( mMultiLineStringLayer->getFeature( lineF2.id() ).geometry().asWkt(), QStringLiteral( "MultiLineString ((0 5, 4 5),(4 5, 10 5),(10 5, 15 5))" ) ); diff --git a/tests/src/app/testqgsmaptooltrimextendfeature.cpp b/tests/src/app/testqgsmaptooltrimextendfeature.cpp index 2fedd6b8b491..cc2ca07dc70e 100644 --- a/tests/src/app/testqgsmaptooltrimextendfeature.cpp +++ b/tests/src/app/testqgsmaptooltrimextendfeature.cpp @@ -107,7 +107,8 @@ class TestQgsMapToolTrimExtendFeature : public QObject QgsFeature multi( vlMultiLine->dataProvider()->fields(), 1 ); multi.setAttribute( QStringLiteral( "pk" ), 1 ); multi.setGeometry( QgsGeometry::fromWkt( QStringLiteral( - "MultiLineString ((10 0, 14 0),(11 1, 11 0.5),(14 -2, 14 2))" ) ) ); + "MultiLineString ((10 0, 14 0),(11 1, 11 0.5),(14 -2, 14 2))" + ) ) ); vlMultiLine->dataProvider()->addFeatures( QgsFeatureList() << multi ); @@ -123,11 +124,13 @@ class TestQgsMapToolTrimExtendFeature : public QObject QgsFeature linez( vlLineZ->dataProvider()->fields(), 1 ); linez.setAttribute( QStringLiteral( "pk" ), 1 ); linez.setGeometry( QgsGeometry::fromWkt( QStringLiteral( - "LineStringZ (3 5 5, 2 6 10)" ) ) ); + "LineStringZ (3 5 5, 2 6 10)" + ) ) ); QgsFeature linez2( vlLineZ->dataProvider()->fields(), 2 ); linez2.setAttribute( QStringLiteral( "pk" ), 2 ); linez2.setGeometry( QgsGeometry::fromWkt( QStringLiteral( - "LineStringZ (0 5 100, 3 8 200)" ) ) ); + "LineStringZ (0 5 100, 3 8 200)" + ) ) ); vlLineZ->dataProvider()->addFeatures( QgsFeatureList() << linez << linez2 ); @@ -189,10 +192,8 @@ class TestQgsMapToolTrimExtendFeature : public QObject } - void testPolygon() { - // vector layer with a triangle in a rectangle: // (0,3) +-------------------+ (3,3) // | (1,2) +---+ (2,2) | @@ -202,40 +203,40 @@ class TestQgsMapToolTrimExtendFeature : public QObject // | + (2,1) | // (0,0) +-------------------+ (3,0) mCanvas->setCurrentLayer( vlPolygon.get() ); - std::unique_ptr< QgsMapToolTrimExtendFeature > tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); vlPolygon->startEditing(); // Limit QgsPointXY pt; pt = tool->canvas()->mapSettings().mapToPixel().transform( 0, 0 ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); // Extend pt = tool->canvas()->mapSettings().mapToPixel().transform( 1, 1.5 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); @@ -266,40 +267,40 @@ class TestQgsMapToolTrimExtendFeature : public QObject * | */ mCanvas->setCurrentLayer( vlMultiLine.get() ); - std::unique_ptr< QgsMapToolTrimExtendFeature > tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); vlMultiLine->startEditing(); // Limit QgsPointXY pt; pt = tool->canvas()->mapSettings().mapToPixel().transform( 12, 0 ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); // Extend pt = tool->canvas()->mapSettings().mapToPixel().transform( 11, 0.8 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); /* @@ -318,34 +319,34 @@ class TestQgsMapToolTrimExtendFeature : public QObject // Limit pt = tool->canvas()->mapSettings().mapToPixel().transform( 12, 0 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); // Extend pt = tool->canvas()->mapSettings().mapToPixel().transform( 14, 1 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); /* @@ -367,33 +368,33 @@ class TestQgsMapToolTrimExtendFeature : public QObject // Limit pt = tool->canvas()->mapSettings().mapToPixel().transform( 12, 0 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); // Extend pt = tool->canvas()->mapSettings().mapToPixel().transform( 14, -1 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); /* @@ -411,7 +412,6 @@ class TestQgsMapToolTrimExtendFeature : public QObject void testLineZ() { - /* (3 8 200) / / (2 6 10) @@ -419,44 +419,43 @@ class TestQgsMapToolTrimExtendFeature : public QObject (0 5 100) (3 5 5) */ mCanvas->setCurrentLayer( vlLineZ.get() ); - std::unique_ptr< QgsMapToolTrimExtendFeature > tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); vlLineZ->startEditing(); // Limit QgsPointXY pt; pt = tool->canvas()->mapSettings().mapToPixel().transform( 0, 5 ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); // Extend pt = tool->canvas()->mapSettings().mapToPixel().transform( 3, 5 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); - /* (3 8 200) / /\ (1.5 6.5 150) @@ -477,41 +476,41 @@ class TestQgsMapToolTrimExtendFeature : public QObject QgsProject::instance()->setTopologicalEditing( true ); mCanvas->setCurrentLayer( vlTopoEdit.get() ); - std::unique_ptr< QgsMapToolTrimExtendFeature > tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); + std::unique_ptr tool( new QgsMapToolTrimExtendFeature( mCanvas ) ); vlTopoLimit->startEditing(); vlTopoEdit->startEditing(); // Limit QgsPointXY pt; pt = tool->canvas()->mapSettings().mapToPixel().transform( 30, 15 ); - std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + std::unique_ptr event( new QgsMapMouseEvent( + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); // Extend pt = tool->canvas()->mapSettings().mapToPixel().transform( 22, 15 ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseMove, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ) - ) ); + mCanvas, + QEvent::MouseMove, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ) + ) ); tool->canvasMoveEvent( event.get() ); event.reset( new QgsMapMouseEvent( - mCanvas, - QEvent::MouseButtonRelease, - QPoint( std::round( pt.x() ), std::round( pt.y() ) ), - Qt::LeftButton - ) ); + mCanvas, + QEvent::MouseButtonRelease, + QPoint( std::round( pt.x() ), std::round( pt.y() ) ), + Qt::LeftButton + ) ); tool->canvasReleaseEvent( event.get() ); const QgsFeature fEdit = vlTopoEdit->getFeature( 1 ); @@ -526,7 +525,6 @@ class TestQgsMapToolTrimExtendFeature : public QObject QgsProject::instance()->setTopologicalEditing( topologicalEditing ); } - }; QGSTEST_MAIN( TestQgsMapToolTrimExtendFeature ) diff --git a/tests/src/app/testqgsmaptoolutils.h b/tests/src/app/testqgsmaptoolutils.h index 51d5414c659a..c5cc31f691fb 100644 --- a/tests/src/app/testqgsmaptoolutils.h +++ b/tests/src/app/testqgsmaptoolutils.h @@ -220,4 +220,3 @@ class TestQgsMapToolUtils private: QgsMapTool *mMapTool = nullptr; }; - diff --git a/tests/src/app/testqgsmeasurebearingtool.cpp b/tests/src/app/testqgsmeasurebearingtool.cpp index ba10fc4e0127..e14d906f0369 100644 --- a/tests/src/app/testqgsmeasurebearingtool.cpp +++ b/tests/src/app/testqgsmeasurebearingtool.cpp @@ -39,10 +39,10 @@ class TestQgsMeasureBearingTool : public QObject TestQgsMeasureBearingTool(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testBearingCartesian(); void testBearingEllipsoid(); @@ -95,7 +95,7 @@ void TestQgsMeasureBearingTool::testBearingCartesian() QgsProject::instance()->setCrs( srs ); QgsProject::instance()->setEllipsoid( QString() ); - QgsMapToolMeasureBearing *mapTool = new QgsMapToolMeasureBearing( mCanvas ) ; + QgsMapToolMeasureBearing *mapTool = new QgsMapToolMeasureBearing( mCanvas ); mCanvas->setMapTool( mapTool ); QVERIFY( !mapTool->mResultDisplay ); @@ -129,7 +129,7 @@ void TestQgsMeasureBearingTool::testBearingEllipsoid() QgsProject::instance()->setCrs( srs ); QgsProject::instance()->setEllipsoid( QStringLiteral( "EPSG:7030" ) ); - QgsMapToolMeasureBearing *mapTool = new QgsMapToolMeasureBearing( mCanvas ) ; + QgsMapToolMeasureBearing *mapTool = new QgsMapToolMeasureBearing( mCanvas ); mCanvas->setMapTool( mapTool ); QVERIFY( !mapTool->mResultDisplay ); diff --git a/tests/src/app/testqgsmeasuretool.cpp b/tests/src/app/testqgsmeasuretool.cpp index 6d88d340955a..ebbd622b3c6c 100644 --- a/tests/src/app/testqgsmeasuretool.cpp +++ b/tests/src/app/testqgsmeasuretool.cpp @@ -32,10 +32,10 @@ class TestQgsMeasureTool : public QObject TestQgsMeasureTool(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testLengthCalculationCartesian(); void testLengthCalculationProjected(); void testLengthCalculationNoCrs(); @@ -93,8 +93,8 @@ void TestQgsMeasureTool::testLengthCalculationCartesian() QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Meters ); // run length calculation - std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); + std::unique_ptr tool( new QgsMeasureTool( mCanvas, false ) ); + std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); dlg->mCartesian->setChecked( true ); @@ -112,8 +112,8 @@ void TestQgsMeasureTool::testLengthCalculationCartesian() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); - std::unique_ptr< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.get() ) ); + std::unique_ptr tool2( new QgsMeasureTool( mCanvas, false ) ); + std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); dlg2->mCartesian->setChecked( true ); tool2->restart(); @@ -145,7 +145,6 @@ void TestQgsMeasureTool::testLengthCalculationCartesian() QGSCOMPARENEAR( p0.y(), n0.y(), 0.001 ); QGSCOMPARENEAR( p1.x(), n1.x(), 0.001 ); QGSCOMPARENEAR( p1.y(), n1.y(), 0.001 ); - } void TestQgsMeasureTool::testLengthCalculationProjected() { @@ -161,8 +160,8 @@ void TestQgsMeasureTool::testLengthCalculationProjected() QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Meters ); // run length calculation - std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); + std::unique_ptr tool( new QgsMeasureTool( mCanvas, false ) ); + std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); dlg->mEllipsoidal->setChecked( true ); tool->restart(); @@ -179,8 +178,8 @@ void TestQgsMeasureTool::testLengthCalculationProjected() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( Qgis::DistanceUnit::Feet ); - std::unique_ptr< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.get() ) ); + std::unique_ptr tool2( new QgsMeasureTool( mCanvas, false ) ); + std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); dlg2->mEllipsoidal->setChecked( true ); tool2->restart(); @@ -226,8 +225,8 @@ void TestQgsMeasureTool::testLengthCalculationNoCrs() QgsProject::instance()->setCrs( QgsCoordinateReferenceSystem() ); // run length calculation - std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, false ) ); - std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); + std::unique_ptr tool( new QgsMeasureTool( mCanvas, false ) ); + std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); tool->restart(); tool->addPoint( QgsPointXY( 2484588, 2425722 ) ); @@ -256,8 +255,8 @@ void TestQgsMeasureTool::testAreaCalculationCartesian() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run length calculation - std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); + std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); dlg->mCartesian->setChecked( true ); @@ -277,8 +276,8 @@ void TestQgsMeasureTool::testAreaCalculationCartesian() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); - std::unique_ptr< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.get() ) ); + std::unique_ptr tool2( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); dlg2->mCartesian->setChecked( true ); tool2->restart(); @@ -310,8 +309,8 @@ void TestQgsMeasureTool::testAreaCalculationProjected() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run length calculation - std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); + std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); dlg->mEllipsoidal->setChecked( true ); @@ -331,8 +330,8 @@ void TestQgsMeasureTool::testAreaCalculationProjected() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMiles ); - std::unique_ptr< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.get() ) ); + std::unique_ptr tool2( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr dlg2( new QgsMeasureDialog( tool2.get() ) ); dlg2->mEllipsoidal->setChecked( true ); @@ -358,8 +357,8 @@ void TestQgsMeasureTool::degreeDecimalPlaces() QgsSettings s; s.setValue( QStringLiteral( "qgis/measure/decimalplaces" ), 3 ); - const std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); + const std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); QCOMPARE( dlg->formatDistance( 11, false ), QString( "11.000 deg" ) ); QCOMPARE( dlg->formatDistance( 0.005, false ), QString( "0.005 deg" ) ); @@ -367,7 +366,6 @@ void TestQgsMeasureTool::degreeDecimalPlaces() QCOMPARE( dlg->formatDistance( 0.001, false ), QString( "0.0010 deg" ) ); QCOMPARE( dlg->formatDistance( 0.0001, false ), QString( "0.00010 deg" ) ); QCOMPARE( dlg->formatDistance( 0.00001, false ), QString( "0.000010 deg" ) ); - } void TestQgsMeasureTool::testToolDesactivationNoExtraPoint() @@ -380,19 +378,17 @@ void TestQgsMeasureTool::testToolDesactivationNoExtraPoint() QgsProject::instance()->setAreaUnits( Qgis::AreaUnit::SquareMeters ); // run length calculation - std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, true ) ); - std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); + std::unique_ptr tool( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr dlg( new QgsMeasureDialog( tool.get() ) ); dlg->mEllipsoidal->setChecked( true ); - auto moveCanvas = [this]( int x, int y, int delay = 0 ) - { + auto moveCanvas = [this]( int x, int y, int delay = 0 ) { auto widget = mCanvas->viewport(); QTest::mouseMove( widget, QPoint( x, y ), delay ); }; - auto clickCanvas = [this]( int x, int y ) - { + auto clickCanvas = [this]( int x, int y ) { auto widget = mCanvas->viewport(); QTest::mouseMove( widget, QPoint( x, y ) ); QTest::mouseClick( mCanvas->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint( x, y ), 50 ); diff --git a/tests/src/app/testqgsmergeattributesdialog.cpp b/tests/src/app/testqgsmergeattributesdialog.cpp index 7927d3b54a12..27e10c582ee3 100644 --- a/tests/src/app/testqgsmergeattributesdialog.cpp +++ b/tests/src/app/testqgsmergeattributesdialog.cpp @@ -26,7 +26,8 @@ class TestQgsMergeattributesDialog : public QgsTest Q_OBJECT public: - TestQgsMergeattributesDialog() : QgsTest( QStringLiteral( "Merge attributes dialog" ) ) + TestQgsMergeattributesDialog() + : QgsTest( QStringLiteral( "Merge attributes dialog" ) ) {} private: @@ -52,18 +53,19 @@ class TestQgsMergeattributesDialog : public QgsTest QgsVectorFileWriter::SaveVectorOptions options; QgsVectorLayer ml( "Polygon", "test", "memory" ); QVERIFY( ml.isValid() ); - QTemporaryFile tmpFile( QDir::tempPath() + "/TestQgsMergeattributesDialog" ); + QTemporaryFile tmpFile( QDir::tempPath() + "/TestQgsMergeattributesDialog" ); tmpFile.open(); - const QString fileName( tmpFile.fileName( ) ); + const QString fileName( tmpFile.fileName() ); options.driverName = "GPKG"; options.layerName = "test"; QString newFilename; const QgsVectorFileWriter::WriterError error( QgsVectorFileWriter::writeAsVectorFormatV3( - &ml, - fileName, - ml.transformContext(), - options, nullptr, - &newFilename ) ); + &ml, + fileName, + ml.transformContext(), + options, nullptr, + &newFilename + ) ); QCOMPARE( error, QgsVectorFileWriter::WriterError::NoError ); QgsVectorLayer layer( QStringLiteral( "%1|layername=test" ).arg( newFilename ), "src_test", "ogr" ); @@ -113,8 +115,8 @@ class TestQgsMergeattributesDialog : public QgsTest QgsField notUniqueField( QStringLiteral( "not_unique" ), QMetaType::Type::Int ); QVERIFY( ml.dataProvider()->addAttributes( - { uniqueField, notUniqueField } - ) ); + { uniqueField, notUniqueField } + ) ); ml.updateFields(); QCOMPARE( ml.fields().at( 0 ).constraints().constraints(), QgsFieldConstraints::ConstraintUnique ); @@ -122,14 +124,14 @@ class TestQgsMergeattributesDialog : public QgsTest // Create a feature QgsFeature f1( ml.fields(), 1 ); - f1.setAttributes( { 11, 12} ); + f1.setAttributes( { 11, 12 } ); f1.setGeometry( QgsGeometry::fromWkt( "POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))" ) ); QVERIFY( ml.dataProvider()->addFeature( f1 ) ); QCOMPARE( ml.featureCount(), 1 ); // And a bigger feature QgsFeature f2( ml.fields(), 2 ); - f2.setAttributes( { 21, 22} ); + f2.setAttributes( { 21, 22 } ); f2.setGeometry( QgsGeometry::fromWkt( "POLYGON((3 3, 10 3, 10 10, 3 10, 3 3))" ) ); QVERIFY( ml.dataProvider()->addFeature( f2 ) ); QCOMPARE( ml.featureCount(), 2 ); diff --git a/tests/src/app/testqgsmeshcalculatordialog.cpp b/tests/src/app/testqgsmeshcalculatordialog.cpp index 6757698084a1..f8aa9035761b 100644 --- a/tests/src/app/testqgsmeshcalculatordialog.cpp +++ b/tests/src/app/testqgsmeshcalculatordialog.cpp @@ -34,10 +34,10 @@ class TestQgsMeshCalculatorDialog : public QObject TestQgsMeshCalculatorDialog(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testCalc(); @@ -70,7 +70,8 @@ void TestQgsMeshCalculatorDialog::initTestCase() mpMeshLayer->dataProvider()->addDataset( testDataDir + "/quad_and_triangle_els_face_vector.dat" ); QgsProject::instance()->addMapLayers( - QList() << mpMeshLayer ); + QList() << mpMeshLayer + ); } //runs after all tests @@ -84,7 +85,7 @@ void TestQgsMeshCalculatorDialog::testCalc() if ( !QgsTest::runFlakyTests() ) QSKIP( "This test is disabled on Travis CI environment" ); - std::unique_ptr< QgsMeshCalculatorDialog > dialog( new QgsMeshCalculatorDialog( mpMeshLayer ) ); + std::unique_ptr dialog( new QgsMeshCalculatorDialog( mpMeshLayer ) ); const int groupCount = mpMeshLayer->dataProvider()->datasetGroupCount(); diff --git a/tests/src/app/testqgsprojectexpressions.cpp b/tests/src/app/testqgsprojectexpressions.cpp index d2a59635c933..5c32381e60d5 100644 --- a/tests/src/app/testqgsprojectexpressions.cpp +++ b/tests/src/app/testqgsprojectexpressions.cpp @@ -34,8 +34,8 @@ class TestQgsProjectExpressions : public QObject TestQgsProjectExpressions(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void projectExpressions(); @@ -99,8 +99,8 @@ void TestQgsProjectExpressions::projectExpressions() QCOMPARE( count_project_loaded - count_before_project, 1 ); // myprojectfunction - exp = myExpression; // Re-parse it - QCOMPARE( exp.evaluate().toInt(), 2 ); // Different result because now it's from project + exp = myExpression; // Re-parse it + QCOMPARE( exp.evaluate().toInt(), 2 ); // Different result because now it's from project // Unload expressions from project, reload user ones QgsProject::instance()->cleanFunctionsFromProject(); @@ -108,7 +108,7 @@ void TestQgsProjectExpressions::projectExpressions() QCOMPARE( count_before_project, count_project_unloaded ); // myprojectfunction is gone QCOMPARE( QgsExpression::functionIndex( QStringLiteral( "myprojectfunction" ) ), -1 ); - exp = myExpression; // Re-parse it + exp = myExpression; // Re-parse it QCOMPARE( exp.evaluate().toInt(), 1 ); // Original result, coming from user function } diff --git a/tests/src/app/testqgsprojectproperties.cpp b/tests/src/app/testqgsprojectproperties.cpp index 624ba5cda1b5..1ffefe0ae99a 100644 --- a/tests/src/app/testqgsprojectproperties.cpp +++ b/tests/src/app/testqgsprojectproperties.cpp @@ -39,10 +39,10 @@ class TestQgsProjectProperties : public QObject TestQgsProjectProperties(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testProjectPropertiesDirty(); void testEllipsoidChange(); @@ -76,7 +76,7 @@ void TestQgsProjectProperties::cleanupTestCase() void TestQgsProjectProperties::testProjectPropertiesDirty() { // create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); // add layer to project, to insure presence of layer-related project settings @@ -100,41 +100,40 @@ void TestQgsProjectProperties::testEllipsoidChange() QgsProject::instance()->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "NONE" ) ); - std::unique_ptr< QgsProjectProperties > pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + std::unique_ptr pp = std::make_unique( mQgisApp->mapCanvas() ); pp->apply(); pp.reset(); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "NONE" ) ); QgsProject::instance()->setEllipsoid( QStringLiteral( "ESRI:107900" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->apply(); pp.reset(); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "ESRI:107900" ) ); QgsProject::instance()->setEllipsoid( QStringLiteral( "EPSG:7002" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->apply(); pp.reset(); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "EPSG:7002" ) ); QgsProject::instance()->setEllipsoid( QStringLiteral( "EPSG:7005" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->apply(); pp.reset(); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "EPSG:7005" ) ); QgsProject::instance()->setEllipsoid( QStringLiteral( "NONE" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->apply(); pp.reset(); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "NONE" ) ); QgsProject::instance()->setEllipsoid( QStringLiteral( "PARAMETER:55:66" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->apply(); pp.reset(); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "PARAMETER:55:66" ) ); - } void TestQgsProjectProperties::testEllipsoidCrsSync() @@ -147,7 +146,7 @@ void TestQgsProjectProperties::testEllipsoidCrsSync() QgsProject::instance()->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "NONE" ) ); - std::unique_ptr< QgsProjectProperties > pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + std::unique_ptr pp = std::make_unique( mQgisApp->mapCanvas() ); pp->setSelectedCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ); pp->apply(); pp.reset(); @@ -157,7 +156,7 @@ void TestQgsProjectProperties::testEllipsoidCrsSync() // if ellipsoid is not set to none, then it should always be synced with the project crs choice QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "NONE" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->setSelectedCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ); pp->apply(); pp.reset(); @@ -166,14 +165,14 @@ void TestQgsProjectProperties::testEllipsoidCrsSync() // but if ellipsoid is initially set, then changing the project CRS should update the ellipsoid to match QgsProject::instance()->setEllipsoid( QStringLiteral( "EPSG:7021" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->setSelectedCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ); pp->apply(); pp.reset(); // ellipsoid should be updated to match CRS ellipsoid QCOMPARE( QgsProject::instance()->ellipsoid(), QStringLiteral( "EPSG:7019" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->setSelectedCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4240" ) ) ); pp->apply(); pp.reset(); @@ -183,7 +182,7 @@ void TestQgsProjectProperties::testEllipsoidCrsSync() // some ArcGIS versions: see https://github.com/OSGeo/PROJ/issues/1781 const QString wkt = QStringLiteral( R"""(PROJCS["Belge 1972 / Belgian Lambert 72",GEOGCS["Belge 1972",DATUM["Reseau_National_Belge_1972",SPHEROID["International 1924",6378388,297],AUTHORITY["EPSG","6313"]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["latitude_of_origin",90],PARAMETER["central_meridian",4.36748666666667],PARAMETER["standard_parallel_1",49.8333339],PARAMETER["standard_parallel_2",51.1666672333333],PARAMETER["false_easting",150000.01256],PARAMETER["false_northing",5400088.4378],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH]])""" ); const QgsCoordinateReferenceSystem customCrs = QgsCoordinateReferenceSystem::fromWkt( wkt ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->setSelectedCrs( customCrs ); pp->apply(); pp.reset(); @@ -193,7 +192,7 @@ void TestQgsProjectProperties::testEllipsoidCrsSync() QgsProject::instance()->setCrs( QgsCoordinateReferenceSystem() ); QgsProject::instance()->setEllipsoid( QStringLiteral( "NONE" ) ); - pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + pp = std::make_unique( mQgisApp->mapCanvas() ); pp->setSelectedCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ); pp->apply(); pp.reset(); @@ -204,11 +203,11 @@ void TestQgsProjectProperties::testEllipsoidCrsSync() void TestQgsProjectProperties::testBearingFormat() { QgsProject::instance()->clear(); - std::unique_ptr< QgsBearingNumericFormat > format = std::make_unique< QgsBearingNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 9 ); QgsProject::instance()->displaySettings()->setBearingFormat( format.release() ); - std::unique_ptr< QgsProjectProperties > pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + std::unique_ptr pp = std::make_unique( mQgisApp->mapCanvas() ); pp->apply(); QCOMPARE( QgsProject::instance()->displaySettings()->bearingFormat()->numberDecimalPlaces(), 9 ); } @@ -216,13 +215,12 @@ void TestQgsProjectProperties::testBearingFormat() void TestQgsProjectProperties::testTimeSettings() { QgsProject::instance()->clear(); - const QgsDateTimeRange range = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime(), Qt::UTC ), - QDateTime( QDate( 2020, 12, 31 ), QTime(), Qt::UTC ) ); + const QgsDateTimeRange range = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime(), Qt::UTC ), QDateTime( QDate( 2020, 12, 31 ), QTime(), Qt::UTC ) ); QgsProject::instance()->timeSettings()->setTemporalRange( range ); const QgsDateTimeRange projectRange = QgsProject::instance()->timeSettings()->temporalRange(); - std::unique_ptr< QgsProjectProperties > projectProperties = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + std::unique_ptr projectProperties = std::make_unique( mQgisApp->mapCanvas() ); QCOMPARE( projectRange, range ); @@ -232,19 +230,16 @@ void TestQgsProjectProperties::testTimeSettings() QgsRasterLayer *secondLayer = new QgsRasterLayer( QString(), QStringLiteral( "secondLayer" ), QStringLiteral( "wms" ) ); QgsRasterLayer *thirdLayer = new QgsRasterLayer( QString(), QStringLiteral( "thirdLayer" ), QStringLiteral( "wms" ) ); - const QgsDateTimeRange firstRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime(), Qt::UTC ), - QDateTime( QDate( 2020, 3, 31 ), QTime(), Qt::UTC ) ); - const QgsDateTimeRange secondRange = QgsDateTimeRange( QDateTime( QDate( 2020, 4, 1 ), QTime(), Qt::UTC ), - QDateTime( QDate( 2020, 7, 31 ), QTime(), Qt::UTC ) ); - const QgsDateTimeRange thirdRange = QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime(), Qt::UTC ), - QDateTime( QDate( 2020, 2, 28 ), QTime(), Qt::UTC ) ); + const QgsDateTimeRange firstRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime(), Qt::UTC ), QDateTime( QDate( 2020, 3, 31 ), QTime(), Qt::UTC ) ); + const QgsDateTimeRange secondRange = QgsDateTimeRange( QDateTime( QDate( 2020, 4, 1 ), QTime(), Qt::UTC ), QDateTime( QDate( 2020, 7, 31 ), QTime(), Qt::UTC ) ); + const QgsDateTimeRange thirdRange = QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime(), Qt::UTC ), QDateTime( QDate( 2020, 2, 28 ), QTime(), Qt::UTC ) ); firstLayer->temporalProperties()->setIsActive( true ); - qobject_cast< QgsRasterLayerTemporalProperties * >( firstLayer->temporalProperties() )->setFixedTemporalRange( firstRange ); + qobject_cast( firstLayer->temporalProperties() )->setFixedTemporalRange( firstRange ); secondLayer->temporalProperties()->setIsActive( true ); - qobject_cast< QgsRasterLayerTemporalProperties * >( secondLayer->temporalProperties() )->setFixedTemporalRange( secondRange ); + qobject_cast( secondLayer->temporalProperties() )->setFixedTemporalRange( secondRange ); thirdLayer->temporalProperties()->setIsActive( true ); - qobject_cast< QgsRasterLayerTemporalProperties * >( thirdLayer->temporalProperties() )->setFixedTemporalRange( thirdRange ); + qobject_cast( thirdLayer->temporalProperties() )->setFixedTemporalRange( thirdRange ); QgsProject::instance()->addMapLayers( { firstLayer, secondLayer, thirdLayer } ); @@ -263,10 +258,10 @@ void TestQgsProjectProperties::testColorSettings() QCOMPARE( QgsProject::instance()->styleSettings()->colorModel(), Qgis::ColorModel::Rgb ); QVERIFY( !QgsProject::instance()->styleSettings()->colorSpace().isValid() ); - std::unique_ptr< QgsProjectProperties > pp = std::make_unique< QgsProjectProperties >( mQgisApp->mapCanvas() ); + std::unique_ptr pp = std::make_unique( mQgisApp->mapCanvas() ); QCOMPARE( static_cast( pp->mColorModel->currentData().toInt() ), Qgis::ColorModel::Rgb ); QVERIFY( !pp->mColorSpace.isValid() ); -#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) QCOMPARE( pp->mColorSpaceName->text(), QStringLiteral( "None" ) ); QVERIFY( !pp->mRemoveIccProfile->isEnabled() ); #else @@ -280,7 +275,7 @@ void TestQgsProjectProperties::testColorSettings() pp->mColorModel->setCurrentIndex( pp->mColorModel->findData( QVariant::fromValue( Qgis::ColorModel::Cmyk ) ) ); QCOMPARE( static_cast( pp->mColorModel->currentData().toInt() ), Qgis::ColorModel::Cmyk ); -#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) const QString iccProfileFilePath = QStringLiteral( TEST_DATA_DIR ) + "/sRGB2014.icc"; pp->addIccProfile( iccProfileFilePath ); @@ -300,11 +295,9 @@ void TestQgsProjectProperties::testColorSettings() QVERIFY( !pp->mRemoveIccProfile->isEnabled() ); #endif - } - QGSTEST_MAIN( TestQgsProjectProperties ) #include "testqgsprojectproperties.moc" diff --git a/tests/src/app/testqgsvectorlayersaveasdialog.cpp b/tests/src/app/testqgsvectorlayersaveasdialog.cpp index 3a7b09b1561e..9a6883af0807 100644 --- a/tests/src/app/testqgsvectorlayersaveasdialog.cpp +++ b/tests/src/app/testqgsvectorlayersaveasdialog.cpp @@ -36,10 +36,10 @@ class TestQgsVectorLayerSaveAsDialog : public QObject TestQgsVectorLayerSaveAsDialog(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testAttributesAsDisplayedValues(); @@ -69,7 +69,7 @@ void TestQgsVectorLayerSaveAsDialog::cleanupTestCase() void TestQgsVectorLayerSaveAsDialog::testAttributesAsDisplayedValues() { //create a temporary layer - std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); // Assign a custom CRS to the layer @@ -134,7 +134,7 @@ void TestQgsVectorLayerSaveAsDialog::testAttributesAsDisplayedValues() QCOMPARE( mAttributeTable->item( 0, 3 )->flags(), Qt::ItemIsUserCheckable ); // Check that we can get a custom CRS with crsObject() - QCOMPARE( d.crs(), crs ) ; + QCOMPARE( d.crs(), crs ); //d.exec(); } diff --git a/tests/src/app/testqgsvertexeditor.cpp b/tests/src/app/testqgsvertexeditor.cpp index 4b7181e2f5db..cbdf84e5c84b 100644 --- a/tests/src/app/testqgsvertexeditor.cpp +++ b/tests/src/app/testqgsvertexeditor.cpp @@ -34,14 +34,13 @@ class TestQgsVertexEditor : public QgsTest TestQgsVertexEditor(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testColumnZMR_data(); void testColumnZMR(); private: - std::unique_ptr mCanvas; QgisApp *mQgisApp = nullptr; std::unique_ptr mLayerLine; @@ -51,7 +50,8 @@ class TestQgsVertexEditor : public QgsTest std::unique_ptr mVertexEditor; }; -TestQgsVertexEditor::TestQgsVertexEditor(): QgsTest( QStringLiteral( "Vertex Editor tests" ) ) {} +TestQgsVertexEditor::TestQgsVertexEditor() + : QgsTest( QStringLiteral( "Vertex Editor tests" ) ) {} //runs before all tests void TestQgsVertexEditor::initTestCase() diff --git a/tests/src/app/testqgsvertextool.cpp b/tests/src/app/testqgsvertextool.cpp index 62e282136808..66cafc89bb11 100644 --- a/tests/src/app/testqgsvertextool.cpp +++ b/tests/src/app/testqgsvertextool.cpp @@ -49,7 +49,7 @@ namespace QTest QByteArray ba = geom.asWkt().toLatin1(); return qstrdup( ba.data() ); } -} +} // namespace QTest /** * \ingroup UnitTests @@ -62,8 +62,8 @@ class TestQgsVertexTool : public QObject TestQgsVertexTool(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testSelectVerticesByPolygon(); void testTopologicalEditingMoveVertexZ(); @@ -261,37 +261,37 @@ void TestQgsVertexTool::initTestCase() mLayerLine->startEditing(); mLayerLine->addFeature( lineF1 ); mFidLineF1 = lineF1.id(); - QCOMPARE( mLayerLine->featureCount(), ( long )1 ); + QCOMPARE( mLayerLine->featureCount(), ( long ) 1 ); mLayerMultiLine->startEditing(); mLayerMultiLine->addFeature( multiLineF1 ); mFidMultiLineF1 = multiLineF1.id(); - QCOMPARE( mLayerMultiLine->featureCount(), ( long )1 ); + QCOMPARE( mLayerMultiLine->featureCount(), ( long ) 1 ); mLayerLineReprojected->startEditing(); mLayerLineReprojected->addFeature( lineF13857 ); mFidLineF13857 = lineF13857.id(); - QCOMPARE( mLayerLineReprojected->featureCount(), ( long )1 ); + QCOMPARE( mLayerLineReprojected->featureCount(), ( long ) 1 ); mLayerPolygon->startEditing(); mLayerPolygon->addFeature( polygonF1 ); mFidPolygonF1 = polygonF1.id(); - QCOMPARE( mLayerPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 1 ); mLayerMultiPolygon->startEditing(); mLayerMultiPolygon->addFeature( multiPolygonF1 ); mFidMultiPolygonF1 = multiPolygonF1.id(); - QCOMPARE( mLayerMultiPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerMultiPolygon->featureCount(), ( long ) 1 ); mLayerPoint->startEditing(); mLayerPoint->addFeature( pointF1 ); mFidPointF1 = pointF1.id(); - QCOMPARE( mLayerPoint->featureCount(), ( long )1 ); + QCOMPARE( mLayerPoint->featureCount(), ( long ) 1 ); mLayerPointZ->startEditing(); mLayerPointZ->addFeature( pointZF1 ); mFidPointZF1 = pointZF1.id(); - QCOMPARE( mLayerPointZ->featureCount(), ( long )1 ); + QCOMPARE( mLayerPointZ->featureCount(), ( long ) 1 ); mLayerLineZ->startEditing(); mLayerLineZ->addFeature( linez1 ); @@ -629,7 +629,7 @@ void TestQgsVertexTool::testMovePointAddingZ() QgsFeature pointZF2; pointZF2.setGeometry( QgsGeometry::fromWkt( "Point (30 35)" ) ); mLayerPointZ->addFeature( pointZF2 ); - QCOMPARE( mLayerPointZ->featureCount(), ( long )2 ); + QCOMPARE( mLayerPointZ->featureCount(), ( long ) 2 ); QCOMPARE( mLayerPointZ->undoStack()->index(), 2 ); // And snap on a point with Z @@ -738,7 +738,6 @@ void TestQgsVertexTool::testAddVertexAtEndpoint() QCOMPARE( mLayerLine->undoStack()->index(), 1 ); QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1, 1 3)" ) ); - } void TestQgsVertexTool::testAddVertexDoubleClick() @@ -771,7 +770,6 @@ void TestQgsVertexTool::testAddVertexDoubleClick() QCOMPARE( mLayerLine->undoStack()->index(), 1 ); QCOMPARE( mLayerPolygon->undoStack()->index(), 1 ); QCOMPARE( mLayerPoint->undoStack()->index(), 1 ); - } void TestQgsVertexTool::testAddVertexDoubleClickWithShift() @@ -802,7 +800,6 @@ void TestQgsVertexTool::testAddVertexDoubleClickWithShift() QCOMPARE( mLayerLine->undoStack()->index(), 1 ); QCOMPARE( mLayerPolygon->undoStack()->index(), 1 ); QCOMPARE( mLayerPoint->undoStack()->index(), 1 ); - } void TestQgsVertexTool::testDeleteVertex() @@ -1035,7 +1032,7 @@ void TestQgsVertexTool::testMoveVertexTopo() QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "POLYGON((3 3, 7 1, 7 4, 4 4, 3 3))" ) ); QCOMPARE( mLayerLine->undoStack()->index(), 2 ); - QCOMPARE( mLayerPolygon->undoStack()->index(), 3 ); // one more move of vertex from earlier + QCOMPARE( mLayerPolygon->undoStack()->index(), 3 ); // one more move of vertex from earlier mLayerLine->undoStack()->undo(); mLayerPolygon->undoStack()->undo(); mLayerPolygon->undoStack()->undo(); @@ -1064,7 +1061,7 @@ void TestQgsVertexTool::testDeleteVertexTopo() QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "POLYGON((7 1, 7 4, 4 4, 7 1))" ) ); QCOMPARE( mLayerLine->undoStack()->index(), 2 ); - QCOMPARE( mLayerPolygon->undoStack()->index(), 3 ); // one more move of vertex from earlier + QCOMPARE( mLayerPolygon->undoStack()->index(), 3 ); // one more move of vertex from earlier mLayerLine->undoStack()->undo(); mLayerPolygon->undoStack()->undo(); mLayerPolygon->undoStack()->undo(); @@ -1244,7 +1241,7 @@ void TestQgsVertexTool::testAddVertexTopoMultipleLayers() void TestQgsVertexTool::testAvoidIntersections() { // There is one feature in the layer - QCOMPARE( mLayerPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 1 ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "Polygon ((4 1, 7 1, 7 4, 4 4, 4 1))" ) ); // avoid rounding errors QgsProject::instance()->setTopologicalEditing( true ); @@ -1267,7 +1264,7 @@ void TestQgsVertexTool::testAvoidIntersections() const QgsFeatureId mFidPolygonF2 = polygonF2.id(); // Starting point - QCOMPARE( mLayerPolygon->featureCount(), ( long )2 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 2 ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "Polygon ((4 1, 7 1, 7 4, 4 4, 4 1))" ) ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF2 ).geometry(), QgsGeometry::fromWkt( "Polygon ((8 2, 9 2, 9 3, 8 3, 8 2))" ) ); @@ -1282,7 +1279,7 @@ void TestQgsVertexTool::testAvoidIntersections() QCOMPARE( spy.count(), 1 ); // 1 for the moved vertex - QCOMPARE( mLayerPolygon->featureCount(), ( long )2 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 2 ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "Polygon ((4 1, 7 1, 7 4, 5 5, 4 1))" ) ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF2 ).geometry(), QgsGeometry::fromWkt( "Polygon ((8 2, 9 2, 9 3, 8 3, 8 2))" ) ); @@ -1298,7 +1295,7 @@ void TestQgsVertexTool::testAvoidIntersections() QCOMPARE( spy.count(), 1 ); // 1 for the moved vertex - QCOMPARE( mLayerPolygon->featureCount(), ( long )2 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 2 ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "Polygon ((4 4, 7 4, 8 3, 8 2, 9 2, 4 1, 4 4))" ) ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF2 ).geometry(), QgsGeometry::fromWkt( "Polygon ((8 2, 9 2, 9 3, 8 3, 8 2))" ) ); @@ -1331,7 +1328,7 @@ void TestQgsVertexTool::testAvoidIntersections() mLayerPolygon->undoStack()->undo(); // delete feature - QCOMPARE( mLayerPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 1 ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "POLYGON((4 1, 7 1, 7 4, 4 4, 4 1))" ) ); QCOMPARE( mLayerPolygon->undoStack()->index(), 1 ); @@ -1358,7 +1355,7 @@ void TestQgsVertexTool::testAvoidIntersections() mLayerPolygon->addFeature( polygonF_topo2 ); const QgsFeatureId mFidPolygonF_topo2 = polygonF_topo2.id(); - QCOMPARE( mLayerPolygon->featureCount(), ( long )3 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 3 ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "Polygon ((4 1, 7 1, 7 4, 4 4, 4 1))" ) ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF_topo1 ).geometry(), QgsGeometry::fromWkt( "Polygon ((0 10, 0 20, 5 15, 0 10))" ) ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF_topo2 ).geometry(), QgsGeometry::fromWkt( "Polygon ((10 15, 15 10, 15 20, 10 15))" ) ); @@ -1373,7 +1370,7 @@ void TestQgsVertexTool::testAvoidIntersections() mLayerPolygon->undoStack()->undo(); // undo move and topological points mLayerPolygon->undoStack()->undo(); // delete feature polygonF_topo2 mLayerPolygon->undoStack()->undo(); // delete feature polygonF_topo1 - QCOMPARE( mLayerPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 1 ); // Make sure the largest part is preserved if multiple parts are created polygonF2.setGeometry( QgsGeometry::fromWkt( "Polygon ((8 3, 9 3, 9 2, 8 2, 8 3))" ) ); @@ -1386,7 +1383,7 @@ void TestQgsVertexTool::testAvoidIntersections() mLayerPolygon->undoStack()->undo(); // undo edge move mLayerPolygon->undoStack()->undo(); // undo feature addition - QCOMPARE( mLayerPolygon->featureCount(), ( long )1 ); + QCOMPARE( mLayerPolygon->featureCount(), ( long ) 1 ); QgsProject::instance()->setTopologicalEditing( false ); QgsProject::instance()->setAvoidIntersectionsMode( mode ); @@ -1448,7 +1445,7 @@ void TestQgsVertexTool::testActiveLayerPriority() layerLine2->startEditing(); layerLine2->addFeature( lineF1 ); const QgsFeatureId fidLineF1 = lineF1.id(); - QCOMPARE( layerLine2->featureCount(), ( long )1 ); + QCOMPARE( layerLine2->featureCount(), ( long ) 1 ); QgsProject::instance()->addMapLayer( layerLine2 ); QList oldMapLayers = mCanvas->layers(); mCanvas->setLayers( QList() << mLayerLine << mLayerPolygon << mLayerPoint << mLayerCompoundCurve << layerLine2 ); @@ -1561,7 +1558,7 @@ void TestQgsVertexTool::testSelectedFeaturesPriority() QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry(), QgsGeometry::fromWkt( "POLYGON((7 1, 7 4, 4 4, 7 1))" ) ); mLayerPolygon->undoStack()->undo(); - mLayerPolygon->undoStack()->undo(); // undo the initial change + mLayerPolygon->undoStack()->undo(); // undo the initial change } void TestQgsVertexTool::testVertexToolCompoundCurve() @@ -1591,8 +1588,7 @@ void TestQgsVertexTool::testVertexToolCompoundCurve() mouseClick( 18, 17, Qt::LeftButton ); QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 3 ); - QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), - QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 18 17, 13.75126265847083928 13.78427124746189492, 10 10, 17 10))" ) ); + QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 18 17, 13.75126265847083928 13.78427124746189492, 10 10, 17 10))" ) ); mLayerCompoundCurve->undoStack()->undo(); @@ -1676,7 +1672,7 @@ void TestQgsVertexTool::testMoveVertexTopoOtherMapCrs() QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry().asWkt( 2 ), "LineString (3 3, 1 1, 1 3)" ); QCOMPARE( mLayerPolygon->getFeature( mFidPolygonF1 ).geometry().asWkt( 2 ), "Polygon ((4 1, 3 3, 7 4, 4 4, 4 1))" ); - QCOMPARE( mLayerLine->undoStack()->index(), 3 ); // one more move of vertex from earlier + QCOMPARE( mLayerLine->undoStack()->index(), 3 ); // one more move of vertex from earlier QCOMPARE( mLayerPolygon->undoStack()->index(), 2 ); mLayerLine->undoStack()->undo(); mLayerLine->undoStack()->undo(); diff --git a/tests/src/auth/testqgsauthoauth2method.cpp b/tests/src/auth/testqgsauthoauth2method.cpp index b79b8bcb167b..826ef5efb883 100644 --- a/tests/src/auth/testqgsauthoauth2method.cpp +++ b/tests/src/auth/testqgsauthoauth2method.cpp @@ -37,7 +37,7 @@ * \ingroup UnitTests * Unit tests for QgsAuthOAuth2Config */ -class TestQgsAuthOAuth2Method: public QObject +class TestQgsAuthOAuth2Method : public QObject { Q_OBJECT @@ -367,16 +367,12 @@ void TestQgsAuthOAuth2Method::testOAuth2ConfigIO() const QString config4path( QDir::tempPath() + "/" + dirname + "/config4.json" ); const QString config5path( QDir::tempPath() + "/" + dirname + "/config5.json" ); - QVERIFY( QgsAuthOAuth2Config::writeOAuth2Config( config4path, config4, - QgsAuthOAuth2Config::JSON, true ) ); - QVERIFY( QgsAuthOAuth2Config::writeOAuth2Config( config5path, config5, - QgsAuthOAuth2Config::JSON, true ) ); + QVERIFY( QgsAuthOAuth2Config::writeOAuth2Config( config4path, config4, QgsAuthOAuth2Config::JSON, true ) ); + QVERIFY( QgsAuthOAuth2Config::writeOAuth2Config( config5path, config5, QgsAuthOAuth2Config::JSON, true ) ); qDebug() << "Verify reading config files from directory"; ok = false; - QList configs = - QgsAuthOAuth2Config::loadOAuth2Configs( QDir::tempPath() + "/" + dirname, - qApp, QgsAuthOAuth2Config::JSON, &ok ); + QList configs = QgsAuthOAuth2Config::loadOAuth2Configs( QDir::tempPath() + "/" + dirname, qApp, QgsAuthOAuth2Config::JSON, &ok ); QVERIFY( ok ); QCOMPARE( configs.size(), 2 ); QgsAuthOAuth2Config *config6 = configs.takeFirst(); @@ -404,7 +400,8 @@ void TestQgsAuthOAuth2Method::testOAuth2ConfigUtils() qDebug() << "Verify serializeFromVariant"; const QByteArray vtxt = QgsAuthOAuth2Config::serializeFromVariant( - basevmap, QgsAuthOAuth2Config::JSON, true, &ok ); + basevmap, QgsAuthOAuth2Config::JSON, true, &ok + ); QVERIFY( ok ); //qDebug() << vtxt; //qDebug() << baseConfigTxt( true ); @@ -412,25 +409,25 @@ void TestQgsAuthOAuth2Method::testOAuth2ConfigUtils() qDebug() << "Verify variantFromSerialized"; const QVariantMap vmap = QgsAuthOAuth2Config::variantFromSerialized( - baseConfigTxt( true ), QgsAuthOAuth2Config::JSON, &ok ); + baseConfigTxt( true ), QgsAuthOAuth2Config::JSON, &ok + ); QVERIFY( ok ); QCOMPARE( vmap.value( "name" ).toString(), QString( "MyConfig" ) ); QCOMPARE( vmap, basevmap ); - } void TestQgsAuthOAuth2Method::testDynamicRegistrationNoEndpoint() { #ifdef WITH_GUI QgsAuthOAuth2Config *config = baseConfig(); - config->setClientId( QString( ) ); - config->setClientSecret( QString( ) ); + config->setClientId( QString() ); + config->setClientSecret( QString() ); QVariantMap configMap( config->mappedProperties() ); QCOMPARE( configMap["clientId"].toString(), QString() ); QCOMPARE( configMap["clientSecret"].toString(), QString() ); QgsAuthOAuth2Edit dlg; QgsStringMap stringMap; - for ( const auto &k : configMap.keys( ) ) + for ( const auto &k : configMap.keys() ) { stringMap[k] = configMap.value( k ).toString(); } @@ -440,7 +437,7 @@ void TestQgsAuthOAuth2Method::testDynamicRegistrationNoEndpoint() // This JWT does not contain a registration_endpoint dlg.leSoftwareStatementJwtPath->setText( QStringLiteral( "%1/auth_code_grant_display_code.jwt" ).arg( sTestDataDir ) ); - QVERIFY( ! dlg.btnRegister->isEnabled() ); + QVERIFY( !dlg.btnRegister->isEnabled() ); QCOMPARE( dlg.leSoftwareStatementConfigUrl->text(), QString() ); #endif } @@ -449,14 +446,14 @@ void TestQgsAuthOAuth2Method::testDynamicRegistration() { #ifdef WITH_GUI QgsAuthOAuth2Config *config = baseConfig(); - config->setClientId( QString( ) ); - config->setClientSecret( QString( ) ); + config->setClientId( QString() ); + config->setClientSecret( QString() ); QVariantMap configMap( config->mappedProperties() ); QCOMPARE( configMap["clientId"].toString(), QString() ); QCOMPARE( configMap["clientSecret"].toString(), QString() ); QgsAuthOAuth2Edit dlg; QgsStringMap stringMap; - for ( const auto &k : configMap.keys( ) ) + for ( const auto &k : configMap.keys() ) { stringMap[k] = configMap.value( k ).toString(); } @@ -466,10 +463,10 @@ void TestQgsAuthOAuth2Method::testDynamicRegistration() // This JWT does not contain a registration_endpoint dlg.leSoftwareStatementJwtPath->setText( QStringLiteral( "%1/auth_code_grant_display_code.jwt" ).arg( sTestDataDir ) ); - QVERIFY( ! dlg.btnRegister->isEnabled() ); + QVERIFY( !dlg.btnRegister->isEnabled() ); QCOMPARE( dlg.leSoftwareStatementConfigUrl->text(), QString() ); // Set the config url to something local - dlg.leSoftwareStatementConfigUrl->setText( QUrl::fromLocalFile( QStringLiteral( "%1/auth_code_grant_display_code_get_config.json" ).arg( sTestDataDir ) ).toString( ) ); + dlg.leSoftwareStatementConfigUrl->setText( QUrl::fromLocalFile( QStringLiteral( "%1/auth_code_grant_display_code_get_config.json" ).arg( sTestDataDir ) ).toString() ); QVERIFY( dlg.btnRegister->isEnabled() ); // Change it to something local dlg.mRegistrationEndpoint = QUrl::fromLocalFile( QStringLiteral( "%1/client_information_registration_response.json" ).arg( sTestDataDir ) ).toString(); @@ -488,14 +485,14 @@ void TestQgsAuthOAuth2Method::testDynamicRegistrationJwt() { #ifdef WITH_GUI QgsAuthOAuth2Config *config = baseConfig(); - config->setClientId( QString( ) ); - config->setClientSecret( QString( ) ); + config->setClientId( QString() ); + config->setClientSecret( QString() ); QVariantMap configMap( config->mappedProperties() ); QCOMPARE( configMap["clientId"].toString(), QString() ); QCOMPARE( configMap["clientSecret"].toString(), QString() ); QgsAuthOAuth2Edit dlg; QgsStringMap stringMap; - for ( const auto &k : configMap.keys( ) ) + for ( const auto &k : configMap.keys() ) { stringMap[k] = configMap.value( k ).toString(); } diff --git a/tests/src/core/geometry/testgeometryutils.h b/tests/src/core/geometry/testgeometryutils.h index c3f426f1c80e..ab1bb8d36c9f 100644 --- a/tests/src/core/geometry/testgeometryutils.h +++ b/tests/src/core/geometry/testgeometryutils.h @@ -21,4 +21,3 @@ QString elemToString( const QDomElement &elem ) return s; } - diff --git a/tests/src/core/geometry/testqgscircle.cpp b/tests/src/core/geometry/testqgscircle.cpp index 885c901a1279..e76dc8b3f1da 100644 --- a/tests/src/core/geometry/testqgscircle.cpp +++ b/tests/src/core/geometry/testqgscircle.cpp @@ -21,7 +21,7 @@ #include "testgeometryutils.h" -class TestQgsCircle: public QObject +class TestQgsCircle : public QObject { Q_OBJECT private slots: @@ -75,52 +75,40 @@ void TestQgsCircle::constructor() void TestQgsCircle::from2Points() { - QVERIFY( QgsCircle().from2Points( QgsPoint( -5, 0 ), QgsPoint( 5, 0 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 5, 90 ) ); - QVERIFY( QgsCircle().from2Points( QgsPoint( 0, -5 ), QgsPoint( 0, 5 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); + QVERIFY( QgsCircle().from2Points( QgsPoint( -5, 0 ), QgsPoint( 5, 0 ) ) == QgsCircle( QgsPoint( 0, 0 ), 5, 90 ) ); + QVERIFY( QgsCircle().from2Points( QgsPoint( 0, -5 ), QgsPoint( 0, 5 ) ) == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); } void TestQgsCircle::fromExtent() { - QVERIFY( QgsCircle().fromExtent( QgsPoint( -5, -5 ), QgsPoint( 5, 5 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); + QVERIFY( QgsCircle().fromExtent( QgsPoint( -5, -5 ), QgsPoint( 5, 5 ) ) == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); QVERIFY( QgsCircle().fromExtent( QgsPoint( -7.5, -2.5 ), QgsPoint( 2.5, 200.5 ) ).isEmpty() ); } void TestQgsCircle::from3Points() { - QVERIFY( QgsCircle().from3Points( QgsPoint( -5, 0 ), QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 5 ) ); + QVERIFY( QgsCircle().from3Points( QgsPoint( -5, 0 ), QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ) == QgsCircle( QgsPoint( 0, 0 ), 5 ) ); QVERIFY( QgsCircle().from3Points( QgsPoint( 5, 0 ), QgsPoint( 6, 0 ), QgsPoint( 7, 0 ) ).isEmpty() ); } void TestQgsCircle::fromCenterDiameter() { - QVERIFY( QgsCircle().fromCenterDiameter( QgsPoint( 0, 0 ), 10 ) - == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); - QVERIFY( QgsCircle().fromCenterDiameter( QgsPoint( 2, 100 ), -10 ) - == QgsCircle( QgsPoint( 2, 100 ), 5, 0 ) ); - QVERIFY( QgsCircle().fromCenterDiameter( QgsPoint( 2, 100 ), -10, 45 ) - == QgsCircle( QgsPoint( 2, 100 ), 5, 45 ) ); + QVERIFY( QgsCircle().fromCenterDiameter( QgsPoint( 0, 0 ), 10 ) == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); + QVERIFY( QgsCircle().fromCenterDiameter( QgsPoint( 2, 100 ), -10 ) == QgsCircle( QgsPoint( 2, 100 ), 5, 0 ) ); + QVERIFY( QgsCircle().fromCenterDiameter( QgsPoint( 2, 100 ), -10, 45 ) == QgsCircle( QgsPoint( 2, 100 ), 5, 45 ) ); } void TestQgsCircle::fromCenterPoint() { - QVERIFY( QgsCircle().fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 5, 90 ) ); - QVERIFY( QgsCircle().fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); - QVERIFY( QgsCircle().fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 5 * std::cos( 45 * M_PI / 180.0 ), 5 * std::sin( 45 * M_PI / 180.0 ) ) ) - == QgsCircle( QgsPoint( 0, 0 ), 5, 45 ) ); + QVERIFY( QgsCircle().fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ) ) == QgsCircle( QgsPoint( 0, 0 ), 5, 90 ) ); + QVERIFY( QgsCircle().fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ) ) == QgsCircle( QgsPoint( 0, 0 ), 5, 0 ) ); + QVERIFY( QgsCircle().fromCenterPoint( QgsPoint( 0, 0 ), QgsPoint( 5 * std::cos( 45 * M_PI / 180.0 ), 5 * std::sin( 45 * M_PI / 180.0 ) ) ) == QgsCircle( QgsPoint( 0, 0 ), 5, 45 ) ); } void TestQgsCircle::from3Tangents() { // Tangents from circle tri1( 0,0 ; 0,5 ), tri2( 0,0 ; 5,0 ), tri3( 5,0 ; 0,5 ) - QgsCircle circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 0, 1 ), - QgsPoint( 2, 0 ), QgsPoint( 3, 0 ), - QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ); + QgsCircle circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 0, 1 ), QgsPoint( 2, 0 ), QgsPoint( 3, 0 ), QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ); QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 1.4645, 1.4645 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 1.4645, 0.0001 ); } @@ -128,40 +116,26 @@ void TestQgsCircle::from3Tangents() void TestQgsCircle::from3TangentsWithParallels() { // with parallels - QgsCircle circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 1, 0 ), QgsPoint( 1, 5 ), - QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ); + QgsCircle circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 1, 0 ), QgsPoint( 1, 5 ), QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ); QVERIFY( circ.isEmpty() ); - circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 1, 0 ), QgsPoint( 1, 5 ) ); + circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 0 ), QgsPoint( 0, 5 ), QgsPoint( 1, 0 ), QgsPoint( 1, 5 ) ); QVERIFY( circ.isEmpty() ); - circ = QgsCircle::from3Tangents( QgsPoint( 5, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 1, 0 ), QgsPoint( 1, 5 ) ); + circ = QgsCircle::from3Tangents( QgsPoint( 5, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 1, 0 ), QgsPoint( 1, 5 ) ); QVERIFY( circ.isEmpty() ); // with 2 parallels const double epsilon = 1e-8; - circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), - QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), - QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ) ); + circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ) ); QVERIFY( circ.isEmpty() ); - circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), - QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), - QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), - epsilon, QgsPoint( 2, 0 ) ); + circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), epsilon, QgsPoint( 2, 0 ) ); QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 1.4645, 2.5000 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 2.5, 0.0001 ); - circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), - QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), - QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), - epsilon, QgsPoint( 3, 0 ) ); + circ = QgsCircle::from3Tangents( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), epsilon, QgsPoint( 3, 0 ) ); QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 8.5355, 2.5000 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 2.5, 0.0001 ); @@ -174,9 +148,7 @@ void TestQgsCircle::from3tangentsMulti() QVector circles; QgsCircle circ; - circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), - QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), - QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ) ); + circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ) ); QCOMPARE( circles.count(), 2 ); circ = circles.at( 0 ); @@ -187,31 +159,21 @@ void TestQgsCircle::from3tangentsMulti() QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 1.4645, 2.5000 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 2.5, 0.0001 ); - circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), - QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), - QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), - epsilon, QgsPoint( 2, 0 ) ); + circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), epsilon, QgsPoint( 2, 0 ) ); QCOMPARE( circles.count(), 1 ); circ = circles.at( 0 ); QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 1.4645, 2.5000 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 2.5, 0.0001 ); - circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), - QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), - QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), - epsilon, QgsPoint( 3, 0 ) ); + circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ), epsilon, QgsPoint( 3, 0 ) ); QCOMPARE( circles.count(), 1 ); - circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), - QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), - QgsPoint( 15, 5 ), QgsPoint( 20, 5 ) ); + circles = QgsCircle::from3TangentsMulti( QgsPoint( 0, 0 ), QgsPoint( 5, 0 ), QgsPoint( 5, 5 ), QgsPoint( 10, 5 ), QgsPoint( 15, 5 ), QgsPoint( 20, 5 ) ); QVERIFY( circles.isEmpty() ); // check that Z dimension is ignored in case of using tangents - circ = QgsCircle::from3Tangents( QgsPoint( 0, 0, 333 ), QgsPoint( 0, 1, 1 ), - QgsPoint( 2, 0, 2 ), QgsPoint( 3, 0, 3 ), - QgsPoint( 5, 0, 4 ), QgsPoint( 0, 5, 5 ) ); + circ = QgsCircle::from3Tangents( QgsPoint( 0, 0, 333 ), QgsPoint( 0, 1, 1 ), QgsPoint( 2, 0, 2 ), QgsPoint( 3, 0, 3 ), QgsPoint( 5, 0, 4 ), QgsPoint( 0, 5, 5 ) ); QCOMPARE( circ.center().is3D(), false ); } @@ -222,19 +184,19 @@ void TestQgsCircle::minimalCircleFrom3points() QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 ); - QCOMPARE( circ, QgsCircle::from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ) ); + QCOMPARE( circ, QgsCircle::from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ) ); circ = QgsCircle::minimalCircleFrom3Points( QgsPoint( 0, -5 ), QgsPoint( 1, 2 ), QgsPoint( 0, 5 ) ); QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 ); - QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ) ); + QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ) ); circ = QgsCircle::minimalCircleFrom3Points( QgsPoint( 1, 2 ), QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ); QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 ); QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 ); - QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ) ); + QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ) ); // equivalent to from3Points circ = QgsCircle::minimalCircleFrom3Points( QgsPoint( 0, 5 ), QgsPoint( 5, 0 ), QgsPoint( -5, 0 ) ); @@ -288,10 +250,8 @@ void TestQgsCircle::areaPerimeter() void TestQgsCircle::boundingBox() { - QVERIFY( QgsRectangle( QgsPointXY( -2.5, -2.5 ), QgsPointXY( 2.5, 2.5 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 2.5, 0 ).boundingBox() ); - QVERIFY( QgsRectangle( QgsPointXY( -2.5, -2.5 ), QgsPointXY( 2.5, 2.5 ) ) - == QgsCircle( QgsPoint( 0, 0 ), 2.5, 45 ).boundingBox() ); + QVERIFY( QgsRectangle( QgsPointXY( -2.5, -2.5 ), QgsPointXY( 2.5, 2.5 ) ) == QgsCircle( QgsPoint( 0, 0 ), 2.5, 0 ).boundingBox() ); + QVERIFY( QgsRectangle( QgsPointXY( -2.5, -2.5 ), QgsPointXY( 2.5, 2.5 ) ) == QgsCircle( QgsPoint( 0, 0 ), 2.5, 45 ).boundingBox() ); } void TestQgsCircle::northQuadrant() @@ -428,13 +388,12 @@ void TestQgsCircle::innerTangents() QGSCOMPARENEAR( l2p1.y(), -0.558, 0.01 ); QGSCOMPARENEAR( l2p2.x(), 1.457, 0.01 ); QGSCOMPARENEAR( l2p2.y(), 2.89, 0.01 ); - } void TestQgsCircle::toPolygon() { QgsPointSequence pts; - std::unique_ptr< QgsPolygon > pol( new QgsPolygon() ); + std::unique_ptr pol( new QgsPolygon() ); pol.reset( QgsCircle( QgsPoint( 0, 0 ), 5 ).toPolygon( 4 ) ); @@ -454,7 +413,7 @@ void TestQgsCircle::toPolygon() void TestQgsCircle::toPolygonoOriented() { QgsPointSequence pts; - std::unique_ptr< QgsPolygon > pol( new QgsPolygon() ); + std::unique_ptr pol( new QgsPolygon() ); double val = 5 * std::sin( M_PI / 4 ); @@ -521,7 +480,7 @@ void TestQgsCircle::toPolygonoOriented() void TestQgsCircle::toCircularString() { - std::unique_ptr< QgsCircularString > cs( QgsCircle( QgsPoint( 0, 0 ), 5 ).toCircularString() ); + std::unique_ptr cs( QgsCircle( QgsPoint( 0, 0 ), 5 ).toCircularString() ); QCOMPARE( cs->asWkt( 2 ), QString( "CircularString (0 5, 5 0, 0 -5, -5 0, 0 5)" ) ); cs.reset( QgsCircle( QgsPoint( 0, 0 ), 5 ).toCircularString( true ) ); diff --git a/tests/src/core/geometry/testqgscircularstring.cpp b/tests/src/core/geometry/testqgscircularstring.cpp index fe8471314793..e5a5733f185b 100644 --- a/tests/src/core/geometry/testqgscircularstring.cpp +++ b/tests/src/core/geometry/testqgscircularstring.cpp @@ -26,7 +26,7 @@ #include "testgeometryutils.h" #include "testtransformer.h" -class TestQgsCircularString: public QObject +class TestQgsCircularString : public QObject { Q_OBJECT private slots: @@ -131,9 +131,7 @@ void TestQgsCircularString::constructorFrom3Points() QCOMPARE( cs.xAt( 2 ), 31.0 ); QCOMPARE( cs.yAt( 2 ), 2.0 ); - cs = QgsCircularString( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ), - QgsPoint( Qgis::WkbType::PointZ, 21, 22, 23 ), - QgsPoint( Qgis::WkbType::PointZ, 31, 2, 33 ) ); + cs = QgsCircularString( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ), QgsPoint( Qgis::WkbType::PointZ, 21, 22, 23 ), QgsPoint( Qgis::WkbType::PointZ, 31, 2, 33 ) ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZ ); QCOMPARE( cs.numPoints(), 3 ); @@ -148,9 +146,7 @@ void TestQgsCircularString::constructorFrom3Points() QCOMPARE( cs.yAt( 2 ), 2.0 ); QCOMPARE( cs.pointN( 2 ).z(), 33.0 ); - cs = QgsCircularString( QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ), - QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 23 ), - QgsPoint( Qgis::WkbType::PointM, 31, 2, 0, 33 ) ); + cs = QgsCircularString( QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ), QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 23 ), QgsPoint( Qgis::WkbType::PointM, 31, 2, 0, 33 ) ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringM ); QCOMPARE( cs.numPoints(), 3 ); @@ -165,9 +161,7 @@ void TestQgsCircularString::constructorFrom3Points() QCOMPARE( cs.yAt( 2 ), 2.0 ); QCOMPARE( cs.pointN( 2 ).m(), 33.0 ); - cs = QgsCircularString( QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ), - QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ), - QgsPoint( Qgis::WkbType::PointZM, 31, 2, 33, 34 ) ); + cs = QgsCircularString( QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ), QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ), QgsPoint( Qgis::WkbType::PointZM, 31, 2, 33, 34 ) ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZM ); QCOMPARE( cs.numPoints(), 3 ); @@ -209,9 +203,7 @@ void TestQgsCircularString::constructorFrom2PointsAndCenter() QCOMPARE( cs.xAt( 2 ), 31.0 ); QCOMPARE( cs.yAt( 2 ), 2.0 ); - cs = QgsCircularString::fromTwoPointsAndCenter( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ), - QgsPoint( Qgis::WkbType::PointZ, 32, 2, 33 ), - QgsPoint( Qgis::WkbType::PointZ, 21, 2, 23 ) ); + cs = QgsCircularString::fromTwoPointsAndCenter( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ), QgsPoint( Qgis::WkbType::PointZ, 32, 2, 33 ), QgsPoint( Qgis::WkbType::PointZ, 21, 2, 23 ) ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZ ); QCOMPARE( cs.numPoints(), 3 ); @@ -225,9 +217,7 @@ void TestQgsCircularString::constructorFrom2PointsAndCenter() QCOMPARE( cs.yAt( 2 ), 2.0 ); QCOMPARE( cs.pointN( 2 ).z(), 33.0 ); - cs = QgsCircularString::fromTwoPointsAndCenter( QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ), - QgsPoint( Qgis::WkbType::PointM, 31, 2, 0, 33 ), - QgsPoint( Qgis::WkbType::PointM, 21, 2, 0, 23 ) ); + cs = QgsCircularString::fromTwoPointsAndCenter( QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ), QgsPoint( Qgis::WkbType::PointM, 31, 2, 0, 33 ), QgsPoint( Qgis::WkbType::PointM, 21, 2, 0, 23 ) ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringM ); QCOMPARE( cs.numPoints(), 3 ); @@ -241,9 +231,7 @@ void TestQgsCircularString::constructorFrom2PointsAndCenter() QCOMPARE( cs.yAt( 2 ), 2.0 ); QCOMPARE( cs.pointN( 2 ).m(), 33.0 ); - cs = QgsCircularString::fromTwoPointsAndCenter( QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ), - QgsPoint( Qgis::WkbType::PointZM, 31, 2, 33, 34 ), - QgsPoint( Qgis::WkbType::PointZM, 21, 2, 23, 24 ) ); + cs = QgsCircularString::fromTwoPointsAndCenter( QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ), QgsPoint( Qgis::WkbType::PointZM, 31, 2, 33, 34 ), QgsPoint( Qgis::WkbType::PointZM, 21, 2, 23, 24 ) ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZM ); QCOMPARE( cs.numPoints(), 3 ); @@ -354,8 +342,7 @@ void TestQgsCircularString::clear() void TestQgsCircularString::setPointsEmpty() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); //setPoints with empty list, should clear linestring cs.setPoints( QgsPointSequence() ); @@ -375,12 +362,10 @@ void TestQgsCircularString::setPointsEmpty() void TestQgsCircularString::setPointsZM() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); //with z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); QCOMPARE( cs.numPoints(), 2 ); QVERIFY( cs.is3D() ); @@ -389,12 +374,10 @@ void TestQgsCircularString::setPointsZM() QgsPointSequence pts; cs.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); //with m - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); QCOMPARE( cs.numPoints(), 2 ); QVERIFY( !cs.is3D() ); @@ -402,12 +385,10 @@ void TestQgsCircularString::setPointsZM() QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringM ); cs.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); //with zm - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); QCOMPARE( cs.numPoints(), 2 ); QVERIFY( cs.is3D() ); @@ -415,15 +396,13 @@ void TestQgsCircularString::setPointsZM() QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZM ); cs.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); } void TestQgsCircularString::setPointsMixedDimensionality() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) ); QCOMPARE( cs.numPoints(), 2 ); QVERIFY( cs.is3D() ); @@ -432,15 +411,13 @@ void TestQgsCircularString::setPointsMixedDimensionality() QgsPointSequence pts; cs.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) ); } void TestQgsCircularString::pointN() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) ); QCOMPARE( cs.pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) ); QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) ); @@ -453,9 +430,7 @@ void TestQgsCircularString::pointN() void TestQgsCircularString::gettersSetters() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); QCOMPARE( cs.xAt( 0 ), 1.0 ); QCOMPARE( cs.xAt( 1 ), 11.0 ); @@ -509,9 +484,7 @@ void TestQgsCircularString::gettersSettersZMWithLine2D() { //check zAt/setZAt with non-3d linestring QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) - << QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) << QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 24 ) ); //basically we just don't want these to crash QVERIFY( std::isnan( cs.pointN( 0 ).z() ) ); @@ -520,9 +493,7 @@ void TestQgsCircularString::gettersSettersZMWithLine2D() cs.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 71.0, 2, 63 ) ); //check mAt/setMAt with non-measure linestring - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); //basically we just don't want these to crash QVERIFY( std::isnan( cs.pointN( 0 ).m() ) ); @@ -558,29 +529,21 @@ void TestQgsCircularString::equality() QVERIFY( cs1 != cs2 ); QgsCircularString cs3; - cs3.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 0 ) - << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 0 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 0 ) ); + cs3.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 0 ) << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 0 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 0 ) ); QVERIFY( !( cs1 == cs3 ) ); //different dimension QVERIFY( cs1 != cs3 ); QgsCircularString cs4; - cs4.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 4 ) ); + cs4.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 4 ) ); QVERIFY( !( cs3 == cs4 ) ); //different z coordinates QVERIFY( cs3 != cs4 ); QgsCircularString cs5; - cs5.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); + cs5.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); QgsCircularString cs6; - cs6.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 11 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 12 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 13 ) ); + cs6.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 11 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 12 ) << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 13 ) ); QVERIFY( !( cs5 == cs6 ) ); //different m values QVERIFY( cs5 != cs6 ); @@ -595,9 +558,7 @@ void TestQgsCircularString::isClosed() QVERIFY( !cs.isClosed2D() ); QVERIFY( !cs.isClosed() ); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 2 ) << QgsPoint( 11, 22 ) - << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); QVERIFY( !cs.isClosed2D() ); QVERIFY( !cs.isClosed() ); @@ -606,10 +567,7 @@ void TestQgsCircularString::isClosed() QCOMPARE( cs.perimeter(), 0.0 ); //test that m values aren't considered when testing for closedness - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 22, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 6 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 22, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 6 ) ); QVERIFY( cs.isClosed2D() ); QVERIFY( cs.isClosed() ); @@ -631,9 +589,7 @@ void TestQgsCircularString::isClosed() void TestQgsCircularString::asQPolygonF() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) ); QPolygonF poly = cs.asQPolygonF(); @@ -647,8 +603,7 @@ void TestQgsCircularString::asQPolygonF() void TestQgsCircularString::clone() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) - << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); std::unique_ptr cloned( cs.clone() ); QCOMPARE( cloned->numPoints(), 4 ); @@ -664,10 +619,7 @@ void TestQgsCircularString::clone() QCOMPARE( cloned->pointN( 3 ), cs.pointN( 3 ) ); //clone with Z/M - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); cloned.reset( cs.clone() ); QCOMPARE( cloned->numPoints(), 4 ); @@ -693,9 +645,8 @@ void TestQgsCircularString::clone() void TestQgsCircularString::segmentize() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); - std::unique_ptr segmentized( static_cast< QgsLineString * >( cs.segmentize() ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); + std::unique_ptr segmentized( static_cast( cs.segmentize() ) ); QCOMPARE( segmentized->numPoints(), 156 ); QCOMPARE( segmentized->vertexCount(), 156 ); @@ -708,10 +659,8 @@ void TestQgsCircularString::segmentize() QCOMPARE( segmentized->pointN( segmentized->numPoints() - 1 ), cs.pointN( cs.numPoints() - 1 ) ); //segmentize with Z/M - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 10, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 2, 21, 24 ) ); - segmentized.reset( static_cast< QgsLineString * >( cs.segmentize() ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 10, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 2, 21, 24 ) ); + segmentized.reset( static_cast( cs.segmentize() ) ); QCOMPARE( segmentized->numPoints(), 156 ); QCOMPARE( segmentized->vertexCount(), 156 ); @@ -725,7 +674,7 @@ void TestQgsCircularString::segmentize() //segmentize an empty line cs.clear(); - segmentized.reset( static_cast< QgsLineString * >( cs.segmentize() ) ); + segmentized.reset( static_cast( cs.segmentize() ) ); QVERIFY( segmentized->isEmpty() ); QCOMPARE( segmentized->numPoints(), 0 ); @@ -737,10 +686,7 @@ void TestQgsCircularString::segmentize() void TestQgsCircularString::toFromWKB() { QgsCircularString cs1; - cs1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + cs1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QByteArray wkb1 = cs1.asWkb(); QCOMPARE( wkb1.size(), cs1.wkbSize() ); @@ -780,10 +726,7 @@ void TestQgsCircularString::toFromWKB() void TestQgsCircularString::toFromWKT() { QgsCircularString cs1; - cs1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + cs1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QString wkt = cs1.asWkt(); QVERIFY( !wkt.isEmpty() ); @@ -813,14 +756,10 @@ void TestQgsCircularString::exportImport() { //asGML2 QgsCircularString exportLine; - exportLine.setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) - << QgsPoint( 41, 42 ) - << QgsPoint( 51, 52 ) ); + exportLine.setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); QgsCircularString exportLineFloat; - exportLineFloat.setPoints( QgsPointSequence() << QgsPoint( 1 / 3.0, 2 / 3.0 ) - << QgsPoint( 1 + 1 / 3.0, 1 + 2 / 3.0 ) - << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) ); + exportLineFloat.setPoints( QgsPointSequence() << QgsPoint( 1 / 3.0, 2 / 3.0 ) << QgsPoint( 1 + 1 / 3.0, 1 + 2 / 3.0 ) << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) ); QDomDocument doc( QStringLiteral( "gml" ) ); QString expectedGML2( QStringLiteral( "31,32 41,42 51,52" ) ); @@ -862,9 +801,7 @@ void TestQgsCircularString::length() QgsCircularString cs; QCOMPARE( cs.length(), 0.0 ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QGSCOMPARENEAR( cs.length(), 26.1433, 0.001 ); } @@ -872,9 +809,7 @@ void TestQgsCircularString::length() void TestQgsCircularString::startEndPoint() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QCOMPARE( cs.startPoint(), QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) ); QCOMPARE( cs.endPoint(), QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); @@ -889,10 +824,8 @@ void TestQgsCircularString::curveToLine() { //curveToLine - no segmentation required, so should return a clone QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); - std::unique_ptr curveToLine( static_cast< QgsLineString * >( cs.curveToLine() ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + std::unique_ptr curveToLine( static_cast( cs.curveToLine() ) ); QCOMPARE( curveToLine->numPoints(), 181 ); QCOMPARE( curveToLine->wkbType(), Qgis::WkbType::LineStringZM ); @@ -910,9 +843,7 @@ void TestQgsCircularString::points() QVERIFY( cs.isEmpty() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); cs.points( points ); QCOMPARE( points.count(), 3 ); @@ -924,13 +855,12 @@ void TestQgsCircularString::points() void TestQgsCircularString::crsTransform() { QgsCoordinateReferenceSystem sourceSrs( QStringLiteral( "EPSG:3994" ) ); - QgsCoordinateReferenceSystem destSrs( QStringLiteral( "EPSG:4202" ) );// want a transform with ellipsoid change + QgsCoordinateReferenceSystem destSrs( QStringLiteral( "EPSG:4202" ) ); // want a transform with ellipsoid change QgsCoordinateTransform tr( sourceSrs, destSrs, QgsProject::instance() ); // 2d CRS transform QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) - << QgsPoint( 6474985, -3526584 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) << QgsPoint( 6474985, -3526584 ) ); cs.transform( tr, Qgis::TransformDirection::Forward ); QGSCOMPARENEAR( cs.pointN( 0 ).x(), 175.771, 0.001 ); @@ -944,8 +874,7 @@ void TestQgsCircularString::crsTransform() //3d CRS transform cs = QgsCircularString(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); cs.transform( tr, Qgis::TransformDirection::Forward ); QGSCOMPARENEAR( cs.pointN( 0 ).x(), 175.771, 0.001 ); @@ -987,21 +916,18 @@ void TestQgsCircularString::transform() { QTransform qtr = QTransform::fromScale( 2, 3 ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); cs.transform( qtr ); QCOMPARE( cs.pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 2, 6, 3, 4 ) ); QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 22, 36, 13, 14 ) ); QCOMPARE( cs.boundingBox(), QgsRectangle( 2, 6, 22, 36 ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); cs.transform( QTransform::fromScale( 1, 1 ), 3, 2, 4, 3 ); QCOMPARE( cs.pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 9, 16 ) ); QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 29, 46 ) ); - } void TestQgsCircularString::insertVertex() @@ -1013,8 +939,7 @@ void TestQgsCircularString::insertVertex() QCOMPARE( cs.numPoints(), 0 ); //2d line - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); QVERIFY( cs.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 4.0, 7.0 ) ) ); @@ -1058,9 +983,7 @@ void TestQgsCircularString::insertVertex() QCOMPARE( cs.numPoints(), 9 ); //insert 4d vertex in 4d line - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QVERIFY( cs.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ) ); @@ -1075,8 +998,7 @@ void TestQgsCircularString::insertVertex() QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 101, 102 ) ); //insert 4d vertex in 2d line - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); QVERIFY( cs.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZM, 2, 4, 103, 104 ) ) ); @@ -1094,8 +1016,7 @@ void TestQgsCircularString::moveVertex() QVERIFY( cs.isEmpty() ); //valid line - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); QVERIFY( cs.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( cs.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); @@ -1114,9 +1035,7 @@ void TestQgsCircularString::moveVertex() QCOMPARE( cs.pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); //move 4d point in 4d line - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QVERIFY( cs.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 7, 12, 13 ) ) ); QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 7, 12, 13 ) ); @@ -1126,8 +1045,7 @@ void TestQgsCircularString::moveVertex() QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 34, 35, 12, 13 ) ); //move 4d point in 2d line - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); QVERIFY( cs.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointZM, 3, 4, 2, 3 ) ) ); QCOMPARE( cs.pointN( 0 ), QgsPoint( 3, 4 ) ); @@ -1142,10 +1060,7 @@ void TestQgsCircularString::deleteVertex() QVERIFY( cs.isEmpty() ); //valid line - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 6, 7 ) ); //out of range vertices QVERIFY( !cs.deleteVertex( QgsVertexId( 0, 0, -1 ) ) ); @@ -1167,8 +1082,7 @@ void TestQgsCircularString::deleteVertex() QVERIFY( cs.isEmpty() ); //removing a vertex from a 3 point circular string should remove the whole line - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); QCOMPARE( cs.numPoints(), 3 ); cs.deleteVertex( QgsVertexId( 0, 0, 2 ) ); @@ -1179,13 +1093,11 @@ void TestQgsCircularString::reversed() { //reversed QgsCircularString cs; - std::unique_ptr< QgsCircularString > reversed( cs.reversed() ); + std::unique_ptr reversed( cs.reversed() ); QVERIFY( reversed->isEmpty() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); reversed.reset( cs.reversed() ); QCOMPARE( reversed->numPoints(), 3 ); @@ -1223,8 +1135,7 @@ void TestQgsCircularString::addZValue() QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZ, 11, 12, 2 ) ); //linestring with m - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) ); QVERIFY( cs.addZValue( 5 ) ); @@ -1262,8 +1173,7 @@ void TestQgsCircularString::addMValue() QCOMPARE( cs.pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 2 ) ); //linestring with z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) ); QVERIFY( cs.addMValue( 5 ) ); @@ -1295,8 +1205,7 @@ void TestQgsCircularString::dropZValue() QVERIFY( !cs.dropZValue() ); //already dropped //linestring with m - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); QVERIFY( cs.dropZValue() ); @@ -1326,8 +1235,7 @@ void TestQgsCircularString::dropMValue() QVERIFY( !cs.dropMValue() ); //already dropped //linestring with z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); QVERIFY( cs.dropMValue() ); @@ -1394,9 +1302,7 @@ void TestQgsCircularString::coordinateSequence() QCOMPARE( coords.at( 0 ).count(), 1 ); QVERIFY( coords.at( 0 ).at( 0 ).isEmpty() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); coords = cs.coordinateSequence(); QCOMPARE( coords.count(), 1 ); @@ -1451,8 +1357,7 @@ void TestQgsCircularString::nextVertex() QCOMPARE( p, QgsPoint( 11, 12 ) ); // with Z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); v = QgsVertexId( 0, 0, -1 ); QVERIFY( cs.nextVertex( v, p ) ); @@ -1466,8 +1371,7 @@ void TestQgsCircularString::nextVertex() QVERIFY( !cs.nextVertex( v, p ) ); // with M - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); v = QgsVertexId( 0, 0, -1 ); QVERIFY( cs.nextVertex( v, p ) ); @@ -1480,8 +1384,7 @@ void TestQgsCircularString::nextVertex() QVERIFY( !cs.nextVertex( v, p ) ); // with ZM - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); v = QgsVertexId( 0, 0, -1 ); QVERIFY( cs.nextVertex( v, p ) ); @@ -1500,7 +1403,7 @@ void TestQgsCircularString::vertexAtPointAt() QgsCircularString cs; cs.vertexAt( QgsVertexId( 0, 0, -10 ) ); //out of bounds, check for no crash - cs.vertexAt( QgsVertexId( 0, 0, 10 ) ); //out of bounds, check for no crash + cs.vertexAt( QgsVertexId( 0, 0, 10 ) ); //out of bounds, check for no crash QgsPoint p; Qgis::VertexType type; @@ -1508,8 +1411,7 @@ void TestQgsCircularString::vertexAtPointAt() QVERIFY( !cs.pointAt( -10, p, type ) ); QVERIFY( !cs.pointAt( 10, p, type ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); cs.vertexAt( QgsVertexId( 0, 0, -10 ) ); cs.vertexAt( QgsVertexId( 0, 0, 10 ) ); //out of bounds, check for no crash @@ -1530,9 +1432,7 @@ void TestQgsCircularString::vertexAtPointAt() QCOMPARE( type, Qgis::VertexType::Segment ); // with Z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 22, 23 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 22, 23 ) ); QCOMPARE( cs.vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); QCOMPARE( cs.vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); @@ -1548,9 +1448,7 @@ void TestQgsCircularString::vertexAtPointAt() QCOMPARE( type, Qgis::VertexType::Segment ); // with M - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 22, 0, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) << QgsPoint( Qgis::WkbType::PointM, 1, 22, 0, 24 ) ); QCOMPARE( cs.vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); QCOMPARE( cs.vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); @@ -1566,9 +1464,7 @@ void TestQgsCircularString::vertexAtPointAt() QCOMPARE( type, Qgis::VertexType::Segment ); // with ZM - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 23, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 23, 24 ) ); QCOMPARE( cs.vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); QCOMPARE( cs.vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); @@ -1605,21 +1501,20 @@ void TestQgsCircularString::closestSegment() QgsVertexId v; int leftOf = 0; - QgsPoint p( 0, 0 ); // reset all coords to zero - ( void )cs.closestSegment( QgsPoint( 1, 2 ), p, v ); //empty line, just want no crash + QgsPoint p( 0, 0 ); // reset all coords to zero + ( void ) cs.closestSegment( QgsPoint( 1, 2 ), p, v ); //empty line, just want no crash cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) ); QVERIFY( cs.closestSegment( QgsPoint( 5, 10 ), p, v ) < 0 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) ); QGSCOMPARENEAR( cs.closestSegment( QgsPoint( 4, 11 ), p, v, &leftOf ), 2.0, 0.0001 ); QCOMPARE( p, QgsPoint( 5, 10 ) ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); QCOMPARE( leftOf, -1 ); - QGSCOMPARENEAR( cs.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.583512, 0.0001 ); + QGSCOMPARENEAR( cs.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.583512, 0.0001 ); QGSCOMPARENEAR( p.x(), 6.84, 0.01 ); QGSCOMPARENEAR( p.y(), 11.49, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -1650,8 +1545,7 @@ void TestQgsCircularString::closestSegment() QCOMPARE( leftOf, 0 ); //clockwise string - cs.setPoints( QgsPointSequence() << QgsPoint( 5, 15 ) - << QgsPoint( 7, 12 ) << QgsPoint( 5, 10 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 5, 15 ) << QgsPoint( 7, 12 ) << QgsPoint( 5, 10 ) ); QGSCOMPARENEAR( cs.closestSegment( QgsPoint( 4, 11 ), p, v, &leftOf ), 2, 0.0001 ); QGSCOMPARENEAR( p.x(), 5, 0.01 ); @@ -1659,7 +1553,7 @@ void TestQgsCircularString::closestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 2 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( cs.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.583512, 0.0001 ); + QGSCOMPARENEAR( cs.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.583512, 0.0001 ); QGSCOMPARENEAR( p.x(), 6.84, 0.01 ); QGSCOMPARENEAR( p.y(), 11.49, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 2 ) ); @@ -1703,28 +1597,23 @@ void TestQgsCircularString::sumUpArea() QCOMPARE( area, 1.0 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 10, 10 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 10 ) ); cs.sumUpArea( area ); QCOMPARE( area, 1.0 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) ); cs.sumUpArea( area ); QGSCOMPARENEAR( area, 4.141593, 0.0001 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) - << QgsPoint( 0, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) << QgsPoint( 0, 2 ) ); cs.sumUpArea( area ); QGSCOMPARENEAR( area, 7.283185, 0.0001 ); // full circle - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 4, 0 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 4, 0 ) << QgsPoint( 0, 0 ) ); area = 0.0; cs.sumUpArea( area ); @@ -1740,8 +1629,7 @@ void TestQgsCircularString::boundingBox() cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 15 ) ); QCOMPARE( cs.boundingBox(), QgsRectangle( 5, 10, 10, 15 ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) - << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); QCOMPARE( cs.boundingBox(), QgsRectangle( -6.125, -10.25, -5, -9 ) ); QByteArray wkbToAppend = cs.asWkb(); @@ -1749,8 +1637,7 @@ void TestQgsCircularString::boundingBox() QVERIFY( cs.boundingBox().isNull() ); QgsConstWkbPtr wkbToAppendPtr( wkbToAppend ); - cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 10, 15 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 15 ) ); QCOMPARE( cs.boundingBox(), QgsRectangle( 5, 10, 10, 15 ) ); @@ -1800,8 +1687,7 @@ void TestQgsCircularString::boundingBox3D() QGSCOMPARENEAR( box1.zMinimum(), -2, 0.0001 ); QGSCOMPARENEAR( box1.zMaximum(), 7, 0.0001 ); - cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10, -7.8 ) - << QgsPoint( -6, -10, 3 ) << QgsPoint( -5.5, -9, 5.2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10, -7.8 ) << QgsPoint( -6, -10, 3 ) << QgsPoint( -5.5, -9, 5.2 ) ); QgsBox3D box2 = cs.boundingBox3D(); QGSCOMPARENEAR( box2.xMinimum(), -6.125, 0.001 ); QGSCOMPARENEAR( box2.xMaximum(), -5, 0.001 ); @@ -1815,8 +1701,7 @@ void TestQgsCircularString::boundingBox3D() QVERIFY( cs.boundingBox().isNull() ); QgsConstWkbPtr wkbToAppendPtr( wkbToAppend ); - cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10, -2 ) - << QgsPoint( 10, 15, 3 ) << QgsPoint( 8, 2, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10, -2 ) << QgsPoint( 10, 15, 3 ) << QgsPoint( 8, 2, 7 ) ); QgsBox3D box3 = cs.boundingBox3D(); QGSCOMPARENEAR( box3.xMinimum(), 5, 0.0001 ); QGSCOMPARENEAR( box3.xMaximum(), 19.1785, 0.0001 ); @@ -1877,15 +1762,15 @@ void TestQgsCircularString::angle() { QgsCircularString cs; - ( void )cs.vertexAngle( QgsVertexId() ); //just want no crash - ( void )cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash + ( void ) cs.vertexAngle( QgsVertexId() ); //just want no crash + ( void ) cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) ); - ( void )cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless + ( void ) cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) ); - ( void )cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless - ( void )cs.vertexAngle( QgsVertexId( 0, 0, 1 ) ); //just want no crash, any answer is meaningless + ( void ) cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless + ( void ) cs.vertexAngle( QgsVertexId( 0, 0, 1 ) ); //just want no crash, any answer is meaningless cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); @@ -1898,11 +1783,9 @@ void TestQgsCircularString::angle() QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 1.5708, 0.0001 ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 3.141593, 0.0001 ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 2 ) ), 4.712389, 0.0001 ); - ( void )cs.vertexAngle( QgsVertexId( 0, 0, 20 ) ); // no crash + ( void ) cs.vertexAngle( QgsVertexId( 0, 0, 20 ) ); // no crash - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) - << QgsPoint( -1, 3 ) << QgsPoint( 0, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) << QgsPoint( -1, 3 ) << QgsPoint( 0, 4 ) ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 1.5708, 0.0001 ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 0, 0.0001 ); @@ -1910,9 +1793,7 @@ void TestQgsCircularString::angle() QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 3 ) ), 0, 0.0001 ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 4 ) ), 1.5708, 0.0001 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 4 ) - << QgsPoint( -1, 3 ) << QgsPoint( 0, 2 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 4 ) << QgsPoint( -1, 3 ) << QgsPoint( 0, 2 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 4.712389, 0.0001 ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 3.141592, 0.0001 ); @@ -1921,8 +1802,7 @@ void TestQgsCircularString::angle() QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 4 ) ), 4.712389, 0.0001 ); //closed circular string - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 0, 0.00001 ); QGSCOMPARENEAR( cs.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 3.141592, 0.00001 ); @@ -1937,7 +1817,7 @@ void TestQgsCircularString::boundary() cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); QgsAbstractGeometry *boundary = cs.boundary(); - QgsMultiPoint *mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + QgsMultiPoint *mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->pointN( 0 )->x(), 0.0 ); @@ -1947,16 +1827,13 @@ void TestQgsCircularString::boundary() delete boundary; // closed string = no boundary - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); QVERIFY( !cs.boundary() ); //boundary with z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); boundary = cs.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->pointN( 0 )->wkbType(), Qgis::WkbType::PointZ ); @@ -1964,9 +1841,9 @@ void TestQgsCircularString::boundary() QCOMPARE( mpBoundary->pointN( 0 )->y(), 0.0 ); QCOMPARE( mpBoundary->pointN( 0 )->z(), 10.0 ); QCOMPARE( mpBoundary->pointN( 1 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); delete boundary; } @@ -1980,9 +1857,7 @@ void TestQgsCircularString::addToPainterPath() path.addToPainterPath( pPath ); QVERIFY( pPath.isEmpty() ); - path.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) - << QgsPoint( Qgis::WkbType::PointZ, 21, 2, 3 ) ); + path.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 21, 2, 3 ) ); path.addToPainterPath( pPath ); QGSCOMPARENEAR( pPath.currentPosition().x(), 21.0, 0.01 ); @@ -1991,8 +1866,7 @@ void TestQgsCircularString::addToPainterPath() // even number of points - should still work pPath = QPainterPath(); - path.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); + path.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); path.addToPainterPath( pPath ); QGSCOMPARENEAR( pPath.currentPosition().x(), 11.0, 0.01 ); @@ -2004,7 +1878,7 @@ void TestQgsCircularString::toCurveType() { QgsCircularString cs; cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); - std::unique_ptr< QgsCurve > curveType( cs.toCurveType() ); + std::unique_ptr curveType( cs.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::CircularString ); QCOMPARE( curveType->numPoints(), 3 ); @@ -2021,8 +1895,7 @@ void TestQgsCircularString::segmentLength() QCOMPARE( cs.segmentLength( QgsVertexId( 0, 0, 0 ) ), 0.0 ); QCOMPARE( cs.segmentLength( QgsVertexId( 1, 0, 0 ) ), 0.0 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); QCOMPARE( cs.segmentLength( QgsVertexId() ), 0.0 ); QCOMPARE( cs.segmentLength( QgsVertexId( 0, 0, -1 ) ), 0.0 ); @@ -2034,8 +1907,7 @@ void TestQgsCircularString::segmentLength() QCOMPARE( cs.segmentLength( QgsVertexId( 1, 0, 1 ) ), 0.0 ); QGSCOMPARENEAR( cs.segmentLength( QgsVertexId( 1, 1, 0 ) ), 31.4159, 0.001 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 22 ) << QgsPoint( -9, 32 ) << QgsPoint( 1, 42 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) << QgsPoint( -9, 32 ) << QgsPoint( 1, 42 ) ); QCOMPARE( cs.segmentLength( QgsVertexId() ), 0.0 ); QCOMPARE( cs.segmentLength( QgsVertexId( 0, 0, -1 ) ), 0.0 ); @@ -2061,15 +1933,12 @@ void TestQgsCircularString::removeDuplicateNodes() QVERIFY( !cs.removeDuplicateNodes() ); QCOMPARE( cs.asWkt(), QStringLiteral( "CircularString (11 2, 11 12, 11 2)" ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 10, 3 ) - << QgsPoint( 11.01, 1.99 ) << QgsPoint( 9, 3 ) << QgsPoint( 11, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 10, 3 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 9, 3 ) << QgsPoint( 11, 2 ) ); QVERIFY( !cs.removeDuplicateNodes( 0.02 ) ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString (11 2, 10 3, 11.01 1.99, 9 3, 11 2)" ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) - << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) - << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); QVERIFY( !cs.removeDuplicateNodes() ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString (11 2, 11.01 1.99, 11.02 2.01, 11 12, 111 12, 111.01 11.99)" ) ); @@ -2088,21 +1957,18 @@ void TestQgsCircularString::removeDuplicateNodes() QVERIFY( !cs.removeDuplicateNodes( 0.02 ) ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString (11 2, 11.01 1.99)" ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) - << QgsPoint( 11, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11, 2 ) ); QVERIFY( !cs.removeDuplicateNodes( 0.02 ) ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString (11 2, 11.01 1.99, 11 2)" ) ); // with z - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) - << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) << QgsPoint( 111, 12, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) << QgsPoint( 111, 12, 5 ) ); QVERIFY( cs.removeDuplicateNodes( 0.02 ) ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString Z (11 2 1, 11 12 4, 111 12 5)" ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) - << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) << QgsPoint( 111, 12, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) << QgsPoint( 111, 12, 5 ) ); QVERIFY( !cs.removeDuplicateNodes( 0.02, true ) ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString Z (11 2 1, 11.01 1.99 2, 11.02 2.01 3, 11 12 4, 111 12 5)" ) ); @@ -2113,9 +1979,7 @@ void TestQgsCircularString::swapXy() QgsCircularString cs; cs.swapXy(); // no crash - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); cs.swapXy(); QCOMPARE( cs.asWkt(), QStringLiteral( "CircularString ZM (2 11 3 4, 12 11 13 14, 12 111 23 24)" ) ); @@ -2124,16 +1988,13 @@ void TestQgsCircularString::swapXy() void TestQgsCircularString::filterVertices() { QgsCircularString cs; - auto filter = []( const QgsPoint & point )-> bool - { + auto filter = []( const QgsPoint &point ) -> bool { return point.x() < 5; }; cs.filterVertices( filter ); // no crash - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); cs.filterVertices( filter ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString ZM (1 2 3 4, 4 12 13 14)" ) ); @@ -2142,16 +2003,13 @@ void TestQgsCircularString::filterVertices() void TestQgsCircularString::transformVertices() { QgsCircularString cs; - auto transform = []( const QgsPoint & point )-> QgsPoint - { + auto transform = []( const QgsPoint &point ) -> QgsPoint { return QgsPoint( point.x() + 2, point.y() + 3, point.z() + 4, point.m() + 7 ); }; cs.transformVertices( transform ); // no crash - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); cs.transformVertices( transform ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString ZM (3 5 7 11, 6 15 17 21, 113 15 27 31)" ) ); @@ -2162,9 +2020,7 @@ void TestQgsCircularString::transformVertices() QVERIFY( cs.transform( &transformer ) ); // no crash - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); QVERIFY( cs.transform( &transformer ) ); QCOMPARE( cs.asWkt( 2 ), QStringLiteral( "CircularString ZM (3 16 8 3, 12 26 18 13, 333 26 28 23)" ) ); @@ -2177,13 +2033,12 @@ void TestQgsCircularString::substring() { QgsCircularString cs; - std::unique_ptr< QgsCircularString > substringResult( cs.curveSubstring( 1, 2 ) ); // no crash + std::unique_ptr substringResult( cs.curveSubstring( 1, 2 ) ); // no crash QVERIFY( substringResult.get() ); QVERIFY( substringResult->isEmpty() ); // CircularStringZM (10 0 1 2, 11 1 3 4, 12 0 13 14) - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) - << QgsPoint( 11, 1, 3, 4 ) << QgsPoint( 12, 0, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 11, 1, 3, 4 ) << QgsPoint( 12, 0, 13, 14 ) ); substringResult.reset( cs.curveSubstring( 0, 0 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CircularString ZM (10 0 1 2, 10 0 1 2, 10 0 1 2)" ) ); @@ -2213,8 +2068,7 @@ void TestQgsCircularString::substring() QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CircularString ZM (10.46 0.84 2.27 3.27, 10.68 0.95 2.59 3.59, 10.93 1 2.91 3.91)" ) ); // CircularStringZM (10 0 1 2, 11 1 3 4, 12 0 13 14, 14 -1 13 14, 16 1 23 24 ) - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 11, 1, 3, 4 ) - << QgsPoint( 12, 0, 13, 14 ) << QgsPoint( 14, -1, 13, 14 ) << QgsPoint( 16, 1, 23, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 11, 1, 3, 4 ) << QgsPoint( 12, 0, 13, 14 ) << QgsPoint( 14, -1, 13, 14 ) << QgsPoint( 16, 1, 23, 24 ) ); substringResult.reset( cs.curveSubstring( 1, 1.5 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CircularString ZM (10.46 0.84 2.27 3.27, 10.68 0.95 2.59 3.59, 10.93 1 2.91 3.91)" ) ); @@ -2238,25 +2092,19 @@ void TestQgsCircularString::substring() QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CircularString ZM (12 0 13 14, 14.36 -0.94 14.19 15.19, 16 1 23 24)" ) ); // CircularStringZ - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1 ) << QgsPoint( 11, 1, 3 ) << QgsPoint( 12, 0, 13 ) - << QgsPoint( 14, -1, 13 ) << QgsPoint( 16, 1, 23 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1 ) << QgsPoint( 11, 1, 3 ) << QgsPoint( 12, 0, 13 ) << QgsPoint( 14, -1, 13 ) << QgsPoint( 16, 1, 23 ) ); substringResult.reset( cs.curveSubstring( 1, 20 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CircularString Z (10.46 0.84 2.27, 11.48 0.88 6.18, 12 0 13, 14 -1 13, 16 1 23)" ) ); // CircularStringM - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 1, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 12, 0, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 14, -1, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 16, 1, 0, 23 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 11, 1, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 12, 0, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 14, -1, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 16, 1, 0, 23 ) ); substringResult.reset( cs.curveSubstring( 1, 20 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CircularString M (10.46 0.84 2.27, 11.48 0.88 6.18, 12 0 13, 14 -1 13, 16 1 23)" ) ); // CircularString - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0 ) << QgsPoint( 11, 1 ) - << QgsPoint( 12, 0 ) << QgsPoint( 14, -1 ) << QgsPoint( 16, 1 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0 ) << QgsPoint( 11, 1 ) << QgsPoint( 12, 0 ) << QgsPoint( 14, -1 ) << QgsPoint( 16, 1 ) ); substringResult.reset( cs.curveSubstring( 1, 20 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CircularString (10.46 0.84, 11.48 0.88, 12 0, 14 -1, 16 1)" ) ); @@ -2266,12 +2114,11 @@ void TestQgsCircularString::interpolate() { QgsCircularString cs; - std::unique_ptr< QgsPoint > interpolated( cs.interpolatePoint( 1 ) ); // no crash + std::unique_ptr interpolated( cs.interpolatePoint( 1 ) ); // no crash QVERIFY( !interpolated.get() ); // CircularStringZM (10 0 1 2, 11 1 3 4, 12 0 13 14) - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) - << QgsPoint( 11, 1, 3, 4 ) << QgsPoint( 12, 0, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 11, 1, 3, 4 ) << QgsPoint( 12, 0, 13, 14 ) ); interpolated.reset( cs.interpolatePoint( 0 ) ); QCOMPARE( interpolated->asWkt( 2 ), QStringLiteral( "Point ZM (10 0 1 2)" ) ); @@ -2292,8 +2139,7 @@ void TestQgsCircularString::interpolate() QCOMPARE( interpolated->asWkt( 2 ), QStringLiteral( "Point ZM (12 0 13 14)" ) ); // CircularStringZM (10 0 1 2, 11 1 3 4, 12 0 13 14, 14 -1 13 14, 16 1 23 24 ) - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 11, 1, 3, 4 ) - << QgsPoint( 12, 0, 13, 14 ) << QgsPoint( 14, -1, 13, 14 ) << QgsPoint( 16, 1, 23, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 11, 1, 3, 4 ) << QgsPoint( 12, 0, 13, 14 ) << QgsPoint( 14, -1, 13, 14 ) << QgsPoint( 16, 1, 23, 24 ) ); interpolated.reset( cs.interpolatePoint( 1 ) ); QCOMPARE( interpolated->asWkt( 2 ), QStringLiteral( "Point ZM (10.46 0.84 2.27 3.27)" ) ); @@ -2311,25 +2157,19 @@ void TestQgsCircularString::interpolate() QCOMPARE( interpolated->asWkt( 2 ), QStringLiteral( "Point ZM (13.51 -0.98 13 14)" ) ); // CircularStringZ - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1 ) << QgsPoint( 11, 1, 3 ) - << QgsPoint( 12, 0, 13 ) << QgsPoint( 14, -1, 13 ) << QgsPoint( 16, 1, 23 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1 ) << QgsPoint( 11, 1, 3 ) << QgsPoint( 12, 0, 13 ) << QgsPoint( 14, -1, 13 ) << QgsPoint( 16, 1, 23 ) ); interpolated.reset( cs.interpolatePoint( 1 ) ); QCOMPARE( interpolated->asWkt( 2 ), QStringLiteral( "Point Z (10.46 0.84 2.27)" ) ); // CircularStringM - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 1, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 12, 0, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 14, -1, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 16, 1, 0, 23 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 11, 1, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 12, 0, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 14, -1, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 16, 1, 0, 23 ) ); interpolated.reset( cs.interpolatePoint( 1 ) ); QCOMPARE( interpolated->asWkt( 2 ), QStringLiteral( "Point M (10.46 0.84 2.27)" ) ); // CircularString - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0 ) << QgsPoint( 11, 1 ) - << QgsPoint( 12, 0 ) << QgsPoint( 14, -1 ) << QgsPoint( 16, 1 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 0 ) << QgsPoint( 11, 1 ) << QgsPoint( 12, 0 ) << QgsPoint( 14, -1 ) << QgsPoint( 16, 1 ) ); interpolated.reset( cs.interpolatePoint( 1 ) ); QCOMPARE( interpolated->asWkt( 2 ), QStringLiteral( "Point (10.46 0.84)" ) ); @@ -2338,22 +2178,20 @@ void TestQgsCircularString::interpolate() void TestQgsCircularString::orientation() { QgsCircularString cs; - ( void )cs.orientation(); // no crash + ( void ) cs.orientation(); // no crash - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) - << QgsPoint( 1, 1 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) << QgsPoint( 1, 1 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); QCOMPARE( cs.orientation(), Qgis::AngularDirection::Clockwise ); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 1 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 1 ) << QgsPoint( 0, 0 ) ); QCOMPARE( cs.orientation(), Qgis::AngularDirection::CounterClockwise ); } void TestQgsCircularString::constructorFromArray() { // test creating circular strings from arrays - QVector< double > xx; - QVector< double > yy; + QVector xx; + QVector yy; xx << 1 << 2 << 3; yy << 11 << 12 << 13; QgsCircularString cs( xx, yy ); @@ -2368,8 +2206,8 @@ void TestQgsCircularString::constructorFromArray() QCOMPARE( cs.yAt( 2 ), 13.0 ); // unbalanced - xx = QVector< double >() << 1 << 2; - yy = QVector< double >() << 11 << 12 << 13; + xx = QVector() << 1 << 2; + yy = QVector() << 11 << 12 << 13; cs = QgsCircularString( xx, yy ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularString ); @@ -2379,8 +2217,8 @@ void TestQgsCircularString::constructorFromArray() QCOMPARE( cs.xAt( 1 ), 2.0 ); QCOMPARE( cs.yAt( 1 ), 12.0 ); - xx = QVector< double >() << 1 << 2 << 3; - yy = QVector< double >() << 11 << 12; + xx = QVector() << 1 << 2 << 3; + yy = QVector() << 11 << 12; cs = QgsCircularString( xx, yy ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularString ); @@ -2393,12 +2231,12 @@ void TestQgsCircularString::constructorFromArray() void TestQgsCircularString::constructorFromArrayZ() { - QVector< double > xx; - QVector< double > yy; - QVector< double > zz; - xx = QVector< double >() << 1 << 2 << 3; - yy = QVector< double >() << 11 << 12 << 13; - zz = QVector< double >() << 21 << 22 << 23; + QVector xx; + QVector yy; + QVector zz; + xx = QVector() << 1 << 2 << 3; + yy = QVector() << 11 << 12 << 13; + zz = QVector() << 21 << 22 << 23; QgsCircularString cs( xx, yy, zz ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZ ); @@ -2414,7 +2252,7 @@ void TestQgsCircularString::constructorFromArrayZ() QCOMPARE( cs.pointN( 2 ).z(), 23.0 ); // unbalanced -> z ignored - zz = QVector< double >() << 21 << 22; + zz = QVector() << 21 << 22; cs = QgsCircularString( xx, yy, zz ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularString ); @@ -2427,7 +2265,7 @@ void TestQgsCircularString::constructorFromArrayZ() QCOMPARE( cs.yAt( 2 ), 13.0 ); // unbalanced -> z truncated - zz = QVector< double >() << 21 << 22 << 23 << 24; + zz = QVector() << 21 << 22 << 23 << 24; cs = QgsCircularString( xx, yy, zz ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZ ); @@ -2445,13 +2283,13 @@ void TestQgsCircularString::constructorFromArrayZ() void TestQgsCircularString::constructorFromArrayM() { - QVector< double > xx; - QVector< double > yy; - QVector< double > mm; - xx = QVector< double >() << 1 << 2 << 3; - yy = QVector< double >() << 11 << 12 << 13; - mm = QVector< double >() << 21 << 22 << 23; - QgsCircularString cs( xx, yy, QVector< double >(), mm ); + QVector xx; + QVector yy; + QVector mm; + xx = QVector() << 1 << 2 << 3; + yy = QVector() << 11 << 12 << 13; + mm = QVector() << 21 << 22 << 23; + QgsCircularString cs( xx, yy, QVector(), mm ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringM ); QCOMPARE( cs.numPoints(), 3 ); @@ -2466,8 +2304,8 @@ void TestQgsCircularString::constructorFromArrayM() QCOMPARE( cs.pointN( 2 ).m(), 23.0 ); // unbalanced -> m ignored - mm = QVector< double >() << 21 << 22; - cs = QgsCircularString( xx, yy, QVector< double >(), mm ); + mm = QVector() << 21 << 22; + cs = QgsCircularString( xx, yy, QVector(), mm ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularString ); QCOMPARE( cs.numPoints(), 3 ); @@ -2479,8 +2317,8 @@ void TestQgsCircularString::constructorFromArrayM() QCOMPARE( cs.yAt( 2 ), 13.0 ); // unbalanced -> m truncated - mm = QVector< double >() << 21 << 22 << 23 << 24; - cs = QgsCircularString( xx, yy, QVector< double >(), mm ); + mm = QVector() << 21 << 22 << 23 << 24; + cs = QgsCircularString( xx, yy, QVector(), mm ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringM ); QCOMPARE( cs.numPoints(), 3 ); @@ -2497,14 +2335,14 @@ void TestQgsCircularString::constructorFromArrayM() void TestQgsCircularString::constructorFromArrayZM() { - QVector< double > xx; - QVector< double > yy; - QVector< double > zz; - QVector< double > mm; - xx = QVector< double >() << 1 << 2 << 3; - yy = QVector< double >() << 11 << 12 << 13; - zz = QVector< double >() << 21 << 22 << 23; - mm = QVector< double >() << 31 << 32 << 33; + QVector xx; + QVector yy; + QVector zz; + QVector mm; + xx = QVector() << 1 << 2 << 3; + yy = QVector() << 11 << 12 << 13; + zz = QVector() << 21 << 22 << 23; + mm = QVector() << 31 << 32 << 33; QgsCircularString cs( xx, yy, zz, mm ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZM ); @@ -2538,9 +2376,7 @@ void TestQgsCircularString::append() QVERIFY( cs.isEmpty() ); QCOMPARE( cs.numPoints(), 0 ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); cs.append( toAppend.get() ); QVERIFY( !cs.is3D() ); @@ -2557,8 +2393,7 @@ void TestQgsCircularString::append() //add more points toAppend.reset( new QgsCircularString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( 21, 22 ) - << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 21, 22 ) << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); cs.append( toAppend.get() ); QCOMPARE( cs.numPoints(), 5 ); @@ -2574,20 +2409,14 @@ void TestQgsCircularString::append() //Make sure there are not duplicate points except start and end point cs.clear(); toAppend.reset( new QgsCircularString() ); - toAppend->setPoints( QgsPointSequence() - << QgsPoint( 1, 1 ) - << QgsPoint( 5, 5 ) - << QgsPoint( 10, 1 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 5, 5 ) << QgsPoint( 10, 1 ) ); cs.append( toAppend.get() ); QCOMPARE( cs.numPoints(), 3 ); QCOMPARE( cs.vertexCount(), 3 ); toAppend.reset( new QgsCircularString() ); - toAppend->setPoints( QgsPointSequence() - << QgsPoint( 10, 1 ) - << QgsPoint( 5, 2 ) - << QgsPoint( 1, 1 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 10, 1 ) << QgsPoint( 5, 2 ) << QgsPoint( 1, 1 ) ); cs.append( toAppend.get() ); QVERIFY( cs.isClosed() ); @@ -2600,9 +2429,7 @@ void TestQgsCircularString::appendZM() //check dimensionality is inherited from append line if initially empty QgsCircularString cs; std::unique_ptr toAppend( new QgsCircularString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 33, 34 ) - << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 43, 44 ) - << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 53, 54 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 33, 34 ) << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 43, 44 ) << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 53, 54 ) ); cs.append( toAppend.get() ); QVERIFY( cs.is3D() ); @@ -2617,17 +2444,13 @@ void TestQgsCircularString::appendZM() //append points with z to non z circular string cs.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 31, 32 ) - << QgsPoint( Qgis::WkbType::Point, 41, 42 ) - << QgsPoint( Qgis::WkbType::Point, 51, 52 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 31, 32 ) << QgsPoint( Qgis::WkbType::Point, 41, 42 ) << QgsPoint( Qgis::WkbType::Point, 51, 52 ) ); QVERIFY( !cs.is3D() ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularString ); toAppend.reset( new QgsCircularString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 33, 34 ) - << QgsPoint( Qgis::WkbType::PointZM, 141, 142, 43, 44 ) - << QgsPoint( Qgis::WkbType::PointZM, 151, 152, 53, 54 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 33, 34 ) << QgsPoint( Qgis::WkbType::PointZM, 141, 142, 43, 44 ) << QgsPoint( Qgis::WkbType::PointZM, 151, 152, 53, 54 ) ); cs.append( toAppend.get() ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularString ); @@ -2639,18 +2462,14 @@ void TestQgsCircularString::appendZM() //append points without z/m to circularstring with z & m cs.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 11, 21 ) - << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 12, 22 ) - << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 13, 23 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 11, 21 ) << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 12, 22 ) << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 13, 23 ) ); QVERIFY( cs.is3D() ); QVERIFY( cs.isMeasure() ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZM ); toAppend.reset( new QgsCircularString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( 51, 52 ) - << QgsPoint( 141, 142 ) - << QgsPoint( 151, 152 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 51, 52 ) << QgsPoint( 141, 142 ) << QgsPoint( 151, 152 ) ); cs.append( toAppend.get() ); QCOMPARE( cs.wkbType(), Qgis::WkbType::CircularStringZM ); diff --git a/tests/src/core/geometry/testqgscompoundcurve.cpp b/tests/src/core/geometry/testqgscompoundcurve.cpp index 7d394f15ef04..2fe1d38eec47 100644 --- a/tests/src/core/geometry/testqgscompoundcurve.cpp +++ b/tests/src/core/geometry/testqgscompoundcurve.cpp @@ -27,7 +27,7 @@ #include "testgeometryutils.h" #include "testtransformer.h" -class TestQgsCompoundCurve: public QObject +class TestQgsCompoundCurve : public QObject { Q_OBJECT private slots: @@ -164,8 +164,7 @@ void TestQgsCompoundCurve::addCurve() QCOMPARE( pts, QgsPointSequence() << QgsPoint( 1.0, 2.0 ) ); cc.clear(); - cs1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); + cs1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); cc.addCurve( cs1.clone() ); QVERIFY( !cc.isEmpty() ); @@ -181,15 +180,13 @@ void TestQgsCompoundCurve::addCurve() QVERIFY( cc.hasCurvedSegments() ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 0 ) ), cs1 ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); + QCOMPARE( *dynamic_cast( cc.curveAt( 0 ) ), cs1 ); QVERIFY( !cc.curveAt( -1 ) ); QVERIFY( !cc.curveAt( 1 ) ); QgsCircularString cs2; - cs2.setPoints( QgsPointSequence() << QgsPoint( 3, 4 ) - << QgsPoint( 4, 5 ) << QgsPoint( 3, 6 ) ); + cs2.setPoints( QgsPointSequence() << QgsPoint( 3, 4 ) << QgsPoint( 4, 5 ) << QgsPoint( 3, 6 ) ); cc.addCurve( cs2.clone() ); QCOMPARE( cc.numPoints(), 5 ); @@ -202,10 +199,9 @@ void TestQgsCompoundCurve::addCurve() pts.clear(); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) - << QgsPoint( 3, 4 ) << QgsPoint( 4, 5 ) << QgsPoint( 3, 6 ) ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 0 ) ), cs1 ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 1 ) ), cs2 ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) << QgsPoint( 4, 5 ) << QgsPoint( 3, 6 ) ); + QCOMPARE( *dynamic_cast( cc.curveAt( 0 ) ), cs1 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 1 ) ), cs2 ); QVERIFY( !cc.curveAt( -1 ) ); QVERIFY( !cc.curveAt( 2 ) ); @@ -223,12 +219,10 @@ void TestQgsCompoundCurve::addCurve() pts.clear(); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) - << QgsPoint( 3, 4 ) << QgsPoint( 4, 5 ) - << QgsPoint( 3, 6 ) << QgsPoint( 4, 6 ) ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 0 ) ), cs1 ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 1 ) ), cs2 ); - QCOMPARE( *dynamic_cast< const QgsLineString *>( cc.curveAt( 2 ) ), cs3 ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) << QgsPoint( 4, 5 ) << QgsPoint( 3, 6 ) << QgsPoint( 4, 6 ) ); + QCOMPARE( *dynamic_cast( cc.curveAt( 0 ) ), cs1 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 1 ) ), cs2 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 2 ) ), cs3 ); QVERIFY( !cc.curveAt( -1 ) ); QVERIFY( !cc.curveAt( 3 ) ); } @@ -281,8 +275,7 @@ void TestQgsCompoundCurve::addCurveWithZM() cc.clear(); //addCurve with z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.numPoints(), 2 ); @@ -292,13 +285,11 @@ void TestQgsCompoundCurve::addCurveWithZM() cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); //addCurve with m cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.numPoints(), 2 ); @@ -307,13 +298,11 @@ void TestQgsCompoundCurve::addCurveWithZM() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveM ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); //addCurve with zm cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.numPoints(), 2 ); @@ -322,8 +311,7 @@ void TestQgsCompoundCurve::addCurveWithZM() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveZM ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); } void TestQgsCompoundCurve::addCurveWithMissingDimInCompoundCurve() @@ -332,14 +320,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInCompoundCurve() //addCurve with z to non z compound curve QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) - << QgsPoint( Qgis::WkbType::Point, 2, 3 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) << QgsPoint( Qgis::WkbType::Point, 2, 3 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurve ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 3, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 3, 5 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.is3D() ); @@ -349,15 +335,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInCompoundCurve() QgsPointSequence pts; cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) - << QgsPoint( Qgis::WkbType::Point, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point, 3, 3 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) << QgsPoint( Qgis::WkbType::Point, 2, 3 ) << QgsPoint( Qgis::WkbType::Point, 3, 3 ) ); cc.removeCurve( 1 ); //addCurve with m to non m compound curve - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 3, 0, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 3, 3, 0, 5 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.is3D() ); @@ -365,15 +348,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInCompoundCurve() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurve ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) - << QgsPoint( Qgis::WkbType::Point, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point, 3, 3 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) << QgsPoint( Qgis::WkbType::Point, 2, 3 ) << QgsPoint( Qgis::WkbType::Point, 3, 3 ) ); cc.removeCurve( 1 ); //addCurve with zm to non m compound curve - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 6, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 3, 1, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 6, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 3, 1, 5 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.is3D() ); @@ -381,9 +361,7 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInCompoundCurve() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurve ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) - << QgsPoint( Qgis::WkbType::Point, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point, 3, 3 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 2 ) << QgsPoint( Qgis::WkbType::Point, 2, 3 ) << QgsPoint( Qgis::WkbType::Point, 3, 3 ) ); cc.removeCurve( 1 ); } @@ -394,14 +372,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInAddedCurve() //addCurve with no z to z compound curve QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveZ ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2, 3 ) << QgsPoint( Qgis::WkbType::Point, 3, 4 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.is3D() ); @@ -411,15 +387,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInAddedCurve() QgsPointSequence pts; cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 0 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 0 ) ); cc.removeCurve( 1 ); //add curve with m, no z to z compound curve - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 8 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 8 ) << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 9 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.is3D() ); @@ -427,15 +400,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInAddedCurve() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveZ ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 0 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 0 ) ); cc.removeCurve( 1 ); //add curve with zm to z compound curve - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 6, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 4, 7, 9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 6, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 4, 7, 9 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.is3D() ); @@ -444,22 +414,18 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInAddedCurve() cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 7 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 7 ) ); cc.removeCurve( 1 ); //addCurve with no m to m compound curve cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveM ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2, 3 ) << QgsPoint( Qgis::WkbType::Point, 3, 4 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.is3D() ); @@ -467,15 +433,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInAddedCurve() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveM ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 0 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 0 ) ); cc.removeCurve( 1 ); //add curve with z, no m to m compound curve - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 8 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 8 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 4, 9 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.is3D() ); @@ -483,15 +446,12 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInAddedCurve() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveM ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 0 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 0 ) ); cc.removeCurve( 1 ); //add curve with zm to m compound curve - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 6, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 4, 7, 9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 6, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 4, 7, 9 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.is3D() ); @@ -499,9 +459,7 @@ void TestQgsCompoundCurve::addCurveWithMissingDimInAddedCurve() QCOMPARE( cc.wkbType(), Qgis::WkbType::CompoundCurveM ); cc.points( pts ); - QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 9 ) ); + QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 3, 4, 0, 9 ) ); cc.removeCurve( 1 ); } @@ -513,8 +471,7 @@ void TestQgsCompoundCurve::addCurveExtend() // try to extend empty compound curve QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); cc.addCurve( cs.clone(), true ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve (CircularString (1 2, 2 3, 3 4))" ) ); @@ -543,8 +500,7 @@ void TestQgsCompoundCurve::addCurveExtend() // try to extend with another linestring //should add to final part, with no duplicate points - ls.setPoints( QgsPointSequence() << QgsPoint( 12, 12 ) - << QgsPoint( 13, 12 ) << QgsPoint( 14, 15 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 12, 12 ) << QgsPoint( 13, 12 ) << QgsPoint( 14, 15 ) ); cc.addCurve( ls.clone(), true ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve (CircularString (1 2, 2 3, 3 4),CircularString (6 6, 7 8),(10 8, 10 12, 11 13, 12 12, 13 12, 14 15))" ) ); @@ -568,13 +524,11 @@ void TestQgsCompoundCurve::removeCurve() QgsCompoundCurve cc; QgsCircularString cs1; - cs1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); + cs1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2, 3 ) << QgsPoint( 3, 4 ) ); cc.addCurve( cs1.clone() ); QgsCircularString cs2; - cs2.setPoints( QgsPointSequence() << QgsPoint( 3, 4 ) - << QgsPoint( 4, 5 ) << QgsPoint( 3, 6 ) ); + cs2.setPoints( QgsPointSequence() << QgsPoint( 3, 4 ) << QgsPoint( 4, 5 ) << QgsPoint( 3, 6 ) ); cc.addCurve( cs2.clone() ); QgsLineString cs3; @@ -585,20 +539,20 @@ void TestQgsCompoundCurve::removeCurve() cc.removeCurve( 3 ); QCOMPARE( cc.nCurves(), 3 ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 0 ) ), cs1 ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 1 ) ), cs2 ); - QCOMPARE( *dynamic_cast< const QgsLineString *>( cc.curveAt( 2 ) ), cs3 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 0 ) ), cs1 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 1 ) ), cs2 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 2 ) ), cs3 ); cc.removeCurve( 1 ); QCOMPARE( cc.nCurves(), 2 ); - QCOMPARE( *dynamic_cast< const QgsCircularString *>( cc.curveAt( 0 ) ), cs1 ); - QCOMPARE( *dynamic_cast< const QgsLineString *>( cc.curveAt( 1 ) ), cs3 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 0 ) ), cs1 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 1 ) ), cs3 ); cc.removeCurve( 0 ); QCOMPARE( cc.nCurves(), 1 ); - QCOMPARE( *dynamic_cast< const QgsLineString *>( cc.curveAt( 0 ) ), cs3 ); + QCOMPARE( *dynamic_cast( cc.curveAt( 0 ) ), cs3 ); cc.removeCurve( 0 ); @@ -609,9 +563,7 @@ void TestQgsCompoundCurve::removeCurve() void TestQgsCompoundCurve::assignment() { QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); QgsCompoundCurve cc1; cc1.addCurve( ls.clone() ); @@ -620,9 +572,7 @@ void TestQgsCompoundCurve::assignment() QVERIFY( cc1 != cc2 ); QgsLineString ls2; - ls2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 3, 4, 5, 6 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 2.0, 5 / 7.0, 1, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 5, 7 ) ); + ls2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 3, 4, 5, 6 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 2.0, 5 / 7.0, 1, 3 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 5, 7 ) ); cc2.addCurve( ls2.clone() ); QVERIFY( cc1 != cc2 ); @@ -635,8 +585,7 @@ void TestQgsCompoundCurve::clone() QgsCompoundCurve cc; QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) - << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); cc.addCurve( cs.clone() ); QgsLineString ls; @@ -648,10 +597,7 @@ void TestQgsCompoundCurve::clone() //clone with Z/M cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); cc.addCurve( cs.clone() ); ls.setPoints( QgsPointSequence() << QgsPoint( 1, 22, 31, 34 ) << QgsPoint( 23, 22, 42, 43 ) ); cc.addCurve( ls.clone() ); @@ -676,19 +622,17 @@ void TestQgsCompoundCurve::gettersSetters() QgsCompoundCurve cc; // no crash! - ( void )cc.xAt( -1 ); - ( void )cc.xAt( 1 ); - ( void )cc.yAt( -1 ); - ( void )cc.yAt( 1 ); - ( void )cc.zAt( -1 ); - ( void )cc.zAt( 1 ); - ( void )cc.mAt( -1 ); - ( void )cc.mAt( 1 ); + ( void ) cc.xAt( -1 ); + ( void ) cc.xAt( 1 ); + ( void ) cc.yAt( -1 ); + ( void ) cc.yAt( 1 ); + ( void ) cc.zAt( -1 ); + ( void ) cc.zAt( 1 ); + ( void ) cc.mAt( -1 ); + ( void ) cc.mAt( 1 ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.xAt( 0 ), 1.0 ); @@ -712,8 +656,7 @@ void TestQgsCompoundCurve::gettersSetters() ( void ) cc.mAt( -1 ); //out of range ( void ) cc.mAt( 11 ); //out of range - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 31, 22, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 31, 22, 13, 14 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.xAt( 0 ), 1.0 ); @@ -802,26 +745,22 @@ void TestQgsCompoundCurve::equality() QVERIFY( cc1 == cc2 ); QVERIFY( !( cc1 != cc2 ) ); - ls1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 1 / 3.0, 4 / 3.0 ) ); + ls1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 1 / 3.0, 4 / 3.0 ) ); cc1.addCurve( ls1.clone() ); QVERIFY( !( cc1 == cc2 ) ); //different number of curves QVERIFY( cc1 != cc2 ); QgsLineString ls2; - ls2.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2 / 6.0, 8 / 6.0 ) ); + ls2.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2 / 6.0, 8 / 6.0 ) ); cc2.addCurve( ls2.clone() ); QVERIFY( cc1 == cc2 ); //check non-integer equality QVERIFY( !( cc1 != cc2 ) ); - ls1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 1 / 3.0, 4 / 3.0 ) << QgsPoint( 7, 8 ) ); + ls1.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 1 / 3.0, 4 / 3.0 ) << QgsPoint( 7, 8 ) ); cc1.addCurve( ls1.clone() ); - ls2.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 2 / 6.0, 8 / 6.0 ) << QgsPoint( 6, 9 ) ); + ls2.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 2 / 6.0, 8 / 6.0 ) << QgsPoint( 6, 9 ) ); cc2.addCurve( ls2.clone() ); QVERIFY( !( cc1 == cc2 ) ); //different coordinates @@ -832,38 +771,29 @@ void TestQgsCompoundCurve::equalityZM() { QgsCompoundCurve cc1; QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 1 / 3.0, 4 / 3.0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 1 / 3.0, 4 / 3.0 ) ); cc1.addCurve( ls.clone() ); QgsCompoundCurve cc2; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 0 ) - << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 0 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 0 ) << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 0 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 0 ) ); cc2.addCurve( ls.clone() ); QVERIFY( !( cc1 == cc2 ) ); //different dimension QVERIFY( cc1 != cc2 ); QgsCompoundCurve cc3; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 4 ) ); cc3.addCurve( ls.clone() ); QVERIFY( !( cc2 == cc3 ) ); //different z coordinates QVERIFY( cc2 != cc3 ); QgsCompoundCurve cc4; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); cc4.addCurve( ls.clone() ); QgsCompoundCurve cc5; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 11 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 12 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 13 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 11 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 12 ) << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 13 ) ); cc5.addCurve( ls.clone() ); QVERIFY( !( cc4 == cc5 ) ); //different m values @@ -877,14 +807,11 @@ void TestQgsCompoundCurve::pointAt() QgsCompoundCurve cc; QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 31, 22, 13, 14 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 31, 22, 13, 14 ) ); cc.addCurve( ls.clone() ); QgsPoint p; @@ -918,8 +845,7 @@ void TestQgsCompoundCurve::insertVertex() //2d line QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 4.0, 7.0 ) ) ); @@ -997,11 +923,9 @@ void TestQgsCompoundCurve::insertVertexZM() { //insert 4d vertex in 4d line QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QgsCompoundCurve cc; - cc.addCurve( cs.clone( ) ); + cc.addCurve( cs.clone() ); QVERIFY( cc.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ) ); QCOMPARE( cc.numPoints(), 5 ); @@ -1021,8 +945,7 @@ void TestQgsCompoundCurve::insertVertexZM() //insert 4d vertex in 2d line cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZM, 2, 4, 103, 104 ) ) ); @@ -1186,8 +1109,7 @@ void TestQgsCompoundCurve::nextVertexZM() //CircularStringZ cc.clear(); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); cc.addCurve( cs.clone() ); QgsVertexId vId( 0, 0, -1 ); @@ -1201,8 +1123,7 @@ void TestQgsCompoundCurve::nextVertexZM() QVERIFY( !cc.nextVertex( vId, pt ) ); //CircularStringM - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); cc.clear(); cc.addCurve( cs.clone() ); @@ -1217,8 +1138,7 @@ void TestQgsCompoundCurve::nextVertexZM() QVERIFY( !cc.nextVertex( vId, pt ) ); //CircularStringZM - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); cc.clear(); cc.addCurve( cs.clone() ); @@ -1240,15 +1160,14 @@ void TestQgsCompoundCurve::vertexAtPointAt() Qgis::VertexType type; cc.vertexAt( QgsVertexId( 0, 0, -10 ) ); //out of bounds, check for no crash - cc.vertexAt( QgsVertexId( 0, 0, 10 ) ); //out of bounds, check for no crash + cc.vertexAt( QgsVertexId( 0, 0, 10 ) ); //out of bounds, check for no crash QVERIFY( !cc.pointAt( -10, p, type ) ); QVERIFY( !cc.pointAt( 10, p, type ) ); //CircularString QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); cc.addCurve( cs.clone() ); cc.vertexAt( QgsVertexId( 0, 0, -10 ) ); @@ -1289,9 +1208,7 @@ void TestQgsCompoundCurve::vertexAtPointAtZM() //CircularStringZ QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 22, 23 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 22, 23 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); @@ -1312,9 +1229,7 @@ void TestQgsCompoundCurve::vertexAtPointAtZM() //CircularStringM cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 22, 0, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) << QgsPoint( Qgis::WkbType::PointM, 1, 22, 0, 24 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); @@ -1335,9 +1250,7 @@ void TestQgsCompoundCurve::vertexAtPointAtZM() //CircularStringZM cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 23, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 23, 24 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); @@ -1367,8 +1280,7 @@ void TestQgsCompoundCurve::moveVertex() //valid line QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); @@ -1401,9 +1313,7 @@ void TestQgsCompoundCurve::moveVertex() QCOMPARE( pt, QgsPoint( 26.0, 27.0 ) ); //move 4d point in 4d line - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); cc.clear(); cc.addCurve( cs.clone() ); @@ -1419,8 +1329,7 @@ void TestQgsCompoundCurve::moveVertex() QCOMPARE( pt, QgsPoint( Qgis::WkbType::PointZM, 34, 35, 12, 13 ) ); //move 4d point in 2d line - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); cc.clear(); cc.addCurve( cs.clone() ); @@ -1439,10 +1348,7 @@ void TestQgsCompoundCurve::deleteVertex() // valid line QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 6, 7 ) ); cc.addCurve( cs.clone() ); // out of range vertices @@ -1463,8 +1369,7 @@ void TestQgsCompoundCurve::deleteVertex() // removing a middle vertex from a 3 point CircularString should create a LineString cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.numPoints(), 3 ); @@ -1475,8 +1380,7 @@ void TestQgsCompoundCurve::deleteVertex() // removing a start vertex from a 3 point CircularString should remove the whole curve cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.numPoints(), 3 ); @@ -1486,8 +1390,7 @@ void TestQgsCompoundCurve::deleteVertex() // removing an end vertex from a 3 point CircularString should remove the whole curve cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.numPoints(), 3 ); @@ -1497,21 +1400,17 @@ void TestQgsCompoundCurve::deleteVertex() // two lines, small line first and long line second QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) ); cc.clear(); cc.addCurve( ls.clone() ); - ls.setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 32, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 31, 42, 4, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 32, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 31, 42, 4, 5 ) ); cc.addCurve( ls.clone() ); QVERIFY( cc.deleteVertex( QgsVertexId( 0, 0, 1 ) ) ); QCOMPARE( cc.nCurves(), 1 ); - const QgsLineString *lsPtr = dynamic_cast< const QgsLineString * >( cc.curveAt( 0 ) ); + const QgsLineString *lsPtr = dynamic_cast( cc.curveAt( 0 ) ); QCOMPARE( lsPtr->numPoints(), 3 ); QCOMPARE( lsPtr->startPoint(), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) ); @@ -1520,28 +1419,24 @@ void TestQgsCompoundCurve::deleteVertex() //add vertex at the end of linestring QVERIFY( cc.insertVertex( QgsVertexId( 0, 0, 3 ), QgsPoint( Qgis::WkbType::PointZM, 35, 43, 4, 5 ) ) ); - lsPtr = dynamic_cast< const QgsLineString * >( cc.curveAt( 0 ) ); + lsPtr = dynamic_cast( cc.curveAt( 0 ) ); QCOMPARE( lsPtr->numPoints(), 4 ); QCOMPARE( lsPtr->startPoint(), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) ); QCOMPARE( lsPtr->endPoint(), QgsPoint( Qgis::WkbType::PointZM, 35, 43, 4, 5 ) ); // two lines, long line first and small line second - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 32, 4, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 32, 4, 5 ) ); cc.clear(); cc.addCurve( ls.clone() ); - ls.setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZM, 21, 32, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 31, 42, 4, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 32, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 31, 42, 4, 5 ) ); cc.addCurve( ls.clone() ); QVERIFY( cc.deleteVertex( QgsVertexId( 0, 0, 2 ) ) ); QCOMPARE( cc.nCurves(), 1 ); - lsPtr = dynamic_cast< const QgsLineString * >( cc.curveAt( 0 ) ); + lsPtr = dynamic_cast( cc.curveAt( 0 ) ); QCOMPARE( lsPtr->numPoints(), 3 ); QCOMPARE( lsPtr->startPoint(), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) ); @@ -1563,8 +1458,7 @@ void TestQgsCompoundCurve::deleteVertex() void TestQgsCompoundCurve::filterVertices() { - auto filter = []( const QgsPoint & point )-> bool - { + auto filter = []( const QgsPoint &point ) -> bool { return point.x() > 5; }; @@ -1572,20 +1466,14 @@ void TestQgsCompoundCurve::filterVertices() cc.filterVertices( filter ); //no crash QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) ); cc.addCurve( cs.clone() ); cc.filterVertices( filter ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve ZM (CircularString ZM (11 2 3 4, 11 12 13 14, 111 12 23 24))" ) ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 111, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) << QgsPoint( 1, 111, 23, 24, Qgis::WkbType::PointZM ) ); cc.addCurve( ls.clone() ); cc.filterVertices( filter ); @@ -1599,34 +1487,27 @@ void TestQgsCompoundCurve::removeDuplicateNodes() QVERIFY( !cc.removeDuplicateNodes() ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.removeDuplicateNodes() ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve (CircularString (11 2, 11 12, 111 12))" ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) ); cc.clear(); cc.addCurve( cs.clone() ); QVERIFY( !cc.removeDuplicateNodes() ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve (CircularString (11 2, 11 12, 11 2))" ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 10, 3 ) << QgsPoint( 11.01, 1.99 ) - << QgsPoint( 9, 3 ) << QgsPoint( 11, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 10, 3 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 9, 3 ) << QgsPoint( 11, 2 ) ); cc.clear(); cc.addCurve( cs.clone() ); QVERIFY( !cc.removeDuplicateNodes( 0.02 ) ); QCOMPARE( cc.asWkt( 2 ), QStringLiteral( "CompoundCurve (CircularString (11 2, 10 3, 11.01 1.99, 9 3, 11 2))" ) ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) - << QgsPoint( 111.01, 11.99 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); cc.clear(); cc.addCurve( cs.clone() ); @@ -1638,8 +1519,7 @@ void TestQgsCompoundCurve::removeDuplicateNodes() // with tiny segment QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 111.01, 11.99 ) - << QgsPoint( 111, 12 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 111.01, 11.99 ) << QgsPoint( 111, 12 ) ); cc.addCurve( ls.clone() ); QVERIFY( !cc.removeDuplicateNodes() ); @@ -1655,8 +1535,7 @@ void TestQgsCompoundCurve::removeDuplicateNodes() // ensure continuity cc.clear(); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 111.01, 11.99 ) << QgsPoint( 111, 12 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 111.01, 11.99 ) << QgsPoint( 111, 12 ) ); cc.addCurve( ls.clone() ); ls.setPoints( QgsPointSequence() << QgsPoint( 111, 12 ) << QgsPoint( 31, 33 ) ); cc.addCurve( ls.clone() ); @@ -1712,11 +1591,9 @@ void TestQgsCompoundCurve::addZValue() //linestring with m cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) ); cc.addCurve( cs.clone() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 21, 32, 0, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 21, 32, 0, 4 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.addZValue( 5 ) ); @@ -1775,11 +1652,9 @@ void TestQgsCompoundCurve::addMValue() //linestring with z cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) ); cc.addCurve( cs.clone() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 21, 32, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 21, 32, 4 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.addMValue( 5 ) ); @@ -1835,11 +1710,9 @@ void TestQgsCompoundCurve::dropZValue() //linestring with m cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); cc.addCurve( cs.clone() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 3, 4 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.dropZValue() ); @@ -1894,12 +1767,10 @@ void TestQgsCompoundCurve::dropMValue() QVERIFY( !cc.dropMValue() ); //already dropped //linestring with z - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); cc.clear(); cc.addCurve( cs.clone() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 3, 4 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.dropMValue() ); @@ -1924,22 +1795,19 @@ void TestQgsCompoundCurve::isRing() QVERIFY( !cc.isRing() ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 2 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.isRing() ); //<4 points cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 31, 32 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 31, 32 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.isRing() ); //not closed cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.isRing() ); @@ -1950,12 +1818,12 @@ void TestQgsCompoundCurve::isRing() QVERIFY( !cc.isRing() ); - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.isRing() ); - cs.setPoints( QgsPointSequence() << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.isRing() ); @@ -1965,14 +1833,11 @@ void TestQgsCompoundCurve::startPointEndPoint() { QgsCompoundCurve cc; QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); cc.addCurve( ls.clone() ); QCOMPARE( cc.startPoint(), QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) ); @@ -1988,7 +1853,7 @@ void TestQgsCompoundCurve::orientation() { QgsCompoundCurve cc; - ( void )cc.orientation(); // no crash + ( void ) cc.orientation(); // no crash cc.fromWkt( QStringLiteral( "CompoundCurve( ( 0 0, 0 1), CircularString (0 1, 1 1, 1 0), (1 0, 0 0))" ) ); QCOMPARE( cc.orientation(), Qgis::AngularDirection::Clockwise ); @@ -2003,14 +1868,11 @@ void TestQgsCompoundCurve::length() QCOMPARE( cc.length(), 0.0 ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); cc.addCurve( ls.clone() ); QGSCOMPARENEAR( cc.length(), 36.1433, 0.001 ); @@ -2028,16 +1890,14 @@ void TestQgsCompoundCurve::centroid() QCOMPARE( cc.centroid(), QgsPoint( 5, 10 ) ); cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 20, 10 ) << QgsPoint( 2, 9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 20, 10 ) << QgsPoint( 2, 9 ) ); cc.addCurve( cs.clone() ); QgsPoint centroid = cc.centroid(); QGSCOMPARENEAR( centroid.x(), 7.333, 0.001 ); QGSCOMPARENEAR( centroid.y(), 6.333, 0.001 ); - cs.setPoints( QgsPointSequence() << QgsPoint( 2, 9 ) - << QgsPoint( 12, 9 ) << QgsPoint( 15, 19 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 2, 9 ) << QgsPoint( 12, 9 ) << QgsPoint( 15, 19 ) ); cc.addCurve( cs.clone() ); centroid = cc.centroid(); @@ -2051,8 +1911,8 @@ void TestQgsCompoundCurve::closestSegment() QgsVertexId vId; int leftOf = 0; - QgsPoint p( 0, 0 ); // reset all coords to zero - ( void )cc.closestSegment( QgsPoint( 1, 2 ), p, vId ); //empty line, just want no crash + QgsPoint p( 0, 0 ); // reset all coords to zero + ( void ) cc.closestSegment( QgsPoint( 1, 2 ), p, vId ); //empty line, just want no crash QgsCircularString cs; cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) ); @@ -2061,8 +1921,7 @@ void TestQgsCompoundCurve::closestSegment() QVERIFY( cc.closestSegment( QgsPoint( 5, 10 ), p, vId ) < 0 ); cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) ); cc.addCurve( cs.clone() ); QGSCOMPARENEAR( cc.closestSegment( QgsPoint( 4, 11 ), p, vId, &leftOf ), 2.0, 0.0001 ); @@ -2070,7 +1929,7 @@ void TestQgsCompoundCurve::closestSegment() QCOMPARE( vId, QgsVertexId( 0, 0, 1 ) ); QCOMPARE( leftOf, -1 ); - QGSCOMPARENEAR( cc.closestSegment( QgsPoint( 8, 11 ), p, vId, &leftOf ), 1.583512, 0.0001 ); + QGSCOMPARENEAR( cc.closestSegment( QgsPoint( 8, 11 ), p, vId, &leftOf ), 1.583512, 0.0001 ); QGSCOMPARENEAR( p.x(), 6.84, 0.01 ); QGSCOMPARENEAR( p.y(), 11.49, 0.01 ); QCOMPARE( vId, QgsVertexId( 0, 0, 1 ) ); @@ -2159,16 +2018,14 @@ void TestQgsCompoundCurve::sumUpArea() QCOMPARE( area, 1.0 ); cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) - << QgsPoint( 2, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) ); cc.addCurve( cs.clone() ); cc.sumUpArea( area ); QGSCOMPARENEAR( area, 4.141593, 0.0001 ); cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) - << QgsPoint( 2, 2 ) << QgsPoint( 0, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) << QgsPoint( 0, 2 ) ); cc.addCurve( cs.clone() ); cc.sumUpArea( area ); @@ -2176,8 +2033,7 @@ void TestQgsCompoundCurve::sumUpArea() // full circle cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 4, 0 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 4, 0 ) << QgsPoint( 0, 0 ) ); cc.addCurve( cs.clone() ); area = 0.0; cc.sumUpArea( area ); @@ -2191,8 +2047,7 @@ void TestQgsCompoundCurve::sumUpArea() cc.addCurve( ll1 ); QgsLineString *ll2 = new QgsLineString(); - ll2->setPoints( QgsPointSequence() << QgsPoint( 0, 2 ) - << QgsPoint( -1, 0 ) << QgsPoint( 0, -1 ) ); + ll2->setPoints( QgsPointSequence() << QgsPoint( 0, 2 ) << QgsPoint( -1, 0 ) << QgsPoint( 0, -1 ) ); cc.addCurve( ll2 ); QgsLineString *ll3 = new QgsLineString(); @@ -2203,9 +2058,7 @@ void TestQgsCompoundCurve::sumUpArea() cc.sumUpArea( ccArea ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 0, 2 ) << QgsPoint( -1, 0 ) - << QgsPoint( 0, -1 ) << QgsPoint( 1, 1 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) << QgsPoint( -1, 0 ) << QgsPoint( 0, -1 ) << QgsPoint( 1, 1 ) ); double lsArea = 0.0; ls.sumUpArea( lsArea ); @@ -2264,24 +2117,23 @@ void TestQgsCompoundCurve::angle() QgsCompoundCurve cc; QgsCircularString cs; - ( void )cc.vertexAngle( QgsVertexId() ); //just want no crash - ( void )cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash + ( void ) cc.vertexAngle( QgsVertexId() ); //just want no crash + ( void ) cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) ); cc.addCurve( cs.clone() ); - ( void )cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless + ( void ) cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless cc.clear(); cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) ); cc.addCurve( cs.clone() ); - ( void )cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless - ( void )cc.vertexAngle( QgsVertexId( 0, 0, 1 ) ); //just want no crash, any answer is meaningless + ( void ) cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless + ( void ) cc.vertexAngle( QgsVertexId( 0, 0, 1 ) ); //just want no crash, any answer is meaningless cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) ); cc.addCurve( cs.clone() ); QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 1.5708, 0.0001 ); @@ -2289,19 +2141,17 @@ void TestQgsCompoundCurve::angle() QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 2 ) ), 4.712389, 0.0001 ); cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 2 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 2 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); cc.addCurve( cs.clone() ); QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 1.5708, 0.0001 ); QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 3.141593, 0.0001 ); QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 2 ) ), 4.712389, 0.0001 ); - ( void )cc.vertexAngle( QgsVertexId( 0, 0, 20 ) ); // no crash + ( void ) cc.vertexAngle( QgsVertexId( 0, 0, 20 ) ); // no crash cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) - << QgsPoint( 0, 2 ) << QgsPoint( -1, 3 ) << QgsPoint( 0, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 2 ) << QgsPoint( -1, 3 ) << QgsPoint( 0, 4 ) ); cc.addCurve( cs.clone() ); QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 1.5708, 0.0001 ); @@ -2311,8 +2161,7 @@ void TestQgsCompoundCurve::angle() QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 4 ) ), 1.5708, 0.0001 ); cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 4 ) << QgsPoint( -1, 3 ) - << QgsPoint( 0, 2 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 4 ) << QgsPoint( -1, 3 ) << QgsPoint( 0, 2 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); cc.addCurve( cs.clone() ); QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 4.712389, 0.0001 ); @@ -2331,8 +2180,7 @@ void TestQgsCompoundCurve::angle() //closed circular string cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); cc.addCurve( cs.clone() ); QGSCOMPARENEAR( cc.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 0, 0.00001 ); @@ -2347,47 +2195,43 @@ void TestQgsCompoundCurve::boundary() QVERIFY( !cc.boundary() ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); cc.addCurve( cs.clone() ); QgsAbstractGeometry *boundary = cc.boundary(); - QgsMultiPoint *mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + QgsMultiPoint *mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); delete boundary; // closed string = no boundary cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.boundary() ); //boundary with z cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); cc.addCurve( cs.clone() ); boundary = cc.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->geometryN( 0 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->z(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->z(), 10.0 ); QCOMPARE( mpBoundary->geometryN( 1 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); delete boundary; } @@ -2406,8 +2250,7 @@ void TestQgsCompoundCurve::boundingBox() QCOMPARE( cc.boundingBox(), QgsRectangle( 5, 10, 10, 15 ) ); cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) - << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); cc.addCurve( cs.clone() ); QCOMPARE( cc.boundingBox(), QgsRectangle( -6.125, -10.25, -5, -9 ) ); @@ -2461,7 +2304,7 @@ void TestQgsCompoundCurve::boundingBoxIntersects() QVERIFY( cc.boundingBox().isNull() ); QVERIFY( !cc.boundingBoxIntersects( ( QgsRectangle( 0, 0, 0, 0 ) ) ) ); - QVERIFY( !cc.boundingBoxIntersects( ( QgsRectangle( ) ) ) ); + QVERIFY( !cc.boundingBoxIntersects( ( QgsRectangle() ) ) ); cs.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 15 ) ); cc.addCurve( cs.clone() ); @@ -2471,8 +2314,7 @@ void TestQgsCompoundCurve::boundingBoxIntersects() cc.clear(); QVERIFY( cc.boundingBox().isNull() ); - cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) - << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.boundingBoxIntersects( QgsRectangle( -5, -9.5, -2, 2 ) ) ); @@ -2514,7 +2356,7 @@ void TestQgsCompoundCurve::interpolate() { QgsCompoundCurve cc; - std::unique_ptr< QgsPoint > interpolateResult( cc.interpolatePoint( 1 ) ); // no crash + std::unique_ptr interpolateResult( cc.interpolatePoint( 1 ) ); // no crash QVERIFY( !interpolateResult.get() ); cc.fromWkt( QStringLiteral( "CompoundCurve ZM( ( 5 0 -1 -2, 10 0 1 2 ), CircularString ZM (10 0 1 2, 11 1 3 4, 12 0 13 14))" ) ); @@ -2563,17 +2405,14 @@ void TestQgsCompoundCurve::swapXy() cc.swapXy(); //no crash QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); cc.addCurve( cs.clone() ); cc.swapXy(); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve ZM (CircularString ZM (2 11 3 4, 12 11 13 14, 12 111 23 24))" ) ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) ); cc.addCurve( ls.clone() ); cc.swapXy(); @@ -2583,27 +2422,23 @@ void TestQgsCompoundCurve::swapXy() void TestQgsCompoundCurve::reversed() { QgsCompoundCurve cc; - std::unique_ptr< QgsCompoundCurve > reversed( cc.reversed() ); + std::unique_ptr reversed( cc.reversed() ); QVERIFY( reversed->isEmpty() ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 23, 32, 7, 8 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 23, 32, 7, 8 ) ); cc.addCurve( ls.clone() ); reversed.reset( cc.reversed() ); QCOMPARE( reversed->numPoints(), 4 ); - QVERIFY( dynamic_cast< const QgsLineString * >( reversed->curveAt( 0 ) ) ); - QVERIFY( dynamic_cast< const QgsCircularString * >( reversed->curveAt( 1 ) ) ); + QVERIFY( dynamic_cast( reversed->curveAt( 0 ) ) ); + QVERIFY( dynamic_cast( reversed->curveAt( 1 ) ) ); QCOMPARE( reversed->wkbType(), Qgis::WkbType::CompoundCurveZM ); QVERIFY( reversed->is3D() ); QVERIFY( reversed->isMeasure() ); @@ -2629,8 +2464,7 @@ void TestQgsCompoundCurve::isClosed() QVERIFY( !cc.isClosed() ); - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) - << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); cc.addCurve( cs.clone() ); QVERIFY( !cc.isClosed() ); @@ -2643,10 +2477,7 @@ void TestQgsCompoundCurve::isClosed() //test that m values aren't considered when testing for closedness cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 22, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 6 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 22, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 6 ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.isClosed() ); @@ -2660,8 +2491,7 @@ void TestQgsCompoundCurve::close() cc.close(); QVERIFY( cc.isEmpty() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); cc.addCurve( ls.clone() ); QCOMPARE( cc.numPoints(), 3 ); @@ -2685,8 +2515,7 @@ void TestQgsCompoundCurve::close() void TestQgsCompoundCurve::transformVertices() { // transform vertices - auto transform = []( const QgsPoint & point )-> QgsPoint - { + auto transform = []( const QgsPoint &point ) -> QgsPoint { return QgsPoint( point.x() + 2, point.y() + 3, point.z() + 4, point.m() + 5 ); }; @@ -2694,20 +2523,14 @@ void TestQgsCompoundCurve::transformVertices() cc.transformVertices( transform ); //no crash QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) ); cc.addCurve( cs.clone() ); cc.transformVertices( transform ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve ZM (CircularString ZM (3 5 7 9, 13 5 7 9, 13 15 17 19, 113 15 27 29, 3 5 7 9))" ) ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 111, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) << QgsPoint( 1, 111, 23, 24, Qgis::WkbType::PointZM ) ); cc.addCurve( ls.clone() ); cc.transformVertices( transform ); @@ -2724,20 +2547,14 @@ void TestQgsCompoundCurve::transformWithClass() QVERIFY( cc.transform( &transformer ) ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) ); cc.addCurve( cs.clone() ); QVERIFY( cc.transform( &transformer ) ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve ZM (CircularString ZM (3 16 8 3, 33 16 8 3, 33 26 18 13, 333 26 28 23, 3 16 8 3))" ) ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 111, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 12, 111, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 22, 122, 33, 34, Qgis::WkbType::PointZM ) << QgsPoint( 1, 111, 23, 24, Qgis::WkbType::PointZM ) ); cc.addCurve( ls.clone() ); QVERIFY( cc.transform( &transformer ) ); @@ -2745,7 +2562,6 @@ void TestQgsCompoundCurve::transformWithClass() TestFailTransformer failTransformer; QVERIFY( !cc.transform( &failTransformer ) ); - } void TestQgsCompoundCurve::crsTransform() @@ -2756,14 +2572,12 @@ void TestQgsCompoundCurve::crsTransform() // 2d CRS transform QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) - << QgsPoint( 6474985, -3526584 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) << QgsPoint( 6474985, -3526584 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 6474985, -3526584 ) - << QgsPoint( 6504985, -3526584 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 6474985, -3526584 ) << QgsPoint( 6504985, -3526584 ) ); cc.addCurve( ls.clone() ); cc.transform( tr, Qgis::TransformDirection::Forward ); @@ -2788,14 +2602,12 @@ void TestQgsCompoundCurve::crs3dTransformAndReverse() //3d CRS transform QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 6474985, -3526584, 3, 4 ) - << QgsPoint( 6504985, -3526584, 5, 6 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 6474985, -3526584, 3, 4 ) << QgsPoint( 6504985, -3526584, 5, 6 ) ); cc.addCurve( ls.clone() ); cc.transform( tr, Qgis::TransformDirection::Forward ); @@ -2865,7 +2677,6 @@ void TestQgsCompoundCurve::crs3dTransformAndReverse() cc.pointAt( 2, pt, v ); QGSCOMPARENEAR( pt.z(), 5, 0.001 ); #endif - } void TestQgsCompoundCurve::QTransformation() @@ -2873,14 +2684,12 @@ void TestQgsCompoundCurve::QTransformation() QTransform qtr = QTransform::fromScale( 2, 3 ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 13, 13, 14 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 13, 13, 14 ) ); cc.addCurve( ls.clone() ); cc.transform( qtr, 5, 2, 4, 3 ); @@ -2907,14 +2716,11 @@ void TestQgsCompoundCurve::coordinateSequence() QVERIFY( coords.at( 0 ).at( 0 ).isEmpty() ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) << - QgsPoint( Qgis::WkbType::PointZM, 31, 32, 16, 17 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 16, 17 ) ); cc.addCurve( ls.clone() ); coords = cc.coordinateSequence(); @@ -2937,14 +2743,11 @@ void TestQgsCompoundCurve::points() QVERIFY( points.isEmpty() ); QgsCircularString cl; - cl.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cl.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); cc.addCurve( cl.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); cc.addCurve( ls.clone() ); cc.points( points ); @@ -2959,11 +2762,10 @@ void TestQgsCompoundCurve::segmentize() { QgsCompoundCurve cc; QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); cc.addCurve( cs.clone() ); - std::unique_ptr segmentized( static_cast< QgsLineString * >( cc.segmentize() ) ); + std::unique_ptr segmentized( static_cast( cc.segmentize() ) ); QCOMPARE( segmentized->numPoints(), 156 ); QCOMPARE( segmentized->vertexCount(), 156 ); @@ -2978,12 +2780,10 @@ void TestQgsCompoundCurve::segmentize() //segmentize with Z/M cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 10, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 2, 21, 24 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 10, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 2, 21, 24 ) ); cc.addCurve( cs.clone() ); - segmentized.reset( static_cast< QgsLineString * >( cc.segmentize() ) ); + segmentized.reset( static_cast( cc.segmentize() ) ); QCOMPARE( segmentized->numPoints(), 156 ); QCOMPARE( segmentized->vertexCount(), 156 ); @@ -2997,7 +2797,7 @@ void TestQgsCompoundCurve::segmentize() //segmentize an empty line cc.clear(); - segmentized.reset( static_cast< QgsLineString * >( cc.segmentize() ) ); + segmentized.reset( static_cast( cc.segmentize() ) ); QVERIFY( segmentized->isEmpty() ); QCOMPARE( segmentized->numPoints(), 0 ); @@ -3009,7 +2809,7 @@ void TestQgsCompoundCurve::segmentize() void TestQgsCompoundCurve::substring() { QgsCompoundCurve cc; - std::unique_ptr< QgsCompoundCurve > substringResult( cc.curveSubstring( 1, 2 ) ); // no crash + std::unique_ptr substringResult( cc.curveSubstring( 1, 2 ) ); // no crash QVERIFY( substringResult.get() ); QVERIFY( substringResult->isEmpty() ); @@ -3017,8 +2817,7 @@ void TestQgsCompoundCurve::substring() cc.fromWkt( QStringLiteral( "CompoundCurve ZM( ( 5 0 -1 -2, 10 0 1 2 ), CircularString ZM (10 0 1 2, 11 1 3 4, 12 0 13 14))" ) ); substringResult.reset( cc.curveSubstring( 0, 0 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ZM ((5 0 -1 -2, 5 0 -1 -2))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ZM ((5 0 -1 -2, 5 0 -1 -2))" ) ); substringResult.reset( cc.curveSubstring( -1, -0.1 ) ); QVERIFY( substringResult->isEmpty() ); @@ -3027,46 +2826,37 @@ void TestQgsCompoundCurve::substring() QVERIFY( substringResult->isEmpty() ); substringResult.reset( cc.curveSubstring( -1, 1 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ZM ((5 0 -1 -2, 6 0 -0.6 -1.2))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ZM ((5 0 -1 -2, 6 0 -0.6 -1.2))" ) ); substringResult.reset( cc.curveSubstring( 1, -1 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 6 0 -0.6 -1.2))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 6 0 -0.6 -1.2))" ) ); substringResult.reset( cc.curveSubstring( -1, 10000 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ZM ((5 0 -1 -2, 10 0 1 2),CircularString ZM (10 0 1 2, 11 1 3 4, 12 0 13 14))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ZM ((5 0 -1 -2, 10 0 1 2),CircularString ZM (10 0 1 2, 11 1 3 4, 12 0 13 14))" ) ); substringResult.reset( cc.curveSubstring( 1, 10000 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 10 0 1 2),CircularString ZM (10 0 1 2, 11 1 3 4, 12 0 13 14))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 10 0 1 2),CircularString ZM (10 0 1 2, 11 1 3 4, 12 0 13 14))" ) ); substringResult.reset( cc.curveSubstring( 1, 7 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 10 0 1 2),CircularString ZM (10 0 1 2, 10.46 0.84 2.27 3.27, 11.42 0.91 5.73 6.73))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 10 0 1 2),CircularString ZM (10 0 1 2, 10.46 0.84 2.27 3.27, 11.42 0.91 5.73 6.73))" ) ); substringResult.reset( cc.curveSubstring( 1, 1.5 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 6.5 0 -0.4 -0.8))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ZM ((6 0 -0.6 -1.2, 6.5 0 -0.4 -0.8))" ) ); cc.fromWkt( QStringLiteral( "CompoundCurve Z( ( 5 0 -1, 10 0 1 ), CircularString Z (10 0 1, 11 1 3, 12 0 13))" ) ); substringResult.reset( cc.curveSubstring( 1, 7 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve Z ((6 0 -0.6, 10 0 1),CircularString Z (10 0 1, 10.46 0.84 2.27, 11.42 0.91 5.73))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve Z ((6 0 -0.6, 10 0 1),CircularString Z (10 0 1, 10.46 0.84 2.27, 11.42 0.91 5.73))" ) ); cc.fromWkt( QStringLiteral( "CompoundCurve M( ( 5 0 -1, 10 0 1 ), CircularString M (10 0 1, 11 1 3, 12 0 13))" ) ); substringResult.reset( cc.curveSubstring( 1, 7 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve M ((6 0 -0.6, 10 0 1),CircularString M (10 0 1, 10.46 0.84 2.27, 11.42 0.91 5.73))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve M ((6 0 -0.6, 10 0 1),CircularString M (10 0 1, 10.46 0.84 2.27, 11.42 0.91 5.73))" ) ); cc.fromWkt( QStringLiteral( "CompoundCurve( ( 5 0, 10 0 ), CircularString (10 0, 11 1, 12 0))" ) ); substringResult.reset( cc.curveSubstring( 1, 7 ) ); - QCOMPARE( substringResult->asWkt( 2 ), - QStringLiteral( "CompoundCurve ((6 0, 10 0),CircularString (10 0, 10.46 0.84, 11.42 0.91))" ) ); + QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "CompoundCurve ((6 0, 10 0),CircularString (10 0, 10.46 0.84, 11.42 0.91))" ) ); } void TestQgsCompoundCurve::convertTo() @@ -3118,18 +2908,15 @@ void TestQgsCompoundCurve::convertTo() void TestQgsCompoundCurve::curveToLine() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 25, 10, 6, 7 ) ); cc.addCurve( ls.clone() ); - std::unique_ptr segmentized( static_cast< QgsLineString * >( cc.curveToLine() ) ); + std::unique_ptr segmentized( static_cast( cc.curveToLine() ) ); QCOMPARE( segmentized->numPoints(), 182 ); QCOMPARE( segmentized->wkbType(), Qgis::WkbType::LineStringZM ); @@ -3143,10 +2930,9 @@ void TestQgsCompoundCurve::toCurveType() { QgsCompoundCurve cc; QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) ); cc.addCurve( cs.clone() ); - std::unique_ptr< QgsCurve > curve( cc.toCurveType() ); + std::unique_ptr curve( cc.toCurveType() ); QCOMPARE( curve->wkbType(), Qgis::WkbType::CompoundCurve ); QCOMPARE( curve->numPoints(), 3 ); @@ -3170,10 +2956,7 @@ void TestQgsCompoundCurve::toCurveType() void TestQgsCompoundCurve::asQPolygonF() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); @@ -3193,10 +2976,7 @@ void TestQgsCompoundCurve::asQPolygonF() void TestQgsCompoundCurve::toFromWKB() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); @@ -3218,10 +2998,10 @@ void TestQgsCompoundCurve::toFromWKB() QVERIFY( cc.isMeasure() ); QCOMPARE( cc.nCurves(), 1 ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 0 ), cs.pointN( 0 ) ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 1 ), cs.pointN( 1 ) ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 2 ), cs.pointN( 2 ) ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 3 ), cs.pointN( 3 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 0 ), cs.pointN( 0 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 1 ), cs.pointN( 1 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 2 ), cs.pointN( 2 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 3 ), cs.pointN( 3 ) ); //bad WKB - check for no crash cc.clear(); @@ -3241,10 +3021,7 @@ void TestQgsCompoundCurve::toFromWKB() void TestQgsCompoundCurve::toFromWKT() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); @@ -3259,10 +3036,10 @@ void TestQgsCompoundCurve::toFromWKT() QVERIFY( cc.is3D() ); QVERIFY( cc.isMeasure() ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 0 ), cs.pointN( 0 ) ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 1 ), cs.pointN( 1 ) ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 2 ), cs.pointN( 2 ) ); - QCOMPARE( qgis::down_cast< const QgsCircularString *>( cc.curveAt( 0 ) )->pointN( 3 ), cs.pointN( 3 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 0 ), cs.pointN( 0 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 1 ), cs.pointN( 1 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 2 ), cs.pointN( 2 ) ); + QCOMPARE( qgis::down_cast( cc.curveAt( 0 ) )->pointN( 3 ), cs.pointN( 3 ) ); //bad WKT QVERIFY( !cc.fromWkt( "Polygon()" ) ); @@ -3279,24 +3056,19 @@ void TestQgsCompoundCurve::exportImport() //asGML2 QgsCompoundCurve exportCurve; QgsCircularString exportLine; - exportLine.setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) - << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); + exportLine.setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); exportCurve.addCurve( exportLine.clone() ); QgsLineString exportLineString; - exportLineString.setPoints( QgsPointSequence() << QgsPoint( 51, 52 ) - << QgsPoint( 61, 62 ) ); + exportLineString.setPoints( QgsPointSequence() << QgsPoint( 51, 52 ) << QgsPoint( 61, 62 ) ); exportCurve.addCurve( exportLineString.clone() ); QgsCircularString exportLineFloat; - exportLineFloat.setPoints( QgsPointSequence() << QgsPoint( 1 / 3.0, 2 / 3.0 ) - << QgsPoint( 1 + 1 / 3.0, 1 + 2 / 3.0 ) - << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) ); + exportLineFloat.setPoints( QgsPointSequence() << QgsPoint( 1 / 3.0, 2 / 3.0 ) << QgsPoint( 1 + 1 / 3.0, 1 + 2 / 3.0 ) << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) ); QgsCompoundCurve exportCurveFloat; exportCurveFloat.addCurve( exportLineFloat.clone() ); QgsLineString exportLineStringFloat; - exportLineStringFloat.setPoints( QgsPointSequence() << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) - << QgsPoint( 3 + 1 / 3.0, 3 + 2 / 3.0 ) ); + exportLineStringFloat.setPoints( QgsPointSequence() << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) << QgsPoint( 3 + 1 / 3.0, 3 + 2 / 3.0 ) ); exportCurveFloat.addCurve( exportLineStringFloat.clone() ); QDomDocument doc( QStringLiteral( "gml" ) ); @@ -3351,9 +3123,7 @@ void TestQgsCompoundCurve::addToPainterPath() QVERIFY( pPath.isEmpty() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) - << QgsPoint( Qgis::WkbType::PointZ, 21, 2, 3 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 21, 2, 3 ) ); cc.addCurve( cs.clone() ); cc.addToPainterPath( pPath ); @@ -3362,8 +3132,7 @@ void TestQgsCompoundCurve::addToPainterPath() QVERIFY( !pPath.isEmpty() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 21, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 31, 12, 3 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 21, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 31, 12, 3 ) ); cc.addCurve( ls.clone() ); pPath = QPainterPath(); cc.addToPainterPath( pPath ); @@ -3373,8 +3142,7 @@ void TestQgsCompoundCurve::addToPainterPath() // even number of points - should still work cc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); cc.addCurve( cs.clone() ); pPath = QPainterPath(); @@ -3407,7 +3175,7 @@ void TestQgsCompoundCurve::compoundCurveCondense() QFETCH( QString, expected ); QgsGeometry g = QgsGeometry::fromWkt( curve ); - qgsgeometry_cast< QgsCompoundCurve * >( g.get() )->condenseCurves(); + qgsgeometry_cast( g.get() )->condenseCurves(); QCOMPARE( g.asWkt(), expected ); } diff --git a/tests/src/core/geometry/testqgscurvepolygon.cpp b/tests/src/core/geometry/testqgscurvepolygon.cpp index f8e9d6988dd9..a0714d5b6bc2 100644 --- a/tests/src/core/geometry/testqgscurvepolygon.cpp +++ b/tests/src/core/geometry/testqgscurvepolygon.cpp @@ -29,7 +29,7 @@ #include "testgeometryutils.h" -class TestQgsCurvePolygon: public QObject +class TestQgsCurvePolygon : public QObject { Q_OBJECT @@ -119,8 +119,7 @@ void TestQgsCurvePolygon::testConstructor() // valid exterior ring ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); QVERIFY( !poly.isEmpty() ); QCOMPARE( poly.numInteriorRings(), 0 ); @@ -140,7 +139,7 @@ void TestQgsCurvePolygon::testConstructor() QVERIFY( !poly.interiorRing( 0 ) ); // retrieve exterior ring and check - QCOMPARE( *( static_cast< const QgsCircularString * >( poly.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( poly.exteriorRing() ) ), *ext ); } void TestQgsCurvePolygon::testCopyConstructor() @@ -151,15 +150,11 @@ void TestQgsCurvePolygon::testCopyConstructor() QCOMPARE( poly1, poly2 ); QgsCircularString *ext1 = new QgsCircularString(); - ext1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); poly1.setExteriorRing( ext1 ); QgsCircularString *ring1 = new QgsCircularString(); - ring1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); poly1.addInteriorRing( ring1 ); QgsCurvePolygon poly3( poly1 ); @@ -167,14 +162,10 @@ void TestQgsCurvePolygon::testCopyConstructor() QgsCurvePolygon poly4; QgsCircularString *ext2 = new QgsCircularString(); - ext2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); poly4.setExteriorRing( ext2 ); QgsCircularString *ring2 = new QgsCircularString(); - ring2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); + ring2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); poly4.addInteriorRing( ring2 ); QVERIFY( poly4.exteriorRing() ); QCOMPARE( poly4.numInteriorRings(), 1 ); @@ -192,15 +183,11 @@ void TestQgsCurvePolygon::testClear() QgsCurvePolygon poly; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); poly.setExteriorRing( ext ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); poly.addInteriorRing( ring ); QCOMPARE( poly.numInteriorRings(), 1 ); @@ -220,19 +207,15 @@ void TestQgsCurvePolygon::testClone() { QgsCurvePolygon poly; - std::unique_ptr< QgsCurvePolygon >cloned( poly.clone() ); + std::unique_ptr cloned( poly.clone() ); QCOMPARE( poly, *cloned ); QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); poly.setExteriorRing( ext ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); poly.addInteriorRing( ring ); cloned.reset( poly.clone() ); @@ -248,30 +231,25 @@ void TestQgsCurvePolygon::testEquality() QVERIFY( !( poly1 != poly2 ) ); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly1.setExteriorRing( ext ); QVERIFY( !( poly1 == poly2 ) ); QVERIFY( poly1 != poly2 ); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly2.setExteriorRing( ext ); QVERIFY( poly1 == poly2 ); QVERIFY( !( poly1 != poly2 ) ); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 9 ) - << QgsPoint( 9, 9 ) << QgsPoint( 9, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 0 ) << QgsPoint( 0, 0 ) ); poly2.setExteriorRing( ext ); QVERIFY( !( poly1 == poly2 ) ); QVERIFY( poly1 != poly2 ); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); poly2.setExteriorRing( ext ); QVERIFY( !( poly1 == poly2 ) ); QVERIFY( poly1 != poly2 ); @@ -281,15 +259,13 @@ void TestQgsCurvePolygon::testEquality() QVERIFY( !( poly1 != poly2 ) ); ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) - << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); poly1.addInteriorRing( ring ); QVERIFY( !( poly1 == poly2 ) ); QVERIFY( poly1 != poly2 ); ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 2, 1 ) << QgsPoint( 2, 9 ) - << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 2, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 2, 1 ) << QgsPoint( 2, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 2, 1 ) ); poly2.addInteriorRing( ring ); QVERIFY( !( poly1 == poly2 ) ); QVERIFY( poly1 != poly2 ); @@ -306,15 +282,11 @@ void TestQgsCurvePolygon::testSetExteriorRing() QgsCurvePolygon poly; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); poly.setExteriorRing( ext ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); poly.addInteriorRing( ring ); QVERIFY( !poly.is3D() ); @@ -322,13 +294,11 @@ void TestQgsCurvePolygon::testSetExteriorRing() QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygon ); QCOMPARE( poly.wktTypeStr(), QString( "CurvePolygon" ) ); QCOMPARE( poly.geometryType(), QString( "CurvePolygon" ) ); - QCOMPARE( *( static_cast< const QgsCircularString * >( poly.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( poly.exteriorRing() ) ), *ext ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::CircularString ); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); poly.setExteriorRing( ext ); QVERIFY( poly.is3D() ); @@ -336,33 +306,29 @@ void TestQgsCurvePolygon::testSetExteriorRing() QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygonZ ); QCOMPARE( poly.wktTypeStr(), QString( "CurvePolygon Z" ) ); QCOMPARE( poly.geometryType(), QString( "CurvePolygon" ) ); - QCOMPARE( *( static_cast< const QgsCircularString * >( poly.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( poly.exteriorRing() ) ), *ext ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::CircularStringZ ); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); poly.setExteriorRing( ext ); QVERIFY( !poly.is3D() ); QVERIFY( poly.isMeasure() ); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygonM ); QCOMPARE( poly.wktTypeStr(), QString( "CurvePolygon M" ) ); - QCOMPARE( *( static_cast< const QgsCircularString * >( poly.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( poly.exteriorRing() ) ), *ext ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::CircularStringM ); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 5, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 5, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) ); poly.setExteriorRing( ext ); QVERIFY( poly.is3D() ); QVERIFY( poly.isMeasure() ); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygonZM ); QCOMPARE( poly.wktTypeStr(), QString( "CurvePolygon ZM" ) ); - QCOMPARE( *( static_cast< const QgsCircularString * >( poly.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( poly.exteriorRing() ) ), *ext ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::CircularStringZM ); } @@ -371,8 +337,7 @@ void TestQgsCurvePolygon::testAddInteriorRing() QgsCurvePolygon poly; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); // empty ring @@ -384,8 +349,7 @@ void TestQgsCurvePolygon::testAddInteriorRing() QCOMPARE( poly.numInteriorRings(), 0 ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); poly.addInteriorRing( ring ); QCOMPARE( poly.numInteriorRings(), 1 ); @@ -393,21 +357,12 @@ void TestQgsCurvePolygon::testAddInteriorRing() QVERIFY( !poly.interiorRing( 1 ) ); QgsCoordinateSequence seq = poly.coordinateSequence(); - QCOMPARE( seq, QgsCoordinateSequence() << ( QgsRingSequence() << ( - QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) - ) << ( - QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) - ) ) - ); + QCOMPARE( seq, QgsCoordinateSequence() << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ) << ( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ) ) ); QCOMPARE( poly.nCoordinates(), 10 ); // try adding an interior ring with z to a 2d polygon, z should be dropped ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); poly.addInteriorRing( ring ); QCOMPARE( poly.numInteriorRings(), 2 ); @@ -421,9 +376,7 @@ void TestQgsCurvePolygon::testAddInteriorRing() // try adding an interior ring with m to a 2d polygon, m should be dropped ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.2, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.1, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.2, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.1, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) ); poly.addInteriorRing( ring ); QCOMPARE( poly.numInteriorRings(), 3 ); @@ -439,9 +392,7 @@ void TestQgsCurvePolygon::testAddInteriorRing() // addInteriorRing without z/m to PolygonZM QgsCurvePolygon poly2; ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) ); poly2.setExteriorRing( ext ); QVERIFY( poly2.is3D() ); @@ -450,9 +401,7 @@ void TestQgsCurvePolygon::testAddInteriorRing() // ring has no z ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 9 ) << QgsPoint( Qgis::WkbType::PointM, 9, 9 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 1, 9 ) << QgsPoint( Qgis::WkbType::PointM, 9, 9 ) << QgsPoint( Qgis::WkbType::PointM, 9, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1, 1 ) ); poly2.addInteriorRing( ring ); QVERIFY( poly2.interiorRing( 0 ) ); @@ -463,9 +412,7 @@ void TestQgsCurvePolygon::testAddInteriorRing() // ring has no m ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); poly2.addInteriorRing( ring ); QVERIFY( poly2.interiorRing( 1 ) ); @@ -478,30 +425,23 @@ void TestQgsCurvePolygon::testAddInteriorRing() void TestQgsCurvePolygon::testRemoveInteriorRing() { QgsCurvePolygon poly; - QVector< QgsCurve * > rings; + QVector rings; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); QVERIFY( !poly.removeInteriorRing( -1 ) ); QVERIFY( !poly.removeInteriorRing( 0 ) ); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[0] )->setPoints( QgsPointSequence() - << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.1, 0.2 ) << QgsPoint( 0.2, 0.2 ) - << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.1, 0.1 ) ); + static_cast( rings[0] )->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.1, 0.2 ) << QgsPoint( 0.2, 0.2 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.1, 0.1 ) ); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[1] )->setPoints( QgsPointSequence() - << QgsPoint( 0.3, 0.3 ) << QgsPoint( 0.3, 0.4 ) << QgsPoint( 0.4, 0.4 ) - << QgsPoint( 0.4, 0.3 ) << QgsPoint( 0.3, 0.3 ) ); + static_cast( rings[1] )->setPoints( QgsPointSequence() << QgsPoint( 0.3, 0.3 ) << QgsPoint( 0.3, 0.4 ) << QgsPoint( 0.4, 0.4 ) << QgsPoint( 0.4, 0.3 ) << QgsPoint( 0.3, 0.3 ) ); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[2] )->setPoints( QgsPointSequence() - << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.8, 0.9 ) << QgsPoint( 0.9, 0.9 ) - << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.8, 0.8 ) ); + static_cast( rings[2] )->setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.8, 0.9 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.8, 0.8 ) ); poly.setInteriorRings( rings ); @@ -524,35 +464,25 @@ void TestQgsCurvePolygon::testRemoveInteriorRing() void TestQgsCurvePolygon::testMixedRingTypes() { QgsCurvePolygon poly; - QVector< QgsCurve * > rings; + QVector rings; QgsCircularString *ext = new QgsCircularString(); // set exterior rings - ext->setPoints( QgsPointSequence() - << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); // add a list of rings with mixed types rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[0] )->setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); + static_cast( rings[0] )->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[1] )->setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.3, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.4, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 0.4, 0.4, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 0.4, 0.3, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.3, 0, 1 ) ); + static_cast( rings[1] )->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.3, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.4, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.4, 0.4, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 0.4, 0.3, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.3, 0, 1 ) ); // throw an empty ring in too rings << 0; rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[3] )->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + static_cast( rings[3] )->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setInteriorRings( rings ); @@ -579,9 +509,7 @@ void TestQgsCurvePolygon::testMixedRingTypes() rings.clear(); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[0] )->setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) - << QgsPoint( 0.8, 0.9 ) << QgsPoint( 0.9, 0.9 ) - << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.8, 0.8 ) ); + static_cast( rings[0] )->setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.8, 0.9 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.8, 0.8 ) ); poly.setInteriorRings( rings ); QCOMPARE( poly.numInteriorRings(), 1 ); @@ -600,26 +528,18 @@ void TestQgsCurvePolygon::test3dRings() { // change dimensionality of interior rings using setExteriorRing QgsCurvePolygon poly; - QVector< QgsCurve * > rings; + QVector rings; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); poly.setExteriorRing( ext ); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[0] )->setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); + static_cast( rings[0] )->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[1] )->setPoints( QgsPointSequence() - << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.3, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.4, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.4, 0.4, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.4, 0.3, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.3, 1 ) ); + static_cast( rings[1] )->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.3, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.4, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.4, 0.4, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.4, 0.3, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.3, 1 ) ); poly.setInteriorRings( rings ); @@ -632,8 +552,7 @@ void TestQgsCurvePolygon::test3dRings() // reset exterior ring to 2d ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); QVERIFY( !poly.is3D() ); @@ -642,9 +561,7 @@ void TestQgsCurvePolygon::test3dRings() // reset exterior ring to LineStringM ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 0 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10 ) << QgsPoint( Qgis::WkbType::PointM, 10, 0 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) ); poly.setExteriorRing( ext ); QVERIFY( poly.isMeasure() ); @@ -656,13 +573,11 @@ void TestQgsCurvePolygon::testAreaPerimeterWithInteriorRing() { QgsCurvePolygon poly; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 6 ) << QgsPoint( 6, 6 ) - << QgsPoint( 6, 1 ) << QgsPoint( 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 6 ) << QgsPoint( 6, 6 ) << QgsPoint( 6, 1 ) << QgsPoint( 1, 1 ) ); poly.addInteriorRing( ring ); QGSCOMPARENEAR( poly.area(), 117.8104, 0.01 ); @@ -681,15 +596,14 @@ void TestQgsCurvePolygon::testInsertVertex() QVERIFY( !poly.insertVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( poly.isEmpty() ); - ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ring.clone() ); QVERIFY( poly.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 0.3, 0 ) ) ); QCOMPARE( poly.nCoordinates(), 8 ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); QVERIFY( !poly.insertVertex( QgsVertexId( 0, 0, -1 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !poly.insertVertex( QgsVertexId( 0, 0, 100 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !poly.insertVertex( QgsVertexId( 0, 1, 0 ), QgsPoint( 6.0, 7.0 ) ) ); @@ -697,22 +611,22 @@ void TestQgsCurvePolygon::testInsertVertex() // first vertex QVERIFY( poly.insertVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 0, 0.1 ) ) ); QCOMPARE( poly.nCoordinates(), 9 ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 7 ), QgsPoint( 0, 2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 7 ), QgsPoint( 0, 2 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); // last vertex QVERIFY( poly.insertVertex( QgsVertexId( 0, 0, 9 ), QgsPoint( 0.1, 0.1 ) ) ); QCOMPARE( poly.nCoordinates(), 10 ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); // with interior ring poly.addInteriorRing( ring.clone() ); @@ -720,9 +634,9 @@ void TestQgsCurvePolygon::testInsertVertex() QCOMPARE( poly.nCoordinates(), 17 ); QVERIFY( poly.insertVertex( QgsVertexId( 0, 1, 1 ), QgsPoint( 0.3, 0 ) ) ); QCOMPARE( poly.nCoordinates(), 18 ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); QVERIFY( !poly.insertVertex( QgsVertexId( 0, 1, -1 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !poly.insertVertex( QgsVertexId( 0, 1, 100 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !poly.insertVertex( QgsVertexId( 0, 2, 0 ), QgsPoint( 6.0, 7.0 ) ) ); @@ -730,22 +644,22 @@ void TestQgsCurvePolygon::testInsertVertex() // first vertex in interior ring QVERIFY( poly.insertVertex( QgsVertexId( 0, 1, 0 ), QgsPoint( 0, 0.1 ) ) ); QCOMPARE( poly.nCoordinates(), 19 ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 7 ), QgsPoint( 0, 2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 7 ), QgsPoint( 0, 2 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); // last vertex in interior ring QVERIFY( poly.insertVertex( QgsVertexId( 0, 1, 9 ), QgsPoint( 0.1, 0.1 ) ) ); QCOMPARE( poly.nCoordinates(), 20 ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); } void TestQgsCurvePolygon::testMoveVertex() @@ -757,43 +671,42 @@ void TestQgsCurvePolygon::testMoveVertex() // valid polygon QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); poly.setExteriorRing( ring.clone() ); QVERIFY( poly.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( poly.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); QVERIFY( poly.moveVertex( QgsVertexId( 0, 0, 2 ), QgsPoint( 26.0, 27.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); // move last vertex QVERIFY( poly.moveVertex( QgsVertexId( 0, 0, 3 ), QgsPoint( 1.0, 2.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); // out of range QVERIFY( !poly.moveVertex( QgsVertexId( 0, 0, -1 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !poly.moveVertex( QgsVertexId( 0, 0, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !poly.moveVertex( QgsVertexId( 0, 1, 0 ), QgsPoint( 3.0, 4.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); // with interior ring poly.addInteriorRing( ring.clone() ); QVERIFY( poly.moveVertex( QgsVertexId( 0, 1, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( poly.moveVertex( QgsVertexId( 0, 1, 1 ), QgsPoint( 16.0, 17.0 ) ) ); QVERIFY( poly.moveVertex( QgsVertexId( 0, 1, 2 ), QgsPoint( 26.0, 27.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); QVERIFY( !poly.moveVertex( QgsVertexId( 0, 1, -1 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !poly.moveVertex( QgsVertexId( 0, 1, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !poly.moveVertex( QgsVertexId( 0, 2, 0 ), QgsPoint( 3.0, 4.0 ) ) ); @@ -809,9 +722,7 @@ void TestQgsCurvePolygon::testDeleteVertex() // valid polygon QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 5, 2 ) - << QgsPoint( 6, 2 ) << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); poly.setExteriorRing( ring.clone() ); // out of range vertices @@ -821,26 +732,26 @@ void TestQgsCurvePolygon::testDeleteVertex() // valid vertices QVERIFY( poly.deleteVertex( QgsVertexId( 0, 0, 1 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); // delete first vertex QVERIFY( poly.deleteVertex( QgsVertexId( 0, 0, 0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 4 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 4 ), QgsPoint( 6.0, 2.0 ) ); // delete last vertex QVERIFY( poly.deleteVertex( QgsVertexId( 0, 0, 4 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); // delete another vertex - should remove ring QVERIFY( poly.deleteVertex( QgsVertexId( 0, 0, 1 ) ) ); @@ -857,26 +768,26 @@ void TestQgsCurvePolygon::testDeleteVertex() // valid vertices QVERIFY( poly.deleteVertex( QgsVertexId( 0, 1, 1 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); // delete first vertex QVERIFY( poly.deleteVertex( QgsVertexId( 0, 1, 0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 4 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 4 ), QgsPoint( 6.0, 2.0 ) ); // delete last vertex QVERIFY( poly.deleteVertex( QgsVertexId( 0, 1, 4 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); // delete another vertex - should remove ring QVERIFY( poly.deleteVertex( QgsVertexId( 0, 1, 1 ) ) ); @@ -904,7 +815,7 @@ void TestQgsCurvePolygon::testNextVertex() QgsPoint pt; QgsVertexId v; - ( void )empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty curve, just want no crash + ( void ) empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty curve, just want no crash // nextVertex QgsCurvePolygon curvePoly; @@ -917,8 +828,7 @@ void TestQgsCurvePolygon::testNextVertex() QVERIFY( !curvePoly.nextVertex( v, pt ) ); QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); curvePoly.setExteriorRing( ring.clone() ); v = QgsVertexId( 0, 0, 4 ); // out of range @@ -950,8 +860,7 @@ void TestQgsCurvePolygon::testNextVertex() QCOMPARE( pt, QgsPoint( 11, 12 ) ); // add interior ring - ring.setPoints( QgsPointSequence() << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) - << QgsPoint( 11, 22 ) << QgsPoint( 11, 12 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 11, 22 ) << QgsPoint( 11, 12 ) ); curvePoly.addInteriorRing( ring.clone() ); v = QgsVertexId( 0, 1, 4 ); // out of range @@ -988,14 +897,12 @@ void TestQgsCurvePolygon::testVertexAngle() QgsCurvePolygon poly; // just want no crash - ( void )poly.vertexAngle( QgsVertexId() ); - ( void )poly.vertexAngle( QgsVertexId( 0, 0, 0 ) ); - ( void )poly.vertexAngle( QgsVertexId( 0, 1, 0 ) ); + ( void ) poly.vertexAngle( QgsVertexId() ); + ( void ) poly.vertexAngle( QgsVertexId( 0, 0, 0 ) ); + ( void ) poly.vertexAngle( QgsVertexId( 0, 1, 0 ) ); QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) - << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ring.clone() ); QGSCOMPARENEAR( poly.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 2.35619, 0.00001 ); @@ -1022,8 +929,7 @@ void TestQgsCurvePolygon::testDeleteVertexRemoveRing() QgsCurvePolygon poly; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); QVERIFY( poly.exteriorRing() ); @@ -1037,14 +943,12 @@ void TestQgsCurvePolygon::testHasCurvedSegments() QVERIFY( !poly.hasCurvedSegments() ); QgsLineString linePoly; - linePoly.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + linePoly.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); poly.setExteriorRing( linePoly.clone() ); QVERIFY( !poly.hasCurvedSegments() ); QgsCircularString circularString; - circularString.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + circularString.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); poly.addInteriorRing( circularString.clone() ); QVERIFY( poly.hasCurvedSegments() ); } @@ -1058,12 +962,11 @@ void TestQgsCurvePolygon::testClosestSegment() QgsPoint pt; QgsVertexId v; int leftOf = 0; - ( void )empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty curve, just want no crash + ( void ) empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty curve, just want no crash QgsCurvePolygon poly; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 7, 12 ) - << QgsPoint( 5, 15 ) << QgsPoint( 5, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) << QgsPoint( 5, 10 ) ); poly.setExteriorRing( ring.clone() ); QGSCOMPARENEAR( poly.closestSegment( QgsPoint( 4, 11 ), pt, v, &leftOf ), 1.0, 0.0001 ); @@ -1072,7 +975,7 @@ void TestQgsCurvePolygon::testClosestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( poly.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( poly.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -1112,7 +1015,7 @@ void TestQgsCurvePolygon::testClosestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( poly.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( poly.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -1146,14 +1049,13 @@ void TestQgsCurvePolygon::testClosestSegment() void TestQgsCurvePolygon::testBoundary() { QgsCircularString extBoundary; - extBoundary.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) - << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); + extBoundary.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); QgsCurvePolygon poly; QVERIFY( !poly.boundary() ); poly.setExteriorRing( extBoundary.clone() ); QgsAbstractGeometry *boundary = poly.boundary(); - QgsCircularString *lineBoundary = dynamic_cast< QgsCircularString * >( boundary ); + QgsCircularString *lineBoundary = dynamic_cast( boundary ); QVERIFY( lineBoundary ); QCOMPARE( lineBoundary->numPoints(), 5 ); QCOMPARE( lineBoundary->xAt( 0 ), 0.0 ); @@ -1169,54 +1071,50 @@ void TestQgsCurvePolygon::testBoundary() delete boundary; QgsCircularString boundaryRing1; - boundaryRing1.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) - << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) ); + boundaryRing1.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) ); QgsCircularString boundaryRing2; - boundaryRing2.setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) - << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) ); + boundaryRing2.setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) ); - poly.setInteriorRings( QVector< QgsCurve * >() << boundaryRing1.clone() << boundaryRing2.clone() ); + poly.setInteriorRings( QVector() << boundaryRing1.clone() << boundaryRing2.clone() ); boundary = poly.boundary(); - QgsMultiCurve *multiLineBoundary = dynamic_cast< QgsMultiCurve * >( boundary ); + QgsMultiCurve *multiLineBoundary = dynamic_cast( boundary ); QVERIFY( multiLineBoundary ); QCOMPARE( multiLineBoundary->numGeometries(), 3 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->numPoints(), 5 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 0 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 1 ), 1.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 2 ), 2.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 3 ), 1.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 4 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 0 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 1 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 2 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 3 ), 0.5 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 4 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 1 ) )->numPoints(), 3 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 1 ) )->xAt( 0 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 1 ) )->xAt( 1 ), 0.2 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 1 ) )->xAt( 2 ), 0.2 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 1 ) )->yAt( 0 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 1 ) )->yAt( 1 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 1 ) )->yAt( 2 ), 0.2 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 2 ) )->numPoints(), 3 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 2 ) )->xAt( 0 ), 0.8 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 2 ) )->xAt( 1 ), 0.9 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 2 ) )->xAt( 2 ), 0.9 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 2 ) )->yAt( 0 ), 0.8 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 2 ) )->yAt( 1 ), 0.8 ); - QCOMPARE( qgis::down_cast< QgsCircularString * >( multiLineBoundary->geometryN( 2 ) )->yAt( 2 ), 0.9 ); - poly.setInteriorRings( QVector< QgsCurve * >() ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->numPoints(), 5 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 0 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 1 ), 1.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 2 ), 2.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 3 ), 1.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 4 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 0 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 1 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 2 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 3 ), 0.5 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 4 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->numPoints(), 3 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->xAt( 0 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->xAt( 1 ), 0.2 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->xAt( 2 ), 0.2 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->yAt( 0 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->yAt( 1 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->yAt( 2 ), 0.2 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->numPoints(), 3 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->xAt( 0 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->xAt( 1 ), 0.9 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->xAt( 2 ), 0.9 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->yAt( 0 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->yAt( 1 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->yAt( 2 ), 0.9 ); + poly.setInteriorRings( QVector() ); // test boundary with z - extBoundary.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); + extBoundary.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); poly.setExteriorRing( extBoundary.clone() ); boundary = poly.boundary(); - lineBoundary = dynamic_cast< QgsCircularString * >( boundary ); + lineBoundary = dynamic_cast( boundary ); QVERIFY( lineBoundary ); QCOMPARE( lineBoundary->numPoints(), 3 ); QCOMPARE( lineBoundary->wkbType(), Qgis::WkbType::CircularStringZ ); @@ -1227,8 +1125,7 @@ void TestQgsCurvePolygon::testBoundary() // remove interior rings QgsCircularString removeRingsExt; - removeRingsExt.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + removeRingsExt.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); QgsCurvePolygon removeRings1; removeRings1.removeInteriorRings(); @@ -1238,14 +1135,10 @@ void TestQgsCurvePolygon::testBoundary() // add interior rings QgsCircularString removeRingsRing1; - removeRingsRing1.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) - << QgsPoint( 0.1, 1, 2 ) << QgsPoint( 0, 2, 3 ) - << QgsPoint( -0.1, 1.2, 4 ) << QgsPoint( 0, 0, 1 ) ); + removeRingsRing1.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 1, 2 ) << QgsPoint( 0, 2, 3 ) << QgsPoint( -0.1, 1.2, 4 ) << QgsPoint( 0, 0, 1 ) ); QgsCircularString removeRingsRing2; - removeRingsRing2.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) - << QgsPoint( 0.01, 0.1, 2 ) << QgsPoint( 0, 0.2, 3 ) - << QgsPoint( -0.01, 0.12, 4 ) << QgsPoint( 0, 0, 1 ) ); - removeRings1.setInteriorRings( QVector< QgsCurve * >() << removeRingsRing1.clone() << removeRingsRing2.clone() ); + removeRingsRing2.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.01, 0.1, 2 ) << QgsPoint( 0, 0.2, 3 ) << QgsPoint( -0.01, 0.12, 4 ) << QgsPoint( 0, 0, 1 ) ); + removeRings1.setInteriorRings( QVector() << removeRingsRing1.clone() << removeRingsRing2.clone() ); // remove ring with size filter removeRings1.removeInteriorRings( 0.05 ); @@ -1262,8 +1155,7 @@ void TestQgsCurvePolygon::testBoundingBox() QgsRectangle bBox = poly.boundingBox(); // no crash! QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) - << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); poly.setExteriorRing( ext ); bBox = poly.boundingBox(); @@ -1279,8 +1171,7 @@ void TestQgsCurvePolygon::testBoundingBox3D() QgsBox3D bBox = poly.boundingBox3D(); QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) - << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); poly.setExteriorRing( ext ); bBox = poly.boundingBox3D(); @@ -1298,9 +1189,8 @@ void TestQgsCurvePolygon::testBoundingBoxIntersects() QgsCurvePolygon poly1; QVERIFY( !poly1.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); - std::unique_ptr< QgsCircularString > ext1( new QgsCircularString() ); - ext1->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) - << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); + std::unique_ptr ext1( new QgsCircularString() ); + ext1->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); poly1.setExteriorRing( ext1.release() ); QVERIFY( poly1.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); @@ -1310,9 +1200,8 @@ void TestQgsCurvePolygon::testBoundingBoxIntersects() QgsCurvePolygon poly2; QVERIFY( !poly2.boundingBoxIntersects( QgsBox3D( 1, 3, 1, 6, 9, 2 ) ) ); - std::unique_ptr< QgsCircularString > ext2( new QgsCircularString() ); - ext2->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) - << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); + std::unique_ptr ext2( new QgsCircularString() ); + ext2->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) << QgsPoint( 0, 18, 3 ) << QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) ); poly2.setExteriorRing( ext2.release() ); QVERIFY( poly2.boundingBoxIntersects( QgsBox3D( 1, 3, 1, 6, 9, 2 ) ) ); @@ -1327,17 +1216,14 @@ void TestQgsCurvePolygon::testRoundness() QCOMPARE( poly.roundness(), 0 ); QgsCircularString ext; - ext.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) - << QgsPoint( 1, 1 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); + ext.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) << QgsPoint( 1, 1 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext.clone() ); QCOMPARE( poly.roundness(), 1.0 ); //with Z QgsLineString extLine; - extLine.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 5 ) - << QgsPoint( 0, 0.01, 4 ) << QgsPoint( 1, 0.01, 2 ) - << QgsPoint( 1, 0, 10 ) << QgsPoint( 0, 0, 5 ) ); + extLine.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 5 ) << QgsPoint( 0, 0.01, 4 ) << QgsPoint( 1, 0.01, 2 ) << QgsPoint( 1, 0, 10 ) << QgsPoint( 0, 0, 5 ) ); poly.setExteriorRing( extLine.clone() ); QGSCOMPARENEAR( poly.roundness(), 0.031, 0.001 ); @@ -1352,8 +1238,7 @@ void TestQgsCurvePolygon::testDropZValue() poly.dropZValue(); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygon ); - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); poly.setExteriorRing( ring.clone() ); poly.addInteriorRing( ring.clone() ); @@ -1362,13 +1247,12 @@ void TestQgsCurvePolygon::testDropZValue() poly.dropZValue(); // not z QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygon ); QCOMPARE( poly.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with z - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 11, 12, 13 ) - << QgsPoint( 1, 12, 23 ) << QgsPoint( 1, 2, 3 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 11, 12, 13 ) << QgsPoint( 1, 12, 23 ) << QgsPoint( 1, 2, 3 ) ); poly.clear(); poly.setExteriorRing( ring.clone() ); poly.addInteriorRing( ring.clone() ); @@ -1378,13 +1262,12 @@ void TestQgsCurvePolygon::testDropZValue() poly.dropZValue(); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygon ); QCOMPARE( poly.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) - << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); poly.clear(); poly.setExteriorRing( ring.clone() ); poly.addInteriorRing( ring.clone() ); @@ -1394,9 +1277,9 @@ void TestQgsCurvePolygon::testDropZValue() poly.dropZValue(); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygonM ); QCOMPARE( poly.exteriorRing()->wkbType(), Qgis::WkbType::LineStringM ); - QCOMPARE( static_cast< const QgsLineString *>( poly.exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineStringM ); - QCOMPARE( static_cast< const QgsLineString *>( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); } void TestQgsCurvePolygon::testDropMValue() @@ -1408,8 +1291,7 @@ void TestQgsCurvePolygon::testDropMValue() poly.dropMValue(); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygon ); - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); poly.setExteriorRing( ring.clone() ); poly.addInteriorRing( ring.clone() ); @@ -1418,15 +1300,12 @@ void TestQgsCurvePolygon::testDropMValue() poly.dropMValue(); // not zm QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygon ); QCOMPARE( poly.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with m - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); poly.clear(); poly.setExteriorRing( ring.clone() ); poly.addInteriorRing( ring.clone() ); @@ -1436,13 +1315,12 @@ void TestQgsCurvePolygon::testDropMValue() poly.dropMValue(); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygon ); QCOMPARE( poly.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) - << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); poly.clear(); poly.setExteriorRing( ring.clone() ); poly.addInteriorRing( ring.clone() ); @@ -1452,9 +1330,9 @@ void TestQgsCurvePolygon::testDropMValue() poly.dropMValue(); QCOMPARE( poly.wkbType(), Qgis::WkbType::CurvePolygonZ ); QCOMPARE( poly.exteriorRing()->wkbType(), Qgis::WkbType::LineStringZ ); - QCOMPARE( static_cast< const QgsLineString *>( poly.exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( poly.exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); QCOMPARE( poly.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineStringZ ); - QCOMPARE( static_cast< const QgsLineString *>( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( poly.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); } void TestQgsCurvePolygon::testToPolygon() @@ -1462,13 +1340,11 @@ void TestQgsCurvePolygon::testToPolygon() QgsCurvePolygon poly = QgsCurvePolygon(); QCOMPARE( *poly.toPolygon(), QgsPolygon() ); - std::unique_ptr< QgsPolygon > surface( poly.surfaceToPolygon() ); + std::unique_ptr surface( poly.surfaceToPolygon() ); QVERIFY( surface->isEmpty() ); QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 10 ) << QgsPoint( 0, 18 ) - << QgsPoint( -1, 4 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 10 ) << QgsPoint( 0, 18 ) << QgsPoint( -1, 4 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ext ); surface.reset( poly.toPolygon() ); @@ -1486,9 +1362,7 @@ void TestQgsCurvePolygon::testToPolygon() QGSCOMPARENEAR( r1.yMaximum(), r2.yMaximum(), 0.01 ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); poly.addInteriorRing( ring ); surface.reset( poly.toPolygon() ); @@ -1508,7 +1382,7 @@ void TestQgsCurvePolygon::testToPolygon() QGSCOMPARENEAR( r1.yMaximum(), r2.yMaximum(), 0.0001 ); // should be identical since it's already a curve - std::unique_ptr< QgsCurvePolygon > curveType( poly.toCurveType() ); + std::unique_ptr curveType( poly.toCurveType() ); QCOMPARE( *curveType, poly ); } @@ -1516,12 +1390,11 @@ void TestQgsCurvePolygon::testSurfaceToPolygon() { QgsCurvePolygon poly; - std::unique_ptr< QgsPolygon > surface( poly.surfaceToPolygon() ); + std::unique_ptr surface( poly.surfaceToPolygon() ); QVERIFY( surface->isEmpty() ); QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 3 ) - << QgsPoint( 2, 4 ) << QgsPoint( -1, 5 ) << QgsPoint( 0, 6 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 3 ) << QgsPoint( 2, 4 ) << QgsPoint( -1, 5 ) << QgsPoint( 0, 6 ) ); poly.setExteriorRing( ext ); surface.reset( poly.surfaceToPolygon() ); @@ -1540,9 +1413,7 @@ void TestQgsCurvePolygon::testSurfaceToPolygon() QGSCOMPARENEAR( r1.yMaximum(), r2.yMaximum(), 0.0001 ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); poly.addInteriorRing( ring ); surface.reset( poly.surfaceToPolygon() ); @@ -1570,13 +1441,11 @@ void TestQgsCurvePolygon::testWKB() QgsCircularString *ring; ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); poly1.setExteriorRing( ext ); ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.1, 0 ) - << QgsPoint( 0.2, 0 ) << QgsPoint( 0.1, 0.05 ) << QgsPoint( 0, 0 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.1, 0 ) << QgsPoint( 0.2, 0 ) << QgsPoint( 0.1, 0.05 ) << QgsPoint( 0, 0 ) ); poly1.addInteriorRing( ring ); QByteArray wkb16 = poly1.asWkb(); @@ -1591,13 +1460,11 @@ void TestQgsCurvePolygon::testWKB() // CurvePolygonZ ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) - << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); poly1.setExteriorRing( ext ); ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 0, 2 ) - << QgsPoint( 0.2, 0, 3 ) << QgsPoint( 0.1, 0.05, 4 ) << QgsPoint( 0, 0, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 0, 2 ) << QgsPoint( 0.2, 0, 3 ) << QgsPoint( 0.1, 0.05, 4 ) << QgsPoint( 0, 0, 1 ) ); poly1.addInteriorRing( ring ); wkb16 = poly1.asWkb(); @@ -1608,8 +1475,7 @@ void TestQgsCurvePolygon::testWKB() // compound curve QgsCompoundCurve *cCurve = new QgsCompoundCurve(); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) - << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); cCurve->addCurve( ext ); poly1.addInteriorRing( cCurve ); @@ -1625,15 +1491,11 @@ void TestQgsCurvePolygon::testWKB() // CurvePolygonM ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 2, 0, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 0.5, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 2, 0, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 1, 0.5, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); poly1.setExteriorRing( ext ); ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.05, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.05, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); poly1.addInteriorRing( ring ); wkb16 = poly1.asWkb(); @@ -1648,15 +1510,11 @@ void TestQgsCurvePolygon::testWKB() poly1.clear(); poly2.clear(); ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); poly1.setExteriorRing( ext ); ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); poly1.addInteriorRing( ring ); wkb16 = poly1.asWkb(); @@ -1669,13 +1527,11 @@ void TestQgsCurvePolygon::testWKB() // With LineString ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); poly1.setExteriorRing( ext ); QgsLineString *lineRing = new QgsLineString(); - lineRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.1, 0 ) - << QgsPoint( 0.2, 0 ) << QgsPoint( 0.1, 0.05 ) << QgsPoint( 0, 0 ) ); + lineRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.1, 0 ) << QgsPoint( 0.2, 0 ) << QgsPoint( 0.1, 0.05 ) << QgsPoint( 0, 0 ) ); poly1.addInteriorRing( lineRing ); wkb16 = poly1.asWkb(); @@ -1705,15 +1561,11 @@ void TestQgsCurvePolygon::testWKT() { QgsCurvePolygon poly1; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); poly1.setExteriorRing( ext ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); poly1.addInteriorRing( ring ); QString wkt = poly1.asWkt(); @@ -1735,9 +1587,7 @@ void TestQgsCurvePolygon::testWKT() // Test WKT export with empty interior ring QgsCurvePolygon poly3; QgsCircularString *ext2 = new QgsCircularString(); - ext2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ext2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); poly3.setExteriorRing( ext2 ); poly3.addInteriorRing( new QgsCircularString() ); wkt = poly3.asWkt(); @@ -1748,9 +1598,7 @@ void TestQgsCurvePolygon::testExport() { QgsCurvePolygon exportPolygon; QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); exportPolygon.setExteriorRing( ext ); // GML document for compare @@ -1778,9 +1626,7 @@ void TestQgsCurvePolygon::testExport() QCOMPARE( res, expectedSimpleJson ); QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); exportPolygon.addInteriorRing( ring ); // as JSON @@ -1794,15 +1640,11 @@ void TestQgsCurvePolygon::testExport() QgsCurvePolygon exportPolygonFloat; ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 1 / 3.0, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2 / 3.0, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1 / 3.0, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 1 / 3.0, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2 / 3.0, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1 / 3.0, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); exportPolygonFloat.setExteriorRing( ext ); ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1 / 3.0, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2 / 3.0, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1 / 3.0, 0.05 / 3.0, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1 / 3.0, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2 / 3.0, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1 / 3.0, 0.05 / 3.0, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); exportPolygonFloat.addInteriorRing( ring ); // as JSON @@ -1861,7 +1703,7 @@ void TestQgsCurvePolygon::testCast() QVERIFY( !pCast2.fromWkt( QStringLiteral( "CurvePolygonZ((111111))" ) ) ); } -void TestQgsCurvePolygon::removeInteriorRings_github_issue_49578() // https://github.com/qgis/QGIS/issues/49578 +void TestQgsCurvePolygon::removeInteriorRings_github_issue_49578() // https://github.com/qgis/QGIS/issues/49578 { // This test creates a polygon very similar to the polygon in the example geopackage attached in github issue #49578 // The test creates one polygon with four holes (interior rings). @@ -1889,8 +1731,7 @@ void TestQgsCurvePolygon::removeInteriorRings_github_issue_49578() // https:// // The function returns the area for the square. // Note that it is important (i.e. relevant for the bug in github issue #49578) that some (e.g. every second) // of the squares are defining the points in clockwise direction. - auto setUpLineStringAsSquare = []( QgsLineString & square, int lower_xy, int upper_xy, bool use_clockwise_direction ) -> int - { + auto setUpLineStringAsSquare = []( QgsLineString &square, int lower_xy, int upper_xy, bool use_clockwise_direction ) -> int { square.setPoints( QgsPointSequence() << QgsPoint( lower_xy, lower_xy ) @@ -1908,33 +1749,32 @@ void TestQgsCurvePolygon::removeInteriorRings_github_issue_49578() // https:// // the square to be used as exteriorRing: const int area_400 = setUpLineStringAsSquare( square_20x20_with_area_400, 0, 20, false ); // the four squares to be used as interiorRings: - const int area_4 = setUpLineStringAsSquare( square_2x2_with_area_4, 1, 3, false ); - const int area_9 = setUpLineStringAsSquare( square_3x3_with_area_9, 4, 7, true ); + const int area_4 = setUpLineStringAsSquare( square_2x2_with_area_4, 1, 3, false ); + const int area_9 = setUpLineStringAsSquare( square_3x3_with_area_9, 4, 7, true ); const int area_16 = setUpLineStringAsSquare( square_4x4_with_area_16, 8, 12, false ); const int area_36 = setUpLineStringAsSquare( square_6x6_with_area_36, 13, 19, true ); // as mentioned further above, every second interiorRings are defined in clockwise direction (and this is indeed relevant for the reported github issue #49578) - QCOMPARE( square_2x2_with_area_4.orientation(), Qgis::AngularDirection::CounterClockwise ); - QCOMPARE( square_3x3_with_area_9.orientation(), Qgis::AngularDirection::Clockwise ); // "negative area" - QCOMPARE( square_4x4_with_area_16.orientation(), Qgis::AngularDirection::CounterClockwise ); - QCOMPARE( square_6x6_with_area_36.orientation(), Qgis::AngularDirection::Clockwise ); // "negative area" + QCOMPARE( square_2x2_with_area_4.orientation(), Qgis::AngularDirection::CounterClockwise ); + QCOMPARE( square_3x3_with_area_9.orientation(), Qgis::AngularDirection::Clockwise ); // "negative area" + QCOMPARE( square_4x4_with_area_16.orientation(), Qgis::AngularDirection::CounterClockwise ); + QCOMPARE( square_6x6_with_area_36.orientation(), Qgis::AngularDirection::Clockwise ); // "negative area" // This test method is not intended for testing the method 'QgsLineString::sumUpArea' but is // using it below for one of the linestrings just to illustrate that the method can produce a negative value // (since it is relevant for the github issue #49578, i.e. the negative value caused problems when the absolute value was not used for the area) double area = 0.0; square_6x6_with_area_36.sumUpArea( area ); - QCOMPARE( area, -36 ); // negative since the sequence was defined in clockwise direction + QCOMPARE( area, -36 ); // negative since the sequence was defined in clockwise direction QgsPolygon polygon; polygon.setExteriorRing( square_20x20_with_area_400.clone() ); // This lambda function will be used just to avoid duplication of the code in the function - auto setInteriorRingsForPolygon = [&]() - { + auto setInteriorRingsForPolygon = [&]() { polygon.setInteriorRings( - QVector< QgsCurve * >() + QVector() << square_2x2_with_area_4.clone() << square_3x3_with_area_9.clone() << square_4x4_with_area_16.clone() diff --git a/tests/src/core/geometry/testqgsellipse.cpp b/tests/src/core/geometry/testqgsellipse.cpp index 2422068a6a74..db58860b284e 100644 --- a/tests/src/core/geometry/testqgsellipse.cpp +++ b/tests/src/core/geometry/testqgsellipse.cpp @@ -22,7 +22,7 @@ #include "testgeometryutils.h" -class TestQgsEllipse: public QObject +class TestQgsEllipse : public QObject { Q_OBJECT private slots: @@ -103,13 +103,11 @@ void TestQgsEllipse::fromCenter2Points() { QgsEllipse elp = QgsEllipse( QgsPoint( 2.5, 5 ), 2.5, 5 ); - QVERIFY( QgsEllipse::fromCenter2Points( QgsPoint( 2.5, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ) ) - == QgsEllipse( QgsPoint( 2.5, 5 ), 5, 5, 180 ) ); + QVERIFY( QgsEllipse::fromCenter2Points( QgsPoint( 2.5, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 7.5, 5 ) ) == QgsEllipse( QgsPoint( 2.5, 5 ), 5, 5, 180 ) ); QVERIFY( QgsEllipse::fromCenter2Points( QgsPoint( 2.5, 5 ), QgsPoint( 2.5, 7.5 ), QgsPoint( 7.5, 5 ) ) != elp ); //same ellipse with different azimuth QVERIFY( QgsEllipse::fromCenter2Points( QgsPoint( 2.5, 5 ), QgsPoint( 2.5, 2.5 ), QgsPoint( 7.5, 5 ) ) != elp ); //same ellipse with different azimuth QVERIFY( QgsEllipse::fromCenter2Points( QgsPoint( 2.5, 5 ), QgsPoint( 2.5, 0 ), QgsPoint( 5, 5 ) ) == elp ); - QVERIFY( QgsEllipse::fromCenter2Points( QgsPoint( 5, 10 ), QgsPoint( 5, 10 ).project( 3, 45 ), QgsPoint( 5, 10 ).project( 2, 90 + 45 ) ) - == QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ) ); + QVERIFY( QgsEllipse::fromCenter2Points( QgsPoint( 5, 10 ), QgsPoint( 5, 10 ).project( 3, 45 ), QgsPoint( 5, 10 ).project( 2, 90 + 45 ) ) == QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ) ); } void TestQgsEllipse::fromFoci() @@ -200,16 +198,11 @@ void TestQgsEllipse::settersGetters() void TestQgsEllipse::equality() { - QVERIFY( !( QgsEllipse() - == QgsEllipse( QgsPoint( 0, 0 ), 0, 0, 0.0005 ) ) ); - QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 3, 2 ) - == QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 0 ) ); - QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 3, 2 ) - != QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ) ); - QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ) - != QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 45 ) ); - QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 45 ) - == QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 90 + 45 ) ); + QVERIFY( !( QgsEllipse() == QgsEllipse( QgsPoint( 0, 0 ), 0, 0, 0.0005 ) ) ); + QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 3, 2 ) == QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 0 ) ); + QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 3, 2 ) != QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ) ); + QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ) != QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 45 ) ); + QVERIFY( QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 45 ) == QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 90 + 45 ) ); } void TestQgsEllipse::points() @@ -280,7 +273,7 @@ void TestQgsEllipse::area() void TestQgsEllipse::perimeter() { - std::unique_ptr< QgsPolygon > poly( QgsEllipse( QgsPoint( 0, 0 ), 5, 2, 45 ).toPolygon( 10000 ) ); + std::unique_ptr poly( QgsEllipse( QgsPoint( 0, 0 ), 5, 2, 45 ).toPolygon( 10000 ) ); QGSCOMPARENEAR( QgsEllipse( QgsPoint( 0, 0 ), 5, 2, 45 ).perimeter(), poly->perimeter(), 0.001 ); } @@ -309,44 +302,36 @@ void TestQgsEllipse::boundingBox() { QCOMPARE( QgsEllipse().boundingBox(), QgsRectangle() ); - std::unique_ptr< QgsPolygon > poly( QgsEllipse( QgsPoint( 0, 0 ), 5, 2 ).orientedBoundingBox() ); + std::unique_ptr poly( QgsEllipse( QgsPoint( 0, 0 ), 5, 2 ).orientedBoundingBox() ); QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 5, 2 ).boundingBox(), poly->boundingBox() ); - QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 5, 5 ).boundingBox(), - QgsRectangle( QgsPointXY( -5, -5 ), QgsPointXY( 5, 5 ) ) ); + QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 5, 5 ).boundingBox(), QgsRectangle( QgsPointXY( -5, -5 ), QgsPointXY( 5, 5 ) ) ); - QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 5, 5, 60 ).boundingBox(), - QgsRectangle( QgsPointXY( -5, -5 ), QgsPointXY( 5, 5 ) ) ); + QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 5, 5, 60 ).boundingBox(), QgsRectangle( QgsPointXY( -5, -5 ), QgsPointXY( 5, 5 ) ) ); - QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 45 ).boundingBox().toString( 4 ).toStdString(), - QgsRectangle( QgsPointXY( -11.1803, -11.1803 ), QgsPointXY( 11.1803, 11.1803 ) ).toString( 4 ).toStdString() ); + QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 45 ).boundingBox().toString( 4 ).toStdString(), QgsRectangle( QgsPointXY( -11.1803, -11.1803 ), QgsPointXY( 11.1803, 11.1803 ) ).toString( 4 ).toStdString() ); - QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 60 ).boundingBox().toString( 4 ).toStdString(), - QgsRectangle( QgsPointXY( -12.12436, -10.14889 ), QgsPointXY( 12.12436, 10.14889 ) ).toString( 4 ).toStdString() ); + QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 60 ).boundingBox().toString( 4 ).toStdString(), QgsRectangle( QgsPointXY( -12.12436, -10.14889 ), QgsPointXY( 12.12436, 10.14889 ) ).toString( 4 ).toStdString() ); - QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 60 + 90 ).boundingBox().toString( 4 ).toStdString(), - QgsRectangle( QgsPointXY( -10.14889, -12.12436 ), QgsPointXY( 10.14889, 12.12436 ) ).toString( 4 ).toStdString() ); + QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 60 + 90 ).boundingBox().toString( 4 ).toStdString(), QgsRectangle( QgsPointXY( -10.14889, -12.12436 ), QgsPointXY( 10.14889, 12.12436 ) ).toString( 4 ).toStdString() ); - QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 300 ).boundingBox().toString( 4 ).toStdString(), - QgsRectangle( QgsPointXY( -12.12436, -10.14889 ), QgsPointXY( 12.12436, 10.14889 ) ).toString( 4 ).toStdString() ); + QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 300 ).boundingBox().toString( 4 ).toStdString(), QgsRectangle( QgsPointXY( -12.12436, -10.14889 ), QgsPointXY( 12.12436, 10.14889 ) ).toString( 4 ).toStdString() ); - QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 300 - 90 ).boundingBox().toString( 4 ).toStdString(), - QgsRectangle( QgsPointXY( -10.14889, -12.12436 ), QgsPointXY( 10.14889, 12.12436 ) ).toString( 4 ).toStdString() ); + QCOMPARE( QgsEllipse( QgsPoint( 0, 0 ), 13, 9, 300 - 90 ).boundingBox().toString( 4 ).toStdString(), QgsRectangle( QgsPointXY( -10.14889, -12.12436 ), QgsPointXY( 10.14889, 12.12436 ) ).toString( 4 ).toStdString() ); } void TestQgsEllipse::orientedBoundingBox() { - std::unique_ptr< QgsPolygon > poly1( QgsEllipse().orientedBoundingBox() ); + std::unique_ptr poly1( QgsEllipse().orientedBoundingBox() ); QVERIFY( poly1->isEmpty() ); QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 5, 2 ) << QgsPoint( 5, -2 ) - << QgsPoint( -5, -2 ) << QgsPoint( -5, 2 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 5, 2 ) << QgsPoint( 5, -2 ) << QgsPoint( -5, -2 ) << QgsPoint( -5, 2 ) ); poly1.reset( new QgsPolygon() ); poly1->setExteriorRing( ext ); QgsEllipse elp( QgsPoint( 0, 0 ), 5, 2 ); - std::unique_ptr< QgsPolygon > poly2( elp.orientedBoundingBox() ); + std::unique_ptr poly2( elp.orientedBoundingBox() ); QCOMPARE( poly1->asWkt( 2 ), poly2->asWkt( 2 ) ); @@ -369,19 +354,15 @@ void TestQgsEllipse::orientedBoundingBox() void TestQgsEllipse::toString() { - QCOMPARE( QgsEllipse().toString(), - QString( "Empty" ) ); - QCOMPARE( QgsEllipse( QgsPoint( 5, 10 ), 3, 2 ).toString(), - QString( "Ellipse (Center: Point (5 10), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 90)" ) ); - QCOMPARE( QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ).toString(), - QString( "Ellipse (Center: Point (5 10), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 45)" ) ); - QCOMPARE( QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 45 ).toString(), - QString( "Ellipse (Center: Point (5 10), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 135)" ) ); + QCOMPARE( QgsEllipse().toString(), QString( "Empty" ) ); + QCOMPARE( QgsEllipse( QgsPoint( 5, 10 ), 3, 2 ).toString(), QString( "Ellipse (Center: Point (5 10), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 90)" ) ); + QCOMPARE( QgsEllipse( QgsPoint( 5, 10 ), 3, 2, 45 ).toString(), QString( "Ellipse (Center: Point (5 10), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 45)" ) ); + QCOMPARE( QgsEllipse( QgsPoint( 5, 10 ), 2, 3, 45 ).toString(), QString( "Ellipse (Center: Point (5 10), Semi-Major Axis: 3, Semi-Minor Axis: 2, Azimuth: 135)" ) ); } void TestQgsEllipse::toLineString() { - std::unique_ptr< QgsLineString > ls( new QgsLineString() ); + std::unique_ptr ls( new QgsLineString() ); ls.reset( QgsEllipse( QgsPoint( 0, 0 ), 5, 2, 0 ).toLineString( 2 ) ); QVERIFY( ls->isEmpty() ); // segments too low @@ -398,7 +379,7 @@ void TestQgsEllipse::toLineString() void TestQgsEllipse::toPolygon() { - std::unique_ptr< QgsPolygon > poly( new QgsPolygon() ); + std::unique_ptr poly( new QgsPolygon() ); poly.reset( QgsEllipse( QgsPoint( 0, 0 ), 5, 2, 0 ).toPolygon( 2 ) ); QVERIFY( poly->isEmpty() ); // segments too low diff --git a/tests/src/core/geometry/testqgsgeometry.cpp b/tests/src/core/geometry/testqgsgeometry.cpp index 74c069015528..01fe9edee1fe 100644 --- a/tests/src/core/geometry/testqgsgeometry.cpp +++ b/tests/src/core/geometry/testqgsgeometry.cpp @@ -70,9 +70,9 @@ class TestQgsGeometry : public QgsTest } private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void cleanup(); // will be called after every testfunction. void copy(); void assignment(); void asVariant(); //test conversion to and from a QVariant @@ -159,10 +159,10 @@ class TestQgsGeometry : public QgsTest void reshapeGeometryLineMerge(); void createCollectionOfType(); - void orientedMinimumBoundingBox( ); + void orientedMinimumBoundingBox(); void boundingBox(); void boundingBox3D(); - void minimalEnclosingCircle( ); + void minimalEnclosingCircle(); void splitGeometry(); void snappedToGrid(); @@ -199,7 +199,7 @@ class TestQgsGeometry : public QgsTest QString bytes2hex( const unsigned char *bytes, int size ) { - QByteArray ba( ( const char * )bytes, size ); + QByteArray ba( ( const char * ) bytes, size ); QString out = ba.toHex(); return out; } @@ -233,7 +233,6 @@ class TestQgsGeometry : public QgsTest QPainter *mpPainter = nullptr; QPen mPen1; QPen mPen2; - }; TestQgsGeometry::TestQgsGeometry() @@ -243,7 +242,6 @@ TestQgsGeometry::TestQgsGeometry() , mpPolygonGeometryB( nullptr ) , mpPolygonGeometryC( nullptr ) { - } void TestQgsGeometry::initTestCase() @@ -397,7 +395,7 @@ void TestQgsGeometry::asVariant() //convert to and from a QVariant QVariant var = QVariant::fromValue( original ); QVERIFY( var.isValid() ); - QCOMPARE( var.userType(), qMetaTypeId< QgsGeometry>() ); + QCOMPARE( var.userType(), qMetaTypeId() ); QgsGeometry fromVar = qvariant_cast( var ); QCOMPARE( fromVar.constGet()->vertexAt( QgsVertexId( 0, 0, 0 ) ).x(), 1.0 ); @@ -498,7 +496,7 @@ void TestQgsGeometry::equality() QVERIFY( !QgsGeometry().equals( QgsGeometry() ) ); // compare to null - QgsGeometry g1( std::make_unique< QgsPoint >( 1.0, 2.0 ) ); + QgsGeometry g1( std::make_unique( 1.0, 2.0 ) ); QVERIFY( !g1.equals( QgsGeometry() ) ); QVERIFY( !QgsGeometry().equals( g1 ) ); @@ -571,7 +569,7 @@ void TestQgsGeometry::partIterator() QVERIFY( it.hasNext() ); QgsAbstractGeometry *part = it.next(); QCOMPARE( part->asWkt(), QStringLiteral( "Point (1 2)" ) ); - static_cast< QgsPoint * >( part )->setX( 100 ); + static_cast( part )->setX( 100 ); QCOMPARE( geom2.asWkt(), QStringLiteral( "Point (100 2)" ) ); QVERIFY( !it.hasNext() ); // geom2 should have adetached, geom should be unaffected by change @@ -590,9 +588,9 @@ void TestQgsGeometry::geos() QgsGeometry res( QgsGeos::fromGeos( asGeos.get() ) ); QCOMPARE( res.asWkt(), QStringLiteral( "MultiPolygon EMPTY" ) ); polyWithEmptyParts.addGeometry( new QgsPolygon( new QgsLineString() ) ); - polyWithEmptyParts.addGeometry( new QgsPolygon( new QgsLineString( QVector< QgsPoint >() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ) ) ); + polyWithEmptyParts.addGeometry( new QgsPolygon( new QgsLineString( QVector() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ) ) ); polyWithEmptyParts.addGeometry( new QgsPolygon( new QgsLineString() ) ); - polyWithEmptyParts.addGeometry( new QgsPolygon( new QgsLineString( QVector< QgsPoint >() << QgsPoint( 10, 0 ) << QgsPoint( 10, 1 ) << QgsPoint( 11, 1 ) << QgsPoint( 10, 0 ) ) ) ); + polyWithEmptyParts.addGeometry( new QgsPolygon( new QgsLineString( QVector() << QgsPoint( 10, 0 ) << QgsPoint( 10, 1 ) << QgsPoint( 11, 1 ) << QgsPoint( 10, 0 ) ) ) ); asGeos = QgsGeos::asGeos( &polyWithEmptyParts ); QCOMPARE( GEOSGetNumGeometries_r( QgsGeosContext::get(), asGeos.get() ), 2 ); res = QgsGeometry( QgsGeos::fromGeos( asGeos.get() ) ); @@ -669,7 +667,7 @@ void TestQgsGeometry::curveIndexOf() QgsGeometry g = QgsGeometry::fromWkt( curve ); QgsPoint p; p.fromWkt( point ); - QCOMPARE( qgsgeometry_cast< const QgsCurve * >( g.constGet() )->indexOf( p ), expected ); + QCOMPARE( qgsgeometry_cast( g.constGet() )->indexOf( p ), expected ); } void TestQgsGeometry::splitCurve_data() @@ -731,13 +729,13 @@ void TestQgsGeometry::splitCurve_data() QTest::newRow( "CompoundCurve 10" ) << QStringLiteral( "CompoundCurve((1 2, 3 4, 5 6), CircularString(5 6, 7 8, 9 10, 11 12, 13 14))" ) << 10 << QStringLiteral( "CompoundCurve ((1 2, 3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14))" ) << QStringLiteral( "CompoundCurve EMPTY" ); QTest::newRow( "CompoundCurve three parts 6" ) << QStringLiteral( "CompoundCurve((1 2, 3 4, 5 6), CircularString(5 6, 7 8, 9 10, 11 12, 13 14), (13 14, 15 16, 17 18))" ) << 6 - << QStringLiteral( "CompoundCurve ((1 2, 3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14))" ) << QStringLiteral( "CompoundCurve ((13 14, 15 16, 17 18))" ); + << QStringLiteral( "CompoundCurve ((1 2, 3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14))" ) << QStringLiteral( "CompoundCurve ((13 14, 15 16, 17 18))" ); QTest::newRow( "CompoundCurve three parts 7" ) << QStringLiteral( "CompoundCurve((1 2, 3 4, 5 6), CircularString(5 6, 7 8, 9 10, 11 12, 13 14), (13 14, 15 16, 17 18))" ) << 7 - << QStringLiteral( "CompoundCurve ((1 2, 3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14),(13 14, 15 16))" ) << QStringLiteral( "CompoundCurve ((15 16, 17 18))" ); + << QStringLiteral( "CompoundCurve ((1 2, 3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14),(13 14, 15 16))" ) << QStringLiteral( "CompoundCurve ((15 16, 17 18))" ); QTest::newRow( "CompoundCurve three parts 7" ) << QStringLiteral( "CompoundCurve((1 2, 3 4, 5 6), CircularString(5 6, 7 8, 9 10, 11 12, 13 14), (13 14, 15 16, 17 18))" ) << 8 - << QStringLiteral( "CompoundCurve ((1 2, 3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14),(13 14, 15 16, 17 18))" ) << QStringLiteral( "CompoundCurve EMPTY" ); + << QStringLiteral( "CompoundCurve ((1 2, 3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14),(13 14, 15 16, 17 18))" ) << QStringLiteral( "CompoundCurve EMPTY" ); QTest::newRow( "CompoundCurve three parts 1" ) << QStringLiteral( "CompoundCurve((1 2, 3 4, 5 6), CircularString(5 6, 7 8, 9 10, 11 12, 13 14), (13 14, 15 16, 17 18))" ) << 1 - << QStringLiteral( "CompoundCurve ((1 2, 3 4))" ) << QStringLiteral( "CompoundCurve ((3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14),(13 14, 15 16, 17 18))" ); + << QStringLiteral( "CompoundCurve ((1 2, 3 4))" ) << QStringLiteral( "CompoundCurve ((3 4, 5 6),CircularString (5 6, 7 8, 9 10, 11 12, 13 14),(13 14, 15 16, 17 18))" ); } void TestQgsGeometry::splitCurve() @@ -748,7 +746,7 @@ void TestQgsGeometry::splitCurve() QFETCH( QString, curve2 ); QgsGeometry curve( QgsGeometry::fromWkt( wkt ) ); - auto [p1, p2] = qgsgeometry_cast< const QgsCurve * >( curve.constGet() )->splitCurveAtVertex( vertex ); + auto [p1, p2] = qgsgeometry_cast( curve.constGet() )->splitCurveAtVertex( vertex ); QCOMPARE( p1->asWkt(), curve1 ); QCOMPARE( p2->asWkt(), curve2 ); } @@ -762,21 +760,21 @@ void TestQgsGeometry::splitToDisjointXYParts() for ( QgsLineString *part : onePartParts ) delete part; - QgsLineString onePointLine( QVector {QgsPoint( 1.0, 1.0 )} ); + QgsLineString onePointLine( QVector { QgsPoint( 1.0, 1.0 ) } ); QVector onePointParts = onePointLine.splitToDisjointXYParts(); QCOMPARE( onePointParts.size(), 1 ); QCOMPARE( onePointParts[0]->asWkt(), onePointLine.asWkt() ); for ( QgsLineString *part : onePointParts ) delete part; - QgsLineString emptyLine( QVector { } ); + QgsLineString emptyLine( QVector {} ); QVector emptyParts = emptyLine.splitToDisjointXYParts(); QCOMPARE( emptyParts.size(), 1 ); QCOMPARE( emptyParts[0]->asWkt(), emptyLine.asWkt() ); for ( QgsLineString *part : emptyParts ) delete part; - QgsLineString triangle( QVector {QgsPoint( 0.0, 0.0 ), QgsPoint( 1.0, 0.0 ), QgsPoint( 1.0, 1.0 ), QgsPoint( 0.0, 0.0 )} ); + QgsLineString triangle( QVector { QgsPoint( 0.0, 0.0 ), QgsPoint( 1.0, 0.0 ), QgsPoint( 1.0, 1.0 ), QgsPoint( 0.0, 0.0 ) } ); QVector triangleParts = triangle.splitToDisjointXYParts(); QCOMPARE( triangleParts.size(), 2 ); QCOMPARE( triangleParts[0]->asWkt(), "LineString (0 0, 1 0, 1 1)" ); @@ -1021,7 +1019,7 @@ void TestQgsGeometry::comparePolygons() QVERIFY( !QgsGeometry::compare( poly3, poly4 ) ); } -#if defined(__clang__) || defined(__GNUG__) +#if defined( __clang__ ) || defined( __GNUG__ ) #include #include @@ -1050,15 +1048,15 @@ namespace std::unique_ptr geomResult { new T() }; std::unique_ptr created { TestQgsGeometry::createEmpty( geom.get() ) }; QVERIFY( created->isEmpty() ); -#if defined(__clang__) || defined(__GNUG__) - srand( ( unsigned )time( NULL ) ); +#if defined( __clang__ ) || defined( __GNUG__ ) + srand( ( unsigned ) time( NULL ) ); - const std::type_info &ti = typeid( T ); + const std::type_info &ti = typeid( T ); int status; char *realname = abi::__cxa_demangle( ti.name(), 0, 0, &status ); QString type = realname; -// remove Qgs prefix + // remove Qgs prefix type = type.right( type.count() - 3 ); QStringList extensionZM; extensionZM << QString() << QString( "Z" ) << QString( "M" ) << QString( "ZM" ) << QString( " Z" ) << QString( " M" ) << QString( " ZM" ) << QString( "Z M" ) << QString( " Z M" ); @@ -1069,12 +1067,12 @@ namespace QStringList emptyStringList; emptyStringList << QString( "EMPTY" ) << QString( "Empty" ) << QString( "empty" ) << QString( "EmptY" ) << QString( "EmPtY" ); - for ( int i = 0 ; i < 10 ; ++i ) + for ( int i = 0; i < 10; ++i ) { QString spacesBefore = generateSpacesString( i ); QString spacesMiddle = i == 0 ? QStringLiteral( " " ) : generateSpacesString( i ); QString spacesAfter = generateSpacesString( i ); - for ( int j = 0; j < emptyStringList.count() ; ++j ) + for ( int j = 0; j < emptyStringList.count(); ++j ) { QString generatedWkt = spacesBefore + wkt + spacesMiddle + emptyStringList.at( j ) + spacesAfter; @@ -1093,7 +1091,7 @@ namespace // Check that it is the correct type QVERIFY( static_cast( created.get() ) != nullptr ); } -} +} // namespace void TestQgsGeometry::createEmptyWithSameType() { @@ -1169,7 +1167,7 @@ void TestQgsGeometry::compareTo_data() QTest::newRow( "linestring zm second" ) << QStringLiteral( "LINESTRINGZM( 1 1 3 5, 2 2 4 5)" ) << QStringLiteral( "LINESTRINGZM( 1 1 3 5, 2 2 4 6)" ) << -1; QTest::newRow( "linestring zm third" ) << QStringLiteral( "LINESTRINGZM( 1 1 3 5, 2 2 4 7)" ) << QStringLiteral( "LINESTRINGZM( 1 1 3 5, 2 2 4 3)" ) << 1; QTest::newRow( "linestring vs circular string" ) << QStringLiteral( "LINESTRING( 1 1, 2 1, 2 3)" ) << QStringLiteral( "CIRCULARSTRING( 1 1, 2 1, 2 3)" ) << -1; - QTest::newRow( "circular string vs linestring" ) << QStringLiteral( "CIRCULARSTRING( 1 1, 2 1, 2 3)" ) << QStringLiteral( "LINESTRING( 1 1, 2 1, 2 3)" ) << 1; + QTest::newRow( "circular string vs linestring" ) << QStringLiteral( "CIRCULARSTRING( 1 1, 2 1, 2 3)" ) << QStringLiteral( "LINESTRING( 1 1, 2 1, 2 3)" ) << 1; QTest::newRow( "circular string empty vs non empty" ) << QStringLiteral( "CIRCULARSTRING()" ) << QStringLiteral( "CIRCULARSTRING(1 1, 2 2, 2 3)" ) << -1; QTest::newRow( "circular string non empty vs empty" ) << QStringLiteral( "CIRCULARSTRING( 1 1, 2 2, 2 3)" ) << QStringLiteral( "CIRCULARSTRING()" ) << 1; QTest::newRow( "circular string empty vs empty" ) << QStringLiteral( "CIRCULARSTRING()" ) << QStringLiteral( "CIRCULARSTRING()" ) << 0; @@ -1197,7 +1195,7 @@ void TestQgsGeometry::compareTo_data() QTest::newRow( "circular string zm third" ) << QStringLiteral( "CIRCULARSTRINGZM( 1 1 3 5, 2 2 4 7, 2 3 5 6)" ) << QStringLiteral( "CIRCULARSTRINGZM( 1 1 3 5, 2 2 4 3, 2 3 5 6)" ) << 1; QTest::newRow( "linestring vs compound curve" ) << QStringLiteral( "LINESTRING( 1 1, 2 1, 2 3)" ) << QStringLiteral( "COMPOUNDCURVE((1 1, 2 1, 2 3))" ) << -1; - QTest::newRow( "compound curve vs linestring" ) << QStringLiteral( "COMPOUNDCURVE(( 1 1, 2 1, 2 3 ))" ) << QStringLiteral( "LINESTRING( 1 1, 2 1, 2 3)" ) << 1; + QTest::newRow( "compound curve vs linestring" ) << QStringLiteral( "COMPOUNDCURVE(( 1 1, 2 1, 2 3 ))" ) << QStringLiteral( "LINESTRING( 1 1, 2 1, 2 3)" ) << 1; QTest::newRow( "compound curve empty vs non empty" ) << QStringLiteral( "COMPOUNDCURVE()" ) << QStringLiteral( "COMPOUNDCURVE((1 1, 2 2, 2 3))" ) << -1; QTest::newRow( "compound curve non empty vs empty" ) << QStringLiteral( "COMPOUNDCURVE( (1 1, 2 2, 2 3))" ) << QStringLiteral( "COMPOUNDCURVE()" ) << 1; QTest::newRow( "compound curve empty vs empty" ) << QStringLiteral( "COMPOUNDCURVE()" ) << QStringLiteral( "COMPOUNDCURVE()" ) << 0; @@ -1307,7 +1305,7 @@ void TestQgsGeometry::scroll() QFETCH( QString, expected ); QgsGeometry geom = QgsGeometry::fromWkt( curve ); - qgsgeometry_cast< QgsCurve * >( geom.get() )->scroll( vertex ); + qgsgeometry_cast( geom.get() )->scroll( vertex ); QCOMPARE( geom.get()->asWkt(), expected ); } @@ -1318,20 +1316,20 @@ void TestQgsGeometry::normalize_data() QTest::addColumn( "expected" ); QTest::newRow( "empty" ) << QString() << QString(); - QTest::newRow( "point empty" ) << QStringLiteral( "POINT EMPTY" ) << QStringLiteral( "Point EMPTY" ); - QTest::newRow( "point" ) << QStringLiteral( "POINT (1 2)" ) << QStringLiteral( "Point (1 2)" ); + QTest::newRow( "point empty" ) << QStringLiteral( "POINT EMPTY" ) << QStringLiteral( "Point EMPTY" ); + QTest::newRow( "point" ) << QStringLiteral( "POINT (1 2)" ) << QStringLiteral( "Point (1 2)" ); // same code paths are used for all curve derivatives - QTest::newRow( "line empty" ) << QStringLiteral( "LINESTRING EMPTY" ) << QStringLiteral( "LineString EMPTY" ); - QTest::newRow( "line open" ) << QStringLiteral( "LINESTRING (1 1, 1 2, 1 3)" ) << QStringLiteral( "LineString (1 1, 1 2, 1 3)" ); - QTest::newRow( "line closed" ) << QStringLiteral( "LINESTRING (1 1, 1 0, 0 0, 0 1, 1 1)" ) << QStringLiteral( "LineString (0 0, 0 1, 1 1, 1 0, 0 0)" ); - QTest::newRow( "circular string closed" ) << QStringLiteral( "CIRCULARSTRING ZM (1 1 11 21, 1 0 12 22, 0 0 13 23, 0 1 14 24, 1 1 11 21)" ) << QStringLiteral( "CircularString ZM (0 0 13 23, 0 1 14 24, 1 1 11 21, 1 0 12 22, 0 0 13 23)" ); + QTest::newRow( "line empty" ) << QStringLiteral( "LINESTRING EMPTY" ) << QStringLiteral( "LineString EMPTY" ); + QTest::newRow( "line open" ) << QStringLiteral( "LINESTRING (1 1, 1 2, 1 3)" ) << QStringLiteral( "LineString (1 1, 1 2, 1 3)" ); + QTest::newRow( "line closed" ) << QStringLiteral( "LINESTRING (1 1, 1 0, 0 0, 0 1, 1 1)" ) << QStringLiteral( "LineString (0 0, 0 1, 1 1, 1 0, 0 0)" ); + QTest::newRow( "circular string closed" ) << QStringLiteral( "CIRCULARSTRING ZM (1 1 11 21, 1 0 12 22, 0 0 13 23, 0 1 14 24, 1 1 11 21)" ) << QStringLiteral( "CircularString ZM (0 0 13 23, 0 1 14 24, 1 1 11 21, 1 0 12 22, 0 0 13 23)" ); // same code paths are used for all curve polygon derivatives - QTest::newRow( "polygon empty" ) << QStringLiteral( "POLYGON EMPTY" ) << QStringLiteral( "Polygon EMPTY" ); - QTest::newRow( "polygon exterior" ) << QStringLiteral( "POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1))" ) << QStringLiteral( "Polygon ((0 0, 0 1, 1 1, 1 0, 0 0))" ); - QTest::newRow( "polygon rings" ) << QStringLiteral( "POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1),(0.1 0.2, 0.2 0.2, 0.2 0.1, 0.1 0.1, 0.1 0.2),(0.8 0.8, 0.8 0.7, 0.7 0.7, 0.7 0.8, 0.8 0.8))" ) << QStringLiteral( "Polygon ((0 0, 0 1, 1 1, 1 0, 0 0),(0.7 0.7, 0.8 0.7, 0.8 0.8, 0.7 0.8, 0.7 0.7),(0.1 0.1, 0.2 0.1, 0.2 0.2, 0.1 0.2, 0.1 0.1))" ); + QTest::newRow( "polygon empty" ) << QStringLiteral( "POLYGON EMPTY" ) << QStringLiteral( "Polygon EMPTY" ); + QTest::newRow( "polygon exterior" ) << QStringLiteral( "POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1))" ) << QStringLiteral( "Polygon ((0 0, 0 1, 1 1, 1 0, 0 0))" ); + QTest::newRow( "polygon rings" ) << QStringLiteral( "POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1),(0.1 0.2, 0.2 0.2, 0.2 0.1, 0.1 0.1, 0.1 0.2),(0.8 0.8, 0.8 0.7, 0.7 0.7, 0.7 0.8, 0.8 0.8))" ) << QStringLiteral( "Polygon ((0 0, 0 1, 1 1, 1 0, 0 0),(0.7 0.7, 0.8 0.7, 0.8 0.8, 0.7 0.8, 0.7 0.7),(0.1 0.1, 0.2 0.1, 0.2 0.2, 0.1 0.2, 0.1 0.1))" ); // same code paths are used for all collection derivatives - QTest::newRow( "collection empty" ) << QStringLiteral( "GEOMETRYCOLLECTION EMPTY" ) << QStringLiteral( "GeometryCollection EMPTY" ); - QTest::newRow( "multipoint" ) << QStringLiteral( "MULTIPOINT(1 1, 3 4, 1 3, 2 2)" ) << QStringLiteral( "MultiPoint ((3 4),(2 2),(1 3),(1 1))" ); + QTest::newRow( "collection empty" ) << QStringLiteral( "GEOMETRYCOLLECTION EMPTY" ) << QStringLiteral( "GeometryCollection EMPTY" ); + QTest::newRow( "multipoint" ) << QStringLiteral( "MULTIPOINT(1 1, 3 4, 1 3, 2 2)" ) << QStringLiteral( "MultiPoint ((3 4),(2 2),(1 3),(1 1))" ); } void TestQgsGeometry::normalize() @@ -1351,19 +1349,19 @@ void TestQgsGeometry::simplifiedTypeRef_data() QTest::addColumn( "wkt" ); QTest::addColumn( "expected" ); - QTest::newRow( "point empty" ) << QStringLiteral( "POINT EMPTY" ) << QStringLiteral( "Point EMPTY" ); - QTest::newRow( "point" ) << QStringLiteral( "POINT (1 2)" ) << QStringLiteral( "Point (1 2)" ); - QTest::newRow( "line empty" ) << QStringLiteral( "LINESTRING EMPTY" ) << QStringLiteral( "LineString EMPTY" ); - QTest::newRow( "line" ) << QStringLiteral( "LINESTRING (1 1, 1 2, 1 3)" ) << QStringLiteral( "LineString (1 1, 1 2, 1 3)" ); - QTest::newRow( "circular string" ) << QStringLiteral( "CIRCULARSTRING ZM (1 1 11 21, 1 0 12 22, 0 0 13 23, 0 1 14 24, 1 1 11 21)" ) << QStringLiteral( "CircularString ZM (1 1 11 21, 1 0 12 22, 0 0 13 23, 0 1 14 24, 1 1 11 21)" ); - QTest::newRow( "compound curve empty" ) << QStringLiteral( "COMPOUNDCURVE EMPTY" ) << QStringLiteral( "CompoundCurve EMPTY" ); - QTest::newRow( "compound curve one curve" ) << QStringLiteral( "COMPOUNDCURVE ((1 1, 1 2, 2 3))" ) << QStringLiteral( "LineString (1 1, 1 2, 2 3)" ); - QTest::newRow( "compound curve two curves" ) << QStringLiteral( "COMPOUNDCURVE ((1 1, 1 2, 2 3),(2 3, 4 4))" ) << QStringLiteral( "CompoundCurve ((1 1, 1 2, 2 3),(2 3, 4 4))" ); - QTest::newRow( "polygon empty" ) << QStringLiteral( "POLYGON EMPTY" ) << QStringLiteral( "Polygon EMPTY" ); - QTest::newRow( "polygon exterior" ) << QStringLiteral( "POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1))" ) << QStringLiteral( "Polygon ((1 1, 0 1, 0 0, 1 0, 1 1))" ); - QTest::newRow( "collection empty" ) << QStringLiteral( "GEOMETRYCOLLECTION EMPTY" ) << QStringLiteral( "GeometryCollection EMPTY" ); - QTest::newRow( "multipoint one point" ) << QStringLiteral( "MULTIPOINT(1 1)" ) << QStringLiteral( "Point (1 1)" ); - QTest::newRow( "multipoint" ) << QStringLiteral( "MULTIPOINT(1 1, 3 4, 1 3, 2 2)" ) << QStringLiteral( "MultiPoint ((1 1),(3 4),(1 3),(2 2))" ); + QTest::newRow( "point empty" ) << QStringLiteral( "POINT EMPTY" ) << QStringLiteral( "Point EMPTY" ); + QTest::newRow( "point" ) << QStringLiteral( "POINT (1 2)" ) << QStringLiteral( "Point (1 2)" ); + QTest::newRow( "line empty" ) << QStringLiteral( "LINESTRING EMPTY" ) << QStringLiteral( "LineString EMPTY" ); + QTest::newRow( "line" ) << QStringLiteral( "LINESTRING (1 1, 1 2, 1 3)" ) << QStringLiteral( "LineString (1 1, 1 2, 1 3)" ); + QTest::newRow( "circular string" ) << QStringLiteral( "CIRCULARSTRING ZM (1 1 11 21, 1 0 12 22, 0 0 13 23, 0 1 14 24, 1 1 11 21)" ) << QStringLiteral( "CircularString ZM (1 1 11 21, 1 0 12 22, 0 0 13 23, 0 1 14 24, 1 1 11 21)" ); + QTest::newRow( "compound curve empty" ) << QStringLiteral( "COMPOUNDCURVE EMPTY" ) << QStringLiteral( "CompoundCurve EMPTY" ); + QTest::newRow( "compound curve one curve" ) << QStringLiteral( "COMPOUNDCURVE ((1 1, 1 2, 2 3))" ) << QStringLiteral( "LineString (1 1, 1 2, 2 3)" ); + QTest::newRow( "compound curve two curves" ) << QStringLiteral( "COMPOUNDCURVE ((1 1, 1 2, 2 3),(2 3, 4 4))" ) << QStringLiteral( "CompoundCurve ((1 1, 1 2, 2 3),(2 3, 4 4))" ); + QTest::newRow( "polygon empty" ) << QStringLiteral( "POLYGON EMPTY" ) << QStringLiteral( "Polygon EMPTY" ); + QTest::newRow( "polygon exterior" ) << QStringLiteral( "POLYGON ((1 1, 0 1, 0 0, 1 0, 1 1))" ) << QStringLiteral( "Polygon ((1 1, 0 1, 0 0, 1 0, 1 1))" ); + QTest::newRow( "collection empty" ) << QStringLiteral( "GEOMETRYCOLLECTION EMPTY" ) << QStringLiteral( "GeometryCollection EMPTY" ); + QTest::newRow( "multipoint one point" ) << QStringLiteral( "MULTIPOINT(1 1)" ) << QStringLiteral( "Point (1 1)" ); + QTest::newRow( "multipoint" ) << QStringLiteral( "MULTIPOINT(1 1, 3 4, 1 3, 2 2)" ) << QStringLiteral( "MultiPoint ((1 1),(3 4),(1 3),(2 2))" ); } void TestQgsGeometry::simplifiedTypeRef() @@ -1399,7 +1397,7 @@ void TestQgsGeometry::intersectionCheck1() initPainterTest(); QVERIFY( mpPolygonGeometryA.intersects( mpPolygonGeometryB ) ); - std::unique_ptr< QgsGeometryEngine > engine( QgsGeometry::createGeometryEngine( mpPolygonGeometryA.constGet() ) ); + std::unique_ptr engine( QgsGeometry::createGeometryEngine( mpPolygonGeometryA.constGet() ) ); QVERIFY( engine->intersects( mpPolygonGeometryB.constGet() ) ); engine->prepareGeometry(); QVERIFY( engine->intersects( mpPolygonGeometryB.constGet() ) ); @@ -1448,7 +1446,6 @@ void TestQgsGeometry::translateCheck1() geom.translate( 2, -10 ); obtained = geom.asWkt(); QCOMPARE( obtained, wkt ); - } void TestQgsGeometry::rotateCheck1() @@ -1489,7 +1486,6 @@ void TestQgsGeometry::rotateCheck1() geom.rotate( 180, QgsPointXY( 40, 0 ) ); // round-trip obtained = geom.asWkt(); QCOMPARE( obtained, wkt ); - } void TestQgsGeometry::unionCheck1() @@ -1514,7 +1510,6 @@ void TestQgsGeometry::unionCheck2() QVERIFY( myPolygon.size() > 0 ); //check that the union created a feature paintPolygon( myPolygon ); QGSVERIFYIMAGECHECK( "Checking A union B produces single union poly", "geometry_unionCheck2", mImage, QString(), 0 ); - } void TestQgsGeometry::differenceCheck1() @@ -1633,10 +1628,9 @@ void TestQgsGeometry::smoothCheck() result = geom.smooth( 1, 0.25 ); QgsMultiPolylineXY multiLine = result.asMultiPolyline(); QgsMultiPolylineXY expectedMultiline; - expectedMultiline << ( QgsPolylineXY() << QgsPointXY( 0, 0 ) << QgsPointXY( 7.5, 0 ) << QgsPointXY( 10.0, 2.5 ) - << QgsPointXY( 10.0, 7.5 ) << QgsPointXY( 12.5, 10.0 ) << QgsPointXY( 20.0, 10.0 ) ) + expectedMultiline << ( QgsPolylineXY() << QgsPointXY( 0, 0 ) << QgsPointXY( 7.5, 0 ) << QgsPointXY( 10.0, 2.5 ) << QgsPointXY( 10.0, 7.5 ) << QgsPointXY( 12.5, 10.0 ) << QgsPointXY( 20.0, 10.0 ) ) << ( QgsPolylineXY() << QgsPointXY( 30.0, 30.0 ) << QgsPointXY( 37.5, 30.0 ) << QgsPointXY( 40.0, 32.5 ) - << QgsPointXY( 40.0, 37.5 ) << QgsPointXY( 42.5, 40.0 ) << QgsPointXY( 50.0, 40.0 ) ); + << QgsPointXY( 40.0, 37.5 ) << QgsPointXY( 42.5, 40.0 ) << QgsPointXY( 50.0, 40.0 ) ); QVERIFY( QgsGeometry::compare( multiLine, expectedMultiline ) ); //polygon @@ -1645,12 +1639,10 @@ void TestQgsGeometry::smoothCheck() result = geom.smooth( 1, 0.25 ); QgsPolygonXY poly = result.asPolygon(); QgsPolygonXY expectedPolygon; - expectedPolygon << ( QgsPolylineXY() << QgsPointXY( 2.5, 0 ) << QgsPointXY( 7.5, 0 ) << QgsPointXY( 10.0, 2.5 ) - << QgsPointXY( 10.0, 7.5 ) << QgsPointXY( 7.5, 10.0 ) << QgsPointXY( 2.5, 10.0 ) << QgsPointXY( 0, 7.5 ) - << QgsPointXY( 0, 2.5 ) << QgsPointXY( 2.5, 0 ) ) + expectedPolygon << ( QgsPolylineXY() << QgsPointXY( 2.5, 0 ) << QgsPointXY( 7.5, 0 ) << QgsPointXY( 10.0, 2.5 ) << QgsPointXY( 10.0, 7.5 ) << QgsPointXY( 7.5, 10.0 ) << QgsPointXY( 2.5, 10.0 ) << QgsPointXY( 0, 7.5 ) << QgsPointXY( 0, 2.5 ) << QgsPointXY( 2.5, 0 ) ) << ( QgsPolylineXY() << QgsPointXY( 2.5, 2.0 ) << QgsPointXY( 3.5, 2.0 ) << QgsPointXY( 4.0, 2.5 ) - << QgsPointXY( 4.0, 3.5 ) << QgsPointXY( 3.5, 4.0 ) << QgsPointXY( 2.5, 4.0 ) - << QgsPointXY( 2.0, 3.5 ) << QgsPointXY( 2.0, 2.5 ) << QgsPointXY( 2.5, 2.0 ) ); + << QgsPointXY( 4.0, 3.5 ) << QgsPointXY( 3.5, 4.0 ) << QgsPointXY( 2.5, 4.0 ) + << QgsPointXY( 2.0, 3.5 ) << QgsPointXY( 2.0, 2.5 ) << QgsPointXY( 2.5, 2.0 ) ); QVERIFY( QgsGeometry::compare( poly, expectedPolygon ) ); //polygonM @@ -1677,8 +1669,7 @@ void TestQgsGeometry::smoothCheck() result = geom.smooth( 1, 0.25, -1, 50 ); poly = result.asPolygon(); expectedPolygon.clear(); - expectedPolygon << ( QgsPolylineXY() << QgsPointXY( 0, 0 ) << QgsPointXY( 10, 0 ) << QgsPointXY( 10.0, 10 ) - << QgsPointXY( 0, 10 ) << QgsPointXY( 0, 0 ) ); + expectedPolygon << ( QgsPolylineXY() << QgsPointXY( 0, 0 ) << QgsPointXY( 10, 0 ) << QgsPointXY( 10.0, 10 ) << QgsPointXY( 0, 10 ) << QgsPointXY( 0, 0 ) ); QVERIFY( QgsGeometry::compare( poly, expectedPolygon ) ); //multipolygon) @@ -1688,12 +1679,8 @@ void TestQgsGeometry::smoothCheck() QgsMultiPolygonXY multipoly = result.asMultiPolygon(); QgsMultiPolygonXY expectedMultiPoly; expectedMultiPoly - << ( QgsPolygonXY() << ( QgsPolylineXY() << QgsPointXY( 1.0, 0 ) << QgsPointXY( 9, 0 ) << QgsPointXY( 10.0, 1 ) - << QgsPointXY( 10.0, 9 ) << QgsPointXY( 9, 10.0 ) << QgsPointXY( 1, 10.0 ) << QgsPointXY( 0, 9 ) - << QgsPointXY( 0, 1 ) << QgsPointXY( 1, 0 ) ) ) - << ( QgsPolygonXY() << ( QgsPolylineXY() << QgsPointXY( 2.2, 2.0 ) << QgsPointXY( 3.8, 2.0 ) << QgsPointXY( 4.0, 2.2 ) - << QgsPointXY( 4.0, 3.8 ) << QgsPointXY( 3.8, 4.0 ) << QgsPointXY( 2.2, 4.0 ) << QgsPointXY( 2.0, 3.8 ) - << QgsPointXY( 2, 2.2 ) << QgsPointXY( 2.2, 2 ) ) ); + << ( QgsPolygonXY() << ( QgsPolylineXY() << QgsPointXY( 1.0, 0 ) << QgsPointXY( 9, 0 ) << QgsPointXY( 10.0, 1 ) << QgsPointXY( 10.0, 9 ) << QgsPointXY( 9, 10.0 ) << QgsPointXY( 1, 10.0 ) << QgsPointXY( 0, 9 ) << QgsPointXY( 0, 1 ) << QgsPointXY( 1, 0 ) ) ) + << ( QgsPolygonXY() << ( QgsPolylineXY() << QgsPointXY( 2.2, 2.0 ) << QgsPointXY( 3.8, 2.0 ) << QgsPointXY( 4.0, 2.2 ) << QgsPointXY( 4.0, 3.8 ) << QgsPointXY( 3.8, 4.0 ) << QgsPointXY( 2.2, 4.0 ) << QgsPointXY( 2.0, 3.8 ) << QgsPointXY( 2, 2.2 ) << QgsPointXY( 2.2, 2 ) ) ); QVERIFY( QgsGeometry::compare( multipoly, expectedMultiPoly ) ); // curved geometry @@ -1716,14 +1703,14 @@ void TestQgsGeometry::shortestLineEmptyGeometry() void TestQgsGeometry::distanceCheck() { QgsGeometry polygon( QgsGeometry::fromWkt( QStringLiteral( "Polygon ((0 0, 10 0, 10 10, 0 10, 0 0 ))" ) ) ); - std::unique_ptr< QgsGeometryEngine > polygonEngine( QgsGeometry::createGeometryEngine( polygon.constGet() ) ); + std::unique_ptr polygonEngine( QgsGeometry::createGeometryEngine( polygon.constGet() ) ); polygonEngine->prepareGeometry(); /** * Test polygon and 2D line */ QgsGeometry line2D( QgsGeometry::fromWkt( QStringLiteral( "LineString (15.05 25.2, 13.2 14.1, 17.05 18.1, 15.5 25.2)" ) ) ); - std::unique_ptr< QgsGeometryEngine > line2DEngine( QgsGeometry::createGeometryEngine( line2D.constGet() ) ); + std::unique_ptr line2DEngine( QgsGeometry::createGeometryEngine( line2D.constGet() ) ); line2DEngine->prepareGeometry(); const double distanceToLine2D = 5.20; @@ -1738,7 +1725,7 @@ void TestQgsGeometry::distanceCheck() * Test polygon and 3D line */ QgsGeometry line3D( QgsGeometry::fromWkt( QStringLiteral( "LineString Z(40 50 1, -30 10 30, -70 80 20, 40 50 1)" ) ) ); - std::unique_ptr< QgsGeometryEngine > line3DEngine( QgsGeometry::createGeometryEngine( line3D.constGet() ) ); + std::unique_ptr line3DEngine( QgsGeometry::createGeometryEngine( line3D.constGet() ) ); line3DEngine->prepareGeometry(); const double distanceToLine3D = 14.88; @@ -1753,7 +1740,7 @@ void TestQgsGeometry::distanceCheck() * Test polygon and 3D point */ QgsGeometry point3D( QgsGeometry::fromWkt( QStringLiteral( "Point Z(40.3 50.1 10.2)" ) ) ); - std::unique_ptr< QgsGeometryEngine > point3DEngine( QgsGeometry::createGeometryEngine( point3D.constGet() ) ); + std::unique_ptr point3DEngine( QgsGeometry::createGeometryEngine( point3D.constGet() ) ); point3DEngine->prepareGeometry(); const double distanceToPoint3D = 50.26; QGSCOMPARENEAR( polygonEngine->distance( point3D.constGet() ), distanceToPoint3D, 0.01 ); @@ -1767,7 +1754,7 @@ void TestQgsGeometry::distanceCheck() * Test polygon and 3D vertical line ((X Y Z1, X Y Z2, ..., X Y ZN, X Y Z1)) */ QgsGeometry line3DVertical( QgsGeometry::fromWkt( QStringLiteral( "LineString Z(40.3 50.1 10, 40.3 50.1 -2, 40.3 50.1 -46, 40.3 50.1 10)" ) ) ); - std::unique_ptr< QgsGeometryEngine > line3DVerticalEngine( QgsGeometry::createGeometryEngine( line3DVertical.constGet() ) ); + std::unique_ptr line3DVerticalEngine( QgsGeometry::createGeometryEngine( line3DVertical.constGet() ) ); line3DVerticalEngine->prepareGeometry(); QGSCOMPARENEAR( polygonEngine->distance( line3DVertical.constGet() ), distanceToPoint3D, 0.01 ); QGSCOMPARENEAR( line3DVerticalEngine->distance( polygon.constGet() ), distanceToPoint3D, 0.01 ); @@ -1780,7 +1767,7 @@ void TestQgsGeometry::distanceCheck() * Test polygon and 3D vertical line of two points ((X Y Z1, X Y Z2)) */ QgsGeometry line3DVertical2( QgsGeometry::fromWkt( QStringLiteral( "LineString Z(40.3 50.1 10, 40.3 50.1 -2)" ) ) ); - std::unique_ptr< QgsGeometryEngine > line3DVertical2Engine( QgsGeometry::createGeometryEngine( line3DVertical2.constGet() ) ); + std::unique_ptr line3DVertical2Engine( QgsGeometry::createGeometryEngine( line3DVertical2.constGet() ) ); line3DVertical2Engine->prepareGeometry(); QGSCOMPARENEAR( polygonEngine->distance( line3DVertical2.constGet() ), distanceToPoint3D, 0.01 ); QGSCOMPARENEAR( line3DVertical2Engine->distance( polygon.constGet() ), distanceToPoint3D, 0.01 ); @@ -1798,7 +1785,7 @@ void TestQgsGeometry::unaryUnion() QgsGeometry geom1( QgsGeometry::fromWkt( wkt1 ) ); QgsGeometry geom2( QgsGeometry::fromWkt( wkt2 ) ); QgsGeometry empty; - QVector< QgsGeometry > list; + QVector list; list << geom1 << empty << geom2; QgsGeometry result( QgsGeometry::unaryUnion( list ) ); @@ -1937,20 +1924,20 @@ void TestQgsGeometry::paintPolygon( QgsPolygonXY &polygon ) void TestQgsGeometry::dumpPolyline( QgsPolylineXY &polyline ) { QVector myPoints; -// QgsPolyline myPolyline = polyline.at( j ); //rings of polygon + // QgsPolyline myPolyline = polyline.at( j ); //rings of polygon for ( int j = 0; j < polyline.size(); j++ ) { const QgsPointXY &myPoint = polyline.at( j ); -// QgsPolyline myPolyline = polygon.at( j ); //rings of polygon + // QgsPolyline myPolyline = polygon.at( j ); //rings of polygon myPoints << QPointF( myPoint.x(), myPoint.y() ); qDebug( "\t\tPoint in line: %d", j ); -// for ( int k = 0; k < myPolyline.size(); k++ ) -// { -// QgsPointXY myPoint = myPolyline.at( k ); -// qDebug( "\t\t\tPoint in ring %d : %s", k, myPoint.toString().toLocal8Bit().constData() ); -// myPoints << QPointF( myPoint.x(), myPoint.y() ); -// } + // for ( int k = 0; k < myPolyline.size(); k++ ) + // { + // QgsPointXY myPoint = myPolyline.at( k ); + // qDebug( "\t\t\tPoint in ring %d : %s", k, myPoint.toString().toLocal8Bit().constData() ); + // myPoints << QPointF( myPoint.x(), myPoint.y() ); + // } } mpPainter->drawPolyline( myPoints ); } @@ -2122,7 +2109,7 @@ void TestQgsGeometry::poleOfInaccessibility() // curved geometry QgsGeometry curved = QgsGeometry::fromWkt( "CurvePolygon( CompoundCurve( CircularString(-0.44 0.35, 0.51 0.34, 0.56 0.21, 0.11 -0.33, 0.15 -0.35," - "-0.93 -0.30, -1.02 -0.22, -0.49 0.01, -0.23 -0.04),(-0.23 -0.04, -0.44, 0.35)))" ); + "-0.93 -0.30, -1.02 -0.22, -0.49 0.01, -0.23 -0.04),(-0.23 -0.04, -0.44, 0.35)))" ); point = curved.poleOfInaccessibility( 0.01 ).asPoint(); QGSCOMPARENEAR( point.x(), -0.4324, 0.0001 ); QGSCOMPARENEAR( point.y(), -0.2434, 0.0001 ); @@ -2224,60 +2211,60 @@ void TestQgsGeometry::reshapeGeometryLineMerge() // append with 2D line QgsGeometry g2D_1 = g2D; - res = static_cast< int >( g2D_1.reshapeGeometry( line2D_1 ) ); + res = static_cast( g2D_1.reshapeGeometry( line2D_1 ) ); QCOMPARE( res, 0 ); QCOMPARE( g2D_1.asWkt(), QString( "LineString (10 10, 20 20, 30 30)" ) ); // prepend with 2D line QgsGeometry g2D_2 = g2D; - res = static_cast< int >( g2D_2.reshapeGeometry( line2D_2 ) ); + res = static_cast( g2D_2.reshapeGeometry( line2D_2 ) ); QCOMPARE( res, 0 ); QCOMPARE( g2D_2.asWkt(), QString( "LineString (-10 -10, 10 10, 20 20)" ) ); // append with 3D line QgsGeometry g3D_1 = g3D; - res = static_cast< int >( g3D_1.reshapeGeometry( line3D_1 ) ); + res = static_cast( g3D_1.reshapeGeometry( line3D_1 ) ); QCOMPARE( res, 0 ); QCOMPARE( g3D_1.asWkt(), QString( "LineString Z (10 10 1, 20 20 2, 30 30 3)" ) ); // prepend with 3D line QgsGeometry g3D_2 = g3D; - res = static_cast< int >( g3D_2.reshapeGeometry( line3D_2 ) ); + res = static_cast( g3D_2.reshapeGeometry( line3D_2 ) ); QCOMPARE( res, 0 ); QCOMPARE( g3D_2.asWkt(), QString( "LineString Z (-10 -10 -1, 10 10 1, 20 20 2)" ) ); } void TestQgsGeometry::createCollectionOfType() { - std::unique_ptr< QgsGeometryCollection > collect( QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::Unknown ) ); + std::unique_ptr collect( QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::Unknown ) ); QVERIFY( !collect ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::Point ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiPoint ); - QVERIFY( dynamic_cast< QgsMultiPoint *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::PointM ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiPointM ); - QVERIFY( dynamic_cast< QgsMultiPoint *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::PointZM ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiPointZM ); - QVERIFY( dynamic_cast< QgsMultiPoint *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::PointZ ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiPointZ ); - QVERIFY( dynamic_cast< QgsMultiPoint *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::MultiPoint ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiPoint ); - QVERIFY( dynamic_cast< QgsMultiPoint *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::LineStringZ ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiLineStringZ ); - QVERIFY( dynamic_cast< QgsMultiLineString *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::PolygonM ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiPolygonM ); - QVERIFY( dynamic_cast< QgsMultiPolygon *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::GeometryCollectionZ ); QCOMPARE( collect->wkbType(), Qgis::WkbType::GeometryCollectionZ ); - QVERIFY( dynamic_cast< QgsGeometryCollection *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); collect = QgsGeometryFactory::createCollectionOfType( Qgis::WkbType::CurvePolygonM ); QCOMPARE( collect->wkbType(), Qgis::WkbType::MultiSurfaceM ); - QVERIFY( dynamic_cast< QgsMultiSurface *>( collect.get() ) ); + QVERIFY( dynamic_cast( collect.get() ) ); } void TestQgsGeometry::orientedMinimumBoundingBox() @@ -2285,27 +2272,26 @@ void TestQgsGeometry::orientedMinimumBoundingBox() QgsGeometry geomTest; QgsGeometry result, resultTest; // empty - result = geomTest.orientedMinimumBoundingBox( ); + result = geomTest.orientedMinimumBoundingBox(); QVERIFY( result.isEmpty() ); // oriented rectangle geomTest = QgsGeometry::fromWkt( QStringLiteral( " Polygon((0 0, 5 5, -2.07106781186547462 12.07106781186547551, -7.07106781186547462 7.07106781186547551, 0 0)) " ) ); - result = geomTest.orientedMinimumBoundingBox( ); + result = geomTest.orientedMinimumBoundingBox(); QgsGeometry expectedGeom = QgsGeometry::fromWkt( QStringLiteral( " Polygon((-7.07106781186547462 7.07106781186547551, 0 0, 5 5, -2.07106781186547462 12.07106781186547551, -7.07106781186547462 7.07106781186547551)) " ) ); QCOMPARE( result.asWkt( 3 ), QStringLiteral( "Polygon ((-7.071 7.071, 0 0, 5 5, -2.071 12.071, -7.071 7.071))" ) ); // Issue https://github.com/qgis/QGIS/issues/33532 geomTest = QgsGeometry::fromWkt( QStringLiteral( " Polygon ((264 -525, 248 -521, 244 -519, 233 -508, 231 -504, 210 -445, 196 -396, 180 -332, 178 -322, 176 -310, 174 -296, 174 -261, 176 -257, 178 -255, 183 -251, 193 -245, 197 -243, 413 -176, 439 -168, 447 -166, 465 -164, 548 -164, 552 -166, 561 -175, 567 -187, 602 -304, 618 -379, 618 -400, 616 -406, 612 -414, 606 -420, 587 -430, 575 -436, 547 -446, 451 -474, 437 -478, 321 -511, 283 -521, 275 -523, 266 -525, 264 -525)) " ) ); - result = geomTest.orientedMinimumBoundingBox( ); + result = geomTest.orientedMinimumBoundingBox(); QString resultTestWKT = QStringLiteral( "Polygon ((635.86 -420.08, 552.66 -134.85, 153.5 -251.27, 236.69 -536.51, 635.86 -420.08))" ); QCOMPARE( result.asWkt( 2 ), resultTestWKT ); // Issue https://github.com/qgis/QGIS/issues/47726 geomTest = QgsGeometry::fromWkt( QStringLiteral( "MultiPolygon (((-57 -30, -56.5 -30, -56 -30, -55.5 -30, -55.5 -29.6667, -55.5 -29.333, -55.5 -29, -56 -29, -56.5 -29, -57 -29, -57 -29.3333, -57 -29.6666, -57 -30)))" ) ); - result = geomTest.orientedMinimumBoundingBox( ); + result = geomTest.orientedMinimumBoundingBox(); resultTestWKT = QStringLiteral( "Polygon ((-57 -30, -55.5 -30, -55.5 -29, -57 -29, -57 -30))" ); QCOMPARE( result.asWkt( 2 ), resultTestWKT ); - } void TestQgsGeometry::boundingBox() @@ -2324,7 +2310,7 @@ void TestQgsGeometry::boundingBox3D() QCOMPARE( geomTest.boundingBox3D(), QgsBox3D() ); QgsGeometry geomTest2D = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0 0, 5 5, -2.07106781186547462 12.07106781186547551, -7.07106781186547462 7.07106781186547551))" ) ); - QgsBox3D expectedResult2D = QgsBox3D( -7.07106781186547462, 0, std::numeric_limits< double >::quiet_NaN(), 5, 12.07106781186547551, std::numeric_limits< double >::quiet_NaN() ); + QgsBox3D expectedResult2D = QgsBox3D( -7.07106781186547462, 0, std::numeric_limits::quiet_NaN(), 5, 12.07106781186547551, std::numeric_limits::quiet_NaN() ); QCOMPARE( geomTest2D.boundingBox3D(), expectedResult2D ); QgsGeometry geomTest3D = QgsGeometry::fromWkt( QStringLiteral( "Polygon((0 0 0, 5 5 3, -2.07106781186547462 12.07106781186547551 4.3489, -7.07106781186547462 7.07106781186547551 -7.8909))" ) ); @@ -2393,7 +2379,6 @@ void TestQgsGeometry::minimalEnclosingCircle() QGSCOMPARENEAR( radius, 5.8926, 0.0001 ); resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) ); QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0.8 6.7, 5.9 3.8, 5.9 -2.1, 0.8 -5.1, -4.3 -2.1, -4.3 3.8, 0.8 6.7))" ) ); - } void TestQgsGeometry::splitGeometry() @@ -2402,8 +2387,7 @@ void TestQgsGeometry::splitGeometry() QgsPointSequence testPoints; qDebug() << GEOSversion() << "\n"; QgsGeometry g1 = QgsGeometry::fromWkt( QStringLiteral( "Polygon ((492980.38648063864093274 7082334.45244149677455425, 493082.65415841294452548 7082319.87918917648494244, 492980.38648063858272508 7082334.45244149677455425, 492980.38648063864093274 7082334.45244149677455425))" ) ); - QCOMPARE( g1.splitGeometry( QgsPointSequence() << QgsPoint( 493825.46541286131832749, 7082214.02779923938214779 ) << QgsPoint( 492955.04876351181883365, 7082338.06309300474822521 ), - newGeoms, false, testPoints ), Qgis::GeometryOperationResult::InvalidBaseGeometry ); + QCOMPARE( g1.splitGeometry( QgsPointSequence() << QgsPoint( 493825.46541286131832749, 7082214.02779923938214779 ) << QgsPoint( 492955.04876351181883365, 7082338.06309300474822521 ), newGeoms, false, testPoints ), Qgis::GeometryOperationResult::InvalidBaseGeometry ); QVERIFY( newGeoms.isEmpty() ); // Bug https://github.com/qgis/QGIS/issues/33489 @@ -2570,62 +2554,50 @@ void TestQgsGeometry::snappedToGrid() { // points { - auto check = []( QgsPoint * _a, QgsPoint const & b ) - { - std::unique_ptr a {_a}; + auto check = []( QgsPoint *_a, QgsPoint const &b ) { + std::unique_ptr a { _a }; // because it is to check after snapping, there shouldn't be small precision errors if ( !std::isnan( b.x() ) ) - QVERIFY( ( float )a->x() == ( float )b.x() ); + QVERIFY( ( float ) a->x() == ( float ) b.x() ); if ( !std::isnan( b.y() ) ) - QVERIFY( ( float )a->y() == ( float )b.y() ); + QVERIFY( ( float ) a->y() == ( float ) b.y() ); if ( !std::isnan( b.z() ) ) - QVERIFY( ( float )a->z() == ( float )b.z() ); + QVERIFY( ( float ) a->z() == ( float ) b.z() ); if ( !std::isnan( b.m() ) ) - QVERIFY( ( float )a->m() == ( float )b.m() ); + QVERIFY( ( float ) a->m() == ( float ) b.m() ); }; - check( QgsPoint( 0, 0 ).snappedToGrid( 1, 1 ), - QgsPoint( 0, 0 ) ); + check( QgsPoint( 0, 0 ).snappedToGrid( 1, 1 ), QgsPoint( 0, 0 ) ); - check( QgsPoint( 1, 2.732 ).snappedToGrid( 1, 1 ), - QgsPoint( 1, 3 ) ); + check( QgsPoint( 1, 2.732 ).snappedToGrid( 1, 1 ), QgsPoint( 1, 3 ) ); - check( QgsPoint( 1.3, 6.4 ).snappedToGrid( 1, 1 ), - QgsPoint( 1, 6 ) ); + check( QgsPoint( 1.3, 6.4 ).snappedToGrid( 1, 1 ), QgsPoint( 1, 6 ) ); - check( QgsPoint( 1.3, 6.4 ).snappedToGrid( 1, 0 ), - QgsPoint( 1, 6.4 ) ); + check( QgsPoint( 1.3, 6.4 ).snappedToGrid( 1, 0 ), QgsPoint( 1, 6.4 ) ); // multiple checks with the same point auto p1 = QgsPoint( 1.38, 2.4432 ); - check( p1.snappedToGrid( 1, 1 ), - QgsPoint( 1, 2 ) ); + check( p1.snappedToGrid( 1, 1 ), QgsPoint( 1, 2 ) ); - check( p1.snappedToGrid( 1, 0.1 ), - QgsPoint( 1, 2.4 ) ); + check( p1.snappedToGrid( 1, 0.1 ), QgsPoint( 1, 2.4 ) ); - check( p1.snappedToGrid( 1, 0.01 ), - QgsPoint( 1, 2.44 ) ); + check( p1.snappedToGrid( 1, 0.01 ), QgsPoint( 1, 2.44 ) ); // Let's test more dimensions auto p2 = QgsPoint( 4.2134212, 543.1231, 0.123, 12.944145 ); - check( p2.snappedToGrid( 0, 0, 0, 0 ), - p2 ); + check( p2.snappedToGrid( 0, 0, 0, 0 ), p2 ); - check( p2.snappedToGrid( 0, 0, 1, 1 ), - QgsPoint( 4.2134212, 543.1231, 0, 13 ) ); - - check( p2.snappedToGrid( 1, 0.1, 0.01, 0.001 ), - QgsPoint( 4, 543.1, 0.12, 12.944 ) ); + check( p2.snappedToGrid( 0, 0, 1, 1 ), QgsPoint( 4.2134212, 543.1231, 0, 13 ) ); + check( p2.snappedToGrid( 1, 0.1, 0.01, 0.001 ), QgsPoint( 4, 543.1, 0.12, 12.944 ) ); } // MultiPolygon (testing QgsCollection, QgsCurvePolygon and QgsLineString) @@ -2746,7 +2718,7 @@ void TestQgsGeometry::snappedToGrid() QgsGeometry polyhedralSurfaceZ = QgsGeometry::fromWkt( "PolyhedralSurfaceZ (((0.1 0.1 10.2,1.13 0.2 10.3,0.4 2.3 10.4,0.1 0.1 10.2)),((0.3 0.2 10.4,1.2 0.2 10.2,1.4 0.10 20.2,0.3 0.2 20.1,0.3 0.2 10.4)),((1.13 0.2 10.3,0.4 2.3 10.4,0.1 2.3 20.2,1.2 0.1 20.1,1.13 0.2 10.3)),((0.4 2.3 10.4,0.1 0.1 10.2,0.2 0.1 20.3,0.1 2.3 20.2,0.4 2.3 10.4)),((0.2 0.1 20.3,1.2 0.1 20.1,0.1 2.3 20.2,0.2 0.1 20.3)))" ); qDebug() << polyhedralSurfaceZ.isEmpty(); std::unique_ptr snappedZ { polyhedralSurfaceZ.constGet()->snappedToGrid( 1, 1, 10 ) }; - QCOMPARE( snappedZ->asWkt( 5 ), QStringLiteral( "PolyhedralSurface Z (((0 0 10, 1 0 10, 0 2 10, 0 0 10)),((0 0 10, 1 0 10, 1 0 20, 0 0 20, 0 0 10)),((1 0 10, 0 2 10, 0 2 20, 1 0 20, 1 0 10)),((0 2 10, 0 0 10, 0 0 20, 0 2 20, 0 2 10)),((0 0 20, 1 0 20, 0 2 20, 0 0 20)))" ) ); + QCOMPARE( snappedZ->asWkt( 5 ), QStringLiteral( "PolyhedralSurface Z (((0 0 10, 1 0 10, 0 2 10, 0 0 10)),((0 0 10, 1 0 10, 1 0 20, 0 0 20, 0 0 10)),((1 0 10, 0 2 10, 0 2 20, 1 0 20, 1 0 10)),((0 2 10, 0 0 10, 0 0 20, 0 2 20, 0 2 10)),((0 0 20, 1 0 20, 0 2 20, 0 0 20)))" ) ); QgsGeometry polyhedralSurfaceM = QgsGeometry::fromWkt( "PolyhedralSurfaceM (((0.1 0.1 3.2, 0.3 1.2 3.2, 1.1 1.05 3.2, 0.1 0.1 3.2)))" ); std::unique_ptr snappedM { polyhedralSurfaceM.constGet()->snappedToGrid( 1, 1, 0, 1 ) }; @@ -2766,7 +2738,7 @@ void TestQgsGeometry::snappedToGrid() QgsGeometry triangulatedSurfaceZ = QgsGeometry::fromWkt( "TINZ (((0.1 0.1 10.2,1.13 0.2 10.3,0.4 2.3 10.4,0.1 0.1 10.2)),((0.3 0.2 10.4,1.2 0.2 10.2,1.4 0.10 20.2,0.3 0.2 10.4)),((1.13 0.2 10.3,0.4 2.3 10.4,0.1 2.3 20.2,1.13 0.2 10.3)),((0.4 2.3 10.4,0.1 0.1 10.2,0.2 0.1 20.3,0.4 2.3 10.4)),((0.2 0.1 20.3,1.2 0.1 20.1,0.1 2.3 20.2,0.2 0.1 20.3)))" ); qDebug() << triangulatedSurfaceZ.isEmpty(); std::unique_ptr snappedZ { triangulatedSurfaceZ.constGet()->snappedToGrid( 1, 1, 10 ) }; - QCOMPARE( snappedZ->asWkt( 5 ), QStringLiteral( "TIN Z (((0 0 10, 1 0 10, 0 2 10, 0 0 10)),((0 0 10, 1 0 10, 1 0 20, 0 0 10)),((1 0 10, 0 2 10, 0 2 20, 1 0 10)),((0 2 10, 0 0 10, 0 0 20, 0 2 10)),((0 0 20, 1 0 20, 0 2 20, 0 0 20)))" ) ); + QCOMPARE( snappedZ->asWkt( 5 ), QStringLiteral( "TIN Z (((0 0 10, 1 0 10, 0 2 10, 0 0 10)),((0 0 10, 1 0 10, 1 0 20, 0 0 10)),((1 0 10, 0 2 10, 0 2 20, 1 0 10)),((0 2 10, 0 0 10, 0 0 20, 0 2 10)),((0 0 20, 1 0 20, 0 2 20, 0 0 20)))" ) ); QgsGeometry triangulatedSurfaceM = QgsGeometry::fromWkt( "TINM (((0.1 0.1 3.2, 0.3 1.2 3.2, 1.1 1.05 3.2, 0.1 0.1 3.2)))" ); std::unique_ptr snappedM { triangulatedSurfaceM.constGet()->snappedToGrid( 1, 1, 0, 1 ) }; @@ -2833,7 +2805,7 @@ void TestQgsGeometry::emptyJson() void TestQgsGeometry::testRandomPointsInPolygon() { // null geometry - QVector< QgsPointXY > points = QgsGeometry().randomPointsInPolygon( 100 ); + QVector points = QgsGeometry().randomPointsInPolygon( 100 ); QVERIFY( points.empty() ); // not polygon geometry @@ -2870,9 +2842,9 @@ void TestQgsGeometry::testRandomPointsInPolygon() // with seed g = QgsGeometry::fromWkt( QStringLiteral( "MultiPolygon((( 5 15, 10 15, 10 20, 5 20, 5 15 ), (6 16, 8 16, 8 18, 6 16 )), (( 105 115, 110 115, 110 120, 105 120, 105 115 ), (106 116, 108 116, 108 118, 106 116 )))" ) ); - QVector< QgsPointXY > points1 = g.randomPointsInPolygon( 100, 200 ); + QVector points1 = g.randomPointsInPolygon( 100, 200 ); QCOMPARE( points1.count(), 100 ); - QVector< QgsPointXY > points2 = g.randomPointsInPolygon( 100, 200 ); + QVector points2 = g.randomPointsInPolygon( 100, 200 ); QCOMPARE( points2.count(), 100 ); QCOMPARE( points1, points2 ); @@ -2884,8 +2856,7 @@ void TestQgsGeometry::testRandomPointsInPolygon() QVERIFY( points1 != points2 ); // with filter - points = g.randomPointsInPolygon( 10000, []( const QgsPointXY & p )->bool - { + points = g.randomPointsInPolygon( 10000, []( const QgsPointXY &p ) -> bool { return p.x() > 100; } ); QCOMPARE( points.count(), 10000 ); @@ -2912,13 +2883,13 @@ void TestQgsGeometry::wktParser() // extra parentheses QVERIFY( QgsPoint().fromWkt( "POINT ( (5 1) )" ) ); // not a number - QVERIFY( ! QgsPoint().fromWkt( "POINT (a, b)" ) ); - QVERIFY( ! QgsPoint().fromWkt( "POINT (a b)" ) ); - QVERIFY( ! QgsPoint().fromWkt( "POINT((0, 1)" ) ); - QVERIFY( ! QgsPoint().fromWkt( "POINT(0, 1) )" ) ); - QVERIFY( ! QgsPoint().fromWkt( "POINT ((0, 1)" ) ); - QVERIFY( ! QgsPoint().fromWkt( "POINT (0, 1) )" ) ); - QVERIFY( ! QgsPoint().fromWkt( "POINT ( (5, 1) )" ) ); + QVERIFY( !QgsPoint().fromWkt( "POINT (a, b)" ) ); + QVERIFY( !QgsPoint().fromWkt( "POINT (a b)" ) ); + QVERIFY( !QgsPoint().fromWkt( "POINT((0, 1)" ) ); + QVERIFY( !QgsPoint().fromWkt( "POINT(0, 1) )" ) ); + QVERIFY( !QgsPoint().fromWkt( "POINT ((0, 1)" ) ); + QVERIFY( !QgsPoint().fromWkt( "POINT (0, 1) )" ) ); + QVERIFY( !QgsPoint().fromWkt( "POINT ( (5, 1) )" ) ); // valid QgsPoint p; @@ -2941,7 +2912,7 @@ void TestQgsGeometry::wktParser() QVERIFY( p.fromWkt( "POINT ( )" ) ); QCOMPARE( p.asWkt(), QStringLiteral( "Point EMPTY" ) ); - QVERIFY( ! p.fromWkt( "POINT (a, b)" ) ); + QVERIFY( !p.fromWkt( "POINT (a, b)" ) ); QCOMPARE( p.asWkt(), QStringLiteral( "Point EMPTY" ) ); // LINESTRING QVERIFY( QgsLineString().fromWkt( "LineString(0 1, 1 2) )" ) ); @@ -2951,10 +2922,10 @@ void TestQgsGeometry::wktParser() QVERIFY( QgsMultiLineString().fromWkt( "MULTILINESTRING ((((1 2, 2 4, 4 5))" ) ); QVERIFY( QgsMultiLineString().fromWkt( "MULTILINESTRING((((1 2, 2 4, 4 5))" ) ); // not a number - QVERIFY( ! QgsLineString().fromWkt( "LineString(0, 1) )" ) ); - QVERIFY( ! QgsLineString().fromWkt( "LineString (0, 1) )" ) ); - QVERIFY( ! QgsLineString().fromWkt( "LineString (a b, 3 4)" ) ); - QVERIFY( ! QgsMultiLineString().fromWkt( "MULTILINESTRING ((1 2, 2 a, 4 b))" ) ); + QVERIFY( !QgsLineString().fromWkt( "LineString(0, 1) )" ) ); + QVERIFY( !QgsLineString().fromWkt( "LineString (0, 1) )" ) ); + QVERIFY( !QgsLineString().fromWkt( "LineString (a b, 3 4)" ) ); + QVERIFY( !QgsMultiLineString().fromWkt( "MULTILINESTRING ((1 2, 2 a, 4 b))" ) ); // valid QgsLineString l; QVERIFY( l.fromWkt( "LINESTRING ( 1 2, 3 4 )" ) ); @@ -2970,12 +2941,12 @@ void TestQgsGeometry::wktParser() // empty QVERIFY( l.fromWkt( "LINESTRING ( )" ) ); QCOMPARE( l.asWkt(), QStringLiteral( "LineString EMPTY" ) ); - QVERIFY( ! l.fromWkt( "LINESTRING ( a b, 2 3 )" ) ); + QVERIFY( !l.fromWkt( "LINESTRING ( a b, 2 3 )" ) ); QCOMPARE( l.asWkt(), QStringLiteral( "LineString EMPTY" ) ); QVERIFY( l.fromWkt( "LINESTRING ( 1e4 -2, 3 +4.5 )" ) ); QCOMPARE( l.asWkt( 1 ), QStringLiteral( "LineString (10000 -2, 3 4.5)" ) ); QgsMultiLineString m; - m.fromWkt( "MULTILINESTRING ((1 2, 2 3, 4 5))" ) ; + m.fromWkt( "MULTILINESTRING ((1 2, 2 3, 4 5))" ); QVERIFY( m.fromWkt( "MULTILINESTRING ((1 2, 2 3, 4 5))" ) ); QCOMPARE( m.asWkt( 1 ), QStringLiteral( "MultiLineString ((1 2, 2 3, 4 5))" ) ); @@ -2983,15 +2954,15 @@ void TestQgsGeometry::wktParser() // unbalanced parenthesis QVERIFY( QgsTriangle().fromWkt( "Triangle( (0 1, 1 2, 3 3) )) " ) ); QVERIFY( QgsTriangle().fromWkt( "Triangle ( (0 1, 1 2, 3 3) )) " ) ); - QVERIFY( ! QgsTriangle().fromWkt( "Triangle(0 1, 1 2, 3 3) )" ) ); - QVERIFY( ! QgsTriangle().fromWkt( "Triangle (0 1, 1 2, 3 3) )" ) ); + QVERIFY( !QgsTriangle().fromWkt( "Triangle(0 1, 1 2, 3 3) )" ) ); + QVERIFY( !QgsTriangle().fromWkt( "Triangle (0 1, 1 2, 3 3) )" ) ); // not a number - QVERIFY( ! QgsTriangle().fromWkt( "Triangle ( (0 a, b 2, 3 3 )) " ) ); - QVERIFY( ! QgsTriangle().fromWkt( "Triangle ( (0 a, b 2, 3 3, 0 a )) " ) ); + QVERIFY( !QgsTriangle().fromWkt( "Triangle ( (0 a, b 2, 3 3 )) " ) ); + QVERIFY( !QgsTriangle().fromWkt( "Triangle ( (0 a, b 2, 3 3, 0 a )) " ) ); // incorrect number of points - QVERIFY( ! QgsTriangle().fromWkt( "Triangle (( 0 0, 1 1))" ) ); - QVERIFY( ! QgsTriangle().fromWkt( "Triangle (( 0 0, 1 1, 1 0, 2 3, 4 5))" ) ); - QVERIFY( ! QgsTriangle().fromWkt( "Triangle (( 0 1, 2 3, 3 4, 1 0))" ) ); // four points but start and last points are different + QVERIFY( !QgsTriangle().fromWkt( "Triangle (( 0 0, 1 1))" ) ); + QVERIFY( !QgsTriangle().fromWkt( "Triangle (( 0 0, 1 1, 1 0, 2 3, 4 5))" ) ); + QVERIFY( !QgsTriangle().fromWkt( "Triangle (( 0 1, 2 3, 3 4, 1 0))" ) ); // four points but start and last points are different // valid QgsTriangle t; QVERIFY( t.fromWkt( "TRIANGLE(( 0 1, 2 3, 3 4))" ) ); @@ -3000,11 +2971,11 @@ void TestQgsGeometry::wktParser() QCOMPARE( t.asWkt(), QStringLiteral( "Triangle ((0 1, 2 3, 3 4, 0 1))" ) ); QVERIFY( t.fromWkt( "TRIANGLE(( 0 1, 2 3, 3 4, 0 1))" ) ); QCOMPARE( t.asWkt(), QStringLiteral( "Triangle ((0 1, 2 3, 3 4, 0 1))" ) ); - QVERIFY( ! t.fromWkt( "TRIANGLE(( 0 1, 2 3, 3 4, 0 3))" ) ); + QVERIFY( !t.fromWkt( "TRIANGLE(( 0 1, 2 3, 3 4, 0 3))" ) ); QCOMPARE( t.asWkt(), QStringLiteral( "Triangle EMPTY" ) ); - QVERIFY( ! t.fromWkt( "TRIANGLE(( 0 1, 2 3, 3 4, 0 3, 4 5))" ) ); + QVERIFY( !t.fromWkt( "TRIANGLE(( 0 1, 2 3, 3 4, 0 3, 4 5))" ) ); QCOMPARE( t.asWkt(), QStringLiteral( "Triangle EMPTY" ) ); - QVERIFY( ! t.fromWkt( "TRIANGLE(( 0 1, 2 3 ))" ) ); + QVERIFY( !t.fromWkt( "TRIANGLE(( 0 1, 2 3 ))" ) ); QCOMPARE( t.asWkt(), QStringLiteral( "Triangle EMPTY" ) ); QVERIFY( t.fromWkt( "TRIANGLE((0 1e3, -2 3, +3 4, 0 1e3))" ) ); QCOMPARE( t.asWkt(), QStringLiteral( "Triangle ((0 1000, -2 3, 3 4, 0 1000))" ) ); @@ -3013,11 +2984,11 @@ void TestQgsGeometry::wktParser() // unbalanced parenthesis QVERIFY( QgsPolygon().fromWkt( "Polygon( (0 1, 1 2, 3 3) )) " ) ); QVERIFY( QgsPolygon().fromWkt( "Polygon ( (0 1, 1 2, 3 3) )) " ) ); - QVERIFY( ! QgsPolygon().fromWkt( "Polygon(0 1, 1 2, 3 3) )" ) ); - QVERIFY( ! QgsPolygon().fromWkt( "Polygon (0 1, 1 2, 3 3) )" ) ); + QVERIFY( !QgsPolygon().fromWkt( "Polygon(0 1, 1 2, 3 3) )" ) ); + QVERIFY( !QgsPolygon().fromWkt( "Polygon (0 1, 1 2, 3 3) )" ) ); // not a number - QVERIFY( ! QgsPolygon().fromWkt( "Polygon ( (0 a, b 2, 3 3 )) " ) ); - QVERIFY( ! QgsPolygon().fromWkt( "Polygon ( (0 a, b 2, 3 3, 0 a )) " ) ); + QVERIFY( !QgsPolygon().fromWkt( "Polygon ( (0 a, b 2, 3 3 )) " ) ); + QVERIFY( !QgsPolygon().fromWkt( "Polygon ( (0 a, b 2, 3 3, 0 a )) " ) ); // valid QgsPolygon poly; QVERIFY( poly.fromWkt( "Polygon(( 0 1, 2 3, 3 4))" ) ); @@ -3034,8 +3005,8 @@ void TestQgsGeometry::wktParser() QVERIFY( QgsCircularString().fromWkt( "CircularString( (0 1, 1 2, 3 3) )) " ) ); QVERIFY( QgsCircularString().fromWkt( "CircularString ( (0 1, 1 2, 3 3) )) " ) ); // not a number - QVERIFY( ! QgsCircularString().fromWkt( "CircularString (0 a, b 2, 3 3) " ) ); - QVERIFY( ! QgsCircularString().fromWkt( "CircularString (0 a, b 2, 3 3, 0 a) " ) ); + QVERIFY( !QgsCircularString().fromWkt( "CircularString (0 a, b 2, 3 3) " ) ); + QVERIFY( !QgsCircularString().fromWkt( "CircularString (0 a, b 2, 3 3, 0 a) " ) ); // valid QgsCircularString c; QVERIFY( c.fromWkt( "CircularString( 0 1, 2 3, 3 4)" ) ); @@ -3048,9 +3019,9 @@ void TestQgsGeometry::wktParser() // multipoint QgsMultiPoint mp; - QVERIFY( ! mp.fromWkt( "MULTIPOINT (((10 40), (40 30), (20 20), (30 10))" ) ); - QVERIFY( ! mp.fromWkt( "MULTIPOINT (((10 40), (40 30), (xx20 20), (30 10))" ) ); - QVERIFY( ! mp.fromWkt( "MULTIPOINT ((10 40, 40 30, 20 20, 30 10)" ) ); + QVERIFY( !mp.fromWkt( "MULTIPOINT (((10 40), (40 30), (20 20), (30 10))" ) ); + QVERIFY( !mp.fromWkt( "MULTIPOINT (((10 40), (40 30), (xx20 20), (30 10))" ) ); + QVERIFY( !mp.fromWkt( "MULTIPOINT ((10 40, 40 30, 20 20, 30 10)" ) ); QVERIFY( mp.fromWkt( "MULTIPOINT ((10 40), (40 30), (20 20), (30 10))))" ) ); QVERIFY( mp.fromWkt( "MULTIPOINT ( )" ) ); QVERIFY( mp.fromWkt( "MULTIPOINT EMPTY" ) ); @@ -3070,7 +3041,7 @@ void TestQgsGeometry::wktParser() // compoundcurve QgsCompoundCurve cc; - QVERIFY( ! cc.fromWkt( "COMPOUNDCURVE((CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); + QVERIFY( !cc.fromWkt( "COMPOUNDCURVE((CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); QVERIFY( cc.fromWkt( "COMPOUNDCURVE(CIRCULARSTRING( 0 0, 1 1, 2 2)))" ) ); QCOMPARE( cc.asWkt(), QStringLiteral( "CompoundCurve (CircularString (0 0, 1 1, 2 2))" ) ); QVERIFY( cc.fromWkt( "COMPOUNDCURVE(CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); @@ -3097,7 +3068,7 @@ void TestQgsGeometry::wktParser() QCOMPARE( gc.asWkt(), QStringLiteral( "GeometryCollection EMPTY" ) ); // curvepolygon QgsCurvePolygon cp; - QVERIFY( ! cp.fromWkt( "CurvePolygon((CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); + QVERIFY( !cp.fromWkt( "CurvePolygon((CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); QVERIFY( cp.fromWkt( "CurvePolygon(CIRCULARSTRING( 0 0, 1 1, 2 2)))" ) ); QCOMPARE( cp.asWkt(), QStringLiteral( "CurvePolygon (CircularString (0 0, 1 1, 2 2))" ) ); QVERIFY( cp.fromWkt( "CurvePolygon(CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); @@ -3110,7 +3081,7 @@ void TestQgsGeometry::wktParser() QCOMPARE( cp.asWkt(), QStringLiteral( "CurvePolygon EMPTY" ) ); // multicurve QgsMultiCurve mc; - QVERIFY( ! mc.fromWkt( "MultiCurve((CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); + QVERIFY( !mc.fromWkt( "MultiCurve((CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); QVERIFY( mc.fromWkt( "MultiCurve(CIRCULARSTRING( 0 0, 1 1, 2 2)))" ) ); QCOMPARE( mc.asWkt(), QStringLiteral( "MultiCurve (CircularString (0 0, 1 1, 2 2))" ) ); QVERIFY( mc.fromWkt( "MultiCurve(CIRCULARSTRING( 0 0, 1 1, 2 2))" ) ); @@ -3123,7 +3094,7 @@ void TestQgsGeometry::wktParser() QCOMPARE( mc.asWkt(), QStringLiteral( "MultiCurve EMPTY" ) ); // multisurface QgsMultiSurface ms; - QVERIFY( ! ms.fromWkt( "MultiSurface((Polygon( 0 0, 1 1, 2 2))" ) ); + QVERIFY( !ms.fromWkt( "MultiSurface((Polygon( 0 0, 1 1, 2 2))" ) ); QVERIFY( ms.fromWkt( "MultiSurface(Polygon(( 0 0, 1 1, 2 2)))" ) ); QCOMPARE( ms.asWkt(), QStringLiteral( "MultiSurface (Polygon ((0 0, 1 1, 2 2)))" ) ); QVERIFY( ms.fromWkt( "MultiSurface(Polygon(( 0 0, 1 1, 2 2)))" ) ); @@ -3136,7 +3107,7 @@ void TestQgsGeometry::wktParser() QCOMPARE( ms.asWkt(), QStringLiteral( "MultiSurface EMPTY" ) ); // multipolygon QgsMultiPolygon mpoly; - QVERIFY( ! mpoly.fromWkt( "MultiPolygon((Polygon( 0 0, 1 1, 2 2))" ) ); + QVERIFY( !mpoly.fromWkt( "MultiPolygon((Polygon( 0 0, 1 1, 2 2))" ) ); QVERIFY( mpoly.fromWkt( "MultiPolygon(Polygon(( 0 0, 1 1, 2 2)))" ) ); QCOMPARE( mpoly.asWkt(), QStringLiteral( "MultiPolygon (((0 0, 1 1, 2 2)))" ) ); QVERIFY( mpoly.fromWkt( "MultiPolygon(Polygon(( 0 0, 1 1, 2 2)))" ) ); @@ -3150,7 +3121,7 @@ void TestQgsGeometry::wktParser() // multilinestring QgsMultiLineString mline; - QVERIFY( ! mline.fromWkt( "MultiLineString((LineString( 0 0, 1 1, 2 2))" ) ); + QVERIFY( !mline.fromWkt( "MultiLineString((LineString( 0 0, 1 1, 2 2))" ) ); QVERIFY( mline.fromWkt( "MultiLineString(LineString(( 0 0, 1 1, 2 2)))" ) ); QCOMPARE( mline.asWkt(), QStringLiteral( "MultiLineString ((0 0, 1 1, 2 2))" ) ); QVERIFY( mline.fromWkt( "MultiLineString(LineString(( 0 0, 1 1, 2 2)))" ) ); diff --git a/tests/src/core/geometry/testqgsgeometrycollection.cpp b/tests/src/core/geometry/testqgsgeometrycollection.cpp index 73ce3c4a1b7d..9a730dac4b21 100644 --- a/tests/src/core/geometry/testqgsgeometrycollection.cpp +++ b/tests/src/core/geometry/testqgsgeometrycollection.cpp @@ -29,7 +29,7 @@ #include "testgeometryutils.h" #include "testtransformer.h" -class TestQgsGeometryCollection: public QObject +class TestQgsGeometryCollection : public QObject { Q_OBJECT private slots: @@ -79,8 +79,7 @@ void TestQgsGeometryCollection::geometryCollection() //valid geometry QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); c1.addGeometry( part.clone() ); QVERIFY( !c1.isEmpty() ); QCOMPARE( c1.numGeometries(), 1 ); @@ -103,12 +102,10 @@ void TestQgsGeometryCollection::geometryCollection() QCOMPARE( c1.vertexCount( 1, 0 ), 0 ); //retrieve geometry and check - QCOMPARE( *( static_cast< const QgsLineString * >( c1.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( c1.geometryN( 0 ) ) ), part ); //initial adding of geometry should set z/m type - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); QgsGeometryCollection c2; c2.addGeometry( part.clone() ); //QVERIFY( c2.is3D() ); //no meaning for collections? @@ -116,59 +113,46 @@ void TestQgsGeometryCollection::geometryCollection() QCOMPARE( c2.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( c2.wktTypeStr(), QString( "GeometryCollection" ) ); QCOMPARE( c2.geometryType(), QString( "GeometryCollection" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( c2.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( c2.geometryN( 0 ) ) ), part ); QgsGeometryCollection c3; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); c3.addGeometry( part.clone() ); //QVERIFY( !c3.is3D() ); //no meaning for collections? //QVERIFY( c3.isMeasure() ); //no meaning for collections? QCOMPARE( c3.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( c3.wktTypeStr(), QString( "GeometryCollection" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( c3.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( c3.geometryN( 0 ) ) ), part ); QgsGeometryCollection c4; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 5, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 5, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) ); c4.addGeometry( part.clone() ); //QVERIFY( c4.is3D() ); //no meaning for collections? //QVERIFY( c4.isMeasure() ); //no meaning for collections? QCOMPARE( c4.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( c4.wktTypeStr(), QString( "GeometryCollection" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( c4.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( c4.geometryN( 0 ) ) ), part ); //add another part QgsGeometryCollection c6; - part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); c6.addGeometry( part.clone() ); QCOMPARE( c6.vertexCount( 0, 0 ), 5 ); - part.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); c6.addGeometry( part.clone() ); QCOMPARE( c6.vertexCount( 1, 0 ), 5 ); QCOMPARE( c6.numGeometries(), 2 ); QVERIFY( c6.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsLineString * >( c6.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( c6.geometryN( 1 ) ), part ); QgsCoordinateSequence seq = c6.coordinateSequence(); - QCOMPARE( seq, QgsCoordinateSequence() << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ) ) - << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ) ) ); + QCOMPARE( seq, QgsCoordinateSequence() << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ) ) << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ) ) ); QCOMPARE( c6.nCoordinates(), 10 ); //clear QgsGeometryCollection c7; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); c7.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); c7.addGeometry( part.clone() ); QCOMPARE( c7.numGeometries(), 2 ); c7.clear(); @@ -183,21 +167,17 @@ void TestQgsGeometryCollection::geometryCollection() //clone QgsGeometryCollection c11; - std::unique_ptr< QgsGeometryCollection >cloned( c11.clone() ); + std::unique_ptr cloned( c11.clone() ); QVERIFY( cloned->isEmpty() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); c11.addGeometry( part.clone() ); QgsLineString part2; - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); c11.addGeometry( part2.clone() ); cloned.reset( c11.clone() ); QCOMPARE( cloned->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( cloned->geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( cloned->geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( cloned->geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( cloned->geometryN( 1 ) ), part2 ); //equality QgsGeometryCollection emptyCollection; @@ -209,15 +189,11 @@ void TestQgsGeometryCollection::geometryCollection() QgsMultiPoint mp; QgsMultiLineString ml; QVERIFY( mp != ml ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); ml.addGeometry( part.clone() ); QgsMultiLineString ml2; QVERIFY( ml != ml2 ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); ml2.addGeometry( part.clone() ); QVERIFY( ml != ml2 ); @@ -226,17 +202,17 @@ void TestQgsGeometryCollection::geometryCollection() QVERIFY( ml2 == ml3 ); //toCurveType - std::unique_ptr< QgsGeometryCollection > curveType( c11.toCurveType() ); + std::unique_ptr curveType( c11.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( curveType->numGeometries(), 2 ); - const QgsCompoundCurve *curve = static_cast< const QgsCompoundCurve * >( curveType->geometryN( 0 ) ); + const QgsCompoundCurve *curve = static_cast( curveType->geometryN( 0 ) ); QCOMPARE( curve->numPoints(), 5 ); QCOMPARE( curve->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) ); QCOMPARE( curve->vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) ); QCOMPARE( curve->vertexAt( QgsVertexId( 0, 0, 2 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); QCOMPARE( curve->vertexAt( QgsVertexId( 0, 0, 3 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); QCOMPARE( curve->vertexAt( QgsVertexId( 0, 0, 4 ) ), QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); - curve = static_cast< const QgsCompoundCurve * >( curveType->geometryN( 1 ) ); + curve = static_cast( curveType->geometryN( 1 ) ); QCOMPARE( curve->numPoints(), 5 ); QCOMPARE( curve->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) ); QCOMPARE( curve->vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) ); @@ -246,13 +222,9 @@ void TestQgsGeometryCollection::geometryCollection() //to/fromWKB QgsGeometryCollection c16; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); c16.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); c16.addGeometry( part2.clone() ); QByteArray wkb16 = c16.asWkb(); QCOMPARE( wkb16.size(), c16.wkbSize() ); @@ -260,63 +232,51 @@ void TestQgsGeometryCollection::geometryCollection() QgsConstWkbPtr wkb16ptr( wkb16 ); c17.fromWkb( wkb16ptr ); QCOMPARE( c17.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( c17.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( c17.geometryN( 1 ) ), part2 ); //parts with Z c16.clear(); c17.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); c16.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); c16.addGeometry( part2.clone() ); wkb16 = c16.asWkb(); QgsConstWkbPtr wkb16ptr2( wkb16 ); c17.fromWkb( wkb16ptr2 ); QCOMPARE( c17.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( c17.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( c17.geometryN( 1 ) ), part2 ); //parts with m c16.clear(); c17.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); c16.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 9, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 9, 9, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 1, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1, 9, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 9, 9, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 9, 1, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) ); c16.addGeometry( part2.clone() ); wkb16 = c16.asWkb(); QgsConstWkbPtr wkb16ptr3( wkb16 ); c17.fromWkb( wkb16ptr3 ); QCOMPARE( c17.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( c17.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( c17.geometryN( 1 ) ), part2 ); // parts with ZM c16.clear(); c17.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); c16.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); c16.addGeometry( part2.clone() ); wkb16 = c16.asWkb(); QgsConstWkbPtr wkb16ptr4( wkb16 ); c17.fromWkb( wkb16ptr4 ); QCOMPARE( c17.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c17.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( c17.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( c17.geometryN( 1 ) ), part2 ); //bad WKB - check for no crash @@ -332,13 +292,9 @@ void TestQgsGeometryCollection::geometryCollection() //to/from WKT QgsGeometryCollection c18; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); c18.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); c18.addGeometry( part2.clone() ); QString wkt = c18.asWkt(); @@ -346,8 +302,8 @@ void TestQgsGeometryCollection::geometryCollection() QgsGeometryCollection c19; QVERIFY( c19.fromWkt( wkt ) ); QCOMPARE( c19.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c19.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c19.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( c19.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( c19.geometryN( 1 ) ), part2 ); //bad WKT QgsGeometryCollection c20; @@ -358,9 +314,7 @@ void TestQgsGeometryCollection::geometryCollection() //as JSON QgsGeometryCollection exportC; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); exportC.addGeometry( part.clone() ); // GML document for compare @@ -386,9 +340,7 @@ void TestQgsGeometryCollection::geometryCollection() res = exportC.asJson(); QCOMPARE( res, expectedSimpleJson ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); exportC.addGeometry( part.clone() ); QString expectedJson( "{\"geometries\":[{\"coordinates\":[[0.0,0.0],[0.0,10.0],[10.0,10.0],[10.0,0.0],[0.0,0.0]],\"type\":\"LineString\"},{\"coordinates\":[[1.0,1.0],[1.0,9.0],[9.0,9.0],[9.0,1.0],[1.0,1.0]],\"type\":\"LineString\"}],\"type\":\"GeometryCollection\"}" ); @@ -396,13 +348,9 @@ void TestQgsGeometryCollection::geometryCollection() QCOMPARE( res, expectedJson ); QgsGeometryCollection exportFloat; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 100 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 100 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 10 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 100 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 100 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 10 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) ); exportFloat.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 4 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 4 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 2 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 4 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 4 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 2 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) ); exportFloat.addGeometry( part.clone() ); QString expectedJsonPrec3( "{\"geometries\":[{\"coordinates\":[[1.111,1.111],[1.111,11.111],[11.111,11.111],[11.111,1.111],[1.111,1.111]],\"type\":\"LineString\"},{\"coordinates\":[[0.667,0.667],[0.667,1.333],[1.333,1.333],[1.333,0.667],[0.667,0.667]],\"type\":\"LineString\"}],\"type\":\"GeometryCollection\"}" ); @@ -438,13 +386,9 @@ void TestQgsGeometryCollection::geometryCollection() rc.removeGeometry( -1 ); rc.removeGeometry( 0 ); rc.removeGeometry( 100 ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); rc.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); rc.addGeometry( part2.clone() ); // no crash rc.removeGeometry( -1 ); @@ -452,12 +396,12 @@ void TestQgsGeometryCollection::geometryCollection() rc.removeGeometry( 0 ); QCOMPARE( rc.numGeometries(), 1 ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 0 ) ), part2 ); + QCOMPARE( *static_cast( rc.geometryN( 0 ) ), part2 ); rc.addGeometry( part.clone() ); rc.removeGeometry( 1 ); QCOMPARE( rc.numGeometries(), 1 ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 0 ) ), part2 ); + QCOMPARE( *static_cast( rc.geometryN( 0 ) ), part2 ); rc.removeGeometry( 0 ); QCOMPARE( rc.numGeometries(), 0 ); @@ -476,21 +420,21 @@ void TestQgsGeometryCollection::geometryCollection() rc.insertGeometry( part.clone(), 0 ); QCOMPARE( rc.numGeometries(), 1 ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( rc.geometryN( 0 ) ), part ); rc.insertGeometry( part2.clone(), 0 ); QCOMPARE( rc.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 0 ) ), part2 ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( rc.geometryN( 0 ) ), part2 ); + QCOMPARE( *static_cast( rc.geometryN( 1 ) ), part ); rc.removeGeometry( 0 ); rc.insertGeometry( part2.clone(), 1 ); QCOMPARE( rc.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( rc.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( rc.geometryN( 1 ) ), part2 ); rc.removeGeometry( 1 ); rc.insertGeometry( part2.clone(), 2 ); QCOMPARE( rc.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( rc.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( rc.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( rc.geometryN( 1 ) ), part2 ); // cast QVERIFY( !QgsGeometryCollection().cast( nullptr ) ); @@ -513,21 +457,18 @@ void TestQgsGeometryCollection::geometryCollection() // 2d CRS transform QgsGeometryCollection pTransform; QgsLineString l21; - l21.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) - << QgsPoint( 6274985, -3526584 ) - << QgsPoint( 6474985, -3526584 ) - << QgsPoint( 6374985, -3626584 ) ); + l21.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) << QgsPoint( 6274985, -3526584 ) << QgsPoint( 6474985, -3526584 ) << QgsPoint( 6374985, -3626584 ) ); pTransform.addGeometry( l21.clone() ); pTransform.addGeometry( l21.clone() ); pTransform.transform( tr, Qgis::TransformDirection::Forward ); - const QgsLineString *extR = static_cast< const QgsLineString * >( pTransform.geometryN( 0 ) ); + const QgsLineString *extR = static_cast( pTransform.geometryN( 0 ) ); QGSCOMPARENEAR( extR->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( extR->pointN( 0 ).y(), -39.724, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( extR->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( extR->pointN( 1 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( extR->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( extR->pointN( 2 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( extR->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( extR->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( extR->boundingBox().xMinimum(), 174.581448, 0.001 ); QGSCOMPARENEAR( extR->boundingBox().yMinimum(), -39.724, 0.001 ); @@ -539,14 +480,14 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( extR->boundingBox3D().xMaximum(), 176.959, 0.001 ); QGSCOMPARENEAR( extR->boundingBox3D().yMaximum(), -38.7999, 0.001 ); QGSCOMPARENEAR( extR->boundingBox3D().zMaximum(), std::numeric_limits::quiet_NaN(), 0.001 ); - const QgsLineString *intR = static_cast< const QgsLineString * >( pTransform.geometryN( 1 ) ); + const QgsLineString *intR = static_cast( pTransform.geometryN( 1 ) ); QGSCOMPARENEAR( intR->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( intR->pointN( 0 ).y(), -39.724, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( intR->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( intR->pointN( 1 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( intR->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( intR->pointN( 2 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( intR->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( intR->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( intR->boundingBox().xMinimum(), 174.581448, 0.001 ); QGSCOMPARENEAR( intR->boundingBox().yMinimum(), -39.724, 0.001 ); @@ -561,28 +502,25 @@ void TestQgsGeometryCollection::geometryCollection() //3d CRS transform QgsLineString l22; - l22.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); + l22.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); pTransform.clear(); pTransform.addGeometry( l22.clone() ); pTransform.addGeometry( l22.clone() ); pTransform.transform( tr, Qgis::TransformDirection::Forward ); - extR = static_cast< const QgsLineString * >( pTransform.geometryN( 0 ) ); + extR = static_cast( pTransform.geometryN( 0 ) ); QGSCOMPARENEAR( extR->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( extR->pointN( 0 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( extR->pointN( 0 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 0 ).m(), 2.0, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( extR->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( extR->pointN( 1 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( extR->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( extR->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( extR->pointN( 2 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( extR->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( extR->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( extR->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( extR->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 3 ).m(), 2.0, 0.001 ); @@ -596,20 +534,20 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( extR->boundingBox3D().xMaximum(), 176.959, 0.001 ); QGSCOMPARENEAR( extR->boundingBox3D().yMaximum(), -38.7999, 0.001 ); QGSCOMPARENEAR( extR->boundingBox3D().zMaximum(), 5.0, 0.001 ); - intR = static_cast< const QgsLineString * >( pTransform.geometryN( 1 ) ); + intR = static_cast( pTransform.geometryN( 1 ) ); QGSCOMPARENEAR( intR->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( intR->pointN( 0 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( intR->pointN( 0 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 0 ).m(), 2.0, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( intR->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( intR->pointN( 1 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( intR->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( intR->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( intR->pointN( 2 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( intR->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( intR->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( intR->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( intR->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 3 ).m(), 2.0, 0.001 ); @@ -626,7 +564,7 @@ void TestQgsGeometryCollection::geometryCollection() //reverse transform pTransform.transform( tr, Qgis::TransformDirection::Reverse ); - extR = static_cast< const QgsLineString * >( pTransform.geometryN( 0 ) ); + extR = static_cast( pTransform.geometryN( 0 ) ); QGSCOMPARENEAR( extR->pointN( 0 ).x(), 6374984, 100 ); QGSCOMPARENEAR( extR->pointN( 0 ).y(), -3626584, 100 ); QGSCOMPARENEAR( extR->pointN( 0 ).z(), 1.0, 0.001 ); @@ -635,11 +573,11 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( extR->pointN( 1 ).y(), -3526584, 100 ); QGSCOMPARENEAR( extR->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 2 ).x(), 6474984, 100 ); + QGSCOMPARENEAR( extR->pointN( 2 ).x(), 6474984, 100 ); QGSCOMPARENEAR( extR->pointN( 2 ).y(), -3526584, 100 ); QGSCOMPARENEAR( extR->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 3 ).x(), 6374984, 100 ); + QGSCOMPARENEAR( extR->pointN( 3 ).x(), 6374984, 100 ); QGSCOMPARENEAR( extR->pointN( 3 ).y(), -3626584, 100 ); QGSCOMPARENEAR( extR->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 3 ).m(), 2.0, 0.001 ); @@ -653,7 +591,7 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( extR->boundingBox3D().xMaximum(), 6474984, 100 ); QGSCOMPARENEAR( extR->boundingBox3D().yMaximum(), -3526584, 100 ); QGSCOMPARENEAR( extR->boundingBox3D().zMaximum(), 5.0, 0.001 ); - intR = static_cast< const QgsLineString * >( pTransform.geometryN( 1 ) ); + intR = static_cast( pTransform.geometryN( 1 ) ); QGSCOMPARENEAR( intR->pointN( 0 ).x(), 6374984, 100 ); QGSCOMPARENEAR( intR->pointN( 0 ).y(), -3626584, 100 ); QGSCOMPARENEAR( intR->pointN( 0 ).z(), 1.0, 0.001 ); @@ -662,11 +600,11 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( intR->pointN( 1 ).y(), -3526584, 100 ); QGSCOMPARENEAR( intR->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 2 ).x(), 6474984, 100 ); + QGSCOMPARENEAR( intR->pointN( 2 ).x(), 6474984, 100 ); QGSCOMPARENEAR( intR->pointN( 2 ).y(), -3526584, 100 ); QGSCOMPARENEAR( intR->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 3 ).x(), 6374984, 100 ); + QGSCOMPARENEAR( intR->pointN( 3 ).x(), 6374984, 100 ); QGSCOMPARENEAR( intR->pointN( 3 ).y(), -3626584, 100 ); QGSCOMPARENEAR( intR->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 3 ).m(), 2.0, 0.001 ); @@ -710,16 +648,13 @@ void TestQgsGeometryCollection::geometryCollection() //QTransform transform QTransform qtr = QTransform::fromScale( 2, 3 ); QgsLineString l23; - l23.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 12, 23, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); + l23.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 12, 23, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); QgsGeometryCollection pTransform2; pTransform2.addGeometry( l23.clone() ); pTransform2.addGeometry( l23.clone() ); pTransform2.transform( qtr, 3, 2, 6, 3 ); - extR = static_cast< const QgsLineString * >( pTransform2.geometryN( 0 ) ); + extR = static_cast( pTransform2.geometryN( 0 ) ); QGSCOMPARENEAR( extR->pointN( 0 ).x(), 2, 100 ); QGSCOMPARENEAR( extR->pointN( 0 ).y(), 6, 100 ); QGSCOMPARENEAR( extR->pointN( 0 ).z(), 9.0, 0.001 ); @@ -728,7 +663,7 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( extR->pointN( 1 ).y(), 36, 100 ); QGSCOMPARENEAR( extR->pointN( 1 ).z(), 29.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 1 ).m(), 48.0, 0.001 ); - QGSCOMPARENEAR( extR->pointN( 2 ).x(), 2, 100 ); + QGSCOMPARENEAR( extR->pointN( 2 ).x(), 2, 100 ); QGSCOMPARENEAR( extR->pointN( 2 ).y(), 36, 100 ); QGSCOMPARENEAR( extR->pointN( 2 ).z(), 49.0, 0.001 ); QGSCOMPARENEAR( extR->pointN( 2 ).m(), 78.0, 0.001 ); @@ -746,7 +681,7 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( extR->boundingBox3D().xMaximum(), 22, 0.001 ); QGSCOMPARENEAR( extR->boundingBox3D().yMaximum(), 36, 0.001 ); QGSCOMPARENEAR( extR->boundingBox3D().zMaximum(), 49, 0.001 ); - intR = static_cast< const QgsLineString * >( pTransform2.geometryN( 1 ) ); + intR = static_cast( pTransform2.geometryN( 1 ) ); QGSCOMPARENEAR( intR->pointN( 0 ).x(), 2, 100 ); QGSCOMPARENEAR( intR->pointN( 0 ).y(), 6, 100 ); QGSCOMPARENEAR( intR->pointN( 0 ).z(), 9.0, 0.001 ); @@ -755,7 +690,7 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( intR->pointN( 1 ).y(), 36, 100 ); QGSCOMPARENEAR( intR->pointN( 1 ).z(), 29.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 1 ).m(), 48.0, 0.001 ); - QGSCOMPARENEAR( intR->pointN( 2 ).x(), 2, 100 ); + QGSCOMPARENEAR( intR->pointN( 2 ).x(), 2, 100 ); QGSCOMPARENEAR( intR->pointN( 2 ).y(), 36, 100 ); QGSCOMPARENEAR( intR->pointN( 2 ).z(), 49.0, 0.001 ); QGSCOMPARENEAR( intR->pointN( 2 ).m(), 78.0, 0.001 ); @@ -780,7 +715,7 @@ void TestQgsGeometryCollection::geometryCollection() QgsVertexId v; int leftOf = 0; QgsGeometryCollection empty; - ( void )empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty collection, just want no crash + ( void ) empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty collection, just want no crash QgsGeometryCollection p21; QgsLineString p21ls; @@ -791,7 +726,7 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( pt.y(), 11, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( p21.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( p21.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -823,7 +758,7 @@ void TestQgsGeometryCollection::geometryCollection() QGSCOMPARENEAR( pt.y(), 11, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( p21.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( p21.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -919,9 +854,9 @@ void TestQgsGeometryCollection::geometryCollection() p23.dropZValue(); // not z QCOMPARE( p23.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( p23.geometryN( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( p23.geometryN( 1 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with z lp23.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 11, 12, 13 ) << QgsPoint( 1, 12, 23 ) << QgsPoint( 1, 2, 3 ) ); p23.clear(); @@ -930,9 +865,9 @@ void TestQgsGeometryCollection::geometryCollection() p23.dropZValue(); QCOMPARE( p23.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( p23.geometryN( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( p23.geometryN( 1 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm lp23.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); p23.clear(); @@ -941,9 +876,9 @@ void TestQgsGeometryCollection::geometryCollection() p23.dropZValue(); QCOMPARE( p23.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( p23.geometryN( 0 )->wkbType(), Qgis::WkbType::LineStringM ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); QCOMPARE( p23.geometryN( 1 )->wkbType(), Qgis::WkbType::LineStringM ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); // dropMValue @@ -957,20 +892,20 @@ void TestQgsGeometryCollection::geometryCollection() p23.dropMValue(); // not zm QCOMPARE( p23.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( p23.geometryN( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( p23.geometryN( 1 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with m - lp23.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); + lp23.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); p23.clear(); p23.addGeometry( lp23.clone() ); p23.addGeometry( lp23.clone() ); p23.dropMValue(); QCOMPARE( p23.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( p23.geometryN( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( p23.geometryN( 1 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm lp23.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); p23.clear(); @@ -979,20 +914,19 @@ void TestQgsGeometryCollection::geometryCollection() p23.dropMValue(); QCOMPARE( p23.wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( p23.geometryN( 0 )->wkbType(), Qgis::WkbType::LineStringZ ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( p23.geometryN( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); QCOMPARE( p23.geometryN( 1 )->wkbType(), Qgis::WkbType::LineStringZ ); - QCOMPARE( static_cast< const QgsLineString *>( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( p23.geometryN( 1 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); //vertexAngle QgsGeometryCollection p24; - ( void )p24.vertexAngle( QgsVertexId() ); //just want no crash - ( void )p24.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash - ( void )p24.vertexAngle( QgsVertexId( 0, 1, 0 ) ); //just want no crash - ( void )p24.vertexAngle( QgsVertexId( 1, 0, 0 ) ); //just want no crash - ( void )p24.vertexAngle( QgsVertexId( -1, 0, 0 ) ); //just want no crash + ( void ) p24.vertexAngle( QgsVertexId() ); //just want no crash + ( void ) p24.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash + ( void ) p24.vertexAngle( QgsVertexId( 0, 1, 0 ) ); //just want no crash + ( void ) p24.vertexAngle( QgsVertexId( 1, 0, 0 ) ); //just want no crash + ( void ) p24.vertexAngle( QgsVertexId( -1, 0, 0 ) ); //just want no crash QgsLineString l38; - l38.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + l38.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); p24.addGeometry( l38.clone() ); QGSCOMPARENEAR( p24.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 2.35619, 0.00001 ); QGSCOMPARENEAR( p24.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 1.5708, 0.0001 ); @@ -1019,64 +953,63 @@ void TestQgsGeometryCollection::geometryCollection() QVERIFY( !p25.insertVertex( QgsVertexId( 0, 1, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !p25.insertVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( p25.isEmpty() ); - l38.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + l38.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); p25.addGeometry( l38.clone() ); QVERIFY( p25.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 0.3, 0 ) ) ); QCOMPARE( p25.nCoordinates(), 8 ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); QVERIFY( !p25.insertVertex( QgsVertexId( 0, 0, -1 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !p25.insertVertex( QgsVertexId( 0, 0, 100 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !p25.insertVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); // first vertex QVERIFY( p25.insertVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 0, 0.1 ) ) ); QCOMPARE( p25.nCoordinates(), 9 ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 7 ), QgsPoint( 0, 2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 7 ), QgsPoint( 0, 2 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); // last vertex QVERIFY( p25.insertVertex( QgsVertexId( 0, 0, 9 ), QgsPoint( 0.1, 0.1 ) ) ); QCOMPARE( p25.nCoordinates(), 10 ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 0 ) )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 0 ) )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); // with second part p25.addGeometry( l38.clone() ); QCOMPARE( p25.nCoordinates(), 17 ); QVERIFY( p25.insertVertex( QgsVertexId( 1, 0, 1 ), QgsPoint( 0.3, 0 ) ) ); QCOMPARE( p25.nCoordinates(), 18 ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); QVERIFY( !p25.insertVertex( QgsVertexId( 1, 0, -1 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !p25.insertVertex( QgsVertexId( 1, 0, 100 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !p25.insertVertex( QgsVertexId( 2, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); // first vertex in second part QVERIFY( p25.insertVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 0, 0.1 ) ) ); QCOMPARE( p25.nCoordinates(), 19 ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 7 ), QgsPoint( 0, 2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 7 ), QgsPoint( 0, 2 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); // last vertex in second part QVERIFY( p25.insertVertex( QgsVertexId( 1, 0, 9 ), QgsPoint( 0.1, 0.1 ) ) ); QCOMPARE( p25.nCoordinates(), 20 ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p25.geometryN( 1 ) )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 8 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( p25.geometryN( 1 ) )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); //move vertex @@ -1088,35 +1021,34 @@ void TestQgsGeometryCollection::geometryCollection() QVERIFY( p26.isEmpty() ); //valid collection - l38.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + l38.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); p26.addGeometry( l38.clone() ); QVERIFY( p26.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( p26.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); QVERIFY( p26.moveVertex( QgsVertexId( 0, 0, 2 ), QgsPoint( 26.0, 27.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 1, 2 ) ); //out of range QVERIFY( !p26.moveVertex( QgsVertexId( 0, 0, -1 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !p26.moveVertex( QgsVertexId( 0, 0, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !p26.moveVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 3.0, 4.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); // with second part p26.addGeometry( l38.clone() ); QVERIFY( p26.moveVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( p26.moveVertex( QgsVertexId( 1, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); QVERIFY( p26.moveVertex( QgsVertexId( 1, 0, 2 ), QgsPoint( 26.0, 27.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p26.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( p26.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); QVERIFY( !p26.moveVertex( QgsVertexId( 1, 0, -1 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !p26.moveVertex( QgsVertexId( 1, 0, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !p26.moveVertex( QgsVertexId( 2, 0, 0 ), QgsPoint( 3.0, 4.0 ) ) ); @@ -1132,8 +1064,7 @@ void TestQgsGeometryCollection::geometryCollection() QVERIFY( p27.isEmpty() ); //valid collection - l38.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) << QgsPoint( 7, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + l38.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); p27.addGeometry( l38.clone() ); //out of range vertices @@ -1143,26 +1074,26 @@ void TestQgsGeometryCollection::geometryCollection() //valid vertices QVERIFY( p27.deleteVertex( QgsVertexId( 0, 0, 1 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); // delete first vertex QVERIFY( p27.deleteVertex( QgsVertexId( 0, 0, 0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 4 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 4 ), QgsPoint( 1.0, 2.0 ) ); // delete last vertex QVERIFY( p27.deleteVertex( QgsVertexId( 0, 0, 4 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 0 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); // delete some more vertices - should remove part QVERIFY( p27.deleteVertex( QgsVertexId( 0, 0, 0 ) ) ); @@ -1181,26 +1112,26 @@ void TestQgsGeometryCollection::geometryCollection() //valid vertices QVERIFY( p27.deleteVertex( QgsVertexId( 1, 0, 1 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); // delete first vertex QVERIFY( p27.deleteVertex( QgsVertexId( 1, 0, 0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 4 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 4 ), QgsPoint( 1.0, 2.0 ) ); // delete last vertex QVERIFY( p27.deleteVertex( QgsVertexId( 1, 0, 4 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( p27.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( p27.geometryN( 1 ) )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); // delete some more vertices - should remove part QVERIFY( p27.deleteVertex( QgsVertexId( 1, 0, 1 ) ) ); @@ -1237,11 +1168,10 @@ void TestQgsGeometryCollection::geometryCollection() // segmentize QgsGeometryCollection segmentC; QgsCircularString toSegment; - toSegment.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); + toSegment.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); segmentC.addGeometry( toSegment.clone() ); - std::unique_ptr segmentized( static_cast< QgsGeometryCollection * >( segmentC.segmentize() ) ); - const QgsLineString *segmentizedLine = static_cast< const QgsLineString * >( segmentized->geometryN( 0 ) ); + std::unique_ptr segmentized( static_cast( segmentC.segmentize() ) ); + const QgsLineString *segmentizedLine = static_cast( segmentized->geometryN( 0 ) ); QCOMPARE( segmentizedLine->numPoints(), 156 ); QCOMPARE( segmentizedLine->vertexCount(), 156 ); QCOMPARE( segmentizedLine->ringCount(), 1 ); @@ -1375,8 +1305,7 @@ void TestQgsGeometryCollection::geometryCollection() gcNodes.addGeometry( nodeLine.clone() ); QVERIFY( !gcNodes.removeDuplicateNodes( 0.02 ) ); QCOMPARE( gcNodes.asWkt(), QStringLiteral( "GeometryCollection (LineString (11 2, 11 12, 111 12))" ) ); - nodeLine.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); + nodeLine.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); gcNodes.addGeometry( nodeLine.clone() ); QVERIFY( gcNodes.removeDuplicateNodes( 0.02 ) ); QVERIFY( !gcNodes.removeDuplicateNodes( 0.02 ) ); @@ -1397,8 +1326,7 @@ void TestQgsGeometryCollection::geometryCollection() // filter vertices QgsGeometryCollection filterCollect; - auto filter = []( const QgsPoint & point )-> bool - { + auto filter = []( const QgsPoint &point ) -> bool { return point.x() > 5; }; QgsLineString filterLine; @@ -1414,8 +1342,7 @@ void TestQgsGeometryCollection::geometryCollection() // transform vertices QgsGeometryCollection transformCollect; - auto transform = []( const QgsPoint & point )-> QgsPoint - { + auto transform = []( const QgsPoint &point ) -> QgsPoint { return QgsPoint( point.x() + 2, point.y() + 3, point.z() + 4, point.m() + 5 ); }; QgsLineString transformLine; @@ -1457,7 +1384,7 @@ void TestQgsGeometryCollection::geometryCollection() b1.clear(); QVERIFY( b1.boundingBox().isNull() ); - transformLine.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) ); + transformLine.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) ); b1.addGeometry( transformLine.clone() ); QgsPolygon polygon1; QVERIFY( polygon1.fromWkt( "Polygon( (5 10 0, 5 15 0, 10 15 0, 10 10 0, 5 10 0) )" ) ); @@ -1475,7 +1402,7 @@ void TestQgsGeometryCollection::geometryCollection() b2.clear(); QVERIFY( b2.boundingBox().isNull() ); - transformLine.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) ); + transformLine.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 12, 15, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 15, 1 ) ); b2.addGeometry( transformLine.clone() ); QgsPolygon polygon2; QVERIFY( polygon2.fromWkt( "Polygon( (5 10 0, 5 15 5, 10 15 5, 10 10 5, 5 10 0) )" ) ); @@ -1488,25 +1415,20 @@ void TestQgsGeometryCollection::testCopyConstructor() QgsLineString part; QgsLineString part2; - part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); c1.addGeometry( part.clone() ); QgsGeometryCollection c2; QgsGeometryCollection c3( c2 ); QVERIFY( c3.isEmpty() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); c2.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); c2.addGeometry( part2.clone() ); QgsGeometryCollection c4( c2 ); QCOMPARE( c4.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c4.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c4.geometryN( 1 ) ), part2 ); + QCOMPARE( *static_cast( c4.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( c4.geometryN( 1 ) ), part2 ); } void TestQgsGeometryCollection::testAssignment() @@ -1516,8 +1438,7 @@ void TestQgsGeometryCollection::testAssignment() QgsLineString part2; QgsLineString part3; - part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); c1.addGeometry( part.clone() ); QCOMPARE( c1.numGeometries(), 1 ); @@ -1525,23 +1446,19 @@ void TestQgsGeometryCollection::testAssignment() QCOMPARE( c2.numGeometries(), 0 ); QVERIFY( c1 != c2 ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); c2.addGeometry( part2.clone() ); QCOMPARE( c2.numGeometries(), 1 ); QVERIFY( c1 != c2 ); - part3.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + part3.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); c1.addGeometry( part3.clone() ); c2 = c1; QCOMPARE( c1.numGeometries(), 2 ); QCOMPARE( c2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c2.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c2.geometryN( 1 ) ), part3 ); + QCOMPARE( *static_cast( c2.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( c2.geometryN( 1 ) ), part3 ); QVERIFY( c1 == c2 ); } diff --git a/tests/src/core/geometry/testqgsgeometryutils.cpp b/tests/src/core/geometry/testqgsgeometryutils.cpp index 1d5db381c891..b40a0e1a23c9 100644 --- a/tests/src/core/geometry/testqgsgeometryutils.cpp +++ b/tests/src/core/geometry/testqgsgeometryutils.cpp @@ -23,7 +23,7 @@ #include "qgspolygon.h" #include "qgsmultipolygon.h" -class TestQgsGeometryUtils: public QObject +class TestQgsGeometryUtils : public QObject { Q_OBJECT public: @@ -236,8 +236,7 @@ void TestQgsGeometryUtils::testSegmentMidPoint() QFETCH( double, expectedY ); QgsPoint midPoint; - const bool ok = QgsGeometryUtils::segmentMidPoint( QgsPoint( pt1x, pt1y ), QgsPoint( pt2x, pt2y ), - midPoint, radius, QgsPoint( mouseX, mouseY ) ); + const bool ok = QgsGeometryUtils::segmentMidPoint( QgsPoint( pt1x, pt1y ), QgsPoint( pt2x, pt2y ), midPoint, radius, QgsPoint( mouseX, mouseY ) ); QVERIFY( ok ); QGSCOMPARENEAR( midPoint.x(), expectedX, 4 * std::numeric_limits::epsilon() ); @@ -471,7 +470,7 @@ void TestQgsGeometryUtils::testVerticesAtDistance() QVERIFY( QgsGeometryUtils::verticesAtDistance( *outerRing1, 3.5, previous, next ) ); QCOMPARE( previous, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( next, QgsVertexId( 0, 0, 4 ) ); - QVERIFY( ! QgsGeometryUtils::verticesAtDistance( *outerRing1, 4.5, previous, next ) ); + QVERIFY( !QgsGeometryUtils::verticesAtDistance( *outerRing1, 4.5, previous, next ) ); // test exact hits QVERIFY( QgsGeometryUtils::verticesAtDistance( *outerRing1, 0, previous, next ) ); @@ -516,7 +515,7 @@ void TestQgsGeometryUtils::testVerticesAtDistance() QVERIFY( QgsGeometryUtils::verticesAtDistance( polygon1, 3.5, previous, next ) ); QCOMPARE( previous, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( next, QgsVertexId( 0, 0, 4 ) ); - QVERIFY( ! QgsGeometryUtils::verticesAtDistance( polygon1, 4.5, previous, next ) ); + QVERIFY( !QgsGeometryUtils::verticesAtDistance( polygon1, 4.5, previous, next ) ); QVERIFY( QgsGeometryUtils::verticesAtDistance( polygon1, 0, previous, next ) ); QCOMPARE( previous, QgsVertexId( 0, 0, 0 ) ); QCOMPARE( next, QgsVertexId( 0, 0, 0 ) ); @@ -609,17 +608,13 @@ void TestQgsGeometryUtils::testCircleCenterRadius() //QgsGeometryUtils::sqrDistToLine void TestQgsGeometryUtils::testSqrDistToLine() { - // See https://github.com/qgis/QGIS/issues/21967#issuecomment-495853991 const QgsPointXY qp( 771938, 6.95593e+06 ); const QgsPointXY p1( 771946, 6.95593e+06 ); const QgsPointXY p2( 771904, 6.95595e+06 ); double rx = 0, ry = 0; const double epsilon = 1e-18; - const double sqrDist = QgsGeometryUtilsBase::sqrDistToLine( qp.x(), qp.y(), - p1.x(), p1.y(), - p2.x(), p2.y(), - rx, ry, epsilon ); + const double sqrDist = QgsGeometryUtilsBase::sqrDistToLine( qp.x(), qp.y(), p1.x(), p1.y(), p2.x(), p2.y(), rx, ry, epsilon ); QGSCOMPARENEAR( sqrDist, 11.83, 0.01 ); } @@ -637,9 +632,9 @@ void TestQgsGeometryUtils::testAngleThreePoints() QGSCOMPARENEAR( QgsGeometryUtilsBase::angleBetweenThreePoints( p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y() ), 0.0, 0.00000001 ); p3 = QgsPointXY( 1, 0 ); //undefined, but want no crash - ( void )QgsGeometryUtilsBase::angleBetweenThreePoints( p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y() ); + ( void ) QgsGeometryUtilsBase::angleBetweenThreePoints( p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y() ); p2 = QgsPointXY( 0, 0 ); - ( void )QgsGeometryUtilsBase::angleBetweenThreePoints( p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y() ); + ( void ) QgsGeometryUtilsBase::angleBetweenThreePoints( p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y() ); } void TestQgsGeometryUtils::testMidPoint() @@ -742,8 +737,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() QgsPoint segmentPoint1( 2, 1 ); QgsPoint segmentPoint2( 2, 2 ); - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); QCOMPARE( perpendicularSegmentPoint1x, 3.0 ); QCOMPARE( perpendicularSegmentPoint1y, ( 1.5 ) ); QCOMPARE( perpendicularSegmentPoint2x, ( 1.0 ) ); @@ -751,8 +745,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() // case 1 with segmentLength segmentLength = 3; - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); QCOMPARE( perpendicularSegmentPoint1x, ( 3.5 ) ); QCOMPARE( perpendicularSegmentPoint1y, ( 1.5 ) ); QCOMPARE( perpendicularSegmentPoint2x, ( 0.5 ) ); @@ -760,8 +753,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() // default case 1 with default segmentLength=0 (meaning no effect) segmentLength = 0; - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); QCOMPARE( perpendicularSegmentPoint1x, 3.0 ); QCOMPARE( perpendicularSegmentPoint1y, ( 1.5 ) ); QCOMPARE( perpendicularSegmentPoint2x, ( 1.0 ) ); @@ -772,8 +764,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() centerPoint = QgsPoint( 3, 13 ); segmentPoint1 = QgsPoint( 2, 3 ); segmentPoint2 = QgsPoint( 7, 11 ); - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); QCOMPARE( perpendicularSegmentPoint1x, ( 11.0 ) ); QCOMPARE( perpendicularSegmentPoint1y, ( 8.0 ) ); QCOMPARE( perpendicularSegmentPoint2x, ( -5.0 ) ); @@ -785,8 +776,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() segmentPoint2 = QgsPoint( -5, -9 ); segmentLength = 5; - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); QCOMPARE( perpendicularSegmentPoint1x, ( -1.0 ) ); QCOMPARE( perpendicularSegmentPoint1y, ( 4.5 ) ); @@ -797,8 +787,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() segmentPoint1 = QgsPoint( -3, 3 ); segmentPoint2 = QgsPoint( 2, 3 ); centerPoint = QgsPoint( 3, 13 ); - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); QCOMPARE( perpendicularSegmentPoint1x, ( 3.0 ) ); QCOMPARE( perpendicularSegmentPoint1y, ( 8.0 ) ); QCOMPARE( perpendicularSegmentPoint2x, ( 3.0 ) ); @@ -808,8 +797,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() segmentPoint1 = QgsPoint( 3, 13 ); segmentPoint2 = QgsPoint( 3, 3 ); centerPoint = QgsPoint( -7, 8 ); - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y ); QCOMPARE( perpendicularSegmentPoint1x, ( -17.0 ) ); QCOMPARE( perpendicularSegmentPoint1y, ( 8.0 ) ); QCOMPARE( perpendicularSegmentPoint2x, ( 3. ) ); @@ -817,8 +805,7 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() // vertical with normalization of segmentLength segmentLength = 1; - QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), - perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); + QgsGeometryUtilsBase::perpendicularCenterSegment( centerPoint.x(), centerPoint.y(), segmentPoint1.x(), segmentPoint1.y(), segmentPoint2.x(), segmentPoint2.y(), perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength ); QCOMPARE( perpendicularSegmentPoint1x, ( -7.5 ) ); QCOMPARE( perpendicularSegmentPoint1y, ( 8.0 ) ); QCOMPARE( perpendicularSegmentPoint2x, ( -6.5 ) ); @@ -827,34 +814,25 @@ void TestQgsGeometryUtils::testPerpendicularCenterSegment() void TestQgsGeometryUtils::testClosestPoint() { - const QgsLineString linestringZ( QVector() - << QgsPoint( 1, 1, 1 ) - << QgsPoint( 1, 3, 2 ) ); + const QgsLineString linestringZ( QVector() << QgsPoint( 1, 1, 1 ) << QgsPoint( 1, 3, 2 ) ); const QgsPoint pt1 = QgsGeometryUtils::closestPoint( linestringZ, QgsPoint( 1, 0 ) ); QGSCOMPARENEAR( pt1.z(), 1, 0.0001 ); QVERIFY( std::isnan( pt1.m() ) ); - const QgsLineString linestringM( QVector() - << QgsPoint( 1, 1, std::numeric_limits::quiet_NaN(), 1 ) - << QgsPoint( 1, 3, std::numeric_limits::quiet_NaN(), 2 ) ); + const QgsLineString linestringM( QVector() << QgsPoint( 1, 1, std::numeric_limits::quiet_NaN(), 1 ) << QgsPoint( 1, 3, std::numeric_limits::quiet_NaN(), 2 ) ); const QgsPoint pt2 = QgsGeometryUtils::closestPoint( linestringM, QgsPoint( 1, 4 ) ); QVERIFY( std::isnan( pt2.z() ) ); QGSCOMPARENEAR( pt2.m(), 2, 0.0001 ); - const QgsLineString linestringZM( QVector() - << QgsPoint( 1, 1, 1, 1 ) - << QgsPoint( 1, 3, 2, 2 ) ); + const QgsLineString linestringZM( QVector() << QgsPoint( 1, 1, 1, 1 ) << QgsPoint( 1, 3, 2, 2 ) ); const QgsPoint pt3 = QgsGeometryUtils::closestPoint( linestringZM, QgsPoint( 2, 2 ) ); QGSCOMPARENEAR( pt3.z(), 1.5, 0.0001 ); QGSCOMPARENEAR( pt3.m(), 1.5, 0.0001 ); - const QgsLineString linestringDuplicatedPoint( QVector() - << QgsPoint( 1, 1, 1, 1 ) - << QgsPoint( 1, 1, 1, 1 ) - << QgsPoint( 1, 3, 2, 2 ) ); + const QgsLineString linestringDuplicatedPoint( QVector() << QgsPoint( 1, 1, 1, 1 ) << QgsPoint( 1, 1, 1, 1 ) << QgsPoint( 1, 3, 2, 2 ) ); const QgsPoint pt4 = QgsGeometryUtils::closestPoint( linestringDuplicatedPoint, QgsPoint( 1, 0 ) ); QGSCOMPARENEAR( pt4.z(), 1, 0.0001 ); @@ -896,7 +874,6 @@ void TestQgsGeometryUtils::testlinesIntersection3D() QVERIFY( QgsGeometryUtilsBase::linesIntersection3D( QgsVector3D( 2.5, 2.5, 2.5 ), QgsVector3D( 5, 0, 0 ), QgsVector3D( 0, 5, 5 ), QgsVector3D( 5, 5, 5 ), x ) ); QVERIFY( x == QgsVector3D( 0.0, 5.0, 5.0 ) ); - } void TestQgsGeometryUtils::testSegmentIntersection() @@ -1192,17 +1169,17 @@ void TestQgsGeometryUtils::testGml() { const QgsPoint point = QgsPoint( 1, 2 ); QDomDocument doc; - QDomElement elm = QgsGeometryUtils::pointsToGML2( QgsPointSequence( ) << point, doc, 2, QStringLiteral( "gml" ) ); + QDomElement elm = QgsGeometryUtils::pointsToGML2( QgsPointSequence() << point, doc, 2, QStringLiteral( "gml" ) ); const QString expectedGML2( QStringLiteral( "1,2" ) ); QGSCOMPAREGML( elemToString( elm ), expectedGML2 ); - elm = QgsGeometryUtils::pointsToGML2( QgsPointSequence( ) << point, doc, 2, QStringLiteral( "gml" ), QgsAbstractGeometry::AxisOrder::YX ); + elm = QgsGeometryUtils::pointsToGML2( QgsPointSequence() << point, doc, 2, QStringLiteral( "gml" ), QgsAbstractGeometry::AxisOrder::YX ); const QString expectedGML2_inverted( QStringLiteral( "2,1" ) ); QGSCOMPAREGML( elemToString( elm ), expectedGML2_inverted ); - elm = QgsGeometryUtils::pointsToGML3( QgsPointSequence( ) << point, doc, 2, QStringLiteral( "gml" ), false, QgsAbstractGeometry::AxisOrder::XY ); + elm = QgsGeometryUtils::pointsToGML3( QgsPointSequence() << point, doc, 2, QStringLiteral( "gml" ), false, QgsAbstractGeometry::AxisOrder::XY ); const QString expectedGML3( QStringLiteral( "1 2" ) ); QGSCOMPAREGML( elemToString( elm ), expectedGML3 ); - elm = QgsGeometryUtils::pointsToGML3( QgsPointSequence( ) << point, doc, 2, QStringLiteral( "gml" ), false, QgsAbstractGeometry::AxisOrder::YX ); + elm = QgsGeometryUtils::pointsToGML3( QgsPointSequence() << point, doc, 2, QStringLiteral( "gml" ), false, QgsAbstractGeometry::AxisOrder::YX ); const QString expectedGML3_inverted( QStringLiteral( "2 1" ) ); QGSCOMPAREGML( elemToString( elm ), expectedGML3_inverted ); } @@ -1328,28 +1305,28 @@ void TestQgsGeometryUtils::testPointOnLineWithDistance() QCOMPARE( x, 0.0 ); QCOMPARE( y, 0.0 ); - p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 2, 3 ), QgsPoint( 12, 3 ), 10 ); + p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 2, 3 ), QgsPoint( 12, 3 ), 10 ); QCOMPARE( p.x(), 12.0 ); QCOMPARE( p.y(), 3.0 ); - QgsGeometryUtilsBase::pointOnLineWithDistance( 2, 3, 12, 3, 10, x, y ); + QgsGeometryUtilsBase::pointOnLineWithDistance( 2, 3, 12, 3, 10, x, y ); QCOMPARE( x, 12.0 ); QCOMPARE( y, 3.0 ); - p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), 0 ); + p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), 0 ); QCOMPARE( p.x(), 0.0 ); QCOMPARE( p.y(), 0.0 ); - QgsGeometryUtilsBase::pointOnLineWithDistance( 0, 0, 0, 10, 0, x, y ); + QgsGeometryUtilsBase::pointOnLineWithDistance( 0, 0, 0, 10, 0, x, y ); QCOMPARE( x, 0.0 ); QCOMPARE( y, 0.0 ); - p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), 10 ); + p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), 10 ); QCOMPARE( p.x(), 0.0 ); QCOMPARE( p.y(), 10.0 ); - QgsGeometryUtilsBase::pointOnLineWithDistance( 0, 0, 0, 10, 10, x, y ); + QgsGeometryUtilsBase::pointOnLineWithDistance( 0, 0, 0, 10, 10, x, y ); QCOMPARE( x, 0.0 ); QCOMPARE( y, 10.0 ); - p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 2, 1 ), QgsPoint( -8, -5 ), 5 ); + p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 2, 1 ), QgsPoint( -8, -5 ), 5 ); QGSCOMPARENEAR( p.x(), -2.28746, 0.0001 ); QGSCOMPARENEAR( p.y(), -1.57248, 0.0001 ); QgsGeometryUtilsBase::pointOnLineWithDistance( 2, 1, -8, -5, 5, x, y ); @@ -1377,21 +1354,21 @@ void TestQgsGeometryUtils::testPointOnLineWithDistance() QGSCOMPARENEAR( z, 7.712535, 0.0001 ); QGSCOMPARENEAR( m, 12.714986, 0.0001 ); - p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( -10, -6 ), 2 ); + p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( -10, -6 ), 2 ); QGSCOMPARENEAR( p.x(), -1.71499, 0.0001 ); QGSCOMPARENEAR( p.y(), -1.02899, 0.0001 ); QgsGeometryUtilsBase::pointOnLineWithDistance( 0, 0, -10, -6, 2, x, y ); QGSCOMPARENEAR( x, -1.71499, 0.0001 ); QGSCOMPARENEAR( y, -1.02899, 0.0001 ); - p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( -10, -6 ), 20 ); + p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( -10, -6 ), 20 ); QGSCOMPARENEAR( p.x(), -17.1499, 0.0001 ); QGSCOMPARENEAR( p.y(), -10.2899, 0.0001 ); QgsGeometryUtilsBase::pointOnLineWithDistance( 0, 0, -10, -6, 20, x, y ); QGSCOMPARENEAR( x, -17.1499, 0.0001 ); QGSCOMPARENEAR( y, -10.2899, 0.0001 ); - p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( -10, -6 ), -10 ); + p = QgsGeometryUtils::pointOnLineWithDistance( QgsPoint( 0, 0 ), QgsPoint( -10, -6 ), -10 ); QGSCOMPARENEAR( p.x(), 8.57493, 0.0001 ); QGSCOMPARENEAR( p.y(), 5.14496, 0.0001 ); QgsGeometryUtilsBase::pointOnLineWithDistance( 0, 0, -10, -6, -10, x, y ); @@ -1431,7 +1408,7 @@ void TestQgsGeometryUtils::interpolatePointOnArc() QGSCOMPARENEAR( p.m(), 2.0, 0.00001 ); p = QgsGeometryUtils::interpolatePointOnArc( QgsPoint( 10, 0, 1, 2 ), QgsPoint( 11, 1, 3, 4 ), QgsPoint( 12, 0, 13, 14 ), 1 ); QGSCOMPARENEAR( p.x(), 10.459698, 0.00001 ); - QGSCOMPARENEAR( p.y(), 0.841471, 0.00001 ); + QGSCOMPARENEAR( p.y(), 0.841471, 0.00001 ); QGSCOMPARENEAR( p.z(), 2.273240, 0.00001 ); QGSCOMPARENEAR( p.m(), 3.273240, 0.00001 ); p = QgsGeometryUtils::interpolatePointOnArc( QgsPoint( 10, 0, 1, 2 ), QgsPoint( 11, 1, 3, 4 ), QgsPoint( 12, 0, 13, 14 ), 2 ); @@ -1475,11 +1452,7 @@ void TestQgsGeometryUtils::testSegmentizeArcHalfCircle() QgsPointSequence points; const double xoff = 1; const double yoff = 100; - QgsGeometryUtils::segmentizeArc( QgsPoint( xoff + 0, yoff + 0 ), - QgsPoint( xoff + 1, yoff + 1 ), - QgsPoint( xoff + 2, yoff + 0 ), - points, 0.1, - QgsAbstractGeometry::MaximumDifference, false, false ); + QgsGeometryUtils::segmentizeArc( QgsPoint( xoff + 0, yoff + 0 ), QgsPoint( xoff + 1, yoff + 1 ), QgsPoint( xoff + 2, yoff + 0 ), points, 0.1, QgsAbstractGeometry::MaximumDifference, false, false ); QCOMPARE( points.size(), 5 ); QGSCOMPARENEAR( points[0].x(), xoff + 0.0, 0.00001 ); QGSCOMPARENEAR( points[0].y(), yoff + 0.0, 0.00001 ); @@ -1498,11 +1471,7 @@ void TestQgsGeometryUtils::testSegmentizeArcHalfCircleOtherDirection() QgsPointSequence points; const double xoff = 1; const double yoff = 100; - QgsGeometryUtils::segmentizeArc( QgsPoint( xoff + 0, yoff + 0 ), - QgsPoint( xoff + 1, yoff - 1 ), - QgsPoint( xoff + 2, yoff + 0 ), - points, 0.1, - QgsAbstractGeometry::MaximumDifference, false, false ); + QgsGeometryUtils::segmentizeArc( QgsPoint( xoff + 0, yoff + 0 ), QgsPoint( xoff + 1, yoff - 1 ), QgsPoint( xoff + 2, yoff + 0 ), points, 0.1, QgsAbstractGeometry::MaximumDifference, false, false ); QCOMPARE( points.size(), 5 ); QGSCOMPARENEAR( points[0].x(), xoff + 0.0, 0.00001 ); QGSCOMPARENEAR( points[0].y(), yoff + 0.0, 0.00001 ); @@ -1521,11 +1490,7 @@ void TestQgsGeometryUtils::testSegmentizeArcFullCircle() QgsPointSequence points; const double xoff = 1; const double yoff = 100; - QgsGeometryUtils::segmentizeArc( QgsPoint( xoff + 0, yoff + 0 ), - QgsPoint( xoff + 2, yoff + 0 ), - QgsPoint( xoff + 0, yoff + 0 ), - points, 0.4, - QgsAbstractGeometry::MaximumDifference, false, false ); + QgsGeometryUtils::segmentizeArc( QgsPoint( xoff + 0, yoff + 0 ), QgsPoint( xoff + 2, yoff + 0 ), QgsPoint( xoff + 0, yoff + 0 ), points, 0.4, QgsAbstractGeometry::MaximumDifference, false, false ); QCOMPARE( points.size(), 5 ); QGSCOMPARENEAR( points[0].x(), xoff + 0.0, 0.00001 ); QGSCOMPARENEAR( points[0].y(), yoff + 0.0, 0.00001 ); @@ -1906,7 +1871,6 @@ void TestQgsGeometryUtils::transferFirstZOrMValueToPoint_qgspointsequence() QCOMPARE( point.wkbType(), Qgis::WkbType::PointZM ); QCOMPARE( point.z(), 9.0 ); QCOMPARE( point.m(), 5.0 ); - } void TestQgsGeometryUtils::transferFirstZOrMValueToPoint_qgsgeometry() diff --git a/tests/src/core/geometry/testqgsgeometryutilsbase.cpp b/tests/src/core/geometry/testqgsgeometryutilsbase.cpp index 036b4864bec2..e2c9e589478e 100644 --- a/tests/src/core/geometry/testqgsgeometryutilsbase.cpp +++ b/tests/src/core/geometry/testqgsgeometryutilsbase.cpp @@ -17,7 +17,7 @@ #include #include "qgsgeometryutils_base.h" -class TestQgsGeometryUtilsBase: public QObject +class TestQgsGeometryUtilsBase : public QObject { Q_OBJECT diff --git a/tests/src/core/geometry/testqgslinestring.cpp b/tests/src/core/geometry/testqgslinestring.cpp index 38db56a99828..ade85da7e638 100644 --- a/tests/src/core/geometry/testqgslinestring.cpp +++ b/tests/src/core/geometry/testqgslinestring.cpp @@ -33,7 +33,7 @@ #include "testtransformer.h" -class TestQgsLineString: public QObject +class TestQgsLineString : public QObject { Q_OBJECT private slots: @@ -135,9 +135,9 @@ void TestQgsLineString::constructorEmpty() void TestQgsLineString::constructorFromArrayZ() { - QVector< double > xx( {1, 2, 3} ); - QVector< double > yy( {11, 12, 13} ); - QVector< double > zz( {21, 22, 23} ); + QVector xx( { 1, 2, 3 } ); + QVector yy( { 11, 12, 13 } ); + QVector zz( { 21, 22, 23 } ); QgsLineString ls( xx, yy, zz ); @@ -154,7 +154,7 @@ void TestQgsLineString::constructorFromArrayZ() QCOMPARE( ls.zAt( 2 ), 23.0 ); // LineString25D - ls = QgsLineString( xx, yy, zz, QVector< double >(), true ); + ls = QgsLineString( xx, yy, zz, QVector(), true ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString25D ); QCOMPARE( ls.numPoints(), 3 ); @@ -169,7 +169,7 @@ void TestQgsLineString::constructorFromArrayZ() QCOMPARE( ls.zAt( 2 ), 23.0 ); // unbalanced -> z ignored - zz = QVector< double >( {21, 22} ); + zz = QVector( { 21, 22 } ); ls = QgsLineString( xx, yy, zz ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString ); @@ -182,7 +182,7 @@ void TestQgsLineString::constructorFromArrayZ() QCOMPARE( ls.yAt( 2 ), 13.0 ); // unbalanced -> z truncated - zz = QVector< double >( {21, 22, 23, 24} ); + zz = QVector( { 21, 22, 23, 24 } ); ls = QgsLineString( xx, yy, zz ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringZ ); @@ -200,10 +200,10 @@ void TestQgsLineString::constructorFromArrayZ() void TestQgsLineString::constructorFromArrayM() { - QVector< double > xx( {1, 2, 3} ); - QVector< double > yy( {11, 12, 13} ); - QVector< double > mm( {21, 22, 23} ); - QgsLineString ls( xx, yy, QVector< double >(), mm ); + QVector xx( { 1, 2, 3 } ); + QVector yy( { 11, 12, 13 } ); + QVector mm( { 21, 22, 23 } ); + QgsLineString ls( xx, yy, QVector(), mm ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringM ); QCOMPARE( ls.numPoints(), 3 ); @@ -218,8 +218,8 @@ void TestQgsLineString::constructorFromArrayM() QCOMPARE( ls.mAt( 2 ), 23.0 ); // unbalanced -> m ignored - mm = QVector< double >( {21, 22} ); - ls = QgsLineString( xx, yy, QVector< double >(), mm ); + mm = QVector( { 21, 22 } ); + ls = QgsLineString( xx, yy, QVector(), mm ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString ); QCOMPARE( ls.numPoints(), 3 ); @@ -231,8 +231,9 @@ void TestQgsLineString::constructorFromArrayM() QCOMPARE( ls.yAt( 2 ), 13.0 ); // unbalanced -> m truncated - mm = QVector< double >( {21, 22, 23, 24} );; - ls = QgsLineString( xx, yy, QVector< double >(), mm ); + mm = QVector( { 21, 22, 23, 24 } ); + ; + ls = QgsLineString( xx, yy, QVector(), mm ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringM ); QCOMPARE( ls.numPoints(), 3 ); @@ -249,10 +250,10 @@ void TestQgsLineString::constructorFromArrayM() void TestQgsLineString::constructorFromArrayZM() { - QVector< double > xx( {1, 2, 3} ); - QVector< double > yy( {11, 12, 13} ); - QVector< double > zz( {21, 22, 23} ); - QVector< double > mm( {31, 32, 33} ); + QVector xx( { 1, 2, 3 } ); + QVector yy( { 11, 12, 13 } ); + QVector zz( { 21, 22, 23 } ); + QVector mm( { 31, 32, 33 } ); QgsLineString ls( xx, yy, zz, mm ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringZM ); @@ -286,8 +287,8 @@ void TestQgsLineString::constructorFromArrayZM() void TestQgsLineString::constructorFromArray() { - QVector< double > xx( {1, 2, 3} ); - QVector< double > yy( {11, 12, 13} ); + QVector xx( { 1, 2, 3 } ); + QVector yy( { 11, 12, 13 } ); QgsLineString ls( xx, yy ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString ); @@ -306,8 +307,8 @@ void TestQgsLineString::constructorFromArray() QCOMPARE( *( ls.yData() + 2 ), 13.0 ); // unbalanced - xx = QVector< double >( {1, 2} ); - yy = QVector< double >( {11, 12, 13} ); + xx = QVector( { 1, 2 } ); + yy = QVector( { 11, 12, 13 } ); ls = QgsLineString( xx, yy ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString ); @@ -317,8 +318,8 @@ void TestQgsLineString::constructorFromArray() QCOMPARE( ls.xAt( 1 ), 2.0 ); QCOMPARE( ls.yAt( 1 ), 12.0 ); - xx = QVector< double >( {1, 2, 3} ); - yy = QVector< double >( {11, 12} ); + xx = QVector( { 1, 2, 3 } ); + yy = QVector( { 11, 12 } ); ls = QgsLineString( xx, yy ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString ); @@ -377,7 +378,7 @@ void TestQgsLineString::constructorFromQgsPointSequence() QCOMPARE( ls.zAt( 1 ), 200.0 ); // with m - ls = QgsLineString( QgsPointSequence() << QgsPoint( 1, 2, 0, 4, Qgis::WkbType::PointM ) ); + ls = QgsLineString( QgsPointSequence() << QgsPoint( 1, 2, 0, 4, Qgis::WkbType::PointM ) ); QCOMPARE( ls.numPoints(), 1 ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringM ); } @@ -592,7 +593,7 @@ void TestQgsLineString::setPoints() //setPoints with z pts = QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ); + << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ); ls.setPoints( pts ); QCOMPARE( ls.numPoints(), 2 ); @@ -605,7 +606,7 @@ void TestQgsLineString::setPoints() //setPoints with 25d pts = QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 4 ) - << QgsPoint( Qgis::WkbType::Point25D, 2, 3, 4 ); + << QgsPoint( Qgis::WkbType::Point25D, 2, 3, 4 ); ls.setPoints( pts ); QCOMPARE( ls.numPoints(), 2 ); @@ -619,7 +620,7 @@ void TestQgsLineString::setPoints() //setPoints with m pts = QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ); + << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ); ls.setPoints( pts ); QCOMPARE( ls.numPoints(), 2 ); @@ -632,7 +633,7 @@ void TestQgsLineString::setPoints() //setPoints with zm pts = QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ); + << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ); ls.setPoints( pts ); QCOMPARE( ls.numPoints(), 2 ); @@ -645,7 +646,7 @@ void TestQgsLineString::setPoints() //setPoints with MIXED dimensionality of points pts = QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ); + << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 5 ); ls.setPoints( pts ); QCOMPARE( ls.numPoints(), 2 ); @@ -654,13 +655,13 @@ void TestQgsLineString::setPoints() QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringZM ); ls.points( expectedPts ); - QCOMPARE( expectedPts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) );; + QCOMPARE( expectedPts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) ); + ; } void TestQgsLineString::pointN() { - QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) ); + QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) ); QCOMPARE( ls.pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) ); QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 2, 3, 0, 5 ) ); @@ -673,9 +674,7 @@ void TestQgsLineString::pointN() void TestQgsLineString::gettersSetters() { QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 23, 24 ) ); QCOMPARE( ls.xAt( 0 ), 1.0 ); QCOMPARE( ls.xAt( 1 ), 11.0 ); @@ -735,9 +734,7 @@ void TestQgsLineString::gettersSetters() ls.setMAt( 11, 54.0 ); //out of range //check zAt/setZAt with non-3d linestring - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) - << QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 24 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) << QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 24 ) ); //basically we just don't want these to crash QVERIFY( std::isnan( ls.zAt( 0 ) ) ); @@ -746,9 +743,7 @@ void TestQgsLineString::gettersSetters() ls.setZAt( 1, 63.0 ); //check mAt/setMAt with non-measure linestring - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); //basically we just don't want these to crash QVERIFY( std::isnan( ls.mAt( 0 ) ) ); @@ -764,9 +759,7 @@ void TestQgsLineString::appendWithZM() //check dimensionality is inherited from append line if initially empty toAppend.reset( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 33, 34 ) - << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 43, 44 ) - << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 53, 54 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 33, 34 ) << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 43, 44 ) << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 53, 54 ) ); ls.append( toAppend.get() ); QVERIFY( ls.is3D() ); @@ -787,9 +780,7 @@ void TestQgsLineString::appendWithZM() QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString ); toAppend.reset( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 33, 34 ) - << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 43, 44 ) - << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 53, 54 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 31, 32, 33, 34 ) << QgsPoint( Qgis::WkbType::PointZM, 41, 42, 43, 44 ) << QgsPoint( Qgis::WkbType::PointZM, 51, 52, 53, 54 ) ); ls.append( toAppend.get() ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString ); @@ -807,9 +798,7 @@ void TestQgsLineString::appendWithZM() QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringZM ); toAppend.reset( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) - << QgsPoint( 41, 42 ) - << QgsPoint( 51, 52 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); ls.append( toAppend.get() ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineStringZM ); @@ -821,8 +810,7 @@ void TestQgsLineString::appendWithZM() //25d append ls.clear(); toAppend.reset( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 31, 32, 33 ) - << QgsPoint( Qgis::WkbType::Point25D, 41, 42, 43 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 31, 32, 33 ) << QgsPoint( Qgis::WkbType::Point25D, 41, 42, 43 ) ); ls.append( toAppend.get() ); QVERIFY( ls.is3D() ); @@ -853,9 +841,7 @@ void TestQgsLineString::append() QCOMPARE( ls.numPoints(), 0 ); std::unique_ptr toAppend( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); ls.append( toAppend.get() ); QVERIFY( !ls.is3D() ); @@ -872,9 +858,7 @@ void TestQgsLineString::append() //add more points toAppend.reset( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) - << QgsPoint( 41, 42 ) - << QgsPoint( 51, 52 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); ls.append( toAppend.get() ); QCOMPARE( ls.numPoints(), 6 ); @@ -890,19 +874,14 @@ void TestQgsLineString::append() //Make sure there are not duplicit points except start and end point ls.clear(); toAppend.reset( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() - << QgsPoint( 1, 1 ) - << QgsPoint( 5, 5 ) - << QgsPoint( 10, 1 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 5, 5 ) << QgsPoint( 10, 1 ) ); ls.append( toAppend.get() ); QCOMPARE( ls.numPoints(), 3 ); QCOMPARE( ls.vertexCount(), 3 ); toAppend.reset( new QgsLineString() ); - toAppend->setPoints( QgsPointSequence() - << QgsPoint( 10, 1 ) - << QgsPoint( 1, 1 ) ); + toAppend->setPoints( QgsPointSequence() << QgsPoint( 10, 1 ) << QgsPoint( 1, 1 ) ); ls.append( toAppend.get() ); QVERIFY( ls.isClosed() ); @@ -941,31 +920,23 @@ void TestQgsLineString::equality() //different dimension QgsLineString ls3; - ls3.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 0 ) - << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 0 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 0 ) ); + ls3.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 0 ) << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 0 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 0 ) ); QVERIFY( !( ls1 == ls3 ) ); QVERIFY( ls1 != ls3 ); //different z coordinates QgsLineString ls4; - ls4.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 4 ) ); + ls4.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 1 / 3.0, 4 / 3.0, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 4 ) ); QVERIFY( !( ls3 == ls4 ) ); QVERIFY( ls3 != ls4 ); //different m values QgsLineString ls5; - ls5.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); + ls5.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 3 ) ); QgsLineString ls6; - ls6.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 11 ) - << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 12 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 13 ) ); + ls6.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 11 ) << QgsPoint( Qgis::WkbType::PointM, 1 / 3.0, 4 / 3.0, 0, 12 ) << QgsPoint( Qgis::WkbType::PointM, 7, 8, 0, 13 ) ); QVERIFY( !( ls5 == ls6 ) ); QVERIFY( ls5 != ls6 ); @@ -984,10 +955,7 @@ void TestQgsLineString::close() QgsLineString ls; QVERIFY( !ls.isClosed() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 2 ) - << QgsPoint( 11, 22 ) - << QgsPoint( 1, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); QVERIFY( !ls.isClosed() ); QCOMPARE( ls.numPoints(), 4 ); QCOMPARE( ls.area(), 0.0 ); @@ -1011,10 +979,7 @@ void TestQgsLineString::close() QCOMPARE( ls.pointN( 4 ), QgsPoint( 1, 2 ) ); // tiny differences - ls.setPoints( QgsPointSequence() << QgsPoint( 0.000000000000001, 0.000000000000002 ) - << QgsPoint( 0.000000000000011, 0.000000000000002 ) - << QgsPoint( 0.000000000000011, 0.000000000000022 ) - << QgsPoint( 0.000000000000001, 0.000000000000022 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0.000000000000001, 0.000000000000002 ) << QgsPoint( 0.000000000000011, 0.000000000000002 ) << QgsPoint( 0.000000000000011, 0.000000000000022 ) << QgsPoint( 0.000000000000001, 0.000000000000022 ) ); QVERIFY( !ls.isClosed() ); ls.close(); @@ -1024,18 +989,12 @@ void TestQgsLineString::close() QGSCOMPARENEAR( ls.pointN( 4 ).y(), 0.000000000000002, 0.00000000000000001 ); //test that m values aren't considered when testing for closedness - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 22, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 6 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 22, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 6 ) ); QVERIFY( ls.isClosed() ); //close with z and m ls = QgsLineString(); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); ls.close(); QCOMPARE( ls.pointN( 4 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); } @@ -1043,10 +1002,7 @@ void TestQgsLineString::close() void TestQgsLineString::asQPolygonF() { QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QPolygonF poly = ls.asQPolygonF(); QCOMPARE( poly.count(), 4 ); @@ -1065,10 +1021,7 @@ void TestQgsLineString::clone() // At the same time, check segmentize as the result should // be equal to a clone for LineStrings QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 2 ) - << QgsPoint( 11, 22 ) - << QgsPoint( 1, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 2 ) << QgsPoint( 11, 22 ) << QgsPoint( 1, 22 ) ); std::unique_ptr cloned( ls.clone() ); QCOMPARE( cloned->numPoints(), 4 ); @@ -1083,7 +1036,7 @@ void TestQgsLineString::clone() QCOMPARE( cloned->pointN( 2 ), ls.pointN( 2 ) ); QCOMPARE( cloned->pointN( 3 ), ls.pointN( 3 ) ); - std::unique_ptr< QgsLineString > segmentized( static_cast< QgsLineString * >( ls.segmentize() ) ); + std::unique_ptr segmentized( static_cast( ls.segmentize() ) ); QCOMPARE( segmentized->numPoints(), 4 ); QCOMPARE( segmentized->wkbType(), Qgis::WkbType::LineString ); @@ -1095,10 +1048,7 @@ void TestQgsLineString::clone() QCOMPARE( segmentized->pointN( 3 ), ls.pointN( 3 ) ); //clone with Z/M - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); cloned.reset( ls.clone() ); QCOMPARE( cloned->numPoints(), 4 ); @@ -1110,7 +1060,7 @@ void TestQgsLineString::clone() QCOMPARE( cloned->pointN( 2 ), ls.pointN( 2 ) ); QCOMPARE( cloned->pointN( 3 ), ls.pointN( 3 ) ); - segmentized.reset( static_cast< QgsLineString * >( ls.segmentize() ) ); + segmentized.reset( static_cast( ls.segmentize() ) ); QCOMPARE( segmentized->numPoints(), 4 ); QCOMPARE( segmentized->wkbType(), Qgis::WkbType::LineStringZM ); @@ -1131,7 +1081,7 @@ void TestQgsLineString::clone() QVERIFY( !cloned->isMeasure() ); QCOMPARE( cloned->wkbType(), Qgis::WkbType::LineString ); - segmentized.reset( static_cast< QgsLineString * >( ls.segmentize() ) ); + segmentized.reset( static_cast( ls.segmentize() ) ); QVERIFY( segmentized->isEmpty() ); QCOMPARE( segmentized->numPoints(), 0 ); @@ -1143,10 +1093,7 @@ void TestQgsLineString::clone() void TestQgsLineString::toWkbFromWkb() { QgsLineString ls1; - ls1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + ls1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QByteArray wkb1 = ls1.asWkb(); QCOMPARE( wkb1.size(), ls1.wkbSize() ); @@ -1186,10 +1133,7 @@ void TestQgsLineString::toWkbFromWkb() void TestQgsLineString::toWktFromWkt() { QgsLineString ls1; - ls1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); + ls1.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 2, 11, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 22, 21, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 22, 31, 34 ) ); QString wkt = ls1.asWkt(); QVERIFY( !wkt.isEmpty() ); @@ -1219,14 +1163,10 @@ void TestQgsLineString::exportAs() { //asGML2 QgsLineString exportLine; - exportLine.setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) - << QgsPoint( 41, 42 ) - << QgsPoint( 51, 52 ) ); + exportLine.setPoints( QgsPointSequence() << QgsPoint( 31, 32 ) << QgsPoint( 41, 42 ) << QgsPoint( 51, 52 ) ); QgsLineString exportLineFloat; - exportLineFloat.setPoints( QgsPointSequence() << QgsPoint( 1 / 3.0, 2 / 3.0 ) - << QgsPoint( 1 + 1 / 3.0, 1 + 2 / 3.0 ) - << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) ); + exportLineFloat.setPoints( QgsPointSequence() << QgsPoint( 1 / 3.0, 2 / 3.0 ) << QgsPoint( 1 + 1 / 3.0, 1 + 2 / 3.0 ) << QgsPoint( 2 + 1 / 3.0, 2 + 2 / 3.0 ) ); QDomDocument doc( QStringLiteral( "gml" ) ); QString expectedGML2( QStringLiteral( "31,32 41,42 51,52" ) ); @@ -1262,17 +1202,13 @@ void TestQgsLineString::length() QgsLineString ls; QCOMPARE( ls.length(), 0.0 ); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QCOMPARE( ls.length(), 23.0 ); } void TestQgsLineString::startEndPoint() { - QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QCOMPARE( ls.startPoint(), QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) ); QCOMPARE( ls.endPoint(), QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); @@ -1290,16 +1226,12 @@ void TestQgsLineString::length3D() QCOMPARE( ls.length3D(), 0.0 ); // without Z - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 3, 4 ) - << QgsPoint( Qgis::WkbType::Point, 8, 16 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 3, 4 ) << QgsPoint( Qgis::WkbType::Point, 8, 16 ) ); QCOMPARE( ls.length3D(), 18.0 ); // with z ls.clear(); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 0 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 4, 6, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 0 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 4, 6, 2 ) ); QCOMPARE( ls.length3D(), 8.0 ); ls.clear(); @@ -1308,19 +1240,15 @@ void TestQgsLineString::length3D() // with z and m ls.clear(); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 0, 0 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 13 ) - << QgsPoint( Qgis::WkbType::PointZM, 4, 6, 2, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 0, 0 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 13 ) << QgsPoint( Qgis::WkbType::PointZM, 4, 6, 2, 7 ) ); QCOMPARE( ls.length3D(), 8.0 ); } void TestQgsLineString::curveToLine() { //no segmentation required, so should return a clone - QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); - std::unique_ptr< QgsLineString > segmentized( static_cast< QgsLineString * >( ls.curveToLine() ) ); + QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + std::unique_ptr segmentized( static_cast( ls.curveToLine() ) ); QCOMPARE( segmentized->numPoints(), 3 ); QCOMPARE( segmentized->wkbType(), Qgis::WkbType::LineStringZM ); @@ -1339,9 +1267,7 @@ void TestQgsLineString::points() ls.points( points ); QVERIFY( ls.isEmpty() ); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); ls.points( points ); QCOMPARE( points.count(), 3 ); @@ -1353,13 +1279,12 @@ void TestQgsLineString::points() void TestQgsLineString::CRSTransform() { QgsCoordinateReferenceSystem sourceSrs( QStringLiteral( "EPSG:3994" ) ); - QgsCoordinateReferenceSystem destSrs( QStringLiteral( "EPSG:4202" ) );// want a transform with ellipsoid change + QgsCoordinateReferenceSystem destSrs( QStringLiteral( "EPSG:4202" ) ); // want a transform with ellipsoid change QgsCoordinateTransform tr( sourceSrs, destSrs, QgsProject::instance() ); // 2d CRS transform QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) - << QgsPoint( 6474985, -3526584 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) << QgsPoint( 6474985, -3526584 ) ); ls.transform( tr, Qgis::TransformDirection::Forward ); QGSCOMPARENEAR( ls.pointN( 0 ).x(), 175.771, 0.001 ); @@ -1372,8 +1297,7 @@ void TestQgsLineString::CRSTransform() QGSCOMPARENEAR( ls.boundingBox().yMaximum(), -38.7999, 0.001 ); //3d CRS transform without considering Z - ls = QgsLineString( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); + ls = QgsLineString( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); ls.transform( tr, Qgis::TransformDirection::Forward ); QGSCOMPARENEAR( ls.pointN( 0 ).x(), 175.771, 0.001 ); @@ -1386,8 +1310,7 @@ void TestQgsLineString::CRSTransform() QCOMPARE( ls.pointN( 1 ).m(), 4.0 ); //3d CRS transform with Z - ls = QgsLineString( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); + ls = QgsLineString( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 3, 4 ) ); ls.transform( tr, Qgis::TransformDirection::Forward, true ); QGSCOMPARENEAR( ls.pointN( 0 ).x(), 175.771, 0.001 ); @@ -1429,16 +1352,14 @@ void TestQgsLineString::QTransformation() { QTransform qtr = QTransform::fromScale( 2, 3 ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); ls.transform( qtr ); QCOMPARE( ls.pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 2, 6, 3, 4 ) ); QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 22, 36, 13, 14 ) ); QCOMPARE( ls.boundingBox(), QgsRectangle( 2, 6, 22, 36 ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); ls.transform( QTransform::fromScale( 1, 1 ), 3, 2, 4, 3 ); QCOMPARE( ls.pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 9, 16 ) ); @@ -1468,8 +1389,7 @@ void TestQgsLineString::insertVertex() QCOMPARE( ls.pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 6.0, 7.0, 1.0, 2.0 ) ); //2d line - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); QVERIFY( ls.insertVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QCOMPARE( ls.numPoints(), 4 ); @@ -1499,9 +1419,7 @@ void TestQgsLineString::insertVertex() QCOMPARE( ls.numPoints(), 7 ); //insert 4d vertex in 4d line - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QVERIFY( ls.insertVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ) ); QCOMPARE( ls.numPoints(), 4 ); @@ -1514,8 +1432,7 @@ void TestQgsLineString::insertVertex() QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 101, 102 ) ); //insert 4d vertex in 2d line - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); QVERIFY( ls.insertVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointZM, 101, 102, 103, 104 ) ) ); QCOMPARE( ls.numPoints(), 4 ); @@ -1538,8 +1455,7 @@ void TestQgsLineString::moveVertex() QVERIFY( ls.isEmpty() ); //valid line - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); QVERIFY( ls.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( ls.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); @@ -1556,9 +1472,7 @@ void TestQgsLineString::moveVertex() QCOMPARE( ls.pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); //move 4d point in 4d line - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 10, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 15, 10, 6, 7 ) ); QVERIFY( ls.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 7, 12, 13 ) ) ); QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 7, 12, 13 ) ); @@ -1568,8 +1482,7 @@ void TestQgsLineString::moveVertex() QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 34, 35, 12, 13 ) ); //move 4d point in 2d line - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) ); QVERIFY( ls.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointZM, 3, 4, 2, 3 ) ) ); QCOMPARE( ls.pointN( 0 ), QgsPoint( 3, 4 ) ); @@ -1584,9 +1497,7 @@ void TestQgsLineString::deleteVertex() QVERIFY( ls.isEmpty() ); //valid line - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); //out of range vertices QVERIFY( !ls.deleteVertex( QgsVertexId( 0, 0, -1 ) ) ); @@ -1608,13 +1519,11 @@ void TestQgsLineString::deleteVertex() void TestQgsLineString::reversed() { QgsLineString ls; - std::unique_ptr< QgsLineString > reversed( ls.reversed() ); + std::unique_ptr reversed( ls.reversed() ); QVERIFY( reversed->isEmpty() ); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); reversed.reset( ls.reversed() ); QCOMPARE( reversed->numPoints(), 3 ); @@ -1652,8 +1561,7 @@ void TestQgsLineString::addZValue() QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZ, 11, 12, 2 ) ); //linestring with m - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) ); QVERIFY( ls.addZValue( 5 ) ); QVERIFY( ls.is3D() ); @@ -1663,8 +1571,7 @@ void TestQgsLineString::addZValue() QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 5, 4 ) ); //linestring25d - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 4 ) ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString25D ); QVERIFY( !ls.addZValue( 5 ) ); @@ -1700,8 +1607,7 @@ void TestQgsLineString::addMValue() QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 2 ) ); //linestring with z - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 4 ) ); QVERIFY( ls.addMValue( 5 ) ); QVERIFY( ls.is3D() ); @@ -1711,8 +1617,7 @@ void TestQgsLineString::addMValue() QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) ); //linestring25d, should become LineStringZM - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 4 ) ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString25D ); QVERIFY( ls.addMValue( 5 ) ); @@ -1742,8 +1647,7 @@ void TestQgsLineString::dropZValue() QVERIFY( !ls.dropZValue() ); //already dropped //linestring with m - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); QVERIFY( ls.dropZValue() ); QVERIFY( !ls.is3D() ); @@ -1753,8 +1657,7 @@ void TestQgsLineString::dropZValue() QCOMPARE( ls.pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 4 ) ); //linestring25d - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 4 ) ); QCOMPARE( ls.wkbType(), Qgis::WkbType::LineString25D ); QVERIFY( ls.dropZValue() ); @@ -1780,8 +1683,7 @@ void TestQgsLineString::dropMValue() QVERIFY( !ls.dropMValue() ); //already dropped //linestring with z - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 3, 4 ) ); QVERIFY( ls.dropMValue() ); QVERIFY( !ls.isMeasure() ); @@ -1826,16 +1728,13 @@ void TestQgsLineString::isRing() QgsLineString ls; QVERIFY( !ls.isRing() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 2 ) ); QVERIFY( !ls.isRing() ); //<4 points - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 31, 32 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 31, 32 ) ); QVERIFY( !ls.isRing() ); //not closed - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); QVERIFY( ls.isRing() ); } @@ -1848,9 +1747,7 @@ void TestQgsLineString::coordinateSequence() QCOMPARE( coords.at( 0 ).count(), 1 ); QVERIFY( coords.at( 0 ).at( 0 ).isEmpty() ); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 21, 22, 6, 7 ) ); coords = ls.coordinateSequence(); QCOMPARE( coords.count(), 1 ); @@ -1904,8 +1801,7 @@ void TestQgsLineString::nextVertex() QCOMPARE( p, QgsPoint( 11, 12 ) ); //LineStringZ - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); v = QgsVertexId( 0, 0, -1 ); QVERIFY( ls.nextVertex( v, p ) ); @@ -1917,8 +1813,7 @@ void TestQgsLineString::nextVertex() QVERIFY( !ls.nextVertex( v, p ) ); //LineStringM - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); v = QgsVertexId( 0, 0, -1 ); QVERIFY( ls.nextVertex( v, p ) ); @@ -1930,8 +1825,7 @@ void TestQgsLineString::nextVertex() QVERIFY( !ls.nextVertex( v, p ) ); //LineStringZM - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); v = QgsVertexId( 0, 0, -1 ); QVERIFY( ls.nextVertex( v, p ) ); @@ -1943,8 +1837,7 @@ void TestQgsLineString::nextVertex() QVERIFY( !ls.nextVertex( v, p ) ); //LineString25D - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 13 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 13 ) ); v = QgsVertexId( 0, 0, -1 ); QVERIFY( ls.nextVertex( v, p ) ); @@ -1997,7 +1890,7 @@ void TestQgsLineString::vertexAtPointAt() Qgis::VertexType type; ls.vertexAt( QgsVertexId( 0, 0, -10 ) ); //out of bounds, check for no crash - ls.vertexAt( QgsVertexId( 0, 0, 10 ) ); //out of bounds, check for no crash + ls.vertexAt( QgsVertexId( 0, 0, 10 ) ); //out of bounds, check for no crash QVERIFY( !ls.pointAt( -10, p, type ) ); QVERIFY( !ls.pointAt( 10, p, type ) ); @@ -2020,8 +1913,7 @@ void TestQgsLineString::vertexAtPointAt() void TestQgsLineString::vertexAtPointAtZ() { - QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); + QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); QgsVertexId v; QgsPoint p; Qgis::VertexType type; @@ -2038,8 +1930,7 @@ void TestQgsLineString::vertexAtPointAtZ() void TestQgsLineString::vertexAtPointAtM() { - QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); + QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 14 ) ); QgsVertexId v; QgsPoint p; Qgis::VertexType type; @@ -2057,8 +1948,7 @@ void TestQgsLineString::vertexAtPointAtM() void TestQgsLineString::vertexAtPointAtZM() { //LineStringZM - QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); + QgsLineString ls( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) ); QgsVertexId v; QgsPoint p; Qgis::VertexType type; @@ -2076,8 +1966,7 @@ void TestQgsLineString::vertexAtPointAtZM() void TestQgsLineString::vertexAtPointAt25D() { QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 13 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 11, 12, 13 ) ); QgsVertexId v; QgsPoint p; @@ -2104,18 +1993,15 @@ void TestQgsLineString::centroid() ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 20, 10 ) ); QCOMPARE( ls.centroid(), QgsPoint( 10, 5 ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 9 ) - << QgsPoint( 2, 9 ) << QgsPoint( 2, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 9 ) << QgsPoint( 2, 9 ) << QgsPoint( 2, 0 ) ); QCOMPARE( ls.centroid(), QgsPoint( 1, 4.95 ) ); //linestring with 0 length segment - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 9 ) - << QgsPoint( 2, 9 ) << QgsPoint( 2, 9 ) << QgsPoint( 2, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 9 ) << QgsPoint( 2, 9 ) << QgsPoint( 2, 9 ) << QgsPoint( 2, 0 ) ); QCOMPARE( ls.centroid(), QgsPoint( 1, 4.95 ) ); //linestring with 0 total length segment - ls.setPoints( QgsPointSequence() << QgsPoint( 5, 4 ) - << QgsPoint( 5, 4 ) << QgsPoint( 5, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 5, 4 ) << QgsPoint( 5, 4 ) << QgsPoint( 5, 4 ) ); QCOMPARE( ls.centroid(), QgsPoint( 5, 4 ) ); } @@ -2126,7 +2012,7 @@ void TestQgsLineString::closestSegment() QgsPoint p( 0, 0 ); // reset all coords to zero QgsVertexId v; - ( void )ls.closestSegment( QgsPoint( 1, 2 ), p, v ); //empty line, just want no crash + ( void ) ls.closestSegment( QgsPoint( 1, 2 ), p, v ); //empty line, just want no crash ls.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) ); QVERIFY( ls.closestSegment( QgsPoint( 5, 10 ), p, v ) < 0 ); @@ -2150,69 +2036,49 @@ void TestQgsLineString::closestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); QCOMPARE( leftOf, 1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 10, 10 ) - << QgsPoint( 10, 15 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 15 ) ); QGSCOMPARENEAR( ls.closestSegment( QgsPoint( 11, 12 ), p, v, &leftOf ), 1.0, 4 * std::numeric_limits::epsilon() ); QCOMPARE( p, QgsPoint( 10, 12 ) ); QCOMPARE( v, QgsVertexId( 0, 0, 2 ) ); QCOMPARE( leftOf, 1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) - << QgsPoint( 6, 4 ) - << QgsPoint( 4, 4 ) - << QgsPoint( 5, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) << QgsPoint( 6, 4 ) << QgsPoint( 4, 4 ) << QgsPoint( 5, 5 ) ); QGSCOMPARENEAR( ls.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * std::numeric_limits::epsilon() ); QCOMPARE( p, QgsPoint( 4, 4 ) ); QCOMPARE( v, QgsVertexId( 0, 0, 2 ) ); QCOMPARE( leftOf, -1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) - << QgsPoint( 4, 4 ) - << QgsPoint( 6, 4 ) - << QgsPoint( 5, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) << QgsPoint( 4, 4 ) << QgsPoint( 6, 4 ) << QgsPoint( 5, 5 ) ); QGSCOMPARENEAR( ls.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * std::numeric_limits::epsilon() ); QCOMPARE( p, QgsPoint( 4, 4 ) ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); QCOMPARE( leftOf, 1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) - << QgsPoint( 6, 4 ) - << QgsPoint( 4, 4 ) - << QgsPoint( 5, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) << QgsPoint( 6, 4 ) << QgsPoint( 4, 4 ) << QgsPoint( 5, 5 ) ); QGSCOMPARENEAR( ls.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * std::numeric_limits::epsilon() ); QCOMPARE( p, QgsPoint( 4, 4 ) ); QCOMPARE( v, QgsVertexId( 0, 0, 2 ) ); QCOMPARE( leftOf, -1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) - << QgsPoint( 4, 4 ) - << QgsPoint( 6, 4 ) - << QgsPoint( 5, 5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) << QgsPoint( 4, 4 ) << QgsPoint( 6, 4 ) << QgsPoint( 5, 5 ) ); QGSCOMPARENEAR( ls.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * std::numeric_limits::epsilon() ); QCOMPARE( p, QgsPoint( 4, 4 ) ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); QCOMPARE( leftOf, 1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 4 ) - << QgsPoint( 2, 2 ) - << QgsPoint( 1, 1 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 4 ) << QgsPoint( 2, 2 ) << QgsPoint( 1, 1 ) ); QGSCOMPARENEAR( ls.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * std::numeric_limits::epsilon() ); QCOMPARE( p, QgsPoint( 1, 1 ) ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); QCOMPARE( leftOf, -1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 2, 2 ) - << QgsPoint( 1, 4 ) - << QgsPoint( 1, 1 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 2, 2 ) << QgsPoint( 1, 4 ) << QgsPoint( 1, 1 ) ); QGSCOMPARENEAR( ls.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * std::numeric_limits::epsilon() ); QCOMPARE( p, QgsPoint( 1, 1 ) ); @@ -2236,20 +2102,16 @@ void TestQgsLineString::sumUpArea() ls.sumUpArea( area ); QGSCOMPARENEAR( area, -24, 4 * std::numeric_limits::epsilon() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) ); ls.sumUpArea( area ); QGSCOMPARENEAR( area, -22, 4 * std::numeric_limits::epsilon() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) - << QgsPoint( 2, 2 ) << QgsPoint( 0, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) << QgsPoint( 0, 2 ) ); ls.sumUpArea( area ); QGSCOMPARENEAR( area, -18, 4 * std::numeric_limits::epsilon() ); double shift = 10.0; - ls.setPoints( QgsPointSequence() << QgsPoint( shift + 0, shift + 0 ) << QgsPoint( shift + 2, shift + 0 ) - << QgsPoint( shift + 2, shift + 2 ) << QgsPoint( shift + 0, shift + 2 ) - << QgsPoint( shift + 0, shift + 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( shift + 0, shift + 0 ) << QgsPoint( shift + 2, shift + 0 ) << QgsPoint( shift + 2, shift + 2 ) << QgsPoint( shift + 0, shift + 2 ) << QgsPoint( shift + 0, shift + 0 ) ); ls.sumUpArea( area ); QGSCOMPARENEAR( area, -14, 4 * std::numeric_limits::epsilon() ); @@ -2261,9 +2123,7 @@ void TestQgsLineString::sumUpArea() for ( int accuracyMeterPow = 3; accuracyMeterPow >= -3; accuracyMeterPow-- ) { area = accuracyMeterPow - 4.0; - ls.setPoints( QgsPointSequence() << QgsPoint( shift + 0, shift + 0 ) << QgsPoint( shift + 2, shift + 0 ) - << QgsPoint( shift + 2, shift + 2 ) << QgsPoint( shift + 0, shift + 2 ) - << QgsPoint( shift + 0, shift + 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( shift + 0, shift + 0 ) << QgsPoint( shift + 2, shift + 0 ) << QgsPoint( shift + 2, shift + 2 ) << QgsPoint( shift + 0, shift + 2 ) << QgsPoint( shift + 0, shift + 0 ) ); ls.sumUpArea( area ); QGSCOMPARENEAR( area, accuracyMeterPow, epsilonArea ); shift = shift * 10.0; @@ -2279,8 +2139,7 @@ void TestQgsLineString::boundingBox() ls.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 15 ) ); QCOMPARE( ls.boundingBox(), QgsRectangle( 5, 10, 10, 15 ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) - << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( -5, -10 ) << QgsPoint( -6, -10 ) << QgsPoint( -5.5, -9 ) ); QCOMPARE( ls.boundingBox(), QgsRectangle( -6, -10, -5, -9 ) ); //setXAt @@ -2327,36 +2186,30 @@ void TestQgsLineString::boundingBox3D() { // boundingBox - test 3D boundingbox QgsLineString bb3d; - bb3d.setPoints( QgsPointSequence() << QgsPoint( -1.0, -1.0, -1.0 ) - << QgsPoint( -2.0, -1.0, -1.0 ) - << QgsPoint( 1.0, 2.0, -1.0 ) - << QgsPoint( 1.0, 2.0, 2.0 ) ); + bb3d.setPoints( QgsPointSequence() << QgsPoint( -1.0, -1.0, -1.0 ) << QgsPoint( -2.0, -1.0, -1.0 ) << QgsPoint( 1.0, 2.0, -1.0 ) << QgsPoint( 1.0, 2.0, 2.0 ) ); QCOMPARE( bb3d.calculateBoundingBox3D(), QgsBox3D( QgsPoint( -2.0, -1.0, -1.0 ), QgsPoint( 1.0, 2.0, 2.0 ) ) ); // retrieve again, should use cached values QCOMPARE( bb3d.calculateBoundingBox3D(), QgsBox3D( QgsPoint( -2.0, -1.0, -1.0 ), QgsPoint( 1.0, 2.0, 2.0 ) ) ); // linestring with z - bb3d.setPoints( QgsPointSequence() << QgsPoint( -1.0, -1.0 ) - << QgsPoint( -2.0, -1.0 ) - << QgsPoint( 1.0, 2.0 ) - << QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( bb3d.calculateBoundingBox3D(), QgsBox3D( QgsPoint( -2.0, -1, std::numeric_limits< double >::quiet_NaN() ), QgsPoint( 1.0, 2.0, std::numeric_limits< double >::quiet_NaN() ) ) ); + bb3d.setPoints( QgsPointSequence() << QgsPoint( -1.0, -1.0 ) << QgsPoint( -2.0, -1.0 ) << QgsPoint( 1.0, 2.0 ) << QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( bb3d.calculateBoundingBox3D(), QgsBox3D( QgsPoint( -2.0, -1, std::numeric_limits::quiet_NaN() ), QgsPoint( 1.0, 2.0, std::numeric_limits::quiet_NaN() ) ) ); } void TestQgsLineString::angle() { QgsLineString ls; - ( void )ls.vertexAngle( QgsVertexId() ); //just want no crash - ( void )ls.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash + ( void ) ls.vertexAngle( QgsVertexId() ); //just want no crash + ( void ) ls.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) ); - ( void )ls.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless + ( void ) ls.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash, any answer is meaningless ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) ); QGSCOMPARENEAR( ls.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 1.5708, 0.0001 ); QGSCOMPARENEAR( ls.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 1.5708, 0.0001 ); - ( void )ls.vertexAngle( QgsVertexId( 0, 0, 2 ) ); //no crash + ( void ) ls.vertexAngle( QgsVertexId( 0, 0, 2 ) ); //no crash ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) ); QGSCOMPARENEAR( ls.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 0.0, 4 * std::numeric_limits::epsilon() ); @@ -2375,9 +2228,8 @@ void TestQgsLineString::angle() QGSCOMPARENEAR( ls.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 0.7854, 0.0001 ); QGSCOMPARENEAR( ls.vertexAngle( QgsVertexId( 0, 0, 2 ) ), 0.0, 0.0001 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) ); - ( void )ls.vertexAngle( QgsVertexId( 0, 0, 20 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) ); + ( void ) ls.vertexAngle( QgsVertexId( 0, 0, 20 ) ); QGSCOMPARENEAR( ls.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 1.5708, 0.0001 ); QGSCOMPARENEAR( ls.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 1.5708, 0.0001 ); @@ -2410,41 +2262,37 @@ void TestQgsLineString::boundary() QgsLineString ls; QVERIFY( !ls.boundary() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); QgsAbstractGeometry *boundary = ls.boundary(); - QgsMultiPoint *mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + QgsMultiPoint *mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); delete boundary; // closed string = no boundary - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); QVERIFY( !ls.boundary() ); - \ + //boundary with z - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); boundary = ls.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->geometryN( 0 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->z(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->z(), 10.0 ); QCOMPARE( mpBoundary->geometryN( 1 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); delete boundary; } @@ -2454,8 +2302,7 @@ void TestQgsLineString::extend() QgsLineString ls; ls.extend( 10, 10 ); //test no crash - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); ls.extend( 1, 2 ); QCOMPARE( ls.pointN( 0 ), QgsPoint( Qgis::WkbType::Point, -1, 0 ) ); @@ -2473,8 +2320,7 @@ void TestQgsLineString::addToPainterPath() path.addToPainterPath( pPath ); QVERIFY( pPath.isEmpty() ); - path.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); + path.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) ); path.addToPainterPath( pPath ); QVERIFY( !pPath.isEmpty() ); @@ -2484,7 +2330,7 @@ void TestQgsLineString::toCurveType() { QgsLineString ls; ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) ); - std::unique_ptr< QgsCompoundCurve > curveType( ls.toCurveType() ); + std::unique_ptr curveType( ls.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::CompoundCurve ); QCOMPARE( curveType->numPoints(), 2 ); @@ -2547,8 +2393,7 @@ void TestQgsLineString::vertexNumberFromVertexId() QCOMPARE( ls.vertexNumberFromVertexId( QgsVertexId( 0, 0, 0 ) ), -1 ); QCOMPARE( ls.vertexNumberFromVertexId( QgsVertexId( 1, 0, 0 ) ), -1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 112 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 112 ) ); QCOMPARE( ls.vertexNumberFromVertexId( QgsVertexId( -1, 0, 0 ) ), -1 ); QCOMPARE( ls.vertexNumberFromVertexId( QgsVertexId( 1, 0, 0 ) ), -1 ); @@ -2569,8 +2414,7 @@ void TestQgsLineString::segmentLength() QCOMPARE( ls.segmentLength( QgsVertexId( 0, 0, 0 ) ), 0.0 ); QCOMPARE( ls.segmentLength( QgsVertexId( 1, 0, 0 ) ), 0.0 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); QCOMPARE( ls.segmentLength( QgsVertexId() ), 0.0 ); QCOMPARE( ls.segmentLength( QgsVertexId( 0, 0, -1 ) ), 0.0 ); @@ -2592,13 +2436,10 @@ void TestQgsLineString::collectDuplicateNodes() QVERIFY( ls.collectDuplicateNodes( 0.0, false ).isEmpty() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) - << QgsPoint( 1, 3, 3 ) << QgsPoint( 1, 3, 5 ) - << QgsPoint( 2, 4, 3 ) << QgsPoint( 2, 4, 3 ) - << QgsPoint( 4, 5, 6 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 1, 3, 3 ) << QgsPoint( 1, 3, 5 ) << QgsPoint( 2, 4, 3 ) << QgsPoint( 2, 4, 3 ) << QgsPoint( 4, 5, 6 ) ); // without considering Z - QVector< QgsVertexId > duplicateNodes = ls.collectDuplicateNodes( 0.1, false ); + QVector duplicateNodes = ls.collectDuplicateNodes( 0.1, false ); QCOMPARE( duplicateNodes.size(), 2 ); QCOMPARE( duplicateNodes[0], QgsVertexId( -1, -1, 2 ) ); @@ -2616,23 +2457,18 @@ void TestQgsLineString::removeDuplicateNodes() QgsLineString ls; QVERIFY( !ls.removeDuplicateNodes() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); QVERIFY( !ls.removeDuplicateNodes() ); QCOMPARE( ls.asWkt(), QStringLiteral( "LineString (11 2, 11 12, 111 12)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) - << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) - << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); QVERIFY( ls.removeDuplicateNodes( 0.02 ) ); QVERIFY( !ls.removeDuplicateNodes( 0.02 ) ); QCOMPARE( ls.asWkt(), QStringLiteral( "LineString (11 2, 11 12, 111 12)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) - << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) - << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111.01, 11.99 ) ); QVERIFY( !ls.removeDuplicateNodes() ); QCOMPARE( ls.asWkt( 2 ), QStringLiteral( "LineString (11 2, 11.01 1.99, 11.02 2.01, 11 12, 111 12, 111.01 11.99)" ) ); @@ -2649,16 +2485,12 @@ void TestQgsLineString::removeDuplicateNodes() QCOMPARE( ls.asWkt( 2 ), QStringLiteral( "LineString (11 2, 11.01 1.99)" ) ); // with z - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) - << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) - << QgsPoint( 111, 12, 5 ) << QgsPoint( 111.01, 11.99, 6 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) << QgsPoint( 111, 12, 5 ) << QgsPoint( 111.01, 11.99, 6 ) ); QVERIFY( ls.removeDuplicateNodes( 0.02 ) ); QCOMPARE( ls.asWkt(), QStringLiteral( "LineString Z (11 2 1, 11 12 4, 111 12 5)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) - << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) - << QgsPoint( 111, 12, 5 ) << QgsPoint( 111.01, 11.99, 6 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 1 ) << QgsPoint( 11.01, 1.99, 2 ) << QgsPoint( 11.02, 2.01, 3 ) << QgsPoint( 11, 12, 4 ) << QgsPoint( 111, 12, 5 ) << QgsPoint( 111.01, 11.99, 6 ) ); QVERIFY( !ls.removeDuplicateNodes( 0.02, true ) ); QCOMPARE( ls.asWkt( 2 ), QStringLiteral( "LineString Z (11 2 1, 11.01 1.99 2, 11.02 2.01 3, 11 12 4, 111 12 5, 111.01 11.99 6)" ) ); @@ -2668,9 +2500,7 @@ void TestQgsLineString::swapXy() { QgsLineString ls; ls.swapXy(); // no crash - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); ls.swapXy(); QCOMPARE( ls.asWkt( 2 ), QStringLiteral( "LineString ZM (2 11 3 4, 12 11 13 14, 12 111 23 24)" ) ); @@ -2679,37 +2509,28 @@ void TestQgsLineString::swapXy() void TestQgsLineString::filterVertices() { QgsLineString ls; - auto filter = []( const QgsPoint & point )-> bool - { + auto filter = []( const QgsPoint &point ) -> bool { return point.x() < 5; }; ls.filterVertices( filter ); // no crash - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); ls.filterVertices( filter ); QCOMPARE( ls.asWkt( 2 ), QStringLiteral( "LineString ZM (1 2 3 4, 4 12 13 14)" ) ); - } void TestQgsLineString::transformVertices() { QgsLineString ls; - auto transform = []( const QgsPoint & point )-> QgsPoint - { + auto transform = []( const QgsPoint &point ) -> QgsPoint { return QgsPoint( point.x() + 5, point.y() + 6, point.z() + 7, point.m() + 8 ); }; ls.transformVertices( transform ); // no crash - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); ls.transformVertices( transform ); QCOMPARE( ls.asWkt( 2 ), QStringLiteral( "LineString ZM (16 8 10 12, 6 8 10 12, 9 18 20 22, 116 18 30 32)" ) ); @@ -2722,10 +2543,7 @@ void TestQgsLineString::transformVertices() QVERIFY( !ls.transform( nullptr ) ); QVERIFY( ls.transform( &transformer ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); QVERIFY( ls.transform( &transformer ) ); QCOMPARE( ls.asWkt( 2 ), QStringLiteral( "LineString ZM (33 16 8 3, 3 16 8 3, 12 26 18 13, 333 26 28 23)" ) ); @@ -2742,13 +2560,11 @@ void TestQgsLineString::curveSubstring() { QgsLineString ls; - std::unique_ptr< QgsLineString > substringResult( ls.curveSubstring( 1, 2 ) ); // no crash + std::unique_ptr substringResult( ls.curveSubstring( 1, 2 ) ); // no crash QVERIFY( substringResult.get() ); QVERIFY( substringResult->isEmpty() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); substringResult.reset( ls.curveSubstring( 0, 0 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "LineString ZM (11 2 3 4, 11 2 3 4)" ) ); @@ -2775,19 +2591,16 @@ void TestQgsLineString::curveSubstring() QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "LineString ZM (11 3 4 5, 11 12 13 14, 21 12 14 15)" ) ); substringResult.reset( ls.curveSubstring( - QgsGeometryUtils::distanceToVertex( ls, QgsVertexId( 0, 0, 1 ) ), - QgsGeometryUtils::distanceToVertex( ls, QgsVertexId( 0, 0, 2 ) ) ) ); + QgsGeometryUtils::distanceToVertex( ls, QgsVertexId( 0, 0, 1 ) ), + QgsGeometryUtils::distanceToVertex( ls, QgsVertexId( 0, 0, 2 ) ) + ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "LineString ZM (11 12 13 14, 111 12 23 24)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 0, Qgis::WkbType::PointZ ) - << QgsPoint( 11, 12, 13, 0, Qgis::WkbType::PointZ ) - << QgsPoint( 111, 12, 23, 0, Qgis::WkbType::PointZ ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 0, Qgis::WkbType::PointZ ) << QgsPoint( 11, 12, 13, 0, Qgis::WkbType::PointZ ) << QgsPoint( 111, 12, 23, 0, Qgis::WkbType::PointZ ) ); substringResult.reset( ls.curveSubstring( 1, 20 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "LineString Z (11 3 4, 11 12 13, 21 12 14)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 0, 3, Qgis::WkbType::PointM ) - << QgsPoint( 11, 12, 0, 13, Qgis::WkbType::PointM ) - << QgsPoint( 111, 12, 0, 23, Qgis::WkbType::PointM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 0, 3, Qgis::WkbType::PointM ) << QgsPoint( 11, 12, 0, 13, Qgis::WkbType::PointM ) << QgsPoint( 111, 12, 0, 23, Qgis::WkbType::PointM ) ); substringResult.reset( ls.curveSubstring( 1, 20 ) ); QCOMPARE( substringResult->asWkt( 2 ), QStringLiteral( "LineString M (11 3 4, 11 12 13, 21 12 14)" ) ); @@ -2802,12 +2615,10 @@ void TestQgsLineString::interpolatePoint() { QgsLineString ls; - std::unique_ptr< QgsPoint > interpolateResult( ls.interpolatePoint( 1 ) ); // no crash + std::unique_ptr interpolateResult( ls.interpolatePoint( 1 ) ); // no crash QVERIFY( !interpolateResult.get() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); interpolateResult.reset( ls.interpolatePoint( 0 ) ); QCOMPARE( interpolateResult->asWkt( 2 ), QStringLiteral( "Point ZM (11 2 3 4)" ) ); @@ -2827,22 +2638,17 @@ void TestQgsLineString::interpolatePoint() interpolateResult.reset( ls.interpolatePoint( 110 ) ); QCOMPARE( interpolateResult->asWkt( 2 ), QStringLiteral( "Point ZM (111 12 23 24)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 0, Qgis::WkbType::PointZ ) - << QgsPoint( 11, 12, 13, 0, Qgis::WkbType::PointZ ) - << QgsPoint( 111, 12, 23, 0, Qgis::WkbType::PointZ ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 0, Qgis::WkbType::PointZ ) << QgsPoint( 11, 12, 13, 0, Qgis::WkbType::PointZ ) << QgsPoint( 111, 12, 23, 0, Qgis::WkbType::PointZ ) ); interpolateResult.reset( ls.interpolatePoint( 1 ) ); QCOMPARE( interpolateResult->asWkt( 2 ), QStringLiteral( "Point Z (11 3 4)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 0, 3, Qgis::WkbType::PointM ) - << QgsPoint( 11, 12, 0, 13, Qgis::WkbType::PointM ) - << QgsPoint( 111, 12, 0, 23, Qgis::WkbType::PointM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 0, 3, Qgis::WkbType::PointM ) << QgsPoint( 11, 12, 0, 13, Qgis::WkbType::PointM ) << QgsPoint( 111, 12, 0, 23, Qgis::WkbType::PointM ) ); interpolateResult.reset( ls.interpolatePoint( 1 ) ); QCOMPARE( interpolateResult->asWkt( 2 ), QStringLiteral( "Point M (11 3 4)" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) ); interpolateResult.reset( ls.interpolatePoint( 1 ) ); QCOMPARE( interpolateResult->asWkt( 2 ), QStringLiteral( "Point (11 3)" ) ); @@ -2851,23 +2657,19 @@ void TestQgsLineString::interpolatePoint() void TestQgsLineString::visitPoints() { QgsLineString ls; - ls.visitPointsByRegularDistance( 1, [ = ]( double, double, double, double, double, double, double, double, double, double, double, double )->bool - { + ls.visitPointsByRegularDistance( 1, [=]( double, double, double, double, double, double, double, double, double, double, double, double ) -> bool { return true; } ); // no crash - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 111, 12, 23, 24, Qgis::WkbType::PointZM ) ); int visitCount = 0; - QVector< double > xx; - QVector< double > yy; - QVector< double > zz; - QVector< double > mm; - QVector< double > pX, pY, pZ, pM, nX, nY, nZ, nM; + QVector xx; + QVector yy; + QVector zz; + QVector mm; + QVector pX, pY, pZ, pM, nX, nY, nZ, nM; - auto visitor = [ & ]( double x, double y, double z, double m, double ppx, double ppy, double ppz, double ppm, double nnx, double nny, double nnz, double nnm )->bool - { + auto visitor = [&]( double x, double y, double z, double m, double ppx, double ppy, double ppz, double ppm, double nnx, double nny, double nnz, double nnm ) -> bool { xx << x; yy << y; zz << z; @@ -2956,17 +2758,13 @@ void TestQgsLineString::orientation() { QgsLineString ls; - ( void )ls.orientation(); // no crash + ( void ) ls.orientation(); // no crash - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 1 ) << QgsPoint( 1, 1 ) - << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) << QgsPoint( 1, 1 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); QCOMPARE( ls.orientation(), Qgis::AngularDirection::Clockwise ); - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) - << QgsPoint( 0, 1 ) << QgsPoint( 0, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 1 ) << QgsPoint( 0, 0 ) ); QCOMPARE( ls.orientation(), Qgis::AngularDirection::CounterClockwise ); } @@ -2977,8 +2775,7 @@ void TestQgsLineString::boundingBoxIntersects() QgsLineString ls; QVERIFY( !ls.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); QVERIFY( ls.boundingBoxIntersects( QgsRectangle( 12, 3, 16, 9 ) ) ); @@ -2989,8 +2786,7 @@ void TestQgsLineString::boundingBoxIntersects() QCOMPARE( ls.boundingBox(), QgsRectangle( 11, -10, 13, 12 ) ); // clear cache - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); QVERIFY( !ls.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); QVERIFY( !ls.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); @@ -3001,8 +2797,7 @@ void TestQgsLineString::boundingBoxIntersects() QgsLineString ls3d; QVERIFY( !ls3d.boundingBoxIntersects( QgsBox3D( 1, 3, 5, 6, 9, 11 ) ) ); - ls3d.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); + ls3d.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); QVERIFY( ls3d.boundingBoxIntersects( QgsRectangle( 12, 3, 16, 9 ) ) ); @@ -3013,8 +2808,7 @@ void TestQgsLineString::boundingBoxIntersects() QCOMPARE( ls3d.boundingBox(), QgsRectangle( 11, -10, 13, 12 ) ); // clear cache - ls3d.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); + ls3d.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 13, -10 ) ); QVERIFY( !ls3d.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); QVERIFY( !ls3d.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); @@ -3027,8 +2821,8 @@ void TestQgsLineString::setPointsFromData() { //setPoints QgsLineString l8; - double x [] = {1, 2, 3}; - double y [] = {2, 3, 4}; + double x[] = { 1, 2, 3 }; + double y[] = { 2, 3, 4 }; l8.setPoints( 3, x, y ); QVERIFY( !l8.isEmpty() ); QCOMPARE( l8.numPoints(), 3 ); @@ -3063,9 +2857,9 @@ void TestQgsLineString::setPointsFromData() QVERIFY( pts.isEmpty() ); //setPoints with z - double x3 [] = {1, 2}; - double y3 [] = {2, 3}; - double z3 [] = {3, 4}; + double x3[] = { 1, 2 }; + double y3[] = { 2, 3 }; + double z3[] = { 3, 4 }; l8.setPoints( 2, x3, y3, z3 ); QCOMPARE( l8.numPoints(), 2 ); QVERIFY( l8.is3D() ); @@ -3075,9 +2869,9 @@ void TestQgsLineString::setPointsFromData() QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 3, 4 ) ); //setPoints with m - double x4 [] = {1, 2}; - double y4 [] = {2, 3}; - double m4 [] = {3, 4}; + double x4[] = { 1, 2 }; + double y4[] = { 2, 3 }; + double m4[] = { 3, 4 }; l8.setPoints( 2, x4, y4, nullptr, m4 ); QCOMPARE( l8.numPoints(), 2 ); QVERIFY( !l8.is3D() ); @@ -3087,10 +2881,10 @@ void TestQgsLineString::setPointsFromData() QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 2, 3, 0, 4 ) ); //setPoints with zm - double x5 [] = {1, 2}; - double y5 [] = {2, 3}; - double z5 [] = {4, 4}; - double m5 [] = {5, 5}; + double x5[] = { 1, 2 }; + double y5[] = { 2, 3 }; + double z5[] = { 4, 4 }; + double m5[] = { 5, 5 }; l8.setPoints( 2, x5, y5, z5, m5 ); l8.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); QCOMPARE( l8.numPoints(), 2 ); @@ -3099,7 +2893,6 @@ void TestQgsLineString::setPointsFromData() QCOMPARE( l8.wkbType(), Qgis::WkbType::LineStringZM ); l8.points( pts ); QCOMPARE( pts, QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 3, 4, 5 ) ); - } QGSTEST_MAIN( TestQgsLineString ) diff --git a/tests/src/core/geometry/testqgsmulticurve.cpp b/tests/src/core/geometry/testqgsmulticurve.cpp index 37e5826891c4..a0223fe1d306 100644 --- a/tests/src/core/geometry/testqgsmulticurve.cpp +++ b/tests/src/core/geometry/testqgsmulticurve.cpp @@ -24,7 +24,7 @@ #include "testgeometryutils.h" -class TestQgsMultiCurve: public QObject +class TestQgsMultiCurve : public QObject { Q_OBJECT private slots: @@ -107,8 +107,7 @@ void TestQgsMultiCurve::addGeometry() //valid geometry QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) - << QgsPoint( 2, 11 ) << QgsPoint( 1, 12 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) << QgsPoint( 1, 12 ) ); mc.addGeometry( part.clone() ); QVERIFY( !mc.isEmpty() ); @@ -126,7 +125,7 @@ void TestQgsMultiCurve::addGeometry() QCOMPARE( mc.area(), 0.0 ); QCOMPARE( mc.perimeter(), 0.0 ); QVERIFY( mc.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( mc.geometryN( 0 ) ), part ); QVERIFY( !mc.geometryN( 100 ) ); QVERIFY( !mc.geometryN( -1 ) ); QCOMPARE( mc.vertexCount( 0, 0 ), 3 ); @@ -138,9 +137,7 @@ void TestQgsMultiCurve::addGeometryZM() //initial adding of geometry should set z/m type QgsMultiCurve mc; QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 31, 3 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 31, 3 ) ); mc.addGeometry( part.clone() ); QVERIFY( mc.is3D() ); @@ -148,48 +145,42 @@ void TestQgsMultiCurve::addGeometryZM() QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZ ); QCOMPARE( mc.wktTypeStr(), QString( "MultiCurve Z" ) ); QCOMPARE( mc.geometryType(), QString( "MultiCurve" ) ); - QCOMPARE( *( static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mc.geometryN( 0 ) ) ), part ); mc.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 31, 0, 3 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 31, 0, 3 ) ); mc.addGeometry( part.clone() ); QVERIFY( !mc.is3D() ); QVERIFY( mc.isMeasure() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveM ); QCOMPARE( mc.wktTypeStr(), QString( "MultiCurve M" ) ); - QCOMPARE( *( static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mc.geometryN( 0 ) ) ), part ); mc.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 31, 4, 5 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 31, 4, 5 ) ); mc.addGeometry( part.clone() ); QVERIFY( mc.is3D() ); QVERIFY( mc.isMeasure() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZM ); QCOMPARE( mc.wktTypeStr(), QString( "MultiCurve ZM" ) ); - QCOMPARE( *( static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mc.geometryN( 0 ) ) ), part ); //add another part mc.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) - << QgsPoint( 2, 11 ) << QgsPoint( 1, 20 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) << QgsPoint( 1, 20 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.vertexCount( 0, 0 ), 3 ); - part.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) - << QgsPoint( 3, 13 ) << QgsPoint( 9, 20 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) << QgsPoint( 9, 20 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.vertexCount( 1, 0 ), 3 ); QCOMPARE( mc.numGeometries(), 2 ); QVERIFY( mc.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( mc.geometryN( 1 ) ), part ); } void TestQgsMultiCurve::addGeometryDimensionPreservation() @@ -197,14 +188,12 @@ void TestQgsMultiCurve::addGeometryDimensionPreservation() //adding subsequent points should not alter z/m type, regardless of parts type QgsMultiCurve mc; QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) - << QgsPoint( 3, 13 ) << QgsPoint( 9, 20 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) << QgsPoint( 9, 20 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurve ); - part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) - << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 20, 4 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 20, 4 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurve ); @@ -217,21 +206,19 @@ void TestQgsMultiCurve::addGeometryDimensionPreservation() QCOMPARE( mc.partCount(), 2 ); QVERIFY( !mc.is3D() ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( mc.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 9, 12 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 3, 13 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( 9, 20 ) ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 1 ) ); + ls = static_cast( mc.geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 1, 10 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 2, 11 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( 1, 20 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 21, 51, 0, 4 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 21, 51, 0, 4 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurve ); @@ -244,7 +231,7 @@ void TestQgsMultiCurve::addGeometryDimensionPreservation() QVERIFY( !mc.is3D() ); QVERIFY( !mc.isMeasure() ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 2 ) ); + ls = static_cast( mc.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 21, 30 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 32, 41 ) ); @@ -255,41 +242,37 @@ void TestQgsMultiCurve::addGeometryDimensionPreservationZ() { QgsMultiCurve mc; QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) - << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 21, 4 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 21, 4 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZ ); - part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) - << QgsPoint( 3, 31 ) << QgsPoint( 2, 41 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) << QgsPoint( 2, 41 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZ ); QVERIFY( mc.is3D() ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( mc.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 1, 10, 2 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 2, 11, 3 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( 1, 21, 4 ) ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 1 ) ); + ls = static_cast( mc.geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 2, 20, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 3, 31, 0 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( 2, 41, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 5, 71, 0, 6 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 5, 71, 0, 6 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZ ); QVERIFY( mc.is3D() ); QVERIFY( !mc.isMeasure() ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 2 ) ); + ls = static_cast( mc.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 5, 50, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 6, 61, 0 ) ); @@ -303,41 +286,37 @@ void TestQgsMultiCurve::addGeometryDimensionPreservationM() QgsCircularString part; QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurve ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 5, 71, 0, 5 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 5, 71, 0, 5 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveM ); - part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) - << QgsPoint( 3, 31 ) << QgsPoint( 2, 41 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) << QgsPoint( 2, 41 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveM ); QVERIFY( mc.isMeasure() ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( mc.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( Qgis::WkbType::PointM, 5, 71, 0, 5 ) ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 1 ) ); + ls = static_cast( mc.geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 2, 20, 0, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 3, 31, 0, 0 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( Qgis::WkbType::PointM, 2, 41, 0, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) - << QgsPoint( 14, 15, 16 ) << QgsPoint( 11, 25, 17 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) << QgsPoint( 14, 15, 16 ) << QgsPoint( 11, 25, 17 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveM ); QVERIFY( !mc.is3D() ); QVERIFY( mc.isMeasure() ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 2 ) ); + ls = static_cast( mc.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 14, 15, 0, 0 ) ); @@ -348,59 +327,51 @@ void TestQgsMultiCurve::addGeometryDimensionPreservationZM() { QgsMultiCurve mc; QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZM ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 11 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 11 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZM ); QVERIFY( mc.isMeasure() ); QVERIFY( mc.is3D() ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( mc.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 1 ) ); + ls = static_cast( mc.geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 7, 17, 0, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 3, 13, 0, 0 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 7, 11, 0, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) - << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) - << QgsPoint( Qgis::WkbType::PointZ, 77, 81, 9 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) << QgsPoint( Qgis::WkbType::PointZ, 77, 81, 9 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZM ); QVERIFY( mc.is3D() ); QVERIFY( mc.isMeasure() ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 2 ) ); + ls = static_cast( mc.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 77, 87, 7, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 83, 83, 8, 0 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 77, 81, 9, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) - << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) - << QgsPoint( Qgis::WkbType::PointM, 177, 181, 0, 13 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) << QgsPoint( Qgis::WkbType::PointM, 177, 181, 0, 13 ) ); mc.addGeometry( part.clone() ); QCOMPARE( mc.wkbType(), Qgis::WkbType::MultiCurveZM ); QVERIFY( mc.is3D() ); QVERIFY( mc.isMeasure() ); - ls = static_cast< const QgsCircularString * >( mc.geometryN( 3 ) ); + ls = static_cast( mc.geometryN( 3 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 177, 187, 0, 9 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 183, 183, 0, 11 ) ); @@ -428,9 +399,7 @@ void TestQgsMultiCurve::insertGeometry() QCOMPARE( mc.numGeometries(), 0 ); QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); mc.insertGeometry( part.clone(), 0 ); QVERIFY( !mc.isEmpty() ); @@ -445,15 +414,13 @@ void TestQgsMultiCurve::curveN() QVERIFY( !std::as_const( mc ).curveN( 0 ) ); QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( 7, 17 ) - << QgsPoint( 3, 13 ) << QgsPoint( 7, 11 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 7, 17 ) << QgsPoint( 3, 13 ) << QgsPoint( 7, 11 ) ); mc.addGeometry( part.clone() ); QCOMPARE( *mc.curveN( 0 ), part ); QCOMPARE( *std::as_const( mc ).curveN( 0 ), part ); - part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) - << QgsPoint( 3, 31 ) << QgsPoint( 2, 41 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) << QgsPoint( 2, 41 ) ); mc.addGeometry( part.clone() ); QCOMPARE( *mc.curveN( 1 ), part ); @@ -492,7 +459,7 @@ void TestQgsMultiCurve::clear() void TestQgsMultiCurve::clone() { QgsMultiCurve mc; - std::unique_ptr< QgsMultiCurve > cloned( mc.clone() ); + std::unique_ptr cloned( mc.clone() ); QVERIFY( cloned->isEmpty() ); @@ -504,11 +471,11 @@ void TestQgsMultiCurve::clone() cloned.reset( mc.clone() ); QCOMPARE( cloned->numGeometries(), 2 ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( cloned->geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( cloned->geometryN( 0 ) ); QCOMPARE( *ls, part ); - ls = static_cast< const QgsCircularString * >( cloned->geometryN( 1 ) ); + ls = static_cast( cloned->geometryN( 1 ) ); QCOMPARE( *ls, part ); } @@ -530,11 +497,11 @@ void TestQgsMultiCurve::copy() QCOMPARE( mc2.numGeometries(), 2 ); QCOMPARE( mc2.wkbType(), Qgis::WkbType::MultiCurveZM ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( mc2.geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( mc2.geometryN( 0 ) ); QCOMPARE( *ls, part ); - ls = static_cast< const QgsCircularString * >( mc2.geometryN( 1 ) ); + ls = static_cast( mc2.geometryN( 1 ) ); QCOMPARE( *ls, part ); } @@ -556,10 +523,10 @@ void TestQgsMultiCurve::assignment() mc1 = mc2; QCOMPARE( mc1.numGeometries(), 2 ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( mc1.geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( mc1.geometryN( 0 ) ); QCOMPARE( *ls, part ); - ls = static_cast< const QgsCircularString * >( mc1.geometryN( 1 ) ); + ls = static_cast( mc1.geometryN( 1 ) ); QCOMPARE( *ls, part ); } @@ -588,104 +555,97 @@ void TestQgsMultiCurve::boundary() QVERIFY( !mc.boundary() ); QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); mc.addGeometry( cs.clone() ); QgsAbstractGeometry *boundary = mc.boundary(); - QgsMultiPoint *mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + QgsMultiPoint *mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 2 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); delete boundary; // add another QgsCircularString - cs.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) - << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) ); mc.addGeometry( cs.clone() ); boundary = mc.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 4 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); delete boundary; // add a closed string = no boundary - cs.setPoints( QgsPointSequence() << QgsPoint( 20, 20 ) - << QgsPoint( 21, 20 ) << QgsPoint( 20, 20 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 20, 20 ) << QgsPoint( 21, 20 ) << QgsPoint( 20, 20 ) ); mc.addGeometry( cs.clone() ); boundary = mc.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 4 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); delete boundary; //boundary with z mc.clear(); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); mc.addGeometry( cs.clone() ); - cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 20, 150 ) - << QgsPoint( Qgis::WkbType::PointZ, 20, 20, 200 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 20, 150 ) << QgsPoint( Qgis::WkbType::PointZ, 20, 20, 200 ) ); mc.addGeometry( cs.clone() ); boundary = mc.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 4 ); QCOMPARE( mpBoundary->geometryN( 0 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->z(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->z(), 10.0 ); QCOMPARE( mpBoundary->geometryN( 1 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->z(), 20.0 ); QCOMPARE( mpBoundary->geometryN( 2 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->z(), 100.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->z(), 100.0 ); QCOMPARE( mpBoundary->geometryN( 3 )->wkbType(), Qgis::WkbType::PointZ ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->x(), 20.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->y(), 20.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->z(), 200.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->x(), 20.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->y(), 20.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->z(), 200.0 ); delete boundary; } @@ -694,30 +654,26 @@ void TestQgsMultiCurve::reversed() { QgsMultiCurve mc; - std::unique_ptr< QgsMultiCurve > reversed( mc.reversed() ); + std::unique_ptr reversed( mc.reversed() ); QVERIFY( reversed->isEmpty() ); QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ); mc.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); mc.addGeometry( part.clone() ); reversed.reset( mc.reversed() ); QVERIFY( !reversed->isEmpty() ); - const QgsCircularString *ls = static_cast< const QgsCircularString * >( reversed->geometryN( 0 ) ); + const QgsCircularString *ls = static_cast( reversed->geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) ); QCOMPARE( ls->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) ); - ls = static_cast< const QgsCircularString * >( reversed->geometryN( 1 ) ); + ls = static_cast( reversed->geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) ); @@ -727,8 +683,7 @@ void TestQgsMultiCurve::reversed() void TestQgsMultiCurve::segmentize() { QgsCircularString cs; - cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); + cs.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 10 ) << QgsPoint( 21, 2 ) ); QgsCompoundCurve cc; cc.addCurve( cs.clone() ); @@ -742,7 +697,7 @@ void TestQgsMultiCurve::segmentize() QCOMPARE( segmentized2->partCount(), 1 ); QVERIFY( !segmentized2->is3D() ); QVERIFY( !segmentized2->isMeasure() ); - QCOMPARE( segmentized2->wkbType(), Qgis::WkbType::MultiLineString ); + QCOMPARE( segmentized2->wkbType(), Qgis::WkbType::MultiLineString ); } void TestQgsMultiCurve::toCurveType() @@ -753,16 +708,16 @@ void TestQgsMultiCurve::toCurveType() mc.addGeometry( part.clone() ); mc.addGeometry( part.clone() ); - std::unique_ptr< QgsMultiCurve > curveType( mc.toCurveType() ); + std::unique_ptr curveType( mc.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::MultiCurveZM ); QCOMPARE( curveType->numGeometries(), 2 ); - const QgsCircularString *curve = static_cast< const QgsCircularString * >( curveType->geometryN( 0 ) ); - QCOMPARE( *curve, *static_cast< const QgsCircularString * >( mc.geometryN( 0 ) ) ); + const QgsCircularString *curve = static_cast( curveType->geometryN( 0 ) ); + QCOMPARE( *curve, *static_cast( mc.geometryN( 0 ) ) ); - curve = static_cast< const QgsCircularString * >( curveType->geometryN( 1 ) ); - QCOMPARE( *curve, *static_cast< const QgsCircularString * >( mc.geometryN( 1 ) ) ); + curve = static_cast( curveType->geometryN( 1 ) ); + QCOMPARE( *curve, *static_cast( mc.geometryN( 1 ) ) ); } void TestQgsMultiCurve::toFromWKB() @@ -770,14 +725,10 @@ void TestQgsMultiCurve::toFromWKB() QgsMultiCurve mc1; QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 11 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 11 ) ); mc1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) - << QgsPoint( Qgis::WkbType::Point, 27, 54 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) << QgsPoint( Qgis::WkbType::Point, 27, 54 ) ); mc1.addGeometry( part.clone() ); QByteArray wkb = mc1.asWkb(); @@ -786,10 +737,8 @@ void TestQgsMultiCurve::toFromWKB() mc2.fromWkb( wkbPtr ); QCOMPARE( mc2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 0 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 1 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 0 ) ), *static_cast( mc1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 1 ) ), *static_cast( mc1.geometryN( 1 ) ) ); //bad WKB - check for no crash mc1.clear(); @@ -812,14 +761,10 @@ void TestQgsMultiCurve::toFromWKBWithZM() QgsMultiCurve mc1; QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 11, 3 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 11, 3 ) ); mc1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 27, 53, 6 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 27, 53, 6 ) ); mc1.addGeometry( part.clone() ); QByteArray wkb = mc1.asWkb(); @@ -829,23 +774,17 @@ void TestQgsMultiCurve::toFromWKBWithZM() QCOMPARE( mc2.numGeometries(), 2 ); QCOMPARE( mc2.wkbType(), Qgis::WkbType::MultiCurveZ ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 0 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 1 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 0 ) ), *static_cast( mc1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 1 ) ), *static_cast( mc1.geometryN( 1 ) ) ); //parts with m mc1.clear(); mc2.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 11, 0, 5 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 7, 11, 0, 5 ) ); mc1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 27, 53, 0, 7 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 27, 53, 0, 7 ) ); mc1.addGeometry( part.clone() ); wkb = mc1.asWkb(); @@ -854,23 +793,17 @@ void TestQgsMultiCurve::toFromWKBWithZM() QCOMPARE( mc2.numGeometries(), 2 ); QCOMPARE( mc2.wkbType(), Qgis::WkbType::MultiCurveM ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 0 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 1 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 0 ) ), *static_cast( mc1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 1 ) ), *static_cast( mc1.geometryN( 1 ) ) ); // parts with ZM mc1.clear(); mc2.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 5 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 5 ) ); mc1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 47, 12, 15 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 47, 12, 15 ) ); mc1.addGeometry( part.clone() ); wkb = mc1.asWkb(); @@ -879,10 +812,8 @@ void TestQgsMultiCurve::toFromWKBWithZM() QCOMPARE( mc2.numGeometries(), 2 ); QCOMPARE( mc2.wkbType(), Qgis::WkbType::MultiCurveZM ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 0 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 1 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 0 ) ), *static_cast( mc1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 1 ) ), *static_cast( mc1.geometryN( 1 ) ) ); } void TestQgsMultiCurve::toFromWKT() @@ -890,14 +821,10 @@ void TestQgsMultiCurve::toFromWKT() QgsMultiCurve mc1; QgsCircularString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ); mc1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); mc1.addGeometry( part.clone() ); QString wkt = mc1.asWkt(); @@ -906,10 +833,8 @@ void TestQgsMultiCurve::toFromWKT() QgsMultiCurve mc2; QVERIFY( mc2.fromWkt( wkt ) ); QCOMPARE( mc2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 0 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCircularString * >( mc2.geometryN( 1 ) ), - *static_cast< const QgsCircularString * >( mc1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 0 ) ), *static_cast( mc1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mc2.geometryN( 1 ) ), *static_cast( mc1.geometryN( 1 ) ) ); //bad WKT mc1 = QgsMultiCurve(); @@ -925,14 +850,10 @@ void TestQgsMultiCurve::exportImport() //as JSON QgsMultiCurve exportC; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 11 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 11 ) ); exportC.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) - << QgsPoint( Qgis::WkbType::Point, 27, 47 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) << QgsPoint( Qgis::WkbType::Point, 27, 47 ) ); exportC.addGeometry( part.clone() ); // GML document for compare @@ -960,13 +881,9 @@ void TestQgsMultiCurve::exportImport() QCOMPARE( res, expectedSimpleJson ); QgsMultiCurve exportFloat; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 3 / 5.0, 13 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 11 / 3.0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 3 / 5.0, 13 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 11 / 3.0 ) ); exportFloat.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 43 / 41.0, 43 / 42.0 ) - << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 1 / 3.0 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 43 / 41.0, 43 / 42.0 ) << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 1 / 3.0 ) ); exportFloat.addGeometry( part.clone() ); QString expectedJsonPrec3( QStringLiteral( "{\"coordinates\":[[[2.333,5.667],[2.316,5.677],[2.298,5.687],[2.28,5.697],[2.262,5.707],[2.244,5.716],[2.226,5.725],[2.207,5.734],[2.188,5.742],[2.17,5.75],[2.151,5.757],[2.131,5.765],[2.112,5.772],[2.093,5.778],[2.074,5.785],[2.054,5.79],[2.034,5.796],[2.015,5.801],[1.995,5.806],[1.975,5.811],[1.955,5.815],[1.935,5.819],[1.915,5.822],[1.894,5.826],[1.874,5.828],[1.854,5.831],[1.834,5.833],[1.813,5.835],[1.793,5.836],[1.773,5.837],[1.752,5.838],[1.732,5.838],[1.711,5.838],[1.691,5.838],[1.67,5.837],[1.65,5.836],[1.63,5.834],[1.609,5.833],[1.589,5.83],[1.569,5.828],[1.548,5.825],[1.528,5.822],[1.508,5.818],[1.488,5.814],[1.468,5.81],[1.448,5.805],[1.428,5.801],[1.409,5.795],[1.389,5.79],[1.37,5.784],[1.35,5.777],[1.331,5.771],[1.312,5.764],[1.293,5.756],[1.274,5.749],[1.255,5.741],[1.236,5.732],[1.218,5.724],[1.199,5.715],[1.181,5.705],[1.163,5.696],[1.145,5.686],[1.128,5.676],[1.11,5.665],[1.093,5.654],[1.076,5.643],[1.059,5.632],[1.042,5.62],[1.025,5.608],[1.009,5.596],[0.993,5.583],[0.977,5.57],[0.962,5.557],[0.946,5.543],[0.931,5.53],[0.916,5.516],[0.901,5.502],[0.887,5.487],[0.873,5.473],[0.859,5.458],[0.845,5.442],[0.832,5.427],[0.819,5.411],[0.806,5.395],[0.793,5.379],[0.781,5.363],[0.769,5.346],[0.757,5.33],[0.746,5.313],[0.735,5.296],[0.724,5.278],[0.713,5.261],[0.703,5.243],[0.693,5.225],[0.684,5.207],[0.674,5.189],[0.666,5.171],[0.657,5.152],[0.649,5.133],[0.641,5.115],[0.633,5.096],[0.626,5.077],[0.619,5.057],[0.612,5.038],[0.606,5.019],[0.6,4.999],[0.594,4.979],[0.589,4.96],[0.584,4.94],[0.579,4.92],[0.575,4.9],[0.571,4.88],[0.568,4.86],[0.564,4.84],[0.562,4.819],[0.559,4.799],[0.557,4.779],[0.555,4.759],[0.554,4.738],[0.553,4.718],[0.552,4.697],[0.552,4.677],[0.552,4.656],[0.552,4.636],[0.553,4.616],[0.554,4.595],[0.555,4.575],[0.557,4.554],[0.559,4.534],[0.562,4.514],[0.564,4.494],[0.568,4.473],[0.571,4.453],[0.575,4.433],[0.579,4.413],[0.584,4.393],[0.589,4.374],[0.594,4.354],[0.6,4.334],[0.606,4.315],[0.612,4.295],[0.619,4.276],[0.626,4.257],[0.633,4.238],[0.641,4.219],[0.649,4.2],[0.657,4.181],[0.666,4.163],[0.674,4.144],[0.684,4.126],[0.693,4.108],[0.703,4.09],[0.713,4.073],[0.724,4.055],[0.735,4.038],[0.746,4.021],[0.757,4.004],[0.769,3.987],[0.781,3.97],[0.793,3.954],[0.806,3.938],[0.819,3.922],[0.832,3.906],[0.845,3.891],[0.859,3.876],[0.873,3.861],[0.887,3.846],[0.901,3.832],[0.916,3.817],[0.931,3.804],[0.946,3.79],[0.962,3.776],[0.977,3.763],[0.993,3.75],[1.009,3.738],[1.025,3.726],[1.042,3.713],[1.059,3.702],[1.076,3.69],[1.093,3.679],[1.11,3.668],[1.128,3.658],[1.145,3.648],[1.163,3.638],[1.181,3.628],[1.199,3.619],[1.218,3.61],[1.236,3.601],[1.255,3.593],[1.274,3.585],[1.293,3.577],[1.312,3.57],[1.331,3.563],[1.35,3.556],[1.37,3.55],[1.389,3.544],[1.409,3.538],[1.428,3.533],[1.448,3.528],[1.468,3.523],[1.488,3.519],[1.508,3.515],[1.528,3.511],[1.548,3.508],[1.569,3.505],[1.589,3.503],[1.609,3.501],[1.63,3.499],[1.65,3.497],[1.67,3.496],[1.691,3.496],[1.711,3.495],[1.732,3.495],[1.752,3.496],[1.773,3.496],[1.793,3.497],[1.813,3.499],[1.834,3.5],[1.854,3.503],[1.874,3.505],[1.894,3.508],[1.915,3.511],[1.935,3.514],[1.955,3.518],[1.975,3.523],[1.995,3.527],[2.015,3.532],[2.034,3.537],[2.054,3.543],[2.074,3.549],[2.093,3.555],[2.112,3.562],[2.131,3.569],[2.151,3.576],[2.17,3.584],[2.188,3.592],[2.207,3.6],[2.226,3.608],[2.244,3.617],[2.262,3.627],[2.28,3.636],[2.298,3.646],[2.316,3.656],[2.333,3.667]],[[9.0,4.111],[8.966,4.178],[8.932,4.244],[8.896,4.309],[8.859,4.374],[8.821,4.438],[8.782,4.502],[8.742,4.565],[8.7,4.627],[8.658,4.688],[8.614,4.749],[8.57,4.809],[8.524,4.868],[8.477,4.926],[8.43,4.983],[8.381,5.04],[8.331,5.096],[8.281,5.151],[8.229,5.205],[8.177,5.258],[8.124,5.31],[8.069,5.361],[8.014,5.411],[7.958,5.461],[7.901,5.509],[7.844,5.556],[7.785,5.603],[7.726,5.648],[7.666,5.692],[7.605,5.735],[7.543,5.777],[7.481,5.818],[7.418,5.858],[7.354,5.897],[7.29,5.935],[7.225,5.971],[7.159,6.007],[7.093,6.041],[7.026,6.074],[6.958,6.106],[6.89,6.137],[6.822,6.167],[6.753,6.195],[6.683,6.222],[6.613,6.248],[6.543,6.273],[6.472,6.296],[6.401,6.319],[6.329,6.34],[6.257,6.36],[6.185,6.378],[6.112,6.395],[6.04,6.411],[5.966,6.426],[5.893,6.44],[5.819,6.452],[5.746,6.463],[5.672,6.472],[5.597,6.48],[5.523,6.487],[5.449,6.493],[5.374,6.498],[5.3,6.501],[5.225,6.503],[5.15,6.503],[5.076,6.502],[5.001,6.5],[4.927,6.497],[4.852,6.492],[4.778,6.486],[4.704,6.479],[4.629,6.47],[4.555,6.46],[4.482,6.449],[4.408,6.437],[4.335,6.423],[4.262,6.408],[4.189,6.392],[4.116,6.374],[4.044,6.355],[3.972,6.335],[3.901,6.314],[3.83,6.292],[3.759,6.268],[3.688,6.243],[3.619,6.217],[3.549,6.189],[3.48,6.16],[3.412,6.131],[3.344,6.1],[3.277,6.067],[3.21,6.034],[3.144,5.999],[3.078,5.964],[3.013,5.927],[2.949,5.889],[2.886,5.85],[2.823,5.81],[2.761,5.768],[2.699,5.726],[2.638,5.683],[2.578,5.638],[2.519,5.593],[2.461,5.546],[2.403,5.499],[2.347,5.45],[2.291,5.401],[2.236,5.35],[2.182,5.299],[2.129,5.246],[2.076,5.193],[2.025,5.139],[1.975,5.084],[1.925,5.028],[1.877,4.971],[1.829,4.914],[1.783,4.855],[1.738,4.796],[1.693,4.736],[1.65,4.675],[1.608,4.614],[1.567,4.551],[1.527,4.488],[1.488,4.425],[1.45,4.36],[1.413,4.295],[1.378,4.23],[1.343,4.164],[1.31,4.097],[1.278,4.029],[1.247,3.961],[1.217,3.893],[1.189,3.824],[1.161,3.755],[1.135,3.685],[1.11,3.614],[1.087,3.544],[1.064,3.472],[1.043,3.401],[1.023,3.329],[1.004,3.257],[0.987,3.184],[0.971,3.111],[0.956,3.038],[0.942,2.965],[0.93,2.891],[0.919,2.817],[0.909,2.743],[0.901,2.669],[0.894,2.595],[0.888,2.52],[0.883,2.446],[0.88,2.371],[0.878,2.297],[0.878,2.222],[0.878,2.148],[0.88,2.073],[0.883,1.998],[0.888,1.924],[0.894,1.85],[0.901,1.775],[0.909,1.701],[0.919,1.627],[0.93,1.553],[0.942,1.48],[0.956,1.406],[0.971,1.333],[0.987,1.26],[1.004,1.188],[1.023,1.116],[1.043,1.044],[1.064,0.972],[1.087,0.901],[1.11,0.83],[1.135,0.76],[1.161,0.69],[1.189,0.62],[1.217,0.551],[1.247,0.483],[1.278,0.415],[1.31,0.348],[1.343,0.281],[1.378,0.215],[1.413,0.149],[1.45,0.084],[1.488,0.02],[1.527,-0.044],[1.567,-0.107],[1.608,-0.169],[1.65,-0.231],[1.693,-0.291],[1.738,-0.351],[1.783,-0.411],[1.829,-0.469],[1.877,-0.527],[1.925,-0.584],[1.975,-0.639],[2.025,-0.694],[2.076,-0.749],[2.129,-0.802],[2.182,-0.854],[2.236,-0.906],[2.291,-0.956],[2.347,-1.006],[2.403,-1.054],[2.461,-1.102],[2.519,-1.148],[2.578,-1.194],[2.638,-1.238],[2.699,-1.282],[2.761,-1.324],[2.823,-1.365],[2.886,-1.405],[2.949,-1.444],[3.013,-1.482],[3.078,-1.519],[3.144,-1.555],[3.21,-1.589],[3.277,-1.623],[3.344,-1.655],[3.412,-1.686],[3.48,-1.716],[3.549,-1.745],[3.619,-1.772],[3.688,-1.798],[3.759,-1.823],[3.83,-1.847],[3.901,-1.87],[3.972,-1.891],[4.044,-1.911],[4.116,-1.93],[4.189,-1.947],[4.262,-1.964],[4.335,-1.979],[4.408,-1.992],[4.482,-2.005],[4.555,-2.016],[4.629,-2.026],[4.704,-2.034],[4.778,-2.042],[4.852,-2.048],[4.927,-2.052],[5.001,-2.056],[5.076,-2.058],[5.15,-2.059],[5.225,-2.058],[5.3,-2.056],[5.374,-2.053],[5.449,-2.049],[5.523,-2.043],[5.597,-2.036],[5.672,-2.028],[5.746,-2.018],[5.819,-2.007],[5.893,-1.995],[5.966,-1.982],[6.04,-1.967],[6.112,-1.951],[6.185,-1.934],[6.257,-1.915],[6.329,-1.895],[6.401,-1.874],[6.472,-1.852],[6.543,-1.829],[6.613,-1.804],[6.683,-1.778],[6.753,-1.751],[6.822,-1.722],[6.89,-1.693],[6.958,-1.662],[7.026,-1.63],[7.093,-1.597],[7.159,-1.562],[7.225,-1.527],[7.29,-1.49],[7.354,-1.453],[7.418,-1.414],[7.481,-1.374],[7.543,-1.333],[7.605,-1.291],[7.666,-1.248],[7.726,-1.203],[7.785,-1.158],[7.844,-1.112],[7.901,-1.065],[7.958,-1.016],[8.014,-0.967],[8.069,-0.917],[8.124,-0.865],[8.177,-0.813],[8.229,-0.76],[8.281,-0.706],[8.331,-0.651],[8.381,-0.596],[8.43,-0.539],[8.477,-0.482],[8.524,-0.423],[8.57,-0.364],[8.614,-0.304],[8.658,-0.244],[8.7,-0.182],[8.742,-0.12],[8.782,-0.057],[8.821,0.006],[8.859,0.07],[8.896,0.135],[8.932,0.201],[8.966,0.267],[9.0,0.333]]],\"type\":\"MultiLineString\"}" ) ); diff --git a/tests/src/core/geometry/testqgsmultilinestring.cpp b/tests/src/core/geometry/testqgsmultilinestring.cpp index 65640031062a..806e7e822c9f 100644 --- a/tests/src/core/geometry/testqgsmultilinestring.cpp +++ b/tests/src/core/geometry/testqgsmultilinestring.cpp @@ -24,7 +24,7 @@ #include "testgeometryutils.h" -class TestQgsMultiLineString: public QObject +class TestQgsMultiLineString : public QObject { Q_OBJECT private slots: @@ -121,7 +121,7 @@ void TestQgsMultiLineString::addGeometry() QCOMPARE( mls.area(), 0.0 ); QCOMPARE( mls.perimeter(), 0.0 ); QVERIFY( mls.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsLineString * >( mls.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( mls.geometryN( 0 ) ), part ); QVERIFY( !mls.geometryN( 100 ) ); QVERIFY( !mls.geometryN( -1 ) ); QCOMPARE( mls.vertexCount( 0, 0 ), 2 ); @@ -134,8 +134,7 @@ void TestQgsMultiLineString::addGeometryInitialDimension() //initial adding of geometry should set z/m type QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) ); mls.addGeometry( part.clone() ); QVERIFY( mls.is3D() ); @@ -143,29 +142,27 @@ void TestQgsMultiLineString::addGeometryInitialDimension() QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZ ); QCOMPARE( mls.wktTypeStr(), QString( "MultiLineString Z" ) ); QCOMPARE( mls.geometryType(), QString( "MultiLineString" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( mls.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mls.geometryN( 0 ) ) ), part ); mls.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) ); mls.addGeometry( part.clone() ); QVERIFY( !mls.is3D() ); QVERIFY( mls.isMeasure() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringM ); QCOMPARE( mls.wktTypeStr(), QString( "MultiLineString M" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( mls.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mls.geometryN( 0 ) ) ), part ); mls.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) ); mls.addGeometry( part.clone() ); QVERIFY( mls.is3D() ); QVERIFY( mls.isMeasure() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZM ); QCOMPARE( mls.wktTypeStr(), QString( "MultiLineString ZM" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( mls.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mls.geometryN( 0 ) ) ), part ); //add another part mls.clear(); @@ -180,7 +177,7 @@ void TestQgsMultiLineString::addGeometryInitialDimension() QCOMPARE( mls.vertexCount( 1, 0 ), 2 ); QCOMPARE( mls.numGeometries(), 2 ); QVERIFY( mls.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsLineString * >( mls.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( mls.geometryN( 1 ) ), part ); //adding subsequent points should not alter z/m type, regardless of points type mls.clear(); @@ -188,7 +185,7 @@ void TestQgsMultiLineString::addGeometryInitialDimension() QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineString ); - part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineString ); @@ -201,23 +198,20 @@ void TestQgsMultiLineString::addGeometryInitialDimension() QCOMPARE( mls.partCount(), 2 ); QVERIFY( !mls.is3D() ); - const QgsLineString *ls = static_cast< const QgsLineString * >( mls.geometryN( 0 ) ); + const QgsLineString *ls = static_cast( mls.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 9, 12 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 3, 13 ) ); // test lineStringN by the same occasion - QCOMPARE( static_cast< const QgsLineString * >( mls.lineStringN( 0 ) ), - static_cast< const QgsLineString * >( mls.geometryN( 0 ) ) ); + QCOMPARE( static_cast( mls.lineStringN( 0 ) ), static_cast( mls.geometryN( 0 ) ) ); - ls = static_cast< const QgsLineString * >( mls.lineStringN( 1 ) ); + ls = static_cast( mls.lineStringN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 1, 10 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 2, 11 ) ); - QCOMPARE( static_cast< const QgsLineString * >( mls.lineStringN( 1 ) ), - static_cast< const QgsLineString * >( mls.geometryN( 1 ) ) ); + QCOMPARE( static_cast( mls.lineStringN( 1 ) ), static_cast( mls.geometryN( 1 ) ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineString ); @@ -230,7 +224,7 @@ void TestQgsMultiLineString::addGeometryInitialDimension() QVERIFY( !mls.is3D() ); QVERIFY( !mls.isMeasure() ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 2 ) ); + ls = static_cast( mls.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 21, 30 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 32, 41 ) ); } @@ -240,34 +234,33 @@ void TestQgsMultiLineString::addGeometryZ() QgsMultiLineString mls; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZ ); - part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZ ); QVERIFY( mls.is3D() ); - const QgsLineString *ls = static_cast< const QgsLineString * >( mls.geometryN( 0 ) ); + const QgsLineString *ls = static_cast( mls.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 1, 10, 2 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 2, 11, 3 ) ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 1 ) ); + ls = static_cast( mls.geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 2, 20, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 3, 31, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZ ); QVERIFY( mls.is3D() ); QVERIFY( !mls.isMeasure() ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 2 ) ); + ls = static_cast( mls.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( 5, 50, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( 6, 61, 0 ) ); } @@ -279,34 +272,33 @@ void TestQgsMultiLineString::addGeometryM() QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineString ); QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringM ); - part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringM ); QVERIFY( mls.isMeasure() ); - const QgsLineString *ls = static_cast< const QgsLineString * >( mls.geometryN( 0 ) ); + const QgsLineString *ls = static_cast( mls.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 1 ) ); + ls = static_cast( mls.geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 2, 20, 0, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 3, 31, 0, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) << QgsPoint( 14, 15, 16 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) << QgsPoint( 14, 15, 16 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringM ); QVERIFY( !mls.is3D() ); QVERIFY( mls.isMeasure() ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 2 ) ); + ls = static_cast( mls.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 14, 15, 0, 0 ) ); } @@ -316,49 +308,45 @@ void TestQgsMultiLineString::addGeometryZM() QgsMultiLineString mls; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZM ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZM ); QVERIFY( mls.isMeasure() ); QVERIFY( mls.is3D() ); - const QgsLineString *ls = static_cast< const QgsLineString * >( mls.geometryN( 0 ) ); + const QgsLineString *ls = static_cast( mls.geometryN( 0 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 1 ) ); + ls = static_cast( mls.geometryN( 1 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 7, 17, 0, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 3, 13, 0, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) - << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZM ); QVERIFY( mls.is3D() ); QVERIFY( mls.isMeasure() ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 2 ) ); + ls = static_cast( mls.geometryN( 2 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 77, 87, 7, 0 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 83, 83, 8, 0 ) ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) - << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) ); mls.addGeometry( part.clone() ); QCOMPARE( mls.wkbType(), Qgis::WkbType::MultiLineStringZM ); QVERIFY( mls.is3D() ); QVERIFY( mls.isMeasure() ); - ls = static_cast< const QgsLineString * >( mls.geometryN( 3 ) ); + ls = static_cast( mls.geometryN( 3 ) ); QCOMPARE( ls->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 177, 187, 0, 9 ) ); QCOMPARE( ls->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 183, 183, 0, 11 ) ); } @@ -385,8 +373,7 @@ void TestQgsMultiLineString::insertGeometry() QCOMPARE( mls.numGeometries(), 0 ); QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ); mls.insertGeometry( part.clone(), 0 ); QVERIFY( !mls.isEmpty() ); @@ -403,36 +390,34 @@ void TestQgsMultiLineString::assignment() QgsMultiLineString mls3; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); mls3.addGeometry( part.clone() ); mls3.addGeometry( part.clone() ); mls1 = mls3; QCOMPARE( mls1.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( mls1.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( mls1.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( mls1.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( mls1.geometryN( 1 ) ), part ); } void TestQgsMultiLineString::clone() { QgsMultiLineString mls; - std::unique_ptr< QgsMultiLineString >cloned( mls.clone() ); + std::unique_ptr cloned( mls.clone() ); QVERIFY( cloned->isEmpty() ); QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); mls.addGeometry( part.clone() ); mls.addGeometry( part.clone() ); cloned.reset( mls.clone() ); QCOMPARE( cloned->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( cloned->geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( cloned->geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( cloned->geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( cloned->geometryN( 1 ) ), part ); } void TestQgsMultiLineString::copy() @@ -443,8 +428,7 @@ void TestQgsMultiLineString::copy() QVERIFY( mls2.isEmpty() ); QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); mls1.addGeometry( part.clone() ); mls1.addGeometry( part.clone() ); @@ -452,8 +436,8 @@ void TestQgsMultiLineString::copy() QCOMPARE( mls3.numGeometries(), 2 ); QCOMPARE( mls3.wkbType(), Qgis::WkbType::MultiLineStringZM ); - QCOMPARE( *static_cast< const QgsLineString * >( mls3.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( mls3.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( mls3.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( mls3.geometryN( 1 ) ), part ); } void TestQgsMultiLineString::clear() @@ -461,8 +445,7 @@ void TestQgsMultiLineString::clear() QgsMultiLineString mls; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); mls.addGeometry( part.clone() ); mls.addGeometry( part.clone() ); @@ -500,12 +483,10 @@ void TestQgsMultiLineString::vertexIterator() QgsMultiLineString mls; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); mls.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) - << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) ); mls.addGeometry( part.clone() ); // vertex iterator: 2 linestrings with 3 points each @@ -563,61 +544,58 @@ void TestQgsMultiLineString::boundary() QVERIFY( !mls.boundary() ); QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) ); mls.addGeometry( part.clone() ); QgsAbstractGeometry *boundary = mls.boundary(); - QgsMultiPoint *mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + QgsMultiPoint *mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 2 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); delete boundary; // add another linestring - part.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) - << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) ); mls.addGeometry( part.clone() ); boundary = mls.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 4 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); delete boundary; // add a closed string = no boundary - part.setPoints( QgsPointSequence() << QgsPoint( 20, 20 ) << QgsPoint( 21, 20 ) - << QgsPoint( 21, 21 ) << QgsPoint( 20, 20 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( 20, 20 ) << QgsPoint( 21, 20 ) << QgsPoint( 21, 21 ) << QgsPoint( 20, 20 ) ); mls.addGeometry( part.clone() ); boundary = mls.boundary(); - mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 4 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); - QCOMPARE( static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->x(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 0 ) )->y(), 0.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->x(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 1 ) )->y(), 1.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->x(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 2 ) )->y(), 10.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->x(), 11.0 ); + QCOMPARE( static_cast( mpBoundary->geometryN( 3 ) )->y(), 11.0 ); delete boundary; } @@ -627,40 +605,36 @@ void TestQgsMultiLineString::boundaryZ() QgsMultiLineString mls; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); mls.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 20, 150 ) - << QgsPoint( Qgis::WkbType::PointZ, 20, 20, 200 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 20, 150 ) << QgsPoint( Qgis::WkbType::PointZ, 20, 20, 200 ) ); mls.addGeometry( part.clone() ); QgsAbstractGeometry *boundary = mls.boundary(); - QgsMultiPoint *mpBoundary = dynamic_cast< QgsMultiPoint * >( boundary ); + QgsMultiPoint *mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 4 ); - auto pt = static_cast< QgsPoint *>( mpBoundary->geometryN( 0 ) ); + auto pt = static_cast( mpBoundary->geometryN( 0 ) ); QCOMPARE( mpBoundary->geometryN( 0 )->wkbType(), Qgis::WkbType::PointZ ); QCOMPARE( pt->x(), 0.0 ); QCOMPARE( pt->y(), 0.0 ); QCOMPARE( pt->z(), 10.0 ); - pt = static_cast< QgsPoint *>( mpBoundary->geometryN( 1 ) ); + pt = static_cast( mpBoundary->geometryN( 1 ) ); QCOMPARE( mpBoundary->geometryN( 1 )->wkbType(), Qgis::WkbType::PointZ ); QCOMPARE( pt->x(), 1.0 ); QCOMPARE( pt->y(), 1.0 ); QCOMPARE( pt->z(), 20.0 ); - pt = static_cast< QgsPoint *>( mpBoundary->geometryN( 2 ) ); + pt = static_cast( mpBoundary->geometryN( 2 ) ); QCOMPARE( mpBoundary->geometryN( 2 )->wkbType(), Qgis::WkbType::PointZ ); QCOMPARE( pt->x(), 10.0 ); QCOMPARE( pt->y(), 10.0 ); QCOMPARE( pt->z(), 100.0 ); - pt = static_cast< QgsPoint *>( mpBoundary->geometryN( 3 ) ); + pt = static_cast( mpBoundary->geometryN( 3 ) ); QCOMPARE( mpBoundary->geometryN( 3 )->wkbType(), Qgis::WkbType::PointZ ); QCOMPARE( pt->x(), 20.0 ); QCOMPARE( pt->y(), 20.0 ); @@ -680,9 +654,7 @@ void TestQgsMultiLineString::segmentLength() QCOMPARE( mls.segmentLength( QgsVertexId( 0, 1, 0 ) ), 0.0 ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) - << QgsPoint( 111, 2 ) << QgsPoint( 11, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111, 2 ) << QgsPoint( 11, 2 ) ); mls.addGeometry( ls.clone() ); QCOMPARE( mls.segmentLength( QgsVertexId() ), 0.0 ); @@ -700,9 +672,7 @@ void TestQgsMultiLineString::segmentLength() QCOMPARE( mls.segmentLength( QgsVertexId( 1, 0, 1 ) ), 0.0 ); // add another line - ls.setPoints( QgsPointSequence() << QgsPoint( 30, 6 ) - << QgsPoint( 34, 6 ) << QgsPoint( 34, 8 ) - << QgsPoint( 30, 8 ) << QgsPoint( 30, 6 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 30, 6 ) << QgsPoint( 34, 6 ) << QgsPoint( 34, 8 ) << QgsPoint( 30, 8 ) << QgsPoint( 30, 6 ) ); mls.addGeometry( ls.clone() ); QCOMPARE( mls.segmentLength( QgsVertexId() ), 0.0 ); @@ -730,20 +700,19 @@ void TestQgsMultiLineString::toCurveType() { QgsMultiLineString mls; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); mls.addGeometry( part.clone() ); mls.addGeometry( part.clone() ); - std::unique_ptr< QgsMultiCurve > curveType( mls.toCurveType() ); + std::unique_ptr curveType( mls.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::MultiCurveZM ); QCOMPARE( curveType->numGeometries(), 2 ); - const QgsCompoundCurve *curve = static_cast< const QgsCompoundCurve * >( curveType->geometryN( 0 ) ); + const QgsCompoundCurve *curve = static_cast( curveType->geometryN( 0 ) ); QCOMPARE( curve->asWkt(), QStringLiteral( "CompoundCurve ZM ((5 50 1 4, 6 61 3 5))" ) ); - curve = static_cast< const QgsCompoundCurve * >( curveType->geometryN( 1 ) ); + curve = static_cast( curveType->geometryN( 1 ) ); QCOMPARE( curve->asWkt(), QStringLiteral( "CompoundCurve ZM ((5 50 1 4, 6 61 3 5))" ) ); } @@ -752,11 +721,9 @@ void TestQgsMultiLineString::toFromWKT() QgsMultiLineString mls1; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) ); mls1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) ); mls1.addGeometry( part.clone() ); QString wkt = mls1.asWkt(); @@ -766,10 +733,8 @@ void TestQgsMultiLineString::toFromWKT() QVERIFY( mls2.fromWkt( wkt ) ); QCOMPARE( mls2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 0 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 1 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 0 ) ), *static_cast( mls1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 1 ) ), *static_cast( mls1.geometryN( 1 ) ) ); //bad WKT mls1.clear(); @@ -785,11 +750,9 @@ void TestQgsMultiLineString::toFromWKB() QgsMultiLineString mls1; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ); mls1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) ); mls1.addGeometry( part.clone() ); QByteArray wkb = mls1.asWkb(); @@ -798,20 +761,16 @@ void TestQgsMultiLineString::toFromWKB() mls2.fromWkb( wkbPtr1 ); QCOMPARE( mls2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 0 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 1 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 0 ) ), *static_cast( mls1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 1 ) ), *static_cast( mls1.geometryN( 1 ) ) ); //parts with Z mls1.clear(); mls2.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) ); mls1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) ); mls1.addGeometry( part.clone() ); wkb = mls1.asWkb(); @@ -820,20 +779,16 @@ void TestQgsMultiLineString::toFromWKB() QCOMPARE( mls2.numGeometries(), 2 ); QCOMPARE( mls2.wkbType(), Qgis::WkbType::MultiLineStringZ ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 0 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 1 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 0 ) ), *static_cast( mls1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 1 ) ), *static_cast( mls1.geometryN( 1 ) ) ); //parts with m mls1.clear(); mls2.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) ); mls1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) ); mls1.addGeometry( part.clone() ); wkb = mls1.asWkb(); @@ -842,20 +797,16 @@ void TestQgsMultiLineString::toFromWKB() QCOMPARE( mls2.numGeometries(), 2 ); QCOMPARE( mls2.wkbType(), Qgis::WkbType::MultiLineStringM ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 0 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 1 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 0 ) ), *static_cast( mls1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 1 ) ), *static_cast( mls1.geometryN( 1 ) ) ); // parts with ZM mls1.clear(); mls2.clear(); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) ); mls1.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) ); mls1.addGeometry( part.clone() ); wkb = mls1.asWkb(); @@ -864,10 +815,8 @@ void TestQgsMultiLineString::toFromWKB() QCOMPARE( mls2.numGeometries(), 2 ); QCOMPARE( mls2.wkbType(), Qgis::WkbType::MultiLineStringZM ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 0 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsLineString * >( mls2.geometryN( 1 ) ), - *static_cast< const QgsLineString * >( mls1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 0 ) ), *static_cast( mls1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mls2.geometryN( 1 ) ), *static_cast( mls1.geometryN( 1 ) ) ); //bad WKB - check for no crash mls2.clear(); @@ -891,11 +840,9 @@ void TestQgsMultiLineString::exportImport() QgsMultiLineString exportC; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) ); exportC.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) ); exportC.addGeometry( part.clone() ); // GML document for compare @@ -923,11 +870,9 @@ void TestQgsMultiLineString::exportImport() QCOMPARE( res, expectedSimpleJson ); QgsMultiLineString exportFloat; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 3 / 5.0, 13 / 3.0 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 3 / 5.0, 13 / 3.0 ) ); exportFloat.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 43 / 41.0, 43 / 42.0 ) ) ; + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 43 / 41.0, 43 / 42.0 ) ); exportFloat.addGeometry( part.clone() ); QString expectedJsonPrec3( "{\"coordinates\":[[[2.333,5.667],[0.6,4.333]],[[9.0,4.111],[1.049,1.024]]],\"type\":\"MultiLineString\"}" ); diff --git a/tests/src/core/geometry/testqgsmultipoint.cpp b/tests/src/core/geometry/testqgsmultipoint.cpp index fb55f0333fcf..31871f6fe83b 100644 --- a/tests/src/core/geometry/testqgsmultipoint.cpp +++ b/tests/src/core/geometry/testqgsmultipoint.cpp @@ -23,7 +23,7 @@ #include "testgeometryutils.h" -class TestQgsMultiPoint: public QObject +class TestQgsMultiPoint : public QObject { Q_OBJECT private slots: @@ -95,7 +95,7 @@ void TestQgsMultiPoint::constructor() QVERIFY( !mp2.isMeasure() ); QCOMPARE( mp2.wkbType(), Qgis::WkbType::MultiPoint ); // vector of 2d points - QgsMultiPoint mp3( QVector { QgsPoint( 1, 2 ), QgsPoint( 3, 4 )} ); + QgsMultiPoint mp3( QVector { QgsPoint( 1, 2 ), QgsPoint( 3, 4 ) } ); QVERIFY( !mp3.isEmpty() ); QCOMPARE( mp3.nCoordinates(), 2 ); QVERIFY( !mp3.is3D() ); @@ -106,7 +106,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp3.pointN( 1 )->x(), 3 ); QCOMPARE( mp3.pointN( 1 )->y(), 4 ); // vector of 3d points - QgsMultiPoint mp4( QVector { QgsPoint( 1, 2, 11 ), QgsPoint( 3, 4, 12 )} ); + QgsMultiPoint mp4( QVector { QgsPoint( 1, 2, 11 ), QgsPoint( 3, 4, 12 ) } ); QVERIFY( !mp4.isEmpty() ); QCOMPARE( mp4.nCoordinates(), 2 ); QVERIFY( mp4.is3D() ); @@ -119,7 +119,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp4.pointN( 1 )->y(), 4 ); QCOMPARE( mp4.pointN( 1 )->z(), 12 ); // vector of 4d points - QgsMultiPoint mp5( QVector { QgsPoint( 1, 2, 11, 21 ), QgsPoint( 3, 4, 12, 22 )} ); + QgsMultiPoint mp5( QVector { QgsPoint( 1, 2, 11, 21 ), QgsPoint( 3, 4, 12, 22 ) } ); QVERIFY( !mp5.isEmpty() ); QCOMPARE( mp5.nCoordinates(), 2 ); QVERIFY( mp5.is3D() ); @@ -134,7 +134,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp5.pointN( 1 )->z(), 12 ); QCOMPARE( mp5.pointN( 1 )->m(), 22 ); // vector of pointm - QgsMultiPoint mp6( QVector { QgsPoint( 1, 2, std::numeric_limits< double >::quiet_NaN(), 21 ), QgsPoint( 3, 4, std::numeric_limits< double >::quiet_NaN(), 22 )} ); + QgsMultiPoint mp6( QVector { QgsPoint( 1, 2, std::numeric_limits::quiet_NaN(), 21 ), QgsPoint( 3, 4, std::numeric_limits::quiet_NaN(), 22 ) } ); QVERIFY( !mp6.isEmpty() ); QCOMPARE( mp6.nCoordinates(), 2 ); QVERIFY( !mp6.is3D() ); @@ -147,7 +147,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp6.pointN( 1 )->y(), 4 ); QCOMPARE( mp6.pointN( 1 )->m(), 22 ); // vector of points with mismatched dimensions - QgsMultiPoint mp7( QVector { QgsPoint( 1, 2 ), QgsPoint( 3, 4, std::numeric_limits< double >::quiet_NaN(), 22 )} ); + QgsMultiPoint mp7( QVector { QgsPoint( 1, 2 ), QgsPoint( 3, 4, std::numeric_limits::quiet_NaN(), 22 ) } ); QVERIFY( !mp7.isEmpty() ); QCOMPARE( mp7.nCoordinates(), 2 ); QVERIFY( !mp7.is3D() ); @@ -166,7 +166,7 @@ void TestQgsMultiPoint::constructor() QVERIFY( !mp2a.isMeasure() ); QCOMPARE( mp2a.wkbType(), Qgis::WkbType::MultiPoint ); // vector of 2d points - QgsMultiPoint mp3a( QVector { new QgsPoint( 1, 2 ), new QgsPoint( 3, 4 )} ); + QgsMultiPoint mp3a( QVector { new QgsPoint( 1, 2 ), new QgsPoint( 3, 4 ) } ); QVERIFY( !mp3a.isEmpty() ); QCOMPARE( mp3a.nCoordinates(), 2 ); QVERIFY( !mp3a.is3D() ); @@ -177,7 +177,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp3a.pointN( 1 )->x(), 3 ); QCOMPARE( mp3a.pointN( 1 )->y(), 4 ); // vector of 3d points - QgsMultiPoint mp4a( QVector { new QgsPoint( 1, 2, 11 ), new QgsPoint( 3, 4, 12 )} ); + QgsMultiPoint mp4a( QVector { new QgsPoint( 1, 2, 11 ), new QgsPoint( 3, 4, 12 ) } ); QVERIFY( !mp4a.isEmpty() ); QCOMPARE( mp4a.nCoordinates(), 2 ); QVERIFY( mp4a.is3D() ); @@ -190,7 +190,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp4a.pointN( 1 )->y(), 4 ); QCOMPARE( mp4a.pointN( 1 )->z(), 12 ); // vector of 4d points - QgsMultiPoint mp5a( QVector { new QgsPoint( 1, 2, 11, 21 ), new QgsPoint( 3, 4, 12, 22 )} ); + QgsMultiPoint mp5a( QVector { new QgsPoint( 1, 2, 11, 21 ), new QgsPoint( 3, 4, 12, 22 ) } ); QVERIFY( !mp5a.isEmpty() ); QCOMPARE( mp5a.nCoordinates(), 2 ); QVERIFY( mp5a.is3D() ); @@ -205,7 +205,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp5a.pointN( 1 )->z(), 12 ); QCOMPARE( mp5a.pointN( 1 )->m(), 22 ); // vector of pointm - QgsMultiPoint mp6a( QVector { new QgsPoint( 1, 2, std::numeric_limits< double >::quiet_NaN(), 21 ), new QgsPoint( 3, 4, std::numeric_limits< double >::quiet_NaN(), 22 )} ); + QgsMultiPoint mp6a( QVector { new QgsPoint( 1, 2, std::numeric_limits::quiet_NaN(), 21 ), new QgsPoint( 3, 4, std::numeric_limits::quiet_NaN(), 22 ) } ); QVERIFY( !mp6a.isEmpty() ); QCOMPARE( mp6a.nCoordinates(), 2 ); QVERIFY( !mp6a.is3D() ); @@ -218,7 +218,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp6a.pointN( 1 )->y(), 4 ); QCOMPARE( mp6a.pointN( 1 )->m(), 22 ); // vector of points with mismatched dimensions - QgsMultiPoint mp7a( QVector { new QgsPoint( 1, 2 ), new QgsPoint( 3, 4, std::numeric_limits< double >::quiet_NaN(), 22 )} ); + QgsMultiPoint mp7a( QVector { new QgsPoint( 1, 2 ), new QgsPoint( 3, 4, std::numeric_limits::quiet_NaN(), 22 ) } ); QVERIFY( !mp7a.isEmpty() ); QCOMPARE( mp7a.nCoordinates(), 2 ); QVERIFY( !mp7a.is3D() ); @@ -237,7 +237,7 @@ void TestQgsMultiPoint::constructor() QVERIFY( !mp8.isMeasure() ); QCOMPARE( mp8.wkbType(), Qgis::WkbType::MultiPoint ); // vector of 2d points - QgsMultiPoint mp9( QVector { QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 )} ); + QgsMultiPoint mp9( QVector { QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ) } ); QVERIFY( !mp9.isEmpty() ); QCOMPARE( mp9.nCoordinates(), 2 ); QVERIFY( !mp9.is3D() ); @@ -249,14 +249,14 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp9.pointN( 1 )->y(), 4 ); // using separate vectors of coordinates - QgsMultiPoint mp10( QVector< double > {}, QVector< double > {} ); + QgsMultiPoint mp10( QVector {}, QVector {} ); QVERIFY( mp10.isEmpty() ); QCOMPARE( mp10.nCoordinates(), 0 ); QVERIFY( !mp10.is3D() ); QVERIFY( !mp10.isMeasure() ); QCOMPARE( mp10.wkbType(), Qgis::WkbType::MultiPoint ); - QgsMultiPoint mp11( QVector< double > {1, 2}, QVector< double > {3, 4} ); + QgsMultiPoint mp11( QVector { 1, 2 }, QVector { 3, 4 } ); QVERIFY( !mp11.isEmpty() ); QCOMPARE( mp11.nCoordinates(), 2 ); QVERIFY( !mp11.is3D() ); @@ -267,7 +267,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp11.pointN( 1 )->x(), 2 ); QCOMPARE( mp11.pointN( 1 )->y(), 4 ); - QgsMultiPoint mp12( QVector< double > {1, 2}, QVector< double > {3, 4}, QVector< double > {13, 14} ); + QgsMultiPoint mp12( QVector { 1, 2 }, QVector { 3, 4 }, QVector { 13, 14 } ); QVERIFY( !mp12.isEmpty() ); QCOMPARE( mp12.nCoordinates(), 2 ); QVERIFY( mp12.is3D() ); @@ -280,7 +280,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp12.pointN( 1 )->y(), 4 ); QCOMPARE( mp12.pointN( 1 )->z(), 14 ); - QgsMultiPoint mp13( QVector< double > {1, 2}, QVector< double > {3, 4}, QVector< double > {13, 14}, QVector< double > {15, 16} ); + QgsMultiPoint mp13( QVector { 1, 2 }, QVector { 3, 4 }, QVector { 13, 14 }, QVector { 15, 16 } ); QVERIFY( !mp13.isEmpty() ); QCOMPARE( mp13.nCoordinates(), 2 ); QVERIFY( mp13.is3D() ); @@ -295,7 +295,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp13.pointN( 1 )->z(), 14 ); QCOMPARE( mp13.pointN( 1 )->m(), 16 ); - QgsMultiPoint mp14( QVector< double > {1, 2}, QVector< double > {3, 4}, QVector< double > {}, QVector< double > {15, 16} ); + QgsMultiPoint mp14( QVector { 1, 2 }, QVector { 3, 4 }, QVector {}, QVector { 15, 16 } ); QVERIFY( !mp14.isEmpty() ); QCOMPARE( mp14.nCoordinates(), 2 ); QVERIFY( !mp14.is3D() ); @@ -309,7 +309,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp14.pointN( 1 )->m(), 16 ); // mismatched sizes - QgsMultiPoint mp15( QVector< double > {1, 2, 5}, QVector< double > {3, 4} ); + QgsMultiPoint mp15( QVector { 1, 2, 5 }, QVector { 3, 4 } ); QVERIFY( !mp15.isEmpty() ); QCOMPARE( mp15.nCoordinates(), 2 ); QVERIFY( !mp15.is3D() ); @@ -319,7 +319,7 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp15.pointN( 0 )->y(), 3 ); QCOMPARE( mp15.pointN( 1 )->x(), 2 ); QCOMPARE( mp15.pointN( 1 )->y(), 4 ); - QgsMultiPoint mp16( QVector< double > {1, 2}, QVector< double > {3, 4, 5} ); + QgsMultiPoint mp16( QVector { 1, 2 }, QVector { 3, 4, 5 } ); QVERIFY( !mp16.isEmpty() ); QCOMPARE( mp16.nCoordinates(), 2 ); QVERIFY( !mp16.is3D() ); @@ -329,7 +329,6 @@ void TestQgsMultiPoint::constructor() QCOMPARE( mp16.pointN( 0 )->y(), 3 ); QCOMPARE( mp16.pointN( 1 )->x(), 2 ); QCOMPARE( mp16.pointN( 1 )->y(), 4 ); - } void TestQgsMultiPoint::copyConstructor() @@ -345,8 +344,8 @@ void TestQgsMultiPoint::copyConstructor() QCOMPARE( mp3.numGeometries(), 2 ); QCOMPARE( mp3.wkbType(), Qgis::WkbType::MultiPointZM ); - QCOMPARE( *static_cast< const QgsPoint * >( mp3.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp3.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 20, 10, 14, 18 ) ); + QCOMPARE( *static_cast( mp3.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); + QCOMPARE( *static_cast( mp3.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 20, 10, 14, 18 ) ); } void TestQgsMultiPoint::addGeometryWithNullptr() @@ -400,7 +399,7 @@ void TestQgsMultiPoint::addGeometry() QCOMPARE( mp.area(), 0.0 ); QCOMPARE( mp.perimeter(), 0.0 ); QVERIFY( mp.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( mp.geometryN( 0 ) ), part ); QVERIFY( !mp.geometryN( 100 ) ); QVERIFY( !mp.geometryN( -1 ) ); QCOMPARE( mp.vertexCount( 0, 0 ), 1 ); @@ -419,7 +418,7 @@ void TestQgsMultiPoint::addGeometryWithZM() QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointZ ); QCOMPARE( mp.wktTypeStr(), QString( "MultiPoint Z" ) ); QCOMPARE( mp.geometryType(), QString( "MultiPoint" ) ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), part ); mp.clear(); part = QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ); @@ -429,7 +428,7 @@ void TestQgsMultiPoint::addGeometryWithZM() QVERIFY( mp.isMeasure() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointM ); QCOMPARE( mp.wktTypeStr(), QString( "MultiPoint M" ) ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), part ); mp.clear(); part = QgsPoint( Qgis::WkbType::PointZM, 10, 10, 5, 3 ); @@ -439,7 +438,7 @@ void TestQgsMultiPoint::addGeometryWithZM() QVERIFY( mp.isMeasure() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointZM ); QCOMPARE( mp.wktTypeStr(), QString( "MultiPoint ZM" ) ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), part ); } void TestQgsMultiPoint::addGeometryDimensionPreservation() @@ -463,7 +462,7 @@ void TestQgsMultiPoint::addGeometryDimensionPreservation() QCOMPARE( mp.partCount(), 2 ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPoint ); //should still be 2d QVERIFY( !mp.is3D() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 1 ) ) ), QgsPoint( 1, 2 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 1 ) ) ), QgsPoint( 1, 2 ) ); mp.addGeometry( new QgsPoint( Qgis::WkbType::PointM, 11.0, 12.0, 0, 3 ) ); @@ -477,7 +476,7 @@ void TestQgsMultiPoint::addGeometryDimensionPreservation() QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPoint ); //should still be 2d QVERIFY( !mp.is3D() ); QVERIFY( !mp.isMeasure() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 2 ) ) ), QgsPoint( 11, 12 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 2 ) ) ), QgsPoint( 11, 12 ) ); } void TestQgsMultiPoint::addGeometryDimensionPreservationZ() @@ -491,15 +490,15 @@ void TestQgsMultiPoint::addGeometryDimensionPreservationZ() QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointZ ); QVERIFY( mp.is3D() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 0 ) ) ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 1 ) ) ), QgsPoint( Qgis::WkbType::PointZ, 11, 12, 0 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 1 ) ) ), QgsPoint( Qgis::WkbType::PointZ, 11, 12, 0 ) ); mp.addGeometry( new QgsPoint( Qgis::WkbType::PointM, 21.0, 22.0, 0, 3 ) ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointZ ); QVERIFY( mp.is3D() ); QVERIFY( !mp.isMeasure() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 2 ) ) ), QgsPoint( Qgis::WkbType::PointZ, 21, 22, 0 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 2 ) ) ), QgsPoint( Qgis::WkbType::PointZ, 21, 22, 0 ) ); } void TestQgsMultiPoint::addGeometryDimensionPreservationM() @@ -513,15 +512,15 @@ void TestQgsMultiPoint::addGeometryDimensionPreservationM() QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointM ); QVERIFY( mp.isMeasure() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 0 ) ) ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 1 ) ) ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 0 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 1 ) ) ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 0 ) ); mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZ, 21.0, 22.0, 3 ) ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointM ); QVERIFY( !mp.is3D() ); QVERIFY( mp.isMeasure() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 2 ) ) ), QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 0 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 2 ) ) ), QgsPoint( Qgis::WkbType::PointM, 21, 22, 0, 0 ) ); } void TestQgsMultiPoint::addGeometryDimensionPreservationZM() @@ -536,22 +535,22 @@ void TestQgsMultiPoint::addGeometryDimensionPreservationZM() QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointZM ); QVERIFY( mp.isMeasure() ); QVERIFY( mp.is3D() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 0 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 3 ) ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 1 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 0, 0 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 4, 3 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 1 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 11, 12, 0, 0 ) ); mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZ, 21.0, 22.0, 3 ) ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointZM ); QVERIFY( mp.is3D() ); QVERIFY( mp.isMeasure() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 2 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 21, 22, 3, 0 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 2 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 21, 22, 3, 0 ) ); mp.addGeometry( new QgsPoint( Qgis::WkbType::PointM, 31.0, 32.0, 0, 4 ) ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPointZM ); QVERIFY( mp.is3D() ); QVERIFY( mp.isMeasure() ); - QCOMPARE( *( static_cast< const QgsPoint * >( mp.geometryN( 3 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 31, 32, 0, 4 ) ); + QCOMPARE( *( static_cast( mp.geometryN( 3 ) ) ), QgsPoint( Qgis::WkbType::PointZM, 31, 32, 0, 4 ) ); } void TestQgsMultiPoint::cordinateSequenceWithMultiPart() @@ -568,12 +567,10 @@ void TestQgsMultiPoint::cordinateSequenceWithMultiPart() QCOMPARE( mp.vertexCount( 1, 0 ), 1 ); QCOMPARE( mp.numGeometries(), 2 ); QVERIFY( mp.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( mp.geometryN( 1 ) ), part ); QgsCoordinateSequence seq = mp.coordinateSequence(); - QCOMPARE( seq, QgsCoordinateSequence() - << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 10, 11 ) ) ) - << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 9, 1 ) ) ) ); + QCOMPARE( seq, QgsCoordinateSequence() << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 10, 11 ) ) ) << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 9, 1 ) ) ) ); QCOMPARE( mp.nCoordinates(), 2 ); } @@ -614,7 +611,7 @@ void TestQgsMultiPoint::insertGeometry() void TestQgsMultiPoint::clone() { QgsMultiPoint mp; - std::unique_ptr< QgsMultiPoint >cloned( mp.clone() ); + std::unique_ptr cloned( mp.clone() ); QVERIFY( cloned->isEmpty() ); @@ -623,15 +620,15 @@ void TestQgsMultiPoint::clone() cloned.reset( mp.clone() ); QCOMPARE( cloned->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsPoint * >( cloned->geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( cloned->geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); + QCOMPARE( *static_cast( cloned->geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) ); + QCOMPARE( *static_cast( cloned->geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); } void TestQgsMultiPoint::clear() { QgsMultiPoint mp; - mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) ); - mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZ, 11, 12, 3 ) ); + mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) ); + mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZ, 11, 12, 3 ) ); QCOMPARE( mp.numGeometries(), 2 ); @@ -660,8 +657,8 @@ void TestQgsMultiPoint::assignment() mp3.addGeometry( new QgsPoint( Qgis::WkbType::PointZM, 20, 10, 14, 18 ) ); mp1 = mp3; QCOMPARE( mp1.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsPoint * >( mp1.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp1.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 20, 10, 14, 18 ) ); + QCOMPARE( *static_cast( mp1.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); + QCOMPARE( *static_cast( mp1.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 20, 10, 14, 18 ) ); } void TestQgsMultiPoint::cast() @@ -702,15 +699,15 @@ void TestQgsMultiPoint::toCurveType() mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); mp.addGeometry( new QgsPoint( Qgis::WkbType::PointZM, 20, 10, 14, 18 ) ); - std::unique_ptr< QgsMultiPoint > curveType( mp.toCurveType() ); + std::unique_ptr curveType( mp.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::MultiPointZM ); QCOMPARE( curveType->numGeometries(), 2 ); - const QgsPoint *curve = static_cast< const QgsPoint * >( curveType->geometryN( 0 ) ); + const QgsPoint *curve = static_cast( curveType->geometryN( 0 ) ); QCOMPARE( *curve, QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); - curve = static_cast< const QgsPoint * >( curveType->geometryN( 1 ) ); + curve = static_cast( curveType->geometryN( 1 ) ); QCOMPARE( *curve, QgsPoint( Qgis::WkbType::PointZM, 20, 10, 14, 18 ) ); } @@ -727,8 +724,8 @@ void TestQgsMultiPoint::toFromWKB() mp2.fromWkb( wkbPtr ); QCOMPARE( mp2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::Point, 10, 11 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::Point, 20, 21 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::Point, 10, 11 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::Point, 20, 21 ) ); } void TestQgsMultiPoint::toFromWKBWithZ() @@ -745,8 +742,8 @@ void TestQgsMultiPoint::toFromWKBWithZ() QCOMPARE( mp2.numGeometries(), 2 ); QCOMPARE( mp2.wkbType(), Qgis::WkbType::MultiPointZ ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) ); } void TestQgsMultiPoint::toFromWKBWithM() @@ -763,8 +760,8 @@ void TestQgsMultiPoint::toFromWKBWithM() QCOMPARE( mp2.numGeometries(), 2 ); QCOMPARE( mp2.wkbType(), Qgis::WkbType::MultiPointM ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointM, 9, 1, 0, 4 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointM, 9, 1, 0, 4 ) ); } void TestQgsMultiPoint::toFromWKBWithZM() @@ -781,8 +778,8 @@ void TestQgsMultiPoint::toFromWKBWithZM() QCOMPARE( mp2.numGeometries(), 2 ); QCOMPARE( mp2.wkbType(), Qgis::WkbType::MultiPointZM ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 70, 4 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 9, 1, 3, 4 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 70, 4 ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 9, 1, 3, 4 ) ); } void TestQgsMultiPoint::toFromBadWKB() @@ -814,8 +811,8 @@ void TestQgsMultiPoint::toFromWKT() mp.clear(); QVERIFY( mp.fromWkt( wkt ) ); QCOMPARE( mp.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsPoint * >( mp.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); - QCOMPARE( *static_cast< const QgsPoint * >( mp.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) ); + QCOMPARE( *static_cast( mp.geometryN( 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) ); + QCOMPARE( *static_cast( mp.geometryN( 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) ); //bad WKT mp.clear(); @@ -937,8 +934,7 @@ void TestQgsMultiPoint::adjacentVertices() void TestQgsMultiPoint::filterVertices() { QgsMultiPoint mp; - auto filter = []( const QgsPoint & point )-> bool - { + auto filter = []( const QgsPoint &point ) -> bool { return point.x() < 5; }; mp.filterVertices( filter ); // no crash diff --git a/tests/src/core/geometry/testqgsmultipolygon.cpp b/tests/src/core/geometry/testqgsmultipolygon.cpp index 7172a7a46924..a136956ec9bd 100644 --- a/tests/src/core/geometry/testqgsmultipolygon.cpp +++ b/tests/src/core/geometry/testqgsmultipolygon.cpp @@ -24,7 +24,7 @@ #include "testgeometryutils.h" -class TestQgsMultiPolygon: public QObject +class TestQgsMultiPolygon : public QObject { Q_OBJECT private slots: @@ -87,10 +87,7 @@ void TestQgsMultiPolygon::assignment() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); QgsMultiPolygon mp3; @@ -100,27 +97,24 @@ void TestQgsMultiPolygon::assignment() mp1 = mp3; QCOMPARE( mp1.numGeometries(), 2 ); - const QgsPolygon *ls = static_cast< const QgsPolygon * >( mp1.geometryN( 0 ) ); + const QgsPolygon *ls = static_cast( mp1.geometryN( 0 ) ); QCOMPARE( *ls, part ); - ls = static_cast< const QgsPolygon * >( mp1.geometryN( 1 ) ); + ls = static_cast( mp1.geometryN( 1 ) ); QCOMPARE( *ls, part ); } void TestQgsMultiPolygon::clone() { QgsMultiPolygon mp; - std::unique_ptr< QgsMultiPolygon >cloned( mp.clone() ); + std::unique_ptr cloned( mp.clone() ); QVERIFY( cloned->isEmpty() ); QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); mp.addGeometry( part.clone() ); @@ -129,10 +123,10 @@ void TestQgsMultiPolygon::clone() QCOMPARE( cloned->numGeometries(), 2 ); - const QgsPolygon *ls = static_cast< const QgsPolygon * >( cloned->geometryN( 0 ) ); + const QgsPolygon *ls = static_cast( cloned->geometryN( 0 ) ); QCOMPARE( *ls, part ); - ls = static_cast< const QgsPolygon * >( cloned->geometryN( 1 ) ); + ls = static_cast( cloned->geometryN( 1 ) ); QCOMPARE( *ls, part ); } @@ -146,10 +140,7 @@ void TestQgsMultiPolygon::copy() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); mp1.addGeometry( part.clone() ); @@ -159,10 +150,10 @@ void TestQgsMultiPolygon::copy() QCOMPARE( mp3.numGeometries(), 2 ); QCOMPARE( mp3.wkbType(), Qgis::WkbType::MultiPolygonZM ); - const QgsPolygon *ls = static_cast< const QgsPolygon * >( mp3.geometryN( 0 ) ); + const QgsPolygon *ls = static_cast( mp3.geometryN( 0 ) ); QCOMPARE( *ls, part ); - ls = static_cast< const QgsPolygon * >( mp3.geometryN( 1 ) ); + ls = static_cast( mp3.geometryN( 1 ) ); QCOMPARE( *ls, part ); } @@ -172,10 +163,7 @@ void TestQgsMultiPolygon::clear() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); mp.addGeometry( part.clone() ); @@ -200,8 +188,7 @@ void TestQgsMultiPolygon::addGeometry() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) - << QgsPoint( 2, 21 ) << QgsPoint( 1, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) << QgsPoint( 2, 21 ) << QgsPoint( 1, 10 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -218,7 +205,7 @@ void TestQgsMultiPolygon::addGeometry() QCOMPARE( mp.dimension(), 2 ); QVERIFY( !mp.hasCurvedSegments() ); QVERIFY( mp.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( mp.geometryN( 0 ) ), part ); QVERIFY( !mp.geometryN( 100 ) ); QVERIFY( !mp.geometryN( -1 ) ); QCOMPARE( mp.vertexCount( 0, 0 ), 4 ); @@ -228,38 +215,34 @@ void TestQgsMultiPolygon::addGeometry() mp.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) - << QgsPoint( 10, 21 ) << QgsPoint( 1, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) << QgsPoint( 10, 21 ) << QgsPoint( 1, 10 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.vertexCount( 0, 0 ), 4 ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) - << QgsPoint( 4, 17 ) << QgsPoint( 9, 12 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) << QgsPoint( 4, 17 ) << QgsPoint( 9, 12 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.vertexCount( 1, 0 ), 4 ); QCOMPARE( mp.numGeometries(), 2 ); QVERIFY( mp.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( mp.geometryN( 1 ) ), part ); //adding subsequent points should not alter z/m type, regardless of parts type mp.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) - << QgsPoint( 4, 17 ) << QgsPoint( 9, 12 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) << QgsPoint( 4, 17 ) << QgsPoint( 9, 12 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygon ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) - << QgsPoint( 10, 13, 3 ) << QgsPoint( 1, 10, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) << QgsPoint( 10, 13, 3 ) << QgsPoint( 1, 10, 2 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -273,21 +256,21 @@ void TestQgsMultiPolygon::addGeometry() QCOMPARE( mp.partCount(), 2 ); QVERIFY( !mp.is3D() ); - const QgsPolygon *ls = static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ); - auto exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + const QgsPolygon *ls = static_cast( mp.geometryN( 0 ) ); + auto exteriorRing = static_cast( ls->exteriorRing() ); // test polygonN by the same occasion - QCOMPARE( *ls, *static_cast< const QgsPolygon * >( mp.polygonN( 0 ) ) ); + QCOMPARE( *ls, *static_cast( mp.polygonN( 0 ) ) ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( 9, 12 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( 3, 13 ) ); QCOMPARE( exteriorRing->pointN( 2 ), QgsPoint( 4, 17 ) ); QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( 9, 12 ) ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 1 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 1 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); - QCOMPARE( *ls, *static_cast< const QgsPolygon * >( mp.polygonN( 1 ) ) ); + QCOMPARE( *ls, *static_cast( mp.polygonN( 1 ) ) ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( 1, 10 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( 2, 11 ) ); @@ -295,10 +278,7 @@ void TestQgsMultiPolygon::addGeometry() QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( 1, 10 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 42, 61, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 42, 61, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -312,8 +292,8 @@ void TestQgsMultiPolygon::addGeometry() QVERIFY( !mp.is3D() ); QVERIFY( !mp.isMeasure() ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 2 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 2 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( 21, 30 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( 32, 41 ) ); @@ -355,10 +335,7 @@ void TestQgsMultiPolygon::addGeometryInitialDimension() QgsLineString ring; //initial adding of geometry should set z/m type - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 30, 31, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 30, 31, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -367,15 +344,12 @@ void TestQgsMultiPolygon::addGeometryInitialDimension() QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonZ ); QCOMPARE( mp.wktTypeStr(), QString( "MultiPolygon Z" ) ); QCOMPARE( mp.geometryType(), QString( "MultiPolygon" ) ); - QCOMPARE( *( static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), part ); mp.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 30, 31, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 30, 31, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -383,15 +357,12 @@ void TestQgsMultiPolygon::addGeometryInitialDimension() QVERIFY( mp.isMeasure() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonM ); QCOMPARE( mp.wktTypeStr(), QString( "MultiPolygon M" ) ); - QCOMPARE( *( static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), part ); mp.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 30, 31, 3, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 30, 31, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -399,7 +370,7 @@ void TestQgsMultiPolygon::addGeometryInitialDimension() QVERIFY( mp.isMeasure() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonZM ); QCOMPARE( mp.wktTypeStr(), QString( "MultiPolygon ZM" ) ); - QCOMPARE( *( static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( mp.geometryN( 0 ) ) ), part ); } void TestQgsMultiPolygon::addGeometryZ() @@ -408,32 +379,30 @@ void TestQgsMultiPolygon::addGeometryZ() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) - << QgsPoint( 9, 15, 3 ) << QgsPoint( 1, 10, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) << QgsPoint( 9, 15, 3 ) << QgsPoint( 1, 10, 2 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonZ ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) - << QgsPoint( 7, 34 ) << QgsPoint( 2, 20 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) << QgsPoint( 7, 34 ) << QgsPoint( 2, 20 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonZ ); QVERIFY( mp.is3D() ); - const QgsPolygon *ls = static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ); - auto exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + const QgsPolygon *ls = static_cast( mp.geometryN( 0 ) ); + auto exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( 1, 10, 2 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( 2, 11, 3 ) ); QCOMPARE( exteriorRing->pointN( 2 ), QgsPoint( 9, 15, 3 ) ); QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( 1, 10, 2 ) ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 1 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 1 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( 2, 20, 0 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( 3, 31, 0 ) ); @@ -441,10 +410,7 @@ void TestQgsMultiPolygon::addGeometryZ() QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( 2, 20, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 65, 0, 7 ) - << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 9, 65, 0, 7 ) << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -452,8 +418,8 @@ void TestQgsMultiPolygon::addGeometryZ() QVERIFY( mp.is3D() ); QVERIFY( !mp.isMeasure() ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 2 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 2 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( 5, 50, 0 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( 6, 61, 0 ) ); @@ -469,34 +435,30 @@ void TestQgsMultiPolygon::addGeometryM() QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygon ); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 76, 0, 8 ) - << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 9, 76, 0, 8 ) << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonM ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) - << QgsPoint( 7, 39 ) << QgsPoint( 2, 20 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) << QgsPoint( 7, 39 ) << QgsPoint( 2, 20 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonM ); QVERIFY( mp.isMeasure() ); - const QgsPolygon *ls = static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ); - auto exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + const QgsPolygon *ls = static_cast( mp.geometryN( 0 ) ); + auto exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ); QCOMPARE( exteriorRing->pointN( 2 ), QgsPoint( Qgis::WkbType::PointM, 9, 76, 0, 8 ) ); QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 1 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 1 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 2, 20, 0, 0 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 3, 31, 0, 0 ) ); @@ -504,8 +466,7 @@ void TestQgsMultiPolygon::addGeometryM() QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( Qgis::WkbType::PointM, 2, 20, 0, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) << QgsPoint( 14, 15, 16 ) - << QgsPoint( 24, 21, 5 ) << QgsPoint( 11, 12, 13 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) << QgsPoint( 14, 15, 16 ) << QgsPoint( 24, 21, 5 ) << QgsPoint( 11, 12, 13 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -513,8 +474,8 @@ void TestQgsMultiPolygon::addGeometryM() QVERIFY( !mp.is3D() ); QVERIFY( mp.isMeasure() ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 2 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 2 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 0 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 14, 15, 0, 0 ) ); @@ -528,20 +489,14 @@ void TestQgsMultiPolygon::addGeometryZM() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 9 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 9 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); QCOMPARE( mp.wkbType(), Qgis::WkbType::MultiPolygonZM ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 13, 27 ) - << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 13, 27 ) << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -549,16 +504,16 @@ void TestQgsMultiPolygon::addGeometryZM() QVERIFY( mp.isMeasure() ); QVERIFY( mp.is3D() ); - const QgsPolygon *ls = static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ); - auto exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + const QgsPolygon *ls = static_cast( mp.geometryN( 0 ) ); + auto exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); QCOMPARE( exteriorRing->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 9 ) ); QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 1 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 1 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 7, 17, 0, 0 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 3, 13, 0, 0 ) ); @@ -566,10 +521,7 @@ void TestQgsMultiPolygon::addGeometryZM() QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( Qgis::WkbType::PointZM, 7, 17, 0, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) - << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) - << QgsPoint( Qgis::WkbType::PointZ, 93, 85, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) << QgsPoint( Qgis::WkbType::PointZ, 93, 85, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -577,8 +529,8 @@ void TestQgsMultiPolygon::addGeometryZM() QVERIFY( mp.is3D() ); QVERIFY( mp.isMeasure() ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 2 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 2 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 77, 87, 7, 0 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 83, 83, 8, 0 ) ); @@ -586,10 +538,7 @@ void TestQgsMultiPolygon::addGeometryZM() QCOMPARE( exteriorRing->pointN( 3 ), QgsPoint( Qgis::WkbType::PointZM, 77, 87, 7, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) - << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) - << QgsPoint( Qgis::WkbType::PointM, 185, 193, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) << QgsPoint( Qgis::WkbType::PointM, 185, 193, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -597,8 +546,8 @@ void TestQgsMultiPolygon::addGeometryZM() QVERIFY( mp.is3D() ); QVERIFY( mp.isMeasure() ); - ls = static_cast< const QgsPolygon * >( mp.geometryN( 3 ) ); - exteriorRing = static_cast< const QgsLineString *>( ls->exteriorRing() ); + ls = static_cast( mp.geometryN( 3 ) ); + exteriorRing = static_cast( ls->exteriorRing() ); QCOMPARE( exteriorRing->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 177, 187, 0, 9 ) ); QCOMPARE( exteriorRing->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 183, 183, 0, 11 ) ); @@ -628,10 +577,7 @@ void TestQgsMultiPolygon::insertGeometry() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 21 ) - << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 21 ) << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ); part.setExteriorRing( ring.clone() ); mp.insertGeometry( part.clone(), 0 ); @@ -665,21 +611,20 @@ void TestQgsMultiPolygon::boundary() QgsLineString ring; QgsPolygon part; - ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); part.clear(); mp.addGeometry( part.clone() ); - std::unique_ptr< QgsAbstractGeometry > boundary( mp.boundary() ); - QgsMultiLineString *mls = dynamic_cast< QgsMultiLineString * >( boundary.get() ); + std::unique_ptr boundary( mp.boundary() ); + QgsMultiLineString *mls = dynamic_cast( boundary.get() ); QVERIFY( mls ); QCOMPARE( mls->numGeometries(), 1 ); - auto ls = qgis::down_cast< QgsLineString * >( mls->geometryN( 0 ) ); + auto ls = qgis::down_cast( mls->geometryN( 0 ) ); QCOMPARE( ls->numPoints(), 4 ); QCOMPARE( ls->xAt( 0 ), 0.0 ); QCOMPARE( ls->xAt( 1 ), 1.0 ); @@ -692,26 +637,23 @@ void TestQgsMultiPolygon::boundary() // add polygon with interior rings part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) - << QgsPoint( 11, 11 ) << QgsPoint( 10, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) << QgsPoint( 10, 10 ) ); part.setExteriorRing( ring.clone() ); QgsLineString boundaryRing1; - boundaryRing1.setPoints( QgsPointSequence() << QgsPoint( 10.1, 10.1 ) << QgsPoint( 10.2, 10.1 ) - << QgsPoint( 10.2, 10.2 ) << QgsPoint( 10.1, 10.1 ) ); + boundaryRing1.setPoints( QgsPointSequence() << QgsPoint( 10.1, 10.1 ) << QgsPoint( 10.2, 10.1 ) << QgsPoint( 10.2, 10.2 ) << QgsPoint( 10.1, 10.1 ) ); QgsLineString boundaryRing2; - boundaryRing2.setPoints( QgsPointSequence() << QgsPoint( 10.8, 10.8 ) << QgsPoint( 10.9, 10.8 ) - << QgsPoint( 10.9, 10.9 ) << QgsPoint( 10.8, 10.8 ) ); - part.setInteriorRings( QVector< QgsCurve * >() << boundaryRing1.clone() << boundaryRing2.clone() ); + boundaryRing2.setPoints( QgsPointSequence() << QgsPoint( 10.8, 10.8 ) << QgsPoint( 10.9, 10.8 ) << QgsPoint( 10.9, 10.9 ) << QgsPoint( 10.8, 10.8 ) ); + part.setInteriorRings( QVector() << boundaryRing1.clone() << boundaryRing2.clone() ); mp.addGeometry( part.clone() ); boundary.reset( mp.boundary() ); - mls = static_cast< QgsMultiLineString * >( boundary.get() ); + mls = static_cast( boundary.get() ); QVERIFY( mls ); QCOMPARE( mls->numGeometries(), 4 ); - ls = qgis::down_cast< QgsLineString * >( mls->geometryN( 0 ) ); + ls = qgis::down_cast( mls->geometryN( 0 ) ); QCOMPARE( ls->numPoints(), 4 ); QCOMPARE( ls->xAt( 0 ), 0.0 ); QCOMPARE( ls->xAt( 1 ), 1.0 ); @@ -722,7 +664,7 @@ void TestQgsMultiPolygon::boundary() QCOMPARE( ls->yAt( 2 ), 1.0 ); QCOMPARE( ls->yAt( 3 ), 0.0 ); - ls = qgis::down_cast< QgsLineString * >( mls->geometryN( 1 ) ); + ls = qgis::down_cast( mls->geometryN( 1 ) ); QCOMPARE( ls->numPoints(), 4 ); QCOMPARE( ls->xAt( 0 ), 10.0 ); QCOMPARE( ls->xAt( 1 ), 11.0 ); @@ -733,7 +675,7 @@ void TestQgsMultiPolygon::boundary() QCOMPARE( ls->yAt( 2 ), 11.0 ); QCOMPARE( ls->yAt( 3 ), 10.0 ); - ls = qgis::down_cast< QgsLineString * >( mls->geometryN( 2 ) ); + ls = qgis::down_cast( mls->geometryN( 2 ) ); QCOMPARE( ls->numPoints(), 4 ); QCOMPARE( ls->xAt( 0 ), 10.1 ); QCOMPARE( ls->xAt( 1 ), 10.2 ); @@ -744,7 +686,7 @@ void TestQgsMultiPolygon::boundary() QCOMPARE( ls->yAt( 2 ), 10.2 ); QCOMPARE( ls->yAt( 3 ), 10.1 ); - ls = qgis::down_cast< QgsLineString * >( mls->geometryN( 3 ) ); + ls = qgis::down_cast( mls->geometryN( 3 ) ); QCOMPARE( ls->numPoints(), 4 ); QCOMPARE( ls->xAt( 0 ), 10.8 ); QCOMPARE( ls->xAt( 1 ), 10.9 ); @@ -782,24 +724,20 @@ void TestQgsMultiPolygon::vertexIterator() QgsLineString ring; QgsPolygon part; - ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) - << QgsPoint( 11, 11 ) << QgsPoint( 10, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) << QgsPoint( 11, 11 ) << QgsPoint( 10, 10 ) ); part.setExteriorRing( ring.clone() ); QgsLineString boundaryRing1; - boundaryRing1.setPoints( QgsPointSequence() << QgsPoint( 10.1, 10.1 ) << QgsPoint( 10.2, 10.1 ) - << QgsPoint( 10.2, 10.2 ) << QgsPoint( 10.1, 10.1 ) ); + boundaryRing1.setPoints( QgsPointSequence() << QgsPoint( 10.1, 10.1 ) << QgsPoint( 10.2, 10.1 ) << QgsPoint( 10.2, 10.2 ) << QgsPoint( 10.1, 10.1 ) ); QgsLineString boundaryRing2; - boundaryRing2.setPoints( QgsPointSequence() << QgsPoint( 10.8, 10.8 ) << QgsPoint( 10.9, 10.8 ) - << QgsPoint( 10.9, 10.9 ) << QgsPoint( 10.8, 10.8 ) ); - part.setInteriorRings( QVector< QgsCurve * >() << boundaryRing1.clone() << boundaryRing2.clone() ); + boundaryRing2.setPoints( QgsPointSequence() << QgsPoint( 10.8, 10.8 ) << QgsPoint( 10.9, 10.8 ) << QgsPoint( 10.9, 10.9 ) << QgsPoint( 10.8, 10.8 ) ); + part.setInteriorRings( QVector() << boundaryRing1.clone() << boundaryRing2.clone() ); mp.addGeometry( part.clone() ); // vertex iterator: 2 polygons (one with just exterior ring, other with two interior rings) @@ -913,24 +851,19 @@ void TestQgsMultiPolygon::toCurveType() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); mp.addGeometry( part.clone() ); - std::unique_ptr< QgsMultiSurface > curveType( mp.toCurveType() ); + std::unique_ptr curveType( mp.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::MultiSurfaceZM ); QCOMPARE( curveType->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsPolygon * >( curveType->geometryN( 0 ) ), - *static_cast< const QgsPolygon * >( mp.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( curveType->geometryN( 0 ) ), *static_cast( mp.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( curveType->geometryN( 1 ) ), - *static_cast< const QgsPolygon * >( mp.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( curveType->geometryN( 1 ) ), *static_cast( mp.geometryN( 1 ) ) ); } void TestQgsMultiPolygon::toFromWKB() @@ -939,18 +872,12 @@ void TestQgsMultiPolygon::toFromWKB() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 9, 27 ) - << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 9, 27 ) << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) - << QgsPoint( Qgis::WkbType::Point, 29, 39 ) - << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) << QgsPoint( Qgis::WkbType::Point, 29, 39 ) << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); @@ -962,10 +889,8 @@ void TestQgsMultiPolygon::toFromWKB() mp2.fromWkb( wkbPtr1 ); QCOMPARE( mp2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 0 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 1 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), *static_cast( mp1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), *static_cast( mp1.geometryN( 1 ) ) ); //bad WKB - check for no crash mp2.clear(); @@ -990,18 +915,12 @@ void TestQgsMultiPolygon::toFromWkbZM() QgsLineString ring; //parts with Z - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 27, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 27, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 87, 54, 7 ) - << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 87, 54, 7 ) << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); @@ -1012,28 +931,20 @@ void TestQgsMultiPolygon::toFromWkbZM() QCOMPARE( mp2.numGeometries(), 2 ); QCOMPARE( mp2.wkbType(), Qgis::WkbType::MultiPolygonZ ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 0 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 1 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), *static_cast( mp1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), *static_cast( mp1.geometryN( 1 ) ) ); //parts with m mp1.clear(); mp2.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 21, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 9, 21, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 37, 31, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 37, 31, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); @@ -1043,28 +954,20 @@ void TestQgsMultiPolygon::toFromWkbZM() QCOMPARE( mp2.numGeometries(), 2 ); QCOMPARE( mp2.wkbType(), Qgis::WkbType::MultiPolygonM ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 0 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 1 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), *static_cast( mp1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), *static_cast( mp1.geometryN( 1 ) ) ); // parts with ZM mp1.clear(); mp2.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 19, 13, 5, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 19, 13, 5, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); @@ -1074,10 +977,8 @@ void TestQgsMultiPolygon::toFromWkbZM() QCOMPARE( mp2.numGeometries(), 2 ); QCOMPARE( mp2.wkbType(), Qgis::WkbType::MultiPolygonZM ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 0 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 1 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), *static_cast( mp1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), *static_cast( mp1.geometryN( 1 ) ) ); } void TestQgsMultiPolygon::toFromWKT() @@ -1086,18 +987,12 @@ void TestQgsMultiPolygon::toFromWKT() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 13, 19, 3, 10 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 13, 19, 3, 10 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 17, 49, 31, 53 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 17, 49, 31, 53 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); part.setExteriorRing( ring.clone() ); mp1.addGeometry( part.clone() ); @@ -1108,10 +1003,8 @@ void TestQgsMultiPolygon::toFromWKT() QVERIFY( mp2.fromWkt( wkt ) ); QCOMPARE( mp2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 0 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsPolygon * >( mp2.geometryN( 1 ) ), - *static_cast< const QgsPolygon * >( mp1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 0 ) ), *static_cast( mp1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( mp2.geometryN( 1 ) ), *static_cast( mp1.geometryN( 1 ) ) ); //bad WKT QVERIFY( !mp1.fromWkt( "Point()" ) ); @@ -1127,18 +1020,12 @@ void TestQgsMultiPolygon::exportImport() QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 21 ) - << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 21 ) << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) - << QgsPoint( Qgis::WkbType::Point, 41, 39 ) - << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) << QgsPoint( Qgis::WkbType::Point, 41, 39 ) << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -1166,10 +1053,7 @@ void TestQgsMultiPolygon::exportImport() res = mp.asJson( 1 ); QCOMPARE( res, expectedSimpleJson ); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 17, 27 ) - << QgsPoint( Qgis::WkbType::Point, 18, 28 ) - << QgsPoint( Qgis::WkbType::Point, 19, 37 ) - << QgsPoint( Qgis::WkbType::Point, 17, 27 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 17, 27 ) << QgsPoint( Qgis::WkbType::Point, 18, 28 ) << QgsPoint( Qgis::WkbType::Point, 19, 37 ) << QgsPoint( Qgis::WkbType::Point, 17, 27 ) ); part.addInteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); @@ -1180,17 +1064,12 @@ void TestQgsMultiPolygon::exportImport() mp.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 3 / 5.0, 13 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 8 / 3.0, 27 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 3 / 5.0, 13 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 8 / 3.0, 27 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 7 / 3.0, 17 / 3.0 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 43 / 41.0, 43 / 42.0 ) - << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 43 / 41.0, 43 / 42.0 ) << QgsPoint( Qgis::WkbType::Point, 27 / 3.0, 37 / 9.0 ) ); part.setExteriorRing( ring.clone() ); mp.addGeometry( part.clone() ); diff --git a/tests/src/core/geometry/testqgsmultisurface.cpp b/tests/src/core/geometry/testqgsmultisurface.cpp index 3d2584392d1a..a6f9e3b5ef29 100644 --- a/tests/src/core/geometry/testqgsmultisurface.cpp +++ b/tests/src/core/geometry/testqgsmultisurface.cpp @@ -26,7 +26,7 @@ #include "testgeometryutils.h" -class TestQgsMultiSurface: public QObject +class TestQgsMultiSurface : public QObject { Q_OBJECT private slots: @@ -83,8 +83,7 @@ void TestQgsMultiSurface::addGeometry() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) - << QgsPoint( 2, 11 ) << QgsPoint( 1, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) << QgsPoint( 1, 10 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -101,7 +100,7 @@ void TestQgsMultiSurface::addGeometry() QCOMPARE( ms.dimension(), 2 ); QVERIFY( ms.hasCurvedSegments() ); QVERIFY( ms.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( ms.geometryN( 0 ) ), part ); QVERIFY( !ms.geometryN( 100 ) ); QVERIFY( !ms.geometryN( -1 ) ); QCOMPARE( ms.vertexCount( 0, 0 ), 3 ); @@ -111,38 +110,34 @@ void TestQgsMultiSurface::addGeometry() ms.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) - << QgsPoint( 2, 11 ) << QgsPoint( 1, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) << QgsPoint( 1, 10 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.vertexCount( 0, 0 ), 3 ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) - << QgsPoint( 3, 13 ) << QgsPoint( 9, 12 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) << QgsPoint( 9, 12 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.vertexCount( 1, 0 ), 3 ); QCOMPARE( ms.numGeometries(), 2 ); QVERIFY( ms.geometryN( 0 ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( ms.geometryN( 1 ) ), part ); //adding subsequent points should not alter z/m type, regardless of parts type ms.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) - << QgsPoint( 3, 13 ) << QgsPoint( 9, 12 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) << QgsPoint( 9, 12 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurface ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) - << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 10, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 10, 2 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -156,22 +151,20 @@ void TestQgsMultiSurface::addGeometry() QCOMPARE( ms.partCount(), 2 ); QVERIFY( !ms.is3D() ); - auto cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ); - auto ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + auto cp = static_cast( ms.geometryN( 0 ) ); + auto ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( 9, 12 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( 3, 13 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( 9, 12 ) ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 1 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 1 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( 1, 10 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( 2, 11 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( 1, 10 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 32, 41, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 21, 30, 0, 2 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -185,8 +178,8 @@ void TestQgsMultiSurface::addGeometry() QVERIFY( !ms.is3D() ); QVERIFY( !ms.isMeasure() ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 2 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 2 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( 21, 30 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( 32, 41 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( 21, 30 ) ); @@ -226,9 +219,7 @@ void TestQgsMultiSurface::addGeometryInitialDimension() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 20, 21, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 1 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -237,14 +228,12 @@ void TestQgsMultiSurface::addGeometryInitialDimension() QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceZ ); QCOMPARE( ms.wktTypeStr(), QString( "MultiSurface Z" ) ); QCOMPARE( ms.geometryType(), QString( "MultiSurface" ) ); - QCOMPARE( *( static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( ms.geometryN( 0 ) ) ), part ); ms.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 20, 21, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 11, 0, 1 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -252,14 +241,12 @@ void TestQgsMultiSurface::addGeometryInitialDimension() QVERIFY( ms.isMeasure() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceM ); QCOMPARE( ms.wktTypeStr(), QString( "MultiSurface M" ) ); - QCOMPARE( *( static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( ms.geometryN( 0 ) ) ), part ); ms.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 20, 21, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 11, 2, 1 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -267,7 +254,7 @@ void TestQgsMultiSurface::addGeometryInitialDimension() QVERIFY( ms.isMeasure() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceZM ); QCOMPARE( ms.wktTypeStr(), QString( "MultiSurface ZM" ) ); - QCOMPARE( *( static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ) ), part ); + QCOMPARE( *( static_cast( ms.geometryN( 0 ) ) ), part ); } void TestQgsMultiSurface::addGeometryZ() @@ -276,38 +263,34 @@ void TestQgsMultiSurface::addGeometryZ() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) - << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 10, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10, 2 ) << QgsPoint( 2, 11, 3 ) << QgsPoint( 1, 10, 2 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceZ ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) - << QgsPoint( 3, 31 ) << QgsPoint( 2, 20 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) << QgsPoint( 2, 20 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceZ ); QVERIFY( ms.is3D() ); - auto cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ); - auto ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + auto cp = static_cast( ms.geometryN( 0 ) ); + auto ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( 1, 10, 2 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( 2, 11, 3 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( 1, 10, 2 ) ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 1 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 1 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( 2, 20, 0 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( 3, 31, 0 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( 2, 20, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -315,8 +298,8 @@ void TestQgsMultiSurface::addGeometryZ() QVERIFY( ms.is3D() ); QVERIFY( !ms.isMeasure() ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 2 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 2 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( 5, 50, 0 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( 6, 61, 0 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( 5, 50, 0 ) ); @@ -330,38 +313,34 @@ void TestQgsMultiSurface::addGeometryM() QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurface ); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceM ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) - << QgsPoint( 3, 31 ) << QgsPoint( 2, 20 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 2, 20 ) << QgsPoint( 3, 31 ) << QgsPoint( 2, 20 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceM ); QVERIFY( ms.isMeasure() ); - auto cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ); - auto ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + auto cp = static_cast( ms.geometryN( 0 ) ); + auto ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 6, 61, 0, 5 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( Qgis::WkbType::PointM, 5, 50, 0, 4 ) ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 1 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 1 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 2, 20, 0, 0 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 3, 31, 0, 0 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( Qgis::WkbType::PointM, 2, 20, 0, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) - << QgsPoint( 14, 15, 16 ) << QgsPoint( 11, 12, 13 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( 11, 12, 13 ) << QgsPoint( 14, 15, 16 ) << QgsPoint( 11, 12, 13 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -369,8 +348,8 @@ void TestQgsMultiSurface::addGeometryM() QVERIFY( !ms.is3D() ); QVERIFY( ms.isMeasure() ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 2 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 2 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 0 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( Qgis::WkbType::PointM, 14, 15, 0, 0 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 0 ) ); @@ -382,18 +361,14 @@ void TestQgsMultiSurface::addGeometryZM() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); QCOMPARE( ms.wkbType(), Qgis::WkbType::MultiSurfaceZM ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -401,22 +376,20 @@ void TestQgsMultiSurface::addGeometryZM() QVERIFY( ms.isMeasure() ); QVERIFY( ms.is3D() ); - auto cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ); - auto ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + auto cp = static_cast( ms.geometryN( 0 ) ); + auto ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 1 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 1 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 7, 17, 0, 0 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 3, 13, 0, 0 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 7, 17, 0, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) - << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) - << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) << QgsPoint( Qgis::WkbType::PointZ, 83, 83, 8 ) << QgsPoint( Qgis::WkbType::PointZ, 77, 87, 7 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -424,16 +397,14 @@ void TestQgsMultiSurface::addGeometryZM() QVERIFY( ms.is3D() ); QVERIFY( ms.isMeasure() ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 2 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 2 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 77, 87, 7, 0 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 83, 83, 8, 0 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 77, 87, 7, 0 ) ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) - << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) - << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) << QgsPoint( Qgis::WkbType::PointM, 183, 183, 0, 11 ) << QgsPoint( Qgis::WkbType::PointM, 177, 187, 0, 9 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -441,8 +412,8 @@ void TestQgsMultiSurface::addGeometryZM() QVERIFY( ms.is3D() ); QVERIFY( ms.isMeasure() ); - cp = static_cast< const QgsCurvePolygon * >( ms.geometryN( 3 ) ); - ext = static_cast< const QgsCircularString *>( cp->exteriorRing() ); + cp = static_cast( ms.geometryN( 3 ) ); + ext = static_cast( cp->exteriorRing() ); QCOMPARE( ext->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 177, 187, 0, 9 ) ); QCOMPARE( ext->pointN( 1 ), QgsPoint( Qgis::WkbType::PointZM, 183, 183, 0, 11 ) ); QCOMPARE( ext->pointN( 2 ), QgsPoint( Qgis::WkbType::PointZM, 177, 187, 0, 9 ) ); @@ -470,9 +441,7 @@ void TestQgsMultiSurface::insertGeometry() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) ); part.setExteriorRing( ring.clone() ); ms.insertGeometry( part.clone(), 0 ); @@ -486,14 +455,12 @@ void TestQgsMultiSurface::surfaceN() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) - << QgsPoint( 2, 11 ) << QgsPoint( 1, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 1, 10 ) << QgsPoint( 2, 11 ) << QgsPoint( 1, 10 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) - << QgsPoint( 3, 13 ) << QgsPoint( 9, 12 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 9, 12 ) << QgsPoint( 3, 13 ) << QgsPoint( 9, 12 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); @@ -514,9 +481,7 @@ void TestQgsMultiSurface::assignment() QgsMultiSurface ms3; QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); ms3.addGeometry( part.clone() ); ms3.addGeometry( part.clone() ); @@ -524,8 +489,8 @@ void TestQgsMultiSurface::assignment() ms1 = ms3; QCOMPARE( ms1.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( ms1.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( ms1.geometryN( 1 ) ), part ); } void TestQgsMultiSurface::clone() @@ -534,13 +499,11 @@ void TestQgsMultiSurface::clone() QgsCurvePolygon part; QgsCircularString ring; - std::unique_ptr< QgsMultiSurface >cloned( ms.clone() ); + std::unique_ptr cloned( ms.clone() ); QVERIFY( cloned->isEmpty() ); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); ms.addGeometry( part.clone() ); @@ -548,8 +511,8 @@ void TestQgsMultiSurface::clone() cloned.reset( ms.clone() ); QCOMPARE( cloned->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( cloned->geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( cloned->geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( cloned->geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( cloned->geometryN( 1 ) ), part ); } void TestQgsMultiSurface::copy() @@ -561,9 +524,7 @@ void TestQgsMultiSurface::copy() QgsMultiSurface ms2( ms1 ); QVERIFY( ms2.isEmpty() ); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); ms1.addGeometry( part.clone() ); @@ -572,8 +533,8 @@ void TestQgsMultiSurface::copy() QCOMPARE( ms3.numGeometries(), 2 ); QCOMPARE( ms3.wkbType(), Qgis::WkbType::MultiSurfaceZM ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms3.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms3.geometryN( 1 ) ), part ); + QCOMPARE( *static_cast( ms3.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast( ms3.geometryN( 1 ) ), part ); } void TestQgsMultiSurface::clear() @@ -582,9 +543,7 @@ void TestQgsMultiSurface::clear() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); ms.addGeometry( part.clone() ); @@ -611,34 +570,32 @@ void TestQgsMultiSurface::boundary() QVERIFY( !ms.boundary() ); - ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) ); part1.setExteriorRing( ring.clone() ); ms.addGeometry( part1.clone() ); QgsAbstractGeometry *boundary = ms.boundary(); - QgsMultiCurve *mpBoundary = dynamic_cast< QgsMultiCurve * >( boundary ); + QgsMultiCurve *mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 1 ); - QCOMPARE( *static_cast< const QgsCurve *>( mpBoundary->geometryN( 0 ) ), *part1.exteriorRing() ); + QCOMPARE( *static_cast( mpBoundary->geometryN( 0 ) ), *part1.exteriorRing() ); delete boundary; // add another QgsCircularString QgsCurvePolygon part2; - ring.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) - << QgsPoint( 11, 10 ) << QgsPoint( 10, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 11, 10 ) << QgsPoint( 10, 10 ) ); part2.setExteriorRing( ring.clone() ); ms.addGeometry( part2.clone() ); boundary = ms.boundary(); - mpBoundary = dynamic_cast< QgsMultiCurve * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCurve *>( mpBoundary->geometryN( 0 ) ), *part1.exteriorRing() ); - QCOMPARE( *static_cast< const QgsCurve *>( mpBoundary->geometryN( 1 ) ), *part2.exteriorRing() ); + QCOMPARE( *static_cast( mpBoundary->geometryN( 0 ) ), *part1.exteriorRing() ); + QCOMPARE( *static_cast( mpBoundary->geometryN( 1 ) ), *part2.exteriorRing() ); delete boundary; @@ -648,26 +605,22 @@ void TestQgsMultiSurface::boundary() part1.clear(); part2.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); part1.setExteriorRing( ring.clone() ); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 20, 150 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 20, 150 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 100 ) ); part2.setExteriorRing( ring.clone() ); ms.addGeometry( part1.clone() ); ms.addGeometry( part2.clone() ); boundary = ms.boundary(); - mpBoundary = dynamic_cast< QgsMultiCurve * >( boundary ); + mpBoundary = dynamic_cast( boundary ); QVERIFY( mpBoundary ); QCOMPARE( mpBoundary->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCurve *>( mpBoundary->geometryN( 0 ) ), *part1.exteriorRing() ); - QCOMPARE( *static_cast< const QgsCurve *>( mpBoundary->geometryN( 1 ) ), *part2.exteriorRing() ); + QCOMPARE( *static_cast( mpBoundary->geometryN( 0 ) ), *part1.exteriorRing() ); + QCOMPARE( *static_cast( mpBoundary->geometryN( 1 ) ), *part2.exteriorRing() ); delete boundary; } @@ -698,22 +651,18 @@ void TestQgsMultiSurface::toCurveType() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); ms.addGeometry( part.clone() ); ms.addGeometry( part.clone() ); - std::unique_ptr< QgsMultiSurface > curveType( ms.toCurveType() ); + std::unique_ptr curveType( ms.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::MultiSurfaceZM ); QCOMPARE( curveType->numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( curveType->geometryN( 0 ) ), - *static_cast< const QgsCurvePolygon * >( ms.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( curveType->geometryN( 1 ) ), - *static_cast< const QgsCurvePolygon * >( ms.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( curveType->geometryN( 0 ) ), *static_cast( ms.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( curveType->geometryN( 1 ) ), *static_cast( ms.geometryN( 1 ) ) ); } void TestQgsMultiSurface::toFromWKT() @@ -722,16 +671,12 @@ void TestQgsMultiSurface::toFromWKT() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 11, 2, 8 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 53, 21, 52 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); @@ -742,10 +687,8 @@ void TestQgsMultiSurface::toFromWKT() QVERIFY( ms2.fromWkt( wkt ) ); QCOMPARE( ms2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 0 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 1 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 0 ) ), *static_cast( ms1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 1 ) ), *static_cast( ms1.geometryN( 1 ) ) ); //bad WKT ms1.clear(); @@ -761,16 +704,12 @@ void TestQgsMultiSurface::toFromWKB() QgsCurvePolygon part; QgsCircularString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) - << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); @@ -780,10 +719,8 @@ void TestQgsMultiSurface::toFromWKB() ms2.fromWkb( wkbPtr ); QCOMPARE( ms2.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 0 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 1 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 0 ) ), *static_cast( ms1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 1 ) ), *static_cast( ms1.geometryN( 1 ) ) ); //bad WKB - check for no crash ms2.clear(); @@ -808,16 +745,12 @@ void TestQgsMultiSurface::toFromWkbZM() //parts with Z - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 3, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 17, 1 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 43, 43, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 27, 37, 2 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); @@ -828,26 +761,20 @@ void TestQgsMultiSurface::toFromWkbZM() QCOMPARE( ms2.numGeometries(), 2 ); QCOMPARE( ms2.wkbType(), Qgis::WkbType::MultiSurfaceZ ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 0 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 1 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 0 ) ), *static_cast( ms1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 1 ) ), *static_cast( ms1.geometryN( 1 ) ) ); //parts with m ms1.clear(); ms2.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 3, 13, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 7, 17, 0, 1 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 43, 43, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 27, 37, 0, 2 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); @@ -857,26 +784,20 @@ void TestQgsMultiSurface::toFromWkbZM() QCOMPARE( ms2.numGeometries(), 2 ); QCOMPARE( ms2.wkbType(), Qgis::WkbType::MultiSurfaceM ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 0 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 1 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 0 ) ), *static_cast( ms1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 1 ) ), *static_cast( ms1.geometryN( 1 ) ) ); // parts with ZM ms1.clear(); ms2.clear(); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 3, 13, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 7, 17, 4, 1 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); part.clear(); - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 43, 43, 11, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 27, 37, 6, 2 ) ); part.setExteriorRing( ring.clone() ); ms1.addGeometry( part.clone() ); @@ -886,10 +807,8 @@ void TestQgsMultiSurface::toFromWkbZM() QCOMPARE( ms2.numGeometries(), 2 ); QCOMPARE( ms2.wkbType(), Qgis::WkbType::MultiSurfaceZM ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 0 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 0 ) ) ); - QCOMPARE( *static_cast< const QgsCurvePolygon * >( ms2.geometryN( 1 ) ), - *static_cast< const QgsCurvePolygon * >( ms1.geometryN( 1 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 0 ) ), *static_cast( ms1.geometryN( 0 ) ) ); + QCOMPARE( *static_cast( ms2.geometryN( 1 ) ), *static_cast( ms1.geometryN( 1 ) ) ); } void TestQgsMultiSurface::exportImport() @@ -900,18 +819,12 @@ void TestQgsMultiSurface::exportImport() QgsCurvePolygon part; QgsCircularString ring; - lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) - << QgsPoint( Qgis::WkbType::Point, 7, 13 ) - << QgsPoint( Qgis::WkbType::Point, 3, 13 ) - << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ) ; + lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 7, 17 ) << QgsPoint( Qgis::WkbType::Point, 7, 13 ) << QgsPoint( Qgis::WkbType::Point, 3, 13 ) << QgsPoint( Qgis::WkbType::Point, 7, 17 ) ); part.setExteriorRing( lineRing.clone() ); exportC.addGeometry( part.clone() ); part.clear(); - lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) - << QgsPoint( Qgis::WkbType::Point, 27, 43 ) - << QgsPoint( Qgis::WkbType::Point, 43, 43 ) - << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ) ; + lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 27, 37 ) << QgsPoint( Qgis::WkbType::Point, 27, 43 ) << QgsPoint( Qgis::WkbType::Point, 43, 43 ) << QgsPoint( Qgis::WkbType::Point, 27, 37 ) ); part.setExteriorRing( lineRing.clone() ); exportC.addGeometry( part.clone() ); @@ -940,10 +853,7 @@ void TestQgsMultiSurface::exportImport() res = exportC.asJson( 1 ); QCOMPARE( res, expectedSimpleJson ); - lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 17, 27 ) - << QgsPoint( Qgis::WkbType::Point, 17, 28 ) - << QgsPoint( Qgis::WkbType::Point, 18, 28 ) - << QgsPoint( Qgis::WkbType::Point, 17, 27 ) ) ; + lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 17, 27 ) << QgsPoint( Qgis::WkbType::Point, 17, 28 ) << QgsPoint( Qgis::WkbType::Point, 18, 28 ) << QgsPoint( Qgis::WkbType::Point, 17, 27 ) ); part.addInteriorRing( lineRing.clone() ); exportC.addGeometry( part.clone() ); @@ -954,10 +864,7 @@ void TestQgsMultiSurface::exportImport() QgsMultiSurface exportFloat; part.clear(); - lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0.1234, 0.1234 ) - << QgsPoint( Qgis::WkbType::Point, 0.1234, 1.2344 ) - << QgsPoint( Qgis::WkbType::Point, 1.2344, 1.2344 ) - << QgsPoint( Qgis::WkbType::Point, 0.1234, 0.1234 ) ) ; + lineRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0.1234, 0.1234 ) << QgsPoint( Qgis::WkbType::Point, 0.1234, 1.2344 ) << QgsPoint( Qgis::WkbType::Point, 1.2344, 1.2344 ) << QgsPoint( Qgis::WkbType::Point, 0.1234, 0.1234 ) ); part.setExteriorRing( lineRing.clone() ); exportFloat.addGeometry( part.clone() ); diff --git a/tests/src/core/geometry/testqgspoint.cpp b/tests/src/core/geometry/testqgspoint.cpp index 5dca51ccc864..c6b068f5fbb9 100644 --- a/tests/src/core/geometry/testqgspoint.cpp +++ b/tests/src/core/geometry/testqgspoint.cpp @@ -23,7 +23,7 @@ #include "qgscoordinatetransform.h" #include "testgeometryutils.h" -class TestQgsPoint: public QObject +class TestQgsPoint : public QObject { Q_OBJECT private slots: @@ -209,7 +209,6 @@ void TestQgsPoint::constructorM() QVERIFY( !pt3.is3D() ); QVERIFY( pt3.isMeasure() ); - } void TestQgsPoint::constructorZM() @@ -264,7 +263,7 @@ void TestQgsPoint::clone() { QgsPoint pt( Qgis::WkbType::PointZM, 9.0, 3.0, 13.0, 23.0 ); - std::unique_ptr< QgsPoint >clone( pt.clone() ); + std::unique_ptr clone( pt.clone() ); QVERIFY( pt == *clone ); } @@ -337,51 +336,36 @@ void TestQgsPoint::equality() QVERIFY( pt2 == pt1 ); - QVERIFY( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ); + QVERIFY( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::PointZ, 2 / 3.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::PointZ, 2 / 3.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::Point, 1 / 3.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::Point, 1 / 3.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) == - QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) == QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); - QVERIFY( QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) ); + QVERIFY( QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointZM, 3.0, 4.0, 1 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::PointZM, 3.0, 4.0, 1 / 3.0 ) ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 2 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 2 / 3.0 ) == QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 1 / 3.0 ) ) ); - QVERIFY( QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) ); + QVERIFY( QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 0.0, 1 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 0.0, 1 / 3.0 ) ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 2 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::PointM, 3.0, 4.0, 0.0, 2 / 3.0 ) ) ); - QVERIFY( QgsPoint( Qgis::WkbType::PointZM, 3.0, 4.0, 2 / 3.0, 1 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointZM, 3.0, 4.0, 2 / 3.0, 1 / 3.0 ) ); + QVERIFY( QgsPoint( Qgis::WkbType::PointZM, 3.0, 4.0, 2 / 3.0, 1 / 3.0 ) == QgsPoint( Qgis::WkbType::PointZM, 3.0, 4.0, 2 / 3.0, 1 / 3.0 ) ); - QVERIFY( QgsPoint( Qgis::WkbType::Point25D, 3.0, 4.0, 2 / 3.0 ) == - QgsPoint( Qgis::WkbType::Point25D, 3.0, 4.0, 2 / 3.0 ) ); + QVERIFY( QgsPoint( Qgis::WkbType::Point25D, 3.0, 4.0, 2 / 3.0 ) == QgsPoint( Qgis::WkbType::Point25D, 3.0, 4.0, 2 / 3.0 ) ); - QVERIFY( !( QgsPoint( Qgis::WkbType::Point25D, 3.0, 4.0, 2 / 3.0 ) == - QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 2 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::Point25D, 3.0, 4.0, 2 / 3.0 ) == QgsPoint( Qgis::WkbType::PointZ, 3.0, 4.0, 2 / 3.0 ) ) ); //test inequality operator - QVERIFY( !( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) != - QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); + QVERIFY( !( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) != QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) ) ); - QVERIFY( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) != - QgsPoint( Qgis::WkbType::PointZ, 2 / 3.0, 1 / 3.0 ) ); + QVERIFY( QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 1 / 3.0 ) != QgsPoint( Qgis::WkbType::PointZ, 2 / 3.0, 1 / 3.0 ) ); QgsLineString ls; QVERIFY( pt1 != ls ); @@ -396,7 +380,7 @@ void TestQgsPoint::operators() QCOMPARE( pt2 - pt1, QgsVector( 2, 3 ) ); QCOMPARE( pt1 - pt2, QgsVector( -2, -3 ) ); -// pt1 = QgsPoint( 1, 2 ); ??? + // pt1 = QgsPoint( 1, 2 ); ??? QCOMPARE( pt1 + QgsVector( 3, 5 ), QgsPoint( 4, 7 ) ); pt1 += QgsVector( 3, 5 ); @@ -451,7 +435,6 @@ void TestQgsPoint::dropDimension() QVERIFY( pt.dropMValue() ); QCOMPARE( pt, QgsPoint( Qgis::WkbType::PointZ, 1.0, 2.0, 3.0, 0.0 ) ); QVERIFY( !pt.dropMValue() ); - } void TestQgsPoint::swapXy() @@ -624,34 +607,28 @@ void TestQgsPoint::moveVertex() { QgsPoint pt( Qgis::WkbType::PointZM, 3.0, 4.0, 6.0, 7.0 ); - pt.moveVertex( QgsVertexId( 0, 0, 0 ), - QgsPoint( Qgis::WkbType::PointZM, 1.0, 2.0, 3.0, 4.0 ) ); + pt.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointZM, 1.0, 2.0, 3.0, 4.0 ) ); QCOMPARE( pt, QgsPoint( Qgis::WkbType::PointZM, 1.0, 2.0, 3.0, 4.0 ) ); //invalid vertex id, should not crash - pt.moveVertex( QgsVertexId( 1, 2, 3 ), - QgsPoint( Qgis::WkbType::PointZM, 2.0, 3.0, 1.0, 2.0 ) ); + pt.moveVertex( QgsVertexId( 1, 2, 3 ), QgsPoint( Qgis::WkbType::PointZM, 2.0, 3.0, 1.0, 2.0 ) ); QCOMPARE( pt, QgsPoint( Qgis::WkbType::PointZM, 2.0, 3.0, 1.0, 2.0 ) ); //move PointZM using Point - pt.moveVertex( QgsVertexId( 0, 0, 0 ), - QgsPoint( Qgis::WkbType::Point, 11.0, 12.0 ) ); + pt.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::Point, 11.0, 12.0 ) ); QCOMPARE( pt, QgsPoint( Qgis::WkbType::PointZM, 11.0, 12.0, 1.0, 2.0 ) ); //move PointZM using PointZ - pt.moveVertex( QgsVertexId( 0, 0, 0 ), - QgsPoint( Qgis::WkbType::PointZ, 21.0, 22.0, 23.0 ) ); + pt.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointZ, 21.0, 22.0, 23.0 ) ); QCOMPARE( pt, QgsPoint( Qgis::WkbType::PointZM, 21.0, 22.0, 23.0, 2.0 ) ); //move PointZM using PointM - pt.moveVertex( QgsVertexId( 0, 0, 0 ), - QgsPoint( Qgis::WkbType::PointM, 31.0, 32.0, 0.0, 43.0 ) ); + pt.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointM, 31.0, 32.0, 0.0, 43.0 ) ); QCOMPARE( pt, QgsPoint( Qgis::WkbType::PointZM, 31.0, 32.0, 23.0, 43.0 ) ); //move Point using PointZM (z/m should be ignored) pt = QgsPoint( 3.0, 4.0 ); - pt.moveVertex( QgsVertexId( 0, 0, 0 ), - QgsPoint( Qgis::WkbType::PointZM, 2.0, 3.0, 1.0, 2.0 ) ); + pt.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( Qgis::WkbType::PointZM, 2.0, 3.0, 1.0, 2.0 ) ); QCOMPARE( pt, QgsPoint( 2.0, 3.0 ) ); } @@ -660,7 +637,7 @@ void TestQgsPoint::vertexAngle() QgsPoint pt( 3.0, 4.0 ); //undefined, but check that it doesn't crash - ( void )pt.vertexAngle( QgsVertexId() ); + ( void ) pt.vertexAngle( QgsVertexId() ); } void TestQgsPoint::removeDuplicateNodes() @@ -685,7 +662,7 @@ void TestQgsPoint::project() QCOMPARE( pt.project( 5, 270 ), QgsPoint( -4, 2 ) ); QCOMPARE( pt.project( 6, 360 ), QgsPoint( 1, 8 ) ); QCOMPARE( pt.project( 5, 450 ), QgsPoint( 6, 2 ) ); - QCOMPARE( pt.project( 5, 450, 450 ), QgsPoint( 6, 2 ) ); // stay Qgis::WkbType::Point + QCOMPARE( pt.project( 5, 450, 450 ), QgsPoint( 6, 2 ) ); // stay Qgis::WkbType::Point QCOMPARE( pt.project( -1, 0 ), QgsPoint( 1, 1 ) ); QCOMPARE( pt.project( 1.5, -90 ), QgsPoint( -0.5, 2 ) ); @@ -693,9 +670,9 @@ void TestQgsPoint::project() pt.addZValue( 0 ); QCOMPARE( pt.project( 1, 0, 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 1 ) ); - QCOMPARE( pt.project( 2, 180, 180 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, -2 ) ); - QCOMPARE( pt.project( 5, 270, 270 ), QgsPoint( Qgis::WkbType::PointZ, 6, 2, 0 ) ); - QCOMPARE( pt.project( 6, 360, 360 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 6 ) ); + QCOMPARE( pt.project( 2, 180, 180 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, -2 ) ); + QCOMPARE( pt.project( 5, 270, 270 ), QgsPoint( Qgis::WkbType::PointZ, 6, 2, 0 ) ); + QCOMPARE( pt.project( 6, 360, 360 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 6 ) ); QCOMPARE( pt.project( -1, 0, 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, -1 ) ); QCOMPARE( pt.project( 1.5, -90, -90 ), QgsPoint( Qgis::WkbType::PointZ, 2.5, 2, 0 ) ); @@ -773,7 +750,7 @@ void TestQgsPoint::measures() QCOMPARE( pt.centroid(), pt ); QVERIFY( !pt.hasCurvedSegments() ); - std::unique_ptr< QgsPoint >segmented( static_cast< QgsPoint *>( pt.segmentize() ) ); + std::unique_ptr segmented( static_cast( pt.segmentize() ) ); QCOMPARE( *segmented, pt ); } @@ -847,35 +824,25 @@ void TestQgsPoint::azimuth() void TestQgsPoint::inclination() { - QCOMPARE( QgsPoint( 1, 2 ).inclination( - QgsPoint( 1, 2 ) ), 90.0 ); + QCOMPARE( QgsPoint( 1, 2 ).inclination( QgsPoint( 1, 2 ) ), 90.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 1, 2, 0 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 1, 2, 0 ) ), 90.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 1, 2, 0 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 1, 2, 0 ) ), 90.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 90 ) ), 90.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 90 ) ), 90.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, -90 ) ), 90.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, -90 ) ), 90.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 0 ) ), 0.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 0 ) ), 0.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 180 ) ), 180.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 180 ) ), 180.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, -180 ) ), 180.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, -180 ) ), 180.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 720 ) ), 0.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 720 ) ), 0.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 45 ) ), 45.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 45 ) ), 45.0 ); - QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 135 ) ), 135.0 ); + QCOMPARE( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).inclination( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 2 ).project( 5, 90, 135 ) ), 135.0 ); } void TestQgsPoint::boundary() @@ -946,25 +913,31 @@ void TestQgsPoint::boundingBoxIntersects() { // 2d QVERIFY( QgsPoint( 1, 2 ).boundingBoxIntersects( - QgsRectangle( 0, 0.5, 1.5, 3 ) ) ); + QgsRectangle( 0, 0.5, 1.5, 3 ) + ) ); QVERIFY( !QgsPoint( 1, 2 ).boundingBoxIntersects( - QgsRectangle( 3, 0.5, 3.5, 3 ) ) ); + QgsRectangle( 3, 0.5, 3.5, 3 ) + ) ); QVERIFY( !QgsPoint().boundingBoxIntersects( - QgsRectangle( 0, 0.5, 3.5, 3 ) ) ); + QgsRectangle( 0, 0.5, 3.5, 3 ) + ) ); // 3d QVERIFY( QgsPoint( 1, 2, 3 ).boundingBoxIntersects( - QgsBox3D( 0, 0.5, 1.5, 3, 2.5, 4.2 ) ) ); + QgsBox3D( 0, 0.5, 1.5, 3, 2.5, 4.2 ) + ) ); QVERIFY( !QgsPoint( 1, 2, 3 ).boundingBoxIntersects( - QgsBox3D( 3, 0.5, 1.5, 3.5, 2.5, 4.5 ) ) ); + QgsBox3D( 3, 0.5, 1.5, 3.5, 2.5, 4.5 ) + ) ); QVERIFY( !QgsPoint().boundingBoxIntersects( - QgsBox3D( 0, 0.5, 1.5, 3.5, 2.5, 4.5 ) ) ); + QgsBox3D( 0, 0.5, 1.5, 3.5, 2.5, 4.5 ) + ) ); } void TestQgsPoint::filterVertices() { QgsPoint pt( 1.1, 2.2, 3.3, 4.4, Qgis::WkbType::PointZM ); - pt.filterVertices( []( const QgsPoint & )-> bool { return false; } ); + pt.filterVertices( []( const QgsPoint & ) -> bool { return false; } ); QCOMPARE( pt.x(), 1.1 ); QCOMPARE( pt.y(), 2.2 ); QCOMPARE( pt.z(), 3.3 ); @@ -976,8 +949,7 @@ void TestQgsPoint::transformVertices() { QgsPoint pt( 1.1, 2.2, 3.3, 4.4, Qgis::WkbType::PointZM ); - pt.transformVertices( []( const QgsPoint & pt )-> QgsPoint - { + pt.transformVertices( []( const QgsPoint &pt ) -> QgsPoint { return QgsPoint( pt.x() + 2, pt.y() + 3, pt.z() + 1, pt.m() + 8 ); } ); @@ -988,8 +960,7 @@ void TestQgsPoint::transformVertices() QCOMPARE( pt.wkbType(), Qgis::WkbType::PointZM ); // no dimensionality change allowed - pt.transformVertices( []( const QgsPoint & pt )-> QgsPoint - { + pt.transformVertices( []( const QgsPoint &pt ) -> QgsPoint { return QgsPoint( pt.x() + 2, pt.y() + 3 ); } ); @@ -1000,8 +971,7 @@ void TestQgsPoint::transformVertices() QCOMPARE( pt.wkbType(), Qgis::WkbType::PointZM ); pt = QgsPoint( 2, 3 ); - pt.transformVertices( []( const QgsPoint & pt )-> QgsPoint - { + pt.transformVertices( []( const QgsPoint &pt ) -> QgsPoint { return QgsPoint( pt.x() + 2, pt.y() + 3, 7, 8 ); } ); @@ -1113,7 +1083,7 @@ void TestQgsPoint::toCurveType() { QgsPoint pt( Qgis::WkbType::PointZM, 9.0, 3.0, 13.0, 23.0 ); - std::unique_ptr< QgsPoint >clone( pt.toCurveType() ); + std::unique_ptr clone( pt.toCurveType() ); QVERIFY( pt == *clone ); } diff --git a/tests/src/core/geometry/testqgspointxy.cpp b/tests/src/core/geometry/testqgspointxy.cpp index 4f8d9e8abe7a..d065be2825b5 100644 --- a/tests/src/core/geometry/testqgspointxy.cpp +++ b/tests/src/core/geometry/testqgspointxy.cpp @@ -27,17 +27,17 @@ #include #include "qgsreferencedgeometry.h" -class TestQgsPointXY: public QgsTest +class TestQgsPointXY : public QgsTest { Q_OBJECT public: - - TestQgsPointXY() : QgsTest( QStringLiteral( "QgsPointXY Tests" ) ) {} + TestQgsPointXY() + : QgsTest( QStringLiteral( "QgsPointXY Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void equality(); void gettersSetters(); void constructors(); @@ -361,7 +361,7 @@ void TestQgsPointXY::isEmpty() QCOMPARE( pointEmpty.x(), 0.0 ); QCOMPARE( pointEmpty.y(), 0.0 ); pointEmpty.setX( 7 ); - QVERIFY( ! pointEmpty.isEmpty() ); + QVERIFY( !pointEmpty.isEmpty() ); QCOMPARE( pointEmpty.x(), 7.0 ); QCOMPARE( pointEmpty.y(), 0.0 ); pointEmpty = QgsPointXY(); @@ -369,14 +369,14 @@ void TestQgsPointXY::isEmpty() QCOMPARE( pointEmpty.x(), 0.0 ); QCOMPARE( pointEmpty.y(), 0.0 ); pointEmpty.setY( 4 ); - QVERIFY( ! pointEmpty.isEmpty() ); + QVERIFY( !pointEmpty.isEmpty() ); QCOMPARE( pointEmpty.x(), 0.0 ); QCOMPARE( pointEmpty.y(), 4.0 ); QVERIFY( QgsPointXY( QgsPoint() ).isEmpty() ); // "can't" be empty - QVERIFY( ! QgsPointXY( QPoint() ).isEmpty() ); - QVERIFY( ! QgsPointXY( QPointF() ).isEmpty() ); + QVERIFY( !QgsPointXY( QPoint() ).isEmpty() ); + QVERIFY( !QgsPointXY( QPointF() ).isEmpty() ); } QGSTEST_MAIN( TestQgsPointXY ) diff --git a/tests/src/core/geometry/testqgspolygon.cpp b/tests/src/core/geometry/testqgspolygon.cpp index c7b10a295501..a83f19b2d706 100644 --- a/tests/src/core/geometry/testqgspolygon.cpp +++ b/tests/src/core/geometry/testqgspolygon.cpp @@ -26,7 +26,7 @@ #include "testgeometryutils.h" #include "testtransformer.h" -class TestQgsPolygon: public QObject +class TestQgsPolygon : public QObject { Q_OBJECT private slots: @@ -110,17 +110,11 @@ void TestQgsPolygon::constructor() void TestQgsPolygon::altConstructor() { - QgsLineString ext( QVector() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); - QgsLineString ring1( QVector< QgsPoint >() << QgsPoint( 1, 1 ) - << QgsPoint( 2, 1 ) << QgsPoint( 2, 2 ) - << QgsPoint( 1, 2 ) << QgsPoint( 1, 1 ) ); - QgsLineString ring2( QVector< QgsPoint >() << QgsPoint( 3, 1 ) - << QgsPoint( 4, 1 ) << QgsPoint( 4, 2 ) - << QgsPoint( 3, 2 ) << QgsPoint( 3, 1 ) ); - - QgsPolygon pl( ext.clone(), QList< QgsLineString *>() << ring1.clone() << ring2.clone() ); + QgsLineString ext( QVector() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + QgsLineString ring1( QVector() << QgsPoint( 1, 1 ) << QgsPoint( 2, 1 ) << QgsPoint( 2, 2 ) << QgsPoint( 1, 2 ) << QgsPoint( 1, 1 ) ); + QgsLineString ring2( QVector() << QgsPoint( 3, 1 ) << QgsPoint( 4, 1 ) << QgsPoint( 4, 2 ) << QgsPoint( 3, 2 ) << QgsPoint( 3, 1 ) ); + + QgsPolygon pl( ext.clone(), QList() << ring1.clone() << ring2.clone() ); QCOMPARE( pl.asWkt(), QStringLiteral( "Polygon ((0 0, 0 10, 10 10, 10 0, 0 0),(1 1, 2 1, 2 2, 1 2, 1 1),(3 1, 4 1, 4 2, 3 2, 3 1))" ) ); } @@ -130,11 +124,7 @@ void TestQgsPolygon::polygon25D() //test handling of 25D rings/polygons QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) ); pl.setExteriorRing( ext ); QVERIFY( pl.is3D() ); @@ -143,11 +133,7 @@ void TestQgsPolygon::polygon25D() //adding a LineStringZ, should become LineString25D QgsLineString *ring1 = new QgsLineString(); - ring1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); + ring1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); QCOMPARE( ring1->wkbType(), Qgis::WkbType::LineStringZ ); @@ -157,16 +143,11 @@ void TestQgsPolygon::polygon25D() QVERIFY( pl.interiorRing( 0 )->is3D() ); QVERIFY( !pl.interiorRing( 0 )->isMeasure() ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString25D ); - QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), - QgsPoint( Qgis::WkbType::Point25D, 0.1, 0.1, 1 ) ); + QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::Point25D, 0.1, 0.1, 1 ) ); //add a LineStringM, should become LineString25D ring1 = new QgsLineString(); - ring1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.2, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.1, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) ); + ring1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.2, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.1, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) ); QCOMPARE( ring1->wkbType(), Qgis::WkbType::LineStringM ); @@ -176,14 +157,11 @@ void TestQgsPolygon::polygon25D() QVERIFY( pl.interiorRing( 1 )->is3D() ); QVERIFY( !pl.interiorRing( 1 )->isMeasure() ); QCOMPARE( pl.interiorRing( 1 )->wkbType(), Qgis::WkbType::LineString25D ); - QCOMPARE( pl.interiorRing( 1 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), - QgsPoint( Qgis::WkbType::Point25D, 0.1, 0.1 ) ); + QCOMPARE( pl.interiorRing( 1 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::Point25D, 0.1, 0.1 ) ); //add curved ring to polygon QgsCircularString *ring2 = new QgsCircularString(); - ring2->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ring2->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); QVERIFY( ring2->hasCurvedSegments() ); @@ -201,19 +179,11 @@ void TestQgsPolygon::clear() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); pl.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); pl.addInteriorRing( ring ); QCOMPARE( pl.numInteriorRings(), 1 ); @@ -239,38 +209,28 @@ void TestQgsPolygon::equality() QVERIFY( !( pl1 != pl2 ) ); QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl1.setExteriorRing( ext ); QVERIFY( !( pl1 == pl2 ) ); QVERIFY( pl1 != pl2 ); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl2.setExteriorRing( ext ); QVERIFY( pl1 == pl2 ); QVERIFY( !( pl1 != pl2 ) ); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 0 ) << QgsPoint( 0, 0 ) ); pl2.setExteriorRing( ext ); QVERIFY( !( pl1 == pl2 ) ); QVERIFY( pl1 != pl2 ); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); pl2.setExteriorRing( ext ); QVERIFY( !( pl1 == pl2 ) ); @@ -282,18 +242,14 @@ void TestQgsPolygon::equality() QVERIFY( !( pl1 != pl2 ) ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); pl1.addInteriorRing( ring ); QVERIFY( !( pl1 == pl2 ) ); QVERIFY( pl1 != pl2 ); ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 2, 1 ) - << QgsPoint( 2, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 2, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 2, 1 ) << QgsPoint( 2, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 2, 1 ) ); pl2.addInteriorRing( ring ); QVERIFY( !( pl1 == pl2 ) ); @@ -314,23 +270,15 @@ void TestQgsPolygon::clone() { QgsPolygon pl; - std::unique_ptr< QgsPolygon > cloned( pl.clone() ); + std::unique_ptr cloned( pl.clone() ); QCOMPARE( pl, *cloned ); QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); pl.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); pl.addInteriorRing( ring ); cloned.reset( pl.clone() ); @@ -345,19 +293,11 @@ void TestQgsPolygon::copy() QCOMPARE( pl1, pl2 ); QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); pl1.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); pl1.addInteriorRing( ring ); pl2 = QgsPolygon( pl1 ); @@ -374,19 +314,11 @@ void TestQgsPolygon::assignment() QgsPolygon pl3; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); pl3.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); pl3.addInteriorRing( ring ); pl1 = pl3; @@ -425,8 +357,7 @@ void TestQgsPolygon::setBadExteriorRing() //test that a non closed exterior ring will be automatically closed ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) ); QVERIFY( !ext->isClosed() ); @@ -442,9 +373,7 @@ void TestQgsPolygon::setExteriorRing() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext ); QVERIFY( !pl.isEmpty() ); @@ -465,7 +394,7 @@ void TestQgsPolygon::setExteriorRing() QVERIFY( !pl.interiorRing( 0 ) ); //retrieve exterior ring and check - QCOMPARE( *( static_cast< const QgsLineString * >( pl.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( pl.exteriorRing() ) ), *ext ); } void TestQgsPolygon::setExteriorRingZM() @@ -474,11 +403,7 @@ void TestQgsPolygon::setExteriorRingZM() //initial setting of exterior ring should set z/m type QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); pl.setExteriorRing( ext ); QVERIFY( pl.is3D() ); @@ -486,52 +411,40 @@ void TestQgsPolygon::setExteriorRingZM() QCOMPARE( pl.wkbType(), Qgis::WkbType::PolygonZ ); QCOMPARE( pl.wktTypeStr(), QString( "Polygon Z" ) ); QCOMPARE( pl.geometryType(), QString( "Polygon" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( pl.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( pl.exteriorRing() ) ), *ext ); pl.clear(); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); pl.setExteriorRing( ext ); QVERIFY( !pl.is3D() ); QVERIFY( pl.isMeasure() ); QCOMPARE( pl.wkbType(), Qgis::WkbType::PolygonM ); QCOMPARE( pl.wktTypeStr(), QString( "Polygon M" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( pl.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( pl.exteriorRing() ) ), *ext ); pl.clear(); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 3, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 5, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 3, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 5, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 2, 1 ) ); pl.setExteriorRing( ext ); QVERIFY( pl.is3D() ); QVERIFY( pl.isMeasure() ); QCOMPARE( pl.wkbType(), Qgis::WkbType::PolygonZM ); QCOMPARE( pl.wktTypeStr(), QString( "Polygon ZM" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( pl.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( pl.exteriorRing() ) ), *ext ); pl.clear(); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) ); pl.setExteriorRing( ext ); QVERIFY( pl.is3D() ); QVERIFY( !pl.isMeasure() ); QCOMPARE( pl.wkbType(), Qgis::WkbType::Polygon25D ); QCOMPARE( pl.wktTypeStr(), QString( "Polygon Z" ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( pl.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( pl.exteriorRing() ) ), *ext ); } void TestQgsPolygon::setCurvedExteriorRing() @@ -540,9 +453,7 @@ void TestQgsPolygon::setCurvedExteriorRing() //setting curved exterior ring should be segmentized QgsCircularString *cs = new QgsCircularString(); - cs->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + cs->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); QVERIFY( cs->hasCurvedSegments() ); @@ -558,14 +469,10 @@ void TestQgsPolygon::setExteriorRingChangesInteriorRings() //change dimensionality of interior rings using setExteriorRing QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); pl.setExteriorRing( ext ); - QVector< QgsCurve * > rings; + QVector rings; QgsPointSequence pts; pts << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) @@ -574,16 +481,16 @@ void TestQgsPolygon::setExteriorRingChangesInteriorRings() << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[0] )->setPoints( pts ); + static_cast( rings[0] )->setPoints( pts ); pts = QgsPointSequence(); pts << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.3, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.4, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.4, 0.4, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.4, 0.3, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.3, 1 ); + << QgsPoint( Qgis::WkbType::PointZ, 0.3, 0.3, 1 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[1] )->setPoints( pts ); + static_cast( rings[1] )->setPoints( pts ); pl.setInteriorRings( rings ); @@ -596,9 +503,7 @@ void TestQgsPolygon::setExteriorRingChangesInteriorRings() //reset exterior ring to 2d ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext ); @@ -608,11 +513,7 @@ void TestQgsPolygon::setExteriorRingChangesInteriorRings() //reset exterior ring to LineStringM ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 10 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 0 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10 ) << QgsPoint( Qgis::WkbType::PointM, 10, 0 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0 ) ); pl.setExteriorRing( ext ); @@ -622,11 +523,7 @@ void TestQgsPolygon::setExteriorRingChangesInteriorRings() //25D exterior ring ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 10 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 0 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 10 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 10 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 0 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 0 ) ); pl.setExteriorRing( ext ); @@ -645,10 +542,7 @@ void TestQgsPolygon::deleteExteriorRing() QgsPolygon pl; QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) - << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -673,9 +567,7 @@ void TestQgsPolygon::addInteriorRing() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext ); //empty ring @@ -688,9 +580,7 @@ void TestQgsPolygon::addInteriorRing() QCOMPARE( pl.numInteriorRings(), 0 ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); pl.addInteriorRing( ring ); QCOMPARE( pl.numInteriorRings(), 1 ); @@ -699,21 +589,15 @@ void TestQgsPolygon::addInteriorRing() QgsCoordinateSequence seq = pl.coordinateSequence(); QgsRingSequence expected; - expected << ( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); - expected << ( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + expected << ( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + expected << ( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); QCOMPARE( seq, QgsCoordinateSequence() << expected ); QCOMPARE( pl.nCoordinates(), 10 ); //add non-closed interior ring, should be closed automatically ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) - << QgsPoint( 0.1, 0.9 ) << QgsPoint( 0.9, 0.9 ) - << QgsPoint( 0.9, 0.1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.1, 0.9 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.9, 0.1 ) ); QVERIFY( !ring->isClosed() ); @@ -728,29 +612,20 @@ void TestQgsPolygon::addInteriorRingZM() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); pl.addInteriorRing( ring ); ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.1, 0.9 ) - << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.9, 0.1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.1, 0.9 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.9, 0.1 ) ); pl.addInteriorRing( ring ); //try adding an interior ring with z to a 2d polygon, z should be dropped ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); pl.addInteriorRing( ring ); QCOMPARE( pl.numInteriorRings(), 3 ); @@ -764,11 +639,7 @@ void TestQgsPolygon::addInteriorRingZM() //try adding an interior ring with m to a 2d polygon, m should be dropped ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.2, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.1, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.2, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0.1, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.1, 0, 1 ) ); pl.addInteriorRing( ring ); QCOMPARE( pl.numInteriorRings(), 4 ); @@ -783,11 +654,7 @@ void TestQgsPolygon::addInteriorRingZM() //addInteriorRing without z/m to PolygonZM pl.clear(); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1 ) ); pl.setExteriorRing( ext ); QVERIFY( pl.is3D() ); @@ -796,35 +663,25 @@ void TestQgsPolygon::addInteriorRingZM() //ring has no z ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 9 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 9 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 1, 9 ) << QgsPoint( Qgis::WkbType::PointM, 9, 9 ) << QgsPoint( Qgis::WkbType::PointM, 9, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1, 1 ) ); pl.addInteriorRing( ring ); QVERIFY( pl.interiorRing( 0 ) ); QVERIFY( pl.interiorRing( 0 )->is3D() ); QVERIFY( pl.interiorRing( 0 )->isMeasure() ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineStringZM ); - QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), - QgsPoint( Qgis::WkbType::PointZM, 1, 1, 0, 2 ) ); + QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 1, 0, 2 ) ); //ring has no m ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.2, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) ); pl.addInteriorRing( ring ); QVERIFY( pl.interiorRing( 1 ) ); QVERIFY( pl.interiorRing( 1 )->is3D() ); QVERIFY( pl.interiorRing( 1 )->isMeasure() ); QCOMPARE( pl.interiorRing( 1 )->wkbType(), Qgis::WkbType::LineStringZM ); - QCOMPARE( pl.interiorRing( 1 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), - QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.1, 1, 0 ) ); + QCOMPARE( pl.interiorRing( 1 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.1, 1, 0 ) ); } void TestQgsPolygon::setInteriorRings() @@ -832,13 +689,11 @@ void TestQgsPolygon::setInteriorRings() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext ); //add a list of rings with mixed types - QVector< QgsCurve * > rings; + QVector rings; QgsPointSequence pts; pts << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ) @@ -847,7 +702,7 @@ void TestQgsPolygon::setInteriorRings() << QgsPoint( Qgis::WkbType::PointZ, 0.2, 0.1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0.1, 0.1, 1 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[0] )->setPoints( pts ); + static_cast( rings[0] )->setPoints( pts ); pts = QgsPointSequence(); pts << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.3, 0, 1 ) @@ -856,7 +711,7 @@ void TestQgsPolygon::setInteriorRings() << QgsPoint( Qgis::WkbType::PointM, 0.4, 0.3, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0.3, 0.3, 0, 1 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[1] )->setPoints( pts ); + static_cast( rings[1] )->setPoints( pts ); //throw an empty ring in too rings << 0; @@ -865,7 +720,7 @@ void TestQgsPolygon::setInteriorRings() pts << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ); rings << new QgsCircularString(); - static_cast< QgsCircularString *>( rings[3] )->setPoints( QgsPointSequence() ); + static_cast( rings[3] )->setPoints( QgsPointSequence() ); pl.setInteriorRings( rings ); @@ -875,15 +730,13 @@ void TestQgsPolygon::setInteriorRings() QVERIFY( !pl.interiorRing( 0 )->is3D() ); QVERIFY( !pl.interiorRing( 0 )->isMeasure() ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), - QgsPoint( Qgis::WkbType::Point, 0.1, 0.1 ) ); + QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::Point, 0.1, 0.1 ) ); QVERIFY( pl.interiorRing( 1 ) ); QVERIFY( !pl.interiorRing( 1 )->is3D() ); QVERIFY( !pl.interiorRing( 1 )->isMeasure() ); QCOMPARE( pl.interiorRing( 1 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( pl.interiorRing( 1 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), - QgsPoint( Qgis::WkbType::Point, 0.3, 0.3 ) ); + QCOMPARE( pl.interiorRing( 1 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::Point, 0.3, 0.3 ) ); QVERIFY( pl.interiorRing( 2 ) ); QVERIFY( !pl.interiorRing( 2 )->is3D() ); @@ -897,7 +750,7 @@ void TestQgsPolygon::setInteriorRings() pts << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.8, 0.9 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.8, 0.8 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[0] )->setPoints( pts ); + static_cast( rings[0] )->setPoints( pts ); pl.setInteriorRings( rings ); @@ -906,8 +759,7 @@ void TestQgsPolygon::setInteriorRings() QVERIFY( !pl.interiorRing( 0 )->is3D() ); QVERIFY( !pl.interiorRing( 0 )->isMeasure() ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), - QgsPoint( Qgis::WkbType::Point, 0.8, 0.8 ) ); + QCOMPARE( pl.interiorRing( 0 )->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::Point, 0.8, 0.8 ) ); rings.clear(); pl.setInteriorRings( rings ); @@ -920,36 +772,34 @@ void TestQgsPolygon::removeInteriorRing() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext ); QVERIFY( !pl.removeInteriorRing( -1 ) ); QVERIFY( !pl.removeInteriorRing( 0 ) ); - QVector< QgsCurve * > rings; + QVector rings; QgsPointSequence pts; pts << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.1, 0.2 ) << QgsPoint( 0.2, 0.2 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.1, 0.1 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[0] )->setPoints( pts ); + static_cast( rings[0] )->setPoints( pts ); pts = QgsPointSequence(); pts << QgsPoint( 0.3, 0.3 ) << QgsPoint( 0.3, 0.4 ) << QgsPoint( 0.4, 0.4 ) << QgsPoint( 0.4, 0.3 ) << QgsPoint( 0.3, 0.3 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[1] )->setPoints( pts ); + static_cast( rings[1] )->setPoints( pts ); pts = QgsPointSequence(); pts << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.8, 0.9 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.8, 0.8 ); rings << new QgsLineString(); - static_cast< QgsLineString *>( rings[2] )->setPoints( pts ); + static_cast( rings[2] )->setPoints( pts ); pl.setInteriorRings( rings ); @@ -976,10 +826,7 @@ void TestQgsPolygon::removeInteriorRings() pl.removeInteriorRings(); QgsLineString ext; - ext.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); + ext.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); pl.setExteriorRing( ext.clone() ); pl.removeInteriorRings(); @@ -988,15 +835,11 @@ void TestQgsPolygon::removeInteriorRings() // add interior rings QgsLineString ring1; - ring1.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) - << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) - << QgsPoint( 0.1, 0.1 ) ); + ring1.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) << QgsPoint( 0.1, 0.1 ) ); QgsLineString ring2; - ring2.setPoints( QgsPointSequence() << QgsPoint( 0.6, 0.8 ) - << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) - << QgsPoint( 0.6, 0.8 ) ); + ring2.setPoints( QgsPointSequence() << QgsPoint( 0.6, 0.8 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.6, 0.8 ) ); - pl.setInteriorRings( QVector< QgsCurve * >() << ring1.clone() << ring2.clone() ); + pl.setInteriorRings( QVector() << ring1.clone() << ring2.clone() ); // remove ring with size filter pl.removeInteriorRings( 0.0075 ); @@ -1013,25 +856,16 @@ void TestQgsPolygon::removeInvalidRings() pl.removeInvalidRings(); // no crash QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); pl.setExteriorRing( ls.clone() ); pl.removeInvalidRings(); QCOMPARE( pl.asWkt(), QStringLiteral( "Polygon ZM ((11 2 3 4, 4 12 13 14, 11 12 13 14, 11 22 23 24, 11 2 3 4))" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); pl.removeInvalidRings(); @@ -1050,13 +884,10 @@ void TestQgsPolygon::insertVertex() QVERIFY( pl.isEmpty() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) - << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ls.clone() ); - auto ext = static_cast< const QgsLineString * >( pl.exteriorRing() ); + auto ext = static_cast( pl.exteriorRing() ); QVERIFY( pl.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 0.3, 0 ) ) ); QCOMPARE( pl.nCoordinates(), 8 ); @@ -1093,7 +924,7 @@ void TestQgsPolygon::insertVertex() // with interior ring pl.addInteriorRing( ls.clone() ); - auto ring = static_cast< const QgsLineString * >( pl.interiorRing( 0 ) ); + auto ring = static_cast( pl.interiorRing( 0 ) ); QCOMPARE( pl.nCoordinates(), 17 ); @@ -1141,11 +972,10 @@ void TestQgsPolygon::moveVertex() //valid polygon QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); pl.setExteriorRing( ls.clone() ); - auto ext = static_cast< const QgsLineString * >( pl.exteriorRing() ); + auto ext = static_cast( pl.exteriorRing() ); QVERIFY( pl.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( pl.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); @@ -1169,7 +999,7 @@ void TestQgsPolygon::moveVertex() // with interior ring pl.addInteriorRing( ls.clone() ); - auto ring = static_cast< const QgsLineString * >( pl.interiorRing( 0 ) ); + auto ring = static_cast( pl.interiorRing( 0 ) ); QVERIFY( pl.moveVertex( QgsVertexId( 0, 1, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( pl.moveVertex( QgsVertexId( 0, 1, 1 ), QgsPoint( 16.0, 17.0 ) ) ); @@ -1196,13 +1026,10 @@ void TestQgsPolygon::deleteVertex() //valid polygon QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) - << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); pl.setExteriorRing( ls.clone() ); - auto ext = static_cast< const QgsLineString * >( pl.exteriorRing() ); + auto ext = static_cast( pl.exteriorRing() ); //out of range vertices QVERIFY( !pl.deleteVertex( QgsVertexId( 0, 0, -1 ) ) ); @@ -1243,7 +1070,7 @@ void TestQgsPolygon::deleteVertex() pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); - auto ring = static_cast< const QgsLineString * >( pl.interiorRing( 0 ) ); + auto ring = static_cast( pl.interiorRing( 0 ) ); //out of range vertices QVERIFY( !pl.deleteVertex( QgsVertexId( 0, 1, -1 ) ) ); @@ -1289,8 +1116,7 @@ void TestQgsPolygon::deleteVertexRemoveRing() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext ); QVERIFY( pl.exteriorRing() ); @@ -1314,8 +1140,7 @@ void TestQgsPolygon::nextVertex() QVERIFY( !pl.nextVertex( v, pt ) ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); pl.setExteriorRing( ls.clone() ); v = QgsVertexId( 0, 0, 4 ); //out of range @@ -1350,8 +1175,7 @@ void TestQgsPolygon::nextVertex() QCOMPARE( pt, QgsPoint( 11, 12 ) ); // add interior ring - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) - << QgsPoint( 11, 22 ) << QgsPoint( 11, 12 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 11, 22 ) << QgsPoint( 11, 12 ) ); pl.addInteriorRing( ls.clone() ); v = QgsVertexId( 0, 1, 4 ); //out of range @@ -1401,9 +1225,7 @@ void TestQgsPolygon::vertexNumberFromVertexId() QCOMPARE( pl.vertexNumberFromVertexId( QgsVertexId( 0, 0, 0 ) ), -1 ); QCOMPARE( pl.vertexNumberFromVertexId( QgsVertexId( 0, 0, 1 ) ), -1 ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 2 ) << QgsPoint( 2, 2 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 1 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 2, 2 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 1 ) ); pl.setExteriorRing( ls.clone() ); QCOMPARE( pl.vertexNumberFromVertexId( QgsVertexId( -1, 0, 0 ) ), -1 ); @@ -1438,15 +1260,12 @@ void TestQgsPolygon::vertexAngle() { QgsPolygon pl; - ( void )pl.vertexAngle( QgsVertexId() ); //just want no crash - ( void )pl.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash - ( void )pl.vertexAngle( QgsVertexId( 0, 1, 0 ) ); //just want no crash + ( void ) pl.vertexAngle( QgsVertexId() ); //just want no crash + ( void ) pl.vertexAngle( QgsVertexId( 0, 0, 0 ) ); //just want no crash + ( void ) pl.vertexAngle( QgsVertexId( 0, 1, 0 ) ); //just want no crash QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) - << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ls.clone() ); QGSCOMPARENEAR( pl.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 2.35619, 0.00001 ); @@ -1476,21 +1295,19 @@ void TestQgsPolygon::adjacentVertices() QgsVertexId next( 4, 5, 6 ); pl.adjacentVertices( QgsVertexId( 0, 0, 0 ), previous, next ); - QCOMPARE( previous, QgsVertexId( ) ); - QCOMPARE( next, QgsVertexId( ) ); + QCOMPARE( previous, QgsVertexId() ); + QCOMPARE( next, QgsVertexId() ); pl.adjacentVertices( QgsVertexId( 0, 1, 0 ), previous, next ); - QCOMPARE( previous, QgsVertexId( ) ); - QCOMPARE( next, QgsVertexId( ) ); + QCOMPARE( previous, QgsVertexId() ); + QCOMPARE( next, QgsVertexId() ); pl.adjacentVertices( QgsVertexId( 0, 0, 1 ), previous, next ); - QCOMPARE( previous, QgsVertexId( ) ); - QCOMPARE( next, QgsVertexId( ) ); + QCOMPARE( previous, QgsVertexId() ); + QCOMPARE( next, QgsVertexId() ); QgsLineString *closedRing1 = new QgsLineString(); - closedRing1->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 2 ) << QgsPoint( 2, 2 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 1 ) ); + closedRing1->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 2, 2 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 1 ) ); pl.setExteriorRing( closedRing1 ); pl.adjacentVertices( QgsVertexId( 0, 0, 0 ), previous, next ); @@ -1514,8 +1331,8 @@ void TestQgsPolygon::adjacentVertices() QCOMPARE( next, QgsVertexId( 0, 0, 1 ) ); pl.adjacentVertices( QgsVertexId( 0, 1, 0 ), previous, next ); - QCOMPARE( previous, QgsVertexId( ) ); - QCOMPARE( next, QgsVertexId( ) ); + QCOMPARE( previous, QgsVertexId() ); + QCOMPARE( next, QgsVertexId() ); // part number should be retained pl.adjacentVertices( QgsVertexId( 1, 0, 0 ), previous, next ); @@ -1546,8 +1363,8 @@ void TestQgsPolygon::adjacentVertices() QCOMPARE( next, QgsVertexId( 0, 1, 1 ) ); pl.adjacentVertices( QgsVertexId( 0, 2, 0 ), previous, next ); - QCOMPARE( previous, QgsVertexId( ) ); - QCOMPARE( next, QgsVertexId( ) ); + QCOMPARE( previous, QgsVertexId() ); + QCOMPARE( next, QgsVertexId() ); } void TestQgsPolygon::removeDuplicateNodes() @@ -1557,37 +1374,27 @@ void TestQgsPolygon::removeDuplicateNodes() QVERIFY( !pl.removeDuplicateNodes() ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 11, 22 ) << QgsPoint( 11, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 22 ) << QgsPoint( 11, 2 ) ); pl.setExteriorRing( ls.clone() ); QVERIFY( !pl.removeDuplicateNodes() ); QCOMPARE( pl.asWkt(), QStringLiteral( "Polygon ((11 2, 11 12, 11 22, 11 2))" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) - << QgsPoint( 11, 12 ) << QgsPoint( 11, 22 ) - << QgsPoint( 11.01, 21.99 ) << QgsPoint( 10.99, 1.99 ) - << QgsPoint( 11, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 22 ) << QgsPoint( 11.01, 21.99 ) << QgsPoint( 10.99, 1.99 ) << QgsPoint( 11, 2 ) ); pl.setExteriorRing( ls.clone() ); QVERIFY( pl.removeDuplicateNodes( 0.02 ) ); QVERIFY( !pl.removeDuplicateNodes( 0.02 ) ); QCOMPARE( pl.asWkt( 2 ), QStringLiteral( "Polygon ((11 2, 11 12, 11 22, 11 2))" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) - << QgsPoint( 11, 12 ) << QgsPoint( 11, 22 ) - << QgsPoint( 11.01, 21.99 ) << QgsPoint( 10.99, 1.99 ) - << QgsPoint( 11, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 1.99 ) << QgsPoint( 11.02, 2.01 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 22 ) << QgsPoint( 11.01, 21.99 ) << QgsPoint( 10.99, 1.99 ) << QgsPoint( 11, 2 ) ); pl.setExteriorRing( ls.clone() ); QVERIFY( !pl.removeDuplicateNodes() ); QCOMPARE( pl.asWkt( 2 ), QStringLiteral( "Polygon ((11 2, 11.01 1.99, 11.02 2.01, 11 12, 11 22, 11.01 21.99, 10.99 1.99, 11 2))" ) ); // don't create degenerate rings - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 2.01 ) - << QgsPoint( 11, 2.01 ) << QgsPoint( 11, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11.01, 2.01 ) << QgsPoint( 11, 2.01 ) << QgsPoint( 11, 2 ) ); pl.addInteriorRing( ls.clone() ); QVERIFY( pl.removeDuplicateNodes( 0.02 ) ); @@ -1602,8 +1409,7 @@ void TestQgsPolygon::dropZValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::Polygon ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -1613,14 +1419,13 @@ void TestQgsPolygon::dropZValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::Polygon ); QCOMPARE( pl.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with z pl.clear(); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 11, 12, 13 ) - << QgsPoint( 1, 12, 23 ) << QgsPoint( 1, 2, 3 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 11, 12, 13 ) << QgsPoint( 1, 12, 23 ) << QgsPoint( 1, 2, 3 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -1630,16 +1435,13 @@ void TestQgsPolygon::dropZValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::Polygon ); QCOMPARE( pl.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm pl.clear(); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) - << QgsPoint( 11, 12, 13, 14 ) - << QgsPoint( 1, 12, 23, 24 ) - << QgsPoint( 1, 2, 3, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -1649,12 +1451,10 @@ void TestQgsPolygon::dropZValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::PolygonM ); QCOMPARE( pl.exteriorRing()->wkbType(), Qgis::WkbType::LineStringM ); - QCOMPARE( static_cast< const QgsLineString *>( pl.exteriorRing() )->pointN( 0 ), - QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( pl.exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineStringM ); - QCOMPARE( static_cast< const QgsLineString *>( pl.interiorRing( 0 ) )->pointN( 0 ), - QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); } void TestQgsPolygon::dropMValue() @@ -1665,8 +1465,7 @@ void TestQgsPolygon::dropMValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::Polygon ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -1676,16 +1475,13 @@ void TestQgsPolygon::dropMValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::Polygon ); QCOMPARE( pl.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with m pl.clear(); - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -1694,14 +1490,13 @@ void TestQgsPolygon::dropMValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::Polygon ); QCOMPARE( pl.exteriorRing()->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( static_cast< const QgsLineString *>( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm pl.clear(); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) - << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -1710,12 +1505,10 @@ void TestQgsPolygon::dropMValue() QCOMPARE( pl.wkbType(), Qgis::WkbType::PolygonZ ); QCOMPARE( pl.exteriorRing()->wkbType(), Qgis::WkbType::LineStringZ ); - QCOMPARE( static_cast< const QgsLineString *>( pl.exteriorRing() )->pointN( 0 ), - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( pl.exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); QCOMPARE( pl.interiorRing( 0 )->wkbType(), Qgis::WkbType::LineStringZ ); - QCOMPARE( static_cast< const QgsLineString *>( pl.interiorRing( 0 ) )->pointN( 0 ), - QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( pl.interiorRing( 0 ) )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); } void TestQgsPolygon::swapXy() @@ -1724,19 +1517,13 @@ void TestQgsPolygon::swapXy() pl.swapXy(); //no crash QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); pl.setExteriorRing( ls.clone() ); pl.swapXy(); QCOMPARE( pl.asWkt(), QStringLiteral( "Polygon ZM ((2 11 3 4, 12 11 13 14, 22 11 23 24, 2 11 3 4))" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); pl.swapXy(); @@ -1749,12 +1536,11 @@ void TestQgsPolygon::boundary() QVERIFY( !pl.boundary() ); QgsLineString ext; - ext.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); + ext.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext.clone() ); QgsAbstractGeometry *boundary = pl.boundary(); - QgsLineString *lineBoundary = dynamic_cast< QgsLineString * >( boundary ); + QgsLineString *lineBoundary = dynamic_cast( boundary ); QVERIFY( lineBoundary ); QCOMPARE( lineBoundary->numPoints(), 4 ); @@ -1771,23 +1557,19 @@ void TestQgsPolygon::boundary() // add interior rings QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) - << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) - << QgsPoint( 0.1, 0.1 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) << QgsPoint( 0.1, 0.1 ) ); QgsLineString ring2; - ring2.setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) - << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) - << QgsPoint( 0.8, 0.8 ) ); + ring2.setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) << QgsPoint( 0.8, 0.8 ) ); - pl.setInteriorRings( QVector< QgsCurve * >() << ring.clone() << ring2.clone() ); + pl.setInteriorRings( QVector() << ring.clone() << ring2.clone() ); boundary = pl.boundary(); - QgsMultiLineString *multiLineBoundary = dynamic_cast< QgsMultiLineString * >( boundary ); + QgsMultiLineString *multiLineBoundary = dynamic_cast( boundary ); QVERIFY( multiLineBoundary ); QCOMPARE( multiLineBoundary->numGeometries(), 3 ); - lineBoundary = qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) ); + lineBoundary = qgis::down_cast( multiLineBoundary->geometryN( 0 ) ); QCOMPARE( lineBoundary->numPoints(), 4 ); QCOMPARE( lineBoundary->xAt( 0 ), 0.0 ); QCOMPARE( lineBoundary->xAt( 1 ), 1.0 ); @@ -1798,7 +1580,7 @@ void TestQgsPolygon::boundary() QCOMPARE( lineBoundary->yAt( 2 ), 1.0 ); QCOMPARE( lineBoundary->yAt( 3 ), 0.0 ); - lineBoundary = qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) ); + lineBoundary = qgis::down_cast( multiLineBoundary->geometryN( 1 ) ); QCOMPARE( lineBoundary->numPoints(), 4 ); QCOMPARE( lineBoundary->xAt( 0 ), 0.1 ); QCOMPARE( lineBoundary->xAt( 1 ), 0.2 ); @@ -1809,7 +1591,7 @@ void TestQgsPolygon::boundary() QCOMPARE( lineBoundary->yAt( 2 ), 0.2 ); QCOMPARE( lineBoundary->yAt( 3 ), 0.1 ); - lineBoundary = qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) ); + lineBoundary = qgis::down_cast( multiLineBoundary->geometryN( 2 ) ); QCOMPARE( lineBoundary->numPoints(), 4 ); QCOMPARE( lineBoundary->xAt( 0 ), 0.8 ); QCOMPARE( lineBoundary->xAt( 1 ), 0.9 ); @@ -1820,18 +1602,15 @@ void TestQgsPolygon::boundary() QCOMPARE( lineBoundary->yAt( 2 ), 0.9 ); QCOMPARE( lineBoundary->yAt( 3 ), 0.8 ); - pl.setInteriorRings( QVector< QgsCurve * >() ); + pl.setInteriorRings( QVector() ); delete boundary; //test boundary with z - ext.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); + ext.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); pl.setExteriorRing( ext.clone() ); boundary = pl.boundary(); - lineBoundary = qgis::down_cast< QgsLineString * >( boundary ); + lineBoundary = qgis::down_cast( boundary ); QVERIFY( lineBoundary ); QCOMPARE( lineBoundary->numPoints(), 4 ); @@ -1848,12 +1627,10 @@ void TestQgsPolygon::pointDistanceToBoundary() { QgsPolygon pl; // no meaning, but let's not crash - ( void )pl.pointDistanceToBoundary( 0, 0 ); + ( void ) pl.pointDistanceToBoundary( 0, 0 ); QgsLineString ext; - ext.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) - << QgsPoint( 0, 1 ) << QgsPoint( 0, 0 ) ); + ext.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 1 ) << QgsPoint( 0, 0 ) ); pl.setExteriorRing( ext.clone() ); QGSCOMPARENEAR( pl.pointDistanceToBoundary( 0, 0.5 ), 0.0, 0.0000000001 ); @@ -1862,10 +1639,8 @@ void TestQgsPolygon::pointDistanceToBoundary() // with a ring QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) - << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.6 ) - << QgsPoint( 0.1, 0.6 ) << QgsPoint( 0.1, 0.1 ) ); - pl.setInteriorRings( QVector< QgsCurve * >() << ring.clone() ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.6 ) << QgsPoint( 0.1, 0.6 ) << QgsPoint( 0.1, 0.1 ) ); + pl.setInteriorRings( QVector() << ring.clone() ); QGSCOMPARENEAR( pl.pointDistanceToBoundary( 0, 0.5 ), 0.0, 0.0000000001 ); QGSCOMPARENEAR( pl.pointDistanceToBoundary( 0.1, 0.5 ), 0.0, 0.0000000001 ); @@ -1882,12 +1657,10 @@ void TestQgsPolygon::closestSegment() int leftOf = 0; QgsPolygon pl; - ( void )pl.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty polygon, just want no crash + ( void ) pl.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty polygon, just want no crash QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) - << QgsPoint( 5, 10 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) << QgsPoint( 5, 10 ) ); pl.setExteriorRing( ls.clone() ); QGSCOMPARENEAR( pl.closestSegment( QgsPoint( 4, 11 ), pt, v, &leftOf ), 1.0, 0.0001 ); @@ -1896,7 +1669,7 @@ void TestQgsPolygon::closestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( pl.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( pl.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -1926,8 +1699,7 @@ void TestQgsPolygon::closestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 2 ) ); // with interior ring - ls.setPoints( QgsPointSequence() << QgsPoint( 6, 11.5 ) << QgsPoint( 6.5, 12 ) - << QgsPoint( 6, 13 ) << QgsPoint( 6, 11.5 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 6, 11.5 ) << QgsPoint( 6.5, 12 ) << QgsPoint( 6, 13 ) << QgsPoint( 6, 11.5 ) ); pl.addInteriorRing( ls.clone() ); QGSCOMPARENEAR( pl.closestSegment( QgsPoint( 4, 11 ), pt, v, &leftOf ), 1.0, 0.0001 ); @@ -1936,7 +1708,7 @@ void TestQgsPolygon::closestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( pl.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( pl.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -1978,9 +1750,7 @@ void TestQgsPolygon::segmentLength() QCOMPARE( pl.segmentLength( QgsVertexId( 0, 1, 0 ) ), 0.0 ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) - << QgsPoint( 111, 2 ) << QgsPoint( 11, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 111, 12 ) << QgsPoint( 111, 2 ) << QgsPoint( 11, 2 ) ); pl.setExteriorRing( ls.clone() ); QCOMPARE( pl.segmentLength( QgsVertexId() ), 0.0 ); @@ -1999,9 +1769,7 @@ void TestQgsPolygon::segmentLength() QCOMPARE( pl.segmentLength( QgsVertexId( 1, 1, 1 ) ), 0.0 ); // add interior ring - ls.setPoints( QgsPointSequence() << QgsPoint( 30, 6 ) - << QgsPoint( 34, 6 ) << QgsPoint( 34, 8 ) - << QgsPoint( 30, 8 ) << QgsPoint( 30, 6 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 30, 6 ) << QgsPoint( 34, 6 ) << QgsPoint( 34, 8 ) << QgsPoint( 30, 8 ) << QgsPoint( 30, 6 ) ); pl.addInteriorRing( ls.clone() ); QCOMPARE( pl.segmentLength( QgsVertexId() ), 0.0 ); @@ -2104,8 +1872,7 @@ void TestQgsPolygon::boundingBoxIntersects() QVERIFY( !pl.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 0, 2 ) << QgsPoint( 4, 2 ) - << QgsPoint( 4, 4 ) << QgsPoint( 0, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 0, 2 ) << QgsPoint( 4, 2 ) << QgsPoint( 4, 4 ) << QgsPoint( 0, 2 ) ); pl.setExteriorRing( ls.clone() ); QVERIFY( pl.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); @@ -2117,8 +1884,7 @@ void TestQgsPolygon::boundingBoxIntersects() QCOMPARE( pl.boundingBox(), QgsRectangle( 0, 2, 4, 4 ) ); // clear cache - ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2 ) << QgsPoint( 14, 2 ) - << QgsPoint( 15, 4 ) << QgsPoint( 10, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2 ) << QgsPoint( 14, 2 ) << QgsPoint( 15, 4 ) << QgsPoint( 10, 2 ) ); pl.setExteriorRing( ls.clone() ); QVERIFY( !pl.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); @@ -2128,8 +1894,7 @@ void TestQgsPolygon::boundingBoxIntersects() // technically invalid -- the interior ring is outside the exterior, but we want boundingBoxIntersects to be tolerant to // cases like this! - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 4, 2 ) - << QgsPoint( 5, 4 ) << QgsPoint( 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 4, 2 ) << QgsPoint( 5, 4 ) << QgsPoint( 1, 2 ) ); pl.addInteriorRing( ls.clone() ); QVERIFY( pl.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); @@ -2141,8 +1906,7 @@ void TestQgsPolygon::boundingBoxIntersects() void TestQgsPolygon::filterVertices() { - auto filter = []( const QgsPoint & point )-> bool - { + auto filter = []( const QgsPoint &point ) -> bool { return point.x() > 5; }; @@ -2150,29 +1914,17 @@ void TestQgsPolygon::filterVertices() pl.filterVertices( filter ); // no crash QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); pl.setExteriorRing( ls.clone() ); pl.filterVertices( filter ); QCOMPARE( pl.asWkt(), QStringLiteral( "Polygon ZM ((11 2 3 4, 11 12 13 14, 11 22 23 24, 11 2 3 4))" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); pl.filterVertices( filter ); @@ -2182,8 +1934,7 @@ void TestQgsPolygon::filterVertices() void TestQgsPolygon::transformVertices() { - auto transform = []( const QgsPoint & point )-> QgsPoint - { + auto transform = []( const QgsPoint &point ) -> QgsPoint { return QgsPoint( point.x() + 2, point.y() + 3, point.z() + 4, point.m() + 5 ); }; @@ -2191,28 +1942,16 @@ void TestQgsPolygon::transformVertices() pl.transformVertices( transform ); // no crash QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); pl.setExteriorRing( ls.clone() ); pl.transformVertices( transform ); QCOMPARE( pl.asWkt(), QStringLiteral( "Polygon ZM ((13 5 7 9, 6 15 17 19, 13 15 17 19, 13 25 27 29, 13 5 7 9))" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); pl.transformVertices( transform ); @@ -2228,28 +1967,16 @@ void TestQgsPolygon::transformWithClass() QVERIFY( pl.transform( &transformer ) ); QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11, 22, 23, 24, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 3, 4, Qgis::WkbType::PointZM ) ); pl.setExteriorRing( ls.clone() ); QVERIFY( pl.transform( &transformer ) ); QCOMPARE( pl.asWkt( 2 ), QStringLiteral( "Polygon ZM ((33 16 8 3, 12 26 18 13, 33 26 18 13, 33 36 28 23, 33 16 8 3))" ) ); - ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 4, 12, 13, 14, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 10, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); - ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) - << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) - << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) - << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) << QgsPoint( 11.01, 2.01, 15, 16, Qgis::WkbType::PointZM ) << QgsPoint( 11, 2.01, 25, 26, Qgis::WkbType::PointZM ) << QgsPoint( 1, 2, 5, 6, Qgis::WkbType::PointZM ) ); pl.addInteriorRing( ls.clone() ); QVERIFY( pl.transform( &transformer ) ); @@ -2269,23 +1996,20 @@ void TestQgsPolygon::transform2D() QgsPolygon pl; QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) - << QgsPoint( 6274985, -3526584 ) - << QgsPoint( 6474985, -3526584 ) - << QgsPoint( 6374985, -3626584 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( 6374985, -3626584 ) << QgsPoint( 6274985, -3526584 ) << QgsPoint( 6474985, -3526584 ) << QgsPoint( 6374985, -3626584 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); pl.transform( tr, Qgis::TransformDirection::Forward ); - const QgsLineString *ext = static_cast< const QgsLineString * >( pl.exteriorRing() ); + const QgsLineString *ext = static_cast( pl.exteriorRing() ); QGSCOMPARENEAR( ext->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ext->pointN( 0 ).y(), -39.724, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( ext->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( ext->pointN( 1 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( ext->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( ext->pointN( 2 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( ext->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ext->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().xMinimum(), 174.581448, 0.001 ); @@ -2293,15 +2017,15 @@ void TestQgsPolygon::transform2D() QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().xMaximum(), 176.959, 0.001 ); QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().yMaximum(), -38.7999, 0.001 ); - const QgsLineString *ring = static_cast< const QgsLineString * >( pl.interiorRing( 0 ) ); + const QgsLineString *ring = static_cast( pl.interiorRing( 0 ) ); QGSCOMPARENEAR( ring->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ring->pointN( 0 ).y(), -39.724, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( ring->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( ring->pointN( 1 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( ring->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( ring->pointN( 2 ).y(), -38.7999, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( ring->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ring->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( pl.interiorRing( 0 )->boundingBox().xMinimum(), 174.581448, 0.001 ); @@ -2320,30 +2044,27 @@ void TestQgsPolygon::transform3D() QgsPolygon pl; QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); pl.transform( tr, Qgis::TransformDirection::Forward ); - const QgsLineString *ext = static_cast< const QgsLineString * >( pl.exteriorRing() ); + const QgsLineString *ext = static_cast( pl.exteriorRing() ); QGSCOMPARENEAR( ext->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ext->pointN( 0 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( ext->pointN( 0 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 0 ).m(), 2.0, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( ext->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( ext->pointN( 1 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( ext->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( ext->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( ext->pointN( 2 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( ext->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( ext->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ext->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( ext->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 3 ).m(), 2.0, 0.001 ); @@ -2353,21 +2074,21 @@ void TestQgsPolygon::transform3D() QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().xMaximum(), 176.959, 0.001 ); QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().yMaximum(), -38.7999, 0.001 ); - const QgsLineString *ring = static_cast< const QgsLineString * >( pl.interiorRing( 0 ) ); + const QgsLineString *ring = static_cast( pl.interiorRing( 0 ) ); QGSCOMPARENEAR( ring->pointN( 0 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ring->pointN( 0 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( ring->pointN( 0 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 0 ).m(), 2.0, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 1 ).x(), 174.581448, 0.001 ); + QGSCOMPARENEAR( ring->pointN( 1 ).x(), 174.581448, 0.001 ); QGSCOMPARENEAR( ring->pointN( 1 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( ring->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 2 ).x(), 176.958633, 0.001 ); + QGSCOMPARENEAR( ring->pointN( 2 ).x(), 176.958633, 0.001 ); QGSCOMPARENEAR( ring->pointN( 2 ).y(), -38.7999, 0.001 ); QGSCOMPARENEAR( ring->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 3 ).x(), 175.771, 0.001 ); + QGSCOMPARENEAR( ring->pointN( 3 ).x(), 175.771, 0.001 ); QGSCOMPARENEAR( ring->pointN( 3 ).y(), -39.724, 0.001 ); QGSCOMPARENEAR( ring->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 3 ).m(), 2.0, 0.001 ); @@ -2376,7 +2097,6 @@ void TestQgsPolygon::transform3D() QGSCOMPARENEAR( pl.interiorRing( 0 )->boundingBox().yMinimum(), -39.724, 0.001 ); QGSCOMPARENEAR( pl.interiorRing( 0 )->boundingBox().xMaximum(), 176.959, 0.001 ); QGSCOMPARENEAR( pl.interiorRing( 0 )->boundingBox().yMaximum(), -38.7999, 0.001 ); - } void TestQgsPolygon::transformReverse() @@ -2389,17 +2109,14 @@ void TestQgsPolygon::transformReverse() QgsPolygon pl; QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); pl.transform( tr, Qgis::TransformDirection::Forward ); pl.transform( tr, Qgis::TransformDirection::Reverse ); - const QgsLineString *ext = static_cast< const QgsLineString * >( pl.exteriorRing() ); + const QgsLineString *ext = static_cast( pl.exteriorRing() ); QGSCOMPARENEAR( ext->pointN( 0 ).x(), 6374984, 100 ); QGSCOMPARENEAR( ext->pointN( 0 ).y(), -3626584, 100 ); @@ -2409,11 +2126,11 @@ void TestQgsPolygon::transformReverse() QGSCOMPARENEAR( ext->pointN( 1 ).y(), -3526584, 100 ); QGSCOMPARENEAR( ext->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 2 ).x(), 6474984, 100 ); + QGSCOMPARENEAR( ext->pointN( 2 ).x(), 6474984, 100 ); QGSCOMPARENEAR( ext->pointN( 2 ).y(), -3526584, 100 ); QGSCOMPARENEAR( ext->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 3 ).x(), 6374984, 100 ); + QGSCOMPARENEAR( ext->pointN( 3 ).x(), 6374984, 100 ); QGSCOMPARENEAR( ext->pointN( 3 ).y(), -3626584, 100 ); QGSCOMPARENEAR( ext->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 3 ).m(), 2.0, 0.001 ); @@ -2422,7 +2139,7 @@ void TestQgsPolygon::transformReverse() QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().xMaximum(), 6474984, 100 ); QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().yMaximum(), -3526584, 100 ); - const QgsLineString *ring = static_cast< const QgsLineString * >( pl.interiorRing( 0 ) ); + const QgsLineString *ring = static_cast( pl.interiorRing( 0 ) ); QGSCOMPARENEAR( ring->pointN( 0 ).x(), 6374984, 100 ); QGSCOMPARENEAR( ring->pointN( 0 ).y(), -3626584, 100 ); @@ -2432,11 +2149,11 @@ void TestQgsPolygon::transformReverse() QGSCOMPARENEAR( ring->pointN( 1 ).y(), -3526584, 100 ); QGSCOMPARENEAR( ring->pointN( 1 ).z(), 3.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 1 ).m(), 4.0, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 2 ).x(), 6474984, 100 ); + QGSCOMPARENEAR( ring->pointN( 2 ).x(), 6474984, 100 ); QGSCOMPARENEAR( ring->pointN( 2 ).y(), -3526584, 100 ); QGSCOMPARENEAR( ring->pointN( 2 ).z(), 5.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 2 ).m(), 6.0, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 3 ).x(), 6374984, 100 ); + QGSCOMPARENEAR( ring->pointN( 3 ).x(), 6374984, 100 ); QGSCOMPARENEAR( ring->pointN( 3 ).y(), -3626584, 100 ); QGSCOMPARENEAR( ring->pointN( 3 ).z(), 1.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 3 ).m(), 2.0, 0.001 ); @@ -2456,10 +2173,7 @@ void TestQgsPolygon::transformOldVersion() QgsPolygon pl; QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 6274985, -3526584, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6474985, -3526584, 5, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 6374985, -3626584, 1, 2 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); @@ -2496,16 +2210,13 @@ void TestQgsPolygon::Qtransform() QgsPolygon pl; QgsLineString ls; - ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 12, 23, 24 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); + ls.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 11, 12, 13, 14 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 12, 23, 24 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); pl.setExteriorRing( ls.clone() ); pl.addInteriorRing( ls.clone() ); pl.transform( qtr, 2, 3, 4, 5 ); - const QgsLineString *ext = static_cast< const QgsLineString * >( pl.exteriorRing() ); + const QgsLineString *ext = static_cast( pl.exteriorRing() ); QGSCOMPARENEAR( ext->pointN( 0 ).x(), 2, 100 ); QGSCOMPARENEAR( ext->pointN( 0 ).y(), 6, 100 ); @@ -2515,7 +2226,7 @@ void TestQgsPolygon::Qtransform() QGSCOMPARENEAR( ext->pointN( 1 ).y(), 36, 100 ); QGSCOMPARENEAR( ext->pointN( 1 ).z(), 41.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 1 ).m(), 74.0, 0.001 ); - QGSCOMPARENEAR( ext->pointN( 2 ).x(), 2, 100 ); + QGSCOMPARENEAR( ext->pointN( 2 ).x(), 2, 100 ); QGSCOMPARENEAR( ext->pointN( 2 ).y(), 36, 100 ); QGSCOMPARENEAR( ext->pointN( 2 ).z(), 71.0, 0.001 ); QGSCOMPARENEAR( ext->pointN( 2 ).m(), 124.0, 0.001 ); @@ -2529,7 +2240,7 @@ void TestQgsPolygon::Qtransform() QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().xMaximum(), 22, 0.001 ); QGSCOMPARENEAR( pl.exteriorRing()->boundingBox().yMaximum(), 36, 0.001 ); - const QgsLineString *ring = static_cast< const QgsLineString * >( pl.interiorRing( 0 ) ); + const QgsLineString *ring = static_cast( pl.interiorRing( 0 ) ); QGSCOMPARENEAR( ring->pointN( 0 ).x(), 2, 100 ); QGSCOMPARENEAR( ring->pointN( 0 ).y(), 6, 100 ); @@ -2539,7 +2250,7 @@ void TestQgsPolygon::Qtransform() QGSCOMPARENEAR( ring->pointN( 1 ).y(), 36, 100 ); QGSCOMPARENEAR( ring->pointN( 1 ).z(), 41.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 1 ).m(), 74.0, 0.001 ); - QGSCOMPARENEAR( ring->pointN( 2 ).x(), 2, 100 ); + QGSCOMPARENEAR( ring->pointN( 2 ).x(), 2, 100 ); QGSCOMPARENEAR( ring->pointN( 2 ).y(), 36, 100 ); QGSCOMPARENEAR( ring->pointN( 2 ).z(), 71.0, 0.001 ); QGSCOMPARENEAR( ring->pointN( 2 ).m(), 124.0, 0.001 ); @@ -2576,27 +2287,19 @@ void TestQgsPolygon::toPolygon() QgsPolygon pl; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); pl.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); pl.addInteriorRing( ring ); //surfaceToPolygon - should be identical given polygon has no curves - std::unique_ptr< QgsPolygon > surface( pl.surfaceToPolygon() ); + std::unique_ptr surface( pl.surfaceToPolygon() ); QCOMPARE( *surface, pl ); //toPolygon - should be identical given polygon has no curves - std::unique_ptr< QgsPolygon > toP( pl.toPolygon() ); + std::unique_ptr toP( pl.toPolygon() ); QCOMPARE( *toP, pl ); } @@ -2604,30 +2307,22 @@ void TestQgsPolygon::toCurveType() { QgsPolygon pl; // empty - std::unique_ptr< QgsCurvePolygon > curveType( pl.toCurveType() ); + std::unique_ptr curveType( pl.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::CurvePolygon ); QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); pl.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); pl.addInteriorRing( ring ); curveType.reset( pl.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::CurvePolygonZM ); - const QgsLineString *exteriorRing = static_cast< const QgsLineString * >( curveType->exteriorRing() ); + const QgsLineString *exteriorRing = static_cast( curveType->exteriorRing() ); QCOMPARE( exteriorRing->numPoints(), 5 ); QCOMPARE( exteriorRing->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) ); QCOMPARE( exteriorRing->vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) ); @@ -2637,7 +2332,7 @@ void TestQgsPolygon::toCurveType() QCOMPARE( curveType->numInteriorRings(), 1 ); - const QgsLineString *interiorRing = static_cast< const QgsLineString * >( curveType->interiorRing( 0 ) ); + const QgsLineString *interiorRing = static_cast( curveType->interiorRing( 0 ) ); QCOMPARE( interiorRing->numPoints(), 5 ); QCOMPARE( interiorRing->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) ); QCOMPARE( interiorRing->vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) ); @@ -2650,19 +2345,11 @@ void TestQgsPolygon::toFromWkb() { QgsPolygon pl1; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); pl1.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); pl1.addInteriorRing( ring ); QByteArray wkb = pl1.asWkb(); @@ -2680,19 +2367,11 @@ void TestQgsPolygon::toFromWkbZM() //PolygonZ QgsPolygon pl1; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); pl1.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); pl1.addInteriorRing( ring ); QByteArray wkb = pl1.asWkb(); @@ -2708,19 +2387,11 @@ void TestQgsPolygon::toFromWkbZM() pl2.clear(); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 10, 0, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); pl1.setExteriorRing( ext ); ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 9, 0, 2 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 9, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 9, 1, 0, 4 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1, 9, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 9, 9, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 9, 1, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 1, 1, 0, 1 ) ); pl1.addInteriorRing( ring ); wkb = pl1.asWkb(); @@ -2734,19 +2405,11 @@ void TestQgsPolygon::toFromWkbZM() pl2.clear(); ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); pl1.setExteriorRing( ext ); ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); pl1.addInteriorRing( ring ); wkb = pl1.asWkb(); @@ -2760,19 +2423,11 @@ void TestQgsPolygon::toFromWkb25D() { QgsPolygon pl1; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 10, 2 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 10, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 10, 0, 4 ) - << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 10, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::Point25D, 0, 0, 1 ) ); pl1.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 1, 1 ) - << QgsPoint( Qgis::WkbType::Point25D, 1, 9, 2 ) - << QgsPoint( Qgis::WkbType::Point25D, 9, 9, 3 ) - << QgsPoint( Qgis::WkbType::Point25D, 9, 1, 4 ) - << QgsPoint( Qgis::WkbType::Point25D, 1, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point25D, 1, 1, 1 ) << QgsPoint( Qgis::WkbType::Point25D, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::Point25D, 9, 9, 3 ) << QgsPoint( Qgis::WkbType::Point25D, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::Point25D, 1, 1, 1 ) ); pl1.addInteriorRing( ring ); QgsPolygon pl2; @@ -2803,19 +2458,11 @@ void TestQgsPolygon::toFromWKT() QgsPolygon pl1; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); pl1.setExteriorRing( ext ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); pl1.addInteriorRing( ring ); QString wkt = pl1.asWkt(); @@ -2837,18 +2484,10 @@ void TestQgsPolygon::toFromWKT() // Test WKT export with compound curve QgsPolygon pl3; QgsLineString *ext3 = new QgsLineString(); - ext3->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); + ext3->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); pl3.setExteriorRing( ext3 ); QgsLineString *ring3 = new QgsLineString(); - ring3->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); + ring3->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); QgsCompoundCurve *compound = new QgsCompoundCurve(); compound->addCurve( ring3 ); pl3.addInteriorRing( compound ); @@ -2858,11 +2497,7 @@ void TestQgsPolygon::toFromWKT() // Test WKT export with empty interior ring QgsPolygon pl4; QgsLineString *ext4 = new QgsLineString(); - ext4->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); + ext4->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); pl4.setExteriorRing( ext4 ); pl4.addInteriorRing( new QgsLineString() ); wkt = pl4.asWkt(); @@ -2874,11 +2509,7 @@ void TestQgsPolygon::exportImport() //as JSON QgsPolygon exportPolygon; QgsLineString *ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 10 ) - << QgsPoint( Qgis::WkbType::Point, 10, 0 ) - << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 0, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 10 ) << QgsPoint( Qgis::WkbType::Point, 10, 0 ) << QgsPoint( Qgis::WkbType::Point, 0, 0 ) ); exportPolygon.setExteriorRing( ext ); // GML document for compare @@ -2903,11 +2534,7 @@ void TestQgsPolygon::exportImport() QCOMPARE( exportPolygon.asJson(), expectedSimpleJson ); QgsLineString *ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 9 ) - << QgsPoint( Qgis::WkbType::Point, 9, 1 ) - << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 1, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 9 ) << QgsPoint( Qgis::WkbType::Point, 9, 1 ) << QgsPoint( Qgis::WkbType::Point, 1, 1 ) ); exportPolygon.addInteriorRing( ring ); QString expectedJson( QStringLiteral( "{\"coordinates\":[[[0.0,0.0],[0.0,10.0],[10.0,10.0],[10.0,0.0],[0.0,0.0]],[[1.0,1.0],[1.0,9.0],[9.0,9.0],[9.0,1.0],[1.0,1.0]]],\"type\":\"Polygon\"}" ) ); @@ -2915,19 +2542,11 @@ void TestQgsPolygon::exportImport() QgsPolygon exportPolygonFloat; ext = new QgsLineString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 100 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 100 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 10 / 9.0 ) - << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 100 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 100 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 100 / 9.0, 10 / 9.0 ) << QgsPoint( Qgis::WkbType::Point, 10 / 9.0, 10 / 9.0 ) ); exportPolygonFloat.setExteriorRing( ext ); ring = new QgsLineString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 4 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 4 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 2 / 3.0 ) - << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) ); + ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 4 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 4 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 4 / 3.0, 2 / 3.0 ) << QgsPoint( Qgis::WkbType::Point, 2 / 3.0, 2 / 3.0 ) ); exportPolygonFloat.addInteriorRing( ring ); QString expectedJsonPrec3( QStringLiteral( "{\"coordinates\":[[[1.111,1.111],[1.111,11.111],[11.111,11.111],[11.111,1.111],[1.111,1.111]],[[0.667,0.667],[0.667,1.333],[1.333,1.333],[1.333,0.667],[0.667,0.667]]],\"type\":\"Polygon\"}" ) ); diff --git a/tests/src/core/geometry/testqgspolyhedralsurface.cpp b/tests/src/core/geometry/testqgspolyhedralsurface.cpp index bb898c29c57b..6a1e96c7bc2d 100644 --- a/tests/src/core/geometry/testqgspolyhedralsurface.cpp +++ b/tests/src/core/geometry/testqgspolyhedralsurface.cpp @@ -26,7 +26,7 @@ #include "qgsvertexid.h" #include "testgeometryutils.h" -class TestQgsPolyhedralSurface: public QObject +class TestQgsPolyhedralSurface : public QObject { Q_OBJECT @@ -88,10 +88,7 @@ void TestQgsPolyhedralSurface::testConstructor() std::unique_ptr multiPolygon = std::make_unique(); QgsPolygon part; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) - << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) - << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ) ; + ring.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 5, 50, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 6, 61, 3, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 71, 4, 15 ) << QgsPoint( Qgis::WkbType::PointZM, 5, 71, 4, 6 ) ); part.setExteriorRing( ring.clone() ); multiPolygon->addGeometry( part.clone() ); QgsPolyhedralSurface polySurface( multiPolygon.get() ); @@ -125,14 +122,10 @@ void TestQgsPolyhedralSurface::testCopyConstructor() // add a patch to polySurface1 QgsPolygon patch; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); patch.setExteriorRing( patchExterior ); QgsLineString *patchInteriorRing1 = new QgsLineString(); - patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); patch.addInteriorRing( patchInteriorRing1 ); polySurface1.addPatch( patch.clone() ); QCOMPARE( polySurface1.numPatches(), 1 ); @@ -153,14 +146,10 @@ void TestQgsPolyhedralSurface::testClear() QgsPolygon *patch = new QgsPolygon; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) - << QgsPoint( 0, 10, 1 ) << QgsPoint( 10, 10, 1 ) - << QgsPoint( 10, 0, 1 ) << QgsPoint( 0, 0, 1 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0, 10, 1 ) << QgsPoint( 10, 10, 1 ) << QgsPoint( 10, 0, 1 ) << QgsPoint( 0, 0, 1 ) ); patch->setExteriorRing( patchExterior ); QgsLineString *patchInteriorRing1 = new QgsLineString(); - patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 1, 1, 1 ) - << QgsPoint( 1, 9, 1 ) << QgsPoint( 9, 9, 1 ) - << QgsPoint( 9, 1, 1 ) << QgsPoint( 1, 1, 1 ) ); + patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 1, 1, 1 ) << QgsPoint( 1, 9, 1 ) << QgsPoint( 9, 9, 1 ) << QgsPoint( 9, 1, 1 ) << QgsPoint( 1, 1, 1 ) ); patch->addInteriorRing( patchInteriorRing1 ); polySurface.addPatch( patch ); @@ -188,19 +177,15 @@ void TestQgsPolyhedralSurface::testClone() { QgsPolyhedralSurface polySurface; - std::unique_ptr< QgsPolyhedralSurface >cloned( polySurface.clone() ); + std::unique_ptr cloned( polySurface.clone() ); QCOMPARE( polySurface, *cloned ); QgsPolygon *patch = new QgsPolygon(); QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 4, 4 ) - << QgsPoint( 6, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 4 ) << QgsPoint( 4, 4 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 4, 4 ) << QgsPoint( 6, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 4 ) << QgsPoint( 4, 4 ) ); patch->setExteriorRing( patchExterior ); QgsLineString *patchInteriorRing1 = new QgsLineString(); - patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 7, 5 ) - << QgsPoint( 8, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 6 ) << QgsPoint( 7, 5 ) ); + patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 7, 5 ) << QgsPoint( 8, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 6 ) << QgsPoint( 7, 5 ) ); patch->addInteriorRing( patchInteriorRing1 ); polySurface.addPatch( patch ); @@ -217,12 +202,8 @@ void TestQgsPolyhedralSurface::testEquality() QVERIFY( !( polySurface1 != polySurface2 ) ); patch = new QgsPolygon(); - QgsLineString patchExterior1( QVector() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); - QgsLineString patchInteriorRing1( QVector< QgsPoint >() << QgsPoint( 1, 1 ) - << QgsPoint( 2, 1 ) << QgsPoint( 2, 2 ) - << QgsPoint( 1, 2 ) << QgsPoint( 1, 1 ) ); + QgsLineString patchExterior1( QVector() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + QgsLineString patchInteriorRing1( QVector() << QgsPoint( 1, 1 ) << QgsPoint( 2, 1 ) << QgsPoint( 2, 2 ) << QgsPoint( 1, 2 ) << QgsPoint( 1, 1 ) ); patch->setExteriorRing( patchExterior1.clone() ); patch->addInteriorRing( patchInteriorRing1.clone() ); polySurface1.addPatch( patch ); @@ -237,12 +218,8 @@ void TestQgsPolyhedralSurface::testEquality() QVERIFY( !( polySurface1 != polySurface2 ) ); patch = new QgsPolygon(); - QgsLineString patchExterior2( QVector() << QgsPoint( 10, 0 ) - << QgsPoint( 10, 10 ) << QgsPoint( 15, 10 ) - << QgsPoint( 15, 0 ) << QgsPoint( 10, 0 ) ); - QgsLineString patchInteriorRing2( QVector< QgsPoint >() << QgsPoint( 13, 1 ) - << QgsPoint( 14, 1 ) << QgsPoint( 14, 2 ) - << QgsPoint( 13, 2 ) << QgsPoint( 13, 1 ) ); + QgsLineString patchExterior2( QVector() << QgsPoint( 10, 0 ) << QgsPoint( 10, 10 ) << QgsPoint( 15, 10 ) << QgsPoint( 15, 0 ) << QgsPoint( 10, 0 ) ); + QgsLineString patchInteriorRing2( QVector() << QgsPoint( 13, 1 ) << QgsPoint( 14, 1 ) << QgsPoint( 14, 2 ) << QgsPoint( 13, 2 ) << QgsPoint( 13, 1 ) ); patch->setExteriorRing( patchExterior2.clone() ); patch->addInteriorRing( patchInteriorRing2.clone() ); polySurface2.addPatch( patch ); @@ -268,14 +245,10 @@ void TestQgsPolyhedralSurface::testAddPatch() QgsPolygon *patch = new QgsPolygon(); QgsLineString patchExterior; - patchExterior.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + patchExterior.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); patch->setExteriorRing( patchExterior.clone() ); QgsLineString patchInteriorRing; - patchInteriorRing.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) - << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + patchInteriorRing.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); patch->addInteriorRing( patchInteriorRing.clone() ); polySurface.addPatch( patch ); @@ -288,14 +261,10 @@ void TestQgsPolyhedralSurface::testAddPatch() // try adding a patch with z to a 2d polyhedral surface, z should be dropped patch = new QgsPolygon(); QgsLineString patchExteriorZ; - patchExteriorZ.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1 ) - << QgsPoint( 0, 10, 1 ) << QgsPoint( 10, 10, 1 ) - << QgsPoint( 10, 0, 1 ) << QgsPoint( 0, 0, 1 ) ); + patchExteriorZ.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1 ) << QgsPoint( 0, 10, 1 ) << QgsPoint( 10, 10, 1 ) << QgsPoint( 10, 0, 1 ) << QgsPoint( 0, 0, 1 ) ); patch->setExteriorRing( patchExteriorZ.clone() ); QgsLineString patchInteriorRingZ; - patchInteriorRingZ.setPoints( QgsPointSequence() << QgsPoint( 1, 1, 1 ) - << QgsPoint( 1, 9, 1 ) << QgsPoint( 9, 9, 1 ) - << QgsPoint( 9, 1, 1 ) << QgsPoint( 1, 1, 1 ) ); + patchInteriorRingZ.setPoints( QgsPointSequence() << QgsPoint( 1, 1, 1 ) << QgsPoint( 1, 9, 1 ) << QgsPoint( 9, 9, 1 ) << QgsPoint( 9, 1, 1 ) << QgsPoint( 1, 1, 1 ) ); patch->addInteriorRing( patchInteriorRingZ.clone() ); polySurface.addPatch( patch ); @@ -311,14 +280,10 @@ void TestQgsPolyhedralSurface::testAddPatch() // try adding a patch with zm to a 2d polygon, z and m should be dropped patch = new QgsPolygon; QgsLineString patchExteriorZM; - patchExteriorZM.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) - << QgsPoint( 0, 10, 1, 2 ) << QgsPoint( 10, 10, 1, 2 ) - << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 0, 0, 1, 2 ) ); + patchExteriorZM.setPoints( QgsPointSequence() << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 0, 10, 1, 2 ) << QgsPoint( 10, 10, 1, 2 ) << QgsPoint( 10, 0, 1, 2 ) << QgsPoint( 0, 0, 1, 2 ) ); patch->setExteriorRing( patchExteriorZM.clone() ); QgsLineString patchInteriorRingZM; - patchInteriorRingZM.setPoints( QgsPointSequence() << QgsPoint( 1, 1, 1, 2 ) - << QgsPoint( 1, 9, 1, 2 ) << QgsPoint( 9, 9, 1, 2 ) - << QgsPoint( 9, 1, 1, 2 ) << QgsPoint( 1, 1, 1, 2 ) ); + patchInteriorRingZM.setPoints( QgsPointSequence() << QgsPoint( 1, 1, 1, 2 ) << QgsPoint( 1, 9, 1, 2 ) << QgsPoint( 9, 9, 1, 2 ) << QgsPoint( 9, 1, 1, 2 ) << QgsPoint( 1, 1, 1, 2 ) ); patch->addInteriorRing( patchInteriorRingZM.clone() ); polySurface.addPatch( patch ); @@ -379,37 +344,29 @@ void TestQgsPolyhedralSurface::testAddPatch() void TestQgsPolyhedralSurface::testRemovePatch() { QgsPolyhedralSurface polySurface; - QVector< QgsPolygon * > patches; + QVector patches; QVERIFY( !polySurface.removePatch( -1 ) ); QVERIFY( !polySurface.removePatch( 0 ) ); QgsPolygon *patch1 = new QgsPolygon(); QgsLineString *patchExterior1 = new QgsLineString(); - patchExterior1->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) - << QgsPoint( 0.1, 0.2 ) << QgsPoint( 0.2, 0.2 ) - << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.1, 0.1 ) ); + patchExterior1->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.1, 0.2 ) << QgsPoint( 0.2, 0.2 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.1, 0.1 ) ); patch1->setExteriorRing( patchExterior1 ); QgsLineString *patchInteriorRing1 = new QgsLineString(); - patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 0.12, 0.12 ) - << QgsPoint( 0.13, 0.13 ) << QgsPoint( 0.14, 0.14 ) - << QgsPoint( 0.14, 0.13 ) << QgsPoint( 0.12, 0.12 ) ); + patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 0.12, 0.12 ) << QgsPoint( 0.13, 0.13 ) << QgsPoint( 0.14, 0.14 ) << QgsPoint( 0.14, 0.13 ) << QgsPoint( 0.12, 0.12 ) ); patch1->addInteriorRing( patchInteriorRing1 ); patches.append( patch1 ); QgsPolygon *patch2 = new QgsPolygon(); QgsLineString *patchExterior2 = new QgsLineString(); - patchExterior2->setPoints( QgsPointSequence() << QgsPoint( 0.2, 0.1 ) - << QgsPoint( 0.2, 0.2 ) << QgsPoint( 0.3, 0.2 ) - << QgsPoint( 0.3, 0.1 ) << QgsPoint( 0.2, 0.1 ) ); + patchExterior2->setPoints( QgsPointSequence() << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) << QgsPoint( 0.3, 0.2 ) << QgsPoint( 0.3, 0.1 ) << QgsPoint( 0.2, 0.1 ) ); patch2->setExteriorRing( patchExterior2 ); patches.append( patch2 ); QgsPolygon *patch3 = new QgsPolygon(); QgsLineString *patchExterior3 = new QgsLineString(); - patchExterior3->setPoints( QgsPointSequence() << QgsPoint( 0.3, 0.1 ) - << QgsPoint( 0.3, 0.2 ) << QgsPoint( 0.4, 0.2 ) - << QgsPoint( 0.4, 0.1 ) << QgsPoint( 0.3, 0.1 ) ); + patchExterior3->setPoints( QgsPointSequence() << QgsPoint( 0.3, 0.1 ) << QgsPoint( 0.3, 0.2 ) << QgsPoint( 0.4, 0.2 ) << QgsPoint( 0.4, 0.1 ) << QgsPoint( 0.3, 0.1 ) ); patch3->setExteriorRing( patchExterior3 ); patches.append( patch3 ); @@ -436,26 +393,20 @@ void TestQgsPolyhedralSurface::test3DPatches() { // change dimensionality of patches using setExteriorRing QgsPolyhedralSurface polySurface; - QVector< QgsPolygon * > patches; + QVector patches; QgsPolygon *patch1 = new QgsPolygon(); QgsLineString *patchExterior1 = new QgsLineString(); - patchExterior1->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1, 2 ) - << QgsPoint( 0.1, 0.2, 2 ) << QgsPoint( 0.2, 0.2, 2 ) - << QgsPoint( 0.2, 0.1, 2 ) << QgsPoint( 0.1, 0.1, 2 ) ); + patchExterior1->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1, 2 ) << QgsPoint( 0.1, 0.2, 2 ) << QgsPoint( 0.2, 0.2, 2 ) << QgsPoint( 0.2, 0.1, 2 ) << QgsPoint( 0.1, 0.1, 2 ) ); patch1->setExteriorRing( patchExterior1 ); QgsLineString *patchInteriorRing1 = new QgsLineString(); - patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 0.12, 0.12, 2 ) - << QgsPoint( 0.13, 0.13, 2 ) << QgsPoint( 0.14, 0.14, 2 ) - << QgsPoint( 0.14, 0.13, 2 ) << QgsPoint( 0.12, 0.12, 2 ) ); + patchInteriorRing1->setPoints( QgsPointSequence() << QgsPoint( 0.12, 0.12, 2 ) << QgsPoint( 0.13, 0.13, 2 ) << QgsPoint( 0.14, 0.14, 2 ) << QgsPoint( 0.14, 0.13, 2 ) << QgsPoint( 0.12, 0.12, 2 ) ); patch1->addInteriorRing( patchInteriorRing1 ); patches.append( patch1 ); QgsPolygon *patch2 = new QgsPolygon(); QgsLineString *patchExterior2 = new QgsLineString(); - patchExterior2->setPoints( QgsPointSequence() << QgsPoint( 0.2, 0.1, 2 ) - << QgsPoint( 0.2, 0.2, 2 ) << QgsPoint( 0.3, 0.2, 2 ) - << QgsPoint( 0.3, 0.1, 2 ) << QgsPoint( 0.2, 0.1, 2 ) ); + patchExterior2->setPoints( QgsPointSequence() << QgsPoint( 0.2, 0.1, 2 ) << QgsPoint( 0.2, 0.2, 2 ) << QgsPoint( 0.3, 0.2, 2 ) << QgsPoint( 0.3, 0.1, 2 ) << QgsPoint( 0.2, 0.1, 2 ) ); patch2->setExteriorRing( patchExterior2 ); patches.append( patch2 ); @@ -475,9 +426,7 @@ void TestQgsPolyhedralSurface::testAreaPerimeter() QgsPolygon *patch = new QgsPolygon(); QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) - << QgsPoint( 1, 6 ) << QgsPoint( 6, 6 ) - << QgsPoint( 6, 1 ) << QgsPoint( 1, 1 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 1, 6 ) << QgsPoint( 6, 6 ) << QgsPoint( 6, 1 ) << QgsPoint( 1, 1 ) ); patch->setExteriorRing( patchExterior ); polySurface.addPatch( patch ); @@ -498,18 +447,15 @@ void TestQgsPolyhedralSurface::testInsertVertex() QVERIFY( polySurface.isEmpty() ); QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) - << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); QVERIFY( polySurface.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 0.3, 0 ) ) ); QCOMPARE( polySurface.nCoordinates(), 8 ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 0.5, 0 ) ); QVERIFY( !polySurface.insertVertex( QgsVertexId( 0, 0, -1 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !polySurface.insertVertex( QgsVertexId( 0, 0, 100 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !polySurface.insertVertex( QgsVertexId( 0, 1, 0 ), QgsPoint( 6.0, 7.0 ) ) ); @@ -518,34 +464,30 @@ void TestQgsPolyhedralSurface::testInsertVertex() // first vertex QVERIFY( polySurface.insertVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 0, 0.1 ) ) ); QCOMPARE( polySurface.nCoordinates(), 9 ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 7 ), QgsPoint( 0, 2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 7 ), QgsPoint( 0, 2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); // last vertex QVERIFY( polySurface.insertVertex( QgsVertexId( 0, 0, 9 ), QgsPoint( 0.1, 0.1 ) ) ); QCOMPARE( polySurface.nCoordinates(), 10 ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 0, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 0.3, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 0.5, 0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 8 ), QgsPoint( 0, 0.1 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 9 ), QgsPoint( 0.1, 0.1 ) ); // add a second patch with an interior ring patch.clear(); patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) - << QgsPoint( 12, 10 ) << QgsPoint( 12, 12 ) - << QgsPoint( 10, 12 ) << QgsPoint( 10, 10 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 12, 10 ) << QgsPoint( 12, 12 ) << QgsPoint( 10, 12 ) << QgsPoint( 10, 10 ) ); patch.setExteriorRing( patchExterior ); QgsLineString *patchInterior = new QgsLineString(); - patchInterior->setPoints( QgsPointSequence() << QgsPoint( 10.2, 10.2 ) - << QgsPoint( 10.9, 10.2 ) << QgsPoint( 10.9, 11.2 ) - << QgsPoint( 10.2, 11.2 ) << QgsPoint( 10.2, 10.2 ) ); + patchInterior->setPoints( QgsPointSequence() << QgsPoint( 10.2, 10.2 ) << QgsPoint( 10.9, 10.2 ) << QgsPoint( 10.9, 11.2 ) << QgsPoint( 10.2, 11.2 ) << QgsPoint( 10.2, 10.2 ) ); patch.addInteriorRing( patchInterior ); polySurface.addPatch( patch.clone() ); @@ -553,14 +495,14 @@ void TestQgsPolyhedralSurface::testInsertVertex() QCOMPARE( polySurface.nCoordinates(), 20 ); QVERIFY( polySurface.insertVertex( QgsVertexId( 1, 0, 1 ), QgsPoint( 10.5, 10 ) ) ); QCOMPARE( polySurface.nCoordinates(), 21 ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 10 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 10.5, 10 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 12, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 10.5, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 12, 10 ) ); QVERIFY( polySurface.insertVertex( QgsVertexId( 1, 1, 1 ), QgsPoint( 10.8, 10.2 ) ) ); QCOMPARE( polySurface.nCoordinates(), 22 ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 10.2, 10.2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 10.8, 10.2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 10.9, 10.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 10.2, 10.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 10.8, 10.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 10.9, 10.2 ) ); QVERIFY( !polySurface.insertVertex( QgsVertexId( 1, 0, -1 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !polySurface.insertVertex( QgsVertexId( 1, 0, 100 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( !polySurface.insertVertex( QgsVertexId( 1, 2, 0 ), QgsPoint( 6.0, 7.0 ) ) ); @@ -571,24 +513,24 @@ void TestQgsPolyhedralSurface::testInsertVertex() QVERIFY( polySurface.insertVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 9, 10 ) ) ); QCOMPARE( polySurface.nCoordinates(), 23 ); QCOMPARE( polySurface.patchN( 1 )->exteriorRing()->numPoints(), 7 ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 9, 10 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 10, 10 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 10.5, 10 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 12, 10 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 5 ), QgsPoint( 10, 12 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 6 ), QgsPoint( 9, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 9, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 10, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 10.5, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 12, 10 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 5 ), QgsPoint( 10, 12 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 6 ), QgsPoint( 9, 10 ) ); // last vertex second patch QCOMPARE( polySurface.patchN( 1 )->interiorRing( 0 )->numPoints(), 6 ); QVERIFY( polySurface.insertVertex( QgsVertexId( 1, 1, 6 ), QgsPoint( 0.1, 0.1 ) ) ); QCOMPARE( polySurface.nCoordinates(), 24 ); QCOMPARE( polySurface.patchN( 1 )->interiorRing( 0 )->numPoints(), 7 ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 10.8, 10.2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 10.9, 10.2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 10.9, 11.2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 5 ), QgsPoint( 10.2, 10.2 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 6 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 0.1, 0.1 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 10.8, 10.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 10.9, 10.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 10.9, 11.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 5 ), QgsPoint( 10.2, 10.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 6 ), QgsPoint( 0.1, 0.1 ) ); } void TestQgsPolyhedralSurface::testMoveVertex() @@ -601,72 +543,66 @@ void TestQgsPolyhedralSurface::testMoveVertex() // valid polygon QgsPolygon patch; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) - << QgsPoint( 1, 2 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); QVERIFY( polySurface.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( polySurface.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); QVERIFY( polySurface.moveVertex( QgsVertexId( 0, 0, 2 ), QgsPoint( 26.0, 27.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); // move last vertex QVERIFY( polySurface.moveVertex( QgsVertexId( 0, 0, 3 ), QgsPoint( 1.0, 2.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); // out of range QVERIFY( !polySurface.moveVertex( QgsVertexId( 0, 0, -1 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !polySurface.moveVertex( QgsVertexId( 0, 0, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !polySurface.moveVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 3.0, 4.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 1.0, 2.0 ) ); // add a second patch with an interior ring patch.clear(); patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) - << QgsPoint( 12, 10 ) << QgsPoint( 12, 12 ) - << QgsPoint( 10, 12 ) << QgsPoint( 10, 10 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 10, 10 ) << QgsPoint( 12, 10 ) << QgsPoint( 12, 12 ) << QgsPoint( 10, 12 ) << QgsPoint( 10, 10 ) ); patch.setExteriorRing( patchExterior ); QgsLineString *patchInterior = new QgsLineString(); - patchInterior->setPoints( QgsPointSequence() << QgsPoint( 10.2, 10.2 ) - << QgsPoint( 10.9, 10.2 ) << QgsPoint( 10.9, 11.2 ) - << QgsPoint( 10.2, 11.2 ) << QgsPoint( 10.2, 10.2 ) ); + patchInterior->setPoints( QgsPointSequence() << QgsPoint( 10.2, 10.2 ) << QgsPoint( 10.9, 10.2 ) << QgsPoint( 10.9, 11.2 ) << QgsPoint( 10.2, 11.2 ) << QgsPoint( 10.2, 10.2 ) ); patch.addInteriorRing( patchInterior ); polySurface.addPatch( patch.clone() ); QVERIFY( polySurface.moveVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 4.0, 5.0 ) ) ); QVERIFY( polySurface.moveVertex( QgsVertexId( 1, 0, 1 ), QgsPoint( 14.0, 15.0 ) ) ); QVERIFY( polySurface.moveVertex( QgsVertexId( 1, 0, 2 ), QgsPoint( 24.0, 25.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 4 ), QgsPoint( 4.0, 5.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 4 ), QgsPoint( 4.0, 5.0 ) ); QVERIFY( polySurface.moveVertex( QgsVertexId( 1, 1, 0 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( polySurface.moveVertex( QgsVertexId( 1, 1, 1 ), QgsPoint( 13.0, 14.0 ) ) ); QVERIFY( polySurface.moveVertex( QgsVertexId( 1, 1, 2 ), QgsPoint( 23.0, 24.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 3.0, 4.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 13.0, 14.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 23.0, 24.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 4 ), QgsPoint( 3.0, 4.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( 3.0, 4.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 13.0, 14.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 23.0, 24.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 4 ), QgsPoint( 3.0, 4.0 ) ); // move last vertex QVERIFY( polySurface.moveVertex( QgsVertexId( 1, 1, 4 ), QgsPoint( -1.0, -2.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( -1.0, -2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 13.0, 14.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 23.0, 24.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 4 ), QgsPoint( -1.0, -2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( -1.0, -2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 13.0, 14.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 23.0, 24.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 4 ), QgsPoint( -1.0, -2.0 ) ); // out of range QVERIFY( !polySurface.moveVertex( QgsVertexId( 1, 1, -1 ), QgsPoint( 3.0, 4.0 ) ) ); @@ -674,14 +610,14 @@ void TestQgsPolyhedralSurface::testMoveVertex() QVERIFY( !polySurface.moveVertex( QgsVertexId( 1, 1, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !polySurface.moveVertex( QgsVertexId( 1, 0, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !polySurface.moveVertex( QgsVertexId( 2, 0, 0 ), QgsPoint( 3.0, 4.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 10.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( -1.0, -2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 13.0, 14.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 23.0, 24.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 10.2, 11.2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 10.0, 12.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 0 ), QgsPoint( -1.0, -2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 1 ), QgsPoint( 13.0, 14.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 2 ), QgsPoint( 23.0, 24.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 1 )->interiorRing( 0 ) )->pointN( 3 ), QgsPoint( 10.2, 11.2 ) ); } void TestQgsPolyhedralSurface::testDeleteVertex() @@ -695,10 +631,7 @@ void TestQgsPolyhedralSurface::testDeleteVertex() // valid polygon QgsPolygon patch; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) - << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 5, 2 ) << QgsPoint( 6, 2 ) << QgsPoint( 7, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); @@ -709,26 +642,26 @@ void TestQgsPolyhedralSurface::testDeleteVertex() // valid vertices QVERIFY( polySurface.deleteVertex( QgsVertexId( 0, 0, 1 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 5 ), QgsPoint( 1.0, 2.0 ) ); // delete first vertex QVERIFY( polySurface.deleteVertex( QgsVertexId( 0, 0, 0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 4 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 4 ), QgsPoint( 6.0, 2.0 ) ); // delete last vertex QVERIFY( polySurface.deleteVertex( QgsVertexId( 0, 0, 4 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 21.0, 22.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 21.0, 22.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 7.0, 2.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 11.0, 12.0 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 21.0, 22.0 ) ); // delete another vertex - should remove patch QVERIFY( polySurface.deleteVertex( QgsVertexId( 0, 0, 1 ) ) ); @@ -743,7 +676,7 @@ void TestQgsPolyhedralSurface::testNextVertex() QgsPoint pt; QgsVertexId vId; - ( void )empty.closestSegment( QgsPoint( 1, 2 ), pt, vId ); // empty segment, just want no crash + ( void ) empty.closestSegment( QgsPoint( 1, 2 ), pt, vId ); // empty segment, just want no crash // nextVertex QgsPolyhedralSurface surfacePoly; @@ -761,9 +694,7 @@ void TestQgsPolyhedralSurface::testNextVertex() QgsPolygon patch; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) - << QgsPoint( 1, 2 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( patchExterior ); surfacePoly.addPatch( patch.clone() ); @@ -796,14 +727,10 @@ void TestQgsPolyhedralSurface::testNextVertex() // add a second patch patch.clear(); patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) - << QgsPoint( 1, 2 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( patchExterior ); QgsLineString *patchInterior = new QgsLineString(); - patchInterior->setPoints( QgsPointSequence() << QgsPoint( 4.5, 3 ) - << QgsPoint( 5.5, 3 ) << QgsPoint( 5, 2.5 ) - << QgsPoint( 4.5, 3 ) ); + patchInterior->setPoints( QgsPointSequence() << QgsPoint( 4.5, 3 ) << QgsPoint( 5.5, 3 ) << QgsPoint( 5, 2.5 ) << QgsPoint( 4.5, 3 ) ); patch.addInteriorRing( patchInterior ); surfacePoly.addPatch( patch.clone() ); @@ -861,15 +788,13 @@ void TestQgsPolyhedralSurface::testVertexAngle() QgsPolyhedralSurface polySurface; // just want no crash - ( void )polySurface.vertexAngle( QgsVertexId() ); - ( void )polySurface.vertexAngle( QgsVertexId( 0, 0, 0 ) ); - ( void )polySurface.vertexAngle( QgsVertexId( 0, 1, 0 ) ); + ( void ) polySurface.vertexAngle( QgsVertexId() ); + ( void ) polySurface.vertexAngle( QgsVertexId( 0, 0, 0 ) ); + ( void ) polySurface.vertexAngle( QgsVertexId( 0, 1, 0 ) ); QgsPolygon patch; QgsLineString *exteriorRing = new QgsLineString; - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) - << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); patch.setExteriorRing( exteriorRing ); polySurface.addPatch( patch.clone() ); @@ -888,9 +813,7 @@ void TestQgsPolyhedralSurface::testDeleteVertexRemovePatch() QgsPolygon *patch = new QgsPolygon(); QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) - << QgsPoint( 0, 0 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); patch->setExteriorRing( patchExterior ); polySurface.addPatch( patch ); @@ -906,9 +829,7 @@ void TestQgsPolyhedralSurface::testVertexNumberFromVertexId() // with only one patch QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) - << QgsPoint( 0, 0 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 0, 0 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); @@ -920,14 +841,10 @@ void TestQgsPolyhedralSurface::testVertexNumberFromVertexId() patch.clear(); patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 0 ) - << QgsPoint( 1, 1 ) << QgsPoint( 2, 0 ) - << QgsPoint( 1, 0 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 0 ) << QgsPoint( 1, 1 ) << QgsPoint( 2, 0 ) << QgsPoint( 1, 0 ) ); patch.setExteriorRing( patchExterior ); QgsLineString *patchInterior = new QgsLineString(); - patchInterior->setPoints( QgsPointSequence() << QgsPoint( 1.2, 1.2 ) - << QgsPoint( 1.2, 1.6 ) << QgsPoint( 1.6, 1.6 ) - << QgsPoint( 1.2, 1.2 ) ); + patchInterior->setPoints( QgsPointSequence() << QgsPoint( 1.2, 1.2 ) << QgsPoint( 1.2, 1.6 ) << QgsPoint( 1.6, 1.6 ) << QgsPoint( 1.2, 1.2 ) ); patch.addInteriorRing( patchInterior ); polySurface.addPatch( patch.clone() ); @@ -955,9 +872,7 @@ void TestQgsPolyhedralSurface::testHasCurvedSegments() QgsPolygon patch; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) - << QgsPoint( 1, 2 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); QVERIFY( !polySurface.hasCurvedSegments() ); @@ -972,14 +887,12 @@ void TestQgsPolyhedralSurface::testClosestSegment() QgsPoint pt; QgsVertexId v; int leftOf = 0; - ( void )empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty segment, just want no crash + ( void ) empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty segment, just want no crash QgsPolyhedralSurface polySurface; QgsPolygon patch; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) - << QgsPoint( 5, 10 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 7, 12 ) << QgsPoint( 5, 15 ) << QgsPoint( 5, 10 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); @@ -989,7 +902,7 @@ void TestQgsPolyhedralSurface::testClosestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( polySurface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( polySurface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -1021,9 +934,7 @@ void TestQgsPolyhedralSurface::testClosestSegment() // with a second patch patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) - << QgsPoint( 5, 15 ) << QgsPoint( 2, 11 ) - << QgsPoint( 5, 10 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 5, 15 ) << QgsPoint( 2, 11 ) << QgsPoint( 5, 10 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); @@ -1033,7 +944,7 @@ void TestQgsPolyhedralSurface::testClosestSegment() QCOMPARE( v, QgsVertexId( 1, 0, 3 ) ); QCOMPARE( leftOf, -1 ); - QGSCOMPARENEAR( polySurface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( polySurface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -1071,14 +982,12 @@ void TestQgsPolyhedralSurface::testBoundary() QVERIFY( !polySurface.boundary() ); QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) - << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) - << QgsPoint( 0, 0, 1 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); QgsAbstractGeometry *boundary = polySurface.boundary(); - QgsMultiLineString *multiLineBoundary = dynamic_cast< QgsMultiLineString * >( boundary ); + QgsMultiLineString *multiLineBoundary = dynamic_cast( boundary ); QVERIFY( multiLineBoundary ); QCOMPARE( multiLineBoundary->numGeometries(), 1 ); QgsLineString *lineBoundary = multiLineBoundary->lineStringN( 0 ); @@ -1096,12 +1005,10 @@ void TestQgsPolyhedralSurface::testBoundary() delete boundary; QgsLineString *patchInterior1 = new QgsLineString(); - patchInterior1->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) - << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) ); + patchInterior1->setPoints( QgsPointSequence() << QgsPoint( 0.1, 0.1 ) << QgsPoint( 0.2, 0.1 ) << QgsPoint( 0.2, 0.2 ) ); patch.addInteriorRing( patchInterior1 ); QgsLineString *patchInterior2 = new QgsLineString(); - patchInterior2->setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) - << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) ); + patchInterior2->setPoints( QgsPointSequence() << QgsPoint( 0.8, 0.8 ) << QgsPoint( 0.9, 0.8 ) << QgsPoint( 0.9, 0.9 ) ); patch.addInteriorRing( patchInterior2 ); @@ -1110,38 +1017,38 @@ void TestQgsPolyhedralSurface::testBoundary() polySurface.addPatch( patch.clone() ); boundary = polySurface.boundary(); - multiLineBoundary = dynamic_cast< QgsMultiLineString * >( boundary ); + multiLineBoundary = dynamic_cast( boundary ); QVERIFY( multiLineBoundary ); QCOMPARE( multiLineBoundary->numGeometries(), 3 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->numPoints(), 5 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 0 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 1 ), 1.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 2 ), 2.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 3 ), 1.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->xAt( 4 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 0 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 1 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 2 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 3 ), 0.5 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 0 ) )->yAt( 4 ), 0.0 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->numPoints(), 4 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->xAt( 0 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->xAt( 1 ), 0.2 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->xAt( 2 ), 0.2 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->xAt( 3 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->yAt( 0 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->yAt( 1 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->yAt( 2 ), 0.2 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 1 ) )->yAt( 3 ), 0.1 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->numPoints(), 4 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->xAt( 0 ), 0.8 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->xAt( 1 ), 0.9 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->xAt( 2 ), 0.9 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->xAt( 3 ), 0.8 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->yAt( 0 ), 0.8 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->yAt( 1 ), 0.8 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->yAt( 2 ), 0.9 ); - QCOMPARE( qgis::down_cast< QgsLineString * >( multiLineBoundary->geometryN( 2 ) )->yAt( 3 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->numPoints(), 5 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 0 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 1 ), 1.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 2 ), 2.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 3 ), 1.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->xAt( 4 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 0 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 1 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 2 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 3 ), 0.5 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 0 ) )->yAt( 4 ), 0.0 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->numPoints(), 4 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->xAt( 0 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->xAt( 1 ), 0.2 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->xAt( 2 ), 0.2 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->xAt( 3 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->yAt( 0 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->yAt( 1 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->yAt( 2 ), 0.2 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 1 ) )->yAt( 3 ), 0.1 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->numPoints(), 4 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->xAt( 0 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->xAt( 1 ), 0.9 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->xAt( 2 ), 0.9 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->xAt( 3 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->yAt( 0 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->yAt( 1 ), 0.8 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->yAt( 2 ), 0.9 ); + QCOMPARE( qgis::down_cast( multiLineBoundary->geometryN( 2 ) )->yAt( 3 ), 0.8 ); polySurface.removePatch( 0 ); QCOMPARE( polySurface.numPatches(), 0 ); @@ -1150,14 +1057,12 @@ void TestQgsPolyhedralSurface::testBoundary() // test boundary with z patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 20 ) ); patch.setExteriorRing( patchExterior ); polySurface.addPatch( patch.clone() ); boundary = polySurface.boundary(); - multiLineBoundary = dynamic_cast< QgsMultiLineString * >( boundary ); + multiLineBoundary = dynamic_cast( boundary ); QVERIFY( multiLineBoundary ); QCOMPARE( multiLineBoundary->numGeometries(), 1 ); lineBoundary = multiLineBoundary->lineStringN( 0 ); @@ -1178,22 +1083,16 @@ void TestQgsPolyhedralSurface::testBoundingBox() QgsPolygon *patch1 = new QgsPolygon(); QgsLineString *patchExterior1 = new QgsLineString(); - patchExterior1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 4, 5, 6 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 9 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + patchExterior1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 4, 5, 6 ) << QgsPoint( Qgis::WkbType::PointZ, 7, 8, 9 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); patch1->setExteriorRing( patchExterior1 ); polySurface.addPatch( patch1 ); QgsPolygon *patch2 = new QgsPolygon(); QgsLineString *patchExterior2 = new QgsLineString(); - patchExterior2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ) - << QgsPoint( Qgis::WkbType::PointZ, 13, 14, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 16, 17, 18 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ) ); + patchExterior2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ) << QgsPoint( Qgis::WkbType::PointZ, 13, 14, 15 ) << QgsPoint( Qgis::WkbType::PointZ, 16, 17, 18 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ) ); patch2->setExteriorRing( patchExterior2 ); QgsLineString *patchInterior2 = new QgsLineString(); - patchInterior2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10.5, 11.5, 12.5 ) - << QgsPoint( Qgis::WkbType::PointZ, 13.5, 14.5, 15.5 ) << QgsPoint( Qgis::WkbType::PointZ, 15.5, 16.5, 17.5 ) - << QgsPoint( Qgis::WkbType::PointZ, 10.5, 11.5, 12.5 ) ); + patchInterior2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10.5, 11.5, 12.5 ) << QgsPoint( Qgis::WkbType::PointZ, 13.5, 14.5, 15.5 ) << QgsPoint( Qgis::WkbType::PointZ, 15.5, 16.5, 17.5 ) << QgsPoint( Qgis::WkbType::PointZ, 10.5, 11.5, 12.5 ) ); patch2->addInteriorRing( patchInterior2 ); polySurface.addPatch( patch2 ); @@ -1217,9 +1116,7 @@ void TestQgsPolyhedralSurface::testBoundingBox3D() QgsPolygon *patch = new QgsPolygon(); QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 6 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, -1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 6 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 6 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) << QgsPoint( Qgis::WkbType::PointZ, -1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 6 ) ); patch->setExteriorRing( patchExterior ); polySurface.addPatch( patch ); @@ -1240,9 +1137,7 @@ void TestQgsPolyhedralSurface::testBoundingBoxIntersects() QgsPolygon *patch1 = new QgsPolygon(); QgsLineString *patchExterior1 = new QgsLineString(); - patchExterior1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, -1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + patchExterior1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) << QgsPoint( Qgis::WkbType::PointZ, -1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); patch1->setExteriorRing( patchExterior1 ); polySurface1.addPatch( patch1 ); @@ -1255,9 +1150,7 @@ void TestQgsPolyhedralSurface::testBoundingBoxIntersects() QgsPolygon *patch2 = new QgsPolygon(); QgsLineString *patchExterior2 = new QgsLineString(); - patchExterior2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, -1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + patchExterior2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) << QgsPoint( Qgis::WkbType::PointZ, -1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); patch2->setExteriorRing( patchExterior2 ); polySurface2.addPatch( patch2 ); @@ -1275,9 +1168,7 @@ void TestQgsPolyhedralSurface::testDropZValue() QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); QgsLineString *exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 1, 4 ) << QgsPoint( 4, 4 ) - << QgsPoint( 4, 1 ) << QgsPoint( 1, 2 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 1, 4 ) << QgsPoint( 4, 4 ) << QgsPoint( 4, 1 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( exteriorRing ); polySurface.addPatch( patch.clone() ); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); @@ -1285,41 +1176,39 @@ void TestQgsPolyhedralSurface::testDropZValue() polySurface.dropZValue(); // not z QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::Polygon ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with z exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 10, 20, 3 ) << QgsPoint( 11, 12, 13 ) - << QgsPoint( 1, 12, 23 ) << QgsPoint( 10, 20, 3 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 10, 20, 3 ) << QgsPoint( 11, 12, 13 ) << QgsPoint( 1, 12, 23 ) << QgsPoint( 10, 20, 3 ) ); patch.setExteriorRing( exteriorRing ); polySurface.clear(); polySurface.addPatch( patch.clone() ); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurfaceZ ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::PolygonZ ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20, 3 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20, 3 ) ); polySurface.dropZValue(); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::Polygon ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20 ) ); // with zm exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) - << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); patch.setExteriorRing( exteriorRing ); polySurface.clear(); polySurface.addPatch( patch.clone() ); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurfaceZM ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::PolygonZM ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); polySurface.dropZValue(); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurfaceM ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::PolygonM ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); } void TestQgsPolyhedralSurface::testDropMValue() @@ -1332,54 +1221,49 @@ void TestQgsPolyhedralSurface::testDropMValue() QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); QgsLineString *exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) - << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 1, 12 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( exteriorRing ); polySurface.addPatch( patch.clone() ); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); polySurface.dropMValue(); // not zm QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::Polygon ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with m exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ) << QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) << QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); patch.setExteriorRing( exteriorRing ); polySurface.clear(); polySurface.addPatch( patch.clone() ); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurfaceM ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::PolygonM ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); polySurface.dropMValue(); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurface ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::Polygon ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) - << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); patch.setExteriorRing( exteriorRing ); polySurface.clear(); polySurface.addPatch( patch.clone() ); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurfaceZM ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::PolygonZM ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2, 3, 4 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2, 3, 4 ) ); polySurface.dropMValue(); QCOMPARE( polySurface.wkbType(), Qgis::WkbType::PolyhedralSurfaceZ ); QCOMPARE( polySurface.patchN( 0 )->wkbType(), Qgis::WkbType::PolygonZ ); - QCOMPARE( static_cast< const QgsLineString *>( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( polySurface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); } void TestQgsPolyhedralSurface::testCoordinateSequence() @@ -1388,21 +1272,16 @@ void TestQgsPolyhedralSurface::testCoordinateSequence() QgsPolygon patch; QgsLineString *patchExterior = new QgsLineString(); - patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) - << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) - << QgsPoint( 1, 2 ) ); + patchExterior->setPoints( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) << QgsPoint( 1, 2 ) ); patch.setExteriorRing( patchExterior ); QgsLineString *patchInterior = new QgsLineString(); - patchInterior->setPoints( QgsPointSequence() << QgsPoint( 4.5, 3 ) - << QgsPoint( 5.5, 3 ) << QgsPoint( 5, 2.5 ) - << QgsPoint( 4.5, 3 ) ); + patchInterior->setPoints( QgsPointSequence() << QgsPoint( 4.5, 3 ) << QgsPoint( 5.5, 3 ) << QgsPoint( 5, 2.5 ) << QgsPoint( 4.5, 3 ) ); patch.addInteriorRing( patchInterior ); surfacePoly.addPatch( patch.clone() ); QgsCoordinateSequence coordinateSequence = surfacePoly.coordinateSequence(); QgsCoordinateSequence expectedSequence; - expectedSequence << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) << QgsPoint( 1, 2 ) ) - << ( QgsPointSequence() << QgsPoint( 4.5, 3 ) << QgsPoint( 5.5, 3 ) << QgsPoint( 5, 2.5 ) << QgsPoint( 4.5, 3 ) ) ); + expectedSequence << ( QgsRingSequence() << ( QgsPointSequence() << QgsPoint( 1, 2 ) << QgsPoint( 11, 12 ) << QgsPoint( 11, 2 ) << QgsPoint( 1, 2 ) ) << ( QgsPointSequence() << QgsPoint( 4.5, 3 ) << QgsPoint( 5.5, 3 ) << QgsPoint( 5, 2.5 ) << QgsPoint( 4.5, 3 ) ) ); QCOMPARE( coordinateSequence, expectedSequence ); } @@ -1422,8 +1301,7 @@ void TestQgsPolyhedralSurface::testChildGeometry() QgsPolygon patch; QgsLineString *exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); patch.setExteriorRing( exteriorRing ); polySurface.addPatch( patch.clone() ); @@ -1440,19 +1318,16 @@ void TestQgsPolyhedralSurface::testWKB() QgsLineString *interiorRing; exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) ); patch.setExteriorRing( exteriorRing ); polySurface1.addPatch( patch.clone() ); exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.1, 0 ) - << QgsPoint( 0.2, 0 ) << QgsPoint( 0.1, 0.05 ) << QgsPoint( 0, 0 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.1, 0 ) << QgsPoint( 0.2, 0 ) << QgsPoint( 0.1, 0.05 ) << QgsPoint( 0, 0 ) ); patch.clear(); patch.setExteriorRing( exteriorRing ); interiorRing = new QgsLineString(); - interiorRing->setPoints( QgsPointSequence() << QgsPoint( 0.02, 0.02 ) << QgsPoint( 0.06, 0.02 ) - << QgsPoint( 0.06, 0.04 ) << QgsPoint( 0.02, 0.02 ) ); + interiorRing->setPoints( QgsPointSequence() << QgsPoint( 0.02, 0.02 ) << QgsPoint( 0.06, 0.02 ) << QgsPoint( 0.06, 0.04 ) << QgsPoint( 0.02, 0.02 ) ); patch.addInteriorRing( interiorRing ); polySurface1.addPatch( patch.clone() ); @@ -1469,19 +1344,16 @@ void TestQgsPolyhedralSurface::testWKB() // PolyhedralSurfaceZ exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) - << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); patch.clear(); patch.setExteriorRing( exteriorRing ); polySurface1.addPatch( patch.clone() ); patch.clear(); exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 0, 2 ) - << QgsPoint( 0.2, 0, 3 ) << QgsPoint( 0.1, 0.05, 4 ) << QgsPoint( 0, 0, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 0, 2 ) << QgsPoint( 0.2, 0, 3 ) << QgsPoint( 0.1, 0.05, 4 ) << QgsPoint( 0, 0, 1 ) ); interiorRing = new QgsLineString(); - interiorRing->setPoints( QgsPointSequence() << QgsPoint( 0.02, 0.02, 1 ) << QgsPoint( 0.06, 0.02, 1 ) - << QgsPoint( 0.06, 0.04, 1 ) << QgsPoint( 0.02, 0.02, 1 ) ); + interiorRing->setPoints( QgsPointSequence() << QgsPoint( 0.02, 0.02, 1 ) << QgsPoint( 0.06, 0.02, 1 ) << QgsPoint( 0.06, 0.04, 1 ) << QgsPoint( 0.02, 0.02, 1 ) ); patch.setExteriorRing( exteriorRing ); patch.addInteriorRing( interiorRing ); polySurface1.addPatch( patch.clone() ); @@ -1497,22 +1369,17 @@ void TestQgsPolyhedralSurface::testWKB() // PolyhedralSurfaceM exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 2, 0, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 1, 0.5, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 2, 0, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 1, 0.5, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); patch.clear(); patch.setExteriorRing( exteriorRing ); polySurface1.addPatch( patch.clone() ); patch.clear(); exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0, 0, 3 ) - << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.05, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0, 0, 2 ) << QgsPoint( Qgis::WkbType::PointM, 0.2, 0, 0, 3 ) << QgsPoint( Qgis::WkbType::PointM, 0.1, 0.05, 0, 4 ) << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ) ); patch.setExteriorRing( exteriorRing ); interiorRing = new QgsLineString(); - interiorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.02, 0.02, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.06, 0.02, 0, 1 ) - << QgsPoint( Qgis::WkbType::PointM, 0.06, 0.04, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.02, 0.02, 0, 1 ) ); + interiorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0.02, 0.02, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.06, 0.02, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.06, 0.04, 0, 1 ) << QgsPoint( Qgis::WkbType::PointM, 0.02, 0.02, 0, 1 ) ); patch.addInteriorRing( interiorRing ); polySurface1.addPatch( patch.clone() ); @@ -1527,22 +1394,17 @@ void TestQgsPolyhedralSurface::testWKB() // PolyhedralSurfaceZM exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); patch.clear(); patch.setExteriorRing( exteriorRing ); polySurface1.addPatch( patch.clone() ); exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); patch.clear(); patch.setExteriorRing( exteriorRing ); interiorRing = new QgsLineString(); - interiorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.02, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.04, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) ); + interiorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.04, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) ); patch.addInteriorRing( interiorRing ); polySurface1.addPatch( patch.clone() ); @@ -1569,19 +1431,16 @@ void TestQgsPolyhedralSurface::testWKB() // GeoJSON export exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) - << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 ) << QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) ); patch.clear(); patch.setExteriorRing( exteriorRing ); polySurface1.addPatch( patch.clone() ); patch.clear(); exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 0, 2 ) - << QgsPoint( 0.2, 0, 3 ) << QgsPoint( 0.1, 0.05, 4 ) << QgsPoint( 0, 0, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 0, 2 ) << QgsPoint( 0.2, 0, 3 ) << QgsPoint( 0.1, 0.05, 4 ) << QgsPoint( 0, 0, 1 ) ); interiorRing = new QgsLineString(); - interiorRing->setPoints( QgsPointSequence() << QgsPoint( 0.02, 0.02, 1 ) << QgsPoint( 0.06, 0.02, 1 ) - << QgsPoint( 0.06, 0.04, 1 ) << QgsPoint( 0.02, 0.02, 1 ) ); + interiorRing->setPoints( QgsPointSequence() << QgsPoint( 0.02, 0.02, 1 ) << QgsPoint( 0.06, 0.02, 1 ) << QgsPoint( 0.06, 0.04, 1 ) << QgsPoint( 0.02, 0.02, 1 ) ); patch.setExteriorRing( exteriorRing ); patch.addInteriorRing( interiorRing ); polySurface1.addPatch( patch.clone() ); @@ -1589,7 +1448,6 @@ void TestQgsPolyhedralSurface::testWKB() QString expectedSimpleJson( "{\"coordinates\":[[[[0.0,0.0,1.0],[1.0,0.0,2.0],[2.0,0.0,3.0],[1.0,0.5,4.0],[0.0,0.0,1.0]]],[[[0.0,0.0,1.0],[0.1,0.0,2.0],[0.2,0.0,3.0],[0.1,0.05,4.0],[0.0,0.0,1.0]],[[0.02,0.02,1.0],[0.06,0.02,1.0],[0.06,0.04,1.0],[0.02,0.02,1.0]]]],\"type\":\"MultiPolygon\"}" ); QString jsonRes = polySurface1.asJson( 2 ); QCOMPARE( jsonRes, expectedSimpleJson ); - } void TestQgsPolyhedralSurface::testWKT() @@ -1600,13 +1458,10 @@ void TestQgsPolyhedralSurface::testWKT() QgsLineString *interiorRing; exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); patch.setExteriorRing( exteriorRing ); interiorRing = new QgsLineString(); - interiorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.02, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.04, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) ); + interiorRing->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.04, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) ); patch.addInteriorRing( interiorRing ); polySurface1.addPatch( patch.clone() ); @@ -1640,9 +1495,7 @@ void TestQgsPolyhedralSurface::testExport() // Z // as GML3 - M is dropped - exteriorRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 11 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 0, 12 ) - << QgsPoint( Qgis::WkbType::PointZ, 1, 0.5, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); + exteriorRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0, 11 ) << QgsPoint( Qgis::WkbType::PointZ, 2, 0, 12 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 0.5, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ) ); patch.setExteriorRing( exteriorRing.clone() ); interiorRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0.02, 0.02, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 0.06, 0.02, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 0.06, 0.04, 10 ) << QgsPoint( Qgis::WkbType::PointZ, 0.02, 0.02, 10 ) ); patch.addInteriorRing( interiorRing.clone() ); @@ -1656,9 +1509,7 @@ void TestQgsPolyhedralSurface::testExport() // as GML3 exportPolygon.clear(); patch.clear(); - exteriorRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); + exteriorRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ) << QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ) ); patch.setExteriorRing( exteriorRing.clone() ); interiorRing.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.02, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.06, 0.04, 10, 1 ) << QgsPoint( Qgis::WkbType::PointZM, 0.02, 0.02, 10, 1 ) ); patch.addInteriorRing( interiorRing.clone() ); @@ -1715,16 +1566,10 @@ void TestQgsPolyhedralSurface::testIsValid() QgsPolygon patch; QgsLineString lineString; - lineString.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 11, 2, 3 ) - << QgsPoint( Qgis::WkbType::PointZ, 4, 12, 13 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 22, 23 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 2, 3 ) ); + lineString.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 11, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZ, 4, 12, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 12, 13 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 22, 23 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 2, 3 ) ); patch.setExteriorRing( lineString.clone() ); - lineString.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 2, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 11, 2, 5 ) - << QgsPoint( Qgis::WkbType::PointZ, 10, 2, 5 ) ); + lineString.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 10, 2, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 11, 2, 5 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 2, 5 ) ); patch.addInteriorRing( lineString.clone() ); polySurface2.addPatch( patch.clone() ); diff --git a/tests/src/core/geometry/testqgsquadrilateral.cpp b/tests/src/core/geometry/testqgsquadrilateral.cpp index 68b75c39a2f6..23992ca41df8 100644 --- a/tests/src/core/geometry/testqgsquadrilateral.cpp +++ b/tests/src/core/geometry/testqgsquadrilateral.cpp @@ -22,7 +22,7 @@ #include "testgeometryutils.h" -class TestQgsQuadrilateral: public QObject +class TestQgsQuadrilateral : public QObject { Q_OBJECT private slots: @@ -44,8 +44,7 @@ class TestQgsQuadrilateral: public QObject void TestQgsQuadrilateral::constructor() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); QVERIFY( quad.isValid() ); QgsPointSequence pts = quad.points(); @@ -70,8 +69,7 @@ void TestQgsQuadrilateral::constructorEmpty() void TestQgsQuadrilateral::constructorWhenColinear() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 0, 10 ), QgsPoint( 10, 10 ) ); + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 10 ), QgsPoint( 10, 10 ) ); QVERIFY( !quad.isValid() ); QgsPointSequence pts = quad.points(); @@ -81,8 +79,7 @@ void TestQgsQuadrilateral::constructorWhenColinear() QVERIFY( pts.at( 2 ).isEmpty() ); QVERIFY( pts.at( 3 ).isEmpty() ); - QgsQuadrilateral quadXY( QgsPointXY( 0, 0 ), QgsPointXY( 0, 5 ), - QgsPointXY( 0, 10 ), QgsPointXY( 10, 10 ) ); + QgsQuadrilateral quadXY( QgsPointXY( 0, 0 ), QgsPointXY( 0, 5 ), QgsPointXY( 0, 10 ), QgsPointXY( 10, 10 ) ); QVERIFY( !quadXY.isValid() ); pts = quadXY.points(); @@ -95,8 +92,7 @@ void TestQgsQuadrilateral::constructorWhenColinear() void TestQgsQuadrilateral::constructorWhenAntiParallelogram() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 5, 5 ), - QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ); + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ), QgsPoint( 0, 5 ) ); QVERIFY( !quad.isValid() ); QgsPointSequence pts = quad.points(); @@ -105,8 +101,7 @@ void TestQgsQuadrilateral::constructorWhenAntiParallelogram() QVERIFY( pts.at( 2 ).isEmpty() ); QVERIFY( pts.at( 3 ).isEmpty() ); - QgsQuadrilateral quadXY( QgsPointXY( 0, 0 ), QgsPointXY( 5, 5 ), - QgsPointXY( 5, 0 ), QgsPointXY( 0, 5 ) ); + QgsQuadrilateral quadXY( QgsPointXY( 0, 0 ), QgsPointXY( 5, 5 ), QgsPointXY( 5, 0 ), QgsPointXY( 0, 5 ) ); QVERIFY( !quadXY.isValid() ); pts = quadXY.points(); @@ -119,264 +114,168 @@ void TestQgsQuadrilateral::constructorWhenAntiParallelogram() void TestQgsQuadrilateral::fromRectangle() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); - - QCOMPARE( QgsQuadrilateral::fromRectangle( QgsRectangle( QgsPointXY( 0, 0 ), QgsPointXY( 0, 0 ) ) ), - QgsQuadrilateral() ); - QCOMPARE( QgsQuadrilateral::fromRectangle( QgsRectangle( QgsPointXY( 0, 0 ), QgsPointXY( 5, 5 ) ) ), - quad ) ; - QCOMPARE( QgsQuadrilateral::fromRectangle( QgsRectangle( QgsPointXY( 5, 5 ), QgsPointXY( 0, 0 ) ) ), - quad ) ; + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + + QCOMPARE( QgsQuadrilateral::fromRectangle( QgsRectangle( QgsPointXY( 0, 0 ), QgsPointXY( 0, 0 ) ) ), QgsQuadrilateral() ); + QCOMPARE( QgsQuadrilateral::fromRectangle( QgsRectangle( QgsPointXY( 0, 0 ), QgsPointXY( 5, 5 ) ) ), quad ); + QCOMPARE( QgsQuadrilateral::fromRectangle( QgsRectangle( QgsPointXY( 5, 5 ), QgsPointXY( 0, 0 ) ) ), quad ); } void TestQgsQuadrilateral::rectangleFromExtent() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); - QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), - QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); - QgsQuadrilateral quadM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), - QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), - QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), - QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointM ) ); - QgsQuadrilateral quadZM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), - QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), - QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), - QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointZM ) ); - - QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ) ), - QgsQuadrilateral() ); - QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ) ), - QgsQuadrilateral() ); - - QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5 ) ), - quad ); - QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 5, 5 ), QgsPoint( 0, 0 ) ), - quad ); + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); + QgsQuadrilateral quadM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointM ) ); + QgsQuadrilateral quadZM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointZM ) ); + + QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ) ), QgsQuadrilateral() ); + QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ) ), QgsQuadrilateral() ); + + QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5 ) ), quad ); + QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 5, 5 ), QgsPoint( 0, 0 ) ), quad ); // Z - QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0, 10 ), QgsPoint( 5, 5 ) ), - quadZ ); - QVERIFY( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10 ) ) - != quadZ ); + QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0, 10 ), QgsPoint( 5, 5 ) ), quadZ ); + QVERIFY( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10 ) ) != quadZ ); QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10 ) ), quad ); // Z and M are only taken from the first point // M - QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ) ), - quadM ); - QVERIFY( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ) ) - != quadM ); + QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ) ), quadM ); + QVERIFY( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ) ) != quadM ); QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10 ) ), quad ); // Z and M are only taken from the first point // ZM - QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ) ), - quadZM ); - QVERIFY( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20 ) ) - != quadZM ); + QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ) ), quadZM ); + QVERIFY( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20 ) ) != quadZM ); QCOMPARE( QgsQuadrilateral::rectangleFromExtent( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20 ) ), quad ); // Z and M are only taken from the first point } void TestQgsQuadrilateral::rectangleFromCenterPoint() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); - QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), - QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); - QgsQuadrilateral quadM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), - QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), - QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), - QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointM ) ); - QgsQuadrilateral quadZM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), - QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), - QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), - QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointZM ) ); - - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 2.5, 2.5 ) ), - QgsQuadrilateral() ) ; - - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 5, 5 ) ), - quad ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 5, 0 ) ), - quad ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 0, 5 ) ), - quad ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 0, 0 ) ), - quad ) ; + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); + QgsQuadrilateral quadM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointM ) ); + QgsQuadrilateral quadZM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointZM ) ); + + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 2.5, 2.5 ) ), QgsQuadrilateral() ); + + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 5, 5 ) ), quad ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 5, 0 ) ), quad ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 0, 5 ) ), quad ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 0, 0 ) ), quad ); // Z - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 5, 5 ) ), - quadZ ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 5, 0 ) ), - quadZ ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 0, 5 ) ), - quadZ ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 0, 0 ) ), - quadZ ) ; + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 5, 5 ) ), quadZ ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 5, 0 ) ), quadZ ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 0, 5 ) ), quadZ ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 0, 0 ) ), quadZ ); QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 0, 0, 10 ) ), - quad ) ; // Z and M are only taken from the first point + quad ); // Z and M are only taken from the first point // M - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ) ), - quadM ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 0 ) ), - quadM ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5 ) ), - quadM ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 0 ) ), - quadM ) ; + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ) ), quadM ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 0 ) ), quadM ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5 ) ), quadM ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 0 ) ), quadM ); QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ) ), - quad ) ; // Z and M are only taken from the first point + quad ); // Z and M are only taken from the first point // ZM - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ) ), - quadM ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 0 ) ), - quadM ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5 ) ), - quadM ) ; - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 0 ) ), - quadM ) ; + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ) ), quadM ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 0 ) ), quadM ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5 ) ), quadM ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 0 ) ), quadM ); QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ) ), - quad ) ; // Z and M are only taken from the first point - + quad ); // Z and M are only taken from the first point } void TestQgsQuadrilateral::rectangleFrom3points() { - QgsQuadrilateral rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + QgsQuadrilateral rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsQuadrilateral::Distance ), - QgsQuadrilateral() ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsQuadrilateral::Projected ), - QgsQuadrilateral() ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsQuadrilateral::Distance ), QgsQuadrilateral() ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsQuadrilateral::Projected ), QgsQuadrilateral() ); // Z - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5, 10 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); - - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4, 10 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 4, 10 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5 ), QgsPoint( 0, 5, 5 ), QgsPoint( 5, 5, 0 ), QgsQuadrilateral::Projected ).toString( 2 ), - QString( "Quadrilateral (Point 1: Point Z (0 0 5), Point 2: Point Z (0 5 5), Point 3: Point Z (5 5 0), Point 4: Point Z (5 0 0))" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5 ), QgsPoint( 0, 5, 5 ), QgsPoint( 5, 5, 10 ), QgsQuadrilateral::Projected ).toString( 2 ), - QString( "Quadrilateral (Point 1: Point Z (0 0 5), Point 2: Point Z (0 5 5), Point 3: Point Z (5 5 10), Point 4: Point Z (5 0 10))" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5, 10 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); + + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4, 10 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 4, 10 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString Z (0 0 10, 0 5 10, 5 5 10, 5 0 10, 0 0 10)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5 ), QgsPoint( 0, 5, 5 ), QgsPoint( 5, 5, 0 ), QgsQuadrilateral::Projected ).toString( 2 ), QString( "Quadrilateral (Point 1: Point Z (0 0 5), Point 2: Point Z (0 5 5), Point 3: Point Z (5 5 0), Point 4: Point Z (5 0 0))" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5 ), QgsPoint( 0, 5, 5 ), QgsPoint( 5, 5, 10 ), QgsQuadrilateral::Projected ).toString( 2 ), QString( "Quadrilateral (Point 1: Point Z (0 0 5), Point 2: Point Z (0 5 5), Point 3: Point Z (5 5 10), Point 4: Point Z (5 0 10))" ) ); // M - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); - - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); + + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString M (0 0 20, 0 5 20, 5 5 20, 5 0 20, 0 0 20)" ) ); QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5, 10, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 5, 10, Qgis::WkbType::PointM ), QgsPoint( 5, 5, 0, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Projected ).toString( 2 ), QString( "Quadrilateral (Point 1: Point M (0 0 10), Point 2: Point M (0 5 10), Point 3: Point M (5 5 10), Point 4: Point M (5 0 10))" ) ); // The first M is taken QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5, 10, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 5, 10, Qgis::WkbType::PointM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), QgsQuadrilateral::Projected ).toString( 2 ), QString( "Quadrilateral (Point 1: Point M (0 0 10), Point 2: Point M (0 5 10), Point 3: Point M (5 5 10), Point 4: Point M (5 0 10))" ) ); // The first M is taken // ZM - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), - QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); - - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), - QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Distance ).toLineString()->asWkt( 0 ), QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); + + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 4, 10, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Projected ).toLineString()->asWkt( 0 ), QString( "LineString ZM (0 0 10 20, 0 5 10 20, 5 5 10 20, 5 0 10 20, 0 0 10 20)" ) ); QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5, 10, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 5, 10, Qgis::WkbType::PointZM ), QgsPoint( 5, 5, 0, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Projected ).toString( 2 ), QString( "Quadrilateral (Point 1: Point ZM (0 0 5 10), Point 2: Point ZM (0 5 5 10), Point 3: Point ZM (5 5 0 10), Point 4: Point ZM (5 0 0 10))" ) ); // The first M is taken QCOMPARE( QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 5, 10, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 5, 10, Qgis::WkbType::PointZM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), QgsQuadrilateral::Projected ).toString( 2 ), QString( "Quadrilateral (Point 1: Point ZM (0 0 5 10), Point 2: Point ZM (0 5 5 10), Point 3: Point ZM (5 5 10 10), Point 4: Point ZM (5 0 10 10))" ) ); // The first M is taken - } void TestQgsQuadrilateral::squareFromDiagonal() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); - QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), - QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); - QgsQuadrilateral quadM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), - QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointM ) ); - QgsQuadrilateral quadZM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), - QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointZM ) ); - QgsQuadrilateral quadInv( QgsPoint( 5, 5 ), QgsPoint( 5, 0 ), - QgsPoint( 0, 0 ), QgsPoint( 0, 5 ) ); - - QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ) ), - QgsQuadrilateral() ); - QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5 ) ), - quad ); - QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 5, 5 ), QgsPoint( 0, 0 ) ) - != quad ); + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); + QgsQuadrilateral quadM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointM ) ); + QgsQuadrilateral quadZM( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 0, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 0, 10, 20, Qgis::WkbType::PointZM ) ); + QgsQuadrilateral quadInv( QgsPoint( 5, 5 ), QgsPoint( 5, 0 ), QgsPoint( 0, 0 ), QgsPoint( 0, 5 ) ); + + QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ) ), QgsQuadrilateral() ); + QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5 ) ), quad ); + QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 5, 5 ), QgsPoint( 0, 0 ) ) != quad ); QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 5, 5 ), QgsPoint( 0, 0 ) ).equals( quadInv, 1E-8 ) ); // Z - QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0, 10 ), QgsPoint( 5, 5 ) ), - quadZ ); - QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10 ) ) - != quadZ ); + QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0, 10 ), QgsPoint( 5, 5 ) ), quadZ ); + QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10 ) ) != quadZ ); QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10 ) ), quad ); // Z and M are only taken from the first point // M - QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ) ), - quadM ); - QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ) ) - != quadM ); + QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointM ), QgsPoint( 5, 5 ) ), quadM ); + QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ) ) != quadM ); QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointM ) ), quad ); // Z and M are only taken from the first point // ZM - QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ) ), - quadZM ); - QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ) ) - != quadZM ); + QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0, 10, 20, Qgis::WkbType::PointZM ), QgsPoint( 5, 5 ) ), quadZM ); + QVERIFY( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ) ) != quadZM ); QCOMPARE( QgsQuadrilateral::squareFromDiagonal( QgsPoint( 0, 0 ), QgsPoint( 5, 5, 10, 20, Qgis::WkbType::PointZM ) ), quad ); // Z and M are only taken from the first point } void TestQgsQuadrilateral::setPoint() { - QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + QgsQuadrilateral quad( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); QVERIFY( quad.setPoint( QgsPoint( -1, -1 ), QgsQuadrilateral::Point1 ) ); QVERIFY( quad.setPoint( QgsPoint( -1, 6 ), QgsQuadrilateral::Point2 ) ); @@ -440,10 +339,8 @@ void TestQgsQuadrilateral::equals() quad2 = QgsQuadrilateral( QgsPoint( 0.01, 0.01, 0.01 ), QgsPoint( 0.01, 5.01, 0 ), QgsPoint( 5.01, 5.01, -0.01 ), QgsPoint( 5.01, 0.01, 0.04 ) ); QVERIFY( quad1.equals( quad2, 1e-1 ) ); - quad1 = QgsQuadrilateral( QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 0, 5, 0, 1 ), - QgsPoint( Qgis::WkbType::PointM, 5, 5, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 5, 0, 0, 1 ) ); - quad2 = QgsQuadrilateral( QgsPoint( Qgis::WkbType::PointM, 0.01, 0.01, 0, 1.01 ), QgsPoint( Qgis::WkbType::PointM, 0.01, 5.01, 0, 1.01 ), - QgsPoint( Qgis::WkbType::PointM, 5.01, 5.01, 0, 1.01 ), QgsPoint( Qgis::WkbType::PointM, 5.01, 0.01, 0, 1.01 ) ); + quad1 = QgsQuadrilateral( QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 0, 5, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 5, 5, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 5, 0, 0, 1 ) ); + quad2 = QgsQuadrilateral( QgsPoint( Qgis::WkbType::PointM, 0.01, 0.01, 0, 1.01 ), QgsPoint( Qgis::WkbType::PointM, 0.01, 5.01, 0, 1.01 ), QgsPoint( Qgis::WkbType::PointM, 5.01, 5.01, 0, 1.01 ), QgsPoint( Qgis::WkbType::PointM, 5.01, 0.01, 0, 1.01 ) ); QVERIFY( quad1.equals( quad2, 1e-1 ) ); } @@ -452,20 +349,17 @@ void TestQgsQuadrilateral::areaPerimeter() QCOMPARE( QgsQuadrilateral().area(), 0.0 ); QCOMPARE( QgsQuadrilateral().perimeter(), 0.0 ); - QgsQuadrilateral quad = QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), - QgsQuadrilateral::Projected ); + QgsQuadrilateral quad = QgsQuadrilateral::rectangleFrom3Points( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5 ), QgsPoint( 5, 4 ), QgsQuadrilateral::Projected ); QVERIFY( qgsDoubleNear( quad.area(), 25.0 ) ); QVERIFY( qgsDoubleNear( quad.perimeter(), 20 ) ); } void TestQgsQuadrilateral::toString() { - QCOMPARE( QgsQuadrilateral( ).toString(), QString( "Empty" ) ); + QCOMPARE( QgsQuadrilateral().toString(), QString( "Empty" ) ); QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 2.5, 2.5 ) ).toString(), QString( "Empty" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 5, 0 ) ).toString(), - QString( "Quadrilateral (Point 1: Point (0 0), Point 2: Point (0 5), Point 3: Point (5 5), Point 4: Point (5 0))" ) ); - QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 5, 0 ) ).toString(), - QString( "Quadrilateral (Point 1: Point Z (0 0 10), Point 2: Point Z (0 5 10), Point 3: Point Z (5 5 10), Point 4: Point Z (5 0 10))" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5 ), QgsPoint( 5, 0 ) ).toString(), QString( "Quadrilateral (Point 1: Point (0 0), Point 2: Point (0 5), Point 3: Point (5 5), Point 4: Point (5 0))" ) ); + QCOMPARE( QgsQuadrilateral::rectangleFromCenterPoint( QgsPoint( 2.5, 2.5, 10 ), QgsPoint( 5, 0 ) ).toString(), QString( "Quadrilateral (Point 1: Point Z (0 0 10), Point 2: Point Z (0 5 10), Point 3: Point Z (5 5 10), Point 4: Point Z (5 0 10))" ) ); } void TestQgsQuadrilateral::toPolygonToLineString() @@ -476,10 +370,8 @@ void TestQgsQuadrilateral::toPolygonToLineString() QgsLineString ext, extZ; QgsPolygon polyg, polygZ; - QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), - QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); - quad = QgsQuadrilateral( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), - QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); + QgsQuadrilateral quadZ( QgsPoint( 0, 0, 10 ), QgsPoint( 0, 5, 10 ), QgsPoint( 5, 5, 10 ), QgsPoint( 5, 0, 10 ) ); + quad = QgsQuadrilateral( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ), QgsPoint( 5, 0 ) ); ext.fromWkt( "LineString (0 0, 0 5, 5 5, 5 0, 0 0)" ); QCOMPARE( quad.toLineString()->asWkt(), ext.asWkt() ); diff --git a/tests/src/core/geometry/testqgsrectangle.cpp b/tests/src/core/geometry/testqgsrectangle.cpp index 591d2b052a60..a85590c2f836 100644 --- a/tests/src/core/geometry/testqgsrectangle.cpp +++ b/tests/src/core/geometry/testqgsrectangle.cpp @@ -20,7 +20,7 @@ #include #include "qgsreferencedgeometry.h" -class TestQgsRectangle: public QObject +class TestQgsRectangle : public QObject { Q_OBJECT private slots: @@ -71,8 +71,7 @@ void TestQgsRectangle::isEmpty() void TestQgsRectangle::isNull() { QVERIFY( QgsRectangle().isNull() ); - QVERIFY( QgsRectangle( std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN() ).isNull() ); + QVERIFY( QgsRectangle( std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN() ).isNull() ); QVERIFY( !QgsRectangle( 0.0, 0.0, 0.0, 0.0 ).isNull() ); QVERIFY( !QgsRectangle( 1.0, 1.0, 1.0, 1.0 ).isNull() ); QVERIFY( !QgsRectangle( std::numeric_limits::max(), -std::numeric_limits::max(), std::numeric_limits::max(), -std::numeric_limits::max() ).isNull() ); @@ -83,7 +82,7 @@ void TestQgsRectangle::isNull() void TestQgsRectangle::fromWkt() { QgsRectangle rect = QgsRectangle::fromWkt( QStringLiteral( "POLYGON((0 0,1 0,1 1,0 1,0 0))" ) ); - QVERIFY( ! rect.isNull() ); + QVERIFY( !rect.isNull() ); QCOMPARE( rect.xMinimum(), 0.0 ); QCOMPARE( rect.yMinimum(), 0.0 ); QCOMPARE( rect.xMaximum(), 1.0 ); @@ -92,7 +91,7 @@ void TestQgsRectangle::fromWkt() QVERIFY( rect == QgsRectangle::fromWkt( rect.asWktPolygon() ) ); rect = QgsRectangle::fromWkt( QStringLiteral( "POLYGONZ((0 0 2,1 0 2,1 1 2,0 1 2,0 0 2))" ) ); - QVERIFY( ! rect.isNull() ); + QVERIFY( !rect.isNull() ); QCOMPARE( rect.xMinimum(), 0.0 ); QCOMPARE( rect.yMinimum(), 0.0 ); QCOMPARE( rect.xMaximum(), 1.0 ); @@ -102,7 +101,7 @@ void TestQgsRectangle::fromWkt() // this is ok, a single rectangular polygon in a multipolygon object rect = QgsRectangle::fromWkt( QStringLiteral( "MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))" ) ); - QVERIFY( ! rect.isNull() ); + QVERIFY( !rect.isNull() ); QCOMPARE( rect.xMinimum(), 0.0 ); QCOMPARE( rect.yMinimum(), 0.0 ); QCOMPARE( rect.xMaximum(), 1.0 ); @@ -111,7 +110,7 @@ void TestQgsRectangle::fromWkt() // this is ok, a single rectangular polygon in a collection rect = QgsRectangle::fromWkt( QStringLiteral( "GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0))))" ) ); - QVERIFY( ! rect.isNull() ); + QVERIFY( !rect.isNull() ); QCOMPARE( rect.xMinimum(), 0.0 ); QCOMPARE( rect.yMinimum(), 0.0 ); QCOMPARE( rect.xMaximum(), 1.0 ); @@ -214,7 +213,7 @@ void TestQgsRectangle::setXY() void TestQgsRectangle::fromCenter() { QgsRectangle rect = QgsRectangle::fromCenterAndSize( QgsPointXY( 12, 21 ), 20, 40 ); - QVERIFY( ! rect.isEmpty() ); + QVERIFY( !rect.isEmpty() ); QCOMPARE( rect.xMinimum(), 2.0 ); QCOMPARE( rect.yMinimum(), 1.0 ); QCOMPARE( rect.xMaximum(), 22.0 ); @@ -251,7 +250,7 @@ void TestQgsRectangle::intersects() QVERIFY( !rect2.intersects( rect1 ) ); // rect2 is still null - rects do not intersect - rect2.set( std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN() ); + rect2.set( std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN() ); QVERIFY( !rect1.isNull() ); QVERIFY( rect2.isNull() ); QVERIFY( !rect1.intersects( rect2 ) ); @@ -281,7 +280,7 @@ void TestQgsRectangle::manipulate() // And check that the result is contained in both QVERIFY( rect1.contains( rect3 ) ); QVERIFY( rect2.contains( rect3 ) ); - QVERIFY( ! rect2.contains( rect1 ) ); + QVERIFY( !rect2.contains( rect1 ) ); // Create the union rect3.combineExtentWith( rect1 ); @@ -366,10 +365,10 @@ void TestQgsRectangle::asVariant() QCOMPARE( var.userType(), qMetaTypeId() ); const QgsRectangle rect2 = qvariant_cast( var ); -#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0)) - QVERIFY( !var.convert( QMetaType::fromType() ) ); +#if ( QT_VERSION > QT_VERSION_CHECK( 6, 0, 0 ) ) + QVERIFY( !var.convert( QMetaType::fromType() ) ); #else - QVERIFY( !var.convert( qMetaTypeId() ) ); + QVERIFY( !var.convert( qMetaTypeId() ) ); #endif QCOMPARE( rect2.xMinimum(), rect1.xMinimum() ); diff --git a/tests/src/core/geometry/testqgsregularpolygon.cpp b/tests/src/core/geometry/testqgsregularpolygon.cpp index f7a568346ad6..662cc27097d1 100644 --- a/tests/src/core/geometry/testqgsregularpolygon.cpp +++ b/tests/src/core/geometry/testqgsregularpolygon.cpp @@ -23,7 +23,7 @@ #include "testgeometryutils.h" -class TestQgsRegularPolygon: public QObject +class TestQgsRegularPolygon : public QObject { Q_OBJECT private slots: @@ -41,34 +41,30 @@ void TestQgsRegularPolygon::constructors() QVERIFY( rp1.center().isEmpty() ); QVERIFY( rp1.firstVertex().isEmpty() ); - QCOMPARE( rp1.numberSides(), static_cast< unsigned int >( 0 ) ); + QCOMPARE( rp1.numberSides(), static_cast( 0 ) ); QCOMPARE( rp1.radius(), 0.0 ); QVERIFY( rp1.isEmpty() ); QgsRegularPolygon rp2; - rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 2, - QgsRegularPolygon::InscribedCircle ); + rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 2, QgsRegularPolygon::InscribedCircle ); QVERIFY( rp2.isEmpty() ); - rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, - static_cast< QgsRegularPolygon::ConstructionOption >( 4 ) ); + rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, static_cast( 4 ) ); QVERIFY( rp2.isEmpty() ); - rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, - QgsRegularPolygon::InscribedCircle ); + rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, QgsRegularPolygon::InscribedCircle ); QVERIFY( !rp2.isEmpty() ); QCOMPARE( rp2.center(), QgsPoint( 0, 0 ) ); QCOMPARE( rp2.firstVertex(), QgsPoint( 0, 5 ) ); - QCOMPARE( rp2.numberSides(), static_cast< unsigned int>( 5 ) ); + QCOMPARE( rp2.numberSides(), static_cast( 5 ) ); QCOMPARE( rp2.radius(), 5.0 ); QGSCOMPARENEAR( rp2.apothem(), 4.0451, 10E-4 ); - QVERIFY( rp2 == QgsRegularPolygon( QgsPoint( 0, 0 ), -5, 0, 5, QgsRegularPolygon::InscribedCircle ) ); + QVERIFY( rp2 == QgsRegularPolygon( QgsPoint( 0, 0 ), -5, 0, 5, QgsRegularPolygon::InscribedCircle ) ); QgsRegularPolygon rp3; - rp3 = QgsRegularPolygon( QgsPoint( 0, 0 ), rp2.apothem(), 36.0, 5, - QgsRegularPolygon::CircumscribedCircle ); + rp3 = QgsRegularPolygon( QgsPoint( 0, 0 ), rp2.apothem(), 36.0, 5, QgsRegularPolygon::CircumscribedCircle ); QVERIFY( rp2 == rp3 ); QVERIFY( rp2 == QgsRegularPolygon( QgsPoint( 0, 0 ), -rp2.apothem(), 36.0, 5, QgsRegularPolygon::CircumscribedCircle ) ); @@ -80,24 +76,19 @@ void TestQgsRegularPolygon::constructors() QgsRegularPolygon rp4 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), 2, QgsRegularPolygon::InscribedCircle ); QVERIFY( rp4.isEmpty() ); - rp4 = QgsRegularPolygon( QgsPoint(), QgsPoint( 0, 5 ), 5, - static_cast< QgsRegularPolygon::ConstructionOption >( 4 ) ); + rp4 = QgsRegularPolygon( QgsPoint(), QgsPoint( 0, 5 ), 5, static_cast( 4 ) ); QVERIFY( rp4.isEmpty() ); - rp4 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), 5, - QgsRegularPolygon::InscribedCircle ); + rp4 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), 5, QgsRegularPolygon::InscribedCircle ); QVERIFY( rp4 == rp2 ); - QgsRegularPolygon rp5 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ).project( rp2.apothem(), 36.0 ), 2, - QgsRegularPolygon::CircumscribedCircle ); + QgsRegularPolygon rp5 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ).project( rp2.apothem(), 36.0 ), 2, QgsRegularPolygon::CircumscribedCircle ); QVERIFY( rp5.isEmpty() ); - rp5 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ).project( rp2.apothem(), 36.0 ), 5, - static_cast< QgsRegularPolygon::ConstructionOption >( 4 ) ); + rp5 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ).project( rp2.apothem(), 36.0 ), 5, static_cast( 4 ) ); QVERIFY( rp5.isEmpty() ); - rp5 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ).project( rp2.apothem(), 36.0 ), 5, - QgsRegularPolygon::CircumscribedCircle ); + rp5 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 0 ).project( rp2.apothem(), 36.0 ), 5, QgsRegularPolygon::CircumscribedCircle ); QVERIFY( rp5 == rp2 ); QgsRegularPolygon rp6 = QgsRegularPolygon( QgsPoint( 0, 5 ), QgsPoint( 0, 0 ).project( 5.0, 72 ), 5 ); @@ -114,19 +105,19 @@ void TestQgsRegularPolygon::settersGetters() rp.setNumberSides( 2 ); QVERIFY( rp.isEmpty() ); - QCOMPARE( rp.numberSides(), static_cast< unsigned int >( 0 ) ); + QCOMPARE( rp.numberSides(), static_cast( 0 ) ); rp.setNumberSides( 5 ); QVERIFY( rp.isEmpty() ); - QCOMPARE( rp.numberSides(), static_cast< unsigned int >( 5 ) ); + QCOMPARE( rp.numberSides(), static_cast( 5 ) ); rp.setNumberSides( 2 ); QVERIFY( rp.isEmpty() ); - QCOMPARE( rp.numberSides(), static_cast< unsigned int >( 5 ) ); + QCOMPARE( rp.numberSides(), static_cast( 5 ) ); rp.setNumberSides( 3 ); QVERIFY( rp.isEmpty() ); - QCOMPARE( rp.numberSides(), static_cast< unsigned int >( 3 ) ); + QCOMPARE( rp.numberSides(), static_cast( 3 ) ); rp.setRadius( -6 ); QVERIFY( !rp.isEmpty() ); @@ -161,8 +152,7 @@ void TestQgsRegularPolygon::measures() QGSCOMPARENEAR( rp1.perimeter(), 0.0, 10e-4 ); QgsRegularPolygon rp2; - rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, - QgsRegularPolygon::InscribedCircle ); + rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, QgsRegularPolygon::InscribedCircle ); QGSCOMPARENEAR( rp2.length(), 5.8779, 10e-4 ); QGSCOMPARENEAR( rp2.area(), 59.4410, 10e-4 ); @@ -194,8 +184,7 @@ void TestQgsRegularPolygon::points() QgsPointSequence points = rp.points(); QVERIFY( points.isEmpty() ); - rp = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), 3, - QgsRegularPolygon::InscribedCircle ); + rp = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), 3, QgsRegularPolygon::InscribedCircle ); points = rp.points(); QCOMPARE( points.count(), 3 ); @@ -213,22 +202,19 @@ void TestQgsRegularPolygon::toString() rp = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, QgsRegularPolygon::InscribedCircle ); QCOMPARE( rp.toString(), QString( "RegularPolygon (Center: Point (0 0), First Vertex: Point (0 5), Radius: 5, Azimuth: 0)" ) ); - } void TestQgsRegularPolygon::conversions() { QgsRegularPolygon rp; - rp = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, - QgsRegularPolygon::InscribedCircle ); + rp = QgsRegularPolygon( QgsPoint( 0, 0 ), 5, 0, 5, QgsRegularPolygon::InscribedCircle ); // circle QVERIFY( QgsCircle( QgsPoint( 0, 0 ), 5 ) == rp.circumscribedCircle() ); QgsCircle circleExpected; - circleExpected = QgsRegularPolygon( QgsPoint( 0, 0 ), rp.apothem(), 36.0, 5, - QgsRegularPolygon::InscribedCircle ).circumscribedCircle(); - QVERIFY( rp.inscribedCircle() == circleExpected ); + circleExpected = QgsRegularPolygon( QgsPoint( 0, 0 ), rp.apothem(), 36.0, 5, QgsRegularPolygon::InscribedCircle ).circumscribedCircle(); + QVERIFY( rp.inscribedCircle() == circleExpected ); // triangle QCOMPARE( QgsTriangle(), rp.toTriangle() ); @@ -240,7 +226,7 @@ void TestQgsRegularPolygon::conversions() rp = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 4 ), 4 ); QVector rp_tri = rp.triangulate(); - QCOMPARE( rp_tri.length(), static_cast< int >( rp.numberSides() ) ); + QCOMPARE( rp_tri.length(), static_cast( rp.numberSides() ) ); QVERIFY( rp_tri.at( 0 ) == QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 4 ), rp.center() ) ); QVERIFY( rp_tri.at( 1 ) == QgsTriangle( QgsPoint( 0, 4 ), QgsPoint( 4, 4 ), rp.center() ) ); QVERIFY( rp_tri.at( 2 ) == QgsTriangle( QgsPoint( 4, 4 ), QgsPoint( 4, 0 ), rp.center() ) ); @@ -249,11 +235,11 @@ void TestQgsRegularPolygon::conversions() QVERIFY( QgsRegularPolygon().triangulate().isEmpty() ); // polygon - std::unique_ptr< QgsPolygon > toP( QgsRegularPolygon().toPolygon() ); + std::unique_ptr toP( QgsRegularPolygon().toPolygon() ); QVERIFY( toP->isEmpty() ); QgsPointSequence ptsPol; - std::unique_ptr< QgsPolygon > pol( new QgsPolygon() ); + std::unique_ptr pol( new QgsPolygon() ); pol.reset( rp.toPolygon() ); QCOMPARE( pol->numInteriorRings(), 0 ); @@ -271,13 +257,12 @@ void TestQgsRegularPolygon::conversions() ptsPol.pop_back(); QgsRegularPolygon rp2; - rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), 1, - QgsRegularPolygon::InscribedCircle ); + rp2 = QgsRegularPolygon( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), 1, QgsRegularPolygon::InscribedCircle ); - std::unique_ptr< QgsLineString > ls( rp2.toLineString() ); + std::unique_ptr ls( rp2.toLineString() ); QVERIFY( ls->isEmpty() ); - ls.reset( rp.toLineString( ) ); + ls.reset( rp.toLineString() ); QCOMPARE( ls->numPoints(), 5 ); QCOMPARE( ls->pointN( 0 ), ls->pointN( 4 ) ); diff --git a/tests/src/core/geometry/testqgstriangle.cpp b/tests/src/core/geometry/testqgstriangle.cpp index e3f867f021b9..34d950a11d2b 100644 --- a/tests/src/core/geometry/testqgstriangle.cpp +++ b/tests/src/core/geometry/testqgstriangle.cpp @@ -23,7 +23,7 @@ #include "testgeometryutils.h" -class TestQgsTriangle: public QObject +class TestQgsTriangle : public QObject { Q_OBJECT @@ -159,9 +159,7 @@ void TestQgsTriangle::constructor3Points() void TestQgsTriangle::constructorZM() { // Z - QgsTriangle tr = QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 0, 5, 1 ), - QgsPoint( Qgis::WkbType::PointZ, 0, 0, 2 ), - QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) ); + QgsTriangle tr = QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 0, 5, 1 ), QgsPoint( Qgis::WkbType::PointZ, 0, 0, 2 ), QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) ); QVERIFY( !tr.isEmpty() ); QVERIFY( tr.is3D() ); @@ -171,9 +169,7 @@ void TestQgsTriangle::constructorZM() QCOMPARE( tr.geometryType(), QString( "Triangle" ) ); // M - tr = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 0, 5, 0, 1 ), - QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 2 ), - QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) ); + tr = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 0, 5, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 2 ), QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 3 ) ); QVERIFY( !tr.isEmpty() ); QVERIFY( !tr.is3D() ); @@ -183,9 +179,7 @@ void TestQgsTriangle::constructorZM() QCOMPARE( tr.geometryType(), QString( "Triangle" ) ); // ZM - tr = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 5, 8, 1 ), - QgsPoint( Qgis::WkbType::PointZM, 0, 0, 5, 2 ), - QgsPoint( Qgis::WkbType::PointZM, 10, 10, 2, 3 ) ); + tr = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 5, 8, 1 ), QgsPoint( Qgis::WkbType::PointZM, 0, 0, 5, 2 ), QgsPoint( Qgis::WkbType::PointZM, 10, 10, 2, 3 ) ); QVERIFY( !tr.isEmpty() ); QVERIFY( tr.is3D() ); @@ -197,21 +191,17 @@ void TestQgsTriangle::constructorZM() void TestQgsTriangle::constructorQgsPointXY() { - QgsTriangle tr = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), - QgsPoint( 10, 10 ) ); + QgsTriangle tr = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), QgsPoint( 10, 10 ) ); - QgsTriangle t_qgspoint = QgsTriangle( QgsPointXY( 0, 0 ), QgsPointXY( 0, 10 ), - QgsPointXY( 10, 10 ) ); + QgsTriangle t_qgspoint = QgsTriangle( QgsPointXY( 0, 0 ), QgsPointXY( 0, 10 ), QgsPointXY( 10, 10 ) ); QVERIFY( tr == t_qgspoint ); } void TestQgsTriangle::constructorQPointF() { - QgsTriangle tr = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), - QgsPoint( 10, 10 ) ); + QgsTriangle tr = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), QgsPoint( 10, 10 ) ); - QgsTriangle t_pointf = QgsTriangle( QPointF( 0, 0 ), QPointF( 0, 10 ), - QPointF( 10, 10 ) ); + QgsTriangle t_pointf = QgsTriangle( QPointF( 0, 0 ), QPointF( 0, 10 ), QPointF( 10, 10 ) ); QVERIFY( tr == t_pointf ); } @@ -230,9 +220,8 @@ void TestQgsTriangle::exteriorRing() QVERIFY( !tr.interiorRing( 0 ) ); QCOMPARE( tr.wkbType(), Qgis::WkbType::Triangle ); - std::unique_ptr< QgsLineString > ext( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) << QgsPoint( 0, 0 ) ); + std::unique_ptr ext( new QgsLineString() ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 0, 0 ) ); QVERIFY( ext->isClosed() ); @@ -256,12 +245,11 @@ void TestQgsTriangle::exteriorRing() QVERIFY( !tr.interiorRing( 0 ) ); //retrieve exterior ring and check - QCOMPARE( *( static_cast< const QgsLineString * >( tr.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( tr.exteriorRing() ) ), *ext ); //set new ExteriorRing ext.reset( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 10 ) << QgsPoint( 5, 5 ) - << QgsPoint( 10, 10 ) << QgsPoint( 0, 10 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 10 ) << QgsPoint( 5, 5 ) << QgsPoint( 10, 10 ) << QgsPoint( 0, 10 ) ); QVERIFY( ext->isClosed() ); tr.setExteriorRing( ext->clone() ); @@ -282,7 +270,7 @@ void TestQgsTriangle::exteriorRing() QGSCOMPARENEAR( tr.perimeter(), 24.1421, 0.001 ); QVERIFY( tr.exteriorRing() ); QVERIFY( !tr.interiorRing( 0 ) ); - QCOMPARE( *( static_cast< const QgsLineString * >( tr.exteriorRing() ) ), *ext ); + QCOMPARE( *( static_cast( tr.exteriorRing() ) ), *ext ); } void TestQgsTriangle::exteriorRingZM() @@ -291,8 +279,7 @@ void TestQgsTriangle::exteriorRingZM() // AddZ QgsLineString lz; - lz.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 11, 12, 13 ) - << QgsPoint( 1, 12, 23 ) << QgsPoint( 1, 2, 3 ) ); + lz.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3 ) << QgsPoint( 11, 12, 13 ) << QgsPoint( 1, 12, 23 ) << QgsPoint( 1, 2, 3 ) ); tr.setExteriorRing( lz.clone() ); QVERIFY( tr.is3D() ); @@ -301,14 +288,13 @@ void TestQgsTriangle::exteriorRingZM() QCOMPARE( tr.wktTypeStr(), QString( "Triangle Z" ) ); QCOMPARE( tr.geometryType(), QString( "Triangle" ) ); QCOMPARE( tr.dimension(), 2 ); - QCOMPARE( tr.vertexAt( 0 ).z(), 3.0 ); + QCOMPARE( tr.vertexAt( 0 ).z(), 3.0 ); QCOMPARE( tr.vertexAt( 1 ).z(), 13.0 ); QCOMPARE( tr.vertexAt( 2 ).z(), 23.0 ); // AddM QgsLineString lzm; - lzm.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) - << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); + lzm.setPoints( QgsPointSequence() << QgsPoint( 1, 2, 3, 4 ) << QgsPoint( 11, 12, 13, 14 ) << QgsPoint( 1, 12, 23, 24 ) << QgsPoint( 1, 2, 3, 4 ) ); tr.setExteriorRing( lzm.clone() ); @@ -318,7 +304,7 @@ void TestQgsTriangle::exteriorRingZM() QCOMPARE( tr.wktTypeStr(), QString( "Triangle ZM" ) ); QCOMPARE( tr.geometryType(), QString( "Triangle" ) ); QCOMPARE( tr.dimension(), 2 ); - QCOMPARE( tr.vertexAt( 0 ).m(), 4.0 ); + QCOMPARE( tr.vertexAt( 0 ).m(), 4.0 ); QCOMPARE( tr.vertexAt( 1 ).m(), 14.0 ); QCOMPARE( tr.vertexAt( 2 ).m(), 24.0 ); @@ -354,24 +340,21 @@ void TestQgsTriangle::invalidExteriorRing() QgsTriangle tr; // invalid exterior ring - std::unique_ptr< QgsLineString > ext( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) << QgsPoint( 5, 10 ) ); + std::unique_ptr ext( new QgsLineString() ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 5, 10 ) ); tr.setExteriorRing( ext.release() ); QVERIFY( tr.isEmpty() ); ext.reset( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 0, 0 ) ); tr.setExteriorRing( ext.release() ); QVERIFY( tr.isEmpty() ); // degenerate case ext.reset( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 0, 0 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 0, 0 ) ); tr.setExteriorRing( ext.release() ); QVERIFY( !tr.isEmpty() ); @@ -379,8 +362,7 @@ void TestQgsTriangle::invalidExteriorRing() // circular ring QgsCircularString *circularRing = new QgsCircularString(); tr.clear(); - circularRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) - << QgsPoint( 10, 10 ) ); + circularRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) ); QVERIFY( circularRing->hasCurvedSegments() ); tr.setExteriorRing( circularRing ); @@ -392,7 +374,7 @@ void TestQgsTriangle::invalidNumberOfPoints() { QgsTriangle tr; - std::unique_ptr< QgsLineString > ext( new QgsLineString() ); + std::unique_ptr ext( new QgsLineString() ); ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) ); tr.setExteriorRing( ext.release() ); @@ -400,9 +382,7 @@ void TestQgsTriangle::invalidNumberOfPoints() ext.reset( new QgsLineString() ); tr.clear(); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 5, 10 ) << QgsPoint( 8, 10 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 5, 10 ) << QgsPoint( 8, 10 ) ); tr.setExteriorRing( ext.release() ); QVERIFY( tr.isEmpty() ); @@ -413,9 +393,8 @@ void TestQgsTriangle::nonClosedRing() QgsTriangle tr; // a non closed exterior ring will be automatically closed - std::unique_ptr< QgsLineString > ext( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) ); + std::unique_ptr ext( new QgsLineString() ); + ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) ); QVERIFY( !ext->isClosed() ); @@ -428,8 +407,7 @@ void TestQgsTriangle::nonClosedRing() void TestQgsTriangle::clone() { - QgsTriangle tr = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), - QgsPoint( 10, 10 ) ); + QgsTriangle tr = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), QgsPoint( 10, 10 ) ); QgsTriangle *trClone = tr.clone(); QCOMPARE( tr, *trClone ); @@ -440,32 +418,28 @@ void TestQgsTriangle::conversion() { QgsTriangle tr; - std::unique_ptr< QgsLineString > ext( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); + std::unique_ptr ext( new QgsLineString() ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); tr.setExteriorRing( ext.release() ); QgsPolygon polyExpected; ext.reset( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); polyExpected.setExteriorRing( ext.release() ); //toPolygon - std::unique_ptr< QgsPolygon > poly( tr.toPolygon() ); + std::unique_ptr poly( tr.toPolygon() ); QCOMPARE( *poly, polyExpected ); //surfaceToPolygon - std::unique_ptr< QgsPolygon > surface( tr.surfaceToPolygon() ); + std::unique_ptr surface( tr.surfaceToPolygon() ); QCOMPARE( *surface, polyExpected ); } void TestQgsTriangle::toCurveType() { QgsTriangle tr( QgsPoint( 7, 4 ), QgsPoint( 13, 3 ), QgsPoint( 9, 6 ) ); - std::unique_ptr< QgsCurvePolygon > curveType( tr.toCurveType() ); + std::unique_ptr curveType( tr.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::CurvePolygon ); QCOMPARE( curveType->exteriorRing()->numPoints(), 4 ); @@ -489,10 +463,8 @@ void TestQgsTriangle::toFromWkt() { QgsTriangle tr; - std::unique_ptr< QgsLineString > ext( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); + std::unique_ptr ext( new QgsLineString() ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) ); tr.setExteriorRing( ext.release() ); QString wkt = tr.asWkt(); @@ -518,8 +490,7 @@ void TestQgsTriangle::toFromWkb() QByteArray wkb; // WKB noZM - tWKB = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), - QgsPoint( 10, 10 ) ); + tWKB = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0, 10 ), QgsPoint( 10, 10 ) ); wkb = tWKB.asWkb(); QCOMPARE( wkb.size(), tWKB.wkbSize() ); @@ -545,8 +516,7 @@ void TestQgsTriangle::toFromWkb() QCOMPARE( pResult.wkbType(), Qgis::WkbType::Polygon ); // WKB Z - tWKB = QgsTriangle( QgsPoint( 0, 0, 1 ), QgsPoint( 0, 10, 2 ), - QgsPoint( 10, 10, 3 ) ); + tWKB = QgsTriangle( QgsPoint( 0, 0, 1 ), QgsPoint( 0, 10, 2 ), QgsPoint( 10, 10, 3 ) ); wkb = tWKB.asWkb(); QCOMPARE( wkb.size(), tWKB.wkbSize() ); @@ -571,10 +541,8 @@ void TestQgsTriangle::toFromWkb() // WKB M // tWKB=QgsTriangle (QgsPoint(0,0, 5), QgsPoint(0, 10, 6), QgsPoint(10, 10, 7)); will produce a TriangleZ - std::unique_ptr< QgsLineString > ext( new QgsLineString() ); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 5 ) - << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 6 ) - << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 7 ) ); + std::unique_ptr ext( new QgsLineString() ); + ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 5 ) << QgsPoint( Qgis::WkbType::PointM, 0, 10, 0, 6 ) << QgsPoint( Qgis::WkbType::PointM, 10, 10, 0, 7 ) ); tWKB.setExteriorRing( ext.release() ); wkb = tWKB.asWkb(); @@ -582,7 +550,7 @@ void TestQgsTriangle::toFromWkb() tResult.clear(); - QgsConstWkbPtr wkbPtrM( wkb ); + QgsConstWkbPtr wkbPtrM( wkb ); tResult.fromWkb( wkbPtrM ); QCOMPARE( tWKB.asWkt(), "Triangle M ((0 0 5, 0 10 6, 10 10 7, 0 0 5))" ); QCOMPARE( tWKB.wkbType(), Qgis::WkbType::TriangleM ); @@ -600,8 +568,7 @@ void TestQgsTriangle::toFromWkb() QCOMPARE( pResult.wkbType(), Qgis::WkbType::PolygonM ); // WKB ZM - tWKB = QgsTriangle( QgsPoint( 0, 0, 1, 5 ), QgsPoint( 0, 10, 2, 6 ), - QgsPoint( 10, 10, 3, 7 ) ); + tWKB = QgsTriangle( QgsPoint( 0, 0, 1, 5 ), QgsPoint( 0, 10, 2, 6 ), QgsPoint( 10, 10, 3, 7 ) ); wkb = tWKB.asWkb(); QCOMPARE( wkb.size(), tWKB.wkbSize() ); @@ -640,9 +607,7 @@ void TestQgsTriangle::toFromWkb() // even with FlagExportTrianglesAsPolygons QgsPolygon poly; QgsLineString ring; - ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + ring.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); poly.setExteriorRing( ring.clone() ); wkb = poly.asWkb( QgsAbstractGeometry::FlagExportTrianglesAsPolygons ); @@ -661,22 +626,14 @@ void TestQgsTriangle::toFromWkb() QgsConstWkbPtr wkbMultiRing( ba ); QVERIFY( !tInvalidWkb.fromWkb( wkbMultiRing ) ); QCOMPARE( tInvalidWkb, QgsTriangle() ); - - } void TestQgsTriangle::exportImport() { //asGML2 - QgsTriangle exportTriangle( QgsPoint( 1, 2 ), - QgsPoint( 3, 4 ), - QgsPoint( 6, 5 ) ); - QgsTriangle exportTriangleZ( QgsPoint( 1, 2, 3 ), - QgsPoint( 11, 12, 13 ), - QgsPoint( 1, 12, 23 ) ); - QgsTriangle exportTriangleFloat( QgsPoint( 1 + 1 / 3.0, 2 + 2 / 3.0 ), - QgsPoint( 3 + 1 / 3.0, 4 + 2 / 3.0 ), - QgsPoint( 6 + 1 / 3.0, 5 + 2 / 3.0 ) ); + QgsTriangle exportTriangle( QgsPoint( 1, 2 ), QgsPoint( 3, 4 ), QgsPoint( 6, 5 ) ); + QgsTriangle exportTriangleZ( QgsPoint( 1, 2, 3 ), QgsPoint( 11, 12, 13 ), QgsPoint( 1, 12, 23 ) ); + QgsTriangle exportTriangleFloat( QgsPoint( 1 + 1 / 3.0, 2 + 2 / 3.0 ), QgsPoint( 3 + 1 / 3.0, 4 + 2 / 3.0 ), QgsPoint( 6 + 1 / 3.0, 5 + 2 / 3.0 ) ); QDomDocument doc( QStringLiteral( "gml" ) ); QString expectedGML2( QStringLiteral( "1,2 3,4 6,5 1,2" ) ); QGSCOMPAREGML( elemToString( exportTriangle.asGml2( doc ) ), expectedGML2 ); @@ -779,9 +736,8 @@ void TestQgsTriangle::deleteVertex() { QgsTriangle tr( QgsPoint( 0, 0 ), QgsPoint( 100, 100 ), QgsPoint( 0, 200 ) ); - std::unique_ptr< QgsLineString > ring( new QgsLineString() ); - ring->setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) << QgsPoint( 50, 50 ) - << QgsPoint( 0, 25 ) << QgsPoint( 5, 5 ) ); + std::unique_ptr ring( new QgsLineString() ); + ring->setPoints( QgsPointSequence() << QgsPoint( 5, 5 ) << QgsPoint( 50, 50 ) << QgsPoint( 0, 25 ) << QgsPoint( 5, 5 ) ); tr.addInteriorRing( ring.release() ); QCOMPARE( tr.asWkt(), QString( "Triangle ((0 0, 100 100, 0 200, 0 0))" ) ); @@ -815,8 +771,7 @@ void TestQgsTriangle::types() QVERIFY( !tr.isScalene() ); QVERIFY( !tr.isEquilateral() ); - tr = QgsTriangle( QgsPoint( 7.2825, 4.2368 ), QgsPoint( 13.0058, 3.3218 ), - QgsPoint( 9.2145, 6.5242 ) ); + tr = QgsTriangle( QgsPoint( 7.2825, 4.2368 ), QgsPoint( 13.0058, 3.3218 ), QgsPoint( 9.2145, 6.5242 ) ); // angles in radians 58.8978;31.1036;89.9985 // length 5.79598;4.96279;2.99413 QVERIFY( !tr.isDegenerate() ); @@ -825,8 +780,7 @@ void TestQgsTriangle::types() QVERIFY( tr.isScalene() ); QVERIFY( !tr.isEquilateral() ); - tr = QgsTriangle( QgsPoint( 10, 10 ), QgsPoint( 16, 10 ), - QgsPoint( 13, 15.1962 ) ); + tr = QgsTriangle( QgsPoint( 10, 10 ), QgsPoint( 16, 10 ), QgsPoint( 13, 15.1962 ) ); QVERIFY( !tr.isDegenerate() ); QVERIFY( !tr.isRight() ); QVERIFY( tr.isIsocele() ); @@ -1004,14 +958,10 @@ void TestQgsTriangle::medial() QCOMPARE( QgsTriangle().medial(), QgsTriangle() ); QgsTriangle tr( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ); - QCOMPARE( tr.medial(), - QgsTriangle( QgsPoint( 0, 2.5 ), QgsPoint( 2.5, 5 ), QgsPoint( 2.5, 2.5 ) ) ); + QCOMPARE( tr.medial(), QgsTriangle( QgsPoint( 0, 2.5 ), QgsPoint( 2.5, 5 ), QgsPoint( 2.5, 2.5 ) ) ); tr = QgsTriangle( QgsPoint( 10, 10 ), QgsPoint( 16, 10 ), QgsPoint( 13, 15.1962 ) ); - QCOMPARE( tr.medial(), - QgsTriangle( QgsGeometryUtils::midpoint( tr.vertexAt( 0 ), tr.vertexAt( 1 ) ), - QgsGeometryUtils::midpoint( tr.vertexAt( 1 ), tr.vertexAt( 2 ) ), - QgsGeometryUtils::midpoint( tr.vertexAt( 2 ), tr.vertexAt( 0 ) ) ) ); + QCOMPARE( tr.medial(), QgsTriangle( QgsGeometryUtils::midpoint( tr.vertexAt( 0 ), tr.vertexAt( 1 ) ), QgsGeometryUtils::midpoint( tr.vertexAt( 1 ), tr.vertexAt( 2 ) ), QgsGeometryUtils::midpoint( tr.vertexAt( 2 ), tr.vertexAt( 0 ) ) ) ); } void TestQgsTriangle::bisectors() @@ -1037,21 +987,17 @@ void TestQgsTriangle::inscribedCircle() QCOMPARE( 0.0, QgsTriangle().inscribedRadius() ); QgsTriangle tr( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 5, 5 ) ); - QGSCOMPARENEARPOINT( QgsPoint( 1.4645, 3.5355 ), - tr.inscribedCenter(), 0.001 ); + QGSCOMPARENEARPOINT( QgsPoint( 1.4645, 3.5355 ), tr.inscribedCenter(), 0.001 ); QGSCOMPARENEAR( 1.4645, tr.inscribedRadius(), 0.0001 ); tr = QgsTriangle( QgsPoint( 20, 2 ), QgsPoint( 16, 6 ), QgsPoint( 26, 2 ) ); - QGSCOMPARENEARPOINT( QgsPoint( 20.4433, 3.0701 ), - tr.inscribedCenter(), 0.001 ); + QGSCOMPARENEARPOINT( QgsPoint( 20.4433, 3.0701 ), tr.inscribedCenter(), 0.001 ); QGSCOMPARENEAR( 1.0701, tr.inscribedRadius(), 0.0001 ); tr = QgsTriangle( QgsPoint( 10, 10 ), QgsPoint( 16, 10 ), QgsPoint( 13, 15.1962 ) ); - QGSCOMPARENEARPOINT( QgsPoint( 13, 11.7321 ), - tr.inscribedCenter(), 0.0001 ); + QGSCOMPARENEARPOINT( QgsPoint( 13, 11.7321 ), tr.inscribedCenter(), 0.0001 ); QGSCOMPARENEAR( 1.7321, tr.inscribedRadius(), 0.0001 ); - QGSCOMPARENEARPOINT( QgsPoint( 13, 11.7321 ), - tr.inscribedCircle().center(), 0.0001 ); + QGSCOMPARENEARPOINT( QgsPoint( 13, 11.7321 ), tr.inscribedCircle().center(), 0.0001 ); QGSCOMPARENEAR( 1.7321, tr.inscribedCircle().radius(), 0.0001 ); } @@ -1080,7 +1026,7 @@ void TestQgsTriangle::boundary() { QVERIFY( !QgsTriangle().boundary() ); - std::unique_ptr< QgsCurve > boundary( QgsTriangle( QgsPoint( 7, 4 ), QgsPoint( 13, 3 ), QgsPoint( 9, 6 ) ).boundary() ); + std::unique_ptr boundary( QgsTriangle( QgsPoint( 7, 4 ), QgsPoint( 13, 3 ), QgsPoint( 9, 6 ) ).boundary() ); QCOMPARE( boundary->wkbType(), Qgis::WkbType::LineString ); QCOMPARE( boundary->numPoints(), 4 ); diff --git a/tests/src/core/geometry/testqgstriangulatedsurface.cpp b/tests/src/core/geometry/testqgstriangulatedsurface.cpp index 3bd8124a4f8a..5b865f5b62f5 100644 --- a/tests/src/core/geometry/testqgstriangulatedsurface.cpp +++ b/tests/src/core/geometry/testqgstriangulatedsurface.cpp @@ -25,7 +25,7 @@ #include "qgstriangulatedsurface.h" #include "testgeometryutils.h" -class TestQgsTriangulatedSurface: public QObject +class TestQgsTriangulatedSurface : public QObject { Q_OBJECT @@ -134,7 +134,7 @@ void TestQgsTriangulatedSurface::testClone() { QgsTriangulatedSurface surface; - std::unique_ptr< QgsTriangulatedSurface >cloned( surface.clone() ); + std::unique_ptr cloned( surface.clone() ); QCOMPARE( surface, *cloned ); QgsTriangle *triangle = new QgsTriangle( QgsPoint( 4, 4 ), QgsPoint( 6, 10 ), QgsPoint( 10, 10 ) ); @@ -187,9 +187,7 @@ void TestQgsTriangulatedSurface::testAddPatch() // Try to add a Polygon which is not a Triangle QgsPolygon *notTriangle = new QgsPolygon(); QgsLineString notTriangleExterior; - notTriangleExterior.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) - << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + notTriangleExterior.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); QCOMPARE( notTriangleExterior.nCoordinates(), 5 ); notTriangle->setExteriorRing( notTriangleExterior.clone() ); surface.addPatch( notTriangle ); @@ -219,7 +217,7 @@ void TestQgsTriangulatedSurface::testAddPatch() QCOMPARE( surface.patchN( 1 )->wkbType(), Qgis::WkbType::Triangle ); // try adding a patch with zm to a 2d surface, z and m should be dropped - triangle = new QgsTriangle( QgsPoint( 10, 0, 1, 2 ), QgsPoint( 0, 10, 1, 2 ), QgsPoint( 10, 10, 1, 2 ) ); + triangle = new QgsTriangle( QgsPoint( 10, 0, 1, 2 ), QgsPoint( 0, 10, 1, 2 ), QgsPoint( 10, 10, 1, 2 ) ); surface.addPatch( triangle ); QCOMPARE( surface.numPatches(), 3 ); QVERIFY( !surface.is3D() ); @@ -233,7 +231,7 @@ void TestQgsTriangulatedSurface::testAddPatch() // addPatch without z/m to TriangleZM QgsTriangulatedSurface surface2; - triangle = new QgsTriangle( QgsPoint( 10, 0, 1, 2 ), QgsPoint( 0, 10, 1, 2 ), QgsPoint( 10, 10, 1, 2 ) ); + triangle = new QgsTriangle( QgsPoint( 10, 0, 1, 2 ), QgsPoint( 0, 10, 1, 2 ), QgsPoint( 10, 10, 1, 2 ) ); surface2.addTriangle( triangle ); QCOMPARE( surface2.numPatches(), 1 ); @@ -272,7 +270,7 @@ void TestQgsTriangulatedSurface::testAddPatch() void TestQgsTriangulatedSurface::testRemovePatch() { QgsTriangulatedSurface surface; - QVector< QgsTriangle * > patches; + QVector patches; QVERIFY( !surface.removePatch( -1 ) ); QVERIFY( !surface.removePatch( 0 ) ); @@ -308,12 +306,12 @@ void TestQgsTriangulatedSurface::testRemovePatch() void TestQgsTriangulatedSurface::testPatches() { QgsTriangulatedSurface surface; - QVector< QgsTriangle * > triangles; + QVector triangles; QgsTriangle *triangle1 = new QgsTriangle( QgsPoint( 0.1, 0.1, 2 ), QgsPoint( 0.1, 0.2, 2 ), QgsPoint( 0.2, 0.2, 2 ) ); triangles.append( triangle1 ); - QgsTriangle *triangle2 = new QgsTriangle( QgsPoint( 0.2, 0.1, 2 ), QgsPoint( 0.2, 0.2, 2 ), QgsPoint( 0.3, 0.2, 2 ) ); + QgsTriangle *triangle2 = new QgsTriangle( QgsPoint( 0.2, 0.1, 2 ), QgsPoint( 0.2, 0.2, 2 ), QgsPoint( 0.3, 0.2, 2 ) ); triangles.append( triangle2 ); surface.setTriangles( triangles ); @@ -331,13 +329,10 @@ void TestQgsTriangulatedSurface::testPatches() // Only the second polygon can be converted to a QgsTriangle // The QgsTriangulatedSurface only contains triangle3 - QVector< QgsPolygon * > patchesPolygons; + QVector patchesPolygons; QgsPolygon *polygonPatch = new QgsPolygon(); QgsLineString *exteriorRing = new QgsLineString(); - exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) - << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) - << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) - << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); + exteriorRing->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0.5, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 1 ) << QgsPoint( 1, 2 ) << QgsPoint( 0, 2 ) << QgsPoint( 0, 0 ) ); polygonPatch->setExteriorRing( exteriorRing ); patchesPolygons.append( polygonPatch ); @@ -404,19 +399,19 @@ void TestQgsTriangulatedSurface::testMoveVertex() QVERIFY( surface.moveVertex( QgsVertexId( 0, 0, 0 ), QgsPoint( 6.0, 7.0 ) ) ); QVERIFY( surface.moveVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 16.0, 17.0 ) ) ); QVERIFY( surface.moveVertex( QgsVertexId( 0, 0, 2 ), QgsPoint( 26.0, 27.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); // out of range QVERIFY( !surface.moveVertex( QgsVertexId( 0, 0, -1 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !surface.moveVertex( QgsVertexId( 0, 0, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !surface.moveVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 3.0, 4.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 6.0, 7.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 1 ), QgsPoint( 16.0, 17.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 2 ), QgsPoint( 26.0, 27.0 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 3 ), QgsPoint( 6.0, 7.0 ) ); // add a second triangle triangle = QgsTriangle( QgsPoint( 10, 10 ), QgsPoint( 12, 10 ), QgsPoint( 12, 12 ) ); @@ -425,10 +420,10 @@ void TestQgsTriangulatedSurface::testMoveVertex() QVERIFY( surface.moveVertex( QgsVertexId( 1, 0, 0 ), QgsPoint( 4.0, 5.0 ) ) ); QVERIFY( surface.moveVertex( QgsVertexId( 1, 0, 1 ), QgsPoint( 14.0, 15.0 ) ) ); QVERIFY( surface.moveVertex( QgsVertexId( 1, 0, 2 ), QgsPoint( 24.0, 25.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 4.0, 5.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 4.0, 5.0 ) ); // out of range QVERIFY( !surface.moveVertex( QgsVertexId( 1, 1, 0 ), QgsPoint( 3.0, 4.0 ) ) ); @@ -437,10 +432,10 @@ void TestQgsTriangulatedSurface::testMoveVertex() QVERIFY( !surface.moveVertex( QgsVertexId( 1, 1, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !surface.moveVertex( QgsVertexId( 1, 0, 10 ), QgsPoint( 3.0, 4.0 ) ) ); QVERIFY( !surface.moveVertex( QgsVertexId( 2, 0, 0 ), QgsPoint( 3.0, 4.0 ) ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); - QCOMPARE( static_cast< const QgsLineString * >( surface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 4.0, 5.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 0 ), QgsPoint( 4.0, 5.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 1 ), QgsPoint( 14.0, 15.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 2 ), QgsPoint( 24.0, 25.0 ) ); + QCOMPARE( static_cast( surface.patchN( 1 )->exteriorRing() )->pointN( 3 ), QgsPoint( 4.0, 5.0 ) ); } void TestQgsTriangulatedSurface::testDeleteVertex() @@ -470,7 +465,7 @@ void TestQgsTriangulatedSurface::testNextVertex() QgsPoint pt; QgsVertexId vId; - ( void )empty.closestSegment( QgsPoint( 1, 2 ), pt, vId ); // empty segment, just want no crash + ( void ) empty.closestSegment( QgsPoint( 1, 2 ), pt, vId ); // empty segment, just want no crash // nextVertex QgsTriangulatedSurface surfacePoly; @@ -512,7 +507,7 @@ void TestQgsTriangulatedSurface::testNextVertex() QVERIFY( !surfacePoly.nextVertex( vId, pt ) ); // add a second triangle - triangle = QgsTriangle( QgsPoint( 1, 2 ), QgsPoint( 11, 12 ), QgsPoint( 11, 2 ) ); + triangle = QgsTriangle( QgsPoint( 1, 2 ), QgsPoint( 11, 12 ), QgsPoint( 11, 2 ) ); surfacePoly.addPatch( triangle.clone() ); vId = QgsVertexId( 1, 1, 7 ); // out of range @@ -557,9 +552,9 @@ void TestQgsTriangulatedSurface::testVertexAngle() QgsTriangulatedSurface surface; // just want no crash - ( void )surface.vertexAngle( QgsVertexId() ); - ( void )surface.vertexAngle( QgsVertexId( 0, 0, 0 ) ); - ( void )surface.vertexAngle( QgsVertexId( 0, 1, 0 ) ); + ( void ) surface.vertexAngle( QgsVertexId() ); + ( void ) surface.vertexAngle( QgsVertexId( 0, 0, 0 ) ); + ( void ) surface.vertexAngle( QgsVertexId( 0, 1, 0 ) ); QgsTriangle triangle = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 0.5, 0 ), QgsPoint( 1, 2 ) ); surface.addPatch( triangle.clone() ); @@ -576,7 +571,7 @@ void TestQgsTriangulatedSurface::testVertexNumberFromVertexId() QgsTriangle triangle; // with only one triangle - triangle = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 1, 0 ), QgsPoint( 1, 1 ) ); + triangle = QgsTriangle( QgsPoint( 0, 0 ), QgsPoint( 1, 0 ), QgsPoint( 1, 1 ) ); surface.addPatch( triangle.clone() ); QCOMPARE( surface.vertexNumberFromVertexId( QgsVertexId( 0, 0, 0 ) ), 0 ); @@ -585,7 +580,7 @@ void TestQgsTriangulatedSurface::testVertexNumberFromVertexId() QCOMPARE( surface.vertexNumberFromVertexId( QgsVertexId( 0, 0, 3 ) ), 3 ); QCOMPARE( surface.vertexNumberFromVertexId( QgsVertexId( 0, 0, 4 ) ), -1 ); - triangle = QgsTriangle( QgsPoint( 1, 0 ), QgsPoint( 1, 1 ), QgsPoint( 2, 0 ) ); + triangle = QgsTriangle( QgsPoint( 1, 0 ), QgsPoint( 1, 1 ), QgsPoint( 2, 0 ) ); surface.addPatch( triangle.clone() ); QCOMPARE( surface.vertexNumberFromVertexId( QgsVertexId( 0, 0, 0 ) ), 0 ); @@ -620,7 +615,7 @@ void TestQgsTriangulatedSurface::testClosestSegment() QgsPoint pt; QgsVertexId v; int leftOf = 0; - ( void )empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty segment, just want no crash + ( void ) empty.closestSegment( QgsPoint( 1, 2 ), pt, v ); // empty segment, just want no crash QgsTriangulatedSurface surface; QgsTriangle triangle = QgsTriangle( QgsPoint( 5, 10 ), QgsPoint( 7, 12 ), QgsPoint( 5, 15 ) ); @@ -632,7 +627,7 @@ void TestQgsTriangulatedSurface::testClosestSegment() QCOMPARE( v, QgsVertexId( 0, 0, 3 ) ); QCOMPARE( leftOf, 1 ); - QGSCOMPARENEAR( surface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( surface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -672,7 +667,7 @@ void TestQgsTriangulatedSurface::testClosestSegment() QCOMPARE( v, QgsVertexId( 1, 0, 3 ) ); QCOMPARE( leftOf, -1 ); - QGSCOMPARENEAR( surface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); + QGSCOMPARENEAR( surface.closestSegment( QgsPoint( 8, 11 ), pt, v, &leftOf ), 2.0, 0.0001 ); QGSCOMPARENEAR( pt.x(), 7, 0.01 ); QGSCOMPARENEAR( pt.y(), 12, 0.01 ); QCOMPARE( v, QgsVertexId( 0, 0, 1 ) ); @@ -708,14 +703,12 @@ void TestQgsTriangulatedSurface::testBoundary() QgsTriangulatedSurface surface; QVERIFY( !surface.boundary() ); - QgsTriangle *triangle1 = new QgsTriangle( QgsPoint( 1, 2 ), - QgsPoint( 4, 5 ), - QgsPoint( 4, 3 ) ); + QgsTriangle *triangle1 = new QgsTriangle( QgsPoint( 1, 2 ), QgsPoint( 4, 5 ), QgsPoint( 4, 3 ) ); surface.addPatch( triangle1 ); QgsAbstractGeometry *boundary = surface.boundary(); QVERIFY( surface.boundary() ); - QgsMultiLineString *multiLineBoundary = dynamic_cast< QgsMultiLineString * >( boundary ); + QgsMultiLineString *multiLineBoundary = dynamic_cast( boundary ); QVERIFY( multiLineBoundary ); QCOMPARE( multiLineBoundary->numGeometries(), 1 ); QgsLineString *lineBoundary = multiLineBoundary->lineStringN( 0 ); @@ -733,12 +726,10 @@ void TestQgsTriangulatedSurface::testBoundary() surface.removePatch( 0 ); QCOMPARE( surface.numPatches(), 0 ); - QgsTriangle *triangleZ = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ), - QgsPoint( Qgis::WkbType::PointZ, 13, 14, 15 ), - QgsPoint( Qgis::WkbType::PointZ, 16, 17, 18 ) ); + QgsTriangle *triangleZ = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ), QgsPoint( Qgis::WkbType::PointZ, 13, 14, 15 ), QgsPoint( Qgis::WkbType::PointZ, 16, 17, 18 ) ); surface.addPatch( triangleZ ); boundary = surface.boundary(); - multiLineBoundary = dynamic_cast< QgsMultiLineString * >( boundary ); + multiLineBoundary = dynamic_cast( boundary ); QVERIFY( multiLineBoundary ); QCOMPARE( multiLineBoundary->numGeometries(), 1 ); lineBoundary = multiLineBoundary->lineStringN( 0 ); @@ -756,14 +747,10 @@ void TestQgsTriangulatedSurface::testBoundingBox() QgsTriangulatedSurface surface; QgsRectangle bBox = surface.boundingBox(); // no crash! - QgsTriangle *triangle1 = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ), - QgsPoint( Qgis::WkbType::PointZ, 4, 5, 6 ), - QgsPoint( Qgis::WkbType::PointZ, 7, 8, 9 ) ); + QgsTriangle *triangle1 = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ), QgsPoint( Qgis::WkbType::PointZ, 4, 5, 6 ), QgsPoint( Qgis::WkbType::PointZ, 7, 8, 9 ) ); surface.addPatch( triangle1 ); - QgsTriangle *triangle2 = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ), - QgsPoint( Qgis::WkbType::PointZ, 13, 14, 15 ), - QgsPoint( Qgis::WkbType::PointZ, 16, 17, 18 ) ); + QgsTriangle *triangle2 = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 10, 11, 12 ), QgsPoint( Qgis::WkbType::PointZ, 13, 14, 15 ), QgsPoint( Qgis::WkbType::PointZ, 16, 17, 18 ) ); surface.addPatch( triangle2 ); bBox = surface.boundingBox(); @@ -784,9 +771,7 @@ void TestQgsTriangulatedSurface::testBoundingBox3D() QCOMPARE( bBox.zMinimum(), std::numeric_limits::quiet_NaN() ); QCOMPARE( bBox.zMaximum(), std::numeric_limits::quiet_NaN() ); - QgsTriangle *triangle = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, -1, 0, 6 ), - QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ), - QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) ); + QgsTriangle *triangle = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, -1, 0, 6 ), QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ), QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) ); surface.addPatch( triangle ); bBox = surface.boundingBox3D(); @@ -807,7 +792,8 @@ void TestQgsTriangulatedSurface::testBoundingBoxIntersects() QgsTriangle *triangle1 = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ), - QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) ); + QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) + ); surface1.addPatch( triangle1 ); QVERIFY( surface1.boundingBoxIntersects( QgsRectangle( 1, 3, 6, 9 ) ) ); @@ -817,9 +803,7 @@ void TestQgsTriangulatedSurface::testBoundingBoxIntersects() QgsTriangulatedSurface surface2; QVERIFY( !surface2.boundingBoxIntersects( QgsBox3D( 1, 3, 1, 6, 9, 2 ) ) ); - QgsTriangle *triangle2 = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ), - QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ), - QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) ); + QgsTriangle *triangle2 = new QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointZ, 1, 10, 2 ), QgsPoint( Qgis::WkbType::PointZ, 0, 18, 3 ) ); surface2.addPatch( triangle2 ); QVERIFY( surface2.boundingBoxIntersects( QgsBox3D( 1, 3, 1, 6, 9, 2 ) ) ); @@ -835,9 +819,7 @@ void TestQgsTriangulatedSurface::testDropZValue() surface.dropZValue(); QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); - triangle = QgsTriangle( QgsPoint( 1, 2 ), - QgsPoint( 1, 4 ), - QgsPoint( 4, 4 ) ); + triangle = QgsTriangle( QgsPoint( 1, 2 ), QgsPoint( 1, 4 ), QgsPoint( 4, 4 ) ); surface.addPatch( triangle.clone() ); QCOMPARE( surface.numPatches(), 1 ); QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); @@ -845,39 +827,35 @@ void TestQgsTriangulatedSurface::testDropZValue() surface.dropZValue(); // not z QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::Triangle ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with z - triangle = QgsTriangle( QgsPoint( 10, 20, 3 ), - QgsPoint( 11, 12, 13 ), - QgsPoint( 1, 12, 23 ) ); + triangle = QgsTriangle( QgsPoint( 10, 20, 3 ), QgsPoint( 11, 12, 13 ), QgsPoint( 1, 12, 23 ) ); surface.clear(); surface.addPatch( triangle.clone() ); QCOMPARE( surface.wkbType(), Qgis::WkbType::TINZ ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::TriangleZ ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20, 3 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20, 3 ) ); surface.dropZValue(); QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::Triangle ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 10, 20 ) ); // with zm - triangle = QgsTriangle( QgsPoint( 1, 2, 3, 4 ), - QgsPoint( 11, 12, 13, 14 ), - QgsPoint( 1, 12, 23, 24 ) ); + triangle = QgsTriangle( QgsPoint( 1, 2, 3, 4 ), QgsPoint( 11, 12, 13, 14 ), QgsPoint( 1, 12, 23, 24 ) ); surface.clear(); surface.addPatch( triangle.clone() ); QCOMPARE( surface.wkbType(), Qgis::WkbType::TINZM ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::TriangleZM ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZM, 1, 2, 3, 4 ) ); surface.dropZValue(); QCOMPARE( surface.wkbType(), Qgis::WkbType::TINM ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::TriangleM ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 4 ) ); } void TestQgsTriangulatedSurface::testDropMValue() @@ -889,50 +867,44 @@ void TestQgsTriangulatedSurface::testDropMValue() surface.dropMValue(); QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); - triangle = QgsTriangle( QgsPoint( 1, 2 ), - QgsPoint( 11, 12 ), - QgsPoint( 1, 12 ) ); + triangle = QgsTriangle( QgsPoint( 1, 2 ), QgsPoint( 11, 12 ), QgsPoint( 1, 12 ) ); surface.addPatch( triangle.clone() ); QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); surface.dropMValue(); // not zm QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::Triangle ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with m - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ), - QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ), - QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ), QgsPoint( Qgis::WkbType::PointM, 11, 12, 0, 13 ), QgsPoint( Qgis::WkbType::PointM, 1, 12, 0, 23 ) ); surface.clear(); surface.addPatch( triangle.clone() ); QCOMPARE( surface.wkbType(), Qgis::WkbType::TINM ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::TriangleM ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointM, 1, 2, 0, 3 ) ); surface.dropMValue(); QCOMPARE( surface.wkbType(), Qgis::WkbType::TIN ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::Triangle ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2 ) ); // with zm - triangle = QgsTriangle( QgsPoint( 1, 2, 3, 4 ), - QgsPoint( 11, 12, 13, 14 ), - QgsPoint( 1, 12, 23, 24 ) ); + triangle = QgsTriangle( QgsPoint( 1, 2, 3, 4 ), QgsPoint( 11, 12, 13, 14 ), QgsPoint( 1, 12, 23, 24 ) ); surface.clear(); surface.addPatch( triangle.clone() ); QCOMPARE( surface.wkbType(), Qgis::WkbType::TINZM ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::TriangleZM ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2, 3, 4 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( 1, 2, 3, 4 ) ); surface.dropMValue(); QCOMPARE( surface.wkbType(), Qgis::WkbType::TINZ ); QCOMPARE( surface.patchN( 0 )->wkbType(), Qgis::WkbType::TriangleZ ); - QCOMPARE( static_cast< const QgsLineString *>( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); + QCOMPARE( static_cast( surface.patchN( 0 )->exteriorRing() )->pointN( 0 ), QgsPoint( Qgis::WkbType::PointZ, 1, 2, 3 ) ); } void TestQgsTriangulatedSurface::testWKB() @@ -975,14 +947,10 @@ void TestQgsTriangulatedSurface::testWKB() surface2.clear(); // TINM - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ), - QgsPoint( Qgis::WkbType::PointM, 1, 0, 0, 2 ), - QgsPoint( Qgis::WkbType::PointM, 1, 0.5, 0, 4 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 1, 0, 0, 2 ), QgsPoint( Qgis::WkbType::PointM, 1, 0.5, 0, 4 ) ); surface1.addPatch( triangle.clone() ); - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ), - QgsPoint( Qgis::WkbType::PointM, 0.1, 0, 0, 2 ), - QgsPoint( Qgis::WkbType::PointM, 0.1, 0.05, 0, 4 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointM, 0, 0, 0, 1 ), QgsPoint( Qgis::WkbType::PointM, 0.1, 0, 0, 2 ), QgsPoint( Qgis::WkbType::PointM, 0.1, 0.05, 0, 4 ) ); surface1.addPatch( triangle.clone() ); QCOMPARE( surface1.wkbType(), Qgis::WkbType::TINM ); @@ -995,14 +963,10 @@ void TestQgsTriangulatedSurface::testWKB() surface2.clear(); // TINZM - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), - QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ), - QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ), QgsPoint( Qgis::WkbType::PointZM, 1, 0.5, 13, 4 ) ); surface1.addPatch( triangle.clone() ); - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), - QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ), - QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ), QgsPoint( Qgis::WkbType::PointZM, 0.1, 0.05, 13, 4 ) ); surface1.addPatch( triangle.clone() ); QCOMPARE( surface1.wkbType(), Qgis::WkbType::TINZM ); @@ -1043,9 +1007,7 @@ void TestQgsTriangulatedSurface::testWKB() void TestQgsTriangulatedSurface::testWKT() { QgsTriangulatedSurface surface; - QgsTriangle triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), - QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ), - QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) ); + QgsTriangle triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), QgsPoint( Qgis::WkbType::PointZM, 0.1, 0, 11, 2 ), QgsPoint( Qgis::WkbType::PointZM, 0.2, 0, 12, 3 ) ); surface.addPatch( triangle.clone() ); QCOMPARE( surface.numPatches(), 1 ); @@ -1078,9 +1040,7 @@ void TestQgsTriangulatedSurface::testExport() // Z // as GML3 with one triangle - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ), - QgsPoint( Qgis::WkbType::PointZ, 1, 0, 11 ), - QgsPoint( Qgis::WkbType::PointZ, 2, 0, 12 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 0, 0, 10 ), QgsPoint( Qgis::WkbType::PointZ, 1, 0, 11 ), QgsPoint( Qgis::WkbType::PointZ, 2, 0, 12 ) ); exportPolygon.addPatch( triangle.clone() ); expectedSimpleGML3 = QString( QStringLiteral( "0 0 10 1 0 11 2 0 12 0 0 10" ) ); @@ -1088,9 +1048,7 @@ void TestQgsTriangulatedSurface::testExport() QCOMPARE( elemToString( exportPolygon.asGml3( doc ) ), expectedSimpleGML3 ); // as GML3 with two triangles - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 10, 10, 10 ), - QgsPoint( Qgis::WkbType::PointZ, 11, 10, 11 ), - QgsPoint( Qgis::WkbType::PointZ, 12, 10, 12 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZ, 10, 10, 10 ), QgsPoint( Qgis::WkbType::PointZ, 11, 10, 11 ), QgsPoint( Qgis::WkbType::PointZ, 12, 10, 12 ) ); exportPolygon.addPatch( triangle.clone() ); expectedSimpleGML3 = QString( QStringLiteral( "0 0 10 1 0 11 2 0 12 0 0 1010 10 10 11 10 11 12 10 12 10 10 10" ) ); @@ -1100,9 +1058,7 @@ void TestQgsTriangulatedSurface::testExport() // ZM // as GML3 with one triangle - M is dropped exportPolygon.clear(); - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), - QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ), - QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 0, 0, 10, 1 ), QgsPoint( Qgis::WkbType::PointZM, 1, 0, 11, 2 ), QgsPoint( Qgis::WkbType::PointZM, 2, 0, 12, 3 ) ); exportPolygon.addPatch( triangle.clone() ); expectedSimpleGML3 = QString( QStringLiteral( "0 0 10 1 0 11 2 0 12 0 0 10" ) ); @@ -1110,9 +1066,7 @@ void TestQgsTriangulatedSurface::testExport() QCOMPARE( elemToString( exportPolygon.asGml3( doc ) ), expectedSimpleGML3 ); // as GML3 with two triangles - M is dropped - triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 10, 10, 10, 1 ), - QgsPoint( Qgis::WkbType::PointZM, 11, 10, 11, 2 ), - QgsPoint( Qgis::WkbType::PointZM, 12, 10, 12, 3 ) ); + triangle = QgsTriangle( QgsPoint( Qgis::WkbType::PointZM, 10, 10, 10, 1 ), QgsPoint( Qgis::WkbType::PointZM, 11, 10, 11, 2 ), QgsPoint( Qgis::WkbType::PointZM, 12, 10, 12, 3 ) ); exportPolygon.addPatch( triangle.clone() ); expectedSimpleGML3 = QString( QStringLiteral( "0 0 10 1 0 11 2 0 12 0 0 1010 10 10 11 10 11 12 10 12 10 10 10" ) ); diff --git a/tests/src/core/geometry/testtransformer.h b/tests/src/core/geometry/testtransformer.h index f4d4cc4ffec4..bd2151acc092 100644 --- a/tests/src/core/geometry/testtransformer.h +++ b/tests/src/core/geometry/testtransformer.h @@ -18,7 +18,6 @@ class TestTransformer : public QgsAbstractGeometryTransformer { public: - bool transformPoint( double &x, double &y, double &z, double &m ) override { x *= 3; @@ -33,7 +32,6 @@ class TestTransformer : public QgsAbstractGeometryTransformer class TestFailTransformer : public QgsAbstractGeometryTransformer { public: - bool transformPoint( double &x, double &y, double &z, double &m ) override { x *= 3; @@ -43,4 +41,3 @@ class TestFailTransformer : public QgsAbstractGeometryTransformer return false; } }; - diff --git a/tests/src/core/test_template.cpp b/tests/src/core/test_template.cpp index b2f529d9b994..f0ee75a62cdd 100644 --- a/tests/src/core/test_template.cpp +++ b/tests/src/core/test_template.cpp @@ -18,16 +18,10 @@ //header for class being tested #include <[testClassLowerCaseName].h> -class Test[testClassCamelCaseName]: public QObject -{ - Q_OBJECT - private slots: +class Test[testClassCamelCaseName] : public QObject { + Q_OBJECT private slots: [TestMethods] }; QGSTEST_MAIN( Test[testClassCamelCaseName] ) #include "test[testClassLowerCaseName].moc" - - - - diff --git a/tests/src/core/testcontrastenhancements.cpp b/tests/src/core/testcontrastenhancements.cpp index fe8fa21a5082..55a8c076e6e0 100644 --- a/tests/src/core/testcontrastenhancements.cpp +++ b/tests/src/core/testcontrastenhancements.cpp @@ -29,22 +29,22 @@ * \ingroup UnitTests * This is a unit test for the ContrastEnhancements contrast enhancement classes. */ -class TestContrastEnhancements: public QgsTest +class TestContrastEnhancements : public QgsTest { Q_OBJECT public: - TestContrastEnhancements() : QgsTest( QStringLiteral( "Raster Contrast Enhancement Tests" ) ) {} + TestContrastEnhancements() + : QgsTest( QStringLiteral( "Raster Contrast Enhancement Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void clipMinMaxEnhancementTest(); void linearMinMaxEnhancementWithClipTest(); void linearMinMaxEnhancementTest(); - }; diff --git a/tests/src/core/testmaprendererjob.cpp b/tests/src/core/testmaprendererjob.cpp index 455dfc9d169a..1064d7191783 100644 --- a/tests/src/core/testmaprendererjob.cpp +++ b/tests/src/core/testmaprendererjob.cpp @@ -26,8 +26,8 @@ class TestQgsMapRendererJob : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testNormal(); @@ -73,7 +73,6 @@ void TestQgsMapRendererJob::initTestCase() mLayerIds << _loadLayer( "/data/gis/sas/trans-trail-l.dbf" ); mLayerIds << _loadLayer( "/data/gis/sas/bnd-ocean-a.shp" ); mLayerIds << _loadLayer( "/data/gis/sas/bnd-political-boundary-a.shp" ); - } void TestQgsMapRendererJob::cleanupTestCase() diff --git a/tests/src/core/testqgis.cpp b/tests/src/core/testqgis.cpp index 7badfd2cce18..cc08d4439744 100644 --- a/tests/src/core/testqgis.cpp +++ b/tests/src/core/testqgis.cpp @@ -43,11 +43,12 @@ class TestQgis : public QgsTest Q_ENUM( TestEnum ) public: - TestQgis() : QgsTest( QStringLiteral( "Qgis Tests" ) ) {} + TestQgis() + : QgsTest( QStringLiteral( "Qgis Tests" ) ) {} private slots: - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void permissiveToDouble(); void permissiveToInt(); @@ -153,7 +154,6 @@ void TestQgis::permissiveToLongLong() result = qgsPermissiveToLongLong( QStringLiteral( "10%0100" ).arg( QLocale().groupSeparator() ), ok ); QVERIFY( ok ); QCOMPARE( result, 1000 ); - } void TestQgis::doubleToString() @@ -191,7 +191,7 @@ void TestQgis::doubleToString() void TestQgis::signalBlocker() { - std::unique_ptr< QCheckBox > checkbox( new QCheckBox() ); + std::unique_ptr checkbox( new QCheckBox() ); QSignalSpy spy( checkbox.get(), &QCheckBox::toggled ); @@ -203,7 +203,7 @@ void TestQgis::signalBlocker() //block signals { - QgsSignalBlocker< QCheckBox > blocker( checkbox.get() ); + QgsSignalBlocker blocker( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); checkbox->setChecked( false ); @@ -224,7 +224,7 @@ void TestQgis::signalBlocker() // now check that initial blocking state is restored when QgsSignalBlocker goes out of scope checkbox->blockSignals( true ); { - QgsSignalBlocker< QCheckBox > blocker( checkbox.get() ); + QgsSignalBlocker blocker( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); } // initial blocked state should be restored @@ -233,10 +233,10 @@ void TestQgis::signalBlocker() // nested signal blockers { - QgsSignalBlocker< QCheckBox > blocker( checkbox.get() ); + QgsSignalBlocker blocker( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); { - QgsSignalBlocker< QCheckBox > blocker2( checkbox.get() ); + QgsSignalBlocker blocker2( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); } QVERIFY( checkbox->signalsBlocked() ); @@ -271,7 +271,7 @@ void TestQgis::qVariantCompare_data() QTest::newRow( "invalid to value 2" ) << QVariant( 2 ) << QVariant() << false << true; QTest::newRow( "invalid to null" ) << QVariant() << QgsVariantUtils::createNullVariant( QMetaType::Type::QString ) << true << false; QTest::newRow( "invalid to null2 " ) << QgsVariantUtils::createNullVariant( QMetaType::Type::QString ) << QVariant() << false << true; - QTest::newRow( "null to value" ) << QgsVariantUtils::createNullVariant( QMetaType::Type::QString ) << QVariant( "a" ) << true << false; + QTest::newRow( "null to value" ) << QgsVariantUtils::createNullVariant( QMetaType::Type::QString ) << QVariant( "a" ) << true << false; QTest::newRow( "null to value 2" ) << QVariant( "a" ) << QgsVariantUtils::createNullVariant( QMetaType::Type::QString ) << false << true; QTest::newRow( "int" ) << QVariant( 1 ) << QVariant( 2 ) << true << false; @@ -332,9 +332,9 @@ void TestQgis::testNanCompatibleEquals_data() QTest::addColumn( "rhs" ); QTest::addColumn( "expected" ); - QTest::newRow( "both nan" ) << std::numeric_limits< double >::quiet_NaN() << std::numeric_limits< double >::quiet_NaN() << true; - QTest::newRow( "first is nan" ) << std::numeric_limits< double >::quiet_NaN() << 5.0 << false; - QTest::newRow( "second is nan" ) << 5.0 << std::numeric_limits< double >::quiet_NaN() << false; + QTest::newRow( "both nan" ) << std::numeric_limits::quiet_NaN() << std::numeric_limits::quiet_NaN() << true; + QTest::newRow( "first is nan" ) << std::numeric_limits::quiet_NaN() << 5.0 << false; + QTest::newRow( "second is nan" ) << 5.0 << std::numeric_limits::quiet_NaN() << false; QTest::newRow( "two numbers, not equal" ) << 5.0 << 6.0 << false; QTest::newRow( "two numbers, equal" ) << 5.0 << 5.0 << true; } @@ -352,7 +352,6 @@ void TestQgis::testNanCompatibleEquals() class ConstTester { public: - void doSomething() { mVal = 1; @@ -405,7 +404,6 @@ void TestQgis::testQgsRound() void TestQgis::testQgsVariantEqual() { - // Invalid QVERIFY( qgsVariantEqual( QVariant(), QVariant() ) ); QVERIFY( QVariant() == QVariant() ); @@ -419,10 +417,10 @@ void TestQgis::testQgsVariantEqual() // This is what we actually wanted to fix with qgsVariantEqual // zero != NULL - QVERIFY( ! qgsVariantEqual( QVariant( 0 ), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ) ); - QVERIFY( ! qgsVariantEqual( QVariant( 0 ), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ) ); - QVERIFY( ! qgsVariantEqual( QVariant( 0.0f ), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ) ); - QVERIFY( ! qgsVariantEqual( QVariant( 0.0f ), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ) ); + QVERIFY( !qgsVariantEqual( QVariant( 0 ), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ) ); + QVERIFY( !qgsVariantEqual( QVariant( 0 ), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ) ); + QVERIFY( !qgsVariantEqual( QVariant( 0.0f ), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ) ); + QVERIFY( !qgsVariantEqual( QVariant( 0.0f ), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ) ); QVERIFY( QVariant( 0 ) == QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); // NULL identities @@ -437,9 +435,9 @@ void TestQgis::testQgsVariantEqual() void TestQgis::testQgsEnumMapList() { - QCOMPARE( qgsEnumList(), QList( {TestEnum::TestEnum1, TestEnum::TestEnum2, TestEnum::TestEnum3} ) ); - QCOMPARE( qgsEnumMap().keys(), QList( {TestEnum::TestEnum1, TestEnum::TestEnum2, TestEnum::TestEnum3} ) ); - QCOMPARE( qgsEnumMap().values(), QStringList( {QStringLiteral( "TestEnum1" ), QStringLiteral( "TestEnum2" ), QStringLiteral( "TestEnum3" ) } ) ); + QCOMPARE( qgsEnumList(), QList( { TestEnum::TestEnum1, TestEnum::TestEnum2, TestEnum::TestEnum3 } ) ); + QCOMPARE( qgsEnumMap().keys(), QList( { TestEnum::TestEnum1, TestEnum::TestEnum2, TestEnum::TestEnum3 } ) ); + QCOMPARE( qgsEnumMap().values(), QStringList( { QStringLiteral( "TestEnum1" ), QStringLiteral( "TestEnum2" ), QStringLiteral( "TestEnum3" ) } ) ); } @@ -449,7 +447,7 @@ void TestQgis::testQgsEnumValueToKey() QgsMapLayerModel::CustomRole value = QgsMapLayerModel::CustomRole::Layer; QgsMapLayerModel::CustomRole badValue = static_cast( -1 ); QMetaEnum metaEnum = QMetaEnum::fromType(); - QVERIFY( !metaEnum.valueToKey( static_cast< int >( badValue ) ) ); + QVERIFY( !metaEnum.valueToKey( static_cast( badValue ) ) ); QCOMPARE( qgsEnumValueToKey( value, &ok ), QStringLiteral( "Layer" ) ); QCOMPARE( ok, true ); QCOMPARE( qgsEnumValueToKey( badValue, &ok ), QString() ); @@ -467,13 +465,13 @@ void TestQgis::testQgsEnumKeyToValue() QCOMPARE( ok, false ); // try with int values as string keys - QCOMPARE( qgsEnumKeyToValue( QString::number( static_cast< int >( QgsMapLayerModel::CustomRole::Additional ) ), defaultValue, true, &ok ), QgsMapLayerModel::CustomRole::Additional ); + QCOMPARE( qgsEnumKeyToValue( QString::number( static_cast( QgsMapLayerModel::CustomRole::Additional ) ), defaultValue, true, &ok ), QgsMapLayerModel::CustomRole::Additional ); QCOMPARE( ok, true ); - QCOMPARE( qgsEnumKeyToValue( QString::number( static_cast< int >( QgsMapLayerModel::CustomRole::Additional ) ), defaultValue, false, &ok ), defaultValue ); + QCOMPARE( qgsEnumKeyToValue( QString::number( static_cast( QgsMapLayerModel::CustomRole::Additional ) ), defaultValue, false, &ok ), defaultValue ); QCOMPARE( ok, false ); // also try with an invalid int value QMetaEnum metaEnum = QMetaEnum::fromType(); - int invalidValue = static_cast< int >( defaultValue ) + 7894563; + int invalidValue = static_cast( defaultValue ) + 7894563; QVERIFY( !metaEnum.valueToKey( invalidValue ) ); QCOMPARE( qgsEnumKeyToValue( QString::number( invalidValue ), defaultValue, true, &ok ), defaultValue ); QCOMPARE( ok, false ); @@ -536,7 +534,7 @@ void TestQgis::testQMapQVariantList() void TestQgis::testQgsMapJoin() { - QMap< QString, int> map; + QMap map; map.insert( "tutu", 3 ); map.insert( "titi", 4 ); diff --git a/tests/src/core/testqgs25drenderer.cpp b/tests/src/core/testqgs25drenderer.cpp index 76069f332bf9..cab98d229145 100644 --- a/tests/src/core/testqgs25drenderer.cpp +++ b/tests/src/core/testqgs25drenderer.cpp @@ -43,13 +43,12 @@ class TestQgs25DRenderer : public QgsTest Q_OBJECT public: TestQgs25DRenderer() - : QgsTest( QStringLiteral( "25D Renderer Tests" ), - QStringLiteral( "25d_renderer" ) ) + : QgsTest( QStringLiteral( "25D Renderer Tests" ), QStringLiteral( "25d_renderer" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void render(); void renderLayout(); @@ -76,8 +75,7 @@ void TestQgs25DRenderer::initTestCase() // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -122,7 +120,7 @@ void TestQgs25DRenderer::renderLayout() QgsLayoutItemMap *map = new QgsLayoutItemMap( &l ); map->attemptSetSceneRect( QRectF( 20, 20, 200, 100 ) ); map->setFrameEnabled( true ); - map->setLayers( QList< QgsMapLayer * >() << mpPolysLayer ); + map->setLayers( QList() << mpPolysLayer ); l.addLayoutItem( map ); map->setExtent( mpPolysLayer->extent() ); diff --git a/tests/src/core/testqgsannotationitemregistry.cpp b/tests/src/core/testqgsannotationitemregistry.cpp index 6ad5e1790602..cb3e14c89c7e 100644 --- a/tests/src/core/testqgsannotationitemregistry.cpp +++ b/tests/src/core/testqgsannotationitemregistry.cpp @@ -31,10 +31,9 @@ //simple item for testing, since some methods in QgsAnnotationItem are pure virtual class TestItem : public QgsAnnotationItem { - public: - - TestItem() : QgsAnnotationItem() + TestItem() + : QgsAnnotationItem() { } @@ -66,15 +65,15 @@ class TestItem : public QgsAnnotationItem }; -class TestQgsAnnotationItemRegistry: public QObject +class TestQgsAnnotationItemRegistry : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void metadata(); void createInstance(); void instanceHasItems(); @@ -95,24 +94,20 @@ void TestQgsAnnotationItemRegistry::cleanupTestCase() void TestQgsAnnotationItemRegistry::init() { - } void TestQgsAnnotationItemRegistry::cleanup() { - } void TestQgsAnnotationItemRegistry::metadata() { - QgsAnnotationItemMetadata metadata = QgsAnnotationItemMetadata( QStringLiteral( "name" ), QStringLiteral( "display name" ), - QStringLiteral( "display names" ), - TestItem::create ); + QgsAnnotationItemMetadata metadata = QgsAnnotationItemMetadata( QStringLiteral( "name" ), QStringLiteral( "display name" ), QStringLiteral( "display names" ), TestItem::create ); QCOMPARE( metadata.type(), QString( "name" ) ); QCOMPARE( metadata.visibleName(), QString( "display name" ) ); //test creating item from metadata - const std::unique_ptr< QgsAnnotationItem > item( metadata.createItem() ); + const std::unique_ptr item( metadata.createItem() ); QVERIFY( item ); TestItem *dummyItem = dynamic_cast( item.get() ); QVERIFY( dummyItem ); @@ -143,16 +138,12 @@ void TestQgsAnnotationItemRegistry::addItem() const QSignalSpy spyTypeAdded( registry, &QgsAnnotationItemRegistry::typeAdded ); - registry->addItemType( new QgsAnnotationItemMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "display name" ), - QStringLiteral( "display names" ), - TestItem::create ) ); + registry->addItemType( new QgsAnnotationItemMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "display name" ), QStringLiteral( "display names" ), TestItem::create ) ); QCOMPARE( registry->itemTypes().size(), previousCount + 1 ); QCOMPARE( spyTypeAdded.count(), 1 ); //try adding again, should have no effect - QgsAnnotationItemMetadata *dupe = new QgsAnnotationItemMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "display name" ), - QStringLiteral( "display names" ), - TestItem::create ); - QVERIFY( ! registry->addItemType( dupe ) ); + QgsAnnotationItemMetadata *dupe = new QgsAnnotationItemMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "display name" ), QStringLiteral( "display names" ), TestItem::create ); + QVERIFY( !registry->addItemType( dupe ) ); QCOMPARE( spyTypeAdded.count(), 1 ); QCOMPARE( registry->itemTypes().size(), previousCount + 1 ); delete dupe; @@ -181,7 +172,7 @@ void TestQgsAnnotationItemRegistry::fetchTypes() void TestQgsAnnotationItemRegistry::createItem() { QgsAnnotationItemRegistry *registry = QgsApplication::annotationItemRegistry(); - std::unique_ptr< QgsAnnotationItem > item( registry->createItem( QStringLiteral( "Dummy" ) ) ); + std::unique_ptr item( registry->createItem( QStringLiteral( "Dummy" ) ) ); QVERIFY( item.get() ); TestItem *dummyItem = dynamic_cast( item.get() ); diff --git a/tests/src/core/testqgsapplication.cpp b/tests/src/core/testqgsapplication.cpp index 92ad1f655530..99d685fe1573 100644 --- a/tests/src/core/testqgsapplication.cpp +++ b/tests/src/core/testqgsapplication.cpp @@ -15,21 +15,19 @@ Email : sherman at mrcc dot com #include "qgstest.h" #include -#define CPL_SUPRESS_CPLUSPLUS //#spellok +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include //header for class being tested #include -class TestQgsApplication: public QgsTest +class TestQgsApplication : public QgsTest { Q_OBJECT public: - TestQgsApplication() - : QgsTest( QStringLiteral( "QgsApplication Tests" ), - QStringLiteral( "application" ) ) + : QgsTest( QStringLiteral( "QgsApplication Tests" ), QStringLiteral( "application" ) ) {} private slots: @@ -46,7 +44,6 @@ class TestQgsApplication: public QgsTest private: QString getQgisPath(); - }; @@ -115,7 +112,7 @@ void TestQgsApplication::themeIcon() // with colors icon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderParams.svg" ), QColor( 255, 100, 100 ), QColor( 255, 0, 0 ) ); im = QImage( icon.pixmap( 16, 16 ).toImage() ); - QVERIFY( QGSIMAGECHECK( QStringLiteral( "theme_icon_colors_1" ), QStringLiteral( "theme_icon_colors_1" ), im, QString(), 0 ) ); + QVERIFY( QGSIMAGECHECK( QStringLiteral( "theme_icon_colors_1" ), QStringLiteral( "theme_icon_colors_1" ), im, QString(), 0 ) ); // different colors icon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderParams.svg" ), QColor( 170, 255, 170 ), QColor( 0, 255, 0 ) ); diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index cc34a7dc95d7..b08069480a62 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -40,10 +40,10 @@ class TestQgsArcGisRestUtils : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testMapEsriFieldType(); void testParseSpatialReference(); void testParseSpatialReferenceEPSG(); @@ -68,13 +68,10 @@ class TestQgsArcGisRestUtils : public QObject void testParsePolylineZM(); private: - QVariantMap jsonStringToMap( const QString &string ) const; - }; - //runs before all tests void TestQgsArcGisRestUtils::initTestCase() { @@ -114,7 +111,8 @@ void TestQgsArcGisRestUtils::testParseSpatialReference() QVariantMap map; map.insert( QStringLiteral( "wkt" ), - QStringLiteral( "PROJCS[\"NewJTM\",GEOGCS[\"GCS_ETRF_1989\",DATUM[\"D_ETRF_1989\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",40000.0],PARAMETER[\"False_Northing\",70000.0],PARAMETER[\"Central_Meridian\",-2.135],PARAMETER[\"Scale_Factor\",0.9999999],PARAMETER[\"Latitude_Of_Origin\",49.225],UNIT[\"Meter\",1.0]]" ) ); + QStringLiteral( "PROJCS[\"NewJTM\",GEOGCS[\"GCS_ETRF_1989\",DATUM[\"D_ETRF_1989\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",40000.0],PARAMETER[\"False_Northing\",70000.0],PARAMETER[\"Central_Meridian\",-2.135],PARAMETER[\"Scale_Factor\",0.9999999],PARAMETER[\"Latitude_Of_Origin\",49.225],UNIT[\"Meter\",1.0]]" ) + ); const QgsCoordinateReferenceSystem crs = QgsArcGisRestUtils::convertSpatialReference( map ); QVERIFY( crs.isValid() ); @@ -214,33 +212,33 @@ void TestQgsArcGisRestUtils::testParseEsriColorJson() void TestQgsArcGisRestUtils::testParseMarkerSymbol() { const QVariantMap map = jsonStringToMap( "{" - "\"type\": \"esriSMS\"," - "\"style\": \"esriSMSSquare\"," - "\"color\": [" - "76," - "115," - "10," - "200" - "]," - "\"size\": 8," - "\"angle\": 10," - "\"xoffset\": 7," - "\"yoffset\": 17," - "\"outline\": {" - "\"color\": [" - "152," - "230," - "17," - "176" - "]," - "\"width\": 5" - "}" - "}" ); + "\"type\": \"esriSMS\"," + "\"style\": \"esriSMSSquare\"," + "\"color\": [" + "76," + "115," + "10," + "200" + "]," + "\"size\": 8," + "\"angle\": 10," + "\"xoffset\": 7," + "\"yoffset\": 17," + "\"outline\": {" + "\"color\": [" + "152," + "230," + "17," + "176" + "]," + "\"width\": 5" + "}" + "}" ); std::unique_ptr symbol( QgsArcGisRestUtils::convertSymbol( map ) ); - QgsMarkerSymbol *marker = dynamic_cast< QgsMarkerSymbol * >( symbol.get() ); + QgsMarkerSymbol *marker = dynamic_cast( symbol.get() ); QVERIFY( marker ); QCOMPARE( marker->symbolLayerCount(), 1 ); - QgsSimpleMarkerSymbolLayer *markerLayer = dynamic_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) ); + QgsSimpleMarkerSymbolLayer *markerLayer = dynamic_cast( marker->symbolLayer( 0 ) ); QVERIFY( markerLayer ); QCOMPARE( markerLayer->fillColor(), QColor( 76, 115, 10, 200 ) ); QCOMPARE( markerLayer->shape(), Qgis::MarkerShape::Square ); @@ -255,62 +253,62 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() // esriTS const QVariantMap fontMap = jsonStringToMap( "{" - "\"type\": \"esriTS\"," - "\"text\": \"text\"," - "\"color\": [" - "78," - "78," - "78," - "255" - "]," - "\"backgroundColor\": [" - "0," - "0," - "0," - "0" - "]," - "\"borderLineSize\": 2," - "\"borderLineColor\": [" - "255," - "0," - "255," - "255" - "]," - "\"haloSize\": 2," - "\"haloColor\": [" - "0," - "255," - "0," - "255" - "]," - "\"verticalAlignment\": \"bottom\"," - "\"horizontalAlignment\": \"left\"," - "\"rightToLeft\": false," - "\"angle\": 45," - "\"xoffset\": 0," - "\"yoffset\": 0," - "\"kerning\": true," - "\"font\": {" - "\"family\": \"Arial\"," - "\"size\": 12," - "\"style\": \"normal\"," - "\"weight\": \"bold\"," - "\"decoration\": \"none\"" - "}" - "}" ); + "\"type\": \"esriTS\"," + "\"text\": \"text\"," + "\"color\": [" + "78," + "78," + "78," + "255" + "]," + "\"backgroundColor\": [" + "0," + "0," + "0," + "0" + "]," + "\"borderLineSize\": 2," + "\"borderLineColor\": [" + "255," + "0," + "255," + "255" + "]," + "\"haloSize\": 2," + "\"haloColor\": [" + "0," + "255," + "0," + "255" + "]," + "\"verticalAlignment\": \"bottom\"," + "\"horizontalAlignment\": \"left\"," + "\"rightToLeft\": false," + "\"angle\": 45," + "\"xoffset\": 0," + "\"yoffset\": 0," + "\"kerning\": true," + "\"font\": {" + "\"family\": \"Arial\"," + "\"size\": 12," + "\"style\": \"normal\"," + "\"weight\": \"bold\"," + "\"decoration\": \"none\"" + "}" + "}" ); std::unique_ptr fontSymbol( QgsArcGisRestUtils::convertSymbol( fontMap ) ); - QgsMarkerSymbol *fontMarker = dynamic_cast< QgsMarkerSymbol * >( fontSymbol.get() ); + QgsMarkerSymbol *fontMarker = dynamic_cast( fontSymbol.get() ); QVERIFY( fontMarker ); QCOMPARE( fontMarker->symbolLayerCount(), 1 ); - QgsFontMarkerSymbolLayer *fontMarkerLayer = dynamic_cast< QgsFontMarkerSymbolLayer * >( fontMarker->symbolLayer( 0 ) ); + QgsFontMarkerSymbolLayer *fontMarkerLayer = dynamic_cast( fontMarker->symbolLayer( 0 ) ); QVERIFY( fontMarkerLayer ); QCOMPARE( fontMarkerLayer->fontStyle(), QString( "normal" ) ); QCOMPARE( fontMarkerLayer->fontFamily(), QString( "Arial" ) ); QCOMPARE( fontMarkerLayer->offset(), QPointF( 0, 0 ) ); QCOMPARE( fontMarkerLayer->angle(), 45 ); - QCOMPARE( fontMarkerLayer->horizontalAnchorPoint(), QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left ); - QCOMPARE( fontMarkerLayer->verticalAnchorPoint(), QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom ); + QCOMPARE( fontMarkerLayer->horizontalAnchorPoint(), QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left ); + QCOMPARE( fontMarkerLayer->verticalAnchorPoint(), QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom ); QColor mainColor = fontMarkerLayer->color(); QCOMPARE( mainColor.name(), QStringLiteral( "#4e4e4e" ) ); QColor strokeColor = fontMarkerLayer->strokeColor(); @@ -326,21 +324,21 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() void TestQgsArcGisRestUtils::testPictureMarkerSymbol() { const QVariantMap map = jsonStringToMap( "{" - "\"type\": \"esriPMS\"," - "\"url\": \"471E7E31\"," - "\"imageData\": \"abcdef\"," - "\"contentType\": \"image/png\"," - "\"width\": 20," - "\"height\": 25," - "\"angle\": 10," - "\"xoffset\": 7," - "\"yoffset\": 17" - "}" ); + "\"type\": \"esriPMS\"," + "\"url\": \"471E7E31\"," + "\"imageData\": \"abcdef\"," + "\"contentType\": \"image/png\"," + "\"width\": 20," + "\"height\": 25," + "\"angle\": 10," + "\"xoffset\": 7," + "\"yoffset\": 17" + "}" ); std::unique_ptr symbol( QgsArcGisRestUtils::convertSymbol( map ) ); - QgsMarkerSymbol *marker = dynamic_cast< QgsMarkerSymbol * >( symbol.get() ); + QgsMarkerSymbol *marker = dynamic_cast( symbol.get() ); QVERIFY( marker ); QCOMPARE( marker->symbolLayerCount(), 1 ); - QgsRasterMarkerSymbolLayer *markerLayer = dynamic_cast< QgsRasterMarkerSymbolLayer * >( marker->symbolLayer( 0 ) ); + QgsRasterMarkerSymbolLayer *markerLayer = dynamic_cast( marker->symbolLayer( 0 ) ); QVERIFY( markerLayer ); QCOMPARE( markerLayer->path(), QStringLiteral( "base64:abcdef" ) ); QCOMPARE( markerLayer->size(), 20.0 ); @@ -358,21 +356,21 @@ void TestQgsArcGisRestUtils::testPictureMarkerSymbol() void TestQgsArcGisRestUtils::testParseLineSymbol() { const QVariantMap map = jsonStringToMap( "{" - "\"type\": \"esriSLS\"," - "\"style\": \"esriSLSDot\"," - "\"color\": [" - "115," - "76," - "10," - "212" - "]," - "\"width\": 7" - "}" ); + "\"type\": \"esriSLS\"," + "\"style\": \"esriSLSDot\"," + "\"color\": [" + "115," + "76," + "10," + "212" + "]," + "\"width\": 7" + "}" ); std::unique_ptr symbol( QgsArcGisRestUtils::convertSymbol( map ) ); - QgsLineSymbol *line = dynamic_cast< QgsLineSymbol * >( symbol.get() ); + QgsLineSymbol *line = dynamic_cast( symbol.get() ); QVERIFY( line ); QCOMPARE( line->symbolLayerCount(), 1 ); - QgsSimpleLineSymbolLayer *lineLayer = dynamic_cast< QgsSimpleLineSymbolLayer * >( line->symbolLayer( 0 ) ); + QgsSimpleLineSymbolLayer *lineLayer = dynamic_cast( line->symbolLayer( 0 ) ); QVERIFY( lineLayer ); QCOMPARE( lineLayer->color(), QColor( 115, 76, 10, 212 ) ); QCOMPARE( lineLayer->width(), 7.0 ); @@ -387,31 +385,31 @@ void TestQgsArcGisRestUtils::testParseLineSymbol() void TestQgsArcGisRestUtils::testParseFillSymbol() { const QVariantMap map = jsonStringToMap( "{" - "\"type\": \"esriSFS\"," - "\"style\": \"esriSFSHorizontal\"," - "\"color\": [" - "115," - "76," - "10," - "200" - "]," - "\"outline\": {" - "\"type\": \"esriSLS\"," - "\"style\": \"esriSLSDashDot\"," - "\"color\": [" - "110," - "120," - "130," - "215" - "]," - "\"width\": 5" - "}" - "}" ); + "\"type\": \"esriSFS\"," + "\"style\": \"esriSFSHorizontal\"," + "\"color\": [" + "115," + "76," + "10," + "200" + "]," + "\"outline\": {" + "\"type\": \"esriSLS\"," + "\"style\": \"esriSLSDashDot\"," + "\"color\": [" + "110," + "120," + "130," + "215" + "]," + "\"width\": 5" + "}" + "}" ); const std::unique_ptr symbol( QgsArcGisRestUtils::convertSymbol( map ) ); - QgsFillSymbol *fill = dynamic_cast< QgsFillSymbol * >( symbol.get() ); + QgsFillSymbol *fill = dynamic_cast( symbol.get() ); QVERIFY( fill ); QCOMPARE( fill->symbolLayerCount(), 1 ); - QgsSimpleFillSymbolLayer *fillLayer = dynamic_cast< QgsSimpleFillSymbolLayer * >( fill->symbolLayer( 0 ) ); + QgsSimpleFillSymbolLayer *fillLayer = dynamic_cast( fill->symbolLayer( 0 ) ); QVERIFY( fillLayer ); QCOMPARE( fillLayer->fillColor(), QColor( 115, 76, 10, 200 ) ); QCOMPARE( fillLayer->brushStyle(), Qt::HorPattern ); @@ -425,35 +423,35 @@ void TestQgsArcGisRestUtils::testParseFillSymbol() void TestQgsArcGisRestUtils::testParsePictureFillSymbol() { const QVariantMap map = jsonStringToMap( "{" - "\"type\": \"esriPFS\"," - "\"url\": \"866880A0\"," - "\"imageData\": \"abcdef\"," - "\"contentType\": \"image/png\"," - "\"width\": 20," - "\"height\": 25," - "\"angle\": 0," - "\"outline\": {" - "\"type\": \"esriSLS\"," - "\"style\": \"esriSLSDashDot\"," - "\"color\": [" - "110," - "120," - "130," - "215" - "]," - "\"width\": 5" - "}" - "}" ); + "\"type\": \"esriPFS\"," + "\"url\": \"866880A0\"," + "\"imageData\": \"abcdef\"," + "\"contentType\": \"image/png\"," + "\"width\": 20," + "\"height\": 25," + "\"angle\": 0," + "\"outline\": {" + "\"type\": \"esriSLS\"," + "\"style\": \"esriSLSDashDot\"," + "\"color\": [" + "110," + "120," + "130," + "215" + "]," + "\"width\": 5" + "}" + "}" ); const std::unique_ptr symbol( QgsArcGisRestUtils::convertSymbol( map ) ); - QgsFillSymbol *fill = dynamic_cast< QgsFillSymbol * >( symbol.get() ); + QgsFillSymbol *fill = dynamic_cast( symbol.get() ); QVERIFY( fill ); QCOMPARE( fill->symbolLayerCount(), 2 ); - QgsRasterFillSymbolLayer *fillLayer = dynamic_cast< QgsRasterFillSymbolLayer * >( fill->symbolLayer( 0 ) ); + QgsRasterFillSymbolLayer *fillLayer = dynamic_cast( fill->symbolLayer( 0 ) ); QVERIFY( fillLayer ); QCOMPARE( fillLayer->imageFilePath(), QString( "base64:abcdef" ) ); QCOMPARE( fillLayer->width(), 20.0 ); QCOMPARE( fillLayer->sizeUnit(), Qgis::RenderUnit::Points ); - QgsSimpleLineSymbolLayer *lineLayer = dynamic_cast< QgsSimpleLineSymbolLayer * >( fill->symbolLayer( 1 ) ); + QgsSimpleLineSymbolLayer *lineLayer = dynamic_cast( fill->symbolLayer( 1 ) ); QVERIFY( lineLayer ); QCOMPARE( lineLayer->color(), QColor( 110, 120, 130, 215 ) ); QCOMPARE( lineLayer->width(), 5.0 ); @@ -464,35 +462,35 @@ void TestQgsArcGisRestUtils::testParsePictureFillSymbol() void TestQgsArcGisRestUtils::testParseRendererSimple() { const QVariantMap map = jsonStringToMap( "{" - "\"type\": \"simple\"," - "\"symbol\": {" - "\"color\": [" - "0," - "0," - "128," - "128" - "]," - "\"size\": 15," - "\"angle\": 0," - "\"xoffset\": 0," - "\"yoffset\": 0," - "\"type\": \"esriSMS\"," - "\"style\": \"esriSMSCircle\"," - "\"outline\": {" - "\"color\": [" - "0," - "0," - "128," - "255" - "]," - "\"width\": 0.99975," - "\"type\": \"esriSLS\"," - "\"style\": \"esriSLSSolid\"" - "}" - "}" - "}" ); - const std::unique_ptr< QgsFeatureRenderer > renderer( QgsArcGisRestUtils::convertRenderer( map ) ); - QgsSingleSymbolRenderer *ssRenderer = dynamic_cast< QgsSingleSymbolRenderer *>( renderer.get() ); + "\"type\": \"simple\"," + "\"symbol\": {" + "\"color\": [" + "0," + "0," + "128," + "128" + "]," + "\"size\": 15," + "\"angle\": 0," + "\"xoffset\": 0," + "\"yoffset\": 0," + "\"type\": \"esriSMS\"," + "\"style\": \"esriSMSCircle\"," + "\"outline\": {" + "\"color\": [" + "0," + "0," + "128," + "255" + "]," + "\"width\": 0.99975," + "\"type\": \"esriSLS\"," + "\"style\": \"esriSLSSolid\"" + "}" + "}" + "}" ); + const std::unique_ptr renderer( QgsArcGisRestUtils::convertRenderer( map ) ); + QgsSingleSymbolRenderer *ssRenderer = dynamic_cast( renderer.get() ); QVERIFY( ssRenderer ); QVERIFY( ssRenderer->symbol() ); } @@ -500,71 +498,71 @@ void TestQgsArcGisRestUtils::testParseRendererSimple() void TestQgsArcGisRestUtils::testParseRendererCategorized() { const QVariantMap map = jsonStringToMap( "{" - "\"type\": \"uniqueValue\"," - "\"field1\": \"COUNTRY\"," - "\"uniqueValueInfos\": [" - "{" - "\"value\": \"US\"," - "\"symbol\": {" - "\"color\": [" - "253," - "127," - "111," - "255" - "]," - "\"size\": 12.75," - "\"angle\": 0," - "\"xoffset\": 0," - "\"yoffset\": 0," - "\"type\": \"esriSMS\"," - "\"style\": \"esriSMSCircle\"," - "\"outline\": {" - "\"color\": [" - "26," - "26," - "26," - "255" - "]," - "\"width\": 0.75," - "\"type\": \"esriSLS\"," - "\"style\": \"esriSLSSolid\"" - "}" - "}," - "\"label\": \"United States\"" - "}," - "{" - "\"value\": \"Canada\"," - "\"symbol\": {" - "\"color\": [" - "126," - "176," - "213," - "255" - "]," - "\"size\": 12.75," - "\"angle\": 0," - "\"xoffset\": 0," - "\"yoffset\": 0," - "\"type\": \"esriSMS\"," - "\"style\": \"esriSMSCircle\"," - "\"outline\": {" - "\"color\": [" - "26," - "26," - "26," - "255" - "]," - "\"width\": 0.75," - "\"type\": \"esriSLS\"," - "\"style\": \"esriSLSSolid\"" - "}" - "}," - "\"label\": \"Canada\"" - "}" - "]" - "}" ); - const std::unique_ptr< QgsFeatureRenderer > renderer( QgsArcGisRestUtils::convertRenderer( map ) ); - QgsCategorizedSymbolRenderer *catRenderer = dynamic_cast< QgsCategorizedSymbolRenderer *>( renderer.get() ); + "\"type\": \"uniqueValue\"," + "\"field1\": \"COUNTRY\"," + "\"uniqueValueInfos\": [" + "{" + "\"value\": \"US\"," + "\"symbol\": {" + "\"color\": [" + "253," + "127," + "111," + "255" + "]," + "\"size\": 12.75," + "\"angle\": 0," + "\"xoffset\": 0," + "\"yoffset\": 0," + "\"type\": \"esriSMS\"," + "\"style\": \"esriSMSCircle\"," + "\"outline\": {" + "\"color\": [" + "26," + "26," + "26," + "255" + "]," + "\"width\": 0.75," + "\"type\": \"esriSLS\"," + "\"style\": \"esriSLSSolid\"" + "}" + "}," + "\"label\": \"United States\"" + "}," + "{" + "\"value\": \"Canada\"," + "\"symbol\": {" + "\"color\": [" + "126," + "176," + "213," + "255" + "]," + "\"size\": 12.75," + "\"angle\": 0," + "\"xoffset\": 0," + "\"yoffset\": 0," + "\"type\": \"esriSMS\"," + "\"style\": \"esriSMSCircle\"," + "\"outline\": {" + "\"color\": [" + "26," + "26," + "26," + "255" + "]," + "\"width\": 0.75," + "\"type\": \"esriSLS\"," + "\"style\": \"esriSLSSolid\"" + "}" + "}," + "\"label\": \"Canada\"" + "}" + "]" + "}" ); + const std::unique_ptr renderer( QgsArcGisRestUtils::convertRenderer( map ) ); + QgsCategorizedSymbolRenderer *catRenderer = dynamic_cast( renderer.get() ); QVERIFY( catRenderer ); QCOMPARE( catRenderer->categories().count(), 2 ); QCOMPARE( catRenderer->categories().at( 0 ).value().toString(), QStringLiteral( "US" ) ); @@ -578,86 +576,86 @@ void TestQgsArcGisRestUtils::testParseRendererCategorized() void TestQgsArcGisRestUtils::testParseLabeling() { const QVariantMap map = jsonStringToMap( "{" - "\"labelingInfo\": [" - "{" - "\"labelPlacement\": \"esriServerPointLabelPlacementAboveRight\"," - "\"where\": \"1=1\"," - "\"labelExpression\": \"[Name]\"," - "\"useCodedValues\": true," - "\"symbol\": {" - "\"type\": \"esriTS\"," - "\"color\": [" - "255," - "0," - "0," - "255" - "]," - "\"backgroundColor\": null," - "\"borderLineColor\": null," - "\"borderLineSize\": null," - "\"verticalAlignment\": \"bottom\"," - "\"horizontalAlignment\": \"center\"," - "\"rightToLeft\": false," - "\"angle\": 0," - "\"xoffset\": 0," - "\"yoffset\": 0," - "\"haloColor\": null," - "\"haloSize\": null," - "\"font\": {" - "\"family\": \"Arial\"," - "\"size\": 8," - "\"style\": \"normal\"," - "\"weight\": \"bold\"," - "\"decoration\": \"none\"" - "}" - "}," - "\"minScale\": 200000," - "\"maxScale\": 0" - "},{" - "\"labelPlacement\": \"esriServerPointLabelPlacementAboveRight\"," - "\"where\": \"1_testing broken where string\"," - "\"labelExpression\": \"\\\"Name: \\\" CONCAT [Name] CONCAT NEWLINE CONCAT [Size]\"," - "\"useCodedValues\": true," - "\"symbol\": {" - "\"type\": \"esriTS\"," - "\"color\": [" - "255," - "0," - "0," - "255" - "]," - "\"backgroundColor\": null," - "\"borderLineColor\": null," - "\"borderLineSize\": null," - "\"verticalAlignment\": \"bottom\"," - "\"horizontalAlignment\": \"center\"," - "\"rightToLeft\": false," - "\"angle\": 0," - "\"xoffset\": 0," - "\"yoffset\": 0," - "\"haloColor\": [" - "255," - "255," - "255," - "255" - "]," - "\"haloSize\": 1," - "\"font\": {" - "\"family\": \"Arial\"," - "\"size\": 8," - "\"style\": \"normal\"," - "\"weight\": \"bold\"," - "\"decoration\": \"none\"" - "}" - "}," - "\"minScale\": 200000," - "\"maxScale\": 0" - "}" - "]" - "}" ); - const std::unique_ptr< QgsAbstractVectorLayerLabeling > labeling( QgsArcGisRestUtils::convertLabeling( map.value( QStringLiteral( "labelingInfo" ) ).toList() ) ); + "\"labelingInfo\": [" + "{" + "\"labelPlacement\": \"esriServerPointLabelPlacementAboveRight\"," + "\"where\": \"1=1\"," + "\"labelExpression\": \"[Name]\"," + "\"useCodedValues\": true," + "\"symbol\": {" + "\"type\": \"esriTS\"," + "\"color\": [" + "255," + "0," + "0," + "255" + "]," + "\"backgroundColor\": null," + "\"borderLineColor\": null," + "\"borderLineSize\": null," + "\"verticalAlignment\": \"bottom\"," + "\"horizontalAlignment\": \"center\"," + "\"rightToLeft\": false," + "\"angle\": 0," + "\"xoffset\": 0," + "\"yoffset\": 0," + "\"haloColor\": null," + "\"haloSize\": null," + "\"font\": {" + "\"family\": \"Arial\"," + "\"size\": 8," + "\"style\": \"normal\"," + "\"weight\": \"bold\"," + "\"decoration\": \"none\"" + "}" + "}," + "\"minScale\": 200000," + "\"maxScale\": 0" + "},{" + "\"labelPlacement\": \"esriServerPointLabelPlacementAboveRight\"," + "\"where\": \"1_testing broken where string\"," + "\"labelExpression\": \"\\\"Name: \\\" CONCAT [Name] CONCAT NEWLINE CONCAT [Size]\"," + "\"useCodedValues\": true," + "\"symbol\": {" + "\"type\": \"esriTS\"," + "\"color\": [" + "255," + "0," + "0," + "255" + "]," + "\"backgroundColor\": null," + "\"borderLineColor\": null," + "\"borderLineSize\": null," + "\"verticalAlignment\": \"bottom\"," + "\"horizontalAlignment\": \"center\"," + "\"rightToLeft\": false," + "\"angle\": 0," + "\"xoffset\": 0," + "\"yoffset\": 0," + "\"haloColor\": [" + "255," + "255," + "255," + "255" + "]," + "\"haloSize\": 1," + "\"font\": {" + "\"family\": \"Arial\"," + "\"size\": 8," + "\"style\": \"normal\"," + "\"weight\": \"bold\"," + "\"decoration\": \"none\"" + "}" + "}," + "\"minScale\": 200000," + "\"maxScale\": 0" + "}" + "]" + "}" ); + const std::unique_ptr labeling( QgsArcGisRestUtils::convertLabeling( map.value( QStringLiteral( "labelingInfo" ) ).toList() ) ); QVERIFY( labeling ); - QgsRuleBasedLabeling *rules = dynamic_cast< QgsRuleBasedLabeling *>( labeling.get() ); + QgsRuleBasedLabeling *rules = dynamic_cast( labeling.get() ); QVERIFY( rules ); QgsRuleBasedLabeling::Rule *root = rules->rootRule(); QVERIFY( root ); @@ -706,7 +704,7 @@ QVariantMap TestQgsArcGisRestUtils::jsonStringToMap( const QString &string ) con void TestQgsArcGisRestUtils::testParseCompoundCurve() { const QVariantMap map = jsonStringToMap( "{\"curvePaths\": [[[6,3],[5,3],{\"c\": [[3,3],[1,4]]}]]}" ); - std::unique_ptr< QgsMultiCurve > curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::Point ) ); + std::unique_ptr curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::Point ) ); QVERIFY( curve ); QCOMPARE( curve->asWkt(), QStringLiteral( "MultiCurve (CompoundCurve ((6 3, 5 3),CircularString (5 3, 1 4, 3 3)))" ) ); } @@ -714,7 +712,7 @@ void TestQgsArcGisRestUtils::testParseCompoundCurve() void TestQgsArcGisRestUtils::testParsePolyline() { const QVariantMap map = jsonStringToMap( "{\"paths\": [[[6,3],[5,3]]]}" ); - std::unique_ptr< QgsMultiCurve > curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::Point ) ); + std::unique_ptr curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::Point ) ); QVERIFY( curve ); QCOMPARE( curve->asWkt(), QStringLiteral( "MultiCurve (CompoundCurve ((6 3, 5 3)))" ) ); } @@ -722,7 +720,7 @@ void TestQgsArcGisRestUtils::testParsePolyline() void TestQgsArcGisRestUtils::testParsePolylineZ() { const QVariantMap map = jsonStringToMap( "{\"paths\": [[[6,3,1],[5,3,2]]]}" ); - std::unique_ptr< QgsMultiCurve > curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::PointZ ) ); + std::unique_ptr curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::PointZ ) ); QVERIFY( curve ); QCOMPARE( curve->asWkt(), QStringLiteral( "MultiCurve Z (CompoundCurve Z ((6 3 1, 5 3 2)))" ) ); } @@ -730,7 +728,7 @@ void TestQgsArcGisRestUtils::testParsePolylineZ() void TestQgsArcGisRestUtils::testParsePolylineM() { const QVariantMap map = jsonStringToMap( "{\"paths\": [[[6,3,1],[5,3,2]]]}" ); - std::unique_ptr< QgsMultiCurve > curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::PointM ) ); + std::unique_ptr curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::PointM ) ); QVERIFY( curve ); QCOMPARE( curve->asWkt(), QStringLiteral( "MultiCurve M (CompoundCurve M ((6 3 1, 5 3 2)))" ) ); } @@ -738,7 +736,7 @@ void TestQgsArcGisRestUtils::testParsePolylineM() void TestQgsArcGisRestUtils::testParsePolylineZM() { const QVariantMap map = jsonStringToMap( "{\"paths\": [[[6,3,1,11],[5,3,2,12]]]}" ); - std::unique_ptr< QgsMultiCurve > curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::PointZM ) ); + std::unique_ptr curve( QgsArcGisRestUtils::convertGeometryPolyline( map, Qgis::WkbType::PointZM ) ); QVERIFY( curve ); QCOMPARE( curve->asWkt(), QStringLiteral( "MultiCurve ZM (CompoundCurve ZM ((6 3 1 11, 5 3 2 12)))" ) ); } diff --git a/tests/src/core/testqgsattributeeditorelement.cpp b/tests/src/core/testqgsattributeeditorelement.cpp index 90d032bd3316..6ea295db5f8d 100644 --- a/tests/src/core/testqgsattributeeditorelement.cpp +++ b/tests/src/core/testqgsattributeeditorelement.cpp @@ -26,13 +26,13 @@ * \ingroup UnitTests * This is a unit test for the QgsAttributeEditorElement label font and color serialization */ -class TestQgsAttributeEditorElement: public QObject +class TestQgsAttributeEditorElement : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testLabelFontAndColor(); }; @@ -59,7 +59,6 @@ void TestQgsAttributeEditorElement::cleanupTestCase() void TestQgsAttributeEditorElement::testLabelFontAndColor() { - QgsEditFormConfig editFormConfig; QFont font0 { QgsFontUtils::getStandardTestFont() }; @@ -68,8 +67,7 @@ void TestQgsAttributeEditorElement::testLabelFontAndColor() font0.setUnderline( true ); font0.setStrikeOut( false ); - QgsAttributeEditorElement::LabelStyle style - { + QgsAttributeEditorElement::LabelStyle style { QColor( Qt::GlobalColor::darkCyan ), font0, true, @@ -86,11 +84,11 @@ void TestQgsAttributeEditorElement::testLabelFontAndColor() font1.setStrikeOut( true ); field1->setLabelStyle( - { - QColor( Qt::GlobalColor::blue ), - font1, - true, - true} ); + { QColor( Qt::GlobalColor::blue ), + font1, + true, + true } + ); editFormConfig.invisibleRootContainer()->addChildElement( field1 ); @@ -99,20 +97,20 @@ void TestQgsAttributeEditorElement::testLabelFontAndColor() QFont font2 { QgsFontUtils::getStandardTestFont() }; field2->setLabelStyle( - { - QColor( Qt::GlobalColor::blue ), - font2, - false, - true } ); + { QColor( Qt::GlobalColor::blue ), + font2, + false, + true } + ); QgsAttributeEditorContainer *container = new QgsAttributeEditorContainer( "group1", nullptr ); container->setLabelStyle( - { - QColor( Qt::GlobalColor::darkCyan ), - font0, - true, - true - } ); + { QColor( Qt::GlobalColor::darkCyan ), + font0, + true, + true + } + ); container->addChildElement( field2 ); editFormConfig.addTab( container ); @@ -137,7 +135,6 @@ void TestQgsAttributeEditorElement::testLabelFontAndColor() const auto field2config { group1config->children().at( 0 ) }; QCOMPARE( field2config->name(), QString( "f2" ) ); QCOMPARE( field2config->labelStyle(), field2->labelStyle() ); - } QGSTEST_MAIN( TestQgsAttributeEditorElement ) diff --git a/tests/src/core/testqgsauthcertutils.cpp b/tests/src/core/testqgsauthcertutils.cpp index 98e5526ba10a..3d440246c4f8 100644 --- a/tests/src/core/testqgsauthcertutils.cpp +++ b/tests/src/core/testqgsauthcertutils.cpp @@ -29,7 +29,7 @@ * \ingroup UnitTests * Unit tests for QgsAuthCertUtils static functions */ -class TestQgsAuthCertUtils: public QObject +class TestQgsAuthCertUtils : public QObject { Q_OBJECT diff --git a/tests/src/core/testqgsauthconfig.cpp b/tests/src/core/testqgsauthconfig.cpp index 6e13039addf0..1a7e5c4881ba 100644 --- a/tests/src/core/testqgsauthconfig.cpp +++ b/tests/src/core/testqgsauthconfig.cpp @@ -27,7 +27,7 @@ * \ingroup UnitTests * Unit tests for QgsAuthConfig */ -class TestQgsAuthConfig: public QObject +class TestQgsAuthConfig : public QObject { Q_OBJECT @@ -132,10 +132,7 @@ void TestQgsAuthConfig::testPkiBundle() const QList cacerts( QSslCertificate::fromPath( sPkiData + "/chain_subissuer-issuer-root.pem" ) ); QVERIFY( !cacerts.isEmpty() ); QCOMPARE( cacerts.size(), 3 ); - const QgsPkiBundle bundle2( QgsPkiBundle::fromPemPaths( sPkiData + "/fra_cert.pem", - sPkiData + "/fra_key_w-pass.pem", - QStringLiteral( "password" ), - cacerts ) ); + const QgsPkiBundle bundle2( QgsPkiBundle::fromPemPaths( sPkiData + "/fra_cert.pem", sPkiData + "/fra_key_w-pass.pem", QStringLiteral( "password" ), cacerts ) ); QVERIFY( !bundle2.isNull() ); QVERIFY( bundle2.isValid() ); QCOMPARE( bundle2.certId(), QString( "c3633c428d441853973e5081ba9be39f667f5af6" ) ); @@ -158,8 +155,7 @@ void TestQgsAuthConfig::testPkiBundle() QVERIFY( !bundle.isNull() ); QVERIFY( bundle.isValid() ); - const QgsPkiBundle bundle4( QgsPkiBundle::fromPkcs12Paths( sPkiData + "/fra_w-chain.p12", - QStringLiteral( "password" ) ) ); + const QgsPkiBundle bundle4( QgsPkiBundle::fromPkcs12Paths( sPkiData + "/fra_w-chain.p12", QStringLiteral( "password" ) ) ); QVERIFY( !bundle4.isNull() ); QVERIFY( bundle4.isValid() ); const QList cachain4( bundle2.caChain() ); diff --git a/tests/src/core/testqgsauthcrypto.cpp b/tests/src/core/testqgsauthcrypto.cpp index 6f62e97f4cf1..1d1903ab8720 100644 --- a/tests/src/core/testqgsauthcrypto.cpp +++ b/tests/src/core/testqgsauthcrypto.cpp @@ -26,15 +26,15 @@ * \ingroup UnitTests * Unit tests for QgsAuthCrypto */ -class TestQgsAuthCrypto: public QObject +class TestQgsAuthCrypto : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testEncrypt(); void testDecrypt(); @@ -54,31 +54,31 @@ const QString TestQgsAuthCrypto::PASS = QStringLiteral( "password" ); const QString TestQgsAuthCrypto::SALT = QStringLiteral( "f48b706946df69d4d2b45bd0603c95af" ); const QString TestQgsAuthCrypto::HASH = QStringLiteral( "0be18c3f1bf872194d6042f5f4a0c116" ); const QString TestQgsAuthCrypto::CIV = QStringLiteral( - "1c18c442b6723ee465bcbb60568412179fcc3313eb0187b4546ca96d869fbdc1" - ); + "1c18c442b6723ee465bcbb60568412179fcc3313eb0187b4546ca96d869fbdc1" +); const QString TestQgsAuthCrypto::TEXT = QString( - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod " - "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " - "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea " - "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate " - "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint " - "occaecat cupidatat non proident, sunt in culpa qui officia deserunt " - "mollit anim id est laborum." - ); + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod " + "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " + "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea " + "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate " + "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint " + "occaecat cupidatat non proident, sunt in culpa qui officia deserunt " + "mollit anim id est laborum." +); const QString TestQgsAuthCrypto::CRYPT = QString( - "ec53707ca8769489a6084e88c0e1fb18d3423406ac23c34ad5ac25600f59486375927bc9ed79" - "d363f8774810ef74a92412ae236b949126c6b799dd8c20b5dbc68e7aa8501e414831e91c6533" - "83aa6f86eb85eb5206a7e8e894b5c15b6e64de9555c580e1434248d3c0b80ee346583b998ee2" - "72997788679f37675c0b03dd5661d90c4a4bae4c238b508e6a405e1fe432e03208d5acae6b29" - "a91fad073a07caa4bda1991b8c2eae79b0179a9fe4e7548089e5a4779e4b92359a332191a60f" - "2389218f46341f3ced9d30a268101afcfd9645bbf6c6684bcf620ab433554de05f95bcc6c50d" - "4527ed8dd809eacf60c3e988f5314b41da8fe7d8b773c1d54208f5eca54c678ef0acfc3134a6" - "b0b18bcadd5f3d00e3188e07aaf9ff88be4ee093514cdb9fa851e5f86d165021c327f0a789fa" - "3ce2f8efe72f671ef9758ef4c442e9ff736131de5382f7169f8fbf426ba043eafe1c853ae7bb" - "76861a176af8ffdaa498f459ea2d92d5cffd4244216090ce32a1bfb1dda5a91f9308556770cf" - "bb13cb91e5909f142f29c7e788a81732bf37c3571955f1a6e4f23fb9c9dbe753b22b4ef47b44" - "548091393e0ddd6225958423a354ba160e9e8415d5fb9ce55670a6e23ac0" - ); + "ec53707ca8769489a6084e88c0e1fb18d3423406ac23c34ad5ac25600f59486375927bc9ed79" + "d363f8774810ef74a92412ae236b949126c6b799dd8c20b5dbc68e7aa8501e414831e91c6533" + "83aa6f86eb85eb5206a7e8e894b5c15b6e64de9555c580e1434248d3c0b80ee346583b998ee2" + "72997788679f37675c0b03dd5661d90c4a4bae4c238b508e6a405e1fe432e03208d5acae6b29" + "a91fad073a07caa4bda1991b8c2eae79b0179a9fe4e7548089e5a4779e4b92359a332191a60f" + "2389218f46341f3ced9d30a268101afcfd9645bbf6c6684bcf620ab433554de05f95bcc6c50d" + "4527ed8dd809eacf60c3e988f5314b41da8fe7d8b773c1d54208f5eca54c678ef0acfc3134a6" + "b0b18bcadd5f3d00e3188e07aaf9ff88be4ee093514cdb9fa851e5f86d165021c327f0a789fa" + "3ce2f8efe72f671ef9758ef4c442e9ff736131de5382f7169f8fbf426ba043eafe1c853ae7bb" + "76861a176af8ffdaa498f459ea2d92d5cffd4244216090ce32a1bfb1dda5a91f9308556770cf" + "bb13cb91e5909f142f29c7e788a81732bf37c3571955f1a6e4f23fb9c9dbe753b22b4ef47b44" + "548091393e0ddd6225958423a354ba160e9e8415d5fb9ce55670a6e23ac0" +); void TestQgsAuthCrypto::initTestCase() { diff --git a/tests/src/core/testqgsauthmanager.cpp b/tests/src/core/testqgsauthmanager.cpp index af7911e0e407..afdd7a5c029f 100644 --- a/tests/src/core/testqgsauthmanager.cpp +++ b/tests/src/core/testqgsauthmanager.cpp @@ -34,7 +34,7 @@ * \ingroup UnitTests * Unit tests for QgsAuthManager */ -class TestQgsAuthManager: public QgsTest +class TestQgsAuthManager : public QgsTest { Q_OBJECT @@ -65,7 +65,6 @@ class TestQgsAuthManager: public QgsTest QString mPkiData; QString mTempDir; const char *mPass = nullptr; - }; @@ -89,8 +88,7 @@ void TestQgsAuthManager::initTestCase() // init app and auth manager QgsApplication::init(); QgsApplication::initQgis(); - QVERIFY2( !QgsApplication::authManager()->isDisabled(), - "Authentication system is DISABLED" ); + QVERIFY2( !QgsApplication::authManager()->isDisabled(), "Authentication system is DISABLED" ); // verify QGIS_AUTH_DB_DIR_PATH (temp auth db path) worked Q_NOWARN_DEPRECATED_PUSH @@ -101,10 +99,8 @@ void TestQgsAuthManager::initTestCase() // verify master pass can be set manually // (this also creates a fresh password hash in the new temp database) - QVERIFY2( QgsApplication::authManager()->setMasterPassword( mPass, true ), - "Master password could not be set" ); - QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), - "Auth master password not set from passed string" ); + QVERIFY2( QgsApplication::authManager()->setMasterPassword( mPass, true ), "Master password could not be set" ); + QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), "Auth master password not set from passed string" ); // create QGIS_AUTH_PASSWORD_FILE file const QString passfilepath = mTempDir + "/passfile"; @@ -123,12 +119,10 @@ void TestQgsAuthManager::initTestCase() // QTest::qSleep( 3000 ); QgsApplication::init(); QgsApplication::initQgis(); - QVERIFY2( !QgsApplication::authManager()->isDisabled(), - "Authentication system is DISABLED" ); + QVERIFY2( !QgsApplication::authManager()->isDisabled(), "Authentication system is DISABLED" ); // verify QGIS_AUTH_PASSWORD_FILE worked, when compared against hash in db - QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), - "Auth master password not set from QGIS_AUTH_PASSWORD_FILE" ); + QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), "Auth master password not set from QGIS_AUTH_PASSWORD_FILE" ); // all tests should now have a valid qgis-auth.db and stored/set master password } @@ -422,7 +416,6 @@ void TestQgsAuthManager::doSync() void TestQgsAuthManager::testPasswordHelper() { - if ( QgsTest::isCIRun() ) { { @@ -439,17 +432,15 @@ void TestQgsAuthManager::testPasswordHelper() // It should be enabled by default QVERIFY( authm->passwordHelperEnabled() ); authm->setPasswordHelperEnabled( false ); - QVERIFY( ! authm->passwordHelperEnabled() ); + QVERIFY( !authm->passwordHelperEnabled() ); authm->setPasswordHelperEnabled( true ); QVERIFY( authm->passwordHelperEnabled() ); // Sync with wallet QVERIFY( authm->setMasterPassword( mPass, true ) ); QVERIFY( authm->masterPasswordIsSet() ); - QObject::connect( authm, &QgsAuthManager::passwordHelperSuccess, - QApplication::instance(), &QCoreApplication::quit ); - QObject::connect( authm, &QgsAuthManager::passwordHelperFailure, - QApplication::instance(), &QCoreApplication::quit ); + QObject::connect( authm, &QgsAuthManager::passwordHelperSuccess, QApplication::instance(), &QCoreApplication::quit ); + QObject::connect( authm, &QgsAuthManager::passwordHelperFailure, QApplication::instance(), &QCoreApplication::quit ); QMetaObject::invokeMethod( this, "doSync", Qt::QueuedConnection ); qApp->exec(); authm->clearMasterPassword(); @@ -459,8 +450,8 @@ void TestQgsAuthManager::testPasswordHelper() // Delete from wallet authm->clearMasterPassword(); QVERIFY( authm->passwordHelperDelete() ); - QVERIFY( ! authm->setMasterPassword() ); - QVERIFY( ! authm->masterPasswordIsSet() ); + QVERIFY( !authm->setMasterPassword() ); + QVERIFY( !authm->masterPasswordIsSet() ); // Re-sync QVERIFY( authm->setMasterPassword( mPass, true ) ); @@ -469,7 +460,6 @@ void TestQgsAuthManager::testPasswordHelper() authm->clearMasterPassword(); QVERIFY( authm->setMasterPassword() ); QVERIFY( authm->masterPasswordIsSet() ); - } QGSTEST_MAIN( TestQgsAuthManager ) diff --git a/tests/src/core/testqgsblendmodes.cpp b/tests/src/core/testqgsblendmodes.cpp index 5a21c71a402d..c8fe5ffc4044 100644 --- a/tests/src/core/testqgsblendmodes.cpp +++ b/tests/src/core/testqgsblendmodes.cpp @@ -40,7 +40,8 @@ class TestQgsBlendModes : public QgsTest Q_OBJECT public: - TestQgsBlendModes() : QgsTest( QStringLiteral( "Blending modes" ) ) {} + TestQgsBlendModes() + : QgsTest( QStringLiteral( "Blending modes" ) ) {} ~TestQgsBlendModes() override { @@ -48,15 +49,16 @@ class TestQgsBlendModes : public QgsTest } private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void vectorBlending(); void featureBlending(); void vectorLayerTransparency(); void rasterBlending(); + private: QgsMapSettings *mMapSettings = nullptr; QgsMapLayer *mpPointsLayer = nullptr; @@ -71,7 +73,6 @@ class TestQgsBlendModes : public QgsTest void TestQgsBlendModes::initTestCase() { - // init QGIS's paths - true means that all path will be inited from prefix QgsApplication::init(); QgsApplication::initQgis(); @@ -87,14 +88,12 @@ void TestQgsBlendModes::initTestCase() mTestDataDir = myDataDir + '/'; const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); //create a poly layer that will be used in tests const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -104,16 +103,13 @@ void TestQgsBlendModes::initTestCase() //create a line layer that will be used in tests const QString myLinesFileName = mTestDataDir + "lines.shp"; const QFileInfo myLineFileInfo( myLinesFileName ); - mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), - myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); mpLinesLayer->setSimplifyMethod( simplifyMethod ); //create two raster layers const QFileInfo rasterFileInfo( mTestDataDir + "rgb256x256.png" ); - mRasterLayer1 = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); - mRasterLayer2 = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + mRasterLayer1 = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); + mRasterLayer2 = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer *rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer1->dataProvider(), 1, 2, 3 ); mRasterLayer1->setRenderer( rasterRenderer ); mRasterLayer2->setRenderer( ( QgsRasterRenderer * ) rasterRenderer->clone() ); diff --git a/tests/src/core/testqgsbrowsermodel.cpp b/tests/src/core/testqgsbrowsermodel.cpp index 9dbf48c325db..de390479f01f 100644 --- a/tests/src/core/testqgsbrowsermodel.cpp +++ b/tests/src/core/testqgsbrowsermodel.cpp @@ -35,15 +35,14 @@ class TestQgsBrowserModel : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testModel(); void driveItems(); void updatesToDataItemProviderRegistry(); - }; void TestQgsBrowserModel::initTestCase() @@ -99,8 +98,8 @@ void TestQgsBrowserModel::testModel() rootItem1->setState( Qgis::BrowserItemState::Populated ); QVERIFY( !model.hasChildren( root1Index ) ); QCOMPARE( model.data( root1Index ).toString(), QStringLiteral( "Test" ) ); - QCOMPARE( model.data( root1Index, static_cast< int >( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root1" ) ); - QCOMPARE( model.data( root1Index, static_cast< int >( QgsBrowserModel::CustomRole::ProviderKey ) ).toString(), QStringLiteral( "providerKeyRoot1" ) ); + QCOMPARE( model.data( root1Index, static_cast( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root1" ) ); + QCOMPARE( model.data( root1Index, static_cast( QgsBrowserModel::CustomRole::ProviderKey ) ).toString(), QStringLiteral( "providerKeyRoot1" ) ); QCOMPARE( model.dataItem( root1Index ), rootItem1 ); QCOMPARE( model.findItem( rootItem1 ), root1Index ); @@ -116,8 +115,8 @@ void TestQgsBrowserModel::testModel() QCOMPARE( model.rowCount( root2Index ), 0 ); QCOMPARE( model.columnCount( root2Index ), 1 ); QCOMPARE( model.data( root2Index ).toString(), QStringLiteral( "Test2" ) ); - QCOMPARE( model.data( root2Index, static_cast< int >( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root2" ) ); - QVERIFY( model.data( root2Index, static_cast< int >( QgsBrowserModel::CustomRole::ProviderKey ) ).toString().isEmpty() ); + QCOMPARE( model.data( root2Index, static_cast( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root2" ) ); + QVERIFY( model.data( root2Index, static_cast( QgsBrowserModel::CustomRole::ProviderKey ) ).toString().isEmpty() ); QCOMPARE( model.dataItem( root2Index ), rootItem2 ); QCOMPARE( model.findItem( rootItem2 ), root2Index ); @@ -133,8 +132,8 @@ void TestQgsBrowserModel::testModel() QVERIFY( model.hasChildren( root1Index ) ); QModelIndex child1Index = model.index( 0, 0, root1Index ); QCOMPARE( model.data( child1Index ).toString(), QStringLiteral( "Child1" ) ); - QCOMPARE( model.data( child1Index, static_cast< int >( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "child1" ) ); - QCOMPARE( model.data( child1Index, static_cast< int >( QgsBrowserModel::CustomRole::ProviderKey ) ).toString(), QStringLiteral( "providerKeyChild1" ) ); + QCOMPARE( model.data( child1Index, static_cast( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "child1" ) ); + QCOMPARE( model.data( child1Index, static_cast( QgsBrowserModel::CustomRole::ProviderKey ) ).toString(), QStringLiteral( "providerKeyChild1" ) ); QCOMPARE( model.dataItem( child1Index ), childItem1 ); QCOMPARE( model.findItem( childItem1 ), child1Index ); QCOMPARE( model.findItem( childItem1, rootItem1 ), child1Index ); diff --git a/tests/src/core/testqgsbrowserproxymodel.cpp b/tests/src/core/testqgsbrowserproxymodel.cpp index 1f39b4f721ce..adb8b8498e57 100644 --- a/tests/src/core/testqgsbrowserproxymodel.cpp +++ b/tests/src/core/testqgsbrowserproxymodel.cpp @@ -32,25 +32,22 @@ class TestQgsBrowserProxyModel : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testModel(); void testShowLayers(); - }; -class TestCollectionItem: public QgsDataCollectionItem +class TestCollectionItem : public QgsDataCollectionItem { Q_OBJECT public: - TestCollectionItem( QgsDataItem *parent, const QString &name, const QString &path = QString(), const QString &providerKey = QString() ) - : QgsDataCollectionItem( parent, name, path, providerKey ) - { - }; + : QgsDataCollectionItem( parent, name, path, providerKey ) { + }; bool layerCollection() const override { return true; }; }; @@ -110,11 +107,11 @@ void TestQgsBrowserProxyModel::testModel() QCOMPARE( proxy.rowCount( root1Index ), 0 ); QCOMPARE( proxy.columnCount( root1Index ), 1 ); QCOMPARE( proxy.data( root1Index ).toString(), QStringLiteral( "Test" ) ); - QCOMPARE( proxy.data( root1Index, static_cast< int >( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root1" ) ); + QCOMPARE( proxy.data( root1Index, static_cast( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root1" ) ); QCOMPARE( proxy.dataItem( root1Index ), rootItem1 ); // second root item - QgsDataCollectionItem *rootItem2 = new QgsDataCollectionItem( nullptr, QStringLiteral( "Test2" ), QStringLiteral( "root2" ), QStringLiteral( "provider2" ) ); + QgsDataCollectionItem *rootItem2 = new QgsDataCollectionItem( nullptr, QStringLiteral( "Test2" ), QStringLiteral( "root2" ), QStringLiteral( "provider2" ) ); model.setupItemConnections( rootItem2 ); model.beginInsertRows( QModelIndex(), 1, 1 ); model.mRootItems.append( rootItem2 ); @@ -127,7 +124,7 @@ void TestQgsBrowserProxyModel::testModel() QCOMPARE( proxy.rowCount( root2Index ), 0 ); QCOMPARE( proxy.columnCount( root2Index ), 1 ); QCOMPARE( proxy.data( root2Index ).toString(), QStringLiteral( "Test2" ) ); - QCOMPARE( proxy.data( root2Index, static_cast< int >( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root2" ) ); + QCOMPARE( proxy.data( root2Index, static_cast( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "root2" ) ); QCOMPARE( proxy.dataItem( root2Index ), rootItem2 ); // child item @@ -141,7 +138,7 @@ void TestQgsBrowserProxyModel::testModel() QVERIFY( proxy.hasChildren( root1Index ) ); QModelIndex child1Index = proxy.index( 0, 0, root1Index ); QCOMPARE( proxy.data( child1Index ).toString(), QStringLiteral( "Child1" ) ); - QCOMPARE( proxy.data( child1Index, static_cast< int >( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "child1" ) ); + QCOMPARE( proxy.data( child1Index, static_cast( QgsBrowserModel::CustomRole::Path ) ).toString(), QStringLiteral( "child1" ) ); QCOMPARE( proxy.dataItem( child1Index ), childItem1 ); // more children @@ -269,11 +266,11 @@ void TestQgsBrowserProxyModel::testModel() proxy.setFilterByLayerType( false ); // provider filtering - proxy.setHiddenDataItemProviderKeyFilter( QStringList( {QStringLiteral( "provider1" )} ) ); + proxy.setHiddenDataItemProviderKeyFilter( QStringList( { QStringLiteral( "provider1" ) } ) ); QCOMPARE( proxy.rowCount(), 2 ); root1Index = proxy.index( 0, 0 ); QCOMPARE( proxy.rowCount( root1Index ), 1 ); - proxy.setHiddenDataItemProviderKeyFilter( QStringList( {QStringLiteral( "provider2" )} ) ); + proxy.setHiddenDataItemProviderKeyFilter( QStringList( { QStringLiteral( "provider2" ) } ) ); QCOMPARE( proxy.rowCount(), 1 ); root1Index = proxy.index( 0, 0 ); QCOMPARE( proxy.rowCount( root1Index ), 2 ); @@ -281,18 +278,17 @@ void TestQgsBrowserProxyModel::testModel() QCOMPARE( proxy.rowCount(), 2 ); // provider filtering - proxy.setHiddenDataItemProviderKeyFilter( QStringList( ) ); - proxy.setShownDataItemProviderKeyFilter( QStringList( {QStringLiteral( "provider2" )} ) ); + proxy.setHiddenDataItemProviderKeyFilter( QStringList() ); + proxy.setShownDataItemProviderKeyFilter( QStringList( { QStringLiteral( "provider2" ) } ) ); QCOMPARE( proxy.rowCount(), 2 ); root1Index = proxy.index( 0, 0 ); QCOMPARE( proxy.rowCount( root1Index ), 1 ); - proxy.setShownDataItemProviderKeyFilter( QStringList( {QStringLiteral( "provider1" )} ) ); + proxy.setShownDataItemProviderKeyFilter( QStringList( { QStringLiteral( "provider1" ) } ) ); QCOMPARE( proxy.rowCount(), 1 ); root1Index = proxy.index( 0, 0 ); QCOMPARE( proxy.rowCount( root1Index ), 2 ); proxy.setShownDataItemProviderKeyFilter( QStringList() ); QCOMPARE( proxy.rowCount(), 2 ); - } void TestQgsBrowserProxyModel::testShowLayers() @@ -323,8 +319,7 @@ void TestQgsBrowserProxyModel::testShowLayers() QVERIFY( proxy.hasChildren( container1Index ) ); proxy.setShowLayers( false ); - QVERIFY( ! proxy.hasChildren( container1Index ) ); - + QVERIFY( !proxy.hasChildren( container1Index ) ); } QGSTEST_MAIN( TestQgsBrowserProxyModel ) diff --git a/tests/src/core/testqgscadutils.cpp b/tests/src/core/testqgscadutils.cpp index 6158842df5a0..a1ac1b442bb5 100644 --- a/tests/src/core/testqgscadutils.cpp +++ b/tests/src/core/testqgscadutils.cpp @@ -34,10 +34,10 @@ class TestQgsCadUtils : public QObject TestQgsCadUtils() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testBasic(); void testXY(); @@ -49,7 +49,6 @@ class TestQgsCadUtils : public QObject void testEdge(); private: - QgsCadUtils::AlignMapPointContext baseContext() { QgsCadUtils::AlignMapPointContext context; @@ -257,7 +256,7 @@ void TestQgsCadUtils::testDistance() QCOMPARE( res1.finalMapPoint, QgsPointXY( 35, 20 ) ); // dist+x - const double d = distance * sqrt( 2 ) / 2.; // sine/cosine of 45 times radius of our distance constraint + const double d = distance * sqrt( 2 ) / 2.; // sine/cosine of 45 times radius of our distance constraint const double expectedX1 = 30 + d; const double expectedY1 = 20 + d; context.xConstraint = QgsCadUtils::AlignMapPointConstraint( true, false, expectedX1 ); @@ -323,7 +322,7 @@ void TestQgsCadUtils::testLineExtension() mLayerPolygon->getFeatures().nextFeature( feature ); QgsFeatureId featId = feature.id(); - QQueue< QgsPointLocator::Match > lockedSnapVertices; + QQueue lockedSnapVertices; lockedSnapVertices.append( QgsPointLocator::Match( QgsPointLocator::Type::Vertex, mLayerPolygon, featId, 0, QgsPointXY( 30, 10 ), 2 ) ); lockedSnapVertices.append( QgsPointLocator::Match( QgsPointLocator::Type::Vertex, mLayerPolygon, featId, 0, QgsPointXY( 10, 20 ), 3 ) ); context.setLockedSnapVertices( lockedSnapVertices ); @@ -453,7 +452,7 @@ void TestQgsCadUtils::testVertexConstrainst() mLayerPolygon->getFeatures().nextFeature( feature ); QgsFeatureId featId = feature.id(); - QQueue< QgsPointLocator::Match > lockedSnapVertices; + QQueue lockedSnapVertices; lockedSnapVertices.append( QgsPointLocator::Match( QgsPointLocator::Type::Vertex, mLayerPolygon, featId, 0, QgsPointXY( 20, 0 ), 1 ) ); lockedSnapVertices.append( QgsPointLocator::Match( QgsPointLocator::Type::Vertex, mLayerPolygon, featId, 0, QgsPointXY( 10, 20 ), 3 ) ); context.setLockedSnapVertices( lockedSnapVertices ); @@ -574,7 +573,7 @@ void TestQgsCadUtils::testEdge() QgsCadUtils::AlignMapPointContext context( baseContext() ); context.setCadPoints( QList() << QgsPoint() << QgsPoint( 40, 30 ) << QgsPoint( 40, 40 ) ); - const QgsPointXY edgePt( 20, 15 ); // in the middle of the triangle polygon's edge + const QgsPointXY edgePt( 20, 15 ); // in the middle of the triangle polygon's edge // x+edge context.xConstraint = QgsCadUtils::AlignMapPointConstraint( true, false, 40 ); diff --git a/tests/src/core/testqgscallout.cpp b/tests/src/core/testqgscallout.cpp index 7b8d525cf957..fe0fcafdbd5f 100644 --- a/tests/src/core/testqgscallout.cpp +++ b/tests/src/core/testqgscallout.cpp @@ -75,8 +75,7 @@ class DummyCallout : public QgsCallout QString prop2() { return mProp2; } protected: - - void draw( QgsRenderContext &, const QRectF &, const double, const QgsGeometry &, QgsCallout::QgsCalloutContext & ) override { } + void draw( QgsRenderContext &, const QRectF &, const double, const QgsGeometry &, QgsCallout::QgsCalloutContext & ) override {} private: QString mProp1; @@ -87,7 +86,6 @@ class DummyCallout : public QgsCallout class TestSimpleCalloutUnder : public QgsSimpleLineCallout { public: - QString type() const override { return QStringLiteral( "SimpleUnder" ); } TestSimpleCalloutUnder *clone() const override { return new TestSimpleCalloutUnder( *this ); } QVariantMap properties( const QgsReadWriteContext & ) const override @@ -105,18 +103,19 @@ class TestSimpleCalloutUnder : public QgsSimpleLineCallout }; -class TestQgsCallout: public QgsTest +class TestQgsCallout : public QgsTest { Q_OBJECT public: - TestQgsCallout() : QgsTest( QStringLiteral( "Callout Tests" ), QStringLiteral( "callouts" ) ) {} + TestQgsCallout() + : QgsTest( QStringLiteral( "Callout Tests" ), QStringLiteral( "callouts" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void saveRestore(); void calloutsInLabeling(); @@ -180,10 +179,8 @@ class TestQgsCallout: public QgsTest void calloutsBlend(); private: - QString mTestDataDir; QgsVectorLayer *vl = nullptr; - }; void TestQgsCallout::initTestCase() @@ -208,10 +205,10 @@ void TestQgsCallout::init() const QString filename = QStringLiteral( TEST_DATA_DIR ) + "/points.shp"; vl = new QgsVectorLayer( filename, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( vl->isValid() ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl->setRenderer( new QgsSingleSymbolRenderer( marker ) ); QgsProject::instance()->addMapLayer( vl ); @@ -228,9 +225,9 @@ void TestQgsCallout::saveRestore() DummyCallout *callout = new DummyCallout( QStringLiteral( "a" ), QStringLiteral( "b" ) ); QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); //test writing with no node @@ -251,7 +248,7 @@ void TestQgsCallout::saveRestore() QCOMPARE( calloutElem.attribute( "type" ), QString( "Dummy" ) ); //test reading empty node - std::unique_ptr< QgsCallout > restoredCallout( QgsApplication::calloutRegistry()->createCallout( QStringLiteral( "Dummy" ), noNode, QgsReadWriteContext() ) ); + std::unique_ptr restoredCallout( QgsApplication::calloutRegistry()->createCallout( QStringLiteral( "Dummy" ), noNode, QgsReadWriteContext() ) ); QVERIFY( restoredCallout ); //test reading bad node @@ -426,7 +423,7 @@ void TestQgsCallout::calloutsWithRotation() callout->lineSymbol()->setWidth( 1 ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -444,7 +441,7 @@ void TestQgsCallout::calloutsInLayout() { //test rendering callouts inside a layout (tests DPI scaling of callouts) QgsLayout l( QgsProject::instance() ); - std::unique_ptr< QgsLayoutItemPage > page = std::make_unique< QgsLayoutItemPage >( &l ); + std::unique_ptr page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 50, 50 ) ); l.pageCollection()->addPage( page.release() ); @@ -524,7 +521,7 @@ void TestQgsCallout::calloutsDisabled() callout->lineSymbol()->setWidth( 1 ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -576,7 +573,7 @@ void TestQgsCallout::calloutsDataDefinedDisabled() settings.setCallout( callout ); settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::CalloutDraw, QgsProperty::fromExpression( QStringLiteral( "Class = 'Jet'" ) ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -628,7 +625,7 @@ void TestQgsCallout::calloutDataDefinedSymbol() callout->lineSymbol()->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::Property::StrokeColor, QgsProperty::fromExpression( QStringLiteral( "case when Class='Jet' then 'green' else 'blue' end" ) ) ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -680,7 +677,7 @@ void TestQgsCallout::calloutDataDefinedSymbolColor() callout->lineSymbol()->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::Property::StrokeColor, QgsProperty::fromExpression( QStringLiteral( "@symbol_color" ) ) ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -732,7 +729,7 @@ void TestQgsCallout::calloutMinimumDistance() callout->setMinimumLength( 10 ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -785,7 +782,7 @@ void TestQgsCallout::calloutDataDefinedMinimumDistance() settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -837,7 +834,7 @@ void TestQgsCallout::calloutOffsetFromAnchor() callout->setOffsetFromAnchor( 4 ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -889,7 +886,7 @@ void TestQgsCallout::calloutDataDefinedOffsetFromAnchor() callout->dataDefinedProperties().setProperty( QgsCallout::Property::OffsetFromAnchor, QgsProperty::fromExpression( QStringLiteral( "case when Class='Jet' then 2 else 6 end" ) ) ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -942,7 +939,7 @@ void TestQgsCallout::calloutOffsetFromLabel() callout->setOffsetFromLabel( 4 ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -995,7 +992,7 @@ void TestQgsCallout::calloutDataDefinedOffsetFromLabel() callout->dataDefinedProperties().setProperty( QgsCallout::Property::OffsetFromLabel, QgsProperty::fromExpression( QStringLiteral( "case when Class='Jet' then 3 else 4 end" ) ) ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1047,7 +1044,7 @@ void TestQgsCallout::calloutLabelAnchorTopRight() callout->setLabelAnchorPoint( QgsCallout::LabelTopRight ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1066,7 +1063,7 @@ void TestQgsCallout::calloutLabelAnchorTopRight() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1115,7 +1112,7 @@ void TestQgsCallout::calloutLabelAnchorTopLeft() callout->setLabelAnchorPoint( QgsCallout::LabelTopLeft ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1134,7 +1131,7 @@ void TestQgsCallout::calloutLabelAnchorTopLeft() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1183,7 +1180,7 @@ void TestQgsCallout::calloutLabelAnchorTop() callout->setLabelAnchorPoint( QgsCallout::LabelTopMiddle ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1202,7 +1199,7 @@ void TestQgsCallout::calloutLabelAnchorTop() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1251,7 +1248,7 @@ void TestQgsCallout::calloutLabelAnchorBottomLeft() callout->setLabelAnchorPoint( QgsCallout::LabelBottomLeft ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1270,7 +1267,7 @@ void TestQgsCallout::calloutLabelAnchorBottomLeft() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1319,7 +1316,7 @@ void TestQgsCallout::calloutLabelAnchorBottom() callout->setLabelAnchorPoint( QgsCallout::LabelBottomMiddle ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1338,7 +1335,7 @@ void TestQgsCallout::calloutLabelAnchorBottom() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1387,7 +1384,7 @@ void TestQgsCallout::calloutLabelAnchorBottomRight() callout->setLabelAnchorPoint( QgsCallout::LabelBottomRight ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1406,7 +1403,7 @@ void TestQgsCallout::calloutLabelAnchorBottomRight() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1455,7 +1452,7 @@ void TestQgsCallout::calloutLabelAnchorLeft() callout->setLabelAnchorPoint( QgsCallout::LabelMiddleLeft ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1474,7 +1471,7 @@ void TestQgsCallout::calloutLabelAnchorLeft() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1523,7 +1520,7 @@ void TestQgsCallout::calloutLabelAnchorRight() callout->setLabelAnchorPoint( QgsCallout::LabelMiddleRight ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1542,7 +1539,7 @@ void TestQgsCallout::calloutLabelAnchorRight() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1591,7 +1588,7 @@ void TestQgsCallout::calloutLabelAnchorCentroid() callout->setLabelAnchorPoint( QgsCallout::LabelCentroid ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1610,7 +1607,7 @@ void TestQgsCallout::calloutLabelAnchorCentroid() settings.xOffset = 6; settings.yOffset = -6; settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromValue( 15 ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsDefaultLabelingEngine engine2; engine2.setMapSettings( mapSettings ); @@ -1660,7 +1657,7 @@ void TestQgsCallout::calloutLabelDataDefinedAnchor() callout->dataDefinedProperties().setProperty( QgsCallout::Property::LabelAnchorPointPosition, QgsProperty::fromExpression( QStringLiteral( "'TL'" ) ) ); settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1716,7 +1713,7 @@ void TestQgsCallout::calloutBehindLabel() settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1772,7 +1769,7 @@ void TestQgsCallout::calloutBehindIndividualLabels() settings.setCallout( callout ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1788,11 +1785,11 @@ void TestQgsCallout::calloutBehindIndividualLabels() void TestQgsCallout::calloutNoDrawToAllParts() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl2->setRenderer( new QgsSingleSymbolRenderer( marker ) ); QgsFeature f; @@ -1840,7 +1837,7 @@ void TestQgsCallout::calloutNoDrawToAllParts() callout->lineSymbol()->setWidth( 1 ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1856,11 +1853,11 @@ void TestQgsCallout::calloutNoDrawToAllParts() void TestQgsCallout::calloutDrawToAllParts() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl2->setRenderer( new QgsSingleSymbolRenderer( marker ) ); QgsFeature f; @@ -1909,7 +1906,7 @@ void TestQgsCallout::calloutDrawToAllParts() callout->setDrawCalloutToAllParts( true ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1925,11 +1922,11 @@ void TestQgsCallout::calloutDrawToAllParts() void TestQgsCallout::calloutDataDefinedDrawToAllParts() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl2->setRenderer( new QgsSingleSymbolRenderer( marker ) ); QgsFeature f; @@ -1978,7 +1975,7 @@ void TestQgsCallout::calloutDataDefinedDrawToAllParts() callout->dataDefinedProperties().setProperty( QgsCallout::Property::DrawCalloutToAllParts, QgsProperty::fromExpression( QStringLiteral( "\"id\"=1" ) ) ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -1994,8 +1991,8 @@ void TestQgsCallout::calloutDataDefinedDrawToAllParts() void TestQgsCallout::calloutPointOnExterior() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsFillSymbol *fill = static_cast< QgsFillSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2041,7 +2038,7 @@ void TestQgsCallout::calloutPointOnExterior() callout->setAnchorPoint( QgsCallout::PointOnExterior ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2057,8 +2054,8 @@ void TestQgsCallout::calloutPointOnExterior() void TestQgsCallout::calloutDataDefinedAnchorPoint() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsFillSymbol *fill = static_cast< QgsFillSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2104,7 +2101,7 @@ void TestQgsCallout::calloutDataDefinedAnchorPoint() callout->dataDefinedProperties().setProperty( QgsCallout::Property::AnchorPointPosition, QgsProperty::fromExpression( QStringLiteral( "'centroid'" ) ) ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2120,8 +2117,8 @@ void TestQgsCallout::calloutDataDefinedAnchorPoint() void TestQgsCallout::calloutDataDefinedDestination() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsFillSymbol *fill = static_cast< QgsFillSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2169,7 +2166,7 @@ void TestQgsCallout::calloutDataDefinedDestination() callout->dataDefinedProperties().setProperty( QgsCallout::Property::DestinationY, QgsProperty::fromExpression( QStringLiteral( "5000096.84" ) ) ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2185,8 +2182,8 @@ void TestQgsCallout::calloutDataDefinedDestination() void TestQgsCallout::calloutDataDefinedOrigin() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsFillSymbol *fill = static_cast< QgsFillSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2234,7 +2231,7 @@ void TestQgsCallout::calloutDataDefinedOrigin() callout->dataDefinedProperties().setProperty( QgsCallout::Property::OriginY, QgsProperty::fromExpression( QStringLiteral( "4999948.34" ) ) ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2355,11 +2352,11 @@ void TestQgsCallout::manhattanRotated() void TestQgsCallout::manhattanNoDrawToAllParts() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl2->setRenderer( new QgsSingleSymbolRenderer( marker ) ); QgsFeature f; @@ -2407,7 +2404,7 @@ void TestQgsCallout::manhattanNoDrawToAllParts() callout->lineSymbol()->setWidth( 1 ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2423,11 +2420,11 @@ void TestQgsCallout::manhattanNoDrawToAllParts() void TestQgsCallout::manhattanDrawToAllParts() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl2->setRenderer( new QgsSingleSymbolRenderer( marker ) ); QgsFeature f; @@ -2476,7 +2473,7 @@ void TestQgsCallout::manhattanDrawToAllParts() callout->setDrawCalloutToAllParts( true ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2492,11 +2489,11 @@ void TestQgsCallout::manhattanDrawToAllParts() void TestQgsCallout::manhattanDataDefinedDrawToAllParts() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl2->setRenderer( new QgsSingleSymbolRenderer( marker ) ); QgsFeature f; @@ -2545,7 +2542,7 @@ void TestQgsCallout::manhattanDataDefinedDrawToAllParts() callout->dataDefinedProperties().setProperty( QgsCallout::Property::DrawCalloutToAllParts, QgsProperty::fromExpression( QStringLiteral( "\"id\"=1" ) ) ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2561,8 +2558,8 @@ void TestQgsCallout::manhattanDataDefinedDrawToAllParts() void TestQgsCallout::manhattanDataDefinedDestination() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsFillSymbol *fill = static_cast< QgsFillSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2610,7 +2607,7 @@ void TestQgsCallout::manhattanDataDefinedDestination() callout->dataDefinedProperties().setProperty( QgsCallout::Property::DestinationY, QgsProperty::fromExpression( QStringLiteral( "5000096.84" ) ) ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2626,8 +2623,8 @@ void TestQgsCallout::manhattanDataDefinedDestination() void TestQgsCallout::manhattanDataDefinedOrigin() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - QgsFillSymbol *fill = static_cast< QgsFillSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + QgsFillSymbol *fill = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ); fill->setColor( QColor( 255, 0, 0 ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( fill ) ); @@ -2675,7 +2672,7 @@ void TestQgsCallout::manhattanDataDefinedOrigin() callout->dataDefinedProperties().setProperty( QgsCallout::Property::OriginY, QgsProperty::fromExpression( QStringLiteral( "4999948.34" ) ) ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2691,7 +2688,7 @@ void TestQgsCallout::manhattanDataDefinedOrigin() void TestQgsCallout::curvedAutoLeavingLabelsAtBottomLeft() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2775,7 +2772,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottomLeft() callout->setLabelAnchorPoint( QgsCallout::LabelBottomLeft ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2791,7 +2788,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottomLeft() void TestQgsCallout::curvedAutoLeavingLabelsAtBottomRight() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2875,7 +2872,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottomRight() callout->setLabelAnchorPoint( QgsCallout::LabelBottomRight ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2891,7 +2888,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottomRight() void TestQgsCallout::curvedAutoLeavingLabelsAtTopLeft() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2975,7 +2972,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTopLeft() callout->setLabelAnchorPoint( QgsCallout::LabelTopLeft ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -2991,7 +2988,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTopLeft() void TestQgsCallout::curvedAutoLeavingLabelsAtTopRight() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3075,7 +3072,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTopRight() callout->setLabelAnchorPoint( QgsCallout::LabelTopRight ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3091,7 +3088,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTopRight() void TestQgsCallout::curvedAutoLeavingLabelsAtTop() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3175,7 +3172,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTop() callout->setLabelAnchorPoint( QgsCallout::LabelTopMiddle ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3191,7 +3188,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtTop() void TestQgsCallout::curvedAutoLeavingLabelsAtBottom() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3275,7 +3272,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottom() callout->setLabelAnchorPoint( QgsCallout::LabelBottomMiddle ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3291,7 +3288,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtBottom() void TestQgsCallout::curvedAutoLeavingLabelsAtLeft() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3375,7 +3372,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtLeft() callout->setLabelAnchorPoint( QgsCallout::LabelMiddleLeft ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3391,7 +3388,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtLeft() void TestQgsCallout::curvedAutoLeavingLabelsAtRight() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3475,7 +3472,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtRight() callout->setLabelAnchorPoint( QgsCallout::LabelMiddleRight ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3491,7 +3488,7 @@ void TestQgsCallout::curvedAutoLeavingLabelsAtRight() void TestQgsCallout::curvedAutoHorizontalLines() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3544,7 +3541,7 @@ void TestQgsCallout::curvedAutoHorizontalLines() callout->lineSymbol()->setWidth( 1 ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3560,7 +3557,7 @@ void TestQgsCallout::curvedAutoHorizontalLines() void TestQgsCallout::curvedAutoVerticalLines() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3613,7 +3610,7 @@ void TestQgsCallout::curvedAutoVerticalLines() callout->lineSymbol()->setWidth( 1 ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3629,7 +3626,7 @@ void TestQgsCallout::curvedAutoVerticalLines() void TestQgsCallout::curvedClockwise() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3713,7 +3710,7 @@ void TestQgsCallout::curvedClockwise() callout->setOrientation( QgsCurvedLineCallout::Clockwise ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3729,7 +3726,7 @@ void TestQgsCallout::curvedClockwise() void TestQgsCallout::curvedCounterClockwise() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3813,7 +3810,7 @@ void TestQgsCallout::curvedCounterClockwise() callout->setOrientation( QgsCurvedLineCallout::CounterClockwise ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3829,7 +3826,7 @@ void TestQgsCallout::curvedCounterClockwise() void TestQgsCallout::curvedCurvature() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer&field=labelx:integer&field=labely:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -3914,7 +3911,7 @@ void TestQgsCallout::curvedCurvature() callout->setCurvature( 0.3 ); settings.setCallout( callout ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -3963,9 +3960,7 @@ void TestQgsCallout::balloonCallout() QgsBalloonCallout *callout = new QgsBalloonCallout(); callout->setEnabled( true ); - callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc"}, - { "outline-width", "1"} - } ) ) ); + callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc" }, { "outline-width", "1" } } ) ) ); settings.setCallout( callout ); vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); @@ -4017,9 +4012,7 @@ void TestQgsCallout::balloonCalloutMargin() QgsBalloonCallout *callout = new QgsBalloonCallout(); callout->setEnabled( true ); - callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc"}, - { "outline-width", "1"} - } ) ) ); + callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc" }, { "outline-width", "1" } } ) ) ); callout->setMargins( QgsMargins( 1, 2, 3, 4 ) ); settings.setCallout( callout ); @@ -4072,9 +4065,7 @@ void TestQgsCallout::balloonCalloutWedgeWidth() QgsBalloonCallout *callout = new QgsBalloonCallout(); callout->setEnabled( true ); - callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc"}, - { "outline-width", "1"} - } ) ) ); + callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc" }, { "outline-width", "1" } } ) ) ); callout->setWedgeWidth( 6 ); settings.setCallout( callout ); @@ -4127,9 +4118,7 @@ void TestQgsCallout::balloonCalloutCornerRadius() QgsBalloonCallout *callout = new QgsBalloonCallout(); callout->setEnabled( true ); - callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc"}, - { "outline-width", "1"} - } ) ) ); + callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc" }, { "outline-width", "1" } } ) ) ); callout->setCornerRadius( 3 ); settings.setCallout( callout ); @@ -4182,9 +4171,7 @@ void TestQgsCallout::balloonCalloutMarkerSymbol() QgsBalloonCallout *callout = new QgsBalloonCallout(); callout->setEnabled( true ); - callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc"}, - { "outline-width", "1"} - } ) ) ); + callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc" }, { "outline-width", "1" } } ) ) ); callout->setOffsetFromAnchor( 1 ); QVariantMap props; @@ -4213,7 +4200,7 @@ void TestQgsCallout::balloonCalloutMarkerSymbol() void TestQgsCallout::blendMode() { - std::unique_ptr< QgsManhattanLineCallout > callout = std::make_unique< QgsManhattanLineCallout >(); + std::unique_ptr callout = std::make_unique(); QCOMPARE( callout->containsAdvancedEffects(), false ); callout->setBlendMode( QPainter::CompositionMode_Multiply ); diff --git a/tests/src/core/testqgscalloutregistry.cpp b/tests/src/core/testqgscalloutregistry.cpp index d528b40020aa..75b4f63332be 100644 --- a/tests/src/core/testqgscalloutregistry.cpp +++ b/tests/src/core/testqgscalloutregistry.cpp @@ -30,9 +30,9 @@ class DummyCallout : public QgsCallout QString type() const override { return QStringLiteral( "Dummy" ); } QgsCallout *clone() const override { return new DummyCallout(); } static QgsCallout *create( const QVariantMap &, const QgsReadWriteContext & ) { return new DummyCallout(); } + protected: void draw( QgsRenderContext &, const QRectF &, const double, const QgsGeometry &, QgsCallout::QgsCalloutContext & ) override {} - }; class TestQgsCalloutRegistry : public QObject @@ -53,7 +53,6 @@ class TestQgsCalloutRegistry : public QObject void defaultCallout(); private: - }; void TestQgsCalloutRegistry::initTestCase() @@ -69,12 +68,10 @@ void TestQgsCalloutRegistry::cleanupTestCase() void TestQgsCalloutRegistry::init() { - } void TestQgsCalloutRegistry::cleanup() { - } void TestQgsCalloutRegistry::metadata() @@ -85,7 +82,7 @@ void TestQgsCalloutRegistry::metadata() //test creating callout from metadata const QVariantMap map; - const std::unique_ptr< QgsCallout > callout( metadata.createCallout( map, QgsReadWriteContext() ) ); + const std::unique_ptr callout( metadata.createCallout( map, QgsReadWriteContext() ) ); QVERIFY( callout ); DummyCallout *dummyCallout = dynamic_cast( callout.get() ); QVERIFY( dummyCallout ); @@ -115,7 +112,7 @@ void TestQgsCalloutRegistry::addCallout() QCOMPARE( registry->calloutTypes().length(), previousCount + 1 ); //try adding again, should have no effect QgsCalloutMetadata *dupe = new QgsCalloutMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "Dummy callout" ), QIcon(), DummyCallout::create ); - QVERIFY( ! registry->addCalloutType( dupe ) ); + QVERIFY( !registry->addCalloutType( dupe ) ); QCOMPARE( registry->calloutTypes().length(), previousCount + 1 ); delete dupe; @@ -142,7 +139,7 @@ void TestQgsCalloutRegistry::fetchTypes() void TestQgsCalloutRegistry::createCallout() { QgsCalloutRegistry *registry = QgsApplication::calloutRegistry(); - std::unique_ptr< QgsCallout > callout( registry->createCallout( QStringLiteral( "Dummy" ) ) ); + std::unique_ptr callout( registry->createCallout( QStringLiteral( "Dummy" ) ) ); QVERIFY( callout.get() ); DummyCallout *dummyCallout = dynamic_cast( callout.get() ); @@ -155,7 +152,7 @@ void TestQgsCalloutRegistry::createCallout() void TestQgsCalloutRegistry::defaultCallout() { - const std::unique_ptr< QgsCallout > callout( QgsCalloutRegistry::defaultCallout() ); + const std::unique_ptr callout( QgsCalloutRegistry::defaultCallout() ); QVERIFY( callout.get() ); } diff --git a/tests/src/core/testqgscentroidfillsymbol.cpp b/tests/src/core/testqgscentroidfillsymbol.cpp index eb02d4545e64..6efa05690062 100644 --- a/tests/src/core/testqgscentroidfillsymbol.cpp +++ b/tests/src/core/testqgscentroidfillsymbol.cpp @@ -42,11 +42,12 @@ class TestQgsCentroidFillSymbol : public QgsTest Q_OBJECT public: - TestQgsCentroidFillSymbol() : QgsTest( QStringLiteral( "Centroid Fill Symbol Tests" ), QStringLiteral( "symbol_centroidfill" ) ) {} + TestQgsCentroidFillSymbol() + : QgsTest( QStringLiteral( "Centroid Fill Symbol Tests" ), QStringLiteral( "symbol_centroidfill" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void centroidFillSymbol(); void centroidFillSymbolPointOnSurface(); @@ -59,7 +60,7 @@ class TestQgsCentroidFillSymbol : public QgsTest void dataDefinedOpacity(); private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings mMapSettings; QgsVectorLayer *mpPolysLayer = nullptr; @@ -87,8 +88,7 @@ void TestQgsCentroidFillSymbol::initTestCase() // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -96,7 +96,7 @@ void TestQgsCentroidFillSymbol::initTestCase() //setup gradient fill mCentroidFill = new QgsCentroidFillSymbolLayer(); - static_cast< QgsSimpleMarkerSymbolLayer * >( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); + static_cast( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); mFillSymbol = new QgsFillSymbol(); mFillSymbol->changeSymbolLayer( 0, mCentroidFill ); mSymbolRenderer = new QgsSingleSymbolRenderer( mFillSymbol ); @@ -107,7 +107,6 @@ void TestQgsCentroidFillSymbol::initTestCase() // and is more light weight // mMapSettings.setLayers( QList() << mpPolysLayer ); - } void TestQgsCentroidFillSymbol::cleanupTestCase() { @@ -204,8 +203,8 @@ void TestQgsCentroidFillSymbol::opacityWithDataDefinedColor() mCentroidFill->subSymbol()->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty::fromExpression( QStringLiteral( "if(Name='Dam', 'red', 'green')" ) ) ); mCentroidFill->subSymbol()->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::Property::StrokeColor, QgsProperty::fromExpression( QStringLiteral( "if(Name='Dam', 'blue', 'magenta')" ) ) ); - qgis::down_cast< QgsSimpleMarkerSymbolLayer * >( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeWidth( 0.5 ); - qgis::down_cast< QgsSimpleMarkerSymbolLayer * >( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setSize( 5 ); + qgis::down_cast( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeWidth( 0.5 ); + qgis::down_cast( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setSize( 5 ); mCentroidFill->subSymbol()->setOpacity( 0.5 ); mFillSymbol->setOpacity( 0.5 ); @@ -220,8 +219,8 @@ void TestQgsCentroidFillSymbol::dataDefinedOpacity() mCentroidFill->subSymbol()->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty::fromExpression( QStringLiteral( "if(Name='Dam', 'red', 'green')" ) ) ); mCentroidFill->subSymbol()->symbolLayer( 0 )->setDataDefinedProperty( QgsSymbolLayer::Property::StrokeColor, QgsProperty::fromExpression( QStringLiteral( "if(Name='Dam', 'blue', 'magenta')" ) ) ); - qgis::down_cast< QgsSimpleMarkerSymbolLayer * >( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeWidth( 0.5 ); - qgis::down_cast< QgsSimpleMarkerSymbolLayer * >( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setSize( 5 ); + qgis::down_cast( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeWidth( 0.5 ); + qgis::down_cast( mCentroidFill->subSymbol()->symbolLayer( 0 ) )->setSize( 5 ); mCentroidFill->subSymbol()->setOpacity( 0.5 ); mFillSymbol->setOpacity( 1.0 ); mFillSymbol->setDataDefinedProperty( QgsSymbol::Property::Opacity, QgsProperty::fromExpression( QStringLiteral( "if(\"Value\" >10, 25, 50)" ) ) ); diff --git a/tests/src/core/testqgsclipper.cpp b/tests/src/core/testqgsclipper.cpp index b204a72cdf54..d09931bc92d3 100644 --- a/tests/src/core/testqgsclipper.cpp +++ b/tests/src/core/testqgsclipper.cpp @@ -27,17 +27,17 @@ #include "qgssinglesymbolrenderer.h" #include "qgsrenderchecker.h" -class TestQgsClipper: public QgsTest +class TestQgsClipper : public QgsTest { - Q_OBJECT public: - TestQgsClipper() : QgsTest( QStringLiteral( "Clipper Rendering Tests" ), QStringLiteral( "3d" ) ) {} + TestQgsClipper() + : QgsTest( QStringLiteral( "Clipper Rendering Tests" ), QStringLiteral( "3d" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void basic(); void basicWithZ(); void basicWithZInf(); @@ -45,7 +45,6 @@ class TestQgsClipper: public QgsTest void clipGeometryWithNaNZValues(); private: - bool checkBoundingBox( const QPolygonF &polygon, const QgsRectangle &clipRect ); bool checkBoundingBox( const QgsLineString &polygon, const QgsBox3D &clipRect ); }; @@ -66,9 +65,9 @@ void TestQgsClipper::basicWithZ() // QgsClipper is static only QgsBox3D clipRect( 10, 10, 11, 25, 30, 19 ); - QVector< double > x; - QVector< double > y; - QVector< double > z; + QVector x; + QVector y; + QVector z; // check that clipping an empty polygon doesn't crash QgsClipper::trimPolygon( x, y, z, clipRect ); @@ -82,7 +81,7 @@ void TestQgsClipper::basicWithZ() // Check that it didn't clip too much QgsBox3D clipRectInner( clipRect ); clipRectInner.scale( 0.999 ); - QVERIFY( ! checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); + QVERIFY( !checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); // A more complex example x = { 1.0, 11.0, 9.0 }; @@ -101,16 +100,16 @@ void TestQgsClipper::basicWithZ() // Check that it didn't clip too much clipRectInner = clipRect; clipRectInner.scale( 0.999 ); - QVERIFY( ! checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); + QVERIFY( !checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); } void TestQgsClipper::basicWithZInf() { // QgsClipper is static only - QVector< double > x { 10.4, 20.2 }; - QVector< double > y { 20.5, 30.2 }; - QVector< double > z { 10.0, 20.0 }; + QVector x { 10.4, 20.2 }; + QVector y { 20.5, 30.2 }; + QVector z { 10.0, 20.0 }; QgsBox3D clipRect( 10, 10, -HUGE_VAL, 25, 30, HUGE_VAL ); @@ -121,7 +120,7 @@ void TestQgsClipper::basicWithZInf() // Check that it didn't clip too much QgsBox3D clipRectInner( clipRect ); clipRectInner.scale( 0.999 ); - QVERIFY( ! checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); + QVERIFY( !checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); // A more complex example x = { 1.0, 11.0, 9.0 }; @@ -140,7 +139,7 @@ void TestQgsClipper::basicWithZInf() // Check that it didn't clip too much clipRectInner = clipRect; clipRectInner.scale( 0.999 ); - QVERIFY( ! checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); + QVERIFY( !checkBoundingBox( QgsLineString( x, y, z ), clipRectInner ) ); } void TestQgsClipper::basic() @@ -159,7 +158,7 @@ void TestQgsClipper::basic() // Check that it didn't clip too much QgsRectangle clipRectInner( clipRect ); clipRectInner.scale( 0.999 ); - QVERIFY( ! checkBoundingBox( polygon, clipRectInner ) ); + QVERIFY( !checkBoundingBox( polygon, clipRectInner ) ); // A more complex example polygon.clear(); @@ -175,7 +174,7 @@ void TestQgsClipper::basic() // Check that it didn't clip too much clipRectInner = clipRect; clipRectInner.scale( 0.999 ); - QVERIFY( ! checkBoundingBox( polygon, clipRectInner ) ); + QVERIFY( !checkBoundingBox( polygon, clipRectInner ) ); } bool TestQgsClipper::checkBoundingBox( const QgsLineString &polygon, const QgsBox3D &clipRect ) @@ -192,7 +191,7 @@ bool TestQgsClipper::checkBoundingBox( const QPolygonF &polygon, const QgsRectan void TestQgsClipper::epsg4978LineRendering() { - std::unique_ptr< QgsVectorLayer >layerLines = std::make_unique< QgsVectorLayer >( QString( TEST_DATA_DIR ) + "/3d/earth_size_sphere_4978.gpkg", "lines", "ogr" ); + std::unique_ptr layerLines = std::make_unique( QString( TEST_DATA_DIR ) + "/3d/earth_size_sphere_4978.gpkg", "lines", "ogr" ); QgsLineSymbol *fillSymbol = new QgsLineSymbol(); fillSymbol->setWidth( 0.5 ); @@ -212,7 +211,7 @@ void TestQgsClipper::clipGeometryWithNaNZValues() { // nan z values should not result in clipping QgsGeometry geom = QgsGeometry::fromWkt( QStringLiteral( "PolygonZ ((704425.82266869 7060014.33574043 19.51, 704439.59844559 7060023.73007711 19.69, 704441.6748229 7060020.65665367 19.63, 704428.333268 7060011.65915509 19.42, 704428.15434668 7060011.92446088 0, 704441.23037799 7060020.74289127 0, 704439.51320673 7060023.28462315 0, 704426.00295955 7060014.07136342 0, 704425.82266869 7060014.33574043 19.51))" ) ); - QgsLineString *exteriorRing = qgsgeometry_cast< QgsLineString * >( qgsgeometry_cast< QgsPolygon *>( geom.get() )->exteriorRing() ); + QgsLineString *exteriorRing = qgsgeometry_cast( qgsgeometry_cast( geom.get() )->exteriorRing() ); exteriorRing->setZAt( 4, std::numeric_limits::quiet_NaN() ); exteriorRing->setZAt( 5, std::numeric_limits::quiet_NaN() ); exteriorRing->setZAt( 6, std::numeric_limits::quiet_NaN() ); @@ -221,9 +220,9 @@ void TestQgsClipper::clipGeometryWithNaNZValues() QPolygonF polygon; polygon << QPointF( 10.4, 20.5 ) << QPointF( 20.2, 30.2 ); - QVector< double > pointsX = exteriorRing->xVector(); - QVector< double > pointsY = exteriorRing->yVector(); - QVector< double > pointsZ = exteriorRing->zVector(); + QVector pointsX = exteriorRing->xVector(); + QVector pointsY = exteriorRing->yVector(); + QVector pointsZ = exteriorRing->zVector(); QCOMPARE( pointsX.size(), 9 ); // 2d trim diff --git a/tests/src/core/testqgscolorscheme.cpp b/tests/src/core/testqgscolorscheme.cpp index 1aa4172346ae..736906cdba5b 100644 --- a/tests/src/core/testqgscolorscheme.cpp +++ b/tests/src/core/testqgscolorscheme.cpp @@ -24,15 +24,13 @@ class DummyColorScheme : public QgsColorScheme { public: - DummyColorScheme() = default; QString schemeName() const override { return QStringLiteral( "Dummy scheme" ); } - QgsNamedColorList fetchColors( const QString &context = QString(), - const QColor &baseColor = QColor() ) override + QgsNamedColorList fetchColors( const QString &context = QString(), const QColor &baseColor = QColor() ) override { - QList< QPair< QColor, QString> > colors; + QList> colors; if ( context == QLatin1String( "testscheme" ) ) { colors << qMakePair( QColor( 255, 255, 0 ), QStringLiteral( "schemetest" ) ); @@ -52,7 +50,6 @@ class DummyColorScheme : public QgsColorScheme { return new DummyColorScheme(); } - }; class TestQgsColorScheme : public QObject @@ -60,19 +57,18 @@ class TestQgsColorScheme : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void createScheme(); // test creation of a scheme - void getName(); //get scheme name - void colorsNoBase(); //fetch colors with no base color - void colorsWithBase(); //fetch colors using a base color + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void createScheme(); // test creation of a scheme + void getName(); //get scheme name + void colorsNoBase(); //fetch colors with no base color + void colorsWithBase(); //fetch colors using a base color void colorsWithScheme(); //fetch colors using a scheme - void clone(); //test cloning color scheme + void clone(); //test cloning color scheme private: - }; void TestQgsColorScheme::initTestCase() @@ -87,12 +83,10 @@ void TestQgsColorScheme::cleanupTestCase() void TestQgsColorScheme::init() { - } void TestQgsColorScheme::cleanup() { - } void TestQgsColorScheme::createScheme() @@ -104,7 +98,7 @@ void TestQgsColorScheme::createScheme() void TestQgsColorScheme::getName() { const std::shared_ptr dummyScheme( new DummyColorScheme() ); - QCOMPARE( dummyScheme->schemeName(), QString( "Dummy scheme" ) ); + QCOMPARE( dummyScheme->schemeName(), QString( "Dummy scheme" ) ); } void TestQgsColorScheme::colorsNoBase() diff --git a/tests/src/core/testqgscolorschemeregistry.cpp b/tests/src/core/testqgscolorschemeregistry.cpp index 2884eefcffd7..cb254599f172 100644 --- a/tests/src/core/testqgscolorschemeregistry.cpp +++ b/tests/src/core/testqgscolorschemeregistry.cpp @@ -26,15 +26,13 @@ class DummyColorScheme : public QgsColorScheme { public: - DummyColorScheme() = default; QString schemeName() const override { return QStringLiteral( "Dummy scheme" ); } - QgsNamedColorList fetchColors( const QString &context = QString(), - const QColor &baseColor = QColor() ) override + QgsNamedColorList fetchColors( const QString &context = QString(), const QColor &baseColor = QColor() ) override { - QList< QPair< QColor, QString> > colors; + QList> colors; if ( context == QLatin1String( "testscheme" ) ) { colors << qMakePair( QColor( 255, 255, 0 ), QStringLiteral( "schemetest" ) ); @@ -54,21 +52,18 @@ class DummyColorScheme : public QgsColorScheme { return new DummyColorScheme(); } - }; class DummyColorScheme2 : public QgsColorScheme { public: - DummyColorScheme2() = default; QString schemeName() const override { return QStringLiteral( "Dummy scheme2" ); } - QgsNamedColorList fetchColors( const QString & = QString(), - const QColor & = QColor() ) override + QgsNamedColorList fetchColors( const QString & = QString(), const QColor & = QColor() ) override { - QList< QPair< QColor, QString> > colors; + QList> colors; colors << qMakePair( QColor( 255, 255, 0 ), QStringLiteral( "schemetest" ) ); return colors; } @@ -77,7 +72,6 @@ class DummyColorScheme2 : public QgsColorScheme { return new DummyColorScheme2(); } - }; class TestQgsColorSchemeRegistry : public QObject @@ -85,22 +79,21 @@ class TestQgsColorSchemeRegistry : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void createInstance(); // create global instance of QgsColorSchemeRegistry + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void createInstance(); // create global instance of QgsColorSchemeRegistry void instanceHasDefaultSchemes(); // check that global instance is populated with default schemes - void createEmpty(); // check that creating an empty registry works - void addScheme(); // check adding a scheme to an empty registry - void addDefaultSchemes(); // check adding a scheme to an empty registry - void populateFromInstance(); // check populating an empty scheme from the registry - void removeScheme(); // check removing a scheme from a registry - void matchingSchemes(); //check fetching schemes of specific type + void createEmpty(); // check that creating an empty registry works + void addScheme(); // check adding a scheme to an empty registry + void addDefaultSchemes(); // check adding a scheme to an empty registry + void populateFromInstance(); // check populating an empty scheme from the registry + void removeScheme(); // check removing a scheme from a registry + void matchingSchemes(); //check fetching schemes of specific type void fetchRandomStyleColor(); private: - }; void TestQgsColorSchemeRegistry::initTestCase() @@ -116,12 +109,10 @@ void TestQgsColorSchemeRegistry::cleanupTestCase() void TestQgsColorSchemeRegistry::init() { - } void TestQgsColorSchemeRegistry::cleanup() { - } void TestQgsColorSchemeRegistry::createInstance() @@ -201,8 +192,8 @@ void TestQgsColorSchemeRegistry::matchingSchemes() DummyColorScheme *dummyScheme = new DummyColorScheme(); registry->addColorScheme( dummyScheme ); QVERIFY( registry->schemes().length() == 2 ); - QList< QgsRecentColorScheme * > recentSchemes; - QList< DummyColorScheme * > dummySchemes; + QList recentSchemes; + QList dummySchemes; registry->schemes( recentSchemes ); QVERIFY( recentSchemes.length() == 1 ); QCOMPARE( recentSchemes.at( 0 ), recentScheme ); @@ -213,7 +204,7 @@ void TestQgsColorSchemeRegistry::matchingSchemes() void TestQgsColorSchemeRegistry::fetchRandomStyleColor() { - std::unique_ptr registry = std::make_unique< QgsColorSchemeRegistry >(); + std::unique_ptr registry = std::make_unique(); // no randomStyleColorScheme set - test lots of colors to make sure their valid for ( int i = 0; i < 10000; ++i ) diff --git a/tests/src/core/testqgscompositionconverter.cpp b/tests/src/core/testqgscompositionconverter.cpp index 9e0ed2459885..056b0f5e3255 100644 --- a/tests/src/core/testqgscompositionconverter.cpp +++ b/tests/src/core/testqgscompositionconverter.cpp @@ -48,17 +48,18 @@ QDebug operator<<( QDebug dbg, const QDomNode &node ) return dbg; } -class TestQgsCompositionConverter: public QgsTest +class TestQgsCompositionConverter : public QgsTest { Q_OBJECT public: - TestQgsCompositionConverter() : QgsTest( QStringLiteral( "Composition Converter Tests" ), QStringLiteral( "compositionconverter" ) ) {} + TestQgsCompositionConverter() + : QgsTest( QStringLiteral( "Composition Converter Tests" ), QStringLiteral( "compositionconverter" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. /** @@ -148,11 +149,9 @@ class TestQgsCompositionConverter: public QgsTest private: - void checkRenderedImage( QgsLayout *layout, const QString &testName, int pageNumber = 0 ); QDomElement loadComposer( const QString &name ); - }; void TestQgsCompositionConverter::initTestCase() @@ -164,12 +163,10 @@ void TestQgsCompositionConverter::initTestCase() void TestQgsCompositionConverter::init() { - } void TestQgsCompositionConverter::cleanup() { - } @@ -178,8 +175,8 @@ void TestQgsCompositionConverter::importComposerTemplateLabel() QDomElement composerElem( loadComposer( QStringLiteral( "2x_template_label.qpt" ) ) ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -199,7 +196,7 @@ void TestQgsCompositionConverter::importComposerTemplateLabel() QCOMPARE( label->referencePoint(), QgsLayoutItem::ReferencePoint::UpperRight ); QCOMPARE( label->frameStrokeColor(), QColor( 251, 0, 0, 255 ) ); QCOMPARE( label->frameStrokeWidth().length(), 0.2 ); - QCOMPARE( ( int )label->rotation(), 4 ); + QCOMPARE( ( int ) label->rotation(), 4 ); checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); @@ -211,9 +208,9 @@ void TestQgsCompositionConverter::importComposerTemplateShape() QDomElement composerElem( loadComposer( QStringLiteral( "2x_template_shape.qpt" ) ) ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -233,7 +230,7 @@ void TestQgsCompositionConverter::importComposerTemplateShape() QCOMPARE( shape->frameStrokeColor(), QColor( 0, 0, 0, 255 ) ); QCOMPARE( shape->frameStrokeWidth().length(), 0.3 ); QCOMPARE( shape->backgroundColor(), QColor( 255, 255, 255, 255 ) ); - QCOMPARE( ( int )shape->rotation(), 0 ); + QCOMPARE( ( int ) shape->rotation(), 0 ); QCOMPARE( shape->frameEnabled(), false ); QCOMPARE( shape->hasBackground(), false ); @@ -248,9 +245,9 @@ void TestQgsCompositionConverter::importComposerTemplatePicture() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -271,7 +268,6 @@ void TestQgsCompositionConverter::importComposerTemplatePicture() checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); qDeleteAll( items ); - } void TestQgsCompositionConverter::importComposerTemplatePolygon() @@ -280,9 +276,9 @@ void TestQgsCompositionConverter::importComposerTemplatePolygon() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -297,7 +293,6 @@ void TestQgsCompositionConverter::importComposerTemplatePolygon() checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); qDeleteAll( items ); - } void TestQgsCompositionConverter::importComposerTemplatePolyline() @@ -306,9 +301,9 @@ void TestQgsCompositionConverter::importComposerTemplatePolyline() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -325,7 +320,6 @@ void TestQgsCompositionConverter::importComposerTemplatePolyline() checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); qDeleteAll( items ); - } void TestQgsCompositionConverter::importComposerTemplateArrow() @@ -334,9 +328,9 @@ void TestQgsCompositionConverter::importComposerTemplateArrow() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -353,7 +347,6 @@ void TestQgsCompositionConverter::importComposerTemplateArrow() checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); qDeleteAll( items ); - } @@ -363,9 +356,9 @@ void TestQgsCompositionConverter::importComposerTemplateMap() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -387,7 +380,7 @@ void TestQgsCompositionConverter::importComposerTemplateMap() QVERIFY( item1->isVisible() ); QCOMPARE( item1->opacity(), 0.78 ); item1->setLayers( project.mapLayers().values() ); - item1->setExtent( QgsRectangle( -126.5731570061082038, -4.69162199770811128, -88.56641716083402116, 69.08616711370645191 ) ); + item1->setExtent( QgsRectangle( -126.5731570061082038, -4.69162199770811128, -88.56641716083402116, 69.08616711370645191 ) ); // Check map ids QStringList mapUuids; @@ -408,10 +401,10 @@ void TestQgsCompositionConverter::importComposerTemplateMap() const auto overviewItems = mapItem->overviews()->asList(); for ( auto const &item : overviewItems ) { - if ( ! item->map( )->uuid().isEmpty( ) ) + if ( !item->map()->uuid().isEmpty() ) { QVERIFY( mapUuids.contains( item->map()->uuid() ) ); - count ++; + count++; } } } @@ -423,7 +416,6 @@ void TestQgsCompositionConverter::importComposerTemplateMap() checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); qDeleteAll( items ); - } void TestQgsCompositionConverter::importComposerTemplateLegend() @@ -432,9 +424,9 @@ void TestQgsCompositionConverter::importComposerTemplateLegend() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -444,12 +436,11 @@ void TestQgsCompositionConverter::importComposerTemplateLegend() QgsLayoutItemLegend *item = items.at( 0 ); QVERIFY( item->isVisible() ); - QVERIFY( ! item->autoUpdateModel() ); + QVERIFY( !item->autoUpdateModel() ); checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); qDeleteAll( items ); - } void TestQgsCompositionConverter::importComposerTemplateAttributeTable() @@ -457,8 +448,8 @@ void TestQgsCompositionConverter::importComposerTemplateAttributeTable() QDomElement composerElem( loadComposer( QStringLiteral( "2x_template_attributetable.qpt" ) ) ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -473,7 +464,6 @@ void TestQgsCompositionConverter::importComposerTemplateAttributeTable() QVERIFY( table->sourceLayer()->isValid() ); checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); - } void TestQgsCompositionConverter::importComposerTemplateHtml() @@ -481,8 +471,8 @@ void TestQgsCompositionConverter::importComposerTemplateHtml() QDomElement composerElem( loadComposer( QStringLiteral( "2x_template_html.qpt" ) ) ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 7 ); @@ -493,11 +483,10 @@ void TestQgsCompositionConverter::importComposerTemplateHtml() QVERIFY( items.size() > 0 ); const QgsLayoutItemHtml *html = items.at( 0 ); QVERIFY( html ); - QCOMPARE( html->contentMode(), QgsLayoutItemHtml::ContentMode::ManualHtml ); - QCOMPARE( html->html(), QStringLiteral( "
    aaaaA
    \t\n" ) ); + QCOMPARE( html->contentMode(), QgsLayoutItemHtml::ContentMode::ManualHtml ); + QCOMPARE( html->html(), QStringLiteral( "
    aaaaA
    \t\n" ) ); checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); - } void TestQgsCompositionConverter::importComposerTemplateScaleBar() @@ -506,9 +495,9 @@ void TestQgsCompositionConverter::importComposerTemplateScaleBar() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -519,12 +508,11 @@ void TestQgsCompositionConverter::importComposerTemplateScaleBar() QgsLayoutItemScaleBar *item = items.at( 0 ); QVERIFY( item->isVisible() ); - QVERIFY( ! item->linkedMap() ); + QVERIFY( !item->linkedMap() ); checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); qDeleteAll( items ); - } void TestQgsCompositionConverter::importComposerTemplateGroup() @@ -533,9 +521,9 @@ void TestQgsCompositionConverter::importComposerTemplateGroup() QVERIFY( !composerElem.isNull() ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); @@ -550,7 +538,6 @@ void TestQgsCompositionConverter::importComposerTemplateGroup() void TestQgsCompositionConverter::convertComposition() { - QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); @@ -568,7 +555,6 @@ void TestQgsCompositionConverter::convertComposition() // Check guides QCOMPARE( layout->guides().rowCount( QModelIndex() ), 8 ); - } void TestQgsCompositionConverter::isCompositionTemplate() @@ -581,7 +567,6 @@ void TestQgsCompositionConverter::isCompositionTemplate() file.close(); QVERIFY( QgsCompositionConverter::isCompositionTemplate( doc ) ); - } void TestQgsCompositionConverter::convertCompositionTemplate() @@ -612,9 +597,9 @@ void TestQgsCompositionConverter::importComposerTemplate() QDomElement composerElem( loadComposer( QStringLiteral( "2x_template.qpt" ) ) ); QgsProject project; project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); - QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); + QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 2 ); @@ -640,7 +625,7 @@ void TestQgsCompositionConverter::importComposerTemplate() if ( item->linkedMap() ) { QVERIFY( mapUuids.contains( item->linkedMap()->uuid() ) ); - count ++; + count++; } } // We have at least one item linked to a map for this test @@ -658,7 +643,7 @@ void TestQgsCompositionConverter::importComposerTemplate() if ( item->linkedMap() ) { QVERIFY( mapUuids.contains( item->linkedMap()->uuid() ) ); - count ++; + count++; } } // We have at least one item linked to a map for this test @@ -672,10 +657,10 @@ void TestQgsCompositionConverter::importComposerTemplate() layout->layoutItems( items ); for ( auto const &item : std::as_const( items ) ) { - if ( item->linkedMap( ) ) + if ( item->linkedMap() ) { QVERIFY( mapUuids.contains( item->linkedMap()->uuid() ) ); - count ++; + count++; } } // We have at least one item linked to a map for this test @@ -684,7 +669,6 @@ void TestQgsCompositionConverter::importComposerTemplate() checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); checkRenderedImage( layout.get(), QTest::currentTestFunction(), 1 ); - } void TestQgsCompositionConverter::importComposerAtlas() @@ -696,7 +680,7 @@ void TestQgsCompositionConverter::importComposerAtlas() project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/sample_project.qgs" ); QDomElement docElem = composerElem.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement(); - std::unique_ptr< QgsPrintLayout > layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); + std::unique_ptr layout( QgsCompositionConverter::createLayoutFromCompositionXml( docElem, &project ) ); QVERIFY( layout.get() ); QCOMPARE( layout->pageCollection()->pageCount(), 1 ); QCOMPARE( layout->name(), QStringLiteral( "composer atlas" ) ); @@ -705,7 +689,6 @@ void TestQgsCompositionConverter::importComposerAtlas() QVERIFY( layout->atlas()->updateFeatures() > 0 ); checkRenderedImage( layout.get(), QTest::currentTestFunction(), 0 ); - } void TestQgsCompositionConverter::checkRenderedImage( QgsLayout *layout, const QString &testName, const int pageNumber ) @@ -716,7 +699,8 @@ void TestQgsCompositionConverter::checkRenderedImage( QgsLayout *layout, const Q QGSLAYOUTCHECK( testName + '_' + QString::number( pageNumber ), layout, - pageNumber, 0, size, 0 ) + pageNumber, 0, size, 0 + ) ); } @@ -727,7 +711,7 @@ QDomElement TestQgsCompositionConverter::loadComposer( const QString &name ) QFile file( templatePath ); bool res = file.open( QIODevice::ReadOnly ); Q_ASSERT( res ); - res = static_cast< bool >( doc.setContent( &file ) ); + res = static_cast( doc.setContent( &file ) ); Q_ASSERT( res ); file.close(); QDomNodeList nodes( doc.elementsByTagName( QStringLiteral( "Composer" ) ) ); diff --git a/tests/src/core/testqgsconnectionpool.cpp b/tests/src/core/testqgsconnectionpool.cpp index 6d27e13b3671..7fb4fba73072 100644 --- a/tests/src/core/testqgsconnectionpool.cpp +++ b/tests/src/core/testqgsconnectionpool.cpp @@ -28,7 +28,7 @@ #include #include "qgstest.h" -class TestQgsConnectionPool: public QObject +class TestQgsConnectionPool : public QObject { Q_OBJECT @@ -40,9 +40,10 @@ class TestQgsConnectionPool: public QObject private: struct ReadJob { - explicit ReadJob( QgsVectorLayer *_layer ) : source( std::make_shared< QgsVectorLayerFeatureSource >( _layer ) ) {} - std::shared_ptr< QgsVectorLayerFeatureSource> source; - QList features; + explicit ReadJob( QgsVectorLayer *_layer ) + : source( std::make_shared( _layer ) ) {} + std::shared_ptr source; + QList features; }; static void processJob( ReadJob &job ) @@ -54,14 +55,12 @@ class TestQgsConnectionPool: public QObject job.features.append( f ); } } - }; void TestQgsConnectionPool::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsConnectionPool::cleanupTestCase() diff --git a/tests/src/core/testqgscoordinatereferencesystem.cpp b/tests/src/core/testqgscoordinatereferencesystem.cpp index ecdd1313a655..912577d5eeb5 100644 --- a/tests/src/core/testqgscoordinatereferencesystem.cpp +++ b/tests/src/core/testqgscoordinatereferencesystem.cpp @@ -33,7 +33,7 @@ Email : sherman at mrcc dot com #include #include -class TestQgsCoordinateReferenceSystem: public QObject +class TestQgsCoordinateReferenceSystem : public QObject { Q_OBJECT private slots: @@ -184,7 +184,6 @@ void TestQgsCoordinateReferenceSystem::initTestCase() qDebug() << "Warning! GDAL_FIX_ESRI_WKT =" << CPLGetConfigOption( "GDAL_FIX_ESRI_WKT", "" ) << "this might generate errors!"; } - } void TestQgsCoordinateReferenceSystem::cleanupTestCase() @@ -206,8 +205,7 @@ void TestQgsCoordinateReferenceSystem::wktCtor() void TestQgsCoordinateReferenceSystem::idCtor() { Q_NOWARN_DEPRECATED_PUSH - const QgsCoordinateReferenceSystem myCrs( GEOSRID, - QgsCoordinateReferenceSystem::EpsgCrsId ); + const QgsCoordinateReferenceSystem myCrs( GEOSRID, QgsCoordinateReferenceSystem::EpsgCrsId ); Q_NOWARN_DEPRECATED_POP QVERIFY( myCrs.isValid() ); @@ -290,11 +288,7 @@ void TestQgsCoordinateReferenceSystem::compoundCrs() QVERIFY( !crs.isGeographic() ); QCOMPARE( crs.mapUnits(), Qgis::DistanceUnit::Meters ); QVERIFY( !crs.hasAxisInverted() ); - QCOMPARE( crs.axisOrdering(), - QList() - << Qgis::CrsAxisDirection::East - << Qgis::CrsAxisDirection::North - << Qgis::CrsAxisDirection::Up ); + QCOMPARE( crs.axisOrdering(), QList() << Qgis::CrsAxisDirection::East << Qgis::CrsAxisDirection::North << Qgis::CrsAxisDirection::Up ); crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3903" ) ); QVERIFY( crs.isValid() ); @@ -302,11 +296,7 @@ void TestQgsCoordinateReferenceSystem::compoundCrs() QVERIFY( !crs.isGeographic() ); QCOMPARE( crs.mapUnits(), Qgis::DistanceUnit::Meters ); QVERIFY( crs.hasAxisInverted() ); - QCOMPARE( crs.axisOrdering(), - QList() - << Qgis::CrsAxisDirection::North - << Qgis::CrsAxisDirection::East - << Qgis::CrsAxisDirection::Up ); + QCOMPARE( crs.axisOrdering(), QList() << Qgis::CrsAxisDirection::North << Qgis::CrsAxisDirection::East << Qgis::CrsAxisDirection::Up ); } void TestQgsCoordinateReferenceSystem::verticalCrs() @@ -396,44 +386,44 @@ void TestQgsCoordinateReferenceSystem::hasVerticalAxis() QVERIFY( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4979" ) ).hasVerticalAxis() ); // projected 3d const QString projected3DWkt = QStringLiteral( "PROJCRS[\"NAD83(HARN) / Oregon GIC Lambert (ft)\",\n" - " BASEGEOGCRS[\"NAD83(HARN)\",\n" - " DATUM[\"NAD83 (High Accuracy Reference Network)\",\n" - " ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n" - " LENGTHUNIT[\"metre\",1]]],\n" - " PRIMEM[\"Greenwich\",0,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" - " ID[\"EPSG\",4957]],\n" - " CONVERSION[\"unnamed\",\n" - " METHOD[\"Lambert Conic Conformal (2SP)\",\n" - " ID[\"EPSG\",9802]],\n" - " PARAMETER[\"Latitude of false origin\",41.75,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8821]],\n" - " PARAMETER[\"Longitude of false origin\",-120.5,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8822]],\n" - " PARAMETER[\"Latitude of 1st standard parallel\",43,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8823]],\n" - " PARAMETER[\"Latitude of 2nd standard parallel\",45.5,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8824]],\n" - " PARAMETER[\"Easting at false origin\",1312335.958,\n" - " LENGTHUNIT[\"foot\",0.3048],\n" - " ID[\"EPSG\",8826]],\n" - " PARAMETER[\"Northing at false origin\",0,\n" - " LENGTHUNIT[\"foot\",0.3048],\n" - " ID[\"EPSG\",8827]]],\n" - " CS[Cartesian,3],\n" - " AXIS[\"easting\",east,\n" - " ORDER[1],\n" - " LENGTHUNIT[\"foot\",0.3048]],\n" - " AXIS[\"northing\",north,\n" - " ORDER[2],\n" - " LENGTHUNIT[\"foot\",0.3048]],\n" - " AXIS[\"ellipsoidal height (h)\",up,\n" - " ORDER[3],\n" - " LENGTHUNIT[\"foot\",0.3048]]]" ); + " BASEGEOGCRS[\"NAD83(HARN)\",\n" + " DATUM[\"NAD83 (High Accuracy Reference Network)\",\n" + " ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " ID[\"EPSG\",4957]],\n" + " CONVERSION[\"unnamed\",\n" + " METHOD[\"Lambert Conic Conformal (2SP)\",\n" + " ID[\"EPSG\",9802]],\n" + " PARAMETER[\"Latitude of false origin\",41.75,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8821]],\n" + " PARAMETER[\"Longitude of false origin\",-120.5,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8822]],\n" + " PARAMETER[\"Latitude of 1st standard parallel\",43,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8823]],\n" + " PARAMETER[\"Latitude of 2nd standard parallel\",45.5,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8824]],\n" + " PARAMETER[\"Easting at false origin\",1312335.958,\n" + " LENGTHUNIT[\"foot\",0.3048],\n" + " ID[\"EPSG\",8826]],\n" + " PARAMETER[\"Northing at false origin\",0,\n" + " LENGTHUNIT[\"foot\",0.3048],\n" + " ID[\"EPSG\",8827]]],\n" + " CS[Cartesian,3],\n" + " AXIS[\"easting\",east,\n" + " ORDER[1],\n" + " LENGTHUNIT[\"foot\",0.3048]],\n" + " AXIS[\"northing\",north,\n" + " ORDER[2],\n" + " LENGTHUNIT[\"foot\",0.3048]],\n" + " AXIS[\"ellipsoidal height (h)\",up,\n" + " ORDER[3],\n" + " LENGTHUNIT[\"foot\",0.3048]]]" ); const QgsCoordinateReferenceSystem projected3D = QgsCoordinateReferenceSystem::fromWkt( projected3DWkt ); QVERIFY( projected3D.isValid() ); QVERIFY( projected3D.hasVerticalAxis() ); @@ -488,8 +478,7 @@ void TestQgsCoordinateReferenceSystem::createFromId() { QgsCoordinateReferenceSystem myCrs; Q_NOWARN_DEPRECATED_PUSH - myCrs.createFromId( GEO_EPSG_CRS_ID, - QgsCoordinateReferenceSystem::EpsgCrsId ); + myCrs.createFromId( GEO_EPSG_CRS_ID, QgsCoordinateReferenceSystem::EpsgCrsId ); Q_NOWARN_DEPRECATED_POP debugPrint( myCrs ); QVERIFY( myCrs.isValid() ); @@ -705,7 +694,7 @@ void TestQgsCoordinateReferenceSystem::createFromWktUnknown() crs.saveAsUserCrs( QStringLiteral( "Test CRS" ) ); QgsDebugMsgLevel( crs.toWkt( Qgis::CrsWktVariant::Preferred ), 1 ); QCOMPARE( crs.toWkt( Qgis::CrsWktVariant::Preferred ), expectedWkt ); - QCOMPARE( crs.srsid(), static_cast< long >( USER_CRS_START_ID + 1 ) ); + QCOMPARE( crs.srsid(), static_cast( USER_CRS_START_ID + 1 ) ); QCOMPARE( crs.authid(), QStringLiteral( "USER:100001" ) ); QCOMPARE( crs.mapUnits(), Qgis::DistanceUnit::Meters ); QCOMPARE( crs.ellipsoidAcronym().left( 30 ), QStringLiteral( "PARAMETER:6378388:6356911.9461" ) ); @@ -796,7 +785,7 @@ QString TestQgsCoordinateReferenceSystem::testESRIWkt( int i, QgsCoordinateRefer { debugPrint( myCrs ); - if ( ! myCrs.isValid() ) + if ( !myCrs.isValid() ) return QStringLiteral( "test %1 crs is invalid" ); #if 0 if ( myCrs.toProj() != myProj4Strings[i] ) @@ -805,10 +794,14 @@ QString TestQgsCoordinateReferenceSystem::testESRIWkt( int i, QgsCoordinateRefer #endif if ( myCrs.toProj().indexOf( myTOWGS84Strings[i] ) == -1 ) return QStringLiteral( "test %1 [%2] not found, PROJ = [%3] expecting [%4]" - ).arg( i ).arg( myTOWGS84Strings[i], myCrs.toProj(), myProj4Strings[i] ); + ) + .arg( i ) + .arg( myTOWGS84Strings[i], myCrs.toProj(), myProj4Strings[i] ); if ( myCrs.authid() != myAuthIdStrings[i] ) return QStringLiteral( "test %1 AUTHID = [%2] expecting [%3]" - ).arg( i ).arg( myCrs.authid(), myAuthIdStrings[i] ); + ) + .arg( i ) + .arg( myCrs.authid(), myAuthIdStrings[i] ); return QString(); } @@ -1191,8 +1184,8 @@ void TestQgsCoordinateReferenceSystem::equality() QVERIFY( !( myCrs == myCrs2 ) ); myCrs2.setCoordinateEpoch( 2021.3 ); QVERIFY( myCrs == myCrs2 ); - myCrs.setCoordinateEpoch( std::numeric_limits< double >::quiet_NaN() ); - myCrs2.setCoordinateEpoch( std::numeric_limits< double >::quiet_NaN() ); + myCrs.setCoordinateEpoch( std::numeric_limits::quiet_NaN() ); + myCrs2.setCoordinateEpoch( std::numeric_limits::quiet_NaN() ); // custom crs, no authid myCrs.createFromWkt( QStringLiteral( "PROJCS[\"unnamed\",GEOGCS[\"unnamed\",DATUM[\"Geocentric_Datum_of_Australia_2020\",SPHEROID[\"GRS 80\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",147],PARAMETER[\"scale_factor\",0.1996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",10000000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]" ) ); @@ -1214,8 +1207,8 @@ void TestQgsCoordinateReferenceSystem::noEquality() QVERIFY( myCrs != myCrs3 ); myCrs3.setCoordinateEpoch( 2021.3 ); QVERIFY( !( myCrs != myCrs3 ) ); - myCrs.setCoordinateEpoch( std::numeric_limits< double >::quiet_NaN() ); - myCrs3.setCoordinateEpoch( std::numeric_limits< double >::quiet_NaN() ); + myCrs.setCoordinateEpoch( std::numeric_limits::quiet_NaN() ); + myCrs3.setCoordinateEpoch( std::numeric_limits::quiet_NaN() ); // custom crs, no authid myCrs.createFromWkt( QStringLiteral( "PROJCS[\"unnamed\",GEOGCS[\"unnamed\",DATUM[\"Geocentric_Datum_of_Australia_2020\",SPHEROID[\"GRS 80\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",147],PARAMETER[\"scale_factor\",0.1996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",10000000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]" ) ); @@ -1250,7 +1243,7 @@ void TestQgsCoordinateReferenceSystem::readWriteXml() QgsCoordinateReferenceSystem badCrs; QVERIFY( !badCrs.readXml( node ) ); QVERIFY( !badCrs.isValid() ); - const QDomElement badSrsElement = document.createElement( QStringLiteral( "spatialrefsys" ) ); + const QDomElement badSrsElement = document.createElement( QStringLiteral( "spatialrefsys" ) ); QDomElement badNode = document.createElement( QStringLiteral( "crs" ) ); document.appendChild( badNode ); badNode.appendChild( badSrsElement ); @@ -1278,11 +1271,11 @@ void TestQgsCoordinateReferenceSystem::readWriteXml() QDomDocument document2( QStringLiteral( "test" ) ); QDomElement node2 = document2.createElement( QStringLiteral( "crs" ) ); document2.appendChild( node2 ); - QVERIFY( ! myCrs3.isValid() ); + QVERIFY( !myCrs3.isValid() ); QVERIFY( myCrs3.writeXml( node2, document2 ) ); QgsCoordinateReferenceSystem myCrs4; QVERIFY( myCrs4.readXml( node2 ) ); - QVERIFY( ! myCrs4.isValid() ); + QVERIFY( !myCrs4.isValid() ); QVERIFY( myCrs3 == myCrs4 ); // Empty XML node @@ -1290,7 +1283,7 @@ void TestQgsCoordinateReferenceSystem::readWriteXml() const QDomElement node3 = document3.createElement( QStringLiteral( "crs" ) ); document3.appendChild( node3 ); QgsCoordinateReferenceSystem myCrs5; - QVERIFY( ! myCrs5.readXml( node3 ) ); + QVERIFY( !myCrs5.readXml( node3 ) ); QVERIFY( myCrs5 == QgsCoordinateReferenceSystem() ); // valid CRS using auth/code @@ -1559,7 +1552,6 @@ void TestQgsCoordinateReferenceSystem::setCustomSrsValidation() void TestQgsCoordinateReferenceSystem::customSrsValidation() { - /** * \todo implement this test * "QgsCoordinateReferenceSystem myCrs; @@ -1583,7 +1575,6 @@ void TestQgsCoordinateReferenceSystem::ellipsoidAcronym() myCrs.createFromString( QStringLiteral( "EPSG:2951" ) ); QCOMPARE( myCrs.ellipsoidAcronym(), QStringLiteral( "EPSG:7019" ) ); - } void TestQgsCoordinateReferenceSystem::toWkt() { @@ -1681,7 +1672,7 @@ void TestQgsCoordinateReferenceSystem::isDynamic() void TestQgsCoordinateReferenceSystem::celestialBody() { -#if (PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR >= 1 ) ) +#if ( PROJ_VERSION_MAJOR > 8 || ( PROJ_VERSION_MAJOR == 8 && PROJ_VERSION_MINOR >= 1 ) ) QgsCoordinateReferenceSystem crs; QCOMPARE( crs.celestialBodyName(), QString() ); @@ -1701,12 +1692,12 @@ void TestQgsCoordinateReferenceSystem::operation() crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ); QVERIFY( crs.operation().isValid() ); QCOMPARE( crs.operation().id(), QStringLiteral( "longlat" ) ); - QCOMPARE( crs.operation().description(), QStringLiteral( "Lat/long (Geodetic alias)" ) ); + QCOMPARE( crs.operation().description(), QStringLiteral( "Lat/long (Geodetic alias)" ) ); crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ); QVERIFY( crs.operation().isValid() ); QCOMPARE( crs.operation().id(), QStringLiteral( "utm" ) ); - QCOMPARE( crs.operation().description(), QStringLiteral( "Universal Transverse Mercator (UTM)" ) ); + QCOMPARE( crs.operation().description(), QStringLiteral( "Universal Transverse Mercator (UTM)" ) ); QVERIFY( crs.operation().details().contains( QStringLiteral( "south approx" ) ) ); } @@ -1740,16 +1731,16 @@ void TestQgsCoordinateReferenceSystem::hasAxisInverted() void TestQgsCoordinateReferenceSystem::debugPrint( - QgsCoordinateReferenceSystem &crs ) + QgsCoordinateReferenceSystem &crs +) { QgsDebugMsgLevel( QStringLiteral( "***SpatialRefSystem***" ), 1 ); - QgsDebugMsgLevel( "* Valid : " + ( crs.isValid() ? QStringLiteral( "true" ) : - QStringLiteral( "false" ) ), 1 ); + QgsDebugMsgLevel( "* Valid : " + ( crs.isValid() ? QStringLiteral( "true" ) : QStringLiteral( "false" ) ), 1 ); QgsDebugMsgLevel( "* SrsId : " + QString::number( crs.srsid() ), 1 ); QgsDebugMsgLevel( "* EPSG ID : " + crs.authid(), 1 ); QgsDebugMsgLevel( "* PGIS ID : " + QString::number( crs.postgisSrid() ), 1 ); QgsDebugMsgLevel( "* Proj4 : " + crs.toProj(), 1 ); - QgsDebugMsgLevel( "* WKT : " + crs.toWkt(), 1 ); + QgsDebugMsgLevel( "* WKT : " + crs.toWkt(), 1 ); QgsDebugMsgLevel( "* Desc. : " + crs.description(), 1 ); if ( crs.mapUnits() == Qgis::DistanceUnit::Meters ) { @@ -1773,7 +1764,7 @@ void TestQgsCoordinateReferenceSystem::createFromProjInvalid() void TestQgsCoordinateReferenceSystem::validSrsIds() { - const QList< long > ids = QgsCoordinateReferenceSystem::validSrsIds(); + const QList ids = QgsCoordinateReferenceSystem::validSrsIds(); QVERIFY( ids.contains( 3857 ) ); QVERIFY( ids.contains( 28356 ) ); @@ -1871,7 +1862,7 @@ void TestQgsCoordinateReferenceSystem::saveAsUserCrs() QCOMPARE( userCrs.srsid(), 0L ); // not saved to database yet const long newId = userCrs.saveAsUserCrs( QStringLiteral( "babies first projection" ) ); - QCOMPARE( newId, static_cast< long >( USER_CRS_START_ID ) ); + QCOMPARE( newId, static_cast( USER_CRS_START_ID ) ); QCOMPARE( userCrs.srsid(), newId ); QCOMPARE( userCrs.authid(), QStringLiteral( "USER:100000" ) ); QCOMPARE( userCrs.description(), QStringLiteral( "babies first projection" ) ); @@ -1947,8 +1938,7 @@ void TestQgsCoordinateReferenceSystem::geographicCrsAuthId() crs.createFromString( QStringLiteral( "EPSG:3825" ) ); QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3825" ) ); QCOMPARE( crs.geographicCrsAuthId(), QStringLiteral( "EPSG:3824" ) ); - QCOMPARE( crs.toGeographicCrs().toProj().replace( QLatin1String( "+towgs84=0,0,0,0,0,0,0 " ), QString() ).replace( QLatin1String( " +type=crs" ), QString() ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3824" ) ).toProj().replace( QLatin1String( "+towgs84=0,0,0,0,0,0,0 " ), QString() ).replace( QLatin1String( " +type=crs" ), QString() ) ); + QCOMPARE( crs.toGeographicCrs().toProj().replace( QLatin1String( "+towgs84=0,0,0,0,0,0,0 " ), QString() ).replace( QLatin1String( " +type=crs" ), QString() ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3824" ) ).toProj().replace( QLatin1String( "+towgs84=0,0,0,0,0,0,0 " ), QString() ).replace( QLatin1String( " +type=crs" ), QString() ) ); QVERIFY( crs.toGeographicCrs().isGeographic() ); } @@ -1968,7 +1958,7 @@ void TestQgsCoordinateReferenceSystem::noProj() QVERIFY( crs.isValid() ); QgsDebugMsgLevel( crs.toWkt(), 1 ); QVERIFY( crs.toWkt().startsWith( QLatin1String( "PROJCS[\"Carthage (Paris) / Tunisia Mining Grid\"," ) ) ); -#if (PROJ_VERSION_MAJOR>9 || (PROJ_VERSION_MAJOR==9 && PROJ_VERSION_MINOR >= 2 ) ) +#if ( PROJ_VERSION_MAJOR > 9 || ( PROJ_VERSION_MAJOR == 9 && PROJ_VERSION_MINOR >= 2 ) ) QVERIFY( crs.toWkt().contains( QLatin1String( "PROJECTION[\"Tunisia_Mining_Grid\"]" ) ) ); #else QVERIFY( crs.toWkt().contains( QLatin1String( "PROJECTION[\"Tunisia_Mapping_Grid\"]" ) ) ); @@ -2041,7 +2031,7 @@ void TestQgsCoordinateReferenceSystem::displayIdentifier() QgsDebugMsgLevel( crs.userFriendlyIdentifier(), 1 ); QVERIFY( crs.userFriendlyIdentifier().startsWith( QLatin1String( "Custom CRS: BOUNDCRS[" ) ) ); QVERIFY( !crs.userFriendlyIdentifier().contains( QLatin1String( "PARAMETER[\"Scale difference\",0.9999973271,ID[\"EPSG\",8611]]" ) ) ); - QVERIFY( crs.userFriendlyIdentifier().endsWith( QChar( 0x2026 ) ) ); //#spellok + QVERIFY( crs.userFriendlyIdentifier().endsWith( QChar( 0x2026 ) ) ); //#spellok QgsDebugMsgLevel( crs.userFriendlyIdentifier( Qgis::CrsIdentifierType::FullString ), 1 ); QVERIFY( crs.userFriendlyIdentifier( Qgis::CrsIdentifierType::FullString ).startsWith( QLatin1String( "Custom CRS: BOUNDCRS[" ) ) ); diff --git a/tests/src/core/testqgscoordinatereferencesystemregistry.cpp b/tests/src/core/testqgscoordinatereferencesystemregistry.cpp index 566302221321..bcfe82c2e016 100644 --- a/tests/src/core/testqgscoordinatereferencesystemregistry.cpp +++ b/tests/src/core/testqgscoordinatereferencesystemregistry.cpp @@ -25,7 +25,7 @@ #include "qgsapplication.h" #include "qgsprojoperation.h" -class TestQgsCoordinateReferenceSystemRegistry: public QObject +class TestQgsCoordinateReferenceSystemRegistry : public QObject { Q_OBJECT private slots: @@ -40,9 +40,7 @@ class TestQgsCoordinateReferenceSystemRegistry: public QObject void testRecent(); private: - QString mTempFolder; - }; void TestQgsCoordinateReferenceSystemRegistry::initTestCase() @@ -186,8 +184,7 @@ void TestQgsCoordinateReferenceSystemRegistry::changeUserCrs() const QString madeUpProjection2 = QStringLiteral( "+proj=aea +lat_1=22.5 +lat_2=-24.5 +lat_0=4 +lon_0=29 +x_0=10 +y_0=3 +datum=WGS84 +units=m +no_defs" ); crs2.createFromProj( madeUpProjection2 ); - const QMetaObject::Connection conn1 = connect( registry, &QgsCoordinateReferenceSystemRegistry::userCrsChanged, this, [&] - { + const QMetaObject::Connection conn1 = connect( registry, &QgsCoordinateReferenceSystemRegistry::userCrsChanged, this, [&] { // make sure that caches are invalidated before the signals are emitted, so that slots will // get the new definition! const QgsCoordinateReferenceSystem crs4( authid ); @@ -273,8 +270,7 @@ void TestQgsCoordinateReferenceSystemRegistry::removeUserCrs() QVERIFY( crs2.isValid() ); // now try removing it - connect( registry, &QgsCoordinateReferenceSystemRegistry::userCrsRemoved, this, [&] - { + connect( registry, &QgsCoordinateReferenceSystemRegistry::userCrsRemoved, this, [&] { // make sure that caches are invalidated before the signals are emitted const QgsCoordinateReferenceSystem crs4( authid ); QVERIFY( !crs4.isValid() ); @@ -284,7 +280,7 @@ void TestQgsCoordinateReferenceSystemRegistry::removeUserCrs() QCOMPARE( spyAdded.length(), 1 ); QCOMPARE( spyChanged.length(), 0 ); QCOMPARE( spyRemoved.length(), 1 ); - QCOMPARE( spyRemoved.at( 0 ).at( 0 ).toLongLong(), static_cast< long long >( id ) ); + QCOMPARE( spyRemoved.at( 0 ).at( 0 ).toLongLong(), static_cast( id ) ); QCOMPARE( spyCrsDefsChanged.length(), 2 ); QCOMPARE( registry->userCrsList().count(), 3 ); @@ -310,7 +306,7 @@ void TestQgsCoordinateReferenceSystemRegistry::removeUserCrs() void TestQgsCoordinateReferenceSystemRegistry::projOperations() { - const QMap< QString, QgsProjOperation > operations = QgsApplication::coordinateReferenceSystemRegistry()->projOperations(); + const QMap operations = QgsApplication::coordinateReferenceSystemRegistry()->projOperations(); QVERIFY( operations.contains( QStringLiteral( "lcc" ) ) ); QVERIFY( operations.value( QStringLiteral( "lcc" ) ).isValid() ); @@ -321,7 +317,7 @@ void TestQgsCoordinateReferenceSystemRegistry::projOperations() void TestQgsCoordinateReferenceSystemRegistry::authorities() { - const QSet< QString > authorities = QgsApplication::coordinateReferenceSystemRegistry()->authorities(); + const QSet authorities = QgsApplication::coordinateReferenceSystemRegistry()->authorities(); QVERIFY( authorities.contains( QStringLiteral( "epsg" ) ) ); QVERIFY( authorities.contains( QStringLiteral( "proj" ) ) ); @@ -330,30 +326,26 @@ void TestQgsCoordinateReferenceSystemRegistry::authorities() void TestQgsCoordinateReferenceSystemRegistry::crsDbRecords() { - const QList< QgsCrsDbRecord > records = QgsApplication::coordinateReferenceSystemRegistry()->crsDbRecords(); + const QList records = QgsApplication::coordinateReferenceSystemRegistry()->crsDbRecords(); QVERIFY( !records.isEmpty() ); - auto it = std::find_if( records.begin(), records.end(), - []( const QgsCrsDbRecord & record ) { return record.authName == QLatin1String( "EPSG" ) && record.authId == QLatin1String( "3111" );} ); + auto it = std::find_if( records.begin(), records.end(), []( const QgsCrsDbRecord &record ) { return record.authName == QLatin1String( "EPSG" ) && record.authId == QLatin1String( "3111" ); } ); QVERIFY( it != records.end() ); QCOMPARE( it->description, QStringLiteral( "GDA94 / Vicgrid" ) ); QCOMPARE( it->type, Qgis::CrsType::Projected ); // check that database includes vertical CRS - it = std::find_if( records.begin(), records.end(), - []( const QgsCrsDbRecord & record ) { return record.type == Qgis::CrsType::Vertical;} ); + it = std::find_if( records.begin(), records.end(), []( const QgsCrsDbRecord &record ) { return record.type == Qgis::CrsType::Vertical; } ); QVERIFY( it != records.end() ); // check that database includes compound CRS - it = std::find_if( records.begin(), records.end(), - []( const QgsCrsDbRecord & record ) { return record.type == Qgis::CrsType::Compound;} ); + it = std::find_if( records.begin(), records.end(), []( const QgsCrsDbRecord &record ) { return record.type == Qgis::CrsType::Compound; } ); QVERIFY( it != records.end() ); - } void TestQgsCoordinateReferenceSystemRegistry::testRecent() { - QList< QgsCoordinateReferenceSystem > recent = QgsApplication::coordinateReferenceSystemRegistry()->recentCrs(); + QList recent = QgsApplication::coordinateReferenceSystemRegistry()->recentCrs(); QVERIFY( recent.isEmpty() ); QSignalSpy pushSpy( QgsApplication::coordinateReferenceSystemRegistry(), &QgsCoordinateReferenceSystemRegistry::recentCrsPushed ); diff --git a/tests/src/core/testqgscoordinatetransform.cpp b/tests/src/core/testqgscoordinatetransform.cpp index 9b7ba58fb9f0..d73357d96fce 100644 --- a/tests/src/core/testqgscoordinatetransform.cpp +++ b/tests/src/core/testqgscoordinatetransform.cpp @@ -24,7 +24,7 @@ #include "qgsexception.h" #include "qgslogger.h" -class TestQgsCoordinateTransform: public QObject +class TestQgsCoordinateTransform : public QObject { Q_OBJECT @@ -61,7 +61,6 @@ void TestQgsCoordinateTransform::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsCoordinateTransform::cleanupTestCase() @@ -132,39 +131,32 @@ void TestQgsCoordinateTransform::equality() QgsCoordinateTransform t2; QVERIFY( t1 == t2 ); - t1 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); + t1 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); QVERIFY( t1 != t2 ); QVERIFY( t2 != t1 ); // same source and destination - t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); + t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); QVERIFY( t1 == t2 ); QVERIFY( t2 == t1 ); // different source - t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3113" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); + t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3113" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); QVERIFY( t1 != t2 ); QVERIFY( t2 != t1 ); // different destination - t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateTransformContext() ); + t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateTransformContext() ); QVERIFY( t1 != t2 ); QVERIFY( t2 != t1 ); // different source and destination - t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3113" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateTransformContext() ); + t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3113" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateTransformContext() ); QVERIFY( t1 != t2 ); QVERIFY( t2 != t1 ); // source/destination swapped - t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateTransformContext() ); + t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateTransformContext() ); QVERIFY( t1 != t2 ); QVERIFY( t2 != t1 ); // same source and dest, different settings - t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); + t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); t1.setBallparkTransformsAreAppropriate( true ); QVERIFY( t1 != t2 ); QVERIFY( t2 != t1 ); @@ -172,11 +164,9 @@ void TestQgsCoordinateTransform::equality() QVERIFY( t1 == t2 ); // explicit coordinate operation - t1 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); + t1 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); t1.setCoordinateOperation( QStringLiteral( "+proj=pipeline +step +inv +proj=lcc +lat_0=-37 +lon_0=145 +lat_1=-36 +lat_2=-38 +x_0=2500000 +y_0=2500000 +ellps=GRS80 +step +proj=hgridshift +grids=au_icsm_GDA94_GDA2020_conformal_and_distortion.tif +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ) ); - t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); + t2 = QgsCoordinateTransform( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateTransformContext() ); QVERIFY( t1 != t2 ); QVERIFY( t2 != t1 ); t2.setCoordinateOperation( QStringLiteral( "+proj=pipeline +step +inv +proj=lcc +lat_0=-37 +lon_0=145 +lat_1=-36 +lat_2=-38 +x_0=2500000 +y_0=2500000 +ellps=GRS80 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ) ); @@ -253,7 +243,7 @@ void TestQgsCoordinateTransform::contextShared() original.addCoordinateOperation( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3113" ) ), QStringLiteral( "proj" ) ); QgsCoordinateTransformContext copy( original ); - QMap< QPair< QString, QString >, QString > expected; + QMap, QString> expected; expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QStringLiteral( "proj" ) ); QCOMPARE( original.coordinateOperations(), expected ); QCOMPARE( copy.coordinateOperations(), expected ); @@ -294,7 +284,6 @@ void TestQgsCoordinateTransform::scaleFactor() { QVERIFY( false ); } - } void TestQgsCoordinateTransform::constructorFlags() @@ -323,11 +312,8 @@ void TestQgsCoordinateTransform::constructorFlags() QVERIFY( !tr4.isShortCircuited() ); QVERIFY( tr4.mIgnoreImpossible ); -#if (PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR >= 1 ) ) - QgsCoordinateTransform tr5( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "ESRI:104903" ) ), - QgsProject::instance(), - Qgis::CoordinateTransformationFlag::IgnoreImpossibleTransformations ); +#if ( PROJ_VERSION_MAJOR > 8 || ( PROJ_VERSION_MAJOR == 8 && PROJ_VERSION_MINOR >= 1 ) ) + QgsCoordinateTransform tr5( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "ESRI:104903" ) ), QgsProject::instance(), Qgis::CoordinateTransformationFlag::IgnoreImpossibleTransformations ); QVERIFY( !tr5.mBallparkTransformsAreAppropriate ); // crses are from two different celestial bodies, the transform is impossible and should be short-circuited QVERIFY( tr5.isShortCircuited() ); @@ -343,20 +329,20 @@ void TestQgsCoordinateTransform::scaleFactor_data() QTest::addColumn( "factor" ); QTest::newRow( "Different map units" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 2056 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << QgsRectangle( 2550000, 1200000, 2550100, 1200100 ) - << 1.1223316038381985e-5; + << QgsCoordinateReferenceSystem::fromEpsgId( 2056 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << QgsRectangle( 2550000, 1200000, 2550100, 1200100 ) + << 1.1223316038381985e-5; QTest::newRow( "Same map units" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 28355 ) - << QgsRectangle( 2560536.7, 2331787.5, 2653161.1, 2427370.4 ) - << 0.999632; + << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 28355 ) + << QgsRectangle( 2560536.7, 2331787.5, 2653161.1, 2427370.4 ) + << 0.999632; QTest::newRow( "Same CRS" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 2056 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 2056 ) - << QgsRectangle( 2550000, 1200000, 2550100, 1200100 ) - << 1.0; + << QgsCoordinateReferenceSystem::fromEpsgId( 2056 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 2056 ) + << QgsRectangle( 2550000, 1200000, 2550100, 1200100 ) + << 1.0; } void TestQgsCoordinateTransform::transform_data() @@ -371,73 +357,73 @@ void TestQgsCoordinateTransform::transform_data() QTest::addColumn( "precision" ); QTest::newRow( "To geographic" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << 2545059.0 << 2393190.0 << static_cast< int >( Qgis::TransformDirection::Forward ) << 145.512750 << -37.961375 << 0.000015; + << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << 2545059.0 << 2393190.0 << static_cast( Qgis::TransformDirection::Forward ) << 145.512750 << -37.961375 << 0.000015; QTest::newRow( "From geographic" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) - << 145.512750 << -37.961375 << static_cast< int >( Qgis::TransformDirection::Forward ) << 2545059.0 << 2393190.0 << 1.5; + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) + << 145.512750 << -37.961375 << static_cast( Qgis::TransformDirection::Forward ) << 2545059.0 << 2393190.0 << 1.5; QTest::newRow( "From geographic to geographic" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4164 ) - << 145.512750 << -37.961375 << static_cast< int >( Qgis::TransformDirection::Forward ) << 145.510966 << -37.961741 << 0.0001; + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4164 ) + << 145.512750 << -37.961375 << static_cast( Qgis::TransformDirection::Forward ) << 145.510966 << -37.961741 << 0.0001; QTest::newRow( "To geographic (reverse)" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << 145.512750 << -37.961375 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 2545059.0 << 2393190.0 << 1.5; + << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << 145.512750 << -37.961375 << static_cast( Qgis::TransformDirection::Reverse ) << 2545059.0 << 2393190.0 << 1.5; QTest::newRow( "From geographic (reverse)" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) - << 2545058.9675128171 << 2393190.0509782173 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 145.512750 << -37.961375 << 0.000015; + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) + << 2545058.9675128171 << 2393190.0509782173 << static_cast( Qgis::TransformDirection::Reverse ) << 145.512750 << -37.961375 << 0.000015; QTest::newRow( "From geographic to geographic reverse" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4164 ) - << 145.510966 << -37.961741 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 145.512750 << -37.961375 << 0.0001; + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4164 ) + << 145.510966 << -37.961741 << static_cast( Qgis::TransformDirection::Reverse ) << 145.512750 << -37.961375 << 0.0001; QTest::newRow( "From LKS92/TM to Baltic93/TM" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 25884 ) - << 725865.850 << 198519.947 << static_cast< int >( Qgis::TransformDirection::Forward ) << 725865.850 << 6198519.947 << 0.001; + << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 25884 ) + << 725865.850 << 198519.947 << static_cast( Qgis::TransformDirection::Forward ) << 725865.850 << 6198519.947 << 0.001; QTest::newRow( "From LKS92/TM to Baltic93/TM (reverse)" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 25884 ) - << 725865.850 << 6198519.947 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 725865.850 << 198519.947 << 0.001; + << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 25884 ) + << 725865.850 << 6198519.947 << static_cast( Qgis::TransformDirection::Reverse ) << 725865.850 << 198519.947 << 0.001; QTest::newRow( "From LKS92/TM to WGS84" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << 725865.850 << 198519.947 << static_cast< int >( Qgis::TransformDirection::Forward ) << 27.61113711 << 55.87910378 << 0.00000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << 725865.850 << 198519.947 << static_cast( Qgis::TransformDirection::Forward ) << 27.61113711 << 55.87910378 << 0.00000001; QTest::newRow( "From LKS92/TM to WGS84 (reverse)" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << 27.61113711 << 55.87910378 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 725865.850 << 198519.947 << 0.001; + << QgsCoordinateReferenceSystem::fromEpsgId( 3059 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << 27.61113711 << 55.87910378 << static_cast( Qgis::TransformDirection::Reverse ) << 725865.850 << 198519.947 << 0.001; QTest::newRow( "From BNG to WGS84" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << 7467023.96 << -5527971.74 << static_cast< int >( Qgis::TransformDirection::Forward ) << 51.400222 << 0.000025 << 0.4; + << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << 7467023.96 << -5527971.74 << static_cast( Qgis::TransformDirection::Forward ) << 51.400222 << 0.000025 << 0.4; QTest::newRow( "From BNG to WGS84 2" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << 246909.0 << 54108.0 << static_cast< int >( Qgis::TransformDirection::Forward ) << -4.153951 << 50.366908 << 0.4; + << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << 246909.0 << 54108.0 << static_cast( Qgis::TransformDirection::Forward ) << -4.153951 << 50.366908 << 0.4; QTest::newRow( "From BNG to WGS84 (reverse)" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << 51.400222 << 0.000025 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 7467023.96 << -5527971.74 << 22000.0; + << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << 51.400222 << 0.000025 << static_cast( Qgis::TransformDirection::Reverse ) << 7467023.96 << -5527971.74 << 22000.0; QTest::newRow( "From WGS84 to BNG (reverse)" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) - << 7467023.96 << -5527971.74 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 51.400222 << 0.000025 << 0.4; + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) + << 7467023.96 << -5527971.74 << static_cast( Qgis::TransformDirection::Reverse ) << 51.400222 << 0.000025 << 0.4; QTest::newRow( "From WGS84 to BNG" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) - << 51.400222 << 0.000025 << static_cast< int >( Qgis::TransformDirection::Forward ) << 7467023.96 << -5527971.74 << 22000.0; + << QgsCoordinateReferenceSystem::fromEpsgId( 4326 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) + << 51.400222 << 0.000025 << static_cast( Qgis::TransformDirection::Forward ) << 7467023.96 << -5527971.74 << 22000.0; QTest::newRow( "From BNG to 3857" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3857 ) - << 7467023.96 << -5527971.74 << static_cast< int >( Qgis::TransformDirection::Forward ) << 5721846.47 << 2.78 << 43000.0; + << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 3857 ) + << 7467023.96 << -5527971.74 << static_cast( Qgis::TransformDirection::Forward ) << 5721846.47 << 2.78 << 43000.0; QTest::newRow( "From BNG to 3857 (reverse)" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) - << QgsCoordinateReferenceSystem::fromEpsgId( 3857 ) - << 5721846.47 << 2.78 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 7467023.96 << -5527971.74 << 22000.0; + << QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) + << QgsCoordinateReferenceSystem::fromEpsgId( 3857 ) + << 5721846.47 << 2.78 << static_cast( Qgis::TransformDirection::Reverse ) << 7467023.96 << -5527971.74 << 22000.0; } void TestQgsCoordinateTransform::transform() @@ -454,7 +440,7 @@ void TestQgsCoordinateTransform::transform() double z = 0; const QgsCoordinateTransform ct( sourceCrs, destCrs, QgsProject::instance() ); - ct.transformInPlace( x, y, z, static_cast< Qgis::TransformDirection >( direction ) ); + ct.transformInPlace( x, y, z, static_cast( direction ) ); QGSCOMPARENEAR( x, outX, precision ); QGSCOMPARENEAR( y, outY, precision ); } @@ -473,60 +459,60 @@ void TestQgsCoordinateTransform::transformEpoch_data() QTest::addColumn( "precision" ); QTest::newRow( "GDA2020 to ITRF at central epoch -- no coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2020.0 - << 150.0 << -30.0 << static_cast< int >( Qgis::TransformDirection::Forward ) << 150.0 << -30.0 << 0.0000000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2020.0 + << 150.0 << -30.0 << static_cast( Qgis::TransformDirection::Forward ) << 150.0 << -30.0 << 0.0000000001; QTest::newRow( "GDA2020 to ITRF at central epoch (reverse) -- no coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2020.0 - << 150.0 << -30.0 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 150.0 << -30.0 << 0.0000000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2020.0 + << 150.0 << -30.0 << static_cast( Qgis::TransformDirection::Reverse ) << 150.0 << -30.0 << 0.0000000001; QTest::newRow( "ITRF at central epoch to GDA2020 -- no coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2020.0 - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << 150.0 << -30.0 << static_cast< int >( Qgis::TransformDirection::Forward ) << 150.0 << -30.0 << 0.0000000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2020.0 + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << 150.0 << -30.0 << static_cast( Qgis::TransformDirection::Forward ) << 150.0 << -30.0 << 0.0000000001; QTest::newRow( "ITRF at central epoch to GDA2020 (reverse) -- no coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2020.0 - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << 150.0 << -30.0 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 150.0 << -30.0 << 0.0000000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2020.0 + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << 150.0 << -30.0 << static_cast( Qgis::TransformDirection::Reverse ) << 150.0 << -30.0 << 0.0000000001; QTest::newRow( "GDA2020 to ITRF at 2030 -- coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2030.0 - << 150.0 << -30.0 << static_cast< int >( Qgis::TransformDirection::Forward ) << 150.0000022212 << -29.9999950478 << 0.0000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2030.0 + << 150.0 << -30.0 << static_cast( Qgis::TransformDirection::Forward ) << 150.0000022212 << -29.9999950478 << 0.0000001; QTest::newRow( "GDA2020 to ITRF at 2030 (reverse) -- coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2030.0 - << 150.0000022212 << -29.9999950478 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 150.0 << -30.0 << 0.0000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2030.0 + << 150.0000022212 << -29.9999950478 << static_cast( Qgis::TransformDirection::Reverse ) << 150.0 << -30.0 << 0.0000001; QTest::newRow( "ITRF at 2030 to GDA2020-- coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2030.0 - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << 150.0000022212 << -29.9999950478 << static_cast< int >( Qgis::TransformDirection::Forward ) << 150.0 << -30.0 << 0.0000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2030.0 + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << 150.0000022212 << -29.9999950478 << static_cast( Qgis::TransformDirection::Forward ) << 150.0 << -30.0 << 0.0000001; QTest::newRow( "ITRF at 2030 to GDA2020 (reverse) -- coordinate change expected" ) - << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 - << 2030.0 - << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 - << std::numeric_limits< double >::quiet_NaN() - << 150.0 << -30.0 << static_cast< int >( Qgis::TransformDirection::Reverse ) << 150.0000022212 << -29.9999950478 << 0.0000001; + << QgsCoordinateReferenceSystem::fromEpsgId( 9000 ) // ITRF2014 + << 2030.0 + << QgsCoordinateReferenceSystem::fromEpsgId( 7844 ) // GDA2020 + << std::numeric_limits::quiet_NaN() + << 150.0 << -30.0 << static_cast( Qgis::TransformDirection::Reverse ) << 150.0000022212 << -29.9999950478 << 0.0000001; } void TestQgsCoordinateTransform::transformEpoch() @@ -550,7 +536,7 @@ void TestQgsCoordinateTransform::transformEpoch() double x = srcX; double y = srcY; - ct.transformInPlace( x, y, z, static_cast< Qgis::TransformDirection >( direction ) ); + ct.transformInPlace( x, y, z, static_cast( direction ) ); QGSCOMPARENEAR( x, outX, precision ); QGSCOMPARENEAR( y, outY, precision ); @@ -558,7 +544,7 @@ void TestQgsCoordinateTransform::transformEpoch() QgsCoordinateTransform ct2( sourceCrs, destCrs, QgsProject::instance() ); x = srcX; y = srcY; - ct2.transformInPlace( x, y, z, static_cast< Qgis::TransformDirection >( direction ) ); + ct2.transformInPlace( x, y, z, static_cast( direction ) ); QGSCOMPARENEAR( x, outX, precision ); QGSCOMPARENEAR( y, outY, precision ); } @@ -567,8 +553,7 @@ void TestQgsCoordinateTransform::dynamicToDynamicErrorHandler() { // test that warnings are raised when attempting a dynamic crs to dynamic crs transformation (not supported by PROJ) int counter = 0; - QgsCoordinateTransform::setDynamicCrsToDynamicCrsWarningHandler( [&counter]( const QgsCoordinateReferenceSystem &, const QgsCoordinateReferenceSystem & ) - { + QgsCoordinateTransform::setDynamicCrsToDynamicCrsWarningHandler( [&counter]( const QgsCoordinateReferenceSystem &, const QgsCoordinateReferenceSystem & ) { counter++; } ); @@ -753,9 +738,9 @@ void TestQgsCoordinateTransform::transformErrorOnePoint() const QgsCoordinateTransformContext context; const QgsCoordinateTransform ct( QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), QgsCoordinateReferenceSystem::fromEpsgId( 3857 ), context ); QVERIFY( ct.isValid() ); - double x[] = { -1000 }; - double y[] = { 0 }; - double z[] = { 0 }; + double x[] = { -1000 }; + double y[] = { 0 }; + double z[] = { 0 }; try { ct.transformCoords( 1, x, y, z ); @@ -846,15 +831,14 @@ void TestQgsCoordinateTransform::testCustomProjTransform() const QgsCoordinateTransform ct( ss, dd, QgsCoordinateTransformContext() ); QVERIFY( ct.isValid() ); QgsDebugMsgLevel( ct.instantiatedCoordinateOperationDetails().proj, 1 ); - QCOMPARE( ct.instantiatedCoordinateOperationDetails().proj, - QStringLiteral( "+proj=pipeline " - "+step +proj=unitconvert +xy_in=deg +xy_out=rad " - "+step +proj=push +v_3 " - "+step +proj=cart +ellps=GRS80 " - "+step +proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 +s=7 +convention=position_vector " - "+step +inv +proj=cart +ellps=WGS84 " - "+step +proj=pop +v_3 " - "+step +proj=unitconvert +xy_in=rad +xy_out=deg" ) ); + QCOMPARE( ct.instantiatedCoordinateOperationDetails().proj, QStringLiteral( "+proj=pipeline " + "+step +proj=unitconvert +xy_in=deg +xy_out=rad " + "+step +proj=push +v_3 " + "+step +proj=cart +ellps=GRS80 " + "+step +proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 +rz=6 +s=7 +convention=position_vector " + "+step +inv +proj=cart +ellps=WGS84 " + "+step +proj=pop +v_3 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg" ) ); } void TestQgsCoordinateTransform::testTransformationIsPossible() @@ -864,10 +848,9 @@ void TestQgsCoordinateTransform::testTransformationIsPossible() QVERIFY( !QgsCoordinateTransform::isTransformationPossible( QgsCoordinateReferenceSystem(), QgsCoordinateReferenceSystem() ) ); QVERIFY( QgsCoordinateTransform::isTransformationPossible( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ) ); -#if (PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR >= 1 ) ) +#if ( PROJ_VERSION_MAJOR > 8 || ( PROJ_VERSION_MAJOR == 8 && PROJ_VERSION_MINOR >= 1 ) ) // crses from two different celestial bodies => transformation is not possible - QVERIFY( !QgsCoordinateTransform::isTransformationPossible( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), - QgsCoordinateReferenceSystem( QStringLiteral( "ESRI:104903" ) ) ) ); + QVERIFY( !QgsCoordinateTransform::isTransformationPossible( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "ESRI:104903" ) ) ) ); #endif } diff --git a/tests/src/core/testqgscoordinateutils.cpp b/tests/src/core/testqgscoordinateutils.cpp index 542778a0c4d0..b8cd8348c9d4 100644 --- a/tests/src/core/testqgscoordinateutils.cpp +++ b/tests/src/core/testqgscoordinateutils.cpp @@ -55,7 +55,7 @@ void TestQgsCoordinateUtils::testPrecisionForCrs() void TestQgsCoordinateUtils::testDegreeWithSuffix() { - bool ok = false ; + bool ok = false; bool isEasting = false; double value = 0.0; @@ -91,7 +91,7 @@ void TestQgsCoordinateUtils::testDegreeWithSuffix() void TestQgsCoordinateUtils::testLocale() { - bool ok = false ; + bool ok = false; bool isEasting = false; double value = 0.0; diff --git a/tests/src/core/testqgscopyfiletask.cpp b/tests/src/core/testqgscopyfiletask.cpp index 7c4341e7efc3..73d0dc47bdf8 100644 --- a/tests/src/core/testqgscopyfiletask.cpp +++ b/tests/src/core/testqgscopyfiletask.cpp @@ -25,7 +25,7 @@ * \ingroup UnitTests * Unit tests for QgsCopyFileTask */ -class TestQgsCopyFileTask: public QObject +class TestQgsCopyFileTask : public QObject { Q_OBJECT diff --git a/tests/src/core/testqgscredentials.cpp b/tests/src/core/testqgscredentials.cpp index e889a709bc4c..0a50de7a9634 100644 --- a/tests/src/core/testqgscredentials.cpp +++ b/tests/src/core/testqgscredentials.cpp @@ -20,7 +20,6 @@ class TestCredentials : public QgsCredentials { - public: TestCredentials( bool isInstance ) : mExpectedRealm( QStringLiteral( "test_realm" ) ) @@ -56,13 +55,12 @@ class TestQgsCredentials : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void basic(); void threadSafety(); - }; @@ -112,15 +110,15 @@ void TestQgsCredentials::basic() struct GetPutCredentials { - void operator()( int i ) - { - QgsCredentials::instance()->put( QStringLiteral( "test_realm%1" ).arg( i ), QStringLiteral( "username" ), QStringLiteral( "password" ) ); - QString user; - QString password; - QVERIFY( QgsCredentials::instance()->get( QStringLiteral( "test_realm%1" ).arg( i ), user, password ) ); - QCOMPARE( user, QStringLiteral( "username" ) ); - QCOMPARE( password, QStringLiteral( "password" ) ); - } + void operator()( int i ) + { + QgsCredentials::instance()->put( QStringLiteral( "test_realm%1" ).arg( i ), QStringLiteral( "username" ), QStringLiteral( "password" ) ); + QString user; + QString password; + QVERIFY( QgsCredentials::instance()->get( QStringLiteral( "test_realm%1" ).arg( i ), user, password ) ); + QCOMPARE( user, QStringLiteral( "username" ) ); + QCOMPARE( password, QStringLiteral( "password" ) ); + } }; void TestQgsCredentials::threadSafety() @@ -132,7 +130,7 @@ void TestQgsCredentials::threadSafety() t->mPassword = QStringLiteral( "pass" ); // smash credentials rendering over multiple threads - QVector< int > list; + QVector list; list.resize( 1000 ); for ( int i = 0; i < list.size(); ++i ) list[i] = i; diff --git a/tests/src/core/testqgscurve.cpp b/tests/src/core/testqgscurve.cpp index 07c0f492127d..346b40629b7d 100644 --- a/tests/src/core/testqgscurve.cpp +++ b/tests/src/core/testqgscurve.cpp @@ -47,77 +47,75 @@ class TestQgsCurve : public QObject }; -#define TEST_C2L(circularString, tol, toltype, exp, prec) { \ - std::unique_ptr< QgsLineString > lineString( \ - circularString->curveToLine(tol, toltype) \ - ); \ - QVERIFY( lineString.get() ); \ - QString wkt_out = lineString->asWkt(prec); \ - QCOMPARE( wkt_out, QString( exp ) ); \ - /* Test reverse */ \ - std::unique_ptr< QgsCircularString > reversed( \ - circularString->reversed() \ - ); \ - lineString.reset( \ - reversed->curveToLine(tol, toltype) \ - ); \ - wkt_out = lineString->asWkt(prec); \ - lineString.reset( \ - reversed->curveToLine(tol, toltype) \ - ); \ - std::unique_ptr< QgsLineString > expgeom( \ - dynamic_cast( \ - QgsGeometryFactory::geomFromWkt( exp ).release() \ - ) \ - ); \ - expgeom.reset( expgeom->reversed() ); \ - QString exp_reversed = expgeom->asWkt(prec); \ - QCOMPARE( wkt_out, exp_reversed ); \ +#define TEST_C2L( circularString, tol, toltype, exp, prec ) \ + { \ + std::unique_ptr lineString( \ + circularString->curveToLine( tol, toltype ) \ + ); \ + QVERIFY( lineString.get() ); \ + QString wkt_out = lineString->asWkt( prec ); \ + QCOMPARE( wkt_out, QString( exp ) ); \ + /* Test reverse */ \ + std::unique_ptr reversed( \ + circularString->reversed() \ + ); \ + lineString.reset( \ + reversed->curveToLine( tol, toltype ) \ + ); \ + wkt_out = lineString->asWkt( prec ); \ + lineString.reset( \ + reversed->curveToLine( tol, toltype ) \ + ); \ + std::unique_ptr expgeom( \ + dynamic_cast( \ + QgsGeometryFactory::geomFromWkt( exp ).release() \ + ) \ + ); \ + expgeom.reset( expgeom->reversed() ); \ + QString exp_reversed = expgeom->asWkt( prec ); \ + QCOMPARE( wkt_out, exp_reversed ); \ } void TestQgsCurve::curveToLine() { - std::unique_ptr< QgsCircularString > circularString; + std::unique_ptr circularString; /* input: 2 quadrants arc (180 degrees, PI radians) */ - circularString.reset( dynamic_cast< QgsCircularString *>( - QgsGeometryFactory::geomFromWkt( QStringLiteral( - "CIRCULARSTRING(0 0,100 100,200 0)" - ) - ).release() - ) ); + circularString.reset( dynamic_cast( + QgsGeometryFactory::geomFromWkt( QStringLiteral( + "CIRCULARSTRING(0 0,100 100,200 0)" + ) + ) + .release() + ) ); QVERIFY( circularString.get() ); /* op: Maximum of 10 units of difference, symmetric */ - TEST_C2L( circularString, 10, QgsAbstractGeometry::MaximumDifference, - "LineString (0 0, 29.29 70.71, 100 100, 170.71 70.71, 200 0)", 2 ); + TEST_C2L( circularString, 10, QgsAbstractGeometry::MaximumDifference, "LineString (0 0, 29.29 70.71, 100 100, 170.71 70.71, 200 0)", 2 ); /* op: Maximum of 300 units (higher than sagitta) of difference, symmetric */ /* See https://github.com/qgis/QGIS/issues/31832 */ - TEST_C2L( circularString, 300, QgsAbstractGeometry::MaximumDifference, - "LineString (0 0, 200 0)", 2 ); + TEST_C2L( circularString, 300, QgsAbstractGeometry::MaximumDifference, "LineString (0 0, 200 0)", 2 ); /* op: Maximum of M_PI / 8 degrees of angle, (a)symmetric */ /* See https://github.com/qgis/QGIS/issues/24616 */ - TEST_C2L( circularString, M_PI / 8, QgsAbstractGeometry::MaximumAngle, - "LineString (0 0, 7.61 38.27, 29.29 70.71, 61.73 92.39, 100 100, 138.27 92.39, 170.71 70.71, 192.39 38.27, 200 0)", 2 ); + TEST_C2L( circularString, M_PI / 8, QgsAbstractGeometry::MaximumAngle, "LineString (0 0, 7.61 38.27, 29.29 70.71, 61.73 92.39, 100 100, 138.27 92.39, 170.71 70.71, 192.39 38.27, 200 0)", 2 ); /* op: Maximum of 70 degrees of angle, symmetric */ /* See https://github.com/qgis/QGIS/issues/24621 */ - TEST_C2L( circularString, 70 * M_PI / 180, QgsAbstractGeometry::MaximumAngle, - "LineString (0 0, 50 86.6, 150 86.6, 200 0)", 2 ); + TEST_C2L( circularString, 70 * M_PI / 180, QgsAbstractGeometry::MaximumAngle, "LineString (0 0, 50 86.6, 150 86.6, 200 0)", 2 ); /* input: 2 arcs of 2 quadrants each (180 degrees + 180 degrees other direction) */ circularString.reset( dynamic_cast( - QgsGeometryFactory::geomFromWkt( QStringLiteral( - "CIRCULARSTRING(0 0,100 100,200 0,300 -100,400 0)" - ) ).release() - ) ); + QgsGeometryFactory::geomFromWkt( QStringLiteral( + "CIRCULARSTRING(0 0,100 100,200 0,300 -100,400 0)" + ) ) + .release() + ) ); QVERIFY( circularString.get() ); /* op: Maximum of M_PI / 3 degrees of angle */ - TEST_C2L( circularString, M_PI / 3, QgsAbstractGeometry::MaximumAngle, - "LineString (0 0, 50 86.6, 150 86.6, 200 0, 250 -86.6, 350 -86.6, 400 0)", 2 ); + TEST_C2L( circularString, M_PI / 3, QgsAbstractGeometry::MaximumAngle, "LineString (0 0, 50 86.6, 150 86.6, 200 0, 250 -86.6, 350 -86.6, 400 0)", 2 ); } diff --git a/tests/src/core/testqgsdatadefinedsizelegend.cpp b/tests/src/core/testqgsdatadefinedsizelegend.cpp index 78c1edbba3d3..031ed7ebe9bf 100644 --- a/tests/src/core/testqgsdatadefinedsizelegend.cpp +++ b/tests/src/core/testqgsdatadefinedsizelegend.cpp @@ -38,16 +38,15 @@ class TestQgsDataDefinedSizeLegend : public QgsTest Q_OBJECT public: - - TestQgsDataDefinedSizeLegend() : QgsTest( QStringLiteral( "Data Defined Size Legend Tests" ), QStringLiteral( "data_defined_size_legend" ) ) {} + TestQgsDataDefinedSizeLegend() + : QgsTest( QStringLiteral( "Data Defined Size Legend Tests" ), QStringLiteral( "data_defined_size_legend" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testBasic(); void testCrowded(); - }; void TestQgsDataDefinedSizeLegend::initTestCase() @@ -71,7 +70,7 @@ void TestQgsDataDefinedSizeLegend::testBasic() settings.setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); QList classes; - classes << QgsDataDefinedSizeLegend::SizeClass( 3., QStringLiteral( "3" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 3., QStringLiteral( "3" ) ); classes << QgsDataDefinedSizeLegend::SizeClass( 15., QStringLiteral( "15" ) ); classes << QgsDataDefinedSizeLegend::SizeClass( 30., QStringLiteral( "30" ) ); settings.setClasses( classes ); @@ -81,7 +80,7 @@ void TestQgsDataDefinedSizeLegend::testBasic() props[QStringLiteral( "color" )] = QStringLiteral( "200,255,200" ); props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,255,0" ); - settings.setSymbol( QgsMarkerSymbol::createSimple( props ) ); // takes ownership + settings.setSymbol( QgsMarkerSymbol::createSimple( props ) ); // takes ownership QgsRenderContext context( _createRenderContext( 100, 96, 100 ) ); @@ -101,8 +100,8 @@ void TestQgsDataDefinedSizeLegend::testCrowded() settings.setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); QList classes; - classes << QgsDataDefinedSizeLegend::SizeClass( 2., QStringLiteral( "2" ) ); - classes << QgsDataDefinedSizeLegend::SizeClass( 5., QStringLiteral( "5" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 2., QStringLiteral( "2" ) ); + classes << QgsDataDefinedSizeLegend::SizeClass( 5., QStringLiteral( "5" ) ); classes << QgsDataDefinedSizeLegend::SizeClass( 10., QStringLiteral( "10" ) ); classes << QgsDataDefinedSizeLegend::SizeClass( 12., QStringLiteral( "12" ) ); classes << QgsDataDefinedSizeLegend::SizeClass( 15., QStringLiteral( "15" ) ); @@ -114,7 +113,7 @@ void TestQgsDataDefinedSizeLegend::testCrowded() props[QStringLiteral( "color" )] = QStringLiteral( "200,255,200" ); props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,255,0" ); - settings.setSymbol( QgsMarkerSymbol::createSimple( props ) ); // takes ownership + settings.setSymbol( QgsMarkerSymbol::createSimple( props ) ); // takes ownership QgsRenderContext context( _createRenderContext( 100, 96, 100 ) ); diff --git a/tests/src/core/testqgsdataitem.cpp b/tests/src/core/testqgsdataitem.cpp index 968e754788e7..696b6090e077 100644 --- a/tests/src/core/testqgsdataitem.cpp +++ b/tests/src/core/testqgsdataitem.cpp @@ -44,10 +44,10 @@ class TestQgsDataItem : public QObject TestQgsDataItem(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testValid(); void testDirItem(); @@ -119,7 +119,7 @@ void TestQgsDataItem::testValid() void TestQgsDataItem::testDirItem() { - std::unique_ptr< QgsDirectoryItem > dirItem = std::make_unique< QgsDirectoryItem >( nullptr, QStringLiteral( "Test" ), TEST_DATA_DIR ); + std::unique_ptr dirItem = std::make_unique( nullptr, QStringLiteral( "Test" ), TEST_DATA_DIR ); QCOMPARE( dirItem->dirPath(), QStringLiteral( TEST_DATA_DIR ) ); QCOMPARE( dirItem->name(), QStringLiteral( "Test" ) ); @@ -146,7 +146,7 @@ void TestQgsDataItem::testDirItemChildren() { QgsDataItem *dataItem = children[i]; QgsLayerItem *layerItem = qobject_cast( dataItem ); - if ( ! layerItem ) + if ( !layerItem ) continue; // test .vrt and .gz files are not loaded by gdal and ogr @@ -198,7 +198,6 @@ void TestQgsDataItem::testDirItemChildren() { QVERIFY2( lName == QLatin1String( "points3" ), errStr.toLocal8Bit().constData() ); } - } qDeleteAll( children ); @@ -216,14 +215,14 @@ void TestQgsDataItem::testDirItemMonitoring() QVERIFY( QDir().mkpath( child1 ) ); QVERIFY( QDir().mkpath( child2 ) ); - std::unique_ptr< QgsDirectoryItem > dirItem = std::make_unique< QgsDirectoryItem >( nullptr, QStringLiteral( "parent name" ), parentDir, parentDir + '/' ); + std::unique_ptr dirItem = std::make_unique( nullptr, QStringLiteral( "parent name" ), parentDir, parentDir + '/' ); QCOMPARE( dirItem->path(), parentDir + '/' ); QCOMPARE( dirItem->dirPath(), parentDir ); dirItem->populate( true ); QCOMPARE( dirItem->rowCount(), 2 ); - QPointer< QgsDirectoryItem > childItem1( qobject_cast< QgsDirectoryItem * >( dirItem->children().at( 0 ) ) ); - QPointer< QgsDirectoryItem > childItem2( qobject_cast< QgsDirectoryItem * >( dirItem->children().at( 1 ) ) ); + QPointer childItem1( qobject_cast( dirItem->children().at( 0 ) ) ); + QPointer childItem2( qobject_cast( dirItem->children().at( 1 ) ) ); QVERIFY( childItem1 ); QCOMPARE( childItem1->path(), child1 ); QCOMPARE( childItem1->dirPath(), child1 ); @@ -253,7 +252,7 @@ void TestQgsDataItem::testDirItemMonitoring() QCOMPARE( dirItem->rowCount(), 3 ); QVERIFY( childItem1 ); QVERIFY( childItem2 ); - QPointer< QgsDirectoryItem > childItem3( qobject_cast< QgsDirectoryItem * >( dirItem->children().at( 2 ) ) ); + QPointer childItem3( qobject_cast( dirItem->children().at( 2 ) ) ); QCOMPARE( childItem3->dirPath(), child3 ); QCOMPARE( childItem3->monitoring(), Qgis::BrowserDirectoryMonitoring::Default ); @@ -384,7 +383,7 @@ void TestQgsDataItem::testDirItemMonitoringSlowDrive() QVERIFY( !QgsDirectoryItem::pathShouldByMonitoredByDefault( child2 ) ); QVERIFY( !QgsDirectoryItem::pathShouldByMonitoredByDefault( child2child ) ); - std::unique_ptr< QgsDirectoryItem > dirItem = std::make_unique< QgsDirectoryItem >( nullptr, QStringLiteral( "parent name" ), parentDir, QStringLiteral( "/" ) + parentDir ); + std::unique_ptr dirItem = std::make_unique( nullptr, QStringLiteral( "parent name" ), parentDir, QStringLiteral( "/" ) + parentDir ); // user has not explicitly set the path to be monitored or not, so Default should be returned here: QCOMPARE( dirItem->monitoring(), Qgis::BrowserDirectoryMonitoring::Default ); // but directory should NOT be monitored @@ -394,8 +393,8 @@ void TestQgsDataItem::testDirItemMonitoringSlowDrive() QVERIFY( !dirItem->mFileSystemWatcher ); QCOMPARE( dirItem->rowCount(), 2 ); - QPointer< QgsDirectoryItem > childItem1( qobject_cast< QgsDirectoryItem * >( dirItem->children().at( 0 ) ) ); - QPointer< QgsDirectoryItem > childItem2( qobject_cast< QgsDirectoryItem * >( dirItem->children().at( 1 ) ) ); + QPointer childItem1( qobject_cast( dirItem->children().at( 0 ) ) ); + QPointer childItem2( qobject_cast( dirItem->children().at( 1 ) ) ); QVERIFY( childItem1 ); QVERIFY( childItem2 ); // neither of these should be monitored either! @@ -419,37 +418,30 @@ void TestQgsDataItem::testDirItemMonitoringSlowDrive() void TestQgsDataItem::testLayerItemType() { - std::unique_ptr< QgsMapLayer > layer = std::make_unique< QgsVectorLayer >( mTestDataDir + "polys.shp", - QString(), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp", QString(), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QCOMPARE( QgsLayerItem::typeFromMapLayer( layer.get() ), Qgis::BrowserLayerType::Polygon ); - layer = std::make_unique< QgsVectorLayer >( mTestDataDir + "points.shp", - QString(), QStringLiteral( "ogr" ) ); + layer = std::make_unique( mTestDataDir + "points.shp", QString(), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QCOMPARE( QgsLayerItem::typeFromMapLayer( layer.get() ), Qgis::BrowserLayerType::Point ); - layer = std::make_unique< QgsVectorLayer >( mTestDataDir + "lines.shp", - QString(), QStringLiteral( "ogr" ) ); + layer = std::make_unique( mTestDataDir + "lines.shp", QString(), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QCOMPARE( QgsLayerItem::typeFromMapLayer( layer.get() ), Qgis::BrowserLayerType::Line ); - layer = std::make_unique< QgsVectorLayer >( mTestDataDir + "nonspatial.dbf", - QString(), QStringLiteral( "ogr" ) ); + layer = std::make_unique( mTestDataDir + "nonspatial.dbf", QString(), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QCOMPARE( QgsLayerItem::typeFromMapLayer( layer.get() ), Qgis::BrowserLayerType::TableLayer ); - layer = std::make_unique< QgsVectorLayer >( mTestDataDir + "invalid.dbf", - QString(), QStringLiteral( "ogr" ) ); + layer = std::make_unique( mTestDataDir + "invalid.dbf", QString(), QStringLiteral( "ogr" ) ); QCOMPARE( QgsLayerItem::typeFromMapLayer( layer.get() ), Qgis::BrowserLayerType::Vector ); - layer = std::make_unique< QgsRasterLayer >( mTestDataDir + "rgb256x256.png", - QString(), QStringLiteral( "gdal" ) ); + layer = std::make_unique( mTestDataDir + "rgb256x256.png", QString(), QStringLiteral( "gdal" ) ); QVERIFY( layer->isValid() ); QCOMPARE( QgsLayerItem::typeFromMapLayer( layer.get() ), Qgis::BrowserLayerType::Raster ); - layer = std::make_unique< QgsMeshLayer >( mTestDataDir + "mesh/quad_and_triangle.2dm", - QString(), QStringLiteral( "mdal" ) ); + layer = std::make_unique( mTestDataDir + "mesh/quad_and_triangle.2dm", QString(), QStringLiteral( "mdal" ) ); QVERIFY( layer->isValid() ); QCOMPARE( QgsLayerItem::typeFromMapLayer( layer.get() ), Qgis::BrowserLayerType::Mesh ); } diff --git a/tests/src/core/testqgsdatasourceuri.cpp b/tests/src/core/testqgsdatasourceuri.cpp index 0866d28c2bc3..409b059b4889 100644 --- a/tests/src/core/testqgsdatasourceuri.cpp +++ b/tests/src/core/testqgsdatasourceuri.cpp @@ -21,7 +21,7 @@ Q_DECLARE_METATYPE( Qgis::WkbType ) Q_DECLARE_METATYPE( QgsDataSourceUri::SslMode ) -class TestQgsDataSourceUri: public QObject +class TestQgsDataSourceUri : public QObject { Q_OBJECT private slots: @@ -64,213 +64,211 @@ void TestQgsDataSourceUri::checkparser_data() QTest::newRow( "oci" ) - << "host=myhost port=1234 user='myname' password='mypasswd' estimatedmetadata=true srid=1000003007 table=\"myschema\".\"mytable\" (GEOM) myparam='myvalue' sql=" - << "mytable" // table - << "GEOM" // geometrycolumn - << "" // key - << true // estimatedmetadata - << "1000003007" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "myname" // user - << "mypasswd" // password - << "" // authcfg - << "" // dbname - << "myhost" // host - << "1234" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "" // sql - << "myvalue" // myparam - << "myschema" - ; + << "host=myhost port=1234 user='myname' password='mypasswd' estimatedmetadata=true srid=1000003007 table=\"myschema\".\"mytable\" (GEOM) myparam='myvalue' sql=" + << "mytable" // table + << "GEOM" // geometrycolumn + << "" // key + << true // estimatedmetadata + << "1000003007" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "myname" // user + << "mypasswd" // password + << "" // authcfg + << "" // dbname + << "myhost" // host + << "1234" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "" // sql + << "myvalue" // myparam + << "myschema"; QTest::newRow( "pgrast" ) - << R"(PG: dbname='qgis_tests' host=localhost port=5432 user='myname' sslmode=disable estimatedmetadata=true srid=3067 table="public"."basic_map_tiled" (rast))" - << "basic_map_tiled" // table - << "rast" // geometrycolumn - << "" // key - << true // estimatedmetadata - << "3067" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "myname" // user - << "" // password - << "" // authcfg - << "qgis_tests" // dbname - << "localhost" // host - << "5432" // port - << "" // driver - << QgsDataSourceUri::SslDisable // sslmode - << "" // sql - << "" // myparam - << "public" // schema - ; + << R"(PG: dbname='qgis_tests' host=localhost port=5432 user='myname' sslmode=disable estimatedmetadata=true srid=3067 table="public"."basic_map_tiled" (rast))" + << "basic_map_tiled" // table + << "rast" // geometrycolumn + << "" // key + << true // estimatedmetadata + << "3067" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "myname" // user + << "" // password + << "" // authcfg + << "qgis_tests" // dbname + << "localhost" // host + << "5432" // port + << "" // driver + << QgsDataSourceUri::SslDisable // sslmode + << "" // sql + << "" // myparam + << "public" // schema + ; QTest::newRow( "pg_notable" ) - << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=myschema " - << "" // table - << "" // geometrycolumn - << "" // key - << false // estimatedmetadata - << "" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "myname" // user - << "mypasswd" // password - << "" // authcfg - << "mydb" // dbname - << "myhost" // host - << "5432" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "" // sql - << "" // myparam - << "public" // schema - ; + << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=myschema " + << "" // table + << "" // geometrycolumn + << "" // key + << false // estimatedmetadata + << "" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "myname" // user + << "mypasswd" // password + << "" // authcfg + << "mydb" // dbname + << "myhost" // host + << "5432" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "" // sql + << "" // myparam + << "public" // schema + ; QTest::newRow( "pg_notable_quoted" ) - << "dbname='mydb' host='myhost' user='myname' password='mypasswd' port='5432' mode='2' schema=myschema" - << "" // table - << "" // geometrycolumn - << "" // key - << false // estimatedmetadata - << "" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "myname" // user - << "mypasswd" // password - << "" // authcfg - << "mydb" // dbname - << "myhost" // host - << "5432" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "" // sql - << "" // myparam - << "public" // schema - ; + << "dbname='mydb' host='myhost' user='myname' password='mypasswd' port='5432' mode='2' schema=myschema" + << "" // table + << "" // geometrycolumn + << "" // key + << false // estimatedmetadata + << "" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "myname" // user + << "mypasswd" // password + << "" // authcfg + << "mydb" // dbname + << "myhost" // host + << "5432" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "" // sql + << "" // myparam + << "public" // schema + ; QTest::newRow( "pg_notable_authcfg" ) - << "PG: dbname=mydb host=myhost authcfg=myauthcfg port=5432 mode=2 schema=myschema " - << "" // table - << "" // geometrycolumn - << "" // key - << false // estimatedmetadata - << "" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "" // user - << "" // password - << "myauthcfg" // authcfg - << "mydb" // dbname - << "myhost" // host - << "5432" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "" // sql - << "" // myparam - << "public" // schema - ; - + << "PG: dbname=mydb host=myhost authcfg=myauthcfg port=5432 mode=2 schema=myschema " + << "" // table + << "" // geometrycolumn + << "" // key + << false // estimatedmetadata + << "" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "" // user + << "" // password + << "myauthcfg" // authcfg + << "mydb" // dbname + << "myhost" // host + << "5432" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "" // sql + << "" // myparam + << "public" // schema + ; QTest::newRow( "pgmlsz" ) - << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=public column=geom table=mytable type=MultiLineStringZ" - << "mytable" // table - << "" // geometrycolumn - << "" // key - << false // estimatedmetadata - << "" // srid - << Qgis::WkbType::MultiLineStringZ // type - << false // selectatid - << "" // service - << "myname" // user - << "mypasswd" // password - << "" // authcfg - << "mydb" // dbname - << "myhost" // host - << "5432" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "" // sql - << "" // myparam - << "public" // schema - ; + << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=public column=geom table=mytable type=MultiLineStringZ" + << "mytable" // table + << "" // geometrycolumn + << "" // key + << false // estimatedmetadata + << "" // srid + << Qgis::WkbType::MultiLineStringZ // type + << false // selectatid + << "" // service + << "myname" // user + << "mypasswd" // password + << "" // authcfg + << "mydb" // dbname + << "myhost" // host + << "5432" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "" // sql + << "" // myparam + << "public" // schema + ; QTest::newRow( "arcgis rest sql" ) - << "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=abc='def'" - << "" // table - << "" // geometrycolumn - << "" // key - << false // estimatedmetadata - << "" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "" // user - << "" // password - << "" // authcfg - << "" // dbname - << "" // host - << "" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "abc='def'" // sql - << "" // myparam - << "public" // schema - ; + << "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=abc='def'" + << "" // table + << "" // geometrycolumn + << "" // key + << false // estimatedmetadata + << "" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "" // user + << "" // password + << "" // authcfg + << "" // dbname + << "" // host + << "" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "abc='def'" // sql + << "" // myparam + << "public" // schema + ; QTest::newRow( "arcgis rest empty sql" ) - << "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=''" - << "" // table - << "" // geometrycolumn - << "" // key - << false // estimatedmetadata - << "" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "" // user - << "" // password - << "" // authcfg - << "" // dbname - << "" // host - << "" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "" // sql - << "" // myparam - << "public" // schema - ; + << "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=''" + << "" // table + << "" // geometrycolumn + << "" // key + << false // estimatedmetadata + << "" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "" // user + << "" // password + << "" // authcfg + << "" // dbname + << "" // host + << "" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "" // sql + << "" // myparam + << "public" // schema + ; QTest::newRow( "arcgis rest empty sql 2" ) - << "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=\"\"" - << "" // table - << "" // geometrycolumn - << "" // key - << false // estimatedmetadata - << "" // srid - << Qgis::WkbType::Unknown // type - << false // selectatid - << "" // service - << "" // user - << "" // password - << "" // authcfg - << "" // dbname - << "" // host - << "" // port - << "" // driver - << QgsDataSourceUri::SslPrefer // sslmode - << "" // sql - << "" // myparam - << "public" // schema - ; + << "crs='EPSG:2154' filter='' url='https://carto.isogeo.net/server/rest/services/scan_services_1/EMS_EFS_WMS_WFS/FeatureServer/2' table='' sql=\"\"" + << "" // table + << "" // geometrycolumn + << "" // key + << false // estimatedmetadata + << "" // srid + << Qgis::WkbType::Unknown // type + << false // selectatid + << "" // service + << "" // user + << "" // password + << "" // authcfg + << "" // dbname + << "" // host + << "" // port + << "" // driver + << QgsDataSourceUri::SslPrefer // sslmode + << "" // sql + << "" // myparam + << "public" // schema + ; } void TestQgsDataSourceUri::checkparser() @@ -327,24 +325,24 @@ void TestQgsDataSourceUri::checkSetConnection_data() QTest::addColumn( "authcfg" ); QTest::newRow( "simple" ) - << "myhost" // host - << "5432" // port - << "mydb" // dbname - << "myname" // user - << "mypasswd" // password - << QgsDataSourceUri::SslPrefer // sslmode - << "" // authcfg - ; + << "myhost" // host + << "5432" // port + << "mydb" // dbname + << "myname" // user + << "mypasswd" // password + << QgsDataSourceUri::SslPrefer // sslmode + << "" // authcfg + ; QTest::newRow( "authcfg" ) - << "myhost" // host - << "5432" // port - << "" // dbname - << "" // user - << "mypasswd" // password - << QgsDataSourceUri::SslPrefer // sslmode - << "myauthcfg" // authcfg - ; + << "myhost" // host + << "5432" // port + << "" // dbname + << "" // user + << "mypasswd" // password + << QgsDataSourceUri::SslPrefer // sslmode + << "myauthcfg" // authcfg + ; } void TestQgsDataSourceUri::checkSetConnection() @@ -382,22 +380,22 @@ void TestQgsDataSourceUri::checkSetConnectionService_data() QTest::addColumn( "authcfg" ); QTest::newRow( "simple" ) - << "myservice" // service - << "mydb" // dbname - << "myname" // user - << "mypasswd" // password - << QgsDataSourceUri::SslPrefer // sslmode - << "" // authcfg - ; + << "myservice" // service + << "mydb" // dbname + << "myname" // user + << "mypasswd" // password + << QgsDataSourceUri::SslPrefer // sslmode + << "" // authcfg + ; QTest::newRow( "authcfg" ) - << "myservice" // service - << "" // dbname - << "" // user - << "mypasswd" // password - << QgsDataSourceUri::SslPrefer // sslmode - << "myauthcfg" // authcfg - ; + << "myservice" // service + << "" // dbname + << "" // user + << "mypasswd" // password + << QgsDataSourceUri::SslPrefer // sslmode + << "myauthcfg" // authcfg + ; } void TestQgsDataSourceUri::checkSetConnectionService() @@ -430,39 +428,39 @@ void TestQgsDataSourceUri::checkConnectionInfo_data() QTest::newRow( "service" ) - << "service='qgis_test'" - << "service='qgis_test'" // conninfo - ; + << "service='qgis_test'" + << "service='qgis_test'" // conninfo + ; QTest::newRow( "db_host_port_user_pw" ) - << "dbname='qgis_test' host=postgres port=5432 user='qgis_test_user' password='qgis_test_user_password'" - << "dbname='qgis_test' host=postgres port=5432 user='qgis_test_user' password='qgis_test_user_password'" // conninfo - ; + << "dbname='qgis_test' host=postgres port=5432 user='qgis_test_user' password='qgis_test_user_password'" + << "dbname='qgis_test' host=postgres port=5432 user='qgis_test_user' password='qgis_test_user_password'" // conninfo + ; QTest::newRow( "oci" ) - << "host=myhost port=1234 user='myname' password='mypasswd' estimatedmetadata=true srid=1000003007 table=\"myschema\".\"mytable\" (GEOM) myparam='myvalue' sql=" - << "host=myhost port=1234 user='myname' password='mypasswd'" // conninfo - ; + << "host=myhost port=1234 user='myname' password='mypasswd' estimatedmetadata=true srid=1000003007 table=\"myschema\".\"mytable\" (GEOM) myparam='myvalue' sql=" + << "host=myhost port=1234 user='myname' password='mypasswd'" // conninfo + ; QTest::newRow( "pgrast" ) - << R"(PG: dbname='qgis_tests' host=localhost port=5432 user='myname' sslmode=disable estimatedmetadata=true srid=3067 table="public"."basic_map_tiled" (rast))" - << "dbname='qgis_tests' host=localhost port=5432 user='myname' sslmode=disable" // conninfo - ; + << R"(PG: dbname='qgis_tests' host=localhost port=5432 user='myname' sslmode=disable estimatedmetadata=true srid=3067 table="public"."basic_map_tiled" (rast))" + << "dbname='qgis_tests' host=localhost port=5432 user='myname' sslmode=disable" // conninfo + ; QTest::newRow( "pg_notable" ) - << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=myschema " - << "dbname='mydb' host=myhost port=5432 user='myname' password='mypasswd'" // conninfo - ; + << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=myschema " + << "dbname='mydb' host=myhost port=5432 user='myname' password='mypasswd'" // conninfo + ; QTest::newRow( "pg_notable_quoted" ) - << "dbname='mydb' host='myhost' user='myname' password='mypasswd' port='5432' mode='2' schema=myschema" - << "dbname='mydb' host=myhost port=5432 user='myname' password='mypasswd'" // conninfo - ; + << "dbname='mydb' host='myhost' user='myname' password='mypasswd' port='5432' mode='2' schema=myschema" + << "dbname='mydb' host=myhost port=5432 user='myname' password='mypasswd'" // conninfo + ; QTest::newRow( "pgmlsz" ) - << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=public column=geom table=mytable type=MultiLineStringZ" - << "dbname='mydb' host=myhost port=5432 user='myname' password='mypasswd'" // conninfo - ; + << "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=public column=geom table=mytable type=MultiLineStringZ" + << "dbname='mydb' host=myhost port=5432 user='myname' password='mypasswd'" // conninfo + ; } void TestQgsDataSourceUri::checkConnectionInfo() @@ -584,7 +582,6 @@ void TestQgsDataSourceUri::checkAuthParams() uri7.setEncodedUri( encodedTwo ); QCOMPARE( uri7.param( QStringLiteral( "percent" ) ), QStringLiteral( "application%2Fvnd.geoserver.mbstyle%2Bjson" ) ); QCOMPARE( uri7.param( QStringLiteral( "explicit" ) ), QStringLiteral( "application/vnd.geoserver.mbstyle+json" ) ); - } void TestQgsDataSourceUri::checkParameterKeys() diff --git a/tests/src/core/testqgsdiagram.cpp b/tests/src/core/testqgsdiagram.cpp index 6e30de1984a3..57a5bbf78437 100644 --- a/tests/src/core/testqgsdiagram.cpp +++ b/tests/src/core/testqgsdiagram.cpp @@ -49,10 +49,11 @@ class TestQgsDiagram : public QgsTest Q_OBJECT public: - TestQgsDiagram() : QgsTest( QStringLiteral( "Diagram Tests" ), QStringLiteral( "diagrams" ) ) {} + TestQgsDiagram() + : QgsTest( QStringLiteral( "Diagram Tests" ), QStringLiteral( "diagrams" ) ) {} private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings *mMapSettings = nullptr; QgsVectorLayer *mPointsLayer = nullptr; QString mTestDataDir; @@ -81,8 +82,7 @@ class TestQgsDiagram : public QgsTest // const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); //we don't want to render the points themselves, just the diagrams QVariantMap symbolProps; @@ -117,7 +117,6 @@ class TestQgsDiagram : public QgsTest // will be called after every testfunction. void cleanup() { - } void testPieDiagram() @@ -596,7 +595,6 @@ class TestQgsDiagram : public QgsTest ds.diagramOrientation = QgsDiagramSettings::Down; dr->setDiagramSettings( ds ); QGSVERIFYRENDERMAPSETTINGSCHECK( "stacked_varying_down", "stacked_varying_down", *mMapSettings, 200, 15 ); - } void testStackedAxis() @@ -1122,12 +1120,12 @@ class TestQgsDiagram : public QgsTest void testClipping() { const QString filename = QStringLiteral( TEST_DATA_DIR ) + "/lines.shp"; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) ); QVariantMap props; props.insert( QStringLiteral( "outline_color" ), QStringLiteral( "#487bb6" ) ); props.insert( QStringLiteral( "outline_width" ), QStringLiteral( "1" ) ); - std::unique_ptr< QgsLineSymbol > symbol( QgsLineSymbol::createSimple( props ) ); + std::unique_ptr symbol( QgsLineSymbol::createSimple( props ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( symbol.release() ) ); QgsDiagramSettings ds; @@ -1168,12 +1166,11 @@ class TestQgsDiagram : public QgsTest mMapSettings->addClippingRegion( region2 ); const bool res = QGSRENDERMAPSETTINGSCHECK( "diagram_clipping", "diagram_clipping", *mMapSettings, 200, 15 ); - mMapSettings->setClippingRegions( QList< QgsMapClippingRegion >() ); + mMapSettings->setClippingRegions( QList() ); mMapSettings->setLayers( QList() << mPointsLayer ); QVERIFY( res ); } - }; diff --git a/tests/src/core/testqgsdistancearea.cpp b/tests/src/core/testqgsdistancearea.cpp index d794df5bc481..c47a8b8779d3 100644 --- a/tests/src/core/testqgsdistancearea.cpp +++ b/tests/src/core/testqgsdistancearea.cpp @@ -29,9 +29,8 @@ #include "qgsproject.h" #include -class TestQgsDistanceArea: public QObject +class TestQgsDistanceArea : public QObject { - Q_OBJECT private slots: void initTestCase(); @@ -47,7 +46,6 @@ class TestQgsDistanceArea: public QObject void emptyPolygon(); void regression14675(); void regression16820(); - }; void TestQgsDistanceArea::initTestCase() @@ -90,7 +88,7 @@ void TestQgsDistanceArea::basic() // Different Ellipsoid daB.setEllipsoid( QStringLiteral( "WGS72" ) ); resultB = daB.measureLine( p1, p2 ); - QVERIFY( ! qFuzzyCompare( resultA, resultB ) ); + QVERIFY( !qFuzzyCompare( resultA, resultB ) ); // Test assignment const std::shared_ptr daC( new QgsDistanceArea ); @@ -182,12 +180,12 @@ void TestQgsDistanceArea::test_distances() const QString myFileName = QStringLiteral( TEST_DATA_DIR ) + "/GeodTest-nano.dat"; QFile myFile( myFileName ); - if ( ! myFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) + if ( !myFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { QFAIL( "Couldn't open file" ); return; } - QTextStream in( & myFile ); + QTextStream in( &myFile ); while ( !in.atEnd() ) { QString line = in.readLine(); @@ -207,7 +205,6 @@ void TestQgsDistanceArea::test_distances() QGSCOMPARENEAR( result, myLineList[6].toDouble(), 0.0005 ); } } - } void TestQgsDistanceArea::regression13601() @@ -312,8 +309,7 @@ void TestQgsDistanceArea::measureAreaAndUnits() QgsDebugMsgLevel( QStringLiteral( "measured %1 in %2" ).arg( area ).arg( QgsUnitTypes::toString( units ) ), 1 ); - QVERIFY( ( qgsDoubleNear( area, 3.0, 0.00000001 ) && units == Qgis::AreaUnit::SquareDegrees ) - || ( qgsDoubleNear( area, 37176087091.5, 0.1 ) && units == Qgis::AreaUnit::SquareMeters ) ); + QVERIFY( ( qgsDoubleNear( area, 3.0, 0.00000001 ) && units == Qgis::AreaUnit::SquareDegrees ) || ( qgsDoubleNear( area, 37176087091.5, 0.1 ) && units == Qgis::AreaUnit::SquareMeters ) ); da.setEllipsoid( QStringLiteral( "WGS84" ) ); area = da.measureArea( polygon ); @@ -374,7 +370,7 @@ void TestQgsDistanceArea::emptyPolygon() da.setEllipsoid( QStringLiteral( "WGS84" ) ); //test that measuring an empty polygon doesn't crash - da.measurePolygon( QVector< QgsPointXY >() ); + da.measurePolygon( QVector() ); } void TestQgsDistanceArea::regression14675() @@ -398,7 +394,3 @@ void TestQgsDistanceArea::regression16820() QGSTEST_MAIN( TestQgsDistanceArea ) #include "testqgsdistancearea.moc" - - - - diff --git a/tests/src/core/testqgsdxfexport.cpp b/tests/src/core/testqgsdxfexport.cpp index 70ae8f0a3b0d..eab2d4bf8819 100644 --- a/tests/src/core/testqgsdxfexport.cpp +++ b/tests/src/core/testqgsdxfexport.cpp @@ -50,8 +50,8 @@ class TestQgsDxfExport : public QObject private slots: void initTestCase(); void cleanupTestCase(); - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testPoints(); void testPointsDataDefinedSizeAngle(); void testPointsDataDefinedSizeSymbol(); @@ -147,7 +147,7 @@ void TestQgsDxfExport::init() QgsProject::instance()->addMapLayer( mPointLayerGeometryGenerator ); // Point layer with data-defined size and angle - mPointLayerDataDefinedSizeAngle = new QgsVectorLayer( filename, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + mPointLayerDataDefinedSizeAngle = new QgsVectorLayer( filename, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); mPointLayerDataDefinedSizeAngle->setSubsetString( QStringLiteral( "\"Staff\" = 6" ) ); QVERIFY( mPointLayerDataDefinedSizeAngle ); QgsSimpleMarkerSymbolLayer *markerSymbolLayer = new QgsSimpleMarkerSymbolLayer( Qgis::MarkerShape::Triangle, 10.0, 0 ); @@ -162,7 +162,7 @@ void TestQgsDxfExport::init() QgsProject::instance()->addMapLayer( mPointLayerDataDefinedSizeAngle ); // Point layer with data-defined size and data defined svg symbol - mPointLayerDataDefinedSizeSymbol = new QgsVectorLayer( filename, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + mPointLayerDataDefinedSizeSymbol = new QgsVectorLayer( filename, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( mPointLayerDataDefinedSizeSymbol ); QgsSvgMarkerSymbolLayer *svgSymbolLayer = new QgsSvgMarkerSymbolLayer( QStringLiteral( "symbol.svg" ) ); QgsPropertyCollection ddProperties; @@ -203,7 +203,7 @@ void TestQgsDxfExport::cleanup() void TestQgsDxfExport::testPoints() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -224,7 +224,7 @@ void TestQgsDxfExport::testPoints() QVERIFY( !fileContainsText( file, QStringLiteral( "nan.0" ) ) ); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->featureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -233,7 +233,7 @@ void TestQgsDxfExport::testPoints() void TestQgsDxfExport::testPointsDataDefinedSizeAngle() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayerDataDefinedSizeAngle ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayerDataDefinedSizeAngle ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -259,7 +259,7 @@ void TestQgsDxfExport::testPointsDataDefinedSizeAngle() void TestQgsDxfExport::testPointsDataDefinedSizeSymbol() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayerDataDefinedSizeSymbol, -1, true, -1 ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayerDataDefinedSizeSymbol, -1, true, -1 ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -289,7 +289,7 @@ void TestQgsDxfExport::testPointsDataDefinedSizeSymbol() void TestQgsDxfExport::testPointsOverriddenName() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer, -1, false, -1, QStringLiteral( "My Point Layer" ) ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer, -1, false, -1, QStringLiteral( "My Point Layer" ) ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -311,7 +311,7 @@ void TestQgsDxfExport::testPointsOverriddenName() QVERIFY( !fileContainsText( file, mPointLayer->name() ) ); // "points" // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->featureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -323,7 +323,7 @@ void TestQgsDxfExport::testPointsOverriddenName() void TestQgsDxfExport::testLines() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mLineLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mLineLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -342,7 +342,7 @@ void TestQgsDxfExport::testLines() dxfFile.close(); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mLineLayer->featureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::LineString ); @@ -351,7 +351,7 @@ void TestQgsDxfExport::testLines() void TestQgsDxfExport::testPolygons() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPolygonLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPolygonLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -370,7 +370,7 @@ void TestQgsDxfExport::testPolygons() dxfFile.close(); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 12L ); QCOMPARE( result->wkbType(), Qgis::WkbType::LineString ); @@ -379,12 +379,12 @@ void TestQgsDxfExport::testPolygons() void TestQgsDxfExport::testMultiSurface() { QgsDxfExport d; - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "MultiSurface" ), QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "MultiSurface" ), QString(), QStringLiteral( "memory" ) ); const QgsGeometry g = QgsGeometry::fromWkt( "MultiSurface (Polygon ((0 0, 0 1, 1 1, 0 0)))" ); QgsFeature f; f.setGeometry( g ); vl->dataProvider()->addFeatures( QgsFeatureList() << f ); - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -403,7 +403,7 @@ void TestQgsDxfExport::testMultiSurface() dxfFile.close(); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 1L ); QCOMPARE( result->wkbType(), Qgis::WkbType::LineString ); @@ -414,7 +414,7 @@ void TestQgsDxfExport::testMultiSurface() void TestQgsDxfExport::testMapTheme() { - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "LineString?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "LineString?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); const QgsGeometry g = QgsGeometry::fromWkt( "LineString(2600000 1280000, 2680000 1280000, 2680000 1285000, 2600000 1285000, 2600000 1280000)" ); QgsFeature f; f.setGeometry( g ); @@ -438,7 +438,7 @@ void TestQgsDxfExport::testMapTheme() dynamic_cast( vl->renderer() )->symbol()->setColor( QColor( 255, 0, 0 ) ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); d.setSymbologyExport( Qgis::FeatureSymbologyExport::PerSymbolLayer ); QgsMapSettings mapSettings; @@ -461,8 +461,10 @@ void TestQgsDxfExport::testMapTheme() QString debugInfo; // Verify that the style override worked by checking for green line color QVERIFY2( fileContainsText( file, "CONTINUOUS\n" - " 62\n" - " 3", &debugInfo ), debugInfo.toUtf8().constData() ); + " 62\n" + " 3", + &debugInfo ), + debugInfo.toUtf8().constData() ); } void TestQgsDxfExport::testMtext() @@ -486,7 +488,7 @@ void TestQgsDxfExport::testMtext() layer->setLabelsEnabled( true ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( layer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( layer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -507,31 +509,33 @@ void TestQgsDxfExport::testMtext() QString debugInfo; QVERIFY2( fileContainsText( file, "MTEXT\n" - " 5\n" - "**no check**\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbMText\n" - " 8\n" - "points\n" - "420\n" - "**no check**\n" - " 10\n" - "**no check**\n" - " 20\n" - "**no check**\n" - " 1\n" - "REGEX ^\\\\fQGIS Vera Sans\\|i0\\|b1;\\\\H3\\.\\d+;Biplane\n" - " 50\n" - "0.0\n" - " 41\n" - "**no check**\n" - " 71\n" - " 7\n" - " 7\n" - "STANDARD\n" - " 0", &debugInfo ), debugInfo.toUtf8().constData() ); + " 5\n" + "**no check**\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbMText\n" + " 8\n" + "points\n" + "420\n" + "**no check**\n" + " 10\n" + "**no check**\n" + " 20\n" + "**no check**\n" + " 1\n" + "REGEX ^\\\\fQGIS Vera Sans\\|i0\\|b1;\\\\H3\\.\\d+;Biplane\n" + " 50\n" + "0.0\n" + " 41\n" + "**no check**\n" + " 71\n" + " 7\n" + " 7\n" + "STANDARD\n" + " 0", + &debugInfo ), + debugInfo.toUtf8().constData() ); QgsProject::instance()->removeMapLayer( layer ); @@ -548,8 +552,8 @@ void TestQgsDxfExport::testMtext_data() QVERIFY( pointLayer->isValid() ); QTest::newRow( "MText" ) - << pointLayer - << QStringLiteral( "mtext_dxf" ); + << pointLayer + << QStringLiteral( "mtext_dxf" ); QgsVectorLayer *pointLayerNoSymbols = new QgsVectorLayer( filename, QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointLayerNoSymbols->isValid() ); @@ -557,8 +561,8 @@ void TestQgsDxfExport::testMtext_data() pointLayerNoSymbols->addExpressionField( QStringLiteral( "'A text with spaces'" ), QgsField( QStringLiteral( "Spacestest" ), QMetaType::Type::QString ) ); QTest::newRow( "MText No Symbology" ) - << pointLayerNoSymbols - << QStringLiteral( "mtext_no_symbology_dxf" ); + << pointLayerNoSymbols + << QStringLiteral( "mtext_no_symbology_dxf" ); } void TestQgsDxfExport::testMTextEscapeSpaces() @@ -575,7 +579,7 @@ void TestQgsDxfExport::testMTextEscapeSpaces() mPointLayerNoSymbols->setLabelsEnabled( true ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayerNoSymbols ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayerNoSymbols ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -613,7 +617,7 @@ void TestQgsDxfExport::testMTextEscapeLineBreaks() mPointLayerNoSymbols->setLabelsEnabled( true ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayerNoSymbols ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayerNoSymbols ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -653,7 +657,7 @@ void TestQgsDxfExport::testText() mPointLayer->setLabelsEnabled( true ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -675,35 +679,37 @@ void TestQgsDxfExport::testText() QString debugInfo; QVERIFY2( fileContainsText( file, "TEXT\n" - " 5\n" - "**no check**\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbText\n" - " 8\n" - "points\n" - "420\n" - "**no check**\n" - " 10\n" - "**no check**\n" - " 20\n" - "**no check**\n" - " 40\n" - "**no check**\n" - " 1\n" - "Biplane\n" - " 50\n" - "0.0\n" - " 7\n" - "STANDARD\n" - "100\n" - "AcDbText", &debugInfo ), debugInfo.toUtf8().constData() ); + " 5\n" + "**no check**\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbText\n" + " 8\n" + "points\n" + "420\n" + "**no check**\n" + " 10\n" + "**no check**\n" + " 20\n" + "**no check**\n" + " 40\n" + "**no check**\n" + " 1\n" + "Biplane\n" + " 50\n" + "0.0\n" + " 7\n" + "STANDARD\n" + "100\n" + "AcDbText", + &debugInfo ), + debugInfo.toUtf8().constData() ); } void TestQgsDxfExport::testTextAngle() { - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:2056&field=ori:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Point?crs=epsg:2056&field=ori:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); const QgsGeometry g = QgsGeometry::fromWkt( "Point(2684679.392 1292182.527)" ); const QgsGeometry g2 = QgsGeometry::fromWkt( "Point(2684692.322 1292192.534)" ); QgsFeature f( vl->fields() ); @@ -732,7 +738,7 @@ void TestQgsDxfExport::testTextAngle() vl->setLabelsEnabled( true ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -754,30 +760,32 @@ void TestQgsDxfExport::testTextAngle() QString debugInfo; QVERIFY2( fileContainsText( file, "TEXT\n" - " 5\n" - "**no check**\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbText\n" - " 8\n" - "vl\n" - "420\n" - "**no check**\n" - " 10\n" - "**no check**\n" - " 20\n" - "**no check**\n" - " 40\n" - "**no check**\n" - " 1\n" - "40\n" - " 50\n" - "320.0\n" - " 7\n" - "STANDARD\n" - "100\n" - "AcDbText", &debugInfo ), debugInfo.toUtf8().constData() ); + " 5\n" + "**no check**\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbText\n" + " 8\n" + "vl\n" + "420\n" + "**no check**\n" + " 10\n" + "**no check**\n" + " 20\n" + "**no check**\n" + " 40\n" + "**no check**\n" + " 1\n" + "40\n" + " 50\n" + "320.0\n" + " 7\n" + "STANDARD\n" + "100\n" + "AcDbText", + &debugInfo ), + debugInfo.toUtf8().constData() ); } void TestQgsDxfExport::testTextAlign() @@ -812,7 +820,7 @@ void TestQgsDxfExport::testTextAlign() format.setColor( QColor( 200, 0, 200 ) ); settings.setFormat( format ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:2056&field=text:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Point?crs=epsg:2056&field=text:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); const QgsGeometry g = QgsGeometry::fromWkt( "Point(2684679.392 1292182.527)" ); QgsFeature f( vl->fields() ); f.setGeometry( g ); @@ -831,7 +839,7 @@ void TestQgsDxfExport::testTextAlign() mapSettings.setDestinationCrs( vl->crs() ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); d.setMapSettings( mapSettings ); d.setSymbologyScale( 1000 ); d.setSymbologyExport( Qgis::FeatureSymbologyExport::PerFeature ); @@ -844,38 +852,41 @@ void TestQgsDxfExport::testTextAlign() dxfFile.close(); QString debugInfo; QVERIFY2( fileContainsText( file, QStringLiteral( "TEXT\n" - " 5\n" - "**no check**\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbText\n" - " 8\n" - "vl\n" - "420\n" - "**no check**\n" - " 10\n" - "REGEX ^2684680\\.39\\d*\n" - " 20\n" - "REGEX ^1292183\\.52\\d*\n" - " 11\n" - "REGEX ^2684680\\.39\\d*\n" - " 21\n" - "REGEX ^1292183\\.52\\d*\n" - " 40\n" - "**no check**\n" - " 1\n" - "--- MY TEXT ---\n" - " 50\n" - "0.0\n" - " 72\n" - " %1\n" - " 7\n" - "STANDARD\n" - "100\n" - "AcDbText\n" - " 73\n" - " %2" ).arg( QString::number( static_cast( dxfHali ) ), QString::number( static_cast( dxfVali ) ) ), &debugInfo ), debugInfo.toUtf8().constData() ); + " 5\n" + "**no check**\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbText\n" + " 8\n" + "vl\n" + "420\n" + "**no check**\n" + " 10\n" + "REGEX ^2684680\\.39\\d*\n" + " 20\n" + "REGEX ^1292183\\.52\\d*\n" + " 11\n" + "REGEX ^2684680\\.39\\d*\n" + " 21\n" + "REGEX ^1292183\\.52\\d*\n" + " 40\n" + "**no check**\n" + " 1\n" + "--- MY TEXT ---\n" + " 50\n" + "0.0\n" + " 72\n" + " %1\n" + " 7\n" + "STANDARD\n" + "100\n" + "AcDbText\n" + " 73\n" + " %2" ) + .arg( QString::number( static_cast( dxfHali ) ), QString::number( static_cast( dxfVali ) ) ), + &debugInfo ), + debugInfo.toUtf8().constData() ); } void TestQgsDxfExport::testTextAlign_data() @@ -886,46 +897,46 @@ void TestQgsDxfExport::testTextAlign_data() QTest::addColumn( "vali" ); QTest::newRow( "Align left bottom" ) - << QgsDxfExport::HAlign::HLeft - << QgsDxfExport::VAlign::VBottom - << QStringLiteral( "Left" ) - << QStringLiteral( "Bottom" ); + << QgsDxfExport::HAlign::HLeft + << QgsDxfExport::VAlign::VBottom + << QStringLiteral( "Left" ) + << QStringLiteral( "Bottom" ); QTest::newRow( "Align center bottom" ) - << QgsDxfExport::HAlign::HCenter - << QgsDxfExport::VAlign::VBottom - << QStringLiteral( "Center" ) - << QStringLiteral( "Bottom" ); + << QgsDxfExport::HAlign::HCenter + << QgsDxfExport::VAlign::VBottom + << QStringLiteral( "Center" ) + << QStringLiteral( "Bottom" ); QTest::newRow( "Align right bottom" ) - << QgsDxfExport::HAlign::HRight - << QgsDxfExport::VAlign::VBottom - << QStringLiteral( "Right" ) - << QStringLiteral( "Bottom" ); + << QgsDxfExport::HAlign::HRight + << QgsDxfExport::VAlign::VBottom + << QStringLiteral( "Right" ) + << QStringLiteral( "Bottom" ); QTest::newRow( "Align left top" ) - << QgsDxfExport::HAlign::HLeft - << QgsDxfExport::VAlign::VTop - << QStringLiteral( "Left" ) - << QStringLiteral( "Top" ); + << QgsDxfExport::HAlign::HLeft + << QgsDxfExport::VAlign::VTop + << QStringLiteral( "Left" ) + << QStringLiteral( "Top" ); QTest::newRow( "Align right cap" ) - << QgsDxfExport::HAlign::HRight - << QgsDxfExport::VAlign::VTop - << QStringLiteral( "Right" ) - << QStringLiteral( "Cap" ); + << QgsDxfExport::HAlign::HRight + << QgsDxfExport::VAlign::VTop + << QStringLiteral( "Right" ) + << QStringLiteral( "Cap" ); QTest::newRow( "Align left base" ) - << QgsDxfExport::HAlign::HLeft - << QgsDxfExport::VAlign::VBaseLine - << QStringLiteral( "Left" ) - << QStringLiteral( "Base" ); + << QgsDxfExport::HAlign::HLeft + << QgsDxfExport::VAlign::VBaseLine + << QStringLiteral( "Left" ) + << QStringLiteral( "Base" ); QTest::newRow( "Align center half" ) - << QgsDxfExport::HAlign::HCenter - << QgsDxfExport::VAlign::VMiddle - << QStringLiteral( "Center" ) - << QStringLiteral( "Half" ); + << QgsDxfExport::HAlign::HCenter + << QgsDxfExport::VAlign::VMiddle + << QStringLiteral( "Center" ) + << QStringLiteral( "Half" ); } void TestQgsDxfExport::testTextQuadrant() @@ -953,7 +964,7 @@ void TestQgsDxfExport::testTextQuadrant() format.setColor( QColor( 200, 0, 200 ) ); settings.setFormat( format ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:2056&field=text:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Point?crs=epsg:2056&field=text:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); const QgsGeometry g = QgsGeometry::fromWkt( "Point(2685025.687 1292145.297)" ); QgsFeature f( vl->fields() ); f.setGeometry( g ); @@ -972,7 +983,7 @@ void TestQgsDxfExport::testTextQuadrant() mapSettings.setDestinationCrs( vl->crs() ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); d.setMapSettings( mapSettings ); d.setSymbologyScale( 1000 ); d.setSymbologyExport( Qgis::FeatureSymbologyExport::PerFeature ); @@ -985,38 +996,42 @@ void TestQgsDxfExport::testTextQuadrant() dxfFile.close(); QString debugInfo; QVERIFY2( fileContainsText( file, QStringLiteral( "TEXT\n" - " 5\n" - "**no check**\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbText\n" - " 8\n" - "vl\n" - "420\n" - "**no check**\n" - " 10\n" - "REGEX ^2685025\\.68\\d*\n" - " 20\n" - "REGEX ^1292145\\.29\\d*\n" - " 11\n" - "REGEX ^2685025\\.68\\d*\n" - " 21\n" - "REGEX ^1292145\\.29\\d*\n" - " 40\n" - "**no check**\n" - " 1\n" - "182\n" - " 50\n" - "%1\n" - " 72\n" - " %2\n" - " 7\n" - "STANDARD\n" - "100\n" - "AcDbText\n" - " 73\n" - " %3" ).arg( QString::number( fmod( 360 - angle, 360 ), 'f', 1 ) ).arg( QString::number( static_cast( dxfHali ) ), QString::number( static_cast( dxfVali ) ) ), &debugInfo ), debugInfo.toUtf8().constData() ); + " 5\n" + "**no check**\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbText\n" + " 8\n" + "vl\n" + "420\n" + "**no check**\n" + " 10\n" + "REGEX ^2685025\\.68\\d*\n" + " 20\n" + "REGEX ^1292145\\.29\\d*\n" + " 11\n" + "REGEX ^2685025\\.68\\d*\n" + " 21\n" + "REGEX ^1292145\\.29\\d*\n" + " 40\n" + "**no check**\n" + " 1\n" + "182\n" + " 50\n" + "%1\n" + " 72\n" + " %2\n" + " 7\n" + "STANDARD\n" + "100\n" + "AcDbText\n" + " 73\n" + " %3" ) + .arg( QString::number( fmod( 360 - angle, 360 ), 'f', 1 ) ) + .arg( QString::number( static_cast( dxfHali ) ), QString::number( static_cast( dxfVali ) ) ), + &debugInfo ), + debugInfo.toUtf8().constData() ); } void TestQgsDxfExport::testTextQuadrant_data() @@ -1027,70 +1042,70 @@ void TestQgsDxfExport::testTextQuadrant_data() QTest::addColumn( "angle" ); QTest::newRow( "Above Left, no rotation" ) - << 0 - << QgsDxfExport::HAlign::HRight - << QgsDxfExport::VAlign::VBottom - << 0.0; + << 0 + << QgsDxfExport::HAlign::HRight + << QgsDxfExport::VAlign::VBottom + << 0.0; QTest::newRow( "Above, no rotation" ) - << 1 - << QgsDxfExport::HAlign::HCenter - << QgsDxfExport::VAlign::VBottom - << 0.0; + << 1 + << QgsDxfExport::HAlign::HCenter + << QgsDxfExport::VAlign::VBottom + << 0.0; QTest::newRow( "Above Right, no rotation" ) - << 2 - << QgsDxfExport::HAlign::HLeft - << QgsDxfExport::VAlign::VBottom - << 0.0; + << 2 + << QgsDxfExport::HAlign::HLeft + << QgsDxfExport::VAlign::VBottom + << 0.0; QTest::newRow( "Left, no rotation" ) - << 3 - << QgsDxfExport::HAlign::HRight - << QgsDxfExport::VAlign::VMiddle - << 0.0; + << 3 + << QgsDxfExport::HAlign::HRight + << QgsDxfExport::VAlign::VMiddle + << 0.0; QTest::newRow( "Over, no rotation" ) - << 4 - << QgsDxfExport::HAlign::HCenter - << QgsDxfExport::VAlign::VMiddle - << 0.0; + << 4 + << QgsDxfExport::HAlign::HCenter + << QgsDxfExport::VAlign::VMiddle + << 0.0; QTest::newRow( "Right, no rotation" ) - << 5 - << QgsDxfExport::HAlign::HLeft - << QgsDxfExport::VAlign::VMiddle - << 0.0; + << 5 + << QgsDxfExport::HAlign::HLeft + << QgsDxfExport::VAlign::VMiddle + << 0.0; QTest::newRow( "Below Left, no rotation" ) - << 6 - << QgsDxfExport::HAlign::HRight - << QgsDxfExport::VAlign::VTop - << 0.0; + << 6 + << QgsDxfExport::HAlign::HRight + << QgsDxfExport::VAlign::VTop + << 0.0; QTest::newRow( "Below, no rotation" ) - << 7 - << QgsDxfExport::HAlign::HCenter - << QgsDxfExport::VAlign::VTop - << 0.0; + << 7 + << QgsDxfExport::HAlign::HCenter + << QgsDxfExport::VAlign::VTop + << 0.0; QTest::newRow( "Below Right, no rotation" ) - << 8 - << QgsDxfExport::HAlign::HLeft - << QgsDxfExport::VAlign::VTop - << 0.0; + << 8 + << QgsDxfExport::HAlign::HLeft + << QgsDxfExport::VAlign::VTop + << 0.0; QTest::newRow( "Below, 20°" ) - << 7 - << QgsDxfExport::HAlign::HCenter - << QgsDxfExport::VAlign::VTop - << 20.0; + << 7 + << QgsDxfExport::HAlign::HCenter + << QgsDxfExport::VAlign::VTop + << 20.0; } void TestQgsDxfExport::testGeometryGeneratorExport() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayerGeometryGenerator ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayerGeometryGenerator ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1119,12 +1134,12 @@ void TestQgsDxfExport::testCurveExport() QFETCH( QString, dxfText ); QgsDxfExport d; - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( wktType, QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( wktType, QString(), QStringLiteral( "memory" ) ); const QgsGeometry g = QgsGeometry::fromWkt( wkt ); QgsFeature f; f.setGeometry( g ); vl->dataProvider()->addFeatures( QgsFeatureList() << f ); - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1154,96 +1169,95 @@ void TestQgsDxfExport::testCurveExport_data() // curved segment QTest::newRow( "circular string" ) - << QStringLiteral( "CompoundCurve (CircularString (220236.7836819862422999 150406.56493463439983316, 220237.85162031010258943 150412.10612405074061826, 220242.38532074165414087 150409.6075513684481848))" ) - << QStringLiteral( "CircularString" ) - << QStringLiteral( "SECTION\n" - " 2\n" - "ENTITIES\n" - " 0\n" - "LWPOLYLINE\n" - " 5\n" - "82\n" - " 8\n" - "0\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbPolyline\n" - " 6\n" - "CONTINUOUS\n" - "420\n" - " 0\n" - " 90\n" - " 2\n" - " 70\n" - " 130\n" - " 43\n" - "-1.0\n" - " 10\n" - "220236.7836819862422999\n" - " 20\n" - "150406.56493463439983316\n" - " 42\n" - "-1.37514344818771517\n" - " 10\n" - "220242.38532074165414087\n" - " 20\n" - "150409.6075513684481848\n" - " 0\n" - "ENDSEC" ); + << QStringLiteral( "CompoundCurve (CircularString (220236.7836819862422999 150406.56493463439983316, 220237.85162031010258943 150412.10612405074061826, 220242.38532074165414087 150409.6075513684481848))" ) + << QStringLiteral( "CircularString" ) + << QStringLiteral( "SECTION\n" + " 2\n" + "ENTITIES\n" + " 0\n" + "LWPOLYLINE\n" + " 5\n" + "82\n" + " 8\n" + "0\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbPolyline\n" + " 6\n" + "CONTINUOUS\n" + "420\n" + " 0\n" + " 90\n" + " 2\n" + " 70\n" + " 130\n" + " 43\n" + "-1.0\n" + " 10\n" + "220236.7836819862422999\n" + " 20\n" + "150406.56493463439983316\n" + " 42\n" + "-1.37514344818771517\n" + " 10\n" + "220242.38532074165414087\n" + " 20\n" + "150409.6075513684481848\n" + " 0\n" + "ENDSEC" ); // Contains straight and curved segments QTest::newRow( "mixed curve polygon" ) - << QStringLiteral( "CurvePolygon (CompoundCurve ((-1.58053402239448748 0.39018087855297157, -1.49267872523686473 0.39362618432385876, -1.24806201550387597 0.65719207579672689),CircularString (-1.24806201550387597 0.65719207579672689, -0.63479758828596045 0.49870801033591727, -0.61584840654608097 0.32644272179155898),(-0.61584840654608097 0.32644272179155898, -1.58053402239448748 0.39018087855297157)))" ) - << QStringLiteral( "CurvePolygon" ) - << QStringLiteral( "SECTION\n" - " 2\n" - "ENTITIES\n" - " 0\n" - "LWPOLYLINE\n" - " 5\n" - "82\n" - " 8\n" - "0\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbPolyline\n" - " 6\n" - "CONTINUOUS\n" - "420\n" - " 0\n" - " 90\n" - " 5\n" - " 70\n" - " 131\n" - " 43\n" - "-1.0\n" - " 10\n" - "-1.58053402239448748\n" - " 20\n" - "0.39018087855297157\n" - " 10\n" - "-1.49267872523686473\n" - " 20\n" - "0.39362618432385876\n" - " 10\n" - "-1.24806201550387597\n" - " 20\n" - "0.65719207579672689\n" - " 42\n" - "-0.69027811746778556\n" - " 10\n" - "-0.61584840654608097\n" - " 20\n" - "0.32644272179155898\n" - " 10\n" - "-1.58053402239448748\n" - " 20\n" - "0.39018087855297157\n" - " 0\n" - "ENDSEC" ); - + << QStringLiteral( "CurvePolygon (CompoundCurve ((-1.58053402239448748 0.39018087855297157, -1.49267872523686473 0.39362618432385876, -1.24806201550387597 0.65719207579672689),CircularString (-1.24806201550387597 0.65719207579672689, -0.63479758828596045 0.49870801033591727, -0.61584840654608097 0.32644272179155898),(-0.61584840654608097 0.32644272179155898, -1.58053402239448748 0.39018087855297157)))" ) + << QStringLiteral( "CurvePolygon" ) + << QStringLiteral( "SECTION\n" + " 2\n" + "ENTITIES\n" + " 0\n" + "LWPOLYLINE\n" + " 5\n" + "82\n" + " 8\n" + "0\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbPolyline\n" + " 6\n" + "CONTINUOUS\n" + "420\n" + " 0\n" + " 90\n" + " 5\n" + " 70\n" + " 131\n" + " 43\n" + "-1.0\n" + " 10\n" + "-1.58053402239448748\n" + " 20\n" + "0.39018087855297157\n" + " 10\n" + "-1.49267872523686473\n" + " 20\n" + "0.39362618432385876\n" + " 10\n" + "-1.24806201550387597\n" + " 20\n" + "0.65719207579672689\n" + " 42\n" + "-0.69027811746778556\n" + " 10\n" + "-0.61584840654608097\n" + " 20\n" + "0.32644272179155898\n" + " 10\n" + "-1.58053402239448748\n" + " 20\n" + "0.39018087855297157\n" + " 0\n" + "ENDSEC" ); } void TestQgsDxfExport::testDashedLine() @@ -1257,7 +1271,7 @@ void TestQgsDxfExport::testDashedLine() QgsLineSymbol *symbol = new QgsLineSymbol(); symbol->changeSymbolLayer( 0, symbolLayer.release() ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "CompoundCurve?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "CompoundCurve?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); const QgsGeometry g = QgsGeometry::fromWkt( "CompoundCurve ((2689563.84200000017881393 1283531.23699999996460974, 2689563.42499999981373549 1283537.55499999993480742, 2689563.19900000002235174 1283540.52399999997578561, 2689562.99800000013783574 1283543.42999999993480742, 2689562.66900000022724271 1283548.56000000005587935, 2689562.43399999989196658 1283555.287999999942258))" ); QgsFeature f; f.setGeometry( g ); @@ -1266,7 +1280,7 @@ void TestQgsDxfExport::testDashedLine() vl->setRenderer( renderer ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); d.setSymbologyExport( Qgis::FeatureSymbologyExport::PerSymbolLayer ); QgsMapSettings mapSettings; @@ -1288,83 +1302,84 @@ void TestQgsDxfExport::testDashedLine() QString debugInfo; // Make sure the style definition for the dashed line is there - QVERIFY2( fileContainsText( file, - "LTYPE\n" - " 5\n" - "6c\n" - "100\n" - "AcDbSymbolTableRecord\n" - "100\n" - "AcDbLinetypeTableRecord\n" - " 2\n" - "symbolLayer0\n" - " 70\n" - " 64\n" - " 3\n" - "\n" - " 72\n" - " 65\n" - " 73\n" - " 2\n" - " 40\n" - "REGEX ^0\\.8[0-9]*\n" - " 49\n" - "0.5\n" - " 74\n" - " 0\n" - " 49\n" - "REGEX ^-0\\.3[0-9]*\n" - " 74\n" - " 0", &debugInfo ), debugInfo.toUtf8().constData() ); + QVERIFY2( fileContainsText( file, "LTYPE\n" + " 5\n" + "6c\n" + "100\n" + "AcDbSymbolTableRecord\n" + "100\n" + "AcDbLinetypeTableRecord\n" + " 2\n" + "symbolLayer0\n" + " 70\n" + " 64\n" + " 3\n" + "\n" + " 72\n" + " 65\n" + " 73\n" + " 2\n" + " 40\n" + "REGEX ^0\\.8[0-9]*\n" + " 49\n" + "0.5\n" + " 74\n" + " 0\n" + " 49\n" + "REGEX ^-0\\.3[0-9]*\n" + " 74\n" + " 0", + &debugInfo ), + debugInfo.toUtf8().constData() ); // Make sure that the polyline references the style symbolLayer0 - QVERIFY2( fileContainsText( file, - "LWPOLYLINE\n" - " 5\n" - "83\n" - " 8\n" - "0\n" - "100\n" - "AcDbEntity\n" - "100\n" - "AcDbPolyline\n" - " 6\n" - "symbolLayer0\n" - "420\n" - " 0\n" - " 90\n" - " 6\n" - " 70\n" - " 128\n" - " 43\n" - "0.11\n" - " 10\n" - "REGEX ^2689563.84[0-9]*\n" - " 20\n" - "REGEX ^1283531.23[0-9]*\n" - " 10\n" - "REGEX ^2689563.42[0-9]*\n" - " 20\n" - "REGEX ^1283537.55[0-9]*\n" - " 10\n" - "REGEX ^2689563.19[0-9]*\n" - " 20\n" - "REGEX ^1283540.52[0-9]*\n" - " 10\n" - "REGEX ^2689562.99[0-9]*\n" - " 20\n" - "REGEX ^1283543.42[0-9]*\n" - " 10\n" - "REGEX ^2689562.66[0-9]*\n" - " 20\n" - "REGEX ^1283548.56[0-9]*\n" - " 10\n" - "REGEX ^2689562.43[0-9]*\n" - " 20\n" - "REGEX ^1283555.28[0-9]*\n" - " 0\n" - "ENDSEC" - , &debugInfo ), debugInfo.toUtf8().constData() ); + QVERIFY2( fileContainsText( file, "LWPOLYLINE\n" + " 5\n" + "83\n" + " 8\n" + "0\n" + "100\n" + "AcDbEntity\n" + "100\n" + "AcDbPolyline\n" + " 6\n" + "symbolLayer0\n" + "420\n" + " 0\n" + " 90\n" + " 6\n" + " 70\n" + " 128\n" + " 43\n" + "0.11\n" + " 10\n" + "REGEX ^2689563.84[0-9]*\n" + " 20\n" + "REGEX ^1283531.23[0-9]*\n" + " 10\n" + "REGEX ^2689563.42[0-9]*\n" + " 20\n" + "REGEX ^1283537.55[0-9]*\n" + " 10\n" + "REGEX ^2689563.19[0-9]*\n" + " 20\n" + "REGEX ^1283540.52[0-9]*\n" + " 10\n" + "REGEX ^2689562.99[0-9]*\n" + " 20\n" + "REGEX ^1283543.42[0-9]*\n" + " 10\n" + "REGEX ^2689562.66[0-9]*\n" + " 20\n" + "REGEX ^1283548.56[0-9]*\n" + " 10\n" + "REGEX ^2689562.43[0-9]*\n" + " 20\n" + "REGEX ^1283555.28[0-9]*\n" + " 0\n" + "ENDSEC", + &debugInfo ), + debugInfo.toUtf8().constData() ); } void TestQgsDxfExport::testTransform() @@ -1378,7 +1393,7 @@ void TestQgsDxfExport::testTransform() QgsLineSymbol *symbol = new QgsLineSymbol(); symbol->changeSymbolLayer( 0, symbolLayer.release() ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Linestring?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Linestring?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); QgsGeometry g = QgsGeometry::fromWkt( QStringLiteral( "LineString (2689564.82757076947018504 1283554.68540272791869938, 2689565.52996697928756475 1283531.49185784510336816)" ) ); QgsFeature f; f.setGeometry( g ); @@ -1391,7 +1406,7 @@ void TestQgsDxfExport::testTransform() vl->setRenderer( renderer ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); d.setSymbologyExport( Qgis::FeatureSymbologyExport::PerSymbolLayer ); QgsMapSettings mapSettings; @@ -1409,7 +1424,7 @@ void TestQgsDxfExport::testTransform() QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), QgsDxfExport::ExportResult::Success ); dxfFile.close(); - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, QStringLiteral( "res" ) ); + std::unique_ptr result = std::make_unique( file, QStringLiteral( "res" ) ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 2L ); QgsFeature f2; @@ -1426,7 +1441,7 @@ void TestQgsDxfExport::testTransform() QCOMPARE( d.writeToFile( &dxfFile2, QStringLiteral( "CP1252" ) ), QgsDxfExport::ExportResult::Success ); dxfFile2.close(); - result = std::make_unique< QgsVectorLayer >( file2, QStringLiteral( "res" ) ); + result = std::make_unique( file2, QStringLiteral( "res" ) ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 1L ); it = result->getFeatures(); @@ -1444,7 +1459,7 @@ void TestQgsDxfExport::testDataDefinedPoints() QgsMarkerSymbol *symbol = new QgsMarkerSymbol(); symbol->changeSymbolLayer( 0, symbolLayer.release() ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Point?crs=epsg:2056" ), QString(), QStringLiteral( "memory" ) ); const QgsGeometry g1 = QgsGeometry::fromWkt( "POINT (2000000 1000000)" ); QgsFeature f1; f1.setGeometry( g1 ); @@ -1457,7 +1472,7 @@ void TestQgsDxfExport::testDataDefinedPoints() vl->setRenderer( renderer ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( vl.get() ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( vl.get() ) ); d.setSymbologyExport( Qgis::FeatureSymbologyExport::PerFeature ); QgsMapSettings mapSettings; @@ -1478,36 +1493,37 @@ void TestQgsDxfExport::testDataDefinedPoints() QString debugInfo; - QVERIFY2( fileContainsText( file, - "CONTINUOUS\n" - "420\n" - "2302755\n" - " 90\n" - " 2\n" - " 70\n" - " 1\n" - " 43\n" - "0.0\n" - " 10\n" - "-100.0\n" - " 20\n" - "0.0\n" - " 42\n" - "1.0\n" - " 10\n" - "100.0\n" - " 20\n" - "0.0\n" - " 42\n" - "1.0\n" - " 0\n" - "ENDBLK", &debugInfo ), debugInfo.toUtf8().constData() ); + QVERIFY2( fileContainsText( file, "CONTINUOUS\n" + "420\n" + "2302755\n" + " 90\n" + " 2\n" + " 70\n" + " 1\n" + " 43\n" + "0.0\n" + " 10\n" + "-100.0\n" + " 20\n" + "0.0\n" + " 42\n" + "1.0\n" + " 10\n" + "100.0\n" + " 20\n" + "0.0\n" + " 42\n" + "1.0\n" + " 0\n" + "ENDBLK", + &debugInfo ), + debugInfo.toUtf8().constData() ); } void TestQgsDxfExport::testExtent() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPolygonLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPolygonLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1527,7 +1543,7 @@ void TestQgsDxfExport::testExtent() dxfFile1.close(); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file1, "dxf" ); + std::unique_ptr result = std::make_unique( file1, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 1L ); QCOMPARE( result->wkbType(), Qgis::WkbType::LineString ); @@ -1548,7 +1564,7 @@ void TestQgsDxfExport::testSelectedPoints() QVERIFY( mPointLayer->selectedFeatureCount() > 0 ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1570,7 +1586,7 @@ void TestQgsDxfExport::testSelectedPoints() QVERIFY( !fileContainsText( file, QStringLiteral( "nan.0" ) ) ); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->selectedFeatureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -1586,7 +1602,7 @@ void TestQgsDxfExport::testSelectedPoints() QVERIFY( !fileContainsText( file2, QStringLiteral( "nan.0" ) ) ); // reload and compare - result = std::make_unique< QgsVectorLayer >( file2, "dxf" ); + result = std::make_unique( file2, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->featureCount() ); QVERIFY( mPointLayer->selectedFeatureCount() > 0 ); @@ -1601,7 +1617,7 @@ void TestQgsDxfExport::testSelectedLines() QVERIFY( mLineLayer->selectedFeatureCount() > 0 ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mLineLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mLineLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1621,7 +1637,7 @@ void TestQgsDxfExport::testSelectedLines() dxfFile.close(); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mLineLayer->selectedFeatureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::LineString ); @@ -1635,7 +1651,7 @@ void TestQgsDxfExport::testSelectedLines() dxfFile2.close(); // reload and compare - result = std::make_unique< QgsVectorLayer >( file2, "dxf" ); + result = std::make_unique( file2, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mLineLayer->featureCount() ); QVERIFY( mLineLayer->selectedFeatureCount() > 0 ); @@ -1650,7 +1666,7 @@ void TestQgsDxfExport::testSelectedPolygons() QVERIFY( mPolygonLayer->selectedFeatureCount() > 0 ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPolygonLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPolygonLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1670,7 +1686,7 @@ void TestQgsDxfExport::testSelectedPolygons() dxfFile.close(); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 8L ); QCOMPARE( result->wkbType(), Qgis::WkbType::LineString ); @@ -1684,7 +1700,7 @@ void TestQgsDxfExport::testSelectedPolygons() dxfFile2.close(); // reload and compare - result = std::make_unique< QgsVectorLayer >( file2, "dxf" ); + result = std::make_unique( file2, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 12L ); QVERIFY( mPolygonLayer->selectedFeatureCount() > 0 ); @@ -1701,7 +1717,7 @@ void TestQgsDxfExport::testMultipleLayersWithSelection() QVERIFY( mLineLayer->selectedFeatureCount() > 0 ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) << QgsDxfExport::DxfLayer( mLineLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer ) << QgsDxfExport::DxfLayer( mLineLayer ) ); QgsRectangle extent; extent = mPointLayer->extent(); @@ -1727,20 +1743,12 @@ void TestQgsDxfExport::testMultipleLayersWithSelection() QVERIFY( !fileContainsText( file, QStringLiteral( "nan.0" ) ) ); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QStringList subLayers = result->dataProvider()->subLayers(); QCOMPARE( subLayers.count(), 2 ); - QStringList subLayer1 = { QStringLiteral( "0" ), - QStringLiteral( "entities" ), - QStringLiteral( "8" ), - QStringLiteral( "Point" ) - }; - QStringList subLayer2 = { QStringLiteral( "0" ), - QStringLiteral( "entities" ), - QStringLiteral( "2" ), - QStringLiteral( "LineString" ) - }; + QStringList subLayer1 = { QStringLiteral( "0" ), QStringLiteral( "entities" ), QStringLiteral( "8" ), QStringLiteral( "Point" ) }; + QStringList subLayer2 = { QStringLiteral( "0" ), QStringLiteral( "entities" ), QStringLiteral( "2" ), QStringLiteral( "LineString" ) }; QVERIFY( subLayers.constFirst().startsWith( subLayer1.join( QgsDataProvider::sublayerSeparator() ) ) ); QVERIFY( subLayers.constLast().startsWith( subLayer2.join( QgsDataProvider::sublayerSeparator() ) ) ); @@ -1753,20 +1761,12 @@ void TestQgsDxfExport::testMultipleLayersWithSelection() dxfFile2.close(); // reload and compare - result = std::make_unique< QgsVectorLayer >( file2, "dxf" ); + result = std::make_unique( file2, "dxf" ); QVERIFY( result->isValid() ); subLayers = result->dataProvider()->subLayers(); QCOMPARE( subLayers.count(), 2 ); - subLayer1 = QStringList{ QStringLiteral( "0" ), - QStringLiteral( "entities" ), - QStringLiteral( "%1" ).arg( mPointLayer->featureCount() ), - QStringLiteral( "Point" ) - }; - subLayer2 = QStringList{ QStringLiteral( "0" ), - QStringLiteral( "entities" ), - QStringLiteral( "%1" ).arg( mLineLayer->featureCount() ), - QStringLiteral( "LineString" ) - }; + subLayer1 = QStringList { QStringLiteral( "0" ), QStringLiteral( "entities" ), QStringLiteral( "%1" ).arg( mPointLayer->featureCount() ), QStringLiteral( "Point" ) }; + subLayer2 = QStringList { QStringLiteral( "0" ), QStringLiteral( "entities" ), QStringLiteral( "%1" ).arg( mLineLayer->featureCount() ), QStringLiteral( "LineString" ) }; QVERIFY( subLayers.constFirst().startsWith( subLayer1.join( QgsDataProvider::sublayerSeparator() ) ) ); QVERIFY( subLayers.constLast().startsWith( subLayer2.join( QgsDataProvider::sublayerSeparator() ) ) ); QVERIFY( mPointLayer->selectedFeatureCount() > 0 ); @@ -1782,7 +1782,7 @@ void TestQgsDxfExport::testExtentWithSelection() QVERIFY( mPointLayer->selectedFeatureCount() > 0 ); QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1803,7 +1803,7 @@ void TestQgsDxfExport::testExtentWithSelection() dxfFile.close(); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), 3L ); // 4 in extent, 8 selected, 17 in total QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -1824,11 +1824,9 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() // A) All layer name options are set QgsDxfExport d; mPointLayer->serverProperties()->setTitle( layerTitle ); - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer, - 0, // Class attribute, 3 unique values - false, - -1, - layerOverriddenName ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer, + 0, // Class attribute, 3 unique values + false, -1, layerOverriddenName ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -1853,7 +1851,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() QVERIFY( !fileContainsText( file, mPointLayer->name() ) ); // reload and compare - std::unique_ptr< QgsVectorLayer > result = std::make_unique< QgsVectorLayer >( file, "dxf" ); + std::unique_ptr result = std::make_unique( file, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->featureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -1864,7 +1862,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() QVERIFY( values.contains( QVariant( "Biplane" ) ) ); // B) No attribute given - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer, -1, false, -1, layerOverriddenName ) ); // this replaces layers + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer, -1, false, -1, layerOverriddenName ) ); // this replaces layers const QString file2 = getTempFileName( "name_precedence_b_no_attr_dxf" ); QFile dxfFile2( file2 ); @@ -1877,7 +1875,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() QVERIFY( !fileContainsText( file2, mPointLayer->name() ) ); // reload and compare - result = std::make_unique< QgsVectorLayer >( file2, "dxf" ); + result = std::make_unique( file2, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->featureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -1887,7 +1885,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() QCOMPARE( result->uniqueValues( 0 ).count(), 1 ); // "Layer" field // C) No attribute given, no override - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer, -1, false, -1 ) ); // this replaces layers + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer, -1, false, -1 ) ); // this replaces layers const QString file3 = getTempFileName( "name_precedence_c_no_attr_no_override_dxf" ); QFile dxfFile3( file3 ); @@ -1900,7 +1898,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() QVERIFY( !fileContainsText( file3, mPointLayer->name() ) ); // reload and compare - result = std::make_unique< QgsVectorLayer >( file3, "dxf" ); + result = std::make_unique( file3, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->featureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -1909,7 +1907,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() QCOMPARE( result->uniqueValues( 0 ).count(), 1 ); // "Layer" field // D) No name options given, use default layer name - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mPointLayer ) ); // This replaces layers + d.addLayers( QList() << QgsDxfExport::DxfLayer( mPointLayer ) ); // This replaces layers d.setLayerTitleAsName( false ); const QString file4 = getTempFileName( "name_precedence_d_no_anything_dxf" ); @@ -1923,7 +1921,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() QVERIFY( fileContainsText( file4, mPointLayer->name() ) ); // reload and compare - result = std::make_unique< QgsVectorLayer >( file4, "dxf" ); + result = std::make_unique( file4, "dxf" ); QVERIFY( result->isValid() ); QCOMPARE( result->featureCount(), mPointLayer->featureCount() ); QCOMPARE( result->wkbType(), Qgis::WkbType::Point ); @@ -1937,7 +1935,7 @@ void TestQgsDxfExport::testOutputLayerNamePrecedence() void TestQgsDxfExport::testMinimumLineWidthExport() { QgsDxfExport d; - d.addLayers( QList< QgsDxfExport::DxfLayer >() << QgsDxfExport::DxfLayer( mLineLayer ) ); + d.addLayers( QList() << QgsDxfExport::DxfLayer( mLineLayer ) ); QgsMapSettings mapSettings; const QSize size( 640, 480 ); @@ -2012,8 +2010,7 @@ bool TestQgsDxfExport::fileContainsText( const QString &path, const QString &tex } if ( found ) return true; - } - while ( !line.isNull() ); + } while ( !line.isNull() ); if ( debugInfo ) { while ( debugLines.size() > 10 ) diff --git a/tests/src/core/testqgselevationmap.cpp b/tests/src/core/testqgselevationmap.cpp index c5d72749db05..96354261576d 100644 --- a/tests/src/core/testqgselevationmap.cpp +++ b/tests/src/core/testqgselevationmap.cpp @@ -26,14 +26,14 @@ class TestQgsElevationMap : public QgsTest Q_OBJECT public: - TestQgsElevationMap() : QgsTest( QStringLiteral( "Elevation Map Tests" ), QStringLiteral( "elevation_map" ) ) {} + TestQgsElevationMap() + : QgsTest( QStringLiteral( "Elevation Map Tests" ), QStringLiteral( "elevation_map" ) ) {} private slots: void initTestCase(); void cleanupTestCase(); void testRasterDemEdl(); void testRasterDemReprojected(); - }; @@ -45,7 +45,6 @@ void TestQgsElevationMap::initTestCase() // init QGIS's paths - true means that all path will be inited from prefix QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsElevationMap::cleanupTestCase() @@ -56,7 +55,6 @@ void TestQgsElevationMap::cleanupTestCase() void TestQgsElevationMap::testRasterDemEdl() { - QString testDataDir = QStringLiteral( TEST_DATA_DIR ); //defined in CmakeLists.txt QgsRasterLayer r( testDataDir + "/analysis/dem.tif" ); QVERIFY( r.isValid() ); diff --git a/tests/src/core/testqgsellipsemarker.cpp b/tests/src/core/testqgsellipsemarker.cpp index 586e7a92ef5d..22c99b613154 100644 --- a/tests/src/core/testqgsellipsemarker.cpp +++ b/tests/src/core/testqgsellipsemarker.cpp @@ -42,13 +42,14 @@ class TestQgsEllipseMarkerSymbol : public QgsTest Q_OBJECT public: - TestQgsEllipseMarkerSymbol() : QgsTest( QStringLiteral( "Ellipse Marker Tests" ), QStringLiteral( "symbol_ellipsemarker" ) ) {} + TestQgsEllipseMarkerSymbol() + : QgsTest( QStringLiteral( "Ellipse Marker Tests" ), QStringLiteral( "symbol_ellipsemarker" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void ellipseMarkerSymbol(); @@ -72,7 +73,7 @@ class TestQgsEllipseMarkerSymbol : public QgsTest void dataDefinedOpacity(); private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings mMapSettings; QgsVectorLayer *mpPointsLayer = nullptr; @@ -100,8 +101,7 @@ void TestQgsEllipseMarkerSymbol::initTestCase() // const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); //setup symbol mEllipseMarkerLayer = new QgsEllipseSymbolLayer(); @@ -115,7 +115,6 @@ void TestQgsEllipseMarkerSymbol::initTestCase() // and is more light weight // mMapSettings.setLayers( QList() << mpPointsLayer ); - } void TestQgsEllipseMarkerSymbol::cleanupTestCase() { diff --git a/tests/src/core/testqgsexpression.cpp b/tests/src/core/testqgsexpression.cpp index d411bc3dad5b..5909fb788d83 100644 --- a/tests/src/core/testqgsexpression.cpp +++ b/tests/src/core/testqgsexpression.cpp @@ -55,8 +55,8 @@ class RunLambdaInThread : public QThread { Q_OBJECT - public : - RunLambdaInThread( const std::function< void() > &function ) + public: + RunLambdaInThread( const std::function &function ) : mFunction( function ) {} @@ -67,21 +67,17 @@ class RunLambdaInThread : public QThread } private: - std::function< void() > mFunction; - - + std::function mFunction; }; -class TestQgsExpression: public QObject +class TestQgsExpression : public QObject { Q_OBJECT public: - TestQgsExpression() = default; private: - QgsVectorLayer *mPointsLayer = nullptr; QgsVectorLayer *mPointsLayerMetadata = nullptr; QgsVectorLayer *mMemoryLayer = nullptr; @@ -110,8 +106,7 @@ class TestQgsExpression: public QObject QString testDataDir = QStringLiteral( TEST_DATA_DIR ) + '/'; QString pointsFileName = testDataDir + "points.shp"; QFileInfo pointFileInfo( pointsFileName ); - mPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( mPointsLayer ); mPointsLayer->serverProperties()->setTitle( QStringLiteral( "layer title" ) ); mPointsLayer->serverProperties()->setAbstract( QStringLiteral( "layer abstract" ) ); @@ -124,8 +119,7 @@ class TestQgsExpression: public QObject mPointsLayer->setMapTipTemplate( QStringLiteral( "Maptip with class = [% \"Class\" %]" ) ); mPointsLayer->setDisplayExpression( QStringLiteral( "'Display expression with class = ' || \"Class\"" ) ); - mPointsLayerMetadata = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName() + "_metadata", QStringLiteral( "ogr" ) ); + mPointsLayerMetadata = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName() + "_metadata", QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( mPointsLayerMetadata ); QgsLayerMetadata metadata; metadata.setTitle( QStringLiteral( "metadata title" ) ); @@ -145,14 +139,12 @@ class TestQgsExpression: public QObject QString rasterFileName = testDataDir + "tenbytenraster.asc"; QFileInfo rasterFileInfo( rasterFileName ); - mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsProject::instance()->addMapLayer( mRasterLayer ); QString rasterWithAttributeTableFileName = testDataDir + "/raster/band1_byte_attribute_table_epsg4326.tif"; QFileInfo rasterWithAttributeTableFileInfo( rasterWithAttributeTableFileName ); - mRasterLayerWithAttributeTable = new QgsRasterLayer( rasterWithAttributeTableFileInfo.filePath(), - rasterWithAttributeTableFileInfo.completeBaseName() ); + mRasterLayerWithAttributeTable = new QgsRasterLayer( rasterWithAttributeTableFileInfo.filePath(), rasterWithAttributeTableFileInfo.completeBaseName() ); Q_ASSERT( mRasterLayerWithAttributeTable->isValid() ); QgsProject::instance()->addMapLayer( mRasterLayerWithAttributeTable ); @@ -187,9 +179,9 @@ class TestQgsExpression: public QObject // test layer for aggregates mAggregatesLayer = new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer" - "&field=col2:string" - "&field=col3:integer" - "&field=col4:string" ), + "&field=col2:string" + "&field=col3:integer" + "&field=col4:string" ), QStringLiteral( "aggregate_layer" ), QStringLiteral( "memory" ) ); QVERIFY( mAggregatesLayer->isValid() ); QgsFeature af1( mAggregatesLayer->dataProvider()->fields(), 1 ); @@ -238,8 +230,8 @@ class TestQgsExpression: public QObject QgsProject::instance()->addMapLayer( mAggregatesLayer ); mChildLayer = new QgsVectorLayer( QStringLiteral( "Point?field=parent:integer" - "&field=col2:string" - "&field=col3:integer" ), + "&field=col2:string" + "&field=col3:integer" ), QStringLiteral( "child_layer" ), QStringLiteral( "memory" ) ); QVERIFY( mChildLayer->isValid() ); QgsFeature cf1( mChildLayer->dataProvider()->fields(), 1 ); @@ -275,8 +267,8 @@ class TestQgsExpression: public QObject QgsProject::instance()->relationManager()->addRelation( rel ); mChildLayer2 = new QgsVectorLayer( QStringLiteral( "Point?field=name:string" - "&field=year:integer" - "&field=my_value:integer" ), + "&field=year:integer" + "&field=my_value:integer" ), QStringLiteral( "child_layer_2" ), QStringLiteral( "memory" ) ); QVERIFY( mChildLayer2->isValid() ); QgsFeature afc1( mChildLayer2->dataProvider()->fields(), 1 ); @@ -568,7 +560,6 @@ class TestQgsExpression: public QObject void represent_attributes() { - QgsVectorLayer layer { QStringLiteral( "Point?field=col1:integer&field=col2:string" ), QStringLiteral( "test_represent_attributes" ), QStringLiteral( "memory" ) }; QVERIFY( layer.isValid() ); QgsFeature f1( layer.dataProvider()->fields(), 1 ); @@ -626,7 +617,7 @@ class TestQgsExpression: public QObject QCOMPARE( result.value( QStringLiteral( "col2" ) ).toString(), QStringLiteral( "test2" ) ); // Test the cached value - QCOMPARE( context3.cachedValue( QStringLiteral( "repvalfcnval:%1:%2:%3" ).arg( layer.id(), QStringLiteral( "col1" ), QStringLiteral( "2" ) ) ).toString(), QStringLiteral( "two" ) ); + QCOMPARE( context3.cachedValue( QStringLiteral( "repvalfcnval:%1:%2:%3" ).arg( layer.id(), QStringLiteral( "col1" ), QStringLiteral( "2" ) ) ).toString(), QStringLiteral( "two" ) ); // Test errors QgsProject::instance()->removeMapLayer( layer.id() ); @@ -634,7 +625,6 @@ class TestQgsExpression: public QObject QgsExpressionContext context4; result = expression.evaluate( &context4 ).toMap(); QVERIFY( expression.hasEvalError() ); - }; void represent_value() @@ -1099,36 +1089,34 @@ class TestQgsExpression: public QObject QTest::newRow( "nodes_to_points point" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('POINT(1 2)')))" << false << QVariant( QStringLiteral( "MultiPoint ((1 2))" ) ); QTest::newRow( "nodes_to_points polygon" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))')))" << false << QVariant( QStringLiteral( "MultiPoint ((-1 -1),(4 0),(4 2),(0 2),(-1 -1))" ) ); QTest::newRow( "nodes_to_points polygon with rings" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1),(-0.3 -0.9, -0.3 0, 4 -0.1, 0.1 2.1, -0.3 -0.9))')))" << false - << QVariant( QStringLiteral( "MultiPoint ((-1 -1),(4 0),(4 2),(0 2),(-1 -1),(-0.1 -0.1),(0.4 0),(0.4 0.2),(0 0.2),(-0.1 -0.1),(-0.3 -0.9),(-0.3 0),(4 -0.1),(0.1 2.1),(-0.3 -0.9))" ) ); + << QVariant( QStringLiteral( "MultiPoint ((-1 -1),(4 0),(4 2),(0 2),(-1 -1),(-0.1 -0.1),(0.4 0),(0.4 0.2),(0 0.2),(-0.1 -0.1),(-0.3 -0.9),(-0.3 0),(4 -0.1),(0.1 2.1),(-0.3 -0.9))" ) ); QTest::newRow( "nodes_to_points line" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)')))" << false << QVariant( QStringLiteral( "MultiPoint ((0 0),(1 1),(2 2))" ) ); QTest::newRow( "nodes_to_points collection 1" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))')))" << false - << QVariant( QStringLiteral( "MultiPoint ((0 1),(0 0),(1 0),(1 1))" ) ); + << QVariant( QStringLiteral( "MultiPoint ((0 1),(0 0),(1 0),(1 1))" ) ); QTest::newRow( "nodes_to_points collection 2" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('GEOMETRYCOLLECTION(POINTZM(0 1 2 3), POINTZM(0 0 3 4), POINTZM(1 1 5 6), POLYGONZM((-1 -1 7 8, 4 0 1 2, 4 2 7 6, 0 2 1 3, -1 -1 7 8),(-0.1 -0.1 5 4, 0.4 0 9 8, 0.4 0.2 7 10, 0 0.2 0 0, -0.1 -0.1 5 4),(-1 -1 0 0, 4 0 0 1, 4 2 1 2, 0 2 2 3, -1 -1 0 0)), POINTZM(1 0 1 2))')))" << false - << QVariant( QStringLiteral( "MultiPoint ZM ((0 1 2 3),(0 0 3 4),(1 1 5 6),(-1 -1 7 8),(4 0 1 2),(4 2 7 6),(0 2 1 3),(-1 -1 7 8),(-0.1 -0.1 5 4),(0.4 0 9 8),(0.4 0.2 7 10),(0 0.2 0 0),(-0.1 -0.1 5 4),(-1 -1 0 0),(4 0 0 1),(4 2 1 2),(0 2 2 3),(-1 -1 0 0),(1 0 1 2))" ) ); - QTest::newRow( "nodes_to_points empty collection" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('GEOMETRYCOLLECTION()')))" << false << - QVariant( QStringLiteral( "MultiPoint EMPTY" ) ); + << QVariant( QStringLiteral( "MultiPoint ZM ((0 1 2 3),(0 0 3 4),(1 1 5 6),(-1 -1 7 8),(4 0 1 2),(4 2 7 6),(0 2 1 3),(-1 -1 7 8),(-0.1 -0.1 5 4),(0.4 0 9 8),(0.4 0.2 7 10),(0 0.2 0 0),(-0.1 -0.1 5 4),(-1 -1 0 0),(4 0 0 1),(4 2 1 2),(0 2 2 3),(-1 -1 0 0),(1 0 1 2))" ) ); + QTest::newRow( "nodes_to_points empty collection" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('GEOMETRYCOLLECTION()')))" << false << QVariant( QStringLiteral( "MultiPoint EMPTY" ) ); QTest::newRow( "nodes_to_points no close polygon" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))'),true))" << false << QVariant( QStringLiteral( "MultiPoint ((-1 -1),(4 0),(4 2),(0 2))" ) ); QTest::newRow( "nodes_to_points no close polygon with rings" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1),(-0.3 -0.9, -0.3 0, 4 -0.1, 0.1 2.1, -0.3 -0.9))'),true))" << false - << QVariant( QStringLiteral( "MultiPoint ((-1 -1),(4 0),(4 2),(0 2),(-0.1 -0.1),(0.4 0),(0.4 0.2),(0 0.2),(-0.3 -0.9),(-0.3 0),(4 -0.1),(0.1 2.1))" ) ); + << QVariant( QStringLiteral( "MultiPoint ((-1 -1),(4 0),(4 2),(0 2),(-0.1 -0.1),(0.4 0),(0.4 0.2),(0 0.2),(-0.3 -0.9),(-0.3 0),(4 -0.1),(0.1 2.1))" ) ); QTest::newRow( "nodes_to_points no close unclosed line" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)'),true))" << false - << QVariant( QStringLiteral( "MultiPoint ((0 0),(1 1),(2 2))" ) ); + << QVariant( QStringLiteral( "MultiPoint ((0 0),(1 1),(2 2))" ) ); QTest::newRow( "nodes_to_points no close closed line" ) << "geom_to_wkt(nodes_to_points(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2, 0 0)'),true))" << false - << QVariant( QStringLiteral( "MultiPoint ((0 0),(1 1),(2 2))" ) ); + << QVariant( QStringLiteral( "MultiPoint ((0 0),(1 1),(2 2))" ) ); QTest::newRow( "segments_to_lines not geom" ) << "segments_to_lines('g')" << true << QVariant(); QTest::newRow( "segments_to_lines null" ) << "segments_to_lines(NULL)" << false << QVariant(); QTest::newRow( "segments_to_lines point" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('POINT(1 2)')))" << false << QVariant( QStringLiteral( "MultiLineString EMPTY" ) ); QTest::newRow( "segments_to_lines polygon" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))')))" << false << QVariant( QStringLiteral( "MultiLineString ((-1 -1, 4 0),(4 0, 4 2),(4 2, 0 2),(0 2, -1 -1))" ) ); QTest::newRow( "segments_to_lines polygon with rings" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1),(-0.3 -0.9, -0.3 0, 4 -0.1, 0.1 2.1, -0.3 -0.9))')))" << false - << QVariant( QStringLiteral( "MultiLineString ((-1 -1, 4 0),(4 0, 4 2),(4 2, 0 2),(0 2, -1 -1),(-0.1 -0.1, 0.4 0),(0.4 0, 0.4 0.2),(0.4 0.2, 0 0.2),(0 0.2, -0.1 -0.1),(-0.3 -0.9, -0.3 0),(-0.3 0, 4 -0.1),(4 -0.1, 0.1 2.1),(0.1 2.1, -0.3 -0.9))" ) ); + << QVariant( QStringLiteral( "MultiLineString ((-1 -1, 4 0),(4 0, 4 2),(4 2, 0 2),(0 2, -1 -1),(-0.1 -0.1, 0.4 0),(0.4 0, 0.4 0.2),(0.4 0.2, 0 0.2),(0 0.2, -0.1 -0.1),(-0.3 -0.9, -0.3 0),(-0.3 0, 4 -0.1),(4 -0.1, 0.1 2.1),(0.1 2.1, -0.3 -0.9))" ) ); QTest::newRow( "segments_to_lines line" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)')))" << false - << QVariant( QStringLiteral( "MultiLineString ((0 0, 1 1),(1 1, 2 2))" ) ); + << QVariant( QStringLiteral( "MultiLineString ((0 0, 1 1),(1 1, 2 2))" ) ); QTest::newRow( "segments_to_lines collection 1" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))')))" << false - << QVariant( QStringLiteral( "MultiLineString EMPTY" ) ); + << QVariant( QStringLiteral( "MultiLineString EMPTY" ) ); QTest::newRow( "segments_to_lines collection 2" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('GEOMETRYCOLLECTION(POINTZM(0 1 2 3), LINESTRINGZM(0 0 1 2, 1 1 3 4, 2 2 5 6), POINTZM(1 1 5 6), POLYGONZM((-1 -1 7 8, 4 0 1 2, 4 2 7 6, 0 2 1 3, -1 -1 7 8)), POINTZM(1 0 1 2))')))" << false - << QVariant( QStringLiteral( "MultiLineString ZM ((0 0 1 2, 1 1 3 4),(1 1 3 4, 2 2 5 6),(-1 -1 7 8, 4 0 1 2),(4 0 1 2, 4 2 7 6),(4 2 7 6, 0 2 1 3),(0 2 1 3, -1 -1 7 8))" ) ); - QTest::newRow( "segments_to_lines empty collection" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('GEOMETRYCOLLECTION()')))" << false << - QVariant( QStringLiteral( "MultiLineString EMPTY" ) ); + << QVariant( QStringLiteral( "MultiLineString ZM ((0 0 1 2, 1 1 3 4),(1 1 3 4, 2 2 5 6),(-1 -1 7 8, 4 0 1 2),(4 0 1 2, 4 2 7 6),(4 2 7 6, 0 2 1 3),(0 2 1 3, -1 -1 7 8))" ) ); + QTest::newRow( "segments_to_lines empty collection" ) << "geom_to_wkt(segments_to_lines(geom_from_wkt('GEOMETRYCOLLECTION()')))" << false << QVariant( QStringLiteral( "MultiLineString EMPTY" ) ); QTest::newRow( "length line" ) << "length(geom_from_wkt('LINESTRING(0 0, 4 0)'))" << false << QVariant( 4.0 ); QTest::newRow( "length polygon" ) << "length(geom_from_wkt('POLYGON((0 0, 4 0, 4 2, 0 2, 0 0))'))" << false << QVariant(); QTest::newRow( "length point" ) << "length(geom_from_wkt('POINT(0 0)'))" << false << QVariant(); @@ -1158,11 +1146,11 @@ class TestQgsExpression: public QObject QTest::newRow( "interior_ring_n point" ) << "interior_ring_n(geom_from_wkt('POINT(1 2)'), 1)" << false << QVariant(); QTest::newRow( "interior_ring_n polygon no rings" ) << "interior_ring_n(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))'),1)" << false << QVariant(); QTest::newRow( "interior_ring_n polygon with rings" ) << "geom_to_wkt(interior_ring_n(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1),(-1 -1, 4 0, 4 2, 0 2, -1 -1))'),1))" << false - << QVariant( QStringLiteral( "LineString (-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1)" ) ); + << QVariant( QStringLiteral( "LineString (-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1)" ) ); QTest::newRow( "interior_ring_n polygon with rings bad index 1" ) << "interior_ring_n(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1),(-1 -1, 4 0, 4 2, 0 2, -1 -1))'),0)" << false - << QVariant(); + << QVariant(); QTest::newRow( "interior_ring_n polygon with rings bad index 2" ) << "interior_ring_n(geom_from_wkt('POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1),(-0.1 -0.1, 0.4 0, 0.4 0.2, 0 0.2, -0.1 -0.1),(-1 -1, 4 0, 4 2, 0 2, -1 -1))'),3)" << false - << QVariant(); + << QVariant(); QTest::newRow( "interior_ring_n line" ) << "interior_ring_n(geom_from_wkt('LINESTRING(0 0, 1 1, 2 2)'), 1)" << false << QVariant(); QTest::newRow( "interior_ring_n collection" ) << "interior_ring_n(geom_from_wkt('GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))'),1)" << false << QVariant(); QTest::newRow( "geometry_n not geom" ) << "geometry_n('g', 1)" << true << QVariant(); @@ -1375,12 +1363,12 @@ class TestQgsExpression: public QObject QTest::newRow( "make_rectangle_3points (distance default)" ) << "geom_to_wkt(make_rectangle_3points(make_point(0, 0), make_point(0,5), make_point(5, 5)))" << false << QVariant( "Polygon ((0 0, 0 5, 5 5, 5 0, 0 0))" ); QTest::newRow( "make_rectangle_3points (distance)" ) << "geom_to_wkt(make_rectangle_3points(make_point(0, 0), make_point(0,5), make_point(5, 5), 0))" << false << QVariant( "Polygon ((0 0, 0 5, 5 5, 5 0, 0 0))" ); QTest::newRow( "make_rectangle_3points (projected)" ) << "geom_to_wkt(make_rectangle_3points(make_point(0, 0), make_point(0,5), make_point(5, 3), 1))" << false << QVariant( "Polygon ((0 0, 0 5, 5 5, 5 0, 0 0))" ); -#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<10 +#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 10 QTest::newRow( "make_valid_extravert" ) << "geom_to_wkt(make_valid(geom_from_wkt('POLYGON((3 2, 4 1, 5 8, 3 2, 4 2))')))" << false << QVariant( "GeometryCollection (Polygon ((5 8, 4 1, 3 2, 5 8)),LineString (3 2, 4 2))" ); #else QTest::newRow( "make_valid_extravert" ) << "geom_to_wkt(make_valid(geom_from_wkt('POLYGON((3 2, 4 1, 5 8, 3 2, 4 2))')))" << false << QVariant( "Polygon ((3 2, 5 8, 4 1, 3 2))" ); #endif -#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<10 +#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 10 QTest::newRow( "make_valid_missingEnd" ) << "geom_to_wkt(make_valid(geom_from_wkt('POLYGON((3 2, 4 1, 5 8))')))" << false << QVariant( "Polygon ((3 2, 4 1, 5 8, 3 2))" ); #else QTest::newRow( "make_valid_missingEnd" ) << "geom_to_wkt(make_valid(geom_from_wkt('POLYGON((3 2, 4 1, 5 8))')))" << false << QVariant( "Polygon ((3 2, 5 8, 4 1, 3 2))" ); @@ -1593,26 +1581,26 @@ class TestQgsExpression: public QObject QTest::newRow( "z_max no 3D" ) << "z_max(geom_from_wkt('POINT (0 0)'))" << false << QVariant(); QTest::newRow( "z_max NULL" ) << "z_max(geom_from_wkt(NULL))" << false << QVariant(); QTest::newRow( "z_max point" ) << "z_max(geom_from_wkt('POINT (0 0 1)'))" << false << QVariant( 1.0 ); - QTest::newRow( "z_max point Z NaN" ) << "z_max(geom_from_wkt('PointZ (1 1 nan)'))" << false << QVariant( ); - QTest::newRow( "z_max line Z NaN" ) << "z_max(make_line(geom_from_wkt('PointZ (0 0 nan)'),make_point(-1,-1,-2)))" << false << QVariant( ); + QTest::newRow( "z_max point Z NaN" ) << "z_max(geom_from_wkt('PointZ (1 1 nan)'))" << false << QVariant(); + QTest::newRow( "z_max line Z NaN" ) << "z_max(make_line(geom_from_wkt('PointZ (0 0 nan)'),make_point(-1,-1,-2)))" << false << QVariant(); QTest::newRow( "z_max line" ) << "z_max(make_line(make_point(0,0,0),make_point(-1,-1,-2)))" << false << QVariant( 0.0 ); QTest::newRow( "z_min no 3D" ) << "z_min(geom_from_wkt('POINT (0 0)'))" << false << QVariant(); QTest::newRow( "z_min NULL" ) << "z_min(geom_from_wkt(NULL))" << false << QVariant(); QTest::newRow( "z_min point" ) << "z_min(geom_from_wkt('POINT (0 0 1)'))" << false << QVariant( 1.0 ); - QTest::newRow( "z_min point Z NaN" ) << "z_min(geom_from_wkt('PointZ (1 1 nan)'))" << false << QVariant( ); - QTest::newRow( "z_min line Z NaN" ) << "z_min(make_line(geom_from_wkt('PointZ (0 0 nan)'),make_point(-1,-1,-2)))" << false << QVariant( ); + QTest::newRow( "z_min point Z NaN" ) << "z_min(geom_from_wkt('PointZ (1 1 nan)'))" << false << QVariant(); + QTest::newRow( "z_min line Z NaN" ) << "z_min(make_line(geom_from_wkt('PointZ (0 0 nan)'),make_point(-1,-1,-2)))" << false << QVariant(); QTest::newRow( "z_min line" ) << "z_min(make_line(make_point(0,0,0),make_point(-1,-1,-2)))" << false << QVariant( -2.0 ); QTest::newRow( "m_max no measure" ) << "m_max(geom_from_wkt('POINT (0 0)'))" << false << QVariant(); QTest::newRow( "m_max NULL" ) << "m_max(geom_from_wkt(NULL))" << false << QVariant(); QTest::newRow( "m_max point" ) << "m_max(make_point_m(0,0,1))" << false << QVariant( 1.0 ); - QTest::newRow( "m_max point M NaN" ) << "m_max(geom_from_wkt('PointZM (0 0 0 nan)'))" << false << QVariant( ); - QTest::newRow( "m_max line M NaN" ) << "m_max(make_line(geom_from_wkt('PointZM (0 0 0 nan)'),geom_from_wkt('PointZM (1 1 1 2)')))" << false << QVariant( ); + QTest::newRow( "m_max point M NaN" ) << "m_max(geom_from_wkt('PointZM (0 0 0 nan)'))" << false << QVariant(); + QTest::newRow( "m_max line M NaN" ) << "m_max(make_line(geom_from_wkt('PointZM (0 0 0 nan)'),geom_from_wkt('PointZM (1 1 1 2)')))" << false << QVariant(); QTest::newRow( "m_max line" ) << "m_max(make_line(make_point_m(0,0,1),make_point_m(-1,-1,2),make_point_m(-2,-2,0)))" << false << QVariant( 2.0 ); QTest::newRow( "m_min no measure" ) << "m_min(geom_from_wkt('POINT (0 0)'))" << false << QVariant(); QTest::newRow( "m_min NULL" ) << "m_min(geom_from_wkt(NULL))" << false << QVariant(); QTest::newRow( "m_min point" ) << "m_min(make_point_m(0,0,1))" << false << QVariant( 1.0 ); - QTest::newRow( "m_min point M NaN" ) << "m_min(geom_from_wkt('PointZM (0 0 0 nan)'))" << false << QVariant( ); - QTest::newRow( "m_min line M NaN" ) << "m_min(make_line(geom_from_wkt('PointZM (0 0 0 nan)'),geom_from_wkt('PointZM (1 1 1 2)')))" << false << QVariant( ); + QTest::newRow( "m_min point M NaN" ) << "m_min(geom_from_wkt('PointZM (0 0 0 nan)'))" << false << QVariant(); + QTest::newRow( "m_min line M NaN" ) << "m_min(make_line(geom_from_wkt('PointZM (0 0 0 nan)'),geom_from_wkt('PointZM (1 1 1 2)')))" << false << QVariant(); QTest::newRow( "m_min line" ) << "m_min(make_line(make_point_m(0,0,1),make_point_m(-1,-1,2),make_point_m(-2,-2,0)))" << false << QVariant( 0.0 ); QTest::newRow( "main angle polygon" ) << "round(main_angle( geom_from_wkt('POLYGON((0 0,2 9,9 2,0 0))')))" << false << QVariant( 77 ); QTest::newRow( "main angle polygon edge case" ) << "round(main_angle( geom_from_wkt('POLYGON((353542.63843526 378974.92373469, 353544.95808017 378975.73690545, 353545.27173175 378974.84218528, 353542.95208684 378974.02901451, 353542.63843526 378974.92373469))')))" << false << QVariant( 71 ); @@ -1654,25 +1642,22 @@ class TestQgsExpression: public QObject QTest::newRow( "geometries_to_array_multipoly" ) << "geom_to_wkt(array_get(geometries_to_array(geom_from_wkt('MULTIPOLYGON(((5 5,0 0,0 10,5 5)),((5 5,10 10,10 0,5 5)))')),1))" << false << QVariant( "Polygon ((5 5, 10 10, 10 0, 5 5))" ); QTest::newRow( "geometries_to_array_emptygeom" ) << "array_length(geometries_to_array(geom_from_wkt('LINESTRING EMPTY')))" << false << QVariant( 1 ); QTest::newRow( "geometries_to_array_nongeom" ) << "geometries_to_array('just a string')" << true << QVariant(); -#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=11 ) +#if GEOS_VERSION_MAJOR > 3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 11 ) QTest::newRow( "concave_hull not geom" ) << "concave_hull('r', 1)" << true << QVariant(); QTest::newRow( "concave_hull null" ) << "concave_hull(NULL, 1)" << false << QVariant(); QTest::newRow( "concave_hull point" ) << "geom_to_wkt(concave_hull(geom_from_wkt('Point(0 0)'), 0.99))" << false << QVariant( "Point (0 0)" ); - QTest::newRow( "concave_hull multilinestring" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MULTILINESTRING((106 164,30 112,74 70,82 112,130 94,130 62,122 40,156 32,162 76,172 88),(132 178,134 148,128 136,96 128,132 108,150 130,170 142,174 110,156 96,158 90,158 88),(22 64,66 28,94 38,94 68,114 76,112 30,132 10,168 18,178 34,186 52,184 74,190 100,190 122,182 148,178 170,176 184,156 164,146 178,132 186,92 182,56 158,36 150,62 150,76 128,88 118))'), 0.99))" << false << - QVariant( "Polygon ((30 112, 36 150, 92 182, 132 186, 176 184, 190 122, 190 100, 186 52, 178 34, 168 18, 132 10, 66 28, 22 64, 30 112))" ); -#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=12 ) - QTest::newRow( "concave_hull multipoint" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MultiPoint ((6.3 8.4),(7.6 8.8),(6.8 7.3),(5.3 1.8),(9.1 5),(8.1 7),(8.8 2.9),(2.4 8.2),(3.2 5.1),(3.7 2.3),(2.7 5.4),(8.4 1.9),(7.5 8.7),(4.4 4.2),(7.7 6.7),(9 3),(3.6 6.1),(3.2 6.5),(8.1 4.7),(8.8 5.8),(6.8 7.3),(4.9 9.5),(8.1 6),(8.7 5),(7.8 1.6),(7.9 2.1),(3 2.2),(7.8 4.3),(2.6 8.5),(4.8 3.4),(3.5 3.5),(3.6 4),(3.1 7.9),(8.3 2.9),(2.7 8.4),(5.2 9.8),(7.2 9.5),(8.5 7.1),(7.5 8.4),(7.5 7.7),(8.1 2.9),(7.7 7.3),(4.1 4.2),(8.3 7.2),(2.3 3.6),(8.9 5.3),(2.7 5.7),(5.7 9.7),(2.7 7.7),(3.9 8.8),(6 8.1),(8 7.2),(5.4 3.2),(5.5 2.6),(6.2 2.2),(7 2),(7.6 2.7),(8.4 3.5),(8.7 4.2),(8.2 5.4),(8.3 6.4),(6.9 8.6),(6 9),(5 8.6),(4.3 8),(3.6 7.3),(3.6 6.8),(4 7.5),(2.4 6.7),(2.3 6),(2.6 4.4),(2.8 3.3),(4 3.2),(4.3 1.9),(6.5 1.6),(7.3 1.6),(3.8 4.6),(3.1 5.9),(3.4 8.6),(4.5 9),(6.4 9.7))'), 0.99),2)" << false << - QVariant( "Polygon ((2.4 8.2, 2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6, 2.4 8.2))" ); + QTest::newRow( "concave_hull multilinestring" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MULTILINESTRING((106 164,30 112,74 70,82 112,130 94,130 62,122 40,156 32,162 76,172 88),(132 178,134 148,128 136,96 128,132 108,150 130,170 142,174 110,156 96,158 90,158 88),(22 64,66 28,94 38,94 68,114 76,112 30,132 10,168 18,178 34,186 52,184 74,190 100,190 122,182 148,178 170,176 184,156 164,146 178,132 186,92 182,56 158,36 150,62 150,76 128,88 118))'), 0.99))" << false << QVariant( "Polygon ((30 112, 36 150, 92 182, 132 186, 176 184, 190 122, 190 100, 186 52, 178 34, 168 18, 132 10, 66 28, 22 64, 30 112))" ); +#if GEOS_VERSION_MAJOR > 3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 12 ) + QTest::newRow( "concave_hull multipoint" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MultiPoint ((6.3 8.4),(7.6 8.8),(6.8 7.3),(5.3 1.8),(9.1 5),(8.1 7),(8.8 2.9),(2.4 8.2),(3.2 5.1),(3.7 2.3),(2.7 5.4),(8.4 1.9),(7.5 8.7),(4.4 4.2),(7.7 6.7),(9 3),(3.6 6.1),(3.2 6.5),(8.1 4.7),(8.8 5.8),(6.8 7.3),(4.9 9.5),(8.1 6),(8.7 5),(7.8 1.6),(7.9 2.1),(3 2.2),(7.8 4.3),(2.6 8.5),(4.8 3.4),(3.5 3.5),(3.6 4),(3.1 7.9),(8.3 2.9),(2.7 8.4),(5.2 9.8),(7.2 9.5),(8.5 7.1),(7.5 8.4),(7.5 7.7),(8.1 2.9),(7.7 7.3),(4.1 4.2),(8.3 7.2),(2.3 3.6),(8.9 5.3),(2.7 5.7),(5.7 9.7),(2.7 7.7),(3.9 8.8),(6 8.1),(8 7.2),(5.4 3.2),(5.5 2.6),(6.2 2.2),(7 2),(7.6 2.7),(8.4 3.5),(8.7 4.2),(8.2 5.4),(8.3 6.4),(6.9 8.6),(6 9),(5 8.6),(4.3 8),(3.6 7.3),(3.6 6.8),(4 7.5),(2.4 6.7),(2.3 6),(2.6 4.4),(2.8 3.3),(4 3.2),(4.3 1.9),(6.5 1.6),(7.3 1.6),(3.8 4.6),(3.1 5.9),(3.4 8.6),(4.5 9),(6.4 9.7))'), 0.99),2)" << false << QVariant( "Polygon ((2.4 8.2, 2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6, 2.4 8.2))" ); #else - QTest::newRow( "concave_hull multipoint" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MultiPoint ((6.3 8.4),(7.6 8.8),(6.8 7.3),(5.3 1.8),(9.1 5),(8.1 7),(8.8 2.9),(2.4 8.2),(3.2 5.1),(3.7 2.3),(2.7 5.4),(8.4 1.9),(7.5 8.7),(4.4 4.2),(7.7 6.7),(9 3),(3.6 6.1),(3.2 6.5),(8.1 4.7),(8.8 5.8),(6.8 7.3),(4.9 9.5),(8.1 6),(8.7 5),(7.8 1.6),(7.9 2.1),(3 2.2),(7.8 4.3),(2.6 8.5),(4.8 3.4),(3.5 3.5),(3.6 4),(3.1 7.9),(8.3 2.9),(2.7 8.4),(5.2 9.8),(7.2 9.5),(8.5 7.1),(7.5 8.4),(7.5 7.7),(8.1 2.9),(7.7 7.3),(4.1 4.2),(8.3 7.2),(2.3 3.6),(8.9 5.3),(2.7 5.7),(5.7 9.7),(2.7 7.7),(3.9 8.8),(6 8.1),(8 7.2),(5.4 3.2),(5.5 2.6),(6.2 2.2),(7 2),(7.6 2.7),(8.4 3.5),(8.7 4.2),(8.2 5.4),(8.3 6.4),(6.9 8.6),(6 9),(5 8.6),(4.3 8),(3.6 7.3),(3.6 6.8),(4 7.5),(2.4 6.7),(2.3 6),(2.6 4.4),(2.8 3.3),(4 3.2),(4.3 1.9),(6.5 1.6),(7.3 1.6),(3.8 4.6),(3.1 5.9),(3.4 8.6),(4.5 9),(6.4 9.7))'), 0.99),2)" << false << - QVariant( "Polygon ((2.3 6, 2.4 8.2, 2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6))" ); + QTest::newRow( "concave_hull multipoint" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MultiPoint ((6.3 8.4),(7.6 8.8),(6.8 7.3),(5.3 1.8),(9.1 5),(8.1 7),(8.8 2.9),(2.4 8.2),(3.2 5.1),(3.7 2.3),(2.7 5.4),(8.4 1.9),(7.5 8.7),(4.4 4.2),(7.7 6.7),(9 3),(3.6 6.1),(3.2 6.5),(8.1 4.7),(8.8 5.8),(6.8 7.3),(4.9 9.5),(8.1 6),(8.7 5),(7.8 1.6),(7.9 2.1),(3 2.2),(7.8 4.3),(2.6 8.5),(4.8 3.4),(3.5 3.5),(3.6 4),(3.1 7.9),(8.3 2.9),(2.7 8.4),(5.2 9.8),(7.2 9.5),(8.5 7.1),(7.5 8.4),(7.5 7.7),(8.1 2.9),(7.7 7.3),(4.1 4.2),(8.3 7.2),(2.3 3.6),(8.9 5.3),(2.7 5.7),(5.7 9.7),(2.7 7.7),(3.9 8.8),(6 8.1),(8 7.2),(5.4 3.2),(5.5 2.6),(6.2 2.2),(7 2),(7.6 2.7),(8.4 3.5),(8.7 4.2),(8.2 5.4),(8.3 6.4),(6.9 8.6),(6 9),(5 8.6),(4.3 8),(3.6 7.3),(3.6 6.8),(4 7.5),(2.4 6.7),(2.3 6),(2.6 4.4),(2.8 3.3),(4 3.2),(4.3 1.9),(6.5 1.6),(7.3 1.6),(3.8 4.6),(3.1 5.9),(3.4 8.6),(4.5 9),(6.4 9.7))'), 0.99),2)" << false << QVariant( "Polygon ((2.3 6, 2.4 8.2, 2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6))" ); #endif -#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=12 ) +#if GEOS_VERSION_MAJOR > 3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 12 ) QTest::newRow( "concave_hull multipoint allow holes" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MultiPoint ((6.3 8.4),(7.6 8.8),(6.8 7.3),(5.3 1.8),(9.1 5),(8.1 7),(8.8 2.9),(2.4 8.2),(3.2 5.1),(3.7 2.3),(2.7 5.4),(8.4 1.9),(7.5 8.7),(4.4 4.2),(7.7 6.7),(9 3),(3.6 6.1),(3.2 6.5),(8.1 4.7),(8.8 5.8),(6.8 7.3),(4.9 9.5),(8.1 6),(8.7 5),(7.8 1.6),(7.9 2.1),(3 2.2),(7.8 4.3),(2.6 8.5),(4.8 3.4),(3.5 3.5),(3.6 4),(3.1 7.9),(8.3 2.9),(2.7 8.4),(5.2 9.8),(7.2 9.5),(8.5 7.1),(7.5 8.4),(7.5 7.7),(8.1 2.9),(7.7 7.3),(4.1 4.2),(8.3 7.2),(2.3 3.6),(8.9 5.3),(2.7 5.7),(5.7 9.7),(2.7 7.7),(3.9 8.8),(6 8.1),(8 7.2),(5.4 3.2),(5.5 2.6),(6.2 2.2),(7 2),(7.6 2.7),(8.4 3.5),(8.7 4.2),(8.2 5.4),(8.3 6.4),(6.9 8.6),(6 9),(5 8.6),(4.3 8),(3.6 7.3),(3.6 6.8),(4 7.5),(2.4 6.7),(2.3 6),(2.6 4.4),(2.8 3.3),(4 3.2),(4.3 1.9),(6.5 1.6),(7.3 1.6),(3.8 4.6),(3.1 5.9),(3.4 8.6),(4.5 9),(6.4 9.7))'), 0.99, true),2)" << false - << QVariant( "Polygon ((2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6, 2.4 8.2, 2.6 8.5),(3.6 6.1, 4.4 4.2, 7.8 4.3, 6.8 7.3, 3.6 6.1))" ); + << QVariant( "Polygon ((2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6, 2.4 8.2, 2.6 8.5),(3.6 6.1, 4.4 4.2, 7.8 4.3, 6.8 7.3, 3.6 6.1))" ); #else QTest::newRow( "concave_hull multipoint allow holes" ) << "geom_to_wkt(concave_hull(geom_from_wkt('MultiPoint ((6.3 8.4),(7.6 8.8),(6.8 7.3),(5.3 1.8),(9.1 5),(8.1 7),(8.8 2.9),(2.4 8.2),(3.2 5.1),(3.7 2.3),(2.7 5.4),(8.4 1.9),(7.5 8.7),(4.4 4.2),(7.7 6.7),(9 3),(3.6 6.1),(3.2 6.5),(8.1 4.7),(8.8 5.8),(6.8 7.3),(4.9 9.5),(8.1 6),(8.7 5),(7.8 1.6),(7.9 2.1),(3 2.2),(7.8 4.3),(2.6 8.5),(4.8 3.4),(3.5 3.5),(3.6 4),(3.1 7.9),(8.3 2.9),(2.7 8.4),(5.2 9.8),(7.2 9.5),(8.5 7.1),(7.5 8.4),(7.5 7.7),(8.1 2.9),(7.7 7.3),(4.1 4.2),(8.3 7.2),(2.3 3.6),(8.9 5.3),(2.7 5.7),(5.7 9.7),(2.7 7.7),(3.9 8.8),(6 8.1),(8 7.2),(5.4 3.2),(5.5 2.6),(6.2 2.2),(7 2),(7.6 2.7),(8.4 3.5),(8.7 4.2),(8.2 5.4),(8.3 6.4),(6.9 8.6),(6 9),(5 8.6),(4.3 8),(3.6 7.3),(3.6 6.8),(4 7.5),(2.4 6.7),(2.3 6),(2.6 4.4),(2.8 3.3),(4 3.2),(4.3 1.9),(6.5 1.6),(7.3 1.6),(3.8 4.6),(3.1 5.9),(3.4 8.6),(4.5 9),(6.4 9.7))'), 0.99, true),2)" << false - << QVariant( "Polygon ((2.4 8.2, 2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6, 2.4 8.2),(3.6 6.1, 4.4 4.2, 7.8 4.3, 6.8 7.3, 3.6 6.1))" ); + << QVariant( "Polygon ((2.4 8.2, 2.6 8.5, 5.2 9.8, 6.4 9.7, 7.2 9.5, 7.6 8.8, 8.5 7.1, 9.1 5, 9 3, 8.4 1.9, 7.8 1.6, 7.3 1.6, 6.5 1.6, 4.3 1.9, 3 2.2, 2.3 3.6, 2.3 6, 2.4 8.2),(3.6 6.1, 4.4 4.2, 7.8 4.3, 6.8 7.3, 3.6 6.1))" ); #endif #endif // string functions @@ -1897,7 +1882,7 @@ class TestQgsExpression: public QObject QTest::newRow( "epoch invalid date" ) << "epoch('invalid')" << true << QVariant(); // datetime_from_epoch will always return a local datetime, so here we create some circular magic to create a local datetime during test (so test can be ran in every timezone...) QTest::newRow( "datetime_from_epoch" ) << "datetime_from_epoch(epoch(to_datetime('2017-01-01T00:00:01')))" << false << QVariant( QDateTime( QDate( 2017, 1, 1 ), QTime( 0, 0, 1 ), Qt::LocalTime ) ); - QTest::newRow( "datetime_from_epoch_null" ) << "datetime_from_epoch(NULL)" << false << QgsVariantUtils::createNullVariant( QMetaType::Type::UnknownType ); + QTest::newRow( "datetime_from_epoch_null" ) << "datetime_from_epoch(NULL)" << false << QgsVariantUtils::createNullVariant( QMetaType::Type::UnknownType ); QTest::newRow( "date from format" ) << "to_date('June 29, 2019','MMMM d, yyyy')" << false << QVariant( QDate( 2019, 6, 29 ) ); QTest::newRow( "date from format and language" ) << "to_date('29 juin, 2019','d MMMM, yyyy','fr')" << false << QVariant( QDate( 2019, 6, 29 ) ); QTest::newRow( "date from format, wrong string" ) << "to_date('wrong.string.here','yyyy.MM.dd')" << true << QVariant(); @@ -1936,7 +1921,7 @@ class TestQgsExpression: public QObject QTest::newRow( "color mix rgb" ) << "color_mix_rgb('0,0,0,100','255,255,255',0.5)" << false << QVariant( "127,127,127,177" ); // looks like way color are rounded has changed between Qt 5 and 6 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QTest::newRow( "color mix" ) << "color_mix('0,0,0,100','255,255,255',0.5)" << false << QVariant( "128,128,128,177" ); #else QTest::newRow( "color mix" ) << "color_mix('0,0,0,100','255,255,255',0.5)" << false << QVariant( "128,128,128,178" ); @@ -2083,7 +2068,7 @@ class TestQgsExpression: public QObject // Raster attributes QTest::newRow( "raster_attributes band 1" ) << QStringLiteral( "map_to_html_dl(raster_attributes('%1',1,246))" ).arg( mRasterLayerWithAttributeTable->name() ) << false << QVariant( "\n
    \n
    Class
    2
    Value
    246
    \n
    " ); - QTest::newRow( "raster_attributes band 1 not found value" ) << QStringLiteral( "raster_attributes('%1',1,100000)" ).arg( mRasterLayerWithAttributeTable->name() ) << false << QVariant( ); + QTest::newRow( "raster_attributes band 1 not found value" ) << QStringLiteral( "raster_attributes('%1',1,100000)" ).arg( mRasterLayerWithAttributeTable->name() ) << false << QVariant(); QTest::newRow( "raster_attributes wrong band 2" ) << QStringLiteral( "raster_attributes('%1',2,243)" ).arg( mRasterLayerWithAttributeTable->name() ) << true << QVariant(); QTest::newRow( "raster_attributes no attributes" ) << QStringLiteral( "raster_attributes('%1',1,1)" ).arg( mRasterLayerWithAttributeTable->name() ) << false << QVariant(); @@ -2219,7 +2204,7 @@ class TestQgsExpression: public QObject // hash functions QTest::newRow( "md5(NULL)" ) << QStringLiteral( "md5(NULL)" ) << false << QVariant(); QTest::newRow( "md5('QGIS')" ) << QStringLiteral( "md5('QGIS')" ) << false << QVariant( "57470aaa9e22adaefac7f5f342f1c6da" ); - QTest::newRow( "sha256(NULL)" ) << QStringLiteral( "sha256(NULL)" ) << false << QVariant( ); + QTest::newRow( "sha256(NULL)" ) << QStringLiteral( "sha256(NULL)" ) << false << QVariant(); QTest::newRow( "sha256('QGIS')" ) << QStringLiteral( "sha256('QGIS')" ) << false << QVariant( "eb045cba7a797aaa06ac58830846e40c8e8c780bc0676d3393605fae50c05309" ); QTest::newRow( "hash('QGIS', 'qsdf')" ) << QStringLiteral( "hash('QGIS', 'qsdf')" ) << true << QVariant(); QTest::newRow( "hash('QGIS', 'md4')" ) << QStringLiteral( "hash('QGIS', 'md4')" ) << false << QVariant( "c0fc71c241cdebb6e888cbac0e2b68eb" ); @@ -2283,11 +2268,11 @@ class TestQgsExpression: public QObject QTest::newRow( "not between time" ) << QStringLiteral( "make_time(10,10,10) not between make_time(9,10,10) AND make_time(11,10,10)" ) << false << QVariant( false ); QTest::newRow( "between datetime" ) << QStringLiteral( "make_datetime(9,10,10,1,1,1) between make_datetime(9,10,10,1,1,0) AND make_datetime(9,10,10,1,1,2)" ) << false << QVariant( true ); QTest::newRow( "not between datetime" ) << QStringLiteral( "make_datetime(9,10,10,1,1,1) not between make_datetime(9,10,10,1,1,0) AND make_datetime(9,10,10,1,1,2)" ) << false << QVariant( false ); - QTest::newRow( "between nulls" ) << QStringLiteral( "'b' between NULL AND 'c'" ) << false << QVariant( ); - QTest::newRow( "between nulls 2" ) << QStringLiteral( "'b' between NULL AND NULL" ) << false << QVariant( ); - QTest::newRow( "between nulls 3" ) << QStringLiteral( "NULL between 'a' AND 'c'" ) << false << QVariant( ); - QTest::newRow( "between nulls 4" ) << QStringLiteral( "'b' between 'a' AND NULL" ) << false << QVariant( ); - QTest::newRow( "between nulls 5" ) << QStringLiteral( "NULL between NULL AND NULL" ) << false << QVariant( ); + QTest::newRow( "between nulls" ) << QStringLiteral( "'b' between NULL AND 'c'" ) << false << QVariant(); + QTest::newRow( "between nulls 2" ) << QStringLiteral( "'b' between NULL AND NULL" ) << false << QVariant(); + QTest::newRow( "between nulls 3" ) << QStringLiteral( "NULL between 'a' AND 'c'" ) << false << QVariant(); + QTest::newRow( "between nulls 4" ) << QStringLiteral( "'b' between 'a' AND NULL" ) << false << QVariant(); + QTest::newRow( "between nulls 5" ) << QStringLiteral( "NULL between NULL AND NULL" ) << false << QVariant(); QTest::newRow( "not between nulls " ) << QStringLiteral( "'c' between NULL AND 'b'" ) << false << QVariant( false ); // Test NULL -> TRUE QTest::newRow( "not between nulls TRUE" ) << QStringLiteral( "'a' not between 'b' AND NULL" ) << false << QVariant( true ); @@ -2660,7 +2645,6 @@ class TestQgsExpression: public QObject QTest::newRow( "get_feature no match-multi1" ) << "get_feature('test',attribute:= map('col1','col2'),value:='no match!')" << false << -1; QTest::newRow( "get_feature no match-multi2" ) << "get_feature('test',map('col2','10','col4','test3'))" << false << -1; QTest::newRow( "get_feature no match-multi2" ) << "get_feature('test',map('col1',10,'datef',to_date('2021-09-24')))" << false << -1; - } void eval_get_feature() @@ -2931,8 +2915,8 @@ class TestQgsExpression: public QObject QgsFeature firstFeature = mPointsLayer->getFeature( 1 ); QgsVectorLayer *noLayer = nullptr; - QTest::newRow( "display not evaluated" ) << QStringLiteral( "display_expression(@layer_id, $currentfeature, False)" ) << firstFeature << mPointsLayer << false << QVariant( "'Display expression with class = ' || \"Class\"" ); - QTest::newRow( "display wrong layer" ) << QStringLiteral( "display_expression()" ) << firstFeature << noLayer << true << QVariant(); + QTest::newRow( "display not evaluated" ) << QStringLiteral( "display_expression(@layer_id, $currentfeature, False)" ) << firstFeature << mPointsLayer << false << QVariant( "'Display expression with class = ' || \"Class\"" ); + QTest::newRow( "display wrong layer" ) << QStringLiteral( "display_expression()" ) << firstFeature << noLayer << true << QVariant(); QTest::newRow( "display wrong feature" ) << QStringLiteral( "display_expression()" ) << QgsFeature() << mPointsLayer << true << QVariant(); QTest::newRow( "maptip wrong feature" ) << QStringLiteral( "maptip()" ) << QgsFeature() << mPointsLayer << true << QVariant(); @@ -3053,7 +3037,7 @@ class TestQgsExpression: public QObject QTest::addColumn( "layer" ); QTest::addColumn( "result" ); - QgsFeature firstFeature = mMemoryLayer->getFeature( 1 ); // hard constraint failure on col1 + QgsFeature firstFeature = mMemoryLayer->getFeature( 1 ); // hard constraint failure on col1 QgsFeature secondFeature = mMemoryLayer->getFeature( 2 ); // all constraints valid QgsVectorLayer *noLayer = nullptr; @@ -3115,27 +3099,27 @@ class TestQgsExpression: public QObject QTest::addColumn( "evalError" ); QTest::addColumn( "result" ); - QTest::newRow( "bad relation" ) << "relation_aggregate('xxxtest','sum',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 0}} ) << true << QVariant(); - QTest::newRow( "bad aggregate" ) << "relation_aggregate('my_rel','xxsum',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 0}} ) << true << QVariant(); - QTest::newRow( "bad expression" ) << "relation_aggregate('my_rel','sum',\"xcvxcvcol1\")" << QVariantMap( {{QStringLiteral( "col1" ), 0}} ) << true << QVariant(); + QTest::newRow( "bad relation" ) << "relation_aggregate('xxxtest','sum',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 0 } } ) << true << QVariant(); + QTest::newRow( "bad aggregate" ) << "relation_aggregate('my_rel','xxsum',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 0 } } ) << true << QVariant(); + QTest::newRow( "bad expression" ) << "relation_aggregate('my_rel','sum',\"xcvxcvcol1\")" << QVariantMap( { { QStringLiteral( "col1" ), 0 } } ) << true << QVariant(); - QTest::newRow( "relation aggregate 1" ) << "relation_aggregate('my_rel','sum',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << false << QVariant( 5 ); - QTest::newRow( "relation aggregate by name" ) << "relation_aggregate('relation name','sum',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << false << QVariant( 5 ); - QTest::newRow( "relation aggregate 2" ) << "relation_aggregate('my_rel','sum',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 3}} ) << false << QVariant( 9 ); - QTest::newRow( "relation aggregate 2" ) << "relation_aggregate('my_rel','sum',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 6}} ) << false << QVariant( 0 ); - QTest::newRow( "relation aggregate count 1" ) << "relation_aggregate('my_rel','count',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << false << QVariant( 3 ); - QTest::newRow( "relation aggregate count 2" ) << "relation_aggregate('my_rel','count',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 3}} ) << false << QVariant( 2 ); - QTest::newRow( "relation aggregate count 2" ) << "relation_aggregate('my_rel','count',\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 6}} ) << false << QVariant( 0 ); - QTest::newRow( "relation aggregate concatenation" ) << "relation_aggregate('my_rel','concatenate',to_string(\"col3\"),concatenator:=',')" << QVariantMap( {{QStringLiteral( "col1" ), 3}} ) << false << QVariant( "2,7" ); + QTest::newRow( "relation aggregate 1" ) << "relation_aggregate('my_rel','sum',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << false << QVariant( 5 ); + QTest::newRow( "relation aggregate by name" ) << "relation_aggregate('relation name','sum',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << false << QVariant( 5 ); + QTest::newRow( "relation aggregate 2" ) << "relation_aggregate('my_rel','sum',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 3 } } ) << false << QVariant( 9 ); + QTest::newRow( "relation aggregate 2" ) << "relation_aggregate('my_rel','sum',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 6 } } ) << false << QVariant( 0 ); + QTest::newRow( "relation aggregate count 1" ) << "relation_aggregate('my_rel','count',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << false << QVariant( 3 ); + QTest::newRow( "relation aggregate count 2" ) << "relation_aggregate('my_rel','count',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 3 } } ) << false << QVariant( 2 ); + QTest::newRow( "relation aggregate count 2" ) << "relation_aggregate('my_rel','count',\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 6 } } ) << false << QVariant( 0 ); + QTest::newRow( "relation aggregate concatenation" ) << "relation_aggregate('my_rel','concatenate',to_string(\"col3\"),concatenator:=',')" << QVariantMap( { { QStringLiteral( "col1" ), 3 } } ) << false << QVariant( "2,7" ); - QTest::newRow( "relation aggregate concatenation with order" ) << "relation_aggregate('my_rel','concatenate',to_string(\"col2\"),concatenator:=',', order_by:=col2)" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << false << QVariant( "test,test333," ); - QTest::newRow( "relation aggregate concatenation with order 2" ) << "relation_aggregate('my_rel','concatenate',to_string(\"col2\"),concatenator:=',', order_by:=col3)" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << false << QVariant( ",test,test333" ); + QTest::newRow( "relation aggregate concatenation with order" ) << "relation_aggregate('my_rel','concatenate',to_string(\"col2\"),concatenator:=',', order_by:=col2)" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << false << QVariant( "test,test333," ); + QTest::newRow( "relation aggregate concatenation with order 2" ) << "relation_aggregate('my_rel','concatenate',to_string(\"col2\"),concatenator:=',', order_by:=col3)" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << false << QVariant( ",test,test333" ); - QTest::newRow( "named relation aggregate 1" ) << "relation_aggregate(relation:='my_rel',aggregate:='sum',expression:=\"col3\")" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << false << QVariant( 5 ); - QTest::newRow( "relation aggregate sub expression 1" ) << "relation_aggregate('my_rel','sum',\"col3\" * 2)" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << false << QVariant( 10 ); - QTest::newRow( "relation aggregate bad sub expression" ) << "relation_aggregate('my_rel','sum',\"fsdfsddf\" * 2)" << QVariantMap( {{QStringLiteral( "col1" ), 4}} ) << true << QVariant(); + QTest::newRow( "named relation aggregate 1" ) << "relation_aggregate(relation:='my_rel',aggregate:='sum',expression:=\"col3\")" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << false << QVariant( 5 ); + QTest::newRow( "relation aggregate sub expression 1" ) << "relation_aggregate('my_rel','sum',\"col3\" * 2)" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << false << QVariant( 10 ); + QTest::newRow( "relation aggregate bad sub expression" ) << "relation_aggregate('my_rel','sum',\"fsdfsddf\" * 2)" << QVariantMap( { { QStringLiteral( "col1" ), 4 } } ) << true << QVariant(); - QTest::newRow( "relation aggregate with composite keys" ) << "relation_aggregate('my_rel_composite','sum',\"my_value\")" << QVariantMap( {{QStringLiteral( "col3" ), 1961}, {QStringLiteral( "col4" ), QStringLiteral( "Sputnik" )}} ) << false << QVariant( 21071969 ); + QTest::newRow( "relation aggregate with composite keys" ) << "relation_aggregate('my_rel_composite','sum',\"my_value\")" << QVariantMap( { { QStringLiteral( "col3" ), 1961 }, { QStringLiteral( "col4" ), QStringLiteral( "Sputnik" ) } } ) << false << QVariant( 21071969 ); } void relationAggregate() @@ -3207,7 +3191,7 @@ class TestQgsExpression: public QObject // Invalid expression since max( v3.userType() ), QMetaType::Type::UnknownType ); + QCOMPARE( static_cast( v3.userType() ), QMetaType::Type::UnknownType ); // Supports multiple type of seeds QgsExpression exp4( QStringLiteral( "rand(1,10,123)" ) ); @@ -3254,7 +3238,7 @@ class TestQgsExpression: public QObject // Invalid expression since max( v3.userType() ), QMetaType::Type::UnknownType ); + QCOMPARE( static_cast( v3.userType() ), QMetaType::Type::UnknownType ); // Supports multiple type of seeds QgsExpression exp4( QStringLiteral( "randf(1.5,9.5,123)" ) ); @@ -3284,7 +3268,7 @@ class TestQgsExpression: public QObject QVariant v9 = exp9.evaluate(); QgsExpression exp10( QStringLiteral( "randf(seed:=2)" ) ); QVariant v10 = exp10.evaluate(); - QVERIFY2( ! qgsDoubleNear( v9.toDouble(), v10.toDouble() ), QStringLiteral( "Calculated: %1 == Expected %2" ).arg( QString::number( v9.toDouble() ), QString::number( v10.toDouble() ) ).toUtf8().constData() ); + QVERIFY2( !qgsDoubleNear( v9.toDouble(), v10.toDouble() ), QStringLiteral( "Calculated: %1 == Expected %2" ).arg( QString::number( v9.toDouble() ), QString::number( v10.toDouble() ) ).toUtf8().constData() ); } void referenced_columns() @@ -3378,7 +3362,6 @@ class TestQgsExpression: public QObject actualBinaryOps << f->op(); } QCOMPARE( actualBinaryOps, expectedBinaryOps ); - } void referenced_columns_all_attributes() @@ -3459,7 +3442,7 @@ class TestQgsExpression: public QObject QgsFeature f; QList geometryList; - geometryList << geom << QgsReferencedGeometry( geom, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ) ); + geometryList << geom << QgsReferencedGeometry( geom, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ) ); // With standard geometry { @@ -3546,11 +3529,9 @@ class TestQgsExpression: public QObject QgsMultiLineString mls; QgsLineString part; - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 10, 10 ) - << QgsPoint( Qgis::WkbType::PointZM, 20, 20, 20, 20 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 10, 10 ) << QgsPoint( Qgis::WkbType::PointZM, 20, 20, 20, 20 ) ); mls.addGeometry( part.clone() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 30, 30, 30, 30 ) - << QgsPoint( Qgis::WkbType::PointZM, 40, 40, 40, 40 ) ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 30, 30, 30, 30 ) << QgsPoint( Qgis::WkbType::PointZM, 40, 40, 40, 40 ) ); mls.addGeometry( part.clone() ); QgsGeometry multiStringZMGeom; multiStringZMGeom.set( mls.clone() ); @@ -3886,7 +3867,7 @@ class TestQgsExpression: public QObject // test length without geomCalculator QgsPolylineXY line3111; line3111 << QgsPointXY( 2484588, 2425722 ) << QgsPointXY( 2482767, 2398853 ); - QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ) ; + QgsGeometry line3111G = QgsGeometry::fromPolylineXY( line3111 ); feat.setGeometry( line3111G ); context.setFeature( feat ); @@ -3995,9 +3976,10 @@ class TestQgsExpression: public QObject QTest::newRow( "GML Box" ) << "geomFromGML('135.2239,34.4879 135.8578,34.8471')" << QgsGeometry::fromRect( rect ) << false; // Envelope is from GML3 ? QTest::newRow( "GML Envelope" ) << "geomFromGML('" - "135.2239 34.4879" - "135.8578 34.8471" - "')" << QgsGeometry::fromRect( rect ) << false; + "135.2239 34.4879" + "135.8578 34.8471" + "')" + << QgsGeometry::fromRect( rect ) << false; } void eval_geometry_constructor() @@ -4018,7 +4000,7 @@ class TestQgsExpression: public QObject QVariant out = exp.evaluate( &context ); QCOMPARE( exp.hasEvalError(), evalError ); - QCOMPARE( out.userType() == qMetaTypeId< QgsGeometry>(), true ); + QCOMPARE( out.userType() == qMetaTypeId(), true ); QgsGeometry outGeom = out.value(); QCOMPARE( geom.equals( outGeom ), true ); } @@ -4079,7 +4061,7 @@ class TestQgsExpression: public QObject QgsExpressionContext context = QgsExpressionContextUtils::createFeatureBasedContext( f, QgsFields() ); QVariant out = exp.evaluate( &context ); QCOMPARE( exp.hasEvalError(), evalError ); - QCOMPARE( out.userType() == qMetaTypeId< QgsGeometry>(), true ); + QCOMPARE( out.userType() == qMetaTypeId(), true ); QgsGeometry outGeom = out.value(); QCOMPARE( geom.equals( outGeom ), true ); } @@ -4191,9 +4173,9 @@ class TestQgsExpression: public QObject QTest::newRow( "bounds" ) << "bounds( $geometry )" << geom << false << true << QgsGeometry::fromRect( geom.boundingBox() ); geom = QgsGeometry::fromPolygonXY( polygon ); - QTest::newRow( "oriented_bbox" ) << "oriented_bbox( $geometry )" << geom << false << true << geom.orientedMinimumBoundingBox( ); + QTest::newRow( "oriented_bbox" ) << "oriented_bbox( $geometry )" << geom << false << true << geom.orientedMinimumBoundingBox(); geom = QgsGeometry::fromPolygonXY( polygon ); - QTest::newRow( "minimal_circle" ) << "minimal_circle( $geometry )" << geom << false << true << geom.minimalEnclosingCircle( ); + QTest::newRow( "minimal_circle" ) << "minimal_circle( $geometry )" << geom << false << true << geom.minimalEnclosingCircle(); geom = QgsGeometry::fromPolygonXY( polygon ); QTest::newRow( "translate" ) << "translate( $geometry, 1, 2)" << geom << false << true << QgsGeometry::fromWkt( QStringLiteral( "POLYGON ((1 2,11 12,11 2,1 2))" ) ); @@ -4222,7 +4204,7 @@ class TestQgsExpression: public QObject QVariant out = exp.evaluate( &context ); QCOMPARE( exp.hasEvalError(), evalError ); - QCOMPARE( out.userType() == qMetaTypeId< QgsGeometry>(), true ); + QCOMPARE( out.userType() == qMetaTypeId(), true ); QgsGeometry outGeom = out.value(); outGeom.normalize(); result.normalize(); @@ -4391,8 +4373,8 @@ class TestQgsExpression: public QObject QCOMPARE( QgsExpression( "array_slice(array('Dufour','Valmiera','Chugiak','Brighton'),-2,-1) = array('Chugiak','Brighton')" ).evaluate( &context ), QVariant( true ) ); QCOMPARE( QgsExpression( "array_slice( array(), 0, 3) = array()" ).evaluate( &context ), QVariant( true ) ); - QCOMPARE( QgsExpression( "array_sort(array('Banana','Cake','Apple'))" ).evaluate( & context ), QVariant( QVariantList() << QStringLiteral( "Apple" ) << QStringLiteral( "Banana" ) << QStringLiteral( "Cake" ) ) ); - QCOMPARE( QgsExpression( "array_sort(array('Banana','Cake','Apple'),false)" ).evaluate( & context ), QVariant( QVariantList() << QStringLiteral( "Cake" ) << QStringLiteral( "Banana" ) << QStringLiteral( "Apple" ) ) ); + QCOMPARE( QgsExpression( "array_sort(array('Banana','Cake','Apple'))" ).evaluate( &context ), QVariant( QVariantList() << QStringLiteral( "Apple" ) << QStringLiteral( "Banana" ) << QStringLiteral( "Cake" ) ) ); + QCOMPARE( QgsExpression( "array_sort(array('Banana','Cake','Apple'),false)" ).evaluate( &context ), QVariant( QVariantList() << QStringLiteral( "Cake" ) << QStringLiteral( "Banana" ) << QStringLiteral( "Apple" ) ) ); } void eval_int_array() @@ -4455,8 +4437,8 @@ class TestQgsExpression: public QObject QCOMPARE( QgsExpression( "array_remove_all(array(1, 2, 3, 4, 3), '3')" ).evaluate( &context ), QVariant( removeAllExpected ) ); QCOMPARE( QgsExpression( "array_remove_all(NULL, 3)" ).evaluate( &context ), QVariant() ); - QCOMPARE( QgsExpression( "array_remove_all(array(1, NULL, 3, NULL, 3), 3)" ).evaluate( &context ), QVariantList( {1, QVariant(), QVariant()} ) ); - QCOMPARE( QgsExpression( "array_remove_all(array(1, NULL, 3, NULL, 3), NULL)" ).evaluate( &context ), QVariantList( {1, 3, 3 } ) ); + QCOMPARE( QgsExpression( "array_remove_all(array(1, NULL, 3, NULL, 3), 3)" ).evaluate( &context ), QVariantList( { 1, QVariant(), QVariant() } ) ); + QCOMPARE( QgsExpression( "array_remove_all(array(1, NULL, 3, NULL, 3), NULL)" ).evaluate( &context ), QVariantList( { 1, 3, 3 } ) ); QVariantList concatExpected = array; concatExpected << 56 << 57; @@ -4613,10 +4595,9 @@ class TestQgsExpression: public QObject QVERIFY( badMap.hasEvalError() ); QCOMPARE( badMap.evalErrorString(), QString( "Cannot convert 'not a map' to map" ) ); - QCOMPARE( QgsExpression( QStringLiteral( "map_prefix_keys(map('1', 'one', '2', 'two'), 'prefix-')" ) ).evaluate( &context ), QVariantMap( {{ "prefix-1", "one" }, { "prefix-2", "two" }} ) ); + QCOMPARE( QgsExpression( QStringLiteral( "map_prefix_keys(map('1', 'one', '2', 'two'), 'prefix-')" ) ).evaluate( &context ), QVariantMap( { { "prefix-1", "one" }, { "prefix-2", "two" } } ) ); QCOMPARE( QgsExpression( QStringLiteral( "map_prefix_keys(map(), 'prefix-')" ) ).evaluate( &context ), QVariantMap() ); QCOMPARE( QgsExpression( QStringLiteral( "map_prefix_keys([], 'prefix-')" ) ).evaluate( &context ), QVariant() ); - } void expression_from_expression_data() @@ -4659,7 +4640,7 @@ class TestQgsExpression: public QObject QCOMPARE( QgsExpression::quotedValue( QVariant(), QMetaType::Type::QString ), QString( "NULL" ) ); QVariantList array = QVariantList() << QVariant( 1 ) << QVariant( "a" ) << QVariant(); QCOMPARE( QgsExpression::quotedValue( array ), QString( "array( 1, 'a', NULL )" ) ); - QCOMPARE( QgsExpression::quotedValue( QStringList( { QStringLiteral( "abc" ), QStringLiteral( "def" )} ) ), QString( "array( 'abc', 'def' )" ) ); + QCOMPARE( QgsExpression::quotedValue( QStringList( { QStringLiteral( "abc" ), QStringLiteral( "def" ) } ) ), QString( "array( 'abc', 'def' )" ) ); } void reentrant() @@ -4693,10 +4674,8 @@ class TestQgsExpression: public QObject void test_expressionToLayerFieldIndex() { - std::unique_ptr layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); - layer->dataProvider()->addAttributes( { QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), - QgsField( QStringLiteral( "another FIELD" ), QMetaType::Type::QString ) - } ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); + layer->dataProvider()->addAttributes( { QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), QgsField( QStringLiteral( "another FIELD" ), QMetaType::Type::QString ) } ); layer->updateFields(); QCOMPARE( QgsExpression::expressionToLayerFieldIndex( "", layer.get() ), -1 ); @@ -4720,10 +4699,8 @@ class TestQgsExpression: public QObject void test_quoteFieldExpression() { - std::unique_ptr layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); - layer->dataProvider()->addAttributes( { QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), - QgsField( QStringLiteral( "another FIELD" ), QMetaType::Type::QString ) - } ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); + layer->dataProvider()->addAttributes( { QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), QgsField( QStringLiteral( "another FIELD" ), QMetaType::Type::QString ) } ); layer->updateFields(); QCOMPARE( QgsExpression::quoteFieldExpression( QString(), layer.get() ), QString() ); @@ -4870,8 +4847,7 @@ class TestQgsExpression: public QObject const QString pointsLayerName = mPointsLayer->name(); bool testOk = false; - auto runTest = [weakPointer, rawPointer, pointsLayerId, pointsLayerName, this, &testOk] - { + auto runTest = [weakPointer, rawPointer, pointsLayerId, pointsLayerName, this, &testOk] { testOk = false; QgsExpression exp; // NULL value @@ -4882,7 +4858,7 @@ class TestQgsExpression: public QObject QVERIFY( !exp.hasEvalError() ); // value which CANNOT be a map layer - res = QgsExpressionUtils::getMapLayer( QVariant( 5 ), &context, &exp ); + res = QgsExpressionUtils::getMapLayer( QVariant( 5 ), &context, &exp ); QVERIFY( !res ); #if 0 // TODO probably **should** raise an eval error for this situation? @@ -4891,7 +4867,7 @@ class TestQgsExpression: public QObject // with weak map layer pointer exp = QgsExpression(); - res = QgsExpressionUtils::getMapLayer( QVariant::fromValue( weakPointer ), &context, &exp ); + res = QgsExpressionUtils::getMapLayer( QVariant::fromValue( weakPointer ), &context, &exp ); QCOMPARE( res, mPointsLayer ); QVERIFY( !exp.hasEvalError() ); @@ -5045,13 +5021,11 @@ class TestQgsExpression: public QObject const QString pointsLayerName = mPointsLayer->name(); bool testOk = false; - auto runTest = [weakPointer, rawPointer, pointsLayerId, pointsLayerName, &testOk] - { + auto runTest = [weakPointer, rawPointer, pointsLayerId, pointsLayerName, &testOk] { testOk = false; QString gotLayerId; - auto lambda = [&gotLayerId]( QgsMapLayer * layer ) - { + auto lambda = [&gotLayerId]( QgsMapLayer *layer ) { if ( layer ) gotLayerId = layer->id(); else @@ -5073,7 +5047,7 @@ class TestQgsExpression: public QObject QVERIFY( gotLayerId.isEmpty() ); // with weak map layer pointer - QgsExpressionUtils::executeLambdaForMapLayer( QVariant::fromValue( weakPointer ), &context, &exp, lambda, foundLayer ); + QgsExpressionUtils::executeLambdaForMapLayer( QVariant::fromValue( weakPointer ), &context, &exp, lambda, foundLayer ); QVERIFY( foundLayer ); QCOMPARE( gotLayerId, pointsLayerId ); @@ -5161,13 +5135,15 @@ class TestQgsExpression: public QObject foundLayer = false; gotLayerId.clear(); - QgsExpressionUtils::executeLambdaForMapLayer( layer2->name(), &context, &exp, lambda, foundLayer );; + QgsExpressionUtils::executeLambdaForMapLayer( layer2->name(), &context, &exp, lambda, foundLayer ); + ; QVERIFY( foundLayer ); QCOMPARE( gotLayerId, layer2->id() ); foundLayer = false; gotLayerId.clear(); - QgsExpressionUtils::executeLambdaForMapLayer( layer3->name(), &context, &exp, lambda, foundLayer );; + QgsExpressionUtils::executeLambdaForMapLayer( layer3->name(), &context, &exp, lambda, foundLayer ); + ; QVERIFY( foundLayer ); QCOMPARE( gotLayerId, layer3->id() ); @@ -5204,14 +5180,14 @@ class TestQgsExpression: public QObject QVERIFY( !exp.hasEvalError() ); // value which CANNOT be a file path - path = QgsExpressionUtils::getFilePathValue( QVariant::fromValue( QgsGeometry() ), &context, &exp ); + path = QgsExpressionUtils::getFilePathValue( QVariant::fromValue( QgsGeometry() ), &context, &exp ); QVERIFY( path.isEmpty() ); QVERIFY( exp.hasEvalError() ); QCOMPARE( exp.evalErrorString(), QStringLiteral( "Cannot convert value to a file path" ) ); // good value exp = QgsExpression(); - path = QgsExpressionUtils::getFilePathValue( QVariant::fromValue( QStringLiteral( "/home/me/mine.txt" ) ), &context, &exp ); + path = QgsExpressionUtils::getFilePathValue( QVariant::fromValue( QStringLiteral( "/home/me/mine.txt" ) ), &context, &exp ); QCOMPARE( path, QStringLiteral( "/home/me/mine.txt" ) ); QVERIFY( !exp.hasEvalError() ); @@ -5282,8 +5258,7 @@ class TestQgsExpression: public QObject QStringList stringList; stringList << QStringLiteral( "One" ) << QStringLiteral( "Two" ) << QStringLiteral( "A very long string that is going to be truncated" ); - QCOMPARE( QgsExpression::formatPreviewString( QVariant( stringList ) ), - QStringLiteral( "[ 'One', 'Two', 'A very long string that is going to be tr… ]" ) ); + QCOMPARE( QgsExpression::formatPreviewString( QVariant( stringList ) ), QStringLiteral( "[ 'One', 'Two', 'A very long string that is going to be tr… ]" ) ); QColor color = QColor::fromRgbF( 1., 0.5f, 0.25f, 0.1f ); QCOMPARE( QgsExpression::formatPreviewString( QVariant( color ) ), "RGBA: 1.00,0.50,0.25,0.10" ); @@ -5329,7 +5304,6 @@ class TestQgsExpression: public QObject QCOMPARE( QgsExpression::formatPreviewString( t_double ), QStringLiteral( "12.345,001" ) ); QLocale::setDefault( QLocale::English ); - } void test_nowStatic() @@ -5578,16 +5552,16 @@ class TestQgsExpression: public QObject QTest::newRow( "one IN expression" ) << ( QStringList() << QStringLiteral( "field IN ('value', 'value2')" ) ) << true << "\"field\" IN ('value','value2')"; QTest::newRow( "one NOT IN expression" ) << ( QStringList() << QStringLiteral( "field NOT IN ('value', 'value2')" ) ) << false << "\"field\" NOT IN ('value','value2')"; QTest::newRow( "one IN expression non-literal" ) << ( QStringList() << QStringLiteral( "field IN ('value', 'value2', \"a field\")" ) ) << false << QString(); - QTest::newRow( "two expressions" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field = 'value2'" ) ) << true << "\"field\" IN ('value','value2')"; - QTest::newRow( "two expressions with IN" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field IN ('value2', 'value3')" ) ) << true << "\"field\" IN ('value','value2','value3')"; - QTest::newRow( "two expressions with a not IN" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field NOT IN ('value2', 'value3')" ) ) << false << QString(); - QTest::newRow( "two expressions with IN not literal" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field IN ('value2', 'value3', \"a field\")" ) ) << false << QString(); - QTest::newRow( "two expressions with IN different field" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field2 IN ('value2', 'value3')" ) ) << false << QString(); - QTest::newRow( "two expressions first not equality" ) << ( QStringList() << QStringLiteral( "field <>'value'" ) << QStringLiteral( "field == 'value2'" ) ) << false << "\"field\""; - QTest::newRow( "two expressions second not equality" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field <> 'value2'" ) ) << false << "\"field\""; - QTest::newRow( "three expressions" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field = 'value2'" ) << QStringLiteral( "field = 'value3'" ) ) << true << "\"field\" IN ('value','value2','value3')"; - QTest::newRow( "three expressions with IN" ) << ( QStringList() << QStringLiteral( "field IN ('v1', 'v2')" ) << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field = 'value2'" ) << QStringLiteral( "field = 'value3'" ) ) << true << "\"field\" IN ('v1','v2','value','value2','value3')"; - QTest::newRow( "three expressions different fields" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field2 = 'value2'" ) << QStringLiteral( "\"field\" = 'value3'" ) ) << false << "field"; + QTest::newRow( "two expressions" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field = 'value2'" ) ) << true << "\"field\" IN ('value','value2')"; + QTest::newRow( "two expressions with IN" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field IN ('value2', 'value3')" ) ) << true << "\"field\" IN ('value','value2','value3')"; + QTest::newRow( "two expressions with a not IN" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field NOT IN ('value2', 'value3')" ) ) << false << QString(); + QTest::newRow( "two expressions with IN not literal" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field IN ('value2', 'value3', \"a field\")" ) ) << false << QString(); + QTest::newRow( "two expressions with IN different field" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field2 IN ('value2', 'value3')" ) ) << false << QString(); + QTest::newRow( "two expressions first not equality" ) << ( QStringList() << QStringLiteral( "field <>'value'" ) << QStringLiteral( "field == 'value2'" ) ) << false << "\"field\""; + QTest::newRow( "two expressions second not equality" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field <> 'value2'" ) ) << false << "\"field\""; + QTest::newRow( "three expressions" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field = 'value2'" ) << QStringLiteral( "field = 'value3'" ) ) << true << "\"field\" IN ('value','value2','value3')"; + QTest::newRow( "three expressions with IN" ) << ( QStringList() << QStringLiteral( "field IN ('v1', 'v2')" ) << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field = 'value2'" ) << QStringLiteral( "field = 'value3'" ) ) << true << "\"field\" IN ('v1','v2','value','value2','value3')"; + QTest::newRow( "three expressions different fields" ) << ( QStringList() << QStringLiteral( "field = 'value'" ) << QStringLiteral( "field2 = 'value2'" ) << QStringLiteral( "\"field\" = 'value3'" ) ) << false << "field"; } void testAttemptReduceToInClause() @@ -5625,7 +5599,6 @@ class TestQgsExpression: public QObject QTest::newRow( "no reduction 1" ) << QStringLiteral( "field = 'value' OR field2 = 'value2'" ) << QStringLiteral( "field = 'value' OR field2 = 'value2'" ); // this could theoretically be reduced, but we don't currently support this QTest::newRow( "no reduction 2" ) << QStringLiteral( "field = 'value' OR field != 'value2' OR field = 'value3'" ) << QStringLiteral( "field = 'value' OR field <> 'value2' OR field = 'value3'" ); - } void testCollapseOrValues() @@ -5648,13 +5621,13 @@ class TestQgsExpression: public QObject QgsExpression exp( QStringLiteral( "attribute(@static_feature, concat('second','_',@field_name_part_var)) + x(geometry( @static_feature ))" ) ); // initially this expression requires all attributes -- we can't determine the referenced columns in advance QCOMPARE( exp.referencedColumns(), QSet() << QgsFeatureRequest::ALL_ATTRIBUTES ); - QCOMPARE( exp.referencedAttributeIndexes( fields ), QSet< int >() << 0 << 1 ); + QCOMPARE( exp.referencedAttributeIndexes( fields ), QSet() << 0 << 1 ); QCOMPARE( exp.referencedFunctions(), QSet() << QStringLiteral( "attribute" ) << QStringLiteral( "concat" ) << QStringLiteral( "geometry" ) << QStringLiteral( "x" ) << QStringLiteral( "var" ) ); QCOMPARE( exp.referencedVariables(), QSet() << QStringLiteral( "field_name_part_var" ) << QStringLiteral( "static_feature" ) ); // prepare the expression using static variables QgsExpressionContext context; - std::unique_ptr< QgsExpressionContextScope > scope = std::make_unique< QgsExpressionContextScope >(); + std::unique_ptr scope = std::make_unique(); scope->setVariable( QStringLiteral( "field_name_part_var" ), QStringLiteral( "field" ), true ); // this feature gets added as a static variable, to emulate eg the @atlas_feature variable @@ -5665,7 +5638,7 @@ class TestQgsExpression: public QObject context.appendScope( scope.release() ); - QVERIFY( exp.prepare( & context ) ); + QVERIFY( exp.prepare( &context ) ); // because all parts of the expression are static, the root node should have a cached static value! QVERIFY( exp.rootNode()->hasCachedStaticValue() ); QCOMPARE( exp.rootNode()->cachedStaticValue().toInt(), 37 ); @@ -5688,13 +5661,13 @@ class TestQgsExpression: public QObject fields2.append( QgsField( QStringLiteral( "another_field" ), QMetaType::Type::Int ) ); context.setFields( fields2 ); - QVERIFY( exp2.prepare( & context ) ); + QVERIFY( exp2.prepare( &context ) ); // because NOT all parts of the expression are static, the root node should NOT have a cached static value! QVERIFY( !exp2.rootNode()->hasCachedStaticValue() ); // but the only referenced column should be "another_field", because the first half of the expression with the "attribute" function is static and has been precomputed QCOMPARE( exp2.referencedColumns(), QSet() << QStringLiteral( "another_field" ) ); - QCOMPARE( exp2.referencedAttributeIndexes( fields2 ), QSet< int >() << 0 ); + QCOMPARE( exp2.referencedAttributeIndexes( fields2 ), QSet() << 0 ); QCOMPARE( exp2.referencedFunctions(), QSet() << QStringLiteral( "attribute" ) << QStringLiteral( "concat" ) << QStringLiteral( "geometry" ) << QStringLiteral( "x" ) << QStringLiteral( "var" ) ); QCOMPARE( exp2.referencedVariables(), QSet() << QStringLiteral( "field_name_part_var" ) << QStringLiteral( "static_feature" ) ); } @@ -5827,7 +5800,7 @@ class TestQgsExpression: public QObject QVERIFY( exp.prepare( &context ) ); QVERIFY( !exp.rootNode()->hasCachedStaticValue() ); QCOMPARE( exp.rootNode()->effectiveNode()->nodeType(), QgsExpressionNode::NodeType::ntColumnRef ); - QCOMPARE( qgis::down_cast< const QgsExpressionNodeColumnRef * >( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "first_field" ) ); + QCOMPARE( qgis::down_cast( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "first_field" ) ); QCOMPARE( exp.evaluate( &context ).toInt(), 11 ); // first condition is static AND false, second is static AND true, so we can effectively replace the entire node with the THEN expression of the second condition @@ -5835,7 +5808,7 @@ class TestQgsExpression: public QObject QVERIFY( exp.prepare( &context ) ); QVERIFY( !exp.rootNode()->hasCachedStaticValue() ); QCOMPARE( exp.rootNode()->effectiveNode()->nodeType(), QgsExpressionNode::NodeType::ntColumnRef ); - QCOMPARE( qgis::down_cast< const QgsExpressionNodeColumnRef * >( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "second_field" ) ); + QCOMPARE( qgis::down_cast( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "second_field" ) ); QCOMPARE( exp.evaluate( &context ).toInt(), 20 ); // first two conditions are static AND false, so we can effectively replace the entire node with the ELSE expression @@ -5843,7 +5816,7 @@ class TestQgsExpression: public QObject QVERIFY( exp.prepare( &context ) ); QVERIFY( !exp.rootNode()->hasCachedStaticValue() ); QCOMPARE( exp.rootNode()->effectiveNode()->nodeType(), QgsExpressionNode::NodeType::ntColumnRef ); - QCOMPARE( qgis::down_cast< const QgsExpressionNodeColumnRef * >( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "third_field" ) ); + QCOMPARE( qgis::down_cast( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "third_field" ) ); QCOMPARE( exp.evaluate( &context ).toInt(), 300 ); // slightly more complex -- second condition is static and TRUE, but uses a more complicated THEN node @@ -5851,8 +5824,8 @@ class TestQgsExpression: public QObject QVERIFY( exp.prepare( &context ) ); QVERIFY( !exp.rootNode()->hasCachedStaticValue() ); QCOMPARE( exp.rootNode()->effectiveNode()->nodeType(), QgsExpressionNode::NodeType::ntBinaryOperator ); - QCOMPARE( qgis::down_cast< const QgsExpressionNodeBinaryOperator * >( exp.rootNode()->effectiveNode() )->opLeft()->nodeType(), QgsExpressionNode::NodeType::ntFunction ); - QCOMPARE( qgis::down_cast< const QgsExpressionNodeBinaryOperator * >( exp.rootNode()->effectiveNode() )->opRight()->nodeType(), QgsExpressionNode::NodeType::ntColumnRef ); + QCOMPARE( qgis::down_cast( exp.rootNode()->effectiveNode() )->opLeft()->nodeType(), QgsExpressionNode::NodeType::ntFunction ); + QCOMPARE( qgis::down_cast( exp.rootNode()->effectiveNode() )->opRight()->nodeType(), QgsExpressionNode::NodeType::ntColumnRef ); QCOMPARE( exp.evaluate( &context ).toInt(), 2011 ); // EVEN more complex -- second condition is static and TRUE, and uses a nested CASE as the THEN node @@ -5861,7 +5834,7 @@ class TestQgsExpression: public QObject QVERIFY( exp.prepare( &context ) ); QVERIFY( !exp.rootNode()->hasCachedStaticValue() ); QCOMPARE( exp.rootNode()->effectiveNode()->nodeType(), QgsExpressionNode::NodeType::ntColumnRef ); - QCOMPARE( qgis::down_cast< const QgsExpressionNodeColumnRef * >( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "second_field" ) ); + QCOMPARE( qgis::down_cast( exp.rootNode()->effectiveNode() )->name(), QStringLiteral( "second_field" ) ); QCOMPARE( exp.evaluate( &context ).toInt(), 20 ); } @@ -5987,7 +5960,6 @@ class TestQgsExpression: public QObject QVERIFY( exp.prepare( &context ) ); QVERIFY( !exp.hasEvalError() ); QCOMPARE( exp.evaluate( &context ).toString(), QStringLiteral( "RasterRaster" ) ); - } void testHelpExamples() @@ -5995,9 +5967,9 @@ class TestQgsExpression: public QObject // trigger initialization of function help QgsExpression::helpText( QString() ); const HelpTextHash &functionHelp = QgsExpression::functionHelpTexts(); - for ( auto helpIt = functionHelp.constBegin(); helpIt != functionHelp.constEnd(); ++ helpIt ) + for ( auto helpIt = functionHelp.constBegin(); helpIt != functionHelp.constEnd(); ++helpIt ) { -#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR<11 +#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 11 if ( helpIt->mName == QLatin1String( "concave_hull" ) ) continue; #endif @@ -6012,14 +5984,11 @@ class TestQgsExpression: public QObject const QString plainTextExpression = sourceDoc.toPlainText(); QgsExpression exampleExpression( plainTextExpression ); - QVERIFY2( !exampleExpression.hasParserError(), - QStringLiteral( "Expression: %1 for %2 has parser error" ).arg( plainTextExpression, - helpIt->mName ).toLocal8Bit() ); + QVERIFY2( !exampleExpression.hasParserError(), QStringLiteral( "Expression: %1 for %2 has parser error" ).arg( plainTextExpression, helpIt->mName ).toLocal8Bit() ); } } } } - }; QGSTEST_MAIN( TestQgsExpression ) diff --git a/tests/src/core/testqgsexpressioncontext.cpp b/tests/src/core/testqgsexpressioncontext.cpp index ec4db0ba5a80..6709fa22db3b 100644 --- a/tests/src/core/testqgsexpressioncontext.cpp +++ b/tests/src/core/testqgsexpressioncontext.cpp @@ -32,10 +32,10 @@ class TestQgsExpressionContext : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void contextScope(); void contextScopeCopy(); void contextScopeFunctions(); @@ -64,7 +64,6 @@ class TestQgsExpressionContext : public QObject void uniqueHash(); private: - class GetTestValueFunction : public QgsScopedExpressionFunction { public: @@ -80,7 +79,6 @@ class TestQgsExpressionContext : public QObject { return new GetTestValueFunction(); } - }; class GetTestValueFunction2 : public QgsScopedExpressionFunction @@ -133,7 +131,6 @@ class TestQgsExpressionContext : public QObject } private: - int *mVal = nullptr; }; }; @@ -156,12 +153,10 @@ void TestQgsExpressionContext::cleanupTestCase() void TestQgsExpressionContext::init() { - } void TestQgsExpressionContext::cleanup() { - } void TestQgsExpressionContext::contextScope() @@ -225,7 +220,6 @@ void TestQgsExpressionContext::contextScope() scope.setHiddenVariables( hiddenVariables ); QCOMPARE( scope.hiddenVariables().length(), 3 ); - } void TestQgsExpressionContext::contextScopeCopy() @@ -336,7 +330,7 @@ void TestQgsExpressionContext::contextStack() QCOMPARE( filteredNames.at( 1 ), QString( "test2" ) ); //test scopes method - const QList< QgsExpressionContextScope *> scopes = context.scopes(); + const QList scopes = context.scopes(); QCOMPARE( scopes.length(), 2 ); QCOMPARE( scopes.at( 0 ), scope1 ); QCOMPARE( scopes.at( 1 ), scope2 ); @@ -669,7 +663,7 @@ void TestQgsExpressionContext::globalScope() //test removeGlobalVariables QgsExpressionContextUtils::setGlobalVariable( QStringLiteral( "key" ), "value" ); - std::unique_ptr< QgsExpressionContextScope > globalScope3( QgsExpressionContextUtils::globalScope() ); + std::unique_ptr globalScope3( QgsExpressionContextUtils::globalScope() ); QVERIFY( globalScope3->hasVariable( "key" ) ); QgsExpressionContextUtils::removeGlobalVariable( QStringLiteral( "key" ) ); globalScope3.reset( QgsExpressionContextUtils::globalScope() ); @@ -703,7 +697,7 @@ void TestQgsExpressionContext::projectScope() QCOMPARE( context.variable( "project_title" ).toString(), QStringLiteral( "project title" ) ); QCOMPARE( context.variable( "project_author" ).toString(), QStringLiteral( "project author" ) ); QCOMPARE( context.variable( "project_abstract" ).toString(), QStringLiteral( "project abstract" ) ); - QCOMPARE( context.variable( "project_creation_date" ).toDateTime(), QDateTime( QDate( 2011, 3, 5 ), QTime( 9, 5, 4 ) ) ); + QCOMPARE( context.variable( "project_creation_date" ).toDateTime(), QDateTime( QDate( 2011, 3, 5 ), QTime( 9, 5, 4 ) ) ); QCOMPARE( context.variable( "project_identifier" ).toString(), QStringLiteral( "project identifier" ) ); QVariantMap keywordsExpected; keywordsExpected.insert( QStringLiteral( "voc1" ), QStringList() << "a" << "b" ); @@ -730,25 +724,25 @@ void TestQgsExpressionContext::projectScope() project.addMapLayer( vectorLayer ); QgsExpressionContextScope *projectScope = QgsExpressionContextUtils::projectScope( &project ); QCOMPARE( projectScope->variable( "layers" ).toList().size(), 1 ); - QCOMPARE( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 0 ) ), vectorLayer ); + QCOMPARE( qvariant_cast( projectScope->variable( "layers" ).toList().at( 0 ) ), vectorLayer ); QCOMPARE( projectScope->variable( "layer_ids" ).toList().size(), 1 ); QVERIFY( projectScope->variable( "layer_ids" ).toList().contains( vectorLayer->id() ) ); delete projectScope; project.addMapLayer( vectorLayer2 ); projectScope = QgsExpressionContextUtils::projectScope( &project ); QCOMPARE( projectScope->variable( "layers" ).toList().size(), 2 ); - QVERIFY( project.mapLayers().values().contains( qobject_cast< QgsMapLayer * >( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 0 ) ) ) ) ); - QVERIFY( project.mapLayers().values().contains( qobject_cast< QgsMapLayer * >( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 1 ) ) ) ) ); + QVERIFY( project.mapLayers().values().contains( qobject_cast( qvariant_cast( projectScope->variable( "layers" ).toList().at( 0 ) ) ) ) ); + QVERIFY( project.mapLayers().values().contains( qobject_cast( qvariant_cast( projectScope->variable( "layers" ).toList().at( 1 ) ) ) ) ); QCOMPARE( projectScope->variable( "layer_ids" ).toList().size(), 2 ); QVERIFY( projectScope->variable( "layer_ids" ).toList().contains( vectorLayer->id() ) ); QVERIFY( projectScope->variable( "layer_ids" ).toList().contains( vectorLayer2->id() ) ); delete projectScope; - project.addMapLayers( QList< QgsMapLayer * >() << vectorLayer3 ); + project.addMapLayers( QList() << vectorLayer3 ); projectScope = QgsExpressionContextUtils::projectScope( &project ); QCOMPARE( projectScope->variable( "layers" ).toList().size(), 3 ); - QVERIFY( project.mapLayers().values().contains( qobject_cast< QgsMapLayer * >( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 0 ) ) ) ) ); - QVERIFY( project.mapLayers().values().contains( qobject_cast< QgsMapLayer * >( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 1 ) ) ) ) ); - QVERIFY( project.mapLayers().values().contains( qobject_cast< QgsMapLayer * >( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 2 ) ) ) ) ); + QVERIFY( project.mapLayers().values().contains( qobject_cast( qvariant_cast( projectScope->variable( "layers" ).toList().at( 0 ) ) ) ) ); + QVERIFY( project.mapLayers().values().contains( qobject_cast( qvariant_cast( projectScope->variable( "layers" ).toList().at( 1 ) ) ) ) ); + QVERIFY( project.mapLayers().values().contains( qobject_cast( qvariant_cast( projectScope->variable( "layers" ).toList().at( 2 ) ) ) ) ); QCOMPARE( projectScope->variable( "layer_ids" ).toList().size(), 3 ); QVERIFY( projectScope->variable( "layer_ids" ).toList().contains( vectorLayer->id() ) ); QVERIFY( projectScope->variable( "layer_ids" ).toList().contains( vectorLayer2->id() ) ); @@ -757,13 +751,13 @@ void TestQgsExpressionContext::projectScope() project.removeMapLayer( vectorLayer ); projectScope = QgsExpressionContextUtils::projectScope( &project ); QCOMPARE( projectScope->variable( "layers" ).toList().size(), 2 ); - QVERIFY( project.mapLayers().values().contains( qobject_cast< QgsMapLayer * >( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 0 ) ) ) ) ); - QVERIFY( project.mapLayers().values().contains( qobject_cast< QgsMapLayer * >( qvariant_cast< QObject * >( projectScope->variable( "layers" ).toList().at( 1 ) ) ) ) ); + QVERIFY( project.mapLayers().values().contains( qobject_cast( qvariant_cast( projectScope->variable( "layers" ).toList().at( 0 ) ) ) ) ); + QVERIFY( project.mapLayers().values().contains( qobject_cast( qvariant_cast( projectScope->variable( "layers" ).toList().at( 1 ) ) ) ) ); QCOMPARE( projectScope->variable( "layer_ids" ).toList().size(), 2 ); QVERIFY( projectScope->variable( "layer_ids" ).toList().contains( vectorLayer2->id() ) ); QVERIFY( projectScope->variable( "layer_ids" ).toList().contains( vectorLayer3->id() ) ); delete projectScope; - project.removeMapLayers( QList< QgsMapLayer * >() << vectorLayer2 << vectorLayer3 ); + project.removeMapLayers( QList() << vectorLayer2 << vectorLayer3 ); projectScope = QgsExpressionContextUtils::projectScope( &project ); QVERIFY( projectScope->variable( "layers" ).toList().isEmpty() ); QVERIFY( projectScope->variable( "layer_ids" ).toList().isEmpty() ); @@ -981,9 +975,9 @@ void TestQgsExpressionContext::description() void TestQgsExpressionContext::readWriteScope() { QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); const QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); @@ -1005,7 +999,7 @@ void TestQgsExpressionContext::readWriteScope() // valid element s2.readXml( e, QgsReadWriteContext() ); QCOMPARE( s2.variableCount(), 2 ); - QCOMPARE( qgis::listToSet( s2.variableNames() ), QSet< QString >() << QStringLiteral( "v1" ) << QStringLiteral( "v2" ) ); + QCOMPARE( qgis::listToSet( s2.variableNames() ), QSet() << QStringLiteral( "v1" ) << QStringLiteral( "v2" ) ); QCOMPARE( s2.variable( QStringLiteral( "v1" ) ).toString(), QStringLiteral( "t1" ) ); QCOMPARE( s2.variable( QStringLiteral( "v2" ) ).toInt(), 55 ); } @@ -1016,16 +1010,16 @@ void TestQgsExpressionContext::layerStores() QVERIFY( scope1->layerStores().isEmpty() ); QgsMapLayerStore store1; - std::unique_ptr< QgsMapLayerStore > store2 = std::make_unique< QgsMapLayerStore >(); + std::unique_ptr store2 = std::make_unique(); scope1->addLayerStore( &store1 ); scope1->addLayerStore( store2.get() ); - QCOMPARE( scope1->layerStores(), QList< QgsMapLayerStore *>( {&store1, store2.get() } ) ); + QCOMPARE( scope1->layerStores(), QList( { &store1, store2.get() } ) ); QgsExpressionContextScope *scope3 = new QgsExpressionContextScope(); QgsMapLayerStore store3; scope3->addLayerStore( &store3 ); - QCOMPARE( scope3->layerStores(), QList< QgsMapLayerStore *>( {&store3 } ) ); + QCOMPARE( scope3->layerStores(), QList( { &store3 } ) ); QgsExpressionContext context; QVERIFY( context.layerStores().isEmpty() ); @@ -1035,17 +1029,17 @@ void TestQgsExpressionContext::layerStores() context.appendScopes( { scope1, scope2, scope3 } ); // stores from scope 3 should take precedence - QCOMPARE( context.layerStores(), QList< QgsMapLayerStore *>( {&store3, &store1, store2.get() } ) ); + QCOMPARE( context.layerStores(), QList( { &store3, &store1, store2.get() } ) ); store2.reset(); - QCOMPARE( context.layerStores(), QList< QgsMapLayerStore *>( {&store3, &store1 } ) ); + QCOMPARE( context.layerStores(), QList( { &store3, &store1 } ) ); QVERIFY( !context.loadedLayerStore() ); QgsMapLayerStore store4; context.setLoadedLayerStore( &store4 ); QCOMPARE( context.loadedLayerStore(), &store4 ); // store4 must also be present in layerStores() - QCOMPARE( context.layerStores(), QList< QgsMapLayerStore *>( {&store3, &store1, &store4 } ) ); + QCOMPARE( context.layerStores(), QList( { &store3, &store1, &store4 } ) ); QgsExpressionContext c2( context ); QCOMPARE( c2.loadedLayerStore(), &store4 ); @@ -1060,7 +1054,7 @@ void TestQgsExpressionContext::uniqueHash() QgsExpressionContext context; bool ok = true; // the actual hash values aren't important, just that they are unique. Feel free to change the expected results accordingly - QSet< QString > vars; + QSet vars; vars.insert( QStringLiteral( "var1" ) ); vars.insert( QStringLiteral( "var2" ) ); QCOMPARE( context.uniqueHash( ok, vars ), QStringLiteral( "var1=||~~||var2=||~~||" ) ); @@ -1084,7 +1078,7 @@ void TestQgsExpressionContext::uniqueHash() feature.setAttributes( QgsAttributes() << 5 << 11 ); context.setFeature( feature ); -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) QCOMPARE( context.uniqueHash( ok, vars ), QStringLiteral( "11||~~||1566||~~||var1=b string||~~||var2=5||~~||" ) ); #else QCOMPARE( context.uniqueHash( ok, vars ), QStringLiteral( "11||~~||18646899||~~||var1=b string||~~||var2=5||~~||" ) ); diff --git a/tests/src/core/testqgsfeature.cpp b/tests/src/core/testqgsfeature.cpp index d65cecbd1aa4..a0f1d61663d0 100644 --- a/tests/src/core/testqgsfeature.cpp +++ b/tests/src/core/testqgsfeature.cpp @@ -25,21 +25,21 @@ #include "qgslinesymbol.h" #include "qgsunsetattributevalue.h" -class TestQgsFeature: public QObject +class TestQgsFeature : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void attributesTest(); //test QgsAttributes + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void attributesTest(); //test QgsAttributes void constructorTest(); //test default constructors void attributesToMap(); void unsetAttributes(); - void create();//test creating a feature - void copy();// test cpy destruction (double delete) + void create(); //test creating a feature + void copy(); // test cpy destruction (double delete) void assignment(); void gettersSetters(); //test getters and setters void attributes(); @@ -52,7 +52,6 @@ class TestQgsFeature: public QObject private: - QgsFields mFields; QgsAttributes mAttrs; QgsGeometry mGeometry; @@ -78,17 +77,14 @@ void TestQgsFeature::initTestCase() void TestQgsFeature::cleanupTestCase() { - } void TestQgsFeature::init() { - } void TestQgsFeature::cleanup() { - } void TestQgsFeature::attributesTest() @@ -141,9 +137,9 @@ void TestQgsFeature::constructorTest() const QgsFeature f2 { QgsFields() }; QVERIFY( FID_IS_NULL( f2.id() ) ); const QgsFeature f3 { 1234 }; - QVERIFY( ! FID_IS_NULL( f3.id() ) ); + QVERIFY( !FID_IS_NULL( f3.id() ) ); const QgsFeature f4 { QgsFields(), 1234 }; - QVERIFY( ! FID_IS_NULL( f4.id() ) ); + QVERIFY( !FID_IS_NULL( f4.id() ) ); } void TestQgsFeature::attributesToMap() @@ -171,7 +167,7 @@ void TestQgsFeature::attributesToMap() void TestQgsFeature::unsetAttributes() { QgsAttributes attr1; - attr1 << QVariant( 5 ) << QVariant() << QVariant( "val" ) << QVariant( QgsUnsetAttributeValue() ) << QVariant( QgsUnsetAttributeValue() ); + attr1 << QVariant( 5 ) << QVariant() << QVariant( "val" ) << QVariant( QgsUnsetAttributeValue() ) << QVariant( QgsUnsetAttributeValue() ); QVERIFY( !attr1.isUnsetValue( 0 ) ); QVERIFY( !attr1.isUnsetValue( 1 ) ); @@ -340,7 +336,7 @@ void TestQgsFeature::geometry() QgsFeature copy( feature ); QCOMPARE( copy.geometry().asWkb(), feature.geometry().asWkb() ); copy.clearGeometry(); - QVERIFY( ! copy.hasGeometry() ); + QVERIFY( !copy.hasGeometry() ); QCOMPARE( feature.geometry().asWkb(), mGeometry.asWkb() ); //test no crash when setting an empty geometry and triggering a detach @@ -369,7 +365,7 @@ void TestQgsFeature::geometry() //setGeometry using abstract geom copy = feature; QCOMPARE( copy.geometry().asWkb(), mGeometry.asWkb() ); - copy.setGeometry( std::make_unique< QgsPoint >( 5, 6 ) ); + copy.setGeometry( std::make_unique( 5, 6 ) ); QCOMPARE( copy.geometry().asWkt(), QStringLiteral( "Point (5 6)" ) ); QCOMPARE( feature.geometry().asWkb(), mGeometry.asWkb() ); diff --git a/tests/src/core/testqgsfeaturerequest.cpp b/tests/src/core/testqgsfeaturerequest.cpp index 85bbd441ba1f..1e69c7651ead 100644 --- a/tests/src/core/testqgsfeaturerequest.cpp +++ b/tests/src/core/testqgsfeaturerequest.cpp @@ -24,7 +24,7 @@ #include "qgssimplifymethod.h" #include "qgsexpressioncontextutils.h" -class TestQgsFeatureRequest: public QObject +class TestQgsFeatureRequest : public QObject { Q_OBJECT @@ -32,37 +32,32 @@ class TestQgsFeatureRequest: public QObject void testDefaultConstructed( const QgsFeatureRequest &f ); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void constructorTest(); //test default constructors - void copyConstructorTest(); //test copy constructor + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void constructorTest(); //test default constructors + void copyConstructorTest(); //test copy constructor void assignmentOperatorTest(); //test copy constructor private: - }; void TestQgsFeatureRequest::initTestCase() { - } void TestQgsFeatureRequest::cleanupTestCase() { - } void TestQgsFeatureRequest::init() { - } void TestQgsFeatureRequest::cleanup() { - } void TestQgsFeatureRequest::testDefaultConstructed( const QgsFeatureRequest &f ) @@ -121,7 +116,7 @@ void TestQgsFeatureRequest::assignmentOperatorTest() f2.setFilterRect( QgsRectangle( 10, 10, 20, 20 ) ); f2.setDistanceWithin( QgsGeometry::fromWkt( "POINT(10 15)" ), 12 ); f2.setFilterFid( 52 ); - f2.setFilterFids( {3, 4} ); + f2.setFilterFids( { 3, 4 } ); f2.setInvalidGeometryCheck( Qgis::InvalidGeometryCheck::SkipInvalid ); f2.setInvalidGeometryCallback( []( const QgsFeature & ) {} ); f2.setFilterExpression( "this not that" ); @@ -130,7 +125,7 @@ void TestQgsFeatureRequest::assignmentOperatorTest() f2.addOrderBy( "someField" ); f2.setLimit( 5 ); f2.setFlags( Qgis::FeatureRequestFlag::NoGeometry ); - f2.setSubsetOfAttributes( {1, 2} ); + f2.setSubsetOfAttributes( { 1, 2 } ); QgsSimplifyMethod sm; sm.setMethodType( QgsSimplifyMethod::PreserveTopology ); f2.setSimplifyMethod( sm ); diff --git a/tests/src/core/testqgsfield.cpp b/tests/src/core/testqgsfield.cpp index 578550919eef..8e5e8f7c9c16 100644 --- a/tests/src/core/testqgsfield.cpp +++ b/tests/src/core/testqgsfield.cpp @@ -27,23 +27,23 @@ #include "qgstest.h" #include "qgsreferencedgeometry.h" -class TestQgsField: public QObject +class TestQgsField : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void create();//test creating a data defined container - void copy();// test cpy destruction (double delete) + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void create(); //test creating a data defined container + void copy(); // test cpy destruction (double delete) void assignment(); void gettersSetters(); //test getters and setters - void isNumeric(); //test isNumeric - void isDateTime(); //test isNumeric - void equality(); //test equality operators - void asVariant(); //test conversion to and from a QVariant + void isNumeric(); //test isNumeric + void isDateTime(); //test isNumeric + void equality(); //test equality operators + void asVariant(); //test conversion to and from a QVariant void displayString(); void convertCompatible(); void dataStream(); @@ -67,7 +67,6 @@ void TestQgsField::initTestCase() void TestQgsField::cleanupTestCase() { - } void TestQgsField::init() @@ -104,7 +103,7 @@ void TestQgsField::copy() original.setReadOnly( true ); original.setSplitPolicy( Qgis::FieldDomainSplitPolicy::GeometryRatio ); original.setDuplicatePolicy( Qgis::FieldDuplicatePolicy::UnsetField ); - original.setMetadata( {{ 1, QStringLiteral( "abc" )}, {2, 5 }} ); + original.setMetadata( { { 1, QStringLiteral( "abc" ) }, { 2, 5 } } ); QVariantMap config; config.insert( QStringLiteral( "a" ), "value_a" ); @@ -132,7 +131,7 @@ void TestQgsField::assignment() original.setReadOnly( true ); original.setSplitPolicy( Qgis::FieldDomainSplitPolicy::GeometryRatio ); original.setDuplicatePolicy( Qgis::FieldDuplicatePolicy::UnsetField ); - original.setMetadata( {{ 1, QStringLiteral( "abc" )}, {2, 5 }} ); + original.setMetadata( { { 1, QStringLiteral( "abc" ) }, { 2, 5 } } ); QgsField copy; copy = original; QVERIFY( copy == original ); @@ -209,17 +208,15 @@ void TestQgsField::gettersSetters() field.setDuplicatePolicy( Qgis::FieldDuplicatePolicy::UnsetField ); QCOMPARE( field.duplicatePolicy(), Qgis::FieldDuplicatePolicy::UnsetField ); - field.setMetadata( {{ static_cast< int >( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" )}, {2, 5 }} ); - QMap< int, QVariant> expected {{ static_cast< int >( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" )}, {2, 5 }}; + field.setMetadata( { { static_cast( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" ) }, { 2, 5 } } ); + QMap expected { { static_cast( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" ) }, { 2, 5 } }; QCOMPARE( field.metadata(), expected ); QVERIFY( !field.metadata( Qgis::FieldMetadataProperty::GeometryWkbType ).isValid() ); QCOMPARE( field.metadata( Qgis::FieldMetadataProperty::GeometryCrs ).toString(), QStringLiteral( "abc" ) ); field.setMetadata( Qgis::FieldMetadataProperty::GeometryWkbType, QStringLiteral( "def" ) ); QCOMPARE( field.metadata( Qgis::FieldMetadataProperty::GeometryWkbType ).toString(), QStringLiteral( "def" ) ); - expected = QMap< int, QVariant> {{ static_cast< int >( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" )}, {2, 5 } - , {static_cast( Qgis::FieldMetadataProperty::GeometryWkbType ), QStringLiteral( "def" ) } - }; + expected = QMap { { static_cast( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" ) }, { 2, 5 }, { static_cast( Qgis::FieldMetadataProperty::GeometryWkbType ), QStringLiteral( "def" ) } }; QCOMPARE( field.metadata(), expected ); } @@ -281,7 +278,7 @@ void TestQgsField::equality() field1.setLength( 5 ); field1.setPrecision( 2 ); field1.setTypeName( QStringLiteral( "typename1" ) ); //typename is NOT required for equality - field1.setComment( QStringLiteral( "comment1" ) ); //comment is NOT required for equality + field1.setComment( QStringLiteral( "comment1" ) ); //comment is NOT required for equality QgsFieldConstraints constraints; constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); field1.setConstraints( constraints ); @@ -291,7 +288,7 @@ void TestQgsField::equality() field2.setLength( 5 ); field2.setPrecision( 2 ); field2.setTypeName( QStringLiteral( "typename2" ) ); //typename is NOT required for equality - field2.setComment( QStringLiteral( "comment2" ) ); //comment is NOT required for equality + field2.setComment( QStringLiteral( "comment2" ) ); //comment is NOT required for equality constraints = field2.constraints(); constraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintOriginProvider ); field2.setConstraints( constraints ); @@ -370,10 +367,10 @@ void TestQgsField::equality() field2.setDuplicatePolicy( Qgis::FieldDuplicatePolicy::UnsetField ); QVERIFY( field1 == field2 ); - field1.setMetadata( {{ static_cast< int >( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" )}, {2, 5 }} ); + field1.setMetadata( { { static_cast( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" ) }, { 2, 5 } } ); QVERIFY( !( field1 == field2 ) ); QVERIFY( field1 != field2 ); - field2.setMetadata( {{ static_cast< int >( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" )}, {2, 5 }} ); + field2.setMetadata( { { static_cast( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" ) }, { 2, 5 } } ); QVERIFY( field1 == field2 ); QVERIFY( !( field1 != field2 ) ); @@ -391,23 +388,22 @@ void TestQgsField::equality() field2.setEditorWidgetSetup( setup2 ); QVERIFY( field1 == field2 ); - setup2 = QgsEditorWidgetSetup{ QStringLiteral( "Text" ), QVariantMap() }; + setup2 = QgsEditorWidgetSetup { QStringLiteral( "Text" ), QVariantMap() }; field2.setEditorWidgetSetup( setup2 ); QVERIFY( field1 != field2 ); - setup1 = QgsEditorWidgetSetup{ QStringLiteral( "Text" ), QVariantMap() }; + setup1 = QgsEditorWidgetSetup { QStringLiteral( "Text" ), QVariantMap() }; field1.setEditorWidgetSetup( setup1 ); QVERIFY( field1 == field2 ); - setup1 = QgsEditorWidgetSetup{ QStringLiteral( "TextEdit" ), QVariantMap{ { QStringLiteral( "a" ), QStringLiteral( "b" ) } } }; - setup2 = QgsEditorWidgetSetup{ QStringLiteral( "TextEdit" ), QVariantMap{ { QStringLiteral( "a" ), QStringLiteral( "b" ) } } }; + setup1 = QgsEditorWidgetSetup { QStringLiteral( "TextEdit" ), QVariantMap { { QStringLiteral( "a" ), QStringLiteral( "b" ) } } }; + setup2 = QgsEditorWidgetSetup { QStringLiteral( "TextEdit" ), QVariantMap { { QStringLiteral( "a" ), QStringLiteral( "b" ) } } }; field1.setEditorWidgetSetup( setup1 ); field2.setEditorWidgetSetup( setup2 ); QVERIFY( field1 == field2 ); - setup2 = QgsEditorWidgetSetup{ QStringLiteral( "TextEdit" ), QVariantMap{ { QStringLiteral( "a" ), QStringLiteral( "XXXXXX" ) } } }; + setup2 = QgsEditorWidgetSetup { QStringLiteral( "TextEdit" ), QVariantMap { { QStringLiteral( "a" ), QStringLiteral( "XXXXXX" ) } } }; field2.setEditorWidgetSetup( setup2 ); QVERIFY( field1 != field2 ); - } void TestQgsField::asVariant() @@ -779,7 +775,7 @@ void TestQgsField::convertCompatible() QCOMPARE( stringDouble, QVariant( 1223456.012345 ) ); // This should not convert stringDouble = QVariant( "1.223.456,012345" ); - QVERIFY( ! doubleField.convertCompatible( stringDouble, &error ) ); + QVERIFY( !doubleField.convertCompatible( stringDouble, &error ) ); QCOMPARE( error, QStringLiteral( "Could not convert value \"1.223.456,012345\" to target type \"double\"" ) ); //double with precision @@ -911,7 +907,7 @@ void TestQgsField::convertCompatible() QVERIFY( geometryValue.isNull() ); geometryValue = QVariant::fromValue( QgsGeometry::fromWkt( QStringLiteral( "Point( 1 2 )" ) ) ); QVERIFY( geometryField.convertCompatible( geometryValue ) ); - QCOMPARE( geometryValue.userType(), qMetaTypeId< QgsGeometry>() ); + QCOMPARE( geometryValue.userType(), qMetaTypeId() ); geometryValue = QVariant::fromValue( QgsReferencedGeometry( QgsGeometry::fromWkt( QStringLiteral( "Point( 1 2 )" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) ) ) ); QVERIFY( geometryField.convertCompatible( geometryValue ) ); @@ -919,7 +915,7 @@ void TestQgsField::convertCompatible() geometryValue = QStringLiteral( "LineString( 1 2, 3 4 )" ); QVERIFY( geometryField.convertCompatible( geometryValue ) ); - QCOMPARE( geometryValue.userType(), qMetaTypeId< QgsGeometry>() ); + QCOMPARE( geometryValue.userType(), qMetaTypeId() ); } void TestQgsField::dataStream() @@ -941,7 +937,7 @@ void TestQgsField::dataStream() constraints.setConstraintExpression( QStringLiteral( "constraint expression" ), QStringLiteral( "description" ) ); constraints.setConstraintStrength( QgsFieldConstraints::ConstraintExpression, QgsFieldConstraints::ConstraintStrengthSoft ); original.setConstraints( constraints ); - original.setMetadata( {{ static_cast< int >( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" )}, {2, 5 }} ); + original.setMetadata( { { static_cast( Qgis::FieldMetadataProperty::GeometryCrs ), QStringLiteral( "abc" ) }, { 2, 5 } } ); QByteArray ba; QDataStream ds( &ba, QIODevice::ReadWrite ); @@ -953,7 +949,7 @@ void TestQgsField::dataStream() QCOMPARE( result, original ); QCOMPARE( result.typeName(), original.typeName() ); //typename is NOT required for equality - QCOMPARE( result.comment(), original.comment() ); //comment is NOT required for equality + QCOMPARE( result.comment(), original.comment() ); //comment is NOT required for equality } void TestQgsField::displayName() @@ -1052,18 +1048,18 @@ void TestQgsField::collection() QVariant str( "hello" ); QVERIFY( !field.convertCompatible( str ) ); - QVariant intList = QVariantList( {1, 2, 3 } ); + QVariant intList = QVariantList( { 1, 2, 3 } ); QVERIFY( field.convertCompatible( intList ) ); - QCOMPARE( intList.toList(), QVariantList( {1, 2, 3} ) ); + QCOMPARE( intList.toList(), QVariantList( { 1, 2, 3 } ) ); - QVariant doubleList = QVariantList( {1.1, 2.2, 3.3 } ); + QVariant doubleList = QVariantList( { 1.1, 2.2, 3.3 } ); QVERIFY( field.convertCompatible( doubleList ) ); - QCOMPARE( doubleList.toList(), QVariantList( {1.1, 2.2, 3.3 } ) ); + QCOMPARE( doubleList.toList(), QVariantList( { 1.1, 2.2, 3.3 } ) ); QgsField stringListField( QStringLiteral( "collection" ), QMetaType::Type::QStringList ); str = QVariant( "hello" ); QVERIFY( stringListField.convertCompatible( str ) ); - QCOMPARE( str, QStringList{ QStringLiteral( "hello" )} ); + QCOMPARE( str, QStringList { QStringLiteral( "hello" ) } ); QVariant strList = QVariant( QStringList( { "hello", "there" } ) ); QVERIFY( stringListField.convertCompatible( strList ) ); diff --git a/tests/src/core/testqgsfields.cpp b/tests/src/core/testqgsfields.cpp index fe2a13703573..f24ca8f45bcf 100644 --- a/tests/src/core/testqgsfields.cpp +++ b/tests/src/core/testqgsfields.cpp @@ -20,19 +20,19 @@ #include "qgsfields.h" -class TestQgsFields: public QObject +class TestQgsFields : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void create();//test creating a data defined container - void copy();// test cpy destruction (double delete) + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void create(); //test creating a data defined container + void copy(); // test cpy destruction (double delete) void assignment(); - void equality(); //test equality operators + void equality(); //test equality operators void asVariant(); //test conversion to and from a QVariant void construct(); void clear(); @@ -63,22 +63,18 @@ class TestQgsFields: public QObject void TestQgsFields::initTestCase() { - } void TestQgsFields::cleanupTestCase() { - } void TestQgsFields::init() { - } void TestQgsFields::cleanup() { - } void TestQgsFields::create() @@ -171,12 +167,11 @@ void TestQgsFields::construct() { // construct using a list of fields QgsFields fields( - QList< QgsField > - { - QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), - QgsField( QStringLiteral( "field2" ), QMetaType::Type::Int ), - QgsField( QStringLiteral( "field3" ), QMetaType::Type::Double ), - } + QList { + QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), + QgsField( QStringLiteral( "field2" ), QMetaType::Type::Int ), + QgsField( QStringLiteral( "field3" ), QMetaType::Type::Double ), + } ); QCOMPARE( fields.size(), 3 ); @@ -401,9 +396,9 @@ void TestQgsFields::indexFromName() QCOMPARE( fields.lookupField( QString( "teStFiEld2" ) ), 1 ); //test that fieldNameIndex prefers exact case matches over case insensitive matches - const QgsField sameNameDifferentCase( QStringLiteral( "teStFielD" ) ); //#spellok + const QgsField sameNameDifferentCase( QStringLiteral( "teStFielD" ) ); //#spellok fields.append( sameNameDifferentCase ); - QCOMPARE( fields.lookupField( QString( "teStFielD" ) ), 4 ); //#spellok + QCOMPARE( fields.lookupField( QString( "teStFielD" ) ), 4 ); //#spellok //test that the alias is only matched with fieldNameIndex QCOMPARE( fields.indexFromName( "testfieldAlias" ), -1 ); @@ -500,7 +495,7 @@ void TestQgsFields::dataStream() QCOMPARE( resultFields, originalFields ); QCOMPARE( resultFields.field( 0 ).typeName(), originalFields.field( 0 ).typeName() ); //typename is NOT required for equality - QCOMPARE( resultFields.field( 0 ).comment(), originalFields.field( 0 ).comment() ); //comment is NOT required for equality + QCOMPARE( resultFields.field( 0 ).comment(), originalFields.field( 0 ).comment() ); //comment is NOT required for equality QCOMPARE( resultFields.field( 1 ).typeName(), originalFields.field( 1 ).typeName() ); QCOMPARE( resultFields.field( 1 ).comment(), originalFields.field( 1 ).comment() ); } @@ -596,7 +591,7 @@ void TestQgsFields::constIterator() //test with empty fields QCOMPARE( fields.constBegin(), fields.constEnd() ); - QCOMPARE( const_cast< const QgsFields * >( &fields )->begin(), const_cast< const QgsFields * >( &fields )->end() ); + QCOMPARE( const_cast( &fields )->begin(), const_cast( &fields )->end() ); for ( const QgsField &f : fields ) { Q_UNUSED( f ); @@ -656,13 +651,12 @@ void TestQgsFields::appendList() QgsFields fields; QVERIFY( fields.append( - QList< QgsField > - { - QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), - QgsField( QStringLiteral( "field2" ), QMetaType::Type::Int ), - QgsField( QStringLiteral( "field3" ), QMetaType::Type::Double ), - } - ) ); + QList { + QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ), + QgsField( QStringLiteral( "field2" ), QMetaType::Type::Int ), + QgsField( QStringLiteral( "field3" ), QMetaType::Type::Double ), + } + ) ); QCOMPARE( fields.size(), 3 ); QCOMPARE( fields.at( 0 ).name(), QStringLiteral( "field1" ) ); @@ -680,22 +674,21 @@ void TestQgsFields::appendList() // should be rejected, duplicate field name QVERIFY( !fields.append( - QList< QgsField > - { - QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ) - } - ) ); + QList { + QgsField( QStringLiteral( "field1" ), QMetaType::Type::QString ) + } + ) ); QCOMPARE( fields.size(), 3 ); QVERIFY( fields.append( - QList< QgsField > - { - QgsField( QStringLiteral( "field4" ), QMetaType::Type::QString ), - QgsField( QStringLiteral( "field5" ), QMetaType::Type::Int ), - QgsField( QStringLiteral( "field6" ), QMetaType::Type::Double ), - }, Qgis::FieldOrigin::Join - ) ); + QList { + QgsField( QStringLiteral( "field4" ), QMetaType::Type::QString ), + QgsField( QStringLiteral( "field5" ), QMetaType::Type::Int ), + QgsField( QStringLiteral( "field6" ), QMetaType::Type::Double ), + }, + Qgis::FieldOrigin::Join + ) ); QCOMPARE( fields.size(), 6 ); QCOMPARE( fields.at( 0 ).name(), QStringLiteral( "field1" ) ); diff --git a/tests/src/core/testqgsfilledmarker.cpp b/tests/src/core/testqgsfilledmarker.cpp index d54fdb404cb9..3abfdd062b22 100644 --- a/tests/src/core/testqgsfilledmarker.cpp +++ b/tests/src/core/testqgsfilledmarker.cpp @@ -45,11 +45,12 @@ class TestQgsFilledMarkerSymbol : public QgsTest Q_OBJECT public: - TestQgsFilledMarkerSymbol() : QgsTest( QStringLiteral( "Filled Marker Tests" ), QStringLiteral( "symbol_filledmarker" ) ) {} + TestQgsFilledMarkerSymbol() + : QgsTest( QStringLiteral( "Filled Marker Tests" ), QStringLiteral( "symbol_filledmarker" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void filledMarkerSymbol(); void dataDefinedShape(); @@ -58,7 +59,7 @@ class TestQgsFilledMarkerSymbol : public QgsTest void dataDefinedOpacity(); private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings mMapSettings; QgsVectorLayer *mpPointsLayer = nullptr; @@ -86,8 +87,7 @@ void TestQgsFilledMarkerSymbol::initTestCase() // const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); //setup symbol QgsGradientFillSymbolLayer *gradientFill = new QgsGradientFillSymbolLayer(); @@ -114,7 +114,6 @@ void TestQgsFilledMarkerSymbol::initTestCase() // and is more light weight // mMapSettings.setLayers( QList() << mpPointsLayer ); - } void TestQgsFilledMarkerSymbol::cleanupTestCase() { @@ -162,10 +161,10 @@ void TestQgsFilledMarkerSymbol::bounds() void TestQgsFilledMarkerSymbol::opacityWithDataDefinedColor() { - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor( QColor( 200, 200, 200 ) ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor2( QColor( 0, 0, 0 ) ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'red', 'green')" ) ) ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::SecondaryColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'blue', 'magenta')" ) ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor( QColor( 200, 200, 200 ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor2( QColor( 0, 0, 0 ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'red', 'green')" ) ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::SecondaryColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'blue', 'magenta')" ) ) ); mMarkerSymbol->setOpacity( 0.8 ); // set opacity on both the symbol AND sub symbol to test that both are applied mFilledMarkerLayer->subSymbol()->setOpacity( 0.6 ); @@ -183,18 +182,18 @@ void TestQgsFilledMarkerSymbol::opacityWithDataDefinedColor() void TestQgsFilledMarkerSymbol::dataDefinedOpacity() { - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor( QColor( 200, 200, 200 ) ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor2( QColor( 0, 0, 0 ) ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'red', 'green')" ) ) ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::SecondaryColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'blue', 'magenta')" ) ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor( QColor( 200, 200, 200 ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setColor2( QColor( 0, 0, 0 ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'red', 'green')" ) ) ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::SecondaryColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'blue', 'magenta')" ) ) ); mMarkerSymbol->setDataDefinedProperty( QgsSymbol::Property::Opacity, QgsProperty::fromExpression( QStringLiteral( "if(\"Heading\" > 100, 25, 50)" ) ) ); mMapSettings.setExtent( mpPointsLayer->extent() ); mMapSettings.setOutputDpi( 96 ); const bool result = QGSRENDERMAPSETTINGSCHECK( "filledmarker_ddopacity", "filledmarker_ddopacity", mMapSettings ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty() ); - qgis::down_cast< QgsGradientFillSymbolLayer * >( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::StrokeColor, QgsProperty() ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty() ); + qgis::down_cast( mFilledMarkerLayer->subSymbol()->symbolLayer( 0 ) )->setDataDefinedProperty( QgsSymbolLayer::Property::StrokeColor, QgsProperty() ); mMarkerSymbol->setDataDefinedProperty( QgsSymbol::Property::Opacity, QgsProperty() ); QVERIFY( result ); } diff --git a/tests/src/core/testqgsfontmarker.cpp b/tests/src/core/testqgsfontmarker.cpp index d8fe40430ad4..2002a2344bf3 100644 --- a/tests/src/core/testqgsfontmarker.cpp +++ b/tests/src/core/testqgsfontmarker.cpp @@ -44,11 +44,12 @@ class TestQgsFontMarkerSymbol : public QgsTest Q_OBJECT public: - TestQgsFontMarkerSymbol() : QgsTest( QStringLiteral( "Font Marker Tests" ), QStringLiteral( "symbol_fontmarker" ) ) {} + TestQgsFontMarkerSymbol() + : QgsTest( QStringLiteral( "Font Marker Tests" ), QStringLiteral( "symbol_fontmarker" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void fontMarkerSymbol(); void fontMarkerSymbolStyle(); @@ -60,7 +61,7 @@ class TestQgsFontMarkerSymbol : public QgsTest void massiveFont(); private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings mMapSettings; QgsVectorLayer *mpPointsLayer = nullptr; @@ -89,8 +90,7 @@ void TestQgsFontMarkerSymbol::initTestCase() // const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); //setup symbol mFontMarkerLayer = new QgsFontMarkerSymbolLayer(); @@ -104,7 +104,6 @@ void TestQgsFontMarkerSymbol::initTestCase() // and is more light weight // mMapSettings.setLayers( QList() << mpPointsLayer ); - } void TestQgsFontMarkerSymbol::cleanupTestCase() { diff --git a/tests/src/core/testqgsfontutils.cpp b/tests/src/core/testqgsfontutils.cpp index e2dddc90ff15..eafee46f60c8 100644 --- a/tests/src/core/testqgsfontutils.cpp +++ b/tests/src/core/testqgsfontutils.cpp @@ -21,21 +21,20 @@ #include "qgsapplication.h" #include "qgsfontutils.h" -class TestQgsFontUtils: public QObject +class TestQgsFontUtils : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void xmlMethods(); //test saving and reading from xml - void fromChildNode(); //test reading from child node - void toCss(); //test converting font to CSS + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void xmlMethods(); //test saving and reading from xml + void fromChildNode(); //test reading from child node + void toCss(); //test converting font to CSS private: - }; void TestQgsFontUtils::initTestCase() @@ -51,21 +50,19 @@ void TestQgsFontUtils::cleanupTestCase() void TestQgsFontUtils::init() { - } void TestQgsFontUtils::cleanup() { - } void TestQgsFontUtils::xmlMethods() { //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QFont f1 = QgsFontUtils::getStandardTestFont(); @@ -117,9 +114,9 @@ void TestQgsFontUtils::fromChildNode() { //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QFont f1 = QgsFontUtils::getStandardTestFont(); diff --git a/tests/src/core/testqgsgdalcloudconnection.cpp b/tests/src/core/testqgsgdalcloudconnection.cpp index 3247f433a5ea..e43c4757ee7f 100644 --- a/tests/src/core/testqgsgdalcloudconnection.cpp +++ b/tests/src/core/testqgsgdalcloudconnection.cpp @@ -24,13 +24,12 @@ class TestQgsGdalCloudConnection : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void encodeDecode(); void testConnections(); - }; @@ -58,7 +57,7 @@ void TestQgsGdalCloudConnection::encodeDecode() data.vsiHandler = QStringLiteral( "vsis3" ); data.container = QStringLiteral( "my_container" ); data.rootPath = QStringLiteral( "some/path" ); - data.credentialOptions = QVariantMap{ {"pw", QStringLiteral( "xxxx" )}, {"key", QStringLiteral( "yyy" )} }; + data.credentialOptions = QVariantMap { { "pw", QStringLiteral( "xxxx" ) }, { "key", QStringLiteral( "yyy" ) } }; QCOMPARE( QgsGdalCloudProviderConnection::encodedUri( data ), QStringLiteral( "container=my_container&credentialOptions=key%3Dyyy%7Cpw%3Dxxxx&handler=vsis3&rootPath=some/path" ) ); @@ -82,10 +81,10 @@ void TestQgsGdalCloudConnection::testConnections() data.vsiHandler = QStringLiteral( "vsis3" ); data.container = QStringLiteral( "my_container" ); data.rootPath = QStringLiteral( "some/path" ); - data.credentialOptions = QVariantMap{ {"pw", QStringLiteral( "xxxx" )}, {"key", QStringLiteral( "yyy" )} }; + data.credentialOptions = QVariantMap { { "pw", QStringLiteral( "xxxx" ) }, { "key", QStringLiteral( "yyy" ) } }; QgsGdalCloudProviderConnection::addConnection( QStringLiteral( "my connection" ), data ); - QCOMPARE( QgsGdalCloudProviderConnection::connectionList(), {QStringLiteral( "my connection" )} ); + QCOMPARE( QgsGdalCloudProviderConnection::connectionList(), { QStringLiteral( "my connection" ) } ); QCOMPARE( QgsGdalCloudProviderConnection::connection( QStringLiteral( "my connection" ) ).vsiHandler, QStringLiteral( "vsis3" ) ); QCOMPARE( QgsGdalCloudProviderConnection::connection( QStringLiteral( "my connection" ) ).container, QStringLiteral( "my_container" ) ); @@ -102,7 +101,7 @@ void TestQgsGdalCloudConnection::testConnections() data2.vsiHandler = QStringLiteral( "vsiaz" ); data2.container = QStringLiteral( "some_container" ); data2.rootPath = QStringLiteral( "path" ); - data2.credentialOptions = QVariantMap{ {"pw", QStringLiteral( "zzz" )} }; + data2.credentialOptions = QVariantMap { { "pw", QStringLiteral( "zzz" ) } }; QgsGdalCloudProviderConnection conn2( QgsGdalCloudProviderConnection::encodedUri( data2 ), {} ); QCOMPARE( conn2.uri(), QStringLiteral( "container=some_container&credentialOptions=pw%3Dzzz&handler=vsiaz&rootPath=path" ) ); diff --git a/tests/src/core/testqgsgdalprovider.cpp b/tests/src/core/testqgsgdalprovider.cpp index 7a08aa63af04..140246e6645d 100644 --- a/tests/src/core/testqgsgdalprovider.cpp +++ b/tests/src/core/testqgsgdalprovider.cpp @@ -47,16 +47,17 @@ class TestQgsGdalProvider : public QgsTest Q_OBJECT public: - TestQgsGdalProvider() : QgsTest( QStringLiteral( "GDAL Provider Tests" ) ) {} + TestQgsGdalProvider() + : QgsTest( QStringLiteral( "GDAL Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. - void decodeUri(); // test decode URI implementation - void encodeUri(); // test encode URI implementation + void decodeUri(); // test decode URI implementation + void encodeUri(); // test encode URI implementation void scaleDataType(); //test resultant data types for int raster with float scale (#11573) - void warpedVrt(); //test loading raster which requires a warped vrt + void warpedVrt(); //test loading raster which requires a warped vrt void testVrtAlphaBandRequired(); void testVrtAlphaBandNotRequired(); void noData(); @@ -64,12 +65,12 @@ class TestQgsGdalProvider : public QgsTest void invalidNoDataInSourceIgnored(); void isRepresentableValue(); void mask(); - void bandName(); // test band name based on `gtiff` tags (#7317) - void bandNameNoDescription(); // test band name for when no description or tags available (#16047) + void bandName(); // test band name based on `gtiff` tags (#7317) + void bandNameNoDescription(); // test band name for when no description or tags available (#16047) void bandNameWithDescription(); // test band name for when description available (#16047) void colorTable(); void interactionBetweenRasterChangeAndCache(); // test that updading a raster invalidates the GDAL dataset cache (#20104) - void scale0(); //test when data has scale 0 (#20493) + void scale0(); //test when data has scale 0 (#20493) void transformCoordinates(); void testGdalProviderQuerySublayers(); void testGdalProviderQuerySublayers_NetCDF(); @@ -83,7 +84,6 @@ class TestQgsGdalProvider : public QgsTest QString mTestDataDir; bool mSupportsNetCDF; QgsProviderMetadata *mGdalMetadata; - }; //runs before all tests @@ -97,13 +97,12 @@ void TestQgsGdalProvider::initTestCase() mGdalMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "gdal" ) ); - mSupportsNetCDF = static_cast< bool >( GDALGetDriverByName( "netcdf" ) ); + mSupportsNetCDF = static_cast( GDALGetDriverByName( "netcdf" ) ); // Disable creation of .aux.xml (stats) files during test run, // to avoid modifying .zip files. // See https://github.com/qgis/QGIS/issues/48846 CPLSetConfigOption( "GDAL_PAM_ENABLED", "NO" ); - } //runs after all tests @@ -231,7 +230,7 @@ void TestQgsGdalProvider::scaleDataType() { const QString rasterWithOffset = QStringLiteral( TEST_DATA_DIR ) + "/int_raster_with_scale.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), rasterWithOffset, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); //raster is an integer data type, but has a scale < 1, so data type must be float QCOMPARE( rp->dataType( 1 ), Qgis::DataType::Float32 ); @@ -243,7 +242,7 @@ void TestQgsGdalProvider::warpedVrt() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/requires_warped_vrt.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); qDebug() << "x min: " << rp->extent().xMinimum(); @@ -261,8 +260,8 @@ void TestQgsGdalProvider::warpedVrt() void TestQgsGdalProvider::testVrtAlphaBandRequired() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/rotated_rgb.png"; - std::unique_ptr< QgsDataProvider > provider( QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ) ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider.get() ); + std::unique_ptr provider( QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ) ); + QgsRasterDataProvider *rp = dynamic_cast( provider.get() ); QVERIFY( rp ); QCOMPARE( rp->bandCount(), 4 ); @@ -275,8 +274,8 @@ void TestQgsGdalProvider::testVrtAlphaBandRequired() void TestQgsGdalProvider::testVrtAlphaBandNotRequired() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/72_528t50dgm.txt"; - std::unique_ptr< QgsDataProvider > provider( QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ) ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider.get() ); + std::unique_ptr provider( QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ) ); + QgsRasterDataProvider *rp = dynamic_cast( provider.get() ); QVERIFY( rp ); QGSCOMPARENEAR( rp->extent().xMinimum(), 719975, 0.0001 ); @@ -292,7 +291,7 @@ void TestQgsGdalProvider::noData() const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); QVERIFY( provider->isValid() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); if ( rp ) { @@ -306,7 +305,7 @@ void TestQgsGdalProvider::noDataOutsideExtent() const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); QVERIFY( provider->isValid() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); if ( rp ) { @@ -330,7 +329,7 @@ void TestQgsGdalProvider::invalidNoDataInSourceIgnored() const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/byte_with_nan_nodata.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); QVERIFY( provider->isValid() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); if ( rp ) { @@ -402,7 +401,7 @@ void TestQgsGdalProvider::mask() const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/rgb_with_mask.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); QVERIFY( provider->isValid() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); if ( rp ) { @@ -424,7 +423,7 @@ void TestQgsGdalProvider::bandName() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/gtiff_tags.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); QCOMPARE( rp->generateBandName( 1 ), QStringLiteral( "Band 1: wvln=1.234 (um)" ) ); delete provider; @@ -434,7 +433,7 @@ void TestQgsGdalProvider::bandNameNoDescription() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); QCOMPARE( rp->generateBandName( 1 ), QStringLiteral( "Band 1" ) ); delete provider; @@ -444,7 +443,7 @@ void TestQgsGdalProvider::bandNameWithDescription() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/gtiff_desc.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); QCOMPARE( rp->generateBandName( 1 ), QStringLiteral( "Band 1: 1.234 um" ) ); delete provider; @@ -454,7 +453,7 @@ void TestQgsGdalProvider::colorTable() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); QCOMPARE( rp->colorTable( 1 ).size(), 256 ); // invalid band @@ -464,25 +463,28 @@ void TestQgsGdalProvider::colorTable() void TestQgsGdalProvider::interactionBetweenRasterChangeAndCache() { - double geoTransform[6] = { 0, 2, 0, 0, 0, -2}; + double geoTransform[6] = { 0, 2, 0, 0, 0, -2 }; const QgsCoordinateReferenceSystem crs; const QString filename = QStringLiteral( "/vsimem/temp.tif" ); // Create a all-0 dataset auto provider = QgsRasterDataProvider::create( - QStringLiteral( "gdal" ), filename, "GTiff", 1, Qgis::DataType::Byte, 1, 1, geoTransform, crs ); + QStringLiteral( "gdal" ), filename, "GTiff", 1, Qgis::DataType::Byte, 1, 1, geoTransform, crs + ); delete provider; // Open it - provider = dynamic_cast< QgsRasterDataProvider * >( - QgsProviderRegistry::instance()->createProvider( - QStringLiteral( "gdal" ), filename, QgsDataProvider::ProviderOptions() ) ); + provider = dynamic_cast( + QgsProviderRegistry::instance()->createProvider( + QStringLiteral( "gdal" ), filename, QgsDataProvider::ProviderOptions() + ) + ); QVERIFY( provider ); - auto rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + auto rp = dynamic_cast( provider ); QVERIFY( rp ); // Create a first clone, and destroys it - auto rpClone = dynamic_cast< QgsRasterDataProvider *>( rp->clone() ); + auto rpClone = dynamic_cast( rp->clone() ); QVERIFY( rpClone ); QCOMPARE( rpClone->sample( QgsPointXY( 0.5, -0.5 ), 1 ), 0.0 ); delete rpClone; @@ -498,7 +500,7 @@ void TestQgsGdalProvider::interactionBetweenRasterChangeAndCache() rp->setEditable( false ); // Creates a new clone, and check that we get an updated sample value - rpClone = dynamic_cast< QgsRasterDataProvider *>( rp->clone() ); + rpClone = dynamic_cast( rp->clone() ); QVERIFY( rpClone ); QCOMPARE( rpClone->sample( QgsPointXY( 0.5, -0.5 ), 1 ), 255.0 ); delete rpClone; @@ -511,7 +513,7 @@ void TestQgsGdalProvider::scale0() { const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/scale0ingdal23.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); QCOMPARE( rp->bandScale( 1 ), 1.0 ); QCOMPARE( rp->bandOffset( 1 ), 0.0 ); @@ -523,7 +525,7 @@ void TestQgsGdalProvider::transformCoordinates() // Test implementation of QgsRasterDataProvider::transformCoordinates() const QString raster = QStringLiteral( TEST_DATA_DIR ) + "/float1-16.tif"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( QStringLiteral( "gdal" ), raster, QgsDataProvider::ProviderOptions() ); - QgsRasterDataProvider *rp = dynamic_cast< QgsRasterDataProvider * >( provider ); + QgsRasterDataProvider *rp = dynamic_cast( provider ); QVERIFY( rp ); QVERIFY( rp->isValid() ); @@ -544,13 +546,12 @@ void TestQgsGdalProvider::transformCoordinates() QCOMPARE( pt1Image, QgsPoint( 0, 0, 0 ) ); QCOMPARE( pt2Image, QgsPoint( 4, 0, 0 ) ); QCOMPARE( pt3Image, QgsPoint( 4, 4, 0 ) ); - } void TestQgsGdalProvider::testGdalProviderQuerySublayers() { // invalid uri - QList< QgsProviderSublayerDetails >res = mGdalMetadata->querySublayers( QString() ); + QList res = mGdalMetadata->querySublayers( QString() ); QVERIFY( res.empty() ); // not a raster @@ -569,8 +570,8 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "GTiff" ) ); // make sure result is valid to load layer from - const QgsProviderSublayerDetails::LayerOptions options{ QgsCoordinateTransformContext() }; - std::unique_ptr< QgsRasterLayer > rl( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + const QgsProviderSublayerDetails::LayerOptions options { QgsCoordinateTransformContext() }; + std::unique_ptr rl( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); // geopackage with two raster layers @@ -583,7 +584,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "GPKG" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); QCOMPARE( res.at( 1 ).layerNumber(), 2 ); QCOMPARE( res.at( 1 ).name(), QStringLiteral( "band2" ) ); @@ -592,7 +593,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 1 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 1 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 1 ).driverName(), QStringLiteral( "GPKG" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 1 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 1 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); // geopackage with one raster layer with an identifier res = mGdalMetadata->querySublayers( QStringLiteral( TEST_DATA_DIR ) + "/qgis_server/test_project_wms_grouped_layers.gpkg" ); @@ -615,7 +616,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "AIG" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); // aigrid, pointing to .adf file @@ -628,7 +629,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "AIG" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); // zip archive, only 1 file @@ -642,7 +643,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( sl.providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( sl.type(), Qgis::LayerType::Raster ); QCOMPARE( sl.driverName(), QStringLiteral( "GTiff" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( sl.toLayer( options ) ) ); + rl.reset( qgis::down_cast( sl.toLayer( options ) ) ); QVERIFY( rl->isValid() ); // multi-layer archive @@ -655,7 +656,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "GTiff" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); QCOMPARE( res.at( 1 ).layerNumber(), 1 ); QCOMPARE( res.at( 1 ).name(), QStringLiteral( "landsat_b1.tif" ) ); @@ -664,7 +665,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 1 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 1 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 1 ).driverName(), QStringLiteral( "GTiff" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 1 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 1 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); QCOMPARE( res.at( 2 ).layerNumber(), 1 ); QCOMPARE( res.at( 2 ).name(), QStringLiteral( "landsat_b1.vrt" ) ); @@ -673,7 +674,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 2 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 2 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 2 ).driverName(), QStringLiteral( "VRT" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 2 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 2 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); // multi-layer archive, but with specific suffix specified @@ -686,7 +687,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "GTiff" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); res = mGdalMetadata->querySublayers( QStringLiteral( "/vsitar/" ) + QStringLiteral( TEST_DATA_DIR ) + "/zip/testtar.tgz/landsat_b1.tif" ); QCOMPARE( res.count(), 1 ); @@ -697,7 +698,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "GTiff" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); res = mGdalMetadata->querySublayers( QStringLiteral( "/vsizip/" ) + QStringLiteral( TEST_DATA_DIR ) + "/zip/testzip.zip/landsat_b1.vrt" ); @@ -723,7 +724,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.count(), 4 ); QCOMPARE( res.at( 0 ).layerNumber(), 1 ); QCOMPARE( res.at( 0 ).name(), QStringLiteral( "SENTINEL2_L2A:/vsizip/%1/zip/S2A_MSIL2A_0000.zip/S2A_MSIL2A_0000.SAFE/MTD_MSIL2A.xml:10m:EPSG_32634" ).arg( QStringLiteral( TEST_DATA_DIR ) ) ); -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 9, 0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 9, 0 ) QCOMPARE( res.at( 0 ).description(), QString( "Bands B2, B3, B4, B8, AOT, WVP with 10m resolution, UTM 34N" ) ); #else QCOMPARE( res.at( 0 ).description(), QString( "Bands B2, B3, B4, B8 with 10m resolution, UTM 34N" ) ); @@ -732,7 +733,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "SENTINEL2" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); // tiff with two raster layers and TIFF Tags describing sublayers @@ -745,7 +746,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "GTiff" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); QCOMPARE( res.at( 1 ).layerNumber(), 2 ); QCOMPARE( res.at( 1 ).name(), QStringLiteral( "Test Document Name 2" ) ); @@ -754,20 +755,20 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers() QCOMPARE( res.at( 1 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 1 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 1 ).driverName(), QStringLiteral( "GTiff" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 1 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 1 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); } void TestQgsGdalProvider::testGdalProviderQuerySublayers_NetCDF() { - if ( ! mSupportsNetCDF ) + if ( !mSupportsNetCDF ) { QSKIP( "NetCDF based tests require the netcdf GDAL driver" ); } - QList< QgsProviderSublayerDetails > res; - std::unique_ptr< QgsRasterLayer > rl; - const QgsProviderSublayerDetails::LayerOptions options{ QgsCoordinateTransformContext() }; + QList res; + std::unique_ptr rl; + const QgsProviderSublayerDetails::LayerOptions options { QgsCoordinateTransformContext() }; // netcdf file res = mGdalMetadata->querySublayers( QStringLiteral( TEST_DATA_DIR ) + "/mesh/trap_steady_05_3D.nc" ); @@ -779,7 +780,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers_NetCDF() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "netCDF" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); QCOMPARE( res.at( 1 ).layerNumber(), 2 ); QCOMPARE( res.at( 1 ).name(), QStringLiteral( "layerface_Z" ) ); @@ -788,7 +789,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers_NetCDF() QCOMPARE( res.at( 1 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 1 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 1 ).driverName(), QStringLiteral( "netCDF" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 1 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 1 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); // netcdf with open options @@ -801,7 +802,7 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers_NetCDF() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "netCDF" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 0 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); QCOMPARE( res.at( 1 ).layerNumber(), 2 ); QCOMPARE( res.at( 1 ).name(), QStringLiteral( "layerface_Z" ) ); @@ -810,14 +811,14 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayers_NetCDF() QCOMPARE( res.at( 1 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 1 ).type(), Qgis::LayerType::Raster ); QCOMPARE( res.at( 1 ).driverName(), QStringLiteral( "netCDF" ) ); - rl.reset( qgis::down_cast< QgsRasterLayer * >( res.at( 1 ).toLayer( options ) ) ); + rl.reset( qgis::down_cast( res.at( 1 ).toLayer( options ) ) ); QVERIFY( rl->isValid() ); } void TestQgsGdalProvider::testGdalProviderQuerySublayersFastScan() { // invalid uri - QList< QgsProviderSublayerDetails >res = mGdalMetadata->querySublayers( QString(), Qgis::SublayerQueryFlag::FastScan ); + QList res = mGdalMetadata->querySublayers( QString(), Qgis::SublayerQueryFlag::FastScan ); QVERIFY( res.empty() ); // not a raster @@ -900,19 +901,19 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayersFastScan() void TestQgsGdalProvider::testGdalProviderQuerySublayersFastScan_NetCDF() { - if ( ! mSupportsNetCDF ) + if ( !mSupportsNetCDF ) { QSKIP( "NetCDF based tests require the netcdf GDAL driver" ); } - QList< QgsProviderSublayerDetails > res; - std::unique_ptr< QgsRasterLayer > rl; + QList res; + std::unique_ptr rl; // netcdf file res = mGdalMetadata->querySublayers( - QStringLiteral( TEST_DATA_DIR ) + "/mesh/trap_steady_05_3D.nc", - Qgis::SublayerQueryFlag::FastScan - ); + QStringLiteral( TEST_DATA_DIR ) + "/mesh/trap_steady_05_3D.nc", + Qgis::SublayerQueryFlag::FastScan + ); QCOMPARE( res.count(), 1 ); QCOMPARE( res.at( 0 ).name(), QStringLiteral( "trap_steady_05_3D" ) ); QCOMPARE( res.at( 0 ).uri(), QStringLiteral( TEST_DATA_DIR ) + "/mesh/trap_steady_05_3D.nc" ); @@ -922,16 +923,15 @@ void TestQgsGdalProvider::testGdalProviderQuerySublayersFastScan_NetCDF() // netcdf with open options res = mGdalMetadata->querySublayers( - QStringLiteral( TEST_DATA_DIR ) + "/mesh/trap_steady_05_3D.nc|option:HONOUR_VALID_RANGE=YES", - Qgis::SublayerQueryFlag::FastScan - ); + QStringLiteral( TEST_DATA_DIR ) + "/mesh/trap_steady_05_3D.nc|option:HONOUR_VALID_RANGE=YES", + Qgis::SublayerQueryFlag::FastScan + ); QCOMPARE( res.count(), 1 ); QCOMPARE( res.at( 0 ).name(), QStringLiteral( "trap_steady_05_3D" ) ); QCOMPARE( res.at( 0 ).uri(), QStringLiteral( TEST_DATA_DIR ) + "/mesh/trap_steady_05_3D.nc|option:HONOUR_VALID_RANGE=YES" ); QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "gdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Raster ); QVERIFY( res.at( 0 ).skippedContainerScan() ); - } void TestQgsGdalProvider::testGdalProviderAbsoluteRelativeUri() @@ -957,12 +957,12 @@ void TestQgsGdalProvider::testGdalProviderAbsoluteRelativeUri() void TestQgsGdalProvider::testVsiCredentialOptions() { -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 6, 0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 6, 0 ) // test that credential options are correctly set when layer URI specifies them // if actual aws dataset proves flaky, use this instead: // std::unique_ptr< QgsRasterLayer > rl = std::make_unique< QgsRasterLayer >( QStringLiteral( "/vsis3/testbucket/test|credential:AWS_NO_SIGN_REQUEST=YES|credential:AWS_REGION=eu-central-1|credential:AWS_S3_ENDPOINT=localhost" ), QStringLiteral( "test" ), QStringLiteral( "gdal" ) ); - std::unique_ptr< QgsRasterLayer > rl = std::make_unique< QgsRasterLayer >( QStringLiteral( "/vsis3/cdn.proj.org/us_nga_egm96_15.tif|credential:AWS_NO_SIGN_REQUEST=YES" ), QStringLiteral( "test" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rl = std::make_unique( QStringLiteral( "/vsis3/cdn.proj.org/us_nga_egm96_15.tif|credential:AWS_NO_SIGN_REQUEST=YES" ), QStringLiteral( "test" ), QStringLiteral( "gdal" ) ); // confirm that GDAL VSI configuration options are set QString noSign( VSIGetPathSpecificOption( "/vsis3/cdn.proj.org", "AWS_NO_SIGN_REQUEST", nullptr ) ); @@ -979,7 +979,7 @@ void TestQgsGdalProvider::testVsiCredentialOptions() QCOMPARE( region, QString() ); // credentials should be bucket specific - std::unique_ptr< QgsRasterLayer > rl2 = std::make_unique< QgsRasterLayer >( QStringLiteral( "/vsis3/another/subfolder/subfolder2/test|credential:AWS_NO_SIGN_REQUEST=NO|credential:AWS_REGION=eu-central-2|credential:AWS_S3_ENDPOINT=localhost" ), QStringLiteral( "test" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rl2 = std::make_unique( QStringLiteral( "/vsis3/another/subfolder/subfolder2/test|credential:AWS_NO_SIGN_REQUEST=NO|credential:AWS_REGION=eu-central-2|credential:AWS_S3_ENDPOINT=localhost" ), QStringLiteral( "test" ), QStringLiteral( "gdal" ) ); noSign = QString( VSIGetPathSpecificOption( "/vsis3/cdn.proj.org", "AWS_NO_SIGN_REQUEST", nullptr ) ); QCOMPARE( noSign, QStringLiteral( "YES" ) ); region = QString( VSIGetPathSpecificOption( "/vsis3/cdn.proj.org", "AWS_REGION", nullptr ) ); @@ -1003,7 +1003,7 @@ void TestQgsGdalProvider::testVsiCredentialOptions() void TestQgsGdalProvider::testVsiCredentialOptionsQuerySublayers() { -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 6, 0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 6, 0 ) QgsProviderMetadata *gdalMetadata = QgsProviderRegistry::instance()->providerMetadata( "gdal" ); QVERIFY( gdalMetadata ); @@ -1011,7 +1011,7 @@ void TestQgsGdalProvider::testVsiCredentialOptionsQuerySublayers() // if actual aws dataset proves flaky, use this instead: //QList< QgsProviderSublayerDetails> subLayers = gdalMetadata->querySublayers( QStringLiteral( "/vsis3/gdalsublayerstestbucket/test.tif|credential:AWS_NO_SIGN_REQUEST=YES|credential:AWS_REGION=eu-central-3|credential:AWS_S3_ENDPOINT=localhost" ) ); - QList< QgsProviderSublayerDetails> subLayers = gdalMetadata->querySublayers( QStringLiteral( "/vsis3/cdn.proj.org/us_nga_egm96_15.tif|credential:AWS_NO_SIGN_REQUEST=YES" ) ); + QList subLayers = gdalMetadata->querySublayers( QStringLiteral( "/vsis3/cdn.proj.org/us_nga_egm96_15.tif|credential:AWS_NO_SIGN_REQUEST=YES" ) ); QCOMPARE( subLayers.size(), 1 ); QCOMPARE( subLayers.at( 0 ).name(), QStringLiteral( "us_nga_egm96_15" ) ); QCOMPARE( subLayers.at( 0 ).uri(), QStringLiteral( "/vsis3/cdn.proj.org/us_nga_egm96_15.tif|credential:AWS_NO_SIGN_REQUEST=YES" ) ); diff --git a/tests/src/core/testqgsgdalutils.cpp b/tests/src/core/testqgsgdalutils.cpp index 56fe6ef50f53..45a6779ac627 100644 --- a/tests/src/core/testqgsgdalutils.cpp +++ b/tests/src/core/testqgsgdalutils.cpp @@ -25,15 +25,15 @@ #include "qgsrasterlayer.h" -class TestQgsGdalUtils: public QObject +class TestQgsGdalUtils : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void supportsRasterCreate(); void testCreateSingleBandMemoryDataset(); void testCreateMultiBandMemoryDataset(); @@ -46,7 +46,6 @@ class TestQgsGdalUtils: public QObject void testMultilayerExtensions(); private: - double identify( GDALDatasetH dataset, int band, int px, int py ); }; @@ -64,12 +63,10 @@ void TestQgsGdalUtils::cleanupTestCase() void TestQgsGdalUtils::init() { - } void TestQgsGdalUtils::cleanup() { - } void TestQgsGdalUtils::supportsRasterCreate() @@ -87,8 +84,8 @@ void TestQgsGdalUtils::supportsRasterCreate() QVERIFY( !QgsGdalUtils::supportsRasterCreate( GDALGetDriverByName( "ESRI Shapefile" ) ) ); } -#define EPSG_4326_WKT \ - "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," \ +#define EPSG_4326_WKT \ + "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," \ "AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433," \ "AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]" @@ -101,7 +98,7 @@ void TestQgsGdalUtils::testCreateSingleBandMemoryDataset() QCOMPARE( GDALGetRasterXSize( ds1.get() ), 40 ); QCOMPARE( GDALGetRasterYSize( ds1.get() ), 20 ); - QCOMPARE( GDALGetProjectionRef( ds1.get() ), R"""(GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]])""" ); + QCOMPARE( GDALGetProjectionRef( ds1.get() ), R"""(GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]])""" ); double geoTransform[6]; double geoTransformExpected[] = { 1, 0.5, 0, 11, 0, -0.5 }; QCOMPARE( GDALGetGeoTransform( ds1.get(), geoTransform ), CE_None ); @@ -119,7 +116,7 @@ void TestQgsGdalUtils::testCreateMultiBandMemoryDataset() QCOMPARE( GDALGetRasterXSize( ds1.get() ), 40 ); QCOMPARE( GDALGetRasterYSize( ds1.get() ), 20 ); - QCOMPARE( GDALGetProjectionRef( ds1.get() ), R"""(GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]])""" ); + QCOMPARE( GDALGetProjectionRef( ds1.get() ), R"""(GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]])""" ); double geoTransform[6]; double geoTransformExpected[] = { 1, 0.5, 0, 11, 0, -0.5 }; QCOMPARE( GDALGetGeoTransform( ds1.get(), geoTransform ), CE_None ); @@ -153,7 +150,7 @@ void TestQgsGdalUtils::testCreateSingleBandTiffDataset() QCOMPARE( GDALGetRasterDataType( GDALGetRasterBand( ds1.get(), 1 ) ), GDT_Float32 ); - ds1.reset(); // makes sure the file is fully written + ds1.reset(); // makes sure the file is fully written QVERIFY( QFile::exists( filename ) ); @@ -163,7 +160,7 @@ void TestQgsGdalUtils::testCreateSingleBandTiffDataset() QCOMPARE( layer->width(), 40 ); QCOMPARE( layer->height(), 20 ); - layer.reset(); // let's clean up before removing the file + layer.reset(); // let's clean up before removing the file QFile::remove( filename ); } @@ -318,8 +315,7 @@ double TestQgsGdalUtils::identify( GDALDatasetH dataset, int band, int px, int p GDALRasterBandH hBand = GDALGetRasterBand( dataset, band ); float *pafScanline = ( float * ) CPLMalloc( sizeof( float ) ); - const CPLErr err = GDALRasterIO( hBand, GF_Read, px, py, 1, 1, - pafScanline, 1, 1, GDT_Float32, 0, 0 ); + const CPLErr err = GDALRasterIO( hBand, GF_Read, px, py, 1, 1, pafScanline, 1, 1, GDT_Float32, 0, 0 ); const double value = err == CE_None ? pafScanline[0] : std::numeric_limits::quiet_NaN(); CPLFree( pafScanline ); diff --git a/tests/src/core/testqgsgenericspatialindex.cpp b/tests/src/core/testqgsgenericspatialindex.cpp index 65bffbdf9f95..dfcf94f57353 100644 --- a/tests/src/core/testqgsgenericspatialindex.cpp +++ b/tests/src/core/testqgsgenericspatialindex.cpp @@ -25,15 +25,15 @@ #include "qgstest.h" #include "qgslabelposition.h" -class TestQgsGenericSpatialIndex: public QObject +class TestQgsGenericSpatialIndex : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testIndex(); private: @@ -45,7 +45,6 @@ void TestQgsGenericSpatialIndex::initTestCase() void TestQgsGenericSpatialIndex::cleanupTestCase() { - } void TestQgsGenericSpatialIndex::init() @@ -58,15 +57,10 @@ void TestQgsGenericSpatialIndex::cleanup() void TestQgsGenericSpatialIndex::testIndex() { - QgsGenericSpatialIndex< QgsLabelPosition > index; - - QList< QgsLabelPosition * > found; - index.intersects( QgsRectangle( std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::max(), - std::numeric_limits< double >::max() ), - [&found]( QgsLabelPosition * p )-> bool - { + QgsGenericSpatialIndex index; + + QList found; + index.intersects( QgsRectangle( std::numeric_limits::lowest(), std::numeric_limits::lowest(), std::numeric_limits::max(), std::numeric_limits::max() ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -75,7 +69,7 @@ void TestQgsGenericSpatialIndex::testIndex() // remove feature not in index QgsLabelPosition p1; - QVERIFY( ! index.remove( &p1, QgsRectangle() ) ); + QVERIFY( !index.remove( &p1, QgsRectangle() ) ); // add data QVERIFY( index.insert( &p1, QgsRectangle( 1, 1, 5, 5 ) ) ); @@ -84,12 +78,7 @@ void TestQgsGenericSpatialIndex::testIndex() QgsLabelPosition p3; QVERIFY( index.insert( &p3, QgsRectangle( 11, 11, 14, 14 ) ) ); - index.intersects( QgsRectangle( std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::max(), - std::numeric_limits< double >::max() ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( std::numeric_limits::lowest(), std::numeric_limits::lowest(), std::numeric_limits::max(), std::numeric_limits::max() ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -99,9 +88,7 @@ void TestQgsGenericSpatialIndex::testIndex() QVERIFY( found.contains( &p3 ) ); found.clear(); - index.intersects( QgsRectangle( 0, 0, 3, 3 ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( 0, 0, 3, 3 ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -110,9 +97,7 @@ void TestQgsGenericSpatialIndex::testIndex() QVERIFY( found.contains( &p2 ) ); found.clear(); - index.intersects( QgsRectangle( 4.5, 4.5, 5, 5 ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( 4.5, 4.5, 5, 5 ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -120,9 +105,7 @@ void TestQgsGenericSpatialIndex::testIndex() QVERIFY( found.contains( &p1 ) ); found.clear(); - index.intersects( QgsRectangle( 10, 10, 13, 13 ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( 10, 10, 13, 13 ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -132,9 +115,7 @@ void TestQgsGenericSpatialIndex::testIndex() QVERIFY( index.remove( &p1, QgsRectangle( 1, 1, 5, 5 ) ) ); - index.intersects( QgsRectangle( 0, 0, 3, 3 ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( 0, 0, 3, 3 ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -144,12 +125,7 @@ void TestQgsGenericSpatialIndex::testIndex() QVERIFY( !index.remove( &p1, QgsRectangle( 1, 1, 5, 5 ) ) ); - index.intersects( QgsRectangle( std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::max(), - std::numeric_limits< double >::max() ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( std::numeric_limits::lowest(), std::numeric_limits::lowest(), std::numeric_limits::max(), std::numeric_limits::max() ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -160,12 +136,7 @@ void TestQgsGenericSpatialIndex::testIndex() QVERIFY( index.remove( &p2, QgsRectangle( 1, 1, 4, 4 ) ) ); - index.intersects( QgsRectangle( std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::max(), - std::numeric_limits< double >::max() ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( std::numeric_limits::lowest(), std::numeric_limits::lowest(), std::numeric_limits::max(), std::numeric_limits::max() ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); @@ -175,12 +146,7 @@ void TestQgsGenericSpatialIndex::testIndex() QVERIFY( index.remove( &p3, QgsRectangle( 11, 11, 14, 14 ) ) ); - index.intersects( QgsRectangle( std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::lowest(), - std::numeric_limits< double >::max(), - std::numeric_limits< double >::max() ), - [&found]( QgsLabelPosition * p )-> bool - { + index.intersects( QgsRectangle( std::numeric_limits::lowest(), std::numeric_limits::lowest(), std::numeric_limits::max(), std::numeric_limits::max() ), [&found]( QgsLabelPosition *p ) -> bool { found.append( p ); return true; } ); diff --git a/tests/src/core/testqgsgeometryimport.cpp b/tests/src/core/testqgsgeometryimport.cpp index 29e2efef19d1..a39da85b98da 100644 --- a/tests/src/core/testqgsgeometryimport.cpp +++ b/tests/src/core/testqgsgeometryimport.cpp @@ -25,7 +25,7 @@ #include -class TestQgsGeometryImport: public QObject +class TestQgsGeometryImport : public QObject { Q_OBJECT @@ -253,18 +253,18 @@ void TestQgsGeometryImport::delimiters_data() { QTest::addColumn( "input" ); QTest::addColumn( "expected" ); - QTest::newRow( "tab delimiter" ) << QStringLiteral( "POINT (180398\t5459331)" ) << QStringLiteral( "Point (180398 5459331)" ); - QTest::newRow( "newline" ) << QStringLiteral( "POINT\n(1\n3)" ) << QStringLiteral( "Point (1 3)" ); - QTest::newRow( "tab and newline" ) << QStringLiteral( "POINT\t\n(1\t\n3)" ) << QStringLiteral( "Point (1 3)" ); - QTest::newRow( "tab, newline and space" ) << QStringLiteral( "POINT\n (1\t\n 3)" ) << QStringLiteral( "Point (1 3)" ); - - QTest::newRow( "tab delimiter" ) << QStringLiteral( "LINESTRING\t(30\t10,\t10\t30,\t40\t40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); - QTest::newRow( "newline delimiter" ) << QStringLiteral( "LINESTRING\n(30\n10,\n10\n30,\n40\n40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); - QTest::newRow( "mixed delimiter" ) << QStringLiteral( "LINESTRING\n(30\t10, 10\t30,\n40\t40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); - - QTest::newRow( "tab delimiter" ) << QStringLiteral( "Polygon\t(\t(30\t10,\t10\t30,\t40\t40,30\t10)\t)" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); - QTest::newRow( "newline delimiter" ) << QStringLiteral( "\nPolygon\n(\n(30\n10,\n10\n30,\n40\n40,30\n10)\n)\n" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); - QTest::newRow( "mixed delimiter" ) << QStringLiteral( " Polygon (\t(30\n10,\t10\n30,\t40 40,30\n10)\t)\n" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); + QTest::newRow( "tab delimiter" ) << QStringLiteral( "POINT (180398\t5459331)" ) << QStringLiteral( "Point (180398 5459331)" ); + QTest::newRow( "newline" ) << QStringLiteral( "POINT\n(1\n3)" ) << QStringLiteral( "Point (1 3)" ); + QTest::newRow( "tab and newline" ) << QStringLiteral( "POINT\t\n(1\t\n3)" ) << QStringLiteral( "Point (1 3)" ); + QTest::newRow( "tab, newline and space" ) << QStringLiteral( "POINT\n (1\t\n 3)" ) << QStringLiteral( "Point (1 3)" ); + + QTest::newRow( "tab delimiter" ) << QStringLiteral( "LINESTRING\t(30\t10,\t10\t30,\t40\t40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); + QTest::newRow( "newline delimiter" ) << QStringLiteral( "LINESTRING\n(30\n10,\n10\n30,\n40\n40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); + QTest::newRow( "mixed delimiter" ) << QStringLiteral( "LINESTRING\n(30\t10, 10\t30,\n40\t40)" ) << QStringLiteral( "LineString (30 10, 10 30, 40 40)" ); + + QTest::newRow( "tab delimiter" ) << QStringLiteral( "Polygon\t(\t(30\t10,\t10\t30,\t40\t40,30\t10)\t)" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); + QTest::newRow( "newline delimiter" ) << QStringLiteral( "\nPolygon\n(\n(30\n10,\n10\n30,\n40\n40,30\n10)\n)\n" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); + QTest::newRow( "mixed delimiter" ) << QStringLiteral( " Polygon (\t(30\n10,\t10\n30,\t40 40,30\n10)\t)\n" ) << QStringLiteral( "Polygon ((30 10, 10 30, 40 40, 30 10))" ); } void TestQgsGeometryImport::delimiters() diff --git a/tests/src/core/testqgsgeopdfexport.cpp b/tests/src/core/testqgsgeopdfexport.cpp index 09eadee7af14..e81dc03b9f3b 100644 --- a/tests/src/core/testqgsgeopdfexport.cpp +++ b/tests/src/core/testqgsgeopdfexport.cpp @@ -23,9 +23,7 @@ class TestGeospatialPdfExporter : public QgsAbstractGeospatialPdfExporter { - private: - VectorComponentDetail componentDetailForLayerId( const QString &layerId ) override { Q_UNUSED( layerId ); @@ -35,7 +33,6 @@ class TestGeospatialPdfExporter : public QgsAbstractGeospatialPdfExporter detail.displayAttribute = QStringLiteral( "attr %1" ).arg( layerId ); return detail; } - }; class TestQgsGeospatialPdfExport : public QgsTest @@ -43,11 +40,12 @@ class TestQgsGeospatialPdfExport : public QgsTest Q_OBJECT public: - TestQgsGeospatialPdfExport() : QgsTest( QStringLiteral( "Geospatial PDF Export Testss" ) ) {} + TestQgsGeospatialPdfExport() + : QgsTest( QStringLiteral( "Geospatial PDF Export Testss" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testCollectingFeatures(); void testComposition(); void testMetadata(); @@ -116,7 +114,7 @@ void TestQgsGeospatialPdfExport::testCollectingFeatures() QCOMPARE( component.mapLayerId, QStringLiteral( "layer1" ) ); QCOMPARE( component.name, QStringLiteral( "name layer1" ) ); // check that temporary layers were correctly written - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layerName=%2" ).arg( component.sourceVectorPath, component.sourceVectorLayer ), QStringLiteral( "layer" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "%1|layerName=%2" ).arg( component.sourceVectorPath, component.sourceVectorLayer ), QStringLiteral( "layer" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QCOMPARE( layer->featureCount(), 2L ); QCOMPARE( layer->wkbType(), Qgis::WkbType::Polygon ); @@ -142,7 +140,7 @@ void TestQgsGeospatialPdfExport::testCollectingFeatures() } QCOMPARE( component.mapLayerId, QStringLiteral( "layer2" ) ); QCOMPARE( component.name, QStringLiteral( "name layer2" ) ); - layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layerName=%2" ).arg( component.sourceVectorPath, component.sourceVectorLayer ), QStringLiteral( "layer" ), QStringLiteral( "ogr" ) ); + layer = std::make_unique( QStringLiteral( "%1|layerName=%2" ).arg( component.sourceVectorPath, component.sourceVectorLayer ), QStringLiteral( "layer" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QCOMPARE( layer->featureCount(), 1L ); QCOMPARE( layer->wkbType(), Qgis::WkbType::LineString ); @@ -198,7 +196,7 @@ void TestQgsGeospatialPdfExport::testComposition() } // test creation of the composition xml - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; + QList renderedLayers; QgsAbstractGeospatialPdfExporter::ComponentLayerDetail detail; detail.mapLayerId = QStringLiteral( "layer3" ); detail.name = QStringLiteral( "xxx" ); @@ -235,12 +233,12 @@ void TestQgsGeospatialPdfExport::testComposition() QDomNodeList ifLayerOnList = doc.elementsByTagName( QStringLiteral( "IfLayerOn" ) ); QCOMPARE( ifLayerOnList.count(), 3 ); - int layer1Idx = ifLayerOnList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer1" ) ? 0 : - ifLayerOnList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer1" ) ? 1 : 2; - int layer2Idx = ifLayerOnList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer2" ) ? 0 : - ifLayerOnList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer2" ) ? 1 : 2; - int layer3Idx = ifLayerOnList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer3" ) ? 0 : - ifLayerOnList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer3" ) ? 1 : 2; + int layer1Idx = ifLayerOnList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer1" ) ? 0 : ifLayerOnList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer1" ) ? 1 + : 2; + int layer2Idx = ifLayerOnList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer2" ) ? 0 : ifLayerOnList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer2" ) ? 1 + : 2; + int layer3Idx = ifLayerOnList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer3" ) ? 0 : ifLayerOnList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == QLatin1String( "layer3" ) ? 1 + : 2; QCOMPARE( ifLayerOnList.at( layer1Idx ).toElement().attribute( QStringLiteral( "layerId" ) ), QStringLiteral( "layer1" ) ); QCOMPARE( ifLayerOnList.at( layer1Idx ).toElement().elementsByTagName( QStringLiteral( "Vector" ) ).at( 0 ).toElement().attribute( QStringLiteral( "dataset" ) ), layer1Path ); QCOMPARE( ifLayerOnList.at( layer1Idx ).toElement().elementsByTagName( QStringLiteral( "Vector" ) ).at( 0 ).toElement().attribute( QStringLiteral( "layer" ) ), layer1Layer ); @@ -259,7 +257,6 @@ void TestQgsGeospatialPdfExport::testComposition() QCOMPARE( ifLayerOnList.at( layer3Idx ).toElement().elementsByTagName( QStringLiteral( "PDF" ) ).at( 0 ).toElement().attribute( QStringLiteral( "dataset" ) ), QStringLiteral( "a pdf.pdf" ) ); QCOMPARE( ifLayerOnList.at( layer3Idx ).toElement().elementsByTagName( QStringLiteral( "PDF" ) ).at( 0 ).toElement().elementsByTagName( QStringLiteral( "Blending" ) ).at( 0 ).toElement().attribute( QStringLiteral( "opacity" ) ).toDouble(), 0.7 ); QCOMPARE( ifLayerOnList.at( layer3Idx ).toElement().elementsByTagName( QStringLiteral( "PDF" ) ).at( 0 ).toElement().elementsByTagName( QStringLiteral( "Blending" ) ).at( 0 ).toElement().attribute( QStringLiteral( "function" ) ), QStringLiteral( "Screen" ) ); - } void TestQgsGeospatialPdfExport::testMetadata() @@ -267,7 +264,7 @@ void TestQgsGeospatialPdfExport::testMetadata() TestGeospatialPdfExporter geospatialPdfExporter; // test creation of the composition xml with metadata - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; + QList renderedLayers; QgsAbstractGeospatialPdfExporter::ExportDetails details; QString composition = geospatialPdfExporter.createCompositionXml( renderedLayers, details ); QgsDebugMsgLevel( composition, 1 ); @@ -300,7 +297,6 @@ void TestQgsGeospatialPdfExport::testMetadata() QCOMPARE( doc.elementsByTagName( QStringLiteral( "Subject" ) ).at( 0 ).toElement().text(), QStringLiteral( "my subject" ) ); QCOMPARE( doc.elementsByTagName( QStringLiteral( "Title" ) ).at( 0 ).toElement().text(), QStringLiteral( "my title" ) ); QCOMPARE( doc.elementsByTagName( QStringLiteral( "Keywords" ) ).at( 0 ).toElement().text(), QStringLiteral( "k1: v1,v2" ) ); - } void TestQgsGeospatialPdfExport::testGeoref() @@ -308,7 +304,7 @@ void TestQgsGeospatialPdfExport::testGeoref() TestGeospatialPdfExporter geospatialPdfExporter; // test creation of the composition xml with georeferencing - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; + QList renderedLayers; QgsAbstractGeospatialPdfExporter::ExportDetails details; QString composition = geospatialPdfExporter.createCompositionXml( renderedLayers, details ); QgsDebugMsgLevel( composition, 1 ); @@ -358,7 +354,7 @@ void TestQgsGeospatialPdfExport::testGeorefPolygon() // test georeferencing a region using polygon bounds TestGeospatialPdfExporter geospatialPdfExporter; - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; + QList renderedLayers; QgsAbstractGeospatialPdfExporter::ExportDetails details; // with points @@ -442,7 +438,7 @@ void TestQgsGeospatialPdfExport::testGroups() } // test creation of the composition xml - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; // no extra layers for now + QList renderedLayers; // no extra layers for now QgsAbstractGeospatialPdfExporter::ExportDetails details; QString composition = geospatialPdfExporter.createCompositionXml( renderedLayers, details ); QgsDebugMsgLevel( composition, 1 ); @@ -480,7 +476,6 @@ void TestQgsGeospatialPdfExport::testGroups() QCOMPARE( layerTreeList.at( layer2Idx ).toElement().attribute( QStringLiteral( "id" ) ), QStringLiteral( "layer2" ) ); QCOMPARE( layerTreeList.at( layer2Idx ).toElement().attribute( QStringLiteral( "name" ) ), QStringLiteral( "name layer2" ) ); QCOMPARE( layerTreeList.at( layer2Idx ).toElement().attribute( QStringLiteral( "initiallyVisible" ) ), QStringLiteral( "true" ) ); - } void TestQgsGeospatialPdfExport::testCustomGroups() @@ -523,7 +518,7 @@ void TestQgsGeospatialPdfExport::testCustomGroups() } // test creation of the composition xml - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; // no extra layers for now + QList renderedLayers; // no extra layers for now QgsAbstractGeospatialPdfExporter::ExportDetails details; details.customLayerTreeGroups.insert( QStringLiteral( "layer1" ), QStringLiteral( "my group" ) ); details.customLayerTreeGroups.insert( QStringLiteral( "layer2" ), QStringLiteral( "my group2" ) ); @@ -618,12 +613,12 @@ void TestQgsGeospatialPdfExport::testGroupOrder() } // test creation of the composition xml - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; // no extra layers for now + QList renderedLayers; // no extra layers for now QgsAbstractGeospatialPdfExporter::ExportDetails details; details.customLayerTreeGroups.insert( QStringLiteral( "layer1" ), QStringLiteral( "my group" ) ); details.customLayerTreeGroups.insert( QStringLiteral( "layer2" ), QStringLiteral( "my group2" ) ); - details.layerTreeGroupOrder = QStringList{ QStringLiteral( "my group2" ), QStringLiteral( "my group" )}; + details.layerTreeGroupOrder = QStringList { QStringLiteral( "my group2" ), QStringLiteral( "my group" ) }; QString composition = geospatialPdfExporter.createCompositionXml( renderedLayers, details ); QgsDebugMsgLevel( composition, 1 ); @@ -635,7 +630,7 @@ void TestQgsGeospatialPdfExport::testGroupOrder() QCOMPARE( layerTreeList.at( 0 ).toElement().attribute( QStringLiteral( "name" ) ), QStringLiteral( "my group2" ) ); QCOMPARE( layerTreeList.at( 1 ).toElement().attribute( QStringLiteral( "name" ) ), QStringLiteral( "my group" ) ); - details.layerTreeGroupOrder = QStringList{ QStringLiteral( "my group" ), QStringLiteral( "my group2" )}; + details.layerTreeGroupOrder = QStringList { QStringLiteral( "my group" ), QStringLiteral( "my group2" ) }; composition = geospatialPdfExporter.createCompositionXml( renderedLayers, details ); QgsDebugMsgLevel( composition, 1 ); @@ -647,7 +642,7 @@ void TestQgsGeospatialPdfExport::testGroupOrder() QCOMPARE( layerTreeList.at( 1 ).toElement().attribute( QStringLiteral( "name" ) ), QStringLiteral( "my group2" ) ); // incomplete list - details.layerTreeGroupOrder = QStringList{ QStringLiteral( "my group2" )}; + details.layerTreeGroupOrder = QStringList { QStringLiteral( "my group2" ) }; composition = geospatialPdfExporter.createCompositionXml( renderedLayers, details ); QgsDebugMsgLevel( composition, 1 ); @@ -659,7 +654,7 @@ void TestQgsGeospatialPdfExport::testGroupOrder() QCOMPARE( layerTreeList.at( 1 ).toElement().attribute( QStringLiteral( "name" ) ), QStringLiteral( "my group" ) ); // list with extra groups which don't have content - details.layerTreeGroupOrder = QStringList{ QStringLiteral( "aaa" ), QStringLiteral( "my group" )}; + details.layerTreeGroupOrder = QStringList { QStringLiteral( "aaa" ), QStringLiteral( "my group" ) }; composition = geospatialPdfExporter.createCompositionXml( renderedLayers, details ); QgsDebugMsgLevel( composition, 1 ); @@ -722,7 +717,7 @@ void TestQgsGeospatialPdfExport::testMutuallyExclusiveGroupsLayers() } // test creation of the composition xml - QList< QgsAbstractGeospatialPdfExporter::ComponentLayerDetail > renderedLayers; // no extra layers for now + QList renderedLayers; // no extra layers for now QgsAbstractGeospatialPdfExporter::ExportDetails details; details.customLayerTreeGroups.insert( QStringLiteral( "layer1" ), QStringLiteral( "my group" ) ); details.customLayerTreeGroups.insert( QStringLiteral( "layer2" ), QStringLiteral( "my group2" ) ); @@ -769,12 +764,15 @@ void TestQgsGeospatialPdfExport::testMutuallyExclusiveGroupsLayers() QDomNodeList contentList = doc.documentElement().firstChildElement( QStringLiteral( "Page" ) ).firstChildElement( QStringLiteral( "Content" ) ).childNodes(); QCOMPARE( contentList.count(), 3 ); - int layer1Idx = contentList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group1Id ? 0 - : contentList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group1Id ? 1 : 2; - int layer2Idx = contentList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group2Id ? 0 - : contentList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group2Id ? 1 : 2; - int layer3Idx = contentList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group3Id ? 0 - : contentList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group3Id ? 1 : 2; + int layer1Idx = contentList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group1Id ? 0 + : contentList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group1Id ? 1 + : 2; + int layer2Idx = contentList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group2Id ? 0 + : contentList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group2Id ? 1 + : 2; + int layer3Idx = contentList.at( 0 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group3Id ? 0 + : contentList.at( 1 ).toElement().attribute( QStringLiteral( "layerId" ) ) == group3Id ? 1 + : 2; QCOMPARE( contentList.at( layer1Idx ).toElement().attribute( QStringLiteral( "layerId" ) ), group1Id ); QCOMPARE( contentList.at( layer1Idx ).toElement().firstChildElement().tagName(), QStringLiteral( "IfLayerOn" ) ); QCOMPARE( contentList.at( layer1Idx ).toElement().firstChildElement().attribute( QStringLiteral( "layerId" ) ), QStringLiteral( "my group_layer1" ) ); @@ -810,15 +808,15 @@ void TestQgsGeospatialPdfExport::testMutuallyExclusiveGroupsCustom() // test creation of the composition xml QgsAbstractGeospatialPdfExporter::ComponentLayerDetail group1; group1.group = QStringLiteral( "my group" ); - group1.sourcePdfPath = QStringLiteral( "group1.pdf" ); + group1.sourcePdfPath = QStringLiteral( "group1.pdf" ); QgsAbstractGeospatialPdfExporter::ComponentLayerDetail group2; group2.group = QStringLiteral( "my group2" ); - group2.sourcePdfPath = QStringLiteral( "group2.pdf" ); + group2.sourcePdfPath = QStringLiteral( "group2.pdf" ); QgsAbstractGeospatialPdfExporter::ComponentLayerDetail group3; group3.group = QStringLiteral( "my group3" ); - group3.sourcePdfPath = QStringLiteral( "group3.pdf" ); + group3.sourcePdfPath = QStringLiteral( "group3.pdf" ); QgsAbstractGeospatialPdfExporter::ComponentLayerDetail object4; - object4.sourcePdfPath = QStringLiteral( "object4.pdf" ); + object4.sourcePdfPath = QStringLiteral( "object4.pdf" ); QgsAbstractGeospatialPdfExporter::ExportDetails details; // groups 1 & 2 should be mutually exclusive diff --git a/tests/src/core/testqgsgltfutils.cpp b/tests/src/core/testqgsgltfutils.cpp index 13fc75d42ae2..44cb34863775 100644 --- a/tests/src/core/testqgsgltfutils.cpp +++ b/tests/src/core/testqgsgltfutils.cpp @@ -25,8 +25,8 @@ class TestQgsGltfUtils : public QObject TestQgsGltfUtils() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testImageResourceType(); void testExtractEmbeddedImage(); @@ -88,15 +88,15 @@ void TestQgsGltfUtils::testExtractTextureCoordinates() tinygltf::Model model; QVERIFY( QgsGltfUtils::loadGltfModel( data, model, nullptr, nullptr ) ); - QVector< float > x; - QVector< float > y; + QVector x; + QVector y; QVERIFY( QgsGltfUtils::extractTextureCoordinates( model, 3, x, y ) ); QCOMPARE( x.size(), 24 ); QCOMPARE( y.size(), 24 ); QCOMPARE( x.at( 0 ), 6.0 ); QCOMPARE( y.at( 0 ), 0.0 ); QCOMPARE( x.at( 23 ), 1.0 ); - QGSCOMPARENEAR( y.at( 23 ), 1.0, 0.01 ); + QGSCOMPARENEAR( y.at( 23 ), 1.0, 0.01 ); } QGSTEST_MAIN( TestQgsGltfUtils ) diff --git a/tests/src/core/testqgsgml.cpp b/tests/src/core/testqgsgml.cpp index e823824e1370..da346244b574 100644 --- a/tests/src/core/testqgsgml.cpp +++ b/tests/src/core/testqgsgml.cpp @@ -125,13 +125,13 @@ void TestQgsGML::testFromURL() tmpFile.flush(); QCOMPARE( gmlParser.getFeatures( QUrl::fromLocalFile( tmpFile.fileName() ).toString(), &wkbType ), 0 ); QCOMPARE( wkbType, Qgis::WkbType::Point ); - QMap featureMaps = gmlParser.featuresMap(); + QMap featureMaps = gmlParser.featuresMap(); QCOMPARE( featureMaps.size(), 1 ); QCOMPARE( gmlParser.idsMap().size(), 1 ); QCOMPARE( gmlParser.crs().authid(), QString( "EPSG:27700" ) ); QCOMPARE( featureMaps[0]->attribute( QStringLiteral( "intfield" ) ).toInt(), 1 ); - QVERIFY( featureMaps[0]->attribute( QStringLiteral( "nillablefield" ) ).isNull( ) ); - delete featureMaps[ 0 ]; + QVERIFY( featureMaps[0]->attribute( QStringLiteral( "nillablefield" ) ).isNull() ); + delete featureMaps[0]; } void TestQgsGML::testFromByteArray() @@ -142,16 +142,16 @@ void TestQgsGML::testFromByteArray() QgsGml gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); Qgis::WkbType wkbType; QCOMPARE( gmlParser.getFeatures( data1.toLatin1(), &wkbType ), 0 ); - QMap featureMaps = gmlParser.featuresMap(); + QMap featureMaps = gmlParser.featuresMap(); QCOMPARE( featureMaps.size(), 1 ); QVERIFY( featureMaps.constFind( 0 ) != featureMaps.constEnd() ); - QCOMPARE( featureMaps[ 0 ]->attributes().size(), 2 ); - QMap idsMap = gmlParser.idsMap(); + QCOMPARE( featureMaps[0]->attributes().size(), 2 ); + QMap idsMap = gmlParser.idsMap(); QVERIFY( idsMap.constFind( 0 ) != idsMap.constEnd() ); - QCOMPARE( idsMap[ 0 ], QString( "mytypename.1" ) ); + QCOMPARE( idsMap[0], QString( "mytypename.1" ) ); QCOMPARE( featureMaps[0]->attribute( QStringLiteral( "intfield" ) ).toInt(), 1 ); - QVERIFY( featureMaps[0]->attribute( QStringLiteral( "nillablefield" ) ).isNull( ) ); - delete featureMaps[ 0 ]; + QVERIFY( featureMaps[0]->attribute( QStringLiteral( "nillablefield" ) ).isNull() ); + delete featureMaps[0]; } void TestQgsGML::testStreamingParser() @@ -172,7 +172,7 @@ void TestQgsGML::testStreamingParser() QCOMPARE( features.size(), 1 ); QCOMPARE( features[0].first->attributes().size(), 6 ); QCOMPARE( features[0].first->attributes().at( 0 ), QVariant( 1 ) ); - QCOMPARE( features[0].first->attributes().at( 1 ), QVariant( ) ); + QCOMPARE( features[0].first->attributes().at( 1 ), QVariant() ); QCOMPARE( features[0].first->attributes().at( 2 ), QVariant( Q_INT64_C( 1234567890123 ) ) ); QCOMPARE( features[0].first->attributes().at( 3 ), QVariant( 1.23 ) ); QCOMPARE( features[0].first->attributes().at( 4 ), QVariant( "foo" ) ); @@ -200,18 +200,20 @@ void TestQgsGML::testPointGML2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "10,20" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "10,20" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -226,18 +228,20 @@ void TestQgsGML::testLineStringGML2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "10,20 30,40" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "10,20 30,40" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::LineString ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -255,27 +259,29 @@ void TestQgsGML::testPolygonGML2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "0,0 0,10 10,10 10,0 0,0" - "" - "" - "" - "" - "1,1 1,9 9,9 1,1" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "0,0 0,10 10,10 10,0 0,0" + "" + "" + "" + "" + "1,1 1,9 9,9 1,1" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Polygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -293,27 +299,29 @@ void TestQgsGML::testMultiPointGML2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "10,20" - "" - "" - "" - "" - "30,40" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "10,20" + "" + "" + "" + "" + "30,40" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::MultiPoint ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -331,27 +339,29 @@ void TestQgsGML::testMultiLineStringGML2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "10,20 30,40" - "" - "" - "" - "" - "50,60 70,80 90,100" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "10,20 30,40" + "" + "" + "" + "" + "50,60 70,80 90,100" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::MultiLineString ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -371,26 +381,28 @@ void TestQgsGML::testMultiPolygonGML2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "" - "" - "0,0 0,10 10,10 10,0 0,0" - "" - "" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "" + "" + "0,0 0,10 10,10 10,0 0,0" + "" + "" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::MultiPolygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -408,18 +420,20 @@ void TestQgsGML::testPointGML3() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "10 20" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "10 20" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 27700 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -436,18 +450,20 @@ void TestQgsGML::testPointGML3_EPSG_4326() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "2 49" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "2 49" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 4326 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -464,18 +480,20 @@ void TestQgsGML::testPointGML3_uri_EPSG_4326() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "49 2" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "49 2" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 4326 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -492,18 +510,20 @@ void TestQgsGML::testPointGML3_urn_EPSG_4326() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "49 2" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "49 2" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 4326 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -520,18 +540,20 @@ void TestQgsGML::testPointGML3_EPSG_4326_honour_EPSG() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields, QgsGmlStreamingParser::Honour_EPSG ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "49 2" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "49 2" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 4326 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -548,18 +570,20 @@ void TestQgsGML::testPointGML3_EPSG_4326_honour_EPSG_invert() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields, QgsGmlStreamingParser::Honour_EPSG, true ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "2 49" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "2 49" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 4326 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -576,18 +600,20 @@ void TestQgsGML::testLineStringGML3() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "10 20 30 40" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "10 20 30 40" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::LineString ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -605,16 +631,18 @@ void TestQgsGML::testLineStringGML3_LineStringSegment() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "10 20 30 40" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "10 20 30 40" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::LineString ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -632,27 +660,29 @@ void TestQgsGML::testPolygonGML3() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "1 1 1 9 9 9 1 1" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "1 1 1 9 9 9 1 1" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Polygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -670,22 +700,24 @@ void TestQgsGML::testPolygonGML3_srsDimension_on_Polygon() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "0 0 -100 0 10 -100 10 10 -100 10 0 -100 0 0 -100" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "0 0 -100 0 10 -100 10 10 -100 10 0 -100 0 0 -100" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Polygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -702,22 +734,24 @@ void TestQgsGML::testPolygonGML3_srsDimension_on_posList() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "0 0 -100 0 10 -100 10 10 -100 10 0 -100 0 0 -100" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "0 0 -100 0 10 -100 10 10 -100 10 0 -100 0 0 -100" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Polygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -734,27 +768,29 @@ void TestQgsGML::testMultiLineStringGML3() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "10 20 30 40" - "" - "" - "" - "" - "50 60 70 80 90 100" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "10 20 30 40" + "" + "" + "" + "" + "50 60 70 80 90 100" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::MultiLineString ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -774,35 +810,37 @@ void TestQgsGML::testMultiPolygonGML3() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::MultiPolygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -820,19 +858,21 @@ void TestQgsGML::testPointGML3_2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" /* First use of gml: */ - "" - "" - "10 20" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml/3.2'>" + "" + "" /* First use of gml: */ + "" + "" + "10 20" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 27700 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -849,18 +889,20 @@ void TestQgsGML::testBoundingBoxGML2() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "0,0 10,10" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "0,0 10,10" + "" + "" + "" + "" + "" ), + true ), + true ); //QCOMPARE(gmlParser.wkbType(), QgsWkbTypes::Polygon); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -877,19 +919,21 @@ void TestQgsGML::testBoundingBoxGML3() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "0 0" - "10 10" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "0 0" + "10 10" + "" + "" + "" + "" + "" ), + true ), + true ); //QCOMPARE(gmlParser.wkbType(), QgsWkbTypes::Polygon); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -908,9 +952,11 @@ void TestQgsGML::testNumberMatchedNumberReturned() { QgsGmlStreamingParser gmlParser( QString(), QString(), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" ), true ), true ); + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" ), + true ), + true ); QCOMPARE( gmlParser.numberReturned(), -1 ); QCOMPARE( gmlParser.numberMatched(), -1 ); } @@ -918,60 +964,72 @@ void TestQgsGML::testNumberMatchedNumberReturned() { QgsGmlStreamingParser gmlParser( QString(), QString(), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" ), true ), true ); + "numberOfFeatures='1' " + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" ), + true ), + true ); QCOMPARE( gmlParser.numberReturned(), 1 ); } // Invalid numberOfFeatures { QgsGmlStreamingParser gmlParser( QString(), QString(), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" ), true ), true ); + "numberOfFeatures='invalid' " + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" ), + true ), + true ); QCOMPARE( gmlParser.numberReturned(), -1 ); } // Valid numberReturned { QgsGmlStreamingParser gmlParser( QString(), QString(), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" ), true ), true ); + "numberReturned='1' " + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" ), + true ), + true ); QCOMPARE( gmlParser.numberReturned(), 1 ); } // Invalid numberReturned { QgsGmlStreamingParser gmlParser( QString(), QString(), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" ), true ), true ); + "numberReturned='invalid' " + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" ), + true ), + true ); QCOMPARE( gmlParser.numberReturned(), -1 ); } // Valid numberMatched { QgsGmlStreamingParser gmlParser( QString(), QString(), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" ), true ), true ); + "numberMatched='1' " + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" ), + true ), + true ); QCOMPARE( gmlParser.numberMatched(), 1 ); } // numberMatched=unknown { QgsGmlStreamingParser gmlParser( QString(), QString(), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" ), true ), true ); + "numberMatched='unknown' " + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" ), + true ), + true ); QCOMPARE( gmlParser.numberMatched(), -1 ); } } @@ -980,10 +1038,12 @@ void TestQgsGML::testException() { QgsGmlStreamingParser gmlParser( ( QString() ), ( QString() ), QgsFields() ); QCOMPARE( gmlParser.processData( QByteArray( "" - " " - " my_exception" - " " - "" ), true ), true ); + " " + " my_exception" + " " + "" ), + true ), + true ); QCOMPARE( gmlParser.isException(), true ); QCOMPARE( gmlParser.exceptionText(), QString( "my_exception" ) ); } @@ -1001,33 +1061,33 @@ void TestQgsGML::testTuple() prop.mName = QStringLiteral( "ns:secondlayer" ); prop.mGeometryAttribute = QStringLiteral( "geom" ); layerProperties.append( prop ); - QMap< QString, QPair > mapFieldNameToSrcLayerNameFieldName; + QMap> mapFieldNameToSrcLayerNameFieldName; mapFieldNameToSrcLayerNameFieldName.insert( QStringLiteral( "my_first_attr" ), QPair( QStringLiteral( "ns:firstlayer" ), QStringLiteral( "a" ) ) ); mapFieldNameToSrcLayerNameFieldName.insert( QStringLiteral( "my_second_attr" ), QPair( QStringLiteral( "ns:secondlayer" ), QStringLiteral( "a" ) ) ); QgsGmlStreamingParser gmlParser( layerProperties, fields, mapFieldNameToSrcLayerNameFieldName ); - QCOMPARE( gmlParser.processData( QByteArray( - "" - "" - "" - "" - "" - "1" - "10 20" - "" - "" - "" - "" - "2" - "20 40" - "" - "" - "" - "" - "" - ), true ), true ); + QCOMPARE( gmlParser.processData( QByteArray( "" + "" + "" + "" + "" + "1" + "10 20" + "" + "" + "" + "" + "2" + "20 40" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.isException(), false ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 27700 ); @@ -1052,23 +1112,23 @@ void TestQgsGML::testRenamedFields() prop.mName = QStringLiteral( "ns:mylayer" ); prop.mGeometryAttribute = QStringLiteral( "geom" ); layerProperties.append( prop ); - QMap< QString, QPair > mapFieldNameToSrcLayerNameFieldName; + QMap> mapFieldNameToSrcLayerNameFieldName; mapFieldNameToSrcLayerNameFieldName.insert( QStringLiteral( "my_first_attr" ), QPair( QStringLiteral( "ns:mylayer" ), QStringLiteral( "b" ) ) ); QgsGmlStreamingParser gmlParser( layerProperties, fields, mapFieldNameToSrcLayerNameFieldName ); - QCOMPARE( gmlParser.processData( QByteArray( - "" - "" - "" - "1" - "2" - "10 20" - "" - "" - "" - ), true ), true ); + QCOMPARE( gmlParser.processData( QByteArray( "" + "" + "" + "1" + "2" + "10 20" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.isException(), false ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Point ); QCOMPARE( gmlParser.getEPSGCode(), 27700 ); @@ -1087,10 +1147,12 @@ void TestQgsGML::testTruncatedResponse() { QgsGmlStreamingParser gmlParser( ( QString() ), ( QString() ), QgsFields() ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" ), true ), true ); + "xmlns:wfs='http://wfs' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.isTruncatedResponse(), true ); } @@ -1099,14 +1161,15 @@ void TestQgsGML::testPartialFeature() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "10,20" - ), true ), false ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "10,20" ), + true ), + false ); const QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 0 ); } @@ -1116,24 +1179,26 @@ void TestQgsGML::testThroughOGRGeometry() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Polygon ); QCOMPARE( gmlParser.getEPSGCode(), 27700 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -1152,24 +1217,26 @@ void TestQgsGML::testThroughOGRGeometry_urn_EPSG_4326() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "" - "49 2 49 3 59 3 49 2" - "" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml/3.2'>" + "" + "" + "" + "" + "" + "" + "" + "49 2 49 3 59 3 49 2" + "" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::Polygon ); QCOMPARE( gmlParser.getEPSGCode(), 4326 ); QVector features = gmlParser.getAndStealReadyFeatures(); @@ -1188,39 +1255,39 @@ void TestQgsGML::testThroughOGRGeometry_urn_EPSG_4326() void TestQgsGML::testAccents() { const QgsFields fields; - QgsGmlStreamingParser gmlParser( QString::fromUtf8( QByteArray( "my\xc3\xa9typename" ) ), - QString::fromUtf8( QByteArray( "my\xc3\xa9geom" ) ), - fields ); + QgsGmlStreamingParser gmlParser( QString::fromUtf8( QByteArray( "my\xc3\xa9typename" ) ), QString::fromUtf8( QByteArray( "my\xc3\xa9geom" ) ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::MultiPolygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -1238,35 +1305,37 @@ void TestQgsGML::testSameTypeameAsGeomName() const QgsFields fields; QgsGmlStreamingParser gmlParser( QStringLiteral( "foo" ), QStringLiteral( "foo" ), fields ); QCOMPARE( gmlParser.processData( QByteArray( "" - "" - "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "" - "" - "" - "" - "0 0 0 10 10 10 10 0 0 0" - "" - "" - "" - "" - "" - "" - "" - "" - "" ), true ), true ); + "xmlns:myns='http://myns' " + "xmlns:gml='http://www.opengis.net/gml'>" + "" + "" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "" + "" + "" + "" + "0 0 0 10 10 10 10 0 0 0" + "" + "" + "" + "" + "" + "" + "" + "" + "" ), + true ), + true ); QCOMPARE( gmlParser.wkbType(), Qgis::WkbType::MultiPolygon ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); @@ -1300,23 +1369,26 @@ void TestQgsGML::testUnknownEncoding() QTextCodec *codec = QTextCodec::codecForName( encoding ); QByteArray data = codec->fromUnicode( - QStringLiteral( - "%1" - "unknown" - "" - "" - "price: 10€" - "" - "" - "10,20" - "" - "" - "" - "" - "" ).arg( xmlHeader ) ); + QStringLiteral( + "%1" + "unknown" + "" + "" + "price: 10€" + "" + "" + "10,20" + "" + "" + "" + "" + "" + ) + .arg( xmlHeader ) + ); QgsFields fields; fields.append( QgsField( QStringLiteral( "strfield" ), QMetaType::Type::QString, QStringLiteral( "string" ) ) ); @@ -1324,12 +1396,12 @@ void TestQgsGML::testUnknownEncoding() { QgsGml gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.getFeatures( data, &wkbType ), 0 ); - QMap featureMaps = gmlParser.featuresMap(); + QMap featureMaps = gmlParser.featuresMap(); QCOMPARE( featureMaps.size(), 1 ); QVERIFY( featureMaps.constFind( 0 ) != featureMaps.constEnd() ); - QCOMPARE( featureMaps[ 0 ]->attributes().size(), 1 ); + QCOMPARE( featureMaps[0]->attributes().size(), 1 ); QCOMPARE( featureMaps[0]->attribute( QStringLiteral( "strfield" ) ).toString(), QString( "price: 10€" ) ); - delete featureMaps[ 0 ]; + delete featureMaps[0]; } { @@ -1340,8 +1412,8 @@ void TestQgsGML::testUnknownEncoding() QCOMPARE( gmlParser.isException(), false ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); - QCOMPARE( features[ 0 ].first->attributes().size(), 1 ); - QCOMPARE( features[ 0 ].first->attribute( QStringLiteral( "strfield" ) ).toString(), QString( "price: 10€" ) ); + QCOMPARE( features[0].first->attributes().size(), 1 ); + QCOMPARE( features[0].first->attribute( QStringLiteral( "strfield" ) ).toString(), QString( "price: 10€" ) ); delete features[0].first; } } @@ -1351,72 +1423,74 @@ void TestQgsGML::testUnhandledEncoding() Qgis::WkbType wkbType; QString data = QStringLiteral( - "" - "" - "unknown" - "" - "" - "price: 10€" - "" - "" - "10,20" - "" - "" - "" - "" - "" ); + "" + "" + "unknown" + "" + "" + "price: 10€" + "" + "" + "10,20" + "" + "" + "" + "" + "" + ); QgsFields fields; fields.append( QgsField( QStringLiteral( "strfield" ), QMetaType::Type::QString, QStringLiteral( "string" ) ) ); QgsGml gmlParser( QStringLiteral( "mytypename" ), QStringLiteral( "mygeom" ), fields ); QCOMPARE( gmlParser.getFeatures( data.toUtf8(), &wkbType ), 0 ); - QMap featureMaps = gmlParser.featuresMap(); + QMap featureMaps = gmlParser.featuresMap(); QCOMPARE( featureMaps.size(), 0 ); } void TestQgsGML::testXPath() { QString data = QStringLiteral( - "" - "" - "unknown" - "" - "" - "foo" - "" - "bar" - "baz" - "" - "" - "" - "x" - "" - "y" - "123456789012312011.2512345678901234567890123456789" - "ab" - "ab" - "abc" - "x" - "" - "" - "" - "foo" - "bar" - "" - "" - "10,20" - "" - "" - "" - "" - "" ); + "" + "" + "unknown" + "" + "" + "foo" + "" + "bar" + "baz" + "" + "" + "" + "x" + "" + "y" + "123456789012312011.2512345678901234567890123456789" + "ab" + "ab" + "abc" + "x" + "" + "" + "" + "foo" + "bar" + "" + "" + "10,20" + "" + "" + "" + "" + "" + ); QgsFields fields; fields.append( QgsField( QStringLiteral( "fid" ), QMetaType::Type::QString, QStringLiteral( "fid" ) ) ); @@ -1448,7 +1522,7 @@ void TestQgsGML::testXPath() QCOMPARE( gmlParser.processData( data.toUtf8(), true ), true ); QVector features = gmlParser.getAndStealReadyFeatures(); QCOMPARE( features.size(), 1 ); - auto &f = *( features[ 0 ].first ); + auto &f = *( features[0].first ); QCOMPARE( f.attributes().size(), 9 ); QCOMPARE( f.attribute( QStringLiteral( "fid" ) ).toString(), QStringLiteral( "mytypename.1" ) ); QCOMPARE( f.attribute( QStringLiteral( "my_attr" ) ).toString(), QStringLiteral( "my_value" ) ); diff --git a/tests/src/core/testqgsgradients.cpp b/tests/src/core/testqgsgradients.cpp index d2557e89fb42..0330d5d20b6d 100644 --- a/tests/src/core/testqgsgradients.cpp +++ b/tests/src/core/testqgsgradients.cpp @@ -44,11 +44,12 @@ class TestQgsGradients : public QgsTest Q_OBJECT public: - TestQgsGradients() : QgsTest( QStringLiteral( "Gradient Renderer Tests" ) ) {} + TestQgsGradients() + : QgsTest( QStringLiteral( "Gradient Renderer Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void gradientSymbol(); void gradientSymbolColors(); @@ -66,7 +67,7 @@ class TestQgsGradients : public QgsTest void gradientSymbolFromQml(); private: - bool mTestHasError = false ; + bool mTestHasError = false; bool setQml( const QString &type ); bool imageCheck( const QString &type ); QgsMapSettings mMapSettings; @@ -92,8 +93,7 @@ void TestQgsGradients::initTestCase() // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -104,7 +104,6 @@ void TestQgsGradients::initTestCase() // and is more light weight // mMapSettings.setLayers( QList() << mpPolysLayer ); - } void TestQgsGradients::cleanupTestCase() { diff --git a/tests/src/core/testqgsgraduatedsymbolrenderer.cpp b/tests/src/core/testqgsgraduatedsymbolrenderer.cpp index 057bd4ca9dd9..fbf892583a4a 100644 --- a/tests/src/core/testqgsgraduatedsymbolrenderer.cpp +++ b/tests/src/core/testqgsgraduatedsymbolrenderer.cpp @@ -30,15 +30,15 @@ * This is a unit test for the qgsGraduatedSymbolRenderer class. */ -class TestQgsGraduatedSymbolRenderer: public QObject +class TestQgsGraduatedSymbolRenderer : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void rangesOverlap(); void rangesHaveGaps(); void classifySymmetric(); @@ -49,22 +49,18 @@ class TestQgsGraduatedSymbolRenderer: public QObject void TestQgsGraduatedSymbolRenderer::initTestCase() { - } void TestQgsGraduatedSymbolRenderer::cleanupTestCase() { - } void TestQgsGraduatedSymbolRenderer::init() { - } void TestQgsGraduatedSymbolRenderer::cleanup() { - } void TestQgsGraduatedSymbolRenderer::rangesOverlap() @@ -153,9 +149,9 @@ void TestQgsGraduatedSymbolRenderer::classifySymmetric() { // minimum < symmetryPointForEqualInterval < maximum // going below 1E-6 will result in a fail because C++ think 2.6e-06 - 2e-06 = 0 - QList minimum = {15.30, 20, 20, 1111, 0.26, 0.000026, -1.56E10}; - QList symmetryPointForEqualInterval = {122.6, 24.3, 26.3, 1563.3, 0.34, 0.000034, 0.56E10}; - QList maximum = {253.6, 30, 30, 2222, 0.55, 0.000055, 1.25E10}; + QList minimum = { 15.30, 20, 20, 1111, 0.26, 0.000026, -1.56E10 }; + QList symmetryPointForEqualInterval = { 122.6, 24.3, 26.3, 1563.3, 0.34, 0.000034, 0.56E10 }; + QList maximum = { 253.6, 30, 30, 2222, 0.55, 0.000055, 1.25E10 }; int newPosOfSymmetryPoint = 0; bool astride = false; @@ -184,7 +180,7 @@ void TestQgsGraduatedSymbolRenderer::classifySymmetric() QCOMPARE( breaks.count() % 2, 0 ); // because the minimum is not in the breaks const int newPosOfSymmetryPoint = breaks.count() / 2; - QCOMPARE( breaks[ newPosOfSymmetryPoint - 1 ], symmetryPoint ); + QCOMPARE( breaks[newPosOfSymmetryPoint - 1], symmetryPoint ); // with astride = true astride = true; @@ -205,8 +201,8 @@ void TestQgsGraduatedSymbolRenderer::classifySymmetric() breaks = QgsClassificationMethod::rangesToBreaks( ranges ); QCOMPARE( breaks.count() % 2, 0 ); // because the minimum is not in the breaks - newPosOfSymmetryPoint = breaks.count() / 2 ; - QCOMPARE( breaks[ newPosOfSymmetryPoint - 1 ], symmetryPointForEqualInterval[valTest] ); + newPosOfSymmetryPoint = breaks.count() / 2; + QCOMPARE( breaks[newPosOfSymmetryPoint - 1], symmetryPointForEqualInterval[valTest] ); // with astride = true astride = true; diff --git a/tests/src/core/testqgshistogram.cpp b/tests/src/core/testqgshistogram.cpp index facd924068b7..331dd0b3c45a 100644 --- a/tests/src/core/testqgshistogram.cpp +++ b/tests/src/core/testqgshistogram.cpp @@ -44,7 +44,6 @@ class TestQgsHistogram : public QObject void fromLayer(); private: - }; TestQgsHistogram::TestQgsHistogram() = default; @@ -53,7 +52,6 @@ void TestQgsHistogram::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsHistogram::cleanupTestCase() @@ -143,7 +141,7 @@ void TestQgsHistogram::fromLayer() QVERIFY( !h.setValues( layer, QString() ) ); QVERIFY( h.setValues( layer, QString( "col1" ) ) ); - const QListcounts = h.counts( 5 ); + const QList counts = h.counts( 5 ); QList expected; expected << 2 << 2 << 2 << 2 << 2; QCOMPARE( counts, expected ); diff --git a/tests/src/core/testqgshttpheaders.cpp b/tests/src/core/testqgshttpheaders.cpp index 913e5e8b6670..9c2df3cc20ec 100644 --- a/tests/src/core/testqgshttpheaders.cpp +++ b/tests/src/core/testqgshttpheaders.cpp @@ -27,18 +27,17 @@ #include #include -class TestQgsHttpheaders: public QObject +class TestQgsHttpheaders : public QObject { - Q_OBJECT private: void setFromSettings( const QString &base ); private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase() {} // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void sanitize(); @@ -57,15 +56,14 @@ class TestQgsHttpheaders: public QObject void TestQgsHttpheaders::initTestCase() { - } void TestQgsHttpheaders::sanitize() { QgsHttpHeaders h; - QCOMPARE( h.sanitizeKey( "qgis//mytest1/" ), "qgis/mytest1" ) ; - QCOMPARE( h.sanitizeKey( "qgis/mytest1/" ), "qgis/mytest1" ) ; + QCOMPARE( h.sanitizeKey( "qgis//mytest1/" ), "qgis/mytest1" ); + QCOMPARE( h.sanitizeKey( "qgis/mytest1/" ), "qgis/mytest1" ); } void TestQgsHttpheaders::setFromSettingsGoodKey() @@ -91,16 +89,16 @@ void TestQgsHttpheaders::setFromSettings( const QString &keyBase ) Q_NOWARN_DEPRECATED_PUSH QgsHttpHeaders h( settings, keyBase ); - QVERIFY( ! h.keys().contains( outOfHeaderKey ) ); + QVERIFY( !h.keys().contains( outOfHeaderKey ) ); QVERIFY( h.keys().contains( QStringLiteral( "key1" ) ) ); - QCOMPARE( h [ QStringLiteral( "key1" ) ].toString(), QStringLiteral( "value1" ) ); + QCOMPARE( h[QStringLiteral( "key1" )].toString(), QStringLiteral( "value1" ) ); QVERIFY( h.keys().contains( QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( h [QgsHttpHeaders::KEY_REFERER ].toString(), QStringLiteral( "valueHH_R" ) ); + QCOMPARE( h[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "valueHH_R" ) ); settings.setValue( keyBase + QgsHttpHeaders::KEY_REFERER, "value_R" ); QgsHttpHeaders h2( settings, keyBase ); QVERIFY( h2.keys().contains( QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( h2 [QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "value_R" ) ); + QCOMPARE( h2[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "value_R" ) ); Q_NOWARN_DEPRECATED_POP } @@ -113,25 +111,25 @@ void TestQgsHttpheaders::updateSettings() Q_NOWARN_DEPRECATED_PUSH - QgsHttpHeaders h( QVariantMap( { {QStringLiteral( "key1" ), "value1"}} ) ); + QgsHttpHeaders h( QVariantMap( { { QStringLiteral( "key1" ), "value1" } } ) ); h.updateSettings( settings, keyBase ); QVERIFY( settings.contains( keyBase + QgsHttpHeaders::PATH_PREFIX + "key1" ) ); QCOMPARE( settings.value( keyBase + QgsHttpHeaders::PATH_PREFIX + "key1" ).toString(), "value1" ); - QVERIFY( ! settings.contains( keyBase + QgsHttpHeaders::KEY_REFERER ) ); - QVERIFY( ! settings.contains( keyBase + QgsHttpHeaders::PATH_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); + QVERIFY( !settings.contains( keyBase + QgsHttpHeaders::KEY_REFERER ) ); + QVERIFY( !settings.contains( keyBase + QgsHttpHeaders::PATH_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); // at old location settings.remove( keyBase + QgsHttpHeaders::KEY_REFERER ); - h [QgsHttpHeaders::KEY_REFERER] = QStringLiteral( "http://gg.com" ); + h[QgsHttpHeaders::KEY_REFERER] = QStringLiteral( "http://gg.com" ); h.updateSettings( settings, keyBase ); QVERIFY( settings.contains( keyBase + QgsHttpHeaders::PATH_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); QCOMPARE( settings.value( keyBase + QgsHttpHeaders::PATH_PREFIX + QgsHttpHeaders::KEY_REFERER ).toString(), "http://gg.com" ); - QVERIFY( ! settings.contains( keyBase + QgsHttpHeaders::KEY_REFERER ) ); + QVERIFY( !settings.contains( keyBase + QgsHttpHeaders::KEY_REFERER ) ); // test backward compatibility - settings.setValue( keyBase + QgsHttpHeaders::KEY_REFERER, "paf" ) ; // legacy referer, should be overridden + settings.setValue( keyBase + QgsHttpHeaders::KEY_REFERER, "paf" ); // legacy referer, should be overridden h.updateSettings( settings, keyBase ); QVERIFY( settings.contains( keyBase + QgsHttpHeaders::PATH_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); QCOMPARE( settings.value( keyBase + QgsHttpHeaders::PATH_PREFIX + QgsHttpHeaders::KEY_REFERER ).toString(), "http://gg.com" ); @@ -144,8 +142,8 @@ void TestQgsHttpheaders::updateSettings() void TestQgsHttpheaders::createQgsOwsConnection() { - QgsHttpHeaders h( QVariantMap( { { QgsHttpHeaders::KEY_REFERER, "http://test.com"}, {"other_http_header", "value"}} ) ); - QgsOwsConnection::settingsHeaders->setValue( h.headers(), {"service", "name"} ); + QgsHttpHeaders h( QVariantMap( { { QgsHttpHeaders::KEY_REFERER, "http://test.com" }, { "other_http_header", "value" } } ) ); + QgsOwsConnection::settingsHeaders->setValue( h.headers(), { "service", "name" } ); QgsOwsConnection ows( "service", "name" ); QCOMPARE( ows.connectionInfo(), ",authcfg=,referer=http://test.com" ); @@ -169,7 +167,7 @@ void TestQgsHttpheaders::updateNetworkRequest() { const QUrl url( "http://ogc.org" ); QNetworkRequest request( url ); - QgsHttpHeaders h( QVariantMap( { {QStringLiteral( "key1" ), "value1"}, {QgsHttpHeaders::KEY_REFERER, "my_ref"}} ) ); + QgsHttpHeaders h( QVariantMap( { { QStringLiteral( "key1" ), "value1" }, { QgsHttpHeaders::KEY_REFERER, "my_ref" } } ) ); h.updateNetworkRequest( request ); QVERIFY( request.hasRawHeader( "key1" ) ); @@ -187,8 +185,8 @@ void TestQgsHttpheaders::setFromUrlQuery() QUrlQuery url( "https://www.ogc.org/?p1=v1&http-header:other_http_header=value&http-header:referer=http://test.new.com" ); QgsHttpHeaders h; h.setFromUrlQuery( url ); - QCOMPARE( h[QgsHttpHeaders::KEY_REFERER ].toString(), QStringLiteral( "http://test.new.com" ) ); - QCOMPARE( h[ "other_http_header" ].toString(), QStringLiteral( "value" ) ); + QCOMPARE( h[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "http://test.new.com" ) ); + QCOMPARE( h["other_http_header"].toString(), QStringLiteral( "value" ) ); } { @@ -196,8 +194,8 @@ void TestQgsHttpheaders::setFromUrlQuery() QUrlQuery url( "https://www.ogc.org/?p1=v1&referer=http://test.old.com&http-header:other_http_header=value&http-header:referer=http://test.new.com" ); QgsHttpHeaders h; h.setFromUrlQuery( url ); - QCOMPARE( h[QgsHttpHeaders::KEY_REFERER ].toString(), QStringLiteral( "http://test.new.com" ) ); - QCOMPARE( h[ "other_http_header" ].toString(), QStringLiteral( "value" ) ); + QCOMPARE( h[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "http://test.new.com" ) ); + QCOMPARE( h["other_http_header"].toString(), QStringLiteral( "value" ) ); } { @@ -205,8 +203,8 @@ void TestQgsHttpheaders::setFromUrlQuery() QUrlQuery url( "https://www.ogc.org/?p1=v1&referer=http://test.old.com&http-header:other_http_header=value" ); QgsHttpHeaders h; h.setFromUrlQuery( url ); - QCOMPARE( h[QgsHttpHeaders::KEY_REFERER ].toString(), QStringLiteral( "http://test.old.com" ) ); - QCOMPARE( h[ "other_http_header" ].toString(), QStringLiteral( "value" ) ); + QCOMPARE( h[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "http://test.old.com" ) ); + QCOMPARE( h["other_http_header"].toString(), QStringLiteral( "value" ) ); } } @@ -215,14 +213,14 @@ void TestQgsHttpheaders::updateSetUrlQuery() { QUrlQuery url( "http://ogc.org" ); // === update - QgsHttpHeaders h( QVariantMap( { {QStringLiteral( "key1" ), "value1"}, {QgsHttpHeaders::KEY_REFERER, "my_ref"}} ) ); + QgsHttpHeaders h( QVariantMap( { { QStringLiteral( "key1" ), "value1" }, { QgsHttpHeaders::KEY_REFERER, "my_ref" } } ) ); h.updateUrlQuery( url ); - QVERIFY( url.hasQueryItem( QgsHttpHeaders::PARAM_PREFIX + "key1" ) ); - QCOMPARE( url.queryItemValue( QgsHttpHeaders::PARAM_PREFIX + "key1" ), "value1" ); + QVERIFY( url.hasQueryItem( QgsHttpHeaders::PARAM_PREFIX + "key1" ) ); + QCOMPARE( url.queryItemValue( QgsHttpHeaders::PARAM_PREFIX + "key1" ), "value1" ); - QVERIFY( url.hasQueryItem( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( url.queryItemValue( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ), "my_ref" ); + QVERIFY( url.hasQueryItem( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); + QCOMPARE( url.queryItemValue( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ), "my_ref" ); // TODO mandatory or not? /*QVERIFY( url.hasQueryItem( QgsHttpHeaders::KEY_REFERER ) ); @@ -235,10 +233,9 @@ void TestQgsHttpheaders::updateSetUrlQuery() */ h2.setFromUrlQuery( url ); QVERIFY( h2.keys().contains( QStringLiteral( "key1" ) ) ); - QCOMPARE( h2 [ QStringLiteral( "key1" ) ].toString(), QStringLiteral( "value1" ) ); + QCOMPARE( h2[QStringLiteral( "key1" )].toString(), QStringLiteral( "value1" ) ); QVERIFY( h2.keys().contains( QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( h2 [QgsHttpHeaders::KEY_REFERER ].toString(), QStringLiteral( "my_ref" ) ); - + QCOMPARE( h2[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "my_ref" ) ); } @@ -246,14 +243,14 @@ void TestQgsHttpheaders::updateSetMap() { QVariantMap map; // === update - QgsHttpHeaders h( QVariantMap( { {QStringLiteral( "key1" ), "value1"}, {QgsHttpHeaders::KEY_REFERER, "my_ref"}} ) ); + QgsHttpHeaders h( QVariantMap( { { QStringLiteral( "key1" ), "value1" }, { QgsHttpHeaders::KEY_REFERER, "my_ref" } } ) ); h.updateMap( map ); - QVERIFY( map.contains( QgsHttpHeaders::PARAM_PREFIX + "key1" ) ); - QCOMPARE( map[QgsHttpHeaders::PARAM_PREFIX + "key1"], "value1" ); + QVERIFY( map.contains( QgsHttpHeaders::PARAM_PREFIX + "key1" ) ); + QCOMPARE( map[QgsHttpHeaders::PARAM_PREFIX + "key1"], "value1" ); - QVERIFY( map.contains( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( map[QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER], "my_ref" ); + QVERIFY( map.contains( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); + QCOMPARE( map[QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER], "my_ref" ); QVERIFY( map.contains( QgsHttpHeaders::KEY_REFERER ) ); QCOMPARE( map[QgsHttpHeaders::KEY_REFERER], "my_ref" ); @@ -263,9 +260,9 @@ void TestQgsHttpheaders::updateSetMap() map[QgsHttpHeaders::KEY_REFERER] = "my_ref_root"; // overwrite root ref to ckeck backward compatibility h2.setFromMap( map ); QVERIFY( h2.keys().contains( QStringLiteral( "key1" ) ) ); - QCOMPARE( h2 [ QStringLiteral( "key1" ) ].toString(), QStringLiteral( "value1" ) ); + QCOMPARE( h2[QStringLiteral( "key1" )].toString(), QStringLiteral( "value1" ) ); QVERIFY( h2.keys().contains( QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( h2 [QgsHttpHeaders::KEY_REFERER ].toString(), QStringLiteral( "my_ref_root" ) ); + QCOMPARE( h2[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "my_ref_root" ) ); } @@ -274,14 +271,14 @@ void TestQgsHttpheaders::updateSetDomElement() QDomDocument doc( QStringLiteral( "connections" ) ); QDomElement element = doc.createElement( "qgs" ); // === update - QgsHttpHeaders h( QVariantMap( { {QStringLiteral( "key1" ), "value1"}, {QgsHttpHeaders::KEY_REFERER, "my_ref"}} ) ); + QgsHttpHeaders h( QVariantMap( { { QStringLiteral( "key1" ), "value1" }, { QgsHttpHeaders::KEY_REFERER, "my_ref" } } ) ); h.updateDomElement( element ); - QVERIFY( element.hasAttribute( QgsHttpHeaders::PARAM_PREFIX + "key1" ) ); - QCOMPARE( element.attribute( QgsHttpHeaders::PARAM_PREFIX + "key1" ), "value1" ); + QVERIFY( element.hasAttribute( QgsHttpHeaders::PARAM_PREFIX + "key1" ) ); + QCOMPARE( element.attribute( QgsHttpHeaders::PARAM_PREFIX + "key1" ), "value1" ); - QVERIFY( element.hasAttribute( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( element.attribute( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ), "my_ref" ); + QVERIFY( element.hasAttribute( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ) ); + QCOMPARE( element.attribute( QgsHttpHeaders::PARAM_PREFIX + QgsHttpHeaders::KEY_REFERER ), "my_ref" ); // TODO mandatory or not? QVERIFY( element.hasAttribute( QgsHttpHeaders::KEY_REFERER ) ); @@ -292,9 +289,9 @@ void TestQgsHttpheaders::updateSetDomElement() element.setAttribute( QgsHttpHeaders::KEY_REFERER, "my_ref_root" ); // overwrite root ref to ckeck backward compatibility h2.setFromDomElement( element ); QVERIFY( h2.keys().contains( QStringLiteral( "key1" ) ) ); - QCOMPARE( h2 [ QStringLiteral( "key1" ) ].toString(), QStringLiteral( "value1" ) ); + QCOMPARE( h2[QStringLiteral( "key1" )].toString(), QStringLiteral( "value1" ) ); QVERIFY( h2.keys().contains( QgsHttpHeaders::KEY_REFERER ) ); - QCOMPARE( h2 [QgsHttpHeaders::KEY_REFERER ].toString(), QStringLiteral( "my_ref_root" ) ); + QCOMPARE( h2[QgsHttpHeaders::KEY_REFERER].toString(), QStringLiteral( "my_ref_root" ) ); } QGSTEST_MAIN( TestQgsHttpheaders ) diff --git a/tests/src/core/testqgsimagecache.cpp b/tests/src/core/testqgsimagecache.cpp index 640ff427f27c..69b6b31b9a62 100644 --- a/tests/src/core/testqgsimagecache.cpp +++ b/tests/src/core/testqgsimagecache.cpp @@ -42,21 +42,21 @@ class TestQgsImageCache : public QgsTest Q_OBJECT public: - TestQgsImageCache() : QgsTest( QStringLiteral( "QgsImageCache Tests" ) ) {} + TestQgsImageCache() + : QgsTest( QStringLiteral( "QgsImageCache Tests" ) ) {} private: - bool imageCheck( const QString &testName, const QImage &image, int mismatchCount ); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void fillCache(); void threadSafeImage(); void broken(); void changeImage(); // check that cache is updated if image source file changes - void size(); // check various size-specific handling - void opacity(); // check non-opaque image rendering + void size(); // check various size-specific handling + void opacity(); // check non-opaque image rendering void base64(); void empty(); void dpi(); @@ -106,23 +106,23 @@ void TestQgsImageCache::fillCache() struct RenderImageWrapper { - QgsImageCache &cache; - QString imagePath; - QSize size = QSize{ 100, 100 }; - explicit RenderImageWrapper( QgsImageCache &cache, const QString &imagePath ) - : cache( cache ) - , imagePath( imagePath ) - {} - void operator()( int ) - { - bool fitInCache = false; - const QImage im = cache.pathAsImage( imagePath, size, true, 1.0, fitInCache ); - const QSize imageSize = im.size(); - QImage image( imageSize, QImage::Format_ARGB32_Premultiplied ); - image.fill( 0 ); // transparent background - QPainter p( &image ); - p.drawImage( 0, 0, im ); - } + QgsImageCache &cache; + QString imagePath; + QSize size = QSize { 100, 100 }; + explicit RenderImageWrapper( QgsImageCache &cache, const QString &imagePath ) + : cache( cache ) + , imagePath( imagePath ) + {} + void operator()( int ) + { + bool fitInCache = false; + const QImage im = cache.pathAsImage( imagePath, size, true, 1.0, fitInCache ); + const QSize imageSize = im.size(); + QImage image( imageSize, QImage::Format_ARGB32_Premultiplied ); + image.fill( 0 ); // transparent background + QPainter p( &image ); + p.drawImage( 0, 0, im ); + } }; void TestQgsImageCache::threadSafeImage() @@ -130,7 +130,7 @@ void TestQgsImageCache::threadSafeImage() // This unit test checks that concurrent rendering of paths as QImage from QgsImageCache // works without issues across threads -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) // test deadlocks on 5.15 - see https://bugreports.qt.io/browse/QTBUG-84857 // this is supposed to be fixed in 5.15.1, but I can still reproduce in Fedora on 5.15.5..! @@ -138,11 +138,10 @@ void TestQgsImageCache::threadSafeImage() const QString imagePath = TEST_DATA_DIR + QStringLiteral( "/sample_image.png" ); // smash picture rendering over multiple threads - QVector< int > list; + QVector list; list.resize( 100 ); QtConcurrent::blockingMap( list, RenderImageWrapper( cache, imagePath ) ); #endif - } void TestQgsImageCache::broken() @@ -150,12 +149,12 @@ void TestQgsImageCache::broken() QgsImageCache cache; bool inCache = false; bool missingImage = false; - cache.pathAsImage( QStringLiteral( "bbbbbbb" ), QSize( 200, 200 ), true, 1.0, inCache, false, 96, -1, &missingImage ); + cache.pathAsImage( QStringLiteral( "bbbbbbb" ), QSize( 200, 200 ), true, 1.0, inCache, false, 96, -1, &missingImage ); QVERIFY( missingImage ); - cache.pathAsImage( QStringLiteral( "bbbbbbb" ), QSize( 200, 200 ), true, 1.0, inCache, false, 96, -1, &missingImage ); + cache.pathAsImage( QStringLiteral( "bbbbbbb" ), QSize( 200, 200 ), true, 1.0, inCache, false, 96, -1, &missingImage ); QVERIFY( missingImage ); const QString originalImage = TEST_DATA_DIR + QStringLiteral( "/sample_image.png" ); - cache.pathAsImage( originalImage, QSize( 200, 200 ), true, 1.0, inCache, false, 96, -1, &missingImage ); + cache.pathAsImage( originalImage, QSize( 200, 200 ), true, 1.0, inCache, false, 96, -1, &missingImage ); QVERIFY( !missingImage ); } @@ -184,7 +183,8 @@ void TestQgsImageCache::changeImage() QElapsedTimer t; t.start(); while ( !t.hasExpired( 1000 ) ) - {} + { + } //replace the image in the temp folder const QString newImage = TEST_DATA_DIR + QStringLiteral( "/sample_image2.png" ); @@ -205,7 +205,8 @@ void TestQgsImageCache::changeImage() // wait a second so that modified time is different t.restart(); while ( !t.hasExpired( 1000 ) ) - {} + { + } //replace the image in the temp folder QFile::remove( tempImagePath ); @@ -285,8 +286,7 @@ void TestQgsImageCache::base64() QVERIFY( !cache.originalSize( QStringLiteral( "base64:zzzzzzzzzzzzzzz" ) ).isValid() ); //valid base 64 - img = cache.pathAsImage( QStringLiteral( "base64:iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAENZJREFUaAXtWwt0VdWZ3vvcmyePAIHaWJEOIMFKBYq2omtGmNbRMoNTpcmqOMJYJfEBU7WixVmjmWlrKT4oWLVWIApTaEMLtda0q84A7cJaB0Gwi4VABZVKoAiSx01Ccu/Z833/Pvvcc8NNuOE1a81yY87e59//6/v/f++zz0lU6qP2/zsC+kzAM6bGe/oXq8YY7U80xowyRg1XWg1TRvXX2vRBX4T7NmN0An2TVuYdpfQe9Dv9eN4fZk/5ynata/wz4dtpA1y7ftyA1sbma43W04xSk5Qx/U/B4UYEY0PcUz+NFZe8WH3V5sZT0JUhesqAn3ih/BKtUnf5RlUAZD61a2gFaCSP6g3IlsY58GHemkX2SZJ7N3b3aSHdgbm6PGW+d8d1b28WgVO4nDTgp9aOmJD09CNAMFkQ0okAme+AADDgCnD2bAyCowkhyyUbb0BbF4/nz509dceWLGI5kXoN+Pv/Nbo01ZJciKj/k0L9wn/gtKDCcZBB8YA4s1g5ToZMTlcP8phiOFfE/fg9s69/63BOKCNMWVyJzHYZLvr5qCm+b5Yg2mVOUPCIFwSNFhnbOdAw4JiNPEKXu2AckcldXjeA95a7r9v1q0BVTp2XExeYFq4d9VDK91+Cs2WUodNcj4TAbLHnvRvLFGnYa92Y3EFYToO8KfN9vx5+1VBvrs0lqlv+Z16fkJfY1/Sc8c10AedcRlbotV2PFI+sTUkjYQb5FF57H/KfTnntrep7fr+Z1Zds7uwWSDDRY4brTEWs+d3GHyFL05kZlykZC1hqIT06h8wj1Y5ms24ze7LyrBIfNqwu9BwLDXoN6eaGpnebVtHfEwGO98Tw3tptS6GwAvolm8KbbdyVpj1b2qSLsGpDvxnEXcrTBxANHjgKtFGD4PdIHEbGA8A5op/8wZoO70kLdn7R58YAK47ZSE57d822WhBmWLnsV3Ep29QjPyu/yxh/oXXYasxtbLVp5SWMNqvwzF01rDy+sfKi7R3Z7DjaI2suHOMbv1Ib/59RHUOFTmAsfbZsYwfc8YBNGzP3vordj4pMlktWwI+tHn15Uvu/hRVUAFhCY3CA2MWADKzKYD7YsNoB8rG8vvHH77lm+5EsNnskcc9ofLd5JjL+LTCeQ/M2u87ViN1QE2j0CX7gOZmKeeZv7522+3fhdGTgtISkxfVfLGht3bMV0qMFnEUo8zQVNrFhN6qQpvUrhTp/xt3T/rgnpJ3kYP7LE0pMY8sTWKA3CeiuerLZB4/ER6k/fXzwuZ++efKG9q5ix21aicTeedh0RsumAKU+1gnjFm4+oDGhPHPwRCVjMaMXX1ZaNul0gKWT38D5ed6Xd87AdjAbMOTwJra6se/8CPwc2fDB/n/rCpb3GRl+uG78EKXa9gJGHzcJ/Wi82ti5o2Fa1GAfij04r2LHN4X1DFy+XTd6Oja2/8SSQZhdVTnXpYzhofU07ZdqL455w++etqMh6lJGhn3Tei/Bci0yYi6DVCI09BJquWemaSS26EyCpbP/WvnWShiDb5n2mU1WYCrobTWSJj+FLSl1fxQsxyHgZ16cUIyFfzuZBaB0jKZVQGOCT4zanIN/4wVqzNfJeqbbA5W7Hof9n6OeVCp4Btts2kzTN+er8x8eVy2u/1zGa2oI+GBr2/UQ6kfmYB2EvcSAgIHKBkSUt8di+TMrK1enzjRYp78wr6AatYd3Yxt8V4HirzARfHpvQWCKjjY1VTp59iFgQJlBBWHJChcUYNUwetHMy6rxvEfmnYbdOOrMicZzr3/zL3D54TAB4hfvmAwLlKc8d099qPiZ7F0TwI/XTSwC4W8oJBHClWICNFQA0MEYFdUSL4rjUHL2W0HhoKfh51H6JskQsNYPHjNJo5uctxjMxPl1E0qcpwK4yRy9AukvIFEwkVMiRiGnwEURSo1aOe8f/vghuc52u/8fX2mGzZUIelB1the/IzT6H1RmrF21X+n8FMDY6q+ggHvmpne9NGBb7jZqKU+tdAr+T3qtfkJALikOXFihwMKc2SAAuO9f4fyUl4dkCqcqySTZ+KSz0XE03rsGpYnzhhf/3t2fqD9y//CS1KCSC7rjy4tp85vXtmytXK1y3vzKRhS/+v7utlacvYu7+kqf+SMlj54HKE/rC519yTAe5+WEapnS0REahTHHaFkef1Mu753OgG8aP5/nd27KKyjO+qPiRa9ffflla9dPUj2+uTl97Gkf1biFa9ZWoytrCzS9DK2Ur1W5kxfAQFIm5ZCxIxNgoIBIgznEa6cTzrX3m3DYaTvaLbvRsanjr73shd6A9pXZJT5Dq/gJXyWzuLrNlXQpa6POdcYFMIj9eGqyWQzWBhW5rApwO4/Ivu+Ee9P7TQeUau1hn/NiUwD6xderVF5Oen3dwDykK88+UiUIkhx72BQepXh6lHXpcYBhsb1nRu2xMroOBHiQZejiLnlSzW8+CNA9vDF6sWsuGD3xl9trLpLv2z0ZMZ5qCc8Mkpj02rWJstUpOPCJ5N9Xj5H3A6xnvDLjdyI2WowKygCWwuxiAuUTlnfKNyf8jNKTo34zzg6J7r+uGs/7u/P6939p95yR8pjsThf8QyUAVOhr8Ph09xIEW+4E16ckRlZ70sKohQCtAsm8BY7US8lIz0DQgM44m1Kqt81vOQTQH3QrBtBfGPJXQ+r31nyysDsmLK0SJoeVSddZmWxCYy9lzXlLH9ZYLu/GsjNCuAk8JSLJC3mIm8wQlCFuBb2nh3F4qs1vAeC++Qfil0/Y142ufoMLy5fsuyUxa+jQ1fgmltlQc2Xin/hqkyQc9Jk0tsB/bFSH3ZlfAGN+LyaHCkoADFswliAJmRf9qXA+hwFWCz6d2odBV3ZdmDhohrZfqr2BXafkHn5dWmIKzt+3r+LqLKDH2n3HioqPMgz8F9AYo0fWw43WeuKbna4UeNomrwSKzCKQ0Y+/74Ur8FaVWxvy3Q9/ibJa1h238ZtwEuphI9PeXw8oGPSb/funFkd1+Cndn8tNjpi42PImB8u4i/9av+VkBTCeg9sdMO58IXgnHPZS1fFUY+NVTkEOvSmdf+RWaF3aHa/xmwU0MoY6j2Erz/zB/nRBgTqvru73FUVOR8zzrsJywwOeCbJrlb3sOQFNzg4Yg2ebk5OS9jzvt0mcwYJiQIQQIjR75QCqZBMIqNq7CaM1vMuxmdLvHJl1eN4g2NC3ZJMh6B+8diCl9MBzaJf26EHgCkX+HnDW1dRNuqqmckPLgpve3Hnfiosndxp/PXjKCC7tP9lt4qgASXyFFDbJ8ILpb2xDJR+2H+5chp04o2cjR4Eg+1Pn/njCCN73ogloBHNJdzKJjkb/aCseW2gMumG9hjCYydhl+fkl/71041dlSRG0r73J+NDXwMBIiQdZop/SPN1SUjj6VXsTAOazGIpfJK8AwiBDAWTdPXs+izs6jj3olPSiZ3lXAcqzWWVw6G3taFYETTvMmgDnGI1jfOD/7IFDh9fNf7lC3nEXOdAo74DNniOEH0Hw9a9rKleHvwQIt0/PeMsZTQuM0WRWbWbZu3sbENB9ddNdz40LX7vEo9wuzHQ1nP9hNnbuIYljzerDxEHYZ4oRbQAP1yZQAfQlqZbODNDG05ORuAbhg7/kot/4tyJqJwT82IytG2BrjwACPAJncVtBlou9C+l4svsmtfz+yNeEqOITjJnp2/xBBb+I8tFZFh1ttHW2BKADX2QuXbZYZp/xE53ra9Z+aQClmGm8BwpoekodQPvOwGGD6jnvWgiYZW2Mt8AaRXSEw0bWMtvsU48NCkobf52TSHSsrFk/KedXO2eYakordjyE/pkIDY7CQpDR1o6EOpJokGC7wFteVhzBe+NjSm2oqbt6EOkErWN6Mngb+NqofG9+zeQNSc65FgImobTvqFpEZZ8tW64ZgrMAbSBshC2dZSP3Uw69c/i5kwU94Nz622HhB9RFvQw0QXNMkO2dbeowQEvWOAcaq00CAKeQ6bGxeNGGeWuuK6UEQcfiBZPBtknwkBhp1usI4c7ai7+C90n+1k+oNG6HvLeGOGHpjDRdwD+t6vv2yZv+3cqT+hMjfXT/F59csP7Alz48lpK/MLDGadHqL8grUgOKy1C1GTlybPRoe5/8wkn3Tl0lh3QmoGt2yXwcYBJvrx37a3wHuppAxCDQSKlRIBhzjv8JcOHjnNmj497Mp2Zs20g9vWz6zufHLkomzRybXWuLOlzQ82JFanA/xsOCzkyBBGcHXJlUc/1a+2zL4sDx4QJTfixeBXNHpKoIJigvIuSYMSeJz22h4Uo6dsXhqU7zu9uXjXv+jhWfGcnZXjTz5Mxt/wIwT1kZG2QbaGu3I9muPmhGedsHtPhAXvFFhPSFSMSGB164NvjlutUUvWbNMBnuqL34Gj+lXsJmzI8EoNh42lFmbF3ZZfRap8D1K/ys0IX9Xn76xo09fO6IuqRU1dJx38cfrNzZtZrIRV9Y3qV9babtcovIw0F4vFMlj02qqazHZ5bMRs+7bdVLx9/j+6nHhMFpDrFTc0Tc0btqg4PgQvK9HSj5t5TxGvC1IoHf9PNcPBCbTjnUpPLi+VOfnPk/4ZeBWUvGP4FD4WxJH81Qv2u4z4sXqNI+56bXdFcepXYntbry4WlrcN5ON7L12KqeHVfja/MQDWZgCgy4NR5ORvhC/pDX1okYDGkIiAROv+kVxz7/w+mbwy8Dtz47djE24jkynUUZgqQG9/0EMoqHUxYHEeC3U6nYld+uXB2+Hp4QMJ27dem4B1BK34JO8AeeitfuAhrL/jht3fBKdJwseyuvvW5AKz0n5BY7zp5WeV6eKu33CRXTAWhGhzxsNlJvx4qxkU1Z82eSsm5anIi2JbdsfVib2A1Q0841JJsWbqjX/oAG5TKG8xl08nSlZdxTh5XH4/DiZMJfN2cZfzFv25JZ3Mj0YuEhn8im+45UpzrU9GccgpIyJy9A4JHjMGzjLD2io9nHJmxbToDJumTWlp/ETP4liNG2EDSNu5/QmQCgo7MX0BF6wBt8I8NhAw5ix7e9+XRLyqy7OQJ62aw3vsZfvFtbsiEAULrvSCXVwcYGlcQuC3Jojzy8j7acAVPo2apN288fMPKzAP0f2GzwB95Woe1ZvpF7zFmnbM9fZKfv7ZGVcuJUoIelTVAAP8ZPmvW3Lb/8Y6IUl9qqLfgzKvU98ls+B4wySnX6Hepg0/sAzUxbHsdnH59CzK2kLau98lWrtuqNh3RevBxrZAVKJimZgRX5zbzLlLAHFYA5dxx0ztjSzHSavzEIq8eoi9ra29ZFQT9fvfVuyC+MgrZe2SpKsryb96tkKiX27AuPTYTD0KsMOyH2tV/dtO+5qjdmYIscgQX8KHZaHFQcQDrusodxsL7FAXnltPPcVBxwl117H8j76qLWtra6urr0nxSuqN56D+QWSnBYDYEdJ9+J8j7UbDNNGtMt56PA+ZMG7MAvr9783vLbtswtMN7H8XiYAgi1CMJ7rpy6AqKcA0Vn8Z9k1WbNjgFoL+SX4iF7zfBRJV9wn1idzRXVWwA69rjoog78pHWhvAPQncg49Uf35sx8y+Tpudy87NKhncdSEz1Pl+PUNAJaPwkQ/XEK6oNlUAR6G/LYAm/xP3l47yD7fwJtV4EXf3XJrNfkEXIiT258esKjOJx8Xc71YIY+xAohZwTQYjquhvQvU3Ed/+aCG9Y8SNoZA0zlZ6MB9HewSioI0h5grNUQtBfXA/sOXvTEjfWLz4Y/H9n4KAJnOQL/C8Ko4jCW8i6JAAAAAElFTkSuQmCC" ), - QSize( 200, 200 ), true, 1.0, inCache ); + img = cache.pathAsImage( QStringLiteral( "base64:iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAENZJREFUaAXtWwt0VdWZ3vvcmyePAIHaWJEOIMFKBYq2omtGmNbRMoNTpcmqOMJYJfEBU7WixVmjmWlrKT4oWLVWIApTaEMLtda0q84A7cJaB0Gwi4VABZVKoAiSx01Ccu/Z833/Pvvcc8NNuOE1a81yY87e59//6/v/f++zz0lU6qP2/zsC+kzAM6bGe/oXq8YY7U80xowyRg1XWg1TRvXX2vRBX4T7NmN0An2TVuYdpfQe9Dv9eN4fZk/5ynata/wz4dtpA1y7ftyA1sbma43W04xSk5Qx/U/B4UYEY0PcUz+NFZe8WH3V5sZT0JUhesqAn3ih/BKtUnf5RlUAZD61a2gFaCSP6g3IlsY58GHemkX2SZJ7N3b3aSHdgbm6PGW+d8d1b28WgVO4nDTgp9aOmJD09CNAMFkQ0okAme+AADDgCnD2bAyCowkhyyUbb0BbF4/nz509dceWLGI5kXoN+Pv/Nbo01ZJciKj/k0L9wn/gtKDCcZBB8YA4s1g5ToZMTlcP8phiOFfE/fg9s69/63BOKCNMWVyJzHYZLvr5qCm+b5Yg2mVOUPCIFwSNFhnbOdAw4JiNPEKXu2AckcldXjeA95a7r9v1q0BVTp2XExeYFq4d9VDK91+Cs2WUodNcj4TAbLHnvRvLFGnYa92Y3EFYToO8KfN9vx5+1VBvrs0lqlv+Z16fkJfY1/Sc8c10AedcRlbotV2PFI+sTUkjYQb5FF57H/KfTnntrep7fr+Z1Zds7uwWSDDRY4brTEWs+d3GHyFL05kZlykZC1hqIT06h8wj1Y5ms24ze7LyrBIfNqwu9BwLDXoN6eaGpnebVtHfEwGO98Tw3tptS6GwAvolm8KbbdyVpj1b2qSLsGpDvxnEXcrTBxANHjgKtFGD4PdIHEbGA8A5op/8wZoO70kLdn7R58YAK47ZSE57d822WhBmWLnsV3Ep29QjPyu/yxh/oXXYasxtbLVp5SWMNqvwzF01rDy+sfKi7R3Z7DjaI2suHOMbv1Ib/59RHUOFTmAsfbZsYwfc8YBNGzP3vordj4pMlktWwI+tHn15Uvu/hRVUAFhCY3CA2MWADKzKYD7YsNoB8rG8vvHH77lm+5EsNnskcc9ofLd5JjL+LTCeQ/M2u87ViN1QE2j0CX7gOZmKeeZv7522+3fhdGTgtISkxfVfLGht3bMV0qMFnEUo8zQVNrFhN6qQpvUrhTp/xt3T/rgnpJ3kYP7LE0pMY8sTWKA3CeiuerLZB4/ER6k/fXzwuZ++efKG9q5ix21aicTeedh0RsumAKU+1gnjFm4+oDGhPHPwRCVjMaMXX1ZaNul0gKWT38D5ed6Xd87AdjAbMOTwJra6se/8CPwc2fDB/n/rCpb3GRl+uG78EKXa9gJGHzcJ/Wi82ti5o2Fa1GAfij04r2LHN4X1DFy+XTd6Oja2/8SSQZhdVTnXpYzhofU07ZdqL455w++etqMh6lJGhn3Tei/Bci0yYi6DVCI09BJquWemaSS26EyCpbP/WvnWShiDb5n2mU1WYCrobTWSJj+FLSl1fxQsxyHgZ16cUIyFfzuZBaB0jKZVQGOCT4zanIN/4wVqzNfJeqbbA5W7Hof9n6OeVCp4Btts2kzTN+er8x8eVy2u/1zGa2oI+GBr2/UQ6kfmYB2EvcSAgIHKBkSUt8di+TMrK1enzjRYp78wr6AatYd3Yxt8V4HirzARfHpvQWCKjjY1VTp59iFgQJlBBWHJChcUYNUwetHMy6rxvEfmnYbdOOrMicZzr3/zL3D54TAB4hfvmAwLlKc8d099qPiZ7F0TwI/XTSwC4W8oJBHClWICNFQA0MEYFdUSL4rjUHL2W0HhoKfh51H6JskQsNYPHjNJo5uctxjMxPl1E0qcpwK4yRy9AukvIFEwkVMiRiGnwEURSo1aOe8f/vghuc52u/8fX2mGzZUIelB1the/IzT6H1RmrF21X+n8FMDY6q+ggHvmpne9NGBb7jZqKU+tdAr+T3qtfkJALikOXFihwMKc2SAAuO9f4fyUl4dkCqcqySTZ+KSz0XE03rsGpYnzhhf/3t2fqD9y//CS1KCSC7rjy4tp85vXtmytXK1y3vzKRhS/+v7utlacvYu7+kqf+SMlj54HKE/rC519yTAe5+WEapnS0REahTHHaFkef1Mu753OgG8aP5/nd27KKyjO+qPiRa9ffflla9dPUj2+uTl97Gkf1biFa9ZWoytrCzS9DK2Ur1W5kxfAQFIm5ZCxIxNgoIBIgznEa6cTzrX3m3DYaTvaLbvRsanjr73shd6A9pXZJT5Dq/gJXyWzuLrNlXQpa6POdcYFMIj9eGqyWQzWBhW5rApwO4/Ivu+Ee9P7TQeUau1hn/NiUwD6xderVF5Oen3dwDykK88+UiUIkhx72BQepXh6lHXpcYBhsb1nRu2xMroOBHiQZejiLnlSzW8+CNA9vDF6sWsuGD3xl9trLpLv2z0ZMZ5qCc8Mkpj02rWJstUpOPCJ5N9Xj5H3A6xnvDLjdyI2WowKygCWwuxiAuUTlnfKNyf8jNKTo34zzg6J7r+uGs/7u/P6939p95yR8pjsThf8QyUAVOhr8Ph09xIEW+4E16ckRlZ70sKohQCtAsm8BY7US8lIz0DQgM44m1Kqt81vOQTQH3QrBtBfGPJXQ+r31nyysDsmLK0SJoeVSddZmWxCYy9lzXlLH9ZYLu/GsjNCuAk8JSLJC3mIm8wQlCFuBb2nh3F4qs1vAeC++Qfil0/Y142ufoMLy5fsuyUxa+jQ1fgmltlQc2Xin/hqkyQc9Jk0tsB/bFSH3ZlfAGN+LyaHCkoADFswliAJmRf9qXA+hwFWCz6d2odBV3ZdmDhohrZfqr2BXafkHn5dWmIKzt+3r+LqLKDH2n3HioqPMgz8F9AYo0fWw43WeuKbna4UeNomrwSKzCKQ0Y+/74Ur8FaVWxvy3Q9/ibJa1h238ZtwEuphI9PeXw8oGPSb/funFkd1+Cndn8tNjpi42PImB8u4i/9av+VkBTCeg9sdMO58IXgnHPZS1fFUY+NVTkEOvSmdf+RWaF3aHa/xmwU0MoY6j2Erz/zB/nRBgTqvru73FUVOR8zzrsJywwOeCbJrlb3sOQFNzg4Yg2ebk5OS9jzvt0mcwYJiQIQQIjR75QCqZBMIqNq7CaM1vMuxmdLvHJl1eN4g2NC3ZJMh6B+8diCl9MBzaJf26EHgCkX+HnDW1dRNuqqmckPLgpve3Hnfiosndxp/PXjKCC7tP9lt4qgASXyFFDbJ8ILpb2xDJR+2H+5chp04o2cjR4Eg+1Pn/njCCN73ogloBHNJdzKJjkb/aCseW2gMumG9hjCYydhl+fkl/71041dlSRG0r73J+NDXwMBIiQdZop/SPN1SUjj6VXsTAOazGIpfJK8AwiBDAWTdPXs+izs6jj3olPSiZ3lXAcqzWWVw6G3taFYETTvMmgDnGI1jfOD/7IFDh9fNf7lC3nEXOdAo74DNniOEH0Hw9a9rKleHvwQIt0/PeMsZTQuM0WRWbWbZu3sbENB9ddNdz40LX7vEo9wuzHQ1nP9hNnbuIYljzerDxEHYZ4oRbQAP1yZQAfQlqZbODNDG05ORuAbhg7/kot/4tyJqJwT82IytG2BrjwACPAJncVtBlou9C+l4svsmtfz+yNeEqOITjJnp2/xBBb+I8tFZFh1ttHW2BKADX2QuXbZYZp/xE53ra9Z+aQClmGm8BwpoekodQPvOwGGD6jnvWgiYZW2Mt8AaRXSEw0bWMtvsU48NCkobf52TSHSsrFk/KedXO2eYakordjyE/pkIDY7CQpDR1o6EOpJokGC7wFteVhzBe+NjSm2oqbt6EOkErWN6Mngb+NqofG9+zeQNSc65FgImobTvqFpEZZ8tW64ZgrMAbSBshC2dZSP3Uw69c/i5kwU94Nz622HhB9RFvQw0QXNMkO2dbeowQEvWOAcaq00CAKeQ6bGxeNGGeWuuK6UEQcfiBZPBtknwkBhp1usI4c7ai7+C90n+1k+oNG6HvLeGOGHpjDRdwD+t6vv2yZv+3cqT+hMjfXT/F59csP7Alz48lpK/MLDGadHqL8grUgOKy1C1GTlybPRoe5/8wkn3Tl0lh3QmoGt2yXwcYBJvrx37a3wHuppAxCDQSKlRIBhzjv8JcOHjnNmj497Mp2Zs20g9vWz6zufHLkomzRybXWuLOlzQ82JFanA/xsOCzkyBBGcHXJlUc/1a+2zL4sDx4QJTfixeBXNHpKoIJigvIuSYMSeJz22h4Uo6dsXhqU7zu9uXjXv+jhWfGcnZXjTz5Mxt/wIwT1kZG2QbaGu3I9muPmhGedsHtPhAXvFFhPSFSMSGB164NvjlutUUvWbNMBnuqL34Gj+lXsJmzI8EoNh42lFmbF3ZZfRap8D1K/ys0IX9Xn76xo09fO6IuqRU1dJx38cfrNzZtZrIRV9Y3qV9babtcovIw0F4vFMlj02qqazHZ5bMRs+7bdVLx9/j+6nHhMFpDrFTc0Tc0btqg4PgQvK9HSj5t5TxGvC1IoHf9PNcPBCbTjnUpPLi+VOfnPk/4ZeBWUvGP4FD4WxJH81Qv2u4z4sXqNI+56bXdFcepXYntbry4WlrcN5ON7L12KqeHVfja/MQDWZgCgy4NR5ORvhC/pDX1okYDGkIiAROv+kVxz7/w+mbwy8Dtz47djE24jkynUUZgqQG9/0EMoqHUxYHEeC3U6nYld+uXB2+Hp4QMJ27dem4B1BK34JO8AeeitfuAhrL/jht3fBKdJwseyuvvW5AKz0n5BY7zp5WeV6eKu33CRXTAWhGhzxsNlJvx4qxkU1Z82eSsm5anIi2JbdsfVib2A1Q0841JJsWbqjX/oAG5TKG8xl08nSlZdxTh5XH4/DiZMJfN2cZfzFv25JZ3Mj0YuEhn8im+45UpzrU9GccgpIyJy9A4JHjMGzjLD2io9nHJmxbToDJumTWlp/ETP4liNG2EDSNu5/QmQCgo7MX0BF6wBt8I8NhAw5ix7e9+XRLyqy7OQJ62aw3vsZfvFtbsiEAULrvSCXVwcYGlcQuC3Jojzy8j7acAVPo2apN288fMPKzAP0f2GzwB95Woe1ZvpF7zFmnbM9fZKfv7ZGVcuJUoIelTVAAP8ZPmvW3Lb/8Y6IUl9qqLfgzKvU98ls+B4wySnX6Hepg0/sAzUxbHsdnH59CzK2kLau98lWrtuqNh3RevBxrZAVKJimZgRX5zbzLlLAHFYA5dxx0ztjSzHSavzEIq8eoi9ra29ZFQT9fvfVuyC+MgrZe2SpKsryb96tkKiX27AuPTYTD0KsMOyH2tV/dtO+5qjdmYIscgQX8KHZaHFQcQDrusodxsL7FAXnltPPcVBxwl117H8j76qLWtra6urr0nxSuqN56D+QWSnBYDYEdJ9+J8j7UbDNNGtMt56PA+ZMG7MAvr9783vLbtswtMN7H8XiYAgi1CMJ7rpy6AqKcA0Vn8Z9k1WbNjgFoL+SX4iF7zfBRJV9wn1idzRXVWwA69rjoog78pHWhvAPQncg49Uf35sx8y+Tpudy87NKhncdSEz1Pl+PUNAJaPwkQ/XEK6oNlUAR6G/LYAm/xP3l47yD7fwJtV4EXf3XJrNfkEXIiT258esKjOJx8Xc71YIY+xAohZwTQYjquhvQvU3Ed/+aCG9Y8SNoZA0zlZ6MB9HewSioI0h5grNUQtBfXA/sOXvTEjfWLz4Y/H9n4KAJnOQL/C8Ko4jCW8i6JAAAAAElFTkSuQmCC" ), QSize( 200, 200 ), true, 1.0, inCache ); QVERIFY( imageCheck( QStringLiteral( "imagecache_base64" ), img, 30 ) ); const QSize size = cache.originalSize( QStringLiteral( "base64:iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAENZJREFUaAXtWwt0VdWZ3vvcmyePAIHaWJEOIMFKBYq2omtGmNbRMoNTpcmqOMJYJfEBU7WixVmjmWlrKT4oWLVWIApTaEMLtda0q84A7cJaB0Gwi4VABZVKoAiSx01Ccu/Z833/Pvvcc8NNuOE1a81yY87e59//6/v/f++zz0lU6qP2/zsC+kzAM6bGe/oXq8YY7U80xowyRg1XWg1TRvXX2vRBX4T7NmN0An2TVuYdpfQe9Dv9eN4fZk/5ynata/wz4dtpA1y7ftyA1sbma43W04xSk5Qx/U/B4UYEY0PcUz+NFZe8WH3V5sZT0JUhesqAn3ih/BKtUnf5RlUAZD61a2gFaCSP6g3IlsY58GHemkX2SZJ7N3b3aSHdgbm6PGW+d8d1b28WgVO4nDTgp9aOmJD09CNAMFkQ0okAme+AADDgCnD2bAyCowkhyyUbb0BbF4/nz509dceWLGI5kXoN+Pv/Nbo01ZJciKj/k0L9wn/gtKDCcZBB8YA4s1g5ToZMTlcP8phiOFfE/fg9s69/63BOKCNMWVyJzHYZLvr5qCm+b5Yg2mVOUPCIFwSNFhnbOdAw4JiNPEKXu2AckcldXjeA95a7r9v1q0BVTp2XExeYFq4d9VDK91+Cs2WUodNcj4TAbLHnvRvLFGnYa92Y3EFYToO8KfN9vx5+1VBvrs0lqlv+Z16fkJfY1/Sc8c10AedcRlbotV2PFI+sTUkjYQb5FF57H/KfTnntrep7fr+Z1Zds7uwWSDDRY4brTEWs+d3GHyFL05kZlykZC1hqIT06h8wj1Y5ms24ze7LyrBIfNqwu9BwLDXoN6eaGpnebVtHfEwGO98Tw3tptS6GwAvolm8KbbdyVpj1b2qSLsGpDvxnEXcrTBxANHjgKtFGD4PdIHEbGA8A5op/8wZoO70kLdn7R58YAK47ZSE57d822WhBmWLnsV3Ep29QjPyu/yxh/oXXYasxtbLVp5SWMNqvwzF01rDy+sfKi7R3Z7DjaI2suHOMbv1Ib/59RHUOFTmAsfbZsYwfc8YBNGzP3vordj4pMlktWwI+tHn15Uvu/hRVUAFhCY3CA2MWADKzKYD7YsNoB8rG8vvHH77lm+5EsNnskcc9ofLd5JjL+LTCeQ/M2u87ViN1QE2j0CX7gOZmKeeZv7522+3fhdGTgtISkxfVfLGht3bMV0qMFnEUo8zQVNrFhN6qQpvUrhTp/xt3T/rgnpJ3kYP7LE0pMY8sTWKA3CeiuerLZB4/ER6k/fXzwuZ++efKG9q5ix21aicTeedh0RsumAKU+1gnjFm4+oDGhPHPwRCVjMaMXX1ZaNul0gKWT38D5ed6Xd87AdjAbMOTwJra6se/8CPwc2fDB/n/rCpb3GRl+uG78EKXa9gJGHzcJ/Wi82ti5o2Fa1GAfij04r2LHN4X1DFy+XTd6Oja2/8SSQZhdVTnXpYzhofU07ZdqL455w++etqMh6lJGhn3Tei/Bci0yYi6DVCI09BJquWemaSS26EyCpbP/WvnWShiDb5n2mU1WYCrobTWSJj+FLSl1fxQsxyHgZ16cUIyFfzuZBaB0jKZVQGOCT4zanIN/4wVqzNfJeqbbA5W7Hof9n6OeVCp4Btts2kzTN+er8x8eVy2u/1zGa2oI+GBr2/UQ6kfmYB2EvcSAgIHKBkSUt8di+TMrK1enzjRYp78wr6AatYd3Yxt8V4HirzARfHpvQWCKjjY1VTp59iFgQJlBBWHJChcUYNUwetHMy6rxvEfmnYbdOOrMicZzr3/zL3D54TAB4hfvmAwLlKc8d099qPiZ7F0TwI/XTSwC4W8oJBHClWICNFQA0MEYFdUSL4rjUHL2W0HhoKfh51H6JskQsNYPHjNJo5uctxjMxPl1E0qcpwK4yRy9AukvIFEwkVMiRiGnwEURSo1aOe8f/vghuc52u/8fX2mGzZUIelB1the/IzT6H1RmrF21X+n8FMDY6q+ggHvmpne9NGBb7jZqKU+tdAr+T3qtfkJALikOXFihwMKc2SAAuO9f4fyUl4dkCqcqySTZ+KSz0XE03rsGpYnzhhf/3t2fqD9y//CS1KCSC7rjy4tp85vXtmytXK1y3vzKRhS/+v7utlacvYu7+kqf+SMlj54HKE/rC519yTAe5+WEapnS0REahTHHaFkef1Mu753OgG8aP5/nd27KKyjO+qPiRa9ffflla9dPUj2+uTl97Gkf1biFa9ZWoytrCzS9DK2Ur1W5kxfAQFIm5ZCxIxNgoIBIgznEa6cTzrX3m3DYaTvaLbvRsanjr73shd6A9pXZJT5Dq/gJXyWzuLrNlXQpa6POdcYFMIj9eGqyWQzWBhW5rApwO4/Ivu+Ee9P7TQeUau1hn/NiUwD6xderVF5Oen3dwDykK88+UiUIkhx72BQepXh6lHXpcYBhsb1nRu2xMroOBHiQZejiLnlSzW8+CNA9vDF6sWsuGD3xl9trLpLv2z0ZMZ5qCc8Mkpj02rWJstUpOPCJ5N9Xj5H3A6xnvDLjdyI2WowKygCWwuxiAuUTlnfKNyf8jNKTo34zzg6J7r+uGs/7u/P6939p95yR8pjsThf8QyUAVOhr8Ph09xIEW+4E16ckRlZ70sKohQCtAsm8BY7US8lIz0DQgM44m1Kqt81vOQTQH3QrBtBfGPJXQ+r31nyysDsmLK0SJoeVSddZmWxCYy9lzXlLH9ZYLu/GsjNCuAk8JSLJC3mIm8wQlCFuBb2nh3F4qs1vAeC++Qfil0/Y142ufoMLy5fsuyUxa+jQ1fgmltlQc2Xin/hqkyQc9Jk0tsB/bFSH3ZlfAGN+LyaHCkoADFswliAJmRf9qXA+hwFWCz6d2odBV3ZdmDhohrZfqr2BXafkHn5dWmIKzt+3r+LqLKDH2n3HioqPMgz8F9AYo0fWw43WeuKbna4UeNomrwSKzCKQ0Y+/74Ur8FaVWxvy3Q9/ibJa1h238ZtwEuphI9PeXw8oGPSb/funFkd1+Cndn8tNjpi42PImB8u4i/9av+VkBTCeg9sdMO58IXgnHPZS1fFUY+NVTkEOvSmdf+RWaF3aHa/xmwU0MoY6j2Erz/zB/nRBgTqvru73FUVOR8zzrsJywwOeCbJrlb3sOQFNzg4Yg2ebk5OS9jzvt0mcwYJiQIQQIjR75QCqZBMIqNq7CaM1vMuxmdLvHJl1eN4g2NC3ZJMh6B+8diCl9MBzaJf26EHgCkX+HnDW1dRNuqqmckPLgpve3Hnfiosndxp/PXjKCC7tP9lt4qgASXyFFDbJ8ILpb2xDJR+2H+5chp04o2cjR4Eg+1Pn/njCCN73ogloBHNJdzKJjkb/aCseW2gMumG9hjCYydhl+fkl/71041dlSRG0r73J+NDXwMBIiQdZop/SPN1SUjj6VXsTAOazGIpfJK8AwiBDAWTdPXs+izs6jj3olPSiZ3lXAcqzWWVw6G3taFYETTvMmgDnGI1jfOD/7IFDh9fNf7lC3nEXOdAo74DNniOEH0Hw9a9rKleHvwQIt0/PeMsZTQuM0WRWbWbZu3sbENB9ddNdz40LX7vEo9wuzHQ1nP9hNnbuIYljzerDxEHYZ4oRbQAP1yZQAfQlqZbODNDG05ORuAbhg7/kot/4tyJqJwT82IytG2BrjwACPAJncVtBlou9C+l4svsmtfz+yNeEqOITjJnp2/xBBb+I8tFZFh1ttHW2BKADX2QuXbZYZp/xE53ra9Z+aQClmGm8BwpoekodQPvOwGGD6jnvWgiYZW2Mt8AaRXSEw0bWMtvsU48NCkobf52TSHSsrFk/KedXO2eYakordjyE/pkIDY7CQpDR1o6EOpJokGC7wFteVhzBe+NjSm2oqbt6EOkErWN6Mngb+NqofG9+zeQNSc65FgImobTvqFpEZZ8tW64ZgrMAbSBshC2dZSP3Uw69c/i5kwU94Nz622HhB9RFvQw0QXNMkO2dbeowQEvWOAcaq00CAKeQ6bGxeNGGeWuuK6UEQcfiBZPBtknwkBhp1usI4c7ai7+C90n+1k+oNG6HvLeGOGHpjDRdwD+t6vv2yZv+3cqT+hMjfXT/F59csP7Alz48lpK/MLDGadHqL8grUgOKy1C1GTlybPRoe5/8wkn3Tl0lh3QmoGt2yXwcYBJvrx37a3wHuppAxCDQSKlRIBhzjv8JcOHjnNmj497Mp2Zs20g9vWz6zufHLkomzRybXWuLOlzQ82JFanA/xsOCzkyBBGcHXJlUc/1a+2zL4sDx4QJTfixeBXNHpKoIJigvIuSYMSeJz22h4Uo6dsXhqU7zu9uXjXv+jhWfGcnZXjTz5Mxt/wIwT1kZG2QbaGu3I9muPmhGedsHtPhAXvFFhPSFSMSGB164NvjlutUUvWbNMBnuqL34Gj+lXsJmzI8EoNh42lFmbF3ZZfRap8D1K/ys0IX9Xn76xo09fO6IuqRU1dJx38cfrNzZtZrIRV9Y3qV9babtcovIw0F4vFMlj02qqazHZ5bMRs+7bdVLx9/j+6nHhMFpDrFTc0Tc0btqg4PgQvK9HSj5t5TxGvC1IoHf9PNcPBCbTjnUpPLi+VOfnPk/4ZeBWUvGP4FD4WxJH81Qv2u4z4sXqNI+56bXdFcepXYntbry4WlrcN5ON7L12KqeHVfja/MQDWZgCgy4NR5ORvhC/pDX1okYDGkIiAROv+kVxz7/w+mbwy8Dtz47djE24jkynUUZgqQG9/0EMoqHUxYHEeC3U6nYld+uXB2+Hp4QMJ27dem4B1BK34JO8AeeitfuAhrL/jht3fBKdJwseyuvvW5AKz0n5BY7zp5WeV6eKu33CRXTAWhGhzxsNlJvx4qxkU1Z82eSsm5anIi2JbdsfVib2A1Q0841JJsWbqjX/oAG5TKG8xl08nSlZdxTh5XH4/DiZMJfN2cZfzFv25JZ3Mj0YuEhn8im+45UpzrU9GccgpIyJy9A4JHjMGzjLD2io9nHJmxbToDJumTWlp/ETP4liNG2EDSNu5/QmQCgo7MX0BF6wBt8I8NhAw5ix7e9+XRLyqy7OQJ62aw3vsZfvFtbsiEAULrvSCXVwcYGlcQuC3Jojzy8j7acAVPo2apN288fMPKzAP0f2GzwB95Woe1ZvpF7zFmnbM9fZKfv7ZGVcuJUoIelTVAAP8ZPmvW3Lb/8Y6IUl9qqLfgzKvU98ls+B4wySnX6Hepg0/sAzUxbHsdnH59CzK2kLau98lWrtuqNh3RevBxrZAVKJimZgRX5zbzLlLAHFYA5dxx0ztjSzHSavzEIq8eoi9ra29ZFQT9fvfVuyC+MgrZe2SpKsryb96tkKiX27AuPTYTD0KsMOyH2tV/dtO+5qjdmYIscgQX8KHZaHFQcQDrusodxsL7FAXnltPPcVBxwl117H8j76qLWtra6urr0nxSuqN56D+QWSnBYDYEdJ9+J8j7UbDNNGtMt56PA+ZMG7MAvr9783vLbtswtMN7H8XiYAgi1CMJ7rpy6AqKcA0Vn8Z9k1WbNjgFoL+SX4iF7zfBRJV9wn1idzRXVWwA69rjoog78pHWhvAPQncg49Uf35sx8y+Tpudy87NKhncdSEz1Pl+PUNAJaPwkQ/XEK6oNlUAR6G/LYAm/xP3l47yD7fwJtV4EXf3XJrNfkEXIiT258esKjOJx8Xc71YIY+xAohZwTQYjquhvQvU3Ed/+aCG9Y8SNoZA0zlZ6MB9HewSioI0h5grNUQtBfXA/sOXvTEjfWLz4Y/H9n4KAJnOQL/C8Ko4jCW8i6JAAAAAElFTkSuQmCC" ) ); QCOMPARE( size.width(), 60 ); @@ -372,7 +372,6 @@ void TestQgsImageCache::nextFrameDelay() QCOMPARE( cache.nextFrameDelay( animatedImage, 5 ), -1 ); QCOMPARE( cache.nextFrameDelay( animatedImage, 5 ), -1 ); - } void TestQgsImageCache::imageFrames() @@ -492,7 +491,7 @@ void TestQgsImageCache::cmykImage() QVERIFY( !image.isNull() ); QCOMPARE( image.size(), QSize( 130, 50 ) ); -#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) QCOMPARE( image.format(), QImage::Format_CMYK8888 ); #else QCOMPARE( image.format(), QImage::Format_ARGB32 ); @@ -520,8 +519,7 @@ void TestQgsImageCache::htmlDataUrl() QgsImageCache cache; bool inCache = false; - const QImage img = cache.pathAsImage( QStringLiteral( "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAENZJREFUaAXtWwt0VdWZ3vvcmyePAIHaWJEOIMFKBYq2omtGmNbRMoNTpcmqOMJYJfEBU7WixVmjmWlrKT4oWLVWIApTaEMLtda0q84A7cJaB0Gwi4VABZVKoAiSx01Ccu/Z833/Pvvcc8NNuOE1a81yY87e59//6/v/f++zz0lU6qP2/zsC+kzAM6bGe/oXq8YY7U80xowyRg1XWg1TRvXX2vRBX4T7NmN0An2TVuYdpfQe9Dv9eN4fZk/5ynata/wz4dtpA1y7ftyA1sbma43W04xSk5Qx/U/B4UYEY0PcUz+NFZe8WH3V5sZT0JUhesqAn3ih/BKtUnf5RlUAZD61a2gFaCSP6g3IlsY58GHemkX2SZJ7N3b3aSHdgbm6PGW+d8d1b28WgVO4nDTgp9aOmJD09CNAMFkQ0okAme+AADDgCnD2bAyCowkhyyUbb0BbF4/nz509dceWLGI5kXoN+Pv/Nbo01ZJciKj/k0L9wn/gtKDCcZBB8YA4s1g5ToZMTlcP8phiOFfE/fg9s69/63BOKCNMWVyJzHYZLvr5qCm+b5Yg2mVOUPCIFwSNFhnbOdAw4JiNPEKXu2AckcldXjeA95a7r9v1q0BVTp2XExeYFq4d9VDK91+Cs2WUodNcj4TAbLHnvRvLFGnYa92Y3EFYToO8KfN9vx5+1VBvrs0lqlv+Z16fkJfY1/Sc8c10AedcRlbotV2PFI+sTUkjYQb5FF57H/KfTnntrep7fr+Z1Zds7uwWSDDRY4brTEWs+d3GHyFL05kZlykZC1hqIT06h8wj1Y5ms24ze7LyrBIfNqwu9BwLDXoN6eaGpnebVtHfEwGO98Tw3tptS6GwAvolm8KbbdyVpj1b2qSLsGpDvxnEXcrTBxANHjgKtFGD4PdIHEbGA8A5op/8wZoO70kLdn7R58YAK47ZSE57d822WhBmWLnsV3Ep29QjPyu/yxh/oXXYasxtbLVp5SWMNqvwzF01rDy+sfKi7R3Z7DjaI2suHOMbv1Ib/59RHUOFTmAsfbZsYwfc8YBNGzP3vordj4pMlktWwI+tHn15Uvu/hRVUAFhCY3CA2MWADKzKYD7YsNoB8rG8vvHH77lm+5EsNnskcc9ofLd5JjL+LTCeQ/M2u87ViN1QE2j0CX7gOZmKeeZv7522+3fhdGTgtISkxfVfLGht3bMV0qMFnEUo8zQVNrFhN6qQpvUrhTp/xt3T/rgnpJ3kYP7LE0pMY8sTWKA3CeiuerLZB4/ER6k/fXzwuZ++efKG9q5ix21aicTeedh0RsumAKU+1gnjFm4+oDGhPHPwRCVjMaMXX1ZaNul0gKWT38D5ed6Xd87AdjAbMOTwJra6se/8CPwc2fDB/n/rCpb3GRl+uG78EKXa9gJGHzcJ/Wi82ti5o2Fa1GAfij04r2LHN4X1DFy+XTd6Oja2/8SSQZhdVTnXpYzhofU07ZdqL455w++etqMh6lJGhn3Tei/Bci0yYi6DVCI09BJquWemaSS26EyCpbP/WvnWShiDb5n2mU1WYCrobTWSJj+FLSl1fxQsxyHgZ16cUIyFfzuZBaB0jKZVQGOCT4zanIN/4wVqzNfJeqbbA5W7Hof9n6OeVCp4Btts2kzTN+er8x8eVy2u/1zGa2oI+GBr2/UQ6kfmYB2EvcSAgIHKBkSUt8di+TMrK1enzjRYp78wr6AatYd3Yxt8V4HirzARfHpvQWCKjjY1VTp59iFgQJlBBWHJChcUYNUwetHMy6rxvEfmnYbdOOrMicZzr3/zL3D54TAB4hfvmAwLlKc8d099qPiZ7F0TwI/XTSwC4W8oJBHClWICNFQA0MEYFdUSL4rjUHL2W0HhoKfh51H6JskQsNYPHjNJo5uctxjMxPl1E0qcpwK4yRy9AukvIFEwkVMiRiGnwEURSo1aOe8f/vghuc52u/8fX2mGzZUIelB1the/IzT6H1RmrF21X+n8FMDY6q+ggHvmpne9NGBb7jZqKU+tdAr+T3qtfkJALikOXFihwMKc2SAAuO9f4fyUl4dkCqcqySTZ+KSz0XE03rsGpYnzhhf/3t2fqD9y//CS1KCSC7rjy4tp85vXtmytXK1y3vzKRhS/+v7utlacvYu7+kqf+SMlj54HKE/rC519yTAe5+WEapnS0REahTHHaFkef1Mu753OgG8aP5/nd27KKyjO+qPiRa9ffflla9dPUj2+uTl97Gkf1biFa9ZWoytrCzS9DK2Ur1W5kxfAQFIm5ZCxIxNgoIBIgznEa6cTzrX3m3DYaTvaLbvRsanjr73shd6A9pXZJT5Dq/gJXyWzuLrNlXQpa6POdcYFMIj9eGqyWQzWBhW5rApwO4/Ivu+Ee9P7TQeUau1hn/NiUwD6xderVF5Oen3dwDykK88+UiUIkhx72BQepXh6lHXpcYBhsb1nRu2xMroOBHiQZejiLnlSzW8+CNA9vDF6sWsuGD3xl9trLpLv2z0ZMZ5qCc8Mkpj02rWJstUpOPCJ5N9Xj5H3A6xnvDLjdyI2WowKygCWwuxiAuUTlnfKNyf8jNKTo34zzg6J7r+uGs/7u/P6939p95yR8pjsThf8QyUAVOhr8Ph09xIEW+4E16ckRlZ70sKohQCtAsm8BY7US8lIz0DQgM44m1Kqt81vOQTQH3QrBtBfGPJXQ+r31nyysDsmLK0SJoeVSddZmWxCYy9lzXlLH9ZYLu/GsjNCuAk8JSLJC3mIm8wQlCFuBb2nh3F4qs1vAeC++Qfil0/Y142ufoMLy5fsuyUxa+jQ1fgmltlQc2Xin/hqkyQc9Jk0tsB/bFSH3ZlfAGN+LyaHCkoADFswliAJmRf9qXA+hwFWCz6d2odBV3ZdmDhohrZfqr2BXafkHn5dWmIKzt+3r+LqLKDH2n3HioqPMgz8F9AYo0fWw43WeuKbna4UeNomrwSKzCKQ0Y+/74Ur8FaVWxvy3Q9/ibJa1h238ZtwEuphI9PeXw8oGPSb/funFkd1+Cndn8tNjpi42PImB8u4i/9av+VkBTCeg9sdMO58IXgnHPZS1fFUY+NVTkEOvSmdf+RWaF3aHa/xmwU0MoY6j2Erz/zB/nRBgTqvru73FUVOR8zzrsJywwOeCbJrlb3sOQFNzg4Yg2ebk5OS9jzvt0mcwYJiQIQQIjR75QCqZBMIqNq7CaM1vMuxmdLvHJl1eN4g2NC3ZJMh6B+8diCl9MBzaJf26EHgCkX+HnDW1dRNuqqmckPLgpve3Hnfiosndxp/PXjKCC7tP9lt4qgASXyFFDbJ8ILpb2xDJR+2H+5chp04o2cjR4Eg+1Pn/njCCN73ogloBHNJdzKJjkb/aCseW2gMumG9hjCYydhl+fkl/71041dlSRG0r73J+NDXwMBIiQdZop/SPN1SUjj6VXsTAOazGIpfJK8AwiBDAWTdPXs+izs6jj3olPSiZ3lXAcqzWWVw6G3taFYETTvMmgDnGI1jfOD/7IFDh9fNf7lC3nEXOdAo74DNniOEH0Hw9a9rKleHvwQIt0/PeMsZTQuM0WRWbWbZu3sbENB9ddNdz40LX7vEo9wuzHQ1nP9hNnbuIYljzerDxEHYZ4oRbQAP1yZQAfQlqZbODNDG05ORuAbhg7/kot/4tyJqJwT82IytG2BrjwACPAJncVtBlou9C+l4svsmtfz+yNeEqOITjJnp2/xBBb+I8tFZFh1ttHW2BKADX2QuXbZYZp/xE53ra9Z+aQClmGm8BwpoekodQPvOwGGD6jnvWgiYZW2Mt8AaRXSEw0bWMtvsU48NCkobf52TSHSsrFk/KedXO2eYakordjyE/pkIDY7CQpDR1o6EOpJokGC7wFteVhzBe+NjSm2oqbt6EOkErWN6Mngb+NqofG9+zeQNSc65FgImobTvqFpEZZ8tW64ZgrMAbSBshC2dZSP3Uw69c/i5kwU94Nz622HhB9RFvQw0QXNMkO2dbeowQEvWOAcaq00CAKeQ6bGxeNGGeWuuK6UEQcfiBZPBtknwkBhp1usI4c7ai7+C90n+1k+oNG6HvLeGOGHpjDRdwD+t6vv2yZv+3cqT+hMjfXT/F59csP7Alz48lpK/MLDGadHqL8grUgOKy1C1GTlybPRoe5/8wkn3Tl0lh3QmoGt2yXwcYBJvrx37a3wHuppAxCDQSKlRIBhzjv8JcOHjnNmj497Mp2Zs20g9vWz6zufHLkomzRybXWuLOlzQ82JFanA/xsOCzkyBBGcHXJlUc/1a+2zL4sDx4QJTfixeBXNHpKoIJigvIuSYMSeJz22h4Uo6dsXhqU7zu9uXjXv+jhWfGcnZXjTz5Mxt/wIwT1kZG2QbaGu3I9muPmhGedsHtPhAXvFFhPSFSMSGB164NvjlutUUvWbNMBnuqL34Gj+lXsJmzI8EoNh42lFmbF3ZZfRap8D1K/ys0IX9Xn76xo09fO6IuqRU1dJx38cfrNzZtZrIRV9Y3qV9babtcovIw0F4vFMlj02qqazHZ5bMRs+7bdVLx9/j+6nHhMFpDrFTc0Tc0btqg4PgQvK9HSj5t5TxGvC1IoHf9PNcPBCbTjnUpPLi+VOfnPk/4ZeBWUvGP4FD4WxJH81Qv2u4z4sXqNI+56bXdFcepXYntbry4WlrcN5ON7L12KqeHVfja/MQDWZgCgy4NR5ORvhC/pDX1okYDGkIiAROv+kVxz7/w+mbwy8Dtz47djE24jkynUUZgqQG9/0EMoqHUxYHEeC3U6nYld+uXB2+Hp4QMJ27dem4B1BK34JO8AeeitfuAhrL/jht3fBKdJwseyuvvW5AKz0n5BY7zp5WeV6eKu33CRXTAWhGhzxsNlJvx4qxkU1Z82eSsm5anIi2JbdsfVib2A1Q0841JJsWbqjX/oAG5TKG8xl08nSlZdxTh5XH4/DiZMJfN2cZfzFv25JZ3Mj0YuEhn8im+45UpzrU9GccgpIyJy9A4JHjMGzjLD2io9nHJmxbToDJumTWlp/ETP4liNG2EDSNu5/QmQCgo7MX0BF6wBt8I8NhAw5ix7e9+XRLyqy7OQJ62aw3vsZfvFtbsiEAULrvSCXVwcYGlcQuC3Jojzy8j7acAVPo2apN288fMPKzAP0f2GzwB95Woe1ZvpF7zFmnbM9fZKfv7ZGVcuJUoIelTVAAP8ZPmvW3Lb/8Y6IUl9qqLfgzKvU98ls+B4wySnX6Hepg0/sAzUxbHsdnH59CzK2kLau98lWrtuqNh3RevBxrZAVKJimZgRX5zbzLlLAHFYA5dxx0ztjSzHSavzEIq8eoi9ra29ZFQT9fvfVuyC+MgrZe2SpKsryb96tkKiX27AuPTYTD0KsMOyH2tV/dtO+5qjdmYIscgQX8KHZaHFQcQDrusodxsL7FAXnltPPcVBxwl117H8j76qLWtra6urr0nxSuqN56D+QWSnBYDYEdJ9+J8j7UbDNNGtMt56PA+ZMG7MAvr9783vLbtswtMN7H8XiYAgi1CMJ7rpy6AqKcA0Vn8Z9k1WbNjgFoL+SX4iF7zfBRJV9wn1idzRXVWwA69rjoog78pHWhvAPQncg49Uf35sx8y+Tpudy87NKhncdSEz1Pl+PUNAJaPwkQ/XEK6oNlUAR6G/LYAm/xP3l47yD7fwJtV4EXf3XJrNfkEXIiT258esKjOJx8Xc71YIY+xAohZwTQYjquhvQvU3Ed/+aCG9Y8SNoZA0zlZ6MB9HewSioI0h5grNUQtBfXA/sOXvTEjfWLz4Y/H9n4KAJnOQL/C8Ko4jCW8i6JAAAAAElFTkSuQmCC" ), - QSize( 200, 200 ), true, 1.0, inCache ); + const QImage img = cache.pathAsImage( QStringLiteral( "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAENZJREFUaAXtWwt0VdWZ3vvcmyePAIHaWJEOIMFKBYq2omtGmNbRMoNTpcmqOMJYJfEBU7WixVmjmWlrKT4oWLVWIApTaEMLtda0q84A7cJaB0Gwi4VABZVKoAiSx01Ccu/Z833/Pvvcc8NNuOE1a81yY87e59//6/v/f++zz0lU6qP2/zsC+kzAM6bGe/oXq8YY7U80xowyRg1XWg1TRvXX2vRBX4T7NmN0An2TVuYdpfQe9Dv9eN4fZk/5ynata/wz4dtpA1y7ftyA1sbma43W04xSk5Qx/U/B4UYEY0PcUz+NFZe8WH3V5sZT0JUhesqAn3ih/BKtUnf5RlUAZD61a2gFaCSP6g3IlsY58GHemkX2SZJ7N3b3aSHdgbm6PGW+d8d1b28WgVO4nDTgp9aOmJD09CNAMFkQ0okAme+AADDgCnD2bAyCowkhyyUbb0BbF4/nz509dceWLGI5kXoN+Pv/Nbo01ZJciKj/k0L9wn/gtKDCcZBB8YA4s1g5ToZMTlcP8phiOFfE/fg9s69/63BOKCNMWVyJzHYZLvr5qCm+b5Yg2mVOUPCIFwSNFhnbOdAw4JiNPEKXu2AckcldXjeA95a7r9v1q0BVTp2XExeYFq4d9VDK91+Cs2WUodNcj4TAbLHnvRvLFGnYa92Y3EFYToO8KfN9vx5+1VBvrs0lqlv+Z16fkJfY1/Sc8c10AedcRlbotV2PFI+sTUkjYQb5FF57H/KfTnntrep7fr+Z1Zds7uwWSDDRY4brTEWs+d3GHyFL05kZlykZC1hqIT06h8wj1Y5ms24ze7LyrBIfNqwu9BwLDXoN6eaGpnebVtHfEwGO98Tw3tptS6GwAvolm8KbbdyVpj1b2qSLsGpDvxnEXcrTBxANHjgKtFGD4PdIHEbGA8A5op/8wZoO70kLdn7R58YAK47ZSE57d822WhBmWLnsV3Ep29QjPyu/yxh/oXXYasxtbLVp5SWMNqvwzF01rDy+sfKi7R3Z7DjaI2suHOMbv1Ib/59RHUOFTmAsfbZsYwfc8YBNGzP3vordj4pMlktWwI+tHn15Uvu/hRVUAFhCY3CA2MWADKzKYD7YsNoB8rG8vvHH77lm+5EsNnskcc9ofLd5JjL+LTCeQ/M2u87ViN1QE2j0CX7gOZmKeeZv7522+3fhdGTgtISkxfVfLGht3bMV0qMFnEUo8zQVNrFhN6qQpvUrhTp/xt3T/rgnpJ3kYP7LE0pMY8sTWKA3CeiuerLZB4/ER6k/fXzwuZ++efKG9q5ix21aicTeedh0RsumAKU+1gnjFm4+oDGhPHPwRCVjMaMXX1ZaNul0gKWT38D5ed6Xd87AdjAbMOTwJra6se/8CPwc2fDB/n/rCpb3GRl+uG78EKXa9gJGHzcJ/Wi82ti5o2Fa1GAfij04r2LHN4X1DFy+XTd6Oja2/8SSQZhdVTnXpYzhofU07ZdqL455w++etqMh6lJGhn3Tei/Bci0yYi6DVCI09BJquWemaSS26EyCpbP/WvnWShiDb5n2mU1WYCrobTWSJj+FLSl1fxQsxyHgZ16cUIyFfzuZBaB0jKZVQGOCT4zanIN/4wVqzNfJeqbbA5W7Hof9n6OeVCp4Btts2kzTN+er8x8eVy2u/1zGa2oI+GBr2/UQ6kfmYB2EvcSAgIHKBkSUt8di+TMrK1enzjRYp78wr6AatYd3Yxt8V4HirzARfHpvQWCKjjY1VTp59iFgQJlBBWHJChcUYNUwetHMy6rxvEfmnYbdOOrMicZzr3/zL3D54TAB4hfvmAwLlKc8d099qPiZ7F0TwI/XTSwC4W8oJBHClWICNFQA0MEYFdUSL4rjUHL2W0HhoKfh51H6JskQsNYPHjNJo5uctxjMxPl1E0qcpwK4yRy9AukvIFEwkVMiRiGnwEURSo1aOe8f/vghuc52u/8fX2mGzZUIelB1the/IzT6H1RmrF21X+n8FMDY6q+ggHvmpne9NGBb7jZqKU+tdAr+T3qtfkJALikOXFihwMKc2SAAuO9f4fyUl4dkCqcqySTZ+KSz0XE03rsGpYnzhhf/3t2fqD9y//CS1KCSC7rjy4tp85vXtmytXK1y3vzKRhS/+v7utlacvYu7+kqf+SMlj54HKE/rC519yTAe5+WEapnS0REahTHHaFkef1Mu753OgG8aP5/nd27KKyjO+qPiRa9ffflla9dPUj2+uTl97Gkf1biFa9ZWoytrCzS9DK2Ur1W5kxfAQFIm5ZCxIxNgoIBIgznEa6cTzrX3m3DYaTvaLbvRsanjr73shd6A9pXZJT5Dq/gJXyWzuLrNlXQpa6POdcYFMIj9eGqyWQzWBhW5rApwO4/Ivu+Ee9P7TQeUau1hn/NiUwD6xderVF5Oen3dwDykK88+UiUIkhx72BQepXh6lHXpcYBhsb1nRu2xMroOBHiQZejiLnlSzW8+CNA9vDF6sWsuGD3xl9trLpLv2z0ZMZ5qCc8Mkpj02rWJstUpOPCJ5N9Xj5H3A6xnvDLjdyI2WowKygCWwuxiAuUTlnfKNyf8jNKTo34zzg6J7r+uGs/7u/P6939p95yR8pjsThf8QyUAVOhr8Ph09xIEW+4E16ckRlZ70sKohQCtAsm8BY7US8lIz0DQgM44m1Kqt81vOQTQH3QrBtBfGPJXQ+r31nyysDsmLK0SJoeVSddZmWxCYy9lzXlLH9ZYLu/GsjNCuAk8JSLJC3mIm8wQlCFuBb2nh3F4qs1vAeC++Qfil0/Y142ufoMLy5fsuyUxa+jQ1fgmltlQc2Xin/hqkyQc9Jk0tsB/bFSH3ZlfAGN+LyaHCkoADFswliAJmRf9qXA+hwFWCz6d2odBV3ZdmDhohrZfqr2BXafkHn5dWmIKzt+3r+LqLKDH2n3HioqPMgz8F9AYo0fWw43WeuKbna4UeNomrwSKzCKQ0Y+/74Ur8FaVWxvy3Q9/ibJa1h238ZtwEuphI9PeXw8oGPSb/funFkd1+Cndn8tNjpi42PImB8u4i/9av+VkBTCeg9sdMO58IXgnHPZS1fFUY+NVTkEOvSmdf+RWaF3aHa/xmwU0MoY6j2Erz/zB/nRBgTqvru73FUVOR8zzrsJywwOeCbJrlb3sOQFNzg4Yg2ebk5OS9jzvt0mcwYJiQIQQIjR75QCqZBMIqNq7CaM1vMuxmdLvHJl1eN4g2NC3ZJMh6B+8diCl9MBzaJf26EHgCkX+HnDW1dRNuqqmckPLgpve3Hnfiosndxp/PXjKCC7tP9lt4qgASXyFFDbJ8ILpb2xDJR+2H+5chp04o2cjR4Eg+1Pn/njCCN73ogloBHNJdzKJjkb/aCseW2gMumG9hjCYydhl+fkl/71041dlSRG0r73J+NDXwMBIiQdZop/SPN1SUjj6VXsTAOazGIpfJK8AwiBDAWTdPXs+izs6jj3olPSiZ3lXAcqzWWVw6G3taFYETTvMmgDnGI1jfOD/7IFDh9fNf7lC3nEXOdAo74DNniOEH0Hw9a9rKleHvwQIt0/PeMsZTQuM0WRWbWbZu3sbENB9ddNdz40LX7vEo9wuzHQ1nP9hNnbuIYljzerDxEHYZ4oRbQAP1yZQAfQlqZbODNDG05ORuAbhg7/kot/4tyJqJwT82IytG2BrjwACPAJncVtBlou9C+l4svsmtfz+yNeEqOITjJnp2/xBBb+I8tFZFh1ttHW2BKADX2QuXbZYZp/xE53ra9Z+aQClmGm8BwpoekodQPvOwGGD6jnvWgiYZW2Mt8AaRXSEw0bWMtvsU48NCkobf52TSHSsrFk/KedXO2eYakordjyE/pkIDY7CQpDR1o6EOpJokGC7wFteVhzBe+NjSm2oqbt6EOkErWN6Mngb+NqofG9+zeQNSc65FgImobTvqFpEZZ8tW64ZgrMAbSBshC2dZSP3Uw69c/i5kwU94Nz622HhB9RFvQw0QXNMkO2dbeowQEvWOAcaq00CAKeQ6bGxeNGGeWuuK6UEQcfiBZPBtknwkBhp1usI4c7ai7+C90n+1k+oNG6HvLeGOGHpjDRdwD+t6vv2yZv+3cqT+hMjfXT/F59csP7Alz48lpK/MLDGadHqL8grUgOKy1C1GTlybPRoe5/8wkn3Tl0lh3QmoGt2yXwcYBJvrx37a3wHuppAxCDQSKlRIBhzjv8JcOHjnNmj497Mp2Zs20g9vWz6zufHLkomzRybXWuLOlzQ82JFanA/xsOCzkyBBGcHXJlUc/1a+2zL4sDx4QJTfixeBXNHpKoIJigvIuSYMSeJz22h4Uo6dsXhqU7zu9uXjXv+jhWfGcnZXjTz5Mxt/wIwT1kZG2QbaGu3I9muPmhGedsHtPhAXvFFhPSFSMSGB164NvjlutUUvWbNMBnuqL34Gj+lXsJmzI8EoNh42lFmbF3ZZfRap8D1K/ys0IX9Xn76xo09fO6IuqRU1dJx38cfrNzZtZrIRV9Y3qV9babtcovIw0F4vFMlj02qqazHZ5bMRs+7bdVLx9/j+6nHhMFpDrFTc0Tc0btqg4PgQvK9HSj5t5TxGvC1IoHf9PNcPBCbTjnUpPLi+VOfnPk/4ZeBWUvGP4FD4WxJH81Qv2u4z4sXqNI+56bXdFcepXYntbry4WlrcN5ON7L12KqeHVfja/MQDWZgCgy4NR5ORvhC/pDX1okYDGkIiAROv+kVxz7/w+mbwy8Dtz47djE24jkynUUZgqQG9/0EMoqHUxYHEeC3U6nYld+uXB2+Hp4QMJ27dem4B1BK34JO8AeeitfuAhrL/jht3fBKdJwseyuvvW5AKz0n5BY7zp5WeV6eKu33CRXTAWhGhzxsNlJvx4qxkU1Z82eSsm5anIi2JbdsfVib2A1Q0841JJsWbqjX/oAG5TKG8xl08nSlZdxTh5XH4/DiZMJfN2cZfzFv25JZ3Mj0YuEhn8im+45UpzrU9GccgpIyJy9A4JHjMGzjLD2io9nHJmxbToDJumTWlp/ETP4liNG2EDSNu5/QmQCgo7MX0BF6wBt8I8NhAw5ix7e9+XRLyqy7OQJ62aw3vsZfvFtbsiEAULrvSCXVwcYGlcQuC3Jojzy8j7acAVPo2apN288fMPKzAP0f2GzwB95Woe1ZvpF7zFmnbM9fZKfv7ZGVcuJUoIelTVAAP8ZPmvW3Lb/8Y6IUl9qqLfgzKvU98ls+B4wySnX6Hepg0/sAzUxbHsdnH59CzK2kLau98lWrtuqNh3RevBxrZAVKJimZgRX5zbzLlLAHFYA5dxx0ztjSzHSavzEIq8eoi9ra29ZFQT9fvfVuyC+MgrZe2SpKsryb96tkKiX27AuPTYTD0KsMOyH2tV/dtO+5qjdmYIscgQX8KHZaHFQcQDrusodxsL7FAXnltPPcVBxwl117H8j76qLWtra6urr0nxSuqN56D+QWSnBYDYEdJ9+J8j7UbDNNGtMt56PA+ZMG7MAvr9783vLbtswtMN7H8XiYAgi1CMJ7rpy6AqKcA0Vn8Z9k1WbNjgFoL+SX4iF7zfBRJV9wn1idzRXVWwA69rjoog78pHWhvAPQncg49Uf35sx8y+Tpudy87NKhncdSEz1Pl+PUNAJaPwkQ/XEK6oNlUAR6G/LYAm/xP3l47yD7fwJtV4EXf3XJrNfkEXIiT258esKjOJx8Xc71YIY+xAohZwTQYjquhvQvU3Ed/+aCG9Y8SNoZA0zlZ6MB9HewSioI0h5grNUQtBfXA/sOXvTEjfWLz4Y/H9n4KAJnOQL/C8Ko4jCW8i6JAAAAAElFTkSuQmCC" ), QSize( 200, 200 ), true, 1.0, inCache ); QVERIFY( imageCheck( QStringLiteral( "imagecache_base64" ), img, 30 ) ); const QSize size = cache.originalSize( QStringLiteral( "base64:iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAENZJREFUaAXtWwt0VdWZ3vvcmyePAIHaWJEOIMFKBYq2omtGmNbRMoNTpcmqOMJYJfEBU7WixVmjmWlrKT4oWLVWIApTaEMLtda0q84A7cJaB0Gwi4VABZVKoAiSx01Ccu/Z833/Pvvcc8NNuOE1a81yY87e59//6/v/f++zz0lU6qP2/zsC+kzAM6bGe/oXq8YY7U80xowyRg1XWg1TRvXX2vRBX4T7NmN0An2TVuYdpfQe9Dv9eN4fZk/5ynata/wz4dtpA1y7ftyA1sbma43W04xSk5Qx/U/B4UYEY0PcUz+NFZe8WH3V5sZT0JUhesqAn3ih/BKtUnf5RlUAZD61a2gFaCSP6g3IlsY58GHemkX2SZJ7N3b3aSHdgbm6PGW+d8d1b28WgVO4nDTgp9aOmJD09CNAMFkQ0okAme+AADDgCnD2bAyCowkhyyUbb0BbF4/nz509dceWLGI5kXoN+Pv/Nbo01ZJciKj/k0L9wn/gtKDCcZBB8YA4s1g5ToZMTlcP8phiOFfE/fg9s69/63BOKCNMWVyJzHYZLvr5qCm+b5Yg2mVOUPCIFwSNFhnbOdAw4JiNPEKXu2AckcldXjeA95a7r9v1q0BVTp2XExeYFq4d9VDK91+Cs2WUodNcj4TAbLHnvRvLFGnYa92Y3EFYToO8KfN9vx5+1VBvrs0lqlv+Z16fkJfY1/Sc8c10AedcRlbotV2PFI+sTUkjYQb5FF57H/KfTnntrep7fr+Z1Zds7uwWSDDRY4brTEWs+d3GHyFL05kZlykZC1hqIT06h8wj1Y5ms24ze7LyrBIfNqwu9BwLDXoN6eaGpnebVtHfEwGO98Tw3tptS6GwAvolm8KbbdyVpj1b2qSLsGpDvxnEXcrTBxANHjgKtFGD4PdIHEbGA8A5op/8wZoO70kLdn7R58YAK47ZSE57d822WhBmWLnsV3Ep29QjPyu/yxh/oXXYasxtbLVp5SWMNqvwzF01rDy+sfKi7R3Z7DjaI2suHOMbv1Ib/59RHUOFTmAsfbZsYwfc8YBNGzP3vordj4pMlktWwI+tHn15Uvu/hRVUAFhCY3CA2MWADKzKYD7YsNoB8rG8vvHH77lm+5EsNnskcc9ofLd5JjL+LTCeQ/M2u87ViN1QE2j0CX7gOZmKeeZv7522+3fhdGTgtISkxfVfLGht3bMV0qMFnEUo8zQVNrFhN6qQpvUrhTp/xt3T/rgnpJ3kYP7LE0pMY8sTWKA3CeiuerLZB4/ER6k/fXzwuZ++efKG9q5ix21aicTeedh0RsumAKU+1gnjFm4+oDGhPHPwRCVjMaMXX1ZaNul0gKWT38D5ed6Xd87AdjAbMOTwJra6se/8CPwc2fDB/n/rCpb3GRl+uG78EKXa9gJGHzcJ/Wi82ti5o2Fa1GAfij04r2LHN4X1DFy+XTd6Oja2/8SSQZhdVTnXpYzhofU07ZdqL455w++etqMh6lJGhn3Tei/Bci0yYi6DVCI09BJquWemaSS26EyCpbP/WvnWShiDb5n2mU1WYCrobTWSJj+FLSl1fxQsxyHgZ16cUIyFfzuZBaB0jKZVQGOCT4zanIN/4wVqzNfJeqbbA5W7Hof9n6OeVCp4Btts2kzTN+er8x8eVy2u/1zGa2oI+GBr2/UQ6kfmYB2EvcSAgIHKBkSUt8di+TMrK1enzjRYp78wr6AatYd3Yxt8V4HirzARfHpvQWCKjjY1VTp59iFgQJlBBWHJChcUYNUwetHMy6rxvEfmnYbdOOrMicZzr3/zL3D54TAB4hfvmAwLlKc8d099qPiZ7F0TwI/XTSwC4W8oJBHClWICNFQA0MEYFdUSL4rjUHL2W0HhoKfh51H6JskQsNYPHjNJo5uctxjMxPl1E0qcpwK4yRy9AukvIFEwkVMiRiGnwEURSo1aOe8f/vghuc52u/8fX2mGzZUIelB1the/IzT6H1RmrF21X+n8FMDY6q+ggHvmpne9NGBb7jZqKU+tdAr+T3qtfkJALikOXFihwMKc2SAAuO9f4fyUl4dkCqcqySTZ+KSz0XE03rsGpYnzhhf/3t2fqD9y//CS1KCSC7rjy4tp85vXtmytXK1y3vzKRhS/+v7utlacvYu7+kqf+SMlj54HKE/rC519yTAe5+WEapnS0REahTHHaFkef1Mu753OgG8aP5/nd27KKyjO+qPiRa9ffflla9dPUj2+uTl97Gkf1biFa9ZWoytrCzS9DK2Ur1W5kxfAQFIm5ZCxIxNgoIBIgznEa6cTzrX3m3DYaTvaLbvRsanjr73shd6A9pXZJT5Dq/gJXyWzuLrNlXQpa6POdcYFMIj9eGqyWQzWBhW5rApwO4/Ivu+Ee9P7TQeUau1hn/NiUwD6xderVF5Oen3dwDykK88+UiUIkhx72BQepXh6lHXpcYBhsb1nRu2xMroOBHiQZejiLnlSzW8+CNA9vDF6sWsuGD3xl9trLpLv2z0ZMZ5qCc8Mkpj02rWJstUpOPCJ5N9Xj5H3A6xnvDLjdyI2WowKygCWwuxiAuUTlnfKNyf8jNKTo34zzg6J7r+uGs/7u/P6939p95yR8pjsThf8QyUAVOhr8Ph09xIEW+4E16ckRlZ70sKohQCtAsm8BY7US8lIz0DQgM44m1Kqt81vOQTQH3QrBtBfGPJXQ+r31nyysDsmLK0SJoeVSddZmWxCYy9lzXlLH9ZYLu/GsjNCuAk8JSLJC3mIm8wQlCFuBb2nh3F4qs1vAeC++Qfil0/Y142ufoMLy5fsuyUxa+jQ1fgmltlQc2Xin/hqkyQc9Jk0tsB/bFSH3ZlfAGN+LyaHCkoADFswliAJmRf9qXA+hwFWCz6d2odBV3ZdmDhohrZfqr2BXafkHn5dWmIKzt+3r+LqLKDH2n3HioqPMgz8F9AYo0fWw43WeuKbna4UeNomrwSKzCKQ0Y+/74Ur8FaVWxvy3Q9/ibJa1h238ZtwEuphI9PeXw8oGPSb/funFkd1+Cndn8tNjpi42PImB8u4i/9av+VkBTCeg9sdMO58IXgnHPZS1fFUY+NVTkEOvSmdf+RWaF3aHa/xmwU0MoY6j2Erz/zB/nRBgTqvru73FUVOR8zzrsJywwOeCbJrlb3sOQFNzg4Yg2ebk5OS9jzvt0mcwYJiQIQQIjR75QCqZBMIqNq7CaM1vMuxmdLvHJl1eN4g2NC3ZJMh6B+8diCl9MBzaJf26EHgCkX+HnDW1dRNuqqmckPLgpve3Hnfiosndxp/PXjKCC7tP9lt4qgASXyFFDbJ8ILpb2xDJR+2H+5chp04o2cjR4Eg+1Pn/njCCN73ogloBHNJdzKJjkb/aCseW2gMumG9hjCYydhl+fkl/71041dlSRG0r73J+NDXwMBIiQdZop/SPN1SUjj6VXsTAOazGIpfJK8AwiBDAWTdPXs+izs6jj3olPSiZ3lXAcqzWWVw6G3taFYETTvMmgDnGI1jfOD/7IFDh9fNf7lC3nEXOdAo74DNniOEH0Hw9a9rKleHvwQIt0/PeMsZTQuM0WRWbWbZu3sbENB9ddNdz40LX7vEo9wuzHQ1nP9hNnbuIYljzerDxEHYZ4oRbQAP1yZQAfQlqZbODNDG05ORuAbhg7/kot/4tyJqJwT82IytG2BrjwACPAJncVtBlou9C+l4svsmtfz+yNeEqOITjJnp2/xBBb+I8tFZFh1ttHW2BKADX2QuXbZYZp/xE53ra9Z+aQClmGm8BwpoekodQPvOwGGD6jnvWgiYZW2Mt8AaRXSEw0bWMtvsU48NCkobf52TSHSsrFk/KedXO2eYakordjyE/pkIDY7CQpDR1o6EOpJokGC7wFteVhzBe+NjSm2oqbt6EOkErWN6Mngb+NqofG9+zeQNSc65FgImobTvqFpEZZ8tW64ZgrMAbSBshC2dZSP3Uw69c/i5kwU94Nz622HhB9RFvQw0QXNMkO2dbeowQEvWOAcaq00CAKeQ6bGxeNGGeWuuK6UEQcfiBZPBtknwkBhp1usI4c7ai7+C90n+1k+oNG6HvLeGOGHpjDRdwD+t6vv2yZv+3cqT+hMjfXT/F59csP7Alz48lpK/MLDGadHqL8grUgOKy1C1GTlybPRoe5/8wkn3Tl0lh3QmoGt2yXwcYBJvrx37a3wHuppAxCDQSKlRIBhzjv8JcOHjnNmj497Mp2Zs20g9vWz6zufHLkomzRybXWuLOlzQ82JFanA/xsOCzkyBBGcHXJlUc/1a+2zL4sDx4QJTfixeBXNHpKoIJigvIuSYMSeJz22h4Uo6dsXhqU7zu9uXjXv+jhWfGcnZXjTz5Mxt/wIwT1kZG2QbaGu3I9muPmhGedsHtPhAXvFFhPSFSMSGB164NvjlutUUvWbNMBnuqL34Gj+lXsJmzI8EoNh42lFmbF3ZZfRap8D1K/ys0IX9Xn76xo09fO6IuqRU1dJx38cfrNzZtZrIRV9Y3qV9babtcovIw0F4vFMlj02qqazHZ5bMRs+7bdVLx9/j+6nHhMFpDrFTc0Tc0btqg4PgQvK9HSj5t5TxGvC1IoHf9PNcPBCbTjnUpPLi+VOfnPk/4ZeBWUvGP4FD4WxJH81Qv2u4z4sXqNI+56bXdFcepXYntbry4WlrcN5ON7L12KqeHVfja/MQDWZgCgy4NR5ORvhC/pDX1okYDGkIiAROv+kVxz7/w+mbwy8Dtz47djE24jkynUUZgqQG9/0EMoqHUxYHEeC3U6nYld+uXB2+Hp4QMJ27dem4B1BK34JO8AeeitfuAhrL/jht3fBKdJwseyuvvW5AKz0n5BY7zp5WeV6eKu33CRXTAWhGhzxsNlJvx4qxkU1Z82eSsm5anIi2JbdsfVib2A1Q0841JJsWbqjX/oAG5TKG8xl08nSlZdxTh5XH4/DiZMJfN2cZfzFv25JZ3Mj0YuEhn8im+45UpzrU9GccgpIyJy9A4JHjMGzjLD2io9nHJmxbToDJumTWlp/ETP4liNG2EDSNu5/QmQCgo7MX0BF6wBt8I8NhAw5ix7e9+XRLyqy7OQJ62aw3vsZfvFtbsiEAULrvSCXVwcYGlcQuC3Jojzy8j7acAVPo2apN288fMPKzAP0f2GzwB95Woe1ZvpF7zFmnbM9fZKfv7ZGVcuJUoIelTVAAP8ZPmvW3Lb/8Y6IUl9qqLfgzKvU98ls+B4wySnX6Hepg0/sAzUxbHsdnH59CzK2kLau98lWrtuqNh3RevBxrZAVKJimZgRX5zbzLlLAHFYA5dxx0ztjSzHSavzEIq8eoi9ra29ZFQT9fvfVuyC+MgrZe2SpKsryb96tkKiX27AuPTYTD0KsMOyH2tV/dtO+5qjdmYIscgQX8KHZaHFQcQDrusodxsL7FAXnltPPcVBxwl117H8j76qLWtra6urr0nxSuqN56D+QWSnBYDYEdJ9+J8j7UbDNNGtMt56PA+ZMG7MAvr9783vLbtswtMN7H8XiYAgi1CMJ7rpy6AqKcA0Vn8Z9k1WbNjgFoL+SX4iF7zfBRJV9wn1idzRXVWwA69rjoog78pHWhvAPQncg49Uf35sx8y+Tpudy87NKhncdSEz1Pl+PUNAJaPwkQ/XEK6oNlUAR6G/LYAm/xP3l47yD7fwJtV4EXf3XJrNfkEXIiT258esKjOJx8Xc71YIY+xAohZwTQYjquhvQvU3Ed/+aCG9Y8SNoZA0zlZ6MB9HewSioI0h5grNUQtBfXA/sOXvTEjfWLz4Y/H9n4KAJnOQL/C8Ko4jCW8i6JAAAAAElFTkSuQmCC" ) ); QCOMPARE( size.width(), 60 ); diff --git a/tests/src/core/testqgsimageoperation.cpp b/tests/src/core/testqgsimageoperation.cpp index 6741dcf31395..2728c7cf6dbb 100644 --- a/tests/src/core/testqgsimageoperation.cpp +++ b/tests/src/core/testqgsimageoperation.cpp @@ -27,12 +27,13 @@ class TestQgsImageOperation : public QgsTest Q_OBJECT public: - TestQgsImageOperation() : QgsTest( QStringLiteral( "Image Operation Tests" ) ) {} + TestQgsImageOperation() + : QgsTest( QStringLiteral( "Image Operation Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void smallImageOp(); //test operation on small image (single threaded op) //grayscale @@ -83,7 +84,6 @@ class TestQgsImageOperation : public QgsTest void flipVertical(); private: - QString mSampleImage; QString mTransparentSampleImage; @@ -105,7 +105,6 @@ void TestQgsImageOperation::init() void TestQgsImageOperation::cleanup() { - } void TestQgsImageOperation::smallImageOp() diff --git a/tests/src/core/testqgsinternalgeometryengine.cpp b/tests/src/core/testqgsinternalgeometryengine.cpp index c1a5a4fd5980..728ea3e0c8a2 100644 --- a/tests/src/core/testqgsinternalgeometryengine.cpp +++ b/tests/src/core/testqgsinternalgeometryengine.cpp @@ -23,17 +23,15 @@ class TestQgsInternalGeometryEngine : public QObject Q_OBJECT public: - private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void ray(); void testLineSegmentDistanceComparer_data(); void testLineSegmentDistanceComparer(); void clockwiseAngleComparer(); - }; void TestQgsInternalGeometryEngine::initTestCase() @@ -159,16 +157,11 @@ void TestQgsInternalGeometryEngine::testLineSegmentDistanceComparer() const QgsLineSegmentDistanceComparer comp( QgsPointXY( 3, 5 ) ); - QVERIFY( !comp( QgsLineSegment2D( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ) ), - QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ) ) ); - QVERIFY( comp( QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ), - QgsLineSegment2D( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ) ) ) ); - QVERIFY( !comp( QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ), - QgsLineSegment2D( QgsPointXY( 8, 9 ), QgsPointXY( 13, 14 ) ) ) ); - QVERIFY( !comp( QgsLineSegment2D( QgsPointXY( 8, 9 ), QgsPointXY( 13, 14 ) ), - QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ) ) ); - QVERIFY( comp( QgsLineSegment2D( QgsPointXY( 1, 4 ), QgsPointXY( 8, 9 ) ), - QgsLineSegment2D( QgsPointXY( 8, 9 ), QgsPointXY( 15, 16 ) ) ) ); + QVERIFY( !comp( QgsLineSegment2D( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ) ), QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ) ) ); + QVERIFY( comp( QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ), QgsLineSegment2D( QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ) ) ) ); + QVERIFY( !comp( QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ), QgsLineSegment2D( QgsPointXY( 8, 9 ), QgsPointXY( 13, 14 ) ) ) ); + QVERIFY( !comp( QgsLineSegment2D( QgsPointXY( 8, 9 ), QgsPointXY( 13, 14 ) ), QgsLineSegment2D( QgsPointXY( 5, 6 ), QgsPointXY( 8, 9 ) ) ) ); + QVERIFY( comp( QgsLineSegment2D( QgsPointXY( 1, 4 ), QgsPointXY( 8, 9 ) ), QgsLineSegment2D( QgsPointXY( 8, 9 ), QgsPointXY( 15, 16 ) ) ) ); } void TestQgsInternalGeometryEngine::clockwiseAngleComparer() diff --git a/tests/src/core/testqgsinvertedpolygonrenderer.cpp b/tests/src/core/testqgsinvertedpolygonrenderer.cpp index 4ee3329d0c17..f20bb5aaa25b 100644 --- a/tests/src/core/testqgsinvertedpolygonrenderer.cpp +++ b/tests/src/core/testqgsinvertedpolygonrenderer.cpp @@ -43,11 +43,12 @@ class TestQgsInvertedPolygon : public QgsTest Q_OBJECT public: - TestQgsInvertedPolygon() : QgsTest( QStringLiteral( "Inverted Polygon Renderer Tests" ), QStringLiteral( "symbol_invertedpolygon" ) ) {} + TestQgsInvertedPolygon() + : QgsTest( QStringLiteral( "Inverted Polygon Renderer Tests" ), QStringLiteral( "symbol_invertedpolygon" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void singleSubRenderer(); void graduatedSubRenderer(); @@ -59,7 +60,7 @@ class TestQgsInvertedPolygon : public QgsTest void rotationTest(); private: - bool mTestHasError = false ; + bool mTestHasError = false; bool setQml( QgsVectorLayer *vlayer, const QString &qmlFile ); bool imageCheck( const QString &type, const QgsRectangle * = nullptr ); QgsMapSettings mMapSettings; @@ -84,8 +85,7 @@ void TestQgsInvertedPolygon::initTestCase() // const QString myPolysFileName = mTestDataDir + "polys_overlapping.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); mpPolysLayer->setSimplifyMethod( simplifyMethod ); @@ -141,15 +141,14 @@ void TestQgsInvertedPolygon::projectionTest() void TestQgsInvertedPolygon::projectionWithSimplificationTest() { - std::unique_ptr< QgsVectorLayer > polyLayer = std::make_unique< QgsVectorLayer >( testDataPath( "polys.shp" ), QStringLiteral( "polys" ) ); + std::unique_ptr polyLayer = std::make_unique( testDataPath( "polys.shp" ), QStringLiteral( "polys" ) ); QVERIFY( polyLayer->isValid() ); QgsMapSettings mapSettings; mapSettings.setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); mapSettings.setLayers( QList() << polyLayer.get() ); mapSettings.setOutputDpi( 96 ); - QgsFillSymbol *fill = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}, - { "outline_width", "1"}} ) ); + QgsFillSymbol *fill = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" }, { "outline_width", "1" } } ) ); QgsInvertedPolygonRenderer *renderer = new QgsInvertedPolygonRenderer(); QgsSingleSymbolRenderer *singleSymbolRenderer = new QgsSingleSymbolRenderer( fill ); renderer->setEmbeddedRenderer( singleSymbolRenderer ); @@ -171,14 +170,13 @@ void TestQgsInvertedPolygon::curvedPolygons() { const QString myCurvedPolysFileName = mTestDataDir + "curved_polys.gpkg"; const QFileInfo myCurvedPolyFileInfo( myCurvedPolysFileName ); - QgsVectorLayer *curvedLayer = new QgsVectorLayer( myCurvedPolyFileInfo.filePath() + "|layername=polys", - myCurvedPolyFileInfo.completeBaseName(), "ogr" ); + QgsVectorLayer *curvedLayer = new QgsVectorLayer( myCurvedPolyFileInfo.filePath() + "|layername=polys", myCurvedPolyFileInfo.completeBaseName(), "ogr" ); QgsProject::instance()->addMapLayers( QList() << curvedLayer ); - mMapSettings.setLayers( QList< QgsMapLayer * >() << curvedLayer ); + mMapSettings.setLayers( QList() << curvedLayer ); QVERIFY( setQml( curvedLayer, "inverted_polys_single.qml" ) ); QVERIFY( imageCheck( "inverted_polys_curved" ) ); - mMapSettings.setLayers( QList< QgsMapLayer * >() << mpPolysLayer ); + mMapSettings.setLayers( QList() << mpPolysLayer ); } void TestQgsInvertedPolygon::rotationTest() diff --git a/tests/src/core/testqgsjsonutils.cpp b/tests/src/core/testqgsjsonutils.cpp index c11617855f53..096a5f78c428 100644 --- a/tests/src/core/testqgsjsonutils.cpp +++ b/tests/src/core/testqgsjsonutils.cpp @@ -23,9 +23,7 @@ class TestQgsJsonUtils : public QObject { - public: - enum JsonAlgs { Json, @@ -52,7 +50,6 @@ class TestQgsJsonUtils : public QObject }; - void TestQgsJsonUtils::testStringList() { QStringList list; @@ -121,26 +118,26 @@ void TestQgsJsonUtils::testJsonToVariant() QCOMPARE( variant.toMap().value( QStringLiteral( "_bool" ) ), true ); QCOMPARE( variant.toMap().value( QStringLiteral( "_double" ) ), 1234.45 ); QCOMPARE( variant.toMap().value( QStringLiteral( "_int" ) ), 123 ); - QCOMPARE( variant.toMap().value( QStringLiteral( "_list" ) ), QVariantList( {1, 2, 3.4, QVariant()} ) ); + QCOMPARE( variant.toMap().value( QStringLiteral( "_list" ) ), QVariantList( { 1, 2, 3.4, QVariant() } ) ); QCOMPARE( variant.toMap().value( QStringLiteral( "_null" ) ), QVariant() ); - QCOMPARE( variant.toMap().value( QStringLiteral( "_object" ) ), QVariantMap( {{ QStringLiteral( "int" ), 123 }} ) ); + QCOMPARE( variant.toMap().value( QStringLiteral( "_object" ) ), QVariantMap( { { QStringLiteral( "int" ), 123 } } ) ); } void TestQgsJsonUtils::testParseJson() { - const QStringList tests {{ - "null", - "false", - "true", - "123", - "123.45", - "4294967295", - "-9223372036854775807", - "9223372036854775807", - R"j("a string")j", - "[1,2,3.4,null]", - R"j({"_bool":true,"_double":1234.45,"_int":123,"_list":[1,2,3.4,null],"_null":null,"_object":{"int":123}})j", - }}; + const QStringList tests { { + "null", + "false", + "true", + "123", + "123.45", + "4294967295", + "-9223372036854775807", + "9223372036854775807", + R"j("a string")j", + "[1,2,3.4,null]", + R"j({"_bool":true,"_double":1234.45,"_int":123,"_list":[1,2,3.4,null],"_null":null,"_object":{"int":123}})j", + } }; for ( const auto &testJson : tests ) { @@ -153,14 +150,8 @@ void TestQgsJsonUtils::testParseJson() // invalid json -> null QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( QgsJsonUtils::parseJson( QStringLiteral( "invalid json" ) ) ).dump() ), QString( "null" ) ); // String lists - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( QStringList() - << QStringLiteral( "A string" ) - << QStringLiteral( "Another string" ) ).dump() ), - QString( R"raw(["A string","Another string"])raw" ) ); - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( QStringList() - << QStringLiteral( "A string" ) ).dump() ), - QString( R"raw(["A string"])raw" ) ); - + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( QStringList() << QStringLiteral( "A string" ) << QStringLiteral( "Another string" ) ).dump() ), QString( R"raw(["A string","Another string"])raw" ) ); + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( QStringList() << QStringLiteral( "A string" ) ).dump() ), QString( R"raw(["A string"])raw" ) ); } void TestQgsJsonUtils::testIntList() @@ -204,14 +195,13 @@ void TestQgsJsonUtils::testExportAttributesJson_data() void TestQgsJsonUtils::testExportAttributesJson() { - QFETCH( enum JsonAlgs, jsonAlg ); QgsVectorLayer vl { QStringLiteral( "Point?field=fldtxt:string&field=fldint:integer&field=flddbl:double" ), QStringLiteral( "mem" ), QStringLiteral( "memory" ) }; QgsFeature feature { vl.fields() }; feature.setAttributes( QgsAttributes() << QStringLiteral( "a value" ) << 1 << 2.0 ); - if ( jsonAlg == JsonAlgs::Json ) // 0.0022 + if ( jsonAlg == JsonAlgs::Json ) // 0.0022 { QBENCHMARK { @@ -231,8 +221,6 @@ void TestQgsJsonUtils::testExportAttributesJson() void TestQgsJsonUtils::testExportFeatureJson() { - - QgsVectorLayer vl { QStringLiteral( "Polygon?field=fldtxt:string&field=fldint:integer&field=flddbl:double" ), QStringLiteral( "mem" ), QStringLiteral( "memory" ) }; QgsFeature feature { vl.fields() }; feature.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POLYGON((1.12 1.34,5.45 1.12,5.34 5.33,1.56 5.2,1.12 1.34),(2 2, 3 2, 3 3, 2 3,2 2))" ) ) ); @@ -241,13 +229,13 @@ void TestQgsJsonUtils::testExportFeatureJson() const QgsJsonExporter exporter { &vl }; const auto expectedJson { QStringLiteral( "{\"bbox\":[1.12,1.12,5.45,5.33],\"geometry\":{\"coordinates\":" - "[[[1.12,1.34],[5.45,1.12],[5.34,5.33],[1.56,5.2],[1.12,1.34]]," - "[[2.0,2.0],[3.0,2.0],[3.0,3.0],[2.0,3.0],[2.0,2.0]]],\"type\":\"Polygon\"}" - ",\"id\":null,\"properties\":{\"flddbl\":2.0,\"fldint\":1,\"fldtxt\":\"a value\"}" - ",\"type\":\"Feature\"}" ) }; + "[[[1.12,1.34],[5.45,1.12],[5.34,5.33],[1.56,5.2],[1.12,1.34]]," + "[[2.0,2.0],[3.0,2.0],[3.0,3.0],[2.0,3.0],[2.0,2.0]]],\"type\":\"Polygon\"}" + ",\"id\":null,\"properties\":{\"flddbl\":2.0,\"fldint\":1,\"fldtxt\":\"a value\"}" + ",\"type\":\"Feature\"}" ) }; const auto j( exporter.exportFeatureToJsonObject( feature ) ); - QCOMPARE( QString::fromStdString( j.dump() ), expectedJson ); + QCOMPARE( QString::fromStdString( j.dump() ), expectedJson ); const auto json = exporter.exportFeature( feature ); QCOMPARE( json, expectedJson ); @@ -255,17 +243,16 @@ void TestQgsJsonUtils::testExportFeatureJson() const auto expectedJsonPrecision { QStringLiteral( "{\"bbox\":[1.1,1.1,5.5,5.3],\"geometry\":{\"coordinates\":" - "[[[1.1,1.3],[5.5,1.1],[5.3,5.3],[1.6,5.2],[1.1,1.3]]," - "[[2.0,2.0],[3.0,2.0],[3.0,3.0],[2.0,3.0],[2.0,2.0]]],\"type\":\"Polygon\"}" - ",\"id\":123,\"properties\":{\"flddbl\":2.0,\"fldint\":1,\"fldtxt\":\"a value\"}" - ",\"type\":\"Feature\"}" ) }; + "[[[1.1,1.3],[5.5,1.1],[5.3,5.3],[1.6,5.2],[1.1,1.3]]," + "[[2.0,2.0],[3.0,2.0],[3.0,3.0],[2.0,3.0],[2.0,2.0]]],\"type\":\"Polygon\"}" + ",\"id\":123,\"properties\":{\"flddbl\":2.0,\"fldint\":1,\"fldtxt\":\"a value\"}" + ",\"type\":\"Feature\"}" ) }; feature.setId( 123 ); const auto jPrecision( exporterPrecision.exportFeatureToJsonObject( feature ) ); - QCOMPARE( QString::fromStdString( jPrecision.dump() ), expectedJsonPrecision ); + QCOMPARE( QString::fromStdString( jPrecision.dump() ), expectedJsonPrecision ); const auto jsonPrecision { exporterPrecision.exportFeature( feature ) }; QCOMPARE( jsonPrecision, expectedJsonPrecision ); - } void TestQgsJsonUtils::testExportFeatureJsonCrs() @@ -280,42 +267,36 @@ void TestQgsJsonUtils::testExportFeatureJsonCrs() const auto expectedJsonPrecision { QStringLiteral( "{\"bbox\":[124677.8,124685.8,606691.2,594190.5],\"geometry\":" - "{\"coordinates\":[[[124677.8,149181.7],[606691.2,124685.8],[594446.1,594190.5],[173658.4,579657.7]," - "[124677.8,149181.7]],[[222639.0,222684.2],[333958.5,222684.2],[333958.5,334111.2],[222639.0,334111.2]," - "[222639.0,222684.2]]],\"type\":\"Polygon\"},\"id\":123,\"properties\":{\"flddbl\":2.0,\"fldint\":1," - "\"fldtxt\":\"a value\"},\"type\":\"Feature\"}" ) }; + "{\"coordinates\":[[[124677.8,149181.7],[606691.2,124685.8],[594446.1,594190.5],[173658.4,579657.7]," + "[124677.8,149181.7]],[[222639.0,222684.2],[333958.5,222684.2],[333958.5,334111.2],[222639.0,334111.2]," + "[222639.0,222684.2]]],\"type\":\"Polygon\"},\"id\":123,\"properties\":{\"flddbl\":2.0,\"fldint\":1," + "\"fldtxt\":\"a value\"},\"type\":\"Feature\"}" ) }; feature.setId( 123 ); const auto jPrecision( exporterPrecision.exportFeatureToJsonObject( feature ) ); qDebug() << QString::fromStdString( jPrecision.dump() ); - QCOMPARE( QString::fromStdString( jPrecision.dump() ), expectedJsonPrecision ); + QCOMPARE( QString::fromStdString( jPrecision.dump() ), expectedJsonPrecision ); const auto jsonPrecision { exporterPrecision.exportFeature( feature ) }; QCOMPARE( jsonPrecision, expectedJsonPrecision ); - } void TestQgsJsonUtils::testExportGeomToJson() { - const QMap testWkts - { + const QMap testWkts { { - { - QStringLiteral( "LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)" ), + { QStringLiteral( "LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)" ), QStringLiteral( R"json({"coordinates":[[-71.16,42.259],[-71.161,42.259],[-71.161,42.259]],"type":"LineString"})json" ) }, - { - QStringLiteral( "MULTILINESTRING((-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932), (-70 43.56, -67 44.68))" ), + { QStringLiteral( "MULTILINESTRING((-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932), (-70 43.56, -67 44.68))" ), QStringLiteral( R"json({"coordinates":[[[-71.16,42.259],[-71.161,42.259],[-71.161,42.259]],[[-70.0,43.56],[-67.0,44.68]]],"type":"MultiLineString"})json" ) }, { QStringLiteral( "POINT(-71.064544 42.28787)" ), QStringLiteral( R"json({"coordinates":[-71.065,42.288],"type":"Point"})json" ) }, { QStringLiteral( "MULTIPOINT(-71.064544 42.28787, -71.1776585052917 42.3902909739571)" ), QStringLiteral( R"json({"coordinates":[[-71.065,42.288],[-71.178,42.39]],"type":"MultiPoint"})json" ) }, - { - QStringLiteral( "POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239," + { QStringLiteral( "POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239," "-71.1776063012595 42.3903825660754,-71.1775826583081 42.3903033653531,-71.1776585052917 42.3902909739571))" ), QStringLiteral( R"json({"coordinates":[[[-71.178,42.39],[-71.178,42.39],[-71.178,42.39],[-71.178,42.39],[-71.178,42.39]]],"type":"Polygon"})json" ) }, - { - QStringLiteral( "MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 2)),((3 3,6 2,6 4,3 3)))" ), + { QStringLiteral( "MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2, 3 2, 3 3, 2 3,2 2)),((3 3,6 2,6 4,3 3)))" ), QStringLiteral( R"json({"coordinates":[[[[1.0,1.0],[5.0,1.0],[5.0,5.0],[1.0,5.0],[1.0,1.0]],[[2.0,2.0],[3.0,2.0],[3.0,3.0],[2.0,3.0],[2.0,2.0]]],[[[3.0,3.0],[6.0,2.0],[6.0,4.0],[3.0,3.0]]]],"type":"MultiPolygon"})json" ) }, // Note: CIRCULARSTRING json is very long, we will check first three vertices only @@ -326,7 +307,7 @@ void TestQgsJsonUtils::testExportGeomToJson() for ( const auto &w : testWkts.toStdMap() ) { const auto g { QgsGeometry::fromWkt( w.first ) }; - QVERIFY( !g.isNull( ) ); + QVERIFY( !g.isNull() ); if ( w.first.startsWith( QLatin1String( "CIRCULARSTRING" ) ) ) { QVERIFY( g.asJson( 3 ).startsWith( w.second ) ); @@ -363,6 +344,5 @@ void TestQgsJsonUtils::testParseNumbers_data() } - QGSTEST_MAIN( TestQgsJsonUtils ) #include "testqgsjsonutils.moc" diff --git a/tests/src/core/testqgslabelingengine.cpp b/tests/src/core/testqgslabelingengine.cpp index 1260d3d34f37..1a82e643b0b1 100644 --- a/tests/src/core/testqgslabelingengine.cpp +++ b/tests/src/core/testqgslabelingengine.cpp @@ -42,13 +42,14 @@ class TestQgsLabelingEngine : public QgsTest { Q_OBJECT public: - TestQgsLabelingEngine() : QgsTest( QStringLiteral( "Labeling Engine Tests" ) ) {} + TestQgsLabelingEngine() + : QgsTest( QStringLiteral( "Labeling Engine Tests" ) ) {} private slots: void initTestCase(); void cleanupTestCase(); - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testEngineSettings(); void testScaledFont(); void testBasic(); @@ -158,7 +159,6 @@ class TestQgsLabelingEngine : public QgsTest void setDefaultLabelParams( QgsPalLayerSettings &settings ); QgsLabelingEngineSettings createLabelEngineSettings(); bool imageCheck( const QString &testName, QImage &image, int mismatchCount ); - }; void TestQgsLabelingEngine::initTestCase() @@ -325,7 +325,7 @@ void TestQgsLabelingEngine::testBasic() settings.fieldName = QStringLiteral( "Class" ); setDefaultLabelParams( settings ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -416,7 +416,7 @@ void TestQgsLabelingEngine::testRuleBased() QgsTextFormat format = s1.format(); format.setColor( QColor( 200, 0, 200 ) ); QFont font = QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ); -#if defined(HAS_KDE_QT5_FONT_STRETCH_FIX) || (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)) +#if defined( HAS_KDE_QT5_FONT_STRETCH_FIX ) || ( QT_VERSION >= QT_VERSION_CHECK( 6, 3, 0 ) ) font.setStretch( 100 ); #endif format.setFont( font ); @@ -614,7 +614,7 @@ void TestQgsLabelingEngine::zOrder() void TestQgsLabelingEngine::testEncodeDecodePositionOrder() { //create an ordered position list - QVector< Qgis::LabelPredefinedPointPosition > original; + QVector original; //make sure all placements are added here original << Qgis::LabelPredefinedPointPosition::BottomLeft << Qgis::LabelPredefinedPointPosition::BottomSlightlyLeft << Qgis::LabelPredefinedPointPosition::BottomMiddle << Qgis::LabelPredefinedPointPosition::BottomSlightlyRight @@ -627,12 +627,12 @@ void TestQgsLabelingEngine::testEncodeDecodePositionOrder() QVERIFY( !encoded.isEmpty() ); //decode - QVector< Qgis::LabelPredefinedPointPosition > decoded = QgsLabelingUtils::decodePredefinedPositionOrder( encoded ); + QVector decoded = QgsLabelingUtils::decodePredefinedPositionOrder( encoded ); QCOMPARE( decoded, original ); //test decoding with a messy string decoded = QgsLabelingUtils::decodePredefinedPositionOrder( QStringLiteral( ",tr,x,BSR, L, t,," ) ); - QVector< Qgis::LabelPredefinedPointPosition > expected; + QVector expected; expected << Qgis::LabelPredefinedPointPosition::TopRight << Qgis::LabelPredefinedPointPosition::BottomSlightlyRight << Qgis::LabelPredefinedPointPosition::MiddleLeft << Qgis::LabelPredefinedPointPosition::TopMiddle; QCOMPARE( decoded, expected ); @@ -657,7 +657,7 @@ void TestQgsLabelingEngine::testSubstitutions() { QgsPalLayerSettings settings; settings.useSubstitutions = false; - const QgsStringReplacementCollection collection( QList< QgsStringReplacement >() << QgsStringReplacement( QStringLiteral( "aa" ), QStringLiteral( "bb" ) ) ); + const QgsStringReplacementCollection collection( QList() << QgsStringReplacement( QStringLiteral( "aa" ), QStringLiteral( "bb" ) ) ); settings.substitutions = collection; settings.fieldName = QStringLiteral( "'aa label'" ); settings.isExpression = true; @@ -892,7 +892,7 @@ void TestQgsLabelingEngine::testParticipatingLayers() const QgsPalLayerSettings settings2; QgsVectorLayerLabelProvider *provider2 = new QgsVectorLayerLabelProvider( layer2, QStringLiteral( "test2" ), true, &settings2 ); engine.addProvider( provider2 ); - QCOMPARE( qgis::listToSet( engine.participatingLayers() ), QSet< QgsMapLayer * >() << vl << layer2 ); + QCOMPARE( qgis::listToSet( engine.participatingLayers() ), QSet() << vl << layer2 ); // add a rule-based labeling node QgsRuleBasedLabeling::Rule *root = new QgsRuleBasedLabeling::Rule( nullptr ); @@ -904,7 +904,7 @@ void TestQgsLabelingEngine::testParticipatingLayers() QgsVectorLayer *layer3 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer" ), QStringLiteral( "layer3" ), QStringLiteral( "memory" ) ); QgsRuleBasedLabelProvider *ruleProvider = new QgsRuleBasedLabelProvider( QgsRuleBasedLabeling( root ), layer3 ); engine.addProvider( ruleProvider ); - QCOMPARE( qgis::listToSet( engine.participatingLayers() ), QSet< QgsMapLayer * >() << vl << layer2 << layer3 ); + QCOMPARE( qgis::listToSet( engine.participatingLayers() ), QSet() << vl << layer2 << layer3 ); } bool TestQgsLabelingEngine::imageCheck( const QString &testName, QImage &image, int mismatchCount ) @@ -937,7 +937,7 @@ void TestQgsLabelingEngine::testRegisterFeatureUnprojectible() settings.isExpression = true; settings.fitInPolygonOnly = true; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); QgsFeature f( vl2->fields(), 1 ); @@ -980,7 +980,7 @@ void TestQgsLabelingEngine::testRotateHidePartial() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); @@ -993,7 +993,7 @@ void TestQgsLabelingEngine::testRotateHidePartial() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POLYGON((0 20,8 20,8 28,0 28,0 20))" ) ) ); vl2->dataProvider()->addFeature( f ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1056,8 +1056,8 @@ void TestQgsLabelingEngine::testParallelLabelSmallFeature() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::Line; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); QgsFeature f( vl2->fields(), 1 ); @@ -1065,7 +1065,7 @@ void TestQgsLabelingEngine::testParallelLabelSmallFeature() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "MultiLineString ((491176.796876200591214 1277565.39028006233274937, 491172.03128372476203367 1277562.45040752924978733, 491167.67935446038609371 1277557.28786265244707465, 491165.36599104333436117 1277550.97473702346906066, 491165.35308923490811139 1277544.24074512091465294, 491166.8345245998352766 1277539.49665334494784474, 491169.47186020453227684 1277535.27191955596208572, 491173.11253597546601668 1277531.85408334922976792, 491179.02124191814800724 1277528.94421873707324266, 491185.57387020520400256 1277528.15719766705296934, 491192.01811734877992421 1277529.57064539520069957, 491197.62341773137450218 1277533.02997340611182153, 491201.74636711279163137 1277538.15941766835749149, 491203.92884904221864417 1277544.35095247370190918, 491203.9633954341406934 1277550.5652371181640774, 491202.02436481812037528 1277556.4815535971429199, 491198.296930403157603 1277561.48062952468171716, 491193.17346247035311535 1277565.0647635399363935, 491187.82046439842088148 1277566.747082503978163, 491182.21622701874002814 1277566.85931688314303756, 491176.796876200591214 1277565.39028006233274937))" ) ) ); vl2->dataProvider()->addFeature( f ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1125,8 +1125,8 @@ void TestQgsLabelingEngine::testAllowDegradedPlacements() // start without degraded placement -- no label should be shown settings.placementSettings().setAllowDegradedPlacement( false ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "linestring?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); QgsFeature f( vl2->fields(), 1 ); @@ -1134,7 +1134,7 @@ void TestQgsLabelingEngine::testAllowDegradedPlacements() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "MultiLineString ((491129.07640071882633492 1277548.62886608019471169, 491238.41896284645190462 1277549.61172057129442692))" ) ) ); vl2->dataProvider()->addFeature( f ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1203,8 +1203,8 @@ void TestQgsLabelingEngine::testOverlapHandling() settings.placement = Qgis::LabelPlacement::OrderedPositionsAroundPoint; settings.priority = 5; - std::unique_ptr< QgsVectorLayer> vl1( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl1->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0}, {QStringLiteral( "outline_style" ), QStringLiteral( "no" )} } ) ) ); + std::unique_ptr vl1( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl1->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl1.get(), QStringLiteral( "test" ), true, &settings ); QgsFeature f( vl1->fields(), 1 ); @@ -1212,7 +1212,7 @@ void TestQgsLabelingEngine::testOverlapHandling() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "Point (491004 1277640)" ) ) ); vl1->dataProvider()->addFeature( f ); - vl1->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl1->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl1->setLabelsEnabled( true ); // this layer has fixed labels, they can't move @@ -1220,8 +1220,8 @@ void TestQgsLabelingEngine::testOverlapHandling() settings.pointSettings().setQuadrant( Qgis::LabelQuadrantPosition::AboveLeft ); settings.priority = 10; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#ff0000" )}, {QStringLiteral( "outline_width" ), 0}, {QStringLiteral( "outline_style" ), QStringLiteral( "no" )} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#ff0000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider2 = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); f = QgsFeature( vl2->fields(), 1 ); @@ -1229,7 +1229,7 @@ void TestQgsLabelingEngine::testOverlapHandling() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "Point (491192 1277700)" ) ) ); vl2->dataProvider()->addFeature( f ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1366,8 +1366,8 @@ void TestQgsLabelingEngine::testAllowOverlapsIgnoresObstacles() settings.pointSettings().setQuadrant( Qgis::LabelQuadrantPosition::AboveRight ); settings.priority = 2; - std::unique_ptr< QgsVectorLayer> vl1( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl1->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0}, {QStringLiteral( "outline_style" ), QStringLiteral( "no" )} } ) ) ); + std::unique_ptr vl1( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl1->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider = new QgsVectorLayerLabelProvider( vl1.get(), QStringLiteral( "test" ), true, &settings ); QgsFeature f( vl1->fields(), 1 ); @@ -1375,7 +1375,7 @@ void TestQgsLabelingEngine::testAllowOverlapsIgnoresObstacles() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "Point (491004 1277640)" ) ) ); vl1->dataProvider()->addFeature( f ); - vl1->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl1->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl1->setLabelsEnabled( true ); // this layer is an obstacle only @@ -1383,8 +1383,8 @@ void TestQgsLabelingEngine::testAllowOverlapsIgnoresObstacles() settings.obstacleSettings().setIsObstacle( true ); settings.obstacleSettings().setFactor( 10 ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#ff0000" )}, {QStringLiteral( "outline_width" ), 0}, {QStringLiteral( "outline_style" ), QStringLiteral( "no" )} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "point?crs=epsg:3148&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsMarkerSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#ff0000" ) }, { QStringLiteral( "outline_width" ), 0 }, { QStringLiteral( "outline_style" ), QStringLiteral( "no" ) } } ) ) ); QgsVectorLayerLabelProvider *provider2 = new QgsVectorLayerLabelProvider( vl2.get(), QStringLiteral( "test" ), true, &settings ); f = QgsFeature( vl2->fields(), 1 ); @@ -1392,7 +1392,7 @@ void TestQgsLabelingEngine::testAllowOverlapsIgnoresObstacles() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "Point (491192 1277700)" ) ) ); vl2->dataProvider()->addFeature( f ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1470,7 +1470,7 @@ void TestQgsLabelingEngine::testAdjacentParts() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = true; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1478,7 +1478,7 @@ void TestQgsLabelingEngine::testAdjacentParts() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "MultiPolygon (((1967901.6872910603415221 5162590.11975561361759901, 1967905.31832842249423265 5162591.80023225769400597, 1967907.63076798897236586 5162586.43503414187580347, 1967903.84105980419553816 5162584.57283254805952311, 1967901.6872910603415221 5162590.11975561361759901)),((1967901.64785283687524498 5162598.3270823871716857, 1967904.82891705213114619 5162601.06552503909915686, 1967910.82140435534529388 5162587.99774718284606934, 1967907.63076798897236586 5162586.43503414187580347, 1967905.31832842249423265 5162591.80023225769400597, 1967901.6872910603415221 5162590.11975561361759901, 1967899.27472299290820956 5162596.28855143301188946, 1967901.64785283687524498 5162598.3270823871716857)),((1967904.82891705213114619 5162601.06552503909915686, 1967901.64785283687524498 5162598.3270823871716857, 1967884.28552994946949184 5162626.09785370342433453, 1967895.81538487318903208 5162633.84423183929175138, 1967901.64141261484473944 5162624.63927845563739538, 1967906.47453573765233159 5162616.87410452589392662, 1967913.7844126324634999 5162604.47178338281810284, 1967909.58057221467606723 5162602.89022256527096033, 1967904.82891705213114619 5162601.06552503909915686)))" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1525,15 +1525,15 @@ void TestQgsLabelingEngine::testTouchingParts() // if treated individually, none of these parts are long enough for the label to fit -- but the label should be rendered if the mergeLines setting is true, // because the parts should be merged into a single linestring - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiLineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiLineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "MultiLineString ((190000 5000010, 190050 5000000), (190050 5000000, 190100 5000000), (190200 5000000, 190150 5000000), (190150 5000000, 190100 5000000))" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1581,8 +1581,8 @@ void TestQgsLabelingEngine::testMergingLinesWithForks() settings.lineSettings().setMergeLines( true ); // if treated individually, none of these parts are long enough for the label to fit -- but the label should be rendered if the mergeLines setting is true - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); @@ -1600,7 +1600,7 @@ void TestQgsLabelingEngine::testMergingLinesWithForks() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190120 5000000, 190100 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1648,8 +1648,8 @@ void TestQgsLabelingEngine::testMergingLinesWithMinimumSize() settings.thinningSettings().setMinimumFeatureSize( 90.0 ); // if treated individually, none of these parts exceed the minimum feature size set above -- but the label should be rendered if the mergeLines setting is true - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); @@ -1667,7 +1667,7 @@ void TestQgsLabelingEngine::testMergingLinesWithMinimumSize() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190120 5000000, 190100 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1711,7 +1711,7 @@ void TestQgsLabelingEngine::testPointLabelTabs() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1720,7 +1720,7 @@ void TestQgsLabelingEngine::testPointLabelTabs() f.setGeometry( refGeom.centroid() ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1765,7 +1765,7 @@ void TestQgsLabelingEngine::testPointLabelTabsHtml() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1774,7 +1774,7 @@ void TestQgsLabelingEngine::testPointLabelTabsHtml() f.setGeometry( refGeom.centroid() ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1818,7 +1818,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlFormatting() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1827,7 +1827,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlFormatting() f.setGeometry( refGeom.centroid() ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1872,7 +1872,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlFormattingDataDefinedSize() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1881,7 +1881,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlFormattingDataDefinedSize() f.setGeometry( refGeom.centroid() ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1925,7 +1925,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlImages() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1934,7 +1934,7 @@ void TestQgsLabelingEngine::testPointLabelHtmlImages() f.setGeometry( refGeom.centroid() ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -1982,7 +1982,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlSuperSubscript() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -1990,7 +1990,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlSuperSubscript() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190100 5000000, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2038,7 +2038,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlWordSpacing() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2046,7 +2046,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlWordSpacing() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190100 5000000, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2095,7 +2095,7 @@ void TestQgsLabelingEngine::testCurvedLabelsTabs() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2103,7 +2103,7 @@ void TestQgsLabelingEngine::testCurvedLabelsTabs() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190100 5000000, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2139,7 +2139,7 @@ void TestQgsLabelingEngine::testCurvedLabelsTabPositions() QgsTextFormat format = settings.format(); format.setSize( 30 ); format.setColor( QColor( 0, 0, 0 ) ); - format.setTabPositions( {QgsTextFormat::Tab( 55 ), QgsTextFormat::Tab( 82 )} ); + format.setTabPositions( { QgsTextFormat::Tab( 55 ), QgsTextFormat::Tab( 82 ) } ); format.setTabStopDistanceUnit( Qgis::RenderUnit::Millimeters ); settings.setFormat( format ); @@ -2152,7 +2152,7 @@ void TestQgsLabelingEngine::testCurvedLabelsTabPositions() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2160,7 +2160,7 @@ void TestQgsLabelingEngine::testCurvedLabelsTabPositions() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190100 5000000, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2208,7 +2208,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlFormatting() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2216,7 +2216,7 @@ void TestQgsLabelingEngine::testCurvedLabelsHtmlFormatting() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190100 5000000, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2263,7 +2263,7 @@ void TestQgsLabelingEngine::testCurvedPerimeterLabelsHtmlFormatting() settings.maxCurvedCharAngleOut = 45; settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -2271,7 +2271,7 @@ void TestQgsLabelingEngine::testCurvedPerimeterLabelsHtmlFormatting() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "Polygon ((189999.00790438248077407 5000025.93351394217461348, 190045.43212749005760998 5000092.01976095419377089, 190116.98004780878545716 5000103.4892748985439539, 190168.8659442231291905 5000086.0119203170761466, 190197.8128127490344923 5000022.11034262739121914, 190202.18215139443054795 4999983.33246214967221022, 190136.64207171316957101 4999950.56242230907082558, 190084.75617529882583767 4999935.81590438075363636, 190017.57759362552314997 4999968.03977689053863287, 190001.19257370519335382 4999987.15563346445560455, 189999.00790438248077407 5000025.93351394217461348))" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2313,19 +2313,19 @@ void TestQgsLabelingEngine::testCurvedLabelsWithTinySegments() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::Curved; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); // our geometry starts with many small segments, followed by long ones QgsGeometry g( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190100 5000000)" ) ) ); g = g.densifyByCount( 100 ); - qgsgeometry_cast< QgsLineString * >( g.get() )->addVertex( QgsPoint( 190200, 5000000 ) ); + qgsgeometry_cast( g.get() )->addVertex( QgsPoint( 190200, 5000000 ) ); f.setGeometry( g ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2372,8 +2372,8 @@ void TestQgsLabelingEngine::testCurvedLabelCorrectLinePlacement() settings.maxCurvedCharAngleIn = 99; settings.maxCurvedCharAngleOut = 99; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); @@ -2382,7 +2382,7 @@ void TestQgsLabelingEngine::testCurvedLabelCorrectLinePlacement() f.setGeometry( g ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2411,7 +2411,7 @@ void TestQgsLabelingEngine::testCurvedLabelCorrectLinePlacement() // and below... settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! QgsMapRendererSequentialJob job2( mapSettings ); job2.start(); @@ -2438,15 +2438,15 @@ void TestQgsLabelingEngine::testCurvedLabelNegativeDistance() settings.labelPerPart = false; settings.dist = -5; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190100 5000000, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2491,15 +2491,15 @@ void TestQgsLabelingEngine::testCurvedLabelOnSmallLineNearCenter() settings.placement = Qgis::LabelPlacement::Curved; settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190080 5000010, 190100 5000000, 190120 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2543,15 +2543,15 @@ void TestQgsLabelingEngine::testCurvedLabelLineOrientationAbove() settings.labelPerPart = false; settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2579,7 +2579,7 @@ void TestQgsLabelingEngine::testCurvedLabelLineOrientationAbove() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_orientation_above" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -2608,15 +2608,15 @@ void TestQgsLabelingEngine::testCurvedLabelLineOrientationBelow() settings.labelPerPart = false; settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2644,7 +2644,7 @@ void TestQgsLabelingEngine::testCurvedLabelLineOrientationBelow() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_orientation_below" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -2677,15 +2677,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAbove() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2713,7 +2713,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAbove() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_above" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -2745,15 +2745,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownBelow() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2781,7 +2781,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownBelow() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_below" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -2814,15 +2814,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAbovePositiveOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2848,7 +2848,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAbovePositiveOffset() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_above_positive_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -2882,15 +2882,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAboveNegativeOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2916,7 +2916,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownAboveNegativeOffset() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_above_negative_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -2949,15 +2949,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownLeftPositiveOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -2983,7 +2983,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownLeftPositiveOffset() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_left_positive_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3017,15 +3017,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownLeftNegativeOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3051,7 +3051,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownLeftNegativeOffset() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_left_negative_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3084,15 +3084,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownRightPositiveOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3118,7 +3118,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownRightPositiveOffset() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_right_positive_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3152,15 +3152,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownRightNegativeOffset() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3186,7 +3186,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownRightNegativeOffset() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_right_negative_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3218,15 +3218,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAbove() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3252,7 +3252,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAbove() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_above" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3284,15 +3284,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintBelow() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3318,7 +3318,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintBelow() QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_below" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3351,15 +3351,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAbovePositiveOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3385,7 +3385,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAbovePositiveOffse QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_above_positive_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3419,15 +3419,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAboveNegativeOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::MapOrientation ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3453,7 +3453,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintAboveNegativeOffse QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_above_negative_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3486,15 +3486,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintLeftPositiveOffset settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3520,7 +3520,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintLeftPositiveOffset QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_left_positive_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3554,15 +3554,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintLeftNegativeOffset settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3588,7 +3588,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintLeftNegativeOffset QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_left_negative_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3621,15 +3621,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintRightPositiveOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3655,7 +3655,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintRightPositiveOffse QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_right_positive_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3689,15 +3689,15 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintRightNegativeOffse settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::BelowLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190100 5000007, 190094 5000012, 190096 5000019, 190103 5000024, 190111 5000023, 190114 5000018)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3723,7 +3723,7 @@ void TestQgsLabelingEngine::testCurvedLabelAllowUpsideDownHintRightNegativeOffse QVERIFY( imageCheck( QStringLiteral( "label_curved_line_allow_upside_down_hint_right_negative_offset" ), img, 20 ) ); // reverse line and retry, label should be flipped to other side of line - f.setGeometry( QgsGeometry( qgsgeometry_cast< QgsLineString * >( f.geometry().constGet() )->reversed() ) ); + f.setGeometry( QgsGeometry( qgsgeometry_cast( f.geometry().constGet() )->reversed() ) ); vl2->dataProvider()->truncate(); QVERIFY( vl2->dataProvider()->addFeature( f ) ); @@ -3753,15 +3753,15 @@ void TestQgsLabelingEngine::testRepeatDistanceWithSmallLine() settings.labelPerPart = false; settings.repeatDistance = 55; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190050 5000000, 190150 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3807,15 +3807,15 @@ void TestQgsLabelingEngine::testParallelPlacementPreferAbove() settings.lineSettings().setPlacementFlags( Qgis::LabelLinePlacementFlag::AboveLine | Qgis::LabelLinePlacementFlag::BelowLine | Qgis::LabelLinePlacementFlag::MapOrientation ); settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3858,7 +3858,7 @@ void TestQgsLabelingEngine::testLabelBoundary() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f( vl2->fields(), 1 ); @@ -3867,12 +3867,12 @@ void TestQgsLabelingEngine::testLabelBoundary() { for ( int y = 0; y < 12; y++ ) { - f.setGeometry( std::make_unique< QgsPoint >( x, y ) ); + f.setGeometry( std::make_unique( x, y ) ); vl2->dataProvider()->addFeature( f ); } } - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3927,7 +3927,7 @@ void TestQgsLabelingEngine::testLabelBlockingRegion() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f( vl2->fields(), 1 ); @@ -3936,12 +3936,12 @@ void TestQgsLabelingEngine::testLabelBlockingRegion() { for ( int y = 0; y < 12; y++ ) { - f.setGeometry( std::make_unique< QgsPoint >( x, y ) ); + f.setGeometry( std::make_unique( x, y ) ); vl2->dataProvider()->addFeature( f ); } } - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -3957,7 +3957,7 @@ void TestQgsLabelingEngine::testLabelBlockingRegion() mapSettings.setLayers( QList() << vl2.get() ); mapSettings.setOutputDpi( 96 ); - QList< QgsLabelBlockingRegion > regions; + QList regions; regions << QgsLabelBlockingRegion( QgsGeometry::fromWkt( QStringLiteral( "Polygon((6 1, 12 1, 12 9, 6 9, 6 1),(8 4, 10 4, 10 7, 8 7, 8 4))" ) ) ); regions << QgsLabelBlockingRegion( QgsGeometry::fromWkt( QStringLiteral( "Polygon((0 0, 3 0, 3 3, 0 3, 0 0))" ) ) ); mapSettings.setLabelBlockingRegions( regions ); @@ -4011,7 +4011,7 @@ void TestQgsLabelingEngine::testLabelRotationWithReprojection() settings.isExpression = true; settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4025,7 +4025,7 @@ void TestQgsLabelingEngine::testLabelRotationWithReprojection() f.setGeometry( QgsGeometry::fromPointXY( QgsPointXY( -0.118667702475932, 51.5019405883275 ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -4084,7 +4084,7 @@ void TestQgsLabelingEngine::testLabelRotationUnit() settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelRotation, QgsProperty::fromExpression( QString::number( 3.14 / 2.0 ) ) ); settings.setRotationUnit( Qgis::AngleUnit::Radians ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -4117,7 +4117,7 @@ void TestQgsLabelingEngine::drawUnplaced() settings.priority = 3; settings.obstacleSettings().setFactor( 0 ); - std::unique_ptr< QgsVectorLayer> vl1( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl1( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl1->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4125,7 +4125,7 @@ void TestQgsLabelingEngine::drawUnplaced() f.setGeometry( QgsGeometry::fromPointXY( QgsPointXY( -6.250851540391068, 53.335006994584944 ) ) ); QVERIFY( vl1->dataProvider()->addFeature( f ) ); - vl1->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl1->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl1->setLabelsEnabled( true ); // second layer @@ -4137,21 +4137,21 @@ void TestQgsLabelingEngine::drawUnplaced() format.setSize( 90 ); settings.setFormat( format ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // test a label with 0 candidates (line is too short for label) - std::unique_ptr< QgsVectorLayer> vl3( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl3( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl3->setRenderer( new QgsNullSymbolRenderer() ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString(-6.250851540391068 60.6, -6.250851640391068 60.6 )" ) ) ); QVERIFY( vl3->dataProvider()->addFeature( f ) ); settings.placement = Qgis::LabelPlacement::Curved; - vl3->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl3->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl3->setLabelsEnabled( true ); // make a fake render context @@ -4198,7 +4198,7 @@ void TestQgsLabelingEngine::labelingResults() settings.priority = 10; settings.angleOffset = 3; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4213,9 +4213,9 @@ void TestQgsLabelingEngine::labelingResults() QVERIFY( vl2->dataProvider()->addFeature( f ) ); vl2->updateExtents(); - std::unique_ptr< QgsVectorLayer> vl3( vl2->clone() ); + std::unique_ptr vl3( vl2->clone() ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -4227,7 +4227,7 @@ void TestQgsLabelingEngine::labelingResults() mapSettings.setOutputSize( size ); mapSettings.setExtent( QgsRectangle( -4137976.6, 6557092.6, 1585557.4, 9656515.0 ) ); -// mapSettings.setRotation( 60 ); + // mapSettings.setRotation( 60 ); mapSettings.setLayers( QList() << vl2.get() << vl3.get() ); mapSettings.setOutputDpi( 96 ); @@ -4241,14 +4241,13 @@ void TestQgsLabelingEngine::labelingResults() job.start(); job.waitForFinished(); - std::unique_ptr< QgsLabelingResults > results( job.takeLabelingResults() ); + std::unique_ptr results( job.takeLabelingResults() ); QVERIFY( results ); // retrieve some labels QList labels = results->allLabels(); QCOMPARE( labels.count(), 3 ); - std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition & a, const QgsLabelPosition & b ) - { + std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition &a, const QgsLabelPosition &b ) { return a.labelText.compare( b.labelText ) < 0; } ); QCOMPARE( labels.at( 0 ).labelText, QStringLiteral( "1" ) ); @@ -4315,8 +4314,7 @@ void TestQgsLabelingEngine::labelingResults() labels = results->allLabels(); QCOMPARE( labels.count(), 6 ); - std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition & a, const QgsLabelPosition & b ) - { + std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition &a, const QgsLabelPosition &b ) { return a.isUnplaced == b.isUnplaced ? a.labelText.compare( b.labelText ) < 0 : a.isUnplaced < b.isUnplaced; } ); QCOMPARE( labels.at( 0 ).labelText, QStringLiteral( "1" ) ); @@ -4332,11 +4330,11 @@ void TestQgsLabelingEngine::labelingResults() QCOMPARE( labels.at( 5 ).labelText, QStringLiteral( "8888" ) ); QVERIFY( labels.at( 5 ).isUnplaced ); - mapSettings.setLayers( {vl2.get() } ); + mapSettings.setLayers( { vl2.get() } ); // with map rotation settings.angleOffset = 0; - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); mapSettings.setRotation( 60 ); QgsMapRendererSequentialJob job2( mapSettings ); @@ -4408,7 +4406,7 @@ void TestQgsLabelingEngine::labelingResultsCurved() settings.placement = Qgis::LabelPlacement::Curved; settings.priority = 10; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -4423,7 +4421,7 @@ void TestQgsLabelingEngine::labelingResultsCurved() QVERIFY( vl2->dataProvider()->addFeature( f ) ); vl2->updateExtents(); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -4449,14 +4447,13 @@ void TestQgsLabelingEngine::labelingResultsCurved() job.start(); job.waitForFinished(); - std::unique_ptr< QgsLabelingResults > results( job.takeLabelingResults() ); + std::unique_ptr results( job.takeLabelingResults() ); QVERIFY( results ); // retrieve some labels QList labels = results->allLabels(); QCOMPARE( labels.count(), 10 ); - std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition & a, const QgsLabelPosition & b ) - { + std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition &a, const QgsLabelPosition &b ) { return a.labelText.compare( b.labelText ) < 0; } ); QCOMPARE( labels.at( 0 ).labelText, QStringLiteral( "1" ) ); @@ -4524,7 +4521,7 @@ void TestQgsLabelingEngine::labelingResultsWithCallouts() settings.callout()->setDataDefinedProperties( calloutProps ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 << -20.173 << 58.624 << -11.160 << 58.001 << -3.814 << 56.046 ); @@ -4536,11 +4533,11 @@ void TestQgsLabelingEngine::labelingResultsWithCallouts() settings.callout()->setEnabled( true ); settings.callout()->setDataDefinedProperties( calloutProps ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // another layer - std::unique_ptr< QgsVectorLayer> vl3( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3857&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl3( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:3857&field=id:integer&field=labelx:double&field=labely:double&field=calloutoriginx:double&field=calloutoriginy:double&field=calloutdestx:double&field=calloutdesty:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); f.setAttributes( QgsAttributes() << 2 << -3424024 << 7849709 << -2713442 << 7628322 << -2567040 << 6974872 ); f.setGeometry( QgsGeometry::fromPointXY( QgsPointXY( -2995532, 7242679 ) ) ); @@ -4552,7 +4549,7 @@ void TestQgsLabelingEngine::labelingResultsWithCallouts() vl3->updateExtents(); - vl3->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl3->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl3->setLabelsEnabled( true ); // make a fake render context @@ -4580,7 +4577,7 @@ void TestQgsLabelingEngine::labelingResultsWithCallouts() job.renderedImage().save( QDir::tempPath() + QStringLiteral( "/labelingResultsWithCallouts_renderer.png" ) ); - std::unique_ptr< QgsLabelingResults > results( job.takeLabelingResults() ); + std::unique_ptr results( job.takeLabelingResults() ); QVERIFY( results ); // retrieve some callouts @@ -4641,9 +4638,12 @@ void TestQgsLabelingEngine::labelingResultsWithCallouts() callouts = results->calloutsWithinRectangle( mapSettings.visibleExtent() ); QCOMPARE( callouts.count(), 3 ); - const int callout1Index = callouts.at( 0 ).layerID == vl2->id() ? 0 : callouts.at( 1 ).layerID == vl2->id() ? 1 : 2; - const int callout2Index = callouts.at( 0 ).layerID == vl3->id() && callouts.at( 0 ).featureId == 1 ? 0 : callouts.at( 1 ).layerID == vl3->id() && callouts.at( 1 ).featureId == 1 ? 1 : 2; - const int callout3Index = callouts.at( 0 ).layerID == vl3->id() && callouts.at( 0 ).featureId == 2 ? 0 : callouts.at( 1 ).layerID == vl3->id() && callouts.at( 1 ).featureId == 2 ? 1 : 2; + const int callout1Index = callouts.at( 0 ).layerID == vl2->id() ? 0 : callouts.at( 1 ).layerID == vl2->id() ? 1 + : 2; + const int callout2Index = callouts.at( 0 ).layerID == vl3->id() && callouts.at( 0 ).featureId == 1 ? 0 : callouts.at( 1 ).layerID == vl3->id() && callouts.at( 1 ).featureId == 1 ? 1 + : 2; + const int callout3Index = callouts.at( 0 ).layerID == vl3->id() && callouts.at( 0 ).featureId == 2 ? 0 : callouts.at( 1 ).layerID == vl3->id() && callouts.at( 1 ).featureId == 2 ? 1 + : 2; QCOMPARE( callouts.at( callout1Index ).featureId, 1 ); QCOMPARE( callouts.at( callout1Index ).layerID, vl2->id() ); QGSCOMPARENEAR( callouts.at( callout1Index ).origin().x(), -1242325.0, 10 ); @@ -4735,9 +4735,9 @@ void TestQgsLabelingEngine::pointsetExtend() { // test extending pointsets by distance { - QVector< double > x; + QVector x; x << 1 << 9; - QVector< double > y; + QVector y; y << 2 << 2; pal::PointSet set( 2, x.data(), y.data() ); @@ -4754,9 +4754,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 1 << 9; - QVector< double > y; + QVector y; y << 2 << 2; pal::PointSet set( 2, x.data(), y.data() ); set.extendLineByDistance( 0, 0, 0 ); @@ -4774,9 +4774,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 1; - QVector< double > y; + QVector y; y << 2; pal::PointSet set( 1, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 0 ); @@ -4784,9 +4784,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 1 << 2 << 8 << 9; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 0 ); @@ -4806,9 +4806,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 9 << 8 << 2 << 1; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 0 ); @@ -4829,9 +4829,9 @@ void TestQgsLabelingEngine::pointsetExtend() { // with averaging - QVector< double > x; + QVector x; x << 1 << 2 << 8 << 9; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 0.5 ); @@ -4851,9 +4851,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 1 << 2 << 8 << 9; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 1 ); @@ -4873,9 +4873,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 1 << 2 << 8 << 9; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 2 ); @@ -4895,9 +4895,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 1 << 2 << 8 << 9; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 4 ); @@ -4917,9 +4917,9 @@ void TestQgsLabelingEngine::pointsetExtend() } { - QVector< double > x; + QVector x; x << 1 << 2 << 8 << 9; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 5 ); @@ -4935,13 +4935,13 @@ void TestQgsLabelingEngine::pointsetExtend() QCOMPARE( set.x.at( 4 ), 9.0 ); QCOMPARE( set.y.at( 4 ), 2.0 ); QGSCOMPARENEAR( set.x.at( 5 ), 11.998204, 0.00001 ); - QGSCOMPARENEAR( set.y.at( 5 ), 1.896217, 0.00001 ); + QGSCOMPARENEAR( set.y.at( 5 ), 1.896217, 0.00001 ); } { - QVector< double > x; + QVector x; x << 1 << 2 << 8 << 9; - QVector< double > y; + QVector y; y << 2 << 3 << 3 << 2; pal::PointSet set( 4, x.data(), y.data() ); set.extendLineByDistance( 1, 3, 15 ); @@ -4978,15 +4978,15 @@ void TestQgsLabelingEngine::curvedOverrun() settings.labelPerPart = false; settings.lineSettings().setOverrunDistance( 0 ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190079.9 5000000.3, 190080 5000000, 190085 5000005, 190110 5000005)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5015,7 +5015,7 @@ void TestQgsLabelingEngine::curvedOverrun() settings.lineSettings().setOverrunDistance( 11 ); settings.maxCurvedCharAngleIn = 99; settings.maxCurvedCharAngleOut = 99; - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsMapRendererSequentialJob job2( mapSettings ); job2.start(); @@ -5026,7 +5026,7 @@ void TestQgsLabelingEngine::curvedOverrun() // too short for what's required... settings.lineSettings().setOverrunDistance( 3 ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsMapRendererSequentialJob job3( mapSettings ); job3.start(); @@ -5053,15 +5053,15 @@ void TestQgsLabelingEngine::parallelOverrun() settings.labelPerPart = false; settings.lineSettings().setOverrunDistance( 0 ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190079.9 5000000.3, 190080 5000000, 190085 5000005, 190110 5000005)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5089,7 +5089,7 @@ void TestQgsLabelingEngine::parallelOverrun() QVERIFY( imageCheck( QStringLiteral( "label_curved_no_overrun" ), img, 20 ) ); settings.lineSettings().setOverrunDistance( 10 ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsMapRendererSequentialJob job2( mapSettings ); job2.start(); @@ -5100,7 +5100,7 @@ void TestQgsLabelingEngine::parallelOverrun() // too short for what's required... settings.lineSettings().setOverrunDistance( 3 ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsMapRendererSequentialJob job3( mapSettings ); job3.start(); @@ -5126,7 +5126,7 @@ void TestQgsLabelingEngine::testDataDefinedLabelAllParts() settings.placement = Qgis::LabelPlacement::OverPoint; settings.labelPerPart = false; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "MultiPolygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "MultiPolygon?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -5140,7 +5140,7 @@ void TestQgsLabelingEngine::testDataDefinedLabelAllParts() settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LabelAllParts, QgsProperty::fromExpression( QStringLiteral( "\"id\" = 2" ) ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5196,7 +5196,7 @@ void TestQgsLabelingEngine::testDataDefinedPlacementPositionPoint() settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::PositionPoint, QgsProperty::fromExpression( QStringLiteral( "translate($geometry, 1, 0.5)" ) ) ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -5240,7 +5240,7 @@ void TestQgsLabelingEngine::testVerticalOrientation() format.setOrientation( Qgis::TextOrientation::Vertical ); settings.setFormat( format ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -5290,7 +5290,7 @@ void TestQgsLabelingEngine::testVerticalOrientationLetterLineSpacing() format.setFont( font ); settings.setFormat( format ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -5336,7 +5336,7 @@ void TestQgsLabelingEngine::testRotationBasedOrientationPoint() format.setOrientation( Qgis::TextOrientation::RotationBased ); settings.setFormat( format ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -5385,7 +5385,7 @@ void TestQgsLabelingEngine::testRotationBasedOrientationPointHtmlLabel() format.setAllowHtmlFormatting( true ); settings.setFormat( format ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -5437,7 +5437,7 @@ void TestQgsLabelingEngine::testRotationBasedOrientationLine() format.setOrientation( Qgis::TextOrientation::RotationBased ); settings.setFormat( format ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); QgsDefaultLabelingEngine engine; @@ -5473,15 +5473,15 @@ void TestQgsLabelingEngine::testMapUnitLetterSpacing() format.setFont( font ); settings.setFormat( format ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190020 5000000, 190180 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5527,15 +5527,15 @@ void TestQgsLabelingEngine::testMapUnitWordSpacing() format.setFont( font ); settings.setFormat( format ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190020 5000000, 190180 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5580,7 +5580,7 @@ void TestQgsLabelingEngine::testLineHeightAbsolute() settings.placement = Qgis::LabelPlacement::Horizontal; settings.setFormat( format ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); QgsFeature f; @@ -5588,7 +5588,7 @@ void TestQgsLabelingEngine::testLineHeightAbsolute() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190020 5000000, 190180 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5647,15 +5647,15 @@ void TestQgsLabelingEngine::testClipping() settings.placement = Qgis::LabelPlacement::Line; const QString filename = QStringLiteral( TEST_DATA_DIR ) + "/lines.shp"; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( filename, QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ) ); QVariantMap props; props.insert( QStringLiteral( "outline_color" ), QStringLiteral( "#487bb6" ) ); props.insert( QStringLiteral( "outline_width" ), QStringLiteral( "1" ) ); - std::unique_ptr< QgsLineSymbol > symbol( QgsLineSymbol::createSimple( props ) ); + std::unique_ptr symbol( QgsLineSymbol::createSimple( props ) ); vl2->setRenderer( new QgsSingleSymbolRenderer( symbol.release() ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5717,15 +5717,15 @@ void TestQgsLabelingEngine::testLineAnchorParallel() settings.labelPerPart = false; settings.lineSettings().setLineAnchorPercent( 0.0 ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5781,15 +5781,15 @@ void TestQgsLabelingEngine::testLineAnchorParallelConstraints() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000000, 190010 5000010, 190190 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -5979,15 +5979,15 @@ void TestQgsLabelingEngine::testLineAnchorDataDefinedType() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::LineAnchorType, QgsProperty::fromExpression( QStringLiteral( "'strict'" ) ) ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000000, 190010 5000010, 190190 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6046,15 +6046,15 @@ void TestQgsLabelingEngine::testLineAnchorCurved() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6109,7 +6109,6 @@ void TestQgsLabelingEngine::testLineAnchorCurved() img = job4.renderedImage(); QVERIFY( imageCheck( QStringLiteral( "curved_anchor_30_below" ), img, 20 ) ); - } void TestQgsLabelingEngine::testLineAnchorCurvedConstraints() @@ -6131,15 +6130,15 @@ void TestQgsLabelingEngine::testLineAnchorCurvedConstraints() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000000, 190010 5000010, 190190 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6332,15 +6331,15 @@ void TestQgsLabelingEngine::testLineAnchorCurvedOverrun() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::EndOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000000, 190010 5000010, 190190 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6402,15 +6401,15 @@ void TestQgsLabelingEngine::testLineAnchorCurvedStrictAllUpsideDown() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::StartOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190088.74697824331815355 4999955.67284447979182005, 190121.74456083800760098 5000011.17647058796137571, 190090.26994359385571443 5000072.94117647036910057)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6457,15 +6456,15 @@ void TestQgsLabelingEngine::testLineAnchorHorizontal() settings.lineSettings().setLineAnchorPercent( 0.0 ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6522,8 +6521,8 @@ void TestQgsLabelingEngine::testLineAnchorHorizontalConstraints() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::HintOnly ); settings.lineSettings().setAnchorTextPoint( QgsLabelLineSettings::AnchorTextPoint::CenterOfText ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << QVariant() ); @@ -6538,7 +6537,7 @@ void TestQgsLabelingEngine::testLineAnchorHorizontalConstraints() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190020 5000000, 190030 5000010, 190170 5000010, 190190 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6614,14 +6613,14 @@ void TestQgsLabelingEngine::testLineAnchorClipping() settings.lineSettings().setAnchorType( QgsLabelLineSettings::AnchorType::Strict ); settings.lineSettings().setAnchorClipping( QgsLabelLineSettings::AnchorClipping::UseEntireLine ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#ff0000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#ff0000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (189950 5000000, 190100 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6670,8 +6669,8 @@ void TestQgsLabelingEngine::testShowAllLabelsWhenALabelHasNoCandidates() settings.obstacleSettings().setFactor( 10 ); settings.lineSettings().setOverrunDistance( 50 ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:23700&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:23700&field=l:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << QVariant() ); @@ -6682,7 +6681,7 @@ void TestQgsLabelingEngine::testShowAllLabelsWhenALabelHasNoCandidates() f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (-2439207 -5198806, -2331302 -5197802)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6714,12 +6713,12 @@ void TestQgsLabelingEngine::testShowAllLabelsWhenALabelHasNoCandidates() void TestQgsLabelingEngine::testSymbologyScalingFactor() { // test rendering labels with a layer with a reference scale set (with callout) - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( TEST_DATA_DIR ) + "/points.shp", QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( TEST_DATA_DIR ) + "/points.shp", QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( vl->isValid() ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl->setRenderer( new QgsSingleSymbolRenderer( marker ) ); @@ -6749,9 +6748,7 @@ void TestQgsLabelingEngine::testSymbologyScalingFactor() QgsBalloonCallout *callout = new QgsBalloonCallout(); callout->setEnabled( true ); - callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc"}, - { "outline-width", "1"} - } ) ) ); + callout->setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc" }, { "outline-width", "1" } } ) ) ); callout->setMargins( QgsMargins( 2, 2, 2, 2 ) ); settings.setCallout( callout ); @@ -6779,12 +6776,12 @@ void TestQgsLabelingEngine::testSymbologyScalingFactor() void TestQgsLabelingEngine::testSymbologyScalingFactor2() { // test rendering labels with a layer with a reference scale set (with label background) - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( TEST_DATA_DIR ) + "/points.shp", QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( TEST_DATA_DIR ) + "/points.shp", QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( vl->isValid() ); - QgsMarkerSymbol *marker = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + QgsMarkerSymbol *marker = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); marker->setColor( QColor( 255, 0, 0 ) ); marker->setSize( 3 ); - static_cast< QgsSimpleMarkerSymbolLayer * >( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); + static_cast( marker->symbolLayer( 0 ) )->setStrokeStyle( Qt::NoPen ); vl->setRenderer( new QgsSingleSymbolRenderer( marker ) ); @@ -6811,9 +6808,7 @@ void TestQgsLabelingEngine::testSymbologyScalingFactor2() format.buffer().setColor( QColor( 200, 255, 200 ) ); format.background().setEnabled( true ); - format.background().setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc"}, - { "outline-width", "1"} - } ) ) ); + format.background().setFillSymbol( QgsFillSymbol::createSimple( QVariantMap( { { "color", "#ffcccc" }, { "outline-width", "1" } } ) ) ); format.background().setSize( QSizeF( 2, 3 ) ); settings.setFormat( format ); @@ -6857,15 +6852,15 @@ void TestQgsLabelingEngine::testLineDirectionSymbolRight() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolLeftRight ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6911,15 +6906,15 @@ void TestQgsLabelingEngine::testLineDirectionSymbolLeft() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolLeftRight ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190200 5000000, 190000 5000010)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -6965,15 +6960,15 @@ void TestQgsLabelingEngine::testLineDirectionSymbolAbove() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolAbove ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context @@ -7019,15 +7014,15 @@ void TestQgsLabelingEngine::testLineDirectionSymbolBelow() settings.lineSettings().setAddDirectionSymbol( true ); settings.lineSettings().setDirectionSymbolPlacement( QgsLabelLineSettings::DirectionSymbolPlacement::SymbolBelow ); - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); - vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { {QStringLiteral( "color" ), QStringLiteral( "#000000" )}, {QStringLiteral( "outline_width" ), 0.6} } ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3946&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + vl2->setRenderer( new QgsSingleSymbolRenderer( QgsLineSymbol::createSimple( { { QStringLiteral( "color" ), QStringLiteral( "#000000" ) }, { QStringLiteral( "outline_width" ), 0.6 } } ) ) ); QgsFeature f; f.setAttributes( QgsAttributes() << 1 ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString (190000 5000010, 190200 5000000)" ) ) ); QVERIFY( vl2->dataProvider()->addFeature( f ) ); - vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl2->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! vl2->setLabelsEnabled( true ); // make a fake render context diff --git a/tests/src/core/testqgslayerdefinition.cpp b/tests/src/core/testqgslayerdefinition.cpp index 6377b8857b30..0f3f14593bf2 100644 --- a/tests/src/core/testqgslayerdefinition.cpp +++ b/tests/src/core/testqgslayerdefinition.cpp @@ -24,17 +24,17 @@ #include #include -class TestQgsLayerDefinition: public QObject +class TestQgsLayerDefinition : public QObject { Q_OBJECT public: TestQgsLayerDefinition() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. /** * test findLayers() @@ -61,7 +61,6 @@ void TestQgsLayerDefinition::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsLayerDefinition::cleanupTestCase() @@ -119,8 +118,5 @@ void TestQgsLayerDefinition::testExportDoesNotCrash() } - QGSTEST_MAIN( TestQgsLayerDefinition ) #include "testqgslayerdefinition.moc" - - diff --git a/tests/src/core/testqgslayeredsymbollevel.cpp b/tests/src/core/testqgslayeredsymbollevel.cpp index 5fdfa316aacc..42e0ddfb7405 100644 --- a/tests/src/core/testqgslayeredsymbollevel.cpp +++ b/tests/src/core/testqgslayeredsymbollevel.cpp @@ -44,11 +44,12 @@ class TestQgsLayeredSymbolLevel : public QgsTest { Q_OBJECT public: - TestQgsLayeredSymbolLevel() : QgsTest( QStringLiteral( "Layered Symbol Level Rendering Tests" ) ) {} + TestQgsLayeredSymbolLevel() + : QgsTest( QStringLiteral( "Layered Symbol Level Rendering Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void render(); @@ -76,15 +77,13 @@ void TestQgsLayeredSymbolLevel::initTestCase() // const QString myRoadsFileName = mTestDataDir + "layered_roads.shp"; const QFileInfo myRoadsFileInfo( myRoadsFileName ); - mpRoadsLayer = new QgsVectorLayer( myRoadsFileInfo.filePath(), - myRoadsFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpRoadsLayer = new QgsVectorLayer( myRoadsFileInfo.filePath(), myRoadsFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); mpRoadsLayer->setSimplifyMethod( simplifyMethod ); mMapSettings.setLayers( QList() << mpRoadsLayer ); - } void TestQgsLayeredSymbolLevel::cleanupTestCase() { diff --git a/tests/src/core/testqgslayertree.cpp b/tests/src/core/testqgslayertree.cpp index ef380b7b433a..48c4591f2389 100644 --- a/tests/src/core/testqgslayertree.cpp +++ b/tests/src/core/testqgslayertree.cpp @@ -73,7 +73,6 @@ class TestQgsLayerTree : public QObject void testInsertLayerBelow(); private: - QgsLayerTreeGroup *mRoot = nullptr; void testRendererLegend( QgsFeatureRenderer *renderer ); @@ -338,7 +337,7 @@ void TestQgsLayerTree::testRestrictedSymbolSize() QgsProject project; project.addMapLayer( vl ); - QgsMarkerSymbol *symbol = static_cast< QgsMarkerSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); + QgsMarkerSymbol *symbol = static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ); symbol->setSize( 500.0 ); symbol->setSizeUnit( Qgis::RenderUnit::MapUnits ); @@ -358,7 +357,7 @@ void TestQgsLayerTree::testRestrictedSymbolSize() m->setLegendMapViewData( 10, 96, 10 ); const QList nodes = m->layerLegendNodes( n ); - const QSize minimumSize = static_cast< QgsSymbolLegendNode *>( nodes.at( 0 ) )->minimumIconSize(); + const QSize minimumSize = static_cast( nodes.at( 0 ) )->minimumIconSize(); QCOMPARE( minimumSize.width(), expectedSize ); //cleanup @@ -422,7 +421,7 @@ void TestQgsLayerTree::testRestrictedSymbolSizeWithGeometryGenerator() m->setLegendMapViewData( 10, 96, 10 ); const QList nodes = m->layerLegendNodes( n ); - const QSize minimumSize = static_cast< QgsSymbolLegendNode *>( nodes.at( 0 ) )->minimumIconSize(); + const QSize minimumSize = static_cast( nodes.at( 0 ) )->minimumIconSize(); QCOMPARE( minimumSize.width(), expectedSize ); //cleanup @@ -463,13 +462,13 @@ void TestQgsLayerTree::testShowHideAllSymbolNodes() QVERIFY( ln->data( Qt::CheckStateRole ) == Qt::Checked ); } //uncheck all and test that all nodes are unchecked - static_cast< QgsSymbolLegendNode * >( nodes.at( 0 ) )->uncheckAllItems(); + static_cast( nodes.at( 0 ) )->uncheckAllItems(); for ( QgsLayerTreeModelLegendNode *ln : nodes ) { QVERIFY( ln->data( Qt::CheckStateRole ) == Qt::Unchecked ); } //check all and test that all nodes are checked - static_cast< QgsSymbolLegendNode * >( nodes.at( 0 ) )->checkAllItems(); + static_cast( nodes.at( 0 ) )->checkAllItems(); for ( QgsLayerTreeModelLegendNode *ln : nodes ) { QVERIFY( ln->data( Qt::CheckStateRole ) == Qt::Checked ); @@ -643,12 +642,12 @@ void TestQgsLayerTree::testRendererLegend( QgsFeatureRenderer *renderer ) QgsLegendSymbolList symbolList = renderer->legendSymbolItems(); for ( const QgsLegendSymbolItem &symbol : symbolList ) { - QgsSymbolLegendNode *symbolNode = dynamic_cast< QgsSymbolLegendNode * >( m->findLegendNode( vl->id(), symbol.ruleKey() ) ); + QgsSymbolLegendNode *symbolNode = dynamic_cast( m->findLegendNode( vl->id(), symbol.ruleKey() ) ); QVERIFY( symbolNode ); QCOMPARE( symbolNode->symbol()->color(), symbol.symbol()->color() ); } //try changing a symbol's color - QgsSymbolLegendNode *symbolNode = dynamic_cast< QgsSymbolLegendNode * >( m->findLegendNode( vl->id(), symbolList.at( 1 ).ruleKey() ) ); + QgsSymbolLegendNode *symbolNode = dynamic_cast( m->findLegendNode( vl->id(), symbolList.at( 1 ).ruleKey() ) ); QVERIFY( symbolNode ); QgsSymbol *newSymbol = symbolNode->symbol()->clone(); newSymbol->setColor( QColor( 255, 255, 0 ) ); @@ -664,7 +663,7 @@ void TestQgsLayerTree::testRendererLegend( QgsFeatureRenderer *renderer ) props.insert( QStringLiteral( "outline_color" ), QStringLiteral( "#000000" ) ); renderer->setLegendSymbolItem( symbolList.at( 2 ).ruleKey(), QgsMarkerSymbol::createSimple( props ) ); m->refreshLayerLegend( n ); - symbolNode = dynamic_cast< QgsSymbolLegendNode * >( m->findLegendNode( vl->id(), symbolList.at( 2 ).ruleKey() ) ); + symbolNode = dynamic_cast( m->findLegendNode( vl->id(), symbolList.at( 2 ).ruleKey() ) ); QVERIFY( symbolNode ); QCOMPARE( symbolNode->symbol()->color(), QColor( 0, 255, 255 ) ); @@ -918,10 +917,7 @@ void TestQgsLayerTree::testSymbolText() scope->setVariable( QStringLiteral( "bbbb" ), QStringLiteral( "aaaa,bbbb,cccc" ) ); context.appendScope( scope ); nodes.at( 2 )->setUserLabel( QStringLiteral( "[% @bbbb %],[% 3+4 %]" ) ); - QCOMPARE( settings.evaluateItemText( nodes.at( 2 )->data( Qt::DisplayRole ).toString(), context ), QStringList() << QStringLiteral( "aaaa" ) - << QStringLiteral( "bbbb" ) - << QStringLiteral( "cccc" ) - << QStringLiteral( "7" ) ); + QCOMPARE( settings.evaluateItemText( nodes.at( 2 )->data( Qt::DisplayRole ).toString(), context ), QStringList() << QStringLiteral( "aaaa" ) << QStringLiteral( "bbbb" ) << QStringLiteral( "cccc" ) << QStringLiteral( "7" ) ); //cleanup delete m; delete root; @@ -967,27 +963,27 @@ void TestQgsLayerTree::testRasterSymbolNode() QgsLayerTreeNode *secondGroup = mRoot->children()[1]; QCOMPARE( secondGroup->depth(), 1 ); - std::unique_ptr< QgsRasterLayer > rl = std::make_unique< QgsRasterLayer >( QStringLiteral( TEST_DATA_DIR ) + "/tenbytenraster.asc", QStringLiteral( "rl" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rl = std::make_unique( QStringLiteral( TEST_DATA_DIR ) + "/tenbytenraster.asc", QStringLiteral( "rl" ), QStringLiteral( "gdal" ) ); QVERIFY( rl->isValid() ); - const std::unique_ptr< QgsLayerTreeLayer > n = std::make_unique< QgsLayerTreeLayer >( rl.get() ); + const std::unique_ptr n = std::make_unique( rl.get() ); // not checkable QgsRasterSymbolLegendNode rasterNode( n.get(), QColor( 255, 0, 0 ), QStringLiteral( "my node" ), nullptr, false, QStringLiteral( "key" ), QStringLiteral( "parentKey" ) ); QVERIFY( !rasterNode.isCheckable() ); QCOMPARE( rasterNode.ruleKey(), QStringLiteral( "key" ) ); - QCOMPARE( static_cast< int >( rasterNode.flags() ), static_cast< int >( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) ); + QCOMPARE( static_cast( rasterNode.flags() ), static_cast( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) ); QCOMPARE( rasterNode.data( Qt::DisplayRole ).toString(), QStringLiteral( "my node" ) ); - QCOMPARE( rasterNode.data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::NodeType ) ).toInt(), static_cast< int >( QgsLayerTreeModelLegendNode::RasterSymbolLegend ) ); - QCOMPARE( rasterNode.data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(), QStringLiteral( "key" ) ); - QCOMPARE( rasterNode.data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::ParentRuleKey ) ).toString(), QStringLiteral( "parentKey" ) ); + QCOMPARE( rasterNode.data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::NodeType ) ).toInt(), static_cast( QgsLayerTreeModelLegendNode::RasterSymbolLegend ) ); + QCOMPARE( rasterNode.data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(), QStringLiteral( "key" ) ); + QCOMPARE( rasterNode.data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::ParentRuleKey ) ).toString(), QStringLiteral( "parentKey" ) ); QCOMPARE( rasterNode.data( Qt::CheckStateRole ), QVariant() ); QVERIFY( !rasterNode.setData( true, Qt::CheckStateRole ) ); // checkable const QgsRasterSymbolLegendNode rasterNode2( n.get(), QColor( 255, 0, 0 ), QStringLiteral( "my node" ), nullptr, true, QStringLiteral( "key" ), QStringLiteral( "parentKey" ) ); QVERIFY( rasterNode2.isCheckable() ); - QCOMPARE( static_cast< int >( rasterNode2.flags() ), static_cast< int >( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ) ); + QCOMPARE( static_cast( rasterNode2.flags() ), static_cast( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ) ); } void TestQgsLayerTree::testLayersEditable() @@ -1008,20 +1004,20 @@ void TestQgsLayerTree::testLayersEditable() QgsLayerTreeLayer *nodeVl2 = nodeGrp->addLayer( vl2 ); QgsLayerTreeLayer *nodeAl = nodeGrp->addLayer( al ); QVERIFY( !QgsLayerTreeUtils::layersEditable( {} ) ); - QVERIFY( !QgsLayerTreeUtils::layersEditable( {nodeVl1, nodeVl2} ) ); + QVERIFY( !QgsLayerTreeUtils::layersEditable( { nodeVl1, nodeVl2 } ) ); vl1->startEditing(); - QVERIFY( QgsLayerTreeUtils::layersEditable( {nodeVl1} ) ); - QVERIFY( QgsLayerTreeUtils::layersEditable( {nodeVl1, nodeVl2} ) ); - QVERIFY( QgsLayerTreeUtils::layersEditable( {nodeVl2, nodeVl1 } ) ); + QVERIFY( QgsLayerTreeUtils::layersEditable( { nodeVl1 } ) ); + QVERIFY( QgsLayerTreeUtils::layersEditable( { nodeVl1, nodeVl2 } ) ); + QVERIFY( QgsLayerTreeUtils::layersEditable( { nodeVl2, nodeVl1 } ) ); - QVERIFY( QgsLayerTreeUtils::layersEditable( {nodeAl} ) ); - QVERIFY( QgsLayerTreeUtils::layersEditable( {nodeAl, nodeVl1} ) ); - QVERIFY( QgsLayerTreeUtils::layersEditable( {nodeAl, nodeVl2} ) ); + QVERIFY( QgsLayerTreeUtils::layersEditable( { nodeAl } ) ); + QVERIFY( QgsLayerTreeUtils::layersEditable( { nodeAl, nodeVl1 } ) ); + QVERIFY( QgsLayerTreeUtils::layersEditable( { nodeAl, nodeVl2 } ) ); // ignore layers which can't be toggled (the annotation layer) - QVERIFY( !QgsLayerTreeUtils::layersEditable( {nodeAl}, true ) ); - QVERIFY( QgsLayerTreeUtils::layersEditable( {nodeAl, nodeVl1}, true ) ); - QVERIFY( !QgsLayerTreeUtils::layersEditable( {nodeAl, nodeVl2}, true ) ); + QVERIFY( !QgsLayerTreeUtils::layersEditable( { nodeAl }, true ) ); + QVERIFY( QgsLayerTreeUtils::layersEditable( { nodeAl, nodeVl1 }, true ) ); + QVERIFY( !QgsLayerTreeUtils::layersEditable( { nodeAl, nodeVl2 }, true ) ); } void TestQgsLayerTree::testInsertLayerBelow() diff --git a/tests/src/core/testqgslayout.cpp b/tests/src/core/testqgslayout.cpp index 3ef46f8c09ab..197d40674391 100644 --- a/tests/src/core/testqgslayout.cpp +++ b/tests/src/core/testqgslayout.cpp @@ -38,16 +38,17 @@ #include "qgslayoutexporter.h" #include -class TestQgsLayout: public QgsTest +class TestQgsLayout : public QgsTest { Q_OBJECT public: - TestQgsLayout() : QgsTest( QStringLiteral( "Layout Tests" ) ) {} + TestQgsLayout() + : QgsTest( QStringLiteral( "Layout Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void creation(); //test creation of QgsLayout + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void creation(); //test creation of QgsLayout void units(); void name(); void customProperties(); @@ -76,7 +77,6 @@ class TestQgsLayout: public QgsTest void mapLayersStyleOverrideRestoredFromTemplate(); void atlasLayerRestoredFromTemplate(); void overviewStackingLayerRestoredFromTemplate(); - }; void TestQgsLayout::initTestCase() @@ -185,9 +185,7 @@ void TestQgsLayout::customProperties() QVERIFY( keys.contains( "testprop2" ) ); // list value - layout.setCustomProperty( QStringLiteral( "a_list" ), QStringList{ QStringLiteral( "value 1" ), - QStringLiteral( "value 2" ), - QStringLiteral( "value 3" )} ); + layout.setCustomProperty( QStringLiteral( "a_list" ), QStringList { QStringLiteral( "value 1" ), QStringLiteral( "value 2" ), QStringLiteral( "value 3" ) } ); const QStringList res = layout.customProperty( QStringLiteral( "a_list" ) ).toStringList(); QCOMPARE( res, QStringList() << "value 1" << "value 2" << "value 3" ); } @@ -198,15 +196,13 @@ void TestQgsLayout::writeRetrieveCustomProperties() layout.setCustomProperty( QStringLiteral( "testprop" ), "testval" ); layout.setCustomProperty( QStringLiteral( "testprop2" ), 5 ); // list value - layout.setCustomProperty( QStringLiteral( "a_list" ), QStringList{ QStringLiteral( "value 1" ), - QStringLiteral( "value 2" ), - QStringLiteral( "value 3" )} ); + layout.setCustomProperty( QStringLiteral( "a_list" ), QStringList { QStringLiteral( "value 1" ), QStringLiteral( "value 2" ), QStringLiteral( "value 3" ) } ); //test writing composition with custom properties QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); const QDomElement layoutNode = layout.writeXml( doc, QgsReadWriteContext() ); QVERIFY( !layoutNode.isNull() ); @@ -245,7 +241,7 @@ void TestQgsLayout::scope() QgsPrintLayout l( &p ); // no crash - std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::layoutScope( nullptr ) ); + std::unique_ptr scope( QgsExpressionContextUtils::layoutScope( nullptr ) ); l.setName( QStringLiteral( "test" ) ); scope.reset( QgsExpressionContextUtils::layoutScope( &l ) ); QCOMPARE( scope->variable( "layout_name" ).toString(), QStringLiteral( "test" ) ); @@ -272,7 +268,6 @@ void TestQgsLayout::scope() QCOMPARE( c.variable( "project_title" ).toString(), QStringLiteral( "my title" ) ); // and layout variables QCOMPARE( c.variable( "new_var3" ).toInt(), 17 ); - } void TestQgsLayout::referenceMap() @@ -379,7 +374,7 @@ void TestQgsLayout::addItem() const QSignalSpy itemAddedSpy( &l, &QgsLayout::itemAdded ); l.addLayoutItem( shape1 ); QCOMPARE( itemAddedSpy.count(), 1 ); - QCOMPARE( itemAddedSpy.at( 0 ).at( 0 ).value< QgsLayoutItem * >(), shape1 ); + QCOMPARE( itemAddedSpy.at( 0 ).at( 0 ).value(), shape1 ); QVERIFY( l.items().contains( shape1 ) ); // bounds should be updated to include item QGSCOMPARENEAR( l.sceneRect().left(), 89.850, 0.001 ); @@ -422,20 +417,20 @@ void TestQgsLayout::layoutItems() QgsLayoutItemMap *map1 = new QgsLayoutItemMap( &l ); l.addLayoutItem( map1 ); - QList< QgsLayoutItem * > items; + QList items; l.layoutItems( items ); QCOMPARE( items.count(), 3 ); QVERIFY( items.contains( shape1 ) ); QVERIFY( items.contains( shape2 ) ); QVERIFY( items.contains( map1 ) ); - QList< QgsLayoutItemShape * > shapes; + QList shapes; l.layoutItems( shapes ); QCOMPARE( shapes.count(), 2 ); QVERIFY( shapes.contains( shape1 ) ); QVERIFY( shapes.contains( shape2 ) ); - QList< QgsLayoutItemMap * > maps; + QList maps; l.layoutItems( maps ); QCOMPARE( maps.count(), 1 ); QVERIFY( maps.contains( map1 ) ); @@ -506,13 +501,13 @@ void TestQgsLayout::undoRedoOccurred() l.undoStack()->stack()->undo(); QCOMPARE( spyOccurred.count(), 1 ); - QSet< QString > items = qvariant_cast< QSet< QString > >( spyOccurred.at( 0 ).at( 0 ) ); - QCOMPARE( items, QSet< QString >() << item2->uuid() ); + QSet items = qvariant_cast>( spyOccurred.at( 0 ).at( 0 ) ); + QCOMPARE( items, QSet() << item2->uuid() ); l.undoStack()->stack()->redo(); QCOMPARE( spyOccurred.count(), 2 ); - items = qvariant_cast< QSet< QString> >( spyOccurred.at( 1 ).at( 0 ) ); - QCOMPARE( items, QSet< QString >() << item2->uuid() ); + items = qvariant_cast>( spyOccurred.at( 1 ).at( 0 ) ); + QCOMPARE( items, QSet() << item2->uuid() ); // macro undo l.undoStack()->beginMacro( QString() ); @@ -523,12 +518,12 @@ void TestQgsLayout::undoRedoOccurred() l.undoStack()->stack()->undo(); QCOMPARE( spyOccurred.count(), 3 ); - items = qvariant_cast< QSet< QString > >( spyOccurred.at( 2 ).at( 0 ) ); - QCOMPARE( items, QSet< QString >() << item->uuid() << item2->uuid() ); + items = qvariant_cast>( spyOccurred.at( 2 ).at( 0 ) ); + QCOMPARE( items, QSet() << item->uuid() << item2->uuid() ); l.undoStack()->stack()->redo(); QCOMPARE( spyOccurred.count(), 4 ); - items = qvariant_cast< QSet< QString > >( spyOccurred.at( 3 ).at( 0 ) ); - QCOMPARE( items, QSet< QString >() << item->uuid() << item2->uuid() ); + items = qvariant_cast>( spyOccurred.at( 3 ).at( 0 ) ); + QCOMPARE( items, QSet() << item->uuid() << item2->uuid() ); // blocking undo const int before = l.undoStack()->stack()->count(); @@ -538,23 +533,23 @@ void TestQgsLayout::undoRedoOccurred() QVERIFY( l.undoStack()->isBlocked() ); item->setId( "yyy" ); QCOMPARE( l.undoStack()->stack()->count(), before + 1 ); // no new command - l.undoStack()->blockCommands( true ); // second stacked command + l.undoStack()->blockCommands( true ); // second stacked command QVERIFY( l.undoStack()->isBlocked() ); item->setId( "ZZZ" ); QCOMPARE( l.undoStack()->stack()->count(), before + 1 ); // no new command - l.undoStack()->blockCommands( false ); // one stacked command left + l.undoStack()->blockCommands( false ); // one stacked command left QVERIFY( l.undoStack()->isBlocked() ); item->setId( "sss" ); QCOMPARE( l.undoStack()->stack()->count(), before + 1 ); // no new command - l.undoStack()->blockCommands( false ); // unblocked + l.undoStack()->blockCommands( false ); // unblocked QVERIFY( !l.undoStack()->isBlocked() ); item->setId( "ttt" ); QCOMPARE( l.undoStack()->stack()->count(), before + 2 ); // new command - l.undoStack()->blockCommands( false ); // don't allow negative stack size + l.undoStack()->blockCommands( false ); // don't allow negative stack size QVERIFY( !l.undoStack()->isBlocked() ); item->setId( "uuu" ); QCOMPARE( l.undoStack()->stack()->count(), before + 3 ); // new command - l.undoStack()->blockCommands( true ); // should be blocked again + l.undoStack()->blockCommands( true ); // should be blocked again QVERIFY( l.undoStack()->isBlocked() ); item->setId( "vvv" ); QCOMPARE( l.undoStack()->stack()->count(), before + 3 ); // no new command @@ -802,13 +797,13 @@ void TestQgsLayout::clear() //add some items to the composition QgsLayoutItemShape *label1 = new QgsLayoutItemShape( &l ); l.addLayoutItem( label1 ); - const QPointer< QgsLayoutItem > item1P = label1; + const QPointer item1P = label1; QgsLayoutItemShape *label2 = new QgsLayoutItemShape( &l ); l.addLayoutItem( label2 ); - const QPointer< QgsLayoutItem > item2P = label2; + const QPointer item2P = label2; QgsLayoutItemShape *label3 = new QgsLayoutItemShape( &l ); l.addLayoutItem( label3 ); - const QPointer< QgsLayoutItem > item3P = label3; + const QPointer item3P = label3; l.clear(); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); @@ -816,7 +811,7 @@ void TestQgsLayout::clear() QVERIFY( !item1P ); QVERIFY( !item2P ); QVERIFY( !item3P ); - QList< QgsLayoutItem * > items; + QList items; l.layoutItems( items ); QVERIFY( items.empty() ); QCOMPARE( l.undoStack()->stack()->count(), 0 ); @@ -831,7 +826,7 @@ void TestQgsLayout::georeference() const QgsLayoutExporter exporter( &l ); // no map - std::unique_ptr< double [] > t = exporter.computeGeoTransform( nullptr ); + std::unique_ptr t = exporter.computeGeoTransform( nullptr ); QVERIFY( !t ); QgsLayoutItemMap *map = new QgsLayoutItemMap( &l ); @@ -914,17 +909,17 @@ void TestQgsLayout::clone() l.addLayoutItem( label3 ); // clone and check a few properties - std::unique_ptr< QgsLayout > cloned( l.clone() ); + std::unique_ptr cloned( l.clone() ); QVERIFY( cloned.get() ); QCOMPARE( cloned->pageCollection()->pageCount(), 3 ); - QList< QgsLayoutItem * > items; + QList items; cloned->layoutItems( items ); QCOMPARE( items.count(), 6 ); // 3 pages + 3 items // clone a print layout QgsPrintLayout pl( &proj ); pl.atlas()->setPageNameExpression( QStringLiteral( "not a real expression" ) ); - std::unique_ptr< QgsPrintLayout > plClone( pl.clone() ); + std::unique_ptr plClone( pl.clone() ); QVERIFY( plClone.get() ); QCOMPARE( plClone->atlas()->pageNameExpression(), QStringLiteral( "not a real expression" ) ); } @@ -935,9 +930,7 @@ void TestQgsLayout::legendRestoredFromTemplate() // load a layer const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsProject p; p.addMapLayer( layer ); @@ -952,7 +945,7 @@ void TestQgsLayout::legendRestoredFromTemplate() QgsLegendModel *model = legend->model(); QgsLayerTreeNode *node = model->rootGroup()->children().at( 0 ); // make sure we've got right node - QgsLayerTreeLayer *layerNode = dynamic_cast< QgsLayerTreeLayer * >( node ); + QgsLayerTreeLayer *layerNode = dynamic_cast( node ); QVERIFY( layerNode ); QCOMPARE( layerNode->layer(), layer ); @@ -969,14 +962,14 @@ void TestQgsLayout::legendRestoredFromTemplate() QgsLayout c2( &p ); c2.loadFromTemplate( doc, QgsReadWriteContext() ); // get legend from new composition - QList< QgsLayoutItemLegend * > legends2; + QList legends2; c2.layoutItems( legends2 ); QgsLayoutItemLegend *legend2 = legends2.at( 0 ); QVERIFY( legend2 ); QgsLegendModel *model2 = legend2->model(); QgsLayerTreeNode *node2 = model2->rootGroup()->children().at( 0 ); - QgsLayerTreeLayer *layerNode2 = dynamic_cast< QgsLayerTreeLayer * >( node2 ); + QgsLayerTreeLayer *layerNode2 = dynamic_cast( node2 ); QVERIFY( layerNode2 ); QCOMPARE( layerNode2->layer(), layer ); QCOMPARE( model2->data( model->node2index( layerNode2 ), Qt::DisplayRole ).toString(), QString( "new title!" ) ); @@ -987,9 +980,7 @@ void TestQgsLayout::legendRestoredFromTemplate() p.removeMapLayer( layer ); // reload it, with a new id - QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); p.addMapLayer( layer2 ); QVERIFY( oldId != layer2->id() ); @@ -997,7 +988,7 @@ void TestQgsLayout::legendRestoredFromTemplate() QgsLayout c3( &p ); c3.loadFromTemplate( doc, QgsReadWriteContext() ); // get legend from new composition - QList< QgsLayoutItemLegend * > legends3; + QList legends3; c3.layoutItems( legends3 ); QgsLayoutItemLegend *legend3 = legends3.at( 0 ); QVERIFY( legend3 ); @@ -1005,7 +996,7 @@ void TestQgsLayout::legendRestoredFromTemplate() //make sure customization remains intact QgsLegendModel *model3 = legend3->model(); QgsLayerTreeNode *node3 = model3->rootGroup()->children().at( 0 ); - QgsLayerTreeLayer *layerNode3 = dynamic_cast< QgsLayerTreeLayer * >( node3 ); + QgsLayerTreeLayer *layerNode3 = dynamic_cast( node3 ); QVERIFY( layerNode3 ); QCOMPARE( layerNode3->layer(), layer2 ); QCOMPARE( model3->data( model->node2index( layerNode3 ), Qt::DisplayRole ).toString(), QString( "new title!" ) ); @@ -1016,9 +1007,7 @@ void TestQgsLayout::legendRestoredFromTemplateAutoUpdate() // load a layer const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer ); @@ -1032,7 +1021,7 @@ void TestQgsLayout::legendRestoredFromTemplateAutoUpdate() QgsLegendModel *model = legend->model(); QgsLayerTreeNode *node = model->rootGroup()->children().at( 0 ); // make sure we've got right node - QgsLayerTreeLayer *layerNode = dynamic_cast< QgsLayerTreeLayer * >( node ); + QgsLayerTreeLayer *layerNode = dynamic_cast( node ); QVERIFY( layerNode ); QCOMPARE( layerNode->layer(), layer ); QCOMPARE( model->data( model->node2index( layerNode ), Qt::DisplayRole ).toString(), QString( "points" ) ); @@ -1042,9 +1031,7 @@ void TestQgsLayout::legendRestoredFromTemplateAutoUpdate() doc.appendChild( c.writeXml( doc, QgsReadWriteContext() ) ); //new project - QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject p2; p2.addMapLayer( layer2 ); @@ -1052,14 +1039,14 @@ void TestQgsLayout::legendRestoredFromTemplateAutoUpdate() QgsLayout c2( &p2 ); c2.loadFromTemplate( doc, QgsReadWriteContext() ); // get legend from new composition - QList< QgsLayoutItemLegend * > legends2; + QList legends2; c2.layoutItems( legends2 ); QgsLayoutItemLegend *legend2 = legends2.at( 0 ); QVERIFY( legend2 ); QgsLegendModel *model2 = legend2->model(); QgsLayerTreeNode *node2 = model2->rootGroup()->children().at( 0 ); - QgsLayerTreeLayer *layerNode2 = dynamic_cast< QgsLayerTreeLayer * >( node2 ); + QgsLayerTreeLayer *layerNode2 = dynamic_cast( node2 ); QVERIFY( layerNode2 ); QCOMPARE( layerNode2->layer(), layer2 ); QCOMPARE( model2->data( model->node2index( layerNode2 ), Qt::DisplayRole ).toString(), QString( "points" ) ); @@ -1069,9 +1056,7 @@ void TestQgsLayout::attributeTableRestoredFromTemplate() { // load some layers const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorLayer *layer2 = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "memory" ), QStringLiteral( "memory" ) ); QgsProject p; p.addMapLayer( layer2 ); @@ -1094,9 +1079,7 @@ void TestQgsLayout::attributeTableRestoredFromTemplate() // new project QgsProject p2; - QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorLayer *layer4 = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "memory" ), QStringLiteral( "memory" ) ); p2.addMapLayer( layer4 ); p2.addMapLayer( layer3 ); @@ -1105,9 +1088,9 @@ void TestQgsLayout::attributeTableRestoredFromTemplate() QgsLayout c2( &p2 ); c2.loadFromTemplate( doc, QgsReadWriteContext() ); // get table from new composition - QList< QgsLayoutFrame * > frames2; + QList frames2; c2.layoutItems( frames2 ); - QgsLayoutItemAttributeTable *table2 = static_cast< QgsLayoutItemAttributeTable *>( frames2.at( 0 )->multiFrame() ); + QgsLayoutItemAttributeTable *table2 = static_cast( frames2.at( 0 )->multiFrame() ); QVERIFY( table2 ); QCOMPARE( table2->vectorLayer(), layer3 ); @@ -1117,16 +1100,11 @@ void TestQgsLayout::mapLayersRestoredFromTemplate() { // load some layers const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); const QFileInfo vectorFileInfo2( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ); - QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo2.filePath(), - vectorFileInfo2.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), QStringLiteral( "ogr" ) ); const QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); - QgsRasterLayer *rl = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + QgsRasterLayer *rl = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsProject p; p.addMapLayer( layer2 ); @@ -1147,14 +1125,9 @@ void TestQgsLayout::mapLayersRestoredFromTemplate() // new project QgsProject p2; - QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); - QgsVectorLayer *layer4 = new QgsVectorLayer( vectorFileInfo2.filePath(), - vectorFileInfo2.completeBaseName(), - QStringLiteral( "ogr" ) ); - QgsRasterLayer *rl5 = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer4 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsRasterLayer *rl5 = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); p2.addMapLayer( layer4 ); p2.addMapLayer( layer3 ); p2.addMapLayer( rl5 ); @@ -1163,9 +1136,9 @@ void TestQgsLayout::mapLayersRestoredFromTemplate() QgsLayout c2( &p2 ); c2.loadFromTemplate( doc, QgsReadWriteContext() ); // get map from new composition - QList< QgsLayoutItemMap * > maps; + QList maps; c2.layoutItems( maps ); - QgsLayoutItemMap *map2 = static_cast< QgsLayoutItemMap *>( maps.at( 0 ) ); + QgsLayoutItemMap *map2 = static_cast( maps.at( 0 ) ); QVERIFY( map2 ); QCOMPARE( map2->layers(), QList() << layer3 << layer4 << rl5 ); @@ -1175,13 +1148,9 @@ void TestQgsLayout::mapLayersStyleOverrideRestoredFromTemplate() { // load some layers const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); const QFileInfo vectorFileInfo2( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ); - QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo2.filePath(), - vectorFileInfo2.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer2 ); p.addMapLayer( layer ); @@ -1205,12 +1174,8 @@ void TestQgsLayout::mapLayersStyleOverrideRestoredFromTemplate() // new project QgsProject p2; - QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); - QgsVectorLayer *layer4 = new QgsVectorLayer( vectorFileInfo2.filePath(), - vectorFileInfo2.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer3 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer4 = new QgsVectorLayer( vectorFileInfo2.filePath(), vectorFileInfo2.completeBaseName(), QStringLiteral( "ogr" ) ); p2.addMapLayer( layer4 ); p2.addMapLayer( layer3 ); @@ -1218,9 +1183,9 @@ void TestQgsLayout::mapLayersStyleOverrideRestoredFromTemplate() QgsLayout c2( &p2 ); c2.loadFromTemplate( doc, QgsReadWriteContext() ); // get map from new composition - QList< QgsLayoutItemMap * > maps; + QList maps; c2.layoutItems( maps ); - QgsLayoutItemMap *map2 = static_cast< QgsLayoutItemMap *>( maps.at( 0 ) ); + QgsLayoutItemMap *map2 = static_cast( maps.at( 0 ) ); QVERIFY( map2 ); QVERIFY( map2->keepLayerStyles() ); @@ -1235,9 +1200,7 @@ void TestQgsLayout::atlasLayerRestoredFromTemplate() { // load some layers const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer ); @@ -1253,9 +1216,7 @@ void TestQgsLayout::atlasLayerRestoredFromTemplate() // new project QgsProject p2; - QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); p2.addMapLayer( layer2 ); // make a new composition from template @@ -1269,9 +1230,7 @@ void TestQgsLayout::overviewStackingLayerRestoredFromTemplate() { // load some layers const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject p; p.addMapLayer( layer ); @@ -1287,16 +1246,14 @@ void TestQgsLayout::overviewStackingLayerRestoredFromTemplate() // new project QgsProject p2; - QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); p2.addMapLayer( layer2 ); // make a new layout from template QgsPrintLayout c2( &p2 ); c2.loadFromTemplate( doc, QgsReadWriteContext() ); // get legend from new composition - QList< QgsLayoutItemMap * > maps2; + QList maps2; c2.layoutItems( maps2 ); QgsLayoutItemMap *map2 = maps2.at( 0 ); QVERIFY( map2 ); diff --git a/tests/src/core/testqgslayoutatlas.cpp b/tests/src/core/testqgslayoutatlas.cpp index 6d33e8ce80dc..9a5a87eeaa1a 100644 --- a/tests/src/core/testqgslayoutatlas.cpp +++ b/tests/src/core/testqgslayoutatlas.cpp @@ -88,12 +88,8 @@ void TestQgsLayoutAtlas::initTestCase() //create maplayers from testdata and add to layer registry const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/france_parts.shp" ); - mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); - mVectorLayer2 = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mVectorLayer2 = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -194,7 +190,7 @@ void TestQgsLayoutAtlas::filename() for ( int fi = 0; fi < mAtlas->count(); ++fi ) { mAtlas->seekTo( fi ); - const QString expected = QStringLiteral( "output_%1" ).arg( ( int )( fi + 1 ) ); + const QString expected = QStringLiteral( "output_%1" ).arg( ( int ) ( fi + 1 ) ); QCOMPARE( mAtlas->currentFilename(), expected ); } mAtlas->endRender(); @@ -215,7 +211,7 @@ void TestQgsLayoutAtlas::autoscale_render() mAtlas->seekTo( fit ); mLabel1->adjustSizeToText(); - QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_autoscale%1" ).arg( ( ( int )fit ) + 1 ), mLayout, 0, 100 ); + QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_autoscale%1" ).arg( ( ( int ) fit ) + 1 ), mLayout, 0, 100 ); } mAtlas->endRender(); } @@ -235,7 +231,7 @@ void TestQgsLayoutAtlas::fixedscale_render() mAtlas->seekTo( fit ); mLabel1->adjustSizeToText(); - QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_fixedscale%1" ).arg( ( ( int )fit ) + 1 ), mLayout, 0, 100 ); + QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_fixedscale%1" ).arg( ( ( int ) fit ) + 1 ), mLayout, 0, 100 ); } mAtlas->endRender(); } @@ -267,7 +263,7 @@ void TestQgsLayoutAtlas::predefinedscales_render() mAtlas->seekTo( fit ); mLabel1->adjustSizeToText(); - QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_predefinedscales%1" ).arg( ( ( int )fit ) + 1 ), mLayout, 0, 100 ); + QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_predefinedscales%1" ).arg( ( ( int ) fit ) + 1 ), mLayout, 0, 100 ); } mAtlas->endRender(); } @@ -289,7 +285,7 @@ void TestQgsLayoutAtlas::two_map_autoscale_render() mAtlas->seekTo( fit ); mLabel1->adjustSizeToText(); - QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_two_maps%1" ).arg( ( ( int )fit ) + 1 ), mLayout, 0, 100 ); + QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_two_maps%1" ).arg( ( ( int ) fit ) + 1 ), mLayout, 0, 100 ); } mAtlas->endRender(); } @@ -308,7 +304,7 @@ void TestQgsLayoutAtlas::hiding_render() mAtlas->seekTo( fit ); mLabel1->adjustSizeToText(); - QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_hiding%1" ).arg( ( ( int )fit ) + 1 ), mLayout, 0, 100 ); + QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_hiding%1" ).arg( ( ( int ) fit ) + 1 ), mLayout, 0, 100 ); } mAtlas->endRender(); } @@ -331,7 +327,7 @@ void TestQgsLayoutAtlas::sorting_render() mAtlas->seekTo( fit ); mLabel1->adjustSizeToText(); - QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_sorting%1" ).arg( ( ( int )fit ) + 1 ), mLayout, 0, 100 ); + QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_sorting%1" ).arg( ( ( int ) fit ) + 1 ), mLayout, 0, 100 ); } mAtlas->endRender(); } @@ -356,7 +352,7 @@ void TestQgsLayoutAtlas::filtering_render() mAtlas->seekTo( fit ); mLabel1->adjustSizeToText(); - QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_filtering%1" ).arg( ( ( int )fit ) + 1 ), mLayout, 0, 100 ); + QGSVERIFYLAYOUTCHECK( QStringLiteral( "atlas_filtering%1" ).arg( ( ( int ) fit ) + 1 ), mLayout, 0, 100 ); } mAtlas->endRender(); } @@ -407,7 +403,7 @@ void TestQgsLayoutAtlas::test_remove_layer() void TestQgsLayoutAtlas::context() { - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer&field=labelx:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QgsFeature f; QVERIFY( vl2->dataProvider()->addFeature( f ) ); QgsFeature f2; diff --git a/tests/src/core/testqgslayoutcontext.cpp b/tests/src/core/testqgslayoutcontext.cpp index 9a8015fa94bd..935058511b03 100644 --- a/tests/src/core/testqgslayoutcontext.cpp +++ b/tests/src/core/testqgslayoutcontext.cpp @@ -28,18 +28,19 @@ #include "qgstest.h" #include -class TestQgsLayoutContext: public QgsTest +class TestQgsLayoutContext : public QgsTest { Q_OBJECT public: - TestQgsLayoutContext() : QgsTest( QStringLiteral( "Layout Context Tests" ) ) {} + TestQgsLayoutContext() + : QgsTest( QStringLiteral( "Layout Context Tests" ) ) {} private slots: void cleanupTestCase(); void creation(); //test creation of QgsLayout - void flags(); //test QgsLayout flags + void flags(); //test QgsLayout flags void feature(); void layer(); void dpi(); @@ -50,7 +51,6 @@ class TestQgsLayoutContext: public QgsTest void scales(); void simplifyMethod(); void maskRenderSettings(); - }; void TestQgsLayoutContext::cleanupTestCase() @@ -78,13 +78,13 @@ void TestQgsLayoutContext::flags() QVERIFY( context.flags() == ( QgsLayoutRenderContext::FlagAntialiasing | QgsLayoutRenderContext::FlagUseAdvancedEffects ) ); QVERIFY( context.testFlag( QgsLayoutRenderContext::FlagAntialiasing ) ); QVERIFY( context.testFlag( QgsLayoutRenderContext::FlagUseAdvancedEffects ) ); - QVERIFY( ! context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); + QVERIFY( !context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); context.setFlag( QgsLayoutRenderContext::FlagDebug ); QCOMPARE( spyFlagsChanged.count(), 1 ); QVERIFY( context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); context.setFlag( QgsLayoutRenderContext::FlagDebug, false ); QCOMPARE( spyFlagsChanged.count(), 2 ); - QVERIFY( ! context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); + QVERIFY( !context.testFlag( QgsLayoutRenderContext::FlagDebug ) ); context.setFlag( QgsLayoutRenderContext::FlagDebug, false ); //no change QCOMPARE( spyFlagsChanged.count(), 2 ); context.setFlags( QgsLayoutRenderContext::FlagDebug ); @@ -127,7 +127,7 @@ void TestQgsLayoutContext::layer() QgsLayout l( QgsProject::instance() ); l.reportContext().setLayer( layer ); //test that expression context created for layout contains report context layer scope - const QgsExpressionContext expContext = l.createExpressionContext(); + const QgsExpressionContext expContext = l.createExpressionContext(); Q_NOWARN_DEPRECATED_PUSH QCOMPARE( QgsExpressionUtils::getVectorLayer( expContext.variable( "layer" ), &expContext, nullptr ), layer ); Q_NOWARN_DEPRECATED_POP @@ -233,7 +233,7 @@ void TestQgsLayoutContext::geometry() void TestQgsLayoutContext::scales() { - QVector< qreal > scales; + QVector scales; scales << 1 << 15 << 5 << 10; QgsLayoutRenderContext context( nullptr ); @@ -243,7 +243,7 @@ void TestQgsLayoutContext::scales() QCOMPARE( spyScalesChanged.count(), 1 ); // should be sorted - QCOMPARE( context.predefinedScales(), QVector< qreal >() << 1 << 5 << 10 << 15 ); + QCOMPARE( context.predefinedScales(), QVector() << 1 << 5 << 10 << 15 ); context.setPredefinedScales( context.predefinedScales() ); QCOMPARE( spyScalesChanged.count(), 1 ); diff --git a/tests/src/core/testqgslayoutexporter.cpp b/tests/src/core/testqgslayoutexporter.cpp index 831abf7af200..046d1c2779a5 100644 --- a/tests/src/core/testqgslayoutexporter.cpp +++ b/tests/src/core/testqgslayoutexporter.cpp @@ -26,7 +26,7 @@ #include "qgsvectorlayer.h" #include "qgslayoutitemlegend.h" -class TestQgsLayoutExporter: public QgsTest +class TestQgsLayoutExporter : public QgsTest { Q_OBJECT @@ -41,7 +41,6 @@ class TestQgsLayoutExporter: public QgsTest void cleanup(); void testHandleLayeredExport(); void testHandleLayeredExportCustomGroups(); - }; void TestQgsLayoutExporter::initTestCase() @@ -57,12 +56,10 @@ void TestQgsLayoutExporter::cleanupTestCase() void TestQgsLayoutExporter::init() { - } void TestQgsLayoutExporter::cleanup() { - } void TestQgsLayoutExporter::testHandleLayeredExport() @@ -71,12 +68,11 @@ void TestQgsLayoutExporter::testHandleLayeredExport() QgsLayout l( &p ); QgsLayoutExporter exporter( &l ); - QList< unsigned int > layerIds; + QList layerIds; QStringList layerNames; QStringList mapLayerIds; QgsLayout *layout = &l; - auto exportFunc = [&layerIds, &layerNames, &mapLayerIds, layout]( unsigned int layerId, const QgsLayoutItem::ExportLayerDetail & layerDetail )->QgsLayoutExporter::ExportResult - { + auto exportFunc = [&layerIds, &layerNames, &mapLayerIds, layout]( unsigned int layerId, const QgsLayoutItem::ExportLayerDetail &layerDetail ) -> QgsLayoutExporter::ExportResult { layerIds << layerId; layerNames << layerDetail.name; mapLayerIds << layerDetail.mapLayerId; @@ -88,12 +84,11 @@ void TestQgsLayoutExporter::testHandleLayeredExport() return QgsLayoutExporter::Success; }; - auto getExportGroupNameFunc = []( QgsLayoutItem * )->QString - { + auto getExportGroupNameFunc = []( QgsLayoutItem * ) -> QString { return QString(); }; - QList< QGraphicsItem * > items; + QList items; QgsLayoutExporter::ExportResult res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); QVERIFY( layerIds.isEmpty() ); @@ -105,7 +100,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << page1; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 ); + QCOMPARE( layerIds, QList() << 1 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Page" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() ); layerIds.clear(); @@ -116,7 +111,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << page2; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 ); + QCOMPARE( layerIds, QList() << 1 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() ); layerIds.clear(); @@ -127,7 +122,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << label; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 ); + QCOMPARE( layerIds, QList() << 1 << 2 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() ); layerIds.clear(); @@ -138,7 +133,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << shape; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 ); + QCOMPARE( layerIds, QList() << 1 << 2 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() ); layerIds.clear(); @@ -149,7 +144,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << label2; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 ); + QCOMPARE( layerIds, QList() << 1 << 2 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() ); layerIds.clear(); @@ -161,7 +156,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << scaleBar; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() ); layerIds.clear(); @@ -172,7 +167,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << label3; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() ); layerIds.clear(); @@ -186,7 +181,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << scaleBar3; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebars" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() ); layerIds.clear(); @@ -194,8 +189,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() mapLayerIds.clear(); // with an item which has sublayers - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); p.addMapLayer( linesLayer ); @@ -211,7 +205,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << map; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebars" ) << QStringLiteral( "Map 1: lines" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() ); layerIds.clear(); @@ -222,7 +216,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() map->setBackgroundEnabled( true ); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebars" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() ); layerIds.clear(); @@ -237,7 +231,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << legend << legend2; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebars" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) << QStringLiteral( "my legend" ) << QStringLiteral( "my legend 2" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() << QString() << QString() ); layerIds.clear(); @@ -248,7 +242,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << label4; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebars" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) << QStringLiteral( "my legend" ) << QStringLiteral( "my legend 2" ) << QStringLiteral( "Label" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() << QString() << QString() << QString() ); layerIds.clear(); @@ -259,7 +253,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport() items << label5; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Labels, Shape" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebars" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) << QStringLiteral( "my legend" ) << QStringLiteral( "my legend 2" ) << QStringLiteral( "Labels" ) ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() << QString() << QString() << QString() ); layerIds.clear(); @@ -276,13 +270,12 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() QgsLayout l( &p ); QgsLayoutExporter exporter( &l ); - QList< unsigned int > layerIds; + QList layerIds; QStringList layerNames; QStringList mapLayerIds; QStringList groupNames; QgsLayout *layout = &l; - auto exportFunc = [&layerIds, &layerNames, &mapLayerIds, &groupNames, layout]( unsigned int layerId, const QgsLayoutItem::ExportLayerDetail & layerDetail )->QgsLayoutExporter::ExportResult - { + auto exportFunc = [&layerIds, &layerNames, &mapLayerIds, &groupNames, layout]( unsigned int layerId, const QgsLayoutItem::ExportLayerDetail &layerDetail ) -> QgsLayoutExporter::ExportResult { layerIds << layerId; layerNames << layerDetail.name; mapLayerIds << layerDetail.mapLayerId; @@ -294,12 +287,11 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() return QgsLayoutExporter::Success; }; - auto getExportGroupNameFunc = []( QgsLayoutItem * item )->QString - { + auto getExportGroupNameFunc = []( QgsLayoutItem *item ) -> QString { return item->customProperty( QStringLiteral( "pdfExportGroup" ) ).toString(); }; - QList< QGraphicsItem * > items; + QList items; QStringList expectedGroupNames; QgsLayoutExporter::ExportResult res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); @@ -314,7 +306,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QString(); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 ); + QCOMPARE( layerIds, QList() << 1 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Page" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() ); @@ -327,7 +319,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() items << page2; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 ); + QCOMPARE( layerIds, QList() << 1 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() ); @@ -341,7 +333,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QString(); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 ); + QCOMPARE( layerIds, QList() << 1 << 2 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() ); @@ -354,7 +346,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() items << shape; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 ); + QCOMPARE( layerIds, QList() << 1 << 2 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() ); @@ -369,7 +361,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() items << label2; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) ); QCOMPARE( groupNames, expectedGroupNames ); layerIds.clear(); @@ -384,7 +376,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() items << scaleBar; res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() ); @@ -398,7 +390,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QString(); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() ); @@ -417,7 +409,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QStringLiteral( "scales" ); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Scalebar" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << QString() ); @@ -427,8 +419,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() mapLayerIds.clear(); // with an item which has sublayers - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); p.addMapLayer( linesLayer ); @@ -445,7 +436,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QString(); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Map 1: lines" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() ); @@ -459,7 +450,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); expectedGroupNames << QString() << QString(); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() ); @@ -479,7 +470,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QStringLiteral( "second group" ) << QStringLiteral( "second group" ); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) << QStringLiteral( "my legend" ) << QStringLiteral( "my legend 2" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() << QString() << QString() ); @@ -494,7 +485,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QStringLiteral( "more labels" ); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) << QStringLiteral( "my legend" ) << QStringLiteral( "my legend 2" ) << QStringLiteral( "Label" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() << QString() << QString() << QString() ); @@ -509,7 +500,7 @@ void TestQgsLayoutExporter::testHandleLayeredExportCustomGroups() expectedGroupNames << QStringLiteral( "more labels 2" ); res = exporter.handleLayeredExport( items, exportFunc, getExportGroupNameFunc ); QCOMPARE( res, QgsLayoutExporter::Success ); - QCOMPARE( layerIds, QList< unsigned int >() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 ); + QCOMPARE( layerIds, QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 ); QCOMPARE( layerNames, QStringList() << QStringLiteral( "Pages" ) << QStringLiteral( "Label, Shape" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Label" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Scalebar" ) << QStringLiteral( "Map 1: Background" ) << QStringLiteral( "Map 1: lines" ) << QStringLiteral( "Map 1: Frame" ) << QStringLiteral( "my legend" ) << QStringLiteral( "my legend 2" ) << QStringLiteral( "Label" ) << QStringLiteral( "Label" ) ); QCOMPARE( groupNames, expectedGroupNames ); QCOMPARE( mapLayerIds, QStringList() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << QString() << linesLayer->id() << QString() << QString() << QString() << QString() << QString() ); diff --git a/tests/src/core/testqgslayoutgeopdfexport.cpp b/tests/src/core/testqgslayoutgeopdfexport.cpp index 61ef9a90846d..92fdbdc695fe 100644 --- a/tests/src/core/testqgslayoutgeopdfexport.cpp +++ b/tests/src/core/testqgslayoutgeopdfexport.cpp @@ -32,11 +32,12 @@ class TestQgsLayoutGeospatialPdfExport : public QgsTest Q_OBJECT public: - TestQgsLayoutGeospatialPdfExport() : QgsTest( QStringLiteral( "Geospatial PDF Export Tests" ) ) {} + TestQgsLayoutGeospatialPdfExport() + : QgsTest( QStringLiteral( "Geospatial PDF Export Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testTempFilenames(); void testCollectingFeatures(); void skipLayers(); @@ -77,14 +78,11 @@ void TestQgsLayoutGeospatialPdfExport::testTempFilenames() void TestQgsLayoutGeospatialPdfExport::testCollectingFeatures() { - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); - QgsVectorLayer *polygonLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), - QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *polygonLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); QVERIFY( polygonLayer->isValid() ); pointsLayer->setDisplayExpression( QStringLiteral( "Staff" ) ); @@ -94,19 +92,12 @@ void TestQgsLayoutGeospatialPdfExport::testCollectingFeatures() p.addMapLayer( polygonLayer ); QgsMapThemeCollection::MapThemeRecord rec; - rec.setLayerRecords( QList() - << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) - ); + rec.setLayerRecords( QList() << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) ); p.mapThemeCollection()->insert( QStringLiteral( "test preset" ), rec ); - rec.setLayerRecords( QList() - << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) - << QgsMapThemeCollection::MapThemeLayerRecord( pointsLayer ) - ); + rec.setLayerRecords( QList() << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) << QgsMapThemeCollection::MapThemeLayerRecord( pointsLayer ) ); p.mapThemeCollection()->insert( QStringLiteral( "test preset2" ), rec ); - rec.setLayerRecords( QList() - << QgsMapThemeCollection::MapThemeLayerRecord( polygonLayer ) - ); + rec.setLayerRecords( QList() << QgsMapThemeCollection::MapThemeLayerRecord( polygonLayer ) ); p.mapThemeCollection()->insert( QStringLiteral( "test preset3" ), rec ); QgsLayout l( &p ); @@ -163,7 +154,7 @@ void TestQgsLayoutGeospatialPdfExport::testCollectingFeatures() QgsDebugMsgLevel( lineGeometry1.asWkt( 0 ), 1 ); QCOMPARE( lineGeometry1.asWkt( 0 ), QStringLiteral( "MultiLineString ((281 538, 283 532, 284 530, 285 529, 289 526, 299 520, 310 516, 313 513, 318 508, 319 507, 320 501, 320 498, 322 493, 323 491, 323 486, 324 484, 326 481, 327 478, 331 474, 331 473, 332 470, 332 465, 332 463, 333 459, 334 457, 338 454, 342 452, 345 450, 349 448, 349 445, 349 443, 347 439, 346 438, 345 435, 343 433, 342 432, 341 430, 341 428, 340 426, 340 424, 342 420, 343 418, 343 418, 348 407, 345 402, 343 399, 340 393, 340 389, 335 385, 333 382, 331 378, 331 376, 331 374, 331 372, 331 369, 332 367, 333 364, 334 362, 336 360, 338 357, 341 353, 346 344, 347 343, 350 339, 352 338, 356 333, 358 331, 363 328, 366 325, 370 321, 372 320, 376 317, 380 314, 384 312, 390 307, 392 305, 393 302, 393 299, 393 295, 393 294, 391 291, 388 287, 386 285, 385 283, 385 280, 386 278, 387 274, 388 272, 391 268, 392 267, 394 263, 398 259, 406 255))" ) ); - QgsFeatureList pointFeatures = geospatialPdfExporter.mCollatedFeatures.value( QString() ).value( pointsLayer->id() ); + QgsFeatureList pointFeatures = geospatialPdfExporter.mCollatedFeatures.value( QString() ).value( pointsLayer->id() ); QCOMPARE( pointFeatures.count(), 32 ); QgsFeature pointFeature3; @@ -213,33 +204,30 @@ void TestQgsLayoutGeospatialPdfExport::testCollectingFeatures() QVERIFY( geospatialPdfExporter.errorMessage().isEmpty() ); QgsAbstractGeospatialPdfExporter::VectorComponentDetail vectorDetail; - for ( const auto &it : geospatialPdfExporter.mVectorComponents ) + for ( const auto &it : geospatialPdfExporter.mVectorComponents ) { if ( it.mapLayerId == linesLayer->id() ) vectorDetail = it; } // read in as vector - std::unique_ptr< QgsVectorLayer > layer1 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer1 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer1->isValid() ); QCOMPARE( layer1->featureCount(), 6L ); - for ( const auto &it : geospatialPdfExporter.mVectorComponents ) + for ( const auto &it : geospatialPdfExporter.mVectorComponents ) { if ( it.mapLayerId == pointsLayer->id() ) vectorDetail = it; } - std::unique_ptr< QgsVectorLayer > layer2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer2 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer2->isValid() ); QCOMPARE( layer2->featureCount(), 32L ); - for ( const auto &it : geospatialPdfExporter.mVectorComponents ) + for ( const auto &it : geospatialPdfExporter.mVectorComponents ) { if ( it.mapLayerId == polygonLayer->id() ) vectorDetail = it; } - std::unique_ptr< QgsVectorLayer > layer3 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer3 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer3->isValid() ); QCOMPARE( layer3->featureCount(), 10L ); @@ -296,8 +284,7 @@ void TestQgsLayoutGeospatialPdfExport::testCollectingFeatures() } // read in as vector - layer1 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + layer1 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer1->isValid() ); QCOMPARE( layer1->featureCount(), 6L ); vectorDetail = QgsAbstractGeospatialPdfExporter::VectorComponentDetail(); @@ -308,52 +295,45 @@ void TestQgsLayoutGeospatialPdfExport::testCollectingFeatures() } // read in as vector - layer1 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + layer1 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer1->isValid() ); QCOMPARE( layer1->featureCount(), 6L ); vectorDetail = QgsAbstractGeospatialPdfExporter::VectorComponentDetail(); - for ( const auto &it : geospatialPdfExporter2.mVectorComponents ) + for ( const auto &it : geospatialPdfExporter2.mVectorComponents ) { if ( it.mapLayerId == pointsLayer->id() && it.group == QLatin1String( "test preset2" ) ) vectorDetail = it; } - layer2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + layer2 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer2->isValid() ); QCOMPARE( layer2->featureCount(), 15L ); vectorDetail = QgsAbstractGeospatialPdfExporter::VectorComponentDetail(); - for ( const auto &it : geospatialPdfExporter2.mVectorComponents ) + for ( const auto &it : geospatialPdfExporter2.mVectorComponents ) { - if ( it.mapLayerId == polygonLayer->id() && it.group.isEmpty() ) + if ( it.mapLayerId == polygonLayer->id() && it.group.isEmpty() ) vectorDetail = it; } - layer3 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + layer3 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer3->isValid() ); QCOMPARE( layer3->featureCount(), 10L ); vectorDetail = QgsAbstractGeospatialPdfExporter::VectorComponentDetail(); - for ( const auto &it : geospatialPdfExporter2.mVectorComponents ) + for ( const auto &it : geospatialPdfExporter2.mVectorComponents ) { if ( it.mapLayerId == polygonLayer->id() && it.group == QLatin1String( "test preset3" ) ) vectorDetail = it; } - layer3 = std::make_unique< QgsVectorLayer >( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + layer3 = std::make_unique( QStringLiteral( "%1|layername=%2" ).arg( vectorDetail.sourceVectorPath, vectorDetail.sourceVectorLayer ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( layer3->isValid() ); QCOMPARE( layer3->featureCount(), 10L ); } void TestQgsLayoutGeospatialPdfExport::skipLayers() { - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); - QgsVectorLayer *polygonLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), - QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *polygonLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); QVERIFY( polygonLayer->isValid() ); pointsLayer->setDisplayExpression( QStringLiteral( "Staff" ) ); @@ -391,7 +371,7 @@ void TestQgsLayoutGeospatialPdfExport::skipLayers() // check that features were collected const QgsFeatureList lineFeatures = geospatialPdfExporter.mCollatedFeatures.value( QString() ).value( linesLayer->id() ); QCOMPARE( lineFeatures.count(), 0 ); // should be nothing, layer is set to skip - const QgsFeatureList pointFeatures = geospatialPdfExporter.mCollatedFeatures.value( QString() ).value( pointsLayer->id() ); + const QgsFeatureList pointFeatures = geospatialPdfExporter.mCollatedFeatures.value( QString() ).value( pointsLayer->id() ); QCOMPARE( pointFeatures.count(), 15 ); // should be features, layer was set to export const QgsFeatureList polyFeatures = geospatialPdfExporter.mCollatedFeatures.value( QString() ).value( polygonLayer->id() ); QCOMPARE( polyFeatures.count(), 10 ); // should be features, layer did not have any setting set @@ -399,14 +379,11 @@ void TestQgsLayoutGeospatialPdfExport::skipLayers() void TestQgsLayoutGeospatialPdfExport::layerOrder() { - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); - QgsVectorLayer *polygonLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), - QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *polygonLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); QVERIFY( polygonLayer->isValid() ); pointsLayer->setDisplayExpression( QStringLiteral( "Staff" ) ); @@ -453,7 +430,7 @@ void TestQgsLayoutGeospatialPdfExport::groupOrder() QVERIFY( geospatialPdfExporter.layerTreeGroupOrder().isEmpty() ); // custom group order is specified, respect that - l.setCustomProperty( QStringLiteral( "pdfGroupOrder" ), QStringList{ QStringLiteral( "group 1" ), QStringLiteral( "GROUP C" ), QStringLiteral( "group 2" ) } ); + l.setCustomProperty( QStringLiteral( "pdfGroupOrder" ), QStringList { QStringLiteral( "group 1" ), QStringLiteral( "GROUP C" ), QStringLiteral( "group 2" ) } ); const QgsLayoutGeospatialPdfExporter geospatialPdfExporter2( &l ); QCOMPARE( geospatialPdfExporter2.layerTreeGroupOrder(), QStringList() << QStringLiteral( "group 1" ) << QStringLiteral( "GROUP C" ) << QStringLiteral( "group 2" ) ); } diff --git a/tests/src/core/testqgslayouthtml.cpp b/tests/src/core/testqgslayouthtml.cpp index 3fad004133ef..8b542748a63e 100644 --- a/tests/src/core/testqgslayouthtml.cpp +++ b/tests/src/core/testqgslayouthtml.cpp @@ -34,19 +34,20 @@ class TestQgsLayoutHtml : public QgsTest Q_OBJECT public: - TestQgsLayoutHtml() : QgsTest( QStringLiteral( "Layout HTML Tests" ), QStringLiteral( "composer_html" ) ) {} + TestQgsLayoutHtml() + : QgsTest( QStringLiteral( "Layout HTML Tests" ), QStringLiteral( "composer_html" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void sourceMode(); //test if rendering manual HTML works - void userStylesheets(); //test if user stylesheets work - void evalExpressions(); //test if rendering with expressions works - void evalExpressionsOff(); //test if rendering with expressions disabled works - void table(); //test if rendering a HTML url works - void tableMultiFrame(); //tests multiframe capabilities of composer html + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void sourceMode(); //test if rendering manual HTML works + void userStylesheets(); //test if user stylesheets work + void evalExpressions(); //test if rendering with expressions works + void evalExpressionsOff(); //test if rendering with expressions disabled works + void table(); //test if rendering a HTML url works + void tableMultiFrame(); //tests multiframe capabilities of composer html void htmlMultiFrameSmartBreak(); //tests smart page breaks in html multi frame - void javascriptSetFeature(); //test that JavaScript setFeature() function is correctly called + void javascriptSetFeature(); //test that JavaScript setFeature() function is correctly called private: QFont mTestFont; @@ -126,7 +127,8 @@ void TestQgsLayoutHtml::evalExpressionsOff() l.initializeDefaults(); QgsLayoutItemHtml *htmlItem = new QgsLayoutItemHtml( &l ); QgsLayoutFrame *htmlFrame = new QgsLayoutFrame( &l, htmlItem ); - htmlFrame->attemptSetSceneRect( QRectF( 0, 0, 100, 200 ) ); htmlFrame->setFrameEnabled( true ); + htmlFrame->attemptSetSceneRect( QRectF( 0, 0, 100, 200 ) ); + htmlFrame->setFrameEnabled( true ); htmlItem->addFrame( htmlFrame ); htmlItem->setContentMode( QgsLayoutItemHtml::ManualHtml ); htmlItem->setEvaluateExpressions( false ); @@ -142,7 +144,8 @@ void TestQgsLayoutHtml::table() l.initializeDefaults(); QgsLayoutItemHtml *htmlItem = new QgsLayoutItemHtml( &l ); QgsLayoutFrame *htmlFrame = new QgsLayoutFrame( &l, htmlItem ); - htmlFrame->attemptSetSceneRect( QRectF( 0, 0, 100, 200 ) ); htmlFrame->setFrameEnabled( true ); + htmlFrame->attemptSetSceneRect( QRectF( 0, 0, 100, 200 ) ); + htmlFrame->setFrameEnabled( true ); htmlItem->addFrame( htmlFrame ); htmlItem->setUrl( QUrl( QStringLiteral( "file:///%1/test_html.html" ).arg( TEST_DATA_DIR ) ) ); @@ -200,7 +203,7 @@ void TestQgsLayoutHtml::javascriptSetFeature() QgsVectorDataProvider *pr = parentLayer->dataProvider(); QgsFeature pf1; pf1.setFields( parentLayer->fields() ); - pf1.setAttributes( QgsAttributes() << "test1" << 67 << 123 ); + pf1.setAttributes( QgsAttributes() << "test1" << 67 << 123 ); QgsFeature pf2; pf2.setFields( parentLayer->fields() ); pf2.setAttributes( QgsAttributes() << "test2" << 68 << 124 ); @@ -214,11 +217,11 @@ void TestQgsLayoutHtml::javascriptSetFeature() f1.setAttributes( QgsAttributes() << "foo" << 123 << 321 ); QgsFeature f2; f2.setFields( childLayer->fields() ); - f2.setAttributes( QgsAttributes() << "bar" << 123 << 654 ); + f2.setAttributes( QgsAttributes() << "bar" << 123 << 654 ); QgsFeature f3; f3.setFields( childLayer->fields() ); - f3.setAttributes( QgsAttributes() << "foobar" << 124 << 554 ); - QVERIFY( pr->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); + f3.setAttributes( QgsAttributes() << "foobar" << 124 << 554 ); + QVERIFY( pr->addFeatures( QgsFeatureList() << f1 << f2 << f3 ) ); QgsProject::instance()->addMapLayers( QList() << childLayer << parentLayer ); diff --git a/tests/src/core/testqgslayoutitem.cpp b/tests/src/core/testqgslayoutitem.cpp index 837ab6bfbe98..44f9961d52ca 100644 --- a/tests/src/core/testqgslayoutitem.cpp +++ b/tests/src/core/testqgslayoutitem.cpp @@ -45,8 +45,8 @@ class TestItem : public QgsLayoutItem Q_OBJECT public: - - TestItem( QgsLayout *layout ) : QgsLayoutItem( layout ) + TestItem( QgsLayout *layout ) + : QgsLayoutItem( layout ) { setFrameEnabled( false ); setBackgroundEnabled( false ); @@ -84,7 +84,8 @@ class MinSizedItem : public TestItem Q_OBJECT public: - MinSizedItem( QgsLayout *layout ) : TestItem( layout ) + MinSizedItem( QgsLayout *layout ) + : TestItem( layout ) { setMinimumSize( QgsLayoutSize( 5.0, 10.0, Qgis::LayoutUnit::Centimeters ) ); } @@ -93,7 +94,6 @@ class MinSizedItem : public TestItem { setMinimumSize( size ); } - }; //item with fixed size @@ -102,8 +102,8 @@ class FixedSizedItem : public TestItem Q_OBJECT public: - - FixedSizedItem( QgsLayout *layout ) : TestItem( layout ) + FixedSizedItem( QgsLayout *layout ) + : TestItem( layout ) { setFixedSize( QgsLayoutSize( 2.0, 4.0, Qgis::LayoutUnit::Inches ) ); } @@ -120,8 +120,8 @@ class FixedMinSizedItem : public TestItem Q_OBJECT public: - - FixedMinSizedItem( QgsLayout *layout ) : TestItem( layout ) + FixedMinSizedItem( QgsLayout *layout ) + : TestItem( layout ) { setFixedSize( QgsLayoutSize( 2.0, 4.0, Qgis::LayoutUnit::Centimeters ) ); setMinimumSize( QgsLayoutSize( 5.0, 9.0, Qgis::LayoutUnit::Centimeters ) ); @@ -129,12 +129,13 @@ class FixedMinSizedItem : public TestItem }; -class TestQgsLayoutItem: public QgsTest +class TestQgsLayoutItem : public QgsTest { Q_OBJECT public: - TestQgsLayoutItem() : QgsTest( QStringLiteral( "Layout Item Tests" ) ) {} + TestQgsLayoutItem() + : QgsTest( QStringLiteral( "Layout Item Tests" ) ) {} private slots: void cleanupTestCase(); @@ -177,9 +178,7 @@ class TestQgsLayoutItem: public QgsTest void mapCreditsFunction(); private: - - std::unique_ptr< QgsLayoutItem > createCopyViaXml( QgsLayout *layout, QgsLayoutItem *original ); - + std::unique_ptr createCopyViaXml( QgsLayout *layout, QgsLayoutItem *original ); }; void TestQgsLayoutItem::cleanupTestCase() @@ -227,12 +226,10 @@ void TestQgsLayoutItem::registry() QVERIFY( registry.itemTypes().isEmpty() ); QVERIFY( !registry.createItem( 1, nullptr ) ); - auto create = []( QgsLayout * layout )->QgsLayoutItem * - { + auto create = []( QgsLayout *layout ) -> QgsLayoutItem * { return new TestItem( layout ); }; - auto resolve = []( QVariantMap & props, const QgsPathResolver &, bool ) - { + auto resolve = []( QVariantMap &props, const QgsPathResolver &, bool ) { props.clear(); }; @@ -255,7 +252,7 @@ void TestQgsLayoutItem::registry() QCOMPARE( registry.itemTypes().value( 2 ), QStringLiteral( "my type" ) ); QgsLayoutItem *item = registry.createItem( 2, nullptr ); QVERIFY( item ); - QVERIFY( dynamic_cast< TestItem *>( item ) ); + QVERIFY( dynamic_cast( item ) ); delete item; QVariantMap props; props.insert( QStringLiteral( "a" ), 5 ); @@ -361,7 +358,7 @@ void TestQgsLayoutItem::positionWithUnits() QgsProject p; QgsLayout l( &p ); - std::unique_ptr< TestItem > item( new TestItem( &l ) ); + std::unique_ptr item( new TestItem( &l ) ); item->attemptMove( QgsLayoutPoint( 60.0, 15.0, Qgis::LayoutUnit::Millimeters ) ); QCOMPARE( item->positionWithUnits().x(), 60.0 ); QCOMPARE( item->positionWithUnits().y(), 15.0 ); @@ -424,7 +421,7 @@ void TestQgsLayoutItem::dataDefinedPosition() QCOMPARE( item->positionWithUnits().y(), 6.0 ); QCOMPARE( item->positionWithUnits().units(), Qgis::LayoutUnit::Centimeters ); QCOMPARE( item->scenePos().x(), 120.0 ); //mm - QCOMPARE( item->scenePos().y(), 60.0 ); //mm + QCOMPARE( item->scenePos().y(), 60.0 ); //mm //also check that data defined position overrides when attempting to move item->attemptMove( QgsLayoutPoint( 6.0, 1.50, Qgis::LayoutUnit::Centimeters ) ); @@ -432,7 +429,7 @@ void TestQgsLayoutItem::dataDefinedPosition() QCOMPARE( item->positionWithUnits().y(), 6.0 ); QCOMPARE( item->positionWithUnits().units(), Qgis::LayoutUnit::Centimeters ); QCOMPARE( item->scenePos().x(), 120.0 ); //mm - QCOMPARE( item->scenePos().y(), 60.0 ); //mm + QCOMPARE( item->scenePos().y(), 60.0 ); //mm //restriction only for x position item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::PositionX, QgsProperty::fromExpression( QStringLiteral( "4+8" ) ) ); item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::PositionY, QgsProperty() ); @@ -441,7 +438,7 @@ void TestQgsLayoutItem::dataDefinedPosition() QCOMPARE( item->positionWithUnits().y(), 1.5 ); QCOMPARE( item->positionWithUnits().units(), Qgis::LayoutUnit::Centimeters ); QCOMPARE( item->scenePos().x(), 120.0 ); //mm - QCOMPARE( item->scenePos().y(), 15.0 ); //mm + QCOMPARE( item->scenePos().y(), 15.0 ); //mm //restriction only for y position item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::PositionX, QgsProperty() ); item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::PositionY, QgsProperty::fromExpression( QStringLiteral( "2+4" ) ) ); @@ -459,19 +456,19 @@ void TestQgsLayoutItem::dataDefinedPosition() item->attemptMove( QgsLayoutPoint( 120.0, 60.0, Qgis::LayoutUnit::Millimeters ) ); //data defined position should utilize new units QCOMPARE( item->positionWithUnits().x(), 12.0 ); //mm - QCOMPARE( item->positionWithUnits().y(), 6.0 ); //mm + QCOMPARE( item->positionWithUnits().y(), 6.0 ); //mm QCOMPARE( item->positionWithUnits().units(), Qgis::LayoutUnit::Millimeters ); QCOMPARE( item->scenePos().x(), 12.0 ); //mm - QCOMPARE( item->scenePos().y(), 6.0 ); //mm + QCOMPARE( item->scenePos().y(), 6.0 ); //mm //test that data defined position applies to item's reference point item->attemptMove( QgsLayoutPoint( 12.0, 6.0, Qgis::LayoutUnit::Centimeters ) ); item->setReferencePoint( QgsLayoutItem::LowerRight ); QCOMPARE( item->positionWithUnits().x(), 12.0 ); //cm - QCOMPARE( item->positionWithUnits().y(), 6.0 ); //cm + QCOMPARE( item->positionWithUnits().y(), 6.0 ); //cm QCOMPARE( item->positionWithUnits().units(), Qgis::LayoutUnit::Centimeters ); QCOMPARE( item->scenePos().x(), 100.0 ); //mm - QCOMPARE( item->scenePos().y(), 20.0 ); //mm + QCOMPARE( item->scenePos().y(), 20.0 ); //mm //also check setting data defined position AFTER setting reference point item->setPos( 0, 0 ); @@ -479,10 +476,10 @@ void TestQgsLayoutItem::dataDefinedPosition() item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::PositionY, QgsProperty::fromExpression( QStringLiteral( "2+6" ) ) ); item->refreshItemPosition(); QCOMPARE( item->positionWithUnits().x(), 16.0 ); //cm - QCOMPARE( item->positionWithUnits().y(), 8.0 ); //cm + QCOMPARE( item->positionWithUnits().y(), 8.0 ); //cm QCOMPARE( item->positionWithUnits().units(), Qgis::LayoutUnit::Centimeters ); QCOMPARE( item->scenePos().x(), 140.0 ); //mm - QCOMPARE( item->scenePos().y(), 40.0 ); //mm + QCOMPARE( item->scenePos().y(), 40.0 ); //mm delete item; } @@ -546,7 +543,7 @@ void TestQgsLayoutItem::dataDefinedSize() QCOMPARE( item->sizeWithUnits().width(), 7.0 ); QCOMPARE( item->sizeWithUnits().height(), 6.0 ); QCOMPARE( item->sizeWithUnits().units(), Qgis::LayoutUnit::Centimeters ); - QCOMPARE( item->rect().width(), 70.0 ); //mm + QCOMPARE( item->rect().width(), 70.0 ); //mm QCOMPARE( item->rect().height(), 60.0 ); //mm // data defined page size @@ -557,7 +554,7 @@ void TestQgsLayoutItem::dataDefinedSize() QCOMPARE( item->sizeWithUnits().width(), 14.8 ); QCOMPARE( item->sizeWithUnits().height(), 21.0 ); QCOMPARE( item->sizeWithUnits().units(), Qgis::LayoutUnit::Centimeters ); - QCOMPARE( item->rect().width(), 148.0 ); //mm + QCOMPARE( item->rect().width(), 148.0 ); //mm QCOMPARE( item->rect().height(), 210.0 ); //mm // data defined height/width should override page size item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ItemWidth, QgsProperty::fromValue( "13.0" ) ); @@ -565,7 +562,7 @@ void TestQgsLayoutItem::dataDefinedSize() QCOMPARE( item->sizeWithUnits().width(), 13.0 ); QCOMPARE( item->sizeWithUnits().height(), 21.0 ); QCOMPARE( item->sizeWithUnits().units(), Qgis::LayoutUnit::Centimeters ); - QCOMPARE( item->rect().width(), 130.0 ); //mm + QCOMPARE( item->rect().width(), 130.0 ); //mm QCOMPARE( item->rect().height(), 210.0 ); //mm item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ItemHeight, QgsProperty::fromValue( "3.0" ) ); item->attemptResize( QgsLayoutSize( 7.0, 1.50, Qgis::LayoutUnit::Centimeters ) ); @@ -580,7 +577,7 @@ void TestQgsLayoutItem::dataDefinedSize() QCOMPARE( item->sizeWithUnits().width(), 3.0 ); QCOMPARE( item->sizeWithUnits().height(), 13.0 ); QCOMPARE( item->sizeWithUnits().units(), Qgis::LayoutUnit::Centimeters ); - QCOMPARE( item->rect().width(), 30.0 ); //mm + QCOMPARE( item->rect().width(), 30.0 ); //mm QCOMPARE( item->rect().height(), 130.0 ); //mm item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ItemWidth, QgsProperty() ); @@ -591,7 +588,7 @@ void TestQgsLayoutItem::dataDefinedSize() QCOMPARE( item->sizeWithUnits().width(), 1.5 ); QCOMPARE( item->sizeWithUnits().height(), 1.0 ); QCOMPARE( item->sizeWithUnits().units(), Qgis::LayoutUnit::Centimeters ); - QCOMPARE( item->rect().width(), 15.0 ); //mm + QCOMPARE( item->rect().width(), 15.0 ); //mm QCOMPARE( item->rect().height(), 10.0 ); //mm item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::PaperOrientation, QgsProperty() ); @@ -617,7 +614,7 @@ void TestQgsLayoutItem::dataDefinedSize() item->setReferencePoint( QgsLayoutItem::LowerRight ); item->refreshItemSize(); QCOMPARE( item->scenePos().x(), 25.0 ); //mm - QCOMPARE( item->scenePos().y(), 9.0 ); //mm + QCOMPARE( item->scenePos().y(), 9.0 ); //mm //test that data defined size applied after setting item's reference point respects reference item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ItemWidth, QgsProperty() ); @@ -630,7 +627,7 @@ void TestQgsLayoutItem::dataDefinedSize() item->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ItemHeight, QgsProperty::fromExpression( QStringLiteral( "9" ) ) ); item->refreshItemSize(); QCOMPARE( item->scenePos().x(), 23.0 ); //mm - QCOMPARE( item->scenePos().y(), 6.0 ); //mm + QCOMPARE( item->scenePos().y(), 6.0 ); //mm delete item; } @@ -659,7 +656,7 @@ void TestQgsLayoutItem::combinedDataDefinedPositionAndSize() QCOMPARE( item->sizeWithUnits().height(), 6.0 ); QCOMPARE( item->sizeWithUnits().units(), Qgis::LayoutUnit::Centimeters ); QCOMPARE( item->scenePos().x(), 110.0 ); //mm - QCOMPARE( item->scenePos().y(), 50.0 ); //mm + QCOMPARE( item->scenePos().y(), 50.0 ); //mm QCOMPARE( item->rect().width(), 130.0 ); //mm QCOMPARE( item->rect().height(), 60.0 ); //mm @@ -676,8 +673,8 @@ void TestQgsLayoutItem::combinedDataDefinedPositionAndSize() QCOMPARE( item->sizeWithUnits().width(), 10.0 ); QCOMPARE( item->sizeWithUnits().height(), 4.0 ); QCOMPARE( item->sizeWithUnits().units(), Qgis::LayoutUnit::Centimeters ); - QCOMPARE( item->scenePos().x(), 70.0 ); //mm - QCOMPARE( item->scenePos().y(), 40.0 ); //mm + QCOMPARE( item->scenePos().x(), 70.0 ); //mm + QCOMPARE( item->scenePos().y(), 40.0 ); //mm QCOMPARE( item->rect().width(), 100.0 ); //mm QCOMPARE( item->rect().height(), 40.0 ); //mm @@ -693,7 +690,7 @@ void TestQgsLayoutItem::resize() //resize test item (no restrictions), same units as layout l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr< TestItem > item( new TestItem( &l ) ); + std::unique_ptr item( new TestItem( &l ) ); const QSignalSpy spySizeChanged( item.get(), &QgsLayoutItem::sizePositionChanged ); item->setRect( 0, 0, 55, 45 ); @@ -763,7 +760,7 @@ void TestQgsLayoutItem::referencePoint() QgsLayout l( &p ); //test setting/getting reference point - std::unique_ptr< TestItem > item( new TestItem( &l ) ); + std::unique_ptr item( new TestItem( &l ) ); item->setReferencePoint( QgsLayoutItem::LowerMiddle ); QCOMPARE( item->referencePoint(), QgsLayoutItem::LowerMiddle ); @@ -943,7 +940,7 @@ void TestQgsLayoutItem::adjustPointForReference() QgsProject p; QgsLayout l( &p ); - std::unique_ptr< TestItem > item( new TestItem( &l ) ); + std::unique_ptr item( new TestItem( &l ) ); QPointF result = item->adjustPointForReferencePosition( QPointF( 5, 7 ), QSizeF( 2, 4 ), QgsLayoutItem::UpperLeft ); QCOMPARE( result.x(), 5.0 ); QCOMPARE( result.y(), 7.0 ); @@ -1048,7 +1045,7 @@ void TestQgsLayoutItem::fixedSize() QgsLayout l( &p ); l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr< FixedSizedItem > item( new FixedSizedItem( &l ) ); + std::unique_ptr item( new FixedSizedItem( &l ) ); QCOMPARE( item->fixedSize().width(), 2.0 ); QCOMPARE( item->fixedSize().height(), 4.0 ); QCOMPARE( item->fixedSize().units(), Qgis::LayoutUnit::Inches ); @@ -1076,7 +1073,7 @@ void TestQgsLayoutItem::minSize() QgsLayout l( &p ); l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr< MinSizedItem > item( new MinSizedItem( &l ) ); + std::unique_ptr item( new MinSizedItem( &l ) ); QCOMPARE( item->minimumSize().width(), 5.0 ); QCOMPARE( item->minimumSize().height(), 10.0 ); QCOMPARE( item->minimumSize().units(), Qgis::LayoutUnit::Centimeters ); @@ -1099,7 +1096,7 @@ void TestQgsLayoutItem::minSize() QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * std::numeric_limits::epsilon() ); //also need check that fixed size trumps min size - std::unique_ptr< FixedMinSizedItem > fixedMinItem( new FixedMinSizedItem( &l ) ); + std::unique_ptr fixedMinItem( new FixedMinSizedItem( &l ) ); QCOMPARE( fixedMinItem->minimumSize().width(), 5.0 ); QCOMPARE( fixedMinItem->minimumSize().height(), 9.0 ); QCOMPARE( fixedMinItem->minimumSize().units(), Qgis::LayoutUnit::Centimeters ); @@ -1120,7 +1117,7 @@ void TestQgsLayoutItem::move() //move test item, same units as layout l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr< TestItem > item( new TestItem( &l ) ); + std::unique_ptr item( new TestItem( &l ) ); item->setRect( 0, 0, 55, 45 ); item->setPos( 27, 29 ); item->attemptMove( QgsLayoutPoint( 60.0, 15.0, Qgis::LayoutUnit::Millimeters ) ); @@ -1221,7 +1218,7 @@ void TestQgsLayoutItem::setSceneRect() //resize test item (no restrictions), same units as layout l.setUnits( Qgis::LayoutUnit::Millimeters ); - std::unique_ptr< TestItem > item( new TestItem( &l ) ); + std::unique_ptr item( new TestItem( &l ) ); const QSignalSpy spySizeChanged( item.get(), &QgsLayoutItem::sizePositionChanged ); item->attemptSetSceneRect( QRectF( 27.0, 29.0, 100, 200 ) ); @@ -1277,7 +1274,7 @@ void TestQgsLayoutItem::page() QCOMPARE( item->pagePositionWithUnits(), QgsLayoutPoint( 5, 5 ) ); // add pages - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 500, 100, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QCOMPARE( item->page(), 0 ); @@ -1398,8 +1395,8 @@ void TestQgsLayoutItem::itemVariablesFunction() r = e4.evaluate( &c ); QCOMPARE( r.toString(), QString( "degrees" ) ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "A" ), QStringLiteral( "memory" ) ); - std::unique_ptr< QgsVectorLayer > layer2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "B" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "A" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer2 = std::make_unique( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "B" ), QStringLiteral( "memory" ) ); map->setLayers( QList() << layer.get() << layer2.get() ); QgsExpression e5( QStringLiteral( "map_get( item_variables( 'Map_id' ), 'map_layer_ids' )" ) ); r = e5.evaluate( &c ); @@ -1413,8 +1410,8 @@ void TestQgsLayoutItem::variables() { QgsLayout l( QgsProject::instance() ); - std::unique_ptr< QgsLayoutItemMap > map = std::make_unique< QgsLayoutItemMap >( &l ); - std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::layoutItemScope( map.get() ) ); + std::unique_ptr map = std::make_unique( &l ); + std::unique_ptr scope( QgsExpressionContextUtils::layoutItemScope( map.get() ) ); const int before = scope->variableCount(); QgsExpressionContextUtils::setLayoutItemVariable( map.get(), QStringLiteral( "var" ), 5 ); @@ -1462,29 +1459,29 @@ void TestQgsLayoutItem::mapCreditsFunction() QCOMPARE( r.toString(), QString() ); // with layers - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "A" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "A" ), QStringLiteral( "memory" ) ); QgsLayerMetadata metadata; metadata.setRights( QStringList() << QStringLiteral( "CC BY SA" ) ); layer->setMetadata( metadata ); - std::unique_ptr< QgsVectorLayer > layer2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "B" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer2 = std::make_unique( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "B" ), QStringLiteral( "memory" ) ); metadata.setRights( QStringList() << QStringLiteral( "CC NC" ) ); layer2->setMetadata( metadata ); - std::unique_ptr< QgsVectorLayer > layer3 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "C" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer3 = std::make_unique( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "C" ), QStringLiteral( "memory" ) ); metadata.setRights( QStringList() << QStringLiteral( "CC BY SA" ) ); layer3->setMetadata( metadata ); - const std::unique_ptr< QgsVectorLayer > layer4 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "C" ), QStringLiteral( "memory" ) ); + const std::unique_ptr layer4 = std::make_unique( QStringLiteral( "Point?field=id_a:integer" ), QStringLiteral( "C" ), QStringLiteral( "memory" ) ); - map->setLayers( QList() << layer.get() << layer2.get() << layer3.get() << layer4.get() ); + map->setLayers( QList() << layer.get() << layer2.get() << layer3.get() << layer4.get() ); e.prepare( &c ); QCOMPARE( e.evaluate( &c ).toString(), QStringLiteral( "CC BY SA,CC NC" ) ); - map->setLayers( QList() << layer.get() << layer3.get() << layer4.get() ); + map->setLayers( QList() << layer.get() << layer3.get() << layer4.get() ); e.prepare( &c ); QCOMPARE( e.evaluate( &c ).toString(), QStringLiteral( "CC BY SA" ) ); QgsExpression e2( QStringLiteral( "array_to_string( map_credits( 'Map_id', include_layer_names:=true ) )" ) ); e2.prepare( &c ); QCOMPARE( e2.evaluate( &c ).toString(), QStringLiteral( "A: CC BY SA,C: CC BY SA" ) ); - map->setLayers( QList() << layer.get() << layer2.get() << layer3.get() << layer4.get() ); + map->setLayers( QList() << layer.get() << layer2.get() << layer3.get() << layer4.get() ); QgsExpression e3( QStringLiteral( "array_to_string( map_credits( 'Map_id', include_layer_names:=true, layer_name_separator:='|' ) )" ) ); e3.prepare( &c ); QCOMPARE( e3.evaluate( &c ).toString(), QStringLiteral( "A|CC BY SA,B|CC NC,C|CC BY SA" ) ); @@ -1496,7 +1493,7 @@ void TestQgsLayoutItem::mapCreditsFunction() map2->setExtent( extent ); l.addLayoutItem( map2 ); map2->setId( QStringLiteral( "Map_2" ) ); - map2->setLayers( QList() << layer.get() << layer4.get() ); + map2->setLayers( QList() << layer.get() << layer4.get() ); QgsExpression e4( QStringLiteral( "array_to_string( map_credits( 'Map_2', include_layer_names:=true ) )" ) ); e4.prepare( &c ); QCOMPARE( e4.evaluate( &c ).toString(), QStringLiteral( "A: CC BY SA" ) ); @@ -1573,7 +1570,7 @@ void TestQgsLayoutItem::rotation() QCOMPARE( item->sceneBoundingRect().bottom(), 18.0 ); // set rotation, using top left - std::unique_ptr< TestItem > item2( new TestItem( &l ) ); + std::unique_ptr item2( new TestItem( &l ) ); item2->attemptMove( QgsLayoutPoint( 5.0, 8.0 ) ); item2->attemptResize( QgsLayoutSize( 10.0, 6.0 ) ); item2->setItemRotation( 90, false ); @@ -1588,7 +1585,7 @@ void TestQgsLayoutItem::rotation() QCOMPARE( item2->pos().y(), 16.0 ); // test that refresh rotation doesn't move item (#18037) - item2 = std::make_unique< TestItem >( &l ); + item2 = std::make_unique( &l ); item2->setReferencePoint( QgsLayoutItem::Middle ); item2->attemptMove( QgsLayoutPoint( 5.0, 8.0 ) ); item2->attemptResize( QgsLayoutSize( 10.0, 6.0 ) ); @@ -1669,9 +1666,9 @@ void TestQgsLayoutItem::rotation() void TestQgsLayoutItem::writeXml() { QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); @@ -1696,9 +1693,9 @@ void TestQgsLayoutItem::writeXml() void TestQgsLayoutItem::readXml() { QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QgsProject proj; @@ -1745,7 +1742,7 @@ void TestQgsLayoutItem::writeReadXmlProperties() original->setItemOpacity( 0.75 ); original->setCustomProperty( QStringLiteral( "pdfExportGroup" ), QStringLiteral( "_export_layer_" ) ); - std::unique_ptr< QgsLayoutItem > copy = createCopyViaXml( &l, original ); + std::unique_ptr copy = createCopyViaXml( &l, original ); QCOMPARE( copy->uuid(), original->uuid() ); QCOMPARE( copy->id(), original->id() ); @@ -1771,7 +1768,7 @@ void TestQgsLayoutItem::writeReadXmlProperties() QVERIFY( !copy->hasBackground() ); QCOMPARE( copy->backgroundColor(), QColor( 200, 150, 100 ) ); QCOMPARE( copy->blendMode(), QPainter::CompositionMode_Darken ); - QVERIFY( copy->excludeFromExports( ) ); + QVERIFY( copy->excludeFromExports() ); QCOMPARE( copy->itemOpacity(), 0.75 ); QCOMPARE( copy->customProperty( QStringLiteral( "pdfExportGroup" ) ).toString(), QStringLiteral( "_export_layer_" ) ); delete original; @@ -1784,7 +1781,7 @@ void TestQgsLayoutItem::undoRedo() QgsLayoutItemShape *item = new QgsLayoutItemShape( &l ); const QString uuid = item->uuid(); - QPointer< QgsLayoutItemShape > pItem( item ); // for testing deletion + QPointer pItem( item ); // for testing deletion item->setFrameStrokeColor( QColor( 255, 100, 200 ) ); l.addLayoutItem( item ); @@ -1802,7 +1799,7 @@ void TestQgsLayoutItem::undoRedo() // redo should restore l.undoStack()->stack()->redo(); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); - item = dynamic_cast< QgsLayoutItemShape * >( l.itemByUuid( uuid ) ); + item = dynamic_cast( l.itemByUuid( uuid ) ); QVERIFY( item ); QVERIFY( l.items().contains( item ) ); pItem = item; @@ -1820,7 +1817,7 @@ void TestQgsLayoutItem::undoRedo() // redo should restore l.undoStack()->stack()->redo(); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); - item = dynamic_cast< QgsLayoutItemShape * >( l.itemByUuid( uuid ) ); + item = dynamic_cast( l.itemByUuid( uuid ) ); QVERIFY( item ); QVERIFY( l.items().contains( item ) ); pItem = item; @@ -1837,7 +1834,7 @@ void TestQgsLayoutItem::undoRedo() // undo should restore l.undoStack()->stack()->undo(); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); - item = dynamic_cast< QgsLayoutItemShape * >( l.itemByUuid( uuid ) ); + item = dynamic_cast( l.itemByUuid( uuid ) ); QVERIFY( item ); QVERIFY( l.items().contains( item ) ); pItem = item; @@ -1853,7 +1850,7 @@ void TestQgsLayoutItem::undoRedo() // redo should restore l.undoStack()->stack()->redo(); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); - item = dynamic_cast< QgsLayoutItemShape * >( l.itemByUuid( uuid ) ); + item = dynamic_cast( l.itemByUuid( uuid ) ); QVERIFY( item ); QVERIFY( l.items().contains( item ) ); pItem = item; @@ -1865,7 +1862,6 @@ void TestQgsLayoutItem::undoRedo() QVERIFY( !pItem ); QVERIFY( !l.items().contains( item ) ); QVERIFY( !l.itemByUuid( uuid ) ); - } void TestQgsLayoutItem::multiItemUndo() @@ -1924,7 +1920,6 @@ void TestQgsLayoutItem::overlappingUndo() l.undoStack()->stack()->undo(); QCOMPARE( item2->positionWithUnits(), QgsLayoutPoint( 20, 20 ) ); QCOMPARE( item->positionWithUnits(), QgsLayoutPoint( 10, 10 ) ); - } void TestQgsLayoutItem::blendMode() @@ -2066,12 +2061,12 @@ void TestQgsLayoutItem::excludeFromExports() QgsProject proj; QgsLayout l( &proj ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol( new QgsFillSymbol() ); + std::unique_ptr fillSymbol( new QgsFillSymbol() ); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( Qt::transparent ); simpleFill->setStrokeColor( Qt::transparent ); @@ -2102,16 +2097,16 @@ std::unique_ptr TestQgsLayoutItem::createCopyViaXml( QgsLayout *l { //save original item to xml QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); original->writeXml( rootNode, doc, QgsReadWriteContext() ); //create new item and restore settings from xml - std::unique_ptr< TestItem > copy = std::make_unique< TestItem >( layout ); + std::unique_ptr copy = std::make_unique( layout ); copy->readXml( rootNode.firstChildElement(), doc, QgsReadWriteContext() ); return std::move( copy ); diff --git a/tests/src/core/testqgslayoutitemgroup.cpp b/tests/src/core/testqgslayoutitemgroup.cpp index ee4ba0d53576..0f363b59ac74 100644 --- a/tests/src/core/testqgslayoutitemgroup.cpp +++ b/tests/src/core/testqgslayoutitemgroup.cpp @@ -32,16 +32,17 @@ class TestQgsLayoutItemGroup : public QgsTest Q_OBJECT public: - TestQgsLayoutItemGroup() : QgsTest( QStringLiteral( "Layout Group Item" ) ) {} + TestQgsLayoutItemGroup() + : QgsTest( QStringLiteral( "Layout Group Item" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void createGroupDirect(); void createGroup(); //test grouping items - void ungroup(); //test ungrouping items + void ungroup(); //test ungrouping items void deleteGroup(); //test deleting group works void groupVisibility(); void moveGroup(); @@ -51,20 +52,17 @@ class TestQgsLayoutItemGroup : public QgsTest void undoRedo(); //test that group/ungroup undo/redo commands don't crash private: - void dumpUndoStack( const QUndoStack &, QString prefix = QString() ) const; - }; // private void TestQgsLayoutItemGroup::dumpUndoStack( const QUndoStack &us, QString prefix ) const { - if ( ! prefix.isEmpty() ) prefix += QLatin1String( ": " ); + if ( !prefix.isEmpty() ) + prefix += QLatin1String( ": " ); for ( int i = 0; i < us.count(); ++i ) { - QgsDebugMsgLevel( QStringLiteral( "%4US %1: %2%3" ) - .arg( i ). arg( i >= us.index() ? "-" : "", - us.text( i ), prefix ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "%4US %1: %2%3" ).arg( i ).arg( i >= us.index() ? "-" : "", us.text( i ), prefix ), 1 ); } } @@ -81,12 +79,10 @@ void TestQgsLayoutItemGroup::cleanupTestCase() void TestQgsLayoutItemGroup::init() { - } void TestQgsLayoutItemGroup::cleanup() { - } void TestQgsLayoutItemGroup::createGroupDirect() @@ -137,7 +133,7 @@ void TestQgsLayoutItemGroup::createGroupDirect() QVERIFY( l.items().contains( item2 ) ); // manually delete an item - const QPointer< QgsLayoutItemShape > pItem( item ); // for testing deletion + const QPointer pItem( item ); // for testing deletion l.removeLayoutItem( item ); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); QVERIFY( !pItem ); @@ -147,7 +143,7 @@ void TestQgsLayoutItemGroup::createGroupDirect() QCOMPARE( group->items().count(), 1 ); QVERIFY( group->items().contains( item2 ) ); - const QPointer< QgsLayoutItemShape > pItem2( item2 ); // for testing deletion + const QPointer pItem2( item2 ); // for testing deletion // remove items group->removeItems(); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); @@ -214,7 +210,7 @@ void TestQgsLayoutItemGroup::ungroup() QVERIFY( groups.contains( group ) ); QCOMPARE( group->layout(), &l ); - const QPointer< QgsLayoutItemGroup > pGroup( group ); // for testing deletion + const QPointer pGroup( group ); // for testing deletion //ungroup group QList ungroupedItems; ungroupedItems = l.ungroupItems( group ); @@ -249,17 +245,17 @@ void TestQgsLayoutItemGroup::deleteGroup() QgsLayout l( &proj ); QgsLayoutItemShape *item = new QgsLayoutItemShape( &l ); - const QPointer< QgsLayoutItemShape > pItem( item ); // for testing deletion + const QPointer pItem( item ); // for testing deletion l.addLayoutItem( item ); QgsLayoutItemShape *item2 = new QgsLayoutItemShape( &l ); - const QPointer< QgsLayoutItemShape > pItem2( item2 ); // for testing deletion + const QPointer pItem2( item2 ); // for testing deletion l.addLayoutItem( item2 ); //group items QList groupItems; groupItems << item << item2; QgsLayoutItemGroup *group = l.groupItems( groupItems ); - const QPointer< QgsLayoutItemGroup > pGroup( group ); // for testing deletion + const QPointer pGroup( group ); // for testing deletion QList items; l.layoutItems( items ); @@ -444,7 +440,7 @@ void TestQgsLayoutItemGroup::resizeGroup() QCOMPARE( group->positionWithUnits().y(), 76.2 ); QCOMPARE( group->positionWithUnits().units(), Qgis::LayoutUnit::Millimeters ); QCOMPARE( group->sizeWithUnits().width(), 102.4 ); - QCOMPARE( group->sizeWithUnits().height(), 163.8 ); + QCOMPARE( group->sizeWithUnits().height(), 163.8 ); QCOMPARE( group->sizeWithUnits().units(), Qgis::LayoutUnit::Millimeters ); group->attemptResize( QgsLayoutSize( 50.8, 76.2, Qgis::LayoutUnit::Millimeters ) ); @@ -452,7 +448,7 @@ void TestQgsLayoutItemGroup::resizeGroup() QCOMPARE( group->positionWithUnits().y(), 76.2 ); QCOMPARE( group->positionWithUnits().units(), Qgis::LayoutUnit::Millimeters ); QCOMPARE( group->sizeWithUnits().width(), 50.8 ); - QCOMPARE( group->sizeWithUnits().height(), 76.2 ); + QCOMPARE( group->sizeWithUnits().height(), 76.2 ); QCOMPARE( group->sizeWithUnits().units(), Qgis::LayoutUnit::Millimeters ); QCOMPARE( item->positionWithUnits().x(), 0.05 ); QGSCOMPARENEAR( item->positionWithUnits().y(), 0.0826198, 0.00001 ); @@ -464,7 +460,7 @@ void TestQgsLayoutItemGroup::resizeGroup() QGSCOMPARENEAR( item2->positionWithUnits().y(), 3.000000, 0.0001 ); QCOMPARE( item2->positionWithUnits().units(), Qgis::LayoutUnit::Inches ); QGSCOMPARENEAR( item2->sizeWithUnits().width(), 1.98438, 0.0001 ); - QGSCOMPARENEAR( item2->sizeWithUnits().height(), 2.791209, 0.0001 ); + QGSCOMPARENEAR( item2->sizeWithUnits().height(), 2.791209, 0.0001 ); QCOMPARE( item2->sizeWithUnits().units(), Qgis::LayoutUnit::Inches ); } @@ -551,21 +547,21 @@ void TestQgsLayoutItemGroup::undoRedo() QgsLayoutItemShape *item1 = nullptr; QgsLayoutItemShape *item2 = nullptr; -// int shapesAdded = 0; -// int groupsAdded = 0; -// int itemsRemoved = 0; + // int shapesAdded = 0; + // int groupsAdded = 0; + // int itemsRemoved = 0; qRegisterMetaType(); -// QSignalSpy spyPolygonAdded( &l, &QgsLayout::itemAdded ); -// QCOMPARE( spyPolygonAdded.count(), 0 ); + // QSignalSpy spyPolygonAdded( &l, &QgsLayout::itemAdded ); + // QCOMPARE( spyPolygonAdded.count(), 0 ); qRegisterMetaType(); -// QSignalSpy spyGroupAdded( &l, &QgsLayout::composerItemGroupAdded ); -// QCOMPARE( spyGroupAdded.count(), 0 ); + // QSignalSpy spyGroupAdded( &l, &QgsLayout::composerItemGroupAdded ); + // QCOMPARE( spyGroupAdded.count(), 0 ); qRegisterMetaType(); -// QSignalSpy spyItemRemoved( &l, &QgsLayout::itemRemoved ); -// QCOMPARE( spyItemRemoved.count(), 0 ); + // QSignalSpy spyItemRemoved( &l, &QgsLayout::itemRemoved ); + // QCOMPARE( spyItemRemoved.count(), 0 ); //test for crash when undo/redoing with groups // Set initial condition @@ -576,27 +572,27 @@ void TestQgsLayoutItemGroup::undoRedo() QList items; l.layoutItems( items ); QCOMPARE( items.size(), 0 ); - QgsDebugMsgLevel( QStringLiteral( "clear stack count:%1 index:%2" ) .arg( us->count() ) .arg( us->index() ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "clear stack count:%1 index:%2" ).arg( us->count() ).arg( us->index() ), 1 ); //create some items item1 = new QgsLayoutItemShape( &l ); item1->attemptMove( QgsLayoutPoint( 0.05, 0.09, Qgis::LayoutUnit::Meters ) ); - QPointer< QgsLayoutItem > pItem1( item1 ); + QPointer pItem1( item1 ); const QString item1Uuid = item1->uuid(); item1->attemptResize( QgsLayoutSize( 0.1, 0.15, Qgis::LayoutUnit::Meters ) ); l.addLayoutItem( item1 ); -// QCOMPARE( spyPolygonAdded.count(), ++shapesAdded ); + // QCOMPARE( spyPolygonAdded.count(), ++shapesAdded ); item2 = new QgsLayoutItemShape( &l ); - QPointer< QgsLayoutItem > pItem2( item2 ); + QPointer pItem2( item2 ); const QString item2Uuid = item2->uuid(); item2->attemptMove( QgsLayoutPoint( 2, 3, Qgis::LayoutUnit::Millimeters ) ); item2->attemptResize( QgsLayoutSize( 4, 6, Qgis::LayoutUnit::Millimeters ) ); l.addLayoutItem( item2 ); -// QCOMPARE( spyPolygonAdded.count(), ++shapesAdded ); + // QCOMPARE( spyPolygonAdded.count(), ++shapesAdded ); l.layoutItems( items ); QCOMPARE( items.size(), 2 ); // 2 shapes - QgsDebugMsgLevel( QStringLiteral( "addedItems stack count:%1 index:%2" ) .arg( us->count() ) .arg( us->index() ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "addedItems stack count:%1 index:%2" ).arg( us->count() ).arg( us->index() ), 1 ); QCOMPARE( item1->pos(), QPointF( 50, 90 ) ); QCOMPARE( item2->pos(), QPointF( 2, 3 ) ); //dumpUndoStack(*us, "after initial items addition"); @@ -606,9 +602,9 @@ void TestQgsLayoutItemGroup::undoRedo() items << item1 << item2; QgsLayoutItemGroup *group = l.groupItems( items ); const QString groupUuid = group->uuid(); -// QCOMPARE( spyPolygonAdded.count(), shapesAdded ); -// QCOMPARE( spyGroupAdded.count(), ++groupsAdded ); -// QCOMPARE( spyItemRemoved.count(), itemsRemoved ); + // QCOMPARE( spyPolygonAdded.count(), shapesAdded ); + // QCOMPARE( spyGroupAdded.count(), ++groupsAdded ); + // QCOMPARE( spyItemRemoved.count(), itemsRemoved ); QCOMPARE( group->items().size(), 2 ); l.layoutItems( items ); QCOMPARE( items.size(), 3 ); // 2 shapes, 1 group @@ -620,30 +616,30 @@ void TestQgsLayoutItemGroup::undoRedo() //move group QgsDebugMsgLevel( QStringLiteral( "moving group" ), 1 ); group->attemptMove( QgsLayoutPoint( 10.0, 20.0 ) ); -// QCOMPARE( spyPolygonAdded.count(), shapesAdded ); -// QCOMPARE( spyGroupAdded.count(), groupsAdded ); -// QCOMPARE( spyItemRemoved.count(), itemsRemoved ); - QgsDebugMsgLevel( QStringLiteral( "groupItems stack count:%1 index:%2" ) .arg( us->count() ) .arg( us->index() ), 1 ); + // QCOMPARE( spyPolygonAdded.count(), shapesAdded ); + // QCOMPARE( spyGroupAdded.count(), groupsAdded ); + // QCOMPARE( spyItemRemoved.count(), itemsRemoved ); + QgsDebugMsgLevel( QStringLiteral( "groupItems stack count:%1 index:%2" ).arg( us->count() ).arg( us->index() ), 1 ); QCOMPARE( group->items().size(), 2 ); l.layoutItems( items ); QCOMPARE( items.size(), 3 ); // 2 shapes, 1 group QCOMPARE( item1->pos(), QPointF( 58, 107 ) ); - QCOMPARE( item2->pos(), QPointF( 10, 20 ) ); - QCOMPARE( group->pos(), QPointF( 10, 20 ) ); + QCOMPARE( item2->pos(), QPointF( 10, 20 ) ); + QCOMPARE( group->pos(), QPointF( 10, 20 ) ); //ungroup - QPointer< QgsLayoutItemGroup > pGroup( group ); // for testing deletion + QPointer pGroup( group ); // for testing deletion QgsDebugMsgLevel( QStringLiteral( "ungrouping" ), 1 ); l.ungroupItems( group ); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); -// QCOMPARE( spyPolygonAdded.count(), shapesAdded ); -// QCOMPARE( spyGroupAdded.count(), groupsAdded ); -// QCOMPARE( spyItemRemoved.count(), ++itemsRemoved ); + // QCOMPARE( spyPolygonAdded.count(), shapesAdded ); + // QCOMPARE( spyGroupAdded.count(), groupsAdded ); + // QCOMPARE( spyItemRemoved.count(), ++itemsRemoved ); l.layoutItems( items ); QCOMPARE( items.size(), 2 ); // 2 shapes QCOMPARE( item1->pos(), QPointF( 58, 107 ) ); - QCOMPARE( item2->pos(), QPointF( 10, 20 ) ); + QCOMPARE( item2->pos(), QPointF( 10, 20 ) ); QVERIFY( !pGroup ); //dumpUndoStack(*us, "after ungroup"); // US 0: Items grouped @@ -653,9 +649,9 @@ void TestQgsLayoutItemGroup::undoRedo() //undo (groups again) -- crashed here before #11371 got fixed QgsDebugMsgLevel( QStringLiteral( "undo ungrouping" ), 1 ); us->undo(); -// QCOMPARE( spyPolygonAdded.count(), shapesAdded ); -// QCOMPARE( spyGroupAdded.count(), ++groupsAdded ); -// QCOMPARE( spyItemRemoved.count(), itemsRemoved ); + // QCOMPARE( spyPolygonAdded.count(), shapesAdded ); + // QCOMPARE( spyGroupAdded.count(), ++groupsAdded ); + // QCOMPARE( spyItemRemoved.count(), itemsRemoved ); QVERIFY( item1->isGroupMember() ); QVERIFY( item2->isGroupMember() ); QCOMPARE( item1->parentGroup(), item2->parentGroup() ); @@ -667,9 +663,9 @@ void TestQgsLayoutItemGroup::undoRedo() l.layoutItems( items ); QCOMPARE( items.size(), 3 ); // 2 shapes, 1 group QCOMPARE( item1->pos(), QPointF( 58, 107 ) ); - QCOMPARE( item2->pos(), QPointF( 10, 20 ) ); + QCOMPARE( item2->pos(), QPointF( 10, 20 ) ); - QCOMPARE( group->pos(), QPointF( 10, 20 ) ); + QCOMPARE( group->pos(), QPointF( 10, 20 ) ); //dumpUndoStack(*us, "after undo ungroup"); // US 0: Items grouped // US 1: move group @@ -678,7 +674,7 @@ void TestQgsLayoutItemGroup::undoRedo() //remove group QgsDebugMsgLevel( QStringLiteral( "remove group" ), 1 ); l.removeLayoutItem( group ); -// QCOMPARE( spyPolygonAdded.count(), shapesAdded ); + // QCOMPARE( spyPolygonAdded.count(), shapesAdded ); //QCOMPARE( spyGroupAdded.count(), groupsAdded ); //itemsRemoved += 3; // the group and the two items //QCOMPARE( spyItemRemoved.count(), itemsRemoved ); @@ -690,7 +686,7 @@ void TestQgsLayoutItemGroup::undoRedo() l.layoutItems( items ); QCOMPARE( items.size(), 0 ); // nothing - QgsDebugMsgLevel( QStringLiteral( "remove stack count:%1 index:%2" ) .arg( us->count() ) .arg( us->index() ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "remove stack count:%1 index:%2" ).arg( us->count() ).arg( us->index() ), 1 ); //dumpUndoStack(*us, "after remove group"); // US 0: Items grouped // US 1: move group @@ -704,16 +700,16 @@ void TestQgsLayoutItemGroup::undoRedo() //QCOMPARE( spyGroupAdded.count(), ++groupsAdded ); //QCOMPARE( spyItemRemoved.count(), itemsRemoved ); l.layoutItems( items ); - group = dynamic_cast< QgsLayoutItemGroup * >( l.itemByUuid( groupUuid ) ); + group = dynamic_cast( l.itemByUuid( groupUuid ) ); QVERIFY( group ); QCOMPARE( group->items().size(), 2 ); QCOMPARE( items.size(), 3 ); // 2 shapes, 1 group - item1 = dynamic_cast< QgsLayoutItemShape * >( l.itemByUuid( item1Uuid ) ); + item1 = dynamic_cast( l.itemByUuid( item1Uuid ) ); QCOMPARE( item1->parentGroup(), group ); - item2 = dynamic_cast< QgsLayoutItemShape * >( l.itemByUuid( item2Uuid ) ); + item2 = dynamic_cast( l.itemByUuid( item2Uuid ) ); QCOMPARE( item2->parentGroup(), group ); - QgsDebugMsgLevel( QStringLiteral( "undo stack count:%1 index:%2" ) .arg( us->count() ) .arg( us->index() ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "undo stack count:%1 index:%2" ).arg( us->count() ).arg( us->index() ), 1 ); //dumpUndoStack(*us, "after undo remove group"); // US 0: Items grouped // US 1: move group @@ -722,15 +718,15 @@ void TestQgsLayoutItemGroup::undoRedo() //undo move group QgsDebugMsgLevel( QStringLiteral( "undo move group" ), 1 ); us->undo(); -// QCOMPARE( spyPolygonAdded.count(), shapesAdded ); -// QCOMPARE( spyGroupAdded.count(), groupsAdded ); -// QCOMPARE( spyItemRemoved.count(), itemsRemoved ); + // QCOMPARE( spyPolygonAdded.count(), shapesAdded ); + // QCOMPARE( spyGroupAdded.count(), groupsAdded ); + // QCOMPARE( spyItemRemoved.count(), itemsRemoved ); QCOMPARE( group->items().size(), 2 ); l.layoutItems( items ); QCOMPARE( items.size(), 3 ); // 2 shapes, 1 group QCOMPARE( item1->isGroupMember(), true ); QCOMPARE( item2->isGroupMember(), true ); - QCOMPARE( item1->pos(), QPointF( 50, 90 ) ); + QCOMPARE( item1->pos(), QPointF( 50, 90 ) ); QCOMPARE( item2->pos(), QPointF( 2, 3 ) ); QCOMPARE( group->pos(), QPointF( 2, 3 ) ); //dumpUndoStack(*us, "after undo move group"); @@ -770,7 +766,7 @@ void TestQgsLayoutItemGroup::undoRedo() QCOMPARE( items.size(), 3 ); // 2 shapes, 1 group QCOMPARE( item1->isGroupMember(), true ); QCOMPARE( item2->isGroupMember(), true ); - group = dynamic_cast< QgsLayoutItemGroup * >( l.itemByUuid( groupUuid ) ); + group = dynamic_cast( l.itemByUuid( groupUuid ) ); QCOMPARE( group->pos(), QPointF( 2, 3 ) ); //dumpUndoStack(*us, "after redo group"); // US 0: Items grouped @@ -815,7 +811,7 @@ void TestQgsLayoutItemGroup::undoRedo() QVERIFY( !pItem1 ); QVERIFY( !pItem2 ); - QgsDebugMsgLevel( QStringLiteral( "undo stack count:%1 index:%2" ) .arg( us->count() ) .arg( us->index() ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "undo stack count:%1 index:%2" ).arg( us->count() ).arg( us->index() ), 1 ); //dumpUndoStack(*us, "after redo remove group"); // US 0: Items grouped // US 1: move group @@ -824,7 +820,7 @@ void TestQgsLayoutItemGroup::undoRedo() //unwind the whole stack us->clear(); - QgsDebugMsgLevel( QStringLiteral( "clear stack count:%1 index:%2" ) .arg( us->count() ) .arg( us->index() ), 1 ); + QgsDebugMsgLevel( QStringLiteral( "clear stack count:%1 index:%2" ).arg( us->count() ).arg( us->index() ), 1 ); } QGSTEST_MAIN( TestQgsLayoutItemGroup ) diff --git a/tests/src/core/testqgslayoutlabel.cpp b/tests/src/core/testqgslayoutlabel.cpp index c042edff2a56..18b0800ae832 100644 --- a/tests/src/core/testqgslayoutlabel.cpp +++ b/tests/src/core/testqgslayoutlabel.cpp @@ -38,11 +38,12 @@ class TestQgsLayoutLabel : public QgsTest Q_OBJECT public: - TestQgsLayoutLabel() : QgsTest( QStringLiteral( "Layout Label Tests" ), QStringLiteral( "composer_label" ) ) {} + TestQgsLayoutLabel() + : QgsTest( QStringLiteral( "Layout Label Tests" ), QStringLiteral( "composer_label" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. // test simple expression evaluation void evaluation(); @@ -72,11 +73,8 @@ void TestQgsLayoutLabel::initTestCase() QgsApplication::initQgis(); //create maplayers from testdata and add to layer registry - const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + '/' + "france_parts.shp" ); - mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); - + const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + '/' + "france_parts.shp" ); + mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); } void TestQgsLayoutLabel::cleanupTestCase() @@ -366,7 +364,7 @@ void TestQgsLayoutLabel::renderAsHtmlRelative() label->setMargin( 1 ); l.addLayoutItem( label ); - QgsProject::instance()->setFileName( QStringLiteral( TEST_DATA_DIR ) + QDir::separator() + "test.qgs" ); + QgsProject::instance()->setFileName( QStringLiteral( TEST_DATA_DIR ) + QDir::separator() + "test.qgs" ); label->setText( QStringLiteral( "test " ) ); QgsTextFormat format; diff --git a/tests/src/core/testqgslayoutmanualtable.cpp b/tests/src/core/testqgslayoutmanualtable.cpp index 4913848b305f..221286603342 100644 --- a/tests/src/core/testqgslayoutmanualtable.cpp +++ b/tests/src/core/testqgslayoutmanualtable.cpp @@ -34,11 +34,12 @@ class TestQgsLayoutManualTable : public QgsTest Q_OBJECT public: - TestQgsLayoutManualTable() : QgsTest( QStringLiteral( "Layout Manual Table Tests" ), QStringLiteral( "layout_manual_table" ) ) {} + TestQgsLayoutManualTable() + : QgsTest( QStringLiteral( "Layout Manual Table Tests" ), QStringLiteral( "layout_manual_table" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void setContents(); void scopeForCell(); @@ -56,7 +57,6 @@ class TestQgsLayoutManualTable : public QgsTest void mergedCellsBackgroundColor(); private: - //compares rows in table to expected rows void compareTable( QgsLayoutItemManualTable *table, const QVector &expectedRows ); }; @@ -168,8 +168,7 @@ void TestQgsLayoutManualTable::setContents() row << QStringLiteral( "A" ) << QString() << QString(); expectedRows.append( row ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) ) ); compareTable( table, expectedRows ); QCOMPARE( table->tableContents().size(), 2 ); QCOMPARE( table->tableContents().at( 0 ).size(), 3 ); @@ -188,8 +187,7 @@ void TestQgsLayoutManualTable::setContents() row << QStringLiteral( "A" ) << QStringLiteral( "B" ) << QString(); expectedRows.append( row ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) ) ); compareTable( table, expectedRows ); QCOMPARE( table->tableContents().size(), 2 ); QCOMPARE( table->tableContents().at( 0 ).size(), 3 ); @@ -209,8 +207,7 @@ void TestQgsLayoutManualTable::setContents() row << QStringLiteral( "A" ) << QStringLiteral( "B" ) << QStringLiteral( "C" ); expectedRows.append( row ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); compareTable( table, expectedRows ); QCOMPARE( table->tableContents().size(), 2 ); QCOMPARE( table->tableContents().at( 0 ).size(), 3 ); @@ -222,16 +219,16 @@ void TestQgsLayoutManualTable::setContents() QCOMPARE( table->tableContents().at( 1 ).at( 1 ).content().toString(), QStringLiteral( "B" ) ); QCOMPARE( table->tableContents().at( 1 ).at( 2 ).content().toString(), QStringLiteral( "C" ) ); - table->setRowHeights( QList< double >() << 5.5 << 4.0 ); - table->setColumnWidths( QList< double >() << 15.5 << 14.0 << 13.4 ); + table->setRowHeights( QList() << 5.5 << 4.0 ); + table->setColumnWidths( QList() << 15.5 << 14.0 << 13.4 ); // save and restore //write to XML QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement tableElement = doc.createElement( QStringLiteral( "table" ) ); QVERIFY( table->writeXml( tableElement, doc, QgsReadWriteContext(), true ) ); @@ -250,8 +247,8 @@ void TestQgsLayoutManualTable::setContents() QCOMPARE( tableFromXml->tableContents().at( 1 ).at( 1 ).content().toString(), QStringLiteral( "B" ) ); QCOMPARE( tableFromXml->tableContents().at( 1 ).at( 2 ).content().toString(), QStringLiteral( "C" ) ); - QCOMPARE( tableFromXml->rowHeights(), QList< double >() << 5.5 << 4.0 ); - QCOMPARE( tableFromXml->columnWidths(), QList< double >() << 15.5 << 14.0 << 13.4 ); + QCOMPARE( tableFromXml->rowHeights(), QList() << 5.5 << 4.0 ); + QCOMPARE( tableFromXml->columnWidths(), QList() << 15.5 << 14.0 << 13.4 ); } void TestQgsLayoutManualTable::scopeForCell() @@ -261,7 +258,7 @@ void TestQgsLayoutManualTable::scopeForCell() l.setName( QStringLiteral( "my layout" ) ); QgsLayoutItemManualTable *table = new QgsLayoutItemManualTable( &l ); - std::unique_ptr< QgsExpressionContextScope > scope( table->scopeForCell( 1, 2 ) ); + std::unique_ptr scope( table->scopeForCell( 1, 2 ) ); // variable values for row/col should start at 1, not 0! QCOMPARE( scope->variable( QStringLiteral( "row_number" ) ).toInt(), 2 ); @@ -288,16 +285,17 @@ void TestQgsLayoutManualTable::expressionContents() table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QgsProperty::fromExpression( QStringLiteral( "@row_number || ',' || @column_number" ) ) ) << QgsTableCell( QgsProperty::fromExpression( QStringLiteral( "@row_number || ',' || @column_number" ) ) ) ) - << ( QgsTableRow() << QgsTableCell( QgsProperty::fromExpression( QStringLiteral( "@layout_name" ) ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) ); + << ( QgsTableRow() << QgsTableCell( QgsProperty::fromExpression( QStringLiteral( "@layout_name" ) ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) + ); compareTable( table, expectedRows ); // save and restore //write to XML QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement tableElement = doc.createElement( QStringLiteral( "table" ) ); QVERIFY( table->writeXml( tableElement, doc, QgsReadWriteContext(), true ) ); @@ -326,8 +324,7 @@ void TestQgsLayoutManualTable::cellStyles() const QgsTableCell c23; table->setBackgroundColor( QColor() ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << c11 << c12 << c13 ) - << ( QgsTableRow() << c21 << c22 << c23 ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << c11 << c12 << c13 ) << ( QgsTableRow() << c21 << c22 << c23 ) ); QCOMPARE( table->backgroundColor( 0, 0 ), QColor() ); QCOMPARE( table->backgroundColor( 0, 1 ), QColor( 255, 0, 0 ) ); QCOMPARE( table->backgroundColor( 0, 2 ), QColor() ); @@ -358,7 +355,7 @@ void TestQgsLayoutManualTable::cellFormat() QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -385,10 +382,9 @@ void TestQgsLayoutManualTable::rowHeight() table->setHorizontalGrid( true ); table->setVerticalGrid( true ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); - table->setRowHeights( QList< double >() << 0 << 40.0 ); + table->setRowHeights( QList() << 0 << 40.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_rowheight" ), &l ); } @@ -410,10 +406,9 @@ void TestQgsLayoutManualTable::columnWidth() table->setHorizontalGrid( true ); table->setVerticalGrid( true ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); - table->setColumnWidths( QList< double >() << 0 << 10.0 << 30.0 ); + table->setColumnWidths( QList() << 0 << 10.0 << 30.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_columnwidth" ), &l ); } @@ -438,12 +433,9 @@ void TestQgsLayoutManualTable::headers() table->setHorizontalGrid( true ); table->setVerticalGrid( true ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << QgsTableCell( QStringLiteral( "Helicopter" ) ) << QgsTableCell( QStringLiteral( "Plane" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) ); table->setIncludeTableHeader( true ); - table->setHeaders( QgsLayoutTableColumns() << QgsLayoutTableColumn( QStringLiteral( "header1" ) ) - << QgsLayoutTableColumn( QStringLiteral( "h2" ) ) - << QgsLayoutTableColumn( QStringLiteral( "header 3" ) ) ); + table->setHeaders( QgsLayoutTableColumns() << QgsLayoutTableColumn( QStringLiteral( "header1" ) ) << QgsLayoutTableColumn( QStringLiteral( "h2" ) ) << QgsLayoutTableColumn( QStringLiteral( "header 3" ) ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_headers" ), &l ); } @@ -490,10 +482,9 @@ void TestQgsLayoutManualTable::cellTextFormat() f3.buffer().setSize( 1 ); c5.setTextFormat( f3 ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << c1 << QgsTableCell( QStringLiteral( "Helicopter" ) ) << c3 ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << c5 << QgsTableCell( QStringLiteral( "C" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << c1 << QgsTableCell( QStringLiteral( "Helicopter" ) ) << c3 ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << c5 << QgsTableCell( QStringLiteral( "C" ) ) ) ); - table->setColumnWidths( QList< double >() << 0 << 0.0 << 30.0 ); + table->setColumnWidths( QList() << 0 << 0.0 << 30.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_textformat" ), &l ); } @@ -527,10 +518,9 @@ void TestQgsLayoutManualTable::cellTextAlignment() c5.setHorizontalAlignment( Qt::AlignRight ); c5.setVerticalAlignment( Qt::AlignTop ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << c1 << QgsTableCell( QStringLiteral( "Helicopter\nHelicopter" ) ) << c3 ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << c5 << QgsTableCell( QStringLiteral( "C" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << c1 << QgsTableCell( QStringLiteral( "Helicopter\nHelicopter" ) ) << c3 ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << c5 << QgsTableCell( QStringLiteral( "C" ) ) ) ); - table->setColumnWidths( QList< double >() << 0 << 0.0 << 30.0 ); + table->setColumnWidths( QList() << 0 << 0.0 << 30.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_textalign" ), &l ); } @@ -568,13 +558,9 @@ void TestQgsLayoutManualTable::mergedCells() c5.setSpan( 1, 3 ); c5.setBackgroundColor( QColor( 200, 250, 200 ) ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << c1 << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "Something" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << c3 ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "D" ) ) << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) - << ( QgsTableRow() << c5 << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << c1 << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "Something" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << c3 ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "D" ) ) << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) << ( QgsTableRow() << c5 << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); - table->setColumnWidths( QList< double >() << 30 << 50.0 << 40.0 << 25.0 ); + table->setColumnWidths( QList() << 30 << 50.0 << 40.0 << 25.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_merged" ), &l ); } @@ -612,13 +598,9 @@ void TestQgsLayoutManualTable::mergedCellsVertOnly() c5.setSpan( 1, 3 ); c5.setBackgroundColor( QColor( 200, 250, 200 ) ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << c1 << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "Something" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << c3 ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "D" ) ) << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) - << ( QgsTableRow() << c5 << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << c1 << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "Something" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << c3 ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "D" ) ) << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) << ( QgsTableRow() << c5 << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); - table->setColumnWidths( QList< double >() << 30 << 50.0 << 40.0 << 25.0 ); + table->setColumnWidths( QList() << 30 << 50.0 << 40.0 << 25.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_merged_vert_only" ), &l ); } @@ -656,13 +638,9 @@ void TestQgsLayoutManualTable::mergedCellsHozOnly() c5.setSpan( 1, 3 ); c5.setBackgroundColor( QColor( 200, 250, 200 ) ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << c1 << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "Something" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << c3 ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "D" ) ) << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) - << ( QgsTableRow() << c5 << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << c1 << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "Something" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "C" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << c3 ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "D" ) ) << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) << ( QgsTableRow() << c5 << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); - table->setColumnWidths( QList< double >() << 30 << 50.0 << 40.0 << 25.0 ); + table->setColumnWidths( QList() << 30 << 50.0 << 40.0 << 25.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_merged_hoz_only" ), &l ); } @@ -717,13 +695,9 @@ void TestQgsLayoutManualTable::mergedCellsBackgroundColor() c4.setVerticalAlignment( Qt::AlignTop ); c4.setSpan( 2, 1 ); - table->setTableContents( QgsTableContents() << ( QgsTableRow() << c1 << QgsTableCell( QStringLiteral( "A2" ) ) << c1 << QgsTableCell( QStringLiteral( "Something" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "B2" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "C2" ) ) << QgsTableCell( QStringLiteral( "C3" ) ) << c3 ) - << ( QgsTableRow() << c4 << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "D2" ) ) << QgsTableCell( QStringLiteral( "D3" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); + table->setTableContents( QgsTableContents() << ( QgsTableRow() << c1 << QgsTableCell( QStringLiteral( "A2" ) ) << c1 << QgsTableCell( QStringLiteral( "Something" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "B" ) ) << QgsTableCell( QStringLiteral( "B2" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C" ) ) << QgsTableCell( QStringLiteral( "C2" ) ) << QgsTableCell( QStringLiteral( "C3" ) ) << c3 ) << ( QgsTableRow() << c4 << QgsTableCell( QStringLiteral( "E" ) ) << QgsTableCell( QStringLiteral( "F" ) ) << QgsTableCell( QStringLiteral( "hidden by span" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "hidden" ) ) << QgsTableCell( QStringLiteral( "D2" ) ) << QgsTableCell( QStringLiteral( "D3" ) ) << QgsTableCell( QStringLiteral( "G" ) ) ) ); - table->setColumnWidths( QList< double >() << 30 << 50.0 << 40.0 << 25.0 ); + table->setColumnWidths( QList() << 30 << 50.0 << 40.0 << 25.0 ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "manualtable_merged_background_color" ), &l ); } diff --git a/tests/src/core/testqgslayoutmap.cpp b/tests/src/core/testqgslayoutmap.cpp index bccf4a2df24f..6f9f3414a258 100644 --- a/tests/src/core/testqgslayoutmap.cpp +++ b/tests/src/core/testqgslayoutmap.cpp @@ -46,24 +46,25 @@ class TestQgsLayoutMap : public QgsTest Q_OBJECT public: - TestQgsLayoutMap() : QgsTest( QStringLiteral( "Layout Map Tests" ), QStringLiteral( "composer_map" ) ) {} + TestQgsLayoutMap() + : QgsTest( QStringLiteral( "Layout Map Tests" ), QStringLiteral( "composer_map" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. void construct(); //test constructor of QgsLayoutItemMap void id(); void render(); - void uniqueId(); //test if map id is adapted when doing copy paste + void uniqueId(); //test if map id is adapted when doing copy paste void worldFileGeneration(); // test world file generation - void zoomToExtent(); // test zoomToExtent method + void zoomToExtent(); // test zoomToExtent method - void mapPolygonVertices(); // test mapPolygon function with no map rotation - void dataDefinedLayers(); //test data defined layer string - void dataDefinedStyles(); //test data defined styles - void dataDefinedCrs(); //test data defined crs + void mapPolygonVertices(); // test mapPolygon function with no map rotation + void dataDefinedLayers(); //test data defined layer string + void dataDefinedStyles(); //test data defined styles + void dataDefinedCrs(); //test data defined crs void dataDefinedTemporalRange(); //test data defined temporal range's start and end values void rasterized(); void layersToRender(); @@ -97,22 +98,18 @@ void TestQgsLayoutMap::initTestCase() //create maplayers from testdata and add to layer registry const QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ); - mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer *rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 ); mRasterLayer->setRenderer( rasterRenderer ); const QFileInfo pointFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - mPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); const QFileInfo polyFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ); - mPolysLayer = new QgsVectorLayer( polyFileInfo.filePath(), - polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPolysLayer = new QgsVectorLayer( polyFileInfo.filePath(), polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); const QFileInfo lineFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/lines.shp" ); - mLinesLayer = new QgsVectorLayer( lineFileInfo.filePath(), - lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mLinesLayer = new QgsVectorLayer( lineFileInfo.filePath(), lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // some layers need to be in project for data-defined layers functionality QgsProject::instance()->addMapLayers( QList() << mRasterLayer << mPointsLayer << mPolysLayer << mLinesLayer ); @@ -138,7 +135,7 @@ void TestQgsLayoutMap::init() void TestQgsLayoutMap::construct() { - QgsLayout l( QgsProject::instance( ) ); + QgsLayout l( QgsProject::instance() ); QgsLayoutItemMap mi( &l ); QCOMPARE( mi.type(), QgsLayoutItemRegistry::LayoutMap ); QVERIFY( mi.extent().isNull() ); // is this correct to expect ? @@ -153,7 +150,7 @@ void TestQgsLayoutMap::construct() void TestQgsLayoutMap::id() { - QgsLayout l( QgsProject::instance( ) ); + QgsLayout l( QgsProject::instance() ); QgsLayoutItemMap *map1 = new QgsLayoutItemMap( &l ); QCOMPARE( map1->displayName(), QStringLiteral( "Map 1" ) ); l.addLayoutItem( map1 ); @@ -202,7 +199,7 @@ void TestQgsLayoutMap::uniqueId() QgsLayoutItemMap *newMap = nullptr; QList mapList; l.layoutItems( mapList ); - for ( auto mapIt = mapList.constBegin() ; mapIt != mapList.constEnd(); ++mapIt ) + for ( auto mapIt = mapList.constBegin(); mapIt != mapList.constEnd(); ++mapIt ) { if ( *mapIt != map ) { @@ -275,7 +272,7 @@ void TestQgsLayoutMap::worldFileGeneration() void TestQgsLayoutMap::zoomToExtent() { - QgsLayout l( QgsProject::instance( ) ); + QgsLayout l( QgsProject::instance() ); QgsLayoutItemMap mi( &l ); QVERIFY( mi.extent().isEmpty() ); @@ -337,7 +334,6 @@ void TestQgsLayoutMap::mapPolygonVertices() QVERIFY( visibleExtent.isClosed() ); map->setMapRotation( 0 ); - } void TestQgsLayoutMap::dataDefinedLayers() @@ -361,24 +357,21 @@ void TestQgsLayoutMap::dataDefinedLayers() QVERIFY( result.isEmpty() ); //test subset of valid layers - map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( - QStringLiteral( "'%1|%2'" ).arg( mPolysLayer->name(), mRasterLayer->name() ) ) ); + map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( QStringLiteral( "'%1|%2'" ).arg( mPolysLayer->name(), mRasterLayer->name() ) ) ); result = map->layersToRender(); QCOMPARE( result.count(), 2 ); QVERIFY( result.contains( mPolysLayer ) ); QVERIFY( result.contains( mRasterLayer ) ); //test non-existent layer - map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( - QStringLiteral( "'x|%1|%2'" ).arg( mLinesLayer->name(), mPointsLayer->name() ) ) ); + map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( QStringLiteral( "'x|%1|%2'" ).arg( mLinesLayer->name(), mPointsLayer->name() ) ) ); result = map->layersToRender(); QCOMPARE( result.count(), 2 ); QVERIFY( result.contains( mLinesLayer ) ); QVERIFY( result.contains( mPointsLayer ) ); //test no layers - map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( - QStringLiteral( "''" ) ) ); + map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( QStringLiteral( "''" ) ) ); result = map->layersToRender(); QVERIFY( result.isEmpty() ); @@ -412,8 +405,7 @@ void TestQgsLayoutMap::dataDefinedLayers() delete atlasLayer; //render test - map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( - QStringLiteral( "'%1|%2'" ).arg( mPolysLayer->name(), mPointsLayer->name() ) ) ); + map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( QStringLiteral( "'%1|%2'" ).arg( mPolysLayer->name(), mPointsLayer->name() ) ) ); map->setExtent( QgsRectangle( -110.0, 25.0, -90, 40.0 ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "composermap_ddlayers" ), &l ); @@ -434,10 +426,7 @@ void TestQgsLayoutMap::dataDefinedStyles() l.addLayoutItem( map ); QgsMapThemeCollection::MapThemeRecord rec; - rec.setLayerRecords( QList() - << QgsMapThemeCollection::MapThemeLayerRecord( mPointsLayer ) - << QgsMapThemeCollection::MapThemeLayerRecord( mLinesLayer ) - ); + rec.setLayerRecords( QList() << QgsMapThemeCollection::MapThemeLayerRecord( mPointsLayer ) << QgsMapThemeCollection::MapThemeLayerRecord( mLinesLayer ) ); QgsProject::instance()->mapThemeCollection()->insert( QStringLiteral( "test preset" ), rec ); @@ -467,8 +456,7 @@ void TestQgsLayoutMap::dataDefinedStyles() //test that dd layer set overrides style layers map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapStylePreset, QgsProperty::fromExpression( QStringLiteral( "'test preset'" ) ) ); - map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( - QStringLiteral( "'%1'" ).arg( mPolysLayer->name() ) ) ); + map->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::MapLayers, QgsProperty::fromExpression( QStringLiteral( "'%1'" ).arg( mPolysLayer->name() ) ) ); result = qgis::listToSet( map->layersToRender() ); QCOMPARE( result.count(), 1 ); QVERIFY( result.contains( mPolysLayer ) ); @@ -618,8 +606,7 @@ void TestQgsLayoutMap::mapRotation() { QgsProject p; const QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/rgb256x256.png" ); - QgsRasterLayer *layer = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + QgsRasterLayer *layer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer *rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 ); layer->setRenderer( rasterRenderer ); p.addMapLayer( layer ); @@ -654,8 +641,7 @@ void TestQgsLayoutMap::mapItemRotation() { QgsProject p; const QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/rgb256x256.png" ); - QgsRasterLayer *layer = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + QgsRasterLayer *layer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer *rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 ); layer->setRenderer( rasterRenderer ); p.addMapLayer( layer ); @@ -921,8 +907,7 @@ void TestQgsLayoutMap::testMaskSettings() class TestHandler : public QgsRenderedFeatureHandlerInterface { public: - - TestHandler( QList< QgsFeature > &features, QList< QgsGeometry > &geometries ) + TestHandler( QList &features, QList &geometries ) : features( features ) , geometries( geometries ) {} @@ -933,16 +918,14 @@ class TestHandler : public QgsRenderedFeatureHandlerInterface geometries.append( geom ); } - QList< QgsFeature > &features; - QList< QgsGeometry > &geometries; - + QList &features; + QList &geometries; }; void TestQgsLayoutMap::testRenderedFeatureHandler() { - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); QgsProject p; @@ -959,8 +942,8 @@ void TestQgsLayoutMap::testRenderedFeatureHandler() l.addLayoutItem( map ); // register a handler - QList< QgsFeature > features1; - QList< QgsGeometry > geometries1; + QList features1; + QList geometries1; TestHandler handler1( features1, geometries1 ); // not added yet, no crash map->removeRenderedFeatureHandler( nullptr ); @@ -987,11 +970,9 @@ void TestQgsLayoutMap::testRenderedFeatureHandler() void TestQgsLayoutMap::testLayeredExport() { - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); QgsProject p; @@ -1409,19 +1390,12 @@ void TestQgsLayoutMap::testLayeredExport() // exporting by theme QgsMapThemeCollection::MapThemeRecord rec; - rec.setLayerRecords( QList() - << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) - ); + rec.setLayerRecords( QList() << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) ); p.mapThemeCollection()->insert( QStringLiteral( "test preset" ), rec ); - rec.setLayerRecords( QList() - << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) - << QgsMapThemeCollection::MapThemeLayerRecord( pointsLayer ) - ); + rec.setLayerRecords( QList() << QgsMapThemeCollection::MapThemeLayerRecord( linesLayer ) << QgsMapThemeCollection::MapThemeLayerRecord( pointsLayer ) ); p.mapThemeCollection()->insert( QStringLiteral( "test preset2" ), rec ); - rec.setLayerRecords( QList() - << QgsMapThemeCollection::MapThemeLayerRecord( pointsLayer ) - ); + rec.setLayerRecords( QList() << QgsMapThemeCollection::MapThemeLayerRecord( pointsLayer ) ); p.mapThemeCollection()->insert( QStringLiteral( "test preset3" ), rec ); l.renderContext().setExportThemes( QStringList() << QStringLiteral( "test preset2" ) << QStringLiteral( "test preset" ) << QStringLiteral( "test preset3" ) ); @@ -1760,11 +1734,9 @@ void TestQgsLayoutMap::testLayeredExport() void TestQgsLayoutMap::testLayeredExportLabelsByLayer() { - QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *linesLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + QgsVectorLayer *pointsLayer = new QgsVectorLayer( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); QgsProject p; @@ -1954,8 +1926,8 @@ void TestQgsLayoutMap::testLayeredExportLabelsByLayer() void TestQgsLayoutMap::testTemporal() { - QgsLayout l( QgsProject::instance( ) ); - std::unique_ptr< QgsLayoutItemMap > map = std::make_unique< QgsLayoutItemMap >( &l ); + QgsLayout l( QgsProject::instance() ); + std::unique_ptr map = std::make_unique( &l ); const QDateTime begin( QDate( 2020, 01, 01 ), QTime( 10, 0, 0 ), Qt::UTC ); const QDateTime end = begin.addSecs( 3600 ); @@ -2023,12 +1995,11 @@ void TestQgsLayoutMap::testLabelResults() painter.end(); // retrieve label results - std::unique_ptr< QgsLabelingResults > results = std::move( map->mExportLabelingResults ); + std::unique_ptr results = std::move( map->mExportLabelingResults ); QVERIFY( results ); QList labels = results->allLabels(); QCOMPARE( labels.count(), 3 ); - std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition & a, const QgsLabelPosition & b ) - { + std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition &a, const QgsLabelPosition &b ) { return a.labelText.compare( b.labelText ) < 0; } ); QCOMPARE( labels.at( 0 ).labelText, QStringLiteral( "1" ) ); @@ -2058,8 +2029,7 @@ void TestQgsLayoutMap::testLabelResults() QVERIFY( results ); labels = results->allLabels(); QCOMPARE( labels.count(), 6 ); - std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition & a, const QgsLabelPosition & b ) - { + std::sort( labels.begin(), labels.end(), []( const QgsLabelPosition &a, const QgsLabelPosition &b ) { return a.isUnplaced == b.isUnplaced ? a.labelText.compare( b.labelText ) < 0 : a.isUnplaced < b.isUnplaced; } ); QCOMPARE( labels.at( 0 ).labelText, QStringLiteral( "1" ) ); @@ -2074,13 +2044,12 @@ void TestQgsLayoutMap::testLabelResults() QVERIFY( labels.at( 4 ).isUnplaced ); QCOMPARE( labels.at( 5 ).labelText, QStringLiteral( "8888" ) ); QVERIFY( labels.at( 5 ).isUnplaced ); - } void TestQgsLayoutMap::testZRange() { - QgsLayout l( QgsProject::instance( ) ); - std::unique_ptr< QgsLayoutItemMap > map = std::make_unique< QgsLayoutItemMap >( &l ); + QgsLayout l( QgsProject::instance() ); + std::unique_ptr map = std::make_unique( &l ); QgsMapSettings settings = map->mapSettings( map->extent(), QSize( 512, 512 ), 72, false ); QVERIFY( settings.zRange().isInfinite() ); diff --git a/tests/src/core/testqgslayoutmapgrid.cpp b/tests/src/core/testqgslayoutmapgrid.cpp index e56afc998a05..500c8e97a0a4 100644 --- a/tests/src/core/testqgslayoutmapgrid.cpp +++ b/tests/src/core/testqgslayoutmapgrid.cpp @@ -31,39 +31,39 @@ class TestQgsLayoutMapGrid : public QgsTest Q_OBJECT public: - - TestQgsLayoutMapGrid() : QgsTest( QStringLiteral( "Layout Map Grid Tests" ), QStringLiteral( "composer_mapgrid" ) ) {} + TestQgsLayoutMapGrid() + : QgsTest( QStringLiteral( "Layout Map Grid Tests" ), QStringLiteral( "composer_mapgrid" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - - void grid(); //test if grid and grid annotation works - void reprojected(); //test if reprojected grid works - void crossGrid(); //test if grid "cross" mode works - void markerGrid(); //test if grid "marker" mode works - void frameOnly(); //test if grid "frame/annotation" mode works - void zebraStyle(); //test zebra map border style - void zebraStyleSides(); //test zebra border on certain sides - void zebraStyleMargin(); //test zebra map border style - void zebraStyleNautical(); //test zebra map border style - void frameDivisions(); //test filtering frame divisions - void annotationFilter(); //test filtering annotations - void interiorTicks(); //test interior tick mode - void interiorTicksMargin(); //test interior tick mode - void interiorTicksAnnotated(); //test interior tick mode with annotations - void exteriorTicks(); //test exterior tick mode - void exteriorTicksMargin(); //test exterior tick mode - void exteriorTicksAnnotated(); //test exterior tick mode with annotations - void interiorExteriorTicks(); //test interior & exterior tick mode - void interiorExteriorTicksMargin(); //test interior & exterior tick mode + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + + void grid(); //test if grid and grid annotation works + void reprojected(); //test if reprojected grid works + void crossGrid(); //test if grid "cross" mode works + void markerGrid(); //test if grid "marker" mode works + void frameOnly(); //test if grid "frame/annotation" mode works + void zebraStyle(); //test zebra map border style + void zebraStyleSides(); //test zebra border on certain sides + void zebraStyleMargin(); //test zebra map border style + void zebraStyleNautical(); //test zebra map border style + void frameDivisions(); //test filtering frame divisions + void annotationFilter(); //test filtering annotations + void interiorTicks(); //test interior tick mode + void interiorTicksMargin(); //test interior tick mode + void interiorTicksAnnotated(); //test interior tick mode with annotations + void exteriorTicks(); //test exterior tick mode + void exteriorTicksMargin(); //test exterior tick mode + void exteriorTicksAnnotated(); //test exterior tick mode with annotations + void interiorExteriorTicks(); //test interior & exterior tick mode + void interiorExteriorTicksMargin(); //test interior & exterior tick mode void interiorExteriorTicksAnnotated(); //test interior & exterior tick mode with annotations - void lineBorder(); //test line border frame mode - void lineBorderMargin(); //test line border frame mode - void lineBorderNautical(); //test line border frame mode - void lineBorderAnnotated(); //test line border frame with annotations - void annotationFormats(); //various tests for annotation formats - void descendingAnnotations(); //test descending annotation direction + void lineBorder(); //test line border frame mode + void lineBorderMargin(); //test line border frame mode + void lineBorderNautical(); //test line border frame mode + void lineBorderAnnotated(); //test line border frame with annotations + void annotationFormats(); //various tests for annotation formats + void descendingAnnotations(); //test descending annotation direction }; void TestQgsLayoutMapGrid::initTestCase() @@ -215,7 +215,7 @@ void TestQgsLayoutMapGrid::markerGrid() map->grid()->setIntervalY( 2000 ); map->grid()->setGridLineWidth( 0.5 ); map->grid()->setGridLineColor( QColor( 0, 0, 0 ) ); - static_cast< QgsSimpleMarkerSymbolLayer * >( map->grid()->markerSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); + static_cast( map->grid()->markerSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); map->updateBoundingRect(); l.addLayoutItem( map ); @@ -361,7 +361,6 @@ void TestQgsLayoutMapGrid::zebraStyleSides() map->grid()->setFrameSideFlag( QgsLayoutItemMapGrid::FrameBottom, true ); map->grid()->setFrameStyle( QgsLayoutItemMapGrid::NoFrame ); - } void TestQgsLayoutMapGrid::zebraStyleMargin() diff --git a/tests/src/core/testqgslayoutmapoverview.cpp b/tests/src/core/testqgslayoutmapoverview.cpp index be0fb9a716e0..ea238a983037 100644 --- a/tests/src/core/testqgslayoutmapoverview.cpp +++ b/tests/src/core/testqgslayoutmapoverview.cpp @@ -31,19 +31,20 @@ class TestQgsLayoutMapOverview : public QgsTest Q_OBJECT public: - TestQgsLayoutMapOverview() : QgsTest( QStringLiteral( "Layout Map Overview Tests" ), QStringLiteral( "composer_mapoverview" ) ) {} + TestQgsLayoutMapOverview() + : QgsTest( QStringLiteral( "Layout Map Overview Tests" ), QStringLiteral( "composer_mapoverview" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void overviewMap(); //test if overview map frame works - void overviewMapRotated(); //test if overview map frame works with rotated overview + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void overviewMap(); //test if overview map frame works + void overviewMapRotated(); //test if overview map frame works with rotated overview void overviewMapRotated2(); //test if overview map frame works with rotated map void overviewMapBlending(); //test if blend modes with overview map frame works - void overviewMapInvert(); //test if invert of overview map frame works - void overviewMapCenter(); //test if centering of overview map frame works + void overviewMapInvert(); //test if invert of overview map frame works + void overviewMapCenter(); //test if centering of overview map frame works void overviewReprojected(); //test that overview frame is reprojected private: @@ -57,8 +58,7 @@ void TestQgsLayoutMapOverview::initTestCase() //create maplayers from testdata and add to layer registry const QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/rgb256x256.png" ); - mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer *rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 ); mRasterLayer->setRenderer( rasterRenderer ); } @@ -76,7 +76,6 @@ void TestQgsLayoutMapOverview::init() void TestQgsLayoutMapOverview::cleanup() { - } void TestQgsLayoutMapOverview::overviewMap() @@ -89,7 +88,7 @@ void TestQgsLayoutMapOverview::overviewMap() map->setLayers( QList() << mRasterLayer ); l.addLayoutItem( map ); - QgsLayoutItemMap *overviewMap = new QgsLayoutItemMap( &l ); + QgsLayoutItemMap *overviewMap = new QgsLayoutItemMap( &l ); overviewMap->attemptSetSceneRect( QRectF( 20, 130, 70, 70 ) ); overviewMap->setFrameEnabled( true ); overviewMap->setLayers( QList() << mRasterLayer ); diff --git a/tests/src/core/testqgslayoutmodel.cpp b/tests/src/core/testqgslayoutmodel.cpp index c0fd30572e1f..bc9152448686 100644 --- a/tests/src/core/testqgslayoutmodel.cpp +++ b/tests/src/core/testqgslayoutmodel.cpp @@ -34,38 +34,38 @@ class TestQgsLayoutModel : public QgsTest Q_OBJECT public: - TestQgsLayoutModel(): QgsTest( QStringLiteral( "Layout model test" ) ) {} + TestQgsLayoutModel() + : QgsTest( QStringLiteral( "Layout model test" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void creation(); //check that model has been created - void addItems(); //add some items to the composition and test model - void zList(); //check model z order list - void clear(); //check clearing the model - void addLayoutItemDirectly(); //add an item directly to the model - void rebuildZList(); //test rebuilding the z list from the current composer stacking - void removeItem(); //test removing an item from the model - void reorderUp(); //test reordering an item up - void reorderDown(); //test reordering an item down - void reorderTop(); //test reordering an item to top - void reorderBottom(); //test reordering an item to bottom - void moveItem(); //test move an item in the item tree - void findItemAbove(); //test getting composer item above - void findItemBelow(); //test getting composer item below - void setItemRemoved(); //test setting an item as removed - void rebuildZListWithRemoved(); //test rebuilding z list with removed items - void reorderUpWithRemoved(); //test reordering up with removed items - void reorderDownWithRemoved(); //test reordering down with removed items - void reorderToTopWithRemoved(); //test reordering to top with removed items + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void creation(); //check that model has been created + void addItems(); //add some items to the composition and test model + void zList(); //check model z order list + void clear(); //check clearing the model + void addLayoutItemDirectly(); //add an item directly to the model + void rebuildZList(); //test rebuilding the z list from the current composer stacking + void removeItem(); //test removing an item from the model + void reorderUp(); //test reordering an item up + void reorderDown(); //test reordering an item down + void reorderTop(); //test reordering an item to top + void reorderBottom(); //test reordering an item to bottom + void moveItem(); //test move an item in the item tree + void findItemAbove(); //test getting composer item above + void findItemBelow(); //test getting composer item below + void setItemRemoved(); //test setting an item as removed + void rebuildZListWithRemoved(); //test rebuilding z list with removed items + void reorderUpWithRemoved(); //test reordering up with removed items + void reorderDownWithRemoved(); //test reordering down with removed items + void reorderToTopWithRemoved(); //test reordering to top with removed items void reorderToBottomWithRemoved(); //test reordering to bottom with removed items void groupSelection(); void proxy(); void proxyCrash(); - }; void TestQgsLayoutModel::initTestCase() @@ -81,12 +81,10 @@ void TestQgsLayoutModel::cleanupTestCase() void TestQgsLayoutModel::init() { - } void TestQgsLayoutModel::cleanup() { - } void TestQgsLayoutModel::creation() @@ -333,12 +331,12 @@ void TestQgsLayoutModel::reorderUp() QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 3, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i1" ) ); //try reordering some bad items - QVERIFY( ! layout.itemsModel()->reorderItemUp( nullptr ) ); + QVERIFY( !layout.itemsModel()->reorderItemUp( nullptr ) ); QgsLayoutItemMap *label = new QgsLayoutItemMap( nullptr ); - QVERIFY( ! layout.itemsModel()->reorderItemUp( label ) ); + QVERIFY( !layout.itemsModel()->reorderItemUp( label ) ); //trying to reorder up the topmost item should fail - QVERIFY( ! layout.itemsModel()->reorderItemUp( item3 ) ); + QVERIFY( !layout.itemsModel()->reorderItemUp( item3 ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 0, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QString() ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 1, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i3" ) ); @@ -398,12 +396,12 @@ void TestQgsLayoutModel::reorderDown() QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 3, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i1" ) ); //try reordering some bad items - QVERIFY( ! layout.itemsModel()->reorderItemDown( nullptr ) ); + QVERIFY( !layout.itemsModel()->reorderItemDown( nullptr ) ); QgsLayoutItemMap *label = new QgsLayoutItemMap( nullptr ); - QVERIFY( ! layout.itemsModel()->reorderItemDown( label ) ); + QVERIFY( !layout.itemsModel()->reorderItemDown( label ) ); //trying to reorder down the bottommost item should fail - QVERIFY( ! layout.itemsModel()->reorderItemDown( item1 ) ); + QVERIFY( !layout.itemsModel()->reorderItemDown( item1 ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 0, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QString() ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 1, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i3" ) ); @@ -463,12 +461,12 @@ void TestQgsLayoutModel::reorderTop() QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 3, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i1" ) ); //try reordering some bad items - QVERIFY( ! layout.itemsModel()->reorderItemToTop( nullptr ) ); + QVERIFY( !layout.itemsModel()->reorderItemToTop( nullptr ) ); QgsLayoutItemMap *label = new QgsLayoutItemMap( nullptr ); - QVERIFY( ! layout.itemsModel()->reorderItemToTop( label ) ); + QVERIFY( !layout.itemsModel()->reorderItemToTop( label ) ); //trying to reorder up the topmost item should fail - QVERIFY( ! layout.itemsModel()->reorderItemToTop( item3 ) ); + QVERIFY( !layout.itemsModel()->reorderItemToTop( item3 ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 0, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QString() ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 1, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i3" ) ); @@ -529,12 +527,12 @@ void TestQgsLayoutModel::reorderBottom() QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 3, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i1" ) ); //try reordering some bad items - QVERIFY( ! layout.itemsModel()->reorderItemToBottom( nullptr ) ); + QVERIFY( !layout.itemsModel()->reorderItemToBottom( nullptr ) ); QgsLayoutItemMap *label = new QgsLayoutItemMap( nullptr ); - QVERIFY( ! layout.itemsModel()->reorderItemToBottom( label ) ); + QVERIFY( !layout.itemsModel()->reorderItemToBottom( label ) ); //trying to reorder down the bottommost item should fail - QVERIFY( ! layout.itemsModel()->reorderItemToBottom( item1 ) ); + QVERIFY( !layout.itemsModel()->reorderItemToBottom( item1 ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 0, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QString() ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 1, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i3" ) ); @@ -595,22 +593,22 @@ void TestQgsLayoutModel::moveItem() QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 3, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i1" ) ); QgsLayoutModel *model = layout.itemsModel(); - std::unique_ptr< QMimeData > mimedata( model->mimeData( QModelIndexList() << model->index( 2, 2 ) ) ); // get i2 - model->dropMimeData( mimedata.get(), Qt::MoveAction, 1, 2, QModelIndex() ); // move i2 at the top + std::unique_ptr mimedata( model->mimeData( QModelIndexList() << model->index( 2, 2 ) ) ); // get i2 + model->dropMimeData( mimedata.get(), Qt::MoveAction, 1, 2, QModelIndex() ); // move i2 at the top QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 1, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i2" ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 2, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i3" ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 3, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i1" ) ); mimedata.reset( model->mimeData( QModelIndexList() << model->index( 1, 2 ) ) ); // get i2 - model->dropMimeData( mimedata.get(), Qt::MoveAction, -1, -1, QModelIndex() ); // move i2 at the bottom + model->dropMimeData( mimedata.get(), Qt::MoveAction, -1, -1, QModelIndex() ); // move i2 at the bottom QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 1, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i3" ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 2, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i1" ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 3, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i2" ) ); mimedata.reset( model->mimeData( QModelIndexList() << model->index( 3, 2 ) ) ); // get i2 - model->dropMimeData( mimedata.get(), Qt::MoveAction, 2, 2, QModelIndex() ); // move i2 between i3 and i1 + model->dropMimeData( mimedata.get(), Qt::MoveAction, 2, 2, QModelIndex() ); // move i2 between i3 and i1 QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 1, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i3" ) ); QCOMPARE( layout.itemsModel()->data( layout.itemsModel()->index( 2, 2, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "i2" ) ); @@ -641,12 +639,12 @@ void TestQgsLayoutModel::findItemAbove() QCOMPARE( layout.itemsModel()->zOrderList().at( 2 ), item1 ); //try getting item above some bad items - QVERIFY( ! layout.itemsModel()->findItemAbove( nullptr ) ); + QVERIFY( !layout.itemsModel()->findItemAbove( nullptr ) ); QgsLayoutItemMap *label = new QgsLayoutItemMap( nullptr ); - QVERIFY( ! layout.itemsModel()->findItemAbove( label ) ); + QVERIFY( !layout.itemsModel()->findItemAbove( label ) ); //trying to get item above topmost item should fail - QVERIFY( ! layout.itemsModel()->findItemAbove( item3 ) ); + QVERIFY( !layout.itemsModel()->findItemAbove( item3 ) ); //try using a good item QCOMPARE( layout.itemsModel()->findItemAbove( item2 ), item3 ); @@ -679,12 +677,12 @@ void TestQgsLayoutModel::findItemBelow() QCOMPARE( layout.itemsModel()->zOrderList().at( 2 ), item1 ); //try getting item below some bad items - QVERIFY( ! layout.itemsModel()->findItemBelow( nullptr ) ); + QVERIFY( !layout.itemsModel()->findItemBelow( nullptr ) ); QgsLayoutItemMap *label = new QgsLayoutItemMap( nullptr ); - QVERIFY( ! layout.itemsModel()->findItemBelow( label ) ); + QVERIFY( !layout.itemsModel()->findItemBelow( label ) ); //trying to get item below bottom most item should fail - QVERIFY( ! layout.itemsModel()->findItemBelow( item1 ) ); + QVERIFY( !layout.itemsModel()->findItemBelow( item1 ) ); //try using a good item QCOMPARE( layout.itemsModel()->findItemBelow( item3 ), item2 ); @@ -993,21 +991,21 @@ void TestQgsLayoutModel::groupSelection() QCOMPARE( spy.count(), 1 ); // but the actual selected item signal should be the originally selected item, so // that it can be tweaked in the properties dialog - QCOMPARE( spy.at( 0 ).at( 0 ).value< QObject * >(), item3 ); + QCOMPARE( spy.at( 0 ).at( 0 ).value(), item3 ); layout.itemsModel()->setSelected( layout.itemsModel()->indexForItem( item1 ) ); QVERIFY( !item1->isSelected() ); QVERIFY( !group->isSelected() ); QVERIFY( group2->isSelected() ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( spy.at( 1 ).at( 0 ).value< QObject * >(), item1 ); + QCOMPARE( spy.at( 1 ).at( 0 ).value(), item1 ); layout.itemsModel()->setSelected( layout.itemsModel()->indexForItem( item2 ) ); QVERIFY( !item2->isSelected() ); QVERIFY( !group->isSelected() ); QVERIFY( group2->isSelected() ); QCOMPARE( spy.count(), 3 ); - QCOMPARE( spy.at( 2 ).at( 0 ).value< QObject * >(), item2 ); + QCOMPARE( spy.at( 2 ).at( 0 ).value(), item2 ); } void TestQgsLayoutModel::proxy() @@ -1090,7 +1088,7 @@ void TestQgsLayoutModel::proxyCrash() layout->addLayoutItem( item3 ); // reorder items - expect no crash! - ( void )layout->itemsModel()->reorderItemUp( item1 ); + ( void ) layout->itemsModel()->reorderItemUp( item1 ); } QGSTEST_MAIN( TestQgsLayoutModel ) diff --git a/tests/src/core/testqgslayoutmultiframe.cpp b/tests/src/core/testqgslayoutmultiframe.cpp index a345fc64446e..d606673d4630 100644 --- a/tests/src/core/testqgslayoutmultiframe.cpp +++ b/tests/src/core/testqgslayoutmultiframe.cpp @@ -36,16 +36,17 @@ class TestQgsLayoutMultiFrame : public QgsTest Q_OBJECT public: - TestQgsLayoutMultiFrame() : QgsTest( QStringLiteral( "Layout MultiFrame Tests" ) ) {} + TestQgsLayoutMultiFrame() + : QgsTest( QStringLiteral( "Layout MultiFrame Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void layoutMethods(); void addFrame(); //test creating new frame inherits all properties of existing frame void displayName(); #ifdef WITH_QTWEBKIT - void frameIsEmpty(); //test if frame is empty works + void frameIsEmpty(); //test if frame is empty works void addRemovePage(); //test if page is added and removed for RepeatUntilFinished mode #endif void undoRedo(); //test that combinations of frame/multiframe undo/redo don't crash @@ -68,29 +69,24 @@ class TestMultiFrame : public QgsLayoutMultiFrame Q_OBJECT public: - TestMultiFrame( QgsLayout *layout ) : QgsLayoutMultiFrame( layout ) { - } int type() const override { - return QgsLayoutItemRegistry::PluginItem + 1; } void render( QgsLayoutItemRenderContext &, const QRectF &, int ) override { - } QSizeF totalSize() const override { return QSizeF(); } - }; void TestQgsLayoutMultiFrame::initTestCase() @@ -117,7 +113,7 @@ void TestQgsLayoutMultiFrame::layoutMethods() l->addMultiFrame( nullptr ); QVERIFY( l->multiFrames().empty() ); TestMultiFrame *mF = new TestMultiFrame( l ); - const QPointer< TestMultiFrame > pMF( mF ); + const QPointer pMF( mF ); QCOMPARE( l->multiFrames().count(), 1 ); QVERIFY( l->multiFrames().contains( mF ) ); QVERIFY( !l->multiFrameByUuid( QString() ) ); @@ -132,7 +128,7 @@ void TestQgsLayoutMultiFrame::layoutMethods() QVERIFY( l->multiFrames().contains( mF ) ); TestMultiFrame *mF2 = new TestMultiFrame( l ); - const QPointer< TestMultiFrame > pMF2( mF2 ); + const QPointer pMF2( mF2 ); l->addMultiFrame( mF2 ); QCOMPARE( l->multiFrames().count(), 2 ); QVERIFY( l->multiFrames().contains( mF ) ); @@ -441,8 +437,7 @@ void TestQgsLayoutMultiFrame::undoRedoRemovedFrame() QCOMPARE( htmlItem->frameCount(), 1 ); - auto dumpStack = [ = ] - { + auto dumpStack = [=] { #if 0 // for debugging // dump stack for ( int i = 0; i < mLayout->undoStack()->stack()->count(); ++i ) @@ -510,12 +505,10 @@ void TestQgsLayoutMultiFrame::registry() QVERIFY( registry.itemTypes().isEmpty() ); QVERIFY( !registry.createMultiFrame( 1, nullptr ) ); - auto create = []( QgsLayout * layout )->QgsLayoutMultiFrame * - { + auto create = []( QgsLayout *layout ) -> QgsLayoutMultiFrame * { return new TestMultiFrame( layout ); }; - auto resolve = []( QVariantMap & props, const QgsPathResolver &, bool ) - { + auto resolve = []( QVariantMap &props, const QgsPathResolver &, bool ) { props.clear(); }; @@ -538,7 +531,7 @@ void TestQgsLayoutMultiFrame::registry() QgsLayout l( QgsProject::instance() ); QgsLayoutMultiFrame *item = registry.createMultiFrame( QgsLayoutItemRegistry::PluginItem + 1, &l ); QVERIFY( item ); - QVERIFY( dynamic_cast< TestMultiFrame *>( item ) ); + QVERIFY( dynamic_cast( item ) ); QVariantMap props; props.insert( QStringLiteral( "a" ), 5 ); registry.resolvePaths( 1, props, QgsPathResolver(), true ); @@ -561,10 +554,10 @@ void TestQgsLayoutMultiFrame::deleteFrame() htmlItem->addFrame( frame2 ); QCOMPARE( htmlItem->frameCount(), 2 ); - QCOMPARE( htmlItem->frames(), QList< QgsLayoutFrame * >() << frame1 << frame2 ); + QCOMPARE( htmlItem->frames(), QList() << frame1 << frame2 ); l.removeLayoutItem( frame1 ); QCOMPARE( htmlItem->frameCount(), 1 ); - QCOMPARE( htmlItem->frames(), QList< QgsLayoutFrame * >() << frame2 ); + QCOMPARE( htmlItem->frames(), QList() << frame2 ); l.removeLayoutItem( frame2 ); QCOMPARE( htmlItem->frameCount(), 0 ); QVERIFY( htmlItem->frames().empty() ); @@ -587,7 +580,7 @@ void TestQgsLayoutMultiFrame::writeReadXml() QCOMPARE( frame->multiFrame(), html ); QCOMPARE( html->frameCount(), 1 ); - QCOMPARE( html->frames(), QList< QgsLayoutFrame * >() << frame ); + QCOMPARE( html->frames(), QList() << frame ); // save layout to xml QDomDocument doc; @@ -597,16 +590,16 @@ void TestQgsLayoutMultiFrame::writeReadXml() QgsLayout c2( &p ); c2.readXml( doc.childNodes().at( 0 ).toElement(), doc, QgsReadWriteContext() ); // get table from new layout - QList< QgsLayoutFrame * > frames2; + QList frames2; c2.layoutItems( frames2 ); QCOMPARE( frames2.count(), 1 ); QgsLayoutFrame *frame2 = frames2.at( 0 ); - QgsLayoutItemHtml *html2 = static_cast< QgsLayoutItemHtml *>( frame2->multiFrame() ); + QgsLayoutItemHtml *html2 = static_cast( frame2->multiFrame() ); QVERIFY( html2 ); QCOMPARE( html2->html(), QStringLiteral( "hi" ) ); QCOMPARE( html2->frameCount(), 1 ); - QCOMPARE( html2->frames(), QList< QgsLayoutFrame * >() << frame2 ); + QCOMPARE( html2->frames(), QList() << frame2 ); } void TestQgsLayoutMultiFrame::noPageNoCrash() @@ -644,7 +637,7 @@ void TestQgsLayoutMultiFrame::variables() QgsLayout l( QgsProject::instance() ); QgsLayoutItemHtml *html = new QgsLayoutItemHtml( &l ); - std::unique_ptr< QgsExpressionContextScope > scope( QgsExpressionContextUtils::multiFrameScope( html ) ); + std::unique_ptr scope( QgsExpressionContextUtils::multiFrameScope( html ) ); const int before = scope->variableCount(); QgsExpressionContextUtils::setLayoutMultiFrameVariable( html, QStringLiteral( "var" ), 5 ); diff --git a/tests/src/core/testqgslayoutobject.cpp b/tests/src/core/testqgslayoutobject.cpp index 53b1c32b60a6..965cf16fa76c 100644 --- a/tests/src/core/testqgslayoutobject.cpp +++ b/tests/src/core/testqgslayoutobject.cpp @@ -21,24 +21,24 @@ #include "qgsreadwritecontext.h" #include "qgsprintlayout.h" -class TestQgsLayoutObject: public QgsTest +class TestQgsLayoutObject : public QgsTest { Q_OBJECT public: - TestQgsLayoutObject() : QgsTest( QStringLiteral( "Layout Object Tests" ) ) {} + TestQgsLayoutObject() + : QgsTest( QStringLiteral( "Layout Object Tests" ) ) {} private slots: void cleanupTestCase(); void creation(); //test creation of QgsLayoutObject - void layout(); //test fetching layout from QgsLayoutObject + void layout(); //test fetching layout from QgsLayoutObject void customProperties(); void context(); void writeReadXml(); - void writeRetrieveDDProperty(); //test writing and retrieving dd properties from xml + void writeRetrieveDDProperty(); //test writing and retrieving dd properties from xml void writeRetrieveCustomProperties(); //test writing/retrieving custom properties from xml - }; @@ -126,9 +126,9 @@ void TestQgsLayoutObject::writeReadXml() QgsLayoutObject *object = new QgsLayoutObject( &l ); QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); //test writing with no parent node @@ -173,9 +173,9 @@ void TestQgsLayoutObject::writeRetrieveDDProperty() //test writing object with dd settings QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); QVERIFY( object->writeObjectPropertiesToElement( rootNode, doc, QgsReadWriteContext() ) ); @@ -214,9 +214,9 @@ void TestQgsLayoutObject::writeRetrieveCustomProperties() //test writing object with custom properties QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); QVERIFY( object->writeObjectPropertiesToElement( rootNode, doc, QgsReadWriteContext() ) ); diff --git a/tests/src/core/testqgslayoutpage.cpp b/tests/src/core/testqgslayoutpage.cpp index cacebf939729..2dcc19489be1 100644 --- a/tests/src/core/testqgslayoutpage.cpp +++ b/tests/src/core/testqgslayoutpage.cpp @@ -34,7 +34,8 @@ class TestQgsLayoutPage : public QgsTest Q_OBJECT public: - TestQgsLayoutPage() : QgsTest( QStringLiteral( "Layout Page Tests" ), QStringLiteral( "composer_paper" ) ) {} + TestQgsLayoutPage() + : QgsTest( QStringLiteral( "Layout Page Tests" ), QStringLiteral( "composer_paper" ) ) {} private slots: void cleanupTestCase(); @@ -45,13 +46,12 @@ class TestQgsLayoutPage : public QgsTest void grid(); void defaultPaper(); void transparentPaper(); //test totally transparent paper style - void borderedPaper(); //test page with border - void markerLinePaper(); //test page with marker line borde + void borderedPaper(); //test page with border + void markerLinePaper(); //test page with marker line borde void hiddenPages(); //test hidden page boundaries void pageLayout(); //test page layout - }; void TestQgsLayoutPage::cleanupTestCase() @@ -63,15 +63,15 @@ void TestQgsLayoutPage::itemType() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); - QCOMPARE( page->type(), static_cast< int >( QgsLayoutItemRegistry::LayoutPage ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); + QCOMPARE( page->type(), static_cast( QgsLayoutItemRegistry::LayoutPage ) ); } void TestQgsLayoutPage::pageSize() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 270, 297, Qgis::LayoutUnit::Meters ) ); QCOMPARE( page->pageSize().width(), 270.0 ); QCOMPARE( page->pageSize().height(), 297.0 ); @@ -99,7 +99,6 @@ void TestQgsLayoutPage::pageSize() QCOMPARE( page->pageSize().height(), 148.0 ); QCOMPARE( page->pageSize().units(), Qgis::LayoutUnit::Millimeters ); QCOMPARE( page->orientation(), QgsLayoutItemPage::Landscape ); - } void TestQgsLayoutPage::decodePageOrientation() @@ -121,7 +120,7 @@ void TestQgsLayoutPage::grid() // test that grid follows page around QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); // should have a grid QVERIFY( page->mGrid.get() ); @@ -146,14 +145,13 @@ void TestQgsLayoutPage::grid() QCOMPARE( page->mGrid->rect().height(), 250.0 ); QCOMPARE( page->mGrid->pos().x(), 0.0 ); QCOMPARE( page->mGrid->pos().y(), 0.0 ); - } void TestQgsLayoutPage::defaultPaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); @@ -164,12 +162,12 @@ void TestQgsLayoutPage::transparentPaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol( new QgsFillSymbol() ); + std::unique_ptr fillSymbol( new QgsFillSymbol() ); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( Qt::transparent ); simpleFill->setStrokeColor( Qt::transparent ); @@ -182,12 +180,12 @@ void TestQgsLayoutPage::borderedPaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); + std::unique_ptr fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( Qt::white ); simpleFill->setStrokeColor( Qt::black ); @@ -201,13 +199,13 @@ void TestQgsLayoutPage::markerLinePaper() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QgsMarkerLineSymbolLayer *markerLine = new QgsMarkerLineSymbolLayer(); - static_cast< QgsSimpleMarkerSymbolLayer * >( markerLine->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); - std::unique_ptr< QgsFillSymbol > markerLineSymbol = std::make_unique< QgsFillSymbol >(); + static_cast( markerLine->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); + std::unique_ptr markerLineSymbol = std::make_unique(); markerLineSymbol->changeSymbolLayer( 0, markerLine ); l.pageCollection()->setPageStyleSymbol( markerLineSymbol.get() ); @@ -218,12 +216,12 @@ void TestQgsLayoutPage::hiddenPages() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page( new QgsLayoutItemPage( &l ) ); page->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); l.pageCollection()->addPage( page.release() ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); + std::unique_ptr fillSymbol = std::make_unique(); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( Qt::blue ); simpleFill->setStrokeColor( Qt::transparent ); @@ -238,7 +236,7 @@ void TestQgsLayoutPage::pageLayout() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemPage > page1( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page1( new QgsLayoutItemPage( &l ) ); page1->setPageSize( QgsLayoutSize( 297, 210, Qgis::LayoutUnit::Millimeters ) ); const QPageLayout layout1 = page1->pageLayout(); @@ -248,7 +246,7 @@ void TestQgsLayoutPage::pageLayout() QCOMPARE( layout1.pageSize().size( QPageSize::Millimeter ).width(), 210 ); QCOMPARE( layout1.pageSize().size( QPageSize::Millimeter ).height(), 297 ); - std::unique_ptr< QgsLayoutItemPage > page2( new QgsLayoutItemPage( &l ) ); + std::unique_ptr page2( new QgsLayoutItemPage( &l ) ); page2->setPageSize( QgsLayoutSize( 210, 297, Qgis::LayoutUnit::Millimeters ) ); const QPageLayout layout2 = page2->pageLayout(); diff --git a/tests/src/core/testqgslayoutpicture.cpp b/tests/src/core/testqgslayoutpicture.cpp index 92cb21e9ff3c..e94975438e61 100644 --- a/tests/src/core/testqgslayoutpicture.cpp +++ b/tests/src/core/testqgslayoutpicture.cpp @@ -32,19 +32,19 @@ class TestQgsLayoutPicture : public QgsTest Q_OBJECT public: - - TestQgsLayoutPicture() : QgsTest( QStringLiteral( "Layout Picture Tests" ), QStringLiteral( "composer_picture" ) ) {} + TestQgsLayoutPicture() + : QgsTest( QStringLiteral( "Layout Picture Tests" ), QStringLiteral( "composer_picture" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void pictureRender(); void pictureRaster(); void pictureSvg(); - void pictureRotation(); //test if picture pictureRotation is functioning + void pictureRotation(); //test if picture pictureRotation is functioning void pictureItemRotation(); //test if composer picture item rotation is functioning void pictureResizeZoom(); @@ -86,7 +86,7 @@ void TestQgsLayoutPicture::initTestCase() QgsApplication::initQgis(); QgsApplication::showSettings(); - QgsFontUtils::loadStandardTestFonts( {QStringLiteral( "Roman" ), QStringLiteral( "Bold" ) } ); + QgsFontUtils::loadStandardTestFonts( { QStringLiteral( "Roman" ), QStringLiteral( "Bold" ) } ); mPngImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_image.png"; mSvgImage = QStringLiteral( TEST_DATA_DIR ) + "/sample_svg.svg"; @@ -100,7 +100,6 @@ void TestQgsLayoutPicture::initTestCase() mPicture->setPicturePath( mPngImage ); mPicture->attemptSetSceneRect( QRectF( 70, 70, 100, 100 ) ); mPicture->setFrameEnabled( true ); - } void TestQgsLayoutPicture::cleanupTestCase() @@ -113,12 +112,10 @@ void TestQgsLayoutPicture::cleanupTestCase() void TestQgsLayoutPicture::init() { - } void TestQgsLayoutPicture::cleanup() { - } void TestQgsLayoutPicture::pictureRender() @@ -177,7 +174,6 @@ void TestQgsLayoutPicture::pictureRotation() QCOMPARE( uninitialized->sizeWithUnits().toQSizeF(), QSizeF( 0, 0 ) ); uninitialized->setPictureRotation( 10 ); QCOMPARE( uninitialized->sizeWithUnits().toQSizeF(), QSizeF( 0, 0 ) ); - } void TestQgsLayoutPicture::pictureItemRotation() diff --git a/tests/src/core/testqgslayoutpolyline.cpp b/tests/src/core/testqgslayoutpolyline.cpp index 8193445cf01f..2264dc96770d 100644 --- a/tests/src/core/testqgslayoutpolyline.cpp +++ b/tests/src/core/testqgslayoutpolyline.cpp @@ -28,13 +28,13 @@ class TestQgsLayoutPolyline : public QgsTest Q_OBJECT public: - TestQgsLayoutPolyline() : QgsTest( QStringLiteral( "Layout Polyline Tests" ), QStringLiteral( "composer_utils" ) ) {} + TestQgsLayoutPolyline() + : QgsTest( QStringLiteral( "Layout Polyline Tests" ), QStringLiteral( "composer_utils" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void drawArrowHead(); - }; void TestQgsLayoutPolyline::initTestCase() diff --git a/tests/src/core/testqgslayoutscalebar.cpp b/tests/src/core/testqgslayoutscalebar.cpp index ab7defc6d9d5..6f4a8b440f6a 100644 --- a/tests/src/core/testqgslayoutscalebar.cpp +++ b/tests/src/core/testqgslayoutscalebar.cpp @@ -40,11 +40,12 @@ class TestQgsLayoutScaleBar : public QgsTest Q_OBJECT public: - TestQgsLayoutScaleBar() : QgsTest( QStringLiteral( "Layout Scalebar Tests" ), QStringLiteral( "layout_scalebar" ) ) {} + TestQgsLayoutScaleBar() + : QgsTest( QStringLiteral( "Layout Scalebar Tests" ), QStringLiteral( "layout_scalebar" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void singleBox(); void singleBoxLineSymbol(); void singleBoxFillSymbol(); @@ -114,7 +115,7 @@ void TestQgsLayoutScaleBar::singleBox() Q_NOWARN_DEPRECATED_PUSH scalebar->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Single Box" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_singlebox" ), &l ); @@ -141,14 +142,14 @@ void TestQgsLayoutScaleBar::singleBoxLineSymbol() scalebar->setNumberOfSegments( 2 ); scalebar->setHeight( 20 ); - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 4 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 0, 0 ) ); lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() ); - lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 2 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 255, 0 ) ); @@ -156,7 +157,7 @@ void TestQgsLayoutScaleBar::singleBoxLineSymbol() scalebar->setLineSymbol( lineSymbol.release() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Single Box" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_singlebox_linesymbol" ), &l ); @@ -183,21 +184,21 @@ void TestQgsLayoutScaleBar::singleBoxFillSymbol() scalebar->setNumberOfSegments( 2 ); scalebar->setHeight( 20 ); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol = std::make_unique(); + std::unique_ptr fillSymbolLayer = std::make_unique(); fillSymbolLayer->setColor( QColor( 255, 0, 0 ) ); fillSymbolLayer->setColor2( QColor( 255, 255, 0 ) ); fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() ); scalebar->setFillSymbol( fillSymbol.release() ); - std::unique_ptr< QgsFillSymbol > fillSymbol2 = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer2 = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol2 = std::make_unique(); + std::unique_ptr fillSymbolLayer2 = std::make_unique(); fillSymbolLayer2->setColor( QColor( 0, 255, 0 ) ); fillSymbolLayer2->setColor2( QColor( 255, 255, 255 ) ); fillSymbol2->changeSymbolLayer( 0, fillSymbolLayer2.release() ); scalebar->setAlternateFillSymbol( fillSymbol2.release() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Single Box" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_singlebox_fillsymbol" ), &l ); @@ -227,7 +228,7 @@ void TestQgsLayoutScaleBar::singleBoxLabelBelowSegment() scalebar->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP scalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::BelowSegment ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Single Box" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_singlebox_labelbelowsegment" ), &l ); @@ -267,7 +268,7 @@ void TestQgsLayoutScaleBar::singleBoxAlpha() scalebar->setLineColor( QColor( 0, 0, 255, 150 ) ); scalebar->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_singlebox_alpha" ), &l ); } @@ -303,7 +304,7 @@ void TestQgsLayoutScaleBar::doubleBox() scalebar->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP scalebar->setStyle( QStringLiteral( "Double Box" ) ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_doublebox" ), &l ); } @@ -329,14 +330,14 @@ void TestQgsLayoutScaleBar::doubleBoxLineSymbol() scalebar->setNumberOfSegments( 2 ); scalebar->setHeight( 20 ); - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 4 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 0, 0 ) ); lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() ); - lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 2 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 255, 0 ) ); @@ -344,7 +345,7 @@ void TestQgsLayoutScaleBar::doubleBoxLineSymbol() scalebar->setLineSymbol( lineSymbol.release() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Double Box" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_doublebox_linesymbol" ), &l ); @@ -371,21 +372,21 @@ void TestQgsLayoutScaleBar::doubleBoxFillSymbol() scalebar->setNumberOfSegments( 2 ); scalebar->setHeight( 20 ); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol = std::make_unique(); + std::unique_ptr fillSymbolLayer = std::make_unique(); fillSymbolLayer->setColor( QColor( 255, 0, 0 ) ); fillSymbolLayer->setColor2( QColor( 255, 255, 0 ) ); fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() ); scalebar->setFillSymbol( fillSymbol.release() ); - std::unique_ptr< QgsFillSymbol > fillSymbol2 = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer2 = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol2 = std::make_unique(); + std::unique_ptr fillSymbolLayer2 = std::make_unique(); fillSymbolLayer2->setColor( QColor( 0, 255, 0 ) ); fillSymbolLayer2->setColor2( QColor( 255, 255, 255 ) ); fillSymbol2->changeSymbolLayer( 0, fillSymbolLayer2.release() ); scalebar->setAlternateFillSymbol( fillSymbol2.release() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Double Box" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_doublebox_fillsymbol" ), &l ); @@ -425,7 +426,7 @@ void TestQgsLayoutScaleBar::doubleBoxLabelCenteredSegment() scalebar->setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement::BelowSegment ); scalebar->setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredSegment ); scalebar->setUnitLabel( QStringLiteral( "units" ) ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_doublebox_labelcenteredsegment" ), &l ); } @@ -459,8 +460,8 @@ void TestQgsLayoutScaleBar::numeric() QFont newFont = QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ); newFont.setPointSizeF( 12 ); scalebar->setTextFormat( QgsTextFormat::fromQFont( newFont ) ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setNumberDecimalPlaces( 0 ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setNumberDecimalPlaces( 0 ); scalebar->setStyle( QStringLiteral( "Numeric" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_numeric" ), &l ); @@ -489,7 +490,7 @@ void TestQgsLayoutScaleBar::tick() Q_NOWARN_DEPRECATED_PUSH scalebar->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Line Ticks Up" ) ); Q_NOWARN_DEPRECATED_PUSH @@ -519,14 +520,14 @@ void TestQgsLayoutScaleBar::tickLineSymbol() scalebar->setNumberOfSegments( 2 ); scalebar->setHeight( 20 ); - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 4 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 0, 0 ) ); lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() ); - lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 2 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 255, 0 ) ); @@ -534,11 +535,11 @@ void TestQgsLayoutScaleBar::tickLineSymbol() scalebar->setLineSymbol( lineSymbol->clone() ); - qgis::down_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setWidth( 5 ); - qgis::down_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 255, 0 ) ); + qgis::down_cast( lineSymbol->symbolLayer( 0 ) )->setWidth( 5 ); + qgis::down_cast( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 255, 0 ) ); scalebar->setDivisionLineSymbol( lineSymbol->clone() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Line Ticks Up" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_tick_linesymbol" ), &l ); @@ -568,8 +569,8 @@ void TestQgsLayoutScaleBar::dataDefined() scalebar->setMinimumBarWidth( 11 ); scalebar->setMaximumBarWidth( 13 ); - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 1 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 0, 0, 0 ) ); @@ -577,8 +578,8 @@ void TestQgsLayoutScaleBar::dataDefined() scalebar->setLineSymbol( lineSymbol.release() ); scalebar->setStyle( QStringLiteral( "Single Box" ) ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setNumberDecimalPlaces( 0 ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setNumberDecimalPlaces( 0 ); QFont newFont = QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ); newFont.setPointSizeF( 12 ); @@ -594,9 +595,9 @@ void TestQgsLayoutScaleBar::dataDefined() // non-deprecated Data Defined Properties (as of QGIS 3.26) // The values should override the manually set values set previous so that we can test that they are correctly being applied scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarLeftSegments, QgsProperty::fromExpression( QStringLiteral( "0" ) ) ); - scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarRightSegments, QgsProperty::fromExpression( QStringLiteral( "length('Hi')" ) ) ); // basic expression -> 2 - scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarSegmentWidth, QgsProperty::fromExpression( QStringLiteral( "1000.0 * 2.0" ) ) ); // basic math expression -> 2 - scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarMinimumWidth, QgsProperty::fromExpression( QStringLiteral( "to_real('50.0')" ) ) ); // basic conversion expression -> 50 + scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarRightSegments, QgsProperty::fromExpression( QStringLiteral( "length('Hi')" ) ) ); // basic expression -> 2 + scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarSegmentWidth, QgsProperty::fromExpression( QStringLiteral( "1000.0 * 2.0" ) ) ); // basic math expression -> 2 + scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarMinimumWidth, QgsProperty::fromExpression( QStringLiteral( "to_real('50.0')" ) ) ); // basic conversion expression -> 50 scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarMaximumWidth, QgsProperty::fromExpression( QStringLiteral( "to_real('50.0') * 3" ) ) ); // basic conversion with math expression -> 150 scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarHeight, QgsProperty::fromExpression( QStringLiteral( "20" ) ) ); scalebar->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::ScalebarSubdivisionHeight, QgsProperty::fromExpression( QStringLiteral( "30" ) ) ); @@ -622,13 +623,13 @@ void TestQgsLayoutScaleBar::oldDataDefinedProject() // read a project with the older data defined line width and color project.read( QStringLiteral( TEST_DATA_DIR ) + "/layouts/scalebar_old_datadefined.qgs" ); QgsLayout *l = project.layoutManager()->printLayouts().at( 0 ); - QList< QgsLayoutItemScaleBar * > scaleBars; + QList scaleBars; l->layoutItems( scaleBars ); QgsLayoutItemScaleBar *scaleBar = scaleBars.at( 0 ); // ensure the deprecated scalebar datadefined properties were automatically copied to the scalebar's line symbol QgsLineSymbol *ls = scaleBar->lineSymbol(); - QgsSimpleLineSymbolLayer *sll = dynamic_cast< QgsSimpleLineSymbolLayer * >( ls->symbolLayer( 0 ) ); + QgsSimpleLineSymbolLayer *sll = dynamic_cast( ls->symbolLayer( 0 ) ); QVERIFY( sll->dataDefinedProperties().property( QgsSymbolLayer::Property::StrokeWidth ).isActive() ); QCOMPARE( sll->dataDefinedProperties().property( QgsSymbolLayer::Property::StrokeWidth ).asExpression(), QStringLiteral( "3" ) ); @@ -663,7 +664,7 @@ void TestQgsLayoutScaleBar::textFormat() scalebar->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP scalebar->setStyle( QStringLiteral( "Single Box" ) ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); QgsTextFormat format = QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); format.setSize( 16 ); @@ -696,9 +697,9 @@ void TestQgsLayoutScaleBar::numericFormat() scalebar->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP scalebar->setStyle( QStringLiteral( "Single Box" ) ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( true ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowPlusSign( true ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setNumberDecimalPlaces( 1 ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( true ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowPlusSign( true ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setNumberDecimalPlaces( 1 ); QFont newFont = QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ); newFont.setPointSizeF( 12 ); @@ -729,14 +730,14 @@ void TestQgsLayoutScaleBar::steppedLine() scalebar->setHeight( 20 ); scalebar->setSubdivisionsHeight( 25 ); //ensure subdivisionsHeight is non used in non tick-style scalebars - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 4 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 0, 0 ) ); lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() ); - lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 2 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 255, 0 ) ); @@ -744,7 +745,7 @@ void TestQgsLayoutScaleBar::steppedLine() scalebar->setLineSymbol( lineSymbol.release() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "stepped" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_stepped" ), &l ); @@ -772,14 +773,14 @@ void TestQgsLayoutScaleBar::hollow() scalebar->setHeight( 20 ); scalebar->setSubdivisionsHeight( 25 ); //ensure subdivisionsHeight is non used in non tick-style scalebars - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 4 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 0, 0 ) ); lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() ); - lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 2 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 255, 0 ) ); @@ -787,21 +788,21 @@ void TestQgsLayoutScaleBar::hollow() scalebar->setLineSymbol( lineSymbol.release() ); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol = std::make_unique(); + std::unique_ptr fillSymbolLayer = std::make_unique(); fillSymbolLayer->setColor( QColor( 255, 0, 0 ) ); fillSymbolLayer->setColor2( QColor( 255, 255, 0 ) ); fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() ); scalebar->setFillSymbol( fillSymbol.release() ); - std::unique_ptr< QgsFillSymbol > fillSymbol2 = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer2 = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol2 = std::make_unique(); + std::unique_ptr fillSymbolLayer2 = std::make_unique(); fillSymbolLayer2->setColor( QColor( 0, 255, 0 ) ); fillSymbolLayer2->setColor2( QColor( 255, 255, 255 ) ); fillSymbol2->changeSymbolLayer( 0, fillSymbolLayer2.release() ); scalebar->setAlternateFillSymbol( fillSymbol2.release() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "hollow" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_hollow" ), &l ); @@ -811,17 +812,17 @@ void TestQgsLayoutScaleBar::hollowDefaults() { QgsLayout l( QgsProject::instance() ); - std::unique_ptr< QgsLayoutItemScaleBar > scalebar = std::make_unique< QgsLayoutItemScaleBar >( &l ); + std::unique_ptr scalebar = std::make_unique( &l ); // apply random symbols - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 4 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 0, 0 ) ); lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() ); - lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 2 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 255, 0 ) ); @@ -829,15 +830,15 @@ void TestQgsLayoutScaleBar::hollowDefaults() scalebar->setLineSymbol( lineSymbol.release() ); - std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol = std::make_unique(); + std::unique_ptr fillSymbolLayer = std::make_unique(); fillSymbolLayer->setColor( QColor( 255, 0, 0 ) ); fillSymbolLayer->setColor2( QColor( 255, 255, 0 ) ); fillSymbol->changeSymbolLayer( 0, fillSymbolLayer.release() ); scalebar->setFillSymbol( fillSymbol.release() ); - std::unique_ptr< QgsFillSymbol > fillSymbol2 = std::make_unique< QgsFillSymbol >(); - std::unique_ptr< QgsGradientFillSymbolLayer > fillSymbolLayer2 = std::make_unique< QgsGradientFillSymbolLayer >(); + std::unique_ptr fillSymbol2 = std::make_unique(); + std::unique_ptr fillSymbolLayer2 = std::make_unique(); fillSymbolLayer2->setColor( QColor( 0, 255, 0 ) ); fillSymbolLayer2->setColor2( QColor( 255, 255, 255 ) ); fillSymbol2->changeSymbolLayer( 0, fillSymbolLayer2.release() ); @@ -847,11 +848,10 @@ void TestQgsLayoutScaleBar::hollowDefaults() QgsHollowScaleBarRenderer renderer; scalebar->applyDefaultRendererSettings( &renderer ); // should be reset to "null" fill symbols - QCOMPARE( qgis::down_cast< QgsSimpleFillSymbolLayer * >( scalebar->fillSymbol()->symbolLayer( 0 ) )->brushStyle(), Qt::NoBrush ); - QCOMPARE( qgis::down_cast< QgsSimpleFillSymbolLayer * >( scalebar->alternateFillSymbol()->symbolLayer( 0 ) )->brushStyle(), Qt::NoBrush ); + QCOMPARE( qgis::down_cast( scalebar->fillSymbol()->symbolLayer( 0 ) )->brushStyle(), Qt::NoBrush ); + QCOMPARE( qgis::down_cast( scalebar->alternateFillSymbol()->symbolLayer( 0 ) )->brushStyle(), Qt::NoBrush ); // stroke should be unchanged - QCOMPARE( qgis::down_cast< QgsSimpleLineSymbolLayer * >( scalebar->lineSymbol()->symbolLayer( 0 ) )->color(), QColor( 255, 0, 0 ) ); - + QCOMPARE( qgis::down_cast( scalebar->lineSymbol()->symbolLayer( 0 ) )->color(), QColor( 255, 0, 0 ) ); } void TestQgsLayoutScaleBar::tickSubdivisions() @@ -878,14 +878,14 @@ void TestQgsLayoutScaleBar::tickSubdivisions() scalebar->setSubdivisionsHeight( 3 ); - std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >(); - std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + std::unique_ptr lineSymbol = std::make_unique(); + std::unique_ptr lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 4 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 0, 0 ) ); lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() ); - lineSymbolLayer = std::make_unique< QgsSimpleLineSymbolLayer >(); + lineSymbolLayer = std::make_unique(); lineSymbolLayer->setWidth( 2 ); lineSymbolLayer->setWidthUnit( Qgis::RenderUnit::Millimeters ); lineSymbolLayer->setColor( QColor( 255, 255, 0 ) ); @@ -893,15 +893,15 @@ void TestQgsLayoutScaleBar::tickSubdivisions() scalebar->setLineSymbol( lineSymbol->clone() ); - qgis::down_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setWidth( 5 ); - qgis::down_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 255, 0 ) ); + qgis::down_cast( lineSymbol->symbolLayer( 0 ) )->setWidth( 5 ); + qgis::down_cast( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 255, 0 ) ); scalebar->setDivisionLineSymbol( lineSymbol->clone() ); - qgis::down_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setWidth( 6 ); - qgis::down_cast< QgsLineSymbolLayer * >( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 0, 255 ) ); + qgis::down_cast( lineSymbol->symbolLayer( 0 ) )->setWidth( 6 ); + qgis::down_cast( lineSymbol->symbolLayer( 0 ) )->setColor( QColor( 0, 0, 255 ) ); scalebar->setSubdivisionLineSymbol( lineSymbol->clone() ); - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar->setStyle( QStringLiteral( "Line Ticks Middle" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "layoutscalebar_tick_subdivisions" ), &l ); @@ -935,7 +935,7 @@ void TestQgsLayoutScaleBar::methodTop() Q_NOWARN_DEPRECATED_PUSH scalebar1->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar1->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar1->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar1->setStyle( QStringLiteral( "Single Box" ) ); QgsLayoutItemScaleBar *scalebar1A = new QgsLayoutItemScaleBar( &l ); @@ -953,7 +953,7 @@ void TestQgsLayoutScaleBar::methodTop() Q_NOWARN_DEPRECATED_PUSH scalebar1A->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar1A->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar1A->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar1A->setStyle( QStringLiteral( "Single Box" ) ); QgsLayoutItemMap *map2 = new QgsLayoutItemMap( &l ); @@ -980,7 +980,7 @@ void TestQgsLayoutScaleBar::methodTop() Q_NOWARN_DEPRECATED_PUSH scalebar2->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar2->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar2->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar2->setStyle( QStringLiteral( "Single Box" ) ); QgsLayoutItemScaleBar *scalebar2A = new QgsLayoutItemScaleBar( &l ); @@ -998,7 +998,7 @@ void TestQgsLayoutScaleBar::methodTop() Q_NOWARN_DEPRECATED_PUSH scalebar2A->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar2A->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar2A->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar2A->setStyle( QStringLiteral( "Single Box" ) ); QgsLayoutItemMap *map3 = new QgsLayoutItemMap( &l ); @@ -1025,7 +1025,7 @@ void TestQgsLayoutScaleBar::methodTop() Q_NOWARN_DEPRECATED_PUSH scalebar3->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar3->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar3->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar3->setStyle( QStringLiteral( "Single Box" ) ); QgsLayoutItemScaleBar *scalebar3A = new QgsLayoutItemScaleBar( &l ); @@ -1043,7 +1043,7 @@ void TestQgsLayoutScaleBar::methodTop() Q_NOWARN_DEPRECATED_PUSH scalebar3A->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar3A->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar3A->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar3A->setStyle( QStringLiteral( "Single Box" ) ); QgsLayoutItemMap *map4 = new QgsLayoutItemMap( &l ); @@ -1070,7 +1070,7 @@ void TestQgsLayoutScaleBar::methodTop() Q_NOWARN_DEPRECATED_PUSH scalebar4->setLineWidth( 1.0 ); Q_NOWARN_DEPRECATED_POP - qgis::down_cast< QgsBasicNumericFormat *>( const_cast< QgsNumericFormat * >( scalebar4->numericFormat() ) )->setShowThousandsSeparator( false ); + qgis::down_cast( const_cast( scalebar4->numericFormat() ) )->setShowThousandsSeparator( false ); scalebar4->setStyle( QStringLiteral( "Single Box" ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "scalebar_method" ), &l ); diff --git a/tests/src/core/testqgslayoutshapes.cpp b/tests/src/core/testqgslayoutshapes.cpp index c6dff2d7cda8..32ef916cc12a 100644 --- a/tests/src/core/testqgslayoutshapes.cpp +++ b/tests/src/core/testqgslayoutshapes.cpp @@ -34,16 +34,17 @@ class TestQgsLayoutShapes : public QgsTest Q_OBJECT public: - TestQgsLayoutShapes() : QgsTest( QStringLiteral( "Layout Shape Tests" ), QStringLiteral( "composer_shapes" ) ) {} + TestQgsLayoutShapes() + : QgsTest( QStringLiteral( "Layout Shape Tests" ), QStringLiteral( "composer_shapes" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void rectangle(); //test if rectangle shape is functioning - void triangle(); //test if triangle shape is functioning - void ellipse(); //test if ellipse shape is functioning + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void rectangle(); //test if rectangle shape is functioning + void triangle(); //test if triangle shape is functioning + void ellipse(); //test if ellipse shape is functioning void roundedRectangle(); //test if rounded rectangle shape is functioning - void symbol(); //test if styling shapes via symbol is working + void symbol(); //test if styling shapes via symbol is working void readWriteXml(); void bounds(); void shapeRotation(); @@ -71,7 +72,7 @@ void TestQgsLayoutShapes::rectangle() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol( new QgsFillSymbol() ); + std::unique_ptr fillSymbol( new QgsFillSymbol() ); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); @@ -96,7 +97,7 @@ void TestQgsLayoutShapes::triangle() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol( new QgsFillSymbol() ); + std::unique_ptr fillSymbol( new QgsFillSymbol() ); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); @@ -121,7 +122,7 @@ void TestQgsLayoutShapes::ellipse() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol( new QgsFillSymbol() ); + std::unique_ptr fillSymbol( new QgsFillSymbol() ); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); @@ -145,7 +146,7 @@ void TestQgsLayoutShapes::roundedRectangle() shape->attemptResize( QgsLayoutSize( 150, 100 ) ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); - std::unique_ptr< QgsFillSymbol > fillSymbol( new QgsFillSymbol() ); + std::unique_ptr fillSymbol( new QgsFillSymbol() ); fillSymbol->changeSymbolLayer( 0, simpleFill ); simpleFill->setColor( QColor( 255, 150, 0 ) ); simpleFill->setStrokeColor( QColor( 0, 0, 0 ) ); @@ -188,7 +189,7 @@ void TestQgsLayoutShapes::readWriteXml() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemShape > shape = std::make_unique< QgsLayoutItemShape >( &l ); + std::unique_ptr shape = std::make_unique( &l ); shape->setShapeType( QgsLayoutItemShape::Triangle ); QgsSimpleFillSymbolLayer *simpleFill = new QgsSimpleFillSymbolLayer(); QgsFillSymbol *fillSymbol = new QgsFillSymbol(); @@ -201,16 +202,16 @@ void TestQgsLayoutShapes::readWriteXml() //save original item to xml QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); shape->writeXml( rootNode, doc, QgsReadWriteContext() ); //create new item and restore settings from xml - std::unique_ptr< QgsLayoutItemShape > copy = std::make_unique< QgsLayoutItemShape >( &l ); + std::unique_ptr copy = std::make_unique( &l ); QVERIFY( copy->readXml( rootNode.firstChildElement(), doc, QgsReadWriteContext() ) ); QCOMPARE( copy->shapeType(), QgsLayoutItemShape::Triangle ); QCOMPARE( copy->symbol()->symbolLayer( 0 )->color().name(), QStringLiteral( "#00ff00" ) ); @@ -221,7 +222,7 @@ void TestQgsLayoutShapes::bounds() { QgsProject p; QgsLayout l( &p ); - std::unique_ptr< QgsLayoutItemShape > shape = std::make_unique< QgsLayoutItemShape >( &l ); + std::unique_ptr shape = std::make_unique( &l ); shape->attemptMove( QgsLayoutPoint( 20, 20 ) ); shape->attemptResize( QgsLayoutSize( 150, 100 ) ); diff --git a/tests/src/core/testqgslayouttable.cpp b/tests/src/core/testqgslayouttable.cpp index cd43366d32c1..446c12acb228 100644 --- a/tests/src/core/testqgslayouttable.cpp +++ b/tests/src/core/testqgslayouttable.cpp @@ -46,41 +46,42 @@ class TestQgsLayoutTable : public QgsTest Q_OBJECT public: - TestQgsLayoutTable() : QgsTest( QStringLiteral( "Layout Table Tests" ), QStringLiteral( "composer_table" ) ) {} + TestQgsLayoutTable() + : QgsTest( QStringLiteral( "Layout Table Tests" ), QStringLiteral( "composer_table" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - - void attributeTableHeadings(); //test retrieving attribute table headers - void attributeTableRows(); //test retrieving attribute table rows - void attributeTableFormattedRows(); //test retrieving attribute formatted table rows - void attributeTableRowsLocalized(); //test retrieving attribute table rows with locale + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + + void attributeTableHeadings(); //test retrieving attribute table headers + void attributeTableRows(); //test retrieving attribute table rows + void attributeTableFormattedRows(); //test retrieving attribute formatted table rows + void attributeTableRowsLocalized(); //test retrieving attribute table rows with locale void attributeTableFilterFeatures(); //test filtering attribute table rows - void attributeTableSetAttributes(); //test subset of attributes in table - void attributeTableVisibleOnly(); //test displaying only visible attributes + void attributeTableSetAttributes(); //test subset of attributes in table + void attributeTableVisibleOnly(); //test displaying only visible attributes void attributeTableInsideAtlasOnly(); void attributeTableRender(); //test rendering attribute table - void manualColumnWidth(); //test setting manual column widths - void attributeTableEmpty(); //test empty modes for attribute table - void showEmptyRows(); //test showing empty rows + void manualColumnWidth(); //test setting manual column widths + void attributeTableEmpty(); //test empty modes for attribute table + void showEmptyRows(); //test showing empty rows void attributeTableExtend(); void attributeTableRepeat(); void attributeTableAtlasSource(); //test attribute table in atlas feature mode void attributeTableRestoreAtlasSource(); - void attributeTableRelationSource(); //test attribute table in relation mode - void contentsContainsRow(); //test the contentsContainsRow function - void removeDuplicates(); //test removing duplicate rows - void multiLineText(); //test rendering a table with multiline text - void horizontalGrid(); //test rendering a table with horizontal-only grid - void verticalGrid(); //test rendering a table with vertical-only grid - void align(); //test alignment of table cells - void wrapChar(); //test setting wrap character - void autoWrap(); //test auto word wrap - void cellStyles(); //test cell styles - void cellStylesRender(); //test rendering cell styles - void conditionalFormatting(); //test rendering with conditional formatting + void attributeTableRelationSource(); //test attribute table in relation mode + void contentsContainsRow(); //test the contentsContainsRow function + void removeDuplicates(); //test removing duplicate rows + void multiLineText(); //test rendering a table with multiline text + void horizontalGrid(); //test rendering a table with horizontal-only grid + void verticalGrid(); //test rendering a table with vertical-only grid + void align(); //test alignment of table cells + void wrapChar(); //test setting wrap character + void autoWrap(); //test auto word wrap + void cellStyles(); //test cell styles + void cellStylesRender(); //test rendering cell styles + void conditionalFormatting(); //test rendering with conditional formatting void conditionalFormattingWithTextFormatting(); //test rendering with conditional formatting with text formatting void dataDefinedSource(); void wrappedText(); @@ -104,9 +105,7 @@ void TestQgsLayoutTable::initTestCase() //create maplayers from testdata and add to layer registry const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( mVectorLayer ); QgsFontUtils::loadStandardTestFonts( QStringList() << QStringLiteral( "Bold" ) ); @@ -222,26 +221,26 @@ void TestQgsLayoutTable::attributeTableFormattedRows() QgsVectorLayer vl { QStringLiteral( "Point?field=int:int" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) }; QVariantList valueConfig; QVariantMap config; - config[ QStringLiteral( "one" ) ] = QStringLiteral( "1" ); - config[ QStringLiteral( "two" ) ] = QStringLiteral( "2" ); + config[QStringLiteral( "one" )] = QStringLiteral( "1" ); + config[QStringLiteral( "two" )] = QStringLiteral( "2" ); valueConfig.append( config ); QVariantMap editorConfig; editorConfig.insert( QStringLiteral( "map" ), valueConfig ); vl.setEditorWidgetSetup( 0, QgsEditorWidgetSetup( QStringLiteral( "ValueMap" ), editorConfig ) ); - QgsFeature f { vl.fields( ) }; + QgsFeature f { vl.fields() }; f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "point(9 45)" ) ) ); f.setAttribute( QStringLiteral( "int" ), 2 ); - QgsFeature f2 { vl.fields( ) }; + QgsFeature f2 { vl.fields() }; f2.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "point(10 46)" ) ) ); f2.setAttribute( QStringLiteral( "int" ), 1 ); vl.dataProvider()->addFeatures( QgsFeatureList() << f << f2 ); QVector expectedRows; QStringList row; - row << QStringLiteral( "two" ); + row << QStringLiteral( "two" ); expectedRows.append( row ); QStringList row2; - row2 << QStringLiteral( "one" ); + row2 << QStringLiteral( "one" ); expectedRows.append( row2 ); QgsLayout l( QgsProject::instance() ); @@ -251,7 +250,6 @@ void TestQgsLayoutTable::attributeTableFormattedRows() //retrieve rows and check compareTable( table, expectedRows ); - } void TestQgsLayoutTable::attributeTableRowsLocalized() @@ -259,7 +257,7 @@ void TestQgsLayoutTable::attributeTableRowsLocalized() //test retrieving attribute table rows QgsVectorLayer vl { QStringLiteral( "Point?field=int:int&field=double:double&" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) }; - QgsFeature f { vl.fields( ) }; + QgsFeature f { vl.fields() }; f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "point(9 45)" ) ) ); f.setAttribute( QStringLiteral( "int" ), 12346 ); f.setAttribute( QStringLiteral( "double" ), 123456.801 ); @@ -267,7 +265,7 @@ void TestQgsLayoutTable::attributeTableRowsLocalized() QVector expectedRows; QStringList row; - row << QStringLiteral( "12,346" ) << QStringLiteral( "123,456.801" ); + row << QStringLiteral( "12,346" ) << QStringLiteral( "123,456.801" ); expectedRows.append( row ); QgsLayout l( QgsProject::instance() ); @@ -281,13 +279,12 @@ void TestQgsLayoutTable::attributeTableRowsLocalized() expectedRows.clear(); row.clear(); - row << QStringLiteral( "12.346" ) << QStringLiteral( "123.456,801" ); + row << QStringLiteral( "12.346" ) << QStringLiteral( "123.456,801" ); expectedRows.append( row ); QLocale::setDefault( QLocale::Italian ); compareTable( table, expectedRows ); QLocale::setDefault( QLocale::English ); - } @@ -451,7 +448,7 @@ void TestQgsLayoutTable::attributeTableInsideAtlasOnly() compareTable( table, expectedRows, false ); //setup atlas - std::unique_ptr< QgsVectorLayer > atlasLayer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=EPSG:3857" ), QStringLiteral( "atlas" ), QStringLiteral( "memory" ) ); + std::unique_ptr atlasLayer = std::make_unique( QStringLiteral( "Polygon?crs=EPSG:3857" ), QStringLiteral( "atlas" ), QStringLiteral( "memory" ) ); QVERIFY( atlasLayer->isValid() ); const QgsGeometry atlasGeom( QgsGeometry::fromWkt( QStringLiteral( "Polygon ((-8863916.31126776337623596 4621257.48816855065524578, -9664269.45078738406300545 5097056.938785120844841, -10049249.44194872118532658 3765399.75924854446202517, -8985488.94005555473268032 3458599.17133777122944593, -8863916.31126776337623596 4621257.48816855065524578))" ) ) ); QgsFeature f; @@ -688,9 +685,7 @@ void TestQgsLayoutTable::attributeTableAtlasSource() //setup atlas QgsVectorLayer *vectorLayer = nullptr; const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - vectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + vectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( vectorLayer ); l.reportContext().setLayer( vectorLayer ); @@ -739,7 +734,6 @@ void TestQgsLayoutTable::attributeTableAtlasSource() //try for a crash when removing current atlas layer QgsProject::instance()->removeMapLayer( vectorLayer->id() ); table->refreshAttributes(); - } void TestQgsLayoutTable::attributeTableRestoreAtlasSource() @@ -748,8 +742,8 @@ void TestQgsLayoutTable::attributeTableRestoreAtlasSource() QgsProject p; p.read( projectPath ); - QgsPrintLayout *l = dynamic_cast< QgsPrintLayout *>( p.layoutManager()->layouts().at( 0 ) ); - QgsLayoutItemAttributeTable *table = qobject_cast< QgsLayoutItemAttributeTable * >( l->multiFrames().at( 0 ) ); + QgsPrintLayout *l = dynamic_cast( p.layoutManager()->layouts().at( 0 ) ); + QgsLayoutItemAttributeTable *table = qobject_cast( l->multiFrames().at( 0 ) ); QCOMPARE( table->source(), QgsLayoutItemAttributeTable::AtlasFeature ); QVERIFY( l->atlas()->coverageLayer() ); QVERIFY( l->atlas()->coverageLayer()->isValid() ); @@ -781,9 +775,7 @@ void TestQgsLayoutTable::attributeTableRelationSource() table->setBackgroundColor( Qt::yellow ); const QFileInfo vectorFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points_relations.shp" ); - QgsVectorLayer *atlasLayer = new QgsVectorLayer( vectorFileInfo.filePath(), - vectorFileInfo.completeBaseName(), - QStringLiteral( "ogr" ) ); + QgsVectorLayer *atlasLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( atlasLayer ); @@ -1130,7 +1122,7 @@ void TestQgsLayoutTable::testIntegerNullCell() l.addLayoutItem( frame ); table->addFrame( frame ); - std::unique_ptr layer = std::make_unique< QgsVectorLayer> ( QStringLiteral( "Point?field=intf:integer" ), QStringLiteral( "point" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?field=intf:integer" ), QStringLiteral( "point" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsFeature f1( layer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "intf" ), 1 ); @@ -1145,7 +1137,6 @@ void TestQgsLayoutTable::testIntegerNullCell() table->setHeaderTextFormat( QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ) ); QGSVERIFYLAYOUTCHECK( QStringLiteral( "composerattributetable_integernullcell" ), &l ); - } void TestQgsLayoutTable::align() @@ -1216,7 +1207,7 @@ void TestQgsLayoutTable::wrapChar() table->setHeaderTextFormat( QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ) ); table->setBackgroundColor( Qt::yellow ); - std::unique_ptr< QgsVectorLayer > multiLineLayer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "multiline" ), QStringLiteral( "memory" ) ); + std::unique_ptr multiLineLayer = std::make_unique( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "multiline" ), QStringLiteral( "memory" ) ); QVERIFY( multiLineLayer->isValid() ); QgsFeature f1( multiLineLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "col1" ), "multiline\nstring" ); @@ -1257,7 +1248,7 @@ void TestQgsLayoutTable::autoWrap() table->setHeaderTextFormat( QgsTextFormat::fromQFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ) ); table->setBackgroundColor( Qt::yellow ); - std::unique_ptr< QgsVectorLayer > multiLineLayer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "multiline" ), QStringLiteral( "memory" ) ); + std::unique_ptr multiLineLayer = std::make_unique( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "multiline" ), QStringLiteral( "memory" ) ); QVERIFY( multiLineLayer->isValid() ); QgsFeature f1( multiLineLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "col1" ), "long multiline\nstring" ); @@ -1314,9 +1305,9 @@ void TestQgsLayoutTable::cellStyles() //write to xml QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); //test writing with no node @@ -1570,7 +1561,7 @@ void TestQgsLayoutTable::conditionalFormatting() style2.setRule( QStringLiteral( "@value > 5" ) ); style2.setTextColor( QColor( 255, 0, 0 ) ); style2.setBackgroundColor( QColor( 0, 0, 255 ) ); - mVectorLayer->conditionalStyles()->setFieldStyles( QStringLiteral( "Staff" ), QList< QgsConditionalStyle >() << style2 ); + mVectorLayer->conditionalStyles()->setFieldStyles( QStringLiteral( "Staff" ), QList() << style2 ); table->setUseConditionalStyling( true ); @@ -1637,7 +1628,7 @@ void TestQgsLayoutTable::conditionalFormattingWithTextFormatting() QFont conditionalFont2 = QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ); conditionalFont2.setUnderline( true ); style2.setFont( conditionalFont2 ); - mVectorLayer->conditionalStyles()->setFieldStyles( QStringLiteral( "Staff" ), QList< QgsConditionalStyle >() << style2 ); + mVectorLayer->conditionalStyles()->setFieldStyles( QStringLiteral( "Staff" ), QList() << style2 ); table->setUseConditionalStyling( true ); @@ -1696,25 +1687,25 @@ void TestQgsLayoutTable::dataDefinedSource() table->setVectorLayer( layer1 ); table->setMaximumNumberOfFeatures( 50 ); QCOMPARE( table->contents().length(), 1 ); - QCOMPARE( table->contents().at( 0 ), QVector< QVariant >() << 1 << 2 << 3 ); + QCOMPARE( table->contents().at( 0 ), QVector() << 1 << 2 << 3 ); // data defined table name, by layer id table->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::AttributeTableSourceLayer, layer1->id() ); table->refresh(); QCOMPARE( table->contents().length(), 1 ); - QCOMPARE( table->contents().at( 0 ), QVector< QVariant >() << 1 << 2 << 3 ); + QCOMPARE( table->contents().at( 0 ), QVector() << 1 << 2 << 3 ); // by layer name table->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::AttributeTableSourceLayer, QStringLiteral( "l2" ) ); table->refresh(); QCOMPARE( table->contents().length(), 1 ); - QCOMPARE( table->contents().at( 0 ), QVector< QVariant >() << 11 << 12 << 13 ); + QCOMPARE( table->contents().at( 0 ), QVector() << 11 << 12 << 13 ); // by layer name (case insensitive) table->dataDefinedProperties().setProperty( QgsLayoutObject::DataDefinedProperty::AttributeTableSourceLayer, QStringLiteral( "L3" ) ); table->refresh(); QCOMPARE( table->contents().length(), 1 ); - QCOMPARE( table->contents().at( 0 ), QVector< QVariant >() << 21 << QVariant() << 23 ); + QCOMPARE( table->contents().at( 0 ), QVector() << 21 << QVariant() << 23 ); // delete current data defined layer match p.removeMapLayer( layer3->id() ); @@ -1722,7 +1713,7 @@ void TestQgsLayoutTable::dataDefinedSource() // expect table to return to preset layer table->refreshAttributes(); QCOMPARE( table->contents().length(), 1 ); - QCOMPARE( table->contents().at( 0 ), QVector< QVariant >() << 1 << 2 << 3 ); + QCOMPARE( table->contents().at( 0 ), QVector() << 1 << 2 << 3 ); } void TestQgsLayoutTable::wrappedText() @@ -1749,7 +1740,7 @@ void TestQgsLayoutTable::testBaseSort() QgsLayoutTableColumn col; col.setAttribute( table->columns()[2].attribute() ); col.setSortOrder( Qt::DescendingOrder ); - table->sortColumns() = {col}; + table->sortColumns() = { col }; table->refresh(); QVector expectedRows; @@ -1774,7 +1765,7 @@ void TestQgsLayoutTable::testExpressionSort() col.setAttribute( "Heading * -1" ); col.setHeading( "exp" ); col.setSortOrder( Qt::AscendingOrder ); - table->sortColumns() = {col}; + table->sortColumns() = { col }; table->columns()[0] = col; table->refresh(); @@ -1796,7 +1787,7 @@ void TestQgsLayoutTable::testScopeForCell() table->setVectorLayer( mVectorLayer ); table->refresh(); - std::unique_ptr< QgsExpressionContextScope > scope( table->scopeForCell( 0, 0 ) ); + std::unique_ptr scope( table->scopeForCell( 0, 0 ) ); // variable values for row/col should start at 1, not 0! QCOMPARE( scope->variable( QStringLiteral( "row_number" ) ).toInt(), 1 ); diff --git a/tests/src/core/testqgslayoutunits.cpp b/tests/src/core/testqgslayoutunits.cpp index 70c894ca0229..4b2659f9535d 100644 --- a/tests/src/core/testqgslayoutunits.cpp +++ b/tests/src/core/testqgslayoutunits.cpp @@ -28,86 +28,82 @@ class TestQgsLayoutUnits : public QgsTest { Q_OBJECT public: - TestQgsLayoutUnits() : QgsTest( QStringLiteral( "Layout Units Tests" ) ) {} + TestQgsLayoutUnits() + : QgsTest( QStringLiteral( "Layout Units Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. //QgsLayoutUnits void encodeDecode(); //test encoding and decoding layout units //QgsLayoutMeasurement - void create(); //test creating new measurement - void gettersSetters(); //test getting/setting properties - void copyConstructor(); //test copy constructor - void equality(); //test measurement equality - void assignment(); //test measurement assignment - void operators(); //test measurement operators - void unitTypes(); //test unit types + void create(); //test creating new measurement + void gettersSetters(); //test getting/setting properties + void copyConstructor(); //test copy constructor + void equality(); //test measurement equality + void assignment(); //test measurement assignment + void operators(); //test measurement operators + void unitTypes(); //test unit types void measurementEncodeDecode(); //test encoding and decoding measurement //QgsLayoutSize - void createSize(); //test creating new layout size - void sizeGettersSetters(); //test getting/setting properties + void createSize(); //test creating new layout size + void sizeGettersSetters(); //test getting/setting properties void sizeCopyConstructor(); //test copy constructor - void sizeEquality(); //test size equality - void sizeAssignment(); //test size assignment - void sizeOperators(); //test size operators - void isEmpty(); //test isEmpty method - void toQSizeF(); //test conversion to QSizeF - void sizeEncodeDecode(); //test encoding and decoding size + void sizeEquality(); //test size equality + void sizeAssignment(); //test size assignment + void sizeOperators(); //test size operators + void isEmpty(); //test isEmpty method + void toQSizeF(); //test conversion to QSizeF + void sizeEncodeDecode(); //test encoding and decoding size //QgsLayoutPoint - void createPoint(); //test creating new layout point - void pointGettersSetters(); //test getting/setting properties + void createPoint(); //test creating new layout point + void pointGettersSetters(); //test getting/setting properties void pointCopyConstructor(); //test copy constructor - void pointEquality(); //test point equality - void pointAssignment(); //test point assignment - void pointOperators(); //test point operators - void isNull(); //test isEmpty method - void toQPointF(); //test conversion to QPointF - void pointEncodeDecode(); //test encoding and decoding point - - void converterCreate(); //test creating new converter - void converterCopy(); //test creating new converter using copy constructor + void pointEquality(); //test point equality + void pointAssignment(); //test point assignment + void pointOperators(); //test point operators + void isNull(); //test isEmpty method + void toQPointF(); //test conversion to QPointF + void pointEncodeDecode(); //test encoding and decoding point + + void converterCreate(); //test creating new converter + void converterCopy(); //test creating new converter using copy constructor void converterGettersSetters(); //test getting/setting converter properties - void conversionToMM(); //test conversion to mm - void conversionToCM(); //test conversion to cm - void conversionToM(); //test conversion to m - void conversionToInches(); //test conversion to inches - void conversionToFeet(); //test conversion to feet - void conversionToPoints(); //test conversion to points - void conversionToPicas(); //test conversion to picas - void conversionFromPixels(); //test conversion from pixels and handling of dpi - void conversionToPixels(); //test conversion to pixels and handling of dpi - void sizeConversion(); //test conversion of QgsLayoutSizes - void pointConversion(); //test conversion of QgsLayoutPoint + void conversionToMM(); //test conversion to mm + void conversionToCM(); //test conversion to cm + void conversionToM(); //test conversion to m + void conversionToInches(); //test conversion to inches + void conversionToFeet(); //test conversion to feet + void conversionToPoints(); //test conversion to points + void conversionToPicas(); //test conversion to picas + void conversionFromPixels(); //test conversion from pixels and handling of dpi + void conversionToPixels(); //test conversion to pixels and handling of dpi + void sizeConversion(); //test conversion of QgsLayoutSizes + void pointConversion(); //test conversion of QgsLayoutPoint private: - }; void TestQgsLayoutUnits::initTestCase() { - } void TestQgsLayoutUnits::cleanupTestCase() { - } void TestQgsLayoutUnits::init() { - } void TestQgsLayoutUnits::cleanup() { - } void TestQgsLayoutUnits::encodeDecode() diff --git a/tests/src/core/testqgslayoututils.cpp b/tests/src/core/testqgslayoututils.cpp index d49474d4e587..7b40d6c3183d 100644 --- a/tests/src/core/testqgslayoututils.cpp +++ b/tests/src/core/testqgslayoututils.cpp @@ -26,15 +26,16 @@ #include -class TestQgsLayoutUtils: public QgsTest +class TestQgsLayoutUtils : public QgsTest { Q_OBJECT public: - TestQgsLayoutUtils() : QgsTest( QStringLiteral( "Layout Utils Tests" ), QStringLiteral( "composer_utils" ) ) {} + TestQgsLayoutUtils() + : QgsTest( QStringLiteral( "Layout Utils Tests" ), QStringLiteral( "composer_utils" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); void rotate(); void normalizedAngle(); //test normalised angle function @@ -43,23 +44,22 @@ class TestQgsLayoutUtils: public QgsTest void createRenderContextFromMap(); void relativePosition(); void relativeResizeRect(); - void pointsToMM(); //test conversion of point size to mm - void mmToPoints(); //test conversion of mm to point size - void scaledFontPixelSize(); //test creating a scaled font - void fontAscentMM(); //test calculating font ascent in mm - void fontDescentMM(); //test calculating font descent in mm - void fontHeightMM(); //test calculating font height in mm + void pointsToMM(); //test conversion of point size to mm + void mmToPoints(); //test conversion of mm to point size + void scaledFontPixelSize(); //test creating a scaled font + void fontAscentMM(); //test calculating font ascent in mm + void fontDescentMM(); //test calculating font descent in mm + void fontHeightMM(); //test calculating font height in mm void fontHeightCharacterMM(); //test calculating font character height in mm - void textWidthMM(); //test calculating text width in mm - void textHeightMM(); //test calculating text height in mm - void drawTextPos(); //test drawing text at a pos - void drawTextRect(); //test drawing text in a rect - void largestRotatedRect(); //test largest rotated rect helper function + void textWidthMM(); //test calculating text width in mm + void textHeightMM(); //test calculating text height in mm + void drawTextPos(); //test drawing text at a pos + void drawTextRect(); //test drawing text in a rect + void largestRotatedRect(); //test largest rotated rect helper function void decodePaperOrientation(); void mapLayerFromString(); private: - QFont mTestFont; }; @@ -78,7 +78,7 @@ void TestQgsLayoutUtils::cleanupTestCase() void TestQgsLayoutUtils::rotate() { // pairs of lines from before -> expected after position and angle to rotate - QList< QPair< QLineF, double > > testVals; + QList> testVals; testVals << qMakePair( QLineF( 0, 1, 0, 1 ), 0.0 ); testVals << qMakePair( QLineF( 0, 1, -1, 0 ), 90.0 ); testVals << qMakePair( QLineF( 0, 1, 0, -1 ), 180.0 ); @@ -86,7 +86,7 @@ void TestQgsLayoutUtils::rotate() testVals << qMakePair( QLineF( 0, 1, 0, 1 ), 360.0 ); //test rotate helper function - QList< QPair< QLineF, double > >::const_iterator it = testVals.constBegin(); + QList>::const_iterator it = testVals.constBegin(); for ( ; it != testVals.constEnd(); ++it ) { double x = ( *it ).first.x1(); @@ -99,7 +99,7 @@ void TestQgsLayoutUtils::rotate() void TestQgsLayoutUtils::normalizedAngle() { - QList< QPair< double, double > > testVals; + QList> testVals; testVals << qMakePair( 0.0, 0.0 ); testVals << qMakePair( 90.0, 90.0 ); testVals << qMakePair( 180.0, 180.0 ); @@ -114,18 +114,17 @@ void TestQgsLayoutUtils::normalizedAngle() testVals << qMakePair( -760.0, 320.0 ); //test normalized angle helper function - QList< QPair< double, double > >::const_iterator it = testVals.constBegin(); + QList>::const_iterator it = testVals.constBegin(); for ( ; it != testVals.constEnd(); ++it ) { const double result = QgsLayoutUtils::normalizedAngle( ( *it ).first ); qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second ); QGSCOMPARENEAR( result, ( *it ).second, 4 * std::numeric_limits::epsilon() ); - } //test with allowing negative angles - QList< QPair< double, double > > negativeTestVals; + QList> negativeTestVals; negativeTestVals << qMakePair( 0.0, 0.0 ); negativeTestVals << qMakePair( 90.0, 90.0 ); negativeTestVals << qMakePair( 360.0, 0.0 ); @@ -142,13 +141,12 @@ void TestQgsLayoutUtils::normalizedAngle() const double result = QgsLayoutUtils::normalizedAngle( ( *it ).first, true ); qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second ); QGSCOMPARENEAR( result, ( *it ).second, 4 * std::numeric_limits::epsilon() ); - } } void TestQgsLayoutUtils::snappedAngle() { - QList< QPair< double, double > > testVals; + QList> testVals; testVals << qMakePair( 0.0, 0.0 ); testVals << qMakePair( 10.0, 0.0 ); testVals << qMakePair( 20.0, 0.0 ); @@ -188,7 +186,7 @@ void TestQgsLayoutUtils::snappedAngle() testVals << qMakePair( 360.0, 0.0 ); //test snapped angle helper function - QList< QPair< double, double > >::const_iterator it = testVals.constBegin(); + QList>::const_iterator it = testVals.constBegin(); for ( ; it != testVals.constEnd(); ++it ) { QGSCOMPARENEAR( QgsLayoutUtils::snappedAngle( ( *it ).first ), ( *it ).second, 4 * std::numeric_limits::epsilon() ); @@ -458,7 +456,6 @@ void TestQgsLayoutUtils::fontHeightCharacterMM() QGSCOMPARENEAR( QgsLayoutUtils::fontHeightCharacterMM( mTestFont, QChar( 'a' ) ), 2.4, 0.15 ); QGSCOMPARENEAR( QgsLayoutUtils::fontHeightCharacterMM( mTestFont, QChar( 'l' ) ), 3.15, 0.16 ); QGSCOMPARENEAR( QgsLayoutUtils::fontHeightCharacterMM( mTestFont, QChar( 'g' ) ), 3.2, 0.11 ); - } void TestQgsLayoutUtils::textWidthMM() @@ -466,7 +463,6 @@ void TestQgsLayoutUtils::textWidthMM() //platform specific font rendering differences mean this test needs to be very lenient mTestFont.setPointSize( 12 ); QGSCOMPARENEAR( QgsLayoutUtils::textWidthMM( mTestFont, QString( "test string" ) ), 20, 2 ); - } void TestQgsLayoutUtils::textHeightMM() @@ -477,7 +473,6 @@ void TestQgsLayoutUtils::textHeightMM() QGSCOMPARENEAR( QgsLayoutUtils::textHeightMM( mTestFont, QString( "test\nstring" ) ), 8.7, 0.2 ); QGSCOMPARENEAR( QgsLayoutUtils::textHeightMM( mTestFont, QString( "test\nstring" ), 2 ), 13.5, 0.2 ); QGSCOMPARENEAR( QgsLayoutUtils::textHeightMM( mTestFont, QString( "test\nstring\nstring" ) ), 13.5, 0.2 ); - } void TestQgsLayoutUtils::drawTextPos() @@ -586,8 +581,7 @@ void TestQgsLayoutUtils::largestRotatedRect() const QRectF rotatedRectBounds = t.mapRect( result ); //one of the rotated rects dimensions must equal the bounding rectangles dimensions (ie, it has been constrained by one dimension) //and the other dimension must be less than or equal to bounds dimension - QVERIFY( ( qgsDoubleNear( rotatedRectBounds.width(), bounds.width(), 0.001 ) && ( rotatedRectBounds.height() <= bounds.height() ) ) - || ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) ); + QVERIFY( ( qgsDoubleNear( rotatedRectBounds.width(), bounds.width(), 0.001 ) && ( rotatedRectBounds.height() <= bounds.height() ) ) || ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) ); //also verify that aspect ratio of rectangle has not changed QGSCOMPARENEAR( result.width() / result.height(), wideRect.width() / wideRect.height(), 4 * std::numeric_limits::epsilon() ); @@ -601,8 +595,7 @@ void TestQgsLayoutUtils::largestRotatedRect() const QRectF rotatedRectBounds = t.mapRect( result ); //one of the rotated rects dimensions must equal the bounding rectangles dimensions (ie, it has been constrained by one dimension) //and the other dimension must be less than or equal to bounds dimension - QVERIFY( ( qgsDoubleNear( rotatedRectBounds.width(), bounds.width(), 0.001 ) && ( rotatedRectBounds.height() <= bounds.height() ) ) - || ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) ); + QVERIFY( ( qgsDoubleNear( rotatedRectBounds.width(), bounds.width(), 0.001 ) && ( rotatedRectBounds.height() <= bounds.height() ) ) || ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) ); //also verify that aspect ratio of rectangle has not changed QGSCOMPARENEAR( result.width() / result.height(), highRect.width() / highRect.height(), 4 * std::numeric_limits::epsilon() ); diff --git a/tests/src/core/testqgslegendrenderer.cpp b/tests/src/core/testqgslegendrenderer.cpp index f8684a768fb7..7be0df036bb3 100644 --- a/tests/src/core/testqgslegendrenderer.cpp +++ b/tests/src/core/testqgslegendrenderer.cpp @@ -57,7 +57,6 @@ class TestRasterRenderer : public QgsPalettedRasterRenderer { public: - TestRasterRenderer( QgsRasterInterface *input, int bandNumber, const ClassData &classes ) : QgsPalettedRasterRenderer( input, bandNumber, classes ) {} @@ -67,16 +66,15 @@ class TestRasterRenderer : public QgsPalettedRasterRenderer { QList res; - const QList< QPair< QString, QColor > > items = legendSymbologyItems(); + const QList> items = legendSymbologyItems(); res.reserve( res.size() + items.size() ); - for ( const QPair< QString, QColor > &item : items ) + for ( const QPair &item : items ) { res << new QgsRasterSymbolLegendNode( nodeLayer, item.second, item.first ); } return res; } - }; class TestQgsLegendRenderer : public QgsTest @@ -84,14 +82,14 @@ class TestQgsLegendRenderer : public QgsTest Q_OBJECT public: - TestQgsLegendRenderer() : QgsTest( QStringLiteral( "Legend Renderer Tests" ), - QStringLiteral( "legend" ) ) {} + TestQgsLegendRenderer() + : QgsTest( QStringLiteral( "Legend Renderer Tests" ), QStringLiteral( "legend" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testModel(); @@ -160,9 +158,9 @@ class TestQgsLegendRenderer : public QgsTest private: QgsLayerTree *mRoot = nullptr; - QgsVectorLayer *mVL1 = nullptr ; // line - QgsVectorLayer *mVL2 = nullptr ; // polygon - QgsVectorLayer *mVL3 = nullptr ; // point + QgsVectorLayer *mVL1 = nullptr; // line + QgsVectorLayer *mVL2 = nullptr; // polygon + QgsVectorLayer *mVL3 = nullptr; // point QgsRasterLayer *mRL = nullptr; bool _testLegendColumns( int itemCount, int columnCount, const QString &testName, double symbolSpacing ); @@ -200,7 +198,7 @@ class TestQgsLegendRenderer : public QgsTest constexpr int dpi = 96; constexpr qreal dpmm = dpi / 25.4; - const QSize s( static_cast< int >( size.width() * dpmm ), static_cast< int >( size.height() * dpmm ) ); + const QSize s( static_cast( size.width() * dpmm ), static_cast( size.height() * dpmm ) ); // qDebug() << QStringLiteral( "testName:%1 size=%2x%3 dpmm=%4 s=%5x%6" ).arg( testName ).arg( size.width() ).arg( size.height() ).arg( dpmm ).arg( s.width() ).arg( s.height() ); QImage img( s, QImage::Format_ARGB32_Premultiplied ); img.fill( Qt::white ); @@ -238,7 +236,6 @@ class TestQgsLegendRenderer : public QgsTest context.setFlag( Qgis::RenderContextFlag::Antialiasing, true ); return legendRenderer.exportLegendToJson( context ); } - }; @@ -290,7 +287,7 @@ void TestQgsLegendRenderer::init() f2.setGeometry( f2G ); QgsFeature f3( fields, 3 ); f3.setAttribute( 0, 3 ); - const QgsGeometry f3G = QgsGeometry::fromPointXY( QgsPointXY( 5.0, 5.0 ) ) ; + const QgsGeometry f3G = QgsGeometry::fromPointXY( QgsPointXY( 5.0, 5.0 ) ); f3.setGeometry( f3G ); features << f1 << f2 << f3; pr->addFeatures( features ); @@ -310,11 +307,7 @@ void TestQgsLegendRenderer::init() mRL = new QgsRasterLayer( QString( tempFileName ), QStringLiteral( "Raster Layer" ), QStringLiteral( "gdal" ) ); - std::unique_ptr< TestRasterRenderer > rasterRenderer( new TestRasterRenderer( mRL->dataProvider(), 1, - { - QgsPalettedRasterRenderer::Class( 1, QColor( 0, 0, 0 ), QStringLiteral( "1" ) ), - QgsPalettedRasterRenderer::Class( 2, QColor( 255, 255, 255 ), QStringLiteral( "2" ) ) - } ) ); + std::unique_ptr rasterRenderer( new TestRasterRenderer( mRL->dataProvider(), 1, { QgsPalettedRasterRenderer::Class( 1, QColor( 0, 0, 0 ), QStringLiteral( "1" ) ), QgsPalettedRasterRenderer::Class( 2, QColor( 255, 255, 255 ), QStringLiteral( "2" ) ) } ) ); mRL->setRenderer( rasterRenderer.release() ); QgsProject::instance()->addMapLayer( mRL ); @@ -622,13 +615,13 @@ void TestQgsLegendRenderer::testOverrideSymbol() QgsLayerTreeLayer *layer = legendModel.rootGroup()->findLayer( mVL2 ); - std::unique_ptr< QgsFillSymbol > sym2 = std::make_unique< QgsFillSymbol >(); + std::unique_ptr sym2 = std::make_unique(); sym2->setColor( Qt::red ); QgsLayerTreeModelLegendNode *embeddedNode = legendModel.legendNodeEmbeddedInParent( layer ); - qgis::down_cast< QgsSymbolLegendNode * >( embeddedNode )->setCustomSymbol( sym2.release() ); + qgis::down_cast( embeddedNode )->setCustomSymbol( sym2.release() ); - std::unique_ptr< QgsMarkerSymbol > sym3 = std::make_unique< QgsMarkerSymbol >(); + std::unique_ptr sym3 = std::make_unique(); sym3->setColor( QColor( 0, 150, 0 ) ); sym3->setSize( 6 ); @@ -919,7 +912,7 @@ void TestQgsLegendRenderer::testMapUnits() sym->setSizeUnit( Qgis::RenderUnit::Millimeters ); catRenderer->updateCategorySymbol( 2, sym ); - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); root->addLayer( mVL3 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1053,7 +1046,7 @@ void TestQgsLegendRenderer::testFilterByMapSameSymbol() f1.setGeometry( f1G ); QgsFeature f2( fields, 2 ); f2.setAttribute( 0, 2 ); - const QgsGeometry f2G = QgsGeometry::fromPointXY( QgsPointXY( 9.0, 1.0 ) ); + const QgsGeometry f2G = QgsGeometry::fromPointXY( QgsPointXY( 9.0, 1.0 ) ); f2.setGeometry( f2G ); QgsFeature f3( fields, 3 ); f3.setAttribute( 0, 3 ); @@ -1081,7 +1074,7 @@ void TestQgsLegendRenderer::testFilterByMapSameSymbol() const QString testName = QStringLiteral( "legend_filter_by_map_dupe" ); - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); root->addLayer( vl4 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1108,9 +1101,9 @@ bool TestQgsLegendRenderer::_testLegendColumns( int itemCount, int columnCount, QgsFillSymbol *sym = new QgsFillSymbol(); sym->setColor( Qt::cyan ); - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); - QList< QgsVectorLayer * > layers; + QList layers; for ( int i = 1; i <= itemCount; ++i ) { QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "Layer %1" ).arg( i ), QStringLiteral( "memory" ) ); @@ -1312,7 +1305,7 @@ void TestQgsLegendRenderer::testRasterStroke() { const QString testName = QStringLiteral( "legend_raster_border" ); - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); root->addLayer( mRL ); QgsLayerTreeModel legendModel( root.get() ); @@ -1393,7 +1386,6 @@ void TestQgsLegendRenderer::testFilterByExpression() setStandardTestFont( settings, QStringLiteral( "Bold" ) ); res = renderLegend( &legendModel, settings ); QVERIFY( _verifyImage( res, testName2 ) ); - } void TestQgsLegendRenderer::testFilterByExpressionWithContext() @@ -1455,7 +1447,6 @@ void TestQgsLegendRenderer::testFilterByExpressionWithContext() setStandardTestFont( settings, QStringLiteral( "Bold" ) ); res = renderLegend( &legendModel, settings ); QVERIFY( _verifyImage( res, testName + "3" ) ); - } void TestQgsLegendRenderer::testDiagramAttributeLegend() @@ -1489,7 +1480,7 @@ void TestQgsLegendRenderer::testDiagramAttributeLegend() dls.setShowAllDiagrams( true ); vl4->setDiagramLayerSettings( dls ); - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); root->addLayer( vl4 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1524,7 +1515,7 @@ void TestQgsLegendRenderer::testDiagramMeshLegend() rendererSettings.setActiveVectorDatasetGroup( vectorIndex ); layer->setRendererSettings( rendererSettings ); - std::unique_ptr< QgsLayerTree > root( std::make_unique() ); + std::unique_ptr root( std::make_unique() ); root->addLayer( layer ); std::unique_ptr legendModel( std::make_unique( root.get() ) ); @@ -1607,7 +1598,7 @@ void TestQgsLegendRenderer::testDiagramSizeLegend() dls.setShowAllDiagrams( true ); vl4->setDiagramLayerSettings( dls ); - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); root->addLayer( vl4 ); QgsLayerTreeModel legendModel( root.get() ); @@ -1658,14 +1649,14 @@ void TestQgsLegendRenderer::testDataDefinedSizeCollapsed() props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,0,0" ); QgsMarkerSymbol *symbol = QgsMarkerSymbol::createSimple( props ); QgsProperty ddsProperty = QgsProperty::fromField( QStringLiteral( "test_attr" ) ); - ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership + ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership symbol->setDataDefinedSize( ddsProperty ); QgsDataDefinedSizeLegend *ddsLegend = new QgsDataDefinedSizeLegend(); ddsLegend->setLegendType( QgsDataDefinedSizeLegend::LegendCollapsed ); ddsLegend->setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); - QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership + QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership r->setDataDefinedSizeLegend( ddsLegend ); vlDataDefinedSize->setRenderer( r ); @@ -1719,14 +1710,14 @@ void TestQgsLegendRenderer::testDataDefinedSizeSeparated() props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,0,0" ); QgsMarkerSymbol *symbol = QgsMarkerSymbol::createSimple( props ); QgsProperty ddsProperty = QgsProperty::fromField( QStringLiteral( "test_attr" ) ); - ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership + ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership symbol->setDataDefinedSize( ddsProperty ); QgsDataDefinedSizeLegend *ddsLegend = new QgsDataDefinedSizeLegend(); ddsLegend->setLegendType( QgsDataDefinedSizeLegend::LegendSeparated ); ddsLegend->setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); - QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership + QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership r->setDataDefinedSizeLegend( ddsLegend ); vlDataDefinedSize->setRenderer( r ); @@ -1780,14 +1771,14 @@ void TestQgsLegendRenderer::testDataDefinedSizeCollapsedFilterByMap() props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,0,0" ); QgsMarkerSymbol *symbol = QgsMarkerSymbol::createSimple( props ); QgsProperty ddsProperty = QgsProperty::fromField( QStringLiteral( "test_attr" ) ); - ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership + ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership symbol->setDataDefinedSize( ddsProperty ); QgsDataDefinedSizeLegend *ddsLegend = new QgsDataDefinedSizeLegend(); ddsLegend->setLegendType( QgsDataDefinedSizeLegend::LegendCollapsed ); ddsLegend->setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); - QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership + QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership r->setDataDefinedSizeLegend( ddsLegend ); vlDataDefinedSize->setRenderer( r ); @@ -1851,14 +1842,14 @@ void TestQgsLegendRenderer::testDataDefinedSizeSeparatedFilterByMap() props[QStringLiteral( "outline_color" )] = QStringLiteral( "0,0,0" ); QgsMarkerSymbol *symbol = QgsMarkerSymbol::createSimple( props ); QgsProperty ddsProperty = QgsProperty::fromField( QStringLiteral( "test_attr" ) ); - ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership + ddsProperty.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 100, 300, 10, 30 ) ); // takes ownership symbol->setDataDefinedSize( ddsProperty ); QgsDataDefinedSizeLegend *ddsLegend = new QgsDataDefinedSizeLegend(); ddsLegend->setLegendType( QgsDataDefinedSizeLegend::LegendSeparated ); ddsLegend->setFont( QgsFontUtils::getStandardTestFont( QStringLiteral( "Bold" ) ) ); - QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership + QgsSingleSymbolRenderer *r = new QgsSingleSymbolRenderer( symbol ); // takes ownership r->setDataDefinedSizeLegend( ddsLegend ); vlDataDefinedSize->setRenderer( r ); @@ -1934,10 +1925,10 @@ void TestQgsLegendRenderer::testColumnsMixedSymbolSize() QgsMarkerSymbol *sym = new QgsMarkerSymbol(); sym->setColor( Qt::cyan ); - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); - QList< QgsVectorLayer * > layers; - for ( double size : { 4, 5, 16} ) + QList layers; + for ( double size : { 4, 5, 16 } ) { QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( "Polygon" ), QStringLiteral( "Layer %1" ).arg( size ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( vl ); @@ -1971,7 +1962,7 @@ void TestQgsLegendRenderer::testBasicJson() setStandardTestFont( settings, QStringLiteral( "Bold" ) ); const QJsonObject json = renderJsonLegend( &legendModel, settings ); - QCOMPARE( json[ "title" ].toString(), QString( "Legend" ) ); + QCOMPARE( json["title"].toString(), QString( "Legend" ) ); const QJsonArray root = json["nodes"].toArray(); @@ -2149,7 +2140,7 @@ void TestQgsLegendRenderer::testLabelLegend() void TestQgsLegendRenderer::testHeatmap() { - std::unique_ptr< QgsLayerTree > root( new QgsLayerTree() ); + std::unique_ptr root( new QgsLayerTree() ); QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( "Points" ), QStringLiteral( "Points" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( vl ); diff --git a/tests/src/core/testqgslinefillsymbol.cpp b/tests/src/core/testqgslinefillsymbol.cpp index 21bc54ec9d88..5330f54c81f2 100644 --- a/tests/src/core/testqgslinefillsymbol.cpp +++ b/tests/src/core/testqgslinefillsymbol.cpp @@ -48,13 +48,14 @@ class TestQgsLineFillSymbol : public QgsTest Q_OBJECT public: - TestQgsLineFillSymbol() : QgsTest( QStringLiteral( "Line Fill Symbol Tests" ) ) {} + TestQgsLineFillSymbol() + : QgsTest( QStringLiteral( "Line Fill Symbol Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void lineFillSymbol(); void lineFillSymbolVector(); @@ -74,7 +75,7 @@ class TestQgsLineFillSymbol : public QgsTest void dataDefinedSubSymbol(); private: - bool mTestHasError = false ; + bool mTestHasError = false; bool imageCheck( const QString &type, QgsVectorLayer *layer = nullptr, bool forceVector = false ); QgsMapSettings mMapSettings; @@ -103,8 +104,7 @@ void TestQgsLineFillSymbol::initTestCase() // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -122,7 +122,6 @@ void TestQgsLineFillSymbol::initTestCase() // and is more light weight // mMapSettings.setLayers( QList() << mpPolysLayer ); - } void TestQgsLineFillSymbol::cleanupTestCase() { @@ -145,7 +144,7 @@ void TestQgsLineFillSymbol::lineFillSymbol() void TestQgsLineFillSymbol::lineFillSymbolVector() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer> ( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -166,7 +165,7 @@ void TestQgsLineFillSymbol::lineFillSymbolVector() void TestQgsLineFillSymbol::viewportLineFillSymbol() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsVectorSimplifyMethod simplifyMethod; @@ -192,7 +191,7 @@ void TestQgsLineFillSymbol::viewportLineFillSymbol() void TestQgsLineFillSymbol::viewportLineFillSymbolVector() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -223,7 +222,7 @@ void TestQgsLineFillSymbol::lineFillSymbolOffset() void TestQgsLineFillSymbol::lineFillSymbolOffsetVector() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -259,7 +258,7 @@ void TestQgsLineFillSymbol::lineFillLargeOffset() void TestQgsLineFillSymbol::lineFillLargeOffsetVector() { // test line fill with large offset compared to line distance - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -294,7 +293,7 @@ void TestQgsLineFillSymbol::lineFillNegativeAngle() void TestQgsLineFillSymbol::lineFillNegativeAngleVector() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -318,7 +317,7 @@ void TestQgsLineFillSymbol::lineFillNegativeAngleVector() void TestQgsLineFillSymbol::lineFillClipPainter() { // test clipping using painter path - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer> ( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -357,7 +356,7 @@ void TestQgsLineFillSymbol::lineFillClipPainter() void TestQgsLineFillSymbol::lineFillClipIntersection() { // test clipping using intersections - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer> ( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -396,7 +395,7 @@ void TestQgsLineFillSymbol::lineFillClipIntersection() void TestQgsLineFillSymbol::lineFillNoClip() { // test no clipping - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer> ( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -435,7 +434,7 @@ void TestQgsLineFillSymbol::lineFillNoClip() void TestQgsLineFillSymbol::lineFillDataDefinedClip() { // test data defined clipping - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer> ( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsLinePatternFillSymbolLayer *lineFill = new QgsLinePatternFillSymbolLayer(); @@ -468,7 +467,8 @@ void TestQgsLineFillSymbol::lineFillDataDefinedClip() lineFill->setDistance( 6 ); lineFill->setDataDefinedProperty( QgsSymbolLayer::Property::LineClipping, - QgsProperty::fromExpression( QStringLiteral( "case when $id % 3 =0 then 'no' when $id % 3 = 1 then 'during_render' else 'before_render' end" ) ) ); + QgsProperty::fromExpression( QStringLiteral( "case when $id % 3 =0 then 'no' when $id % 3 = 1 then 'during_render' else 'before_render' end" ) ) + ); QVERIFY( imageCheck( QStringLiteral( "symbol_linefill_clip_data_defined" ), layer.get() ) ); } @@ -495,7 +495,7 @@ bool TestQgsLineFillSymbol::imageCheck( const QString &testType, QgsVectorLayer if ( !layer ) layer = mpPolysLayer; - mMapSettings.setLayers( {layer } ); + mMapSettings.setLayers( { layer } ); //use the QgsRenderChecker test utility class to //ensure the rendered output matches our control image diff --git a/tests/src/core/testqgsmapdevicepixelratio.cpp b/tests/src/core/testqgsmapdevicepixelratio.cpp index 8a7a7777b6f9..6d462256a4ce 100644 --- a/tests/src/core/testqgsmapdevicepixelratio.cpp +++ b/tests/src/core/testqgsmapdevicepixelratio.cpp @@ -47,8 +47,8 @@ class TestQgsMapDevicePixelRatio : public QgsTest ~TestQgsMapDevicePixelRatio() override; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void pointsLayer(); @@ -72,8 +72,7 @@ void TestQgsMapDevicePixelRatio::initTestCase() //create a point layer that will be used in all tests... const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsFontUtils::loadStandardTestFonts( QStringList() << QStringLiteral( "Bold" ) ); } diff --git a/tests/src/core/testqgsmaplayer.cpp b/tests/src/core/testqgsmaplayer.cpp index ce6100bf266a..47e6f2d5a6e9 100644 --- a/tests/src/core/testqgsmaplayer.cpp +++ b/tests/src/core/testqgsmaplayer.cpp @@ -45,10 +45,10 @@ class TestQgsMapLayer : public QObject TestQgsMapLayer() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void isValid(); void testId(); @@ -86,7 +86,6 @@ void TestQgsMapLayer::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsMapLayer::init() @@ -96,8 +95,7 @@ void TestQgsMapLayer::init() QString myFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt myFileName = myFileName + "/points.shp"; const QFileInfo myMapFileInfo( myFileName ); - mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), - myMapFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), myMapFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( mpLayer ); } @@ -118,7 +116,7 @@ void TestQgsMapLayer::isValid() void TestQgsMapLayer::testId() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); QSignalSpy spy( layer.get(), &QgsMapLayer::idChanged ); QVERIFY( layer->setId( QStringLiteral( "my forced id" ) ) ); QCOMPARE( layer->id(), QStringLiteral( "my forced id" ) ); @@ -167,7 +165,7 @@ void TestQgsMapLayer::setBlendMode() mpLayer->setBlendMode( QPainter::CompositionMode_Screen ); // check the signal has been correctly emitted QCOMPARE( spy.count(), 1 ); - QCOMPARE( spy.at( 0 ).at( 0 ).toInt(), static_cast< int >( QPainter::CompositionMode_Screen ) ); + QCOMPARE( spy.at( 0 ).at( 0 ).toInt(), static_cast( QPainter::CompositionMode_Screen ) ); // check accessor QCOMPARE( mpLayer->blendMode(), QPainter::CompositionMode_Screen ); @@ -176,7 +174,7 @@ void TestQgsMapLayer::setBlendMode() mpLayer->setBlendMode( QPainter::CompositionMode_Darken ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( spy.at( 1 ).at( 0 ).toInt(), static_cast< int >( QPainter::CompositionMode_Darken ) ); + QCOMPARE( spy.at( 1 ).at( 0 ).toInt(), static_cast( QPainter::CompositionMode_Darken ) ); QCOMPARE( mpLayer->blendMode(), QPainter::CompositionMode_Darken ); } @@ -190,7 +188,7 @@ void TestQgsMapLayer::isInScaleRange_data() QTest::newRow( "too high" ) << 6000.0 << false; QTest::newRow( "min is not inclusive" ) << 5000.0 << false; QTest::newRow( "max is inclusive" ) << 2500.0 << true; - QTest::newRow( "max is inclusive even with conversion errors" ) << static_cast< double >( 1.0f / ( ( float )1.0 / 2500.0 ) ) << true; + QTest::newRow( "max is inclusive even with conversion errors" ) << static_cast( 1.0f / ( ( float ) 1.0 / 2500.0 ) ) << true; QTest::newRow( "max is inclusive even with non-round scales (below)" ) << 2499.9999999966526 << true; QTest::newRow( "max is inclusive even with non-round scales (above)" ) << 2500.0000000027226 << true; QTest::newRow( "min is exclusive even with non-round scales (below)" ) << 4999.999999997278 << false; @@ -313,19 +311,19 @@ void TestQgsMapLayer::layerRefListUtils() QList listRawSource; listRawSource << vlA << vlB; - QList< QgsMapLayerRef > refs = _qgis_listRawToRef( listRawSource ); + QList refs = _qgis_listRawToRef( listRawSource ); QCOMPARE( refs.at( 0 ).get(), vlA ); QCOMPARE( refs.at( 1 ).get(), vlB ); const QList raw = _qgis_listRefToRaw( refs ); - QCOMPARE( raw, QList< QgsMapLayer *>() << vlA << vlB ); + QCOMPARE( raw, QList() << vlA << vlB ); //remove layers QgsVectorLayer *vlC = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "c" ), QStringLiteral( "memory" ) ); QgsVectorLayer *vlD = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "d" ), QStringLiteral( "memory" ) ); refs << QgsMapLayerRef( vlC ) << QgsMapLayerRef( vlD ); - _qgis_removeLayers( refs, QList< QgsMapLayer *>() << vlB << vlD ); + _qgis_removeLayers( refs, QList() << vlB << vlD ); QCOMPARE( refs.size(), 2 ); QCOMPARE( refs.at( 0 ).get(), vlA ); QCOMPARE( refs.at( 1 ).get(), vlC ); @@ -356,41 +354,29 @@ void TestQgsMapLayer::layerRefResolveWeakly() QgsVectorLayerRef ref; QgsProject::instance()->addMapLayer( vlA ); ref.name = vlA->name(); - QVERIFY( ! ref.resolveWeakly( QgsProject::instance() ) ); + QVERIFY( !ref.resolveWeakly( QgsProject::instance() ) ); QVERIFY( ref.resolveWeakly( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ) ); ref = QgsVectorLayerRef(); ref.name = QStringLiteral( "another name" ); - QVERIFY( ! ref.resolveWeakly( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ) ); + QVERIFY( !ref.resolveWeakly( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ) ); ref.provider = vlA->providerType(); QVERIFY( ref.resolveWeakly( QgsProject::instance(), QgsVectorLayerRef::MatchType::Provider ) ); ref = QgsVectorLayerRef(); ref.name = QStringLiteral( "another name" ); - QVERIFY( ! ref.resolveWeakly( QgsProject::instance(), - static_cast( QgsVectorLayerRef::MatchType::Provider | - QgsVectorLayerRef::MatchType::Name ) ) ); + QVERIFY( !ref.resolveWeakly( QgsProject::instance(), static_cast( QgsVectorLayerRef::MatchType::Provider | QgsVectorLayerRef::MatchType::Name ) ) ); ref.provider = vlA->providerType(); - QVERIFY( ! ref.resolveWeakly( QgsProject::instance(), - static_cast( QgsVectorLayerRef::MatchType::Provider | - QgsVectorLayerRef::MatchType::Name ) ) ); + QVERIFY( !ref.resolveWeakly( QgsProject::instance(), static_cast( QgsVectorLayerRef::MatchType::Provider | QgsVectorLayerRef::MatchType::Name ) ) ); ref.name = vlA->name(); - QVERIFY( ref.resolveWeakly( QgsProject::instance(), - static_cast( QgsVectorLayerRef::MatchType::Provider | - QgsVectorLayerRef::MatchType::Name ) ) ); + QVERIFY( ref.resolveWeakly( QgsProject::instance(), static_cast( QgsVectorLayerRef::MatchType::Provider | QgsVectorLayerRef::MatchType::Name ) ) ); ref = QgsVectorLayerRef(); - QVERIFY( ! ref.resolveWeakly( QgsProject::instance(), - static_cast( QgsVectorLayerRef::MatchType::Source | - QgsVectorLayerRef::MatchType::Name ) ) ); + QVERIFY( !ref.resolveWeakly( QgsProject::instance(), static_cast( QgsVectorLayerRef::MatchType::Source | QgsVectorLayerRef::MatchType::Name ) ) ); ref.source = vlA->publicSource(); - QVERIFY( ! ref.resolveWeakly( QgsProject::instance(), - static_cast( QgsVectorLayerRef::MatchType::Source | - QgsVectorLayerRef::MatchType::Name ) ) ); + QVERIFY( !ref.resolveWeakly( QgsProject::instance(), static_cast( QgsVectorLayerRef::MatchType::Source | QgsVectorLayerRef::MatchType::Name ) ) ); ref.name = vlA->name(); - QVERIFY( ref.resolveWeakly( QgsProject::instance(), - static_cast( QgsVectorLayerRef::MatchType::Source | - QgsVectorLayerRef::MatchType::Name ) ) ); + QVERIFY( ref.resolveWeakly( QgsProject::instance(), static_cast( QgsVectorLayerRef::MatchType::Source | QgsVectorLayerRef::MatchType::Name ) ) ); } void TestQgsMapLayer::styleCategories() @@ -450,7 +436,7 @@ void TestQgsMapLayer::customEnumFlagProperties() QVERIFY( static_cast( Qgis::LayoutUnit::Meters ) != -1 ); // standard method returns invalid property - const int v1 = ml->customProperty( QStringLiteral( "my_property_for_units" ), static_cast< int >( Qgis::LayoutUnit::Meters ) ).toInt(); + const int v1 = ml->customProperty( QStringLiteral( "my_property_for_units" ), static_cast( Qgis::LayoutUnit::Meters ) ).toInt(); QCOMPARE( v1, -1 ); // enum method returns default property if current property is incorrect @@ -501,9 +487,9 @@ void TestQgsMapLayer::readCustomProperties() ml->setCustomProperty( QStringLiteral( "my_property_three" ), QStringLiteral( "test3" ) ); QMap map; - map[ "my_property_one" ] = 51; - map[ "my_property_two" ] = QStringLiteral( "test2 different" ); - map[ "my_property_three" ] = QStringLiteral( "test3" ); + map["my_property_one"] = 51; + map["my_property_two"] = QStringLiteral( "test2 different" ); + map["my_property_three"] = QStringLiteral( "test3" ); QDomDocument doc( QStringLiteral( "qgis" ) ); QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) ); @@ -522,7 +508,6 @@ void TestQgsMapLayer::readCustomProperties() QCOMPARE( spy.count(), 2 ); QCOMPARE( spy.at( 0 ).at( 0 ), "my_property_one" ); QCOMPARE( spy.at( 1 ).at( 0 ), "my_property_two" ); - } QGSTEST_MAIN( TestQgsMapLayer ) diff --git a/tests/src/core/testqgsmaplayerstylemanager.cpp b/tests/src/core/testqgsmaplayerstylemanager.cpp index 134a551af694..03584f2fb04d 100644 --- a/tests/src/core/testqgsmaplayerstylemanager.cpp +++ b/tests/src/core/testqgsmaplayerstylemanager.cpp @@ -30,10 +30,10 @@ class TestQgsMapLayerStyleManager : public QObject TestQgsMapLayerStyleManager() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testDefault(); void testStyle(); diff --git a/tests/src/core/testqgsmaprenderercache.cpp b/tests/src/core/testqgsmaprenderercache.cpp index 2619c09b4562..ca001f411fad 100644 --- a/tests/src/core/testqgsmaprenderercache.cpp +++ b/tests/src/core/testqgsmaprenderercache.cpp @@ -20,7 +20,7 @@ #include "qgsmaptopixel.h" #include "qgsrectangle.h" -class TestQgsMapRendererCache: public QObject +class TestQgsMapRendererCache : public QObject { Q_OBJECT @@ -28,10 +28,10 @@ class TestQgsMapRendererCache: public QObject TestQgsMapRendererCache(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testCache(); }; diff --git a/tests/src/core/testqgsmaprendererjob.cpp b/tests/src/core/testqgsmaprendererjob.cpp index 7c646fae454e..5f341731d643 100644 --- a/tests/src/core/testqgsmaprendererjob.cpp +++ b/tests/src/core/testqgsmaprendererjob.cpp @@ -67,7 +67,8 @@ class TestQgsMapRendererJob : public QgsTest Q_OBJECT public: - TestQgsMapRendererJob() : QgsTest( QStringLiteral( "Map Renderer Job Tests" ) ) {} + TestQgsMapRendererJob() + : QgsTest( QStringLiteral( "Map Renderer Job Tests" ) ) {} ~TestQgsMapRendererJob() override { @@ -75,8 +76,8 @@ class TestQgsMapRendererJob : public QgsTest } private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. //! This method tests render performance void performanceTest(); @@ -107,7 +108,7 @@ class TestQgsMapRendererJob : public QgsTest bool imageCheck( const QString &type, const QImage &image, int mismatchCount = 0 ); QString mEncoding; - QgsVectorFileWriter::WriterError mError = QgsVectorFileWriter::NoError ; + QgsVectorFileWriter::WriterError mError = QgsVectorFileWriter::NoError; QgsCoordinateReferenceSystem mCRS; QgsFields mFields; QgsMapSettings *mMapSettings = nullptr; @@ -137,9 +138,9 @@ void TestQgsMapRendererJob::initTestCase() QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt QString myTestDataDir = myDataDir + '/'; QString myTmpDir = QDir::tempPath() + '/'; - QString myFileName = myTmpDir + "maprender_testdata.gpkg"; + QString myFileName = myTmpDir + "maprender_testdata.gpkg"; //copy over the default qml for our generated layer - QString myQmlFileName = myTestDataDir + "maprender_testdata.qml"; + QString myQmlFileName = myTestDataDir + "maprender_testdata.qml"; QFile::remove( myTmpDir + "maprender_testdata.qml" ); QVERIFY( QFile::copy( myQmlFileName, myTmpDir + "maprender_testdata.qml" ) ); qDebug( "Checking test dataset exists...\n%s", myFileName.toLocal8Bit().constData() ); @@ -149,7 +150,7 @@ void TestQgsMapRendererJob::initTestCase() QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = mEncoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); + std::unique_ptr writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); double myInterval = 0.5; for ( double i = -180.0; i <= 180.0; i += myInterval ) { @@ -203,8 +204,7 @@ void TestQgsMapRendererJob::initTestCase() //create a poly layer that will be used in all tests... // QFileInfo myPolyFileInfo( myFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QVERIFY( mpPolysLayer->isValid() ); // Register the layer with the registry QgsProject::instance()->addMapLayers( QList() << mpPolysLayer ); @@ -349,8 +349,7 @@ void TestQgsMapRendererJob::testFourAdjacentTiles() class TestHandler : public QgsRenderedFeatureHandlerInterface { public: - - TestHandler( QList< QgsFeature > &features, QList< QgsGeometry > &geometries, bool allAttributes = false ) + TestHandler( QList &features, QList &geometries, bool allAttributes = false ) : features( features ) , geometries( geometries ) , mAllAttributes( allAttributes ) @@ -362,32 +361,28 @@ class TestHandler : public QgsRenderedFeatureHandlerInterface geometries.append( geom ); } - QSet< QString > usedAttributes( QgsVectorLayer *, const QgsRenderContext & ) const override + QSet usedAttributes( QgsVectorLayer *, const QgsRenderContext & ) const override { if ( !mAllAttributes ) - return QSet< QString >(); + return QSet(); else - return QSet< QString >() << QgsFeatureRequest::ALL_ATTRIBUTES; + return QSet() << QgsFeatureRequest::ALL_ATTRIBUTES; } - QList< QgsFeature > &features; - QList< QgsGeometry > &geometries; + QList &features; + QList &geometries; bool mAllAttributes = false; - }; void TestQgsMapRendererJob::testRenderedFeatureHandlers() { - std::unique_ptr< QgsVectorLayer > pointsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr pointsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > linesLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + std::unique_ptr linesLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > polygonsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), - QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); + std::unique_ptr polygonsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); QVERIFY( polygonsLayer->isValid() ); QgsMapSettings mapSettings; @@ -398,11 +393,11 @@ void TestQgsMapRendererJob::testRenderedFeatureHandlers() mapSettings.setFlags( Qgis::MapSettingsFlag::RenderMapTile ); mapSettings.setOutputDpi( 96 ); - QList< QgsFeature > features1; - QList< QgsGeometry > geometries1; + QList features1; + QList geometries1; TestHandler handler1( features1, geometries1 ); - QList< QgsFeature > features2; - QList< QgsGeometry > geometries2; + QList features2; + QList geometries2; TestHandler handler2( features2, geometries2 ); mapSettings.addRenderedFeatureHandler( &handler1 ); mapSettings.addRenderedFeatureHandler( &handler2 ); @@ -462,8 +457,8 @@ void TestQgsMapRendererJob::testRenderedFeatureHandlers() QCOMPARE( wkts.at( 4 ), QStringLiteral( "Polygon ((4.2 59.5, 73.5 59.5, 73.5 128.8, 4.2 128.8, 4.2 59.5))" ) ); // now, use a handler which requires all attributes to be fetched - QList< QgsFeature > features3; - QList< QgsGeometry > geometries3; + QList features3; + QList geometries3; TestHandler handler3( features3, geometries3, true ); mapSettings.addRenderedFeatureHandler( &handler3 ); @@ -493,17 +488,13 @@ void TestQgsMapRendererJob::stagedRenderer() { // test the staged map renderer job subclass - std::unique_ptr< QgsVectorLayer > pointsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr pointsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > linesLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + std::unique_ptr linesLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > polygonsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), - QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); + std::unique_ptr polygonsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); QVERIFY( polygonsLayer->isValid() ); - std::unique_ptr< QgsRasterLayer > rasterLayer = std::make_unique< QgsRasterLayer >( TEST_DATA_DIR + QStringLiteral( "/raster_layer.tiff" ), - QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rasterLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/raster_layer.tiff" ), QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); QVERIFY( rasterLayer->isValid() ); QgsMapSettings mapSettings; @@ -513,7 +504,7 @@ void TestQgsMapRendererJob::stagedRenderer() mapSettings.setFlag( Qgis::MapSettingsFlag::DrawLabeling, false ); mapSettings.setOutputDpi( 96 ); - std::unique_ptr< QgsMapRendererStagedRenderJob > job = std::make_unique< QgsMapRendererStagedRenderJob >( mapSettings ); + std::unique_ptr job = std::make_unique( mapSettings ); job->start(); // nothing to render QVERIFY( job->isFinished() ); @@ -523,7 +514,7 @@ void TestQgsMapRendererJob::stagedRenderer() // with layers mapSettings.setLayers( QList() << pointsLayer.get() << linesLayer.get() << rasterLayer.get() << polygonsLayer.get() ); - job = std::make_unique< QgsMapRendererStagedRenderJob >( mapSettings ); + job = std::make_unique( mapSettings ); job->start(); QVERIFY( !job->isFinished() ); QCOMPARE( job->currentLayerId(), polygonsLayer->id() ); @@ -597,7 +588,7 @@ void TestQgsMapRendererJob::stagedRenderer() pointsLayer->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); pointsLayer->setLabelsEnabled( true ); - job = std::make_unique< QgsMapRendererStagedRenderJob >( mapSettings ); + job = std::make_unique( mapSettings ); job->start(); QVERIFY( !job->isFinished() ); QCOMPARE( job->currentLayerId(), polygonsLayer->id() ); @@ -672,14 +663,11 @@ void TestQgsMapRendererJob::stagedRendererWithStagedLabeling() { // test the staged map renderer job subclass, when using staged labeling - std::unique_ptr< QgsVectorLayer > pointsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr pointsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > linesLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), - QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); + std::unique_ptr linesLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/lines.shp" ), QStringLiteral( "lines" ), QStringLiteral( "ogr" ) ); QVERIFY( linesLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > polygonsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), - QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); + std::unique_ptr polygonsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ), QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); QVERIFY( polygonsLayer->isValid() ); QgsMapSettings mapSettings; @@ -689,7 +677,7 @@ void TestQgsMapRendererJob::stagedRendererWithStagedLabeling() mapSettings.setFlag( Qgis::MapSettingsFlag::DrawLabeling, false ); mapSettings.setOutputDpi( 96 ); - std::unique_ptr< QgsMapRendererStagedRenderJob > job = std::make_unique< QgsMapRendererStagedRenderJob >( mapSettings, QgsMapRendererStagedRenderJob::RenderLabelsByMapLayer ); + std::unique_ptr job = std::make_unique( mapSettings, QgsMapRendererStagedRenderJob::RenderLabelsByMapLayer ); job->start(); // nothing to render QVERIFY( job->isFinished() ); @@ -699,7 +687,7 @@ void TestQgsMapRendererJob::stagedRendererWithStagedLabeling() // with layers mapSettings.setLayers( QList() << pointsLayer.get() << linesLayer.get() << polygonsLayer.get() ); - job = std::make_unique< QgsMapRendererStagedRenderJob >( mapSettings, QgsMapRendererStagedRenderJob::RenderLabelsByMapLayer ); + job = std::make_unique( mapSettings, QgsMapRendererStagedRenderJob::RenderLabelsByMapLayer ); job->start(); QVERIFY( !job->isFinished() ); QCOMPARE( job->currentLayerId(), polygonsLayer->id() ); @@ -775,7 +763,7 @@ void TestQgsMapRendererJob::stagedRendererWithStagedLabeling() polygonsLayer->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); polygonsLayer->setLabelsEnabled( true ); - job = std::make_unique< QgsMapRendererStagedRenderJob >( mapSettings, QgsMapRendererStagedRenderJob::RenderLabelsByMapLayer ); + job = std::make_unique( mapSettings, QgsMapRendererStagedRenderJob::RenderLabelsByMapLayer ); job->start(); QVERIFY( !job->isFinished() ); QCOMPARE( job->currentLayerId(), polygonsLayer->id() ); @@ -863,14 +851,13 @@ void TestQgsMapRendererJob::stagedRendererWithStagedLabeling() void TestQgsMapRendererJob::vectorLayerBoundsWithReprojection() { - std::unique_ptr< QgsVectorLayer > gridLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/grid_4326.geojson" ), - QStringLiteral( "grid" ), QStringLiteral( "ogr" ) ); + std::unique_ptr gridLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/grid_4326.geojson" ), QStringLiteral( "grid" ), QStringLiteral( "ogr" ) ); QVERIFY( gridLayer->isValid() ); - std::unique_ptr< QgsLineSymbol > symbol = std::make_unique< QgsLineSymbol >(); + std::unique_ptr symbol = std::make_unique(); symbol->setColor( QColor( 255, 0, 255 ) ); symbol->setWidth( 2 ); - std::unique_ptr< QgsSingleSymbolRenderer > renderer = std::make_unique< QgsSingleSymbolRenderer >( symbol.release() ); + std::unique_ptr renderer = std::make_unique( symbol.release() ); gridLayer->setRenderer( renderer.release() ); QgsMapSettings mapSettings; @@ -880,7 +867,7 @@ void TestQgsMapRendererJob::vectorLayerBoundsWithReprojection() mapSettings.setOutputSize( QSize( 512, 512 ) ); mapSettings.setFlag( Qgis::MapSettingsFlag::DrawLabeling, false ); mapSettings.setOutputDpi( 96 ); - mapSettings.setLayers( QList< QgsMapLayer * >() << gridLayer.get() ); + mapSettings.setLayers( QList() << gridLayer.get() ); QgsMapRendererSequentialJob renderJob( mapSettings ); renderJob.start(); @@ -891,8 +878,7 @@ void TestQgsMapRendererJob::vectorLayerBoundsWithReprojection() void TestQgsMapRendererJob::temporalRender() { - std::unique_ptr< QgsRasterLayer > rasterLayer = std::make_unique< QgsRasterLayer >( TEST_DATA_DIR + QStringLiteral( "/raster_layer.tiff" ), - QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rasterLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/raster_layer.tiff" ), QStringLiteral( "raster" ), QStringLiteral( "gdal" ) ); QVERIFY( rasterLayer->isValid() ); QgsMapSettings mapSettings; @@ -901,7 +887,7 @@ void TestQgsMapRendererJob::temporalRender() mapSettings.setOutputSize( QSize( 512, 512 ) ); mapSettings.setFlag( Qgis::MapSettingsFlag::DrawLabeling, false ); mapSettings.setOutputDpi( 96 ); - mapSettings.setLayers( QList< QgsMapLayer * >() << rasterLayer.get() ); + mapSettings.setLayers( QList() << rasterLayer.get() ); QgsMapRendererSequentialJob renderJob( mapSettings ); renderJob.start(); @@ -910,11 +896,10 @@ void TestQgsMapRendererJob::temporalRender() QVERIFY( imageCheck( QStringLiteral( "temporal_render_visible" ), img ) ); // set temporal properties for layer - QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast< QgsRasterLayerTemporalProperties * >( rasterLayer->temporalProperties() ); + QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast( rasterLayer->temporalProperties() ); temporalProperties->setIsActive( true ); temporalProperties->setMode( Qgis::RasterTemporalMode::FixedTemporalRange ); - temporalProperties->setFixedTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ) ) ); + temporalProperties->setFixedTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ) ) ); // should still be visible -- map render job isn't temporal QgsMapRendererSequentialJob renderJob2( mapSettings ); @@ -925,8 +910,7 @@ void TestQgsMapRendererJob::temporalRender() // make render job temporal, outside of layer's fixed range mapSettings.setIsTemporal( true ); - mapSettings.setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2021, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2021, 1, 5 ), QTime( 0, 0, 0 ) ) ) ); + mapSettings.setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2021, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 1, 5 ), QTime( 0, 0, 0 ) ) ) ); // should no longer be visible QgsMapRendererSequentialJob renderJob3( mapSettings ); renderJob3.start(); @@ -935,15 +919,13 @@ void TestQgsMapRendererJob::temporalRender() QVERIFY( imageCheck( QStringLiteral( "temporal_render_invisible" ), img ) ); // temporal range ok for layer - mapSettings.setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 2 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ); + mapSettings.setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 2 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ); // should be visible QgsMapRendererSequentialJob renderJob4( mapSettings ); renderJob4.start(); renderJob4.waitForFinished(); img = renderJob4.renderedImage(); QVERIFY( imageCheck( QStringLiteral( "temporal_render_visible" ), img ) ); - } class TestLabelSink : public QgsLabelSink @@ -965,8 +947,7 @@ class TestLabelSink : public QgsLabelSink void TestQgsMapRendererJob::labelSink() { - std::unique_ptr< QgsVectorLayer > pointsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr pointsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); QgsPalLayerSettings settings; @@ -988,7 +969,7 @@ void TestQgsMapRendererJob::labelSink() mapSettings.setOutputSize( QSize( 512, 512 ) ); mapSettings.setFlag( Qgis::MapSettingsFlag::DrawLabeling, true ); mapSettings.setOutputDpi( 96 ); - mapSettings.setLayers( QList< QgsMapLayer * >() << pointsLayer.get() ); + mapSettings.setLayers( QList() << pointsLayer.get() ); QgsMapRendererSequentialJob renderJob( mapSettings ); @@ -1004,8 +985,7 @@ void TestQgsMapRendererJob::labelSink() void TestQgsMapRendererJob::skipSymbolRendering() { - std::unique_ptr< QgsVectorLayer > pointsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr pointsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); QgsPalLayerSettings settings; @@ -1028,7 +1008,7 @@ void TestQgsMapRendererJob::skipSymbolRendering() mapSettings.setFlag( Qgis::MapSettingsFlag::DrawLabeling, true ); mapSettings.setFlag( Qgis::MapSettingsFlag::SkipSymbolRendering, true ); mapSettings.setOutputDpi( 96 ); - mapSettings.setLayers( QList< QgsMapLayer * >() << pointsLayer.get() ); + mapSettings.setLayers( QList() << pointsLayer.get() ); QgsMapRendererSequentialJob renderJob( mapSettings ); renderJob.start(); @@ -1039,8 +1019,7 @@ void TestQgsMapRendererJob::skipSymbolRendering() void TestQgsMapRendererJob::customNullPainterJob() { - std::unique_ptr< QgsVectorLayer > pointsLayer = std::make_unique< QgsVectorLayer >( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), - QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); + std::unique_ptr pointsLayer = std::make_unique( TEST_DATA_DIR + QStringLiteral( "/points.shp" ), QStringLiteral( "points" ), QStringLiteral( "ogr" ) ); QVERIFY( pointsLayer->isValid() ); QgsPalLayerSettings settings; @@ -1062,7 +1041,7 @@ void TestQgsMapRendererJob::customNullPainterJob() mapSettings.setOutputSize( QSize( 512, 512 ) ); mapSettings.setFlag( Qgis::MapSettingsFlag::DrawLabeling, true ); mapSettings.setOutputDpi( 96 ); - mapSettings.setLayers( QList< QgsMapLayer * >() << pointsLayer.get() ); + mapSettings.setLayers( QList() << pointsLayer.get() ); std::unique_ptr nullPaintDevice = std::make_unique(); nullPaintDevice->setOutputSize( QSize( 512, 512 ) ); @@ -1082,43 +1061,40 @@ void TestQgsMapRendererJob::customNullPainterJob() void TestQgsMapRendererJob::testMapShading() { - std::unique_ptr< QgsPointCloudLayer > pointCloudLayer = - std::make_unique< QgsPointCloudLayer >( - TEST_DATA_DIR + - QStringLiteral( "/point_clouds/ept/lone-star-laszip/ept.json" ), - QStringLiteral( "point-cloud" ), - QStringLiteral( "ept" ) ); + std::unique_ptr pointCloudLayer = std::make_unique( + TEST_DATA_DIR + QStringLiteral( "/point_clouds/ept/lone-star-laszip/ept.json" ), + QStringLiteral( "point-cloud" ), + QStringLiteral( "ept" ) + ); QVERIFY( pointCloudLayer->isValid() ); std::unique_ptr pointCloudRenderer( new QgsPointCloudAttributeByRampRenderer ); pointCloudRenderer->setDrawOrder2d( Qgis::PointCloudDrawOrder::BottomToTop ); pointCloudLayer->setRenderer( pointCloudRenderer.release() ); - std::unique_ptr< QgsRasterLayer > rasterLayer = - std::make_unique< QgsRasterLayer >( - TEST_DATA_DIR + - QStringLiteral( "/raster/raster_shading.tif" ), - QStringLiteral( "raster" ), - QStringLiteral( "gdal" ) ); + std::unique_ptr rasterLayer = std::make_unique( + TEST_DATA_DIR + QStringLiteral( "/raster/raster_shading.tif" ), + QStringLiteral( "raster" ), + QStringLiteral( "gdal" ) + ); QVERIFY( rasterLayer->isValid() ); static_cast( rasterLayer->elevationProperties() )->setEnabled( true ); rasterLayer->dataProvider()->enableProviderResampling( true ); rasterLayer->dataProvider()->setZoomedOutResamplingMethod( QgsRasterDataProvider::ResamplingMethod::Cubic ); - std::unique_ptr< QgsMeshLayer > meshLayer = - std::make_unique< QgsMeshLayer >( - TEST_DATA_DIR + - QStringLiteral( "/mesh/mesh_shading.nc" ), - QStringLiteral( "mesh" ), - QStringLiteral( "mdal" ) ); + std::unique_ptr meshLayer = std::make_unique( + TEST_DATA_DIR + QStringLiteral( "/mesh/mesh_shading.nc" ), + QStringLiteral( "mesh" ), + QStringLiteral( "mdal" ) + ); QVERIFY( meshLayer->isValid() ); - std::unique_ptr< QgsVectorLayer > vectorLayer = - std::make_unique< QgsVectorLayer >( - QStringLiteral( "Polygon?crs=%1&field=id:integer&field=name:string(20)&index=no" ) + std::unique_ptr vectorLayer = std::make_unique( + QStringLiteral( "Polygon?crs=%1&field=id:integer&field=name:string(20)&index=no" ) .arg( pointCloudLayer->crs().toWkt( Qgis::CrsWktVariant::Preferred ) ), - QStringLiteral( "vector-layer" ), - QStringLiteral( "memory" ) ); + QStringLiteral( "vector-layer" ), + QStringLiteral( "memory" ) + ); QVERIFY( vectorLayer->isValid() ); QgsFeature ft0( vectorLayer->fields() ); @@ -1128,7 +1104,7 @@ void TestQgsMapRendererJob::testMapShading() vectorLayer->addFeature( ft0 ); vectorLayer->commitChanges(); QVERIFY( vectorLayer->featureCount() == 1 ); - std::unique_ptr fill( static_cast< QgsFillSymbol * >( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ) ) ; + std::unique_ptr fill( static_cast( QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ) ) ); fill->setColor( QColor( 255, 0, 255 ) ); vectorLayer->setRenderer( new QgsSingleSymbolRenderer( fill.release() ) ); @@ -1137,11 +1113,7 @@ void TestQgsMapRendererJob::testMapShading() mapSettings.setExtent( pointCloudLayer->extent() ); mapSettings.setOutputSize( QSize( 512, 512 ) ); mapSettings.setOutputDpi( 96 ); - mapSettings.setLayers( QList< QgsMapLayer * >() - << pointCloudLayer.get() - << rasterLayer.get() - << vectorLayer.get() - << meshLayer.get() ); + mapSettings.setLayers( QList() << pointCloudLayer.get() << rasterLayer.get() << vectorLayer.get() << meshLayer.get() ); QgsElevationShadingRenderer shadingRenderer; shadingRenderer.setActive( true ); @@ -1197,7 +1169,7 @@ void TestQgsMapRendererJob::testMapShading() shadingRenderer2.setActiveHillshading( true ); shadingRenderer2.setActiveEyeDomeLighting( false ); pointCloudLayer->renderer()->setRenderAsTriangles( true ); - mapSettings.setLayers( QList< QgsMapLayer * >() << pointCloudLayer.get() ); + mapSettings.setLayers( QList() << pointCloudLayer.get() ); mapSettings.setElevationShadingRenderer( shadingRenderer2 ); renderJob.reset( new QgsMapRendererSequentialJob( mapSettings ) ); renderJob->start(); @@ -1224,5 +1196,3 @@ bool TestQgsMapRendererJob::imageCheck( const QString &testName, const QImage &i QGSTEST_MAIN( TestQgsMapRendererJob ) #include "testqgsmaprendererjob.moc" - - diff --git a/tests/src/core/testqgsmaprotation.cpp b/tests/src/core/testqgsmaprotation.cpp index 79a2b367cf17..1384602142ea 100644 --- a/tests/src/core/testqgsmaprotation.cpp +++ b/tests/src/core/testqgsmaprotation.cpp @@ -51,8 +51,8 @@ class TestQgsMapRotation : public QgsTest ~TestQgsMapRotation() override; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void rasterLayer(); void pointsLayer(); @@ -80,22 +80,19 @@ void TestQgsMapRotation::initTestCase() //create a raster layer that will be used in all tests... const QFileInfo rasterFileInfo( mTestDataDir + "rgb256x256.png" ); - mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer *rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 ); mRasterLayer->setRenderer( rasterRenderer ); //create a point layer that will be used in all tests... const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); //create a line layer that will be used in all tests... const QString myLinesFileName = mTestDataDir + "lines_cardinals.shp"; const QFileInfo myLinesFileInfo( myLinesFileName ); - mLinesLayer = new QgsVectorLayer( myLinesFileInfo.filePath(), - myLinesFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mLinesLayer = new QgsVectorLayer( myLinesFileInfo.filePath(), myLinesFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // This is needed to correctly set rotation center, // the actual size doesn't matter as QgsRenderChecker will diff --git a/tests/src/core/testqgsmapsettings.cpp b/tests/src/core/testqgsmapsettings.cpp index 52c07f790b9a..7ab81eae21c2 100644 --- a/tests/src/core/testqgsmapsettings.cpp +++ b/tests/src/core/testqgsmapsettings.cpp @@ -34,12 +34,10 @@ class TestHandler : public QgsRenderedFeatureHandlerInterface { public: - void handleRenderedFeature( const QgsFeature &, const QgsGeometry &, const QgsRenderedFeatureHandlerInterface::RenderedFeatureContext & ) override {} - }; -class TestQgsMapSettings: public QObject +class TestQgsMapSettings : public QObject { Q_OBJECT private slots: @@ -91,9 +89,7 @@ QString TestQgsMapSettings::toString( const QPolygonF &p, int dec ) const const double r = std::pow( 10.0, dec ); for ( int i = 0; i < p.size(); ++i ) { - s += QStringLiteral( "%1%2 %3" ).arg( sep ) - .arg( int( p[i].x() * r ) / r ) - .arg( int( p[i].y() * r ) / r ); + s += QStringLiteral( "%1%2 %3" ).arg( sep ).arg( int( p[i].x() * r ) / r ).arg( int( p[i].y() * r ) / r ); sep = ","; } @@ -246,29 +242,22 @@ void TestQgsMapSettings::visiblePolygon() ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) ); ms.setOutputSize( QSize( 100, 50 ) ); - QCOMPARE( toString( ms.visiblePolygon() ), - QString( "-50 100,150 100,150 0,-50 0" ) ); + QCOMPARE( toString( ms.visiblePolygon() ), QString( "-50 100,150 100,150 0,-50 0" ) ); ms.setExtent( QgsRectangle( 0, -50, 100, 0 ) ); ms.setOutputSize( QSize( 100, 50 ) ); ms.setRotation( 90 ); - QCOMPARE( toString( ms.visiblePolygon() ), - QString( "25 -75,25 25,75 25,75 -75" ) ); + QCOMPARE( toString( ms.visiblePolygon() ), QString( "25 -75,25 25,75 25,75 -75" ) ); ms.setRotation( -90 ); - QCOMPARE( toString( ms.visiblePolygon() ), - QString( "75 25,75 -75,25 -75,25 25" ) ); + QCOMPARE( toString( ms.visiblePolygon() ), QString( "75 25,75 -75,25 -75,25 25" ) ); ms.setRotation( 30 ); - QCOMPARE( toString( ms.visiblePolygon() ), - QString( "-5.8 -28.34,80.8 21.65,105.8 -21.65,19.19 -71.65" ) ); + QCOMPARE( toString( ms.visiblePolygon() ), QString( "-5.8 -28.34,80.8 21.65,105.8 -21.65,19.19 -71.65" ) ); ms.setRotation( -30 ); - QCOMPARE( toString( ms.visiblePolygon() ), - QString( "19.19 21.65,105.8 -28.34,80.8 -71.65,-5.8 -21.65" ) ); + QCOMPARE( toString( ms.visiblePolygon() ), QString( "19.19 21.65,105.8 -28.34,80.8 -71.65,-5.8 -21.65" ) ); ms.setRotation( 45 ); - QCOMPARE( toString( ms.visiblePolygon() ), - QString( "-3.03 -42.67,67.67 28.03,103.03 -7.32,32.32 -78.03" ) ); + QCOMPARE( toString( ms.visiblePolygon() ), QString( "-3.03 -42.67,67.67 28.03,103.03 -7.32,32.32 -78.03" ) ); ms.setRotation( -45 ); - QCOMPARE( toString( ms.visiblePolygon() ), - QString( "32.32 28.03,103.03 -42.67,67.67 -78.03,-3.03 -7.32" ) ); + QCOMPARE( toString( ms.visiblePolygon() ), QString( "32.32 28.03,103.03 -42.67,67.67 -78.03,-3.03 -7.32" ) ); } void TestQgsMapSettings::visiblePolygonWithBuffer() @@ -277,23 +266,19 @@ void TestQgsMapSettings::visiblePolygonWithBuffer() ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) ); ms.setOutputSize( QSize( 100, 50 ) ); - QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), - QString( "-50 100,150 100,150 0,-50 0" ) ); + QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), QString( "-50 100,150 100,150 0,-50 0" ) ); ms.setExtentBuffer( 10 ); - QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), - QString( "-70 120,170 120,170 -20,-70 -20" ) ); + QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), QString( "-70 120,170 120,170 -20,-70 -20" ) ); ms.setExtent( QgsRectangle( 0, -50, 100, 0 ) ); ms.setOutputSize( QSize( 100, 50 ) ); ms.setRotation( 90 ); ms.setExtentBuffer( 0 ); - QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), - QString( "25 -75,25 25,75 25,75 -75" ) ); + QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), QString( "25 -75,25 25,75 25,75 -75" ) ); ms.setExtentBuffer( 10 ); - QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), - QString( "15 -85,15 35,85 35,85 -85" ) ); + QCOMPARE( toString( ms.visiblePolygonWithBuffer() ), QString( "15 -85,15 35,85 35,85 -85" ) ); } void TestQgsMapSettings::testIsLayerVisible() @@ -375,7 +360,6 @@ void TestQgsMapSettings::testIsLayerVisible() e2.prepare( &context ); r = e2.evaluate( &context ); QCOMPARE( r.toBool(), false ); // layer is deleted - } void TestQgsMapSettings::testMapLayerListUtils() @@ -414,7 +398,7 @@ void TestQgsMapSettings::testMapLayerListUtils() // QPointer to vlA must get invalidated delete vlA; - QCOMPARE( listQPointer.count(), 2 ); // still two items but one is invalid + QCOMPARE( listQPointer.count(), 2 ); // still two items but one is invalid QList listRaw2 = _qgis_listQPointerToRaw( listQPointer ); @@ -433,9 +417,9 @@ void TestQgsMapSettings::testXmlReadWrite() { //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement element = doc.createElement( QStringLiteral( "s" ) ); @@ -462,19 +446,19 @@ void TestQgsMapSettings::testXmlReadWrite() void TestQgsMapSettings::testSetLayers() { - const std::unique_ptr< QgsVectorLayer > vlA = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); - const std::unique_ptr< QgsVectorLayer > vlB = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "b" ), QStringLiteral( "memory" ) ); - const std::unique_ptr< QgsVectorLayer > nonSpatial = std::make_unique< QgsVectorLayer >( QStringLiteral( "none" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); + const std::unique_ptr vlA = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); + const std::unique_ptr vlB = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "b" ), QStringLiteral( "memory" ) ); + const std::unique_ptr nonSpatial = std::make_unique( QStringLiteral( "none" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); QgsMapSettings ms; - ms.setLayers( QList< QgsMapLayer * >() << vlA.get() ); - QCOMPARE( ms.layers(), QList< QgsMapLayer * >() << vlA.get() ); - ms.setLayers( QList< QgsMapLayer * >() << vlB.get() << vlA.get() ); - QCOMPARE( ms.layers(), QList< QgsMapLayer * >() << vlB.get() << vlA.get() ); + ms.setLayers( QList() << vlA.get() ); + QCOMPARE( ms.layers(), QList() << vlA.get() ); + ms.setLayers( QList() << vlB.get() << vlA.get() ); + QCOMPARE( ms.layers(), QList() << vlB.get() << vlA.get() ); // non spatial and null layers should be stripped - ms.setLayers( QList< QgsMapLayer * >() << vlA.get() << nonSpatial.get() << nullptr << vlB.get() ); - QCOMPARE( ms.layers(), QList< QgsMapLayer * >() << vlA.get() << vlB.get() ); + ms.setLayers( QList() << vlA.get() << nonSpatial.get() << nullptr << vlB.get() ); + QCOMPARE( ms.layers(), QList() << vlA.get() << vlB.get() ); } void TestQgsMapSettings::testLabelBoundary() @@ -624,7 +608,7 @@ void TestQgsMapSettings::testExpressionContext() QCOMPARE( r.toDateTime(), QDateTime( QDate( 2010, 6, 7 ), QTime( 0, 0, 0 ) ) ); e = QgsExpression( QStringLiteral( "@map_interval" ) ); r = e.evaluate( &c ); - QCOMPARE( r.value< QgsInterval >(), QgsInterval( QDateTime( QDate( 2010, 6, 7 ), QTime( 0, 0, 0 ) ) - QDateTime( QDate( 2002, 3, 4 ), QTime( 0, 0, 0 ) ) ) ); + QCOMPARE( r.value(), QgsInterval( QDateTime( QDate( 2010, 6, 7 ), QTime( 0, 0, 0 ) ) - QDateTime( QDate( 2002, 3, 4 ), QTime( 0, 0, 0 ) ) ) ); QVERIFY( !c.variable( QStringLiteral( "frame_rate" ) ).isValid() ); QVERIFY( !c.variable( QStringLiteral( "frame_number" ) ).isValid() ); @@ -645,14 +629,14 @@ void TestQgsMapSettings::testExpressionContext() void TestQgsMapSettings::testRenderedFeatureHandlers() { - const std::unique_ptr< TestHandler > testHandler = std::make_unique< TestHandler >(); - const std::unique_ptr< TestHandler > testHandler2 = std::make_unique< TestHandler >(); + const std::unique_ptr testHandler = std::make_unique(); + const std::unique_ptr testHandler2 = std::make_unique(); - std::unique_ptr< QgsMapSettings> mapSettings = std::make_unique< QgsMapSettings >(); + std::unique_ptr mapSettings = std::make_unique(); QVERIFY( mapSettings->renderedFeatureHandlers().isEmpty() ); mapSettings->addRenderedFeatureHandler( testHandler.get() ); mapSettings->addRenderedFeatureHandler( testHandler2.get() ); - QCOMPARE( mapSettings->renderedFeatureHandlers(), QList< QgsRenderedFeatureHandlerInterface * >() << testHandler.get() << testHandler2.get() ); + QCOMPARE( mapSettings->renderedFeatureHandlers(), QList() << testHandler.get() << testHandler2.get() ); //ownership should NOT be transferred, i.e. it won't delete the registered handlers upon QgsMapSettings destruction mapSettings.reset(); @@ -664,8 +648,8 @@ void TestQgsMapSettings::testCustomRenderingFlags() QgsMapSettings settings; settings.setCustomRenderingFlag( QStringLiteral( "myexport" ), true ); settings.setCustomRenderingFlag( QStringLiteral( "omitgeometries" ), QStringLiteral( "points" ) ); - QVERIFY( settings.customRenderingFlags()[ QStringLiteral( "myexport" ) ].toBool() == true ); - QVERIFY( settings.customRenderingFlags()[ QStringLiteral( "omitgeometries" ) ].toString() == QLatin1String( "points" ) ); + QVERIFY( settings.customRenderingFlags()[QStringLiteral( "myexport" )].toBool() == true ); + QVERIFY( settings.customRenderingFlags()[QStringLiteral( "omitgeometries" )].toString() == QLatin1String( "points" ) ); // Test deprecated API Q_NOWARN_DEPRECATED_PUSH @@ -699,11 +683,11 @@ void TestQgsMapSettings::testClippingRegions() settings3 = settings; QCOMPARE( settings3.clippingRegions().size(), 2 ); QCOMPARE( settings3.clippingRegions().at( 0 ).geometry().asWkt(), QStringLiteral( "Polygon ((0 0, 1 0, 1 1, 0 1, 0 0))" ) ); - QCOMPARE( settings3.clippingRegions().at( 1 ).geometry().asWkt(), QStringLiteral( "Polygon ((10 0, 11 0, 11 1, 10 1, 10 0))" ) ) ; + QCOMPARE( settings3.clippingRegions().at( 1 ).geometry().asWkt(), QStringLiteral( "Polygon ((10 0, 11 0, 11 1, 10 1, 10 0))" ) ); - settings.setClippingRegions( QList< QgsMapClippingRegion >() << region2 ); + settings.setClippingRegions( QList() << region2 ); QCOMPARE( settings.clippingRegions().size(), 1 ); - QCOMPARE( settings.clippingRegions().at( 0 ).geometry().asWkt(), QStringLiteral( "Polygon ((10 0, 11 0, 11 1, 10 1, 10 0))" ) ) ; + QCOMPARE( settings.clippingRegions().at( 0 ).geometry().asWkt(), QStringLiteral( "Polygon ((10 0, 11 0, 11 1, 10 1, 10 0))" ) ); } void TestQgsMapSettings::testComputeExtentForScale() @@ -719,8 +703,7 @@ void TestQgsMapSettings::testComputeExtentForScale() // [ output width in inches ] * [scale] const double widthInches = settings.outputSize().width() / double( settings.outputDpi() ) * 500; const double widthMapUnits = widthInches * QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Feet, settings.mapUnits() ) / 12; - QGSCOMPARENEARRECTANGLE( rect, QgsRectangle( - 0.5 * widthMapUnits, - 0.5 * widthMapUnits, 0.5 * widthMapUnits, 0.5 * widthMapUnits ), 0.0001 ); - + QGSCOMPARENEARRECTANGLE( rect, QgsRectangle( -0.5 * widthMapUnits, -0.5 * widthMapUnits, 0.5 * widthMapUnits, 0.5 * widthMapUnits ), 0.0001 ); } void TestQgsMapSettings::testComputeScaleForExtent() @@ -743,9 +726,9 @@ void TestQgsMapSettings::testLayersWithGroupLayers() // test retrieving layers from map settings when a QgsGroupLayer is present QgsMapSettings settings; - std::unique_ptr< QgsVectorLayer > vlA = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); - std::unique_ptr< QgsVectorLayer > vlB = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "b" ), QStringLiteral( "memory" ) ); - std::unique_ptr< QgsVectorLayer > vlC = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "c" ), QStringLiteral( "memory" ) ); + std::unique_ptr vlA = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) ); + std::unique_ptr vlB = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "b" ), QStringLiteral( "memory" ) ); + std::unique_ptr vlC = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "c" ), QStringLiteral( "memory" ) ); QgsGroupLayer::LayerOptions options( ( QgsCoordinateTransformContext() ) ); QgsGroupLayer groupLayer( QStringLiteral( "group" ), options ); diff --git a/tests/src/core/testqgsmapsettingsutils.cpp b/tests/src/core/testqgsmapsettingsutils.cpp index dbd091f48c57..dd6a59198d97 100644 --- a/tests/src/core/testqgsmapsettingsutils.cpp +++ b/tests/src/core/testqgsmapsettingsutils.cpp @@ -28,18 +28,16 @@ class TestQgsMapSettingsUtils : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase() {} // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after each testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after each testfunction was executed. - void createWorldFileContent(); //test world file content function + void createWorldFileContent(); //test world file content function void containsAdvancedEffects(); //test contains advanced effects function private: - QgsMapSettings mMapSettings; - }; void TestQgsMapSettingsUtils::initTestCase() @@ -82,7 +80,7 @@ void TestQgsMapSettingsUtils::containsAdvancedEffects() { QgsMapSettings mapSettings = mMapSettings; - std::unique_ptr< QgsVectorLayer > layer( new QgsVectorLayer( QStringLiteral( "Point?field=col1:real" ), QStringLiteral( "layer" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr layer( new QgsVectorLayer( QStringLiteral( "Point?field=col1:real" ), QStringLiteral( "layer" ), QStringLiteral( "memory" ) ) ); layer->setBlendMode( QPainter::CompositionMode_Multiply ); QList layers; diff --git a/tests/src/core/testqgsmapthemecollection.cpp b/tests/src/core/testqgsmapthemecollection.cpp index 1f93badc8488..ad283e611c8e 100644 --- a/tests/src/core/testqgsmapthemecollection.cpp +++ b/tests/src/core/testqgsmapthemecollection.cpp @@ -30,8 +30,8 @@ class TestQgsMapThemeCollection : public QObject TestQgsMapThemeCollection() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void expandedState(); void checkedState(); @@ -58,16 +58,13 @@ void TestQgsMapThemeCollection::initTestCase() QgsApplication::initQgis(); const QFileInfo pointFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/points.shp" ); - mPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); const QFileInfo polyFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/polys.shp" ); - mPolysLayer = new QgsVectorLayer( polyFileInfo.filePath(), - polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPolysLayer = new QgsVectorLayer( polyFileInfo.filePath(), polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); const QFileInfo lineFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/lines.shp" ); - mLinesLayer = new QgsVectorLayer( lineFileInfo.filePath(), - lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mLinesLayer = new QgsVectorLayer( lineFileInfo.filePath(), lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // rule-based renderer for points layer with two levels of rules QgsRuleBasedRenderer::Rule *rule0 = new QgsRuleBasedRenderer::Rule( nullptr ); @@ -125,7 +122,7 @@ void TestQgsMapThemeCollection::expandedState() const QList legendNodes = mLayerTreeModel->layerLegendNodes( mNodeLayerPoints, true ); for ( QgsLayerTreeModelLegendNode *legendNode : legendNodes ) { - const QString key = legendNode->data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(); + const QString key = legendNode->data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(); pointLayerRootLegendNodes << key; } QCOMPARE( pointLayerRootLegendNodes.count(), 4 ); @@ -215,7 +212,7 @@ void TestQgsMapThemeCollection::checkedState() const QList legendNodes = mLayerTreeModel->layerLegendNodes( mNodeLayerPoints, true ); for ( QgsLayerTreeModelLegendNode *legendNode : legendNodes ) { - const QString key = legendNode->data( static_cast< int >( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(); + const QString key = legendNode->data( static_cast( QgsLayerTreeModelLegendNode::CustomRole::RuleKey ) ).toString(); pointLayerRootLegendNodes << key; } QCOMPARE( pointLayerRootLegendNodes.count(), 4 ); diff --git a/tests/src/core/testqgsmaptopixel.cpp b/tests/src/core/testqgsmaptopixel.cpp index d29f82fcc0bb..83a21d57407e 100644 --- a/tests/src/core/testqgsmaptopixel.cpp +++ b/tests/src/core/testqgsmaptopixel.cpp @@ -20,7 +20,7 @@ #include #include -class TestQgsMapToPixel: public QObject +class TestQgsMapToPixel : public QObject { Q_OBJECT private slots: @@ -71,9 +71,9 @@ void TestQgsMapToPixel::rotation() { QgsMapToPixel m2p( 1, 5, 5, 10, 10, 90 ); - QgsPointXY p( 5, 5 ); // in geographical units + QgsPointXY p( 5, 5 ); // in geographical units QgsPointXY d = m2p.transform( p ); // to device pixels - QCOMPARE( d.x(), 5.0 ); // center doesn't move + QCOMPARE( d.x(), 5.0 ); // center doesn't move QCOMPARE( d.y(), 5.0 ); const QgsPointXY b = m2p.toMapCoordinates( d.x(), d.y() ); // transform back @@ -108,7 +108,6 @@ void TestQgsMapToPixel::rotation() QCOMPARE( p.y(), 5.5 ); d = m2p.transform( p ); QCOMPARE( d, QgsPointXY( 10, 0 ) ); - } void TestQgsMapToPixel::getters() @@ -207,7 +206,3 @@ void TestQgsMapToPixel::transformBounds() QGSTEST_MAIN( TestQgsMapToPixel ) #include "testqgsmaptopixel.moc" - - - - diff --git a/tests/src/core/testqgsmaptopixelgeometrysimplifier.cpp b/tests/src/core/testqgsmaptopixelgeometrysimplifier.cpp index a69e0f60e6c2..89489842290d 100644 --- a/tests/src/core/testqgsmaptopixelgeometrysimplifier.cpp +++ b/tests/src/core/testqgsmaptopixelgeometrysimplifier.cpp @@ -43,7 +43,7 @@ class TestQgsMapToPixelGeometrySimplifier : public QObject private: // Release return with delete [] unsigned char * - hex2bytes( const char *hex, int *size ) + hex2bytes( const char *hex, int *size ) { QByteArray ba = QByteArray::fromHex( hex ); unsigned char *out = new unsigned char[ba.size()]; @@ -53,10 +53,10 @@ class TestQgsMapToPixelGeometrySimplifier : public QObject } private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testDefaultGeometry(); void testLine1(); @@ -69,7 +69,6 @@ class TestQgsMapToPixelGeometrySimplifier : public QObject void testVisvalingamZM(); void testRingValidity(); void testAbstractGeometrySimplify(); - }; TestQgsMapToPixelGeometrySimplifier::TestQgsMapToPixelGeometrySimplifier() = default; @@ -140,8 +139,7 @@ void TestQgsMapToPixelGeometrySimplifier::testLine1() QCOMPARE( wkt, QString( "LineString (0 0, 20 1)" ) ); } -void -TestQgsMapToPixelGeometrySimplifier::testIsGeneralizableByMapBoundingBox() +void TestQgsMapToPixelGeometrySimplifier::testIsGeneralizableByMapBoundingBox() { const QgsRectangle r1( 0, 0, 10, 1 ); bool ret; @@ -151,10 +149,10 @@ TestQgsMapToPixelGeometrySimplifier::testIsGeneralizableByMapBoundingBox() // NOTE: boundary case ret = QgsMapToPixelSimplifier::isGeneralizableByMapBoundingBox( r1, 10 ); - QVERIFY( ! ret ); + QVERIFY( !ret ); ret = QgsMapToPixelSimplifier::isGeneralizableByMapBoundingBox( r1, 5 ); - QVERIFY( ! ret ); + QVERIFY( !ret ); } void TestQgsMapToPixelGeometrySimplifier::testWkbDimensionMismatch() @@ -239,14 +237,13 @@ void TestQgsMapToPixelGeometrySimplifier::testRingValidity() const QgsMapToPixelSimplifier simplifier( fl, 5 ); const QgsGeometry ret = simplifier.simplify( poly ); QVERIFY( ret.isGeosValid() ); - } void TestQgsMapToPixelGeometrySimplifier::testAbstractGeometrySimplify() { // test direct simplification of abstract geometries, especially the "no simplification required" paths QgsMapToPixelSimplifier simplifier( QgsMapToPixelSimplifier::SimplifyGeometry, 5 ); - std::unique_ptr< QgsAbstractGeometry > simplified; + std::unique_ptr simplified; // no input geometry simplified.reset( simplifier.simplify( nullptr ) ); diff --git a/tests/src/core/testqgsmarkerlinesymbol.cpp b/tests/src/core/testqgsmarkerlinesymbol.cpp index 80b5fe886072..e57b74098085 100644 --- a/tests/src/core/testqgsmarkerlinesymbol.cpp +++ b/tests/src/core/testqgsmarkerlinesymbol.cpp @@ -54,8 +54,8 @@ class TestQgsMarkerLineSymbol : public QgsTest ~TestQgsMarkerLineSymbol() override; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void lineOffset(); void pointNumInterval(); @@ -85,8 +85,7 @@ void TestQgsMarkerLineSymbol::initTestCase() //create a line layer that will be used in all tests... const QString myLinesFileName = mTestDataDir + "lines_cardinals.shp"; const QFileInfo myLinesFileInfo( myLinesFileName ); - mLinesLayer = new QgsVectorLayer( myLinesFileInfo.filePath(), - myLinesFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mLinesLayer = new QgsVectorLayer( myLinesFileInfo.filePath(), myLinesFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); mapLayers << mLinesLayer; // Register all layers with the registry @@ -144,7 +143,7 @@ void TestQgsMarkerLineSymbol::pointNumInterval() props[QStringLiteral( "color" )] = QStringLiteral( "255,0,0" ); props[QStringLiteral( "size" )] = QStringLiteral( "2" ); props[QStringLiteral( "outline_style" )] = QStringLiteral( "no" ); - QgsSimpleMarkerSymbolLayer *marker = static_cast< QgsSimpleMarkerSymbolLayer * >( QgsSimpleMarkerSymbolLayer::create( props ) ); + QgsSimpleMarkerSymbolLayer *marker = static_cast( QgsSimpleMarkerSymbolLayer::create( props ) ); marker->setDataDefinedProperty( QgsSymbolLayer::Property::Size, QgsProperty::fromExpression( QStringLiteral( "@geometry_point_num * 2" ) ) ); @@ -173,7 +172,7 @@ void TestQgsMarkerLineSymbol::pointNumVertex() props[QStringLiteral( "color" )] = QStringLiteral( "255,0,0" ); props[QStringLiteral( "size" )] = QStringLiteral( "2" ); props[QStringLiteral( "outline_style" )] = QStringLiteral( "no" ); - QgsSimpleMarkerSymbolLayer *marker = static_cast< QgsSimpleMarkerSymbolLayer * >( QgsSimpleMarkerSymbolLayer::create( props ) ); + QgsSimpleMarkerSymbolLayer *marker = static_cast( QgsSimpleMarkerSymbolLayer::create( props ) ); marker->setDataDefinedProperty( QgsSymbolLayer::Property::Size, QgsProperty::fromExpression( QStringLiteral( "@geometry_point_num * 2" ) ) ); @@ -197,225 +196,224 @@ void TestQgsMarkerLineSymbol::collectPoints_data() QTest::addColumn>( "expected" ); QTest::newRow( "empty" ) - << QVector< QPointF >() - << 1.0 << 0.0 << 0.0 << 0 - << QVector< QPointF >(); + << QVector() + << 1.0 << 0.0 << 0.0 << 0 + << QVector(); QTest::newRow( "a" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) ) - << 1.0 << 0.0 << 0.0 << 0 - << ( QVector< QPointF >() ); + << ( QVector() << QPointF( 1, 2 ) ) + << 1.0 << 0.0 << 0.0 << 0 + << ( QVector() ); QTest::newRow( "b" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 1.0 << 0.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 2, 2 ) << QPointF( 3, 2 ) - << QPointF( 4, 2 ) << QPointF( 5, 2 ) << QPointF( 6, 2 ) << QPointF( 7, 2 ) << QPointF( 8, 2 ) - << QPointF( 9, 2 ) << QPointF( 10, 2 ) << QPointF( 11, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 1.0 << 0.0 << 0.0 << 0 + << ( QVector() << QPointF( 2, 2 ) << QPointF( 3, 2 ) + << QPointF( 4, 2 ) << QPointF( 5, 2 ) << QPointF( 6, 2 ) << QPointF( 7, 2 ) << QPointF( 8, 2 ) + << QPointF( 9, 2 ) << QPointF( 10, 2 ) << QPointF( 11, 2 ) ); QTest::newRow( "b maxpoints" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 1.0 << 0.0 << 0.0 << 3 - << ( QVector< QPointF >() << QPointF( 2, 2 ) << QPointF( 3, 2 ) - << QPointF( 4, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 1.0 << 0.0 << 0.0 << 3 + << ( QVector() << QPointF( 2, 2 ) << QPointF( 3, 2 ) + << QPointF( 4, 2 ) ); QTest::newRow( "b pad points" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 1.0 << 0.0 << 0.0 << 13 - << ( QVector< QPointF >() << QPointF( 2, 2 ) << QPointF( 3, 2 ) - << QPointF( 4, 2 ) << QPointF( 5, 2 ) << QPointF( 6, 2 ) << QPointF( 7, 2 ) << QPointF( 8, 2 ) - << QPointF( 9, 2 ) << QPointF( 10, 2 ) << QPointF( 11, 2 ) << QPointF( 11, 2 ) << QPointF( 11, 2 ) << QPointF( 11, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 1.0 << 0.0 << 0.0 << 13 + << ( QVector() << QPointF( 2, 2 ) << QPointF( 3, 2 ) + << QPointF( 4, 2 ) << QPointF( 5, 2 ) << QPointF( 6, 2 ) << QPointF( 7, 2 ) << QPointF( 8, 2 ) + << QPointF( 9, 2 ) << QPointF( 10, 2 ) << QPointF( 11, 2 ) << QPointF( 11, 2 ) << QPointF( 11, 2 ) << QPointF( 11, 2 ) ); QTest::newRow( "c" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 1.0 << 1.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 3, 2 ) - << QPointF( 4, 2 ) << QPointF( 5, 2 ) << QPointF( 6, 2 ) << QPointF( 7, 2 ) << QPointF( 8, 2 ) - << QPointF( 9, 2 ) << QPointF( 10, 2 ) << QPointF( 11, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 1.0 << 1.0 << 0.0 << 0 + << ( QVector() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 3, 2 ) + << QPointF( 4, 2 ) << QPointF( 5, 2 ) << QPointF( 6, 2 ) << QPointF( 7, 2 ) << QPointF( 8, 2 ) + << QPointF( 9, 2 ) << QPointF( 10, 2 ) << QPointF( 11, 2 ) ); QTest::newRow( "c3" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 2.0 << 0.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 3, 2 ) << QPointF( 5, 2 ) - << QPointF( 7, 2 ) << QPointF( 9, 2 ) << QPointF( 11, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 2.0 << 0.0 << 0.0 << 0 + << ( QVector() << QPointF( 3, 2 ) << QPointF( 5, 2 ) + << QPointF( 7, 2 ) << QPointF( 9, 2 ) << QPointF( 11, 2 ) ); QTest::newRow( "d" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 2.0 << 1.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 2, 2 ) << QPointF( 4, 2 ) - << QPointF( 6, 2 ) << QPointF( 8, 2 ) << QPointF( 10, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 2.0 << 1.0 << 0.0 << 0 + << ( QVector() << QPointF( 2, 2 ) << QPointF( 4, 2 ) + << QPointF( 6, 2 ) << QPointF( 8, 2 ) << QPointF( 10, 2 ) ); QTest::newRow( "e" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 2.0 << 2.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 3, 2 ) << QPointF( 5, 2 ) - << QPointF( 7, 2 ) << QPointF( 9, 2 ) << QPointF( 11, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 2.0 << 2.0 << 0.0 << 0 + << ( QVector() << QPointF( 1, 2 ) << QPointF( 3, 2 ) << QPointF( 5, 2 ) + << QPointF( 7, 2 ) << QPointF( 9, 2 ) << QPointF( 11, 2 ) ); QTest::newRow( "f" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 2.0 << 0.0 << 1.0 << 0 - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) - << QPointF( 10, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 2.0 << 0.0 << 1.0 << 0 + << ( QVector() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) + << QPointF( 10, 2 ) ); QTest::newRow( "g" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 2.0 << 0.0 << 2.0 << 0 - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 1, 2 ) << QPointF( 3, 2 ) << QPointF( 5, 2 ) << QPointF( 7, 2 ) - << QPointF( 9, 2 ) << QPointF( 11, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 2.0 << 0.0 << 2.0 << 0 + << ( QVector() << QPointF( 1, 2 ) << QPointF( 1, 2 ) << QPointF( 3, 2 ) << QPointF( 5, 2 ) << QPointF( 7, 2 ) + << QPointF( 9, 2 ) << QPointF( 11, 2 ) ); QTest::newRow( "h" ) - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) - << 2.0 << 0.0 << 2.1 << 0 - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 1, 2 ) << QPointF( 2.9, 2 ) << QPointF( 4.9, 2 ) << QPointF( 6.9, 2 ) - << QPointF( 8.9, 2 ) << QPointF( 10.9, 2 ) ); + << ( QVector() << QPointF( 1, 2 ) << QPointF( 11, 2 ) ) + << 2.0 << 0.0 << 2.1 << 0 + << ( QVector() << QPointF( 1, 2 ) << QPointF( 1, 2 ) << QPointF( 2.9, 2 ) << QPointF( 4.9, 2 ) << QPointF( 6.9, 2 ) + << QPointF( 8.9, 2 ) << QPointF( 10.9, 2 ) ); QTest::newRow( "i" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 8, 2 ) ) - << 2.0 << 2.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 8, 2 ) ) + << 2.0 << 2.0 << 0.0 << 0 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) ); QTest::newRow( "j" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 8, 2 ) ) - << 2.0 << 0.0 << 2.0 << 0 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 8, 2 ) ) + << 2.0 << 0.0 << 2.0 << 0 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) ); QTest::newRow( "k" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 8, 2 ) ) - << 2.0 << 0.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 8, 2 ) ) + << 2.0 << 0.0 << 0.0 << 0 + << ( QVector() << QPointF( 2, 2 ) << QPointF( 4, 2 ) << QPointF( 6, 2 ) << QPointF( 8, 2 ) ); QTest::newRow( "closed ring" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 2.0 << 2.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 2.0 << 2.0 << 0.0 << 0 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ); QTest::newRow( "closed ring required points" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 2.0 << 2.0 << 0.0 << 7 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 2.0 << 2.0 << 0.0 << 7 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ); QTest::newRow( "closed ring 1.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 1.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 1.0 << 0.0 << 0 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); QTest::newRow( "closed ring 1.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 1.0 << 0.0 << 11 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 1.0 << 0.0 << 11 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) ); QTest::newRow( "closed ring initial offset 1.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 0.0 << 0 + << ( QVector() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); QTest::newRow( "closed ring initial offset 1.0 num points" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 0.0 << 10 - << ( QVector< QPointF >() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 0.0 << 10 + << ( QVector() << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) ); QTest::newRow( "closed ring 1.0 initial lag 1.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 1.0 << 0 - << ( QVector< QPointF >() << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 1.0 << 0 + << ( QVector() << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); QTest::newRow( "closed ring 2.0 initial lag" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 2.0 << 0.0 << 1.0 << 0 - << ( QVector< QPointF >() << QPointF( 0, 1 ) << QPointF( 1, 2 ) << QPointF( 2, 1 ) << QPointF( 1, 0 ) << QPointF( 0, 1 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 2.0 << 0.0 << 1.0 << 0 + << ( QVector() << QPointF( 0, 1 ) << QPointF( 1, 2 ) << QPointF( 2, 1 ) << QPointF( 1, 0 ) << QPointF( 0, 1 ) ); QTest::newRow( "closed ring 1.0 initial lag 0.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 0.5 << 0 - << ( QVector< QPointF >() << QPointF( 0, 1.5 ) << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) << QPointF( 1.5, 0 ) - << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 0.5 << 0 + << ( QVector() << QPointF( 0, 1.5 ) << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) << QPointF( 1.5, 0 ) + << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) ); QTest::newRow( "closed ring 1.0 initial offset 0.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.5 << 0.0 << 10 - << ( QVector< QPointF >() << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) << QPointF( 1.5, 0 ) - << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) << QPointF( 0.5, 2.0 ) << QPointF( 1.5, 2.0 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.5 << 0.0 << 10 + << ( QVector() << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) << QPointF( 1.5, 0 ) + << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) << QPointF( 0.5, 2.0 ) << QPointF( 1.5, 2.0 ) ); QTest::newRow( "closed ring 1.0 initial lag 1.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 1.5 << 0 - << ( QVector< QPointF >() << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) << QPointF( 1.5, 0 ) - << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 1.5 << 0 + << ( QVector() << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) << QPointF( 1.5, 0 ) + << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) ); QTest::newRow( "closed ring 1.0 initial lag 2.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 2.0 << 0 - << ( QVector< QPointF >() << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 2.0 << 0 + << ( QVector() << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); QTest::newRow( "closed ring 1.0 initial lag 3.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 3.0 << 0 - << ( QVector< QPointF >() << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 3.0 << 0 + << ( QVector() << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); QTest::newRow( "closed ring 1.0 initial lag 3.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 3.5 << 0 - << ( QVector< QPointF >() << QPointF( 1.5, 0 ) << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) - << QPointF( 1.5, 0 ) << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 3.5 << 0 + << ( QVector() << QPointF( 1.5, 0 ) << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) << QPointF( 0.5, 2 ) << QPointF( 1.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 2, 0.5 ) + << QPointF( 1.5, 0 ) << QPointF( 0.5, 0 ) << QPointF( 0, 0.5 ) << QPointF( 0, 1.5 ) ); QTest::newRow( "closed ring 1.0 initial lag 4.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 4.0 << 0 - << ( QVector< QPointF >() << QPointF( 2, 0 ) << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 4.0 << 0 + << ( QVector() << QPointF( 2, 0 ) << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); QTest::newRow( "closed ring 1.0 initial lag 5.0" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 1.0 << 0.0 << 5.0 << 0 - << ( QVector< QPointF >() << QPointF( 2, 1 ) << QPointF( 2, 0 ) << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) - << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 1.0 << 0.0 << 5.0 << 0 + << ( QVector() << QPointF( 2, 1 ) << QPointF( 2, 0 ) << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) << QPointF( 1, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 1 ) << QPointF( 2, 0 ) + << QPointF( 1, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 1 ) << QPointF( 0, 2 ) ); QTest::newRow( "simulate initial offset 0.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) - << 2.0 << 1.5 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0.5, 2 ) << QPointF( 2, 1.5 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) + << 2.0 << 1.5 << 0.0 << 0 + << ( QVector() << QPointF( 0.5, 2 ) << QPointF( 2, 1.5 ) ); QTest::newRow( "simulate initial offset 0.5 lag 0.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) - << 2.0 << 2.0 - ( 0.5 - 0.5 ) << 0.5 - 0.5 << 0 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) + << 2.0 << 2.0 - ( 0.5 - 0.5 ) << 0.5 - 0.5 << 0 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ); QTest::newRow( "simulate initial offset 0.5 lag 0.1" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) - << 2.0 << 2.0 - ( 0.5 - 0.1 ) << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0.4, 2 ) << QPointF( 2, 1.6 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) + << 2.0 << 2.0 - ( 0.5 - 0.1 ) << 0.0 << 0 + << ( QVector() << QPointF( 0.4, 2 ) << QPointF( 2, 1.6 ) ); QTest::newRow( "simulate initial offset 0.1 lag 0.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) - << 2.0 << 0.0 << 0.5 - 0.1 << 0 - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 1.6, 2.0 ) << QPointF( 2.0, 0.4 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) + << 2.0 << 0.0 << 0.5 - 0.1 << 0 + << ( QVector() << QPointF( 0, 2 ) << QPointF( 1.6, 2.0 ) << QPointF( 2.0, 0.4 ) ); QTest::newRow( "simulate initial offset 0.5 lag -0.1" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) - << 2.0 << 2.0 - 0.5 - 0.1 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0.6, 2 ) << QPointF( 2, 1.4 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) + << 2.0 << 2.0 - 0.5 - 0.1 << 0.0 << 0 + << ( QVector() << QPointF( 0.6, 2 ) << QPointF( 2, 1.4 ) ); QTest::newRow( "simulate initial offset 0.1 lag -0.5" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) - << 2.0 << 2.0 - 0.1 - 0.5 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0.6, 2 ) << QPointF( 2.0, 1.4 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) ) + << 2.0 << 2.0 - 0.1 - 0.5 << 0.0 << 0 + << ( QVector() << QPointF( 0.6, 2 ) << QPointF( 2.0, 1.4 ) ); QTest::newRow( "simulate initial offset 0.5 closed" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 2.0 << 1.5 << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 1.5, 0 ) << QPointF( 0.0, 0.5 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 2.0 << 1.5 << 0.0 << 0 + << ( QVector() << QPointF( 0.5, 2 ) << QPointF( 2, 1.5 ) << QPointF( 1.5, 0 ) << QPointF( 0.0, 0.5 ) ); QTest::newRow( "simulate initial offset 0.5 lag 0.1 closed" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 2.0 << 2.0 - ( 0.5 - 0.1 ) << 0.0 << 0 - << ( QVector< QPointF >() << QPointF( 0.4, 2 ) << QPointF( 2, 1.6 ) << QPointF( 1.6, 0 ) << QPointF( 0, 0.4 ) ); + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 2.0 << 2.0 - ( 0.5 - 0.1 ) << 0.0 << 0 + << ( QVector() << QPointF( 0.4, 2 ) << QPointF( 2, 1.6 ) << QPointF( 1.6, 0 ) << QPointF( 0, 0.4 ) ); QTest::newRow( "simulate initial offset 0.1 lag 0.5 closed" ) - << ( QVector< QPointF >() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) - << 2.0 << 0.0 << 0.5 - 0.1 << 0 - << ( QVector< QPointF >() << QPointF( 0, 1.6 ) << QPointF( 1.6, 2 ) << QPointF( 2.0, 0.4 ) << QPointF( 0.4, 0.0 ) << QPointF( 0.0, 1.6 ) ); - + << ( QVector() << QPointF( 0, 2 ) << QPointF( 2, 2 ) << QPointF( 2, 0 ) << QPointF( 0, 0 ) << QPointF( 0, 2 ) ) + << 2.0 << 0.0 << 0.5 - 0.1 << 0 + << ( QVector() << QPointF( 0, 1.6 ) << QPointF( 1.6, 2 ) << QPointF( 2.0, 0.4 ) << QPointF( 0.4, 0.0 ) << QPointF( 0.0, 1.6 ) ); } void TestQgsMarkerLineSymbol::collectPoints() { - QFETCH( QVector< QPointF >, input ); + QFETCH( QVector, input ); QFETCH( double, interval ); QFETCH( double, initialOffset ); QFETCH( double, initialLag ); QFETCH( int, numberPointsRequired ); - QFETCH( QVector< QPointF >, expected ); + QFETCH( QVector, expected ); - QVector dest; + QVector dest; QgsTemplatedLineSymbolLayerBase::collectOffsetPoints( input, dest, interval, initialOffset, initialLag, numberPointsRequired ); QCOMPARE( dest, expected ); } diff --git a/tests/src/core/testqgsmatrix4x4.cpp b/tests/src/core/testqgsmatrix4x4.cpp index 96eb92d842f6..84f3b25a7bd5 100644 --- a/tests/src/core/testqgsmatrix4x4.cpp +++ b/tests/src/core/testqgsmatrix4x4.cpp @@ -27,8 +27,8 @@ class TestQgsMatrix4x4 : public QObject TestQgsMatrix4x4() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testData(); void testIdentity(); @@ -51,10 +51,7 @@ void TestQgsMatrix4x4::cleanupTestCase() void TestQgsMatrix4x4::testData() { // Initialization - row-major order - QgsMatrix4x4 m1( 10., 20., 30., 40., - 50., 60., 70., 80., - 90., 100., 110., 120., - 130., 140., 150., 160. ); + QgsMatrix4x4 m1( 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160. ); // Access through data() / constData() - column-major order const double *m1data = m1.constData(); @@ -109,11 +106,8 @@ void TestQgsMatrix4x4::testIdentity() void TestQgsMatrix4x4::testVectorMultiply() { - double sa = 0.5, ca = sqrt( 3. ) / 2.; // sin(30 deg) and cos(30 deg) - QgsMatrix4x4 m( ca, -sa, 0., 0., - sa, ca, 0., 0., - 0., 0., 1., 0., - 0., 0., 0., 1. ); // CCW rotation around Z axis + double sa = 0.5, ca = sqrt( 3. ) / 2.; // sin(30 deg) and cos(30 deg) + QgsMatrix4x4 m( ca, -sa, 0., 0., sa, ca, 0., 0., 0., 0., 1., 0., 0., 0., 0., 1. ); // CCW rotation around Z axis QgsVector3D v1( 5., 0., 1. ); QgsVector3D v1rot = m.map( v1 ); @@ -128,10 +122,7 @@ void TestQgsMatrix4x4::testVectorMultiply() QCOMPARE( v2rot.z(), 1. ); // translation by a large vector - QgsMatrix4x4 mTr( 1., 0., 0., 123456789., - 0., 1., 0., 234567890., - 0., 0., 1., 345678901., - 0., 0., 0., 1. ); + QgsMatrix4x4 mTr( 1., 0., 0., 123456789., 0., 1., 0., 234567890., 0., 0., 1., 345678901., 0., 0., 0., 1. ); QgsVector3D v1tr = mTr.map( v1 ); QCOMPARE( v1tr.x(), 123456794. ); @@ -141,15 +132,9 @@ void TestQgsMatrix4x4::testVectorMultiply() void TestQgsMatrix4x4::testMatrixMultiply() { - QgsMatrix4x4 mTr( 1., 0., 0., 123456789., - 0., 1., 0., 234567890., - 0., 0., 1., 345678901., - 0., 0., 0., 1. ); - - QgsMatrix4x4 mTr2( 1., 0., 0., -123456790., - 0., 1., 0., -234567892., - 0., 0., 1., -345678904., - 0., 0., 0., 1. ); + QgsMatrix4x4 mTr( 1., 0., 0., 123456789., 0., 1., 0., 234567890., 0., 0., 1., 345678901., 0., 0., 0., 1. ); + + QgsMatrix4x4 mTr2( 1., 0., 0., -123456790., 0., 1., 0., -234567892., 0., 0., 1., -345678904., 0., 0., 0., 1. ); QgsMatrix4x4 m = mTr * mTr2; const double *mdata = m.constData(); diff --git a/tests/src/core/testqgsmesh3daveraging.cpp b/tests/src/core/testqgsmesh3daveraging.cpp index 7564b1bc4bc8..4313458841cb 100644 --- a/tests/src/core/testqgsmesh3daveraging.cpp +++ b/tests/src/core/testqgsmesh3daveraging.cpp @@ -29,14 +29,14 @@ * \ingroup UnitTests * This is a unit test for the QgsMesh3dAveragingMethod derived classes */ -class TestQgsMesh3dAveraging: public QObject +class TestQgsMesh3dAveraging : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testMeshSingleLevelFromTopAveragingMethod_data(); void testMeshSingleLevelFromTopAveragingMethod(); @@ -111,16 +111,12 @@ void TestQgsMesh3dAveraging::initTestCase() const QVector faceToVolumeIndex = { 0, 4 }; // so intervals are { 1, 0.5, 1.5, 1 } - const QVector verticalLevels = { -1.0, -2.0, -2.5, -4.0, -5.0, - -1.0, -2.0, -2.5, -4.0, -5.0 - }; + const QVector verticalLevels = { -1.0, -2.0, -2.5, -4.0, -5.0, -1.0, -2.0, -2.5, -4.0, -5.0 }; const QVector verticalLevelsCount = { 4, 4 }; scalarBlock = QgsMesh3DDataBlock( 2, false ); - const QVector values = { 1, 2, std::numeric_limits::quiet_NaN(), 4, - 1, 2, std::numeric_limits::quiet_NaN(), 4 - }; + const QVector values = { 1, 2, std::numeric_limits::quiet_NaN(), 4, 1, 2, std::numeric_limits::quiet_NaN(), 4 }; scalarBlock.setFaceToVolumeIndex( faceToVolumeIndex ); scalarBlock.setVerticalLevelsCount( verticalLevelsCount ); @@ -129,9 +125,7 @@ void TestQgsMesh3dAveraging::initTestCase() scalarBlock.setValid( true ); vectorBlock = QgsMesh3DDataBlock( 2, true ); - const QVector valuesVec = { 1, 1, 2, 2, std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), 4, 4, - 1, 1, 2, 2, std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), 4, 4 - }; + const QVector valuesVec = { 1, 1, 2, 2, std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), 4, 4, 1, 1, 2, 2, std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN(), 4, 4 }; vectorBlock.setFaceToVolumeIndex( faceToVolumeIndex ); vectorBlock.setVerticalLevelsCount( verticalLevelsCount ); vectorBlock.setVerticalLevels( verticalLevels ); @@ -148,7 +142,7 @@ void TestQgsMesh3dAveraging::testMeshSingleLevelFromTopAveragingMethod_data() QTest::addColumn( "level" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << -111 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << -111 << std::numeric_limits::quiet_NaN(); QTest::newRow( "top" ) << 1 << 1.0; QTest::newRow( "2" ) << 2 << 2.0; QTest::newRow( "3" ) << 3 << std::numeric_limits::quiet_NaN(); @@ -165,23 +159,18 @@ void TestQgsMesh3dAveraging::testMeshSingleLevelFromTopAveragingMethod() compare( &method, expected, level >= 1 ); // Same test but with some vertical height equal to 0 - QVector verticalLevels = { -1.0, -2.0, -4.0, -4.0, -5.0, - -2.0, -2.0, -2.5, -4.0, -5.0 - }; + QVector verticalLevels = { -1.0, -2.0, -4.0, -4.0, -5.0, -2.0, -2.0, -2.5, -4.0, -5.0 }; scalarBlock.setVerticalLevels( verticalLevels ); vectorBlock.setVerticalLevels( verticalLevels ); compare( &method, expected, level >= 1 ); - verticalLevels = { -1.0, -2.0, -2.5, -4.0, -5.0, - -1.0, -2.0, -2.5, -4.0, -5.0 - }; + verticalLevels = { -1.0, -2.0, -2.5, -4.0, -5.0, -1.0, -2.0, -2.5, -4.0, -5.0 }; // Reset vertical levels scalarBlock.setVerticalLevels( verticalLevels ); vectorBlock.setVerticalLevels( verticalLevels ); - } void TestQgsMesh3dAveraging::testMeshSingleLevelFromBottomAveragingMethod_data() @@ -189,7 +178,7 @@ void TestQgsMesh3dAveraging::testMeshSingleLevelFromBottomAveragingMethod_data() QTest::addColumn( "level" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << -111 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << -111 << std::numeric_limits::quiet_NaN(); QTest::newRow( "bottom" ) << 1 << 4.0; QTest::newRow( "2" ) << 2 << std::numeric_limits::quiet_NaN(); QTest::newRow( "3" ) << 3 << 2.0; @@ -206,18 +195,14 @@ void TestQgsMesh3dAveraging::testMeshSingleLevelFromBottomAveragingMethod() compare( &method, expected, level >= 1 ); // Same test but with some vertical height equal to 0 - QVector verticalLevels = { -1.0, -2.0, -4.0, -4.0, -5.0, - -2.0, -2.0, -2.5, -4.0, -5.0 - }; + QVector verticalLevels = { -1.0, -2.0, -4.0, -4.0, -5.0, -2.0, -2.0, -2.5, -4.0, -5.0 }; scalarBlock.setVerticalLevels( verticalLevels ); vectorBlock.setVerticalLevels( verticalLevels ); compare( &method, expected, level >= 1 ); - verticalLevels = { -1.0, -2.0, -2.5, -4.0, -5.0, - -1.0, -2.0, -2.5, -4.0, -5.0 - }; + verticalLevels = { -1.0, -2.0, -2.5, -4.0, -5.0, -1.0, -2.0, -2.5, -4.0, -5.0 }; // Reset vertical levels scalarBlock.setVerticalLevels( verticalLevels ); @@ -230,15 +215,15 @@ void TestQgsMesh3dAveraging::testMeshMultiLevelsFromTopAveragingMethod_data() QTest::addColumn( "endLevel" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << -111 << -111 << std::numeric_limits::quiet_NaN() ; - QTest::newRow( "invalid2" ) << 1 << -111 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << -111 << -111 << std::numeric_limits::quiet_NaN(); + QTest::newRow( "invalid2" ) << 1 << -111 << std::numeric_limits::quiet_NaN(); QTest::newRow( "single level" ) << 1 << 1 << 1.0; - QTest::newRow( "1to2" ) << 1 << 2 << ( 1.0 * 1.0 + 2.0 * 0.5 ) / 1.5 ; - QTest::newRow( "1to3" ) << 1 << 3 << ( 1.0 * 1.0 + 2.0 * 0.5 ) / 1.5 ; - QTest::newRow( "2to4" ) << 2 << 4 << ( 2.0 * 0.5 + 4.0 * 1.0 ) / 1.5 ; + QTest::newRow( "1to2" ) << 1 << 2 << ( 1.0 * 1.0 + 2.0 * 0.5 ) / 1.5; + QTest::newRow( "1to3" ) << 1 << 3 << ( 1.0 * 1.0 + 2.0 * 0.5 ) / 1.5; + QTest::newRow( "2to4" ) << 2 << 4 << ( 2.0 * 0.5 + 4.0 * 1.0 ) / 1.5; QTest::newRow( "outside" ) << 100 << 111 << std::numeric_limits::quiet_NaN(); - QTest::newRow( "outside2" ) << 1 << 111 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5 ; - QTest::newRow( "reverted" ) << 111 << 1 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5 ; + QTest::newRow( "outside2" ) << 1 << 111 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; + QTest::newRow( "reverted" ) << 111 << 1 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; } void TestQgsMesh3dAveraging::testMeshMultiLevelsFromTopAveragingMethod() @@ -257,15 +242,15 @@ void TestQgsMesh3dAveraging::testMeshMultiLevelsFromBottomAveragingMethod_data() QTest::addColumn( "endLevel" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << -111 << -111 << std::numeric_limits::quiet_NaN() ; - QTest::newRow( "invalid2" ) << 1 << -111 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << -111 << -111 << std::numeric_limits::quiet_NaN(); + QTest::newRow( "invalid2" ) << 1 << -111 << std::numeric_limits::quiet_NaN(); QTest::newRow( "single level" ) << 1 << 1 << 4.0; QTest::newRow( "1to2" ) << 1 << 2 << 4.0; - QTest::newRow( "1to3" ) << 1 << 3 << ( 4.0 * 1.0 + 2.0 * 0.5 ) / 1.5 ; - QTest::newRow( "2to4" ) << 2 << 4 << ( 2.0 * 0.5 + 1.0 * 1.0 ) / 1.5 ; + QTest::newRow( "1to3" ) << 1 << 3 << ( 4.0 * 1.0 + 2.0 * 0.5 ) / 1.5; + QTest::newRow( "2to4" ) << 2 << 4 << ( 2.0 * 0.5 + 1.0 * 1.0 ) / 1.5; QTest::newRow( "outside" ) << 100 << 111 << std::numeric_limits::quiet_NaN(); - QTest::newRow( "outside2" ) << 1 << 111 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5 ; - QTest::newRow( "reverted" ) << 111 << 1 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5 ; + QTest::newRow( "outside2" ) << 1 << 111 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; + QTest::newRow( "reverted" ) << 111 << 1 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; } void TestQgsMesh3dAveraging::testMeshMultiLevelsFromBottomAveragingMethod() @@ -284,9 +269,9 @@ void TestQgsMesh3dAveraging::testMeshSigmaAveragingMethod_data() QTest::addColumn( "endParam" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << -1.0 << -111.0 << std::numeric_limits::quiet_NaN() ; - QTest::newRow( "invalid2" ) << 1.1 << 111.0 << std::numeric_limits::quiet_NaN() ; - QTest::newRow( "invalid3" ) << -1.0 << 111.0 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << -1.0 << -111.0 << std::numeric_limits::quiet_NaN(); + QTest::newRow( "invalid2" ) << 1.1 << 111.0 << std::numeric_limits::quiet_NaN(); + QTest::newRow( "invalid3" ) << -1.0 << 111.0 << std::numeric_limits::quiet_NaN(); QTest::newRow( "full" ) << 0.0 << 1.0 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; } @@ -306,7 +291,7 @@ void TestQgsMesh3dAveraging::testMeshDepthAveragingMethod_data() QTest::addColumn( "endParam" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << -1.0 << -111.0 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << -1.0 << -111.0 << std::numeric_limits::quiet_NaN(); QTest::newRow( "1to2" ) << 0.0 << 1.5 << ( 1.0 * 1.0 + 2.0 * 0.5 ) / 1.5; QTest::newRow( "25to45" ) << 1.25 << 3.5 << ( 2.0 * 0.25 + 4.0 * 0.5 ) / 0.75; QTest::newRow( "full" ) << 0.0 << 10.0 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; @@ -328,7 +313,7 @@ void TestQgsMesh3dAveraging::testMeshHeightAveragingMethod_data() QTest::addColumn( "endParam" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << -1.0 << -111.0 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << -1.0 << -111.0 << std::numeric_limits::quiet_NaN(); QTest::newRow( "1to2" ) << 2.5 << 4.0 << ( 1.0 * 1.0 + 2.0 * 0.5 ) / 1.5; QTest::newRow( "25to45" ) << 2.75 << 0.5 << ( 2.0 * 0.25 + 4.0 * 0.5 ) / 0.75; QTest::newRow( "full" ) << 0.0 << 10.0 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; @@ -350,7 +335,7 @@ void TestQgsMesh3dAveraging::testMeshElevationAveragingMethod_data() QTest::addColumn( "endParam" ); QTest::addColumn( "expected" ); - QTest::newRow( "invalid" ) << 1.0 << 111.0 << std::numeric_limits::quiet_NaN() ; + QTest::newRow( "invalid" ) << 1.0 << 111.0 << std::numeric_limits::quiet_NaN(); QTest::newRow( "1to2" ) << -1.0 << -2.5 << ( 1.0 * 1.0 + 2.0 * 0.5 ) / 1.5; QTest::newRow( "25to45" ) << -2.25 << -4.5 << ( 2.0 * 0.25 + 4.0 * 0.5 ) / 0.75; QTest::newRow( "full" ) << 0.0 << -10.0 << ( 1.0 * 1.0 + 2.0 * 0.5 + 4.0 * 1.0 ) / 2.5; @@ -372,18 +357,12 @@ void TestQgsMesh3dAveraging::testMeshElevationAveragingMethodVariableMesh() // each face and also that for face 1 the vertical levels are outside of // requested elevation range const QVector faceToVolumeIndex = { 0, 4, 7 }; - const QVector verticalLevels = { -1.0, -2.0, -3.0, -4.0, -5.0, - -1.0, -1.1, -1.3, -1.5, - -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 - }; + const QVector verticalLevels = { -1.0, -2.0, -3.0, -4.0, -5.0, -1.0, -1.1, -1.3, -1.5, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 }; const QVector verticalLevelsCount = { 4, 3, 5 }; QgsMesh3DDataBlock scalarBlock2( 3, false ); - const QVector values = { 1, 2, 3, 4, - 0, 0, 0, - 100, 200, 300, 400, 500 - }; + const QVector values = { 1, 2, 3, 4, 0, 0, 0, 100, 200, 300, 400, 500 }; scalarBlock2.setFaceToVolumeIndex( faceToVolumeIndex ); scalarBlock2.setVerticalLevelsCount( verticalLevelsCount ); diff --git a/tests/src/core/testqgsmesheditor.cpp b/tests/src/core/testqgsmesheditor.cpp index 62a469509f78..04159a48ba62 100644 --- a/tests/src/core/testqgsmesheditor.cpp +++ b/tests/src/core/testqgsmesheditor.cpp @@ -42,10 +42,10 @@ class TestQgsMeshEditor : public QObject QString mDataDir; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void startStopEditing(); void startEditingWithErrors(); @@ -74,16 +74,16 @@ void TestQgsMeshEditor::initTestCase() QgsApplication::initQgis(); nativeMesh.clear(); - nativeMesh.vertices.append( QgsMeshVertex( 0.0, 0.0, 0.0 ) ); // 0 - nativeMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); // 1 - nativeMesh.vertices.append( QgsMeshVertex( 0.9, 0.9, 0.0 ) ); // 2 - nativeMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); // 3 - nativeMesh.vertices.append( QgsMeshVertex( 1.5, 1.2, 0.0 ) ); // 4 + nativeMesh.vertices.append( QgsMeshVertex( 0.0, 0.0, 0.0 ) ); // 0 + nativeMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); // 1 + nativeMesh.vertices.append( QgsMeshVertex( 0.9, 0.9, 0.0 ) ); // 2 + nativeMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); // 3 + nativeMesh.vertices.append( QgsMeshVertex( 1.5, 1.2, 0.0 ) ); // 4 nativeMesh.vertices.append( QgsMeshVertex( 2.0, -0.2, 0.0 ) ); // 5 - nativeMesh.faces.append( QgsMeshFace( {0, 1, 2, 3} ) ); //clock wise face - nativeMesh.faces.append( QgsMeshFace( {1, 4, 2} ) ); //clock wise face - nativeMesh.faces.append( QgsMeshFace( {3, 4, 2} ) ); //counter clock wise face - nativeMesh.faces.append( QgsMeshFace( {3, 5, 4} ) ); //counter clock wise face + nativeMesh.faces.append( QgsMeshFace( { 0, 1, 2, 3 } ) ); //clock wise face + nativeMesh.faces.append( QgsMeshFace( { 1, 4, 2 } ) ); //clock wise face + nativeMesh.faces.append( QgsMeshFace( { 3, 4, 2 } ) ); //counter clock wise face + nativeMesh.faces.append( QgsMeshFace( { 3, 5, 4 } ) ); //counter clock wise face } void TestQgsMeshEditor::cleanupTestCase() @@ -137,7 +137,7 @@ void TestQgsMeshEditor::startStopEditing() QCOMPARE( mesh.vertex( i ).z(), meshLayerQuadTriangle->datasetValue( QgsMeshDatasetIndex( 0, 0 ), i ).scalar() ); QgsMeshEditor *editor = meshLayerQuadTriangle->meshEditor(); - QCOMPARE( editor->addVertices( {QgsMeshVertex( 1500, 2500, 0 )}, 10 ), 1 ); + QCOMPARE( editor->addVertices( { QgsMeshVertex( 1500, 2500, 0 ) }, 10 ), 1 ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 6 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 5 ); @@ -161,7 +161,7 @@ void TestQgsMeshEditor::startStopEditing() QCOMPARE( meta.minimum(), 10.0 ); QCOMPARE( meta.maximum(), 50.0 ); - QCOMPARE( editor->addVertices( {QgsMeshVertex( 1500, 2500, 0 )}, 10 ), 1 ); + QCOMPARE( editor->addVertices( { QgsMeshVertex( 1500, 2500, 0 ) }, 10 ), 1 ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 6 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 5 ); @@ -259,7 +259,7 @@ static bool checkNeighbors( const QgsTopologicalMesh &mesh, int faceIndex, const bool ret = true; ret &= neighbors.count() == mesh.mesh()->face( faceIndex ).count(); for ( const int exn : expectedNeighbors ) - ret &= neighbors.contains( exn ) ; + ret &= neighbors.contains( exn ); return ret; } @@ -270,7 +270,7 @@ static bool checkFacesAround( const QgsTopologicalMesh &mesh, int vertexIndex, Q bool ret = true; ret &= expectedFace.count() == facesAround.count(); for ( const int exf : expectedFace ) - ret &= facesAround.contains( exf ) ; + ret &= facesAround.contains( exf ); return ret; } @@ -284,23 +284,23 @@ void TestQgsMeshEditor::createTopologicMesh() QVERIFY( error.errorType == Qgis::MeshEditingErrorType::NoError ); // Check if face are counter clock wise - QVERIFY( !QgsMesh::compareFaces( nativeMesh.face( 0 ), QgsMeshFace( {0, 1, 2, 3} ) ) ); - QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 0 ), QgsMeshFace( {3, 2, 1, 0} ) ) ); - QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 1 ), QgsMeshFace( {2, 4, 1} ) ) ); - QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 2 ), QgsMeshFace( {3, 4, 2} ) ) ); - QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 3 ), QgsMeshFace( {5, 4, 3} ) ) ); - - QVERIFY( checkNeighbors( topologicMesh, 0, {-1, 1, 2} ) ); - QVERIFY( checkNeighbors( topologicMesh, 1, {-1, 0, 2} ) ); - QVERIFY( checkNeighbors( topologicMesh, 2, {0, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicMesh, 3, {-1, 2} ) ); - - QVERIFY( checkFacesAround( topologicMesh, 0, {0} ) ); - QVERIFY( checkFacesAround( topologicMesh, 1, {0, 1} ) ); - QVERIFY( checkFacesAround( topologicMesh, 2, {0, 1, 2} ) ); - QVERIFY( checkFacesAround( topologicMesh, 3, {0, 2, 3} ) ); - QVERIFY( checkFacesAround( topologicMesh, 4, {1, 2, 3} ) ); - QVERIFY( checkFacesAround( topologicMesh, 5, {3} ) ); + QVERIFY( !QgsMesh::compareFaces( nativeMesh.face( 0 ), QgsMeshFace( { 0, 1, 2, 3 } ) ) ); + QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 0 ), QgsMeshFace( { 3, 2, 1, 0 } ) ) ); + QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 1 ), QgsMeshFace( { 2, 4, 1 } ) ) ); + QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 2 ), QgsMeshFace( { 3, 4, 2 } ) ) ); + QVERIFY( QgsMesh::compareFaces( nativeMesh.face( 3 ), QgsMeshFace( { 5, 4, 3 } ) ) ); + + QVERIFY( checkNeighbors( topologicMesh, 0, { -1, 1, 2 } ) ); + QVERIFY( checkNeighbors( topologicMesh, 1, { -1, 0, 2 } ) ); + QVERIFY( checkNeighbors( topologicMesh, 2, { 0, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicMesh, 3, { -1, 2 } ) ); + + QVERIFY( checkFacesAround( topologicMesh, 0, { 0 } ) ); + QVERIFY( checkFacesAround( topologicMesh, 1, { 0, 1 } ) ); + QVERIFY( checkFacesAround( topologicMesh, 2, { 0, 1, 2 } ) ); + QVERIFY( checkFacesAround( topologicMesh, 3, { 0, 2, 3 } ) ); + QVERIFY( checkFacesAround( topologicMesh, 4, { 1, 2, 3 } ) ); + QVERIFY( checkFacesAround( topologicMesh, 5, { 3 } ) ); QVERIFY( topologicMesh.checkConsistency() == QgsMeshEditingError() ); @@ -356,14 +356,15 @@ void TestQgsMeshEditor::editTopologicMesh() QVector topologicalChanges; const QVector vertices( - { - {2.5, 1.0, 0}, // 6 - {2.5, 0.0, 0}, // 7 - {2.0, 1.7, 0}, // 8 - { 0.9, 1.8, 0 }, // 9 - {-1, 0.5, 0}, // 10 - {0.9, -0.8, 0} // 11 - } ); + { + { 2.5, 1.0, 0 }, // 6 + { 2.5, 0.0, 0 }, // 7 + { 2.0, 1.7, 0 }, // 8 + { 0.9, 1.8, 0 }, // 9 + { -1, 0.5, 0 }, // 10 + { 0.9, -0.8, 0 } // 11 + } + ); for ( const QgsMeshVertex &vertex : vertices ) topologicalChanges.append( topologicalMesh.addFreeVertex( vertex ) ); @@ -375,68 +376,63 @@ void TestQgsMeshEditor::editTopologicMesh() QgsTopologicalMesh::TopologicalFaces topologicFaces; QVector faces; - faces = {{5, 7, 6}}; + faces = { { 5, 7, 6 } }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); - QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ) == - QgsMeshEditingError( Qgis::MeshEditingErrorType::UniqueSharedVertex, 5 ) ); + QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ) == QgsMeshEditingError( Qgis::MeshEditingErrorType::UniqueSharedVertex, 5 ) ); - faces = {{5, 7, 6, 4}}; + faces = { { 5, 7, 6, 4 } }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ) == QgsMeshEditingError() ); - faces = - { - {5, 7, 6, 4}, // 0 - {6, 8, 4}, // 1 - {1, 4, 9}, // 2 - {10, 1, 9}, // 3 - {0, 1, 10}, // 4 - {11, 3, 0}, // 5 - {11, 5, 3}, // 6 + faces = { + { 5, 7, 6, 4 }, // 0 + { 6, 8, 4 }, // 1 + { 1, 4, 9 }, // 2 + { 10, 1, 9 }, // 3 + { 0, 1, 10 }, // 4 + { 11, 3, 0 }, // 5 + { 11, 5, 3 }, // 6 }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ) == QgsMeshEditingError() ); - faces = - { - {5, 7, 6}, // 0 face that share only one vertex - {6, 8, 4}, // 1 - {1, 4, 9}, // 2 - {10, 1, 9}, // 3 - {0, 1, 10}, // 4 - {11, 3, 0}, // 5 - {11, 5, 3}, // 6 + faces = { + { 5, 7, 6 }, // 0 face that share only one vertex + { 6, 8, 4 }, // 1 + { 1, 4, 9 }, // 2 + { 10, 1, 9 }, // 3 + { 0, 1, 10 }, // 4 + { 11, 3, 0 }, // 5 + { 11, 5, 3 }, // 6 }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); - QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ).errorType == Qgis::MeshEditingErrorType::UniqueSharedVertex ); + QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ).errorType == Qgis::MeshEditingErrorType::UniqueSharedVertex ); QCOMPARE( topologicalMesh.freeVerticesIndexes().count(), 6 ); - faces = - { - {5, 7, 6}, // 0 face that share only one vertex - {6, 8, 4}, // 1 - {1, 4, 9}, // 2 - {10, 1, 9}, // 3 - {0, 1, 10}, // 4 - {11, 3, 0}, // 5 - {11, 5, 3}, // 6 - {5, 6, 4} // face added to fixe the first one + faces = { + { 5, 7, 6 }, // 0 face that share only one vertex + { 6, 8, 4 }, // 1 + { 1, 4, 9 }, // 2 + { 10, 1, 9 }, // 3 + { 0, 1, 10 }, // 4 + { 11, 3, 0 }, // 5 + { 11, 5, 3 }, // 6 + { 5, 6, 4 } // face added to fixe the first one }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ) == QgsMeshEditingError() ); - faces = - { - {3, 5, 7, 6}, // 0 share vertices with same clockwise - {6, 8, 4}, // 1 - {1, 4, 9}, // 2 - {10, 1, 9}, // 3 - {0, 1, 10}, // 4 - {11, 3, 0}, // 5 + faces = { + { 3, 5, 7, 6 }, // 0 share vertices with same clockwise + { 6, 8, 4 }, // 1 + { 1, 4, 9 }, // 2 + { 10, 1, 9 }, // 3 + { 0, 1, 10 }, // 4 + { 11, 3, 0 }, // 5 }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); @@ -444,26 +440,26 @@ void TestQgsMeshEditor::editTopologicMesh() error = topologicalMesh.facesCanBeAdded( topologicFaces ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::ManifoldFace, 0 ) ); - faces = {{5, 7, 6, 4}}; + faces = { { 5, 7, 6, 4 } }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ) == QgsMeshEditingError() ); - topologicalChanges.append( topologicalMesh.addFaces( topologicFaces ) ) ; + topologicalChanges.append( topologicalMesh.addFaces( topologicFaces ) ); QCOMPARE( topologicalMesh.freeVerticesIndexes().count(), 4 ); - QVERIFY( checkNeighbors( topologicalMesh, 0, {-1, 2, 1} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 1, {-1, 0, 2} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 2, {0, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 3, {-1, 2, 4} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 4, {-1, 3} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {0} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {0, 1} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {0, 1, 2} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {0, 2, 3} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 4, {1, 2, 3, 4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 5, {3, 4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 6, {4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 7, {4} ) ); + QVERIFY( checkNeighbors( topologicalMesh, 0, { -1, 2, 1 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 1, { -1, 0, 2 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 2, { 0, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 3, { -1, 2, 4 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 4, { -1, 3 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 0 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 0, 1 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 0, 1, 2 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 0, 2, 3 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 4, { 1, 2, 3, 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 5, { 3, 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 6, { 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 7, { 4 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); QVERIFY( !topologicalMesh.canBeMerged( 4, 5 ) ); @@ -477,168 +473,167 @@ void TestQgsMeshEditor::editTopologicMesh() QVERIFY( !topologicalMesh.canBeMerged( 3, 5 ) ); QVERIFY( !topologicalMesh.canBeMerged( 6, 7 ) ); - faces = - { - {6, 8, 4}, // 1 - {1, 4, 9}, // 2 - {10, 1, 9}, // 3 - {0, 1, 10}, // 4 - {11, 3, 0}, // 5 - {11, 5, 3}, // 6 + faces = { + { 6, 8, 4 }, // 1 + { 1, 4, 9 }, // 2 + { 10, 1, 9 }, // 3 + { 0, 1, 10 }, // 4 + { 11, 3, 0 }, // 5 + { 11, 5, 3 }, // 6 }; topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( faces, true, error ); QVERIFY( topologicalMesh.facesCanBeAdded( topologicFaces ) == QgsMeshEditingError() ); - topologicalChanges.append( topologicalMesh.addFaces( topologicFaces ) ) ; + topologicalChanges.append( topologicalMesh.addFaces( topologicFaces ) ); QCOMPARE( topologicalMesh.freeVerticesIndexes().count(), 0 ); - QVERIFY( checkNeighbors( topologicalMesh, 0, {1, 2, 9, 8} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 1, {0, 2, 6} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 2, {0, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 3, {2, 4, 10} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 4, {-1, 3, 5} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 5, {-1, 4} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 6, {-1, 1, 7} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 7, {-1, 6, 8} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 8, {-1, 0, 7} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 9, {-1, 0, 10} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 10, {-1, 3, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {0, 8, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {0, 1, 6, 7, 8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {1, 2, 0} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {0, 2, 3, 10, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 4, {1, 2, 3, 4, 5, 6} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 5, {4, 3, 10} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 6, {4, 5} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 7, {4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 8, {5} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 9, {6, 7} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 10, {7, 8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 11, {9, 10} ) ); + QVERIFY( checkNeighbors( topologicalMesh, 0, { 1, 2, 9, 8 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 1, { 0, 2, 6 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 2, { 0, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 3, { 2, 4, 10 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 4, { -1, 3, 5 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 5, { -1, 4 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 6, { -1, 1, 7 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 7, { -1, 6, 8 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 8, { -1, 0, 7 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 9, { -1, 0, 10 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 10, { -1, 3, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 0, 8, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 0, 1, 6, 7, 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 1, 2, 0 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 0, 2, 3, 10, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 4, { 1, 2, 3, 4, 5, 6 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 5, { 4, 3, 10 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 6, { 4, 5 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 7, { 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 8, { 5 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 9, { 6, 7 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 10, { 7, 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 11, { 9, 10 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); topologicalMesh.reverseChanges( topologicalChanges.last() ); QCOMPARE( topologicalMesh.freeVerticesIndexes().count(), 4 ); - QVERIFY( checkNeighbors( topologicalMesh, 0, {-1, 2, 1} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 1, {-1, 0, 2} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 2, {0, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 3, {-1, 2, 4} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 4, {-1, 3} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {0} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {0, 1} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {0, 1, 2} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {0, 2, 3} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 4, {1, 2, 3, 4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 5, {3, 4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 6, {4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 7, {4} ) ); + QVERIFY( checkNeighbors( topologicalMesh, 0, { -1, 2, 1 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 1, { -1, 0, 2 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 2, { 0, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 3, { -1, 2, 4 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 4, { -1, 3 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 0 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 0, 1 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 0, 1, 2 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 0, 2, 3 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 4, { 1, 2, 3, 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 5, { 3, 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 6, { 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 7, { 4 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); topologicalMesh.applyChanges( topologicalChanges.last() ); QCOMPARE( topologicalMesh.freeVerticesIndexes().count(), 0 ); - QVERIFY( checkNeighbors( topologicalMesh, 0, {1, 2, 9, 8} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 1, {0, 2, 6} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 2, {0, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 3, {2, 4, 10} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 4, {-1, 3, 5} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 5, {-1, 4} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 6, {-1, 1, 7} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 7, {-1, 6, 8} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 8, {-1, 0, 7} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 9, {-1, 0, 10} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 10, {-1, 3, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {0, 8, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {0, 1, 6, 7, 8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {1, 2, 0} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {0, 2, 3, 10, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 4, {1, 2, 3, 4, 5, 6} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 5, {4, 3, 10} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 6, {4, 5} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 7, {4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 8, {5} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 9, {6, 7} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 10, {7, 8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 11, {9, 10} ) ); + QVERIFY( checkNeighbors( topologicalMesh, 0, { 1, 2, 9, 8 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 1, { 0, 2, 6 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 2, { 0, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 3, { 2, 4, 10 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 4, { -1, 3, 5 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 5, { -1, 4 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 6, { -1, 1, 7 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 7, { -1, 6, 8 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 8, { -1, 0, 7 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 9, { -1, 0, 10 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 10, { -1, 3, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 0, 8, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 0, 1, 6, 7, 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 1, 2, 0 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 0, 2, 3, 10, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 4, { 1, 2, 3, 4, 5, 6 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 5, { 4, 3, 10 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 6, { 4, 5 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 7, { 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 8, { 5 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 9, { 6, 7 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 10, { 7, 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 11, { 9, 10 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); QList faceToRemove; - faceToRemove = {2, 3}; + faceToRemove = { 2, 3 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ).errorType == Qgis::MeshEditingErrorType::UniqueSharedVertex ); - faceToRemove = {0, 1, 2, 3}; + faceToRemove = { 0, 1, 2, 3 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ).errorType == Qgis::MeshEditingErrorType::UniqueSharedVertex ); - faceToRemove = {0, 9}; + faceToRemove = { 0, 9 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ) == QgsMeshEditingError() ); - faceToRemove = {8, 0, 9, 10}; + faceToRemove = { 8, 0, 9, 10 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ) == QgsMeshEditingError() ); - faceToRemove = {1, 2, 3, 4, 5}; + faceToRemove = { 1, 2, 3, 4, 5 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ) == QgsMeshEditingError() ); - faceToRemove = {0, 1, 2, 3, 4, 5}; + faceToRemove = { 0, 1, 2, 3, 4, 5 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ).errorType == Qgis::MeshEditingErrorType::UniqueSharedVertex ); - faceToRemove = {9, 0, 1, 2, 3, 4, 5}; + faceToRemove = { 9, 0, 1, 2, 3, 4, 5 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ) == QgsMeshEditingError() ); - faceToRemove = {0, 6, 7, 8}; + faceToRemove = { 0, 6, 7, 8 }; QVERIFY( topologicalMesh.facesCanBeRemoved( faceToRemove ) == QgsMeshEditingError() ); - topologicalChanges.append( topologicalMesh.removeFaces( {0, 9} ) ); - - QVERIFY( checkNeighbors( topologicalMesh, 8, {-1, 7} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 10, {-1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 2, {-1, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 1, {-1, 2, 6} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {1, 6, 7, 8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, { 1, 2} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, { 2, 3, 10} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 11, {10} ) ); + topologicalChanges.append( topologicalMesh.removeFaces( { 0, 9 } ) ); + + QVERIFY( checkNeighbors( topologicalMesh, 8, { -1, 7 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 10, { -1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 2, { -1, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 1, { -1, 2, 6 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 1, 6, 7, 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 1, 2 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 2, 3, 10 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 11, { 10 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); topologicalMesh.reverseChanges( topologicalChanges.last() ); - QVERIFY( checkNeighbors( topologicalMesh, 0, {1, 2, 9, 8} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 1, {0, 2, 6} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 2, {0, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 3, {2, 4, 10} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 4, {-1, 3, 5} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 5, {-1, 4} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 6, {-1, 1, 7} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 7, {-1, 6, 8} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 8, {-1, 0, 7} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 9, {-1, 0, 10} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 10, {-1, 3, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {0, 8, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {0, 1, 6, 7, 8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {1, 2, 0} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {0, 2, 3, 10, 9} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 4, {1, 2, 3, 4, 5, 6} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 5, {4, 3, 10} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 6, {4, 5} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 7, {4} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 8, {5} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 9, {6, 7} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 10, {7, 8} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 11, {9, 10} ) ); + QVERIFY( checkNeighbors( topologicalMesh, 0, { 1, 2, 9, 8 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 1, { 0, 2, 6 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 2, { 0, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 3, { 2, 4, 10 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 4, { -1, 3, 5 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 5, { -1, 4 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 6, { -1, 1, 7 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 7, { -1, 6, 8 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 8, { -1, 0, 7 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 9, { -1, 0, 10 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 10, { -1, 3, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 0, 8, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 0, 1, 6, 7, 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 1, 2, 0 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 0, 2, 3, 10, 9 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 4, { 1, 2, 3, 4, 5, 6 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 5, { 4, 3, 10 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 6, { 4, 5 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 7, { 4 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 8, { 5 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 9, { 6, 7 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 10, { 7, 8 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 11, { 9, 10 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); topologicalMesh.applyChanges( topologicalChanges.last() ); - topologicalChanges.append( topologicalMesh.addVertexInFace( 4, {2.2, 0.5, 0} ) ); // vertex 12 + topologicalChanges.append( topologicalMesh.addVertexInFace( 4, { 2.2, 0.5, 0 } ) ); // vertex 12 - QVERIFY( checkFacesAround( topologicalMesh, 12, {11, 12, 13, 14} ) ); + QVERIFY( checkFacesAround( topologicalMesh, 12, { 11, 12, 13, 14 } ) ); - topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( {{4, 8, 9}, {0, 3, 2, 1}}, true, error ); + topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( { { 4, 8, 9 }, { 0, 3, 2, 1 } }, true, error ); QVERIFY( error == QgsMeshEditingError() ); topologicalChanges.append( topologicalMesh.addFaces( topologicFaces ) ); - QVERIFY( checkFacesAround( topologicalMesh, 9, {7, 6, 15} ) ); + QVERIFY( checkFacesAround( topologicalMesh, 9, { 7, 6, 15 } ) ); topologicalChanges.append( topologicalMesh.removeVertexFillHole( 4 ) ); @@ -647,35 +642,35 @@ void TestQgsMeshEditor::editTopologicMesh() QVERIFY( topologicalMesh.edgeCanBeFlipped( 2, 12 ) ); topologicalChanges.append( topologicalMesh.flipEdge( 2, 12 ) ); - QVERIFY( checkFacesAround( topologicalMesh, 12, {11, 12, 20, 22, 24} ) ); + QVERIFY( checkFacesAround( topologicalMesh, 12, { 11, 12, 20, 22, 24 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); QVERIFY( topologicalMesh.canBeMerged( 3, 8 ) ); topologicalChanges.append( topologicalMesh.merge( 3, 8 ) ); - QVERIFY( checkFacesAround( topologicalMesh, 12, {11, 12, 20, 22, 25} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 8, {18, 20, 25} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {16, 17, 18, 25} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {16, 25, 22, 10} ) ); + QVERIFY( checkFacesAround( topologicalMesh, 12, { 11, 12, 20, 22, 25 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 8, { 18, 20, 25 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 16, 17, 18, 25 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 16, 25, 22, 10 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); QVERIFY( topologicalMesh.canBeSplit( 25 ) ); topologicalChanges.append( topologicalMesh.splitFace( 25 ) ); - QVERIFY( checkFacesAround( topologicalMesh, 12, {11, 12, 20, 22, 26, 27} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 8, {18, 20, 27} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {16, 17, 18, 27, 26} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {16, 26, 22, 10} ) ); + QVERIFY( checkFacesAround( topologicalMesh, 12, { 11, 12, 20, 22, 26, 27 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 8, { 18, 20, 27 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 16, 17, 18, 27, 26 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 16, 26, 22, 10 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); topologicalChanges.append( topologicalMesh.insertVertexInFacesEdge( 17, 0, QgsMeshVertex( 0.44, 0.94, 0.0 ) ) ); - QVERIFY( checkFacesAround( topologicalMesh, 13, {28, 29, 30, 31, 32} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {8, 30, 31} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {7, 8, 28, 30} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {18, 27, 26, 29, 32} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {10, 22, 26, 32, 31} ) ); + QVERIFY( checkFacesAround( topologicalMesh, 13, { 28, 29, 30, 31, 32 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 8, 30, 31 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 7, 8, 28, 30 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 18, 27, 26, 29, 32 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 10, 22, 26, 32, 31 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); topologicalChanges.append( topologicalMesh.insertVertexInFacesEdge( 8, 2, QgsMeshVertex( -0.5, 0.25, 0.0 ) ) ); - QVERIFY( checkFacesAround( topologicalMesh, 14, {33, 34} ) ); + QVERIFY( checkFacesAround( topologicalMesh, 14, { 33, 34 } ) ); QVERIFY( topologicalMesh.checkConsistency() == QgsMeshEditingError() ); // reverse all!!! @@ -683,16 +678,16 @@ void TestQgsMeshEditor::editTopologicMesh() topologicalMesh.reverseChanges( topologicalChanges.at( topologicalChanges.count() - i - 1 ) ); QCOMPARE( topologicalMesh.freeVerticesIndexes().count(), 0 ); - QVERIFY( checkNeighbors( topologicalMesh, 0, {-1, 1, 2} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 1, {-1, 0, 2} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 2, {0, 1, 3} ) ); - QVERIFY( checkNeighbors( topologicalMesh, 3, {-1, 2} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 0, {0} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 1, {0, 1} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 2, {0, 2, 1} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 3, {0, 2, 3} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 4, {1, 2, 3} ) ); - QVERIFY( checkFacesAround( topologicalMesh, 5, {3} ) ); + QVERIFY( checkNeighbors( topologicalMesh, 0, { -1, 1, 2 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 1, { -1, 0, 2 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 2, { 0, 1, 3 } ) ); + QVERIFY( checkNeighbors( topologicalMesh, 3, { -1, 2 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 0, { 0 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 1, { 0, 1 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 2, { 0, 2, 1 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 3, { 0, 2, 3 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 4, { 1, 2, 3 } ) ); + QVERIFY( checkFacesAround( topologicalMesh, 5, { 3 } ) ); QCOMPARE( topologicalMesh.mesh()->faceCount(), 4 ); QCOMPARE( topologicalMesh.mesh()->vertexCount(), 6 ); @@ -726,7 +721,7 @@ void TestQgsMeshEditor::badTopologicMesh() badMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 0.2, 0.2, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); - badMesh.faces.append( QgsMeshFace( {0, 1, 2, 3} ) ); + badMesh.faces.append( QgsMeshFace( { 0, 1, 2, 3 } ) ); QgsMeshEditingError error; QgsTopologicalMesh topologicalMesh = QgsTopologicalMesh::createTopologicalMesh( &badMesh, 4, error ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::InvalidVertex, 0 ) ); @@ -737,7 +732,7 @@ void TestQgsMeshEditor::badTopologicMesh() badMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 0.2, 0.2, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); - badMesh.faces.append( QgsMeshFace( {0, 1, 2, 5} ) ); + badMesh.faces.append( QgsMeshFace( { 0, 1, 2, 5 } ) ); topologicalMesh = QgsTopologicalMesh::createTopologicalMesh( &badMesh, 4, error ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::InvalidVertex, 5 ) ); @@ -748,7 +743,7 @@ void TestQgsMeshEditor::badTopologicMesh() badMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 0.2, 0.2, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); - badMesh.faces.append( QgsMeshFace( {0, 1, 2, 3} ) ); //concave face + badMesh.faces.append( QgsMeshFace( { 0, 1, 2, 3 } ) ); //concave face topologicalMesh = QgsTopologicalMesh::createTopologicalMesh( &badMesh, 4, error ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::InvalidFace, 0 ) ); @@ -758,7 +753,7 @@ void TestQgsMeshEditor::badTopologicMesh() badMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 0.9, 0.9, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); - badMesh.faces.append( QgsMeshFace( {0, 2, 1, 3} ) ); //bad ordering of faces + badMesh.faces.append( QgsMeshFace( { 0, 2, 1, 3 } ) ); //bad ordering of faces topologicalMesh = QgsTopologicalMesh::createTopologicalMesh( &badMesh, 4, error ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::InvalidFace, 0 ) ); @@ -768,7 +763,7 @@ void TestQgsMeshEditor::badTopologicMesh() badMesh.vertices.append( QgsMeshVertex( -1.0, 0.0, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 0.9, 0.9, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); - badMesh.faces.append( QgsMeshFace( {0, 2, 1, 3} ) ); + badMesh.faces.append( QgsMeshFace( { 0, 2, 1, 3 } ) ); topologicalMesh = QgsTopologicalMesh::createTopologicalMesh( &badMesh, 4, error ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::FlatFace, 0 ) ); @@ -778,23 +773,23 @@ void TestQgsMeshEditor::badTopologicMesh() badMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 0.9, 0.9, 0.0 ) ); badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); - badMesh.faces.append( QgsMeshFace( {0, 1, 2, 3} ) ); + badMesh.faces.append( QgsMeshFace( { 0, 1, 2, 3 } ) ); topologicalMesh = QgsTopologicalMesh::createTopologicalMesh( &badMesh, 3, error ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::InvalidFace, 0 ) ); // Sharing only one vertex badMesh.clear(); - badMesh.vertices.append( QgsMeshVertex( 0.0, 0.0, 0.0 ) ); // 0 - badMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); // 1 - badMesh.vertices.append( QgsMeshVertex( 0.9, 0.9, 0.0 ) ); // 2 - badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); // 3 - badMesh.vertices.append( QgsMeshVertex( 1.5, 1.2, 0.0 ) ); // 4 + badMesh.vertices.append( QgsMeshVertex( 0.0, 0.0, 0.0 ) ); // 0 + badMesh.vertices.append( QgsMeshVertex( 0.0, 1.0, 0.0 ) ); // 1 + badMesh.vertices.append( QgsMeshVertex( 0.9, 0.9, 0.0 ) ); // 2 + badMesh.vertices.append( QgsMeshVertex( 1.0, 0.0, 0.0 ) ); // 3 + badMesh.vertices.append( QgsMeshVertex( 1.5, 1.2, 0.0 ) ); // 4 badMesh.vertices.append( QgsMeshVertex( 2.0, -0.2, 0.0 ) ); // 5 - badMesh.vertices.append( QgsMeshVertex( 2.5, 1.3, 0.0 ) ); // 6 - badMesh.faces.append( QgsMeshFace( {0, 1, 2, 3} ) ); //clock wise face - badMesh.faces.append( QgsMeshFace( {1, 4, 2} ) ); //clock wise face - badMesh.faces.append( QgsMeshFace( {3, 4, 2} ) ); //counter clock wise face - badMesh.faces.append( QgsMeshFace( {4, 5, 6} ) ); // isolated face linked by ony one vertices + badMesh.vertices.append( QgsMeshVertex( 2.5, 1.3, 0.0 ) ); // 6 + badMesh.faces.append( QgsMeshFace( { 0, 1, 2, 3 } ) ); //clock wise face + badMesh.faces.append( QgsMeshFace( { 1, 4, 2 } ) ); //clock wise face + badMesh.faces.append( QgsMeshFace( { 3, 4, 2 } ) ); //counter clock wise face + badMesh.faces.append( QgsMeshFace( { 4, 5, 6 } ) ); // isolated face linked by ony one vertices topologicalMesh = QgsTopologicalMesh::createTopologicalMesh( &badMesh, 4, error ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::UniqueSharedVertex, 4 ) ); } @@ -814,11 +809,11 @@ void TestQgsMeshEditor::meshEditorSimpleEdition() QgsMeshEditor meshEditor( &mesh, &triangularMesh ); QCOMPARE( meshEditor.initialize(), QgsMeshEditingError() ); - const QVector vertices( {QgsPoint( 0.0, 0.0, 0.0 ), // 0 - QgsPoint( 0.0, 1.0, 0.0 ), // 1 - QgsPoint( 0.9, 0.9, 0.0 ), // 2 - QgsPoint( 1.0, 0.0, 0.0 ), // 3 - QgsPoint( )} ); // 4 + const QVector vertices( { QgsPoint( 0.0, 0.0, 0.0 ), // 0 + QgsPoint( 0.0, 1.0, 0.0 ), // 1 + QgsPoint( 0.9, 0.9, 0.0 ), // 2 + QgsPoint( 1.0, 0.0, 0.0 ), // 3 + QgsPoint() } ); // 4 meshEditor.addVertices( vertices, 0.01 ); @@ -826,12 +821,12 @@ void TestQgsMeshEditor::meshEditorSimpleEdition() QCOMPARE( meshEditor.mTopologicalMesh.facesAroundVertex( i ), QList() ); // add bad face - QVERIFY( meshEditor.addFaces( {{0, 1, 3, 2}} ).errorType == Qgis::MeshEditingErrorType::InvalidFace ); //unordered vertex index - QVERIFY( meshEditor.addFaces( {{0, 1, 2, 100}} ).errorType == Qgis::MeshEditingErrorType::InvalidVertex ); //out of range vertex index - QVERIFY( meshEditor.addFaces( {{0, 1, 2, 4}} ).errorType == Qgis::MeshEditingErrorType::InvalidVertex ); // empty vertex + QVERIFY( meshEditor.addFaces( { { 0, 1, 3, 2 } } ).errorType == Qgis::MeshEditingErrorType::InvalidFace ); //unordered vertex index + QVERIFY( meshEditor.addFaces( { { 0, 1, 2, 100 } } ).errorType == Qgis::MeshEditingErrorType::InvalidVertex ); //out of range vertex index + QVERIFY( meshEditor.addFaces( { { 0, 1, 2, 4 } } ).errorType == Qgis::MeshEditingErrorType::InvalidVertex ); // empty vertex -// add good face - QVERIFY( meshEditor.addFaces( {{0, 1, 2, 3}} ).errorType == Qgis::MeshEditingErrorType::NoError ); + // add good face + QVERIFY( meshEditor.addFaces( { { 0, 1, 2, 3 } } ).errorType == Qgis::MeshEditingErrorType::NoError ); QCOMPARE( triangularMesh.vertices().count(), 4 ); QCOMPARE( triangularMesh.faceCentroids().count(), 1 ); @@ -841,9 +836,9 @@ void TestQgsMeshEditor::meshEditorSimpleEdition() QCOMPARE( triangularMesh.faceIndexForPoint_v2( QgsPointXY( 1, 0.5 ) ), -1 ); QVERIFY( meshEditor.checkConsistency( error ) ); - QCOMPARE( meshEditor.mTopologicalMesh.neighborsOfFace( 0 ), QVector( {-1, -1, -1, -1} ) ); + QCOMPARE( meshEditor.mTopologicalMesh.neighborsOfFace( 0 ), QVector( { -1, -1, -1, -1 } ) ); for ( int i = 0; i < 4; ++i ) - QCOMPARE( meshEditor.mTopologicalMesh.facesAroundVertex( i ), QList( {0} ) ); + QCOMPARE( meshEditor.mTopologicalMesh.facesAroundVertex( i ), QList( { 0 } ) ); QCOMPARE( meshEditor.mTopologicalMesh.facesAroundVertex( 4 ), QList() ); // undo edition @@ -866,11 +861,10 @@ void TestQgsMeshEditor::meshEditorSimpleEdition() QCOMPARE( triangularMesh.faceIndexForPoint_v2( QgsPointXY( 1, 0.5 ) ), -1 ); QVERIFY( meshEditor.checkConsistency( error ) ); - QCOMPARE( meshEditor.mTopologicalMesh.neighborsOfFace( 0 ), QVector( {-1, -1, -1, -1} ) ); + QCOMPARE( meshEditor.mTopologicalMesh.neighborsOfFace( 0 ), QVector( { -1, -1, -1, -1 } ) ); for ( int i = 0; i < 4; ++i ) - QCOMPARE( meshEditor.mTopologicalMesh.facesAroundVertex( i ), QList( {0} ) ); + QCOMPARE( meshEditor.mTopologicalMesh.facesAroundVertex( i ), QList( { 0 } ) ); QCOMPARE( meshEditor.mTopologicalMesh.facesAroundVertex( 4 ), QList() ); - } void TestQgsMeshEditor::faceIntersection() @@ -883,36 +877,37 @@ void TestQgsMeshEditor::faceIntersection() QVERIFY( editor ); // add some free vertices - const QVector vertices( {QgsPoint( 2500.0, 3500.0, 0.0 ), // 8 - QgsPoint( 1500.0, 4000.0, 0.0 ), // 9 - QgsPoint( 2750.0, 3000.0, 0.0 ), // 10 - QgsPoint( 1750.0, 3750.0, 0.0 ), // 11 - QgsPoint( 500.0, 1500.0, 0.0 ), // 12 - QgsPoint( 0.0, 0.0, 0.0 ), // 13 - QgsPoint( 0.0, 5000.0, 0.0 ), // 14 - QgsPoint( 5000.0, 5000.0, 0.0 ), // 15 - QgsPoint( 5000.0, 0.0, 0.0 ), // 16 - } ); + const QVector vertices( { + QgsPoint( 2500.0, 3500.0, 0.0 ), // 8 + QgsPoint( 1500.0, 4000.0, 0.0 ), // 9 + QgsPoint( 2750.0, 3000.0, 0.0 ), // 10 + QgsPoint( 1750.0, 3750.0, 0.0 ), // 11 + QgsPoint( 500.0, 1500.0, 0.0 ), // 12 + QgsPoint( 0.0, 0.0, 0.0 ), // 13 + QgsPoint( 0.0, 5000.0, 0.0 ), // 14 + QgsPoint( 5000.0, 5000.0, 0.0 ), // 15 + QgsPoint( 5000.0, 0.0, 0.0 ), // 16 + } ); editor->addVertices( vertices, 10 ); QCOMPARE( editor->freeVerticesIndexes().count(), 9 ); - QVERIFY( editor->faceCanBeAdded( {3, 8, 7} ) ); - editor->addFace( {3, 8, 7} ); + QVERIFY( editor->faceCanBeAdded( { 3, 8, 7 } ) ); + editor->addFace( { 3, 8, 7 } ); QCOMPARE( editor->freeVerticesIndexes().count(), 8 ); QCOMPARE( editor->mMesh->faceCount(), 6 ); - QVERIFY( !editor->faceCanBeAdded( {2, 3, 11} ) ); - QVERIFY( !editor->faceCanBeAdded( {7, 8, 9} ) ); - QVERIFY( !editor->faceCanBeAdded( {7, 8, 9} ) ); - QVERIFY( !editor->faceCanBeAdded( {10, 12, 9} ) ); - QVERIFY( !editor->faceCanBeAdded( {13, 14, 15, 16} ) ); - QVERIFY( !editor->faceCanBeAdded( {0, 9, 10} ) ); + QVERIFY( !editor->faceCanBeAdded( { 2, 3, 11 } ) ); + QVERIFY( !editor->faceCanBeAdded( { 7, 8, 9 } ) ); + QVERIFY( !editor->faceCanBeAdded( { 7, 8, 9 } ) ); + QVERIFY( !editor->faceCanBeAdded( { 10, 12, 9 } ) ); + QVERIFY( !editor->faceCanBeAdded( { 13, 14, 15, 16 } ) ); + QVERIFY( !editor->faceCanBeAdded( { 0, 9, 10 } ) ); - QVERIFY( editor->faceCanBeAdded( {2, 3, 8} ) ); - QVERIFY( editor->faceCanBeAdded( {2, 3, 10} ) ); - QVERIFY( editor->faceCanBeAdded( {7, 11, 8} ) ); + QVERIFY( editor->faceCanBeAdded( { 2, 3, 8 } ) ); + QVERIFY( editor->faceCanBeAdded( { 2, 3, 10 } ) ); + QVERIFY( editor->faceCanBeAdded( { 7, 11, 8 } ) ); } void TestQgsMeshEditor::particularCases() @@ -937,24 +932,24 @@ void TestQgsMeshEditor::particularCases() mesh.vertices.append( QgsMeshVertex( 200, 200, 0 ) ); mesh.vertices.append( QgsMeshVertex( 300, 200, 0 ) ); - mesh.faces.append( {0, 1, 4} ); - mesh.faces.append( {1, 2, 6} ); - mesh.faces.append( {2, 3, 7} ); - mesh.faces.append( {1, 5, 4} ); - mesh.faces.append( {1, 6, 5} ); - mesh.faces.append( {2, 7, 6} ); - mesh.faces.append( {4, 5, 8} ); - mesh.faces.append( {6, 7, 11, 10} ); - mesh.faces.append( {5, 9, 8} ); - mesh.faces.append( {5, 10, 9} ); - mesh.faces.append( {5, 6, 10} ); + mesh.faces.append( { 0, 1, 4 } ); + mesh.faces.append( { 1, 2, 6 } ); + mesh.faces.append( { 2, 3, 7 } ); + mesh.faces.append( { 1, 5, 4 } ); + mesh.faces.append( { 1, 6, 5 } ); + mesh.faces.append( { 2, 7, 6 } ); + mesh.faces.append( { 4, 5, 8 } ); + mesh.faces.append( { 6, 7, 11, 10 } ); + mesh.faces.append( { 5, 9, 8 } ); + mesh.faces.append( { 5, 10, 9 } ); + mesh.faces.append( { 5, 6, 10 } ); const QgsCoordinateTransform transform; triangularMesh.update( &mesh, transform ); QVERIFY( meshEditor.initialize() == QgsMeshEditingError() ); QVERIFY( meshEditor.checkConsistency( error ) ); - QVERIFY( meshEditor.removeVerticesWithoutFillHoles( {5, 1} ) == QgsMeshEditingError() ); + QVERIFY( meshEditor.removeVerticesWithoutFillHoles( { 5, 1 } ) == QgsMeshEditingError() ); QVERIFY( meshEditor.checkConsistency( error ) ); meshEditor.mUndoStack->undo(); @@ -963,7 +958,7 @@ void TestQgsMeshEditor::particularCases() QVERIFY( meshEditor.checkConsistency( error ) ); - QVERIFY( meshEditor.removeVerticesWithoutFillHoles( {6} ) == QgsMeshEditingError() ); + QVERIFY( meshEditor.removeVerticesWithoutFillHoles( { 6 } ) == QgsMeshEditingError() ); meshEditor.stopEditing(); @@ -985,17 +980,17 @@ void TestQgsMeshEditor::particularCases() mesh.vertices.append( QgsMeshVertex( 200, 100, 0 ) ); mesh.vertices.append( QgsMeshVertex( 100, 200, 0 ) ); - mesh.faces.append( {0, 1, 3} ); - mesh.faces.append( {1, 2, 4} ); - mesh.faces.append( {1, 5, 3} ); - mesh.faces.append( {1, 4, 5} ); + mesh.faces.append( { 0, 1, 3 } ); + mesh.faces.append( { 1, 2, 4 } ); + mesh.faces.append( { 1, 5, 3 } ); + mesh.faces.append( { 1, 4, 5 } ); const QgsCoordinateTransform transform; triangularMesh.update( &mesh, transform ); QVERIFY( meshEditor.initialize() == QgsMeshEditingError() ); QVERIFY( meshEditor.checkConsistency( error ) ); - QVERIFY( meshEditor.removeVerticesFillHoles( {5} ) == QList() ); + QVERIFY( meshEditor.removeVerticesFillHoles( { 5 } ) == QList() ); } { @@ -1012,9 +1007,9 @@ void TestQgsMeshEditor::particularCases() mesh.vertices.append( QgsMeshVertex( 130, 000, 0 ) ); // 5 mesh.vertices.append( QgsMeshVertex( 130, 400, 0 ) ); // 6 - mesh.faces.append( {5, 1, 0} ); - mesh.faces.append( {5, 3, 2, 1} ); - mesh.faces.append( {5, 4, 3} ); + mesh.faces.append( { 5, 1, 0 } ); + mesh.faces.append( { 5, 3, 2, 1 } ); + mesh.faces.append( { 5, 4, 3 } ); const QgsCoordinateTransform transform; @@ -1022,9 +1017,9 @@ void TestQgsMeshEditor::particularCases() QVERIFY( meshEditor.initialize() == QgsMeshEditingError() ); QVERIFY( meshEditor.checkConsistency( error ) ); - QVERIFY( meshEditor.isFaceGeometricallyCompatible( {1, 3, 2} ) ); + QVERIFY( meshEditor.isFaceGeometricallyCompatible( { 1, 3, 2 } ) ); - const QVector facesToAdd( {{0, 1, 2}, {0, 2, 6}, {1, 3, 2}, {2, 3, 4}} ); + const QVector facesToAdd( { { 0, 1, 2 }, { 0, 2, 6 }, { 1, 3, 2 }, { 2, 3, 4 } } ); const QgsTopologicalMesh::TopologicalFaces topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( facesToAdd, true, error ); QVERIFY( error == QgsMeshEditingError() ); @@ -1046,24 +1041,24 @@ void TestQgsMeshEditor::particularCases() mesh.vertices.append( QgsMeshVertex( 130, 000, 0 ) ); // 5 mesh.vertices.append( QgsMeshVertex( 130, 400, 0 ) ); // 6 - mesh.faces.append( {5, 1, 0} ); - mesh.faces.append( {5, 2, 1} ); - mesh.faces.append( {5, 3, 2} ); - mesh.faces.append( {5, 4, 3} ); + mesh.faces.append( { 5, 1, 0 } ); + mesh.faces.append( { 5, 2, 1 } ); + mesh.faces.append( { 5, 3, 2 } ); + mesh.faces.append( { 5, 4, 3 } ); const QgsCoordinateTransform transform; triangularMesh.update( &mesh, transform ); QVERIFY( meshEditor.initialize() == QgsMeshEditingError() ); QVERIFY( meshEditor.checkConsistency( error ) ); - const QVector facesToAdd( {{1, 6, 0}, {1, 2, 6}, {2, 3, 6}, {3, 4, 6 }, {1, 3, 2} } ); + const QVector facesToAdd( { { 1, 6, 0 }, { 1, 2, 6 }, { 2, 3, 6 }, { 3, 4, 6 }, { 1, 3, 2 } } ); const QgsTopologicalMesh::TopologicalFaces topologicFaces = QgsTopologicalMesh::createNewTopologicalFaces( facesToAdd, true, error ); QVERIFY( error == QgsMeshEditingError() ); error = meshEditor.mTopologicalMesh.facesCanBeAdded( topologicFaces ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::ManifoldFace, 4 ) ); - QVERIFY( !meshEditor.isFaceGeometricallyCompatible( {1, 3, 2} ) ); + QVERIFY( !meshEditor.isFaceGeometricallyCompatible( { 1, 3, 2 } ) ); } { @@ -1086,21 +1081,17 @@ void TestQgsMeshEditor::particularCases() { // add a quad mesh.faces.append( QgsMeshFace( - { - i * sideSize + j, - ( i + 1 ) * sideSize + j, - ( i + 1 ) * sideSize + j + 1, - ( i ) * sideSize + j + 1} ) ); + { i * sideSize + j, + ( i + 1 ) * sideSize + j, + ( i + 1 ) * sideSize + j + 1, + ( i ) *sideSize + j + 1 } + ) ); } else { // add two triangles - mesh.faces.append( QgsMeshFace( {i * sideSize + j, - ( i + 1 ) * sideSize + j, - ( i + 1 ) * sideSize + j + 1} ) ); - mesh.faces.append( QgsMeshFace( {i * sideSize + j, - i * sideSize + j + 1, - ( i + 1 ) * sideSize + j + 1} ) ); + mesh.faces.append( QgsMeshFace( { i * sideSize + j, ( i + 1 ) * sideSize + j, ( i + 1 ) * sideSize + j + 1 } ) ); + mesh.faces.append( QgsMeshFace( { i * sideSize + j, i * sideSize + j + 1, ( i + 1 ) * sideSize + j + 1 } ) ); } } @@ -1131,9 +1122,7 @@ void TestQgsMeshEditor::particularCases() QVERIFY( meshEditor.checkConsistency( error ) ); // just create a valid different transform to update the vertices of the triangular mesh - transform = QgsCoordinateTransform( QgsCoordinateReferenceSystem( "EPSG:32620" ), - QgsCoordinateReferenceSystem( "EPSG:32620" ), - QgsCoordinateTransformContext() ); + transform = QgsCoordinateTransform( QgsCoordinateReferenceSystem( "EPSG:32620" ), QgsCoordinateReferenceSystem( "EPSG:32620" ), QgsCoordinateTransformContext() ); triangularMesh.update( &mesh, transform ); meshEditor.mUndoStack->undo(); QVERIFY( meshEditor.checkConsistency( error ) ); @@ -1143,25 +1132,25 @@ void TestQgsMeshEditor::particularCases() { // remove vertex filling hole on boundary -- first configuration: all other vertex inside or only one outide QgsMesh mesh; - mesh.vertices.append( QgsMeshVertex( 0, 4, 0 ) ); // 0 - mesh.vertices.append( QgsMeshVertex( 2, 2, 0 ) ); // 1 - mesh.vertices.append( QgsMeshVertex( 4, 2, 0 ) ); // 2 - mesh.vertices.append( QgsMeshVertex( 6, 2, 0 ) ); // 3 - mesh.vertices.append( QgsMeshVertex( 8, 4, 0 ) ); // 4 + mesh.vertices.append( QgsMeshVertex( 0, 4, 0 ) ); // 0 + mesh.vertices.append( QgsMeshVertex( 2, 2, 0 ) ); // 1 + mesh.vertices.append( QgsMeshVertex( 4, 2, 0 ) ); // 2 + mesh.vertices.append( QgsMeshVertex( 6, 2, 0 ) ); // 3 + mesh.vertices.append( QgsMeshVertex( 8, 4, 0 ) ); // 4 mesh.vertices.append( QgsMeshVertex( 4, 10, 0 ) ); // 5 - mesh.vertices.append( QgsMeshVertex( 0, 2, 0 ) ); // 6 - mesh.vertices.append( QgsMeshVertex( 3, 0, 0 ) ); // 7 - mesh.vertices.append( QgsMeshVertex( 5, 0, 0 ) ); // 8 - mesh.vertices.append( QgsMeshVertex( 8, 2, 0 ) ); // 9 - - mesh.faces.append( {0, 6, 1} ); - mesh.faces.append( {1, 7, 2} ); - mesh.faces.append( {2, 8, 3} ); - mesh.faces.append( {3, 9, 4} ); - mesh.faces.append( {0, 1, 5} ); - mesh.faces.append( {1, 2, 5} ); - mesh.faces.append( {2, 3, 5} ); - mesh.faces.append( {3, 4, 5} ); + mesh.vertices.append( QgsMeshVertex( 0, 2, 0 ) ); // 6 + mesh.vertices.append( QgsMeshVertex( 3, 0, 0 ) ); // 7 + mesh.vertices.append( QgsMeshVertex( 5, 0, 0 ) ); // 8 + mesh.vertices.append( QgsMeshVertex( 8, 2, 0 ) ); // 9 + + mesh.faces.append( { 0, 6, 1 } ); + mesh.faces.append( { 1, 7, 2 } ); + mesh.faces.append( { 2, 8, 3 } ); + mesh.faces.append( { 3, 9, 4 } ); + mesh.faces.append( { 0, 1, 5 } ); + mesh.faces.append( { 1, 2, 5 } ); + mesh.faces.append( { 2, 3, 5 } ); + mesh.faces.append( { 3, 4, 5 } ); QCOMPARE( mesh.vertexCount(), 10 ); QCOMPARE( mesh.faceCount(), 8 ); @@ -1217,7 +1206,7 @@ void TestQgsMeshEditor::particularCases() QCOMPARE( mesh.faceCount(), 8 ); // with adding a face to make vertex 2 not an boundary anymore - QgsTopologicalMesh::Changes addFaceChanges = topologicMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( {{2, 7, 8}}, false, error ) ); + QgsTopologicalMesh::Changes addFaceChanges = topologicMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( { { 2, 7, 8 } }, false, error ) ); Q_ASSERT( error == QgsMeshEditingError() ); changes = topologicMesh.removeVertexFillHole( 5 ); @@ -1235,7 +1224,7 @@ void TestQgsMeshEditor::particularCases() QCOMPARE( mesh.faceCount(), 8 ); // try removing a face, no sufficient - QgsTopologicalMesh::Changes removeFaceChange = topologicMesh.removeFaces( {1} ); + QgsTopologicalMesh::Changes removeFaceChange = topologicMesh.removeFaces( { 1 } ); changes = topologicMesh.removeVertexFillHole( 5 ); QCOMPARE( changes.verticesToRemoveIndexes().count(), 0 ); @@ -1252,7 +1241,7 @@ void TestQgsMeshEditor::particularCases() QCOMPARE( mesh.faceCount(), 8 ); // try removing two faces, no sufficient - QgsTopologicalMesh::Changes remove2FacesChange = topologicMesh.removeFaces( {1, 2} ); + QgsTopologicalMesh::Changes remove2FacesChange = topologicMesh.removeFaces( { 1, 2 } ); changes = topologicMesh.removeVertexFillHole( 5 ); QCOMPARE( changes.verticesToRemoveIndexes().count(), 0 ); @@ -1272,25 +1261,25 @@ void TestQgsMeshEditor::particularCases() { // remove vertex filling hole -- second configuration: all vertex outside QgsMesh mesh; - mesh.vertices.append( QgsMeshVertex( 0, 2, 0 ) ); // 0 - mesh.vertices.append( QgsMeshVertex( 2, 4, 0 ) ); // 1 - mesh.vertices.append( QgsMeshVertex( 4, 5, 0 ) ); // 2 - mesh.vertices.append( QgsMeshVertex( 6, 4, 0 ) ); // 3 - mesh.vertices.append( QgsMeshVertex( 8, 2, 0 ) ); // 4 + mesh.vertices.append( QgsMeshVertex( 0, 2, 0 ) ); // 0 + mesh.vertices.append( QgsMeshVertex( 2, 4, 0 ) ); // 1 + mesh.vertices.append( QgsMeshVertex( 4, 5, 0 ) ); // 2 + mesh.vertices.append( QgsMeshVertex( 6, 4, 0 ) ); // 3 + mesh.vertices.append( QgsMeshVertex( 8, 2, 0 ) ); // 4 mesh.vertices.append( QgsMeshVertex( 4, 10, 0 ) ); // 5 - mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 6 - mesh.vertices.append( QgsMeshVertex( 3, 0, 0 ) ); // 7 - mesh.vertices.append( QgsMeshVertex( 5, 0, 0 ) ); // 8 - mesh.vertices.append( QgsMeshVertex( 8, 0, 0 ) ); // 9 - - mesh.faces.append( {0, 6, 1} ); - mesh.faces.append( {1, 7, 2} ); - mesh.faces.append( {2, 8, 3} ); - mesh.faces.append( {3, 9, 4} ); - mesh.faces.append( {0, 1, 5} ); - mesh.faces.append( {1, 2, 5} ); - mesh.faces.append( {2, 3, 5} ); - mesh.faces.append( {3, 4, 5} ); + mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 6 + mesh.vertices.append( QgsMeshVertex( 3, 0, 0 ) ); // 7 + mesh.vertices.append( QgsMeshVertex( 5, 0, 0 ) ); // 8 + mesh.vertices.append( QgsMeshVertex( 8, 0, 0 ) ); // 9 + + mesh.faces.append( { 0, 6, 1 } ); + mesh.faces.append( { 1, 7, 2 } ); + mesh.faces.append( { 2, 8, 3 } ); + mesh.faces.append( { 3, 9, 4 } ); + mesh.faces.append( { 0, 1, 5 } ); + mesh.faces.append( { 1, 2, 5 } ); + mesh.faces.append( { 2, 3, 5 } ); + mesh.faces.append( { 3, 4, 5 } ); QCOMPARE( mesh.vertexCount(), 10 ); QCOMPARE( mesh.faceCount(), 8 ); @@ -1305,7 +1294,7 @@ void TestQgsMeshEditor::particularCases() QCOMPARE( changes.addedFaces().count(), 0 ); // try adding a face, not sufficient - QgsTopologicalMesh::Changes addFaceChanges = topologicalMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( {{1, 6, 7}}, true, error ) ); + QgsTopologicalMesh::Changes addFaceChanges = topologicalMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( { { 1, 6, 7 } }, true, error ) ); Q_ASSERT( error == QgsMeshEditingError() ); changes = topologicalMesh.removeVertexFillHole( 5 ); @@ -1323,8 +1312,7 @@ void TestQgsMeshEditor::particularCases() QCOMPARE( mesh.faceCount(), 8 ); // try adding two faces, not sufficient - QgsTopologicalMesh::Changes add2FacesChanges = - topologicalMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( {{1, 6, 7}, {2, 7, 8}}, true, error ) ); + QgsTopologicalMesh::Changes add2FacesChanges = topologicalMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( { { 1, 6, 7 }, { 2, 7, 8 } }, true, error ) ); Q_ASSERT( error == QgsMeshEditingError() ); changes = topologicalMesh.removeVertexFillHole( 5 ); @@ -1342,8 +1330,7 @@ void TestQgsMeshEditor::particularCases() QCOMPARE( mesh.faceCount(), 8 ); // try adding three faces, good - QgsTopologicalMesh::Changes add3FacesChanges = - topologicalMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( {{1, 6, 7}, {2, 7, 8}, {3, 8, 9}}, true, error ) ); + QgsTopologicalMesh::Changes add3FacesChanges = topologicalMesh.addFaces( QgsTopologicalMesh::createNewTopologicalFaces( { { 1, 6, 7 }, { 2, 7, 8 }, { 3, 8, 9 } }, true, error ) ); Q_ASSERT( error == QgsMeshEditingError() ); changes = topologicalMesh.removeVertexFillHole( 5 ); @@ -1364,25 +1351,25 @@ void TestQgsMeshEditor::particularCases() { // remove vertex filling hole on boundary -- enclosed void QgsMesh mesh; - mesh.vertices.append( QgsMeshVertex( 0, 2, 0 ) ); // 0 - mesh.vertices.append( QgsMeshVertex( 2, 2, 0 ) ); // 1 - mesh.vertices.append( QgsMeshVertex( 4, 5, 0 ) ); // 2 - mesh.vertices.append( QgsMeshVertex( 6, 2, 0 ) ); // 3 - mesh.vertices.append( QgsMeshVertex( 8, 2, 0 ) ); // 4 + mesh.vertices.append( QgsMeshVertex( 0, 2, 0 ) ); // 0 + mesh.vertices.append( QgsMeshVertex( 2, 2, 0 ) ); // 1 + mesh.vertices.append( QgsMeshVertex( 4, 5, 0 ) ); // 2 + mesh.vertices.append( QgsMeshVertex( 6, 2, 0 ) ); // 3 + mesh.vertices.append( QgsMeshVertex( 8, 2, 0 ) ); // 4 mesh.vertices.append( QgsMeshVertex( 4, 10, 0 ) ); // 5 - mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 6 - mesh.vertices.append( QgsMeshVertex( 4, 0, 0 ) ); // 7 - mesh.vertices.append( QgsMeshVertex( 8, 0, 0 ) ); // 8 - - mesh.faces.append( {6, 1, 0} ); // 0 - mesh.faces.append( {1, 6, 7} ); // 1 - mesh.faces.append( {1, 7, 3} ); // 2 - mesh.faces.append( {3, 7, 8} ); // 3 - mesh.faces.append( {3, 8, 4} ); // 4 - mesh.faces.append( {0, 1, 5} ); // 5 - mesh.faces.append( {1, 2, 5} ); // 6 - mesh.faces.append( {2, 3, 5} ); // 7 - mesh.faces.append( {3, 4, 5} ); // 8 + mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 6 + mesh.vertices.append( QgsMeshVertex( 4, 0, 0 ) ); // 7 + mesh.vertices.append( QgsMeshVertex( 8, 0, 0 ) ); // 8 + + mesh.faces.append( { 6, 1, 0 } ); // 0 + mesh.faces.append( { 1, 6, 7 } ); // 1 + mesh.faces.append( { 1, 7, 3 } ); // 2 + mesh.faces.append( { 3, 7, 8 } ); // 3 + mesh.faces.append( { 3, 8, 4 } ); // 4 + mesh.faces.append( { 0, 1, 5 } ); // 5 + mesh.faces.append( { 1, 2, 5 } ); // 6 + mesh.faces.append( { 2, 3, 5 } ); // 7 + mesh.faces.append( { 3, 4, 5 } ); // 8 QCOMPARE( mesh.vertexCount(), 9 ); QCOMPARE( mesh.faceCount(), 9 ); @@ -1401,9 +1388,9 @@ void TestQgsMeshEditor::particularCases() QCOMPARE( changes.addedFaces().count(), 1 ); QList facesAround = topologicalMesh.facesAroundVertex( 3 ); - QCOMPARE( facesAround, QList( {2, 3, 4, 8, 9} ) ); + QCOMPARE( facesAround, QList( { 2, 3, 4, 8, 9 } ) ); facesAround = topologicalMesh.facesAroundVertex( 1 ); - QCOMPARE( facesAround, QList( {0, 1, 2, 9, 5} ) ); + QCOMPARE( facesAround, QList( { 0, 1, 2, 9, 5 } ) ); QVERIFY( !topologicalMesh.isVertexOnBoundary( 1 ) ); QVERIFY( !topologicalMesh.isVertexOnBoundary( 3 ) ); @@ -1425,7 +1412,7 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QgsMeshEditor *editor = meshLayerQuadTriangle->meshEditor(); - editor->addVertices( {{4000, 2000, 0}}, 10 ); + editor->addVertices( { { 4000, 2000, 0 } }, 10 ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 6 ); QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 1 ); QVERIFY( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().contains( 5 ) ); @@ -1435,10 +1422,12 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 0 ); editor->addVertices( - { - {4000, 2000, 0}, // 5 - {4000, 3000, 0} // 6 - }, 10 ); + { + { 4000, 2000, 0 }, // 5 + { 4000, 3000, 0 } // 6 + }, + 10 + ); QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 2 ); QVERIFY( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().contains( 5 ) ); @@ -1457,27 +1446,27 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QVERIFY( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().contains( 6 ) ); // Add vertices under the tolerance from the edge inside the face - editor->addVertices( {{2500, 2002, 0}}, 10 ); + editor->addVertices( { { 2500, 2002, 0 } }, 10 ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 8 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 3 ); QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 2 ); meshLayerQuadTriangle->undoStack()->undo(); // Add vertices under the tolerance from the edge outside the face - editor->addVertices( {{2500, 1998, 0}}, 10 ); + editor->addVertices( { { 2500, 1998, 0 } }, 10 ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 8 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 3 ); QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 2 ); meshLayerQuadTriangle->undoStack()->undo(); // try to add a face that shares only one vertex - error = editor->addFaces( {{2, 5, 6}} ); + error = editor->addFaces( { { 2, 5, 6 } } ); QVERIFY( error == QgsMeshEditingError( Qgis::MeshEditingErrorType::UniqueSharedVertex, 2 ) ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 7 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 2 ); // Add a face that shares two vertices - error = editor->addFaces( {{2, 3, 6}} ); + error = editor->addFaces( { { 2, 3, 6 } } ); QVERIFY( error == QgsMeshEditingError() ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 7 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 3 ); @@ -1512,7 +1501,7 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QVERIFY( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().contains( 5 ) ); // Add another face - error = editor->addFaces( {{2, 5, 6}} ); + error = editor->addFaces( { { 2, 5, 6 } } ); QVERIFY( error == QgsMeshEditingError() ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 7 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 4 ); @@ -1549,7 +1538,7 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 0 ); - editor->removeFaces( {2, 3} ); + editor->removeFaces( { 2, 3 } ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 2 ); QVERIFY( meshLayerQuadTriangle->nativeMesh()->face( 2 ).isEmpty() ); //removed faces are still present but empty @@ -1574,25 +1563,26 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QVERIFY( centroid.compare( QgsPointXY( 3666.6666666, 2333.33333333 ), 1e-6 ) ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 4 ); //removed faces are still present but empty - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 2 ), {2, 6, 3} ) ); - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 3 ), {2, 5, 6} ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 2 ), { 2, 6, 3 } ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 3 ), { 2, 5, 6 } ) ); QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 0 ); //Add a vertex on a face and one external editor->addVertices( - { - {1500, 2800, 0}, - {3000, 3500, 0} - }, 10 ); + { { 1500, 2800, 0 }, + { 3000, 3500, 0 } + }, + 10 + ); QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 9 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 7 ); // vertex on a quad face : 4 faces created, 1 removed, removed are still present but void and not counted QVERIFY( meshLayerQuadTriangle->nativeMesh()->face( 0 ).isEmpty() ); - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 4 ), {0, 1, 7} ) ); - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 5 ), {1, 3, 7} ) ); - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 6 ), {3, 4, 7} ) ); - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 7 ), {4, 0, 7} ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 4 ), { 0, 1, 7 } ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 5 ), { 1, 3, 7 } ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 6 ), { 3, 4, 7 } ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 7 ), { 4, 0, 7 } ) ); QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 1 ); QVERIFY( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().contains( 8 ) ); @@ -1619,8 +1609,8 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QCOMPARE( meshLayerQuadTriangle->meshVertexCount(), 7 ); QCOMPARE( meshLayerQuadTriangle->meshFaceCount(), 4 ); - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 2 ), {2, 6, 3} ) ); - QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 3 ), {2, 5, 6} ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 2 ), { 2, 6, 3 } ) ); + QVERIFY( QgsMesh::compareFaces( meshLayerQuadTriangle->nativeMesh()->face( 3 ), { 2, 5, 6 } ) ); QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 0 ); @@ -1668,7 +1658,7 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() //split QVERIFY( editor->faceCanBeSplit( 8 ) ); - QCOMPARE( editor->splitFaces( {8} ), 1 ); + QCOMPARE( editor->splitFaces( { 8 } ), 1 ); centroid = meshLayerQuadTriangle->snapOnElement( QgsMesh::Face, QgsPoint( 2100, 2500, 0 ), 10 ); QVERIFY( centroid.compare( QgsPointXY( 2333.3333333, 2333.33333333 ), 1e-6 ) ); @@ -1693,7 +1683,7 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadTriangle() QCOMPARE( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().count(), 1 ); QVERIFY( meshLayerQuadTriangle->meshEditor()->freeVerticesIndexes().contains( 8 ) ); - editor->removeVerticesWithoutFillHoles( {7} ); + editor->removeVerticesWithoutFillHoles( { 7 } ); centroid = meshLayerQuadTriangle->snapOnElement( QgsMesh::Face, QgsPoint( 1400, 2050, 0 ), 10 ); QVERIFY( centroid.isEmpty() ); @@ -1763,22 +1753,22 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadFlower() meshLayerQuadFlower->startFrameEditing( transform, error, false ); editor = meshLayerQuadFlower->meshEditor(); - QCOMPARE( editor->addPointsAsVertices( {QgsPoint( 1500, 2800, -10 )}, 10 ), 1 ); // 8 + QCOMPARE( editor->addPointsAsVertices( { QgsPoint( 1500, 2800, -10 ) }, 10 ), 1 ); // 8 QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 8 ); - QCOMPARE( editor->addPointsAsVertices( {QgsPoint( 1800, 2700, -10 )}, 10 ), 1 ); // 9 + QCOMPARE( editor->addPointsAsVertices( { QgsPoint( 1800, 2700, -10 ) }, 10 ), 1 ); // 9 QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 10 ); - QCOMPARE( editor->addPointsAsVertices( {QgsPoint( 1400, 2300, -10 ), QgsPoint( 1500, 2200, -10 )}, 10 ), 2 ); // 10 & 11 + QCOMPARE( editor->addPointsAsVertices( { QgsPoint( 1400, 2300, -10 ), QgsPoint( 1500, 2200, -10 ) }, 10 ), 2 ); // 10 & 11 QCOMPARE( meshLayerQuadFlower->meshEditor()->freeVerticesIndexes().count(), 0 ); QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 14 ); QVERIFY( editor->checkConsistency( error ) ); // attempt to add a vertex under tolerance next existing one - QCOMPARE( editor->addPointsAsVertices( {QgsPoint( 1499, 2801, -10 )}, 10 ), 0 ); + QCOMPARE( editor->addPointsAsVertices( { QgsPoint( 1499, 2801, -10 ) }, 10 ), 0 ); QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 14 ); - QCOMPARE( editor->addPointsAsVertices( {QgsPoint( 700, 1750, 0 )}, 10 ), 1 ); // 12 + QCOMPARE( editor->addPointsAsVertices( { QgsPoint( 700, 1750, 0 ) }, 10 ), 1 ); // 12 QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 14 ); QCOMPARE( meshLayerQuadFlower->meshVertexCount(), 13 ); @@ -1786,58 +1776,58 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadFlower() QVERIFY( meshLayerQuadFlower->meshEditor()->freeVerticesIndexes().contains( 12 ) ); QVERIFY( editor->checkConsistency( error ) ); - QVERIFY( editor->addFace( {0, 6, 12} ) == QgsMeshEditingError() ); + QVERIFY( editor->addFace( { 0, 6, 12 } ) == QgsMeshEditingError() ); QCOMPARE( meshLayerQuadFlower->meshEditor()->freeVerticesIndexes().count(), 0 ); QVERIFY( editor->checkConsistency( error ) ); - QCOMPARE( editor->addPointsAsVertices( {QgsPoint( 1400, 2200, -10 )}, 10 ), 1 ); // 13 + QCOMPARE( editor->addPointsAsVertices( { QgsPoint( 1400, 2200, -10 ) }, 10 ), 1 ); // 13 QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 17 ); QVERIFY( editor->checkConsistency( error ) ); QCOMPARE( meshLayerQuadFlower->datasetValue( QgsMeshDatasetIndex( 0, 0 ), QgsPointXY( 1420, 2220 ), 10 ).x(), -10 ); - QVERIFY( editor->removeVerticesFillHoles( {0} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 0 } ) == QList() ); meshLayerQuadFlower->undoStack()->undo(); - QVERIFY( editor->removeVerticesWithoutFillHoles( {0} ) == QgsMeshEditingError() ); + QVERIFY( editor->removeVerticesWithoutFillHoles( { 0 } ) == QgsMeshEditingError() ); QVERIFY( editor->checkConsistency( error ) ); QgsPointXY centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1200, 2500, 0 ), 10 ); QVERIFY( centroid.isEmpty() ); - QVERIFY( editor->addFace( {12, 10, 8, 4, 5} ) == QgsMeshEditingError() ); + QVERIFY( editor->addFace( { 12, 10, 8, 4, 5 } ) == QgsMeshEditingError() ); centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1200, 2500, 0 ), 10 ); QVERIFY( centroid.compare( QgsPointXY( 984.879, 2436.712 ), 1e-2 ) ); - QVERIFY( editor->addFace( {6, 1, 11, 10, 12} ).errorType == Qgis::MeshEditingErrorType::InvalidFace ); //concave face + QVERIFY( editor->addFace( { 6, 1, 11, 10, 12 } ).errorType == Qgis::MeshEditingErrorType::InvalidFace ); //concave face centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1600, 1750, 0 ), 10 ); QVERIFY( centroid.isEmpty() ); - QVERIFY( editor->addFace( {6, 1, 11, 13} ) == QgsMeshEditingError() ); + QVERIFY( editor->addFace( { 6, 1, 11, 13 } ) == QgsMeshEditingError() ); centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1600, 1750, 0 ), 10 ); QVERIFY( centroid.compare( QgsPointXY( 1633.3333, 1911.11111 ), 1e-2 ) ); - QVERIFY( editor->addFace( {13, 10, 12} ) == QgsMeshEditingError() ); + QVERIFY( editor->addFace( { 13, 10, 12 } ) == QgsMeshEditingError() ); centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1330, 2200, 0 ), 10 ); QVERIFY( centroid.compare( QgsPointXY( 1166.66666, 2083.33333 ), 1e-2 ) ); - QVERIFY( editor->addFace( {6, 13, 12} ) == QgsMeshEditingError() ); + QVERIFY( editor->addFace( { 6, 13, 12 } ) == QgsMeshEditingError() ); centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1300, 1800, 0 ), 10 ); QVERIFY( centroid.compare( QgsPointXY( 1200.0, 1816.6666 ), 1e-2 ) ); - editor->changeZValues( {6, 13, 12}, {-200.0, -200.0, -200.0} ); + editor->changeZValues( { 6, 13, 12 }, { -200.0, -200.0, -200.0 } ); QCOMPARE( meshLayerQuadFlower->datasetValue( QgsMeshDatasetIndex( 0, 0 ), QgsPoint( 1300, 1800 ), 10 ).x(), -200 ); - QCOMPARE( editor->addVertices( {QgsMeshVertex( 750, 2500, 550 )}, 10 ), 1 ); - QCOMPARE( editor->addVertices( {QgsMeshVertex( 1200, 2500, 700 )}, 10 ), 1 ); + QCOMPARE( editor->addVertices( { QgsMeshVertex( 750, 2500, 550 ) }, 10 ), 1 ); + QCOMPARE( editor->addVertices( { QgsMeshVertex( 1200, 2500, 700 ) }, 10 ), 1 ); centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1330, 2500, 0 ), 10 ); QVERIFY( centroid.compare( QgsPointXY( 1366.6666, 2533.3333 ), 1e-2 ) ); @@ -1852,12 +1842,12 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadFlower() QVERIFY( !editor->edgeCanBeFlipped( 8, 9 ) ); QVERIFY( !editor->edgeCanBeFlipped( 10, 17 ) ); - QVERIFY( editor->removeVerticesFillHoles( {10} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 10 } ) == QList() ); QVERIFY( editor->checkConsistency( error ) ); editor->mUndoStack->undo(); - QVERIFY( editor->removeVerticesFillHoles( {10} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 10 } ) == QList() ); centroid = meshLayerQuadFlower->snapOnElement( QgsMesh::Face, QgsPoint( 1330, 2500, 0 ), 10 ); QVERIFY( centroid.compare( QgsPointXY( 1400, 2500 ), 1e-2 ) ); @@ -1867,19 +1857,19 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadFlower() editor->mUndoStack->undo(); - QVERIFY( editor->removeVerticesFillHoles( {13} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 13 } ) == QList() ); - QVERIFY( editor->removeVerticesFillHoles( {11} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 11 } ) == QList() ); - QVERIFY( editor->removeVerticesFillHoles( {9} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 9 } ) == QList() ); - QVERIFY( editor->removeVerticesFillHoles( {8} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 8 } ) == QList() ); - QVERIFY( editor->removeVerticesFillHoles( {15} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 15 } ) == QList() ); - QVERIFY( editor->removeVerticesFillHoles( {14} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 14 } ) == QList() ); - QVERIFY( editor->removeVerticesFillHoles( {7} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 7 } ) == QList() ); QCOMPARE( meshLayerQuadFlower->meshFaceCount(), 5 ); QCOMPARE( meshLayerQuadFlower->meshVertexCount(), 7 ); @@ -1894,13 +1884,13 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadFlower() QCOMPARE( meshLayerQuadFlower->meshVertexCount(), 7 ); QCOMPARE( meshLayerQuadFlower->meshEditor()->freeVerticesIndexes().count(), 0 ); - QVERIFY( editor->removeVerticesWithoutFillHoles( {3} ).errorType != Qgis::MeshEditingErrorType::NoError ); // leads to a topological error - QCOMPARE( meshLayerQuadFlower->meshEditor()->addVertices( {{4000, 4000, 0}, {4000, 4100, 0}, {4100, 4000, 0}, {4100, 4100, 0}}, 10 ), 4 ); + QVERIFY( editor->removeVerticesWithoutFillHoles( { 3 } ).errorType != Qgis::MeshEditingErrorType::NoError ); // leads to a topological error + QCOMPARE( meshLayerQuadFlower->meshEditor()->addVertices( { { 4000, 4000, 0 }, { 4000, 4100, 0 }, { 4100, 4000, 0 }, { 4100, 4100, 0 } }, 10 ), 4 ); QCOMPARE( meshLayerQuadFlower->meshEditor()->freeVerticesIndexes().count(), 4 ); //QVERIFY( editor->removeVertices( {3}, true ).errorType != Qgis::MeshEditingErrorType::NoError ); // filling after removing boundary not supported, so not fill and leads to a topological error - QVERIFY( editor->removeVerticesFillHoles( {4} ) == QList() ); + QVERIFY( editor->removeVerticesFillHoles( { 4 } ) == QList() ); QVERIFY( editor->checkConsistency( error ) ); meshLayerQuadFlower->commitFrameEditing( transform, true ); @@ -1935,14 +1925,7 @@ void TestQgsMeshEditor::meshEditorFromMeshLayer_quadFlower() void TestQgsMeshEditor::refineMesh() { - auto checkRefinedFace = []( const QgsMesh & mesh, - const QHash &facesRefinement, - int faceIndex, - int refinedNeighborCount, - int centerVertexIndex, - int newBorderVertexCount, - int newFaceCount ) - { + auto checkRefinedFace = []( const QgsMesh &mesh, const QHash &facesRefinement, int faceIndex, int refinedNeighborCount, int centerVertexIndex, int newBorderVertexCount, int newFaceCount ) { const QgsMeshEditRefineFaces::FaceRefinement &refinement = facesRefinement.value( faceIndex ); int refinedNeighbor = 0; for ( int j = 0; j < mesh.face( faceIndex ).count(); ++j ) @@ -1971,19 +1954,23 @@ void TestQgsMeshEditor::refineMesh() mesh.vertices.append( QgsMeshVertex( 300, 200, 0 ) ); // 6 mesh.vertices.append( QgsMeshVertex( 200, 100, 0 ) ); // 7 mesh.vertices.append( QgsMeshVertex( 100, 100, 0 ) ); // 8 - mesh.vertices.append( QgsMeshVertex( 0, 230, 0 ) ); // 9 - mesh.vertices.append( QgsMeshVertex( 0, 120, 0 ) ); // 10 - mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 11 - mesh.vertices.append( QgsMeshVertex( 100, 0, 0 ) ); // 12 - - mesh.faces.append( {0, 1, 2, 3} ); // 0 - mesh.faces.append( {4, 5, 2, 1} ); // 1 - mesh.faces.append( {8, 7, 5, 4} ); // 2 - mesh.faces.append( {9, 8, 4} ); // 3 - mesh.faces.append( {10, 8, 9} ); // 4 - mesh.faces.append( {5, 7, 6} ); // 5 - mesh.faces.append( {10, 11, 12, 8} ); // 6 - mesh.faces.append( {8, 12, 7,} ); // 7 + mesh.vertices.append( QgsMeshVertex( 0, 230, 0 ) ); // 9 + mesh.vertices.append( QgsMeshVertex( 0, 120, 0 ) ); // 10 + mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 11 + mesh.vertices.append( QgsMeshVertex( 100, 0, 0 ) ); // 12 + + mesh.faces.append( { 0, 1, 2, 3 } ); // 0 + mesh.faces.append( { 4, 5, 2, 1 } ); // 1 + mesh.faces.append( { 8, 7, 5, 4 } ); // 2 + mesh.faces.append( { 9, 8, 4 } ); // 3 + mesh.faces.append( { 10, 8, 9 } ); // 4 + mesh.faces.append( { 5, 7, 6 } ); // 5 + mesh.faces.append( { 10, 11, 12, 8 } ); // 6 + mesh.faces.append( { + 8, + 12, + 7, + } ); // 7 const QgsCoordinateTransform transform; triangularMesh.update( &mesh, transform ); @@ -1995,7 +1982,7 @@ void TestQgsMeshEditor::refineMesh() QgsMeshEditRefineFaces refineEditing; refineEditing.setInputFaces( facesList ); - QHash facesRefinement; + QHash facesRefinement; QHash borderFaces; QSet facesToRefine; facesToRefine = qgis::listToSet( facesList ); @@ -2033,21 +2020,17 @@ void TestQgsMeshEditor::refineMesh() { // add a quad mesh.faces.append( QgsMeshFace( - { - i * sideSize + j, - ( i + 1 ) * sideSize + j, - ( i + 1 ) * sideSize + j + 1, - ( i ) * sideSize + j + 1} ) ); + { i * sideSize + j, + ( i + 1 ) * sideSize + j, + ( i + 1 ) * sideSize + j + 1, + ( i ) *sideSize + j + 1 } + ) ); } else { // add two triangles - mesh.faces.append( QgsMeshFace( {i * sideSize + j, - ( i + 1 ) * sideSize + j, - ( i + 1 ) * sideSize + j + 1} ) ); - mesh.faces.append( QgsMeshFace( {i * sideSize + j, - i * sideSize + j + 1, - ( i + 1 ) * sideSize + j + 1} ) ); + mesh.faces.append( QgsMeshFace( { i * sideSize + j, ( i + 1 ) * sideSize + j, ( i + 1 ) * sideSize + j + 1 } ) ); + mesh.faces.append( QgsMeshFace( { i * sideSize + j, i * sideSize + j + 1, ( i + 1 ) * sideSize + j + 1 } ) ); } } @@ -2096,24 +2079,24 @@ void TestQgsMeshEditor::refineMesh() QgsMeshEditor meshEditor( &mesh, &triangularMesh ); QgsMeshEditingError error; - mesh.vertices.append( QgsMeshVertex( 0, 200, 0 ) ); // 0 + mesh.vertices.append( QgsMeshVertex( 0, 200, 0 ) ); // 0 mesh.vertices.append( QgsMeshVertex( 200, 200, 0 ) ); // 1 - mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 2 - mesh.vertices.append( QgsMeshVertex( 200, 0, 0 ) ); // + mesh.vertices.append( QgsMeshVertex( 0, 0, 0 ) ); // 2 + mesh.vertices.append( QgsMeshVertex( 200, 0, 0 ) ); // mesh.vertices.append( QgsMeshVertex( 100, 175, 0 ) ); // 4 - mesh.vertices.append( QgsMeshVertex( 25, 150, 0 ) ); // 5 - mesh.vertices.append( QgsMeshVertex( 25, 25, 0 ) ); // 6 - mesh.vertices.append( QgsMeshVertex( 175, 25, 0 ) ); // 7 + mesh.vertices.append( QgsMeshVertex( 25, 150, 0 ) ); // 5 + mesh.vertices.append( QgsMeshVertex( 25, 25, 0 ) ); // 6 + mesh.vertices.append( QgsMeshVertex( 175, 25, 0 ) ); // 7 mesh.vertices.append( QgsMeshVertex( 175, 150, 0 ) ); // 8 - mesh.faces.append( {2, 5, 0 } ); // 0 - mesh.faces.append( {0, 5, 4 } ); // 1 - mesh.faces.append( {0, 4, 1 } ); // 2 - mesh.faces.append( {1, 4, 8 } ); // 3 - mesh.faces.append( {4, 5, 6, 7, 8 } ); // 4 - mesh.faces.append( {2, 6, 5 } ); // 5 - mesh.faces.append( {6, 2, 3, 7 } ); // 6 - mesh.faces.append( {3, 8, 7} ); // 7 + mesh.faces.append( { 2, 5, 0 } ); // 0 + mesh.faces.append( { 0, 5, 4 } ); // 1 + mesh.faces.append( { 0, 4, 1 } ); // 2 + mesh.faces.append( { 1, 4, 8 } ); // 3 + mesh.faces.append( { 4, 5, 6, 7, 8 } ); // 4 + mesh.faces.append( { 2, 6, 5 } ); // 5 + mesh.faces.append( { 6, 2, 3, 7 } ); // 6 + mesh.faces.append( { 3, 8, 7 } ); // 7 const QgsCoordinateTransform transform; triangularMesh.update( &mesh, transform ); @@ -2128,7 +2111,7 @@ void TestQgsMeshEditor::refineMesh() QgsMeshEditRefineFaces refineEditing; refineEditing.setInputFaces( facesList ); - QHash facesRefinement; + QHash facesRefinement; QHash borderFaces; QSet facesToRefine; facesToRefine = qgis::listToSet( facesList ); @@ -2154,7 +2137,6 @@ void TestQgsMeshEditor::refineMesh() QVERIFY( !facesRefinement.isEmpty() ); QVERIFY( !borderFaces.isEmpty() ); - } } @@ -2173,11 +2155,11 @@ void TestQgsMeshEditor::transformByExpression() // no input set QVERIFY( !transformVertex.calculate( layer.get() ) ); - transformVertex.setInputVertices( {0, 1, 3, 4} ); + transformVertex.setInputVertices( { 0, 1, 3, 4 } ); QVERIFY( transformVertex.calculate( layer.get() ) ); - QCOMPARE( transformVertex.mChangeCoordinateVerticesIndexes, QList( {0, 1, 3, 4} ) ); + QCOMPARE( transformVertex.mChangeCoordinateVerticesIndexes, QList( { 0, 1, 3, 4 } ) ); QVERIFY( transformVertex.mOldXYValues.at( 0 ).compare( QgsPointXY( 1000, 2000 ), 0.1 ) ); QVERIFY( transformVertex.mOldXYValues.at( 1 ).compare( QgsPointXY( 2000, 2000 ), 0.1 ) ); QVERIFY( transformVertex.mOldXYValues.at( 2 ).compare( QgsPointXY( 2000, 3000 ), 0.1 ) ); @@ -2196,65 +2178,66 @@ void TestQgsMeshEditor::transformByExpression() QgsMesh &mesh = *layer->nativeMesh(); QVERIFY( QgsPoint( 1050, 1950, 300 ).compareTo( &mesh.vertices.at( 0 ) ) == 0 ); - QVERIFY( QgsPoint( 2050, 1950, 300 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); - QVERIFY( QgsPoint( 2500, 2500, 800 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); - QVERIFY( QgsPoint( 2050, 2950, 300 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); - QVERIFY( QgsPoint( 1050, 2950, 300 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); - QVERIFY( QgsPoint( 500, 2500, 800 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); - QVERIFY( QgsPoint( 1500, 1500, 800 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); - QVERIFY( QgsPoint( 1500, 3500, 800 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); + QVERIFY( QgsPoint( 2050, 1950, 300 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); + QVERIFY( QgsPoint( 2500, 2500, 800 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); + QVERIFY( QgsPoint( 2050, 2950, 300 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); + QVERIFY( QgsPoint( 1050, 2950, 300 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); + QVERIFY( QgsPoint( 500, 2500, 800 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); + QVERIFY( QgsPoint( 1500, 1500, 800 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); + QVERIFY( QgsPoint( 1500, 3500, 800 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); layer->undoStack()->undo(); mesh = *layer->nativeMesh(); QVERIFY( QgsPoint( 1000, 2000, 200 ).compareTo( &mesh.vertices.at( 0 ) ) == 0 ); - QVERIFY( QgsPoint( 2000, 2000, 200 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); - QVERIFY( QgsPoint( 2500, 2500, 800 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); - QVERIFY( QgsPoint( 2000, 3000, 200 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); - QVERIFY( QgsPoint( 1000, 3000, 200 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); - QVERIFY( QgsPoint( 500, 2500, 800 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); - QVERIFY( QgsPoint( 1500, 1500, 800 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); - QVERIFY( QgsPoint( 1500, 3500, 800 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); + QVERIFY( QgsPoint( 2000, 2000, 200 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); + QVERIFY( QgsPoint( 2500, 2500, 800 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); + QVERIFY( QgsPoint( 2000, 3000, 200 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); + QVERIFY( QgsPoint( 1000, 3000, 200 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); + QVERIFY( QgsPoint( 500, 2500, 800 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); + QVERIFY( QgsPoint( 1500, 1500, 800 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); + QVERIFY( QgsPoint( 1500, 3500, 800 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); layer->undoStack()->redo(); mesh = *layer->nativeMesh(); QVERIFY( QgsPoint( 1050, 1950, 300 ).compareTo( &mesh.vertices.at( 0 ) ) == 0 ); - QVERIFY( QgsPoint( 2050, 1950, 300 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); - QVERIFY( QgsPoint( 2500, 2500, 800 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); - QVERIFY( QgsPoint( 2050, 2950, 300 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); - QVERIFY( QgsPoint( 1050, 2950, 300 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); - QVERIFY( QgsPoint( 500, 2500, 800 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); - QVERIFY( QgsPoint( 1500, 1500, 800 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); - QVERIFY( QgsPoint( 1500, 3500, 800 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); + QVERIFY( QgsPoint( 2050, 1950, 300 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); + QVERIFY( QgsPoint( 2500, 2500, 800 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); + QVERIFY( QgsPoint( 2050, 2950, 300 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); + QVERIFY( QgsPoint( 1050, 2950, 300 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); + QVERIFY( QgsPoint( 500, 2500, 800 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); + QVERIFY( QgsPoint( 1500, 1500, 800 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); + QVERIFY( QgsPoint( 1500, 3500, 800 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); layer->undoStack()->undo(); // leads to an invalid mesh transformVertex.clear(); - transformVertex.setInputVertices( {1, 3} ); + transformVertex.setInputVertices( { 1, 3 } ); transformVertex.setExpressions( QStringLiteral( "$vertex_x -1500" ), QStringLiteral( "$vertex_y - 1500" ), QString() ); QVERIFY( !transformVertex.calculate( layer.get() ) ); // transforme with intersecting existing faces transformVertex.clear(); - transformVertex.setInputVertices( {2, 3, 7} ); + transformVertex.setInputVertices( { 2, 3, 7 } ); transformVertex.setExpressions( QStringLiteral( "$vertex_x+700" ), QStringLiteral( "$vertex_y + 700" ), QString() ); QVERIFY( transformVertex.calculate( layer.get() ) ); // add a other face that will intersects transformed ones layer->meshEditor()->addVertices( - { - {2000, 3500, 0}, // 8 - {2500, 3500, 10}, // 9 - {2500, 4000, 20}} // 10 - , 1 ); + { { 2000, 3500, 0 }, // 8 + { 2500, 3500, 10 }, // 9 + { 2500, 4000, 20 } } // 10 + , + 1 + ); QVERIFY( !transformVertex.calculate( layer.get() ) ); - layer->meshEditor()->addFace( {8, 9, 10} ); + layer->meshEditor()->addFace( { 8, 9, 10 } ); QVERIFY( !transformVertex.calculate( layer.get() ) ); @@ -2266,10 +2249,8 @@ void TestQgsMeshEditor::transformByExpression() // composed expression transformVertex.clear(); - transformVertex.setInputVertices( {0, 1, 2, 3, 4, 5, 6, 7} ); - transformVertex.setExpressions( QStringLiteral( "$vertex_y + 50" ), - QStringLiteral( "-$vertex_x" ), - QStringLiteral( "if( $vertex_x <= 1500 , $vertex_z + 80 , $vertex_z - 150)" ) ); + transformVertex.setInputVertices( { 0, 1, 2, 3, 4, 5, 6, 7 } ); + transformVertex.setExpressions( QStringLiteral( "$vertex_y + 50" ), QStringLiteral( "-$vertex_x" ), QStringLiteral( "if( $vertex_x <= 1500 , $vertex_z + 80 , $vertex_z - 150)" ) ); QVERIFY( transformVertex.calculate( layer.get() ) ); layer->meshEditor()->advancedEdit( &transformVertex ); @@ -2277,35 +2258,31 @@ void TestQgsMeshEditor::transformByExpression() mesh = *layer->nativeMesh(); QVERIFY( QgsPoint( 2050, -1000, 280 ).compareTo( &mesh.vertices.at( 0 ) ) == 0 ); - QVERIFY( QgsPoint( 2050, -2000, 50 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); - QVERIFY( QgsPoint( 2550, -2500, 650 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); - QVERIFY( QgsPoint( 3050, -2000, 50 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); - QVERIFY( QgsPoint( 3050, -1000, 280 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); - QVERIFY( QgsPoint( 2550, -500, 880 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); - QVERIFY( QgsPoint( 1550, -1500, 880 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); - QVERIFY( QgsPoint( 3550, -1500, 880 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); + QVERIFY( QgsPoint( 2050, -2000, 50 ).compareTo( &mesh.vertices.at( 1 ) ) == 0 ); + QVERIFY( QgsPoint( 2550, -2500, 650 ).compareTo( &mesh.vertices.at( 2 ) ) == 0 ); + QVERIFY( QgsPoint( 3050, -2000, 50 ).compareTo( &mesh.vertices.at( 3 ) ) == 0 ); + QVERIFY( QgsPoint( 3050, -1000, 280 ).compareTo( &mesh.vertices.at( 4 ) ) == 0 ); + QVERIFY( QgsPoint( 2550, -500, 880 ).compareTo( &mesh.vertices.at( 5 ) ) == 0 ); + QVERIFY( QgsPoint( 1550, -1500, 880 ).compareTo( &mesh.vertices.at( 6 ) ) == 0 ); + QVERIFY( QgsPoint( 3550, -1500, 880 ).compareTo( &mesh.vertices.at( 7 ) ) == 0 ); layer->undoStack()->undo(); // move only a free vertex in an existing face - layer->meshEditor()->addVertices( {QgsMeshVertex( 2500, 3500, 0 )}, 10 ); + layer->meshEditor()->addVertices( { QgsMeshVertex( 2500, 3500, 0 ) }, 10 ); QVERIFY( layer->meshVertexCount() == 9 ); transformVertex.clear(); - transformVertex.setInputVertices( {8} ); - transformVertex.setExpressions( QStringLiteral( "$vertex_x - 1000" ), - QStringLiteral( "$vertex_y - 1000" ), - QLatin1String( "" ) ); + transformVertex.setInputVertices( { 8 } ); + transformVertex.setExpressions( QStringLiteral( "$vertex_x - 1000" ), QStringLiteral( "$vertex_y - 1000" ), QLatin1String( "" ) ); QVERIFY( !transformVertex.calculate( layer.get() ) ); transformVertex.clear(); - transformVertex.setInputVertices( {8} ); + transformVertex.setInputVertices( { 8 } ); - transformVertex.setExpressions( QStringLiteral( "$vertex_x + 1000" ), - QStringLiteral( "$vertex_y + 1000" ), - QLatin1String( "" ) ); + transformVertex.setExpressions( QStringLiteral( "$vertex_x + 1000" ), QStringLiteral( "$vertex_y + 1000" ), QLatin1String( "" ) ); QVERIFY( transformVertex.calculate( layer.get() ) ); } @@ -2479,9 +2456,9 @@ void TestQgsMeshEditor::forceByLine() forceByPolyline1.setTolerance( 5 ); std::unique_ptr lineString = std::make_unique(); - lineString->addVertex( {1250, 2250, 5} ); - lineString->addVertex( {1850, 2850, 20} ); - lineString->addVertex( {1850, 0, 150} ); + lineString->addVertex( { 1250, 2250, 5 } ); + lineString->addVertex( { 1850, 2850, 20 } ); + lineString->addVertex( { 1850, 0, 150 } ); forceByPolyline1.addLineFromGeometry( QgsGeometry( lineString.release() ) ); meshLayer->meshEditor()->advancedEdit( &forceByPolyline1 ); @@ -2494,9 +2471,9 @@ void TestQgsMeshEditor::forceByLine() QgsMeshEditForceByPolylines forceByPolyline2; lineString = std::make_unique(); - lineString->addVertex( {1250, 2250, 5} ); - lineString->addVertex( {1850, 2850, 20} ); - lineString->addVertex( {1850, 0, 150} ); + lineString->addVertex( { 1250, 2250, 5 } ); + lineString->addVertex( { 1850, 2850, 20 } ); + lineString->addVertex( { 1850, 0, 150 } ); forceByPolyline2.addLineFromGeometry( QgsGeometry( lineString.release() ) ); forceByPolyline2.clear(); forceByPolyline2.setAddVertexOnIntersection( true ); @@ -2505,7 +2482,6 @@ void TestQgsMeshEditor::forceByLine() QVERIFY( meshLayer->meshEditor()->checkConsistency( error ) ); QCOMPARE( meshLayer->nativeMesh()->vertexCount(), initialVertexCount + 8 ); QCOMPARE( meshLayer->nativeMesh()->faceCount(), initialFaceCount + 31 ); - } QGSTEST_MAIN( TestQgsMeshEditor ) diff --git a/tests/src/core/testqgsmeshlayer.cpp b/tests/src/core/testqgsmeshlayer.cpp index eb9fd0fb45df..7a34e098fed6 100644 --- a/tests/src/core/testqgsmeshlayer.cpp +++ b/tests/src/core/testqgsmeshlayer.cpp @@ -57,10 +57,10 @@ class TestQgsMeshLayer : public QgsTest QString readFile( const QString &fname ) const; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void test_write_read_project(); void test_path(); @@ -154,7 +154,8 @@ void TestQgsMeshLayer::initTestCase() QCOMPARE( referenceTime, QDateTime( QDate( 2017, 2, 27 ), QTime( 1, 2, 3 ), Qt::UTC ) ); QVERIFY( !mMemoryLayer->supportsEditing() ); QgsProject::instance()->addMapLayers( - QList() << mMemoryLayer ); + QList() << mMemoryLayer + ); // MDAL Layer QString uri( mDataDir + "/quad_and_triangle.2dm" ); @@ -178,7 +179,8 @@ void TestQgsMeshLayer::initTestCase() QVERIFY( mMemoryLayer->temporalProperties()->isActive() ); QgsProject::instance()->addMapLayers( - QList() << mMdalLayer ); + QList() << mMdalLayer + ); // Memory 1D layer mMemory1DLayer = new QgsMeshLayer( readFile( "/lines.txt" ), "Lines Memory", "mesh_memory" ); @@ -198,7 +200,8 @@ void TestQgsMeshLayer::initTestCase() QVERIFY( mMemory1DLayer->temporalProperties()->isActive() ); QgsProject::instance()->addMapLayers( - QList() << mMemory1DLayer ); + QList() << mMemory1DLayer + ); // MDAL 1D Layer uri = QString( mDataDir + "/lines.2dm" ); @@ -222,7 +225,8 @@ void TestQgsMeshLayer::initTestCase() QVERIFY( mMdal1DLayer->isValid() ); QgsProject::instance()->addMapLayers( - QList() << mMdal1DLayer ); + QList() << mMdal1DLayer + ); // MDAL 3D Layer @@ -231,7 +235,8 @@ void TestQgsMeshLayer::initTestCase() QVERIFY( mMdal3DLayer->isValid() ); QgsProject::instance()->addMapLayers( - QList() << mMdal3DLayer ); + QList() << mMdal3DLayer + ); } void TestQgsMeshLayer::cleanupTestCase() @@ -351,7 +356,7 @@ void TestQgsMeshLayer::test_read_1d_vertex_scalar_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 1, i ); @@ -402,7 +407,7 @@ void TestQgsMeshLayer::test_read_1d_vertex_vector_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 2, i ); @@ -453,7 +458,7 @@ void TestQgsMeshLayer::test_read_1d_edge_scalar_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 3, i ); @@ -507,7 +512,7 @@ void TestQgsMeshLayer::test_read_1d_edge_vector_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 4, i ); @@ -655,7 +660,7 @@ void TestQgsMeshLayer::test_read_vertex_scalar_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 1, i ); @@ -723,7 +728,7 @@ void TestQgsMeshLayer::test_read_vertex_vector_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 2, i ); @@ -785,7 +790,7 @@ void TestQgsMeshLayer::test_read_face_scalar_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 3, i ); @@ -842,7 +847,7 @@ void TestQgsMeshLayer::test_read_face_vector_dataset() QCOMPARE( 5, dp->datasetGroupCount() ); QCOMPARE( 5, ly->datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 4, i ); @@ -894,7 +899,7 @@ void TestQgsMeshLayer::test_read_vertex_scalar_dataset_with_inactive_face() QCOMPARE( 2, dp->datasetGroupCount() ); QCOMPARE( 2, layer.datasetGroupCount() ); - for ( int i = 0; i < 2 ; ++i ) + for ( int i = 0; i < 2; ++i ) { const QgsMeshDatasetIndex ds( 1, i ); @@ -982,9 +987,10 @@ void TestQgsMeshLayer::test_path() QString meshLayerUri = QStringLiteral( "2DM:\"" ) + dir1.filePath( QStringLiteral( "quad_and_triangle.2dm" ) ) + QStringLiteral( "\"" ); std::unique_ptr meshLayer = std::make_unique( - meshLayerUri, - QStringLiteral( "mesh layer" ), - QStringLiteral( "mdal" ) ); + meshLayerUri, + QStringLiteral( "mesh layer" ), + QStringLiteral( "mdal" ) + ); Q_ASSERT( meshLayer->isValid() ); meshLayer->addDatasets( dir1.filePath( QStringLiteral( "dataseGroup.dat" ) ) ); @@ -1053,8 +1059,7 @@ void TestQgsMeshLayer::test_reload() QTemporaryFile testFile; - auto copyToTemporaryFile = []( QFile & fileTocopy, QTemporaryFile & tempFile ) - { + auto copyToTemporaryFile = []( QFile &fileTocopy, QTemporaryFile &tempFile ) { QDataStream streamToCopy( &fileTocopy ); QDataStream streamTemporaryFile( &tempFile ); tempFile.open(); @@ -1135,8 +1140,7 @@ void TestQgsMeshLayer::test_reload_extra_dataset() QTemporaryFile testFileDataSet; - auto copyToTemporaryFile = []( QFile & fileTocopy, QTemporaryFile & tempFile ) - { + auto copyToTemporaryFile = []( QFile &fileTocopy, QTemporaryFile &tempFile ) { QDataStream streamToCopy( &fileTocopy ); QDataStream streamTemporaryFile( &tempFile ); tempFile.open(); @@ -1173,9 +1177,9 @@ void TestQgsMeshLayer::test_reload_extra_dataset() layer.reload(); //test if dataset presence - QCOMPARE( layer.dataProvider()->extraDatasets().count(), 1 ); //uri still present - QCOMPARE( layer.dataProvider()->datasetGroupCount(), 1 ); //dataset not loaded in the provider - QCOMPARE( layer.datasetGroupCount(), 1 ); //dataset not registered anymore in the mesh layer + QCOMPARE( layer.dataProvider()->extraDatasets().count(), 1 ); //uri still present + QCOMPARE( layer.dataProvider()->datasetGroupCount(), 1 ); //dataset not loaded in the provider + QCOMPARE( layer.datasetGroupCount(), 1 ); //dataset not registered anymore in the mesh layer QCOMPARE( layer.datasetGroupTreeRootItem()->childCount(), 1 ); //dataset group tree item hasn't anymore the item indexes = layer.datasetGroupsIndexes(); @@ -1208,7 +1212,7 @@ void TestQgsMeshLayer::test_reload_extra_dataset() //test dataset presence QCOMPARE( layer.dataProvider()->extraDatasets().count(), 1 ); QCOMPARE( layer.dataProvider()->datasetGroupCount(), 1 ); - QCOMPARE( layer.datasetGroupCount(), 1 ); //dataset not registered anymore in the mesh layer + QCOMPARE( layer.datasetGroupCount(), 1 ); //dataset not registered anymore in the mesh layer QCOMPARE( layer.datasetGroupTreeRootItem()->childCount(), 1 ); //dataset group tree item hasn't anymore the item indexes = layer.datasetGroupsIndexes(); @@ -1226,10 +1230,10 @@ void TestQgsMeshLayer::test_reload_extra_dataset() QCOMPARE( layer.datasetGroupTreeRootItem()->childCount(), 2 ); // Add twice the same file - QVERIFY( layer.addDatasets( testFileDataSet.fileName() ) ); //dataset added + QVERIFY( layer.addDatasets( testFileDataSet.fileName() ) ); //dataset added QCOMPARE( layer.dataProvider()->extraDatasets().count(), 1 ); //uri not dupplicated - QCOMPARE( layer.dataProvider()->datasetGroupCount(), 3 ); //dataset added - QCOMPARE( layer.datasetGroupCount(), 2 ); // meshLayer do not allow dataset group with same name + QCOMPARE( layer.dataProvider()->datasetGroupCount(), 3 ); //dataset added + QCOMPARE( layer.datasetGroupCount(), 2 ); // meshLayer do not allow dataset group with same name QCOMPARE( layer.datasetGroupTreeRootItem()->childCount(), 2 ); indexes = layer.datasetGroupsIndexes(); @@ -1355,16 +1359,16 @@ void TestQgsMeshLayer::test_snap_on_mesh() QCOMPARE( snappedPoint, QgsPointXY() ); snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Vertex, QgsPointXY(), searchRadius ); QCOMPARE( snappedPoint, QgsPointXY() ); - snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Vertex, transform.transform( QgsPointXY( 1002, 2005 ) ), searchRadius ); - QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1000, 2000 ) ) ); - snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Vertex, transform.transform( QgsPointXY( 2002, 2998 ) ), searchRadius ); - QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 2000, 3000 ) ) ); - snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Face, transform.transform( QgsPointXY( 998, 1998 ) ), searchRadius ); - QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1500, 2500 ) ) ); - snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Face, transform.transform( QgsPointXY( 1002, 2001 ) ), searchRadius ); - QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1500, 2500 ) ) ); - snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Face, transform.transform( QgsPointXY( 1998, 2998 ) ), searchRadius ); - QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1500, 2500 ) ) ); + snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Vertex, transform.transform( QgsPointXY( 1002, 2005 ) ), searchRadius ); + QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1000, 2000 ) ) ); + snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Vertex, transform.transform( QgsPointXY( 2002, 2998 ) ), searchRadius ); + QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 2000, 3000 ) ) ); + snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Face, transform.transform( QgsPointXY( 998, 1998 ) ), searchRadius ); + QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1500, 2500 ) ) ); + snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Face, transform.transform( QgsPointXY( 1002, 2001 ) ), searchRadius ); + QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1500, 2500 ) ) ); + snappedPoint = mMdalLayer->snapOnElement( QgsMesh::Face, transform.transform( QgsPointXY( 1998, 2998 ) ), searchRadius ); + QCOMPARE( snappedPoint, transform.transform( QgsPointXY( 1500, 2500 ) ) ); } void TestQgsMeshLayer::test_dataset_value_from_layer() @@ -1396,7 +1400,6 @@ void TestQgsMeshLayer::test_dataset_value_from_layer() QCOMPARE( QgsMeshDatasetValue( 2 ), value ); value = mMdalLayer->datasetValue( QgsMeshDatasetIndex( 4, 1 ), QgsPointXY( 1750, 2250 ) ); QCOMPARE( QgsMeshDatasetValue( 2, 2 ), value ); - } void TestQgsMeshLayer::test_dataset_group_item_tree_item() @@ -1409,11 +1412,7 @@ void TestQgsMeshLayer::test_dataset_group_item_tree_item() QVERIFY( rootItem->childFromDatasetGroupIndex( i )->isEnabled() ); QStringList names; - names << "Bed Elevation" << - "temperature" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums" << - "velocity" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums" << - "water depth" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums" << - "water surface elevation" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums"; + names << "Bed Elevation" << "temperature" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums" << "velocity" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums" << "water depth" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums" << "water surface elevation" << "Maximums" << "Minimums" << "Time at Maximums" << "Time at Minimums"; for ( int i = 0; i < rootItem->totalChildCount(); ++i ) QCOMPARE( rootItem->childFromDatasetGroupIndex( i )->name(), names.at( i ) ); @@ -1527,7 +1526,7 @@ void TestQgsMeshLayer::test_memory_dataset_group() QCOMPARE( mMdalLayer->datasetGroupCount(), 5 ); std::unique_ptr goodDatasetGroupVertices( new QgsMeshMemoryDatasetGroup ); - std::unique_ptr badDatasetGroupVertices( new QgsMeshMemoryDatasetGroup ); + std::unique_ptr badDatasetGroupVertices( new QgsMeshMemoryDatasetGroup ); goodDatasetGroupVertices->setName( QStringLiteral( "good vertices datasets" ) ); goodDatasetGroupVertices->setDataType( QgsMeshDatasetGroupMetadata::DataOnVertices ); badDatasetGroupVertices->setDataType( QgsMeshDatasetGroupMetadata::DataOnVertices ); @@ -1551,7 +1550,8 @@ void TestQgsMeshLayer::test_memory_dataset_group() QCOMPARE( mMdalLayer->extraDatasetGroupCount(), 1 ); std::unique_ptr goodDatasetGroupFaces( - new QgsMeshMemoryDatasetGroup( QStringLiteral( "good faces datasets" ), QgsMeshDatasetGroupMetadata::DataOnFaces ) ); + new QgsMeshMemoryDatasetGroup( QStringLiteral( "good faces datasets" ), QgsMeshDatasetGroupMetadata::DataOnFaces ) + ); std::unique_ptr badDatasetGroupFaces( new QgsMeshMemoryDatasetGroup ); badDatasetGroupFaces->setDataType( QgsMeshDatasetGroupMetadata::DataOnFaces ); for ( int i = 1; i < 10; i++ ) @@ -1586,7 +1586,6 @@ void TestQgsMeshLayer::test_memory_dataset_group() QCOMPARE( mMdalLayer->datasetGroupMetadata( 5 ).name(), QStringLiteral( "good vertices datasets" ) ); QCOMPARE( mMdalLayer->datasetGroupMetadata( 6 ).name(), QStringLiteral( "good faces datasets" ) ); - } void TestQgsMeshLayer::test_memory_dataset_group_1d() @@ -1597,7 +1596,7 @@ void TestQgsMeshLayer::test_memory_dataset_group_1d() QCOMPARE( mMdal1DLayer->datasetGroupCount(), 5 ); std::unique_ptr goodDatasetGroupVertices( new QgsMeshMemoryDatasetGroup ); - std::unique_ptr badDatasetGroupVertices( new QgsMeshMemoryDatasetGroup ); + std::unique_ptr badDatasetGroupVertices( new QgsMeshMemoryDatasetGroup ); goodDatasetGroupVertices->setDataType( QgsMeshDatasetGroupMetadata::DataOnVertices ); badDatasetGroupVertices->setDataType( QgsMeshDatasetGroupMetadata::DataOnVertices ); for ( int i = 1; i < 10; i++ ) @@ -1617,7 +1616,7 @@ void TestQgsMeshLayer::test_memory_dataset_group_1d() QCOMPARE( mMdal1DLayer->datasetGroupCount(), 6 ); std::unique_ptr goodDatasetGroupEdges( new QgsMeshMemoryDatasetGroup ); - std::unique_ptr badDatasetGroupEdges( new QgsMeshMemoryDatasetGroup ); + std::unique_ptr badDatasetGroupEdges( new QgsMeshMemoryDatasetGroup ); goodDatasetGroupEdges->setName( QStringLiteral( "dataset on edges" ) ); goodDatasetGroupEdges->setDataType( QgsMeshDatasetGroupMetadata::DataOnEdges ); badDatasetGroupEdges->setDataType( QgsMeshDatasetGroupMetadata::DataOnEdges ); @@ -1745,7 +1744,7 @@ void TestQgsMeshLayer::test_setDataSource() QCOMPARE( layerWithBadDataSource.datasetGroupTreeRootItem()->child( 0 )->description(), uri ); QCOMPARE( layerWithBadDataSource.datasetGroupTreeRootItem()->child( 1 )->description(), mDataDir + "/quad_and_triangle_vertex_scalar.dat" ); QCOMPARE( layerWithBadDataSource.datasetGroupTreeRootItem()->child( 2 )->description(), mDataDir + "/quad_and_triangle_vertex_vector.dat" ); - QCOMPARE( layerWithBadDataSource.datasetGroupTreeRootItem()->child( 3 )->name(), QStringLiteral( "memory dataset" ) ); + QCOMPARE( layerWithBadDataSource.datasetGroupTreeRootItem()->child( 3 )->name(), QStringLiteral( "memory dataset" ) ); QCOMPARE( layerWithBadDataSource.datasetGroupTreeRootItem()->child( 4 )->description(), mDataDir + "/quad_and_triangle_els_face_scalar.dat" ); layerWithBadDataSource.setDataSource( uri, "Triangle and Quad MDAL", "mdal" ); @@ -1771,7 +1770,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers() QgsProviderMetadata *mdalMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) ); // invalid uri - QList< QgsProviderSublayerDetails >res = mdalMetadata->querySublayers( QString() ); + QList res = mdalMetadata->querySublayers( QString() ); QVERIFY( res.empty() ); // not a mesh @@ -1815,8 +1814,8 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Mesh ); // make sure result is valid to load layer from - const QgsProviderSublayerDetails::LayerOptions options{ QgsCoordinateTransformContext() }; - std::unique_ptr< QgsMeshLayer > ml( qgis::down_cast< QgsMeshLayer * >( res.at( 0 ).toLayer( options ) ) ); + const QgsProviderSublayerDetails::LayerOptions options { QgsCoordinateTransformContext() }; + std::unique_ptr ml( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); // directly query MDAL uri @@ -1828,7 +1827,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "mdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Mesh ); QCOMPARE( res.at( 0 ).driverName(), "2DM" ); - ml.reset( qgis::down_cast< QgsMeshLayer * >( res.at( 0 ).toLayer( options ) ) ); + ml.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); // mesh with two layers @@ -1840,7 +1839,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "mdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Mesh ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "Ugrid" ) ); - ml.reset( qgis::down_cast< QgsMeshLayer * >( res.at( 0 ).toLayer( options ) ) ); + ml.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); QCOMPARE( res.at( 1 ).layerNumber(), 1 ); QCOMPARE( res.at( 1 ).name(), QStringLiteral( "mesh2d" ) ); @@ -1848,7 +1847,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers() QCOMPARE( res.at( 1 ).providerKey(), QStringLiteral( "mdal" ) ); QCOMPARE( res.at( 1 ).type(), Qgis::LayerType::Mesh ); QCOMPARE( res.at( 1 ).driverName(), QStringLiteral( "Ugrid" ) ); - ml.reset( qgis::down_cast< QgsMeshLayer * >( res.at( 1 ).toLayer( options ) ) ); + ml.reset( qgis::down_cast( res.at( 1 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); // mesh with two layers, but uri is for one of these layers only @@ -1860,7 +1859,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "mdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Mesh ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "Ugrid" ) ); - ml.reset( qgis::down_cast< QgsMeshLayer * >( res.at( 0 ).toLayer( options ) ) ); + ml.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); res = mdalMetadata->querySublayers( QStringLiteral( "Ugrid:\"%1/manzese_1d2d_small_map.nc\":mesh2d" ).arg( mDataDir ) ); QCOMPARE( res.count(), 1 ); @@ -1870,7 +1869,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayers() QCOMPARE( res.at( 0 ).providerKey(), QStringLiteral( "mdal" ) ); QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::Mesh ); QCOMPARE( res.at( 0 ).driverName(), QStringLiteral( "Ugrid" ) ); - ml.reset( qgis::down_cast< QgsMeshLayer * >( res.at( 0 ).toLayer( options ) ) ); + ml.reset( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); } @@ -1880,7 +1879,7 @@ void TestQgsMeshLayer::testMdalProviderQuerySublayersFastScan() QgsProviderMetadata *mdalMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) ); // invalid uri - QList< QgsProviderSublayerDetails >res = mdalMetadata->querySublayers( QString(), Qgis::SublayerQueryFlag::FastScan ); + QList res = mdalMetadata->querySublayers( QString(), Qgis::SublayerQueryFlag::FastScan ); QVERIFY( res.empty() ); // not a mesh @@ -1942,18 +1941,18 @@ void TestQgsMeshLayer::testSelectByExpression() QgsExpression expression( QStringLiteral( " $vertex_z > 30" ) ); QList selectedVerticesIndexes = mMdalLayer->selectVerticesByExpression( expression ); - QCOMPARE( selectedVerticesIndexes, QList( {2, 3} ) ); + QCOMPARE( selectedVerticesIndexes, QList( { 2, 3 } ) ); expression = QgsExpression( QStringLiteral( " x($vertex_as_point) > 1500" ) ); selectedVerticesIndexes = mMdalLayer->selectVerticesByExpression( expression ); QCOMPARE( selectedVerticesIndexes.count(), 3 ); - QCOMPARE( selectedVerticesIndexes, QList( {1, 2, 3} ) ); + QCOMPARE( selectedVerticesIndexes, QList( { 1, 2, 3 } ) ); expression = QgsExpression( QStringLiteral( " $face_area > 900000" ) ); QList selectedFacesIndexes = mMdalLayer->selectFacesByExpression( expression ); QCOMPARE( selectedFacesIndexes.count(), 1 ); - QCOMPARE( selectedFacesIndexes, QList( {0} ) ); + QCOMPARE( selectedFacesIndexes, QList( { 0 } ) ); expression = QgsExpression( QStringLiteral( " $face_area > 1100000" ) ); selectedFacesIndexes = mMdalLayer->selectFacesByExpression( expression ); @@ -1966,7 +1965,7 @@ void TestQgsMeshLayer::testSetDataSourceRetainStyle() const QString uri( mDataDir + "/quad_and_triangle.2dm" ); // start with a layer with valid path - std::unique_ptr< QgsMeshLayer > layer = std::make_unique< QgsMeshLayer >( uri, "Triangle and Quad MDAL", "mdal" ); + std::unique_ptr layer = std::make_unique( uri, "Triangle and Quad MDAL", "mdal" ); QVERIFY( layer->isValid() ); // ensure a default renderer is set automatically @@ -1987,7 +1986,7 @@ void TestQgsMeshLayer::testSetDataSourceRetainStyle() settings.setNativeMeshSettings( meshSettings ); // craft a layer with a broken path - layer = std::make_unique< QgsMeshLayer >( QStringLiteral( "yyy" ), "Triangle and Quad MDAL", "mdal" ); + layer = std::make_unique( QStringLiteral( "yyy" ), "Triangle and Quad MDAL", "mdal" ); QVERIFY( !layer->isValid() ); // set some renderer settings layer->setRendererSettings( settings ); @@ -2016,14 +2015,14 @@ void TestQgsMeshLayer::testSetDataSourceRetainStyle() void TestQgsMeshLayer::keepDatasetIndexConsistency() { const QString uri_1( mDataDir + QStringLiteral( "/mesh_z_ws_d_vel.nc" ) ); //mesh with dataset group "Bed Elevation", "Water Level", "Depth" and "Velocity" - const QString uri_2( mDataDir + QStringLiteral( "/mesh_z_ws_d.nc" ) ); //exactly the same mesh except without "Velocity" + const QString uri_2( mDataDir + QStringLiteral( "/mesh_z_ws_d.nc" ) ); //exactly the same mesh except without "Velocity" QTemporaryDir tempDir; const QString uri( tempDir.filePath( QStringLiteral( "mesh.nc" ) ) ); QFile::copy( uri_1, uri ); // start with a layer with valid path - std::unique_ptr< QgsMeshLayer > layer = std::make_unique< QgsMeshLayer >( uri, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); + std::unique_ptr layer = std::make_unique( uri, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); QVERIFY( layer->isValid() ); QCOMPARE( layer->datasetGroupCount(), 4 ); @@ -2107,16 +2106,15 @@ void TestQgsMeshLayer::keepDatasetIndexConsistency() QVERIFY( indexes.contains( vectorIndex ) ); QVERIFY( layer->rendererSettings().activeScalarDatasetGroup() != vectorIndex ); QVERIFY( layer->rendererSettings().activeVectorDatasetGroup() != vectorIndex ); - } void TestQgsMeshLayer::symbologyConsistencyWithName() { const QString uri_1( mDataDir + QStringLiteral( "/mesh_z_ws_d_vel.nc" ) ); //mesh with dataset group "Bed Elevation", "Water level", "Depth" and "Velocity" - const QString uri_2( mDataDir + QStringLiteral( "/mesh_z_ws_d.nc" ) ); //exactly the same mesh except without "Velocity" + const QString uri_2( mDataDir + QStringLiteral( "/mesh_z_ws_d.nc" ) ); //exactly the same mesh except without "Velocity" - std::unique_ptr< QgsMeshLayer > layer_1 = std::make_unique< QgsMeshLayer >( uri_1, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); - std::unique_ptr< QgsMeshLayer > layer_2 = std::make_unique< QgsMeshLayer >( uri_2, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); + std::unique_ptr layer_1 = std::make_unique( uri_1, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); + std::unique_ptr layer_2 = std::make_unique( uri_2, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); QMap nameToindex_1; QList indexes = layer_1->datasetGroupsIndexes(); @@ -2283,14 +2281,14 @@ void TestQgsMeshLayer::test_temporal() void TestQgsMeshLayer::updateTimePropertiesWhenReloading() { const QString uri_1( mDataDir + QStringLiteral( "/mesh_z_ws_d_vel.nc" ) ); //mesh with dataset group "Bed Elevation", "Water Level", "Depth" and "Velocity" - const QString uri_2( mDataDir + QStringLiteral( "/mesh_z_ws_d.nc" ) ); //exactly the same mesh except without "Velocity" and reference time / time extent are different + const QString uri_2( mDataDir + QStringLiteral( "/mesh_z_ws_d.nc" ) ); //exactly the same mesh except without "Velocity" and reference time / time extent are different QTemporaryDir tempDir; const QString uri( tempDir.filePath( QStringLiteral( "mesh.nc" ) ) ); QFile::copy( uri_1, uri ); // start with a layer with valid path - std::unique_ptr< QgsMeshLayer > layer = std::make_unique< QgsMeshLayer >( uri, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); + std::unique_ptr layer = std::make_unique( uri, QStringLiteral( "mesh" ), QStringLiteral( "mdal" ) ); QVERIFY( layer->isValid() ); QgsMeshLayerTemporalProperties *temporalProperties = static_cast( layer->temporalProperties() ); @@ -2349,7 +2347,8 @@ void TestQgsMeshLayer::testHaveSameParentQuantity() QgsMeshLayer layer1( testDataPath( "mesh/netcdf_parent_quantity.nc" ), QStringLiteral( "mesh" ), - QStringLiteral( "mdal" ) ); + QStringLiteral( "mdal" ) + ); QVERIFY( layer1.isValid() ); QVERIFY( QgsMeshLayerUtils::haveSameParentQuantity( &layer1, QgsMeshDatasetIndex( 0 ), QgsMeshDatasetIndex( 1 ) ) ); @@ -2360,7 +2359,8 @@ void TestQgsMeshLayer::testHaveSameParentQuantity() QgsMeshLayer layer2( testDataPath( "mesh/mesh_z_ws_d.nc" ), QStringLiteral( "mesh" ), - QStringLiteral( "mdal" ) ); + QStringLiteral( "mdal" ) + ); QVERIFY( layer2.isValid() ); QVERIFY( !QgsMeshLayerUtils::haveSameParentQuantity( &layer2, QgsMeshDatasetIndex( 0 ), QgsMeshDatasetIndex( 1 ) ) ); diff --git a/tests/src/core/testqgsmeshlayerinterpolator.cpp b/tests/src/core/testqgsmeshlayerinterpolator.cpp index 2635c9d9f41c..9475459fc5ae 100644 --- a/tests/src/core/testqgsmeshlayerinterpolator.cpp +++ b/tests/src/core/testqgsmeshlayerinterpolator.cpp @@ -29,16 +29,17 @@ * \ingroup UnitTests * This is a unit test for the TestQgsMeshLayerInterpolator class */ -class TestQgsMeshLayerInterpolator: public QObject +class TestQgsMeshLayerInterpolator : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testExportRasterBand(); + private: QString mTestDataDir; }; @@ -60,21 +61,20 @@ void TestQgsMeshLayerInterpolator::cleanupTestCase() void TestQgsMeshLayerInterpolator::testExportRasterBand() { - QgsMeshLayer meshLayer( mTestDataDir + "/mesh/quad_and_triangle.2dm", - "Triangle and Quad Mdal", - "mdal" ); + QgsMeshLayer meshLayer( mTestDataDir + "/mesh/quad_and_triangle.2dm", "Triangle and Quad Mdal", "mdal" ); QVERIFY( meshLayer.isValid() ); QgsMeshDatasetIndex index( 0, 0 ); // bed elevation meshLayer.setCrs( QgsCoordinateReferenceSystem::fromEpsgId( 27700 ) ); std::unique_ptr block; block.reset( QgsMeshUtils::exportRasterBlock( - meshLayer, - index, - meshLayer.crs(), - QgsProject::instance()->transformContext(), - 100, - meshLayer.extent() ) ); + meshLayer, + index, + meshLayer.crs(), + QgsProject::instance()->transformContext(), + 100, + meshLayer.extent() + ) ); QVERIFY( block ); @@ -91,7 +91,7 @@ void TestQgsMeshLayerInterpolator::testExportRasterBand() QVERIFY( block->isNoData( 10, 10 ) ); std::unique_ptr virtualGroup = std::make_unique( QStringLiteral( "on face" ), QgsMeshDatasetGroupMetadata::DataOnFaces ); - std::shared_ptr dataset = std::make_shared < QgsMeshMemoryDataset>(); + std::shared_ptr dataset = std::make_shared(); dataset->values.resize( 2 ); dataset->values[0] = 12; dataset->values[1] = 36; @@ -109,12 +109,13 @@ void TestQgsMeshLayerInterpolator::testExportRasterBand() index = QgsMeshDatasetIndex( 1, 0 ); block.reset( QgsMeshUtils::exportRasterBlock( - meshLayer, - index, - meshLayer.crs(), - QgsProject::instance()->transformContext(), - 100, - meshLayer.extent() ) ); + meshLayer, + index, + meshLayer.crs(), + QgsProject::instance()->transformContext(), + 100, + meshLayer.extent() + ) ); QVERIFY( block ); diff --git a/tests/src/core/testqgsmeshlayerrenderer.cpp b/tests/src/core/testqgsmeshlayerrenderer.cpp index 8c3cb3692d40..0a00cfe73d81 100644 --- a/tests/src/core/testqgsmeshlayerrenderer.cpp +++ b/tests/src/core/testqgsmeshlayerrenderer.cpp @@ -44,7 +44,8 @@ class TestQgsMeshRenderer : public QgsTest Q_OBJECT public: - TestQgsMeshRenderer() : QgsTest( QStringLiteral( "Mesh Layer Rendering Tests" ), QStringLiteral( "mesh" ) ) {} + TestQgsMeshRenderer() + : QgsTest( QStringLiteral( "Mesh Layer Rendering Tests" ), QStringLiteral( "mesh" ) ) {} private: QString mDataDir; @@ -55,9 +56,9 @@ class TestQgsMeshRenderer : public QgsTest QgsMapSettings *mMapSettings = nullptr; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. QString readFile( const QString &fname ) const; void test_native_mesh_rendering(); @@ -174,9 +175,11 @@ void TestQgsMeshRenderer::initTestCase() // Add layers QgsProject::instance()->addMapLayers( - QList() << mMemory1DLayer << mMemoryLayer << mMdalLayer << mMdal3DLayer ); + QList() << mMemory1DLayer << mMemoryLayer << mMdalLayer << mMdal3DLayer + ); mMapSettings->setLayers( - QList() << mMemory1DLayer << mMemoryLayer << mMdalLayer << mMdal3DLayer ); + QList() << mMemory1DLayer << mMemoryLayer << mMdalLayer << mMdal3DLayer + ); // here we check that datasets automatically get our default color ramp applied ("Plasma") QgsMeshDatasetIndex ds( 0, 0 ); @@ -184,8 +187,8 @@ void TestQgsMeshRenderer::initTestCase() QgsColorRampShader shader = scalarSettings.colorRampShader(); QList lst = shader.colorRampItemList(); QCOMPARE( lst.count(), 52 ); - QCOMPARE( lst.at( 0 ).value, 1. ); // min group value - QCOMPARE( lst.at( lst.count() - 1 ).value, 4. ); // max group value + QCOMPARE( lst.at( 0 ).value, 1. ); // min group value + QCOMPARE( lst.at( lst.count() - 1 ).value, 4. ); // max group value ds = QgsMeshDatasetIndex( 1, 0 ); const QgsMeshRendererVectorSettings vectorSettings = mMemoryLayer->rendererSettings().vectorSettings( ds.group() ); @@ -193,7 +196,7 @@ void TestQgsMeshRenderer::initTestCase() lst = shader.colorRampItemList(); QCOMPARE( lst.count(), 52 ); QVERIFY( fabs( lst.at( 0 ).value - 1.41421356237 ) < 0.000001 ); // min group value - QCOMPARE( lst.at( lst.count() - 1 ).value, 5. ); // max group value + QCOMPARE( lst.at( lst.count() - 1 ).value, 5. ); // max group value } void TestQgsMeshRenderer::cleanupTestCase() @@ -251,7 +254,7 @@ void TestQgsMeshRenderer::test_native_mesh_renderingWithClipping() mMapSettings->setOutputDpi( 96 ); mMapSettings->setRotation( 0 ); QGSVERIFYRENDERMAPSETTINGSCHECK( "painterclip_region", "painterclip_region", *mMapSettings, 0, 15 ); - mMapSettings->setClippingRegions( QList< QgsMapClippingRegion >() ); + mMapSettings->setClippingRegions( QList() ); } void TestQgsMeshRenderer::test_triangular_mesh_rendering() diff --git a/tests/src/core/testqgsmimedatautils.cpp b/tests/src/core/testqgsmimedatautils.cpp index fe7becd2c137..6cfc3201c802 100644 --- a/tests/src/core/testqgsmimedatautils.cpp +++ b/tests/src/core/testqgsmimedatautils.cpp @@ -24,21 +24,20 @@ const QString TEST_ENCODED_DATA( "raster:wms:A Fancy WMS From Ciriè City:crs=EPSG\\:2036&dpiMode=7&format=image/png&layers=lidar&styles=default" "&url=https\\://geoegl.msp.gouv.qc.:EPSG\\\\:2036\\:EPSG\\\\:3857:image/tiff\\:image/jpeg:::PointZ:/home/me/my data.jpg" ); -class TestQgsMimeDataUtils: public QObject +class TestQgsMimeDataUtils : public QObject { Q_OBJECT public: TestQgsMimeDataUtils() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testEncodeDecode(); void testLayerFromProject(); - }; @@ -46,7 +45,6 @@ void TestQgsMimeDataUtils::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsMimeDataUtils::cleanupTestCase() @@ -65,12 +63,11 @@ void TestQgsMimeDataUtils::cleanup() void TestQgsMimeDataUtils::testEncodeDecode() { - QgsMimeDataUtils::Uri uri; uri.layerType = QStringLiteral( "raster" ); uri.name = QStringLiteral( "A Fancy WMS From Ciriè City" ); uri.providerKey = QStringLiteral( "wms" ); - uri.supportedCrs << QStringLiteral( "EPSG:2036" ) << QStringLiteral( "EPSG:3857" ) ; + uri.supportedCrs << QStringLiteral( "EPSG:2036" ) << QStringLiteral( "EPSG:3857" ); uri.supportedFormats << QStringLiteral( "image/tiff" ) << QStringLiteral( "image/jpeg" ); uri.uri = QStringLiteral( "crs=EPSG:2036&dpiMode=7&format=image/png&layers=lidar&styles=default&url=https://geoegl.msp.gouv.qc." ); uri.wkbType = Qgis::WkbType::PointZ; @@ -81,7 +78,7 @@ void TestQgsMimeDataUtils::testEncodeDecode() QgsMimeDataUtils::UriList uriList; uriList << uri; - QMimeData *mimeData = QgsMimeDataUtils::encodeUriList( uriList ); + QMimeData *mimeData = QgsMimeDataUtils::encodeUriList( uriList ); const QgsMimeDataUtils::Uri uriDecoded( QgsMimeDataUtils::decodeUriList( mimeData ).at( 0 ) ); @@ -186,5 +183,3 @@ void TestQgsMimeDataUtils::testLayerFromProject() QGSTEST_MAIN( TestQgsMimeDataUtils ) #include "testqgsmimedatautils.moc" - - diff --git a/tests/src/core/testqgsnetworkaccessmanager.cpp b/tests/src/core/testqgsnetworkaccessmanager.cpp index ee2be6dc264f..678ce0eae25d 100644 --- a/tests/src/core/testqgsnetworkaccessmanager.cpp +++ b/tests/src/core/testqgsnetworkaccessmanager.cpp @@ -35,8 +35,7 @@ class BackgroundRequest : public QThread : mRequest( request ) { moveToThread( this ); - connect( this, &QThread::started, this, [ = ] - { + connect( this, &QThread::started, this, [=] { QVERIFY( QThread::currentThread() != QCoreApplication::instance()->thread() ); switch ( op ) { @@ -51,11 +50,11 @@ class BackgroundRequest : public QThread default: break; } - } ); } QNetworkReply *mReply = nullptr; + private: QNetworkRequest mRequest; }; @@ -66,14 +65,12 @@ class BackgroundBlockingRequest : public QThread Q_OBJECT public: - BackgroundBlockingRequest( const QNetworkRequest &request, QNetworkAccessManager::Operation op = QNetworkAccessManager::GetOperation, - QNetworkReply::NetworkError expectedRes = QNetworkReply::NoError, const QByteArray &data = QByteArray(), const QByteArray &expectedData = QByteArray() ) + BackgroundBlockingRequest( const QNetworkRequest &request, QNetworkAccessManager::Operation op = QNetworkAccessManager::GetOperation, QNetworkReply::NetworkError expectedRes = QNetworkReply::NoError, const QByteArray &data = QByteArray(), const QByteArray &expectedData = QByteArray() ) : mRequest( request ) , mExpectedData( expectedData ) { moveToThread( this ); - connect( this, &QThread::started, this, [ = ] - { + connect( this, &QThread::started, this, [=] { QVERIFY( QThread::currentThread() != QCoreApplication::instance()->thread() ); switch ( op ) { @@ -92,11 +89,11 @@ class BackgroundBlockingRequest : public QThread QCOMPARE( mReply.error(), expectedRes ); if ( !mExpectedData.isEmpty() ) QVERIFY( mReply.content().contains( mExpectedData ) ); - } ); } QgsNetworkReplyContent mReply; + private: QNetworkRequest mRequest; QByteArray mExpectedData; @@ -105,20 +102,17 @@ class BackgroundBlockingRequest : public QThread class TestSslErrorHandler : public QgsSslErrorHandler { public: - void handleSslErrors( QNetworkReply *reply, const QList &errors ) override { Q_ASSERT( QThread::currentThread() == QApplication::instance()->thread() ); QCOMPARE( errors.at( 0 ).error(), QSslError::SelfSignedCertificate ); reply->ignoreSslErrors(); } - }; class TestAuthRequestHandler : public QgsNetworkAuthenticationHandler { public: - TestAuthRequestHandler( const QString &user, const QString &password ) : mUser( user ) , mPassword( password ) @@ -135,7 +129,6 @@ class TestAuthRequestHandler : public QgsNetworkAuthenticationHandler QString mUser; QString mPassword; - }; class TestQgsNetworkAccessManager : public QgsTest @@ -147,13 +140,13 @@ class TestQgsNetworkAccessManager : public QgsTest {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testRequestPreprocessor(); - void fetchEmptyUrl(); //test fetching blank url - void fetchBadUrl(); //test fetching bad url + void fetchEmptyUrl(); //test fetching blank url + void fetchBadUrl(); //test fetching bad url void fetchEncodedContent(); //test fetching url content encoded as utf-8 void fetchPost(); void fetchPostMultiPart(); @@ -167,9 +160,7 @@ class TestQgsNetworkAccessManager : public QgsTest void testHandlers(); private: - QString mHttpBinHost; - }; void TestQgsNetworkAccessManager::initTestCase() @@ -197,7 +188,6 @@ void TestQgsNetworkAccessManager::cleanupTestCase() void TestQgsNetworkAccessManager::init() { - } void TestQgsNetworkAccessManager::cleanup() @@ -223,42 +213,38 @@ void TestQgsNetworkAccessManager::testProxyExcludeList() QgsNetworkAccessManager::instance()->setFallbackProxyAndExcludes( fallback, QStringList() << QStringLiteral( "intranet" ) << "", QStringList() << QStringLiteral( "noProxy" ) ); QList proxies = QgsNetworkAccessManager::instance()->proxyFactory()->queryProxy( QNetworkProxyQuery( QUrl( "intranet/mystuff" ) ) ); QCOMPARE( proxies.count(), 1 ); - QCOMPARE( proxies.at( 0 ).type(), QNetworkProxy::DefaultProxy ); + QCOMPARE( proxies.at( 0 ).type(), QNetworkProxy::DefaultProxy ); proxies = QgsNetworkAccessManager::instance()->proxyFactory()->queryProxy( QNetworkProxyQuery( QUrl( "noProxy/mystuff" ) ) ); QCOMPARE( proxies.count(), 1 ); - QCOMPARE( proxies.at( 0 ).type(), QNetworkProxy::NoProxy ); + QCOMPARE( proxies.at( 0 ).type(), QNetworkProxy::NoProxy ); } class DummySslErrorHandler : public QgsSslErrorHandler { - public: - }; class DummyNetworkAuthenticationHandler : public QgsNetworkAuthenticationHandler { - public: - }; void TestQgsNetworkAccessManager::testHandlers() { - QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique< DummySslErrorHandler >() ); - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< DummyNetworkAuthenticationHandler >() ); + QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique() ); + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique() ); - QVERIFY( dynamic_cast< DummySslErrorHandler * >( QgsNetworkAccessManager::instance()->mSslErrorHandler.get() ) ); - QVERIFY( dynamic_cast< DummyNetworkAuthenticationHandler * >( QgsNetworkAccessManager::instance()->mAuthHandler.get() ) ); + QVERIFY( dynamic_cast( QgsNetworkAccessManager::instance()->mSslErrorHandler.get() ) ); + QVERIFY( dynamic_cast( QgsNetworkAccessManager::instance()->mAuthHandler.get() ) ); // handlers should NOT be overwritten QgsNetworkAccessManager::instance()->setupDefaultProxyAndCache(); - QVERIFY( dynamic_cast< DummySslErrorHandler * >( QgsNetworkAccessManager::instance()->mSslErrorHandler.get() ) ); - QVERIFY( dynamic_cast< DummyNetworkAuthenticationHandler * >( QgsNetworkAccessManager::instance()->mAuthHandler.get() ) ); + QVERIFY( dynamic_cast( QgsNetworkAccessManager::instance()->mSslErrorHandler.get() ) ); + QVERIFY( dynamic_cast( QgsNetworkAccessManager::instance()->mAuthHandler.get() ) ); - QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique< QgsSslErrorHandler >() ); - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< QgsNetworkAuthenticationHandler >() ); + QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique() ); + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique() ); } void TestQgsNetworkAccessManager::fetchEmptyUrl() @@ -268,16 +254,14 @@ void TestQgsNetworkAccessManager::fetchEmptyUrl() bool loaded = false; bool gotRequestAboutToBeCreatedSignal = false; int requestId = -1; - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); QCOMPARE( params.operation(), QNetworkAccessManager::GetOperation ); QCOMPARE( params.request().url(), QUrl() ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.errorString(), QStringLiteral( "Protocol \"\" is unknown" ) ); QCOMPARE( reply.requestId(), requestId ); QCOMPARE( reply.request().url(), QUrl() ); @@ -296,7 +280,7 @@ void TestQgsNetworkAccessManager::fetchEmptyUrl() loaded = false; // blocking request - QNetworkRequest req{ QUrl() }; + QNetworkRequest req { QUrl() }; const QgsNetworkReplyContent rep = QgsNetworkAccessManager::blockingGet( req ); QCOMPARE( rep.errorString(), QStringLiteral( "Protocol \"\" is unknown" ) ); while ( !loaded ) @@ -346,16 +330,14 @@ void TestQgsNetworkAccessManager::fetchBadUrl() bool loaded = false; bool gotRequestAboutToBeCreatedSignal = false; int requestId = -1; - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); QCOMPARE( params.operation(), QNetworkAccessManager::GetOperation ); QCOMPARE( params.request().url(), QUrl( QStringLiteral( "http://x" ) ) ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.errorString(), QStringLiteral( "Host x not found" ) ); QCOMPARE( reply.requestId(), requestId ); QCOMPARE( reply.request().url(), QUrl( QStringLiteral( "http://x" ) ) ); @@ -374,7 +356,7 @@ void TestQgsNetworkAccessManager::fetchBadUrl() loaded = false; // blocking request - QNetworkRequest req{ QUrl( QStringLiteral( "http://x" ) ) }; + QNetworkRequest req { QUrl( QStringLiteral( "http://x" ) ) }; const QgsNetworkReplyContent rep = QgsNetworkAccessManager::blockingGet( req ); QCOMPARE( rep.errorString(), QStringLiteral( "Host x not found" ) ); while ( !loaded ) @@ -424,9 +406,8 @@ void TestQgsNetworkAccessManager::fetchEncodedContent() bool loaded = false; bool gotRequestAboutToBeCreatedSignal = false; int requestId = -1; - QUrl u = QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + '/' + "encoded_html.html" ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + QUrl u = QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + '/' + "encoded_html.html" ); + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); @@ -435,8 +416,7 @@ void TestQgsNetworkAccessManager::fetchEncodedContent() QCOMPARE( params.initiatorClassName(), QStringLiteral( "myTestClass" ) ); QCOMPARE( params.initiatorRequestId().toInt(), 55 ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.error(), QNetworkReply::NoError ); QCOMPARE( reply.requestId(), requestId ); QVERIFY( reply.rawHeaderList().contains( "Content-Length" ) ); @@ -444,8 +424,8 @@ void TestQgsNetworkAccessManager::fetchEncodedContent() loaded = true; } ); QNetworkRequest r( u ); - r.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorClass ), QStringLiteral( "myTestClass" ) ); - r.setAttribute( static_cast< QNetworkRequest::Attribute >( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), 55 ); + r.setAttribute( static_cast( QgsNetworkRequestParameters::AttributeInitiatorClass ), QStringLiteral( "myTestClass" ) ); + r.setAttribute( static_cast( QgsNetworkRequestParameters::AttributeInitiatorRequestId ), 55 ); QgsNetworkAccessManager::instance()->get( r ); while ( !loaded ) @@ -487,7 +467,7 @@ void TestQgsNetworkAccessManager::fetchEncodedContent() gotRequestAboutToBeCreatedSignal = false; loaded = false; - BackgroundBlockingRequest *blockingThread = new BackgroundBlockingRequest( r, QNetworkAccessManager::GetOperation, QNetworkReply::NoError, QByteArray(), "test" ); + BackgroundBlockingRequest *blockingThread = new BackgroundBlockingRequest( r, QNetworkAccessManager::GetOperation, QNetworkReply::NoError, QByteArray(), "test" ); blockingThread->start(); while ( !loaded ) { @@ -506,13 +486,12 @@ void TestQgsNetworkAccessManager::fetchPost() bool loaded = false; bool gotRequestAboutToBeCreatedSignal = false; int requestId = -1; - QUrl u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/post" ) ); + QUrl u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/post" ) ); QNetworkRequest req( u ); req.setHeader( QNetworkRequest::ContentTypeHeader, QStringLiteral( "application/x-www-form-urlencoded" ) ); QString replyContent; - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); @@ -520,8 +499,7 @@ void TestQgsNetworkAccessManager::fetchPost() QCOMPARE( params.request().url(), u ); QCOMPARE( params.content(), QByteArray( "a=b&c=d" ) ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.error(), QNetworkReply::NoError ); QCOMPARE( reply.requestId(), requestId ); QVERIFY( reply.rawHeaderList().contains( "Content-Type" ) ); @@ -580,7 +558,7 @@ void TestQgsNetworkAccessManager::fetchPost() loaded = false; req.setHeader( QNetworkRequest::ContentTypeHeader, QStringLiteral( "application/x-www-form-urlencoded" ) ); - BackgroundBlockingRequest *blockingThread = new BackgroundBlockingRequest( req, QNetworkAccessManager::PostOperation, QNetworkReply::NoError, QByteArray( "a=b&c=d" ), "\"a\": \"b\"" ); + BackgroundBlockingRequest *blockingThread = new BackgroundBlockingRequest( req, QNetworkAccessManager::PostOperation, QNetworkReply::NoError, QByteArray( "a=b&c=d" ), "\"a\": \"b\"" ); blockingThread->start(); while ( !loaded ) { @@ -595,12 +573,11 @@ void TestQgsNetworkAccessManager::fetchPost() void TestQgsNetworkAccessManager::fetchPostMultiPart() { QFETCH( int, iContentType ); - QHttpMultiPart::ContentType contentType = static_cast< QHttpMultiPart::ContentType>( iContentType ); + QHttpMultiPart::ContentType contentType = static_cast( iContentType ); QHttpMultiPart *multipart = new QHttpMultiPart( contentType ); QHttpPart part; - part.setHeader( QNetworkRequest::ContentDispositionHeader, - QStringLiteral( "form-data; name=\"param\"" ) ); - part.setBody( QStringLiteral( "some data" ) .toUtf8() ); + part.setHeader( QNetworkRequest::ContentDispositionHeader, QStringLiteral( "form-data; name=\"param\"" ) ); + part.setBody( QStringLiteral( "some data" ).toUtf8() ); multipart->append( part ); QUrl u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/post" ) ); QNetworkRequest req( u ); @@ -642,29 +619,25 @@ void TestQgsNetworkAccessManager::fetchBadSsl() bool gotSslError = false; bool gotRequestEncounteredSslError = false; int requestId = -1; - QUrl u = QUrl( QStringLiteral( "https://expired.badssl.com" ) ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + QUrl u = QUrl( QStringLiteral( "https://expired.badssl.com" ) ); + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); QCOMPARE( params.operation(), QNetworkAccessManager::GetOperation ); QCOMPARE( params.request().url(), u ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.error(), QNetworkReply::SslHandshakeFailedError ); QCOMPARE( reply.requestId(), requestId ); QCOMPARE( reply.request().url(), u ); loaded = true; } ); - connect( QgsNetworkAccessManager::instance(), &QNetworkAccessManager::sslErrors, &context, [&]( QNetworkReply *, const QList &errors ) - { + connect( QgsNetworkAccessManager::instance(), &QNetworkAccessManager::sslErrors, &context, [&]( QNetworkReply *, const QList &errors ) { QCOMPARE( errors.at( 0 ).error(), QSslError::CertificateExpired ); gotSslError = true; } ); - connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestEncounteredSslErrors, &context, [&]( int errorRequestId, const QList &errors ) - { + connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestEncounteredSslErrors, &context, [&]( int errorRequestId, const QList &errors ) { QCOMPARE( errors.at( 0 ).error(), QSslError::CertificateExpired ); QCOMPARE( errorRequestId, requestId ); gotRequestEncounteredSslError = true; @@ -684,9 +657,9 @@ void TestQgsNetworkAccessManager::fetchBadSsl() loaded = false; gotSslError = false; gotRequestEncounteredSslError = false; - QNetworkRequest req{ u }; + QNetworkRequest req { u }; const QgsNetworkReplyContent rep = QgsNetworkAccessManager::blockingGet( req ); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) QCOMPARE( rep.errorString(), QStringLiteral( "SSL handshake failed" ) ); #else QCOMPARE( rep.errorString(), QStringLiteral( "SSL handshake failed: The certificate has expired" ) ); @@ -731,7 +704,6 @@ void TestQgsNetworkAccessManager::fetchBadSsl() blockingThread->exit(); blockingThread->wait(); blockingThread->deleteLater(); - } void TestQgsNetworkAccessManager::testSslErrorHandler() @@ -741,7 +713,7 @@ void TestQgsNetworkAccessManager::testSslErrorHandler() QSKIP( "badssl.com service is not reliable enough for use on CI" ); } - QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique< TestSslErrorHandler >() ); + QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique() ); const QObject context; //test fetching from a blank url @@ -750,29 +722,25 @@ void TestQgsNetworkAccessManager::testSslErrorHandler() bool gotSslError = false; int requestId = -1; bool gotRequestEncounteredSslError = false; - QUrl u = QUrl( QStringLiteral( "https://self-signed.badssl.com/" ) ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + QUrl u = QUrl( QStringLiteral( "https://self-signed.badssl.com/" ) ); + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); QCOMPARE( params.operation(), QNetworkAccessManager::GetOperation ); QCOMPARE( params.request().url(), u ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.error(), QNetworkReply::NoError ); // because handler ignores error QCOMPARE( reply.requestId(), requestId ); QCOMPARE( reply.request().url(), u ); loaded = true; } ); - connect( QgsNetworkAccessManager::instance(), &QNetworkAccessManager::sslErrors, &context, [&]( QNetworkReply *, const QList &errors ) - { + connect( QgsNetworkAccessManager::instance(), &QNetworkAccessManager::sslErrors, &context, [&]( QNetworkReply *, const QList &errors ) { QCOMPARE( errors.at( 0 ).error(), QSslError::SelfSignedCertificate ); gotSslError = true; } ); - connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestEncounteredSslErrors, &context, [&]( int errorRequestId, const QList &errors ) - { + connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestEncounteredSslErrors, &context, [&]( int errorRequestId, const QList &errors ) { QCOMPARE( errors.at( 0 ).error(), QSslError::SelfSignedCertificate ); QCOMPARE( errorRequestId, requestId ); gotRequestEncounteredSslError = true; @@ -792,7 +760,7 @@ void TestQgsNetworkAccessManager::testSslErrorHandler() loaded = false; gotSslError = false; gotRequestEncounteredSslError = false; - QNetworkRequest req{ u }; + QNetworkRequest req { u }; const QgsNetworkReplyContent rep = QgsNetworkAccessManager::blockingGet( req ); QCOMPARE( rep.error(), QNetworkReply::NoError ); QVERIFY( rep.content().contains( "" ) ); @@ -837,13 +805,13 @@ void TestQgsNetworkAccessManager::testSslErrorHandler() blockingThread->wait(); blockingThread->deleteLater(); - QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique< QgsSslErrorHandler >() ); + QgsNetworkAccessManager::instance()->setSslErrorHandler( std::make_unique() ); } void TestQgsNetworkAccessManager::testAuthRequestHandler() { // initially this request should fail -- we aren't providing the username and password required - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< TestAuthRequestHandler >( QString(), QString() ) ); + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique( QString(), QString() ) ); const QObject context; bool loaded = false; @@ -854,34 +822,30 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() QString expectedUser; QString expectedPassword; int requestId = -1; - QUrl u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); + QUrl u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); QNetworkReply::NetworkError expectedError = QNetworkReply::NoError; - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); QCOMPARE( params.operation(), QNetworkAccessManager::GetOperation ); QCOMPARE( params.request().url(), u ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { QCOMPARE( reply.error(), expectedError ); QCOMPARE( reply.requestId(), requestId ); QCOMPARE( reply.request().url(), u ); loaded = true; } ); - connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestRequiresAuth, &context, [&]( int authRequestId, const QString & realm ) - { + connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestRequiresAuth, &context, [&]( int authRequestId, const QString &realm ) { QCOMPARE( authRequestId, requestId ); QCOMPARE( realm, QStringLiteral( "Fake Realm" ) ); gotAuthRequest = true; } ); - connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestAuthDetailsAdded, &context, [&]( int authRequestId, const QString & realm, const QString & user, const QString & password ) - { + connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestAuthDetailsAdded, &context, [&]( int authRequestId, const QString &realm, const QString &user, const QString &password ) { QCOMPARE( authRequestId, requestId ); QCOMPARE( realm, QStringLiteral( "Fake Realm" ) ); QCOMPARE( user, expectedUser ); @@ -901,13 +865,13 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() // blocking request hash = QUuid::createUuid().toString().mid( 1, 10 ); - u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); + u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); loaded = false; gotAuthRequest = false; gotRequestAboutToBeCreatedSignal = false; gotAuthDetailsAdded = false; - QNetworkRequest req{ u }; + QNetworkRequest req { u }; QgsNetworkReplyContent rep = QgsNetworkAccessManager::blockingGet( req ); QVERIFY( rep.content().isEmpty() ); while ( !loaded ) @@ -923,7 +887,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() gotRequestAboutToBeCreatedSignal = false; gotAuthDetailsAdded = false; hash = QUuid::createUuid().toString().mid( 1, 10 ); - u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); + u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); BackgroundRequest *thread = new BackgroundRequest( QNetworkRequest( u ) ); @@ -945,7 +909,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() gotRequestAboutToBeCreatedSignal = false; gotAuthDetailsAdded = false; hash = QUuid::createUuid().toString().mid( 1, 10 ); - u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); + u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); req = QNetworkRequest( u ); BackgroundBlockingRequest *blockingThread = new BackgroundBlockingRequest( req, QNetworkAccessManager::GetOperation, expectedError ); blockingThread->start(); @@ -960,8 +924,8 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() // try with username and password specified hash = QUuid::createUuid().toString().mid( 1, 10 ); - u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< TestAuthRequestHandler >( QStringLiteral( "me" ), hash ) ); + u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique( QStringLiteral( "me" ), hash ) ); loaded = false; gotAuthRequest = false; gotRequestAboutToBeCreatedSignal = false; @@ -972,7 +936,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() QgsNetworkAccessManager::instance()->get( QNetworkRequest( u ) ); - while ( !loaded || !gotAuthRequest || !gotRequestAboutToBeCreatedSignal || !gotAuthDetailsAdded ) + while ( !loaded || !gotAuthRequest || !gotRequestAboutToBeCreatedSignal || !gotAuthDetailsAdded ) { qApp->processEvents(); } @@ -984,9 +948,9 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() gotAuthDetailsAdded = false; hash = QUuid::createUuid().toString().mid( 1, 10 ); expectedPassword = hash; - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< TestAuthRequestHandler >( QStringLiteral( "me" ), hash ) ); - u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); - req = QNetworkRequest{ u }; + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique( QStringLiteral( "me" ), hash ) ); + u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me/" ) + hash ); + req = QNetworkRequest { u }; rep = QgsNetworkAccessManager::blockingGet( req ); QVERIFY( rep.content().contains( "\"user\": \"me\"" ) ); while ( !loaded ) @@ -998,7 +962,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() // correct username and password, in a thread hash = QUuid::createUuid().toString().mid( 1, 10 ); - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< TestAuthRequestHandler >( QStringLiteral( "me2" ), hash ) ); + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique( QStringLiteral( "me2" ), hash ) ); u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me2/" ) + hash ); loaded = false; gotAuthRequest = false; @@ -1022,7 +986,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() // blocking request in worker thread hash = QUuid::createUuid().toString().mid( 1, 10 ); - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< TestAuthRequestHandler >( QStringLiteral( "me2" ), hash ) ); + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique( QStringLiteral( "me2" ), hash ) ); u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/basic-auth/me2/" ) + hash ); loaded = false; gotAuthRequest = false; @@ -1031,8 +995,8 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() expectedError = QNetworkReply::NoError; expectedUser = QStringLiteral( "me2" ); expectedPassword = hash; - req = QNetworkRequest{ u }; - blockingThread = new BackgroundBlockingRequest( req, QNetworkAccessManager::GetOperation, QNetworkReply::NoError, QByteArray(), "\"user\": \"me2\"" ); + req = QNetworkRequest { u }; + blockingThread = new BackgroundBlockingRequest( req, QNetworkAccessManager::GetOperation, QNetworkReply::NoError, QByteArray(), "\"user\": \"me2\"" ); blockingThread->start(); while ( !loaded ) { @@ -1043,7 +1007,7 @@ void TestQgsNetworkAccessManager::testAuthRequestHandler() blockingThread->wait(); blockingThread->deleteLater(); - QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique< QgsNetworkAuthenticationHandler >() ); + QgsNetworkAccessManager::instance()->setAuthHandler( std::make_unique() ); } void TestQgsNetworkAccessManager::fetchTimeout() @@ -1058,22 +1022,19 @@ void TestQgsNetworkAccessManager::fetchTimeout() bool gotTimeoutError = false; bool finished = false; int requestId = -1; - QUrl u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/delay/10" ) ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters & params ) - { + QUrl u = QUrl( QStringLiteral( "http://" ) + mHttpBinHost + QStringLiteral( "/delay/10" ) ); + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestAboutToBeCreated ), &context, [&]( const QgsNetworkRequestParameters ¶ms ) { gotRequestAboutToBeCreatedSignal = true; requestId = params.requestId(); QVERIFY( requestId > 0 ); QCOMPARE( params.operation(), QNetworkAccessManager::GetOperation ); QCOMPARE( params.request().url(), u ); } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestTimedOut ), &context, [&]( const QgsNetworkRequestParameters & request ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::requestTimedOut ), &context, [&]( const QgsNetworkRequestParameters &request ) { QCOMPARE( request.requestId(), requestId ); gotTimeoutError = true; } ); - connect( QgsNetworkAccessManager::instance(), qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent & reply ) - { + connect( QgsNetworkAccessManager::instance(), qOverload( &QgsNetworkAccessManager::finished ), &context, [&]( const QgsNetworkReplyContent &reply ) { finished = reply.error() != QNetworkReply::OperationCanceledError; // should not happen! } ); @@ -1092,7 +1053,7 @@ void TestQgsNetworkAccessManager::fetchTimeout() gotRequestAboutToBeCreatedSignal = false; gotTimeoutError = false; finished = false; - QNetworkRequest req = QNetworkRequest{ u }; + QNetworkRequest req = QNetworkRequest { u }; const QgsNetworkReplyContent rep = QgsNetworkAccessManager::blockingGet( req ); QCOMPARE( rep.errorString(), QStringLiteral( "Operation canceled" ) ); while ( !gotTimeoutError ) @@ -1127,7 +1088,7 @@ void TestQgsNetworkAccessManager::fetchTimeout() gotRequestAboutToBeCreatedSignal = false; gotTimeoutError = false; finished = false; - req = QNetworkRequest{ u }; + req = QNetworkRequest { u }; BackgroundBlockingRequest *blockingThread = new BackgroundBlockingRequest( req, QNetworkAccessManager::GetOperation, QNetworkReply::OperationCanceledError ); blockingThread->start(); while ( !gotTimeoutError ) @@ -1145,11 +1106,13 @@ class FunctionThread : public QThread { Q_OBJECT public: - FunctionThread( const std::function &f ) : m_f( f ), m_result( false ) {} + FunctionThread( const std::function &f ) + : m_f( f ), m_result( false ) {} bool getResult() const { return m_result; } + private: std::function m_f; bool m_result; @@ -1165,10 +1128,10 @@ void TestQgsNetworkAccessManager::testCookieManagement() const QUrl url( "http://example.com" ); // Set cookie in a thread and verify that it also set in main thread QEventLoop evLoop; - FunctionThread thread1( [ = ] - { + FunctionThread thread1( [=] { QgsNetworkAccessManager::instance()->cookieJar()->setCookiesFromUrl( - QList() << QNetworkCookie( "foo=bar" ), url ); + QList() << QNetworkCookie( "foo=bar" ), url + ); return true; } ); QObject::connect( &thread1, &QThread::finished, &evLoop, &QEventLoop::quit ); @@ -1188,8 +1151,7 @@ void TestQgsNetworkAccessManager::testCookieManagement() QList() << QNetworkCookie( "baz=yadda" ), url ); - FunctionThread thread2( [ = ] - { + FunctionThread thread2( [=] { QList cookies = QgsNetworkAccessManager::instance()->cookieJar()->cookiesForUrl( url ); return cookies.size() == 1 && cookies[0].toRawForm() == "baz=yadda=; domain=example.com; path=/"; } ); @@ -1201,7 +1163,7 @@ void TestQgsNetworkAccessManager::testCookieManagement() void TestQgsNetworkAccessManager::testRequestPreprocessor() { - const QString processorId = QgsNetworkAccessManager::setRequestPreprocessor( []( QNetworkRequest * request ) { request->setHeader( QNetworkRequest::UserAgentHeader, QStringLiteral( "QGIS" ) );} ); + const QString processorId = QgsNetworkAccessManager::setRequestPreprocessor( []( QNetworkRequest *request ) { request->setHeader( QNetworkRequest::UserAgentHeader, QStringLiteral( "QGIS" ) ); } ); QNetworkRequest request; QgsNetworkAccessManager::instance()->preprocessRequest( &request ); const QString userAgent = request.header( QNetworkRequest::UserAgentHeader ).toString(); diff --git a/tests/src/core/testqgsnetworkcontentfetcher.cpp b/tests/src/core/testqgsnetworkcontentfetcher.cpp index b58997197b1f..9376ea889e3a 100644 --- a/tests/src/core/testqgsnetworkcontentfetcher.cpp +++ b/tests/src/core/testqgsnetworkcontentfetcher.cpp @@ -28,18 +28,18 @@ class TestQgsNetworkContentFetcher : public QObject TestQgsNetworkContentFetcher() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void fetchEmptyUrl(); //test fetching blank url - void fetchBadUrl(); //test fetching bad url + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void fetchEmptyUrl(); //test fetching blank url + void fetchBadUrl(); //test fetching bad url void fetchEncodedContent(); //test fetching url content encoded as utf-8 void contentLoaded(); private: - bool mLoaded = false ; + bool mLoaded = false; }; void TestQgsNetworkContentFetcher::initTestCase() @@ -96,7 +96,7 @@ void TestQgsNetworkContentFetcher::fetchEncodedContent() QgsNetworkContentFetcher fetcher; //test fetching encoded content as string mLoaded = false; - fetcher.fetchContent( QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + '/' + "encoded_html.html" ) ); + fetcher.fetchContent( QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + '/' + "encoded_html.html" ) ); connect( &fetcher, SIGNAL( finished() ), this, SLOT( contentLoaded() ) ); while ( !mLoaded ) { diff --git a/tests/src/core/testqgsnewsfeedparser.cpp b/tests/src/core/testqgsnewsfeedparser.cpp index 441f9a0c147a..8b254bbd7cb5 100644 --- a/tests/src/core/testqgsnewsfeedparser.cpp +++ b/tests/src/core/testqgsnewsfeedparser.cpp @@ -21,17 +21,17 @@ #include "qgsnewsfeedmodel.h" -class TestQgsNewsFeedParser: public QObject +class TestQgsNewsFeedParser : public QObject { Q_OBJECT public: TestQgsNewsFeedParser() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testFetch(); void testAutoExpiry(); @@ -40,7 +40,6 @@ class TestQgsNewsFeedParser: public QObject void testModel(); void testProxyModel(); void testUpdatedEntries(); - }; @@ -69,7 +68,7 @@ void TestQgsNewsFeedParser::cleanup() void TestQgsNewsFeedParser::testFetch() { - QList< QgsNewsFeedParser::Entry > entries; + QList entries; const QUrl url( QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + "/newsfeed/feed" ) ); const QString feedKey = QgsNewsFeedParser::keyForFeed( url.toString() ); @@ -81,8 +80,7 @@ void TestQgsNewsFeedParser::testFetch() const QSignalSpy spy( &parser, &QgsNewsFeedParser::entryAdded ); QVERIFY( parser.entries().isEmpty() ); QEventLoop loop; - connect( &parser, &QgsNewsFeedParser::fetched, this, [ =, &loop, &entries ]( const QList< QgsNewsFeedParser::Entry > &e ) - { + connect( &parser, &QgsNewsFeedParser::fetched, this, [=, &loop, &entries]( const QList &e ) { entries = e; loop.quit(); } ); @@ -122,8 +120,7 @@ void TestQgsNewsFeedParser::testFetch() QgsNewsFeedParser parser2( url ); QVERIFY( parser2.entries().isEmpty() ); QEventLoop loop2; - connect( &parser2, &QgsNewsFeedParser::fetched, this, [ =, &loop2, &entries ]( const QList< QgsNewsFeedParser::Entry > &e ) - { + connect( &parser2, &QgsNewsFeedParser::fetched, this, [=, &loop2, &entries]( const QList &e ) { entries = e; loop2.quit(); } ); @@ -224,7 +221,7 @@ void TestQgsNewsFeedParser::testAutoExpiry() void TestQgsNewsFeedParser::testLang() { - QList< QgsNewsFeedParser::Entry > entries; + QList entries; const QUrl url( QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + "/newsfeed/feed" ) ); const QString feedKey = QgsNewsFeedParser::keyForFeed( url.toString() ); @@ -236,8 +233,7 @@ void TestQgsNewsFeedParser::testLang() const QSignalSpy spy( &parser, &QgsNewsFeedParser::entryAdded ); QVERIFY( parser.entries().isEmpty() ); QEventLoop loop; - connect( &parser, &QgsNewsFeedParser::fetched, this, [ =, &loop, &entries ]( const QList< QgsNewsFeedParser::Entry > &e ) - { + connect( &parser, &QgsNewsFeedParser::fetched, this, [=, &loop, &entries]( const QList &e ) { entries = e; loop.quit(); } ); @@ -251,7 +247,7 @@ void TestQgsNewsFeedParser::testLang() void TestQgsNewsFeedParser::testGeoFencing() { - QList< QgsNewsFeedParser::Entry > entries; + QList entries; const QUrl url( QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + "/newsfeed/feed" ) ); const QString feedKey = QgsNewsFeedParser::keyForFeed( url.toString() ); @@ -263,8 +259,7 @@ void TestQgsNewsFeedParser::testGeoFencing() const QSignalSpy spy( &parser, &QgsNewsFeedParser::entryAdded ); QVERIFY( parser.entries().isEmpty() ); QEventLoop loop; - connect( &parser, &QgsNewsFeedParser::fetched, this, [ =, &loop, &entries ]( const QList< QgsNewsFeedParser::Entry > &e ) - { + connect( &parser, &QgsNewsFeedParser::fetched, this, [=, &loop, &entries]( const QList &e ) { entries = e; loop.quit(); } ); @@ -289,8 +284,7 @@ void TestQgsNewsFeedParser::testModel() QCOMPARE( model.rowCount(), 0 ); QEventLoop loop; - connect( &parser, &QgsNewsFeedParser::fetched, this, [ =, &loop ]( const QList< QgsNewsFeedParser::Entry > & ) - { + connect( &parser, &QgsNewsFeedParser::fetched, this, [=, &loop]( const QList & ) { loop.quit(); } ); parser.fetch(); @@ -302,58 +296,58 @@ void TestQgsNewsFeedParser::testModel() QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "

    Ciao from Italy!

    " ) ); QVERIFY( model.data( model.index( 3, 0, QModelIndex() ), Qt::DisplayRole ).toString().startsWith( QLatin1String( "

    QGIS is finally part of the ESRI ecosystem, i" ) ) ); QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "

    Let's dive in the ocean together!

    " ) ); - QVERIFY( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Content ) ).toString().startsWith( QLatin1String( "

    Rumors from a whistleblower revealed the next Windows release code nam" ) ) ); - QVERIFY( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Content ) ).toString().startsWith( QLatin1String( "

    Tired with C++ intricacies, the core developers h" ) ) ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Content ) ).toString(), QStringLiteral( "

    Ciao from Italy!

    " ) ); - QVERIFY( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Content ) ).toString().startsWith( QLatin1String( "

    QGIS is finally part of the ESRI ecosystem, i" ) ) ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Content ) ).toString(), QStringLiteral( "

    Let's dive in the ocean together!

    " ) ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), Qt::ToolTipRole ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); + QVERIFY( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Content ) ).toString().startsWith( QLatin1String( "

    Rumors from a whistleblower revealed the next Windows release code nam" ) ) ); + QVERIFY( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Content ) ).toString().startsWith( QLatin1String( "

    Tired with C++ intricacies, the core developers h" ) ) ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Content ) ).toString(), QStringLiteral( "

    Ciao from Italy!

    " ) ); + QVERIFY( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Content ) ).toString().startsWith( QLatin1String( "

    QGIS is finally part of the ESRI ecosystem, i" ) ) ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Content ) ).toString(), QStringLiteral( "

    Let's dive in the ocean together!

    " ) ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), Qt::ToolTipRole ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), Qt::ToolTipRole ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), Qt::ToolTipRole ).toString(), QStringLiteral( "QGIS Italian Meeting" ) ); QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), Qt::ToolTipRole ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), Qt::ToolTipRole ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS Italian Meeting" ) ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 4 ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 6 ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 11 ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 3 ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 5 ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QStringLiteral( "http://0.0.0.0:8000/media/feedimages/rust.png" ) ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QStringLiteral( "https://www.winux.microsoft.com" ) ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QString() ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QString() ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QStringLiteral( "https://www.qgis.com" ) ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QString() ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS Italian Meeting" ) ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 4 ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 6 ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 11 ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 3 ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 5 ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QStringLiteral( "http://0.0.0.0:8000/media/feedimages/rust.png" ) ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::ImageUrl ) ).toString(), QString() ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QStringLiteral( "https://www.winux.microsoft.com" ) ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QString() ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QString() ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QStringLiteral( "https://www.qgis.com" ) ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Link ) ).toString(), QString() ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); // remove an entry parser.dismissEntry( 11 ); QCOMPARE( model.rowCount(), 4 ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); // construct a new model/parser -- should initially have stored entries QgsNewsFeedParser parser2( url ); const QgsNewsFeedModel model2( &parser2 ); QCOMPARE( model2.rowCount(), 4 ); - QCOMPARE( model2.data( model2.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); - QCOMPARE( model2.data( model2.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); - QCOMPARE( model2.data( model2.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); - QCOMPARE( model2.data( model2.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); + QCOMPARE( model2.data( model2.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); + QCOMPARE( model2.data( model2.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); + QCOMPARE( model2.data( model2.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); + QCOMPARE( model2.data( model2.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); } void TestQgsNewsFeedParser::testProxyModel() @@ -368,8 +362,7 @@ void TestQgsNewsFeedParser::testProxyModel() QCOMPARE( model.rowCount(), 0 ); QEventLoop loop; - connect( &parser, &QgsNewsFeedParser::fetched, this, [ =, &loop ]( const QList< QgsNewsFeedParser::Entry > & ) - { + connect( &parser, &QgsNewsFeedParser::fetched, this, [=, &loop]( const QList & ) { loop.quit(); } ); parser.fetch(); @@ -377,43 +370,43 @@ void TestQgsNewsFeedParser::testProxyModel() QCOMPARE( model.rowCount(), 5 ); // stickies first, then sort by key descending (i.e. more recently published entries first) - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 6 ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 4 ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 11 ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 5 ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 3 ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS Italian Meeting" ) ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); - QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), true ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Sticky ) ).toBool(), false ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 6 ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 4 ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 11 ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 5 ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Key ) ).toInt(), 3 ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS Italian Meeting" ) ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); + QCOMPARE( model.data( model.index( 4, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); // remove an entry parser.dismissEntry( 11 ); QCOMPARE( model.rowCount(), 4 ); - QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); - QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); - QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); - QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); + QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); + QCOMPARE( model.data( model.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); + QCOMPARE( model.data( model.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); + QCOMPARE( model.data( model.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); // construct a new model/parser -- should initially have stored entries QgsNewsFeedParser parser2( url ); const QgsNewsFeedProxyModel model2( &parser2 ); QCOMPARE( model2.rowCount(), 4 ); - QCOMPARE( model2.data( model2.index( 0, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); - QCOMPARE( model2.data( model2.index( 1, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); - QCOMPARE( model2.data( model2.index( 2, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); - QCOMPARE( model2.data( model2.index( 3, 0, QModelIndex() ), static_cast< int >( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); + QCOMPARE( model2.data( model2.index( 0, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS core will be rewritten in Rust" ) ); + QCOMPARE( model2.data( model2.index( 1, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Next Microsoft Windows code name revealed" ) ); + QCOMPARE( model2.data( model2.index( 2, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "Null Island QGIS Meeting" ) ); + QCOMPARE( model2.data( model2.index( 3, 0, QModelIndex() ), static_cast( QgsNewsFeedModel::CustomRole::Title ) ).toString(), QStringLiteral( "QGIS acquired by ESRI" ) ); } void TestQgsNewsFeedParser::testUpdatedEntries() { - QList< QgsNewsFeedParser::Entry > entries; + QList entries; const QUrl url( QUrl::fromLocalFile( QStringLiteral( TEST_DATA_DIR ) + "/newsfeed/feed" ) ); const QString feedKey = QgsNewsFeedParser::keyForFeed( url.toString() ); @@ -426,8 +419,7 @@ void TestQgsNewsFeedParser::testUpdatedEntries() QgsNewsFeedParser parser( url ); QVERIFY( parser.entries().isEmpty() ); QEventLoop loop; - connect( &parser, &QgsNewsFeedParser::fetched, this, [ =, &loop, &entries ]( const QList< QgsNewsFeedParser::Entry > &e ) - { + connect( &parser, &QgsNewsFeedParser::fetched, this, [=, &loop, &entries]( const QList &e ) { entries = e; loop.quit(); } ); @@ -447,10 +439,9 @@ void TestQgsNewsFeedParser::testUpdatedEntries() QgsNewsFeedParser::settingsFeedLastFetchTime->setValue( 1557079653, feedKey ); QgsNewsFeedParser parser2( url ); - QVERIFY( ! parser2.entries().isEmpty() ); + QVERIFY( !parser2.entries().isEmpty() ); QEventLoop loop2; - connect( &parser2, &QgsNewsFeedParser::fetched, this, [ =, &loop2, &entries ]( const QList< QgsNewsFeedParser::Entry > &e ) - { + connect( &parser2, &QgsNewsFeedParser::fetched, this, [=, &loop2, &entries]( const QList &e ) { entries = e; loop2.quit(); } ); @@ -470,11 +461,8 @@ void TestQgsNewsFeedParser::testUpdatedEntries() QCOMPARE( parser2.entries().at( 1 ).title, QStringLiteral( "Null Island QGIS Meeting" ) ); QCOMPARE( parser2.entries().at( 2 ).title, QStringLiteral( "QGIS Italian Meeting Revisited" ) ); QCOMPARE( parser2.entries().at( 2 ).expiry.toSecsSinceEpoch(), 7868426853 ); - } QGSTEST_MAIN( TestQgsNewsFeedParser ) #include "testqgsnewsfeedparser.moc" - - diff --git a/tests/src/core/testqgsnmeaconnection.cpp b/tests/src/core/testqgsnmeaconnection.cpp index e085caeff669..e10c9712a44b 100644 --- a/tests/src/core/testqgsnmeaconnection.cpp +++ b/tests/src/core/testqgsnmeaconnection.cpp @@ -27,7 +27,6 @@ class ReplayNmeaConnection : public QgsNmeaConnection { Q_OBJECT public: - ReplayNmeaConnection() : QgsNmeaConnection( nullptr ) { @@ -47,7 +46,7 @@ class ReplayNmeaConnection : public QgsNmeaConnection mBuffer->seek( pos ); spy.wait(); - return spy.constLast().at( 0 ).value< QgsGpsInformation >(); + return spy.constLast().at( 0 ).value(); } void pushString( const QString &string ) @@ -59,7 +58,6 @@ class ReplayNmeaConnection : public QgsNmeaConnection } private: - QBuffer *mBuffer = nullptr; }; @@ -69,8 +67,8 @@ class TestQgsNmeaConnection : public QgsTest Q_OBJECT public: - - TestQgsNmeaConnection() : QgsTest( QStringLiteral( "NMEA Connection Tests" ) ) {} + TestQgsNmeaConnection() + : QgsTest( QStringLiteral( "NMEA Connection Tests" ) ) {} private slots: void initTestCase(); @@ -88,7 +86,6 @@ class TestQgsNmeaConnection : public QgsTest void testComponent_data(); void testComponent(); void testIncompleteMessage(); - }; void TestQgsNmeaConnection::initTestCase() @@ -140,7 +137,7 @@ void TestQgsNmeaConnection::testBasic() QCOMPARE( info.elevation, 0 ); QVERIFY( std::isnan( info.direction ) ); - info = connection.push( QStringLiteral( "$%1GSV,3,3,12,17,31,279,,28,27,320,,23,23,026,,14,22,060,*7B" ).arg( talkerId ) ); + info = connection.push( QStringLiteral( "$%1GSV,3,3,12,17,31,279,,28,27,320,,23,23,026,,14,22,060,*7B" ).arg( talkerId ) ); QVERIFY( info.isValid() ); QVERIFY( !info.satInfoComplete ); QCOMPARE( info.bestFixStatus( constellation ), Qgis::GpsFixStatus::NoData ); @@ -305,7 +302,7 @@ void TestQgsNmeaConnection::testFixStatus() QVERIFY( info.isValid() ); QCOMPARE( info.bestFixStatus( constellation ), Qgis::GpsFixStatus::Fix3D ); QCOMPARE( statusSpy.count(), 1 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::Fix3D ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::Fix3D ); // no fix status change connection.push( QStringLiteral( "$%1GSA,A,3,,,,,,16,18,,22,24,,,3.6,2.1,2.2*3C" ).arg( talkerId ) ); @@ -317,7 +314,7 @@ void TestQgsNmeaConnection::testFixStatus() QVERIFY( info.isValid() ); QCOMPARE( info.bestFixStatus( constellation ), Qgis::GpsFixStatus::Fix2D ); QCOMPARE( statusSpy.count(), 2 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::Fix2D ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::Fix2D ); // no fix status change connection.push( QStringLiteral( "$%1GSA,A,2,,,,,,16,18,,22,24,,,3.6,2.1,2.2*3C" ).arg( talkerId ) ); @@ -329,7 +326,7 @@ void TestQgsNmeaConnection::testFixStatus() QVERIFY( !info.isValid() ); QCOMPARE( info.bestFixStatus( constellation ), Qgis::GpsFixStatus::NoFix ); QCOMPARE( statusSpy.count(), 3 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::NoFix ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::NoFix ); // no fix status change connection.push( QStringLiteral( "$%1GSA,A,1,,,,,,16,18,,22,24,,,3.6,2.1,2.2*3C" ).arg( talkerId ) ); @@ -344,7 +341,7 @@ void TestQgsNmeaConnection::testFixStatus() QVERIFY( !info.isValid() ); QCOMPARE( statusSpy.count(), 4 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::Fix2D ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::Fix2D ); info = connection.push( QStringLiteral( "$%1RMC,220516,A,9933.82,S,00042.24,W,173.8,231.8,130694,004.2,W*70" ).arg( talkerId ) ); QGSCOMPARENEAR( info.latitude, -99.563666, 0.00001 ); @@ -366,8 +363,7 @@ void TestQgsNmeaConnection::testFixStatus() connection.close(); QCOMPARE( statusSpy.count(), 5 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::NoData ); - + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::NoData ); } void TestQgsNmeaConnection::testFixStatusAcrossConstellations() @@ -381,40 +377,40 @@ void TestQgsNmeaConnection::testFixStatusAcrossConstellations() QgsGpsInformation info = connection.push( QStringLiteral( "$GPGSA,A,1,7,9,16,27,30,9,7,1,6,5,,,4.2,3.4,2.4*07" ) ); QCOMPARE( info.bestFixStatus( bestConstellation ), Qgis::GpsFixStatus::NoFix ); QCOMPARE( statusSpy.count(), 1 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::NoFix ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::NoFix ); QCOMPARE( bestConstellation, Qgis::GnssConstellation::Gps ); info = connection.push( QStringLiteral( "$GLGSA,A,1,7,9,16,27,30,9,7,1,6,5,,,4.2,3.4,2.4*07" ) ); QCOMPARE( info.bestFixStatus( bestConstellation ), Qgis::GpsFixStatus::NoFix ); QCOMPARE( statusSpy.count(), 1 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::NoFix ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::NoFix ); QCOMPARE( bestConstellation, Qgis::GnssConstellation::Gps ); info = connection.push( QStringLiteral( "$GLGSA,A,2,7,9,16,27,30,9,7,1,6,5,,,4.2,3.4,2.4*07\r\n$GPGSA,A,1,7,9,16,27,30,9,7,1,6,5,,,4.2,3.4,2.4*07" ) ); QCOMPARE( info.bestFixStatus( bestConstellation ), Qgis::GpsFixStatus::Fix2D ); QCOMPARE( statusSpy.count(), 2 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::Fix2D ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::Fix2D ); QCOMPARE( bestConstellation, Qgis::GnssConstellation::Glonass ); info = connection.push( QStringLiteral( "$GNGSA,A,3,7,9,16,27,30,9,7,1,6,5,,,4.2,3.4,2.4*07" ) ); QCOMPARE( info.bestFixStatus( bestConstellation ), Qgis::GpsFixStatus::Fix3D ); QCOMPARE( statusSpy.count(), 3 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::Fix3D ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::Fix3D ); QCOMPARE( bestConstellation, Qgis::GnssConstellation::Gps ); // GPS fix lost, best fix is 2D glonass one info = connection.push( QStringLiteral( "$GNGSA,A,1,7,9,16,27,30,9,7,1,6,5,,,4.2,3.4,2.4*07" ) ); QCOMPARE( info.bestFixStatus( bestConstellation ), Qgis::GpsFixStatus::Fix2D ); QCOMPARE( statusSpy.count(), 4 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::Fix2D ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::Fix2D ); QCOMPARE( bestConstellation, Qgis::GnssConstellation::Glonass ); // another test where a number of GNGSA sentences are received at once info = connection.push( QStringLiteral( "$GNGSA,A,3,6,11,12,19,20,25,29,10,20,19,7,10,7.5,5.5,5.1*24\r\n$GNGSA,A,3,11,12,24,25,31,,,,,,,,7.5,5.5,5.1*2A\r\n$GNGSA,A,1,194,195,,,,,,,,,,,7.5,5.5,5.1*29" ) ); QCOMPARE( info.bestFixStatus( bestConstellation ), Qgis::GpsFixStatus::Fix3D ); - QVERIFY( info.isValid() ) ; + QVERIFY( info.isValid() ); QCOMPARE( statusSpy.count(), 5 ); - QCOMPARE( statusSpy.constLast().at( 0 ).value< Qgis::GpsFixStatus >(), Qgis::GpsFixStatus::Fix3D ); + QCOMPARE( statusSpy.constLast().at( 0 ).value(), Qgis::GpsFixStatus::Fix3D ); QCOMPARE( bestConstellation, Qgis::GnssConstellation::Gps ); } @@ -488,7 +484,7 @@ void TestQgsNmeaConnection::testPosition() connection.push( QStringLiteral( "$%1GGA,084112.185,6900.0,N,01800.0,E,1,04,1.4,35.0,M,29.4,M,,0000*63" ).arg( talkerId ) ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( spy.constLast().at( 0 ).value< QgsPoint>(), QgsPoint( 18, 69, 35 ) ); + QCOMPARE( spy.constLast().at( 0 ).value(), QgsPoint( 18, 69, 35 ) ); QCOMPARE( connection.lastValidLocation(), QgsPoint( 18, 69, 35 ) ); // push same location, should be no new signal connection.push( QStringLiteral( "$%1GGA,084112.185,6900.0,N,01800.0,E,1,04,1.4,35.0,M,29.6,M,,0000*63" ).arg( talkerId ) ); @@ -497,7 +493,7 @@ void TestQgsNmeaConnection::testPosition() // new location connection.push( QStringLiteral( "$%1GGA,084112.185,6900.0,N,01900.0,E,1,04,1.4,35.0,M,29.4,M,,0000*63" ).arg( talkerId ) ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( spy.constLast().at( 0 ).value< QgsPoint>(), QgsPoint( 19, 69, 35 ) ); + QCOMPARE( spy.constLast().at( 0 ).value(), QgsPoint( 19, 69, 35 ) ); QCOMPARE( connection.lastValidLocation(), QgsPoint( 19, 69, 35 ) ); // invalid location (latitude > 90 degrees) @@ -525,15 +521,15 @@ void TestQgsNmeaConnection::testComponent() QgsGpsInformation info = connection.push( QStringLiteral( "$%1GGA,084112.185,6900.0,N,01800.0,E,1,04,1.4,35.0,M,29.4,M,,0000*63" ).arg( talkerId ) ); - QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Location ).value< QgsPointXY >(), QgsPointXY( 18, 69 ) ); + QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Location ).value(), QgsPointXY( 18, 69 ) ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Altitude ).toDouble(), 35 ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::GroundSpeed ).toDouble(), 0 ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Bearing ).toDouble(), 0 ); info = connection.push( QStringLiteral( "$%1RMC,084111.185,A,6938.6531,N,01856.8527,E,0.16,2.00,220120,,,A*6E" ).arg( talkerId ) ); - QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Location ).value< QgsPointXY >(), QgsPointXY( 18.94754499999999808, 69.644218333333341779 ) ); + QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Location ).value(), QgsPointXY( 18.94754499999999808, 69.644218333333341779 ) ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Altitude ).toDouble(), 35 ); - QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::GroundSpeed ).toDouble(), 0.29632 ); + QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::GroundSpeed ).toDouble(), 0.29632 ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Bearing ).toDouble(), 2 ); } @@ -555,9 +551,9 @@ void TestQgsNmeaConnection::testIncompleteMessage() // got a full sentence now, status should be "data received" QCOMPARE( connection.status(), QgsGpsConnection::Status::GPSDataReceived ); QCOMPARE( stateChangedSpy.size(), 1 ); - const QgsGpsInformation info = stateChangedSpy.at( 0 ).at( 0 ).value< QgsGpsInformation >(); + const QgsGpsInformation info = stateChangedSpy.at( 0 ).at( 0 ).value(); - QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Location ).value< QgsPointXY >(), QgsPointXY( 18, 69 ) ); + QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Location ).value(), QgsPointXY( 18, 69 ) ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Altitude ).toDouble(), 35 ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::GroundSpeed ).toDouble(), 0 ); QCOMPARE( info.componentValue( Qgis::GpsInformationComponent::Bearing ).toDouble(), 0 ); diff --git a/tests/src/core/testqgsofflineediting.cpp b/tests/src/core/testqgsofflineediting.cpp index 00a0d81b6a9c..ed9a779fb3ad 100644 --- a/tests/src/core/testqgsofflineediting.cpp +++ b/tests/src/core/testqgsofflineediting.cpp @@ -48,10 +48,10 @@ class TestQgsOfflineEditing : public QObject QTemporaryDir tempDir; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void createSpatialiteAndSynchronizeBack_data(); void createGeopackageAndSynchronizeBack_data(); @@ -89,8 +89,7 @@ void TestQgsOfflineEditing::init() QFile::copy( myFileName + "/points.geojson", myTempDirName + "/points.geojson" ); const QString myTempFileName = myTempDirName + "/points.geojson"; const QFileInfo myMapFileInfo( myTempFileName ); - mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), - myMapFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), myMapFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( mpLayer ); numberOfFeatures = mpLayer->featureCount(); @@ -143,7 +142,6 @@ void TestQgsOfflineEditing::createGeopackageAndSynchronizeBack_data() void TestQgsOfflineEditing::createSpatialiteAndSynchronizeBack() { - QFETCH( QString, suffix_input ); QFETCH( QString, suffix_result ); @@ -199,7 +197,7 @@ void TestQgsOfflineEditing::createGeopackageAndSynchronizeBack() QgsFeatureIterator it = mpLayer->getFeatures(); it.nextFeature( firstFeatureBeforeAction ); - connect( mOfflineEditing, &QgsOfflineEditing::warning, this, []( const QString & title, const QString & message ) { qDebug() << title << message; } ); + connect( mOfflineEditing, &QgsOfflineEditing::warning, this, []( const QString &title, const QString &message ) { qDebug() << title << message; } ); //set on LayerTreeNode showFeatureCount property QgsLayerTreeLayer *layerTreelayer = QgsProject::instance()->layerTreeRoot()->findLayer( mpLayer->id() ); diff --git a/tests/src/core/testqgsogcutils.cpp b/tests/src/core/testqgsogcutils.cpp index 4dec2fee4abf..6237a903b7a4 100644 --- a/tests/src/core/testqgsogcutils.cpp +++ b/tests/src/core/testqgsogcutils.cpp @@ -118,7 +118,7 @@ static bool compareElements( QDomElement &element1, QDomElement &element2 ) if ( tag1 != tag2 ) { qDebug( "Different tag names: %s, %s", tag1.toLatin1().data(), tag2.toLatin1().data() ); - return false ; + return false; } if ( element1.hasAttributes() != element2.hasAttributes() ) @@ -138,7 +138,7 @@ static bool compareElements( QDomElement &element1, QDomElement &element2 ) return false; } - for ( int i = 0 ; i < attrs1.size() ; ++i ) + for ( int i = 0; i < attrs1.size(); ++i ) { const QDomNode node1 = attrs1.item( i ); const QDomAttr attr1 = node1.toAttr(); @@ -174,7 +174,7 @@ static bool compareElements( QDomElement &element1, QDomElement &element2 ) return false; } - for ( int i = 0 ; i < nodes1.size() ; ++i ) + for ( int i = 0; i < nodes1.size(); ++i ) { const QDomNode node1 = nodes1.at( i ); const QDomNode node2 = nodes2.at( i ); @@ -280,32 +280,35 @@ void TestQgsOgcUtils::testExpressionFromOgcFilterWFS20_data() QTest::addColumn( "dumpText" ); QTest::newRow( "=" ) << QString( - "" - "" - "NAME" - "New York" - "" ) + "" + "" + "NAME" + "New York" + "" + ) << QStringLiteral( "NAME = 'New York'" ); QTest::newRow( "bbox coordinates" ) << QString( - "" - "Name>NAME" - "135.2239,34.4879 135.8578,34.8471" - "" ) + "" + "Name>NAME" + "135.2239,34.4879 135.8578,34.8471" + "" + ) << QStringLiteral( "intersects_bbox($geometry, geom_from_gml('135.2239,34.4879 135.8578,34.8471'))" ); QTest::newRow( "bbox corner" ) - << QString( - "" - "" - "my_geometry_name" - "" - "49 2" - "50 3" - "" - "" - "" ) - << QStringLiteral( "intersects_bbox($geometry, geom_from_gml('49 250 3'))" ); + << QString( + "" + "" + "my_geometry_name" + "" + "49 2" + "50 3" + "" + "" + "" + ) + << QStringLiteral( "intersects_bbox($geometry, geom_from_gml('49 250 3'))" ); } void TestQgsOgcUtils::testExpressionFromOgcFilterWFS20() @@ -338,159 +341,177 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter_data() QTest::addColumn( "dumpText" ); QTest::newRow( "=" ) << QString( - "" - "NAME" - "New York" - "" ) + "" + "NAME" + "New York" + "" + ) << QStringLiteral( "NAME = 'New York'" ); QTest::newRow( ">" ) << QString( - "" - "COUNT" - "3" - "" ) + "" + "COUNT" + "3" + "" + ) << QStringLiteral( "COUNT > 3" ); QTest::newRow( "AND" ) << QString( - "" - "" - "" - "pop" - "50000" - "" - "" - "pop" - "100000" - "" - "" - "" ) + "" + "" + "" + "pop" + "50000" + "" + "" + "pop" + "100000" + "" + "" + "" + ) << QStringLiteral( "pop >= 50000 AND pop < 100000" ); // TODO: should work also without tags in Lower/Upper-Boundary tags? QTest::newRow( "between" ) << QString( - "" - "POPULATION" - "100" - "200" - "" ) + "" + "POPULATION" + "100" + "200" + "" + ) << QStringLiteral( "POPULATION >= 100 AND POPULATION <= 200" ); // handle different wildcards, single chars, escape chars QTest::newRow( "like" ) << QString( - "" - "" - "NAME*QGIS*" - "" ) + "" + "" + "NAME*QGIS*" + "" + ) << QStringLiteral( "NAME LIKE '*QGIS*'" ); QTest::newRow( "ilike" ) << QString( - "" - "" - "NAME*QGIS*" - "" ) + "" + "" + "NAME*QGIS*" + "" + ) << QStringLiteral( "NAME ILIKE '*QGIS*'" ); // different wildCards QTest::newRow( "like wildCard simple" ) << QString( - "" - "" - "NAME*QGIS*" - "" ) + "" + "" + "NAME*QGIS*" + "" + ) << QStringLiteral( "NAME LIKE '%QGIS%'" ); QTest::newRow( "like wildCard complex" ) << QString( - "" - "" - "NAME*%QGIS*\\*" - "" ) - << QStringLiteral( "NAME LIKE '%\\\\%QGIS%*'" ); + "" + "" + "NAME*%QGIS*\\*" + "" + ) + << QStringLiteral( "NAME LIKE '%\\\\%QGIS%*'" ); QTest::newRow( "ilike wildCard simple" ) << QString( - "" - "" - "NAME*QGIS*" - "" ) - << QStringLiteral( "NAME ILIKE '%QGIS%'" ); + "" + "" + "NAME*QGIS*" + "" + ) + << QStringLiteral( "NAME ILIKE '%QGIS%'" ); QTest::newRow( "ilike wildCard complex" ) << QString( - "" - "" - "NAME*%QGIS*\\*" - "" ) - << QStringLiteral( "NAME ILIKE '%\\\\%QGIS%*'" ); + "" + "" + "NAME*%QGIS*\\*" + "" + ) + << QStringLiteral( "NAME ILIKE '%\\\\%QGIS%*'" ); // different single chars QTest::newRow( "like single char" ) << QString( - "" - "" - "NAME._QGIS.\\." - "" ) + "" + "" + "NAME._QGIS.\\." + "" + ) << QStringLiteral( "NAME LIKE '_\\\\_QGIS_.'" ); // different escape chars QTest::newRow( "like escape char" ) << QString( - "" - "" - "NAME_QGIS.!.!!%QGIS*!*" - "" ) + "" + "" + "NAME_QGIS.!.!!%QGIS*!*" + "" + ) << QStringLiteral( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" ); QTest::newRow( "like escape char" ) << QString( - "" - "" - "NAME_QGIS.!.!!%QGIS*!*" - "" ) + "" + "" + "NAME_QGIS.!.!!%QGIS*!*" + "" + ) << QStringLiteral( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" ); QTest::newRow( "is null" ) << QString( - "" - "" - "FIRST_NAME" - "" - "" ) + "" + "" + "FIRST_NAME" + "" + "" + ) << QStringLiteral( "FIRST_NAME IS NULL" ); QTest::newRow( "bbox with GML2 Box" ) << QString( - "" - "Name>NAME" - "135.2239,34.4879 135.8578,34.8471" - "" ) + "" + "Name>NAME" + "135.2239,34.4879 135.8578,34.8471" + "" + ) << QStringLiteral( "intersects_bbox($geometry, geom_from_gml('135.2239,34.4879 135.8578,34.8471'))" ); QTest::newRow( "Intersects" ) << QString( - "" - "" - "GEOMETRY" - "" - "123,456" - "" - "" - "" ) + "" + "" + "GEOMETRY" + "" + "123,456" + "" + "" + "" + ) << QStringLiteral( "intersects($geometry, geom_from_gml('123,456'))" ); QTest::newRow( "Literal conversion" ) << QString( - "" - "LITERAL" - "+2" - "" ) + "" + "LITERAL" + "+2" + "" + ) << QStringLiteral( "LITERAL = '+2'" ); QTest::newRow( "not or list" ) << QStringLiteral( "" - "" - " " - " " - " A" - " 1" - " " - " " - " A" - " 2" - " " - " " - " A" - " 3" - " " - " " - "" - "" ) << QStringLiteral( "NOT ( A = 1 OR A = 2 OR A = 3 )" ); + "" + " " + " " + " A" + " 1" + " " + " " + " A" + " 2" + " " + " " + " A" + " 3" + " " + " " + "" + "" ) + << QStringLiteral( "NOT ( A = 1 OR A = 2 OR A = 3 )" ); } void TestQgsOgcUtils::testExpressionFromOgcFilter() @@ -522,16 +543,17 @@ void TestQgsOgcUtils::testExpressionFromOgcFilterWithLongLong_data() QTest::addColumn( "xmlText" ); QTest::addColumn( "dumpText" ); QTest::newRow( "Literal less than" ) << QString( - "" - "" - "id" - "1" - "" - "" - "id" - "3" - "" - "" ) + "" + "" + "id" + "1" + "" + "" + "id" + "3" + "" + "" + ) << QStringLiteral( "id > 1 AND id < 3" ); } @@ -600,151 +622,137 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data() QTest::addColumn( "exprText" ); QTest::addColumn( "xmlText" ); - QTest::newRow( "=" ) << QStringLiteral( "NAME = 'New York'" ) << QString( - "" - "" - "NAME" - "New York" - "" ); - - QTest::newRow( ">" ) << QStringLiteral( "\"COUNT\" > 3" ) << QString( - "" - "" - "COUNT" - "3" - "" ); - - QTest::newRow( "and+or" ) << QStringLiteral( "(FIELD1 = 10 OR FIELD1 = 20) AND STATUS = 'VALID'" ) << QString( - "" - "" - "" - "" - "FIELD1" - "10" - "" - "" - "FIELD1" - "20" - "" - "" - "" - "STATUS" - "VALID" - "" - "" - "" ); - - QTest::newRow( "like" ) << QStringLiteral( "NAME LIKE '*QGIS*'" ) << QString( - "" - "" - "NAME" - "*QGIS*" - "" - "" ); - - QTest::newRow( "ilike" ) << QStringLiteral( "NAME ILIKE '*QGIS*'" ) << QString( - "" - "" - "NAME" - "*QGIS*" - "" - "" ); - - QTest::newRow( "is null" ) << QStringLiteral( "A IS NULL" ) << QString( - "" - "" - "A" - "" - "" ); - - QTest::newRow( "is not null" ) << QStringLiteral( "A IS NOT NULL" ) << QString( - "" - "" - "" - "A" - "" - "" - "" ); - - QTest::newRow( "in" ) << QStringLiteral( "A IN (10,20,30)" ) << QString( - "" - "" - "" - "A" - "10" - "" - "" - "A" - "20" - "" - "" - "A" - "30" - "" - "" - "" ); - - QTest::newRow( "not in" ) << QStringLiteral( "A NOT IN (10,20,30)" ) << QString( - "" - "" - "" - "" - "A" - "10" - "" - "" - "A" - "20" - "" - "" - "A" - "30" - "" - "" - "" - "" ); - - QTest::newRow( "in" ) << QStringLiteral( "A IN (10)" ) << QString( - "" - "" - "A" - "10" - "" - "" ); - - QTest::newRow( "not in" ) << QStringLiteral( "A NOT IN (10)" ) << QString( - "" - "" - "" - "A" - "10" - "" - "" - "" ); - - QTest::newRow( "intersects_bbox" ) << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POINT (5 6)'))" ) << QString( - "" - "" - "geometry" - "5,6 5,6" - "" - "" ); - - QTest::newRow( "intersects + wkt" ) << QStringLiteral( "intersects($geometry, geomFromWKT('POINT (5 6)'))" ) << QString( - "" - "" - "geometry" - "5,6" - "" - "" ); - - QTest::newRow( "contains + gml" ) << QStringLiteral( "contains($geometry, geomFromGML('5,6'))" ) << QString( - "" - "" - "geometry" - "5,6" - "" - "" ); + QTest::newRow( "=" ) << QStringLiteral( "NAME = 'New York'" ) << QString( "" + "" + "NAME" + "New York" + "" ); + + QTest::newRow( ">" ) << QStringLiteral( "\"COUNT\" > 3" ) << QString( "" + "" + "COUNT" + "3" + "" ); + + QTest::newRow( "and+or" ) << QStringLiteral( "(FIELD1 = 10 OR FIELD1 = 20) AND STATUS = 'VALID'" ) << QString( "" + "" + "" + "" + "FIELD1" + "10" + "" + "" + "FIELD1" + "20" + "" + "" + "" + "STATUS" + "VALID" + "" + "" + "" ); + + QTest::newRow( "like" ) << QStringLiteral( "NAME LIKE '*QGIS*'" ) << QString( "" + "" + "NAME" + "*QGIS*" + "" + "" ); + + QTest::newRow( "ilike" ) << QStringLiteral( "NAME ILIKE '*QGIS*'" ) << QString( "" + "" + "NAME" + "*QGIS*" + "" + "" ); + + QTest::newRow( "is null" ) << QStringLiteral( "A IS NULL" ) << QString( "" + "" + "A" + "" + "" ); + + QTest::newRow( "is not null" ) << QStringLiteral( "A IS NOT NULL" ) << QString( "" + "" + "" + "A" + "" + "" + "" ); + + QTest::newRow( "in" ) << QStringLiteral( "A IN (10,20,30)" ) << QString( "" + "" + "" + "A" + "10" + "" + "" + "A" + "20" + "" + "" + "A" + "30" + "" + "" + "" ); + + QTest::newRow( "not in" ) << QStringLiteral( "A NOT IN (10,20,30)" ) << QString( "" + "" + "" + "" + "A" + "10" + "" + "" + "A" + "20" + "" + "" + "A" + "30" + "" + "" + "" + "" ); + + QTest::newRow( "in" ) << QStringLiteral( "A IN (10)" ) << QString( "" + "" + "A" + "10" + "" + "" ); + + QTest::newRow( "not in" ) << QStringLiteral( "A NOT IN (10)" ) << QString( "" + "" + "" + "A" + "10" + "" + "" + "" ); + + QTest::newRow( "intersects_bbox" ) << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POINT (5 6)'))" ) << QString( "" + "" + "geometry" + "5,6 5,6" + "" + "" ); + + QTest::newRow( "intersects + wkt" ) << QStringLiteral( "intersects($geometry, geomFromWKT('POINT (5 6)'))" ) << QString( "" + "" + "geometry" + "5,6" + "" + "" ); + + QTest::newRow( "contains + gml" ) << QStringLiteral( "contains($geometry, geomFromGML('5,6'))" ) << QString( "" + "" + "geometry" + "5,6" + "" + "" ); } void TestQgsOgcUtils::testExpressionToOgcFilterWFS11() @@ -758,10 +766,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS11() QString errorMsg; QDomDocument doc; - const QDomElement filterElem = QgsOgcUtils::expressionToOgcFilter( exp, doc, - QgsOgcUtils::GML_3_1_0, QgsOgcUtils::FILTER_OGC_1_1, - QString(), QString(), - QStringLiteral( "my_geometry_name" ), srsName, true, false, &errorMsg ); + const QDomElement filterElem = QgsOgcUtils::expressionToOgcFilter( exp, doc, QgsOgcUtils::GML_3_1_0, QgsOgcUtils::FILTER_OGC_1_1, QString(), QString(), QStringLiteral( "my_geometry_name" ), srsName, true, false, &errorMsg ); if ( !errorMsg.isEmpty() ) qDebug( "ERROR: %s", errorMsg.toLatin1().data() ); @@ -787,18 +792,19 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS11_data() QTest::addColumn( "xmlText" ); QTest::newRow( "bbox" ) - << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) - << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) - << QString( - "" - "" - "my_geometry_name" - "" - "49 2" - "50 3" - "" - "" - "" ); + << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) + << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) + << QString( + "" + "" + "my_geometry_name" + "" + "49 2" + "50 3" + "" + "" + "" + ); } void TestQgsOgcUtils::testExpressionToOgcFilterWFS20() @@ -814,10 +820,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS20() QString errorMsg; QDomDocument doc; - const QDomElement filterElem = QgsOgcUtils::expressionToOgcFilter( exp, doc, - QgsOgcUtils::GML_3_2_1, QgsOgcUtils::FILTER_FES_2_0, - namespacePrefix, namespaceURI, - QStringLiteral( "my_geometry_name" ), srsName, true, false, &errorMsg ); + const QDomElement filterElem = QgsOgcUtils::expressionToOgcFilter( exp, doc, QgsOgcUtils::GML_3_2_1, QgsOgcUtils::FILTER_FES_2_0, namespacePrefix, namespaceURI, QStringLiteral( "my_geometry_name" ), srsName, true, false, &errorMsg ); if ( !errorMsg.isEmpty() ) qDebug( "ERROR: %s", errorMsg.toLatin1().data() ); @@ -843,69 +846,70 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS20_data() QTest::addColumn( "namespacePrefix" ); QTest::addColumn( "namespaceURI" ); - QTest::newRow( "=" ) << QStringLiteral( "NAME = 'New York'" ) << QString() << QString( - "" - "" - "NAME" - "New York" - "" ) + QTest::newRow( "=" ) << QStringLiteral( "NAME = 'New York'" ) << QString() << QString( "" + "" + "NAME" + "New York" + "" ) << QString() << QString(); - QTest::newRow( "= with namespace" ) << QStringLiteral( "NAME = 'New York'" ) << QString() << QString( - "" - "" - "myns:NAME" - "New York" - "" ) + QTest::newRow( "= with namespace" ) << QStringLiteral( "NAME = 'New York'" ) << QString() << QString( "" + "" + "myns:NAME" + "New York" + "" ) << QStringLiteral( "myns" ) << QStringLiteral( "http://example.com/myns" ); QTest::newRow( "bbox" ) - << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) - << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) - << QString( - "" - "" - "my_geometry_name" - "" - "49 2" - "50 3" - "" - "" - "" ) - << QString() << QString(); + << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) + << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) + << QString( + "" + "" + "my_geometry_name" + "" + "49 2" + "50 3" + "" + "" + "" + ) + << QString() << QString(); QTest::newRow( "bbox with namespace" ) - << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) - << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) - << QString( - "" - "" - "myns:my_geometry_name" - "" - "49 2" - "50 3" - "" - "" - "" ) - << QStringLiteral( "myns" ) << QStringLiteral( "http://example.com/myns" ); + << QStringLiteral( "intersects_bbox($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) + << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) + << QString( + "" + "" + "myns:my_geometry_name" + "" + "49 2" + "50 3" + "" + "" + "" + ) + << QStringLiteral( "myns" ) << QStringLiteral( "http://example.com/myns" ); QTest::newRow( "intersects" ) - << QStringLiteral( "intersects($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) - << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) - << QString( - "" - "" - "my_geometry_name" - "" - "" - "" - "49 2 50 2 50 3 49 3 49 2" - "" - "" - "" - "" - "" ) - << QString() << QString(); + << QStringLiteral( "intersects($geometry, geomFromWKT('POLYGON((2 49,2 50,3 50,3 49,2 49))'))" ) + << QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ) + << QString( + "" + "" + "my_geometry_name" + "" + "" + "" + "49 2 50 2 50 3 49 3 49 2" + "" + "" + "" + "" + "" + ) + << QString() << QString(); } Q_DECLARE_METATYPE( QgsOgcUtils::GMLVersion ) @@ -934,15 +938,7 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter() const bool honourAxisOrientation = true; const bool invertAxisOrientation = false; //QList layerProperties; - const QDomElement filterElem = QgsOgcUtils::SQLStatementToOgcFilter( statement, - doc, - gmlVersion, - filterVersion, - layerProperties, - honourAxisOrientation, - invertAxisOrientation, - QMap(), - &errorMsg ); + const QDomElement filterElem = QgsOgcUtils::SQLStatementToOgcFilter( statement, doc, gmlVersion, filterVersion, layerProperties, honourAxisOrientation, invertAxisOrientation, QMap(), &errorMsg ); if ( !errorMsg.isEmpty() ) qDebug( "ERROR: %s", errorMsg.toLatin1().data() ); @@ -952,12 +948,12 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter() doc.appendChild( filterElem ); qDebug( "SQL: %s", statement.statement().toLatin1().data() ); - qDebug( "GML: %s", gmlVersion == QgsOgcUtils::GML_2_1_2 ? "2.1.2" : - gmlVersion == QgsOgcUtils::GML_3_1_0 ? "3.1.0" : - gmlVersion == QgsOgcUtils::GML_3_2_1 ? "3.2.1" : "unknown" ); - qDebug( "FILTER: %s", filterVersion == QgsOgcUtils::FILTER_OGC_1_0 ? "OGC 1.0" : - filterVersion == QgsOgcUtils::FILTER_OGC_1_1 ? "OGC 1.1" : - filterVersion == QgsOgcUtils::FILTER_FES_2_0 ? "FES 2.0" : "unknown" ); + qDebug( "GML: %s", gmlVersion == QgsOgcUtils::GML_2_1_2 ? "2.1.2" : gmlVersion == QgsOgcUtils::GML_3_1_0 ? "3.1.0" + : gmlVersion == QgsOgcUtils::GML_3_2_1 ? "3.2.1" + : "unknown" ); + qDebug( "FILTER: %s", filterVersion == QgsOgcUtils::FILTER_OGC_1_0 ? "OGC 1.0" : filterVersion == QgsOgcUtils::FILTER_OGC_1_1 ? "OGC 1.1" + : filterVersion == QgsOgcUtils::FILTER_FES_2_0 ? "FES 2.0" + : "unknown" ); qDebug( "OGC : %s", doc.toString( -1 ).toLatin1().data() ); QDomElement xmlElem = comparableElement( xmlText ); @@ -972,233 +968,192 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter_data() QTest::addColumn( "statementText" ); QTest::addColumn( "gmlVersion" ); QTest::addColumn( "filterVersion" ); - QTest::addColumn< QList >( "layerProperties" ); + QTest::addColumn>( "layerProperties" ); QTest::addColumn( "xmlText" ); - QTest::newRow( "= 1.0" ) << QStringLiteral( "SELECT * FROM t WHERE NAME = 'New York'" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << - QString( - "" - "" - "NAME" - "New York" - "" - "" ); - - QTest::newRow( "= 2.0" ) << QStringLiteral( "SELECT * FROM t WHERE NAME = 'New York'" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << - QString( - "" - "" - "NAME" - "New York" - "" - "" ); - - QTest::newRow( ">" ) << QStringLiteral( "SELECT * FROM t WHERE COUNT > 3" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << - QString( - "" - "" - "COUNT" - "3" - "" ); - - QTest::newRow( "and+or" ) << QStringLiteral( "SELECT * FROM t WHERE (FIELD1 <= 10 OR FIELD1 > 20) AND STATUS >= 1.5" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "" - "" - "FIELD1" - "10" - "" - "" - "FIELD1" - "20" - "" - "" - "" - "STATUS" - "1.5" - "" - "" - "" ); - - QTest::newRow( "is null" ) << QStringLiteral( "SELECT * FROM t WHERE A IS NULL" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "A" - "" - "" ); - - QTest::newRow( "is not null" ) << QStringLiteral( "SELECT * FROM t WHERE A IS NOT NULL" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "" - "A" - "" - "" - "" ); - - QTest::newRow( "in" ) << QStringLiteral( "SELECT * FROM t WHERE A IN (10,20,30)" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "" - "A" - "10" - "" - "" - "A" - "20" - "" - "" - "A" - "30" - "" - "" - "" ); - - QTest::newRow( "not in" ) << QStringLiteral( "SELECT * FROM t WHERE A NOT IN (10,20,30)" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "" - "" - "A" - "10" - "" - "" - "A" - "20" - "" - "" - "A" - "30" - "" - "" - "" - "" ); - - QTest::newRow( "in" ) << QStringLiteral( "SELECT * FROM t WHERE A IN (10)" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "A" - "10" - "" - "" ); - - QTest::newRow( "not in" ) << QStringLiteral( "SELECT * FROM t WHERE A NOT IN (10)" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "" - "A" - "10" - "" - "" - "" ); - - QTest::newRow( "between" ) << QStringLiteral( "SELECT * FROM t WHERE A BETWEEN 1 AND 2" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "A" - "1" - "2" - "" - "" ); - - QTest::newRow( "not between" ) << QStringLiteral( "SELECT * FROM t WHERE A NOT BETWEEN 1 AND 2" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "" - "A" - "1" - "2" - "" - "" - "" ); - - QTest::newRow( "intersects + wkt" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)'))" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "geom" - "5,6" - "" - "" ); - - QTest::newRow( "contains + gml" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Contains(geom, ST_GeomFromGML('5,6'))" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "geom" - "5,6" - "" - "" ); - - QTest::newRow( "abs" ) << QStringLiteral( "SELECT * FROM t WHERE ABS(x) < 5" ) << - QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( - "" - "" - "" - "x" - "" - "5" - "" - "" ); - - QTest::newRow( "bbox + wkt + explicit srs" ) << QStringLiteral( "SELECT * FROM t WHERE BBOX(geom, ST_MakeEnvelope(2.2, 49, 3, 50, 4326))" ) << - QgsOgcUtils::GML_3_1_0 << QgsOgcUtils::FILTER_OGC_1_1 << layerProperties << QString( - "" - "" - "geom" - "" - "49 2.2" - "50 3" - "" - "" - "" ); - - QTest::newRow( "intersects + wkt + explicit srs" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)', 'urn:ogc:def:crs:EPSG::4326'))" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "geom" - "" - "6 5" - "" - "" - "" ); - - QTest::newRow( "intersects + wkt + explicit srs int" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)', 4326))" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "geom" - "" - "6 5" - "" - "" - "" ); - - QTest::newRow( "dwithin + wkt" ) << QStringLiteral( "SELECT * FROM t WHERE ST_DWithin(geom, ST_GeometryFromText('POINT (5 6)', 'urn:ogc:def:crs:EPSG::4326'), '3 m')" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "geom" - "" - "6 5" - "" - "3" - "" - "" ); + QTest::newRow( "= 1.0" ) << QStringLiteral( "SELECT * FROM t WHERE NAME = 'New York'" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "NAME" + "New York" + "" + "" ); + + QTest::newRow( "= 2.0" ) << QStringLiteral( "SELECT * FROM t WHERE NAME = 'New York'" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "NAME" + "New York" + "" + "" ); + + QTest::newRow( ">" ) << QStringLiteral( "SELECT * FROM t WHERE COUNT > 3" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "COUNT" + "3" + "" ); + + QTest::newRow( "and+or" ) << QStringLiteral( "SELECT * FROM t WHERE (FIELD1 <= 10 OR FIELD1 > 20) AND STATUS >= 1.5" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "" + "" + "FIELD1" + "10" + "" + "" + "FIELD1" + "20" + "" + "" + "" + "STATUS" + "1.5" + "" + "" + "" ); + + QTest::newRow( "is null" ) << QStringLiteral( "SELECT * FROM t WHERE A IS NULL" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "A" + "" + "" ); + + QTest::newRow( "is not null" ) << QStringLiteral( "SELECT * FROM t WHERE A IS NOT NULL" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "" + "A" + "" + "" + "" ); + + QTest::newRow( "in" ) << QStringLiteral( "SELECT * FROM t WHERE A IN (10,20,30)" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "" + "A" + "10" + "" + "" + "A" + "20" + "" + "" + "A" + "30" + "" + "" + "" ); + + QTest::newRow( "not in" ) << QStringLiteral( "SELECT * FROM t WHERE A NOT IN (10,20,30)" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "" + "" + "A" + "10" + "" + "" + "A" + "20" + "" + "" + "A" + "30" + "" + "" + "" + "" ); + + QTest::newRow( "in" ) << QStringLiteral( "SELECT * FROM t WHERE A IN (10)" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "A" + "10" + "" + "" ); + + QTest::newRow( "not in" ) << QStringLiteral( "SELECT * FROM t WHERE A NOT IN (10)" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "" + "A" + "10" + "" + "" + "" ); + + QTest::newRow( "between" ) << QStringLiteral( "SELECT * FROM t WHERE A BETWEEN 1 AND 2" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "A" + "1" + "2" + "" + "" ); + + QTest::newRow( "not between" ) << QStringLiteral( "SELECT * FROM t WHERE A NOT BETWEEN 1 AND 2" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "" + "A" + "1" + "2" + "" + "" + "" ); + + QTest::newRow( "intersects + wkt" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)'))" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "geom" + "5,6" + "" + "" ); + + QTest::newRow( "contains + gml" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Contains(geom, ST_GeomFromGML('5,6'))" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "geom" + "5,6" + "" + "" ); + + QTest::newRow( "abs" ) << QStringLiteral( "SELECT * FROM t WHERE ABS(x) < 5" ) << QgsOgcUtils::GML_2_1_2 << QgsOgcUtils::FILTER_OGC_1_0 << layerProperties << QString( "" + "" + "" + "x" + "" + "5" + "" + "" ); + + QTest::newRow( "bbox + wkt + explicit srs" ) << QStringLiteral( "SELECT * FROM t WHERE BBOX(geom, ST_MakeEnvelope(2.2, 49, 3, 50, 4326))" ) << QgsOgcUtils::GML_3_1_0 << QgsOgcUtils::FILTER_OGC_1_1 << layerProperties << QString( "" + "" + "geom" + "" + "49 2.2" + "50 3" + "" + "" + "" ); + + QTest::newRow( "intersects + wkt + explicit srs" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)', 'urn:ogc:def:crs:EPSG::4326'))" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "geom" + "" + "6 5" + "" + "" + "" ); + + QTest::newRow( "intersects + wkt + explicit srs int" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)', 4326))" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "geom" + "" + "6 5" + "" + "" + "" ); + + QTest::newRow( "dwithin + wkt" ) << QStringLiteral( "SELECT * FROM t WHERE ST_DWithin(geom, ST_GeometryFromText('POINT (5 6)', 'urn:ogc:def:crs:EPSG::4326'), '3 m')" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "geom" + "" + "6 5" + "" + "3" + "" + "" ); QList layerProperties4326_FES20; QgsOgcUtils::LayerProperties prop; @@ -1206,73 +1161,61 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter_data() prop.mGeometryAttribute = QStringLiteral( "geom" ); layerProperties4326_FES20.append( prop ); - QTest::newRow( "intersects + wkt + implicit SRS" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)'))" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties4326_FES20 << QString( - "" - "" - "geom" - "" - "6 5" - "" - "" - "" ); - - QTest::newRow( "intersects join 2.0" ) << QStringLiteral( "SELECT * FROM t, t2 WHERE ST_Intersects(t.geom, t2.geom)" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "t/geom" - "t2/geom" - "" - "" ); - - QTest::newRow( "attrib join USING 2.0" ) << QStringLiteral( "SELECT * FROM t JOIN t2 USING (a)" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "t/a" - "t2/a" - "" - "" ); - - QTest::newRow( "attrib join multi USING 2.0" ) << QStringLiteral( "SELECT * FROM t JOIN t2 USING (a, b)" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "" - "t/a" - "t2/a" - "" - "" - "t/b" - "t2/b" - "" - "" - "" ); - - QTest::newRow( "attrib join ON 2.0" ) << QStringLiteral( "SELECT * FROM t aliased_t JOIN t2 aliasted_t2 ON aliased_t.a = aliasted_t2.b" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "t/a" - "t2/b" - "" - "" ); - - QTest::newRow( "attrib multi join 2.0" ) << QStringLiteral( "SELECT * FROM t aliased_t JOIN t2 aliasted_t2 ON aliased_t.a = aliasted_t2.b JOIN t3 USING (c)" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( - "" - "" - "" - "t/a" - "t2/b" - "" - "" - "t2/c" - "t3/c" - "" - "" - "" ); + QTest::newRow( "intersects + wkt + implicit SRS" ) << QStringLiteral( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)'))" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties4326_FES20 << QString( "" + "" + "geom" + "" + "6 5" + "" + "" + "" ); + + QTest::newRow( "intersects join 2.0" ) << QStringLiteral( "SELECT * FROM t, t2 WHERE ST_Intersects(t.geom, t2.geom)" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "t/geom" + "t2/geom" + "" + "" ); + + QTest::newRow( "attrib join USING 2.0" ) << QStringLiteral( "SELECT * FROM t JOIN t2 USING (a)" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "t/a" + "t2/a" + "" + "" ); + + QTest::newRow( "attrib join multi USING 2.0" ) << QStringLiteral( "SELECT * FROM t JOIN t2 USING (a, b)" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "" + "t/a" + "t2/a" + "" + "" + "t/b" + "t2/b" + "" + "" + "" ); + + QTest::newRow( "attrib join ON 2.0" ) << QStringLiteral( "SELECT * FROM t aliased_t JOIN t2 aliasted_t2 ON aliased_t.a = aliasted_t2.b" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "t/a" + "t2/b" + "" + "" ); + + QTest::newRow( "attrib multi join 2.0" ) << QStringLiteral( "SELECT * FROM t aliased_t JOIN t2 aliasted_t2 ON aliased_t.a = aliasted_t2.b JOIN t3 USING (c)" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString( "" + "" + "" + "t/a" + "t2/b" + "" + "" + "t2/c" + "t3/c" + "" + "" + "" ); QList layerPropertiesWithNameSpace; QgsOgcUtils::LayerProperties props; @@ -1281,15 +1224,12 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter_data() props.mNamespaceURI = QStringLiteral( "http://example.com/prefix" ); layerPropertiesWithNameSpace << props; - QTest::newRow( "namespace" ) << QStringLiteral( "SELECT * FROM mylayer WHERE NAME = 'New York'" ) << - QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerPropertiesWithNameSpace << - QString( - "" - "" - "prefix:NAME" - "New York" - "" - "" ); + QTest::newRow( "namespace" ) << QStringLiteral( "SELECT * FROM mylayer WHERE NAME = 'New York'" ) << QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerPropertiesWithNameSpace << QString( "" + "" + "prefix:NAME" + "New York" + "" + "" ); } void TestQgsOgcUtils::testExpressionToOgcFilterWithXPath() @@ -1305,10 +1245,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWithXPath() mapNamespacePrefixToUri["otherns"] = "https://otherns"; QDomDocument doc; - const QDomElement filterElem = QgsOgcUtils::expressionToOgcFilter( exp, doc, - QgsOgcUtils::GML_3_2_1, QgsOgcUtils::FILTER_FES_2_0, - QString(), QString(), - QStringLiteral( "my_geometry_name" ), QString(), true, false, &errorMsg, mapFieldNameToXPath, mapNamespacePrefixToUri ); + const QDomElement filterElem = QgsOgcUtils::expressionToOgcFilter( exp, doc, QgsOgcUtils::GML_3_2_1, QgsOgcUtils::FILTER_FES_2_0, QString(), QString(), QStringLiteral( "my_geometry_name" ), QString(), true, false, &errorMsg, mapFieldNameToXPath, mapNamespacePrefixToUri ); if ( !errorMsg.isEmpty() ) qDebug( "ERROR: %s", errorMsg.toLatin1().data() ); @@ -1323,7 +1260,6 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWithXPath() void TestQgsOgcUtils::testSQLStatementToOgcFilterWithXPath() { - const QgsSQLStatement statement( "SELECT * FROM t WHERE a = 1" ); if ( !statement.hasParserError() ) { @@ -1347,15 +1283,7 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilterWithXPath() prop.mSRSName = QStringLiteral( "urn:ogc:def:crs:EPSG::4326" ); prop.mGeometryAttribute = QStringLiteral( "geom" ); layerProperties.append( prop ); - const QDomElement filterElem = QgsOgcUtils::SQLStatementToOgcFilter( statement, - doc, - QgsOgcUtils::GML_3_2_1, - QgsOgcUtils::FILTER_FES_2_0, - layerProperties, - honourAxisOrientation, - invertAxisOrientation, - QMap(), - &errorMsg, mapFieldNameToXPath, mapNamespacePrefixToUri ); + const QDomElement filterElem = QgsOgcUtils::SQLStatementToOgcFilter( statement, doc, QgsOgcUtils::GML_3_2_1, QgsOgcUtils::FILTER_FES_2_0, layerProperties, honourAxisOrientation, invertAxisOrientation, QMap(), &errorMsg, mapFieldNameToXPath, mapNamespacePrefixToUri ); if ( !errorMsg.isEmpty() ) qDebug( "ERROR: %s", errorMsg.toLatin1().data() ); diff --git a/tests/src/core/testqgsogrprovider.cpp b/tests/src/core/testqgsogrprovider.cpp index 0baac23f69e9..86f987bad571 100644 --- a/tests/src/core/testqgsogrprovider.cpp +++ b/tests/src/core/testqgsogrprovider.cpp @@ -42,11 +42,12 @@ class TestQgsOgrProvider : public QgsTest Q_OBJECT public: - TestQgsOgrProvider() : QgsTest( QStringLiteral( "OGR Provider Tests" ) ) {} + TestQgsOgrProvider() + : QgsTest( QStringLiteral( "OGR Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void setupProxy(); void decodeUri(); @@ -66,7 +67,6 @@ class TestQgsOgrProvider : public QgsTest }; - //runs before all tests void TestQgsOgrProvider::initTestCase() { @@ -92,7 +92,6 @@ void TestQgsOgrProvider::cleanupTestCase() void TestQgsOgrProvider::setupProxy() { - QgsSettings settings; { settings.setValue( QStringLiteral( "proxy/proxyEnabled" ), true ); @@ -308,13 +307,12 @@ class ReadVectorLayer : public QThread { Q_OBJECT - public : + public: ReadVectorLayer( const QString &filePath, QMutex &mutex, QWaitCondition &waitForVlCreation, QWaitCondition &waitForProcessEvents ) : _filePath( filePath ), _mutex( mutex ), _waitForVlCreation( waitForVlCreation ), _waitForProcessEvents( waitForProcessEvents ) {} void run() override { - QgsVectorLayer *vl2 = new QgsVectorLayer( _filePath, QStringLiteral( "thread_test" ), QLatin1String( "ogr" ) ); QgsFeature f; @@ -336,7 +334,6 @@ class ReadVectorLayer : public QThread QMutex &_mutex; QWaitCondition &_waitForVlCreation; QWaitCondition &_waitForProcessEvents; - }; void failOnWarning( QtMsgType type, const QMessageLogContext &context, const QString &msg ) @@ -389,7 +386,6 @@ void TestQgsOgrProvider::testThread() thread->wait(); qInstallMessageHandler( 0 ); - } void TestQgsOgrProvider::testCsvFeatureAddition() @@ -499,12 +495,12 @@ void TestQgsOgrProvider::testExtent() void TestQgsOgrProvider::testVsiCredentialOptions() { -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 6, 0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 6, 0 ) // test that credential options are correctly set when layer URI specifies them // if actual aws dataset proves flaky, use this instead: // std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "/vsis3/testbucket/test|credential:AWS_NO_SIGN_REQUEST=YES|credential:AWS_REGION=eu-central-1|credential:AWS_S3_ENDPOINT=localhost" ), QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "/vsis3/cdn.proj.org/files.geojson|credential:AWS_NO_SIGN_REQUEST=YES" ), QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "/vsis3/cdn.proj.org/files.geojson|credential:AWS_NO_SIGN_REQUEST=YES" ), QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); // confirm that GDAL VSI configuration options are set QString noSign( VSIGetPathSpecificOption( "/vsis3/cdn.proj.org", "AWS_NO_SIGN_REQUEST", nullptr ) ); @@ -521,7 +517,7 @@ void TestQgsOgrProvider::testVsiCredentialOptions() QCOMPARE( vl->dataProvider()->dataSourceUri(), QStringLiteral( "/vsis3/cdn.proj.org/files.geojson|credential:AWS_NO_SIGN_REQUEST=YES" ) ); // credentials should be bucket specific - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "/vsis3/ogranother/subfolder/subfolder2/test|credential:AWS_NO_SIGN_REQUEST=NO|credential:AWS_REGION=eu-central-2|credential:AWS_S3_ENDPOINT=localhost" ), QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); + std::unique_ptr vl2 = std::make_unique( QStringLiteral( "/vsis3/ogranother/subfolder/subfolder2/test|credential:AWS_NO_SIGN_REQUEST=NO|credential:AWS_REGION=eu-central-2|credential:AWS_S3_ENDPOINT=localhost" ), QStringLiteral( "test" ), QStringLiteral( "ogr" ) ); noSign = QString( VSIGetPathSpecificOption( "/vsis3/cdn.proj.org", "AWS_NO_SIGN_REQUEST", nullptr ) ); QCOMPARE( noSign, QStringLiteral( "YES" ) ); region = QString( VSIGetPathSpecificOption( "/vsis3/cdn.proj.org", "AWS_REGION", nullptr ) ); @@ -545,7 +541,7 @@ void TestQgsOgrProvider::testVsiCredentialOptions() void TestQgsOgrProvider::testVsiCredentialOptionsQuerySublayers() { -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 6, 0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 6, 0 ) QgsProviderMetadata *ogrMetadata = QgsProviderRegistry::instance()->providerMetadata( "ogr" ); QVERIFY( ogrMetadata ); @@ -553,7 +549,7 @@ void TestQgsOgrProvider::testVsiCredentialOptionsQuerySublayers() // if actual aws dataset proves flaky, use this instead: // QList< QgsProviderSublayerDetails> subLayers = ogrMetadata->querySublayers( QStringLiteral( "/vsis3/sublayerstestbucket/test.shp|credential:AWS_NO_SIGN_REQUEST=YES|credential:AWS_REGION=eu-central-3|credential:AWS_S3_ENDPOINT=localhost" ) ); - QList< QgsProviderSublayerDetails> subLayers = ogrMetadata->querySublayers( QStringLiteral( "/vsis3/cdn.proj.org/files.geojson|credential:AWS_NO_SIGN_REQUEST=YES" ) ); + QList subLayers = ogrMetadata->querySublayers( QStringLiteral( "/vsis3/cdn.proj.org/files.geojson|credential:AWS_NO_SIGN_REQUEST=YES" ) ); QCOMPARE( subLayers.size(), 1 ); QCOMPARE( subLayers.at( 0 ).name(), QStringLiteral( "files" ) ); diff --git a/tests/src/core/testqgsogrutils.cpp b/tests/src/core/testqgsogrutils.cpp index 927cdab83525..872c329baea2 100644 --- a/tests/src/core/testqgsogrutils.cpp +++ b/tests/src/core/testqgsogrutils.cpp @@ -41,15 +41,15 @@ #include "qgsogrproviderutils.h" #include "qgssinglesymbolrenderer.h" -class TestQgsOgrUtils: public QObject +class TestQgsOgrUtils : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void ogrGeometryToQgsGeometry(); void ogrGeometryToQgsGeometry2_data(); void ogrGeometryToQgsGeometry2(); @@ -75,18 +75,17 @@ class TestQgsOgrUtils: public QObject void testOgrStringToVariant(); void testOgrUtilsStoredStyle(); -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,3,0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 3, 0 ) void testConvertFieldDomain(); void testConvertToFieldDomain(); #endif -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,6,0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 6, 0 ) void testConvertGdalRelationship(); void testConvertToGdalRelationship(); #endif private: - QString mTestDataDir; QString mTestFile; }; @@ -110,12 +109,10 @@ void TestQgsOgrUtils::cleanupTestCase() void TestQgsOgrUtils::init() { - } void TestQgsOgrUtils::cleanup() { - } void TestQgsOgrUtils::ogrGeometryToQgsGeometry() @@ -212,23 +209,23 @@ void TestQgsOgrUtils::ogrGeometryToQgsGeometry2_data() QTest::addColumn( "wkt" ); QTest::addColumn( "type" ); - QTest::newRow( "point" ) << QStringLiteral( "Point (1.1 2.2)" ) << static_cast< int >( Qgis::WkbType::Point ); - QTest::newRow( "pointz" ) << QStringLiteral( "Point Z (1.1 2.2 3.3)" ) << static_cast< int >( Qgis::WkbType::PointZ ); - QTest::newRow( "pointm" ) << QStringLiteral( "Point M (1.1 2.2 3.3)" ) << static_cast< int >( Qgis::WkbType::PointM ); - QTest::newRow( "pointzm" ) << QStringLiteral( "Point ZM (1.1 2.2 3.3 4.4)" ) << static_cast< int >( Qgis::WkbType::PointZM ); - QTest::newRow( "point25d" ) << QStringLiteral( "Point25D (1.1 2.2 3.3)" ) << static_cast< int >( Qgis::WkbType::PointZ ); - - QTest::newRow( "linestring" ) << QStringLiteral( "LineString (1.1 2.2, 3.3 4.4)" ) << static_cast< int >( Qgis::WkbType::LineString ); - QTest::newRow( "linestringz" ) << QStringLiteral( "LineString Z (1.1 2.2 3.3, 4.4 5.5 6.6)" ) << static_cast< int >( Qgis::WkbType::LineStringZ ); - QTest::newRow( "linestringm" ) << QStringLiteral( "LineString M (1.1 2.2 3.3, 4.4 5.5 6.6)" ) << static_cast< int >( Qgis::WkbType::LineStringM ); - QTest::newRow( "linestringzm" ) << QStringLiteral( "LineString ZM (1.1 2.2 3.3 4.4, 5.5 6.6 7.7 8.8)" ) << static_cast< int >( Qgis::WkbType::LineStringZM ); - QTest::newRow( "linestring25d" ) << QStringLiteral( "LineString25D (1.1 2.2 3.3, 4.4 5.5 6.6)" ) << static_cast< int >( Qgis::WkbType::LineStringZ ); - - QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString ((1.1 2.2, 3.3 4.4))" ) << static_cast< int >( Qgis::WkbType::MultiLineString ); - QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString ((1.1 2.2, 3.3 4.4),(5 5, 6 6))" ) << static_cast< int >( Qgis::WkbType::MultiLineString ); - QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString Z ((1.1 2.2 3, 3.3 4.4 6),(5 5 3, 6 6 1))" ) << static_cast< int >( Qgis::WkbType::MultiLineStringZ ); - QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString M ((1.1 2.2 4, 3.3 4.4 7),(5 5 4, 6 6 2))" ) << static_cast< int >( Qgis::WkbType::MultiLineStringM ); - QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString ZM ((1.1 2.2 4 5, 3.3 4.4 8 9),(5 5 7 1, 6 6 2 3))" ) << static_cast< int >( Qgis::WkbType::MultiLineStringZM ); + QTest::newRow( "point" ) << QStringLiteral( "Point (1.1 2.2)" ) << static_cast( Qgis::WkbType::Point ); + QTest::newRow( "pointz" ) << QStringLiteral( "Point Z (1.1 2.2 3.3)" ) << static_cast( Qgis::WkbType::PointZ ); + QTest::newRow( "pointm" ) << QStringLiteral( "Point M (1.1 2.2 3.3)" ) << static_cast( Qgis::WkbType::PointM ); + QTest::newRow( "pointzm" ) << QStringLiteral( "Point ZM (1.1 2.2 3.3 4.4)" ) << static_cast( Qgis::WkbType::PointZM ); + QTest::newRow( "point25d" ) << QStringLiteral( "Point25D (1.1 2.2 3.3)" ) << static_cast( Qgis::WkbType::PointZ ); + + QTest::newRow( "linestring" ) << QStringLiteral( "LineString (1.1 2.2, 3.3 4.4)" ) << static_cast( Qgis::WkbType::LineString ); + QTest::newRow( "linestringz" ) << QStringLiteral( "LineString Z (1.1 2.2 3.3, 4.4 5.5 6.6)" ) << static_cast( Qgis::WkbType::LineStringZ ); + QTest::newRow( "linestringm" ) << QStringLiteral( "LineString M (1.1 2.2 3.3, 4.4 5.5 6.6)" ) << static_cast( Qgis::WkbType::LineStringM ); + QTest::newRow( "linestringzm" ) << QStringLiteral( "LineString ZM (1.1 2.2 3.3 4.4, 5.5 6.6 7.7 8.8)" ) << static_cast( Qgis::WkbType::LineStringZM ); + QTest::newRow( "linestring25d" ) << QStringLiteral( "LineString25D (1.1 2.2 3.3, 4.4 5.5 6.6)" ) << static_cast( Qgis::WkbType::LineStringZ ); + + QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString ((1.1 2.2, 3.3 4.4))" ) << static_cast( Qgis::WkbType::MultiLineString ); + QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString ((1.1 2.2, 3.3 4.4),(5 5, 6 6))" ) << static_cast( Qgis::WkbType::MultiLineString ); + QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString Z ((1.1 2.2 3, 3.3 4.4 6),(5 5 3, 6 6 1))" ) << static_cast( Qgis::WkbType::MultiLineStringZ ); + QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString M ((1.1 2.2 4, 3.3 4.4 7),(5 5 4, 6 6 2))" ) << static_cast( Qgis::WkbType::MultiLineStringM ); + QTest::newRow( "linestring" ) << QStringLiteral( "MultiLineString ZM ((1.1 2.2 4 5, 3.3 4.4 8 9),(5 5 7 1, 6 6 2 3))" ) << static_cast( Qgis::WkbType::MultiLineStringZM ); } void TestQgsOgrUtils::ogrGeometryToQgsGeometry2() @@ -247,7 +244,7 @@ void TestQgsOgrUtils::ogrGeometryToQgsGeometry2() // back again! const QgsGeometry geom = QgsOgrUtils::ogrGeometryToQgsGeometry( ogrGeom ); - QCOMPARE( static_cast< int >( geom.wkbType() ), type ); + QCOMPARE( static_cast( geom.wkbType() ), type ); OGR_G_DestroyGeometry( ogrGeom ); // bit of trickiness here - QGIS wkt conversion changes 25D -> Z, so account for that @@ -484,26 +481,27 @@ void TestQgsOgrUtils::stringToFeatureList() QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() ); QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); QgsGeometry featureGeom = features.at( 0 ).geometry(); - const QgsPoint *point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + const QgsPoint *point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 125.0 ); QCOMPARE( point->y(), 10.0 ); QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) ); // geojson string with 2 features features = QgsOgrUtils::stringToFeatureList( "{ \"type\": \"FeatureCollection\",\"features\":[{\n\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\",\"coordinates\": [125, 10]},\"properties\": {\"name\": \"Dinagat Islands\"}}," - " {\n\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\",\"coordinates\": [110, 20]},\"properties\": {\"name\": \"Henry Gale Island\"}}]}", fields, QTextCodec::codecForName( "System" ) ); + " {\n\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\",\"coordinates\": [110, 20]},\"properties\": {\"name\": \"Henry Gale Island\"}}]}", + fields, QTextCodec::codecForName( "System" ) ); QCOMPARE( features.length(), 2 ); QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() ); QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); featureGeom = features.at( 0 ).geometry(); - point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 125.0 ); QCOMPARE( point->y(), 10.0 ); QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) ); QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() ); QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), Qgis::WkbType::Point ); featureGeom = features.at( 1 ).geometry(); - point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() ); + point = dynamic_cast( featureGeom.constGet() ); QCOMPARE( point->x(), 110.0 ); QCOMPARE( point->y(), 20.0 ); QCOMPARE( features.at( 1 ).attribute( "name" ).toString(), QString( "Henry Gale Island" ) ); @@ -552,33 +550,22 @@ void TestQgsOgrUtils::parseStyleString_data() QTest::addColumn( "string" ); QTest::addColumn( "expected" ); - QTest::newRow( "symbol" ) << QStringLiteral( R"""(SYMBOL(a:0,c:#000000,s:12pt,id:"mapinfo-sym-35,ogr-sym-10"))""" ) << QVariantMap{ { "symbol", QVariantMap{ { "a", "0"}, - {"c", "#000000"}, - {"s", "12pt"}, - {"id", "mapinfo-sym-35,ogr-sym-10"}, - } - } }; + QTest::newRow( "symbol" ) << QStringLiteral( R"""(SYMBOL(a:0,c:#000000,s:12pt,id:"mapinfo-sym-35,ogr-sym-10"))""" ) << QVariantMap { { "symbol", QVariantMap { + { "a", "0" }, + { "c", "#000000" }, + { "s", "12pt" }, + { "id", "mapinfo-sym-35,ogr-sym-10" }, + } } }; - QTest::newRow( "pen" ) << QStringLiteral( R"""(PEN(w:2px,c:#ffb060,id:"mapinfo-pen-14,ogr-pen-6",p:"8 2 1 2px"))""" ) << QVariantMap{ { "pen", QVariantMap{ { "w", "2px"}, - {"c", "#ffb060"}, - {"id", "mapinfo-pen-14,ogr-pen-6"}, - {"p", "8 2 1 2px"}, - } - } }; + QTest::newRow( "pen" ) << QStringLiteral( R"""(PEN(w:2px,c:#ffb060,id:"mapinfo-pen-14,ogr-pen-6",p:"8 2 1 2px"))""" ) << QVariantMap { { "pen", QVariantMap { + { "w", "2px" }, + { "c", "#ffb060" }, + { "id", "mapinfo-pen-14,ogr-pen-6" }, + { "p", "8 2 1 2px" }, + } } }; QTest::newRow( "brush and pen" ) << QStringLiteral( R"""(BRUSH(FC:#ff8000,bc:#f0f000,id:"mapinfo-brush-6,ogr-brush-4");pen(W:3px,c:#e00000,id:"mapinfo-pen-2,ogr-pen-0"))""" ) - << QVariantMap{ { "brush", QVariantMap{ { "fc", "#ff8000"}, - {"bc", "#f0f000"}, - {"id", "mapinfo-brush-6,ogr-brush-4"} - } - }, - { - "pen", QVariantMap{ { "w", "3px"}, - {"c", "#e00000"}, - {"id", "mapinfo-pen-2,ogr-pen-0"} - } - } - }; + << QVariantMap { { "brush", QVariantMap { { "fc", "#ff8000" }, { "bc", "#f0f000" }, { "id", "mapinfo-brush-6,ogr-brush-4" } } }, { "pen", QVariantMap { { "w", "3px" }, { "c", "#e00000" }, { "id", "mapinfo-pen-2,ogr-pen-0" } } } }; } void TestQgsOgrUtils::parseStyleString() @@ -597,150 +584,150 @@ void TestQgsOgrUtils::convertStyleString() symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(PEN(w:7px,c:#0040c0,id:"mapinfo-pen-5,ogr-pen-3",p:"3 1px"))""" ), Qgis::SymbolType::Line ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( dynamic_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#0040c0" ) ); + QCOMPARE( dynamic_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#0040c0" ) ); // px sizes should be converted to pts - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->width(), 5.25 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->widthUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penCapStyle(), Qt::RoundCap ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penJoinStyle(), Qt::RoundJoin ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->customDashVector().at( 0 ), 21.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->customDashVector().at( 1 ), 10.5 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->customDashPatternUnit(), Qgis::RenderUnit::Points ); - QVERIFY( qgis::down_cast( symbol->symbolLayer( 0 ) )->useCustomDashPattern() ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->width(), 5.25 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->widthUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penCapStyle(), Qt::RoundCap ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penJoinStyle(), Qt::RoundJoin ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->customDashVector().at( 0 ), 21.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->customDashVector().at( 1 ), 10.5 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->customDashPatternUnit(), Qgis::RenderUnit::Points ); + QVERIFY( qgis::down_cast( symbol->symbolLayer( 0 ) )->useCustomDashPattern() ); symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(PEN(c:#00000087,w:10.500000cm,cap:p,j:b))""" ), Qgis::SymbolType::Line ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#000000" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 135 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->width(), 105.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->widthUnit(), Qgis::RenderUnit::Millimeters ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penCapStyle(), Qt::SquareCap ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penJoinStyle(), Qt::BevelJoin ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#000000" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 135 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->width(), 105.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->widthUnit(), Qgis::RenderUnit::Millimeters ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penCapStyle(), Qt::SquareCap ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->penJoinStyle(), Qt::BevelJoin ); // both brush and pen, but requesting a line symbol only symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(PEN(c:#FFFF007F,w:4.000000pt);BRUSH(fc:#00FF007F))""" ), Qgis::SymbolType::Line ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#ffff00" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 127 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->width(), 4.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->widthUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#ffff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 127 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->width(), 4.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->widthUnit(), Qgis::RenderUnit::Points ); // brush symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(BRUSH(fc:#00FF007F))""" ), Qgis::SymbolType::Fill ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 127 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::SolidPattern ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 127 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::SolidPattern ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(BRUSH(fc:#00FF007F,bc:#00000087,id:ogr-brush-6))""" ), Qgis::SymbolType::Fill ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 2 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#000000" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 135 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::SolidPattern ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->color().name(), QStringLiteral( "#00ff00" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->color().alpha(), 127 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->brushStyle(), Qt::CrossPattern ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->strokeStyle(), Qt::NoPen ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#000000" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 135 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::SolidPattern ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->color().name(), QStringLiteral( "#00ff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->color().alpha(), 127 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->brushStyle(), Qt::CrossPattern ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 1 ) )->strokeStyle(), Qt::NoPen ); // brush with pen symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(PEN(c:#FFFF007F,w:4.000000pt);BRUSH(fc:#00FF007F))""" ), Qgis::SymbolType::Fill ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 127 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::SolidPattern ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#ffff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 127 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::SolidPattern ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#ffff00" ) ); // no brush, but need fill symbol symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(PEN(c:#FFFF007F,w:4.000000pt))""" ), Qgis::SymbolType::Fill ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::NoBrush ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#ffff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->brushStyle(), Qt::NoBrush ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#ffff00" ) ); // symbol symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(SYMBOL(a:0,c:#5050ff,s:36pt,id:"ogr-sym-5"))""" ), Qgis::SymbolType::Marker ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#5050ff" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Square ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#5050ff" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Square ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(SYMBOL(a:0,c:#5050ff,s:36pt,id:"ogr-sym-6"))""" ), Qgis::SymbolType::Marker ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#5050ff" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Triangle ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().alpha(), 0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#5050ff" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Triangle ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(SYMBOL(a:20,c:#5050ff,s:36pt,id:"ogr-sym-5"))""" ), Qgis::SymbolType::Marker ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#5050ff" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Square ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#5050ff" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Square ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); // OGR symbol angles are opposite direction to qgis marker angles - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), -20.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), -20.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(SYMBOL(c:#5050ff,o:#3030ff,s:36pt,id:"ogr-sym-5"))""" ), Qgis::SymbolType::Marker ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#5050ff" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Square ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#3030ff" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#5050ff" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Square ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 36.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::SolidLine ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#3030ff" ) ); // font symbol const QFont f = QgsFontUtils::getStandardTestFont(); symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(SYMBOL(c:#00FF00,s:12pt,id:"font-sym-75,ogr-sym-9",f:"%1"))""" ).arg( f.family() ), Qgis::SymbolType::Marker ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->character(), QStringLiteral( "K" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 12.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeWidth(), 0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->character(), QStringLiteral( "K" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 12.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeWidth(), 0 ); symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(SYMBOL(a:20,c:#00FF00,o:#3030ff,s:12pt,id:"font-sym-75,ogr-sym-9",f:"%1"))""" ).arg( f.family() ), Qgis::SymbolType::Marker ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->character(), QStringLiteral( "K" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 12.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), -20.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeWidth(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeWidthUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#3030ff" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->character(), QStringLiteral( "K" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 12.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), -20.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeWidth(), 1 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeWidthUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeColor().name(), QStringLiteral( "#3030ff" ) ); // bad font name, should fallback to ogr symbol id symbol = QgsOgrUtils::symbolFromStyleString( QStringLiteral( R"""(SYMBOL(c:#00FF00,s:12pt,id:"font-sym-75,ogr-sym-9",f:"xxxxxx"))""" ), Qgis::SymbolType::Marker ); QVERIFY( symbol ); QCOMPARE( symbol->symbolLayerCount(), 1 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Star ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 12.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); - QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->color().name(), QStringLiteral( "#00ff00" ) ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->shape(), Qgis::MarkerShape::Star ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->size(), 12.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->angle(), 0.0 ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->sizeUnit(), Qgis::RenderUnit::Points ); + QCOMPARE( qgis::down_cast( symbol->symbolLayer( 0 ) )->strokeStyle(), Qt::NoPen ); } void TestQgsOgrUtils::ogrCrsConversion() @@ -764,7 +751,7 @@ void TestQgsOgrUtils::ogrCrsConversion() QCOMPARE( crs1, crs2 ); OSRRelease( srs ); -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,4,0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 4, 0 ) QVERIFY( std::isnan( crs2.coordinateEpoch() ) ); #endif } @@ -778,7 +765,7 @@ void TestQgsOgrUtils::ogrCrsConversion() QVERIFY( !crs.bounds().isEmpty() ); } -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,4,0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 4, 0 ) { // test conversion with a coordinate epoch, should work on GDAL 3.4+ QgsCoordinateReferenceSystem crs1( QStringLiteral( "EPSG:4326" ) ); @@ -918,7 +905,6 @@ void TestQgsOgrUtils::variantToOgrField() // Incompatible data type field = QgsOgrUtils::variantToOGRField( QVariant( QDateTime( QDate( 2021, 2, 3 ), QTime( 12, 13, 14, 50 ) ) ), OFTInteger ); QCOMPARE( QgsOgrUtils::OGRFieldtoVariant( field.get(), OFTInteger ), QVariant() ); - } void TestQgsOgrUtils::testOgrFieldTypeToQVariantType_data() @@ -928,29 +914,29 @@ void TestQgsOgrUtils::testOgrFieldTypeToQVariantType_data() QTest::addColumn( "expectedType" ); QTest::addColumn( "expectedSubType" ); - QTest::newRow( "OFTInteger" ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::Int ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTIntegerList" ) << static_cast< int >( OFTIntegerList ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QVariantList ) << static_cast< int >( QMetaType::Type::Int ); + QTest::newRow( "OFTInteger" ) << static_cast( OFTInteger ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::Int ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTIntegerList" ) << static_cast( OFTIntegerList ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QVariantList ) << static_cast( QMetaType::Type::Int ); - QTest::newRow( "OFSTBoolean" ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTBoolean ) << static_cast< int >( QMetaType::Type::Bool ) << static_cast< int >( QMetaType::Type::UnknownType ); + QTest::newRow( "OFSTBoolean" ) << static_cast( OFTInteger ) << static_cast( OFSTBoolean ) << static_cast( QMetaType::Type::Bool ) << static_cast( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTReal" ) << static_cast< int >( OFTReal ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::Double ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTRealList" ) << static_cast< int >( OFTRealList ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QVariantList ) << static_cast< int >( QMetaType::Type::Double ); + QTest::newRow( "OFTReal" ) << static_cast( OFTReal ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::Double ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTRealList" ) << static_cast( OFTRealList ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QVariantList ) << static_cast( QMetaType::Type::Double ); - QTest::newRow( "OFTString" ) << static_cast< int >( OFTString ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QString ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTStringList" ) << static_cast< int >( OFTStringList ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QStringList ) << static_cast< int >( QMetaType::Type::QString ); - QTest::newRow( "OFTWideString" ) << static_cast< int >( OFTWideString ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QString ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTWideStringList" ) << static_cast< int >( OFTWideStringList ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QStringList ) << static_cast< int >( QMetaType::Type::QString ); + QTest::newRow( "OFTString" ) << static_cast( OFTString ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QString ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTStringList" ) << static_cast( OFTStringList ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QStringList ) << static_cast( QMetaType::Type::QString ); + QTest::newRow( "OFTWideString" ) << static_cast( OFTWideString ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QString ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTWideStringList" ) << static_cast( OFTWideStringList ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QStringList ) << static_cast( QMetaType::Type::QString ); - QTest::newRow( "OFTString OFSTJSON" ) << static_cast< int >( OFTString ) << static_cast< int >( OFSTJSON ) << static_cast< int >( QMetaType::Type::QVariantMap ) << static_cast< int >( QMetaType::Type::QString ); - QTest::newRow( "OFTWideString OFSTJSON" ) << static_cast< int >( OFTWideString ) << static_cast< int >( OFSTJSON ) << static_cast< int >( QMetaType::Type::QVariantMap ) << static_cast< int >( QMetaType::Type::QString ); + QTest::newRow( "OFTString OFSTJSON" ) << static_cast( OFTString ) << static_cast( OFSTJSON ) << static_cast( QMetaType::Type::QVariantMap ) << static_cast( QMetaType::Type::QString ); + QTest::newRow( "OFTWideString OFSTJSON" ) << static_cast( OFTWideString ) << static_cast( OFSTJSON ) << static_cast( QMetaType::Type::QVariantMap ) << static_cast( QMetaType::Type::QString ); - QTest::newRow( "OFTInteger64" ) << static_cast< int >( OFTInteger64 ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::LongLong ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTInteger64List" ) << static_cast< int >( OFTInteger64List ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QVariantList ) << static_cast< int >( QMetaType::Type::LongLong ); + QTest::newRow( "OFTInteger64" ) << static_cast( OFTInteger64 ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::LongLong ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTInteger64List" ) << static_cast( OFTInteger64List ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QVariantList ) << static_cast( QMetaType::Type::LongLong ); - QTest::newRow( "OFTBinary" ) << static_cast< int >( OFTBinary ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QByteArray ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTDate" ) << static_cast< int >( OFTDate ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QDate ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTTime" ) << static_cast< int >( OFTTime ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QTime ) << static_cast< int >( QMetaType::Type::UnknownType ); - QTest::newRow( "OFTDateTime" ) << static_cast< int >( OFTDateTime ) << static_cast< int >( OFSTNone ) << static_cast< int >( QMetaType::Type::QDateTime ) << static_cast< int >( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTBinary" ) << static_cast( OFTBinary ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QByteArray ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTDate" ) << static_cast( OFTDate ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QDate ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTTime" ) << static_cast( OFTTime ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QTime ) << static_cast( QMetaType::Type::UnknownType ); + QTest::newRow( "OFTDateTime" ) << static_cast( OFTDateTime ) << static_cast( OFSTNone ) << static_cast( QMetaType::Type::QDateTime ) << static_cast( QMetaType::Type::UnknownType ); } void TestQgsOgrUtils::testOgrFieldTypeToQVariantType() @@ -962,11 +948,9 @@ void TestQgsOgrUtils::testOgrFieldTypeToQVariantType() QMetaType::Type variantType; QMetaType::Type variantSubType; - QgsOgrUtils::ogrFieldTypeToQVariantType( static_cast( ogrType ), - static_cast( ogrSubType ), - variantType, variantSubType ); - QCOMPARE( static_cast< int >( variantType ), expectedType ); - QCOMPARE( static_cast< int >( variantSubType ), expectedSubType ); + QgsOgrUtils::ogrFieldTypeToQVariantType( static_cast( ogrType ), static_cast( ogrSubType ), variantType, variantSubType ); + QCOMPARE( static_cast( variantType ), expectedType ); + QCOMPARE( static_cast( variantSubType ), expectedSubType ); } void TestQgsOgrUtils::testVariantTypeToOgrFieldType_data() @@ -975,17 +959,17 @@ void TestQgsOgrUtils::testVariantTypeToOgrFieldType_data() QTest::addColumn( "expectedType" ); QTest::addColumn( "expectedSubType" ); - QTest::newRow( "Bool" ) << static_cast< int >( QMetaType::Type::Bool ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTBoolean ); - QTest::newRow( "Int" ) << static_cast< int >( QMetaType::Type::Int ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTNone ); - QTest::newRow( "LongLong" ) << static_cast< int >( QMetaType::Type::LongLong ) << static_cast< int >( OFTInteger64 ) << static_cast< int >( OFSTNone ); - QTest::newRow( "Double" ) << static_cast< int >( QMetaType::Type::Double ) << static_cast< int >( OFTReal ) << static_cast< int >( OFSTNone ); - QTest::newRow( "Char" ) << static_cast< int >( QMetaType::Type::QChar ) << static_cast< int >( OFTString ) << static_cast< int >( OFSTNone ); - QTest::newRow( "String" ) << static_cast< int >( QMetaType::Type::QString ) << static_cast< int >( OFTString ) << static_cast< int >( OFSTNone ); - QTest::newRow( "StringList" ) << static_cast< int >( QMetaType::Type::QStringList ) << static_cast< int >( OFTStringList ) << static_cast< int >( OFSTNone ); - QTest::newRow( "ByteArray" ) << static_cast< int >( QMetaType::Type::QByteArray ) << static_cast< int >( OFTBinary ) << static_cast< int >( OFSTNone ); - QTest::newRow( "Date" ) << static_cast< int >( QMetaType::Type::QDate ) << static_cast< int >( OFTDate ) << static_cast< int >( OFSTNone ); - QTest::newRow( "Time" ) << static_cast< int >( QMetaType::Type::QTime ) << static_cast< int >( OFTTime ) << static_cast< int >( OFSTNone ); - QTest::newRow( "DateTime" ) << static_cast< int >( QMetaType::Type::QDateTime ) << static_cast< int >( OFTDateTime ) << static_cast< int >( OFSTNone ); + QTest::newRow( "Bool" ) << static_cast( QMetaType::Type::Bool ) << static_cast( OFTInteger ) << static_cast( OFSTBoolean ); + QTest::newRow( "Int" ) << static_cast( QMetaType::Type::Int ) << static_cast( OFTInteger ) << static_cast( OFSTNone ); + QTest::newRow( "LongLong" ) << static_cast( QMetaType::Type::LongLong ) << static_cast( OFTInteger64 ) << static_cast( OFSTNone ); + QTest::newRow( "Double" ) << static_cast( QMetaType::Type::Double ) << static_cast( OFTReal ) << static_cast( OFSTNone ); + QTest::newRow( "Char" ) << static_cast( QMetaType::Type::QChar ) << static_cast( OFTString ) << static_cast( OFSTNone ); + QTest::newRow( "String" ) << static_cast( QMetaType::Type::QString ) << static_cast( OFTString ) << static_cast( OFSTNone ); + QTest::newRow( "StringList" ) << static_cast( QMetaType::Type::QStringList ) << static_cast( OFTStringList ) << static_cast( OFSTNone ); + QTest::newRow( "ByteArray" ) << static_cast( QMetaType::Type::QByteArray ) << static_cast( OFTBinary ) << static_cast( OFSTNone ); + QTest::newRow( "Date" ) << static_cast( QMetaType::Type::QDate ) << static_cast( OFTDate ) << static_cast( OFSTNone ); + QTest::newRow( "Time" ) << static_cast( QMetaType::Type::QTime ) << static_cast( OFTTime ) << static_cast( OFSTNone ); + QTest::newRow( "DateTime" ) << static_cast( QMetaType::Type::QDateTime ) << static_cast( OFTDateTime ) << static_cast( OFSTNone ); } void TestQgsOgrUtils::testVariantTypeToOgrFieldType() @@ -996,10 +980,9 @@ void TestQgsOgrUtils::testVariantTypeToOgrFieldType() OGRFieldType type; OGRFieldSubType subType; - QgsOgrUtils::variantTypeToOgrFieldType( static_cast( variantType ), - type, subType ); - QCOMPARE( static_cast< int >( type ), expectedType ); - QCOMPARE( static_cast< int >( subType ), expectedSubType ); + QgsOgrUtils::variantTypeToOgrFieldType( static_cast( variantType ), type, subType ); + QCOMPARE( static_cast( type ), expectedType ); + QCOMPARE( static_cast( subType ), expectedSubType ); } void TestQgsOgrUtils::testOgrStringToVariant_data() @@ -1009,30 +992,30 @@ void TestQgsOgrUtils::testOgrStringToVariant_data() QTest::addColumn( "string" ); QTest::addColumn( "expected" ); - QTest::newRow( "OFTInteger null" ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTInteger 5" ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTNone ) << QStringLiteral( "5" ) << QVariant( 5 ); + QTest::newRow( "OFTInteger null" ) << static_cast( OFTInteger ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTInteger 5" ) << static_cast( OFTInteger ) << static_cast( OFSTNone ) << QStringLiteral( "5" ) << QVariant( 5 ); - QTest::newRow( "OFTInteger64 null" ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTInteger64 5" ) << static_cast< int >( OFTInteger ) << static_cast< int >( OFSTNone ) << QStringLiteral( "5" ) << QVariant( 5LL ); + QTest::newRow( "OFTInteger64 null" ) << static_cast( OFTInteger ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTInteger64 5" ) << static_cast( OFTInteger ) << static_cast( OFSTNone ) << QStringLiteral( "5" ) << QVariant( 5LL ); - QTest::newRow( "OFTReal null" ) << static_cast< int >( OFTReal ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTReal 5.5" ) << static_cast< int >( OFTReal ) << static_cast< int >( OFSTNone ) << QStringLiteral( "5.5" ) << QVariant( 5.5 ); - QTest::newRow( "OFTReal -5.5" ) << static_cast< int >( OFTReal ) << static_cast< int >( OFSTNone ) << QStringLiteral( "-5.5" ) << QVariant( -5.5 ); + QTest::newRow( "OFTReal null" ) << static_cast( OFTReal ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTReal 5.5" ) << static_cast( OFTReal ) << static_cast( OFSTNone ) << QStringLiteral( "5.5" ) << QVariant( 5.5 ); + QTest::newRow( "OFTReal -5.5" ) << static_cast( OFTReal ) << static_cast( OFSTNone ) << QStringLiteral( "-5.5" ) << QVariant( -5.5 ); - QTest::newRow( "OFTString null" ) << static_cast< int >( OFTString ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTString aaaa" ) << static_cast< int >( OFTString ) << static_cast< int >( OFSTNone ) << QStringLiteral( "aaaa" ) << QVariant( QStringLiteral( "aaaa" ) ); + QTest::newRow( "OFTString null" ) << static_cast( OFTString ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTString aaaa" ) << static_cast( OFTString ) << static_cast( OFSTNone ) << QStringLiteral( "aaaa" ) << QVariant( QStringLiteral( "aaaa" ) ); - QTest::newRow( "OFTWideString null" ) << static_cast< int >( OFTWideString ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTWideString aaaa" ) << static_cast< int >( OFTWideString ) << static_cast< int >( OFSTNone ) << QStringLiteral( "aaaa" ) << QVariant( QStringLiteral( "aaaa" ) ); + QTest::newRow( "OFTWideString null" ) << static_cast( OFTWideString ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTWideString aaaa" ) << static_cast( OFTWideString ) << static_cast( OFSTNone ) << QStringLiteral( "aaaa" ) << QVariant( QStringLiteral( "aaaa" ) ); - QTest::newRow( "OFTDate null" ) << static_cast< int >( OFTDate ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTDate 2021-03-04" ) << static_cast< int >( OFTDate ) << static_cast< int >( OFSTNone ) << QStringLiteral( "2021-03-04" ) << QVariant( QDate( 2021, 3, 4 ) ); + QTest::newRow( "OFTDate null" ) << static_cast( OFTDate ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTDate 2021-03-04" ) << static_cast( OFTDate ) << static_cast( OFSTNone ) << QStringLiteral( "2021-03-04" ) << QVariant( QDate( 2021, 3, 4 ) ); - QTest::newRow( "OFTTime null" ) << static_cast< int >( OFTTime ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTTime aaaa" ) << static_cast< int >( OFTTime ) << static_cast< int >( OFSTNone ) << QStringLiteral( "13:14:15" ) << QVariant( QTime( 13, 14, 15 ) ); + QTest::newRow( "OFTTime null" ) << static_cast( OFTTime ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTTime aaaa" ) << static_cast( OFTTime ) << static_cast( OFSTNone ) << QStringLiteral( "13:14:15" ) << QVariant( QTime( 13, 14, 15 ) ); - QTest::newRow( "OFTDateTime null" ) << static_cast< int >( OFTDateTime ) << static_cast< int >( OFSTNone ) << QString( "" ) << QVariant(); - QTest::newRow( "OFTDateTime aaaa" ) << static_cast< int >( OFTDateTime ) << static_cast< int >( OFSTNone ) << QStringLiteral( "2021-03-04 13:14:15" ) << QVariant( QDateTime( QDate( 2021, 3, 4 ), QTime( 13, 14, 15 ) ) ); + QTest::newRow( "OFTDateTime null" ) << static_cast( OFTDateTime ) << static_cast( OFSTNone ) << QString( "" ) << QVariant(); + QTest::newRow( "OFTDateTime aaaa" ) << static_cast( OFTDateTime ) << static_cast( OFSTNone ) << QStringLiteral( "2021-03-04 13:14:15" ) << QVariant( QDateTime( QDate( 2021, 3, 4 ), QTime( 13, 14, 15 ) ) ); } void TestQgsOgrUtils::testOgrStringToVariant() @@ -1042,9 +1025,7 @@ void TestQgsOgrUtils::testOgrStringToVariant() QFETCH( QString, string ); QFETCH( QVariant, expected ); - const QVariant res = QgsOgrUtils::stringToVariant( static_cast( ogrType ), - static_cast( ogrSubType ), - string ); + const QVariant res = QgsOgrUtils::stringToVariant( static_cast( ogrType ), static_cast( ogrSubType ), string ); QCOMPARE( res, expected ); } @@ -1060,9 +1041,7 @@ void TestQgsOgrUtils::testOgrUtilsStoredStyle() QString testFile = tempDirPath + "/test.gpkg"; // Create datasource QString error; - QVERIFY( QgsOgrProviderUtils::createEmptyDataSource( testFile, QStringLiteral( "GPKG" ), - QStringLiteral( "UTF-8" ), Qgis::WkbType::Point, QList< QPair >(), - QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), error ) ); + QVERIFY( QgsOgrProviderUtils::createEmptyDataSource( testFile, QStringLiteral( "GPKG" ), QStringLiteral( "UTF-8" ), Qgis::WkbType::Point, QList>(), QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), error ) ); { // Open the datasource @@ -1105,31 +1084,29 @@ void TestQgsOgrUtils::testOgrUtilsStoredStyle() QCOMPARE( names.size(), 3 ); QCOMPARE( descriptions.size(), 3 ); QCOMPARE( QSet( names.constBegin(), names.constEnd() ), QSet() << QStringLiteral( "style1" ) << QStringLiteral( "style2" ) << QStringLiteral( "style3" ) ); - } -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,3,0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 3, 0 ) void TestQgsOgrUtils::testConvertFieldDomain() { OGRCodedValue v1; - v1.pszCode = const_cast< char *>( "1" ); - v1.pszValue = const_cast< char *>( "val1" ); + v1.pszCode = const_cast( "1" ); + v1.pszValue = const_cast( "val1" ); OGRCodedValue v2; - v2.pszCode = const_cast< char *>( "2" ); - v2.pszValue = const_cast< char *>( "val2" ); + v2.pszCode = const_cast( "2" ); + v2.pszValue = const_cast( "val2" ); OGRCodedValue v3; v3.pszCode = nullptr; v3.pszValue = nullptr; - OGRCodedValue values[] = - { + OGRCodedValue values[] = { v1, v2, v3 }; OGRFieldDomainH domain = OGR_CodedFldDomain_Create( "name", "desc", OFTInteger, OFSTNone, values ); - std::unique_ptr< QgsFieldDomain > res = QgsOgrUtils::convertFieldDomain( domain ); - QgsCodedFieldDomain *codedFieldDomain = dynamic_cast< QgsCodedFieldDomain *>( res.get() ); + std::unique_ptr res = QgsOgrUtils::convertFieldDomain( domain ); + QgsCodedFieldDomain *codedFieldDomain = dynamic_cast( res.get() ); QVERIFY( codedFieldDomain ); QCOMPARE( codedFieldDomain->name(), QStringLiteral( "name" ) ); QCOMPARE( codedFieldDomain->description(), QStringLiteral( "desc" ) ); @@ -1169,7 +1146,7 @@ void TestQgsOgrUtils::testConvertFieldDomain() max.Integer = 15; domain = OGR_RangeFldDomain_Create( "name", "desc", OFTInteger, OFSTNone, &min, true, &max, false ); res = QgsOgrUtils::convertFieldDomain( domain ); - QgsRangeFieldDomain *rangeDomain = dynamic_cast< QgsRangeFieldDomain *>( res.get() ); + QgsRangeFieldDomain *rangeDomain = dynamic_cast( res.get() ); QVERIFY( rangeDomain ); QCOMPARE( rangeDomain->name(), QStringLiteral( "name" ) ); QCOMPARE( rangeDomain->description(), QStringLiteral( "desc" ) ); @@ -1181,14 +1158,14 @@ void TestQgsOgrUtils::testConvertFieldDomain() OGR_FldDomain_Destroy( domain ); domain = OGR_RangeFldDomain_Create( "name", "desc", OFTInteger, OFSTNone, &min, false, &max, true ); res = QgsOgrUtils::convertFieldDomain( domain ); - rangeDomain = dynamic_cast< QgsRangeFieldDomain *>( res.get() ); + rangeDomain = dynamic_cast( res.get() ); QVERIFY( !rangeDomain->minimumIsInclusive() ); QVERIFY( rangeDomain->maximumIsInclusive() ); OGR_FldDomain_Destroy( domain ); domain = OGR_GlobFldDomain_Create( "name", "desc", OFTString, OFSTNone, "*a*" ); res = QgsOgrUtils::convertFieldDomain( domain ); - QgsGlobFieldDomain *globDomain = dynamic_cast< QgsGlobFieldDomain *>( res.get() ); + QgsGlobFieldDomain *globDomain = dynamic_cast( res.get() ); QVERIFY( globDomain ); QCOMPARE( globDomain->name(), QStringLiteral( "name" ) ); QCOMPARE( globDomain->description(), QStringLiteral( "desc" ) ); @@ -1202,12 +1179,12 @@ void TestQgsOgrUtils::testConvertToFieldDomain() QgsGlobFieldDomain globDomain( QStringLiteral( "name" ), QStringLiteral( "desc" ), QMetaType::Type::QString, QStringLiteral( "*a*" ) ); OGRFieldDomainH domain = QgsOgrUtils::convertFieldDomain( &globDomain ); - std::unique_ptr< QgsFieldDomain > res = QgsOgrUtils::convertFieldDomain( domain ); + std::unique_ptr res = QgsOgrUtils::convertFieldDomain( domain ); QCOMPARE( res->name(), QStringLiteral( "name" ) ); QCOMPARE( res->description(), QStringLiteral( "desc" ) ); QCOMPARE( res->splitPolicy(), Qgis::FieldDomainSplitPolicy::DefaultValue ); QCOMPARE( res->mergePolicy(), Qgis::FieldDomainMergePolicy::DefaultValue ); - QCOMPARE( dynamic_cast< QgsGlobFieldDomain * >( res.get() )->glob(), QStringLiteral( "*a*" ) ); + QCOMPARE( dynamic_cast( res.get() )->glob(), QStringLiteral( "*a*" ) ); OGR_FldDomain_Destroy( domain ); globDomain.setSplitPolicy( Qgis::FieldDomainSplitPolicy::Duplicate ); @@ -1228,17 +1205,16 @@ void TestQgsOgrUtils::testConvertToFieldDomain() // range - QgsRangeFieldDomain rangeDomain( QStringLiteral( "name" ), QStringLiteral( "desc" ), QMetaType::Type::Int, - 1, true, 5, false ); + QgsRangeFieldDomain rangeDomain( QStringLiteral( "name" ), QStringLiteral( "desc" ), QMetaType::Type::Int, 1, true, 5, false ); domain = QgsOgrUtils::convertFieldDomain( &rangeDomain ); res = QgsOgrUtils::convertFieldDomain( domain ); OGR_FldDomain_Destroy( domain ); QCOMPARE( res->name(), QStringLiteral( "name" ) ); QCOMPARE( res->description(), QStringLiteral( "desc" ) ); - QCOMPARE( dynamic_cast< QgsRangeFieldDomain * >( res.get() )->minimum(), QVariant( 1 ) ); - QVERIFY( dynamic_cast< QgsRangeFieldDomain * >( res.get() )->minimumIsInclusive() ); - QCOMPARE( dynamic_cast< QgsRangeFieldDomain * >( res.get() )->maximum(), QVariant( 5 ) ); - QVERIFY( !dynamic_cast< QgsRangeFieldDomain * >( res.get() )->maximumIsInclusive() ); + QCOMPARE( dynamic_cast( res.get() )->minimum(), QVariant( 1 ) ); + QVERIFY( dynamic_cast( res.get() )->minimumIsInclusive() ); + QCOMPARE( dynamic_cast( res.get() )->maximum(), QVariant( 5 ) ); + QVERIFY( !dynamic_cast( res.get() )->maximumIsInclusive() ); rangeDomain.setFieldType( QMetaType::Type::Double ); rangeDomain.setMinimum( 5.5 ); @@ -1248,40 +1224,35 @@ void TestQgsOgrUtils::testConvertToFieldDomain() domain = QgsOgrUtils::convertFieldDomain( &rangeDomain ); res = QgsOgrUtils::convertFieldDomain( domain ); OGR_FldDomain_Destroy( domain ); - QCOMPARE( dynamic_cast< QgsRangeFieldDomain * >( res.get() )->minimum(), QVariant( 5.5 ) ); - QVERIFY( !dynamic_cast< QgsRangeFieldDomain * >( res.get() )->minimumIsInclusive() ); - QCOMPARE( dynamic_cast< QgsRangeFieldDomain * >( res.get() )->maximum(), QVariant( 12.1 ) ); - QVERIFY( dynamic_cast< QgsRangeFieldDomain * >( res.get() )->maximumIsInclusive() ); + QCOMPARE( dynamic_cast( res.get() )->minimum(), QVariant( 5.5 ) ); + QVERIFY( !dynamic_cast( res.get() )->minimumIsInclusive() ); + QCOMPARE( dynamic_cast( res.get() )->maximum(), QVariant( 12.1 ) ); + QVERIFY( dynamic_cast( res.get() )->maximumIsInclusive() ); // coded - QgsCodedFieldDomain codedDomain( QStringLiteral( "name" ), QStringLiteral( "desc" ), QMetaType::Type::QString, - { - QgsCodedValue( "aa", "aaaa" ), - QgsCodedValue( "bb", "bbbb" ), - } ); + QgsCodedFieldDomain codedDomain( QStringLiteral( "name" ), QStringLiteral( "desc" ), QMetaType::Type::QString, { + QgsCodedValue( "aa", "aaaa" ), + QgsCodedValue( "bb", "bbbb" ), + } ); domain = QgsOgrUtils::convertFieldDomain( &codedDomain ); res = QgsOgrUtils::convertFieldDomain( domain ); OGR_FldDomain_Destroy( domain ); QCOMPARE( res->name(), QStringLiteral( "name" ) ); QCOMPARE( res->description(), QStringLiteral( "desc" ) ); - QList< QgsCodedValue > resValues = dynamic_cast< QgsCodedFieldDomain * >( res.get() )->values(); + QList resValues = dynamic_cast( res.get() )->values(); QCOMPARE( resValues.size(), 2 ); QCOMPARE( resValues.at( 0 ).code(), QVariant( "aa" ) ); QCOMPARE( resValues.at( 0 ).value(), QStringLiteral( "aaaa" ) ); QCOMPARE( resValues.at( 1 ).code(), QVariant( "bb" ) ); QCOMPARE( resValues.at( 1 ).value(), QStringLiteral( "bbbb" ) ); - } #endif -#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,6,0) +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION( 3, 6, 0 ) void TestQgsOgrUtils::testConvertGdalRelationship() { - gdal::relationship_unique_ptr relationH( GDALRelationshipCreate( "relation_name", - "left_table", - "right_table", - GDALRelationshipCardinality::GRC_ONE_TO_ONE ) ); + gdal::relationship_unique_ptr relationH( GDALRelationshipCreate( "relation_name", "left_table", "right_table", GDALRelationshipCardinality::GRC_ONE_TO_ONE ) ); QgsWeakRelation rel = QgsOgrUtils::convertRelationship( relationH.get(), QStringLiteral( "/some_data.gdb" ) ); QCOMPARE( rel.name(), QStringLiteral( "relation_name" ) ); @@ -1289,31 +1260,22 @@ void TestQgsOgrUtils::testConvertGdalRelationship() QCOMPARE( rel.referencingLayerSource(), QStringLiteral( "/some_data.gdb|layername=right_table" ) ); QCOMPARE( rel.cardinality(), Qgis::RelationshipCardinality::OneToOne ); - relationH.reset( GDALRelationshipCreate( "relation_name", - "left_table", - "right_table", - GDALRelationshipCardinality::GRC_ONE_TO_MANY ) ); + relationH.reset( GDALRelationshipCreate( "relation_name", "left_table", "right_table", GDALRelationshipCardinality::GRC_ONE_TO_MANY ) ); rel = QgsOgrUtils::convertRelationship( relationH.get(), QStringLiteral( "/some_data.gdb" ) ); QCOMPARE( rel.cardinality(), Qgis::RelationshipCardinality::OneToMany ); - relationH.reset( GDALRelationshipCreate( "relation_name", - "left_table", - "right_table", - GDALRelationshipCardinality::GRC_MANY_TO_ONE ) ); + relationH.reset( GDALRelationshipCreate( "relation_name", "left_table", "right_table", GDALRelationshipCardinality::GRC_MANY_TO_ONE ) ); rel = QgsOgrUtils::convertRelationship( relationH.get(), QStringLiteral( "/some_data.gdb" ) ); QCOMPARE( rel.cardinality(), Qgis::RelationshipCardinality::ManyToOne ); - relationH.reset( GDALRelationshipCreate( "relation_name", - "left_table", - "right_table", - GDALRelationshipCardinality::GRC_MANY_TO_MANY ) ); + relationH.reset( GDALRelationshipCreate( "relation_name", "left_table", "right_table", GDALRelationshipCardinality::GRC_MANY_TO_MANY ) ); rel = QgsOgrUtils::convertRelationship( relationH.get(), QStringLiteral( "/some_data.gdb" ) ); QCOMPARE( rel.cardinality(), Qgis::RelationshipCardinality::ManyToMany ); - const char *const fieldsLeft[] {"fielda", "fieldb", nullptr}; + const char *const fieldsLeft[] { "fielda", "fieldb", nullptr }; GDALRelationshipSetLeftTableFields( relationH.get(), fieldsLeft ); - const char *const fieldsRight[] {"fieldc", "fieldd", nullptr}; + const char *const fieldsRight[] { "fieldc", "fieldd", nullptr }; GDALRelationshipSetRightTableFields( relationH.get(), fieldsRight ); rel = QgsOgrUtils::convertRelationship( relationH.get(), QStringLiteral( "/some_data.gdb" ) ); @@ -1324,10 +1286,10 @@ void TestQgsOgrUtils::testConvertGdalRelationship() GDALRelationshipSetMappingTableName( relationH.get(), "mapping_table" ); - const char *const mappingFieldsLeft[] {"fieldd", "fielde", nullptr}; + const char *const mappingFieldsLeft[] { "fieldd", "fielde", nullptr }; GDALRelationshipSetLeftMappingTableFields( relationH.get(), mappingFieldsLeft ); - const char *const mappingFieldsRight[] {"fieldf", "fieldg", nullptr}; + const char *const mappingFieldsRight[] { "fieldf", "fieldg", nullptr }; GDALRelationshipSetRightMappingTableFields( relationH.get(), mappingFieldsRight ); rel = QgsOgrUtils::convertRelationship( relationH.get(), QStringLiteral( "/some_data.gdb" ) ); @@ -1357,16 +1319,7 @@ void TestQgsOgrUtils::testConvertGdalRelationship() void TestQgsOgrUtils::testConvertToGdalRelationship() { - QgsWeakRelation rel( QStringLiteral( "id" ), QStringLiteral( "name" ), - Qgis::RelationshipStrength::Association, - QStringLiteral( "referencing_layer_id" ), - QStringLiteral( "referencing_layer_name" ), - QStringLiteral( "/some_data.gdb|layername=referencing" ), - QStringLiteral( "ogr" ), - QStringLiteral( "referenced_layer_id" ), - QStringLiteral( "referenced_layer_name" ), - QStringLiteral( "/some_data.gdb|layername=referenced" ), - QStringLiteral( "ogr" ) ); + QgsWeakRelation rel( QStringLiteral( "id" ), QStringLiteral( "name" ), Qgis::RelationshipStrength::Association, QStringLiteral( "referencing_layer_id" ), QStringLiteral( "referencing_layer_name" ), QStringLiteral( "/some_data.gdb|layername=referencing" ), QStringLiteral( "ogr" ), QStringLiteral( "referenced_layer_id" ), QStringLiteral( "referenced_layer_name" ), QStringLiteral( "/some_data.gdb|layername=referenced" ), QStringLiteral( "ogr" ) ); rel.setReferencedLayerFields( QStringList() << QStringLiteral( "fielda" ) << QStringLiteral( "fieldb" ) ); rel.setReferencingLayerFields( QStringList() << QStringLiteral( "fieldc" ) << QStringLiteral( "fieldd" ) ); rel.setCardinality( Qgis::RelationshipCardinality::OneToMany ); @@ -1401,16 +1354,7 @@ void TestQgsOgrUtils::testConvertToGdalRelationship() QCOMPARE( GDALRelationshipGetType( relationH.get() ), GDALRelationshipType::GRT_ASSOCIATION ); - rel = QgsWeakRelation( QStringLiteral( "id" ), QStringLiteral( "name" ), - Qgis::RelationshipStrength::Composition, - QStringLiteral( "referencing_layer_id" ), - QStringLiteral( "referencing_layer_name" ), - QStringLiteral( "/some_data.gdb|layername=referencing" ), - QStringLiteral( "ogr" ), - QStringLiteral( "referenced_layer_id" ), - QStringLiteral( "referenced_layer_name" ), - QStringLiteral( "/some_data.gdb|layername=referenced" ), - QStringLiteral( "ogr" ) ); + rel = QgsWeakRelation( QStringLiteral( "id" ), QStringLiteral( "name" ), Qgis::RelationshipStrength::Composition, QStringLiteral( "referencing_layer_id" ), QStringLiteral( "referencing_layer_name" ), QStringLiteral( "/some_data.gdb|layername=referencing" ), QStringLiteral( "ogr" ), QStringLiteral( "referenced_layer_id" ), QStringLiteral( "referenced_layer_name" ), QStringLiteral( "/some_data.gdb|layername=referenced" ), QStringLiteral( "ogr" ) ); relationH = QgsOgrUtils::convertRelationship( rel, error ); QCOMPARE( GDALRelationshipGetType( relationH.get() ), GDALRelationshipType::GRT_COMPOSITE ); @@ -1424,10 +1368,7 @@ void TestQgsOgrUtils::testConvertToGdalRelationship() relationH = QgsOgrUtils::convertRelationship( rel, error ); QCOMPARE( QString( GDALRelationshipGetRelatedTableType( relationH.get() ) ), QStringLiteral( "table_type" ) ); - rel.setMappingTable( QgsVectorLayerRef( QStringLiteral( "mapping_id" ), - QStringLiteral( "mapping_name" ), - QStringLiteral( "/some_data.gdb|layername=mapping" ), - QStringLiteral( "ogr" ) ) ); + rel.setMappingTable( QgsVectorLayerRef( QStringLiteral( "mapping_id" ), QStringLiteral( "mapping_name" ), QStringLiteral( "/some_data.gdb|layername=mapping" ), QStringLiteral( "ogr" ) ) ); rel.setMappingReferencedLayerFields( QStringList() << QStringLiteral( "fielde" ) << QStringLiteral( "fieldf" ) ); rel.setMappingReferencingLayerFields( QStringList() << QStringLiteral( "fieldh" ) << QStringLiteral( "fieldi" ) ); relationH = QgsOgrUtils::convertRelationship( rel, error ); @@ -1444,30 +1385,17 @@ void TestQgsOgrUtils::testConvertToGdalRelationship() QCOMPARE( rightMappingTableFieldNames, QStringList() << QStringLiteral( "fieldh" ) << QStringLiteral( "fieldi" ) ); // check that error is raised when tables from different dataset - rel.setMappingTable( QgsVectorLayerRef( QStringLiteral( "mapping_id" ), - QStringLiteral( "mapping_name" ), - QStringLiteral( "/some_other_data.gdb|layername=mapping" ), - QStringLiteral( "ogr" ) ) ); + rel.setMappingTable( QgsVectorLayerRef( QStringLiteral( "mapping_id" ), QStringLiteral( "mapping_name" ), QStringLiteral( "/some_other_data.gdb|layername=mapping" ), QStringLiteral( "ogr" ) ) ); relationH = QgsOgrUtils::convertRelationship( rel, error ); QVERIFY( !relationH.get() ); QCOMPARE( error, QStringLiteral( "Parent and mapping table must be from the same dataset" ) ); error.clear(); - rel = QgsWeakRelation( QStringLiteral( "id" ), QStringLiteral( "name" ), - Qgis::RelationshipStrength::Composition, - QStringLiteral( "referencing_layer_id" ), - QStringLiteral( "referencing_layer_name" ), - QStringLiteral( "/some_data.gdb|layername=referencing" ), - QStringLiteral( "ogr" ), - QStringLiteral( "referenced_layer_id" ), - QStringLiteral( "referenced_layer_name" ), - QStringLiteral( "/some_other_data.gdb|layername=referenced" ), - QStringLiteral( "ogr" ) ); + rel = QgsWeakRelation( QStringLiteral( "id" ), QStringLiteral( "name" ), Qgis::RelationshipStrength::Composition, QStringLiteral( "referencing_layer_id" ), QStringLiteral( "referencing_layer_name" ), QStringLiteral( "/some_data.gdb|layername=referencing" ), QStringLiteral( "ogr" ), QStringLiteral( "referenced_layer_id" ), QStringLiteral( "referenced_layer_name" ), QStringLiteral( "/some_other_data.gdb|layername=referenced" ), QStringLiteral( "ogr" ) ); relationH = QgsOgrUtils::convertRelationship( rel, error ); QVERIFY( !relationH.get() ); QCOMPARE( error, QStringLiteral( "Parent and child table must be from the same dataset" ) ); error.clear(); - } #endif diff --git a/tests/src/core/testqgsopenclutils.cpp b/tests/src/core/testqgsopenclutils.cpp index dc4f05bd6079..4dfe4901f2f3 100644 --- a/tests/src/core/testqgsopenclutils.cpp +++ b/tests/src/core/testqgsopenclutils.cpp @@ -26,15 +26,15 @@ #include #include -class TestQgsOpenClUtils: public QObject +class TestQgsOpenClUtils : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void TestEnable(); void TestDisable(); @@ -50,7 +50,6 @@ class TestQgsOpenClUtils: public QObject void testHillshadeGPU(); private: - void _testMakeRunProgram(); void _testMakeHillshade( const int loops ); @@ -64,7 +63,6 @@ class TestQgsOpenClUtils: public QObject } )CL"; return pgm; - } QgsRasterLayer *mFloat32RasterLayer = nullptr; @@ -95,8 +93,7 @@ void TestQgsOpenClUtils::initTestCase() const QString float32FileName = QStringLiteral( TEST_DATA_DIR ) + '/' + "/raster/band1_float32_noct_epsg4326.tif"; const QFileInfo float32RasterFileInfo( float32FileName ); - mFloat32RasterLayer = new QgsRasterLayer( float32RasterFileInfo.filePath(), - float32RasterFileInfo.completeBaseName() ); + mFloat32RasterLayer = new QgsRasterLayer( float32RasterFileInfo.filePath(), float32RasterFileInfo.completeBaseName() ); } @@ -134,7 +131,6 @@ void TestQgsOpenClUtils::testMakeRunProgram() void TestQgsOpenClUtils::_testMakeRunProgram() { - const cl_int err = 0; QVERIFY( err == 0 ); @@ -142,30 +138,21 @@ void TestQgsOpenClUtils::_testMakeRunProgram() const cl::Context ctx = QgsOpenClUtils::context(); cl::CommandQueue queue = QgsOpenClUtils::commandQueue(); - std::vector a_vec = {1, 10, 100}; - std::vector b_vec = {1, 10, 100}; - std::vector c_vec = {-1, -1, -1}; + std::vector a_vec = { 1, 10, 100 }; + std::vector b_vec = { 1, 10, 100 }; + std::vector c_vec = { -1, -1, -1 }; cl::Buffer a_buf( queue, a_vec.begin(), a_vec.end(), true ); cl::Buffer b_buf( queue, b_vec.begin(), b_vec.end(), true ); cl::Buffer c_buf( queue, c_vec.begin(), c_vec.end(), false ); const cl::Program program = QgsOpenClUtils::buildProgram( QString::fromStdString( source() ) ); - auto kernel = - cl::KernelFunctor < + auto kernel = cl::KernelFunctor< cl::Buffer &, cl::Buffer &, - cl::Buffer & - > ( program, "vectorAdd" ); - - kernel( cl::EnqueueArgs( - queue, - cl::NDRange( 3 ) - ), - a_buf, - b_buf, - c_buf - ); + cl::Buffer &>( program, "vectorAdd" ); + + kernel( cl::EnqueueArgs( queue, cl::NDRange( 3 ) ), a_buf, b_buf, c_buf ); cl::copy( queue, c_buf, c_vec.begin(), c_vec.end() ); for ( size_t i = 0; i < c_vec.size(); ++i ) @@ -178,11 +165,11 @@ void TestQgsOpenClUtils::testProgramSource() { QgsOpenClUtils::setSourcePath( QDir::tempPath() ); QTemporaryFile tmpFile( QDir::tempPath() + "/XXXXXX.cl" ); - tmpFile.open( ); - tmpFile.write( QByteArray::fromStdString( source( ) ) ); + tmpFile.open(); + tmpFile.write( QByteArray::fromStdString( source() ) ); tmpFile.flush(); const QString baseName = tmpFile.fileName().replace( ".cl", "" ).replace( QDir::tempPath(), "" ); - QVERIFY( ! QgsOpenClUtils::sourceFromBaseName( baseName ).isEmpty() ); + QVERIFY( !QgsOpenClUtils::sourceFromBaseName( baseName ).isEmpty() ); } void TestQgsOpenClUtils::testContext() @@ -192,7 +179,7 @@ void TestQgsOpenClUtils::testContext() void TestQgsOpenClUtils::testDevices() { - std::vector _devices( QgsOpenClUtils::devices( ) ); + std::vector _devices( QgsOpenClUtils::devices() ); QVERIFY( _devices.size() > 0 ); qDebug() << QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Name, _devices.at( 0 ) ); qDebug() << QgsOpenClUtils::deviceInfo( QgsOpenClUtils::Info::Type, _devices.at( 0 ) ); @@ -207,7 +194,7 @@ void TestQgsOpenClUtils::testActiveDeviceVersion() void TestQgsOpenClUtils::_testMakeHillshade( const int loops ) { - for ( int i = 0 ; i < loops; i++ ) + for ( int i = 0; i < loops; i++ ) { QgsHillshadeRenderer renderer( mFloat32RasterLayer->dataProvider(), 1, 35.0, 5000.0 ); // Note: CPU time grows linearly with raster dimensions while GPU time is roughly constant @@ -235,6 +222,5 @@ void TestQgsOpenClUtils::testHillshadeCPU() } - QGSTEST_MAIN( TestQgsOpenClUtils ) #include "testqgsopenclutils.moc" diff --git a/tests/src/core/testqgsoverlayexpression.cpp b/tests/src/core/testqgsoverlayexpression.cpp index 95e38be77f7a..c920fe14cdec 100644 --- a/tests/src/core/testqgsoverlayexpression.cpp +++ b/tests/src/core/testqgsoverlayexpression.cpp @@ -38,12 +38,11 @@ #include "geos_c.h" -class TestQgsOverlayExpression: public QObject +class TestQgsOverlayExpression : public QObject { Q_OBJECT public: - TestQgsOverlayExpression() = default; void testOverlayExpression(); void testOverlayExpression_data(); @@ -64,11 +63,9 @@ class TestQgsOverlayExpression: public QObject void testOverlayMeasure(); void testOverlayMeasure_data(); - }; - void TestQgsOverlayExpression::initTestCase() { QgsApplication::init(); @@ -78,15 +75,13 @@ void TestQgsOverlayExpression::initTestCase() const QString rectanglesFileName = testDataDir + QStringLiteral( "rectangles.shp" ); const QFileInfo rectanglesFileInfo( rectanglesFileName ); - mRectanglesLayer = new QgsVectorLayer( rectanglesFileInfo.filePath(), - QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + mRectanglesLayer = new QgsVectorLayer( rectanglesFileInfo.filePath(), QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); const QString polygonsFileName = testDataDir + QStringLiteral( "polys_overlapping_with_id.shp" ); const QFileInfo polygonsFileInfo( polygonsFileName ); - mPolyLayer = new QgsVectorLayer( polygonsFileInfo.filePath(), - QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); + mPolyLayer = new QgsVectorLayer( polygonsFileInfo.filePath(), QStringLiteral( "polys" ), QStringLiteral( "ogr" ) ); // Create linestrings target layer for test - QgsVectorLayer *linestringsLayer = new QgsVectorLayer{ QStringLiteral( "LineString?crs=epsg:4326" ), QStringLiteral( "linestrings" ), QStringLiteral( "memory" ) }; + QgsVectorLayer *linestringsLayer = new QgsVectorLayer { QStringLiteral( "LineString?crs=epsg:4326" ), QStringLiteral( "linestrings" ), QStringLiteral( "memory" ) }; QgsFeature f1 { linestringsLayer->fields() }; f1.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "LINESTRING(1 0, 2 0)" ) ) ); @@ -97,7 +92,7 @@ void TestQgsOverlayExpression::initTestCase() linestringsLayer->dataProvider()->addFeature( f2 ); // Points layer for tests - QgsVectorLayer *pointsLayer = new QgsVectorLayer{ QStringLiteral( "Point?crs=epsg:4326" ), QStringLiteral( "points" ), QStringLiteral( "memory" ) }; + QgsVectorLayer *pointsLayer = new QgsVectorLayer { QStringLiteral( "Point?crs=epsg:4326" ), QStringLiteral( "points" ), QStringLiteral( "memory" ) }; QgsFeature f3 { pointsLayer->fields() }; f3.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POINT(1 0)" ) ) ); @@ -107,7 +102,7 @@ void TestQgsOverlayExpression::initTestCase() pointsLayer->dataProvider()->addFeature( f3 ); pointsLayer->dataProvider()->addFeature( f4 ); - QgsVectorLayer *polygonsLayer = new QgsVectorLayer{ R"layer_definition(Polygon?crs=EPSG:2051&uid={d6f1eaf3-ec08-4e6c-9e39-6dab242e73f4}&field=fid:integer)layer_definition", QStringLiteral( "polygons2" ), QStringLiteral( "memory" ) }; + QgsVectorLayer *polygonsLayer = new QgsVectorLayer { R"layer_definition(Polygon?crs=EPSG:2051&uid={d6f1eaf3-ec08-4e6c-9e39-6dab242e73f4}&field=fid:integer)layer_definition", QStringLiteral( "polygons2" ), QStringLiteral( "memory" ) }; QgsFeature f { polygonsLayer->fields() }; f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "Polygon ((2604689.23400000017136335 1231339.72999999998137355, 2604696.20599999977275729 1231363.55400000000372529, 2604720.66000000014901161 1231358.27099999994970858, 2604713.89399999985471368 1231333.42900000000372529, 2604704.85499999998137355 1231335.10299999988637865, 2604695.41300000017508864 1231337.88999999989755452, 2604689.23400000017136335 1231339.72999999998137355))" ) ) ); f.setAttribute( 0, 997 ); @@ -123,8 +118,6 @@ void TestQgsOverlayExpression::initTestCase() QgsProject::instance()->addMapLayer( mRectanglesLayer ); QgsProject::instance()->addMapLayer( mPolyLayer ); QgsProject::instance()->addMapLayer( polygonsLayer ); - - } void TestQgsOverlayExpression::cleanupTestCase() @@ -150,7 +143,6 @@ void TestQgsOverlayExpression::testOverlay() const QVariant result = exp.evaluate( &context ); QCOMPARE( result.toBool(), expectedResult ); - } void TestQgsOverlayExpression::testOverlay_data() @@ -234,7 +226,6 @@ void TestQgsOverlayExpression::testOverlay_data() QTest::newRow( "intersects linestring multi match" ) << "overlay_intersects('polys', min_overlap:=1.76)" << "LINESTRING(-102.76 33.74, -106.12 33.74)" << true; QTest::newRow( "intersects linestring multi no match" ) << "overlay_intersects('polys', min_overlap:=2.0)" << "LINESTRING(-102.76 33.74, -106.12 33.74)" << false; - } @@ -266,7 +257,6 @@ void TestQgsOverlayExpression::testOverlayMeasure() void TestQgsOverlayExpression::testOverlayMeasure_data() { - QTest::addColumn( "expression" ); QTest::addColumn( "geometry" ); QTest::addColumn( "expectedResult" ); @@ -275,28 +265,28 @@ void TestQgsOverlayExpression::testOverlayMeasure_data() expected3.insert( QStringLiteral( "id" ), 3LL ); expected3.insert( QStringLiteral( "result" ), 3LL ); expected3.insert( QStringLiteral( "overlap" ), 1.4033836999702842 ); - expected3 .insert( QStringLiteral( "radius" ), 0.5344336346973622 ); + expected3.insert( QStringLiteral( "radius" ), 0.5344336346973622 ); QVariantMap expected1; expected1.insert( QStringLiteral( "id" ), 1LL ); expected1.insert( QStringLiteral( "result" ), 1LL ); expected1.insert( QStringLiteral( "overlap" ), 1.2281139270097938 ); - expected1.insert( QStringLiteral( "radius" ), 0.46454276882989376 ); + expected1.insert( QStringLiteral( "radius" ), 0.46454276882989376 ); - QTest::newRow( "intersects min_overlap multi match return measure" ) << "overlay_intersects('polys', expression:=$id, min_overlap:=1.34, return_details:=true)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << expected3 ) ; + QTest::newRow( "intersects min_overlap multi match return measure" ) << "overlay_intersects('polys', expression:=$id, min_overlap:=1.34, return_details:=true)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << expected3 ); - QTest::newRow( "intersects multi match return measure" ) << "overlay_intersects('polys', expression:=$id, return_details:=true)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << expected1 << expected3 ) ; + QTest::newRow( "intersects multi match return measure" ) << "overlay_intersects('polys', expression:=$id, return_details:=true)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << expected1 << expected3 ); - QTest::newRow( "intersects multi match return sorted measure" ) << "overlay_intersects('polys', expression:=$id, sort_by_intersection_size:='des', return_details:=true)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << expected3 << expected1 ) ; + QTest::newRow( "intersects multi match return sorted measure" ) << "overlay_intersects('polys', expression:=$id, sort_by_intersection_size:='des', return_details:=true)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << expected3 << expected1 ); - QTest::newRow( "intersects multi match return sorted" ) << "overlay_intersects('polys', expression:=$id, sort_by_intersection_size:='des')" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 3LL << 1LL ) ; + QTest::newRow( "intersects multi match return sorted" ) << "overlay_intersects('polys', expression:=$id, sort_by_intersection_size:='des')" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 3LL << 1LL ); - QTest::newRow( "intersects multi match return unsorted" ) << "overlay_intersects('polys', expression:=$id)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 1LL << 3LL ) ; + QTest::newRow( "intersects multi match return unsorted" ) << "overlay_intersects('polys', expression:=$id)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 1LL << 3LL ); - QTest::newRow( "intersects multi match return unsorted limit " ) << "overlay_intersects('polys', limit:=1, expression:=$id)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 1LL ) ; + QTest::newRow( "intersects multi match return unsorted limit " ) << "overlay_intersects('polys', limit:=1, expression:=$id)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 1LL ); - QTest::newRow( "intersects multi match return sorted limit " ) << "overlay_intersects('polys', sort_by_intersection_size:='des', limit:=1, expression:=$id)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 3LL ) ; + QTest::newRow( "intersects multi match return sorted limit " ) << "overlay_intersects('polys', sort_by_intersection_size:='des', limit:=1, expression:=$id)" << "POLYGON((-107.37 33.75, -102.76 33.75, -102.76 36.97, -107.37 36.97, -107.37 33.75))" << ( QVariantList() << 3LL ); - QTest::newRow( "intersects multi match points" ) << "overlay_intersects('polys', expression:=$id)" << "MULTIPOINT((-107.37 33.75), (-102.8 36.97))" << ( QVariantList() << 1LL << 3LL ) ; + QTest::newRow( "intersects multi match points" ) << "overlay_intersects('polys', expression:=$id)" << "MULTIPOINT((-107.37 33.75), (-102.8 36.97))" << ( QVariantList() << 1LL << 3LL ); QTest::newRow( "intersects multi match points sorted" ) << "overlay_intersects('polys', sort_by_intersection_size:='des', expression:=$id)" << "MULTIPOINT((-107.37 33.75), (-102.8 36.97))" << ( QVariantList() << 3LL << 1LL ); @@ -314,8 +304,7 @@ void TestQgsOverlayExpression::testOverlayMeasure_data() expected3.insert( QStringLiteral( "radius" ), 1.3414663642343596 ); expected1.insert( QStringLiteral( "radius" ), 1.8924012738149243 ); - QTest::newRow( "intersects multi match points return sorted" ) << "overlay_intersects('polys', sort_by_intersection_size:='des', return_details:=true, expression:=$id)" << "MULTIPOINT((-107.37 33.75), (-102.8 36.97))" << ( QVariantList() << expected3 << expected1 ) ; - + QTest::newRow( "intersects multi match points return sorted" ) << "overlay_intersects('polys', sort_by_intersection_size:='des', return_details:=true, expression:=$id)" << "MULTIPOINT((-107.37 33.75), (-102.8 36.97))" << ( QVariantList() << expected3 << expected1 ); } // Linestring tests! @@ -376,7 +365,6 @@ void TestQgsOverlayExpression::testOverlayMeasure_data() QTest::newRow( "intersects linestring multi match points" ) << "overlay_intersects('linestrings', return_details:=true, expression:=$id)" << "MULTIPOINT((1.5 0), (3.5 0))" << ( QVariantList() << expectedLine1 << expectedLine2 ); QTest::newRow( "intersects linestring multi match points sorted" ) << "overlay_intersects('linestrings', sort_by_intersection_size:='des', return_details:=true, expression:=$id)" << "MULTIPOINT((1.5 0), (3.5 0))" << ( QVariantList() << expectedLine2 << expectedLine1 ); - } // Test point target layer (no sorting supported) @@ -501,11 +489,9 @@ void TestQgsOverlayExpression::testOverlaySelf() context.setFeature( feat ); result = exp.evaluate( &context ); QCOMPARE( result.toBool(), true ); - } - QGSTEST_MAIN( TestQgsOverlayExpression ) #include "testqgsoverlayexpression.moc" diff --git a/tests/src/core/testqgspagesizeregistry.cpp b/tests/src/core/testqgspagesizeregistry.cpp index ae5378bdd701..942b81d1cb2e 100644 --- a/tests/src/core/testqgspagesizeregistry.cpp +++ b/tests/src/core/testqgspagesizeregistry.cpp @@ -26,41 +26,36 @@ class TestQgsPageSizeRegistry : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void pageSizeEquality(); //test equality of QgsPageSize - void pageCopyConstructor(); //test copy constructor of QgsPageSize - void createInstance(); // create global instance of QgsPageSizeRegistry + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void pageSizeEquality(); //test equality of QgsPageSize + void pageCopyConstructor(); //test copy constructor of QgsPageSize + void createInstance(); // create global instance of QgsPageSizeRegistry void instanceHasDefaultSizes(); // check that global instance is populated with default page sizes - void addSize(); // check adding a size to the registry - void findSize(); //find a size in the registry - void findBySize(); //find a matching size in the registry - void decodePageSize(); //test decoding a page size string + void addSize(); // check adding a size to the registry + void findSize(); //find a size in the registry + void findBySize(); //find a matching size in the registry + void decodePageSize(); //test decoding a page size string private: - }; void TestQgsPageSizeRegistry::initTestCase() { - } void TestQgsPageSizeRegistry::cleanupTestCase() { - } void TestQgsPageSizeRegistry::init() { - } void TestQgsPageSizeRegistry::cleanup() { - } void TestQgsPageSizeRegistry::pageSizeEquality() @@ -114,11 +109,11 @@ void TestQgsPageSizeRegistry::findSize() QgsPageSizeRegistry *registry = QgsApplication::pageSizeRegistry(); const QgsPageSize newSize( QStringLiteral( "test size" ), QgsLayoutSize( 1, 2 ) ); registry->add( newSize ); - const QList< QgsPageSize > results = registry->find( QStringLiteral( "test size" ) ); + const QList results = registry->find( QStringLiteral( "test size" ) ); QVERIFY( results.length() > 0 ); QCOMPARE( results.at( 0 ), newSize ); //check that match is case insensitive - const QList< QgsPageSize > results2 = registry->find( QStringLiteral( "tEsT Size" ) ); + const QList results2 = registry->find( QStringLiteral( "tEsT Size" ) ); QVERIFY( results2.length() > 0 ); QCOMPARE( results2.at( 0 ), newSize ); } @@ -149,13 +144,13 @@ void TestQgsPageSizeRegistry::decodePageSize() QVERIFY( registry->decodePageSize( QStringLiteral( "a4" ), result ) ); QCOMPARE( result.size.width(), 210.0 ); QCOMPARE( result.size.height(), 297.0 ); - QVERIFY( registry->decodePageSize( QStringLiteral( "B0" ), result ) ); + QVERIFY( registry->decodePageSize( QStringLiteral( "B0" ), result ) ); QCOMPARE( result.size.width(), 1000.0 ); QCOMPARE( result.size.height(), 1414.0 ); - QVERIFY( registry->decodePageSize( QStringLiteral( "letter" ), result ) ); + QVERIFY( registry->decodePageSize( QStringLiteral( "letter" ), result ) ); QCOMPARE( result.size.width(), 215.9 ); QCOMPARE( result.size.height(), 279.4 ); - QVERIFY( registry->decodePageSize( QStringLiteral( "LEGAL" ), result ) ); + QVERIFY( registry->decodePageSize( QStringLiteral( "LEGAL" ), result ) ); QCOMPARE( result.size.width(), 215.9 ); QCOMPARE( result.size.height(), 355.6 ); diff --git a/tests/src/core/testqgspainteffect.cpp b/tests/src/core/testqgspainteffect.cpp index 06fc937ff1ae..5c8a23e36434 100644 --- a/tests/src/core/testqgspainteffect.cpp +++ b/tests/src/core/testqgspainteffect.cpp @@ -78,7 +78,6 @@ class DummyPaintEffect : public QgsPaintEffect QString prop2() { return mProp2; } protected: - void draw( QgsRenderContext &context ) override { Q_UNUSED( context ); } private: @@ -87,23 +86,23 @@ class DummyPaintEffect : public QgsPaintEffect }; - /** * \ingroup UnitTests * This is a unit test for paint effects */ -class TestQgsPaintEffect: public QgsTest +class TestQgsPaintEffect : public QgsTest { Q_OBJECT public: - TestQgsPaintEffect() : QgsTest( QStringLiteral( "Paint Effect Tests" ) ) {} + TestQgsPaintEffect() + : QgsTest( QStringLiteral( "Paint Effect Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void saveRestore(); void stackSaveRestore(); @@ -173,9 +172,9 @@ void TestQgsPaintEffect::saveRestore() DummyPaintEffect *effect = new DummyPaintEffect( QStringLiteral( "a" ), QStringLiteral( "b" ) ); QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); //test writing with no node @@ -230,9 +229,9 @@ void TestQgsPaintEffect::stackSaveRestore() stack->setEnabled( false ); QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); //test writing with no node @@ -298,7 +297,7 @@ void TestQgsPaintEffect::drawSource() //clone QgsPaintEffect *clone = effect->clone(); - QgsDrawSourceEffect *cloneCast = dynamic_cast( clone ); + QgsDrawSourceEffect *cloneCast = dynamic_cast( clone ); QVERIFY( cloneCast ); QCOMPARE( cloneCast->blendMode(), effect->blendMode() ); QCOMPARE( cloneCast->opacity(), effect->opacity() ); @@ -309,7 +308,7 @@ void TestQgsPaintEffect::drawSource() //read/write const QVariantMap props = effect->properties(); QgsPaintEffect *readEffect = QgsDrawSourceEffect::create( props ); - QgsDrawSourceEffect *readCast = dynamic_cast( readEffect ); + QgsDrawSourceEffect *readCast = dynamic_cast( readEffect ); QVERIFY( readCast ); QCOMPARE( readCast->blendMode(), effect->blendMode() ); QCOMPARE( readCast->opacity(), effect->opacity() ); @@ -370,7 +369,7 @@ void TestQgsPaintEffect::blur() //clone QgsPaintEffect *clone = effect->clone(); - QgsBlurEffect *cloneCast = dynamic_cast( clone ); + QgsBlurEffect *cloneCast = dynamic_cast( clone ); QVERIFY( cloneCast ); QCOMPARE( cloneCast->blendMode(), effect->blendMode() ); QCOMPARE( cloneCast->opacity(), effect->opacity() ); @@ -383,7 +382,7 @@ void TestQgsPaintEffect::blur() //read/write const QVariantMap props = effect->properties(); QgsPaintEffect *readEffect = QgsBlurEffect::create( props ); - QgsBlurEffect *readCast = dynamic_cast( readEffect ); + QgsBlurEffect *readCast = dynamic_cast( readEffect ); QVERIFY( readCast ); QCOMPARE( readCast->blendMode(), effect->blendMode() ); QCOMPARE( readCast->opacity(), effect->opacity() ); @@ -458,7 +457,7 @@ void TestQgsPaintEffect::dropShadow() //clone QgsPaintEffect *clone = effect->clone(); - QgsDropShadowEffect *cloneCast = dynamic_cast( clone ); + QgsDropShadowEffect *cloneCast = dynamic_cast( clone ); QVERIFY( cloneCast ); QCOMPARE( cloneCast->blendMode(), effect->blendMode() ); QCOMPARE( cloneCast->opacity(), effect->opacity() ); @@ -476,7 +475,7 @@ void TestQgsPaintEffect::dropShadow() //read/write const QVariantMap props = effect->properties(); QgsPaintEffect *readEffect = QgsDropShadowEffect::create( props ); - QgsDropShadowEffect *readCast = dynamic_cast( readEffect ); + QgsDropShadowEffect *readCast = dynamic_cast( readEffect ); QVERIFY( readCast ); QCOMPARE( readCast->blendMode(), effect->blendMode() ); QCOMPARE( readCast->opacity(), effect->opacity() ); @@ -559,7 +558,7 @@ void TestQgsPaintEffect::glow() //clone QgsPaintEffect *clone = effect->clone(); - QgsOuterGlowEffect *cloneCast = dynamic_cast( clone ); + QgsOuterGlowEffect *cloneCast = dynamic_cast( clone ); QVERIFY( cloneCast ); QCOMPARE( cloneCast->blendMode(), effect->blendMode() ); QCOMPARE( cloneCast->opacity(), effect->opacity() ); @@ -578,7 +577,7 @@ void TestQgsPaintEffect::glow() //read/write const QVariantMap props = effect->properties(); QgsPaintEffect *readEffect = QgsOuterGlowEffect::create( props ); - QgsOuterGlowEffect *readCast = dynamic_cast( readEffect ); + QgsOuterGlowEffect *readCast = dynamic_cast( readEffect ); QVERIFY( readCast ); QCOMPARE( readCast->blendMode(), effect->blendMode() ); QCOMPARE( readCast->opacity(), effect->opacity() ); @@ -615,13 +614,12 @@ void TestQgsPaintEffect::glow() QVERIFY( result ); //TODO - inner glow - } void TestQgsPaintEffect::transform() { //create - std::unique_ptr< QgsTransformEffect > effect( new QgsTransformEffect() ); + std::unique_ptr effect( new QgsTransformEffect() ); QVERIFY( effect.get() ); effect->setEnabled( false ); QCOMPARE( effect->enabled(), false ); @@ -652,7 +650,7 @@ void TestQgsPaintEffect::transform() QCOMPARE( effect->drawMode(), QgsPaintEffect::Modifier ); //copy constructor - std::unique_ptr< QgsTransformEffect > copy( new QgsTransformEffect( *effect ) ); + std::unique_ptr copy( new QgsTransformEffect( *effect ) ); QVERIFY( copy.get() ); QCOMPARE( copy->enabled(), false ); QCOMPARE( copy->translateX(), 6.0 ); @@ -671,8 +669,8 @@ void TestQgsPaintEffect::transform() copy.reset( nullptr ); //clone - std::unique_ptr< QgsPaintEffect > clone( effect->clone() ); - QgsTransformEffect *cloneCast = dynamic_cast( clone.get() ); + std::unique_ptr clone( effect->clone() ); + QgsTransformEffect *cloneCast = dynamic_cast( clone.get() ); QVERIFY( cloneCast ); QCOMPARE( cloneCast->enabled(), false ); QCOMPARE( cloneCast->translateX(), 6.0 ); @@ -692,8 +690,8 @@ void TestQgsPaintEffect::transform() //read/write const QVariantMap props = effect->properties(); - const std::unique_ptr< QgsPaintEffect > readEffect( QgsTransformEffect::create( props ) ); - QgsTransformEffect *readCast = dynamic_cast( readEffect.get() ); + const std::unique_ptr readEffect( QgsTransformEffect::create( props ) ); + QgsTransformEffect *readCast = dynamic_cast( readEffect.get() ); QVERIFY( readCast ); QCOMPARE( readCast->enabled(), false ); QCOMPARE( readCast->translateX(), 6.0 ); @@ -731,7 +729,7 @@ void TestQgsPaintEffect::stack() //clone QgsPaintEffect *clone = effect->clone(); - QgsEffectStack *cloneCast = dynamic_cast( clone ); + QgsEffectStack *cloneCast = dynamic_cast( clone ); QVERIFY( cloneCast ); QCOMPARE( cloneCast->enabled(), effect->enabled() ); QCOMPARE( cloneCast->count(), effect->count() ); @@ -780,8 +778,7 @@ void TestQgsPaintEffect::layerEffectPolygon() const QString polysFileName = mTestDataDir + "polys.shp"; const QFileInfo polyFileInfo( polysFileName ); - QgsVectorLayer *polysLayer = new QgsVectorLayer( polyFileInfo.filePath(), - polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *polysLayer = new QgsVectorLayer( polyFileInfo.filePath(), polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); polysLayer->setSimplifyMethod( simplifyMethod ); @@ -810,8 +807,7 @@ void TestQgsPaintEffect::layerEffectLine() // test rendering a line symbol layer with a paint effect const QString linesFileName = mTestDataDir + "lines.shp"; const QFileInfo lineFileInfo( linesFileName ); - QgsVectorLayer *lineLayer = new QgsVectorLayer( lineFileInfo.filePath(), - lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *lineLayer = new QgsVectorLayer( lineFileInfo.filePath(), lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); lineLayer->setSimplifyMethod( simplifyMethod ); @@ -841,8 +837,7 @@ void TestQgsPaintEffect::layerEffectMarker() // test rendering a marker symbol layer with a paint effect const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - QgsVectorLayer *pointLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *pointLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsMapSettings ms; QgsSimpleMarkerSymbolLayer *marker = new QgsSimpleMarkerSymbolLayer; @@ -868,8 +863,7 @@ void TestQgsPaintEffect::vectorLayerEffect() // test rendering a whole vector layer with a layer-wide effect const QString polysFileName = mTestDataDir + "polys.shp"; const QFileInfo polyFileInfo( polysFileName ); - QgsVectorLayer *polysLayer = new QgsVectorLayer( polyFileInfo.filePath(), - polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *polysLayer = new QgsVectorLayer( polyFileInfo.filePath(), polyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); polysLayer->setSimplifyMethod( simplifyMethod ); @@ -902,8 +896,7 @@ void TestQgsPaintEffect::mapUnits() //test rendering an effect which utilizes map units const QString linesFileName = mTestDataDir + "lines.shp"; const QFileInfo lineFileInfo( linesFileName ); - QgsVectorLayer *lineLayer = new QgsVectorLayer( lineFileInfo.filePath(), - lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *lineLayer = new QgsVectorLayer( lineFileInfo.filePath(), lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); lineLayer->setSimplifyMethod( simplifyMethod ); @@ -937,8 +930,7 @@ void TestQgsPaintEffect::layout() const QString linesFileName = mTestDataDir + "lines.shp"; const QFileInfo lineFileInfo( linesFileName ); - QgsVectorLayer *lineLayer = new QgsVectorLayer( lineFileInfo.filePath(), - lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *lineLayer = new QgsVectorLayer( lineFileInfo.filePath(), lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); lineLayer->setSimplifyMethod( simplifyMethod ); @@ -958,7 +950,7 @@ void TestQgsPaintEffect::layout() lineLayer->setRenderer( renderer ); QgsLayout l( QgsProject::instance() ); - std::unique_ptr< QgsLayoutItemPage > page = std::make_unique< QgsLayoutItemPage >( &l ); + std::unique_ptr page = std::make_unique( &l ); page->setPageSize( QgsLayoutSize( 50, 50 ) ); l.pageCollection()->addPage( page.release() ); diff --git a/tests/src/core/testqgspainteffectregistry.cpp b/tests/src/core/testqgspainteffectregistry.cpp index 2f7e3d5d2fb6..08c72f142ddc 100644 --- a/tests/src/core/testqgspainteffectregistry.cpp +++ b/tests/src/core/testqgspainteffectregistry.cpp @@ -33,6 +33,7 @@ class DummyPaintEffect : public QgsPaintEffect static QgsPaintEffect *create( const QVariantMap & ) { return new DummyPaintEffect(); } QVariantMap properties() const override { return QVariantMap(); } void readProperties( const QVariantMap &props ) override { Q_UNUSED( props ); } + protected: void draw( QgsRenderContext &context ) override { Q_UNUSED( context ); } }; @@ -42,20 +43,19 @@ class TestQgsPaintEffectRegistry : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void metadata(); //test metadata - void createInstance(); // create global instance of QgsPaintEffectRegistry + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void metadata(); //test metadata + void createInstance(); // create global instance of QgsPaintEffectRegistry void instanceHasDefaultEffects(); // check that global instance is populated with default effects - void addEffect(); // check adding an effect to an empty registry - void fetchEffects(); //check fetching effects - void createEffect(); //check creating effect - void defaultStack(); //check creating/testing default stack + void addEffect(); // check adding an effect to an empty registry + void fetchEffects(); //check fetching effects + void createEffect(); //check creating effect + void defaultStack(); //check creating/testing default stack private: - }; void TestQgsPaintEffectRegistry::initTestCase() @@ -71,12 +71,10 @@ void TestQgsPaintEffectRegistry::cleanupTestCase() void TestQgsPaintEffectRegistry::init() { - } void TestQgsPaintEffectRegistry::cleanup() { - } void TestQgsPaintEffectRegistry::metadata() @@ -118,7 +116,7 @@ void TestQgsPaintEffectRegistry::addEffect() QCOMPARE( registry->effects().length(), previousCount + 1 ); //try adding again, should have no effect QgsPaintEffectMetadata *dupe = new QgsPaintEffectMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "Dummy effect" ), DummyPaintEffect::create ); - QVERIFY( ! registry->addEffectType( dupe ) ); + QVERIFY( !registry->addEffectType( dupe ) ); QCOMPARE( registry->effects().length(), previousCount + 1 ); delete dupe; @@ -176,11 +174,11 @@ void TestQgsPaintEffectRegistry::defaultStack() delete effect2; effect = static_cast( QgsPaintEffectRegistry::defaultStack() ); - static_cast< QgsDrawSourceEffect * >( effect->effect( 2 ) )->setOpacity( 0.5 ); + static_cast( effect->effect( 2 ) )->setOpacity( 0.5 ); QVERIFY( !registry->isDefaultStack( effect ) ); - static_cast< QgsDrawSourceEffect * >( effect->effect( 2 ) )->setOpacity( 1.0 ); + static_cast( effect->effect( 2 ) )->setOpacity( 1.0 ); QVERIFY( registry->isDefaultStack( effect ) ); - static_cast< QgsDrawSourceEffect * >( effect->effect( 2 ) )->setBlendMode( QPainter::CompositionMode_Lighten ); + static_cast( effect->effect( 2 ) )->setBlendMode( QPainter::CompositionMode_Lighten ); QVERIFY( !registry->isDefaultStack( effect ) ); } diff --git a/tests/src/core/testqgspallabeling.cpp b/tests/src/core/testqgspallabeling.cpp index cc7e2a2d909c..aa32a16ab1ab 100644 --- a/tests/src/core/testqgspallabeling.cpp +++ b/tests/src/core/testqgspallabeling.cpp @@ -26,21 +26,21 @@ #include "qgsmaprenderersequentialjob.h" #include "qgsrenderchecker.h" -class TestQgsPalLabeling: public QgsTest +class TestQgsPalLabeling : public QgsTest { Q_OBJECT public: - - TestQgsPalLabeling() : QgsTest( QStringLiteral( "PAL labeling Tests" ) ) {} + TestQgsPalLabeling() + : QgsTest( QStringLiteral( "PAL labeling Tests" ) ) {} private slots: - void cleanupTestCase();// will be called after the last testfunction was executed. - void wrapChar();//test wrapping text lines - void graphemes(); //test splitting strings to graphemes + void cleanupTestCase(); // will be called after the last testfunction was executed. + void wrapChar(); //test wrapping text lines + void graphemes(); //test splitting strings to graphemes bool imageCheck( const QString &testName, QImage &image, int mismatchCount ); void testGeometryGenerator(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void testPolygonWithEmptyRing(); #endif }; @@ -164,17 +164,7 @@ void TestQgsPalLabeling::graphemes() expected2Pt11 += QChar( 0x17D2 ); expected2Pt11 += QChar( 0x179F ); - QCOMPARE( QgsPalLabeling::splitToGraphemes( str2 ), QStringList() << expected2Pt1 - << expected2Pt2 - << expected2Pt3 - << expected2Pt4 - << expected2Pt5 - << expected2Pt6 - << expected2Pt7 - << expected2Pt8 - << expected2Pt9 - << expected2Pt10 - << expected2Pt11 ); + QCOMPARE( QgsPalLabeling::splitToGraphemes( str2 ), QStringList() << expected2Pt1 << expected2Pt2 << expected2Pt3 << expected2Pt4 << expected2Pt5 << expected2Pt6 << expected2Pt7 << expected2Pt8 << expected2Pt9 << expected2Pt10 << expected2Pt11 ); } bool TestQgsPalLabeling::imageCheck( const QString &testName, QImage &image, int mismatchCount ) @@ -219,7 +209,7 @@ void TestQgsPalLabeling::testGeometryGenerator() settings.geometryGeneratorType = Qgis::GeometryType::Point; settings.geometryGenerator = "translate($geometry, 1, 0)"; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); @@ -234,7 +224,7 @@ void TestQgsPalLabeling::testGeometryGenerator() { for ( int y = 0; y < 10; y += 3 ) { - f.setGeometry( std::make_unique< QgsPoint >( x, y ) ); + f.setGeometry( std::make_unique( x, y ) ); vl2->dataProvider()->addFeature( f ); } } @@ -271,7 +261,7 @@ void TestQgsPalLabeling::testGeometryGenerator() QVERIFY( imageCheck( QStringLiteral( "rotated_geometry_generator_translated" ), img, 20 ) ); } -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) void TestQgsPalLabeling::testPolygonWithEmptyRing() { // test that no labels are drawn outside of the specified label boundary @@ -290,7 +280,7 @@ void TestQgsPalLabeling::testPolygonWithEmptyRing() settings.placement = Qgis::LabelPlacement::OverPoint; - std::unique_ptr< QgsVectorLayer> vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vl2( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); vl2->setRenderer( new QgsNullSymbolRenderer() ); diff --git a/tests/src/core/testqgspointcloudattribute.cpp b/tests/src/core/testqgspointcloudattribute.cpp index 244292930cc4..495040513ea5 100644 --- a/tests/src/core/testqgspointcloudattribute.cpp +++ b/tests/src/core/testqgspointcloudattribute.cpp @@ -29,15 +29,15 @@ #include "qgspoint.h" #include "qgspointcloudattribute.h" -class TestQgsPointCloudAttribute: public QObject +class TestQgsPointCloudAttribute : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testAttribute(); void testAttributeDisplayType(); void testVariantType(); @@ -48,7 +48,6 @@ class TestQgsPointCloudAttribute: public QObject void testToFields(); private: - QString mTestDataDir; }; @@ -69,12 +68,10 @@ void TestQgsPointCloudAttribute::cleanupTestCase() void TestQgsPointCloudAttribute::init() { - } void TestQgsPointCloudAttribute::cleanup() { - } void TestQgsPointCloudAttribute::testAttribute() @@ -171,10 +168,7 @@ void TestQgsPointCloudAttribute::testCollection() QCOMPARE( offset, 6 ); // populate from other attributes - const QgsPointCloudAttributeCollection collection2( QVector< QgsPointCloudAttribute >() - << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) - << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) - << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) ); + const QgsPointCloudAttributeCollection collection2( QVector() << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) ); QCOMPARE( collection2.attributes().size(), 3 ); QCOMPARE( collection2.count(), 3 ); QCOMPARE( collection2.attributes().at( 0 ).name(), QStringLiteral( "at1" ) ); @@ -193,10 +187,7 @@ void TestQgsPointCloudAttribute::testCollection() void TestQgsPointCloudAttribute::testCollectionFindCaseInsensitive() { int offset = 0; - const QgsPointCloudAttributeCollection collection( QVector< QgsPointCloudAttribute >() - << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) - << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) - << QgsPointCloudAttribute( QStringLiteral( "AT3" ), QgsPointCloudAttribute::DataType::Double ) ); + const QgsPointCloudAttributeCollection collection( QVector() << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) << QgsPointCloudAttribute( QStringLiteral( "AT3" ), QgsPointCloudAttribute::DataType::Double ) ); QCOMPARE( collection.attributes().size(), 3 ); QCOMPARE( collection.count(), 3 ); QCOMPARE( collection.attributes().at( 0 ).name(), QStringLiteral( "at1" ) ); @@ -215,16 +206,8 @@ void TestQgsPointCloudAttribute::testCollectionFindCaseInsensitive() void TestQgsPointCloudAttribute::testCollevtionExtend() { int offset = 0; - QgsPointCloudAttributeCollection collection( QVector< QgsPointCloudAttribute >() - << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) - << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) - << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) ); - const QgsPointCloudAttributeCollection collection2( QVector< QgsPointCloudAttribute >() - << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) - << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) - << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) - << QgsPointCloudAttribute( QStringLiteral( "at4" ), QgsPointCloudAttribute::DataType::Float ) - << QgsPointCloudAttribute( QStringLiteral( "at5" ), QgsPointCloudAttribute::DataType::Short ) ); + QgsPointCloudAttributeCollection collection( QVector() << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) ); + const QgsPointCloudAttributeCollection collection2( QVector() << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) << QgsPointCloudAttribute( QStringLiteral( "at4" ), QgsPointCloudAttribute::DataType::Float ) << QgsPointCloudAttribute( QStringLiteral( "at5" ), QgsPointCloudAttribute::DataType::Short ) ); collection.extend( collection2, QSet() ); QCOMPARE( collection.attributes().size(), 3 ); @@ -273,10 +256,7 @@ void TestQgsPointCloudAttribute::testToFields() QgsFields fields = QgsPointCloudAttributeCollection().toFields(); QCOMPARE( fields.size(), 0 ); - const QgsPointCloudAttributeCollection collection( QVector< QgsPointCloudAttribute >() - << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) - << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) - << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) ); + const QgsPointCloudAttributeCollection collection( QVector() << QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) << QgsPointCloudAttribute( QStringLiteral( "at2" ), QgsPointCloudAttribute::DataType::Short ) << QgsPointCloudAttribute( QStringLiteral( "at3" ), QgsPointCloudAttribute::DataType::Double ) ); fields = collection.toFields(); QCOMPARE( fields.size(), 3 ); diff --git a/tests/src/core/testqgspointcloudexpression.cpp b/tests/src/core/testqgspointcloudexpression.cpp index 15fcb5029dda..a7011b387a48 100644 --- a/tests/src/core/testqgspointcloudexpression.cpp +++ b/tests/src/core/testqgspointcloudexpression.cpp @@ -25,7 +25,7 @@ #include "qgspointcloudexpression.h" -template +template bool _storeToStream( char *s, size_t position, QgsPointCloudAttribute::DataType type, T value ) { switch ( type ) @@ -38,7 +38,7 @@ bool _storeToStream( char *s, size_t position, QgsPointCloudAttribute::DataType } case QgsPointCloudAttribute::UChar: { - const unsigned char val = ( unsigned char )( value ); + const unsigned char val = ( unsigned char ) ( value ); s[position] = val; break; } @@ -46,52 +46,52 @@ bool _storeToStream( char *s, size_t position, QgsPointCloudAttribute::DataType case QgsPointCloudAttribute::Short: { short val = short( value ); - memcpy( s + position, reinterpret_cast( &val ), sizeof( short ) ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( short ) ); break; } case QgsPointCloudAttribute::UShort: { - unsigned short val = static_cast< unsigned short>( value ); - memcpy( s + position, reinterpret_cast< char * >( &val ), sizeof( unsigned short ) ); + unsigned short val = static_cast( value ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( unsigned short ) ); break; } case QgsPointCloudAttribute::Int32: { qint32 val = qint32( value ); - memcpy( s + position, reinterpret_cast< char * >( &val ), sizeof( qint32 ) ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( qint32 ) ); break; } case QgsPointCloudAttribute::UInt32: { quint32 val = quint32( value ); - memcpy( s + position, reinterpret_cast< char * >( &val ), sizeof( quint32 ) ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( quint32 ) ); break; } case QgsPointCloudAttribute::Int64: { qint64 val = qint64( value ); - memcpy( s + position, reinterpret_cast< char * >( &val ), sizeof( qint64 ) ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( qint64 ) ); break; } case QgsPointCloudAttribute::UInt64: { quint64 val = quint64( value ); - memcpy( s + position, reinterpret_cast< char * >( &val ), sizeof( quint64 ) ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( quint64 ) ); break; } case QgsPointCloudAttribute::Float: { float val = float( value ); - memcpy( s + position, reinterpret_cast< char * >( &val ), sizeof( float ) ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( float ) ); break; } case QgsPointCloudAttribute::Double: { double val = double( value ); - memcpy( s + position, reinterpret_cast< char * >( &val ), sizeof( double ) ); + memcpy( s + position, reinterpret_cast( &val ), sizeof( double ) ); break; } } @@ -100,17 +100,16 @@ bool _storeToStream( char *s, size_t position, QgsPointCloudAttribute::DataType } - -class TestQgsPointCloudExpression: public QObject +class TestQgsPointCloudExpression : public QObject { Q_OBJECT private slots: QgsPointCloudBlock *createPointCloudBlock( const QVector &points, const QgsVector3D &scale, const QgsVector3D &offset, const QgsPointCloudAttributeCollection &attributes ); - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testCreateBlock(); void testParsing_data(); void testParsing(); @@ -123,7 +122,8 @@ class TestQgsPointCloudExpression: public QObject private: QString mTestDataDir; QVector mPoints; - QgsPointCloudBlock *mBlock = nullptr;; + QgsPointCloudBlock *mBlock = nullptr; + ; }; QgsPointCloudBlock *TestQgsPointCloudExpression::createPointCloudBlock( const QVector &points, const QgsVector3D &scale, const QgsVector3D &offset, const QgsPointCloudAttributeCollection &attributes ) @@ -136,45 +136,45 @@ QgsPointCloudBlock *TestQgsPointCloudExpression::createPointCloudBlock( const QV int dataOffset = 0; int count = 0; - const QVector< QgsPointCloudAttribute > attributesVector = attributes.attributes(); + const QVector attributesVector = attributes.attributes(); for ( const auto &point : points ) { for ( const auto &attribute : std::as_const( attributesVector ) ) { if ( attribute.name().compare( QLatin1String( "X" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), std::round( ( point[ attribute.name() ].toDouble() - offset.x() ) / scale.x() ) ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), std::round( ( point[attribute.name()].toDouble() - offset.x() ) / scale.x() ) ); else if ( attribute.name().compare( QLatin1String( "Y" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), std::round( ( point[ attribute.name() ].toDouble() - offset.y() ) / scale.y() ) ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), std::round( ( point[attribute.name()].toDouble() - offset.y() ) / scale.y() ) ); else if ( attribute.name().compare( QLatin1String( "Z" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), std::round( ( point[ attribute.name() ].toDouble() - offset.z() ) / scale.z() ) ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), std::round( ( point[attribute.name()].toDouble() - offset.z() ) / scale.z() ) ); else if ( attribute.name().compare( QLatin1String( "Classification" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toInt() ); else if ( attribute.name().compare( QLatin1String( "Intensity" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toInt() ); else if ( attribute.name().compare( QLatin1String( "ReturnNumber" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toInt() ); else if ( attribute.name().compare( QLatin1String( "NumberOfReturns" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toInt() ); else if ( attribute.name().compare( QLatin1String( "ScanDirectionFlag" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toInt() ); else if ( attribute.name().compare( QLatin1String( "EdgeOfFlightLine" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toInt() ); else if ( attribute.name().compare( QLatin1String( "ScanAngleRank" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toFloat() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toFloat() ); else if ( attribute.name().compare( QLatin1String( "UserData" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toInt() ); else if ( attribute.name().compare( QLatin1String( "PointSourceId" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toUInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toUInt() ); else if ( attribute.name().compare( QLatin1String( "GpsTime" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toDouble() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toDouble() ); else if ( attribute.name().compare( QLatin1String( "Red" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toUInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toUInt() ); else if ( attribute.name().compare( QLatin1String( "Green" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toUInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toUInt() ); else if ( attribute.name().compare( QLatin1String( "Blue" ), Qt::CaseInsensitive ) == 0 ) - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toUInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toUInt() ); else - _storeToStream( dataBuffer, dataOffset, attribute.type(), point[ attribute.name() ].toUInt() ); + _storeToStream( dataBuffer, dataOffset, attribute.type(), point[attribute.name()].toUInt() ); dataOffset += attribute.size(); } ++count; @@ -184,7 +184,6 @@ QgsPointCloudBlock *TestQgsPointCloudExpression::createPointCloudBlock( const QV } - void TestQgsPointCloudExpression::initTestCase() { const QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -216,90 +215,90 @@ void TestQgsPointCloudExpression::initTestCase() // Generate some points with predefined data QVariantMap p0, p1, p2, p3, p4; - p0[ QLatin1String( "X" ) ] = 1001.1; - p0[ QLatin1String( "Y" ) ] = 2002.2; - p0[ QLatin1String( "Z" ) ] = 3003.3; - p0[ QLatin1String( "Classification" ) ] = 1; - p0[ QLatin1String( "Intensity" ) ] = 2; - p0[ QLatin1String( "ReturnNumber" ) ] = 3; - p0[ QLatin1String( "NumberOfReturns" ) ] = 4; - p0[ QLatin1String( "ScanDirectionFlag" ) ] = 5; - p0[ QLatin1String( "EdgeOfFlightLine" ) ] = 6; - p0[ QLatin1String( "ScanAngleRank" ) ] = 7; - p0[ QLatin1String( "UserData" ) ] = 8; - p0[ QLatin1String( "PointSourceId" ) ] = 9; - p0[ QLatin1String( "GpsTime" ) ] = 10; - p0[ QLatin1String( "Red" ) ] = 11; - p0[ QLatin1String( "Green" ) ] = 12; - p0[ QLatin1String( "Blue" ) ] = 13; - - p1[ QLatin1String( "X" ) ] = 1002.2; - p1[ QLatin1String( "Y" ) ] = 2003.3; - p1[ QLatin1String( "Z" ) ] = 3004.4; - p1[ QLatin1String( "Classification" ) ] = 2; - p1[ QLatin1String( "Intensity" ) ] = 3; - p1[ QLatin1String( "ReturnNumber" ) ] = 4; - p1[ QLatin1String( "NumberOfReturns" ) ] = 5; - p1[ QLatin1String( "ScanDirectionFlag" ) ] = 6; - p1[ QLatin1String( "EdgeOfFlightLine" ) ] = 7; - p1[ QLatin1String( "ScanAngleRank" ) ] = 8; - p1[ QLatin1String( "UserData" ) ] = 9; - p1[ QLatin1String( "PointSourceId" ) ] = 10; - p1[ QLatin1String( "GpsTime" ) ] = 11; - p1[ QLatin1String( "Red" ) ] = 12; - p1[ QLatin1String( "Green" ) ] = 13; - p1[ QLatin1String( "Blue" ) ] = 14; - - p2[ QLatin1String( "X" ) ] = 1003.3; - p2[ QLatin1String( "Y" ) ] = 2004.4; - p2[ QLatin1String( "Z" ) ] = 3005.5; - p2[ QLatin1String( "Classification" ) ] = 3; - p2[ QLatin1String( "Intensity" ) ] = 4; - p2[ QLatin1String( "ReturnNumber" ) ] = 5; - p2[ QLatin1String( "NumberOfReturns" ) ] = 6; - p2[ QLatin1String( "ScanDirectionFlag" ) ] = 7; - p2[ QLatin1String( "EdgeOfFlightLine" ) ] = 8; - p2[ QLatin1String( "ScanAngleRank" ) ] = 9; - p2[ QLatin1String( "UserData" ) ] = 10; - p2[ QLatin1String( "PointSourceId" ) ] = 11; - p2[ QLatin1String( "GpsTime" ) ] = 12; - p2[ QLatin1String( "Red" ) ] = 13; - p2[ QLatin1String( "Green" ) ] = 14; - p2[ QLatin1String( "Blue" ) ] = 15; - - p3[ QLatin1String( "X" ) ] = 1004.4; - p3[ QLatin1String( "Y" ) ] = 2005.5; - p3[ QLatin1String( "Z" ) ] = 3006.6; - p3[ QLatin1String( "Classification" ) ] = 4; - p3[ QLatin1String( "Intensity" ) ] = 4; - p3[ QLatin1String( "ReturnNumber" ) ] = 6; - p3[ QLatin1String( "NumberOfReturns" ) ] = 6; - p3[ QLatin1String( "ScanDirectionFlag" ) ] = 7; - p3[ QLatin1String( "EdgeOfFlightLine" ) ] = 8; - p3[ QLatin1String( "ScanAngleRank" ) ] = 9; - p3[ QLatin1String( "UserData" ) ] = 10; - p3[ QLatin1String( "PointSourceId" ) ] = 11; - p3[ QLatin1String( "GpsTime" ) ] = 12; - p3[ QLatin1String( "Red" ) ] = 13; - p3[ QLatin1String( "Green" ) ] = 14; - p3[ QLatin1String( "Blue" ) ] = 15; - - p4[ QLatin1String( "X" ) ] = 1005.5; - p4[ QLatin1String( "Y" ) ] = 2006.6; - p4[ QLatin1String( "Z" ) ] = 3007.7; - p4[ QLatin1String( "Classification" ) ] = 1; - p4[ QLatin1String( "Intensity" ) ] = 4; - p4[ QLatin1String( "ReturnNumber" ) ] = 7; - p4[ QLatin1String( "NumberOfReturns" ) ] = 7; - p4[ QLatin1String( "ScanDirectionFlag" ) ] = 7; - p4[ QLatin1String( "EdgeOfFlightLine" ) ] = 8; - p4[ QLatin1String( "ScanAngleRank" ) ] = 9; - p4[ QLatin1String( "UserData" ) ] = 10; - p4[ QLatin1String( "PointSourceId" ) ] = 11; - p4[ QLatin1String( "GpsTime" ) ] = 12; - p4[ QLatin1String( "Red" ) ] = 13; - p4[ QLatin1String( "Green" ) ] = 14; - p4[ QLatin1String( "Blue" ) ] = 15; + p0[QLatin1String( "X" )] = 1001.1; + p0[QLatin1String( "Y" )] = 2002.2; + p0[QLatin1String( "Z" )] = 3003.3; + p0[QLatin1String( "Classification" )] = 1; + p0[QLatin1String( "Intensity" )] = 2; + p0[QLatin1String( "ReturnNumber" )] = 3; + p0[QLatin1String( "NumberOfReturns" )] = 4; + p0[QLatin1String( "ScanDirectionFlag" )] = 5; + p0[QLatin1String( "EdgeOfFlightLine" )] = 6; + p0[QLatin1String( "ScanAngleRank" )] = 7; + p0[QLatin1String( "UserData" )] = 8; + p0[QLatin1String( "PointSourceId" )] = 9; + p0[QLatin1String( "GpsTime" )] = 10; + p0[QLatin1String( "Red" )] = 11; + p0[QLatin1String( "Green" )] = 12; + p0[QLatin1String( "Blue" )] = 13; + + p1[QLatin1String( "X" )] = 1002.2; + p1[QLatin1String( "Y" )] = 2003.3; + p1[QLatin1String( "Z" )] = 3004.4; + p1[QLatin1String( "Classification" )] = 2; + p1[QLatin1String( "Intensity" )] = 3; + p1[QLatin1String( "ReturnNumber" )] = 4; + p1[QLatin1String( "NumberOfReturns" )] = 5; + p1[QLatin1String( "ScanDirectionFlag" )] = 6; + p1[QLatin1String( "EdgeOfFlightLine" )] = 7; + p1[QLatin1String( "ScanAngleRank" )] = 8; + p1[QLatin1String( "UserData" )] = 9; + p1[QLatin1String( "PointSourceId" )] = 10; + p1[QLatin1String( "GpsTime" )] = 11; + p1[QLatin1String( "Red" )] = 12; + p1[QLatin1String( "Green" )] = 13; + p1[QLatin1String( "Blue" )] = 14; + + p2[QLatin1String( "X" )] = 1003.3; + p2[QLatin1String( "Y" )] = 2004.4; + p2[QLatin1String( "Z" )] = 3005.5; + p2[QLatin1String( "Classification" )] = 3; + p2[QLatin1String( "Intensity" )] = 4; + p2[QLatin1String( "ReturnNumber" )] = 5; + p2[QLatin1String( "NumberOfReturns" )] = 6; + p2[QLatin1String( "ScanDirectionFlag" )] = 7; + p2[QLatin1String( "EdgeOfFlightLine" )] = 8; + p2[QLatin1String( "ScanAngleRank" )] = 9; + p2[QLatin1String( "UserData" )] = 10; + p2[QLatin1String( "PointSourceId" )] = 11; + p2[QLatin1String( "GpsTime" )] = 12; + p2[QLatin1String( "Red" )] = 13; + p2[QLatin1String( "Green" )] = 14; + p2[QLatin1String( "Blue" )] = 15; + + p3[QLatin1String( "X" )] = 1004.4; + p3[QLatin1String( "Y" )] = 2005.5; + p3[QLatin1String( "Z" )] = 3006.6; + p3[QLatin1String( "Classification" )] = 4; + p3[QLatin1String( "Intensity" )] = 4; + p3[QLatin1String( "ReturnNumber" )] = 6; + p3[QLatin1String( "NumberOfReturns" )] = 6; + p3[QLatin1String( "ScanDirectionFlag" )] = 7; + p3[QLatin1String( "EdgeOfFlightLine" )] = 8; + p3[QLatin1String( "ScanAngleRank" )] = 9; + p3[QLatin1String( "UserData" )] = 10; + p3[QLatin1String( "PointSourceId" )] = 11; + p3[QLatin1String( "GpsTime" )] = 12; + p3[QLatin1String( "Red" )] = 13; + p3[QLatin1String( "Green" )] = 14; + p3[QLatin1String( "Blue" )] = 15; + + p4[QLatin1String( "X" )] = 1005.5; + p4[QLatin1String( "Y" )] = 2006.6; + p4[QLatin1String( "Z" )] = 3007.7; + p4[QLatin1String( "Classification" )] = 1; + p4[QLatin1String( "Intensity" )] = 4; + p4[QLatin1String( "ReturnNumber" )] = 7; + p4[QLatin1String( "NumberOfReturns" )] = 7; + p4[QLatin1String( "ScanDirectionFlag" )] = 7; + p4[QLatin1String( "EdgeOfFlightLine" )] = 8; + p4[QLatin1String( "ScanAngleRank" )] = 9; + p4[QLatin1String( "UserData" )] = 10; + p4[QLatin1String( "PointSourceId" )] = 11; + p4[QLatin1String( "GpsTime" )] = 12; + p4[QLatin1String( "Red" )] = 13; + p4[QLatin1String( "Green" )] = 14; + p4[QLatin1String( "Blue" )] = 15; mPoints << p0 << p1 << p2 << p3 << p4; // Also define scale and offset for x/y/z in the block @@ -333,26 +332,24 @@ void TestQgsPointCloudExpression::testCreateBlock() int i = 0; for ( const auto &p : mPoints ) { - map = QgsPointCloudAttribute::getAttributeMap( mBlock->data(), - i * mBlock->attributes().pointRecordSize(), - mBlock->attributes() ); - - QCOMPARE( map[ "X" ].toDouble() * scale.x() + offset.x(), p[ "X" ] ); - QCOMPARE( map[ "Y" ].toDouble() * scale.y() + offset.y(), p[ "Y" ] ); - QCOMPARE( map[ "Z" ].toDouble() * scale.z() + offset.z(), p[ "Z" ] ); - QCOMPARE( map[ "Classification" ], p[ "Classification" ] ); - QCOMPARE( map[ "Intensity" ], p[ "Intensity" ] ); - QCOMPARE( map[ "ReturnNumber" ], p[ "ReturnNumber" ] ); - QCOMPARE( map[ "NumberOfReturns" ], p[ "NumberOfReturns" ] ); - QCOMPARE( map[ "ScanDirectionFlag" ], p[ "ScanDirectionFlag" ] ); - QCOMPARE( map[ "EdgeOfFlightLine" ], p[ "EdgeOfFlightLine" ] ); - QCOMPARE( map[ "ScanAngleRank" ], p[ "ScanAngleRank" ] ); - QCOMPARE( map[ "UserData" ], p[ "UserData" ] ); - QCOMPARE( map[ "PointSourceId" ], p[ "PointSourceId" ] ); - QCOMPARE( map[ "GpsTime" ], p[ "GpsTime" ] ); - QCOMPARE( map[ "Red" ], p[ "Red" ] ); - QCOMPARE( map[ "Green" ], p[ "Green" ] ); - QCOMPARE( map[ "Blue" ], p[ "Blue" ] ); + map = QgsPointCloudAttribute::getAttributeMap( mBlock->data(), i * mBlock->attributes().pointRecordSize(), mBlock->attributes() ); + + QCOMPARE( map["X"].toDouble() * scale.x() + offset.x(), p["X"] ); + QCOMPARE( map["Y"].toDouble() * scale.y() + offset.y(), p["Y"] ); + QCOMPARE( map["Z"].toDouble() * scale.z() + offset.z(), p["Z"] ); + QCOMPARE( map["Classification"], p["Classification"] ); + QCOMPARE( map["Intensity"], p["Intensity"] ); + QCOMPARE( map["ReturnNumber"], p["ReturnNumber"] ); + QCOMPARE( map["NumberOfReturns"], p["NumberOfReturns"] ); + QCOMPARE( map["ScanDirectionFlag"], p["ScanDirectionFlag"] ); + QCOMPARE( map["EdgeOfFlightLine"], p["EdgeOfFlightLine"] ); + QCOMPARE( map["ScanAngleRank"], p["ScanAngleRank"] ); + QCOMPARE( map["UserData"], p["UserData"] ); + QCOMPARE( map["PointSourceId"], p["PointSourceId"] ); + QCOMPARE( map["GpsTime"], p["GpsTime"] ); + QCOMPARE( map["Red"], p["Red"] ); + QCOMPARE( map["Green"], p["Green"] ); + QCOMPARE( map["Blue"], p["Blue"] ); ++i; } } diff --git a/tests/src/core/testqgspointcloudlayerexporter.cpp b/tests/src/core/testqgspointcloudlayerexporter.cpp index 074a3e11a146..7d6947700106 100644 --- a/tests/src/core/testqgspointcloudlayerexporter.cpp +++ b/tests/src/core/testqgspointcloudlayerexporter.cpp @@ -17,15 +17,15 @@ #include "qgspointcloudlayer.h" #include "qgspointcloudlayerexporter.h" -class TestQgsPointCloudLayerExporter: public QObject +class TestQgsPointCloudLayerExporter : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testScratchLayer(); void testScratchLayerFiltered(); void testScratchLayerExtent(); @@ -43,7 +43,6 @@ class TestQgsPointCloudLayerExporter: public QObject void testPdalFile(); private: - std::unique_ptr mProject; QgsPointCloudLayer *mLayer; QString mTestDataDir; @@ -64,7 +63,6 @@ void TestQgsPointCloudLayerExporter::initTestCase() QVERIFY( mLayer->isValid() ); mProject->addMapLayer( mLayer ); mProject->setCrs( mLayer->crs() ); - } void TestQgsPointCloudLayerExporter::cleanupTestCase() @@ -74,7 +72,6 @@ void TestQgsPointCloudLayerExporter::cleanupTestCase() void TestQgsPointCloudLayerExporter::init() { - } void TestQgsPointCloudLayerExporter::cleanup() @@ -217,7 +214,7 @@ void TestQgsPointCloudLayerExporter::testScratchLayerFilteredByLayerSelected() polygonLayer->addFeature( polygonF3 ); polygonLayer->commitChanges(); - const QgsFeatureIds ids{1, 2}; + const QgsFeatureIds ids { 1, 2 }; polygonLayer->selectByIds( ids ); QgsPointCloudLayerExporter exp( mLayer ); @@ -263,10 +260,7 @@ void TestQgsPointCloudLayerExporter::testScratchLayerFilteredByLayerDifferentCrs void TestQgsPointCloudLayerExporter::testScratchLayerAttributes() { QgsPointCloudLayerExporter exp( mLayer ); - QStringList attrs { QStringLiteral( "Red" ), - QStringLiteral( "Green" ), - QStringLiteral( "Blue" ) - }; + QStringList attrs { QStringLiteral( "Red" ), QStringLiteral( "Green" ), QStringLiteral( "Blue" ) }; exp.setAttributes( attrs ); exp.setFormat( QgsPointCloudLayerExporter::ExportFormat::Memory ); exp.doExport(); @@ -288,10 +282,7 @@ void TestQgsPointCloudLayerExporter::testScratchLayerAttributes() void TestQgsPointCloudLayerExporter::testScratchLayerBadAttributes() { QgsPointCloudLayerExporter exp( mLayer ); - QStringList attrs { QStringLiteral( "Red" ), - QStringLiteral( "Red" ), - QStringLiteral( "MissingAttribute" ) - }; + QStringList attrs { QStringLiteral( "Red" ), QStringLiteral( "Red" ), QStringLiteral( "MissingAttribute" ) }; exp.setAttributes( attrs ); exp.setFormat( QgsPointCloudLayerExporter::ExportFormat::Memory ); exp.doExport(); @@ -349,10 +340,7 @@ void TestQgsPointCloudLayerExporter::testScratchLayerSynthetic() mLayer->setSubsetString( QStringLiteral( "red > 150" ) ); QgsPointCloudLayerExporter exp( mLayer ); - QStringList attrs { QStringLiteral( "Red" ), - QStringLiteral( "Red" ), - QStringLiteral( "MissingAttribute" ) - }; + QStringList attrs { QStringLiteral( "Red" ), QStringLiteral( "Red" ), QStringLiteral( "MissingAttribute" ) }; exp.setAttributes( attrs ); exp.setFilterExtent( QgsRectangle( 497754, 7050888, 497755, 7050889 ) ); exp.setZRange( QgsDoubleRange( 1, 1.1 ) ); diff --git a/tests/src/core/testqgspointcloudrendererregistry.cpp b/tests/src/core/testqgspointcloudrendererregistry.cpp index 04b4fe747053..aecbe367a4bd 100644 --- a/tests/src/core/testqgspointcloudrendererregistry.cpp +++ b/tests/src/core/testqgspointcloudrendererregistry.cpp @@ -33,7 +33,6 @@ class DummyRenderer : public QgsPointCloudRenderer static QgsPointCloudRenderer *create( QDomElement &, const QgsReadWriteContext & ) { return new DummyRenderer(); } void renderBlock( const QgsPointCloudBlock *, QgsPointCloudRenderContext & ) override {} QDomElement save( QDomDocument &doc, const QgsReadWriteContext & ) const override { return doc.createElement( QStringLiteral( "test" ) ); } - }; class TestQgsPointCloudRendererRegistry : public QObject @@ -52,7 +51,6 @@ class TestQgsPointCloudRendererRegistry : public QObject void fetchTypes(); private: - }; void TestQgsPointCloudRendererRegistry::initTestCase() @@ -68,12 +66,10 @@ void TestQgsPointCloudRendererRegistry::cleanupTestCase() void TestQgsPointCloudRendererRegistry::init() { - } void TestQgsPointCloudRendererRegistry::cleanup() { - } void TestQgsPointCloudRendererRegistry::metadata() @@ -84,7 +80,7 @@ void TestQgsPointCloudRendererRegistry::metadata() //test creating renderer from metadata QDomElement elem; - const std::unique_ptr< QgsPointCloudRenderer > renderer( metadata.createRenderer( elem, QgsReadWriteContext() ) ); + const std::unique_ptr renderer( metadata.createRenderer( elem, QgsReadWriteContext() ) ); QVERIFY( renderer ); DummyRenderer *dummyRenderer = dynamic_cast( renderer.get() ); QVERIFY( dummyRenderer ); @@ -113,7 +109,7 @@ void TestQgsPointCloudRendererRegistry::addRenderer() QCOMPARE( registry->renderersList().length(), previousCount + 1 ); //try adding again, should have no effect QgsPointCloudRendererMetadata *dupe = new QgsPointCloudRendererMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "Dummy callout" ), DummyRenderer::create, QIcon() ); - QVERIFY( ! registry->addRenderer( dupe ) ); + QVERIFY( !registry->addRenderer( dupe ) ); QCOMPARE( registry->renderersList().length(), previousCount + 1 ); delete dupe; diff --git a/tests/src/core/testqgspointlocator.cpp b/tests/src/core/testqgspointlocator.cpp index eef5feac99c6..9c2fa9d354d2 100644 --- a/tests/src/core/testqgspointlocator.cpp +++ b/tests/src/core/testqgspointlocator.cpp @@ -28,28 +28,29 @@ struct FilterExcludePoint : public QgsPointLocator::MatchFilter { - explicit FilterExcludePoint( const QgsPointXY &p ) : mPoint( p ) {} + explicit FilterExcludePoint( const QgsPointXY &p ) + : mPoint( p ) {} - bool acceptMatch( const QgsPointLocator::Match &match ) override { return match.point() != mPoint; } + bool acceptMatch( const QgsPointLocator::Match &match ) override { return match.point() != mPoint; } - QgsPointXY mPoint; + QgsPointXY mPoint; }; struct FilterExcludeEdge : public QgsPointLocator::MatchFilter { - FilterExcludeEdge( const QgsPointXY &p1, const QgsPointXY &p2 ) - : mP1( p1 ) - , mP2( p2 ) - {} - - bool acceptMatch( const QgsPointLocator::Match &match ) override - { - QgsPointXY p1, p2; - match.edgePoints( p1, p2 ); - return !( p1 == mP1 && p2 == mP2 ) && !( p1 == mP2 && p2 == mP1 ); - } - - QgsPointXY mP1, mP2; + FilterExcludeEdge( const QgsPointXY &p1, const QgsPointXY &p2 ) + : mP1( p1 ) + , mP2( p2 ) + {} + + bool acceptMatch( const QgsPointLocator::Match &match ) override + { + QgsPointXY p1, p2; + match.edgePoints( p1, p2 ); + return !( p1 == mP1 && p2 == mP2 ) && !( p1 == mP2 && p2 == mP1 ); + } + + QgsPointXY mP1, mP2; }; @@ -106,7 +107,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m.isValid() ); QVERIFY( m.hasVertex() ); QCOMPARE( m.layer(), mVL ); - QCOMPARE( m.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m.point(), QgsPointXY( 1, 1 ) ); QCOMPARE( m.distance(), std::sqrt( 2.0 ) ); QCOMPARE( m.vertexIndex(), 2 ); @@ -120,7 +121,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m.isValid() ); QVERIFY( m.hasEdge() ); QCOMPARE( m.layer(), mVL ); - QCOMPARE( m.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m.point(), QgsPointXY( 1, 0.5 ) ); QCOMPARE( m.distance(), 0.1 ); QCOMPARE( m.vertexIndex(), 1 ); @@ -142,7 +143,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m2.isValid() ); QVERIFY( m2.hasArea() ); QCOMPARE( m2.layer(), mVL ); - QCOMPARE( m2.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m2.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m2.point(), QgsPointXY( 0.9, 0.9 ) ); QCOMPARE( m2.distance(), 0.0 ); @@ -151,7 +152,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m3.isValid() ); QVERIFY( m3.hasArea() ); QCOMPARE( m3.layer(), mVL ); - QCOMPARE( m3.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m3.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m3.point(), QgsPointXY( 1.0, 1.0 ) ); QCOMPARE( m3.distance(), .1 * std::sqrt( 2 ) ); } @@ -165,7 +166,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m.isValid() ); QVERIFY( m.hasArea() ); QCOMPARE( m.layer(), mVL ); - QCOMPARE( m.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m.featureId(), ( QgsFeatureId ) 1 ); const QgsPointLocator::MatchList mInvalid = loc.pointInPolygon( QgsPointXY( 0, 0 ) ); QCOMPARE( mInvalid.count(), 0 ); @@ -217,7 +218,7 @@ class TestQgsPointLocator : public QObject QCOMPARE( lst.count(), 0 ); QgsPointLocator::MatchList lst2 = loc.verticesInRect( QgsPointXY( 0, 1.5 ), 0.5 ); - QCOMPARE( lst2.count(), 2 ); // one matching point, but it is the first point in ring, so it is duplicated + QCOMPARE( lst2.count(), 2 ); // one matching point, but it is the first point in ring, so it is duplicated QCOMPARE( lst2[0].vertexIndex(), 0 ); QCOMPARE( lst2[1].vertexIndex(), 3 ); @@ -230,7 +231,6 @@ class TestQgsPointLocator : public QObject void testLayerUpdates() { - QgsPointLocator loc( mVL ); const QgsPointLocator::Match mAddV0 = loc.nearestVertex( QgsPointXY( 12, 12 ), 999 ); @@ -245,7 +245,7 @@ class TestQgsPointLocator : public QObject QgsPolylineXY polyline; polyline << QgsPointXY( 10, 11 ) << QgsPointXY( 11, 10 ) << QgsPointXY( 11, 11 ) << QgsPointXY( 10, 11 ); polygon << polyline; - const QgsGeometry ffGeom = QgsGeometry::fromPolygonXY( polygon ) ; + const QgsGeometry ffGeom = QgsGeometry::fromPolygonXY( polygon ); ff.setGeometry( ffGeom ); QgsFeatureList flist; flist << ff; @@ -369,7 +369,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m.isValid() ); QVERIFY( m.hasVertex() ); QCOMPARE( m.layer(), mVL ); - QCOMPARE( m.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m.point(), QgsPointXY( 1, 1 ) ); QCOMPARE( m.distance(), std::sqrt( 2.0 ) ); QCOMPARE( m.vertexIndex(), 2 ); @@ -377,7 +377,6 @@ class TestQgsPointLocator : public QObject void testLayerUpdatesAsynchronous() { - QgsPointLocator loc( mVL ); QEventLoop loop; @@ -398,7 +397,7 @@ class TestQgsPointLocator : public QObject QgsPolylineXY polyline; polyline << QgsPointXY( 10, 11 ) << QgsPointXY( 11, 10 ) << QgsPointXY( 11, 11 ) << QgsPointXY( 10, 11 ); polygon << polyline; - const QgsGeometry ffGeom = QgsGeometry::fromPolygonXY( polygon ) ; + const QgsGeometry ffGeom = QgsGeometry::fromPolygonXY( polygon ); ff.setGeometry( ffGeom ); QgsFeatureList flist; flist << ff; @@ -457,7 +456,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m.isValid() ); QVERIFY( m.hasVertex() ); QCOMPARE( m.layer(), mVL ); - QCOMPARE( m.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m.point(), QgsPointXY( 1, 1 ) ); QCOMPARE( m.distance(), std::sqrt( 2.0 ) ); QCOMPARE( m.vertexIndex(), 2 ); @@ -518,7 +517,7 @@ class TestQgsPointLocator : public QObject { std::unique_ptr curveLayer( new QgsVectorLayer( QStringLiteral( "CircularStringZ" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ) ); QgsFeature f1; - const QgsGeometry f1g = QgsGeometry::fromWkt( "CircularStringZ (0 0 0, 5 5 5, 0 10 10)" ) ; + const QgsGeometry f1g = QgsGeometry::fromWkt( "CircularStringZ (0 0 0, 5 5 5, 0 10 10)" ); f1.setGeometry( f1g ); QgsFeatureList f1list; f1list << f1; @@ -530,7 +529,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m1.isValid() ); QVERIFY( m1.hasEdge() ); QCOMPARE( m1.layer(), curveLayer.get() ); - QCOMPARE( m1.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m1.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m1.point(), QgsPointXY( 3.53553390593273775, 8.53553390593273775 ) ); QCOMPARE( m1.distance(), 0.757359312881 ); QCOMPARE( m1.vertexIndex(), 1 ); @@ -542,7 +541,7 @@ class TestQgsPointLocator : public QObject std::unique_ptr lineLayer( new QgsVectorLayer( QStringLiteral( "LineStringZ" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ) ); QgsFeature f2; - const QgsGeometry f2g = QgsGeometry::fromWkt( "LineStringZ (0 0 0, 5 5 5, 0 10 10)" ) ; + const QgsGeometry f2g = QgsGeometry::fromWkt( "LineStringZ (0 0 0, 5 5 5, 0 10 10)" ); f2.setGeometry( f2g ); QgsFeatureList f2list; f2list << f2; @@ -554,7 +553,7 @@ class TestQgsPointLocator : public QObject QVERIFY( m2.isValid() ); QVERIFY( m2.hasEdge() ); QCOMPARE( m2.layer(), lineLayer.get() ); - QCOMPARE( m2.featureId(), ( QgsFeatureId )1 ); + QCOMPARE( m2.featureId(), ( QgsFeatureId ) 1 ); QCOMPARE( m2.point(), QgsPointXY( 2.5, 7.5 ) ); QCOMPARE( m2.distance(), 0.707106781187 ); QCOMPARE( m2.vertexIndex(), 1 ); diff --git a/tests/src/core/testqgspointpatternfillsymbol.cpp b/tests/src/core/testqgspointpatternfillsymbol.cpp index 834d8c25ed8b..bb65e51bdd0b 100644 --- a/tests/src/core/testqgspointpatternfillsymbol.cpp +++ b/tests/src/core/testqgspointpatternfillsymbol.cpp @@ -49,11 +49,12 @@ class TestQgsPointPatternFillSymbol : public QgsTest Q_OBJECT public: - TestQgsPointPatternFillSymbol() : QgsTest( QStringLiteral( "Point Pattern Fill Tests" ) ) {} + TestQgsPointPatternFillSymbol() + : QgsTest( QStringLiteral( "Point Pattern Fill Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void pointPatternFillSymbol(); void pointPatternFillSymbolVector(); @@ -77,7 +78,7 @@ class TestQgsPointPatternFillSymbol : public QgsTest void pointPatternAngleViewport(); private: - bool mTestHasError = false ; + bool mTestHasError = false; bool imageCheck( const QString &type, QgsVectorLayer *layer = nullptr ); QgsMapSettings mMapSettings; @@ -106,8 +107,7 @@ void TestQgsPointPatternFillSymbol::initTestCase() // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -115,7 +115,8 @@ void TestQgsPointPatternFillSymbol::initTestCase() // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPolysLayer ); + QList() << mpPolysLayer + ); //setup symbol mPointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -125,7 +126,6 @@ void TestQgsPointPatternFillSymbol::initTestCase() mpPolysLayer->setRenderer( mSymbolRenderer ); mMapSettings.setLayers( QList() << mpPolysLayer ); - } void TestQgsPointPatternFillSymbol::cleanupTestCase() { @@ -195,7 +195,7 @@ void TestQgsPointPatternFillSymbol::pointPatternFillSymbolVector() void TestQgsPointPatternFillSymbol::viewportPointPatternFillSymbol() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsVectorSimplifyMethod simplifyMethod; @@ -221,7 +221,7 @@ void TestQgsPointPatternFillSymbol::viewportPointPatternFillSymbol() void TestQgsPointPatternFillSymbol::viewportPointPatternFillSymbolVector() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsVectorSimplifyMethod simplifyMethod; @@ -355,7 +355,7 @@ void TestQgsPointPatternFillSymbol::zeroSpacedPointPatternFillSymbolVector() void TestQgsPointPatternFillSymbol::pointPatternFillNoClip() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -379,7 +379,7 @@ void TestQgsPointPatternFillSymbol::pointPatternFillNoClip() void TestQgsPointPatternFillSymbol::pointPatternFillCompletelyWithin() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -403,7 +403,7 @@ void TestQgsPointPatternFillSymbol::pointPatternFillCompletelyWithin() void TestQgsPointPatternFillSymbol::pointPatternFillCentroidWithin() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -427,7 +427,7 @@ void TestQgsPointPatternFillSymbol::pointPatternFillCentroidWithin() void TestQgsPointPatternFillSymbol::pointPatternFillDataDefinedClip() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -452,7 +452,7 @@ void TestQgsPointPatternFillSymbol::pointPatternFillDataDefinedClip() void TestQgsPointPatternFillSymbol::pointPatternFillDataDefinedWithOpacity() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -482,7 +482,7 @@ void TestQgsPointPatternFillSymbol::pointPatternFillDataDefinedWithOpacity() void TestQgsPointPatternFillSymbol::pointPatternRandomOffset() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -509,7 +509,7 @@ void TestQgsPointPatternFillSymbol::pointPatternRandomOffset() void TestQgsPointPatternFillSymbol::pointPatternRandomOffsetPercent() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -538,7 +538,7 @@ void TestQgsPointPatternFillSymbol::pointPatternRandomOffsetPercent() void TestQgsPointPatternFillSymbol::pointPatternRandomOffsetDataDefined() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -555,9 +555,9 @@ void TestQgsPointPatternFillSymbol::pointPatternRandomOffsetDataDefined() pointPatternFill->setSubSymbol( pointSymbol ); pointPatternFill->setDistanceX( 10 ); pointPatternFill->setDistanceY( 10 ); - pointPatternFill->dataDefinedProperties().setProperty( static_cast < int >( QgsSymbolLayer::Property::RandomOffsetX ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then 5 else 10 end" ) ) ); - pointPatternFill->dataDefinedProperties().setProperty( static_cast < int >( QgsSymbolLayer::Property::RandomOffsetY ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then 3 else 6 end" ) ) ); - pointPatternFill->dataDefinedProperties().setProperty( static_cast < int >( QgsSymbolLayer::Property::RandomSeed ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then 1 else 2 end" ) ) ); + pointPatternFill->dataDefinedProperties().setProperty( static_cast( QgsSymbolLayer::Property::RandomOffsetX ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then 5 else 10 end" ) ) ); + pointPatternFill->dataDefinedProperties().setProperty( static_cast( QgsSymbolLayer::Property::RandomOffsetY ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then 3 else 6 end" ) ) ); + pointPatternFill->dataDefinedProperties().setProperty( static_cast( QgsSymbolLayer::Property::RandomSeed ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then 1 else 2 end" ) ) ); const bool res = imageCheck( "symbol_pointfill_data_defined_random_offset", layer.get() ); QVERIFY( res ); @@ -565,7 +565,7 @@ void TestQgsPointPatternFillSymbol::pointPatternRandomOffsetDataDefined() void TestQgsPointPatternFillSymbol::pointPatternAngle() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -590,7 +590,7 @@ void TestQgsPointPatternFillSymbol::pointPatternAngle() void TestQgsPointPatternFillSymbol::pointPatternAngleDataDefined() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -608,7 +608,7 @@ void TestQgsPointPatternFillSymbol::pointPatternAngleDataDefined() pointPatternFill->setDistanceX( 10 ); pointPatternFill->setDistanceY( 6 ); pointPatternFill->setAngle( 25 ); - pointPatternFill->dataDefinedProperties().setProperty( static_cast < int >( QgsSymbolLayer::Property::Angle ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then -10 else 25 end" ) ) ); + pointPatternFill->dataDefinedProperties().setProperty( static_cast( QgsSymbolLayer::Property::Angle ), QgsProperty::fromExpression( QStringLiteral( "case when $id % 2 = 0 then -10 else 25 end" ) ) ); const bool res = imageCheck( "symbol_pointfill_data_defined_angle", layer.get() ); QVERIFY( res ); @@ -616,7 +616,7 @@ void TestQgsPointPatternFillSymbol::pointPatternAngleDataDefined() void TestQgsPointPatternFillSymbol::pointPatternAngleViewport() { - std::unique_ptr< QgsVectorLayer> layer = std::make_unique< QgsVectorLayer>( mTestDataDir + "polys.shp" ); + std::unique_ptr layer = std::make_unique( mTestDataDir + "polys.shp" ); QVERIFY( layer->isValid() ); QgsPointPatternFillSymbolLayer *pointPatternFill = new QgsPointPatternFillSymbolLayer(); @@ -650,7 +650,7 @@ bool TestQgsPointPatternFillSymbol::imageCheck( const QString &testType, QgsVect if ( !layer ) layer = mpPolysLayer; - mMapSettings.setLayers( {layer } ); + mMapSettings.setLayers( { layer } ); //use the QgsRenderChecker test utility class to //ensure the rendered output matches our control image diff --git a/tests/src/core/testqgspostgresstringutils.cpp b/tests/src/core/testqgspostgresstringutils.cpp index 285b507bad59..0a2d2dfde15d 100644 --- a/tests/src/core/testqgspostgresstringutils.cpp +++ b/tests/src/core/testqgspostgresstringutils.cpp @@ -31,7 +31,6 @@ class TestQgsPostgresStringUtils : public QObject void TestQgsPostgresStringUtils::testPgArrayStringToListAndBack() { - QVariantList vl; vl.push_back( QStringLiteral( "one" ) ); vl.push_back( QStringLiteral( "}two{" ) ); diff --git a/tests/src/core/testqgsproject.cpp b/tests/src/core/testqgsproject.cpp index 4b86fc720008..4efe6afd7870 100644 --- a/tests/src/core/testqgsproject.cpp +++ b/tests/src/core/testqgsproject.cpp @@ -38,10 +38,10 @@ class TestQgsProject : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testDirtySet(); void testReadPath(); @@ -110,7 +110,7 @@ void TestQgsProject::testReadPath() { QgsProject *prj = new QgsProject; // this is a bit hacky as we do not really load such project -#if defined(Q_OS_WIN) +#if defined( Q_OS_WIN ) const QString prefix( "C:" ); #else const QString prefix; @@ -167,7 +167,7 @@ void TestQgsProject::testPathResolver() // test older style relative path - file must exist for this to work QTemporaryFile tmpFile; tmpFile.open(); // fileName is not available until we open the file - const QString tmpName = tmpFile.fileName(); + const QString tmpName = tmpFile.fileName(); tmpFile.close(); const QgsPathResolver tempRel( tmpName ); const QFileInfo fi( tmpName ); @@ -212,13 +212,13 @@ static QString _getLayerSvgMarkerPath( const QgsProject &prj, const QString &lay static QHash _parseSvgPathsForLayers( const QString &projectFilename ) { - QHash projectFileSvgPaths; // key = layer name, value = svg path + QHash projectFileSvgPaths; // key = layer name, value = svg path QDomDocument doc; QFile projectFile( projectFilename ); bool res = projectFile.open( QIODevice::ReadOnly ); Q_ASSERT( res ); - res = static_cast< bool >( doc.setContent( &projectFile ) ); + res = static_cast( doc.setContent( &projectFile ) ); Q_ASSERT( res ); projectFile.close(); @@ -261,10 +261,10 @@ void TestQgsProject::testPathResolverSvg() QFile svgFile( ourSvgPath ); QVERIFY( svgFile.open( QIODevice::WriteOnly ) ); - svgFile.write( "" ); // not a proper SVG, but good enough for this case + svgFile.write( "" ); // not a proper SVG, but good enough for this case svgFile.close(); - QVERIFY( QFileInfo::exists( ourSvgPath ) ); // should exist now + QVERIFY( QFileInfo::exists( ourSvgPath ) ); // should exist now const QString librarySvgPath = QgsSymbolLayerUtils::svgSymbolNameToPath( QStringLiteral( "transport/transport_airport.svg" ), QgsPathResolver() ); QCOMPARE( QgsSymbolLayerUtils::svgSymbolPathToName( librarySvgPath, QgsPathResolver() ), QStringLiteral( "transport/transport_airport.svg" ) ); @@ -294,9 +294,9 @@ void TestQgsProject::testPathResolverSvg() QHash projectFileSvgPaths = _parseSvgPathsForLayers( projectFilename ); QCOMPARE( projectFileSvgPaths.count(), 3 ); - QCOMPARE( projectFileSvgPaths["points 1"], QString( "./valid.svg" ) ); // relative path to project - QCOMPARE( projectFileSvgPaths["points 2"], invalidSvgPath ); // full path to non-existent file (not sure why - but that's how it works now) - QCOMPARE( projectFileSvgPaths["points 3"], QString( "transport/transport_airport.svg" ) ); // relative path to library + QCOMPARE( projectFileSvgPaths["points 1"], QString( "./valid.svg" ) ); // relative path to project + QCOMPARE( projectFileSvgPaths["points 2"], invalidSvgPath ); // full path to non-existent file (not sure why - but that's how it works now) + QCOMPARE( projectFileSvgPaths["points 3"], QString( "transport/transport_airport.svg" ) ); // relative path to library // load project again, check that the paths are absolute QgsProject projectLoaded; @@ -324,7 +324,6 @@ void TestQgsProject::testPathResolverSvg() QCOMPARE( svg1x, ourSvgPath ); QCOMPARE( svg2x, invalidSvgPath ); QCOMPARE( svg3x, librarySvgPath ); - } @@ -477,9 +476,8 @@ void TestQgsProject::testLocalFiles() QFile f2( shpPath ); QVERIFY( f2.open( QFile::ReadWrite ) ); f2.close(); - const QgsPathResolver resolver( f.fileName( ) ); - QCOMPARE( resolver.writePath( layerPath ), QString( "./" + info.baseName() + ".shp" ) ) ; - + const QgsPathResolver resolver( f.fileName() ); + QCOMPARE( resolver.writePath( layerPath ), QString( "./" + info.baseName() + ".shp" ) ); } void TestQgsProject::testLocalUrlFiles() @@ -492,14 +490,13 @@ void TestQgsProject::testLocalUrlFiles() prj.setFileName( f.fileName() ); prj.write(); const QString shpPath = info.dir().path() + '/' + info.baseName() + ".shp"; - const QString extraStuff {"?someVar=someValue&someOtherVar=someOtherValue" }; + const QString extraStuff { "?someVar=someValue&someOtherVar=someOtherValue" }; const QString layerPath = "file://" + shpPath + extraStuff; QFile f2( shpPath ); QVERIFY( f2.open( QFile::ReadWrite ) ); f2.close(); - const QgsPathResolver resolver( f.fileName( ) ); - QCOMPARE( resolver.writePath( layerPath ), QString( "./" + info.baseName() + ".shp" + extraStuff ) ) ; - + const QgsPathResolver resolver( f.fileName() ); + QCOMPARE( resolver.writePath( layerPath ), QString( "./" + info.baseName() + ".shp" + extraStuff ) ); } void TestQgsProject::testReadFlags() @@ -515,10 +512,10 @@ void TestQgsProject::testReadFlags() QVERIFY( !layers.value( QStringLiteral( "polys20170310142652234" ) )->isValid() ); // but they should have renderers (and other stuff!) - QCOMPARE( qobject_cast< QgsVectorLayer * >( layers.value( QStringLiteral( "points20170310142652246" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( layers.value( QStringLiteral( "lines20170310142652255" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( layers.value( QStringLiteral( "polys20170310142652234" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); - QVERIFY( ! layers.value( QStringLiteral( "polys20170310142652234" ) )->originalXmlProperties().isEmpty() ); + QCOMPARE( qobject_cast( layers.value( QStringLiteral( "points20170310142652246" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); + QCOMPARE( qobject_cast( layers.value( QStringLiteral( "lines20170310142652255" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); + QCOMPARE( qobject_cast( layers.value( QStringLiteral( "polys20170310142652234" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); + QVERIFY( !layers.value( QStringLiteral( "polys20170310142652234" ) )->originalXmlProperties().isEmpty() ); // do not store styles QVERIFY( p.read( project1Path, Qgis::ProjectReadFlag::DontStoreOriginalStyles ) ); @@ -534,8 +531,8 @@ void TestQgsProject::testReadFlags() QCOMPARE( layers.count(), 2 ); QVERIFY( !layers.value( QStringLiteral( "lines20170310142652255" ) )->isValid() ); QVERIFY( !layers.value( QStringLiteral( "polys20170310142652234" ) )->isValid() ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( layers.value( QStringLiteral( "lines20170310142652255" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); - QCOMPARE( qobject_cast< QgsVectorLayer * >( layers.value( QStringLiteral( "polys20170310142652234" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); + QCOMPARE( qobject_cast( layers.value( QStringLiteral( "lines20170310142652255" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); + QCOMPARE( qobject_cast( layers.value( QStringLiteral( "polys20170310142652234" ) ) )->renderer()->type(), QStringLiteral( "categorizedSymbol" ) ); const QString project3Path = QString( TEST_DATA_DIR ) + QStringLiteral( "/layouts/layout_casting.qgs" ); @@ -871,7 +868,6 @@ void TestQgsProject::testAttachmentsQgs() p2.removeMapLayer( p2layer->id() ); QVERIFY( !QFile( path ).exists() ); } - } void TestQgsProject::testAttachmentsQgz() @@ -951,7 +947,6 @@ void TestQgsProject::testAttachmentsQgz() p2.removeMapLayer( p2layer->id() ); QVERIFY( !QFile( path ).exists() ); } - } void TestQgsProject::testAttachmentIdentifier() @@ -1046,7 +1041,7 @@ void TestQgsProject::testAsynchronousLayerLoading() << QStringLiteral( "lines.shp" ) << QStringLiteral( "lines_cardinals.shp" ) << QStringLiteral( "lines_touching.shp" ) - << QStringLiteral( "linestXXXX_XXXXXX.shp" ) //invalid name + << QStringLiteral( "linestXXXX_XXXXXX.shp" ) //invalid name << QStringLiteral( "multipatch.shp" ) << QStringLiteral( "multipoint.shp" ) << QStringLiteral( "points.shp" ) @@ -1075,7 +1070,7 @@ void TestQgsProject::testAsynchronousLayerLoading() { layers << new QgsVectorLayer( QString( TEST_DATA_DIR ) + QString( '/' ) + vectorFile, vectorFile, QStringLiteral( "ogr" ) ); if ( layers.last()->name() == QLatin1String( "linestXXXX_XXXXXX.shp" ) ) - QVERIFY( ! layers.last()->isValid() ); + QVERIFY( !layers.last()->isValid() ); else QVERIFY( layers.last()->isValid() ); } diff --git a/tests/src/core/testqgsprojectstorage.cpp b/tests/src/core/testqgsprojectstorage.cpp index d8e186b4adbf..286badb04aaf 100644 --- a/tests/src/core/testqgsprojectstorage.cpp +++ b/tests/src/core/testqgsprojectstorage.cpp @@ -28,10 +28,10 @@ class TestQgsProjectStorage : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testMemoryStorage(); void testSupportedUri(); diff --git a/tests/src/core/testqgsprojutils.cpp b/tests/src/core/testqgsprojutils.cpp index 6974c11e5f3e..86c11203d7e8 100644 --- a/tests/src/core/testqgsprojutils.cpp +++ b/tests/src/core/testqgsprojutils.cpp @@ -24,7 +24,7 @@ #include "qgsprojutils.h" #include -class TestQgsProjUtils: public QObject +class TestQgsProjUtils : public QObject { Q_OBJECT private slots: @@ -38,7 +38,6 @@ class TestQgsProjUtils: public QObject void toHorizontalCrs(); void toUnboundCrs(); void hasVerticalAxis(); - }; @@ -58,20 +57,20 @@ void TestQgsProjUtils::cleanupTestCase() struct ProjContextWrapper { - explicit ProjContextWrapper() - {} - - void operator()( int ) - { - QVERIFY( QgsProjContext::get() ); - // TODO - do something with the context? - } + explicit ProjContextWrapper() + {} + + void operator()( int ) + { + QVERIFY( QgsProjContext::get() ); + // TODO - do something with the context? + } }; void TestQgsProjUtils::threadSafeContext() { // smash proj context generation over many threads - QVector< int > list; + QVector list; list.resize( 100 ); QtConcurrent::blockingMap( list, ProjContextWrapper() ); } @@ -108,7 +107,7 @@ void TestQgsProjUtils::searchPath() void TestQgsProjUtils::gridsUsed() { // ensure local user-writable path is present in Proj search paths - QList< QgsDatumTransform::GridDetails > grids = QgsProjUtils::gridsUsed( QStringLiteral( "+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +inv +proj=hgridshift +grids=GDA94_GDA2020_conformal_and_distortion.gsb +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1" ) ); + QList grids = QgsProjUtils::gridsUsed( QStringLiteral( "+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +inv +proj=hgridshift +grids=GDA94_GDA2020_conformal_and_distortion.gsb +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1" ) ); QCOMPARE( grids.count(), 1 ); QCOMPARE( grids.at( 0 ).shortName, QStringLiteral( "GDA94_GDA2020_conformal_and_distortion.gsb" ) ); QVERIFY( grids.at( 0 ).directDownload ); @@ -178,44 +177,44 @@ void TestQgsProjUtils::hasVerticalAxis() // projected 3d crs crs.reset( proj_create( context, "PROJCRS[\"NAD83(HARN) / Oregon GIC Lambert (ft)\",\n" - " BASEGEOGCRS[\"NAD83(HARN)\",\n" - " DATUM[\"NAD83 (High Accuracy Reference Network)\",\n" - " ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n" - " LENGTHUNIT[\"metre\",1]]],\n" - " PRIMEM[\"Greenwich\",0,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" - " ID[\"EPSG\",4957]],\n" - " CONVERSION[\"unnamed\",\n" - " METHOD[\"Lambert Conic Conformal (2SP)\",\n" - " ID[\"EPSG\",9802]],\n" - " PARAMETER[\"Latitude of false origin\",41.75,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8821]],\n" - " PARAMETER[\"Longitude of false origin\",-120.5,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8822]],\n" - " PARAMETER[\"Latitude of 1st standard parallel\",43,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8823]],\n" - " PARAMETER[\"Latitude of 2nd standard parallel\",45.5,\n" - " ANGLEUNIT[\"degree\",0.0174532925199433],\n" - " ID[\"EPSG\",8824]],\n" - " PARAMETER[\"Easting at false origin\",1312335.958,\n" - " LENGTHUNIT[\"foot\",0.3048],\n" - " ID[\"EPSG\",8826]],\n" - " PARAMETER[\"Northing at false origin\",0,\n" - " LENGTHUNIT[\"foot\",0.3048],\n" - " ID[\"EPSG\",8827]]],\n" - " CS[Cartesian,3],\n" - " AXIS[\"easting\",east,\n" - " ORDER[1],\n" - " LENGTHUNIT[\"foot\",0.3048]],\n" - " AXIS[\"northing\",north,\n" - " ORDER[2],\n" - " LENGTHUNIT[\"foot\",0.3048]],\n" - " AXIS[\"ellipsoidal height (h)\",up,\n" - " ORDER[3],\n" - " LENGTHUNIT[\"foot\",0.3048]]]" ) ); + " BASEGEOGCRS[\"NAD83(HARN)\",\n" + " DATUM[\"NAD83 (High Accuracy Reference Network)\",\n" + " ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n" + " LENGTHUNIT[\"metre\",1]]],\n" + " PRIMEM[\"Greenwich\",0,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433]],\n" + " ID[\"EPSG\",4957]],\n" + " CONVERSION[\"unnamed\",\n" + " METHOD[\"Lambert Conic Conformal (2SP)\",\n" + " ID[\"EPSG\",9802]],\n" + " PARAMETER[\"Latitude of false origin\",41.75,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8821]],\n" + " PARAMETER[\"Longitude of false origin\",-120.5,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8822]],\n" + " PARAMETER[\"Latitude of 1st standard parallel\",43,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8823]],\n" + " PARAMETER[\"Latitude of 2nd standard parallel\",45.5,\n" + " ANGLEUNIT[\"degree\",0.0174532925199433],\n" + " ID[\"EPSG\",8824]],\n" + " PARAMETER[\"Easting at false origin\",1312335.958,\n" + " LENGTHUNIT[\"foot\",0.3048],\n" + " ID[\"EPSG\",8826]],\n" + " PARAMETER[\"Northing at false origin\",0,\n" + " LENGTHUNIT[\"foot\",0.3048],\n" + " ID[\"EPSG\",8827]]],\n" + " CS[Cartesian,3],\n" + " AXIS[\"easting\",east,\n" + " ORDER[1],\n" + " LENGTHUNIT[\"foot\",0.3048]],\n" + " AXIS[\"northing\",north,\n" + " ORDER[2],\n" + " LENGTHUNIT[\"foot\",0.3048]],\n" + " AXIS[\"ellipsoidal height (h)\",up,\n" + " ORDER[3],\n" + " LENGTHUNIT[\"foot\",0.3048]]]" ) ); QVERIFY( QgsProjUtils::hasVerticalAxis( crs.get() ) ); } diff --git a/tests/src/core/testqgsproperty.cpp b/tests/src/core/testqgsproperty.cpp index 1aec57aa930b..0ce79454f2b9 100644 --- a/tests/src/core/testqgsproperty.cpp +++ b/tests/src/core/testqgsproperty.cpp @@ -36,11 +36,9 @@ enum class PropertyKeys : int class TestTransformer : public QgsPropertyTransformer { public: - TestTransformer( double minValue, double maxValue ) : QgsPropertyTransformer( minValue, maxValue ) { - } Type transformerType() const override { return SizeScaleTransformer; } @@ -51,7 +49,6 @@ class TestTransformer : public QgsPropertyTransformer QString toExpression( const QString & ) const override { return QString(); } private: - QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const override { Q_UNUSED( context ); @@ -61,7 +58,6 @@ class TestTransformer : public QgsPropertyTransformer return value.toDouble() * 2; } - }; @@ -70,28 +66,28 @@ class TestQgsProperty : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void conversions(); //test QgsProperty static conversion methods - void invalid(); //test invalid properties - void staticProperty(); //test for QgsStaticProperty - void fieldBasedProperty(); //test for QgsFieldBasedProperty + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void conversions(); //test QgsProperty static conversion methods + void invalid(); //test invalid properties + void staticProperty(); //test for QgsStaticProperty + void fieldBasedProperty(); //test for QgsFieldBasedProperty void expressionBasedProperty(); //test for QgsExpressionBasedProperty void equality(); void isStaticValueInContext(); - void propertyTransformer(); //test for QgsPropertyTransformer + void propertyTransformer(); //test for QgsPropertyTransformer void propertyTransformerFromExpression(); // text converting expression into QgsPropertyTransformer void genericNumericTransformer(); void genericNumericTransformerFromExpression(); // text converting expression to QgsGenericNumericTransformer - void sizeScaleTransformer(); //test for QgsSizeScaleTransformer - void sizeScaleTransformerFromExpression(); // text converting expression to QgsSizeScaleTransformer - void colorRampTransformer(); //test for QgsColorRampTransformer - void propertyToTransformer(); //test converting expression based property to transformer/expression pair - void asExpression(); //test converting property to expression - void propertyCollection(); //test for QgsPropertyCollection - void collectionStack(); //test for QgsPropertyCollectionStack + void sizeScaleTransformer(); //test for QgsSizeScaleTransformer + void sizeScaleTransformerFromExpression(); // text converting expression to QgsSizeScaleTransformer + void colorRampTransformer(); //test for QgsColorRampTransformer + void propertyToTransformer(); //test converting expression based property to transformer/expression pair + void asExpression(); //test converting property to expression + void propertyCollection(); //test for QgsPropertyCollection + void collectionStack(); //test for QgsPropertyCollectionStack void curveTransform(); void asVariant(); void isProjectColor(); @@ -99,20 +95,18 @@ class TestQgsProperty : public QObject void mapToMap(); private: - QgsPropertiesDefinition mDefinitions; - void checkCurveResult( const QList< QgsPointXY > &controlPoints, const QVector &x, const QVector &y ); - + void checkCurveResult( const QList &controlPoints, const QVector &x, const QVector &y ); }; void TestQgsProperty::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - mDefinitions.insert( static_cast< int >( PropertyKeys::Property1 ), QgsPropertyDefinition( QStringLiteral( "p1" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); - mDefinitions.insert( static_cast< int >( PropertyKeys::Property2 ), QgsPropertyDefinition( QStringLiteral( "p2" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); - mDefinitions.insert( static_cast< int >( PropertyKeys::Property3 ), QgsPropertyDefinition( QStringLiteral( "p3" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); - mDefinitions.insert( static_cast< int >( PropertyKeys::Property4 ), QgsPropertyDefinition( QStringLiteral( "p4" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( static_cast( PropertyKeys::Property1 ), QgsPropertyDefinition( QStringLiteral( "p1" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( static_cast( PropertyKeys::Property2 ), QgsPropertyDefinition( QStringLiteral( "p2" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( static_cast( PropertyKeys::Property3 ), QgsPropertyDefinition( QStringLiteral( "p3" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); + mDefinitions.insert( static_cast( PropertyKeys::Property4 ), QgsPropertyDefinition( QStringLiteral( "p4" ), QgsPropertyDefinition::DataTypeString, QString(), QString() ) ); } void TestQgsProperty::cleanupTestCase() @@ -122,12 +116,10 @@ void TestQgsProperty::cleanupTestCase() void TestQgsProperty::init() { - } void TestQgsProperty::cleanup() { - } void TestQgsProperty::conversions() @@ -146,20 +138,20 @@ void TestQgsProperty::conversions() collection.setProperty( 0, c1 ); QCOMPARE( c1.valueAsColor( context, QColor( 200, 210, 220 ) ), QColor( 200, 210, 220 ) ); QCOMPARE( collection.valueAsColor( 0, context, QColor( 200, 210, 220 ) ), QColor( 200, 210, 220 ) ); - c1.setStaticValue( QColor( 255, 200, 100, 50 ) ); //color in qvariant + c1.setStaticValue( QColor( 255, 200, 100, 50 ) ); //color in qvariant collection.property( 0 ).setStaticValue( QColor( 255, 200, 100, 50 ) ); //color in qvariant QCOMPARE( c1.valueAsColor( context, QColor( 200, 210, 220 ), &ok ), QColor( 255, 200, 100, 50 ) ); QVERIFY( ok ); QCOMPARE( collection.valueAsColor( 0, context, QColor( 200, 210, 220 ) ), QColor( 255, 200, 100, 50 ) ); - c1.setStaticValue( QColor() ); //invalid color in qvariant, should return default color - collection.property( 0 ).setStaticValue( QColor() ); //invalid color in qvariant, should return default color + c1.setStaticValue( QColor() ); //invalid color in qvariant, should return default color + collection.property( 0 ).setStaticValue( QColor() ); //invalid color in qvariant, should return default color QCOMPARE( c1.valueAsColor( context, QColor( 200, 210, 220 ) ), QColor( 200, 210, 220 ) ); QCOMPARE( collection.valueAsColor( 0, context, QColor( 200, 210, 220 ) ), QColor( 200, 210, 220 ) ); - c1.setStaticValue( QgsSymbolLayerUtils::encodeColor( QColor( 255, 200, 100, 50 ) ) ); //encoded color + c1.setStaticValue( QgsSymbolLayerUtils::encodeColor( QColor( 255, 200, 100, 50 ) ) ); //encoded color collection.property( 0 ).setStaticValue( QgsSymbolLayerUtils::encodeColor( QColor( 255, 200, 100, 50 ) ) ); //encoded color QCOMPARE( c1.valueAsColor( context, QColor( 200, 210, 220 ) ), QColor( 255, 200, 100, 50 ) ); QCOMPARE( collection.valueAsColor( 0, context, QColor( 200, 210, 220 ) ), QColor( 255, 200, 100, 50 ) ); - c1.setStaticValue( "i am not a color" ); //badly encoded color, should return default color + c1.setStaticValue( "i am not a color" ); //badly encoded color, should return default color collection.property( 0 ).setStaticValue( "i am not a color" ); //badly encoded color, should return default color QCOMPARE( c1.valueAsColor( context, QColor( 200, 210, 220 ) ), QColor( 200, 210, 220 ) ); QCOMPARE( collection.valueAsColor( 0, context, QColor( 200, 210, 220 ) ), QColor( 200, 210, 220 ) ); @@ -175,20 +167,20 @@ void TestQgsProperty::conversions() QCOMPARE( d1.valueAsDouble( context, -1.2, &ok ), -1.2 ); QVERIFY( !ok ); QCOMPARE( collection.valueAsDouble( 1, context, -1.2 ), -1.2 ); - d1.setStaticValue( 12.3 ); //double in qvariant + d1.setStaticValue( 12.3 ); //double in qvariant collection.property( 1 ).setStaticValue( 12.3 ); //double in qvariant QCOMPARE( d1.valueAsDouble( context, -1.2, &ok ), 12.3 ); QVERIFY( ok ); QCOMPARE( collection.valueAsDouble( 1, context, -1.2 ), 12.3 ); - d1.setStaticValue( "15.6" ); //double as string + d1.setStaticValue( "15.6" ); //double as string collection.property( 1 ).setStaticValue( "15.6" ); //double as string QCOMPARE( d1.valueAsDouble( context, -1.2 ), 15.6 ); QCOMPARE( collection.valueAsDouble( 1, context, -1.2 ), 15.6 ); - d1.setStaticValue( "i am not a double" ); //not a double, should return default value + d1.setStaticValue( "i am not a double" ); //not a double, should return default value collection.property( 1 ).setStaticValue( "i am not a double" ); //not a double, should return default value QCOMPARE( d1.valueAsDouble( context, -1.2 ), -1.2 ); QCOMPARE( collection.valueAsDouble( 1, context, -1.2 ), -1.2 ); - d1.setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); //null value + d1.setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); //null value collection.property( 1 ).setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); //null value QCOMPARE( d1.valueAsDouble( context, -1.2, &ok ), -1.2 ); QVERIFY( !ok ); @@ -201,29 +193,29 @@ void TestQgsProperty::conversions() QCOMPARE( i1.valueAsInt( context, -11, &ok ), -11 ); QVERIFY( !ok ); QCOMPARE( collection.valueAsInt( 2, context, -11 ), -11 ); - i1.setStaticValue( 13 ); //integer in qvariant + i1.setStaticValue( 13 ); //integer in qvariant collection.property( 2 ).setStaticValue( 13 ); //integer in qvariant QCOMPARE( i1.valueAsInt( context, -11, &ok ), 13 ); QVERIFY( ok ); QCOMPARE( collection.valueAsInt( 2, context, -11, &ok ), 13 ); QVERIFY( ok ); - i1.setStaticValue( 13.9 ); //double in qvariant, should be rounded + i1.setStaticValue( 13.9 ); //double in qvariant, should be rounded collection.property( 2 ).setStaticValue( 13.9 ); //double in qvariant, should be rounded QCOMPARE( i1.valueAsInt( context, -11 ), 14 ); QCOMPARE( collection.valueAsInt( 2, context, -11 ), 14 ); - i1.setStaticValue( "15" ); //integer as string + i1.setStaticValue( "15" ); //integer as string collection.property( 2 ).setStaticValue( "15" ); //integer as string QCOMPARE( i1.valueAsInt( context, -11 ), 15 ); QCOMPARE( collection.valueAsInt( 2, context, -11 ), 15 ); - i1.setStaticValue( "15.9" ); //double as string, should be rounded + i1.setStaticValue( "15.9" ); //double as string, should be rounded collection.property( 2 ).setStaticValue( "15.9" ); //double as string, should be rounded QCOMPARE( i1.valueAsInt( context, -11 ), 16 ); QCOMPARE( collection.valueAsInt( 2, context, -11 ), 16 ); - i1.setStaticValue( "i am not a int" ); //not a int, should return default value + i1.setStaticValue( "i am not a int" ); //not a int, should return default value collection.property( 2 ).setStaticValue( "i am not a int" ); //not a int, should return default value QCOMPARE( i1.valueAsInt( context, -11 ), -11 ); QCOMPARE( collection.valueAsInt( 2, context, -11 ), -11 ); - i1.setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); // null value + i1.setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); // null value collection.property( 2 ).setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); // null value QCOMPARE( i1.valueAsInt( context, -11, &ok ), -11 ); QVERIFY( !ok ); @@ -315,21 +307,21 @@ void TestQgsProperty::conversions() QVERIFY( !ok ); QCOMPARE( collection.valueAsDateTime( 5, context, dt, &ok ), dt ); QVERIFY( !ok ); - d1.setStaticValue( dt2 ); //datetime in qvariant + d1.setStaticValue( dt2 ); //datetime in qvariant collection.property( 5 ).setStaticValue( dt2 ); //datetime in qvariant QCOMPARE( d1.valueAsDateTime( context, dt, &ok ), dt2 ); QVERIFY( ok ); - QCOMPARE( collection.valueAsDateTime( 5, context, dt, &ok ), dt2 ); + QCOMPARE( collection.valueAsDateTime( 5, context, dt, &ok ), dt2 ); QVERIFY( ok ); - d1.setStaticValue( "2010-01-01" ); //datetime as string + d1.setStaticValue( "2010-01-01" ); //datetime as string collection.property( 5 ).setStaticValue( "2010-01-01" ); //datetime as string QCOMPARE( d1.valueAsDateTime( context, dt ), dt2 ); QCOMPARE( collection.valueAsDateTime( 5, context, dt ), dt2 ); - d1.setStaticValue( "i am not a datetime" ); //not a datetime, should return default value + d1.setStaticValue( "i am not a datetime" ); //not a datetime, should return default value collection.property( 5 ).setStaticValue( "i am not a datetime" ); //not a double, should return default value QCOMPARE( d1.valueAsDateTime( context, dt ), dt ); QCOMPARE( collection.valueAsDateTime( 5, context, dt ), dt ); - d1.setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::QDateTime ) ); // null value + d1.setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::QDateTime ) ); // null value collection.property( 5 ).setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::QDateTime ) ); // null value QCOMPARE( d1.valueAsDateTime( context, dt, &ok ), dt ); QVERIFY( !ok ); @@ -346,7 +338,6 @@ void TestQgsProperty::invalid() QgsProperty p3 = QgsProperty::fromValue( 5 ); p3 = p; QCOMPARE( p3.propertyType(), Qgis::PropertyType::Invalid ); - } void TestQgsProperty::staticProperty() @@ -369,9 +360,9 @@ void TestQgsProperty::staticProperty() //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); QgsProperty p1; @@ -456,7 +447,7 @@ void TestQgsProperty::fieldBasedProperty() QCOMPARE( property.propertyType(), Qgis::PropertyType::Field ); QVERIFY( property.isActive() ); QCOMPARE( property.value( context, -1 ).toInt(), 5 ); - QCOMPARE( property.referencedFields( context ), QSet< QString >() << "field1" ); + QCOMPARE( property.referencedFields( context ), QSet() << "field1" ); property.setActive( false ); QVERIFY( !property.isActive() ); QCOMPARE( property.value( context, -1 ).toInt(), -1 ); @@ -464,7 +455,7 @@ void TestQgsProperty::fieldBasedProperty() property.setField( QStringLiteral( "field2" ) ); property.setActive( true ); QCOMPARE( property.value( context, -1 ).toInt(), 7 ); - QCOMPARE( property.referencedFields( context ), QSet< QString >() << "field2" ); + QCOMPARE( property.referencedFields( context ), QSet() << "field2" ); //bad field reference property.setField( QStringLiteral( "bad_field" ) ); QCOMPARE( property.value( context, -1 ).toInt(), -1 ); @@ -485,9 +476,9 @@ void TestQgsProperty::fieldBasedProperty() //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); QgsProperty p1; @@ -560,7 +551,7 @@ void TestQgsProperty::expressionBasedProperty() QVERIFY( property.referencedFields( context ).contains( "field2" ) ); property.setExpressionString( QStringLiteral( "\"field2\"*2" ) ); QCOMPARE( property.value( context, -1 ).toInt(), 14 ); - QCOMPARE( property.referencedFields( context ), QSet< QString >() << "field2" ); + QCOMPARE( property.referencedFields( context ), QSet() << "field2" ); property.setActive( false ); QVERIFY( !property.isActive() ); QCOMPARE( property.value( context, -1 ).toInt(), -1 ); @@ -594,9 +585,9 @@ void TestQgsProperty::expressionBasedProperty() //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); QgsProperty p1; @@ -750,9 +741,9 @@ void TestQgsProperty::propertyTransformer() //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); const TestTransformer t1( -5, 6 ); @@ -766,9 +757,9 @@ void TestQgsProperty::propertyTransformer() //install into property and test evaluation QgsProperty p1; p1.setTransformer( new TestTransformer( 10, 20 ) ); - QVERIFY( dynamic_cast< const TestTransformer * >( p1.transformer() ) ); - QCOMPARE( static_cast< const TestTransformer * >( p1.transformer() )->minValue(), 10.0 ); - QCOMPARE( static_cast< const TestTransformer * >( p1.transformer() )->maxValue(), 20.0 ); + QVERIFY( dynamic_cast( p1.transformer() ) ); + QCOMPARE( static_cast( p1.transformer() )->minValue(), 10.0 ); + QCOMPARE( static_cast( p1.transformer() )->maxValue(), 20.0 ); p1.setStaticValue( QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); QCOMPARE( p1.value( context, -99 ).toDouble(), -1.0 ); p1.setStaticValue( 11.0 ); @@ -803,7 +794,7 @@ void TestQgsProperty::propertyTransformerFromExpression() QString baseExpression; QString fieldName; // not convertible to a transformer - std::unique_ptr< QgsPropertyTransformer > exp( QgsPropertyTransformer::fromExpression( QStringLiteral( "1 * 2" ), baseExpression, fieldName ) ); + std::unique_ptr exp( QgsPropertyTransformer::fromExpression( QStringLiteral( "1 * 2" ), baseExpression, fieldName ) ); QVERIFY( !exp.get() ); QVERIFY( baseExpression.isEmpty() ); QVERIFY( fieldName.isEmpty() ); @@ -825,12 +816,7 @@ void TestQgsProperty::propertyTransformerFromExpression() void TestQgsProperty::genericNumericTransformer() { const QgsExpressionContext context; - QgsGenericNumericTransformer t1( 10, - 20, - 100, - 200, - -10, - 1.0 ); + QgsGenericNumericTransformer t1( 10, 20, 100, 200, -10, 1.0 ); QCOMPARE( t1.transformerType(), QgsPropertyTransformer::GenericNumericTransformer ); QCOMPARE( t1.minValue(), 10.0 ); QCOMPARE( t1.maxValue(), 20.0 ); @@ -849,9 +835,9 @@ void TestQgsProperty::genericNumericTransformer() // add a curve QVERIFY( !t1.curveTransform() ); - t1.setCurveTransform( new QgsCurveTransform( QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); + t1.setCurveTransform( new QgsCurveTransform( QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); QVERIFY( t1.curveTransform() ); - QCOMPARE( t1.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( t1.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); QCOMPARE( t1.transform( context, 10 ).toInt(), 180 ); QCOMPARE( t1.transform( context, 20 ).toInt(), 120 ); @@ -859,30 +845,25 @@ void TestQgsProperty::genericNumericTransformer() // copy const QgsGenericNumericTransformer s1( t1 ); QVERIFY( s1.curveTransform() ); - QCOMPARE( s1.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( s1.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); // assignment QgsGenericNumericTransformer s2; s2 = t1; QVERIFY( s2.curveTransform() ); - QCOMPARE( s2.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( s2.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); //saving and restoring //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); - QgsGenericNumericTransformer t2( 15, - 25, - 150, - 250, - -10, - 99 ); - t2.setCurveTransform( new QgsCurveTransform( QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); + QgsGenericNumericTransformer t2( 15, 25, 150, 250, -10, 99 ); + t2.setCurveTransform( new QgsCurveTransform( QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); QVariant element; element = t2.toVariant(); @@ -895,10 +876,10 @@ void TestQgsProperty::genericNumericTransformer() QCOMPARE( r1.nullOutputValue(), -10.0 ); QCOMPARE( r1.exponent(), 99.0 ); QVERIFY( r1.curveTransform() ); - QCOMPARE( r1.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r1.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); // test cloning - std::unique_ptr< QgsGenericNumericTransformer > r2( t2.clone() ); + std::unique_ptr r2( t2.clone() ); QCOMPARE( r2->minValue(), 15.0 ); QCOMPARE( r2->maxValue(), 25.0 ); QCOMPARE( r2->minOutputValue(), 150.0 ); @@ -906,7 +887,7 @@ void TestQgsProperty::genericNumericTransformer() QCOMPARE( r2->nullOutputValue(), -10.0 ); QCOMPARE( r2->exponent(), 99.0 ); QVERIFY( r2->curveTransform() ); - QCOMPARE( r2->curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r2->curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); //test various min/max value/size and scaling methods @@ -944,24 +925,14 @@ void TestQgsProperty::genericNumericTransformer() QCOMPARE( invalid.value( 2.0 ), 1.0 ); //as expression - QgsGenericNumericTransformer t3( 15, - 25, - 150, - 250, - -10, - 1.0 ); + QgsGenericNumericTransformer t3( 15, 25, 150, 250, -10, 1.0 ); QCOMPARE( t3.toExpression( "5+6" ), QStringLiteral( "coalesce(scale_linear(5+6, 15, 25, 150, 250), -10)" ) ); t3.setExponent( 1.6 ); QCOMPARE( t3.toExpression( "5+6" ), QStringLiteral( "coalesce(scale_polynomial(5+6, 15, 25, 150, 250, 1.6), -10)" ) ); // test size scale transformer inside property QgsProperty p; - p.setTransformer( new QgsGenericNumericTransformer( 15, - 25, - 150, - 250, - -10, - 99 ) ); + p.setTransformer( new QgsGenericNumericTransformer( 15, 25, 150, 250, -10, 99 ) ); p.setStaticValue( QVariant() ); bool ok = false; QCOMPARE( p.valueAsDouble( context, 100, &ok ), -10.0 ); @@ -978,7 +949,7 @@ void TestQgsProperty::genericNumericTransformerFromExpression() { QString baseExpression; QString fieldName; - std::unique_ptr< QgsGenericNumericTransformer > exp( QgsGenericNumericTransformer::fromExpression( QStringLiteral( "coalesce(scale_linear(column, 1, 7, 2, 10), 0)" ), baseExpression, fieldName ) ); + std::unique_ptr exp( QgsGenericNumericTransformer::fromExpression( QStringLiteral( "coalesce(scale_linear(column, 1, 7, 2, 10), 0)" ), baseExpression, fieldName ) ); QVERIFY( exp.get() ); QCOMPARE( fieldName, QStringLiteral( "column" ) ); QVERIFY( baseExpression.isEmpty() ); @@ -1024,13 +995,7 @@ void TestQgsProperty::genericNumericTransformerFromExpression() void TestQgsProperty::sizeScaleTransformer() { const QgsExpressionContext context; - QgsSizeScaleTransformer scale( QgsSizeScaleTransformer::Linear, - 10, - 20, - 100, - 200, - -10, - 1.0 ); + QgsSizeScaleTransformer scale( QgsSizeScaleTransformer::Linear, 10, 20, 100, 200, -10, 1.0 ); QCOMPARE( scale.transformerType(), QgsPropertyTransformer::SizeScaleTransformer ); QCOMPARE( scale.minValue(), 10.0 ); QCOMPARE( scale.maxValue(), 20.0 ); @@ -1050,40 +1015,34 @@ void TestQgsProperty::sizeScaleTransformer() // add a curve QVERIFY( !scale.curveTransform() ); - scale.setCurveTransform( new QgsCurveTransform( QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ) ); + scale.setCurveTransform( new QgsCurveTransform( QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ) ); QVERIFY( scale.curveTransform() ); - QCOMPARE( scale.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); + QCOMPARE( scale.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); QCOMPARE( scale.transform( context, 10 ).toInt(), 120 ); QCOMPARE( scale.transform( context, 20 ).toInt(), 180 ); // copy const QgsSizeScaleTransformer s1( scale ); QVERIFY( s1.curveTransform() ); - QCOMPARE( s1.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); + QCOMPARE( s1.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); // assignment QgsSizeScaleTransformer s2; s2 = scale; QVERIFY( s2.curveTransform() ); - QCOMPARE( s2.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); + QCOMPARE( s2.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); //saving and restoring //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); - QgsSizeScaleTransformer t1( QgsSizeScaleTransformer::Exponential, - 15, - 25, - 150, - 250, - -10, - 99 ); - t1.setCurveTransform( new QgsCurveTransform( QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); + QgsSizeScaleTransformer t1( QgsSizeScaleTransformer::Exponential, 15, 25, 150, 250, -10, 99 ); + t1.setCurveTransform( new QgsCurveTransform( QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); QVariant element; element = t1.toVariant(); @@ -1097,10 +1056,10 @@ void TestQgsProperty::sizeScaleTransformer() QCOMPARE( r1.exponent(), 99.0 ); QCOMPARE( r1.type(), QgsSizeScaleTransformer::Exponential ); QVERIFY( r1.curveTransform() ); - QCOMPARE( r1.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r1.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); // test cloning - std::unique_ptr< QgsSizeScaleTransformer > r2( t1.clone() ); + std::unique_ptr r2( t1.clone() ); QCOMPARE( r2->minValue(), 15.0 ); QCOMPARE( r2->maxValue(), 25.0 ); QCOMPARE( r2->minSize(), 150.0 ); @@ -1109,7 +1068,7 @@ void TestQgsProperty::sizeScaleTransformer() QCOMPARE( r2->exponent(), 99.0 ); QCOMPARE( r2->type(), QgsSizeScaleTransformer::Exponential ); QVERIFY( r2->curveTransform() ); - QCOMPARE( r2->curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r2->curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); //test various min/max value/size and scaling methods @@ -1161,13 +1120,7 @@ void TestQgsProperty::sizeScaleTransformer() QCOMPARE( t.size( 200 ), 20.0 ); //as expression - QgsSizeScaleTransformer t2( QgsSizeScaleTransformer::Linear, - 15, - 25, - 150, - 250, - -10, - 1.6 ); + QgsSizeScaleTransformer t2( QgsSizeScaleTransformer::Linear, 15, 25, 150, 250, -10, 1.6 ); QCOMPARE( t2.toExpression( "5+6" ), QStringLiteral( "coalesce(scale_linear(5+6, 15, 25, 150, 250), -10)" ) ); t2.setType( QgsSizeScaleTransformer::Exponential ); t2.setExponent( 1.6 ); @@ -1175,13 +1128,7 @@ void TestQgsProperty::sizeScaleTransformer() // test size scale transformer inside property QgsProperty p; - p.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Exponential, - 15, - 25, - 150, - 250, - -10, - 99 ) ); + p.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Exponential, 15, 25, 150, 250, -10, 99 ) ); p.setStaticValue( QVariant() ); bool ok = false; QCOMPARE( p.valueAsDouble( context, 100, &ok ), -10.0 ); @@ -1198,7 +1145,7 @@ void TestQgsProperty::sizeScaleTransformerFromExpression() { QString baseExpression; QString fieldName; - std::unique_ptr< QgsSizeScaleTransformer > exp( QgsSizeScaleTransformer::fromExpression( QStringLiteral( "coalesce(scale_linear(column, 1, 7, 2, 10), 0)" ), baseExpression, fieldName ) ); + std::unique_ptr exp( QgsSizeScaleTransformer::fromExpression( QStringLiteral( "coalesce(scale_linear(column, 1, 7, 2, 10), 0)" ), baseExpression, fieldName ) ); QVERIFY( exp.get() ); QCOMPARE( exp->type(), QgsSizeScaleTransformer::Linear ); QCOMPARE( fieldName, QStringLiteral( "column" ) ); @@ -1259,10 +1206,7 @@ void TestQgsProperty::sizeScaleTransformerFromExpression() void TestQgsProperty::colorRampTransformer() { const QgsExpressionContext context; - QgsColorRampTransformer scale( 10, - 20, - new QgsGradientColorRamp( QColor( 0, 0, 0 ), QColor( 255, 255, 255 ) ), - QColor( 100, 150, 200 ) ); + QgsColorRampTransformer scale( 10, 20, new QgsGradientColorRamp( QColor( 0, 0, 0 ), QColor( 255, 255, 255 ) ), QColor( 100, 150, 200 ) ); QCOMPARE( scale.transformerType(), QgsPropertyTransformer::ColorRampTransformer ); QCOMPARE( scale.minValue(), 10.0 ); QCOMPARE( scale.maxValue(), 20.0 ); @@ -1279,9 +1223,9 @@ void TestQgsProperty::colorRampTransformer() // add a curve QVERIFY( !scale.curveTransform() ); - scale.setCurveTransform( new QgsCurveTransform( QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ) ); + scale.setCurveTransform( new QgsCurveTransform( QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ) ); QVERIFY( scale.curveTransform() ); - QCOMPARE( scale.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); + QCOMPARE( scale.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); QCOMPARE( scale.transform( context, 10 ).value().name(), QString( "#333333" ) ); QCOMPARE( scale.transform( context, 20 ).value().name(), QString( "#cccccc" ) ); @@ -1289,29 +1233,26 @@ void TestQgsProperty::colorRampTransformer() // copy const QgsColorRampTransformer s1( scale ); QVERIFY( s1.curveTransform() ); - QCOMPARE( s1.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); + QCOMPARE( s1.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); // assignment QgsColorRampTransformer s2; s2 = scale; QVERIFY( s2.curveTransform() ); - QCOMPARE( s2.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); + QCOMPARE( s2.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1, 0.8 ) ); //saving and restoring //create a test dom element QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); - QgsColorRampTransformer t1( 15, - 25, - new QgsGradientColorRamp( QColor( 10, 20, 30 ), QColor( 200, 190, 180 ) ), - QColor( 100, 150, 200 ) ); + QgsColorRampTransformer t1( 15, 25, new QgsGradientColorRamp( QColor( 10, 20, 30 ), QColor( 200, 190, 180 ) ), QColor( 100, 150, 200 ) ); t1.setRampName( QStringLiteral( "rampname " ) ); - t1.setCurveTransform( new QgsCurveTransform( QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); + t1.setCurveTransform( new QgsCurveTransform( QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ) ); QVariant element; element = t1.toVariant(); @@ -1321,22 +1262,22 @@ void TestQgsProperty::colorRampTransformer() QCOMPARE( r1.maxValue(), 25.0 ); QCOMPARE( r1.nullColor(), QColor( 100, 150, 200 ) ); QCOMPARE( r1.rampName(), QStringLiteral( "rampname " ) ); - QVERIFY( dynamic_cast< QgsGradientColorRamp * >( r1.colorRamp() ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r1.colorRamp() )->color1(), QColor( 10, 20, 30 ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r1.colorRamp() )->color2(), QColor( 200, 190, 180 ) ); + QVERIFY( dynamic_cast( r1.colorRamp() ) ); + QCOMPARE( static_cast( r1.colorRamp() )->color1(), QColor( 10, 20, 30 ) ); + QCOMPARE( static_cast( r1.colorRamp() )->color2(), QColor( 200, 190, 180 ) ); QVERIFY( r1.curveTransform() ); - QCOMPARE( r1.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r1.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); // test cloning - std::unique_ptr< QgsColorRampTransformer > r2( t1.clone() ); + std::unique_ptr r2( t1.clone() ); QCOMPARE( r2->minValue(), 15.0 ); QCOMPARE( r2->maxValue(), 25.0 ); QCOMPARE( r2->nullColor(), QColor( 100, 150, 200 ) ); QCOMPARE( r2->rampName(), QStringLiteral( "rampname " ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r2->colorRamp() )->color1(), QColor( 10, 20, 30 ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r2->colorRamp() )->color2(), QColor( 200, 190, 180 ) ); + QCOMPARE( static_cast( r2->colorRamp() )->color1(), QColor( 10, 20, 30 ) ); + QCOMPARE( static_cast( r2->colorRamp() )->color2(), QColor( 200, 190, 180 ) ); QVERIFY( r2->curveTransform() ); - QCOMPARE( r2->curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r2->curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); // copy constructor const QgsColorRampTransformer r3( t1 ); @@ -1344,10 +1285,10 @@ void TestQgsProperty::colorRampTransformer() QCOMPARE( r3.maxValue(), 25.0 ); QCOMPARE( r3.nullColor(), QColor( 100, 150, 200 ) ); QCOMPARE( r3.rampName(), QStringLiteral( "rampname " ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r3.colorRamp() )->color1(), QColor( 10, 20, 30 ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r3.colorRamp() )->color2(), QColor( 200, 190, 180 ) ); + QCOMPARE( static_cast( r3.colorRamp() )->color1(), QColor( 10, 20, 30 ) ); + QCOMPARE( static_cast( r3.colorRamp() )->color2(), QColor( 200, 190, 180 ) ); QVERIFY( r3.curveTransform() ); - QCOMPARE( r3.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r3.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); // assignment operator QgsColorRampTransformer r4; @@ -1356,10 +1297,10 @@ void TestQgsProperty::colorRampTransformer() QCOMPARE( r4.maxValue(), 25.0 ); QCOMPARE( r4.nullColor(), QColor( 100, 150, 200 ) ); QCOMPARE( r4.rampName(), QStringLiteral( "rampname " ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r4.colorRamp() )->color1(), QColor( 10, 20, 30 ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( r4.colorRamp() )->color2(), QColor( 200, 190, 180 ) ); + QCOMPARE( static_cast( r4.colorRamp() )->color1(), QColor( 10, 20, 30 ) ); + QCOMPARE( static_cast( r4.colorRamp() )->color2(), QColor( 200, 190, 180 ) ); QVERIFY( r4.curveTransform() ); - QCOMPARE( r4.curveTransform()->controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); + QCOMPARE( r4.curveTransform()->controlPoints(), QList() << QgsPointXY( 0, 0.8 ) << QgsPointXY( 1, 0.2 ) ); //test various min/max value/color and scaling methods @@ -1372,7 +1313,7 @@ void TestQgsProperty::colorRampTransformer() t.setNullColor( QColor( 1, 10, 11, 21 ) ); QCOMPARE( t.nullColor(), QColor( 1, 10, 11, 21 ) ); t.setColorRamp( new QgsGradientColorRamp( QColor( 10, 20, 100 ), QColor( 100, 200, 200 ) ) ); - QCOMPARE( static_cast< QgsGradientColorRamp * >( t.colorRamp() )->color1(), QColor( 10, 20, 100 ) ); + QCOMPARE( static_cast( t.colorRamp() )->color1(), QColor( 10, 20, 100 ) ); t.setRampName( QStringLiteral( "colorramp" ) ); QCOMPARE( t.rampName(), QStringLiteral( "colorramp" ) ); @@ -1384,10 +1325,7 @@ void TestQgsProperty::colorRampTransformer() QCOMPARE( t.color( 250 ), QColor( 100, 200, 200 ) ); //out of range //toExpression - QgsColorRampTransformer t5( 15, - 25, - new QgsGradientColorRamp( QColor( 10, 20, 30 ), QColor( 200, 190, 180 ) ), - QColor( 100, 150, 200 ) ); + QgsColorRampTransformer t5( 15, 25, new QgsGradientColorRamp( QColor( 10, 20, 30 ), QColor( 200, 190, 180 ) ), QColor( 100, 150, 200 ) ); QCOMPARE( t5.toExpression( "5+6" ), QStringLiteral( "coalesce(ramp_color('custom ramp',scale_linear(5+6, 15, 25, 0, 1)), '#6496c8')" ) ); t5.setRampName( QStringLiteral( "my ramp" ) ); QCOMPARE( t5.toExpression( "5+6" ), QStringLiteral( "coalesce(ramp_color('my ramp',scale_linear(5+6, 15, 25, 0, 1)), '#6496c8')" ) ); @@ -1445,13 +1383,7 @@ void TestQgsProperty::asExpression() QCOMPARE( p.asExpression(), QStringLiteral( "5 + 6" ) ); // with transformer - p.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, - 15, - 25, - 150, - 250, - -10, - 1 ) ); + p.setTransformer( new QgsSizeScaleTransformer( QgsSizeScaleTransformer::Linear, 15, 25, 150, 250, -10, 1 ) ); QCOMPARE( p.asExpression(), QStringLiteral( "coalesce(scale_linear(5 + 6, 15, 25, 150, 250), -10)" ) ); } @@ -1478,7 +1410,7 @@ void TestQgsProperty::propertyCollection() QVERIFY( !collection.hasProperty( PropertyKeys::Property1 ) ); QVERIFY( collection.referencedFields( context ).isEmpty() ); QCOMPARE( collection.count(), 0 ); - QCOMPARE( collection.propertyKeys(), QSet< int >() ); + QCOMPARE( collection.propertyKeys(), QSet() ); QVERIFY( !collection.hasDynamicProperties() ); QVERIFY( !collection.hasActiveProperties() ); @@ -1490,7 +1422,7 @@ void TestQgsProperty::propertyCollection() collection.setProperty( PropertyKeys::Property1, property ); QVERIFY( collection.hasProperty( PropertyKeys::Property1 ) ); QCOMPARE( collection.count(), 1 ); - QCOMPARE( collection.propertyKeys(), QSet< int >() << static_cast< int >( PropertyKeys::Property1 ) ); + QCOMPARE( collection.propertyKeys(), QSet() << static_cast( PropertyKeys::Property1 ) ); QCOMPARE( collection.property( PropertyKeys::Property1 ).value( context ), property.value( context ) ); QCOMPARE( collection.value( PropertyKeys::Property1, context ), property.value( context ) ); QVERIFY( collection.isActive( PropertyKeys::Property1 ) ); @@ -1507,7 +1439,7 @@ void TestQgsProperty::propertyCollection() QVERIFY( collection.prepare( context ) ); //test bad property - QVERIFY( !const_cast< const QgsPropertyCollection * >( &collection )->property( PropertyKeys::Property2 ) ); + QVERIFY( !const_cast( &collection )->property( PropertyKeys::Property2 ) ); QVERIFY( !collection.value( PropertyKeys::Property2, context ).isValid() ); QCOMPARE( collection.value( PropertyKeys::Property2, context, QStringLiteral( "default" ) ).toString(), QStringLiteral( "default" ) ); QVERIFY( !collection.isActive( PropertyKeys::Property2 ) ); @@ -1516,7 +1448,7 @@ void TestQgsProperty::propertyCollection() const QgsProperty property2 = QgsProperty::fromValue( "value2", true ); collection.setProperty( PropertyKeys::Property1, property2 ); QCOMPARE( collection.count(), 1 ); - QCOMPARE( collection.propertyKeys(), QSet< int >() << static_cast< int >( PropertyKeys::Property1 ) ); + QCOMPARE( collection.propertyKeys(), QSet() << static_cast( PropertyKeys::Property1 ) ); QCOMPARE( collection.property( PropertyKeys::Property1 ).value( context ), property2.value( context ) ); QVERIFY( collection.hasActiveProperties() ); QVERIFY( !collection.hasDynamicProperties() ); @@ -1528,13 +1460,13 @@ void TestQgsProperty::propertyCollection() QCOMPARE( collection.property( PropertyKeys::Property3 ).value( context ).toInt(), 5 ); QVERIFY( collection.property( PropertyKeys::Property3 ).isActive() ); QCOMPARE( collection.count(), 2 ); - QCOMPARE( collection.propertyKeys(), QSet() << static_cast< int>( PropertyKeys::Property1 ) << static_cast< int >( PropertyKeys::Property3 ) ); + QCOMPARE( collection.propertyKeys(), QSet() << static_cast( PropertyKeys::Property1 ) << static_cast( PropertyKeys::Property3 ) ); //test removing a property collection.setProperty( PropertyKeys::Property1, QgsProperty() ); - QVERIFY( !const_cast< const QgsPropertyCollection * >( &collection )->property( PropertyKeys::Property1 ) ); + QVERIFY( !const_cast( &collection )->property( PropertyKeys::Property1 ) ); QVERIFY( !collection.hasProperty( PropertyKeys::Property1 ) ); - QCOMPARE( collection.propertyKeys(), QSet() << static_cast< int >( PropertyKeys::Property3 ) ); + QCOMPARE( collection.propertyKeys(), QSet() << static_cast( PropertyKeys::Property3 ) ); QVERIFY( !collection.property( PropertyKeys::Property1 ) ); // should insert a default created invalid property in internal hash QVERIFY( !collection.hasProperty( PropertyKeys::Property1 ) ); @@ -1566,9 +1498,9 @@ void TestQgsProperty::propertyCollection() //saving and restoring QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); const QDomDocument doc( documentType ); const QVariant collectionElement = collection.toVariant( mDefinitions ); @@ -1677,13 +1609,13 @@ void TestQgsProperty::collectionStack() QgsPropertyCollectionStack stack; //test retrieving from empty stack - QVERIFY( !stack.property( static_cast< int >( PropertyKeys::Property1 ) ) ); + QVERIFY( !stack.property( static_cast( PropertyKeys::Property1 ) ) ); QVERIFY( !stack.at( 0 ) ); - QVERIFY( !const_cast< const QgsPropertyCollectionStack * >( &stack )->at( 0 ) ); + QVERIFY( !const_cast( &stack )->at( 0 ) ); QVERIFY( !stack.collection( "nothing" ) ); - QVERIFY( !stack.value( static_cast< int >( PropertyKeys::Property1 ), context ).isValid() ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property1 ), context, "default" ).toString(), QStringLiteral( "default" ) ); - QVERIFY( !stack.isActive( static_cast< int >( PropertyKeys::Property1 ) ) ); + QVERIFY( !stack.value( static_cast( PropertyKeys::Property1 ), context ).isValid() ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property1 ), context, "default" ).toString(), QStringLiteral( "default" ) ); + QVERIFY( !stack.isActive( static_cast( PropertyKeys::Property1 ) ) ); QVERIFY( stack.referencedFields( context ).isEmpty() ); QCOMPARE( stack.count(), 0 ); QVERIFY( !stack.hasDynamicProperties() ); @@ -1694,13 +1626,13 @@ void TestQgsProperty::collectionStack() stack.appendCollection( collection ); QCOMPARE( stack.count(), 1 ); QCOMPARE( stack.at( 0 ), collection ); - QCOMPARE( const_cast< const QgsPropertyCollectionStack * >( &stack )->at( 0 ), collection ); + QCOMPARE( const_cast( &stack )->at( 0 ), collection ); QVERIFY( !stack.collection( "nothing" ) ); QCOMPARE( stack.collection( "collection" ), collection ); - QVERIFY( !stack.property( static_cast< int >( PropertyKeys::Property1 ) ) ); - QVERIFY( !stack.value( static_cast< int >( PropertyKeys::Property1 ), context ).isValid() ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property1 ), context, "default" ).toString(), QStringLiteral( "default" ) ); - QVERIFY( !stack.isActive( static_cast< int >( PropertyKeys::Property1 ) ) ); + QVERIFY( !stack.property( static_cast( PropertyKeys::Property1 ) ) ); + QVERIFY( !stack.value( static_cast( PropertyKeys::Property1 ), context ).isValid() ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property1 ), context, "default" ).toString(), QStringLiteral( "default" ) ); + QVERIFY( !stack.isActive( static_cast( PropertyKeys::Property1 ) ) ); QVERIFY( !stack.hasDynamicProperties() ); QVERIFY( !stack.hasActiveProperties() ); QVERIFY( stack.referencedFields( context ).isEmpty() ); @@ -1708,14 +1640,14 @@ void TestQgsProperty::collectionStack() //now add a property to the collection const QgsProperty property = QgsProperty::fromValue( "value", true ); stack.at( 0 )->setProperty( PropertyKeys::Property1, property ); - QVERIFY( stack.isActive( static_cast< int >( PropertyKeys::Property1 ) ) ); - QCOMPARE( stack.property( static_cast< int >( PropertyKeys::Property1 ) ).value( context ), property.value( context ) ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property1 ), context ), property.value( context ) ); + QVERIFY( stack.isActive( static_cast( PropertyKeys::Property1 ) ) ); + QCOMPARE( stack.property( static_cast( PropertyKeys::Property1 ) ).value( context ), property.value( context ) ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property1 ), context ), property.value( context ) ); QVERIFY( !stack.hasDynamicProperties() ); QVERIFY( stack.hasActiveProperties() ); - QVERIFY( !stack.isActive( static_cast< int >( PropertyKeys::Property2 ) ) ); + QVERIFY( !stack.isActive( static_cast( PropertyKeys::Property2 ) ) ); collection->setProperty( PropertyKeys::Property2, QgsProperty::fromValue( "value1", true ) ); - QVERIFY( stack.isActive( static_cast< int >( PropertyKeys::Property2 ) ) ); + QVERIFY( stack.isActive( static_cast( PropertyKeys::Property2 ) ) ); QVERIFY( !stack.hasDynamicProperties() ); QVERIFY( stack.hasActiveProperties() ); @@ -1724,15 +1656,15 @@ void TestQgsProperty::collectionStack() stack.appendCollection( collection2 ); QCOMPARE( stack.count(), 2 ); QCOMPARE( stack.at( 1 ), collection2 ); - QCOMPARE( const_cast< const QgsPropertyCollectionStack * >( &stack )->at( 1 ), collection2 ); + QCOMPARE( const_cast( &stack )->at( 1 ), collection2 ); QCOMPARE( stack.collection( "collection2" ), collection2 ); QVERIFY( !stack.hasDynamicProperties() ); QVERIFY( stack.hasActiveProperties() ); const QgsProperty property2 = QgsProperty::fromValue( "value2", true ); collection2->setProperty( PropertyKeys::Property2, property2 ); - QVERIFY( stack.isActive( static_cast< int >( PropertyKeys::Property2 ) ) ); - QCOMPARE( stack.property( static_cast< int >( PropertyKeys::Property2 ) ).value( context ), property2.value( context ) ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property2 ), context ), property2.value( context ) ); + QVERIFY( stack.isActive( static_cast( PropertyKeys::Property2 ) ) ); + QCOMPARE( stack.property( static_cast( PropertyKeys::Property2 ) ).value( context ), property2.value( context ) ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property2 ), context ), property2.value( context ) ); QVERIFY( !stack.hasDynamicProperties() ); QVERIFY( stack.hasActiveProperties() ); @@ -1742,21 +1674,21 @@ void TestQgsProperty::collectionStack() //test adding active property later in the stack const QgsProperty property3 = QgsProperty::fromValue( "value3", true ); collection2->setProperty( PropertyKeys::Property1, property3 ); - QVERIFY( stack.isActive( static_cast< int >( PropertyKeys::Property1 ) ) ); - QCOMPARE( stack.property( static_cast< int >( PropertyKeys::Property1 ) ).value( context, "default" ), property3.value( context ) ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property1 ), context ), property3.value( context ) ); + QVERIFY( stack.isActive( static_cast( PropertyKeys::Property1 ) ) ); + QCOMPARE( stack.property( static_cast( PropertyKeys::Property1 ) ).value( context, "default" ), property3.value( context ) ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property1 ), context ), property3.value( context ) ); collection2->property( PropertyKeys::Property1 ).setActive( false ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property1 ), context ), property.value( context ) ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property1 ), context ), property.value( context ) ); //test overriding a property const QgsProperty property4 = QgsProperty::fromValue( "value4", true ); collection2->setProperty( PropertyKeys::Property2, property4 ); - QVERIFY( stack.isActive( static_cast< int >( PropertyKeys::Property2 ) ) ); - QCOMPARE( stack.property( static_cast< int >( PropertyKeys::Property2 ) ).value( context ), property4.value( context ) ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property2 ), context ), property4.value( context ) ); + QVERIFY( stack.isActive( static_cast( PropertyKeys::Property2 ) ) ); + QCOMPARE( stack.property( static_cast( PropertyKeys::Property2 ) ).value( context ), property4.value( context ) ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property2 ), context ), property4.value( context ) ); collection2->property( PropertyKeys::Property2 ).setActive( false ); - QCOMPARE( stack.property( static_cast< int >( PropertyKeys::Property2 ) ).value( context ), QVariant( "value1" ) ); - QCOMPARE( stack.value( static_cast< int >( PropertyKeys::Property2 ), context ), QVariant( "value1" ) ); + QCOMPARE( stack.property( static_cast( PropertyKeys::Property2 ) ).value( context ), QVariant( "value1" ) ); + QCOMPARE( stack.value( static_cast( PropertyKeys::Property2 ), context ), QVariant( "value1" ) ); //clearing stack.clear(); @@ -1807,7 +1739,7 @@ void TestQgsProperty::collectionStack() stack4.at( 0 )->setProperty( PropertyKeys::Property2, QgsProperty::fromExpression( QStringLiteral( "\"field1\" + \"field2\"" ), true ) ); QVERIFY( stack4.hasActiveProperties() ); QVERIFY( stack4.hasDynamicProperties() ); - QCOMPARE( stack4.referencedFields( context ), QSet< QString>() << "field1" << "field2" ); + QCOMPARE( stack4.referencedFields( context ), QSet() << "field1" << "field2" ); stack4.at( 0 )->property( PropertyKeys::Property1 ).setActive( false ); QVERIFY( stack4.hasActiveProperties() ); QVERIFY( stack4.hasDynamicProperties() ); @@ -1828,9 +1760,9 @@ void TestQgsProperty::curveTransform() QCOMPARE( t.y( 1 ), 1.0 ); QCOMPARE( t.y( 2 ), 1.0 ); - QVector< double > x; + QVector x; x << -1 << 0 << 0.2 << 0.5 << 0.8 << 1 << 2; - QVector< double > y = t.y( x ); + QVector y = t.y( x ); QCOMPARE( y[0], 0.0 ); QCOMPARE( y[1], 0.0 ); QCOMPARE( y[2], 0.2 ); @@ -1840,75 +1772,63 @@ void TestQgsProperty::curveTransform() QCOMPARE( y[6], 1.0 ); // linear transform with y =/= x - checkCurveResult( QList< QgsPointXY >() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1.0, 0.8 ), - QVector< double >() << -1 << 0 << 0.2 << 0.5 << 0.8 << 1 << 2, - QVector< double >() << 0.2 << 0.2 << 0.32 << 0.5 << 0.68 << 0.8 << 0.8 ); + checkCurveResult( QList() << QgsPointXY( 0, 0.2 ) << QgsPointXY( 1.0, 0.8 ), QVector() << -1 << 0 << 0.2 << 0.5 << 0.8 << 1 << 2, QVector() << 0.2 << 0.2 << 0.32 << 0.5 << 0.68 << 0.8 << 0.8 ); // reverse linear transform with y = -x - checkCurveResult( QList< QgsPointXY >() << QgsPointXY( 0.0, 1.0 ) << QgsPointXY( 1.0, 0 ), - QVector< double >() << -1 << 0 << 0.2 << 0.5 << 0.8 << 1 << 2, - QVector< double >() << 1.0 << 1.0 << 0.8 << 0.5 << 0.2 << 0.0 << 0.0 ); + checkCurveResult( QList() << QgsPointXY( 0.0, 1.0 ) << QgsPointXY( 1.0, 0 ), QVector() << -1 << 0 << 0.2 << 0.5 << 0.8 << 1 << 2, QVector() << 1.0 << 1.0 << 0.8 << 0.5 << 0.2 << 0.0 << 0.0 ); // OK, time for some more complex tests... // 3 control points, but linear - checkCurveResult( QList< QgsPointXY >() << QgsPointXY( 0, 0.0 ) << QgsPointXY( 0.2, 0.2 ) << QgsPointXY( 1.0, 1.0 ), - QVector< double >() << -1 << 0 << 0.2 << 0.5 << 0.8 << 1 << 2, - QVector< double >() << 0.0 << 0.0 << 0.2 << 0.5 << 0.8 << 1.0 << 1.0 ); + checkCurveResult( QList() << QgsPointXY( 0, 0.0 ) << QgsPointXY( 0.2, 0.2 ) << QgsPointXY( 1.0, 1.0 ), QVector() << -1 << 0 << 0.2 << 0.5 << 0.8 << 1 << 2, QVector() << 0.0 << 0.0 << 0.2 << 0.5 << 0.8 << 1.0 << 1.0 ); // test for "flat" response for x outside of control point range - checkCurveResult( QList< QgsPointXY >() << QgsPointXY( 0.2, 0.2 ) << QgsPointXY( 0.5, 0.5 ) << QgsPointXY( 0.8, 0.8 ), - QVector< double >() << -1 << 0 << 0.1 << 0.2 << 0.5 << 0.8 << 0.9 << 1 << 2, - QVector< double >() << 0.2 << 0.2 << 0.2 << 0.2 << 0.5 << 0.8 << 0.8 << 0.8 << 0.8 ); + checkCurveResult( QList() << QgsPointXY( 0.2, 0.2 ) << QgsPointXY( 0.5, 0.5 ) << QgsPointXY( 0.8, 0.8 ), QVector() << -1 << 0 << 0.1 << 0.2 << 0.5 << 0.8 << 0.9 << 1 << 2, QVector() << 0.2 << 0.2 << 0.2 << 0.2 << 0.5 << 0.8 << 0.8 << 0.8 << 0.8 ); //curves! - checkCurveResult( QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.4, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 1.0, 1.0 ), - QVector< double >() << -1 << 0 << 0.2 << 0.4 << 0.5 << 0.6 << 0.8 << 0.9 << 1.0 << 2.0, - QVector< double >() << 0.0 << 0.0 << 0.321429 << 0.6 << 0.710714 << 0.8 << 0.921429 << 0.963393 << 1.0 << 1.0 ); + checkCurveResult( QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.4, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 1.0, 1.0 ), QVector() << -1 << 0 << 0.2 << 0.4 << 0.5 << 0.6 << 0.8 << 0.9 << 1.0 << 2.0, QVector() << 0.0 << 0.0 << 0.321429 << 0.6 << 0.710714 << 0.8 << 0.921429 << 0.963393 << 1.0 << 1.0 ); //curves with more control points - checkCurveResult( QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.6 ) << QgsPointXY( 0.4, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 0.8, 0.3 ) << QgsPointXY( 1.0, 1.0 ), - QVector< double >() << -1 << 0 << 0.2 << 0.4 << 0.5 << 0.6 << 0.8 << 0.9 << 1.0 << 2.0, - QVector< double >() << 0.0 << 0.0 << 0.6 << 0.6 << 0.751316 << 0.8 << 0.3 << 0.508074 << 1.0 << 1.0 ); + checkCurveResult( QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.6 ) << QgsPointXY( 0.4, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 0.8, 0.3 ) << QgsPointXY( 1.0, 1.0 ), QVector() << -1 << 0 << 0.2 << 0.4 << 0.5 << 0.6 << 0.8 << 0.9 << 1.0 << 2.0, QVector() << 0.0 << 0.0 << 0.6 << 0.6 << 0.751316 << 0.8 << 0.3 << 0.508074 << 1.0 << 1.0 ); // general tests - QList< QgsPointXY > points = QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.4, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 1.0, 1.0 ); + QList points = QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.4, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 1.0, 1.0 ); QgsCurveTransform src( points ); QCOMPARE( src.controlPoints(), points ); - points = QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.5, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 1.0, 1.0 ); + points = QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.5, 0.6 ) << QgsPointXY( 0.6, 0.8 ) << QgsPointXY( 1.0, 1.0 ); src.setControlPoints( points ); QCOMPARE( src.controlPoints(), points ); - src.setControlPoints( QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 1.0, 1.0 ) ); + src.setControlPoints( QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 1.0, 1.0 ) ); src.addControlPoint( 0.2, 0.3 ); src.addControlPoint( 0.1, 0.4 ); - QCOMPARE( src.controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.1, 0.4 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); + QCOMPARE( src.controlPoints(), QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.1, 0.4 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); // remove non-existent point src.removeControlPoint( 0.6, 0.7 ); - QCOMPARE( src.controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.1, 0.4 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); + QCOMPARE( src.controlPoints(), QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.1, 0.4 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); // remove valid point src.removeControlPoint( 0.1, 0.4 ); - QCOMPARE( src.controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); + QCOMPARE( src.controlPoints(), QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); // copy constructor const QgsCurveTransform dest( src ); - QCOMPARE( dest.controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); + QCOMPARE( dest.controlPoints(), QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); // check a value to ensure that derivative matrix was copied OK QGSCOMPARENEAR( dest.y( 0.5 ), 0.1, 0.638672 ); // assignment operator QgsCurveTransform dest2; dest2 = src; - QCOMPARE( dest2.controlPoints(), QList< QgsPointXY >() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); + QCOMPARE( dest2.controlPoints(), QList() << QgsPointXY( 0.0, 0.0 ) << QgsPointXY( 0.2, 0.3 ) << QgsPointXY( 1.0, 1.0 ) ); QGSCOMPARENEAR( dest2.y( 0.5 ), 0.1, 0.638672 ); // writing and reading from xml QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement element = doc.createElement( QStringLiteral( "xform" ) ); @@ -1988,7 +1908,7 @@ void TestQgsProperty::checkCurveResult( const QList &controlPoints, QGSCOMPARENEAR( t.y( x.at( i ) ), y.at( i ), 0.0001 ); } - const QVector< double > results = t.y( x ); + const QVector results = t.y( x ); for ( int i = 0; i < y.count(); ++i ) { QGSCOMPARENEAR( results.at( i ), y.at( i ), 0.0001 ); diff --git a/tests/src/core/testqgsprovidermetadata.cpp b/tests/src/core/testqgsprovidermetadata.cpp index 263b57703a62..b62713594aa0 100644 --- a/tests/src/core/testqgsprovidermetadata.cpp +++ b/tests/src/core/testqgsprovidermetadata.cpp @@ -19,7 +19,7 @@ #include #include -class TestQgsProviderMetadata: public QObject +class TestQgsProviderMetadata : public QObject { Q_OBJECT @@ -27,10 +27,10 @@ class TestQgsProviderMetadata: public QObject TestQgsProviderMetadata() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void checkBoolParameterSetting(); @@ -47,7 +47,6 @@ void TestQgsProviderMetadata::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsProviderMetadata::init() @@ -76,12 +75,7 @@ void TestQgsProviderMetadata::checkBoolParameterSetting() QgsProviderMetadata::setBoolParameter( uri, QStringLiteral( "testFour" ), QStringLiteral( "true" ) ); QgsProviderMetadata::setBoolParameter( uri, QStringLiteral( "testFive" ), true ); - QVariantMap expected = { { QStringLiteral( "testOne" ), QVariant( true ) }, - { QStringLiteral( "testTwo" ), QVariant( true ) }, - { QStringLiteral( "testThree" ), QVariant( true ) }, - { QStringLiteral( "testFour" ), QVariant( true ) }, - { QStringLiteral( "testFive" ), QVariant( true ) } - }; + QVariantMap expected = { { QStringLiteral( "testOne" ), QVariant( true ) }, { QStringLiteral( "testTwo" ), QVariant( true ) }, { QStringLiteral( "testThree" ), QVariant( true ) }, { QStringLiteral( "testFour" ), QVariant( true ) }, { QStringLiteral( "testFive" ), QVariant( true ) } }; QCOMPARE( uri, expected ); @@ -96,12 +90,7 @@ void TestQgsProviderMetadata::checkBoolParameterSetting() QgsProviderMetadata::setBoolParameter( uri, QStringLiteral( "testFour" ), QStringLiteral( "false" ) ); QgsProviderMetadata::setBoolParameter( uri, QStringLiteral( "testFive" ), false ); - expected = { { QStringLiteral( "testOne" ), QVariant( false ) }, - { QStringLiteral( "testTwo" ), QVariant( false ) }, - { QStringLiteral( "testThree" ), QVariant( false ) }, - { QStringLiteral( "testFour" ), QVariant( false ) }, - { QStringLiteral( "testFive" ), QVariant( false ) } - }; + expected = { { QStringLiteral( "testOne" ), QVariant( false ) }, { QStringLiteral( "testTwo" ), QVariant( false ) }, { QStringLiteral( "testThree" ), QVariant( false ) }, { QStringLiteral( "testFour" ), QVariant( false ) }, { QStringLiteral( "testFive" ), QVariant( false ) } }; QCOMPARE( uri, expected ); QgsProviderMetadata::setBoolParameter( uri, QStringLiteral( "testOne" ), QStringLiteral( "NO" ) ); @@ -109,12 +98,12 @@ void TestQgsProviderMetadata::checkBoolParameterSetting() QCOMPARE( uri, expected ); - uri[ QStringLiteral( "testOne" ) ] = QStringLiteral( "yes" ); - uri[ QStringLiteral( "testTwo" ) ] = QStringLiteral( "1" ); - uri[ QStringLiteral( "testThree" ) ] = QStringLiteral( "true" ); - uri[ QStringLiteral( "testFour" ) ] = 1; - uri[ QStringLiteral( "testFive" ) ] = true; - uri[ QStringLiteral( "testSix" ) ] = QStringLiteral( "otherValue" ); + uri[QStringLiteral( "testOne" )] = QStringLiteral( "yes" ); + uri[QStringLiteral( "testTwo" )] = QStringLiteral( "1" ); + uri[QStringLiteral( "testThree" )] = QStringLiteral( "true" ); + uri[QStringLiteral( "testFour" )] = 1; + uri[QStringLiteral( "testFive" )] = true; + uri[QStringLiteral( "testSix" )] = QStringLiteral( "otherValue" ); QVERIFY( mMetadata->boolParameter( uri, QStringLiteral( "testOne" ), false ) ); QVERIFY( mMetadata->boolParameter( uri, QStringLiteral( "testTwo" ), false ) ); diff --git a/tests/src/core/testqgsrange.cpp b/tests/src/core/testqgsrange.cpp index ecf1cfce9d4b..c1d41ff0989b 100644 --- a/tests/src/core/testqgsrange.cpp +++ b/tests/src/core/testqgsrange.cpp @@ -17,20 +17,19 @@ #include "qgsrange.h" -class TestQgsRange: public QObject +class TestQgsRange : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testMergeRangesDate(); void testMergeRangesDateTime(); private: - }; void TestQgsRange::initTestCase() @@ -43,57 +42,47 @@ void TestQgsRange::cleanupTestCase() void TestQgsRange::init() { - } void TestQgsRange::cleanup() { - } void TestQgsRange::testMergeRangesDate() { - QList< QgsDateRange > res = QgsDateRange::mergeRanges( {} ); + QList res = QgsDateRange::mergeRanges( {} ); QVERIFY( res.empty() ); - res = QgsDateRange::mergeRanges( {QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) )} ); + res = QgsDateRange::mergeRanges( { QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ) } ); QCOMPARE( res.size(), 1 ); QCOMPARE( res.at( 0 ).begin(), QDate( 2020, 1, 10 ) ); QCOMPARE( res.at( 0 ).end(), QDate( 2020, 1, 15 ) ); - res = QgsDateRange::mergeRanges( {QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ), - QgsDateRange( QDate( 2020, 1, 19 ), QDate( 2020, 1, 22 ) )} ); + res = QgsDateRange::mergeRanges( { QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ), QgsDateRange( QDate( 2020, 1, 19 ), QDate( 2020, 1, 22 ) ) } ); QCOMPARE( res.size(), 2 ); QCOMPARE( res.at( 0 ).begin(), QDate( 2020, 1, 10 ) ); QCOMPARE( res.at( 0 ).end(), QDate( 2020, 1, 15 ) ); QCOMPARE( res.at( 1 ).begin(), QDate( 2020, 1, 19 ) ); QCOMPARE( res.at( 1 ).end(), QDate( 2020, 1, 22 ) ); - res = QgsDateRange::mergeRanges( {QgsDateRange( QDate( 2020, 1, 19 ), QDate( 2020, 1, 22 ) ), - QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) )} ); + res = QgsDateRange::mergeRanges( { QgsDateRange( QDate( 2020, 1, 19 ), QDate( 2020, 1, 22 ) ), QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ) } ); QCOMPARE( res.size(), 2 ); QCOMPARE( res.at( 0 ).begin(), QDate( 2020, 1, 10 ) ); QCOMPARE( res.at( 0 ).end(), QDate( 2020, 1, 15 ) ); QCOMPARE( res.at( 1 ).begin(), QDate( 2020, 1, 19 ) ); QCOMPARE( res.at( 1 ).end(), QDate( 2020, 1, 22 ) ); - res = QgsDateRange::mergeRanges( {QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ), - QgsDateRange( QDate( 2020, 1, 12 ), QDate( 2020, 1, 22 ) )} ); + res = QgsDateRange::mergeRanges( { QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ), QgsDateRange( QDate( 2020, 1, 12 ), QDate( 2020, 1, 22 ) ) } ); QCOMPARE( res.size(), 1 ); QCOMPARE( res.at( 0 ).begin(), QDate( 2020, 1, 10 ) ); QCOMPARE( res.at( 0 ).end(), QDate( 2020, 1, 22 ) ); - res = QgsDateRange::mergeRanges( {QgsDateRange( QDate( 2020, 1, 12 ), QDate( 2020, 1, 22 ) ), - QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) )} ); + res = QgsDateRange::mergeRanges( { QgsDateRange( QDate( 2020, 1, 12 ), QDate( 2020, 1, 22 ) ), QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ) } ); QCOMPARE( res.size(), 1 ); QCOMPARE( res.at( 0 ).begin(), QDate( 2020, 1, 10 ) ); QCOMPARE( res.at( 0 ).end(), QDate( 2020, 1, 22 ) ); - const QList< QgsDateRange > ranges { QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ), - QgsDateRange( QDate( 2020, 1, 20 ), QDate( 2020, 1, 25 ) ), - QgsDateRange( QDate( 2020, 1, 9 ), QDate( 2020, 1, 11 ) ), - QgsDateRange( QDate( 2020, 1, 19 ), QDate( 2020, 1, 27 ) ), - QgsDateRange( QDate( 2020, 1, 1 ), QDate( 2020, 1, 3 ) ) }; + const QList ranges { QgsDateRange( QDate( 2020, 1, 10 ), QDate( 2020, 1, 15 ) ), QgsDateRange( QDate( 2020, 1, 20 ), QDate( 2020, 1, 25 ) ), QgsDateRange( QDate( 2020, 1, 9 ), QDate( 2020, 1, 11 ) ), QgsDateRange( QDate( 2020, 1, 19 ), QDate( 2020, 1, 27 ) ), QgsDateRange( QDate( 2020, 1, 1 ), QDate( 2020, 1, 3 ) ) }; res = QgsDateRange::mergeRanges( ranges ); QCOMPARE( res.size(), 3 ); @@ -107,13 +96,9 @@ void TestQgsRange::testMergeRangesDate() void TestQgsRange::testMergeRangesDateTime() { - const QList< QgsDateTimeRange > ranges { QgsDateTimeRange( QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 15 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( QDateTime( QDate( 2020, 1, 20 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 25 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( QDateTime( QDate( 2020, 1, 9 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( QDateTime( QDate( 2020, 1, 19 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 27 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) }; + const QList ranges { QgsDateTimeRange( QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 15 ), QTime( 0, 0, 0 ) ) ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 20 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 25 ), QTime( 0, 0, 0 ) ) ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 9 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 19 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 27 ), QTime( 0, 0, 0 ) ) ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) }; - const QList< QgsDateTimeRange > res = QgsDateTimeRange::mergeRanges( ranges ); + const QList res = QgsDateTimeRange::mergeRanges( ranges ); QCOMPARE( res.size(), 3 ); QCOMPARE( res.at( 0 ).begin(), QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ); QCOMPARE( res.at( 0 ).end(), QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ); diff --git a/tests/src/core/testqgsrasterblock.cpp b/tests/src/core/testqgsrasterblock.cpp index c91e5ba73a25..f580786344c0 100644 --- a/tests/src/core/testqgsrasterblock.cpp +++ b/tests/src/core/testqgsrasterblock.cpp @@ -35,10 +35,10 @@ class TestQgsRasterBlock : public QgsTest {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testBasic(); void testWrite(); @@ -49,7 +49,6 @@ class TestQgsRasterBlock : public QgsTest void testMinimumMaximum(); private: - QString mTestDataDir; QgsRasterLayer *mpRasterLayer = nullptr; }; @@ -144,7 +143,7 @@ void TestQgsRasterBlock::testBasic() // data() const QByteArray data = block->data(); - QCOMPARE( data.count(), 100 ); // 10x10 raster with 1 byte/pixel + QCOMPARE( data.count(), 100 ); // 10x10 raster with 1 byte/pixel QCOMPARE( data.at( 0 ), ( char ) 2 ); QCOMPARE( data.at( 1 ), ( char ) 5 ); QCOMPARE( data.at( 10 ), ( char ) 27 ); @@ -167,8 +166,7 @@ void TestQgsRasterBlock::testWrite() int nCols = mpRasterLayer->width(), nRows = mpRasterLayer->height(); QVERIFY( nCols > 0 ); QVERIFY( nRows > 0 ); - double tform[] = - { + double tform[] = { extent.xMinimum(), extent.width() / nCols, 0.0, extent.yMaximum(), 0.0, -extent.height() / nRows }; @@ -185,7 +183,7 @@ void TestQgsRasterBlock::testWrite() QgsRasterBlock *block = mpRasterLayer->dataProvider()->block( 1, mpRasterLayer->extent(), mpRasterLayer->width(), mpRasterLayer->height() ); QByteArray origData = block->data(); - origData.detach(); // make sure we have private copy independent from independent block content + origData.detach(); // make sure we have private copy independent from independent block content QCOMPARE( origData.at( 0 ), ( char ) 2 ); QCOMPARE( origData.at( 1 ), ( char ) 5 ); @@ -250,17 +248,17 @@ void TestQgsRasterBlock::testWrite() delete block; } -void TestQgsRasterBlock::testPrintValueDouble_data( ) +void TestQgsRasterBlock::testPrintValueDouble_data() { - QTest::addColumn< double >( "value" ); - QTest::addColumn< bool >( "localized" ); - QTest::addColumn< QLocale::Language >( "language" ); - QTest::addColumn< QString >( "expected" ); + QTest::addColumn( "value" ); + QTest::addColumn( "localized" ); + QTest::addColumn( "language" ); + QTest::addColumn( "expected" ); QTest::newRow( "English double" ) << 123456.789 << true << QLocale::Language::English << QStringLiteral( "123,456.789" ); QTest::newRow( "English int" ) << 123456.0 << true << QLocale::Language::English << QStringLiteral( "123,456" ); - QTest::newRow( "English int no locale" ) << 123456.0 << false << QLocale::Language::English << QStringLiteral( "123456" ); - QTest::newRow( "English double no locale" ) << 123456.789 << false << QLocale::Language::English << QStringLiteral( "123456.789" ); + QTest::newRow( "English int no locale" ) << 123456.0 << false << QLocale::Language::English << QStringLiteral( "123456" ); + QTest::newRow( "English double no locale" ) << 123456.789 << false << QLocale::Language::English << QStringLiteral( "123456.789" ); QTest::newRow( "English negative double" ) << -123456.789 << true << QLocale::Language::English << QStringLiteral( "-123,456.789" ); QTest::newRow( "Italian double" ) << 123456.789 << true << QLocale::Language::Italian << QStringLiteral( "123.456,789" ); @@ -294,7 +292,7 @@ void TestQgsRasterBlock::testMinimumMaximum() const QgsRectangle fullExtent = rl.extent(); const int width = rl.width(); const int height = rl.height(); - std::unique_ptr< QgsRasterBlock > block( provider->block( 1, fullExtent, width, height ) ); + std::unique_ptr block( provider->block( 1, fullExtent, width, height ) ); QVERIFY( block ); QVERIFY( !block->hasNoData() ); @@ -370,12 +368,12 @@ void TestQgsRasterBlock::testMinimumMaximum() QCOMPARE( col2, 293 ); } -void TestQgsRasterBlock::testPrintValueFloat_data( ) +void TestQgsRasterBlock::testPrintValueFloat_data() { - QTest::addColumn< float >( "value" ); - QTest::addColumn< bool >( "localized" ); - QTest::addColumn< QLocale::Language >( "language" ); - QTest::addColumn< QString >( "expected" ); + QTest::addColumn( "value" ); + QTest::addColumn( "localized" ); + QTest::addColumn( "language" ); + QTest::addColumn( "expected" ); QTest::newRow( "English float" ) << 123456.789f << true << QLocale::Language::English << QStringLiteral( "123,456.79" ); QTest::newRow( "English int" ) << 123456.f << true << QLocale::Language::English << QStringLiteral( "123,456" ); diff --git a/tests/src/core/testqgsrastercontourrenderer.cpp b/tests/src/core/testqgsrastercontourrenderer.cpp index d3d5c4f7e3de..6b877a38d3e1 100644 --- a/tests/src/core/testqgsrastercontourrenderer.cpp +++ b/tests/src/core/testqgsrastercontourrenderer.cpp @@ -34,7 +34,8 @@ class TestQgsRasterContourRenderer : public QgsTest Q_OBJECT public: - TestQgsRasterContourRenderer() : QgsTest( QStringLiteral( "Raster Contour Renderer Tests" ) ) {} + TestQgsRasterContourRenderer() + : QgsTest( QStringLiteral( "Raster Contour Renderer Tests" ) ) {} private: QString mDataDir; @@ -42,10 +43,10 @@ class TestQgsRasterContourRenderer : public QgsTest QgsMapSettings *mMapSettings = nullptr; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void test_render(); void testRenderOpacity(); diff --git a/tests/src/core/testqgsrasterdataprovidertemporalcapabilities.cpp b/tests/src/core/testqgsrasterdataprovidertemporalcapabilities.cpp index 833547c72a47..89a6cdc3dbb6 100644 --- a/tests/src/core/testqgsrasterdataprovidertemporalcapabilities.cpp +++ b/tests/src/core/testqgsrasterdataprovidertemporalcapabilities.cpp @@ -33,10 +33,10 @@ class TestQgsRasterDataProviderTemporalCapabilities : public QObject TestQgsRasterDataProviderTemporalCapabilities() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void checkActiveStatus(); void checkTemporalRange(); @@ -54,7 +54,6 @@ void TestQgsRasterDataProviderTemporalCapabilities::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsRasterDataProviderTemporalCapabilities::init() @@ -84,12 +83,9 @@ void TestQgsRasterDataProviderTemporalCapabilities::checkActiveStatus() void TestQgsRasterDataProviderTemporalCapabilities::checkTemporalRange() { - const QgsDateTimeRange fixedDateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ); - const QgsDateTimeRange dateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ) ); - const QgsDateTimeRange outOfLimitsRange = QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2021, 3, 1 ), QTime( 0, 0, 0 ) ) ); + const QgsDateTimeRange fixedDateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ); + const QgsDateTimeRange dateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ) ); + const QgsDateTimeRange outOfLimitsRange = QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 3, 1 ), QTime( 0, 0, 0 ) ) ); temporalCapabilities->setAvailableTemporalRange( fixedDateTimeRange ); temporalCapabilities->setRequestedTemporalRange( dateTimeRange ); diff --git a/tests/src/core/testqgsrasterfilewriter.cpp b/tests/src/core/testqgsrasterfilewriter.cpp index 30c53301c88e..4bfd504ac3bb 100644 --- a/tests/src/core/testqgsrasterfilewriter.cpp +++ b/tests/src/core/testqgsrasterfilewriter.cpp @@ -39,24 +39,25 @@ * \ingroup UnitTests * This is a unit test for the QgsRasterFileWriter class. */ -class TestQgsRasterFileWriter: public QgsTest +class TestQgsRasterFileWriter : public QgsTest { Q_OBJECT public: - - TestQgsRasterFileWriter() : QgsTest( QStringLiteral( "Raster File Writer Tests" ) ) {} + TestQgsRasterFileWriter() + : QgsTest( QStringLiteral( "Raster File Writer Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void writeTest(); void testCreateOneBandRaster(); void testCreateMultiBandRaster(); void testVrtCreation(); + private: bool writeTest( const QString &rasterName ); @@ -92,7 +93,8 @@ void TestQgsRasterFileWriter::writeTest() for ( const QString &rasterName : rasterNames ) { const bool ok = writeTest( "raster/" + rasterName ); - if ( !ok ) allOK = false; + if ( !ok ) + allOK = false; } QVERIFY( allOK ); @@ -112,8 +114,7 @@ bool TestQgsRasterFileWriter::writeTest( const QString &rasterName ) return false; } - std::unique_ptr mpRasterLayer( new QgsRasterLayer( copiedSrc, - rasterFileInfo.completeBaseName() ) ); + std::unique_ptr mpRasterLayer( new QgsRasterLayer( copiedSrc, rasterFileInfo.completeBaseName() ) ); if ( !mpRasterLayer->isValid() ) return false; @@ -127,7 +128,7 @@ bool TestQgsRasterFileWriter::writeTest( const QString &rasterName ) mReport += "temporary output file: " + tmpName + "
    "; QgsRasterFileWriter fileWriter( tmpName ); - std::unique_ptr< QgsRasterPipe > pipe = std::make_unique< QgsRasterPipe >(); + std::unique_ptr pipe = std::make_unique(); if ( !pipe->set( provider->clone() ) ) { appendToReport( QStringLiteral( "Write test" ), QStringLiteral( "Cannot set pipe provider" ) ); @@ -188,7 +189,7 @@ void TestQgsRasterFileWriter::testCreateOneBandRaster() int width = 200, height = 100; QgsRasterFileWriter writer( filename ); - std::unique_ptr< QgsRasterDataProvider > dp( writer.createOneBandRaster( Qgis::DataType::Byte, width, height, extent, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ) ); + std::unique_ptr dp( writer.createOneBandRaster( Qgis::DataType::Byte, width, height, extent, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ) ); QVERIFY( dp ); QCOMPARE( dp->xSize(), width ); QCOMPARE( dp->ySize(), height ); @@ -198,7 +199,7 @@ void TestQgsRasterFileWriter::testCreateOneBandRaster() QVERIFY( dp->isEditable() ); dp.reset(); - std::unique_ptr< QgsRasterLayer > rlayer = std::make_unique< QgsRasterLayer >( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rlayer = std::make_unique( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); QVERIFY( rlayer->isValid() ); QCOMPARE( rlayer->width(), width ); QCOMPARE( rlayer->height(), height ); @@ -217,7 +218,7 @@ void TestQgsRasterFileWriter::testCreateMultiBandRaster() int width = 200, height = 100, nBands = 1; QgsRasterFileWriter writer( filename ); - std::unique_ptr< QgsRasterDataProvider > dp( writer.createMultiBandRaster( Qgis::DataType::Byte, width, height, extent, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), nBands ) ); + std::unique_ptr dp( writer.createMultiBandRaster( Qgis::DataType::Byte, width, height, extent, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), nBands ) ); QVERIFY( dp ); QCOMPARE( dp->xSize(), width ); QCOMPARE( dp->ySize(), height ); @@ -227,7 +228,7 @@ void TestQgsRasterFileWriter::testCreateMultiBandRaster() QVERIFY( dp->isEditable() ); dp.reset(); - std::unique_ptr< QgsRasterLayer > rlayer = std::make_unique< QgsRasterLayer >( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); + std::unique_ptr rlayer = std::make_unique( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); QVERIFY( rlayer->isValid() ); QCOMPARE( rlayer->width(), width ); QCOMPARE( rlayer->height(), height ); @@ -250,7 +251,7 @@ void TestQgsRasterFileWriter::testCreateMultiBandRaster() QVERIFY( dp->isEditable() ); dp.reset(); - rlayer = std::make_unique< QgsRasterLayer >( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); + rlayer = std::make_unique( filename, QStringLiteral( "tmp" ), QStringLiteral( "gdal" ) ); QVERIFY( rlayer->isValid() ); QCOMPARE( rlayer->width(), width ); QCOMPARE( rlayer->height(), height ); @@ -267,10 +268,10 @@ void TestQgsRasterFileWriter::testVrtCreation() //create a raster layer that will be used in all tests... const QString srcFileName = mTestDataDir + QStringLiteral( "ALLINGES_RGF93_CC46_1_1.tif" ); const QFileInfo rasterFileInfo( srcFileName ); - std::unique_ptr< QgsRasterLayer > srcRasterLayer = std::make_unique< QgsRasterLayer >( rasterFileInfo.absoluteFilePath(), rasterFileInfo.completeBaseName() ); + std::unique_ptr srcRasterLayer = std::make_unique( rasterFileInfo.absoluteFilePath(), rasterFileInfo.completeBaseName() ); const QTemporaryDir dir; - std::unique_ptr< QgsRasterFileWriter > rasterFileWriter = std::make_unique< QgsRasterFileWriter >( dir.path() + '/' + rasterFileInfo.completeBaseName() ); + std::unique_ptr rasterFileWriter = std::make_unique( dir.path() + '/' + rasterFileInfo.completeBaseName() ); //2. Definition of the pyramid levels QList levelList; @@ -292,11 +293,11 @@ void TestQgsRasterFileWriter::testVrtCreation() QgsRasterPipe pipe; pipe.set( srcRasterLayer->dataProvider()->clone() ); // Let's do it ! - const Qgis::RasterFileWriterResult res = rasterFileWriter->writeRaster( &pipe, srcRasterLayer->width(), srcRasterLayer->height(), srcRasterLayer->extent(), crs, srcRasterLayer->transformContext() ); + const Qgis::RasterFileWriterResult res = rasterFileWriter->writeRaster( &pipe, srcRasterLayer->width(), srcRasterLayer->height(), srcRasterLayer->extent(), crs, srcRasterLayer->transformContext() ); QCOMPARE( res, Qgis::RasterFileWriterResult::Success ); // Now let's compare the georef of the original raster with the georef of the generated vrt file - std::unique_ptr< QgsRasterLayer > vrtRasterLayer = std::make_unique< QgsRasterLayer >( dir.path() + '/' + rasterFileInfo.completeBaseName() + '/' + rasterFileInfo.completeBaseName() + QStringLiteral( ".vrt" ), rasterFileInfo.completeBaseName() ); + std::unique_ptr vrtRasterLayer = std::make_unique( dir.path() + '/' + rasterFileInfo.completeBaseName() + '/' + rasterFileInfo.completeBaseName() + QStringLiteral( ".vrt" ), rasterFileInfo.completeBaseName() ); const double xminVrt = vrtRasterLayer->extent().xMinimum(); const double yminVrt = vrtRasterLayer->extent().yMaximum(); diff --git a/tests/src/core/testqgsrasterfill.cpp b/tests/src/core/testqgsrasterfill.cpp index 78a4d809846a..c44a0836edd2 100644 --- a/tests/src/core/testqgsrasterfill.cpp +++ b/tests/src/core/testqgsrasterfill.cpp @@ -42,13 +42,14 @@ class TestQgsRasterFill : public QgsTest Q_OBJECT public: - TestQgsRasterFill() : QgsTest( QStringLiteral( "Raster Fill Renderer Tests" ), QStringLiteral( "symbol_rasterfill" ) ) {} + TestQgsRasterFill() + : QgsTest( QStringLiteral( "Raster Fill Renderer Tests" ), QStringLiteral( "symbol_rasterfill" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void rasterFillSymbol(); void coordinateMode(); @@ -88,8 +89,7 @@ void TestQgsRasterFill::initTestCase() // const QString myPolysFileName = testDataPath( "polys.shp" ); const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -97,7 +97,8 @@ void TestQgsRasterFill::initTestCase() // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPolysLayer ); + QList() << mpPolysLayer + ); //setup raster fill mRasterFill = new QgsRasterFillSymbolLayer(); @@ -131,7 +132,6 @@ void TestQgsRasterFill::init() void TestQgsRasterFill::cleanup() { - } void TestQgsRasterFill::rasterFillSymbol() @@ -146,8 +146,9 @@ void TestQgsRasterFill::coordinateMode() mMapSettings.setExtent( mpPolysLayer->extent() ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_viewport" ), QStringLiteral( "rasterfill_viewport" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_viewport" ), QStringLiteral( "rasterfill_viewport" ), + mMapSettings, 500, 20 + ); mRasterFill->setCoordinateMode( Qgis::SymbolCoordinateReference::Feature ); @@ -159,8 +160,9 @@ void TestQgsRasterFill::alpha() mRasterFill->setOpacity( 0.5 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_alpha" ), QStringLiteral( "rasterfill_alpha" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_alpha" ), QStringLiteral( "rasterfill_alpha" ), + mMapSettings, 500, 20 + ); mRasterFill->setOpacity( 1.0 ); @@ -172,8 +174,9 @@ void TestQgsRasterFill::offset() mRasterFill->setOffset( QPointF( 5, 10 ) ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_offset" ), QStringLiteral( "rasterfill_offset" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_offset" ), QStringLiteral( "rasterfill_offset" ), + mMapSettings, 500, 20 + ); mRasterFill->setOffset( QPointF() ); @@ -186,8 +189,9 @@ void TestQgsRasterFill::width() mRasterFill->setWidth( 5.0 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_width" ), QStringLiteral( "rasterfill_width" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_width" ), QStringLiteral( "rasterfill_width" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -203,8 +207,9 @@ void TestQgsRasterFill::widthAndHeight() mRasterFill->setHeight( 15.0 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_width_and_height" ), QStringLiteral( "rasterfill_width_and_height" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_width_and_height" ), QStringLiteral( "rasterfill_width_and_height" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -222,8 +227,9 @@ void TestQgsRasterFill::widthForHeight() mRasterFill->setHeight( 15.0 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_height" ), QStringLiteral( "rasterfill_height" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_height" ), QStringLiteral( "rasterfill_height" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -239,8 +245,9 @@ void TestQgsRasterFill::percentageHeight() mRasterFill->setHeight( 10 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_height_percentage" ), QStringLiteral( "rasterfill_height_percentage" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_height_percentage" ), QStringLiteral( "rasterfill_height_percentage" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -255,8 +262,9 @@ void TestQgsRasterFill::percentage() mRasterFill->setWidth( 6.3 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_percentage" ), QStringLiteral( "rasterfill_percentage" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_percentage" ), QStringLiteral( "rasterfill_percentage" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -271,8 +279,9 @@ void TestQgsRasterFill::percentageCoordinateMode() mRasterFill->setCoordinateMode( Qgis::SymbolCoordinateReference::Viewport ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_viewport_percentage" ), QStringLiteral( "rasterfill_viewport_percentage" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_viewport_percentage" ), QStringLiteral( "rasterfill_viewport_percentage" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -289,8 +298,9 @@ void TestQgsRasterFill::percentageOffset() mRasterFill->setOffset( QPointF( 12, 15 ) ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_offset_percentage" ), QStringLiteral( "rasterfill_offset_percentage" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_offset_percentage" ), QStringLiteral( "rasterfill_offset_percentage" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -307,8 +317,9 @@ void TestQgsRasterFill::percentageAlpha() mRasterFill->setOpacity( 0.5 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_alpha_percentage" ), QStringLiteral( "rasterfill_alpha_percentage" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_alpha_percentage" ), QStringLiteral( "rasterfill_alpha_percentage" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); @@ -323,8 +334,9 @@ void TestQgsRasterFill::percentageWidth() mRasterFill->setWidth( 3.3 ); const bool result = QGSRENDERMAPSETTINGSCHECK( - QStringLiteral( "rasterfill_width_percentage" ), QStringLiteral( "rasterfill_width_percentage" ), - mMapSettings, 500, 20 ); + QStringLiteral( "rasterfill_width_percentage" ), QStringLiteral( "rasterfill_width_percentage" ), + mMapSettings, 500, 20 + ); mRasterFill->setSizeUnit( Qgis::RenderUnit::Pixels ); mRasterFill->setWidth( 0 ); diff --git a/tests/src/core/testqgsrasteriterator.cpp b/tests/src/core/testqgsrasteriterator.cpp index 9d2f0f935a3d..8853ea40875e 100644 --- a/tests/src/core/testqgsrasteriterator.cpp +++ b/tests/src/core/testqgsrasteriterator.cpp @@ -33,10 +33,10 @@ class TestQgsRasterIterator : public QObject TestQgsRasterIterator() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testBasic(); void testNoBlock(); @@ -44,7 +44,6 @@ class TestQgsRasterIterator : public QObject void testPixelOverlap(); private: - QString mTestDataDir; QgsRasterLayer *mpRasterLayer = nullptr; }; @@ -99,7 +98,7 @@ void TestQgsRasterIterator::testBasic() int topLeftCol; int topLeftRow; QgsRectangle blockExtent; - std::unique_ptr< QgsRasterBlock > block; + std::unique_ptr block; QVERIFY( it.readNextRasterPart( 1, nCols, nRows, block, topLeftCol, topLeftRow, &blockExtent ) ); QGSCOMPARENEAR( it.progress( 1 ), 0.111, 0.001 ); @@ -165,7 +164,7 @@ void TestQgsRasterIterator::testBasic() QCOMPARE( block->width(), 3000 ); QCOMPARE( block->height(), 2500 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -181,7 +180,7 @@ void TestQgsRasterIterator::testBasic() QCOMPARE( block->width(), 3000 ); QCOMPARE( block->height(), 2500 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -195,7 +194,7 @@ void TestQgsRasterIterator::testBasic() QCOMPARE( block->width(), 1200 ); QCOMPARE( block->height(), 2500 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -211,7 +210,7 @@ void TestQgsRasterIterator::testBasic() QCOMPARE( block->width(), 3000 ); QCOMPARE( block->height(), 450 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -225,7 +224,7 @@ void TestQgsRasterIterator::testBasic() QCOMPARE( block->width(), 3000 ); QCOMPARE( block->height(), 450 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -241,7 +240,7 @@ void TestQgsRasterIterator::testBasic() QCOMPARE( block->width(), 1200 ); QCOMPARE( block->height(), 450 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -312,7 +311,7 @@ void TestQgsRasterIterator::testNoBlock() QCOMPARE( topLeftCol, 0 ); QCOMPARE( topLeftRow, 2500 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -322,7 +321,7 @@ void TestQgsRasterIterator::testNoBlock() QCOMPARE( topLeftCol, 3000 ); QCOMPARE( topLeftRow, 2500 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -332,7 +331,7 @@ void TestQgsRasterIterator::testNoBlock() QCOMPARE( topLeftCol, 6000 ); QCOMPARE( topLeftRow, 2500 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -342,7 +341,7 @@ void TestQgsRasterIterator::testNoBlock() QCOMPARE( topLeftCol, 0 ); QCOMPARE( topLeftRow, 5000 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -352,7 +351,7 @@ void TestQgsRasterIterator::testNoBlock() QCOMPARE( topLeftCol, 3000 ); QCOMPARE( topLeftRow, 5000 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -362,7 +361,7 @@ void TestQgsRasterIterator::testNoBlock() QCOMPARE( topLeftCol, 6000 ); QCOMPARE( topLeftRow, 5000 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -385,9 +384,7 @@ void TestQgsRasterIterator::testSubRegion() int subRectTop = 0; int subRectLeft = 0; // sub region is whole of raster extent - QgsRectangle subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), - QgsRectangle( 497470, 7050585, 498190, 7051130 ), - subRectWidth, subRectHeight, subRectLeft, subRectTop ); + QgsRectangle subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), QgsRectangle( 497470, 7050585, 498190, 7051130 ), subRectWidth, subRectHeight, subRectLeft, subRectTop ); QCOMPARE( subRect.xMinimum(), 497470 ); QCOMPARE( subRect.yMinimum(), 7050585 ); QCOMPARE( subRect.xMaximum(), 498190 ); @@ -398,9 +395,7 @@ void TestQgsRasterIterator::testSubRegion() QCOMPARE( subRectTop, 0 ); // sub region extends outside of raster extent, should be clipped back to raster extent - subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), - QgsRectangle( 497370, 7050385, 498390, 7051330 ), - subRectWidth, subRectHeight, subRectLeft, subRectTop ); + subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), QgsRectangle( 497370, 7050385, 498390, 7051330 ), subRectWidth, subRectHeight, subRectLeft, subRectTop ); QCOMPARE( subRect.xMinimum(), 497470 ); QCOMPARE( subRect.yMinimum(), 7050585 ); QCOMPARE( subRect.xMaximum(), 498190 ); @@ -411,9 +406,7 @@ void TestQgsRasterIterator::testSubRegion() QCOMPARE( subRectTop, 0 ); // sub rect inside raster extent - subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), - QgsRectangle( 497970.01, 7050985.05, 498030.95, 7051030.75 ), - subRectWidth, subRectHeight, subRectLeft, subRectTop ); + subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), QgsRectangle( 497970.01, 7050985.05, 498030.95, 7051030.75 ), subRectWidth, subRectHeight, subRectLeft, subRectTop ); QCOMPARE( subRect.xMinimum(), 497970 ); QCOMPARE( subRect.yMinimum(), 7050985.0 ); QCOMPARE( subRect.xMaximum(), 498031 ); @@ -425,9 +418,7 @@ void TestQgsRasterIterator::testSubRegion() QCOMPARE( subRectTop, 992 ); // sub rect JUST inside raster extent - subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), - QgsRectangle( 497370.001, 7050385.001, 498389.99999, 7051329.9999 ), - subRectWidth, subRectHeight, subRectLeft, subRectTop ); + subRect = QgsRasterIterator::subRegion( provider->extent(), provider->xSize(), provider->ySize(), QgsRectangle( 497370.001, 7050385.001, 498389.99999, 7051329.9999 ), subRectWidth, subRectHeight, subRectLeft, subRectTop ); QCOMPARE( subRect.xMinimum(), 497470 ); QCOMPARE( subRect.yMinimum(), 7050585 ); QCOMPARE( subRect.xMaximum(), 498190 ); @@ -436,7 +427,6 @@ void TestQgsRasterIterator::testSubRegion() QCOMPARE( subRectHeight, 5450 ); QCOMPARE( subRectLeft, 0 ); QCOMPARE( subRectTop, 0 ); - } void TestQgsRasterIterator::testPixelOverlap() @@ -465,7 +455,7 @@ void TestQgsRasterIterator::testPixelOverlap() int tileTopLeftRow; QgsRectangle blockExtent; - std::unique_ptr< QgsRasterBlock > block; + std::unique_ptr block; QVERIFY( it.readNextRasterPart( 1, nCols, nRows, block, topLeftCol, topLeftRow, &blockExtent, &tileCols, &tileRows, &tileTopLeftCol, &tileTopLeftRow ) ); QCOMPARE( nCols, 3020 ); @@ -543,7 +533,7 @@ void TestQgsRasterIterator::testPixelOverlap() QCOMPARE( block->width(), 3020 ); QCOMPARE( block->height(), 2540 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -562,7 +552,7 @@ void TestQgsRasterIterator::testPixelOverlap() QCOMPARE( block->width(), 3040 ); QCOMPARE( block->height(), 2540 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -579,7 +569,7 @@ void TestQgsRasterIterator::testPixelOverlap() QCOMPARE( block->width(), 1220 ); QCOMPARE( block->height(), 2540 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -598,7 +588,7 @@ void TestQgsRasterIterator::testPixelOverlap() QCOMPARE( block->width(), 3020 ); QCOMPARE( block->height(), 470 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -615,7 +605,7 @@ void TestQgsRasterIterator::testPixelOverlap() QCOMPARE( block->width(), 3040 ); QCOMPARE( block->height(), 470 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); @@ -634,7 +624,7 @@ void TestQgsRasterIterator::testPixelOverlap() QCOMPARE( block->width(), 1220 ); QCOMPARE( block->height(), 470 ); QCOMPARE( blockExtent.xMinimum(), mpRasterLayer->extent().xMinimum() + topLeftCol * mpRasterLayer->rasterUnitsPerPixelX() ); - QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow )* mpRasterLayer->rasterUnitsPerPixelY() ); + QCOMPARE( blockExtent.yMinimum(), mpRasterLayer->extent().yMaximum() - ( nRows + topLeftRow ) * mpRasterLayer->rasterUnitsPerPixelY() ); QCOMPARE( blockExtent.width(), nCols * mpRasterLayer->rasterUnitsPerPixelX() ); QCOMPARE( blockExtent.height(), nRows * mpRasterLayer->rasterUnitsPerPixelY() ); diff --git a/tests/src/core/testqgsrasterlayer.cpp b/tests/src/core/testqgsrasterlayer.cpp index 824c52c0e0e1..5a4b36bd2d63 100644 --- a/tests/src/core/testqgsrasterlayer.cpp +++ b/tests/src/core/testqgsrasterlayer.cpp @@ -60,17 +60,18 @@ class TestQgsRasterLayer : public QgsTest { Q_OBJECT public: - TestQgsRasterLayer() : QgsTest( QStringLiteral( "Raster Layer Tests" ) ) {} + TestQgsRasterLayer() + : QgsTest( QStringLiteral( "Raster Layer Tests" ) ) {} ~TestQgsRasterLayer() override { delete mMapSettings; } private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void isValid(); void isSpatial(); @@ -111,11 +112,8 @@ class TestQgsRasterLayer : public QgsTest private: bool render( const QString &fileName, int mismatchCount = 0 ); bool setQml( const QString &type, QString &msg ); - void populateColorRampShader( QgsColorRampShader *colorRampShader, - QgsColorRamp *colorRamp, - int numberOfEntries ); - bool testColorRamp( const QString &name, QgsColorRamp *colorRamp, - Qgis::ShaderInterpolationMethod type, int numberOfEntries ); + void populateColorRampShader( QgsColorRampShader *colorRampShader, QgsColorRamp *colorRamp, int numberOfEntries ); + bool testColorRamp( const QString &name, QgsColorRamp *colorRamp, Qgis::ShaderInterpolationMethod type, int numberOfEntries ); QString mTestDataDir; QgsRasterLayer *mpRasterLayer = nullptr; QgsRasterLayer *mpLandsatRasterLayer = nullptr; @@ -152,41 +150,36 @@ void TestQgsRasterLayer::initTestCase() const QString geoJp2RasterFileName = mTestDataDir + "rgbwcmyk01_YeGeo.jp2"; const QFileInfo myRasterFileInfo( myFileName ); - mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), - myRasterFileInfo.completeBaseName() ); + mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); // qDebug() << "tenbyteraster metadata: " << mpRasterLayer->dataProvider()->htmlMetadata(); const QFileInfo myLandsatRasterFileInfo( myLandsatFileName ); - mpLandsatRasterLayer = new QgsRasterLayer( myLandsatRasterFileInfo.filePath(), - myLandsatRasterFileInfo.completeBaseName() ); + mpLandsatRasterLayer = new QgsRasterLayer( myLandsatRasterFileInfo.filePath(), myLandsatRasterFileInfo.completeBaseName() ); // qDebug() << "landsat metadata: " << mpLandsatRasterLayer->dataProvider()->htmlMetadata(); const QFileInfo myFloat32RasterFileInfo( myFloat32FileName ); - mpFloat32RasterLayer = new QgsRasterLayer( myFloat32RasterFileInfo.filePath(), - myFloat32RasterFileInfo.completeBaseName() ); + mpFloat32RasterLayer = new QgsRasterLayer( myFloat32RasterFileInfo.filePath(), myFloat32RasterFileInfo.completeBaseName() ); // qDebug() << "float32raster metadata: " << mpFloat32RasterLayer->dataProvider()->htmlMetadata(); const QFileInfo pngRasterFileInfo( pngRasterFileName ); - mPngRasterLayer = new QgsRasterLayer( pngRasterFileInfo.filePath(), - pngRasterFileInfo.completeBaseName() ); + mPngRasterLayer = new QgsRasterLayer( pngRasterFileInfo.filePath(), pngRasterFileInfo.completeBaseName() ); const QFileInfo geoJp2RasterFileInfo( geoJp2RasterFileName ); - mGeoJp2RasterLayer = new QgsRasterLayer( geoJp2RasterFileInfo.filePath(), - geoJp2RasterFileInfo.completeBaseName() ); + mGeoJp2RasterLayer = new QgsRasterLayer( geoJp2RasterFileInfo.filePath(), geoJp2RasterFileInfo.completeBaseName() ); // Register the layer with the registry QgsProject::instance()->addMapLayers( QList() << mpRasterLayer - << mpLandsatRasterLayer - << mpFloat32RasterLayer - << mPngRasterLayer - << mGeoJp2RasterLayer ); + << mpLandsatRasterLayer + << mpFloat32RasterLayer + << mPngRasterLayer + << mGeoJp2RasterLayer + ); // add the test layer to the maprender mMapSettings->setLayers( QList() << mpRasterLayer ); mTemporalRasterLayer = new QgsRasterLayer(); - } //runs after all tests void TestQgsRasterLayer::cleanupTestCase() @@ -240,9 +233,7 @@ void TestQgsRasterLayer::pseudoColor() QVERIFY( render( "raster_pseudo" ) ); } -void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader *colorRampShader, - QgsColorRamp *colorRamp, - int numberOfEntries ) +void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader *colorRampShader, QgsColorRamp *colorRamp, int numberOfEntries ) { // adapted from QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked() @@ -259,8 +250,7 @@ void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader *colorRampS { //because the highest value is also an entry, there are (numberOfEntries - 1) //intervals - intervalDiff = ( myRasterBandStats.maximumValue - myRasterBandStats.minimumValue ) / - ( numberOfEntries - 1 ); + intervalDiff = ( myRasterBandStats.maximumValue - myRasterBandStats.minimumValue ) / ( numberOfEntries - 1 ); } else { @@ -285,8 +275,7 @@ void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader *colorRampS colorRampShader->setColorRampItemList( colorRampItems ); } -bool TestQgsRasterLayer::testColorRamp( const QString &name, QgsColorRamp *colorRamp, - Qgis::ShaderInterpolationMethod type, int numberOfEntries ) +bool TestQgsRasterLayer::testColorRamp( const QString &name, QgsColorRamp *colorRamp, Qgis::ShaderInterpolationMethod type, int numberOfEntries ) { QgsRasterShader *rasterShader = new QgsRasterShader(); QgsColorRampShader *colorRampShader = new QgsColorRampShader(); @@ -318,9 +307,7 @@ void TestQgsRasterLayer::colorRamp2() { QgsColorBrewerColorRamp ramp( QStringLiteral( "BrBG" ), 10 ); // ColorBrewer ramp - QVERIFY( testColorRamp( "raster_colorRamp2", - &ramp, - Qgis::ShaderInterpolationMethod::Discrete, 10 ) ); + QVERIFY( testColorRamp( "raster_colorRamp2", &ramp, Qgis::ShaderInterpolationMethod::Discrete, 10 ) ); } void TestQgsRasterLayer::colorRamp3() @@ -328,9 +315,7 @@ void TestQgsRasterLayer::colorRamp3() // cpt-city ramp, discrete QgsCptCityArchive::initArchives(); QgsCptCityColorRamp ramp( QStringLiteral( "cb/div/BrBG" ), QStringLiteral( "_10" ) ); - QVERIFY( testColorRamp( "raster_colorRamp3", - &ramp, - Qgis::ShaderInterpolationMethod::Discrete, 10 ) ); + QVERIFY( testColorRamp( "raster_colorRamp3", &ramp, Qgis::ShaderInterpolationMethod::Discrete, 10 ) ); QgsCptCityArchive::clearArchives(); } @@ -338,9 +323,7 @@ void TestQgsRasterLayer::colorRamp4() { // cpt-city ramp, continuous QgsCptCityColorRamp ramp( QStringLiteral( "grass/elevation" ), QString() ); - QVERIFY( testColorRamp( "raster_colorRamp4", - &ramp, - Qgis::ShaderInterpolationMethod::Discrete, 10 ) ); + QVERIFY( testColorRamp( "raster_colorRamp4", &ramp, Qgis::ShaderInterpolationMethod::Discrete, 10 ) ); } void TestQgsRasterLayer::landsatBasic() @@ -375,9 +358,7 @@ void TestQgsRasterLayer::checkDimensions() } void TestQgsRasterLayer::checkStats() { - QgsRasterBandStats myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, - Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | - Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev ); + QgsRasterBandStats myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev ); QCOMPARE( mpRasterLayer->width(), 10 ); QCOMPARE( mpRasterLayer->height(), 10 ); //QCOMPARE( myStatistics.elementCount, 100 ); @@ -389,9 +370,7 @@ void TestQgsRasterLayer::checkStats() QGSCOMPARENEAR( myStatistics.stdDev, stdDev, 0.000001 ); // limited extent - myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, - Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | - Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535450, 5083320 ) ); + myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535450, 5083320 ) ); QCOMPARE( myStatistics.minimumValue, 2.0 ); QCOMPARE( myStatistics.maximumValue, 7.0 ); @@ -399,9 +378,7 @@ void TestQgsRasterLayer::checkStats() QGSCOMPARENEAR( myStatistics.stdDev, 1.507557, 0.00001 ); // with sample size - myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, - Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | - Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535450, 5083320 ), 10 ); + myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535450, 5083320 ), 10 ); QCOMPARE( myStatistics.minimumValue, 2.0 ); QCOMPARE( myStatistics.maximumValue, 7.0 ); QCOMPARE( myStatistics.elementCount, 12ULL ); @@ -409,18 +386,14 @@ void TestQgsRasterLayer::checkStats() QGSCOMPARENEAR( myStatistics.stdDev, 2.153222, 0.00001 ); // extremely limited extent - ~1 px size - myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, - Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | - Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535412, 5083288 ) ); + myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535412, 5083288 ) ); QCOMPARE( myStatistics.minimumValue, 2.0 ); QCOMPARE( myStatistics.maximumValue, 3.0 ); QGSCOMPARENEAR( myStatistics.mean, 2.600000, 4 * std::numeric_limits::epsilon() ); QGSCOMPARENEAR( myStatistics.stdDev, 0.492366, 0.00001 ); // extremely limited extent - ~1 px size - with sample size - myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, - Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | - Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535412, 5083288 ), 6 ); + myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev, QgsRectangle( 1535400, 5083280, 1535412, 5083288 ), 6 ); QCOMPARE( myStatistics.minimumValue, 2.0 ); QCOMPARE( myStatistics.maximumValue, 3.0 ); QCOMPARE( myStatistics.elementCount, 2ULL ); @@ -433,11 +406,10 @@ void TestQgsRasterLayer::checkStats() void TestQgsRasterLayer::checkScaleOffset() { const QFileInfo myRasterFileInfo( mTestDataDir + "scaleoffset.tif" ); - std::unique_ptr< QgsRasterLayer > myRasterLayer; - myRasterLayer = std::make_unique< QgsRasterLayer >( myRasterFileInfo.filePath(), - myRasterFileInfo.completeBaseName() ); + std::unique_ptr myRasterLayer; + myRasterLayer = std::make_unique( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); QVERIFY( myRasterLayer ); - if ( ! myRasterLayer->isValid() ) + if ( !myRasterLayer->isValid() ) { qDebug() << QStringLiteral( "raster layer %1 invalid" ).arg( myRasterFileInfo.filePath() ); QVERIFY( false ); @@ -445,9 +417,7 @@ void TestQgsRasterLayer::checkScaleOffset() } QFile::remove( myRasterFileInfo.filePath() + ".aux.xml" ); // remove cached stats - const QgsRasterBandStats myStatistics = myRasterLayer->dataProvider()->bandStatistics( 1, - Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | - Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev ); + const QgsRasterBandStats myStatistics = myRasterLayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max | Qgis::RasterBandStatistic::Mean | Qgis::RasterBandStatistic::StdDev ); const QString oldReport = mReport; @@ -520,8 +490,7 @@ void TestQgsRasterLayer::buildExternalOverviews() QFile::remove( myTempPath + "landsat.tif" ); QVERIFY( QFile::copy( mTestDataDir + "landsat.tif", myTempPath + "landsat.tif" ) ); const QFileInfo myRasterFileInfo( myTempPath + "landsat.tif" ); - QgsRasterLayer *mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), - myRasterFileInfo.completeBaseName() ); + QgsRasterLayer *mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); QVERIFY( mypLayer->isValid() ); @@ -530,15 +499,14 @@ void TestQgsRasterLayer::buildExternalOverviews() // const Qgis::RasterPyramidFormat myFormatFlag = Qgis::RasterPyramidFormat::GeoTiff; - QList< QgsRasterPyramid > myPyramidList = mypLayer->dataProvider()->buildPyramidList(); + QList myPyramidList = mypLayer->dataProvider()->buildPyramidList(); for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ ) { //mark to be pyramided myPyramidList[myCounterInt].setBuild( true ); } //now actually make the pyramids - QString myResult = - mypLayer->dataProvider()->buildPyramids( myPyramidList, QStringLiteral( "NEAREST" ), myFormatFlag ); + QString myResult = mypLayer->dataProvider()->buildPyramids( myPyramidList, QStringLiteral( "NEAREST" ), myFormatFlag ); qDebug( "%s", myResult.toLocal8Bit().constData() ); QVERIFY( myResult.isEmpty() ); // @@ -560,8 +528,7 @@ void TestQgsRasterLayer::buildExternalOverviews() delete mypLayer; QFile::remove( myTempPath + "landsat.tif.ovr" ); - mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), - myRasterFileInfo.completeBaseName() ); + mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); myPyramidList = mypLayer->dataProvider()->buildPyramidList(); for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ ) { @@ -574,8 +541,7 @@ void TestQgsRasterLayer::buildExternalOverviews() optionList << QStringLiteral( "COMPRESS_OVERVIEW=DEFLATE" ); optionList << QStringLiteral( "invalid" ); - myResult = - mypLayer->dataProvider()->buildPyramids( myPyramidList, QStringLiteral( "NEAREST" ), myFormatFlag, optionList ); + myResult = mypLayer->dataProvider()->buildPyramids( myPyramidList, QStringLiteral( "NEAREST" ), myFormatFlag, optionList ); qDebug( "%s", myResult.toLocal8Bit().constData() ); QVERIFY( myResult.isEmpty() ); QVERIFY( QFile::exists( myTempPath + "landsat.tif.ovr" ) ); @@ -600,14 +566,15 @@ void TestQgsRasterLayer::registry() QFile::remove( myTempPath + "landsat.tif" ); QVERIFY( QFile::copy( mTestDataDir + "landsat.tif", myTempPath + "landsat.tif" ) ); const QFileInfo myRasterFileInfo( myTempPath + "landsat.tif" ); - QgsRasterLayer *mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), - myRasterFileInfo.completeBaseName() ); + QgsRasterLayer *mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); QVERIFY( mypLayer->isValid() ); QgsProject::instance()->addMapLayers( - QList() << mypLayer, false ); + QList() << mypLayer, false + ); QgsProject::instance()->removeMapLayers( - QStringList() << mypLayer->id() ); + QStringList() << mypLayer->id() + ); } // @@ -648,7 +615,6 @@ bool TestQgsRasterLayer::setQml( const QString &type, QString &msg ) void TestQgsRasterLayer::transparency() { - QVERIFY( mpFloat32RasterLayer->isValid() ); QgsSingleBandGrayRenderer *renderer = new QgsSingleBandGrayRenderer( mpRasterLayer->dataProvider(), 1 ); mpFloat32RasterLayer->setRenderer( renderer ); @@ -717,13 +683,10 @@ void TestQgsRasterLayer::multiBandColorRendererNoDataColor() void TestQgsRasterLayer::palettedRendererNoData() { const QString rasterFileName = mTestDataDir + "raster/with_color_table.tif"; - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( rasterFileName, - QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); - std::unique_ptr< QgsPalettedRasterRenderer > rasterRenderer = std::make_unique< QgsPalettedRasterRenderer >( rl->dataProvider(), 1, QList< QgsPalettedRasterRenderer::Class >() - << QgsPalettedRasterRenderer::Class( 1, QColor( 0, 255, 0 ), QStringLiteral( "class 2" ) ) - << QgsPalettedRasterRenderer::Class( 3, QColor( 255, 0, 0 ), QStringLiteral( "class 1" ) ) ); + std::unique_ptr rasterRenderer = std::make_unique( rl->dataProvider(), 1, QList() << QgsPalettedRasterRenderer::Class( 1, QColor( 0, 255, 0 ), QStringLiteral( "class 2" ) ) << QgsPalettedRasterRenderer::Class( 3, QColor( 255, 0, 0 ), QStringLiteral( "class 1" ) ) ); QVERIFY( rl->dataProvider()->setNoDataValue( 1, 2 ) ); rl->setRenderer( rasterRenderer.release() ); mMapSettings->setLayers( QList() << rl.get() ); @@ -735,8 +698,7 @@ void TestQgsRasterLayer::palettedRendererNoData() void TestQgsRasterLayer::palettedRendererRasterAttributeTable() { const QString rasterFileName = mTestDataDir + "raster/band1_byte_attribute_table_epsg4326.tif"; - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( rasterFileName, - QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); QVERIFY( rl->dataProvider()->setNoDataValue( 1, 9999 ) ); mMapSettings->setLayers( QList() << rl.get() ); @@ -753,9 +715,9 @@ void TestQgsRasterLayer::palettedRendererRasterAttributeTable() QgsPalettedRasterRenderer::MultiValueClass testClass = multiValueclasses.at( 0 ); QCOMPARE( testClass.label, QStringLiteral( "2" ) ); QCOMPARE( testClass.values.size(), 3 ); - QCOMPARE( testClass.values.at( 0 ).toDouble( ), 2.0 ); - QCOMPARE( testClass.values.at( 1 ).toDouble( ), 246.0 ); - QCOMPARE( testClass.values.at( 2 ).toDouble( ), 254.0 ); + QCOMPARE( testClass.values.at( 0 ).toDouble(), 2.0 ); + QCOMPARE( testClass.values.at( 1 ).toDouble(), 246.0 ); + QCOMPARE( testClass.values.at( 2 ).toDouble(), 254.0 ); // Test legacy classes QgsPalettedRasterRenderer::ClassData legacyClasses { rasterRenderer->classes() }; @@ -764,8 +726,8 @@ void TestQgsRasterLayer::palettedRendererRasterAttributeTable() // Make sure the actual grouped values are returned as individual entries struct Klass { - QString label; - QString color; + QString label; + QString color; }; QMap classMap; @@ -778,25 +740,21 @@ void TestQgsRasterLayer::palettedRendererRasterAttributeTable() QVERIFY( classMap.contains( 246.0 ) ); QVERIFY( classMap.contains( 254.0 ) ); - QCOMPARE( classMap.value( 2.0 ).label, QStringLiteral( "2" ) ); - QCOMPARE( classMap.value( 246.0 ).label, classMap.value( 2.0 ).label ); - QCOMPARE( classMap.value( 254.0 ).label, classMap.value( 2.0 ).label ); + QCOMPARE( classMap.value( 2.0 ).label, QStringLiteral( "2" ) ); + QCOMPARE( classMap.value( 246.0 ).label, classMap.value( 2.0 ).label ); + QCOMPARE( classMap.value( 254.0 ).label, classMap.value( 2.0 ).label ); QCOMPARE( classMap.value( 246.0 ).color, classMap.value( 2.0 ).color ); QCOMPARE( classMap.value( 254.0 ).color, classMap.value( 2.0 ).color ); - } void TestQgsRasterLayer::palettedRendererNoDataColor() { const QString rasterFileName = mTestDataDir + "raster/with_color_table.tif"; - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( rasterFileName, - QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); - QgsPalettedRasterRenderer *rasterRenderer = new QgsPalettedRasterRenderer( rl->dataProvider(), 1, QList< QgsPalettedRasterRenderer::Class >() - << QgsPalettedRasterRenderer::Class( 1, QColor( 0, 255, 0 ), QStringLiteral( "class 2" ) ) - << QgsPalettedRasterRenderer::Class( 3, QColor( 255, 0, 0 ), QStringLiteral( "class 1" ) ) ); + QgsPalettedRasterRenderer *rasterRenderer = new QgsPalettedRasterRenderer( rl->dataProvider(), 1, QList() << QgsPalettedRasterRenderer::Class( 1, QColor( 0, 255, 0 ), QStringLiteral( "class 2" ) ) << QgsPalettedRasterRenderer::Class( 3, QColor( 255, 0, 0 ), QStringLiteral( "class 1" ) ) ); rasterRenderer->setNodataColor( QColor( 255, 0, 255 ) ); rl->dataProvider()->setNoDataValue( 1, 2 ); rl->setRenderer( rasterRenderer ); @@ -816,12 +774,12 @@ void TestQgsRasterLayer::palettedRendererConstantInt() Q_ASSERT( hDS ); GDALFillRaster( GDALGetRasterBand( hDS, 1 ), value, 0 ); GDALClose( hDS ); - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( QString( tempFileName ), QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( QString( tempFileName ), QStringLiteral( "rl" ) ); Q_ASSERT( rl->isValid() ); const auto classData { QgsPalettedRasterRenderer::classDataFromRaster( rl->dataProvider(), 1 ) }; QCOMPARE( classData.size(), 1 ); QCOMPARE( classData.first().value, value ); - rl.reset( ); + rl.reset(); VSIUnlink( tempFileName ); } @@ -832,11 +790,10 @@ void TestQgsRasterLayer::singleBandGrayRendererNoData() QFile::copy( mTestDataDir + "landsat.tif", tmpDir.filePath( QStringLiteral( "landsat.tif" ) ) ); const QString rasterFileName = tmpDir.filePath( QStringLiteral( "landsat.tif" ) ); - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( rasterFileName, - QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); - std::unique_ptr< QgsSingleBandGrayRenderer > rasterRenderer = std::make_unique< QgsSingleBandGrayRenderer >( rl->dataProvider(), 1 ); + std::unique_ptr rasterRenderer = std::make_unique( rl->dataProvider(), 1 ); QVERIFY( rl->dataProvider()->setNoDataValue( 1, 126 ) ); rl->setRenderer( rasterRenderer.release() ); mMapSettings->setLayers( QList() << rl.get() ); @@ -852,11 +809,10 @@ void TestQgsRasterLayer::singleBandGrayRendererNoDataColor() QFile::copy( mTestDataDir + "landsat.tif", tmpDir.filePath( QStringLiteral( "landsat.tif" ) ) ); const QString rasterFileName = tmpDir.filePath( QStringLiteral( "landsat.tif" ) ); - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( rasterFileName, - QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); - std::unique_ptr< QgsSingleBandGrayRenderer > rasterRenderer = std::make_unique< QgsSingleBandGrayRenderer >( rl->dataProvider(), 1 ); + std::unique_ptr rasterRenderer = std::make_unique( rl->dataProvider(), 1 ); QVERIFY( rl->dataProvider()->setNoDataValue( 1, 126 ) ); rasterRenderer->setNodataColor( QColor( 255, 0, 255 ) ); rl->setRenderer( rasterRenderer.release() ); @@ -873,8 +829,7 @@ void TestQgsRasterLayer::singleBandPseudoRendererNoData() QFile::copy( mTestDataDir + "landsat.tif", tmpDir.filePath( QStringLiteral( "landsat.tif" ) ) ); const QString rasterFileName = tmpDir.filePath( QStringLiteral( "landsat.tif" ) ); - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( rasterFileName, - QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); QgsRasterShader *rasterShader = new QgsRasterShader(); @@ -903,7 +858,7 @@ void TestQgsRasterLayer::singleBandPseudoRendererNoData() colorRampShader->setColorRampItemList( colorRampItems ); rasterShader->setRasterShaderFunction( colorRampShader ); - std::unique_ptr< QgsSingleBandPseudoColorRenderer > rasterRenderer = std::make_unique< QgsSingleBandPseudoColorRenderer >( rl->dataProvider(), 1, rasterShader ); + std::unique_ptr rasterRenderer = std::make_unique( rl->dataProvider(), 1, rasterShader ); QVERIFY( rl->dataProvider()->setNoDataValue( 1, 126 ) ); rl->setRenderer( rasterRenderer.release() ); mMapSettings->setLayers( QList() << rl.get() ); @@ -919,8 +874,7 @@ void TestQgsRasterLayer::singleBandPseudoRendererNoDataColor() QFile::copy( mTestDataDir + "landsat.tif", tmpDir.filePath( QStringLiteral( "landsat.tif" ) ) ); const QString rasterFileName = tmpDir.filePath( QStringLiteral( "landsat.tif" ) ); - std::unique_ptr< QgsRasterLayer> rl = std::make_unique< QgsRasterLayer >( rasterFileName, - QStringLiteral( "rl" ) ); + std::unique_ptr rl = std::make_unique( rasterFileName, QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); QgsRasterShader *rasterShader = new QgsRasterShader(); @@ -949,7 +903,7 @@ void TestQgsRasterLayer::singleBandPseudoRendererNoDataColor() colorRampShader->setColorRampItemList( colorRampItems ); rasterShader->setRasterShaderFunction( colorRampShader ); - std::unique_ptr< QgsSingleBandPseudoColorRenderer > rasterRenderer = std::make_unique< QgsSingleBandPseudoColorRenderer >( rl->dataProvider(), 1, rasterShader ); + std::unique_ptr rasterRenderer = std::make_unique( rl->dataProvider(), 1, rasterShader ); QVERIFY( rl->dataProvider()->setNoDataValue( 1, 126 ) ); rasterRenderer->setNodataColor( QColor( 255, 0, 255 ) ); rl->setRenderer( rasterRenderer.release() ); @@ -990,7 +944,7 @@ void TestQgsRasterLayer::setLayerOpacity() void TestQgsRasterLayer::regression992() { - if ( ! mGeoJp2RasterLayer->isValid() ) + if ( !mGeoJp2RasterLayer->isValid() ) { QSKIP( "This test requires the JPEG2000 GDAL driver", SkipAll ); } @@ -1033,9 +987,7 @@ void TestQgsRasterLayer::testRefreshRendererIfNeeded() { double min; double max; - mpLandsatRasterLayer->computeMinMax( bandIdx, mmo, mmo.limits(), - newExtent, static_cast( QgsRasterLayer::SAMPLE_SIZE ), - min, max ); + mpLandsatRasterLayer->computeMinMax( bandIdx, mmo, mmo.limits(), newExtent, static_cast( QgsRasterLayer::SAMPLE_SIZE ), min, max ); minValues.append( min ); maxValues.append( max ); } @@ -1069,8 +1021,7 @@ void TestQgsRasterLayer::sample() QString fileName = mTestDataDir + "landsat-f32-b1.tif"; QFileInfo rasterFileInfo( fileName ); - std::unique_ptr< QgsRasterLayer > rl = std::make_unique< QgsRasterLayer> ( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + std::unique_ptr rl = std::make_unique( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QVERIFY( rl->isValid() ); QVERIFY( std::isnan( rl->dataProvider()->sample( QgsPointXY( 0, 0 ), 1 ) ) ); bool ok = false; @@ -1092,8 +1043,7 @@ void TestQgsRasterLayer::sample() fileName = tmpDir.filePath( QStringLiteral( "landsat_4326.tif" ) ); rasterFileInfo = QFileInfo( fileName ); - rl = std::make_unique< QgsRasterLayer> ( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + rl = std::make_unique( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QVERIFY( rl->isValid() ); QVERIFY( std::isnan( rl->dataProvider()->sample( QgsPointXY( 0, 0 ), 1 ) ) ); QVERIFY( std::isnan( rl->dataProvider()->sample( QgsPointXY( 0, 0 ), 1, &ok ) ) ); @@ -1118,11 +1068,10 @@ void TestQgsRasterLayer::sample() void TestQgsRasterLayer::testTemporalProperties() { - QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast< QgsRasterLayerTemporalProperties * >( mTemporalRasterLayer->temporalProperties() ); + QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast( mTemporalRasterLayer->temporalProperties() ); QVERIFY( !mTemporalRasterLayer->temporalProperties()->isActive() ); - const QgsDateTimeRange dateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ); + const QgsDateTimeRange dateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ); temporalProperties->setFixedTemporalRange( dateTimeRange ); @@ -1153,15 +1102,13 @@ void TestQgsRasterLayer::rotatedRaster() { mMapSettings->setExtent( QgsRectangle( 994, 922, 1174, 1102 ) ); - std::unique_ptr< QgsRasterLayer> rgb = std::make_unique< QgsRasterLayer >( mTestDataDir + "raster/rotated_rgb.png", - QStringLiteral( "rgb" ) ); + std::unique_ptr rgb = std::make_unique( mTestDataDir + "raster/rotated_rgb.png", QStringLiteral( "rgb" ) ); QVERIFY( rgb->isValid() ); mMapSettings->setLayers( QList() << rgb.get() ); QVERIFY( render( QStringLiteral( "raster_rotated_rgb" ) ) ); - std::unique_ptr< QgsRasterLayer> rgba = std::make_unique< QgsRasterLayer >( mTestDataDir + "raster/rotated_rgba.png", - QStringLiteral( "rgba" ) ); + std::unique_ptr rgba = std::make_unique( mTestDataDir + "raster/rotated_rgba.png", QStringLiteral( "rgba" ) ); QVERIFY( rgba->isValid() ); mMapSettings->setLayers( QList() << rgba.get() ); @@ -1173,12 +1120,12 @@ void TestQgsRasterLayer::forceRasterRender() QVERIFY2( mpLandsatRasterLayer->isValid(), "landsat.tif layer is not valid!" ); mMapSettings->setDestinationCrs( mpLandsatRasterLayer->crs() ); - mMapSettings->setExtent( QgsRectangle( 10, 10, 11, 11 ) ); // outside of layer extent + mMapSettings->setExtent( QgsRectangle( 10, 10, 11, 11 ) ); // outside of layer extent mMapSettings->setLayers( QList() << mpLandsatRasterLayer ); QgsRenderContext context( QgsRenderContext::fromMapSettings( *mMapSettings ) ); std::unique_ptr layerRenderer( mpLandsatRasterLayer->createMapRenderer( context ) ); - layerRenderer->forceRasterRender(); // this should not crash + layerRenderer->forceRasterRender(); // this should not crash } QGSTEST_MAIN( TestQgsRasterLayer ) diff --git a/tests/src/core/testqgsrasterlayertemporalproperties.cpp b/tests/src/core/testqgsrasterlayertemporalproperties.cpp index 3d048a5ed38b..05b64f7d639d 100644 --- a/tests/src/core/testqgsrasterlayertemporalproperties.cpp +++ b/tests/src/core/testqgsrasterlayertemporalproperties.cpp @@ -33,15 +33,14 @@ class TestQgsRasterLayerTemporalProperties : public QObject TestQgsRasterLayerTemporalProperties() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void checkSettingTemporalRange(); void testReadWrite(); void testVisibleInTimeRange(); - }; void TestQgsRasterLayerTemporalProperties::initTestCase() @@ -53,7 +52,6 @@ void TestQgsRasterLayerTemporalProperties::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsRasterLayerTemporalProperties::init() @@ -72,8 +70,7 @@ void TestQgsRasterLayerTemporalProperties::cleanupTestCase() void TestQgsRasterLayerTemporalProperties::checkSettingTemporalRange() { QgsRasterLayerTemporalProperties temporalProperties; - const QgsDateTimeRange dateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ); + const QgsDateTimeRange dateTimeRange = QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ); temporalProperties.setFixedTemporalRange( dateTimeRange ); @@ -85,9 +82,9 @@ void TestQgsRasterLayerTemporalProperties::testReadWrite() QgsRasterLayerTemporalProperties temporalProperties; QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement node = doc.createElement( QStringLiteral( "temp" ) ); @@ -119,17 +116,14 @@ void TestQgsRasterLayerTemporalProperties::testReadWrite() QCOMPARE( temporalProperties3.intervalHandlingMethod(), Qgis::TemporalIntervalMatchMethod::MatchExactUsingEndOfRange ); temporalProperties.setMode( Qgis::RasterTemporalMode::FixedTemporalRange ); - temporalProperties.setFixedTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ) ); + temporalProperties.setFixedTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ) ); QDomElement node3 = doc.createElement( QStringLiteral( "temp" ) ); temporalProperties.writeXml( node3, doc, QgsReadWriteContext() ); QgsRasterLayerTemporalProperties temporalProperties4; temporalProperties4.readXml( node3, QgsReadWriteContext() ); QVERIFY( !temporalProperties4.isActive() ); QCOMPARE( temporalProperties4.mode(), Qgis::RasterTemporalMode::FixedTemporalRange ); - QCOMPARE( temporalProperties4.fixedTemporalRange(), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ) ); - + QCOMPARE( temporalProperties4.fixedTemporalRange(), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 12, 31 ), QTime( 0, 0, 0 ) ) ) ); } void TestQgsRasterLayerTemporalProperties::testVisibleInTimeRange() @@ -137,44 +131,32 @@ void TestQgsRasterLayerTemporalProperties::testVisibleInTimeRange() QgsRasterLayerTemporalProperties props; // by default, should be visible regardless of time range QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange() ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ) ) ); // when in data provider time handling mode, we also should always render regardless of time range props.setIsActive( true ); props.setMode( Qgis::RasterTemporalMode::TemporalRangeFromDataProvider ); QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange() ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ) ) ); // fix temporal range should be ignored while in ModeTemporalRangeFromDataProvider - props.setFixedTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ) ) ); + props.setFixedTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ) ) ); QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange() ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ) ) ) ); // switch to fixed time mode props.setMode( Qgis::RasterTemporalMode::FixedTemporalRange ); // should be visible in infinite time ranges QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange() ) ); // should not be visible -- outside of fixed time range - QVERIFY( !props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( !props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ) ) ) ); // should be visible -- intersects fixed time range - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 2 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 2 ), QTime( 0, 0, 0 ) ), - QDateTime( ) ) ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime(), - QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2021, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ) ) ); - QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 2 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 2 ), QTime( 0, 0, 0 ) ), QDateTime() ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime(), QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2019, 1, 2 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 1, 3 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ) ) ); + QVERIFY( props.isVisibleInTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 5 ), QTime( 0, 0, 0 ) ) ) ) ); } QGSTEST_MAIN( TestQgsRasterLayerTemporalProperties ) diff --git a/tests/src/core/testqgsrastermarker.cpp b/tests/src/core/testqgsrastermarker.cpp index e835dd057b5a..e9986a736616 100644 --- a/tests/src/core/testqgsrastermarker.cpp +++ b/tests/src/core/testqgsrastermarker.cpp @@ -43,13 +43,14 @@ class TestQgsRasterMarker : public QgsTest Q_OBJECT public: - TestQgsRasterMarker() : QgsTest( QStringLiteral( "Raster Marker Renderer Tests" ) ) {} + TestQgsRasterMarker() + : QgsTest( QStringLiteral( "Raster Marker Renderer Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void rasterMarkerSymbol(); void anchor(); @@ -95,12 +96,12 @@ void TestQgsRasterMarker::initTestCase() //create a marker layer that will be used in all tests const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - mPointLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mPointLayer ); + QList() << mPointLayer + ); //setup the raster marker symbol mRasterMarker = new QgsRasterMarkerSymbolLayer(); @@ -129,7 +130,6 @@ void TestQgsRasterMarker::init() void TestQgsRasterMarker::cleanup() { - } void TestQgsRasterMarker::rasterMarkerSymbol() diff --git a/tests/src/core/testqgsrastersublayer.cpp b/tests/src/core/testqgsrastersublayer.cpp index bf389756e5b4..2e87729793d9 100644 --- a/tests/src/core/testqgsrastersublayer.cpp +++ b/tests/src/core/testqgsrastersublayer.cpp @@ -49,21 +49,23 @@ class TestQgsRasterSubLayer : public QgsTest Q_OBJECT public: - TestQgsRasterSubLayer() : QgsTest( QStringLiteral( "Raster Sub Layer Tests" ) ) {} + TestQgsRasterSubLayer() + : QgsTest( QStringLiteral( "Raster Sub Layer Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void subLayersList(); void checkStats(); + private: QString mTestDataDir; QString mFileName; QgsRasterLayer *mpRasterLayer = nullptr; - bool mHasNetCDF = false ; + bool mHasNetCDF = false; }; //runs before all tests @@ -87,8 +89,7 @@ void TestQgsRasterSubLayer::initTestCase() if ( mHasNetCDF ) { const QFileInfo myRasterFileInfo( mFileName ); - mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), - myRasterFileInfo.completeBaseName() ); + mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); } else { @@ -156,8 +157,7 @@ void TestQgsRasterSubLayer::checkStats() sublayerUri = sublayerUri.split( QgsDataProvider::sublayerSeparator() )[0]; QgsRasterLayer *sublayer = new QgsRasterLayer( sublayerUri, QStringLiteral( "Sublayer 1" ) ); - const QgsRasterBandStats myStatistics = sublayer->dataProvider()->bandStatistics( 1, - Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max ); + const QgsRasterBandStats myStatistics = sublayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::Min | Qgis::RasterBandStatistic::Max ); const int width = 200; const int height = 200; const double min = 122; diff --git a/tests/src/core/testqgsrelation.cpp b/tests/src/core/testqgsrelation.cpp index 25289c3641ba..a9920acb290d 100644 --- a/tests/src/core/testqgsrelation.cpp +++ b/tests/src/core/testqgsrelation.cpp @@ -28,13 +28,13 @@ * \ingroup UnitTests * This is a unit test for the QgsRelation changing style */ -class TestQgsRelation: public QObject +class TestQgsRelation : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testValidRelationAfterChangingStyle(); }; @@ -67,7 +67,7 @@ void TestQgsRelation::testValidRelationAfterChangingStyle() QVERIFY( p->read( projectPath ) ); - const auto layers { p->mapLayers().values( ) }; + const auto layers { p->mapLayers().values() }; for ( const auto &l : std::as_const( layers ) ) { QVERIFY( l->isValid() ); @@ -105,7 +105,6 @@ void TestQgsRelation::testValidRelationAfterChangingStyle() } QVERIFY( valid ); - } QGSTEST_MAIN( TestQgsRelation ) diff --git a/tests/src/core/testqgsrelationreferencefieldformatter.cpp b/tests/src/core/testqgsrelationreferencefieldformatter.cpp index 3a5094c09aab..b2dac26a39d0 100644 --- a/tests/src/core/testqgsrelationreferencefieldformatter.cpp +++ b/tests/src/core/testqgsrelationreferencefieldformatter.cpp @@ -26,23 +26,22 @@ //header for class being tested #include "fieldformatter/qgsrelationreferencefieldformatter.h" -class TestQgsRelationReferenceFieldFormatter: public QObject +class TestQgsRelationReferenceFieldFormatter : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testDependencies(); private: std::unique_ptr mLayer1; std::unique_ptr mLayer2; std::unique_ptr mRelation; - }; @@ -131,11 +130,11 @@ void TestQgsRelationReferenceFieldFormatter::testDependencies() // Test dependencies const QgsEditorWidgetSetup setup { QStringLiteral( "RelationReference" ), { - { QStringLiteral( "ReferencedLayerDataSource" ), mLayer2->publicSource() }, - { QStringLiteral( "ReferencedLayerProviderKey" ), mLayer2->providerType() }, - { QStringLiteral( "ReferencedLayerId" ), mLayer2->id() }, - { QStringLiteral( "ReferencedLayerName" ), mLayer2->name() }, - }}; + { QStringLiteral( "ReferencedLayerDataSource" ), mLayer2->publicSource() }, + { QStringLiteral( "ReferencedLayerProviderKey" ), mLayer2->providerType() }, + { QStringLiteral( "ReferencedLayerId" ), mLayer2->id() }, + { QStringLiteral( "ReferencedLayerName" ), mLayer2->name() }, + } }; QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() ); const QList dependencies = fieldFormatter->layerDependencies( setup.config() ); QVERIFY( dependencies.count() == 1 ); @@ -148,7 +147,3 @@ void TestQgsRelationReferenceFieldFormatter::testDependencies() QGSTEST_MAIN( TestQgsRelationReferenceFieldFormatter ) #include "testqgsrelationreferencefieldformatter.moc" - - - - diff --git a/tests/src/core/testqgsrenderers.cpp b/tests/src/core/testqgsrenderers.cpp index c58ce69edd42..913aa82705cd 100644 --- a/tests/src/core/testqgsrenderers.cpp +++ b/tests/src/core/testqgsrenderers.cpp @@ -44,7 +44,8 @@ class TestQgsRenderers : public QgsTest Q_OBJECT public: - TestQgsRenderers() : QgsTest( QStringLiteral( "Vector Renderer Tests" ) ) {} + TestQgsRenderers() + : QgsTest( QStringLiteral( "Vector Renderer Tests" ) ) {} ~TestQgsRenderers() override { @@ -52,17 +53,17 @@ class TestQgsRenderers : public QgsTest } private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void singleSymbol(); void emptyGeometry(); -// void uniqueValue(); -// void graduatedSymbol(); -// void continuousSymbol(); + // void uniqueValue(); + // void graduatedSymbol(); + // void continuousSymbol(); private: - bool mTestHasError = false ; - bool setQml( const QString &type ); //uniquevalue / continuous / single / + bool mTestHasError = false; + bool setQml( const QString &type ); //uniquevalue / continuous / single / bool imageCheck( const QString &type ); //as above bool checkEmptyRender( const QString &name, QgsVectorLayer *layer ); QgsMapSettings *mMapSettings = nullptr; @@ -93,22 +94,22 @@ void TestQgsRenderers::initTestCase() mTestDataDir = myDataDir + '/'; const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPointsLayer ); + QList() << mpPointsLayer + ); // //create a poly layer that will be used in all tests... // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPolysLayer ); + QList() << mpPolysLayer + ); // @@ -116,18 +117,19 @@ void TestQgsRenderers::initTestCase() // const QString myLinesFileName = mTestDataDir + "lines.shp"; const QFileInfo myLineFileInfo( myLinesFileName ); - mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), - myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpLinesLayer ); + QList() << mpLinesLayer + ); // // We only need maprender instead of mapcanvas // since maprender does not require a qui // and is more light weight // mMapSettings->setLayers( - QList() << mpPointsLayer << mpPolysLayer << mpLinesLayer ); + QList() << mpPointsLayer << mpPolysLayer << mpLinesLayer + ); } void TestQgsRenderers::cleanupTestCase() { @@ -154,7 +156,7 @@ void TestQgsRenderers::emptyGeometry() QgsProject::instance()->addMapLayer( vl ); QgsFeature f; - std::unique_ptr< QgsMultiPolygon > mp = std::make_unique< QgsMultiPolygon >(); + std::unique_ptr mp = std::make_unique(); mp->addGeometry( new QgsPolygon() ); f.setGeometry( QgsGeometry( std::move( mp ) ) ); QVERIFY( vl->dataProvider()->addFeature( f ) ); @@ -180,7 +182,7 @@ void TestQgsRenderers::emptyGeometry() vl = new QgsVectorLayer( QStringLiteral( "MultiLineString?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( vl->isValid() ); QgsProject::instance()->addMapLayer( vl ); - std::unique_ptr< QgsMultiLineString > mls = std::make_unique< QgsMultiLineString >(); + std::unique_ptr mls = std::make_unique(); mls->addGeometry( new QgsLineString() ); f.setGeometry( QgsGeometry( std::move( mls ) ) ); QVERIFY( vl->dataProvider()->addFeature( f ) ); @@ -190,7 +192,7 @@ void TestQgsRenderers::emptyGeometry() vl = new QgsVectorLayer( QStringLiteral( "MultiPoint?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( vl->isValid() ); QgsProject::instance()->addMapLayer( vl ); - std::unique_ptr< QgsMultiPoint > mlp = std::make_unique< QgsMultiPoint >(); + std::unique_ptr mlp = std::make_unique(); f.setGeometry( QgsGeometry( std::move( mlp ) ) ); QVERIFY( vl->dataProvider()->addFeature( f ) ); QVERIFY( checkEmptyRender( "MultiPoint", vl ) ); @@ -203,7 +205,7 @@ bool TestQgsRenderers::checkEmptyRender( const QString &testName, QgsVectorLayer ms.setExtent( extent ); ms.setFlag( Qgis::MapSettingsFlag::ForceVectorOutput ); ms.setOutputDpi( 96 ); - ms.setLayers( QList< QgsMapLayer * >() << layer ); + ms.setLayers( QList() << layer ); QgsMultiRenderChecker myChecker; myChecker.setControlName( "expected_emptygeometry" ); myChecker.setMapSettings( ms ); @@ -223,7 +225,7 @@ bool TestQgsRenderers::setQml( const QString &type ) //load a qml style and apply to our layer //the style will correspond to the renderer //type we are testing - if ( ! mpPointsLayer->isValid() ) + if ( !mpPointsLayer->isValid() ) { return false; } diff --git a/tests/src/core/testqgsrulebasedrenderer.cpp b/tests/src/core/testqgsrulebasedrenderer.cpp index 3e35d356f769..2fde23257b73 100644 --- a/tests/src/core/testqgsrulebasedrenderer.cpp +++ b/tests/src/core/testqgsrulebasedrenderer.cpp @@ -36,13 +36,13 @@ typedef QgsRuleBasedRenderer::Rule RRule; -class TestQgsRuleBasedRenderer: public QgsTest +class TestQgsRuleBasedRenderer : public QgsTest { Q_OBJECT public: - - TestQgsRuleBasedRenderer() : QgsTest( QStringLiteral( "Rule based renderer tests" ) ) {} + TestQgsRuleBasedRenderer() + : QgsTest( QStringLiteral( "Rule based renderer tests" ) ) {} private slots: @@ -164,14 +164,11 @@ class TestQgsRuleBasedRenderer: public QgsTest */ void test_many_rules_expression_filter() { - - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "point?field=fld:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "point?field=fld:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsRenderContext ctx; // dummy render context ctx.expressionContext().setFields( layer->fields() ); - const std::function makeFilter = [ & ]( const int rc ) -> QString - { - + const std::function makeFilter = [&]( const int rc ) -> QString { // prepare renderer RRule *rootRule = new RRule( nullptr ); for ( int i = 0; i < rc; i++ ) @@ -192,21 +189,20 @@ class TestQgsRuleBasedRenderer: public QgsTest "((((12) OR ((13) OR (14))) OR ((15) OR ((16) OR (17)))) OR (((18) OR ((19) OR (20))) OR (((21) OR (22)) OR ((23) OR (24)))))) OR " "(((((25) OR ((26) OR (27))) OR ((28) OR ((29) OR (30)))) OR (((31) OR ((32) OR (33))) OR (((34) OR (35)) OR ((36) OR (37))))) OR " "((((38) OR ((39) OR (40))) OR ((41) OR ((42) OR (43)))) OR (((44) OR ((45) OR (46))) OR (((47) OR (48)) OR ((49) OR (50))))))" ) ); - } void testElse() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); @@ -222,7 +218,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsMultiRenderChecker renderchecker; renderchecker.setMapSettings( mapsettings ); @@ -236,15 +232,15 @@ class TestQgsRuleBasedRenderer: public QgsTest void testDisabledElse() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); @@ -262,7 +258,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsMultiRenderChecker renderchecker; renderchecker.setMapSettings( mapsettings ); @@ -276,14 +272,14 @@ class TestQgsRuleBasedRenderer: public QgsTest void testNoMatchingZoomRanges() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); r1->setMaximumScale( 1000 ); @@ -303,7 +299,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -162.9, 22.1 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsRenderContext rc = QgsRenderContext::fromMapSettings( mapsettings ); QGSCOMPARENEAR( rc.rendererScale(), 78999, 1000 ); @@ -334,15 +330,15 @@ class TestQgsRuleBasedRenderer: public QgsTest void testWillRenderFeature() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); @@ -361,7 +357,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsFeature f; QgsFeatureIterator it = layer->getFeatures(); @@ -389,15 +385,15 @@ class TestQgsRuleBasedRenderer: public QgsTest void testGroupAndElseRules() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *rx1 = new QgsRuleBasedRenderer::Rule( nullptr, 0, 0, "\"id\" < 3" ); QgsRuleBasedRenderer::Rule *rx2 = new QgsRuleBasedRenderer::Rule( sym3, 0, 0, "ELSE" ); @@ -420,7 +416,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsMultiRenderChecker renderchecker; renderchecker.setMapSettings( mapsettings ); @@ -434,15 +430,15 @@ class TestQgsRuleBasedRenderer: public QgsTest void testWillRenderFeatureNestedElse() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); @@ -460,7 +456,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsFeature ft = layer->getFeature( 0 ); @@ -484,15 +480,15 @@ class TestQgsRuleBasedRenderer: public QgsTest // Regression #21287, also test rulesForFeature since there were no tests any where and I've found a couple of issues const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 200" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 1000, 100000000, "ELSE" ); // < match this! @@ -509,7 +505,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsFeature f = layer->getFeature( 0 ); // 'id' = 1 @@ -539,8 +535,8 @@ class TestQgsRuleBasedRenderer: public QgsTest void testUsedAttributes() { // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 200" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 1000, 100000000, "ELSE" ); @@ -549,7 +545,7 @@ class TestQgsRuleBasedRenderer: public QgsTest rootrule->appendChild( r1 ); rootrule->appendChild( r2 ); - std::unique_ptr< QgsRuleBasedRenderer > renderer = std::make_unique< QgsRuleBasedRenderer >( rootrule ); + std::unique_ptr renderer = std::make_unique( rootrule ); QgsMapSettings mapsettings; mapsettings.setOutputSize( QSize( 400, 400 ) ); @@ -557,13 +553,13 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); QgsRenderContext ctx = QgsRenderContext::fromMapSettings( mapsettings ); - QCOMPARE( renderer->usedAttributes( ctx ), QSet { QStringLiteral( "id" )} ); + QCOMPARE( renderer->usedAttributes( ctx ), QSet { QStringLiteral( "id" ) } ); } void testPointsUsedAttributes() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/points.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); // Create rulebased style @@ -610,25 +606,25 @@ class TestQgsRuleBasedRenderer: public QgsTest ctx.expressionContext().appendScope( layer->createExpressionContextScope() ); // for symbol layer - QCOMPARE( l1->usedAttributes( ctx ), QSet( {"Heading"} ) ); + QCOMPARE( l1->usedAttributes( ctx ), QSet( { "Heading" } ) ); // for symbol - QCOMPARE( sym1->usedAttributes( ctx ), QSet( {"Heading"} ) ); + QCOMPARE( sym1->usedAttributes( ctx ), QSet( { "Heading" } ) ); // for symbol renderer - QCOMPARE( renderer->usedAttributes( ctx ), QSet( {"Class", "Heading"} ) ); + QCOMPARE( renderer->usedAttributes( ctx ), QSet( { "Class", "Heading" } ) ); } void testFeatureCount() { const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); @@ -645,7 +641,7 @@ class TestQgsRuleBasedRenderer: public QgsTest mapsettings.setOutputSize( QSize( 400, 400 ) ); mapsettings.setOutputDpi( 96 ); mapsettings.setExtent( QgsRectangle( -163, 22, -70, 52 ) ); - mapsettings.setLayers( {layer.get()} ); + mapsettings.setLayers( { layer.get() } ); QgsFeature ft = layer->getFeature( 2 ); // 'id' = 3 => ELSE @@ -676,31 +672,31 @@ class TestQgsRuleBasedRenderer: public QgsTest // Test refining rule with categories (refs #10815) const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); QgsRuleBasedRenderer::Rule *r3 = new QgsRuleBasedRenderer::Rule( sym3, 0, 0, "ELSE" ); - std::unique_ptr< QgsRuleBasedRenderer::Rule > rootrule = std::make_unique< QgsRuleBasedRenderer::Rule >( nullptr ); + std::unique_ptr rootrule = std::make_unique( nullptr ); rootrule->appendChild( r1 ); rootrule->appendChild( r2 ); rootrule->appendChild( r3 ); // First, try with a field based category (id) - QList< QgsRendererCategory > cats; + QList cats; cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "id 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), QString() ) ); cats.append( QgsRendererCategory( QVariant(), new QgsMarkerSymbol(), QString() ) ); - std::unique_ptr< QgsCategorizedSymbolRenderer > c = std::make_unique< QgsCategorizedSymbolRenderer >( "id", cats ); + std::unique_ptr c = std::make_unique( "id", cats ); QgsRuleBasedRenderer::refineRuleCategories( r2, c.get() ); QCOMPARE( r2->children()[0]->filterExpression(), "\"id\" = 1" ); @@ -714,7 +710,7 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "result 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "result 2" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "id + 1", cats ); + c = std::make_unique( "id + 1", cats ); QgsRuleBasedRenderer::refineRuleCategories( r1, c.get() ); QCOMPARE( r1->children()[0]->filterExpression(), "id + 1 = 1" ); @@ -726,7 +722,7 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "result 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "result 2" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "\"id\"", cats ); + c = std::make_unique( "\"id\"", cats ); QgsRuleBasedRenderer::refineRuleCategories( r3, c.get() ); QCOMPARE( r3->children()[0]->filterExpression(), "\"id\" = 1" ); @@ -740,30 +736,30 @@ class TestQgsRuleBasedRenderer: public QgsTest // Test refining rule with ranges (refs #10815) const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); QgsRuleBasedRenderer::Rule *r3 = new QgsRuleBasedRenderer::Rule( sym3, 0, 0, "ELSE" ); - std::unique_ptr< QgsRuleBasedRenderer::Rule > rootrule = std::make_unique< QgsRuleBasedRenderer::Rule >( nullptr ); + std::unique_ptr rootrule = std::make_unique( nullptr ); rootrule->appendChild( r1 ); rootrule->appendChild( r2 ); rootrule->appendChild( r3 ); // First, try with a field based category (id) - QList< QgsRendererRange > ranges; + QList ranges; ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - std::unique_ptr< QgsGraduatedSymbolRenderer > c = std::make_unique< QgsGraduatedSymbolRenderer >( "id", ranges ); + std::unique_ptr c = std::make_unique( "id", ranges ); QgsRuleBasedRenderer::refineRuleRanges( r2, c.get() ); QCOMPARE( r2->children()[0]->filterExpression(), "\"id\" >= 0.0000 AND \"id\" <= 1.0000" ); @@ -773,7 +769,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "id / 2", ranges ); + c = std::make_unique( "id / 2", ranges ); QgsRuleBasedRenderer::refineRuleRanges( r1, c.get() ); QCOMPARE( r1->children()[0]->filterExpression(), "(id / 2) >= 0.0000 AND (id / 2) <= 1.0000" ); @@ -783,7 +779,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "\"id\"", ranges ); + c = std::make_unique( "\"id\"", ranges ); QgsRuleBasedRenderer::refineRuleRanges( r3, c.get() ); QCOMPARE( r3->children()[0]->filterExpression(), "\"id\" >= 0.0000 AND \"id\" <= 1.0000" ); @@ -795,37 +791,37 @@ class TestQgsRuleBasedRenderer: public QgsTest // Test converting categorised renderer to rule based const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); QgsRuleBasedRenderer::Rule *r3 = new QgsRuleBasedRenderer::Rule( sym3, 0, 0, "ELSE" ); - std::unique_ptr rootrule = std::make_unique< QgsRuleBasedRenderer::Rule>( nullptr ); + std::unique_ptr rootrule = std::make_unique( nullptr ); rootrule->appendChild( r1 ); rootrule->appendChild( r2 ); rootrule->appendChild( r3 ); // First, try with a field based category (id) - QList< QgsRendererCategory > cats; + QList cats; cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "id 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "id 2" ) ); cats.append( QgsRendererCategory( "a\'b", new QgsMarkerSymbol(), "id a'b" ) ); cats.append( QgsRendererCategory( "a\nb", new QgsMarkerSymbol(), "id a\\nb" ) ); cats.append( QgsRendererCategory( "a\\b", new QgsMarkerSymbol(), "id a\\\\b" ) ); cats.append( QgsRendererCategory( "a\tb", new QgsMarkerSymbol(), "id a\\tb" ) ); - cats.append( QgsRendererCategory( QVariantList( {"c", "d"} ), new QgsMarkerSymbol(), "c/d" ) ); - std::unique_ptr< QgsCategorizedSymbolRenderer > c = std::make_unique< QgsCategorizedSymbolRenderer >( "id", cats ); + cats.append( QgsRendererCategory( QVariantList( { "c", "d" } ), new QgsMarkerSymbol(), "c/d" ) ); + std::unique_ptr c = std::make_unique( "id", cats ); - std::unique_ptr< QgsRuleBasedRenderer > r( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); + std::unique_ptr r( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children().size(), 7 ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "\"id\" = 1" ); QCOMPARE( r->rootRule()->children()[1]->filterExpression(), "\"id\" = 2" ); @@ -840,8 +836,8 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "result 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "result 2" ) ); - cats.append( QgsRendererCategory( QVariantList( {3, 4} ), new QgsMarkerSymbol(), "result 3/4" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "id + 1", cats ); + cats.append( QgsRendererCategory( QVariantList( { 3, 4 } ), new QgsMarkerSymbol(), "result 3/4" ) ); + c = std::make_unique( "id + 1", cats ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children().size(), 3 ); @@ -853,8 +849,8 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "result 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "result 2" ) ); - cats.append( QgsRendererCategory( QVariantList( {3, 4} ), new QgsMarkerSymbol(), "result 3/4" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "\"id\"", cats ); + cats.append( QgsRendererCategory( QVariantList( { 3, 4 } ), new QgsMarkerSymbol(), "result 3/4" ) ); + c = std::make_unique( "\"id\"", cats ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "\"id\" = 1" ); @@ -865,7 +861,7 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "fa_cy-fie+ld 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "fa_cy-fie+ld 2" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "fa_cy-fie+ld", cats ); + c = std::make_unique( "fa_cy-fie+ld", cats ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "\"fa_cy-fie+ld\" = 1" ); @@ -877,31 +873,31 @@ class TestQgsRuleBasedRenderer: public QgsTest // Test converting categorised renderer to rule based // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); QgsRuleBasedRenderer::Rule *r3 = new QgsRuleBasedRenderer::Rule( sym3, 0, 0, "ELSE" ); - std::unique_ptr< QgsRuleBasedRenderer::Rule > rootrule = std::make_unique< QgsRuleBasedRenderer::Rule >( nullptr ); + std::unique_ptr rootrule = std::make_unique( nullptr ); rootrule->appendChild( r1 ); rootrule->appendChild( r2 ); rootrule->appendChild( r3 ); // First, try with a field based category (id) - QList< QgsRendererCategory > cats; + QList cats; cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "id 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "id 2" ) ); cats.append( QgsRendererCategory( "a\'b", new QgsMarkerSymbol(), "id a'b" ) ); cats.append( QgsRendererCategory( "a\nb", new QgsMarkerSymbol(), "id a\\nb" ) ); cats.append( QgsRendererCategory( "a\\b", new QgsMarkerSymbol(), "id a\\\\b" ) ); cats.append( QgsRendererCategory( "a\tb", new QgsMarkerSymbol(), "id a\\tb" ) ); - cats.append( QgsRendererCategory( QVariantList( {"c", "d"} ), new QgsMarkerSymbol(), "c/d" ) ); - std::unique_ptr< QgsCategorizedSymbolRenderer > c = std::make_unique< QgsCategorizedSymbolRenderer >( "id", cats ); + cats.append( QgsRendererCategory( QVariantList( { "c", "d" } ), new QgsMarkerSymbol(), "c/d" ) ); + std::unique_ptr c = std::make_unique( "id", cats ); - std::unique_ptr< QgsRuleBasedRenderer > r( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); + std::unique_ptr r( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children().size(), 7 ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "\"id\" = 1" ); QCOMPARE( r->rootRule()->children()[1]->filterExpression(), "\"id\" = 2" ); @@ -916,8 +912,8 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "result 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "result 2" ) ); - cats.append( QgsRendererCategory( QVariantList( {3, 4} ), new QgsMarkerSymbol(), "result 3/4" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "id + 1", cats ); + cats.append( QgsRendererCategory( QVariantList( { 3, 4 } ), new QgsMarkerSymbol(), "result 3/4" ) ); + c = std::make_unique( "id + 1", cats ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children().size(), 3 ); @@ -929,8 +925,8 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "result 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "result 2" ) ); - cats.append( QgsRendererCategory( QVariantList( {3, 4} ), new QgsMarkerSymbol(), "result 3/4" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "\"id\"", cats ); + cats.append( QgsRendererCategory( QVariantList( { 3, 4 } ), new QgsMarkerSymbol(), "result 3/4" ) ); + c = std::make_unique( "\"id\"", cats ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "\"id\" = 1" ); @@ -942,7 +938,7 @@ class TestQgsRuleBasedRenderer: public QgsTest cats.clear(); cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "fa_cy-fie+ld 1" ) ); cats.append( QgsRendererCategory( 2, new QgsMarkerSymbol(), "fa_cy-fie+ld 2" ) ); - c = std::make_unique< QgsCategorizedSymbolRenderer >( "fa_cy-fie+ld", cats ); + c = std::make_unique( "fa_cy-fie+ld", cats ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "fa_cy-fie+ld = 1" ); @@ -954,32 +950,32 @@ class TestQgsRuleBasedRenderer: public QgsTest // Test converting graduated renderer to rule based const QString shpFile = TEST_DATA_DIR + QStringLiteral( "/rectangles.shp" ); - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); + std::unique_ptr layer = std::make_unique( shpFile, QStringLiteral( "rectangles" ), QStringLiteral( "ogr" ) ); QVERIFY( layer->isValid() ); QgsField vfield = QgsField( QStringLiteral( "fa_cy-fie+ld" ), QMetaType::Type::Int ); layer->addExpressionField( QStringLiteral( "\"id\"" ), vfield ); // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); QgsRuleBasedRenderer::Rule *r3 = new QgsRuleBasedRenderer::Rule( sym3, 0, 0, "ELSE" ); - std::unique_ptr< QgsRuleBasedRenderer::Rule > rootrule = std::make_unique< QgsRuleBasedRenderer::Rule >( nullptr ); + std::unique_ptr rootrule = std::make_unique( nullptr ); rootrule->appendChild( r1 ); rootrule->appendChild( r2 ); rootrule->appendChild( r3 ); // First, try with a field based category (id) - QList< QgsRendererRange > ranges; + QList ranges; ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - std::unique_ptr< QgsGraduatedSymbolRenderer > c = std::make_unique< QgsGraduatedSymbolRenderer >( "id", ranges ); + std::unique_ptr c = std::make_unique( "id", ranges ); - std::unique_ptr< QgsRuleBasedRenderer > r( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); + std::unique_ptr r( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "\"id\" >= 0.000000 AND \"id\" <= 1.000000" ); QCOMPARE( r->rootRule()->children()[1]->filterExpression(), "\"id\" > 1.000000 AND \"id\" <= 2.000000" ); @@ -988,7 +984,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "id / 2", ranges ); + c = std::make_unique( "id / 2", ranges ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); @@ -999,7 +995,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "\"id\"", ranges ); + c = std::make_unique( "\"id\"", ranges ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); @@ -1010,7 +1006,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "fa_cy-fie+ld", ranges ); + c = std::make_unique( "fa_cy-fie+ld", ranges ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get(), layer.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); @@ -1023,26 +1019,26 @@ class TestQgsRuleBasedRenderer: public QgsTest // Test converting graduated renderer to rule based // Create rulebased style - QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#fdbf6f"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#71bd6c"}, {"outline_color", "black"}} ) ); - QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( {{"color", "#1f78b4"}, {"outline_color", "black"}} ) ); + QgsSymbol *sym1 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#fdbf6f" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym2 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#71bd6c" }, { "outline_color", "black" } } ) ); + QgsSymbol *sym3 = QgsFillSymbol::createSimple( QVariantMap( { { "color", "#1f78b4" }, { "outline_color", "black" } } ) ); QgsRuleBasedRenderer::Rule *r1 = new QgsRuleBasedRenderer::Rule( sym1, 0, 0, "\"id\" = 1" ); QgsRuleBasedRenderer::Rule *r2 = new QgsRuleBasedRenderer::Rule( sym2, 0, 0, "\"id\" = 2" ); QgsRuleBasedRenderer::Rule *r3 = new QgsRuleBasedRenderer::Rule( sym3, 0, 0, "ELSE" ); - std::unique_ptr< QgsRuleBasedRenderer::Rule > rootrule = std::make_unique< QgsRuleBasedRenderer::Rule >( nullptr ); + std::unique_ptr rootrule = std::make_unique( nullptr ); rootrule->appendChild( r1 ); rootrule->appendChild( r2 ); rootrule->appendChild( r3 ); // First, try with a field based category (id) - QList< QgsRendererRange > ranges; + QList ranges; ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - std::unique_ptr< QgsGraduatedSymbolRenderer > c = std::make_unique< QgsGraduatedSymbolRenderer >( "id", ranges ); + std::unique_ptr c = std::make_unique( "id", ranges ); - std::unique_ptr< QgsRuleBasedRenderer > r( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); + std::unique_ptr r( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); QCOMPARE( r->rootRule()->children()[0]->filterExpression(), "\"id\" >= 0.000000 AND \"id\" <= 1.000000" ); QCOMPARE( r->rootRule()->children()[1]->filterExpression(), "\"id\" > 1.000000 AND \"id\" <= 2.000000" ); @@ -1051,7 +1047,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "id / 2", ranges ); + c = std::make_unique( "id / 2", ranges ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); @@ -1062,7 +1058,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "\"id\"", ranges ); + c = std::make_unique( "\"id\"", ranges ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); @@ -1074,7 +1070,7 @@ class TestQgsRuleBasedRenderer: public QgsTest ranges.clear(); ranges.append( QgsRendererRange( 0, 1, new QgsMarkerSymbol(), "0-1" ) ); ranges.append( QgsRendererRange( 1, 2, new QgsMarkerSymbol(), "1-2" ) ); - c = std::make_unique< QgsGraduatedSymbolRenderer >( "fa_cy-fie+ld", ranges ); + c = std::make_unique( "fa_cy-fie+ld", ranges ); r.reset( QgsRuleBasedRenderer::convertFromRenderer( c.get() ) ); QCOMPARE( r->rootRule()->children().size(), 2 ); @@ -1085,26 +1081,28 @@ class TestQgsRuleBasedRenderer: public QgsTest void testConvertFromEmbedded() { // Test converting an embedded symbol renderer to a rule based renderer - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "points" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "points" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsFeature f; f.setGeometry( QgsGeometry::fromWkt( "Point(-100 30)" ) ); f.setEmbeddedSymbol( - QgsMarkerSymbol::createSimple( {{"name", "triangle"}, {"size", 10}, {"color", "#ff0000"}, {"outline_style", "no"}} ) ); + QgsMarkerSymbol::createSimple( { { "name", "triangle" }, { "size", 10 }, { "color", "#ff0000" }, { "outline_style", "no" } } ) + ); QVERIFY( layer->dataProvider()->addFeature( f ) ); f.setGeometry( QgsGeometry::fromWkt( "Point(-110 40)" ) ); f.setEmbeddedSymbol( - QgsMarkerSymbol::createSimple( {{"name", "square"}, { "size", 7}, { "color", "#00ff00"}, { "outline_style", "no"} } ) ); + QgsMarkerSymbol::createSimple( { { "name", "square" }, { "size", 7 }, { "color", "#00ff00" }, { "outline_style", "no" } } ) + ); QVERIFY( layer->dataProvider()->addFeature( f ) ); f.setGeometry( QgsGeometry::fromWkt( "Point(-90 50)" ) ); f.setEmbeddedSymbol( nullptr ); QVERIFY( layer->dataProvider()->addFeature( f ) ); - QgsEmbeddedSymbolRenderer *renderer = new QgsEmbeddedSymbolRenderer( QgsMarkerSymbol::createSimple( {{"name", "star"}, {"size", 10}, {"color", "#ff00ff"}, {"outline_style", "no"}} ) ); + QgsEmbeddedSymbolRenderer *renderer = new QgsEmbeddedSymbolRenderer( QgsMarkerSymbol::createSimple( { { "name", "star" }, { "size", 10 }, { "color", "#ff00ff" }, { "outline_style", "no" } } ) ); layer->setRenderer( renderer ); - std::unique_ptr< QgsRuleBasedRenderer > rule_based( QgsRuleBasedRenderer::convertFromRenderer( renderer, layer.get() ) ); + std::unique_ptr rule_based( QgsRuleBasedRenderer::convertFromRenderer( renderer, layer.get() ) ); QCOMPARE( rule_based->rootRule()->children().size(), 3 ); QgsRuleBasedRenderer::Rule *rule_0 = rule_based->rootRule()->children()[0]; QCOMPARE( rule_0->filterExpression(), "$id=1" ); @@ -1122,7 +1120,7 @@ class TestQgsRuleBasedRenderer: public QgsTest void testNullsCount() { - std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:4326&field=number:int" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "Point?crs=epsg:4326&field=number:int" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); QVERIFY( layer->isValid() ); QgsFeature f( layer->fields() ); @@ -1137,7 +1135,7 @@ class TestQgsRuleBasedRenderer: public QgsTest f = QgsFeature( layer->fields() ); QVERIFY( layer->dataProvider()->addFeature( f ) ); - QList< QgsRendererCategory > cats; + QList cats; cats.append( QgsRendererCategory( 1, new QgsMarkerSymbol(), "one" ) ); cats.append( QgsRendererCategory( 0, new QgsMarkerSymbol(), "zero" ) ); cats.append( QgsRendererCategory( QVariant(), new QgsMarkerSymbol(), "NULL" ) ); @@ -1155,7 +1153,7 @@ class TestQgsRuleBasedRenderer: public QgsTest void testLegendKeys() { QgsRuleBasedRenderer::Rule *rootRule = new QgsRuleBasedRenderer::Rule( nullptr ); - std::unique_ptr< QgsRuleBasedRenderer > renderer = std::make_unique< QgsRuleBasedRenderer >( rootRule ); + std::unique_ptr renderer = std::make_unique( rootRule ); QVERIFY( renderer->legendKeys().empty() ); @@ -1169,8 +1167,7 @@ class TestQgsRuleBasedRenderer: public QgsTest rootRule->appendChild( rule4 ); rootRule->appendChild( rule5 ); - QSet< QString > expected = QSet< QString > - { + QSet expected = QSet { rule2->ruleKey(), rule3->ruleKey(), rule4->ruleKey(), @@ -1182,8 +1179,8 @@ class TestQgsRuleBasedRenderer: public QgsTest void testLegendKeysForFeature() { QgsRuleBasedRenderer::Rule *rootRule = new QgsRuleBasedRenderer::Rule( nullptr ); - std::unique_ptr< QgsRuleBasedRenderer > renderer = std::make_unique< QgsRuleBasedRenderer >( rootRule ); - std::unique_ptr< QgsMarkerSymbol > symbol( QgsMarkerSymbol::createSimple( {} ) ); + std::unique_ptr renderer = std::make_unique( rootRule ); + std::unique_ptr symbol( QgsMarkerSymbol::createSimple( {} ) ); QgsRuleBasedRenderer::Rule *lessThanTwoRule = new QgsRuleBasedRenderer::Rule( symbol->clone(), 0, 0, "\"Importance\" <= 2" ); rootRule->appendChild( lessThanTwoRule ); @@ -1212,31 +1209,31 @@ class TestQgsRuleBasedRenderer: public QgsTest renderer->startRender( rc, fields ); - QSet< QString > expected{rootRule->ruleKey(), elseRule->ruleKey() }; + QSet expected { rootRule->ruleKey(), elseRule->ruleKey() }; QCOMPARE( renderer->legendKeysForFeature( feature, rc ), expected ); feature.setAttributes( QgsAttributes() << 1 << 2 ); - expected = {rootRule->ruleKey(), lessThanTwoRule->ruleKey() }; + expected = { rootRule->ruleKey(), lessThanTwoRule->ruleKey() }; QCOMPARE( renderer->legendKeysForFeature( feature, rc ), expected ); feature.setAttributes( QgsAttributes() << 2 << 2 ); - expected = {rootRule->ruleKey(), lessThanTwoRule->ruleKey() }; + expected = { rootRule->ruleKey(), lessThanTwoRule->ruleKey() }; QCOMPARE( renderer->legendKeysForFeature( feature, rc ), expected ); feature.setAttributes( QgsAttributes() << 3 << 1 ); - expected = {rootRule->ruleKey(), elseRule->ruleKey(), oneRule->ruleKey() }; + expected = { rootRule->ruleKey(), elseRule->ruleKey(), oneRule->ruleKey() }; QCOMPARE( renderer->legendKeysForFeature( feature, rc ), expected ); feature.setAttributes( QgsAttributes() << 3 << 2 ); - expected = {rootRule->ruleKey(), elseRule->ruleKey(), twoRule->ruleKey() }; + expected = { rootRule->ruleKey(), elseRule->ruleKey(), twoRule->ruleKey() }; QCOMPARE( renderer->legendKeysForFeature( feature, rc ), expected ); feature.setAttributes( QgsAttributes() << 3 << 3 ); - expected = {rootRule->ruleKey(), elseRule->ruleKey(), threeRule->ruleKey() }; + expected = { rootRule->ruleKey(), elseRule->ruleKey(), threeRule->ruleKey() }; QCOMPARE( renderer->legendKeysForFeature( feature, rc ), expected ); feature.setAttributes( QgsAttributes() << 3 << 4 ); - expected = {rootRule->ruleKey(), elseRule->ruleKey() }; + expected = { rootRule->ruleKey(), elseRule->ruleKey() }; QCOMPARE( renderer->legendKeysForFeature( feature, rc ), expected ); renderer->stopRender( rc ); @@ -1246,7 +1243,7 @@ class TestQgsRuleBasedRenderer: public QgsTest void testLegendKeyToExpression() { QgsRuleBasedRenderer::Rule *rootRule = new QgsRuleBasedRenderer::Rule( nullptr ); - std::unique_ptr< QgsRuleBasedRenderer > renderer = std::make_unique< QgsRuleBasedRenderer >( rootRule ); + std::unique_ptr renderer = std::make_unique( rootRule ); bool ok = false; QString exp = renderer->legendKeyToExpression( "xxxx", nullptr, ok ); @@ -1310,7 +1307,7 @@ class TestQgsRuleBasedRenderer: public QgsTest // else rules rootRule = new QgsRuleBasedRenderer::Rule( nullptr ); - renderer = std::make_unique< QgsRuleBasedRenderer >( rootRule ); + renderer = std::make_unique( rootRule ); rule2 = new QgsRuleBasedRenderer::Rule( nullptr, 0, 0, "\"field_name\" = 5" ); rule3 = new QgsRuleBasedRenderer::Rule( nullptr, 2000, 0, "\"field_name\" = 6" ); @@ -1346,7 +1343,7 @@ class TestQgsRuleBasedRenderer: public QgsTest // isolated ELSE rule, with no siblings rootRule = new QgsRuleBasedRenderer::Rule( nullptr ); - renderer = std::make_unique< QgsRuleBasedRenderer >( rootRule ); + renderer = std::make_unique( rootRule ); rule2 = new QgsRuleBasedRenderer::Rule( nullptr, 0, 0, "\"field_name\" = 5" ); rule3 = new QgsRuleBasedRenderer::Rule( nullptr, 2000, 0, "\"field_name\" = 6" ); @@ -1365,7 +1362,7 @@ class TestQgsRuleBasedRenderer: public QgsTest void testElseRuleSld() { QgsRuleBasedRenderer::Rule *rootRule = new QgsRuleBasedRenderer::Rule( nullptr ); - std::unique_ptr< QgsRuleBasedRenderer > renderer = std::make_unique< QgsRuleBasedRenderer >( rootRule ); + std::unique_ptr renderer = std::make_unique( rootRule ); QgsRuleBasedRenderer::Rule *rule1 = new QgsRuleBasedRenderer::Rule( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ), 0, 0, "\"field_name\" = 1" ); QgsRuleBasedRenderer::Rule *rule2 = new QgsRuleBasedRenderer::Rule( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ), 0, 0, "\"field_name\" = 6" ); @@ -1410,7 +1407,6 @@ class TestQgsRuleBasedRenderer: public QgsTest QgsRuleBasedRenderer *renderer2 = static_cast( vl->renderer() ); ruleElse = renderer2->rootRule()->children().last(); Q_ASSERT( ruleElse->isElse() ); - } @@ -1450,7 +1446,6 @@ class TestQgsRuleBasedRenderer: public QgsTest for ( QgsRuleBasedRenderer::Rule *child : node->children() ) check_non_root_rule( child ); } - }; QGSTEST_MAIN( TestQgsRuleBasedRenderer ) diff --git a/tests/src/core/testqgsruntimeprofiler.cpp b/tests/src/core/testqgsruntimeprofiler.cpp index d71c4ec70194..32d2a74de565 100644 --- a/tests/src/core/testqgsruntimeprofiler.cpp +++ b/tests/src/core/testqgsruntimeprofiler.cpp @@ -19,7 +19,7 @@ Email : nyall dot dawson at gmail dot com #include -class TestQgsRuntimeProfiler: public QObject +class TestQgsRuntimeProfiler : public QObject { Q_OBJECT private slots: @@ -27,7 +27,6 @@ class TestQgsRuntimeProfiler: public QObject void cleanupTestCase(); void testGroups(); void threading(); - }; @@ -101,12 +100,11 @@ void TestQgsRuntimeProfiler::testGroups() } - class ProfileInThread : public QThread { Q_OBJECT - public : + public: ProfileInThread( QgsRuntimeProfiler *mainProfiler ) : mMainProfiler( mainProfiler ) {} @@ -119,8 +117,6 @@ class ProfileInThread : public QThread private: QgsRuntimeProfiler *mMainProfiler = nullptr; - - }; void TestQgsRuntimeProfiler::threading() @@ -133,7 +129,7 @@ void TestQgsRuntimeProfiler::threading() { const QgsScopedRuntimeProfile profile( QStringLiteral( "launch thread" ), QStringLiteral( "main" ) ); - QSignalSpy spy( QgsApplication::profiler(), &QgsRuntimeProfiler::groupAdded ); + QSignalSpy spy( QgsApplication::profiler(), &QgsRuntimeProfiler::groupAdded ); thread->start(); thread->exit(); @@ -145,9 +141,9 @@ void TestQgsRuntimeProfiler::threading() QCOMPARE( QgsApplication::profiler()->rowCount(), 2 ); const int row1 = QgsApplication::profiler()->data( QgsApplication::profiler()->index( 0, 0 ) ).toString() == QLatin1String( "launch thread" ) ? 0 : 1; QCOMPARE( QgsApplication::profiler()->data( QgsApplication::profiler()->index( row1, 0 ) ).toString(), QStringLiteral( "launch thread" ) ); - QCOMPARE( QgsApplication::profiler()->data( QgsApplication::profiler()->index( row1, 0 ), static_cast< int >( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString(), QStringLiteral( "main" ) ); + QCOMPARE( QgsApplication::profiler()->data( QgsApplication::profiler()->index( row1, 0 ), static_cast( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString(), QStringLiteral( "main" ) ); QCOMPARE( QgsApplication::profiler()->data( QgsApplication::profiler()->index( row1 == 0 ? 1 : 0, 0 ) ).toString(), QStringLiteral( "in thread" ) ); - QCOMPARE( QgsApplication::profiler()->data( QgsApplication::profiler()->index( row1 == 0 ? 1 : 0, 0 ), static_cast< int >( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString(), QStringLiteral( "bg" ) ); + QCOMPARE( QgsApplication::profiler()->data( QgsApplication::profiler()->index( row1 == 0 ? 1 : 0, 0 ), static_cast( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString(), QStringLiteral( "bg" ) ); } diff --git a/tests/src/core/testqgsscaleutils.cpp b/tests/src/core/testqgsscaleutils.cpp index 457fb9d26790..513957d8e579 100644 --- a/tests/src/core/testqgsscaleutils.cpp +++ b/tests/src/core/testqgsscaleutils.cpp @@ -18,13 +18,13 @@ #include "qgsscaleutils.h" -class TestQgsScaleUtils: public QObject +class TestQgsScaleUtils : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testMaximumScaleComparisons_data(); void testMaximumScaleComparisons(); void testMinimumScaleComparisons_data(); @@ -94,7 +94,3 @@ void TestQgsScaleUtils::testMinimumScaleComparisons() QGSTEST_MAIN( TestQgsScaleUtils ) #include "testqgsscaleutils.moc" - - - - diff --git a/tests/src/core/testqgssensorthingsconnection.cpp b/tests/src/core/testqgssensorthingsconnection.cpp index 85bcb6c74b2f..b6e68ffce933 100644 --- a/tests/src/core/testqgssensorthingsconnection.cpp +++ b/tests/src/core/testqgssensorthingsconnection.cpp @@ -24,13 +24,12 @@ class TestQgsSensorThingsConnection : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void encodeDecode(); void testConnections(); - }; @@ -88,7 +87,7 @@ void TestQgsSensorThingsConnection::testConnections() data.httpHeaders.insert( QStringLiteral( "my_header" ), QStringLiteral( "value" ) ); QgsSensorThingsProviderConnection::addConnection( QStringLiteral( "my connection" ), data ); - QCOMPARE( QgsSensorThingsProviderConnection::connectionList(), {QStringLiteral( "my connection" )} ); + QCOMPARE( QgsSensorThingsProviderConnection::connectionList(), { QStringLiteral( "my connection" ) } ); QCOMPARE( QgsSensorThingsProviderConnection::connection( QStringLiteral( "my connection" ) ).url, QStringLiteral( "http://testurl" ) ); diff --git a/tests/src/core/testqgssettings.cpp b/tests/src/core/testqgssettings.cpp index 5e2093f85728..cdc74abd9ec7 100644 --- a/tests/src/core/testqgssettings.cpp +++ b/tests/src/core/testqgssettings.cpp @@ -45,7 +45,7 @@ void TestQgsSettings::enumValue() QVERIFY( static_cast( Qgis::LayoutUnit::Meters ) != -1 ); // standard method returns invalid value - const int v1 = settings.value( QStringLiteral( "qgis/testing/my_value_for_units" ), static_cast< int >( Qgis::LayoutUnit::Meters ) ).toInt(); + const int v1 = settings.value( QStringLiteral( "qgis/testing/my_value_for_units" ), static_cast( Qgis::LayoutUnit::Meters ) ).toInt(); QCOMPARE( v1, -1 ); // enum method returns default value if current setting is incorrect @@ -55,7 +55,7 @@ void TestQgsSettings::enumValue() QCOMPARE( v2s, Qgis::LayoutUnit::Meters ); // test a different value than default - settings.setValue( QStringLiteral( "qgis/testing/my_value_for_units" ), static_cast< int >( Qgis::LayoutUnit::Centimeters ) ); + settings.setValue( QStringLiteral( "qgis/testing/my_value_for_units" ), static_cast( Qgis::LayoutUnit::Centimeters ) ); const Qgis::LayoutUnit v3 = settings.enumValue( QStringLiteral( "qgis/testing/my_value_for_units" ), Qgis::LayoutUnit::Meters ); QCOMPARE( v3, Qgis::LayoutUnit::Centimeters ); settings.setEnumValue( QStringLiteral( "qgis/testing/my_value_for_units" ), Qgis::LayoutUnit::Centimeters ); diff --git a/tests/src/core/testqgssettingsentry.cpp b/tests/src/core/testqgssettingsentry.cpp index 11508439e707..c13d1c925381 100644 --- a/tests/src/core/testqgssettingsentry.cpp +++ b/tests/src/core/testqgssettingsentry.cpp @@ -111,11 +111,11 @@ void TestQgsSettingsEntry::enumValue() } // check that value is stored as string - QCOMPARE( settingsEntryEnum.valueAsVariant().toString(), QMetaEnum::fromType().key( static_cast< int >( Qgis::LayoutUnit::Picas ) ) ); + QCOMPARE( settingsEntryEnum.valueAsVariant().toString(), QMetaEnum::fromType().key( static_cast( Qgis::LayoutUnit::Picas ) ) ); // auto conversion of old settings (int to str) QSettings().setValue( QStringLiteral( "%1/%2" ).arg( mSettingsSection, settingsKey ), static_cast( Qgis::LayoutUnit::Centimeters ) ); - QCOMPARE( settingsEntryEnum.valueAsVariant().toInt(), static_cast< int >( Qgis::LayoutUnit::Centimeters ) ); + QCOMPARE( settingsEntryEnum.valueAsVariant().toInt(), static_cast( Qgis::LayoutUnit::Centimeters ) ); QCOMPARE( settingsEntryEnum.value(), Qgis::LayoutUnit::Centimeters ); // save as int instead of string diff --git a/tests/src/core/testqgssettingsregistry.cpp b/tests/src/core/testqgssettingsregistry.cpp index f305d9eae299..ab0d42274776 100644 --- a/tests/src/core/testqgssettingsregistry.cpp +++ b/tests/src/core/testqgssettingsregistry.cpp @@ -25,7 +25,6 @@ Q_NOWARN_DEPRECATED_PUSH class SettingsRegistryTest : public QgsSettingsRegistry { public: - void addSettingsEntry( const QgsSettingsEntryBase *settingsEntry ) { QgsSettingsRegistry::addSettingsEntry( settingsEntry ); diff --git a/tests/src/core/testqgsshapeburst.cpp b/tests/src/core/testqgsshapeburst.cpp index ba4f8cc26ebf..4e71d9a5949f 100644 --- a/tests/src/core/testqgsshapeburst.cpp +++ b/tests/src/core/testqgsshapeburst.cpp @@ -44,11 +44,12 @@ class TestQgsShapeburst : public QgsTest { Q_OBJECT public: - TestQgsShapeburst() : QgsTest( QStringLiteral( "Shapeburst Renderer Tests" ) ) {} + TestQgsShapeburst() + : QgsTest( QStringLiteral( "Shapeburst Renderer Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void shapeburstSymbol(); void shapeburstSymbolColors(); @@ -60,7 +61,7 @@ class TestQgsShapeburst : public QgsTest void shapeburstSymbolFromQml(); private: - bool mTestHasError = false ; + bool mTestHasError = false; bool setQml( const QString &type ); bool imageCheck( const QString &type ); QgsMapSettings mMapSettings; @@ -89,8 +90,7 @@ void TestQgsShapeburst::initTestCase() // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsVectorSimplifyMethod simplifyMethod; simplifyMethod.setSimplifyHints( Qgis::VectorRenderingSimplificationFlags() ); @@ -98,7 +98,8 @@ void TestQgsShapeburst::initTestCase() // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPolysLayer ); + QList() << mpPolysLayer + ); //setup shapeburst fill mShapeburstFill = new QgsShapeburstFillSymbolLayer(); @@ -112,7 +113,6 @@ void TestQgsShapeburst::initTestCase() // and is more light weight // mMapSettings.setLayers( QList() << mpPolysLayer ); - } void TestQgsShapeburst::cleanupTestCase() { @@ -139,7 +139,6 @@ void TestQgsShapeburst::shapeburstSymbolColors() void TestQgsShapeburst::shapeburstSymbolRamp() { - QgsGradientColorRamp *gradientRamp = new QgsGradientColorRamp( QColor( Qt::yellow ), QColor( 255, 105, 180 ) ); QgsGradientStopsList stops; stops.append( QgsGradientStop( 0.5, QColor( 255, 255, 255, 0 ) ) ); diff --git a/tests/src/core/testqgssimplemarker.cpp b/tests/src/core/testqgssimplemarker.cpp index b1c70648264c..049e8b26625d 100644 --- a/tests/src/core/testqgssimplemarker.cpp +++ b/tests/src/core/testqgssimplemarker.cpp @@ -43,14 +43,14 @@ class TestQgsSimpleMarkerSymbol : public QgsTest Q_OBJECT public: - TestQgsSimpleMarkerSymbol() : QgsTest( QStringLiteral( "Simple Marker Tests" ), - QStringLiteral( "symbol_simplemarker" ) ) {} + TestQgsSimpleMarkerSymbol() + : QgsTest( QStringLiteral( "Simple Marker Tests" ), QStringLiteral( "symbol_simplemarker" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void decodeShape_data(); void decodeShape(); @@ -82,7 +82,7 @@ class TestQgsSimpleMarkerSymbol : public QgsTest void dataDefinedOpacity(); private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings mMapSettings; QgsVectorLayer *mpPointsLayer = nullptr; @@ -110,12 +110,12 @@ void TestQgsSimpleMarkerSymbol::initTestCase() // const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPointsLayer ); + QList() << mpPointsLayer + ); //setup symbol mSimpleMarkerLayer = new QgsSimpleMarkerSymbolLayer(); @@ -143,46 +143,46 @@ void TestQgsSimpleMarkerSymbol::decodeShape_data() QTest::addColumn( "shape" ); QTest::addColumn( "ok" ); - QTest::newRow( "empty string" ) << "" << static_cast< int >( Qgis::MarkerShape::Circle ) << false; - QTest::newRow( "invalid character" ) << "@" << static_cast< int >( Qgis::MarkerShape::Circle ) << false; - QTest::newRow( "square" ) << "square" << static_cast< int >( Qgis::MarkerShape::Square ) << true; - QTest::newRow( "square case" ) << "SQUARE" << static_cast< int >( Qgis::MarkerShape::Square ) << true; - QTest::newRow( "square case spaces" ) << " SQUARE " << static_cast< int >( Qgis::MarkerShape::Square ) << true; - QTest::newRow( "square_with_corners" ) << "square_with_corners" << static_cast< int >( Qgis::MarkerShape::SquareWithCorners ) << true; - QTest::newRow( "shield" ) << "shield" << static_cast< int >( Qgis::MarkerShape::Shield ) << true; - QTest::newRow( "rounded_square" ) << "rounded_square" << static_cast< int >( Qgis::MarkerShape::RoundedSquare ) << true; - QTest::newRow( "trapezoid" ) << "trapezoid" << static_cast< int >( Qgis::MarkerShape::Trapezoid ) << true; - QTest::newRow( "parallelogram_left" ) << "parallelogram_left" << static_cast< int >( Qgis::MarkerShape::ParallelogramLeft ) << true; - QTest::newRow( "rectangle" ) << "rectangle" << static_cast< int >( Qgis::MarkerShape::Square ) << true; - QTest::newRow( "diamond" ) << "diamond" << static_cast< int >( Qgis::MarkerShape::Diamond ) << true; - QTest::newRow( "pentagon" ) << "pentagon" << static_cast< int >( Qgis::MarkerShape::Pentagon ) << true; - QTest::newRow( "hexagon" ) << "hexagon" << static_cast< int >( Qgis::MarkerShape::Hexagon ) << true; - QTest::newRow( "octagon" ) << "octagon" << static_cast< int >( Qgis::MarkerShape::Octagon ) << true; - QTest::newRow( "decagon" ) << "decagon" << static_cast< int >( Qgis::MarkerShape::Decagon ) << true; - QTest::newRow( "triangle" ) << "triangle" << static_cast< int >( Qgis::MarkerShape::Triangle ) << true; - QTest::newRow( "equilateral_triangle" ) << "equilateral_triangle" << static_cast< int >( Qgis::MarkerShape::EquilateralTriangle ) << true; - QTest::newRow( "star_diamond" ) << "star_diamond" << static_cast< int >( Qgis::MarkerShape::DiamondStar ) << true; - QTest::newRow( "star" ) << "star" << static_cast< int >( Qgis::MarkerShape::Star ) << true; - QTest::newRow( "regular_star" ) << "regular_star" << static_cast< int >( Qgis::MarkerShape::Star ) << true; - QTest::newRow( "heart" ) << "heart" << static_cast< int >( Qgis::MarkerShape::Heart ) << true; - QTest::newRow( "arrow" ) << "arrow" << static_cast< int >( Qgis::MarkerShape::Arrow ) << true; - QTest::newRow( "circle" ) << "circle" << static_cast< int >( Qgis::MarkerShape::Circle ) << true; - QTest::newRow( "cross" ) << "cross" << static_cast< int >( Qgis::MarkerShape::Cross ) << true; - QTest::newRow( "cross_fill" ) << "cross_fill" << static_cast< int >( Qgis::MarkerShape::CrossFill ) << true; - QTest::newRow( "cross2" ) << "cross2" << static_cast< int >( Qgis::MarkerShape::Cross2 ) << true; - QTest::newRow( "x" ) << "x" << static_cast< int >( Qgis::MarkerShape::Cross2 ) << true; - QTest::newRow( "line" ) << "line" << static_cast< int >( Qgis::MarkerShape::Line ) << true; - QTest::newRow( "arrowhead" ) << "arrowhead" << static_cast< int >( Qgis::MarkerShape::ArrowHead ) << true; - QTest::newRow( "filled_arrowhead" ) << "filled_arrowhead" << static_cast< int >( Qgis::MarkerShape::ArrowHeadFilled ) << true; - QTest::newRow( "semi_circle" ) << "semi_circle" << static_cast< int >( Qgis::MarkerShape::SemiCircle ) << true; - QTest::newRow( "third_circle" ) << "third_circle" << static_cast< int >( Qgis::MarkerShape::ThirdCircle ) << true; - QTest::newRow( "quarter_circle" ) << "quarter_circle" << static_cast< int >( Qgis::MarkerShape::QuarterCircle ) << true; - QTest::newRow( "quarter_square" ) << "quarter_square" << static_cast< int >( Qgis::MarkerShape::QuarterSquare ) << true; - QTest::newRow( "half_square" ) << "half_square" << static_cast< int >( Qgis::MarkerShape::HalfSquare ) << true; - QTest::newRow( "diagonal_half_square" ) << "diagonal_half_square" << static_cast< int >( Qgis::MarkerShape::DiagonalHalfSquare ) << true; - QTest::newRow( "right_half_triangle" ) << "right_half_triangle" << static_cast< int >( Qgis::MarkerShape::RightHalfTriangle ) << true; - QTest::newRow( "left_half_triangle" ) << "left_half_triangle" << static_cast< int >( Qgis::MarkerShape::LeftHalfTriangle ) << true; - QTest::newRow( "asterisk_fill" ) << "asterisk_fill" << static_cast< int >( Qgis::MarkerShape::AsteriskFill ) << true; + QTest::newRow( "empty string" ) << "" << static_cast( Qgis::MarkerShape::Circle ) << false; + QTest::newRow( "invalid character" ) << "@" << static_cast( Qgis::MarkerShape::Circle ) << false; + QTest::newRow( "square" ) << "square" << static_cast( Qgis::MarkerShape::Square ) << true; + QTest::newRow( "square case" ) << "SQUARE" << static_cast( Qgis::MarkerShape::Square ) << true; + QTest::newRow( "square case spaces" ) << " SQUARE " << static_cast( Qgis::MarkerShape::Square ) << true; + QTest::newRow( "square_with_corners" ) << "square_with_corners" << static_cast( Qgis::MarkerShape::SquareWithCorners ) << true; + QTest::newRow( "shield" ) << "shield" << static_cast( Qgis::MarkerShape::Shield ) << true; + QTest::newRow( "rounded_square" ) << "rounded_square" << static_cast( Qgis::MarkerShape::RoundedSquare ) << true; + QTest::newRow( "trapezoid" ) << "trapezoid" << static_cast( Qgis::MarkerShape::Trapezoid ) << true; + QTest::newRow( "parallelogram_left" ) << "parallelogram_left" << static_cast( Qgis::MarkerShape::ParallelogramLeft ) << true; + QTest::newRow( "rectangle" ) << "rectangle" << static_cast( Qgis::MarkerShape::Square ) << true; + QTest::newRow( "diamond" ) << "diamond" << static_cast( Qgis::MarkerShape::Diamond ) << true; + QTest::newRow( "pentagon" ) << "pentagon" << static_cast( Qgis::MarkerShape::Pentagon ) << true; + QTest::newRow( "hexagon" ) << "hexagon" << static_cast( Qgis::MarkerShape::Hexagon ) << true; + QTest::newRow( "octagon" ) << "octagon" << static_cast( Qgis::MarkerShape::Octagon ) << true; + QTest::newRow( "decagon" ) << "decagon" << static_cast( Qgis::MarkerShape::Decagon ) << true; + QTest::newRow( "triangle" ) << "triangle" << static_cast( Qgis::MarkerShape::Triangle ) << true; + QTest::newRow( "equilateral_triangle" ) << "equilateral_triangle" << static_cast( Qgis::MarkerShape::EquilateralTriangle ) << true; + QTest::newRow( "star_diamond" ) << "star_diamond" << static_cast( Qgis::MarkerShape::DiamondStar ) << true; + QTest::newRow( "star" ) << "star" << static_cast( Qgis::MarkerShape::Star ) << true; + QTest::newRow( "regular_star" ) << "regular_star" << static_cast( Qgis::MarkerShape::Star ) << true; + QTest::newRow( "heart" ) << "heart" << static_cast( Qgis::MarkerShape::Heart ) << true; + QTest::newRow( "arrow" ) << "arrow" << static_cast( Qgis::MarkerShape::Arrow ) << true; + QTest::newRow( "circle" ) << "circle" << static_cast( Qgis::MarkerShape::Circle ) << true; + QTest::newRow( "cross" ) << "cross" << static_cast( Qgis::MarkerShape::Cross ) << true; + QTest::newRow( "cross_fill" ) << "cross_fill" << static_cast( Qgis::MarkerShape::CrossFill ) << true; + QTest::newRow( "cross2" ) << "cross2" << static_cast( Qgis::MarkerShape::Cross2 ) << true; + QTest::newRow( "x" ) << "x" << static_cast( Qgis::MarkerShape::Cross2 ) << true; + QTest::newRow( "line" ) << "line" << static_cast( Qgis::MarkerShape::Line ) << true; + QTest::newRow( "arrowhead" ) << "arrowhead" << static_cast( Qgis::MarkerShape::ArrowHead ) << true; + QTest::newRow( "filled_arrowhead" ) << "filled_arrowhead" << static_cast( Qgis::MarkerShape::ArrowHeadFilled ) << true; + QTest::newRow( "semi_circle" ) << "semi_circle" << static_cast( Qgis::MarkerShape::SemiCircle ) << true; + QTest::newRow( "third_circle" ) << "third_circle" << static_cast( Qgis::MarkerShape::ThirdCircle ) << true; + QTest::newRow( "quarter_circle" ) << "quarter_circle" << static_cast( Qgis::MarkerShape::QuarterCircle ) << true; + QTest::newRow( "quarter_square" ) << "quarter_square" << static_cast( Qgis::MarkerShape::QuarterSquare ) << true; + QTest::newRow( "half_square" ) << "half_square" << static_cast( Qgis::MarkerShape::HalfSquare ) << true; + QTest::newRow( "diagonal_half_square" ) << "diagonal_half_square" << static_cast( Qgis::MarkerShape::DiagonalHalfSquare ) << true; + QTest::newRow( "right_half_triangle" ) << "right_half_triangle" << static_cast( Qgis::MarkerShape::RightHalfTriangle ) << true; + QTest::newRow( "left_half_triangle" ) << "left_half_triangle" << static_cast( Qgis::MarkerShape::LeftHalfTriangle ) << true; + QTest::newRow( "asterisk_fill" ) << "asterisk_fill" << static_cast( Qgis::MarkerShape::AsteriskFill ) << true; } void TestQgsSimpleMarkerSymbol::decodeShape() @@ -192,11 +192,11 @@ void TestQgsSimpleMarkerSymbol::decodeShape() QFETCH( bool, ok ); bool res = false; - QCOMPARE( static_cast< int >( QgsSimpleMarkerSymbolLayerBase::decodeShape( string, &res ) ), shape ); + QCOMPARE( static_cast( QgsSimpleMarkerSymbolLayerBase::decodeShape( string, &res ) ), shape ); QCOMPARE( res, ok ); // round trip through encode - QCOMPARE( static_cast< int >( QgsSimpleMarkerSymbolLayerBase::decodeShape( QgsSimpleMarkerSymbolLayerBase::encodeShape( static_cast< Qgis::MarkerShape >( shape ) ) ) ), shape ); + QCOMPARE( static_cast( QgsSimpleMarkerSymbolLayerBase::decodeShape( QgsSimpleMarkerSymbolLayerBase::encodeShape( static_cast( shape ) ) ) ), shape ); } void TestQgsSimpleMarkerSymbol::simpleMarkerSymbol() @@ -247,7 +247,7 @@ void TestQgsSimpleMarkerSymbol::simpleMarkerSymbolPreviewRotation_data() QTest::addColumn( "angle" ); QTest::addColumn( "expression" ); - QTest::newRow( "field_based" ) << QStringLiteral( "field_based" ) << 20. << QStringLiteral( "orientation" ); // Should fallback to 20 because orientation is not available + QTest::newRow( "field_based" ) << QStringLiteral( "field_based" ) << 20. << QStringLiteral( "orientation" ); // Should fallback to 20 because orientation is not available QTest::newRow( "static_expression" ) << QStringLiteral( "static_expression" ) << 20. << QStringLiteral( "40" ); // Should use 40 because expression has precedence } @@ -261,7 +261,6 @@ void TestQgsSimpleMarkerSymbol::simpleMarkerSymbolBevelJoin() mSimpleMarkerLayer->setStrokeWidth( 3 ); mSimpleMarkerLayer->setPenJoinStyle( Qt::BevelJoin ); QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "simplemarker_beveljoin" ), QStringLiteral( "simplemarker_beveljoin" ), mMapSettings ); - } void TestQgsSimpleMarkerSymbol::simpleMarkerSymbolMiterJoin() @@ -350,7 +349,6 @@ void TestQgsSimpleMarkerSymbol::simpleMarkerSquareWithCorners() mSimpleMarkerLayer->setStrokeWidth( 2 ); mSimpleMarkerLayer->setPenJoinStyle( Qt::MiterJoin ); QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "simplemarker_square_with_corners" ), QStringLiteral( "simplemarker_square_with_corners" ), mMapSettings ); - } void TestQgsSimpleMarkerSymbol::simpleMarkerRoundedSquare() diff --git a/tests/src/core/testqgssimplifymethod.cpp b/tests/src/core/testqgssimplifymethod.cpp index f1a2ca09edb0..2f7e50f18ce7 100644 --- a/tests/src/core/testqgssimplifymethod.cpp +++ b/tests/src/core/testqgssimplifymethod.cpp @@ -23,17 +23,17 @@ #include "qgssimplifymethod.h" -class TestQgsSimplifyMethod: public QObject +class TestQgsSimplifyMethod : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void testCreate();//test creating a simplify method - void testEqualityInequality();//test equality operator + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void testCreate(); //test creating a simplify method + void testEqualityInequality(); //test equality operator private: }; @@ -48,7 +48,6 @@ void TestQgsSimplifyMethod::initTestCase() void TestQgsSimplifyMethod::cleanupTestCase() { - } void TestQgsSimplifyMethod::init() diff --git a/tests/src/core/testqgssnappingutils.cpp b/tests/src/core/testqgssnappingutils.cpp index 31f6dc759e64..00c8c731eeea 100644 --- a/tests/src/core/testqgssnappingutils.cpp +++ b/tests/src/core/testqgssnappingutils.cpp @@ -31,11 +31,12 @@ struct FilterExcludePoint : public QgsPointLocator::MatchFilter { - explicit FilterExcludePoint( const QgsPointXY &p ) : mPoint( p ) {} + explicit FilterExcludePoint( const QgsPointXY &p ) + : mPoint( p ) {} - bool acceptMatch( const QgsPointLocator::Match &match ) override { return match.point() != mPoint; } + bool acceptMatch( const QgsPointLocator::Match &match ) override { return match.point() != mPoint; } - QgsPointXY mPoint; + QgsPointXY mPoint; }; @@ -83,7 +84,6 @@ class TestQgsSnappingUtils : public QObject mVL->dataProvider()->addFeatures( flist ); QgsProject::instance()->addMapLayer( mVL ); - } void cleanupTestCase() @@ -197,7 +197,7 @@ class TestQgsSnappingUtils : public QObject QCOMPARE( m5.point(), QgsPointXY( 0, 1 ) ); //uncheck all and test that all nodes are unchecked - static_cast< QgsSymbolLegendNode * >( nodes.at( 0 ) )->uncheckAllItems(); + static_cast( nodes.at( 0 ) )->uncheckAllItems(); for ( QgsLayerTreeModelLegendNode *ln : nodes ) { QVERIFY( ln->data( Qt::CheckStateRole ) == Qt::Unchecked ); @@ -276,7 +276,7 @@ class TestQgsSnappingUtils : public QObject polyline1 << QgsPointXY( 0, 0 ) << QgsPointXY( 1, 1 ); polyline2 << QgsPointXY( 1, 0 ) << QgsPointXY( 0, 1 ); QgsFeature f1; - const QgsGeometry f1g = QgsGeometry::fromPolylineXY( polyline1 ) ; + const QgsGeometry f1g = QgsGeometry::fromPolylineXY( polyline1 ); f1.setGeometry( f1g ); QgsFeature f2; const QgsGeometry f2g = QgsGeometry::fromPolylineXY( polyline2 ); @@ -321,7 +321,7 @@ class TestQgsSnappingUtils : public QObject // testing with a layer with curve and Z std::unique_ptr vCurveZ( new QgsVectorLayer( QStringLiteral( "CircularStringZ" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ) ); QgsFeature f1; - const QgsGeometry f1g = QgsGeometry::fromWkt( "CircularStringZ (0 0 0, 5 5 5, 0 10 10)" ) ; + const QgsGeometry f1g = QgsGeometry::fromWkt( "CircularStringZ (0 0 0, 5 5 5, 0 10 10)" ); f1.setGeometry( f1g ); QgsFeature f2; const QgsGeometry f2g = QgsGeometry::fromWkt( "CircularStringZ (8 0 20, 5 3 30, 8 10 40)" ); @@ -371,7 +371,7 @@ class TestQgsSnappingUtils : public QObject f2.setGeometry( f2g ); QgsFeatureList flist; - flist << f1 << f2 ; + flist << f1 << f2; vMulti->dataProvider()->addFeatures( flist ); QVERIFY( vMulti->dataProvider()->featureCount() == 2 ); @@ -400,7 +400,6 @@ class TestQgsSnappingUtils : public QObject QVERIFY( m2.isValid() ); QCOMPARE( m2.type(), QgsPointLocator::Vertex ); QCOMPARE( m2.point(), QgsPointXY( 5.0, 2.5 ) ); - } void testSnapOnCentroidAndMiddleSegment() { @@ -730,8 +729,8 @@ class TestQgsSnappingUtils : public QObject QVERIFY( m1.hasVertex() ); snappingConfig.setScaleDependencyMode( QgsSnappingConfig::Global ); - snappingConfig.setMinimumScale( 10000.0 );// 1/10000 scale - snappingConfig.setMaximumScale( 1000.0 );// 1/1000 scale + snappingConfig.setMinimumScale( 10000.0 ); // 1/10000 scale + snappingConfig.setMaximumScale( 1000.0 ); // 1/1000 scale u.setConfig( snappingConfig ); //Global settings for scale limit, but scale outside min max range -> no snapping diff --git a/tests/src/core/testqgsspatialindex.cpp b/tests/src/core/testqgsspatialindex.cpp index 73c1763fd2d1..149038dd6baf 100644 --- a/tests/src/core/testqgsspatialindex.cpp +++ b/tests/src/core/testqgsspatialindex.cpp @@ -45,10 +45,10 @@ static QList _pointFeatures() */ QList feats; - feats << _pointFeature( 1, 1, 1 ) - << _pointFeature( 2, -1, 1 ) + feats << _pointFeature( 1, 1, 1 ) + << _pointFeature( 2, -1, 1 ) << _pointFeature( 3, -1, -1 ) - << _pointFeature( 4, 1, -1 ); + << _pointFeature( 4, 1, -1 ); return feats; } @@ -248,8 +248,8 @@ class TestQgsSpatialIndex : public QObject void bulkLoadWithCallback() { - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); - QList< QgsFeatureId > addedIds; + std::unique_ptr vl = std::make_unique( QStringLiteral( "Point" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); + QList addedIds; for ( int i = 0; i < 10; ++i ) { QgsFeature f( i ); @@ -261,8 +261,7 @@ class TestQgsSpatialIndex : public QObject QCOMPARE( vl->featureCount(), 10L ); QgsFeatureIds ids; - const QgsSpatialIndex i( vl->getFeatures(), [ & ]( const QgsFeature & f )->bool - { + const QgsSpatialIndex i( vl->getFeatures(), [&]( const QgsFeature &f ) -> bool { ids.insert( f.id() ); return true; } ); @@ -278,8 +277,7 @@ class TestQgsSpatialIndex : public QObject // try canceling ids.clear(); - const QgsSpatialIndex i2( vl->getFeatures(), [ & ]( const QgsFeature & f )->bool - { + const QgsSpatialIndex i2( vl->getFeatures(), [&]( const QgsFeature &f ) -> bool { ids.insert( f.id() ); return false; } ); @@ -301,7 +299,7 @@ class TestQgsSpatialIndex : public QObject for ( int y = 100; y < 110; ++y ) { QgsFeature f( fid++ ); - f.setGeometry( std::make_unique< QgsLineString >( QgsPoint( x, y ), QgsPoint( x + 0.5, y - 0.5 ) ) ); + f.setGeometry( std::make_unique( QgsPoint( x, y ), QgsPoint( x + 0.5, y - 0.5 ) ) ); flist << f; } vl->dataProvider()->addFeatures( flist ); @@ -382,66 +380,63 @@ class TestQgsSpatialIndex : public QObject i2.addFeature( f3 ); // i does not store feature geometries, so nearest neighbour search uses bounding box only - QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1 ), QList< QgsFeatureId >() << 1 ); - QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2 ), QList< QgsFeatureId >() << 1 << 3 ); + QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1 ), QList() << 1 ); + QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2 ), QList() << 1 << 3 ); // i2 does store feature geometries, so nearest neighbour is exact - QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1 ), QList< QgsFeatureId >() << 2 ); - QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2 ), QList< QgsFeatureId >() << 2 << 3 ); + QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1 ), QList() << 2 ); + QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2 ), QList() << 2 << 3 ); // with maximum distance - QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 0.5 ), QList< QgsFeatureId >() << 1 ); - QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 0.5 ), QList< QgsFeatureId >() ); - QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 0.5 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 0.5 ), QList< QgsFeatureId >() ); - QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 1.1 ), QList< QgsFeatureId >() << 1 ); - QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 1.1 ), QList< QgsFeatureId >() << 2 ); - QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 1.1 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 1.1 ), QList< QgsFeatureId >() << 2 ); - QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 2 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 2 ), QList< QgsFeatureId >() << 2 << 3 ); + QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 0.5 ), QList() << 1 ); + QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 0.5 ), QList() ); + QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 0.5 ), QList() << 1 << 3 ); + QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 0.5 ), QList() ); + QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 1.1 ), QList() << 1 ); + QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 1, 1.1 ), QList() << 2 ); + QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 1.1 ), QList() << 1 << 3 ); + QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 1.1 ), QList() << 2 ); + QCOMPARE( i.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 2 ), QList() << 1 << 3 ); + QCOMPARE( i2.nearestNeighbor( QgsPointXY( 1, 2.9 ), 2, 2 ), QList() << 2 << 3 ); // using geometries as input, not points QgsGeometry g = QgsGeometry::fromWkt( QStringLiteral( "LineString (1 0, 1 -1, -2 -1, -2 7, 5 4, 5 0)" ) ); - QCOMPARE( i2.nearestNeighbor( g, 1 ), QList< QgsFeatureId >() << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 2 ), QList< QgsFeatureId >() << 3 << 1 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList< QgsFeatureId >() << 3 << 1 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList< QgsFeatureId >() ); + QCOMPARE( i2.nearestNeighbor( g, 1 ), QList() << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 2 ), QList() << 3 << 1 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList() << 3 << 1 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList() ); g = QgsGeometry::fromWkt( QStringLiteral( "LineString (3 7, 3 6, 5 6, 4 2)" ) ); - QCOMPARE( i.nearestNeighbor( g, 1 ), QList< QgsFeatureId >() << 1 << 3 ); // bounding box search only - QCOMPARE( i.nearestNeighbor( g, 2 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i.nearestNeighbor( g, 2, 1.1 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i.nearestNeighbor( g, 2, 0.2 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 1 ), QList< QgsFeatureId >() << 1 ); - QCOMPARE( i2.nearestNeighbor( g, 2 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList< QgsFeatureId >() << 1 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList< QgsFeatureId >() ); + QCOMPARE( i.nearestNeighbor( g, 1 ), QList() << 1 << 3 ); // bounding box search only + QCOMPARE( i.nearestNeighbor( g, 2 ), QList() << 1 << 3 ); + QCOMPARE( i.nearestNeighbor( g, 2, 1.1 ), QList() << 1 << 3 ); + QCOMPARE( i.nearestNeighbor( g, 2, 0.2 ), QList() << 1 << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 1 ), QList() << 1 ); + QCOMPARE( i2.nearestNeighbor( g, 2 ), QList() << 1 << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList() << 1 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList() ); g = QgsGeometry::fromWkt( QStringLiteral( "Polygon ((2 3, -3 4, 1 7, 6 6, 6 1, 3 4, 2 3))" ) ); - QCOMPARE( i.nearestNeighbor( g, 1 ), QList< QgsFeatureId >() << 1 << 2 << 3 ); // bounding box search only - QCOMPARE( i.nearestNeighbor( g, 2 ), QList< QgsFeatureId >() << 1 << 2 << 3 ); - QCOMPARE( i.nearestNeighbor( g, 2, 1.1 ), QList< QgsFeatureId >() << 1 << 2 << 3 ); - QCOMPARE( i.nearestNeighbor( g, 2, 0.2 ), QList< QgsFeatureId >() << 1 << 2 << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 1 ), QList< QgsFeatureId >() << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 2 ), QList< QgsFeatureId >() << 3 << 2 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList< QgsFeatureId >() << 3 << 2 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList< QgsFeatureId >() << 3 ); + QCOMPARE( i.nearestNeighbor( g, 1 ), QList() << 1 << 2 << 3 ); // bounding box search only + QCOMPARE( i.nearestNeighbor( g, 2 ), QList() << 1 << 2 << 3 ); + QCOMPARE( i.nearestNeighbor( g, 2, 1.1 ), QList() << 1 << 2 << 3 ); + QCOMPARE( i.nearestNeighbor( g, 2, 0.2 ), QList() << 1 << 2 << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 1 ), QList() << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 2 ), QList() << 3 << 2 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList() << 3 << 2 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList() << 3 ); g = QgsGeometry::fromWkt( QStringLiteral( "MultiPoint (1.5 2.5, 3 4.5)" ) ); - QCOMPARE( i.nearestNeighbor( g, 1 ), QList< QgsFeatureId >() << 1 << 3 ); // bounding box search only - QCOMPARE( i.nearestNeighbor( g, 2 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i.nearestNeighbor( g, 2, 1.1 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i.nearestNeighbor( g, 2, 0.2 ), QList< QgsFeatureId >() << 1 << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 1 ), QList< QgsFeatureId >() << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 2 ), QList< QgsFeatureId >() << 3 << 2 << 1 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList< QgsFeatureId >() << 3 ); - QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList< QgsFeatureId >() ); + QCOMPARE( i.nearestNeighbor( g, 1 ), QList() << 1 << 3 ); // bounding box search only + QCOMPARE( i.nearestNeighbor( g, 2 ), QList() << 1 << 3 ); + QCOMPARE( i.nearestNeighbor( g, 2, 1.1 ), QList() << 1 << 3 ); + QCOMPARE( i.nearestNeighbor( g, 2, 0.2 ), QList() << 1 << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 1 ), QList() << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 2 ), QList() << 3 << 2 << 1 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 1.1 ), QList() << 3 ); + QCOMPARE( i2.nearestNeighbor( g, 2, 0.2 ), QList() ); } - }; QGSTEST_MAIN( TestQgsSpatialIndex ) #include "testqgsspatialindex.moc" - - diff --git a/tests/src/core/testqgsspatialindexkdbush.cpp b/tests/src/core/testqgsspatialindexkdbush.cpp index bc6c3366863a..f6c0dde86f3f 100644 --- a/tests/src/core/testqgsspatialindexkdbush.cpp +++ b/tests/src/core/testqgsspatialindexkdbush.cpp @@ -44,10 +44,10 @@ static QList _pointFeatures() */ QList feats; - feats << _pointFeature( 1, 1, 1 ) - << _pointFeature( 2, -1, 1 ) + feats << _pointFeature( 1, 1, 1 ) + << _pointFeature( 2, -1, 1 ) << _pointFeature( 3, -1, -1 ) - << _pointFeature( 4, 1, -1 ); + << _pointFeature( 4, 1, -1 ); return feats; } @@ -81,7 +81,7 @@ class TestQgsSpatialIndexKdBush : public QObject void testQuery() { - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( "Point", QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( "Point", QString(), QStringLiteral( "memory" ) ); for ( QgsFeature f : _pointFeatures() ) vl->dataProvider()->addFeature( f ); const QgsSpatialIndexKDBush index( *vl->dataProvider() ); @@ -115,14 +115,14 @@ class TestQgsSpatialIndexKdBush : public QObject void testCopy() { - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( "Point", QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( "Point", QString(), QStringLiteral( "memory" ) ); for ( QgsFeature f : _pointFeatures() ) vl->dataProvider()->addFeature( f ); - std::unique_ptr< QgsSpatialIndexKDBush > index( new QgsSpatialIndexKDBush( *vl->dataProvider() ) ); + std::unique_ptr index( new QgsSpatialIndexKDBush( *vl->dataProvider() ) ); // create copy of the index - std::unique_ptr< QgsSpatialIndexKDBush > indexCopy( new QgsSpatialIndexKDBush( *index ) ); + std::unique_ptr indexCopy( new QgsSpatialIndexKDBush( *index ) ); QVERIFY( index->d == indexCopy->d ); QVERIFY( index->d->ref == 2 ); @@ -145,7 +145,7 @@ class TestQgsSpatialIndexKdBush : public QObject QVERIFY( indexCopy->d->ref == 1 ); // assignment operator - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( "Point", QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl2 = std::make_unique( "Point", QString(), QStringLiteral( "memory" ) ); QgsSpatialIndexKDBush index3( *vl2->dataProvider() ); QVERIFY( index3.size() == 0 ); fids = index3.intersects( QgsRectangle( 0, 0, 10, 10 ) ); @@ -162,11 +162,8 @@ class TestQgsSpatialIndexKdBush : public QObject indexCopy.reset(); QVERIFY( index3.d->ref == 1 ); } - }; QGSTEST_MAIN( TestQgsSpatialIndexKdBush ) #include "testqgsspatialindexkdbush.moc" - - diff --git a/tests/src/core/testqgssqliteexpressioncompiler.cpp b/tests/src/core/testqgssqliteexpressioncompiler.cpp index f888fcc3a46e..8197d4512b5f 100644 --- a/tests/src/core/testqgssqliteexpressioncompiler.cpp +++ b/tests/src/core/testqgssqliteexpressioncompiler.cpp @@ -24,12 +24,11 @@ #include "qgsproject.h" #include "qgssqliteexpressioncompiler.h" -class TestQgsSQLiteExpressionCompiler: public QObject +class TestQgsSQLiteExpressionCompiler : public QObject { Q_OBJECT public: - TestQgsSQLiteExpressionCompiler() = default; QgsExpression makeExpression( const int length ); @@ -46,12 +45,10 @@ class TestQgsSQLiteExpressionCompiler: public QObject void testPlusWithStrings_data(); private: - QgsVectorLayer *mPointsLayer = nullptr; }; - QgsExpression TestQgsSQLiteExpressionCompiler::makeExpression( const int length ) { QStringList expString; @@ -103,7 +100,7 @@ void TestQgsSQLiteExpressionCompiler::testCompiler() exp = makeExpression( 3 ); QCOMPARE( compiler.compile( &exp ), QgsSqlExpressionCompiler::Result::Complete ); // Check that parenthesis matches - QCOMPARE( compiler.result().count( '(' ), compiler.result().count( ')' ) ); + QCOMPARE( compiler.result().count( '(' ), compiler.result().count( ')' ) ); QCOMPARE( compiler.result(), QStringLiteral( "((((\"Z\" >= 0) AND (\"Bottom\" <= 1)) OR ((\"Z\" >= 1) AND (\"Bottom\" <= 2))) OR ((\"Z\" >= 2) AND (\"Bottom\" <= 3)))" ) ); const QgsExpression ilike( QStringLiteral( "'a' ilike 'A'" ) ); @@ -127,7 +124,7 @@ void TestQgsSQLiteExpressionCompiler::testPreparedCachedNodes() QgsExpression exp( QStringLiteral( "\"Z\" = (1 + 2) OR \"z\" < (@static_var + 5)" ) ); QgsExpressionContext context; - std::unique_ptr< QgsExpressionContextScope > scope = std::make_unique< QgsExpressionContextScope >(); + std::unique_ptr scope = std::make_unique(); scope->setVariable( QStringLiteral( "static_var" ), 10, true ); context.appendScope( scope.release() ); // not possible to compile due to use of a variable @@ -178,7 +175,6 @@ void TestQgsSQLiteExpressionCompiler::testPlusWithStrings() } - QGSTEST_MAIN( TestQgsSQLiteExpressionCompiler ) #include "testqgssqliteexpressioncompiler.moc" diff --git a/tests/src/core/testqgssqliteutils.cpp b/tests/src/core/testqgssqliteutils.cpp index 9a2fa3e739e7..773f23a7b9d1 100644 --- a/tests/src/core/testqgssqliteutils.cpp +++ b/tests/src/core/testqgssqliteutils.cpp @@ -31,17 +31,16 @@ class TestQgsSqliteUtils : public QObject Q_OBJECT public: - TestQgsSqliteUtils() = default; private slots: // init / cleanup - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. // void initStyles(); void testPrintfAscii(); @@ -70,8 +69,6 @@ void TestQgsSqliteUtils::initTestCase() QCoreApplication::setOrganizationName( QStringLiteral( "QGIS" ) ); QCoreApplication::setOrganizationDomain( QStringLiteral( "qgis.org" ) ); QCoreApplication::setApplicationName( QStringLiteral( "QGIS-TEST" ) ); - - } void TestQgsSqliteUtils::cleanupTestCase() diff --git a/tests/src/core/testqgsstac.cpp b/tests/src/core/testqgsstac.cpp index d2b834dfab79..cbc0481aa534 100644 --- a/tests/src/core/testqgsstac.cpp +++ b/tests/src/core/testqgsstac.cpp @@ -42,10 +42,10 @@ class TestQgsStac : public QObject TestQgsStac() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testParseLocalCatalog(); void testParseLocalCollection(); @@ -78,7 +78,7 @@ void TestQgsStac::testParseLocalCatalog() QgsStacObject *obj = c.fetchStacObject( url.toString() ); QVERIFY( obj ); QCOMPARE( obj->type(), QgsStacObject::Type::Catalog ); - QgsStacCatalog *cat = dynamic_cast< QgsStacCatalog * >( obj ); + QgsStacCatalog *cat = dynamic_cast( obj ); QVERIFY( cat ); QCOMPARE( cat->id(), QLatin1String( "examples" ) ); @@ -108,7 +108,7 @@ void TestQgsStac::testParseLocalCollection() QgsStacObject *obj = c.fetchStacObject( url.toString() ); QVERIFY( obj ); QCOMPARE( obj->type(), QgsStacObject::Type::Collection ); - QgsStacCollection *col = dynamic_cast< QgsStacCollection * >( obj ); + QgsStacCollection *col = dynamic_cast( obj ); QVERIFY( col ); QCOMPARE( col->id(), QLatin1String( "simple-collection" ) ); diff --git a/tests/src/core/testqgsstackeddiagram.cpp b/tests/src/core/testqgsstackeddiagram.cpp index add44c566bec..1587017957a8 100644 --- a/tests/src/core/testqgsstackeddiagram.cpp +++ b/tests/src/core/testqgsstackeddiagram.cpp @@ -38,10 +38,11 @@ class TestQgsStackedDiagram : public QgsTest Q_OBJECT public: - TestQgsStackedDiagram() : QgsTest( QStringLiteral( "Stacked Diagram Tests" ), QStringLiteral( "stackeddiagrams" ) ) {} + TestQgsStackedDiagram() + : QgsTest( QStringLiteral( "Stacked Diagram Tests" ), QStringLiteral( "stackeddiagrams" ) ) {} private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings *mMapSettings = nullptr; QgsVectorLayer *mPointsLayer = nullptr; QString mTestDataDir; @@ -66,8 +67,7 @@ class TestQgsStackedDiagram : public QgsTest //create a point layer that will be used in all tests... // const QString myPointsFileName = mTestDataDir + "stacked_diagrams.gpkg|layername=centroids"; - mPointsLayer = new QgsVectorLayer( myPointsFileName, - QStringLiteral( "population" ), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( myPointsFileName, QStringLiteral( "population" ), QStringLiteral( "ogr" ) ); //Add points to diagrams, so that it's easier to also verify diagram positioning QVariantMap symbolProps { { QStringLiteral( "color" ), QStringLiteral( "0,0,0,0" ) } }; @@ -115,7 +115,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -146,7 +146,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -204,7 +204,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -236,7 +236,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -294,7 +294,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -328,7 +328,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -386,7 +386,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -417,7 +417,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -475,7 +475,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -506,7 +506,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -564,7 +564,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -597,7 +597,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -657,7 +657,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -690,7 +690,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -749,7 +749,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2 << col3 << col4; - ds.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -766,7 +766,7 @@ class TestQgsStackedDiagram : public QgsTest dr->setLowerSize( QSizeF( 0.0, 0.0 ) ); dr->setUpperValue( 15000 ); dr->setUpperSize( QSizeF( 20, 20 ) ); - dr->setClassificationField( QStringLiteral( "max( \"maennlich_6_17\", \"maennlich_18_64\", \"maennlich_ab_65\", \"maennlich_unter_6\" )" ) ); //#spellok + dr->setClassificationField( QStringLiteral( "max( \"maennlich_6_17\", \"maennlich_18_64\", \"maennlich_ab_65\", \"maennlich_unter_6\" )" ) ); //#spellok dr->setDiagram( new QgsHistogramDiagram() ); dr->setDiagramSettings( ds ); mPointsLayer->setDiagramRenderer( dr ); @@ -795,7 +795,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2 << col3 << col4; - ds.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -812,7 +812,7 @@ class TestQgsStackedDiagram : public QgsTest dr->setLowerSize( QSizeF( 0.0, 0.0 ) ); dr->setUpperValue( 15000 ); dr->setUpperSize( QSizeF( 20, 20 ) ); - dr->setClassificationField( QStringLiteral( "max(\"weiblich_unter_6\", \"weiblich_6_17\", \"weiblich_18_64\", \"weiblich_ab_65\")" ) ); //#spellok + dr->setClassificationField( QStringLiteral( "max(\"weiblich_unter_6\", \"weiblich_6_17\", \"weiblich_18_64\", \"weiblich_ab_65\")" ) ); //#spellok dr->setDiagram( new QgsHistogramDiagram() ); dr->setDiagramSettings( ds ); mPointsLayer->setDiagramRenderer( dr ); @@ -842,7 +842,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -868,7 +868,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -919,7 +919,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -945,7 +945,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -998,7 +998,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -1024,7 +1024,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -1076,7 +1076,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2 << col3 << col4; - ds.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -1116,7 +1116,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds.categoryColors = QList() << col1 << col2 << col3 << col4; - ds.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds.minimumScale = -1; ds.maximumScale = -1; ds.minimumSize = 0; @@ -1157,7 +1157,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds1.categoryColors = QList() << col1 << col2 << col3 << col4; - ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds1.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds1.minimumScale = -1; ds1.maximumScale = -1; ds1.minimumSize = 0; @@ -1183,7 +1183,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -1199,7 +1199,7 @@ class TestQgsStackedDiagram : public QgsTest dr2->setLowerSize( QSizeF( 0.0, 0.0 ) ); dr2->setUpperValue( 15000 ); dr2->setUpperSize( QSizeF( 20, 20 ) ); - dr2->setClassificationField( QStringLiteral( "max(\"maennlich_18_64\", \"maennlich_ab_65\", \"weiblich_unter_6\", \"weiblich_6_17\", \"weiblich_18_64\", \"weiblich_ab_65\")" ) ); //#spellok + dr2->setClassificationField( QStringLiteral( "max(\"maennlich_18_64\", \"maennlich_ab_65\", \"weiblich_unter_6\", \"weiblich_6_17\", \"weiblich_18_64\", \"weiblich_ab_65\")" ) ); //#spellok dr2->setDiagram( new QgsHistogramDiagram() ); dr2->setDiagramSettings( ds2 ); @@ -1249,7 +1249,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds11.categoryColors = QList() << col1 << col2 << col3 << col4; - ds11.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok + ds11.categoryAttributes = QList() << QStringLiteral( "\"maennlich_ab_65\"" ) << QStringLiteral( "\"maennlich_18_64\"" ) << QStringLiteral( "\"maennlich_6_17\"" ) << QStringLiteral( "\"maennlich_unter_6\"" ); //#spellok ds11.minimumScale = -1; ds11.maximumScale = -1; ds11.minimumSize = 0; @@ -1281,7 +1281,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds12.categoryColors = QList() << col1 << col2 << col3 << col4; - ds12.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok + ds12.categoryAttributes = QList() << QStringLiteral( "\"weiblich_ab_65\"" ) << QStringLiteral( "\"weiblich_18_64\"" ) << QStringLiteral( "\"weiblich_6_17\"" ) << QStringLiteral( "\"weiblich_unter_6\"" ); //#spellok ds12.minimumScale = -1; ds12.maximumScale = -1; ds12.minimumSize = 0; @@ -1325,7 +1325,7 @@ class TestQgsStackedDiagram : public QgsTest col3.setAlphaF( 0.5 ); col4.setAlphaF( 0.5 ); ds2.categoryColors = QList() << col1 << col2 << col3 << col4; - ds2.categoryAttributes = QList() << QStringLiteral( "\"gesamt_ab_65\"" ) << QStringLiteral( "\"gesamt_18_64\"" ) << QStringLiteral( "\"gesamt_6_17\"" ) << QStringLiteral( "\"gesamt_unter_6\"" ); //#spellok + ds2.categoryAttributes = QList() << QStringLiteral( "\"gesamt_ab_65\"" ) << QStringLiteral( "\"gesamt_18_64\"" ) << QStringLiteral( "\"gesamt_6_17\"" ) << QStringLiteral( "\"gesamt_unter_6\"" ); //#spellok ds2.minimumScale = -1; ds2.maximumScale = -1; ds2.minimumSize = 0; @@ -1364,7 +1364,6 @@ class TestQgsStackedDiagram : public QgsTest mMapSettings->setOutputDpi( 96 ); QGSVERIFYRENDERMAPSETTINGSCHECK( "stackeddiagramsnested", "stackeddiagramsnested", *mMapSettings, 200, 15 ); } - }; diff --git a/tests/src/core/testqgsstatisticalsummary.cpp b/tests/src/core/testqgsstatisticalsummary.cpp index ff055eb0d82f..a3d97817b300 100644 --- a/tests/src/core/testqgsstatisticalsummary.cpp +++ b/tests/src/core/testqgsstatisticalsummary.cpp @@ -21,15 +21,15 @@ #include "qgsstatisticalsummary.h" #include "qgis.h" -class TestQgsStatisticSummary: public QObject +class TestQgsStatisticSummary : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void stats(); void individualStatCalculations_data(); void individualStatCalculations(); @@ -39,27 +39,22 @@ class TestQgsStatisticSummary: public QObject void shortName(); private: - }; void TestQgsStatisticSummary::initTestCase() { - } void TestQgsStatisticSummary::cleanupTestCase() { - } void TestQgsStatisticSummary::init() { - } void TestQgsStatisticSummary::cleanup() { - } void TestQgsStatisticSummary::stats() @@ -114,7 +109,7 @@ void TestQgsStatisticSummary::stats() values << 4 << 5 << 8 << 12 << 12 << 12; s.calculate( values ); s2.addValue( 4 ); - s2.addValue( 5 ) ; + s2.addValue( 5 ); s2.addValue( 8 ); s2.addValue( 12 ); s2.addValue( 12 ); @@ -157,7 +152,7 @@ void TestQgsStatisticSummary::stats() s2.addValue( 36 ); s2.addValue( 39 ); s2.addValue( 40 ); - s2.addValue( 41 ) ; + s2.addValue( 41 ); s2.addValue( 43 ); s2.addValue( 49 ); s2.finalize(); @@ -213,27 +208,27 @@ void TestQgsStatisticSummary::stats() void TestQgsStatisticSummary::individualStatCalculations_data() { - QTest::addColumn< int >( "statInt" ); + QTest::addColumn( "statInt" ); QTest::addColumn( "expected" ); - QTest::newRow( "count" ) << ( int )Qgis::Statistic::Count << 10.0; - QTest::newRow( "sum" ) << ( int )Qgis::Statistic::Sum << 45.0; - QTest::newRow( "mean" ) << ( int )Qgis::Statistic::Mean << 4.5; - QTest::newRow( "median" ) << ( int )Qgis::Statistic::Median << 4.0; - QTest::newRow( "st_dev" ) << ( int )Qgis::Statistic::StDev << 1.96214; - QTest::newRow( "st_dev_sample" ) << ( int )Qgis::Statistic::StDevSample << 2.06828; - QTest::newRow( "min" ) << ( int )Qgis::Statistic::Min << 2.0; - QTest::newRow( "max" ) << ( int )Qgis::Statistic::Max << 8.0; - QTest::newRow( "range" ) << ( int )Qgis::Statistic::Range << 6.0; - QTest::newRow( "minority" ) << ( int )Qgis::Statistic::Minority << 2.0; - QTest::newRow( "majority" ) << ( int )Qgis::Statistic::Majority << 3.0; - QTest::newRow( "variety" ) << ( int )Qgis::Statistic::Variety << 5.0; - QTest::newRow( "first_quartile" ) << ( int )Qgis::Statistic::FirstQuartile << 3.0; - QTest::newRow( "third_quartile" ) << ( int )Qgis::Statistic::ThirdQuartile << 5.0; - QTest::newRow( "iqr" ) << ( int )Qgis::Statistic::InterQuartileRange << 2.0; - QTest::newRow( "missing" ) << ( int )Qgis::Statistic::CountMissing << 0.0; - QTest::newRow( "first" ) << static_cast< int >( Qgis::Statistic::First ) << 4.0; - QTest::newRow( "last" ) << static_cast< int >( Qgis::Statistic::Last ) << 8.0; + QTest::newRow( "count" ) << ( int ) Qgis::Statistic::Count << 10.0; + QTest::newRow( "sum" ) << ( int ) Qgis::Statistic::Sum << 45.0; + QTest::newRow( "mean" ) << ( int ) Qgis::Statistic::Mean << 4.5; + QTest::newRow( "median" ) << ( int ) Qgis::Statistic::Median << 4.0; + QTest::newRow( "st_dev" ) << ( int ) Qgis::Statistic::StDev << 1.96214; + QTest::newRow( "st_dev_sample" ) << ( int ) Qgis::Statistic::StDevSample << 2.06828; + QTest::newRow( "min" ) << ( int ) Qgis::Statistic::Min << 2.0; + QTest::newRow( "max" ) << ( int ) Qgis::Statistic::Max << 8.0; + QTest::newRow( "range" ) << ( int ) Qgis::Statistic::Range << 6.0; + QTest::newRow( "minority" ) << ( int ) Qgis::Statistic::Minority << 2.0; + QTest::newRow( "majority" ) << ( int ) Qgis::Statistic::Majority << 3.0; + QTest::newRow( "variety" ) << ( int ) Qgis::Statistic::Variety << 5.0; + QTest::newRow( "first_quartile" ) << ( int ) Qgis::Statistic::FirstQuartile << 3.0; + QTest::newRow( "third_quartile" ) << ( int ) Qgis::Statistic::ThirdQuartile << 5.0; + QTest::newRow( "iqr" ) << ( int ) Qgis::Statistic::InterQuartileRange << 2.0; + QTest::newRow( "missing" ) << ( int ) Qgis::Statistic::CountMissing << 0.0; + QTest::newRow( "first" ) << static_cast( Qgis::Statistic::First ) << 4.0; + QTest::newRow( "last" ) << static_cast( Qgis::Statistic::Last ) << 8.0; } void TestQgsStatisticSummary::individualStatCalculations() @@ -249,7 +244,7 @@ void TestQgsStatisticSummary::individualStatCalculations() QFETCH( double, expected ); //start with a summary which calculates NO statistics - QgsStatisticalSummary s{ Qgis::Statistics() }; + QgsStatisticalSummary s { Qgis::Statistics() }; //set it to calculate just a single statistic s.setStatistics( stat ); QCOMPARE( s.statistics(), stat ); @@ -258,16 +253,16 @@ void TestQgsStatisticSummary::individualStatCalculations() QGSCOMPARENEAR( s.statistic( stat ), expected, 0.00001 ); //also test using values added one-at-a-time - QgsStatisticalSummary s2{ Qgis::Statistics() }; + QgsStatisticalSummary s2 { Qgis::Statistics() }; s2.setStatistics( stat ); s2.addValue( 4 ); s2.addValue( 4 ); s2.addValue( 2 ); s2.addValue( 3 ); s2.addValue( 3 ); - s2.addValue( 3 ) ; - s2.addValue( 5 ) ; - s2.addValue( 5 ) ; + s2.addValue( 3 ); + s2.addValue( 5 ); + s2.addValue( 5 ); s2.addValue( 8 ); s2.addValue( 8 ); s2.finalize(); @@ -303,7 +298,7 @@ void TestQgsStatisticSummary::countMissing() s.finalize(); QCOMPARE( s.countMissing(), 3 ); - QCOMPARE( s.statistic( Qgis::Statistic::CountMissing ), 3.0 ); + QCOMPARE( s.statistic( Qgis::Statistic::CountMissing ), 3.0 ); } void TestQgsStatisticSummary::noValues() diff --git a/tests/src/core/testqgsstoredexpressionmanager.cpp b/tests/src/core/testqgsstoredexpressionmanager.cpp index 8139aad61420..d9656be1432a 100644 --- a/tests/src/core/testqgsstoredexpressionmanager.cpp +++ b/tests/src/core/testqgsstoredexpressionmanager.cpp @@ -37,7 +37,7 @@ void TestQgsStoredExpressionManager::init() { mManager = new QgsStoredExpressionManager(); - QList newStoredExpressions; + QList newStoredExpressions; //fill up some for the FilterExpression for ( int i = 0; i < 10; i++ ) @@ -74,11 +74,11 @@ void TestQgsStoredExpressionManager::storeSingleExpression() QCOMPARE( storedExpression.tag, QgsStoredExpression::Category::FilterExpression ); //get all expressions - const QList allStoredExpressions = mManager->storedExpressions(); + const QList allStoredExpressions = mManager->storedExpressions(); QCOMPARE( allStoredExpressions.count(), 21 ); //get all expressions for Category::FilterExpression - const QList allStoredFilterExpressions = mManager->storedExpressions( QgsStoredExpression::Category::FilterExpression ); + const QList allStoredFilterExpressions = mManager->storedExpressions( QgsStoredExpression::Category::FilterExpression ); QCOMPARE( allStoredFilterExpressions.count(), 11 ); QCOMPARE( allStoredFilterExpressions.at( 10 ).id, id ); @@ -89,7 +89,7 @@ void TestQgsStoredExpressionManager::storeSingleExpression() void TestQgsStoredExpressionManager::storeListOfExpressions() { - QList newStoredExpressions; + QList newStoredExpressions; //fill up for ( int i = 20; i < 30; i++ ) @@ -100,7 +100,7 @@ void TestQgsStoredExpressionManager::storeListOfExpressions() mManager->addStoredExpressions( newStoredExpressions ); //get all expressions - const QList allStoredExpressions = mManager->storedExpressions(); + const QList allStoredExpressions = mManager->storedExpressions(); QCOMPARE( allStoredExpressions.count(), 30 ); QCOMPARE( allStoredExpressions.at( 0 ).name, QStringLiteral( "filter0" ) ); QCOMPARE( allStoredExpressions.at( 0 ).expression, QStringLiteral( "\"age\"=0" ) ); diff --git a/tests/src/core/testqgsstringutils.cpp b/tests/src/core/testqgsstringutils.cpp index c5fec28901cf..6f761f866cbe 100644 --- a/tests/src/core/testqgsstringutils.cpp +++ b/tests/src/core/testqgsstringutils.cpp @@ -24,10 +24,10 @@ class TestQgsStringUtils : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void levenshtein(); void longestCommonSubstring(); @@ -43,17 +43,14 @@ class TestQgsStringUtils : public QObject void wordWrap_data(); void wordWrap(); void testIsUrl(); - }; void TestQgsStringUtils::initTestCase() { - } void TestQgsStringUtils::cleanupTestCase() { - } void TestQgsStringUtils::init() @@ -68,16 +65,16 @@ void TestQgsStringUtils::levenshtein() { QCOMPARE( QgsStringUtils::levenshteinDistance( QString(), QString() ), 0 ); QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QString() ), 3 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QString(), QStringLiteral( "abc" ) ), 3 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "abc" ) ), 0 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "aBc" ), true ), 1 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "xec" ) ), 2 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "abd" ) ), 1 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "ebg" ) ), 2 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kitten" ), QStringLiteral( "sitting" ) ), 3 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kItten" ), QStringLiteral( "sitting" ) ), 3 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kitten" ), QStringLiteral( "sitTing" ), true ), 4 ); - QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kitten" ), QStringLiteral( "xkitte" ) ), 2 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QString(), QStringLiteral( "abc" ) ), 3 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "abc" ) ), 0 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "aBc" ), true ), 1 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "xec" ) ), 2 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "abd" ) ), 1 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "abc" ), QStringLiteral( "ebg" ) ), 2 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kitten" ), QStringLiteral( "sitting" ) ), 3 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kItten" ), QStringLiteral( "sitting" ) ), 3 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kitten" ), QStringLiteral( "sitTing" ), true ), 4 ); + QCOMPARE( QgsStringUtils::levenshteinDistance( QStringLiteral( "kitten" ), QStringLiteral( "xkitte" ) ), 2 ); } void TestQgsStringUtils::longestCommonSubstring() @@ -85,12 +82,12 @@ void TestQgsStringUtils::longestCommonSubstring() QCOMPARE( QgsStringUtils::longestCommonSubstring( QString(), QString() ), QString() ); QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QString() ), QString() ); QCOMPARE( QgsStringUtils::longestCommonSubstring( QString(), QStringLiteral( "abc" ) ), QString() ); - QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "def" ) ), QString() ); - QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "abd" ) ), QStringLiteral( "ab" ) ); - QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "xbc" ) ), QStringLiteral( "bc" ) ); - QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "xbd" ) ), QStringLiteral( "b" ) ); - QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "longer test" ), QStringLiteral( "inger task" ) ), QStringLiteral( "nger t" ) ); - QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "lonGer test" ), QStringLiteral( "inger task" ), true ), QStringLiteral( "er t" ) ); + QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "def" ) ), QString() ); + QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "abd" ) ), QStringLiteral( "ab" ) ); + QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "xbc" ) ), QStringLiteral( "bc" ) ); + QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "abc" ), QStringLiteral( "xbd" ) ), QStringLiteral( "b" ) ); + QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "longer test" ), QStringLiteral( "inger task" ) ), QStringLiteral( "nger t" ) ); + QCOMPARE( QgsStringUtils::longestCommonSubstring( QStringLiteral( "lonGer test" ), QStringLiteral( "inger task" ), true ), QStringLiteral( "er t" ) ); } void TestQgsStringUtils::hammingDistance() @@ -165,7 +162,6 @@ void TestQgsStringUtils::insertLinks() QVERIFY( found ); QCOMPARE( QgsStringUtils::insertLinks( QStringLiteral( "Load https://iot.comune.fe.it/FROST-Server/v1.1/Observations('b1d12280-ac1f-11ee-94c7-cf46c7a21b9f')" ), &found ), QStringLiteral( "Load https://iot.comune.fe.it/FROST-Server/v1.1/Observations('b1d12280-ac1f-11ee-94c7-cf46c7a21b9f')" ) ); QVERIFY( found ); - } void TestQgsStringUtils::titleCase_data() @@ -233,7 +229,6 @@ void TestQgsStringUtils::ampersandEncode() QFETCH( QString, input ); QFETCH( QString, expected ); QCOMPARE( QgsStringUtils::ampersandEncode( input ), expected ); - } void TestQgsStringUtils::wordWrap_data() diff --git a/tests/src/core/testqgsstyle.cpp b/tests/src/core/testqgsstyle.cpp index 825b6dd54cbd..a1fbde844d66 100644 --- a/tests/src/core/testqgsstyle.cpp +++ b/tests/src/core/testqgsstyle.cpp @@ -61,10 +61,10 @@ class TestStyle : public QgsTest Q_OBJECT public: - TestStyle() : QgsTest( QStringLiteral( "Style Tests" ) ) {} + TestStyle() + : QgsTest( QStringLiteral( "Style Tests" ) ) {} private: - QgsStyle *mStyle = nullptr; QString mTestDataDir; @@ -73,7 +73,8 @@ class TestStyle : public QgsTest static bool compareItemLists( QList &itemsList1, QList &itemsList2 ) { - if ( itemsList1.size() != itemsList2.size() ) return false; + if ( itemsList1.size() != itemsList2.size() ) + return false; for ( int i = 0; i < itemsList1.size(); ++i ) { if ( itemsList1[i].value != itemsList2[i].value ) @@ -92,10 +93,10 @@ class TestStyle : public QgsTest private slots: // init / cleanup - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. // void initStyles(); void testProperties(); @@ -123,13 +124,17 @@ class Dummy3DSymbol : public QgsAbstract3DSymbol public: static QgsAbstract3DSymbol *create() { return new Dummy3DSymbol; } QString type() const override { return QStringLiteral( "dummy" ); } - QgsAbstract3DSymbol *clone() const override { Dummy3DSymbol *res = new Dummy3DSymbol(); res->id = id; return res; } + QgsAbstract3DSymbol *clone() const override + { + Dummy3DSymbol *res = new Dummy3DSymbol(); + res->id = id; + return res; + } void readXml( const QDomElement &elem, const QgsReadWriteContext & ) override { id = elem.attribute( QStringLiteral( "id" ) ); } void writeXml( QDomElement &elem, const QgsReadWriteContext & ) const override { elem.setAttribute( QStringLiteral( "id" ), id ); } - QList compatibleGeometryTypes() const override { return QList< Qgis::GeometryType >() << Qgis::GeometryType::Point << Qgis::GeometryType::Line; } + QList compatibleGeometryTypes() const override { return QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Line; } QString id; - }; // slots @@ -159,8 +164,7 @@ void TestStyle::initTestCase() // cpt-city ramp, small selection available in /cpt-city QgsCptCityArchive::initArchives(); - QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "dummy" ), QObject::tr( "Dummy" ), - &Dummy3DSymbol::create, nullptr, nullptr ) ); + QgsApplication::symbol3DRegistry()->addSymbolType( new Qgs3DSymbolMetadata( QStringLiteral( "dummy" ), QObject::tr( "Dummy" ), &Dummy3DSymbol::create, nullptr, nullptr ) ); } void TestStyle::cleanupTestCase() @@ -195,21 +199,17 @@ void TestStyle::testCreateSymbols() QgsStyle s; s.createMemoryDatabase(); - std::unique_ptr< QgsMarkerSymbol > sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - std::unique_ptr< QgsMarkerSymbol > sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - std::unique_ptr< QgsMarkerSymbol > sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - const std::unique_ptr< QgsMarkerSymbol > sym4( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + const std::unique_ptr sym4( QgsMarkerSymbol::createSimple( QVariantMap() ) ); s.addSymbol( QStringLiteral( "symbolA" ), sym1.release(), true ); s.addSymbol( QStringLiteral( "symbolB" ), sym2.release(), true ); s.addSymbol( QStringLiteral( "symbolC" ), sym3.release(), true ); QgsStyleSymbolEntity symbolEntity( sym4.get() ); - s.addEntity( QStringLiteral( "symbolD" ), &symbolEntity, true ); + s.addEntity( QStringLiteral( "symbolD" ), &symbolEntity, true ); - QCOMPARE( s.allNames( QgsStyle::SymbolEntity ), - QStringList() << QStringLiteral( "symbolA" ) - << QStringLiteral( "symbolB" ) - << QStringLiteral( "symbolC" ) - << QStringLiteral( "symbolD" ) ); + QCOMPARE( s.allNames( QgsStyle::SymbolEntity ), QStringList() << QStringLiteral( "symbolA" ) << QStringLiteral( "symbolB" ) << QStringLiteral( "symbolC" ) << QStringLiteral( "symbolD" ) ); } bool TestStyle::imageCheck( QgsMapSettings &ms, const QString &testName ) @@ -230,8 +230,7 @@ bool TestStyle::testValidColor( QgsColorRamp *ramp, double value, const QColor & if ( result.red() != expected.red() || result.green() != expected.green() || result.blue() != expected.blue() || result.alpha() != expected.alpha() ) { - QWARN( QString( "value = %1 result = %2 expected = %3" ).arg( value ).arg( - result.name(), expected.name() ).toLocal8Bit().data() ); + QWARN( QString( "value = %1 result = %2 expected = %3" ).arg( value ).arg( result.name(), expected.name() ).toLocal8Bit().data() ); return false; } return true; @@ -266,26 +265,13 @@ void TestStyle::testCreateColorRamps() QgsCptCityColorRamp *cc3Ramp = new QgsCptCityColorRamp( QStringLiteral( "grass/byr" ), QString() ); QVERIFY( mStyle->addColorRamp( "test_cc3", cc3Ramp, true ) ); - QCOMPARE( mStyle->allNames( QgsStyle::ColorrampEntity ), QStringList() << QStringLiteral( "test_cb1" ) - << QStringLiteral( "test_cb2" ) - << QStringLiteral( "test_cc1" ) - << QStringLiteral( "test_cc2" ) - << QStringLiteral( "test_cc3" ) - << QStringLiteral( "test_gradient" ) - << QStringLiteral( "test_random" ) ); + QCOMPARE( mStyle->allNames( QgsStyle::ColorrampEntity ), QStringList() << QStringLiteral( "test_cb1" ) << QStringLiteral( "test_cb2" ) << QStringLiteral( "test_cc1" ) << QStringLiteral( "test_cc2" ) << QStringLiteral( "test_cc3" ) << QStringLiteral( "test_gradient" ) << QStringLiteral( "test_random" ) ); - const std::unique_ptr< QgsCptCityColorRamp > cc4Ramp = std::make_unique< QgsCptCityColorRamp >( QStringLiteral( "grass/byr" ), QString() ); + const std::unique_ptr cc4Ramp = std::make_unique( QStringLiteral( "grass/byr" ), QString() ); QgsStyleColorRampEntity entity( cc4Ramp.get() ); QVERIFY( mStyle->addEntity( "test_cc4", &entity, true ) ); - QCOMPARE( mStyle->allNames( QgsStyle::ColorrampEntity ), QStringList() << QStringLiteral( "test_cb1" ) - << QStringLiteral( "test_cb2" ) - << QStringLiteral( "test_cc1" ) - << QStringLiteral( "test_cc2" ) - << QStringLiteral( "test_cc3" ) - << QStringLiteral( "test_cc4" ) - << QStringLiteral( "test_gradient" ) - << QStringLiteral( "test_random" ) ); + QCOMPARE( mStyle->allNames( QgsStyle::ColorrampEntity ), QStringList() << QStringLiteral( "test_cb1" ) << QStringLiteral( "test_cb2" ) << QStringLiteral( "test_cc1" ) << QStringLiteral( "test_cc2" ) << QStringLiteral( "test_cc3" ) << QStringLiteral( "test_cc4" ) << QStringLiteral( "test_gradient" ) << QStringLiteral( "test_random" ) ); } void TestStyle::testCreateTextFormats() @@ -337,8 +323,7 @@ void TestStyle::testCreateTextFormats() QCOMPARE( style2.textFormat( QString( "test_format" ) ).color().name(), QStringLiteral( "#ffff00" ) ); QCOMPARE( style2.textFormat( QString( "test_format2" ) ).color().name(), QStringLiteral( "#ffffff" ) ); - QCOMPARE( mStyle->allNames( QgsStyle::TextFormatEntity ), QStringList() << QStringLiteral( "test_format" ) - << QStringLiteral( "test_format2" ) ); + QCOMPARE( mStyle->allNames( QgsStyle::TextFormatEntity ), QStringList() << QStringLiteral( "test_format" ) << QStringLiteral( "test_format2" ) ); format.setColor( QColor( 255, 255, 205 ) ); @@ -396,8 +381,7 @@ void TestStyle::testCreateLabelSettings() QCOMPARE( style2.labelSettings( QString( "test_settings" ) ).fieldName, QStringLiteral( "actually_no_its_a_nightmare" ) ); QCOMPARE( style2.labelSettings( QString( "test_format2" ) ).fieldName, QStringLiteral( "phew_it_was_just_a_dream_all_along" ) ); - QCOMPARE( mStyle->allNames( QgsStyle::LabelSettingsEntity ), QStringList() << QStringLiteral( "test_format2" ) - << QStringLiteral( "test_settings" ) ); + QCOMPARE( mStyle->allNames( QgsStyle::LabelSettingsEntity ), QStringList() << QStringLiteral( "test_format2" ) << QStringLiteral( "test_settings" ) ); QgsStyleLabelSettingsEntity entity( settings ); QVERIFY( mStyle->addEntity( "test_settings2", &entity, true ) ); @@ -453,8 +437,7 @@ void TestStyle::testCreateLegendPatchShapes() QCOMPARE( style2.legendPatchShape( QString( "test_settings" ) ).geometry().asWkt(), QStringLiteral( "Point (15 16)" ) ); QCOMPARE( style2.legendPatchShape( QString( "test_format2" ) ).geometry().asWkt(), QStringLiteral( "Point (25 26)" ) ); - QCOMPARE( mStyle->allNames( QgsStyle::LegendPatchShapeEntity ), QStringList() << QStringLiteral( "test_format2" ) - << QStringLiteral( "test_settings" ) ); + QCOMPARE( mStyle->allNames( QgsStyle::LegendPatchShapeEntity ), QStringList() << QStringLiteral( "test_format2" ) << QStringLiteral( "test_settings" ) ); QgsStyleLegendPatchShapeEntity entity( settings ); QVERIFY( mStyle->addEntity( "test_settings2", &entity, true ) ); @@ -481,14 +464,14 @@ void TestStyle::testCreate3dSymbol() QVERIFY( mStyle->symbol3DNames().contains( QStringLiteral( "test_settings" ) ) ); QCOMPARE( mStyle->symbol3DCount(), 1 ); QVERIFY( mStyle->symbol3DCompatibleGeometryTypes( QStringLiteral( "blah" ) ).isEmpty() ); - QCOMPARE( mStyle->symbol3DCompatibleGeometryTypes( QStringLiteral( "test_settings" ) ), QList< Qgis::GeometryType >() << Qgis::GeometryType::Point << Qgis::GeometryType::Line ); - std::unique_ptr< Dummy3DSymbol > retrieved( dynamic_cast< Dummy3DSymbol * >( mStyle->symbol3D( QStringLiteral( "test_settings" ) ) ) ); + QCOMPARE( mStyle->symbol3DCompatibleGeometryTypes( QStringLiteral( "test_settings" ) ), QList() << Qgis::GeometryType::Point << Qgis::GeometryType::Line ); + std::unique_ptr retrieved( dynamic_cast( mStyle->symbol3D( QStringLiteral( "test_settings" ) ) ) ); QCOMPARE( retrieved->id, QStringLiteral( "xxx" ) ); symbol.id = QStringLiteral( "yyy" ); QVERIFY( mStyle->addSymbol3D( "test_settings", symbol.clone(), true ) ); QVERIFY( mStyle->symbol3DNames().contains( QStringLiteral( "test_settings" ) ) ); QCOMPARE( mStyle->symbol3DCount(), 1 ); - retrieved.reset( dynamic_cast< Dummy3DSymbol * >( mStyle->symbol3D( QStringLiteral( "test_settings" ) ) ) ); + retrieved.reset( dynamic_cast( mStyle->symbol3D( QStringLiteral( "test_settings" ) ) ) ); QCOMPARE( retrieved->id, QStringLiteral( "yyy" ) ); QCOMPARE( spy.count(), 1 ); QCOMPARE( spyChanged.count(), 1 ); @@ -497,9 +480,9 @@ void TestStyle::testCreate3dSymbol() QVERIFY( mStyle->addSymbol3D( "test_format2", symbol.clone(), true ) ); QVERIFY( mStyle->symbol3DNames().contains( QStringLiteral( "test_format2" ) ) ); QCOMPARE( mStyle->symbol3DCount(), 2 ); - retrieved.reset( dynamic_cast< Dummy3DSymbol * >( mStyle->symbol3D( QStringLiteral( "test_settings" ) ) ) ); + retrieved.reset( dynamic_cast( mStyle->symbol3D( QStringLiteral( "test_settings" ) ) ) ); QCOMPARE( retrieved->id, QStringLiteral( "yyy" ) ); - retrieved.reset( dynamic_cast< Dummy3DSymbol * >( mStyle->symbol3D( QStringLiteral( "test_format2" ) ) ) ); + retrieved.reset( dynamic_cast( mStyle->symbol3D( QStringLiteral( "test_format2" ) ) ) ); QCOMPARE( retrieved->id, QStringLiteral( "zzz" ) ); QCOMPARE( spy.count(), 2 ); QCOMPARE( spyChanged.count(), 1 ); @@ -513,13 +496,12 @@ void TestStyle::testCreate3dSymbol() QVERIFY( style2.symbol3DNames().contains( QStringLiteral( "test_settings" ) ) ); QVERIFY( style2.symbol3DNames().contains( QStringLiteral( "test_format2" ) ) ); QCOMPARE( style2.symbol3DCount(), 2 ); - retrieved.reset( dynamic_cast< Dummy3DSymbol * >( style2.symbol3D( QStringLiteral( "test_settings" ) ) ) ); + retrieved.reset( dynamic_cast( style2.symbol3D( QStringLiteral( "test_settings" ) ) ) ); QCOMPARE( retrieved->id, QStringLiteral( "yyy" ) ); - retrieved.reset( dynamic_cast< Dummy3DSymbol * >( style2.symbol3D( QStringLiteral( "test_format2" ) ) ) ); + retrieved.reset( dynamic_cast( style2.symbol3D( QStringLiteral( "test_format2" ) ) ) ); QCOMPARE( retrieved->id, QStringLiteral( "zzz" ) ); - QCOMPARE( mStyle->allNames( QgsStyle::Symbol3DEntity ), QStringList() << QStringLiteral( "test_format2" ) - << QStringLiteral( "test_settings" ) ); + QCOMPARE( mStyle->allNames( QgsStyle::Symbol3DEntity ), QStringList() << QStringLiteral( "test_format2" ) << QStringLiteral( "test_settings" ) ); QgsStyleSymbol3DEntity entity( &symbol ); QVERIFY( mStyle->addEntity( "test_settings2", &entity, true ) ); @@ -530,10 +512,10 @@ void TestStyle::testLoadColorRamps() { const QStringList colorRamps = mStyle->colorRampNames(); QStringList colorRampsTest = QStringList() << QStringLiteral( "test_gradient" ) << QStringLiteral( "test_random" ) - << QStringLiteral( "test_cb1" ) << QStringLiteral( "test_cb2" ); + << QStringLiteral( "test_cb1" ) << QStringLiteral( "test_cb2" ); // values for color tests - QMultiMap< QString, QPair< double, QColor> > colorTests; + QMultiMap> colorTests; colorTests.insert( QStringLiteral( "test_gradient" ), qMakePair( 0, QColor( "#ff0000" ) ) ); colorTests.insert( QStringLiteral( "test_gradient" ), qMakePair( 1, QColor( "#0000ff" ) ) ); // cannot test random colors! @@ -564,7 +546,7 @@ void TestStyle::testLoadColorRamps() // test colors if ( colorTests.contains( name ) ) { - const QList< QPair< double, QColor> > values = colorTests.values( name ); + const QList> values = colorTests.values( name ); for ( int i = 0; i < values.size(); ++i ) { QVERIFY( testValidColor( ramp, values.at( i ).first, values.at( i ).second ) ); @@ -611,9 +593,9 @@ void TestStyle::testFavorites() QVERIFY( !mStyle->isFavorite( QgsStyle::Symbol3DEntity, QStringLiteral( "AaaaaaaaaA" ) ) ); // add some symbols to favorites - const std::unique_ptr< QgsMarkerSymbol > sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - const std::unique_ptr< QgsMarkerSymbol > sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - const std::unique_ptr< QgsMarkerSymbol > sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + const std::unique_ptr sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + const std::unique_ptr sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + const std::unique_ptr sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); mStyle->saveSymbol( QStringLiteral( "symbolA" ), sym1.get(), true, QStringList() ); mStyle->saveSymbol( QStringLiteral( "symbolB" ), sym2.get(), false, QStringList() ); mStyle->saveSymbol( QStringLiteral( "symbolC" ), sym3.get(), true, QStringList() ); @@ -633,7 +615,7 @@ void TestStyle::testFavorites() // remove one symbol from favorites mStyle->removeFavorite( QgsStyle::SymbolEntity, QStringLiteral( "symbolA" ) ); QCOMPARE( favoriteChangedSpy.count(), 1 ); - QCOMPARE( favoriteChangedSpy.at( 0 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::SymbolEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 0 ).at( 0 ).toInt(), static_cast( QgsStyle::SymbolEntity ) ); QCOMPARE( favoriteChangedSpy.at( 0 ).at( 1 ).toString(), QStringLiteral( "symbolA" ) ); QCOMPARE( favoriteChangedSpy.at( 0 ).at( 2 ).toBool(), false ); @@ -648,7 +630,7 @@ void TestStyle::testFavorites() mStyle->addFavorite( QgsStyle::SymbolEntity, QStringLiteral( "symbolA" ) ); QCOMPARE( favoriteChangedSpy.count(), 2 ); - QCOMPARE( favoriteChangedSpy.at( 1 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::SymbolEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 1 ).at( 0 ).toInt(), static_cast( QgsStyle::SymbolEntity ) ); QCOMPARE( favoriteChangedSpy.at( 1 ).at( 1 ).toString(), QStringLiteral( "symbolA" ) ); QCOMPARE( favoriteChangedSpy.at( 1 ).at( 2 ).toBool(), true ); favorites = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity ); @@ -668,7 +650,7 @@ void TestStyle::testFavorites() mStyle->addFavorite( QgsStyle::ColorrampEntity, QStringLiteral( "gradient_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 3 ); - QCOMPARE( favoriteChangedSpy.at( 2 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::ColorrampEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 2 ).at( 0 ).toInt(), static_cast( QgsStyle::ColorrampEntity ) ); QCOMPARE( favoriteChangedSpy.at( 2 ).at( 1 ).toString(), QStringLiteral( "gradient_1" ) ); QCOMPARE( favoriteChangedSpy.at( 2 ).at( 2 ).toBool(), true ); favorites = mStyle->symbolsOfFavorite( QgsStyle::ColorrampEntity ); @@ -678,7 +660,7 @@ void TestStyle::testFavorites() mStyle->removeFavorite( QgsStyle::ColorrampEntity, QStringLiteral( "gradient_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 4 ); - QCOMPARE( favoriteChangedSpy.at( 3 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::ColorrampEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 3 ).at( 0 ).toInt(), static_cast( QgsStyle::ColorrampEntity ) ); QCOMPARE( favoriteChangedSpy.at( 3 ).at( 1 ).toString(), QStringLiteral( "gradient_1" ) ); QCOMPARE( favoriteChangedSpy.at( 3 ).at( 2 ).toBool(), false ); favorites = mStyle->symbolsOfFavorite( QgsStyle::ColorrampEntity ); @@ -694,7 +676,7 @@ void TestStyle::testFavorites() mStyle->addFavorite( QgsStyle::TextFormatEntity, QStringLiteral( "format_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 5 ); - QCOMPARE( favoriteChangedSpy.at( 4 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::TextFormatEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 4 ).at( 0 ).toInt(), static_cast( QgsStyle::TextFormatEntity ) ); QCOMPARE( favoriteChangedSpy.at( 4 ).at( 1 ).toString(), QStringLiteral( "format_1" ) ); QCOMPARE( favoriteChangedSpy.at( 4 ).at( 2 ).toBool(), true ); favorites = mStyle->symbolsOfFavorite( QgsStyle::TextFormatEntity ); @@ -704,7 +686,7 @@ void TestStyle::testFavorites() mStyle->removeFavorite( QgsStyle::TextFormatEntity, QStringLiteral( "format_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 6 ); - QCOMPARE( favoriteChangedSpy.at( 5 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::TextFormatEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 5 ).at( 0 ).toInt(), static_cast( QgsStyle::TextFormatEntity ) ); QCOMPARE( favoriteChangedSpy.at( 5 ).at( 1 ).toString(), QStringLiteral( "format_1" ) ); QCOMPARE( favoriteChangedSpy.at( 5 ).at( 2 ).toBool(), false ); favorites = mStyle->symbolsOfFavorite( QgsStyle::TextFormatEntity ); @@ -720,7 +702,7 @@ void TestStyle::testFavorites() mStyle->addFavorite( QgsStyle::LabelSettingsEntity, QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 7 ); - QCOMPARE( favoriteChangedSpy.at( 6 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LabelSettingsEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 6 ).at( 0 ).toInt(), static_cast( QgsStyle::LabelSettingsEntity ) ); QCOMPARE( favoriteChangedSpy.at( 6 ).at( 1 ).toString(), QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.at( 6 ).at( 2 ).toBool(), true ); favorites = mStyle->symbolsOfFavorite( QgsStyle::LabelSettingsEntity ); @@ -730,7 +712,7 @@ void TestStyle::testFavorites() mStyle->removeFavorite( QgsStyle::LabelSettingsEntity, QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 8 ); - QCOMPARE( favoriteChangedSpy.at( 7 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LabelSettingsEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 7 ).at( 0 ).toInt(), static_cast( QgsStyle::LabelSettingsEntity ) ); QCOMPARE( favoriteChangedSpy.at( 7 ).at( 1 ).toString(), QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.at( 7 ).at( 2 ).toBool(), false ); favorites = mStyle->symbolsOfFavorite( QgsStyle::LabelSettingsEntity ); @@ -746,7 +728,7 @@ void TestStyle::testFavorites() mStyle->addFavorite( QgsStyle::LegendPatchShapeEntity, QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 9 ); - QCOMPARE( favoriteChangedSpy.at( 8 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LegendPatchShapeEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 8 ).at( 0 ).toInt(), static_cast( QgsStyle::LegendPatchShapeEntity ) ); QCOMPARE( favoriteChangedSpy.at( 8 ).at( 1 ).toString(), QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.at( 8 ).at( 2 ).toBool(), true ); favorites = mStyle->symbolsOfFavorite( QgsStyle::LegendPatchShapeEntity ); @@ -756,7 +738,7 @@ void TestStyle::testFavorites() mStyle->removeFavorite( QgsStyle::LegendPatchShapeEntity, QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 10 ); - QCOMPARE( favoriteChangedSpy.at( 9 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LegendPatchShapeEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 9 ).at( 0 ).toInt(), static_cast( QgsStyle::LegendPatchShapeEntity ) ); QCOMPARE( favoriteChangedSpy.at( 9 ).at( 1 ).toString(), QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.at( 9 ).at( 2 ).toBool(), false ); favorites = mStyle->symbolsOfFavorite( QgsStyle::LegendPatchShapeEntity ); @@ -772,7 +754,7 @@ void TestStyle::testFavorites() mStyle->addFavorite( QgsStyle::Symbol3DEntity, QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 11 ); - QCOMPARE( favoriteChangedSpy.at( 10 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::Symbol3DEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 10 ).at( 0 ).toInt(), static_cast( QgsStyle::Symbol3DEntity ) ); QCOMPARE( favoriteChangedSpy.at( 10 ).at( 1 ).toString(), QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.at( 10 ).at( 2 ).toBool(), true ); favorites = mStyle->symbolsOfFavorite( QgsStyle::Symbol3DEntity ); @@ -782,7 +764,7 @@ void TestStyle::testFavorites() mStyle->removeFavorite( QgsStyle::Symbol3DEntity, QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.count(), 12 ); - QCOMPARE( favoriteChangedSpy.at( 11 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::Symbol3DEntity ) ); + QCOMPARE( favoriteChangedSpy.at( 11 ).at( 0 ).toInt(), static_cast( QgsStyle::Symbol3DEntity ) ); QCOMPARE( favoriteChangedSpy.at( 11 ).at( 1 ).toString(), QStringLiteral( "settings_1" ) ); QCOMPARE( favoriteChangedSpy.at( 11 ).at( 2 ).toBool(), false ); favorites = mStyle->symbolsOfFavorite( QgsStyle::Symbol3DEntity ); @@ -808,12 +790,7 @@ void TestStyle::testTags() QCOMPARE( id, mStyle->tagId( "purple" ) ); QCOMPARE( QStringLiteral( "purple" ), mStyle->tag( id ) ); - QCOMPARE( mStyle->allNames( QgsStyle::TagEntity ), - QStringList() << QStringLiteral( "red" ) - << QStringLiteral( "starry" ) - << QStringLiteral( "circle" ) - << QStringLiteral( "blue" ) - << QStringLiteral( "purple" ) ); + QCOMPARE( mStyle->allNames( QgsStyle::TagEntity ), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "starry" ) << QStringLiteral( "circle" ) << QStringLiteral( "blue" ) << QStringLiteral( "purple" ) ); // Cyrillic id = mStyle->addTag( QStringLiteral( "МЕТЕОР" ) ); @@ -836,10 +813,10 @@ void TestStyle::testTags() QVERIFY( !tags.contains( "purple" ) ); //add some symbols - const std::unique_ptr< QgsMarkerSymbol> sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - std::unique_ptr< QgsMarkerSymbol> sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - std::unique_ptr< QgsMarkerSymbol> sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - std::unique_ptr< QgsMarkerSymbol> sym4( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + const std::unique_ptr sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym4( QgsMarkerSymbol::createSimple( QVariantMap() ) ); QVERIFY( mStyle->saveSymbol( "symbol1", sym1.get(), false, QStringList() << "red" << "starry" ) ); mStyle->addSymbol( QStringLiteral( "blue starry" ), sym2.release(), true ); mStyle->addSymbol( QStringLiteral( "red circle" ), sym3.release(), true ); @@ -850,13 +827,13 @@ void TestStyle::testTags() //tag them QVERIFY( mStyle->tagSymbol( QgsStyle::SymbolEntity, "blue starry", QStringList() << "blue" << "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 1 ); - QCOMPARE( tagsChangedSpy.at( 0 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::SymbolEntity ) ); + QCOMPARE( tagsChangedSpy.at( 0 ).at( 0 ).toInt(), static_cast( QgsStyle::SymbolEntity ) ); QCOMPARE( tagsChangedSpy.at( 0 ).at( 1 ).toString(), QStringLiteral( "blue starry" ) ); QCOMPARE( tagsChangedSpy.at( 0 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "blue" ) << QStringLiteral( "starry" ) ); QVERIFY( mStyle->tagSymbol( QgsStyle::SymbolEntity, "red circle", QStringList() << "red" << "circle" ) ); QCOMPARE( tagsChangedSpy.count(), 2 ); - QCOMPARE( tagsChangedSpy.at( 1 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::SymbolEntity ) ); + QCOMPARE( tagsChangedSpy.at( 1 ).at( 0 ).toInt(), static_cast( QgsStyle::SymbolEntity ) ); QCOMPARE( tagsChangedSpy.at( 1 ).at( 1 ).toString(), QStringLiteral( "red circle" ) ); QCOMPARE( tagsChangedSpy.at( 1 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) ); @@ -866,7 +843,7 @@ void TestStyle::testTags() //tag which hasn't been added yet QVERIFY( mStyle->tagSymbol( QgsStyle::SymbolEntity, "red circle", QStringList() << "round" ) ); QCOMPARE( tagsChangedSpy.count(), 3 ); - QCOMPARE( tagsChangedSpy.at( 2 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::SymbolEntity ) ); + QCOMPARE( tagsChangedSpy.at( 2 ).at( 0 ).toInt(), static_cast( QgsStyle::SymbolEntity ) ); QCOMPARE( tagsChangedSpy.at( 2 ).at( 1 ).toString(), QStringLiteral( "red circle" ) ); QCOMPARE( tagsChangedSpy.at( 2 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) << QStringLiteral( "round" ) ); @@ -912,7 +889,7 @@ void TestStyle::testTags() QCOMPARE( tags.count(), 1 ); QVERIFY( tags.contains( "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 5 ); - QCOMPARE( tagsChangedSpy.at( 4 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::SymbolEntity ) ); + QCOMPARE( tagsChangedSpy.at( 4 ).at( 0 ).toInt(), static_cast( QgsStyle::SymbolEntity ) ); QCOMPARE( tagsChangedSpy.at( 4 ).at( 1 ).toString(), QStringLiteral( "blue starry" ) ); QCOMPARE( tagsChangedSpy.at( 4 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "starry" ) ); @@ -921,7 +898,7 @@ void TestStyle::testTags() tags = mStyle->tagsOfSymbol( QgsStyle::SymbolEntity, QStringLiteral( "blue starry" ) ); QCOMPARE( tags.count(), 0 ); QCOMPARE( tagsChangedSpy.count(), 6 ); - QCOMPARE( tagsChangedSpy.at( 5 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::SymbolEntity ) ); + QCOMPARE( tagsChangedSpy.at( 5 ).at( 0 ).toInt(), static_cast( QgsStyle::SymbolEntity ) ); QCOMPARE( tagsChangedSpy.at( 5 ).at( 1 ).toString(), QStringLiteral( "blue starry" ) ); QCOMPARE( tagsChangedSpy.at( 5 ).at( 2 ).toStringList(), QStringList() ); @@ -983,13 +960,13 @@ void TestStyle::testTags() QVERIFY( mStyle->tagSymbol( QgsStyle::ColorrampEntity, "gradient_tag1", QStringList() << "blue" << "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 10 ); - QCOMPARE( tagsChangedSpy.at( 9 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::ColorrampEntity ) ); + QCOMPARE( tagsChangedSpy.at( 9 ).at( 0 ).toInt(), static_cast( QgsStyle::ColorrampEntity ) ); QCOMPARE( tagsChangedSpy.at( 9 ).at( 1 ).toString(), QStringLiteral( "gradient_tag1" ) ); QCOMPARE( tagsChangedSpy.at( 9 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "blue" ) << QStringLiteral( "starry" ) ); QVERIFY( mStyle->tagSymbol( QgsStyle::ColorrampEntity, "gradient_tag2", QStringList() << "red" << "circle" ) ); QCOMPARE( tagsChangedSpy.count(), 11 ); - QCOMPARE( tagsChangedSpy.at( 10 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::ColorrampEntity ) ); + QCOMPARE( tagsChangedSpy.at( 10 ).at( 0 ).toInt(), static_cast( QgsStyle::ColorrampEntity ) ); QCOMPARE( tagsChangedSpy.at( 10 ).at( 1 ).toString(), QStringLiteral( "gradient_tag2" ) ); QCOMPARE( tagsChangedSpy.at( 10 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) ); @@ -999,7 +976,7 @@ void TestStyle::testTags() //tag which hasn't been added yet QVERIFY( mStyle->tagSymbol( QgsStyle::ColorrampEntity, "gradient_tag2", QStringList() << "round ramp" ) ); QCOMPARE( tagsChangedSpy.count(), 12 ); - QCOMPARE( tagsChangedSpy.at( 11 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::ColorrampEntity ) ); + QCOMPARE( tagsChangedSpy.at( 11 ).at( 0 ).toInt(), static_cast( QgsStyle::ColorrampEntity ) ); QCOMPARE( tagsChangedSpy.at( 11 ).at( 1 ).toString(), QStringLiteral( "gradient_tag2" ) ); QCOMPARE( tagsChangedSpy.at( 11 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) << QStringLiteral( "round ramp" ) ); @@ -1023,7 +1000,7 @@ void TestStyle::testTags() QCOMPARE( tags.count(), 1 ); QVERIFY( tags.contains( "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 13 ); - QCOMPARE( tagsChangedSpy.at( 12 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::ColorrampEntity ) ); + QCOMPARE( tagsChangedSpy.at( 12 ).at( 0 ).toInt(), static_cast( QgsStyle::ColorrampEntity ) ); QCOMPARE( tagsChangedSpy.at( 12 ).at( 1 ).toString(), QStringLiteral( "gradient_tag1" ) ); QCOMPARE( tagsChangedSpy.at( 12 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "starry" ) ); @@ -1032,7 +1009,7 @@ void TestStyle::testTags() tags = mStyle->tagsOfSymbol( QgsStyle::ColorrampEntity, QStringLiteral( "gradient_tag1" ) ); QCOMPARE( tags.count(), 0 ); QCOMPARE( tagsChangedSpy.count(), 14 ); - QCOMPARE( tagsChangedSpy.at( 13 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::ColorrampEntity ) ); + QCOMPARE( tagsChangedSpy.at( 13 ).at( 0 ).toInt(), static_cast( QgsStyle::ColorrampEntity ) ); QCOMPARE( tagsChangedSpy.at( 13 ).at( 1 ).toString(), QStringLiteral( "gradient_tag1" ) ); QCOMPARE( tagsChangedSpy.at( 13 ).at( 2 ).toStringList(), QStringList() ); @@ -1046,13 +1023,13 @@ void TestStyle::testTags() QVERIFY( mStyle->tagSymbol( QgsStyle::TextFormatEntity, "format1", QStringList() << "blue" << "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 17 ); - QCOMPARE( tagsChangedSpy.at( 16 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::TextFormatEntity ) ); + QCOMPARE( tagsChangedSpy.at( 16 ).at( 0 ).toInt(), static_cast( QgsStyle::TextFormatEntity ) ); QCOMPARE( tagsChangedSpy.at( 16 ).at( 1 ).toString(), QStringLiteral( "format1" ) ); QCOMPARE( tagsChangedSpy.at( 16 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "blue" ) << QStringLiteral( "starry" ) ); QVERIFY( mStyle->tagSymbol( QgsStyle::TextFormatEntity, "format2", QStringList() << "red" << "circle" ) ); QCOMPARE( tagsChangedSpy.count(), 18 ); - QCOMPARE( tagsChangedSpy.at( 17 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::TextFormatEntity ) ); + QCOMPARE( tagsChangedSpy.at( 17 ).at( 0 ).toInt(), static_cast( QgsStyle::TextFormatEntity ) ); QCOMPARE( tagsChangedSpy.at( 17 ).at( 1 ).toString(), QStringLiteral( "format2" ) ); QCOMPARE( tagsChangedSpy.at( 17 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) ); @@ -1062,7 +1039,7 @@ void TestStyle::testTags() //tag which hasn't been added yet QVERIFY( mStyle->tagSymbol( QgsStyle::TextFormatEntity, "format2", QStringList() << "red text" ) ); QCOMPARE( tagsChangedSpy.count(), 19 ); - QCOMPARE( tagsChangedSpy.at( 18 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::TextFormatEntity ) ); + QCOMPARE( tagsChangedSpy.at( 18 ).at( 0 ).toInt(), static_cast( QgsStyle::TextFormatEntity ) ); QCOMPARE( tagsChangedSpy.at( 18 ).at( 1 ).toString(), QStringLiteral( "format2" ) ); QCOMPARE( tagsChangedSpy.at( 18 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) << QStringLiteral( "red text" ) ); @@ -1086,7 +1063,7 @@ void TestStyle::testTags() QCOMPARE( tags.count(), 1 ); QVERIFY( tags.contains( "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 20 ); - QCOMPARE( tagsChangedSpy.at( 19 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::TextFormatEntity ) ); + QCOMPARE( tagsChangedSpy.at( 19 ).at( 0 ).toInt(), static_cast( QgsStyle::TextFormatEntity ) ); QCOMPARE( tagsChangedSpy.at( 19 ).at( 1 ).toString(), QStringLiteral( "format1" ) ); QCOMPARE( tagsChangedSpy.at( 19 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "starry" ) ); @@ -1095,7 +1072,7 @@ void TestStyle::testTags() tags = mStyle->tagsOfSymbol( QgsStyle::TextFormatEntity, QStringLiteral( "format1" ) ); QCOMPARE( tags.count(), 0 ); QCOMPARE( tagsChangedSpy.count(), 21 ); - QCOMPARE( tagsChangedSpy.at( 20 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::TextFormatEntity ) ); + QCOMPARE( tagsChangedSpy.at( 20 ).at( 0 ).toInt(), static_cast( QgsStyle::TextFormatEntity ) ); QCOMPARE( tagsChangedSpy.at( 20 ).at( 1 ).toString(), QStringLiteral( "format1" ) ); QCOMPARE( tagsChangedSpy.at( 20 ).at( 2 ).toStringList(), QStringList() ); @@ -1110,13 +1087,13 @@ void TestStyle::testTags() QVERIFY( mStyle->tagSymbol( QgsStyle::LabelSettingsEntity, "settings1", QStringList() << "blue" << "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 24 ); - QCOMPARE( tagsChangedSpy.at( 23 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::LabelSettingsEntity ) ); + QCOMPARE( tagsChangedSpy.at( 23 ).at( 0 ).toInt(), static_cast( QgsStyle::LabelSettingsEntity ) ); QCOMPARE( tagsChangedSpy.at( 23 ).at( 1 ).toString(), QStringLiteral( "settings1" ) ); QCOMPARE( tagsChangedSpy.at( 23 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "blue" ) << QStringLiteral( "starry" ) ); QVERIFY( mStyle->tagSymbol( QgsStyle::LabelSettingsEntity, "settings2", QStringList() << "red" << "circle" ) ); QCOMPARE( tagsChangedSpy.count(), 25 ); - QCOMPARE( tagsChangedSpy.at( 24 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::LabelSettingsEntity ) ); + QCOMPARE( tagsChangedSpy.at( 24 ).at( 0 ).toInt(), static_cast( QgsStyle::LabelSettingsEntity ) ); QCOMPARE( tagsChangedSpy.at( 24 ).at( 1 ).toString(), QStringLiteral( "settings2" ) ); QCOMPARE( tagsChangedSpy.at( 24 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) ); @@ -1126,7 +1103,7 @@ void TestStyle::testTags() //tag which hasn't been added yet QVERIFY( mStyle->tagSymbol( QgsStyle::LabelSettingsEntity, "settings2", QStringList() << "red labels" ) ); QCOMPARE( tagsChangedSpy.count(), 26 ); - QCOMPARE( tagsChangedSpy.at( 25 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::LabelSettingsEntity ) ); + QCOMPARE( tagsChangedSpy.at( 25 ).at( 0 ).toInt(), static_cast( QgsStyle::LabelSettingsEntity ) ); QCOMPARE( tagsChangedSpy.at( 25 ).at( 1 ).toString(), QStringLiteral( "settings2" ) ); QCOMPARE( tagsChangedSpy.at( 25 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) << QStringLiteral( "red labels" ) ); @@ -1150,7 +1127,7 @@ void TestStyle::testTags() QCOMPARE( tags.count(), 1 ); QVERIFY( tags.contains( "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 27 ); - QCOMPARE( tagsChangedSpy.at( 26 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LabelSettingsEntity ) ); + QCOMPARE( tagsChangedSpy.at( 26 ).at( 0 ).toInt(), static_cast( QgsStyle::LabelSettingsEntity ) ); QCOMPARE( tagsChangedSpy.at( 26 ).at( 1 ).toString(), QStringLiteral( "settings1" ) ); QCOMPARE( tagsChangedSpy.at( 26 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "starry" ) ); @@ -1159,7 +1136,7 @@ void TestStyle::testTags() tags = mStyle->tagsOfSymbol( QgsStyle::LabelSettingsEntity, QStringLiteral( "settings1" ) ); QCOMPARE( tags.count(), 0 ); QCOMPARE( tagsChangedSpy.count(), 28 ); - QCOMPARE( tagsChangedSpy.at( 27 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LabelSettingsEntity ) ); + QCOMPARE( tagsChangedSpy.at( 27 ).at( 0 ).toInt(), static_cast( QgsStyle::LabelSettingsEntity ) ); QCOMPARE( tagsChangedSpy.at( 27 ).at( 1 ).toString(), QStringLiteral( "settings1" ) ); QCOMPARE( tagsChangedSpy.at( 27 ).at( 2 ).toStringList(), QStringList() ); @@ -1174,13 +1151,13 @@ void TestStyle::testTags() QVERIFY( mStyle->tagSymbol( QgsStyle::LegendPatchShapeEntity, "shape1", QStringList() << "blue" << "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 31 ); - QCOMPARE( tagsChangedSpy.at( 30 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::LegendPatchShapeEntity ) ); + QCOMPARE( tagsChangedSpy.at( 30 ).at( 0 ).toInt(), static_cast( QgsStyle::LegendPatchShapeEntity ) ); QCOMPARE( tagsChangedSpy.at( 30 ).at( 1 ).toString(), QStringLiteral( "shape1" ) ); QCOMPARE( tagsChangedSpy.at( 30 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "blue" ) << QStringLiteral( "starry" ) ); QVERIFY( mStyle->tagSymbol( QgsStyle::LegendPatchShapeEntity, "shape2", QStringList() << "red" << "circle" ) ); QCOMPARE( tagsChangedSpy.count(), 32 ); - QCOMPARE( tagsChangedSpy.at( 31 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::LegendPatchShapeEntity ) ); + QCOMPARE( tagsChangedSpy.at( 31 ).at( 0 ).toInt(), static_cast( QgsStyle::LegendPatchShapeEntity ) ); QCOMPARE( tagsChangedSpy.at( 31 ).at( 1 ).toString(), QStringLiteral( "shape2" ) ); QCOMPARE( tagsChangedSpy.at( 31 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) ); @@ -1190,7 +1167,7 @@ void TestStyle::testTags() //tag which hasn't been added yet QVERIFY( mStyle->tagSymbol( QgsStyle::LegendPatchShapeEntity, "shape2", QStringList() << "red patch" ) ); QCOMPARE( tagsChangedSpy.count(), 33 ); - QCOMPARE( tagsChangedSpy.at( 32 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::LegendPatchShapeEntity ) ); + QCOMPARE( tagsChangedSpy.at( 32 ).at( 0 ).toInt(), static_cast( QgsStyle::LegendPatchShapeEntity ) ); QCOMPARE( tagsChangedSpy.at( 32 ).at( 1 ).toString(), QStringLiteral( "shape2" ) ); QCOMPARE( tagsChangedSpy.at( 32 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) << QStringLiteral( "red patch" ) ); @@ -1214,7 +1191,7 @@ void TestStyle::testTags() QCOMPARE( tags.count(), 1 ); QVERIFY( tags.contains( "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 34 ); - QCOMPARE( tagsChangedSpy.at( 33 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LegendPatchShapeEntity ) ); + QCOMPARE( tagsChangedSpy.at( 33 ).at( 0 ).toInt(), static_cast( QgsStyle::LegendPatchShapeEntity ) ); QCOMPARE( tagsChangedSpy.at( 33 ).at( 1 ).toString(), QStringLiteral( "shape1" ) ); QCOMPARE( tagsChangedSpy.at( 33 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "starry" ) ); @@ -1223,7 +1200,7 @@ void TestStyle::testTags() tags = mStyle->tagsOfSymbol( QgsStyle::LegendPatchShapeEntity, QStringLiteral( "shape1" ) ); QCOMPARE( tags.count(), 0 ); QCOMPARE( tagsChangedSpy.count(), 35 ); - QCOMPARE( tagsChangedSpy.at( 34 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::LegendPatchShapeEntity ) ); + QCOMPARE( tagsChangedSpy.at( 34 ).at( 0 ).toInt(), static_cast( QgsStyle::LegendPatchShapeEntity ) ); QCOMPARE( tagsChangedSpy.at( 34 ).at( 1 ).toString(), QStringLiteral( "shape1" ) ); QCOMPARE( tagsChangedSpy.at( 34 ).at( 2 ).toStringList(), QStringList() ); @@ -1237,13 +1214,13 @@ void TestStyle::testTags() QVERIFY( mStyle->tagSymbol( QgsStyle::Symbol3DEntity, "3dsymbol1", QStringList() << "blue" << "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 38 ); - QCOMPARE( tagsChangedSpy.at( 37 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::Symbol3DEntity ) ); + QCOMPARE( tagsChangedSpy.at( 37 ).at( 0 ).toInt(), static_cast( QgsStyle::Symbol3DEntity ) ); QCOMPARE( tagsChangedSpy.at( 37 ).at( 1 ).toString(), QStringLiteral( "3dsymbol1" ) ); QCOMPARE( tagsChangedSpy.at( 37 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "blue" ) << QStringLiteral( "starry" ) ); QVERIFY( mStyle->tagSymbol( QgsStyle::Symbol3DEntity, "3dsymbol2", QStringList() << "red" << "circle" ) ); QCOMPARE( tagsChangedSpy.count(), 39 ); - QCOMPARE( tagsChangedSpy.at( 38 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::Symbol3DEntity ) ); + QCOMPARE( tagsChangedSpy.at( 38 ).at( 0 ).toInt(), static_cast( QgsStyle::Symbol3DEntity ) ); QCOMPARE( tagsChangedSpy.at( 38 ).at( 1 ).toString(), QStringLiteral( "3dsymbol2" ) ); QCOMPARE( tagsChangedSpy.at( 38 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) ); @@ -1253,7 +1230,7 @@ void TestStyle::testTags() //tag which hasn't been added yet QVERIFY( mStyle->tagSymbol( QgsStyle::Symbol3DEntity, "3dsymbol2", QStringList() << "red patch" ) ); QCOMPARE( tagsChangedSpy.count(), 40 ); - QCOMPARE( tagsChangedSpy.at( 39 ).at( 0 ).toInt(), static_cast< int>( QgsStyle::Symbol3DEntity ) ); + QCOMPARE( tagsChangedSpy.at( 39 ).at( 0 ).toInt(), static_cast( QgsStyle::Symbol3DEntity ) ); QCOMPARE( tagsChangedSpy.at( 39 ).at( 1 ).toString(), QStringLiteral( "3dsymbol2" ) ); QCOMPARE( tagsChangedSpy.at( 39 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "red" ) << QStringLiteral( "circle" ) << QStringLiteral( "red patch" ) ); @@ -1277,7 +1254,7 @@ void TestStyle::testTags() QCOMPARE( tags.count(), 1 ); QVERIFY( tags.contains( "starry" ) ); QCOMPARE( tagsChangedSpy.count(), 41 ); - QCOMPARE( tagsChangedSpy.at( 40 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::Symbol3DEntity ) ); + QCOMPARE( tagsChangedSpy.at( 40 ).at( 0 ).toInt(), static_cast( QgsStyle::Symbol3DEntity ) ); QCOMPARE( tagsChangedSpy.at( 40 ).at( 1 ).toString(), QStringLiteral( "3dsymbol1" ) ); QCOMPARE( tagsChangedSpy.at( 40 ).at( 2 ).toStringList(), QStringList() << QStringLiteral( "starry" ) ); @@ -1286,7 +1263,7 @@ void TestStyle::testTags() tags = mStyle->tagsOfSymbol( QgsStyle::Symbol3DEntity, QStringLiteral( "3dsymbol1" ) ); QCOMPARE( tags.count(), 0 ); QCOMPARE( tagsChangedSpy.count(), 42 ); - QCOMPARE( tagsChangedSpy.at( 41 ).at( 0 ).toInt(), static_cast< int >( QgsStyle::Symbol3DEntity ) ); + QCOMPARE( tagsChangedSpy.at( 41 ).at( 0 ).toInt(), static_cast( QgsStyle::Symbol3DEntity ) ); QCOMPARE( tagsChangedSpy.at( 41 ).at( 1 ).toString(), QStringLiteral( "3dsymbol1" ) ); QCOMPARE( tagsChangedSpy.at( 41 ).at( 2 ).toStringList(), QStringList() ); } @@ -1298,9 +1275,9 @@ void TestStyle::testSmartGroup() const QSignalSpy groupModifiedSpy( &style, &QgsStyle::groupsModified ); - std::unique_ptr< QgsMarkerSymbol > sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - std::unique_ptr< QgsMarkerSymbol > sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); - std::unique_ptr< QgsMarkerSymbol > sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym1( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym2( QgsMarkerSymbol::createSimple( QVariantMap() ) ); + std::unique_ptr sym3( QgsMarkerSymbol::createSimple( QVariantMap() ) ); style.addSymbol( QStringLiteral( "symbolA" ), sym1->clone(), true ); style.addSymbol( QStringLiteral( "symbolB" ), sym2->clone(), true ); style.addSymbol( QStringLiteral( "symbolC" ), sym3->clone(), true ); @@ -1336,12 +1313,11 @@ void TestStyle::testSmartGroup() int res = style.addSmartgroup( QStringLiteral( "mine" ), QStringLiteral( "AND" ), QStringList(), QStringList(), QStringList() << QStringLiteral( "a" ), QStringList() ); QCOMPARE( res, 1 ); QCOMPARE( style.smartgroupNames(), QStringList() << QStringLiteral( "mine" ) ); - QCOMPARE( style.smartgroup( 1 ).values( QStringLiteral( "name" ) ), QList< QString >() << QStringLiteral( "a" ) ); + QCOMPARE( style.smartgroup( 1 ).values( QStringLiteral( "name" ) ), QList() << QStringLiteral( "a" ) ); QCOMPARE( style.smartgroupId( QStringLiteral( "mine" ) ), 1 ); QCOMPARE( groupModifiedSpy.count(), 1 ); - QCOMPARE( style.allNames( QgsStyle::SmartgroupEntity ), - QStringList() << QStringLiteral( "mine" ) ); + QCOMPARE( style.allNames( QgsStyle::SmartgroupEntity ), QStringList() << QStringLiteral( "mine" ) ); QCOMPARE( style.symbolsOfSmartgroup( QgsStyle::SymbolEntity, 1 ), QStringList() << QStringLiteral( "symbolA" ) ); QCOMPARE( style.symbolsOfSmartgroup( QgsStyle::ColorrampEntity, 1 ), QStringList() << QStringLiteral( "ramp a" ) ); @@ -1353,8 +1329,8 @@ void TestStyle::testSmartGroup() res = style.addSmartgroup( QStringLiteral( "tag" ), QStringLiteral( "OR" ), QStringList(), QStringList(), QStringList() << "c", QStringList() << "a" ); QCOMPARE( res, 2 ); QCOMPARE( style.smartgroupNames(), QStringList() << QStringLiteral( "mine" ) << QStringLiteral( "tag" ) ); - QCOMPARE( style.smartgroup( 2 ).values( QStringLiteral( "name" ) ), QList< QString >() << QStringLiteral( "c" ) ); - QCOMPARE( style.smartgroup( 2 ).values( QStringLiteral( "!name" ) ), QList< QString >() << QStringLiteral( "a" ) ); + QCOMPARE( style.smartgroup( 2 ).values( QStringLiteral( "name" ) ), QList() << QStringLiteral( "c" ) ); + QCOMPARE( style.smartgroup( 2 ).values( QStringLiteral( "!name" ) ), QList() << QStringLiteral( "a" ) ); QCOMPARE( style.smartgroupId( QStringLiteral( "tag" ) ), 2 ); QCOMPARE( groupModifiedSpy.count(), 2 ); @@ -1385,8 +1361,8 @@ void TestStyle::testSmartGroup() res = style.addSmartgroup( QStringLiteral( "tags" ), QStringLiteral( "AND" ), QStringList() << "blue", QStringList() << "red", QStringList(), QStringList() ); QCOMPARE( res, 3 ); QCOMPARE( style.smartgroupNames(), QStringList() << QStringLiteral( "mine" ) << QStringLiteral( "tag" ) << QStringLiteral( "tags" ) ); - QCOMPARE( style.smartgroup( 3 ).values( QStringLiteral( "tag" ) ), QList< QString >() << QStringLiteral( "blue" ) ); - QCOMPARE( style.smartgroup( 3 ).values( QStringLiteral( "!tag" ) ), QList< QString >() << QStringLiteral( "red" ) ); + QCOMPARE( style.smartgroup( 3 ).values( QStringLiteral( "tag" ) ), QList() << QStringLiteral( "blue" ) ); + QCOMPARE( style.smartgroup( 3 ).values( QStringLiteral( "!tag" ) ), QList() << QStringLiteral( "red" ) ); QCOMPARE( style.smartgroupId( QStringLiteral( "tags" ) ), 3 ); QCOMPARE( groupModifiedSpy.count(), 5 ); @@ -1399,9 +1375,9 @@ void TestStyle::testSmartGroup() res = style.addSmartgroup( QStringLiteral( "combined" ), QStringLiteral( "AND" ), QStringList() << "blue", QStringList(), QStringList(), QStringList() << "a" ); QCOMPARE( res, 4 ); - QCOMPARE( style.smartgroupNames(), QStringList() << QStringLiteral( "mine" ) << QStringLiteral( "tag" ) << QStringLiteral( "tags" ) << QStringLiteral( "combined" ) ); - QCOMPARE( style.smartgroup( 4 ).values( QStringLiteral( "tag" ) ), QList< QString >() << QStringLiteral( "blue" ) ); - QCOMPARE( style.smartgroup( 4 ).values( QStringLiteral( "!name" ) ), QList< QString >() << QStringLiteral( "a" ) ); + QCOMPARE( style.smartgroupNames(), QStringList() << QStringLiteral( "mine" ) << QStringLiteral( "tag" ) << QStringLiteral( "tags" ) << QStringLiteral( "combined" ) ); + QCOMPARE( style.smartgroup( 4 ).values( QStringLiteral( "tag" ) ), QList() << QStringLiteral( "blue" ) ); + QCOMPARE( style.smartgroup( 4 ).values( QStringLiteral( "!name" ) ), QList() << QStringLiteral( "a" ) ); QCOMPARE( style.smartgroupId( QStringLiteral( "combined" ) ), 4 ); QCOMPARE( groupModifiedSpy.count(), 6 ); @@ -1413,7 +1389,7 @@ void TestStyle::testSmartGroup() QCOMPARE( style.symbolsOfSmartgroup( QgsStyle::Symbol3DEntity, 4 ), QStringList() << QStringLiteral( "different symbol3D bbb" ) ); style.remove( QgsStyle::SmartgroupEntity, 1 ); - QCOMPARE( style.smartgroupNames(), QStringList() << QStringLiteral( "tag" ) << QStringLiteral( "tags" ) << QStringLiteral( "combined" ) ); + QCOMPARE( style.smartgroupNames(), QStringList() << QStringLiteral( "tag" ) << QStringLiteral( "tags" ) << QStringLiteral( "combined" ) ); QCOMPARE( groupModifiedSpy.count(), 7 ); style.remove( QgsStyle::SmartgroupEntity, 4 ); @@ -1433,7 +1409,6 @@ void TestStyle::testIsStyleXml() class TestVisitor : public QgsStyleEntityVisitorInterface { public: - TestVisitor( QStringList &found ) : mFound( found ) {} @@ -1456,27 +1431,27 @@ class TestVisitor : public QgsStyleEntityVisitorInterface { case QgsStyle::SymbolEntity: { - mFound << QStringLiteral( "symbol: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast< const QgsStyleSymbolEntity * >( entity.entity )->symbol()->color().name() ); + mFound << QStringLiteral( "symbol: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast( entity.entity )->symbol()->color().name() ); break; } case QgsStyle::ColorrampEntity: - mFound << QStringLiteral( "ramp: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast< const QgsStyleColorRampEntity * >( entity.entity )->ramp()->color( 0 ).name() ); + mFound << QStringLiteral( "ramp: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast( entity.entity )->ramp()->color( 0 ).name() ); break; case QgsStyle::TextFormatEntity: - mFound << QStringLiteral( "text format: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast< const QgsStyleTextFormatEntity * >( entity.entity )->format().font().family() ); + mFound << QStringLiteral( "text format: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast( entity.entity )->format().font().family() ); break; case QgsStyle::LabelSettingsEntity: - mFound << QStringLiteral( "labels: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast< const QgsStyleLabelSettingsEntity * >( entity.entity )->settings().fieldName ); + mFound << QStringLiteral( "labels: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast( entity.entity )->settings().fieldName ); break; case QgsStyle::LegendPatchShapeEntity: - mFound << QStringLiteral( "patch: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast< const QgsStyleLegendPatchShapeEntity * >( entity.entity )->shape().geometry().asWkt() ); + mFound << QStringLiteral( "patch: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast( entity.entity )->shape().geometry().asWkt() ); break; case QgsStyle::Symbol3DEntity: - mFound << QStringLiteral( "symbol 3d: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast< const QgsStyleSymbol3DEntity * >( entity.entity )->symbol()->type() ); + mFound << QStringLiteral( "symbol 3d: %1 %2 %3" ).arg( entity.description, entity.identifier, static_cast( entity.entity )->symbol()->type() ); break; case QgsStyle::TagEntity: @@ -1510,9 +1485,7 @@ void TestStyle::testVisitor() vl->setRenderer( new QgsSingleSymbolRenderer( markerSymbol ) ); QVERIFY( p.accept( &visitor ) ); - QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "symbol: #ff0000" ) - << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); + QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) << QStringLiteral( "symbol: #ff0000" ) << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); // rule based renderer QgsVectorLayer *vl2 = new QgsVectorLayer( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=col1:string" ), QStringLiteral( "vl2" ), QStringLiteral( "memory" ) ); @@ -1531,43 +1504,20 @@ void TestStyle::testVisitor() found.clear(); QVERIFY( p.accept( &visitor ) ); - QCOMPARE( found, QStringList() - << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "symbol: #00ff00" ) - << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "symbol: #00ffff" ) - << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "symbol: #ff0000" ) - << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); + QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "symbol: #00ff00" ) << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "symbol: #00ffff" ) << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) << QStringLiteral( "symbol: #ff0000" ) << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); // labeling QgsPalLayerSettings settings; settings.fieldName = QStringLiteral( "Class" ); - vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! + vl->setLabeling( new QgsVectorLayerSimpleLabeling( settings ) ); // TODO: this should not be necessary! found.clear(); QVERIFY( p.accept( &visitor ) ); - QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "symbol: #00ff00" ) - << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "symbol: #00ffff" ) - << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "symbol: #ff0000" ) - << QStringLiteral( "labels: Class" ) - << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); + QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "symbol: #00ff00" ) << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "symbol: #00ffff" ) << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) << QStringLiteral( "symbol: #ff0000" ) << QStringLiteral( "labels: Class" ) << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); // raster layer - QgsRasterLayer *rl = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/tenbytenraster.asc", - QStringLiteral( "rl" ) ); + QgsRasterLayer *rl = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/tenbytenraster.asc", QStringLiteral( "rl" ) ); QVERIFY( rl->isValid() ); p.addMapLayer( rl ); @@ -1582,22 +1532,7 @@ void TestStyle::testVisitor() found.clear(); QVERIFY( p.accept( &visitor ) ); - QCOMPARE( found, QStringList() - << QStringLiteral( "enter: %1 rl" ).arg( rl->id() ) - << QStringLiteral( "ramp: #ffff00" ) - << QStringLiteral( "exit: %1 rl" ).arg( rl->id() ) - << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "symbol: #00ff00" ) - << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "symbol: #00ffff" ) - << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "symbol: #ff0000" ) - << QStringLiteral( "labels: Class" ) - << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); + QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 rl" ).arg( rl->id() ) << QStringLiteral( "ramp: #ffff00" ) << QStringLiteral( "exit: %1 rl" ).arg( rl->id() ) << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "symbol: #00ff00" ) << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "symbol: #00ffff" ) << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) << QStringLiteral( "symbol: #ff0000" ) << QStringLiteral( "labels: Class" ) << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) ); // with layout QgsPrintLayout *l = new QgsPrintLayout( &p ); @@ -1611,42 +1546,18 @@ void TestStyle::testVisitor() QgsLayoutItemLegend *legend = new QgsLayoutItemLegend( l ); l->addLayoutItem( legend ); const QgsLegendPatchShape shape( Qgis::SymbolType::Marker, QgsGeometry::fromWkt( QStringLiteral( "Point( 3 4)" ) ) ); - qobject_cast< QgsLayerTreeLayer * >( legend->model()->index2node( legend->model()->index( 0, 0 ) ) )->setPatchShape( shape ); + qobject_cast( legend->model()->index2node( legend->model()->index( 0, 0 ) ) )->setPatchShape( shape ); const QgsLegendPatchShape shape2( Qgis::SymbolType::Marker, QgsGeometry::fromWkt( QStringLiteral( "Point( 13 14)" ) ) ); - QCOMPARE( qobject_cast< QgsLayerTreeLayer * >( legend->model()->index2node( legend->model()->index( 1, 0 ) ) )->layer()->name(), QStringLiteral( "vl2" ) ); - QgsMapLayerLegendUtils::setLegendNodePatchShape( qobject_cast< QgsLayerTreeLayer * >( legend->model()->index2node( legend->model()->index( 1, 0 ) ) ), 1, shape2 ); - legend->model()->refreshLayerLegend( qobject_cast< QgsLayerTreeLayer * >( legend->model()->index2node( legend->model()->index( 1, 0 ) ) ) ); + QCOMPARE( qobject_cast( legend->model()->index2node( legend->model()->index( 1, 0 ) ) )->layer()->name(), QStringLiteral( "vl2" ) ); + QgsMapLayerLegendUtils::setLegendNodePatchShape( qobject_cast( legend->model()->index2node( legend->model()->index( 1, 0 ) ) ), 1, shape2 ); + legend->model()->refreshLayerLegend( qobject_cast( legend->model()->index2node( legend->model()->index( 1, 0 ) ) ) ); p.layoutManager()->addLayout( l ); found.clear(); QVERIFY( p.accept( &visitor ) ); - QCOMPARE( found, QStringList() - << QStringLiteral( "enter: %1 rl" ).arg( rl->id() ) - << QStringLiteral( "ramp: #ffff00" ) - << QStringLiteral( "exit: %1 rl" ).arg( rl->id() ) - << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "symbol: #00ff00" ) - << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "symbol: #00ffff" ) - << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) - << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) - << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) - << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "symbol: #ff0000" ) - << QStringLiteral( "labels: Class" ) - << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "enter: layouts Layouts" ) - << QStringLiteral( "enter: layout test layout" ) - << QStringLiteral( "patch: %1 Point (3 4)" ).arg( legend->uuid() ) - << QStringLiteral( "patch: %1 Point (13 14)" ).arg( legend->uuid() ) - << QStringLiteral( "text format: %1 QGIS Vera Sans" ).arg( scalebar->uuid() ) - << QStringLiteral( "symbol: Page page #ffffff" ) - << QStringLiteral( "exit: layout test layout" ) - << QStringLiteral( "exit: layouts Layouts" ) - ); + QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 rl" ).arg( rl->id() ) << QStringLiteral( "ramp: #ffff00" ) << QStringLiteral( "exit: %1 rl" ).arg( rl->id() ) << QStringLiteral( "enter: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "symbol: #00ff00" ) << QStringLiteral( "enter: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "symbol: #00ffff" ) << QStringLiteral( "exit: %1 " ).arg( rule3->ruleKey() ) << QStringLiteral( "exit: %1 " ).arg( rule2->ruleKey() ) << QStringLiteral( "exit: %1 vl2" ).arg( vl2->id() ) << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) << QStringLiteral( "symbol: #ff0000" ) << QStringLiteral( "labels: Class" ) << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) << QStringLiteral( "enter: layouts Layouts" ) << QStringLiteral( "enter: layout test layout" ) << QStringLiteral( "patch: %1 Point (3 4)" ).arg( legend->uuid() ) << QStringLiteral( "patch: %1 Point (13 14)" ).arg( legend->uuid() ) << QStringLiteral( "text format: %1 QGIS Vera Sans" ).arg( scalebar->uuid() ) << QStringLiteral( "symbol: Page page #ffffff" ) << QStringLiteral( "exit: layout test layout" ) << QStringLiteral( "exit: layouts Layouts" ) ); p.removeMapLayer( vl2 ); @@ -1654,36 +1565,16 @@ void TestStyle::testVisitor() QgsTextAnnotation *annotation = new QgsTextAnnotation(); QgsSymbol *a1 = QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ); a1->setColor( QColor( 0, 200, 0 ) ); - annotation->setMarkerSymbol( static_cast< QgsMarkerSymbol * >( a1 ) ); + annotation->setMarkerSymbol( static_cast( a1 ) ); QgsSymbol *a2 = QgsSymbol::defaultSymbol( Qgis::GeometryType::Polygon ); a2->setColor( QColor( 200, 200, 0 ) ); - annotation->setFillSymbol( static_cast< QgsFillSymbol * >( a2 ) ); + annotation->setFillSymbol( static_cast( a2 ) ); p.annotationManager()->addAnnotation( annotation ); found.clear(); QVERIFY( p.accept( &visitor ) ); - QCOMPARE( found, QStringList() - << QStringLiteral( "enter: %1 rl" ).arg( rl->id() ) - << QStringLiteral( "ramp: #ffff00" ) - << QStringLiteral( "exit: %1 rl" ).arg( rl->id() ) - << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "symbol: #ff0000" ) - << QStringLiteral( "labels: Class" ) - << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) - << QStringLiteral( "enter: layouts Layouts" ) - << QStringLiteral( "enter: layout test layout" ) - << QStringLiteral( "patch: %1 Point (3 4)" ).arg( legend->uuid() ) - << QStringLiteral( "text format: %1 QGIS Vera Sans" ).arg( scalebar->uuid() ) - << QStringLiteral( "symbol: Page page #ffffff" ) - << QStringLiteral( "exit: layout test layout" ) - << QStringLiteral( "exit: layouts Layouts" ) - << QStringLiteral( "enter: annotations Annotations" ) - << QStringLiteral( "enter: annotation Annotation" ) - << QStringLiteral( "symbol: Marker marker #00c800" ) - << QStringLiteral( "symbol: Fill fill #c8c800" ) - << QStringLiteral( "exit: annotation Annotation" ) - << QStringLiteral( "exit: annotations Annotations" ) ); + QCOMPARE( found, QStringList() << QStringLiteral( "enter: %1 rl" ).arg( rl->id() ) << QStringLiteral( "ramp: #ffff00" ) << QStringLiteral( "exit: %1 rl" ).arg( rl->id() ) << QStringLiteral( "enter: %1 vl" ).arg( vl->id() ) << QStringLiteral( "symbol: #ff0000" ) << QStringLiteral( "labels: Class" ) << QStringLiteral( "exit: %1 vl" ).arg( vl->id() ) << QStringLiteral( "enter: layouts Layouts" ) << QStringLiteral( "enter: layout test layout" ) << QStringLiteral( "patch: %1 Point (3 4)" ).arg( legend->uuid() ) << QStringLiteral( "text format: %1 QGIS Vera Sans" ).arg( scalebar->uuid() ) << QStringLiteral( "symbol: Page page #ffffff" ) << QStringLiteral( "exit: layout test layout" ) << QStringLiteral( "exit: layouts Layouts" ) << QStringLiteral( "enter: annotations Annotations" ) << QStringLiteral( "enter: annotation Annotation" ) << QStringLiteral( "symbol: Marker marker #00c800" ) << QStringLiteral( "symbol: Fill fill #c8c800" ) << QStringLiteral( "exit: annotation Annotation" ) << QStringLiteral( "exit: annotations Annotations" ) ); } void TestStyle::testColorRampShaderClassificationEqualInterval() @@ -1695,11 +1586,11 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 63.75, QColor( 0, 191, 64 ), "63.8" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 127.5, QColor( 0, 128, 128 ), "128" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 191.25, QColor( 0, 64, 191 ), "191" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 63.75, QColor( 0, 191, 64 ), "63.8" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 127.5, QColor( 0, 128, 128 ), "128" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 191.25, QColor( 0, 64, 191 ), "191" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } @@ -1711,11 +1602,11 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 63.75, QColor( 0, 191, 64 ), "63.8" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 127.5, QColor( 0, 128, 128 ), "128" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 191.25, QColor( 0, 64, 191 ), "191" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 63.75, QColor( 0, 191, 64 ), "63.8" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 127.5, QColor( 0, 128, 128 ), "128" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 191.25, QColor( 0, 64, 191 ), "191" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } @@ -1727,11 +1618,11 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 51, QColor( 0, 255, 0 ), "51" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 102, QColor( 0, 191, 64 ), "102" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 153, QColor( 0, 128, 128 ), "153" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 204, QColor( 0, 64, 191 ), "204" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 51, QColor( 0, 255, 0 ), "51" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 102, QColor( 0, 191, 64 ), "102" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 153, QColor( 0, 128, 128 ), "153" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 204, QColor( 0, 64, 191 ), "204" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } @@ -1745,13 +1636,12 @@ void TestStyle::testColorRampShaderClassificationEqualInterval() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); if ( type == Qgis::ShaderInterpolationMethod::Discrete ) - itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } - } void TestStyle::testColorRampShaderClassificationContinius() @@ -1763,8 +1653,8 @@ void TestStyle::testColorRampShaderClassificationContinius() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } @@ -1776,8 +1666,8 @@ void TestStyle::testColorRampShaderClassificationContinius() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 255, QColor( 0, 0, 255 ), "255" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } @@ -1789,8 +1679,8 @@ void TestStyle::testColorRampShaderClassificationContinius() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 127.5, QColor( 0, 255, 0 ), "128" ) ); - itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 127.5, QColor( 0, 255, 0 ), "128" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } @@ -1804,9 +1694,9 @@ void TestStyle::testColorRampShaderClassificationContinius() QList itemsList = shader->colorRampItemList(); QList itemsList2; - itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( 0, QColor( 0, 255, 0 ), "0" ) ); if ( type == Qgis::ShaderInterpolationMethod::Discrete ) - itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); + itemsList2.append( QgsColorRampShader::ColorRampItem( qInf(), QColor( 0, 0, 255 ), "inf" ) ); QVERIFY( compareItemLists( itemsList, itemsList2 ) ); } @@ -1830,7 +1720,7 @@ void TestStyle::testDefaultLabelTextFormat() // re-create default label settings const QgsPalLayerSettings settings2; // should be default text format now, not app default font - QCOMPARE( settings2.format().font().family(), QgsFontUtils::getStandardTestFont().family() ); + QCOMPARE( settings2.format().font().family(), QgsFontUtils::getStandardTestFont().family() ); QVERIFY( settings2.format().buffer().enabled() ); } diff --git a/tests/src/core/testqgssvgcache.cpp b/tests/src/core/testqgssvgcache.cpp index d48a47750d92..f7b96e7fa4f8 100644 --- a/tests/src/core/testqgssvgcache.cpp +++ b/tests/src/core/testqgssvgcache.cpp @@ -36,17 +36,17 @@ class TestQgsSvgCache : public QgsTest Q_OBJECT public: - TestQgsSvgCache() : QgsTest( QStringLiteral( "QgsSvgCache Tests" ) ) {} + TestQgsSvgCache() + : QgsTest( QStringLiteral( "QgsSvgCache Tests" ) ) {} private: - bool imageCheck( const QString &testName, QImage &image, int mismatchCount ); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void fillCache(); void broken(); void threadSafePicture(); @@ -108,22 +108,22 @@ void TestQgsSvgCache::broken() struct RenderPictureWrapper { - QgsSvgCache &cache; - QString svgPath; - double size = 100; - explicit RenderPictureWrapper( QgsSvgCache &cache, const QString &svgPath ) - : cache( cache ) - , svgPath( svgPath ) - {} - void operator()( int ) - { - const QPicture pic = cache.svgAsPicture( svgPath, size, QColor( 255, 0, 0 ), QColor( 0, 255, 0 ), 1, 1, true ); - const QSize imageSize = pic.boundingRect().size(); - QImage image( imageSize, QImage::Format_ARGB32_Premultiplied ); - image.fill( 0 ); // transparent background - QPainter p( &image ); - p.drawPicture( 0, 0, pic ); - } + QgsSvgCache &cache; + QString svgPath; + double size = 100; + explicit RenderPictureWrapper( QgsSvgCache &cache, const QString &svgPath ) + : cache( cache ) + , svgPath( svgPath ) + {} + void operator()( int ) + { + const QPicture pic = cache.svgAsPicture( svgPath, size, QColor( 255, 0, 0 ), QColor( 0, 255, 0 ), 1, 1, true ); + const QSize imageSize = pic.boundingRect().size(); + QImage image( imageSize, QImage::Format_ARGB32_Premultiplied ); + image.fill( 0 ); // transparent background + QPainter p( &image ); + p.drawPicture( 0, 0, pic ); + } }; void TestQgsSvgCache::threadSafePicture() @@ -140,7 +140,7 @@ void TestQgsSvgCache::threadSafePicture() const QString svgPath = TEST_DATA_DIR + QStringLiteral( "/sample_svg.svg" ); // smash picture rendering over multiple threads - QVector< int > list; + QVector list; list.resize( 100 ); QtConcurrent::blockingMap( list, RenderPictureWrapper( cache, svgPath ) ); } @@ -148,22 +148,22 @@ void TestQgsSvgCache::threadSafePicture() struct RenderImageWrapper { - QgsSvgCache &cache; - QString svgPath; - double size = 100; - explicit RenderImageWrapper( QgsSvgCache &cache, const QString &svgPath ) - : cache( cache ) - , svgPath( svgPath ) - {} - void operator()( int ) - { - bool fitsInCache = false; - const QImage cachedImage = cache.svgAsImage( svgPath, size, QColor( 255, 0, 0 ), QColor( 0, 255, 0 ), 1, 1, fitsInCache ); - QImage image( cachedImage.size(), QImage::Format_ARGB32_Premultiplied ); - image.fill( 0 ); // transparent background - QPainter p( &image ); - p.drawImage( 0, 0, cachedImage ); - } + QgsSvgCache &cache; + QString svgPath; + double size = 100; + explicit RenderImageWrapper( QgsSvgCache &cache, const QString &svgPath ) + : cache( cache ) + , svgPath( svgPath ) + {} + void operator()( int ) + { + bool fitsInCache = false; + const QImage cachedImage = cache.svgAsImage( svgPath, size, QColor( 255, 0, 0 ), QColor( 0, 255, 0 ), 1, 1, fitsInCache ); + QImage image( cachedImage.size(), QImage::Format_ARGB32_Premultiplied ); + image.fill( 0 ); // transparent background + QPainter p( &image ); + p.drawImage( 0, 0, cachedImage ); + } }; void TestQgsSvgCache::threadSafeImage() @@ -175,7 +175,7 @@ void TestQgsSvgCache::threadSafeImage() const QString svgPath = TEST_DATA_DIR + QStringLiteral( "/sample_svg.svg" ); // smash image rendering over multiple threads - QVector< int > list; + QVector list; list.resize( 100 ); QtConcurrent::blockingMap( list, RenderImageWrapper( cache, svgPath ) ); } @@ -196,15 +196,15 @@ void TestQgsSvgCache::changeImage() QFile::copy( originalImage, tempImagePath ); //render it through the cache - QImage img = cache.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache ); + QImage img = cache.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache ); QVERIFY( imageCheck( "svgcache_changed_before", img, 30 ) ); // wait a second so that modified time is different QElapsedTimer t; t.start(); while ( !t.hasExpired( 1000 ) ) - {} + { + } //replace the image in the temp folder const QString newImage = TEST_DATA_DIR + QStringLiteral( "/test_symbol_svg2.svg" ); @@ -212,22 +212,21 @@ void TestQgsSvgCache::changeImage() QFile::copy( newImage, tempImagePath ); //re-render it - img = cache.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache ); + img = cache.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache ); QVERIFY( imageCheck( "svgcache_changed_after", img, 30 ) ); // repeat, with minimum time between checks QgsSvgCache cache2; QFile::remove( tempImagePath ); QFile::copy( originalImage, tempImagePath ); - img = cache2.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache ); + img = cache2.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache ); QVERIFY( imageCheck( "svgcache_changed_before", img, 30 ) ); // wait a second so that modified time is different t.restart(); while ( !t.hasExpired( 1000 ) ) - {} + { + } //replace the image in the temp folder QFile::remove( tempImagePath ); @@ -235,8 +234,7 @@ void TestQgsSvgCache::changeImage() //re-render it - not enough time has elapsed between checks, so file modification time will NOT be rechecked and // existing cached image should be used - img = cache2.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache ); + img = cache2.svgAsImage( tempImagePath, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache ); QVERIFY( imageCheck( "svgcache_changed_before", img, 30 ) ); } @@ -247,20 +245,15 @@ void TestQgsSvgCache::base64() bool inCache = false; // invalid base64 strings - QImage img = cache.svgAsImage( QStringLiteral( "base64:" ), 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache ); + QImage img = cache.svgAsImage( QStringLiteral( "base64:" ), 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache ); QVERIFY( imageCheck( QStringLiteral( "null_image" ), img, 0 ) ); - img = cache.svgAsImage( QStringLiteral( "base64:zzzzzzzzzzzzzzzzzzzz" ), 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache ); + img = cache.svgAsImage( QStringLiteral( "base64:zzzzzzzzzzzzzzzzzzzz" ), 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache ); QVERIFY( imageCheck( QStringLiteral( "null_image" ), img, 0 ) ); //valid base 64 - img = cache.svgAsImage( QStringLiteral( "base64:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNi4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnMiIKICAgaW5rc2NhcGU6b3V0cHV0X2V4dGVuc2lvbj0ib3JnLmlua3NjYXBlLm91dHB1dC5zdmcuaW5rc2NhcGUiCiAgIHNvZGlwb2RpOmRvY25hbWU9InNob3BwaW5nX2RpeS5zdmciCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTp2ZXJzaW9uPSIwLjMyIgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgd2lkdGg9IjMwNi4zMzQ3NSIKICAgaGVpZ2h0PSI0ODQuNzk5OTkiCiAgIHZpZXdCb3g9IjAgMCAzMDYuMzM0NzUgNDg0Ljc5OTk5IgogICBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1ODAgNTgwIgogICB4bWw6c3BhY2U9InByZXNlcnZlIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGEyNiI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PHNvZGlwb2RpOm5hbWVkdmlldwogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTpjeT0iLTExNS4wNDM3MiIKICAgICBpbmtzY2FwZTpjeD0iMTMwLjIyMTYxIgogICAgIGlua3NjYXBlOnpvb209IjAuNDYwODM4NTYiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGd1aWRldG9sZXJhbmNlPSIxMC4wIgogICAgIG9iamVjdHRvbGVyYW5jZT0iMTAuMCIKICAgICBncmlkdG9sZXJhbmNlPSIxMC4wIgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpZD0iYmFzZSIKICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJzdmcyIgogICAgIGlua3NjYXBlOndpbmRvdy15PSIzNCIKICAgICBpbmtzY2FwZTp3aW5kb3cteD0iNzUiCiAgICAgaW5rc2NhcGU6cGFnZW9wYWNpdHk9IjAuMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTAxNCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI3MTEiCiAgICAgZml0LW1hcmdpbi10b3A9IjAiCiAgICAgZml0LW1hcmdpbi1sZWZ0PSIwIgogICAgIGZpdC1tYXJnaW4tcmlnaHQ9IjAiCiAgICAgZml0LW1hcmdpbi1ib3R0b209IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LW1heGltaXplZD0iMCIgLz48ZGVmcwogICAgIGlkPSJkZWZzNCIgLz48ZwogICAgIGlkPSJsYXllcjMiCiAgICAgdHJhbnNmb3JtPSJtYXRyaXgoNDguMTQ5NjksMCwwLDQ4LjE0OTY5LC02NzMuMTA0NTMsLTgwLjkwNTc1MikiCiAgICAgaW5rc2NhcGU6bGFiZWw9IkxheW91dCIKICAgICBkaXNwbGF5PSJub25lIgogICAgIHN0eWxlPSJkaXNwbGF5Om5vbmUiPjxyZWN0CiAgICAgICBpZD0icmVjdDQxMzQiCiAgICAgICB4PSIxIgogICAgICAgeT0iMSIKICAgICAgIGRpc3BsYXk9ImlubGluZSIKICAgICAgIHdpZHRoPSIxMCIKICAgICAgIGhlaWdodD0iMTAiCiAgICAgICBzdHlsZT0iZGlzcGxheTppbmxpbmU7ZmlsbDpub25lO3N0cm9rZTojNzU3NTc1O3N0cm9rZS13aWR0aDowLjEiIC8+PHJlY3QKICAgICAgIGlkPSJyZWN0NDEzNiIKICAgICAgIHg9IjIiCiAgICAgICB5PSIyIgogICAgICAgZGlzcGxheT0iaW5saW5lIgogICAgICAgd2lkdGg9IjgiCiAgICAgICBoZWlnaHQ9IjgiCiAgICAgICBzdHlsZT0iZGlzcGxheTppbmxpbmU7ZmlsbDpub25lO3N0cm9rZTojNzU3NTc1O3N0cm9rZS13aWR0aDowLjEiIC8+PC9nPjxwYXRoCiAgICAgZmlsbD0icGFyYW0oZmlsbCkiCiAgICAgc3Ryb2tlPSJwYXJhbShvdXRsaW5lKSIKICAgICBzdHJva2Utd2lkdGg9InBhcmFtKG91dGxpbmUtd2lkdGgpIgogICAgIGQ9Ik0gMzA2LjI5NTc0LDE5LjU1NCBDIDMwNi4yMTk3NCw4LjU4OSAyOTYuNjg3NzQsMCAyODQuNTk1NzQsMCBsIC0wLjE3OSwwLjAwMSBjIC0xMC4xOTEsMCAtMTguNzksNi40ODggLTIwLjg5MSwxNS41ODYgLTE0LjM2LC0wLjkxNSAtMjEuMTM2LC0zLjYwMiAtMjguMjk4LC02LjQ0MSAtOC44MzQsLTMuNTAzIC0xNy45NjksLTcuMTI1IC00MS40MjEsLTguMjgyIGwgLTc3Ljc5LC0wLjcyIEMgNjcuNzkyNzQyLDAuNjgyIDI4LjgwODc0MiwyOC42MjQgMC4xNDU3NDIwMSw4My4xOTMgYyAtMC4yNjksMC41MTIgLTAuMTU4LDEuMTQgMC4yNywxLjUyNyAwLjQyOCwwLjM4OSAxLjA2Mjk5OTk5LDAuNDM4IDEuNTQ1OTk5OTksMC4xMjMgbCAyLjU2MywtMS42NzggYyAwLjE4OCwtMC4xMjMgMC4zNCwtMC4yOTMgMC40NCwtMC40OTQgOS42MzgsLTE5LjMxNiA0NS43ODUsLTM2LjI2IDc3LjM1NSwtMzYuMjYgMjAuNzk0OTk4LDAgMzUuMjgzOTk4LDcuNDg4IDQwLjgxNDk5OCwyMS4wODggMS41MjYsNy44ODUgOS43OCwxNS4zNDUgMTguNzUzLDE3LjExMSBsIDAuMjMyLDEzNi4xNTkgYyAtOC4wNDcsMC44NTQgLTE2LjI2NSw5LjQ4NCAtMTYuNDI5LDE3LjY1NiBsIC00LjI2NCwyMjQuMjg2IGMgLTAuMTI5LDYuODQ0IDEuNjEyLDEyLjE2OSA1LjE3NSwxNS44MyA1Ljk3NSw2LjEzOCAxNS41NjgsNi4yMTQgMjEuMyw2LjI1OSAwLjAwNCwwIDAuMDA4LDAgMC4wMTIsMCBsIDQxLjA2MSwtMC4wNjIgYyA2LjU1NCwtMC4wMyAxNS43OTQsLTIuNzggMjEuNjYsLTguODU1IDQuMTAxLC00LjI0NiA2LjA4NCwtOS41MjcgNS44OTYsLTE1LjY5MyBsIC02LjE2NCwtMjIxLjgxNSBjIC0wLjIxNiwtOC4wMzUgLTguNDU2LC0xNi42MTYgLTE2LjQ1NCwtMTcuNTA3IGwgLTAuMTc5LC0xMzYuNjA1IGMgMTIuMDU3LC0wLjkzNCAyMC4zNDgsLTYuMDU2IDI2LjAyNywtMTYuMDUzIDQuMjM0LC03LjQ1IDEwLjk5OSwtMTAuNzczIDIxLjkzNSwtMTAuNzczIDQuNzE3LDAgOS43NTgsMC41OTggMTQuNjMzLDEuMTc2IDIuMTE4LDAuMjUxIDQuMjk3LDAuNTEgNi40MjIsMC43MTUgbCAtMC4wMzcsNS42NTggYyAwLjA3NSwxMC44MTMgOS44NjIsMTkuNjA5IDIxLjg1NCwxOS42MDkgMTIuMDE4LC0wLjAxOSAyMS43ODIsLTguODM1IDIxLjc2NywtMTkuNjUyIGwgLTAuMDM5LC00NS4zODkgeiIKICAgICBpZD0icGF0aDI0IgogICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiIC8+PC9zdmc+" ), - 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache ); + img = cache.svgAsImage( QStringLiteral( "base64:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNi4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4KCjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnMiIKICAgaW5rc2NhcGU6b3V0cHV0X2V4dGVuc2lvbj0ib3JnLmlua3NjYXBlLm91dHB1dC5zdmcuaW5rc2NhcGUiCiAgIHNvZGlwb2RpOmRvY25hbWU9InNob3BwaW5nX2RpeS5zdmciCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTp2ZXJzaW9uPSIwLjMyIgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgd2lkdGg9IjMwNi4zMzQ3NSIKICAgaGVpZ2h0PSI0ODQuNzk5OTkiCiAgIHZpZXdCb3g9IjAgMCAzMDYuMzM0NzUgNDg0Ljc5OTk5IgogICBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1ODAgNTgwIgogICB4bWw6c3BhY2U9InByZXNlcnZlIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGEyNiI+PHJkZjpSREY+PGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPjxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PjxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz48ZGM6dGl0bGU+PC9kYzp0aXRsZT48L2NjOldvcms+PC9yZGY6UkRGPjwvbWV0YWRhdGE+PHNvZGlwb2RpOm5hbWVkdmlldwogICAgIHNob3dncmlkPSJmYWxzZSIKICAgICBpbmtzY2FwZTpjeT0iLTExNS4wNDM3MiIKICAgICBpbmtzY2FwZTpjeD0iMTMwLjIyMTYxIgogICAgIGlua3NjYXBlOnpvb209IjAuNDYwODM4NTYiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGd1aWRldG9sZXJhbmNlPSIxMC4wIgogICAgIG9iamVjdHRvbGVyYW5jZT0iMTAuMCIKICAgICBncmlkdG9sZXJhbmNlPSIxMC4wIgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpZD0iYmFzZSIKICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJzdmcyIgogICAgIGlua3NjYXBlOndpbmRvdy15PSIzNCIKICAgICBpbmtzY2FwZTp3aW5kb3cteD0iNzUiCiAgICAgaW5rc2NhcGU6cGFnZW9wYWNpdHk9IjAuMCIKICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTAxNCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI3MTEiCiAgICAgZml0LW1hcmdpbi10b3A9IjAiCiAgICAgZml0LW1hcmdpbi1sZWZ0PSIwIgogICAgIGZpdC1tYXJnaW4tcmlnaHQ9IjAiCiAgICAgZml0LW1hcmdpbi1ib3R0b209IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LW1heGltaXplZD0iMCIgLz48ZGVmcwogICAgIGlkPSJkZWZzNCIgLz48ZwogICAgIGlkPSJsYXllcjMiCiAgICAgdHJhbnNmb3JtPSJtYXRyaXgoNDguMTQ5NjksMCwwLDQ4LjE0OTY5LC02NzMuMTA0NTMsLTgwLjkwNTc1MikiCiAgICAgaW5rc2NhcGU6bGFiZWw9IkxheW91dCIKICAgICBkaXNwbGF5PSJub25lIgogICAgIHN0eWxlPSJkaXNwbGF5Om5vbmUiPjxyZWN0CiAgICAgICBpZD0icmVjdDQxMzQiCiAgICAgICB4PSIxIgogICAgICAgeT0iMSIKICAgICAgIGRpc3BsYXk9ImlubGluZSIKICAgICAgIHdpZHRoPSIxMCIKICAgICAgIGhlaWdodD0iMTAiCiAgICAgICBzdHlsZT0iZGlzcGxheTppbmxpbmU7ZmlsbDpub25lO3N0cm9rZTojNzU3NTc1O3N0cm9rZS13aWR0aDowLjEiIC8+PHJlY3QKICAgICAgIGlkPSJyZWN0NDEzNiIKICAgICAgIHg9IjIiCiAgICAgICB5PSIyIgogICAgICAgZGlzcGxheT0iaW5saW5lIgogICAgICAgd2lkdGg9IjgiCiAgICAgICBoZWlnaHQ9IjgiCiAgICAgICBzdHlsZT0iZGlzcGxheTppbmxpbmU7ZmlsbDpub25lO3N0cm9rZTojNzU3NTc1O3N0cm9rZS13aWR0aDowLjEiIC8+PC9nPjxwYXRoCiAgICAgZmlsbD0icGFyYW0oZmlsbCkiCiAgICAgc3Ryb2tlPSJwYXJhbShvdXRsaW5lKSIKICAgICBzdHJva2Utd2lkdGg9InBhcmFtKG91dGxpbmUtd2lkdGgpIgogICAgIGQ9Ik0gMzA2LjI5NTc0LDE5LjU1NCBDIDMwNi4yMTk3NCw4LjU4OSAyOTYuNjg3NzQsMCAyODQuNTk1NzQsMCBsIC0wLjE3OSwwLjAwMSBjIC0xMC4xOTEsMCAtMTguNzksNi40ODggLTIwLjg5MSwxNS41ODYgLTE0LjM2LC0wLjkxNSAtMjEuMTM2LC0zLjYwMiAtMjguMjk4LC02LjQ0MSAtOC44MzQsLTMuNTAzIC0xNy45NjksLTcuMTI1IC00MS40MjEsLTguMjgyIGwgLTc3Ljc5LC0wLjcyIEMgNjcuNzkyNzQyLDAuNjgyIDI4LjgwODc0MiwyOC42MjQgMC4xNDU3NDIwMSw4My4xOTMgYyAtMC4yNjksMC41MTIgLTAuMTU4LDEuMTQgMC4yNywxLjUyNyAwLjQyOCwwLjM4OSAxLjA2Mjk5OTk5LDAuNDM4IDEuNTQ1OTk5OTksMC4xMjMgbCAyLjU2MywtMS42NzggYyAwLjE4OCwtMC4xMjMgMC4zNCwtMC4yOTMgMC40NCwtMC40OTQgOS42MzgsLTE5LjMxNiA0NS43ODUsLTM2LjI2IDc3LjM1NSwtMzYuMjYgMjAuNzk0OTk4LDAgMzUuMjgzOTk4LDcuNDg4IDQwLjgxNDk5OCwyMS4wODggMS41MjYsNy44ODUgOS43OCwxNS4zNDUgMTguNzUzLDE3LjExMSBsIDAuMjMyLDEzNi4xNTkgYyAtOC4wNDcsMC44NTQgLTE2LjI2NSw5LjQ4NCAtMTYuNDI5LDE3LjY1NiBsIC00LjI2NCwyMjQuMjg2IGMgLTAuMTI5LDYuODQ0IDEuNjEyLDEyLjE2OSA1LjE3NSwxNS44MyA1Ljk3NSw2LjEzOCAxNS41NjgsNi4yMTQgMjEuMyw2LjI1OSAwLjAwNCwwIDAuMDA4LDAgMC4wMTIsMCBsIDQxLjA2MSwtMC4wNjIgYyA2LjU1NCwtMC4wMyAxNS43OTQsLTIuNzggMjEuNjYsLTguODU1IDQuMTAxLC00LjI0NiA2LjA4NCwtOS41MjcgNS44OTYsLTE1LjY5MyBsIC02LjE2NCwtMjIxLjgxNSBjIC0wLjIxNiwtOC4wMzUgLTguNDU2LC0xNi42MTYgLTE2LjQ1NCwtMTcuNTA3IGwgLTAuMTc5LC0xMzYuNjA1IGMgMTIuMDU3LC0wLjkzNCAyMC4zNDgsLTYuMDU2IDI2LjAyNywtMTYuMDUzIDQuMjM0LC03LjQ1IDEwLjk5OSwtMTAuNzczIDIxLjkzNSwtMTAuNzczIDQuNzE3LDAgOS43NTgsMC41OTggMTQuNjMzLDEuMTc2IDIuMTE4LDAuMjUxIDQuMjk3LDAuNTEgNi40MjIsMC43MTUgbCAtMC4wMzcsNS42NTggYyAwLjA3NSwxMC44MTMgOS44NjIsMTkuNjA5IDIxLjg1NCwxOS42MDkgMTIuMDE4LC0wLjAxOSAyMS43ODIsLTguODM1IDIxLjc2NywtMTkuNjUyIGwgLTAuMDM5LC00NS4zODkgeiIKICAgICBpZD0icGF0aDI0IgogICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiIC8+PC9zdmc+" ), 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache ); QVERIFY( imageCheck( QStringLiteral( "svgcache_base64" ), img, 30 ) ); - } void TestQgsSvgCache::replaceParams() @@ -327,8 +320,7 @@ void TestQgsSvgCache::dynamicSvg() // test rendering SVGs with manual aspect ratio QgsSvgCache cache; const QString dynamicImage = TEST_DATA_DIR + QStringLiteral( "/svg/test_dynamic_svg.svg" ); - const QString svg = cache.svgContent( dynamicImage, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, 0, false, {{"text1", "green?"}, {"text2", "supergreen"}, {"align", "middle" }} ); + const QString svg = cache.svgContent( dynamicImage, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, 0, false, { { "text1", "green?" }, { "text2", "supergreen" }, { "align", "middle" } } ); QDomDocument doc; QVERIFY( doc.setContent( svg ) ); @@ -401,8 +393,7 @@ void TestQgsSvgCache::aspectRatio() bool inCache = false; const QString originalImage = TEST_DATA_DIR + QStringLiteral( "/test_symbol_svg.svg" ); - QImage img = cache.svgAsImage( originalImage, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, - 1.0, inCache, 0.5 ); + QImage img = cache.svgAsImage( originalImage, 200, QColor( 0, 0, 0 ), QColor( 0, 0, 0 ), 1.0, 1.0, inCache, 0.5 ); QVERIFY( imageCheck( QStringLiteral( "svgcache_aspect_ratio" ), img, 30 ) ); } diff --git a/tests/src/core/testqgssvgmarker.cpp b/tests/src/core/testqgssvgmarker.cpp index 8c98cc2c67cd..93aad104be48 100644 --- a/tests/src/core/testqgssvgmarker.cpp +++ b/tests/src/core/testqgssvgmarker.cpp @@ -45,12 +45,12 @@ class TestQgsSvgMarkerSymbol : public QgsTest Q_OBJECT public: - TestQgsSvgMarkerSymbol() : QgsTest( QStringLiteral( "SVG Marker Tests" ), - QStringLiteral( "symbol_svgmarker" ) ) {} + TestQgsSvgMarkerSymbol() + : QgsTest( QStringLiteral( "SVG Marker Tests" ), QStringLiteral( "symbol_svgmarker" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void svgMarkerSymbol(); void bounds(); @@ -67,7 +67,7 @@ class TestQgsSvgMarkerSymbol : public QgsTest void dynamicParameters(); private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsMapSettings mMapSettings; QgsVectorLayer *mpPointsLayer = nullptr; @@ -86,7 +86,7 @@ void TestQgsSvgMarkerSymbol::initTestCase() QgsApplication::initQgis(); QgsApplication::showSettings(); - QgsFontUtils::loadStandardTestFonts( {QStringLiteral( "Roman" ), QStringLiteral( "Bold" ) } ); + QgsFontUtils::loadStandardTestFonts( { QStringLiteral( "Roman" ), QStringLiteral( "Bold" ) } ); //create some objects that will be used in all tests... const QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt @@ -97,12 +97,12 @@ void TestQgsSvgMarkerSymbol::initTestCase() // const QString pointFileName = mTestDataDir + "points.shp"; const QFileInfo pointFileInfo( pointFileName ); - mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), - pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(), pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPointsLayer ); + QList() << mpPointsLayer + ); const QString defaultSvgPath = QgsSymbolLayerUtils::svgSymbolNameToPath( QStringLiteral( "/crosses/Star1.svg" ), QgsPathResolver() ); @@ -338,9 +338,7 @@ void TestQgsSvgMarkerSymbol::dynamicParameters() { const QString svgPath = TEST_DATA_DIR + QStringLiteral( "/svg/test_dynamic_svg.svg" ); - const QMap parameters {{QStringLiteral( "text1" ), QgsProperty::fromExpression( QStringLiteral( "1+1" ) )}, - {QStringLiteral( "text2" ), QgsProperty::fromExpression( QStringLiteral( "\"Class\"" ) )}, - {QStringLiteral( "align" ), QgsProperty::fromExpression( QStringLiteral( "'middle'" ) ) }}; + const QMap parameters { { QStringLiteral( "text1" ), QgsProperty::fromExpression( QStringLiteral( "1+1" ) ) }, { QStringLiteral( "text2" ), QgsProperty::fromExpression( QStringLiteral( "\"Class\"" ) ) }, { QStringLiteral( "align" ), QgsProperty::fromExpression( QStringLiteral( "'middle'" ) ) } }; mSvgMarkerLayer->setPath( svgPath ); mSvgMarkerLayer->setSize( 20 ); diff --git a/tests/src/core/testqgssymbol.cpp b/tests/src/core/testqgssymbol.cpp index f5de049fe791..f6125861798d 100644 --- a/tests/src/core/testqgssymbol.cpp +++ b/tests/src/core/testqgssymbol.cpp @@ -45,11 +45,10 @@ class TestQgsSymbol : public QgsTest Q_OBJECT public: - - TestQgsSymbol() : QgsTest( QStringLiteral( "Symbol Tests" ) ) {} + TestQgsSymbol() + : QgsTest( QStringLiteral( "Symbol Tests" ) ) {} private: - QString mTestDataDir; QgsVectorLayer *mpPointsLayer = nullptr; @@ -61,8 +60,8 @@ class TestQgsSymbol : public QgsTest private slots: // init / cleanup - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. // void initStyles(); void testCanvasClip(); @@ -103,22 +102,22 @@ void TestQgsSymbol::initTestCase() mTestDataDir = myDataDir + '/'; const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPointsLayer ); + QList() << mpPointsLayer + ); // //create a poly layer that will be used in all tests... // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPolysLayer ); + QList() << mpPolysLayer + ); // @@ -126,11 +125,11 @@ void TestQgsSymbol::initTestCase() // const QString myLinesFileName = mTestDataDir + "lines.shp"; const QFileInfo myLineFileInfo( myLinesFileName ); - mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), - myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpLinesLayer ); + QList() << mpLinesLayer + ); } void TestQgsSymbol::cleanupTestCase() @@ -162,7 +161,7 @@ void TestQgsSymbol::testCanvasClip() QgsMarkerLineSymbolLayer *markerLine = new QgsMarkerLineSymbolLayer(); markerLine->setPlacements( Qgis::MarkerLinePlacement::CentralPoint ); - static_cast< QgsSimpleMarkerSymbolLayer *>( markerLine->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); + static_cast( markerLine->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); QgsLineSymbol *lineSymbol = new QgsLineSymbol(); lineSymbol->changeSymbolLayer( 0, markerLine ); QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer( lineSymbol ); @@ -181,7 +180,7 @@ void TestQgsSymbol::testCanvasClip() ms.setLayers( QList() << mpPolysLayer ); QgsCentroidFillSymbolLayer *centroidFill = new QgsCentroidFillSymbolLayer(); - static_cast< QgsSimpleMarkerSymbolLayer * >( centroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); + static_cast( centroidFill->subSymbol()->symbolLayer( 0 ) )->setStrokeColor( Qt::black ); QgsFillSymbol *fillSymbol = new QgsFillSymbol(); fillSymbol->changeSymbolLayer( 0, centroidFill ); renderer = new QgsSingleSymbolRenderer( fillSymbol ); @@ -203,7 +202,7 @@ void TestQgsSymbol::testCanvasClip() void TestQgsSymbol::testParseColor() { // values for color tests - QMap< QString, QPair< QColor, bool> > colorTests; + QMap> colorTests; colorTests.insert( QStringLiteral( "bad color" ), qMakePair( QColor(), false ) ); colorTests.insert( QStringLiteral( "red" ), qMakePair( QColor( 255, 0, 0 ), false ) ); @@ -284,10 +283,10 @@ void TestQgsSymbol::testParseColor() colorTests.insert( QStringLiteral( "(50%,60%,0%,1.0)" ), qMakePair( QColor::fromRgbF( 0.5, 0.6, 0, 1.0 ), true ) ); colorTests.insert( QStringLiteral( "050%,060%,000%,0" ), qMakePair( QColor::fromRgbF( 0.5, 0.6, 0, 0 ), true ) ); - QMap >::const_iterator i = colorTests.constBegin(); + QMap>::const_iterator i = colorTests.constBegin(); while ( i != colorTests.constEnd() ) { - QgsDebugMsgLevel( "color string: " + i.key(), 1 ); + QgsDebugMsgLevel( "color string: " + i.key(), 1 ); bool hasAlpha = false; const QColor result = QgsSymbolLayerUtils::parseColorWithAlpha( i.key(), hasAlpha ); QCOMPARE( result, i.value().first ); @@ -300,7 +299,7 @@ void TestQgsSymbol::testParseColorList() { //ensure that majority of single parseColor tests work for lists //note that some are not possible, as the colors may be ambiguous when treated as a list - QMap< QString, QColor > colorTests; + QMap colorTests; colorTests.insert( QStringLiteral( "bad color" ), QColor() ); colorTests.insert( QStringLiteral( "red" ), QColor( 255, 0, 0 ) ); colorTests.insert( QStringLiteral( "#ff00ff" ), QColor( 255, 0, 255 ) ); @@ -320,7 +319,7 @@ void TestQgsSymbol::testParseColorList() colorTests.insert( QStringLiteral( "00000000" ), QColor( 0, 0, 0, 0 ) ); colorTests.insert( QStringLiteral( "00ff0011" ), QColor( 0, 255, 0, 17 ) ); colorTests.insert( QStringLiteral( "00gg0011" ), QColor() ); - colorTests.insert( QStringLiteral( "00ff00000" ), QColor() ); + colorTests.insert( QStringLiteral( "00ff00000" ), QColor() ); colorTests.insert( QStringLiteral( "0,0,0" ), QColor( 0, 0, 0 ) ); colorTests.insert( QStringLiteral( "127,60,0" ), QColor( 127, 60, 0 ) ); @@ -365,11 +364,11 @@ void TestQgsSymbol::testParseColorList() colorTests.insert( QStringLiteral( "(50%,60%,0%,1.0)" ), QColor::fromRgbF( 0.5, 0.6, 0, 1 ) ); colorTests.insert( QStringLiteral( "050%,060%,000%,0" ), QColor::fromRgbF( 0.5, 0.6, 0, 0 ) ); - QMap::const_iterator i = colorTests.constBegin(); + QMap::const_iterator i = colorTests.constBegin(); while ( i != colorTests.constEnd() ) { - QgsDebugMsgLevel( "color list string: " + i.key(), 1 ); - const QList< QColor > result = QgsSymbolLayerUtils::parseColorList( i.key() ); + QgsDebugMsgLevel( "color list string: " + i.key(), 1 ); + const QList result = QgsSymbolLayerUtils::parseColorList( i.key() ); if ( i.value().isValid() ) { QCOMPARE( result.length(), 1 ); @@ -382,7 +381,7 @@ void TestQgsSymbol::testParseColorList() ++i; } - QVector< QPair< QString, QList > > colorListTests; + QVector>> colorListTests; QList list1; list1 << QColor( QStringLiteral( "blue" ) ) << QColor( QStringLiteral( "red" ) ) << QColor( QStringLiteral( "green" ) ); colorListTests.append( qMakePair( QStringLiteral( "blue red green" ), list1 ) ); @@ -403,16 +402,16 @@ void TestQgsSymbol::testParseColorList() colorListTests.append( qMakePair( QStringLiteral( "rgb(255,0,0)\nrgb(0,255,0)\nrgb(0,0,255)" ), list3 ) ); colorListTests.append( qMakePair( QStringLiteral( "rgb(255,0,0)\nrgb(0,255,0) rgb(0,0,255)" ), list3 ) ); - QVector< QPair< QString, QList > >::const_iterator it = colorListTests.constBegin(); + QVector>>::const_iterator it = colorListTests.constBegin(); while ( it != colorListTests.constEnd() ) { QgsDebugMsgLevel( "color list string: " + ( *it ).first, 1 ); - const QList< QColor > result = QgsSymbolLayerUtils::parseColorList( ( *it ).first ); + const QList result = QgsSymbolLayerUtils::parseColorList( ( *it ).first ); if ( ( *it ).second.length() > 0 ) { QCOMPARE( result.length(), ( *it ).second.length() ); int index = 0; - for ( QList::const_iterator colorIt = ( *it ).second.constBegin(); colorIt != ( *it ).second.constEnd(); ++colorIt ) + for ( QList::const_iterator colorIt = ( *it ).second.constBegin(); colorIt != ( *it ).second.constEnd(); ++colorIt ) { QVERIFY( result.at( index ) == ( *colorIt ) ); index++; @@ -424,7 +423,6 @@ void TestQgsSymbol::testParseColorList() } ++it; } - } void TestQgsSymbol::symbolProperties() @@ -437,16 +435,14 @@ void TestQgsSymbol::symbolProperties() QgsFillSymbol *fillSymbol = new QgsFillSymbol(); fillSymbol->changeSymbolLayer( 0, fill ); - QgsFillSymbol *fillSymbol2 = static_cast< QgsFillSymbol * >( fillSymbol->clone() ); + QgsFillSymbol *fillSymbol2 = static_cast( fillSymbol->clone() ); //test that two different symbol pointers return same properties - QCOMPARE( QgsSymbolLayerUtils::symbolProperties( fillSymbol ), - QgsSymbolLayerUtils::symbolProperties( fillSymbol2 ) ); + QCOMPARE( QgsSymbolLayerUtils::symbolProperties( fillSymbol ), QgsSymbolLayerUtils::symbolProperties( fillSymbol2 ) ); //modify one of the symbols fillSymbol2->symbolLayer( 0 )->setColor( QColor( 235, 135, 35 ) ); - QVERIFY( QgsSymbolLayerUtils::symbolProperties( fillSymbol ) != - QgsSymbolLayerUtils::symbolProperties( fillSymbol2 ) ); + QVERIFY( QgsSymbolLayerUtils::symbolProperties( fillSymbol ) != QgsSymbolLayerUtils::symbolProperties( fillSymbol2 ) ); delete fillSymbol; delete fillSymbol2; diff --git a/tests/src/core/testqgstaskmanager.cpp b/tests/src/core/testqgstaskmanager.cpp index 4a69b857f42b..67862e78fd8b 100644 --- a/tests/src/core/testqgstaskmanager.cpp +++ b/tests/src/core/testqgstaskmanager.cpp @@ -32,13 +32,14 @@ class TestTask : public QgsTask Q_OBJECT public: - - TestTask( const QString &desc = QString() ) : QgsTask( desc ) + TestTask( const QString &desc = QString() ) + : QgsTask( desc ) { qDebug() << "created task " << desc; } - TestTask( const QString &desc, const QgsTask::Flags &flags ) : QgsTask( desc, flags ) + TestTask( const QString &desc, const QgsTask::Flags &flags ) + : QgsTask( desc, flags ) { qDebug() << "created task " << desc; } @@ -48,19 +49,17 @@ class TestTask : public QgsTask qDebug() << "deleting task " << description(); } - void emitTaskStopped() { } - void emitTaskCompleted() { } + void emitTaskStopped() {} + void emitTaskCompleted() {} - bool runCalled = false ; + bool runCalled = false; protected: - bool run() override { runCalled = true; return true; } - }; class ProgressReportingTask : public QgsTask @@ -68,8 +67,8 @@ class ProgressReportingTask : public QgsTask Q_OBJECT public: - - ProgressReportingTask( const QString &desc = QString(), QgsTask::Flags flags = AllFlags ) : QgsTask( desc, flags ) + ProgressReportingTask( const QString &desc = QString(), QgsTask::Flags flags = AllFlags ) + : QgsTask( desc, flags ) { qDebug() << "created task " << desc; } @@ -85,8 +84,8 @@ class ProgressReportingTask : public QgsTask mProgress.append( progress ); } - bool finished = false ; - bool terminated = false ; + bool finished = false; + bool terminated = false; public slots: @@ -103,7 +102,6 @@ class ProgressReportingTask : public QgsTask } protected: - bool run() override { while ( true ) @@ -129,7 +127,6 @@ class ProgressReportingTask : public QgsTask QList mProgress; QMutex mProgressMutex; QMutex mCompletedMutex; - }; class TestTerminationTask : public TestTask @@ -137,8 +134,8 @@ class TestTerminationTask : public TestTask Q_OBJECT public: - - TestTerminationTask( const QString &desc = QString() ) : TestTask( desc ) {} + TestTerminationTask( const QString &desc = QString() ) + : TestTask( desc ) {} ~TestTerminationTask() override { @@ -147,11 +144,11 @@ class TestTerminationTask : public TestTask } protected: - bool run() override { while ( !isCanceled() ) - {} + { + } return false; } }; @@ -161,8 +158,8 @@ class CancelableTask : public QgsTask Q_OBJECT public: - - CancelableTask( const QString &desc = QString() ) : QgsTask( desc ) + CancelableTask( const QString &desc = QString() ) + : QgsTask( desc ) { qDebug() << "created task " << desc; } @@ -173,11 +170,11 @@ class CancelableTask : public QgsTask } protected: - bool run() override { while ( !isCanceled() ) - {} + { + } return true; } }; @@ -187,8 +184,8 @@ class HiddenTask : public ProgressReportingTask Q_OBJECT public: - - HiddenTask( const QString &desc = QString() ) : ProgressReportingTask( desc, QgsTask::CanCancel | QgsTask::Hidden ) + HiddenTask( const QString &desc = QString() ) + : ProgressReportingTask( desc, QgsTask::CanCancel | QgsTask::Hidden ) { qDebug() << "created task " << desc; } @@ -197,7 +194,6 @@ class HiddenTask : public ProgressReportingTask { qDebug() << "deleting task " << description(); } - }; @@ -206,8 +202,8 @@ class SuccessTask : public QgsTask Q_OBJECT public: - - SuccessTask( const QString &desc = QString() ) : QgsTask( desc ) + SuccessTask( const QString &desc = QString() ) + : QgsTask( desc ) { qDebug() << "created task " << desc; } @@ -218,7 +214,6 @@ class SuccessTask : public QgsTask } protected: - bool run() override { return true; @@ -230,8 +225,8 @@ class FailTask : public QgsTask Q_OBJECT public: - - FailTask( const QString &desc = QString() ) : QgsTask( desc ) + FailTask( const QString &desc = QString() ) + : QgsTask( desc ) { qDebug() << "created task " << desc; } @@ -242,12 +237,10 @@ class FailTask : public QgsTask } protected: - bool run() override { return false; } - }; class FinishTask : public QgsTask @@ -255,7 +248,6 @@ class FinishTask : public QgsTask Q_OBJECT public: - FinishTask( bool *result, const QString &desc ) : QgsTask( desc ) , desiredResult( false ) @@ -273,7 +265,6 @@ class FinishTask : public QgsTask bool *resultObtained = nullptr; protected: - bool run() override { return desiredResult; @@ -299,8 +290,8 @@ class WaitTask : public QgsTask Q_OBJECT public: - - WaitTask( const QString &desc = QString() ) : QgsTask( desc ) + WaitTask( const QString &desc = QString() ) + : QgsTask( desc ) { qDebug() << "created task " << desc; } @@ -311,7 +302,6 @@ class WaitTask : public QgsTask } protected: - bool run() override { QThread::sleep( 2 ); @@ -323,12 +313,11 @@ class TestQgsTaskManager : public QObject { Q_OBJECT public: - private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void task(); void taskResult(); @@ -378,18 +367,16 @@ void TestQgsTaskManager::cleanupTestCase() void TestQgsTaskManager::init() { - } void TestQgsTaskManager::cleanup() { - } void TestQgsTaskManager::task() { - std::unique_ptr< TestTask > task( new TestTask( QStringLiteral( "test_task_desc" ) ) ); + std::unique_ptr task( new TestTask( QStringLiteral( "test_task_desc" ) ) ); QCOMPARE( task->status(), QgsTask::Queued ); QCOMPARE( task->description(), QStringLiteral( "test_task_desc" ) ); QVERIFY( !task->isActive() ); @@ -403,11 +390,11 @@ void TestQgsTaskManager::task() QVERIFY( task->runCalled ); QCOMPARE( startedSpy.count(), 1 ); QCOMPARE( statusSpy.count(), 2 ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy.at( 0 ).at( 0 ).toInt() ), QgsTask::Running ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy.at( 1 ).at( 0 ).toInt() ), QgsTask::Complete ); + QCOMPARE( static_cast( statusSpy.at( 0 ).at( 0 ).toInt() ), QgsTask::Running ); + QCOMPARE( static_cast( statusSpy.at( 1 ).at( 0 ).toInt() ), QgsTask::Complete ); //test that calling stopped sets correct state - std::unique_ptr< FailTask > failTask( new FailTask( QStringLiteral( "task_fail" ) ) ); + std::unique_ptr failTask( new FailTask( QStringLiteral( "task_fail" ) ) ); QSignalSpy stoppedSpy( failTask.get(), &QgsTask::taskTerminated ); QSignalSpy statusSpy2( failTask.get(), &QgsTask::statusChanged ); failTask->start(); @@ -415,7 +402,7 @@ void TestQgsTaskManager::task() QVERIFY( !failTask->isActive() ); QCOMPARE( stoppedSpy.count(), 1 ); QCOMPARE( statusSpy2.count(), 2 ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy2.last().at( 0 ).toInt() ), QgsTask::Terminated ); + QCOMPARE( static_cast( statusSpy2.last().at( 0 ).toInt() ), QgsTask::Terminated ); //test that calling completed sets correct state task.reset( new TestTask( QStringLiteral( "test_task_3" ) ) ); @@ -426,7 +413,7 @@ void TestQgsTaskManager::task() QVERIFY( !task->isActive() ); QCOMPARE( completeSpy.count(), 1 ); QCOMPARE( statusSpy3.count(), 2 ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy3.last().at( 0 ).toInt() ), QgsTask::Complete ); + QCOMPARE( static_cast( statusSpy3.last().at( 0 ).toInt() ), QgsTask::Complete ); // test that canceling tasks which have not begin immediately ends them task.reset( new TestTask( QStringLiteral( "test_task_4" ) ) ); @@ -448,14 +435,14 @@ void TestQgsTaskManager::task() void TestQgsTaskManager::taskResult() { - std::unique_ptr< QgsTask > task( new SuccessTask( QStringLiteral( "task_result_1" ) ) ); + std::unique_ptr task( new SuccessTask( QStringLiteral( "task_result_1" ) ) ); QCOMPARE( task->status(), QgsTask::Queued ); QSignalSpy statusSpy( task.get(), &QgsTask::statusChanged ); task->start(); QCOMPARE( statusSpy.count(), 2 ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy.at( 0 ).at( 0 ).toInt() ), QgsTask::Running ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy.at( 1 ).at( 0 ).toInt() ), QgsTask::Complete ); + QCOMPARE( static_cast( statusSpy.at( 0 ).at( 0 ).toInt() ), QgsTask::Running ); + QCOMPARE( static_cast( statusSpy.at( 1 ).at( 0 ).toInt() ), QgsTask::Complete ); QCOMPARE( task->status(), QgsTask::Complete ); task.reset( new FailTask( QStringLiteral( "task_result_2" ) ) ); @@ -464,8 +451,8 @@ void TestQgsTaskManager::taskResult() task->start(); QCOMPARE( statusSpy2.count(), 2 ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy2.at( 0 ).at( 0 ).toInt() ), QgsTask::Running ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy2.at( 1 ).at( 0 ).toInt() ), QgsTask::Terminated ); + QCOMPARE( static_cast( statusSpy2.at( 0 ).at( 0 ).toInt() ), QgsTask::Running ); + QCOMPARE( static_cast( statusSpy2.at( 1 ).at( 0 ).toInt() ), QgsTask::Terminated ); QCOMPARE( task->status(), QgsTask::Terminated ); QApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); @@ -617,7 +604,7 @@ void TestQgsTaskManager::subTaskGrandChildren() // parent with grand children ProgressReportingTask *parent = new ProgressReportingTask( QStringLiteral( "sub_task_parent_task_2" ) ); QPointer subTask = new ProgressReportingTask( QStringLiteral( "sub_task_sub_task_2" ) ); - QPointer< ProgressReportingTask> subsubTask( new ProgressReportingTask( QStringLiteral( "sub_task_subsub_task_2" ) ) ); + QPointer subsubTask( new ProgressReportingTask( QStringLiteral( "sub_task_subsub_task_2" ) ) ); subTask->addSubTask( subsubTask ); parent->addSubTask( subTask ); @@ -636,7 +623,7 @@ void TestQgsTaskManager::subTaskProgress() // test parent task progress ProgressReportingTask *parent = new ProgressReportingTask( QStringLiteral( "sub_task_parent_task_3" ) ); QPointer subTask = new ProgressReportingTask( QStringLiteral( "sub_task_sub_task_3" ) ); - QPointer< ProgressReportingTask > subTask2( new ProgressReportingTask( QStringLiteral( "sub_task_sub_task_3a" ) ) ); + QPointer subTask2( new ProgressReportingTask( QStringLiteral( "sub_task_sub_task_3a" ) ) ); parent->addSubTask( subTask ); parent->addSubTask( subTask2 ); @@ -779,11 +766,11 @@ void TestQgsTaskManager::subTaskPartialComplete() flushEvents(); //should still be running - QCOMPARE( ( int )parent->status(), ( int )QgsTask::Running ); + QCOMPARE( ( int ) parent->status(), ( int ) QgsTask::Running ); subTask->finish(); flushEvents(); QCOMPARE( parent->status(), QgsTask::Running ); - QCOMPARE( ( int )subTask->status(), ( int )QgsTask::Running ); + QCOMPARE( ( int ) subTask->status(), ( int ) QgsTask::Running ); QSignalSpy parentFinished( parent, &QgsTask::taskCompleted ); QSignalSpy subFinished( subTask, &QgsTask::taskCompleted ); @@ -800,7 +787,6 @@ void TestQgsTaskManager::subTaskPartialComplete() QVERIFY( parentFinished.count() > 0 ); QVERIFY( subFinished.count() > 0 ); QVERIFY( subsubFinished.count() > 0 ); - } void TestQgsTaskManager::subTaskPartialComplete2() @@ -892,8 +878,7 @@ void TestQgsTaskManager::waitForFinished() QTimer *timer = new QTimer( nullptr ); connect( timer, &QTimer::timeout, finishedTask, &ProgressReportingTask::finish, Qt::DirectConnection ); timer->moveToThread( timerThread ); - connect( timerThread, &QThread::started, timer, [ = ] - { + connect( timerThread, &QThread::started, timer, [=] { timer->start( 2000 ); } ); connect( timerThread, &QThread::finished, timer, &QTimer::deleteLater ); @@ -919,8 +904,7 @@ void TestQgsTaskManager::waitForFinished() timer = new QTimer( nullptr ); connect( timer, &QTimer::timeout, failedTask, &ProgressReportingTask::terminate, Qt::DirectConnection ); timer->moveToThread( timerThread ); - connect( timerThread, &QThread::started, timer, [ = ] - { + connect( timerThread, &QThread::started, timer, [=] { timer->start( 500 ); } ); connect( timerThread, &QThread::finished, timer, &QTimer::deleteLater ); @@ -942,8 +926,7 @@ void TestQgsTaskManager::waitForFinished() timer = new QTimer( nullptr ); connect( timer, &QTimer::timeout, timeoutTooShortTask, &ProgressReportingTask::finish, Qt::DirectConnection ); timer->moveToThread( timerThread ); - connect( timerThread, &QThread::started, timer, [ = ] - { + connect( timerThread, &QThread::started, timer, [=] { timer->start( 1000 ); } ); connect( timerThread, &QThread::finished, timer, &QTimer::deleteLater ); @@ -998,8 +981,7 @@ void TestQgsTaskManager::progressChanged() manager.addTask( task ); manager.addTask( task2 ); - while ( task->status() != QgsTask::Running || - task2->status() != QgsTask::Running ) + while ( task->status() != QgsTask::Running || task2->status() != QgsTask::Running ) { QCoreApplication::processEvents(); } @@ -1129,7 +1111,7 @@ void TestQgsTaskManager::statusChanged() QCOMPARE( spy.count(), 1 ); QCOMPARE( spy.last().at( 0 ).toLongLong(), 2LL ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( spy.last().at( 1 ).toInt() ), QgsTask::Running ); + QCOMPARE( static_cast( spy.last().at( 1 ).toInt() ), QgsTask::Running ); task->terminate(); while ( task->status() == QgsTask::Running || manager.countActiveTasks() > 1 ) @@ -1139,7 +1121,7 @@ void TestQgsTaskManager::statusChanged() flushEvents(); QCOMPARE( spy.count(), 2 ); QCOMPARE( spy.last().at( 0 ).toLongLong(), 1LL ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( spy.last().at( 1 ).toInt() ), QgsTask::Terminated ); + QCOMPARE( static_cast( spy.last().at( 1 ).toInt() ), QgsTask::Terminated ); task2->finish(); while ( task2->status() == QgsTask::Running || manager.countActiveTasks() > 0 ) @@ -1149,7 +1131,7 @@ void TestQgsTaskManager::statusChanged() flushEvents(); QCOMPARE( spy.count(), 3 ); QCOMPARE( spy.last().at( 0 ).toLongLong(), 2LL ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( spy.last().at( 1 ).toInt() ), QgsTask::Complete ); + QCOMPARE( static_cast( spy.last().at( 1 ).toInt() ), QgsTask::Complete ); } void TestQgsTaskManager::allTasksFinished() @@ -1240,7 +1222,7 @@ void TestQgsTaskManager::activeTasks() QCoreApplication::processEvents(); } flushEvents(); - QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList< QgsTask * >() << task ) ); + QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList() << task ) ); QCOMPARE( manager.countActiveTasks(), 1 ); QCOMPARE( spy.count(), 1 ); QCOMPARE( spy.last().at( 0 ).toInt(), 1 ); @@ -1250,7 +1232,7 @@ void TestQgsTaskManager::activeTasks() QCoreApplication::processEvents(); } flushEvents(); - QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList< QgsTask * >() << task << task2 ) ); + QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList() << task << task2 ) ); QCOMPARE( manager.countActiveTasks(), 2 ); QCOMPARE( spy.count(), 2 ); QCOMPARE( spy.last().at( 0 ).toInt(), 2 ); @@ -1260,7 +1242,7 @@ void TestQgsTaskManager::activeTasks() QCoreApplication::processEvents(); } flushEvents(); - QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList< QgsTask * >() << task2 ) ); + QCOMPARE( qgis::listToSet( manager.activeTasks() ), qgis::listToSet( QList() << task2 ) ); QCOMPARE( manager.countActiveTasks(), 1 ); QCOMPARE( spy.count(), 3 ); QCOMPARE( spy.last().at( 0 ).toInt(), 1 ); @@ -1314,9 +1296,9 @@ void TestQgsTaskManager::dependencies() long grandChildTaskId = manager.addTask( grandChildTask ); // check dependency resolution - QCOMPARE( manager.dependencies( grandChildTaskId ), QSet< long >() ); - QCOMPARE( manager.dependencies( childTaskId ), QSet< long >() << grandChildTaskId ); - QCOMPARE( manager.dependencies( taskId ), QSet< long >() << childTaskId << grandChildTaskId ); + QCOMPARE( manager.dependencies( grandChildTaskId ), QSet() ); + QCOMPARE( manager.dependencies( childTaskId ), QSet() << grandChildTaskId ); + QCOMPARE( manager.dependencies( taskId ), QSet() << childTaskId << grandChildTaskId ); QVERIFY( !manager.hasCircularDependencies( taskId ) ); QVERIFY( !manager.hasCircularDependencies( childTaskId ) ); @@ -1419,27 +1401,27 @@ void TestQgsTaskManager::layerDependencies() QVERIFY( layer2->isValid() ); QgsVectorLayer *layer3 = new QgsVectorLayer( QStringLiteral( "Point?field=col1:string&field=col2:string&field=col3:string" ), QStringLiteral( "layer3" ), QStringLiteral( "memory" ) ); QVERIFY( layer3->isValid() ); - QgsProject::instance()->addMapLayers( QList< QgsMapLayer * >() << layer1 << layer2 << layer3 ); + QgsProject::instance()->addMapLayers( QList() << layer1 << layer2 << layer3 ); QgsTaskManager manager; //test that remove layers cancels all tasks which are dependent on them TestTask *task = new TestTask(); task->hold(); - task->setDependentLayers( QList< QgsMapLayer * >() << layer2 << layer3 ); - QCOMPARE( task->dependentLayers(), QList< QgsMapLayer * >() << layer2 << layer3 ); + task->setDependentLayers( QList() << layer2 << layer3 ); + QCOMPARE( task->dependentLayers(), QList() << layer2 << layer3 ); long taskId = manager.addTask( task ); - QCOMPARE( manager.dependentLayers( taskId ), QList< QgsMapLayer * >() << layer2 << layer3 ); + QCOMPARE( manager.dependentLayers( taskId ), QList() << layer2 << layer3 ); QVERIFY( manager.tasksDependentOnLayer( nullptr ).isEmpty() ); - QCOMPARE( manager.tasksDependentOnLayer( layer2 ), QList< QgsTask * >() << task ); - QCOMPARE( manager.tasksDependentOnLayer( layer3 ), QList< QgsTask * >() << task ); + QCOMPARE( manager.tasksDependentOnLayer( layer2 ), QList() << task ); + QCOMPARE( manager.tasksDependentOnLayer( layer3 ), QList() << task ); QCOMPARE( task->status(), QgsTask::OnHold ); //removing layer1 should have no effect - QgsProject::instance()->removeMapLayers( QList< QgsMapLayer * >() << layer1 ); + QgsProject::instance()->removeMapLayers( QList() << layer1 ); QCOMPARE( task->status(), QgsTask::OnHold ); //removing layer3 should cancel task - QgsProject::instance()->removeMapLayers( QList< QgsMapLayer * >() << layer3 ); + QgsProject::instance()->removeMapLayers( QList() << layer3 ); while ( task->status() != QgsTask::Terminated ) { QCoreApplication::processEvents(); @@ -1447,7 +1429,7 @@ void TestQgsTaskManager::layerDependencies() flushEvents(); QCOMPARE( task->status(), QgsTask::Terminated ); - QgsProject::instance()->removeMapLayers( QList< QgsMapLayer * >() << layer2 ); + QgsProject::instance()->removeMapLayers( QList() << layer2 ); } void TestQgsTaskManager::managerWithSubTasks() @@ -1537,7 +1519,7 @@ void TestQgsTaskManager::managerWithSubTasks() flushEvents(); QCOMPARE( statusSpy.count(), 1 ); QCOMPARE( statusSpy.last().at( 0 ).toLongLong(), 1LL ); - QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy.last().at( 1 ).toInt() ), QgsTask::Complete ); + QCOMPARE( static_cast( statusSpy.last().at( 1 ).toInt() ), QgsTask::Complete ); delete manager; } @@ -1548,11 +1530,11 @@ void TestQgsTaskManager::managerWithSubTasks2() //test 1 QgsTaskManager *manager2 = new QgsTaskManager(); - QPointer< CancelableTask > parent( new CancelableTask() ); -// parent->hold(); - QPointer< CancelableTask > subTask( new CancelableTask() ); + QPointer parent( new CancelableTask() ); + // parent->hold(); + QPointer subTask( new CancelableTask() ); //subTask->hold(); - QPointer< CancelableTask > subTask2( new CancelableTask() ); + QPointer subTask2( new CancelableTask() ); //subTask2->hold(); parent->addSubTask( subTask, QgsTaskList() << subTask2 ); @@ -1568,9 +1550,9 @@ void TestQgsTaskManager::managerWithSubTasks2() long subTaskId = manager2->taskId( subTask ); long subTask2Id = manager2->taskId( subTask2 ); - QCOMPARE( manager2->dependencies( parentId ), QSet< long >() ); - QCOMPARE( manager2->dependencies( subTaskId ), QSet< long >() << subTask2Id ); - QCOMPARE( manager2->dependencies( subTask2Id ), QSet< long >() ); + QCOMPARE( manager2->dependencies( parentId ), QSet() ); + QCOMPARE( manager2->dependencies( subTaskId ), QSet() << subTask2Id ); + QCOMPARE( manager2->dependencies( subTask2Id ), QSet() ); delete manager2; } @@ -1593,9 +1575,9 @@ void TestQgsTaskManager::managerWithSubTasks3() long subTaskId = manager3.taskId( subTask ); long subTask2Id = manager3.taskId( subTask2 ); - QCOMPARE( manager3.dependencies( parentId ), QSet< long >() << subTask2Id ); - QCOMPARE( manager3.dependencies( subTaskId ), QSet< long >() << subTask2Id ); - QCOMPARE( manager3.dependencies( subTask2Id ), QSet< long >() ); + QCOMPARE( manager3.dependencies( parentId ), QSet() << subTask2Id ); + QCOMPARE( manager3.dependencies( subTaskId ), QSet() << subTask2Id ); + QCOMPARE( manager3.dependencies( subTask2Id ), QSet() ); } void TestQgsTaskManager::cancelBeforeStart() @@ -1607,7 +1589,7 @@ void TestQgsTaskManager::cancelBeforeStart() // add too much tasks to the manager, so that some are queued and can't start immediately // then cancel them all! - QList< QgsTask * > tasks; + QList tasks; for ( int i = 0; i < 10; ++i ) { @@ -1640,7 +1622,7 @@ void TestQgsTaskManager::proxyTask() // finalize before task gets a chance to start QgsTaskManager manager; proxyTask->finalize( false ); - QPointer< QgsTask > p( proxyTask ); + QPointer p( proxyTask ); manager.addTask( proxyTask ); @@ -1658,7 +1640,7 @@ void TestQgsTaskManager::proxyTask2() // finalize before task gets a chance to start QgsTaskManager manager; - QPointer< QgsTask > p( proxyTask ); + QPointer p( proxyTask ); manager.addTask( proxyTask ); // should all be ok, no deadlock... @@ -1679,7 +1661,7 @@ void TestQgsTaskManager::scopedProxyTask() { { // task finishes before it can start - QgsScopedProxyProgressTask task{ QString() }; + QgsScopedProxyProgressTask task { QString() }; } // should all be ok, no deadlock... @@ -1792,7 +1774,7 @@ void TestQgsTaskManager::hiddenTask() void TestQgsTaskManager::testQgsTaskWithSerialSubTasks() { QgsTaskWithSerialSubTasks *taskWithSerialSubTasks = new QgsTaskWithSerialSubTasks(); - QPointer< QgsTask > p( taskWithSerialSubTasks ); + QPointer p( taskWithSerialSubTasks ); auto task = new TestTask(); taskWithSerialSubTasks->addSubTask( task ); diff --git a/tests/src/core/testqgstemporalnavigationobject.cpp b/tests/src/core/testqgstemporalnavigationobject.cpp index b390e54a1601..66df678cd68a 100644 --- a/tests/src/core/testqgstemporalnavigationobject.cpp +++ b/tests/src/core/testqgstemporalnavigationobject.cpp @@ -34,10 +34,10 @@ class TestQgsTemporalNavigationObject : public QObject TestQgsTemporalNavigationObject() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void animationState(); void temporalExtents(); @@ -61,7 +61,6 @@ void TestQgsTemporalNavigationObject::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsTemporalNavigationObject::init() @@ -85,9 +84,9 @@ void TestQgsTemporalNavigationObject::cleanupTestCase() void TestQgsTemporalNavigationObject::animationState() { const QgsDateTimeRange range = QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 10, 1 ), QTime( 8, 0, 0 ) ) - ); + QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), + QDateTime( QDate( 2020, 10, 1 ), QTime( 8, 0, 0 ) ) + ); navigationObject->setTemporalExtents( range ); navigationObject->setFrameDuration( QgsInterval( 1, Qgis::TemporalUnit::Months ) ); @@ -128,15 +127,14 @@ void TestQgsTemporalNavigationObject::animationState() QCOMPARE( navigationObject->isLooping(), false ); navigationObject->setLooping( true ); QCOMPARE( navigationObject->isLooping(), true ); - } void TestQgsTemporalNavigationObject::temporalExtents() { const QgsDateTimeRange range = QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 12, 1 ), QTime( 8, 0, 0 ) ) - ); + QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), + QDateTime( QDate( 2020, 12, 1 ), QTime( 8, 0, 0 ) ) + ); navigationObject->setTemporalExtents( range ); QCOMPARE( navigationObject->temporalExtents(), range ); @@ -147,16 +145,17 @@ void TestQgsTemporalNavigationObject::temporalExtents() void TestQgsTemporalNavigationObject::navigationMode() { const QgsDateTimeRange range = QgsDateTimeRange( - QDateTime( QDate( 2010, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ); + QDateTime( QDate( 2010, 1, 1 ), QTime( 0, 0, 0 ) ), + QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) + ); const QgsDateTimeRange range2 = QgsDateTimeRange( - QDateTime( QDate( 2015, 1, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) ); + QDateTime( QDate( 2015, 1, 1 ), QTime( 0, 0, 0 ) ), + QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 0, 0 ) ) + ); QgsDateTimeRange check; - auto checkUpdateTemporalRange = [&check]( const QgsDateTimeRange range ) - { + auto checkUpdateTemporalRange = [&check]( const QgsDateTimeRange range ) { QCOMPARE( range, check ); }; QObject *context = new QObject( this ); @@ -186,27 +185,17 @@ void TestQgsTemporalNavigationObject::frameSettings() const QSignalSpy temporalRangeSignal( navigationObject, &QgsTemporalNavigationObject::updateTemporalRange ); const QgsDateTimeRange range = QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), - true, - false - ); + QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), + QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), + true, + false + ); navigationObject->setTemporalExtents( range ); QCOMPARE( temporalRangeSignal.count(), 1 ); // two frames - 8-10am, 10-12am QCOMPARE( navigationObject->totalFrameCount(), 2LL ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), - true, - false - ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), true, false ) ); navigationObject->setFrameDuration( QgsInterval( 1, Qgis::TemporalUnit::Hours ) ); QCOMPARE( navigationObject->frameDuration(), QgsInterval( 1, Qgis::TemporalUnit::Hours ) ); @@ -218,30 +207,10 @@ void TestQgsTemporalNavigationObject::frameSettings() QCOMPARE( navigationObject->currentFrameNumber(), 0 ); // four frames - 8-9, 9-10, 10-11, 11-12am QCOMPARE( navigationObject->totalFrameCount(), 4LL ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 0, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 2 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 3 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), - true, - false - ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 0, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 2 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 3 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), true, false ) ); navigationObject->setCurrentFrameNumber( 1 ); QCOMPARE( navigationObject->currentFrameNumber(), 1 ); @@ -273,12 +242,7 @@ void TestQgsTemporalNavigationObject::frameSettings() // Test if, when changing to Cumulative mode, the dateTimeRange for frame 2 (with 2 hours frames) is indeed the full range navigationObject->setTemporalRangeCumulative( true ); QCOMPARE( temporalRangeSignal.count(), 8 ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), - true, - false - ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ), true, false ) ); QCOMPARE( temporalRangeSignal.count(), 8 ); navigationObject->setTemporalRangeCumulative( false ); @@ -286,106 +250,57 @@ void TestQgsTemporalNavigationObject::frameSettings() navigationObject->setFrameDuration( QgsInterval( 0.75, Qgis::TemporalUnit::Hours ) ); // six frames - 8-8.45, 8.45-9.30, 9.30-10.15, 10.15-11.00, 11.00-11.45, 11.45-12.30 QCOMPARE( navigationObject->totalFrameCount(), 6LL ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 45, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 45, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 30, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 2 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 30, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 15, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 3 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 15, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), - true, - false - ) ); - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 4 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 45, 0 ) ), - true, - false - ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 45, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 45, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 30, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 2 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 9, 30, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 15, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 3 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 10, 15, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), true, false ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 4 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 0, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 45, 0 ) ), true, false ) ); // yes, this frame goes PAST the end of the overall animation range -- but we need to ensure that // every frame has equal length! - QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 5 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 45, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 30, 0 ) ), - true, - false - ) ); + QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 5 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 1 ), QTime( 11, 45, 0 ) ), QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 30, 0 ) ), true, false ) ); } void TestQgsTemporalNavigationObject::expressionContext() { QgsTemporalNavigationObject object; const QgsDateTimeRange range = QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ) - ); + QDateTime( QDate( 2020, 1, 1 ), QTime( 8, 0, 0 ) ), + QDateTime( QDate( 2020, 1, 1 ), QTime( 12, 0, 0 ) ) + ); object.setTemporalExtents( range ); object.setFrameDuration( QgsInterval( 1, Qgis::TemporalUnit::Hours ) ); object.setCurrentFrameNumber( 1 ); object.setFramesPerSecond( 30 ); - std::unique_ptr< QgsExpressionContextScope > scope( object.createExpressionContextScope() ); + std::unique_ptr scope( object.createExpressionContextScope() ); QCOMPARE( scope->variable( QStringLiteral( "frame_rate" ) ).toDouble(), 30.0 ); - QCOMPARE( scope->variable( QStringLiteral( "frame_duration" ) ).value< QgsInterval >().seconds(), 3600.0 ); - QCOMPARE( scope->variable( QStringLiteral( "frame_timestep" ) ).value< double >(), 1.0 ); - QCOMPARE( scope->variable( QStringLiteral( "frame_timestep_unit" ) ).value< Qgis::TemporalUnit >(), Qgis::TemporalUnit::Hours ); + QCOMPARE( scope->variable( QStringLiteral( "frame_duration" ) ).value().seconds(), 3600.0 ); + QCOMPARE( scope->variable( QStringLiteral( "frame_timestep" ) ).value(), 1.0 ); + QCOMPARE( scope->variable( QStringLiteral( "frame_timestep_unit" ) ).value(), Qgis::TemporalUnit::Hours ); QCOMPARE( scope->variable( QStringLiteral( "frame_timestep_units" ) ).toString(), QStringLiteral( "hours" ) ); QCOMPARE( scope->variable( QStringLiteral( "frame_number" ) ).toInt(), 1 ); QCOMPARE( scope->variable( QStringLiteral( "animation_start_time" ) ).toDateTime(), range.begin() ); QCOMPARE( scope->variable( QStringLiteral( "animation_end_time" ) ).toDateTime(), range.end() ); - QCOMPARE( scope->variable( QStringLiteral( "animation_interval" ) ).value< QgsInterval >(), range.end() - range.begin() ); + QCOMPARE( scope->variable( QStringLiteral( "animation_interval" ) ).value(), range.end() - range.begin() ); } void TestQgsTemporalNavigationObject::testIrregularStep() { // test using the navigation in irregular step mode QgsTemporalNavigationObject object; - const QList< QgsDateTimeRange > ranges{ QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 15 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 20 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( - QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 4, 5 ), QTime( 0, 0, 0 ) ) ) - }; + const QList ranges { QgsDateTimeRange( QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 15 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 20 ), QTime( 0, 0, 0 ) ) ), QgsDateTimeRange( QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 4, 5 ), QTime( 0, 0, 0 ) ) ) }; object.setAvailableTemporalRanges( ranges ); object.setFrameDuration( QgsInterval( 1, Qgis::TemporalUnit::IrregularStep ) ); QCOMPARE( object.totalFrameCount(), 3LL ); - QCOMPARE( object.dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ) ); + QCOMPARE( object.dateTimeRangeForFrameNumber( 0 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ) ); // negative should return first frame range - QCOMPARE( object.dateTimeRangeForFrameNumber( -1 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ) ); - QCOMPARE( object.dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 1, 15 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 1, 20 ), QTime( 0, 0, 0 ) ) ) ); - QCOMPARE( object.dateTimeRangeForFrameNumber( 2 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 4, 5 ), QTime( 0, 0, 0 ) ) ) ); - QCOMPARE( object.dateTimeRangeForFrameNumber( 5 ), QgsDateTimeRange( - QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ), - QDateTime( QDate( 2020, 4, 5 ), QTime( 0, 0, 0 ) ) ) ); + QCOMPARE( object.dateTimeRangeForFrameNumber( -1 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 11 ), QTime( 0, 0, 0 ) ) ) ); + QCOMPARE( object.dateTimeRangeForFrameNumber( 1 ), QgsDateTimeRange( QDateTime( QDate( 2020, 1, 15 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 1, 20 ), QTime( 0, 0, 0 ) ) ) ); + QCOMPARE( object.dateTimeRangeForFrameNumber( 2 ), QgsDateTimeRange( QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 4, 5 ), QTime( 0, 0, 0 ) ) ) ); + QCOMPARE( object.dateTimeRangeForFrameNumber( 5 ), QgsDateTimeRange( QDateTime( QDate( 2020, 3, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2020, 4, 5 ), QTime( 0, 0, 0 ) ) ) ); QCOMPARE( object.findBestFrameNumberForFrameStart( QDateTime( QDate( 2019, 1, 1 ), QTime() ) ), 0LL ); QCOMPARE( object.findBestFrameNumberForFrameStart( QDateTime( QDate( 2020, 1, 10 ), QTime( 0, 0, 0 ) ) ), 0LL ); @@ -424,7 +339,7 @@ void TestQgsTemporalNavigationObject::testMovieMode() object.setCurrentFrameNumber( 17 ); object.setFramesPerSecond( 30 ); - std::unique_ptr< QgsExpressionContextScope > scope( object.createExpressionContextScope() ); + std::unique_ptr scope( object.createExpressionContextScope() ); QCOMPARE( scope->variable( QStringLiteral( "frame_rate" ) ).toDouble(), 30.0 ); QCOMPARE( scope->variable( QStringLiteral( "frame_number" ) ).toInt(), 17 ); QCOMPARE( scope->variable( QStringLiteral( "total_frame_count" ) ).toInt(), 500 ); diff --git a/tests/src/core/testqgstemporalproperty.cpp b/tests/src/core/testqgstemporalproperty.cpp index 28582155c839..3b16f1f2c93b 100644 --- a/tests/src/core/testqgstemporalproperty.cpp +++ b/tests/src/core/testqgstemporalproperty.cpp @@ -34,10 +34,10 @@ class TestQgsTemporalProperty : public QObject TestQgsTemporalProperty() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void checkSettingTemporalStatus(); @@ -54,7 +54,6 @@ void TestQgsTemporalProperty::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsTemporalProperty::init() diff --git a/tests/src/core/testqgstemporalrangeobject.cpp b/tests/src/core/testqgstemporalrangeobject.cpp index 6d08377a7d93..ada432032583 100644 --- a/tests/src/core/testqgstemporalrangeobject.cpp +++ b/tests/src/core/testqgstemporalrangeobject.cpp @@ -33,10 +33,10 @@ class TestQgsTemporalRangeObject : public QObject TestQgsTemporalRangeObject() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void isTemporal(); void checkSettingTemporal(); @@ -55,7 +55,6 @@ void TestQgsTemporalRangeObject::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsTemporalRangeObject::init() diff --git a/tests/src/core/testqgstiledownloadmanager.cpp b/tests/src/core/testqgstiledownloadmanager.cpp index 2c08d701936e..d5b6931f5a42 100644 --- a/tests/src/core/testqgstiledownloadmanager.cpp +++ b/tests/src/core/testqgstiledownloadmanager.cpp @@ -37,8 +37,8 @@ class TestQgsTileDownloadManager : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void testOneRequest(); void testOneRequestEarlyDelete(); @@ -48,7 +48,6 @@ class TestQgsTileDownloadManager : public QObject void testTwoRequests(); void testShutdownWithPendingRequest(); void testIdleThread(); - }; @@ -113,7 +112,7 @@ void TestQgsTileDownloadManager::testOneRequestEarlyDelete() QVERIFY( manager.hasPendingRequests() ); - QThread::usleep( 1000 ); // sleep 1ms - enough time to start request but not enough to finish it + QThread::usleep( 1000 ); // sleep 1ms - enough time to start request but not enough to finish it r.reset(); @@ -190,7 +189,7 @@ void TestQgsTileDownloadManager::testOneRequestTwiceAndEarlyDelete() QVERIFY( manager.hasPendingRequests() ); QSignalSpy spy( r2.get(), &QgsTileDownloadManagerReply::finished ); - QThread::usleep( 1000 ); // sleep 1ms - enough time to start request but not enough to finish it + QThread::usleep( 1000 ); // sleep 1ms - enough time to start request but not enough to finish it r1.reset(); @@ -259,7 +258,7 @@ void TestQgsTileDownloadManager::testTwoRequests() QVERIFY( spy1.wait() ); if ( spy2.isEmpty() ) { - QVERIFY( spy2.wait() ); // r1 it may have finished earlier... + QVERIFY( spy2.wait() ); // r1 it may have finished earlier... } QCOMPARE( spy1.count(), 1 ); QCOMPARE( spy2.count(), 1 ); @@ -295,7 +294,7 @@ void TestQgsTileDownloadManager::testShutdownWithPendingRequest() QVERIFY( manager.hasPendingRequests() ); - QThread::usleep( 1000 ); // sleep 1ms - enough time to start request but not enough to finish it + QThread::usleep( 1000 ); // sleep 1ms - enough time to start request but not enough to finish it manager.shutdown(); @@ -315,7 +314,7 @@ void TestQgsTileDownloadManager::testIdleThread() // check that the worker thread gets killed after some time when it is idle QgsTileDownloadManager manager; - manager.setIdleThreadTimeout( 1000 ); // shorter timeout so that we don't need to wait for too long + manager.setIdleThreadTimeout( 1000 ); // shorter timeout so that we don't need to wait for too long QVERIFY( !manager.hasWorkerThreadRunning() ); @@ -327,7 +326,7 @@ void TestQgsTileDownloadManager::testIdleThread() QVERIFY( manager.hasWorkerThreadRunning() ); - QThread::usleep( 1500000 ); // sleep 1.5s - enough time to get the thread killed due to being idle + QThread::usleep( 1500000 ); // sleep 1.5s - enough time to get the thread killed due to being idle QVERIFY( !manager.hasWorkerThreadRunning() ); diff --git a/tests/src/core/testqgstiledsceneconnection.cpp b/tests/src/core/testqgstiledsceneconnection.cpp index 5311b1cc3388..1f5d4263c67e 100644 --- a/tests/src/core/testqgstiledsceneconnection.cpp +++ b/tests/src/core/testqgstiledsceneconnection.cpp @@ -24,13 +24,12 @@ class TestQgsTiledSceneConnection : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void encodeDecode(); void testConnections(); - }; @@ -91,7 +90,7 @@ void TestQgsTiledSceneConnection::testConnections() data.httpHeaders.insert( QStringLiteral( "my_header" ), QStringLiteral( "value" ) ); QgsTiledSceneProviderConnection::addConnection( QStringLiteral( "my connection" ), data ); - QCOMPARE( QgsTiledSceneProviderConnection::connectionList(), {QStringLiteral( "my connection" )} ); + QCOMPARE( QgsTiledSceneProviderConnection::connectionList(), { QStringLiteral( "my connection" ) } ); QCOMPARE( QgsTiledSceneProviderConnection::connection( QStringLiteral( "my connection" ) ).provider, QStringLiteral( "test_provider" ) ); QCOMPARE( QgsTiledSceneProviderConnection::connection( QStringLiteral( "my connection" ) ).url, QStringLiteral( "http://testurl" ) ); @@ -99,7 +98,7 @@ void TestQgsTiledSceneConnection::testConnections() // retrieve stored connection conn = QgsTiledSceneProviderConnection( QStringLiteral( "my connection" ) ); QCOMPARE( conn.uri(), QStringLiteral( "url=http://testurl&username=my_user&password=my_pw&authcfg=my_auth&http-header:my_header=value" ) ); - QCOMPARE( qgis::down_cast< QgsTiledSceneProviderConnection * >( &conn )->providerKey(), QStringLiteral( "test_provider" ) ); + QCOMPARE( qgis::down_cast( &conn )->providerKey(), QStringLiteral( "test_provider" ) ); // add a second connection QgsTiledSceneProviderConnection::Data data2; @@ -112,7 +111,7 @@ void TestQgsTiledSceneConnection::testConnections() // construct connection using encoded uri QgsTiledSceneProviderConnection conn2( QgsTiledSceneProviderConnection::encodedUri( data2 ), QStringLiteral( "test_provider2" ), {} ); QCOMPARE( conn2.uri(), QStringLiteral( "url=http://testurl2&username=my_user2&password=my_pw2&authcfg=my_auth2&http-header:my_header=value2" ) ); - QCOMPARE( qgis::down_cast< QgsTiledSceneProviderConnection * >( &conn2 )->providerKey(), QStringLiteral( "test_provider2" ) ); + QCOMPARE( qgis::down_cast( &conn2 )->providerKey(), QStringLiteral( "test_provider2" ) ); conn2.store( QStringLiteral( "second connection" ) ); // retrieve stored connections diff --git a/tests/src/core/testqgstiledscenerendererregistry.cpp b/tests/src/core/testqgstiledscenerendererregistry.cpp index c75f248f2dfd..84b13f77fbe2 100644 --- a/tests/src/core/testqgstiledscenerendererregistry.cpp +++ b/tests/src/core/testqgstiledscenerendererregistry.cpp @@ -33,7 +33,6 @@ class DummyRenderer : public QgsTiledSceneRenderer QDomElement save( QDomDocument &doc, const QgsReadWriteContext & ) const override { return doc.createElement( QStringLiteral( "test" ) ); } void renderTriangle( QgsTiledSceneRenderContext &, const QPolygonF & ) override {}; void renderLine( QgsTiledSceneRenderContext &, const QPolygonF & ) override {}; - }; class TestQgsTiledSceneRendererRegistry : public QObject @@ -52,7 +51,6 @@ class TestQgsTiledSceneRendererRegistry : public QObject void fetchTypes(); private: - }; void TestQgsTiledSceneRendererRegistry::initTestCase() @@ -68,12 +66,10 @@ void TestQgsTiledSceneRendererRegistry::cleanupTestCase() void TestQgsTiledSceneRendererRegistry::init() { - } void TestQgsTiledSceneRendererRegistry::cleanup() { - } void TestQgsTiledSceneRendererRegistry::metadata() @@ -84,7 +80,7 @@ void TestQgsTiledSceneRendererRegistry::metadata() //test creating renderer from metadata QDomElement elem; - const std::unique_ptr< QgsTiledSceneRenderer > renderer( metadata.createRenderer( elem, QgsReadWriteContext() ) ); + const std::unique_ptr renderer( metadata.createRenderer( elem, QgsReadWriteContext() ) ); QVERIFY( renderer ); DummyRenderer *dummyRenderer = dynamic_cast( renderer.get() ); QVERIFY( dummyRenderer ); @@ -113,7 +109,7 @@ void TestQgsTiledSceneRendererRegistry::addRenderer() QCOMPARE( registry->renderersList().length(), previousCount + 1 ); //try adding again, should have no effect QgsTiledSceneRendererMetadata *dupe = new QgsTiledSceneRendererMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "Dummy callout" ), DummyRenderer::create, QIcon() ); - QVERIFY( ! registry->addRenderer( dupe ) ); + QVERIFY( !registry->addRenderer( dupe ) ); QCOMPARE( registry->renderersList().length(), previousCount + 1 ); delete dupe; diff --git a/tests/src/core/testqgstiles.cpp b/tests/src/core/testqgstiles.cpp index e05127fb7f98..932507554ab9 100644 --- a/tests/src/core/testqgstiles.cpp +++ b/tests/src/core/testqgstiles.cpp @@ -38,10 +38,10 @@ class TestQgsTiles : public QObject QString mDataDir; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void test_matrixFromWebMercator(); void test_matrixFromCustomDef(); diff --git a/tests/src/core/testqgstracer.cpp b/tests/src/core/testqgstracer.cpp index b8018dd4100f..7bf48587beee 100644 --- a/tests/src/core/testqgstracer.cpp +++ b/tests/src/core/testqgstracer.cpp @@ -46,7 +46,6 @@ class TestQgsTracer : public QObject void testInvisible(); private: - }; namespace QTest @@ -54,16 +53,15 @@ namespace QTest template<> char *toString( const QgsPointXY &point ) { - QByteArray ba = "QgsPointXY(" + QByteArray::number( point.x() ) + - ", " + QByteArray::number( point.y() ) + ")"; + QByteArray ba = "QgsPointXY(" + QByteArray::number( point.x() ) + ", " + QByteArray::number( point.y() ) + ")"; return qstrdup( ba.data() ); } -} +} // namespace QTest static QgsFeature make_feature( const QString &wkt ) { QgsFeature f; - const QgsGeometry g = QgsGeometry::fromWkt( wkt ) ; + const QgsGeometry g = QgsGeometry::fromWkt( wkt ); f.setGeometry( g ); return f; } @@ -97,12 +95,10 @@ void print_shortest_path( QgsTracer &tracer, const QgsPointXY &p1, const QgsPoin } - void TestQgsTracer::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsTracer::cleanupTestCase() @@ -113,10 +109,10 @@ void TestQgsTracer::cleanupTestCase() void TestQgsTracer::testSimple() { QStringList wkts; - wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) - << QStringLiteral( "LINESTRING(0 0, 10 0)" ) - << QStringLiteral( "LINESTRING(0 10, 20 10)" ) - << QStringLiteral( "LINESTRING(10 0, 20 10)" ); + wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) + << QStringLiteral( "LINESTRING(0 0, 10 0)" ) + << QStringLiteral( "LINESTRING(0 10, 20 10)" ) + << QStringLiteral( "LINESTRING(10 0, 20 10)" ); /* This shape - nearly a square (one side is shifted to have exactly one shortest * path between corners): @@ -216,8 +212,8 @@ void TestQgsTracer::testInvisible() const QList nodes = m->layerLegendNodes( n ); QCOMPARE( nodes.length(), 1 ); //uncheck all and test that all nodes are unchecked - static_cast< QgsSymbolLegendNode * >( nodes.at( 0 ) )->uncheckAllItems(); - for ( QgsLayerTreeModelLegendNode *ln : nodes ) + static_cast( nodes.at( 0 ) )->uncheckAllItems(); + for ( QgsLayerTreeModelLegendNode *ln : nodes ) { QVERIFY( ln->data( Qt::CheckStateRole ) == Qt::Unchecked ); } @@ -252,7 +248,6 @@ void TestQgsTracer::testInvisible() tracer.setRenderContext( &renderContext ); points1 = tracer.findShortestPath( QgsPointXY( 10, 0 ), QgsPointXY( 0, 10 ) ); QCOMPARE( points1.count(), 0 ); - } void TestQgsTracer::testPolygon() @@ -357,10 +352,10 @@ void TestQgsTracer::testLayerUpdates() // same shape as in testSimple() QStringList wkts; - wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) - << QStringLiteral( "LINESTRING(0 0, 10 0)" ) - << QStringLiteral( "LINESTRING(0 10, 20 10)" ) - << QStringLiteral( "LINESTRING(10 0, 20 10)" ); + wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) + << QStringLiteral( "LINESTRING(0 0, 10 0)" ) + << QStringLiteral( "LINESTRING(0 10, 20 10)" ) + << QStringLiteral( "LINESTRING(10 0, 20 10)" ); QgsVectorLayer *vl = make_layer( wkts ); @@ -396,7 +391,7 @@ void TestQgsTracer::testLayerUpdates() // make the shortcut again from a different feature QgsGeometry g = QgsGeometry::fromWkt( QStringLiteral( "LINESTRING(10 0, 10 10)" ) ); - vl->changeGeometry( 2, g ); // change bottom line (second item in wkts) + vl->changeGeometry( 2, g ); // change bottom line (second item in wkts) QgsPolylineXY points4 = tracer.findShortestPath( QgsPointXY( 10, 0 ), QgsPointXY( 10, 10 ) ); QCOMPARE( points4.count(), 2 ); @@ -421,10 +416,10 @@ void TestQgsTracer::testExtent() // same shape as in testSimple() QStringList wkts; - wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) - << QStringLiteral( "LINESTRING(0 0, 10 0)" ) - << QStringLiteral( "LINESTRING(0 10, 20 10)" ) - << QStringLiteral( "LINESTRING(10 0, 20 10)" ); + wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) + << QStringLiteral( "LINESTRING(0 0, 10 0)" ) + << QStringLiteral( "LINESTRING(0 10, 20 10)" ) + << QStringLiteral( "LINESTRING(10 0, 20 10)" ); QgsVectorLayer *vl = make_layer( wkts ); @@ -445,7 +440,7 @@ void TestQgsTracer::testExtent() void TestQgsTracer::testReprojection() { QStringList wkts; - wkts << QStringLiteral( "LINESTRING(1 0, 2 0)" ); + wkts << QStringLiteral( "LINESTRING(1 0, 2 0)" ); QgsVectorLayer *vl = make_layer( wkts ); @@ -467,7 +462,7 @@ void TestQgsTracer::testReprojection() void TestQgsTracer::testCurved() { QStringList wkts; - wkts << QStringLiteral( "CIRCULARSTRING(0 0, 10 10, 20 0)" ); + wkts << QStringLiteral( "CIRCULARSTRING(0 0, 10 10, 20 0)" ); /* This shape - half of a circle (r = 10) * 10,10 _ @@ -500,10 +495,10 @@ void TestQgsTracer::testCurved() void TestQgsTracer::testOffset() { QStringList wkts; - wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) - << QStringLiteral( "LINESTRING(0 0, 10 0)" ) - << QStringLiteral( "LINESTRING(0 10, 20 10)" ) - << QStringLiteral( "LINESTRING(10 0, 20 10)" ); + wkts << QStringLiteral( "LINESTRING(0 0, 0 10)" ) + << QStringLiteral( "LINESTRING(0 0, 10 0)" ) + << QStringLiteral( "LINESTRING(0 10, 20 10)" ) + << QStringLiteral( "LINESTRING(10 0, 20 10)" ); /* This shape - nearly a square (one side is shifted to have exactly one shortest * path between corners): diff --git a/tests/src/core/testqgstranslateproject.cpp b/tests/src/core/testqgstranslateproject.cpp index fc5ef1d1d3c6..d022ae1e512d 100644 --- a/tests/src/core/testqgstranslateproject.cpp +++ b/tests/src/core/testqgstranslateproject.cpp @@ -36,19 +36,17 @@ class TestQgsTranslateProject : public QObject Q_OBJECT public: - private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void createTsFile(); void translateProject(); private: QString original_locale; - }; void TestQgsTranslateProject::initTestCase() @@ -198,7 +196,7 @@ void TestQgsTranslateProject::translateProject() //Class (Alias: Level) -> Klasse QCOMPARE( points_fields.field( QStringLiteral( "Class" ) ).alias(), QStringLiteral( "Klasse" ) ); //Heading -> Titel //#spellok - QCOMPARE( points_fields.field( QStringLiteral( "Heading" ) ).alias(), QStringLiteral( "Titel" ) ); //#spellok + QCOMPARE( points_fields.field( QStringLiteral( "Heading" ) ).alias(), QStringLiteral( "Titel" ) ); //#spellok //Importance -> Wichtigkeit QCOMPARE( points_fields.field( QStringLiteral( "Importance" ) ).alias(), QStringLiteral( "Wichtigkeit" ) ); //Pilots -> Piloten diff --git a/tests/src/core/testqgstriangularmesh.cpp b/tests/src/core/testqgstriangularmesh.cpp index 8c7f77fe8bac..4d497dd98084 100644 --- a/tests/src/core/testqgstriangularmesh.cpp +++ b/tests/src/core/testqgstriangularmesh.cpp @@ -37,10 +37,10 @@ class TestQgsTriangularMesh : public QObject TestQgsTriangularMesh() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void test_triangulate(); @@ -48,7 +48,6 @@ class TestQgsTriangularMesh : public QObject private: void populateMeshVertices( QgsTriangularMesh &mesh ); - }; void TestQgsTriangularMesh::populateMeshVertices( QgsTriangularMesh &mesh ) @@ -100,7 +99,7 @@ void TestQgsTriangularMesh::test_triangulate() const QgsMeshFace triangle = { 0, 1, 2 }; mesh.triangulate( triangle, 0 ); QCOMPARE( 1, mesh.mTriangularMesh.faces.size() ); - const QgsMeshFace firstTriangle = {1, 2, 0}; + const QgsMeshFace firstTriangle = { 1, 2, 0 }; QCOMPARE( firstTriangle, mesh.mTriangularMesh.faces[0] ); } @@ -110,9 +109,9 @@ void TestQgsTriangularMesh::test_triangulate() const QgsMeshFace quad = { 0, 1, 2, 3 }; mesh.triangulate( quad, 0 ); QCOMPARE( 2, mesh.mTriangularMesh.faces.size() ); - const QgsMeshFace firstTriangle = {2, 3, 0}; + const QgsMeshFace firstTriangle = { 2, 3, 0 }; QCOMPARE( firstTriangle, mesh.mTriangularMesh.faces[0] ); - const QgsMeshFace secondTriangle = {1, 2, 0}; + const QgsMeshFace secondTriangle = { 1, 2, 0 }; QCOMPARE( secondTriangle, mesh.mTriangularMesh.faces[1] ); } @@ -133,7 +132,7 @@ void TestQgsTriangularMesh::test_centroids() nativeMesh.vertices << QgsMeshVertex( 0, 10, 0 ) << QgsMeshVertex( 10, 10, 0 ) << QgsMeshVertex( 10, 0, 0 ) << QgsMeshVertex( 0, 0, 0 ) << QgsMeshVertex( 20, 0, 0 ) << QgsMeshVertex( 30, 10, 0 ) << QgsMeshVertex( 20, 10, 0 ); - nativeMesh.faces << QgsMeshFace( {0, 1, 2, 3} ) << QgsMeshFace( {1, 2, 4, 5} ); + nativeMesh.faces << QgsMeshFace( { 0, 1, 2, 3 } ) << QgsMeshFace( { 1, 2, 4, 5 } ); triangularMesh.update( &nativeMesh, QgsCoordinateTransform() ); @@ -153,7 +152,7 @@ void TestQgsTriangularMesh::test_centroids() nativeMesh.vertices << QgsMeshVertex( 900000000, 300000010, 0 ) << QgsMeshVertex( 900000010, 300000010, 0 ) << QgsMeshVertex( 900000010, 300000000, 0 ) << QgsMeshVertex( 900000000, 300000000, 0 ) << QgsMeshVertex( 900000020, 300000000, 0 ) << QgsMeshVertex( 900000030, 300000010, 0 ) << QgsMeshVertex( 900000020, 300000010, 0 ); - nativeMesh.faces << QgsMeshFace( {0, 1, 2, 3} ) << QgsMeshFace( {1, 2, 4, 5} ); + nativeMesh.faces << QgsMeshFace( { 0, 1, 2, 3 } ) << QgsMeshFace( { 1, 2, 4, 5 } ); triangularMesh.update( &nativeMesh, QgsCoordinateTransform() ); centroids = triangularMesh.faceCentroids(); @@ -164,7 +163,6 @@ void TestQgsTriangularMesh::test_centroids() QVERIFY( qgsDoubleNear( centroids.at( 0 ).y(), 300000005, 0.00001 ) ); QVERIFY( qgsDoubleNear( centroids.at( 1 ).x(), 900000017.777777, 0.00001 ) ); QVERIFY( qgsDoubleNear( centroids.at( 1 ).y(), 300000005.555555, 0.00001 ) ); - } QGSTEST_MAIN( TestQgsTriangularMesh ) diff --git a/tests/src/core/testqgsvaluerelationfieldformatter.cpp b/tests/src/core/testqgsvaluerelationfieldformatter.cpp index 3d43a2daf561..14ce3c65f477 100644 --- a/tests/src/core/testqgsvaluerelationfieldformatter.cpp +++ b/tests/src/core/testqgsvaluerelationfieldformatter.cpp @@ -26,16 +26,16 @@ //header for class being tested #include "fieldformatter/qgsvaluerelationfieldformatter.h" -class TestQgsValueRelationFieldFormatter: public QObject +class TestQgsValueRelationFieldFormatter : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testDependencies(); void testSortValueNull(); void testGroup(); @@ -46,7 +46,6 @@ class TestQgsValueRelationFieldFormatter: public QObject std::unique_ptr mLayer1; std::unique_ptr mLayer2; std::unique_ptr mRelation; - }; @@ -134,12 +133,7 @@ void TestQgsValueRelationFieldFormatter::testDependencies() { // Test dependencies - const QgsEditorWidgetSetup setup { QStringLiteral( "ValueRelation" ), { - { QStringLiteral( "LayerSource" ), mLayer2->publicSource() }, - { QStringLiteral( "LayerProviderName" ), mLayer2->providerType() }, - { QStringLiteral( "LayerName" ), mLayer2->name() }, - { QStringLiteral( "Layer" ), mLayer2->id() } - }}; + const QgsEditorWidgetSetup setup { QStringLiteral( "ValueRelation" ), { { QStringLiteral( "LayerSource" ), mLayer2->publicSource() }, { QStringLiteral( "LayerProviderName" ), mLayer2->providerType() }, { QStringLiteral( "LayerName" ), mLayer2->name() }, { QStringLiteral( "Layer" ), mLayer2->id() } } }; QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() ); const QList dependencies = fieldFormatter->layerDependencies( setup.config() ); QVERIFY( dependencies.count() == 1 ); @@ -199,7 +193,6 @@ void TestQgsValueRelationFieldFormatter::testOrderBy_data() void TestQgsValueRelationFieldFormatter::testOrderBy() { - QFETCH( QString, orderBy ); QFETCH( QString, fieldName ); QFETCH( QString, expectedFirst ); diff --git a/tests/src/core/testqgsvector.cpp b/tests/src/core/testqgsvector.cpp index 2a41ab6369d5..c318af2942e6 100644 --- a/tests/src/core/testqgsvector.cpp +++ b/tests/src/core/testqgsvector.cpp @@ -27,8 +27,8 @@ class TestQgsVector : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. // vector3d void vector3d(); diff --git a/tests/src/core/testqgsvectordataprovider.cpp b/tests/src/core/testqgsvectordataprovider.cpp index 4da1faece616..70a44ca0123d 100644 --- a/tests/src/core/testqgsvectordataprovider.cpp +++ b/tests/src/core/testqgsvectordataprovider.cpp @@ -33,8 +33,8 @@ class TestQgsVectorDataProvider : public QObject private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. // test whether QgsFeature content is set up correctly void select_checkContents_data(); @@ -49,7 +49,6 @@ class TestQgsVectorDataProvider : public QObject void sourceExtent(); private: - QgsVectorLayer *vlayerPoints = nullptr; QgsVectorLayer *vlayerLines = nullptr; QgsVectorLayer *vlayerPoints3D = nullptr; @@ -112,7 +111,7 @@ static void checkFid4( QgsFeature &f, bool hasGeometry, bool hasAttrs, int onlyO { const QgsAttributes &attrs = f.attributes(); - QCOMPARE( f.id(), ( QgsFeatureId )4 ); + QCOMPARE( f.id(), ( QgsFeatureId ) 4 ); QCOMPARE( f.attributes().count(), 6 ); if ( hasAttrs ) @@ -133,7 +132,7 @@ static void checkFid4( QgsFeature &f, bool hasGeometry, bool hasAttrs, int onlyO QVERIFY( f.hasGeometry() ); QVERIFY( f.geometry().wkbType() == Qgis::WkbType::Point ); QCOMPARE( keep6digits( f.geometry().asPoint().x() ), -88.302277 ); - QCOMPARE( keep6digits( f.geometry().asPoint().y() ), 33.731884 ); + QCOMPARE( keep6digits( f.geometry().asPoint().y() ), 33.731884 ); } else { diff --git a/tests/src/core/testqgsvectorfilewriter.cpp b/tests/src/core/testqgsvectorfilewriter.cpp index c640863bfcb1..de4381bc3d86 100644 --- a/tests/src/core/testqgsvectorfilewriter.cpp +++ b/tests/src/core/testqgsvectorfilewriter.cpp @@ -19,11 +19,11 @@ #include #include -#include "qgsvectorlayer.h" //defines QgsFieldMap -#include "qgsvectorfilewriter.h" //logic for writing shpfiles -#include "qgsfeature.h" //we will need to pass a bunch of these for each rec -#include "qgsgeometry.h" //each feature needs a geometry -#include "qgspointxy.h" //we will use point geometry +#include "qgsvectorlayer.h" //defines QgsFieldMap +#include "qgsvectorfilewriter.h" //logic for writing shpfiles +#include "qgsfeature.h" //we will need to pass a bunch of these for each rec +#include "qgsgeometry.h" //each feature needs a geometry +#include "qgspointxy.h" //we will use point geometry #include "qgscoordinatereferencesystem.h" //needed for creating a srs #include "qgscoordinatetransformcontext.h" #include "qgsapplication.h" //search path for srs.db @@ -31,7 +31,7 @@ #include "qgsfield.h" #include "qgis.h" //defines GEOWkt -#if defined(linux) +#if defined( linux ) #include #endif @@ -57,24 +57,20 @@ * int prec, * QString comment) */ -class TestQgsVectorFileWriter: public QObject +class TestQgsVectorFileWriter : public QObject { Q_OBJECT public: TestQgsVectorFileWriter(); - void _testExportToGpx( const QString &geomTypeName, - const QString &wkt, - const QString &expectedLayerName, - const QString &inputLayerName = QStringLiteral( "test" ), - const QStringList &layerOptions = QStringList() ); + void _testExportToGpx( const QString &geomTypeName, const QString &wkt, const QString &expectedLayerName, const QString &inputLayerName = QStringLiteral( "test" ), const QStringList &layerOptions = QStringList() ); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. + void cleanupTestCase(); // will be called after the last testfunction was executed. //! This method tests writing a point to a shapefile void createPoint(); @@ -112,11 +108,12 @@ class TestQgsVectorFileWriter: public QObject void testExportCustomFieldNames(); //! Test export to shape with NaN values for Z void testExportToShapeNanValuesForZ(); + private: // a little util fn used by all tests bool cleanupFile( QString fileBase ); QString mEncoding; - QgsVectorFileWriter::WriterError mError = QgsVectorFileWriter::NoError ; + QgsVectorFileWriter::WriterError mError = QgsVectorFileWriter::NoError; QgsCoordinateReferenceSystem mCRS; QgsFields mFields; QgsPointXY mPoint1; @@ -158,7 +155,6 @@ void TestQgsVectorFileWriter::cleanupTestCase() void TestQgsVectorFileWriter::createPoint() { - // // Remove old copies that may be lying around // @@ -168,7 +164,7 @@ void TestQgsVectorFileWriter::createPoint() QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = mEncoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Point, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); + std::unique_ptr writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Point, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); // // Create a feature // @@ -210,7 +206,7 @@ void TestQgsVectorFileWriter::createLine() QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = mEncoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::LineString, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); + std::unique_ptr writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::LineString, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); // // Create a feature // @@ -244,7 +240,6 @@ void TestQgsVectorFileWriter::createLine() void TestQgsVectorFileWriter::createPolygon() { - // // Remove old copies that may be lying around // @@ -254,7 +249,7 @@ void TestQgsVectorFileWriter::createPolygon() QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = mEncoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); + std::unique_ptr writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); // // Create a polygon feature // @@ -301,7 +296,7 @@ void TestQgsVectorFileWriter::polygonGridTest() QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = mEncoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); + std::unique_ptr writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); const double myInterval = 5.0; for ( double i = -180.0; i <= 180.0; i += myInterval ) { @@ -364,11 +359,11 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest() QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = mEncoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); - const double myInterval = 1000.0; //1km2 + std::unique_ptr writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::Polygon, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); + const double myInterval = 1000.0; //1km2 for ( double i = 0.0; i <= 10000.0; i += myInterval ) //10km { - for ( double j = 0.0; j <= 10000.0; j += myInterval )//10km + for ( double j = 0.0; j <= 10000.0; j += myInterval ) //10km { // // Create a polygon feature @@ -414,7 +409,7 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest() void TestQgsVectorFileWriter::regression1141() { -#if defined(linux) +#if defined( linux ) const char *cs = nl_langinfo( CODESET ); QgsDebugMsgLevel( QStringLiteral( "CODESET:%1" ).arg( cs ? cs : "unset" ), 1 ); if ( !cs || strcmp( cs, "UTF-8" ) != 0 ) @@ -432,7 +427,7 @@ void TestQgsVectorFileWriter::regression1141() QgsCoordinateReferenceSystem crs; crs = QgsCoordinateReferenceSystem( geoWkt() ); const QString tmpDir = QDir::tempPath() + '/'; - const QString fileName = tmpDir + "ąęćń.shp"; + const QString fileName = tmpDir + "ąęćń.shp"; QVERIFY2( !QFile::exists( fileName ), QString( "File %1 already exists, cannot run test" ).arg( fileName ).toLocal8Bit().constData() ); @@ -441,7 +436,7 @@ void TestQgsVectorFileWriter::regression1141() { QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = encoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( fileName, fields, Qgis::WkbType::Point, crs, QgsCoordinateTransformContext(), saveOptions ) ); + std::unique_ptr writer( QgsVectorFileWriter::create( fileName, fields, Qgis::WkbType::Point, crs, QgsCoordinateTransformContext(), saveOptions ) ); const QgsPointXY myPoint = QgsPointXY( 10.0, 10.0 ); const QgsGeometry mypPointGeometry = QgsGeometry::fromPointXY( myPoint ); @@ -481,23 +476,24 @@ void TestQgsVectorFileWriter::prepareWriteAsVectorFormat() QgsVectorFileWriter::PreparedWriterDetails details; QgsVectorFileWriter::SaveVectorOptions options; QgsVectorLayer ml( "Point?field=firstfield:int&field=secondfield:int", "test", "memory" ); - QgsFeature ft( ml.fields( ) ); + QgsFeature ft( ml.fields() ); ft.setAttribute( 0, 4 ); ft.setAttribute( 1, -10 ); ml.dataProvider()->addFeature( ft ); QVERIFY( ml.isValid() ); - QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter_XXXXXX.gpkg" ); + QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter_XXXXXX.gpkg" ); tmpFile.open(); - const QString fileName( tmpFile.fileName( ) ); + const QString fileName( tmpFile.fileName() ); options.driverName = "GPKG"; options.layerName = "test"; QString newFilename; const QgsVectorFileWriter::WriterError error( QgsVectorFileWriter::writeAsVectorFormatV3( - &ml, - fileName, - ml.transformContext(), - options, nullptr, - &newFilename ) ); + &ml, + fileName, + ml.transformContext(), + options, nullptr, + &newFilename + ) ); QCOMPARE( error, QgsVectorFileWriter::WriterError::NoError ); QCOMPARE( newFilename, fileName ); @@ -510,9 +506,9 @@ void TestQgsVectorFileWriter::prepareWriteAsVectorFormat() void TestQgsVectorFileWriter::testTextFieldLength() { - QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter2_XXXXXX.gpkg" ); + QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter2_XXXXXX.gpkg" ); tmpFile.open(); - const QString fileName( tmpFile.fileName( ) ); + const QString fileName( tmpFile.fileName() ); QgsVectorLayer vl( "Point?field=firstfield:string(1024)", "test", "memory" ); QCOMPARE( vl.fields().at( 0 ).length(), 1024 ); QgsFeature f { vl.fields() }; @@ -525,11 +521,12 @@ void TestQgsVectorFileWriter::testTextFieldLength() options.layerName = "test"; QString newFilename; const QgsVectorFileWriter::WriterError error( QgsVectorFileWriter::writeAsVectorFormatV3( - &vl, - fileName, - vl.transformContext(), - options, nullptr, - &newFilename ) ); + &vl, + fileName, + vl.transformContext(), + options, nullptr, + &newFilename + ) ); QCOMPARE( error, QgsVectorFileWriter::WriterError::NoError ); QCOMPARE( newFilename, fileName ); const QgsVectorLayer vl2( QStringLiteral( "%1|layername=test" ).arg( fileName ), "src_test", "ogr" ); @@ -537,14 +534,13 @@ void TestQgsVectorFileWriter::testTextFieldLength() QCOMPARE( vl2.featureCount(), 1L ); QCOMPARE( vl2.fields().at( 1 ).length(), 1024 ); QCOMPARE( vl2.getFeature( 1 ).attribute( 1 ).toString(), QString( 1024, 'x' ) ); - } void TestQgsVectorFileWriter::testExportArrayToGpkg() { - QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter3_XXXXXX.gpkg" ); + QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter3_XXXXXX.gpkg" ); tmpFile.open(); - const QString fileName( tmpFile.fileName( ) ); + const QString fileName( tmpFile.fileName() ); QgsVectorLayer vl( "Point?field=arrayfield:integerlist&field=arrayfield2:stringlist", "test", "memory" ); QCOMPARE( vl.fields().at( 0 ).type(), QMetaType::Type::QVariantList ); QCOMPARE( vl.fields().at( 0 ).subType(), QMetaType::Type::Int ); @@ -561,11 +557,12 @@ void TestQgsVectorFileWriter::testExportArrayToGpkg() options.layerName = "test"; QString newFilename; const QgsVectorFileWriter::WriterError error( QgsVectorFileWriter::writeAsVectorFormatV3( - &vl, - fileName, - vl.transformContext(), - options, nullptr, - &newFilename ) ); + &vl, + fileName, + vl.transformContext(), + options, nullptr, + &newFilename + ) ); QCOMPARE( error, QgsVectorFileWriter::WriterError::NoError ); QCOMPARE( newFilename, fileName ); const QgsVectorLayer vl2( QStringLiteral( "%1|layername=test" ).arg( fileName ), "src_test", "ogr" ); @@ -581,15 +578,11 @@ void TestQgsVectorFileWriter::testExportArrayToGpkg() QCOMPARE( vl2.getFeature( 1 ).attribute( 2 ).toStringList(), QStringList() << "a" << "b" << "c" ); } -void TestQgsVectorFileWriter::_testExportToGpx( const QString &geomTypeName, - const QString &wkt, - const QString &expectedLayerName, - const QString &inputLayerName, - const QStringList &layerOptions ) +void TestQgsVectorFileWriter::_testExportToGpx( const QString &geomTypeName, const QString &wkt, const QString &expectedLayerName, const QString &inputLayerName, const QStringList &layerOptions ) { - QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter_testExportToGpx" + geomTypeName + "_XXXXXX.gpx" ); + QTemporaryFile tmpFile( QDir::tempPath() + "/test_qgsvectorfilewriter_testExportToGpx" + geomTypeName + "_XXXXXX.gpx" ); tmpFile.open(); - const QString fileName( tmpFile.fileName( ) ); + const QString fileName( tmpFile.fileName() ); QString memLayerDef( geomTypeName ); if ( inputLayerName == QLatin1String( "track_points" ) ) { @@ -619,12 +612,13 @@ void TestQgsVectorFileWriter::_testExportToGpx( const QString &geomTypeName, options.layerOptions = layerOptions; QString outLayerName; const QgsVectorFileWriter::WriterError error( QgsVectorFileWriter::writeAsVectorFormatV3( - &vl, - fileName, - vl.transformContext(), - options, nullptr, - nullptr, // newFilename - &outLayerName ) ); + &vl, + fileName, + vl.transformContext(), + options, nullptr, + nullptr, // newFilename + &outLayerName + ) ); QCOMPARE( error, QgsVectorFileWriter::WriterError::NoError ); QCOMPARE( outLayerName, expectedLayerName ); const QgsVectorLayer vl2( QStringLiteral( "%1|layername=%2" ).arg( fileName ).arg( outLayerName ), "src_test", "ogr" ); @@ -634,57 +628,37 @@ void TestQgsVectorFileWriter::_testExportToGpx( const QString &geomTypeName, void TestQgsVectorFileWriter::testExportToGpxPoint() { - _testExportToGpx( QStringLiteral( "Point" ), - QStringLiteral( "point(9 45)" ), - QStringLiteral( "waypoints" ) ); + _testExportToGpx( QStringLiteral( "Point" ), QStringLiteral( "point(9 45)" ), QStringLiteral( "waypoints" ) ); } void TestQgsVectorFileWriter::testExportToGpxPointTrackPoints() { - _testExportToGpx( QStringLiteral( "Point" ), - QStringLiteral( "point(9 45)" ), - QStringLiteral( "track_points" ), - QStringLiteral( "track_points" ) ); + _testExportToGpx( QStringLiteral( "Point" ), QStringLiteral( "point(9 45)" ), QStringLiteral( "track_points" ), QStringLiteral( "track_points" ) ); } void TestQgsVectorFileWriter::testExportToGpxPointRoutePoints() { - _testExportToGpx( QStringLiteral( "Point" ), - QStringLiteral( "point(9 45)" ), - QStringLiteral( "route_points" ), - QStringLiteral( "route_points" ) ); + _testExportToGpx( QStringLiteral( "Point" ), QStringLiteral( "point(9 45)" ), QStringLiteral( "route_points" ), QStringLiteral( "route_points" ) ); } void TestQgsVectorFileWriter::testExportToGpxLineString() { - _testExportToGpx( QStringLiteral( "LineString" ), - QStringLiteral( "linestring(9 45,10 46)" ), - QStringLiteral( "routes" ) ); + _testExportToGpx( QStringLiteral( "LineString" ), QStringLiteral( "linestring(9 45,10 46)" ), QStringLiteral( "routes" ) ); } void TestQgsVectorFileWriter::testExportToGpxLineStringForceTrack() { - _testExportToGpx( QStringLiteral( "LineString" ), - QStringLiteral( "linestring(9 45,10 46)" ), - QStringLiteral( "tracks" ), - QStringLiteral( "test" ), - QStringList() << QStringLiteral( "FORCE_GPX_TRACK=YES" ) ); + _testExportToGpx( QStringLiteral( "LineString" ), QStringLiteral( "linestring(9 45,10 46)" ), QStringLiteral( "tracks" ), QStringLiteral( "test" ), QStringList() << QStringLiteral( "FORCE_GPX_TRACK=YES" ) ); } void TestQgsVectorFileWriter::testExportToGpxMultiLineString() { - _testExportToGpx( QStringLiteral( "MultiLineString" ), - QStringLiteral( "multilinestring((9 45,10 46))" ), - QStringLiteral( "tracks" ) ); + _testExportToGpx( QStringLiteral( "MultiLineString" ), QStringLiteral( "multilinestring((9 45,10 46))" ), QStringLiteral( "tracks" ) ); } void TestQgsVectorFileWriter::testExportToGpxMultiLineStringForceRoute() { - _testExportToGpx( QStringLiteral( "MultiLineString" ), - QStringLiteral( "multilinestring((9 45,10 46))" ), - QStringLiteral( "routes" ), - QStringLiteral( "test" ), - QStringList() << QStringLiteral( "FORCE_GPX_ROUTE=YES" ) ); + _testExportToGpx( QStringLiteral( "MultiLineString" ), QStringLiteral( "multilinestring((9 45,10 46))" ), QStringLiteral( "routes" ), QStringLiteral( "test" ), QStringList() << QStringLiteral( "FORCE_GPX_ROUTE=YES" ) ); } void TestQgsVectorFileWriter::testExportCustomFieldNames() @@ -692,7 +666,7 @@ void TestQgsVectorFileWriter::testExportCustomFieldNames() QgsVectorFileWriter::PreparedWriterDetails details; QgsVectorFileWriter::SaveVectorOptions options; QgsVectorLayer ml( "Point?field=firstfield:int&field=secondfield:int", "test", "memory" ); - QgsFeature ft( ml.fields( ) ); + QgsFeature ft( ml.fields() ); ft.setAttribute( 0, 4 ); ft.setAttribute( 1, -10 ); ml.dataProvider()->addFeature( ft ); @@ -716,14 +690,12 @@ void TestQgsVectorFileWriter::testExportToShapeNanValuesForZ() QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = mEncoding; - std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::LineStringZ, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); + std::unique_ptr writer( QgsVectorFileWriter::create( myFileName, mFields, Qgis::WkbType::LineStringZ, mCRS, QgsCoordinateTransformContext(), saveOptions ) ); // // Create a feature // QgsLineString *ls = new QgsLineString(); - ls->setPoints( QgsPointSequence() << QgsPoint( mPoint1 ) - << QgsPoint( mPoint2 ) - << QgsPoint( mPoint3 ) ); + ls->setPoints( QgsPointSequence() << QgsPoint( mPoint1 ) << QgsPoint( mPoint2 ) << QgsPoint( mPoint3 ) ); ls->setZAt( 1, std::numeric_limits::quiet_NaN() ); const QgsGeometry mypLineGeometry( ls ); QgsFeature myFeature; diff --git a/tests/src/core/testqgsvectorlayer.cpp b/tests/src/core/testqgsvectorlayer.cpp index 1a3b9c1ecfdf..0fc472aca29a 100644 --- a/tests/src/core/testqgsvectorlayer.cpp +++ b/tests/src/core/testqgsvectorlayer.cpp @@ -44,10 +44,11 @@ class TestQgsVectorLayer : public QgsTest { Q_OBJECT public: - TestQgsVectorLayer() : QgsTest( QStringLiteral( "Vector Renderer Tests" ) ) {} + TestQgsVectorLayer() + : QgsTest( QStringLiteral( "Vector Renderer Tests" ) ) {} private: - bool mTestHasError = false ; + bool mTestHasError = false; QgsVectorLayer *mpPointsLayer = nullptr; QgsVectorLayer *mpLinesLayer = nullptr; QgsVectorLayer *mpPolysLayer = nullptr; @@ -57,7 +58,7 @@ class TestQgsVectorLayer : public QgsTest private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. void nonSpatialIterator(); @@ -93,32 +94,32 @@ void TestQgsVectorLayer::initTestCase() mTestDataDir = myDataDir + '/'; const QString myDbfFileName = mTestDataDir + "nonspatial.dbf"; const QFileInfo myDbfFileInfo( myDbfFileName ); - mpNonSpatialLayer = new QgsVectorLayer( myDbfFileInfo.filePath(), - myDbfFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpNonSpatialLayer = new QgsVectorLayer( myDbfFileInfo.filePath(), myDbfFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpNonSpatialLayer ); + QList() << mpNonSpatialLayer + ); // //create a point layer that will be used in all tests... // const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPointsLayer ); + QList() << mpPointsLayer + ); // //create a poly layer that will be used in all tests... // const QString myPolysFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpPolysLayer ); + QList() << mpPolysLayer + ); // @@ -126,11 +127,11 @@ void TestQgsVectorLayer::initTestCase() // const QString myLinesFileName = mTestDataDir + "lines.shp"; const QFileInfo myLineFileInfo( myLinesFileName ); - mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), - myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), myLineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // Register the layer with the registry QgsProject::instance()->addMapLayers( - QList() << mpLinesLayer ); + QList() << mpLinesLayer + ); } void TestQgsVectorLayer::cleanupTestCase() @@ -247,14 +248,14 @@ void TestQgsVectorLayer::setFeatureBlendMode() mpPointsLayer->setFeatureBlendMode( QPainter::CompositionMode_Screen ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( spy.at( 0 ).at( 0 ).toInt(), static_cast< int >( QPainter::CompositionMode_Screen ) ); + QCOMPARE( spy.at( 0 ).at( 0 ).toInt(), static_cast( QPainter::CompositionMode_Screen ) ); QCOMPARE( mpPointsLayer->featureBlendMode(), QPainter::CompositionMode_Screen ); mpPointsLayer->setFeatureBlendMode( QPainter::CompositionMode_Screen ); QCOMPARE( spy.count(), 1 ); mpPointsLayer->setFeatureBlendMode( QPainter::CompositionMode_Darken ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( spy.at( 1 ).at( 0 ).toInt(), static_cast< int >( QPainter::CompositionMode_Darken ) ); + QCOMPARE( spy.at( 1 ).at( 0 ).toInt(), static_cast( QPainter::CompositionMode_Darken ) ); QCOMPARE( mpPointsLayer->featureBlendMode(), QPainter::CompositionMode_Darken ); } @@ -326,7 +327,7 @@ void TestQgsVectorLayer::testAddTopologicalPoints() layerLine->startEditing(); layerLine->addFeature( lineF1 ); const QgsFeatureId fidLineF1 = lineF1.id(); - QCOMPARE( layerLine->featureCount(), ( long )1 ); + QCOMPARE( layerLine->featureCount(), ( long ) 1 ); QCOMPARE( layerLine->undoStack()->index(), 1 ); @@ -372,11 +373,11 @@ void TestQgsVectorLayer::testAddTopologicalPoints() QVERIFY( nonSpatialLayer->isValid() ); result = nonSpatialLayer->addTopologicalPoints( QgsPoint( 2, 2 ) ); - QCOMPARE( result, -1 ); // Non editable + QCOMPARE( result, -1 ); // Non editable nonSpatialLayer->startEditing(); result = nonSpatialLayer->addTopologicalPoints( QgsPoint( 2, 2 ) ); - QCOMPARE( result, 1 ); // Non spatial + QCOMPARE( result, 1 ); // Non spatial delete nonSpatialLayer; @@ -385,7 +386,7 @@ void TestQgsVectorLayer::testAddTopologicalPoints() layerPoint->startEditing(); result = layerPoint->addTopologicalPoints( QgsGeometry() ); - QCOMPARE( result, 1 ); // Null geometry + QCOMPARE( result, 1 ); // Null geometry delete layerPoint; @@ -393,7 +394,7 @@ void TestQgsVectorLayer::testAddTopologicalPoints() QVERIFY( !layerInvalid->isValid() ); result = layerInvalid->addTopologicalPoints( QgsPoint( 2, 2 ) ); - QCOMPARE( result, -1 ); // Invalid layer + QCOMPARE( result, -1 ); // Invalid layer delete layerInvalid; } @@ -462,8 +463,8 @@ void TestQgsVectorLayer::testFieldExpression() layer1.addExpressionField( QStringLiteral( "'abc'" ), QgsField( QStringLiteral( "virtual_field" ), QMetaType::Type::QString ) ); - QCOMPARE( layer1.expressionField( layer1.fields().lookupField( QStringLiteral( "virtual_field" ) ) ), QStringLiteral( "'abc'" ) ); - QCOMPARE( layer1.expressionField( layer1.fields().lookupField( QStringLiteral( "name" ) ) ), QString() ); + QCOMPARE( layer1.expressionField( layer1.fields().lookupField( QStringLiteral( "virtual_field" ) ) ), QStringLiteral( "'abc'" ) ); + QCOMPARE( layer1.expressionField( layer1.fields().lookupField( QStringLiteral( "name" ) ) ), QString() ); } void TestQgsVectorLayer::testFieldAggregateExpression() @@ -495,6 +496,5 @@ void TestQgsVectorLayer::testFieldAggregateExpression() } - QGSTEST_MAIN( TestQgsVectorLayer ) #include "testqgsvectorlayer.moc" diff --git a/tests/src/core/testqgsvectorlayercache.cpp b/tests/src/core/testqgsvectorlayercache.cpp index 14f889146db6..9a8b90bacc19 100644 --- a/tests/src/core/testqgsvectorlayercache.cpp +++ b/tests/src/core/testqgsvectorlayercache.cpp @@ -42,10 +42,10 @@ class TestVectorLayerCache : public QObject TestVectorLayerCache() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. - void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testCacheOverflow(); // Test cache will work if too many features to cache them all are present void testCacheAttrActions(); // Test attribute add/ attribute delete @@ -65,10 +65,10 @@ class TestVectorLayerCache : public QObject void onCommittedFeaturesAdded( const QString &, const QgsFeatureList & ); private: - QgsVectorLayerCache *mVectorLayerCache = nullptr; - QgsCacheIndexFeatureId *mFeatureIdIndex = nullptr; - QgsVectorLayer *mPointsLayer = nullptr; - QgsFeatureList mAddedFeatures; + QgsVectorLayerCache *mVectorLayerCache = nullptr; + QgsCacheIndexFeatureId *mFeatureIdIndex = nullptr; + QgsVectorLayer *mPointsLayer = nullptr; + QgsFeatureList mAddedFeatures; QMap mTmpFiles; }; @@ -104,8 +104,7 @@ void TestVectorLayerCache::initTestCase() // const QString myPointsFileName = mTmpFiles.value( myTestDataDir + "points.shp" ); const QFileInfo myPointFileInfo( myPointsFileName ); - mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); } void TestVectorLayerCache::init() @@ -221,7 +220,9 @@ void TestVectorLayerCache::testSubsetRequest() const QVariant a = f.attribute( 3 ); QgsFeatureIterator itSubset = mVectorLayerCache->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( requiredFields, fields ) ); - while ( itSubset.nextFeature( f ) ) {} + while ( itSubset.nextFeature( f ) ) + { + } itSubset.close(); mVectorLayerCache->featureAtId( 16, f ); @@ -307,7 +308,9 @@ void TestVectorLayerCache::testCanUseCacheForRequest() // get just the first feature into the cache it = cache.getFeatures( QgsFeatureRequest().setFilterFid( id1 ) ); - while ( it.nextFeature( f ) ) { } + while ( it.nextFeature( f ) ) + { + } QCOMPARE( cache.cachedFeatureIds(), QgsFeatureIds() << id1 ); QVERIFY( cache.canUseCacheForRequest( QgsFeatureRequest().setFilterFid( id1 ), it ) ); //verify that the returned iterator was correct @@ -321,7 +324,9 @@ void TestVectorLayerCache::testCanUseCacheForRequest() // get feature 2 into cache it = cache.getFeatures( QgsFeatureRequest().setFilterFid( id2 ) ); - while ( it.nextFeature( f ) ) { } + while ( it.nextFeature( f ) ) + { + } QCOMPARE( cache.cachedFeatureIds(), QgsFeatureIds() << id1 << id2 ); QVERIFY( cache.canUseCacheForRequest( QgsFeatureRequest().setFilterFid( id1 ), it ) ); QVERIFY( it.nextFeature( f ) ); @@ -407,16 +412,16 @@ void TestVectorLayerCache::testFullCacheWithRect() QgsVectorLayerCache cache( mPointsLayer, static_cast( mPointsLayer->dataProvider()->featureCount() ) ); // cache geometry cache.setCacheGeometry( true ); - QVERIFY( ! cache.hasFullCache() ); + QVERIFY( !cache.hasFullCache() ); QgsFeatureRequest req; - req.setFilterRect( mPointsLayer->dataProvider()->extent().buffered( - mPointsLayer->dataProvider()->extent().width() / 2 ) ); + req.setFilterRect( mPointsLayer->dataProvider()->extent().buffered( -mPointsLayer->dataProvider()->extent().width() / 2 ) ); QgsFeatureIterator it = cache.getFeatures( req ); QgsFeature f; while ( it.nextFeature( f ) ) { QVERIFY( f.hasGeometry() ); } - QVERIFY( ! cache.hasFullCache() ); + QVERIFY( !cache.hasFullCache() ); // Filter rect contains extent req.setFilterRect( mPointsLayer->dataProvider()->extent().buffered( 1 ) ); @@ -426,16 +431,14 @@ void TestVectorLayerCache::testFullCacheWithRect() QVERIFY( f.hasGeometry() ); } QVERIFY( cache.hasFullCache() ); - } void TestVectorLayerCache::testMixedAttributesCache() { - // Test cache with no subset QgsVectorLayerCache cache( mPointsLayer, static_cast( mPointsLayer->dataProvider()->featureCount() ) ); QgsFeature f; - QgsFeatureIterator it = cache.getFeatures( ); + QgsFeatureIterator it = cache.getFeatures(); it.nextFeature( f ); QVERIFY( cache.isFidCached( f.id() ) ); @@ -443,46 +446,45 @@ void TestVectorLayerCache::testMixedAttributesCache() // Test with subset QgsVectorLayerCache cacheSubset( mPointsLayer, static_cast( mPointsLayer->dataProvider()->featureCount() ) ); - cacheSubset.setCacheSubsetOfAttributes( {2} ); - QgsFeatureIterator itSubset = cacheSubset.getFeatures( ); + cacheSubset.setCacheSubsetOfAttributes( { 2 } ); + QgsFeatureIterator itSubset = cacheSubset.getFeatures(); itSubset.nextFeature( f ); - QVERIFY( ! cacheSubset.isFidCached( f.id() ) ); + QVERIFY( !cacheSubset.isFidCached( f.id() ) ); cacheSubset.featureAtId( f.id(), f ); QVERIFY( cacheSubset.isFidCached( f.id() ) ); - QVERIFY( ! cacheSubset.mCache[f.id()]->allAttributesFetched() ); + QVERIFY( !cacheSubset.mCache[f.id()]->allAttributesFetched() ); QVERIFY( f.attribute( 0 ).isNull() ); QVERIFY( f.attribute( 1 ).isNull() ); - QVERIFY( ! f.attribute( 2 ).isNull() ); + QVERIFY( !f.attribute( 2 ).isNull() ); cacheSubset.featureAtIdWithAllAttributes( 0, f ); QVERIFY( cacheSubset.isFidCached( 0 ) ); - QVERIFY( cacheSubset.mCache[ 0 ]->allAttributesFetched() ); - QVERIFY( ! f.attribute( 0 ).isNull() ); - QVERIFY( ! f.attribute( 1 ).isNull() ); - QVERIFY( ! f.attribute( 2 ).isNull() ); + QVERIFY( cacheSubset.mCache[0]->allAttributesFetched() ); + QVERIFY( !f.attribute( 0 ).isNull() ); + QVERIFY( !f.attribute( 1 ).isNull() ); + QVERIFY( !f.attribute( 2 ).isNull() ); cacheSubset.featureAtIdWithAllAttributes( 1, f ); QVERIFY( cacheSubset.isFidCached( 1 ) ); QVERIFY( cacheSubset.mCache[1]->allAttributesFetched() ); - QVERIFY( ! f.attribute( 0 ).isNull() ); - QVERIFY( ! f.attribute( 1 ).isNull() ); - QVERIFY( ! f.attribute( 2 ).isNull() ); + QVERIFY( !f.attribute( 0 ).isNull() ); + QVERIFY( !f.attribute( 1 ).isNull() ); + QVERIFY( !f.attribute( 2 ).isNull() ); // Test subset with request QgsVectorLayerCache cacheSubsetWithRequest( mPointsLayer, static_cast( mPointsLayer->dataProvider()->featureCount() ) ); - cacheSubsetWithRequest.setCacheSubsetOfAttributes( {1, 2} ); + cacheSubsetWithRequest.setCacheSubsetOfAttributes( { 1, 2 } ); QgsFeatureRequest req; req.setSubsetOfAttributes( { 2 } ); QgsFeatureIterator itSubsetWithRequest = cacheSubsetWithRequest.getFeatures( req ); itSubsetWithRequest.nextFeature( f ); QVERIFY( cacheSubset.isFidCached( 0 ) ); - QVERIFY( ! cacheSubsetWithRequest.mCache[f.id()]->allAttributesFetched() ); + QVERIFY( !cacheSubsetWithRequest.mCache[f.id()]->allAttributesFetched() ); QVERIFY( f.attribute( 0 ).isNull() ); - QVERIFY( ! f.attribute( 1 ).isNull() ); - QVERIFY( ! f.attribute( 2 ).isNull() ); - + QVERIFY( !f.attribute( 1 ).isNull() ); + QVERIFY( !f.attribute( 2 ).isNull() ); } void TestVectorLayerCache::onCommittedFeaturesAdded( const QString &layerId, const QgsFeatureList &features ) diff --git a/tests/src/core/testqgsvectorlayerjoinbuffer.cpp b/tests/src/core/testqgsvectorlayerjoinbuffer.cpp index 4bad15a8a59a..30e37c9a08a3 100644 --- a/tests/src/core/testqgsvectorlayerjoinbuffer.cpp +++ b/tests/src/core/testqgsvectorlayerjoinbuffer.cpp @@ -42,14 +42,14 @@ class TestVectorLayerJoinBuffer : public QObject public: TestVectorLayerJoinBuffer() - : mLayers( QMap, QgsVectorLayer*>() ) + : mLayers( QMap, QgsVectorLayer *>() ) {} private slots: - void initTestCase(); // will be called before the first testfunction is executed. - void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testJoinBasic_data(); void testJoinBasic(); @@ -214,11 +214,11 @@ void TestVectorLayerJoinBuffer::testJoinBasic_data() QTest::addColumn( "provider" ); QTest::addColumn( "memoryCache" ); - QTest::newRow( "memory with cache" ) << "memory" << true ; + QTest::newRow( "memory with cache" ) << "memory" << true; QTest::newRow( "memory without cache" ) << "memory" << false; #ifdef ENABLE_PGTEST - QTest::newRow( "postgresql with cache" ) << "PG" << true ; + QTest::newRow( "postgresql with cache" ) << "PG" << true; QTest::newRow( "postgresql without cache" ) << "PG" << false; #endif } @@ -268,7 +268,6 @@ void TestVectorLayerJoinBuffer::testJoinTransitive_data() void TestVectorLayerJoinBuffer::testJoinTransitive() { - QFETCH( QString, provider ); QgsVectorLayer *vlA = mLayers.value( QPair( QStringLiteral( "A" ), provider ) ); @@ -371,11 +370,11 @@ void TestVectorLayerJoinBuffer::testJoinSubset_data() QTest::addColumn( "provider" ); QTest::addColumn( "memoryCache" ); - QTest::newRow( "memory with cache" ) << "memory" << true ; + QTest::newRow( "memory with cache" ) << "memory" << true; QTest::newRow( "memory without cache" ) << "memory" << false; #ifdef ENABLE_PGTEST - QTest::newRow( "postgresql with cache" ) << "PG" << true ; + QTest::newRow( "postgresql with cache" ) << "PG" << true; QTest::newRow( "postgresql without cache" ) << "PG" << false; #endif } @@ -440,7 +439,6 @@ void TestVectorLayerJoinBuffer::testJoinTwoTimes_data() void TestVectorLayerJoinBuffer::testJoinTwoTimes() { - QFETCH( QString, provider ); QgsVectorLayer *vlA = mLayers.value( QPair( QStringLiteral( "A" ), provider ) ); @@ -807,10 +805,7 @@ void TestVectorLayerJoinBuffer::testChangeAttributeValues() QCOMPARE( joinFeature.attributes().at( 2 ).toString(), QString() ); // change a combination of provider and joined fields at once - QVERIFY( vlA->changeAttributeValues( 2, QgsAttributeMap{ { 1, QStringLiteral( "new_a_2_1" ) }, - { 2, QStringLiteral( "new_a_2_2" ) }, - { 3, QStringLiteral( "new_b_2_1" ) }, - { 4, QStringLiteral( "new_b_2_2" ) }} ) ); + QVERIFY( vlA->changeAttributeValues( 2, QgsAttributeMap { { 1, QStringLiteral( "new_a_2_1" ) }, { 2, QStringLiteral( "new_a_2_2" ) }, { 3, QStringLiteral( "new_b_2_1" ) }, { 4, QStringLiteral( "new_b_2_2" ) } } ) ); QCOMPARE( vlA->getFeature( 2 ).attributes().size(), 5 ); QCOMPARE( vlA->getFeature( 2 ).attributes().at( 0 ).toInt(), 2 ); @@ -820,8 +815,7 @@ void TestVectorLayerJoinBuffer::testChangeAttributeValues() QCOMPARE( vlA->getFeature( 2 ).attributes().at( 4 ).toString(), QStringLiteral( "new_b_2_2" ) ); // change only provider fields - QVERIFY( vlA->changeAttributeValues( 2, QgsAttributeMap{ { 1, QStringLiteral( "new_a_2_1b" ) }, - { 2, QStringLiteral( "new_a_2_2b" ) }} ) ); + QVERIFY( vlA->changeAttributeValues( 2, QgsAttributeMap { { 1, QStringLiteral( "new_a_2_1b" ) }, { 2, QStringLiteral( "new_a_2_2b" ) } } ) ); QCOMPARE( vlA->getFeature( 2 ).attributes().size(), 5 ); QCOMPARE( vlA->getFeature( 2 ).attributes().at( 0 ).toInt(), 2 ); @@ -831,8 +825,7 @@ void TestVectorLayerJoinBuffer::testChangeAttributeValues() QCOMPARE( vlA->getFeature( 2 ).attributes().at( 4 ).toString(), QStringLiteral( "new_b_2_2" ) ); // change only joined fields - QVERIFY( vlA->changeAttributeValues( 2, QgsAttributeMap{ { 3, QStringLiteral( "new_b_2_1b" ) }, - { 4, QStringLiteral( "new_b_2_2b" ) }} ) ); + QVERIFY( vlA->changeAttributeValues( 2, QgsAttributeMap { { 3, QStringLiteral( "new_b_2_1b" ) }, { 4, QStringLiteral( "new_b_2_2b" ) } } ) ); QCOMPARE( vlA->getFeature( 2 ).attributes().size(), 5 ); QCOMPARE( vlA->getFeature( 2 ).attributes().at( 0 ).toInt(), 2 ); @@ -840,7 +833,6 @@ void TestVectorLayerJoinBuffer::testChangeAttributeValues() QCOMPARE( vlA->getFeature( 2 ).attributes().at( 2 ).toString(), QStringLiteral( "new_a_2_2b" ) ); QCOMPARE( vlA->getFeature( 2 ).attributes().at( 3 ).toString(), QStringLiteral( "new_b_2_1b" ) ); QCOMPARE( vlA->getFeature( 2 ).attributes().at( 4 ).toString(), QStringLiteral( "new_b_2_2b" ) ); - } // Check https://github.com/qgis/QGIS/issues/26652 @@ -871,7 +863,7 @@ void TestVectorLayerJoinBuffer::testCollidingNameColumn() QgsFeatureIterator fi1 = vlA->getFeatures(); fi1.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QVERIFY( !fA1.attribute( "value_b" ).isValid() ); @@ -887,73 +879,73 @@ void TestVectorLayerJoinBuffer::testCollidingNameColumn() QgsFeatureIterator fi2 = vlA->getFeatures(); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_b" ).toString(), QStringLiteral( "value_b" ) ); QCOMPARE( fA1.attribute( "value_c" ).toString(), QStringLiteral( "value_c" ) ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 2} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 2 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_b" ).toString(), QStringLiteral( "value_b" ) ); QVERIFY( !fA1.attribute( "value_c" ).isValid() ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 3} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 3 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QVERIFY( !fA1.attribute( "value_b" ).isValid() ); QCOMPARE( fA1.attribute( "value_c" ).toString(), QStringLiteral( "value_c" ) ); vlA->removeJoin( vlB->id() ); - joinInfo.setJoinFieldNamesSubset( new QStringList( {"name"} ) ); + joinInfo.setJoinFieldNamesSubset( new QStringList( { "name" } ) ); vlA->addJoin( joinInfo ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 2} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 2 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); vlA->removeJoin( vlB->id() ); - joinInfo.setJoinFieldNamesSubset( new QStringList( {"value_b"} ) ); + joinInfo.setJoinFieldNamesSubset( new QStringList( { "value_b" } ) ); vlA->addJoin( joinInfo ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 2} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 2 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_b" ).toString(), QStringLiteral( "value_b" ) ); vlA->removeJoin( vlB->id() ); - joinInfo.setJoinFieldNamesSubset( new QStringList( {"value_c"} ) ); + joinInfo.setJoinFieldNamesSubset( new QStringList( { "value_c" } ) ); vlA->addJoin( joinInfo ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 2} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 2 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_c" ).toString(), QStringLiteral( "value_c" ) ); vlA->removeJoin( vlB->id() ); - joinInfo.setJoinFieldNamesSubset( new QStringList( {"name", "value_c"} ) ); + joinInfo.setJoinFieldNamesSubset( new QStringList( { "name", "value_c" } ) ); vlA->addJoin( joinInfo ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 2, 3} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 2, 3 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_c" ).toString(), QStringLiteral( "value_c" ) ); vlA->removeJoin( vlB->id() ); - joinInfo.setJoinFieldNamesSubset( new QStringList( {"value_b", "value_c"} ) ); + joinInfo.setJoinFieldNamesSubset( new QStringList( { "value_b", "value_c" } ) ); vlA->addJoin( joinInfo ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 2, 3} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 2, 3 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_b" ).toString(), QStringLiteral( "value_b" ) ); @@ -962,17 +954,17 @@ void TestVectorLayerJoinBuffer::testCollidingNameColumn() vlA->removeJoin( vlB->id() ); joinInfo.setJoinFieldNamesSubset( nullptr ); vlA->addJoin( joinInfo ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 2} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 2 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_b" ).toString(), QStringLiteral( "value_b" ) ); QVERIFY( !fA1.attribute( "value_c" ).isValid() ); - fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( {0, 1, 3} ) ) ); + fi2 = vlA->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList( { 0, 1, 3 } ) ) ); fi2.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QVERIFY( !fA1.attribute( "value_b" ).isValid() ); @@ -1015,7 +1007,7 @@ void TestVectorLayerJoinBuffer::testCollidingNameColumnCached() QgsFeatureIterator fi1 = vlA->getFeatures(); fi1.nextFeature( fA1 ); - QCOMPARE( fA1.fields().names(), QStringList( {"id_a", "name", "value_b", "value_c"} ) ); + QCOMPARE( fA1.fields().names(), QStringList( { "id_a", "name", "value_b", "value_c" } ) ); QCOMPARE( fA1.attribute( "id_a" ).toInt(), 1 ); QCOMPARE( fA1.attribute( "name" ).toString(), QStringLiteral( "name_a" ) ); QCOMPARE( fA1.attribute( "value_b" ).toString(), QStringLiteral( "value_b" ) ); diff --git a/tests/src/core/testqgsvectorlayerutils.cpp b/tests/src/core/testqgsvectorlayerutils.cpp index bf071ff1059d..d41e93e06d45 100644 --- a/tests/src/core/testqgsvectorlayerutils.cpp +++ b/tests/src/core/testqgsvectorlayerutils.cpp @@ -30,10 +30,10 @@ class TestQgsVectorLayerUtils : public QObject private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testGetFeatureSource(); }; @@ -43,7 +43,6 @@ void TestQgsVectorLayerUtils::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); - } void TestQgsVectorLayerUtils::cleanupTestCase() @@ -97,8 +96,7 @@ void TestQgsVectorLayerUtils::testGetFeatureSource() bool finished = false; QVariant result; - auto onResultReady = [&finished, &result]( const QVariant & res ) - { + auto onResultReady = [&finished, &result]( const QVariant &res ) { finished = true; result = res; }; diff --git a/tests/src/core/testqgsvectortileconnection.cpp b/tests/src/core/testqgsvectortileconnection.cpp index a8e20f0b4852..e539eb0be697 100644 --- a/tests/src/core/testqgsvectortileconnection.cpp +++ b/tests/src/core/testqgsvectortileconnection.cpp @@ -33,12 +33,11 @@ class TestQgsVectorTileConnection : public QObject TestQgsVectorTileConnection() = default; private: - private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void test_encodedUri(); }; diff --git a/tests/src/core/testqgsvectortilelayer.cpp b/tests/src/core/testqgsvectortilelayer.cpp index aa48369133f4..4a5f82f0b0db 100644 --- a/tests/src/core/testqgsvectortilelayer.cpp +++ b/tests/src/core/testqgsvectortilelayer.cpp @@ -46,7 +46,8 @@ class TestQgsVectorTileLayer : public QgsTest Q_OBJECT public: - TestQgsVectorTileLayer() : QgsTest( QStringLiteral( "Vector Tile Layer Tests" ), QStringLiteral( "vector_tile" ) ) {} + TestQgsVectorTileLayer() + : QgsTest( QStringLiteral( "Vector Tile Layer Tests" ), QStringLiteral( "vector_tile" ) ) {} private: QString mDataDir; @@ -54,8 +55,8 @@ class TestQgsVectorTileLayer : public QgsTest QgsMapSettings *mMapSettings = nullptr; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. void test_basic(); void test_render(); @@ -118,10 +119,11 @@ void TestQgsVectorTileLayer::initTestCase() QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer; rend->setStyles( QgsVectorTileBasicRenderer::simpleStyle( - polygonFillColor, polygonStrokeColor, polygonStrokeWidth, - lineStrokeColor, lineStrokeWidth, - pointFillColor, pointStrokeColor, pointSize ) ); - mLayer->setRenderer( rend ); // takes ownership + polygonFillColor, polygonStrokeColor, polygonStrokeWidth, + lineStrokeColor, lineStrokeWidth, + pointFillColor, pointStrokeColor, pointSize + ) ); + mLayer->setRenderer( rend ); // takes ownership } void TestQgsVectorTileLayer::cleanupTestCase() @@ -146,8 +148,7 @@ void TestQgsVectorTileLayer::test_render() { mMapSettings->setExtent( mLayer->extent() ); mMapSettings->setDestinationCrs( mLayer->crs() ); - QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_basic" ), - QStringLiteral( "render_test_basic" ), *mMapSettings, 0, 15 ); + QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_basic" ), QStringLiteral( "render_test_basic" ), *mMapSettings, 0, 15 ); } void TestQgsVectorTileLayer::test_render_withClip() @@ -161,9 +162,8 @@ void TestQgsVectorTileLayer::test_render_withClip() mMapSettings->setExtent( mLayer->extent() ); mMapSettings->setDestinationCrs( mLayer->crs() ); - const bool res = QGSRENDERMAPSETTINGSCHECK( QStringLiteral( "render_painterclip" ), - QStringLiteral( "render_painterclip" ), *mMapSettings, 0, 15 ); - mMapSettings->setClippingRegions( QList< QgsMapClippingRegion >() ); + const bool res = QGSRENDERMAPSETTINGSCHECK( QStringLiteral( "render_painterclip" ), QStringLiteral( "render_painterclip" ), *mMapSettings, 0, 15 ); + mMapSettings->setClippingRegions( QList() ); QVERIFY( res ); } @@ -200,20 +200,19 @@ void TestQgsVectorTileLayer::test_labeling() // use a different renderer to make the labels stand out more QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer; rend->setStyles( QgsVectorTileBasicRenderer::simpleStyle( - Qt::transparent, Qt::white, DEFAULT_LINE_WIDTH * 2, - Qt::transparent, 0, - Qt::transparent, Qt::transparent, 0 ) ); - mLayer->setRenderer( rend ); // takes ownership + Qt::transparent, Qt::white, DEFAULT_LINE_WIDTH * 2, + Qt::transparent, 0, + Qt::transparent, Qt::transparent, 0 + ) ); + mLayer->setRenderer( rend ); // takes ownership mMapSettings->setExtent( mLayer->extent() ); mMapSettings->setDestinationCrs( mLayer->crs() ); - const bool res1 = QGSRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_labeling" ), - QStringLiteral( "render_test_labeling" ), *mMapSettings, 0, 15 ); + const bool res1 = QGSRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_labeling" ), QStringLiteral( "render_test_labeling" ), *mMapSettings, 0, 15 ); // disable label rendering mLayer->setLabelsEnabled( false ); - const bool res2 = QGSRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_labeling_disabled" ), - QStringLiteral( "render_test_labeling_disabled" ), *mMapSettings, 0, 15 ); + const bool res2 = QGSRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_labeling_disabled" ), QStringLiteral( "render_test_labeling_disabled" ), *mMapSettings, 0, 15 ); mLayer->setRenderer( oldRenderer ); @@ -251,13 +250,13 @@ void TestQgsVectorTileLayer::testMbtilesProviderMetadata() // mbtile uris QCOMPARE( vectorTileMetadata->priorityForUri( QStringLiteral( "%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ), 100 ); - QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( "%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ), {Qgis::LayerType::VectorTile} ); + QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( "%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ), { Qgis::LayerType::VectorTile } ); QCOMPARE( vectorTileMetadata->priorityForUri( QStringLiteral( "type=mbtiles&url=%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ), 100 ); - QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( "type=mbtiles&url=%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ), {Qgis::LayerType::VectorTile} ); + QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( "type=mbtiles&url=%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ), { Qgis::LayerType::VectorTile } ); // query sublayers - QList< QgsProviderSublayerDetails > sublayers = vectorTileMetadata->querySublayers( QStringLiteral( "%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ); + QList sublayers = vectorTileMetadata->querySublayers( QStringLiteral( "%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ); QCOMPARE( sublayers.size(), 1 ); QCOMPARE( sublayers.at( 0 ).providerKey(), QStringLiteral( "mbtilesvectortiles" ) ); QCOMPARE( sublayers.at( 0 ).name(), QStringLiteral( "mbtiles_vt" ) ); @@ -308,14 +307,14 @@ void TestQgsVectorTileLayer::testMbtilesProviderMetadata() int vtProviderIndex = candidates.at( 0 ).metadata()->key() == QLatin1String( "mbtilesvectortiles" ) ? 0 : 1; QCOMPARE( candidates.size(), 2 ); QCOMPARE( candidates.at( vtProviderIndex ).metadata()->key(), QStringLiteral( "mbtilesvectortiles" ) ); - QCOMPARE( candidates.at( vtProviderIndex ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::VectorTile ); + QCOMPARE( candidates.at( vtProviderIndex ).layerTypes(), QList() << Qgis::LayerType::VectorTile ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ) ); // wms provider also reports handling this url QCOMPARE( candidates.size(), 2 ); vtProviderIndex = candidates.at( 0 ).metadata()->key() == QLatin1String( "mbtilesvectortiles" ) ? 0 : 1; QCOMPARE( candidates.at( vtProviderIndex ).metadata()->key(), QStringLiteral( "mbtilesvectortiles" ) ); - QCOMPARE( candidates.at( vtProviderIndex ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::VectorTile ); + QCOMPARE( candidates.at( vtProviderIndex ).layerTypes(), QList() << Qgis::LayerType::VectorTile ); QCOMPARE( vectorTileMetadata->filters( Qgis::FileFilterType::VectorTile ), QStringLiteral( "Mbtiles Vector Tiles (*.mbtiles *.MBTILES)" ) ); QCOMPARE( vectorTileMetadata->filters( Qgis::FileFilterType::PointCloud ), QString() ); @@ -332,7 +331,7 @@ void TestQgsVectorTileLayer::test_relativePathsMbTiles() const QString srcMbtiles = QStringLiteral( "type=mbtiles&url=%1/vector_tile/mbtiles_vt.mbtiles" ).arg( TEST_DATA_DIR ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( srcMbtiles ); + std::unique_ptr layer = std::make_unique( srcMbtiles ); QVERIFY( layer->isValid() ); QCOMPARE( layer->providerType(), QStringLiteral( "mbtilesvectortiles" ) ); @@ -381,7 +380,7 @@ void TestQgsVectorTileLayer::test_relativePathsXyz() const QString srcXyzLocal = "type=xyz&url=file:///home/qgis/%7Bz%7D/%7Bx%7D/%7By%7D.pbf"; const QString srcXyzRemote = "type=xyz&url=http://www.example.com/%7Bz%7D/%7Bx%7D/%7By%7D.pbf"; - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( srcXyzLocal ); + std::unique_ptr layer = std::make_unique( srcXyzLocal ); QCOMPARE( layer->providerType(), QStringLiteral( "xyzvectortiles" ) ); // encode source: converting absolute paths to relative @@ -445,8 +444,8 @@ void TestQgsVectorTileLayer::testVtpkProviderMetadata() // vtpk uris QCOMPARE( vectorTileMetadata->priorityForUri( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/testvtpk.vtpk" ) ), 100 ); - QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/testvtpk.vtpk" ) ), {Qgis::LayerType::VectorTile} ); - QList< QgsProviderSublayerDetails > sublayers = vectorTileMetadata->querySublayers( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/testvtpk.vtpk" ) ); + QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/testvtpk.vtpk" ) ), { Qgis::LayerType::VectorTile } ); + QList sublayers = vectorTileMetadata->querySublayers( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/testvtpk.vtpk" ) ); QCOMPARE( sublayers.size(), 1 ); QCOMPARE( sublayers.at( 0 ).providerKey(), QStringLiteral( "vtpkvectortiles" ) ); QCOMPARE( sublayers.at( 0 ).name(), QStringLiteral( "testvtpk" ) ); @@ -454,7 +453,7 @@ void TestQgsVectorTileLayer::testVtpkProviderMetadata() QCOMPARE( sublayers.at( 0 ).type(), Qgis::LayerType::VectorTile ); QCOMPARE( vectorTileMetadata->priorityForUri( QStringLiteral( "type=vtpk&url=%1/testvtpk.vtpk" ).arg( TEST_DATA_DIR ) ), 100 ); - QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( "type=vtpk&url=%1/testvtpk.vtpk" ).arg( TEST_DATA_DIR ) ), {Qgis::LayerType::VectorTile} ); + QCOMPARE( vectorTileMetadata->validLayerTypesForUri( QStringLiteral( "type=vtpk&url=%1/testvtpk.vtpk" ).arg( TEST_DATA_DIR ) ), { Qgis::LayerType::VectorTile } ); sublayers = vectorTileMetadata->querySublayers( QStringLiteral( "type=vtpk&url=%1/testvtpk.vtpk" ).arg( TEST_DATA_DIR ) ); QCOMPARE( sublayers.size(), 1 ); QCOMPARE( sublayers.at( 0 ).providerKey(), QStringLiteral( "vtpkvectortiles" ) ); @@ -466,12 +465,12 @@ void TestQgsVectorTileLayer::testVtpkProviderMetadata() QList candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "type=vtpk&url=%1/testvtpk.vtpk" ).arg( TEST_DATA_DIR ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "vtpkvectortiles" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::VectorTile ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::VectorTile ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/testvtpk.vtpk" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "vtpkvectortiles" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::VectorTile ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::VectorTile ); QCOMPARE( vectorTileMetadata->filters( Qgis::FileFilterType::VectorTile ), QStringLiteral( "VTPK Vector Tiles (*.vtpk *.VTPK)" ) ); QCOMPARE( vectorTileMetadata->filters( Qgis::FileFilterType::PointCloud ), QString() ); @@ -488,7 +487,7 @@ void TestQgsVectorTileLayer::test_relativePathsVtpk() const QString srcVtpk = QStringLiteral( "type=vtpk&url=%1/testvtpk.vtpk" ).arg( TEST_DATA_DIR ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( srcVtpk ); + std::unique_ptr layer = std::make_unique( srcVtpk ); QVERIFY( layer->isValid() ); QCOMPARE( layer->providerType(), QStringLiteral( "vtpkvectortiles" ) ); @@ -535,7 +534,7 @@ void TestQgsVectorTileLayer::test_polygonWithLineStyle() ds.setParam( "type", "xyz" ); ds.setParam( "url", QString( "file://%1/{z}-{x}-{y}.pbf" ).arg( mDataDir ) ); ds.setParam( "zmax", "1" ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( ds.encodedUri(), "Vector Tiles Test" ); + std::unique_ptr layer = std::make_unique( ds.encodedUri(), "Vector Tiles Test" ); QVERIFY( layer->isValid() ); mMapSettings->setLayers( QList() << layer.get() ); @@ -561,12 +560,11 @@ void TestQgsVectorTileLayer::test_polygonWithLineStyle() QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer; rend->setStyles( QList() << bgst << st ); - layer->setRenderer( rend ); // takes ownership + layer->setRenderer( rend ); // takes ownership mMapSettings->setExtent( layer->extent() ); mMapSettings->setDestinationCrs( layer->crs() ); - QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_polygon_with_line_style" ), - QStringLiteral( "render_test_polygon_with_line_style" ), *mMapSettings, 0, 15 ); + QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_polygon_with_line_style" ), QStringLiteral( "render_test_polygon_with_line_style" ), *mMapSettings, 0, 15 ); } void TestQgsVectorTileLayer::test_polygonWithMarker() @@ -576,7 +574,7 @@ void TestQgsVectorTileLayer::test_polygonWithMarker() ds.setParam( "type", "xyz" ); ds.setParam( "url", QString( "file://%1/{z}-{x}-{y}.pbf" ).arg( mDataDir ) ); ds.setParam( "zmax", "1" ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( ds.encodedUri(), "Vector Tiles Test" ); + std::unique_ptr layer = std::make_unique( ds.encodedUri(), "Vector Tiles Test" ); QVERIFY( layer->isValid() ); mMapSettings->setLayers( QList() << layer.get() ); @@ -600,12 +598,11 @@ void TestQgsVectorTileLayer::test_polygonWithMarker() QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer; rend->setStyles( QList() << bgst << st ); - layer->setRenderer( rend ); // takes ownership + layer->setRenderer( rend ); // takes ownership mMapSettings->setExtent( layer->extent() ); mMapSettings->setDestinationCrs( layer->crs() ); - QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_polygon_with_marker" ), - QStringLiteral( "render_test_polygon_with_marker" ), *mMapSettings, 0, 15 ); + QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_polygon_with_marker" ), QStringLiteral( "render_test_polygon_with_marker" ), *mMapSettings, 0, 15 ); } void TestQgsVectorTileLayer::test_styleMinZoomBeyondTileMaxZoom() @@ -615,7 +612,7 @@ void TestQgsVectorTileLayer::test_styleMinZoomBeyondTileMaxZoom() ds.setParam( "type", "xyz" ); ds.setParam( "url", QString( "file://%1/{z}-{x}-{y}.pbf" ).arg( mDataDir ) ); ds.setParam( "zmax", "1" ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( ds.encodedUri(), "Vector Tiles Test" ); + std::unique_ptr layer = std::make_unique( ds.encodedUri(), "Vector Tiles Test" ); QVERIFY( layer->isValid() ); mMapSettings->setLayers( QList() << layer.get() ); @@ -642,12 +639,11 @@ void TestQgsVectorTileLayer::test_styleMinZoomBeyondTileMaxZoom() QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer; rend->setStyles( QList() << bgst << st ); - layer->setRenderer( rend ); // takes ownership + layer->setRenderer( rend ); // takes ownership mMapSettings->setExtent( QgsRectangle( -1180017, 4261973, 155871, 5474783 ) ); mMapSettings->setDestinationCrs( layer->crs() ); - QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_style_min_zoom" ), - QStringLiteral( "render_test_style_min_zoom" ), *mMapSettings, 0, 15 ); + QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_style_min_zoom" ), QStringLiteral( "render_test_style_min_zoom" ), *mMapSettings, 0, 15 ); } void TestQgsVectorTileLayer::test_filterRuleAllLayers() @@ -656,7 +652,7 @@ void TestQgsVectorTileLayer::test_filterRuleAllLayers() QgsDataSourceUri ds; ds.setParam( "type", "mbtiles" ); ds.setParam( "url", QString( "/%1/mbtiles_vt.mbtiles" ).arg( mDataDir ) ); - std::unique_ptr< QgsVectorTileLayer > layer = std::make_unique< QgsVectorTileLayer >( ds.encodedUri(), "Vector Tiles Test" ); + std::unique_ptr layer = std::make_unique( ds.encodedUri(), "Vector Tiles Test" ); QVERIFY( layer->isValid() ); mMapSettings->setLayers( QList() << layer.get() ); @@ -683,12 +679,11 @@ void TestQgsVectorTileLayer::test_filterRuleAllLayers() QgsVectorTileBasicRenderer *rend = new QgsVectorTileBasicRenderer; rend->setStyles( QList() << bgst << st ); - layer->setRenderer( rend ); // takes ownership + layer->setRenderer( rend ); // takes ownership mMapSettings->setExtent( layer->extent() ); mMapSettings->setDestinationCrs( layer->crs() ); - QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_filter_all_layers" ), - QStringLiteral( "render_test_filter_all_layers" ), *mMapSettings, 0, 15 ); + QGSVERIFYRENDERMAPSETTINGSCHECK( QStringLiteral( "render_test_filter_all_layers" ), QStringLiteral( "render_test_filter_all_layers" ), *mMapSettings, 0, 15 ); } diff --git a/tests/src/core/testqgsvectortileutils.cpp b/tests/src/core/testqgsvectortileutils.cpp index 9640dfd6a3ba..de579c863d0a 100644 --- a/tests/src/core/testqgsvectortileutils.cpp +++ b/tests/src/core/testqgsvectortileutils.cpp @@ -34,12 +34,11 @@ class TestQgsVectorTileUtils : public QObject TestQgsVectorTileUtils() = default; private: - private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void test_scaleToZoomLevel(); void test_urlsFromStyle(); @@ -73,7 +72,7 @@ void TestQgsVectorTileUtils::test_urlsFromStyle() QString style1Content = style1File.readAll(); style1File.close(); style1Content.replace( QString( "_TILE_SOURCE_TEST_PATH_" ), "file://" + dataDir + "/vector_tile/styles" ); - QFile fixedStyleFilePath( QDir::tempPath() + QStringLiteral( "/style1.json" ) ); + QFile fixedStyleFilePath( QDir::tempPath() + QStringLiteral( "/style1.json" ) ); if ( fixedStyleFilePath.open( QFile::WriteOnly | QFile::Truncate ) ) { QTextStream out( &fixedStyleFilePath ); diff --git a/tests/src/core/testqgsvectortilewriter.cpp b/tests/src/core/testqgsvectortilewriter.cpp index 54a9115f9ef2..04a06c636956 100644 --- a/tests/src/core/testqgsvectortilewriter.cpp +++ b/tests/src/core/testqgsvectortilewriter.cpp @@ -46,10 +46,10 @@ class TestQgsVectorTileWriter : public QObject QString mDataDir; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void test_basic(); void test_mbtiles(); @@ -78,7 +78,7 @@ void TestQgsVectorTileWriter::cleanupTestCase() void TestQgsVectorTileWriter::test_basic() { QTemporaryDir dir; - dir.setAutoRemove( false ); // so that we can inspect the results later + dir.setAutoRemove( false ); // so that we can inspect the results later const QString tmpDir = dir.path(); QgsDataSourceUri ds; @@ -110,7 +110,7 @@ void TestQgsVectorTileWriter::test_basic() // check on the file level const QDir dirInfo( tmpDir ); const QStringList dirFiles = dirInfo.entryList( QStringList( "*.pbf" ) ); - QCOMPARE( dirFiles.count(), 8 ); // 1 tile at z0, 1 tile at z1, 2 tiles at z2, 4 tiles at z3 + QCOMPARE( dirFiles.count(), 8 ); // 1 tile at z0, 1 tile at z1, 2 tiles at z2, 4 tiles at z3 QVERIFY( dirFiles.contains( "0-0-0.pbf" ) ); QgsVectorTileLayer *vtLayer = new QgsVectorTileLayer( ds.encodedUri(), "output" ); @@ -137,7 +137,7 @@ void TestQgsVectorTileWriter::test_basic() QCOMPARE( features0["points"][0].geometry().wkbType(), Qgis::WkbType::Point ); QCOMPARE( features0["lines"][0].geometry().wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons + QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons QgsAttributes attrsPolys0_0 = features0["polys"][0].attributes(); QCOMPARE( attrsPolys0_0.count(), 1 ); @@ -206,7 +206,7 @@ void TestQgsVectorTileWriter::test_mbtiles() QCOMPARE( features0["points"][0].geometry().wkbType(), Qgis::WkbType::Point ); QCOMPARE( features0["lines"][0].geometry().wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons + QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons QgsAttributes attrsPolys0_0 = features0["polys"][0].attributes(); QCOMPARE( attrsPolys0_0.count(), 1 ); @@ -252,7 +252,7 @@ void TestQgsVectorTileWriter::test_mbtiles_metadata() QVERIFY( reader.open() ); QCOMPARE( reader.metadataValue( "name" ), QStringLiteral( "QGIS rocks!" ) ); QCOMPARE( reader.metadataValue( "attribution" ), QStringLiteral( "QGIS sample data" ) ); - QCOMPARE( reader.metadataValue( "description" ), QString() ); // was not specified + QCOMPARE( reader.metadataValue( "description" ), QString() ); // was not specified QCOMPARE( reader.metadataValue( "minzoom" ).toInt(), 0 ); QCOMPARE( reader.metadataValue( "maxzoom" ).toInt(), 1 ); } @@ -322,7 +322,7 @@ void TestQgsVectorTileWriter::test_filtering() void TestQgsVectorTileWriter::test_z0TileMatrix3857() { QTemporaryDir dir; - dir.setAutoRemove( false ); // so that we can inspect the results later + dir.setAutoRemove( false ); // so that we can inspect the results later const QString tmpDir = dir.path(); QgsDataSourceUri ds; @@ -358,7 +358,7 @@ void TestQgsVectorTileWriter::test_z0TileMatrix3857() // check on the file level const QDir dirInfo( tmpDir ); const QStringList dirFiles = dirInfo.entryList( QStringList( "*.pbf" ) ); - QCOMPARE( dirFiles.count(), 8 ); // 1 tile at z0, 1 tile at z1, 2 tiles at z2, 4 tiles at z3 + QCOMPARE( dirFiles.count(), 8 ); // 1 tile at z0, 1 tile at z1, 2 tiles at z2, 4 tiles at z3 QVERIFY( dirFiles.contains( "custom3857-0-0-0.pbf" ) ); QgsVectorTileLayer *vtLayer = new QgsVectorTileLayer( ds.encodedUri(), "output" ); @@ -385,7 +385,7 @@ void TestQgsVectorTileWriter::test_z0TileMatrix3857() QCOMPARE( features0["points"][0].geometry().wkbType(), Qgis::WkbType::Point ); QCOMPARE( features0["lines"][0].geometry().wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons + QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons QgsAttributes attrsPolys0_0 = features0["polys"][0].attributes(); QCOMPARE( attrsPolys0_0.count(), 1 ); @@ -399,7 +399,7 @@ void TestQgsVectorTileWriter::test_z0TileMatrix3857() void TestQgsVectorTileWriter::test_z0TileMatrix2154() { QTemporaryDir dir; - dir.setAutoRemove( false ); // so that we can inspect the results later + dir.setAutoRemove( false ); // so that we can inspect the results later const QString tmpDir = dir.path(); QgsDataSourceUri ds; @@ -444,7 +444,7 @@ void TestQgsVectorTileWriter::test_z0TileMatrix2154() // check on the file level const QDir dirInfo( tmpDir ); const QStringList dirFiles = dirInfo.entryList( QStringList( "*.pbf" ) ); - QCOMPARE( dirFiles.count(), 8 ); // 1 tile at z0, 1 tile at z1, 2 tiles at z2, 4 tiles at z3 + QCOMPARE( dirFiles.count(), 8 ); // 1 tile at z0, 1 tile at z1, 2 tiles at z2, 4 tiles at z3 QVERIFY( dirFiles.contains( "custom2154-0-0-0.pbf" ) ); QgsVectorTileLayer *vtLayer = new QgsVectorTileLayer( ds.encodedUri(), "output" ); @@ -471,7 +471,7 @@ void TestQgsVectorTileWriter::test_z0TileMatrix2154() QCOMPARE( features0["points"][0].geometry().wkbType(), Qgis::WkbType::Point ); QCOMPARE( features0["lines"][0].geometry().wkbType(), Qgis::WkbType::LineString ); - QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons + QCOMPARE( features0["polys"][0].geometry().wkbType(), Qgis::WkbType::MultiPolygon ); // source geoms in shp are multipolygons QgsAttributes attrsPolys0_0 = features0["polys"][0].attributes(); QCOMPARE( attrsPolys0_0.count(), 1 ); diff --git a/tests/src/core/testqgsweakrelation.cpp b/tests/src/core/testqgsweakrelation.cpp index a2ffab3a534a..3c14a8191b8f 100644 --- a/tests/src/core/testqgsweakrelation.cpp +++ b/tests/src/core/testqgsweakrelation.cpp @@ -21,15 +21,15 @@ #include "qgsrelation.h" #include "qgsrelationmanager.h" -class TestQgsWeakRelation: public QObject +class TestQgsWeakRelation : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testSetters(); @@ -91,31 +91,20 @@ void TestQgsWeakRelation::testSetters() void TestQgsWeakRelation::testResolved() { - QgsWeakRelation weakRel( QStringLiteral( "my_relation_id" ), - QStringLiteral( "my_relation_name" ), - Qgis::RelationshipStrength::Association, - QStringLiteral( "referencingLayerId" ), - QStringLiteral( "referencingLayerName" ), - QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), - QStringLiteral( "memory" ), - QStringLiteral( "referencedLayerId" ), - QStringLiteral( "referencedLayerName" ), - QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), - QStringLiteral( "memory" ) - ); + QgsWeakRelation weakRel( QStringLiteral( "my_relation_id" ), QStringLiteral( "my_relation_name" ), Qgis::RelationshipStrength::Association, QStringLiteral( "referencingLayerId" ), QStringLiteral( "referencingLayerName" ), QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), QStringLiteral( "memory" ), QStringLiteral( "referencedLayerId" ), QStringLiteral( "referencedLayerName" ), QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), QStringLiteral( "memory" ) ); weakRel.setReferencingLayerFields( { "fk_province" } ); weakRel.setReferencedLayerFields( { "pk" } ); - QList< QgsRelation > res = weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ); + QList res = weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ); QCOMPARE( res.size(), 1 ); - QVERIFY( ! res.at( 0 ).isValid() ); + QVERIFY( !res.at( 0 ).isValid() ); // create a vector layer QgsVectorLayer referencedLayer( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), QStringLiteral( "referencedLayerName" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( &referencedLayer, false, false ); res = weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ); QCOMPARE( res.size(), 1 ); - QVERIFY( ! res.at( 0 ).isValid() ); + QVERIFY( !res.at( 0 ).isValid() ); QgsVectorLayer referencingLayer( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), QStringLiteral( "referencingLayerName" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( &referencingLayer, false, false ); @@ -147,18 +136,7 @@ void TestQgsWeakRelation::testResolved() void TestQgsWeakRelation::testResolvedManyToMany() { - QgsWeakRelation weakRel( QStringLiteral( "my_relation_id" ), - QStringLiteral( "my_relation_name" ), - Qgis::RelationshipStrength::Association, - QStringLiteral( "referencingLayerId" ), - QStringLiteral( "referencingLayerName" ), - QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), - QStringLiteral( "memory" ), - QStringLiteral( "referencedLayerId" ), - QStringLiteral( "referencedLayerName" ), - QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), - QStringLiteral( "memory" ) - ); + QgsWeakRelation weakRel( QStringLiteral( "my_relation_id" ), QStringLiteral( "my_relation_name" ), Qgis::RelationshipStrength::Association, QStringLiteral( "referencingLayerId" ), QStringLiteral( "referencingLayerName" ), QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), QStringLiteral( "memory" ), QStringLiteral( "referencedLayerId" ), QStringLiteral( "referencedLayerName" ), QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), QStringLiteral( "memory" ) ); weakRel.setCardinality( Qgis::RelationshipCardinality::ManyToMany ); weakRel.setMappingTable( QgsVectorLayerRef( QStringLiteral( "mappingTableId" ), QStringLiteral( "mappingTableName" ), QStringLiteral( "None?field=origin_key:int&field=destination_key:int" ), QStringLiteral( "memory" ) ) ); @@ -167,25 +145,25 @@ void TestQgsWeakRelation::testResolvedManyToMany() weakRel.setReferencedLayerFields( { "pk" } ); weakRel.setMappingReferencedLayerFields( { "origin_key" } ); - QList< QgsRelation > res = weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ); + QList res = weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ); QCOMPARE( res.size(), 2 ); - QVERIFY( ! res.at( 0 ).isValid() ); - QVERIFY( ! res.at( 1 ).isValid() ); + QVERIFY( !res.at( 0 ).isValid() ); + QVERIFY( !res.at( 1 ).isValid() ); // create a vector layer QgsVectorLayer referencedLayer( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), QStringLiteral( "referencedLayerName" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( &referencedLayer, false, false ); res = weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ); QCOMPARE( res.size(), 2 ); - QVERIFY( ! res.at( 0 ).isValid() ); - QVERIFY( ! res.at( 1 ).isValid() ); + QVERIFY( !res.at( 0 ).isValid() ); + QVERIFY( !res.at( 1 ).isValid() ); QgsVectorLayer referencingLayer( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), QStringLiteral( "referencingLayerName" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( &referencingLayer, false, false ); res = weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ); QCOMPARE( res.size(), 2 ); - QVERIFY( ! res.at( 0 ).isValid() ); - QVERIFY( ! res.at( 1 ).isValid() ); + QVERIFY( !res.at( 0 ).isValid() ); + QVERIFY( !res.at( 1 ).isValid() ); QgsVectorLayer mappingTable( QStringLiteral( "None?field=origin_key:int&field=destination_key:int" ), QStringLiteral( "mappingTableName" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( &mappingTable, false, false ); @@ -196,13 +174,13 @@ void TestQgsWeakRelation::testResolvedManyToMany() QCOMPARE( res.at( 0 ).referencedLayerId(), referencedLayer.id() ); QCOMPARE( res.at( 0 ).referencingLayerId(), mappingTable.id() ); - QCOMPARE( res.at( 0 ).referencingFields(), {0} ); - QCOMPARE( res.at( 0 ).referencedFields(), {0} ); + QCOMPARE( res.at( 0 ).referencingFields(), { 0 } ); + QCOMPARE( res.at( 0 ).referencedFields(), { 0 } ); QCOMPARE( res.at( 1 ).referencedLayerId(), referencingLayer.id() ); QCOMPARE( res.at( 1 ).referencingLayerId(), mappingTable.id() ); - QCOMPARE( res.at( 1 ).referencingFields(), {1} ); - QCOMPARE( res.at( 1 ).referencedFields(), {1} ); + QCOMPARE( res.at( 1 ).referencingFields(), { 1 } ); + QCOMPARE( res.at( 1 ).referencedFields(), { 1 } ); res = weakRel.resolvedRelations( QgsProject::instance(), static_cast( QgsVectorLayerRef::MatchType::Name | QgsVectorLayerRef::MatchType::Provider ) ); QCOMPARE( res.size(), 2 ); @@ -233,20 +211,9 @@ void TestQgsWeakRelation::testResolvedManyToMany() void TestQgsWeakRelation::testReadWrite() { - QgsWeakRelation weakRel( QStringLiteral( "my_relation_id" ), - QStringLiteral( "my_relation_name" ), - Qgis::RelationshipStrength::Association, - QStringLiteral( "referencingLayerId" ), - QStringLiteral( "referencingLayerName" ), - QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), - QStringLiteral( "memory" ), - QStringLiteral( "referencedLayerId" ), - QStringLiteral( "referencedLayerName" ), - QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), - QStringLiteral( "memory" ) - ); - weakRel.setReferencingLayerFields( {"fk_province" } ); - weakRel.setReferencedLayerFields( {"pk" } ); + QgsWeakRelation weakRel( QStringLiteral( "my_relation_id" ), QStringLiteral( "my_relation_name" ), Qgis::RelationshipStrength::Association, QStringLiteral( "referencingLayerId" ), QStringLiteral( "referencingLayerName" ), QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), QStringLiteral( "memory" ), QStringLiteral( "referencedLayerId" ), QStringLiteral( "referencedLayerName" ), QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), QStringLiteral( "memory" ) ); + weakRel.setReferencingLayerFields( { "fk_province" } ); + weakRel.setReferencedLayerFields( { "pk" } ); QgsVectorLayer referencedLayer( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int&field=province:int&field=municipality:string" ), QStringLiteral( "referencedLayerName" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( &referencedLayer, false, false ); @@ -254,31 +221,31 @@ void TestQgsWeakRelation::testReadWrite() QgsVectorLayer referencingLayer( QStringLiteral( "Point?crs=epsg:4326&field=pk:int&field=fk_province:int&field=fk_municipality:int" ), QStringLiteral( "referencingLayerName" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( &referencingLayer, false, false ); - const QList< QgsRelation > relations( weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ) ); + const QList relations( weakRel.resolvedRelations( QgsProject::instance(), QgsVectorLayerRef::MatchType::Name ) ); QCOMPARE( relations.size(), 1 ); QVERIFY( relations.at( 0 ).isValid() ); QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); // Check the XML is written for the referenced layer QDomElement node = doc.createElement( QStringLiteral( "relation" ) ); QgsWeakRelation::writeXml( &referencedLayer, QgsWeakRelation::Referenced, relations.at( 0 ), node, doc ); - const QgsWeakRelation weakRelReferenced( QgsWeakRelation::readXml( &referencedLayer, QgsWeakRelation::Referenced, node, QgsProject::instance()->pathResolver() ) ); - QCOMPARE( weakRelReferenced.referencingLayerFields(), {"fk_province" } ); - QCOMPARE( weakRelReferenced.referencedLayerFields(), {"pk" } ); + const QgsWeakRelation weakRelReferenced( QgsWeakRelation::readXml( &referencedLayer, QgsWeakRelation::Referenced, node, QgsProject::instance()->pathResolver() ) ); + QCOMPARE( weakRelReferenced.referencingLayerFields(), { "fk_province" } ); + QCOMPARE( weakRelReferenced.referencedLayerFields(), { "pk" } ); QCOMPARE( weakRelReferenced.strength(), Qgis::RelationshipStrength::Association ); QCOMPARE( weakRelReferenced.referencedLayer().resolve( QgsProject::instance() ), &referencedLayer ); // Check the XML is written for the referencing layer node = doc.createElement( QStringLiteral( "relation" ) ); QgsWeakRelation::writeXml( &referencingLayer, QgsWeakRelation::Referencing, relations.at( 0 ), node, doc ); - const QgsWeakRelation weakRelReferencing( QgsWeakRelation::readXml( &referencingLayer, QgsWeakRelation::Referencing, node, QgsProject::instance()->pathResolver() ) ); - QCOMPARE( weakRelReferencing.referencingLayerFields(), {"fk_province" } ); - QCOMPARE( weakRelReferencing.referencedLayerFields(), {"pk" } ); + const QgsWeakRelation weakRelReferencing( QgsWeakRelation::readXml( &referencingLayer, QgsWeakRelation::Referencing, node, QgsProject::instance()->pathResolver() ) ); + QCOMPARE( weakRelReferencing.referencingLayerFields(), { "fk_province" } ); + QCOMPARE( weakRelReferencing.referencedLayerFields(), { "pk" } ); QCOMPARE( weakRelReferencing.strength(), Qgis::RelationshipStrength::Association ); QCOMPARE( weakRelReferencing.referencingLayer().resolve( QgsProject::instance() ), &referencingLayer ); } @@ -317,9 +284,9 @@ void TestQgsWeakRelation::testWriteStyleCategoryRelations() // Write to XML QDomImplementation DomImplementation; - const QDomDocumentType documentType = - DomImplementation.createDocumentType( - QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) ); + const QDomDocumentType documentType = DomImplementation.createDocumentType( + QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ), QStringLiteral( "SYSTEM" ) + ); QDomDocument doc( documentType ); QDomElement node = doc.createElement( QStringLiteral( "style_categories_relations" ) ); QString errorMessage; @@ -344,10 +311,10 @@ void TestQgsWeakRelation::testWriteStyleCategoryRelations() Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "name" ) ) ); Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "referencingLayer" ) ) ); Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "referencedLayer" ) ) ); - Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "layerId" ) ) ); // Weak relation attribute - Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "layerName" ) ) ); // Weak relation attribute + Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "layerId" ) ) ); // Weak relation attribute + Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "layerName" ) ) ); // Weak relation attribute Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "dataSource" ) ) ); // Weak relation attribute - Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "providerKey" ) ) ); // Weak relation attribute + Q_ASSERT( relationElement.hasAttribute( QStringLiteral( "providerKey" ) ) ); // Weak relation attribute QCOMPARE( relationElement.attribute( QStringLiteral( "providerKey" ) ), QStringLiteral( "memory" ) ); QCOMPARE( relationElement.attribute( QStringLiteral( "referencingLayer" ) ), layer1->id() ); diff --git a/tests/src/core/testqgsziputils.cpp b/tests/src/core/testqgsziputils.cpp index 84946e22ab1a..0b1860f4a609 100644 --- a/tests/src/core/testqgsziputils.cpp +++ b/tests/src/core/testqgsziputils.cpp @@ -21,15 +21,15 @@ #include "qgsziputils.h" #include "qgsapplication.h" -class TestQgsZipUtils: public QObject +class TestQgsZipUtils : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void unzipWithSubdirs(); void unzipWithSubdirs2(); @@ -53,12 +53,10 @@ void TestQgsZipUtils::cleanupTestCase() void TestQgsZipUtils::init() { - } void TestQgsZipUtils::cleanup() { - } void TestQgsZipUtils::unzipWithSubdirs() @@ -146,11 +144,11 @@ void TestQgsZipUtils::genericTest( QString zipName, int expectedEntries, bool in if ( includeFolders ) { - dir.setFilter( QDir::Files | QDir::NoDotAndDotDot | QDir::Dirs ); + dir.setFilter( QDir::Files | QDir::NoDotAndDotDot | QDir::Dirs ); } else { - dir.setFilter( QDir::Files | QDir::NoDotAndDotDot ); + dir.setFilter( QDir::Files | QDir::NoDotAndDotDot ); } // Get list of entries from the root folder QDirIterator it( dir, QDirIterator::Subdirectories ); diff --git a/tests/src/core/testqobjectparentuniqueptr.cpp b/tests/src/core/testqobjectparentuniqueptr.cpp index 416cf8eebbac..bb72929a4470 100644 --- a/tests/src/core/testqobjectparentuniqueptr.cpp +++ b/tests/src/core/testqobjectparentuniqueptr.cpp @@ -24,7 +24,6 @@ class TestQObjectOwner : public QObject { Q_OBJECT public: - ~TestQObjectOwner() override; void setChild( TestQObjectChild *child ) @@ -33,15 +32,12 @@ class TestQObjectOwner : public QObject } private: - TestQObjectChild *mChild = nullptr; - }; class TestQObjectChild { public: - TestQObjectChild( TestQObjectOwner *parent ) : mParent( parent ) { @@ -63,10 +59,8 @@ class TestQObjectChild int value() const { return mValue; } private: - TestQObjectOwner *mParent = nullptr; int mValue = 0; - }; @@ -171,6 +165,5 @@ void TestQObjectParentUniquePtr::testDeleteLater() } - QGSTEST_MAIN( TestQObjectParentUniquePtr ) #include "testqobjectparentuniqueptr.moc" diff --git a/tests/src/core/testziplayer.cpp b/tests/src/core/testziplayer.cpp index ec381d604449..b1ed99d20c48 100644 --- a/tests/src/core/testziplayer.cpp +++ b/tests/src/core/testziplayer.cpp @@ -39,12 +39,11 @@ * \ingroup UnitTests * This is a unit test to verify that zip vector layers work */ -class TestZipLayer: public QObject +class TestZipLayer : public QObject { Q_OBJECT private: - QString mDataDir; QString mScanZipSetting; QString mSettingsKey; @@ -62,10 +61,10 @@ class TestZipLayer: public QObject private slots: // init / cleanup - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. // tests // test for .zip and .gz files using all options @@ -142,7 +141,7 @@ QgsMapLayer *TestZipLayer::getZipLayer( const QString &myPath, const QString &my bool TestZipLayer::testZipItemPassthru( const QString &myFileName, const QString &myProviderKey ) { - std::unique_ptr< QgsMapLayer > layer( getLayer( myFileName, QString(), myProviderKey ) ); + std::unique_ptr layer( getLayer( myFileName, QString(), myProviderKey ) ); return layer && layer->isValid(); } @@ -171,8 +170,7 @@ QgsDataItem *getItemFromZip( const QString &fileName, const QString &childName ) bool TestZipLayer::testZipItem( const QString &myFileName, const QString &myChildName, const QString &myProviderName ) { - QgsDebugMsgLevel( QStringLiteral( "\n=======================================\nfile = %1 name = %2 provider = %3" - ).arg( myFileName, myChildName, myProviderName ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "\n=======================================\nfile = %1 name = %2 provider = %3" ).arg( myFileName, myChildName, myProviderName ), 2 ); QFileInfo myFileInfo( myFileName ); QgsZipItem *myZipItem = new QgsZipItem( nullptr, myFileInfo.fileName(), myFileName ); myZipItem->populate(); @@ -209,13 +207,13 @@ bool TestZipLayer::testZipItem( const QString &myFileName, const QString &myChil QgsDebugMsgLevel( QStringLiteral( "valid: %1" ).arg( layer->isValid() ), 2 ); ok = layer->isValid(); delete layer; - if ( ! ok ) + if ( !ok ) { QWARN( QString( "Invalid layer %1" ).arg( layerItem->path() ).toLocal8Bit().data() ); } if ( myChildName.isEmpty() ) { - if ( ! ok ) + if ( !ok ) break; } else @@ -224,10 +222,13 @@ bool TestZipLayer::testZipItem( const QString &myFileName, const QString &myChil if ( !myProviderName.isEmpty() ) { ok = ( myProviderName == layerItem->providerKey() ); - if ( ! ok ) + if ( !ok ) { QWARN( QString( "Layer %1 opened by provider %2, expecting %3" - ).arg( layerItem->path(), layerItem->providerKey(), myProviderName ).toLocal8Bit().data() ); + ) + .arg( layerItem->path(), layerItem->providerKey(), myProviderName ) + .toLocal8Bit() + .data() ); } } break; @@ -504,7 +505,7 @@ void TestZipLayer::testZipItemVRT() QVERIFY( zipItem ); // VRT items will be a collection type - QgsFileDataCollectionItem *collectionItem = dynamic_cast< QgsFileDataCollectionItem * >( zipItem ); + QgsFileDataCollectionItem *collectionItem = dynamic_cast( zipItem ); QVERIFY( collectionItem ); collectionItem->populate(); @@ -517,7 +518,7 @@ void TestZipLayer::testZipItemVRT() QCoreApplication::processEvents(); } - QgsProviderSublayerItem *sublayerItem = qobject_cast< QgsProviderSublayerItem * >( collectionItem->children().at( 0 ) ); + QgsProviderSublayerItem *sublayerItem = qobject_cast( collectionItem->children().at( 0 ) ); QVERIFY( sublayerItem ); QCOMPARE( sublayerItem->sublayerDetails().name(), QStringLiteral( "landsat_b1.vrt" ) ); QCOMPARE( sublayerItem->sublayerDetails().providerKey(), QStringLiteral( "gdal" ) ); @@ -527,7 +528,7 @@ void TestZipLayer::testZipItemVRT() zipItem = getItemFromZip( QDir::tempPath() + "/testzip.zip", "landsat_b1.vrt" ); QVERIFY( zipItem ); - collectionItem = dynamic_cast< QgsFileDataCollectionItem * >( zipItem ); + collectionItem = dynamic_cast( zipItem ); QVERIFY( collectionItem ); collectionItem->populate(); @@ -539,11 +540,10 @@ void TestZipLayer::testZipItemVRT() QCoreApplication::processEvents(); } - sublayerItem = qobject_cast< QgsProviderSublayerItem * >( collectionItem->children().at( 0 ) ); + sublayerItem = qobject_cast( collectionItem->children().at( 0 ) ); QVERIFY( sublayerItem ); QCOMPARE( sublayerItem->sublayerDetails().name(), QStringLiteral( "landsat_b1.vrt" ) ); QCOMPARE( sublayerItem->sublayerDetails().providerKey(), QStringLiteral( "gdal" ) ); - } QGSTEST_MAIN( TestZipLayer ) diff --git a/tests/src/core/vector/testqgsvectorlayereditbuffer.cpp b/tests/src/core/vector/testqgsvectorlayereditbuffer.cpp index 089b85ac9a92..dcba4fcb65a8 100644 --- a/tests/src/core/vector/testqgsvectorlayereditbuffer.cpp +++ b/tests/src/core/vector/testqgsvectorlayereditbuffer.cpp @@ -19,13 +19,14 @@ #include "qgsvectorlayer.h" #include "qgsvectorlayereditbuffer.h" -class TestQgsVectorLayerEditBuffer: public QObject +class TestQgsVectorLayerEditBuffer : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. void constructor(); + private: QgsVectorLayer *mLayerPoint = nullptr; }; @@ -52,7 +53,7 @@ void TestQgsVectorLayerEditBuffer::cleanupTestCase() void TestQgsVectorLayerEditBuffer::constructor() { QgsVectorLayerEditBuffer buf( mLayerPoint ); - QVERIFY( ! buf.isModified() ); + QVERIFY( !buf.isModified() ); // TODO: buf.addedFeatures().isEmpty() // TODO: buf.allAddedOrEditedFeatures().isEmpty() @@ -63,7 +64,3 @@ void TestQgsVectorLayerEditBuffer::constructor() QGSTEST_MAIN( TestQgsVectorLayerEditBuffer ) #include "testqgsvectorlayereditbuffer.moc" - - - - diff --git a/tests/src/core/vector/testqgsvectorlayerundocommand.cpp b/tests/src/core/vector/testqgsvectorlayerundocommand.cpp index ca0e933d967d..19c0aa0217e6 100644 --- a/tests/src/core/vector/testqgsvectorlayerundocommand.cpp +++ b/tests/src/core/vector/testqgsvectorlayerundocommand.cpp @@ -19,11 +19,11 @@ #include "qgsvectorlayer.h" #include "qgsvectorlayerundocommand.h" -class TestQgsVectorLayerUndoCommand: public QObject +class TestQgsVectorLayerUndoCommand : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. void baseClass(); @@ -66,22 +66,24 @@ void TestQgsVectorLayerUndoCommand::baseClass() void TestQgsVectorLayerUndoCommand::changeAttribute() { - std::unique_ptr< QgsVectorLayerUndoCommandChangeAttribute > cmd; + std::unique_ptr cmd; // Should this be allowed at all, when fid is nonexistent ? cmd.reset( new QgsVectorLayerUndoCommandChangeAttribute( - mLayerEditBuffer, - 1, // Positive (not-new) non-existent FID - 0, "newvalue", "oldvalue" ) ); + mLayerEditBuffer, + 1, // Positive (not-new) non-existent FID + 0, "newvalue", "oldvalue" + ) ); QCOMPARE( cmd->layer(), mLayerPoint ); QCOMPARE( cmd->id(), -1 ); cmd->undo(); // Test for https://github.com/qgis/QGIS/issues/23243 cmd.reset( new QgsVectorLayerUndoCommandChangeAttribute( - mLayerEditBuffer, - -1, // Negative (new) non-existent FID - 0, "newvalue", "oldvalue" ) ); + mLayerEditBuffer, + -1, // Negative (new) non-existent FID + 0, "newvalue", "oldvalue" + ) ); QCOMPARE( cmd->layer(), mLayerPoint ); QCOMPARE( cmd->id(), -1 ); cmd->undo(); @@ -90,7 +92,3 @@ void TestQgsVectorLayerUndoCommand::changeAttribute() QGSTEST_MAIN( TestQgsVectorLayerUndoCommand ) #include "testqgsvectorlayerundocommand.moc" - - - - diff --git a/tests/src/geometry_checker/testqgsgeometrychecks.cpp b/tests/src/geometry_checker/testqgsgeometrychecks.cpp index 927684f01525..76a98237f82b 100644 --- a/tests/src/geometry_checker/testqgsgeometrychecks.cpp +++ b/tests/src/geometry_checker/testqgsgeometrychecks.cpp @@ -49,23 +49,23 @@ #include "qgsgeometrytypecheck.h" -class TestQgsGeometryChecks: public QObject +class TestQgsGeometryChecks : public QObject { Q_OBJECT private: struct Change { - QString layerId; - QgsFeatureId fid; - QgsGeometryCheck::ChangeWhat what; - QgsGeometryCheck::ChangeType type; - QgsVertexId vidx; + QString layerId; + QgsFeatureId fid; + QgsGeometryCheck::ChangeWhat what; + QgsGeometryCheck::ChangeType type; + QgsVertexId vidx; }; double layerToMapUnits( const QgsMapLayer *layer, const QgsCoordinateReferenceSystem &mapCrs ) const; QgsFeaturePool *createFeaturePool( QgsVectorLayer *layer, bool selectedOnly = false ) const; - QPair > createTestContext( QTemporaryDir &tempDir, QMap &layers, const QgsCoordinateReferenceSystem &mapCrs = QgsCoordinateReferenceSystem( "EPSG:4326" ), int prec = 8 ) const; - QPair > createMemoryTestContext( QMap &layers, const QgsCoordinateReferenceSystem &mapCrs = QgsCoordinateReferenceSystem( "EPSG:4326" ), int prec = 8 ) const; - void cleanupTestContext( QPair > ctx ) const; + QPair> createTestContext( QTemporaryDir &tempDir, QMap &layers, const QgsCoordinateReferenceSystem &mapCrs = QgsCoordinateReferenceSystem( "EPSG:4326" ), int prec = 8 ) const; + QPair> createMemoryTestContext( QMap &layers, const QgsCoordinateReferenceSystem &mapCrs = QgsCoordinateReferenceSystem( "EPSG:4326" ), int prec = 8 ) const; + void cleanupTestContext( QPair> ctx ) const; void listErrors( const QList &checkErrors, const QStringList &messages ) const; QList searchCheckErrors( const QList &checkErrors, const QString &layerId, const QgsFeatureId &featureId = -1, const QgsPointXY &pos = QgsPointXY(), const QgsVertexId &vid = QgsVertexId(), const QVariant &value = QVariant(), double tol = 1E-4 ) const; bool fixCheckError( QMap featurePools, QgsGeometryCheckError *error, int method, const QgsGeometryCheckError::Status &expectedStatus, const QVector &expectedChanges, const QMap &mergeAttr = QMap() ); @@ -145,7 +145,7 @@ void TestQgsGeometryChecks::testAngleCheckMemoryLayers() QCOMPARE( checkErrors.size(), 8 ); QVERIFY( searchCheckErrors( checkErrors, layers["point_layer.shp"] ).isEmpty() ); - QVERIFY( ( errs1 = searchCheckErrors( checkErrors, layers["line_layer.shp"], 1, QgsPointXY( -0.2225, 0.5526 ), QgsVertexId( 0, 0, 3 ), 10.5865 ) ).size() == 1 ); + QVERIFY( ( errs1 = searchCheckErrors( checkErrors, layers["line_layer.shp"], 1, QgsPointXY( -0.2225, 0.5526 ), QgsVertexId( 0, 0, 3 ), 10.5865 ) ).size() == 1 ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"], 1, QgsPointXY( -0.94996, 0.99967 ), QgsVertexId( 1, 0, 1 ), 8.3161 ).size() == 1 ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"], 3, QgsPointXY( -0.4547, -0.3059 ), QgsVertexId( 0, 0, 1 ), 5.4165 ).size() == 1 ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"], 3, QgsPointXY( -0.7594, -0.1971 ), QgsVertexId( 0, 0, 2 ), 12.5288 ).size() == 1 ); @@ -160,39 +160,35 @@ void TestQgsGeometryChecks::testAngleCheckMemoryLayers() testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); n1 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring ); - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, - {{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx() } } ) ); testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); n2 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring ); QCOMPARE( n1, n2 + 1 ); testContext.second[errs2[0]->layerId()]->getFeature( errs2[0]->featureId(), f ); n1 = f.geometry().constGet()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring ); - QVERIFY( fixCheckError( testContext.second, errs2[0], - QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, - {{errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs2[0], QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, { { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx() } } ) ); testContext.second[errs2[0]->layerId()]->getFeature( errs2[0]->featureId(), f ); n2 = f.geometry().constGet()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring ); QCOMPARE( n1, n2 + 1 ); // Test change tracking - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeChanged, QgsVertexId()} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part + 1 )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part + 1 )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx()} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, errs2[0]->vidx()} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 )} ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeChanged, QgsVertexId() } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part + 1 ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part + 1 ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx() } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, errs2[0]->vidx() } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 ) } ) ) ); const QgsVertexId oldVidx = errs2[0]->vidx(); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex - 1 )} ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex - 1 ) } ) ) ); QVERIFY( errs2[0]->vidx().vertex == oldVidx.vertex - 1 ); cleanupTestContext( testContext ); @@ -224,7 +220,7 @@ void TestQgsGeometryChecks::testAngleCheck() QCOMPARE( checkErrors.size(), 8 ); QVERIFY( searchCheckErrors( checkErrors, layers["point_layer.shp"] ).isEmpty() ); - QVERIFY( ( errs1 = searchCheckErrors( checkErrors, layers["line_layer.shp"], 0, QgsPointXY( -0.2225, 0.5526 ), QgsVertexId( 0, 0, 3 ), 10.5865 ) ).size() == 1 ); + QVERIFY( ( errs1 = searchCheckErrors( checkErrors, layers["line_layer.shp"], 0, QgsPointXY( -0.2225, 0.5526 ), QgsVertexId( 0, 0, 3 ), 10.5865 ) ).size() == 1 ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"], 0, QgsPointXY( -0.94996, 0.99967 ), QgsVertexId( 1, 0, 1 ), 8.3161 ).size() == 1 ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"], 2, QgsPointXY( -0.4547, -0.3059 ), QgsVertexId( 0, 0, 1 ), 5.4165 ).size() == 1 ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"], 2, QgsPointXY( -0.7594, -0.1971 ), QgsVertexId( 0, 0, 2 ), 12.5288 ).size() == 1 ); @@ -239,39 +235,35 @@ void TestQgsGeometryChecks::testAngleCheck() testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); n1 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring ); - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, - {{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx() } } ) ); testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); n2 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring ); QCOMPARE( n1, n2 + 1 ); testContext.second[errs2[0]->layerId()]->getFeature( errs2[0]->featureId(), f ); n1 = f.geometry().constGet()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring ); - QVERIFY( fixCheckError( testContext.second, errs2[0], - QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, - {{errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs2[0], QgsGeometryAngleCheck::DeleteNode, QgsGeometryCheckError::StatusFixed, { { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx() } } ) ); testContext.second[errs2[0]->layerId()]->getFeature( errs2[0]->featureId(), f ); n2 = f.geometry().constGet()->vertexCount( errs2[0]->vidx().part, errs2[0]->vidx().ring ); QCOMPARE( n1, n2 + 1 ); // Test change tracking - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeChanged, QgsVertexId()} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part + 1 )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part + 1 )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 )} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx()} ) ) ); - QVERIFY( !errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, errs2[0]->vidx()} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 )} ) ) ); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 )} ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeChanged, QgsVertexId() } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part + 1 ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part + 1 ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring + 1 ) } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs2[0]->vidx() } ) ) ); + QVERIFY( !errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, errs2[0]->vidx() } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 ) } ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeChanged, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex + 1 ) } ) ) ); const QgsVertexId oldVidx = errs2[0]->vidx(); - QVERIFY( errs2[0]->handleChanges( change2changes( {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex - 1 )} ) ) ); + QVERIFY( errs2[0]->handleChanges( change2changes( { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( errs2[0]->vidx().part, errs2[0]->vidx().ring, errs2[0]->vidx().vertex - 1 ) } ) ) ); QVERIFY( errs2[0]->vidx().vertex == oldVidx.vertex - 1 ); cleanupTestContext( testContext ); @@ -319,22 +311,14 @@ void TestQgsGeometryChecks::testAreaCheck() QgsFeature f; bool valid; - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryAreaCheck::Delete, QgsGeometryCheckError::StatusFixed, - {{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryAreaCheck::Delete, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() } } ) ); valid = testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); QVERIFY( !valid ); // Try merging a small geometry by longest edge, largest area and common value testContext.second[layers["polygon_layer.shp"]]->getFeature( 15, f ); const double area15 = f.geometry().area(); - QVERIFY( fixCheckError( testContext.second, errs2[0], - QgsGeometryAreaCheck::MergeLargestArea, QgsGeometryCheckError::StatusFixed, - { - {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()}, - {layers["polygon_layer.shp"], 15, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 )}, - {layers["polygon_layer.shp"], 15, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs2[0], QgsGeometryAreaCheck::MergeLargestArea, QgsGeometryCheckError::StatusFixed, { { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() }, { layers["polygon_layer.shp"], 15, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 ) }, { layers["polygon_layer.shp"], 15, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 ) } } ) ); testContext.second[layers["polygon_layer.shp"]]->getFeature( 15, f ); QVERIFY( f.geometry().area() > area15 ); valid = testContext.second[errs2[0]->layerId()]->getFeature( errs2[0]->featureId(), f ); @@ -342,13 +326,7 @@ void TestQgsGeometryChecks::testAreaCheck() testContext.second[layers["polygon_layer.shp"]]->getFeature( 18, f ); const double area18 = f.geometry().area(); - QVERIFY( fixCheckError( testContext.second, errs3[0], - QgsGeometryAreaCheck::MergeLongestEdge, QgsGeometryCheckError::StatusFixed, - { - {errs3[0]->layerId(), errs3[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()}, - {layers["polygon_layer.shp"], 18, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 )}, - {layers["polygon_layer.shp"], 18, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs3[0], QgsGeometryAreaCheck::MergeLongestEdge, QgsGeometryCheckError::StatusFixed, { { errs3[0]->layerId(), errs3[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() }, { layers["polygon_layer.shp"], 18, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 ) }, { layers["polygon_layer.shp"], 18, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 ) } } ) ); testContext.second[layers["polygon_layer.shp"]]->getFeature( 18, f ); QVERIFY( f.geometry().area() > area18 ); valid = testContext.second[errs3[0]->layerId()]->getFeature( errs3[0]->featureId(), f ); @@ -358,13 +336,7 @@ void TestQgsGeometryChecks::testAreaCheck() const double area21 = f.geometry().area(); QMap mergeIdx; mergeIdx.insert( layers["polygon_layer.shp"], 1 ); // 1: attribute "attr" - QVERIFY( fixCheckError( testContext.second, errs4[0], - QgsGeometryAreaCheck::MergeIdenticalAttribute, QgsGeometryCheckError::StatusFixed, - { - {errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()}, - {layers["polygon_layer.shp"], 21, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 )}, - {layers["polygon_layer.shp"], 21, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 )} - }, mergeIdx ) ); + QVERIFY( fixCheckError( testContext.second, errs4[0], QgsGeometryAreaCheck::MergeIdenticalAttribute, QgsGeometryCheckError::StatusFixed, { { errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() }, { layers["polygon_layer.shp"], 21, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 ) }, { layers["polygon_layer.shp"], 21, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 ) } }, mergeIdx ) ); testContext.second[layers["polygon_layer.shp"]]->getFeature( 21, f ); QVERIFY( f.geometry().area() > area21 ); valid = testContext.second[errs4[0]->layerId()]->getFeature( errs4[0]->featureId(), f ); @@ -401,9 +373,7 @@ void TestQgsGeometryChecks::testContainedCheck() QVERIFY( messages.contains( "Contained check failed for (polygon_layer.shp:1): the geometry is invalid" ) ); // Test fixes - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryContainedCheck::Delete, QgsGeometryCheckError::StatusFixed, - {{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryContainedCheck::Delete, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() } } ) ); QgsFeature f; const bool valid = testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); QVERIFY( !valid ); @@ -443,7 +413,7 @@ void TestQgsGeometryChecks::testDangleCheck() // Test change tracking const QgsVertexId oldVidx = errs1[0]->vidx(); - QVERIFY( errs1[0]->handleChanges( change2changes( {errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 )} ) ) ); + QVERIFY( errs1[0]->handleChanges( change2changes( { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 ) } ) ) ); QVERIFY( errs1[0]->vidx().part == oldVidx.part - 1 ); cleanupTestContext( testContext ); @@ -475,9 +445,7 @@ void TestQgsGeometryChecks::testDegeneratePolygonCheck() QVERIFY( ( errs1 = searchCheckErrors( checkErrors, layers["polygon_layer.shp"], 6, QgsPointXY(), QgsVertexId( 0, 0 ) ) ).size() == 1 ); // Test fixes - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryDegeneratePolygonCheck::DeleteRing, QgsGeometryCheckError::StatusFixed, - {{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryDegeneratePolygonCheck::DeleteRing, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() } } ) ); QgsFeature f; const bool valid = testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); QVERIFY( !valid ); @@ -509,21 +477,22 @@ void TestQgsGeometryChecks::testDuplicateCheck() QCOMPARE( checkErrors.size(), 3 ); QVERIFY( searchCheckErrors( checkErrors, layers["point_layer.shp"], 6, QgsPoint(), QgsVertexId(), QVariant( "point_layer.shp:2" ) ).size() == 1 - || searchCheckErrors( checkErrors, layers["point_layer.shp"], 2, QgsPoint(), QgsVertexId(), QVariant( "point_layer.shp:6" ) ).size() == 1 ); + || searchCheckErrors( checkErrors, layers["point_layer.shp"], 2, QgsPoint(), QgsVertexId(), QVariant( "point_layer.shp:6" ) ).size() == 1 + ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"], 4, QgsPoint(), QgsVertexId(), QVariant( "line_layer.shp:7" ) ).size() == 1 - || searchCheckErrors( checkErrors, layers["line_layer.shp"], 7, QgsPoint(), QgsVertexId(), QVariant( "line_layer.shp:4" ) ).size() == 1 ); + || searchCheckErrors( checkErrors, layers["line_layer.shp"], 7, QgsPoint(), QgsVertexId(), QVariant( "line_layer.shp:4" ) ).size() == 1 + ); QVERIFY( ( errs1 = searchCheckErrors( checkErrors, layers["polygon_layer.shp"], 8, QgsPoint(), QgsVertexId(), QVariant( "polygon_layer.shp:7" ) ) ).size() == 1 - || ( errs1 = searchCheckErrors( checkErrors, layers["polygon_layer.shp"], 7, QgsPoint(), QgsVertexId(), QVariant( "polygon_layer.shp:8" ) ) ).size() == 1 ); + || ( errs1 = searchCheckErrors( checkErrors, layers["polygon_layer.shp"], 7, QgsPoint(), QgsVertexId(), QVariant( "polygon_layer.shp:8" ) ) ).size() == 1 + ); // Test fixes QgsGeometryDuplicateCheckError *dupErr = static_cast( errs1[0] ); QString dup1LayerId = dupErr->duplicates().firstKey(); QgsFeatureId dup1Fid = dupErr->duplicates()[dup1LayerId][0]; - QVERIFY( fixCheckError( testContext.second, dupErr, - QgsGeometryDuplicateCheck::RemoveDuplicates, QgsGeometryCheckError::StatusFixed, - {{dup1LayerId, dup1Fid, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId()}} ) ); + QVERIFY( fixCheckError( testContext.second, dupErr, QgsGeometryDuplicateCheck::RemoveDuplicates, QgsGeometryCheckError::StatusFixed, { { dup1LayerId, dup1Fid, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() } } ) ); QgsFeature f; const bool valid = testContext.second[dup1LayerId]->getFeature( dup1Fid, f ); QVERIFY( !valid ); @@ -563,9 +532,7 @@ void TestQgsGeometryChecks::testDuplicateNodesCheck() testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); const int n1 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring ); - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryDuplicateNodesCheck::RemoveDuplicates, QgsGeometryCheckError::StatusFixed, - {{errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx()}} ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryDuplicateNodesCheck::RemoveDuplicates, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, errs1[0]->vidx() } } ) ); testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); const int n2 = f.geometry().constGet()->vertexCount( errs1[0]->vidx().part, errs1[0]->vidx().ring ); QCOMPARE( n1, n2 + 1 ); @@ -657,12 +624,7 @@ void TestQgsGeometryChecks::testGapCheck() testContext.second[layers["gap_layer.shp"]]->getFeature( 0, f ); const double areaOld = f.geometry().area(); - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryGapCheck::MergeLongestEdge, QgsGeometryCheckError::StatusFixed, - { - {layers["gap_layer.shp"], 0, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 )}, - {layers["gap_layer.shp"], 0, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryGapCheck::MergeLongestEdge, QgsGeometryCheckError::StatusFixed, { { layers["gap_layer.shp"], 0, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 ) }, { layers["gap_layer.shp"], 0, QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 ) } } ) ); testContext.second[layers["gap_layer.shp"]]->getFeature( 0, f ); QVERIFY( f.geometry().area() > areaOld ); @@ -677,7 +639,7 @@ void TestQgsGeometryChecks::testAllowedGaps() const auto testContext = createTestContext( dir, layers ); // Allowed gaps layer - std::unique_ptr allowedGaps = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:4326" ), QStringLiteral( "allowedGaps" ), QStringLiteral( "memory" ) ); + std::unique_ptr allowedGaps = std::make_unique( QStringLiteral( "Polygon?crs=epsg:4326" ), QStringLiteral( "allowedGaps" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( allowedGaps.get(), true, false ); // Test detection @@ -797,11 +759,7 @@ void TestQgsGeometryChecks::testHoleCheck() // Test fixes QgsFeature f; - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryHoleCheck::RemoveHoles, QgsGeometryCheckError::StatusFixed, - { - {errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0, 1 )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryHoleCheck::RemoveHoles, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0, 1 ) } } ) ); testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); QVERIFY( f.geometry().constGet()->ringCount( 0 ) == 1 ); @@ -915,11 +873,7 @@ void TestQgsGeometryChecks::testMultipartCheck() QVERIFY( QgsWkbTypes::isSingleType( f.geometry().geometry()->wkbType() ) ); #endif - QVERIFY( fixCheckError( testContext.second, errs2[0], - QgsGeometryMultipartCheck::RemoveObject, QgsGeometryCheckError::StatusFixed, - { - {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId( )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs2[0], QgsGeometryMultipartCheck::RemoveObject, QgsGeometryCheckError::StatusFixed, { { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeRemoved, QgsVertexId() } } ) ); const bool valid = testContext.second[errs2[0]->layerId()]->getFeature( errs2[0]->featureId(), f ); QVERIFY( !valid ); @@ -961,11 +915,7 @@ void TestQgsGeometryChecks::testOverlapCheck() testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); const double areaOld = f.geometry().area(); - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometryOverlapCheck::Subtract, QgsGeometryCheckError::StatusFixed, - { - {errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeChanged, QgsVertexId( )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometryOverlapCheck::Subtract, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeChanged, QgsVertexId() } } ) ); testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); QVERIFY( f.geometry().area() < areaOld ); @@ -1125,7 +1075,7 @@ void TestQgsGeometryChecks::testSelfContactCheck() QVERIFY( errors.isEmpty() ); // test with totally empty line - qgsgeometry_cast< QgsMultiLineString * >( g.get() )->addGeometry( new QgsLineString() ); + qgsgeometry_cast( g.get() )->addGeometry( new QgsLineString() ); errors = check2.processGeometry( g ); QVERIFY( errors.isEmpty() ); } @@ -1165,13 +1115,7 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck() QgsFeature f; QgsFeatureId nextId = testContext.second[errs1[0]->layerId()]->layer()->featureCount(); - QVERIFY( fixCheckError( testContext.second, errs1[0], - QgsGeometrySelfIntersectionCheck::ToSingleObjects, QgsGeometryCheckError::StatusFixed, - { - {errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 )}, - {errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 )}, - {errs1[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId()} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs1[0], QgsGeometrySelfIntersectionCheck::ToSingleObjects, QgsGeometryCheckError::StatusFixed, { { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 ) }, { errs1[0]->layerId(), errs1[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 ) }, { errs1[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId() } } ) ); testContext.second[errs1[0]->layerId()]->getFeature( errs1[0]->featureId(), f ); QCOMPARE( f.geometry().constGet()->partCount(), 1 ); QCOMPARE( f.geometry().constGet()->vertexCount(), 4 ); @@ -1179,13 +1123,7 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck() QCOMPARE( f.geometry().constGet()->partCount(), 1 ); QCOMPARE( f.geometry().constGet()->vertexCount(), 6 ); - QVERIFY( fixCheckError( testContext.second, errs2[0], - QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed, - { - {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 )}, - {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 )}, - {errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs2[0], QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed, { { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0 ) }, { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 0 ) }, { errs2[0]->layerId(), errs2[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 ) } } ) ); testContext.second[errs2[0]->layerId()]->getFeature( errs2[0]->featureId(), f ); QCOMPARE( f.geometry().constGet()->partCount(), 2 ); QCOMPARE( f.geometry().constGet()->vertexCount( 0 ), 4 ); @@ -1193,31 +1131,20 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck() nextId = testContext.second[errs3[0]->layerId()]->layer()->featureCount(); testContext.second[errs3[0]->layerId()]->getFeature( errs3[0]->featureId(), f ); - QVERIFY( fixCheckError( testContext.second, errs3[0], - QgsGeometrySelfIntersectionCheck::ToSingleObjects, QgsGeometryCheckError::StatusFixed, - { - {errs3[0]->layerId(), errs3[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( 0, 0 )}, - {errs3[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId()} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs3[0], QgsGeometrySelfIntersectionCheck::ToSingleObjects, QgsGeometryCheckError::StatusFixed, { { errs3[0]->layerId(), errs3[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( 0, 0 ) }, { errs3[0]->layerId(), nextId, QgsGeometryCheck::ChangeFeature, QgsGeometryCheck::ChangeAdded, QgsVertexId() } } ) ); testContext.second[errs3[0]->layerId()]->getFeature( errs3[0]->featureId(), f ); - const QgsGeometryCollection *collectionResult = qgsgeometry_cast< const QgsGeometryCollection * >( f.geometry().constGet() ); + const QgsGeometryCollection *collectionResult = qgsgeometry_cast( f.geometry().constGet() ); - QCOMPARE( qgsgeometry_cast< const QgsPolygon * >( collectionResult->geometryN( 0 ) )->exteriorRing()->asWkt( 2 ), QStringLiteral( "LineString (0.7 0.59, 1.32 0.6, 1.26 0.09, 0.51 0.05, 0.89 0.57, 0.7 0.59)" ) ); + QCOMPARE( qgsgeometry_cast( collectionResult->geometryN( 0 ) )->exteriorRing()->asWkt( 2 ), QStringLiteral( "LineString (0.7 0.59, 1.32 0.6, 1.26 0.09, 0.51 0.05, 0.89 0.57, 0.7 0.59)" ) ); // make sure the other part of the ring isn't present in this feature. We may have OTHER parts in this feature though, depending on the GDAL version! for ( int i = 1; i < collectionResult->numGeometries(); ++i ) { - QVERIFY( qgsgeometry_cast< const QgsPolygon * >( collectionResult->geometryN( i ) )->exteriorRing()->asWkt( 2 ) != QLatin1String( "LineString (1.24 -0.05, 1.45 0.1, 1.26 0.09, 1.24 -0.05)" ) ); + QVERIFY( qgsgeometry_cast( collectionResult->geometryN( i ) )->exteriorRing()->asWkt( 2 ) != QLatin1String( "LineString (1.24 -0.05, 1.45 0.1, 1.26 0.09, 1.24 -0.05)" ) ); } testContext.second[errs3[0]->layerId()]->getFeature( nextId, f ); - QCOMPARE( qgsgeometry_cast< const QgsPolygon * >( f.geometry().constGet() )->exteriorRing()->asWkt( 2 ), QStringLiteral( "LineString (1.24 -0.05, 1.45 0.1, 1.26 0.09, 1.24 -0.05)" ) ); + QCOMPARE( qgsgeometry_cast( f.geometry().constGet() )->exteriorRing()->asWkt( 2 ), QStringLiteral( "LineString (1.24 -0.05, 1.45 0.1, 1.26 0.09, 1.24 -0.05)" ) ); - QVERIFY( fixCheckError( testContext.second, errs4[0], - QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed, - { - {errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( 0, 0 )}, - {errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0, 1 )}, - {errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 )} - } ) ); + QVERIFY( fixCheckError( testContext.second, errs4[0], QgsGeometrySelfIntersectionCheck::ToMultiObject, QgsGeometryCheckError::StatusFixed, { { errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeChanged, QgsVertexId( 0, 0 ) }, { errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeRing, QgsGeometryCheck::ChangeRemoved, QgsVertexId( 0, 1 ) }, { errs4[0]->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangePart, QgsGeometryCheck::ChangeAdded, QgsVertexId( 1 ) } } ) ); testContext.second[errs4[0]->layerId()]->getFeature( errs4[0]->featureId(), f ); QCOMPARE( f.geometry().constGet()->partCount(), 2 ); QCOMPARE( f.geometry().constGet()->ringCount( 0 ), 1 ); @@ -1229,11 +1156,11 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck() // Test change tracking QgsGeometryCheckErrorSingle *err = static_cast( errs4[0] ); const QgsGeometryUtils::SelfIntersection oldInter = static_cast( err->singleError() )->intersection(); - QVERIFY( err->handleChanges( change2changes( {err->layerId(), err->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( err->vidx().part, errs4[0]->vidx().ring, 0 )} ) ) ); - QgsGeometryUtils::SelfIntersection newInter = static_cast( err->singleError() )->intersection(); + QVERIFY( err->handleChanges( change2changes( { err->layerId(), err->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeRemoved, QgsVertexId( err->vidx().part, errs4[0]->vidx().ring, 0 ) } ) ) ); + QgsGeometryUtils::SelfIntersection newInter = static_cast( err->singleError() )->intersection(); QVERIFY( oldInter.segment1 == newInter.segment1 + 1 ); QVERIFY( oldInter.segment2 == newInter.segment2 + 1 ); - QVERIFY( err->handleChanges( change2changes( {err->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeAdded, QgsVertexId( err->vidx().part, errs4[0]->vidx().ring, 0 )} ) ) ); + QVERIFY( err->handleChanges( change2changes( { err->layerId(), errs4[0]->featureId(), QgsGeometryCheck::ChangeNode, QgsGeometryCheck::ChangeAdded, QgsVertexId( err->vidx().part, errs4[0]->vidx().ring, 0 ) } ) ) ); newInter = static_cast( err->singleError() )->intersection(); QVERIFY( oldInter.segment1 == newInter.segment1 ); QVERIFY( oldInter.segment2 == newInter.segment2 ); @@ -1409,7 +1336,7 @@ QgsFeaturePool *TestQgsGeometryChecks::createFeaturePool( QgsVectorLayer *layer, return new QgsVectorDataProviderFeaturePool( layer, selectedOnly ); } -QPair > TestQgsGeometryChecks::createMemoryTestContext( QMap &layers, const QgsCoordinateReferenceSystem &mapCrs, int prec ) const +QPair> TestQgsGeometryChecks::createMemoryTestContext( QMap &layers, const QgsCoordinateReferenceSystem &mapCrs, int prec ) const { const QDir testDataDir( QDir( TEST_DATA_DIR ).absoluteFilePath( "geometry_checker" ) ); @@ -1426,7 +1353,7 @@ QPair > TestQgsGeomet return qMakePair( new QgsGeometryCheckContext( prec, mapCrs, QgsProject::instance()->transformContext(), QgsProject::instance() ), featurePools ); } -QPair > TestQgsGeometryChecks::createTestContext( QTemporaryDir &tempDir, QMap &layers, const QgsCoordinateReferenceSystem &mapCrs, int prec ) const +QPair> TestQgsGeometryChecks::createTestContext( QTemporaryDir &tempDir, QMap &layers, const QgsCoordinateReferenceSystem &mapCrs, int prec ) const { const QDir testDataDir( QDir( TEST_DATA_DIR ).absoluteFilePath( "geometry_checker" ) ); const QDir tmpDir( tempDir.path() ); @@ -1454,7 +1381,7 @@ QPair > TestQgsGeomet return qMakePair( new QgsGeometryCheckContext( prec, mapCrs, QgsProject::instance()->transformContext(), QgsProject::instance() ), featurePools ); } -void TestQgsGeometryChecks::cleanupTestContext( QPair > ctx ) const +void TestQgsGeometryChecks::cleanupTestContext( QPair> ctx ) const { for ( const QgsFeaturePool *pool : ctx.second ) { @@ -1474,7 +1401,8 @@ void TestQgsGeometryChecks::listErrors( const QList &ch } if ( !messages.isEmpty() ) { - QTextStream( stdout ) << " - Check messages:" << Qt::endl << " * " << messages.join( "\n * " ) << Qt::endl; + QTextStream( stdout ) << " - Check messages:" << Qt::endl + << " * " << messages.join( "\n * " ) << Qt::endl; } } @@ -1573,7 +1501,7 @@ QgsGeometryCheck::Changes TestQgsGeometryChecks::change2changes( const Change &c { QgsGeometryCheck::Changes changes; QMap> featureChanges; - featureChanges.insert( change.fid, {QgsGeometryCheck::Change( change.what, change.type, change.vidx )} ); + featureChanges.insert( change.fid, { QgsGeometryCheck::Change( change.what, change.type, change.vidx ) } ); changes.insert( change.layerId, featureChanges ); return changes; } diff --git a/tests/src/geometry_checker/testqgsvectorlayerfeaturepool.cpp b/tests/src/geometry_checker/testqgsvectorlayerfeaturepool.cpp index f4055d232c90..2c69d4cb5acd 100644 --- a/tests/src/geometry_checker/testqgsvectorlayerfeaturepool.cpp +++ b/tests/src/geometry_checker/testqgsvectorlayerfeaturepool.cpp @@ -163,7 +163,7 @@ void TestQgsVectorLayerFeaturePool::changeGeometry() QCOMPARE( feat.geometry().asWkt(), QStringLiteral( "Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))" ) ); // Add enough features for the cache to be full - for ( int i = 0; i < 1100; i++ ) // max cache size is 1000 + for ( int i = 0; i < 1100; i++ ) // max cache size is 1000 { feat = QgsFeature(); feat.setGeometry( QgsGeometry::fromWkt( "Polygon (( 0 0, 20 0, 20 20, 0 20, 0 0))" ) ); diff --git a/tests/src/gui/testprocessinggui.cpp b/tests/src/gui/testprocessinggui.cpp index ad5dbdcc9d0c..93162a486072 100644 --- a/tests/src/gui/testprocessinggui.cpp +++ b/tests/src/gui/testprocessinggui.cpp @@ -111,7 +111,6 @@ class TestParamType : public QgsProcessingParameterDefinition { public: - TestParamType( const QString &type, const QString &name, const QVariant &defaultValue = QVariant() ) : QgsProcessingParameterDefinition( name, name, defaultValue ) , mType( type ) @@ -127,15 +126,12 @@ class TestParamType : public QgsProcessingParameterDefinition QString type() const override { return mType; } QString valueAsPythonString( const QVariant &, QgsProcessingContext & ) const override { return QString(); } QString asScriptCode() const override { return QString(); } - }; class TestWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper // clazy:exclude=missing-qobject-macro { public: - - TestWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, - QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard ) + TestWidgetWrapper( const QgsProcessingParameterDefinition *parameter = nullptr, QgsProcessingGui::WidgetType type = QgsProcessingGui::Standard ) : QgsAbstractProcessingParameterWidgetWrapper( parameter, type ) {} @@ -157,14 +153,11 @@ class TestWidgetWrapper : public QgsAbstractProcessingParameterWidgetWrapper // { return QVariant(); } - }; class TestWidgetFactory : public QgsProcessingParameterWidgetFactoryInterface { - public: - TestWidgetFactory( const QString &type ) : type( type ) {} @@ -176,8 +169,7 @@ class TestWidgetFactory : public QgsProcessingParameterWidgetFactoryInterface return type; } - QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, - QgsProcessingGui::WidgetType type ) override + QgsAbstractProcessingParameterWidgetWrapper *createWidgetWrapper( const QgsProcessingParameterDefinition *parameter, QgsProcessingGui::WidgetType type ) override { return new TestWidgetWrapper( parameter, type ); } @@ -186,15 +178,14 @@ class TestWidgetFactory : public QgsProcessingParameterWidgetFactoryInterface QStringList compatibleParameterTypes() const override { return QStringList(); } QStringList compatibleOutputTypes() const override { return QStringList(); } - }; -class DummyPluginLayer: public QgsPluginLayer +class DummyPluginLayer : public QgsPluginLayer { Q_OBJECT public: - - DummyPluginLayer( const QString &layerType, const QString &layerName ): QgsPluginLayer( layerType, layerName ) + DummyPluginLayer( const QString &layerType, const QString &layerName ) + : QgsPluginLayer( layerType, layerName ) { mValid = true; }; @@ -214,8 +205,7 @@ class DummyPluginLayer: public QgsPluginLayer Q_UNUSED( context ); return true; }; - bool readSymbology( const QDomNode &node, QString &errorMessage, - QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override + bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override { Q_UNUSED( node ); Q_UNUSED( errorMessage ); @@ -223,8 +213,7 @@ class DummyPluginLayer: public QgsPluginLayer Q_UNUSED( categories ); return true; }; - bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, - StyleCategories categories = AllStyleCategories ) const override + bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const override { Q_UNUSED( node ); Q_UNUSED( doc ); @@ -244,10 +233,10 @@ class TestProcessingGui : public QObject TestProcessingGui() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testModelUndo(); void testSetGetConfig(); void testFilterAlgorithmConfig(); @@ -330,7 +319,6 @@ class TestProcessingGui : public QObject void testModelGraphicsView(); private: - QString mTempDir; const char *mPass = "pass"; @@ -351,8 +339,7 @@ void TestProcessingGui::initTestCase() // init app and auth manager QgsApplication::init(); QgsApplication::initQgis(); - QVERIFY2( !QgsApplication::authManager()->isDisabled(), - "Authentication system is DISABLED" ); + QVERIFY2( !QgsApplication::authManager()->isDisabled(), "Authentication system is DISABLED" ); // verify QGIS_AUTH_DB_DIR_PATH (temp auth db path) worked Q_NOWARN_DEPRECATED_PUSH @@ -363,10 +350,8 @@ void TestProcessingGui::initTestCase() // verify master pass can be set manually // (this also creates a fresh password hash in the new temp database) - QVERIFY2( QgsApplication::authManager()->setMasterPassword( mPass, true ), - "Master password could not be set" ); - QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), - "Auth master password not set from passed string" ); + QVERIFY2( QgsApplication::authManager()->setMasterPassword( mPass, true ), "Master password could not be set" ); + QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), "Auth master password not set from passed string" ); // create QGIS_AUTH_PASSWORD_FILE file QString passfilepath = mTempDir + "/passfile"; @@ -383,12 +368,10 @@ void TestProcessingGui::initTestCase() QgsApplication::quit(); QgsApplication::init(); QgsApplication::initQgis(); - QVERIFY2( !QgsApplication::authManager()->isDisabled(), - "Authentication system is DISABLED" ); + QVERIFY2( !QgsApplication::authManager()->isDisabled(), "Authentication system is DISABLED" ); // verify QGIS_AUTH_PASSWORD_FILE worked, when compared against hash in db - QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), - "Auth master password not set from QGIS_AUTH_PASSWORD_FILE" ); + QVERIFY2( QgsApplication::authManager()->masterPasswordIsSet(), "Auth master password not set from QGIS_AUTH_PASSWORD_FILE" ); QgsApplication::processingRegistry()->addProvider( new QgsNativeAlgorithms( QgsApplication::processingRegistry() ) ); } @@ -452,7 +435,7 @@ void TestProcessingGui::testModelUndo() void TestProcessingGui::testSetGetConfig() { - const QList< const QgsProcessingAlgorithm * > algorithms = QgsApplication::processingRegistry()->algorithms(); + const QList algorithms = QgsApplication::processingRegistry()->algorithms(); // Find all defined widgets for native algorithms // and get the default configuration (that is, we create a widget @@ -536,11 +519,7 @@ void TestProcessingGui::testWrapperFactoryRegistry() TestParamType customParam( QStringLiteral( "custom" ), QStringLiteral( "custom" ) ); wrapper = registry.createParameterWidgetWrapper( &customParam, QgsProcessingGui::Standard ); QVERIFY( !wrapper ); - customParam.setMetadata( {{ - QStringLiteral( "widget_wrapper" ), QVariantMap( - {{QStringLiteral( "widget_type" ), QStringLiteral( "str" ) }} - ) - } + customParam.setMetadata( { { QStringLiteral( "widget_wrapper" ), QVariantMap( { { QStringLiteral( "widget_type" ), QStringLiteral( "str" ) } } ) } } ); wrapper = registry.createParameterWidgetWrapper( &customParam, QgsProcessingGui::Standard ); QVERIFY( wrapper ); @@ -607,19 +586,19 @@ void TestProcessingGui::testWrapperGeneral() QVERIFY( !falseDefault.widgetValue().toBool() ); delete w; - std::unique_ptr< QgsMapCanvas > mc = std::make_unique< QgsMapCanvas >(); + std::unique_ptr mc = std::make_unique(); QgsProcessingParameterWidgetContext widgetContext; widgetContext.setMapCanvas( mc.get() ); QCOMPARE( widgetContext.mapCanvas(), mc.get() ); - std::unique_ptr< QgsMessageBar > mb = std::make_unique< QgsMessageBar >(); + std::unique_ptr mb = std::make_unique(); widgetContext.setMessageBar( mb.get() ); QCOMPARE( widgetContext.messageBar(), mb.get() ); QgsProject p; widgetContext.setProject( &p ); QCOMPARE( widgetContext.project(), &p ); - std::unique_ptr< QgsProcessingModelAlgorithm > model = std::make_unique< QgsProcessingModelAlgorithm >(); + std::unique_ptr model = std::make_unique(); widgetContext.setModel( model.get() ); QCOMPARE( widgetContext.model(), model.get() ); widgetContext.setModelChildAlgorithmId( QStringLiteral( "xx" ) ); @@ -635,7 +614,6 @@ void TestProcessingGui::testWrapperGeneral() class TestProcessingContextGenerator : public QgsProcessingContextGenerator { public: - TestProcessingContextGenerator( QgsProcessingContext &context ) : mContext( context ) {} @@ -655,7 +633,7 @@ class TestLayerWrapper : public QgsAbstractProcessingParameterWidgetWrapper // c : QgsAbstractProcessingParameterWidgetWrapper( parameter ) {} QWidget *createWidget() override { return nullptr; } - void setWidgetValue( const QVariant &val, QgsProcessingContext & ) override { v = val;} + void setWidgetValue( const QVariant &val, QgsProcessingContext & ) override { v = val; } QVariant widgetValue() const override { return v; } QVariant v; @@ -672,17 +650,17 @@ void TestProcessingGui::testWrapperDynamic() QgsProcessingContext context; - std::unique_ptr< QWidget > allPartsWidget( allPartsWrapper.createWrappedWidget( context ) ); + std::unique_ptr allPartsWidget( allPartsWrapper.createWrappedWidget( context ) ); // dynamic parameter, so property button should be created QVERIFY( allPartsWrapper.mPropertyButton.data() != nullptr ); - std::unique_ptr< QWidget > inputWidget( inputWrapper.createWrappedWidget( context ) ); + std::unique_ptr inputWidget( inputWrapper.createWrappedWidget( context ) ); // not dynamic parameter, so property button should be NOT created QVERIFY( inputWrapper.mPropertyButton.data() == nullptr ); // set dynamic parameter to dynamic value allPartsWrapper.setParameterValue( QgsProperty::fromExpression( QStringLiteral( "1+2" ) ), context ); - QCOMPARE( allPartsWrapper.parameterValue().value< QgsProperty >().expressionString(), QStringLiteral( "1+2" ) ); + QCOMPARE( allPartsWrapper.parameterValue().value().expressionString(), QStringLiteral( "1+2" ) ); // not dynamic value allPartsWrapper.setParameterValue( true, context ); QCOMPARE( allPartsWrapper.parameterValue().toBool(), true ); @@ -785,23 +763,23 @@ void TestProcessingGui::testModelerWrapper() w = registry.createModelerParameterWidget( &model, QStringLiteral( "a" ), model.parameterDefinition( "p1" ), context ); QVERIFY( w ); // should default to static value - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); delete w; w = registry.createModelerParameterWidget( &model, QStringLiteral( "a" ), model.parameterDefinition( "p4" ), context ); QVERIFY( w ); // a layer parameter should default to "model input" type - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); delete w; // but an optionl layer parameter should NOT -- we don't want to autofill values for optional layers by default w = registry.createModelerParameterWidget( &model, QStringLiteral( "a" ), model.parameterDefinition( "p5" ), context ); QVERIFY( w ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); delete w; // widget tests w = new QgsProcessingModelerParameterWidget( &model, "alg1", model.parameterDefinition( "p1" ), context ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); QCOMPARE( w->parameterDefinition()->name(), QStringLiteral( "p1" ) ); QLabel *l = w->createLabel(); QVERIFY( l ); @@ -811,32 +789,32 @@ void TestProcessingGui::testModelerWrapper() // static value w->setWidgetValue( QgsProcessingModelChildParameterSource::fromStaticValue( true ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().staticValue().toBool(), true ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); + QCOMPARE( w->value().value().staticValue().toBool(), true ); w->setWidgetValue( QgsProcessingModelChildParameterSource::fromStaticValue( false ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().staticValue().toBool(), false ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); + QCOMPARE( w->value().value().staticValue().toBool(), false ); QCOMPARE( w->mStackedWidget->currentIndex(), 0 ); QCOMPARE( w->mSourceButton->toolTip(), QStringLiteral( "Value" ) ); // expression value w->setWidgetValue( QgsProcessingModelChildParameterSource::fromExpression( QStringLiteral( "1+2" ) ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::Expression ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().expression(), QStringLiteral( "1+2" ) ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::Expression ); + QCOMPARE( w->value().value().expression(), QStringLiteral( "1+2" ) ); QCOMPARE( w->mStackedWidget->currentIndex(), 1 ); QCOMPARE( w->mSourceButton->toolTip(), QStringLiteral( "Pre-calculated Value" ) ); // model input - should fail, because we haven't populated sources yet, and so have no compatible sources w->setWidgetValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "p1" ) ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); - QVERIFY( w->value().value< QgsProcessingModelChildParameterSource>().parameterName().isEmpty() ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); + QVERIFY( w->value().value().parameterName().isEmpty() ); QCOMPARE( w->mStackedWidget->currentIndex(), 2 ); QCOMPARE( w->mSourceButton->toolTip(), QStringLiteral( "Model Input" ) ); // alg output - should fail, because we haven't populated sources yet, and so have no compatible sources w->setWidgetValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg3" ), QStringLiteral( "OUTPUT" ) ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); - QVERIFY( w->value().value< QgsProcessingModelChildParameterSource>().outputChildId().isEmpty() ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); + QVERIFY( w->value().value().outputChildId().isEmpty() ); QCOMPARE( w->mStackedWidget->currentIndex(), 3 ); QCOMPARE( w->mSourceButton->toolTip(), QStringLiteral( "Algorithm Output" ) ); @@ -845,14 +823,14 @@ void TestProcessingGui::testModelerWrapper() // model input w->setWidgetValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "p1" ) ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().parameterName(), QStringLiteral( "p1" ) ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); + QCOMPARE( w->value().value().parameterName(), QStringLiteral( "p1" ) ); // alg output w->setWidgetValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg3" ), QStringLiteral( "OUTPUT" ) ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().outputChildId(), QStringLiteral( "alg3" ) ); - QCOMPARE( w->value().value< QgsProcessingModelChildParameterSource>().outputName(), QStringLiteral( "OUTPUT" ) ); + QCOMPARE( w->value().value().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); + QCOMPARE( w->value().value().outputChildId(), QStringLiteral( "alg3" ) ); + QCOMPARE( w->value().value().outputName(), QStringLiteral( "OUTPUT" ) ); // model output delete w; @@ -880,22 +858,18 @@ void TestProcessingGui::testModelerWrapper() w = new QgsProcessingModelerParameterWidget( &model, "alg4", layerDef, context ); - w->setWidgetValue( QList< QgsProcessingModelChildParameterSource>() - << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg3" ), QStringLiteral( "OUTPUT" ) ) - << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "p1" ) ) - << QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "something" ) ) ); + w->setWidgetValue( QList() << QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg3" ), QStringLiteral( "OUTPUT" ) ) << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "p1" ) ) << QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "something" ) ) ); QCOMPARE( w->value().toList().count(), 3 ); - QCOMPARE( w->value().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); - QCOMPARE( w->value().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); - QCOMPARE( w->value().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().outputChildId(), QStringLiteral( "alg3" ) ); - QCOMPARE( w->value().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().outputName(), QStringLiteral( "OUTPUT" ) ); - QCOMPARE( w->value().toList().at( 1 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); - QCOMPARE( w->value().toList().at( 1 ).value< QgsProcessingModelChildParameterSource>().parameterName(), QStringLiteral( "p1" ) ); - QCOMPARE( w->value().toList().at( 2 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); - QCOMPARE( w->value().toList().at( 2 ).value< QgsProcessingModelChildParameterSource>().staticValue().toString(), QStringLiteral( "something" ) ); + QCOMPARE( w->value().toList().at( 0 ).value().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); + QCOMPARE( w->value().toList().at( 0 ).value().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); + QCOMPARE( w->value().toList().at( 0 ).value().outputChildId(), QStringLiteral( "alg3" ) ); + QCOMPARE( w->value().toList().at( 0 ).value().outputName(), QStringLiteral( "OUTPUT" ) ); + QCOMPARE( w->value().toList().at( 1 ).value().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); + QCOMPARE( w->value().toList().at( 1 ).value().parameterName(), QStringLiteral( "p1" ) ); + QCOMPARE( w->value().toList().at( 2 ).value().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); + QCOMPARE( w->value().toList().at( 2 ).value().staticValue().toString(), QStringLiteral( "something" ) ); delete w; - } void TestProcessingGui::testHiddenWrapper() @@ -919,7 +893,7 @@ void TestProcessingGui::testHiddenWrapper() QVERIFY( !wrapper.createWrappedWidget( context ) ); QVERIFY( !wrapper.createWrappedLabel() ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); QVERIFY( !wrapper.linkedVectorLayer() ); wrapper.setLinkedVectorLayer( vl.get() ); QCOMPARE( wrapper.linkedVectorLayer(), vl.get() ); @@ -938,20 +912,20 @@ void TestProcessingGui::testBooleanWrapper() wrapper.setWidgetValue( true, context ); QCOMPARE( spy.count(), 1 ); QVERIFY( wrapper.widgetValue().toBool() ); - QVERIFY( static_cast< QCheckBox * >( wrapper.wrappedWidget() )->isChecked() ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->isChecked() ); wrapper.setWidgetValue( false, context ); QCOMPARE( spy.count(), 2 ); QVERIFY( !wrapper.widgetValue().toBool() ); - QVERIFY( !static_cast< QCheckBox * >( wrapper.wrappedWidget() )->isChecked() ); + QVERIFY( !static_cast( wrapper.wrappedWidget() )->isChecked() ); // should be no label in standard mode QVERIFY( !wrapper.createWrappedLabel() ); - QCOMPARE( static_cast< QCheckBox * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "bool" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "bool" ) ); // check signal - static_cast< QCheckBox * >( wrapper.wrappedWidget() )->setChecked( true ); + static_cast( wrapper.wrappedWidget() )->setChecked( true ); QCOMPARE( spy.count(), 3 ); - static_cast< QCheckBox * >( wrapper.wrappedWidget() )->setChecked( false ); + static_cast( wrapper.wrappedWidget() )->setChecked( false ); QCOMPARE( spy.count(), 4 ); delete w; @@ -964,16 +938,16 @@ void TestProcessingGui::testBooleanWrapper() wrapperB.setWidgetValue( true, context ); QCOMPARE( spy2.count(), 1 ); QVERIFY( wrapperB.widgetValue().toBool() ); - QVERIFY( static_cast< QComboBox * >( wrapperB.wrappedWidget() )->currentData().toBool() ); + QVERIFY( static_cast( wrapperB.wrappedWidget() )->currentData().toBool() ); wrapperB.setWidgetValue( false, context ); QCOMPARE( spy2.count(), 2 ); QVERIFY( !wrapperB.widgetValue().toBool() ); - QVERIFY( !static_cast< QComboBox * >( wrapperB.wrappedWidget() )->currentData().toBool() ); + QVERIFY( !static_cast( wrapperB.wrappedWidget() )->currentData().toBool() ); // check signal - static_cast< QComboBox * >( w )->setCurrentIndex( 0 ); + static_cast( w )->setCurrentIndex( 0 ); QCOMPARE( spy2.count(), 3 ); - static_cast< QComboBox * >( w )->setCurrentIndex( 1 ); + static_cast( w )->setCurrentIndex( 1 ); QCOMPARE( spy2.count(), 4 ); // should be no label in batch mode @@ -988,16 +962,16 @@ void TestProcessingGui::testBooleanWrapper() wrapperM.setWidgetValue( true, context ); QVERIFY( wrapperM.widgetValue().toBool() ); QCOMPARE( spy3.count(), 1 ); - QVERIFY( static_cast< QComboBox * >( wrapperM.wrappedWidget() )->currentData().toBool() ); + QVERIFY( static_cast( wrapperM.wrappedWidget() )->currentData().toBool() ); wrapperM.setWidgetValue( false, context ); QVERIFY( !wrapperM.widgetValue().toBool() ); QCOMPARE( spy3.count(), 2 ); - QVERIFY( !static_cast< QComboBox * >( wrapperM.wrappedWidget() )->currentData().toBool() ); + QVERIFY( !static_cast( wrapperM.wrappedWidget() )->currentData().toBool() ); // check signal - static_cast< QComboBox * >( w )->setCurrentIndex( 0 ); + static_cast( w )->setCurrentIndex( 0 ); QCOMPARE( spy3.count(), 3 ); - static_cast< QComboBox * >( w )->setCurrentIndex( 1 ); + static_cast( w )->setCurrentIndex( 1 ); QCOMPARE( spy3.count(), 4 ); // should be a label in modeler mode @@ -1010,30 +984,30 @@ void TestProcessingGui::testBooleanWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "boolean" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "boolean" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterBoolean boolParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), true, false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "boolean" ), context, widgetContext, &boolParam ); + widget = std::make_unique( QStringLiteral( "boolean" ), context, widgetContext, &boolParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( static_cast< QgsProcessingParameterBoolean * >( def.get() )->defaultValue().toBool() ); + QVERIFY( static_cast( def.get() )->defaultValue().toBool() ); boolParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); boolParam.setDefaultValue( false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "boolean" ), context, widgetContext, &boolParam ); + widget = std::make_unique( QStringLiteral( "boolean" ), context, widgetContext, &boolParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QVERIFY( !static_cast< QgsProcessingParameterBoolean * >( def.get() )->defaultValue().toBool() ); + QVERIFY( !static_cast( def.get() )->defaultValue().toBool() ); } void TestProcessingGui::testStringWrapper() @@ -1050,11 +1024,11 @@ void TestProcessingGui::testStringWrapper() wrapper.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "a" ) ); wrapper.setWidgetValue( QString(), context ); QCOMPARE( spy.count(), 2 ); QVERIFY( wrapper.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text().isEmpty() ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->text().isEmpty() ); QLabel *l = wrapper.createWrappedLabel(); QVERIFY( l ); @@ -1063,9 +1037,9 @@ void TestProcessingGui::testStringWrapper() delete l; // check signal - static_cast< QLineEdit * >( wrapper.wrappedWidget() )->setText( QStringLiteral( "b" ) ); + static_cast( wrapper.wrappedWidget() )->setText( QStringLiteral( "b" ) ); QCOMPARE( spy.count(), 3 ); - static_cast< QLineEdit * >( wrapper.wrappedWidget() )->clear(); + static_cast( wrapper.wrappedWidget() )->clear(); QCOMPARE( spy.count(), 4 ); delete w; @@ -1078,16 +1052,16 @@ void TestProcessingGui::testStringWrapper() wrapperB.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapperB.widgetValue().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapperB.wrappedWidget() )->text(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapperB.wrappedWidget() )->text(), QStringLiteral( "a" ) ); wrapperB.setWidgetValue( QString(), context ); QCOMPARE( spy2.count(), 2 ); QVERIFY( wrapperB.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QLineEdit * >( wrapperB.wrappedWidget() )->text().isEmpty() ); + QVERIFY( static_cast( wrapperB.wrappedWidget() )->text().isEmpty() ); // check signal - static_cast< QLineEdit * >( w )->setText( QStringLiteral( "x" ) ); + static_cast( w )->setText( QStringLiteral( "x" ) ); QCOMPARE( spy2.count(), 3 ); - static_cast< QLineEdit * >( w )->clear(); + static_cast( w )->clear(); QCOMPARE( spy2.count(), 4 ); // should be no label in batch mode @@ -1102,16 +1076,16 @@ void TestProcessingGui::testStringWrapper() wrapperM.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( wrapperM.widgetValue().toString(), QStringLiteral( "a" ) ); QCOMPARE( spy3.count(), 1 ); - QCOMPARE( static_cast< QLineEdit * >( wrapperM.wrappedWidget() )->text(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapperM.wrappedWidget() )->text(), QStringLiteral( "a" ) ); wrapperM.setWidgetValue( QString(), context ); QVERIFY( wrapperM.widgetValue().toString().isEmpty() ); QCOMPARE( spy3.count(), 2 ); - QVERIFY( static_cast< QLineEdit * >( wrapperM.wrappedWidget() )->text().isEmpty() ); + QVERIFY( static_cast( wrapperM.wrappedWidget() )->text().isEmpty() ); // check signal - static_cast< QLineEdit * >( w )->setText( QStringLiteral( "x" ) ); + static_cast( w )->setText( QStringLiteral( "x" ) ); QCOMPARE( spy3.count(), 3 ); - static_cast< QLineEdit * >( w )->clear(); + static_cast( w )->clear(); QCOMPARE( spy3.count(), 4 ); // should be a label in modeler mode @@ -1136,11 +1110,11 @@ void TestProcessingGui::testStringWrapper() wrapperMultiLine.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy4.count(), 1 ); QCOMPARE( wrapperMultiLine.widgetValue().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QPlainTextEdit * >( wrapperMultiLine.wrappedWidget() )->toPlainText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapperMultiLine.wrappedWidget() )->toPlainText(), QStringLiteral( "a" ) ); wrapperMultiLine.setWidgetValue( QString(), context ); QCOMPARE( spy4.count(), 2 ); QVERIFY( wrapperMultiLine.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QPlainTextEdit * >( wrapperMultiLine.wrappedWidget() )->toPlainText().isEmpty() ); + QVERIFY( static_cast( wrapperMultiLine.wrappedWidget() )->toPlainText().isEmpty() ); l = wrapper.createWrappedLabel(); QVERIFY( l ); @@ -1149,9 +1123,9 @@ void TestProcessingGui::testStringWrapper() delete l; // check signal - static_cast< QPlainTextEdit * >( wrapperMultiLine.wrappedWidget() )->setPlainText( QStringLiteral( "b" ) ); + static_cast( wrapperMultiLine.wrappedWidget() )->setPlainText( QStringLiteral( "b" ) ); QCOMPARE( spy4.count(), 3 ); - static_cast< QPlainTextEdit * >( wrapperMultiLine.wrappedWidget() )->clear(); + static_cast( wrapperMultiLine.wrappedWidget() )->clear(); QCOMPARE( spy4.count(), 4 ); delete w; @@ -1164,16 +1138,16 @@ void TestProcessingGui::testStringWrapper() wrapperMultiLineB.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy5.count(), 1 ); QCOMPARE( wrapperMultiLineB.widgetValue().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapperMultiLineB.wrappedWidget() )->text(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapperMultiLineB.wrappedWidget() )->text(), QStringLiteral( "a" ) ); wrapperMultiLineB.setWidgetValue( QString(), context ); QCOMPARE( spy5.count(), 2 ); QVERIFY( wrapperMultiLineB.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QLineEdit * >( wrapperMultiLineB.wrappedWidget() )->text().isEmpty() ); + QVERIFY( static_cast( wrapperMultiLineB.wrappedWidget() )->text().isEmpty() ); // check signal - static_cast< QLineEdit * >( w )->setText( QStringLiteral( "x" ) ); + static_cast( w )->setText( QStringLiteral( "x" ) ); QCOMPARE( spy5.count(), 3 ); - static_cast< QLineEdit * >( w )->clear(); + static_cast( w )->clear(); QCOMPARE( spy5.count(), 4 ); // should be no label in batch mode @@ -1188,16 +1162,16 @@ void TestProcessingGui::testStringWrapper() wrapperMultiLineM.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( wrapperMultiLineM.widgetValue().toString(), QStringLiteral( "a" ) ); QCOMPARE( spy6.count(), 1 ); - QCOMPARE( static_cast< QPlainTextEdit * >( wrapperMultiLineM.wrappedWidget() )->toPlainText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapperMultiLineM.wrappedWidget() )->toPlainText(), QStringLiteral( "a" ) ); wrapperMultiLineM.setWidgetValue( QString(), context ); QVERIFY( wrapperMultiLineM.widgetValue().toString().isEmpty() ); QCOMPARE( spy6.count(), 2 ); - QVERIFY( static_cast< QPlainTextEdit * >( wrapperMultiLineM.wrappedWidget() )->toPlainText().isEmpty() ); + QVERIFY( static_cast( wrapperMultiLineM.wrappedWidget() )->toPlainText().isEmpty() ); // check signal - static_cast< QPlainTextEdit * >( w )->setPlainText( QStringLiteral( "x" ) ); + static_cast( w )->setPlainText( QStringLiteral( "x" ) ); QCOMPARE( spy6.count(), 3 ); - static_cast< QPlainTextEdit * >( w )->clear(); + static_cast( w )->clear(); QCOMPARE( spy6.count(), 4 ); // should be a label in modeler mode @@ -1213,16 +1187,7 @@ void TestProcessingGui::testStringWrapper() // with value hints // param = QgsProcessingParameterString( QStringLiteral( "string" ), QStringLiteral( "string" ), QVariant() ); - param.setMetadata( { { - QStringLiteral( "widget_wrapper" ), - QVariantMap( - { { - QStringLiteral( "value_hints" ), - QStringList() << "value 1" << "value 2" << "value 3" - } - } - ) - } + param.setMetadata( { { QStringLiteral( "widget_wrapper" ), QVariantMap( { { QStringLiteral( "value_hints" ), QStringList() << "value 1" << "value 2" << "value 3" } } ) } } ); QgsProcessingStringWidgetWrapper wrapperHints( ¶m ); @@ -1233,17 +1198,17 @@ void TestProcessingGui::testStringWrapper() wrapperHints.setWidgetValue( QStringLiteral( "value 2" ), context ); QCOMPARE( spy7.count(), 1 ); QCOMPARE( wrapperHints.widgetValue().toString(), QStringLiteral( "value 2" ) ); - QCOMPARE( qgis::down_cast< QComboBox * >( wrapperHints.wrappedWidget() )->currentText(), QStringLiteral( "value 2" ) ); + QCOMPARE( qgis::down_cast( wrapperHints.wrappedWidget() )->currentText(), QStringLiteral( "value 2" ) ); wrapperHints.setWidgetValue( QStringLiteral( "value 3" ), context ); QCOMPARE( spy7.count(), 2 ); QCOMPARE( wrapperHints.widgetValue().toString(), QStringLiteral( "value 3" ) ); - QCOMPARE( qgis::down_cast< QComboBox * >( wrapperHints.wrappedWidget() )->currentText(), QStringLiteral( "value 3" ) ); + QCOMPARE( qgis::down_cast( wrapperHints.wrappedWidget() )->currentText(), QStringLiteral( "value 3" ) ); // set to value which is not present -- should fallback to first value wrapperHints.setWidgetValue( QStringLiteral( "value 4" ), context ); QCOMPARE( spy7.count(), 3 ); QCOMPARE( wrapperHints.widgetValue().toString(), QStringLiteral( "value 1" ) ); - QCOMPARE( qgis::down_cast< QComboBox * >( wrapperHints.wrappedWidget() )->currentText(), QStringLiteral( "value 1" ) ); + QCOMPARE( qgis::down_cast( wrapperHints.wrappedWidget() )->currentText(), QStringLiteral( "value 1" ) ); l = wrapperHints.createWrappedLabel(); QVERIFY( l ); @@ -1252,25 +1217,16 @@ void TestProcessingGui::testStringWrapper() delete l; // check signal - qgis::down_cast< QComboBox * >( wrapperHints.wrappedWidget() )->setCurrentIndex( 1 ); + qgis::down_cast( wrapperHints.wrappedWidget() )->setCurrentIndex( 1 ); QCOMPARE( spy7.count(), 4 ); - qgis::down_cast< QComboBox * >( wrapperHints.wrappedWidget() )->setCurrentIndex( 2 ); + qgis::down_cast( wrapperHints.wrappedWidget() )->setCurrentIndex( 2 ); QCOMPARE( spy7.count(), 5 ); delete w; // with value hints, optional param param = QgsProcessingParameterString( QStringLiteral( "string" ), QStringLiteral( "string" ), QVariant(), false, true ); - param.setMetadata( { { - QStringLiteral( "widget_wrapper" ), - QVariantMap( - { { - QStringLiteral( "value_hints" ), - QStringList() << "value 1" << "value 2" << "value 3" - } - } - ) - } + param.setMetadata( { { QStringLiteral( "widget_wrapper" ), QVariantMap( { { QStringLiteral( "value_hints" ), QStringList() << "value 1" << "value 2" << "value 3" } } ) } } ); QgsProcessingStringWidgetWrapper wrapperHintsOptional( ¶m ); @@ -1281,21 +1237,21 @@ void TestProcessingGui::testStringWrapper() wrapperHintsOptional.setWidgetValue( QStringLiteral( "value 2" ), context ); QCOMPARE( spy8.count(), 1 ); QCOMPARE( wrapperHintsOptional.widgetValue().toString(), QStringLiteral( "value 2" ) ); - QCOMPARE( qgis::down_cast< QComboBox * >( wrapperHintsOptional.wrappedWidget() )->currentText(), QStringLiteral( "value 2" ) ); + QCOMPARE( qgis::down_cast( wrapperHintsOptional.wrappedWidget() )->currentText(), QStringLiteral( "value 2" ) ); wrapperHintsOptional.setWidgetValue( QVariant(), context ); QCOMPARE( spy8.count(), 2 ); QVERIFY( !wrapperHintsOptional.widgetValue().isValid() ); - QCOMPARE( qgis::down_cast< QComboBox * >( wrapperHintsOptional.wrappedWidget() )->currentText(), QString() ); + QCOMPARE( qgis::down_cast( wrapperHintsOptional.wrappedWidget() )->currentText(), QString() ); wrapperHintsOptional.setWidgetValue( QStringLiteral( "value 3" ), context ); QCOMPARE( spy8.count(), 3 ); QCOMPARE( wrapperHintsOptional.widgetValue().toString(), QStringLiteral( "value 3" ) ); - QCOMPARE( qgis::down_cast< QComboBox * >( wrapperHintsOptional.wrappedWidget() )->currentText(), QStringLiteral( "value 3" ) ); + QCOMPARE( qgis::down_cast( wrapperHintsOptional.wrappedWidget() )->currentText(), QStringLiteral( "value 3" ) ); // set to value which is not present -- should fallback to first value ("not set") wrapperHintsOptional.setWidgetValue( QStringLiteral( "value 4" ), context ); QCOMPARE( spy8.count(), 4 ); QVERIFY( !wrapperHintsOptional.widgetValue().isValid() ); - QCOMPARE( qgis::down_cast< QComboBox * >( wrapperHintsOptional.wrappedWidget() )->currentText(), QString() ); + QCOMPARE( qgis::down_cast( wrapperHintsOptional.wrappedWidget() )->currentText(), QString() ); l = wrapperHintsOptional.createWrappedLabel(); QVERIFY( l ); @@ -1304,9 +1260,9 @@ void TestProcessingGui::testStringWrapper() delete l; // check signal - qgis::down_cast< QComboBox * >( wrapperHintsOptional.wrappedWidget() )->setCurrentIndex( 1 ); + qgis::down_cast( wrapperHintsOptional.wrappedWidget() )->setCurrentIndex( 1 ); QCOMPARE( spy8.count(), 5 ); - qgis::down_cast< QComboBox * >( wrapperHintsOptional.wrappedWidget() )->setCurrentIndex( 2 ); + qgis::down_cast( wrapperHintsOptional.wrappedWidget() )->setCurrentIndex( 2 ); QCOMPARE( spy8.count(), 6 ); delete w; @@ -1314,40 +1270,39 @@ void TestProcessingGui::testStringWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "string" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "string" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( !static_cast< QgsProcessingParameterString * >( def.get() )->multiLine() ); + QVERIFY( !static_cast( def.get() )->multiLine() ); // using a parameter definition as initial values QgsProcessingParameterString stringParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "aaa" ), true ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "string" ), context, widgetContext, &stringParam ); + widget = std::make_unique( QStringLiteral( "string" ), context, widgetContext, &stringParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( static_cast< QgsProcessingParameterString * >( def.get() )->multiLine() ); - QCOMPARE( static_cast< QgsProcessingParameterString * >( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); + QVERIFY( static_cast( def.get() )->multiLine() ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); stringParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); stringParam.setMultiLine( false ); stringParam.setDefaultValue( QString() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "string" ), context, widgetContext, &stringParam ); + widget = std::make_unique( QStringLiteral( "string" ), context, widgetContext, &stringParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QVERIFY( static_cast< QgsProcessingParameterString * >( def.get() )->defaultValue().toString().isEmpty() ); - QVERIFY( !static_cast< QgsProcessingParameterString * >( def.get() )->multiLine() ); + QVERIFY( static_cast( def.get() )->defaultValue().toString().isEmpty() ); + QVERIFY( !static_cast( def.get() )->multiLine() ); } void TestProcessingGui::testFileWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterFile param( QStringLiteral( "file" ), QStringLiteral( "file" ) ); QgsProcessingFileWidgetWrapper wrapper( ¶m, type ); @@ -1359,13 +1314,13 @@ void TestProcessingGui::testFileWrapper() wrapper.setWidgetValue( QString( TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ), context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ) ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->filePath(), QString( TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ) ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->filter(), QStringLiteral( "All files (*.*)" ) ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->storageMode(), QgsFileWidget::GetFile ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->filePath(), QString( TEST_DATA_DIR + QStringLiteral( "/points.shp" ) ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->filter(), QStringLiteral( "All files (*.*)" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->storageMode(), QgsFileWidget::GetFile ); wrapper.setWidgetValue( QString(), context ); QCOMPARE( spy.count(), 2 ); QVERIFY( wrapper.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->filePath().isEmpty() ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->filePath().isEmpty() ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -1381,7 +1336,7 @@ void TestProcessingGui::testFileWrapper() } // check signal - static_cast< QgsFileWidget * >( wrapper.wrappedWidget() )->setFilePath( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ) ); + static_cast( wrapper.wrappedWidget() )->setFilePath( TEST_DATA_DIR + QStringLiteral( "/polys.shp" ) ); QCOMPARE( spy.count(), 3 ); delete w; @@ -1391,23 +1346,23 @@ void TestProcessingGui::testFileWrapper() QgsProcessingFileWidgetWrapper wrapper2( ¶m2, type ); w = wrapper2.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper2.wrappedWidget() )->filter(), QStringLiteral( "QML files (*.qml)" ) ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper2.wrappedWidget() )->storageMode(), QgsFileWidget::GetFile ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->filter(), QStringLiteral( "QML files (*.qml)" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->storageMode(), QgsFileWidget::GetFile ); // with filter QgsProcessingParameterFile param3( QStringLiteral( "file" ), QStringLiteral( "file" ), Qgis::ProcessingFileParameterBehavior::File, QString(), QVariant(), false, QStringLiteral( "Project files (*.qgs *.qgz)" ) ); - QgsProcessingFileWidgetWrapper wrapper3( & param3, type ); + QgsProcessingFileWidgetWrapper wrapper3( ¶m3, type ); w = wrapper3.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper3.wrappedWidget() )->filter(), QStringLiteral( "Project files (*.qgs *.qgz)" ) ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper3.wrappedWidget() )->storageMode(), QgsFileWidget::GetFile ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->filter(), QStringLiteral( "Project files (*.qgs *.qgz)" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->storageMode(), QgsFileWidget::GetFile ); // folder mode QgsProcessingParameterFile param4( QStringLiteral( "folder" ), QStringLiteral( "folder" ), Qgis::ProcessingFileParameterBehavior::Folder ); QgsProcessingFileWidgetWrapper wrapper4( ¶m4, type ); w = wrapper4.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsFileWidget * >( wrapper4.wrappedWidget() )->storageMode(), QgsFileWidget::GetDirectory ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->storageMode(), QgsFileWidget::GetDirectory ); }; // standard wrapper @@ -1423,39 +1378,39 @@ void TestProcessingGui::testFileWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "file" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "file" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterFile fileParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), Qgis::ProcessingFileParameterBehavior::File ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "file" ), context, widgetContext, &fileParam ); + widget = std::make_unique( QStringLiteral( "file" ), context, widgetContext, &fileParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterFile * >( def.get() )->behavior(), Qgis::ProcessingFileParameterBehavior::File ); - QVERIFY( !static_cast< QgsProcessingParameterFile * >( def.get() )->defaultValue().isValid() ); - QCOMPARE( static_cast< QgsProcessingParameterFile * >( def.get() )->fileFilter(), QStringLiteral( "All files (*.*)" ) ); + QCOMPARE( static_cast( def.get() )->behavior(), Qgis::ProcessingFileParameterBehavior::File ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); + QCOMPARE( static_cast( def.get() )->fileFilter(), QStringLiteral( "All files (*.*)" ) ); fileParam.setFileFilter( QStringLiteral( "TAB files (*.tab)" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "file" ), context, widgetContext, &fileParam ); + widget = std::make_unique( QStringLiteral( "file" ), context, widgetContext, &fileParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); - QCOMPARE( static_cast< QgsProcessingParameterFile * >( def.get() )->fileFilter(), QStringLiteral( "TAB files (*.tab)" ) ); + QCOMPARE( static_cast( def.get() )->fileFilter(), QStringLiteral( "TAB files (*.tab)" ) ); fileParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); fileParam.setBehavior( Qgis::ProcessingFileParameterBehavior::Folder ); fileParam.setDefaultValue( QStringLiteral( "my path" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "file" ), context, widgetContext, &fileParam ); + widget = std::make_unique( QStringLiteral( "file" ), context, widgetContext, &fileParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterFile * >( def.get() )->behavior(), Qgis::ProcessingFileParameterBehavior::Folder ); - QCOMPARE( static_cast< QgsProcessingParameterFile * >( def.get() )->defaultValue().toString(), QStringLiteral( "my path" ) ); + QCOMPARE( static_cast( def.get() )->behavior(), Qgis::ProcessingFileParameterBehavior::Folder ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "my path" ) ); } void TestProcessingGui::testAuthCfgWrapper() @@ -1509,15 +1464,15 @@ void TestProcessingGui::testAuthCfgWrapper() wrapper.setWidgetValue( authIds.at( 0 ), context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), authIds.at( 0 ) ); - QCOMPARE( static_cast< QgsAuthConfigSelect * >( wrapper.wrappedWidget() )->configId(), authIds.at( 0 ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->configId(), authIds.at( 0 ) ); wrapper.setWidgetValue( authIds.at( 1 ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), authIds.at( 1 ) ); - QCOMPARE( static_cast< QgsAuthConfigSelect * >( wrapper.wrappedWidget() )->configId(), authIds.at( 1 ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->configId(), authIds.at( 1 ) ); wrapper.setWidgetValue( QString(), context ); QCOMPARE( spy.count(), 3 ); QVERIFY( wrapper.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsAuthConfigSelect * >( wrapper.wrappedWidget() )->configId().isEmpty() ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->configId().isEmpty() ); QLabel *l = wrapper.createWrappedLabel(); QVERIFY( l ); @@ -1526,7 +1481,7 @@ void TestProcessingGui::testAuthCfgWrapper() delete l; // check signal - static_cast< QgsAuthConfigSelect * >( wrapper.wrappedWidget() )->setConfigId( authIds.at( 0 ) ); + static_cast( wrapper.wrappedWidget() )->setConfigId( authIds.at( 0 ) ); QCOMPARE( spy.count(), 4 ); delete w; @@ -1539,14 +1494,14 @@ void TestProcessingGui::testAuthCfgWrapper() wrapperB.setWidgetValue( authIds.at( 0 ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapperB.widgetValue().toString(), authIds.at( 0 ) ); - QCOMPARE( static_cast< QgsAuthConfigSelect * >( wrapperB.wrappedWidget() )->configId(), authIds.at( 0 ) ); + QCOMPARE( static_cast( wrapperB.wrappedWidget() )->configId(), authIds.at( 0 ) ); wrapperB.setWidgetValue( QString(), context ); QCOMPARE( spy2.count(), 2 ); QVERIFY( wrapperB.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsAuthConfigSelect * >( wrapperB.wrappedWidget() )->configId().isEmpty() ); + QVERIFY( static_cast( wrapperB.wrappedWidget() )->configId().isEmpty() ); // check signal - static_cast< QgsAuthConfigSelect * >( w )->setConfigId( authIds.at( 0 ) ); + static_cast( w )->setConfigId( authIds.at( 0 ) ); QCOMPARE( spy2.count(), 3 ); // should be no label in batch mode @@ -1561,14 +1516,14 @@ void TestProcessingGui::testAuthCfgWrapper() wrapperM.setWidgetValue( authIds.at( 0 ), context ); QCOMPARE( wrapperM.widgetValue().toString(), authIds.at( 0 ) ); QCOMPARE( spy3.count(), 1 ); - QCOMPARE( static_cast< QgsAuthConfigSelect * >( wrapperM.wrappedWidget() )->configId(), authIds.at( 0 ) ); + QCOMPARE( static_cast( wrapperM.wrappedWidget() )->configId(), authIds.at( 0 ) ); wrapperM.setWidgetValue( QString(), context ); QVERIFY( wrapperM.widgetValue().toString().isEmpty() ); QCOMPARE( spy3.count(), 2 ); - QVERIFY( static_cast< QgsAuthConfigSelect * >( wrapperM.wrappedWidget() )->configId().isEmpty() ); + QVERIFY( static_cast( wrapperM.wrappedWidget() )->configId().isEmpty() ); // check signal - static_cast< QgsAuthConfigSelect * >( w )->setConfigId( authIds.at( 0 ) ); + static_cast( w )->setConfigId( authIds.at( 0 ) ); QCOMPARE( spy3.count(), 3 ); // should be a label in modeler mode @@ -1593,16 +1548,16 @@ void TestProcessingGui::testCrsWrapper() QSignalSpy spy( &wrapper, &QgsProcessingCrsWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QStringLiteral( "epsg:3111" ), context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().value< QgsCoordinateReferenceSystem >().authid(), QStringLiteral( "EPSG:3111" ) ); - QCOMPARE( static_cast< QgsProjectionSelectionWidget * >( wrapper.wrappedWidget() )->crs().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( wrapper.widgetValue().value().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->crs().authid(), QStringLiteral( "EPSG:3111" ) ); wrapper.setWidgetValue( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ), context ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( wrapper.widgetValue().value< QgsCoordinateReferenceSystem >().authid(), QStringLiteral( "EPSG:28356" ) ); - QCOMPARE( static_cast< QgsProjectionSelectionWidget * >( wrapper.wrappedWidget() )->crs().authid(), QStringLiteral( "EPSG:28356" ) ); + QCOMPARE( wrapper.widgetValue().value().authid(), QStringLiteral( "EPSG:28356" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->crs().authid(), QStringLiteral( "EPSG:28356" ) ); wrapper.setWidgetValue( QString(), context ); QCOMPARE( spy.count(), 3 ); - QVERIFY( !wrapper.widgetValue().value< QgsCoordinateReferenceSystem >().isValid() ); - QVERIFY( !static_cast< QgsProjectionSelectionWidget * >( wrapper.wrappedWidget() )->crs().isValid() ); + QVERIFY( !wrapper.widgetValue().value().isValid() ); + QVERIFY( !static_cast( wrapper.wrappedWidget() )->crs().isValid() ); QLabel *l = wrapper.createWrappedLabel(); QVERIFY( l ); @@ -1611,9 +1566,9 @@ void TestProcessingGui::testCrsWrapper() delete l; // check signal - static_cast< QgsProjectionSelectionWidget * >( wrapper.wrappedWidget() )->setCrs( QgsCoordinateReferenceSystem( "EPSG:3857" ) ); + static_cast( wrapper.wrappedWidget() )->setCrs( QgsCoordinateReferenceSystem( "EPSG:3857" ) ); QCOMPARE( spy.count(), 4 ); - static_cast< QgsProjectionSelectionWidget * >( wrapper.wrappedWidget() )->setCrs( QgsCoordinateReferenceSystem() ); + static_cast( wrapper.wrappedWidget() )->setCrs( QgsCoordinateReferenceSystem() ); QCOMPARE( spy.count(), 5 ); delete w; @@ -1625,17 +1580,17 @@ void TestProcessingGui::testCrsWrapper() QSignalSpy spy2( &wrapperB, &QgsProcessingCrsWidgetWrapper::widgetValueHasChanged ); wrapperB.setWidgetValue( QStringLiteral( "epsg:3111" ), context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapperB.widgetValue().value< QgsCoordinateReferenceSystem >().authid(), QStringLiteral( "EPSG:3111" ) ); - QCOMPARE( static_cast< QgsProjectionSelectionWidget * >( wrapperB.wrappedWidget() )->crs().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( wrapperB.widgetValue().value().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( static_cast( wrapperB.wrappedWidget() )->crs().authid(), QStringLiteral( "EPSG:3111" ) ); wrapperB.setWidgetValue( QgsCoordinateReferenceSystem(), context ); QCOMPARE( spy2.count(), 2 ); - QVERIFY( !wrapperB.widgetValue().value< QgsCoordinateReferenceSystem >().isValid() ); - QVERIFY( !static_cast< QgsProjectionSelectionWidget * >( wrapperB.wrappedWidget() )->crs().isValid() ); + QVERIFY( !wrapperB.widgetValue().value().isValid() ); + QVERIFY( !static_cast( wrapperB.wrappedWidget() )->crs().isValid() ); // check signal - static_cast< QgsProjectionSelectionWidget * >( w )->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ) ); + static_cast( w )->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ) ); QCOMPARE( spy2.count(), 3 ); - static_cast< QgsProjectionSelectionWidget * >( w )->setCrs( QgsCoordinateReferenceSystem() ); + static_cast( w )->setCrs( QgsCoordinateReferenceSystem() ); QCOMPARE( spy2.count(), 4 ); // should be no label in batch mode @@ -1648,12 +1603,12 @@ void TestProcessingGui::testCrsWrapper() w = wrapperM.createWrappedWidget( context ); QSignalSpy spy3( &wrapperM, &QgsProcessingCrsWidgetWrapper::widgetValueHasChanged ); wrapperM.setWidgetValue( QStringLiteral( "epsg:3111" ), context ); - QCOMPARE( wrapperM.widgetValue().value< QgsCoordinateReferenceSystem >().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( wrapperM.widgetValue().value().authid(), QStringLiteral( "EPSG:3111" ) ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapperM.mProjectionSelectionWidget->crs().authid(), QStringLiteral( "EPSG:3111" ) ); QVERIFY( !wrapperM.mUseProjectCrsCheckBox->isChecked() ); wrapperM.setWidgetValue( QgsCoordinateReferenceSystem(), context ); - QVERIFY( !wrapperM.widgetValue().value< QgsCoordinateReferenceSystem >().isValid() ); + QVERIFY( !wrapperM.widgetValue().value().isValid() ); QCOMPARE( spy3.count(), 2 ); QVERIFY( !wrapperM.mProjectionSelectionWidget->crs().isValid() ); QVERIFY( !wrapperM.mUseProjectCrsCheckBox->isChecked() ); @@ -1680,62 +1635,61 @@ void TestProcessingGui::testCrsWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "crs" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "crs" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterCrs crsParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "EPSG:4326" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "crs" ), context, widgetContext, &crsParam ); + widget = std::make_unique( QStringLiteral( "crs" ), context, widgetContext, &crsParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterCrs * >( def.get() )->defaultValue().toString(), QStringLiteral( "EPSG:4326" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "EPSG:4326" ) ); crsParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); crsParam.setDefaultValue( QStringLiteral( "EPSG:3111" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "crs" ), context, widgetContext, &crsParam ); + widget = std::make_unique( QStringLiteral( "crs" ), context, widgetContext, &crsParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterCrs * >( def.get() )->defaultValue().toString(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "EPSG:3111" ) ); } void TestProcessingGui::testNumericWrapperDouble() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingContext context; QgsProcessingParameterNumber param( QStringLiteral( "num" ), QStringLiteral( "num" ), Qgis::ProcessingNumberParameterType::Double ); QgsProcessingNumericWidgetWrapper wrapper( ¶m, type ); QWidget *w = wrapper.createWrappedWidget( context ); - QVERIFY( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->expressionsEnabled() ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->decimals(), 6 ); // you can change this, if it's an intentional change! - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->singleStep(), 1.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->minimum(), -999999999.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->maximum(), 999999999.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->clearValue(), 0.0 ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->expressionsEnabled() ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->decimals(), 6 ); // you can change this, if it's an intentional change! + QCOMPARE( static_cast( wrapper.wrappedWidget() )->singleStep(), 1.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->minimum(), -999999999.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->maximum(), 999999999.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->clearValue(), 0.0 ); QSignalSpy spy( &wrapper, &QgsProcessingNumericWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( 5, context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toDouble(), 5.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->value(), 5.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 5.0 ); wrapper.setWidgetValue( QStringLiteral( "28356" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toDouble(), 28356.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->value(), 28356.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 28356.0 ); wrapper.setWidgetValue( QVariant(), context ); // not optional, so shouldn't work QCOMPARE( spy.count(), 3 ); QCOMPARE( wrapper.widgetValue().toDouble(), 0.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->value(), 0.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 0.0 ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -1751,12 +1705,12 @@ void TestProcessingGui::testNumericWrapperDouble() } // check signal - static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->setValue( 37.0 ); + static_cast( wrapper.wrappedWidget() )->setValue( 37.0 ); QCOMPARE( spy.count(), 4 ); - static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->clear(); + static_cast( wrapper.wrappedWidget() )->clear(); QCOMPARE( spy.count(), 5 ); QCOMPARE( wrapper.widgetValue().toDouble(), 0.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapper.wrappedWidget() )->value(), 0.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 0.0 ); delete w; @@ -1767,10 +1721,10 @@ void TestProcessingGui::testNumericWrapperDouble() QgsProcessingNumericWidgetWrapper wrapperMin( ¶mMin, type ); w = wrapperMin.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMin.wrappedWidget() )->singleStep(), 1.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMin.wrappedWidget() )->minimum(), -5.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMin.wrappedWidget() )->maximum(), 999999999.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMin.wrappedWidget() )->clearValue(), -5.0 ); + QCOMPARE( static_cast( wrapperMin.wrappedWidget() )->singleStep(), 1.0 ); + QCOMPARE( static_cast( wrapperMin.wrappedWidget() )->minimum(), -5.0 ); + QCOMPARE( static_cast( wrapperMin.wrappedWidget() )->maximum(), 999999999.0 ); + QCOMPARE( static_cast( wrapperMin.wrappedWidget() )->clearValue(), -5.0 ); QCOMPARE( wrapperMin.parameterValue().toDouble(), 0.0 ); delete w; @@ -1781,10 +1735,10 @@ void TestProcessingGui::testNumericWrapperDouble() QgsProcessingNumericWidgetWrapper wrapperMax( ¶mMax, type ); w = wrapperMax.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMax.wrappedWidget() )->singleStep(), 1.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMax.wrappedWidget() )->minimum(), -999999999.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMax.wrappedWidget() )->maximum(), 5.0 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMax.wrappedWidget() )->clearValue(), 0.0 ); + QCOMPARE( static_cast( wrapperMax.wrappedWidget() )->singleStep(), 1.0 ); + QCOMPARE( static_cast( wrapperMax.wrappedWidget() )->minimum(), -999999999.0 ); + QCOMPARE( static_cast( wrapperMax.wrappedWidget() )->maximum(), 5.0 ); + QCOMPARE( static_cast( wrapperMax.wrappedWidget() )->clearValue(), 0.0 ); QCOMPARE( wrapperMax.parameterValue().toDouble(), 0.0 ); delete w; @@ -1796,10 +1750,10 @@ void TestProcessingGui::testNumericWrapperDouble() QgsProcessingNumericWidgetWrapper wrapperMinMax( ¶mMinMax, type ); w = wrapperMinMax.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMinMax.wrappedWidget() )->singleStep(), 0.02 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMinMax.wrappedWidget() )->minimum(), -.1 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMinMax.wrappedWidget() )->maximum(), .1 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperMinMax.wrappedWidget() )->clearValue(), -.1 ); + QCOMPARE( static_cast( wrapperMinMax.wrappedWidget() )->singleStep(), 0.02 ); + QCOMPARE( static_cast( wrapperMinMax.wrappedWidget() )->minimum(), -.1 ); + QCOMPARE( static_cast( wrapperMinMax.wrappedWidget() )->maximum(), .1 ); + QCOMPARE( static_cast( wrapperMinMax.wrappedWidget() )->clearValue(), -.1 ); QCOMPARE( wrapperMinMax.parameterValue().toDouble(), 0.0 ); delete w; @@ -1810,7 +1764,7 @@ void TestProcessingGui::testNumericWrapperDouble() QgsProcessingNumericWidgetWrapper wrapperDefault( ¶mDefault, type ); w = wrapperDefault.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperDefault.wrappedWidget() )->clearValue(), 55.0 ); + QCOMPARE( static_cast( wrapperDefault.wrappedWidget() )->clearValue(), 55.0 ); QCOMPARE( wrapperDefault.parameterValue().toDouble(), 55.0 ); delete w; @@ -1820,14 +1774,14 @@ void TestProcessingGui::testNumericWrapperDouble() QgsProcessingNumericWidgetWrapper wrapperOptional( ¶mOptional, type ); w = wrapperOptional.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperOptional.wrappedWidget() )->clearValue(), -1000000000.0 ); + QCOMPARE( static_cast( wrapperOptional.wrappedWidget() )->clearValue(), -1000000000.0 ); QVERIFY( !wrapperOptional.parameterValue().isValid() ); wrapperOptional.setParameterValue( 5, context ); QCOMPARE( wrapperOptional.parameterValue().toDouble(), 5.0 ); wrapperOptional.setParameterValue( QVariant(), context ); QVERIFY( !wrapperOptional.parameterValue().isValid() ); wrapperOptional.setParameterValue( 5, context ); - static_cast< QgsDoubleSpinBox * >( wrapperOptional.wrappedWidget() )->clear(); + static_cast( wrapperOptional.wrappedWidget() )->clear(); QVERIFY( !wrapperOptional.parameterValue().isValid() ); // optional, with default @@ -1835,16 +1789,16 @@ void TestProcessingGui::testNumericWrapperDouble() QgsProcessingNumericWidgetWrapper wrapperOptionalDefault( ¶mOptional, type ); w = wrapperOptionalDefault.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperOptionalDefault.wrappedWidget() )->clearValue(), -1000000000.0 ); + QCOMPARE( static_cast( wrapperOptionalDefault.wrappedWidget() )->clearValue(), -1000000000.0 ); QCOMPARE( wrapperOptionalDefault.parameterValue().toDouble(), 3.0 ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toDouble(), 5.0 ); wrapperOptionalDefault.setParameterValue( QVariant(), context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperOptionalDefault.wrappedWidget() )->value(), -1000000000.0 ); + QCOMPARE( static_cast( wrapperOptionalDefault.wrappedWidget() )->value(), -1000000000.0 ); QVERIFY( !wrapperOptionalDefault.parameterValue().isValid() ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toDouble(), 5.0 ); - static_cast< QgsDoubleSpinBox * >( wrapperOptionalDefault.wrappedWidget() )->clear(); + static_cast( wrapperOptionalDefault.wrappedWidget() )->clear(); QVERIFY( !wrapperOptionalDefault.parameterValue().isValid() ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toDouble(), 5.0 ); @@ -1860,8 +1814,8 @@ void TestProcessingGui::testNumericWrapperDouble() paramDecimals.setMetadata( metadata ); QgsProcessingNumericWidgetWrapper wrapperDecimals( ¶mDecimals, type ); w = wrapperDecimals.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperDecimals.wrappedWidget() )->decimals(), 2 ); - QCOMPARE( static_cast< QgsDoubleSpinBox * >( wrapperDecimals.wrappedWidget() )->singleStep(), 0.01 ); // single step should never be less than set number of decimals + QCOMPARE( static_cast( wrapperDecimals.wrappedWidget() )->decimals(), 2 ); + QCOMPARE( static_cast( wrapperDecimals.wrappedWidget() )->singleStep(), 0.01 ); // single step should never be less than set number of decimals delete w; }; @@ -1877,8 +1831,8 @@ void TestProcessingGui::testNumericWrapperDouble() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -1887,61 +1841,60 @@ void TestProcessingGui::testNumericWrapperDouble() QgsProcessingParameterNumber numParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), Qgis::ProcessingNumberParameterType::Double, 1.0 ); numParam.setMinimum( 0 ); numParam.setMaximum( 10 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext, &numParam ); + widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext, &numParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->minimum(), 0.0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->maximum(), 10.0 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); + QCOMPARE( static_cast( def.get() )->minimum(), 0.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 10.0 ); numParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); numParam.setDataType( Qgis::ProcessingNumberParameterType::Integer ); numParam.setMinimum( -1 ); numParam.setMaximum( 1 ); numParam.setDefaultValue( 0 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext, &numParam ); + widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext, &numParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->defaultValue().toInt(), 0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->minimum(), -1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->maximum(), 1.0 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toInt(), 0 ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); + QCOMPARE( static_cast( def.get() )->minimum(), -1.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 1.0 ); } void TestProcessingGui::testNumericWrapperInt() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingContext context; QgsProcessingParameterNumber param( QStringLiteral( "num" ), QStringLiteral( "num" ), Qgis::ProcessingNumberParameterType::Integer ); QgsProcessingNumericWidgetWrapper wrapper( ¶m, type ); QWidget *w = wrapper.createWrappedWidget( context ); - QVERIFY( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->expressionsEnabled() ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->minimum(), -999999999 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->maximum(), 999999999 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->clearValue(), 0 ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->expressionsEnabled() ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->minimum(), -999999999 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->maximum(), 999999999 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->clearValue(), 0 ); QSignalSpy spy( &wrapper, &QgsProcessingNumericWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( 5, context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toInt(), 5 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->value(), 5 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 5 ); wrapper.setWidgetValue( QStringLiteral( "28356" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toInt(), 28356 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->value(), 28356 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 28356 ); wrapper.setWidgetValue( QVariant(), context ); // not optional, so shouldn't work QCOMPARE( spy.count(), 3 ); QCOMPARE( wrapper.widgetValue().toInt(), 0 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->value(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 0 ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -1957,12 +1910,12 @@ void TestProcessingGui::testNumericWrapperInt() } // check signal - static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->setValue( 37 ); + static_cast( wrapper.wrappedWidget() )->setValue( 37 ); QCOMPARE( spy.count(), 4 ); - static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->clear(); + static_cast( wrapper.wrappedWidget() )->clear(); QCOMPARE( spy.count(), 5 ); QCOMPARE( wrapper.widgetValue().toInt(), 0 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapper.wrappedWidget() )->value(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value(), 0 ); delete w; @@ -1973,9 +1926,9 @@ void TestProcessingGui::testNumericWrapperInt() QgsProcessingNumericWidgetWrapper wrapperMin( ¶mMin, type ); w = wrapperMin.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMin.wrappedWidget() )->minimum(), -5 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMin.wrappedWidget() )->maximum(), 999999999 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMin.wrappedWidget() )->clearValue(), -5 ); + QCOMPARE( static_cast( wrapperMin.wrappedWidget() )->minimum(), -5 ); + QCOMPARE( static_cast( wrapperMin.wrappedWidget() )->maximum(), 999999999 ); + QCOMPARE( static_cast( wrapperMin.wrappedWidget() )->clearValue(), -5 ); QCOMPARE( wrapperMin.parameterValue().toInt(), 0 ); delete w; @@ -1986,9 +1939,9 @@ void TestProcessingGui::testNumericWrapperInt() QgsProcessingNumericWidgetWrapper wrapperMax( ¶mMax, type ); w = wrapperMax.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMax.wrappedWidget() )->minimum(), -999999999 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMax.wrappedWidget() )->maximum(), 5 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMax.wrappedWidget() )->clearValue(), 0 ); + QCOMPARE( static_cast( wrapperMax.wrappedWidget() )->minimum(), -999999999 ); + QCOMPARE( static_cast( wrapperMax.wrappedWidget() )->maximum(), 5 ); + QCOMPARE( static_cast( wrapperMax.wrappedWidget() )->clearValue(), 0 ); QCOMPARE( wrapperMax.parameterValue().toInt(), 0 ); delete w; @@ -2000,9 +1953,9 @@ void TestProcessingGui::testNumericWrapperInt() QgsProcessingNumericWidgetWrapper wrapperMinMax( ¶mMinMax, type ); w = wrapperMinMax.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMinMax.wrappedWidget() )->minimum(), -1 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMinMax.wrappedWidget() )->maximum(), 1 ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperMinMax.wrappedWidget() )->clearValue(), -1 ); + QCOMPARE( static_cast( wrapperMinMax.wrappedWidget() )->minimum(), -1 ); + QCOMPARE( static_cast( wrapperMinMax.wrappedWidget() )->maximum(), 1 ); + QCOMPARE( static_cast( wrapperMinMax.wrappedWidget() )->clearValue(), -1 ); QCOMPARE( wrapperMinMax.parameterValue().toInt(), 0 ); delete w; @@ -2013,7 +1966,7 @@ void TestProcessingGui::testNumericWrapperInt() QgsProcessingNumericWidgetWrapper wrapperDefault( ¶mDefault, type ); w = wrapperDefault.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperDefault.wrappedWidget() )->clearValue(), 55 ); + QCOMPARE( static_cast( wrapperDefault.wrappedWidget() )->clearValue(), 55 ); QCOMPARE( wrapperDefault.parameterValue().toInt(), 55 ); delete w; @@ -2023,14 +1976,14 @@ void TestProcessingGui::testNumericWrapperInt() QgsProcessingNumericWidgetWrapper wrapperOptional( ¶mOptional, type ); w = wrapperOptional.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperOptional.wrappedWidget() )->clearValue(), -1000000000 ); + QCOMPARE( static_cast( wrapperOptional.wrappedWidget() )->clearValue(), -1000000000 ); QVERIFY( !wrapperOptional.parameterValue().isValid() ); wrapperOptional.setParameterValue( 5, context ); QCOMPARE( wrapperOptional.parameterValue().toInt(), 5 ); wrapperOptional.setParameterValue( QVariant(), context ); QVERIFY( !wrapperOptional.parameterValue().isValid() ); wrapperOptional.setParameterValue( 5, context ); - static_cast< QgsSpinBox * >( wrapperOptional.wrappedWidget() )->clear(); + static_cast( wrapperOptional.wrappedWidget() )->clear(); QVERIFY( !wrapperOptional.parameterValue().isValid() ); // optional, with default @@ -2038,16 +1991,16 @@ void TestProcessingGui::testNumericWrapperInt() QgsProcessingNumericWidgetWrapper wrapperOptionalDefault( ¶mOptional, type ); w = wrapperOptionalDefault.createWrappedWidget( context ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperOptionalDefault.wrappedWidget() )->clearValue(), -1000000000 ); + QCOMPARE( static_cast( wrapperOptionalDefault.wrappedWidget() )->clearValue(), -1000000000 ); QCOMPARE( wrapperOptionalDefault.parameterValue().toInt(), 3 ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toInt(), 5 ); wrapperOptionalDefault.setParameterValue( QVariant(), context ); - QCOMPARE( static_cast< QgsSpinBox * >( wrapperOptionalDefault.wrappedWidget() )->value(), -1000000000 ); + QCOMPARE( static_cast( wrapperOptionalDefault.wrappedWidget() )->value(), -1000000000 ); QVERIFY( !wrapperOptionalDefault.parameterValue().isValid() ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toInt(), 5 ); - static_cast< QgsSpinBox * >( wrapperOptionalDefault.wrappedWidget() )->clear(); + static_cast( wrapperOptionalDefault.wrappedWidget() )->clear(); QVERIFY( !wrapperOptionalDefault.parameterValue().isValid() ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toInt(), 5 ); @@ -2067,8 +2020,8 @@ void TestProcessingGui::testNumericWrapperInt() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -2077,57 +2030,57 @@ void TestProcessingGui::testNumericWrapperInt() QgsProcessingParameterNumber numParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), Qgis::ProcessingNumberParameterType::Integer, 1 ); numParam.setMinimum( 0 ); numParam.setMaximum( 10 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext, &numParam ); + widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext, &numParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->minimum(), 0.0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->maximum(), 10.0 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); + QCOMPARE( static_cast( def.get() )->minimum(), 0.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 10.0 ); numParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); numParam.setDataType( Qgis::ProcessingNumberParameterType::Double ); numParam.setMinimum( -2.5 ); numParam.setMaximum( 2.5 ); numParam.setDefaultValue( 0.5 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext, &numParam ); + widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext, &numParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->defaultValue().toDouble(), 0.5 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->minimum(), -2.5 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->maximum(), 2.5 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 0.5 ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); + QCOMPARE( static_cast( def.get() )->minimum(), -2.5 ); + QCOMPARE( static_cast( def.get() )->maximum(), 2.5 ); // integer type, no min/max values set QgsProcessingParameterNumber numParam2( QStringLiteral( "n" ), QStringLiteral( "test desc" ), Qgis::ProcessingNumberParameterType::Integer, 1 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext, &numParam2 ); + widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext, &numParam2 ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->minimum(), numParam2.minimum() ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->maximum(), numParam2.maximum() ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); + QCOMPARE( static_cast( def.get() )->minimum(), numParam2.minimum() ); + QCOMPARE( static_cast( def.get() )->maximum(), numParam2.maximum() ); // double type, no min/max values set QgsProcessingParameterNumber numParam3( QStringLiteral( "n" ), QStringLiteral( "test desc" ), Qgis::ProcessingNumberParameterType::Double, 1 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "number" ), context, widgetContext, &numParam3 ); + widget = std::make_unique( QStringLiteral( "number" ), context, widgetContext, &numParam3 ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->minimum(), numParam3.minimum() ); - QCOMPARE( static_cast< QgsProcessingParameterNumber * >( def.get() )->maximum(), numParam3.maximum() ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); + QCOMPARE( static_cast( def.get() )->minimum(), numParam3.minimum() ); + QCOMPARE( static_cast( def.get() )->maximum(), numParam3.maximum() ); } void TestProcessingGui::testDistanceWrapper() @@ -2171,7 +2124,7 @@ void TestProcessingGui::testDistanceWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast< int >( Qgis::DistanceUnit::Meters ) ); + QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast( Qgis::DistanceUnit::Meters ) ); wrapper.setUnitParameterValue( QStringLiteral( "EPSG:4326" ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "degrees" ) ); @@ -2184,7 +2137,7 @@ void TestProcessingGui::testDistanceWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast< int >( Qgis::DistanceUnit::Meters ) ); + QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast( Qgis::DistanceUnit::Meters ) ); wrapper.setUnitParameterValue( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "degrees" ) ); @@ -2193,15 +2146,15 @@ void TestProcessingGui::testDistanceWrapper() QVERIFY( wrapper.mLabel->isVisible() ); // layer values - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); wrapper.setUnitParameterValue( QVariant::fromValue( vl.get() ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "meters" ) ); QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast< int >( Qgis::DistanceUnit::Meters ) ); + QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast( Qgis::DistanceUnit::Meters ) ); - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); wrapper.setUnitParameterValue( QVariant::fromValue( vl2.get() ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "degrees" ) ); QVERIFY( wrapper.mWarningLabel->isVisible() ); @@ -2227,12 +2180,12 @@ void TestProcessingGui::testDistanceWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast< int >( Qgis::DistanceUnit::Meters ) ); + QCOMPARE( wrapper.mUnitsCombo->currentData().toInt(), static_cast( Qgis::DistanceUnit::Meters ) ); // using unit choice wrapper.setParameterValue( 5, context ); QCOMPARE( wrapper.parameterValue().toDouble(), 5.0 ); - wrapper.mUnitsCombo->setCurrentIndex( wrapper.mUnitsCombo->findData( static_cast< int >( Qgis::DistanceUnit::Kilometers ) ) ); + wrapper.mUnitsCombo->setCurrentIndex( wrapper.mUnitsCombo->findData( static_cast( Qgis::DistanceUnit::Kilometers ) ) ); QCOMPARE( wrapper.parameterValue().toDouble(), 5000.0 ); wrapper.setParameterValue( 2, context ); QCOMPARE( wrapper.parameterValue().toDouble(), 2000.0 ); @@ -2281,7 +2234,7 @@ void TestProcessingGui::testDistanceWrapper() QCOMPARE( wrapperB.mDoubleSpinBox->value(), -57.0 ); // check signal - static_cast< QgsDoubleSpinBox * >( w )->setValue( 29 ); + static_cast( w )->setValue( 29 ); QCOMPARE( spy2.count(), 3 ); // should be no label in batch mode @@ -2316,8 +2269,8 @@ void TestProcessingGui::testDistanceWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "distance" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "distance" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -2326,31 +2279,31 @@ void TestProcessingGui::testDistanceWrapper() QgsProcessingParameterDistance distParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), 1, QStringLiteral( "parent" ) ); distParam.setMinimum( 1 ); distParam.setMaximum( 100 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "distance" ), context, widgetContext, &distParam ); + widget = std::make_unique( QStringLiteral( "distance" ), context, widgetContext, &distParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterDistance * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterDistance * >( def.get() )->minimum(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterDistance * >( def.get() )->maximum(), 100.0 ); - QCOMPARE( static_cast< QgsProcessingParameterDistance * >( def.get() )->parentParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->minimum(), 1.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 100.0 ); + QCOMPARE( static_cast( def.get() )->parentParameterName(), QStringLiteral( "parent" ) ); distParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); distParam.setParentParameterName( QString() ); distParam.setMinimum( 10 ); distParam.setMaximum( 12 ); distParam.setDefaultValue( 11.5 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "distance" ), context, widgetContext, &distParam ); + widget = std::make_unique( QStringLiteral( "distance" ), context, widgetContext, &distParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterDistance * >( def.get() )->defaultValue().toDouble(), 11.5 ); - QCOMPARE( static_cast< QgsProcessingParameterDistance * >( def.get() )->minimum(), 10.0 ); - QCOMPARE( static_cast< QgsProcessingParameterDistance * >( def.get() )->maximum(), 12.0 ); - QVERIFY( static_cast< QgsProcessingParameterDistance * >( def.get() )->parentParameterName().isEmpty() ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 11.5 ); + QCOMPARE( static_cast( def.get() )->minimum(), 10.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 12.0 ); + QVERIFY( static_cast( def.get() )->parentParameterName().isEmpty() ); } void TestProcessingGui::testAreaWrapper() @@ -2394,7 +2347,7 @@ void TestProcessingGui::testAreaWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::AreaUnit >(), Qgis::AreaUnit::SquareMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::AreaUnit::SquareMeters ); wrapper.setUnitParameterValue( QStringLiteral( "EPSG:4326" ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "square degrees" ) ); @@ -2407,7 +2360,7 @@ void TestProcessingGui::testAreaWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::AreaUnit >(), Qgis::AreaUnit::SquareMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::AreaUnit::SquareMeters ); wrapper.setUnitParameterValue( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "square degrees" ) ); @@ -2416,15 +2369,15 @@ void TestProcessingGui::testAreaWrapper() QVERIFY( wrapper.mLabel->isVisible() ); // layer values - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); wrapper.setUnitParameterValue( QVariant::fromValue( vl.get() ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "square meters" ) ); QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::AreaUnit >(), Qgis::AreaUnit::SquareMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::AreaUnit::SquareMeters ); - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); wrapper.setUnitParameterValue( QVariant::fromValue( vl2.get() ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "square degrees" ) ); QVERIFY( wrapper.mWarningLabel->isVisible() ); @@ -2450,7 +2403,7 @@ void TestProcessingGui::testAreaWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::AreaUnit >(), Qgis::AreaUnit::SquareMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::AreaUnit::SquareMeters ); // using unit choice wrapper.setParameterValue( 5, context ); @@ -2504,7 +2457,7 @@ void TestProcessingGui::testAreaWrapper() QCOMPARE( wrapperB.mDoubleSpinBox->value(), 5.0 ); // check signal - static_cast< QgsDoubleSpinBox * >( w )->setValue( 29 ); + static_cast( w )->setValue( 29 ); QCOMPARE( spy2.count(), 3 ); // should be no label in batch mode @@ -2539,8 +2492,8 @@ void TestProcessingGui::testAreaWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "area" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "area" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -2549,31 +2502,31 @@ void TestProcessingGui::testAreaWrapper() QgsProcessingParameterArea distParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), 1, QStringLiteral( "parent" ) ); distParam.setMinimum( 1 ); distParam.setMaximum( 100 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "area" ), context, widgetContext, &distParam ); + widget = std::make_unique( QStringLiteral( "area" ), context, widgetContext, &distParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterArea * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterArea * >( def.get() )->minimum(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterArea * >( def.get() )->maximum(), 100.0 ); - QCOMPARE( static_cast< QgsProcessingParameterArea * >( def.get() )->parentParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->minimum(), 1.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 100.0 ); + QCOMPARE( static_cast( def.get() )->parentParameterName(), QStringLiteral( "parent" ) ); distParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); distParam.setParentParameterName( QString() ); distParam.setMinimum( 10 ); distParam.setMaximum( 12 ); distParam.setDefaultValue( 11.5 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "area" ), context, widgetContext, &distParam ); + widget = std::make_unique( QStringLiteral( "area" ), context, widgetContext, &distParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterArea * >( def.get() )->defaultValue().toDouble(), 11.5 ); - QCOMPARE( static_cast< QgsProcessingParameterArea * >( def.get() )->minimum(), 10.0 ); - QCOMPARE( static_cast< QgsProcessingParameterArea * >( def.get() )->maximum(), 12.0 ); - QVERIFY( static_cast< QgsProcessingParameterArea * >( def.get() )->parentParameterName().isEmpty() ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 11.5 ); + QCOMPARE( static_cast( def.get() )->minimum(), 10.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 12.0 ); + QVERIFY( static_cast( def.get() )->parentParameterName().isEmpty() ); } void TestProcessingGui::testVolumeWrapper() @@ -2617,7 +2570,7 @@ void TestProcessingGui::testVolumeWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::VolumeUnit >(), Qgis::VolumeUnit::CubicMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::VolumeUnit::CubicMeters ); wrapper.setUnitParameterValue( QStringLiteral( "EPSG:4326" ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "cubic degrees" ) ); @@ -2630,7 +2583,7 @@ void TestProcessingGui::testVolumeWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::VolumeUnit >(), Qgis::VolumeUnit::CubicMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::VolumeUnit::CubicMeters ); wrapper.setUnitParameterValue( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "cubic degrees" ) ); @@ -2639,15 +2592,15 @@ void TestProcessingGui::testVolumeWrapper() QVERIFY( wrapper.mLabel->isVisible() ); // layer values - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); wrapper.setUnitParameterValue( QVariant::fromValue( vl.get() ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "cubic meters" ) ); QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::VolumeUnit >(), Qgis::VolumeUnit::CubicMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::VolumeUnit::CubicMeters ); - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl2 = std::make_unique( QStringLiteral( "Polygon?crs=epsg:4326&field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); wrapper.setUnitParameterValue( QVariant::fromValue( vl2.get() ) ); QCOMPARE( wrapper.mLabel->text(), QStringLiteral( "cubic degrees" ) ); QVERIFY( wrapper.mWarningLabel->isVisible() ); @@ -2673,7 +2626,7 @@ void TestProcessingGui::testVolumeWrapper() QVERIFY( !wrapper.mWarningLabel->isVisible() ); QVERIFY( wrapper.mUnitsCombo->isVisible() ); QVERIFY( !wrapper.mLabel->isVisible() ); - QCOMPARE( wrapper.mUnitsCombo->currentData().value< Qgis::VolumeUnit >(), Qgis::VolumeUnit::CubicMeters ); + QCOMPARE( wrapper.mUnitsCombo->currentData().value(), Qgis::VolumeUnit::CubicMeters ); // using unit choice wrapper.setParameterValue( 5, context ); @@ -2727,7 +2680,7 @@ void TestProcessingGui::testVolumeWrapper() QCOMPARE( wrapperB.mDoubleSpinBox->value(), 5.0 ); // check signal - static_cast< QgsDoubleSpinBox * >( w )->setValue( 29 ); + static_cast( w )->setValue( 29 ); QCOMPARE( spy2.count(), 3 ); // should be no label in batch mode @@ -2762,8 +2715,8 @@ void TestProcessingGui::testVolumeWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "volume" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "volume" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -2772,31 +2725,31 @@ void TestProcessingGui::testVolumeWrapper() QgsProcessingParameterVolume distParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), 1, QStringLiteral( "parent" ) ); distParam.setMinimum( 1 ); distParam.setMaximum( 100 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "volume" ), context, widgetContext, &distParam ); + widget = std::make_unique( QStringLiteral( "volume" ), context, widgetContext, &distParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterVolume * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterVolume * >( def.get() )->minimum(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterVolume * >( def.get() )->maximum(), 100.0 ); - QCOMPARE( static_cast< QgsProcessingParameterVolume * >( def.get() )->parentParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->minimum(), 1.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 100.0 ); + QCOMPARE( static_cast( def.get() )->parentParameterName(), QStringLiteral( "parent" ) ); distParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); distParam.setParentParameterName( QString() ); distParam.setMinimum( 10 ); distParam.setMaximum( 12 ); distParam.setDefaultValue( 11.5 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "volume" ), context, widgetContext, &distParam ); + widget = std::make_unique( QStringLiteral( "volume" ), context, widgetContext, &distParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterVolume * >( def.get() )->defaultValue().toDouble(), 11.5 ); - QCOMPARE( static_cast< QgsProcessingParameterVolume * >( def.get() )->minimum(), 10.0 ); - QCOMPARE( static_cast< QgsProcessingParameterVolume * >( def.get() )->maximum(), 12.0 ); - QVERIFY( static_cast< QgsProcessingParameterVolume * >( def.get() )->parentParameterName().isEmpty() ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 11.5 ); + QCOMPARE( static_cast( def.get() )->minimum(), 10.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 12.0 ); + QVERIFY( static_cast( def.get() )->parentParameterName().isEmpty() ); } void TestProcessingGui::testDurationWrapper() @@ -2866,7 +2819,7 @@ void TestProcessingGui::testDurationWrapper() QCOMPARE( wrapperB.mDoubleSpinBox->value(), -57.0 ); // check signal - static_cast< QgsDoubleSpinBox * >( w )->setValue( 29 ); + static_cast( w )->setValue( 29 ); QCOMPARE( spy2.count(), 3 ); // should be no label in batch mode @@ -2901,8 +2854,8 @@ void TestProcessingGui::testDurationWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "duration" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "duration" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -2911,34 +2864,33 @@ void TestProcessingGui::testDurationWrapper() QgsProcessingParameterDuration durParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), 1 ); durParam.setMinimum( 1 ); durParam.setMaximum( 100 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "duration" ), context, widgetContext, &durParam ); + widget = std::make_unique( QStringLiteral( "duration" ), context, widgetContext, &durParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterDuration * >( def.get() )->defaultValue().toDouble(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterDuration * >( def.get() )->minimum(), 1.0 ); - QCOMPARE( static_cast< QgsProcessingParameterDuration * >( def.get() )->maximum(), 100.0 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1.0 ); + QCOMPARE( static_cast( def.get() )->minimum(), 1.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 100.0 ); durParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); durParam.setMinimum( 10 ); durParam.setMaximum( 12 ); durParam.setDefaultValue( 11.5 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "duration" ), context, widgetContext, &durParam ); + widget = std::make_unique( QStringLiteral( "duration" ), context, widgetContext, &durParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterDuration * >( def.get() )->defaultValue().toDouble(), 11.5 ); - QCOMPARE( static_cast< QgsProcessingParameterDuration * >( def.get() )->minimum(), 10.0 ); - QCOMPARE( static_cast< QgsProcessingParameterDuration * >( def.get() )->maximum(), 12.0 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 11.5 ); + QCOMPARE( static_cast( def.get() )->minimum(), 10.0 ); + QCOMPARE( static_cast( def.get() )->maximum(), 12.0 ); } void TestProcessingGui::testScaleWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingContext context; QgsProcessingParameterScale param( QStringLiteral( "num" ), QStringLiteral( "num" ) ); @@ -2949,15 +2901,15 @@ void TestProcessingGui::testScaleWrapper() wrapper.setWidgetValue( 5, context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toDouble(), 5.0 ); - QCOMPARE( static_cast< QgsScaleWidget * >( wrapper.wrappedWidget() )->scale(), 5.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->scale(), 5.0 ); wrapper.setWidgetValue( QStringLiteral( "28356" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toDouble(), 28356.0 ); - QCOMPARE( static_cast< QgsScaleWidget * >( wrapper.wrappedWidget() )->scale(), 28356.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->scale(), 28356.0 ); wrapper.setWidgetValue( QVariant(), context ); // not optional, so shouldn't work QCOMPARE( spy.count(), 3 ); QCOMPARE( wrapper.widgetValue().toDouble(), 0.0 ); - QCOMPARE( static_cast< QgsScaleWidget * >( wrapper.wrappedWidget() )->scale(), 0.0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->scale(), 0.0 ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -2973,7 +2925,7 @@ void TestProcessingGui::testScaleWrapper() } // check signal - static_cast< QgsScaleWidget * >( wrapper.wrappedWidget() )->setScale( 37.0 ); + static_cast( wrapper.wrappedWidget() )->setScale( 37.0 ); QCOMPARE( spy.count(), 4 ); delete w; @@ -2990,7 +2942,7 @@ void TestProcessingGui::testScaleWrapper() wrapperOptional.setParameterValue( QVariant(), context ); QVERIFY( !wrapperOptional.parameterValue().isValid() ); wrapperOptional.setParameterValue( 5, context ); - static_cast< QgsScaleWidget * >( wrapperOptional.wrappedWidget() )->setScale( std::numeric_limits< double >::quiet_NaN() ); + static_cast( wrapperOptional.wrappedWidget() )->setScale( std::numeric_limits::quiet_NaN() ); QVERIFY( !wrapperOptional.parameterValue().isValid() ); // optional, with default @@ -3002,11 +2954,11 @@ void TestProcessingGui::testScaleWrapper() wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toDouble(), 5.0 ); wrapperOptionalDefault.setParameterValue( QVariant(), context ); - QVERIFY( std::isnan( static_cast< QgsScaleWidget * >( wrapperOptionalDefault.wrappedWidget() )->scale() ) ); + QVERIFY( std::isnan( static_cast( wrapperOptionalDefault.wrappedWidget() )->scale() ) ); QVERIFY( !wrapperOptionalDefault.parameterValue().isValid() ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toDouble(), 5.0 ); - static_cast< QgsScaleWidget * >( wrapperOptionalDefault.wrappedWidget() )->setScale( std::numeric_limits< double >::quiet_NaN() ); + static_cast( wrapperOptionalDefault.wrappedWidget() )->setScale( std::numeric_limits::quiet_NaN() ); QVERIFY( !wrapperOptionalDefault.parameterValue().isValid() ); wrapperOptionalDefault.setParameterValue( 5, context ); QCOMPARE( wrapperOptionalDefault.parameterValue().toDouble(), 5.0 ); @@ -3026,36 +2978,35 @@ void TestProcessingGui::testScaleWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "scale" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "scale" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterScale scaleParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), 1000 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "scale" ), context, widgetContext, &scaleParam ); + widget = std::make_unique( QStringLiteral( "scale" ), context, widgetContext, &scaleParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterScale * >( def.get() )->defaultValue().toDouble(), 1000.0 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 1000.0 ); scaleParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); scaleParam.setDefaultValue( 28356 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "scale" ), context, widgetContext, &scaleParam ); + widget = std::make_unique( QStringLiteral( "scale" ), context, widgetContext, &scaleParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterScale * >( def.get() )->defaultValue().toDouble(), 28356.0 ); + QCOMPARE( static_cast( def.get() )->defaultValue().toDouble(), 28356.0 ); } void TestProcessingGui::testRangeWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingContext context; QgsProcessingParameterRange param( QStringLiteral( "range" ), QStringLiteral( "range" ), Qgis::ProcessingNumberParameterType::Double ); @@ -3187,39 +3138,39 @@ void TestProcessingGui::testRangeWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "range" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "range" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterRange rangeParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), Qgis::ProcessingNumberParameterType::Integer, QStringLiteral( "0,255" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "range" ), context, widgetContext, &rangeParam ); + widget = std::make_unique( QStringLiteral( "range" ), context, widgetContext, &rangeParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterRange * >( def.get() )->defaultValue().toString(), QStringLiteral( "0,255" ) ); - QCOMPARE( static_cast< QgsProcessingParameterRange * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "0,255" ) ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Integer ); rangeParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); rangeParam.setDataType( Qgis::ProcessingNumberParameterType::Double ); rangeParam.setDefaultValue( QStringLiteral( "0,1" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "range" ), context, widgetContext, &rangeParam ); + widget = std::make_unique( QStringLiteral( "range" ), context, widgetContext, &rangeParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterRange * >( def.get() )->defaultValue().toString(), QStringLiteral( "0,1" ) ); - QCOMPARE( static_cast< QgsProcessingParameterRange * >( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "0,1" ) ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingNumberParameterType::Double ); } void TestProcessingGui::testMatrixDialog() { QgsProcessingParameterMatrix matrixParam( QString(), QString(), 3, false, QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); - std::unique_ptr< QgsProcessingMatrixParameterPanelWidget > dlg = std::make_unique< QgsProcessingMatrixParameterPanelWidget>( nullptr, &matrixParam ); + std::unique_ptr dlg = std::make_unique( nullptr, &matrixParam ); // variable length table QVERIFY( dlg->mButtonAdd->isEnabled() ); QVERIFY( dlg->mButtonRemove->isEnabled() ); @@ -3227,7 +3178,7 @@ void TestProcessingGui::testMatrixDialog() QCOMPARE( dlg->table(), QVariantList() ); - dlg = std::make_unique< QgsProcessingMatrixParameterPanelWidget >( nullptr, &matrixParam, QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); + dlg = std::make_unique( nullptr, &matrixParam, QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); QCOMPARE( dlg->table(), QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); dlg->addRow(); QCOMPARE( dlg->table(), QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) << QString() << QString() ); @@ -3235,7 +3186,7 @@ void TestProcessingGui::testMatrixDialog() QCOMPARE( dlg->table(), QVariantList() ); QgsProcessingParameterMatrix matrixParam2( QString(), QString(), 3, true, QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); - dlg = std::make_unique< QgsProcessingMatrixParameterPanelWidget >( nullptr, &matrixParam2, QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); + dlg = std::make_unique( nullptr, &matrixParam2, QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) << QStringLiteral( "e" ) << QStringLiteral( "f" ) ); QVERIFY( !dlg->mButtonAdd->isEnabled() ); QVERIFY( !dlg->mButtonRemove->isEnabled() ); QVERIFY( !dlg->mButtonRemoveAll->isEnabled() ); @@ -3243,8 +3194,7 @@ void TestProcessingGui::testMatrixDialog() void TestProcessingGui::testMatrixWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingContext context; QgsProcessingParameterMatrix param( QStringLiteral( "matrix" ), QStringLiteral( "matrix" ), 3, false, QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); @@ -3300,35 +3250,35 @@ void TestProcessingGui::testMatrixWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "matrix" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "matrix" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterMatrix matrixParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), 1, false, QStringList() << "A" << "B" << "C", QVariantList() << 0 << 0 << 0 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "matrix" ), context, widgetContext, &matrixParam ); + widget = std::make_unique( QStringLiteral( "matrix" ), context, widgetContext, &matrixParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterMatrix * >( def.get() )->headers(), QStringList() << "A" << "B" << "C" ); - QCOMPARE( static_cast< QgsProcessingParameterMatrix * >( def.get() )->defaultValue().toStringList(), QStringList() << "0" << "0" << "0" ); - QVERIFY( !static_cast< QgsProcessingParameterMatrix * >( def.get() )->hasFixedNumberRows() ); + QCOMPARE( static_cast( def.get() )->headers(), QStringList() << "A" << "B" << "C" ); + QCOMPARE( static_cast( def.get() )->defaultValue().toStringList(), QStringList() << "0" << "0" << "0" ); + QVERIFY( !static_cast( def.get() )->hasFixedNumberRows() ); matrixParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); matrixParam.setHasFixedNumberRows( true ); matrixParam.setDefaultValue( QVariantList() << 1 << 2 << 3 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "matrix" ), context, widgetContext, &matrixParam ); + widget = std::make_unique( QStringLiteral( "matrix" ), context, widgetContext, &matrixParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterMatrix * >( def.get() )->headers(), QStringList() << "A" << "B" << "C" ); - QCOMPARE( static_cast< QgsProcessingParameterMatrix * >( def.get() )->defaultValue().toStringList(), QStringList() << "1" << "2" << "3" ); - QVERIFY( static_cast< QgsProcessingParameterMatrix * >( def.get() )->hasFixedNumberRows() ); + QCOMPARE( static_cast( def.get() )->headers(), QStringList() << "A" << "B" << "C" ); + QCOMPARE( static_cast( def.get() )->defaultValue().toStringList(), QStringList() << "1" << "2" << "3" ); + QVERIFY( static_cast( def.get() )->hasFixedNumberRows() ); } void TestProcessingGui::testExpressionWrapper() @@ -3337,8 +3287,7 @@ void TestProcessingGui::testExpressionWrapper() const QgsProcessingParameterDefinition *vLayerDef = centroidAlg->parameterDefinition( QStringLiteral( "INPUT" ) ); const QgsProcessingParameterDefinition *pcLayerDef = new QgsProcessingParameterPointCloudLayer( "INPUT", QStringLiteral( "input" ), QVariant(), false ); - auto testWrapper = [vLayerDef, pcLayerDef]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [vLayerDef, pcLayerDef]( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterExpression param( QStringLiteral( "expression" ), QStringLiteral( "expression" ) ); QgsProcessingExpressionWidgetWrapper wrapper( ¶m, type ); @@ -3349,12 +3298,12 @@ void TestProcessingGui::testExpressionWrapper() QSignalSpy spy( &wrapper, &QgsProcessingExpressionWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QStringLiteral( "1+2" ), context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1+2" ) ); - QCOMPARE( static_cast< QgsExpressionLineEdit * >( wrapper.wrappedWidget() )->expression(), QStringLiteral( "1+2" ) ); + QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1+2" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->expression(), QStringLiteral( "1+2" ) ); wrapper.setWidgetValue( QString(), context ); QCOMPARE( spy.count(), 2 ); QVERIFY( wrapper.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsExpressionLineEdit * >( wrapper.wrappedWidget() )->expression().isEmpty() ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->expression().isEmpty() ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -3370,7 +3319,7 @@ void TestProcessingGui::testExpressionWrapper() } // check signal - static_cast< QgsExpressionLineEdit * >( wrapper.wrappedWidget() )->setExpression( QStringLiteral( "3+4" ) ); + static_cast( wrapper.wrappedWidget() )->setExpression( QStringLiteral( "3+4" ) ); QCOMPARE( spy.count(), 3 ); delete w; @@ -3383,15 +3332,15 @@ void TestProcessingGui::testExpressionWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingExpressionWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( QStringLiteral( "11+12" ), context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "11+12" ) ); - QCOMPARE( static_cast< QgsFieldExpressionWidget * >( wrapper2.wrappedWidget() )->expression(), QStringLiteral( "11+12" ) ); + QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "11+12" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->expression(), QStringLiteral( "11+12" ) ); wrapper2.setWidgetValue( QString(), context ); QCOMPARE( spy2.count(), 2 ); QVERIFY( wrapper2.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsFieldExpressionWidget * >( wrapper2.wrappedWidget() )->expression().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->expression().isEmpty() ); - static_cast< QgsFieldExpressionWidget * >( wrapper2.wrappedWidget() )->setExpression( QStringLiteral( "3+4" ) ); + static_cast( wrapper2.wrappedWidget() )->setExpression( QStringLiteral( "3+4" ) ); QCOMPARE( spy2.count(), 3 ); TestLayerWrapper vLayerWrapper( vLayerDef ); @@ -3444,15 +3393,15 @@ void TestProcessingGui::testExpressionWrapper() QSignalSpy spy3( &wrapper3, &QgsProcessingExpressionWidgetWrapper::widgetValueHasChanged ); wrapper3.setWidgetValue( QStringLiteral( "Intensity+100" ), context ); QCOMPARE( spy3.count(), 1 ); - QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "Intensity+100" ) ); - QCOMPARE( static_cast< QgsProcessingPointCloudExpressionLineEdit * >( wrapper3.wrappedWidget() )->expression(), QStringLiteral( "Intensity+100" ) ); + QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "Intensity+100" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->expression(), QStringLiteral( "Intensity+100" ) ); wrapper3.setWidgetValue( QString(), context ); QCOMPARE( spy3.count(), 2 ); QVERIFY( wrapper3.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsProcessingPointCloudExpressionLineEdit * >( wrapper3.wrappedWidget() )->expression().isEmpty() ); + QVERIFY( static_cast( wrapper3.wrappedWidget() )->expression().isEmpty() ); // check signal - static_cast< QgsProcessingPointCloudExpressionLineEdit * >( wrapper3.wrappedWidget() )->setExpression( QStringLiteral( "Red+4" ) ); + static_cast( wrapper3.wrappedWidget() )->setExpression( QStringLiteral( "Red+4" ) ); QCOMPARE( spy3.count(), 3 ); delete w; @@ -3465,15 +3414,15 @@ void TestProcessingGui::testExpressionWrapper() QSignalSpy spy4( &wrapper4, &QgsProcessingExpressionWidgetWrapper::widgetValueHasChanged ); wrapper4.setWidgetValue( QStringLiteral( "Intensity+100" ), context ); QCOMPARE( spy4.count(), 1 ); - QCOMPARE( wrapper4.widgetValue().toString(), QStringLiteral( "Intensity+100" ) ); - QCOMPARE( static_cast< QgsProcessingPointCloudExpressionLineEdit * >( wrapper4.wrappedWidget() )->expression(), QStringLiteral( "Intensity+100" ) ); + QCOMPARE( wrapper4.widgetValue().toString(), QStringLiteral( "Intensity+100" ) ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->expression(), QStringLiteral( "Intensity+100" ) ); wrapper4.setWidgetValue( QString(), context ); QCOMPARE( spy4.count(), 2 ); QVERIFY( wrapper4.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsProcessingPointCloudExpressionLineEdit * >( wrapper4.wrappedWidget() )->expression().isEmpty() ); + QVERIFY( static_cast( wrapper4.wrappedWidget() )->expression().isEmpty() ); - static_cast< QgsProcessingPointCloudExpressionLineEdit * >( wrapper4.wrappedWidget() )->setExpression( QStringLiteral( "Red+4" ) ); + static_cast( wrapper4.wrappedWidget() )->setExpression( QStringLiteral( "Red+4" ) ); QCOMPARE( spy4.count(), 3 ); TestLayerWrapper pcLayerWrapper( pcLayerDef ); @@ -3527,34 +3476,34 @@ void TestProcessingGui::testExpressionWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "expression" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "expression" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterExpression * >( def.get() )->expressionType(), Qgis::ExpressionType::Qgis ); + QCOMPARE( static_cast( def.get() )->expressionType(), Qgis::ExpressionType::Qgis ); // using a parameter definition as initial values QgsProcessingParameterExpression exprParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QVariant(), QStringLiteral( "parent" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "expression" ), context, widgetContext, &exprParam ); + widget = std::make_unique( QStringLiteral( "expression" ), context, widgetContext, &exprParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterExpression * >( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); - QCOMPARE( static_cast< QgsProcessingParameterExpression * >( def.get() )->expressionType(), Qgis::ExpressionType::Qgis ); + QCOMPARE( static_cast( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->expressionType(), Qgis::ExpressionType::Qgis ); exprParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); exprParam.setExpressionType( Qgis::ExpressionType::PointCloud ); exprParam.setParentLayerParameterName( QString() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "expression" ), context, widgetContext, &exprParam ); + widget = std::make_unique( QStringLiteral( "expression" ), context, widgetContext, &exprParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QVERIFY( static_cast< QgsProcessingParameterExpression * >( def.get() )->parentLayerParameterName().isEmpty() ); - QCOMPARE( static_cast< QgsProcessingParameterExpression * >( def.get() )->expressionType(), Qgis::ExpressionType::PointCloud ); + QVERIFY( static_cast( def.get() )->parentLayerParameterName().isEmpty() ); + QCOMPARE( static_cast( def.get() )->expressionType(), Qgis::ExpressionType::PointCloud ); } void TestProcessingGui::testFieldSelectionPanel() @@ -3578,7 +3527,6 @@ void TestProcessingGui::testFieldSelectionPanel() QCOMPARE( spy.count(), 3 ); QCOMPARE( w.value().toList(), QVariantList() ); QCOMPARE( w.mLineEdit->text(), QStringLiteral( "0 field(s) selected" ) ); - } void TestProcessingGui::testFieldWrapper() @@ -3586,8 +3534,7 @@ void TestProcessingGui::testFieldWrapper() const QgsProcessingAlgorithm *centroidAlg = QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "native:centroids" ) ); const QgsProcessingParameterDefinition *layerDef = centroidAlg->parameterDefinition( QStringLiteral( "INPUT" ) ); - auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) { TestLayerWrapper layerWrapper( layerDef ); QgsProject p; QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( "LineString?field=aaa:int&field=bbb:string" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); @@ -3600,24 +3547,24 @@ void TestProcessingGui::testFieldWrapper() QgsProcessingContext context; QWidget *w = wrapper.createWrappedWidget( context ); - ( void )w; + ( void ) w; layerWrapper.setWidgetValue( QVariant::fromValue( vl ), context ); wrapper.setParentLayerWrapperValue( &layerWrapper ); QSignalSpy spy( &wrapper, &QgsProcessingFieldWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QStringLiteral( "bbb" ), context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bbb" ) ); + QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bbb" ) ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsFieldComboBox * >( wrapper.wrappedWidget() )->currentField(), QStringLiteral( "bbb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentField(), QStringLiteral( "bbb" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "bbb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "bbb" ) ); break; } @@ -3638,7 +3585,7 @@ void TestProcessingGui::testFieldWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingFieldWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( QStringLiteral( "aaa" ), context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "aaa" ) ); + QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "aaa" ) ); wrapper2.setWidgetValue( QString(), context ); QCOMPARE( spy2.count(), 2 ); @@ -3648,11 +3595,11 @@ void TestProcessingGui::testFieldWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsFieldComboBox * >( wrapper2.wrappedWidget() )->currentField(), QString() ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentField(), QString() ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text(), QString() ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->text(), QString() ); break; } @@ -3674,11 +3621,11 @@ void TestProcessingGui::testFieldWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - static_cast< QgsFieldComboBox * >( wrapper2.wrappedWidget() )->setField( QStringLiteral( "bbb" ) ); + static_cast( wrapper2.wrappedWidget() )->setField( QStringLiteral( "bbb" ) ); break; case QgsProcessingGui::Modeler: - static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->setText( QStringLiteral( "bbb" ) ); + static_cast( wrapper2.wrappedWidget() )->setText( QStringLiteral( "bbb" ) ); break; } @@ -3809,7 +3756,7 @@ void TestProcessingGui::testFieldWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsFieldComboBox * >( wrapper4.wrappedWidget() )->filters(), QgsFieldProxyModel::String ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->filters(), QgsFieldProxyModel::String ); break; case QgsProcessingGui::Modeler: @@ -3846,7 +3793,7 @@ void TestProcessingGui::testFieldWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsFieldComboBox * >( wrapper5.wrappedWidget() )->filters(), QgsFieldProxyModel::Numeric ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->filters(), QgsFieldProxyModel::Numeric ); break; case QgsProcessingGui::Modeler: @@ -3885,7 +3832,7 @@ void TestProcessingGui::testFieldWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsFieldComboBox * >( wrapper6.wrappedWidget() )->filters(), QgsFieldProxyModel::Date | QgsFieldProxyModel::Time | QgsFieldProxyModel::DateTime ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->filters(), QgsFieldProxyModel::Date | QgsFieldProxyModel::Time | QgsFieldProxyModel::DateTime ); break; case QgsProcessingGui::Modeler: @@ -3905,7 +3852,7 @@ void TestProcessingGui::testFieldWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsFieldComboBox * >( wrapper7.wrappedWidget() )->filters(), QgsFieldProxyModel::Binary ); + QCOMPARE( static_cast( wrapper7.wrappedWidget() )->filters(), QgsFieldProxyModel::Binary ); break; case QgsProcessingGui::Modeler: @@ -3924,7 +3871,7 @@ void TestProcessingGui::testFieldWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsFieldComboBox * >( wrapper8.wrappedWidget() )->filters(), QgsFieldProxyModel::Boolean ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->filters(), QgsFieldProxyModel::Boolean ); break; case QgsProcessingGui::Modeler: @@ -3988,8 +3935,8 @@ void TestProcessingGui::testFieldWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "field" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "field" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !def->defaultValue().isValid() ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory @@ -3997,47 +3944,47 @@ void TestProcessingGui::testFieldWrapper() // using a parameter definition as initial values QgsProcessingParameterField fieldParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "field_name" ), QStringLiteral( "parent" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "field" ), context, widgetContext, &fieldParam ); + widget = std::make_unique( QStringLiteral( "field" ), context, widgetContext, &fieldParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->defaultValue().toString(), QStringLiteral( "field_name" ) ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->dataType(), Qgis::ProcessingFieldParameterDataType::Any ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->allowMultiple(), false ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->defaultToAllFields(), false ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "field_name" ) ); + QCOMPARE( static_cast( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingFieldParameterDataType::Any ); + QCOMPARE( static_cast( def.get() )->allowMultiple(), false ); + QCOMPARE( static_cast( def.get() )->defaultToAllFields(), false ); fieldParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); fieldParam.setParentLayerParameterName( QString() ); fieldParam.setAllowMultiple( true ); fieldParam.setDefaultToAllFields( true ); fieldParam.setDataType( Qgis::ProcessingFieldParameterDataType::String ); fieldParam.setDefaultValue( QStringLiteral( "field_1;field_2" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "field" ), context, widgetContext, &fieldParam ); + widget = std::make_unique( QStringLiteral( "field" ), context, widgetContext, &fieldParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->defaultValue().toString(), QStringLiteral( "field_1;field_2" ) ); - QVERIFY( static_cast< QgsProcessingParameterBand * >( def.get() )->parentLayerParameterName().isEmpty() ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->dataType(), Qgis::ProcessingFieldParameterDataType::String ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->allowMultiple(), true ); - QCOMPARE( static_cast< QgsProcessingParameterField * >( def.get() )->defaultToAllFields(), true ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "field_1;field_2" ) ); + QVERIFY( static_cast( def.get() )->parentLayerParameterName().isEmpty() ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingFieldParameterDataType::String ); + QCOMPARE( static_cast( def.get() )->allowMultiple(), true ); + QCOMPARE( static_cast( def.get() )->defaultToAllFields(), true ); } void TestProcessingGui::testMultipleSelectionDialog() { QVariantList availableOptions; QVariantList selectedOptions; - std::unique_ptr< QgsProcessingMultipleSelectionPanelWidget > dlg = std::make_unique< QgsProcessingMultipleSelectionPanelWidget >( availableOptions, selectedOptions ); + std::unique_ptr dlg = std::make_unique( availableOptions, selectedOptions ); QVERIFY( dlg->selectedOptions().isEmpty() ); QCOMPARE( dlg->mModel->rowCount(), 0 ); - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( QStringLiteral( "LineString" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( QStringLiteral( "LineString" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); availableOptions << QVariant( "aa" ) << QVariant( 15 ) << QVariant::fromValue( vl.get() ); - dlg = std::make_unique< QgsProcessingMultipleSelectionPanelWidget >( availableOptions, selectedOptions ); + dlg = std::make_unique( availableOptions, selectedOptions ); QVERIFY( dlg->selectedOptions().isEmpty() ); QCOMPARE( dlg->mModel->rowCount(), 3 ); dlg->selectAll( true ); @@ -4053,7 +4000,7 @@ void TestProcessingGui::testMultipleSelectionDialog() // additional options availableOptions.clear(); selectedOptions << QVariant( "bb" ) << QVariant( 6.6 ); - dlg = std::make_unique< QgsProcessingMultipleSelectionPanelWidget >( availableOptions, selectedOptions ); + dlg = std::make_unique( availableOptions, selectedOptions ); QCOMPARE( dlg->mModel->rowCount(), 2 ); QCOMPARE( dlg->selectedOptions(), selectedOptions ); dlg->mModel->item( 1 )->setCheckState( Qt::Unchecked ); @@ -4061,7 +4008,7 @@ void TestProcessingGui::testMultipleSelectionDialog() // mix of standard and additional options availableOptions << QVariant( 6.6 ) << QVariant( "aa" ); - dlg = std::make_unique< QgsProcessingMultipleSelectionPanelWidget >( availableOptions, selectedOptions ); + dlg = std::make_unique( availableOptions, selectedOptions ); QCOMPARE( dlg->mModel->rowCount(), 3 ); QCOMPARE( dlg->selectedOptions(), selectedOptions ); // order must be maintained! dlg->mModel->item( 2 )->setCheckState( Qt::Checked ); @@ -4070,7 +4017,7 @@ void TestProcessingGui::testMultipleSelectionDialog() // selection buttons selectedOptions.clear(); availableOptions = QVariantList() << QVariant( "a" ) << QVariant( "b" ) << QVariant( "c" ); - dlg = std::make_unique< QgsProcessingMultipleSelectionPanelWidget >( availableOptions, selectedOptions ); + dlg = std::make_unique( availableOptions, selectedOptions ); QVERIFY( dlg->selectedOptions().isEmpty() ); dlg->mSelectionList->selectionModel()->select( dlg->mModel->index( 1, 0 ), QItemSelectionModel::ClearAndSelect ); // without a multi-selection, select all/toggle options should affect all items @@ -4100,12 +4047,11 @@ void TestProcessingGui::testMultipleSelectionDialog() // text format availableOptions = QVariantList() << QVariant( "a" ) << 6 << 6.2; - dlg = std::make_unique< QgsProcessingMultipleSelectionPanelWidget >( availableOptions, selectedOptions ); + dlg = std::make_unique( availableOptions, selectedOptions ); QCOMPARE( dlg->mModel->item( 0 )->text(), QStringLiteral( "a" ) ); QCOMPARE( dlg->mModel->item( 1 )->text(), QStringLiteral( "6" ) ); QCOMPARE( dlg->mModel->item( 2 )->text(), QStringLiteral( "6.2" ) ); - dlg->setValueFormatter( []( const QVariant & v )-> QString - { + dlg->setValueFormatter( []( const QVariant &v ) -> QString { return v.toString() + '_'; } ); QCOMPARE( dlg->mModel->item( 0 )->text(), QStringLiteral( "a_" ) ); @@ -4114,33 +4060,31 @@ void TestProcessingGui::testMultipleSelectionDialog() // mix of fixed + model choices availableOptions = QVariantList() << QVariant( "a" ) << 6 << 6.2 - << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ) - << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ); - dlg = std::make_unique< QgsProcessingMultipleSelectionPanelWidget >( availableOptions, QVariantList() << 6 - << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ) - << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ) ); + << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ) + << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ); + dlg = std::make_unique( availableOptions, QVariantList() << 6 << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ) << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ) ); // when any selected option is a model child parameter source, then we require that all options are upgraded in place to model child parameter sources QVariantList res = dlg->selectedOptions(); QCOMPARE( res.size(), 3 ); - QCOMPARE( res.at( 0 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromStaticValue( 6 ) ); - QCOMPARE( res.at( 1 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); - QCOMPARE( res.at( 2 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ); + QCOMPARE( res.at( 0 ).value(), QgsProcessingModelChildParameterSource::fromStaticValue( 6 ) ); + QCOMPARE( res.at( 1 ).value(), QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); + QCOMPARE( res.at( 2 ).value(), QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ); dlg->selectAll( true ); res = dlg->selectedOptions(); QCOMPARE( res.size(), 5 ); - QCOMPARE( res.at( 0 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromStaticValue( 6 ) ); - QCOMPARE( res.at( 1 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); - QCOMPARE( res.at( 2 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ); - QCOMPARE( res.at( 3 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "a" ) ) ); - QCOMPARE( res.at( 4 ).value< QgsProcessingModelChildParameterSource >(), QgsProcessingModelChildParameterSource::fromStaticValue( 6.2 ) ); + QCOMPARE( res.at( 0 ).value(), QgsProcessingModelChildParameterSource::fromStaticValue( 6 ) ); + QCOMPARE( res.at( 1 ).value(), QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg" ), QStringLiteral( "out" ) ) ); + QCOMPARE( res.at( 2 ).value(), QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "input" ) ) ); + QCOMPARE( res.at( 3 ).value(), QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "a" ) ) ); + QCOMPARE( res.at( 4 ).value(), QgsProcessingModelChildParameterSource::fromStaticValue( 6.2 ) ); } void TestProcessingGui::testMultipleFileSelectionDialog() { - std::unique_ptr< QgsProcessingParameterMultipleLayers > param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::Raster ); + std::unique_ptr param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::Raster ); QVariantList selectedOptions; - std::unique_ptr< QgsProcessingMultipleInputPanelWidget > dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), selectedOptions, QList() ); + std::unique_ptr dlg = std::make_unique( param.get(), selectedOptions, QList() ); QVERIFY( dlg->selectedOptions().isEmpty() ); QCOMPARE( dlg->mModel->rowCount(), 0 ); @@ -4177,21 +4121,21 @@ void TestProcessingGui::testMultipleFileSelectionDialog() QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), raster->id() ); QVERIFY( dlg->selectedOptions().isEmpty() ); // existing value using layer id should match to project layer - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << raster->id(), QList() ); + dlg = std::make_unique( param.get(), QVariantList() << raster->id(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "raster [EPSG:4326]" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), raster->id() ); QCOMPARE( dlg->selectedOptions().size(), 1 ); QCOMPARE( dlg->selectedOptions().at( 0 ).toString(), raster->id() ); // existing value using layer source should also match to project layer - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << raster->source(), QList() ); + dlg = std::make_unique( param.get(), QVariantList() << raster->source(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "raster [EPSG:4326]" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), raster->source() ); QCOMPARE( dlg->selectedOptions().size(), 1 ); QCOMPARE( dlg->selectedOptions().at( 0 ).toString(), raster->source() ); // existing value using full layer path not matching a project layer should work - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << raster->source() << QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ), QList() ); + dlg = std::make_unique( param.get(), QVariantList() << raster->source() << QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 2 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "raster [EPSG:4326]" ) ); @@ -4203,7 +4147,7 @@ void TestProcessingGui::testMultipleFileSelectionDialog() QCOMPARE( dlg->selectedOptions().at( 1 ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); // should remember layer order - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList() << QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) << raster->source(), QList() ); + dlg = std::make_unique( param.get(), QVariantList() << QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) << raster->source(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 2 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QString( QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif" ) ); @@ -4215,16 +4159,16 @@ void TestProcessingGui::testMultipleFileSelectionDialog() QCOMPARE( dlg->selectedOptions().at( 1 ).toString(), raster->source() ); // mesh - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::Mesh ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::Mesh ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 1 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "mesh" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), mesh->id() ); // plugin - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::Plugin ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::Plugin ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 1 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "plugin" ) ); @@ -4232,8 +4176,8 @@ void TestProcessingGui::testMultipleFileSelectionDialog() #ifdef HAVE_EPT // point cloud - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::PointCloud ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::PointCloud ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 1 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "pointcloud [EPSG:28356]" ) ); @@ -4241,8 +4185,8 @@ void TestProcessingGui::testMultipleFileSelectionDialog() #endif // annotation - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::Annotation ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::Annotation ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 2 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "secondary annotations" ) ); @@ -4251,32 +4195,32 @@ void TestProcessingGui::testMultipleFileSelectionDialog() QCOMPARE( dlg->mModel->data( dlg->mModel->index( 1, 0 ), Qt::UserRole ).toString(), QStringLiteral( "main" ) ); // vector points - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::VectorPoint ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::VectorPoint ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 1 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "point [EPSG:4326]" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), point->id() ); // vector lines - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::VectorLine ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::VectorLine ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 1 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "line [EPSG:4326]" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), line->id() ); // vector polygons - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::VectorPolygon ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::VectorPolygon ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 1 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "polygon [EPSG:4326]" ) ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ), Qt::UserRole ).toString(), polygon->id() ); // vector any geometry type - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::VectorAnyGeometry ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::VectorAnyGeometry ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 3 ); QCOMPARE( dlg->mModel->data( dlg->mModel->index( 0, 0 ) ).toString(), QStringLiteral( "line [EPSG:4326]" ) ); @@ -4287,18 +4231,18 @@ void TestProcessingGui::testMultipleFileSelectionDialog() QCOMPARE( dlg->mModel->data( dlg->mModel->index( 2, 0 ), Qt::UserRole ).toString(), polygon->id() ); // vector any type - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::Vector ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::Vector ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 4 ); - QSet< QString > titles; + QSet titles; for ( int i = 0; i < dlg->mModel->rowCount(); ++i ) titles << dlg->mModel->data( dlg->mModel->index( i, 0 ) ).toString(); QCOMPARE( titles, QSet() << QStringLiteral( "polygon [EPSG:4326]" ) << QStringLiteral( "point [EPSG:4326]" ) << QStringLiteral( "line [EPSG:4326]" ) << QStringLiteral( "nogeom" ) ); // any type - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::MapLayer ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::MapLayer ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); #ifdef HAVE_EPT QCOMPARE( dlg->mModel->rowCount(), 10 ); @@ -4310,18 +4254,14 @@ void TestProcessingGui::testMultipleFileSelectionDialog() for ( int i = 0; i < dlg->mModel->rowCount(); ++i ) titles << dlg->mModel->data( dlg->mModel->index( i, 0 ) ).toString(); #ifdef HAVE_EPT - QCOMPARE( titles, QSet() << QStringLiteral( "polygon [EPSG:4326]" ) << QStringLiteral( "point [EPSG:4326]" ) << QStringLiteral( "line [EPSG:4326]" ) - << QStringLiteral( "nogeom" ) << QStringLiteral( "raster [EPSG:4326]" ) << QStringLiteral( "mesh" ) << QStringLiteral( "plugin" ) - << QStringLiteral( "pointcloud [EPSG:28356]" ) << QStringLiteral( "secondary annotations" ) << QStringLiteral( "Annotations" ) ); + QCOMPARE( titles, QSet() << QStringLiteral( "polygon [EPSG:4326]" ) << QStringLiteral( "point [EPSG:4326]" ) << QStringLiteral( "line [EPSG:4326]" ) << QStringLiteral( "nogeom" ) << QStringLiteral( "raster [EPSG:4326]" ) << QStringLiteral( "mesh" ) << QStringLiteral( "plugin" ) << QStringLiteral( "pointcloud [EPSG:28356]" ) << QStringLiteral( "secondary annotations" ) << QStringLiteral( "Annotations" ) ); #else - QCOMPARE( titles, QSet() << QStringLiteral( "polygon [EPSG:4326]" ) << QStringLiteral( "point [EPSG:4326]" ) << QStringLiteral( "line [EPSG:4326]" ) - << QStringLiteral( "nogeom" ) << QStringLiteral( "raster [EPSG:4326]" ) << QStringLiteral( "mesh" ) << QStringLiteral( "plugin" ) - << QStringLiteral( "secondary annotations" ) << QStringLiteral( "Annotations" ) ); + QCOMPARE( titles, QSet() << QStringLiteral( "polygon [EPSG:4326]" ) << QStringLiteral( "point [EPSG:4326]" ) << QStringLiteral( "line [EPSG:4326]" ) << QStringLiteral( "nogeom" ) << QStringLiteral( "raster [EPSG:4326]" ) << QStringLiteral( "mesh" ) << QStringLiteral( "plugin" ) << QStringLiteral( "secondary annotations" ) << QStringLiteral( "Annotations" ) ); #endif // files - param = std::make_unique< QgsProcessingParameterMultipleLayers >( QString(), QString(), Qgis::ProcessingSourceType::File ); - dlg = std::make_unique< QgsProcessingMultipleInputPanelWidget >( param.get(), QVariantList(), QList() ); + param = std::make_unique( QString(), QString(), Qgis::ProcessingSourceType::File ); + dlg = std::make_unique( param.get(), QVariantList(), QList() ); dlg->setProject( QgsProject::instance() ); QCOMPARE( dlg->mModel->rowCount(), 0 ); } @@ -4359,8 +4299,7 @@ void TestProcessingGui::testBandWrapper() const QgsProcessingAlgorithm *statsAlg = QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "native:rasterlayerstatistics" ) ); const QgsProcessingParameterDefinition *layerDef = statsAlg->parameterDefinition( QStringLiteral( "INPUT" ) ); - auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) { TestLayerWrapper layerWrapper( layerDef ); QgsProject p; QgsRasterLayer *rl = new QgsRasterLayer( TEST_DATA_DIR + QStringLiteral( "/landsat.tif" ), QStringLiteral( "x" ), QStringLiteral( "gdal" ) ); @@ -4373,7 +4312,7 @@ void TestProcessingGui::testBandWrapper() QgsProcessingContext context; QWidget *w = wrapper.createWrappedWidget( context ); - ( void )w; + ( void ) w; layerWrapper.setWidgetValue( QVariant::fromValue( rl ), context ); wrapper.setParentLayerWrapperValue( &layerWrapper ); @@ -4386,11 +4325,11 @@ void TestProcessingGui::testBandWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsRasterBandComboBox * >( wrapper.wrappedWidget() )->currentBand(), 3 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentBand(), 3 ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "3" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "3" ) ); break; } @@ -4402,11 +4341,11 @@ void TestProcessingGui::testBandWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsRasterBandComboBox * >( wrapper.wrappedWidget() )->currentBand(), 1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentBand(), 1 ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "1" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "1" ) ); break; } @@ -4423,7 +4362,7 @@ void TestProcessingGui::testBandWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingBandWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( QStringLiteral( "4" ), context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapper2.widgetValue().toInt(), 4 ); + QCOMPARE( wrapper2.widgetValue().toInt(), 4 ); wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 2 ); @@ -4433,11 +4372,11 @@ void TestProcessingGui::testBandWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsRasterBandComboBox * >( wrapper2.wrappedWidget() )->currentBand(), -1 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentBand(), -1 ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text(), QString() ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->text(), QString() ); break; } @@ -4459,11 +4398,11 @@ void TestProcessingGui::testBandWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - static_cast< QgsRasterBandComboBox * >( wrapper2.wrappedWidget() )->setBand( 6 ); + static_cast( wrapper2.wrappedWidget() )->setBand( 6 ); break; case QgsProcessingGui::Modeler: - static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->setText( QStringLiteral( "6" ) ); + static_cast( wrapper2.wrappedWidget() )->setText( QStringLiteral( "6" ) ); break; } @@ -4619,36 +4558,36 @@ void TestProcessingGui::testBandWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "band" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "band" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterBand bandParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), 1, QStringLiteral( "parent" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "band" ), context, widgetContext, &bandParam ); + widget = std::make_unique( QStringLiteral( "band" ), context, widgetContext, &bandParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterBand * >( def.get() )->defaultValue().toString(), QStringLiteral( "1" ) ); - QCOMPARE( static_cast< QgsProcessingParameterBand * >( def.get() )->allowMultiple(), false ); - QCOMPARE( static_cast< QgsProcessingParameterBand * >( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "1" ) ); + QCOMPARE( static_cast( def.get() )->allowMultiple(), false ); + QCOMPARE( static_cast( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); bandParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); bandParam.setParentLayerParameterName( QString() ); bandParam.setAllowMultiple( true ); bandParam.setDefaultValue( QVariantList() << 2 << 3 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "band" ), context, widgetContext, &bandParam ); + widget = std::make_unique( QStringLiteral( "band" ), context, widgetContext, &bandParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterBand * >( def.get() )->defaultValue().toStringList(), QStringList() << "2" << "3" ); - QCOMPARE( static_cast< QgsProcessingParameterBand * >( def.get() )->allowMultiple(), true ); - QVERIFY( static_cast< QgsProcessingParameterBand * >( def.get() )->parentLayerParameterName().isEmpty() ); + QCOMPARE( static_cast( def.get() )->defaultValue().toStringList(), QStringList() << "2" << "3" ); + QCOMPARE( static_cast( def.get() )->allowMultiple(), true ); + QVERIFY( static_cast( def.get() )->parentLayerParameterName().isEmpty() ); } void TestProcessingGui::testMultipleInputWrapper() @@ -4656,8 +4595,7 @@ void TestProcessingGui::testMultipleInputWrapper() QString path1 = TEST_DATA_DIR + QStringLiteral( "/landsat-f32-b1.tif" ); QString path2 = TEST_DATA_DIR + QStringLiteral( "/landsat.tif" ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterMultipleLayers param( QStringLiteral( "multi" ), QStringLiteral( "multi" ), Qgis::ProcessingSourceType::Vector, QVariant(), false ); QgsProcessingMultipleLayerWidgetWrapper wrapper( ¶m, type ); @@ -4665,18 +4603,18 @@ void TestProcessingGui::testMultipleInputWrapper() QgsProcessingContext context; QWidget *w = wrapper.createWrappedWidget( context ); - ( void )w; + ( void ) w; QSignalSpy spy( &wrapper, &QgsProcessingMultipleLayerWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QVariantList() << path1 << path2, context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toList(), QVariantList() << path1 << path2 ); - QCOMPARE( static_cast< QgsProcessingMultipleLayerPanelWidget * >( wrapper.wrappedWidget() )->value().toList(), QVariantList() << path1 << path2 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList(), QVariantList() << path1 << path2 ); wrapper.setWidgetValue( path1, context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toStringList(), QStringList() << path1 ); - QCOMPARE( static_cast< QgsProcessingMultipleLayerPanelWidget * >( wrapper.wrappedWidget() )->value().toList(), QVariantList() << path1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList(), QVariantList() << path1 ); delete w; // optional @@ -4693,7 +4631,7 @@ void TestProcessingGui::testMultipleInputWrapper() wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 2 ); QVERIFY( !wrapper2.widgetValue().isValid() ); - QVERIFY( static_cast< QgsProcessingMultipleLayerPanelWidget * >( wrapper2.wrappedWidget() )->value().toList().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->value().toList().isEmpty() ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -4709,7 +4647,7 @@ void TestProcessingGui::testMultipleInputWrapper() } // check signal - static_cast< QgsProcessingMultipleLayerPanelWidget * >( wrapper2.wrappedWidget() )->setValue( QVariantList() << path1 ); + static_cast( wrapper2.wrappedWidget() )->setValue( QVariantList() << path1 ); QCOMPARE( spy2.count(), 3 ); @@ -4717,20 +4655,17 @@ void TestProcessingGui::testMultipleInputWrapper() { // different mix of sources - wrapper2.setWidgetValue( QVariantList() - << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg3" ), QStringLiteral( "OUTPUT" ) ) ) - << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "p1" ) ) ) - << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "something" ) ) ), context ) ; + wrapper2.setWidgetValue( QVariantList() << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromChildOutput( QStringLiteral( "alg3" ), QStringLiteral( "OUTPUT" ) ) ) << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "p1" ) ) ) << QVariant::fromValue( QgsProcessingModelChildParameterSource::fromStaticValue( QStringLiteral( "something" ) ) ), context ); QCOMPARE( wrapper2.widgetValue().toList().count(), 3 ); - QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); - QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); - QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().outputChildId(), QStringLiteral( "alg3" ) ); - QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value< QgsProcessingModelChildParameterSource>().outputName(), QStringLiteral( "OUTPUT" ) ); - QCOMPARE( wrapper2.widgetValue().toList().at( 1 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); - QCOMPARE( wrapper2.widgetValue().toList().at( 1 ).value< QgsProcessingModelChildParameterSource>().parameterName(), QStringLiteral( "p1" ) ); - QCOMPARE( wrapper2.widgetValue().toList().at( 2 ).value< QgsProcessingModelChildParameterSource>().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); - QCOMPARE( wrapper2.widgetValue().toList().at( 2 ).value< QgsProcessingModelChildParameterSource>().staticValue().toString(), QStringLiteral( "something" ) ); + QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); + QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value().source(), Qgis::ProcessingModelChildParameterSource::ChildOutput ); + QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value().outputChildId(), QStringLiteral( "alg3" ) ); + QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).value().outputName(), QStringLiteral( "OUTPUT" ) ); + QCOMPARE( wrapper2.widgetValue().toList().at( 1 ).value().source(), Qgis::ProcessingModelChildParameterSource::ModelParameter ); + QCOMPARE( wrapper2.widgetValue().toList().at( 1 ).value().parameterName(), QStringLiteral( "p1" ) ); + QCOMPARE( wrapper2.widgetValue().toList().at( 2 ).value().source(), Qgis::ProcessingModelChildParameterSource::StaticValue ); + QCOMPARE( wrapper2.widgetValue().toList().at( 2 ).value().staticValue().toString(), QStringLiteral( "something" ) ); delete w; } }; @@ -4747,30 +4682,30 @@ void TestProcessingGui::testMultipleInputWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "multilayer" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "multilayer" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterMultipleLayers layersParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "multilayer" ), context, widgetContext, &layersParam ); + widget = std::make_unique( QStringLiteral( "multilayer" ), context, widgetContext, &layersParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterMultipleLayers * >( def.get() )->layerType(), Qgis::ProcessingSourceType::VectorAnyGeometry ); + QCOMPARE( static_cast( def.get() )->layerType(), Qgis::ProcessingSourceType::VectorAnyGeometry ); layersParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); layersParam.setLayerType( Qgis::ProcessingSourceType::Raster ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "multilayer" ), context, widgetContext, &layersParam ); + widget = std::make_unique( QStringLiteral( "multilayer" ), context, widgetContext, &layersParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterMultipleLayers * >( def.get() )->layerType(), Qgis::ProcessingSourceType::Raster ); + QCOMPARE( static_cast( def.get() )->layerType(), Qgis::ProcessingSourceType::Raster ); } void TestProcessingGui::testEnumSelectionPanel() @@ -4828,24 +4763,24 @@ void TestProcessingGui::testEnumCheckboxPanel() panel.setValue( 2 ); QCOMPARE( spy.count(), 1 ); QCOMPARE( panel.value().toInt(), 2 ); - QVERIFY( !panel.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel.mButtons[0]->isChecked() ); + QVERIFY( !panel.mButtons[1]->isChecked() ); + QVERIFY( panel.mButtons[2]->isChecked() ); panel.setValue( 0 ); QCOMPARE( spy.count(), 2 ); QCOMPARE( panel.value().toInt(), 0 ); - QVERIFY( panel.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel.mButtons[ 2 ]->isChecked() ); + QVERIFY( panel.mButtons[0]->isChecked() ); + QVERIFY( !panel.mButtons[1]->isChecked() ); + QVERIFY( !panel.mButtons[2]->isChecked() ); panel.mButtons[1]->setChecked( true ); QCOMPARE( spy.count(), 4 ); QCOMPARE( panel.value().toInt(), 1 ); panel.setValue( QVariantList() << 2 ); QCOMPARE( spy.count(), 5 ); QCOMPARE( panel.value().toInt(), 2 ); - QVERIFY( !panel.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel.mButtons[0]->isChecked() ); + QVERIFY( !panel.mButtons[1]->isChecked() ); + QVERIFY( panel.mButtons[2]->isChecked() ); // multiple value QgsProcessingParameterEnum param2( QStringLiteral( "enum" ), QStringLiteral( "enum" ), QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ), true ); @@ -4856,21 +4791,21 @@ void TestProcessingGui::testEnumCheckboxPanel() panel2.setValue( 2 ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( panel2.value().toList(), QVariantList() << 2 ); - QVERIFY( !panel2.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel2.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel2.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel2.mButtons[0]->isChecked() ); + QVERIFY( !panel2.mButtons[1]->isChecked() ); + QVERIFY( panel2.mButtons[2]->isChecked() ); panel2.setValue( QVariantList() << 0 << 1 ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( panel2.value().toList(), QVariantList() << 0 << 1 ); - QVERIFY( panel2.mButtons[ 0 ]->isChecked() ); - QVERIFY( panel2.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel2.mButtons[ 2 ]->isChecked() ); + QVERIFY( panel2.mButtons[0]->isChecked() ); + QVERIFY( panel2.mButtons[1]->isChecked() ); + QVERIFY( !panel2.mButtons[2]->isChecked() ); panel2.mButtons[0]->setChecked( false ); QCOMPARE( spy2.count(), 3 ); - QCOMPARE( panel2.value().toList(), QVariantList() << 1 ); + QCOMPARE( panel2.value().toList(), QVariantList() << 1 ); panel2.mButtons[2]->setChecked( true ); QCOMPARE( spy2.count(), 4 ); - QCOMPARE( panel2.value().toList(), QVariantList() << 1 << 2 ); + QCOMPARE( panel2.value().toList(), QVariantList() << 1 << 2 ); panel2.deselectAll(); QCOMPARE( spy2.count(), 5 ); QCOMPARE( panel2.value().toList(), QVariantList() ); @@ -4887,21 +4822,21 @@ void TestProcessingGui::testEnumCheckboxPanel() panel3.setValue( 2 ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( panel3.value().toList(), QVariantList() << 2 ); - QVERIFY( !panel3.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel3.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel3.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel3.mButtons[0]->isChecked() ); + QVERIFY( !panel3.mButtons[1]->isChecked() ); + QVERIFY( panel3.mButtons[2]->isChecked() ); panel3.setValue( QVariantList() << 0 << 1 ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( panel3.value().toList(), QVariantList() << 0 << 1 ); - QVERIFY( panel3.mButtons[ 0 ]->isChecked() ); - QVERIFY( panel3.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel3.mButtons[ 2 ]->isChecked() ); + QVERIFY( panel3.mButtons[0]->isChecked() ); + QVERIFY( panel3.mButtons[1]->isChecked() ); + QVERIFY( !panel3.mButtons[2]->isChecked() ); panel3.mButtons[0]->setChecked( false ); QCOMPARE( spy3.count(), 3 ); - QCOMPARE( panel3.value().toList(), QVariantList() << 1 ); + QCOMPARE( panel3.value().toList(), QVariantList() << 1 ); panel3.mButtons[2]->setChecked( true ); QCOMPARE( spy3.count(), 4 ); - QCOMPARE( panel3.value().toList(), QVariantList() << 1 << 2 ); + QCOMPARE( panel3.value().toList(), QVariantList() << 1 << 2 ); panel3.deselectAll(); QCOMPARE( spy3.count(), 5 ); QCOMPARE( panel3.value().toList(), QVariantList() ); @@ -4910,17 +4845,17 @@ void TestProcessingGui::testEnumCheckboxPanel() QCOMPARE( panel3.value().toList(), QVariantList() << 0 << 1 << 2 ); panel3.setValue( QVariantList() ); QCOMPARE( panel3.value().toList(), QVariantList() ); - QVERIFY( !panel3.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel3.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel3.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel3.mButtons[0]->isChecked() ); + QVERIFY( !panel3.mButtons[1]->isChecked() ); + QVERIFY( !panel3.mButtons[2]->isChecked() ); QCOMPARE( spy3.count(), 7 ); panel3.selectAll(); QCOMPARE( spy3.count(), 8 ); panel3.setValue( QVariant() ); QCOMPARE( panel3.value().toList(), QVariantList() ); - QVERIFY( !panel3.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel3.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel3.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel3.mButtons[0]->isChecked() ); + QVERIFY( !panel3.mButtons[1]->isChecked() ); + QVERIFY( !panel3.mButtons[2]->isChecked() ); QCOMPARE( spy3.count(), 9 ); //single value using static strings @@ -4932,24 +4867,24 @@ void TestProcessingGui::testEnumCheckboxPanel() panel4.setValue( QStringLiteral( "c" ) ); QCOMPARE( spy4.count(), 1 ); QCOMPARE( panel4.value().toString(), QStringLiteral( "c" ) ); - QVERIFY( !panel4.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel4.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel4.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel4.mButtons[0]->isChecked() ); + QVERIFY( !panel4.mButtons[1]->isChecked() ); + QVERIFY( panel4.mButtons[2]->isChecked() ); panel4.setValue( QStringLiteral( "a" ) ); QCOMPARE( spy4.count(), 2 ); QCOMPARE( panel4.value().toString(), QStringLiteral( "a" ) ); - QVERIFY( panel4.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel4.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel4.mButtons[ 2 ]->isChecked() ); + QVERIFY( panel4.mButtons[0]->isChecked() ); + QVERIFY( !panel4.mButtons[1]->isChecked() ); + QVERIFY( !panel4.mButtons[2]->isChecked() ); panel4.mButtons[1]->setChecked( true ); QCOMPARE( spy4.count(), 4 ); QCOMPARE( panel4.value().toString(), QStringLiteral( "b" ) ); panel4.setValue( QVariantList() << QStringLiteral( "c" ) ); QCOMPARE( spy4.count(), 5 ); QCOMPARE( panel4.value().toString(), QStringLiteral( "c" ) ); - QVERIFY( !panel4.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel4.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel4.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel4.mButtons[0]->isChecked() ); + QVERIFY( !panel4.mButtons[1]->isChecked() ); + QVERIFY( panel4.mButtons[2]->isChecked() ); // multiple value with static strings QgsProcessingParameterEnum param5( QStringLiteral( "enum" ), QStringLiteral( "enum" ), QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ), true, QVariant(), false, true ); @@ -4960,18 +4895,18 @@ void TestProcessingGui::testEnumCheckboxPanel() panel5.setValue( QStringLiteral( "c" ) ); QCOMPARE( spy5.count(), 1 ); QCOMPARE( panel5.value().toList(), QVariantList() << QStringLiteral( "c" ) ); - QVERIFY( !panel5.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel5.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel5.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel5.mButtons[0]->isChecked() ); + QVERIFY( !panel5.mButtons[1]->isChecked() ); + QVERIFY( panel5.mButtons[2]->isChecked() ); panel5.setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); QCOMPARE( spy5.count(), 2 ); QCOMPARE( panel5.value().toList(), QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); - QVERIFY( panel5.mButtons[ 0 ]->isChecked() ); - QVERIFY( panel5.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel5.mButtons[ 2 ]->isChecked() ); + QVERIFY( panel5.mButtons[0]->isChecked() ); + QVERIFY( panel5.mButtons[1]->isChecked() ); + QVERIFY( !panel5.mButtons[2]->isChecked() ); panel5.mButtons[0]->setChecked( false ); QCOMPARE( spy5.count(), 3 ); - QCOMPARE( panel5.value().toList(), QVariantList() << QStringLiteral( "b" ) ); + QCOMPARE( panel5.value().toList(), QVariantList() << QStringLiteral( "b" ) ); panel5.mButtons[2]->setChecked( true ); QCOMPARE( spy5.count(), 4 ); QCOMPARE( panel5.value().toList(), QVariantList() << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); @@ -4991,15 +4926,15 @@ void TestProcessingGui::testEnumCheckboxPanel() panel6.setValue( QStringLiteral( "c" ) ); QCOMPARE( spy6.count(), 1 ); QCOMPARE( panel6.value().toList(), QVariantList() << QStringLiteral( "c" ) ); - QVERIFY( !panel6.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel6.mButtons[ 1 ]->isChecked() ); - QVERIFY( panel6.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel6.mButtons[0]->isChecked() ); + QVERIFY( !panel6.mButtons[1]->isChecked() ); + QVERIFY( panel6.mButtons[2]->isChecked() ); panel6.setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); QCOMPARE( spy6.count(), 2 ); QCOMPARE( panel6.value().toList(), QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); - QVERIFY( panel6.mButtons[ 0 ]->isChecked() ); - QVERIFY( panel6.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel6.mButtons[ 2 ]->isChecked() ); + QVERIFY( panel6.mButtons[0]->isChecked() ); + QVERIFY( panel6.mButtons[1]->isChecked() ); + QVERIFY( !panel6.mButtons[2]->isChecked() ); panel6.mButtons[0]->setChecked( false ); QCOMPARE( spy6.count(), 3 ); QCOMPARE( panel6.value().toList(), QVariantList() << QStringLiteral( "b" ) ); @@ -5014,24 +4949,23 @@ void TestProcessingGui::testEnumCheckboxPanel() QCOMPARE( panel6.value().toList(), QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); panel6.setValue( QVariantList() ); QCOMPARE( panel6.value().toList(), QVariantList() ); - QVERIFY( !panel6.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel6.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel6.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel6.mButtons[0]->isChecked() ); + QVERIFY( !panel6.mButtons[1]->isChecked() ); + QVERIFY( !panel6.mButtons[2]->isChecked() ); QCOMPARE( spy6.count(), 7 ); panel6.selectAll(); QCOMPARE( spy6.count(), 8 ); panel6.setValue( QVariant() ); QCOMPARE( panel6.value().toList(), QVariantList() ); - QVERIFY( !panel6.mButtons[ 0 ]->isChecked() ); - QVERIFY( !panel6.mButtons[ 1 ]->isChecked() ); - QVERIFY( !panel6.mButtons[ 2 ]->isChecked() ); + QVERIFY( !panel6.mButtons[0]->isChecked() ); + QVERIFY( !panel6.mButtons[1]->isChecked() ); + QVERIFY( !panel6.mButtons[2]->isChecked() ); QCOMPARE( spy6.count(), 9 ); } void TestProcessingGui::testEnumWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type, bool checkboxStyle = false ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type, bool checkboxStyle = false ) { // non optional, single value QgsProcessingParameterEnum param( QStringLiteral( "enum" ), QStringLiteral( "enum" ), QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ), false ); QVariantMap metadata; @@ -5049,27 +4983,27 @@ void TestProcessingGui::testEnumWrapper() QSignalSpy spy( &wrapper, &QgsProcessingEnumWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( 1, context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().toInt(), 1 ); + QCOMPARE( wrapper.widgetValue().toInt(), 1 ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentIndex(), 1 ); - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentIndex(), 1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper.wrappedWidget() )->value().toInt(), 1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toInt(), 1 ); } wrapper.setWidgetValue( 0, context ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( wrapper.widgetValue().toInt(), 0 ); + QCOMPARE( wrapper.widgetValue().toInt(), 0 ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentIndex(), 0 ); - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentIndex(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper.wrappedWidget() )->value().toInt(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toInt(), 0 ); } QLabel *l = wrapper.createWrappedLabel(); @@ -5087,9 +5021,9 @@ void TestProcessingGui::testEnumWrapper() // check signal if ( !checkboxStyle ) - static_cast< QComboBox * >( wrapper.wrappedWidget() )->setCurrentIndex( 2 ); + static_cast( wrapper.wrappedWidget() )->setCurrentIndex( 2 ); else - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper.wrappedWidget() )->setValue( 2 ); + static_cast( wrapper.wrappedWidget() )->setValue( 2 ); QCOMPARE( spy.count(), 3 ); delete w; @@ -5106,42 +5040,42 @@ void TestProcessingGui::testEnumWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingEnumWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( 1, context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapper2.widgetValue().toInt(), 1 ); + QCOMPARE( wrapper2.widgetValue().toInt(), 1 ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentIndex(), 2 ); - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentIndex(), 2 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper2.wrappedWidget() )->value().toInt(), 1 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->value().toInt(), 1 ); } wrapper2.setWidgetValue( 0, context ); QCOMPARE( spy2.count(), 2 ); - QCOMPARE( wrapper2.widgetValue().toInt(), 0 ); + QCOMPARE( wrapper2.widgetValue().toInt(), 0 ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentIndex(), 1 ); - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentIndex(), 1 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper2.wrappedWidget() )->value().toInt(), 0 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->value().toInt(), 0 ); } wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 3 ); if ( !checkboxStyle ) { QVERIFY( !wrapper2.widgetValue().isValid() ); - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentIndex(), 0 ); - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "[Not selected]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentIndex(), 0 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "[Not selected]" ) ); } // check signal if ( !checkboxStyle ) - static_cast< QComboBox * >( wrapper2.wrappedWidget() )->setCurrentIndex( 2 ); + static_cast( wrapper2.wrappedWidget() )->setCurrentIndex( 2 ); else - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper2.wrappedWidget() )->setValue( 1 ); + static_cast( wrapper2.wrappedWidget() )->setValue( 1 ); QCOMPARE( spy2.count(), 4 ); delete w; @@ -5160,34 +5094,34 @@ void TestProcessingGui::testEnumWrapper() QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toList(), QVariantList() << 1 ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 1 ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 1 ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 1 ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 1 ); wrapper3.setWidgetValue( 0, context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toList(), QVariantList() << 0 ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 0 ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 0 ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 0 ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 0 ); wrapper3.setWidgetValue( QVariantList() << 2 << 1, context ); QCOMPARE( spy3.count(), 3 ); if ( !checkboxStyle ) { QCOMPARE( wrapper3.widgetValue().toList(), QVariantList() << 2 << 1 ); - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 2 << 1 ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 2 << 1 ); } else { // checkbox style isn't ordered QCOMPARE( wrapper3.widgetValue().toList(), QVariantList() << 1 << 2 ); - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 1 << 2 ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toList(), QVariantList() << 1 << 2 ); } // check signal if ( !checkboxStyle ) - static_cast< QgsProcessingEnumPanelWidget * >( wrapper3.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); + static_cast( wrapper3.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); else - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper3.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); + static_cast( wrapper3.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); QCOMPARE( spy3.count(), 4 ); @@ -5207,58 +5141,58 @@ void TestProcessingGui::testEnumWrapper() QCOMPARE( spy4.count(), 1 ); QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() << 1 ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 1 ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 1 ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 1 ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 1 ); wrapper4.setWidgetValue( 0, context ); QCOMPARE( spy4.count(), 2 ); QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() << 0 ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 0 ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 0 ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 0 ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 0 ); wrapper4.setWidgetValue( QVariantList() << 2 << 1, context ); QCOMPARE( spy4.count(), 3 ); if ( !checkboxStyle ) { QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() << 2 << 1 ); - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 2 << 1 ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 2 << 1 ); } else { // checkbox style isn't ordered QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() << 1 << 2 ); - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 1 << 2 ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() << 1 << 2 ); } wrapper4.setWidgetValue( QVariantList(), context ); QCOMPARE( spy4.count(), 4 ); QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); wrapper4.setWidgetValue( QVariant(), context ); QCOMPARE( spy4.count(), 5 ); QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->value().toList(), QVariantList() ); // check signal if ( !checkboxStyle ) { - static_cast< QgsProcessingEnumPanelWidget * >( wrapper4.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); + static_cast( wrapper4.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); QCOMPARE( spy4.count(), 6 ); - static_cast< QgsProcessingEnumPanelWidget * >( wrapper4.wrappedWidget() )->setValue( QVariant() ); + static_cast( wrapper4.wrappedWidget() )->setValue( QVariant() ); QCOMPARE( spy4.count(), 7 ); } else { - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper4.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); + static_cast( wrapper4.wrappedWidget() )->setValue( QVariantList() << 0 << 1 ); QCOMPARE( spy4.count(), 6 ); - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper4.wrappedWidget() )->setValue( QVariant() ); + static_cast( wrapper4.wrappedWidget() )->setValue( QVariant() ); QCOMPARE( spy4.count(), 7 ); } @@ -5279,31 +5213,31 @@ void TestProcessingGui::testEnumWrapper() QCOMPARE( wrapper5.widgetValue().toString(), QStringLiteral( "b" ) ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper5.wrappedWidget() )->currentIndex(), 1 ); - QCOMPARE( static_cast< QComboBox * >( wrapper5.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->currentIndex(), 1 ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper5.wrappedWidget() )->value().toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->value().toString(), QStringLiteral( "b" ) ); } wrapper5.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy5.count(), 2 ); QCOMPARE( wrapper5.widgetValue().toString(), QStringLiteral( "a" ) ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper5.wrappedWidget() )->currentIndex(), 0 ); - QCOMPARE( static_cast< QComboBox * >( wrapper5.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->currentIndex(), 0 ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper5.wrappedWidget() )->value().toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->value().toString(), QStringLiteral( "a" ) ); } // check signal if ( !checkboxStyle ) - static_cast< QComboBox * >( wrapper5.wrappedWidget() )->setCurrentIndex( 2 ); + static_cast( wrapper5.wrappedWidget() )->setCurrentIndex( 2 ); else - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper5.wrappedWidget() )->setValue( QStringLiteral( "c" ) ); + static_cast( wrapper5.wrappedWidget() )->setValue( QStringLiteral( "c" ) ); QCOMPARE( spy5.count(), 3 ); delete w; @@ -5323,39 +5257,39 @@ void TestProcessingGui::testEnumWrapper() QCOMPARE( wrapper6.widgetValue().toString(), QStringLiteral( "b" ) ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper6.wrappedWidget() )->currentIndex(), 2 ); - QCOMPARE( static_cast< QComboBox * >( wrapper6.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->currentIndex(), 2 ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper6.wrappedWidget() )->value().toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->value().toString(), QStringLiteral( "b" ) ); } wrapper6.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy6.count(), 2 ); QCOMPARE( wrapper6.widgetValue().toString(), QStringLiteral( "a" ) ); if ( !checkboxStyle ) { - QCOMPARE( static_cast< QComboBox * >( wrapper6.wrappedWidget() )->currentIndex(), 1 ); - QCOMPARE( static_cast< QComboBox * >( wrapper6.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->currentIndex(), 1 ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); } else { - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper6.wrappedWidget() )->value().toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->value().toString(), QStringLiteral( "a" ) ); } wrapper6.setWidgetValue( QVariant(), context ); QCOMPARE( spy6.count(), 3 ); if ( !checkboxStyle ) { QVERIFY( !wrapper6.widgetValue().isValid() ); - QCOMPARE( static_cast< QComboBox * >( wrapper6.wrappedWidget() )->currentIndex(), 0 ); - QCOMPARE( static_cast< QComboBox * >( wrapper6.wrappedWidget() )->currentText(), QStringLiteral( "[Not selected]" ) ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->currentIndex(), 0 ); + QCOMPARE( static_cast( wrapper6.wrappedWidget() )->currentText(), QStringLiteral( "[Not selected]" ) ); } // check signal if ( !checkboxStyle ) - static_cast< QComboBox * >( wrapper6.wrappedWidget() )->setCurrentIndex( 2 ); + static_cast( wrapper6.wrappedWidget() )->setCurrentIndex( 2 ); else - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper6.wrappedWidget() )->setValue( QStringLiteral( "a" ) ); + static_cast( wrapper6.wrappedWidget() )->setValue( QStringLiteral( "a" ) ); QCOMPARE( spy6.count(), 4 ); delete w; @@ -5374,34 +5308,34 @@ void TestProcessingGui::testEnumWrapper() QCOMPARE( spy7.count(), 1 ); QCOMPARE( wrapper7.widgetValue().toList(), QVariantList() << QStringLiteral( "b" ) ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); wrapper7.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy7.count(), 2 ); QCOMPARE( wrapper7.widgetValue().toList(), QVariantList() << QStringLiteral( "a" ) ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); wrapper7.setWidgetValue( QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ), context ); QCOMPARE( spy7.count(), 3 ); if ( !checkboxStyle ) { QCOMPARE( wrapper7.widgetValue().toList(), QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ) ); } else { // checkbox style isn't ordered QCOMPARE( wrapper7.widgetValue().toList(), QVariantList() << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); + QCOMPARE( static_cast( wrapper7.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); } // check signal if ( !checkboxStyle ) - static_cast< QgsProcessingEnumPanelWidget * >( wrapper7.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); + static_cast( wrapper7.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); else - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper7.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); + static_cast( wrapper7.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); QCOMPARE( spy7.count(), 4 ); @@ -5421,58 +5355,58 @@ void TestProcessingGui::testEnumWrapper() QCOMPARE( spy8.count(), 1 ); QCOMPARE( wrapper8.widgetValue().toList(), QVariantList() << QStringLiteral( "b" ) ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) ); wrapper8.setWidgetValue( QStringLiteral( "a" ), context ); QCOMPARE( spy8.count(), 2 ); QCOMPARE( wrapper8.widgetValue().toList(), QVariantList() << QStringLiteral( "a" ) ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "a" ) ); wrapper8.setWidgetValue( QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ), context ); QCOMPARE( spy8.count(), 3 ); if ( !checkboxStyle ) { QCOMPARE( wrapper8.widgetValue().toList(), QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "c" ) << QStringLiteral( "b" ) ); } else { // checkbox style isn't ordered QCOMPARE( wrapper8.widgetValue().toList(), QVariantList() << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() << QStringLiteral( "b" ) << QStringLiteral( "c" ) ); } wrapper8.setWidgetValue( QVariantList(), context ); QCOMPARE( spy8.count(), 4 ); QCOMPARE( wrapper8.widgetValue().toList(), QVariantList() ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); wrapper8.setWidgetValue( QVariant(), context ); QCOMPARE( spy8.count(), 5 ); QCOMPARE( wrapper8.widgetValue().toList(), QVariantList() ); if ( !checkboxStyle ) - QCOMPARE( static_cast< QgsProcessingEnumPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); else - QCOMPARE( static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); + QCOMPARE( static_cast( wrapper8.wrappedWidget() )->value().toList(), QVariantList() ); // check signal if ( !checkboxStyle ) { - static_cast< QgsProcessingEnumPanelWidget * >( wrapper8.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); + static_cast( wrapper8.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); QCOMPARE( spy8.count(), 6 ); - static_cast< QgsProcessingEnumPanelWidget * >( wrapper8.wrappedWidget() )->setValue( QVariant() ); + static_cast( wrapper8.wrappedWidget() )->setValue( QVariant() ); QCOMPARE( spy8.count(), 7 ); } else { - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper8.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); + static_cast( wrapper8.wrappedWidget() )->setValue( QVariantList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); QCOMPARE( spy8.count(), 6 ); - static_cast< QgsProcessingEnumCheckboxPanelWidget * >( wrapper8.wrappedWidget() )->setValue( QVariant() ); + static_cast( wrapper8.wrappedWidget() )->setValue( QVariant() ); QCOMPARE( spy8.count(), 7 ); } @@ -5494,35 +5428,35 @@ void TestProcessingGui::testEnumWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "enum" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "enum" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterEnum enumParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringList() << "A" << "B" << "C", false, 2 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "enum" ), context, widgetContext, &enumParam ); + widget = std::make_unique( QStringLiteral( "enum" ), context, widgetContext, &enumParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterEnum * >( def.get() )->options(), QStringList() << "A" << "B" << "C" ); - QCOMPARE( static_cast< QgsProcessingParameterEnum * >( def.get() )->defaultValue().toStringList(), QStringList() << "2" ); - QVERIFY( !static_cast< QgsProcessingParameterEnum * >( def.get() )->allowMultiple() ); + QCOMPARE( static_cast( def.get() )->options(), QStringList() << "A" << "B" << "C" ); + QCOMPARE( static_cast( def.get() )->defaultValue().toStringList(), QStringList() << "2" ); + QVERIFY( !static_cast( def.get() )->allowMultiple() ); enumParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); enumParam.setAllowMultiple( true ); enumParam.setDefaultValue( QVariantList() << 0 << 1 ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "enum" ), context, widgetContext, &enumParam ); + widget = std::make_unique( QStringLiteral( "enum" ), context, widgetContext, &enumParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterEnum * >( def.get() )->options(), QStringList() << "A" << "B" << "C" ); - QCOMPARE( static_cast< QgsProcessingParameterEnum * >( def.get() )->defaultValue().toStringList(), QStringList() << "0" << "1" ); - QVERIFY( static_cast< QgsProcessingParameterEnum * >( def.get() )->allowMultiple() ); + QCOMPARE( static_cast( def.get() )->options(), QStringList() << "A" << "B" << "C" ); + QCOMPARE( static_cast( def.get() )->defaultValue().toStringList(), QStringList() << "0" << "1" ); + QVERIFY( static_cast( def.get() )->allowMultiple() ); } void TestProcessingGui::testLayoutWrapper() @@ -5535,8 +5469,7 @@ void TestProcessingGui::testLayoutWrapper() l2->setName( "l2" ); p.layoutManager()->addLayout( l2 ); - auto testWrapper = [&p]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [&p]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterLayout param( QStringLiteral( "layout" ), QStringLiteral( "layout" ), false ); @@ -5552,27 +5485,27 @@ void TestProcessingGui::testLayoutWrapper() QSignalSpy spy( &wrapper, &QgsProcessingLayoutWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( "l2", context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "l2" ) ); + QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "l2" ) ); if ( type != QgsProcessingGui::Modeler ) { - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper.wrappedWidget() )->currentIndex(), 1 ); - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentIndex(), 1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); } else { - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); } wrapper.setWidgetValue( "l1", context ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "l1" ) ); + QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "l1" ) ); if ( type != QgsProcessingGui::Modeler ) { - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper.wrappedWidget() )->currentIndex(), 0 ); - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentIndex(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); } else { - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); } QLabel *l = wrapper.createWrappedLabel(); @@ -5591,11 +5524,11 @@ void TestProcessingGui::testLayoutWrapper() // check signal if ( type != QgsProcessingGui::Modeler ) { - static_cast< QComboBox * >( wrapper.wrappedWidget() )->setCurrentIndex( 1 ); + static_cast( wrapper.wrappedWidget() )->setCurrentIndex( 1 ); } else { - static_cast< QComboBox * >( wrapper.wrappedWidget() )->setCurrentText( QStringLiteral( "aaaa" ) ); + static_cast( wrapper.wrappedWidget() )->setCurrentText( QStringLiteral( "aaaa" ) ); } QCOMPARE( spy.count(), 3 ); @@ -5615,43 +5548,43 @@ void TestProcessingGui::testLayoutWrapper() QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "l2" ) ); if ( type != QgsProcessingGui::Modeler ) { - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper2.wrappedWidget() )->currentIndex(), 2 ); - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentIndex(), 2 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); } else { - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l2" ) ); } wrapper2.setWidgetValue( "l1", context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "l1" ) ); if ( type != QgsProcessingGui::Modeler ) { - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper2.wrappedWidget() )->currentIndex(), 1 ); - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentIndex(), 1 ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); } else { - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); } wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 3 ); QVERIFY( !wrapper2.widgetValue().isValid() ); if ( type != QgsProcessingGui::Modeler ) { - QCOMPARE( static_cast< QgsLayoutComboBox * >( wrapper2.wrappedWidget() )->currentIndex(), 0 ); - QVERIFY( static_cast< QgsLayoutComboBox * >( wrapper2.wrappedWidget() )->currentText().isEmpty() ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentIndex(), 0 ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->currentText().isEmpty() ); } else { - QVERIFY( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->currentText().isEmpty() ); } // check signal if ( type != QgsProcessingGui::Modeler ) - static_cast< QComboBox * >( wrapper2.wrappedWidget() )->setCurrentIndex( 2 ); + static_cast( wrapper2.wrappedWidget() )->setCurrentIndex( 2 ); else - static_cast< QComboBox * >( wrapper2.wrappedWidget() )->setCurrentText( QStringLiteral( "aaa" ) ); + static_cast( wrapper2.wrappedWidget() )->setCurrentText( QStringLiteral( "aaa" ) ); QCOMPARE( spy2.count(), 4 ); delete w; @@ -5665,7 +5598,6 @@ void TestProcessingGui::testLayoutWrapper() // modeler wrapper testWrapper( QgsProcessingGui::Modeler ); - } void TestProcessingGui::testLayoutItemWrapper() @@ -5681,8 +5613,7 @@ void TestProcessingGui::testLayoutItemWrapper() label2->setId( "b" ); l1->addLayoutItem( label2 ); - auto testWrapper = [&p, l1, label1, label2]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [&p, l1, label1, label2]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterLayoutItem param( QStringLiteral( "layout" ), QStringLiteral( "layout" ), false ); @@ -5703,24 +5634,24 @@ void TestProcessingGui::testLayoutItemWrapper() if ( type != QgsProcessingGui::Modeler ) { QCOMPARE( wrapper.widgetValue().toString(), label2->uuid() ); - QCOMPARE( static_cast< QgsLayoutItemComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); } else { QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "b" ) ); } wrapper.setWidgetValue( "a", context ); QCOMPARE( spy.count(), 2 ); if ( type != QgsProcessingGui::Modeler ) { QCOMPARE( wrapper.widgetValue().toString(), label1->uuid() ); - QCOMPARE( static_cast< QgsLayoutItemComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); } else { QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "a" ) ); } QLabel *l = wrapper.createWrappedLabel(); @@ -5739,11 +5670,11 @@ void TestProcessingGui::testLayoutItemWrapper() // check signal if ( type != QgsProcessingGui::Modeler ) { - static_cast< QComboBox * >( wrapper.wrappedWidget() )->setCurrentIndex( 1 ); + static_cast( wrapper.wrappedWidget() )->setCurrentIndex( 1 ); } else { - static_cast< QLineEdit * >( wrapper.wrappedWidget() )->setText( QStringLiteral( "aaaa" ) ); + static_cast( wrapper.wrappedWidget() )->setText( QStringLiteral( "aaaa" ) ); } QCOMPARE( spy.count(), 3 ); @@ -5764,42 +5695,42 @@ void TestProcessingGui::testLayoutItemWrapper() if ( type != QgsProcessingGui::Modeler ) { QCOMPARE( wrapper2.widgetValue().toString(), label2->uuid() ); - QCOMPARE( static_cast< QgsLayoutItemComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "b" ) ); } else { QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->text(), QStringLiteral( "b" ) ); } wrapper2.setWidgetValue( "a", context ); QCOMPARE( spy2.count(), 2 ); if ( type != QgsProcessingGui::Modeler ) { QCOMPARE( wrapper2.widgetValue().toString(), label1->uuid() ); - QCOMPARE( static_cast< QgsLayoutItemComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "a" ) ); } else { QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->text(), QStringLiteral( "a" ) ); } wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 3 ); QVERIFY( !wrapper2.widgetValue().isValid() ); if ( type != QgsProcessingGui::Modeler ) { - QVERIFY( static_cast< QgsLayoutItemComboBox * >( wrapper2.wrappedWidget() )->currentText().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->currentText().isEmpty() ); } else { - QVERIFY( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->text().isEmpty() ); } // check signal if ( type != QgsProcessingGui::Modeler ) - static_cast< QgsLayoutItemComboBox * >( wrapper2.wrappedWidget() )->setCurrentIndex( 1 ); + static_cast( wrapper2.wrappedWidget() )->setCurrentIndex( 1 ); else - static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->setText( QStringLiteral( "aaa" ) ); + static_cast( wrapper2.wrappedWidget() )->setText( QStringLiteral( "aaa" ) ); QCOMPARE( spy2.count(), 4 ); delete w; @@ -5818,35 +5749,35 @@ void TestProcessingGui::testLayoutItemWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "layoutitem" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "layoutitem" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterLayoutItem itemParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QVariant(), QStringLiteral( "parent" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "layoutitem" ), context, widgetContext, &itemParam ); + widget = std::make_unique( QStringLiteral( "layoutitem" ), context, widgetContext, &itemParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterLayoutItem * >( def.get() )->parentLayoutParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->parentLayoutParameterName(), QStringLiteral( "parent" ) ); itemParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); itemParam.setParentLayoutParameterName( QString() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "layoutitem" ), context, widgetContext, &itemParam ); + widget = std::make_unique( QStringLiteral( "layoutitem" ), context, widgetContext, &itemParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QVERIFY( static_cast< QgsProcessingParameterLayoutItem * >( def.get() )->parentLayoutParameterName().isEmpty() ); + QVERIFY( static_cast( def.get() )->parentLayoutParameterName().isEmpty() ); } void TestProcessingGui::testPointPanel() { - std::unique_ptr< QgsProcessingPointPanel > panel = std::make_unique< QgsProcessingPointPanel >( nullptr ); + std::unique_ptr panel = std::make_unique( nullptr ); QSignalSpy spy( panel.get(), &QgsProcessingPointPanel::changed ); panel->setValue( QgsPointXY( 100, 150 ), QgsCoordinateReferenceSystem() ); @@ -5881,8 +5812,7 @@ void TestProcessingGui::testPointPanel() void TestProcessingGui::testPointWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterPoint param( QStringLiteral( "point" ), QStringLiteral( "point" ), false ); @@ -5897,34 +5827,34 @@ void TestProcessingGui::testPointWrapper() if ( type != QgsProcessingGui::Modeler ) { QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1.000000,2.000000" ) ); - QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000" ) ); } else { QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1,2" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "1,2" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "1,2" ) ); } wrapper.setWidgetValue( "1,2 [EPSG:3111]", context ); QCOMPARE( spy.count(), 2 ); if ( type != QgsProcessingGui::Modeler ) { QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) ); - QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) ); } else { QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1,2 [EPSG:3111]" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "1,2 [EPSG:3111]" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "1,2 [EPSG:3111]" ) ); } // check signal if ( type != QgsProcessingGui::Modeler ) { - static_cast< QgsProcessingPointPanel * >( wrapper.wrappedWidget() )->mLineEdit->setText( QStringLiteral( "b" ) ); + static_cast( wrapper.wrappedWidget() )->mLineEdit->setText( QStringLiteral( "b" ) ); } else { - static_cast< QLineEdit * >( wrapper.wrappedWidget() )->setText( QStringLiteral( "aaaa" ) ); + static_cast( wrapper.wrappedWidget() )->setText( QStringLiteral( "aaaa" ) ); } QCOMPARE( spy.count(), 3 ); @@ -5956,13 +5886,13 @@ void TestProcessingGui::testPointWrapper() QCOMPARE( spy2.count(), 1 ); if ( type != QgsProcessingGui::Modeler ) { - QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000" ) ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1.000000,2.000000" ) ); } else { QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1,2" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text(), QStringLiteral( "1,2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->text(), QStringLiteral( "1,2" ) ); } wrapper2.setWidgetValue( "1,2 [EPSG:3111]", context ); @@ -5970,23 +5900,23 @@ void TestProcessingGui::testPointWrapper() if ( type != QgsProcessingGui::Modeler ) { QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) ); - QCOMPARE( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->mLineEdit->text(), QStringLiteral( "1.000000,2.000000 [EPSG:3111]" ) ); } else { QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1,2 [EPSG:3111]" ) ); - QCOMPARE( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text(), QStringLiteral( "1,2 [EPSG:3111]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->text(), QStringLiteral( "1,2 [EPSG:3111]" ) ); } wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 3 ); QVERIFY( !wrapper2.widgetValue().isValid() ); if ( type == QgsProcessingGui::Modeler ) { - QVERIFY( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->text().isEmpty() ); } else { - QVERIFY( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->mLineEdit->text().isEmpty() ); } wrapper2.setWidgetValue( "1,3", context ); QCOMPARE( spy2.count(), 4 ); @@ -5995,11 +5925,11 @@ void TestProcessingGui::testPointWrapper() QVERIFY( !wrapper2.widgetValue().isValid() ); if ( type == QgsProcessingGui::Modeler ) { - QVERIFY( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->text().isEmpty() ); } else { - QVERIFY( static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->text().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->mLineEdit->text().isEmpty() ); } // check signals @@ -6007,11 +5937,11 @@ void TestProcessingGui::testPointWrapper() QCOMPARE( spy2.count(), 6 ); if ( type == QgsProcessingGui::Modeler ) { - static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->clear(); + static_cast( wrapper2.wrappedWidget() )->clear(); } else { - static_cast< QgsProcessingPointPanel * >( wrapper2.wrappedWidget() )->mLineEdit->clear(); + static_cast( wrapper2.wrappedWidget() )->mLineEdit->clear(); } QCOMPARE( spy2.count(), 7 ); @@ -6030,38 +5960,36 @@ void TestProcessingGui::testPointWrapper() // config widget QgsProcessingContext context; QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "point" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "point" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterPoint pointParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "1,2" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "point" ), context, widgetContext, &pointParam ); + widget = std::make_unique( QStringLiteral( "point" ), context, widgetContext, &pointParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterPoint * >( def.get() )->defaultValue().toString(), QStringLiteral( "1.000000,2.000000" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "1.000000,2.000000" ) ); pointParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); pointParam.setDefaultValue( QStringLiteral( "4,7" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "point" ), context, widgetContext, &pointParam ); + widget = std::make_unique( QStringLiteral( "point" ), context, widgetContext, &pointParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterPoint * >( def.get() )->defaultValue().toString(), QStringLiteral( "4.000000,7.000000" ) ); - + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "4.000000,7.000000" ) ); } void TestProcessingGui::testGeometryWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterGeometry param( QStringLiteral( "geometry" ), QStringLiteral( "geometry" ), false ); @@ -6074,11 +6002,11 @@ void TestProcessingGui::testGeometryWrapper() wrapper.setWidgetValue( QStringLiteral( "POINT (1 2)" ), context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString().toLower(), QStringLiteral( "point (1 2)" ) ); - QCOMPARE( static_cast< QgsGeometryWidget * >( wrapper.wrappedWidget() )->geometryValue().asWkt().toLower(), QStringLiteral( "point (1 2)" ).toLower() ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->geometryValue().asWkt().toLower(), QStringLiteral( "point (1 2)" ).toLower() ); wrapper.setWidgetValue( QString(), context ); QCOMPARE( spy.count(), 2 ); QVERIFY( wrapper.widgetValue().toString().isEmpty() ); - QVERIFY( static_cast< QgsGeometryWidget * >( wrapper.wrappedWidget() )->geometryValue().asWkt().isEmpty() ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->geometryValue().asWkt().isEmpty() ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -6094,9 +6022,9 @@ void TestProcessingGui::testGeometryWrapper() } // check signal - static_cast< QgsGeometryWidget * >( wrapper.wrappedWidget() )->setGeometryValue( QgsReferencedGeometry( QgsGeometry::fromWkt( "point(0 0)" ), QgsCoordinateReferenceSystem() ) ); + static_cast( wrapper.wrappedWidget() )->setGeometryValue( QgsReferencedGeometry( QgsGeometry::fromWkt( "point(0 0)" ), QgsCoordinateReferenceSystem() ) ); QCOMPARE( spy.count(), 3 ); - static_cast< QgsGeometryWidget * >( wrapper.wrappedWidget() )->clearGeometry(); + static_cast( wrapper.wrappedWidget() )->clearGeometry(); QCOMPARE( spy.count(), 4 ); delete w; @@ -6113,19 +6041,19 @@ void TestProcessingGui::testGeometryWrapper() wrapper2.setWidgetValue( "POINT (1 2)", context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString().toLower(), QStringLiteral( "point (1 2)" ) ); - QCOMPARE( static_cast< QgsGeometryWidget * >( wrapper2.wrappedWidget() )->geometryValue().asWkt().toLower(), QStringLiteral( "point (1 2)" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->geometryValue().asWkt().toLower(), QStringLiteral( "point (1 2)" ) ); wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 2 ); QVERIFY( !wrapper2.widgetValue().isValid() ); - QVERIFY( static_cast< QgsGeometryWidget * >( wrapper2.wrappedWidget() )->geometryValue().asWkt().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->geometryValue().asWkt().isEmpty() ); wrapper2.setWidgetValue( "POINT (1 3)", context ); QCOMPARE( spy2.count(), 3 ); wrapper2.setWidgetValue( "", context ); QCOMPARE( spy2.count(), 4 ); QVERIFY( !wrapper2.widgetValue().isValid() ); - QVERIFY( static_cast< QgsGeometryWidget * >( wrapper2.wrappedWidget() )->geometryValue().asWkt().isEmpty() ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->geometryValue().asWkt().isEmpty() ); delete w; }; @@ -6144,8 +6072,8 @@ void TestProcessingGui::testGeometryWrapper() // config widget QgsProcessingContext context; QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "geometry" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "geometry" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -6153,33 +6081,29 @@ void TestProcessingGui::testGeometryWrapper() // using a parameter definition as initial values QgsProcessingParameterGeometry geometryParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "POINT (1 2)" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "geometry" ), context, widgetContext, &geometryParam ); + widget = std::make_unique( QStringLiteral( "geometry" ), context, widgetContext, &geometryParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterGeometry * >( def.get() )->defaultValue().toString().toLower(), QStringLiteral( "point (1 2)" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString().toLower(), QStringLiteral( "point (1 2)" ) ); geometryParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); geometryParam.setDefaultValue( QStringLiteral( "POINT (4 7)" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "geometry" ), context, widgetContext, &geometryParam ); + widget = std::make_unique( QStringLiteral( "geometry" ), context, widgetContext, &geometryParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterGeometry * >( def.get() )->defaultValue().toString().toLower(), QStringLiteral( "point (4 7)" ) ); - + QCOMPARE( static_cast( def.get() )->defaultValue().toString().toLower(), QStringLiteral( "point (4 7)" ) ); } - - void TestProcessingGui::testExtentWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterExtent param( QStringLiteral( "extent" ), QStringLiteral( "extent" ), false ); @@ -6192,16 +6116,16 @@ void TestProcessingGui::testExtentWrapper() wrapper.setWidgetValue( "1,2,3,4", context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1.000000000,2.000000000,3.000000000,4.000000000" ) ); - QCOMPARE( static_cast< QgsExtentWidget * >( wrapper.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); wrapper.setWidgetValue( "1,2,3,4 [EPSG:3111]", context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "1.000000000,2.000000000,3.000000000,4.000000000 [EPSG:3111]" ) ); - QCOMPARE( static_cast< QgsExtentWidget * >( wrapper.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); - QCOMPARE( static_cast< QgsExtentWidget * >( wrapper.wrappedWidget() )->outputCrs().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->outputCrs().authid(), QStringLiteral( "EPSG:3111" ) ); // check signal - static_cast< QgsExtentWidget * >( wrapper.wrappedWidget() )->setOutputExtentFromUser( QgsRectangle( 11, 22, 33, 44 ), QgsCoordinateReferenceSystem() ); + static_cast( wrapper.wrappedWidget() )->setOutputExtentFromUser( QgsRectangle( 11, 22, 33, 44 ), QgsCoordinateReferenceSystem() ); QCOMPARE( spy.count(), 3 ); QLabel *l = wrapper.createWrappedLabel(); @@ -6229,40 +6153,39 @@ void TestProcessingGui::testExtentWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingExtentWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( "1,2,3,4", context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( static_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1.000000000,2.000000000,3.000000000,4.000000000" ) ); wrapper2.setWidgetValue( "1,2,3,4 [EPSG:3111]", context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "1.000000000,2.000000000,3.000000000,4.000000000 [EPSG:3111]" ) ); - QCOMPARE( static_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); - QCOMPARE( static_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->outputCrs().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->outputExtent(), QgsRectangle( 1, 3, 2, 4 ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->outputCrs().authid(), QStringLiteral( "EPSG:3111" ) ); wrapper2.setWidgetValue( QVariant(), context ); QCOMPARE( spy2.count(), 3 ); QVERIFY( !wrapper2.widgetValue().isValid() ); - QVERIFY( !static_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->isValid() ); + QVERIFY( !static_cast( wrapper2.wrappedWidget() )->isValid() ); // simulate a user manually entering an extent by hand - qgis::down_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->mCondensedLineEdit->setText( "372830.001,373830.001,372830.001,373830.001" ); - qgis::down_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->setOutputExtentFromCondensedLineEdit(); + qgis::down_cast( wrapper2.wrappedWidget() )->mCondensedLineEdit->setText( "372830.001,373830.001,372830.001,373830.001" ); + qgis::down_cast( wrapper2.wrappedWidget() )->setOutputExtentFromCondensedLineEdit(); QCOMPARE( spy2.count(), 4 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "372830.001000000,373830.001000000,372830.001000000,373830.001000000 [EPSG:3111]" ) ); - QCOMPARE( qgis::down_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->outputExtent(), QgsRectangle( 372830.001, 372830.001, 373830.001, 373830.001 ) ); - QCOMPARE( static_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->outputCrs().authid(), QStringLiteral( "EPSG:3111" ) ); + QCOMPARE( qgis::down_cast( wrapper2.wrappedWidget() )->outputExtent(), QgsRectangle( 372830.001, 372830.001, 373830.001, 373830.001 ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->outputCrs().authid(), QStringLiteral( "EPSG:3111" ) ); wrapper2.setWidgetValue( "", context ); QCOMPARE( spy2.count(), 5 ); QVERIFY( !wrapper2.widgetValue().isValid() ); - QVERIFY( !static_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->isValid() ); + QVERIFY( !static_cast( wrapper2.wrappedWidget() )->isValid() ); // check signals wrapper2.setWidgetValue( "1,3,9,8", context ); QCOMPARE( spy2.count(), 6 ); - static_cast< QgsExtentWidget * >( wrapper2.wrappedWidget() )->clear(); + static_cast( wrapper2.wrappedWidget() )->clear(); QCOMPARE( spy2.count(), 7 ); delete w; - }; // standard wrapper @@ -6277,36 +6200,35 @@ void TestProcessingGui::testExtentWrapper() // config widget QgsProcessingContext context; QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "extent" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "extent" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterExtent extentParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "1,2,3,4" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "extent" ), context, widgetContext, &extentParam ); + widget = std::make_unique( QStringLiteral( "extent" ), context, widgetContext, &extentParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterExtent * >( def.get() )->defaultValue().toString(), QStringLiteral( "1.000000000,2.000000000,3.000000000,4.000000000" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "1.000000000,2.000000000,3.000000000,4.000000000" ) ); extentParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); extentParam.setDefaultValue( QStringLiteral( "4,7,8,9" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "extent" ), context, widgetContext, &extentParam ); + widget = std::make_unique( QStringLiteral( "extent" ), context, widgetContext, &extentParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterExtent * >( def.get() )->defaultValue().toString(), QStringLiteral( "4.000000000,7.000000000,8.000000000,9.000000000" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "4.000000000,7.000000000,8.000000000,9.000000000" ) ); } void TestProcessingGui::testColorWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterColor param( QStringLiteral( "color" ), QStringLiteral( "color" ) ); QgsProcessingColorWidgetWrapper wrapper( ¶m, type ); @@ -6317,14 +6239,14 @@ void TestProcessingGui::testColorWrapper() QSignalSpy spy( &wrapper, &QgsProcessingColorWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QColor( 255, 0, 0 ), context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().value< QColor >().name(), QStringLiteral( "#ff0000" ) ); - QCOMPARE( static_cast< QgsColorButton * >( wrapper.wrappedWidget() )->color(), QColor( 255, 0, 0 ) ); - QVERIFY( !static_cast< QgsColorButton * >( wrapper.wrappedWidget() )->showNull() ); - QVERIFY( static_cast< QgsColorButton * >( wrapper.wrappedWidget() )->allowOpacity() ); + QCOMPARE( wrapper.widgetValue().value().name(), QStringLiteral( "#ff0000" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->color(), QColor( 255, 0, 0 ) ); + QVERIFY( !static_cast( wrapper.wrappedWidget() )->showNull() ); + QVERIFY( static_cast( wrapper.wrappedWidget() )->allowOpacity() ); wrapper.setWidgetValue( QColor(), context ); QCOMPARE( spy.count(), 2 ); - QVERIFY( !wrapper.widgetValue().value< QColor >().isValid() ); - QVERIFY( !static_cast< QgsColorButton * >( wrapper.wrappedWidget() )->color().isValid() ); + QVERIFY( !wrapper.widgetValue().value().isValid() ); + QVERIFY( !static_cast( wrapper.wrappedWidget() )->color().isValid() ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -6340,12 +6262,12 @@ void TestProcessingGui::testColorWrapper() } // check signal - static_cast< QgsColorButton * >( wrapper.wrappedWidget() )->setColor( QColor( 0, 255, 0 ) ); + static_cast( wrapper.wrappedWidget() )->setColor( QColor( 0, 255, 0 ) ); QCOMPARE( spy.count(), 3 ); // with opacity wrapper.setWidgetValue( QColor( 255, 0, 0, 100 ), context ); - QCOMPARE( wrapper.widgetValue().value< QColor >(), QColor( 255, 0, 0, 100 ) ); + QCOMPARE( wrapper.widgetValue().value(), QColor( 255, 0, 0, 100 ) ); delete w; @@ -6354,12 +6276,12 @@ void TestProcessingGui::testColorWrapper() QgsProcessingColorWidgetWrapper wrapper2( ¶m2, type ); w = wrapper2.createWrappedWidget( context ); - QVERIFY( static_cast< QgsColorButton * >( wrapper2.wrappedWidget() )->showNull() ); - QCOMPARE( static_cast< QgsColorButton * >( wrapper2.wrappedWidget() )->color().name(), QStringLiteral( "#0a141e" ) ); + QVERIFY( static_cast( wrapper2.wrappedWidget() )->showNull() ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->color().name(), QStringLiteral( "#0a141e" ) ); wrapper2.setWidgetValue( QVariant(), context ); QVERIFY( !wrapper2.widgetValue().isValid() ); wrapper2.setWidgetValue( QColor( 255, 0, 255 ), context ); - QCOMPARE( wrapper2.widgetValue().value< QColor >().name(), QStringLiteral( "#ff00ff" ) ); + QCOMPARE( wrapper2.widgetValue().value().name(), QStringLiteral( "#ff00ff" ) ); // no opacity QgsProcessingParameterColor param3( QStringLiteral( "c2" ), QStringLiteral( "c2" ), QColor( 10, 20, 30 ), false, true ); @@ -6367,7 +6289,7 @@ void TestProcessingGui::testColorWrapper() QgsProcessingColorWidgetWrapper wrapper3( ¶m3, type ); w = wrapper3.createWrappedWidget( context ); wrapper3.setWidgetValue( QColor( 255, 0, 0, 100 ), context ); - QCOMPARE( wrapper3.widgetValue().value< QColor >(), QColor( 255, 0, 0 ) ); + QCOMPARE( wrapper3.widgetValue().value(), QColor( 255, 0, 0 ) ); }; // standard wrapper @@ -6382,39 +6304,38 @@ void TestProcessingGui::testColorWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "color" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "color" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( static_cast< QgsProcessingParameterColor * >( def.get() )->opacityEnabled() ); // should default to true + QVERIFY( static_cast( def.get() )->opacityEnabled() ); // should default to true // using a parameter definition as initial values QgsProcessingParameterColor colorParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QColor( 255, 0, 0, 100 ), true ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "color" ), context, widgetContext, &colorParam ); + widget = std::make_unique( QStringLiteral( "color" ), context, widgetContext, &colorParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterColor * >( def.get() )->defaultValue().value< QColor >(), QColor( 255, 0, 0, 100 ) ); - QVERIFY( static_cast< QgsProcessingParameterColor * >( def.get() )->opacityEnabled() ); + QCOMPARE( static_cast( def.get() )->defaultValue().value(), QColor( 255, 0, 0, 100 ) ); + QVERIFY( static_cast( def.get() )->opacityEnabled() ); colorParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); colorParam.setOpacityEnabled( false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "color" ), context, widgetContext, &colorParam ); + widget = std::make_unique( QStringLiteral( "color" ), context, widgetContext, &colorParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterColor * >( def.get() )->defaultValue().value< QColor >(), QColor( 255, 0, 0 ) ); // (no opacity!) - QVERIFY( !static_cast< QgsProcessingParameterColor * >( def.get() )->opacityEnabled() ); + QCOMPARE( static_cast( def.get() )->defaultValue().value(), QColor( 255, 0, 0 ) ); // (no opacity!) + QVERIFY( !static_cast( def.get() )->opacityEnabled() ); } void TestProcessingGui::testCoordinateOperationWrapper() { - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterCoordinateOperation param( QStringLiteral( "op" ), QStringLiteral( "op" ) ); QgsProcessingCoordinateOperationWidgetWrapper wrapper( ¶m, type ); @@ -6432,15 +6353,15 @@ void TestProcessingGui::testCoordinateOperationWrapper() { case QgsProcessingGui::Standard: { - QCOMPARE( static_cast< QgsCoordinateOperationWidget * >( wrapper.wrappedWidget() )->selectedOperation().proj, QStringLiteral( "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +xy_out=m +step +inv +proj=lcc +lat_0=33.5 +lon_0=-118 +lat_1=35.4666666666667 +lat_2=34.0333333333333 +x_0=609601.219202438 +y_0=0 +ellps=clrk66 +step +proj=push +v_3 +step +proj=cart +ellps=clrk66 +step +proj=helmert +x=-8 +y=160 +z=176 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->selectedOperation().proj, QStringLiteral( "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +xy_out=m +step +inv +proj=lcc +lat_0=33.5 +lon_0=-118 +lat_1=35.4666666666667 +lat_2=34.0333333333333 +x_0=609601.219202438 +y_0=0 +ellps=clrk66 +step +proj=push +v_3 +step +proj=cart +ellps=clrk66 +step +proj=helmert +x=-8 +y=160 +z=176 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ) ); wrapper.setWidgetValue( QStringLiteral( "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +xy_out=m +step +inv +proj=lcc +lat_0=33.5 +lon_0=-118 +lat_1=35.4666666666667 +lat_2=34.0333333333333 +x_0=609601.219202438 +y_0=0 +ellps=clrk66 +step +proj=push +v_3 +step +proj=cart +ellps=clrk66 +step +proj=helmert +x=-8 +y=159 +z=175 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ), context ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( static_cast< QgsCoordinateOperationWidget * >( wrapper.wrappedWidget() )->selectedOperation().proj, QStringLiteral( "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +xy_out=m +step +inv +proj=lcc +lat_0=33.5 +lon_0=-118 +lat_1=35.4666666666667 +lat_2=34.0333333333333 +x_0=609601.219202438 +y_0=0 +ellps=clrk66 +step +proj=push +v_3 +step +proj=cart +ellps=clrk66 +step +proj=helmert +x=-8 +y=159 +z=175 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->selectedOperation().proj, QStringLiteral( "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +xy_out=m +step +inv +proj=lcc +lat_0=33.5 +lon_0=-118 +lat_1=35.4666666666667 +lat_2=34.0333333333333 +x_0=609601.219202438 +y_0=0 +ellps=clrk66 +step +proj=push +v_3 +step +proj=cart +ellps=clrk66 +step +proj=helmert +x=-8 +y=159 +z=175 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ) ); // check signal QgsCoordinateOperationWidget::OperationDetails deets; deets.proj = QStringLiteral( "+proj=pipeline +step +proj=unitconvert +xy_in=us-ft +xy_out=m +step +inv +proj=lcc +lat_0=33.5 +lon_0=-118 +lat_1=35.4666666666667 +lat_2=34.0333333333333 +x_0=609601.219202438 +y_0=0 +ellps=clrk66 +step +proj=push +v_3 +step +proj=cart +ellps=clrk66 +step +proj=helmert +x=-8 +y=160 +z=176 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=webmerc +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84" ); - static_cast< QgsCoordinateOperationWidget * >( wrapper.wrappedWidget() )->setSelectedOperation( deets ); + static_cast( wrapper.wrappedWidget() )->setSelectedOperation( deets ); QCOMPARE( spy.count(), 3 ); break; } @@ -6488,32 +6409,32 @@ void TestProcessingGui::testCoordinateOperationWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "coordinateoperation" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "coordinateoperation" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( !static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->sourceCrs().isValid() ); // should default to not set - QVERIFY( !static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->destinationCrs().isValid() ); // should default to not set - QVERIFY( static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->sourceCrsParameterName().isEmpty() ); // should default to not set - QVERIFY( static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->destinationCrsParameterName().isEmpty() ); // should default to not set + QVERIFY( !static_cast( def.get() )->sourceCrs().isValid() ); // should default to not set + QVERIFY( !static_cast( def.get() )->destinationCrs().isValid() ); // should default to not set + QVERIFY( static_cast( def.get() )->sourceCrsParameterName().isEmpty() ); // should default to not set + QVERIFY( static_cast( def.get() )->destinationCrsParameterName().isEmpty() ); // should default to not set // using a parameter definition as initial values QgsProcessingParameterCoordinateOperation coordParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "+proj" ), QStringLiteral( "a" ), QStringLiteral( "b" ), QStringLiteral( "EPSG:26745" ), QStringLiteral( "EPSG:4326" ), false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "coordinateoperation" ), context, widgetContext, &coordParam ); + widget = std::make_unique( QStringLiteral( "coordinateoperation" ), context, widgetContext, &coordParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->defaultValue().toString(), QStringLiteral( "+proj" ) ); - QCOMPARE( static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->sourceCrsParameterName(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->destinationCrsParameterName(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->sourceCrs().value< QgsCoordinateReferenceSystem >( ).authid(), QStringLiteral( "EPSG:26745" ) ); - QCOMPARE( static_cast< QgsProcessingParameterCoordinateOperation * >( def.get() )->destinationCrs().value< QgsCoordinateReferenceSystem >( ).authid(), QStringLiteral( "EPSG:4326" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "+proj" ) ); + QCOMPARE( static_cast( def.get() )->sourceCrsParameterName(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( def.get() )->destinationCrsParameterName(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( def.get() )->sourceCrs().value().authid(), QStringLiteral( "EPSG:26745" ) ); + QCOMPARE( static_cast( def.get() )->destinationCrs().value().authid(), QStringLiteral( "EPSG:4326" ) ); coordParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "coordinateoperation" ), context, widgetContext, &coordParam ); + widget = std::make_unique( QStringLiteral( "coordinateoperation" ), context, widgetContext, &coordParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); @@ -6528,8 +6449,8 @@ void TestProcessingGui::mapLayerComboBox() context.setProject( QgsProject::instance() ); // feature source param - std::unique_ptr< QgsProcessingParameterDefinition > param( new QgsProcessingParameterFeatureSource( QStringLiteral( "param" ), QString() ) ); - std::unique_ptr< QgsProcessingMapLayerComboBox> combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); + std::unique_ptr param( new QgsProcessingParameterFeatureSource( QStringLiteral( "param" ), QString() ) ); + std::unique_ptr combo = std::make_unique( param.get() ); QSignalSpy spy( combo.get(), &QgsProcessingMapLayerComboBox::valueChanged ); QVERIFY( !combo->value().isValid() ); @@ -6605,8 +6526,8 @@ void TestProcessingGui::mapLayerComboBox() vl2->selectAll(); combo->setValue( sourceDef, context ); QCOMPARE( combo->value().userType(), qMetaTypeId() ); - QCOMPARE( combo->value().value< QgsProcessingFeatureSourceDefinition >().source.staticValue().toString(), vl2->id() ); - QVERIFY( combo->value().value< QgsProcessingFeatureSourceDefinition >().selectedFeaturesOnly ); + QCOMPARE( combo->value().value().source.staticValue().toString(), vl2->id() ); + QVERIFY( combo->value().value().selectedFeaturesOnly ); QVERIFY( combo->currentText().startsWith( vl2->name() ) ); QCOMPARE( spy.count(), 8 ); @@ -6629,47 +6550,47 @@ void TestProcessingGui::mapLayerComboBox() // one last variation - selection to selection combo->setValue( sourceDef, context ); QCOMPARE( spy.count(), 12 ); - QVERIFY( combo->value().value< QgsProcessingFeatureSourceDefinition >().selectedFeaturesOnly ); + QVERIFY( combo->value().value().selectedFeaturesOnly ); vl->selectAll(); sourceDef = QgsProcessingFeatureSourceDefinition( vl->id(), true ); combo->setValue( sourceDef, context ); // expect "selected only" state to remain QCOMPARE( combo->value().userType(), qMetaTypeId() ); - QCOMPARE( combo->value().value< QgsProcessingFeatureSourceDefinition >().source.staticValue().toString(), vl->id() ); - QVERIFY( combo->value().value< QgsProcessingFeatureSourceDefinition >().selectedFeaturesOnly ); + QCOMPARE( combo->value().value().source.staticValue().toString(), vl->id() ); + QVERIFY( combo->value().value().selectedFeaturesOnly ); QVERIFY( combo->currentText().startsWith( vl->name() ) ); QCOMPARE( spy.count(), 13 ); // iterate over features - QVERIFY( !( combo->value().value< QgsProcessingFeatureSourceDefinition >().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::CreateIndividualOutputPerInputFeature ) ); + QVERIFY( !( combo->value().value().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::CreateIndividualOutputPerInputFeature ) ); sourceDef.flags |= Qgis::ProcessingFeatureSourceDefinitionFlag::CreateIndividualOutputPerInputFeature; combo->setValue( sourceDef, context ); - QVERIFY( combo->value().value< QgsProcessingFeatureSourceDefinition >().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::CreateIndividualOutputPerInputFeature ); + QVERIFY( combo->value().value().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::CreateIndividualOutputPerInputFeature ); sourceDef.flags = Qgis::ProcessingFeatureSourceDefinitionFlags(); combo->setValue( sourceDef, context ); - QVERIFY( !( combo->value().value< QgsProcessingFeatureSourceDefinition >().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::CreateIndividualOutputPerInputFeature ) ); + QVERIFY( !( combo->value().value().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::CreateIndividualOutputPerInputFeature ) ); // advanced settings sourceDef.featureLimit = 67; combo->setValue( sourceDef, context ); - QCOMPARE( combo->value().value< QgsProcessingFeatureSourceDefinition >().featureLimit, 67LL ); + QCOMPARE( combo->value().value().featureLimit, 67LL ); sourceDef.featureLimit = -1; combo->setValue( sourceDef, context ); - QCOMPARE( combo->value().value< QgsProcessingFeatureSourceDefinition >().featureLimit, -1LL ); + QCOMPARE( combo->value().value().featureLimit, -1LL ); sourceDef.flags |= Qgis::ProcessingFeatureSourceDefinitionFlag::OverrideDefaultGeometryCheck; sourceDef.geometryCheck = Qgis::InvalidGeometryCheck::SkipInvalid; combo->setValue( sourceDef, context ); - QVERIFY( combo->value().value< QgsProcessingFeatureSourceDefinition >().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::OverrideDefaultGeometryCheck ); - QCOMPARE( combo->value().value< QgsProcessingFeatureSourceDefinition >().geometryCheck, Qgis::InvalidGeometryCheck::SkipInvalid ); + QVERIFY( combo->value().value().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::OverrideDefaultGeometryCheck ); + QCOMPARE( combo->value().value().geometryCheck, Qgis::InvalidGeometryCheck::SkipInvalid ); sourceDef.flags = Qgis::ProcessingFeatureSourceDefinitionFlags(); combo->setValue( sourceDef, context ); - QVERIFY( !( combo->value().value< QgsProcessingFeatureSourceDefinition >().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::OverrideDefaultGeometryCheck ) ); + QVERIFY( !( combo->value().value().flags & Qgis::ProcessingFeatureSourceDefinitionFlag::OverrideDefaultGeometryCheck ) ); sourceDef.filterExpression = QStringLiteral( "name='test'" ); combo->setValue( sourceDef, context ); - QCOMPARE( combo->value().value< QgsProcessingFeatureSourceDefinition >().filterExpression, QStringLiteral( "name='test'" ) ); + QCOMPARE( combo->value().value().filterExpression, QStringLiteral( "name='test'" ) ); sourceDef.filterExpression = QString(); combo->setValue( sourceDef, context ); - QCOMPARE( combo->value().value< QgsProcessingFeatureSourceDefinition >().filterExpression, QString() ); + QCOMPARE( combo->value().value().filterExpression, QString() ); combo.reset(); param.reset(); @@ -6695,8 +6616,8 @@ void TestProcessingGui::mapLayerComboBox() QgsProject::instance()->addMapLayer( pointCloud ); // map layer param, all types are acceptable - param = std::make_unique< QgsProcessingParameterMapLayer> ( QStringLiteral( "param" ), QString() ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString() ); + combo = std::make_unique( param.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo->setLayer( line ); @@ -6715,8 +6636,8 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // map layer param, only point vector and raster types are acceptable - param = std::make_unique< QgsProcessingParameterMapLayer> ( QStringLiteral( "param" ), QString(), QVariant(), false, QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) << static_cast< int >( Qgis::ProcessingSourceType::Raster ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QVariant(), false, QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) << static_cast( Qgis::ProcessingSourceType::Raster ) ); + combo = std::make_unique( param.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo->setLayer( line ); @@ -6735,8 +6656,8 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // raster layer param, only raster types are acceptable - param = std::make_unique< QgsProcessingParameterRasterLayer> ( QStringLiteral( "param" ), QString() ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString() ); + combo = std::make_unique( param.get() ); combo->setLayer( point ); QVERIFY( !combo->currentLayer() ); combo->setLayer( line ); @@ -6755,8 +6676,8 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // mesh layer parm, only mesh types are acceptable - param = std::make_unique< QgsProcessingParameterMeshLayer> ( QStringLiteral( "param" ), QString() ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString() ); + combo = std::make_unique( param.get() ); combo->setLayer( point ); QVERIFY( !combo->currentLayer() ); combo->setLayer( line ); @@ -6775,8 +6696,8 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // point cloud layer parm, only point cloud types are acceptable - param = std::make_unique< QgsProcessingParameterPointCloudLayer> ( QStringLiteral( "param" ), QString() ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString() ); + combo = std::make_unique( param.get() ); combo->setLayer( point ); QVERIFY( !combo->currentLayer() ); combo->setLayer( line ); @@ -6796,10 +6717,10 @@ void TestProcessingGui::mapLayerComboBox() // feature source and vector layer params // if not specified, the default is any vector layer with geometry - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); - auto param2 = std::make_unique< QgsProcessingParameterFeatureSource> ( QStringLiteral( "param" ) ); - auto combo2 = std::make_unique< QgsProcessingMapLayerComboBox >( param2.get() ); + param = std::make_unique( QStringLiteral( "param" ) ); + combo = std::make_unique( param.get() ); + auto param2 = std::make_unique( QStringLiteral( "param" ) ); + auto combo2 = std::make_unique( param2.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo2->setLayer( point ); @@ -6834,10 +6755,10 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // point layer - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); - param2 = std::make_unique< QgsProcessingParameterFeatureSource> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); - combo2 = std::make_unique< QgsProcessingMapLayerComboBox >( param2.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); + combo = std::make_unique( param.get() ); + param2 = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); + combo2 = std::make_unique( param2.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo2->setLayer( point ); @@ -6872,10 +6793,10 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // line layer - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); - param2 = std::make_unique< QgsProcessingParameterFeatureSource> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); - combo2 = std::make_unique< QgsProcessingMapLayerComboBox >( param2.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); + combo = std::make_unique( param.get() ); + param2 = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); + combo2 = std::make_unique( param2.get() ); combo->setLayer( point ); QVERIFY( !combo->currentLayer() ); combo2->setLayer( point ); @@ -6910,10 +6831,10 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // polygon - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorPolygon ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); - param2 = std::make_unique< QgsProcessingParameterFeatureSource> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorPolygon ) ); - combo2 = std::make_unique< QgsProcessingMapLayerComboBox >( param2.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) ); + combo = std::make_unique( param.get() ); + param2 = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPolygon ) ); + combo2 = std::make_unique( param2.get() ); combo->setLayer( point ); QVERIFY( !combo->currentLayer() ); combo2->setLayer( point ); @@ -6948,10 +6869,10 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // no geom - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); - param2 = std::make_unique< QgsProcessingParameterFeatureSource> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::Vector ) ); - combo2 = std::make_unique< QgsProcessingMapLayerComboBox >( param2.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ); + combo = std::make_unique( param.get() ); + param2 = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::Vector ) ); + combo2 = std::make_unique( param2.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo2->setLayer( point ); @@ -6986,10 +6907,10 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // any geom - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); - param2 = std::make_unique< QgsProcessingParameterFeatureSource> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); - combo2 = std::make_unique< QgsProcessingMapLayerComboBox >( param2.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + combo = std::make_unique( param.get() ); + param2 = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + combo2 = std::make_unique( param2.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo2->setLayer( point ); @@ -7024,10 +6945,10 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // combination point and line only - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); - param2 = std::make_unique< QgsProcessingParameterFeatureSource> ( QStringLiteral( "param" ), QString(), QList< int>() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); - combo2 = std::make_unique< QgsProcessingMapLayerComboBox >( param2.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); + combo = std::make_unique( param.get() ); + param2 = std::make_unique( QStringLiteral( "param" ), QString(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); + combo2 = std::make_unique( param2.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo2->setLayer( point ); @@ -7062,8 +6983,8 @@ void TestProcessingGui::mapLayerComboBox() param.reset(); // optional - param = std::make_unique< QgsProcessingParameterVectorLayer> ( QStringLiteral( "param" ), QString(), QList< int>(), QVariant(), true ); - combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() ); + param = std::make_unique( QStringLiteral( "param" ), QString(), QList(), QVariant(), true ); + combo = std::make_unique( param.get() ); combo->setLayer( point ); QCOMPARE( combo->currentLayer(), point ); combo->setLayer( nullptr ); @@ -7101,8 +7022,7 @@ void TestProcessingGui::testMapLayerWrapper() QgsRasterLayer *raster = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif", QStringLiteral( "band1_byte" ) ); QgsProject::instance()->addMapLayer( raster ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterMapLayer param( QStringLiteral( "layer" ), QStringLiteral( "layer" ), false ); @@ -7121,11 +7041,11 @@ void TestProcessingGui::testMapLayerWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); break; } @@ -7144,7 +7064,7 @@ void TestProcessingGui::testMapLayerWrapper() wrapper2.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper2.setWidgetValue( QStringLiteral( "band1_byte" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), raster->id() ); @@ -7152,31 +7072,31 @@ void TestProcessingGui::testMapLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "band1_byte" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "band1_byte" ) ); // check signal - static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->setLayer( polygon ); + static_cast( wrapper2.wrappedWidget() )->setLayer( polygon ); QCOMPARE( spy2.count(), 3 ); QCOMPARE( wrapper2.widgetValue().toString(), polygon->id() ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1 [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1 [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "l1" ) ); delete w; @@ -7190,7 +7110,7 @@ void TestProcessingGui::testMapLayerWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "band1_byte" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), raster->id() ); @@ -7198,10 +7118,10 @@ void TestProcessingGui::testMapLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); break; } wrapper3.setWidgetValue( QVariant(), context ); @@ -7236,30 +7156,30 @@ void TestProcessingGui::testMapLayerWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "layer" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "layer" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values - QgsProcessingParameterMapLayer layerParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QVariant(), false, QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "layer" ), context, widgetContext, &layerParam ); + QgsProcessingParameterMapLayer layerParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QVariant(), false, QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + widget = std::make_unique( QStringLiteral( "layer" ), context, widgetContext, &layerParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterMapLayer * >( def.get() )->dataTypes(), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + QCOMPARE( static_cast( def.get() )->dataTypes(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); layerParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); - layerParam.setDataTypes( QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::Raster ) << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "layer" ), context, widgetContext, &layerParam ); + layerParam.setDataTypes( QList() << static_cast( Qgis::ProcessingSourceType::Raster ) << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); + widget = std::make_unique( QStringLiteral( "layer" ), context, widgetContext, &layerParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterMapLayer * >( def.get() )->dataTypes(), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) << static_cast< int >( Qgis::ProcessingSourceType::Raster ) ); + QCOMPARE( static_cast( def.get() )->dataTypes(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) << static_cast( Qgis::ProcessingSourceType::Raster ) ); } void TestProcessingGui::testRasterLayerWrapper() @@ -7271,8 +7191,7 @@ void TestProcessingGui::testRasterLayerWrapper() QgsRasterLayer *raster2 = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif", QStringLiteral( "band1_byte2" ) ); QgsProject::instance()->addMapLayer( raster2 ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterRasterLayer param( QStringLiteral( "raster" ), QStringLiteral( "raster" ), false ); @@ -7291,11 +7210,11 @@ void TestProcessingGui::testRasterLayerWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); break; } @@ -7314,7 +7233,7 @@ void TestProcessingGui::testRasterLayerWrapper() wrapper2.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper2.setWidgetValue( QStringLiteral( "band1_byte" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), raster->id() ); @@ -7322,31 +7241,31 @@ void TestProcessingGui::testRasterLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "band1_byte" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "band1_byte" ) ); // check signal - static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->setLayer( raster2 ); + static_cast( wrapper2.wrappedWidget() )->setLayer( raster2 ); QCOMPARE( spy2.count(), 3 ); QCOMPARE( wrapper2.widgetValue().toString(), raster2->id() ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte2 [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte2 [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte2" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "band1_byte2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "band1_byte2" ) ); delete w; @@ -7360,7 +7279,7 @@ void TestProcessingGui::testRasterLayerWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "band1_byte" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), raster->id() ); @@ -7368,10 +7287,10 @@ void TestProcessingGui::testRasterLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "band1_byte" ) ); break; } wrapper3.setWidgetValue( QVariant(), context ); @@ -7417,10 +7336,9 @@ void TestProcessingGui::testVectorLayerWrapper() QgsVectorLayer *noGeom = new QgsVectorLayer( QStringLiteral( "None" ), QStringLiteral( "l1" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( noGeom ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional - QgsProcessingParameterVectorLayer param( QStringLiteral( "vector" ), QStringLiteral( "vector" ), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ), false ); + QgsProcessingParameterVectorLayer param( QStringLiteral( "vector" ), QStringLiteral( "vector" ), QList() << static_cast( Qgis::ProcessingSourceType::Vector ), false ); QgsProcessingVectorLayerWidgetWrapper wrapper( ¶m, type ); @@ -7437,11 +7355,11 @@ void TestProcessingGui::testVectorLayerWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); break; } @@ -7460,7 +7378,7 @@ void TestProcessingGui::testVectorLayerWrapper() wrapper2.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper2.setWidgetValue( QStringLiteral( "point" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), point->id() ); @@ -7468,36 +7386,36 @@ void TestProcessingGui::testVectorLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "point" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "point" ) ); // check signal - static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->setLayer( polygon ); + static_cast( wrapper2.wrappedWidget() )->setLayer( polygon ); QCOMPARE( spy2.count(), 3 ); QCOMPARE( wrapper2.widgetValue().toString(), polygon->id() ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1 [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1 [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "l1" ) ); delete w; // optional - QgsProcessingParameterVectorLayer param2( QStringLiteral( "vector" ), QStringLiteral( "vector" ), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::Vector ), QVariant(), true ); + QgsProcessingParameterVectorLayer param2( QStringLiteral( "vector" ), QStringLiteral( "vector" ), QList() << static_cast( Qgis::ProcessingSourceType::Vector ), QVariant(), true ); QgsProcessingVectorLayerWidgetWrapper wrapper3( ¶m2, type ); wrapper3.setWidgetContext( widgetContext ); w = wrapper3.createWrappedWidget( context ); @@ -7506,7 +7424,7 @@ void TestProcessingGui::testVectorLayerWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "point" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), point->id() ); @@ -7514,10 +7432,10 @@ void TestProcessingGui::testVectorLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); break; } wrapper3.setWidgetValue( QVariant(), context ); @@ -7552,30 +7470,30 @@ void TestProcessingGui::testVectorLayerWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "vector" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "vector" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values - QgsProcessingParameterVectorLayer layerParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "vector" ), context, widgetContext, &layerParam ); + QgsProcessingParameterVectorLayer layerParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + widget = std::make_unique( QStringLiteral( "vector" ), context, widgetContext, &layerParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterVectorLayer * >( def.get() )->dataTypes(), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + QCOMPARE( static_cast( def.get() )->dataTypes(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); layerParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); - layerParam.setDataTypes( QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "vector" ), context, widgetContext, &layerParam ); + layerParam.setDataTypes( QList() << static_cast( Qgis::ProcessingSourceType::VectorLine ) << static_cast( Qgis::ProcessingSourceType::VectorPoint ) ); + widget = std::make_unique( QStringLiteral( "vector" ), context, widgetContext, &layerParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterVectorLayer * >( def.get() )->dataTypes(), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); + QCOMPARE( static_cast( def.get() )->dataTypes(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); } void TestProcessingGui::testFeatureSourceWrapper() @@ -7591,10 +7509,9 @@ void TestProcessingGui::testFeatureSourceWrapper() QgsVectorLayer *noGeom = new QgsVectorLayer( QStringLiteral( "None" ), QStringLiteral( "l1" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( noGeom ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional - QgsProcessingParameterFeatureSource param( QStringLiteral( "source" ), QStringLiteral( "source" ), QList() << static_cast< int >( Qgis::ProcessingSourceType::Vector ), false ); + QgsProcessingParameterFeatureSource param( QStringLiteral( "source" ), QStringLiteral( "source" ), QList() << static_cast( Qgis::ProcessingSourceType::Vector ), false ); QgsProcessingFeatureSourceWidgetWrapper wrapper( ¶m, type ); @@ -7611,11 +7528,11 @@ void TestProcessingGui::testFeatureSourceWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); break; } @@ -7634,7 +7551,7 @@ void TestProcessingGui::testFeatureSourceWrapper() wrapper2.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper2.setWidgetValue( QStringLiteral( "point" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), point->id() ); @@ -7642,36 +7559,36 @@ void TestProcessingGui::testFeatureSourceWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "point" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "point" ) ); // check signal - static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->setLayer( polygon ); + static_cast( wrapper2.wrappedWidget() )->setLayer( polygon ); QCOMPARE( spy2.count(), 3 ); QCOMPARE( wrapper2.widgetValue().toString(), polygon->id() ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1 [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1 [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "l1" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "l1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "l1" ) ); delete w; // optional - QgsProcessingParameterFeatureSource param2( QStringLiteral( "source" ), QStringLiteral( "source" ), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::Vector ), QVariant(), true ); + QgsProcessingParameterFeatureSource param2( QStringLiteral( "source" ), QStringLiteral( "source" ), QList() << static_cast( Qgis::ProcessingSourceType::Vector ), QVariant(), true ); QgsProcessingFeatureSourceWidgetWrapper wrapper3( ¶m2, type ); wrapper3.setWidgetContext( widgetContext ); w = wrapper3.createWrappedWidget( context ); @@ -7680,7 +7597,7 @@ void TestProcessingGui::testFeatureSourceWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "point" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), point->id() ); @@ -7688,10 +7605,10 @@ void TestProcessingGui::testFeatureSourceWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "point" ) ); break; } wrapper3.setWidgetValue( QVariant(), context ); @@ -7726,30 +7643,30 @@ void TestProcessingGui::testFeatureSourceWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "source" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "source" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values - QgsProcessingParameterFeatureSource sourceParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "source" ), context, widgetContext, &sourceParam ); + QgsProcessingParameterFeatureSource sourceParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + widget = std::make_unique( QStringLiteral( "source" ), context, widgetContext, &sourceParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterFeatureSource * >( def.get() )->dataTypes(), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); + QCOMPARE( static_cast( def.get() )->dataTypes(), QList() << static_cast( Qgis::ProcessingSourceType::VectorAnyGeometry ) ); sourceParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); - sourceParam.setDataTypes( QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "source" ), context, widgetContext, &sourceParam ); + sourceParam.setDataTypes( QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); + widget = std::make_unique( QStringLiteral( "source" ), context, widgetContext, &sourceParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterFeatureSource * >( def.get() )->dataTypes(), QList< int >() << static_cast< int >( Qgis::ProcessingSourceType::VectorPoint ) << static_cast< int >( Qgis::ProcessingSourceType::VectorLine ) ); + QCOMPARE( static_cast( def.get() )->dataTypes(), QList() << static_cast( Qgis::ProcessingSourceType::VectorPoint ) << static_cast( Qgis::ProcessingSourceType::VectorLine ) ); } void TestProcessingGui::testMeshLayerWrapper() @@ -7767,8 +7684,7 @@ void TestProcessingGui::testMeshLayerWrapper() mesh2->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QgsProject::instance()->addMapLayer( mesh2 ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterMeshLayer param( QStringLiteral( "mesh" ), QStringLiteral( "mesh" ), false ); @@ -7787,11 +7703,11 @@ void TestProcessingGui::testMeshLayerWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); break; } @@ -7810,7 +7726,7 @@ void TestProcessingGui::testMeshLayerWrapper() wrapper2.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper2.setWidgetValue( QStringLiteral( "mesh2" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), mesh2->id() ); @@ -7818,31 +7734,31 @@ void TestProcessingGui::testMeshLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh2 [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh2 [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh2" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "mesh2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "mesh2" ) ); // check signal - static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->setLayer( mesh ); + static_cast( wrapper2.wrappedWidget() )->setLayer( mesh ); QCOMPARE( spy2.count(), 3 ); QCOMPARE( wrapper2.widgetValue().toString(), mesh->id() ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh1 [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh1 [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "mesh1" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "mesh1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "mesh1" ) ); delete w; @@ -7856,7 +7772,7 @@ void TestProcessingGui::testMeshLayerWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "mesh2" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), mesh2->id() ); @@ -7864,10 +7780,10 @@ void TestProcessingGui::testMeshLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "mesh2 [EPSG:4326]" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "mesh2 [EPSG:4326]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "mesh2" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "mesh2" ) ); break; } wrapper3.setWidgetValue( QVariant(), context ); @@ -7904,8 +7820,8 @@ void TestProcessingGui::paramConfigWidget() { QgsProcessingContext context; QgsProcessingParameterWidgetContext widgetContext; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "string" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "string" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); @@ -7913,14 +7829,14 @@ void TestProcessingGui::paramConfigWidget() // using a parameter definition as initial values def->setDescription( QStringLiteral( "test desc" ) ); def->setFlags( Qgis::ProcessingParameterFlag::Optional ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "string" ), context, widgetContext, def.get() ); + widget = std::make_unique( QStringLiteral( "string" ), context, widgetContext, def.get() ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); def->setFlags( Qgis::ProcessingParameterFlag::Advanced ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "string" ), context, widgetContext, def.get() ); + widget = std::make_unique( QStringLiteral( "string" ), context, widgetContext, def.get() ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); @@ -7937,8 +7853,7 @@ void TestProcessingGui::testMapThemeWrapper() QCOMPARE( p.mapThemeCollection()->mapThemes(), QStringList() << QStringLiteral( "aa" ) << QStringLiteral( "bb" ) ); - auto testWrapper = [&p]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [&p]( QgsProcessingGui::WidgetType type ) { // non optional, no existing themes QgsProcessingParameterMapTheme param( QStringLiteral( "theme" ), QStringLiteral( "theme" ), false ); @@ -7957,21 +7872,21 @@ void TestProcessingGui::testMapThemeWrapper() // batch or standard mode, only valid themes can be set! QCOMPARE( spy.count(), 0 ); QVERIFY( !wrapper.widgetValue().isValid() ); - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentIndex(), -1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentIndex(), -1 ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 0 ); QVERIFY( !wrapper.widgetValue().isValid() ); - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentIndex(), -1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentIndex(), -1 ); break; case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); break; } @@ -7989,14 +7904,14 @@ void TestProcessingGui::testMapThemeWrapper() wrapper2.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper2.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); // check signal - static_cast< QComboBox * >( wrapper2.wrappedWidget() )->setCurrentIndex( 2 ); + static_cast( wrapper2.wrappedWidget() )->setCurrentIndex( 2 ); QCOMPARE( spy2.count(), 3 ); delete w; @@ -8011,11 +7926,11 @@ void TestProcessingGui::testMapThemeWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 3 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -8050,41 +7965,40 @@ void TestProcessingGui::testMapThemeWrapper() QgsProcessingParameterWidgetContext widgetContext; widgetContext.setProject( &p ); QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "maptheme" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "maptheme" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( !static_cast< QgsProcessingParameterMapTheme * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); // using a parameter definition as initial values QgsProcessingParameterMapTheme themeParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "aaa" ), false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "maptheme" ), context, widgetContext, &themeParam ); + widget = std::make_unique( QStringLiteral( "maptheme" ), context, widgetContext, &themeParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterMapTheme * >( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); themeParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); themeParam.setDefaultValue( QStringLiteral( "xxx" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "maptheme" ), context, widgetContext, &themeParam ); + widget = std::make_unique( QStringLiteral( "maptheme" ), context, widgetContext, &themeParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterMapTheme * >( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); themeParam.setDefaultValue( QVariant() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "maptheme" ), context, widgetContext, &themeParam ); + widget = std::make_unique( QStringLiteral( "maptheme" ), context, widgetContext, &themeParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); - QVERIFY( !static_cast< QgsProcessingParameterMapTheme * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); } void TestProcessingGui::testDateTimeWrapper() { - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional, no existing themes QgsProcessingParameterDateTime param( QStringLiteral( "datetime" ), QStringLiteral( "datetime" ), Qgis::ProcessingDateTimeParameterDataType::DateTime, QVariant(), false ); @@ -8103,12 +8017,12 @@ void TestProcessingGui::testDateTimeWrapper() QCOMPARE( spy.count(), 1 ); QVERIFY( wrapper.widgetValue().isValid() ); QCOMPARE( wrapper.widgetValue().toDateTime(), QDateTime( QDate( 2019, 8, 7 ), QTime( 0, 0, 0 ) ) ); - QCOMPARE( static_cast< QgsDateTimeEdit * >( wrapper.wrappedWidget() )->dateTime(), QDateTime( QDate( 2019, 8, 7 ), QTime( 0, 0, 0 ) ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->dateTime(), QDateTime( QDate( 2019, 8, 7 ), QTime( 0, 0, 0 ) ) ); wrapper.setWidgetValue( QStringLiteral( "2019-08-07" ), context ); QCOMPARE( spy.count(), 1 ); // check signal - static_cast< QgsDateTimeEdit * >( wrapper.wrappedWidget() )->setDateTime( QDateTime( QDate( 2019, 8, 9 ), QTime( 0, 0, 0 ) ) ); + static_cast( wrapper.wrappedWidget() )->setDateTime( QDateTime( QDate( 2019, 8, 9 ), QTime( 0, 0, 0 ) ) ); QCOMPARE( spy.count(), 2 ); delete w; @@ -8122,11 +8036,11 @@ void TestProcessingGui::testDateTimeWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 0 ); QVERIFY( !wrapper3.widgetValue().isValid() ); - QVERIFY( !static_cast< QgsDateTimeEdit * >( wrapper3.wrappedWidget() )->dateTime().isValid() ); + QVERIFY( !static_cast( wrapper3.wrappedWidget() )->dateTime().isValid() ); wrapper3.setWidgetValue( QStringLiteral( "2019-03-20" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toDateTime(), QDateTime( QDate( 2019, 3, 20 ), QTime( 0, 0, 0 ) ) ); - QCOMPARE( static_cast< QgsDateTimeEdit * >( wrapper3.wrappedWidget() )->dateTime(), QDateTime( QDate( 2019, 3, 20 ), QTime( 0, 0, 0 ) ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->dateTime(), QDateTime( QDate( 2019, 3, 20 ), QTime( 0, 0, 0 ) ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 2 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -8141,15 +8055,15 @@ void TestProcessingGui::testDateTimeWrapper() wrapper4.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy4.count(), 0 ); QVERIFY( !wrapper4.widgetValue().isValid() ); - QVERIFY( !static_cast< QgsDateEdit * >( wrapper4.wrappedWidget() )->date().isValid() ); + QVERIFY( !static_cast( wrapper4.wrappedWidget() )->date().isValid() ); wrapper4.setWidgetValue( QStringLiteral( "2019-03-20" ), context ); QCOMPARE( spy4.count(), 1 ); QCOMPARE( wrapper4.widgetValue().toDate(), QDate( 2019, 3, 20 ) ); - QCOMPARE( static_cast< QgsDateEdit * >( wrapper4.wrappedWidget() )->date(), QDate( 2019, 3, 20 ) ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->date(), QDate( 2019, 3, 20 ) ); wrapper4.setWidgetValue( QDate( 2020, 1, 3 ), context ); QCOMPARE( spy4.count(), 2 ); QCOMPARE( wrapper4.widgetValue().toDate(), QDate( 2020, 1, 3 ) ); - QCOMPARE( static_cast< QgsDateEdit * >( wrapper4.wrappedWidget() )->date(), QDate( 2020, 1, 3 ) ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->date(), QDate( 2020, 1, 3 ) ); wrapper4.setWidgetValue( QVariant(), context ); QCOMPARE( spy4.count(), 3 ); QVERIFY( !wrapper4.widgetValue().isValid() ); @@ -8164,15 +8078,15 @@ void TestProcessingGui::testDateTimeWrapper() wrapper5.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy5.count(), 0 ); QVERIFY( !wrapper5.widgetValue().isValid() ); - QVERIFY( !static_cast< QgsTimeEdit * >( wrapper5.wrappedWidget() )->time().isValid() ); + QVERIFY( !static_cast( wrapper5.wrappedWidget() )->time().isValid() ); wrapper5.setWidgetValue( QStringLiteral( "11:34:56" ), context ); QCOMPARE( spy5.count(), 1 ); QCOMPARE( wrapper5.widgetValue().toTime(), QTime( 11, 34, 56 ) ); - QCOMPARE( static_cast< QgsTimeEdit * >( wrapper5.wrappedWidget() )->time(), QTime( 11, 34, 56 ) ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->time(), QTime( 11, 34, 56 ) ); wrapper5.setWidgetValue( QTime( 9, 34, 56 ), context ); QCOMPARE( spy5.count(), 2 ); QCOMPARE( wrapper5.widgetValue().toTime(), QTime( 9, 34, 56 ) ); - QCOMPARE( static_cast< QgsTimeEdit * >( wrapper5.wrappedWidget() )->time(), QTime( 9, 34, 56 ) ); + QCOMPARE( static_cast( wrapper5.wrappedWidget() )->time(), QTime( 9, 34, 56 ) ); wrapper5.setWidgetValue( QVariant(), context ); QCOMPARE( spy5.count(), 3 ); QVERIFY( !wrapper5.widgetValue().isValid() ); @@ -8204,31 +8118,31 @@ void TestProcessingGui::testDateTimeWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "datetime" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "datetime" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( !static_cast< QgsProcessingParameterDateTime * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); // using a parameter definition as initial values QgsProcessingParameterDateTime datetimeParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), Qgis::ProcessingDateTimeParameterDataType::Date, QVariant(), false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "datetime" ), context, widgetContext, &datetimeParam ); + widget = std::make_unique( QStringLiteral( "datetime" ), context, widgetContext, &datetimeParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterDateTime * >( def.get() )->dataType(), Qgis::ProcessingDateTimeParameterDataType::Date ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingDateTimeParameterDataType::Date ); datetimeParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); datetimeParam.setDefaultValue( QStringLiteral( "xxx" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "datetime" ), context, widgetContext, &datetimeParam ); + widget = std::make_unique( QStringLiteral( "datetime" ), context, widgetContext, &datetimeParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterDateTime * >( def.get() )->dataType(), Qgis::ProcessingDateTimeParameterDataType::Date ); + QCOMPARE( static_cast( def.get() )->dataType(), Qgis::ProcessingDateTimeParameterDataType::Date ); } void TestProcessingGui::testProviderConnectionWrapper() @@ -8239,8 +8153,7 @@ void TestProcessingGui::testProviderConnectionWrapper() md->saveConnection( conn, QStringLiteral( "aa" ) ); md->saveConnection( conn, QStringLiteral( "bb" ) ); - auto testWrapper = []( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = []( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterProviderConnection param( QStringLiteral( "conn" ), QStringLiteral( "connection" ), QStringLiteral( "ogr" ), false ); QgsProcessingProviderConnectionWidgetWrapper wrapper( ¶m, type ); @@ -8252,7 +8165,7 @@ void TestProcessingGui::testProviderConnectionWrapper() wrapper.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProviderConnectionComboBox * >( wrapper.wrappedWidget() )->currentConnection(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentConnection(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy.count(), 1 ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); @@ -8269,19 +8182,18 @@ void TestProcessingGui::testProviderConnectionWrapper() wrapper.setWidgetValue( QStringLiteral( "cc" ), context ); QCOMPARE( spy.count(), 3 ); QVERIFY( !wrapper.widgetValue().isValid() ); - QCOMPARE( static_cast< QComboBox * >( wrapper.wrappedWidget() )->currentIndex(), -1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentIndex(), -1 ); break; - } case QgsProcessingGui::Modeler: // invalid connections permitted wrapper.setWidgetValue( QStringLiteral( "cc" ), context ); QCOMPARE( spy.count(), 3 ); - QCOMPARE( static_cast< QgsProviderConnectionComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "cc" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "cc" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "cc" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 4 ); - QCOMPARE( static_cast< QgsProviderConnectionComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); break; } @@ -8296,11 +8208,11 @@ void TestProcessingGui::testProviderConnectionWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 3 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -8331,36 +8243,36 @@ void TestProcessingGui::testProviderConnectionWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "providerconnection" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "providerconnection" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( !static_cast< QgsProcessingParameterProviderConnection * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); // using a parameter definition as initial values QgsProcessingParameterProviderConnection connParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "spatialite" ), QStringLiteral( "aaa" ), false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "providerconnection" ), context, widgetContext, &connParam ); + widget = std::make_unique( QStringLiteral( "providerconnection" ), context, widgetContext, &connParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterProviderConnection * >( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); - QCOMPARE( static_cast< QgsProcessingParameterProviderConnection * >( def.get() )->providerId(), QStringLiteral( "spatialite" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); + QCOMPARE( static_cast( def.get() )->providerId(), QStringLiteral( "spatialite" ) ); connParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); connParam.setDefaultValue( QStringLiteral( "xxx" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "providerconnection" ), context, widgetContext, &connParam ); + widget = std::make_unique( QStringLiteral( "providerconnection" ), context, widgetContext, &connParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterProviderConnection * >( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); connParam.setDefaultValue( QVariant() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "providerconnection" ), context, widgetContext, &connParam ); + widget = std::make_unique( QStringLiteral( "providerconnection" ), context, widgetContext, &connParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); - QVERIFY( !static_cast< QgsProcessingParameterProviderConnection * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); } void TestProcessingGui::testDatabaseSchemaWrapper() @@ -8380,8 +8292,7 @@ void TestProcessingGui::testDatabaseSchemaWrapper() const QStringList schemas = dynamic_cast( conn )->schemas(); QVERIFY( !schemas.isEmpty() ); - auto testWrapper = [&schemas]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [&schemas]( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterProviderConnection connParam( QStringLiteral( "conn" ), QStringLiteral( "connection" ), QStringLiteral( "postgres" ), QVariant(), true ); TestLayerWrapper connWrapper( &connParam ); @@ -8392,23 +8303,23 @@ void TestProcessingGui::testDatabaseSchemaWrapper() QgsProcessingContext context; QWidget *w = wrapper.createWrappedWidget( context ); // no connection associated yet - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); // Set the parent widget connection value connWrapper.setWidgetValue( QStringLiteral( "aa" ), context ); wrapper.setParentConnectionWrapperValue( &connWrapper ); // now we should have schemas available - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), schemas.count() ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->count(), schemas.count() ); QSignalSpy spy( &wrapper, &QgsProcessingDatabaseSchemaWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QStringLiteral( "qgis_test" ), context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "qgis_test" ) ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->currentSchema(), QStringLiteral( "qgis_test" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentSchema(), QStringLiteral( "qgis_test" ) ); wrapper.setWidgetValue( QStringLiteral( "public" ), context ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "public" ) ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->currentSchema(), QStringLiteral( "public" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentSchema(), QStringLiteral( "public" ) ); QCOMPARE( spy.count(), 2 ); wrapper.setWidgetValue( QStringLiteral( "public" ), context ); QCOMPARE( spy.count(), 2 ); @@ -8423,19 +8334,18 @@ void TestProcessingGui::testDatabaseSchemaWrapper() wrapper.setWidgetValue( QStringLiteral( "cc" ), context ); QCOMPARE( spy.count(), 3 ); QVERIFY( !wrapper.widgetValue().isValid() ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentIndex(), -1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentIndex(), -1 ); break; - } case QgsProcessingGui::Modeler: // invalid schemas permitted wrapper.setWidgetValue( QStringLiteral( "cc" ), context ); QCOMPARE( spy.count(), 3 ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "cc" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "cc" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "cc" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 4 ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "aa" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); break; } @@ -8443,7 +8353,7 @@ void TestProcessingGui::testDatabaseSchemaWrapper() // make sure things are ok if connection is changed back to nothing connWrapper.setWidgetValue( QVariant(), context ); wrapper.setParentConnectionWrapperValue( &connWrapper ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); switch ( type ) { @@ -8473,7 +8383,7 @@ void TestProcessingGui::testDatabaseSchemaWrapper() case QgsProcessingGui::Modeler: // invalid schemas permitted QCOMPARE( spy.count(), 6 ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "qgis_test" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "qgis_test" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "qgis_test" ) ); break; @@ -8493,11 +8403,11 @@ void TestProcessingGui::testDatabaseSchemaWrapper() wrapper3.setWidgetValue( QStringLiteral( "qgis_test" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "qgis_test" ) ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "qgis_test" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "qgis_test" ) ); wrapper3.setWidgetValue( QStringLiteral( "public" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "public" ) ); - QCOMPARE( static_cast< QgsDatabaseSchemaComboBox * >( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "public" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "public" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 3 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -8515,7 +8425,6 @@ void TestProcessingGui::testDatabaseSchemaWrapper() { QVERIFY( !l ); } - }; // standard wrapper @@ -8530,36 +8439,36 @@ void TestProcessingGui::testDatabaseSchemaWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databaseschema" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "databaseschema" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( !static_cast< QgsProcessingParameterDatabaseSchema * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); // using a parameter definition as initial values QgsProcessingParameterDatabaseSchema schemaParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "connparam" ), QStringLiteral( "aaa" ), false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databaseschema" ), context, widgetContext, &schemaParam ); + widget = std::make_unique( QStringLiteral( "databaseschema" ), context, widgetContext, &schemaParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterDatabaseSchema * >( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); - QCOMPARE( static_cast< QgsProcessingParameterDatabaseSchema * >( def.get() )->parentConnectionParameterName(), QStringLiteral( "connparam" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); + QCOMPARE( static_cast( def.get() )->parentConnectionParameterName(), QStringLiteral( "connparam" ) ); schemaParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); schemaParam.setDefaultValue( QStringLiteral( "xxx" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databaseschema" ), context, widgetContext, &schemaParam ); + widget = std::make_unique( QStringLiteral( "databaseschema" ), context, widgetContext, &schemaParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterDatabaseSchema * >( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); schemaParam.setDefaultValue( QVariant() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databaseschema" ), context, widgetContext, &schemaParam ); + widget = std::make_unique( QStringLiteral( "databaseschema" ), context, widgetContext, &schemaParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); - QVERIFY( !static_cast< QgsProcessingParameterDatabaseSchema * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); #endif } @@ -8584,8 +8493,7 @@ void TestProcessingGui::testDatabaseTableWrapper() QVERIFY( !tableNames.isEmpty() ); - auto testWrapper = [&tableNames]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [&tableNames]( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterProviderConnection connParam( QStringLiteral( "conn" ), QStringLiteral( "connection" ), QStringLiteral( "postgres" ), QVariant(), true ); TestLayerWrapper connWrapper( &connParam ); QgsProcessingParameterDatabaseSchema schemaParam( QStringLiteral( "schema" ), QStringLiteral( "schema" ), QStringLiteral( "connection" ), QVariant(), true ); @@ -8598,7 +8506,7 @@ void TestProcessingGui::testDatabaseTableWrapper() QgsProcessingContext context; QWidget *w = wrapper.createWrappedWidget( context ); // no connection associated yet - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); // Set the parent widget connection value connWrapper.setWidgetValue( QStringLiteral( "aa" ), context ); @@ -8607,16 +8515,16 @@ void TestProcessingGui::testDatabaseTableWrapper() wrapper.setParentSchemaWrapperValue( &schemaWrapper ); // now we should have tables available - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), tableNames.count() ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->count(), tableNames.count() ); QSignalSpy spy( &wrapper, &QgsProcessingDatabaseTableWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QStringLiteral( "someData" ), context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "someData" ) ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->currentTable(), QStringLiteral( "someData" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentTable(), QStringLiteral( "someData" ) ); wrapper.setWidgetValue( QStringLiteral( "some_poly_data" ), context ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "some_poly_data" ) ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->currentTable(), QStringLiteral( "some_poly_data" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentTable(), QStringLiteral( "some_poly_data" ) ); QCOMPARE( spy.count(), 2 ); wrapper.setWidgetValue( QStringLiteral( "some_poly_data" ), context ); QCOMPARE( spy.count(), 2 ); @@ -8631,19 +8539,18 @@ void TestProcessingGui::testDatabaseTableWrapper() wrapper.setWidgetValue( QStringLiteral( "cc" ), context ); QCOMPARE( spy.count(), 3 ); QVERIFY( !wrapper.widgetValue().isValid() ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentIndex(), -1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentIndex(), -1 ); break; - } case QgsProcessingGui::Modeler: // invalid tables permitted wrapper.setWidgetValue( QStringLiteral( "cc" ), context ); QCOMPARE( spy.count(), 3 ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "cc" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "cc" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "cc" ) ); wrapper.setWidgetValue( QStringLiteral( "someData" ), context ); QCOMPARE( spy.count(), 4 ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someData" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someData" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "someData" ) ); break; } @@ -8651,7 +8558,7 @@ void TestProcessingGui::testDatabaseTableWrapper() // make sure things are ok if connection is changed back to nothing connWrapper.setWidgetValue( QVariant(), context ); wrapper.setParentConnectionWrapperValue( &connWrapper ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->count(), 0 ); switch ( type ) { @@ -8681,7 +8588,7 @@ void TestProcessingGui::testDatabaseTableWrapper() case QgsProcessingGui::Modeler: // invalid tables permitted QCOMPARE( spy.count(), 6 ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "some_poly_data" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "some_poly_data" ) ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "some_poly_data" ) ); break; @@ -8702,11 +8609,11 @@ void TestProcessingGui::testDatabaseTableWrapper() wrapper3.setWidgetValue( QStringLiteral( "someData" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "someData" ) ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someData" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someData" ) ); wrapper3.setWidgetValue( QStringLiteral( "some_poly_data" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "some_poly_data" ) ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "some_poly_data" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "some_poly_data" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 3 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -8725,11 +8632,11 @@ void TestProcessingGui::testDatabaseTableWrapper() wrapper4.setWidgetValue( QStringLiteral( "someData" ), context ); QCOMPARE( spy4.count(), 1 ); QCOMPARE( wrapper4.widgetValue().toString(), QStringLiteral( "someData" ) ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper4.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someData" ) ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someData" ) ); wrapper4.setWidgetValue( QStringLiteral( "some_poly_data" ), context ); QCOMPARE( spy4.count(), 2 ); QCOMPARE( wrapper4.widgetValue().toString(), QStringLiteral( "some_poly_data" ) ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper4.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "some_poly_data" ) ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "some_poly_data" ) ); wrapper4.setWidgetValue( QVariant(), context ); QCOMPARE( spy4.count(), 3 ); QVERIFY( !wrapper4.widgetValue().isValid() ); @@ -8737,7 +8644,7 @@ void TestProcessingGui::testDatabaseTableWrapper() wrapper4.setWidgetValue( QStringLiteral( "someDataxxxxxxxxxxxxxxxxxxxx" ), context ); QCOMPARE( spy4.count(), 4 ); QCOMPARE( wrapper4.widgetValue().toString(), QStringLiteral( "someDataxxxxxxxxxxxxxxxxxxxx" ) ); - QCOMPARE( static_cast< QgsDatabaseTableComboBox * >( wrapper4.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someDataxxxxxxxxxxxxxxxxxxxx" ) ); + QCOMPARE( static_cast( wrapper4.wrappedWidget() )->comboBox()->currentText(), QStringLiteral( "someDataxxxxxxxxxxxxxxxxxxxx" ) ); delete w; @@ -8769,37 +8676,37 @@ void TestProcessingGui::testDatabaseTableWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databasetable" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "databasetable" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QVERIFY( !static_cast< QgsProcessingParameterDatabaseTable * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); // using a parameter definition as initial values QgsProcessingParameterDatabaseTable tableParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "connparam" ), QStringLiteral( "schemaparam" ), QStringLiteral( "aaa" ), false ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databasetable" ), context, widgetContext, &tableParam ); + widget = std::make_unique( QStringLiteral( "databasetable" ), context, widgetContext, &tableParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterDatabaseTable * >( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); - QCOMPARE( static_cast< QgsProcessingParameterDatabaseTable * >( def.get() )->parentConnectionParameterName(), QStringLiteral( "connparam" ) ); - QCOMPARE( static_cast< QgsProcessingParameterDatabaseTable * >( def.get() )->parentSchemaParameterName(), QStringLiteral( "schemaparam" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "aaa" ) ); + QCOMPARE( static_cast( def.get() )->parentConnectionParameterName(), QStringLiteral( "connparam" ) ); + QCOMPARE( static_cast( def.get() )->parentSchemaParameterName(), QStringLiteral( "schemaparam" ) ); tableParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); tableParam.setDefaultValue( QStringLiteral( "xxx" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databasetable" ), context, widgetContext, &tableParam ); + widget = std::make_unique( QStringLiteral( "databasetable" ), context, widgetContext, &tableParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterDatabaseTable * >( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "xxx" ) ); tableParam.setDefaultValue( QVariant() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "databasetable" ), context, widgetContext, &tableParam ); + widget = std::make_unique( QStringLiteral( "databasetable" ), context, widgetContext, &tableParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); - QVERIFY( !static_cast< QgsProcessingParameterDatabaseTable * >( def.get() )->defaultValue().isValid() ); + QVERIFY( !static_cast( def.get() )->defaultValue().isValid() ); #endif } @@ -8809,12 +8716,12 @@ void TestProcessingGui::testFieldMapWidget() QVariantMap map; map.insert( QStringLiteral( "name" ), QStringLiteral( "n" ) ); - map.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::Double ) ); + map.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::Double ) ); map.insert( QStringLiteral( "length" ), 8 ); map.insert( QStringLiteral( "precision" ), 5 ); QVariantMap map2; map2.insert( QStringLiteral( "name" ), QStringLiteral( "n2" ) ); - map2.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::QString ) ); + map2.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::QString ) ); map2.insert( QStringLiteral( "expression" ), QStringLiteral( "'abc' || \"def\"" ) ); map2.insert( QStringLiteral( "alias" ), QStringLiteral( "my alias" ) ); map2.insert( QStringLiteral( "comment" ), QStringLiteral( "my comment" ) ); @@ -8825,12 +8732,12 @@ void TestProcessingGui::testFieldMapWidget() QCOMPARE( widget.value().toList().size(), 2 ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::Double ) ); + QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::Double ) ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "length" ) ).toInt(), 8 ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "precision" ) ).toInt(), 5 ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "expression" ) ).toString(), QString() ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::QString ) ); + QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::QString ) ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "expression" ) ).toString(), QStringLiteral( "'abc' || \"def\"" ) ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "alias" ) ).toString(), QStringLiteral( "my alias" ) ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "comment" ) ).toString(), QStringLiteral( "my comment" ) ); @@ -8841,8 +8748,7 @@ void TestProcessingGui::testFieldMapWrapper() const QgsProcessingAlgorithm *centroidAlg = QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "native:centroids" ) ); const QgsProcessingParameterDefinition *layerDef = centroidAlg->parameterDefinition( QStringLiteral( "INPUT" ) ); - auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterFieldMapping param( QStringLiteral( "mapping" ), QStringLiteral( "mapping" ) ); QgsProcessingFieldMapWidgetWrapper wrapper( ¶m, type ); @@ -8852,12 +8758,12 @@ void TestProcessingGui::testFieldMapWrapper() QVariantMap map; map.insert( QStringLiteral( "name" ), QStringLiteral( "n" ) ); - map.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::Double ) ); + map.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::Double ) ); map.insert( QStringLiteral( "length" ), 8 ); map.insert( QStringLiteral( "precision" ), 5 ); QVariantMap map2; map2.insert( QStringLiteral( "name" ), QStringLiteral( "n2" ) ); - map2.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::QString ) ); + map2.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::QString ) ); map2.insert( QStringLiteral( "expression" ), QStringLiteral( "'abc' || \"def\"" ) ); map2.insert( QStringLiteral( "alias" ), QStringLiteral( "my alias" ) ); map2.insert( QStringLiteral( "comment" ), QStringLiteral( "my comment" ) ); @@ -8866,23 +8772,23 @@ void TestProcessingGui::testFieldMapWrapper() wrapper.setWidgetValue( QVariantList() << map << map2, context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::Double ) ); + QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::Double ) ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "length" ) ).toInt(), 8 ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "precision" ) ).toInt(), 5 ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "expression" ) ).toString(), QString() ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::QString ) ); + QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::QString ) ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "expression" ) ).toString(), QStringLiteral( "'abc' || \"def\"" ) ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "alias" ) ).toString(), QStringLiteral( "my alias" ) ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "comment" ) ).toString(), QStringLiteral( "my comment" ) ); - QCOMPARE( static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper.wrappedWidget() )->value().toList().count(), 2 ); - QCOMPARE( static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper.wrappedWidget() )->value().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().count(), 2 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); wrapper.setWidgetValue( QVariantList() << map, context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toList().size(), 1 ); - QCOMPARE( static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper.wrappedWidget() )->value().toList().size(), 1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().size(), 1 ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -8898,7 +8804,7 @@ void TestProcessingGui::testFieldMapWrapper() } // check signal - static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper.wrappedWidget() )->setValue( QVariantList() << map << map2 ); + static_cast( wrapper.wrappedWidget() )->setValue( QVariantList() << map << map2 ); QCOMPARE( spy.count(), 3 ); delete w; @@ -8911,17 +8817,17 @@ void TestProcessingGui::testFieldMapWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingFieldMapWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( QVariantList() << map, context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); + QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); wrapper2.setWidgetValue( QVariantList() << map2, context ); QCOMPARE( spy2.count(), 2 ); - QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); + QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - QCOMPARE( static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - static_cast< QgsProcessingFieldMapPanelWidget * >( wrapper2.wrappedWidget() )->setValue( QVariantList() << map ); + static_cast( wrapper2.wrappedWidget() )->setValue( QVariantList() << map ); QCOMPARE( spy2.count(), 3 ); TestLayerWrapper layerWrapper( layerDef ); @@ -8962,7 +8868,6 @@ void TestProcessingGui::testFieldMapWrapper() QCOMPARE( wrapper2.mPanel->layer()->publicSource(), pointFileName ); // must be owned by wrapper, or layer may be deleted while still required by wrapper QCOMPARE( wrapper2.mParentLayer->publicSource(), pointFileName ); - }; // standard wrapper @@ -8977,30 +8882,30 @@ void TestProcessingGui::testFieldMapWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "fields_mapping" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "fields_mapping" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterFieldMapping mapParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "parent" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "fields_mapping" ), context, widgetContext, &mapParam ); + widget = std::make_unique( QStringLiteral( "fields_mapping" ), context, widgetContext, &mapParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterFieldMapping * >( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); mapParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); mapParam.setParentLayerParameterName( QString() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "fields_mapping" ), context, widgetContext, &mapParam ); + widget = std::make_unique( QStringLiteral( "fields_mapping" ), context, widgetContext, &mapParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QVERIFY( static_cast< QgsProcessingParameterFieldMapping * >( def.get() )->parentLayerParameterName().isEmpty() ); + QVERIFY( static_cast( def.get() )->parentLayerParameterName().isEmpty() ); } void TestProcessingGui::testAggregateWidget() @@ -9009,12 +8914,12 @@ void TestProcessingGui::testAggregateWidget() QVariantMap map; map.insert( QStringLiteral( "name" ), QStringLiteral( "n" ) ); - map.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::Double ) ); + map.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::Double ) ); map.insert( QStringLiteral( "length" ), 8 ); map.insert( QStringLiteral( "precision" ), 5 ); QVariantMap map2; map2.insert( QStringLiteral( "name" ), QStringLiteral( "n2" ) ); - map2.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::QString ) ); + map2.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::QString ) ); map2.insert( QStringLiteral( "input" ), QStringLiteral( "'abc' || \"def\"" ) ); map2.insert( QStringLiteral( "aggregate" ), QStringLiteral( "concatenate" ) ); map2.insert( QStringLiteral( "delimiter" ), QStringLiteral( "|" ) ); @@ -9025,14 +8930,14 @@ void TestProcessingGui::testAggregateWidget() QCOMPARE( widget.value().toList().size(), 2 ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::Double ) ); + QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::Double ) ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "length" ) ).toInt(), 8 ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "precision" ) ).toInt(), 5 ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "input" ) ).toString(), QString() ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "aggregate" ) ).toString(), QString() ); QCOMPARE( widget.value().toList().at( 0 ).toMap().value( QStringLiteral( "delimiter" ) ).toString(), QString() ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::QString ) ); + QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::QString ) ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "input" ) ).toString(), QStringLiteral( "'abc' || \"def\"" ) ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "aggregate" ) ).toString(), QStringLiteral( "concatenate" ) ); QCOMPARE( widget.value().toList().at( 1 ).toMap().value( QStringLiteral( "delimiter" ) ).toString(), QStringLiteral( "|" ) ); @@ -9043,8 +8948,7 @@ void TestProcessingGui::testAggregateWrapper() const QgsProcessingAlgorithm *centroidAlg = QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "native:centroids" ) ); const QgsProcessingParameterDefinition *layerDef = centroidAlg->parameterDefinition( QStringLiteral( "INPUT" ) ); - auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) { QgsProcessingParameterAggregate param( QStringLiteral( "mapping" ), QStringLiteral( "mapping" ) ); QgsProcessingAggregateWidgetWrapper wrapper( ¶m, type ); @@ -9054,12 +8958,12 @@ void TestProcessingGui::testAggregateWrapper() QVariantMap map; map.insert( QStringLiteral( "name" ), QStringLiteral( "n" ) ); - map.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::Double ) ); + map.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::Double ) ); map.insert( QStringLiteral( "length" ), 8 ); map.insert( QStringLiteral( "precision" ), 5 ); QVariantMap map2; map2.insert( QStringLiteral( "name" ), QStringLiteral( "n2" ) ); - map2.insert( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::QString ) ); + map2.insert( QStringLiteral( "type" ), static_cast( QMetaType::Type::QString ) ); map2.insert( QStringLiteral( "input" ), QStringLiteral( "'abc' || \"def\"" ) ); map2.insert( QStringLiteral( "aggregate" ), QStringLiteral( "concatenate" ) ); map2.insert( QStringLiteral( "delimiter" ), QStringLiteral( "|" ) ); @@ -9068,25 +8972,25 @@ void TestProcessingGui::testAggregateWrapper() wrapper.setWidgetValue( QVariantList() << map << map2, context ); QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::Double ) ); + QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::Double ) ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "length" ) ).toInt(), 8 ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "precision" ) ).toInt(), 5 ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "input" ) ).toString(), QString() ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "aggregate" ) ).toString(), QString() ); QCOMPARE( wrapper.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "delimiter" ) ).toString(), QString() ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast< int >( QMetaType::Type::QString ) ); + QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "type" ) ).toInt(), static_cast( QMetaType::Type::QString ) ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "input" ) ).toString(), QStringLiteral( "'abc' || \"def\"" ) ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "aggregate" ) ).toString(), QStringLiteral( "concatenate" ) ); QCOMPARE( wrapper.widgetValue().toList().at( 1 ).toMap().value( QStringLiteral( "delimiter" ) ).toString(), QStringLiteral( "|" ) ); - QCOMPARE( static_cast< QgsProcessingAggregatePanelWidget * >( wrapper.wrappedWidget() )->value().toList().count(), 2 ); - QCOMPARE( static_cast< QgsProcessingAggregatePanelWidget * >( wrapper.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( static_cast< QgsProcessingAggregatePanelWidget * >( wrapper.wrappedWidget() )->value().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().count(), 2 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().at( 1 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); wrapper.setWidgetValue( QVariantList() << map, context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toList().size(), 1 ); - QCOMPARE( static_cast< QgsProcessingAggregatePanelWidget * >( wrapper.wrappedWidget() )->value().toList().size(), 1 ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toList().size(), 1 ); QLabel *l = wrapper.createWrappedLabel(); if ( wrapper.type() != QgsProcessingGui::Batch ) @@ -9102,7 +9006,7 @@ void TestProcessingGui::testAggregateWrapper() } // check signal - static_cast< QgsProcessingAggregatePanelWidget * >( wrapper.wrappedWidget() )->setValue( QVariantList() << map << map2 ); + static_cast( wrapper.wrappedWidget() )->setValue( QVariantList() << map << map2 ); QCOMPARE( spy.count(), 3 ); delete w; @@ -9115,17 +9019,17 @@ void TestProcessingGui::testAggregateWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingAggregateWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( QVariantList() << map, context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); + QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); - QCOMPARE( static_cast< QgsProcessingAggregatePanelWidget * >( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n" ) ); wrapper2.setWidgetValue( QVariantList() << map2, context ); QCOMPARE( spy2.count(), 2 ); - QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); + QCOMPARE( wrapper2.widgetValue().toList().size(), 1 ); QCOMPARE( wrapper2.widgetValue().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - QCOMPARE( static_cast< QgsProcessingAggregatePanelWidget * >( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->value().toList().at( 0 ).toMap().value( QStringLiteral( "name" ) ).toString(), QStringLiteral( "n2" ) ); - static_cast< QgsProcessingAggregatePanelWidget * >( wrapper2.wrappedWidget() )->setValue( QVariantList() << map ); + static_cast( wrapper2.wrappedWidget() )->setValue( QVariantList() << map ); QCOMPARE( spy2.count(), 3 ); @@ -9167,7 +9071,6 @@ void TestProcessingGui::testAggregateWrapper() QCOMPARE( wrapper2.mPanel->layer()->publicSource(), pointFileName ); // must be owned by wrapper, or layer may be deleted while still required by wrapper QCOMPARE( wrapper2.mParentLayer->publicSource(), pointFileName ); - }; // standard wrapper @@ -9182,30 +9085,30 @@ void TestProcessingGui::testAggregateWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "aggregates" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "aggregates" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); // using a parameter definition as initial values QgsProcessingParameterAggregate mapParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "parent" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "aggregates" ), context, widgetContext, &mapParam ); + widget = std::make_unique( QStringLiteral( "aggregates" ), context, widgetContext, &mapParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterAggregate * >( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); mapParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); mapParam.setParentLayerParameterName( QString() ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "aggregates" ), context, widgetContext, &mapParam ); + widget = std::make_unique( QStringLiteral( "aggregates" ), context, widgetContext, &mapParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QVERIFY( static_cast< QgsProcessingParameterAggregate * >( def.get() )->parentLayerParameterName().isEmpty() ); + QVERIFY( static_cast( def.get() )->parentLayerParameterName().isEmpty() ); } void TestProcessingGui::testOutputDefinitionWidget() @@ -9218,14 +9121,14 @@ void TestProcessingGui::testOutputDefinitionWidget() QVariant v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 0 ); @@ -9241,14 +9144,14 @@ void TestProcessingGui::testOutputDefinitionWidget() QCOMPARE( changedSpy.count(), 0 ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); panel.setValue( QStringLiteral( "memory:" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 0 ); @@ -9262,16 +9165,16 @@ void TestProcessingGui::testOutputDefinitionWidget() QCOMPARE( changedSpy.count(), 0 ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); panel.setValue( QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 1 ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) ); QCOMPARE( skipSpy.count(), 0 ); @@ -9280,8 +9183,8 @@ void TestProcessingGui::testOutputDefinitionWidget() panel.setValue( QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 2 ); @@ -9292,8 +9195,8 @@ void TestProcessingGui::testOutputDefinitionWidget() panel.setValue( QStringLiteral( "/home/me/test.shp" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "/home/me/test.shp" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "/home/me/test.shp" ) ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 3 ); @@ -9309,8 +9212,8 @@ void TestProcessingGui::testOutputDefinitionWidget() panel.setValue( QStringLiteral( "test.shp" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "utf8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ) ); // optional, test skipping sink.setFlags( sink.flags() | Qgis::ProcessingParameterFlag::Optional ); @@ -9322,14 +9225,14 @@ void TestProcessingGui::testOutputDefinitionWidget() v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); panel2.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); QCOMPARE( skipSpy2.count(), 0 ); QCOMPARE( changedSpy2.count(), 0 ); @@ -9360,8 +9263,8 @@ void TestProcessingGui::testOutputDefinitionWidget() panel3.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel3.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel3.outputIsSkipped() ); QCOMPARE( skipSpy3.count(), 1 ); QCOMPARE( changedSpy3.count(), 1 ); @@ -9382,7 +9285,7 @@ void TestProcessingGui::testOutputDefinitionWidget() // with remapping def = QgsProcessingOutputLayerDefinition( QStringLiteral( "test.shp" ) ); QgsRemappingSinkDefinition remap; - QMap< QString, QgsProperty > fieldMap; + QMap fieldMap; fieldMap.insert( QStringLiteral( "field1" ), QgsProperty::fromField( QStringLiteral( "source1" ) ) ); fieldMap.insert( QStringLiteral( "field2" ), QgsProperty::fromExpression( QStringLiteral( "source || source2" ) ) ); remap.setFieldMap( fieldMap ); @@ -9391,15 +9294,15 @@ void TestProcessingGui::testOutputDefinitionWidget() panel3.setValue( def ); v = panel3.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QVERIFY( v.value< QgsProcessingOutputLayerDefinition>().useRemapping() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().remappingDefinition().fieldMap().size(), 2 ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().remappingDefinition().fieldMap().value( QStringLiteral( "field1" ) ), QgsProperty::fromField( QStringLiteral( "source1" ) ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().remappingDefinition().fieldMap().value( QStringLiteral( "field2" ) ), QgsProperty::fromExpression( QStringLiteral( "source || source2" ) ) ); + QVERIFY( v.value().useRemapping() ); + QCOMPARE( v.value().remappingDefinition().fieldMap().size(), 2 ); + QCOMPARE( v.value().remappingDefinition().fieldMap().value( QStringLiteral( "field1" ) ), QgsProperty::fromField( QStringLiteral( "source1" ) ) ); + QCOMPARE( v.value().remappingDefinition().fieldMap().value( QStringLiteral( "field2" ) ), QgsProperty::fromExpression( QStringLiteral( "source || source2" ) ) ); panel3.setValue( QStringLiteral( "other.shp" ) ); v = panel3.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QVERIFY( !v.value< QgsProcessingOutputLayerDefinition>().useRemapping() ); + QVERIFY( !v.value().useRemapping() ); } void TestProcessingGui::testOutputDefinitionWidgetVectorOut() @@ -9412,14 +9315,14 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() QVariant v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 0 ); @@ -9430,8 +9333,8 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() panel.setValue( QStringLiteral( "memory:" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 0 ); @@ -9445,8 +9348,8 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() QCOMPARE( changedSpy.count(), 1 ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QStringLiteral( "ogr:dbname='/me/a.gpkg' table=\"d\" (geom) sql=''" ) ); QCOMPARE( skipSpy.count(), 0 ); @@ -9455,8 +9358,8 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() panel.setValue( QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table=\"stufff\".\"output\" (the_geom) sql=" ) ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 2 ); @@ -9467,8 +9370,8 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() panel.setValue( QStringLiteral( "/home/me/test.shp" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "/home/me/test.shp" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "/home/me/test.shp" ) ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 3 ); @@ -9484,8 +9387,8 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() panel.setValue( QStringLiteral( "test.shp" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.shp" ) ) ); // optional, test skipping vector.setFlags( vector.flags() | Qgis::ProcessingParameterFlag::Optional ); @@ -9497,14 +9400,14 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); panel2.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); QCOMPARE( skipSpy2.count(), 0 ); QCOMPARE( changedSpy2.count(), 0 ); @@ -9535,8 +9438,8 @@ void TestProcessingGui::testOutputDefinitionWidgetVectorOut() panel3.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel3.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel3.outputIsSkipped() ); QCOMPARE( skipSpy3.count(), 1 ); QCOMPARE( changedSpy3.count(), 1 ); @@ -9565,14 +9468,14 @@ void TestProcessingGui::testOutputDefinitionWidgetRasterOut() QVariant v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 0 ); @@ -9585,8 +9488,8 @@ void TestProcessingGui::testOutputDefinitionWidgetRasterOut() QCOMPARE( changedSpy.count(), 1 ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "/home/me/test.tif" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "/home/me/test.tif" ) ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QStringLiteral( "/home/me/test.tif" ) ); QCOMPARE( skipSpy.count(), 0 ); @@ -9597,8 +9500,8 @@ void TestProcessingGui::testOutputDefinitionWidgetRasterOut() panel.setValue( QStringLiteral( "test.tif" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.tif" ) ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.tif" ) ) ); // optional, test skipping raster.setFlags( raster.flags() | Qgis::ProcessingParameterFlag::Optional ); @@ -9610,14 +9513,14 @@ void TestProcessingGui::testOutputDefinitionWidgetRasterOut() v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); panel2.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); QCOMPARE( skipSpy2.count(), 0 ); QCOMPARE( changedSpy2.count(), 0 ); @@ -9648,8 +9551,8 @@ void TestProcessingGui::testOutputDefinitionWidgetRasterOut() panel3.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel3.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel3.outputIsSkipped() ); QCOMPARE( skipSpy3.count(), 1 ); QCOMPARE( changedSpy3.count(), 1 ); @@ -9678,14 +9581,14 @@ void TestProcessingGui::testOutputDefinitionWidgetPointCloudOut() QVariant v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel.outputIsSkipped() ); QCOMPARE( skipSpy.count(), 0 ); QCOMPARE( changedSpy.count(), 0 ); @@ -9698,8 +9601,8 @@ void TestProcessingGui::testOutputDefinitionWidgetPointCloudOut() QCOMPARE( changedSpy.count(), 1 ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QStringLiteral( "/home/me/test.las" ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QStringLiteral( "/home/me/test.las" ) ); QVERIFY( !panel.outputIsSkipped() ); panel.setValue( QStringLiteral( "/home/me/test.las" ) ); QCOMPARE( skipSpy.count(), 0 ); @@ -9710,8 +9613,8 @@ void TestProcessingGui::testOutputDefinitionWidgetPointCloudOut() panel.setValue( QStringLiteral( "test.las" ) ); v = panel.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.las" ) ) ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QString( TEST_DATA_DIR + QStringLiteral( "/test.las" ) ) ); // optional, test skipping pointCloud.setFlags( pointCloud.flags() | Qgis::ProcessingParameterFlag::Optional ); @@ -9723,14 +9626,14 @@ void TestProcessingGui::testOutputDefinitionWidgetPointCloudOut() v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); panel2.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel2.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel2.outputIsSkipped() ); QCOMPARE( skipSpy2.count(), 0 ); QCOMPARE( changedSpy2.count(), 0 ); @@ -9761,8 +9664,8 @@ void TestProcessingGui::testOutputDefinitionWidgetPointCloudOut() panel3.setValue( QgsProcessing::TEMPORARY_OUTPUT ); v = panel3.value(); QCOMPARE( v.userType(), qMetaTypeId() ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); - QCOMPARE( v.value< QgsProcessingOutputLayerDefinition>().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); + QCOMPARE( v.value().createOptions.value( QStringLiteral( "fileEncoding" ) ).toString(), QStringLiteral( "UTF-8" ) ); + QCOMPARE( v.value().sink.staticValue().toString(), QgsProcessing::TEMPORARY_OUTPUT ); QVERIFY( !panel3.outputIsSkipped() ); QCOMPARE( skipSpy3.count(), 1 ); QCOMPARE( changedSpy3.count(), 1 ); @@ -10026,8 +9929,7 @@ void TestProcessingGui::testFeatureSourceOptionsWidget() void TestProcessingGui::testVectorOutWrapper() { - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterVectorDestination param( QStringLiteral( "vector" ), QStringLiteral( "vector" ) ); @@ -10045,19 +9947,19 @@ void TestProcessingGui::testVectorOutWrapper() case QgsProcessingGui::Batch: case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); wrapper.setWidgetValue( QStringLiteral( "/aa.shp" ), context ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); break; } // check signal - static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.shp" ) ); + static_cast( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.shp" ) ); QCOMPARE( spy.count(), 3 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/cc.shp" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/cc.shp" ) ); delete w; // optional @@ -10068,8 +9970,8 @@ void TestProcessingGui::testVectorOutWrapper() QSignalSpy spy3( &wrapper3, &QgsProcessingVectorDestinationWidgetWrapper::widgetValueHasChanged ); wrapper3.setWidgetValue( QStringLiteral( "/bb.shp" ), context ); QCOMPARE( spy3.count(), 1 ); - QCOMPARE( wrapper3.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper3.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( wrapper3.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 2 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -10101,8 +10003,7 @@ void TestProcessingGui::testVectorOutWrapper() void TestProcessingGui::testSinkWrapper() { - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterFeatureSink param( QStringLiteral( "sink" ), QStringLiteral( "sink" ) ); @@ -10120,19 +10021,19 @@ void TestProcessingGui::testSinkWrapper() case QgsProcessingGui::Batch: case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); wrapper.setWidgetValue( QStringLiteral( "/aa.shp" ), context ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/aa.shp" ) ); break; } // check signal - static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.shp" ) ); + static_cast( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.shp" ) ); QCOMPARE( spy.count(), 3 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/cc.shp" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/cc.shp" ) ); delete w; // optional @@ -10143,8 +10044,8 @@ void TestProcessingGui::testSinkWrapper() QSignalSpy spy3( &wrapper3, &QgsProcessingFeatureSinkWidgetWrapper::widgetValueHasChanged ); wrapper3.setWidgetValue( QStringLiteral( "/bb.shp" ), context ); QCOMPARE( spy3.count(), 1 ); - QCOMPARE( wrapper3.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper3.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( wrapper3.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/bb.shp" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 2 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -10176,8 +10077,7 @@ void TestProcessingGui::testSinkWrapper() void TestProcessingGui::testRasterOutWrapper() { - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterRasterDestination param( QStringLiteral( "raster" ), QStringLiteral( "raster" ) ); @@ -10195,19 +10095,19 @@ void TestProcessingGui::testRasterOutWrapper() case QgsProcessingGui::Batch: case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); wrapper.setWidgetValue( QStringLiteral( "/aa.tif" ), context ); QCOMPARE( spy.count(), 2 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/aa.tif" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/aa.tif" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/aa.tif" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/aa.tif" ) ); break; } // check signal - static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.tif" ) ); + static_cast( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.tif" ) ); QCOMPARE( spy.count(), 3 ); - QCOMPARE( wrapper.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/cc.tif" ) ); + QCOMPARE( wrapper.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/cc.tif" ) ); delete w; // optional @@ -10218,8 +10118,8 @@ void TestProcessingGui::testRasterOutWrapper() QSignalSpy spy3( &wrapper3, &QgsProcessingRasterDestinationWidgetWrapper::widgetValueHasChanged ); wrapper3.setWidgetValue( QStringLiteral( "/bb.tif" ), context ); QCOMPARE( spy3.count(), 1 ); - QCOMPARE( wrapper3.widgetValue().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper3.wrappedWidget() )->value().value< QgsProcessingOutputLayerDefinition >().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); + QCOMPARE( wrapper3.widgetValue().value().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().value().sink.staticValue().toString(), QStringLiteral( "/bb.tif" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 2 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -10251,8 +10151,7 @@ void TestProcessingGui::testRasterOutWrapper() void TestProcessingGui::testFileOutWrapper() { - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterFileDestination param( QStringLiteral( "file" ), QStringLiteral( "file" ) ); @@ -10271,16 +10170,16 @@ void TestProcessingGui::testFileOutWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "/bb.tif" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/bb.tif" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/bb.tif" ) ); wrapper.setWidgetValue( QStringLiteral( "/aa.tif" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "/aa.tif" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/aa.tif" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/aa.tif" ) ); break; } // check signal - static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.tif" ) ); + static_cast( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc.tif" ) ); QCOMPARE( spy.count(), 3 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "/cc.tif" ) ); delete w; @@ -10294,7 +10193,7 @@ void TestProcessingGui::testFileOutWrapper() wrapper3.setWidgetValue( QStringLiteral( "/bb.tif" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "/bb.tif" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper3.wrappedWidget() )->value().toString(), QStringLiteral( "/bb.tif" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toString(), QStringLiteral( "/bb.tif" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 2 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -10326,8 +10225,7 @@ void TestProcessingGui::testFileOutWrapper() void TestProcessingGui::testFolderOutWrapper() { - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterFolderDestination param( QStringLiteral( "folder" ), QStringLiteral( "folder" ) ); @@ -10346,16 +10244,16 @@ void TestProcessingGui::testFolderOutWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "/bb" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/bb" ) ); wrapper.setWidgetValue( QStringLiteral( "/aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "/aa" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->value().toString(), QStringLiteral( "/aa" ) ); break; } // check signal - static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc" ) ); + static_cast( wrapper.wrappedWidget() )->setValue( QStringLiteral( "/cc" ) ); QCOMPARE( spy.count(), 3 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "/cc" ) ); delete w; @@ -10369,7 +10267,7 @@ void TestProcessingGui::testFolderOutWrapper() wrapper3.setWidgetValue( QStringLiteral( "/bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "/bb" ) ); - QCOMPARE( static_cast< QgsProcessingLayerOutputDestinationWidget * >( wrapper3.wrappedWidget() )->value().toString(), QStringLiteral( "/bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->value().toString(), QStringLiteral( "/bb" ) ); wrapper3.setWidgetValue( QVariant(), context ); QCOMPARE( spy3.count(), 2 ); QVERIFY( !wrapper3.widgetValue().isValid() ); @@ -10401,7 +10299,7 @@ void TestProcessingGui::testFolderOutWrapper() void TestProcessingGui::testTinInputLayerWrapper() { - QgsProcessingParameterTinInputLayers definition( QStringLiteral( "TIN input layers" ) ) ; + QgsProcessingParameterTinInputLayers definition( QStringLiteral( "TIN input layers" ) ); QgsProcessingTinInputLayersWidgetWrapper wrapper; std::unique_ptr w( wrapper.createWidget() ); @@ -10412,9 +10310,7 @@ void TestProcessingGui::testTinInputLayerWrapper() QgsProcessingContext context; QgsProject project; context.setProject( &project ); - QgsVectorLayer *vectorLayer = new QgsVectorLayer( QStringLiteral( "Point" ), - QStringLiteral( "PointLayerForTin" ), - QStringLiteral( "memory" ) ); + QgsVectorLayer *vectorLayer = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "PointLayerForTin" ), QStringLiteral( "memory" ) ); project.addMapLayer( vectorLayer ); QVariantList layerList; @@ -10437,7 +10333,7 @@ void TestProcessingGui::testTinInputLayerWrapper() void TestProcessingGui::testDxfLayersWrapper() { - QgsProcessingParameterDxfLayers definition( QStringLiteral( "DXF layers" ) ) ; + QgsProcessingParameterDxfLayers definition( QStringLiteral( "DXF layers" ) ); QgsProcessingDxfLayersWidgetWrapper wrapper; std::unique_ptr w( wrapper.createWidget() ); @@ -10448,9 +10344,7 @@ void TestProcessingGui::testDxfLayersWrapper() QgsProcessingContext context; QgsProject project; context.setProject( &project ); - QgsVectorLayer *vectorLayer = new QgsVectorLayer( QStringLiteral( "Point" ), - QStringLiteral( "PointLayer" ), - QStringLiteral( "memory" ) ); + QgsVectorLayer *vectorLayer = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "PointLayer" ), QStringLiteral( "memory" ) ); project.addMapLayer( vectorLayer ); QVariantList layerList; @@ -10475,7 +10369,7 @@ void TestProcessingGui::testDxfLayersWrapper() void TestProcessingGui::testAlignRasterLayersWrapper() { - QgsProcessingParameterAlignRasterLayers definition( QStringLiteral( "Raster layers" ) ) ; + QgsProcessingParameterAlignRasterLayers definition( QStringLiteral( "Raster layers" ) ); QgsProcessingAlignRasterLayersWidgetWrapper wrapper; std::unique_ptr w( wrapper.createWidget() ); @@ -10511,11 +10405,7 @@ void TestProcessingGui::testAlignRasterLayersWrapper() void TestProcessingGui::testRasterOptionsWrapper() { QgsProcessingParameterString param( QStringLiteral( "string" ), QStringLiteral( "string" ) ); - param.setMetadata( {{ - QStringLiteral( "widget_wrapper" ), QVariantMap( - {{QStringLiteral( "widget_type" ), QStringLiteral( "rasteroptions" ) }} - ) - } + param.setMetadata( { { QStringLiteral( "widget_wrapper" ), QVariantMap( { { QStringLiteral( "widget_type" ), QStringLiteral( "rasteroptions" ) } } ) } } ); QgsProcessingContext context; @@ -10539,11 +10429,8 @@ void TestProcessingGui::testMeshDatasetWrapperLayerInProject() QgsProcessingParameterMeshLayer layerDefinition( QStringLiteral( "layer" ), QStringLiteral( "layer" ) ); QgsProcessingMeshLayerWidgetWrapper layerWrapper( &layerDefinition ); - QSet supportedDataType( {QgsMeshDatasetGroupMetadata::DataOnVertices} ); - QgsProcessingParameterMeshDatasetGroups groupsDefinition( QStringLiteral( "groups" ), - QStringLiteral( "groups" ), - QStringLiteral( "layer" ), - supportedDataType ); + QSet supportedDataType( { QgsMeshDatasetGroupMetadata::DataOnVertices } ); + QgsProcessingParameterMeshDatasetGroups groupsDefinition( QStringLiteral( "groups" ), QStringLiteral( "groups" ), QStringLiteral( "layer" ), supportedDataType ); QgsProcessingMeshDatasetGroupsWidgetWrapper groupsWrapper( &groupsDefinition ); QgsProcessingParameterMeshDatasetTime timeDefinition( QStringLiteral( "time" ), QStringLiteral( "time" ), QStringLiteral( "layer" ), QStringLiteral( "groups" ) ); @@ -10635,8 +10522,7 @@ void TestProcessingGui::testMeshDatasetWrapperLayerInProject() timeSpy.clear(); project.addMapLayer( layer ); - static_cast( layer->temporalProperties() )->setReferenceTime( - QDateTime( QDate( 2020, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), layer->dataProvider()->temporalCapabilities() ); + static_cast( layer->temporalProperties() )->setReferenceTime( QDateTime( QDate( 2020, 01, 01 ), QTime( 0, 0, 0 ), Qt::UTC ), layer->dataProvider()->temporalCapabilities() ); layerWrapper.setWidgetValue( meshLayerName, context ); QCOMPARE( layerSpy.count(), 1 ); @@ -10657,7 +10543,7 @@ void TestProcessingGui::testMeshDatasetWrapperLayerInProject() QString pythonString = groupsDefinition.valueAsPythonString( groupsValue, context ); QCOMPARE( pythonString, QStringLiteral( "[1]" ) ); QVERIFY( groupsDefinition.checkValueIsAcceptable( groupsValue ) ); - QCOMPARE( QgsProcessingParameterMeshDatasetGroups::valueAsDatasetGroup( groupsValue ), QList( {1} ) ); + QCOMPARE( QgsProcessingParameterMeshDatasetGroups::valueAsDatasetGroup( groupsValue ), QList( { 1 } ) ); // 2 datasets on vertices settings = layer->rendererSettings(); @@ -10740,10 +10626,10 @@ void TestProcessingGui::testMeshDatasetWrapperLayerInProject() groupsWrapper.setWidgetValue( 3, context ); QCOMPARE( datasetGroupWidget->value(), QVariantList() << 3 ); - groupsWrapper.setWidgetValue( QVariantList( {1, 2, 3} ), context ); - QCOMPARE( datasetGroupWidget->value().toList(), QVariantList( {1, 2, 3} ) ); - groupsWrapper.setWidgetValue( QVariantList( {"1", "2", "3"} ), context ); - QCOMPARE( datasetGroupWidget->value().toList(), QVariantList( {1, 2, 3} ) ); + groupsWrapper.setWidgetValue( QVariantList( { 1, 2, 3 } ), context ); + QCOMPARE( datasetGroupWidget->value().toList(), QVariantList( { 1, 2, 3 } ) ); + groupsWrapper.setWidgetValue( QVariantList( { "1", "2", "3" } ), context ); + QCOMPARE( datasetGroupWidget->value().toList(), QVariantList( { 1, 2, 3 } ) ); groupsWrapper.setWidgetValue( QgsProperty::fromExpression( QStringLiteral( "1+3" ) ), context ); QCOMPARE( datasetGroupWidget->value().toList(), QVariantList() << 4 ); @@ -10779,11 +10665,8 @@ void TestProcessingGui::testMeshDatasetWrapperLayerOutsideProject() QgsProcessingParameterMeshLayer layerDefinition( QStringLiteral( "layer" ), QStringLiteral( "layer" ) ); QgsProcessingMeshLayerWidgetWrapper layerWrapper( &layerDefinition ); - QSet supportedDataType( {QgsMeshDatasetGroupMetadata::DataOnFaces} ); - QgsProcessingParameterMeshDatasetGroups groupsDefinition( QStringLiteral( "groups" ), - QStringLiteral( "groups" ), - QStringLiteral( "layer" ), - supportedDataType ); + QSet supportedDataType( { QgsMeshDatasetGroupMetadata::DataOnFaces } ); + QgsProcessingParameterMeshDatasetGroups groupsDefinition( QStringLiteral( "groups" ), QStringLiteral( "groups" ), QStringLiteral( "layer" ), supportedDataType ); QgsProcessingMeshDatasetGroupsWidgetWrapper groupsWrapper( &groupsDefinition ); QgsProcessingParameterMeshDatasetTime timeDefinition( QStringLiteral( "time" ), QStringLiteral( "time" ), QStringLiteral( "layer" ), QStringLiteral( "groups" ) ); @@ -10866,13 +10749,11 @@ void TestProcessingGui::testMeshDatasetWrapperLayerOutsideProject() datasetTimeWidget->radioButtonDefinedDateTime->setChecked( true ); QCOMPARE( QgsProcessingParameterMeshDatasetTime::valueAsTimeType( timeWrapper.widgetValue() ), QStringLiteral( "defined-date-time" ) ); - QCOMPARE( QgsProcessingParameterMeshDatasetTime::timeValueAsDefinedDateTime( timeWrapper.widgetValue() ), - QDateTime( QDate( 1990, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( QgsProcessingParameterMeshDatasetTime::timeValueAsDefinedDateTime( timeWrapper.widgetValue() ), QDateTime( QDate( 1990, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); mapCanvas->setTemporalRange( QgsDateTimeRange( QDateTime( QDate( 2021, 1, 1 ), QTime( 0, 3, 0 ), Qt::UTC ), QDateTime( QDate( 2020, 1, 1 ), QTime( 0, 5, 0 ), Qt::UTC ) ) ); QVERIFY( datasetTimeWidget->radioButtonCurrentCanvasTime->isEnabled() ); - } void TestProcessingGui::testPointCloudLayerWrapper() @@ -10886,8 +10767,7 @@ void TestProcessingGui::testPointCloudLayerWrapper() QVERIFY( cloud2->isValid() ); QgsProject::instance()->addMapLayer( cloud2 ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterPointCloudLayer param( QStringLiteral( "cloud" ), QStringLiteral( "cloud" ), false ); @@ -10906,11 +10786,11 @@ void TestProcessingGui::testPointCloudLayerWrapper() case QgsProcessingGui::Modeler: QCOMPARE( spy.count(), 1 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper.setWidgetValue( QStringLiteral( "aa" ), context ); QCOMPARE( spy.count(), 2 ); QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "aa" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentText(), QStringLiteral( "aa" ) ); break; } @@ -10929,7 +10809,7 @@ void TestProcessingGui::testPointCloudLayerWrapper() wrapper2.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper2.setWidgetValue( QStringLiteral( "cloud2" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), cloud2->id() ); @@ -10937,31 +10817,31 @@ void TestProcessingGui::testPointCloudLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud2 [EPSG:28356]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud2 [EPSG:28356]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud2" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "cloud2" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "cloud2" ) ); // check signal - static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->setLayer( cloud1 ); + static_cast( wrapper2.wrappedWidget() )->setLayer( cloud1 ); QCOMPARE( spy2.count(), 3 ); QCOMPARE( wrapper2.widgetValue().toString(), cloud1->id() ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud1 [EPSG:28356]" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud1 [EPSG:28356]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "cloud1" ) ); break; } - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "cloud1" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "cloud1" ) ); delete w; @@ -10975,7 +10855,7 @@ void TestProcessingGui::testPointCloudLayerWrapper() wrapper3.setWidgetValue( QStringLiteral( "bb" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "bb" ) ); - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "bb" ) ); wrapper3.setWidgetValue( QStringLiteral( "cloud2" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), cloud2->id() ); @@ -10983,10 +10863,10 @@ void TestProcessingGui::testPointCloudLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "cloud2 [EPSG:28356]" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "cloud2 [EPSG:28356]" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QgsProcessingMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "cloud2" ) ); + QCOMPARE( static_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "cloud2" ) ); break; } wrapper3.setWidgetValue( QVariant(), context ); @@ -11026,8 +10906,7 @@ void TestProcessingGui::testAnnotationLayerWrapper() QVERIFY( layer1->isValid() ); QgsProject::instance()->addMapLayer( layer1 ); - auto testWrapper = [ = ]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [=]( QgsProcessingGui::WidgetType type ) { // non optional QgsProcessingParameterAnnotationLayer param( QStringLiteral( "annotation" ), QStringLiteral( "annotation" ), false ); @@ -11048,7 +10927,7 @@ void TestProcessingGui::testAnnotationLayerWrapper() wrapper2.setWidgetValue( QStringLiteral( "main" ), context ); QCOMPARE( spy2.count(), 1 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "main" ) ); - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); wrapper2.setWidgetValue( QStringLiteral( "secondary annotations" ), context ); QCOMPARE( spy2.count(), 2 ); QCOMPARE( wrapper2.widgetValue().toString(), layer1->id() ); @@ -11056,31 +10935,31 @@ void TestProcessingGui::testAnnotationLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); break; } - QCOMPARE( static_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "secondary annotations" ) ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "secondary annotations" ) ); // check signal - static_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->setLayer( QgsProject::instance()->mainAnnotationLayer() ); + static_cast( wrapper2.wrappedWidget() )->setLayer( QgsProject::instance()->mainAnnotationLayer() ); QCOMPARE( spy2.count(), 3 ); QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "main" ) ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper2.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); break; } - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "Annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper2.wrappedWidget() )->currentLayer()->name(), QStringLiteral( "Annotations" ) ); delete w; @@ -11094,7 +10973,7 @@ void TestProcessingGui::testAnnotationLayerWrapper() wrapper3.setWidgetValue( QStringLiteral( "main" ), context ); QCOMPARE( spy3.count(), 1 ); QCOMPARE( wrapper3.widgetValue().toString(), QStringLiteral( "main" ) ); - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "Annotations" ) ); wrapper3.setWidgetValue( QStringLiteral( "secondary annotations" ), context ); QCOMPARE( spy3.count(), 2 ); QCOMPARE( wrapper3.widgetValue().toString(), layer1->id() ); @@ -11102,10 +10981,10 @@ void TestProcessingGui::testAnnotationLayerWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( qgis::down_cast< QgsMapLayerComboBox * >( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); + QCOMPARE( qgis::down_cast( wrapper3.wrappedWidget() )->currentText(), QStringLiteral( "secondary annotations" ) ); break; } wrapper3.setWidgetValue( QVariant(), context ); @@ -11141,8 +11020,7 @@ void TestProcessingGui::testPointCloudAttributeWrapper() { const QgsProcessingParameterDefinition *layerDef = new QgsProcessingParameterPointCloudLayer( "INPUT", QStringLiteral( "input" ), QVariant(), false ); - auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) - { + auto testWrapper = [layerDef]( QgsProcessingGui::WidgetType type ) { TestLayerWrapper layerWrapper( layerDef ); QgsProject p; QgsPointCloudLayer *pcl = new QgsPointCloudLayer( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/copc/rgb.copc.laz", QStringLiteral( "x" ), QStringLiteral( "copc" ) ); @@ -11155,24 +11033,24 @@ void TestProcessingGui::testPointCloudAttributeWrapper() QgsProcessingContext context; QWidget *w = wrapper.createWrappedWidget( context ); - ( void )w; + ( void ) w; layerWrapper.setWidgetValue( QVariant::fromValue( pcl ), context ); wrapper.setParentLayerWrapperValue( &layerWrapper ); QSignalSpy spy( &wrapper, &QgsProcessingPointCloudAttributeWidgetWrapper::widgetValueHasChanged ); wrapper.setWidgetValue( QStringLiteral( "Red" ), context ); QCOMPARE( spy.count(), 1 ); - QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "Red" ) ); + QCOMPARE( wrapper.widgetValue().toString(), QStringLiteral( "Red" ) ); switch ( type ) { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsPointCloudAttributeComboBox * >( wrapper.wrappedWidget() )->currentAttribute(), QStringLiteral( "Red" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->currentAttribute(), QStringLiteral( "Red" ) ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QLineEdit * >( wrapper.wrappedWidget() )->text(), QStringLiteral( "Red" ) ); + QCOMPARE( static_cast( wrapper.wrappedWidget() )->text(), QStringLiteral( "Red" ) ); break; } @@ -11193,7 +11071,7 @@ void TestProcessingGui::testPointCloudAttributeWrapper() QSignalSpy spy2( &wrapper2, &QgsProcessingPointCloudAttributeWidgetWrapper::widgetValueHasChanged ); wrapper2.setWidgetValue( QStringLiteral( "Intensity" ), context ); QCOMPARE( spy2.count(), 1 ); - QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "Intensity" ) ); + QCOMPARE( wrapper2.widgetValue().toString(), QStringLiteral( "Intensity" ) ); wrapper2.setWidgetValue( QString(), context ); QCOMPARE( spy2.count(), 2 ); @@ -11203,11 +11081,11 @@ void TestProcessingGui::testPointCloudAttributeWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( static_cast< QgsPointCloudAttributeComboBox * >( wrapper2.wrappedWidget() )->currentAttribute(), QString() ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->currentAttribute(), QString() ); break; case QgsProcessingGui::Modeler: - QCOMPARE( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text(), QString() ); + QCOMPARE( static_cast( wrapper2.wrappedWidget() )->text(), QString() ); break; } @@ -11229,11 +11107,11 @@ void TestProcessingGui::testPointCloudAttributeWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - static_cast< QgsPointCloudAttributeComboBox * >( wrapper2.wrappedWidget() )->setAttribute( QStringLiteral( "Red" ) ); + static_cast( wrapper2.wrappedWidget() )->setAttribute( QStringLiteral( "Red" ) ); break; case QgsProcessingGui::Modeler: - static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->setText( QStringLiteral( "Red" ) ); + static_cast( wrapper2.wrappedWidget() )->setText( QStringLiteral( "Red" ) ); break; } @@ -11352,28 +11230,7 @@ void TestProcessingGui::testPointCloudAttributeWrapper() { case QgsProcessingGui::Standard: case QgsProcessingGui::Batch: - QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() - << QStringLiteral( "X" ) - << QStringLiteral( "Y" ) - << QStringLiteral( "Z" ) - << QStringLiteral( "Intensity" ) - << QStringLiteral( "ReturnNumber" ) - << QStringLiteral( "NumberOfReturns" ) - << QStringLiteral( "ScanDirectionFlag" ) - << QStringLiteral( "EdgeOfFlightLine" ) - << QStringLiteral( "Classification" ) - << QStringLiteral( "ScanAngleRank" ) - << QStringLiteral( "UserData" ) - << QStringLiteral( "PointSourceId" ) - << QStringLiteral( "Synthetic" ) - << QStringLiteral( "KeyPoint" ) - << QStringLiteral( "Withheld" ) - << QStringLiteral( "Overlap" ) - << QStringLiteral( "ScannerChannel" ) - << QStringLiteral( "GpsTime" ) - << QStringLiteral( "Red" ) - << QStringLiteral( "Green" ) - << QStringLiteral( "Blue" ) ); + QCOMPARE( wrapper4.widgetValue().toList(), QVariantList() << QStringLiteral( "X" ) << QStringLiteral( "Y" ) << QStringLiteral( "Z" ) << QStringLiteral( "Intensity" ) << QStringLiteral( "ReturnNumber" ) << QStringLiteral( "NumberOfReturns" ) << QStringLiteral( "ScanDirectionFlag" ) << QStringLiteral( "EdgeOfFlightLine" ) << QStringLiteral( "Classification" ) << QStringLiteral( "ScanAngleRank" ) << QStringLiteral( "UserData" ) << QStringLiteral( "PointSourceId" ) << QStringLiteral( "Synthetic" ) << QStringLiteral( "KeyPoint" ) << QStringLiteral( "Withheld" ) << QStringLiteral( "Overlap" ) << QStringLiteral( "ScannerChannel" ) << QStringLiteral( "GpsTime" ) << QStringLiteral( "Red" ) << QStringLiteral( "Green" ) << QStringLiteral( "Blue" ) ); break; case QgsProcessingGui::Modeler: @@ -11394,8 +11251,8 @@ void TestProcessingGui::testPointCloudAttributeWrapper() // config widget QgsProcessingParameterWidgetContext widgetContext; QgsProcessingContext context; - std::unique_ptr< QgsProcessingParameterDefinitionWidget > widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "attribute" ), context, widgetContext ); - std::unique_ptr< QgsProcessingParameterDefinition > def( widget->createParameter( QStringLiteral( "param_name" ) ) ); + std::unique_ptr widget = std::make_unique( QStringLiteral( "attribute" ), context, widgetContext ); + std::unique_ptr def( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QVERIFY( !def->defaultValue().isValid() ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); // should default to mandatory @@ -11403,31 +11260,31 @@ void TestProcessingGui::testPointCloudAttributeWrapper() // using a parameter definition as initial values QgsProcessingParameterPointCloudAttribute attrParam( QStringLiteral( "n" ), QStringLiteral( "test desc" ), QStringLiteral( "attribute_name" ), QStringLiteral( "parent" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "attribute" ), context, widgetContext, &attrParam ); + widget = std::make_unique( QStringLiteral( "attribute" ), context, widgetContext, &attrParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Optional ) ); QVERIFY( !( def->flags() & Qgis::ProcessingParameterFlag::Advanced ) ); - QCOMPARE( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->defaultValue().toString(), QStringLiteral( "attribute_name" ) ); - QCOMPARE( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); - QCOMPARE( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->allowMultiple(), false ); - QCOMPARE( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->defaultToAllAttributes(), false ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "attribute_name" ) ); + QCOMPARE( static_cast( def.get() )->parentLayerParameterName(), QStringLiteral( "parent" ) ); + QCOMPARE( static_cast( def.get() )->allowMultiple(), false ); + QCOMPARE( static_cast( def.get() )->defaultToAllAttributes(), false ); attrParam.setFlags( Qgis::ProcessingParameterFlag::Advanced | Qgis::ProcessingParameterFlag::Optional ); attrParam.setParentLayerParameterName( QString() ); attrParam.setAllowMultiple( true ); attrParam.setDefaultToAllAttributes( true ); attrParam.setDefaultValue( QStringLiteral( "Intensity;Red" ) ); - widget = std::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "attribute" ), context, widgetContext, &attrParam ); + widget = std::make_unique( QStringLiteral( "attribute" ), context, widgetContext, &attrParam ); def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) ); QCOMPARE( def->name(), QStringLiteral( "param_name" ) ); QCOMPARE( def->description(), QStringLiteral( "test desc" ) ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Optional ); QVERIFY( def->flags() & Qgis::ProcessingParameterFlag::Advanced ); - QCOMPARE( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->defaultValue().toString(), QStringLiteral( "Intensity;Red" ) ); - QVERIFY( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->parentLayerParameterName().isEmpty() ); - QCOMPARE( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->allowMultiple(), true ); - QCOMPARE( static_cast< QgsProcessingParameterPointCloudAttribute * >( def.get() )->defaultToAllAttributes(), true ); + QCOMPARE( static_cast( def.get() )->defaultValue().toString(), QStringLiteral( "Intensity;Red" ) ); + QVERIFY( static_cast( def.get() )->parentLayerParameterName().isEmpty() ); + QCOMPARE( static_cast( def.get() )->allowMultiple(), true ); + QCOMPARE( static_cast( def.get() )->defaultToAllAttributes(), true ); } void TestProcessingGui::testModelGraphicsView() @@ -11444,7 +11301,7 @@ void TestProcessingGui::testModelGraphicsView() param.setPosition( QPointF( 101, 102 ) ); param.comment()->setDescription( QStringLiteral( "input comment" ) ); model1.addModelParameter( new QgsProcessingParameterMapLayer( QStringLiteral( "LAYER" ) ), param ); - algc1.addParameterSources( QStringLiteral( "INPUT" ), QList< QgsProcessingModelChildParameterSource >() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "LAYER" ) ) ); + algc1.addParameterSources( QStringLiteral( "INPUT" ), QList() << QgsProcessingModelChildParameterSource::fromModelParameter( QStringLiteral( "LAYER" ) ) ); algc1.comment()->setDescription( QStringLiteral( "alg comment" ) ); algc1.comment()->setSize( QSizeF( 300, 200 ) ); algc1.comment()->setPosition( QPointF( 201, 202 ) ); @@ -11453,7 +11310,7 @@ void TestProcessingGui::testModelGraphicsView() modelOut.setChildId( algc1.childId() ); modelOut.setChildOutputName( QStringLiteral( "my_output" ) ); modelOut.comment()->setDescription( QStringLiteral( "output comm" ) ); - QMap< QString, QgsProcessingModelOutput > outs; + QMap outs; outs.insert( QStringLiteral( "OUTPUT" ), modelOut ); algc1.setModelOutputs( outs ); model1.addChildAlgorithm( algc1 ); @@ -11468,11 +11325,11 @@ void TestProcessingGui::testModelGraphicsView() scene2.setModel( &model1 ); scene2.setFlags( QgsModelGraphicsScene::FlagHideComments ); scene2.createItems( &model1, context ); - QList< QGraphicsItem * > items = scene2.items(); + QList items = scene2.items(); QgsModelParameterGraphicItem *layerItem = nullptr; for ( QGraphicsItem *item : items ) { - if ( QgsModelParameterGraphicItem *param = dynamic_cast< QgsModelParameterGraphicItem * >( item ) ) + if ( QgsModelParameterGraphicItem *param = dynamic_cast( item ) ) { layerItem = param; break; @@ -11482,7 +11339,7 @@ void TestProcessingGui::testModelGraphicsView() QgsModelCommentGraphicItem *layerCommentItem = nullptr; for ( QGraphicsItem *item : items ) { - if ( QgsModelCommentGraphicItem *comment = dynamic_cast< QgsModelCommentGraphicItem * >( item ) ) + if ( QgsModelCommentGraphicItem *comment = dynamic_cast( item ) ) { layerCommentItem = comment; break; @@ -11503,40 +11360,39 @@ void TestProcessingGui::testModelGraphicsView() layerItem = nullptr; for ( QGraphicsItem *item : items ) { - if ( QgsModelParameterGraphicItem *param = dynamic_cast< QgsModelParameterGraphicItem * >( item ) ) + if ( QgsModelParameterGraphicItem *param = dynamic_cast( item ) ) { layerItem = param; - } } QVERIFY( layerItem ); - QCOMPARE( dynamic_cast< QgsProcessingModelParameter * >( layerItem->component() )->parameterName(), QStringLiteral( "LAYER" ) ); + QCOMPARE( dynamic_cast( layerItem->component() )->parameterName(), QStringLiteral( "LAYER" ) ); QCOMPARE( layerItem->itemRect().size(), QSizeF( 500, 400 ) ); QCOMPARE( layerItem->scenePos(), QPointF( 101, 102 ) ); QgsModelChildAlgorithmGraphicItem *algItem = nullptr; for ( QGraphicsItem *item : items ) { - if ( QgsModelChildAlgorithmGraphicItem *param = dynamic_cast< QgsModelChildAlgorithmGraphicItem * >( item ) ) + if ( QgsModelChildAlgorithmGraphicItem *param = dynamic_cast( item ) ) { algItem = param; break; } } QVERIFY( algItem ); - QCOMPARE( dynamic_cast< QgsProcessingModelChildAlgorithm * >( algItem->component() )->algorithmId(), QStringLiteral( "native:buffer" ) ); + QCOMPARE( dynamic_cast( algItem->component() )->algorithmId(), QStringLiteral( "native:buffer" ) ); QgsModelOutputGraphicItem *outputItem = nullptr; for ( QGraphicsItem *item : items ) { - if ( QgsModelOutputGraphicItem *comment = dynamic_cast< QgsModelOutputGraphicItem * >( item ) ) + if ( QgsModelOutputGraphicItem *comment = dynamic_cast( item ) ) { outputItem = comment; break; } } QVERIFY( outputItem ); - QCOMPARE( dynamic_cast< QgsProcessingModelOutput * >( outputItem->component() )->childOutputName(), QStringLiteral( "my_output" ) ); + QCOMPARE( dynamic_cast( outputItem->component() )->childOutputName(), QStringLiteral( "my_output" ) ); layerCommentItem = nullptr; @@ -11544,7 +11400,7 @@ void TestProcessingGui::testModelGraphicsView() QgsModelCommentGraphicItem *outputCommentItem = nullptr; for ( QGraphicsItem *item : items ) { - if ( QgsModelCommentGraphicItem *comment = dynamic_cast< QgsModelCommentGraphicItem * >( item ) ) + if ( QgsModelCommentGraphicItem *comment = dynamic_cast( item ) ) { if ( comment->parentComponentItem() == layerItem ) { @@ -11575,21 +11431,21 @@ void TestProcessingGui::testModelGraphicsView() QgsModelGroupBoxGraphicItem *groupItem = nullptr; for ( QGraphicsItem *item : items ) { - if ( QgsModelGroupBoxGraphicItem *comment = dynamic_cast< QgsModelGroupBoxGraphicItem * >( item ) ) + if ( QgsModelGroupBoxGraphicItem *comment = dynamic_cast( item ) ) { groupItem = comment; break; } } QVERIFY( groupItem ); - QCOMPARE( dynamic_cast< QgsProcessingModelGroupBox * >( groupItem->component() )->description(), QStringLiteral( "group" ) ); + QCOMPARE( dynamic_cast( groupItem->component() )->description(), QStringLiteral( "group" ) ); QgsModelGraphicsView view; view.setModelScene( &scene ); // copy some items - view.copyItems( QList< QgsModelComponentGraphicItem * >() << layerItem << algItem << groupItem, QgsModelGraphicsView::ClipboardCopy ); + view.copyItems( QList() << layerItem << algItem << groupItem, QgsModelGraphicsView::ClipboardCopy ); // second view to paste into @@ -11618,7 +11474,7 @@ void TestProcessingGui::testModelGraphicsView() QCOMPARE( algDest.groupBoxes().at( 0 ).description(), QStringLiteral( "group" ) ); // copy comments and output (not output comment though!) - view.copyItems( QList< QgsModelComponentGraphicItem * >() << layerItem << layerCommentItem << algItem << algCommentItem << outputItem << groupItem, QgsModelGraphicsView::ClipboardCopy ); + view.copyItems( QList() << layerItem << layerCommentItem << algItem << algCommentItem << outputItem << groupItem, QgsModelGraphicsView::ClipboardCopy ); viewDest.pasteItems( QgsModelGraphicsView::PasteModeInPlace ); QCOMPARE( algDest.parameterComponents().size(), 2 ); @@ -11640,7 +11496,7 @@ void TestProcessingGui::testModelGraphicsView() QCOMPARE( algDest.groupBoxes().at( 1 ).description(), QStringLiteral( "group" ) ); // output and output comment - view.copyItems( QList< QgsModelComponentGraphicItem * >() << algItem << outputItem << outputCommentItem, QgsModelGraphicsView::ClipboardCopy ); + view.copyItems( QList() << algItem << outputItem << outputCommentItem, QgsModelGraphicsView::ClipboardCopy ); viewDest.pasteItems( QgsModelGraphicsView::PasteModeInPlace ); QCOMPARE( algDest.childAlgorithms().size(), 3 ); QCOMPARE( algDest.childAlgorithms().value( QStringLiteral( "native:buffer_2" ) ).modelOutputs().size(), 1 ); diff --git a/tests/src/gui/testprojectionissues.cpp b/tests/src/gui/testprojectionissues.cpp index b67239aded95..62aa1937e60d 100644 --- a/tests/src/gui/testprojectionissues.cpp +++ b/tests/src/gui/testprojectionissues.cpp @@ -31,15 +31,15 @@ class TestProjectionIssues : public QObject TestProjectionIssues() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. - void issue5895();// test for #5895 + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. + void issue5895(); // test for #5895 private: QgsRasterLayer *mRasterLayer = nullptr; - QgsMapCanvas *mMapCanvas = nullptr; + QgsMapCanvas *mMapCanvas = nullptr; }; void TestProjectionIssues::initTestCase() @@ -48,9 +48,8 @@ void TestProjectionIssues::initTestCase() QgsApplication::initQgis(); //create maplayer from testdata and add to layer registry - const QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + '/' + "checker360by180.asc" ); - mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), - rasterFileInfo.completeBaseName() ); + const QFileInfo rasterFileInfo( QStringLiteral( TEST_DATA_DIR ) + '/' + "checker360by180.asc" ); + mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); // Set to WGS84 const QgsCoordinateReferenceSystem sourceCRS( QStringLiteral( "EPSG:4326" ) ); mRasterLayer->setCrs( sourceCRS, false ); @@ -76,7 +75,6 @@ void TestProjectionIssues::initTestCase() //reproject to SWEDREF 99 TM const QgsCoordinateReferenceSystem destCRS( QStringLiteral( "EPSG:3006" ) ); mMapCanvas->setDestinationCrs( destCRS ); - } void TestProjectionIssues::cleanupTestCase() @@ -88,12 +86,10 @@ void TestProjectionIssues::cleanupTestCase() void TestProjectionIssues::init() { - } void TestProjectionIssues::cleanup() { - } void TestProjectionIssues::issue5895() diff --git a/tests/src/gui/testqgsadvanceddigitizingdockwidget.cpp b/tests/src/gui/testqgsadvanceddigitizingdockwidget.cpp index a338453c2473..58ad13173e8f 100644 --- a/tests/src/gui/testqgsadvanceddigitizingdockwidget.cpp +++ b/tests/src/gui/testqgsadvanceddigitizingdockwidget.cpp @@ -27,13 +27,12 @@ class TestQgsAdvancedDigitizingDockWidget : public QObject TestQgsAdvancedDigitizingDockWidget() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void parseUserInput(); - }; void TestQgsAdvancedDigitizingDockWidget::initTestCase() @@ -60,7 +59,7 @@ void TestQgsAdvancedDigitizingDockWidget::parseUserInput() { QgsProject::instance()->clear(); QgsMapCanvas canvas; - QgsAdvancedDigitizingDockWidget widget{ &canvas }; + QgsAdvancedDigitizingDockWidget widget { &canvas }; bool ok; double result; @@ -127,7 +126,7 @@ void TestQgsAdvancedDigitizingDockWidget::parseUserInput() QVERIFY( ok ); result = widget.parseUserInput( QStringLiteral( "120.123NM" ), Qgis::CadConstraintType::Distance, ok ); - QCOMPARE( result, 120.123 ); + QCOMPARE( result, 120.123 ); QVERIFY( ok ); // Set a CRS using feet as units @@ -136,8 +135,6 @@ void TestQgsAdvancedDigitizingDockWidget::parseUserInput() result = widget.parseUserInput( QStringLiteral( "100" ), Qgis::CadConstraintType::Distance, ok ); QCOMPARE( result, 100.0 * QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Meters, Qgis::DistanceUnit::FeetUSSurvey ) ); QVERIFY( ok ); - - } QGSTEST_MAIN( TestQgsAdvancedDigitizingDockWidget ) diff --git a/tests/src/gui/testqgsadvanceddigitizingtoolsregistry.cpp b/tests/src/gui/testqgsadvanceddigitizingtoolsregistry.cpp index b04222632049..6f1b363f686e 100644 --- a/tests/src/gui/testqgsadvanceddigitizingtoolsregistry.cpp +++ b/tests/src/gui/testqgsadvanceddigitizingtoolsregistry.cpp @@ -18,18 +18,17 @@ #include "qgsadvanceddigitizingtoolsregistry.h" #include -class TestQgsAdvancedDigitizingToolsRegistry: public QObject +class TestQgsAdvancedDigitizingToolsRegistry : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void guiRegistry(); private: - }; void TestQgsAdvancedDigitizingToolsRegistry::initTestCase() @@ -66,8 +65,7 @@ void TestQgsAdvancedDigitizingToolsRegistry::guiRegistry() QVERIFY( !registry.toolMetadata( QString( "empty" ) ) ); QVERIFY( registry.toolMetadataNames().isEmpty() ); - auto createTool = []( QgsMapCanvas *, QgsAdvancedDigitizingDockWidget * )->QgsAdvancedDigitizingTool * - { + auto createTool = []( QgsMapCanvas *, QgsAdvancedDigitizingDockWidget * ) -> QgsAdvancedDigitizingTool * { return new DummyAdvancedDigitizingTool(); }; diff --git a/tests/src/gui/testqgsannotationitemguiregistry.cpp b/tests/src/gui/testqgsannotationitemguiregistry.cpp index 5487e8beed3b..3e8ec925fe67 100644 --- a/tests/src/gui/testqgsannotationitemguiregistry.cpp +++ b/tests/src/gui/testqgsannotationitemguiregistry.cpp @@ -21,23 +21,21 @@ #include "qgsannotationitemregistry.h" #include -class TestQgsAnnotationItemGuiRegistry: public QObject +class TestQgsAnnotationItemGuiRegistry : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void guiRegistry(); private: - }; void TestQgsAnnotationItemGuiRegistry::initTestCase() { - } void TestQgsAnnotationItemGuiRegistry::cleanupTestCase() @@ -56,32 +54,30 @@ void TestQgsAnnotationItemGuiRegistry::cleanup() class TestItem : public QgsAnnotationItem // clazy:exclude=missing-qobject-macro { public: - - TestItem() : QgsAnnotationItem() {} + TestItem() + : QgsAnnotationItem() {} int mFlag = 0; //implement pure virtual methods QString type() const override { return QStringLiteral( "mytype" ); } TestItem *clone() const override { return new TestItem(); } - QgsRectangle boundingBox() const override { return QgsRectangle();} + QgsRectangle boundingBox() const override { return QgsRectangle(); } void render( QgsRenderContext &, QgsFeedback * ) override {} bool writeXml( QDomElement &, QDomDocument &, const QgsReadWriteContext & ) const override { return true; } bool readXml( const QDomElement &, const QgsReadWriteContext & ) override { return true; } }; -class TestItemWidget: public QgsAnnotationItemBaseWidget +class TestItemWidget : public QgsAnnotationItemBaseWidget { Q_OBJECT public: - TestItemWidget( QWidget *parent ) : QgsAnnotationItemBaseWidget( parent ) {} QgsAnnotationItem *createItem() override { return nullptr; } void updateItem( QgsAnnotationItem * ) override {} - }; void TestQgsAnnotationItemGuiRegistry::guiRegistry() @@ -95,14 +91,13 @@ void TestQgsAnnotationItemGuiRegistry::guiRegistry() QCOMPARE( registry.metadataIdForItemType( QString() ), -1 ); QVERIFY( !registry.createItemWidget( nullptr ) ); QVERIFY( !registry.createItemWidget( nullptr ) ); - const std::unique_ptr< TestItem > testItem = std::make_unique< TestItem >(); + const std::unique_ptr testItem = std::make_unique(); QVERIFY( !registry.createItemWidget( testItem.get() ) ); // not in registry const QSignalSpy spyTypeAdded( ®istry, &QgsAnnotationItemGuiRegistry::typeAdded ); // add a dummy item to registry - auto createWidget = []( QgsAnnotationItem * )->QgsAnnotationItemBaseWidget * - { + auto createWidget = []( QgsAnnotationItem * ) -> QgsAnnotationItemBaseWidget * { return new TestItemWidget( nullptr ); }; @@ -138,21 +133,19 @@ void TestQgsAnnotationItemGuiRegistry::guiRegistry() //creating item QgsAnnotationItem *item = registry.createItem( uuid ); QVERIFY( !item ); - QgsApplication::annotationItemRegistry()->addItemType( new QgsAnnotationItemMetadata( QStringLiteral( "mytype" ), QStringLiteral( "My Type" ), QStringLiteral( "My Types" ), []( )->QgsAnnotationItem* - { + QgsApplication::annotationItemRegistry()->addItemType( new QgsAnnotationItemMetadata( QStringLiteral( "mytype" ), QStringLiteral( "My Type" ), QStringLiteral( "My Types" ), []() -> QgsAnnotationItem * { return new TestItem(); } ) ); item = registry.createItem( uuid ); QVERIFY( item ); QCOMPARE( item->type(), QStringLiteral( "mytype" ) ); - QCOMPARE( static_cast< TestItem * >( item )->mFlag, 0 ); + QCOMPARE( static_cast( item )->mFlag, 0 ); delete item; // override create func metadata = new QgsAnnotationItemGuiMetadata( QStringLiteral( "mytype" ), QStringLiteral( "mytype" ), QIcon(), createWidget ); - metadata->setItemCreationFunction( []()->QgsAnnotationItem* - { + metadata->setItemCreationFunction( []() -> QgsAnnotationItem * { TestItem *item = new TestItem(); item->mFlag = 2; return item; @@ -162,7 +155,7 @@ void TestQgsAnnotationItemGuiRegistry::guiRegistry() item = registry.createItem( uuid ); QVERIFY( item ); QCOMPARE( item->type(), QStringLiteral( "mytype" ) ); - QCOMPARE( static_cast< TestItem * >( item )->mFlag, 2 ); + QCOMPARE( static_cast( item )->mFlag, 2 ); delete item; } diff --git a/tests/src/gui/testqgsattributeform.cpp b/tests/src/gui/testqgsattributeform.cpp index 83734ead98f4..cfb4aeccc475 100644 --- a/tests/src/gui/testqgsattributeform.cpp +++ b/tests/src/gui/testqgsattributeform.cpp @@ -42,10 +42,10 @@ class TestQgsAttributeForm : public QObject TestQgsAttributeForm() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testFieldConstraint(); void testFieldMultiConstraints(); @@ -731,9 +731,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() form.setFeature( ft0A ); // count features - QCOMPARE( ( int )layerA->featureCount(), 1 ); - QCOMPARE( ( int )layerB->featureCount(), 1 ); - QCOMPARE( ( int )layerC->featureCount(), 1 ); + QCOMPARE( ( int ) layerA->featureCount(), 1 ); + QCOMPARE( ( int ) layerB->featureCount(), 1 ); + QCOMPARE( ( int ) layerC->featureCount(), 1 ); // add a new feature with null joined fields. Joined feature should not be // added @@ -748,9 +748,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() layerC->commitChanges(); // count features - QCOMPARE( ( int )layerA->featureCount(), 2 ); - QCOMPARE( ( int )layerB->featureCount(), 1 ); - QCOMPARE( ( int )layerC->featureCount(), 1 ); + QCOMPARE( ( int ) layerA->featureCount(), 2 ); + QCOMPARE( ( int ) layerB->featureCount(), 1 ); + QCOMPARE( ( int ) layerC->featureCount(), 1 ); // start editing layers layerA->startEditing(); @@ -774,9 +774,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() layerC->commitChanges(); // count features - QCOMPARE( ( int )layerA->featureCount(), 3 ); - QCOMPARE( ( int )layerB->featureCount(), 2 ); - QCOMPARE( ( int )layerC->featureCount(), 1 ); + QCOMPARE( ( int ) layerA->featureCount(), 3 ); + QCOMPARE( ( int ) layerB->featureCount(), 2 ); + QCOMPARE( ( int ) layerC->featureCount(), 1 ); // check joined feature value filter = QgsExpression::createFieldEqualityExpression( QStringLiteral( "id_a" ), 34 ); @@ -808,9 +808,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() layerC->commitChanges(); // count features - QCOMPARE( ( int )layerA->featureCount(), 4 ); - QCOMPARE( ( int )layerB->featureCount(), 2 ); - QCOMPARE( ( int )layerC->featureCount(), 1 ); + QCOMPARE( ( int ) layerA->featureCount(), 4 ); + QCOMPARE( ( int ) layerB->featureCount(), 2 ); + QCOMPARE( ( int ) layerC->featureCount(), 1 ); // check joined feature value filter = QgsExpression::createFieldEqualityExpression( QStringLiteral( "id_a" ), 33 ); @@ -842,9 +842,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() layerC->commitChanges(); // count features - QCOMPARE( ( int )layerA->featureCount(), 4 ); - QCOMPARE( ( int )layerB->featureCount(), 2 ); - QCOMPARE( ( int )layerC->featureCount(), 1 ); + QCOMPARE( ( int ) layerA->featureCount(), 4 ); + QCOMPARE( ( int ) layerB->featureCount(), 2 ); + QCOMPARE( ( int ) layerC->featureCount(), 1 ); // start editing layers layerA->startEditing(); @@ -867,9 +867,9 @@ void TestQgsAttributeForm::testUpsertOnEdit() layerC->commitChanges(); // count features - QCOMPARE( ( int )layerA->featureCount(), 4 ); - QCOMPARE( ( int )layerB->featureCount(), 3 ); - QCOMPARE( ( int )layerC->featureCount(), 1 ); + QCOMPARE( ( int ) layerA->featureCount(), 4 ); + QCOMPARE( ( int ) layerB->featureCount(), 3 ); + QCOMPARE( ( int ) layerC->featureCount(), 1 ); // check joined feature value filter = QgsExpression::createFieldEqualityExpression( QStringLiteral( "id_a" ), 31 ); @@ -916,7 +916,7 @@ void TestQgsAttributeForm::testFixAttributeForm() // now save the feature and enjoy its new value, but don't update the layer QVERIFY( form.save() ); QCOMPARE( form.feature().attribute( QStringLiteral( "col1" ) ), QVariant( 630 ) ); - QCOMPARE( ( int )layer->featureCount(), 0 ); + QCOMPARE( ( int ) layer->featureCount(), 0 ); delete layer; } @@ -957,10 +957,7 @@ void TestQgsAttributeForm::testAttributeFormInterface() form.addInterface( new MyInterface( &form ) ); bool set = false; - connect( &form, &QgsAttributeForm::widgetValueChanged, this, - [&set]( const QString & attribute, const QVariant & newValue, bool attributeChanged ) - { - + connect( &form, &QgsAttributeForm::widgetValueChanged, this, [&set]( const QString &attribute, const QVariant &newValue, bool attributeChanged ) { // Check that our value set by the QgsAttributeFormInterface has correct parameters. // attributeChanged has to be true because it won't be taken into account by others // (QgsValueRelationWidgetWrapper for instance) @@ -1210,7 +1207,7 @@ void TestQgsAttributeForm::testMinimumWidth() ft.setAttribute( QStringLiteral( "col0" ), 0.0 ); QgsAttributeEditorContext context; context.setAttributeFormMode( QgsAttributeEditorContext::SingleEditMode ); - std::unique_ptr< QgsAttributeForm > form = std::make_unique< QgsAttributeForm >( &layer, QgsFeature(), context ); + std::unique_ptr form = std::make_unique( &layer, QgsFeature(), context ); form->setFeature( ft ); form->show(); // we don't want the larger width requirement of the search wrappers to be enforced when the attribute form @@ -1223,26 +1220,25 @@ void TestQgsAttributeForm::testMinimumWidth() QGSVERIFYLESSTHAN( form->minimumWidth(), leMetrics.horizontalAdvance( 'x' ) * 150 ); context.setAttributeFormMode( QgsAttributeEditorContext::AddFeatureMode ); - form = std::make_unique< QgsAttributeForm >( &layer, QgsFeature(), context ); + form = std::make_unique( &layer, QgsFeature(), context ); form->setFeature( ft ); form->show(); form->setMode( QgsAttributeEditorContext::AddFeatureMode ); QGSVERIFYLESSTHAN( form->minimumWidth(), leMetrics.horizontalAdvance( 'x' ) * 20 ); context.setAttributeFormMode( QgsAttributeEditorContext::AggregateSearchMode ); - form = std::make_unique< QgsAttributeForm >( &layer, QgsFeature(), context ); + form = std::make_unique( &layer, QgsFeature(), context ); form->setFeature( ft ); form->show(); form->setMode( QgsAttributeEditorContext::AggregateSearchMode ); QGSVERIFYLESSTHAN( form->minimumWidth(), leMetrics.horizontalAdvance( 'x' ) * 150 ); context.setAttributeFormMode( QgsAttributeEditorContext::MultiEditMode ); - form = std::make_unique< QgsAttributeForm >( &layer, QgsFeature(), context ); + form = std::make_unique( &layer, QgsFeature(), context ); form->setFeature( ft ); form->setMode( QgsAttributeEditorContext::MultiEditMode ); form->show(); QGSVERIFYLESSTHAN( form->minimumWidth(), leMetrics.horizontalAdvance( 'x' ) * 100 ); - } void TestQgsAttributeForm::testFieldConstraintDuplicateField() diff --git a/tests/src/gui/testqgscategorizedrendererwidget.cpp b/tests/src/gui/testqgscategorizedrendererwidget.cpp index 85a1d3f525d5..21a595ae1ef2 100644 --- a/tests/src/gui/testqgscategorizedrendererwidget.cpp +++ b/tests/src/gui/testqgscategorizedrendererwidget.cpp @@ -31,14 +31,13 @@ class TestQgsCategorizedRendererWidget : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testAddMissingCategories(); void merge(); void model(); - }; void TestQgsCategorizedRendererWidget::initTestCase() @@ -62,7 +61,7 @@ void TestQgsCategorizedRendererWidget::cleanup() void TestQgsCategorizedRendererWidget::testAddMissingCategories() { - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( "Point?crs=EPSG:4326&field=idx:integer&field=name:string", QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( "Point?crs=EPSG:4326&field=idx:integer&field=name:string", QString(), QStringLiteral( "memory" ) ); QVERIFY( vl->isValid() ); QgsFeature f; @@ -78,24 +77,24 @@ void TestQgsCategorizedRendererWidget::testAddMissingCategories() QgsCategorizedSymbolRenderer *renderer = new QgsCategorizedSymbolRenderer( QStringLiteral( "name" ) ); vl->setRenderer( renderer ); - std::unique_ptr< QgsCategorizedSymbolRendererWidget > widget = std::make_unique< QgsCategorizedSymbolRendererWidget >( vl.get(), nullptr, renderer ); - QVERIFY( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().isEmpty() ); + std::unique_ptr widget = std::make_unique( vl.get(), nullptr, renderer ); + QVERIFY( static_cast( widget->renderer() )->categories().isEmpty() ); widget->addCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 5 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 4 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 5 ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 4 ).value().toString(), QString() ); // add a new value f.setAttributes( QgsAttributes() << 4 << "e" ); vl->dataProvider()->addFeature( f ); widget->addCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 5 ).value().toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 6 ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 5 ).value().toString(), QStringLiteral( "e" ) ); // test with a value list category widget.reset(); @@ -105,25 +104,25 @@ void TestQgsCategorizedRendererWidget::testAddMissingCategories() vl->setRenderer( renderer ); - widget = std::make_unique< QgsCategorizedSymbolRendererWidget >( vl.get(), nullptr, renderer ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 ); + widget = std::make_unique( vl.get(), nullptr, renderer ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 2 ); // values inside list categories should not be re-added widget->addCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 5 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toList().at( 0 ).toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toList().at( 1 ).toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 4 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 5 ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toList().at( 0 ).toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toList().at( 1 ).toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 4 ).value().toString(), QString() ); } void TestQgsCategorizedRendererWidget::merge() { // test merging categories - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( "Point?crs=EPSG:4326&field=idx:integer&field=name:string", QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( "Point?crs=EPSG:4326&field=idx:integer&field=name:string", QString(), QStringLiteral( "memory" ) ); QVERIFY( vl->isValid() ); QgsFeature f; @@ -141,58 +140,58 @@ void TestQgsCategorizedRendererWidget::merge() QgsCategorizedSymbolRenderer *renderer = new QgsCategorizedSymbolRenderer( QStringLiteral( "name" ) ); vl->setRenderer( renderer ); - std::unique_ptr< QgsCategorizedSymbolRendererWidget > widget = std::make_unique< QgsCategorizedSymbolRendererWidget >( vl.get(), nullptr, renderer ); + std::unique_ptr widget = std::make_unique( vl.get(), nullptr, renderer ); widget->addCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 4 ).value().toString(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 5 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 6 ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 4 ).value().toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 5 ).value().toString(), QString() ); // no selection, should have no effect widget->mergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 6 ); widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 1, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); // one selection, should have no effect widget->mergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 6 ); widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 3, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 4, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); widget->mergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 4 ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 4 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toList().at( 0 ).toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toList().at( 1 ).toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toList().at( 2 ).toString(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toList().at( 0 ).toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toList().at( 1 ).toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toList().at( 2 ).toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).value().toString(), QString() ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).label(), QStringLiteral( "b,d,e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).label(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).label(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).label(), QStringLiteral( "b,d,e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).label(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).label(), QString() ); // selection should always "merge into" first selected item widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows ); widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 0, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); widget->mergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 3 ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 3 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 0 ).toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 1 ).toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 2 ).toString(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toList().at( 0 ).toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toList().at( 1 ).toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 0 ).toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 1 ).toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 2 ).toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toList().at( 0 ).toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toList().at( 1 ).toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).value().toString(), QString() ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b,d,e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).label(), QStringLiteral( "c,a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).label(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b,d,e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).label(), QStringLiteral( "c,a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).label(), QString() ); // merging categories which are already lists widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 0, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows ); @@ -201,43 +200,43 @@ void TestQgsCategorizedRendererWidget::merge() widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); widget->mergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 2 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 0 ).toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 1 ).toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 2 ).toString(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 3 ).toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toList().at( 4 ).toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 0 ).toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 1 ).toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 2 ).toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 3 ).toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toList().at( 4 ).toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toString(), QString() ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b,d,e,c,a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).label(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b,d,e,c,a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).label(), QString() ); widget->viewCategories->selectionModel()->clearSelection(); // unmerge widget->unmergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 2 ); // not a list widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 1, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows ); widget->unmergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 2 ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 2 ); // list widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 0, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows ); widget->unmergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toString(), QString() ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 4 ).value().toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 5 ).value().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).label(), QString() ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).label(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).label(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 4 ).label(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 5 ).label(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 6 ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 4 ).value().toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 5 ).value().toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).label(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).label(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).label(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 4 ).label(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 5 ).label(), QStringLiteral( "a" ) ); widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows ); widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 3, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); @@ -250,24 +249,24 @@ void TestQgsCategorizedRendererWidget::merge() widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 2, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); widget->viewCategories->selectionModel()->select( widget->viewCategories->model()->index( 3, 0 ), QItemSelectionModel::Select | QItemSelectionModel::Rows ); widget->unmergeSelectedCategories(); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().count(), 6 ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).value().toString(), QString() ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 4 ).value().toString(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 5 ).value().toString(), QStringLiteral( "a" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 1 ).label(), QString() ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 2 ).label(), QStringLiteral( "d" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 3 ).label(), QStringLiteral( "c" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 4 ).label(), QStringLiteral( "e" ) ); - QCOMPARE( static_cast< QgsCategorizedSymbolRenderer * >( widget->renderer() )->categories().at( 5 ).label(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().count(), 6 ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).value().toString(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).value().toString(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).value().toString(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).value().toString(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 4 ).value().toString(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 5 ).value().toString(), QStringLiteral( "a" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 0 ).label(), QStringLiteral( "b" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 1 ).label(), QString() ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 2 ).label(), QStringLiteral( "d" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 3 ).label(), QStringLiteral( "c" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 4 ).label(), QStringLiteral( "e" ) ); + QCOMPARE( static_cast( widget->renderer() )->categories().at( 5 ).label(), QStringLiteral( "a" ) ); } void TestQgsCategorizedRendererWidget::model() { - std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( "Point?crs=EPSG:4326&field=idx:integer&field=name:string", QString(), QStringLiteral( "memory" ) ); + std::unique_ptr vl = std::make_unique( "Point?crs=EPSG:4326&field=idx:integer&field=name:string", QString(), QStringLiteral( "memory" ) ); QVERIFY( vl->isValid() ); QgsFeature f; @@ -290,7 +289,7 @@ void TestQgsCategorizedRendererWidget::model() vl->setRenderer( renderer ); - std::unique_ptr< QgsCategorizedSymbolRendererWidget > widget = std::make_unique< QgsCategorizedSymbolRendererWidget >( vl.get(), nullptr, renderer ); + std::unique_ptr widget = std::make_unique( vl.get(), nullptr, renderer ); QgsCategorizedSymbolRendererModel *model = widget->mModel; QCOMPARE( model->rowCount(), 3 ); QCOMPARE( model->data( model->index( 0, 1 ), Qt::DisplayRole ).toString(), QStringLiteral( "b" ) ); @@ -300,9 +299,9 @@ void TestQgsCategorizedRendererWidget::model() QCOMPARE( model->data( model->index( 1, 2 ), Qt::DisplayRole ).toString(), QStringLiteral( "list" ) ); QCOMPARE( model->data( model->index( 2, 2 ), Qt::DisplayRole ).toString(), QStringLiteral( "dd" ) ); - QCOMPARE( model->data( model->index( 0, 0 ), Qt::CheckStateRole ).toInt(), static_cast< int >( Qt::Checked ) ); - QCOMPARE( model->data( model->index( 1, 0 ), Qt::CheckStateRole ).toInt(), static_cast< int >( Qt::Checked ) ); - QCOMPARE( model->data( model->index( 2, 0 ), Qt::CheckStateRole ).toInt(), static_cast< int >( Qt::Unchecked ) ); + QCOMPARE( model->data( model->index( 0, 0 ), Qt::CheckStateRole ).toInt(), static_cast( Qt::Checked ) ); + QCOMPARE( model->data( model->index( 1, 0 ), Qt::CheckStateRole ).toInt(), static_cast( Qt::Checked ) ); + QCOMPARE( model->data( model->index( 2, 0 ), Qt::CheckStateRole ).toInt(), static_cast( Qt::Unchecked ) ); } QGSTEST_MAIN( TestQgsCategorizedRendererWidget ) diff --git a/tests/src/gui/testqgscompoundcolorwidget.cpp b/tests/src/gui/testqgscompoundcolorwidget.cpp index aa56890482fc..5deda1f9e42e 100644 --- a/tests/src/gui/testqgscompoundcolorwidget.cpp +++ b/tests/src/gui/testqgscompoundcolorwidget.cpp @@ -31,14 +31,14 @@ class TestQgsCompoundColorWidget : public QgsTest Q_OBJECT public: - - TestQgsCompoundColorWidget() : QgsTest( QStringLiteral( "Compound color widget Tests" ) ) {} + TestQgsCompoundColorWidget() + : QgsTest( QStringLiteral( "Compound color widget Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testCmykConversion(); void testComponentChange(); void testComponentSettings_data(); @@ -105,7 +105,7 @@ void TestQgsCompoundColorWidget::testCmykConversion() QCOMPARE( w.color(), QColor::fromCmyk( 120, 85, 0, 225, 50 ) ); // edit color in RGB, the returned color is still CMYK - w.mColorWheel->setColor( QColor( 10, 20, 30, 50 ), true ); + w.mColorWheel->setColor( QColor( 10, 20, 30, 50 ), true ); QCOMPARE( w.color(), QColor::fromCmyk( 170, 85, 0, 225, 50 ) ); } @@ -135,11 +135,9 @@ void TestQgsCompoundColorWidget::testComponentSettings() QFETCH( QgsColorWidget::ColorComponent, newComponent ); QFETCH( int, newSettingsComponent ); - QgsSettings().setValue( QgsColorWidget::colorSpec( expectedComponent ) == QColor::Cmyk ? - QStringLiteral( "Windows/ColorDialog/activeCmykComponent" ) : QStringLiteral( "Windows/ColorDialog/activeComponent" ), settingsComponent ); + QgsSettings().setValue( QgsColorWidget::colorSpec( expectedComponent ) == QColor::Cmyk ? QStringLiteral( "Windows/ColorDialog/activeCmykComponent" ) : QStringLiteral( "Windows/ColorDialog/activeComponent" ), settingsComponent ); - QgsCompoundColorWidget w( nullptr, QgsColorWidget::colorSpec( expectedComponent ) == QColor::Cmyk ? - QColor::fromCmyk( 1, 2, 3, 4 ) : QColor( 10, 20, 30, 50 ) ); + QgsCompoundColorWidget w( nullptr, QgsColorWidget::colorSpec( expectedComponent ) == QColor::Cmyk ? QColor::fromCmyk( 1, 2, 3, 4 ) : QColor( 10, 20, 30, 50 ) ); w.setVisible( true ); QCOMPARE( w.mColorBox->component(), expectedComponent ); @@ -150,8 +148,7 @@ void TestQgsCompoundColorWidget::testComponentSettings() QCOMPARE( w.mVerticalRamp->component(), newComponent ); w.saveSettings(); - const int newValue = QgsSettings().value( QgsColorWidget::colorSpec( expectedComponent ) == QColor::Cmyk ? - QStringLiteral( "Windows/ColorDialog/activeCmykComponent" ) : QStringLiteral( "Windows/ColorDialog/activeComponent" ), -1 ).toInt(); + const int newValue = QgsSettings().value( QgsColorWidget::colorSpec( expectedComponent ) == QColor::Cmyk ? QStringLiteral( "Windows/ColorDialog/activeCmykComponent" ) : QStringLiteral( "Windows/ColorDialog/activeComponent" ), -1 ).toInt(); QCOMPARE( newValue, newSettingsComponent ); } @@ -163,10 +160,9 @@ void TestQgsCompoundColorWidget::testComponentChange() w.setVisible( true ); QCOMPARE( w.mColorBox->component(), QgsColorWidget::Red ); - QCOMPARE( w.mVerticalRamp->component(), QgsColorWidget::Red ); + QCOMPARE( w.mVerticalRamp->component(), QgsColorWidget::Red ); - const QList> colors = - { + const QList> colors = { { w.mHueRadio, QgsColorWidget::Hue }, { w.mSaturationRadio, QgsColorWidget::Saturation }, { w.mValueRadio, QgsColorWidget::Value }, @@ -186,7 +182,7 @@ void TestQgsCompoundColorWidget::testComponentChange() color.first->setChecked( true ); QCOMPARE( w.mColorBox->component(), color.second ); - QCOMPARE( w.mVerticalRamp->component(), color.second ); + QCOMPARE( w.mVerticalRamp->component(), color.second ); } } diff --git a/tests/src/gui/testqgsdatetimeedit.cpp b/tests/src/gui/testqgsdatetimeedit.cpp index f658574cb701..75fef20b1291 100644 --- a/tests/src/gui/testqgsdatetimeedit.cpp +++ b/tests/src/gui/testqgsdatetimeedit.cpp @@ -21,14 +21,14 @@ #include #include -class TestQgsDateTimeEdit: public QObject +class TestQgsDateTimeEdit : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void nullValues(); void focus(); @@ -43,7 +43,6 @@ class TestQgsDateTimeEdit: public QObject std::unique_ptr widget6; // For field 5 std::unique_ptr widget7; // For field 6 std::unique_ptr vl; - }; void TestQgsDateTimeEdit::initTestCase() @@ -56,10 +55,7 @@ void TestQgsDateTimeEdit::cleanupTestCase() void TestQgsDateTimeEdit::init() { - - vl = std::make_unique( QStringLiteral( "Point?crs=epsg:4326" ), - QStringLiteral( "myvl" ), - QLatin1String( "memory" ) ); + vl = std::make_unique( QStringLiteral( "Point?crs=epsg:4326" ), QStringLiteral( "myvl" ), QLatin1String( "memory" ) ); // add fields QList fields; @@ -330,11 +326,10 @@ void TestQgsDateTimeEdit::testDateTime() QVERIFY( dateedit7 ); widget7->initWidget( dateedit7 ); QgsFeature f { vl->fields() }; - f.setAttribute( QStringLiteral( "text" ), QgsExpression{ QStringLiteral( "now()" ) }.evaluate() ); + f.setAttribute( QStringLiteral( "text" ), QgsExpression { QStringLiteral( "now()" ) }.evaluate() ); widget7->setFeature( f ); const QDate value7 { widget7->value().toDate() }; QCOMPARE( value7, QDate::currentDate() ); - } QGSTEST_MAIN( TestQgsDateTimeEdit ) diff --git a/tests/src/gui/testqgsdatumtransformdialog.cpp b/tests/src/gui/testqgsdatumtransformdialog.cpp index 6ce355ae038d..8cff00bd1b9f 100644 --- a/tests/src/gui/testqgsdatumtransformdialog.cpp +++ b/tests/src/gui/testqgsdatumtransformdialog.cpp @@ -20,14 +20,14 @@ #include "qgssettings.h" #include "qgsproject.h" -class TestQgsDatumTransformDialog: public QObject +class TestQgsDatumTransformDialog : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void defaultTransform(); void fallback(); @@ -36,7 +36,6 @@ class TestQgsDatumTransformDialog: public QObject void runDialog(); private: - }; void TestQgsDatumTransformDialog::initTestCase() @@ -125,7 +124,7 @@ void TestQgsDatumTransformDialog::shouldAskUser() const QgsDatumTransformDialog dlg2( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:7406" ) ) ); QVERIFY( !dlg2.shouldAskUserForSelection() ); -//prompts + //prompts QgsSettings().setValue( QStringLiteral( "/projections/promptWhenMultipleTransformsExist" ), true, QgsSettings::App ); const QgsDatumTransformDialog dlg3( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); QVERIFY( dlg3.shouldAskUserForSelection() ); diff --git a/tests/src/gui/testqgsdockwidget.cpp b/tests/src/gui/testqgsdockwidget.cpp index 6978a0f1b2fe..bedf3c7a3a2a 100644 --- a/tests/src/gui/testqgsdockwidget.cpp +++ b/tests/src/gui/testqgsdockwidget.cpp @@ -22,14 +22,14 @@ #include #include -class TestQgsDockWidget: public QObject +class TestQgsDockWidget : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testSignals(); void testUserVisible(); @@ -38,7 +38,6 @@ class TestQgsDockWidget: public QObject void testAction(); private: - }; void TestQgsDockWidget::initTestCase() @@ -177,7 +176,6 @@ void TestQgsDockWidget::testSetUserVisible() QVERIFY( !d1->isVisible() ); delete w; - } void TestQgsDockWidget::testToggleUserVisible() @@ -220,7 +218,6 @@ void TestQgsDockWidget::testToggleUserVisible() QVERIFY( !d1->isVisible() ); delete w; - } void TestQgsDockWidget::testAction() @@ -237,7 +234,7 @@ void TestQgsDockWidget::testAction() QAction *a1 = new QAction( w ); QAction *a2 = new QAction( w ); - QVERIFY( ! d1->toggleVisibilityAction() ); + QVERIFY( !d1->toggleVisibilityAction() ); d1->setToggleVisibilityAction( a1 ); d2->setToggleVisibilityAction( a2 ); QVERIFY( a1->isCheckable() ); diff --git a/tests/src/gui/testqgsdoublespinbox.cpp b/tests/src/gui/testqgsdoublespinbox.cpp index d957a9d79bf3..59e407083425 100644 --- a/tests/src/gui/testqgsdoublespinbox.cpp +++ b/tests/src/gui/testqgsdoublespinbox.cpp @@ -18,26 +18,24 @@ #include -class TestQgsDoubleSpinBox: public QObject +class TestQgsDoubleSpinBox : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void clear(); void expression(); void step(); private: - }; void TestQgsDoubleSpinBox::initTestCase() { - } void TestQgsDoubleSpinBox::cleanupTestCase() diff --git a/tests/src/gui/testqgsdoublevalidator.cpp b/tests/src/gui/testqgsdoublevalidator.cpp index 4c43b2fab1a3..3a9b5efeabb9 100644 --- a/tests/src/gui/testqgsdoublevalidator.cpp +++ b/tests/src/gui/testqgsdoublevalidator.cpp @@ -19,14 +19,14 @@ #include "qgsdoublevalidator.h" #include -class TestQgsDoubleValidator: public QObject +class TestQgsDoubleValidator : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void validate(); void validate_data(); @@ -34,12 +34,10 @@ class TestQgsDoubleValidator: public QObject void toDouble(); private: - }; void TestQgsDoubleValidator::initTestCase() { - } void TestQgsDoubleValidator::cleanupTestCase() @@ -73,7 +71,7 @@ void TestQgsDoubleValidator::validate_data() QTest::newRow( "exponent C negative" ) << QString( "44446ecn1" ) << int( QValidator::Acceptable ) << false; QTest::newRow( "exponent locale negative" ) << QString( "44446eln1" ) << int( QValidator::Acceptable ) << false; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) || (QT_VERSION >= QT_VERSION_CHECK(6, 5, 2)) // https://bugreports.qt.io/browse/QTBUG-113443 +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) || ( QT_VERSION >= QT_VERSION_CHECK( 6, 5, 2 ) ) // https://bugreports.qt.io/browse/QTBUG-113443 QTest::newRow( "locale decimal exponent positive" ) << QString( "444ld46E1" ) << int( QValidator::Acceptable ) << false; QTest::newRow( "locale decimal exponent positive sign" ) << QString( "444ld46E+1" ) << int( QValidator::Acceptable ) << false; #endif @@ -92,7 +90,6 @@ void TestQgsDoubleValidator::validate_data() QTest::newRow( "outside the range + local decimal" ) << QString( "3ld6" ) << int( QValidator::Intermediate ) << false; QTest::newRow( "outside the range + c decimal" ) << QString( "3cd6" ) << int( QValidator::Intermediate ) << false; QTest::newRow( "string" ) << QString( "string" ) << int( QValidator::Invalid ) << false; - } void TestQgsDoubleValidator::toDouble_data() @@ -113,7 +110,7 @@ void TestQgsDoubleValidator::toDouble_data() QTest::newRow( "exponent C negative" ) << QString( "44446ecn1" ) << 4444.6; QTest::newRow( "exponent locale negative" ) << QString( "44446eln1" ) << 4444.6; -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) || (QT_VERSION >= QT_VERSION_CHECK(6, 5, 2)) // https://bugreports.qt.io/browse/QTBUG-113443 +#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) || ( QT_VERSION >= QT_VERSION_CHECK( 6, 5, 2 ) ) // https://bugreports.qt.io/browse/QTBUG-113443 QTest::newRow( "locale decimal exponent positive" ) << QString( "444ld46E1" ) << 4444.6; QTest::newRow( "locale decimal exponent positive sign" ) << QString( "444ld46E+1" ) << 4444.6; #endif @@ -131,7 +128,6 @@ void TestQgsDoubleValidator::toDouble_data() QTest::newRow( "outside the range + local decimal" ) << QString( "3ld6" ) << 3.6; QTest::newRow( "outside the range + c decimal" ) << QString( "3cd6" ) << 3.6; QTest::newRow( "string" ) << QString( "string" ) << 0.0; - } void TestQgsDoubleValidator::validate() @@ -144,7 +140,7 @@ void TestQgsDoubleValidator::validate() QString value; int expectedValue; - const QVectorlistLocale( {QLocale::English, QLocale::French, QLocale::German, QLocale::Italian, QLocale::NorwegianBokmal, QLocale::Ukrainian} ); + const QVector listLocale( { QLocale::English, QLocale::French, QLocale::German, QLocale::Italian, QLocale::NorwegianBokmal, QLocale::Ukrainian } ); QLocale loc; for ( int i = 0; i < listLocale.count(); ++i ) { @@ -161,12 +157,12 @@ void TestQgsDoubleValidator::validate() value = actualState; value = value.replace( "ld", QLocale().decimalPoint() ) - .replace( "cd", QLocale( QLocale::C ).decimalPoint() ) - .replace( "lg", QLocale().groupSeparator() ) - .replace( "cg", QLocale( QLocale::C ).groupSeparator() ) - .replace( "ln", QLocale().negativeSign() ) - .replace( "cn", QLocale( QLocale::C ).negativeSign() ) - .replace( "le", QLocale().exponential() ); + .replace( "cd", QLocale( QLocale::C ).decimalPoint() ) + .replace( "lg", QLocale().groupSeparator() ) + .replace( "cg", QLocale( QLocale::C ).groupSeparator() ) + .replace( "ln", QLocale().negativeSign() ) + .replace( "cn", QLocale( QLocale::C ).negativeSign() ) + .replace( "le", QLocale().exponential() ); expectedValue = expState; // if the local group separator / decimal point is equal to the C one, // expected result will be different for double with test with mixed @@ -179,8 +175,7 @@ void TestQgsDoubleValidator::validate() // and validator->validate(4lg444ld6) == 1 and not 0 // for 4cg444ld6 double, if cd == ld then 4cg444ld6 == 4cg444cd6 // and validator->validate(4cg444cd6) == 1 and not 0 - if ( ( QLocale( QLocale::C ).groupSeparator() == QLocale().groupSeparator() || - QLocale( QLocale::C ).decimalPoint() == QLocale().decimalPoint() ) + if ( ( QLocale( QLocale::C ).groupSeparator() == QLocale().groupSeparator() || QLocale( QLocale::C ).decimalPoint() == QLocale().decimalPoint() ) && value != "string" && expectedValue == 0 ) expectedValue = 1; // There is another corner case in the test where the group separator is equal @@ -188,7 +183,7 @@ void TestQgsDoubleValidator::validate() // in that case the value is valid, because the fall // back check is to test after removing all group separators if ( QLocale().groupSeparator() == QLocale( QLocale::C ).decimalPoint() - && ! value.contains( QLocale().decimalPoint() ) + && !value.contains( QLocale().decimalPoint() ) && value != "string" && expectedValue == 0 ) { expectedValue = 1; @@ -205,7 +200,7 @@ void TestQgsDoubleValidator::toDouble() QString value; double expectedValue; - const QVectorlistLocale( {QLocale::English, QLocale::French, QLocale::German, QLocale::Italian, QLocale::NorwegianBokmal, QLocale::Ukrainian} ); + const QVector listLocale( { QLocale::English, QLocale::French, QLocale::German, QLocale::Italian, QLocale::NorwegianBokmal, QLocale::Ukrainian } ); QLocale loc; for ( int i = 0; i < listLocale.count(); ++i ) { @@ -213,12 +208,12 @@ void TestQgsDoubleValidator::toDouble() QLocale::setDefault( loc ); value = actualValue; value = value.replace( "ld", QLocale().decimalPoint() ) - .replace( "cd", QLocale( QLocale::C ).decimalPoint() ) - .replace( "lg", QLocale().groupSeparator() ) - .replace( "cg", QLocale( QLocale::C ).groupSeparator() ) - .replace( "ln", QLocale().negativeSign() ) - .replace( "cn", QLocale( QLocale::C ).negativeSign() ) - .replace( "le", QLocale().exponential() ); + .replace( "cd", QLocale( QLocale::C ).decimalPoint() ) + .replace( "lg", QLocale().groupSeparator() ) + .replace( "cg", QLocale( QLocale::C ).groupSeparator() ) + .replace( "ln", QLocale().negativeSign() ) + .replace( "cn", QLocale( QLocale::C ).negativeSign() ) + .replace( "le", QLocale().exponential() ); expectedValue = expValue; // if the local group separator / decimal point is equal to the C one, // expected result will be different for double with test with mixed @@ -231,8 +226,7 @@ void TestQgsDoubleValidator::toDouble() // and QgsDoubleValidator::toDouble(4lg444ld6) == 4444.6 and not 0.0 // for 4cg444ld6 double, if cd == ld then 4cg444ld6 == 4cg444cd6 // and QgsDoubleValidator::toDouble(4cg444cd6) == 4444.6 and not 0.0 - if ( ( QLocale( QLocale::C ).groupSeparator() == QLocale().groupSeparator() || - QLocale( QLocale::C ).decimalPoint() == QLocale().decimalPoint() ) + if ( ( QLocale( QLocale::C ).groupSeparator() == QLocale().groupSeparator() || QLocale( QLocale::C ).decimalPoint() == QLocale().decimalPoint() ) && value != "string" && expectedValue == 0.0 ) expectedValue = 4444.6; // There is another corner case in the test where the group separator is equal @@ -240,7 +234,7 @@ void TestQgsDoubleValidator::toDouble() // in that case the value is valid, because the fall // back check is to test after removing all group separators if ( QLocale().groupSeparator() == QLocale( QLocale::C ).decimalPoint() - && ! value.contains( QLocale().decimalPoint() ) + && !value.contains( QLocale().decimalPoint() ) && value != "string" && expectedValue == 0 ) { expectedValue = 44446; @@ -248,7 +242,6 @@ void TestQgsDoubleValidator::toDouble() QCOMPARE( QgsDoubleValidator::toDouble( value ), expectedValue ); } - } QGSTEST_MAIN( TestQgsDoubleValidator ) diff --git a/tests/src/gui/testqgsdualview.cpp b/tests/src/gui/testqgsdualview.cpp index 71945243dd79..be8dbb739a78 100644 --- a/tests/src/gui/testqgsdualview.cpp +++ b/tests/src/gui/testqgsdualview.cpp @@ -41,10 +41,10 @@ class TestQgsDualView : public QObject TestQgsDualView() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testColumnCount(); @@ -92,8 +92,7 @@ void TestQgsDualView::initTestCase() // const QString myPointsFileName = mTestDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); mCanvas = new QgsMapCanvas(); } @@ -152,13 +151,13 @@ void TestQgsDualView::testAttributeTableConfig() void TestQgsDualView::testFilterSelected() { QgsFeature feature; - QList< QgsFeatureId > ids; + QList ids; QgsFeatureIterator it = mPointsLayer->getFeatures( QgsFeatureRequest().setOrderBy( QgsFeatureRequest::OrderBy() << QgsFeatureRequest::OrderByClause( QStringLiteral( "Heading" ) ) ) ); while ( it.nextFeature( feature ) ) ids << feature.id(); // select some features - QList< QgsFeatureId > selected; + QList selected; selected << ids.at( 1 ) << ids.at( 3 ); mPointsLayer->selectByIds( qgis::listToSet( selected ) ); @@ -181,7 +180,6 @@ void TestQgsDualView::testFilterSelected() void TestQgsDualView::testSelectAll() { - QEventLoop loop; connect( qobject_cast( mDualView->mFilterModel ), &QgsAttributeTableFilterModel::visibleReloaded, &loop, &QEventLoop::quit ); mDualView->setFilterMode( QgsAttributeTableFilterModel::ShowVisible ); @@ -229,22 +227,22 @@ void TestQgsDualView::testSort() QStringList headings; headings << QStringLiteral( "0" ) - << QStringLiteral( "0" ) - << QStringLiteral( "12" ) - << QStringLiteral( "34" ) - << QStringLiteral( "80" ) - << QStringLiteral( "85" ) - << QStringLiteral( "90" ) - << QStringLiteral( "90" ) - << QStringLiteral( "95" ) - << QStringLiteral( "100" ) - << QStringLiteral( "140" ) - << QStringLiteral( "160" ) - << QStringLiteral( "180" ) - << QStringLiteral( "240" ) - << QStringLiteral( "270" ) - << QStringLiteral( "300" ) - << QStringLiteral( "340" ); + << QStringLiteral( "0" ) + << QStringLiteral( "12" ) + << QStringLiteral( "34" ) + << QStringLiteral( "80" ) + << QStringLiteral( "85" ) + << QStringLiteral( "90" ) + << QStringLiteral( "90" ) + << QStringLiteral( "95" ) + << QStringLiteral( "100" ) + << QStringLiteral( "140" ) + << QStringLiteral( "160" ) + << QStringLiteral( "180" ) + << QStringLiteral( "240" ) + << QStringLiteral( "270" ) + << QStringLiteral( "300" ) + << QStringLiteral( "340" ); mDualView->setSortExpression( QStringLiteral( "Heading" ) ); @@ -259,8 +257,8 @@ void TestQgsDualView::testAttributeFormSharedValueScanning() { // test QgsAttributeForm::scanForEqualAttributes - QSet< int > mixedValueFields; - QHash< int, QVariant > fieldSharedValues; + QSet mixedValueFields; + QHash fieldSharedValues; // make a temporary layer to check through QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer&field=col2:integer&field=col3:integer&field=col4:integer" ), QStringLiteral( "test" ), QStringLiteral( "memory" ) ); @@ -293,7 +291,7 @@ void TestQgsDualView::testAttributeFormSharedValueScanning() form.scanForEqualAttributes( it, mixedValueFields, fieldSharedValues ); - QCOMPARE( mixedValueFields, QSet< int >() << 1 << 3 ); + QCOMPARE( mixedValueFields, QSet() << 1 << 3 ); QCOMPARE( fieldSharedValues.value( 0 ).toInt(), 1 ); QCOMPARE( fieldSharedValues.value( 2 ).toInt(), 3 ); @@ -308,7 +306,7 @@ void TestQgsDualView::testAttributeFormSharedValueScanning() it = layer->getFeatures(); form.scanForEqualAttributes( it, mixedValueFields, fieldSharedValues ); - QCOMPARE( mixedValueFields, QSet< int >() << 0 << 1 << 2 << 3 ); + QCOMPARE( mixedValueFields, QSet() << 0 << 1 << 2 << 3 ); QVERIFY( fieldSharedValues.isEmpty() ); // single feature, all attributes should be shared @@ -324,7 +322,7 @@ void TestQgsDualView::testAttributeFormSharedValueScanning() void TestQgsDualView::testNoGeom() { //test that both the master model and cache for the dual view either both request geom or both don't request geom - std::unique_ptr< QgsDualView > dv( new QgsDualView() ); + std::unique_ptr dv( new QgsDualView() ); // request with geometry QgsFeatureRequest req; diff --git a/tests/src/gui/testqgseditorwidgetregistry.cpp b/tests/src/gui/testqgseditorwidgetregistry.cpp index e2946511b789..bf7981927727 100644 --- a/tests/src/gui/testqgseditorwidgetregistry.cpp +++ b/tests/src/gui/testqgseditorwidgetregistry.cpp @@ -20,11 +20,11 @@ #include "qgsrelationmanager.h" #include "qgsgui.h" -class TestQgsEditorWidgetRegistry: public QObject +class TestQgsEditorWidgetRegistry : public QObject { Q_OBJECT - class DummyPlugin: public QgsEditorWidgetAutoConfPlugin + class DummyPlugin : public QgsEditorWidgetAutoConfPlugin { public: QgsEditorWidgetSetup editorWidgetSetup( const QgsVectorLayer *vl, const QString &fieldName, int &score ) const override @@ -148,7 +148,6 @@ class TestQgsEditorWidgetRegistry: public QObject } private: - static void checkSimple( const QString &dataType, const QString &widgetType ) { const QgsVectorLayer vl( "LineString?crs=epsg:3111&field=pk:int&field=col1:" + dataType, QStringLiteral( "vl" ), QStringLiteral( "memory" ) ); diff --git a/tests/src/gui/testqgsexternalresourcewidgetwrapper.cpp b/tests/src/gui/testqgsexternalresourcewidgetwrapper.cpp index 1c50e41069b2..1e2534cf0ae0 100644 --- a/tests/src/gui/testqgsexternalresourcewidgetwrapper.cpp +++ b/tests/src/gui/testqgsexternalresourcewidgetwrapper.cpp @@ -48,10 +48,10 @@ class TestQgsExternalResourceWidgetWrapper : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testSetNullValues(); void testUrlStorageExpression(); @@ -83,7 +83,6 @@ class QgsTestExternalStorageFetchedContent Q_OBJECT public: - QgsTestExternalStorageFetchedContent( QString url ) : QgsExternalStorageFetchedContent() , mCached( url.endsWith( QLatin1String( "cached.txt" ) ) ) @@ -128,7 +127,6 @@ class QgsTestExternalStorageFetchedContent } private: - bool mCached = false; QString mUrl; }; @@ -139,10 +137,8 @@ class QgsTestExternalStorageStoredContent Q_OBJECT public: - QgsTestExternalStorageStoredContent( const QString &url ) - : QgsExternalStorageStoredContent(), - mUrl( url ) + : QgsExternalStorageStoredContent(), mUrl( url ) { } @@ -173,11 +169,10 @@ class QgsTestExternalStorageStoredContent QString url() const override { return mUrl.endsWith( "/" ) ? QString( "http://www.test.com/here/myfile.txt" ) - : mUrl; + : mUrl; } private: - QString mUrl; }; @@ -185,7 +180,6 @@ class QgsTestExternalStorageStoredContent class QgsTestExternalStorage : public QgsExternalStorage { public: - QString type() const override { return QStringLiteral( "test" ); } QString displayName() const override { return QStringLiteral( "Test" ); } @@ -235,15 +229,13 @@ void TestQgsExternalResourceWidgetWrapper::cleanupTestCase() void TestQgsExternalResourceWidgetWrapper::init() { - vl = std::make_unique( QStringLiteral( "NoGeometry?field=type:string&field=url:string" ), - QStringLiteral( "myvl" ), - QLatin1String( "memory" ) ); + vl = std::make_unique( QStringLiteral( "NoGeometry?field=type:string&field=url:string" ), QStringLiteral( "myvl" ), QLatin1String( "memory" ) ); - QgsFeature feat1( vl->fields(), 1 ); + QgsFeature feat1( vl->fields(), 1 ); feat1.setAttribute( QStringLiteral( "type" ), QStringLiteral( "type1" ) ); vl->dataProvider()->addFeature( feat1 ); - QgsFeature feat2( vl->fields(), 2 ); + QgsFeature feat2( vl->fields(), 2 ); feat2.setAttribute( QStringLiteral( "type" ), QStringLiteral( "type2" ) ); vl->dataProvider()->addFeature( feat2 ); } @@ -298,10 +290,10 @@ void TestQgsExternalResourceWidgetWrapper::testUrlStorageExpression() QVariantMap config; config.insert( QStringLiteral( "StorageType" ), QStringLiteral( "test" ) ); QgsPropertyCollection propertyCollection; - propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( - "@myurl || @layer_name || '/' || \"type\" || '/' " - "|| attribute( @current_feature, 'type' ) " - "|| '/' || $id || '/test'", true ) ); + propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( "@myurl || @layer_name || '/' || \"type\" || '/' " + "|| attribute( @current_feature, 'type' ) " + "|| '/' || $id || '/test'", + true ) ); config.insert( QStringLiteral( "PropertyCollection" ), propertyCollection.toVariant( QgsWidgetWrapper::propertyDefinitions() ) ); ww.setConfig( config ); @@ -319,8 +311,7 @@ void TestQgsExternalResourceWidgetWrapper::testUrlStorageExpression() QgsExpressionContext expressionContext = ww.mQgsWidget->fileWidget()->expressionContext(); QVERIFY( expression->prepare( &expressionContext ) ); - QCOMPARE( expression->evaluate( &expressionContext ).toString(), - QStringLiteral( "http://url.test.com/myvl/type1/type1/1/test" ) ); + QCOMPARE( expression->evaluate( &expressionContext ).toString(), QStringLiteral( "http://url.test.com/myvl/type1/type1/1/test" ) ); feat = vl->getFeature( 2 ); QVERIFY( feat.isValid() ); @@ -328,8 +319,7 @@ void TestQgsExternalResourceWidgetWrapper::testUrlStorageExpression() expressionContext = ww.mQgsWidget->fileWidget()->expressionContext(); QVERIFY( expression->prepare( &expressionContext ) ); - QCOMPARE( expression->evaluate( &expressionContext ).toString(), - QStringLiteral( "http://url.test.com/myvl/type2/type2/2/test" ) ); + QCOMPARE( expression->evaluate( &expressionContext ).toString(), QStringLiteral( "http://url.test.com/myvl/type2/type2/2/test" ) ); } void TestQgsExternalResourceWidgetWrapper::testLoadExternalDocument_data() @@ -606,7 +596,6 @@ void TestQgsExternalResourceWidgetWrapper::testLoadNullExternalDocument() QVERIFY( ww.mQgsWidget->mLoadingMovie->state() != QMovie::Running ); QVERIFY( !ww.mQgsWidget->mErrorLabel->isVisible() ); QVERIFY( !messageBar->currentItem() ); - } void TestQgsExternalResourceWidgetWrapper::testStoreExternalDocument_data() @@ -637,9 +626,9 @@ void TestQgsExternalResourceWidgetWrapper::testStoreExternalDocument() config.insert( QStringLiteral( "DocumentViewer" ), documentType ); QgsPropertyCollection propertyCollection; - propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( - "'http://mytest.com/' || $id || '/' " - " || file_name(@selected_file_path)", true ) ); + propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( "'http://mytest.com/' || $id || '/' " + " || file_name(@selected_file_path)", + true ) ); config.insert( QStringLiteral( "PropertyCollection" ), propertyCollection.toVariant( QgsWidgetWrapper::propertyDefinitions() ) ); ww.setConfig( config ); @@ -736,9 +725,9 @@ void TestQgsExternalResourceWidgetWrapper::testStoreExternalDocumentError() config.insert( QStringLiteral( "StorageType" ), QStringLiteral( "test" ) ); config.insert( QStringLiteral( "DocumentViewer" ), documentType ); QgsPropertyCollection propertyCollection; - propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( - "'http://mytest.com/' || $id || '/' " - " || file_name(@selected_file_path)", true ) ); + propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( "'http://mytest.com/' || $id || '/' " + " || file_name(@selected_file_path)", + true ) ); config.insert( QStringLiteral( "PropertyCollection" ), propertyCollection.toVariant( QgsWidgetWrapper::propertyDefinitions() ) ); ww.setConfig( config ); @@ -849,9 +838,9 @@ void TestQgsExternalResourceWidgetWrapper::testStoreExternalDocumentCancel() config.insert( QStringLiteral( "StorageType" ), QStringLiteral( "test" ) ); config.insert( QStringLiteral( "DocumentViewer" ), documentType ); QgsPropertyCollection propertyCollection; - propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( - "'http://mytest.com/' || $id || '/' " - " || file_name(@selected_file_path)", true ) ); + propertyCollection.setProperty( QgsWidgetWrapper::Property::StorageUrl, QgsProperty::fromExpression( "'http://mytest.com/' || $id || '/' " + " || file_name(@selected_file_path)", + true ) ); config.insert( QStringLiteral( "PropertyCollection" ), propertyCollection.toVariant( QgsWidgetWrapper::propertyDefinitions() ) ); ww.setConfig( config ); @@ -1329,6 +1318,5 @@ void TestQgsExternalResourceWidgetWrapper::testChangeValueToNullBeforeLoaded() } - QGSTEST_MAIN( TestQgsExternalResourceWidgetWrapper ) #include "testqgsexternalresourcewidgetwrapper.moc" diff --git a/tests/src/gui/testqgsexternalstoragefilewidget.cpp b/tests/src/gui/testqgsexternalstoragefilewidget.cpp index 8df49b31c756..9bd532c51ca1 100644 --- a/tests/src/gui/testqgsexternalstoragefilewidget.cpp +++ b/tests/src/gui/testqgsexternalstoragefilewidget.cpp @@ -32,14 +32,14 @@ #include #include -class TestQgsExternalStorageFileWidget: public QObject +class TestQgsExternalStorageFileWidget : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testLayout_data(); void testLayout(); void testStoring(); @@ -63,10 +63,8 @@ class QgsTestExternalStorageStoredContent : public QgsExternalStorageStoredConte Q_OBJECT public: - QgsTestExternalStorageStoredContent( const QString &filePath, const QString &url ) - : QgsExternalStorageStoredContent(), - mUrl( filePath.endsWith( QLatin1String( "mydir" ) ) ? url + "mydir/" : url ) + : QgsExternalStorageStoredContent(), mUrl( filePath.endsWith( QLatin1String( "mydir" ) ) ? url + "mydir/" : url ) {} void store() override @@ -104,15 +102,12 @@ class QgsTestExternalStorageStoredContent : public QgsExternalStorageStoredConte } private: - QString mUrl; - }; class QgsTestExternalStorage : public QgsExternalStorage { public: - QString type() const override { return QStringLiteral( "test" ); } QString displayName() const override { return QStringLiteral( "Test" ); } @@ -120,7 +115,6 @@ class QgsTestExternalStorage : public QgsExternalStorage static QPointer sCurrentStoredContent; protected: - QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authcfg = QString() ) const override { Q_UNUSED( authcfg ); @@ -283,12 +277,13 @@ void TestQgsExternalStorageFileWidget::testStoring() w.setUseLink( useLink ); w.setReadOnly( false ); - const QStringList fileNames = QStringList() << "myfile1.txt" << "myfile2.txt" ; + const QStringList fileNames = QStringList() << "myfile1.txt" << "myfile2.txt"; for ( QString fileName : fileNames ) { QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -325,7 +320,8 @@ void TestQgsExternalStorageFileWidget::testStoring() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -369,7 +365,8 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFiles() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -418,7 +415,8 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFiles() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -466,7 +464,8 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesError() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -516,7 +515,8 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesError() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -564,7 +564,8 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesCancel() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -613,7 +614,8 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesCancel() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -703,7 +705,8 @@ void TestQgsExternalStorageFileWidget::testStoringBadExpression() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -717,7 +720,8 @@ void TestQgsExternalStorageFileWidget::testStoringBadExpression() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -758,7 +762,8 @@ void TestQgsExternalStorageFileWidget::testStoringDirectory() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -783,7 +788,8 @@ void TestQgsExternalStorageFileWidget::testStoringDirectory() QVERIFY( useLink == w.mLinkLabel->isVisible() ); QVERIFY( useLink == w.mLinkEditButton->isVisible() ); - if ( useLink ) QCOMPARE( w.mLinkEditButton->icon(), editIcon ); + if ( useLink ) + QCOMPARE( w.mLinkEditButton->icon(), editIcon ); QVERIFY( useLink != w.mLineEdit->isVisible() ); QVERIFY( w.mFileWidgetButton->isVisible() ); QVERIFY( w.mFileWidgetButton->isEnabled() ); @@ -837,11 +843,11 @@ void TestQgsExternalStorageFileWidget::testDragAndDrop() QVERIFY( !w.mCancelButton->isVisible() ); QVERIFY( w.acceptDrops() ); - std::unique_ptr dragEvent( new QDragEnterEvent( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + std::unique_ptr dragEvent( new QDragEnterEvent( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); w.dragEnterEvent( dragEvent.get() ); QVERIFY( dragEvent->isAccepted() ); - std::unique_ptr dropEvent( new QDropEvent( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + std::unique_ptr dropEvent( new QDropEvent( QPoint( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); w.dropEvent( dropEvent.get() ); QVERIFY( dropEvent->isAccepted() ); diff --git a/tests/src/gui/testqgsfeaturelistcombobox.cpp b/tests/src/gui/testqgsfeaturelistcombobox.cpp index d71cff87867f..fc6ee9ab1071 100644 --- a/tests/src/gui/testqgsfeaturelistcombobox.cpp +++ b/tests/src/gui/testqgsfeaturelistcombobox.cpp @@ -37,10 +37,10 @@ class TestQgsFeatureListComboBox : public QObject TestQgsFeatureListComboBox() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testSetGetLayer(); void testSetGetForeignKey(); @@ -53,7 +53,6 @@ class TestQgsFeatureListComboBox : public QObject void testFeatureFurtherThanFetchLimit(); private: - std::unique_ptr mLayer; friend class QgsFeatureListComboBox; @@ -68,7 +67,6 @@ void TestQgsFeatureListComboBox::initTestCase() QCoreApplication::setOrganizationName( QStringLiteral( "QGIS" ) ); QCoreApplication::setOrganizationDomain( QStringLiteral( "qgis.org" ) ); QCoreApplication::setApplicationName( QStringLiteral( "QGIS-TEST-FEATURELIST-COMBOBOX" ) ); - } void TestQgsFeatureListComboBox::cleanupTestCase() @@ -221,7 +219,7 @@ void TestQgsFeatureListComboBox::testValuesAndSelection() cb->setSourceLayer( mLayer.get() ); cb->setAllowNull( allowNull ); - cb->setIdentifierFields( {QStringLiteral( "raccord" )} ); + cb->setIdentifierFields( { QStringLiteral( "raccord" ) } ); cb->setDisplayExpression( QStringLiteral( "\"raccord\"" ) ); //check if everything is fine: @@ -234,14 +232,14 @@ void TestQgsFeatureListComboBox::testValuesAndSelection() QCOMPARE( cb->currentIndex(), allowNull ? cb->nullIndex() : 0 ); QCOMPARE( cb->currentText(), allowNull ? QStringLiteral( "nope" ) : QString() ); QCOMPARE( cb->lineEdit()->selectedText(), allowNull ? QStringLiteral( "nope" ) : QString() ); - QVERIFY( ! cb->mLineEdit->mClearAction ); + QVERIFY( !cb->mLineEdit->mClearAction ); //check if text is selected after receiving focus cb->setFocus(); QCOMPARE( cb->currentIndex(), allowNull ? cb->nullIndex() : 0 ); QCOMPARE( cb->currentText(), allowNull ? QStringLiteral( "nope" ) : QString() ); QCOMPARE( cb->lineEdit()->selectedText(), allowNull ? QStringLiteral( "nope" ) : QString() ); - QVERIFY( ! cb->mLineEdit->mClearAction ); + QVERIFY( !cb->mLineEdit->mClearAction ); //check with another entry, clear button needs to be there then: QTest::keyClicks( cb.get(), QStringLiteral( "sleeve" ) ); @@ -301,12 +299,12 @@ void TestQgsFeatureListComboBox::testFeatureFurtherThanFetchLimit() model->setFetchLimit( 20 ); model->setAllowNull( false ); cb->setSourceLayer( mLayer.get() ); - cb->setIdentifierFields( {QStringLiteral( "pk" )} ); + cb->setIdentifierFields( { QStringLiteral( "pk" ) } ); spy.wait(); QCOMPARE( model->mEntries.count(), 20 ); for ( int i = 0; i < 20; i++ ) QCOMPARE( model->mEntries.at( i ).identifierFields.at( 0 ).toInt(), i + 10 ); - cb->setIdentifierValues( {33} ); + cb->setIdentifierValues( { 33 } ); spy.wait(); QCOMPARE( cb->lineEdit()->text(), QStringLiteral( "33" ) ); QCOMPARE( model->mEntries.count(), 21 ); diff --git a/tests/src/gui/testqgsfieldexpressionwidget.cpp b/tests/src/gui/testqgsfieldexpressionwidget.cpp index c9639dcd2419..054d57c69766 100644 --- a/tests/src/gui/testqgsfieldexpressionwidget.cpp +++ b/tests/src/gui/testqgsfieldexpressionwidget.cpp @@ -39,10 +39,10 @@ class TestQgsFieldExpressionWidget : public QObject TestQgsFieldExpressionWidget() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. - void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testRemoveJoin(); void asExpression(); @@ -83,8 +83,6 @@ void TestQgsFieldExpressionWidget::initTestCase() // init widget mWidget = new QgsFieldExpressionWidget(); mWidget->setLayer( mLayerA ); - - } void TestQgsFieldExpressionWidget::init() @@ -102,7 +100,6 @@ void TestQgsFieldExpressionWidget::cleanupTestCase() void TestQgsFieldExpressionWidget::testRemoveJoin() { - QVERIFY( mLayerA->fields().count() == 1 ); QgsVectorLayerJoinInfo joinInfo; @@ -138,15 +135,15 @@ void TestQgsFieldExpressionWidget::testRemoveJoin() void TestQgsFieldExpressionWidget::asExpression() { QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "point?field=fld:int&field=fld2:int&field=fld3:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); - layer->dataProvider()->addAttributes( QList< QgsField >() << QgsField( QStringLiteral( "a space" ), QMetaType::Type::QString ) ); + layer->dataProvider()->addAttributes( QList() << QgsField( QStringLiteral( "a space" ), QMetaType::Type::QString ) ); layer->updateFields(); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); + std::unique_ptr widget( new QgsFieldExpressionWidget() ); widget->setLayer( layer ); - const QSignalSpy spy( widget.get(), static_cast < void ( QgsFieldExpressionWidget::* )( const QString & ) >( &QgsFieldExpressionWidget::fieldChanged ) ); - const QSignalSpy spy2( widget.get(), static_cast < void ( QgsFieldExpressionWidget::* )( const QString &, bool ) >( &QgsFieldExpressionWidget::fieldChanged ) ); + const QSignalSpy spy( widget.get(), static_cast( &QgsFieldExpressionWidget::fieldChanged ) ); + const QSignalSpy spy2( widget.get(), static_cast( &QgsFieldExpressionWidget::fieldChanged ) ); // check with field set widget->setField( QStringLiteral( "fld" ) ); @@ -233,7 +230,7 @@ void TestQgsFieldExpressionWidget::testIsValid() QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "point?field=fld:int&field=name%20with%20space:string" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); + std::unique_ptr widget( new QgsFieldExpressionWidget() ); widget->setLayer( layer ); // also check the fieldChanged signal to ensure that the emitted bool isValid value is correct @@ -290,7 +287,7 @@ void TestQgsFieldExpressionWidget::testFilters() QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "point?field=intfld:int&field=stringfld:string&field=string2fld:string&field=longfld:long&field=doublefld:double&field=datefld:date&field=timefld:time&field=datetimefld:datetime&field=binaryfld:binary&field=booleanfld:boolean" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); + std::unique_ptr widget( new QgsFieldExpressionWidget() ); widget->setLayer( layer ); QCOMPARE( widget->mCombo->count(), 10 ); @@ -358,7 +355,7 @@ void TestQgsFieldExpressionWidget::setNull() QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "point?field=fld:int&field=fld2:int&field=fld3:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - std::unique_ptr< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); + std::unique_ptr widget( new QgsFieldExpressionWidget() ); widget->setLayer( layer ); widget->setField( QString() ); @@ -386,6 +383,5 @@ void TestQgsFieldExpressionWidget::testVeryLongExpression() }; - QGSTEST_MAIN( TestQgsFieldExpressionWidget ) #include "testqgsfieldexpressionwidget.moc" diff --git a/tests/src/gui/testqgsfiledownloader.cpp b/tests/src/gui/testqgsfiledownloader.cpp index 8e9c8bf8488d..7e2fdcea803c 100644 --- a/tests/src/gui/testqgsfiledownloader.cpp +++ b/tests/src/gui/testqgsfiledownloader.cpp @@ -25,7 +25,7 @@ #include #include -class TestQgsFileDownloader: public QObject +class TestQgsFileDownloader : public QObject { Q_OBJECT public: @@ -63,10 +63,10 @@ class TestQgsFileDownloader: public QObject } private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testValidDownload(); void testInValidDownload(); @@ -84,11 +84,11 @@ class TestQgsFileDownloader: public QObject void makeCall( QUrl url, QString fileName, bool cancel = false ); QTemporaryFile *mTempFile = nullptr; QString mErrorMessage; - bool mCanceled = false ; - bool mProgress = false ; - bool mError = false ; - bool mCompleted = false ; - bool mExited = false ; + bool mCanceled = false; + bool mProgress = false; + bool mError = false; + bool mCompleted = false; + bool mExited = false; QgsFileDownloader *mFileDownloader = nullptr; }; @@ -109,14 +109,12 @@ void TestQgsFileDownloader::makeCall( QUrl url, QString fileName, bool cancel ) QTimer::singleShot( 1000, mFileDownloader, &QgsFileDownloader::cancelDownload ); loop.exec(); - } void TestQgsFileDownloader::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsFileDownloader::cleanupTestCase() @@ -138,7 +136,6 @@ void TestQgsFileDownloader::init() } - void TestQgsFileDownloader::cleanup() { delete mTempFile; @@ -146,7 +143,7 @@ void TestQgsFileDownloader::cleanup() void TestQgsFileDownloader::testValidDownload() { - QVERIFY( ! mTempFile->fileName().isEmpty() ); + QVERIFY( !mTempFile->fileName().isEmpty() ); makeCall( QUrl( QStringLiteral( "http://www.qgis.org" ) ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( mCompleted ); @@ -158,7 +155,7 @@ void TestQgsFileDownloader::testValidDownload() void TestQgsFileDownloader::testInValidDownload() { - QVERIFY( ! mTempFile->fileName().isEmpty() ); + QVERIFY( !mTempFile->fileName().isEmpty() ); makeCall( QUrl( QStringLiteral( "http://www.doesnotexistofthatimsure.qgis" ) ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( !mCompleted ); @@ -170,7 +167,7 @@ void TestQgsFileDownloader::testInValidDownload() void TestQgsFileDownloader::testCanceledDownload() { - QVERIFY( ! mTempFile->fileName().isEmpty() ); + QVERIFY( !mTempFile->fileName().isEmpty() ); makeCall( QUrl( QStringLiteral( "https://github.com/qgis/QGIS/archive/master.zip" ) ), mTempFile->fileName(), true ); QVERIFY( mExited ); QVERIFY( !mCompleted ); @@ -192,7 +189,7 @@ void TestQgsFileDownloader::testInvalidFile() void TestQgsFileDownloader::testInvalidUrl() { - QVERIFY( ! mTempFile->fileName().isEmpty() ); + QVERIFY( !mTempFile->fileName().isEmpty() ); makeCall( QUrl( QStringLiteral( "xyz://www" ) ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( !mCompleted ); @@ -203,7 +200,7 @@ void TestQgsFileDownloader::testInvalidUrl() void TestQgsFileDownloader::testBlankUrl() { - QVERIFY( ! mTempFile->fileName().isEmpty() ); + QVERIFY( !mTempFile->fileName().isEmpty() ); makeCall( QUrl( QString() ), mTempFile->fileName() ); QVERIFY( mExited ); QVERIFY( !mCompleted ); @@ -228,7 +225,7 @@ void TestQgsFileDownloader::testSslError() { QFETCH( QString, url ); QFETCH( QString, result ); - QVERIFY( ! mTempFile->fileName().isEmpty() ); + QVERIFY( !mTempFile->fileName().isEmpty() ); makeCall( QUrl( url ), mTempFile->fileName() ); QCOMPARE( mErrorMessage, result ); QVERIFY( !mCompleted ); @@ -239,16 +236,16 @@ void TestQgsFileDownloader::testSslError() void TestQgsFileDownloader::testLacksWritePermissionsError() { const QTemporaryDir dir; - QFile tmpDir( dir.path( ) ); - tmpDir.setPermissions( tmpDir.permissions() & ~( QFile::Permission::WriteGroup | QFile::Permission::WriteUser | QFile::Permission::WriteOther | QFile::Permission::WriteOwner ) ); - QVERIFY( ! tmpDir.isWritable() ); + QFile tmpDir( dir.path() ); + tmpDir.setPermissions( tmpDir.permissions() & ~( QFile::Permission::WriteGroup | QFile::Permission::WriteUser | QFile::Permission::WriteOther | QFile::Permission::WriteOwner ) ); + QVERIFY( !tmpDir.isWritable() ); const QString fileName( dir.path() + '/' + QStringLiteral( "tmp.bin" ) ); makeCall( QUrl( QStringLiteral( "http://www.qgis.org" ) ), fileName ); QVERIFY( mExited ); QVERIFY( !mCompleted ); QVERIFY( mError ); QVERIFY( !mCanceled ); - QVERIFY( ! QFileInfo::exists( fileName ) ); + QVERIFY( !QFileInfo::exists( fileName ) ); } @@ -257,5 +254,3 @@ void TestQgsFileDownloader::testLacksWritePermissionsError() QGSTEST_MAIN( TestQgsFileDownloader ) #include "testqgsfiledownloader.moc" - - diff --git a/tests/src/gui/testqgsfilewidget.cpp b/tests/src/gui/testqgsfilewidget.cpp index 23a426dc6b89..a141e29a05af 100644 --- a/tests/src/gui/testqgsfilewidget.cpp +++ b/tests/src/gui/testqgsfilewidget.cpp @@ -24,14 +24,14 @@ #include "qgsdirectoryitem.h" #include -class TestQgsFileWidget: public QObject +class TestQgsFileWidget : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void relativePath(); void toUrl(); void testDroppedFiles(); @@ -96,17 +96,17 @@ void TestQgsFileWidget::testDroppedFiles() w->setStorageMode( QgsFileWidget::GetFile ); // should not accept dropped folders - std::unique_ptr< QMimeData > mime( new QMimeData() ); + std::unique_ptr mime( new QMimeData() ); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR ) ); - std::unique_ptr< QDropEvent > event( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + std::unique_ptr event( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QVERIFY( w->lineEdit()->text().isEmpty() ); // but dropped files should be fine mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); - event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); // also should support files dragged from browser @@ -116,8 +116,8 @@ void TestQgsFileWidget::testDroppedFiles() QgsMimeDataUtils::UriList uriList; uriList << uri; mime.reset( QgsMimeDataUtils::encodeUriList( uriList ) ); - event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ) ); QgsBrowserModel m; @@ -126,40 +126,40 @@ void TestQgsFileWidget::testDroppedFiles() m.driveItems().first()->addChild( layerItem ); mime.reset( m.mimeData( QModelIndexList() << m.findItem( layerItem ) ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh/quad_and_triangle.txt" ) ) ); // plain text should also be permitted - mime = std::make_unique< QMimeData >(); + mime = std::make_unique(); mime->setText( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ); - event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ) ); mime.reset( new QMimeData() ); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); - event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); // with file filter w->setFilter( QStringLiteral( "Data (*.shp)" ) ); w->setFilePath( QString() ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) ); w->setFilePath( QString() ); // should be rejected, not compatible with filter mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/encoded_html.html" ) ) ); - event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QVERIFY( w->lineEdit()->text().isEmpty() ); // new filter, should be allowed now w->setFilter( QStringLiteral( "Data (*.shp);;HTML (*.HTML)" ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/encoded_html.html" ) ) ); //try with wildcard filter w->setFilter( QStringLiteral( "All files (*.*);;Data (*.shp);;HTML (*.HTML)" ) ); mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.prj" ) ) ); - event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR + QStringLiteral( "/bug5598.prj" ) ) ); // try with folders @@ -167,14 +167,14 @@ void TestQgsFileWidget::testDroppedFiles() w->setFilePath( QString() ); // dropping a file should accept only the folder containing that file mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/mesh/quad_and_triangle.2dm" ) ) ); - event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), QString( QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh" ) ) ); + event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); + QCOMPARE( w->lineEdit()->text(), QString( QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh" ) ) ); // but dropping a folder should work mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( TEST_DATA_DIR ) ); // integration test - dropping a directory item's mime data @@ -182,7 +182,7 @@ void TestQgsFileWidget::testDroppedFiles() m.driveItems().first()->addChild( dirItem ); mime.reset( m.mimeData( QModelIndexList() << m.findItem( dirItem ) ) ); event.reset( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); QCOMPARE( w->lineEdit()->text(), QString( QString( TEST_DATA_DIR ) + QStringLiteral( "/mesh" ) ) ); } @@ -191,14 +191,12 @@ void TestQgsFileWidget::testMultipleFiles() QgsFileWidget *w = new QgsFileWidget(); w->setStorageMode( QgsFileWidget::GetMultipleFiles ); - std::unique_ptr< QMimeData > mime( new QMimeData() ); - mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) - << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/elev.gpx" ) ) ); - const std::unique_ptr< QDropEvent > event( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); + std::unique_ptr mime( new QMimeData() ); + mime->setUrls( QList() << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) << QUrl::fromLocalFile( TEST_DATA_DIR + QStringLiteral( "/elev.gpx" ) ) ); + const std::unique_ptr event( new QDropEvent( QPointF( 1, 1 ), Qt::CopyAction, mime.get(), Qt::LeftButton, Qt::NoModifier ) ); - qobject_cast< QgsFileDropEdit * >( w->lineEdit() )->dropEvent( event.get() ); - QCOMPARE( w->lineEdit()->text(), QStringLiteral( "\"%1\" \"%2\"" ).arg( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ) - .arg( TEST_DATA_DIR + QStringLiteral( "/elev.gpx" ) ) ); + qobject_cast( w->lineEdit() )->dropEvent( event.get() ); + QCOMPARE( w->lineEdit()->text(), QStringLiteral( "\"%1\" \"%2\"" ).arg( TEST_DATA_DIR + QStringLiteral( "/bug5598.shp" ) ).arg( TEST_DATA_DIR + QStringLiteral( "/elev.gpx" ) ) ); } diff --git a/tests/src/gui/testqgsfocuswatcher.cpp b/tests/src/gui/testqgsfocuswatcher.cpp index d2828e30e4a8..93a3a60f0f99 100644 --- a/tests/src/gui/testqgsfocuswatcher.cpp +++ b/tests/src/gui/testqgsfocuswatcher.cpp @@ -21,19 +21,18 @@ #include #include -class TestQgsFocusWatcher: public QObject +class TestQgsFocusWatcher : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testSignals(); private: - }; void TestQgsFocusWatcher::initTestCase() diff --git a/tests/src/gui/testqgsgui.cpp b/tests/src/gui/testqgsgui.cpp index 273a8d48e50a..bfc71f7fb5b0 100644 --- a/tests/src/gui/testqgsgui.cpp +++ b/tests/src/gui/testqgsgui.cpp @@ -24,7 +24,6 @@ class TestQgsGui : public QObject void createFileFilter(); void displayValueWithMaximumDecimals(); void displayValueWithMaximumDecimals_data(); - }; void TestQgsGui::createFileFilterForFormat() @@ -57,7 +56,6 @@ void TestQgsGui::displayValueWithMaximumDecimals() void TestQgsGui::displayValueWithMaximumDecimals_data() { - QTest::addColumn( "locale" ); QTest::addColumn( "dataType" ); QTest::addColumn( "value" ); @@ -65,23 +63,22 @@ void TestQgsGui::displayValueWithMaximumDecimals_data() QTest::addColumn( "result" ); // Italian locale ("," as decimal point and "." as thousands separator) - QTest::newRow( "float_1_it_1" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0 << true << "112.345,0000000" ; - QTest::newRow( "float_1_it_0" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0 << false << "112.345" ; - QTest::newRow( "float_2_it_1" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0102 << true << "112.345,0102000" ; - QTest::newRow( "float_2_it_0" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0102 << false << "112.345,0102" ; + QTest::newRow( "float_1_it_1" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0 << true << "112.345,0000000"; + QTest::newRow( "float_1_it_0" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0 << false << "112.345"; + QTest::newRow( "float_2_it_1" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0102 << true << "112.345,0102000"; + QTest::newRow( "float_2_it_0" ) << QLocale::Italian << Qgis::DataType::Float32 << 112345.0102 << false << "112.345,0102"; - QTest::newRow( "int_2_it_1" ) << QLocale::Italian << Qgis::DataType::Int32 << 112345.0102 << true << "112.345" ; - QTest::newRow( "int_2_it_0" ) << QLocale::Italian << Qgis::DataType::Int32 << 112345.0102 << false << "112.345" ; + QTest::newRow( "int_2_it_1" ) << QLocale::Italian << Qgis::DataType::Int32 << 112345.0102 << true << "112.345"; + QTest::newRow( "int_2_it_0" ) << QLocale::Italian << Qgis::DataType::Int32 << 112345.0102 << false << "112.345"; // English locale - QTest::newRow( "float_1_en_1" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0 << true << "112,345.0000000" ; - QTest::newRow( "float_1_en_0" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0 << false << "112,345" ; - QTest::newRow( "float_2_en_1" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0102 << true << "112,345.0102000" ; - QTest::newRow( "float_2_en_0" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0102 << false << "112,345.0102" ; - - QTest::newRow( "int_2_en_1" ) << QLocale::English << Qgis::DataType::Int32 << 112345.0102 << true << "112,345" ; - QTest::newRow( "int_2_en_0" ) << QLocale::English << Qgis::DataType::Int32 << 112345.0102 << false << "112,345" ; + QTest::newRow( "float_1_en_1" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0 << true << "112,345.0000000"; + QTest::newRow( "float_1_en_0" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0 << false << "112,345"; + QTest::newRow( "float_2_en_1" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0102 << true << "112,345.0102000"; + QTest::newRow( "float_2_en_0" ) << QLocale::English << Qgis::DataType::Float32 << 112345.0102 << false << "112,345.0102"; + QTest::newRow( "int_2_en_1" ) << QLocale::English << Qgis::DataType::Int32 << 112345.0102 << true << "112,345"; + QTest::newRow( "int_2_en_0" ) << QLocale::English << Qgis::DataType::Int32 << 112345.0102 << false << "112,345"; } QGSTEST_MAIN( TestQgsGui ) diff --git a/tests/src/gui/testqgshtmlwidgetwrapper.cpp b/tests/src/gui/testqgshtmlwidgetwrapper.cpp index 3e3f725a984c..d6d92b250ca6 100644 --- a/tests/src/gui/testqgshtmlwidgetwrapper.cpp +++ b/tests/src/gui/testqgshtmlwidgetwrapper.cpp @@ -31,10 +31,10 @@ class TestQgsHtmlWidgetWrapper : public QObject TestQgsHtmlWidgetWrapper() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. #ifdef WITH_QTWEBKIT void testExpressionEvaluate_data(); @@ -115,7 +115,7 @@ Second line)html" ) }; QgsWebView *webView = qobject_cast( htmlWrapper->widget() ); Q_ASSERT( webView ); - Q_ASSERT( ! htmlWrapper->needsGeometry() ); + Q_ASSERT( !htmlWrapper->needsGeometry() ); QCOMPARE( webView->page()->mainFrame()->toPlainText(), R"(First line Second line)" ); } diff --git a/tests/src/gui/testqgskeyvaluewidget.cpp b/tests/src/gui/testqgskeyvaluewidget.cpp index 5d7c2f036ee4..740e8a1d8818 100644 --- a/tests/src/gui/testqgskeyvaluewidget.cpp +++ b/tests/src/gui/testqgskeyvaluewidget.cpp @@ -26,7 +26,6 @@ class TestQgsKeyValueWidget : public QObject { Q_OBJECT public: - private slots: void initTestCase() // will be called before the first testfunction is executed. { @@ -46,7 +45,7 @@ class TestQgsKeyValueWidget : public QObject QVERIFY( wrapper ); const QSignalSpy spy( wrapper, SIGNAL( valueChanged( const QVariant & ) ) ); - QgsKeyValueWidget *widget = qobject_cast< QgsKeyValueWidget * >( wrapper->widget() ); + QgsKeyValueWidget *widget = qobject_cast( wrapper->widget() ); QVERIFY( widget ); QVariantMap initial; @@ -76,7 +75,6 @@ class TestQgsKeyValueWidget : public QObject QCOMPARE( rowSpy.count(), 1 ); model->insertRow( 0, QModelIndex() ); QCOMPARE( rowSpy.count(), 2 ); - } }; diff --git a/tests/src/gui/testqgslayoutgui.cpp b/tests/src/gui/testqgslayoutgui.cpp index 7b1715de526e..fcc1e7536919 100644 --- a/tests/src/gui/testqgslayoutgui.cpp +++ b/tests/src/gui/testqgslayoutgui.cpp @@ -14,8 +14,6 @@ ***************************************************************************/ - - #include #include "qgsmapsettings.h" @@ -30,20 +28,19 @@ #include -class TestQgsLayoutGui: public QObject +class TestQgsLayoutGui : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void itemTypeComboBox(); void testProxyCrash(); private: - }; void TestQgsLayoutGui::initTestCase() @@ -88,7 +85,7 @@ void TestQgsLayoutGui::itemTypeComboBox() QCOMPARE( cb->currentItem(), item1 ); QVERIFY( !cb2->currentItem() ); - int expectedSpy1Count = 2;// ideally only one, but we'll settle for 2 + int expectedSpy1Count = 2; // ideally only one, but we'll settle for 2 int expectedSpy2Count = 0; QCOMPARE( spy1.count(), 2 ); QCOMPARE( qvariant_cast( spy1.at( 1 ).at( 0 ) ), item1 ); @@ -110,7 +107,7 @@ void TestQgsLayoutGui::itemTypeComboBox() QCOMPARE( cb2->currentItem(), item2 ); QCOMPARE( spy1.count(), expectedSpy1Count ); // must be unchanged from earlier - expectedSpy2Count = 2;// ideally only one, but we'll settle for 2 + expectedSpy2Count = 2; // ideally only one, but we'll settle for 2 QCOMPARE( spy2.count(), expectedSpy2Count ); QCOMPARE( qvariant_cast( spy2.at( 1 ).at( 0 ) ), item2 ); diff --git a/tests/src/gui/testqgslayoutview.cpp b/tests/src/gui/testqgslayoutview.cpp index 2dfc97d2a6ab..3a52fc10196f 100644 --- a/tests/src/gui/testqgslayoutview.cpp +++ b/tests/src/gui/testqgslayoutview.cpp @@ -27,14 +27,14 @@ #include #include -class TestQgsLayoutView: public QObject +class TestQgsLayoutView : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void basic(); void tool(); void events(); @@ -42,12 +42,10 @@ class TestQgsLayoutView: public QObject void rubberBand(); private: - }; void TestQgsLayoutView::initTestCase() { - } void TestQgsLayoutView::cleanupTestCase() @@ -124,7 +122,6 @@ void TestQgsLayoutView::tool() class LoggingTool : public QgsLayoutViewTool // clazy:exclude=missing-qobject-macro { public: - LoggingTool( QgsLayoutView *view ) : QgsLayoutViewTool( view, QStringLiteral( "logging" ) ) {} @@ -148,7 +145,7 @@ class LoggingTool : public QgsLayoutViewTool // clazy:exclude=missing-qobject-ma bool receivedPressEvent = false; void layoutPressEvent( QgsLayoutViewMouseEvent *event ) override { - receivedPressEvent = true; + receivedPressEvent = true; QCOMPARE( event->layoutPoint().x(), 8.0 ); QCOMPARE( event->layoutPoint().y(), 6.0 ); } @@ -156,7 +153,7 @@ class LoggingTool : public QgsLayoutViewTool // clazy:exclude=missing-qobject-ma bool receivedReleaseEvent = false; void layoutReleaseEvent( QgsLayoutViewMouseEvent *event ) override { - receivedReleaseEvent = true; + receivedReleaseEvent = true; QCOMPARE( event->layoutPoint().x(), 8.0 ); QCOMPARE( event->layoutPoint().y(), 6.0 ); } @@ -170,7 +167,7 @@ class LoggingTool : public QgsLayoutViewTool // clazy:exclude=missing-qobject-ma bool receivedKeyPressEvent = false; void keyPressEvent( QKeyEvent * ) override { - receivedKeyPressEvent = true; + receivedKeyPressEvent = true; } bool receivedKeyReleaseEvent = false; @@ -203,16 +200,11 @@ void TestQgsLayoutView::events() view->setTool( tool ); const QPointF point( 80, 60 ); - QMouseEvent press( QEvent::MouseButtonPress, point, - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); - QMouseEvent move( QEvent::MouseMove, point, - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); - QMouseEvent releases( QEvent::MouseButtonRelease, point, - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); - QMouseEvent dblClick( QEvent::MouseButtonDblClick, point, - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); - QWheelEvent wheelEvent( point, QPointF(), QPoint( 0, 10 ), QPoint( 0, 10 ), - Qt::LeftButton, Qt::NoModifier, Qt::NoScrollPhase, false ); + QMouseEvent press( QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); + QMouseEvent move( QEvent::MouseMove, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); + QMouseEvent releases( QEvent::MouseButtonRelease, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); + QMouseEvent dblClick( QEvent::MouseButtonDblClick, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); + QWheelEvent wheelEvent( point, QPointF(), QPoint( 0, 10 ), QPoint( 0, 10 ), Qt::LeftButton, Qt::NoModifier, Qt::NoScrollPhase, false ); QKeyEvent keyPress( QEvent::KeyPress, 10, Qt::NoModifier ); QKeyEvent keyRelease( QEvent::KeyRelease, 10, Qt::NoModifier ); @@ -236,15 +228,15 @@ void TestQgsLayoutView::events() class TestItem : public QgsLayoutItem // clazy:exclude=missing-qobject-macro { public: - - TestItem( QgsLayout *layout ) : QgsLayoutItem( layout ) {} + TestItem( QgsLayout *layout ) + : QgsLayoutItem( layout ) {} int mFlag = 0; //implement pure virtual methods int type() const override { return QgsLayoutItemRegistry::LayoutItem + 101; } void draw( QgsLayoutItemRenderContext & ) override - { } + {} }; void TestQgsLayoutView::guiRegistry() @@ -258,19 +250,17 @@ void TestQgsLayoutView::guiRegistry() QCOMPARE( registry.metadataIdForItemType( 0 ), -1 ); QVERIFY( !registry.createItemWidget( nullptr ) ); QVERIFY( !registry.createItemWidget( nullptr ) ); - const std::unique_ptr< TestItem > testItem = std::make_unique< TestItem >( nullptr ); + const std::unique_ptr testItem = std::make_unique( nullptr ); QVERIFY( !registry.createItemWidget( testItem.get() ) ); // not in registry const QSignalSpy spyTypeAdded( ®istry, &QgsLayoutItemGuiRegistry::typeAdded ); // add a dummy item to registry - auto createWidget = []( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * - { + auto createWidget = []( QgsLayoutItem *item ) -> QgsLayoutItemBaseWidget * { return new QgsLayoutItemBaseWidget( nullptr, item ); }; - auto createRubberBand = []( QgsLayoutView * view )->QgsLayoutViewRubberBand * - { + auto createRubberBand = []( QgsLayoutView *view ) -> QgsLayoutViewRubberBand * { return new QgsLayoutViewRectangularRubberBand( view ); }; @@ -301,7 +291,7 @@ void TestQgsLayoutView::guiRegistry() //should use metadata's method QgsLayoutViewRubberBand *band = registry.createItemRubberBand( uuid, view ); QVERIFY( band ); - QVERIFY( dynamic_cast< QgsLayoutViewRectangularRubberBand * >( band ) ); + QVERIFY( dynamic_cast( band ) ); QCOMPARE( band->view(), view ); delete band; @@ -314,21 +304,19 @@ void TestQgsLayoutView::guiRegistry() //creating item QgsLayoutItem *item = registry.createItem( uuid, nullptr ); QVERIFY( !item ); - QgsApplication::layoutItemRegistry()->addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 101, QStringLiteral( "my type" ), QStringLiteral( "my types" ), []( QgsLayout * layout )->QgsLayoutItem* - { + QgsApplication::layoutItemRegistry()->addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 101, QStringLiteral( "my type" ), QStringLiteral( "my types" ), []( QgsLayout *layout ) -> QgsLayoutItem * { return new TestItem( layout ); } ) ); item = registry.createItem( uuid, nullptr ); QVERIFY( item ); QCOMPARE( item->type(), QgsLayoutItemRegistry::LayoutItem + 101 ); - QCOMPARE( static_cast< TestItem * >( item )->mFlag, 0 ); + QCOMPARE( static_cast( item )->mFlag, 0 ); delete item; // override create func metadata = new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutItem + 101, QStringLiteral( "mytype" ), QIcon(), createWidget, createRubberBand ); - metadata->setItemCreationFunction( []( QgsLayout * layout )->QgsLayoutItem* - { + metadata->setItemCreationFunction( []( QgsLayout *layout ) -> QgsLayoutItem * { TestItem *item = new TestItem( layout ); item->mFlag = 2; return item; @@ -338,9 +326,8 @@ void TestQgsLayoutView::guiRegistry() item = registry.createItem( uuid, nullptr ); QVERIFY( item ); QCOMPARE( item->type(), QgsLayoutItemRegistry::LayoutItem + 101 ); - QCOMPARE( static_cast< TestItem * >( item )->mFlag, 2 ); + QCOMPARE( static_cast( item )->mFlag, 2 ); delete item; - } void TestQgsLayoutView::rubberBand() diff --git a/tests/src/gui/testqgslistwidget.cpp b/tests/src/gui/testqgslistwidget.cpp index 8c1f0ae1cafa..a8dac75d7e96 100644 --- a/tests/src/gui/testqgslistwidget.cpp +++ b/tests/src/gui/testqgslistwidget.cpp @@ -28,7 +28,6 @@ class TestQgsListWidget : public QObject { Q_OBJECT private: - #ifdef ENABLE_PGTEST QString dbConn; #endif @@ -52,17 +51,16 @@ class TestQgsListWidget : public QObject #ifdef ENABLE_PGTEST // delete new features in db from postgres test QgsVectorLayer *vl_array_int = new QgsVectorLayer( QStringLiteral( "%1 sslmode=disable key=\"pk\" table=\"qgis_test\".\"array_tbl\" sql=" ).arg( dbConn ), QStringLiteral( "json" ), QStringLiteral( "postgres" ) ); - vl_array_int->startEditing( ); + vl_array_int->startEditing(); const QgsFeatureIds delete_ids = QSet() << Q_INT64_C( 997 ) << Q_INT64_C( 998 ) << Q_INT64_C( 999 ); vl_array_int->deleteFeatures( delete_ids ); vl_array_int->commitChanges( false ); QgsVectorLayer *vl_array_str = new QgsVectorLayer( QStringLiteral( "%1 sslmode=disable key=\"pk\" table=\"qgis_test\".\"string_array\" sql=" ).arg( dbConn ), QStringLiteral( "json" ), QStringLiteral( "postgres" ) ); - vl_array_str->startEditing( ); + vl_array_str->startEditing(); vl_array_str->deleteFeatures( delete_ids ); vl_array_str->commitChanges( false ); #endif QgsApplication::exitQgis(); - } void testStringUpdate() @@ -156,20 +154,20 @@ class TestQgsListWidget : public QObject //create pg layers QgsVectorLayer *vl_array_int = new QgsVectorLayer( QStringLiteral( "%1 sslmode=disable key=\"pk\" table=\"qgis_test\".\"array_tbl\" sql=" ).arg( dbConn ), QStringLiteral( "json" ), QStringLiteral( "postgres" ) ); - connect( vl_array_int, &QgsVectorLayer::raiseError, this, []( const QString & msg ) { qWarning() << msg; } ); - QVERIFY( vl_array_int->isValid( ) ); + connect( vl_array_int, &QgsVectorLayer::raiseError, this, []( const QString &msg ) { qWarning() << msg; } ); + QVERIFY( vl_array_int->isValid() ); QgsListWidgetWrapper w_array_int( vl_array_int, vl_array_int->fields().indexOf( QLatin1String( "location" ) ), nullptr, nullptr ); - QgsListWidget *widget = w_array_int.widget( )->findChild(); + QgsListWidget *widget = w_array_int.widget()->findChild(); - vl_array_int->startEditing( ); + vl_array_int->startEditing(); QVariantList newList; newList.append( QStringLiteral( "100" ) ); widget->setList( QList() << 100 ); - QVERIFY( w_array_int.value( ).isValid( ) ); - QCOMPARE( widget->list( ), QList( ) << 100 ); + QVERIFY( w_array_int.value().isValid() ); + QCOMPARE( widget->list(), QList() << 100 ); // save value and check it is saved properly in postges - QgsFeature new_rec_997 {vl_array_int->fields(), 997}; + QgsFeature new_rec_997 { vl_array_int->fields(), 997 }; new_rec_997.setAttribute( 0, QVariant( 997 ) ); vl_array_int->addFeature( new_rec_997, QgsFeatureSink::RollBackOnErrors ); vl_array_int->commitChanges( false ); @@ -177,44 +175,44 @@ class TestQgsListWidget : public QObject QVERIFY( vl_array_int->commitChanges( false ) ); w_array_int.setFeature( vl_array_int->getFeature( 997 ) ); - QCOMPARE( widget->list( ), QList( ) << 100 ); + QCOMPARE( widget->list(), QList() << 100 ); // alter two values at a time which triggered old bug (#38784) widget->setList( QList() << 4 << 5 << 6 ); - QgsFeature new_rec_998 {vl_array_int->fields(), 998}; + QgsFeature new_rec_998 { vl_array_int->fields(), 998 }; new_rec_998.setAttribute( 0, QVariant( 998 ) ); new_rec_998.setAttribute( 1, w_array_int.value() ); vl_array_int->addFeature( new_rec_998, QgsFeatureSink::RollBackOnErrors ); widget->setList( QList() << 10 << 11 << 12 ); - QgsFeature new_rec_999 {vl_array_int->fields(), 999}; + QgsFeature new_rec_999 { vl_array_int->fields(), 999 }; new_rec_999.setAttribute( 0, QVariant( 999 ) ); new_rec_999.setAttribute( 1, w_array_int.value() ); vl_array_int->addFeature( new_rec_999, QgsFeatureSink::RollBackOnErrors ); vl_array_int->commitChanges( false ); w_array_int.setFeature( vl_array_int->getFeature( 998 ) ); - QCOMPARE( widget->list( ), QList( ) << 4 << 5 << 6 ); + QCOMPARE( widget->list(), QList() << 4 << 5 << 6 ); w_array_int.setFeature( vl_array_int->getFeature( 999 ) ); - QCOMPARE( widget->list( ), QList() << 10 << 11 << 12 ); + QCOMPARE( widget->list(), QList() << 10 << 11 << 12 ); // do similar for array of strings QgsVectorLayer *vl_array_str = new QgsVectorLayer( QStringLiteral( "%1 sslmode=disable key=\"pk\" table=\"qgis_test\".\"string_array\" sql=" ).arg( dbConn ), QStringLiteral( "json" ), QStringLiteral( "postgres" ) ); QVERIFY( vl_array_str->isValid() ); QgsListWidgetWrapper w_array_str( vl_array_str, vl_array_str->fields().indexOf( QLatin1String( "value" ) ), nullptr, nullptr ); - widget = w_array_str.widget( )->findChild(); - vl_array_str->startEditing( ); + widget = w_array_str.widget()->findChild(); + vl_array_str->startEditing(); QVariantList newListStr; // test quotes newListStr.append( QStringLiteral( "10\"0" ) ); widget->setList( newListStr ); QVERIFY( w_array_str.value().isValid() ); - QCOMPARE( widget->list( ), QList( ) << QStringLiteral( "10\"0" ) ); + QCOMPARE( widget->list(), QList() << QStringLiteral( "10\"0" ) ); // save value and check it is saved properly in postges - QgsFeature new_rec_997_str {vl_array_str->fields(), 997}; + QgsFeature new_rec_997_str { vl_array_str->fields(), 997 }; new_rec_997_str.setAttribute( 0, QVariant( 997 ) ); vl_array_str->addFeature( new_rec_997_str, QgsFeatureSink::RollBackOnErrors ); vl_array_str->commitChanges( false ); @@ -222,27 +220,27 @@ class TestQgsListWidget : public QObject QVERIFY( vl_array_str->commitChanges( false ) ); w_array_str.setFeature( vl_array_str->getFeature( 997 ) ); - QCOMPARE( widget->list( ), QList( ) << QStringLiteral( "10\"0" ) ); + QCOMPARE( widget->list(), QList() << QStringLiteral( "10\"0" ) ); // alter two values at a time which triggered old bug (#38784) widget->setList( QList() << QStringLiteral( "four" ) << QStringLiteral( "five" ) << QStringLiteral( "six" ) ); - QgsFeature new_rec_998_str {vl_array_str->fields(), 998}; + QgsFeature new_rec_998_str { vl_array_str->fields(), 998 }; new_rec_998_str.setAttribute( 0, QVariant( 998 ) ); new_rec_998_str.setAttribute( 1, w_array_str.value() ); vl_array_str->addFeature( new_rec_998_str, QgsFeatureSink::RollBackOnErrors ); widget->setList( QList() << QStringLiteral( "ten" ) << QStringLiteral( "eleven" ) << QStringLiteral( "twelve" ) ); - QgsFeature new_rec_999_str {vl_array_str->fields(), 999}; + QgsFeature new_rec_999_str { vl_array_str->fields(), 999 }; new_rec_999_str.setAttribute( 0, QVariant( 999 ) ); new_rec_999_str.setAttribute( 1, w_array_str.value() ); vl_array_str->addFeature( new_rec_999_str, QgsFeatureSink::RollBackOnErrors ); vl_array_str->commitChanges( false ); w_array_str.setFeature( vl_array_str->getFeature( 998 ) ); - QCOMPARE( widget->list( ), QList() << QStringLiteral( "four" ) << QStringLiteral( "five" ) << QStringLiteral( "six" ) ); + QCOMPARE( widget->list(), QList() << QStringLiteral( "four" ) << QStringLiteral( "five" ) << QStringLiteral( "six" ) ); w_array_str.setFeature( vl_array_str->getFeature( 999 ) ); - QCOMPARE( widget->list( ), QList() << QStringLiteral( "ten" ) << QStringLiteral( "eleven" ) << QStringLiteral( "twelve" ) ); + QCOMPARE( widget->list(), QList() << QStringLiteral( "ten" ) << QStringLiteral( "eleven" ) << QStringLiteral( "twelve" ) ); } #endif }; diff --git a/tests/src/gui/testqgsmapcanvas.cpp b/tests/src/gui/testqgsmapcanvas.cpp index 12147248fd4e..e13befea6ddc 100644 --- a/tests/src/gui/testqgsmapcanvas.cpp +++ b/tests/src/gui/testqgsmapcanvas.cpp @@ -35,12 +35,13 @@ namespace QTest QByteArray ba = r.toString().toLocal8Bit(); return qstrdup( ba.data() ); } -} +} // namespace QTest class QgsMapToolTest : public QgsMapTool // clazy:exclude=missing-qobject-macro { public: - QgsMapToolTest( QgsMapCanvas *canvas ) : QgsMapTool( canvas ) {} + QgsMapToolTest( QgsMapCanvas *canvas ) + : QgsMapTool( canvas ) {} bool canvasToolTipEvent( QHelpEvent *e ) override { @@ -55,7 +56,6 @@ class QgsMapToolTest : public QgsMapTool // clazy:exclude=missing-qobject-macro private: bool mGotTooltipEvent = false; - }; class TestQgsMapCanvas : public QObject @@ -65,7 +65,7 @@ class TestQgsMapCanvas : public QObject TestQgsMapCanvas() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. void testPanByKeyboard(); @@ -87,7 +87,6 @@ class TestQgsMapCanvas : public QObject }; - void TestQgsMapCanvas::initTestCase() { QgsApplication::init(); // init paths for CRS lookup @@ -138,7 +137,7 @@ void TestQgsMapCanvas::testSetExtent() QCOMPARE( mCanvas->extent().toString( 0 ), QStringLiteral( "-3,-3 : 13,13" ) ); QVERIFY( mCanvas->setReferencedExtent( QgsReferencedRectangle( QgsRectangle( 16259461, -2477192, 16391255, -2372535 ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ) ) ) ); QCOMPARE( mCanvas->extent().toString( 0 ), QStringLiteral( "146,-22 : 147,-21" ) ); - mCanvas->setDestinationCrs( QgsCoordinateReferenceSystem( ) ); + mCanvas->setDestinationCrs( QgsCoordinateReferenceSystem() ); } void TestQgsMapCanvas::testMagnification() @@ -169,8 +168,7 @@ void TestQgsMapCanvas::testMagnification() // build vector layer const QString myPointsFileName = testDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - QgsVectorLayer *layer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // prepare map canvas mCanvas->setLayers( QList() << layer ); @@ -231,8 +229,7 @@ void TestQgsMapCanvas::testMagnification() QCOMPARE( checker.compareImages( QStringLiteral( "map_magnification" ), 100 ), true ); } -void compareExtent( const QgsRectangle &initialExtent, - const QgsRectangle &extent ) +void compareExtent( const QgsRectangle &initialExtent, const QgsRectangle &extent ) { QGSCOMPARENEAR( initialExtent.xMinimum(), extent.xMinimum(), 0.00000000001 ); QGSCOMPARENEAR( initialExtent.xMaximum(), extent.xMaximum(), 0.00000000001 ); @@ -246,8 +243,7 @@ void TestQgsMapCanvas::testMagnificationExtent() const QString testDataDir = QStringLiteral( TEST_DATA_DIR ) + '/'; const QString myPointsFileName = testDataDir + "points.shp"; const QFileInfo myPointFileInfo( myPointsFileName ); - QgsVectorLayer *layer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + QgsVectorLayer *layer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); // prepare map canvas mCanvas->setLayers( QList() << layer ); @@ -375,25 +371,25 @@ void TestQgsMapCanvas::testZoomByWheel() mCanvas->setWheelFactor( 2 ); //test zoom out - std::unique_ptr< QWheelEvent > e = std::make_unique< QWheelEvent >( QPoint( 0, 0 ), QPointF(), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false ); + std::unique_ptr e = std::make_unique( QPoint( 0, 0 ), QPointF(), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false ); mCanvas->wheelEvent( e.get() ); QGSCOMPARENEAR( mCanvas->extent().width(), originalWidth * 2.0, 0.1 ); QGSCOMPARENEAR( mCanvas->extent().height(), originalHeight * 2.0, 0.1 ); //test zoom in - e = std::make_unique< QWheelEvent >( QPoint( 0, 0 ), QPointF(), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false ); + e = std::make_unique( QPoint( 0, 0 ), QPointF(), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false ); mCanvas->wheelEvent( e.get() ); QGSCOMPARENEAR( mCanvas->extent().width(), originalWidth, 0.1 ); QGSCOMPARENEAR( mCanvas->extent().height(), originalHeight, 0.1 ); // test zoom out with ctrl - e = std::make_unique< QWheelEvent >( QPoint( 0, 0 ), QPointF(), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, false ); + e = std::make_unique( QPoint( 0, 0 ), QPointF(), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, -QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, false ); mCanvas->wheelEvent( e.get() ); QGSCOMPARENEAR( mCanvas->extent().width(), 1.05 * originalWidth, 0.1 ); QGSCOMPARENEAR( mCanvas->extent().height(), 1.05 * originalHeight, 0.1 ); //test zoom in with ctrl - e = std::make_unique< QWheelEvent >( QPoint( 0, 0 ), QPointF(), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, false ); + e = std::make_unique( QPoint( 0, 0 ), QPointF(), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), QPoint( 0, QWheelEvent::DefaultDeltasPerStep ), Qt::NoButton, Qt::ControlModifier, Qt::NoScrollPhase, false ); mCanvas->wheelEvent( e.get() ); QGSCOMPARENEAR( mCanvas->extent().width(), originalWidth, 0.1 ); QGSCOMPARENEAR( mCanvas->extent().height(), originalHeight, 0.1 ); @@ -414,14 +410,11 @@ void TestQgsMapCanvas::testShiftZoom() // start by testing a tool with shift-zoom enabled mCanvas->setMapTool( &panTool ); - std::unique_ptr< QMouseEvent > e = std::make_unique< QMouseEvent >( QMouseEvent::MouseButtonPress, startPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + std::unique_ptr e = std::make_unique( QMouseEvent::MouseButtonPress, startPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mousePressEvent( e.get() ); - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseMove, endPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseMove, endPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mouseMoveEvent( e.get() ); - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseButtonRelease, endPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseButtonRelease, endPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mouseReleaseEvent( e.get() ); QGSCOMPARENEAR( mCanvas->extent().width(), originalWidth / 2.0, 0.2 ); @@ -431,14 +424,11 @@ void TestQgsMapCanvas::testShiftZoom() mCanvas->setExtent( QgsRectangle( 0, 0, 10, 10 ) ); //test that a shift-click (no movement) will not zoom - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseButtonPress, startPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseButtonPress, startPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mousePressEvent( e.get() ); - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseMove, startPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseMove, startPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mouseMoveEvent( e.get() ); - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseButtonRelease, startPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseButtonRelease, startPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mouseReleaseEvent( e.get() ); QGSCOMPARENEAR( mCanvas->extent().width(), originalWidth, 0.0001 ); @@ -451,14 +441,11 @@ void TestQgsMapCanvas::testShiftZoom() QgsMapToolTest mapTool( mCanvas ); mCanvas->setMapTool( &mapTool ); - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseButtonPress, startPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseButtonPress, startPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mousePressEvent( e.get() ); - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseMove, endPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseMove, endPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mouseMoveEvent( e.get() ); - e = std::make_unique< QMouseEvent >( QMouseEvent::MouseButtonRelease, endPos, - Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); + e = std::make_unique( QMouseEvent::MouseButtonRelease, endPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier ); mCanvas->mouseReleaseEvent( e.get() ); QGSCOMPARENEAR( mCanvas->extent().width(), originalWidth, 0.00001 ); @@ -470,7 +457,6 @@ class TestNoDropHandler : public QgsCustomDropHandler Q_OBJECT public: - QString customUriProviderKey() const override { return QStringLiteral( "test" ); } bool canHandleCustomUriCanvasDrop( const QgsMimeDataUtils::Uri &, QgsMapCanvas * ) override { return false; } bool handleCustomUriCanvasDrop( const QgsMimeDataUtils::Uri &, QgsMapCanvas * ) const override { return false; } @@ -481,7 +467,6 @@ class TestYesDropHandler : public QgsCustomDropHandler Q_OBJECT public: - QString customUriProviderKey() const override { return QStringLiteral( "test" ); } bool canHandleCustomUriCanvasDrop( const QgsMimeDataUtils::Uri &, QgsMapCanvas * ) override { return true; } bool handleCustomUriCanvasDrop( const QgsMimeDataUtils::Uri &, QgsMapCanvas * ) const override { return true; } @@ -490,8 +475,8 @@ class TestYesDropHandler : public QgsCustomDropHandler void TestQgsMapCanvas::testDragDrop() { // default drag, should not be accepted - std::unique_ptr< QMimeData > data = std::make_unique< QMimeData >(); - std::unique_ptr< QDragEnterEvent > event = std::make_unique< QDragEnterEvent >( QPoint( 10, 10 ), Qt::CopyAction, data.get(), Qt::LeftButton, Qt::NoModifier ); + std::unique_ptr data = std::make_unique(); + std::unique_ptr event = std::make_unique( QPoint( 10, 10 ), Qt::CopyAction, data.get(), Qt::LeftButton, Qt::NoModifier ); mCanvas->dragEnterEvent( event.get() ); QVERIFY( !event->isAccepted() ); @@ -502,33 +487,33 @@ void TestQgsMapCanvas::testDragDrop() uri.providerKey = QStringLiteral( "test" ); list << uri; data.reset( QgsMimeDataUtils::encodeUriList( list ) ); - event = std::make_unique< QDragEnterEvent >( QPoint( 10, 10 ), Qt::CopyAction, data.get(), Qt::LeftButton, Qt::NoModifier ); + event = std::make_unique( QPoint( 10, 10 ), Qt::CopyAction, data.get(), Qt::LeftButton, Qt::NoModifier ); mCanvas->dragEnterEvent( event.get() ); // still not accepted by default QVERIFY( !event->isAccepted() ); // add a custom drop handler to the canvas TestNoDropHandler handler; - mCanvas->setCustomDropHandlers( QVector< QPointer< QgsCustomDropHandler > >() << &handler ); + mCanvas->setCustomDropHandlers( QVector>() << &handler ); mCanvas->dragEnterEvent( event.get() ); // not accepted by handler QVERIFY( !event->isAccepted() ); TestYesDropHandler handler2; - mCanvas->setCustomDropHandlers( QVector< QPointer< QgsCustomDropHandler > >() << &handler << &handler2 ); + mCanvas->setCustomDropHandlers( QVector>() << &handler << &handler2 ); mCanvas->dragEnterEvent( event.get() ); // IS accepted by handler QVERIFY( event->isAccepted() ); // check drop event logic - mCanvas->setCustomDropHandlers( QVector< QPointer< QgsCustomDropHandler > >() ); - std::unique_ptr< QDropEvent > dropEvent = std::make_unique< QDropEvent >( QPoint( 10, 10 ), Qt::CopyAction, data.get(), Qt::LeftButton, Qt::NoModifier ); + mCanvas->setCustomDropHandlers( QVector>() ); + std::unique_ptr dropEvent = std::make_unique( QPoint( 10, 10 ), Qt::CopyAction, data.get(), Qt::LeftButton, Qt::NoModifier ); mCanvas->dropEvent( dropEvent.get() ); QVERIFY( !dropEvent->isAccepted() ); - mCanvas->setCustomDropHandlers( QVector< QPointer< QgsCustomDropHandler > >() << &handler ); + mCanvas->setCustomDropHandlers( QVector>() << &handler ); mCanvas->dropEvent( dropEvent.get() ); QVERIFY( !dropEvent->isAccepted() ); - mCanvas->setCustomDropHandlers( QVector< QPointer< QgsCustomDropHandler > >() << &handler << &handler2 ); + mCanvas->setCustomDropHandlers( QVector>() << &handler << &handler2 ); mCanvas->dropEvent( dropEvent.get() ); // is accepted! QVERIFY( dropEvent->isAccepted() ); @@ -611,13 +596,13 @@ void TestQgsMapCanvas::testMapLayers() QVERIFY( vl1->isValid() ); QgsProject::instance()->addMapLayer( vl1 ); - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:3946&field=halig:string&field=valig:string" ), QStringLiteral( "vl2" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=halig:string&field=valig:string" ), QStringLiteral( "vl2" ), QStringLiteral( "memory" ) ); QVERIFY( vl2->isValid() ); - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setLayers( { vl1, vl2.get() } ); - QCOMPARE( canvas->layers(), QList< QgsMapLayer * >( { vl1, vl2.get() } ) ); + QCOMPARE( canvas->layers(), QList( { vl1, vl2.get() } ) ); // retrieving layer by id should work for both layers from the project AND for freestanding layers QCOMPARE( canvas->layer( vl1->id() ), vl1 ); QCOMPARE( canvas->layer( vl2->id() ), vl2.get() ); diff --git a/tests/src/gui/testqgsmaptoolcapture.cpp b/tests/src/gui/testqgsmaptoolcapture.cpp index 2c70007e4f58..0695dacd2a29 100644 --- a/tests/src/gui/testqgsmaptoolcapture.cpp +++ b/tests/src/gui/testqgsmaptoolcapture.cpp @@ -30,15 +30,14 @@ class TestQgsMapToolCapture : public QObject TestQgsMapToolCapture() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void addVertexNoLayer(); void addVertexNonVectorLayer(); void addVertexNonVectorLayerTransform(); - }; void TestQgsMapToolCapture::initTestCase() @@ -120,7 +119,6 @@ void TestQgsMapToolCapture::addVertexNonVectorLayer() QCOMPARE( tool.nextPoint( QgsPoint( 5, 6 ), layerPoint ), 0 ); QCOMPARE( layerPoint.x(), 5.0 ); QCOMPARE( layerPoint.y(), 6.0 ); - } void TestQgsMapToolCapture::addVertexNonVectorLayerTransform() diff --git a/tests/src/gui/testqgsmaptooledit.cpp b/tests/src/gui/testqgsmaptooledit.cpp index 48da28d217d1..edc444b4ac8e 100644 --- a/tests/src/gui/testqgsmaptooledit.cpp +++ b/tests/src/gui/testqgsmaptooledit.cpp @@ -30,10 +30,10 @@ class TestQgsMapToolEdit : public QObject TestQgsMapToolEdit() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void checkDefaultZValue(); void checkDefaultMValue(); @@ -41,7 +41,6 @@ class TestQgsMapToolEdit : public QObject private: QgsMapCanvas *mCanvas = nullptr; - }; void TestQgsMapToolEdit::initTestCase() @@ -101,13 +100,13 @@ void TestQgsMapToolEdit::checkLayers() QVERIFY( vl1->isValid() ); QgsProject::instance()->addMapLayer( vl1 ); - std::unique_ptr< QgsVectorLayer > vl2 = std::make_unique< QgsVectorLayer >( QStringLiteral( "Point?crs=epsg:3946&field=halig:string&field=valig:string" ), QStringLiteral( "vl2" ), QStringLiteral( "memory" ) ); + std::unique_ptr vl2 = std::make_unique( QStringLiteral( "Point?crs=epsg:3946&field=halig:string&field=valig:string" ), QStringLiteral( "vl2" ), QStringLiteral( "memory" ) ); QVERIFY( vl2->isValid() ); - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setLayers( { vl1, vl2.get() } ); - std::unique_ptr< QgsMapToolEdit > tool = std::make_unique< QgsMapToolEdit >( canvas.get() ); + std::unique_ptr tool = std::make_unique( canvas.get() ); // retrieving layer by id should work for both layers from the project AND for freestanding layers QCOMPARE( tool->layer( vl1->id() ), vl1 ); diff --git a/tests/src/gui/testqgsmaptoolzoom.cpp b/tests/src/gui/testqgsmaptoolzoom.cpp index 74b6b6c5df39..c577ccef9e12 100644 --- a/tests/src/gui/testqgsmaptoolzoom.cpp +++ b/tests/src/gui/testqgsmaptoolzoom.cpp @@ -32,11 +32,12 @@ class TestQgsMapToolZoom : public QObject TestQgsMapToolZoom() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void zeroDragArea(); + private: QgsMapCanvas *canvas = nullptr; }; @@ -71,12 +72,9 @@ void TestQgsMapToolZoom::cleanup() void TestQgsMapToolZoom::zeroDragArea() { const QPoint point = QPoint( 15, 15 ); - QMouseEvent press( QEvent::MouseButtonPress, point, - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); - QMouseEvent move( QEvent::MouseMove, point, - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); - QMouseEvent releases( QEvent::MouseButtonRelease, point, - Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); + QMouseEvent press( QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); + QMouseEvent move( QEvent::MouseMove, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); + QMouseEvent releases( QEvent::MouseButtonRelease, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier ); QgsMapMouseEvent mapPress( nullptr, &press ); QgsMapMouseEvent mapMove( nullptr, &move ); @@ -99,7 +97,3 @@ void TestQgsMapToolZoom::zeroDragArea() QGSTEST_MAIN( TestQgsMapToolZoom ) #include "testqgsmaptoolzoom.moc" - - - - diff --git a/tests/src/gui/testqgsmaskingwidget.cpp b/tests/src/gui/testqgsmaskingwidget.cpp index 8aece0f1acd3..92b4ff449f37 100644 --- a/tests/src/gui/testqgsmaskingwidget.cpp +++ b/tests/src/gui/testqgsmaskingwidget.cpp @@ -31,14 +31,14 @@ class TestQgsMaskingWidget : public QgsTest Q_OBJECT public: - - TestQgsMaskingWidget() : QgsTest( QStringLiteral( "Masking widget Tests" ) ) {} + TestQgsMaskingWidget() + : QgsTest( QStringLiteral( "Masking widget Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testTreeWidget(); }; @@ -90,7 +90,7 @@ void TestQgsMaskingWidget::testTreeWidget() polys->labeling()->setSettings( labelSettings ); QgsMaskMarkerSymbolLayer *maskLayer = new QgsMaskMarkerSymbolLayer(); - maskLayer->setSubSymbol( QgsMarkerSymbol::createSimple( { {QStringLiteral( "size" ), 6 } } ) ); + maskLayer->setSubSymbol( QgsMarkerSymbol::createSimple( { { QStringLiteral( "size" ), 6 } } ) ); QgsCategorizedSymbolRenderer *renderer = dynamic_cast( points->renderer() ); QVERIFY( renderer ); const QgsCategoryList categories = renderer->categories(); diff --git a/tests/src/gui/testqgsmeshlayerpropertiesdialog.cpp b/tests/src/gui/testqgsmeshlayerpropertiesdialog.cpp index e9df888eaaa5..adb8fd55b6b9 100644 --- a/tests/src/gui/testqgsmeshlayerpropertiesdialog.cpp +++ b/tests/src/gui/testqgsmeshlayerpropertiesdialog.cpp @@ -35,10 +35,10 @@ class TestQgsMeshLayerPropertiesDialog : public QObject TestQgsMeshLayerPropertiesDialog(); private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testInvalidLayer(); void testCrs(); @@ -63,7 +63,8 @@ void TestQgsMeshLayerPropertiesDialog::initTestCase() mpMeshLayer = new QgsMeshLayer( uri, "Triangle and Quad MDAL", "mdal" ); QgsProject::instance()->addMapLayers( - QList() << mpMeshLayer ); + QList() << mpMeshLayer + ); } //runs after all tests @@ -76,8 +77,7 @@ void TestQgsMeshLayerPropertiesDialog::testInvalidLayer() { QgsMeshLayer invalidLayer; QgsMapCanvas mapCanvas; - const std::unique_ptr< QgsMeshLayerProperties > dialog = std::make_unique< QgsMeshLayerProperties > ( &invalidLayer, - &mapCanvas ); + const std::unique_ptr dialog = std::make_unique( &invalidLayer, &mapCanvas ); QVERIFY( dialog ); } @@ -85,8 +85,7 @@ void TestQgsMeshLayerPropertiesDialog::testInvalidLayer() void TestQgsMeshLayerPropertiesDialog::testCrs() { QgsMapCanvas mapCanvas; - std::unique_ptr< QgsMeshLayerProperties > dialog = std::make_unique< QgsMeshLayerProperties > ( mpMeshLayer, - &mapCanvas ); + std::unique_ptr dialog = std::make_unique( mpMeshLayer, &mapCanvas ); QCOMPARE( dialog->mCrsSelector->crs(), mpMeshLayer->crs() ); const QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromEpsgId( 27700 ); dialog->mCrsSelector->setCrs( crs ); @@ -115,7 +114,6 @@ void TestQgsMeshLayerPropertiesDialog::testDatasetGroupTree() meshLayer.setDatasetGroupTreeRootItem( rootItem.get() ); QCOMPARE( activeDatasetWidget.activeScalarDatasetGroup(), 0 ); - } QGSTEST_MAIN( TestQgsMeshLayerPropertiesDialog ) diff --git a/tests/src/gui/testqgsmessagebar.cpp b/tests/src/gui/testqgsmessagebar.cpp index dca48141e667..cddd1354ce6a 100644 --- a/tests/src/gui/testqgsmessagebar.cpp +++ b/tests/src/gui/testqgsmessagebar.cpp @@ -20,23 +20,21 @@ #include "qgsmessagebaritem.h" #include -class TestQgsMessageBar: public QObject +class TestQgsMessageBar : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void dismiss(); void pushPop(); void autoDelete(); - }; void TestQgsMessageBar::initTestCase() { - } void TestQgsMessageBar::cleanupTestCase() @@ -58,7 +56,7 @@ void TestQgsMessageBar::dismiss() QVERIFY( !bar.currentItem() ); QgsMessageBarItem *item = new QgsMessageBarItem( QStringLiteral( "test" ) ); - const QPointer< QgsMessageBarItem > pItem( item ); + const QPointer pItem( item ); item->dismiss(); // should do nothing, not in a bar yet QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); for ( int i = 1; i < 100; ++i ) @@ -92,17 +90,17 @@ void TestQgsMessageBar::pushPop() QCOMPARE( bar.items().size(), 1 ); QCOMPARE( bar.items().at( 0 )->text(), QStringLiteral( "1" ) ); QCOMPARE( bar.currentItem()->text(), QStringLiteral( "1" ) ); - const QPointer< QgsMessageBarItem > item1 = bar.currentItem(); + const QPointer item1 = bar.currentItem(); // make sure correct item is the visible one - QCOMPARE( qobject_cast< QgsMessageBarItem * >( qgis::down_cast< QGridLayout * >( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "1" ) ); + QCOMPARE( qobject_cast( qgis::down_cast( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "1" ) ); bar.pushMessage( QStringLiteral( "2" ) ); QCOMPARE( bar.items().size(), 2 ); QCOMPARE( bar.items().at( 0 )->text(), QStringLiteral( "2" ) ); QCOMPARE( bar.items().at( 1 )->text(), QStringLiteral( "1" ) ); QCOMPARE( bar.currentItem()->text(), QStringLiteral( "2" ) ); - const QPointer< QgsMessageBarItem > item2 = bar.currentItem(); - QCOMPARE( qobject_cast< QgsMessageBarItem * >( qgis::down_cast< QGridLayout * >( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "2" ) ); + const QPointer item2 = bar.currentItem(); + QCOMPARE( qobject_cast( qgis::down_cast( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "2" ) ); bar.pushMessage( QStringLiteral( "3" ) ); QCOMPARE( bar.items().size(), 3 ); @@ -110,8 +108,8 @@ void TestQgsMessageBar::pushPop() QCOMPARE( bar.items().at( 1 )->text(), QStringLiteral( "2" ) ); QCOMPARE( bar.items().at( 2 )->text(), QStringLiteral( "1" ) ); QCOMPARE( bar.currentItem()->text(), QStringLiteral( "3" ) ); - const QPointer< QgsMessageBarItem > item3 = bar.currentItem(); - QCOMPARE( qobject_cast< QgsMessageBarItem * >( qgis::down_cast< QGridLayout * >( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "3" ) ); + const QPointer item3 = bar.currentItem(); + QCOMPARE( qobject_cast( qgis::down_cast( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "3" ) ); const int childCount = bar.children().count(); QVERIFY( bar.popWidget() ); @@ -119,7 +117,7 @@ void TestQgsMessageBar::pushPop() QCOMPARE( bar.items().at( 0 )->text(), QStringLiteral( "2" ) ); QCOMPARE( bar.items().at( 1 )->text(), QStringLiteral( "1" ) ); QCOMPARE( bar.currentItem()->text(), QStringLiteral( "2" ) ); - QCOMPARE( qobject_cast< QgsMessageBarItem * >( qgis::down_cast< QGridLayout * >( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "2" ) ); + QCOMPARE( qobject_cast( qgis::down_cast( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "2" ) ); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); QCOMPARE( bar.children().count(), childCount - 1 ); QVERIFY( !item3 ); @@ -128,7 +126,7 @@ void TestQgsMessageBar::pushPop() QCOMPARE( bar.items().size(), 1 ); QCOMPARE( bar.items().at( 0 )->text(), QStringLiteral( "1" ) ); QCOMPARE( bar.currentItem()->text(), QStringLiteral( "1" ) ); - QCOMPARE( qobject_cast< QgsMessageBarItem * >( qgis::down_cast< QGridLayout * >( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "1" ) ); + QCOMPARE( qobject_cast( qgis::down_cast( bar.layout() )->itemAt( 3 )->widget() )->text(), QStringLiteral( "1" ) ); QgsApplication::sendPostedEvents( nullptr, QEvent::DeferredDelete ); QCOMPARE( bar.children().count(), childCount - 2 ); QVERIFY( !item2 ); @@ -156,7 +154,7 @@ void TestQgsMessageBar::autoDelete() QCOMPARE( bar.items().size(), 100 ); QCOMPARE( bar.items().at( 0 )->text(), QStringLiteral( "99" ) ); QCOMPARE( bar.items().at( 99 )->text(), QStringLiteral( "0" ) ); - const QPointer< QgsMessageBarItem > oldest = bar.items().at( 99 ); + const QPointer oldest = bar.items().at( 99 ); // push one more item, oldest one should be auto-removed bar.pushMessage( QStringLiteral( "100" ), Qgis::MessageLevel::Warning ); diff --git a/tests/src/gui/testqgsnewdatabasetablewidget.cpp b/tests/src/gui/testqgsnewdatabasetablewidget.cpp index 47b0c34a3784..621ecb2ced66 100644 --- a/tests/src/gui/testqgsnewdatabasetablewidget.cpp +++ b/tests/src/gui/testqgsnewdatabasetablewidget.cpp @@ -26,24 +26,23 @@ #include "qgsabstractproviderconnection.h" #include "qgsdataitem.h" -class TestQgsNewDatabaseTableNameWidget: public QObject +class TestQgsNewDatabaseTableNameWidget : public QObject { Q_OBJECT public: TestQgsNewDatabaseTableNameWidget() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testWidgetFilters(); void testWidgetSignalsPostgres(); void testWidgetSignalsGeopackage(); private: - std::unique_ptr mPgConn; std::unique_ptr mGpkgConn; QTemporaryDir mDir; @@ -52,7 +51,6 @@ class TestQgsNewDatabaseTableNameWidget: public QObject void TestQgsNewDatabaseTableNameWidget::initTestCase() { - QCoreApplication::setOrganizationName( QStringLiteral( "QGIS" ) ); QCoreApplication::setOrganizationDomain( QStringLiteral( "qgis.org" ) ); QCoreApplication::setApplicationName( QStringLiteral( "QGIS-TEST-NEW-DBTABLE-WIDGET" ) ); @@ -64,7 +62,7 @@ void TestQgsNewDatabaseTableNameWidget::initTestCase() QgsProviderMetadata *md = nullptr; #ifdef ENABLE_PGTEST md = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "postgres" ) ); - mPgConn.reset( md->createConnection( qgetenv( "QGIS_PGTEST_DB" ), { } ) ); + mPgConn.reset( md->createConnection( qgetenv( "QGIS_PGTEST_DB" ), {} ) ); md->saveConnection( mPgConn.get(), QStringLiteral( "PG_1" ) ); md->saveConnection( mPgConn.get(), QStringLiteral( "PG_2" ) ); #endif @@ -74,18 +72,10 @@ void TestQgsNewDatabaseTableNameWidget::initTestCase() QMap m; mGpkgPath = mDir.filePath( QStringLiteral( "test.gpkg" ) ); const QMap options { { QStringLiteral( "layerName" ), QString( "test_layer" ) } }; - QVERIFY( md->createEmptyLayer( mGpkgPath, - QgsFields(), - Qgis::WkbType::Point, - QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), - true, - m, - errCause, - &options ) == Qgis::VectorExportResult::Success ); + QVERIFY( md->createEmptyLayer( mGpkgPath, QgsFields(), Qgis::WkbType::Point, QgsCoordinateReferenceSystem::fromEpsgId( 4326 ), true, m, errCause, &options ) == Qgis::VectorExportResult::Success ); QVERIFY( errCause.isEmpty() ); - mGpkgConn.reset( md->createConnection( mDir.filePath( QStringLiteral( "test.gpkg" ) ), { } ) ); + mGpkgConn.reset( md->createConnection( mDir.filePath( QStringLiteral( "test.gpkg" ) ), {} ) ); md->saveConnection( mGpkgConn.get(), QStringLiteral( "GPKG_1" ) ); - } void TestQgsNewDatabaseTableNameWidget::cleanupTestCase() @@ -103,11 +93,11 @@ void TestQgsNewDatabaseTableNameWidget::cleanup() void TestQgsNewDatabaseTableNameWidget::testWidgetFilters() { - std::unique_ptr w { std::make_unique( nullptr, QStringList{ "NOT_EXISTS" } ) }; + std::unique_ptr w { std::make_unique( nullptr, QStringList { "NOT_EXISTS" } ) }; QCOMPARE( w->mBrowserProxyModel.rowCount(), 0 ); std::unique_ptr w2 { std::make_unique( nullptr ) }; QVERIFY( w2->mBrowserProxyModel.rowCount() > 0 ); - std::unique_ptr w3 { std::make_unique( nullptr, QStringList{ "postgres" } ) }; + std::unique_ptr w3 { std::make_unique( nullptr, QStringList { "postgres" } ) }; QVERIFY( w3->mBrowserProxyModel.rowCount() > 0 ); } @@ -115,14 +105,14 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetFilters() void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsPostgres() { #ifdef ENABLE_PGTEST - std::unique_ptr w { std::make_unique( nullptr, QStringList{ "postgres" } ) }; + std::unique_ptr w { std::make_unique( nullptr, QStringList { "postgres" } ) }; auto index = w->mBrowserModel->findPath( QStringLiteral( "pg:/PG_1" ) ); QVERIFY( index.isValid() ); w->mBrowserModel->dataItem( index )->populate( true ); w->mBrowserTreeView->expandAll(); - QVERIFY( ! w->isValid() ); + QVERIFY( !w->isValid() ); QSignalSpy validationSpy( w.get(), SIGNAL( validationChanged( bool ) ) ); QSignalSpy schemaSpy( w.get(), SIGNAL( schemaNameChanged( QString ) ) ); @@ -137,7 +127,7 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsPostgres() QVERIFY( rect.isValid() ); QTest::mouseClick( w->mBrowserTreeView->viewport(), Qt::LeftButton, Qt::KeyboardModifiers(), rect.topLeft() ); - QVERIFY( ! w->isValid() ); + QVERIFY( !w->isValid() ); /* QDialog d; @@ -163,7 +153,7 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsPostgres() QVERIFY( rect.isValid() ); QTest::mouseClick( w->mBrowserTreeView->viewport(), Qt::LeftButton, Qt::KeyboardModifiers(), rect.center() ); - QVERIFY( ! w->isValid() ); + QVERIFY( !w->isValid() ); QCOMPARE( validationSpy.count(), 0 ); QCOMPARE( schemaSpy.count(), 1 ); @@ -171,7 +161,7 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsPostgres() arguments = schemaSpy.takeLast(); QCOMPARE( arguments.at( 0 ).toString(), QString( "qgis_test" ) ); arguments = uriSpy.takeLast(); - QVERIFY( ! arguments.at( 0 ).toString().isEmpty() ); + QVERIFY( !arguments.at( 0 ).toString().isEmpty() ); w->mNewTableName->setText( QStringLiteral( "someNewTableData" ) ); //#spellok QCOMPARE( tableSpy.count(), 1 ); @@ -190,7 +180,7 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsPostgres() // Test unique and make it invalid again so we get a status change w->mNewTableName->setText( QStringLiteral( "someData" ) ); - QVERIFY( ! w->isValid() ); + QVERIFY( !w->isValid() ); QCOMPARE( tableSpy.count(), 1 ); arguments = tableSpy.takeLast(); QCOMPARE( arguments.at( 0 ).toString(), QString( "someData" ) ); @@ -225,14 +215,14 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsPostgres() void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsGeopackage() { #ifdef ENABLE_PGTEST - std::unique_ptr w { std::make_unique( nullptr, QStringList{ "ogr" } ) }; + std::unique_ptr w { std::make_unique( nullptr, QStringList { "ogr" } ) }; auto index = w->mBrowserModel->findPath( QStringLiteral( "pg:/PG_1" ) ); QVERIFY( index.isValid() ); w->mBrowserModel->dataItem( index )->populate( true ); w->mBrowserTreeView->expandAll(); - QVERIFY( ! w->isValid() ); + QVERIFY( !w->isValid() ); QSignalSpy validationSpy( w.get(), SIGNAL( validationChanged( bool ) ) ); QSignalSpy schemaSpy( w.get(), SIGNAL( schemaNameChanged( QString ) ) ); @@ -256,7 +246,7 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsGeopackage() QVERIFY( rect.isValid() ); QTest::mouseClick( w->mBrowserTreeView->viewport(), Qt::LeftButton, Qt::KeyboardModifiers(), rect.center() ); - QVERIFY( ! w->isValid() ); + QVERIFY( !w->isValid() ); QCOMPARE( schemaSpy.count(), 1 ); auto arguments = schemaSpy.takeLast(); QCOMPARE( arguments.at( 0 ).toString(), mGpkgPath ); @@ -280,5 +270,3 @@ void TestQgsNewDatabaseTableNameWidget::testWidgetSignalsGeopackage() QGSTEST_MAIN( TestQgsNewDatabaseTableNameWidget ) #include "testqgsnewdatabasetablewidget.moc" - - diff --git a/tests/src/gui/testqgsogrprovidergui.cpp b/tests/src/gui/testqgsogrprovidergui.cpp index cea52024ee5b..a965f33e47f2 100644 --- a/tests/src/gui/testqgsogrprovidergui.cpp +++ b/tests/src/gui/testqgsogrprovidergui.cpp @@ -33,10 +33,10 @@ class TestQgsOgrProviderGui : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void providersRegistered(); //! Test GPKG data items rename @@ -84,9 +84,9 @@ void TestQgsOgrProviderGui::testGpkgDataItemRename() QTemporaryFile f( QStringLiteral( "qgis-XXXXXX.gpkg" ) ); f.open(); f.close(); - const QString fileName { f.fileName( ) }; + const QString fileName { f.fileName() }; f.remove(); - QVERIFY( QFile::copy( QStringLiteral( "%1/provider/bug_21227-rename-styles.gpkg" ).arg( mTestDataDir ), fileName ) ); + QVERIFY( QFile::copy( QStringLiteral( "%1/provider/bug_21227-rename-styles.gpkg" ).arg( mTestDataDir ), fileName ) ); // create geopackage item and populate it with layers QgsGeoPackageCollectionItem gpkgItem( nullptr, QStringLiteral( "test gpkg" ), QStringLiteral( "gpkg:/%1" ).arg( fileName ) ); diff --git a/tests/src/gui/testqgsprocessingmodel.cpp b/tests/src/gui/testqgsprocessingmodel.cpp index 772eebe6b3ec..4f898b55ccc9 100644 --- a/tests/src/gui/testqgsprocessingmodel.cpp +++ b/tests/src/gui/testqgsprocessingmodel.cpp @@ -33,12 +33,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm { public: - - DummyAlgorithm( const QString &name, const QString &group, - Qgis::ProcessingAlgorithmFlags flags = Qgis::ProcessingAlgorithmFlags(), - const QString &tags = QString(), - const QString &shortDescription = QString(), - const QString &displayName = QString() ) + DummyAlgorithm( const QString &name, const QString &group, Qgis::ProcessingAlgorithmFlags flags = Qgis::ProcessingAlgorithmFlags(), const QString &tags = QString(), const QString &shortDescription = QString(), const QString &displayName = QString() ) : mName( name ) , mDisplayName( displayName ) , mGroup( group ) @@ -65,19 +60,16 @@ class DummyAlgorithm : public QgsProcessingAlgorithm Qgis::ProcessingAlgorithmFlags mFlags = Qgis::ProcessingAlgorithmFlags(); QStringList mTags; QString mShortDescription; - }; //dummy provider for testing class DummyProvider : public QgsProcessingProvider // clazy:exclude=missing-qobject-macro { public: - - DummyProvider( const QString &id, const QString &name, const QList< QgsProcessingAlgorithm *> algs = QList< QgsProcessingAlgorithm *>() ) + DummyProvider( const QString &id, const QString &name, const QList algs = QList() ) : mId( id ) , mName( name ) , mAlgs( algs ) { - } ~DummyProvider() override { @@ -88,8 +80,9 @@ class DummyProvider : public QgsProcessingProvider // clazy:exclude=missing-qobj bool isActive() const override { return mActive; } QString name() const override { return mName; } - QString longName() const override { return QStringLiteral( "long name %1" ).arg( mName );} + QString longName() const override { return QStringLiteral( "long name %1" ).arg( mName ); } bool mActive = true; + protected: void loadAlgorithms() override { @@ -99,20 +92,19 @@ class DummyProvider : public QgsProcessingProvider // clazy:exclude=missing-qobj QString mId; QString mName; - QList< QgsProcessingAlgorithm *> mAlgs; - + QList mAlgs; }; -class TestQgsProcessingModel: public QObject +class TestQgsProcessingModel : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testModel(); void testKnownIssues(); void testProxyModel(); @@ -210,7 +202,7 @@ void TestQgsProcessingModel::testModel() // provider with algs and groups DummyAlgorithm *a1 = new DummyAlgorithm( "a1", "group1", Qgis::ProcessingAlgorithmFlag::HideFromModeler, QStringLiteral( "tag1,tag2" ), QStringLiteral( "short desc a" ) ); DummyAlgorithm *a2 = new DummyAlgorithm( "a2", "group2", Qgis::ProcessingAlgorithmFlag::HideFromToolbox ); - DummyProvider *p3 = new DummyProvider( "p3", "provider3", QList< QgsProcessingAlgorithm * >() << a1 << a2 ); + DummyProvider *p3 = new DummyProvider( "p3", "provider3", QList() << a1 << a2 ); registry.addProvider( p3 ); QCOMPARE( model.rowCount(), 5 ); @@ -242,11 +234,11 @@ void TestQgsProcessingModel::testModel() QVERIFY( !model.providerForIndex( alg1Index ) ); QCOMPARE( model.data( alg1Index, Qt::DisplayRole ).toString(), QStringLiteral( "a1" ) ); QCOMPARE( model.data( alg1Index, Qt::ToolTipRole ).toString(), QStringLiteral( u"

    a1

    short desc a

    Algorithm ID: \u2018p3:a1\u2019

    " ) ); - QCOMPARE( model.data( alg1Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmFlags ) ).toInt(), static_cast< int >( Qgis::ProcessingAlgorithmFlag::HideFromModeler ) ); - QCOMPARE( model.data( alg1Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p3:a1" ) ); - QCOMPARE( model.data( alg1Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmName ) ).toString(), QStringLiteral( "a1" ) ); - QCOMPARE( model.data( alg1Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmTags ) ).toStringList().join( ',' ), QStringLiteral( "tag1,tag2" ) ); - QCOMPARE( model.data( alg1Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmShortDescription ) ).toString(), QStringLiteral( "short desc a" ) ); + QCOMPARE( model.data( alg1Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmFlags ) ).toInt(), static_cast( Qgis::ProcessingAlgorithmFlag::HideFromModeler ) ); + QCOMPARE( model.data( alg1Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p3:a1" ) ); + QCOMPARE( model.data( alg1Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmName ) ).toString(), QStringLiteral( "a1" ) ); + QCOMPARE( model.data( alg1Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmTags ) ).toStringList().join( ',' ), QStringLiteral( "tag1,tag2" ) ); + QCOMPARE( model.data( alg1Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmShortDescription ) ).toString(), QStringLiteral( "short desc a" ) ); QCOMPARE( model.algorithmForIndex( alg1Index )->id(), QStringLiteral( "p3:a1" ) ); @@ -256,17 +248,17 @@ void TestQgsProcessingModel::testModel() QModelIndex alg2Index = model.index( 0, 0, group2Index ); QCOMPARE( model.data( alg2Index, Qt::DisplayRole ).toString(), QStringLiteral( "a2" ) ); QCOMPARE( model.data( alg2Index, Qt::ToolTipRole ).toString(), QStringLiteral( u"

    a2

    Algorithm ID: \u2018p3:a2\u2019

    " ) ); - QCOMPARE( model.data( alg2Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmFlags ) ).toInt(), static_cast< int >( Qgis::ProcessingAlgorithmFlag::HideFromToolbox ) ); - QCOMPARE( model.data( alg2Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p3:a2" ) ); - QCOMPARE( model.data( alg2Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmName ) ).toString(), QStringLiteral( "a2" ) ); - QCOMPARE( model.data( alg2Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmTags ) ).toStringList().join( ',' ), QString() ); - QCOMPARE( model.data( alg2Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmShortDescription ) ).toString(), QString() ); + QCOMPARE( model.data( alg2Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmFlags ) ).toInt(), static_cast( Qgis::ProcessingAlgorithmFlag::HideFromToolbox ) ); + QCOMPARE( model.data( alg2Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p3:a2" ) ); + QCOMPARE( model.data( alg2Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmName ) ).toString(), QStringLiteral( "a2" ) ); + QCOMPARE( model.data( alg2Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmTags ) ).toStringList().join( ',' ), QString() ); + QCOMPARE( model.data( alg2Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmShortDescription ) ).toString(), QString() ); QCOMPARE( model.algorithmForIndex( alg2Index )->id(), QStringLiteral( "p3:a2" ) ); // combined groups DummyAlgorithm *a3 = new DummyAlgorithm( "a3", "group1" ); DummyAlgorithm *a4 = new DummyAlgorithm( "a4", "group1" ); - DummyProvider *p4 = new DummyProvider( "p4", "provider4", QList< QgsProcessingAlgorithm * >() << a3 << a4 ); + DummyProvider *p4 = new DummyProvider( "p4", "provider4", QList() << a3 << a4 ); registry.addProvider( p4 ); const QModelIndex p4ProviderIndex = model.indexForProvider( p4->id() ); QModelIndex groupIndex = model.index( 0, 0, p4ProviderIndex ); @@ -278,7 +270,7 @@ void TestQgsProcessingModel::testModel() DummyAlgorithm *a5 = new DummyAlgorithm( "a5", "group1" ); DummyAlgorithm *a6 = new DummyAlgorithm( "a6", QString() ); DummyAlgorithm *a7 = new DummyAlgorithm( "a7", "group2" ); - DummyProvider *p5 = new DummyProvider( "p5", "provider5", QList< QgsProcessingAlgorithm * >() << a5 << a6 << a7 ); + DummyProvider *p5 = new DummyProvider( "p5", "provider5", QList() << a5 << a6 << a7 ); registry.addProvider( p5 ); QCOMPARE( model.rowCount(), 7 ); QModelIndex p5ProviderIndex = model.indexForProvider( p5->id() ); @@ -329,14 +321,14 @@ void TestQgsProcessingModel::testModel() QCOMPARE( model.rowCount( recentIndex ), 0 ); recentLog.push( QStringLiteral( "p5:a5" ) ); QCOMPARE( model.rowCount( recentIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); recentLog.push( QStringLiteral( "not valid" ) ); QCOMPARE( model.rowCount( recentIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); recentLog.push( QStringLiteral( "p4:a3" ) ); QCOMPARE( model.rowCount( recentIndex ), 2 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); - QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); + QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); // favorite algorithms QModelIndex favoriteIndex = model.index( 1, 0, QModelIndex() ); @@ -344,24 +336,24 @@ void TestQgsProcessingModel::testModel() QCOMPARE( model.rowCount( favoriteIndex ), 0 ); favoriteManager.add( QStringLiteral( "p5:a5" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); favoriteManager.add( QStringLiteral( "not valid" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); favoriteManager.add( QStringLiteral( "p4:a3" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 2 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); - QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); + QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); favoriteManager.remove( QStringLiteral( "p5:a5" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); favoriteManager.clear(); QCOMPARE( model.rowCount( favoriteIndex ), 0 ); favoriteManager.add( QStringLiteral( "p5:a5" ) ); favoriteManager.add( QStringLiteral( "p4:a3" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 2 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); - QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p5:a5" ) ); + QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); // remove a provider registry.removeProvider( p1 ); @@ -373,10 +365,10 @@ void TestQgsProcessingModel::testModel() QCOMPARE( model.rowCount(), 5 ); recentIndex = model.index( 0, 0, QModelIndex() ); QCOMPARE( model.rowCount( recentIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); favoriteIndex = model.index( 1, 0, QModelIndex() ); QCOMPARE( model.rowCount( favoriteIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p4:a3" ) ); registry.removeProvider( p2 ); QCOMPARE( model.rowCount(), 4 ); registry.removeProvider( p3 ); @@ -406,7 +398,7 @@ void TestQgsProcessingModel::testModel() DummyAlgorithm *qgisA2 = new DummyAlgorithm( "a2", "group2" ); DummyAlgorithm *qgisA3 = new DummyAlgorithm( "a3", "group1" ); DummyAlgorithm *qgisA4 = new DummyAlgorithm( "a4", "group3" ); - DummyProvider *qgisP = new DummyProvider( "qgis", "qgis_provider", QList< QgsProcessingAlgorithm * >() << qgisA1 << qgisA2 << qgisA3 << qgisA4 ); + DummyProvider *qgisP = new DummyProvider( "qgis", "qgis_provider", QList() << qgisA1 << qgisA2 << qgisA3 << qgisA4 ); registry2.addProvider( qgisP ); QCOMPARE( model2.rowCount(), 3 ); @@ -440,12 +432,11 @@ void TestQgsProcessingModel::testProxyModel() // add a provider DummyAlgorithm *a1 = new DummyAlgorithm( "a1", "group2", Qgis::ProcessingAlgorithmFlag::HideFromModeler ); - DummyProvider *p1 = new DummyProvider( "p2", "provider2", QList< QgsProcessingAlgorithm * >() << a1 ); + DummyProvider *p1 = new DummyProvider( "p2", "provider2", QList() << a1 ); registry.addProvider( p1 ); // second provider - DummyAlgorithm *a2 = new DummyAlgorithm( "a2", "group2", Qgis::ProcessingAlgorithmFlag::HideFromModeler, - QStringLiteral( "buffer,vector" ), QStringLiteral( "short desc" ), QStringLiteral( "algorithm2" ) ); - DummyProvider *p2 = new DummyProvider( "p1", "provider1", QList< QgsProcessingAlgorithm * >() << a2 ); + DummyAlgorithm *a2 = new DummyAlgorithm( "a2", "group2", Qgis::ProcessingAlgorithmFlag::HideFromModeler, QStringLiteral( "buffer,vector" ), QStringLiteral( "short desc" ), QStringLiteral( "algorithm2" ) ); + DummyProvider *p2 = new DummyProvider( "p1", "provider1", QList() << a2 ); registry.addProvider( p2 ); QCOMPARE( model.data( model.index( 0, 0, QModelIndex() ), Qt::DisplayRole ).toString(), QStringLiteral( "provider1" ) ); @@ -454,7 +445,7 @@ void TestQgsProcessingModel::testProxyModel() // top level groups come first DummyAlgorithm *qgisA1 = new DummyAlgorithm( "a1", "group2", Qgis::ProcessingAlgorithmFlag::HideFromModeler ); DummyAlgorithm *qgisA2 = new DummyAlgorithm( "a2", "group1", Qgis::ProcessingAlgorithmFlag::HideFromToolbox ); - DummyProvider *qgisP = new DummyProvider( "qgis", "qgis_provider", QList< QgsProcessingAlgorithm * >() << qgisA1 << qgisA2 ); + DummyProvider *qgisP = new DummyProvider( "qgis", "qgis_provider", QList() << qgisA1 << qgisA2 ); registry.addProvider( qgisP ); QModelIndex group1Index = model.index( 0, 0, QModelIndex() ); @@ -494,14 +485,14 @@ void TestQgsProcessingModel::testProxyModel() QModelIndex provider2Index = model.index( 1, 0, QModelIndex() ); QCOMPARE( model.rowCount( group1Index ), 1 ); QCOMPARE( model.data( group1Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); - QCOMPARE( model.data( model.index( 0, 0, group1Index ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); + QCOMPARE( model.data( model.index( 0, 0, group1Index ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); QCOMPARE( model.rowCount( group2Index ), 1 ); QCOMPARE( model.data( provider2Index, Qt::DisplayRole ).toString(), QStringLiteral( "provider2" ) ); QCOMPARE( model.rowCount( provider2Index ), 1 ); group2Index = model.index( 0, 0, provider2Index ); QCOMPARE( model.rowCount( group2Index ), 1 ); QCOMPARE( model.data( group2Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); - QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); // filter by algorithm display name model.setFilterString( QStringLiteral( "ALGOR" ) ); @@ -513,7 +504,7 @@ void TestQgsProcessingModel::testProxyModel() group2Index = model.index( 0, 0, provider1Index ); QCOMPARE( model.data( group2Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); QCOMPARE( model.rowCount( group2Index ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); // filter by algorithm tags model.setFilterString( QStringLiteral( "buff CTOR" ) ); @@ -525,7 +516,7 @@ void TestQgsProcessingModel::testProxyModel() group2Index = model.index( 0, 0, provider1Index ); QCOMPARE( model.data( group2Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); QCOMPARE( model.rowCount( group2Index ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); // filter by algorithm short desc model.setFilterString( QStringLiteral( "buff CTOR desc" ) ); @@ -537,7 +528,7 @@ void TestQgsProcessingModel::testProxyModel() group2Index = model.index( 0, 0, provider1Index ); QCOMPARE( model.data( group2Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); QCOMPARE( model.rowCount( group2Index ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); // filter by group model.setFilterString( QStringLiteral( "group2" ) ); @@ -546,7 +537,7 @@ void TestQgsProcessingModel::testProxyModel() QCOMPARE( model.rowCount( group2Index ), 1 ); QCOMPARE( model.data( group2Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); alg1Index = model.index( 0, 0, group2Index ); - QCOMPARE( model.data( alg1Index, static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); + QCOMPARE( model.data( alg1Index, static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); provider1Index = model.index( 1, 0, QModelIndex() ); QCOMPARE( model.rowCount( provider1Index ), 1 ); QCOMPARE( model.data( provider1Index, Qt::DisplayRole ).toString(), QStringLiteral( "provider1" ) ); @@ -554,14 +545,14 @@ void TestQgsProcessingModel::testProxyModel() group2Index = model.index( 0, 0, provider1Index ); QCOMPARE( model.data( group2Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); QCOMPARE( model.rowCount( group2Index ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); provider2Index = model.index( 2, 0, QModelIndex() ); QCOMPARE( model.rowCount( provider2Index ), 1 ); QCOMPARE( model.data( provider2Index, Qt::DisplayRole ).toString(), QStringLiteral( "provider2" ) ); group2Index = model.index( 0, 0, provider2Index ); QCOMPARE( model.data( group2Index, Qt::DisplayRole ).toString(), QStringLiteral( "group2" ) ); QCOMPARE( model.rowCount( group2Index ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 0, 0, group2Index ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); model.setFilterString( QString() ); QCOMPARE( model.rowCount(), 4 ); @@ -572,21 +563,21 @@ void TestQgsProcessingModel::testProxyModel() const QModelIndex recentIndex = model.index( 0, 0, QModelIndex() ); QCOMPARE( model.data( recentIndex, Qt::DisplayRole ).toString(), QStringLiteral( "Recently used" ) ); QCOMPARE( model.rowCount( recentIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); recentLog.push( QStringLiteral( "p1:a2" ) ); QCOMPARE( model.rowCount( recentIndex ), 2 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); - QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); recentLog.push( QStringLiteral( "qgis:a1" ) ); QCOMPARE( model.rowCount( recentIndex ), 3 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); - QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); - QCOMPARE( model.data( model.index( 2, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); + QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 2, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); recentLog.push( QStringLiteral( "p2:a1" ) ); QCOMPARE( model.rowCount( recentIndex ), 3 ); - QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); - QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); - QCOMPARE( model.data( model.index( 2, 0, recentIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 1, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); + QCOMPARE( model.data( model.index( 2, 0, recentIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); // check sort order of favorite algorithms favoriteManager.add( QStringLiteral( "p2:a1" ) ); @@ -594,30 +585,30 @@ void TestQgsProcessingModel::testProxyModel() const QModelIndex favoriteIndex = model.index( 1, 0, QModelIndex() ); QCOMPARE( model.data( favoriteIndex, Qt::DisplayRole ).toString(), QStringLiteral( "Favorites" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 1 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); favoriteManager.add( QStringLiteral( "p1:a2" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 2 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); - QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); favoriteManager.add( QStringLiteral( "qgis:a1" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 3 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); - QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); - QCOMPARE( model.data( model.index( 2, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); + QCOMPARE( model.data( model.index( 2, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); favoriteManager.remove( QStringLiteral( "p2:a1" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 2 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); - QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); + QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); favoriteManager.add( QStringLiteral( "p2:a1" ) ); QCOMPARE( model.rowCount( favoriteIndex ), 3 ); - QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); - QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); - QCOMPARE( model.data( model.index( 2, 0, favoriteIndex ), static_cast< int >( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); + QCOMPARE( model.data( model.index( 0, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "qgis:a1" ) ); + QCOMPARE( model.data( model.index( 1, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p2:a1" ) ); + QCOMPARE( model.data( model.index( 2, 0, favoriteIndex ), static_cast( QgsProcessingToolboxModel::CustomRole::AlgorithmId ) ).toString(), QStringLiteral( "p1:a2" ) ); // inactive provider - should not be visible QCOMPARE( model.rowCount(), 6 ); DummyAlgorithm *qgisA31 = new DummyAlgorithm( "a3", "group1" ); - DummyProvider *p3 = new DummyProvider( "p3", "provider3", QList< QgsProcessingAlgorithm * >() << qgisA31 ); + DummyProvider *p3 = new DummyProvider( "p3", "provider3", QList() << qgisA31 ); p3->mActive = false; registry.addProvider( p3 ); QCOMPARE( model.rowCount(), 6 ); @@ -640,12 +631,11 @@ void TestQgsProcessingModel::testView() // add a provider DummyAlgorithm *a1 = new DummyAlgorithm( "a1", "group2", Qgis::ProcessingAlgorithmFlag::HideFromToolbox ); - DummyProvider *p1 = new DummyProvider( "p2", "provider2", QList< QgsProcessingAlgorithm * >() << a1 ); + DummyProvider *p1 = new DummyProvider( "p2", "provider2", QList() << a1 ); registry.addProvider( p1 ); // second provider - DummyAlgorithm *a2 = new DummyAlgorithm( "a2", "group2", Qgis::ProcessingAlgorithmFlag::HideFromModeler, - QStringLiteral( "buffer,vector" ), QStringLiteral( "short desc" ), QStringLiteral( "algorithm2" ) ); - DummyProvider *p2 = new DummyProvider( "p1", "provider1", QList< QgsProcessingAlgorithm * >() << a2 ); + DummyAlgorithm *a2 = new DummyAlgorithm( "a2", "group2", Qgis::ProcessingAlgorithmFlag::HideFromModeler, QStringLiteral( "buffer,vector" ), QStringLiteral( "short desc" ), QStringLiteral( "algorithm2" ) ); + DummyProvider *p2 = new DummyProvider( "p1", "provider1", QList() << a2 ); registry.addProvider( p2 ); QModelIndex provider1Index = view.model()->index( 0, 0, QModelIndex() ); @@ -731,17 +721,17 @@ void TestQgsProcessingModel::testKnownIssues() const QgsProcessingToolboxModel model( nullptr, ®istry, &recentLog, &favoriteManager ); DummyAlgorithm *a1 = new DummyAlgorithm( "a1", "group1", Qgis::ProcessingAlgorithmFlag::KnownIssues, QStringLiteral( "tag1,tag2" ), QStringLiteral( "short desc a" ) ); DummyAlgorithm *a2 = new DummyAlgorithm( "b1", "group1", Qgis::ProcessingAlgorithmFlags(), QStringLiteral( "tag1,tag2" ), QStringLiteral( "short desc b" ) ); - DummyProvider *p = new DummyProvider( "p3", "provider3", QList< QgsProcessingAlgorithm * >() << a1 << a2 ); + DummyProvider *p = new DummyProvider( "p3", "provider3", QList() << a1 << a2 ); registry.addProvider( p ); QModelIndex providerIndex = model.index( 2, 0, QModelIndex() ); QModelIndex group1Index = model.index( 0, 0, providerIndex ); QCOMPARE( model.data( model.index( 0, 0, group1Index ), Qt::DisplayRole ).toString(), QStringLiteral( "a1" ) ); QVERIFY( model.data( model.index( 0, 0, group1Index ), Qt::ToolTipRole ).toString().contains( QStringLiteral( "known issues" ) ) ); - QCOMPARE( model.data( model.index( 0, 0, group1Index ), Qt::ForegroundRole ).value< QBrush >().color().name(), QStringLiteral( "#ff0000" ) ); + QCOMPARE( model.data( model.index( 0, 0, group1Index ), Qt::ForegroundRole ).value().color().name(), QStringLiteral( "#ff0000" ) ); QCOMPARE( model.data( model.index( 1, 0, group1Index ), Qt::DisplayRole ).toString(), QStringLiteral( "b1" ) ); QVERIFY( !model.data( model.index( 1, 0, group1Index ), Qt::ToolTipRole ).toString().contains( QStringLiteral( "known issues" ) ) ); - QCOMPARE( model.data( model.index( 1, 0, group1Index ), Qt::ForegroundRole ).value< QBrush >().color().name(), QStringLiteral( "#000000" ) ); + QCOMPARE( model.data( model.index( 1, 0, group1Index ), Qt::ForegroundRole ).value().color().name(), QStringLiteral( "#000000" ) ); QgsProcessingToolboxProxyModel proxyModel( nullptr, ®istry, &recentLog, &favoriteManager ); providerIndex = proxyModel.index( 0, 0, QModelIndex() ); @@ -750,15 +740,15 @@ void TestQgsProcessingModel::testKnownIssues() QCOMPARE( proxyModel.rowCount( group1Index ), 1 ); QCOMPARE( proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::DisplayRole ).toString(), QStringLiteral( "b1" ) ); QVERIFY( !proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::ToolTipRole ).toString().contains( QStringLiteral( "known issues" ) ) ); - QCOMPARE( proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::ForegroundRole ).value< QBrush >().color().name(), QStringLiteral( "#000000" ) ); + QCOMPARE( proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::ForegroundRole ).value().color().name(), QStringLiteral( "#000000" ) ); proxyModel.setFilters( QgsProcessingToolboxProxyModel::Filters( QgsProcessingToolboxProxyModel::Filter::Toolbox | QgsProcessingToolboxProxyModel::Filter::ShowKnownIssues ) ); QCOMPARE( proxyModel.rowCount( group1Index ), 2 ); QCOMPARE( proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::DisplayRole ).toString(), QStringLiteral( "a1" ) ); QVERIFY( proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::ToolTipRole ).toString().contains( QStringLiteral( "known issues" ) ) ); - QCOMPARE( proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::ForegroundRole ).value< QBrush >().color().name(), QStringLiteral( "#ff0000" ) ); + QCOMPARE( proxyModel.data( proxyModel.index( 0, 0, group1Index ), Qt::ForegroundRole ).value().color().name(), QStringLiteral( "#ff0000" ) ); QCOMPARE( proxyModel.data( proxyModel.index( 1, 0, group1Index ), Qt::DisplayRole ).toString(), QStringLiteral( "b1" ) ); QVERIFY( !proxyModel.data( proxyModel.index( 1, 0, group1Index ), Qt::ToolTipRole ).toString().contains( QStringLiteral( "known issues" ) ) ); - QCOMPARE( proxyModel.data( proxyModel.index( 1, 0, group1Index ), Qt::ForegroundRole ).value< QBrush >().color().name(), QStringLiteral( "#000000" ) ); + QCOMPARE( proxyModel.data( proxyModel.index( 1, 0, group1Index ), Qt::ForegroundRole ).value().color().name(), QStringLiteral( "#000000" ) ); } QGSTEST_MAIN( TestQgsProcessingModel ) diff --git a/tests/src/gui/testqgsquerybuilder.cpp b/tests/src/gui/testqgsquerybuilder.cpp index 6e873b73fa1b..9abccf803501 100644 --- a/tests/src/gui/testqgsquerybuilder.cpp +++ b/tests/src/gui/testqgsquerybuilder.cpp @@ -29,16 +29,14 @@ class TestQgsQueryBuilder : public QObject TestQgsQueryBuilder() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testFillValues(); private: - QStringList getModelItemDisplayStrings( QStandardItemModel *model ); - }; void TestQgsQueryBuilder::initTestCase() // will be called before the first testfunction is executed. diff --git a/tests/src/gui/testqgsqueryresultwidget.cpp b/tests/src/gui/testqgsqueryresultwidget.cpp index 3dfdc86aace9..2cbf2d924c3a 100644 --- a/tests/src/gui/testqgsqueryresultwidget.cpp +++ b/tests/src/gui/testqgsqueryresultwidget.cpp @@ -26,14 +26,14 @@ #include #include -class TestQgsQueryResultWidget: public QObject +class TestQgsQueryResultWidget : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. private slots: void testWidget(); @@ -42,16 +42,14 @@ class TestQgsQueryResultWidget: public QObject void testCodeEditorApis(); private: - QgsAbstractDatabaseProviderConnection *makeConn(); std::unique_ptr mConn; - }; QgsAbstractDatabaseProviderConnection *TestQgsQueryResultWidget::makeConn() { - return static_cast( QgsProviderRegistry::instance( )->providerMetadata( QStringLiteral( "postgres" ) )->createConnection( qgetenv( "QGIS_PGTEST_DB" ), QVariantMap() ) ); + return static_cast( QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "postgres" ) )->createConnection( qgetenv( "QGIS_PGTEST_DB" ), QVariantMap() ) ); } void TestQgsQueryResultWidget::initTestCase() @@ -85,11 +83,11 @@ void TestQgsQueryResultWidget::testWidgetCrash() auto res = new QgsAbstractDatabaseProviderConnection::QueryResult( mConn->execSql( QStringLiteral( "SELECT * FROM qgis_test.random_big_data" ) ) ); auto model = new QgsQueryResultModel( *res ); bool exited { false }; - QTimer::singleShot( 1, model, [ & ] { delete res; } ); - QTimer::singleShot( 2, model, [ & ] { exited = true; } ); - while ( ! exited ) + QTimer::singleShot( 1, model, [&] { delete res; } ); + QTimer::singleShot( 2, model, [&] { exited = true; } ); + while ( !exited ) { - model->fetchMore( QModelIndex( ) ); + model->fetchMore( QModelIndex() ); QgsApplication::processEvents(); } const auto rowCount { model->rowCount( model->index( -1, -1 ) ) }; @@ -97,7 +95,7 @@ void TestQgsQueryResultWidget::testWidgetCrash() delete model; // Test widget closed while fetching - auto d = std::make_unique( ); + auto d = std::make_unique(); QVBoxLayout *l = new QVBoxLayout(); QgsQueryResultWidget *w = new QgsQueryResultWidget( d.get(), makeConn() ); w->setQuery( QStringLiteral( "SELECT * FROM qgis_test.random_big_data" ) ); @@ -105,15 +103,15 @@ void TestQgsQueryResultWidget::testWidgetCrash() d->setLayout( l ); w->executeQuery(); exited = false; - QTimer::singleShot( 1, d.get(), [ & ] { exited = true; } ); - while ( ! exited ) + QTimer::singleShot( 1, d.get(), [&] { exited = true; } ); + while ( !exited ) QgsApplication::processEvents(); } void TestQgsQueryResultWidget::testWidget() { - auto d = std::make_unique( ); + auto d = std::make_unique(); QVBoxLayout *l = new QVBoxLayout(); QgsQueryResultWidget *w = new QgsQueryResultWidget( d.get(), makeConn() ); w->setQuery( QStringLiteral( "SELECT * FROM qgis_test.random_big_data" ) ); @@ -123,8 +121,8 @@ void TestQgsQueryResultWidget::testWidget() //d->exec(); w->executeQuery(); bool exited = false; - connect( w, &QgsQueryResultWidget::firstResultBatchFetched, d.get(), [ & ] { exited = true; } ); - while ( ! exited ) + connect( w, &QgsQueryResultWidget::firstResultBatchFetched, d.get(), [&] { exited = true; } ); + while ( !exited ) QgsApplication::processEvents(); const auto rowCount { w->mModel->rowCount( w->mModel->index( -1, -1 ) ) }; QVERIFY( rowCount > 0 && rowCount < 100000 ); @@ -140,8 +138,8 @@ void TestQgsQueryResultWidget::testCodeEditorApis() { auto w = std::make_unique( nullptr, makeConn() ); bool exited = false; - connect( w->mApiFetcher, &QgsConnectionsApiFetcher::fetchingFinished, w.get(), [ & ] { exited = true; } ); - while ( ! exited ) + connect( w->mApiFetcher, &QgsConnectionsApiFetcher::fetchingFinished, w.get(), [&] { exited = true; } ); + while ( !exited ) QgsApplication::processEvents(); QVERIFY( w->mSqlEditor->extraKeywords().contains( QStringLiteral( "qgis_test" ) ) ); QVERIFY( w->mSqlEditor->extraKeywords().contains( QStringLiteral( "random_big_data" ) ) ); @@ -149,14 +147,12 @@ void TestQgsQueryResultWidget::testCodeEditorApis() // Test feedback interrupt w = std::make_unique( nullptr, makeConn() ); - QTimer::singleShot( 0, w.get(), [ & ] - { + QTimer::singleShot( 0, w.get(), [&] { QTest::mousePress( w->mStopButton, Qt::MouseButton::LeftButton ); } ); - connect( w->mApiFetcher, &QgsConnectionsApiFetcher::fetchingFinished, w.get(), [ & ] { exited = true; } ); - while ( ! exited ) + connect( w->mApiFetcher, &QgsConnectionsApiFetcher::fetchingFinished, w.get(), [&] { exited = true; } ); + while ( !exited ) QgsApplication::processEvents(); - } diff --git a/tests/src/gui/testqgsquickprint.cpp b/tests/src/gui/testqgsquickprint.cpp index 2c3c4c5f777a..6a07f8bbd740 100644 --- a/tests/src/gui/testqgsquickprint.cpp +++ b/tests/src/gui/testqgsquickprint.cpp @@ -47,12 +47,13 @@ class TestQgsQuickPrint : public QObject {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {};// will be called before each testfunction is executed. - void cleanup() {};// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {}; // will be called before each testfunction is executed. + void cleanup() {}; // will be called after every testfunction. void basicMapTest(); + private: bool imageCheck( QString type ); //as above QgsMapRenderer *mpMapRenderer = nullptr; @@ -80,8 +81,7 @@ void TestQgsQuickPrint::initTestCase() mTestDataDir = myDataDir + "/"; QString myPointsFileName = mTestDataDir + "points.shp"; QFileInfo myPointFileInfo( myPointsFileName ); - mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), - myPointFileInfo.completeBaseName(), "ogr" ); + mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry QgsProject::instance()->addMapLayer( mpPointsLayer ); @@ -90,8 +90,7 @@ void TestQgsQuickPrint::initTestCase() // QString myPolysFileName = mTestDataDir + "polys.shp"; QFileInfo myPolyFileInfo( myPolysFileName ); - mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), - myPolyFileInfo.completeBaseName(), "ogr" ); + mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry QgsProject::instance()->addMapLayer( mpPolysLayer ); @@ -100,8 +99,7 @@ void TestQgsQuickPrint::initTestCase() // QString myLinesFileName = mTestDataDir + "lines.shp"; QFileInfo myLineFileInfo( myLinesFileName ); - mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), - myLineFileInfo.completeBaseName(), "ogr" ); + mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), myLineFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry QgsProject::instance()->addMapLayer( mpLinesLayer ); // diff --git a/tests/src/gui/testqgsrangewidgetwrapper.cpp b/tests/src/gui/testqgsrangewidgetwrapper.cpp index 3c8aaa5304c0..0b29cf61b6fc 100644 --- a/tests/src/gui/testqgsrangewidgetwrapper.cpp +++ b/tests/src/gui/testqgsrangewidgetwrapper.cpp @@ -45,10 +45,10 @@ class TestQgsRangeWidgetWrapper : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void test_setDoubleRange(); void test_setDoubleSmallerRange(); void test_setDoubleLimits(); @@ -83,19 +83,17 @@ void TestQgsRangeWidgetWrapper::cleanupTestCase() void TestQgsRangeWidgetWrapper::init() { - vl = std::make_unique( QStringLiteral( "Point?crs=epsg:4326" ), - QStringLiteral( "myvl" ), - QLatin1String( "memory" ) ); + vl = std::make_unique( QStringLiteral( "Point?crs=epsg:4326" ), QStringLiteral( "myvl" ), QLatin1String( "memory" ) ); // add fields QList fields; fields.append( QgsField( "id", QMetaType::Type::Int ) ); // precision = 9 - QgsField dfield( "number", QMetaType::Type::Double ); + QgsField dfield( "number", QMetaType::Type::Double ); dfield.setPrecision( 9 ); fields.append( dfield ); // default precision = 0 - const QgsField dfield2( "number_def", QMetaType::Type::Double ); + const QgsField dfield2( "number_def", QMetaType::Type::Double ); fields.append( dfield2 ); // simple int fields.append( QgsField( "simplenumber", QMetaType::Type::Int ) ); @@ -105,26 +103,26 @@ void TestQgsRangeWidgetWrapper::init() QVERIFY( vl.get() ); QVERIFY( vl->isValid() ); // Add feature 1:1:123.123456789:123.123456789:NULL:POINT( 1 1 ) - QgsFeature feat1( vl->fields(), 1 ); + QgsFeature feat1( vl->fields(), 1 ); feat1.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POINT( 1 1 )" ) ) ); feat1.setAttribute( QStringLiteral( "id" ), 1 ); feat1.setAttribute( QStringLiteral( "number" ), 123.123456789 ); feat1.setAttribute( QStringLiteral( "number_def" ), 123.123456789 ); vl->dataProvider()->addFeature( feat1 ); // Add feature 2:2:NULL:NULL:NULL:POINT( 2 2 ) - QgsFeature feat2( vl->fields(), 2 ); + QgsFeature feat2( vl->fields(), 2 ); feat2.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POINT( 2 2 )" ) ) ); feat2.setAttribute( QStringLiteral( "id" ), 2 ); vl->dataProvider()->addFeature( feat2 ); // Add feature 3:3:-123.123456789:-123.123456789:NULL:POINT( 3 3 ) - QgsFeature feat3( vl->fields(), 3 ); + QgsFeature feat3( vl->fields(), 3 ); feat3.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POINT( 3 3 )" ) ) ); feat3.setAttribute( QStringLiteral( "number" ), -123.123456789 ); feat3.setAttribute( QStringLiteral( "number_def" ), -123.123456789 ); feat3.setAttribute( QStringLiteral( "id" ), 3 ); vl->dataProvider()->addFeature( feat3 ); // Verify feat 1 was added - QCOMPARE( vl->featureCount( ), ( long )3 ); + QCOMPARE( vl->featureCount(), ( long ) 3 ); const QgsFeature _feat1( vl->getFeature( 1 ) ); QCOMPARE( _feat1, feat1 ); widget0 = std::make_unique( vl.get(), 0, nullptr, nullptr ); @@ -162,25 +160,25 @@ void TestQgsRangeWidgetWrapper::test_setDoubleRange() QCOMPARE( editor->decimals(), vl->fields().at( 1 ).precision() ); QCOMPARE( editor->decimals(), 9 ); QCOMPARE( editor2->decimals(), vl->fields().at( 2 ).precision() ); - QCOMPARE( editor->valueFromText( feat.attribute( 1 ).toString() ), 123.123456789 ); + QCOMPARE( editor->valueFromText( feat.attribute( 1 ).toString() ), 123.123456789 ); QCOMPARE( feat.attribute( 1 ).toString(), QStringLiteral( "123.123456789" ) ); QCOMPARE( editor2->valueFromText( feat.attribute( 1 ).toString() ), 123.123456789 ); - QCOMPARE( editor->value( ), 123.123456789 ); - QCOMPARE( editor2->value( ), 123.0 ); - QCOMPARE( editor->minimum( ), std::numeric_limits::lowest() ); - QCOMPARE( editor2->minimum( ), std::numeric_limits::lowest() ); - QCOMPARE( editor->maximum( ), std::numeric_limits::max() ); - QCOMPARE( editor2->maximum( ), std::numeric_limits::max() ); + QCOMPARE( editor->value(), 123.123456789 ); + QCOMPARE( editor2->value(), 123.0 ); + QCOMPARE( editor->minimum(), std::numeric_limits::lowest() ); + QCOMPARE( editor2->minimum(), std::numeric_limits::lowest() ); + QCOMPARE( editor->maximum(), std::numeric_limits::max() ); + QCOMPARE( editor2->maximum(), std::numeric_limits::max() ); widget1->setFeature( vl->getFeature( 2 ) ); widget2->setFeature( vl->getFeature( 2 ) ); - QCOMPARE( editor->value( ), editor->minimum() ); - QCOMPARE( editor2->value( ), editor->minimum() ); + QCOMPARE( editor->value(), editor->minimum() ); + QCOMPARE( editor2->value(), editor->minimum() ); widget1->setFeature( vl->getFeature( 3 ) ); widget2->setFeature( vl->getFeature( 3 ) ); - QCOMPARE( editor->value( ), -123.123456789 ); - QCOMPARE( editor2->value( ), -123.0 ); + QCOMPARE( editor->value(), -123.123456789 ); + QCOMPARE( editor2->value(), -123.0 ); } void TestQgsRangeWidgetWrapper::test_setDoubleSmallerRange() @@ -212,29 +210,28 @@ void TestQgsRangeWidgetWrapper::test_setDoubleSmallerRange() QCOMPARE( editor->decimals(), vl->fields().at( 1 ).precision() ); QCOMPARE( editor2->decimals(), vl->fields().at( 2 ).precision() ); // value was changed to the maximum (not NULL) accepted value - QCOMPARE( editor->value( ), 100.0 ); + QCOMPARE( editor->value(), 100.0 ); // value was changed to the maximum (not NULL) accepted value - QCOMPARE( editor2->value( ), 100.0 ); + QCOMPARE( editor2->value(), 100.0 ); // minimum was lowered by the precision (10e-9) - QCOMPARE( editor->minimum( ), -100.000000001 ); + QCOMPARE( editor->minimum(), -100.000000001 ); // minimum was lowered by step (1) - QCOMPARE( editor2->minimum( ), ( double ) - 101 ); - QCOMPARE( editor->maximum( ), ( double )100 ); - QCOMPARE( editor2->maximum( ), ( double )100 ); + QCOMPARE( editor2->minimum(), ( double ) -101 ); + QCOMPARE( editor->maximum(), ( double ) 100 ); + QCOMPARE( editor2->maximum(), ( double ) 100 ); // NULL, NULL widget1->setFeature( vl->getFeature( 2 ) ); widget2->setFeature( vl->getFeature( 2 ) ); - QCOMPARE( editor->value( ), editor->minimum() ); - QCOMPARE( editor2->value( ), editor2->minimum() ); + QCOMPARE( editor->value(), editor->minimum() ); + QCOMPARE( editor2->value(), editor2->minimum() ); // negative, negative widget1->setFeature( vl->getFeature( 3 ) ); widget2->setFeature( vl->getFeature( 3 ) ); // value was changed to the minimum - QCOMPARE( editor->value( ), editor->minimum() ); - QCOMPARE( editor2->value( ), editor2->minimum() ); - + QCOMPARE( editor->value(), editor->minimum() ); + QCOMPARE( editor2->value(), editor2->minimum() ); } void TestQgsRangeWidgetWrapper::test_setDoubleLimits() @@ -254,10 +251,10 @@ void TestQgsRangeWidgetWrapper::test_setDoubleLimits() QVERIFY( editor2 ); widget2->initWidget( editor2 ); - QCOMPARE( editor->minimum( ), std::numeric_limits::lowest() ); - QCOMPARE( editor2->minimum( ), std::numeric_limits::lowest() ); - QCOMPARE( editor->maximum( ), std::numeric_limits::max() ); - QCOMPARE( editor2->maximum( ), std::numeric_limits::max() ); + QCOMPARE( editor->minimum(), std::numeric_limits::lowest() ); + QCOMPARE( editor2->minimum(), std::numeric_limits::lowest() ); + QCOMPARE( editor->maximum(), std::numeric_limits::max() ); + QCOMPARE( editor2->maximum(), std::numeric_limits::max() ); const QgsFeature feat( vl->getFeature( 1 ) ); QVERIFY( feat.isValid() ); @@ -270,22 +267,21 @@ void TestQgsRangeWidgetWrapper::test_setDoubleLimits() QCOMPARE( vl->fields().at( 2 ).precision(), 0 ); QCOMPARE( editor->decimals(), vl->fields().at( 1 ).precision() ); QCOMPARE( editor2->decimals(), vl->fields().at( 2 ).precision() ); - QCOMPARE( editor->value( ), 123.123456789 ); - QCOMPARE( editor2->value( ), 123.0 ); + QCOMPARE( editor->value(), 123.123456789 ); + QCOMPARE( editor2->value(), 123.0 ); // NULL, NULL widget1->setFeature( vl->getFeature( 2 ) ); widget2->setFeature( vl->getFeature( 2 ) ); - QCOMPARE( editor->value( ), editor->minimum() ); - QCOMPARE( editor2->value( ), editor2->minimum() ); + QCOMPARE( editor->value(), editor->minimum() ); + QCOMPARE( editor2->value(), editor2->minimum() ); // negative, negative widget1->setFeature( vl->getFeature( 3 ) ); widget2->setFeature( vl->getFeature( 3 ) ); // value was changed to the minimum - QCOMPARE( editor->value( ), -123.123456789 ); - QCOMPARE( editor2->value( ), -123.0 ); - + QCOMPARE( editor->value(), -123.123456789 ); + QCOMPARE( editor2->value(), -123.0 ); } void TestQgsRangeWidgetWrapper::test_nulls() @@ -303,17 +299,17 @@ void TestQgsRangeWidgetWrapper::test_nulls() widget1->initWidget( editor1 ); // Out of range widget1->setFeature( vl->getFeature( 3 ) ); - QCOMPARE( editor1->value( ), editor1->minimum() ); - QCOMPARE( widget1->value( ), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); + QCOMPARE( editor1->value(), editor1->minimum() ); + QCOMPARE( widget1->value(), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); widget1->setFeature( QgsFeature( vl->fields() ) ); // Null - QCOMPARE( editor1->value( ), editor1->minimum() ); - QCOMPARE( widget1->value( ), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); + QCOMPARE( editor1->value(), editor1->minimum() ); + QCOMPARE( widget1->value(), QgsVariantUtils::createNullVariant( QMetaType::Type::Double ) ); QCOMPARE( editor1->mLineEdit->text(), SPECIAL_TEXT_WHEN_EMPTY ); editor1->mLineEdit->setText( QString( "151%1" ).arg( SPECIAL_TEXT_WHEN_EMPTY ) ); - QCOMPARE( widget1->value( ).toInt(), 151 ); + QCOMPARE( widget1->value().toInt(), 151 ); editor1->mLineEdit->setText( QString( SPECIAL_TEXT_WHEN_EMPTY ).append( QStringLiteral( "161" ) ) ); - QCOMPARE( widget1->value( ).toInt(), 161 ); + QCOMPARE( widget1->value().toInt(), 161 ); QgsSpinBox *editor0 = qobject_cast( widget0->createWidget( nullptr ) ); @@ -322,19 +318,18 @@ void TestQgsRangeWidgetWrapper::test_nulls() widget0->initWidget( editor0 ); // Out of range widget0->setFeature( vl->getFeature( 3 ) ); - QCOMPARE( editor0->value( ), editor0->minimum() ); - QCOMPARE( widget0->value( ), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); + QCOMPARE( editor0->value(), editor0->minimum() ); + QCOMPARE( widget0->value(), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); widget0->setFeature( QgsFeature( vl->fields() ) ); // Null - QCOMPARE( editor0->value( ), editor0->minimum() ); - QCOMPARE( widget0->value( ), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); + QCOMPARE( editor0->value(), editor0->minimum() ); + QCOMPARE( widget0->value(), QgsVariantUtils::createNullVariant( QMetaType::Type::Int ) ); QCOMPARE( editor0->mLineEdit->text(), SPECIAL_TEXT_WHEN_EMPTY ); editor0->mLineEdit->setText( QString( "150%1" ).arg( SPECIAL_TEXT_WHEN_EMPTY ) ); - QCOMPARE( widget0->value( ).toInt(), 150 ); + QCOMPARE( widget0->value().toInt(), 150 ); editor0->mLineEdit->setText( QString( SPECIAL_TEXT_WHEN_EMPTY ).append( QStringLiteral( "160" ) ) ); - QCOMPARE( widget0->value( ).toInt(), 160 ); - + QCOMPARE( widget0->value().toInt(), 160 ); } void TestQgsRangeWidgetWrapper::test_negativeIntegers() @@ -352,22 +347,21 @@ void TestQgsRangeWidgetWrapper::test_negativeIntegers() feature.setAttribute( 3, -12345 ); widget3->setFeature( feature ); - QCOMPARE( widget3->value( ).toInt(), -12345 ); + QCOMPARE( widget3->value().toInt(), -12345 ); cfg.insert( QStringLiteral( "Min" ), 10 ); widget3->setConfig( cfg ); widget3->initWidget( editor3 ); widget3->setFeature( feature ); QVERIFY( widget3->value().isNull() ); - QCOMPARE( widget3->value( ).toInt(), 0 ); + QCOMPARE( widget3->value().toInt(), 0 ); cfg.clear(); cfg.insert( QStringLiteral( "Min" ), -12346 ); widget3->setConfig( cfg ); widget3->initWidget( editor3 ); widget3->setFeature( feature ); - QCOMPARE( widget3->value( ).toInt(), -12345 ); - + QCOMPARE( widget3->value().toInt(), -12345 ); } void TestQgsRangeWidgetWrapper::test_focus() @@ -466,13 +460,12 @@ void TestQgsRangeWidgetWrapper::test_focus() QCOMPARE( editor1->mLineEdit->text(), QStringLiteral( "151.000000000" ) ); QCOMPARE( editor2->mLineEdit->text(), QString() ); QCOMPARE( editor3->mLineEdit->text(), QStringLiteral( "nope" ) ); - } void TestQgsRangeWidgetWrapper::testLongLong() { // test range widget with a long long field type - std::unique_ptr< QgsRangeWidgetWrapper >wrapper = std::make_unique( vl.get(), 4, nullptr, nullptr ); + std::unique_ptr wrapper = std::make_unique( vl.get(), 4, nullptr, nullptr ); // should use a double spin box, as a integer spin box does not have sufficient range QgsDoubleSpinBox *editor = qobject_cast( wrapper->createWidget( nullptr ) ); @@ -480,8 +473,8 @@ void TestQgsRangeWidgetWrapper::testLongLong() wrapper->initWidget( editor ); // no decimals, it's for long long value editing! QCOMPARE( editor->decimals(), 0 ); - QCOMPARE( editor->minimum( ), std::numeric_limits::lowest() ); - QCOMPARE( editor->maximum( ), std::numeric_limits::max() ); + QCOMPARE( editor->minimum(), std::numeric_limits::lowest() ); + QCOMPARE( editor->maximum(), std::numeric_limits::max() ); wrapper->setValue( 1234567890123LL ); diff --git a/tests/src/gui/testqgsrasterhistogram.cpp b/tests/src/gui/testqgsrasterhistogram.cpp index 1176c4ac18b1..b06f56294a0e 100644 --- a/tests/src/gui/testqgsrasterhistogram.cpp +++ b/tests/src/gui/testqgsrasterhistogram.cpp @@ -45,7 +45,6 @@ class TestRasterHistogram : public QObject TestRasterHistogram() {} private: - QString mDataDir; QString mTestPrefix; int mWidth, mHeight, mImageQuality; @@ -59,19 +58,15 @@ class TestRasterHistogram : public QObject bool openLayer( const QString &fileName ); void closeLayer(); bool saveImage( const QString &fileName ); - int testFile( QString testName, - QString rendererName, - QgsRasterRendererWidget *rendererWidget, - QStringList actionsList = QStringList(), - int selectedBand = -1 ); + int testFile( QString testName, QString rendererName, QgsRasterRendererWidget *rendererWidget, QStringList actionsList = QStringList(), int selectedBand = -1 ); private slots: // init / cleanup - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {};// will be called before each testfunction is executed. - void cleanup() {};// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {}; // will be called before each testfunction is executed. + void cleanup() {}; // will be called after every testfunction. // tests void testGray1(); @@ -193,7 +188,7 @@ void TestRasterHistogram::testPseudo1() bool TestRasterHistogram::openLayer( const QString &fileName ) { mRasterLayer = new QgsRasterLayer( mDataDir + "/" + fileName, fileName ); - if ( ! mRasterLayer ) + if ( !mRasterLayer ) return false; mGrayRendererWidget = new QgsSingleBandGrayRendererWidget( mRasterLayer ); mRGBRendererWidget = new QgsMultiBandColorRendererWidget( mRasterLayer ); @@ -239,9 +234,7 @@ bool TestRasterHistogram::saveImage( const QString &fileName ) // test resulting image file - relax this test because there are too many possible outputs depending on machine // 1 means pass, 0 means warning (different images), -1 means fail (no image output) -int TestRasterHistogram::testFile( QString testType, - QString rendererName, QgsRasterRendererWidget *rendererWidget, - QStringList actionsList, int selectedBand ) +int TestRasterHistogram::testFile( QString testType, QString rendererName, QgsRasterRendererWidget *rendererWidget, QStringList actionsList, int selectedBand ) { if ( mRasterLayer == 0 ) { @@ -264,9 +257,8 @@ int TestRasterHistogram::testFile( QString testType, { mHistogramWidget->setSelectedBand( selectedBand ); } - QString fileName = QDir::tempPath() + "/" + - testType + "_result.png"; - if ( ! saveImage( fileName ) ) + QString fileName = QDir::tempPath() + "/" + testType + "_result.png"; + if ( !saveImage( fileName ) ) { QWARN( QString( "Did not save image file " + fileName ).toLocal8Bit().data() ); return -1; @@ -281,7 +273,7 @@ int TestRasterHistogram::testFile( QString testType, mReport += "\n\n\n" + myChecker.report(); // return myResultFlag; - if ( ! myResultFlag ) + if ( !myResultFlag ) { QWARN( QString( "Test %1 failed with file %2 " ).arg( testType ).arg( fileName ).toLocal8Bit().data() ); return 0; diff --git a/tests/src/gui/testqgsrasterlayersaveasdialog.cpp b/tests/src/gui/testqgsrasterlayersaveasdialog.cpp index 76a32b2a395f..102b6781bf70 100644 --- a/tests/src/gui/testqgsrasterlayersaveasdialog.cpp +++ b/tests/src/gui/testqgsrasterlayersaveasdialog.cpp @@ -32,17 +32,15 @@ class TestQgsRasterLayerSaveAsDialog : public QObject TestQgsRasterLayerSaveAsDialog() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void outputLayerExists(); void filenameWhenNoExtension(); private: - QString prepareDb(); - }; void TestQgsRasterLayerSaveAsDialog::initTestCase() @@ -78,10 +76,10 @@ void TestQgsRasterLayerSaveAsDialog::outputLayerExists() QgsRasterLayerSaveAsDialog d( &rl, rl.dataProvider(), rl.extent(), rl.crs(), rl.crs() ); d.mFormatComboBox->setCurrentIndex( d.mFormatComboBox->findData( QStringLiteral( "GPKG" ) ) ); QCOMPARE( d.mFormatComboBox->currentData().toString(), QString( "GPKG" ) ); - QVERIFY( ! d.outputLayerExists() ); + QVERIFY( !d.outputLayerExists() ); d.mFilename->setFilePath( fileName ); d.mLayerName->setText( QStringLiteral( "my_imported_raster" ) ); - QVERIFY( ! d.outputLayerExists() ); + QVERIFY( !d.outputLayerExists() ); // Write the raster into the destination file const auto pipe { *rl.pipe() }; @@ -106,22 +104,22 @@ void TestQgsRasterLayerSaveAsDialog::outputLayerExists() fileWriter2.writeRaster( &pipe, 10, 10, rl.extent(), rl.crs(), rl.transformContext() ); { const auto rasterUri2 { QStringLiteral( "GPKG:%1:%2" ).arg( d.outputFileName() ).arg( d.outputLayerName() ) }; - QVERIFY( ! QgsRasterLayer( rasterUri2, QStringLiteral( "my_raster2" ) ).isValid() ); + QVERIFY( !QgsRasterLayer( rasterUri2, QStringLiteral( "my_raster2" ) ).isValid() ); } } QString TestQgsRasterLayerSaveAsDialog::prepareDb() { // Preparation: make a test gpk DB with a vector layer in it - QTemporaryFile tmpFile( QDir::tempPath() + QStringLiteral( "/test_qgsrasterlayersavesdialog_XXXXXX.gpkg" ) ); + QTemporaryFile tmpFile( QDir::tempPath() + QStringLiteral( "/test_qgsrasterlayersavesdialog_XXXXXX.gpkg" ) ); tmpFile.setAutoRemove( false ); tmpFile.open(); - const QString fileName( tmpFile.fileName( ) ); + const QString fileName( tmpFile.fileName() ); QgsVectorLayer vl( QStringLiteral( "Point?field=firstfield:string(1024)" ), "test_vector_layer", "memory" ); QgsVectorFileWriter::SaveVectorOptions saveOptions; saveOptions.fileEncoding = QStringLiteral( "UTF-8" ); - const std::unique_ptr< QgsVectorFileWriter > writer( QgsVectorFileWriter::create( fileName, vl.fields(), Qgis::WkbType::Point, vl.crs(), QgsCoordinateTransformContext(), saveOptions ) ); + const std::unique_ptr writer( QgsVectorFileWriter::create( fileName, vl.fields(), Qgis::WkbType::Point, vl.crs(), QgsCoordinateTransformContext(), saveOptions ) ); QgsFeature f { vl.fields() }; f.setAttribute( 0, QString( 1024, 'x' ) ); @@ -143,7 +141,7 @@ QString TestQgsRasterLayerSaveAsDialog::prepareDb() ); const QgsVectorLayer vl2( QStringLiteral( "%1|layername=test_vector_layer" ).arg( fileName ), "test_vector_layer", "ogr" ); Q_ASSERT( vl2.isValid() ); - return tmpFile.fileName( ); + return tmpFile.fileName(); } void TestQgsRasterLayerSaveAsDialog::filenameWhenNoExtension() diff --git a/tests/src/gui/testqgsrasterlayersavesdialog.cpp b/tests/src/gui/testqgsrasterlayersavesdialog.cpp index 9642dcab0789..8b6068e08550 100644 --- a/tests/src/gui/testqgsrasterlayersavesdialog.cpp +++ b/tests/src/gui/testqgsrasterlayersavesdialog.cpp @@ -31,16 +31,14 @@ class TestQgsRasterLayerSaveAsDialog : public QObject TestQgsRasterLayerSaveAsDialog() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void outputLayerExists(); private: - QString prepareDb(); - }; void TestQgsRasterLayerSaveAsDialog::initTestCase() @@ -76,10 +74,10 @@ void TestQgsRasterLayerSaveAsDialog::outputLayerExists() QgsRasterLayerSaveAsDialog d( &rl, rl.dataProvider(), rl.extent(), rl.crs(), rl.crs() ); d.mFormatComboBox->setCurrentIndex( d.mFormatComboBox->findData( QStringLiteral( "GPKG" ) ) ); QCOMPARE( d.mFormatComboBox->currentData().toString(), QString( "GPKG" ) ); - QVERIFY( ! d.outputLayerExists() ); + QVERIFY( !d.outputLayerExists() ); d.mFilename->setFilePath( fileName ); d.mLayerName->setText( QStringLiteral( "my_imported_raster" ) ); - QVERIFY( ! d.outputLayerExists() ); + QVERIFY( !d.outputLayerExists() ); // Write the raster into the destination file auto pipe { *rl.pipe() }; @@ -102,16 +100,12 @@ void TestQgsRasterLayerSaveAsDialog::outputLayerExists() QString TestQgsRasterLayerSaveAsDialog::prepareDb() { // Preparation: make a test gpk DB with a vector layer in it - QTemporaryFile tmpFile( QDir::tempPath() + QStringLiteral( "/test_qgsrasterlayersavesdialog_XXXXXX.gpkg" ) ); + QTemporaryFile tmpFile( QDir::tempPath() + QStringLiteral( "/test_qgsrasterlayersavesdialog_XXXXXX.gpkg" ) ); tmpFile.setAutoRemove( false ); tmpFile.open(); - QString fileName( tmpFile.fileName( ) ); + QString fileName( tmpFile.fileName() ); QgsVectorLayer vl( QStringLiteral( "Point?field=firstfield:string(1024)" ), "test_layer", "memory" ); - QgsVectorFileWriter w( fileName, - QStringLiteral( "UTF-8" ), - vl.fields(), - QgsWkbTypes::Point, - vl.crs() ); + QgsVectorFileWriter w( fileName, QStringLiteral( "UTF-8" ), vl.fields(), QgsWkbTypes::Point, vl.crs() ); QgsFeature f { vl.fields() }; f.setAttribute( 0, QString( 1024, 'x' ) ); f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "point(9 45)" ) ) ); @@ -125,10 +119,11 @@ QString TestQgsRasterLayerSaveAsDialog::prepareDb() &vl, fileName, options, - &errorMessage ); + &errorMessage + ); QgsVectorLayer vl2( QStringLiteral( "%1|layername=test_layer" ).arg( fileName ), "src_test", "ogr" ); Q_ASSERT( vl2.isValid() ); - return tmpFile.fileName( ); + return tmpFile.fileName(); } QGSTEST_MAIN( TestQgsRasterLayerSaveAsDialog ) diff --git a/tests/src/gui/testqgsrelationeditorwidget.cpp b/tests/src/gui/testqgsrelationeditorwidget.cpp index c57feb03c98e..97706872e77d 100644 --- a/tests/src/gui/testqgsrelationeditorwidget.cpp +++ b/tests/src/gui/testqgsrelationeditorwidget.cpp @@ -34,10 +34,10 @@ class TestQgsRelationEditorWidget : public QObject TestQgsRelationEditorWidget() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testMultiEdit1N(); void testMultiEditNM(); @@ -178,8 +178,7 @@ void TestQgsRelationEditorWidget::cleanup() void TestQgsRelationEditorWidget::testMultiEdit1N() { // Init a relation editor widget - QgsRelationEditorWidget relationEditorWidget( QVariantMap(), - new QWidget() ); + QgsRelationEditorWidget relationEditorWidget( QVariantMap(), new QWidget() ); relationEditorWidget.setRelations( *mRelation, QgsRelation() ); QVERIFY( !relationEditorWidget.multiEditModeActive() ); @@ -202,14 +201,12 @@ void TestQgsRelationEditorWidget::testMultiEdit1N() { QTreeWidgetItem *parentItem = relationEditorWidget.mMultiEditTreeWidget->topLevelItem( parentIndex ); setParentItemsText.insert( parentItem->text( 0 ) ); - QCOMPARE( parentItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), - static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Parent ) ); + QCOMPARE( parentItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Parent ) ); for ( int childIndex = 0; childIndex < parentItem->childCount(); ++childIndex ) { QTreeWidgetItem *childItem = parentItem->child( childIndex ); setChildrenItemsText.insert( childItem->text( 0 ) ); - QCOMPARE( childItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), - static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Child ) ); + QCOMPARE( childItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Child ) ); if ( childItem->text( 0 ) == QLatin1String( "Layer1-0" ) ) QCOMPARE( parentItem->text( 0 ), QStringLiteral( "Layer2-10" ) ); @@ -219,19 +216,15 @@ void TestQgsRelationEditorWidget::testMultiEdit1N() } } - QCOMPARE( setParentItemsText, QSet() << QStringLiteral( "Layer2-10" ) - << QStringLiteral( "Layer2-11" ) - << QStringLiteral( "Layer2-12" ) ); + QCOMPARE( setParentItemsText, QSet() << QStringLiteral( "Layer2-10" ) << QStringLiteral( "Layer2-11" ) << QStringLiteral( "Layer2-12" ) ); - QCOMPARE( setChildrenItemsText, QSet() << QStringLiteral( "Layer1-0" ) - << QStringLiteral( "Layer1-1" ) ); + QCOMPARE( setChildrenItemsText, QSet() << QStringLiteral( "Layer1-0" ) << QStringLiteral( "Layer1-1" ) ); } void TestQgsRelationEditorWidget::testMultiEditNM() { // Init a relation editor widget - QgsRelationEditorWidget relationEditorWidget( QVariantMap(), - new QWidget() ); + QgsRelationEditorWidget relationEditorWidget( QVariantMap(), new QWidget() ); relationEditorWidget.setRelations( *mRelation1N, *mRelationNM ); QVERIFY( !relationEditorWidget.multiEditModeActive() ); @@ -254,14 +247,12 @@ void TestQgsRelationEditorWidget::testMultiEditNM() { QTreeWidgetItem *parentItem = relationEditorWidget.mMultiEditTreeWidget->topLevelItem( parentIndex ); setParentItemsText.insert( parentItem->text( 0 ) ); - QCOMPARE( parentItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), - static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Parent ) ); + QCOMPARE( parentItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Parent ) ); for ( int childIndex = 0; childIndex < parentItem->childCount(); ++childIndex ) { QTreeWidgetItem *childItem = parentItem->child( childIndex ); listChildrenItemsText.append( childItem->text( 0 ) ); - QCOMPARE( childItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), - static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Child ) ); + QCOMPARE( childItem->data( 0, static_cast( QgsRelationEditorWidget::MultiEditTreeWidgetRole::FeatureType ) ).toInt(), static_cast( QgsRelationEditorWidget::MultiEditFeatureType::Child ) ); if ( childItem->text( 0 ) == QLatin1String( "Layer2-10" ) ) QCOMPARE( parentItem->text( 0 ), QStringLiteral( "Layer1-0" ) ); @@ -276,22 +267,16 @@ void TestQgsRelationEditorWidget::testMultiEditNM() } } - QCOMPARE( setParentItemsText, QSet() << QStringLiteral( "Layer1-0" ) - << QStringLiteral( "Layer1-1" ) ); + QCOMPARE( setParentItemsText, QSet() << QStringLiteral( "Layer1-0" ) << QStringLiteral( "Layer1-1" ) ); listChildrenItemsText.sort(); - QCOMPARE( listChildrenItemsText, QStringList() << QStringLiteral( "Layer2-10" ) - << QStringLiteral( "Layer2-11" ) - << QStringLiteral( "Layer2-11" ) ); - + QCOMPARE( listChildrenItemsText, QStringList() << QStringLiteral( "Layer2-10" ) << QStringLiteral( "Layer2-11" ) << QStringLiteral( "Layer2-11" ) ); } void TestQgsRelationEditorWidget::testFeatureRequest() { - // Init a relation editor widget - QgsRelationEditorWidget relationEditorWidget( QVariantMap(), - new QWidget() ); + QgsRelationEditorWidget relationEditorWidget( QVariantMap(), new QWidget() ); relationEditorWidget.setRelations( *mRelation1N, *mRelationNM ); QVERIFY( !relationEditorWidget.multiEditModeActive() ); @@ -397,7 +382,6 @@ void TestQgsRelationEditorWidget::testUpdateUi() relationEditorWidget.nmRelation().referencedLayer()->selectAll(); QVERIFY( relationEditorWidget.selectedChildFeatureIds().contains( 1 ) ); QVERIFY( relationEditorWidget.selectedChildFeatureIds().contains( 2 ) ); - } QGSTEST_MAIN( TestQgsRelationEditorWidget ) diff --git a/tests/src/gui/testqgsrelationreferencewidget.cpp b/tests/src/gui/testqgsrelationreferencewidget.cpp index 34363be24b26..b3784c8fc6d8 100644 --- a/tests/src/gui/testqgsrelationreferencewidget.cpp +++ b/tests/src/gui/testqgsrelationreferencewidget.cpp @@ -52,10 +52,10 @@ class TestQgsRelationReferenceWidget : public QObject TestQgsRelationReferenceWidget() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testChainFilter(); void testChainFilter_data(); @@ -622,11 +622,11 @@ class DummyVectorLayerTools : public QgsVectorLayerTools // clazy:exclude=missin return true; } - bool startEditing( QgsVectorLayer * ) const override {return true;} + bool startEditing( QgsVectorLayer * ) const override { return true; } - bool stopEditing( QgsVectorLayer *, bool = true ) const override {return true;} + bool stopEditing( QgsVectorLayer *, bool = true ) const override { return true; } - bool saveEdits( QgsVectorLayer * ) const override {return true;} + bool saveEdits( QgsVectorLayer * ) const override { return true; } }; void TestQgsRelationReferenceWidget::testAddEntry() diff --git a/tests/src/gui/testqgsrubberband.cpp b/tests/src/gui/testqgsrubberband.cpp index 5e01952c138f..9205d416a1fb 100644 --- a/tests/src/gui/testqgsrubberband.cpp +++ b/tests/src/gui/testqgsrubberband.cpp @@ -34,13 +34,14 @@ class TestQgsRubberband : public QgsTest { Q_OBJECT public: - TestQgsRubberband() : QgsTest( QStringLiteral( "Rubberband Tests" ) ) {} + TestQgsRubberband() + : QgsTest( QStringLiteral( "Rubberband Tests" ) ) {} private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testAddSingleMultiGeometries(); //test for #7728 void pointGeometryAddPoints(); @@ -48,8 +49,8 @@ class TestQgsRubberband : public QgsTest void lineGeometryAddPoints(); void copyPointsFrom(); void testBoundingRect(); //test for #12392 - void testVisibility(); //test for 12486 - void testClose(); //test closing geometry + void testVisibility(); //test for 12486 + void testClose(); //test closing geometry void testLineSymbolRender(); void testFillSymbolRender(); @@ -75,8 +76,7 @@ void TestQgsRubberband::initTestCase() // const QString myPolygonFileName = mTestDataDir + "polys.shp"; const QFileInfo myPolygonFileInfo( myPolygonFileName ); - mPolygonLayer = new QgsVectorLayer( myPolygonFileInfo.filePath(), - myPolygonFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); + mPolygonLayer = new QgsVectorLayer( myPolygonFileInfo.filePath(), myPolygonFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); mCanvas = new QgsMapCanvas(); mCanvas->setFrameStyle( QFrame::NoFrame ); @@ -98,12 +98,10 @@ void TestQgsRubberband::cleanupTestCase() void TestQgsRubberband::init() { - } void TestQgsRubberband::cleanup() { - } void TestQgsRubberband::testAddSingleMultiGeometries() @@ -122,7 +120,7 @@ void TestQgsRubberband::testAddSingleMultiGeometries() void TestQgsRubberband::pointGeometryAddPoints() { // point geometry - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); QgsRubberBand r1( canvas.get(), Qgis::GeometryType::Point ); QVERIFY( r1.asGeometry().isEmpty() ); r1.addPoint( QgsPointXY( 1, 2 ) ); @@ -140,7 +138,7 @@ void TestQgsRubberband::pointGeometryAddPoints() void TestQgsRubberband::pointGeometrySetGeometry() { // point geometry, set using setToGeometry - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); QgsRubberBand r1( canvas.get(), Qgis::GeometryType::Point ); QVERIFY( r1.asGeometry().isEmpty() ); r1.setToGeometry( QgsGeometry::fromPointXY( QgsPointXY( 1, 2 ) ) ); @@ -149,20 +147,20 @@ void TestQgsRubberband::pointGeometrySetGeometry() QCOMPARE( r1.asGeometry().asWkt(), QStringLiteral( "MultiPoint ((2 3))" ) ); r1.addGeometry( QgsGeometry::fromPointXY( QgsPointXY( 5, 6 ) ) ); QCOMPARE( r1.asGeometry().asWkt(), QStringLiteral( "MultiPoint ((2 3),(5 6))" ) ); - r1.setToGeometry( QgsGeometry::fromMultiPointXY( {QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ) } ) ); + r1.setToGeometry( QgsGeometry::fromMultiPointXY( { QgsPointXY( 1, 2 ), QgsPointXY( 3, 4 ) } ) ); QCOMPARE( r1.asGeometry().asWkt(), QStringLiteral( "MultiPoint ((1 2),(3 4))" ) ); r1.addGeometry( QgsGeometry::fromPointXY( QgsPointXY( 5, 7 ) ) ); QCOMPARE( r1.asGeometry().asWkt(), QStringLiteral( "MultiPoint ((1 2),(3 4),(5 7))" ) ); - r1.addGeometry( QgsGeometry::fromMultiPointXY( { QgsPointXY( 7, 8 ), QgsPointXY( 9, 10 )} ) ); + r1.addGeometry( QgsGeometry::fromMultiPointXY( { QgsPointXY( 7, 8 ), QgsPointXY( 9, 10 ) } ) ); QCOMPARE( r1.asGeometry().asWkt(), QStringLiteral( "MultiPoint ((1 2),(3 4),(5 7),(7 8),(9 10))" ) ); r1.reset( Qgis::GeometryType::Point ); - r1.addGeometry( QgsGeometry::fromMultiPointXY( { QgsPointXY( 7, 8 ), QgsPointXY( 9, 10 )} ) ); + r1.addGeometry( QgsGeometry::fromMultiPointXY( { QgsPointXY( 7, 8 ), QgsPointXY( 9, 10 ) } ) ); QCOMPARE( r1.asGeometry().asWkt(), QStringLiteral( "MultiPoint ((7 8),(9 10))" ) ); } void TestQgsRubberband::lineGeometryAddPoints() { - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); QgsRubberBand r1( canvas.get(), Qgis::GeometryType::Line ); QVERIFY( r1.asGeometry().isEmpty() ); r1.addPoint( QgsPointXY( 1, 2 ) ); @@ -179,7 +177,7 @@ void TestQgsRubberband::lineGeometryAddPoints() void TestQgsRubberband::copyPointsFrom() { - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); QgsRubberBand r1( canvas.get(), Qgis::GeometryType::Point ); r1.addPoint( QgsPointXY( 1, 2 ) ); r1.addPoint( QgsPointXY( 3, 4 ) ); @@ -209,8 +207,8 @@ void TestQgsRubberband::testBoundingRect() // Polygon extent is 10,10 to 30,30 const QgsGeometry geom( QgsGeometry::fromWkt( - QStringLiteral( "POLYGON((10 10,10 30,30 30,30 10,10 10))" ) - ) ); + QStringLiteral( "POLYGON((10 10,10 30,30 30,30 10,10 10))" ) + ) ); mRubberband = new QgsRubberBand( mCanvas, mPolygonLayer->geometryType() ); mRubberband->setIconSize( 5 ); // default, but better be explicit mRubberband->setWidth( 1 ); // default, but better be explicit @@ -219,23 +217,22 @@ void TestQgsRubberband::testBoundingRect() // 20 pixels for the extent + 3 for pen & icon per side + 2 of extra padding from setRect() QCOMPARE( mRubberband->boundingRect(), QRectF( QPointF( -1, -1 ), QSizeF( 28, 28 ) ) ); QCOMPARE( mRubberband->pos(), QPointF( - // 10 for extent minx - 3 for pen & icon - 10 - 3, - // 30 for extent maxy - 3 for pen & icon - 512 - 30 - 3 - ) ); + // 10 for extent minx - 3 for pen & icon + 10 - 3, + // 30 for extent maxy - 3 for pen & icon + 512 - 30 - 3 + ) ); mCanvas->setExtent( QgsRectangle( 0, 0, 256, 256 ) ); // 40 pixels for the extent + 3 for pen & icon per side + 2 of extra padding from setRect() QCOMPARE( mRubberband->boundingRect(), QRectF( QPointF( -1, -1 ), QSizeF( 48, 48 ) ) ); QCOMPARE( mRubberband->pos(), QPointF( - // 10 for extent minx - 3 for pen & icon - 10 * 2 - 3, - // 30 for extent maxy - 3 for pen & icon - 512 - 30 * 2 - 3 - ) ); - + // 10 for extent minx - 3 for pen & icon + 10 * 2 - 3, + // 30 for extent maxy - 3 for pen & icon + 512 - 30 * 2 - 3 + ) ); } void TestQgsRubberband::testVisibility() @@ -257,8 +254,8 @@ void TestQgsRubberband::testVisibility() // Check visibility after setting to valid geometry const QgsGeometry geom( QgsGeometry::fromWkt( - QStringLiteral( "POLYGON((10 10,10 30,30 30,30 10,10 10))" ) - ) ); + QStringLiteral( "POLYGON((10 10,10 30,30 30,30 10,10 10))" ) + ) ); mRubberband->setToGeometry( geom, mPolygonLayer ); QCOMPARE( mRubberband->isVisible(), true ); @@ -275,7 +272,6 @@ void TestQgsRubberband::testVisibility() mRubberband->setVisible( false ); mCanvas->zoomIn(); QCOMPARE( mRubberband->isVisible(), false ); - } void TestQgsRubberband::testClose() @@ -308,7 +304,7 @@ void TestQgsRubberband::testClose() void TestQgsRubberband::testLineSymbolRender() { - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); canvas->setFrameStyle( 0 ); canvas->resize( 600, 400 ); @@ -318,12 +314,12 @@ void TestQgsRubberband::testLineSymbolRender() QgsRubberBand r( canvas.get(), Qgis::GeometryType::Line ); r.addGeometry( QgsGeometry::fromWkt( QStringLiteral( "LineString( 12 32, 18 33)" ) ) ); - std::unique_ptr< QgsLineSymbol > lineSymbol( QgsLineSymbol::createSimple( - { - { QStringLiteral( "line_color" ), QStringLiteral( "#0000ff" ) }, - { QStringLiteral( "line_width" ), QStringLiteral( "3" )}, - { QStringLiteral( "capstyle" ), QStringLiteral( "round" )} - } ) ); + std::unique_ptr lineSymbol( QgsLineSymbol::createSimple( + { { QStringLiteral( "line_color" ), QStringLiteral( "#0000ff" ) }, + { QStringLiteral( "line_width" ), QStringLiteral( "3" ) }, + { QStringLiteral( "capstyle" ), QStringLiteral( "round" ) } + } + ) ); r.setSymbol( lineSymbol.release() ); QPixmap pixmap( canvas->size() ); @@ -344,7 +340,7 @@ void TestQgsRubberband::testLineSymbolRender() void TestQgsRubberband::testFillSymbolRender() { - std::unique_ptr< QgsMapCanvas > canvas = std::make_unique< QgsMapCanvas >(); + std::unique_ptr canvas = std::make_unique(); canvas->setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); canvas->setFrameStyle( 0 ); canvas->resize( 600, 400 ); @@ -354,13 +350,13 @@ void TestQgsRubberband::testFillSymbolRender() QgsRubberBand r( canvas.get(), Qgis::GeometryType::Line ); r.addGeometry( QgsGeometry::fromWkt( QStringLiteral( "Polygon((12 32, 12 35, 18 35, 12 32))" ) ) ); - std::unique_ptr< QgsFillSymbol > fillSymbol( QgsFillSymbol::createSimple( - { - { QStringLiteral( "color" ), QStringLiteral( "#ff00ff" ) }, - { QStringLiteral( "line_color" ), QStringLiteral( "#0000ff" ) }, - { QStringLiteral( "line_width" ), QStringLiteral( "3" )}, - { QStringLiteral( "joinstyle" ), QStringLiteral( "round" )} - } ) ); + std::unique_ptr fillSymbol( QgsFillSymbol::createSimple( + { { QStringLiteral( "color" ), QStringLiteral( "#ff00ff" ) }, + { QStringLiteral( "line_color" ), QStringLiteral( "#0000ff" ) }, + { QStringLiteral( "line_width" ), QStringLiteral( "3" ) }, + { QStringLiteral( "joinstyle" ), QStringLiteral( "round" ) } + } + ) ); r.setSymbol( fillSymbol.release() ); QPixmap pixmap( canvas->size() ); @@ -382,5 +378,3 @@ void TestQgsRubberband::testFillSymbolRender() QGSTEST_MAIN( TestQgsRubberband ) #include "testqgsrubberband.moc" - - diff --git a/tests/src/gui/testqgsscalecombobox.cpp b/tests/src/gui/testqgsscalecombobox.cpp index 825e30241b70..468957537131 100644 --- a/tests/src/gui/testqgsscalecombobox.cpp +++ b/tests/src/gui/testqgsscalecombobox.cpp @@ -32,10 +32,10 @@ class TestQgsScaleComboBox : public QObject TestQgsScaleComboBox() = default; private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void basic(); void slot_test(); void min_test(); @@ -54,7 +54,6 @@ void TestQgsScaleComboBox::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); - } void TestQgsScaleComboBox::cleanupTestCase() @@ -130,7 +129,6 @@ void TestQgsScaleComboBox::basic() s->setScaleString( QStringLiteral( "1:2" ) + QLocale().decimalPoint() + "4" ); QCOMPARE( s->scaleString(), QString( "1:%1" ).arg( QLocale().toString( 240 ) ) ); QCOMPARE( s->scale(), 240.0 ); - } void TestQgsScaleComboBox::slot_test() @@ -168,7 +166,7 @@ void TestQgsScaleComboBox::toString() QCOMPARE( QgsScaleComboBox::toString( 100.02134234 ), QStringLiteral( "1:100" ) ); QCOMPARE( QgsScaleComboBox::toString( 1 ), QStringLiteral( "1:1" ) ); QCOMPARE( QgsScaleComboBox::toString( 1.0 / 100 ), QStringLiteral( "100:1" ) ); - QCOMPARE( QgsScaleComboBox::toString( std::numeric_limits< double >::quiet_NaN() ), QString() ); + QCOMPARE( QgsScaleComboBox::toString( std::numeric_limits::quiet_NaN() ), QString() ); } void TestQgsScaleComboBox::toDouble() diff --git a/tests/src/gui/testqgsscalerangewidget.cpp b/tests/src/gui/testqgsscalerangewidget.cpp index 9cd754c8e19b..fa82a5321571 100644 --- a/tests/src/gui/testqgsscalerangewidget.cpp +++ b/tests/src/gui/testqgsscalerangewidget.cpp @@ -38,11 +38,12 @@ class TestQgsScaleRangeWidget : public QObject { Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void test_setScaleRange(); + private: std::unique_ptr widget; }; @@ -87,7 +88,6 @@ void TestQgsScaleRangeWidget::test_setScaleRange() QCOMPARE( widget->maximumScale(), 2.0 ); // TODO: test passing min > max - } QGSTEST_MAIN( TestQgsScaleRangeWidget ) diff --git a/tests/src/gui/testqgssinglebandpseudocolorrendererwidget.cpp b/tests/src/gui/testqgssinglebandpseudocolorrendererwidget.cpp index 854781d481ff..829a47bcf305 100644 --- a/tests/src/gui/testqgssinglebandpseudocolorrendererwidget.cpp +++ b/tests/src/gui/testqgssinglebandpseudocolorrendererwidget.cpp @@ -31,18 +31,16 @@ class TestQgsSingleBandPseudoColorRendererWidget : public QObject Q_OBJECT public: - TestQgsSingleBandPseudoColorRendererWidget() {} private: - QgsRasterLayer *mRasterLayer = nullptr; private slots: // init / cleanup - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. // tests void testEditLabel(); @@ -130,6 +128,5 @@ void TestQgsSingleBandPseudoColorRendererWidget::testEditLabel() } - QGSTEST_MAIN( TestQgsSingleBandPseudoColorRendererWidget ) #include "testqgssinglebandpseudocolorrendererwidget.moc" diff --git a/tests/src/gui/testqgsspinbox.cpp b/tests/src/gui/testqgsspinbox.cpp index 326a667c7090..37423b98324c 100644 --- a/tests/src/gui/testqgsspinbox.cpp +++ b/tests/src/gui/testqgsspinbox.cpp @@ -18,26 +18,24 @@ #include -class TestQgsSpinBox: public QObject +class TestQgsSpinBox : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void clear(); void expression(); void step(); private: - }; void TestQgsSpinBox::initTestCase() { - } void TestQgsSpinBox::cleanupTestCase() diff --git a/tests/src/gui/testqgssqlcomposerdialog.cpp b/tests/src/gui/testqgssqlcomposerdialog.cpp index 9fdaf3521bab..2a1c71c471e9 100644 --- a/tests/src/gui/testqgssqlcomposerdialog.cpp +++ b/tests/src/gui/testqgssqlcomposerdialog.cpp @@ -19,7 +19,7 @@ #include #include -class TestQgsSQLComposerDialog: public QObject +class TestQgsSQLComposerDialog : public QObject { Q_OBJECT private slots: @@ -30,6 +30,7 @@ class TestQgsSQLComposerDialog: public QObject void testSelectSpatialPredicate(); void testSelectOperator(); void testJoins(); + private: bool runTest(); }; @@ -224,9 +225,7 @@ void TestQgsSQLComposerDialog::testSelectColumn() if ( !runTest() ) return; QgsSQLComposerDialog d; - d.addColumnNames( QList() << - QgsSQLComposerDialog::PairNameType( QStringLiteral( "a" ), QString() ) << - QgsSQLComposerDialog::PairNameType( QStringLiteral( "b" ), QStringLiteral( "type" ) ), QStringLiteral( "my_table" ) ); + d.addColumnNames( QList() << QgsSQLComposerDialog::PairNameType( QStringLiteral( "a" ), QString() ) << QgsSQLComposerDialog::PairNameType( QStringLiteral( "b" ), QStringLiteral( "type" ) ), QStringLiteral( "my_table" ) ); QCOMPARE( getColumnsCombo( d )->itemText( 1 ), QString( "a" ) ); QCOMPARE( getColumnsCombo( d )->itemText( 2 ), QString( "b (type)" ) ); diff --git a/tests/src/gui/testqgssvgselectorwidget.cpp b/tests/src/gui/testqgssvgselectorwidget.cpp index 280296c04d4c..f5627dd9aa7b 100644 --- a/tests/src/gui/testqgssvgselectorwidget.cpp +++ b/tests/src/gui/testqgssvgselectorwidget.cpp @@ -24,14 +24,14 @@ class TestQgsSvgSelectorWidget : public QgsTest Q_OBJECT public: - - TestQgsSvgSelectorWidget() : QgsTest( QStringLiteral( "SVG Selector Widget Tests" ) ) {} + TestQgsSvgSelectorWidget() + : QgsTest( QStringLiteral( "SVG Selector Widget Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init();// will be called before each testfunction is executed. - void cleanup();// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testPixmapCache(); }; diff --git a/tests/src/gui/testqgstableeditor.cpp b/tests/src/gui/testqgstableeditor.cpp index eebe12c021b2..ea71d1263f9c 100644 --- a/tests/src/gui/testqgstableeditor.cpp +++ b/tests/src/gui/testqgstableeditor.cpp @@ -21,14 +21,14 @@ #include "qgsbearingnumericformat.h" #include -class TestQgsTableEditor: public QObject +class TestQgsTableEditor : public QObject { Q_OBJECT private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testData(); void insertRowsBelow(); void insertRowsAbove(); @@ -50,12 +50,10 @@ class TestQgsTableEditor: public QObject void headers(); private: - }; void TestQgsTableEditor::initTestCase() { - } void TestQgsTableEditor::cleanupTestCase() @@ -78,7 +76,7 @@ void TestQgsTableEditor::testData() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -129,14 +127,14 @@ void TestQgsTableEditor::insertRowsBelow() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); QgsTableCell c2( 76 ); c2.setBackgroundColor( QColor( 255, 0, 0 ) ); QgsTextFormat c2f; - c2f.setColor( QColor( 0, 255, 0 ) ) ; + c2f.setColor( QColor( 0, 255, 0 ) ); c2.setTextFormat( c2f ); w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) << c2 << c3 ) ); QCOMPARE( spy.count(), 1 ); @@ -239,7 +237,7 @@ void TestQgsTableEditor::insertRowsAbove() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -349,7 +347,7 @@ void TestQgsTableEditor::insertColumnsBefore() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -431,7 +429,7 @@ void TestQgsTableEditor::insertColumnsAfter() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -513,7 +511,7 @@ void TestQgsTableEditor::deleteRows() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); QgsTableCell c2( 76 ); @@ -522,10 +520,7 @@ void TestQgsTableEditor::deleteRows() QgsTextFormat c2f; c2f.setColor( QColor( 0, 255, 0 ) ); c2.setTextFormat( c2f ); - w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) ) - << ( QgsTableRow() << c2 ) - << ( QgsTableRow() << c3 ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet3" ) ) ) ); + w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet" ) ) ) << ( QgsTableRow() << c2 ) << ( QgsTableRow() << c3 ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "Jet3" ) ) ) ); QCOMPARE( spy.count(), 1 ); // no selection @@ -569,7 +564,6 @@ void TestQgsTableEditor::deleteRows() QCOMPARE( spy.count(), 3 ); QCOMPARE( w.tableContents().size(), 1 ); QCOMPARE( w.tableContents().at( 0 ).size(), 1 ); - } void TestQgsTableEditor::deleteColumns() @@ -580,7 +574,7 @@ void TestQgsTableEditor::deleteColumns() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); QgsTableCell c2( 76 ); @@ -635,16 +629,12 @@ void TestQgsTableEditor::deleteColumns() QCOMPARE( spy.count(), 3 ); QCOMPARE( w.tableContents().size(), 1 ); QCOMPARE( w.tableContents().at( 0 ).size(), 1 ); - } void TestQgsTableEditor::selectRows() { QgsTableEditorWidget w; - w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); + w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); w.selectionModel()->select( w.model()->index( 0, 0 ), QItemSelectionModel::ClearAndSelect ); w.expandRowSelection(); @@ -674,9 +664,7 @@ void TestQgsTableEditor::selectRows() void TestQgsTableEditor::selectColumns() { QgsTableEditorWidget w; - w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); + w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); w.selectionModel()->select( w.model()->index( 0, 0 ), QItemSelectionModel::ClearAndSelect ); w.expandColumnSelection(); @@ -705,9 +693,7 @@ void TestQgsTableEditor::selectColumns() void TestQgsTableEditor::clearSelected() { QgsTableEditorWidget w; - w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << QgsTableCell( QStringLiteral( "A2" ) ) << QgsTableCell( QStringLiteral( "A3" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "B1" ) ) << QgsTableCell( QStringLiteral( "B2" ) ) << QgsTableCell( QStringLiteral( "B3" ) ) ) - << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C1" ) ) << QgsTableCell( QStringLiteral( "C2" ) ) << QgsTableCell( QStringLiteral( "C3" ) ) ) ); + w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( QStringLiteral( "A1" ) ) << QgsTableCell( QStringLiteral( "A2" ) ) << QgsTableCell( QStringLiteral( "A3" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "B1" ) ) << QgsTableCell( QStringLiteral( "B2" ) ) << QgsTableCell( QStringLiteral( "B3" ) ) ) << ( QgsTableRow() << QgsTableCell( QStringLiteral( "C1" ) ) << QgsTableCell( QStringLiteral( "C2" ) ) << QgsTableCell( QStringLiteral( "C3" ) ) ) ); const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); w.selectionModel()->clearSelection(); @@ -745,7 +731,6 @@ void TestQgsTableEditor::clearSelected() QCOMPARE( w.tableContents().at( 2 ).at( 0 ).content().toString(), QStringLiteral( "C1" ) ); QCOMPARE( w.tableContents().at( 2 ).at( 1 ).content().toString(), QStringLiteral( "C2" ) ); QCOMPARE( w.tableContents().at( 2 ).at( 2 ).content().toString(), QStringLiteral( "C3" ) ); - } void TestQgsTableEditor::foregroundColor() @@ -756,7 +741,7 @@ void TestQgsTableEditor::foregroundColor() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -821,7 +806,7 @@ void TestQgsTableEditor::backgroundColor() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -884,7 +869,7 @@ void TestQgsTableEditor::alignment() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -952,7 +937,7 @@ void TestQgsTableEditor::properties() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); c3.setNumericFormat( format.release() ); @@ -965,7 +950,7 @@ void TestQgsTableEditor::properties() QCOMPARE( w.tableContents().at( 0 ).at( 0 ).content().toString(), QStringLiteral( "Jet" ) ); QVERIFY( w.tableContents().at( 0 ).at( 0 ).content().userType() != qMetaTypeId() ); QCOMPARE( w.tableContents().at( 0 ).at( 1 ).content().userType(), qMetaTypeId() ); - QCOMPARE( w.tableContents().at( 0 ).at( 1 ).content().value< QgsProperty >().asExpression(), QStringLiteral( "1+2" ) ); + QCOMPARE( w.tableContents().at( 0 ).at( 1 ).content().value().asExpression(), QStringLiteral( "1+2" ) ); QCOMPARE( w.tableContents().at( 0 ).at( 2 ).content().toString(), QStringLiteral( "87" ) ); QVERIFY( w.tableContents().at( 0 ).at( 2 ).content().userType() != qMetaTypeId() ); QCOMPARE( w.tableContents().at( 0 ).at( 3 ).content().toString(), QStringLiteral( "Jet3" ) ); @@ -989,9 +974,9 @@ void TestQgsTableEditor::properties() QVERIFY( w.selectionCellProperty().isActive() ); QCOMPARE( w.selectionCellProperty().asExpression(), QStringLiteral( "3+4" ) ); QCOMPARE( w.tableContents().at( 0 ).at( 0 ).content().userType(), qMetaTypeId() ); - QCOMPARE( w.tableContents().at( 0 ).at( 0 ).content().value< QgsProperty >().asExpression(), QStringLiteral( "3+4" ) ); + QCOMPARE( w.tableContents().at( 0 ).at( 0 ).content().value().asExpression(), QStringLiteral( "3+4" ) ); QCOMPARE( w.tableContents().at( 0 ).at( 1 ).content().userType(), qMetaTypeId() ); - QCOMPARE( w.tableContents().at( 0 ).at( 1 ).content().value< QgsProperty >().asExpression(), QStringLiteral( "3+4" ) ); + QCOMPARE( w.tableContents().at( 0 ).at( 1 ).content().value().asExpression(), QStringLiteral( "3+4" ) ); QCOMPARE( w.tableContents().at( 0 ).at( 2 ).content().toString(), QStringLiteral( "87" ) ); QVERIFY( w.tableContents().at( 0 ).at( 2 ).content().userType() != qMetaTypeId() ); QCOMPARE( w.tableContents().at( 0 ).at( 3 ).content().toString(), QStringLiteral( "Jet3" ) ); @@ -1035,13 +1020,13 @@ void TestQgsTableEditor::textFormat() QCOMPARE( spy.count(), 1 ); w.selectionModel()->select( w.model()->index( 0, 0 ), QItemSelectionModel::ClearAndSelect ); - QVERIFY( w.selectionTextFormat().size() != 21.0 ); + QVERIFY( w.selectionTextFormat().size() != 21.0 ); w.selectionModel()->select( w.model()->index( 0, 1 ), QItemSelectionModel::Select ); - QVERIFY( w.selectionTextFormat().size() != 21.0 ); + QVERIFY( w.selectionTextFormat().size() != 21.0 ); w.selectionModel()->select( w.model()->index( 0, 1 ), QItemSelectionModel::ClearAndSelect ); QCOMPARE( w.selectionTextFormat().size(), 12.6 ); w.selectionModel()->select( w.model()->index( 0, 0 ), QItemSelectionModel::Select ); - QVERIFY( w.selectionTextFormat().size() != 21.0 ); + QVERIFY( w.selectionTextFormat().size() != 21.0 ); w.setSelectionTextFormat( format ); QCOMPARE( spy.count(), 2 ); QVERIFY( w.selectionTextFormat().isValid() ); @@ -1060,7 +1045,7 @@ void TestQgsTableEditor::numericFormat() const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); QgsTableCell c3; c3.setContent( 87 ); - std::unique_ptr< QgsCurrencyNumericFormat > format = std::make_unique< QgsCurrencyNumericFormat >(); + std::unique_ptr format = std::make_unique(); format->setNumberDecimalPlaces( 2 ); format->setPrefix( QStringLiteral( "$" ) ); QgsTableCell c2( 76 ); @@ -1128,9 +1113,7 @@ void TestQgsTableEditor::rowHeight() QVERIFY( w.tableContents().isEmpty() ); const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); - w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); + w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); QCOMPARE( spy.count(), 1 ); w.setTableRowHeight( 1, 14.0 ); @@ -1170,9 +1153,7 @@ void TestQgsTableEditor::columnWidth() QVERIFY( w.tableContents().isEmpty() ); const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); - w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) - << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); + w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) << ( QgsTableRow() << QgsTableCell() << QgsTableCell() << QgsTableCell() ) ); QCOMPARE( spy.count(), 1 ); w.setTableColumnWidth( 1, 14.0 ); @@ -1212,8 +1193,7 @@ void TestQgsTableEditor::headers() QVERIFY( w.tableContents().isEmpty() ); const QSignalSpy spy( &w, &QgsTableEditorWidget::tableChanged ); - w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( 1 ) << QgsTableCell( 2 ) << QgsTableCell( 3 ) ) - << ( QgsTableRow() << QgsTableCell( 4 ) << QgsTableCell( 5 ) << QgsTableCell( 6 ) ) ); + w.setTableContents( QgsTableContents() << ( QgsTableRow() << QgsTableCell( 1 ) << QgsTableCell( 2 ) << QgsTableCell( 3 ) ) << ( QgsTableRow() << QgsTableCell( 4 ) << QgsTableCell( 5 ) << QgsTableCell( 6 ) ) ); QCOMPARE( spy.count(), 1 ); w.setIncludeTableHeader( true ); @@ -1238,7 +1218,6 @@ void TestQgsTableEditor::headers() QCOMPARE( w.tableContents().at( 1 ).at( 0 ).content(), QVariant( 4 ) ); QCOMPARE( w.tableContents().at( 1 ).at( 1 ).content(), QVariant( 5 ) ); QCOMPARE( w.tableContents().at( 1 ).at( 2 ).content(), QVariant( 6 ) ); - } diff --git a/tests/src/gui/testqgstexteditwrapper.cpp b/tests/src/gui/testqgstexteditwrapper.cpp index 45760cf32240..e7a2610370b8 100644 --- a/tests/src/gui/testqgstexteditwrapper.cpp +++ b/tests/src/gui/testqgstexteditwrapper.cpp @@ -39,10 +39,10 @@ class TestQgsTextEditWrapper : public QObject QTemporaryDir tempDir; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testWithJsonInPostgres(); void testWithJsonBInPostgres(); @@ -85,7 +85,7 @@ void TestQgsTextEditWrapper::testWithJsonInPostgres() QCOMPARE( vl_json->fields().at( 1 ).type(), QVariant::Map ); QgsTextEditWrapper w_json( vl_json, vl_json->fields().indexOf( QLatin1String( "jvalue" ) ), nullptr, nullptr ); - QLineEdit *widget = qobject_cast< QLineEdit * >( w_json.widget() ); + QLineEdit *widget = qobject_cast( w_json.widget() ); w_json.setEnabled( true ); // check text output from DB @@ -115,7 +115,7 @@ void TestQgsTextEditWrapper::testWithJsonInPostgres() widget->setText( QString( "{\"foo\":\"bar\",\"baz\":[1,2,3]}" ) ); QVERIFY( w_json.value().isValid() ); QVERIFY( w_json.value().userType() == QMetaType::QVariantMap ); - json complexJson = QgsJsonUtils::jsonFromVariant( w_json.value() ); + json complexJson = QgsJsonUtils::jsonFromVariant( w_json.value() ); QVERIFY( complexJson.is_object() ); const json jsonArr = complexJson.at( "baz" ); QCOMPARE( QString::fromStdString( jsonArr.dump() ), QStringLiteral( "[1,2,3]" ) ); @@ -124,13 +124,13 @@ void TestQgsTextEditWrapper::testWithJsonInPostgres() widget->setText( QString( "" ) ); QVERIFY( w_json.value().isValid() ); QVERIFY( QgsJsonUtils::jsonFromVariant( w_json.value() ).is_string() ); - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front( ) ), QStringLiteral( "\"\"" ) ); + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front() ), QStringLiteral( "\"\"" ) ); //test quoted empty widget->setText( QString( "\"\"" ) ); QVERIFY( w_json.value().isValid() ); QVERIFY( QgsJsonUtils::jsonFromVariant( w_json.value() ).is_string() ); - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front( ) ), QStringLiteral( "\"\"" ) ); + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front() ), QStringLiteral( "\"\"" ) ); // test invalid JSON widget->setText( QString( "{\"body\";\"text\"}" ) ); @@ -166,10 +166,10 @@ void TestQgsTextEditWrapper::testWithJsonInPostgres() // test with quoted string (valid JSON) widget->setText( QString( "\"abc\"" ) ); - QVERIFY( w_json.value().isValid() ) ; + QVERIFY( w_json.value().isValid() ); QVERIFY( QgsJsonUtils::jsonFromVariant( w_json.value() ).is_string() ); // avoid dumping as strings are quoted, so would be double quoted - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front( ) ), QStringLiteral( "abc" ) ); + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front() ), QStringLiteral( "abc" ) ); #endif } @@ -189,7 +189,7 @@ void TestQgsTextEditWrapper::testWithJsonBInPostgres() QCOMPARE( vl_json->fields().at( 1 ).type(), QVariant::Map ); QgsTextEditWrapper w_json( vl_json, vl_json->fields().indexOf( QLatin1String( "jbvalue" ) ), nullptr, nullptr ); - QLineEdit *widget = qobject_cast< QLineEdit * >( w_json.widget() ); + QLineEdit *widget = qobject_cast( w_json.widget() ); w_json.setEnabled( true ); // check text output from DB @@ -218,7 +218,7 @@ void TestQgsTextEditWrapper::testWithJsonBInPostgres() widget->setText( QString( "{\"foo\":\"bar\",\"baz\":[1,2,3]}" ) ); QVERIFY( w_json.value().isValid() ); QVERIFY( w_json.value().userType() == QMetaType::QVariantMap ); - json complexJson = QgsJsonUtils::jsonFromVariant( w_json.value() ); + json complexJson = QgsJsonUtils::jsonFromVariant( w_json.value() ); QVERIFY( complexJson.is_object() ); const json jsonArr = complexJson.at( "baz" ); QCOMPARE( QString::fromStdString( jsonArr.dump() ), QStringLiteral( "[1,2,3]" ) ); @@ -228,14 +228,14 @@ void TestQgsTextEditWrapper::testWithJsonBInPostgres() widget->setText( QString( "" ) ); QVERIFY( w_json.value().isValid() ); QVERIFY( QgsJsonUtils::jsonFromVariant( w_json.value() ).is_string() ); - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front( ) ), QStringLiteral( "\"\"" ) ); + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front() ), QStringLiteral( "\"\"" ) ); //test quoted empty widget->setText( QString( "\"\"" ) ); QVERIFY( w_json.value().isValid() ); QVERIFY( QgsJsonUtils::jsonFromVariant( w_json.value() ).is_string() ); - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front( ) ), QStringLiteral( "\"\"" ) ); + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front() ), QStringLiteral( "\"\"" ) ); // test invalid JSON widget->setText( QString( "{\"body\";\"text\"}" ) ); @@ -272,10 +272,10 @@ void TestQgsTextEditWrapper::testWithJsonBInPostgres() // test with quoted string (valid JSON) widget->setText( QString( "\"abc\"" ) ); - QVERIFY( w_json.value().isValid() ) ; + QVERIFY( w_json.value().isValid() ); QVERIFY( QgsJsonUtils::jsonFromVariant( w_json.value() ).is_string() ); // avoid dumping as strings are quoted, so would be double quoted - QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front( ) ), QStringLiteral( "abc" ) ); + QCOMPARE( QString::fromStdString( QgsJsonUtils::jsonFromVariant( w_json.value() ).front() ), QStringLiteral( "abc" ) ); #endif } diff --git a/tests/src/gui/testqgsvaluemapconfigdlg.cpp b/tests/src/gui/testqgsvaluemapconfigdlg.cpp index 727ff6dda6ed..38c4a7dd8357 100644 --- a/tests/src/gui/testqgsvaluemapconfigdlg.cpp +++ b/tests/src/gui/testqgsvaluemapconfigdlg.cpp @@ -30,10 +30,10 @@ class TestQgsValueMapConfigDlg : public QObject TestQgsValueMapConfigDlg() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testLoadFromCSV(); }; diff --git a/tests/src/gui/testqgsvaluemapwidgetwrapper.cpp b/tests/src/gui/testqgsvaluemapwidgetwrapper.cpp index 080a13b8718e..366c7c71f4c5 100644 --- a/tests/src/gui/testqgsvaluemapwidgetwrapper.cpp +++ b/tests/src/gui/testqgsvaluemapwidgetwrapper.cpp @@ -31,12 +31,11 @@ class TestQgsValueMapWidgetWrapper : public QObject TestQgsValueMapWidgetWrapper() = default; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testPopulateComboBox(); - }; void TestQgsValueMapWidgetWrapper::initTestCase() @@ -77,7 +76,7 @@ void TestQgsValueMapWidgetWrapper::testPopulateComboBox() config.insert( QStringLiteral( "map" ), valueList ); - std::unique_ptr< QComboBox > combo = std::make_unique< QComboBox >(); + std::unique_ptr combo = std::make_unique(); // with nulls QgsValueMapConfigDlg::populateComboBox( combo.get(), config, false ); @@ -129,7 +128,6 @@ void TestQgsValueMapWidgetWrapper::testPopulateComboBox() QCOMPARE( combo->itemData( 0 ).toString(), QStringLiteral( "val 1" ) ); QCOMPARE( combo->itemText( 1 ), QStringLiteral( "desc 2" ) ); QCOMPARE( combo->itemData( 1 ).toString(), QStringLiteral( "val 2" ) ); - } QGSTEST_MAIN( TestQgsValueMapWidgetWrapper ) diff --git a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp index 381677710536..57583fab9ba7 100644 --- a/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp +++ b/tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp @@ -42,10 +42,10 @@ class TestQgsValueRelationWidgetWrapper : public QObject QTemporaryDir tempDir; private slots: - void initTestCase(); // will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void cleanupTestCase(); // will be called after the last testfunction was executed. - void init(); // will be called before each testfunction is executed. - void cleanup(); // will be called after every testfunction. + void init(); // will be called before each testfunction is executed. + void cleanup(); // will be called after every testfunction. void testScrollBarUnlocked(); void testDrillDown(); @@ -86,7 +86,6 @@ void TestQgsValueRelationWidgetWrapper::init() void TestQgsValueRelationWidgetWrapper::cleanup() { - } void TestQgsValueRelationWidgetWrapper::testScrollBarUnlocked() @@ -124,7 +123,7 @@ void TestQgsValueRelationWidgetWrapper::testScrollBarUnlocked() QgsValueRelationWidgetWrapper w( &vl2, vl2.fields().indexOf( QLatin1String( "fk_municipality" ) ), nullptr, nullptr ); QVariantMap cfg; cfg.insert( QStringLiteral( "Layer" ), vl1.id() ); - cfg.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg.insert( QStringLiteral( "Value" ), QStringLiteral( "municipality" ) ); cfg.insert( QStringLiteral( "AllowMulti" ), true ); cfg.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -197,7 +196,7 @@ void TestQgsValueRelationWidgetWrapper::testDrillDown() QgsValueRelationWidgetWrapper w_municipality( &vl2, vl2.fields().indexOf( QLatin1String( "fk_municipality" ) ), nullptr, nullptr ); QVariantMap cfg_municipality; cfg_municipality.insert( QStringLiteral( "Layer" ), vl1.id() ); - cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_municipality.insert( QStringLiteral( "Value" ), QStringLiteral( "municipality" ) ); cfg_municipality.insert( QStringLiteral( "AllowMulti" ), false ); cfg_municipality.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -230,7 +229,7 @@ void TestQgsValueRelationWidgetWrapper::testDrillDown() QCOMPARE( w_municipality.value().toString(), QStringLiteral( "1" ) ); // Filter by geometry - cfg_municipality[ QStringLiteral( "FilterExpression" ) ] = QStringLiteral( "contains(buffer(@current_geometry, 1 ), $geometry)" ); + cfg_municipality[QStringLiteral( "FilterExpression" )] = QStringLiteral( "contains(buffer(@current_geometry, 1 ), $geometry)" ); w_municipality.setConfig( cfg_municipality ); w_municipality.setFeature( f3 ); QCOMPARE( w_municipality.mComboBox->count(), 1 ); @@ -247,7 +246,7 @@ void TestQgsValueRelationWidgetWrapper::testDrillDown() QCOMPARE( w_municipality.mComboBox->currentIndex(), 1 ); // Enlarge the buffer - cfg_municipality[ QStringLiteral( "FilterExpression" ) ] = QStringLiteral( "contains(buffer(@current_geometry, 3 ), $geometry)" ); + cfg_municipality[QStringLiteral( "FilterExpression" )] = QStringLiteral( "contains(buffer(@current_geometry, 3 ), $geometry)" ); w_municipality.setConfig( cfg_municipality ); w_municipality.setFeature( f3 ); QCOMPARE( w_municipality.mComboBox->count(), 2 ); @@ -274,7 +273,6 @@ void TestQgsValueRelationWidgetWrapper::testDrillDown() w_municipality.setFeature( f3 ); QCOMPARE( w_municipality.mComboBox->itemText( 1 ), QStringLiteral( "Dreamland By The Clouds" ) ); QCOMPARE( w_municipality.mComboBox->itemText( 0 ), QStringLiteral( "Some Place By The River" ) ); - } void TestQgsValueRelationWidgetWrapper::testDrillDownMulti() @@ -312,7 +310,7 @@ void TestQgsValueRelationWidgetWrapper::testDrillDownMulti() QgsValueRelationWidgetWrapper w_municipality( &vl2, vl2.fields().indexOf( QLatin1String( "fk_municipality" ) ), nullptr, nullptr ); QVariantMap cfg_municipality; cfg_municipality.insert( QStringLiteral( "Layer" ), vl1.id() ); - cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_municipality.insert( QStringLiteral( "Value" ), QStringLiteral( "municipality" ) ); cfg_municipality.insert( QStringLiteral( "AllowMulti" ), true ); cfg_municipality.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -334,7 +332,7 @@ void TestQgsValueRelationWidgetWrapper::testDrillDownMulti() QCOMPARE( w_municipality.value(), QVariant( QStringLiteral( "{1}" ) ) ); // Filter by geometry - cfg_municipality[ QStringLiteral( "FilterExpression" ) ] = QStringLiteral( "contains(buffer(@current_geometry, 1 ), $geometry)" ); + cfg_municipality[QStringLiteral( "FilterExpression" )] = QStringLiteral( "contains(buffer(@current_geometry, 1 ), $geometry)" ); w_municipality.setConfig( cfg_municipality ); w_municipality.setFeature( f3 ); QCOMPARE( w_municipality.mTableWidget->rowCount(), 1 ); @@ -347,7 +345,7 @@ void TestQgsValueRelationWidgetWrapper::testDrillDownMulti() QCOMPARE( w_municipality.mTableWidget->item( 0, 0 )->text(), QStringLiteral( "Dreamland By The Clouds" ) ); // Enlarge the buffer - cfg_municipality[ QStringLiteral( "FilterExpression" ) ] = QStringLiteral( "contains(buffer(@current_geometry, 3 ), $geometry)" ); + cfg_municipality[QStringLiteral( "FilterExpression" )] = QStringLiteral( "contains(buffer(@current_geometry, 3 ), $geometry)" ); w_municipality.setConfig( cfg_municipality ); w_municipality.setFeature( f3 ); QCOMPARE( w_municipality.mTableWidget->rowCount(), 2 ); @@ -364,7 +362,7 @@ void TestQgsValueRelationWidgetWrapper::testDrillDownMulti() QCOMPARE( w_municipality.mTableWidget->item( 1, 0 )->checkState(), Qt::Checked ); // Check with passing a variant list - w_municipality.setValues( QVariantList( {1, 2} ), QVariantList() ); + w_municipality.setValues( QVariantList( { 1, 2 } ), QVariantList() ); QCOMPARE( w_municipality.value(), QVariant( QStringLiteral( "{2,1}" ) ) ); // Check values are checked @@ -391,7 +389,7 @@ void TestQgsValueRelationWidgetWrapper::testZeroIndexInRelatedTable() // insert some features QgsFeature f1( vl1.fields() ); - f1.setAttribute( QStringLiteral( "pk" ), 0 ); // !!! Notice: pk 0 + f1.setAttribute( QStringLiteral( "pk" ), 0 ); // !!! Notice: pk 0 f1.setAttribute( QStringLiteral( "province" ), 123 ); f1.setAttribute( QStringLiteral( "municipality" ), QStringLiteral( "Some Place By The River" ) ); f1.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POLYGON(( 0 0, 0 1, 1 1, 1 0, 0 0 ))" ) ) ); @@ -416,7 +414,7 @@ void TestQgsValueRelationWidgetWrapper::testZeroIndexInRelatedTable() QgsValueRelationWidgetWrapper w_municipality( &vl2, vl2.fields().indexOf( QLatin1String( "fk_municipality" ) ), nullptr, nullptr ); QVariantMap cfg_municipality; cfg_municipality.insert( QStringLiteral( "Layer" ), vl1.id() ); - cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_municipality.insert( QStringLiteral( "Value" ), QStringLiteral( "municipality" ) ); cfg_municipality.insert( QStringLiteral( "AllowMulti" ), false ); cfg_municipality.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -457,7 +455,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInPostgres() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_json, vl_json->fields().indexOf( QLatin1String( "jvalue" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "name" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -502,7 +500,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInPostgres() QgsValueRelationWidgetWrapper w_favoriteauthors_b( vl_json, vl_json->fields().indexOf( QLatin1String( "jbvalue" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors_b; cfg_favoriteauthors_b.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors_b.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_favoriteauthors_b.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_favoriteauthors_b.insert( QStringLiteral( "Value" ), QStringLiteral( "name" ) ); cfg_favoriteauthors_b.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors_b.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -569,7 +567,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInGPKG() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_json, vl_json->fields().indexOf( QLatin1String( "json_content" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "NAME" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -696,7 +694,7 @@ void TestQgsValueRelationWidgetWrapper::testWithTextInGPKG() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_text, vl_text->fields().indexOf( QLatin1String( "PRFEDEA" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "NAME" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -868,7 +866,7 @@ void TestQgsValueRelationWidgetWrapper::testWithTextInGPKGTextFk() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_text, vl_text->fields().indexOf( QLatin1String( "PRFEDEA" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "NAME" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "NAME" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "NAME" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -1088,13 +1086,9 @@ void TestQgsValueRelationWidgetWrapper::testWithTextInGPKGWeirdTextFk() // create ogr spatialite layer for authors with weird signs (vl_authors) myTempFileName = myTempDirName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ); - QFile::copy( myFileName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ), - myTempFileName ); + QFile::copy( myFileName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ), myTempFileName ); const QFileInfo myMapFileInfoAuthor( myTempFileName ); - QgsVectorLayer *vl_authors = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ) - .arg( myMapFileInfoAuthor.filePath() ).arg( QLatin1String( "authors" ) ), - QStringLiteral( "test" ), - QStringLiteral( "spatialite" ) ); + QgsVectorLayer *vl_authors = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ).arg( myMapFileInfoAuthor.filePath() ).arg( QLatin1String( "authors" ) ), QStringLiteral( "test" ), QStringLiteral( "spatialite" ) ); QVERIFY( vl_authors->isValid() ); QgsProject::instance()->addMapLayer( vl_text, false, false ); @@ -1105,7 +1099,7 @@ void TestQgsValueRelationWidgetWrapper::testWithTextInGPKGWeirdTextFk() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_text, vl_text->fields().indexOf( QLatin1String( "PRFEDEA" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk_text" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk_text" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "name" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -1262,17 +1256,10 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialite() const QString myFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt const QString myTempDirName = tempDir.path(); const QString myTempFileName = myTempDirName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ); - QFile::copy( myFileName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ), - myTempFileName ); + QFile::copy( myFileName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ), myTempFileName ); const QFileInfo myMapFileInfo( myTempFileName ); - QgsVectorLayer *vl_json = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ) - .arg( myMapFileInfo.filePath() ).arg( QLatin1String( "json" ) ), - QStringLiteral( "test" ), - QStringLiteral( "spatialite" ) ); - QgsVectorLayer *vl_authors = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ) - .arg( myMapFileInfo.filePath() ).arg( QLatin1String( "authors" ) ), - QStringLiteral( "test" ), - QStringLiteral( "spatialite" ) ); + QgsVectorLayer *vl_json = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ).arg( myMapFileInfo.filePath() ).arg( QLatin1String( "json" ) ), QStringLiteral( "test" ), QStringLiteral( "spatialite" ) ); + QgsVectorLayer *vl_authors = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ).arg( myMapFileInfo.filePath() ).arg( QLatin1String( "authors" ) ), QStringLiteral( "test" ), QStringLiteral( "spatialite" ) ); const auto fk_field_idx { vl_json->fields().indexOf( fk_field ) }; QVERIFY( vl_json->isValid() ); @@ -1287,7 +1274,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialite() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_json, fk_field_idx, nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "name" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -1340,7 +1327,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialite() w_favoriteauthors.mTableWidget->item( 4, 0 )->setCheckState( Qt::Checked ); //check if first feature checked correctly (1,2,3,5) - QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList( {1, 2, 3, 5} ) ) ); + QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList( { 1, 2, 3, 5 } ) ) ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 0, 0 )->checkState(), Qt::Checked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 1, 0 )->checkState(), Qt::Checked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 2, 0 )->checkState(), Qt::Checked ); @@ -1361,7 +1348,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialite() // FEATURE 2 w_favoriteauthors.setFeature( vl_json->getFeature( 2 ) ); - QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList( {2, 5} ) ) ); + QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList( { 2, 5 } ) ) ); //check if second feature checked correctly QCOMPARE( w_favoriteauthors.mTableWidget->item( 0, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 1, 0 )->checkState(), Qt::Checked ); @@ -1375,7 +1362,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialite() w_favoriteauthors.setFeature( vl_json->getFeature( 4 ) ); // Because allowNull is false we have a NULL variant here QCOMPARE( w_favoriteauthors.value(), QgsVariantUtils::createNullVariant( QMetaType::Type::QVariantList ) ); - cfg_favoriteauthors[ QStringLiteral( "AllowNull" ) ] = true; + cfg_favoriteauthors[QStringLiteral( "AllowNull" )] = true; w_favoriteauthors.setConfig( cfg_favoriteauthors ); //check if first feature checked correctly (empty list) QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList() ) ); @@ -1386,7 +1373,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialite() QCOMPARE( w_favoriteauthors.mTableWidget->item( 4, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 5, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 6, 0 )->checkState(), Qt::Unchecked ); - cfg_favoriteauthors[ QStringLiteral( "AllowNull" ) ] = false; + cfg_favoriteauthors[QStringLiteral( "AllowNull" )] = false; w_favoriteauthors.setConfig( cfg_favoriteauthors ); // FEATURE 5 @@ -1394,10 +1381,10 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialite() // Because allowNull is false we have a NULL variant here QCOMPARE( w_favoriteauthors.value(), QgsVariantUtils::createNullVariant( QMetaType::Type::QVariantList ) ); - cfg_favoriteauthors[ QStringLiteral( "AllowNull" ) ] = true; + cfg_favoriteauthors[QStringLiteral( "AllowNull" )] = true; w_favoriteauthors.setConfig( cfg_favoriteauthors ); //check if first feature checked correctly (empty list) - QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList( ) ) ); + QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList() ) ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 0, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 1, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 2, 0 )->checkState(), Qt::Unchecked ); @@ -1415,17 +1402,10 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialiteTextFk() const QString myFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt const QString myTempDirName = tempDir.path(); const QString myTempFileName = myTempDirName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ); - QFile::copy( myFileName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ), - myTempFileName ); + QFile::copy( myFileName + QStringLiteral( "/valuerelation_widget_wrapper_test.spatialite.sqlite" ), myTempFileName ); const QFileInfo myMapFileInfo( myTempFileName ); - QgsVectorLayer *vl_json = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ) - .arg( myMapFileInfo.filePath() ).arg( QLatin1String( "json" ) ), - QStringLiteral( "test" ), - QStringLiteral( "spatialite" ) ); - QgsVectorLayer *vl_authors = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ) - .arg( myMapFileInfo.filePath() ).arg( QLatin1String( "authors" ) ), - QStringLiteral( "test" ), - QStringLiteral( "spatialite" ) ); + QgsVectorLayer *vl_json = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ).arg( myMapFileInfo.filePath() ).arg( QLatin1String( "json" ) ), QStringLiteral( "test" ), QStringLiteral( "spatialite" ) ); + QgsVectorLayer *vl_authors = new QgsVectorLayer( QStringLiteral( R"(dbname='%1' table="%2")" ).arg( myMapFileInfo.filePath() ).arg( QLatin1String( "authors" ) ), QStringLiteral( "test" ), QStringLiteral( "spatialite" ) ); const auto fk_field_idx { vl_json->fields().indexOf( fk_field ) }; QVERIFY( vl_json->isValid() ); @@ -1440,7 +1420,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialiteTextFk() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_json, fk_field_idx, nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk_text" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "pk_text" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "name" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -1544,11 +1524,11 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialiteTextFk() // Because allowNull is false we have a NULL variant here QCOMPARE( w_favoriteauthors.value(), QgsVariantUtils::createNullVariant( QMetaType::Type::QVariantList ) ); - cfg_favoriteauthors[ QStringLiteral( "AllowNull" ) ] = true; + cfg_favoriteauthors[QStringLiteral( "AllowNull" )] = true; w_favoriteauthors.setConfig( cfg_favoriteauthors ); //check if first feature checked correctly (NULL) - QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList( ) ) ); + QCOMPARE( w_favoriteauthors.value(), QVariant( QVariantList() ) ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 0, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 1, 0 )->checkState(), Qt::Unchecked ); @@ -1557,7 +1537,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialiteTextFk() QCOMPARE( w_favoriteauthors.mTableWidget->item( 4, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 5, 0 )->checkState(), Qt::Unchecked ); QCOMPARE( w_favoriteauthors.mTableWidget->item( 6, 0 )->checkState(), Qt::Unchecked ); - cfg_favoriteauthors[ QStringLiteral( "AllowNull" ) ] = false; + cfg_favoriteauthors[QStringLiteral( "AllowNull" )] = false; w_favoriteauthors.setConfig( cfg_favoriteauthors ); // FEATURE 5 @@ -1565,7 +1545,7 @@ void TestQgsValueRelationWidgetWrapper::testWithJsonInSpatialiteTextFk() // Because allowNull is false we have a NULL variant here QCOMPARE( w_favoriteauthors.value(), QgsVariantUtils::createNullVariant( QMetaType::Type::QVariantList ) ); - cfg_favoriteauthors[ QStringLiteral( "AllowNull" ) ] = true; + cfg_favoriteauthors[QStringLiteral( "AllowNull" )] = true; w_favoriteauthors.setConfig( cfg_favoriteauthors ); //check if first feature checked correctly (empty list) @@ -1590,7 +1570,7 @@ void TestQgsValueRelationWidgetWrapper::testMatchLayerName() // insert some features QgsFeature f1( vl1.fields() ); - f1.setAttribute( QStringLiteral( "pk" ), 0 ); // !!! Notice: pk 0 + f1.setAttribute( QStringLiteral( "pk" ), 0 ); // !!! Notice: pk 0 f1.setAttribute( QStringLiteral( "province" ), 123 ); f1.setAttribute( QStringLiteral( "municipality" ), QStringLiteral( "Some Place By The River" ) ); f1.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "POLYGON(( 0 0, 0 1, 1 1, 1 0, 0 0 ))" ) ) ); @@ -1616,7 +1596,7 @@ void TestQgsValueRelationWidgetWrapper::testMatchLayerName() QVariantMap cfg_municipality; cfg_municipality.insert( QStringLiteral( "Layer" ), QStringLiteral( "wrong_id_here_hope_name_is_good" ) ); cfg_municipality.insert( QStringLiteral( "LayerName" ), vl1.name() ); - cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_municipality.insert( QStringLiteral( "Value" ), QStringLiteral( "municipality" ) ); cfg_municipality.insert( QStringLiteral( "AllowMulti" ), false ); cfg_municipality.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -1667,7 +1647,7 @@ void TestQgsValueRelationWidgetWrapper::testRegressionGH42003() QgsValueRelationWidgetWrapper w_municipality( &vl2, vl2.fields().indexOf( QLatin1String( "fk_municipality" ) ), nullptr, nullptr ); QVariantMap cfg_municipality; cfg_municipality.insert( QStringLiteral( "Layer" ), vl1.id() ); - cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg_municipality.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg_municipality.insert( QStringLiteral( "Value" ), QStringLiteral( "municipality" ) ); cfg_municipality.insert( QStringLiteral( "AllowMulti" ), false ); cfg_municipality.insert( QStringLiteral( "NofColumns" ), 1 ); @@ -1699,7 +1679,6 @@ void TestQgsValueRelationWidgetWrapper::testRegressionGH42003() QCOMPARE( w_municipality.mComboBox->currentIndex(), 1 ); QCOMPARE( w_municipality.mComboBox->currentText(), QStringLiteral( "Some Place By The River" ) ); QCOMPARE( w_municipality.value().toString(), QStringLiteral( "1" ) ); - } void TestQgsValueRelationWidgetWrapper::testAllowMultiColumns() @@ -1723,7 +1702,7 @@ void TestQgsValueRelationWidgetWrapper::testAllowMultiColumns() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_text.get(), vl_text->fields().indexOf( QLatin1String( "PRFEDEA" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "NAME" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 3 ); @@ -1771,7 +1750,7 @@ void TestQgsValueRelationWidgetWrapper::testAllowMultiAndCompleter() QgsValueRelationWidgetWrapper w_favoriteauthors( vl_text.get(), vl_text->fields().indexOf( QLatin1String( "PRFEDEA" ) ), nullptr, nullptr ); QVariantMap cfg_favoriteauthors; cfg_favoriteauthors.insert( QStringLiteral( "Layer" ), vl_authors->id() ); - cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); + cfg_favoriteauthors.insert( QStringLiteral( "Key" ), QStringLiteral( "fid" ) ); cfg_favoriteauthors.insert( QStringLiteral( "Value" ), QStringLiteral( "NAME" ) ); cfg_favoriteauthors.insert( QStringLiteral( "AllowMulti" ), true ); cfg_favoriteauthors.insert( QStringLiteral( "NofColumns" ), 3 ); @@ -1857,7 +1836,7 @@ void TestQgsValueRelationWidgetWrapper::testGroup() QgsValueRelationWidgetWrapper w( &vl2, vl2.fields().indexOf( QLatin1String( "fk_municipality" ) ), nullptr, nullptr ); QVariantMap cfg; cfg.insert( QStringLiteral( "Layer" ), vl1.id() ); - cfg.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); + cfg.insert( QStringLiteral( "Key" ), QStringLiteral( "pk" ) ); cfg.insert( QStringLiteral( "Value" ), QStringLiteral( "municipality" ) ); cfg.insert( QStringLiteral( "Group" ), QStringLiteral( "province" ) ); cfg.insert( QStringLiteral( "DisplayGroupName" ), false ); @@ -1930,7 +1909,7 @@ void TestQgsValueRelationWidgetWrapper::testMultiEditMode() people->setEditorWidgetSetup( 0, QgsEditorWidgetSetup( QStringLiteral( "TextEdit" ), QVariantMap() ) ); QVariantMap cfg; cfg.insert( QStringLiteral( "Layer" ), famous->id() ); - cfg.insert( QStringLiteral( "Key" ), QStringLiteral( "name" ) ); + cfg.insert( QStringLiteral( "Key" ), QStringLiteral( "name" ) ); cfg.insert( QStringLiteral( "Value" ), QStringLiteral( "name" ) ); cfg.insert( QStringLiteral( "AllowMulti" ), false ); cfg.insert( QStringLiteral( "NofColumns" ), 1 ); diff --git a/tests/src/native/testqgsmacnative.cpp b/tests/src/native/testqgsmacnative.cpp index 2e10bd0fca7b..cf9da2c26fc9 100644 --- a/tests/src/native/testqgsmacnative.cpp +++ b/tests/src/native/testqgsmacnative.cpp @@ -20,7 +20,7 @@ //header for class being tested #include "qgsmacnative.h" -class TestQgsMacNative: public QObject +class TestQgsMacNative : public QObject { Q_OBJECT diff --git a/tests/src/providers/grass/testqgsgrassprovider.cpp b/tests/src/providers/grass/testqgsgrassprovider.cpp index 636c40bb4fea..b18ec149c925 100644 --- a/tests/src/providers/grass/testqgsgrassprovider.cpp +++ b/tests/src/providers/grass/testqgsgrassprovider.cpp @@ -49,16 +49,17 @@ extern "C" #include } -#define TINY_VALUE std::numeric_limits::epsilon() * 20 +#define TINY_VALUE std::numeric_limits::epsilon() * 20 // Feature + GRASS primitive type class TestQgsGrassFeature : public QgsFeature { public: TestQgsGrassFeature() { setValid( true ); } - explicit TestQgsGrassFeature( int type ) : grassType( type ) { setValid( true ); } + explicit TestQgsGrassFeature( int type ) + : grassType( type ) { setValid( true ); } - int grassType = 0 ; + int grassType = 0; }; // Command which can be composed of more GRASS features, e.g. boundaries + centroid equivalent @@ -87,13 +88,13 @@ class TestQgsGrassCommand {} QString toString() const; - Command command = AddFeature ; + Command command = AddFeature; // some commands (in case of multiple commands making single change) must not be verified - bool verify = true ; + bool verify = true; QList grassFeatures; QgsFeature expectedFeature; // simple feature for verification - QgsFeatureId fid = 0 ; + QgsFeatureId fid = 0; QgsField field; QgsGeometry *geometry = nullptr; QVariant value; @@ -186,15 +187,16 @@ class TestQgsGrassCommandGroup * \ingroup UnitTests * This is a unit test for the QgsRasterLayer class. */ -class TestQgsGrassProvider: public QgsTest +class TestQgsGrassProvider : public QgsTest { Q_OBJECT public: - TestQgsGrassProvider() : QgsTest( QStringLiteral( "Grass provider tests" ) ) {} + TestQgsGrassProvider() + : QgsTest( QStringLiteral( "Grass provider tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. + void initTestCase(); // will be called before the first testfunction is executed. void fatalError(); void locations(); @@ -208,6 +210,7 @@ class TestQgsGrassProvider: public QgsTest void rasterImport(); void vectorImport(); void edit(); + private: void reportRow( const QString &message ); void reportHeader( const QString &message ); @@ -228,7 +231,7 @@ class TestQgsGrassProvider: public QgsTest bool compare( QList features, QList expectedFeatures, bool &ok ); bool compare( QMap layers, bool &ok ); bool compare( QString uri, QgsVectorLayer *expectedLayer, bool &ok ); - QList< TestQgsGrassCommandGroup > createCommands(); + QList createCommands(); QList getFeatures( QgsVectorLayer *layer ); bool setAttributes( QgsFeature &feature, const QMap &attributes ); QString mGisdbase; @@ -236,7 +239,7 @@ class TestQgsGrassProvider: public QgsTest QString mBuildMapset; }; -#define GVERIFY(x) QVERIFY( verify(x) ) +#define GVERIFY( x ) QVERIFY( verify( x ) ) void TestQgsGrassProvider::reportRow( const QString &message ) { @@ -374,11 +377,11 @@ void TestQgsGrassProvider::mapsets() QStringList expectedMapsets; expectedMapsets << QStringLiteral( "PERMANENT" ) << QStringLiteral( "test" ) << QStringLiteral( "test6" ) << QStringLiteral( "test7" ) << QStringLiteral( "test8" ); - QStringList mapsets = QgsGrass::mapsets( tmpGisdbase, mLocation ); + QStringList mapsets = QgsGrass::mapsets( tmpGisdbase, mLocation ); reportRow( "expectedMapsets: " + expectedMapsets.join( QLatin1String( ", " ) ) ); reportRow( "mapsets: " + mapsets.join( QLatin1String( ", " ) ) ); compare( expectedMapsets, mapsets, ok ); - QgsGrass::setLocation( tmpGisdbase, mLocation ); // for G_is_mapset_in_search_path + QgsGrass::setLocation( tmpGisdbase, mLocation ); // for G_is_mapset_in_search_path // Disabled because adding of all mapsets to search path was disabled in setLocation() #if 0 Q_FOREACH ( QString expectedMapset, expectedMapsets ) @@ -440,7 +443,7 @@ void TestQgsGrassProvider::maps() bool ok = true; QStringList expectedVectors; expectedVectors << QStringLiteral( "test" ); - QStringList vectors = QgsGrass::vectors( mGisdbase, mLocation, mBuildMapset ); + QStringList vectors = QgsGrass::vectors( mGisdbase, mLocation, mBuildMapset ); reportRow( "expectedVectors: " + expectedVectors.join( QLatin1String( ", " ) ) ); reportRow( "vectors: " + vectors.join( QLatin1String( ", " ) ) ); compare( expectedVectors, vectors, ok ); @@ -448,7 +451,7 @@ void TestQgsGrassProvider::maps() reportRow( QLatin1String( "" ) ); QStringList expectedRasters; expectedRasters << QStringLiteral( "cell" ) << QStringLiteral( "dcell" ) << QStringLiteral( "fcell" ); - QStringList rasters = QgsGrass::rasters( mGisdbase, mLocation, QStringLiteral( "test" ) ); + QStringList rasters = QgsGrass::rasters( mGisdbase, mLocation, QStringLiteral( "test" ) ); reportRow( "expectedRasters: " + expectedRasters.join( QLatin1String( ", " ) ) ); reportRow( "rasters: " + rasters.join( QLatin1String( ", " ) ) ); compare( expectedRasters, rasters, ok ); @@ -484,7 +487,7 @@ void TestQgsGrassProvider::vectorLayers() void TestQgsGrassProvider::invalidLayer() { - std::unique_ptr< QgsVectorLayer > brokenLayer = std::make_unique< QgsVectorLayer >( QStringLiteral( "/not/valid" ), QStringLiteral( "test" ), QStringLiteral( "grass" ) ); + std::unique_ptr brokenLayer = std::make_unique( QStringLiteral( "/not/valid" ), QStringLiteral( "test" ), QStringLiteral( "grass" ) ); QVERIFY( !brokenLayer->isValid() ); QgsVectorDataProvider *provider = brokenLayer->dataProvider(); QVERIFY( provider ); @@ -552,8 +555,7 @@ void TestQgsGrassProvider::info() es = expectedStats.value( map ); // TODO: QgsGrass::info() may open dialog window on error which blocks tests QString error; - QHash info = QgsGrass::info( mGisdbase, mLocation, QStringLiteral( "test" ), map, QgsGrassObject::Raster, QStringLiteral( "stats" ), - expectedExtent, 10, 10, 5000, error ); + QHash info = QgsGrass::info( mGisdbase, mLocation, QStringLiteral( "test" ), map, QgsGrassObject::Raster, QStringLiteral( "stats" ), expectedExtent, 10, 10, 5000, error ); if ( !error.isEmpty() ) { ok = false; @@ -566,8 +568,8 @@ void TestQgsGrassProvider::info() s.minimumValue = info[QStringLiteral( "MIN" )].toDouble(); s.maximumValue = info[QStringLiteral( "MAX" )].toDouble(); - reportRow( QStringLiteral( "expectedStats: min = %1 max = %2" ).arg( es.minimumValue ).arg( es.maximumValue ) ) ; - reportRow( QStringLiteral( "stats: min = %1 max = %2" ).arg( s.minimumValue ).arg( s.maximumValue ) ) ; + reportRow( QStringLiteral( "expectedStats: min = %1 max = %2" ).arg( es.minimumValue ).arg( es.maximumValue ) ); + reportRow( QStringLiteral( "stats: min = %1 max = %2" ).arg( s.minimumValue ).arg( s.maximumValue ) ); compare( es.minimumValue, s.minimumValue, ok ); compare( es.maximumValue, s.maximumValue, ok ); @@ -619,7 +621,7 @@ void TestQgsGrassProvider::info() void TestQgsGrassProvider::crsEpsg3857() { QString error; - const QgsCoordinateReferenceSystem crs = QgsGrass::crs( mGisdbase, QStringLiteral( "webmerc" ), error ); + const QgsCoordinateReferenceSystem crs = QgsGrass::crs( mGisdbase, QStringLiteral( "webmerc" ), error ); QCOMPARE( error, QString() ); QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3857" ) ); } @@ -638,7 +640,7 @@ bool TestQgsGrassProvider::copyRecursively( const QString &srcFilePath, const QS if ( error ) { *error = QCoreApplication::translate( "Utils::FileUtils", "Failed to create directory '%1'." ) - .arg( QDir::toNativeSeparators( tgtFilePath ) ); + .arg( QDir::toNativeSeparators( tgtFilePath ) ); return false; } } @@ -661,8 +663,7 @@ bool TestQgsGrassProvider::copyRecursively( const QString &srcFilePath, const QS if ( error ) { *error = QCoreApplication::translate( "Utils::FileUtils", "Could not copy file '%1' to '%2'." ) - .arg( QDir::toNativeSeparators( srcFilePath ), - QDir::toNativeSeparators( tgtFilePath ) ); + .arg( QDir::toNativeSeparators( srcFilePath ), QDir::toNativeSeparators( tgtFilePath ) ); } return false; } @@ -680,8 +681,7 @@ bool TestQgsGrassProvider::removeRecursively( const QString &filePath, QString * if ( fileInfo.isDir() ) { QDir dir( filePath ); - QStringList fileNames = dir.entryList( QDir::Files | QDir::Hidden - | QDir::System | QDir::Dirs | QDir::NoDotAndDotDot ); + QStringList fileNames = dir.entryList( QDir::Files | QDir::Hidden | QDir::System | QDir::Dirs | QDir::NoDotAndDotDot ); Q_FOREACH ( const QString &fileName, fileNames ) { if ( !removeRecursively( filePath + QLatin1Char( '/' ) + fileName, error ) ) @@ -693,7 +693,7 @@ bool TestQgsGrassProvider::removeRecursively( const QString &filePath, QString * if ( error ) { *error = QCoreApplication::translate( "Utils::FileUtils", "Failed to remove directory '%1'." ) - .arg( QDir::toNativeSeparators( filePath ) ); + .arg( QDir::toNativeSeparators( filePath ) ); } return false; } @@ -705,7 +705,7 @@ bool TestQgsGrassProvider::removeRecursively( const QString &filePath, QString * if ( error ) { *error = QCoreApplication::translate( "Utils::FileUtils", "Failed to remove file '%1'." ) - .arg( QDir::toNativeSeparators( filePath ) ); + .arg( QDir::toNativeSeparators( filePath ) ); } return false; } @@ -825,18 +825,16 @@ void TestQgsGrassProvider::rasterImport() Q_NOWARN_DEPRECATED_PUSH projector->setCrs( providerCrs, mapsetCrs ); Q_NOWARN_DEPRECATED_POP - projector->destExtentSize( provider->extent(), provider->xSize(), provider->ySize(), - newExtent, newXSize, newYSize ); + projector->destExtentSize( provider->extent(), provider->xSize(), provider->ySize(), newExtent, newXSize, newYSize ); pipe->set( projector ); } QgsGrassObject rasterObject( tmpGisdbase, tmpLocation, tmpMapset, name, QgsGrassObject::Raster ); - QgsGrassRasterImport *import = new QgsGrassRasterImport( pipe, rasterObject, - newExtent, newXSize, newYSize ); + QgsGrassRasterImport *import = new QgsGrassRasterImport( pipe, rasterObject, newExtent, newXSize, newYSize ); if ( !import->import() ) { - reportRow( "import failed: " + import->error() ); + reportRow( "import failed: " + import->error() ); ok = false; } delete import; @@ -889,7 +887,7 @@ void TestQgsGrassProvider::vectorImport() QgsGrassVectorImport *import = new QgsGrassVectorImport( provider, vectorObject ); if ( !import->import() ) { - reportRow( "import failed: " + import->error() ); + reportRow( "import failed: " + import->error() ); ok = false; } delete import; @@ -901,9 +899,9 @@ void TestQgsGrassProvider::vectorImport() GVERIFY( ok ); } -QList< TestQgsGrassCommandGroup > TestQgsGrassProvider::createCommands() +QList TestQgsGrassProvider::createCommands() { - QList< TestQgsGrassCommandGroup > commandGroups; + QList commandGroups; TestQgsGrassCommandGroup commandGroup; TestQgsGrassCommand command; @@ -1135,7 +1133,7 @@ void TestQgsGrassProvider::edit() return; } - QList< TestQgsGrassCommandGroup > commandGroups = createCommands(); + QList commandGroups = createCommands(); for ( int i = 0; i < commandGroups.size(); i++ ) { @@ -1378,11 +1376,12 @@ void TestQgsGrassProvider::edit() } else if ( command.command == TestQgsGrassCommand::UndoAll ) { - if ( grassLayer->undoStack()->count() != editCommands.size() || - grassLayer->undoStack()->count() != expectedLayer->undoStack()->count() ) + if ( grassLayer->undoStack()->count() != editCommands.size() || grassLayer->undoStack()->count() != expectedLayer->undoStack()->count() ) { reportRow( QStringLiteral( "Different undo stack size: %1, expected: %2, editCommands: %3" ) - .arg( grassLayer->undoStack()->count() ).arg( expectedLayer->undoStack()->count() ).arg( editCommands.size() ) ); + .arg( grassLayer->undoStack()->count() ) + .arg( expectedLayer->undoStack()->count() ) + .arg( editCommands.size() ) ); commandOk = false; } else @@ -1407,11 +1406,12 @@ void TestQgsGrassProvider::edit() } else if ( command.command == TestQgsGrassCommand::RedoAll ) { - if ( grassLayer->undoStack()->count() != editCommands.size() || - grassLayer->undoStack()->count() != expectedLayer->undoStack()->count() ) + if ( grassLayer->undoStack()->count() != editCommands.size() || grassLayer->undoStack()->count() != expectedLayer->undoStack()->count() ) { reportRow( QStringLiteral( "Different undo stack size: %1, expected: %2, editCommands: %3" ) - .arg( grassLayer->undoStack()->count() ).arg( expectedLayer->undoStack()->count() ).arg( editCommands.size() ) ); + .arg( grassLayer->undoStack()->count() ) + .arg( expectedLayer->undoStack()->count() ) + .arg( editCommands.size() ) ); commandOk = false; } else @@ -1523,7 +1523,7 @@ bool TestQgsGrassProvider::equal( QgsFeature feature, QgsFeature expectedFeature if ( feature.attribute( index ) != expectedFeature.attribute( i ) ) { reportRow( QStringLiteral( "Attribute name %1, value: '%2' does not match expected value: '%3'" ) - .arg( name, feature.attribute( index ).toString(), expectedFeature.attribute( i ).toString() ) ); + .arg( name, feature.attribute( index ).toString(), expectedFeature.attribute( i ).toString() ) ); return false; } } @@ -1551,7 +1551,7 @@ bool TestQgsGrassProvider::compare( QList features, QList candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/dataset.copc.laz" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "copc" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/dataset.COPC.LAZ" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "copc" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); QVERIFY( !QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/dataset.copc.laz" ), QStringLiteral( "copc" ) ) ); QVERIFY( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/dataset.copc.laz" ), QStringLiteral( "ogr" ) ) ); @@ -175,8 +173,8 @@ void TestQgsCopcProvider::layerTypesForUri() QgsProviderMetadata *copcMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "copc" ) ); QVERIFY( copcMetadata->capabilities() & QgsProviderMetadata::LayerTypesForUri ); - QCOMPARE( copcMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.copc.laz" ) ), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); - QCOMPARE( copcMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/ept.json" ) ), QList< Qgis::LayerType >() ); + QCOMPARE( copcMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.copc.laz" ) ), QList() << Qgis::LayerType::PointCloud ); + QCOMPARE( copcMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/ept.json" ) ), QList() ); } void TestQgsCopcProvider::uriIsBlocklisted() @@ -191,7 +189,7 @@ void TestQgsCopcProvider::querySublayers() QgsProviderMetadata *copcMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "copc" ) ); // invalid uri - QList< QgsProviderSublayerDetails >res = copcMetadata->querySublayers( QString() ); + QList res = copcMetadata->querySublayers( QString() ); QVERIFY( res.empty() ); // not a copc layer @@ -209,15 +207,15 @@ void TestQgsCopcProvider::querySublayers() QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::PointCloud ); // make sure result is valid to load layer from - QgsProviderSublayerDetails::LayerOptions options{ QgsCoordinateTransformContext() }; - std::unique_ptr< QgsPointCloudLayer > ml( qgis::down_cast< QgsPointCloudLayer * >( res.at( 0 ).toLayer( options ) ) ); + QgsProviderSublayerDetails::LayerOptions options { QgsCoordinateTransformContext() }; + std::unique_ptr ml( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); } void TestQgsCopcProvider::brokenPath() { // test loading a bad layer URI - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( !layer->isValid() ); } @@ -253,7 +251,7 @@ void TestQgsCopcProvider::validLayer() { const QString dataPath = copyTestData( QStringLiteral( "point_clouds/copc/sunshine-coast.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:28356" ) ); @@ -275,7 +273,7 @@ void TestQgsCopcProvider::validLayerWithCopcHierarchy() { const QString dataPath = copyTestData( QStringLiteral( "point_clouds/copc/lone-star.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); QGSCOMPARENEAR( layer->extent().xMinimum(), 515368.6022, 0.1 ); @@ -293,7 +291,7 @@ void TestQgsCopcProvider::attributes() { const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/sunshine-coast.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); const QgsPointCloudAttributeCollection attributes = layer->attributes(); @@ -346,15 +344,15 @@ void TestQgsCopcProvider::calculateZRange() { const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/sunshine-coast.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); QgsDoubleRange range = layer->elevationProperties()->calculateZRange( layer.get() ); QGSCOMPARENEAR( range.lower(), 74.34, 0.01 ); QGSCOMPARENEAR( range.upper(), 80.02, 0.01 ); - static_cast< QgsPointCloudLayerElevationProperties * >( layer->elevationProperties() )->setZScale( 2 ); - static_cast< QgsPointCloudLayerElevationProperties * >( layer->elevationProperties() )->setZOffset( 0.5 ); + static_cast( layer->elevationProperties() )->setZScale( 2 ); + static_cast( layer->elevationProperties() )->setZOffset( 0.5 ); range = layer->elevationProperties()->calculateZRange( layer.get() ); QGSCOMPARENEAR( range.lower(), 149.18, 0.01 ); @@ -374,7 +372,7 @@ void TestQgsCopcProvider::testIdentify() const QString datasetPath = copyTestData( srcDatasetPath ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( datasetPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( datasetPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); @@ -394,22 +392,22 @@ void TestQgsCopcProvider::testIdentify() const QMap identifiedPoint = points[0]; QMap expected; - expected[ QStringLiteral( "Blue" ) ] = 0; - expected[ QStringLiteral( "Classification" ) ] = 2; - expected[ QStringLiteral( "EdgeOfFlightLine" ) ] = 0; - expected[ QStringLiteral( "GpsTime (raw)" ) ] = 268793.37257748609409; - expected[ QStringLiteral( "Green" ) ] = 0; - expected[ QStringLiteral( "Intensity" ) ] = 1765; - expected[ QStringLiteral( "NumberOfReturns" ) ] = 1; - expected[ QStringLiteral( "PointSourceId" ) ] = 7041; - expected[ QStringLiteral( "Red" ) ] = 0; - expected[ QStringLiteral( "ReturnNumber" ) ] = 1; - expected[ QStringLiteral( "ScanAngleRank" ) ] = -28.0020008087; - expected[ QStringLiteral( "ScanDirectionFlag" ) ] = 1; - expected[ QStringLiteral( "UserData" ) ] = 17; - expected[ QStringLiteral( "X" ) ] = 498062.52; - expected[ QStringLiteral( "Y" ) ] = 7050996.61; - expected[ QStringLiteral( "Z" ) ] = 75.0; + expected[QStringLiteral( "Blue" )] = 0; + expected[QStringLiteral( "Classification" )] = 2; + expected[QStringLiteral( "EdgeOfFlightLine" )] = 0; + expected[QStringLiteral( "GpsTime (raw)" )] = 268793.37257748609409; + expected[QStringLiteral( "Green" )] = 0; + expected[QStringLiteral( "Intensity" )] = 1765; + expected[QStringLiteral( "NumberOfReturns" )] = 1; + expected[QStringLiteral( "PointSourceId" )] = 7041; + expected[QStringLiteral( "Red" )] = 0; + expected[QStringLiteral( "ReturnNumber" )] = 1; + expected[QStringLiteral( "ScanAngleRank" )] = -28.0020008087; + expected[QStringLiteral( "ScanDirectionFlag" )] = 1; + expected[QStringLiteral( "UserData" )] = 17; + expected[QStringLiteral( "X" )] = 498062.52; + expected[QStringLiteral( "Y" )] = 7050996.61; + expected[QStringLiteral( "Z" )] = 75.0; // compare values using toDouble() so that fuzzy comparison is used in case of // tiny rounding errors (e.g. 74.6 vs 74.60000000000001) for ( auto it = expected.constBegin(); it != expected.constEnd(); it++ ) @@ -421,34 +419,34 @@ void TestQgsCopcProvider::testIdentify() // identify 1 point (circular point shape) { QPolygonF polygon; - polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); - polygon.push_back( QPointF( 498066.21890226693358, 7050995.0112726856023 ) ); - polygon.push_back( QPointF( 498066.21890226693358, 7050995.0919103417546 ) ); - polygon.push_back( QPointF( 498066.28873652569018, 7050995.1322291698307 ) ); - polygon.push_back( QPointF( 498066.35857078444678, 7050995.0919103417546 ) ); - polygon.push_back( QPointF( 498066.35857078444678, 7050995.0112726856023 ) ); - polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); - const float maxErrorInMapCoords = 0.0091431681066751480103; + polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); + polygon.push_back( QPointF( 498066.21890226693358, 7050995.0112726856023 ) ); + polygon.push_back( QPointF( 498066.21890226693358, 7050995.0919103417546 ) ); + polygon.push_back( QPointF( 498066.28873652569018, 7050995.1322291698307 ) ); + polygon.push_back( QPointF( 498066.35857078444678, 7050995.0919103417546 ) ); + polygon.push_back( QPointF( 498066.35857078444678, 7050995.0112726856023 ) ); + polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); + const float maxErrorInMapCoords = 0.0091431681066751480103; const QVector> identifiedPoints = layer->dataProvider()->identify( maxErrorInMapCoords, QgsGeometry::fromQPolygonF( polygon ) ); QVector> expected; { QMap point; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "268793.3373408913" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "278" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "1" ; - point[ QStringLiteral( "PointSourceId" ) ] = "7041" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "1" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-28.0020008087" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "1" ; - point[ QStringLiteral( "UserData" ) ] = "17" ; - point[ QStringLiteral( "X" ) ] = "498066.27" ; - point[ QStringLiteral( "Y" ) ] = "7050995.06" ; - point[ QStringLiteral( "Z" ) ] = "74.60" ; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "268793.3373408913"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "278"; + point[QStringLiteral( "NumberOfReturns" )] = "1"; + point[QStringLiteral( "PointSourceId" )] = "7041"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "ReturnNumber" )] = "1"; + point[QStringLiteral( "ScanAngleRank" )] = "-28.0020008087"; + point[QStringLiteral( "ScanDirectionFlag" )] = "1"; + point[QStringLiteral( "UserData" )] = "17"; + point[QStringLiteral( "X" )] = "498066.27"; + point[QStringLiteral( "Y" )] = "7050995.06"; + point[QStringLiteral( "Z" )] = "74.60"; expected.push_back( point ); } @@ -476,42 +474,42 @@ void TestQgsCopcProvider::testIdentify() QVector> expected; { QMap point; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "268793.3813974548" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1142" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "1" ; - point[ QStringLiteral( "PointSourceId" ) ] = "7041" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "1" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-28.0020008087" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "1" ; - point[ QStringLiteral( "UserData" ) ] = "17" ; - point[ QStringLiteral( "X" ) ] = "498063.14" ; - point[ QStringLiteral( "Y" ) ] = "7050996.79" ; - point[ QStringLiteral( "Z" ) ] = "74.89" ; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "268793.3813974548"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1142"; + point[QStringLiteral( "NumberOfReturns" )] = "1"; + point[QStringLiteral( "PointSourceId" )] = "7041"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "ReturnNumber" )] = "1"; + point[QStringLiteral( "ScanAngleRank" )] = "-28.0020008087"; + point[QStringLiteral( "ScanDirectionFlag" )] = "1"; + point[QStringLiteral( "UserData" )] = "17"; + point[QStringLiteral( "X" )] = "498063.14"; + point[QStringLiteral( "Y" )] = "7050996.79"; + point[QStringLiteral( "Z" )] = "74.89"; expected.push_back( point ); } { QMap point; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "3" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "269160.5176644815" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1631" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "1" ; - point[ QStringLiteral( "PointSourceId" ) ] = "7042" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "1" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-12" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "1" ; - point[ QStringLiteral( "UserData" ) ] = "17" ; - point[ QStringLiteral( "X" ) ] = "498063.11" ; - point[ QStringLiteral( "Y" ) ] = "7050996.75" ; - point[ QStringLiteral( "Z" ) ] = "74.90" ; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "3"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "269160.5176644815"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1631"; + point[QStringLiteral( "NumberOfReturns" )] = "1"; + point[QStringLiteral( "PointSourceId" )] = "7042"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "ReturnNumber" )] = "1"; + point[QStringLiteral( "ScanAngleRank" )] = "-12"; + point[QStringLiteral( "ScanDirectionFlag" )] = "1"; + point[QStringLiteral( "UserData" )] = "17"; + point[QStringLiteral( "X" )] = "498063.11"; + point[QStringLiteral( "Y" )] = "7050996.75"; + point[QStringLiteral( "Z" )] = "74.90"; expected.push_back( point ); } @@ -568,69 +566,68 @@ void TestQgsCopcProvider::testExtraBytesAttributesValues() { const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/extrabytes-dataset.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); { const float maxErrorInMapCoords = 0.0015207174f; QPolygonF polygon; - polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); - polygon.push_back( QPointF( 527919.0742796324, 6210983.5918774214 ) ); - polygon.push_back( QPointF( 527919.0742796324, 6210983.4383113598 ) ); - polygon.push_back( QPointF( 527919.2459517354, 6210983.4383113598 ) ); - polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); + polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); + polygon.push_back( QPointF( 527919.0742796324, 6210983.5918774214 ) ); + polygon.push_back( QPointF( 527919.0742796324, 6210983.4383113598 ) ); + polygon.push_back( QPointF( 527919.2459517354, 6210983.4383113598 ) ); + polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); QVector> identifiedPoints = layer->dataProvider()->identify( maxErrorInMapCoords, QgsGeometry::fromQPolygonF( polygon ) ); QVector> expectedPoints; { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "14.170000076293945" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "Deviation" ) ] = "0" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "302522582.235839" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1417" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-8.050000190734863" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "3" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.11" ; - point[ QStringLiteral( "Y" ) ] = "6210983.55" ; - point[ QStringLiteral( "Z" ) ] = "147.111" ; + point[QStringLiteral( "Amplitude" )] = "14.170000076293945"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "Deviation" )] = "0"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "302522582.235839"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1417"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-8.050000190734863"; + point[QStringLiteral( "ReturnNumber" )] = "3"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "X" )] = "527919.11"; + point[QStringLiteral( "Y" )] = "6210983.55"; + point[QStringLiteral( "Z" )] = "147.111"; expectedPoints.push_back( point ); } { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "4.409999847412109" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "5" ; - point[ QStringLiteral( "Deviation" ) ] = "2" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "302522582.235838" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "441" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-17.829999923706055" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "2" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.1799999999" ; - point[ QStringLiteral( "Y" ) ] = "6210983.47" ; - point[ QStringLiteral( "Z" ) ] = "149.341" ; + point[QStringLiteral( "Amplitude" )] = "4.409999847412109"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "5"; + point[QStringLiteral( "Deviation" )] = "2"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "302522582.235838"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "441"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-17.829999923706055"; + point[QStringLiteral( "ReturnNumber" )] = "2"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "X" )] = "527919.1799999999"; + point[QStringLiteral( "Y" )] = "6210983.47"; + point[QStringLiteral( "Z" )] = "149.341"; expectedPoints.push_back( point ); } - auto cmp = []( const QMap &p1, const QMap &p2 ) - { + auto cmp = []( const QMap &p1, const QMap &p2 ) { return qgsVariantLessThan( p1.value( QStringLiteral( "X" ), 0 ), p2.value( QStringLiteral( "X" ), 0 ) ); }; std::sort( expectedPoints.begin(), expectedPoints.end(), cmp ); @@ -652,158 +649,157 @@ void TestQgsCopcProvider::testClassFlagsValues() { const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/extrabytes-dataset.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); { const float maxErrorInMapCoords = 0.0015207174f; QPolygonF polygon; - polygon.push_back( QPointF( 527919.6, 6210983.6 ) ); - polygon.push_back( QPointF( 527919.0, 6210983.6 ) ); - polygon.push_back( QPointF( 527919.0, 6210983.4 ) ); - polygon.push_back( QPointF( 527919.6, 6210983.4 ) ); - polygon.push_back( QPointF( 527919.6, 6210983.6 ) ); + polygon.push_back( QPointF( 527919.6, 6210983.6 ) ); + polygon.push_back( QPointF( 527919.0, 6210983.6 ) ); + polygon.push_back( QPointF( 527919.0, 6210983.4 ) ); + polygon.push_back( QPointF( 527919.6, 6210983.4 ) ); + polygon.push_back( QPointF( 527919.6, 6210983.6 ) ); QVector> identifiedPoints = layer->dataProvider()->identify( maxErrorInMapCoords, QgsGeometry::fromQPolygonF( polygon ) ); QVector> expectedPoints; { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "14.170000076293945" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "Deviation" ) ] = "0" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "302522582.235839" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1417" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-8.050000190734863" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "3" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "Synthetic" ) ] = "1" ; - point[ QStringLiteral( "KeyPoint" ) ] = "0" ; - point[ QStringLiteral( "Withheld" ) ] = "0" ; - point[ QStringLiteral( "Overlap" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.11" ; - point[ QStringLiteral( "Y" ) ] = "6210983.55" ; - point[ QStringLiteral( "Z" ) ] = "147.111" ; + point[QStringLiteral( "Amplitude" )] = "14.170000076293945"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "Deviation" )] = "0"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "302522582.235839"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1417"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-8.050000190734863"; + point[QStringLiteral( "ReturnNumber" )] = "3"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "Synthetic" )] = "1"; + point[QStringLiteral( "KeyPoint" )] = "0"; + point[QStringLiteral( "Withheld" )] = "0"; + point[QStringLiteral( "Overlap" )] = "0"; + point[QStringLiteral( "X" )] = "527919.11"; + point[QStringLiteral( "Y" )] = "6210983.55"; + point[QStringLiteral( "Z" )] = "147.111"; expectedPoints.push_back( point ); } { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "4.409999847412109" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "5" ; - point[ QStringLiteral( "Deviation" ) ] = "2" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "302522582.235838" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "441" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-17.829999923706055" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "2" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "Synthetic" ) ] = "1" ; - point[ QStringLiteral( "KeyPoint" ) ] = "1" ; - point[ QStringLiteral( "Withheld" ) ] = "0" ; - point[ QStringLiteral( "Overlap" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.1799999999" ; - point[ QStringLiteral( "Y" ) ] = "6210983.47" ; - point[ QStringLiteral( "Z" ) ] = "149.341" ; + point[QStringLiteral( "Amplitude" )] = "4.409999847412109"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "5"; + point[QStringLiteral( "Deviation" )] = "2"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "302522582.235838"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "441"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-17.829999923706055"; + point[QStringLiteral( "ReturnNumber" )] = "2"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "Synthetic" )] = "1"; + point[QStringLiteral( "KeyPoint" )] = "1"; + point[QStringLiteral( "Withheld" )] = "0"; + point[QStringLiteral( "Overlap" )] = "0"; + point[QStringLiteral( "X" )] = "527919.1799999999"; + point[QStringLiteral( "Y" )] = "6210983.47"; + point[QStringLiteral( "Z" )] = "149.341"; expectedPoints.push_back( point ); } { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "7.539999961853027" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "5" ; - point[ QStringLiteral( "Deviation" ) ] = "8" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "302522582.235837" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "754" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-14.720000267028809" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "2" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "Synthetic" ) ] = "1" ; - point[ QStringLiteral( "KeyPoint" ) ] = "1" ; - point[ QStringLiteral( "Withheld" ) ] = "1" ; - point[ QStringLiteral( "Overlap" ) ] = "1" ; - point[ QStringLiteral( "X" ) ] = "527919.31" ; - point[ QStringLiteral( "Y" ) ] = "6210983.42" ; - point[ QStringLiteral( "Z" ) ] = "150.99099999999999" ; + point[QStringLiteral( "Amplitude" )] = "7.539999961853027"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "5"; + point[QStringLiteral( "Deviation" )] = "8"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "302522582.235837"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "754"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-14.720000267028809"; + point[QStringLiteral( "ReturnNumber" )] = "2"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "Synthetic" )] = "1"; + point[QStringLiteral( "KeyPoint" )] = "1"; + point[QStringLiteral( "Withheld" )] = "1"; + point[QStringLiteral( "Overlap" )] = "1"; + point[QStringLiteral( "X" )] = "527919.31"; + point[QStringLiteral( "Y" )] = "6210983.42"; + point[QStringLiteral( "Z" )] = "150.99099999999999"; expectedPoints.push_back( point ); } { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "15.390000343322754" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "Deviation" ) ] = "6" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "302522582.235838" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1539" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-6.829999923706055" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "3" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "Synthetic" ) ] = "1" ; - point[ QStringLiteral( "KeyPoint" ) ] = "1" ; - point[ QStringLiteral( "Withheld" ) ] = "1" ; - point[ QStringLiteral( "Overlap" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.39" ; - point[ QStringLiteral( "Y" ) ] = "6210983.56" ; - point[ QStringLiteral( "Z" ) ] = "147.101" ; + point[QStringLiteral( "Amplitude" )] = "15.390000343322754"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "Deviation" )] = "6"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "302522582.235838"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1539"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-6.829999923706055"; + point[QStringLiteral( "ReturnNumber" )] = "3"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "Synthetic" )] = "1"; + point[QStringLiteral( "KeyPoint" )] = "1"; + point[QStringLiteral( "Withheld" )] = "1"; + point[QStringLiteral( "Overlap" )] = "0"; + point[QStringLiteral( "X" )] = "527919.39"; + point[QStringLiteral( "Y" )] = "6210983.56"; + point[QStringLiteral( "Z" )] = "147.101"; expectedPoints.push_back( point ); } { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "11.710000038146973" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "5" ; - point[ QStringLiteral( "Deviation" ) ] = "43" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime (raw)" ) ] = "302522582.23583597" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1171" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-10.550000190734863" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "1" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "Synthetic" ) ] = "0" ; - point[ QStringLiteral( "KeyPoint" ) ] = "0" ; - point[ QStringLiteral( "Withheld" ) ] = "0" ; - point[ QStringLiteral( "Overlap" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.58" ; - point[ QStringLiteral( "Y" ) ] = "6210983.42" ; - point[ QStringLiteral( "Z" ) ] = "151.131" ; + point[QStringLiteral( "Amplitude" )] = "11.710000038146973"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "5"; + point[QStringLiteral( "Deviation" )] = "43"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime (raw)" )] = "302522582.23583597"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1171"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-10.550000190734863"; + point[QStringLiteral( "ReturnNumber" )] = "1"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "Synthetic" )] = "0"; + point[QStringLiteral( "KeyPoint" )] = "0"; + point[QStringLiteral( "Withheld" )] = "0"; + point[QStringLiteral( "Overlap" )] = "0"; + point[QStringLiteral( "X" )] = "527919.58"; + point[QStringLiteral( "Y" )] = "6210983.42"; + point[QStringLiteral( "Z" )] = "151.131"; expectedPoints.push_back( point ); } - auto cmp = []( const QMap &p1, const QMap &p2 ) - { + auto cmp = []( const QMap &p1, const QMap &p2 ) { return qgsVariantLessThan( p1.value( QStringLiteral( "X" ), 0 ), p2.value( QStringLiteral( "X" ), 0 ) ); }; std::sort( expectedPoints.begin(), expectedPoints.end(), cmp ); @@ -825,7 +821,7 @@ void TestQgsCopcProvider::testPointCloudIndex() { const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/lone-star.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); QgsPointCloudIndex *index = layer->dataProvider()->index(); @@ -852,9 +848,9 @@ void TestQgsCopcProvider::testPointCloudIndex() QCOMPARE( bounds.xMin(), -170000 ); QCOMPARE( bounds.yMin(), -210000 ); QCOMPARE( bounds.zMin(), -85000 ); - QCOMPARE( bounds.xMax(), 250000 ); - QCOMPARE( bounds.yMax(), 210000 ); - QCOMPARE( bounds.zMax(), 335000 ); + QCOMPARE( bounds.xMax(), 250000 ); + QCOMPARE( bounds.yMax(), 210000 ); + QCOMPARE( bounds.zMax(), 335000 ); } { @@ -882,7 +878,7 @@ void TestQgsCopcProvider::testStatsCalculator() { const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/extrabytes-dataset.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QgsPointCloudIndex *index = layer->dataProvider()->index(); QgsPointCloudStatsCalculator calculator( index ); @@ -916,139 +912,139 @@ void TestQgsCopcProvider::testStatsCalculator() { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Amplitude" ) ); - QCOMPARE( ( float )s.minimum, 1.1599999666214 ); - QCOMPARE( ( float )s.maximum, 19.6000003814697 ); + QCOMPARE( ( float ) s.minimum, 1.1599999666214 ); + QCOMPARE( ( float ) s.maximum, 19.6000003814697 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Blue" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Synthetic" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 1 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 1 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 2 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "KeyPoint" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 1 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 1 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 2 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Withheld" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 1 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 1 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 2 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Overlap" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 1 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 1 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 2 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Classification" ) ); - QCOMPARE( ( float )s.minimum, 2 ); - QCOMPARE( ( float )s.maximum, 18 ); + QCOMPARE( ( float ) s.minimum, 2 ); + QCOMPARE( ( float ) s.maximum, 18 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 7 ); - QCOMPARE( classCount[ 2 ], 103782 ); - QCOMPARE( classCount[ 3 ], 484 ); - QCOMPARE( classCount[ 4 ], 79 ); - QCOMPARE( classCount[ 5 ], 966 ); - QCOMPARE( classCount[ 7 ], 12 ); - QCOMPARE( classCount[ 8 ], 648 ); - QCOMPARE( classCount[ 18 ], 1 ); + QCOMPARE( classCount[2], 103782 ); + QCOMPARE( classCount[3], 484 ); + QCOMPARE( classCount[4], 79 ); + QCOMPARE( classCount[5], 966 ); + QCOMPARE( classCount[7], 12 ); + QCOMPARE( classCount[8], 648 ); + QCOMPARE( classCount[18], 1 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Deviation" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 120 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 120 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "EdgeOfFlightLine" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "GpsTime" ) ); - QCOMPARE( ( float )s.minimum, ( float )302522581.972046196460723876953 ); - QCOMPARE( ( float )s.maximum, ( float )302522583.437068104743957519531 ); + QCOMPARE( ( float ) s.minimum, ( float ) 302522581.972046196460723876953 ); + QCOMPARE( ( float ) s.maximum, ( float ) 302522583.437068104743957519531 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Green" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Intensity" ) ); - QCOMPARE( ( float )s.minimum, 116 ); - QCOMPARE( ( float )s.maximum, 1960 ); + QCOMPARE( ( float ) s.minimum, 116 ); + QCOMPARE( ( float ) s.maximum, 1960 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "NumberOfReturns" ) ); - QCOMPARE( ( float )s.minimum, 1 ); - QCOMPARE( ( float )s.maximum, 5 ); + QCOMPARE( ( float ) s.minimum, 1 ); + QCOMPARE( ( float ) s.maximum, 5 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "PointSourceId" ) ); - QCOMPARE( ( float )s.minimum, 15017 ); - QCOMPARE( ( float )s.maximum, 15017 ); + QCOMPARE( ( float ) s.minimum, 15017 ); + QCOMPARE( ( float ) s.maximum, 15017 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Red" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Reflectance" ) ); - QCOMPARE( ( float )s.minimum, -21.1100006103515625 ); - QCOMPARE( ( float )s.maximum, -2.6099998950958251953125 ); + QCOMPARE( ( float ) s.minimum, -21.1100006103515625 ); + QCOMPARE( ( float ) s.maximum, -2.6099998950958251953125 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "ReturnNumber" ) ); - QCOMPARE( ( float )s.minimum, 1 ); - QCOMPARE( ( float )s.maximum, 5 ); + QCOMPARE( ( float ) s.minimum, 1 ); + QCOMPARE( ( float ) s.maximum, 5 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "ScanAngleRank" ) ); - QCOMPARE( ( float )s.minimum, -10.998000145f ); - QCOMPARE( ( float )s.maximum, -4.001999855f ); + QCOMPARE( ( float ) s.minimum, -10.998000145f ); + QCOMPARE( ( float ) s.maximum, -4.001999855f ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "ScanDirectionFlag" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "UserData" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } } @@ -1056,8 +1052,7 @@ void TestQgsCopcProvider::testQgsRangeRequestCache() { // Note: the QTest::qSleep calls were added to prevent 2 files from being created at very close times - auto request = []( const QUrl & url, const QString & range ) - { + auto request = []( const QUrl &url, const QString &range ) { QNetworkRequest req( url ); req.setRawHeader( "Range", range.toUtf8() ); return req; @@ -1132,7 +1127,7 @@ void TestQgsCopcProvider::testSaveLoadStats() const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/lone-star.copc.laz" ) ); { - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); QVERIFY( layer->dataProvider() && layer->dataProvider()->isValid() && layer->dataProvider()->index() ); @@ -1143,7 +1138,7 @@ void TestQgsCopcProvider::testSaveLoadStats() } { - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); QVERIFY( layer->dataProvider() && layer->dataProvider()->isValid() && layer->dataProvider()->index() ); @@ -1160,7 +1155,7 @@ void TestQgsCopcProvider::testPointCloudRequest() { const QString dataPath = copyTestData( QStringLiteral( "/point_clouds/copc/lone-star.copc.laz" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "copc" ) ); QVERIFY( layer->isValid() ); QgsPointCloudIndex *index = layer->dataProvider()->index(); diff --git a/tests/src/providers/testqgseptprovider.cpp b/tests/src/providers/testqgseptprovider.cpp index de72ad9150d3..b237ca7911ab 100644 --- a/tests/src/providers/testqgseptprovider.cpp +++ b/tests/src/providers/testqgseptprovider.cpp @@ -50,13 +50,14 @@ class TestQgsEptProvider : public QgsTest Q_OBJECT public: - TestQgsEptProvider() : QgsTest( QStringLiteral( "EPT Provider Tests" ) ) {} + TestQgsEptProvider() + : QgsTest( QStringLiteral( "EPT Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void filters(); void encodeUri(); @@ -149,12 +150,12 @@ void TestQgsEptProvider::preferredUri() QList candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/ept.json" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "ept" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/EPT.JSON" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "ept" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); QVERIFY( !QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/ept.json" ), QStringLiteral( "ept" ) ) ); QVERIFY( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/ept.json" ), QStringLiteral( "ogr" ) ) ); @@ -165,8 +166,8 @@ void TestQgsEptProvider::layerTypesForUri() QgsProviderMetadata *eptMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ept" ) ); QVERIFY( eptMetadata->capabilities() & QgsProviderMetadata::LayerTypesForUri ); - QCOMPARE( eptMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/ept.json" ) ), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); - QCOMPARE( eptMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.las" ) ), QList< Qgis::LayerType >() ); + QCOMPARE( eptMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/ept.json" ) ), QList() << Qgis::LayerType::PointCloud ); + QCOMPARE( eptMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.las" ) ), QList() ); } void TestQgsEptProvider::uriIsBlocklisted() @@ -181,7 +182,7 @@ void TestQgsEptProvider::querySublayers() QgsProviderMetadata *eptMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ept" ) ); // invalid uri - QList< QgsProviderSublayerDetails >res = eptMetadata->querySublayers( QString() ); + QList res = eptMetadata->querySublayers( QString() ); QVERIFY( res.empty() ); // not a ept layer @@ -198,15 +199,15 @@ void TestQgsEptProvider::querySublayers() QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::PointCloud ); // make sure result is valid to load layer from - const QgsProviderSublayerDetails::LayerOptions options{ QgsCoordinateTransformContext() }; - std::unique_ptr< QgsPointCloudLayer > ml( qgis::down_cast< QgsPointCloudLayer * >( res.at( 0 ).toLayer( options ) ) ); + const QgsProviderSublayerDetails::LayerOptions options { QgsCoordinateTransformContext() }; + std::unique_ptr ml( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); } void TestQgsEptProvider::brokenPath() { // test loading a bad layer URI - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( !layer->isValid() ); } @@ -250,7 +251,7 @@ void TestQgsEptProvider::validLayer() { const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/sunshine-coast" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:28356" ) ); @@ -272,7 +273,7 @@ void TestQgsEptProvider::validLayerWithEptHierarchy() { const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/lone-star-laszip" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); QGSCOMPARENEAR( layer->extent().xMinimum(), 515368.000000, 0.1 ); @@ -290,7 +291,7 @@ void TestQgsEptProvider::attributes() { const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/sunshine-coast" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); const QgsPointCloudAttributeCollection attributes = layer->attributes(); @@ -333,15 +334,15 @@ void TestQgsEptProvider::calculateZRange() { const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/sunshine-coast" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); QgsDoubleRange range = layer->elevationProperties()->calculateZRange( layer.get() ); QGSCOMPARENEAR( range.lower(), 74.34, 0.01 ); QGSCOMPARENEAR( range.upper(), 80.02, 0.01 ); - static_cast< QgsPointCloudLayerElevationProperties * >( layer->elevationProperties() )->setZScale( 2 ); - static_cast< QgsPointCloudLayerElevationProperties * >( layer->elevationProperties() )->setZOffset( 0.5 ); + static_cast( layer->elevationProperties() )->setZScale( 2 ); + static_cast( layer->elevationProperties() )->setZOffset( 0.5 ); range = layer->elevationProperties()->calculateZRange( layer.get() ); QGSCOMPARENEAR( range.lower(), 149.18, 0.01 ); @@ -362,7 +363,7 @@ void TestQgsEptProvider::testIdentify() const QString path = copyTestDataDirectory( datasetPath ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); // identify 1 point click (rectangular point shape) { @@ -380,56 +381,56 @@ void TestQgsEptProvider::testIdentify() const QMap identifiedPoint = points[0]; QMap expected; - expected[ QStringLiteral( "Blue" ) ] = 0; - expected[ QStringLiteral( "Classification" ) ] = 2; - expected[ QStringLiteral( "EdgeOfFlightLine" ) ] = 0; - expected[ QStringLiteral( "GpsTime" ) ] = 268793.37257748609409; - expected[ QStringLiteral( "Green" ) ] = 0; - expected[ QStringLiteral( "Intensity" ) ] = 1765; - expected[ QStringLiteral( "NumberOfReturns" ) ] = 1; - expected[ QStringLiteral( "PointSourceId" ) ] = 7041; - expected[ QStringLiteral( "Red" ) ] = 0; - expected[ QStringLiteral( "ReturnNumber" ) ] = 1; - expected[ QStringLiteral( "ScanAngleRank" ) ] = -28; - expected[ QStringLiteral( "ScanDirectionFlag" ) ] = 1; - expected[ QStringLiteral( "UserData" ) ] = 17; - expected[ QStringLiteral( "X" ) ] = 498062.52; - expected[ QStringLiteral( "Y" ) ] = 7050996.61; - expected[ QStringLiteral( "Z" ) ] = 75.0; + expected[QStringLiteral( "Blue" )] = 0; + expected[QStringLiteral( "Classification" )] = 2; + expected[QStringLiteral( "EdgeOfFlightLine" )] = 0; + expected[QStringLiteral( "GpsTime" )] = 268793.37257748609409; + expected[QStringLiteral( "Green" )] = 0; + expected[QStringLiteral( "Intensity" )] = 1765; + expected[QStringLiteral( "NumberOfReturns" )] = 1; + expected[QStringLiteral( "PointSourceId" )] = 7041; + expected[QStringLiteral( "Red" )] = 0; + expected[QStringLiteral( "ReturnNumber" )] = 1; + expected[QStringLiteral( "ScanAngleRank" )] = -28; + expected[QStringLiteral( "ScanDirectionFlag" )] = 1; + expected[QStringLiteral( "UserData" )] = 17; + expected[QStringLiteral( "X" )] = 498062.52; + expected[QStringLiteral( "Y" )] = 7050996.61; + expected[QStringLiteral( "Z" )] = 75.0; QVERIFY( identifiedPoint == expected ); } // identify 1 point (circular point shape) { QPolygonF polygon; - polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); - polygon.push_back( QPointF( 498066.21890226693358, 7050995.0112726856023 ) ); - polygon.push_back( QPointF( 498066.21890226693358, 7050995.0919103417546 ) ); - polygon.push_back( QPointF( 498066.28873652569018, 7050995.1322291698307 ) ); - polygon.push_back( QPointF( 498066.35857078444678, 7050995.0919103417546 ) ); - polygon.push_back( QPointF( 498066.35857078444678, 7050995.0112726856023 ) ); - polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); - const float maxErrorInMapCoords = 0.0091431681066751480103; + polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); + polygon.push_back( QPointF( 498066.21890226693358, 7050995.0112726856023 ) ); + polygon.push_back( QPointF( 498066.21890226693358, 7050995.0919103417546 ) ); + polygon.push_back( QPointF( 498066.28873652569018, 7050995.1322291698307 ) ); + polygon.push_back( QPointF( 498066.35857078444678, 7050995.0919103417546 ) ); + polygon.push_back( QPointF( 498066.35857078444678, 7050995.0112726856023 ) ); + polygon.push_back( QPointF( 498066.28873652569018, 7050994.9709538575262 ) ); + const float maxErrorInMapCoords = 0.0091431681066751480103; const QVector> identifiedPoints = layer->dataProvider()->identify( maxErrorInMapCoords, QgsGeometry::fromQPolygonF( polygon ) ); QVector> expected; { QMap point; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime" ) ] = "268793.3373408913" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "278" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "1" ; - point[ QStringLiteral( "PointSourceId" ) ] = "7041" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "1" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-28" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "1" ; - point[ QStringLiteral( "UserData" ) ] = "17" ; - point[ QStringLiteral( "X" ) ] = "498066.27" ; - point[ QStringLiteral( "Y" ) ] = "7050995.06" ; - point[ QStringLiteral( "Z" ) ] = "74.60" ; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime" )] = "268793.3373408913"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "278"; + point[QStringLiteral( "NumberOfReturns" )] = "1"; + point[QStringLiteral( "PointSourceId" )] = "7041"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "ReturnNumber" )] = "1"; + point[QStringLiteral( "ScanAngleRank" )] = "-28"; + point[QStringLiteral( "ScanDirectionFlag" )] = "1"; + point[QStringLiteral( "UserData" )] = "17"; + point[QStringLiteral( "X" )] = "498066.27"; + point[QStringLiteral( "Y" )] = "7050995.06"; + point[QStringLiteral( "Z" )] = "74.60"; expected.push_back( point ); } @@ -455,42 +456,42 @@ void TestQgsEptProvider::testIdentify() QVector> expected; { QMap point; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime" ) ] = "268793.3813974548" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1142" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "1" ; - point[ QStringLiteral( "PointSourceId" ) ] = "7041" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "1" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-28" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "1" ; - point[ QStringLiteral( "UserData" ) ] = "17" ; - point[ QStringLiteral( "X" ) ] = "498063.14" ; - point[ QStringLiteral( "Y" ) ] = "7050996.79" ; - point[ QStringLiteral( "Z" ) ] = "74.89" ; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime" )] = "268793.3813974548"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1142"; + point[QStringLiteral( "NumberOfReturns" )] = "1"; + point[QStringLiteral( "PointSourceId" )] = "7041"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "ReturnNumber" )] = "1"; + point[QStringLiteral( "ScanAngleRank" )] = "-28"; + point[QStringLiteral( "ScanDirectionFlag" )] = "1"; + point[QStringLiteral( "UserData" )] = "17"; + point[QStringLiteral( "X" )] = "498063.14"; + point[QStringLiteral( "Y" )] = "7050996.79"; + point[QStringLiteral( "Z" )] = "74.89"; expected.push_back( point ); } { QMap point; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "3" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime" ) ] = "269160.5176644815" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1631" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "1" ; - point[ QStringLiteral( "PointSourceId" ) ] = "7042" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "1" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-12" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "1" ; - point[ QStringLiteral( "UserData" ) ] = "17" ; - point[ QStringLiteral( "X" ) ] = "498063.11" ; - point[ QStringLiteral( "Y" ) ] = "7050996.75" ; - point[ QStringLiteral( "Z" ) ] = "74.90" ; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Classification" )] = "3"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime" )] = "269160.5176644815"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1631"; + point[QStringLiteral( "NumberOfReturns" )] = "1"; + point[QStringLiteral( "PointSourceId" )] = "7042"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "ReturnNumber" )] = "1"; + point[QStringLiteral( "ScanAngleRank" )] = "-12"; + point[QStringLiteral( "ScanDirectionFlag" )] = "1"; + point[QStringLiteral( "UserData" )] = "17"; + point[QStringLiteral( "X" )] = "498063.11"; + point[QStringLiteral( "Y" )] = "7050996.75"; + point[QStringLiteral( "Z" )] = "74.90"; expected.push_back( point ); } @@ -546,72 +547,72 @@ void TestQgsEptProvider::testExtraBytesAttributesValues() const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/extrabytes-dataset" ) ); QString dataPath = path + QStringLiteral( "/ept.json" ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( dataPath, QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( dataPath, QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); { const float maxErrorInMapCoords = 0.0015207174f; QPolygonF polygon; - polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); - polygon.push_back( QPointF( 527919.0742796324, 6210983.5918774214 ) ); - polygon.push_back( QPointF( 527919.0742796324, 6210983.4383113598 ) ); - polygon.push_back( QPointF( 527919.2459517354, 6210983.4383113598 ) ); - polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); + polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); + polygon.push_back( QPointF( 527919.0742796324, 6210983.5918774214 ) ); + polygon.push_back( QPointF( 527919.0742796324, 6210983.4383113598 ) ); + polygon.push_back( QPointF( 527919.2459517354, 6210983.4383113598 ) ); + polygon.push_back( QPointF( 527919.2459517354, 6210983.5918774214 ) ); const QVector> identifiedPoints = layer->dataProvider()->identify( maxErrorInMapCoords, QgsGeometry::fromQPolygonF( polygon ) ); QVector> expectedPoints; { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "4.409999847412109" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Synthetic" ) ] = "0" ; - point[ QStringLiteral( "KeyPoint" ) ] = "0" ; - point[ QStringLiteral( "Withheld" ) ] = "0" ; - point[ QStringLiteral( "Overlap" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "5" ; - point[ QStringLiteral( "Deviation" ) ] = "2" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime" ) ] = "302522582.235838" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "441" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-17.829999923706055" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "2" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.18" ; - point[ QStringLiteral( "Y" ) ] = "6210983.47" ; - point[ QStringLiteral( "Z" ) ] = "149.341" ; + point[QStringLiteral( "Amplitude" )] = "4.409999847412109"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Synthetic" )] = "0"; + point[QStringLiteral( "KeyPoint" )] = "0"; + point[QStringLiteral( "Withheld" )] = "0"; + point[QStringLiteral( "Overlap" )] = "0"; + point[QStringLiteral( "Classification" )] = "5"; + point[QStringLiteral( "Deviation" )] = "2"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime" )] = "302522582.235838"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "441"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-17.829999923706055"; + point[QStringLiteral( "ReturnNumber" )] = "2"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "X" )] = "527919.18"; + point[QStringLiteral( "Y" )] = "6210983.47"; + point[QStringLiteral( "Z" )] = "149.341"; expectedPoints.push_back( point ); } { QMap point; - point[ QStringLiteral( "Amplitude" ) ] = "14.170000076293945" ; - point[ QStringLiteral( "Blue" ) ] = "0" ; - point[ QStringLiteral( "Synthetic" ) ] = "0" ; - point[ QStringLiteral( "KeyPoint" ) ] = "0" ; - point[ QStringLiteral( "Withheld" ) ] = "0" ; - point[ QStringLiteral( "Overlap" ) ] = "0" ; - point[ QStringLiteral( "Classification" ) ] = "2" ; - point[ QStringLiteral( "Deviation" ) ] = "0" ; - point[ QStringLiteral( "EdgeOfFlightLine" ) ] = "0" ; - point[ QStringLiteral( "GpsTime" ) ] = "302522582.235839" ; - point[ QStringLiteral( "Green" ) ] = "0" ; - point[ QStringLiteral( "Intensity" ) ] = "1417" ; - point[ QStringLiteral( "NumberOfReturns" ) ] = "3" ; - point[ QStringLiteral( "PointSourceId" ) ] = "15017" ; - point[ QStringLiteral( "Red" ) ] = "0" ; - point[ QStringLiteral( "Reflectance" ) ] = "-8.050000190734863" ; - point[ QStringLiteral( "ReturnNumber" ) ] = "3" ; - point[ QStringLiteral( "ScanAngleRank" ) ] = "-6" ; - point[ QStringLiteral( "ScanDirectionFlag" ) ] = "0" ; - point[ QStringLiteral( "UserData" ) ] = "0" ; - point[ QStringLiteral( "X" ) ] = "527919.11" ; - point[ QStringLiteral( "Y" ) ] = "6210983.55" ; - point[ QStringLiteral( "Z" ) ] = "147.111" ; + point[QStringLiteral( "Amplitude" )] = "14.170000076293945"; + point[QStringLiteral( "Blue" )] = "0"; + point[QStringLiteral( "Synthetic" )] = "0"; + point[QStringLiteral( "KeyPoint" )] = "0"; + point[QStringLiteral( "Withheld" )] = "0"; + point[QStringLiteral( "Overlap" )] = "0"; + point[QStringLiteral( "Classification" )] = "2"; + point[QStringLiteral( "Deviation" )] = "0"; + point[QStringLiteral( "EdgeOfFlightLine" )] = "0"; + point[QStringLiteral( "GpsTime" )] = "302522582.235839"; + point[QStringLiteral( "Green" )] = "0"; + point[QStringLiteral( "Intensity" )] = "1417"; + point[QStringLiteral( "NumberOfReturns" )] = "3"; + point[QStringLiteral( "PointSourceId" )] = "15017"; + point[QStringLiteral( "Red" )] = "0"; + point[QStringLiteral( "Reflectance" )] = "-8.050000190734863"; + point[QStringLiteral( "ReturnNumber" )] = "3"; + point[QStringLiteral( "ScanAngleRank" )] = "-6"; + point[QStringLiteral( "ScanDirectionFlag" )] = "0"; + point[QStringLiteral( "UserData" )] = "0"; + point[QStringLiteral( "X" )] = "527919.11"; + point[QStringLiteral( "Y" )] = "6210983.55"; + point[QStringLiteral( "Z" )] = "147.111"; expectedPoints.push_back( point ); } @@ -623,15 +624,15 @@ void TestQgsEptProvider::testPointCloudIndex() { const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/lone-star-laszip" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); QgsPointCloudIndex *index = layer->dataProvider()->index(); QVERIFY( index->isValid() ); - QCOMPARE( index->nodePointCount( IndexedPointCloudNode::fromString( QStringLiteral( "0-0-0-0" ) ) ), 41998 ); - QCOMPARE( index->nodePointCount( IndexedPointCloudNode::fromString( QStringLiteral( "1-1-1-1" ) ) ), 48879 ); - QCOMPARE( index->nodePointCount( IndexedPointCloudNode::fromString( QStringLiteral( "2-3-3-1" ) ) ), 41734 ); + QCOMPARE( index->nodePointCount( IndexedPointCloudNode::fromString( QStringLiteral( "0-0-0-0" ) ) ), 41998 ); + QCOMPARE( index->nodePointCount( IndexedPointCloudNode::fromString( QStringLiteral( "1-1-1-1" ) ) ), 48879 ); + QCOMPARE( index->nodePointCount( IndexedPointCloudNode::fromString( QStringLiteral( "2-3-3-1" ) ) ), 41734 ); QCOMPARE( index->nodePointCount( IndexedPointCloudNode::fromString( QStringLiteral( "9-9-9-9" ) ) ), -1 ); QCOMPARE( index->pointCount(), 518862 ); @@ -650,9 +651,9 @@ void TestQgsEptProvider::testPointCloudIndex() QCOMPARE( bounds.xMin(), -88000 ); QCOMPARE( bounds.yMin(), -88000 ); QCOMPARE( bounds.zMin(), -88000 ); - QCOMPARE( bounds.xMax(), 88000 ); - QCOMPARE( bounds.yMax(), 88000 ); - QCOMPARE( bounds.zMax(), 88000 ); + QCOMPARE( bounds.xMax(), 88000 ); + QCOMPARE( bounds.yMax(), 88000 ); + QCOMPARE( bounds.zMax(), 88000 ); } { @@ -680,7 +681,7 @@ void TestQgsEptProvider::testPointCloudRequest() { const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/lone-star-laszip" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QVERIFY( layer->isValid() ); QgsPointCloudIndex *index = layer->dataProvider()->index(); @@ -707,7 +708,7 @@ void TestQgsEptProvider::testPointCloudRequest() int count = 0; for ( IndexedPointCloudNode node : nodes ) { - std::unique_ptr< QgsPointCloudBlock> block( index->nodeData( node, request ) ); + std::unique_ptr block( index->nodeData( node, request ) ); count += block->pointCount(); } QCOMPARE( count, layer->pointCount() ); @@ -718,7 +719,7 @@ void TestQgsEptProvider::testPointCloudRequest() count = 0; for ( IndexedPointCloudNode node : nodes ) { - std::unique_ptr< QgsPointCloudBlock> block( index->nodeData( node, request ) ); + std::unique_ptr block( index->nodeData( node, request ) ); count += block->pointCount(); } QCOMPARE( count, 217600 ); @@ -729,7 +730,7 @@ void TestQgsEptProvider::testPointCloudRequest() count = 0; for ( IndexedPointCloudNode node : nodes ) { - std::unique_ptr< QgsPointCloudBlock> block( index->nodeData( node, request ) ); + std::unique_ptr block( index->nodeData( node, request ) ); count += block->pointCount(); } QCOMPARE( count, 0 ); @@ -740,7 +741,7 @@ void TestQgsEptProvider::testPointCloudRequest() request.setFilterRect( extent ); for ( IndexedPointCloudNode node : nodes ) { - std::unique_ptr< QgsPointCloudBlock> block( index->nodeData( node, request ) ); + std::unique_ptr block( index->nodeData( node, request ) ); count += block->pointCount(); } QCOMPARE( count, layer->pointCount() ); @@ -750,7 +751,7 @@ void TestQgsEptProvider::testStatsCalculator() { const QString path = copyTestDataDirectory( QStringLiteral( "point_clouds/ept/extrabytes-dataset" ) ); - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); + std::unique_ptr layer = std::make_unique( path + QStringLiteral( "/ept.json" ), QStringLiteral( "layer" ), QStringLiteral( "ept" ) ); QgsPointCloudIndex *index = layer->dataProvider()->index(); QgsPointCloudStatsCalculator calculator( index ); @@ -784,139 +785,139 @@ void TestQgsEptProvider::testStatsCalculator() { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Amplitude" ) ); - QCOMPARE( ( float )s.minimum, 1.1599999666214 ); - QCOMPARE( ( float )s.maximum, 19.6000003814697 ); + QCOMPARE( ( float ) s.minimum, 1.1599999666214 ); + QCOMPARE( ( float ) s.maximum, 19.6000003814697 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Blue" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Synthetic" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 1 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "KeyPoint" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 1 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Withheld" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 1 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Overlap" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 1 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Classification" ) ); - QCOMPARE( ( float )s.minimum, 2 ); - QCOMPARE( ( float )s.maximum, 18 ); + QCOMPARE( ( float ) s.minimum, 2 ); + QCOMPARE( ( float ) s.maximum, 18 ); QMap classCount = s.classCount; QCOMPARE( classCount.size(), 7 ); - QCOMPARE( classCount[ 2 ], 103782 ); - QCOMPARE( classCount[ 3 ], 484 ); - QCOMPARE( classCount[ 4 ], 79 ); - QCOMPARE( classCount[ 5 ], 966 ); - QCOMPARE( classCount[ 7 ], 12 ); - QCOMPARE( classCount[ 8 ], 648 ); - QCOMPARE( classCount[ 18 ], 1 ); + QCOMPARE( classCount[2], 103782 ); + QCOMPARE( classCount[3], 484 ); + QCOMPARE( classCount[4], 79 ); + QCOMPARE( classCount[5], 966 ); + QCOMPARE( classCount[7], 12 ); + QCOMPARE( classCount[8], 648 ); + QCOMPARE( classCount[18], 1 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Deviation" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 120 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 120 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "EdgeOfFlightLine" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "GpsTime" ) ); - QCOMPARE( ( float )s.minimum, ( float )302522581.972046196460723876953 ); - QCOMPARE( ( float )s.maximum, ( float )302522583.437068104743957519531 ); + QCOMPARE( ( float ) s.minimum, ( float ) 302522581.972046196460723876953 ); + QCOMPARE( ( float ) s.maximum, ( float ) 302522583.437068104743957519531 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Green" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Intensity" ) ); - QCOMPARE( ( float )s.minimum, 116 ); - QCOMPARE( ( float )s.maximum, 1960 ); + QCOMPARE( ( float ) s.minimum, 116 ); + QCOMPARE( ( float ) s.maximum, 1960 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "NumberOfReturns" ) ); - QCOMPARE( ( float )s.minimum, 1 ); - QCOMPARE( ( float )s.maximum, 5 ); + QCOMPARE( ( float ) s.minimum, 1 ); + QCOMPARE( ( float ) s.maximum, 5 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "PointSourceId" ) ); - QCOMPARE( ( float )s.minimum, 15017 ); - QCOMPARE( ( float )s.maximum, 15017 ); + QCOMPARE( ( float ) s.minimum, 15017 ); + QCOMPARE( ( float ) s.maximum, 15017 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Red" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "Reflectance" ) ); - QCOMPARE( ( float )s.minimum, -21.1100006103515625 ); - QCOMPARE( ( float )s.maximum, -2.6099998950958251953125 ); + QCOMPARE( ( float ) s.minimum, -21.1100006103515625 ); + QCOMPARE( ( float ) s.maximum, -2.6099998950958251953125 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "ReturnNumber" ) ); - QCOMPARE( ( float )s.minimum, 1 ); - QCOMPARE( ( float )s.maximum, 5 ); + QCOMPARE( ( float ) s.minimum, 1 ); + QCOMPARE( ( float ) s.maximum, 5 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "ScanAngleRank" ) ); - QCOMPARE( ( float )s.minimum, -11 ); - QCOMPARE( ( float )s.maximum, -4 ); + QCOMPARE( ( float ) s.minimum, -11 ); + QCOMPARE( ( float ) s.maximum, -4 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "ScanDirectionFlag" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } { QgsPointCloudAttributeStatistics s = stats.statisticsOf( QStringLiteral( "UserData" ) ); - QCOMPARE( ( float )s.minimum, 0 ); - QCOMPARE( ( float )s.maximum, 0 ); + QCOMPARE( ( float ) s.minimum, 0 ); + QCOMPARE( ( float ) s.maximum, 0 ); } } diff --git a/tests/src/providers/testqgsmdalprovider.cpp b/tests/src/providers/testqgsmdalprovider.cpp index 359d01eeaaa4..d6d98a95612d 100644 --- a/tests/src/providers/testqgsmdalprovider.cpp +++ b/tests/src/providers/testqgsmdalprovider.cpp @@ -38,14 +38,14 @@ class TestQgsMdalProvider : public QgsTest Q_OBJECT public: - - TestQgsMdalProvider() : QgsTest( QStringLiteral( "MDAL Provider Tests" ) ) {} + TestQgsMdalProvider() + : QgsTest( QStringLiteral( "MDAL Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void load(); void filters(); @@ -145,12 +145,12 @@ void TestQgsMdalProvider::load() { const QString file = QStringLiteral( TEST_DATA_DIR ) + "/mesh/quad_flower.2dm"; QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( - QStringLiteral( "mdal" ), - file, - QgsDataProvider::ProviderOptions() - ); + QStringLiteral( "mdal" ), + file, + QgsDataProvider::ProviderOptions() + ); - QgsMeshDataProvider *mp = dynamic_cast< QgsMeshDataProvider * >( provider ); + QgsMeshDataProvider *mp = dynamic_cast( provider ); QVERIFY( mp ); QVERIFY( mp->isValid() ); delete provider; @@ -158,12 +158,12 @@ void TestQgsMdalProvider::load() { const QString file = QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/goodluckwiththisfilename.2dm" ); QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( - QStringLiteral( "mdal" ), - file, - QgsDataProvider::ProviderOptions() - ); + QStringLiteral( "mdal" ), + file, + QgsDataProvider::ProviderOptions() + ); - QgsMeshDataProvider *mp = dynamic_cast< QgsMeshDataProvider * >( provider ); + QgsMeshDataProvider *mp = dynamic_cast( provider ); QVERIFY( mp ); QVERIFY( !mp->isValid() ); delete provider; @@ -185,12 +185,12 @@ void TestQgsMdalProvider::preserveMeshMetadata() meshFile.copy( copiedFile ); QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider( - QStringLiteral( "mdal" ), - copiedFile, - QgsDataProvider::ProviderOptions() - ); + QStringLiteral( "mdal" ), + copiedFile, + QgsDataProvider::ProviderOptions() + ); - QgsMeshDataProvider *mp = dynamic_cast< QgsMeshDataProvider * >( provider ); + QgsMeshDataProvider *mp = dynamic_cast( provider ); QVERIFY( mp ); QVERIFY( mp->isValid() ); diff --git a/tests/src/providers/testqgsmssqlprovider.cpp b/tests/src/providers/testqgsmssqlprovider.cpp index df40b6aa4071..03357342b01d 100644 --- a/tests/src/providers/testqgsmssqlprovider.cpp +++ b/tests/src/providers/testqgsmssqlprovider.cpp @@ -38,10 +38,10 @@ class TestQgsMssqlProvider : public QObject Q_OBJECT private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void openLayer(); @@ -51,13 +51,11 @@ class TestQgsMssqlProvider : public QObject void transactionUndoRedo(); private: - QString mDbConn; QStringList mSomeDataWktGeom; QStringList mSomeDataPolyWktGeom; QList mSomeDataAttributes; - }; //runs before all tests @@ -67,8 +65,7 @@ void TestQgsMssqlProvider::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); - mDbConn = qEnvironmentVariable( "QGIS_MSSQLTEST_DB", - "service='testsqlserver' user=sa password='' " ); + mDbConn = qEnvironmentVariable( "QGIS_MSSQLTEST_DB", "service='testsqlserver' user=sa password='' " ); mSomeDataWktGeom << QStringLiteral( "Point (-70.33199999999999363 66.32999999999999829)" ) << QStringLiteral( "Point (-68.20000000000000284 70.79999999999999716)" ) @@ -77,19 +74,19 @@ void TestQgsMssqlProvider::initTestCase() << QStringLiteral( "Point (-71.12300000000000466 78.23000000000000398)" ); QVariantList varList; - varList << 1ll << 100 << "Orange" << "oranGe" << "1" << QDateTime( QDate( 2020, 05, 03 ), QTime( 12, 13, 14 ) ) << QDate( 2020, 05, 03 ) << QTime( 12, 13, 14 ) ; + varList << 1ll << 100 << "Orange" << "oranGe" << "1" << QDateTime( QDate( 2020, 05, 03 ), QTime( 12, 13, 14 ) ) << QDate( 2020, 05, 03 ) << QTime( 12, 13, 14 ); mSomeDataAttributes << varList; varList.clear(); - varList << 2ll << 200 << "Apple" << "Apple" << "2" << QDateTime( QDate( 2020, 05, 04 ), QTime( 12, 14, 14 ) ) << QDate( 2020, 05, 04 ) << QTime( 12, 14, 14 ) ; + varList << 2ll << 200 << "Apple" << "Apple" << "2" << QDateTime( QDate( 2020, 05, 04 ), QTime( 12, 14, 14 ) ) << QDate( 2020, 05, 04 ) << QTime( 12, 14, 14 ); mSomeDataAttributes << varList; varList.clear(); - varList << 3ll << 300 << "Pear" << "PEaR" << "3" << QDateTime() << QDate() << QTime(); + varList << 3ll << 300 << "Pear" << "PEaR" << "3" << QDateTime() << QDate() << QTime(); mSomeDataAttributes << varList; varList.clear(); - varList << 4ll << 400 << "Honey" << "Honey" << "4" << QDateTime( QDate( 2021, 05, 04 ), QTime( 13, 13, 14 ) ) << QDate( 2021, 05, 04 ) << QTime( 13, 13, 14 ) ; + varList << 4ll << 400 << "Honey" << "Honey" << "4" << QDateTime( QDate( 2021, 05, 04 ), QTime( 13, 13, 14 ) ) << QDate( 2021, 05, 04 ) << QTime( 13, 13, 14 ); mSomeDataAttributes << varList; varList.clear(); - varList << 5ll << -200 << "" << "NuLl" << "5" << QDateTime( QDate( 2020, 05, 04 ), QTime( 12, 13, 14 ) ) << QDate( 2020, 05, 02 ) << QTime( 12, 13, 1 ) ; + varList << 5ll << -200 << "" << "NuLl" << "5" << QDateTime( QDate( 2020, 05, 04 ), QTime( 12, 13, 14 ) ) << QDate( 2020, 05, 02 ) << QTime( 12, 13, 1 ); mSomeDataAttributes << varList; @@ -284,7 +281,6 @@ void TestQgsMssqlProvider::transactionUndoRedo() vectorLayerPoint1->rollBack(); // 2. with transaction, try to add a feature to the first layer -> both layers are affected - } QGSTEST_MAIN( TestQgsMssqlProvider ) diff --git a/tests/src/providers/testqgspdalprovider.cpp b/tests/src/providers/testqgspdalprovider.cpp index a818b9d24ae0..f3d48b39dc7e 100644 --- a/tests/src/providers/testqgspdalprovider.cpp +++ b/tests/src/providers/testqgspdalprovider.cpp @@ -44,14 +44,14 @@ class TestQgsPdalProvider : public QgsTest Q_OBJECT public: - - TestQgsPdalProvider() : QgsTest( QStringLiteral( "PDAL Provider Tests" ) ) {} + TestQgsPdalProvider() + : QgsTest( QStringLiteral( "PDAL Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void filters(); void encodeUri(); @@ -127,8 +127,8 @@ void TestQgsPdalProvider::layerTypesForUri() QgsProviderMetadata *pdalMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "pdal" ) ); QVERIFY( pdalMetadata->capabilities() & QgsProviderMetadata::LayerTypesForUri ); - QCOMPARE( pdalMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.las" ) ), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); - QCOMPARE( pdalMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.shp" ) ), QList< Qgis::LayerType >() ); + QCOMPARE( pdalMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.las" ) ), QList() << Qgis::LayerType::PointCloud ); + QCOMPARE( pdalMetadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.shp" ) ), QList() ); } void TestQgsPdalProvider::preferredUri() @@ -140,22 +140,22 @@ void TestQgsPdalProvider::preferredUri() QList candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/cloud.las" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "pdal" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/CLOUD.LAS" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "pdal" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/cloud.laz" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "pdal" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/CLOUD.LAZ" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "pdal" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); QVERIFY( !QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/cloud.las" ), QStringLiteral( "pdal" ) ) ); QVERIFY( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/cloud.las" ), QStringLiteral( "ept" ) ) ); @@ -167,7 +167,7 @@ void TestQgsPdalProvider::querySublayers() QgsProviderMetadata *pdalMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "pdal" ) ); // invalid uri - QList< QgsProviderSublayerDetails >res = pdalMetadata->querySublayers( QString() ); + QList res = pdalMetadata->querySublayers( QString() ); QVERIFY( res.empty() ); // not a pdal layer @@ -183,18 +183,19 @@ void TestQgsPdalProvider::querySublayers() QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::PointCloud ); // make sure result is valid to load layer from - const QgsProviderSublayerDetails::LayerOptions options{ QgsCoordinateTransformContext() }; - std::unique_ptr< QgsPointCloudLayer > ml( qgis::down_cast< QgsPointCloudLayer * >( res.at( 0 ).toLayer( options ) ) ); + const QgsProviderSublayerDetails::LayerOptions options { QgsCoordinateTransformContext() }; + std::unique_ptr ml( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); } void TestQgsPdalProvider::brokenPath() { // test loading a bad layer URI - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( - QStringLiteral( "not valid" ), - QStringLiteral( "layer" ), - QStringLiteral( "pdal" ) ); + std::unique_ptr layer = std::make_unique( + QStringLiteral( "not valid" ), + QStringLiteral( "layer" ), + QStringLiteral( "pdal" ) + ); QVERIFY( !layer->isValid() ); } @@ -203,12 +204,12 @@ void TestQgsPdalProvider::validLayer() QgsPointCloudLayer::LayerOptions options; options.skipIndexGeneration = true; - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( - mTestDataDir + QStringLiteral( "point_clouds/las/cloud.las" ), - QStringLiteral( "layer" ), - QStringLiteral( "pdal" ), - options - ); + std::unique_ptr layer = std::make_unique( + mTestDataDir + QStringLiteral( "point_clouds/las/cloud.las" ), + QStringLiteral( "layer" ), + QStringLiteral( "pdal" ), + options + ); QVERIFY( layer->isValid() ); QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:28356" ) ); diff --git a/tests/src/providers/testqgspostgresconn.cpp b/tests/src/providers/testqgspostgresconn.cpp index c02c687c8e22..b5629da68fe0 100644 --- a/tests/src/providers/testqgspostgresconn.cpp +++ b/tests/src/providers/testqgspostgresconn.cpp @@ -53,7 +53,7 @@ char *toString( const QgsPostgresGeometryColumnType &t ) return qstrcpy( dst, ptr ); } -class TestQgsPostgresConn: public QObject +class TestQgsPostgresConn : public QObject { Q_OBJECT @@ -64,10 +64,11 @@ class TestQgsPostgresConn: public QObject QgsPostgresConn *getConnection() { - if ( ! _connection ) + if ( !_connection ) { const char *connstring = getenv( "QGIS_PGTEST_DB" ); - if ( !connstring ) connstring = "service=qgis_test"; + if ( !connstring ) + connstring = "service=qgis_test"; _connection = QgsPostgresConn::connectDb( connstring, true ); } return _connection; @@ -84,7 +85,8 @@ class TestQgsPostgresConn: public QObject void cleanupTestCase() // will be called after the last testfunction was executed. { #ifdef ENABLE_PGTEST - if ( this->_connection ) this->_connection->unref(); + if ( this->_connection ) + this->_connection->unref(); #endif } @@ -169,12 +171,12 @@ class TestQgsPostgresConn: public QObject QMap layersMap; const bool success = conn->supportedLayers( - layers, - false, // searchGeometryColumnsOnly - false, // searchPublicOnly - false, // allowGeometrylessTables - "qgis_test" // schema - ); + layers, + false, // searchGeometryColumnsOnly + false, // searchPublicOnly + false, // allowGeometrylessTables + "qgis_test" // schema + ); QVERIFY( success ); // Test no duplicates are reported by supportedLayers @@ -187,7 +189,10 @@ class TestQgsPostgresConn: public QObject QFAIL( QString( "Layer %1 returned multiple times by supportedLayers" - ).arg( key ).toUtf8().data() + ) + .arg( key ) + .toUtf8() + .data() ); } layersMap.insert( key, l ); @@ -203,7 +208,6 @@ class TestQgsPostgresConn: public QObject QCOMPARE( lit->geometryColName, "topogeom" ); QCOMPARE( lit->geometryColType, SctTopoGeometry ); // TODO: add more tests - } void connectDb() @@ -220,7 +224,8 @@ class TestQgsPostgresConn: public QObject QCOMPARE( result.PQgetvalue( 0, 0 ), result.PQgetvalue( 0, 1 ) ); const char *connstring = getenv( "QGIS_PGTEST_DB" ); - if ( !connstring ) connstring = "service=qgis_test"; + if ( !connstring ) + connstring = "service=qgis_test"; const QString conninfo( connstring ); QgsDataSourceUri uri( conninfo ); @@ -239,7 +244,7 @@ class TestQgsPostgresConn: public QObject conn->unref(); // Add known session_role parameter to postgres uri - uri.setParam( QStringLiteral( "session_role" ), QStringLiteral( "qgis_test_group" ) ); + uri.setParam( QStringLiteral( "session_role" ), QStringLiteral( "qgis_test_group" ) ); conn = QgsPostgresConn::connectDb( uri, true ); QVERIFY( conn ); result = conn->PQexec( sql ); diff --git a/tests/src/providers/testqgspostgresexpressioncompiler.cpp b/tests/src/providers/testqgspostgresexpressioncompiler.cpp index 5ef743e98421..5bf182847d38 100644 --- a/tests/src/providers/testqgspostgresexpressioncompiler.cpp +++ b/tests/src/providers/testqgspostgresexpressioncompiler.cpp @@ -21,22 +21,22 @@ #include "qgspostgresprovider.h" //The only purpose of this class is to set geomColumn and srid -class QgsTestPostgresExpressionCompiler: public QgsPostgresExpressionCompiler +class QgsTestPostgresExpressionCompiler : public QgsPostgresExpressionCompiler { public: - QgsTestPostgresExpressionCompiler( QgsPostgresFeatureSource *source, const QString &srid, const QString &geometryColumn ): QgsPostgresExpressionCompiler( source ) + QgsTestPostgresExpressionCompiler( QgsPostgresFeatureSource *source, const QString &srid, const QString &geometryColumn ) + : QgsPostgresExpressionCompiler( source ) { mDetectedSrid = srid; mGeometryColumn = geometryColumn; } }; -class TestQgsPostgresExpressionCompiler: public QObject +class TestQgsPostgresExpressionCompiler : public QObject { Q_OBJECT public: - TestQgsPostgresExpressionCompiler() = default; private slots: diff --git a/tests/src/providers/testqgspostgresprovider.cpp b/tests/src/providers/testqgspostgresprovider.cpp index 2ed06d71d2db..884dd5890937 100644 --- a/tests/src/providers/testqgspostgresprovider.cpp +++ b/tests/src/providers/testqgspostgresprovider.cpp @@ -22,22 +22,22 @@ #include #include -class TestQgsPostgresProvider: public QObject +class TestQgsPostgresProvider : public QObject { Q_OBJECT private: - #ifdef ENABLE_PGTEST QgsPostgresConn *_connection; QgsPostgresConn *getConnection() { - if ( ! _connection ) + if ( !_connection ) { const char *connstring = getenv( "QGIS_PGTEST_DB" ); - if ( !connstring ) connstring = "service=qgis_test"; + if ( !connstring ) + connstring = "service=qgis_test"; _connection = QgsPostgresConn::connectDb( connstring, true ); } return _connection; @@ -55,7 +55,8 @@ class TestQgsPostgresProvider: public QObject void cleanupTestCase() // will be called after the last testfunction was executed. { #ifdef ENABLE_PGTEST - if ( this->_connection ) this->_connection->unref(); + if ( this->_connection ) + this->_connection->unref(); #endif } @@ -79,7 +80,6 @@ class TestQgsPostgresProvider: public QObject }; - void TestQgsPostgresProvider::decodeHstore() { const QVariant decoded = QgsPostgresProvider::convertValue( QMetaType::Type::QVariantMap, QMetaType::Type::QString, QStringLiteral( "\"1\"=>\"2\", \"a\"=>\"b, \\\"c'\", \"backslash\"=>\"\\\\\"" ), QStringLiteral( "hstore" ), nullptr ); @@ -212,7 +212,6 @@ void TestQgsPostgresProvider::decodeJsonbMap() void TestQgsPostgresProvider::testDecodeDateTimes() { - QVariant decoded; decoded = QgsPostgresProvider::convertValue( QMetaType::Type::QDateTime, QMetaType::Type::UnknownType, QStringLiteral( "2020-06-08 18:30:35.496438+02" ), QStringLiteral( "timestamptz" ), nullptr ); @@ -229,7 +228,6 @@ void TestQgsPostgresProvider::testDecodeDateTimes() decoded = QgsPostgresProvider::convertValue( QMetaType::Type::QTime, QMetaType::Type::UnknownType, QStringLiteral( "18:29:27.569401" ), QStringLiteral( "time" ), nullptr ); QCOMPARE( static_cast( decoded.userType() ), QMetaType::Type::QTime ); - } void TestQgsPostgresProvider::testQuotedValueBigInt() @@ -238,7 +236,7 @@ void TestQgsPostgresProvider::testQuotedValueBigInt() QList pkAttrs; QVariantList vlst; - const std::shared_ptr< QgsPostgresSharedData > sdata( new QgsPostgresSharedData() ); + const std::shared_ptr sdata( new QgsPostgresSharedData() ); QgsField f0, f1, f2, f3; @@ -340,39 +338,39 @@ void TestQgsPostgresProvider::testWhereClauseFids() QgsFields fields; QList pkAttrs; - const std::shared_ptr< QgsPostgresSharedData > sdata( new QgsPostgresSharedData() ); + const std::shared_ptr sdata( new QgsPostgresSharedData() ); QgsField f0, f1, f2, f3; // need regular expression to check IN/OR because QgsFeatureIds is a set and ids could come // in various order -#define CHECK_IN_CLAUSE(whereClause,expectedValues) \ - { \ - QRegularExpression inRe("\\\"fld\\\" IN \\(([^,]*),([^,]*)\\)"); \ - QVERIFY(inRe.isValid()); \ - QRegularExpressionMatch match = inRe.match( whereClause ); \ - QVERIFY( match.hasMatch() ); \ - QStringList values; \ - values << match.captured(1); \ - values << match.captured(2); \ - std::sort( values.begin(), values.end() ); \ - QCOMPARE( values, expectedValues ); \ +#define CHECK_IN_CLAUSE( whereClause, expectedValues ) \ + { \ + QRegularExpression inRe( "\\\"fld\\\" IN \\(([^,]*),([^,]*)\\)" ); \ + QVERIFY( inRe.isValid() ); \ + QRegularExpressionMatch match = inRe.match( whereClause ); \ + QVERIFY( match.hasMatch() ); \ + QStringList values; \ + values << match.captured( 1 ); \ + values << match.captured( 2 ); \ + std::sort( values.begin(), values.end() ); \ + QCOMPARE( values, expectedValues ); \ } // QRegularExpression inOr("\\(\\\"fld\\\"=([^,]*) OR \\\"fld\\\"=([^,]*)\\)"); -#define CHECK_OR_CLAUSE(whereClause,expectedValues) \ - { \ - QRegularExpression inOr("\\((.*) OR (.*)\\)"); \ - QVERIFY(inOr.isValid()); \ - QRegularExpressionMatch match = inOr.match( whereClause ); \ - QVERIFY( match.hasMatch() ); \ - QStringList values; \ - values << match.captured(1); \ - values << match.captured(2); \ - std::sort( values.begin(), values.end() ); \ - QCOMPARE( values, expectedValues ); \ +#define CHECK_OR_CLAUSE( whereClause, expectedValues ) \ + { \ + QRegularExpression inOr( "\\((.*) OR (.*)\\)" ); \ + QVERIFY( inOr.isValid() ); \ + QRegularExpressionMatch match = inOr.match( whereClause ); \ + QVERIFY( match.hasMatch() ); \ + QStringList values; \ + values << match.captured( 1 ); \ + values << match.captured( 2 ); \ + std::sort( values.begin(), values.end() ); \ + QCOMPARE( values, expectedValues ); \ } // 4 byte integer -> IN clause @@ -387,8 +385,7 @@ void TestQgsPostgresProvider::testWhereClauseFids() sdata->insertFid( 42, QVariantList() << 42 ); sdata->insertFid( 43, QVariantList() << 43 ); - CHECK_IN_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 42 << 43, fields, NULL, QgsPostgresPrimaryKeyType::PktInt, pkAttrs, std::shared_ptr( sdata ) ), - QStringList() << "42" << "43" ); + CHECK_IN_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 42 << 43, fields, NULL, QgsPostgresPrimaryKeyType::PktInt, pkAttrs, std::shared_ptr( sdata ) ), QStringList() << "42" << "43" ); // 8 byte integer -> IN clause f1.setName( "fld" ); @@ -405,8 +402,7 @@ void TestQgsPostgresProvider::testWhereClauseFids() sdata->insertFid( 1LL, QVariantList() << -9223372036854775800LL ); // way outside int4 range sdata->insertFid( 2LL, QVariantList() << -9223372036854775801LL ); - CHECK_IN_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktInt64, pkAttrs, std::shared_ptr( sdata ) ), - QStringList() << "-9223372036854775800" << "-9223372036854775801" ); + CHECK_IN_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktInt64, pkAttrs, std::shared_ptr( sdata ) ), QStringList() << "-9223372036854775800" << "-9223372036854775801" ); // double -> OR clause f2.setName( "fld" ); @@ -423,8 +419,7 @@ void TestQgsPostgresProvider::testWhereClauseFids() sdata->insertFid( 1LL, QVariantList() << 3.141592741 ); sdata->insertFid( 2LL, QVariantList() << 6.141592741 ); - CHECK_OR_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr( sdata ) ), - QStringList() << "\"fld\"='3.141592741'" << "\"fld\"='6.141592741'" ); + CHECK_OR_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr( sdata ) ), QStringList() << "\"fld\"='3.141592741'" << "\"fld\"='6.141592741'" ); // text -> IN clause f3.setName( "fld" ); @@ -441,8 +436,7 @@ void TestQgsPostgresProvider::testWhereClauseFids() sdata->insertFid( 1LL, QVariantList() << QString( "QGIS 'Rocks'!" ) ); sdata->insertFid( 2LL, QVariantList() << QString( "PostGIS too!" ) ); - CHECK_IN_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr( sdata ) ), - QStringList() << "'PostGIS too!'" << "'QGIS ''Rocks''!'" ); + CHECK_IN_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr( sdata ) ), QStringList() << "'PostGIS too!'" << "'QGIS ''Rocks''!'" ); // Composite text + int -> OR clause f0.setName( "fld_int" ); @@ -458,9 +452,8 @@ void TestQgsPostgresProvider::testWhereClauseFids() sdata->insertFid( 1LL, QVariantList() << 42 << QString( "QGIS 'Rocks'!" ) ); sdata->insertFid( 2LL, QVariantList() << 43 << QString( "PostGIS too!" ) ); - CHECK_OR_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr( sdata ) ), - QStringList() << "\"fld_int\"=42 AND \"fld\"::text='QGIS ''Rocks''!'" - << "\"fld_int\"=43 AND \"fld\"::text='PostGIS too!'" ); + CHECK_OR_CLAUSE( QgsPostgresUtils::whereClause( QgsFeatureIds() << 1LL << 2LL, fields, NULL, QgsPostgresPrimaryKeyType::PktFidMap, pkAttrs, std::shared_ptr( sdata ) ), QStringList() << "\"fld_int\"=42 AND \"fld\"::text='QGIS ''Rocks''!'" + << "\"fld_int\"=43 AND \"fld\"::text='PostGIS too!'" ); } #ifdef ENABLE_PGTEST @@ -474,7 +467,7 @@ void TestQgsPostgresProvider::testEwktInOut() QString ewkt_obtained; g = QgsPostgresProvider::fromEwkt( "SRID=4326;LINESTRING(0 0,-5 2)", conn ); - QVERIFY( ! g.isNull() ); + QVERIFY( !g.isNull() ); QCOMPARE( g.crs().authid(), "EPSG:4326" ); ewkt_obtained = QgsPostgresProvider::toEwkt( g, conn ); QCOMPARE( ewkt_obtained, "SRID=4326;LineString (0 0, -5 2)" ); @@ -482,11 +475,10 @@ void TestQgsPostgresProvider::testEwktInOut() // Test for srid-less geometry // See https://github.com/qgis/QGIS/issues/49380#issuecomment-1282913470 g = QgsPostgresProvider::fromEwkt( "POINT(0 0)", conn ); - QVERIFY( ! g.isNull() ); + QVERIFY( !g.isNull() ); ewkt_obtained = QgsPostgresProvider::toEwkt( g, conn ); - QVERIFY( ! g.crs().isValid() ); // is unknown + QVERIFY( !g.crs().isValid() ); // is unknown QCOMPARE( ewkt_obtained, QString( "SRID=0;Point (0 0)" ) ); - } #endif // ENABLE_PGTEST diff --git a/tests/src/providers/testqgsvirtuallayerprovider.cpp b/tests/src/providers/testqgsvirtuallayerprovider.cpp index 561271a3fd93..26f702be7aa0 100644 --- a/tests/src/providers/testqgsvirtuallayerprovider.cpp +++ b/tests/src/providers/testqgsvirtuallayerprovider.cpp @@ -46,14 +46,14 @@ class TestQgsVirtualLayerProvider : public QgsTest Q_OBJECT public: - - TestQgsVirtualLayerProvider() : QgsTest( QStringLiteral( "Virtual Layer Provider Tests" ) ) {} + TestQgsVirtualLayerProvider() + : QgsTest( QStringLiteral( "Virtual Layer Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void testConstructor(); diff --git a/tests/src/providers/testqgsvirtualpointcloudprovider.cpp b/tests/src/providers/testqgsvirtualpointcloudprovider.cpp index 01f3901649f2..61fac3d1f866 100644 --- a/tests/src/providers/testqgsvirtualpointcloudprovider.cpp +++ b/tests/src/providers/testqgsvirtualpointcloudprovider.cpp @@ -53,14 +53,14 @@ class TestQgsVirtualPointCloudProvider : public QgsTest Q_OBJECT public: - - TestQgsVirtualPointCloudProvider() : QgsTest( QStringLiteral( "Virtual Point Cloud Provider Tests" ) ) {} + TestQgsVirtualPointCloudProvider() + : QgsTest( QStringLiteral( "Virtual Point Cloud Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void filters(); void encodeUri(); @@ -149,12 +149,12 @@ void TestQgsVirtualPointCloudProvider::preferredUri() QList candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/dataset.vpc" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "vpc" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "/home/test/dataset.VPC" ) ); QCOMPARE( candidates.size(), 1 ); QCOMPARE( candidates.at( 0 ).metadata()->key(), QStringLiteral( "vpc" ) ); - QCOMPARE( candidates.at( 0 ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); + QCOMPARE( candidates.at( 0 ).layerTypes(), QList() << Qgis::LayerType::PointCloud ); QVERIFY( !QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/dataset.vpc" ), QStringLiteral( "vpc" ) ) ); QVERIFY( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/dataset.vpc" ), QStringLiteral( "ogr" ) ) ); @@ -165,9 +165,9 @@ void TestQgsVirtualPointCloudProvider::layerTypesForUri() QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "vpc" ) ); QVERIFY( metadata->capabilities() & QgsProviderMetadata::LayerTypesForUri ); - QCOMPARE( metadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.vpc" ) ), QList< Qgis::LayerType >() << Qgis::LayerType::PointCloud ); - QCOMPARE( metadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.copc.laz" ) ), QList< Qgis::LayerType >() ); - QCOMPARE( metadata->validLayerTypesForUri( QStringLiteral( "/home/test/ept.json" ) ), QList< Qgis::LayerType >() ); + QCOMPARE( metadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.vpc" ) ), QList() << Qgis::LayerType::PointCloud ); + QCOMPARE( metadata->validLayerTypesForUri( QStringLiteral( "/home/test/cloud.copc.laz" ) ), QList() ); + QCOMPARE( metadata->validLayerTypesForUri( QStringLiteral( "/home/test/ept.json" ) ), QList() ); } void TestQgsVirtualPointCloudProvider::uriIsBlocklisted() @@ -181,7 +181,7 @@ void TestQgsVirtualPointCloudProvider::querySublayers() QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "vpc" ) ); // invalid uri - QList< QgsProviderSublayerDetails >res = metadata->querySublayers( QString() ); + QList res = metadata->querySublayers( QString() ); QVERIFY( res.empty() ); // not a VPC layer @@ -197,21 +197,21 @@ void TestQgsVirtualPointCloudProvider::querySublayers() QCOMPARE( res.at( 0 ).type(), Qgis::LayerType::PointCloud ); // make sure result is valid to load layer from - QgsProviderSublayerDetails::LayerOptions options{ QgsCoordinateTransformContext() }; - std::unique_ptr< QgsPointCloudLayer > ml( qgis::down_cast< QgsPointCloudLayer * >( res.at( 0 ).toLayer( options ) ) ); + QgsProviderSublayerDetails::LayerOptions options { QgsCoordinateTransformContext() }; + std::unique_ptr ml( qgis::down_cast( res.at( 0 ).toLayer( options ) ) ); QVERIFY( ml->isValid() ); } void TestQgsVirtualPointCloudProvider::brokenPath() { // test loading a bad layer URI - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); + std::unique_ptr layer = std::make_unique( QStringLiteral( "not valid" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); QVERIFY( !layer->isValid() ); } void TestQgsVirtualPointCloudProvider::validLayer() { - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( mTestDataDir + QStringLiteral( "point_clouds/virtual/tiles.vpc" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); + std::unique_ptr layer = std::make_unique( mTestDataDir + QStringLiteral( "point_clouds/virtual/tiles.vpc" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); QVERIFY( layer->isValid() ); QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:5514" ) ); @@ -228,7 +228,7 @@ void TestQgsVirtualPointCloudProvider::validLayer() void TestQgsVirtualPointCloudProvider::attributes() { - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( mTestDataDir + QStringLiteral( "point_clouds/virtual/tiles.vpc" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); + std::unique_ptr layer = std::make_unique( mTestDataDir + QStringLiteral( "point_clouds/virtual/tiles.vpc" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); QVERIFY( layer->isValid() ); const QgsPointCloudAttributeCollection attributes = layer->attributes(); @@ -269,13 +269,13 @@ void TestQgsVirtualPointCloudProvider::attributes() void TestQgsVirtualPointCloudProvider::testLazyLoading() { - std::unique_ptr< QgsPointCloudLayer > layer = std::make_unique< QgsPointCloudLayer >( mTestDataDir + QStringLiteral( "point_clouds/virtual/tiles.vpc" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); + std::unique_ptr layer = std::make_unique( mTestDataDir + QStringLiteral( "point_clouds/virtual/tiles.vpc" ), QStringLiteral( "layer" ), QStringLiteral( "vpc" ) ); QVERIFY( layer->isValid() ); QgsPointCloudIndex *index = layer->dataProvider()->index(); QCOMPARE( index, nullptr ); - QVector< QgsPointCloudSubIndex > subIndexes = layer->dataProvider()->subIndexes(); + QVector subIndexes = layer->dataProvider()->subIndexes(); QCOMPARE( subIndexes.size(), 18 ); int loadedIndexes = 0; diff --git a/tests/src/providers/testqgsvirtualrasterprovider.cpp b/tests/src/providers/testqgsvirtualrasterprovider.cpp index 823fa9704156..450609c91000 100644 --- a/tests/src/providers/testqgsvirtualrasterprovider.cpp +++ b/tests/src/providers/testqgsvirtualrasterprovider.cpp @@ -53,14 +53,14 @@ class TestQgsVirtualRasterProvider : public QgsTest Q_OBJECT public: - - TestQgsVirtualRasterProvider() : QgsTest( QStringLiteral( "Virtual Raster Provider Tests" ) ) {} + TestQgsVirtualRasterProvider() + : QgsTest( QStringLiteral( "Virtual Raster Provider Tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {}// will be called before each testfunction is executed. - void cleanup() {}// will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void validLayer(); void testUriProviderDecoding(); @@ -75,7 +75,6 @@ class TestQgsVirtualRasterProvider : public QgsTest QString mTestDataDir; QgsRasterLayer *mDemRasterLayer = nullptr; QgsRasterLayer *mLandsatRasterLayer = nullptr; - }; //runs before all tests @@ -89,27 +88,25 @@ void TestQgsVirtualRasterProvider::initTestCase() QString demFileName = mTestDataDir + "raster/dem.tif"; QFileInfo demRasterFileInfo( demFileName ); - mDemRasterLayer = new QgsRasterLayer( demRasterFileInfo.filePath(), - demRasterFileInfo.completeBaseName() ); + mDemRasterLayer = new QgsRasterLayer( demRasterFileInfo.filePath(), demRasterFileInfo.completeBaseName() ); QString landsatFileName = mTestDataDir + "landsat.tif"; QFileInfo landsatRasterFileInfo( landsatFileName ); - mLandsatRasterLayer = new QgsRasterLayer( landsatRasterFileInfo.filePath(), - landsatRasterFileInfo.completeBaseName() ); + mLandsatRasterLayer = new QgsRasterLayer( landsatRasterFileInfo.filePath(), landsatRasterFileInfo.completeBaseName() ); } void TestQgsVirtualRasterProvider::validLayer() { QgsRasterLayer::LayerOptions options; - std::unique_ptr< QgsRasterLayer > layer = std::make_unique< QgsRasterLayer >( - mTestDataDir + QStringLiteral( "raster/dem.tif" ), - QStringLiteral( "layer" ), - QStringLiteral( "virtualraster" ), - options - ); + std::unique_ptr layer = std::make_unique( + mTestDataDir + QStringLiteral( "raster/dem.tif" ), + QStringLiteral( "layer" ), + QStringLiteral( "virtualraster" ), + options + ); - QVERIFY( ! layer->isValid() ); + QVERIFY( !layer->isValid() ); } //runs after all tests @@ -120,7 +117,6 @@ void TestQgsVirtualRasterProvider::cleanupTestCase() void TestQgsVirtualRasterProvider::testUriProviderDecoding() { - QgsRasterDataProvider::VirtualRasterParameters decodedParams = QgsVirtualRasterProvider::decodeVirtualRasterProviderUri( QStringLiteral( "?crs=EPSG:4326&extent=18.6662979442000001,45.7767014376000034,18.7035979441999984,45.8117014376000000&width=373&height=350&formula=\"dem@1\" + 200&dem:uri=path/to/file&dem:provider=gdal&landsat:uri=path/to/landsat&landsat:provider=gdal" ) ); QCOMPARE( decodedParams.width, 373 ); @@ -135,7 +131,6 @@ void TestQgsVirtualRasterProvider::testUriProviderDecoding() QCOMPARE( decodedParams.rInputLayers.at( 1 ).uri, QStringLiteral( "path/to/landsat" ) ); QCOMPARE( decodedParams.rInputLayers.at( 0 ).provider, QStringLiteral( "gdal" ) ); QCOMPARE( decodedParams.rInputLayers.at( 1 ).provider, QStringLiteral( "gdal" ) ); - } void TestQgsVirtualRasterProvider::testUriEncoding() @@ -163,23 +158,22 @@ void TestQgsVirtualRasterProvider::absoluteRelativeUri() QgsReadWriteContext context; context.setPathResolver( QgsPathResolver( QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/project.qgs" ) ) ); - QString uriAbs = - "?crs=EPSG:32633&" - "extent=781662.375,3339523.125,793062.375,3350923.125&" - "width=200&" - "height=200&" - "formula=%22landsat@1%22+1&" - "landsat:uri=" + QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif&" - "landsat:provider=gdal"; - - QString uriRel = - "?crs=EPSG:32633&" - "extent=781662.375,3339523.125,793062.375,3350923.125&" - "width=200&" - "height=200&" - "formula=%22landsat@1%22+1&" - "landsat:uri=./landsat.tif&" - "landsat:provider=gdal"; + QString uriAbs = "?crs=EPSG:32633&" + "extent=781662.375,3339523.125,793062.375,3350923.125&" + "width=200&" + "height=200&" + "formula=%22landsat@1%22+1&" + "landsat:uri=" + + QStringLiteral( TEST_DATA_DIR ) + "/landsat.tif&" + "landsat:provider=gdal"; + + QString uriRel = "?crs=EPSG:32633&" + "extent=781662.375,3339523.125,793062.375,3350923.125&" + "width=200&" + "height=200&" + "formula=%22landsat@1%22+1&" + "landsat:uri=./landsat.tif&" + "landsat:provider=gdal"; QgsProviderMetadata *vrMetadata = QgsProviderRegistry::instance()->providerMetadata( "virtualraster" ); QVERIFY( vrMetadata ); @@ -194,22 +188,17 @@ void TestQgsVirtualRasterProvider::testConstructorWrong() { //Giving an invalid uri, with more raster referencies compared to the raster.ref that are present in the formula QString str1 = QStringLiteral( "?crs=EPSG:4326&extent=18.6662979442000001,45.7767014376000034,18.7035979441999984,45.8117014376000000&width=373&height=350&formula=\"dem@1\" + 200&dem:provider=gdal&landsat:provider=gdal" ); - QString uri = QString( "%1&%2&%3" ).arg( str1, QStringLiteral( "dem:uri=" ) % mTestDataDir % QStringLiteral( "raster/dem.tif" ), - QStringLiteral( "landsat:uri=" ) % mTestDataDir % QStringLiteral( "landsat.tif" ) ); - std::unique_ptr< QgsRasterLayer > layer = std::make_unique< QgsRasterLayer >( uri, - QStringLiteral( "layer" ), - QStringLiteral( "virtualraster" ) ); + QString uri = QString( "%1&%2&%3" ).arg( str1, QStringLiteral( "dem:uri=" ) % mTestDataDir % QStringLiteral( "raster/dem.tif" ), QStringLiteral( "landsat:uri=" ) % mTestDataDir % QStringLiteral( "landsat.tif" ) ); + std::unique_ptr layer = std::make_unique( uri, QStringLiteral( "layer" ), QStringLiteral( "virtualraster" ) ); - QVERIFY( ! layer->isValid() ); + QVERIFY( !layer->isValid() ); } void TestQgsVirtualRasterProvider::testConstructor() { QString str1 = QStringLiteral( "?crs=EPSG:4326&extent=18.6662979442000001,45.7767014376000034,18.7035979441999984,45.8117014376000000&width=373&height=350&formula=\"dem@1\" + 200&dem:provider=gdal" ); QString uri1 = QString( "%1&%2" ).arg( str1, QStringLiteral( "dem:uri=" ) % mTestDataDir % QStringLiteral( "raster/dem.tif" ) ); - std::unique_ptr< QgsRasterLayer > layer_1 = std::make_unique< QgsRasterLayer >( uri1, - QStringLiteral( "layer_1" ), - QStringLiteral( "virtualraster" ) ); + std::unique_ptr layer_1 = std::make_unique( uri1, QStringLiteral( "layer_1" ), QStringLiteral( "virtualraster" ) ); QVERIFY( layer_1->dataProvider()->isValid() ); QVERIFY( layer_1->isValid() ); @@ -224,7 +213,7 @@ void TestQgsVirtualRasterProvider::testConstructor() const QString landsatPath = dir.filePath( QStringLiteral( "landsat.tif" ) ); QVERIFY( QFile::copy( mTestDataDir + "landsat.tif", landsatPath ) ); // remove nodata values from layer for consistent test results - std::unique_ptr< QgsRasterLayer > landsat = std::make_unique< QgsRasterLayer >( landsatPath, QString(), QStringLiteral( "gdal" ) ); + std::unique_ptr landsat = std::make_unique( landsatPath, QString(), QStringLiteral( "gdal" ) ); QVERIFY( landsat->isValid() ); landsat->dataProvider()->setNoDataValue( 1, -999999 ); landsat->dataProvider()->setNoDataValue( 2, -999999 ); @@ -232,9 +221,7 @@ void TestQgsVirtualRasterProvider::testConstructor() QString str2 = QStringLiteral( "?crs=EPSG:32633&extent=781662.375,3339523.125,793062.375,3350923.125&width=200&height=200&formula=\"landsat@1\" + \"landsat@2\"&landsat:provider=gdal" ); QString uri2 = QString( "%1&%2" ).arg( str2, QStringLiteral( "landsat:uri=" ) % landsatPath ); - std::unique_ptr< QgsRasterLayer > layer_2 = std::make_unique< QgsRasterLayer >( uri2, - QStringLiteral( "layer_2" ), - QStringLiteral( "virtualraster" ) ); + std::unique_ptr layer_2 = std::make_unique( uri2, QStringLiteral( "layer_2" ), QStringLiteral( "virtualraster" ) ); QVERIFY( layer_2->isValid() ); QVERIFY( layer_2->dataProvider()->isValid() ); @@ -245,18 +232,15 @@ void TestQgsVirtualRasterProvider::testConstructor() //use wrong formula QString str3 = QStringLiteral( "?crs=EPSG:32633&extent=781662.375,3339523.125,793062.375,3350923.125&width=200&height=200&formula=\"landsat@1\" xxxxxx+ \"landsat@2\"&landsat:provider=gdal" ); QString uri3 = QString( "%1&%2" ).arg( str3, QStringLiteral( "landsat:uri=" ) % landsatPath ); - std::unique_ptr< QgsRasterLayer > layer_3 = std::make_unique< QgsRasterLayer >( uri3, - QStringLiteral( "layer_3" ), - QStringLiteral( "virtualraster" ) ); - QVERIFY( ! layer_3->isValid() ); - + std::unique_ptr layer_3 = std::make_unique( uri3, QStringLiteral( "layer_3" ), QStringLiteral( "virtualraster" ) ); + QVERIFY( !layer_3->isValid() ); } void TestQgsVirtualRasterProvider::testNewCalcNodeMethods() { QString formula( "\"landsat@1\" + \"landsat@2\"-\"landsat@3\"" ); QString errorString; - std::unique_ptr< QgsRasterCalcNode > calcNodeApp( QgsRasterCalcNode::parseRasterCalcString( formula, errorString ) ); + std::unique_ptr calcNodeApp( QgsRasterCalcNode::parseRasterCalcString( formula, errorString ) ); QStringList rLayers = calcNodeApp->referencedLayerNames(); QStringList rasterRef = calcNodeApp->cleanRasterReferences(); @@ -274,13 +258,10 @@ void TestQgsVirtualRasterProvider::testNewCalcNodeMethods() void TestQgsVirtualRasterProvider::testSecondGenerationVirtualRaster() { - // creation of the "first generation" virtual raster, meaning a virtual raster that comes directly from a file QString str = QStringLiteral( "?crs=EPSG:4326&extent=18.6662979442000001,45.7767014376000034,18.7035979441999984,45.8117014376000000&width=373&height=350&formula=\"dem@1\" + 200&dem:provider=gdal" ); QString uri = QString( "%1&%2" ).arg( str, QStringLiteral( "dem:uri=" ) % mTestDataDir % QStringLiteral( "raster/dem.tif" ) ); - std::unique_ptr< QgsRasterLayer > layerFirst = std::make_unique< QgsRasterLayer >( uri, - QStringLiteral( "firstGenerationLayer" ), - QStringLiteral( "virtualraster" ) ); + std::unique_ptr layerFirst = std::make_unique( uri, QStringLiteral( "firstGenerationLayer" ), QStringLiteral( "virtualraster" ) ); QVERIFY( layerFirst->dataProvider()->isValid() ); QVERIFY( layerFirst->isValid() ); @@ -300,9 +281,7 @@ void TestQgsVirtualRasterProvider::testSecondGenerationVirtualRaster() params.rInputLayers.append( rasterParams ); QString uriSecond = QgsVirtualRasterProvider::encodeVirtualRasterProviderUri( params ); - std::unique_ptr< QgsRasterLayer > layerSecond = std::make_unique< QgsRasterLayer >( uriSecond, - QStringLiteral( "SecondGenerationLayer" ), - QStringLiteral( "virtualraster" ) ); + std::unique_ptr layerSecond = std::make_unique( uriSecond, QStringLiteral( "SecondGenerationLayer" ), QStringLiteral( "virtualraster" ) ); QVERIFY( layerSecond->dataProvider()->isValid() ); QVERIFY( layerSecond->isValid() ); @@ -311,7 +290,6 @@ void TestQgsVirtualRasterProvider::testSecondGenerationVirtualRaster() QCOMPARE( sampledValueCalc_1, sampledValue + 200. ); QCOMPARE( layerSecond->dataProvider()->crs(), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ); - } QGSTEST_MAIN( TestQgsVirtualRasterProvider ) #include "testqgsvirtualrasterprovider.moc" diff --git a/tests/src/providers/testqgswcsprovider.cpp b/tests/src/providers/testqgswcsprovider.cpp index 7ff7f51888ca..9c3174a79310 100644 --- a/tests/src/providers/testqgswcsprovider.cpp +++ b/tests/src/providers/testqgswcsprovider.cpp @@ -29,28 +29,29 @@ #include #include "qgsprovidermetadata.h" -#define TINY_VALUE std::numeric_limits::epsilon() * 20 +#define TINY_VALUE std::numeric_limits::epsilon() * 20 /** * \ingroup UnitTests * This is a unit test for the QgsRasterLayer class. */ -class TestQgsWcsProvider: public QgsTest +class TestQgsWcsProvider : public QgsTest { Q_OBJECT public: - - TestQgsWcsProvider() : QgsTest( QStringLiteral( "WCS provider tests" ) ) {} + TestQgsWcsProvider() + : QgsTest( QStringLiteral( "WCS provider tests" ) ) {} private slots: - void initTestCase();// will be called before the first testfunction is executed. - void cleanupTestCase();// will be called after the last testfunction was executed. - void init() {} // will be called before each testfunction is executed. - void cleanup() {} // will be called after every testfunction. + void initTestCase(); // will be called before the first testfunction is executed. + void cleanupTestCase(); // will be called after the last testfunction was executed. + void init() {} // will be called before each testfunction is executed. + void cleanup() {} // will be called after every testfunction. void providerUriUpdates(); void read(); + private: bool read( const QString &identifier, const QString &wcsUri, const QString &filePath, QString &report ); QString mTestDataDir; @@ -79,7 +80,7 @@ void TestQgsWcsProvider::initTestCase() mTestDataDir = QStringLiteral( TEST_DATA_DIR ) + "/raster"; qDebug() << "mTestDataDir = " << mTestDataDir; - mUrl = QStringLiteral( TEST_SERVER_URL ) + "/wcs"; + mUrl = QStringLiteral( TEST_SERVER_URL ) + "/wcs"; } //runs after all tests @@ -120,7 +121,7 @@ void TestQgsWcsProvider::read() { // copy to temporary to avoid creation/changes/use of GDAL .aux.xml files const QString testFilePath = mTestDataDir + '/' + identifier + ".tif"; - qDebug() << "copy " << testFilePath << " to " << tmpFilePath; + qDebug() << "copy " << testFilePath << " to " << tmpFilePath; if ( !QFile::copy( testFilePath, tmpFilePath ) ) { mReport += QStringLiteral( "Cannot copy %1 to %2" ).arg( testFilePath, tmpFilePath ); @@ -165,9 +166,7 @@ void TestQgsWcsProvider::providerUriUpdates() "testParam=true" ); QVariantMap parts = metadata->decodeUri( uriString ); - QVariantMap expectedParts { { QString( "crs" ), QVariant( "EPSG:4326" ) }, { QString( "dpiMode" ), QVariant( "7" ) }, - { QString( "testParam" ), QVariant( "true" ) }, { QString( "layers" ), QVariant( "testlayer" ) }, - { QString( "styles" ), QString() }, { QString( "url" ), QVariant( "http://localhost:8380/mapserv" ) } }; + QVariantMap expectedParts { { QString( "crs" ), QVariant( "EPSG:4326" ) }, { QString( "dpiMode" ), QVariant( "7" ) }, { QString( "testParam" ), QVariant( "true" ) }, { QString( "layers" ), QVariant( "testlayer" ) }, { QString( "styles" ), QString() }, { QString( "url" ), QVariant( "http://localhost:8380/mapserv" ) } }; QCOMPARE( parts, expectedParts ); parts["testParam"] = QVariant( "false" ); @@ -180,7 +179,6 @@ void TestQgsWcsProvider::providerUriUpdates() "testParam=false&" "url=http://localhost:8380/mapserv" ); QCOMPARE( updatedUri, expectedUri ); - } diff --git a/tests/src/providers/testqgswcspublicservers.cpp b/tests/src/providers/testqgswcspublicservers.cpp index 979ede7b489b..8492a1825ba4 100644 --- a/tests/src/providers/testqgswcspublicservers.cpp +++ b/tests/src/providers/testqgswcspublicservers.cpp @@ -42,8 +42,8 @@ #include #endif -TestQgsWcsPublicServers::TestQgsWcsPublicServers( const QString &cacheDirPath, int maxCoverages, const QString &server, const QString &coverage, const QString &version, bool force ): - mCacheDirPath( cacheDirPath ) +TestQgsWcsPublicServers::TestQgsWcsPublicServers( const QString &cacheDirPath, int maxCoverages, const QString &server, const QString &coverage, const QString &version, bool force ) + : mCacheDirPath( cacheDirPath ) , mMaxCoverages( maxCoverages ) , mServer( server ) , mCoverage( coverage ) @@ -52,7 +52,6 @@ TestQgsWcsPublicServers::TestQgsWcsPublicServers( const QString &cacheDirPath, i , mTimeout( 300000 ) , mOrigTimeout( 20000 ) { - } TestQgsWcsPublicServers::~TestQgsWcsPublicServers() @@ -104,7 +103,7 @@ void TestQgsWcsPublicServers::init() } // read servers + issues list - QString path = QgsApplication::pkgDataPath() + "/resources/wcs-servers.json"; + QString path = QgsApplication::pkgDataPath() + "/resources/wcs-servers.json"; QFile file( path ); if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { @@ -176,7 +175,8 @@ TestQgsWcsPublicServers::Server TestQgsWcsPublicServers::getServer( const QStrin { for ( const Server &server : std::as_const( mServers ) ) { - if ( server.url == url ) return server; + if ( server.url == url ) + return server; } return Server(); } @@ -190,8 +190,7 @@ QList TestQgsWcsPublicServers::issues( const QSt { for ( const Issue &issue : server.issues ) { - if ( ( issue.coverages.isEmpty() || issue.coverages.contains( coverage ) ) && - ( issue.versions.isEmpty() || issue.versions.contains( version ) ) ) + if ( ( issue.coverages.isEmpty() || issue.coverages.contains( coverage ) ) && ( issue.versions.isEmpty() || issue.versions.contains( version ) ) ) { issues << issue; } @@ -316,7 +315,7 @@ void TestQgsWcsPublicServers::test() if ( !myCapabilities.lastError().isEmpty() ) { QgsDebugError( myCapabilities.lastError() ); - myVersionLog << "error:" + myCapabilities.lastError().replace( '\n', ' ' ); + myVersionLog << "error:" + myCapabilities.lastError().replace( '\n', ' ' ); continue; } @@ -333,13 +332,14 @@ void TestQgsWcsPublicServers::test() myVersionLog << QStringLiteral( "totalCoverages:%1" ).arg( myCoverages.size() ); int myCoverageCount = 0; - int myStep = myCoverages.size() / std::min< int >( mMaxCoverages, myCoverages.size() ); + int myStep = myCoverages.size() / std::min( mMaxCoverages, myCoverages.size() ); int myStepCount = -1; bool myCoverageFound = false; for ( QgsWcsCoverageSummary myCoverage : myCoverages ) { QgsDebugMsgLevel( "coverage: " + myCoverage.identifier, 1 ); - if ( !mCoverage.isEmpty() && myCoverage.identifier != mCoverage ) continue; + if ( !mCoverage.isEmpty() && myCoverage.identifier != mCoverage ) + continue; myCoverageFound = true; // Go in steps to get more success/errors @@ -354,7 +354,8 @@ void TestQgsWcsPublicServers::test() } myCoverageCount++; - if ( myCoverageCount > mMaxCoverages ) break; + if ( myCoverageCount > mMaxCoverages ) + break; QString myPath = myVersionDirPath + '/' + myCoverage.identifier; @@ -428,15 +429,15 @@ void TestQgsWcsPublicServers::test() myLog << provider + "_height:" + QString::number( myLayer->dataProvider()->ySize() ); QgsRectangle extent = myLayer->dataProvider()->extent(); myLog << provider + "_extent:" - + QgsRasterBlock::printValue( extent.xMinimum() ) + ',' - + QgsRasterBlock::printValue( extent.yMinimum() ) + ',' - + QgsRasterBlock::printValue( extent.xMaximum() ) + ',' - + QgsRasterBlock::printValue( extent.yMaximum() ) + ','; + + QgsRasterBlock::printValue( extent.xMinimum() ) + ',' + + QgsRasterBlock::printValue( extent.yMinimum() ) + ',' + + QgsRasterBlock::printValue( extent.xMaximum() ) + ',' + + QgsRasterBlock::printValue( extent.yMaximum() ) + ','; int myBandCount = myLayer->dataProvider()->bandCount(); myLog << provider + "_bandCount:" + QString::number( myBandCount ); if ( myBandCount > 0 ) { - myLog << provider + "_srcType:" + qgsEnumValueToKey< Qgis::DataType >( myLayer->dataProvider()->sourceDataType( 1 ) ); + myLog << provider + "_srcType:" + qgsEnumValueToKey( myLayer->dataProvider()->sourceDataType( 1 ) ); QgsRasterBandStats myStats = myLayer->dataProvider()->bandStatistics( 1, Qgis::RasterBandStatistic::All, QgsRectangle(), myWidth * myHeight ); myLog << provider + "_min:" + QString::number( myStats.minimumValue ); @@ -472,7 +473,8 @@ void TestQgsWcsPublicServers::test() { double value = myBlock->value( row, col ); QString valueStr = QString::number( value ); - if ( !myValues.contains( valueStr ) ) myValues.insert( valueStr ); + if ( !myValues.contains( valueStr ) ) + myValues.insert( valueStr ); } } delete myBlock; @@ -487,7 +489,8 @@ void TestQgsWcsPublicServers::test() for ( int col = 0; col < myWidth; col++ ) { QRgb color = myImage.pixel( col, row ); - if ( !myColors.contains( color ) ) myColors.insert( color ); + if ( !myColors.contains( color ) ) + myColors.insert( color ); } } QgsDebugMsgLevel( QStringLiteral( "%1 colors" ).arg( myColors.size() ), 1 ); @@ -512,7 +515,7 @@ void TestQgsWcsPublicServers::test() myLogFile.close(); QgsProject::instance()->removeAllMapLayers(); } - if ( !mCoverage.isEmpty() && ! myCoverageFound ) + if ( !mCoverage.isEmpty() && !myCoverageFound ) { QgsDebugError( QStringLiteral( "Coverage not found" ) ); } @@ -548,7 +551,7 @@ void TestQgsWcsPublicServers::report() QString myReport; int myServerCount = 0; - int myServerErrCount = 0; // at least one error + int myServerErrCount = 0; // at least one error int myServerWarnCount = 0; // at least one error int myCoverageCount = 0; int myCoverageErrCount = 0; @@ -616,12 +619,13 @@ void TestQgsWcsPublicServers::report() myVersionDir.setNameFilters( filters ); for ( const QString &myLogFileName : myVersionDir.entryList( QDir::Files ) ) { - if ( myLogFileName == QLatin1String( "version.log" ) ) continue; + if ( myLogFileName == QLatin1String( "version.log" ) ) + continue; myVersionCoverageCount++; myCoverageCount++; QString myLogPath = myVersionDir.absolutePath() + '/' + myLogFileName; - QMapmyLog = readLog( myLogPath ); + QMap myLog = readLog( myLogPath ); myVersionReport += QLatin1String( "" ); QStringList myValues; @@ -727,18 +731,19 @@ void TestQgsWcsPublicServers::report() } // coverages myVersionReport += QLatin1String( "\n" ); // prepend counts - myVersionReport.prepend( QStringLiteral( "Total coverages: %1
    \n" ).arg( myVersionLog.value( QStringLiteral( "totalCoverages" ) ) ) + - QStringLiteral( "Tested coverages: %1
    \n" ).arg( myVersionCoverageCount ) + - QStringLiteral( "Errors: %1
    \n" ).arg( myVersionErrCount ) + - QStringLiteral( "Warnings: %1

    " ).arg( myVersionWarnCount ) ); + myVersionReport.prepend( QStringLiteral( "Total coverages: %1
    \n" ).arg( myVersionLog.value( QStringLiteral( "totalCoverages" ) ) ) + QStringLiteral( "Tested coverages: %1
    \n" ).arg( myVersionCoverageCount ) + QStringLiteral( "Errors: %1
    \n" ).arg( myVersionErrCount ) + QStringLiteral( "Warnings: %1

    " ).arg( myVersionWarnCount ) ); myServerReport += myVersionReport; } - if ( myVersionErrCount > 0 ) myServerErr = true; - if ( myVersionWarnCount > 0 ) myServerWarn = true; + if ( myVersionErrCount > 0 ) + myServerErr = true; + if ( myVersionWarnCount > 0 ) + myServerWarn = true; } // versions myReport += myServerReport; - if ( myServerErr ) myServerErrCount++; - if ( myServerWarn ) myServerWarnCount++; + if ( myServerErr ) + myServerErrCount++; + if ( myServerWarn ) + myServerWarnCount++; } // servers QString mySettings = QgsApplication::showSettings(); @@ -838,7 +843,7 @@ void usage( std::string const &appName ) { std::cerr << "QGIS public WCS servers test - " << VERSION << " '" << RELEASE_NAME << "'\n" << "Console application for QGIS WCS provider (WCS client) testing.\n" - << "Usage: " << appName << " [options] CACHE_DIR\n" + << "Usage: " << appName << " [options] CACHE_DIR\n" << " options: \n" << "\t[--server URL]\tWCS server URL to be tested.\n" << "\t[--coverage coverage]\tCoverage name to be tested.\n" @@ -855,10 +860,10 @@ int main( int argc, char *argv[] ) #ifdef Q_OS_WIN // Windows #ifdef _MSC_VER _set_fmode( _O_BINARY ); -#else //MinGW +#else //MinGW _fmode = _O_BINARY; -#endif // _MSC_VER -#endif // Q_OS_WIN +#endif // _MSC_VER +#endif // Q_OS_WIN QString myServer; QString myCoverage; @@ -868,15 +873,14 @@ int main( int argc, char *argv[] ) #ifndef Q_OS_WIN int optionChar; - static struct option long_options[] = - { - {"help", no_argument, nullptr, 'h'}, - {"server", required_argument, nullptr, 's'}, - {"coverage", required_argument, nullptr, 'c'}, - {"num", required_argument, nullptr, 'n'}, - {"version", required_argument, nullptr, 'v'}, - {"force", no_argument, nullptr, 'f'}, - {nullptr, 0, nullptr, 0} + static struct option long_options[] = { + { "help", no_argument, nullptr, 'h' }, + { "server", required_argument, nullptr, 's' }, + { "coverage", required_argument, nullptr, 'c' }, + { "num", required_argument, nullptr, 'n' }, + { "version", required_argument, nullptr, 'v' }, + { "force", no_argument, nullptr, 'f' }, + { nullptr, 0, nullptr, 0 } }; while ( true ) @@ -884,8 +888,7 @@ int main( int argc, char *argv[] ) /* getopt_long stores the option index here. */ int option_index = 0; - optionChar = getopt_long( argc, argv, "hscnvf", - long_options, &option_index ); + optionChar = getopt_long( argc, argv, "hscnvf", long_options, &option_index ); /* Detect the end of the options. */ if ( optionChar == -1 ) @@ -925,13 +928,12 @@ int main( int argc, char *argv[] ) case 'h': usage( argv[0] ); - return 2; // XXX need standard exit codes + return 2; // XXX need standard exit codes default: QgsDebugMsgLevel( QStringLiteral( "%1: getopt returned character code %2" ).arg( argv[0] ).arg( optionChar ), 1 ); - return 1; // XXX need standard exit codes + return 1; // XXX need standard exit codes } - } QgsDebugMsgLevel( QStringLiteral( "myServer = %1" ).arg( myServer ), 1 ); diff --git a/tests/src/providers/testqgswcspublicservers.h b/tests/src/providers/testqgswcspublicservers.h index bc3e74aba23b..955ec6017769 100644 --- a/tests/src/providers/testqgswcspublicservers.h +++ b/tests/src/providers/testqgswcspublicservers.h @@ -28,35 +28,37 @@ * This class tries to get samples of coverages from public WCS servers, * cache results and write report. */ -class TestQgsWcsPublicServers: public QObject +class TestQgsWcsPublicServers : public QObject { Q_OBJECT public: // Known problem struct Issue { - QString offender; // server or empty == qgis - QStringList versions; // version regex - QStringList coverages; // coverage regex - QString description; // problem description - Issue( const QString &d ) : description( d ) {} + QString offender; // server or empty == qgis + QStringList versions; // version regex + QStringList coverages; // coverage regex + QString description; // problem description + Issue( const QString &d ) + : description( d ) {} }; struct Server { - Server() = default; - Server( const QString &u ) : url( u ) {} - QString url; // URL - QString description; // notes - QList issues; - // additional params to be set on URI, e.g. IgnoreGetMapUrl - QMap params; + Server() = default; + Server( const QString &u ) + : url( u ) {} + QString url; // URL + QString description; // notes + QList issues; + // additional params to be set on URI, e.g. IgnoreGetMapUrl + QMap params; }; enum OffenderType { - NoOffender = 0, - ServerOffender = 1, - QgisOffender = 1 << 1 + NoOffender = 0, + ServerOffender = 1, + QgisOffender = 1 << 1 }; TestQgsWcsPublicServers( const QString &cacheDirPath, int maxCoverages, const QString &server = QString(), const QString &coverage = QString(), const QString &version = QString(), bool force = false ); @@ -66,6 +68,7 @@ class TestQgsWcsPublicServers: public QObject void init(); void test(); void report(); + private: QString cells( const QStringList &values, const QString &classStr = QString(), int colspan = 1, int rowspan = 1 ); QString row( const QStringList &values, const QString &classStr = QString() ); diff --git a/tests/src/providers/testqgswmscapabilities.cpp b/tests/src/providers/testqgswmscapabilities.cpp index 6291f4ddebdf..e5f458e5f31b 100644 --- a/tests/src/providers/testqgswmscapabilities.cpp +++ b/tests/src/providers/testqgswmscapabilities.cpp @@ -23,7 +23,7 @@ * \ingroup UnitTests * This is a unit test for the WMS capabilities parser. */ -class TestQgsWmsCapabilities: public QObject +class TestQgsWmsCapabilities : public QObject { Q_OBJECT private slots: @@ -72,12 +72,10 @@ class TestQgsWmsCapabilities: public QObject QCOMPARE( capabilities.supportedLayers()[0].style.size(), 2 ); QCOMPARE( capabilities.supportedLayers()[0].style[0].name, QString( "yt_style" ) ); QCOMPARE( capabilities.supportedLayers()[0].style[0].legendUrl.size(), 1 ); - QCOMPARE( capabilities.supportedLayers()[0].style[0].legendUrl[0].onlineResource.xlinkHref, - QString( "http://www.example.com/yt.png" ) ); + QCOMPARE( capabilities.supportedLayers()[0].style[0].legendUrl[0].onlineResource.xlinkHref, QString( "http://www.example.com/yt.png" ) ); QCOMPARE( capabilities.supportedLayers()[0].style[1].name, QString( "fb_style" ) ); QCOMPARE( capabilities.supportedLayers()[0].style[1].legendUrl.size(), 1 ); - QCOMPARE( capabilities.supportedLayers()[0].style[1].legendUrl[0].onlineResource.xlinkHref, - QString( "http://www.example.com/fb.png" ) ); + QCOMPARE( capabilities.supportedLayers()[0].style[1].legendUrl[0].onlineResource.xlinkHref, QString( "http://www.example.com/fb.png" ) ); QCOMPARE( capabilities.supportedLayers()[0].crs, QStringList() << QStringLiteral( "EPSG:2056" ) ); } @@ -96,16 +94,13 @@ class TestQgsWmsCapabilities: public QObject QCOMPARE( capabilities.supportedLayers().size(), 5 ); QCOMPARE( capabilities.supportedLayers().at( 0 ).preferredAvailableCrs(), QStringLiteral( "EPSG:3857" ) ); - } void wmstSettings() { QgsWmsSettings settings = QgsWmsSettings(); - QMap map = { { "2020-02-13T12:00:00Z", "yyyy-MM-ddThh:mm:ssZ" }, - { "2020-02-13", "yyyy-MM-dd" } - }; + QMap map = { { "2020-02-13T12:00:00Z", "yyyy-MM-ddThh:mm:ssZ" }, { "2020-02-13", "yyyy-MM-dd" } }; QMapIterator iterator( map ); while ( iterator.hasNext() ) @@ -115,8 +110,7 @@ class TestQgsWmsCapabilities: public QObject QCOMPARE( date.toString( iterator.value() ), iterator.key() ); } - QList resolutionList = - { + QList resolutionList = { "P1D", "P1Y", "PT5M", "P1DT1H", "P1Y1DT3S", "P1MT1M", "PT23H3M", "P26DT23H3M", "PT30S" }; @@ -230,18 +224,18 @@ class TestQgsWmsCapabilities: public QObject QCOMPARE( extent.datesResolutionList.at( 7 ).dates.dateTimes.size(), 1 ); QCOMPARE( extent.datesResolutionList.at( 7 ).dates.dateTimes.at( 0 ), QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1930, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1930, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1932, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1933, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1947, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1947, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1949, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1947, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1950, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1950, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1950, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1950, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1973, 12, 31 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1972, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1974, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); - QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 2000, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1930, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1930, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1932, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1933, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1932, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1947, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1947, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1949, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1947, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1950, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1950, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1950, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1950, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1973, 12, 31 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1972, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 1974, 1, 2 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); + QCOMPARE( settings.findLeastClosestDateTime( QDateTime( QDate( 2000, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ), QDateTime( QDate( 1974, 1, 1 ), QTime( 0, 0, 0 ), Qt::UTC ) ); } void wmsTemporalDimension_data() @@ -259,10 +253,10 @@ class TestQgsWmsCapabilities: public QObject )""" << "2020-01-01/2020-12-31/P1M"; - QTest::newRow( "list" ) << R"""( + QTest::newRow( "list" ) << R"""( 2020-01-01,2020-06-31,2020-12-31 )""" - << "2020-01-01,2020-06-31,2020-12-31"; + << "2020-01-01,2020-06-31,2020-12-31"; QTest::newRow( "continuous" ) << R"""( 2020-01-01/2020-06-31 @@ -270,11 +264,11 @@ class TestQgsWmsCapabilities: public QObject << "2020-01-01/2020-06-31"; QTest::newRow( "interval with internal newline characters" ) - << R"""( + << R"""( 2020-01-01/2020-06-31/P1M, 2020-07-01/2020-12-31/P1D )""" - << "2020-01-01/2020-06-31/P1M, 2020-07-01/2020-12-31/P1D"; + << "2020-01-01/2020-06-31/P1M, 2020-07-01/2020-12-31/P1D"; } void wmsTemporalDimension() @@ -412,7 +406,7 @@ class TestQgsWmsCapabilities: public QObject 2020-01-01 )""" - << R"""( + << R"""( Test Test Test @@ -424,7 +418,7 @@ class TestQgsWmsCapabilities: public QObject 2020-01-01/2020-12-31/P1M )""" - << false; + << false; } void wmsLayerProperty() @@ -447,7 +441,6 @@ class TestQgsWmsCapabilities: public QObject cap.parseLayer( doc2.documentElement(), secondLayerProp ); QCOMPARE( firstLayerProp.equal( secondLayerProp ), result ); - } void wmsIdentifyFormat_data() @@ -567,13 +560,12 @@ class TestQgsWmsCapabilities: public QObject QCOMPARE( tileLayer.title, QStringLiteral( "ETa Scaled" ) ); QCOMPARE( tileLayer.timeDimensionIdentifier, QStringLiteral( "time" ) ); - QCOMPARE( tileLayer.allTimeRanges, QList< QgsDateTimeRange >( - { - QgsDateTimeRange( QDateTime( QDate( 2005, 8, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2005, 8, 1 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( QDateTime( QDate( 2016, 3, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2016, 3, 1 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( QDateTime( QDate( 2005, 7, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2005, 7, 1 ), QTime( 0, 0, 0 ) ) ), - QgsDateTimeRange( QDateTime( QDate( 2009, 2, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2009, 2, 1 ), QTime( 0, 0, 0 ) ) ), - } ) ); + QCOMPARE( tileLayer.allTimeRanges, QList( { + QgsDateTimeRange( QDateTime( QDate( 2005, 8, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2005, 8, 1 ), QTime( 0, 0, 0 ) ) ), + QgsDateTimeRange( QDateTime( QDate( 2016, 3, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2016, 3, 1 ), QTime( 0, 0, 0 ) ) ), + QgsDateTimeRange( QDateTime( QDate( 2005, 7, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2005, 7, 1 ), QTime( 0, 0, 0 ) ) ), + QgsDateTimeRange( QDateTime( QDate( 2009, 2, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2009, 2, 1 ), QTime( 0, 0, 0 ) ) ), + } ) ); QCOMPARE( tileLayer.temporalExtent, QgsDateTimeRange( QDateTime( QDate( 2005, 7, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2016, 3, 1 ), QTime( 0, 0, 0 ) ) ) ); QCOMPARE( tileLayer.temporalInterval, QgsInterval( 1, Qgis::TemporalUnit::IrregularStep ) ); QCOMPARE( tileLayer.temporalCapabilityFlags, Qgis::RasterTemporalCapabilityFlag::RequestedTimesMustExactlyMatchAllAvailableTemporalRanges ); @@ -586,10 +578,10 @@ class TestQgsWmsCapabilities: public QObject QTest::addColumn( "range" ); QTest::addColumn( "format" ); - QTest::newRow( "YYYYMMDD" ) << QString( "20210103" ) << QgsDateTimeRange( QDateTime( QDate( 2021, 1, 3 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 1, 3 ), QTime( 23, 59, 59, 999 ) ) ) << static_cast< int >( QgsWmtsTileLayer::WmtsTimeFormat::yyyyMMdd ); - QTest::newRow( "YYYY-MM-DD" ) << QString( "2021-01-03" ) << QgsDateTimeRange( QDateTime( QDate( 2021, 1, 3 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 1, 3 ), QTime( 23, 59, 59, 999 ) ) ) << static_cast< int >( QgsWmtsTileLayer::WmtsTimeFormat::yyyy_MM_dd ); - QTest::newRow( "YYYY" ) << QString( "2021" ) << QgsDateTimeRange( QDateTime( QDate( 2021, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 12, 31 ), QTime( 23, 59, 59, 999 ) ) ) << static_cast< int >( QgsWmtsTileLayer::WmtsTimeFormat::yyyy ); - QTest::newRow( "YYYY-MM-DDTHH:mm:ss.SSSZ" ) << QString( "2018-03-01T16:23:44Z" ) << QgsDateTimeRange( QDateTime( QDate( 2018, 3, 1 ), QTime( 16, 23, 44 ) ), QDateTime( QDate( 2018, 3, 1 ), QTime( 16, 23, 44 ) ) ) << static_cast< int >( QgsWmtsTileLayer::WmtsTimeFormat::yyyyMMddThhmmssZ ); + QTest::newRow( "YYYYMMDD" ) << QString( "20210103" ) << QgsDateTimeRange( QDateTime( QDate( 2021, 1, 3 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 1, 3 ), QTime( 23, 59, 59, 999 ) ) ) << static_cast( QgsWmtsTileLayer::WmtsTimeFormat::yyyyMMdd ); + QTest::newRow( "YYYY-MM-DD" ) << QString( "2021-01-03" ) << QgsDateTimeRange( QDateTime( QDate( 2021, 1, 3 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 1, 3 ), QTime( 23, 59, 59, 999 ) ) ) << static_cast( QgsWmtsTileLayer::WmtsTimeFormat::yyyy_MM_dd ); + QTest::newRow( "YYYY" ) << QString( "2021" ) << QgsDateTimeRange( QDateTime( QDate( 2021, 1, 1 ), QTime( 0, 0, 0 ) ), QDateTime( QDate( 2021, 12, 31 ), QTime( 23, 59, 59, 999 ) ) ) << static_cast( QgsWmtsTileLayer::WmtsTimeFormat::yyyy ); + QTest::newRow( "YYYY-MM-DDTHH:mm:ss.SSSZ" ) << QString( "2018-03-01T16:23:44Z" ) << QgsDateTimeRange( QDateTime( QDate( 2018, 3, 1 ), QTime( 16, 23, 44 ) ), QDateTime( QDate( 2018, 3, 1 ), QTime( 16, 23, 44 ) ) ) << static_cast( QgsWmtsTileLayer::WmtsTimeFormat::yyyyMMddThhmmssZ ); } void wmtsTimeDimensionValue() @@ -602,9 +594,8 @@ class TestQgsWmsCapabilities: public QObject QgsDateTimeRange res = QgsWmsSettings::parseWmtsTimeValue( value, resFormat ); QCOMPARE( res.begin(), range.begin() ); QCOMPARE( res.end(), range.end() ); - QCOMPARE( static_cast< int >( resFormat ), format ); + QCOMPARE( static_cast( resFormat ), format ); } - }; QGSTEST_MAIN( TestQgsWmsCapabilities ) diff --git a/tests/src/providers/testqgswmsccapabilities.cpp b/tests/src/providers/testqgswmsccapabilities.cpp index a1e2e5f298d5..78d14e6f615d 100644 --- a/tests/src/providers/testqgswmsccapabilities.cpp +++ b/tests/src/providers/testqgswmsccapabilities.cpp @@ -23,7 +23,7 @@ * This is a unit test for the WMS-C capabilities parser * implemented as QgsWmsCapabilities::parseTileSetProfile */ -class TestQgsWmscCapabilities: public QObject +class TestQgsWmscCapabilities : public QObject { Q_OBJECT private slots: diff --git a/tests/src/providers/testqgswmsprovider.cpp b/tests/src/providers/testqgswmsprovider.cpp index 40d93a3576cc..d736bfcc38f7 100644 --- a/tests/src/providers/testqgswmsprovider.cpp +++ b/tests/src/providers/testqgswmsprovider.cpp @@ -36,13 +36,13 @@ * \ingroup UnitTests * This is a unit test for the WMS provider. */ -class TestQgsWmsProvider: public QgsTest +class TestQgsWmsProvider : public QgsTest { Q_OBJECT public: - - TestQgsWmsProvider() : QgsTest( QStringLiteral( "WMS Provider Tests" ) ) {} + TestQgsWmsProvider() + : QgsTest( QStringLiteral( "WMS Provider Tests" ) ) {} private slots: @@ -101,7 +101,6 @@ class TestQgsWmsProvider: public QgsTest private: QgsWmsCapabilities *mCapabilities = nullptr; - }; @@ -170,7 +169,7 @@ void TestQgsWmsProvider::queryItemsWithPlusSign() QgsWmsCapabilities cap; QFile file( QStringLiteral( TEST_DATA_DIR ) + "/provider/GetCapabilities.xml" ); QVERIFY( file.open( QIODevice::ReadOnly | QIODevice::Text ) ); - const QByteArray content = file.readAll().replace( "test", "plus+sign" ); + const QByteArray content = file.readAll().replace( "test", "plus+sign" ); QVERIFY( cap.parseResponse( content, config ) ); QgsWmsProvider provider( failingAddress, QgsDataProvider::ProviderOptions(), &cap ); QUrl url( provider.createRequestUrlWMS( QgsRectangle( 0, 0, 90, 90 ), 100, 100 ) ); @@ -312,13 +311,13 @@ void TestQgsWmsProvider::testMbtilesProviderMetadata() // mbtile uris QCOMPARE( wmsMetadata->priorityForUri( QStringLiteral( "%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ), 100 ); - QCOMPARE( wmsMetadata->validLayerTypesForUri( QStringLiteral( "%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ), {Qgis::LayerType::Raster} ); + QCOMPARE( wmsMetadata->validLayerTypesForUri( QStringLiteral( "%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ), { Qgis::LayerType::Raster } ); QCOMPARE( wmsMetadata->priorityForUri( QStringLiteral( "type=mbtiles&url=%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ), 100 ); - QCOMPARE( wmsMetadata->validLayerTypesForUri( QStringLiteral( "type=mbtiles&url=%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ), {Qgis::LayerType::Raster} ); + QCOMPARE( wmsMetadata->validLayerTypesForUri( QStringLiteral( "type=mbtiles&url=%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ), { Qgis::LayerType::Raster } ); // query sublayers - QList< QgsProviderSublayerDetails > sublayers = wmsMetadata->querySublayers( QStringLiteral( "%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ); + QList sublayers = wmsMetadata->querySublayers( QStringLiteral( "%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ); QCOMPARE( sublayers.size(), 1 ); QCOMPARE( sublayers.at( 0 ).providerKey(), QStringLiteral( "wms" ) ); QCOMPARE( sublayers.at( 0 ).name(), QStringLiteral( "isle_of_man" ) ); @@ -385,14 +384,14 @@ void TestQgsWmsProvider::testMbtilesProviderMetadata() int candidateIndex = candidates.at( 0 ).metadata()->key() == QLatin1String( "wms" ) ? 0 : 1; QCOMPARE( candidates.at( candidateIndex ).metadata()->key(), QStringLiteral( "wms" ) ); - QCOMPARE( candidates.at( candidateIndex ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::Raster ); + QCOMPARE( candidates.at( candidateIndex ).layerTypes(), QList() << Qgis::LayerType::Raster ); candidates = QgsProviderRegistry::instance()->preferredProvidersForUri( QStringLiteral( "%1/isle_of_man.mbtiles" ).arg( TEST_DATA_DIR ) ); // mbtiles vector tile provider also reports handling this url QCOMPARE( candidates.size(), 2 ); candidateIndex = candidates.at( 0 ).metadata()->key() == QLatin1String( "wms" ) ? 0 : 1; QCOMPARE( candidates.at( candidateIndex ).metadata()->key(), QStringLiteral( "wms" ) ); - QCOMPARE( candidates.at( candidateIndex ).layerTypes(), QList< Qgis::LayerType >() << Qgis::LayerType::Raster ); + QCOMPARE( candidates.at( candidateIndex ).layerTypes(), QList() << Qgis::LayerType::Raster ); } void TestQgsWmsProvider::testDpiDependentData() @@ -428,9 +427,7 @@ void TestQgsWmsProvider::providerUriUpdates() "url=http://localhost:8380/mapserv&" "testParam=true" ); QVariantMap parts = metadata->decodeUri( uriString ); - QVariantMap expectedParts { { QString( "crs" ), QVariant( "EPSG:4326" ) }, { QString( "dpiMode" ), QVariant( "7" ) }, - { QString( "testParam" ), QVariant( "true" ) }, { QString( "layers" ), QVariant( "testlayer" ) }, - { QString( "styles" ), QString() }, { QString( "url" ), QVariant( "http://localhost:8380/mapserv" ) } }; + QVariantMap expectedParts { { QString( "crs" ), QVariant( "EPSG:4326" ) }, { QString( "dpiMode" ), QVariant( "7" ) }, { QString( "testParam" ), QVariant( "true" ) }, { QString( "layers" ), QVariant( "testlayer" ) }, { QString( "styles" ), QString() }, { QString( "url" ), QVariant( "http://localhost:8380/mapserv" ) } }; QCOMPARE( parts, expectedParts ); parts["testParam"] = QVariant( "false" ); @@ -443,16 +440,13 @@ void TestQgsWmsProvider::providerUriUpdates() "testParam=false&" "url=http://localhost:8380/mapserv" ); QCOMPARE( updatedUri, expectedUri ); - } void TestQgsWmsProvider::providerUriLocalFile() { QString uriString = QStringLiteral( "url=file:///my/local/tiles.mbtiles&type=mbtiles" ); QVariantMap parts = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "wms" ), uriString ); - QVariantMap expectedParts { { QString( "type" ), QVariant( "mbtiles" ) }, - { QString( "path" ), QVariant( "/my/local/tiles.mbtiles" ) }, - { QString( "url" ), QVariant( "file:///my/local/tiles.mbtiles" ) } }; + QVariantMap expectedParts { { QString( "type" ), QVariant( "mbtiles" ) }, { QString( "path" ), QVariant( "/my/local/tiles.mbtiles" ) }, { QString( "url" ), QVariant( "file:///my/local/tiles.mbtiles" ) } }; QCOMPARE( parts, expectedParts ); QString encodedUri = QgsProviderRegistry::instance()->encodeUri( QStringLiteral( "wms" ), parts ); @@ -462,7 +456,7 @@ void TestQgsWmsProvider::providerUriLocalFile() QVERIFY( wmsMetadata ); // query sublayers - QList< QgsProviderSublayerDetails > sublayers; + QList sublayers; sublayers = wmsMetadata->querySublayers( QStringLiteral( "type=xyz&url=file:///my/xyz/directory/%7Bz%7D/%7Bx%7D/%7By%7D.png&zmax=19&zmin=0" ) ); QCOMPARE( sublayers.size(), 1 ); QCOMPARE( sublayers.at( 0 ).providerKey(), QStringLiteral( "wms" ) ); @@ -582,10 +576,7 @@ void TestQgsWmsProvider::testResampling() QgsMapSettings mapSettings; mapSettings.setLayers( QList() << &layer ); QgsRectangle layerExtent = layer.extent(); - mapSettings.setExtent( QgsRectangle( layerExtent.xMinimum() + 1000, - layerExtent.yMinimum() + 1000, - layerExtent.xMinimum() + 1000 + layerExtent.width() / 3000000, - layerExtent.yMinimum() + 1000 + layerExtent.height() / 3000000 ) ); + mapSettings.setExtent( QgsRectangle( layerExtent.xMinimum() + 1000, layerExtent.yMinimum() + 1000, layerExtent.xMinimum() + 1000 + layerExtent.width() / 3000000, layerExtent.yMinimum() + 1000 + layerExtent.height() / 3000000 ) ); mapSettings.setOutputSize( QSize( 400, 400 ) ); mapSettings.setOutputDpi( 96 ); mapSettings.setDpiTarget( 48 ); @@ -646,7 +637,6 @@ void TestQgsWmsProvider::testMaxTileSize() const QSize maxTileSize5 = provider5.maximumTileSize(); QCOMPARE( maxTileSize5.width(), 3000 ); QCOMPARE( maxTileSize5.height(), 3000 ); - } QGSTEST_MAIN( TestQgsWmsProvider ) diff --git a/tests/src/quickgui/app/main.cpp b/tests/src/quickgui/app/main.cpp index 4ee4e21ec1bc..8a6a385bd514 100644 --- a/tests/src/quickgui/app/main.cpp +++ b/tests/src/quickgui/app/main.cpp @@ -45,7 +45,7 @@ int main( int argc, char *argv[] ) QgsApplication::initQgis(); // 2) Load QGIS Project - QString dataDir( TEST_DATA_DIR ); // defined in CMakeLists.txt + QString dataDir( TEST_DATA_DIR ); // defined in CMakeLists.txt QString projectFile = dataDir + "/quickapp_project.qgs"; QgsDebugMsgLevel( QStringLiteral( "project file: %1" ).arg( projectFile ), 2 ); QgsProject project; diff --git a/tests/src/quickgui/testqgsquickmapsettings.cpp b/tests/src/quickgui/testqgsquickmapsettings.cpp index b2967c00fe3a..a8ace8d8f87c 100644 --- a/tests/src/quickgui/testqgsquickmapsettings.cpp +++ b/tests/src/quickgui/testqgsquickmapsettings.cpp @@ -24,11 +24,11 @@ #include "qgsquickmapsettings.h" #include "qgsquickmaptoscreen.h" -class TestQgsQuickMapSettings: public QObject +class TestQgsQuickMapSettings : public QObject { Q_OBJECT private slots: - void init() {} // will be called before each testfunction is executed. + void init() {} // will be called before each testfunction is executed. void cleanup() {} // will be called after every testfunction. void test_project_existency(); diff --git a/tests/src/server/testqgsserverquerystringparameter.cpp b/tests/src/server/testqgsserverquerystringparameter.cpp index 78aad7216489..4d6f170b46c9 100644 --- a/tests/src/server/testqgsserverquerystringparameter.cpp +++ b/tests/src/server/testqgsserverquerystringparameter.cpp @@ -134,7 +134,6 @@ void TestQgsServerQueryStringParameter::testArguments() request.setUrl( QStringLiteral( "http://www.qgis.org/api/?parameter1=a%20value" ) ); QCOMPARE( p.value( ctx ).toStringList(), QStringList() << QStringLiteral( "a value" ) ); QCOMPARE( static_cast( p.value( ctx ).userType() ), QMetaType::Type::QStringList ); - } void TestQgsServerQueryStringParameter::testCustomValidators() @@ -147,8 +146,7 @@ void TestQgsServerQueryStringParameter::testCustomValidators() QCOMPARE( p.value( ctx ).toInt(), 123 ); // Test a range validator that increments the value - const QgsServerQueryStringParameter::customValidator validator = [ ]( const QgsServerApiContext &, QVariant & value ) -> bool - { + const QgsServerQueryStringParameter::customValidator validator = []( const QgsServerApiContext &, QVariant &value ) -> bool { const auto v { value.toLongLong() }; // Change the value by adding 1 value.setValue( v + 1 ); @@ -160,7 +158,6 @@ void TestQgsServerQueryStringParameter::testCustomValidators() request.setUrl( QStringLiteral( "http://www.qgis.org/api/?parameter1=501" ) ); QCOMPARE( p.value( ctx ).toInt(), 502 ); QCOMPARE( static_cast( p.value( ctx ).userType() ), QMetaType::Type::LongLong ); - } void TestQgsServerQueryStringParameter::testDefaultValues() @@ -177,7 +174,6 @@ void TestQgsServerQueryStringParameter::testDefaultValues() QCOMPARE( p2.value( ctx ).toInt(), 10 ); request.setUrl( QStringLiteral( "http://www.qgis.org/api/?parameter1=501" ) ); QCOMPARE( p2.value( ctx ).toInt(), 501 ); - } void TestQgsServerQueryStringParameter::testParseInput() diff --git a/tests/src/server/wms/test_qgsserver_wms_parameters.cpp b/tests/src/server/wms/test_qgsserver_wms_parameters.cpp index d35cf80da1ce..792325c642b1 100644 --- a/tests/src/server/wms/test_qgsserver_wms_parameters.cpp +++ b/tests/src/server/wms/test_qgsserver_wms_parameters.cpp @@ -95,8 +95,6 @@ void TestQgsServerWmsParameters::external_layers() QgsWms::QgsWmsParametersLayer layer_params2 = layers_params2[0]; QCOMPARE( layer_params2.mNickname, QString( "external_layer_1" ) ); QCOMPARE( layer_params2.mExternalUri, QString( "layers=layer_1_name&url=http://url_1" ) ); - - } void TestQgsServerWmsParameters::percent_encoding() @@ -199,9 +197,7 @@ void TestQgsServerWmsParameters::prefixed_layers() query.addQueryItem( "LAYERS", "a,b" ); QgsWms::QgsWmsParameters parameters1( query ); - QCOMPARE( parameters1.allLayersNickname(), QStringList() - << QStringLiteral( "a" ) - << QStringLiteral( "b" ) ); + QCOMPARE( parameters1.allLayersNickname(), QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) ); query.addQueryItem( "map0:LAYERS", "b,c" ); query.addQueryItem( "map1:LAYERS", "c,d" ); @@ -215,12 +211,7 @@ void TestQgsServerWmsParameters::prefixed_layers() QCOMPARE( params.at( 2 ).mNickname, QStringLiteral( "c" ) ); QCOMPARE( params.at( 3 ).mNickname, QStringLiteral( "d" ) ); - QCOMPARE( parameters.allLayersNickname(), QStringList() - << QStringLiteral( "a" ) - << QStringLiteral( "b" ) - << QStringLiteral( "c" ) - << QStringLiteral( "d" ) ); - + QCOMPARE( parameters.allLayersNickname(), QStringList() << QStringLiteral( "a" ) << QStringLiteral( "b" ) << QStringLiteral( "c" ) << QStringLiteral( "d" ) ); } QGSTEST_MAIN( TestQgsServerWmsParameters )